select.scss 13 KB

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