select.scss 11 KB

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