UNPKG

9.58 kBtext/lessView Raw
1@import '../../style/themes/index';
2@import '../../style/mixins/index';
3
4@input-affix-with-clear-btn-width: 38px;
5
6// size mixins for input
7.input-lg() {
8 padding: @input-padding-vertical-lg @input-padding-horizontal-lg;
9 font-size: @font-size-lg;
10}
11
12.input-sm() {
13 padding: @input-padding-vertical-sm @input-padding-horizontal-sm;
14}
15
16// input status
17// == when focus or actived
18.active(@color: @outline-color) {
19 & when (@theme = dark) {
20 border-color: @color;
21 }
22 & when not (@theme = dark) {
23 border-color: ~`colorPalette('@{color}', 5) `;
24 }
25 border-right-width: @border-width-base !important;
26 outline: 0;
27 box-shadow: @input-outline-offset @outline-blur-size @outline-width fade(@color, @outline-fade);
28}
29
30// == when hoverd
31.hover(@color: @input-hover-border-color) {
32 border-color: @color;
33 border-right-width: @border-width-base !important;
34}
35
36.disabled() {
37 color: @input-disabled-color;
38 background-color: @input-disabled-bg;
39 border-color: @input-border-color;
40 box-shadow: none;
41 cursor: not-allowed;
42 opacity: 1;
43
44 &:hover {
45 .hover(@input-border-color);
46 }
47}
48
49// Basic style for input
50.input() {
51 position: relative;
52 display: inline-block;
53 width: 100%;
54 min-width: 0;
55 padding: @input-padding-vertical-base @input-padding-horizontal-base;
56 color: @input-color;
57 font-size: @font-size-base;
58 line-height: @line-height-base;
59 background-color: @input-bg;
60 background-image: none;
61 border: @border-width-base @border-style-base @input-border-color;
62 border-radius: @border-radius-base;
63 transition: all 0.3s;
64 .placeholder(); // Reset placeholder
65
66 &:hover {
67 .hover();
68 }
69
70 &:focus,
71 &-focused {
72 .active();
73 }
74
75 &-disabled {
76 .disabled();
77 }
78
79 &[disabled] {
80 .disabled();
81 }
82
83 &-borderless {
84 &,
85 &:hover,
86 &:focus,
87 &-focused,
88 &-disabled,
89 &[disabled] {
90 background-color: transparent;
91 border: none;
92 box-shadow: none;
93 }
94 }
95
96 // Reset height for `textarea`s
97 textarea& {
98 max-width: 100%; // prevent textearea resize from coming out of its container
99 height: auto;
100 min-height: @input-height-base;
101 line-height: @line-height-base;
102 vertical-align: bottom;
103 transition: all 0.3s, height 0s;
104 }
105
106 // Size
107 &-lg {
108 .input-lg();
109 }
110
111 &-sm {
112 .input-sm();
113 }
114}
115
116// label input
117.input-group(@inputClass) {
118 position: relative;
119 display: table;
120 width: 100%;
121 border-collapse: separate;
122 border-spacing: 0;
123
124 // Undo padding and float of grid classes
125 &[class*='col-'] {
126 float: none;
127 padding-right: 0;
128 padding-left: 0;
129 }
130
131 > [class*='col-'] {
132 padding-right: 8px;
133
134 &:last-child {
135 padding-right: 0;
136 }
137 }
138
139 &-addon,
140 &-wrap,
141 > .@{inputClass} {
142 display: table-cell;
143
144 &:not(:first-child):not(:last-child) {
145 border-radius: 0;
146 }
147 }
148
149 &-addon,
150 &-wrap {
151 width: 1px; // To make addon/wrap as small as possible
152 white-space: nowrap;
153 vertical-align: middle;
154 }
155
156 &-wrap > * {
157 display: block !important;
158 }
159
160 .@{inputClass} {
161 float: left;
162 width: 100%;
163 margin-bottom: 0;
164 text-align: inherit;
165
166 &:focus {
167 z-index: 1; // Fix https://gw.alipayobjects.com/zos/rmsportal/DHNpoqfMXSfrSnlZvhsJ.png
168 border-right-width: 1px;
169 }
170
171 &:hover {
172 z-index: 1;
173 border-right-width: 1px;
174 .@{ant-prefix}-input-search-with-button & {
175 z-index: 0;
176 }
177 }
178 }
179
180 &-addon {
181 position: relative;
182 padding: 0 @input-padding-horizontal-base;
183 color: @input-color;
184 font-weight: normal;
185 font-size: @font-size-base;
186 text-align: center;
187 background-color: @input-addon-bg;
188 border: @border-width-base @border-style-base @input-border-color;
189 border-radius: @border-radius-base;
190 transition: all 0.3s;
191
192 // Reset Select's style in addon
193 .@{ant-prefix}-select {
194 margin: -(@input-padding-vertical-base + 1px) (-@input-padding-horizontal-base);
195
196 &.@{ant-prefix}-select-single:not(.@{ant-prefix}-select-customize-input)
197 .@{ant-prefix}-select-selector {
198 background-color: inherit;
199 border: @border-width-base @border-style-base transparent;
200 box-shadow: none;
201 }
202
203 &-open,
204 &-focused {
205 .@{ant-prefix}-select-selector {
206 color: @primary-color;
207 }
208 }
209 }
210
211 // https://github.com/ant-design/ant-design/issues/31333
212 .@{ant-prefix}-cascader-picker {
213 margin: -9px (-@control-padding-horizontal);
214 background-color: transparent;
215 .@{ant-prefix}-cascader-input {
216 text-align: left;
217 border: 0;
218 box-shadow: none;
219 }
220 }
221 }
222
223 // Reset rounded corners
224 > .@{inputClass}:first-child,
225 &-addon:first-child {
226 border-top-right-radius: 0;
227 border-bottom-right-radius: 0;
228
229 // Reset Select's style in addon
230 .@{ant-prefix}-select .@{ant-prefix}-select-selector {
231 border-top-right-radius: 0;
232 border-bottom-right-radius: 0;
233 }
234 }
235
236 > .@{inputClass}-affix-wrapper {
237 &:not(:first-child) .@{inputClass} {
238 border-top-left-radius: 0;
239 border-bottom-left-radius: 0;
240 }
241
242 &:not(:last-child) .@{inputClass} {
243 border-top-right-radius: 0;
244 border-bottom-right-radius: 0;
245 }
246 }
247
248 &-addon:first-child {
249 border-right: 0;
250 }
251
252 &-addon:last-child {
253 border-left: 0;
254 }
255
256 > .@{inputClass}:last-child,
257 &-addon:last-child {
258 border-top-left-radius: 0;
259 border-bottom-left-radius: 0;
260
261 // Reset Select's style in addon
262 .@{ant-prefix}-select .@{ant-prefix}-select-selector {
263 border-top-left-radius: 0;
264 border-bottom-left-radius: 0;
265 }
266 }
267
268 // Sizing options
269 &-lg .@{inputClass},
270 &-lg > &-addon {
271 .input-lg();
272 }
273
274 &-sm .@{inputClass},
275 &-sm > &-addon {
276 .input-sm();
277 }
278
279 // Fix https://github.com/ant-design/ant-design/issues/5754
280 &-lg .@{ant-prefix}-select-single .@{ant-prefix}-select-selector {
281 height: @input-height-lg;
282 }
283
284 &-sm .@{ant-prefix}-select-single .@{ant-prefix}-select-selector {
285 height: @input-height-sm;
286 }
287
288 .@{inputClass}-affix-wrapper {
289 &:not(:first-child) {
290 border-top-left-radius: 0;
291 border-bottom-left-radius: 0;
292 }
293
294 &:not(:last-child) {
295 border-top-right-radius: 0;
296 border-bottom-right-radius: 0;
297 .@{ant-prefix}-input-search & {
298 border-top-left-radius: @border-radius-base;
299 border-bottom-left-radius: @border-radius-base;
300 }
301 }
302 }
303
304 &&-compact {
305 display: block;
306 .clearfix();
307
308 &-addon,
309 &-wrap,
310 > .@{inputClass} {
311 &:not(:first-child):not(:last-child) {
312 border-right-width: @border-width-base;
313
314 &:hover {
315 z-index: 1;
316 }
317
318 &:focus {
319 z-index: 1;
320 }
321 }
322 }
323
324 & > * {
325 display: inline-block;
326 float: none;
327 vertical-align: top; // https://github.com/ant-design/ant-design-pro/issues/139
328 border-radius: 0;
329 }
330
331 & > .@{inputClass}-affix-wrapper {
332 display: inline-flex;
333 }
334
335 & > .@{ant-prefix}-picker-range {
336 display: inline-flex;
337 }
338
339 & > *:not(:last-child) {
340 margin-right: -@border-width-base;
341 border-right-width: @border-width-base;
342 }
343
344 // Undo float for .ant-input-group .ant-input
345 .@{inputClass} {
346 float: none;
347 }
348
349 // reset border for Select, DatePicker, AutoComplete, Cascader, Mention, TimePicker, Input
350 & > .@{ant-prefix}-select > .@{ant-prefix}-select-selector,
351 & > .@{ant-prefix}-select-auto-complete .@{ant-prefix}-input,
352 & > .@{ant-prefix}-cascader-picker .@{ant-prefix}-input,
353 & > .@{ant-prefix}-input-group-wrapper .@{ant-prefix}-input {
354 border-right-width: @border-width-base;
355 border-radius: 0;
356
357 &:hover {
358 z-index: 1;
359 }
360
361 &:focus {
362 z-index: 1;
363 }
364 }
365
366 & > .@{ant-prefix}-select-focused {
367 z-index: 1;
368 }
369
370 // update z-index for arrow icon
371 & > .@{ant-prefix}-select > .@{ant-prefix}-select-arrow {
372 z-index: 1; // https://github.com/ant-design/ant-design/issues/20371
373 }
374
375 & > *:first-child,
376 & > .@{ant-prefix}-select:first-child > .@{ant-prefix}-select-selector,
377 & > .@{ant-prefix}-select-auto-complete:first-child .@{ant-prefix}-input,
378 & > .@{ant-prefix}-cascader-picker:first-child .@{ant-prefix}-input {
379 border-top-left-radius: @border-radius-base;
380 border-bottom-left-radius: @border-radius-base;
381 }
382
383 & > *:last-child,
384 & > .@{ant-prefix}-select:last-child > .@{ant-prefix}-select-selector,
385 & > .@{ant-prefix}-cascader-picker:last-child .@{ant-prefix}-input,
386 & > .@{ant-prefix}-cascader-picker-focused:last-child .@{ant-prefix}-input {
387 border-right-width: @border-width-base;
388 border-top-right-radius: @border-radius-base;
389 border-bottom-right-radius: @border-radius-base;
390 }
391
392 // https://github.com/ant-design/ant-design/issues/12493
393 & > .@{ant-prefix}-select-auto-complete .@{ant-prefix}-input {
394 vertical-align: top;
395 }
396
397 .@{ant-prefix}-input-group-wrapper + .@{ant-prefix}-input-group-wrapper {
398 margin-left: -1px;
399 .@{ant-prefix}-input-affix-wrapper {
400 border-radius: 0;
401 }
402 }
403
404 .@{ant-prefix}-input-group-wrapper:not(:last-child) {
405 &.@{ant-prefix}-input-search > .@{ant-prefix}-input-group {
406 & > .@{ant-prefix}-input-group-addon > .@{ant-prefix}-input-search-button {
407 border-radius: 0;
408 }
409
410 & > .@{ant-prefix}-input {
411 border-radius: @border-radius-base 0 0 @border-radius-base;
412 }
413 }
414 }
415 }
416}