@everymatrix/general-input 0.0.1

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.
Files changed (121) hide show
  1. package/dist/cjs/checkbox-group-input_10.cjs.entry.js +34870 -0
  2. package/dist/cjs/general-input.cjs.entry.js +51 -0
  3. package/dist/cjs/general-input.cjs.js +19 -0
  4. package/dist/cjs/index-1768513d.js +1286 -0
  5. package/dist/cjs/index.cjs.js +2 -0
  6. package/dist/cjs/loader.cjs.js +21 -0
  7. package/dist/collection/collection-manifest.json +22 -0
  8. package/dist/collection/components/checkbox-group-input/checkbox-group-input.css +62 -0
  9. package/dist/collection/components/checkbox-group-input/checkbox-group-input.js +344 -0
  10. package/dist/collection/components/checkbox-input/checkbox-input.css +62 -0
  11. package/dist/collection/components/checkbox-input/checkbox-input.js +322 -0
  12. package/dist/collection/components/date-input/date-input.css +85 -0
  13. package/dist/collection/components/date-input/date-input.js +341 -0
  14. package/dist/collection/components/email-input/email-input.css +83 -0
  15. package/dist/collection/components/email-input/email-input.js +382 -0
  16. package/dist/collection/components/general-input/general-input.css +3 -0
  17. package/dist/collection/components/general-input/general-input.js +296 -0
  18. package/dist/collection/components/number-input/number-input.css +90 -0
  19. package/dist/collection/components/number-input/number-input.js +349 -0
  20. package/dist/collection/components/password-input/password-input.css +86 -0
  21. package/dist/collection/components/password-input/password-input.js +395 -0
  22. package/dist/collection/components/radio-input/radio-input.css +43 -0
  23. package/dist/collection/components/radio-input/radio-input.js +298 -0
  24. package/dist/collection/components/select-input/select-input.css +93 -0
  25. package/dist/collection/components/select-input/select-input.js +412 -0
  26. package/dist/collection/components/tel-input/tel-input.css +116 -0
  27. package/dist/collection/components/tel-input/tel-input.js +421 -0
  28. package/dist/collection/components/text-input/text-input.css +83 -0
  29. package/dist/collection/components/text-input/text-input.js +406 -0
  30. package/dist/collection/index.js +1 -0
  31. package/dist/collection/utils/locale.utils.js +26 -0
  32. package/dist/collection/utils/tooltipIcon.svg +5 -0
  33. package/dist/collection/utils/types.js +1 -0
  34. package/dist/collection/utils/utils.js +5 -0
  35. package/dist/components/active-mixin.js +975 -0
  36. package/dist/components/checkbox-group-input.d.ts +11 -0
  37. package/dist/components/checkbox-group-input.js +6 -0
  38. package/dist/components/checkbox-group-input2.js +5793 -0
  39. package/dist/components/checkbox-input.d.ts +11 -0
  40. package/dist/components/checkbox-input.js +6 -0
  41. package/dist/components/checkbox-input2.js +127 -0
  42. package/dist/components/date-input.d.ts +11 -0
  43. package/dist/components/date-input.js +6 -0
  44. package/dist/components/date-input2.js +5182 -0
  45. package/dist/components/email-input.d.ts +11 -0
  46. package/dist/components/email-input.js +6 -0
  47. package/dist/components/email-input2.js +150 -0
  48. package/dist/components/field-mixin.js +12712 -0
  49. package/dist/components/general-input.d.ts +11 -0
  50. package/dist/components/general-input.js +140 -0
  51. package/dist/components/index.d.ts +26 -0
  52. package/dist/components/index.js +1 -0
  53. package/dist/components/input-field-shared-styles.js +1067 -0
  54. package/dist/components/number-input.d.ts +11 -0
  55. package/dist/components/number-input.js +6 -0
  56. package/dist/components/number-input2.js +139 -0
  57. package/dist/components/password-input.d.ts +11 -0
  58. package/dist/components/password-input.js +6 -0
  59. package/dist/components/password-input2.js +879 -0
  60. package/dist/components/pattern-mixin.js +85 -0
  61. package/dist/components/radio-input.d.ts +11 -0
  62. package/dist/components/radio-input.js +6 -0
  63. package/dist/components/radio-input2.js +115 -0
  64. package/dist/components/select-input.d.ts +11 -0
  65. package/dist/components/select-input.js +6 -0
  66. package/dist/components/select-input2.js +166 -0
  67. package/dist/components/tel-input.d.ts +11 -0
  68. package/dist/components/tel-input.js +6 -0
  69. package/dist/components/tel-input2.js +178 -0
  70. package/dist/components/text-input.d.ts +11 -0
  71. package/dist/components/text-input.js +6 -0
  72. package/dist/components/text-input2.js +157 -0
  73. package/dist/components/tooltipIcon.js +30 -0
  74. package/dist/components/vaadin-button.js +461 -0
  75. package/dist/components/vaadin-combo-box.js +4329 -0
  76. package/dist/components/virtual-keyboard-controller.js +2693 -0
  77. package/dist/esm/checkbox-group-input_10.entry.js +34857 -0
  78. package/dist/esm/general-input.entry.js +47 -0
  79. package/dist/esm/general-input.js +17 -0
  80. package/dist/esm/index-7e24a6f1.js +1259 -0
  81. package/dist/esm/index.js +1 -0
  82. package/dist/esm/loader.js +17 -0
  83. package/dist/esm/polyfills/core-js.js +11 -0
  84. package/dist/esm/polyfills/css-shim.js +1 -0
  85. package/dist/esm/polyfills/dom.js +79 -0
  86. package/dist/esm/polyfills/es5-html-element.js +1 -0
  87. package/dist/esm/polyfills/index.js +34 -0
  88. package/dist/esm/polyfills/system.js +6 -0
  89. package/dist/general-input/general-input.esm.js +1 -0
  90. package/dist/general-input/index.esm.js +0 -0
  91. package/dist/general-input/p-61d76ec3.entry.js +1 -0
  92. package/dist/general-input/p-a79eb0a3.entry.js +4413 -0
  93. package/dist/general-input/p-fb647820.js +1 -0
  94. package/dist/index.cjs.js +1 -0
  95. package/dist/index.js +1 -0
  96. package/dist/stencil.config.js +22 -0
  97. package/dist/types/Users/adrian.pripon/Documents/Work/stencil/widgets-stencil/packages/general-input/.stencil/packages/general-input/stencil.config.d.ts +2 -0
  98. package/dist/types/components/checkbox-group-input/checkbox-group-input.d.ts +72 -0
  99. package/dist/types/components/checkbox-input/checkbox-input.d.ts +64 -0
  100. package/dist/types/components/date-input/date-input.d.ts +70 -0
  101. package/dist/types/components/email-input/email-input.d.ts +77 -0
  102. package/dist/types/components/general-input/general-input.d.ts +60 -0
  103. package/dist/types/components/number-input/number-input.d.ts +70 -0
  104. package/dist/types/components/password-input/password-input.d.ts +79 -0
  105. package/dist/types/components/radio-input/radio-input.d.ts +59 -0
  106. package/dist/types/components/select-input/select-input.d.ts +82 -0
  107. package/dist/types/components/tel-input/tel-input.d.ts +85 -0
  108. package/dist/types/components/text-input/text-input.d.ts +81 -0
  109. package/dist/types/components.d.ts +1140 -0
  110. package/dist/types/index.d.ts +1 -0
  111. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  112. package/dist/types/utils/locale.utils.d.ts +5 -0
  113. package/dist/types/utils/types.d.ts +76 -0
  114. package/dist/types/utils/utils.d.ts +1 -0
  115. package/loader/cdn.js +3 -0
  116. package/loader/index.cjs.js +3 -0
  117. package/loader/index.d.ts +12 -0
  118. package/loader/index.es2017.js +3 -0
  119. package/loader/index.js +4 -0
  120. package/loader/package.json +10 -0
  121. package/package.json +26 -0
@@ -0,0 +1,879 @@
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, a as InputControlMixin, b as inputFieldShared$1 } from './input-field-shared-styles.js';
4
+ import { r as registerStyles, h as html, e as InputController, f as LabelledInputController, g as TooltipController, T as ThemableMixin, E as ElementMixin, P as PolymerElement, i, S as SlotController } from './field-mixin.js';
5
+ import { P as PatternMixin } from './pattern-mixin.js';
6
+ import { b as button, B as Button } from './vaadin-button.js';
7
+
8
+ /**
9
+ * @license
10
+ * Copyright (c) 2017 - 2022 Vaadin Ltd.
11
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
12
+ */
13
+
14
+ registerStyles('vaadin-text-field', inputFieldShared, {
15
+ moduleId: 'lumo-text-field-styles',
16
+ });
17
+
18
+ /**
19
+ * @license
20
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
21
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
22
+ */
23
+
24
+ /**
25
+ * A mixin to provide logic for vaadin-text-field and related components.
26
+ *
27
+ * @polymerMixin
28
+ * @mixes InputControlMixin
29
+ */
30
+ const InputFieldMixin = (superclass) =>
31
+ class InputFieldMixinClass extends InputControlMixin(superclass) {
32
+ static get properties() {
33
+ return {
34
+ /**
35
+ * Whether the value of the control can be automatically completed by the browser.
36
+ * List of available options at:
37
+ * https://developer.mozilla.org/en/docs/Web/HTML/Element/input#attr-autocomplete
38
+ */
39
+ autocomplete: {
40
+ type: String,
41
+ },
42
+
43
+ /**
44
+ * This is a property supported by Safari that is used to control whether
45
+ * autocorrection should be enabled when the user is entering/editing the text.
46
+ * Possible values are:
47
+ * on: Enable autocorrection.
48
+ * off: Disable autocorrection.
49
+ */
50
+ autocorrect: {
51
+ type: String,
52
+ },
53
+
54
+ /**
55
+ * This is a property supported by Safari and Chrome that is used to control whether
56
+ * autocapitalization should be enabled when the user is entering/editing the text.
57
+ * Possible values are:
58
+ * characters: Characters capitalization.
59
+ * words: Words capitalization.
60
+ * sentences: Sentences capitalization.
61
+ * none: No capitalization.
62
+ */
63
+ autocapitalize: {
64
+ type: String,
65
+ reflectToAttribute: true,
66
+ },
67
+ };
68
+ }
69
+
70
+ static get delegateAttrs() {
71
+ return [...super.delegateAttrs, 'autocapitalize', 'autocomplete', 'autocorrect'];
72
+ }
73
+
74
+ /**
75
+ * @param {HTMLElement} input
76
+ * @protected
77
+ * @override
78
+ */
79
+ _inputElementChanged(input) {
80
+ super._inputElementChanged(input);
81
+
82
+ if (input) {
83
+ // Discard value set on the custom slotted input.
84
+ if (input.value && input.value !== this.value) {
85
+ console.warn(`Please define value on the <${this.localName}> component!`);
86
+ input.value = '';
87
+ }
88
+
89
+ if (this.value) {
90
+ input.value = this.value;
91
+ }
92
+ }
93
+ }
94
+
95
+ // Workaround for https://github.com/Polymer/polymer/issues/5259
96
+ get __data() {
97
+ return this.__dataValue || {};
98
+ }
99
+
100
+ set __data(value) {
101
+ this.__dataValue = value;
102
+ }
103
+
104
+ /**
105
+ * Override an event listener from `FocusMixin`.
106
+ * @param {boolean} focused
107
+ * @protected
108
+ * @override
109
+ */
110
+ _setFocused(focused) {
111
+ super._setFocused(focused);
112
+
113
+ if (!focused) {
114
+ this.validate();
115
+ }
116
+ }
117
+
118
+ /**
119
+ * Override an event listener from `InputMixin`
120
+ * to mark as valid after user started typing.
121
+ * @param {Event} event
122
+ * @protected
123
+ * @override
124
+ */
125
+ _onInput(event) {
126
+ super._onInput(event);
127
+
128
+ if (this.invalid) {
129
+ this.validate();
130
+ }
131
+ }
132
+
133
+ /**
134
+ * Override an observer from `InputMixin` to validate the field
135
+ * when a new value is set programmatically.
136
+ *
137
+ * @param {string | undefined} newValue
138
+ * @param {string | undefined} oldValue
139
+ * @protected
140
+ * @override
141
+ */
142
+ _valueChanged(newValue, oldValue) {
143
+ super._valueChanged(newValue, oldValue);
144
+
145
+ if (oldValue === undefined) {
146
+ return;
147
+ }
148
+
149
+ if (this.invalid) {
150
+ this.validate();
151
+ }
152
+ }
153
+ };
154
+
155
+ /**
156
+ * @license
157
+ * Copyright (c) 2017 - 2022 Vaadin Ltd.
158
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
159
+ */
160
+
161
+ registerStyles('vaadin-text-field', inputFieldShared$1, { moduleId: 'vaadin-text-field-styles' });
162
+
163
+ /**
164
+ * `<vaadin-text-field>` is a web component that allows the user to input and edit text.
165
+ *
166
+ * ```html
167
+ * <vaadin-text-field label="First Name"></vaadin-text-field>
168
+ * ```
169
+ *
170
+ * ### Prefixes and suffixes
171
+ *
172
+ * These are child elements of a `<vaadin-text-field>` that are displayed
173
+ * inline with the input, before or after.
174
+ * In order for an element to be considered as a prefix, it must have the slot
175
+ * attribute set to `prefix` (and similarly for `suffix`).
176
+ *
177
+ * ```html
178
+ * <vaadin-text-field label="Email address">
179
+ * <div slot="prefix">Sent to:</div>
180
+ * <div slot="suffix">@vaadin.com</div>
181
+ * </vaadin-text-field>
182
+ * ```
183
+ *
184
+ * ### Styling
185
+ *
186
+ * The following custom properties are available for styling:
187
+ *
188
+ * Custom property | Description | Default
189
+ * -------------------------------|----------------------------|---------
190
+ * `--vaadin-field-default-width` | Default width of the field | `12em`
191
+ *
192
+ * The following shadow DOM parts are available for styling:
193
+ *
194
+ * Part name | Description
195
+ * ---------------------|----------------
196
+ * `label` | The label element
197
+ * `input-field` | The element that wraps prefix, value and suffix
198
+ * `clear-button` | The clear button
199
+ * `error-message` | The error message element
200
+ * `helper-text` | The helper text element wrapper
201
+ * `required-indicator` | The `required` state indicator element
202
+ *
203
+ * The following state attributes are available for styling:
204
+ *
205
+ * Attribute | Description | Part name
206
+ * --------------------|-------------|------------
207
+ * `disabled` | Set to a disabled text field | :host
208
+ * `has-value` | Set when the element has a value | :host
209
+ * `has-label` | Set when the element has a label | :host
210
+ * `has-helper` | Set when the element has helper text or slot | :host
211
+ * `has-error-message` | Set when the element has an error message | :host
212
+ * `invalid` | Set when the element is invalid | :host
213
+ * `input-prevented` | Temporarily set when invalid input is prevented | :host
214
+ * `focused` | Set when the element is focused | :host
215
+ * `focus-ring` | Set when the element is keyboard focused | :host
216
+ * `readonly` | Set to a readonly text field | :host
217
+ *
218
+ * See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
219
+ *
220
+ * @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.
221
+ * @fires {Event} change - Fired when the user commits a value change.
222
+ * @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
223
+ * @fires {CustomEvent} value-changed - Fired when the `value` property changes.
224
+ * @fires {CustomEvent} validated - Fired whenever the field is validated.
225
+ *
226
+ * @extends HTMLElement
227
+ * @mixes ElementMixin
228
+ * @mixes ThemableMixin
229
+ * @mixes PatternMixin
230
+ * @mixes InputFieldMixin
231
+ */
232
+ class TextField extends PatternMixin(InputFieldMixin(ThemableMixin(ElementMixin(PolymerElement)))) {
233
+ static get is() {
234
+ return 'vaadin-text-field';
235
+ }
236
+
237
+ static get template() {
238
+ return html`
239
+ <style>
240
+ [part='input-field'] {
241
+ flex-grow: 0;
242
+ }
243
+ </style>
244
+
245
+ <div class="vaadin-field-container">
246
+ <div part="label">
247
+ <slot name="label"></slot>
248
+ <span part="required-indicator" aria-hidden="true" on-click="focus"></span>
249
+ </div>
250
+
251
+ <vaadin-input-container
252
+ part="input-field"
253
+ readonly="[[readonly]]"
254
+ disabled="[[disabled]]"
255
+ invalid="[[invalid]]"
256
+ theme$="[[_theme]]"
257
+ >
258
+ <slot name="prefix" slot="prefix"></slot>
259
+ <slot name="input"></slot>
260
+ <slot name="suffix" slot="suffix"></slot>
261
+ <div id="clearButton" part="clear-button" slot="suffix" aria-hidden="true"></div>
262
+ </vaadin-input-container>
263
+
264
+ <div part="helper-text">
265
+ <slot name="helper"></slot>
266
+ </div>
267
+
268
+ <div part="error-message">
269
+ <slot name="error-message"></slot>
270
+ </div>
271
+ </div>
272
+ <slot name="tooltip"></slot>
273
+ `;
274
+ }
275
+
276
+ static get properties() {
277
+ return {
278
+ /**
279
+ * Maximum number of characters (in Unicode code points) that the user can enter.
280
+ */
281
+ maxlength: {
282
+ type: Number,
283
+ },
284
+
285
+ /**
286
+ * Minimum number of characters (in Unicode code points) that the user can enter.
287
+ */
288
+ minlength: {
289
+ type: Number,
290
+ },
291
+ };
292
+ }
293
+
294
+ static get delegateAttrs() {
295
+ return [...super.delegateAttrs, 'maxlength', 'minlength'];
296
+ }
297
+
298
+ static get constraints() {
299
+ return [...super.constraints, 'maxlength', 'minlength'];
300
+ }
301
+
302
+ constructor() {
303
+ super();
304
+ this._setType('text');
305
+ }
306
+
307
+ /** @protected */
308
+ get clearElement() {
309
+ return this.$.clearButton;
310
+ }
311
+
312
+ /** @protected */
313
+ ready() {
314
+ super.ready();
315
+
316
+ this.addController(
317
+ new InputController(this, (input) => {
318
+ this._setInputElement(input);
319
+ this._setFocusElement(input);
320
+ this.stateTarget = input;
321
+ this.ariaTarget = input;
322
+ }),
323
+ );
324
+ this.addController(new LabelledInputController(this.inputElement, this._labelController));
325
+
326
+ this._tooltipController = new TooltipController(this);
327
+ this._tooltipController.setPosition('top');
328
+ this.addController(this._tooltipController);
329
+ }
330
+ }
331
+
332
+ customElements.define(TextField.is, TextField);
333
+
334
+ /**
335
+ * @license
336
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
337
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
338
+ */
339
+
340
+ const passwordFieldButton = i`
341
+ :host {
342
+ position: absolute;
343
+ right: 0;
344
+ top: 0;
345
+ margin: 0;
346
+ padding: 0;
347
+ width: 100%;
348
+ height: 100%;
349
+ min-width: auto;
350
+ background: transparent;
351
+ outline: none;
352
+ }
353
+ `;
354
+
355
+ registerStyles('vaadin-password-field-button', [button, passwordFieldButton], {
356
+ moduleId: 'lumo-password-field-button',
357
+ });
358
+
359
+ /**
360
+ * @license
361
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
362
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
363
+ */
364
+
365
+ const passwordField = i`
366
+ [part='reveal-button']::before {
367
+ content: var(--lumo-icons-eye);
368
+ }
369
+
370
+ :host([password-visible]) [part='reveal-button']::before {
371
+ content: var(--lumo-icons-eye-disabled);
372
+ }
373
+
374
+ /* Make it easy to hide the button across the whole app */
375
+ [part='reveal-button'] {
376
+ position: relative;
377
+ display: var(--lumo-password-field-reveal-button-display, block);
378
+ }
379
+
380
+ [part='reveal-button'][hidden] {
381
+ display: none !important;
382
+ }
383
+ `;
384
+
385
+ registerStyles('vaadin-password-field', [inputFieldShared, passwordField], { moduleId: 'lumo-password-field' });
386
+
387
+ /**
388
+ * @license
389
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
390
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
391
+ */
392
+
393
+ /**
394
+ * An element used internally by `<vaadin-password-field>`. Not intended to be used separately.
395
+ *
396
+ * @extends Button
397
+ * @private
398
+ */
399
+ class PasswordFieldButton extends Button {
400
+ static get is() {
401
+ return 'vaadin-password-field-button';
402
+ }
403
+
404
+ static get template() {
405
+ return html`
406
+ <style>
407
+ :host {
408
+ display: block;
409
+ }
410
+
411
+ :host([hidden]) {
412
+ display: none !important;
413
+ }
414
+ </style>
415
+ <slot name="tooltip"></slot>
416
+ `;
417
+ }
418
+ }
419
+
420
+ customElements.define(PasswordFieldButton.is, PasswordFieldButton);
421
+
422
+ /**
423
+ * @license
424
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
425
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
426
+ */
427
+
428
+ const ownTemplate = html`
429
+ <div part="reveal-button" slot="suffix">
430
+ <slot name="reveal"></slot>
431
+ </div>
432
+ `;
433
+
434
+ let memoizedTemplate;
435
+
436
+ /**
437
+ * `<vaadin-password-field>` is an extension of `<vaadin-text-field>` component for entering passwords.
438
+ *
439
+ * ```html
440
+ * <vaadin-password-field label="Password"></vaadin-password-field>
441
+ * ```
442
+ *
443
+ * ### Styling
444
+ *
445
+ * `<vaadin-password-field>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.
446
+ * See [`<vaadin-text-field>`](#/elements/vaadin-text-field) for the styling documentation.
447
+ *
448
+ * In addition to `<vaadin-text-field>` parts, the following parts are available for theming:
449
+ *
450
+ * Part name | Description
451
+ * ----------------|----------------------------------------------------
452
+ * `reveal-button` | The eye icon which toggles the password visibility
453
+ *
454
+ * In addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:
455
+ *
456
+ * Attribute | Description
457
+ * -------------------|---------------------------------
458
+ * `password-visible` | Set when the password is visible
459
+ *
460
+ * See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
461
+ *
462
+ * @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.
463
+ * @fires {Event} change - Fired when the user commits a value change.
464
+ * @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
465
+ * @fires {CustomEvent} value-changed - Fired when the `value` property changes.
466
+ * @fires {CustomEvent} validated - Fired whenever the field is validated.
467
+ *
468
+ * @extends TextField
469
+ */
470
+ class PasswordField extends TextField {
471
+ static get is() {
472
+ return 'vaadin-password-field';
473
+ }
474
+
475
+ static get template() {
476
+ if (!memoizedTemplate) {
477
+ // Clone the superclass template
478
+ memoizedTemplate = super.template.cloneNode(true);
479
+
480
+ // Retrieve this element's dom-module template
481
+ const revealButton = ownTemplate.content.querySelector('[part="reveal-button"]');
482
+
483
+ // Append reveal-button and styles to the text-field template
484
+ const inputField = memoizedTemplate.content.querySelector('[part="input-field"]');
485
+ inputField.appendChild(revealButton);
486
+ }
487
+
488
+ return memoizedTemplate;
489
+ }
490
+
491
+ static get properties() {
492
+ return {
493
+ /**
494
+ * Set to true to hide the eye icon which toggles the password visibility.
495
+ * @attr {boolean} reveal-button-hidden
496
+ */
497
+ revealButtonHidden: {
498
+ type: Boolean,
499
+ observer: '_revealButtonHiddenChanged',
500
+ value: false,
501
+ },
502
+
503
+ /**
504
+ * True if the password is visible ([type=text]).
505
+ * @attr {boolean} password-visible
506
+ */
507
+ passwordVisible: {
508
+ type: Boolean,
509
+ value: false,
510
+ reflectToAttribute: true,
511
+ observer: '_passwordVisibleChanged',
512
+ readOnly: true,
513
+ },
514
+
515
+ /**
516
+ * An object with translated strings used for localization.
517
+ * It has the following structure and default values:
518
+ *
519
+ * ```
520
+ * {
521
+ * // Translation of the reveal icon button accessible label
522
+ * reveal: 'Show password'
523
+ * }
524
+ * ```
525
+ */
526
+ i18n: {
527
+ type: Object,
528
+ value: () => {
529
+ return {
530
+ reveal: 'Show password',
531
+ };
532
+ },
533
+ },
534
+ };
535
+ }
536
+
537
+ static get observers() {
538
+ return ['__i18nChanged(i18n.*)'];
539
+ }
540
+
541
+ /** @protected */
542
+ get slotStyles() {
543
+ const tag = this.localName;
544
+ return [
545
+ ...super.slotStyles,
546
+ `
547
+ ${tag} [slot="input"]::-ms-reveal {
548
+ display: none;
549
+ }
550
+ `,
551
+ ];
552
+ }
553
+
554
+ /** @protected */
555
+ get _revealNode() {
556
+ return this._revealButtonController && this._revealButtonController.node;
557
+ }
558
+
559
+ constructor() {
560
+ super();
561
+ this._setType('password');
562
+ this.__boundRevealButtonClick = this._onRevealButtonClick.bind(this);
563
+ this.__boundRevealButtonTouchend = this._onRevealButtonTouchend.bind(this);
564
+ }
565
+
566
+ /** @protected */
567
+ ready() {
568
+ super.ready();
569
+
570
+ this._revealPart = this.shadowRoot.querySelector('[part="reveal-button"]');
571
+
572
+ this._revealButtonController = new SlotController(
573
+ this,
574
+ 'reveal',
575
+ () => document.createElement('vaadin-password-field-button'),
576
+ (host, btn) => {
577
+ btn.disabled = host.disabled;
578
+
579
+ btn.addEventListener('click', host.__boundRevealButtonClick);
580
+ btn.addEventListener('touchend', host.__boundRevealButtonTouchend);
581
+ },
582
+ );
583
+ this.addController(this._revealButtonController);
584
+
585
+ this.__updateAriaLabel(this.i18n);
586
+
587
+ this._updateToggleState(false);
588
+ this._toggleRevealHidden(this.revealButtonHidden);
589
+
590
+ if (this.inputElement) {
591
+ this.inputElement.autocapitalize = 'off';
592
+ }
593
+ }
594
+
595
+ /**
596
+ * Override method inherited from `FocusMixin` to mark field as focused
597
+ * when focus moves to the reveal button using Shift Tab.
598
+ * @param {Event} event
599
+ * @return {boolean}
600
+ * @protected
601
+ */
602
+ _shouldSetFocus(event) {
603
+ return event.target === this.inputElement || event.target === this._revealNode;
604
+ }
605
+
606
+ /**
607
+ * Override method inherited from `FocusMixin` to not hide password
608
+ * when focus moves to the reveal button or back to the input.
609
+ * @param {Event} event
610
+ * @return {boolean}
611
+ * @protected
612
+ */
613
+ _shouldRemoveFocus(event) {
614
+ return !(
615
+ event.relatedTarget === this._revealNode ||
616
+ (event.relatedTarget === this.inputElement && event.target === this._revealNode)
617
+ );
618
+ }
619
+
620
+ /**
621
+ * Override method inherited from `FocusMixin` to toggle password visibility.
622
+ * @param {boolean} focused
623
+ * @protected
624
+ * @override
625
+ */
626
+ _setFocused(focused) {
627
+ super._setFocused(focused);
628
+
629
+ if (!focused) {
630
+ this._setPasswordVisible(false);
631
+ } else {
632
+ const isButtonFocused = this.getRootNode().activeElement === this._revealNode;
633
+ // Remove focus-ring from the field when the reveal button gets focused
634
+ this.toggleAttribute('focus-ring', this._keyboardActive && !isButtonFocused);
635
+ }
636
+ }
637
+
638
+ /** @private */
639
+ __updateAriaLabel(i18n) {
640
+ if (i18n.reveal && this._revealNode) {
641
+ this._revealNode.setAttribute('aria-label', i18n.reveal);
642
+ }
643
+ }
644
+
645
+ /** @private */
646
+ __i18nChanged(i18n) {
647
+ this.__updateAriaLabel(i18n.base);
648
+ }
649
+
650
+ /** @private */
651
+ _revealButtonHiddenChanged(hidden) {
652
+ this._toggleRevealHidden(hidden);
653
+ }
654
+
655
+ /** @private */
656
+ _togglePasswordVisibility() {
657
+ this._setPasswordVisible(!this.passwordVisible);
658
+ }
659
+
660
+ /** @private */
661
+ _onRevealButtonClick() {
662
+ this._togglePasswordVisibility();
663
+ }
664
+
665
+ /** @private */
666
+ _onRevealButtonTouchend(e) {
667
+ // Cancel the following click event
668
+ e.preventDefault();
669
+ this._togglePasswordVisibility();
670
+ // Focus the input to avoid problem with password still visible
671
+ // when user clicks the reveal button and then clicks outside.
672
+ this.inputElement.focus();
673
+ }
674
+
675
+ /** @private */
676
+ _toggleRevealHidden(hidden) {
677
+ if (this._revealNode) {
678
+ if (hidden) {
679
+ this._revealPart.setAttribute('hidden', '');
680
+ this._revealNode.setAttribute('tabindex', '-1');
681
+ this._revealNode.setAttribute('aria-hidden', 'true');
682
+ } else {
683
+ this._revealPart.removeAttribute('hidden');
684
+ this._revealNode.setAttribute('tabindex', '0');
685
+ this._revealNode.removeAttribute('aria-hidden');
686
+ }
687
+ }
688
+ }
689
+
690
+ /** @private */
691
+ _updateToggleState(passwordVisible) {
692
+ if (this._revealNode) {
693
+ this._revealNode.setAttribute('aria-pressed', passwordVisible ? 'true' : 'false');
694
+ }
695
+ }
696
+
697
+ /** @private */
698
+ _passwordVisibleChanged(passwordVisible) {
699
+ this._setType(passwordVisible ? 'text' : 'password');
700
+
701
+ this._updateToggleState(passwordVisible);
702
+ }
703
+
704
+ /**
705
+ * Override method inherited from `DisabledMixin` to synchronize the reveal button
706
+ * disabled state with the password field disabled state.
707
+ * @param {boolean} disabled
708
+ * @param {boolean} oldDisabled
709
+ * @protected
710
+ */
711
+ _disabledChanged(disabled, oldDisabled) {
712
+ super._disabledChanged(disabled, oldDisabled);
713
+
714
+ if (this._revealNode) {
715
+ this._revealNode.disabled = disabled;
716
+ }
717
+ }
718
+ }
719
+
720
+ customElements.define(PasswordField.is, PasswordField);
721
+
722
+ 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%}.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:#1F1F1F}.password__label--required::after{content:\"*\";font-family:inherit;color:#1F1F1F;margin-left:2px}.password__input{width:inherit;border:none}.password__input[focused]::part(input-field){border-color:#3E3E3E}.password__input[invalid]::part(input-field){border-color:#cc0000b3}.password__input::part(input-field){border-radius:4px;background-color:transparent;font-family:inherit;font-style:normal;font-weight:300;font-size:16px;line-height:19px;color:#2A2E3F;width:100%;position:relative;border:2px solid #DEE1EE}.password__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}.password__tooltip-icon{width:16px;height:auto}.password__tooltip{position:absolute;top:0;left:20px;background-color:#FFFFFF;border:1px solid #B0B0B0;color:#2B2D3F;padding:10px;border-radius:5px;opacity:0;transition:opacity 0.3s ease-in-out;z-index:10}.password__tooltip.visible{opacity:1}";
723
+
724
+ const PasswordInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
725
+ constructor() {
726
+ super();
727
+ this.__registerHost();
728
+ this.__attachShadow();
729
+ this.sendValidityState = createEvent(this, "sendValidityState", 7);
730
+ this.sendInputValue = createEvent(this, "sendInputValue", 7);
731
+ /**
732
+ * Default value for the input.
733
+ */
734
+ this.defaultValue = '';
735
+ /**
736
+ * Client custom styling via inline style
737
+ */
738
+ this.clientStyling = '';
739
+ this.limitStylingAppends = false;
740
+ this.showTooltip = false;
741
+ this.value = '';
742
+ this.validationPattern = '';
743
+ this.setClientStyling = () => {
744
+ let sheet = document.createElement('style');
745
+ sheet.innerHTML = this.clientStyling;
746
+ this.stylingContainer.prepend(sheet);
747
+ };
748
+ }
749
+ validityChanged() {
750
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
751
+ if (this.emitValue == true) {
752
+ this.valueHandler({ name: this.name, value: this.value });
753
+ }
754
+ }
755
+ emitValueHandler(newValue) {
756
+ if (newValue == true && this.isValid) {
757
+ this.valueHandler({ name: this.name, value: this.value });
758
+ }
759
+ }
760
+ validityStateHandler(inputStateEvent) {
761
+ this.sendValidityState.emit(inputStateEvent);
762
+ }
763
+ valueHandler(inputValueEvent) {
764
+ this.sendInputValue.emit(inputValueEvent);
765
+ }
766
+ valueChangedHandler(event) {
767
+ if (this.isDuplicateInput) {
768
+ if (this.name === event.detail.name + 'Duplicate') {
769
+ this.duplicateInputValue = event.detail.value;
770
+ }
771
+ }
772
+ }
773
+ handleClickOutside(event) {
774
+ if (event.composedPath()[0] === this.tooltipIconReference)
775
+ return;
776
+ if (event.composedPath()[0] !== this.tooltipReference)
777
+ this.showTooltip = false;
778
+ }
779
+ connectedCallback() {
780
+ this.validationPattern = this.setPattern();
781
+ }
782
+ componentDidRender() {
783
+ // start custom styling area
784
+ if (!this.limitStylingAppends && this.stylingContainer) {
785
+ if (this.clientStyling)
786
+ this.setClientStyling();
787
+ this.limitStylingAppends = true;
788
+ }
789
+ // end custom styling area
790
+ if (this.defaultValue) {
791
+ this.value = this.defaultValue;
792
+ this.valueHandler({ name: this.name, value: this.value });
793
+ }
794
+ }
795
+ componentDidLoad() {
796
+ this.inputReference = this.element.shadowRoot.querySelector('input');
797
+ }
798
+ handleInput(event) {
799
+ this.value = event.target.value;
800
+ this.errorMessage = this.setErrorMessage();
801
+ this.isValid = this.setValidity();
802
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
803
+ this.emitValueHandler(true);
804
+ }
805
+ setValidity() {
806
+ return this.inputReference.validity.valid;
807
+ }
808
+ setPattern() {
809
+ var _a, _b;
810
+ if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
811
+ return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
812
+ }
813
+ }
814
+ setErrorMessage() {
815
+ var _a;
816
+ if (this.inputReference.validity.patternMismatch) {
817
+ return (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorMessage;
818
+ }
819
+ if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
820
+ return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
821
+ }
822
+ if (this.inputReference.validity.valueMissing) {
823
+ return translate('requiredError', this.language);
824
+ }
825
+ if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
826
+ return this.validation.custom.find(customRule => customRule.rule === 'duplicate-input').errorMessage;
827
+ }
828
+ }
829
+ renderTooltip() {
830
+ if (this.showTooltip) {
831
+ return (h("div", { class: `password__tooltip ${this.showTooltip ? 'visible' : ''}`, ref: (el) => this.tooltipReference = el, innerHTML: this.tooltip }));
832
+ }
833
+ return null;
834
+ }
835
+ render() {
836
+ const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'password__input--invalid';
837
+ return h("div", { class: 'password__wrapper', 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 &&
838
+ 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,
839
+ // ref={(el) => this.inputReference = el as HTMLInputElement}
840
+ required: this.validation.mandatory, maxlength: this.validation.maxLength, minlength: this.validation.minLength, pattern: this.validationPattern, placeholder: `${this.placeholder} ${this.placeholder && this.validation.mandatory ? '*' : ''}`, onBlur: (e) => this.handleInput(e) }), h("small", { class: 'password__error-message' }, this.errorMessage));
841
+ }
842
+ get element() { return this; }
843
+ static get watchers() { return {
844
+ "isValid": ["validityChanged"],
845
+ "emitValue": ["emitValueHandler"]
846
+ }; }
847
+ static get style() { return passwordInputCss; }
848
+ }, [1, "password-input", {
849
+ "name": [513],
850
+ "displayName": [513, "display-name"],
851
+ "placeholder": [513],
852
+ "defaultValue": [513, "default-value"],
853
+ "autofilled": [516],
854
+ "tooltip": [513],
855
+ "validation": [16],
856
+ "language": [513],
857
+ "emitValue": [516, "emit-value"],
858
+ "isDuplicateInput": [516, "is-duplicate-input"],
859
+ "clientStyling": [513, "client-styling"],
860
+ "isValid": [32],
861
+ "errorMessage": [32],
862
+ "limitStylingAppends": [32],
863
+ "showTooltip": [32]
864
+ }, [[16, "sendInputValue", "valueChangedHandler"], [4, "click", "handleClickOutside"]]]);
865
+ function defineCustomElement() {
866
+ if (typeof customElements === "undefined") {
867
+ return;
868
+ }
869
+ const components = ["password-input"];
870
+ components.forEach(tagName => { switch (tagName) {
871
+ case "password-input":
872
+ if (!customElements.get(tagName)) {
873
+ customElements.define(tagName, PasswordInput);
874
+ }
875
+ break;
876
+ } });
877
+ }
878
+
879
+ export { PasswordInput as P, defineCustomElement as d };