select.scss 10 KB

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