select.scss 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. //@import '../theme/variables.scss';
  2. @import "./animation.scss";
  3. @import './variables.scss';
  4. @import './option.scss';
  5. @import './mixin.scss';
  6. $module: #{$prefix}-select;
  7. $single: #{$module}-single;
  8. $filterable: #{$module}-filterable;
  9. $multiple: #{$module}-multiple;
  10. $overflowList: #{$prefix}-overflow-list;
  11. .#{$module} {
  12. box-sizing: border-box;
  13. border-radius: $radius-select;
  14. border: $width-select-border solid $color-select-border-default;
  15. height: $height-select_default;
  16. font-weight: $font-select-fontWeight;
  17. background-color: $color-select-bg-default;
  18. // display: inline-block;
  19. display: inline-flex;
  20. vertical-align: middle;
  21. position: relative;
  22. outline: none;
  23. cursor: pointer;
  24. transition: background-color $transition_duration-select-bg $transition_function-select-bg $transition_delay-select-bg, border $transition_duration-select-border $transition_function-select-border $transition_delay-select-border;
  25. transform: scale($transform_scale-select);
  26. max-height: 300px;
  27. overflow-y: auto;
  28. &:hover {
  29. background-color: $color-select-bg-hover;
  30. border: $width-select-border-hover solid $color-select-border-hover;
  31. }
  32. &:focus {
  33. border: $width-select-border-focus solid $color-select-border-focus;
  34. outline: 0;
  35. }
  36. &-small {
  37. height: $height-select_small;
  38. line-height: $height-select_small;
  39. }
  40. &-large {
  41. min-height: $height-select_large;
  42. line-height: $height-select_large;
  43. .#{$module}-selection {
  44. @include font-size-header-6;
  45. }
  46. }
  47. &-open,
  48. &-focus {
  49. border: $border-thickness-control-focus solid $color-select_default-border-focus;
  50. outline: 0;
  51. &:hover {
  52. background-color: $color-select-bg-default;
  53. border: $border-thickness-control-focus solid $color-select_default-border-focus;
  54. }
  55. // when click the trigger, trigger get the focus state, active style should take effect
  56. &:active {
  57. background-color: $color-select-bg-active;
  58. border: $width-select-border-active solid $color-select-border-active;
  59. }
  60. }
  61. &-warning {
  62. background-color: $color-select_warning-bg-default;
  63. border-color: $color-select_warning-border-default;
  64. &:hover {
  65. background-color: $color-select_warning-bg-hover;
  66. border-color: $color-select_warning-border-hover;
  67. }
  68. &:focus {
  69. background-color: $color-select_warning-bg-focus;
  70. border-color: $color-select_warning-border-focus;
  71. }
  72. &:active {
  73. background-color: $color-select_warning-bg-active;
  74. border-color: $color-select_warning-border-active;
  75. }
  76. }
  77. &-error {
  78. background-color: $color-select_danger-bg-default;
  79. border-color: $color-select_danger-border-default;
  80. &:hover {
  81. background-color: $color-select_danger-bg-hover;
  82. border-color: $color-select_danger-border-hover;
  83. }
  84. &:focus {
  85. background-color: $color-select_danger-bg-focus;
  86. border-color: $color-select_danger-border-focus;
  87. }
  88. &:active {
  89. background-color: $color-select_danger-bg-active;
  90. border-color: $color-select_danger-border-active;
  91. }
  92. }
  93. &-disabled {
  94. cursor: not-allowed;
  95. background-color: $color-select_input_disabled-bg;
  96. // border: 1px solid $color-select_input_disabled-border;
  97. &:hover {
  98. background-color: $color-select_input_disabled-bg-hover;
  99. }
  100. &:focus {
  101. // border: $border-thickness-control-focus solid $color-select_default-border-focus;
  102. // when select is disabled, the border should not have active color
  103. border: $border-thickness-control-focus solid transparent;
  104. }
  105. .#{$module}-selection,
  106. .#{$module}-selection-placeholder {
  107. color: $color-select_input_disabled-text;
  108. cursor: not-allowed;
  109. }
  110. .#{$module}-arrow,
  111. .#{$module}-prefix,
  112. .#{$module}-suffix {
  113. color: $color-select_input_disabled-text;
  114. }
  115. .#{$prefix}-tag {
  116. color: $color-select_input_disabled-text;
  117. background-color: transparent;
  118. }
  119. }
  120. &-selection {
  121. @include font-size-regular;
  122. height: 100%;
  123. display: flex;
  124. align-items: center;
  125. flex-grow: 1;
  126. overflow: hidden;
  127. margin-left: $spacing-select_selection-marginLeft;
  128. // margin-right: $width-select_icon_right;
  129. cursor: pointer;
  130. color: $color-select_main-text-default;
  131. &-text {
  132. // display: inline-flex;
  133. // align-items: center;
  134. // height: 100%;
  135. width: 100%;
  136. overflow: hidden;
  137. text-overflow: ellipsis;
  138. &-inactive {
  139. display: flex;
  140. opacity: $opacity-select_selection_text_inactive;
  141. }
  142. &-hide {
  143. display: none;
  144. }
  145. }
  146. &-placeholder {
  147. color: $color-select_input_placeholder-text;
  148. }
  149. .#{$prefix}-tag {
  150. &:nth-of-type(1) {
  151. margin-left: 0;
  152. }
  153. @include select-tag-margin;
  154. }
  155. .#{$prefix}-tag-group {
  156. height: inherit;
  157. .#{$prefix}-tag {
  158. @include select-tag-margin;
  159. }
  160. }
  161. }
  162. &-content-wrapper {
  163. white-space: nowrap;
  164. overflow: hidden;
  165. display: flex;
  166. align-items: center;
  167. height: 100%;
  168. &-collapse {
  169. display: inline-flex;
  170. flex-shrink: 0;
  171. width: 100%;
  172. .#{$overflowList}-overflow {
  173. max-width: 100%; // when one tag exceed the max width
  174. min-width: 50px;
  175. }
  176. &>&-tag {
  177. background-color: transparent;
  178. }
  179. &>&-N {
  180. background-color: transparent;
  181. padding: 4px;
  182. color: var(--semi-color-text-0);
  183. font-size: 12px;
  184. }
  185. }
  186. }
  187. &-multiple {
  188. // 这里要设置为 auto,可能存在换行
  189. height: auto;
  190. .#{$module}-selection {
  191. margin-left: $spacing-select_multiple_selection-marginLeft;
  192. // &-placeholder {
  193. // padding-left: $spacing-base-tight - $spacing-extra-tight;
  194. // }
  195. }
  196. .#{$module}-content-wrapper {
  197. width: 100%;
  198. min-height: $height-select_multiple_content_wrapper-minHeight;
  199. flex-wrap: wrap;
  200. &-empty {
  201. margin-left: $spacing-select_multiple_content_wrapper_empty-marginLeft;
  202. }
  203. .#{$prefix}-tag-group {
  204. display: flex;
  205. align-items: center;
  206. }
  207. &-one-line {
  208. flex-wrap: nowrap;
  209. .#{$prefix}-tag-group {
  210. flex-wrap: nowrap;
  211. justify-content: flex-start;
  212. overflow: hidden;
  213. flex-shrink: 0;
  214. }
  215. }
  216. }
  217. .#{$module}-inline-label-wrapper {
  218. flex-shrink: 0;
  219. }
  220. }
  221. &-multiple.#{$module}-large {
  222. .#{$module}-content-wrapper {
  223. min-height: $height-select_large - 2;
  224. }
  225. }
  226. &-multiple.#{$module}-small {
  227. .#{$module}-content-wrapper {
  228. min-height: $height-select_small - 2;
  229. }
  230. }
  231. &-arrow {
  232. display: flex;
  233. align-items: center;
  234. justify-content: center;
  235. width: $width-select_arrow;
  236. color: $color-select-icon-default;
  237. flex-shrink: 0;
  238. transform: rotate($transform_rotate-select-arrow);
  239. &-empty {
  240. // 不显示arrow时,右侧留出12px空白
  241. display: flex;
  242. width: $width-select_arrow_empty;
  243. }
  244. }
  245. &-prefix,
  246. &-suffix {
  247. @include all-center;
  248. &-text {
  249. margin: $spacing-select_prefix_suffix_text-marginY $spacing-select_prefix_suffix_text-marginX;
  250. }
  251. &-icon {
  252. color: $color-select-icon-default;
  253. margin: $spacing-select_prefix_suffix_icon-marginY $spacing-select_prefix_suffix_icon-marginX;
  254. }
  255. }
  256. &-suffix {
  257. @include all-center;
  258. }
  259. &-clear {
  260. @include all-center;
  261. width: $width-select_clear-icon;
  262. color: $color-select_clearBtn-text-default;
  263. flex-shrink: 0;
  264. &:hover {
  265. color: $color-select_clearBtn-text-hover;
  266. }
  267. }
  268. &-inset-label-wrapper {
  269. display: inline;
  270. }
  271. &-inset-label {
  272. margin-right: $spacing-base-tight;
  273. font-weight: $font-select_inset_label-fontWeight;
  274. @include font-size-regular;
  275. color: $color-select_inset_label-text;
  276. flex-shrink: 0;
  277. white-space: nowrap;
  278. }
  279. &-create-tips {
  280. color: $color-select_create_tips-text;
  281. margin-right: $spacing-select_create_tips-marginRight;
  282. }
  283. }
  284. .#{$module}-with-prefix {
  285. .#{$module}-selection {
  286. margin-left: 0;
  287. }
  288. }
  289. // 单选且可输入
  290. .#{$single}.#{$filterable} {
  291. .#{$module}-content-wrapper {
  292. flex-grow: 1;
  293. height: 100%;
  294. overflow: hidden;
  295. position: relative;
  296. }
  297. .#{$prefix}-input-wrapper {
  298. position: absolute;
  299. top: 0;
  300. left: 0;
  301. height: 100%;
  302. width: 100%;
  303. border: none;
  304. background-color: transparent;
  305. }
  306. .#{$prefix}-input-wrapper-focus {
  307. border: none;
  308. }
  309. .#{$prefix}-input {
  310. padding-left: 0;
  311. padding-right: 0;
  312. height: 100%; // 自定义renderSelectedItem时,Select的整体高度可能不是默认的32px
  313. }
  314. }
  315. // 多选且可输入
  316. .#{$multiple}.#{$filterable} {
  317. .#{$module}-content-wrapper {
  318. flex-grow: 1;
  319. height: 100%;
  320. overflow: hidden;
  321. position: relative;
  322. &-empty {
  323. .#{$prefix}-input-wrapper {
  324. position: absolute;
  325. top: 0;
  326. left: 0;
  327. height: 100%;
  328. width: 100%;
  329. }
  330. }
  331. }
  332. .#{$prefix}-input-wrapper {
  333. // position: absolute;
  334. // top: 0;
  335. // left: 0;
  336. height: 100%;
  337. width: 100%;
  338. border: none;
  339. background-color: transparent;
  340. }
  341. .#{$prefix}-input-wrapper-focus {
  342. border: none;
  343. }
  344. .#{$prefix}-input {
  345. padding-left: 0;
  346. padding-right: 0;
  347. }
  348. }
  349. .#{$module}-option-list-wrapper {
  350. padding-top: $spacing-select_option_list-paddingTop;
  351. padding-bottom: $spacing-select_option_list-paddingBottom;
  352. padding-left: $spacing-select_option_list-paddingLeft;
  353. padding-right: $spacing-select_option_list-paddingRight;
  354. }
  355. .#{$module}-option-list {
  356. overflow-x: hidden;
  357. overflow-y: auto;
  358. &-chosen {
  359. .#{$module}-option-icon {
  360. display: flex;
  361. }
  362. }
  363. }
  364. .#{$module}-group {
  365. color: $color-select_group-text;
  366. padding-top: $spacing-select_group-paddingTop;
  367. margin-top: $spacing-select_group-marginTop;
  368. padding-bottom: $spacing-select_group-paddingBottom;
  369. padding-left: $spacing-select_group-paddingLeft;
  370. padding-right: $spacing-select_group-paddingRight;
  371. @include font-size-small;
  372. cursor: default;
  373. // &:nth-of-type(1) {
  374. // margin-top: $spacing-extra-tight;
  375. // }
  376. &:not(:nth-of-type(1)) {
  377. border-top: $width-select_group_top-border solid $color-select_option-border-default;
  378. }
  379. }
  380. .#{$module}-loading-wrapper {
  381. padding-left: $spacing-select_loading_wrapper-paddingLeft;
  382. padding-right: $spacing-select_loading_wrapper-paddingRight;
  383. padding-top: $spacing-select_loading_wrapper-paddingTop;
  384. padding-bottom: $spacing-select_loading_wrapper-paddingBottom;
  385. cursor: not-allowed;
  386. // make sure that spin align vertical, no need to make 20px as a spacing token here
  387. height: 20px;
  388. }
  389. @import './rtl.scss';