UNPKG

14.8 kBSCSSView Raw
1@charset "UTF-8";
2@import "../core/index-noreset.scss";
3@import "../input/scss/variable.scss";
4@import "../input/scss/mixin.scss";
5@import "scss/mixin";
6@import "scss/variable";
7
8#{$select-prefix} {
9 @include box-sizing;
10 display: inline-block;
11 position: relative;
12 font-size: 0;
13 vertical-align: middle;
14
15 /* Select trigger */
16 &-trigger {
17 min-width: 100px;
18 outline: 0;
19 transition: all $motion-duration-immediately $motion-linear;
20
21 .#{$css-prefix}input-label {
22 flex: 0 0 auto;
23 width: auto;
24 }
25
26 #{$select-prefix}-values {
27 display: block;
28 width: 100%;
29 flex: 1 1 0;
30 overflow: hidden;
31
32 > em {
33 font-style: inherit;
34 }
35
36 input {
37 padding-left: 0;
38 padding-right: 0;
39 }
40 }
41
42 .#{$css-prefix}input-control {
43 flex: 0 0 auto;
44 width: auto;
45 > * {
46 display: inline-block;
47 width: auto;
48 }
49 > .#{$css-prefix}select-arrow {
50 padding-right: 0;
51 }
52 }
53
54 .#{$css-prefix}input.#{$css-prefix}disabled {
55 em {
56 color: $input-disabled-color;
57 }
58 #{$select-prefix}-arrow {
59 cursor: not-allowed;
60 }
61 }
62
63 .#{$css-prefix}select-clear {
64 display: none;
65 }
66
67 &.#{$css-prefix}has-clear:hover {
68 .#{$css-prefix}select-clear {
69 display: inline-block;
70 }
71 .#{$css-prefix}select-arrow {
72 display: none;
73 }
74 }
75 }
76
77 #{$select-prefix}-inner {
78 display: inline-flex;
79 align-items: center;
80 width: 100%;
81 min-width: 100px;
82
83 outline: 0;
84 color: $select-color;
85
86 #{$tag-prefix} {
87 line-height: 1;
88 margin-right: $select-tag-spacing-lr;
89 margin-bottom: $select-tag-spacing-tb;
90 // TODO: removed next 2 line in next version
91 padding-left: $select-tag-padding-lr;
92 padding-right: $select-tag-padding-lr;
93 }
94
95 .#{$css-prefix}input-inner {
96 width: auto;
97 }
98 }
99
100 &-trigger-search {
101 position: relative;
102 display: inline-block;
103 vertical-align: top;
104 overflow: hidden;
105 width: 100%;
106 max-width: 100%;
107
108 > input, > span {
109 display: block;
110 font-size: inherit;
111 font-family: inherit;
112 letter-spacing: inherit;
113 white-space: nowrap;
114 overflow: hidden;
115 }
116
117 input {
118 position: absolute;
119 background-color: $color-transparent;
120 width: 100%;
121 height: 100% !important;
122 z-index: 1;
123 left: 0;
124 border: 0;
125 outline: 0;
126 margin: 0;
127 padding: 0;
128 cursor: inherit;
129 }
130
131 > span {
132 position: relative;
133 visibility: hidden;
134 white-space: pre;
135 max-width: 100%; /* 在 table 布局中,100% 并没有什么x用 */
136 z-index: -1;
137 }
138 }
139
140 &-single {
141 &.#{$css-prefix}no-search {
142 cursor: pointer;
143 }
144
145 /* 搜索框激活时,展开后不显示值,只显示搜索框 */
146 &.#{$css-prefix}has-search.#{$css-prefix}active {
147 #{$select-prefix}-values > em {
148 display: none;
149 }
150 }
151
152 /* 搜索框未激活,或者menu未展开,如果有值,则不显示搜索(placeholder) */
153 &.#{$css-prefix}no-search,
154 &.#{$css-prefix}inactive {
155 #{$select-prefix}-values > em + #{$select-prefix}-trigger-search {
156 width: 1px;
157 opacity: 0;
158 /* stylelint-disable */
159 filter: alpha(opacity=0); /* for IE 9 */
160 /* stylelint-enable */
161 }
162 }
163
164 #{$select-prefix}-values {
165 display: inline-flex;
166 align-items: center;
167
168 > em {
169 vertical-align: middle;
170 overflow: hidden;
171 text-overflow: ellipsis;
172 white-space: nowrap;
173 }
174 }
175 }
176
177 &-multiple {
178 #{$select-prefix}-compact {
179 position: relative;
180 white-space: nowrap;
181 #{$select-prefix}-trigger-search {
182 width: auto;
183 }
184 #{$select-prefix}-tag-compact {
185 position: absolute;
186 top: 0;
187 right: 0;
188 z-index: 1;
189 padding: 0 4px 0 16px;
190 color: $input-text-color;
191 background: linear-gradient(90deg, transparent, $input-bg-color 10px);
192 }
193 }
194 .#{$css-prefix}disabled #{$select-prefix}-tag-compact {
195 background: linear-gradient(90deg, transparent, $input-disabled-bg-color 10px);
196 }
197 }
198
199 &-multiple, &-tag {
200 #{$select-prefix}-values {
201 /* Tag 有 3px 的 margin-bottom,所以包裹 Tag 的容器要作一下处理 */
202 margin-bottom: calc(0px - #{$select-tag-spacing-tb});
203 height: auto !important;
204 }
205
206 #{$select-prefix}-trigger-search {
207 margin-bottom: $select-tag-spacing-tb;
208 }
209
210 /* 如果有值,则搜索框变为1px */
211 #{$tag-prefix} + #{$select-prefix}-trigger-search {
212 width: auto;
213 min-width: 1px; /* 保留一个光标的宽度 */
214 }
215 .#{$css-prefix}input {
216 height: auto;
217 align-items: start;
218 }
219
220 &.#{$css-prefix}small {
221 #{$select-prefix}-values {
222 @include select-size($form-element-small-height, $select-s-lineheight);
223 }
224 #{$select-prefix}-values-compact {
225 height: $form-element-small-height !important;
226 }
227 #{$tag-prefix} {
228 border: 0;
229 @include select-tag-size($select-s-lineheight, calc(0px - 1px));
230
231 &-body {
232 line-height: $select-s-lineheight;
233 }
234 }
235 .#{$css-prefix}input-label, .#{$css-prefix}input-inner, .#{$css-prefix}input-control, #{$select-prefix}-tag-compact {
236 line-height: calc(#{$form-element-small-height} - 2px);
237 }
238 }
239
240 &.#{$css-prefix}medium {
241 #{$select-prefix}-values {
242 @include select-size($form-element-medium-height, $select-m-lineheight);
243 }
244 #{$select-prefix}-values-compact {
245 height: $form-element-medium-height !important;
246 }
247 #{$tag-prefix} {
248 @include select-tag-size($select-m-lineheight);
249 }
250 .#{$css-prefix}input-label, .#{$css-prefix}input-inner, .#{$css-prefix}input-control, #{$select-prefix}-tag-compact {
251 line-height: calc(#{$form-element-medium-height} - 2px);
252 }
253 }
254
255 &.#{$css-prefix}large {
256 #{$select-prefix}-values {
257 @include select-size($form-element-large-height, $select-l-lineheight);
258 }
259 #{$select-prefix}-values-compact {
260 height: $form-element-large-height !important;
261 }
262 #{$tag-prefix} {
263 @include select-tag-size($select-l-lineheight);
264 }
265 .#{$css-prefix}input-label, .#{$css-prefix}input-inner, .#{$css-prefix}input-control, #{$select-prefix}-tag-compact {
266 line-height: calc(#{$form-element-large-height} - 2px);
267 }
268 }
269 }
270
271
272 /* 在搜索框未激活时,将 input 的 color 置为透明 */
273 /* ISSUE: 在 IE11 中,<input readonly/> 仍然会显示光标, 要隐藏掉 */
274 /*
275 &.#{$css-prefix}no-search {
276 #{$select-prefix}-trigger-search input {
277 color: $color-transparent;
278 }
279 }
280 */
281
282 &-auto-complete {
283 width: 160px;
284
285 .#{$css-prefix}input {
286 width: 100%;
287 .#{$css-prefix}input-hint-wrap {
288 padding-right: 1px;
289 }
290 /* table-cell 下 margin 无效 */
291 #{$select-prefix}-arrow {
292 padding-left: 0;
293 }
294 }
295 }
296
297 &.#{$css-prefix}active {
298 @if get-compiling-value($select-unfold-icon-content) != get-compiling-value($icon-reset) {
299 #{$select-prefix}-symbol-fold::before {
300 content: $select-unfold-icon-content;
301 }
302 } @else {
303 #{$select-prefix}-arrow .#{$css-prefix}icon-arrow-down {
304 transform: rotate(180deg);
305 }
306 }
307 }
308
309 // --------- this is for config platform
310 #{$select-prefix}-unfold-icon::before {
311 content: $select-unfold-icon-content;
312 }
313 // --------- this is for config platform
314
315 &-symbol-fold::before {
316 content: $select-fold-icon-content;
317 }
318
319 &-arrow {
320 cursor: pointer;
321 width: auto !important;
322 text-align: center;
323 transition: all $motion-duration-immediately $motion-linear;
324 /* transform-origin: center 41.8%; // icon 图像中心 */
325 }
326
327 &-popup-wrap {
328 animation-duration: $motion-duration-standard;
329 animation-timing-function: $motion-ease;
330 padding: $popup-spacing-tb 0;
331 }
332
333 &-spacing-tb {
334 padding: $popup-spacing-tb 0;
335 }
336
337 &-menu-wrapper {
338 max-height: 260px;
339 overflow: auto;
340 border: $popup-local-border-width $popup-local-border-style $popup-local-border-color;
341 border-radius: $popup-local-corner;
342 box-shadow: $popup-local-shadow;
343 #{$select-prefix}-menu {
344 max-height: none;
345 border: none;
346 }
347 }
348
349 /* 弹层 */
350 &-menu {
351 max-height: 260px;
352 overflow: auto;
353
354 #{$select-prefix}-menu-empty-content {
355 padding-left: $s-2;
356 padding-right: $s-2;
357 color: $select-hint-color;
358 }
359
360 /* autoComplete 没有选项时 menu 不显示 */
361 &#{$select-prefix}-auto-complete-menu#{$select-prefix}-menu-empty {
362 display: none;
363 }
364
365 .#{$css-prefix}menu-item-text .#{$css-prefix}icon {
366 vertical-align: middle;
367 }
368 }
369
370 /* 全选按钮 */
371 &-all {
372 display: block;
373 cursor: pointer;
374 padding: 0 $s-2;
375 margin: 0 $s-3 $s-2;
376 border-bottom: 1px solid $color-line1-2;
377
378 &:hover {
379 color: $color-link-3;
380 }
381
382 .#{$css-prefix}menu-icon-selected.#{$css-prefix}icon {
383 // remove display: inline-block !important; in next Y
384 display: inline-block !important;
385 top: initial;
386 color: $select-menu-icon-color;
387 }
388 }
389
390 &-highlight {
391 color: $select-highlight-color;
392 font-size: $select-highlight-font;
393 }
394
395 /* -------------- IE polyfill -------------- */
396 /* 根据最新的数据,在中国,PC 端的 IE9 份额为 2%, */
397 /* 所以不应该因为 IE9 而不使用 flex,而是应该做降级 polyfill */
398 /* @see http://gs.statcounter.com/ */
399 /* IE10、IE11 虽然支持 flex,但还是会有各种各样奇奇怪怪的问题 */
400 &-in-ie#{$select-prefix}-trigger {
401 #{$select-prefix}-values {
402 /* 在 table 布局中,overflow: hidden 会导致负的 margin 失效 */
403 overflow: visible;
404 }
405
406 .#{$css-prefix}input-control, .#{$css-prefix}input-label {
407 width: 1px;
408 }
409 .#{$css-prefix}input-control > * {
410 display: table-cell;
411 width: 1%;
412 }
413 #{$select-prefix}-arrow {
414 display: table-cell;
415 }
416 #{$select-prefix}-clear {
417 display: none;
418 }
419
420 &#{$select-prefix}-multiple,
421 &#{$select-prefix}-tag {
422 #{$select-prefix}-inner {
423 vertical-align: top;
424 }
425 }
426
427 #{$select-prefix}-inner {
428 display: inline-table;
429 }
430
431 &#{$select-prefix}-single {
432 #{$select-prefix}-values {
433 display: inline-table;
434 }
435 .#{$css-prefix}input.#{$css-prefix}small #{$select-prefix}-values {
436 line-height: $form-element-small-height;
437 }
438 .#{$css-prefix}input.#{$css-prefix}medium #{$select-prefix}-values {
439 line-height: $form-element-medium-height;
440 }
441 .#{$css-prefix}input.#{$css-prefix}large #{$select-prefix}-values {
442 line-height: $form-element-large-height;
443 }
444 }
445
446 #{$select-prefix}-trigger-search {
447 > span {
448 max-width: 100px;
449 }
450 }
451
452 &#{$select-prefix}-single {
453 &#{$select-prefix}-in-ie-fixwidth #{$select-prefix}-values {
454 position: relative;
455 > em {
456 position: absolute;
457 display: inline-block;
458 height: 100%;
459 line-height: 1;
460 vertical-align: middle;
461 overflow: hidden;
462 left: 4px;
463 right: 0;
464 top: 30%;
465 }
466 }
467 /* 搜索框未激活,或者menu未展开,如果有值,则不显示搜索(placeholder) */
468 &.#{$css-prefix}no-search,
469 &.#{$css-prefix}inactive {
470 #{$select-prefix}-values > em + #{$select-prefix}-trigger-search {
471 /* stylelint-disable */
472 filter: alpha(opacity=0); /* for IE 9 */
473 /* stylelint-enable */
474 font-size: 0;
475 }
476 }
477 }
478
479 &.#{$css-prefix}no-search {
480 #{$select-prefix}-trigger-search input {
481 color: inherit;
482 }
483 }
484 }
485}
486
487@media screen and (-webkit-min-device-pixel-ratio: 0) {
488 #{$select-prefix}-multiple {
489 #{$select-prefix}-compact {
490 #{$select-prefix}-tag-compact {
491 background: linear-gradient(90deg, rgba(255, 255, 255, 0), $input-bg-color 10px);
492 }
493 }
494
495 .#{$css-prefix}disabled #{$select-prefix}-tag-compact {
496 background: linear-gradient(90deg, rgba(255, 255, 255, 0), $input-disabled-bg-color 10px);
497 }
498 }
499}
500
501@import "./rtl.scss";