select.scss 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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--plain {
  117. border-color: getCssVar('tag', 'border-color');
  118. }
  119. .#{$namespace}-tag__content {
  120. min-width: 0;
  121. }
  122. }
  123. }
  124. @include e(selected-item) {
  125. display: flex;
  126. flex-wrap: wrap;
  127. user-select: none;
  128. }
  129. @include e(tags-text) {
  130. display: block;
  131. line-height: normal;
  132. @include utils-ellipsis;
  133. }
  134. @include e(placeholder) {
  135. position: absolute;
  136. display: block;
  137. top: 50%;
  138. transform: translateY(-50%);
  139. width: 100%;
  140. @include utils-ellipsis;
  141. color: var(
  142. #{getCssVarName('input-text-color')},
  143. map.get($input, 'text-color')
  144. );
  145. @include when(transparent) {
  146. user-select: none;
  147. color: getCssVar('text-color', 'placeholder');
  148. }
  149. }
  150. @include e(popper) {
  151. @include picker-popper(
  152. map.get($select-dropdown, 'bg-color'),
  153. map.get($select-dropdown, 'border'),
  154. map.get($select-dropdown, 'shadow')
  155. );
  156. }
  157. @include e(input-wrapper) {
  158. max-width: 100%;
  159. @include when(hidden) {
  160. // Out of the document flow
  161. position: absolute;
  162. opacity: 0;
  163. }
  164. }
  165. @include e(input) {
  166. border: none;
  167. outline: none;
  168. padding: 0;
  169. color: getCssVar('select-multiple-input-color');
  170. font-size: inherit;
  171. font-family: inherit;
  172. appearance: none;
  173. height: map.get($select-item-height, 'default');
  174. max-width: 100%;
  175. background-color: transparent;
  176. @include when(disabled) {
  177. cursor: not-allowed;
  178. }
  179. }
  180. @include e(input-calculator) {
  181. position: absolute;
  182. left: 0;
  183. top: 0;
  184. max-width: 100%;
  185. visibility: hidden;
  186. white-space: pre;
  187. overflow: hidden;
  188. }
  189. @each $size in (large, small) {
  190. @include m($size) {
  191. @include e(wrapper) {
  192. gap: map.get($select-item-gap, $size);
  193. padding: map.get($select-wrapper-padding, $size);
  194. min-height: map.get($input-height, $size);
  195. line-height: map.get($select-item-height, $size);
  196. font-size: map.get($input-font-size, $size);
  197. }
  198. @include e(selection) {
  199. gap: map.get($select-item-gap, $size);
  200. @include when(near) {
  201. margin-left: map.get($select-near-margin-left, $size);
  202. }
  203. }
  204. @include e(prefix) {
  205. gap: map.get($select-item-gap, $size);
  206. }
  207. @include e(suffix) {
  208. gap: map.get($select-item-gap, $size);
  209. }
  210. @include e(input) {
  211. height: map.get($select-item-height, $size);
  212. }
  213. }
  214. }
  215. }