select.scss 11 KB

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