8
0

select.scss 5.6 KB

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