select-v2.scss 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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-v2.scss';
  7. @use './option-item.scss';
  8. @use './option-group.scss';
  9. @use './select/common.scss' as *;
  10. $input-inline-start: map.get($input-padding-horizontal, 'default') !default;
  11. @include b(select-v2) {
  12. @include set-component-css-var('select', $select);
  13. }
  14. @include b(select-v2) {
  15. display: inline-block;
  16. position: relative;
  17. vertical-align: middle;
  18. font-size: map.get($input-font-size, 'default');
  19. $selector: &;
  20. @include e(wrapper) {
  21. display: flex;
  22. align-items: center;
  23. flex-wrap: wrap;
  24. position: relative;
  25. box-sizing: border-box;
  26. cursor: pointer;
  27. padding: 1px 30px 1px 0;
  28. border: 1px solid getCssVar('border-color');
  29. border-radius: getCssVar('border-radius-base');
  30. background-color: getCssVar('fill-color', 'blank');
  31. transition: getCssVar('transition', 'duration');
  32. &:hover {
  33. border-color: getCssVar('text-color', 'placeholder');
  34. }
  35. @include when(filterable) {
  36. cursor: text;
  37. }
  38. @include when(focused) {
  39. border-color: getCssVar('color-primary');
  40. }
  41. @include when(hovering) {
  42. &:not(.is-focused) {
  43. border-color: getCssVar('border-color-hover');
  44. }
  45. }
  46. @include when(disabled) {
  47. cursor: not-allowed;
  48. background-color: getCssVar('fill-color', 'light');
  49. color: getCssVar('text-color', 'placeholder');
  50. border-color: getCssVar('select-disabled-border');
  51. &:hover {
  52. border-color: getCssVar('select-disabled-border');
  53. }
  54. &.is-focus {
  55. border-color: getCssVar('input-focus-border-color');
  56. }
  57. .is-transparent {
  58. opacity: 1;
  59. user-select: none;
  60. }
  61. #{$selector}__caret {
  62. cursor: not-allowed;
  63. }
  64. #{$selector}__combobox-input {
  65. cursor: not-allowed;
  66. }
  67. }
  68. #{$selector}__input-wrapper {
  69. box-sizing: border-box;
  70. position: relative;
  71. margin-inline-start: $input-inline-start;
  72. max-width: 100%;
  73. overflow: hidden;
  74. }
  75. &,
  76. #{$selector}__input-wrapper {
  77. line-height: map.get($input-height, 'default');
  78. }
  79. #{$selector}__input-wrapper input {
  80. @include set-css-var-value(
  81. 'input-inner-height',
  82. calc(
  83. var(
  84. #{getCssVarName('component-size')},
  85. #{map.get($input-height, 'default')}
  86. ) - 8px
  87. )
  88. );
  89. height: getCssVar('input-inner-height');
  90. line-height: getCssVar('input-inner-height');
  91. min-width: 4px;
  92. width: 100%;
  93. background-color: transparent;
  94. -webkit-appearance: none;
  95. -moz-appearance: none;
  96. appearance: none;
  97. background: 0 0;
  98. border: none;
  99. margin: 2px 0;
  100. outline: none;
  101. padding: 0;
  102. }
  103. }
  104. @include select-common(select-v2);
  105. @include e(empty) {
  106. padding: 10px 0;
  107. margin: 0;
  108. text-align: center;
  109. color: getCssVar('text-color', 'secondary');
  110. font-size: 14px;
  111. }
  112. @include e(popper) {
  113. @include picker-popper(
  114. map.get($select-dropdown, 'bg-color'),
  115. map.get($select-dropdown, 'border'),
  116. map.get($select-dropdown, 'shadow')
  117. );
  118. }
  119. @each $size in (large, small) {
  120. @include m($size) {
  121. @include e(wrapper) {
  122. #{$selector}__combobox-input {
  123. height: map.get($input-height, $size) - 8px;
  124. }
  125. }
  126. @include e(caret) {
  127. height: map.get($input-height, $size);
  128. }
  129. @include e(suffix) {
  130. height: map.get($input-height, $size);
  131. }
  132. @include e(placeholder) {
  133. font-size: map.get($input-font-size, $size);
  134. line-height: map.get($input-line-height, $size);
  135. }
  136. }
  137. }
  138. #{$selector}__selection > span {
  139. display: inline-block;
  140. }
  141. &:hover {
  142. #{$selector}__combobox-input {
  143. border-color: getCssVar('select-border-color-hover');
  144. }
  145. }
  146. .#{$namespace}-select__selection-text {
  147. text-overflow: ellipsis;
  148. display: inline-block;
  149. overflow-x: hidden;
  150. vertical-align: bottom;
  151. }
  152. #{$selector}__combobox-input {
  153. padding-right: 35px;
  154. display: block;
  155. color: getCssVar('text-color', 'regular');
  156. &:focus {
  157. border-color: getCssVar('select-input-focus-border-color');
  158. }
  159. }
  160. @include e(input) {
  161. border: none;
  162. outline: none;
  163. padding: 0;
  164. margin-left: 15px;
  165. color: getCssVar('select-multiple-input-color');
  166. font-size: getCssVar('select-font-size');
  167. appearance: none;
  168. height: 28px;
  169. @include when(small) {
  170. height: 14px;
  171. }
  172. }
  173. @include e(close) {
  174. cursor: pointer;
  175. position: absolute;
  176. top: 8px;
  177. z-index: getCssVar('index-top');
  178. right: 25px;
  179. color: getCssVar('select-input-color');
  180. line-height: 18px;
  181. font-size: getCssVar('select-input-font-size');
  182. &:hover {
  183. color: getCssVar('select-close-hover-color');
  184. }
  185. }
  186. @include e(suffix) {
  187. display: inline-flex;
  188. position: absolute;
  189. right: 12px;
  190. height: 32px;
  191. top: 50%;
  192. transform: translateY(-50%);
  193. color: var(
  194. #{getCssVarName('input-icon-color')},
  195. map.get($input, 'icon-color')
  196. );
  197. .#{$namespace}-input__icon {
  198. height: inherit;
  199. &:not(:first-child) {
  200. margin-left: 8px;
  201. }
  202. }
  203. }
  204. @include e(caret) {
  205. color: getCssVar('select-input-color');
  206. font-size: getCssVar('select-input-font-size');
  207. transition: getCssVar('transition', 'duration');
  208. transform: rotateZ(180deg);
  209. cursor: pointer;
  210. @include when(reverse) {
  211. transform: rotateZ(0deg);
  212. }
  213. @include when(show-close) {
  214. font-size: getCssVar('select-font-size');
  215. text-align: center;
  216. transform: rotateZ(180deg);
  217. border-radius: getCssVar('border-radius-circle');
  218. color: getCssVar('select-input-color');
  219. transition: getCssVar('transition', 'color');
  220. &:hover {
  221. color: getCssVar('select', 'close-hover-color');
  222. }
  223. }
  224. &.#{$namespace}-icon {
  225. height: inherit;
  226. svg {
  227. vertical-align: middle;
  228. }
  229. }
  230. }
  231. @include e(selection) {
  232. white-space: normal;
  233. z-index: getCssVar('index-normal');
  234. display: flex;
  235. align-items: center;
  236. flex-wrap: wrap;
  237. width: 100%;
  238. }
  239. @include e(input-calculator) {
  240. left: 0;
  241. position: absolute;
  242. top: 0;
  243. visibility: hidden;
  244. white-space: pre;
  245. z-index: 999;
  246. }
  247. @include e(selected-item) {
  248. line-height: inherit;
  249. height: inherit;
  250. user-select: none;
  251. // using this to keep the item centered in both vertically and horizontally
  252. display: flex;
  253. flex-wrap: wrap;
  254. }
  255. @include e(placeholder) {
  256. position: absolute;
  257. top: 50%;
  258. transform: translateY(-50%);
  259. margin-inline-start: $input-inline-start;
  260. width: calc(100% - 52px);
  261. @include utils-ellipsis;
  262. color: var(
  263. #{getCssVarName('input-text-color')},
  264. map.get($input, 'text-color')
  265. );
  266. @include when(transparent) {
  267. color: getCssVar('text-color', 'placeholder');
  268. }
  269. }
  270. .#{$namespace}-select-v2__selection .#{$namespace}-tag {
  271. box-sizing: border-box;
  272. border-color: transparent;
  273. margin: 2px 0 2px 6px;
  274. background-color: getCssVar('fill-color');
  275. .#{$namespace}-icon-close {
  276. background-color: getCssVar('text-color', 'placeholder');
  277. right: -7px;
  278. color: getCssVar('color-white');
  279. &:hover {
  280. background-color: getCssVar('text-color', 'secondary');
  281. }
  282. &::before {
  283. display: block;
  284. transform: translate(0, 0.5px);
  285. }
  286. }
  287. }
  288. &.#{$namespace}-select-v2--small {
  289. .#{$namespace}-select-v2__selection .#{$namespace}-tag {
  290. margin: 1px 0 1px 6px;
  291. height: 18px;
  292. }
  293. }
  294. }