@everymatrix/general-input 1.44.0 → 1.45.2
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.
- package/dist/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/checkbox-group-input_10.cjs.entry.js +3873 -1756
- package/dist/cjs/general-input.cjs.entry.js +65 -63
- package/dist/cjs/general-input.cjs.js +17 -11
- package/dist/cjs/index-8cb018cb.js +1316 -0
- package/dist/cjs/index.cjs.js +13 -13
- package/dist/cjs/loader.cjs.js +7 -13
- package/dist/cjs/locale.utils-76c75c40.js +147 -0
- package/dist/cjs/toggle-checkbox-input.cjs.entry.js +77 -78
- package/dist/collection/collection-manifest.json +14 -14
- package/dist/collection/components/checkbox-group-input/checkbox-group-input.js +368 -353
- package/dist/collection/components/checkbox-input/checkbox-input.js +325 -315
- package/dist/collection/components/date-input/date-input.css +2 -2
- package/dist/collection/components/date-input/date-input.js +397 -376
- package/dist/collection/components/email-input/email-input.css +7 -11
- package/dist/collection/components/email-input/email-input.js +404 -385
- package/dist/collection/components/general-input/general-input.js +373 -368
- package/dist/collection/components/general-input/index.js +1 -0
- package/dist/collection/components/number-input/number-input.js +370 -352
- package/dist/collection/components/password-input/password-input.css +2 -4
- package/dist/collection/components/password-input/password-input.js +513 -540
- package/dist/collection/components/radio-input/radio-input.js +301 -286
- package/dist/collection/components/select-input/select-input.css +8 -9
- package/dist/collection/components/select-input/select-input.js +427 -414
- package/dist/collection/components/tel-input/tel-input.css +1 -1
- package/dist/collection/components/tel-input/tel-input.js +440 -422
- package/dist/collection/components/text-input/text-input.css +0 -1
- package/dist/collection/components/text-input/text-input.js +444 -429
- package/dist/collection/components/toggle-checkbox-input/toggle-checkbox-input.js +327 -340
- package/dist/collection/index.js +13 -13
- package/dist/collection/utils/locale.utils.js +133 -133
- package/dist/collection/utils/utils.js +3 -3
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/checkbox-group-input_10.entry.js +3873 -1756
- package/dist/esm/general-input.entry.js +65 -63
- package/dist/esm/general-input.js +14 -11
- package/dist/esm/index-514fda47.js +1287 -0
- package/dist/esm/index.js +13 -13
- package/dist/esm/loader.js +7 -13
- package/dist/esm/locale.utils-ca41bf95.js +144 -0
- package/dist/esm/toggle-checkbox-input.entry.js +77 -78
- package/dist/general-input/general-input.esm.js +1 -1
- package/dist/general-input/p-03e81c11.js +2 -0
- package/dist/general-input/p-aec71434.js +1 -0
- package/dist/general-input/p-e1255160.js +1 -0
- package/dist/general-input/p-eb454344.entry.js +1 -0
- package/dist/general-input/p-ecdc294b.entry.js +5430 -0
- package/dist/general-input/p-f92ab852.entry.js +1 -0
- package/dist/stencil.config.dev.js +17 -0
- package/dist/stencil.config.js +14 -19
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-input/.stencil/packages/stencil/general-input/stencil.config.d.ts +2 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-input/.stencil/packages/stencil/general-input/stencil.config.dev.d.ts +2 -0
- package/dist/types/components/checkbox-group-input/checkbox-group-input.d.ts +68 -68
- package/dist/types/components/checkbox-input/checkbox-input.d.ts +61 -62
- package/dist/types/components/date-input/date-input.d.ts +78 -78
- package/dist/types/components/email-input/email-input.d.ts +77 -77
- package/dist/types/components/general-input/general-input.d.ts +72 -72
- package/dist/types/components/general-input/index.d.ts +1 -0
- package/dist/types/components/number-input/number-input.d.ts +71 -71
- package/dist/types/components/password-input/password-input.d.ts +87 -92
- package/dist/types/components/radio-input/radio-input.d.ts +55 -55
- package/dist/types/components/select-input/select-input.d.ts +79 -79
- package/dist/types/components/tel-input/tel-input.d.ts +85 -85
- package/dist/types/components/text-input/text-input.d.ts +81 -81
- package/dist/types/components/toggle-checkbox-input/toggle-checkbox-input.d.ts +63 -68
- package/dist/types/components.d.ts +201 -39
- package/dist/types/stencil-public-runtime.d.ts +142 -33
- package/dist/types/utils/locale.utils.d.ts +8 -8
- package/dist/types/utils/types.d.ts +54 -54
- package/loader/cdn.js +1 -3
- package/loader/index.cjs.js +1 -3
- package/loader/index.d.ts +13 -1
- package/loader/index.es2017.js +1 -3
- package/loader/index.js +1 -3
- package/loader/package.json +1 -0
- package/package.json +8 -1
- package/dist/cjs/index-132a0774.js +0 -1327
- package/dist/cjs/locale.utils-2fa6f747.js +0 -147
- package/dist/components/active-mixin.js +0 -975
- package/dist/components/checkbox-group-input.d.ts +0 -11
- package/dist/components/checkbox-group-input.js +0 -6
- package/dist/components/checkbox-group-input2.js +0 -1078
- package/dist/components/checkbox-input.d.ts +0 -11
- package/dist/components/checkbox-input.js +0 -6
- package/dist/components/checkbox-input2.js +0 -132
- package/dist/components/date-input.d.ts +0 -11
- package/dist/components/date-input.js +0 -6
- package/dist/components/date-input2.js +0 -11556
- package/dist/components/email-input.d.ts +0 -11
- package/dist/components/email-input.js +0 -6
- package/dist/components/email-input2.js +0 -171
- package/dist/components/field-mixin.js +0 -12426
- package/dist/components/general-input.d.ts +0 -11
- package/dist/components/general-input.js +0 -6
- package/dist/components/general-input2.js +0 -350
- package/dist/components/index.d.ts +0 -26
- package/dist/components/index.js +0 -18
- package/dist/components/input-field-shared-styles.js +0 -1211
- package/dist/components/number-input.d.ts +0 -11
- package/dist/components/number-input.js +0 -6
- package/dist/components/number-input2.js +0 -158
- package/dist/components/password-input.d.ts +0 -11
- package/dist/components/password-input.js +0 -6
- package/dist/components/password-input2.js +0 -1059
- package/dist/components/radio-input.d.ts +0 -11
- package/dist/components/radio-input.js +0 -6
- package/dist/components/radio-input2.js +0 -114
- package/dist/components/select-input.d.ts +0 -11
- package/dist/components/select-input.js +0 -6
- package/dist/components/select-input2.js +0 -183
- package/dist/components/tel-input.d.ts +0 -11
- package/dist/components/tel-input.js +0 -6
- package/dist/components/tel-input2.js +0 -197
- package/dist/components/text-input.d.ts +0 -11
- package/dist/components/text-input.js +0 -6
- package/dist/components/text-input2.js +0 -199
- package/dist/components/toggle-checkbox-input.d.ts +0 -11
- package/dist/components/toggle-checkbox-input.js +0 -6
- package/dist/components/tooltipIcon.js +0 -146
- package/dist/components/vaadin-button.js +0 -490
- package/dist/components/vaadin-combo-box.js +0 -4512
- package/dist/components/virtual-keyboard-controller.js +0 -2001
- package/dist/esm/index-db76d5b5.js +0 -1299
- package/dist/esm/locale.utils-30fb5289.js +0 -144
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/css-shim.js +0 -1
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/general-input/p-04d4b145.js +0 -1
- package/dist/general-input/p-a8221ce9.entry.js +0 -1
- package/dist/general-input/p-b408093e.js +0 -1
- package/dist/general-input/p-b64caafa.entry.js +0 -3646
- package/dist/general-input/p-c85c0e4d.entry.js +0 -1
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/general-input/.stencil/packages/general-input/stencil.config.d.ts +0 -2
- /package/dist/cjs/{tooltipIcon-092a795f.js → tooltipIcon-7e9ee226.js} +0 -0
- /package/dist/esm/{tooltipIcon-99c1c7b7.js → tooltipIcon-0a5a06a2.js} +0 -0
- /package/dist/general-input/{p-f4f4ccda.js → p-2dccd0bf.js} +0 -0
|
@@ -1,1211 +0,0 @@
|
|
|
1
|
-
import { r as registerStyles, i, f as defineCustomElement, g as ThemableMixin, n as DirMixin, P as PolymerElement, h as html, j as requiredField, k as helper, d as dedupingMixin, I as InputMixin, K as KeyboardMixin, D as DelegateStateMixin, V as ValidateMixin, b as DelegateFocusMixin, F as FieldMixin, o as Debouncer, t as timeOut } from './field-mixin.js';
|
|
2
|
-
|
|
3
|
-
registerStyles(
|
|
4
|
-
'vaadin-input-container',
|
|
5
|
-
i`
|
|
6
|
-
:host {
|
|
7
|
-
background-color: var(--lumo-contrast-10pct);
|
|
8
|
-
padding: 0 calc(0.375em + var(--_input-container-radius) / 4 - 1px);
|
|
9
|
-
font-weight: 500;
|
|
10
|
-
line-height: 1;
|
|
11
|
-
position: relative;
|
|
12
|
-
cursor: text;
|
|
13
|
-
box-sizing: border-box;
|
|
14
|
-
border-radius:
|
|
15
|
-
/* See https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius#syntax */
|
|
16
|
-
var(--vaadin-input-field-top-start-radius, var(--_input-container-radius))
|
|
17
|
-
var(--vaadin-input-field-top-end-radius, var(--_input-container-radius))
|
|
18
|
-
var(--vaadin-input-field-bottom-end-radius, var(--_input-container-radius))
|
|
19
|
-
var(--vaadin-input-field-bottom-start-radius, var(--_input-container-radius));
|
|
20
|
-
/* Fallback */
|
|
21
|
-
--_input-container-radius: var(--vaadin-input-field-border-radius, var(--lumo-border-radius-m));
|
|
22
|
-
/* Default field border color */
|
|
23
|
-
--_input-border-color: var(--vaadin-input-field-border-color, var(--lumo-contrast-50pct));
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
:host([dir='rtl']) {
|
|
27
|
-
border-radius:
|
|
28
|
-
/* Don't use logical props, see https://github.com/vaadin/vaadin-time-picker/issues/145 */
|
|
29
|
-
var(--vaadin-input-field-top-end-radius, var(--_input-container-radius))
|
|
30
|
-
var(--vaadin-input-field-top-start-radius, var(--_input-container-radius))
|
|
31
|
-
var(--vaadin-input-field-bottom-start-radius, var(--_input-container-radius))
|
|
32
|
-
var(--vaadin-input-field-bottom-end-radius, var(--_input-container-radius));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/* Used for hover and activation effects */
|
|
36
|
-
:host::after {
|
|
37
|
-
content: '';
|
|
38
|
-
position: absolute;
|
|
39
|
-
inset: 0;
|
|
40
|
-
border-radius: inherit;
|
|
41
|
-
pointer-events: none;
|
|
42
|
-
background-color: var(--lumo-contrast-50pct);
|
|
43
|
-
opacity: 0;
|
|
44
|
-
transition: transform 0.15s, opacity 0.2s;
|
|
45
|
-
transform-origin: 100% 0;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
::slotted(:not([slot$='fix'])) {
|
|
49
|
-
cursor: inherit;
|
|
50
|
-
min-height: var(--lumo-text-field-size, var(--lumo-size-m));
|
|
51
|
-
padding: 0 0.25em;
|
|
52
|
-
--_lumo-text-field-overflow-mask-image: linear-gradient(to left, transparent, #000 1.25em);
|
|
53
|
-
-webkit-mask-image: var(--_lumo-text-field-overflow-mask-image);
|
|
54
|
-
mask-image: var(--_lumo-text-field-overflow-mask-image);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/* Read-only */
|
|
58
|
-
:host([readonly]) {
|
|
59
|
-
color: var(--lumo-secondary-text-color);
|
|
60
|
-
background-color: transparent;
|
|
61
|
-
cursor: default;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
:host([readonly])::after {
|
|
65
|
-
background-color: transparent;
|
|
66
|
-
opacity: 1;
|
|
67
|
-
border: 1px dashed var(--lumo-contrast-30pct);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/* Disabled */
|
|
71
|
-
:host([disabled]) {
|
|
72
|
-
background-color: var(--lumo-contrast-5pct);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
:host([disabled]) ::slotted(*) {
|
|
76
|
-
color: var(--lumo-disabled-text-color);
|
|
77
|
-
-webkit-text-fill-color: var(--lumo-disabled-text-color);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/* Invalid */
|
|
81
|
-
:host([invalid]) {
|
|
82
|
-
background-color: var(--lumo-error-color-10pct);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
:host([invalid])::after {
|
|
86
|
-
background-color: var(--lumo-error-color-50pct);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/* Slotted icons */
|
|
90
|
-
::slotted(vaadin-icon) {
|
|
91
|
-
color: var(--lumo-contrast-60pct);
|
|
92
|
-
width: var(--lumo-icon-size-m);
|
|
93
|
-
height: var(--lumo-icon-size-m);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/* Vaadin icons are based on a 16x16 grid (unlike Lumo and Material icons with 24x24), so they look too big by default */
|
|
97
|
-
::slotted(vaadin-icon[icon^='vaadin:']) {
|
|
98
|
-
padding: 0.25em;
|
|
99
|
-
box-sizing: border-box !important;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/* Text align */
|
|
103
|
-
:host([dir='rtl']) ::slotted(:not([slot$='fix'])) {
|
|
104
|
-
--_lumo-text-field-overflow-mask-image: linear-gradient(to right, transparent, #000 1.25em);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
@-moz-document url-prefix() {
|
|
108
|
-
:host([dir='rtl']) ::slotted(:not([slot$='fix'])) {
|
|
109
|
-
mask-image: var(--_lumo-text-field-overflow-mask-image);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
:host([theme~='align-left']) ::slotted(:not([slot$='fix'])) {
|
|
114
|
-
text-align: start;
|
|
115
|
-
--_lumo-text-field-overflow-mask-image: none;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
:host([theme~='align-center']) ::slotted(:not([slot$='fix'])) {
|
|
119
|
-
text-align: center;
|
|
120
|
-
--_lumo-text-field-overflow-mask-image: none;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
:host([theme~='align-right']) ::slotted(:not([slot$='fix'])) {
|
|
124
|
-
text-align: end;
|
|
125
|
-
--_lumo-text-field-overflow-mask-image: none;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
@-moz-document url-prefix() {
|
|
129
|
-
/* Firefox is smart enough to align overflowing text to right */
|
|
130
|
-
:host([theme~='align-right']) ::slotted(:not([slot$='fix'])) {
|
|
131
|
-
--_lumo-text-field-overflow-mask-image: linear-gradient(to right, transparent 0.25em, #000 1.5em);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
@-moz-document url-prefix() {
|
|
136
|
-
/* Firefox is smart enough to align overflowing text to right */
|
|
137
|
-
:host([theme~='align-left']) ::slotted(:not([slot$='fix'])) {
|
|
138
|
-
--_lumo-text-field-overflow-mask-image: linear-gradient(to left, transparent 0.25em, #000 1.5em);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/* RTL specific styles */
|
|
143
|
-
:host([dir='rtl'])::after {
|
|
144
|
-
transform-origin: 0% 0;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
:host([theme~='align-left'][dir='rtl']) ::slotted(:not([slot$='fix'])) {
|
|
148
|
-
--_lumo-text-field-overflow-mask-image: none;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
:host([theme~='align-center'][dir='rtl']) ::slotted(:not([slot$='fix'])) {
|
|
152
|
-
--_lumo-text-field-overflow-mask-image: none;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
:host([theme~='align-right'][dir='rtl']) ::slotted(:not([slot$='fix'])) {
|
|
156
|
-
--_lumo-text-field-overflow-mask-image: none;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
@-moz-document url-prefix() {
|
|
160
|
-
/* Firefox is smart enough to align overflowing text to right */
|
|
161
|
-
:host([theme~='align-right'][dir='rtl']) ::slotted(:not([slot$='fix'])) {
|
|
162
|
-
--_lumo-text-field-overflow-mask-image: linear-gradient(to right, transparent 0.25em, #000 1.5em);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
@-moz-document url-prefix() {
|
|
167
|
-
/* Firefox is smart enough to align overflowing text to right */
|
|
168
|
-
:host([theme~='align-left'][dir='rtl']) ::slotted(:not([slot$='fix'])) {
|
|
169
|
-
--_lumo-text-field-overflow-mask-image: linear-gradient(to left, transparent 0.25em, #000 1.5em);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
`,
|
|
173
|
-
{ moduleId: 'lumo-input-container' },
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* @license
|
|
178
|
-
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
179
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
180
|
-
*/
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* @customElement
|
|
184
|
-
* @extends HTMLElement
|
|
185
|
-
* @mixes ThemableMixin
|
|
186
|
-
* @mixes DirMixin
|
|
187
|
-
*/
|
|
188
|
-
class InputContainer extends ThemableMixin(DirMixin(PolymerElement)) {
|
|
189
|
-
static get is() {
|
|
190
|
-
return 'vaadin-input-container';
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
static get template() {
|
|
194
|
-
return html`
|
|
195
|
-
<style>
|
|
196
|
-
:host {
|
|
197
|
-
display: flex;
|
|
198
|
-
align-items: center;
|
|
199
|
-
flex: 0 1 auto;
|
|
200
|
-
border-radius:
|
|
201
|
-
/* See https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius */
|
|
202
|
-
var(--vaadin-input-field-top-start-radius, var(--__border-radius))
|
|
203
|
-
var(--vaadin-input-field-top-end-radius, var(--__border-radius))
|
|
204
|
-
var(--vaadin-input-field-bottom-end-radius, var(--__border-radius))
|
|
205
|
-
var(--vaadin-input-field-bottom-start-radius, var(--__border-radius));
|
|
206
|
-
--_border-radius: var(--vaadin-input-field-border-radius, 0px);
|
|
207
|
-
--_input-border-width: var(--vaadin-input-field-border-width, 0);
|
|
208
|
-
--_input-border-color: var(--vaadin-input-field-border-color, transparent);
|
|
209
|
-
box-shadow: inset 0 0 0 var(--_input-border-width, 0) var(--_input-border-color);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
:host([dir='rtl']) {
|
|
213
|
-
border-radius:
|
|
214
|
-
/* Don't use logical props, see https://github.com/vaadin/vaadin-time-picker/issues/145 */
|
|
215
|
-
var(--vaadin-input-field-top-end-radius, var(--_border-radius))
|
|
216
|
-
var(--vaadin-input-field-top-start-radius, var(--_border-radius))
|
|
217
|
-
var(--vaadin-input-field-bottom-start-radius, var(--_border-radius))
|
|
218
|
-
var(--vaadin-input-field-bottom-end-radius, var(--_border-radius));
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
:host([hidden]) {
|
|
222
|
-
display: none !important;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/* Reset the native input styles */
|
|
226
|
-
::slotted(input) {
|
|
227
|
-
-webkit-appearance: none;
|
|
228
|
-
-moz-appearance: none;
|
|
229
|
-
flex: auto;
|
|
230
|
-
white-space: nowrap;
|
|
231
|
-
overflow: hidden;
|
|
232
|
-
width: 100%;
|
|
233
|
-
height: 100%;
|
|
234
|
-
outline: none;
|
|
235
|
-
margin: 0;
|
|
236
|
-
padding: 0;
|
|
237
|
-
border: 0;
|
|
238
|
-
border-radius: 0;
|
|
239
|
-
min-width: 0;
|
|
240
|
-
font: inherit;
|
|
241
|
-
line-height: normal;
|
|
242
|
-
color: inherit;
|
|
243
|
-
background-color: transparent;
|
|
244
|
-
/* Disable default invalid style in Firefox */
|
|
245
|
-
box-shadow: none;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
::slotted(*) {
|
|
249
|
-
flex: none;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
::slotted(:is(input, textarea))::placeholder {
|
|
253
|
-
/* Use ::slotted(input:placeholder-shown) in themes to style the placeholder. */
|
|
254
|
-
/* because ::slotted(...)::placeholder does not work in Safari. */
|
|
255
|
-
font: inherit;
|
|
256
|
-
color: inherit;
|
|
257
|
-
/* Override default opacity in Firefox */
|
|
258
|
-
opacity: 1;
|
|
259
|
-
}
|
|
260
|
-
</style>
|
|
261
|
-
<slot name="prefix"></slot>
|
|
262
|
-
<slot></slot>
|
|
263
|
-
<slot name="suffix"></slot>
|
|
264
|
-
`;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
static get properties() {
|
|
268
|
-
return {
|
|
269
|
-
/**
|
|
270
|
-
* If true, the user cannot interact with this element.
|
|
271
|
-
*/
|
|
272
|
-
disabled: {
|
|
273
|
-
type: Boolean,
|
|
274
|
-
reflectToAttribute: true,
|
|
275
|
-
},
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Set to true to make this element read-only.
|
|
279
|
-
*/
|
|
280
|
-
readonly: {
|
|
281
|
-
type: Boolean,
|
|
282
|
-
reflectToAttribute: true,
|
|
283
|
-
},
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Set to true when the element is invalid.
|
|
287
|
-
*/
|
|
288
|
-
invalid: {
|
|
289
|
-
type: Boolean,
|
|
290
|
-
reflectToAttribute: true,
|
|
291
|
-
},
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/** @protected */
|
|
296
|
-
ready() {
|
|
297
|
-
super.ready();
|
|
298
|
-
|
|
299
|
-
this.addEventListener('pointerdown', (event) => {
|
|
300
|
-
if (event.target === this) {
|
|
301
|
-
// Prevent direct clicks to the input container from blurring the input
|
|
302
|
-
event.preventDefault();
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
this.addEventListener('click', (event) => {
|
|
307
|
-
if (event.target === this) {
|
|
308
|
-
// The vaadin-input-container element was directly clicked,
|
|
309
|
-
// focus any focusable child element from the default slot
|
|
310
|
-
this.shadowRoot
|
|
311
|
-
.querySelector('slot:not([name])')
|
|
312
|
-
.assignedNodes({ flatten: true })
|
|
313
|
-
.forEach((node) => node.focus && node.focus());
|
|
314
|
-
}
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
defineCustomElement(InputContainer);
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* @license
|
|
323
|
-
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
324
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
325
|
-
*/
|
|
326
|
-
|
|
327
|
-
const fieldButton = i`
|
|
328
|
-
[part$='button'] {
|
|
329
|
-
flex: none;
|
|
330
|
-
width: 1em;
|
|
331
|
-
height: 1em;
|
|
332
|
-
line-height: 1;
|
|
333
|
-
font-size: var(--lumo-icon-size-m);
|
|
334
|
-
text-align: center;
|
|
335
|
-
color: var(--lumo-contrast-60pct);
|
|
336
|
-
transition: 0.2s color;
|
|
337
|
-
cursor: var(--lumo-clickable-cursor);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
[part$='button']:hover {
|
|
341
|
-
color: var(--lumo-contrast-90pct);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
:host([disabled]) [part$='button'],
|
|
345
|
-
:host([readonly]) [part$='button'] {
|
|
346
|
-
color: var(--lumo-contrast-20pct);
|
|
347
|
-
cursor: default;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
[part$='button']::before {
|
|
351
|
-
font-family: 'lumo-icons';
|
|
352
|
-
display: block;
|
|
353
|
-
}
|
|
354
|
-
`;
|
|
355
|
-
registerStyles('', fieldButton, { moduleId: 'lumo-field-button' });
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* @license
|
|
359
|
-
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
360
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
361
|
-
*/
|
|
362
|
-
|
|
363
|
-
const inputField = i`
|
|
364
|
-
:host {
|
|
365
|
-
--lumo-text-field-size: var(--lumo-size-m);
|
|
366
|
-
color: var(--lumo-body-text-color);
|
|
367
|
-
font-size: var(--lumo-font-size-m);
|
|
368
|
-
font-family: var(--lumo-font-family);
|
|
369
|
-
-webkit-font-smoothing: antialiased;
|
|
370
|
-
-moz-osx-font-smoothing: grayscale;
|
|
371
|
-
-webkit-tap-highlight-color: transparent;
|
|
372
|
-
padding: var(--lumo-space-xs) 0;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
:host::before {
|
|
376
|
-
height: var(--lumo-text-field-size);
|
|
377
|
-
box-sizing: border-box;
|
|
378
|
-
display: inline-flex;
|
|
379
|
-
align-items: center;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
:host([focused]:not([readonly])) [part='label'] {
|
|
383
|
-
color: var(--lumo-primary-text-color);
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
:host([focused]) [part='input-field'] ::slotted(:is(input, textarea)) {
|
|
387
|
-
-webkit-mask-image: none;
|
|
388
|
-
mask-image: none;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
::slotted(:is(input, textarea):placeholder-shown) {
|
|
392
|
-
color: var(--lumo-secondary-text-color);
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
/* Hover */
|
|
396
|
-
:host(:hover:not([readonly]):not([focused])) [part='label'] {
|
|
397
|
-
color: var(--lumo-body-text-color);
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
:host(:hover:not([readonly]):not([focused])) [part='input-field']::after {
|
|
401
|
-
opacity: 0.1;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
/* Touch device adjustment */
|
|
405
|
-
@media (pointer: coarse) {
|
|
406
|
-
:host(:hover:not([readonly]):not([focused])) [part='label'] {
|
|
407
|
-
color: var(--lumo-secondary-text-color);
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
:host(:hover:not([readonly]):not([focused])) [part='input-field']::after {
|
|
411
|
-
opacity: 0;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
:host(:active:not([readonly]):not([focused])) [part='input-field']::after {
|
|
415
|
-
opacity: 0.2;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
/* Trigger when not focusing using the keyboard */
|
|
420
|
-
:host([focused]:not([focus-ring]):not([readonly])) [part='input-field']::after {
|
|
421
|
-
transform: scaleX(0);
|
|
422
|
-
transition-duration: 0.15s, 1s;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
/* Focus-ring */
|
|
426
|
-
:host([focus-ring]) [part='input-field'] {
|
|
427
|
-
box-shadow: 0 0 0 2px var(--lumo-primary-color-50pct);
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
/* Read-only and disabled */
|
|
431
|
-
:host(:is([readonly], [disabled])) ::slotted(:is(input, textarea):placeholder-shown) {
|
|
432
|
-
opacity: 0;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
/* Read-only style */
|
|
436
|
-
:host([readonly]) {
|
|
437
|
-
--vaadin-input-field-border-color: transparent;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
/* Disabled style */
|
|
441
|
-
:host([disabled]) {
|
|
442
|
-
pointer-events: none;
|
|
443
|
-
--vaadin-input-field-border-color: var(--lumo-contrast-20pct);
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
:host([disabled]) [part='label'],
|
|
447
|
-
:host([disabled]) [part='input-field'] ::slotted(*) {
|
|
448
|
-
color: var(--lumo-disabled-text-color);
|
|
449
|
-
-webkit-text-fill-color: var(--lumo-disabled-text-color);
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
/* Invalid style */
|
|
453
|
-
:host([invalid]) {
|
|
454
|
-
--vaadin-input-field-border-color: var(--lumo-error-color);
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
:host([invalid][focus-ring]) [part='input-field'] {
|
|
458
|
-
box-shadow: 0 0 0 2px var(--lumo-error-color-50pct);
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
:host([input-prevented]) [part='input-field'] {
|
|
462
|
-
animation: shake 0.15s infinite;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
@keyframes shake {
|
|
466
|
-
25% {
|
|
467
|
-
transform: translateX(4px);
|
|
468
|
-
}
|
|
469
|
-
75% {
|
|
470
|
-
transform: translateX(-4px);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
/* Small theme */
|
|
475
|
-
:host([theme~='small']) {
|
|
476
|
-
font-size: var(--lumo-font-size-s);
|
|
477
|
-
--lumo-text-field-size: var(--lumo-size-s);
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
:host([theme~='small']) [part='label'] {
|
|
481
|
-
font-size: var(--lumo-font-size-xs);
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
:host([theme~='small']) [part='error-message'] {
|
|
485
|
-
font-size: var(--lumo-font-size-xxs);
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
/* Slotted content */
|
|
489
|
-
[part='input-field'] ::slotted(:not(vaadin-icon):not(input):not(textarea)) {
|
|
490
|
-
color: var(--lumo-secondary-text-color);
|
|
491
|
-
font-weight: 400;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
[part='clear-button']::before {
|
|
495
|
-
content: var(--lumo-icons-cross);
|
|
496
|
-
}
|
|
497
|
-
`;
|
|
498
|
-
|
|
499
|
-
const inputFieldShared$1 = [requiredField, fieldButton, helper, inputField];
|
|
500
|
-
|
|
501
|
-
registerStyles('', inputFieldShared$1, {
|
|
502
|
-
moduleId: 'lumo-input-field-shared-styles',
|
|
503
|
-
});
|
|
504
|
-
|
|
505
|
-
/**
|
|
506
|
-
* @license
|
|
507
|
-
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
508
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
509
|
-
*/
|
|
510
|
-
|
|
511
|
-
const testUserAgent = (regexp) => regexp.test(navigator.userAgent);
|
|
512
|
-
|
|
513
|
-
const testPlatform = (regexp) => regexp.test(navigator.platform);
|
|
514
|
-
|
|
515
|
-
const testVendor = (regexp) => regexp.test(navigator.vendor);
|
|
516
|
-
|
|
517
|
-
testUserAgent(/Android/u);
|
|
518
|
-
|
|
519
|
-
testUserAgent(/Chrome/u) && testVendor(/Google Inc/u);
|
|
520
|
-
|
|
521
|
-
const isFirefox = testUserAgent(/Firefox/u);
|
|
522
|
-
|
|
523
|
-
// IPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
|
|
524
|
-
const isIPad = testPlatform(/^iPad/u) || (testPlatform(/^Mac/u) && navigator.maxTouchPoints > 1);
|
|
525
|
-
|
|
526
|
-
const isIPhone = testPlatform(/^iPhone/u);
|
|
527
|
-
|
|
528
|
-
const isIOS = isIPhone || isIPad;
|
|
529
|
-
|
|
530
|
-
const isSafari = testUserAgent(/^((?!chrome|android).)*safari/iu);
|
|
531
|
-
|
|
532
|
-
const isTouch = (() => {
|
|
533
|
-
try {
|
|
534
|
-
document.createEvent('TouchEvent');
|
|
535
|
-
return true;
|
|
536
|
-
} catch (e) {
|
|
537
|
-
return false;
|
|
538
|
-
}
|
|
539
|
-
})();
|
|
540
|
-
|
|
541
|
-
/**
|
|
542
|
-
* @license
|
|
543
|
-
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
544
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
545
|
-
*/
|
|
546
|
-
|
|
547
|
-
const stylesMap = new WeakMap();
|
|
548
|
-
|
|
549
|
-
/**
|
|
550
|
-
* Get all the styles inserted into root.
|
|
551
|
-
* @param {DocumentOrShadowRoot} root
|
|
552
|
-
* @return {Set<string>}
|
|
553
|
-
*/
|
|
554
|
-
function getRootStyles(root) {
|
|
555
|
-
if (!stylesMap.has(root)) {
|
|
556
|
-
stylesMap.set(root, new Set());
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
return stylesMap.get(root);
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
/**
|
|
563
|
-
* Insert styles into the root.
|
|
564
|
-
* @param {string} styles
|
|
565
|
-
* @param {DocumentOrShadowRoot} root
|
|
566
|
-
*/
|
|
567
|
-
function insertStyles(styles, root) {
|
|
568
|
-
const style = document.createElement('style');
|
|
569
|
-
style.textContent = styles;
|
|
570
|
-
|
|
571
|
-
if (root === document) {
|
|
572
|
-
document.head.appendChild(style);
|
|
573
|
-
} else {
|
|
574
|
-
root.insertBefore(style, root.firstChild);
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
/**
|
|
579
|
-
* Mixin to insert styles into the outer scope to handle slotted components.
|
|
580
|
-
* This is useful e.g. to hide native `<input type="number">` controls.
|
|
581
|
-
*
|
|
582
|
-
* @polymerMixin
|
|
583
|
-
*/
|
|
584
|
-
const SlotStylesMixin = dedupingMixin(
|
|
585
|
-
(superclass) =>
|
|
586
|
-
class SlotStylesMixinClass extends superclass {
|
|
587
|
-
/**
|
|
588
|
-
* List of styles to insert into root.
|
|
589
|
-
* @protected
|
|
590
|
-
*/
|
|
591
|
-
get slotStyles() {
|
|
592
|
-
return {};
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
/** @protected */
|
|
596
|
-
connectedCallback() {
|
|
597
|
-
super.connectedCallback();
|
|
598
|
-
|
|
599
|
-
this.__applySlotStyles();
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
/** @private */
|
|
603
|
-
__applySlotStyles() {
|
|
604
|
-
const root = this.getRootNode();
|
|
605
|
-
const rootStyles = getRootStyles(root);
|
|
606
|
-
|
|
607
|
-
this.slotStyles.forEach((styles) => {
|
|
608
|
-
if (!rootStyles.has(styles)) {
|
|
609
|
-
insertStyles(styles, root);
|
|
610
|
-
rootStyles.add(styles);
|
|
611
|
-
}
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
},
|
|
615
|
-
);
|
|
616
|
-
|
|
617
|
-
/**
|
|
618
|
-
* @license
|
|
619
|
-
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
620
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
621
|
-
*/
|
|
622
|
-
|
|
623
|
-
/**
|
|
624
|
-
* A mixin that manages the clear button.
|
|
625
|
-
*
|
|
626
|
-
* @polymerMixin
|
|
627
|
-
* @mixes InputMixin
|
|
628
|
-
* @mixes KeyboardMixin
|
|
629
|
-
*/
|
|
630
|
-
const ClearButtonMixin = (superclass) =>
|
|
631
|
-
class ClearButtonMixinClass extends InputMixin(KeyboardMixin(superclass)) {
|
|
632
|
-
static get properties() {
|
|
633
|
-
return {
|
|
634
|
-
/**
|
|
635
|
-
* Set to true to display the clear icon which clears the input.
|
|
636
|
-
*
|
|
637
|
-
* It is up to the component to choose where to place the clear icon:
|
|
638
|
-
* in the Shadow DOM or in the light DOM. In any way, a reference to
|
|
639
|
-
* the clear icon element should be provided via the `clearElement` getter.
|
|
640
|
-
*
|
|
641
|
-
* @attr {boolean} clear-button-visible
|
|
642
|
-
*/
|
|
643
|
-
clearButtonVisible: {
|
|
644
|
-
type: Boolean,
|
|
645
|
-
reflectToAttribute: true,
|
|
646
|
-
value: false,
|
|
647
|
-
},
|
|
648
|
-
};
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
/**
|
|
652
|
-
* Any element extending this mixin is required to implement this getter.
|
|
653
|
-
* It returns the reference to the clear button element.
|
|
654
|
-
*
|
|
655
|
-
* @protected
|
|
656
|
-
* @return {Element | null | undefined}
|
|
657
|
-
*/
|
|
658
|
-
get clearElement() {
|
|
659
|
-
console.warn(`Please implement the 'clearElement' property in <${this.localName}>`);
|
|
660
|
-
return null;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
/** @protected */
|
|
664
|
-
ready() {
|
|
665
|
-
super.ready();
|
|
666
|
-
|
|
667
|
-
if (this.clearElement) {
|
|
668
|
-
this.clearElement.addEventListener('mousedown', (event) => this._onClearButtonMouseDown(event));
|
|
669
|
-
this.clearElement.addEventListener('click', (event) => this._onClearButtonClick(event));
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
/**
|
|
674
|
-
* @param {Event} event
|
|
675
|
-
* @protected
|
|
676
|
-
*/
|
|
677
|
-
_onClearButtonClick(event) {
|
|
678
|
-
event.preventDefault();
|
|
679
|
-
this._onClearAction();
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
/**
|
|
683
|
-
* @param {MouseEvent} event
|
|
684
|
-
* @protected
|
|
685
|
-
*/
|
|
686
|
-
_onClearButtonMouseDown(event) {
|
|
687
|
-
event.preventDefault();
|
|
688
|
-
if (!isTouch) {
|
|
689
|
-
this.inputElement.focus();
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
/**
|
|
694
|
-
* Override an event listener inherited from `KeydownMixin` to clear on Esc.
|
|
695
|
-
* Components that extend this mixin can prevent this behavior by overriding
|
|
696
|
-
* this method without calling `super._onEscape` to provide custom logic.
|
|
697
|
-
*
|
|
698
|
-
* @param {KeyboardEvent} event
|
|
699
|
-
* @protected
|
|
700
|
-
* @override
|
|
701
|
-
*/
|
|
702
|
-
_onEscape(event) {
|
|
703
|
-
super._onEscape(event);
|
|
704
|
-
|
|
705
|
-
if (this.clearButtonVisible && !!this.value) {
|
|
706
|
-
event.stopPropagation();
|
|
707
|
-
this._onClearAction();
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
/**
|
|
712
|
-
* Clears the value and dispatches `input` and `change` events
|
|
713
|
-
* on the input element. This method should be called
|
|
714
|
-
* when the clear action originates from the user.
|
|
715
|
-
*
|
|
716
|
-
* @protected
|
|
717
|
-
*/
|
|
718
|
-
_onClearAction() {
|
|
719
|
-
this.clear();
|
|
720
|
-
// Note, according to the HTML spec, the native change event isn't composed
|
|
721
|
-
// while the input event is composed.
|
|
722
|
-
this.inputElement.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
|
723
|
-
this.inputElement.dispatchEvent(new Event('change', { bubbles: true }));
|
|
724
|
-
}
|
|
725
|
-
};
|
|
726
|
-
|
|
727
|
-
/**
|
|
728
|
-
* @license
|
|
729
|
-
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
730
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
731
|
-
*/
|
|
732
|
-
|
|
733
|
-
/**
|
|
734
|
-
* A mixin to combine multiple input validation constraints.
|
|
735
|
-
*
|
|
736
|
-
* @polymerMixin
|
|
737
|
-
* @mixes DelegateStateMixin
|
|
738
|
-
* @mixes InputMixin
|
|
739
|
-
* @mixes ValidateMixin
|
|
740
|
-
*/
|
|
741
|
-
const InputConstraintsMixin = dedupingMixin(
|
|
742
|
-
(superclass) =>
|
|
743
|
-
class InputConstraintsMixinClass extends DelegateStateMixin(ValidateMixin(InputMixin(superclass))) {
|
|
744
|
-
/**
|
|
745
|
-
* An array of attributes which participate in the input validation.
|
|
746
|
-
* Changing these attributes will cause the input to re-validate.
|
|
747
|
-
*
|
|
748
|
-
* IMPORTANT: The attributes should be properly delegated to the input element
|
|
749
|
-
* from the host using `delegateAttrs` getter (see `DelegateStateMixin`).
|
|
750
|
-
* The `required` attribute is already delegated.
|
|
751
|
-
*/
|
|
752
|
-
static get constraints() {
|
|
753
|
-
return ['required'];
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
static get delegateAttrs() {
|
|
757
|
-
return [...super.delegateAttrs, 'required'];
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
/** @protected */
|
|
761
|
-
ready() {
|
|
762
|
-
super.ready();
|
|
763
|
-
|
|
764
|
-
this._createConstraintsObserver();
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
/**
|
|
768
|
-
* Returns true if the current input value satisfies all constraints (if any).
|
|
769
|
-
* @return {boolean}
|
|
770
|
-
*/
|
|
771
|
-
checkValidity() {
|
|
772
|
-
if (this.inputElement && this._hasValidConstraints(this.constructor.constraints.map((c) => this[c]))) {
|
|
773
|
-
return this.inputElement.checkValidity();
|
|
774
|
-
}
|
|
775
|
-
return !this.invalid;
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
/**
|
|
779
|
-
* Returns true if some of the provided set of constraints are valid.
|
|
780
|
-
* @param {Array} constraints
|
|
781
|
-
* @return {boolean}
|
|
782
|
-
* @protected
|
|
783
|
-
*/
|
|
784
|
-
_hasValidConstraints(constraints) {
|
|
785
|
-
return constraints.some((c) => this.__isValidConstraint(c));
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
/**
|
|
789
|
-
* Override this method to customize setting up constraints observer.
|
|
790
|
-
* @protected
|
|
791
|
-
*/
|
|
792
|
-
_createConstraintsObserver() {
|
|
793
|
-
// This complex observer needs to be added dynamically instead of using `static get observers()`
|
|
794
|
-
// to make it possible to tweak this behavior in classes that apply this mixin.
|
|
795
|
-
this._createMethodObserver(`_constraintsChanged(stateTarget, ${this.constructor.constraints.join(', ')})`);
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
/**
|
|
799
|
-
* Override this method to implement custom validation constraints.
|
|
800
|
-
* @param {HTMLElement | undefined} stateTarget
|
|
801
|
-
* @param {unknown[]} constraints
|
|
802
|
-
* @protected
|
|
803
|
-
*/
|
|
804
|
-
_constraintsChanged(stateTarget, ...constraints) {
|
|
805
|
-
// The input element's validity cannot be determined until
|
|
806
|
-
// all the necessary constraint attributes aren't set on it.
|
|
807
|
-
if (!stateTarget) {
|
|
808
|
-
return;
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
const hasConstraints = this._hasValidConstraints(constraints);
|
|
812
|
-
const isLastConstraintRemoved = this.__previousHasConstraints && !hasConstraints;
|
|
813
|
-
|
|
814
|
-
if ((this._hasValue || this.invalid) && hasConstraints) {
|
|
815
|
-
this.validate();
|
|
816
|
-
} else if (isLastConstraintRemoved) {
|
|
817
|
-
this._setInvalid(false);
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
this.__previousHasConstraints = hasConstraints;
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
/**
|
|
824
|
-
* Override an event listener inherited from `InputMixin`
|
|
825
|
-
* to capture native `change` event and make sure that
|
|
826
|
-
* a new one is dispatched after validation runs.
|
|
827
|
-
* @param {Event} event
|
|
828
|
-
* @protected
|
|
829
|
-
* @override
|
|
830
|
-
*/
|
|
831
|
-
_onChange(event) {
|
|
832
|
-
event.stopPropagation();
|
|
833
|
-
|
|
834
|
-
this.validate();
|
|
835
|
-
|
|
836
|
-
this.dispatchEvent(
|
|
837
|
-
new CustomEvent('change', {
|
|
838
|
-
detail: {
|
|
839
|
-
sourceEvent: event,
|
|
840
|
-
},
|
|
841
|
-
bubbles: event.bubbles,
|
|
842
|
-
cancelable: event.cancelable,
|
|
843
|
-
}),
|
|
844
|
-
);
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
/** @private */
|
|
848
|
-
__isValidConstraint(constraint) {
|
|
849
|
-
// 0 is valid for `minlength` and `maxlength`
|
|
850
|
-
return Boolean(constraint) || constraint === 0;
|
|
851
|
-
}
|
|
852
|
-
},
|
|
853
|
-
);
|
|
854
|
-
|
|
855
|
-
/**
|
|
856
|
-
* @license
|
|
857
|
-
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
858
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
859
|
-
*/
|
|
860
|
-
|
|
861
|
-
/**
|
|
862
|
-
* A mixin to provide shared logic for the editable form input controls.
|
|
863
|
-
*
|
|
864
|
-
* @polymerMixin
|
|
865
|
-
* @mixes DelegateFocusMixin
|
|
866
|
-
* @mixes FieldMixin
|
|
867
|
-
* @mixes InputConstraintsMixin
|
|
868
|
-
* @mixes KeyboardMixin
|
|
869
|
-
* @mixes ClearButtonMixin
|
|
870
|
-
* @mixes SlotStylesMixin
|
|
871
|
-
*/
|
|
872
|
-
const InputControlMixin = (superclass) =>
|
|
873
|
-
class InputControlMixinClass extends SlotStylesMixin(
|
|
874
|
-
DelegateFocusMixin(InputConstraintsMixin(FieldMixin(ClearButtonMixin(KeyboardMixin(superclass))))),
|
|
875
|
-
) {
|
|
876
|
-
static get properties() {
|
|
877
|
-
return {
|
|
878
|
-
/**
|
|
879
|
-
* A pattern matched against individual characters the user inputs.
|
|
880
|
-
*
|
|
881
|
-
* When set, the field will prevent:
|
|
882
|
-
* - `keydown` events if the entered key doesn't match `/^allowedCharPattern$/`
|
|
883
|
-
* - `paste` events if the pasted text doesn't match `/^allowedCharPattern*$/`
|
|
884
|
-
* - `drop` events if the dropped text doesn't match `/^allowedCharPattern*$/`
|
|
885
|
-
*
|
|
886
|
-
* For example, to allow entering only numbers and minus signs, use:
|
|
887
|
-
* `allowedCharPattern = "[\\d-]"`
|
|
888
|
-
* @attr {string} allowed-char-pattern
|
|
889
|
-
*/
|
|
890
|
-
allowedCharPattern: {
|
|
891
|
-
type: String,
|
|
892
|
-
observer: '_allowedCharPatternChanged',
|
|
893
|
-
},
|
|
894
|
-
|
|
895
|
-
/**
|
|
896
|
-
* If true, the input text gets fully selected when the field is focused using click or touch / tap.
|
|
897
|
-
*/
|
|
898
|
-
autoselect: {
|
|
899
|
-
type: Boolean,
|
|
900
|
-
value: false,
|
|
901
|
-
},
|
|
902
|
-
|
|
903
|
-
/**
|
|
904
|
-
* The name of this field.
|
|
905
|
-
*/
|
|
906
|
-
name: {
|
|
907
|
-
type: String,
|
|
908
|
-
reflectToAttribute: true,
|
|
909
|
-
},
|
|
910
|
-
|
|
911
|
-
/**
|
|
912
|
-
* A hint to the user of what can be entered in the field.
|
|
913
|
-
*/
|
|
914
|
-
placeholder: {
|
|
915
|
-
type: String,
|
|
916
|
-
reflectToAttribute: true,
|
|
917
|
-
},
|
|
918
|
-
|
|
919
|
-
/**
|
|
920
|
-
* When present, it specifies that the field is read-only.
|
|
921
|
-
*/
|
|
922
|
-
readonly: {
|
|
923
|
-
type: Boolean,
|
|
924
|
-
value: false,
|
|
925
|
-
reflectToAttribute: true,
|
|
926
|
-
},
|
|
927
|
-
|
|
928
|
-
/**
|
|
929
|
-
* The text usually displayed in a tooltip popup when the mouse is over the field.
|
|
930
|
-
*/
|
|
931
|
-
title: {
|
|
932
|
-
type: String,
|
|
933
|
-
reflectToAttribute: true,
|
|
934
|
-
},
|
|
935
|
-
};
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
static get delegateAttrs() {
|
|
939
|
-
return [...super.delegateAttrs, 'name', 'type', 'placeholder', 'readonly', 'invalid', 'title'];
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
constructor() {
|
|
943
|
-
super();
|
|
944
|
-
|
|
945
|
-
this._boundOnPaste = this._onPaste.bind(this);
|
|
946
|
-
this._boundOnDrop = this._onDrop.bind(this);
|
|
947
|
-
this._boundOnBeforeInput = this._onBeforeInput.bind(this);
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
/** @protected */
|
|
951
|
-
get slotStyles() {
|
|
952
|
-
// Needed for Safari, where ::slotted(...)::placeholder does not work
|
|
953
|
-
return [
|
|
954
|
-
`
|
|
955
|
-
:is(input[slot='input'], textarea[slot='textarea'])::placeholder {
|
|
956
|
-
font: inherit;
|
|
957
|
-
color: inherit;
|
|
958
|
-
}
|
|
959
|
-
`,
|
|
960
|
-
];
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
/**
|
|
964
|
-
* Override an event listener from `DelegateFocusMixin`.
|
|
965
|
-
* @param {FocusEvent} event
|
|
966
|
-
* @protected
|
|
967
|
-
* @override
|
|
968
|
-
*/
|
|
969
|
-
_onFocus(event) {
|
|
970
|
-
super._onFocus(event);
|
|
971
|
-
|
|
972
|
-
if (this.autoselect && this.inputElement) {
|
|
973
|
-
this.inputElement.select();
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
/**
|
|
978
|
-
* Override an event listener inherited from `InputMixin`
|
|
979
|
-
* to capture native `change` event and make sure that
|
|
980
|
-
* a new one is dispatched after validation runs.
|
|
981
|
-
* @param {Event} event
|
|
982
|
-
* @protected
|
|
983
|
-
* @override
|
|
984
|
-
*/
|
|
985
|
-
_onChange(event) {
|
|
986
|
-
event.stopPropagation();
|
|
987
|
-
|
|
988
|
-
this.validate();
|
|
989
|
-
|
|
990
|
-
this.dispatchEvent(
|
|
991
|
-
new CustomEvent('change', {
|
|
992
|
-
detail: {
|
|
993
|
-
sourceEvent: event,
|
|
994
|
-
},
|
|
995
|
-
bubbles: event.bubbles,
|
|
996
|
-
cancelable: event.cancelable,
|
|
997
|
-
}),
|
|
998
|
-
);
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
/**
|
|
1002
|
-
* Override a method from `InputMixin`.
|
|
1003
|
-
* @param {!HTMLElement} input
|
|
1004
|
-
* @protected
|
|
1005
|
-
* @override
|
|
1006
|
-
*/
|
|
1007
|
-
_addInputListeners(input) {
|
|
1008
|
-
super._addInputListeners(input);
|
|
1009
|
-
|
|
1010
|
-
input.addEventListener('paste', this._boundOnPaste);
|
|
1011
|
-
input.addEventListener('drop', this._boundOnDrop);
|
|
1012
|
-
input.addEventListener('beforeinput', this._boundOnBeforeInput);
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
/**
|
|
1016
|
-
* Override a method from `InputMixin`.
|
|
1017
|
-
* @param {!HTMLElement} input
|
|
1018
|
-
* @protected
|
|
1019
|
-
* @override
|
|
1020
|
-
*/
|
|
1021
|
-
_removeInputListeners(input) {
|
|
1022
|
-
super._removeInputListeners(input);
|
|
1023
|
-
|
|
1024
|
-
input.removeEventListener('paste', this._boundOnPaste);
|
|
1025
|
-
input.removeEventListener('drop', this._boundOnDrop);
|
|
1026
|
-
input.removeEventListener('beforeinput', this._boundOnBeforeInput);
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
/**
|
|
1030
|
-
* Override an event listener from `KeyboardMixin`.
|
|
1031
|
-
* @param {!KeyboardEvent} event
|
|
1032
|
-
* @protected
|
|
1033
|
-
* @override
|
|
1034
|
-
*/
|
|
1035
|
-
_onKeyDown(event) {
|
|
1036
|
-
super._onKeyDown(event);
|
|
1037
|
-
|
|
1038
|
-
if (this.allowedCharPattern && !this.__shouldAcceptKey(event)) {
|
|
1039
|
-
event.preventDefault();
|
|
1040
|
-
this._markInputPrevented();
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
/** @protected */
|
|
1045
|
-
_markInputPrevented() {
|
|
1046
|
-
// Add input-prevented attribute for 200ms
|
|
1047
|
-
this.setAttribute('input-prevented', '');
|
|
1048
|
-
this._preventInputDebouncer = Debouncer.debounce(this._preventInputDebouncer, timeOut.after(200), () => {
|
|
1049
|
-
this.removeAttribute('input-prevented');
|
|
1050
|
-
});
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
/** @private */
|
|
1054
|
-
__shouldAcceptKey(event) {
|
|
1055
|
-
return (
|
|
1056
|
-
event.metaKey ||
|
|
1057
|
-
event.ctrlKey ||
|
|
1058
|
-
!event.key || // Allow typing anything if event.key is not supported
|
|
1059
|
-
event.key.length !== 1 || // Allow "Backspace", "ArrowLeft" etc.
|
|
1060
|
-
this.__allowedCharRegExp.test(event.key)
|
|
1061
|
-
);
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
/** @private */
|
|
1065
|
-
_onPaste(e) {
|
|
1066
|
-
if (this.allowedCharPattern) {
|
|
1067
|
-
const pastedText = e.clipboardData.getData('text');
|
|
1068
|
-
if (!this.__allowedTextRegExp.test(pastedText)) {
|
|
1069
|
-
e.preventDefault();
|
|
1070
|
-
this._markInputPrevented();
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
/** @private */
|
|
1076
|
-
_onDrop(e) {
|
|
1077
|
-
if (this.allowedCharPattern) {
|
|
1078
|
-
const draggedText = e.dataTransfer.getData('text');
|
|
1079
|
-
if (!this.__allowedTextRegExp.test(draggedText)) {
|
|
1080
|
-
e.preventDefault();
|
|
1081
|
-
this._markInputPrevented();
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
/** @private */
|
|
1087
|
-
_onBeforeInput(e) {
|
|
1088
|
-
// The `beforeinput` event covers all the cases for `allowedCharPattern`: keyboard, pasting and dropping,
|
|
1089
|
-
// but it is still experimental technology so we can't rely on it. It's used here just as an additional check,
|
|
1090
|
-
// because it seems to be the only way to detect and prevent specific keys on mobile devices.
|
|
1091
|
-
// See https://github.com/vaadin/vaadin-text-field/issues/429
|
|
1092
|
-
if (this.allowedCharPattern && e.data && !this.__allowedTextRegExp.test(e.data)) {
|
|
1093
|
-
e.preventDefault();
|
|
1094
|
-
this._markInputPrevented();
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
/** @private */
|
|
1099
|
-
_allowedCharPatternChanged(charPattern) {
|
|
1100
|
-
if (charPattern) {
|
|
1101
|
-
try {
|
|
1102
|
-
this.__allowedCharRegExp = new RegExp(`^${charPattern}$`, 'u');
|
|
1103
|
-
this.__allowedTextRegExp = new RegExp(`^${charPattern}*$`, 'u');
|
|
1104
|
-
} catch (e) {
|
|
1105
|
-
console.error(e);
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
/**
|
|
1111
|
-
* Fired when the user commits a value change.
|
|
1112
|
-
*
|
|
1113
|
-
* @event change
|
|
1114
|
-
*/
|
|
1115
|
-
|
|
1116
|
-
/**
|
|
1117
|
-
* Fired when the value is changed by the user: on every typing keystroke,
|
|
1118
|
-
* and the value is cleared using the clear button.
|
|
1119
|
-
*
|
|
1120
|
-
* @event input
|
|
1121
|
-
*/
|
|
1122
|
-
};
|
|
1123
|
-
|
|
1124
|
-
/**
|
|
1125
|
-
* @license
|
|
1126
|
-
* Copyright (c) 2021 - 2023 Vaadin Ltd..
|
|
1127
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
1128
|
-
*/
|
|
1129
|
-
|
|
1130
|
-
const clearButton = i`
|
|
1131
|
-
[part='clear-button'] {
|
|
1132
|
-
display: none;
|
|
1133
|
-
cursor: default;
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
[part='clear-button']::before {
|
|
1137
|
-
content: '\\2715';
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
|
-
:host([clear-button-visible][has-value]:not([disabled]):not([readonly])) [part='clear-button'] {
|
|
1141
|
-
display: block;
|
|
1142
|
-
}
|
|
1143
|
-
`;
|
|
1144
|
-
|
|
1145
|
-
/**
|
|
1146
|
-
* @license
|
|
1147
|
-
* Copyright (c) 2021 - 2023 Vaadin Ltd..
|
|
1148
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
1149
|
-
*/
|
|
1150
|
-
|
|
1151
|
-
const fieldShared = i`
|
|
1152
|
-
:host {
|
|
1153
|
-
display: inline-flex;
|
|
1154
|
-
outline: none;
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
|
-
:host::before {
|
|
1158
|
-
content: '\\2003';
|
|
1159
|
-
width: 0;
|
|
1160
|
-
display: inline-block;
|
|
1161
|
-
/* Size and position this element on the same vertical position as the input-field element
|
|
1162
|
-
to make vertical align for the host element work as expected */
|
|
1163
|
-
}
|
|
1164
|
-
|
|
1165
|
-
:host([hidden]) {
|
|
1166
|
-
display: none !important;
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
:host(:not([has-label])) [part='label'] {
|
|
1170
|
-
display: none;
|
|
1171
|
-
}
|
|
1172
|
-
|
|
1173
|
-
@media (forced-colors: active) {
|
|
1174
|
-
:host(:not([readonly])) [part='input-field'] {
|
|
1175
|
-
outline: 1px solid;
|
|
1176
|
-
outline-offset: -1px;
|
|
1177
|
-
}
|
|
1178
|
-
:host([focused]) [part='input-field'] {
|
|
1179
|
-
outline-width: 2px;
|
|
1180
|
-
}
|
|
1181
|
-
:host([disabled]) [part='input-field'] {
|
|
1182
|
-
outline-color: GrayText;
|
|
1183
|
-
}
|
|
1184
|
-
}
|
|
1185
|
-
`;
|
|
1186
|
-
|
|
1187
|
-
/**
|
|
1188
|
-
* @license
|
|
1189
|
-
* Copyright (c) 2021 - 2023 Vaadin Ltd..
|
|
1190
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
1191
|
-
*/
|
|
1192
|
-
|
|
1193
|
-
const inputFieldContainer = i`
|
|
1194
|
-
[class$='container'] {
|
|
1195
|
-
display: flex;
|
|
1196
|
-
flex-direction: column;
|
|
1197
|
-
min-width: 100%;
|
|
1198
|
-
max-width: 100%;
|
|
1199
|
-
width: var(--vaadin-field-default-width, 12em);
|
|
1200
|
-
}
|
|
1201
|
-
`;
|
|
1202
|
-
|
|
1203
|
-
/**
|
|
1204
|
-
* @license
|
|
1205
|
-
* Copyright (c) 2021 - 2023 Vaadin Ltd..
|
|
1206
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
1207
|
-
*/
|
|
1208
|
-
|
|
1209
|
-
const inputFieldShared = [fieldShared, inputFieldContainer, clearButton];
|
|
1210
|
-
|
|
1211
|
-
export { InputConstraintsMixin as I, isFirefox as a, isIOS as b, InputControlMixin as c, inputFieldShared as d, isSafari as e, isTouch as f, inputFieldShared$1 as i };
|