@vaadin/vaadin-text-field 22.0.0-alpha4 → 22.0.0-alpha8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,354 +0,0 @@
1
- import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
2
- import '@vaadin/vaadin-lumo-styles/color.js';
3
- import '@vaadin/vaadin-lumo-styles/sizing.js';
4
- import '@vaadin/vaadin-lumo-styles/spacing.js';
5
- import '@vaadin/vaadin-lumo-styles/style.js';
6
- import '@vaadin/vaadin-lumo-styles/typography.js';
7
- import '@vaadin/vaadin-lumo-styles/mixins/required-field.js';
8
- import '@vaadin/vaadin-lumo-styles/font-icons.js';
9
- import '@vaadin/vaadin-lumo-styles/mixins/field-button.js';
10
-
11
- registerStyles(
12
- 'vaadin-text-field',
13
- css`
14
- :host {
15
- --lumo-text-field-size: var(--lumo-size-m);
16
- color: var(--lumo-body-text-color);
17
- font-size: var(--lumo-font-size-m);
18
- font-family: var(--lumo-font-family);
19
- -webkit-font-smoothing: antialiased;
20
- -moz-osx-font-smoothing: grayscale;
21
- -webkit-tap-highlight-color: transparent;
22
- padding: var(--lumo-space-xs) 0;
23
- }
24
-
25
- :host::before {
26
- height: var(--lumo-text-field-size);
27
- box-sizing: border-box;
28
- display: inline-flex;
29
- align-items: center;
30
- }
31
-
32
- :host([focused]:not([readonly])) [part='label'] {
33
- color: var(--lumo-primary-text-color);
34
- }
35
-
36
- :host([has-helper]) [part='helper-text']::before {
37
- content: '';
38
- display: block;
39
- height: 0.4em;
40
- }
41
-
42
- [part='helper-text'],
43
- [part='helper-text'] ::slotted(*) {
44
- display: block;
45
- color: var(--lumo-secondary-text-color);
46
- font-size: var(--lumo-font-size-xs);
47
- line-height: var(--lumo-line-height-xs);
48
- margin-left: calc(var(--lumo-border-radius-m) / 4);
49
- transition: color 0.2s;
50
- }
51
-
52
- [part='value'],
53
- [part='input-field'] ::slotted(input),
54
- [part='input-field'] ::slotted(textarea),
55
- [part='input-field'] ::slotted([part='value']) {
56
- cursor: inherit;
57
- min-height: var(--lumo-text-field-size);
58
- padding: 0 0.25em;
59
- --_lumo-text-field-overflow-mask-image: linear-gradient(to left, transparent, #000 1.25em);
60
- -webkit-mask-image: var(--_lumo-text-field-overflow-mask-image);
61
- mask-image: var(--_lumo-text-field-overflow-mask-image);
62
- }
63
-
64
- [part='value']:focus,
65
- :host([focused]) [part='input-field'] ::slotted(input),
66
- :host([focused]) [part='input-field'] ::slotted(textarea) {
67
- -webkit-mask-image: none;
68
- mask-image: none;
69
- }
70
-
71
- [part='value']::placeholder {
72
- color: inherit;
73
- transition: opacity 0.175s 0.1s;
74
- opacity: 0.5;
75
- }
76
-
77
- [part='input-field'] {
78
- border-radius: var(--lumo-border-radius-m);
79
- background-color: var(--lumo-contrast-10pct);
80
- padding: 0 calc(0.375em + var(--lumo-border-radius-m) / 4 - 1px);
81
- font-weight: 500;
82
- line-height: 1;
83
- position: relative;
84
- cursor: text;
85
- box-sizing: border-box;
86
- }
87
-
88
- /* Used for hover and activation effects */
89
- [part='input-field']::after {
90
- content: '';
91
- position: absolute;
92
- top: 0;
93
- right: 0;
94
- bottom: 0;
95
- left: 0;
96
- border-radius: inherit;
97
- pointer-events: none;
98
- background-color: var(--lumo-contrast-50pct);
99
- opacity: 0;
100
- transition: transform 0.15s, opacity 0.2s;
101
- transform-origin: 100% 0;
102
- }
103
-
104
- /* Hover */
105
-
106
- :host(:hover:not([readonly]):not([focused])) [part='label'],
107
- :host(:hover:not([readonly])) [part='helper-text'],
108
- :host(:hover:not([readonly])) [part='helper-text'] ::slotted(*) {
109
- color: var(--lumo-body-text-color);
110
- }
111
-
112
- :host(:hover:not([readonly]):not([focused])) [part='input-field']::after {
113
- opacity: 0.1;
114
- }
115
-
116
- /* Touch device adjustment */
117
- @media (pointer: coarse) {
118
- :host(:hover:not([readonly]):not([focused])) [part='label'] {
119
- color: var(--lumo-secondary-text-color);
120
- }
121
-
122
- :host(:hover:not([readonly]):not([focused])) [part='input-field']::after {
123
- opacity: 0;
124
- }
125
-
126
- :host(:active:not([readonly]):not([focused])) [part='input-field']::after {
127
- opacity: 0.2;
128
- }
129
- }
130
-
131
- /* Trigger when not focusing using the keyboard */
132
- :host([focused]:not([focus-ring]):not([readonly])) [part='input-field']::after {
133
- transform: scaleX(0);
134
- transition-duration: 0.15s, 1s;
135
- }
136
-
137
- /* Focus-ring */
138
-
139
- :host([focus-ring]) [part='input-field'] {
140
- box-shadow: 0 0 0 2px var(--lumo-primary-color-50pct);
141
- }
142
-
143
- /* Read-only and disabled */
144
- :host([readonly]) [part='value']::placeholder,
145
- :host([disabled]) [part='value']::placeholder {
146
- opacity: 0;
147
- }
148
-
149
- /* Read-only */
150
-
151
- :host([readonly]) [part='input-field'] {
152
- color: var(--lumo-secondary-text-color);
153
- background-color: transparent;
154
- cursor: default;
155
- }
156
-
157
- :host([readonly]) [part='input-field']::after {
158
- background-color: transparent;
159
- opacity: 1;
160
- border: 1px dashed var(--lumo-contrast-30pct);
161
- }
162
-
163
- /* Disabled style */
164
-
165
- :host([disabled]) {
166
- pointer-events: none;
167
- }
168
-
169
- :host([disabled]) [part='input-field'] {
170
- background-color: var(--lumo-contrast-5pct);
171
- }
172
-
173
- :host([disabled]) [part='label'],
174
- :host([disabled]) [part='helper-text'],
175
- :host([disabled]) [part='value'],
176
- :host([disabled]) [part='input-field'] ::slotted(*) {
177
- color: var(--lumo-disabled-text-color);
178
- -webkit-text-fill-color: var(--lumo-disabled-text-color);
179
- }
180
-
181
- /* Invalid style */
182
-
183
- :host([invalid]) [part='input-field'] {
184
- background-color: var(--lumo-error-color-10pct);
185
- }
186
-
187
- :host([invalid]) [part='input-field']::after {
188
- background-color: var(--lumo-error-color-50pct);
189
- }
190
-
191
- :host([invalid][focus-ring]) [part='input-field'] {
192
- box-shadow: 0 0 0 2px var(--lumo-error-color-50pct);
193
- }
194
-
195
- :host([input-prevented]) [part='input-field'] {
196
- color: var(--lumo-error-text-color);
197
- }
198
-
199
- /* Small theme */
200
-
201
- :host([theme~='small']) {
202
- font-size: var(--lumo-font-size-s);
203
- --lumo-text-field-size: var(--lumo-size-s);
204
- }
205
-
206
- :host([theme~='small'][has-label]) [part='label'] {
207
- font-size: var(--lumo-font-size-xs);
208
- }
209
-
210
- :host([theme~='small'][has-label]) [part='error-message'] {
211
- font-size: var(--lumo-font-size-xxs);
212
- }
213
-
214
- /* Text align */
215
-
216
- :host([theme~='align-left']) [part='value'] {
217
- text-align: left;
218
- --_lumo-text-field-overflow-mask-image: none;
219
- }
220
-
221
- :host([theme~='align-center']) [part='value'] {
222
- text-align: center;
223
- --_lumo-text-field-overflow-mask-image: none;
224
- }
225
-
226
- :host([theme~='align-right']) [part='value'] {
227
- text-align: right;
228
- --_lumo-text-field-overflow-mask-image: none;
229
- }
230
-
231
- @-moz-document url-prefix() {
232
- /* Firefox is smart enough to align overflowing text to right */
233
- :host([theme~='align-right']) [part='value'] {
234
- --_lumo-text-field-overflow-mask-image: linear-gradient(to right, transparent 0.25em, #000 1.5em);
235
- }
236
- }
237
-
238
- @-moz-document url-prefix() {
239
- /* Firefox is smart enough to align overflowing text to right */
240
- :host([theme~='align-left']) [part='value'] {
241
- --_lumo-text-field-overflow-mask-image: linear-gradient(to left, transparent 0.25em, #000 1.5em);
242
- }
243
- }
244
- /* helper-text position */
245
-
246
- :host([has-helper][theme~='helper-above-field']) [part='helper-text']::before {
247
- display: none;
248
- }
249
-
250
- :host([has-helper][theme~='helper-above-field']) [part='helper-text']::after {
251
- content: '';
252
- display: block;
253
- height: 0.4em;
254
- }
255
-
256
- :host([has-helper][theme~='helper-above-field']) [part='label'] {
257
- order: 0;
258
- padding-bottom: 0.4em;
259
- }
260
-
261
- :host([has-helper][theme~='helper-above-field']) [part='helper-text'] {
262
- order: 1;
263
- }
264
-
265
- :host([has-helper][theme~='helper-above-field']) [part='input-field'] {
266
- order: 2;
267
- }
268
-
269
- :host([has-helper][theme~='helper-above-field']) [part='error-message'] {
270
- order: 3;
271
- }
272
-
273
- /* Slotted content */
274
-
275
- [part='input-field'] ::slotted(:not([part]):not(iron-icon):not(vaadin-icon):not(input):not(textarea)) {
276
- color: var(--lumo-secondary-text-color);
277
- font-weight: 400;
278
- }
279
-
280
- /* Slotted icons */
281
- [part='input-field'] ::slotted(vaadin-icon),
282
- [part='input-field'] ::slotted(iron-icon) {
283
- color: var(--lumo-contrast-60pct);
284
- width: var(--lumo-icon-size-m);
285
- height: var(--lumo-icon-size-m);
286
- }
287
-
288
- /* Vaadin icons are based on a 16x16 grid (unlike Lumo and Material icons with 24x24), so they look too big by default */
289
- [part='input-field'] ::slotted(vaadin-icon[icon^='vaadin:']),
290
- [part='input-field'] ::slotted(iron-icon[icon^='vaadin:']) {
291
- padding: 0.25em;
292
- box-sizing: border-box !important;
293
- }
294
-
295
- [part='clear-button']::before {
296
- content: var(--lumo-icons-cross);
297
- }
298
-
299
- /* RTL specific styles */
300
-
301
- :host([dir='rtl']) [part='input-field']::after {
302
- transform-origin: 0% 0;
303
- }
304
-
305
- :host([dir='rtl']) [part='value'],
306
- :host([dir='rtl']) [part='input-field'] ::slotted(input),
307
- :host([dir='rtl']) [part='input-field'] ::slotted(textarea) {
308
- --_lumo-text-field-overflow-mask-image: linear-gradient(to right, transparent, #000 1.25em);
309
- }
310
-
311
- :host([dir='rtl']) [part='value']:focus,
312
- :host([focused][dir='rtl']) [part='input-field'] ::slotted(input),
313
- :host([focused][dir='rtl']) [part='input-field'] ::slotted(textarea) {
314
- -webkit-mask-image: none;
315
- mask-image: none;
316
- }
317
-
318
- @-moz-document url-prefix() {
319
- :host([dir='rtl']) [part='value'],
320
- :host([dir='rtl']) [part='input-field'] ::slotted(input),
321
- :host([dir='rtl']) [part='input-field'] ::slotted(textarea),
322
- :host([dir='rtl']) [part='input-field'] ::slotted([part='value']) {
323
- mask-image: var(--_lumo-text-field-overflow-mask-image);
324
- }
325
- }
326
-
327
- :host([theme~='align-left'][dir='rtl']) [part='value'] {
328
- --_lumo-text-field-overflow-mask-image: none;
329
- }
330
-
331
- :host([theme~='align-center'][dir='rtl']) [part='value'] {
332
- --_lumo-text-field-overflow-mask-image: none;
333
- }
334
-
335
- :host([theme~='align-right'][dir='rtl']) [part='value'] {
336
- --_lumo-text-field-overflow-mask-image: none;
337
- }
338
-
339
- @-moz-document url-prefix() {
340
- /* Firefox is smart enough to align overflowing text to right */
341
- :host([theme~='align-right'][dir='rtl']) [part='value'] {
342
- --_lumo-text-field-overflow-mask-image: linear-gradient(to right, transparent 0.25em, #000 1.5em);
343
- }
344
- }
345
-
346
- @-moz-document url-prefix() {
347
- /* Firefox is smart enough to align overflowing text to right */
348
- :host([theme~='align-left'][dir='rtl']) [part='value'] {
349
- --_lumo-text-field-overflow-mask-image: linear-gradient(to left, transparent 0.25em, #000 1.5em);
350
- }
351
- }
352
- `,
353
- { moduleId: 'lumo-text-field', include: ['lumo-required-field', 'lumo-field-button'] }
354
- );
@@ -1,220 +0,0 @@
1
- import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
2
- import '@vaadin/vaadin-material-styles/color.js';
3
- import '@vaadin/vaadin-material-styles/typography.js';
4
- import '@vaadin/vaadin-material-styles/mixins/required-field.js';
5
- import '@vaadin/vaadin-material-styles/font-icons.js';
6
- import '@vaadin/vaadin-material-styles/mixins/field-button.js';
7
-
8
- registerStyles(
9
- 'vaadin-text-field',
10
- css`
11
- :host {
12
- display: inline-flex;
13
- position: relative;
14
- padding-top: 8px;
15
- margin-bottom: 8px;
16
- outline: none;
17
- color: var(--material-body-text-color);
18
- font-size: var(--material-body-font-size);
19
- line-height: 24px;
20
- font-family: var(--material-font-family);
21
- -webkit-font-smoothing: antialiased;
22
- -moz-osx-font-smoothing: grayscale;
23
- }
24
-
25
- :host::before {
26
- line-height: 32px;
27
- }
28
-
29
- /* Strange gymnastics to make fields vertically align nicely in most cases
30
- (no label, with label, without prefix, with prefix, etc.) */
31
-
32
- :host([has-label]) {
33
- padding-top: 24px;
34
- }
35
-
36
- [part='label']:empty {
37
- display: none;
38
- }
39
-
40
- [part='label']:empty::before {
41
- content: '\\00a0';
42
- position: absolute;
43
- }
44
-
45
- [part='input-field'] {
46
- position: relative;
47
- top: -0.2px; /* NOTE(platosha): Adjusts for wrong flex baseline in Chrome & Safari */
48
- height: 32px;
49
- padding-left: 0;
50
- padding-right: 0;
51
- background-color: transparent;
52
- margin: 0;
53
- }
54
-
55
- [part='input-field']::before,
56
- [part='input-field']::after {
57
- content: '';
58
- position: absolute;
59
- bottom: 0;
60
- left: 0;
61
- right: 0;
62
- height: 1px;
63
- transform-origin: 50% 0%;
64
- background-color: var(--_material-text-field-input-line-background-color, #000);
65
- opacity: var(--_material-text-field-input-line-opacity, 0.42);
66
- }
67
-
68
- [part='input-field']::after {
69
- background-color: var(--material-primary-color);
70
- opacity: 0;
71
- height: 2px;
72
- bottom: 0;
73
- transform: scaleX(0);
74
- transition: opacity 0.175s;
75
- }
76
-
77
- :host([disabled]) [part='label'],
78
- :host([disabled]) [part='value'],
79
- :host([disabled]) [part='input-field'] ::slotted(input),
80
- :host([disabled]) [part='input-field'] ::slotted(textarea),
81
- :host([disabled]) [part='input-field'] ::slotted([part='value']) {
82
- color: var(--material-disabled-text-color);
83
- -webkit-text-fill-color: var(--material-disabled-text-color);
84
- }
85
-
86
- [part='value'],
87
- :host([disabled]) [part='input-field'] ::slotted(input),
88
- :host([disabled]) [part='input-field'] ::slotted(textarea),
89
- [part='input-field'] ::slotted([part='value']) {
90
- outline: none;
91
- margin: 0;
92
- border: 0;
93
- border-radius: 0;
94
- padding: 8px 0;
95
- width: 100%;
96
- height: 100%;
97
- font-family: inherit;
98
- font-size: 1em;
99
- line-height: inherit;
100
- color: inherit;
101
- background-color: transparent;
102
- /* Disable default invalid style in Firefox */
103
- box-shadow: none;
104
- }
105
-
106
- /* TODO: the text opacity should be 42%, but the disabled style is 38%.
107
- Would need to introduce another property for it if we want to be 100% accurate. */
108
- [part='value']::placeholder {
109
- color: var(--material-disabled-text-color);
110
- transition: opacity 0.175s 0.1s;
111
- opacity: 1;
112
- }
113
-
114
- :host([has-label]:not([focused]):not([invalid]):not([theme='always-float-label'])) [part='value']::placeholder {
115
- opacity: 0;
116
- transition-delay: 0;
117
- }
118
-
119
- /* According to material theme guidelines, helper text should be hidden when error message is set and input is invalid */
120
- :host([has-helper][invalid][has-error-message]) [part='helper-text'] {
121
- display: none;
122
- }
123
-
124
- [part='label'] {
125
- width: 133%;
126
- transition: transform 0.175s, color 0.175s, width 0.175s;
127
- transition-timing-function: ease, ease, step-end;
128
- }
129
-
130
- :host([has-helper]) [part='helper-text']::before {
131
- content: '';
132
- display: block;
133
- height: 6px;
134
- }
135
-
136
- [part='helper-text'],
137
- [part='helper-text'] ::slotted(*) {
138
- font-size: 0.75rem;
139
- line-height: 1;
140
- color: var(--material-secondary-text-color);
141
- }
142
-
143
- :host(:hover:not([readonly]):not([invalid])) [part='input-field']::before {
144
- opacity: var(--_material-text-field-input-line-hover-opacity, 0.87);
145
- }
146
-
147
- :host([focused]:not([invalid])) [part='label'] {
148
- color: var(--material-primary-text-color);
149
- }
150
-
151
- :host([focused]) [part='input-field']::after,
152
- :host([invalid]) [part='input-field']::after {
153
- opacity: 1;
154
- transform: none;
155
- transition: transform 0.175s, opacity 0.175s;
156
- }
157
-
158
- :host([invalid]) [part='input-field']::after {
159
- background-color: var(--material-error-color);
160
- }
161
-
162
- :host([input-prevented]) [part='input-field'] {
163
- color: var(--material-error-text-color);
164
- }
165
-
166
- :host([disabled]) {
167
- pointer-events: none;
168
- }
169
-
170
- :host([disabled]) [part='input-field'] {
171
- color: var(--material-disabled-text-color);
172
- }
173
-
174
- :host([disabled]) [part='input-field']::before {
175
- background-color: transparent;
176
- background-image: linear-gradient(
177
- 90deg,
178
- var(--_material-text-field-input-line-background-color, #000) 0,
179
- var(--_material-text-field-input-line-background-color, #000) 2px,
180
- transparent 2px
181
- );
182
- background-size: 4px 1px;
183
- background-repeat: repeat-x;
184
- }
185
-
186
- /* Only target the visible floating label */
187
- :host([has-label]:not([has-value]):not([focused]):not([invalid]):not([theme~='always-float-label']))
188
- [part='label'] {
189
- width: 100%;
190
- transform: scale(1) translateY(24px);
191
- transition-timing-function: ease, ease, step-start;
192
- pointer-events: none;
193
- left: auto;
194
- right: auto;
195
- transition-delay: 0.1s;
196
- }
197
-
198
- /* Slotted content */
199
-
200
- [part='input-field'] ::slotted(*:not([part='value']):not([part\$='-button']):not(input):not(textarea)) {
201
- color: var(--material-secondary-text-color);
202
- }
203
-
204
- [part='clear-button']::before {
205
- content: var(--material-icons-clear);
206
- }
207
-
208
- /* RTL specific styles */
209
-
210
- :host([disabled][dir='rtl']) [part='input-field']::before {
211
- background-image: linear-gradient(
212
- -90deg,
213
- var(--_material-text-field-input-line-background-color, #000) 0,
214
- var(--_material-text-field-input-line-background-color, #000) 2px,
215
- transparent 2px
216
- );
217
- }
218
- `,
219
- { moduleId: 'material-text-field', include: ['material-required-field', 'material-field-button'] }
220
- );