select.scss 10 KB

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