UNPKG

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