select.scss 10 KB

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