select.scss 15 KB

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