@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,1059 +0,0 @@
|
|
|
1
|
-
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
-
import { t as translate, a as tooltipIconSvg } from './tooltipIcon.js';
|
|
3
|
-
import { i as inputFieldShared, c as InputControlMixin, d as inputFieldShared$1 } from './input-field-shared-styles.js';
|
|
4
|
-
import { r as registerStyles, c as InputController, e as LabelledInputController, h as html, T as TooltipController, f as defineCustomElement$1, g as ThemableMixin, E as ElementMixin, P as PolymerElement, i, G as SlotController } from './field-mixin.js';
|
|
5
|
-
import { b as button, B as Button } from './vaadin-button.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @license
|
|
9
|
-
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
10
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
registerStyles('vaadin-text-field', inputFieldShared, {
|
|
14
|
-
moduleId: 'lumo-text-field-styles',
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @license
|
|
19
|
-
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
20
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* A mixin to provide logic for vaadin-text-field and related components.
|
|
25
|
-
*
|
|
26
|
-
* @polymerMixin
|
|
27
|
-
* @mixes InputControlMixin
|
|
28
|
-
*/
|
|
29
|
-
const InputFieldMixin = (superclass) =>
|
|
30
|
-
class InputFieldMixinClass extends InputControlMixin(superclass) {
|
|
31
|
-
static get properties() {
|
|
32
|
-
return {
|
|
33
|
-
/**
|
|
34
|
-
* Whether the value of the control can be automatically completed by the browser.
|
|
35
|
-
* List of available options at:
|
|
36
|
-
* https://developer.mozilla.org/en/docs/Web/HTML/Element/input#attr-autocomplete
|
|
37
|
-
*/
|
|
38
|
-
autocomplete: {
|
|
39
|
-
type: String,
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* This is a property supported by Safari that is used to control whether
|
|
44
|
-
* autocorrection should be enabled when the user is entering/editing the text.
|
|
45
|
-
* Possible values are:
|
|
46
|
-
* on: Enable autocorrection.
|
|
47
|
-
* off: Disable autocorrection.
|
|
48
|
-
*/
|
|
49
|
-
autocorrect: {
|
|
50
|
-
type: String,
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* This is a property supported by Safari and Chrome that is used to control whether
|
|
55
|
-
* autocapitalization should be enabled when the user is entering/editing the text.
|
|
56
|
-
* Possible values are:
|
|
57
|
-
* characters: Characters capitalization.
|
|
58
|
-
* words: Words capitalization.
|
|
59
|
-
* sentences: Sentences capitalization.
|
|
60
|
-
* none: No capitalization.
|
|
61
|
-
*/
|
|
62
|
-
autocapitalize: {
|
|
63
|
-
type: String,
|
|
64
|
-
reflectToAttribute: true,
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
static get delegateAttrs() {
|
|
70
|
-
return [...super.delegateAttrs, 'autocapitalize', 'autocomplete', 'autocorrect'];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Workaround for https://github.com/Polymer/polymer/issues/5259
|
|
74
|
-
get __data() {
|
|
75
|
-
return this.__dataValue || {};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
set __data(value) {
|
|
79
|
-
this.__dataValue = value;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @param {HTMLElement} input
|
|
84
|
-
* @protected
|
|
85
|
-
* @override
|
|
86
|
-
*/
|
|
87
|
-
_inputElementChanged(input) {
|
|
88
|
-
super._inputElementChanged(input);
|
|
89
|
-
|
|
90
|
-
if (input) {
|
|
91
|
-
// Discard value set on the custom slotted input.
|
|
92
|
-
if (input.value && input.value !== this.value) {
|
|
93
|
-
console.warn(`Please define value on the <${this.localName}> component!`);
|
|
94
|
-
input.value = '';
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (this.value) {
|
|
98
|
-
input.value = this.value;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Override an event listener from `FocusMixin`.
|
|
105
|
-
* @param {boolean} focused
|
|
106
|
-
* @protected
|
|
107
|
-
* @override
|
|
108
|
-
*/
|
|
109
|
-
_setFocused(focused) {
|
|
110
|
-
super._setFocused(focused);
|
|
111
|
-
|
|
112
|
-
// Do not validate when focusout is caused by document
|
|
113
|
-
// losing focus, which happens on browser tab switch.
|
|
114
|
-
if (!focused && document.hasFocus()) {
|
|
115
|
-
this.validate();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Override an event listener from `InputMixin`
|
|
121
|
-
* to mark as valid after user started typing.
|
|
122
|
-
* @param {Event} event
|
|
123
|
-
* @protected
|
|
124
|
-
* @override
|
|
125
|
-
*/
|
|
126
|
-
_onInput(event) {
|
|
127
|
-
super._onInput(event);
|
|
128
|
-
|
|
129
|
-
if (this.invalid) {
|
|
130
|
-
this.validate();
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Override an observer from `InputMixin` to validate the field
|
|
136
|
-
* when a new value is set programmatically.
|
|
137
|
-
*
|
|
138
|
-
* @param {string | undefined} newValue
|
|
139
|
-
* @param {string | undefined} oldValue
|
|
140
|
-
* @protected
|
|
141
|
-
* @override
|
|
142
|
-
*/
|
|
143
|
-
_valueChanged(newValue, oldValue) {
|
|
144
|
-
super._valueChanged(newValue, oldValue);
|
|
145
|
-
|
|
146
|
-
if (oldValue === undefined) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (this.invalid) {
|
|
151
|
-
this.validate();
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* @license
|
|
158
|
-
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
159
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
160
|
-
*/
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* A mixin providing common text field functionality.
|
|
164
|
-
*
|
|
165
|
-
* @polymerMixin
|
|
166
|
-
* @mixes InputFieldMixin
|
|
167
|
-
*/
|
|
168
|
-
const TextFieldMixin = (superClass) =>
|
|
169
|
-
class TextFieldMixinClass extends InputFieldMixin(superClass) {
|
|
170
|
-
static get properties() {
|
|
171
|
-
return {
|
|
172
|
-
/**
|
|
173
|
-
* Maximum number of characters (in Unicode code points) that the user can enter.
|
|
174
|
-
*/
|
|
175
|
-
maxlength: {
|
|
176
|
-
type: Number,
|
|
177
|
-
},
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Minimum number of characters (in Unicode code points) that the user can enter.
|
|
181
|
-
*/
|
|
182
|
-
minlength: {
|
|
183
|
-
type: Number,
|
|
184
|
-
},
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* A regular expression that the value is checked against.
|
|
188
|
-
* The pattern must match the entire value, not just some subset.
|
|
189
|
-
*/
|
|
190
|
-
pattern: {
|
|
191
|
-
type: String,
|
|
192
|
-
},
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
static get delegateAttrs() {
|
|
197
|
-
return [...super.delegateAttrs, 'maxlength', 'minlength', 'pattern'];
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
static get constraints() {
|
|
201
|
-
return [...super.constraints, 'maxlength', 'minlength', 'pattern'];
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
constructor() {
|
|
205
|
-
super();
|
|
206
|
-
this._setType('text');
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/** @protected */
|
|
210
|
-
get clearElement() {
|
|
211
|
-
return this.$.clearButton;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/** @protected */
|
|
215
|
-
ready() {
|
|
216
|
-
super.ready();
|
|
217
|
-
|
|
218
|
-
this.addController(
|
|
219
|
-
new InputController(this, (input) => {
|
|
220
|
-
this._setInputElement(input);
|
|
221
|
-
this._setFocusElement(input);
|
|
222
|
-
this.stateTarget = input;
|
|
223
|
-
this.ariaTarget = input;
|
|
224
|
-
}),
|
|
225
|
-
);
|
|
226
|
-
this.addController(new LabelledInputController(this.inputElement, this._labelController));
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* @license
|
|
232
|
-
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
233
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
234
|
-
*/
|
|
235
|
-
|
|
236
|
-
registerStyles('vaadin-text-field', inputFieldShared$1, { moduleId: 'vaadin-text-field-styles' });
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* `<vaadin-text-field>` is a web component that allows the user to input and edit text.
|
|
240
|
-
*
|
|
241
|
-
* ```html
|
|
242
|
-
* <vaadin-text-field label="First Name"></vaadin-text-field>
|
|
243
|
-
* ```
|
|
244
|
-
*
|
|
245
|
-
* ### Prefixes and suffixes
|
|
246
|
-
*
|
|
247
|
-
* These are child elements of a `<vaadin-text-field>` that are displayed
|
|
248
|
-
* inline with the input, before or after.
|
|
249
|
-
* In order for an element to be considered as a prefix, it must have the slot
|
|
250
|
-
* attribute set to `prefix` (and similarly for `suffix`).
|
|
251
|
-
*
|
|
252
|
-
* ```html
|
|
253
|
-
* <vaadin-text-field label="Email address">
|
|
254
|
-
* <div slot="prefix">Sent to:</div>
|
|
255
|
-
* <div slot="suffix">@vaadin.com</div>
|
|
256
|
-
* </vaadin-text-field>
|
|
257
|
-
* ```
|
|
258
|
-
*
|
|
259
|
-
* ### Styling
|
|
260
|
-
*
|
|
261
|
-
* The following custom properties are available for styling:
|
|
262
|
-
*
|
|
263
|
-
* Custom property | Description | Default
|
|
264
|
-
* -------------------------------|----------------------------|---------
|
|
265
|
-
* `--vaadin-field-default-width` | Default width of the field | `12em`
|
|
266
|
-
*
|
|
267
|
-
* The following shadow DOM parts are available for styling:
|
|
268
|
-
*
|
|
269
|
-
* Part name | Description
|
|
270
|
-
* ---------------------|----------------
|
|
271
|
-
* `label` | The label element
|
|
272
|
-
* `input-field` | The element that wraps prefix, value and suffix
|
|
273
|
-
* `clear-button` | The clear button
|
|
274
|
-
* `error-message` | The error message element
|
|
275
|
-
* `helper-text` | The helper text element wrapper
|
|
276
|
-
* `required-indicator` | The `required` state indicator element
|
|
277
|
-
*
|
|
278
|
-
* The following state attributes are available for styling:
|
|
279
|
-
*
|
|
280
|
-
* Attribute | Description | Part name
|
|
281
|
-
* --------------------|-------------|------------
|
|
282
|
-
* `disabled` | Set to a disabled text field | :host
|
|
283
|
-
* `has-value` | Set when the element has a value | :host
|
|
284
|
-
* `has-label` | Set when the element has a label | :host
|
|
285
|
-
* `has-helper` | Set when the element has helper text or slot | :host
|
|
286
|
-
* `has-error-message` | Set when the element has an error message | :host
|
|
287
|
-
* `invalid` | Set when the element is invalid | :host
|
|
288
|
-
* `input-prevented` | Temporarily set when invalid input is prevented | :host
|
|
289
|
-
* `focused` | Set when the element is focused | :host
|
|
290
|
-
* `focus-ring` | Set when the element is keyboard focused | :host
|
|
291
|
-
* `readonly` | Set to a readonly text field | :host
|
|
292
|
-
*
|
|
293
|
-
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
294
|
-
*
|
|
295
|
-
* @fires {Event} input - Fired when the value is changed by the user: on every typing keystroke, and the value is cleared using the clear button.
|
|
296
|
-
* @fires {Event} change - Fired when the user commits a value change.
|
|
297
|
-
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
298
|
-
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
299
|
-
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
300
|
-
*
|
|
301
|
-
* @customElement
|
|
302
|
-
* @extends HTMLElement
|
|
303
|
-
* @mixes ElementMixin
|
|
304
|
-
* @mixes ThemableMixin
|
|
305
|
-
* @mixes TextFieldMixin
|
|
306
|
-
*/
|
|
307
|
-
class TextField extends TextFieldMixin(ThemableMixin(ElementMixin(PolymerElement))) {
|
|
308
|
-
static get is() {
|
|
309
|
-
return 'vaadin-text-field';
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
static get template() {
|
|
313
|
-
return html`
|
|
314
|
-
<style>
|
|
315
|
-
[part='input-field'] {
|
|
316
|
-
flex-grow: 0;
|
|
317
|
-
}
|
|
318
|
-
</style>
|
|
319
|
-
|
|
320
|
-
<div class="vaadin-field-container">
|
|
321
|
-
<div part="label">
|
|
322
|
-
<slot name="label"></slot>
|
|
323
|
-
<span part="required-indicator" aria-hidden="true" on-click="focus"></span>
|
|
324
|
-
</div>
|
|
325
|
-
|
|
326
|
-
<vaadin-input-container
|
|
327
|
-
part="input-field"
|
|
328
|
-
readonly="[[readonly]]"
|
|
329
|
-
disabled="[[disabled]]"
|
|
330
|
-
invalid="[[invalid]]"
|
|
331
|
-
theme$="[[_theme]]"
|
|
332
|
-
>
|
|
333
|
-
<slot name="prefix" slot="prefix"></slot>
|
|
334
|
-
<slot name="input"></slot>
|
|
335
|
-
<slot name="suffix" slot="suffix"></slot>
|
|
336
|
-
<div id="clearButton" part="clear-button" slot="suffix" aria-hidden="true"></div>
|
|
337
|
-
</vaadin-input-container>
|
|
338
|
-
|
|
339
|
-
<div part="helper-text">
|
|
340
|
-
<slot name="helper"></slot>
|
|
341
|
-
</div>
|
|
342
|
-
|
|
343
|
-
<div part="error-message">
|
|
344
|
-
<slot name="error-message"></slot>
|
|
345
|
-
</div>
|
|
346
|
-
</div>
|
|
347
|
-
<slot name="tooltip"></slot>
|
|
348
|
-
`;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
static get properties() {
|
|
352
|
-
return {
|
|
353
|
-
/**
|
|
354
|
-
* Maximum number of characters (in Unicode code points) that the user can enter.
|
|
355
|
-
*/
|
|
356
|
-
maxlength: {
|
|
357
|
-
type: Number,
|
|
358
|
-
},
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* Minimum number of characters (in Unicode code points) that the user can enter.
|
|
362
|
-
*/
|
|
363
|
-
minlength: {
|
|
364
|
-
type: Number,
|
|
365
|
-
},
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
/** @protected */
|
|
370
|
-
ready() {
|
|
371
|
-
super.ready();
|
|
372
|
-
|
|
373
|
-
this._tooltipController = new TooltipController(this);
|
|
374
|
-
this._tooltipController.setPosition('top');
|
|
375
|
-
this._tooltipController.setAriaTarget(this.inputElement);
|
|
376
|
-
this.addController(this._tooltipController);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
defineCustomElement$1(TextField);
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* @license
|
|
384
|
-
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
385
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
386
|
-
*/
|
|
387
|
-
|
|
388
|
-
const passwordFieldButton = i`
|
|
389
|
-
:host {
|
|
390
|
-
position: absolute;
|
|
391
|
-
right: 0;
|
|
392
|
-
top: 0;
|
|
393
|
-
margin: 0;
|
|
394
|
-
padding: 0;
|
|
395
|
-
width: 100%;
|
|
396
|
-
height: 100%;
|
|
397
|
-
min-width: auto;
|
|
398
|
-
background: transparent;
|
|
399
|
-
outline: none;
|
|
400
|
-
}
|
|
401
|
-
`;
|
|
402
|
-
|
|
403
|
-
registerStyles('vaadin-password-field-button', [button, passwordFieldButton], {
|
|
404
|
-
moduleId: 'lumo-password-field-button',
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* @license
|
|
409
|
-
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
410
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
411
|
-
*/
|
|
412
|
-
|
|
413
|
-
const passwordField = i`
|
|
414
|
-
[part='reveal-button']::before {
|
|
415
|
-
content: var(--lumo-icons-eye);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
:host([password-visible]) [part='reveal-button']::before {
|
|
419
|
-
content: var(--lumo-icons-eye-disabled);
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
/* Make it easy to hide the button across the whole app */
|
|
423
|
-
[part='reveal-button'] {
|
|
424
|
-
position: relative;
|
|
425
|
-
display: var(--lumo-password-field-reveal-button-display, block);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
[part='reveal-button'][hidden] {
|
|
429
|
-
display: none !important;
|
|
430
|
-
}
|
|
431
|
-
`;
|
|
432
|
-
|
|
433
|
-
registerStyles('vaadin-password-field', [inputFieldShared, passwordField], { moduleId: 'lumo-password-field' });
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
* @license
|
|
437
|
-
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
438
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
439
|
-
*/
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
* An element used internally by `<vaadin-password-field>`. Not intended to be used separately.
|
|
443
|
-
*
|
|
444
|
-
* @customElement
|
|
445
|
-
* @extends Button
|
|
446
|
-
* @private
|
|
447
|
-
*/
|
|
448
|
-
class PasswordFieldButton extends Button {
|
|
449
|
-
static get is() {
|
|
450
|
-
return 'vaadin-password-field-button';
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
static get template() {
|
|
454
|
-
return html`
|
|
455
|
-
<style>
|
|
456
|
-
:host {
|
|
457
|
-
display: block;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
:host([hidden]) {
|
|
461
|
-
display: none !important;
|
|
462
|
-
}
|
|
463
|
-
</style>
|
|
464
|
-
<slot name="tooltip"></slot>
|
|
465
|
-
`;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
defineCustomElement$1(PasswordFieldButton);
|
|
470
|
-
|
|
471
|
-
/**
|
|
472
|
-
* @license
|
|
473
|
-
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
474
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
475
|
-
*/
|
|
476
|
-
|
|
477
|
-
const ownTemplate = html`
|
|
478
|
-
<div part="reveal-button" slot="suffix">
|
|
479
|
-
<slot name="reveal"></slot>
|
|
480
|
-
</div>
|
|
481
|
-
`;
|
|
482
|
-
|
|
483
|
-
let memoizedTemplate;
|
|
484
|
-
|
|
485
|
-
/**
|
|
486
|
-
* `<vaadin-password-field>` is an extension of `<vaadin-text-field>` component for entering passwords.
|
|
487
|
-
*
|
|
488
|
-
* ```html
|
|
489
|
-
* <vaadin-password-field label="Password"></vaadin-password-field>
|
|
490
|
-
* ```
|
|
491
|
-
*
|
|
492
|
-
* ### Styling
|
|
493
|
-
*
|
|
494
|
-
* `<vaadin-password-field>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.
|
|
495
|
-
* See [`<vaadin-text-field>`](#/elements/vaadin-text-field) for the styling documentation.
|
|
496
|
-
*
|
|
497
|
-
* In addition to `<vaadin-text-field>` parts, the following parts are available for theming:
|
|
498
|
-
*
|
|
499
|
-
* Part name | Description
|
|
500
|
-
* ----------------|----------------------------------------------------
|
|
501
|
-
* `reveal-button` | The eye icon which toggles the password visibility
|
|
502
|
-
*
|
|
503
|
-
* In addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:
|
|
504
|
-
*
|
|
505
|
-
* Attribute | Description
|
|
506
|
-
* -------------------|---------------------------------
|
|
507
|
-
* `password-visible` | Set when the password is visible
|
|
508
|
-
*
|
|
509
|
-
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
510
|
-
*
|
|
511
|
-
* @fires {Event} input - Fired when the value is changed by the user: on every typing keystroke, and the value is cleared using the clear button.
|
|
512
|
-
* @fires {Event} change - Fired when the user commits a value change.
|
|
513
|
-
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
514
|
-
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
515
|
-
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
516
|
-
*
|
|
517
|
-
* @customElement
|
|
518
|
-
* @extends TextField
|
|
519
|
-
*/
|
|
520
|
-
class PasswordField extends TextField {
|
|
521
|
-
static get is() {
|
|
522
|
-
return 'vaadin-password-field';
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
static get template() {
|
|
526
|
-
if (!memoizedTemplate) {
|
|
527
|
-
// Clone the superclass template
|
|
528
|
-
memoizedTemplate = super.template.cloneNode(true);
|
|
529
|
-
|
|
530
|
-
// Retrieve this element's dom-module template
|
|
531
|
-
const revealButton = ownTemplate.content.querySelector('[part="reveal-button"]');
|
|
532
|
-
|
|
533
|
-
// Append reveal-button and styles to the text-field template
|
|
534
|
-
const inputField = memoizedTemplate.content.querySelector('[part="input-field"]');
|
|
535
|
-
inputField.appendChild(revealButton);
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
return memoizedTemplate;
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
static get properties() {
|
|
542
|
-
return {
|
|
543
|
-
/**
|
|
544
|
-
* Set to true to hide the eye icon which toggles the password visibility.
|
|
545
|
-
* @attr {boolean} reveal-button-hidden
|
|
546
|
-
*/
|
|
547
|
-
revealButtonHidden: {
|
|
548
|
-
type: Boolean,
|
|
549
|
-
observer: '_revealButtonHiddenChanged',
|
|
550
|
-
value: false,
|
|
551
|
-
},
|
|
552
|
-
|
|
553
|
-
/**
|
|
554
|
-
* True if the password is visible ([type=text]).
|
|
555
|
-
* @attr {boolean} password-visible
|
|
556
|
-
*/
|
|
557
|
-
passwordVisible: {
|
|
558
|
-
type: Boolean,
|
|
559
|
-
value: false,
|
|
560
|
-
reflectToAttribute: true,
|
|
561
|
-
observer: '_passwordVisibleChanged',
|
|
562
|
-
readOnly: true,
|
|
563
|
-
},
|
|
564
|
-
|
|
565
|
-
/**
|
|
566
|
-
* An object with translated strings used for localization.
|
|
567
|
-
* It has the following structure and default values:
|
|
568
|
-
*
|
|
569
|
-
* ```
|
|
570
|
-
* {
|
|
571
|
-
* // Translation of the reveal icon button accessible label
|
|
572
|
-
* reveal: 'Show password'
|
|
573
|
-
* }
|
|
574
|
-
* ```
|
|
575
|
-
*/
|
|
576
|
-
i18n: {
|
|
577
|
-
type: Object,
|
|
578
|
-
value: () => {
|
|
579
|
-
return {
|
|
580
|
-
reveal: 'Show password',
|
|
581
|
-
};
|
|
582
|
-
},
|
|
583
|
-
},
|
|
584
|
-
};
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
static get observers() {
|
|
588
|
-
return ['__i18nChanged(i18n.*)'];
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
constructor() {
|
|
592
|
-
super();
|
|
593
|
-
this._setType('password');
|
|
594
|
-
this.__boundRevealButtonClick = this._onRevealButtonClick.bind(this);
|
|
595
|
-
this.__boundRevealButtonMouseDown = this._onRevealButtonMouseDown.bind(this);
|
|
596
|
-
this.__lastChange = '';
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
/** @protected */
|
|
600
|
-
get slotStyles() {
|
|
601
|
-
const tag = this.localName;
|
|
602
|
-
return [
|
|
603
|
-
...super.slotStyles,
|
|
604
|
-
`
|
|
605
|
-
${tag} [slot="input"]::-ms-reveal {
|
|
606
|
-
display: none;
|
|
607
|
-
}
|
|
608
|
-
`,
|
|
609
|
-
];
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
/** @protected */
|
|
613
|
-
get _revealNode() {
|
|
614
|
-
return this._revealButtonController && this._revealButtonController.node;
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
/** @protected */
|
|
618
|
-
ready() {
|
|
619
|
-
super.ready();
|
|
620
|
-
|
|
621
|
-
this._revealPart = this.shadowRoot.querySelector('[part="reveal-button"]');
|
|
622
|
-
|
|
623
|
-
this._revealButtonController = new SlotController(this, 'reveal', 'vaadin-password-field-button', {
|
|
624
|
-
initializer: (btn) => {
|
|
625
|
-
btn.disabled = this.disabled;
|
|
626
|
-
|
|
627
|
-
btn.addEventListener('click', this.__boundRevealButtonClick);
|
|
628
|
-
btn.addEventListener('mousedown', this.__boundRevealButtonMouseDown);
|
|
629
|
-
},
|
|
630
|
-
});
|
|
631
|
-
this.addController(this._revealButtonController);
|
|
632
|
-
|
|
633
|
-
this.__updateAriaLabel(this.i18n);
|
|
634
|
-
|
|
635
|
-
this._updateToggleState(false);
|
|
636
|
-
this._toggleRevealHidden(this.revealButtonHidden);
|
|
637
|
-
|
|
638
|
-
if (this.inputElement) {
|
|
639
|
-
this.inputElement.autocapitalize = 'off';
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
/**
|
|
644
|
-
* Override an event listener inherited from `InputControlMixin`
|
|
645
|
-
* to store the value at the moment of the native `change` event.
|
|
646
|
-
* @param {Event} event
|
|
647
|
-
* @protected
|
|
648
|
-
* @override
|
|
649
|
-
*/
|
|
650
|
-
_onChange(event) {
|
|
651
|
-
super._onChange(event);
|
|
652
|
-
|
|
653
|
-
this.__lastChange = this.inputElement.value;
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
/**
|
|
657
|
-
* Override method inherited from `FocusMixin` to mark field as focused
|
|
658
|
-
* when focus moves to the reveal button using Shift Tab.
|
|
659
|
-
* @param {Event} event
|
|
660
|
-
* @return {boolean}
|
|
661
|
-
* @protected
|
|
662
|
-
*/
|
|
663
|
-
_shouldSetFocus(event) {
|
|
664
|
-
return event.target === this.inputElement || event.target === this._revealNode;
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
/**
|
|
668
|
-
* Override method inherited from `FocusMixin` to not hide password
|
|
669
|
-
* when focus moves to the reveal button or back to the input.
|
|
670
|
-
* @param {Event} event
|
|
671
|
-
* @return {boolean}
|
|
672
|
-
* @protected
|
|
673
|
-
*/
|
|
674
|
-
_shouldRemoveFocus(event) {
|
|
675
|
-
return !(
|
|
676
|
-
event.relatedTarget === this._revealNode ||
|
|
677
|
-
(event.relatedTarget === this.inputElement && event.target === this._revealNode)
|
|
678
|
-
);
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
/**
|
|
682
|
-
* Override method inherited from `FocusMixin` to toggle password visibility.
|
|
683
|
-
* @param {boolean} focused
|
|
684
|
-
* @protected
|
|
685
|
-
* @override
|
|
686
|
-
*/
|
|
687
|
-
_setFocused(focused) {
|
|
688
|
-
super._setFocused(focused);
|
|
689
|
-
|
|
690
|
-
if (!focused) {
|
|
691
|
-
this._setPasswordVisible(false);
|
|
692
|
-
|
|
693
|
-
// Detect if `focusout` was prevented and if so, dispatch `change` event manually.
|
|
694
|
-
if (this.__lastChange !== this.inputElement.value) {
|
|
695
|
-
this.__lastChange = this.inputElement.value;
|
|
696
|
-
this.dispatchEvent(new CustomEvent('change', { bubbles: true }));
|
|
697
|
-
}
|
|
698
|
-
} else {
|
|
699
|
-
const isButtonFocused = this.getRootNode().activeElement === this._revealNode;
|
|
700
|
-
// Remove focus-ring from the field when the reveal button gets focused
|
|
701
|
-
this.toggleAttribute('focus-ring', this._keyboardActive && !isButtonFocused);
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
/** @private */
|
|
706
|
-
__updateAriaLabel(i18n) {
|
|
707
|
-
if (i18n.reveal && this._revealNode) {
|
|
708
|
-
this._revealNode.setAttribute('aria-label', i18n.reveal);
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
/** @private */
|
|
713
|
-
__i18nChanged(i18n) {
|
|
714
|
-
this.__updateAriaLabel(i18n.base);
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
/** @private */
|
|
718
|
-
_revealButtonHiddenChanged(hidden) {
|
|
719
|
-
this._toggleRevealHidden(hidden);
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
/** @private */
|
|
723
|
-
_togglePasswordVisibility() {
|
|
724
|
-
this._setPasswordVisible(!this.passwordVisible);
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
/** @private */
|
|
728
|
-
_onRevealButtonClick() {
|
|
729
|
-
this._togglePasswordVisibility();
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
/** @private */
|
|
733
|
-
_onRevealButtonMouseDown(e) {
|
|
734
|
-
// Cancel the following focusout event
|
|
735
|
-
e.preventDefault();
|
|
736
|
-
|
|
737
|
-
// Focus the input to avoid problem with password still visible
|
|
738
|
-
// when user clicks the reveal button and then clicks outside.
|
|
739
|
-
this.inputElement.focus();
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
/** @private */
|
|
743
|
-
_toggleRevealHidden(hidden) {
|
|
744
|
-
if (this._revealNode) {
|
|
745
|
-
if (hidden) {
|
|
746
|
-
this._revealPart.setAttribute('hidden', '');
|
|
747
|
-
this._revealNode.setAttribute('tabindex', '-1');
|
|
748
|
-
this._revealNode.setAttribute('aria-hidden', 'true');
|
|
749
|
-
} else {
|
|
750
|
-
this._revealPart.removeAttribute('hidden');
|
|
751
|
-
this._revealNode.setAttribute('tabindex', '0');
|
|
752
|
-
this._revealNode.removeAttribute('aria-hidden');
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
/** @private */
|
|
758
|
-
_updateToggleState(passwordVisible) {
|
|
759
|
-
if (this._revealNode) {
|
|
760
|
-
this._revealNode.setAttribute('aria-pressed', passwordVisible ? 'true' : 'false');
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
/** @private */
|
|
765
|
-
_passwordVisibleChanged(passwordVisible) {
|
|
766
|
-
this._setType(passwordVisible ? 'text' : 'password');
|
|
767
|
-
|
|
768
|
-
this._updateToggleState(passwordVisible);
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
/**
|
|
772
|
-
* Override method inherited from `DisabledMixin` to synchronize the reveal button
|
|
773
|
-
* disabled state with the password field disabled state.
|
|
774
|
-
* @param {boolean} disabled
|
|
775
|
-
* @param {boolean} oldDisabled
|
|
776
|
-
* @protected
|
|
777
|
-
*/
|
|
778
|
-
_disabledChanged(disabled, oldDisabled) {
|
|
779
|
-
super._disabledChanged(disabled, oldDisabled);
|
|
780
|
-
|
|
781
|
-
if (this._revealNode) {
|
|
782
|
-
this._revealNode.disabled = disabled;
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
defineCustomElement$1(PasswordField);
|
|
788
|
-
|
|
789
|
-
const passwordInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.password{font-family:\"Roboto\";font-style:normal}.password__wrapper{position:relative;width:100%;display:flex;flex-direction:column;gap:5px}.password__wrapper--autofilled{pointer-events:none}.password__wrapper--autofilled .password__label{color:var(--emfe-w-registration-typography, var(--emfe-w-color-black, #000000))}.password__wrapper--autofilled .password__input::part(input-field){color:var(--emfe-w-color-black, #000000)}.password__wrapper--flex{display:flex;gap:5px}.password__wrapper--relative{position:relative}.password__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:var(--emfe-w-registration-typography, var(--emfe-w-color-black, #000000))}.password__label--required::after{content:\"*\";font-family:inherit;color:var(--emfe-w-login-color-primary, var(--emfe-w-color-primary, #D0046C));margin-left:2px}.password__input{width:inherit;border:none}.password__input[focused]::part(input-field){border-color:var(--emfe-w-login-color-primary, var(--emfe-w-color-primary, #D0046C))}.password__input[invalid]::part(input-field){border:1px solid var(--emfe-w-color-error, var(--emfe-w-color-red, #ed0909))}.password__input::part(input-field){border-radius:4px;background-color:var(--emfe-w-color-white, #FFFFFF);border:1px solid var(--emfe-w-color-gray-100, #E6E6E6);color:var(--emfe-w-color-black, #000000);background-color:var(--emfe-w-color-white, #FFFFFF);font-family:inherit;font-style:normal;font-weight:300;font-size:16px;line-height:1.5;position:relative;margin-bottom:unset;height:44px;padding:0;width:100%}.password__input::part(reveal-button){position:relative;right:10px}.password__input::part(reveal-button)::before{color:var(--emfe-w-registration-typography, var(--emfe-w-color-black, #000000))}.password__input>input{padding:5px 15px}.password__input>input:placeholder-shown{color:var(--emfe-w-color-gray-150, #828282)}.password__error-message{position:absolute;top:calc(100% + 5px);left:0;color:var(--emfe-w-color-error, var(--emfe-w-color-red, #ed0909))}.password__complexity{position:relative;padding:10px;display:flex;flex-direction:column;gap:20px;justify-content:center;margin-top:20px;font-weight:300;background:var(--emfe-w-color-white, #FFFFFF);-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;height:150px;border:1px solid #B0B0B0;}.password__complexity meter{border-color:transparent;}.password__complexity meter[value=\"1\"]::-moz-meter-bar{background-color:var(--emfe-w-color-valid, #48952a)}.password__complexity meter[value=\"1\"]::-webkit-meter-optimum-value{background-color:var(--emfe-w-color-valid, #48952a)}.password__complexity meter:not([value=\"1\"])::-moz-meter-bar{background-color:var(--emfe-w-color-error, #FD2839)}.password__complexity meter:not([value=\"1\"])::-webkit-meter-optimum-value{background-color:var(--emfe-w-color-error, #FD2839)}.password__complexity--strength{display:flex;justify-content:space-evenly;align-items:center}.password__complexity--strength meter::-moz-meter-bar{background:#B0B0B0}.password__complexity--hidden{display:none}.password__complexity--text-bold{font-weight:500}.password__complexity--checkbox{margin-right:5px}.password__complexity:after{content:\"\";position:absolute;width:25px;height:25px;border-top:1px solid var(--emfe-w-color-gray-150, #828282);border-right:0 solid var(--emfe-w-color-gray-150, #828282);border-left:1px solid var(--emfe-w-color-gray-150, #828282);border-bottom:0 solid var(--emfe-w-color-gray-150, #828282);bottom:92%;left:50%;margin-left:-25px;transform:rotate(45deg);margin-top:-25px;background-color:var(--emfe-w-color-white, #FFFFFF)}.password__tooltip-icon{width:16px;height:auto}.password__tooltip{position:absolute;top:0;left:20px;background-color:var(--emfe-w-color-white, #FFFFFF);border:1px solid var(--emfe-w-color-gray-150, #828282);color:#2B2D3F;padding:10px;border-radius:5px;opacity:0;transition:opacity 0.3s ease-in-out;z-index:10}.password__tooltip.visible{opacity:1}";
|
|
790
|
-
|
|
791
|
-
const PasswordInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
792
|
-
constructor() {
|
|
793
|
-
super();
|
|
794
|
-
this.__registerHost();
|
|
795
|
-
this.__attachShadow();
|
|
796
|
-
this.sendOriginalValidityState = createEvent(this, "sendOriginalValidityState", 7);
|
|
797
|
-
this.sendValidityState = createEvent(this, "sendValidityState", 7);
|
|
798
|
-
this.sendInputValue = createEvent(this, "sendInputValue", 7);
|
|
799
|
-
/**
|
|
800
|
-
* Default value for the input.
|
|
801
|
-
*/
|
|
802
|
-
this.defaultValue = '';
|
|
803
|
-
/**
|
|
804
|
-
* Client custom styling via inline style
|
|
805
|
-
*/
|
|
806
|
-
this.clientStyling = '';
|
|
807
|
-
/**
|
|
808
|
-
* Client Styling Url
|
|
809
|
-
*/
|
|
810
|
-
this.clientStylingUrl = '';
|
|
811
|
-
this.limitStylingAppends = false;
|
|
812
|
-
this.showTooltip = false;
|
|
813
|
-
this.value = '';
|
|
814
|
-
this.touched = false;
|
|
815
|
-
this.originalValid = false;
|
|
816
|
-
this.validationPattern = '';
|
|
817
|
-
this.duplicateInputValue = null;
|
|
818
|
-
this.handleInput = (event) => {
|
|
819
|
-
this.value = event.target.value;
|
|
820
|
-
this.calculateComplexity(this.value);
|
|
821
|
-
this.validation.custom.length === 0 || (this.showPopup = true);
|
|
822
|
-
this.touched = true;
|
|
823
|
-
if (this.debounceTime) {
|
|
824
|
-
clearTimeout(this.debounceTime);
|
|
825
|
-
}
|
|
826
|
-
this.debounceTime = setTimeout(() => {
|
|
827
|
-
this.isValid = this.setValidity();
|
|
828
|
-
this.errorMessage = this.setErrorMessage();
|
|
829
|
-
this.emitValueHandler(true);
|
|
830
|
-
}, 500);
|
|
831
|
-
};
|
|
832
|
-
this.handleBlur = (event) => {
|
|
833
|
-
this.value = event.target.value;
|
|
834
|
-
this.showPopup = false;
|
|
835
|
-
this.touched = true;
|
|
836
|
-
this.isValid = this.setValidity();
|
|
837
|
-
this.errorMessage = this.setErrorMessage();
|
|
838
|
-
};
|
|
839
|
-
this.handleFocus = () => {
|
|
840
|
-
this.validation.custom.length === 0 || (this.showPopup = true);
|
|
841
|
-
this.calculateComplexity(this.value);
|
|
842
|
-
};
|
|
843
|
-
this.setClientStyling = () => {
|
|
844
|
-
const sheet = document.createElement('style');
|
|
845
|
-
sheet.innerHTML = this.clientStyling;
|
|
846
|
-
this.stylingContainer.prepend(sheet);
|
|
847
|
-
};
|
|
848
|
-
this.setClientStylingURL = () => {
|
|
849
|
-
const url = new URL(this.clientStylingUrl);
|
|
850
|
-
const cssFile = document.createElement('style');
|
|
851
|
-
fetch(url.href)
|
|
852
|
-
.then((res) => res.text())
|
|
853
|
-
.then((data) => {
|
|
854
|
-
cssFile.innerHTML = data;
|
|
855
|
-
setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
|
|
856
|
-
})
|
|
857
|
-
.catch((err) => {
|
|
858
|
-
console.error(err);
|
|
859
|
-
});
|
|
860
|
-
};
|
|
861
|
-
}
|
|
862
|
-
validityChanged() {
|
|
863
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
864
|
-
if (this.emitValue == true) {
|
|
865
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
valueChanged() {
|
|
869
|
-
if (!this.isDuplicateInput) {
|
|
870
|
-
// recalculate complexity immediately in order to send the correct validity to the duplicate
|
|
871
|
-
this.calculateComplexity(this.value);
|
|
872
|
-
this.sendOriginalValidityState.emit({ name: this.name, valid: this.setValidity() });
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
emitValueHandler(newValue) {
|
|
876
|
-
if (newValue == true && this.isValid) {
|
|
877
|
-
this.valueHandler({ name: this.name, value: this.value, type: 'duplicate' });
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
validityStateHandler(inputStateEvent) {
|
|
881
|
-
this.sendValidityState.emit(inputStateEvent);
|
|
882
|
-
}
|
|
883
|
-
valueHandler(inputValueEvent) {
|
|
884
|
-
this.sendInputValue.emit(inputValueEvent);
|
|
885
|
-
}
|
|
886
|
-
originalValidityChangedHandler(event) {
|
|
887
|
-
if (this.isDuplicateInput) {
|
|
888
|
-
if (event.detail.valid) {
|
|
889
|
-
this.originalValid = true;
|
|
890
|
-
this.isValid = this.setValidity();
|
|
891
|
-
}
|
|
892
|
-
else {
|
|
893
|
-
this.originalValid = false;
|
|
894
|
-
this.isValid = false;
|
|
895
|
-
// only show error if the user has touched the input, in order to not show errors on empty inputs
|
|
896
|
-
this.value !== '' && (this.errorMessage = this.setErrorMessage());
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
valueChangedHandler(event) {
|
|
901
|
-
if (this.isDuplicateInput && this.name === event.detail.name + 'Duplicate') {
|
|
902
|
-
this.duplicateInputValue = event.detail.value;
|
|
903
|
-
if (this.touched) {
|
|
904
|
-
this.isValid = this.setValidity();
|
|
905
|
-
this.errorMessage = this.setErrorMessage();
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
if (this.name === event.detail.name + 'Duplicate'
|
|
909
|
-
&& this.name.replace('Duplicate', '') === event.detail.name
|
|
910
|
-
&& this.touched === true) {
|
|
911
|
-
this.isValid = this.setValidity();
|
|
912
|
-
this.errorMessage = this.setErrorMessage();
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
handleClickOutside(event) {
|
|
916
|
-
if (event.composedPath()[0] === this.tooltipIconReference)
|
|
917
|
-
return;
|
|
918
|
-
if (event.composedPath()[0] !== this.tooltipReference)
|
|
919
|
-
this.showTooltip = false;
|
|
920
|
-
}
|
|
921
|
-
componentDidRender() {
|
|
922
|
-
// start custom styling area
|
|
923
|
-
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
924
|
-
if (this.clientStyling)
|
|
925
|
-
this.setClientStyling();
|
|
926
|
-
this.limitStylingAppends = true;
|
|
927
|
-
}
|
|
928
|
-
// end custom styling area
|
|
929
|
-
}
|
|
930
|
-
componentDidLoad() {
|
|
931
|
-
this.inputReference = this.element.shadowRoot.querySelector('input');
|
|
932
|
-
this.passwordButton = this.element.shadowRoot.querySelector('vaadin-password-field-button');
|
|
933
|
-
this.passwordButton.tabIndex = -1;
|
|
934
|
-
if (this.defaultValue) {
|
|
935
|
-
this.value = this.defaultValue;
|
|
936
|
-
this.calculateComplexity(this.value);
|
|
937
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
938
|
-
if (this.isDuplicateInput) {
|
|
939
|
-
this.duplicateInputValue = this.defaultValue;
|
|
940
|
-
this.touched = true;
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
this.isValid = this.setValidity();
|
|
944
|
-
}
|
|
945
|
-
calculateComplexity(password) {
|
|
946
|
-
this.passwordComplexity = this.validation.custom
|
|
947
|
-
.filter(customValidation => customValidation.rule.toLowerCase() === 'regex')
|
|
948
|
-
.map(customValidation => {
|
|
949
|
-
const ruleRegex = new RegExp(customValidation.pattern);
|
|
950
|
-
const passed = ruleRegex.test(password);
|
|
951
|
-
return { rule: customValidation.displayName, ruleKey: customValidation.errorKey, passed };
|
|
952
|
-
});
|
|
953
|
-
}
|
|
954
|
-
setValidity() {
|
|
955
|
-
var _a, _b;
|
|
956
|
-
if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
|
|
957
|
-
return false;
|
|
958
|
-
}
|
|
959
|
-
else if (!((_a = this.passwordComplexity) === null || _a === void 0 ? void 0 : _a.every(complexity => complexity.passed))) {
|
|
960
|
-
return false;
|
|
961
|
-
}
|
|
962
|
-
else {
|
|
963
|
-
return (_b = this.inputReference) === null || _b === void 0 ? void 0 : _b.validity.valid;
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
setPattern() {
|
|
967
|
-
var _a, _b;
|
|
968
|
-
if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
969
|
-
return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
setErrorMessage() {
|
|
973
|
-
var _a, _b, _c, _d;
|
|
974
|
-
if (this.isDuplicateInput && !this.originalValid) {
|
|
975
|
-
return translate('invalidOriginalPasswordError', this.language);
|
|
976
|
-
}
|
|
977
|
-
if (this.inputReference.validity.patternMismatch) {
|
|
978
|
-
const errorCode = (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorKey;
|
|
979
|
-
const errorMessage = (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.errorMessage;
|
|
980
|
-
return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
|
|
981
|
-
}
|
|
982
|
-
if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
|
|
983
|
-
return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
|
|
984
|
-
}
|
|
985
|
-
if (this.inputReference.validity.valueMissing) {
|
|
986
|
-
return translate('requiredError', this.language);
|
|
987
|
-
}
|
|
988
|
-
if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
|
|
989
|
-
const errorCode = (_c = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _c === void 0 ? void 0 : _c.errorKey;
|
|
990
|
-
const errorMessage = (_d = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _d === void 0 ? void 0 : _d.errorMessage;
|
|
991
|
-
return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
renderTooltip() {
|
|
995
|
-
if (this.showTooltip) {
|
|
996
|
-
return (h("div", { class: `password__tooltip ${this.showTooltip ? 'visible' : ''}`, ref: (el) => this.tooltipReference = el, innerHTML: this.tooltip }));
|
|
997
|
-
}
|
|
998
|
-
return null;
|
|
999
|
-
}
|
|
1000
|
-
renderComplexityPopup() {
|
|
1001
|
-
const totalRules = this.passwordComplexity.length;
|
|
1002
|
-
const passedRules = this.passwordComplexity.filter(complexity => complexity.passed).length;
|
|
1003
|
-
const meterValue = passedRules / totalRules;
|
|
1004
|
-
const allRulesPassed = this.passwordComplexity.every(complexity => complexity.passed);
|
|
1005
|
-
return (h("div", { class: `password__complexity ${!this.showPopup ? 'password__complexity--hidden' : ''}` }, h("div", { class: 'password__complexity--strength' }, h("p", { class: 'password__complexity--text' }, translate('passwordStrength', this.language), "\u00A0", h("span", { class: 'password__complexity--text-bold' }, translate(`${allRulesPassed ? 'passwordStrengthStrong' : 'passwordStrengthWeak'}`, this.language))), h("meter", { value: meterValue, min: "0", max: "1" })), h("div", null, this.passwordComplexity.map((complexity, index) => {
|
|
1006
|
-
return (h("div", { key: index }, h("input", { class: 'password__complexity--checkbox', type: "checkbox", checked: complexity.passed, disabled: true }), h("span", null, translate(`${complexity.ruleKey}`, this.language) ? translate(`${complexity.ruleKey}`, this.language) : complexity.rule)));
|
|
1007
|
-
}))));
|
|
1008
|
-
}
|
|
1009
|
-
render() {
|
|
1010
|
-
let invalidClass = '';
|
|
1011
|
-
if (this.touched) {
|
|
1012
|
-
invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
|
|
1013
|
-
}
|
|
1014
|
-
return h("div", { class: `password__wrapper ${this.autofilled ? 'password__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, h("div", { class: 'password__wrapper--flex' }, h("label", { class: `password__label ${this.validation.mandatory ? 'password__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("div", { class: 'password__wrapper--relative' }, this.tooltip &&
|
|
1015
|
-
h("img", { class: 'password__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), h("vaadin-password-field", { type: "password", id: `${this.name}__input`, class: `password__input ${invalidClass}`, name: this.name, readOnly: this.autofilled, value: this.defaultValue, required: this.validation.mandatory, maxlength: this.validation.maxLength, minlength: this.validation.minLength, pattern: this.validationPattern, placeholder: `${this.placeholder}`, onInput: this.handleInput, onBlur: this.handleBlur, onFocus: this.handleFocus }), h("small", { class: 'password__error-message' }, this.errorMessage), this.passwordComplexity && this.showPopup && !this.isDuplicateInput && this.renderComplexityPopup());
|
|
1016
|
-
}
|
|
1017
|
-
get element() { return this; }
|
|
1018
|
-
static get watchers() { return {
|
|
1019
|
-
"isValid": ["validityChanged"],
|
|
1020
|
-
"value": ["valueChanged"],
|
|
1021
|
-
"emitValue": ["emitValueHandler"]
|
|
1022
|
-
}; }
|
|
1023
|
-
static get style() { return passwordInputCss; }
|
|
1024
|
-
}, [1, "password-input", {
|
|
1025
|
-
"name": [513],
|
|
1026
|
-
"displayName": [513, "display-name"],
|
|
1027
|
-
"placeholder": [513],
|
|
1028
|
-
"defaultValue": [513, "default-value"],
|
|
1029
|
-
"autofilled": [516],
|
|
1030
|
-
"tooltip": [513],
|
|
1031
|
-
"validation": [16],
|
|
1032
|
-
"language": [513],
|
|
1033
|
-
"emitValue": [516, "emit-value"],
|
|
1034
|
-
"isDuplicateInput": [516, "is-duplicate-input"],
|
|
1035
|
-
"clientStyling": [513, "client-styling"],
|
|
1036
|
-
"clientStylingUrl": [513, "client-styling-url"],
|
|
1037
|
-
"isValid": [32],
|
|
1038
|
-
"errorMessage": [32],
|
|
1039
|
-
"limitStylingAppends": [32],
|
|
1040
|
-
"showTooltip": [32],
|
|
1041
|
-
"passwordComplexity": [32],
|
|
1042
|
-
"showPopup": [32],
|
|
1043
|
-
"value": [32]
|
|
1044
|
-
}, [[16, "sendOriginalValidityState", "originalValidityChangedHandler"], [16, "sendInputValue", "valueChangedHandler"], [4, "click", "handleClickOutside"]]]);
|
|
1045
|
-
function defineCustomElement() {
|
|
1046
|
-
if (typeof customElements === "undefined") {
|
|
1047
|
-
return;
|
|
1048
|
-
}
|
|
1049
|
-
const components = ["password-input"];
|
|
1050
|
-
components.forEach(tagName => { switch (tagName) {
|
|
1051
|
-
case "password-input":
|
|
1052
|
-
if (!customElements.get(tagName)) {
|
|
1053
|
-
customElements.define(tagName, PasswordInput);
|
|
1054
|
-
}
|
|
1055
|
-
break;
|
|
1056
|
-
} });
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
export { PasswordInput as P, defineCustomElement as d };
|