select.scss 14 KB

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