select.scss 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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. }
  73. }
  74. @include e(prefix) {
  75. display: flex;
  76. align-items: center;
  77. flex-shrink: 0;
  78. gap: map.get($select-item-gap, 'default');
  79. color: var(
  80. #{getCssVarName('input-icon-color')},
  81. map.get($input, 'icon-color')
  82. );
  83. }
  84. @include e(suffix) {
  85. display: flex;
  86. align-items: center;
  87. flex-shrink: 0;
  88. gap: map.get($select-item-gap, 'default');
  89. color: var(
  90. #{getCssVarName('input-icon-color')},
  91. map.get($input, 'icon-color')
  92. );
  93. }
  94. @include e(caret) {
  95. color: getCssVar('select-input-color');
  96. font-size: getCssVar('select-input-font-size');
  97. transition: getCssVar('transition', 'duration');
  98. transform: rotateZ(0deg);
  99. cursor: pointer;
  100. @include when(reverse) {
  101. transform: rotateZ(180deg);
  102. }
  103. }
  104. @include e(clear) {
  105. cursor: pointer;
  106. &:hover {
  107. color: getCssVar('select-close-hover-color');
  108. }
  109. }
  110. @include e(selection) {
  111. position: relative;
  112. display: flex;
  113. flex-wrap: wrap;
  114. align-items: center;
  115. flex: 1;
  116. min-width: 0;
  117. gap: map.get($select-item-gap, 'default');
  118. @include when(near) {
  119. margin-left: map.get($select-near-margin-left, 'default');
  120. }
  121. .#{$namespace}-tag {
  122. cursor: pointer;
  123. border-color: transparent;
  124. &.#{$namespace}-tag--plain {
  125. border-color: getCssVar('tag', 'border-color');
  126. }
  127. .#{$namespace}-tag__content {
  128. min-width: 0;
  129. }
  130. }
  131. }
  132. @include e(selected-item) {
  133. display: flex;
  134. flex-wrap: wrap;
  135. user-select: none;
  136. }
  137. @include e(tags-text) {
  138. display: block;
  139. line-height: normal;
  140. @include utils-ellipsis;
  141. }
  142. @include e(placeholder) {
  143. position: absolute;
  144. z-index: -1;
  145. display: block;
  146. top: 50%;
  147. transform: translateY(-50%);
  148. width: 100%;
  149. @include utils-ellipsis;
  150. color: var(
  151. #{getCssVarName('input-text-color')},
  152. map.get($input, 'text-color')
  153. );
  154. @include when(transparent) {
  155. user-select: none;
  156. color: getCssVar('text-color', 'placeholder');
  157. }
  158. }
  159. @include e(popper) {
  160. @include picker-popper(
  161. map.get($select-dropdown, 'bg-color'),
  162. map.get($select-dropdown, 'border'),
  163. map.get($select-dropdown, 'shadow')
  164. );
  165. }
  166. @include e(input-wrapper) {
  167. flex: 1;
  168. @include when(hidden) {
  169. // Out of the document flow
  170. position: absolute;
  171. opacity: 0;
  172. z-index: -1;
  173. }
  174. }
  175. @include e(input) {
  176. border: none;
  177. outline: none;
  178. padding: 0;
  179. color: getCssVar('select-multiple-input-color');
  180. font-size: inherit;
  181. font-family: inherit;
  182. appearance: none;
  183. height: map.get($select-item-height, 'default');
  184. width: 100%;
  185. background-color: transparent;
  186. @include when(disabled) {
  187. cursor: not-allowed;
  188. }
  189. }
  190. @include e(input-calculator) {
  191. position: absolute;
  192. left: 0;
  193. top: 0;
  194. max-width: 100%;
  195. visibility: hidden;
  196. white-space: pre;
  197. overflow: hidden;
  198. }
  199. @each $size in (large, small) {
  200. @include m($size) {
  201. @include e(wrapper) {
  202. gap: map.get($select-item-gap, $size);
  203. padding: map.get($select-wrapper-padding, $size);
  204. min-height: map.get($input-height, $size);
  205. line-height: map.get($select-item-height, $size);
  206. font-size: map.get($input-font-size, $size);
  207. }
  208. @include e(selection) {
  209. gap: map.get($select-item-gap, $size);
  210. @include when(near) {
  211. margin-left: map.get($select-near-margin-left, $size);
  212. }
  213. }
  214. @include e(prefix) {
  215. gap: map.get($select-item-gap, $size);
  216. }
  217. @include e(suffix) {
  218. gap: map.get($select-item-gap, $size);
  219. }
  220. @include e(input) {
  221. height: map.get($select-item-height, $size);
  222. }
  223. }
  224. }
  225. }