select.scss 10 KB

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