select.scss 11 KB

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