2f888b86565014905818ed4426c45ce9932b2bfd50574488da5e87b7a6b405595513bf7b98378129255c8ffb5e8a8a591ee18b122d18c823834819aa712c66 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. @use 'sass:map';
  2. @use 'mixins/mixins' as *;
  3. @use 'mixins/utils' as *;
  4. @use 'mixins/var' as *;
  5. @use 'common/var' as *;
  6. @use './select-dropdown.scss';
  7. @use './option.scss';
  8. @use './option-group.scss';
  9. @mixin mixed-input-border($color) {
  10. box-shadow: 0 0 0 1px $color inset;
  11. }
  12. @include b(select) {
  13. @include set-component-css-var('select', $select);
  14. }
  15. @include b(select) {
  16. display: inline-block;
  17. position: relative;
  18. vertical-align: middle;
  19. width: getCssVar('select-width');
  20. @include e(wrapper) {
  21. display: flex;
  22. align-items: center;
  23. position: relative;
  24. box-sizing: border-box;
  25. cursor: pointer;
  26. text-align: left;
  27. font-size: map.get($input-font-size, 'default');
  28. padding: map.get($select-wrapper-padding, 'default');
  29. gap: map.get($select-item-gap, 'default');
  30. min-height: map.get($input-height, 'default');
  31. line-height: map.get($select-item-height, 'default');
  32. border-radius: getCssVar('border-radius-base');
  33. background-color: getCssVar('fill-color', 'blank');
  34. transition: getCssVar('transition', 'duration');
  35. transform: translate3d(0, 0, 0);
  36. @include mixed-input-border(#{getCssVar('border-color')});
  37. @include when(filterable) {
  38. cursor: text;
  39. }
  40. @include when(focused) {
  41. @include mixed-input-border(#{getCssVar('color-primary')});
  42. }
  43. @include when(hovering) {
  44. &:not(.is-focused) {
  45. @include mixed-input-border(#{getCssVar('border-color-hover')});
  46. }
  47. }
  48. @include when(disabled) {
  49. cursor: not-allowed;
  50. background-color: getCssVar('fill-color', 'light');
  51. color: getCssVar('text-color', 'placeholder');
  52. @include mixed-input-border(#{getCssVar('select-disabled-border')});
  53. &:hover {
  54. @include mixed-input-border(#{getCssVar('select-disabled-border')});
  55. }
  56. &.is-focus {
  57. @include mixed-input-border(#{getCssVar('input-focus-border-color')});
  58. }
  59. @include e(selected-item) {
  60. color: getCssVar('select-disabled-color');
  61. }
  62. @include e(caret) {
  63. cursor: not-allowed;
  64. }
  65. .#{$namespace}-tag {
  66. cursor: not-allowed;
  67. }
  68. // When the native input tag is disabled, the cursor value is the 'default'.
  69. input {
  70. cursor: not-allowed;
  71. }
  72. .#{$namespace}-select__prefix,
  73. .#{$namespace}-select__suffix {
  74. pointer-events: none;
  75. }
  76. }
  77. }
  78. @include e(prefix) {
  79. display: flex;
  80. align-items: center;
  81. flex-shrink: 0;
  82. gap: map.get($select-item-gap, 'default');
  83. color: var(
  84. #{getCssVarName('input-icon-color')},
  85. map.get($input, 'icon-color')
  86. );
  87. }
  88. @include e(suffix) {
  89. display: flex;
  90. align-items: center;
  91. flex-shrink: 0;
  92. gap: map.get($select-item-gap, 'default');
  93. color: var(
  94. #{getCssVarName('input-icon-color')},
  95. map.get($input, 'icon-color')
  96. );
  97. }
  98. @include e(caret) {
  99. color: getCssVar('select-input-color');
  100. font-size: getCssVar('select-input-font-size');
  101. transition: getCssVar('transition', 'duration');
  102. transform: rotateZ(0deg);
  103. cursor: pointer;
  104. @include when(reverse) {
  105. transform: rotateZ(180deg);
  106. }
  107. }
  108. @include e(clear) {
  109. cursor: pointer;
  110. &:hover {
  111. color: getCssVar('select-close-hover-color');
  112. }
  113. }
  114. @include e(selection) {
  115. position: relative;
  116. display: flex;
  117. flex-wrap: wrap;
  118. align-items: center;
  119. flex: 1;
  120. min-width: 0;
  121. gap: map.get($select-item-gap, 'default');
  122. @include when(near) {
  123. margin-left: map.get($select-near-margin-left, 'default');
  124. }
  125. .#{$namespace}-tag {
  126. cursor: pointer;
  127. border-color: transparent;
  128. &.#{$namespace}-tag--plain {
  129. border-color: getCssVar('tag', 'border-color');
  130. }
  131. .#{$namespace}-tag__content {
  132. min-width: 0;
  133. }
  134. }
  135. }
  136. @include e(selected-item) {
  137. display: flex;
  138. flex-wrap: wrap;
  139. user-select: none;
  140. }
  141. @include e(tags-text) {
  142. display: block;
  143. line-height: normal;
  144. @include utils-ellipsis;
  145. }
  146. @include e(placeholder) {
  147. position: absolute;
  148. z-index: -1;
  149. display: block;
  150. top: 50%;
  151. transform: translateY(-50%);
  152. width: 100%;
  153. @include utils-ellipsis;
  154. color: var(
  155. #{getCssVarName('input-text-color')},
  156. map.get($input, 'text-color')
  157. );
  158. @include when(transparent) {
  159. user-select: none;
  160. color: getCssVar('text-color', 'placeholder');
  161. }
  162. }
  163. @include e(popper) {
  164. @include picker-popper(
  165. map.get($select-dropdown, 'bg-color'),
  166. map.get($select-dropdown, 'border'),
  167. map.get($select-dropdown, 'shadow')
  168. );
  169. }
  170. @include e(input-wrapper) {
  171. flex: 1;
  172. @include when(hidden) {
  173. // Out of the document flow
  174. position: absolute;
  175. opacity: 0;
  176. z-index: -1;
  177. }
  178. }
  179. @include e(input) {
  180. border: none;
  181. outline: none;
  182. padding: 0;
  183. color: getCssVar('select-multiple-input-color');
  184. font-size: inherit;
  185. font-family: inherit;
  186. appearance: none;
  187. height: map.get($select-item-height, 'default');
  188. width: 100%;
  189. background-color: transparent;
  190. @include when(disabled) {
  191. cursor: not-allowed;
  192. }
  193. }
  194. @include e(input-calculator) {
  195. position: absolute;
  196. left: 0;
  197. top: 0;
  198. max-width: 100%;
  199. visibility: hidden;
  200. white-space: pre;
  201. overflow: hidden;
  202. }
  203. @each $size in (large, small) {
  204. @include m($size) {
  205. @include e(wrapper) {
  206. gap: map.get($select-item-gap, $size);
  207. padding: map.get($select-wrapper-padding, $size);
  208. min-height: map.get($input-height, $size);
  209. line-height: map.get($select-item-height, $size);
  210. font-size: map.get($input-font-size, $size);
  211. }
  212. @include e(selection) {
  213. gap: map.get($select-item-gap, $size);
  214. @include when(near) {
  215. margin-left: map.get($select-near-margin-left, $size);
  216. }
  217. }
  218. @include e(prefix) {
  219. gap: map.get($select-item-gap, $size);
  220. }
  221. @include e(suffix) {
  222. gap: map.get($select-item-gap, $size);
  223. }
  224. @include e(input) {
  225. height: map.get($select-item-height, $size);
  226. }
  227. }
  228. }
  229. }