select.scss 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. @include mixed-input-border(#{getCssVar('border-color')});
  36. &:hover {
  37. @include mixed-input-border(#{getCssVar('text-color')});
  38. }
  39. @include when(filterable) {
  40. cursor: text;
  41. }
  42. @include when(focused) {
  43. @include mixed-input-border(#{getCssVar('color-primary')});
  44. }
  45. @include when(hovering) {
  46. &:not(.is-focused) {
  47. @include mixed-input-border(#{getCssVar('border-color-hover')});
  48. }
  49. }
  50. @include when(disabled) {
  51. cursor: not-allowed;
  52. background-color: getCssVar('fill-color', 'light');
  53. color: getCssVar('text-color', 'placeholder');
  54. @include mixed-input-border(#{getCssVar('select-disabled-border')});
  55. &:hover {
  56. @include mixed-input-border(#{getCssVar('select-disabled-border')});
  57. }
  58. &.is-focus {
  59. @include mixed-input-border(#{getCssVar('input-focus-border-color')});
  60. }
  61. @include e(caret) {
  62. cursor: not-allowed;
  63. }
  64. .#{$namespace}-tag {
  65. cursor: not-allowed;
  66. }
  67. }
  68. }
  69. @include e(prefix) {
  70. display: flex;
  71. align-items: center;
  72. flex-shrink: 0;
  73. gap: map.get($select-item-gap, 'default');
  74. color: var(
  75. #{getCssVarName('input-icon-color')},
  76. map.get($input, 'icon-color')
  77. );
  78. }
  79. @include e(suffix) {
  80. display: flex;
  81. align-items: center;
  82. flex-shrink: 0;
  83. gap: map.get($select-item-gap, 'default');
  84. color: var(
  85. #{getCssVarName('input-icon-color')},
  86. map.get($input, 'icon-color')
  87. );
  88. }
  89. @include e(caret) {
  90. color: getCssVar('select-input-color');
  91. font-size: getCssVar('select-input-font-size');
  92. transition: getCssVar('transition', 'duration');
  93. transform: rotateZ(0deg);
  94. cursor: pointer;
  95. @include when(reverse) {
  96. transform: rotateZ(180deg);
  97. }
  98. }
  99. @include e(selection) {
  100. position: relative;
  101. display: flex;
  102. flex-wrap: wrap;
  103. align-items: center;
  104. flex: 1;
  105. min-width: 0;
  106. gap: map.get($select-item-gap, 'default');
  107. @include when(near) {
  108. margin-left: map.get($select-near-margin-left, 'default');
  109. }
  110. .#{$namespace}-tag {
  111. cursor: pointer;
  112. border-color: transparent;
  113. .#{$namespace}-tag__content {
  114. min-width: 0;
  115. }
  116. }
  117. }
  118. @include e(selected-item) {
  119. display: flex;
  120. flex-wrap: wrap;
  121. user-select: none;
  122. }
  123. @include e(tags-text) {
  124. display: block;
  125. line-height: normal;
  126. @include utils-ellipsis;
  127. }
  128. @include e(placeholder) {
  129. position: absolute;
  130. display: block;
  131. top: 50%;
  132. transform: translateY(-50%);
  133. width: 100%;
  134. @include utils-ellipsis;
  135. color: var(
  136. #{getCssVarName('input-text-color')},
  137. map.get($input, 'text-color')
  138. );
  139. @include when(transparent) {
  140. user-select: none;
  141. color: getCssVar('text-color', 'placeholder');
  142. }
  143. }
  144. @include e(popper) {
  145. @include picker-popper(
  146. map.get($select-dropdown, 'bg-color'),
  147. map.get($select-dropdown, 'border'),
  148. map.get($select-dropdown, 'shadow')
  149. );
  150. }
  151. @include e(input-wrapper) {
  152. max-width: 100%;
  153. @include when(hidden) {
  154. // Out of the document flow
  155. position: absolute;
  156. opacity: 0;
  157. }
  158. }
  159. @include e(input) {
  160. border: none;
  161. outline: none;
  162. padding: 0;
  163. color: getCssVar('select-multiple-input-color');
  164. font-size: inherit;
  165. appearance: none;
  166. height: map.get($select-item-height, 'default');
  167. max-width: 100%;
  168. background-color: transparent;
  169. @include when(disabled) {
  170. cursor: not-allowed;
  171. }
  172. }
  173. @include e(input-calculator) {
  174. position: absolute;
  175. left: 0;
  176. top: 0;
  177. max-width: 100%;
  178. visibility: hidden;
  179. white-space: nowrap;
  180. overflow: hidden;
  181. }
  182. @each $size in (large, small) {
  183. @include m($size) {
  184. @include e(wrapper) {
  185. gap: map.get($select-item-gap, $size);
  186. padding: map.get($select-wrapper-padding, $size);
  187. min-height: map.get($input-height, $size);
  188. line-height: map.get($select-item-height, $size);
  189. font-size: map.get($input-font-size, $size);
  190. }
  191. @include e(selection) {
  192. gap: map.get($select-item-gap, $size);
  193. @include when(near) {
  194. margin-left: map.get($select-near-margin-left, $size);
  195. }
  196. }
  197. @include e(prefix) {
  198. gap: map.get($select-item-gap, $size);
  199. }
  200. @include e(suffix) {
  201. gap: map.get($select-item-gap, $size);
  202. }
  203. @include e(input) {
  204. height: map.get($select-item-height, $size);
  205. }
  206. }
  207. }
  208. }