@italia/input 0.1.0-alpha.0 → 0.1.0-alpha.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/custom-elements.json +263 -292
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/it-input.d.ts +25 -1077
- package/dist/src/it-input.d.ts.map +1 -1
- package/dist/src/it-input.js +982 -481
- package/dist/src/it-input.js.map +1 -1
- package/dist/src/locales/it.d.ts.map +1 -1
- package/package.json +15 -14
- package/styles/globals.scss +15 -6
package/dist/src/it-input.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { directive, Directive } from 'lit/directive.js';
|
|
2
2
|
import { LitElement, css, html, nothing } from 'lit';
|
|
3
|
-
import {
|
|
3
|
+
import { state, query, property, queryAssignedElements, customElement } from 'lit/decorators.js';
|
|
4
4
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
5
|
import { when } from 'lit/directives/when.js';
|
|
6
|
+
import { live } from 'lit/directives/live.js';
|
|
6
7
|
|
|
7
8
|
/******************************************************************************
|
|
8
9
|
Copyright (c) Microsoft Corporation.
|
|
@@ -37,209 +38,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
37
38
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
38
39
|
};
|
|
39
40
|
|
|
40
|
-
/**
|
|
41
|
-
* @license
|
|
42
|
-
*
|
|
43
|
-
* Copyright IBM Corp. 2020, 2022
|
|
44
|
-
*
|
|
45
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
46
|
-
* LICENSE file in the root directory of this source tree.
|
|
47
|
-
*/
|
|
48
|
-
/**
|
|
49
|
-
* @param Base The base class.
|
|
50
|
-
* @returns A mix-in to handle `formdata` event on the containing form.
|
|
51
|
-
*/
|
|
52
|
-
const FormMixin = (Base) => {
|
|
53
|
-
/**
|
|
54
|
-
* A mix-in class to handle `formdata` event on the containing form.
|
|
55
|
-
*/
|
|
56
|
-
class FormMixinImpl extends Base {
|
|
57
|
-
connectedCallback() {
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
super.connectedCallback();
|
|
60
|
-
if (this.closest('form')) {
|
|
61
|
-
this.closest('form')?.addEventListener('formdata', this._handleFormdata.bind(this));
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
disconnectedCallback() {
|
|
65
|
-
// if (this._hFormdata) {
|
|
66
|
-
// this._hFormdata = this._hFormdata.release();
|
|
67
|
-
// }
|
|
68
|
-
// @ts-ignore
|
|
69
|
-
super.disconnectedCallback();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return FormMixinImpl;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* @license
|
|
77
|
-
*
|
|
78
|
-
* Copyright IBM Corp. 2020, 2022
|
|
79
|
-
*
|
|
80
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
81
|
-
* LICENSE file in the root directory of this source tree.
|
|
82
|
-
*/
|
|
83
|
-
/**
|
|
84
|
-
* Form validation status.
|
|
85
|
-
*/
|
|
86
|
-
var VALIDATION_STATUS;
|
|
87
|
-
(function (VALIDATION_STATUS) {
|
|
88
|
-
/**
|
|
89
|
-
* One indicating no validation error.
|
|
90
|
-
*/
|
|
91
|
-
VALIDATION_STATUS["NO_ERROR"] = "";
|
|
92
|
-
/**
|
|
93
|
-
* One indicating that the value is invalid (generic).
|
|
94
|
-
*/
|
|
95
|
-
VALIDATION_STATUS["INVALID"] = "invalid";
|
|
96
|
-
/**
|
|
97
|
-
* One indicating missing required value.
|
|
98
|
-
*/
|
|
99
|
-
VALIDATION_STATUS["ERROR_REQUIRED"] = "required";
|
|
100
|
-
/**
|
|
101
|
-
* One indicating that the value does not match the pattern.
|
|
102
|
-
*/
|
|
103
|
-
VALIDATION_STATUS["PATTERN"] = "pattern";
|
|
104
|
-
/**
|
|
105
|
-
* One indicating that the value is shorter than the minimum length.
|
|
106
|
-
*/
|
|
107
|
-
VALIDATION_STATUS["MINLENGTH"] = "minlength";
|
|
108
|
-
/**
|
|
109
|
-
* One indicating that the value is less than the maximum length.
|
|
110
|
-
*/
|
|
111
|
-
VALIDATION_STATUS["MAXLENGTH"] = "maxlength";
|
|
112
|
-
})(VALIDATION_STATUS || (VALIDATION_STATUS = {}));
|
|
113
|
-
/**
|
|
114
|
-
* @param Base The base class.
|
|
115
|
-
* @returns A mix-in implementing `.setCustomValidity()` method.
|
|
116
|
-
*/
|
|
117
|
-
const ValidityMixin = (Base) => {
|
|
118
|
-
class ValidityMixinImpl extends Base {
|
|
119
|
-
constructor() {
|
|
120
|
-
super(...arguments);
|
|
121
|
-
/**
|
|
122
|
-
* Field is touched
|
|
123
|
-
*/
|
|
124
|
-
this._touched = false;
|
|
125
|
-
}
|
|
126
|
-
// Not using TypeScript `protected` due to: microsoft/TypeScript#17744
|
|
127
|
-
// Using `string` instead of `VALIDATION_STATUS` until we can require TypeScript 3.8
|
|
128
|
-
/**
|
|
129
|
-
* @param state The form validation status.
|
|
130
|
-
* @returns The form validation error mesasages associated with the given status.
|
|
131
|
-
* @protected
|
|
132
|
-
*/
|
|
133
|
-
_getValidityMessage(state, translations) {
|
|
134
|
-
return {
|
|
135
|
-
[VALIDATION_STATUS.NO_ERROR]: '',
|
|
136
|
-
[VALIDATION_STATUS.INVALID]: translations[VALIDATION_STATUS.INVALID],
|
|
137
|
-
[VALIDATION_STATUS.ERROR_REQUIRED]: translations[VALIDATION_STATUS.ERROR_REQUIRED],
|
|
138
|
-
[VALIDATION_STATUS.PATTERN]: translations[VALIDATION_STATUS.PATTERN],
|
|
139
|
-
[VALIDATION_STATUS.MINLENGTH]: translations[VALIDATION_STATUS.MINLENGTH].replace('{minlength}', this.minlength.toString()),
|
|
140
|
-
[VALIDATION_STATUS.MAXLENGTH]: translations[VALIDATION_STATUS.MAXLENGTH].replace('{maxlength}', this.maxlength.toString()),
|
|
141
|
-
}[state];
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Checks if the value meets the constraints.
|
|
145
|
-
*
|
|
146
|
-
* @returns `true` if the value meets the constraints. `false` otherwise.
|
|
147
|
-
*/
|
|
148
|
-
_checkValidity(translations, htmlValidity = true) {
|
|
149
|
-
// htmlValidity = this.inputElement.checkValidity(); //check browser validity
|
|
150
|
-
if (this.customValidation) {
|
|
151
|
-
return undefined;
|
|
152
|
-
}
|
|
153
|
-
let validity = htmlValidity;
|
|
154
|
-
let message = validity
|
|
155
|
-
? this._getValidityMessage(VALIDATION_STATUS.NO_ERROR, translations)
|
|
156
|
-
: this._getValidityMessage(VALIDATION_STATUS.INVALID, translations);
|
|
157
|
-
if (this.required || (this._value && (this.pattern || this.minlength > 0 || this.maxlength > 0))) {
|
|
158
|
-
if (this.pattern) {
|
|
159
|
-
const regex = new RegExp(`^${this.pattern}$`, 'u');
|
|
160
|
-
validity = regex.test(this._value.toString());
|
|
161
|
-
if (!validity) {
|
|
162
|
-
message = this._getValidityMessage(VALIDATION_STATUS.PATTERN, translations);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
if (typeof this.minlength !== 'undefined' && this.minlength > 0) {
|
|
166
|
-
validity = validity && this._value.toString().length >= this.minlength;
|
|
167
|
-
if (!validity) {
|
|
168
|
-
message = this._getValidityMessage(VALIDATION_STATUS.MINLENGTH, translations);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
if (typeof this.maxlength !== 'undefined' && this.maxlength > 0) {
|
|
172
|
-
validity = validity && this._value.toString().length <= this.maxlength;
|
|
173
|
-
if (!validity) {
|
|
174
|
-
message = this._getValidityMessage(VALIDATION_STATUS.MAXLENGTH, translations);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
if (this.required && !this._value) {
|
|
178
|
-
validity = false;
|
|
179
|
-
message = this._getValidityMessage(VALIDATION_STATUS.ERROR_REQUIRED, translations);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
this.invalid = !validity;
|
|
183
|
-
this.validityMessage = message;
|
|
184
|
-
return validity;
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Sets the given custom validity message.
|
|
188
|
-
*
|
|
189
|
-
* @param validityMessage The custom validity message
|
|
190
|
-
*/
|
|
191
|
-
setCustomValidity(validityMessage) {
|
|
192
|
-
this.invalid = Boolean(validityMessage);
|
|
193
|
-
this.validityMessage = validityMessage;
|
|
194
|
-
}
|
|
195
|
-
_handleBlur() {
|
|
196
|
-
this._touched = true;
|
|
197
|
-
this.dispatchEvent(new FocusEvent('blur', { bubbles: true, composed: true }));
|
|
198
|
-
}
|
|
199
|
-
_handleFocus() {
|
|
200
|
-
this.dispatchEvent(new FocusEvent('focus', { bubbles: true, composed: true }));
|
|
201
|
-
}
|
|
202
|
-
_handleClick() {
|
|
203
|
-
this.dispatchEvent(new MouseEvent('click', { bubbles: true, composed: true }));
|
|
204
|
-
}
|
|
205
|
-
_handleChange(e) {
|
|
206
|
-
const target = e.target;
|
|
207
|
-
let value;
|
|
208
|
-
if (target instanceof HTMLInputElement) {
|
|
209
|
-
switch (target.type) {
|
|
210
|
-
case 'checkbox':
|
|
211
|
-
case 'radio':
|
|
212
|
-
value = target.checked;
|
|
213
|
-
break;
|
|
214
|
-
case 'file':
|
|
215
|
-
value = target.files; // FileList
|
|
216
|
-
break;
|
|
217
|
-
default:
|
|
218
|
-
value = target.value;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
else if (target instanceof HTMLSelectElement) {
|
|
222
|
-
if (target.multiple) {
|
|
223
|
-
value = Array.from(target.selectedOptions).map((o) => o.value);
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
value = target.value;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
// textarea o altri input con value
|
|
231
|
-
value = target.value;
|
|
232
|
-
}
|
|
233
|
-
this.dispatchEvent(new CustomEvent('change', {
|
|
234
|
-
detail: { value, el: target },
|
|
235
|
-
bubbles: true,
|
|
236
|
-
composed: true,
|
|
237
|
-
}));
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
return ValidityMixinImpl;
|
|
241
|
-
};
|
|
242
|
-
|
|
243
41
|
class SetAttributesDirective extends Directive {
|
|
244
42
|
update(part, [attributes]) {
|
|
245
43
|
const el = part.element;
|
|
@@ -262,6 +60,8 @@ class SetAttributesDirective extends Directive {
|
|
|
262
60
|
*/
|
|
263
61
|
const setAttributes = directive(SetAttributesDirective);
|
|
264
62
|
|
|
63
|
+
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
64
|
+
|
|
265
65
|
const connectedElements = new Set();
|
|
266
66
|
if (window && !window.translations) {
|
|
267
67
|
window.translations = new Map();
|
|
@@ -471,10 +271,11 @@ const LocalizeMixin = (Base) => class extends Base {
|
|
|
471
271
|
constructor() {
|
|
472
272
|
super(...arguments);
|
|
473
273
|
this.localize = new LocalizeController(this);
|
|
474
|
-
// Provide default values to avoid definite assignment errors and avoid decorators
|
|
475
|
-
this.dir = '';
|
|
476
|
-
this.lang = '';
|
|
477
274
|
}
|
|
275
|
+
// Provide default values to avoid definite assignment errors and avoid decorators
|
|
276
|
+
// commentati perchè danno problemi su React.js. Sono attributi nativi, e assegnare un valore di default a react da fastidio
|
|
277
|
+
// dir: string = '';
|
|
278
|
+
// lang: string = '';
|
|
478
279
|
/**
|
|
479
280
|
* Restituisce tutta l'utility di traduzione
|
|
480
281
|
*
|
|
@@ -567,9 +368,21 @@ class Logger {
|
|
|
567
368
|
class BaseComponent extends LitElement {
|
|
568
369
|
constructor() {
|
|
569
370
|
super();
|
|
570
|
-
this.
|
|
371
|
+
this.composeClass = clsx;
|
|
571
372
|
this.logger = new Logger(this.tagName.toLowerCase());
|
|
572
373
|
}
|
|
374
|
+
get _ariaAttributes() {
|
|
375
|
+
const attributes = {};
|
|
376
|
+
for (const attr of this.getAttributeNames()) {
|
|
377
|
+
if (attr === 'it-role') {
|
|
378
|
+
attributes.role = this.getAttribute(attr);
|
|
379
|
+
}
|
|
380
|
+
else if (attr.startsWith('it-aria-')) {
|
|
381
|
+
attributes[attr.replace(/^it-/, '')] = this.getAttribute(attr);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return attributes;
|
|
385
|
+
}
|
|
573
386
|
// eslint-disable-next-line class-methods-use-this
|
|
574
387
|
generateId(prefix) {
|
|
575
388
|
return `${prefix}-${Math.random().toString(36).slice(2)}`;
|
|
@@ -579,25 +392,22 @@ class BaseComponent extends LitElement {
|
|
|
579
392
|
// new TrackFocus(element); // per il momento è stato disattivato perchè ci sono le pseudo classi ::focus-visible per fare quello che fa TrackFocus. Si possono aggiungere regole css in bsi-italia 3 dato che stiamo facendo una breaking release di bsi.
|
|
580
393
|
}
|
|
581
394
|
// eslint-disable-next-line class-methods-use-this
|
|
582
|
-
|
|
583
|
-
let
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
.forEach((newClass) => {
|
|
587
|
-
composedClass += ` ${newClass}`;
|
|
588
|
-
});
|
|
589
|
-
return composedClass.trim();
|
|
590
|
-
}
|
|
591
|
-
getAriaAttributes() {
|
|
592
|
-
for (const attr of this.getAttributeNames()) {
|
|
593
|
-
if (attr.startsWith('aria-')) {
|
|
594
|
-
this._ariaAttributes[attr] = this.getAttribute(attr);
|
|
595
|
-
}
|
|
395
|
+
getActiveElement() {
|
|
396
|
+
let active = document.activeElement;
|
|
397
|
+
while (active && active.shadowRoot && active.shadowRoot.activeElement) {
|
|
398
|
+
active = active.shadowRoot.activeElement;
|
|
596
399
|
}
|
|
400
|
+
return active;
|
|
401
|
+
}
|
|
402
|
+
get focusElement() {
|
|
403
|
+
return this;
|
|
404
|
+
}
|
|
405
|
+
// eslint-disable-next-line class-methods-use-this
|
|
406
|
+
get prefersReducedMotion() {
|
|
407
|
+
return window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
597
408
|
}
|
|
598
409
|
connectedCallback() {
|
|
599
|
-
super.connectedCallback
|
|
600
|
-
this.getAriaAttributes();
|
|
410
|
+
super.connectedCallback();
|
|
601
411
|
// generate internal _id
|
|
602
412
|
const prefix = this.id?.length > 0 ? this.id : this.tagName.toLowerCase();
|
|
603
413
|
this._id = this.generateId(prefix);
|
|
@@ -605,6 +415,625 @@ class BaseComponent extends LitElement {
|
|
|
605
415
|
}
|
|
606
416
|
const BaseLocalizedComponent = LocalizeMixin(BaseComponent);
|
|
607
417
|
|
|
418
|
+
//
|
|
419
|
+
// We store a WeakMap of forms + controls so we can keep references to all FormControl within a given form. As
|
|
420
|
+
// elements connect and disconnect to/from the DOM, their containing form is used as the key and the form control is
|
|
421
|
+
// added and removed from the form's set, respectively.
|
|
422
|
+
//
|
|
423
|
+
const formCollections = new WeakMap();
|
|
424
|
+
//
|
|
425
|
+
// We store a WeakMap of reportValidity() overloads so we can override it when form controls connect to the DOM and
|
|
426
|
+
// restore the original behavior when they disconnect.
|
|
427
|
+
//
|
|
428
|
+
const reportValidityOverloads = new WeakMap();
|
|
429
|
+
const checkValidityOverloads = new WeakMap();
|
|
430
|
+
//
|
|
431
|
+
// We store a Set of controls that users have interacted with. This allows us to determine the interaction state
|
|
432
|
+
// without littering the DOM with additional data attributes.
|
|
433
|
+
//
|
|
434
|
+
const userInteractedControls = new WeakSet();
|
|
435
|
+
//
|
|
436
|
+
// We store a WeakMap of interactions for each form control so we can track when all conditions are met for validation.
|
|
437
|
+
//
|
|
438
|
+
const interactions = new WeakMap();
|
|
439
|
+
/** A reactive controller to allow form controls to participate in form submission, validation, etc. */
|
|
440
|
+
class FormControlController {
|
|
441
|
+
constructor(host, options) {
|
|
442
|
+
this.handleFormData = (event) => {
|
|
443
|
+
// console.log('handleFormData');
|
|
444
|
+
const disabled = this.options.disabled(this.host);
|
|
445
|
+
const name = this.options.name(this.host);
|
|
446
|
+
const value = this.options.value(this.host);
|
|
447
|
+
const tagName = this.host.tagName.toLowerCase();
|
|
448
|
+
// For buttons, we only submit the value if they were the submitter. This is currently done in doAction() by
|
|
449
|
+
// injecting the name/value on a temporary button, so we can just skip them here.
|
|
450
|
+
const isButton = tagName === 'it-button';
|
|
451
|
+
if (this.host.isConnected &&
|
|
452
|
+
!disabled &&
|
|
453
|
+
!isButton &&
|
|
454
|
+
typeof name === 'string' &&
|
|
455
|
+
name.length > 0 &&
|
|
456
|
+
typeof value !== 'undefined') {
|
|
457
|
+
switch (tagName) {
|
|
458
|
+
case 'it-radio':
|
|
459
|
+
if (this.host.checked) {
|
|
460
|
+
event.formData.append(name, value);
|
|
461
|
+
}
|
|
462
|
+
break;
|
|
463
|
+
default:
|
|
464
|
+
if (Array.isArray(value)) {
|
|
465
|
+
value.forEach((val) => {
|
|
466
|
+
event.formData.append(name, val.toString());
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
event.formData.append(name, value.toString());
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
this.handleFormSubmit = (event) => {
|
|
476
|
+
const disabled = this.options.disabled(this.host);
|
|
477
|
+
const reportValidity = this.options.reportValidity;
|
|
478
|
+
// Update the interacted state for all controls when the form is submitted
|
|
479
|
+
if (this.form && !this.form.noValidate) {
|
|
480
|
+
formCollections.get(this.form)?.forEach((control) => {
|
|
481
|
+
this.setUserInteracted(control, true);
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
if (this.form && !this.form.noValidate && !disabled && !reportValidity(this.host)) {
|
|
485
|
+
event.preventDefault();
|
|
486
|
+
// event.stopImmediatePropagation(); // se lo attiviamo, valida un campo alla volta
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
this.handleFormReset = () => {
|
|
490
|
+
this.options.setValue(this.host, '');
|
|
491
|
+
this.setUserInteracted(this.host, false);
|
|
492
|
+
interactions.set(this.host, []);
|
|
493
|
+
};
|
|
494
|
+
this.handleInteraction = (event) => {
|
|
495
|
+
const emittedEvents = interactions.get(this.host);
|
|
496
|
+
if (!emittedEvents.includes(event.type)) {
|
|
497
|
+
emittedEvents.push(event.type);
|
|
498
|
+
}
|
|
499
|
+
// Mark it as user-interacted as soon as all associated events have been emitted
|
|
500
|
+
if (emittedEvents.length === this.options.assumeInteractionOn.length) {
|
|
501
|
+
this.setUserInteracted(this.host, true);
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
this.checkFormValidity = () => {
|
|
505
|
+
// console.log('checkFormValidity');
|
|
506
|
+
//
|
|
507
|
+
// This is very similar to the `reportFormValidity` function, but it does not trigger native constraint validation
|
|
508
|
+
// Allow the user to simply check if the form is valid and handling validity in their own way.
|
|
509
|
+
//
|
|
510
|
+
// We preserve the original method in a WeakMap, but we don't call it from the overload because that would trigger
|
|
511
|
+
// validations in an unexpected order. When the element disconnects, we revert to the original behavior. This won't
|
|
512
|
+
// be necessary once we can use ElementInternals.
|
|
513
|
+
//
|
|
514
|
+
// Note that we're also honoring the form's novalidate attribute.
|
|
515
|
+
//
|
|
516
|
+
if (this.form && !this.form.noValidate) {
|
|
517
|
+
// This seems sloppy, but checking all elements will cover native inputs, Shoelace inputs, and other custom
|
|
518
|
+
// elements that support the constraint validation API.
|
|
519
|
+
const elements = this.form.querySelectorAll('*');
|
|
520
|
+
for (const element of elements) {
|
|
521
|
+
if (typeof element.checkValidity === 'function') {
|
|
522
|
+
if (!element.checkValidity()) {
|
|
523
|
+
return false;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
return true;
|
|
529
|
+
};
|
|
530
|
+
this.reportFormValidity = () => {
|
|
531
|
+
// console.log('reportFormValidity');
|
|
532
|
+
//
|
|
533
|
+
// FormControl work hard to act like regular form controls. They support the Constraint Validation API
|
|
534
|
+
// and its associated methods such as setCustomValidity() and reportValidity(). However, the HTMLFormElement also
|
|
535
|
+
// has a reportValidity() method that will trigger validation on all child controls. Since we're not yet using
|
|
536
|
+
// ElementInternals, we need to overload this method so it looks for any element with the reportValidity() method.
|
|
537
|
+
//
|
|
538
|
+
// We preserve the original method in a WeakMap, but we don't call it from the overload because that would trigger
|
|
539
|
+
// validations in an unexpected order. When the element disconnects, we revert to the original behavior. This won't
|
|
540
|
+
// be necessary once we can use ElementInternals.
|
|
541
|
+
//
|
|
542
|
+
// Note that we're also honoring the form's novalidate attribute.
|
|
543
|
+
//
|
|
544
|
+
if (this.form && !this.form.noValidate) {
|
|
545
|
+
// This seems sloppy, but checking all elements will cover native inputs, Shoelace inputs, and other custom
|
|
546
|
+
// elements that support the constraint validation API.
|
|
547
|
+
const elements = this.form.querySelectorAll('*');
|
|
548
|
+
for (const element of elements) {
|
|
549
|
+
if (typeof element.reportValidity === 'function') {
|
|
550
|
+
if (!element.reportValidity()) {
|
|
551
|
+
return false;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
return true;
|
|
557
|
+
};
|
|
558
|
+
(this.host = host).addController(this);
|
|
559
|
+
this.options = {
|
|
560
|
+
form: (input) => {
|
|
561
|
+
// If there's a form attribute, use it to find the target form by id
|
|
562
|
+
// Controls may not always reflect the 'form' property. For example, `<it-button>` doesn't reflect.
|
|
563
|
+
const formId = input.form;
|
|
564
|
+
if (formId) {
|
|
565
|
+
const root = input.getRootNode();
|
|
566
|
+
const form = root.querySelector(`#${formId}`);
|
|
567
|
+
if (form) {
|
|
568
|
+
return form;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
return input.closest('form');
|
|
572
|
+
},
|
|
573
|
+
name: (input) => input.name,
|
|
574
|
+
value: (input) => input.value,
|
|
575
|
+
disabled: (input) => input.disabled ?? false,
|
|
576
|
+
reportValidity: (input) => typeof input.reportValidity === 'function' ? input.reportValidity() : true,
|
|
577
|
+
checkValidity: (input) => (typeof input.checkValidity === 'function' ? input.checkValidity() : true),
|
|
578
|
+
setValue: (input, value) => {
|
|
579
|
+
// eslint-disable-next-line no-param-reassign
|
|
580
|
+
input.value = value;
|
|
581
|
+
},
|
|
582
|
+
assumeInteractionOn: ['it-input'],
|
|
583
|
+
...options,
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
hostConnected() {
|
|
587
|
+
const form = this.options.form(this.host);
|
|
588
|
+
if (form) {
|
|
589
|
+
this.attachForm(form);
|
|
590
|
+
}
|
|
591
|
+
// Listen for interactions
|
|
592
|
+
interactions.set(this.host, []);
|
|
593
|
+
this.options.assumeInteractionOn.forEach((event) => {
|
|
594
|
+
this.host.addEventListener(event, this.handleInteraction);
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
hostDisconnected() {
|
|
598
|
+
this.detachForm();
|
|
599
|
+
// Clean up interactions
|
|
600
|
+
interactions.delete(this.host);
|
|
601
|
+
this.options.assumeInteractionOn.forEach((event) => {
|
|
602
|
+
this.host.removeEventListener(event, this.handleInteraction);
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
hostUpdated() {
|
|
606
|
+
const form = this.options.form(this.host);
|
|
607
|
+
// Detach if the form no longer exists
|
|
608
|
+
if (!form) {
|
|
609
|
+
this.detachForm();
|
|
610
|
+
}
|
|
611
|
+
// If the form has changed, reattach it
|
|
612
|
+
if (form && this.form !== form) {
|
|
613
|
+
this.detachForm();
|
|
614
|
+
this.attachForm(form);
|
|
615
|
+
}
|
|
616
|
+
if (this.host.hasUpdated) {
|
|
617
|
+
this.setValidity(this.host.validity.valid);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
attachForm(form) {
|
|
621
|
+
if (form) {
|
|
622
|
+
this.form = form;
|
|
623
|
+
// Add this element to the form's collection
|
|
624
|
+
if (formCollections.has(this.form)) {
|
|
625
|
+
formCollections.get(this.form).add(this.host);
|
|
626
|
+
}
|
|
627
|
+
else {
|
|
628
|
+
formCollections.set(this.form, new Set([this.host]));
|
|
629
|
+
}
|
|
630
|
+
this.form.addEventListener('formdata', this.handleFormData);
|
|
631
|
+
this.form.addEventListener('submit', this.handleFormSubmit);
|
|
632
|
+
this.form.addEventListener('reset', this.handleFormReset);
|
|
633
|
+
// Overload the form's reportValidity() method so it looks at FormControl
|
|
634
|
+
if (!reportValidityOverloads.has(this.form)) {
|
|
635
|
+
reportValidityOverloads.set(this.form, this.form.reportValidity);
|
|
636
|
+
this.form.reportValidity = () => this.reportFormValidity();
|
|
637
|
+
}
|
|
638
|
+
// Overload the form's checkValidity() method so it looks at FormControl
|
|
639
|
+
if (!checkValidityOverloads.has(this.form)) {
|
|
640
|
+
checkValidityOverloads.set(this.form, this.form.checkValidity);
|
|
641
|
+
this.form.checkValidity = () => this.checkFormValidity();
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
else {
|
|
645
|
+
this.form = undefined;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
detachForm() {
|
|
649
|
+
if (!this.form)
|
|
650
|
+
return;
|
|
651
|
+
const formCollection = formCollections.get(this.form);
|
|
652
|
+
if (!formCollection) {
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
// Remove this host from the form's collection
|
|
656
|
+
formCollection.delete(this.host);
|
|
657
|
+
// Check to make sure there's no other form controls in the collection. If we do this
|
|
658
|
+
// without checking if any other controls are still in the collection, then we will wipe out the
|
|
659
|
+
// validity checks for all other elements.
|
|
660
|
+
// see: https://github.com/shoelace-style/shoelace/issues/1703
|
|
661
|
+
if (formCollection.size <= 0) {
|
|
662
|
+
this.form.removeEventListener('formdata', this.handleFormData);
|
|
663
|
+
this.form.removeEventListener('submit', this.handleFormSubmit);
|
|
664
|
+
this.form.removeEventListener('reset', this.handleFormReset);
|
|
665
|
+
// Remove the overload and restore the original method
|
|
666
|
+
if (reportValidityOverloads.has(this.form)) {
|
|
667
|
+
this.form.reportValidity = reportValidityOverloads.get(this.form);
|
|
668
|
+
reportValidityOverloads.delete(this.form);
|
|
669
|
+
}
|
|
670
|
+
if (checkValidityOverloads.has(this.form)) {
|
|
671
|
+
this.form.checkValidity = checkValidityOverloads.get(this.form);
|
|
672
|
+
checkValidityOverloads.delete(this.form);
|
|
673
|
+
}
|
|
674
|
+
// So it looks weird here to not always set the form to undefined. But I _think_ if we unattach this.form here,
|
|
675
|
+
// we end up in this fun spot where future validity checks don't have a reference to the form validity handler.
|
|
676
|
+
// First form element in sets the validity handler. So we can't clean up `this.form` until there are no other form elements in the form.
|
|
677
|
+
this.form = undefined;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
// eslint-disable-next-line class-methods-use-this
|
|
681
|
+
setUserInteracted(el, hasInteracted) {
|
|
682
|
+
if (hasInteracted) {
|
|
683
|
+
userInteractedControls.add(el);
|
|
684
|
+
}
|
|
685
|
+
else {
|
|
686
|
+
userInteractedControls.delete(el);
|
|
687
|
+
}
|
|
688
|
+
el.requestUpdate();
|
|
689
|
+
}
|
|
690
|
+
doAction(type, submitter) {
|
|
691
|
+
// console.log('doaction', type);
|
|
692
|
+
if (this.form) {
|
|
693
|
+
const button = document.createElement('button');
|
|
694
|
+
button.type = type;
|
|
695
|
+
button.style.position = 'absolute';
|
|
696
|
+
button.style.width = '0';
|
|
697
|
+
button.style.height = '0';
|
|
698
|
+
button.style.clipPath = 'inset(50%)';
|
|
699
|
+
button.style.overflow = 'hidden';
|
|
700
|
+
button.style.whiteSpace = 'nowrap';
|
|
701
|
+
// Pass name, value, and form attributes through to the temporary button
|
|
702
|
+
if (submitter) {
|
|
703
|
+
button.name = submitter.name;
|
|
704
|
+
button.value = submitter.value;
|
|
705
|
+
['formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget'].forEach((attr) => {
|
|
706
|
+
if (submitter.hasAttribute(attr)) {
|
|
707
|
+
button.setAttribute(attr, submitter.getAttribute(attr));
|
|
708
|
+
}
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
this.form.append(button);
|
|
712
|
+
button.click();
|
|
713
|
+
button.remove();
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
/** Returns the associated `<form>` element, if one exists. */
|
|
717
|
+
getForm() {
|
|
718
|
+
return this.form ?? null;
|
|
719
|
+
}
|
|
720
|
+
/** Resets the form, restoring all the control to their default value */
|
|
721
|
+
reset(submitter) {
|
|
722
|
+
this.doAction('reset', submitter);
|
|
723
|
+
}
|
|
724
|
+
/** Submits the form, triggering validation and form data injection. */
|
|
725
|
+
submit(submitter) {
|
|
726
|
+
// Calling form.submit() bypasses the submit event and constraint validation. To prevent this, we can inject a
|
|
727
|
+
// native submit button into the form, "click" it, then remove it to simulate a standard form submission.
|
|
728
|
+
this.doAction('submit', submitter);
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Synchronously sets the form control's validity. Call this when you know the future validity but need to update
|
|
732
|
+
* the host element immediately, i.e. before Lit updates the component in the next update.
|
|
733
|
+
*/
|
|
734
|
+
setValidity(isValid) {
|
|
735
|
+
const host = this.host;
|
|
736
|
+
const hasInteracted = Boolean(userInteractedControls.has(host));
|
|
737
|
+
const required = Boolean(host.required);
|
|
738
|
+
//
|
|
739
|
+
// We're mapping the following "states" to data attributes. In the future, we can use ElementInternals.states to
|
|
740
|
+
// create a similar mapping, but instead of [data-invalid] it will look like :--invalid.
|
|
741
|
+
//
|
|
742
|
+
// See this RFC for more details: https://github.com/shoelace-style/shoelace/issues/1011
|
|
743
|
+
//
|
|
744
|
+
host.toggleAttribute('data-required', required);
|
|
745
|
+
host.toggleAttribute('data-optional', !required);
|
|
746
|
+
host.toggleAttribute('data-invalid', !isValid);
|
|
747
|
+
host.toggleAttribute('data-valid', isValid);
|
|
748
|
+
host.toggleAttribute('data-user-invalid', !isValid && hasInteracted);
|
|
749
|
+
host.toggleAttribute('data-user-valid', isValid && hasInteracted);
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Updates the form control's validity based on the current value of `host.validity.valid`. Call this when anything
|
|
753
|
+
* that affects constraint validation changes so the component receives the correct validity states.
|
|
754
|
+
*/
|
|
755
|
+
updateValidity() {
|
|
756
|
+
const host = this.host;
|
|
757
|
+
this.setValidity(host.validity.valid);
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Dispatches a non-bubbling, cancelable custom event of type `it-invalid`.
|
|
761
|
+
* If the `it-invalid` event will be cancelled then the original `invalid`
|
|
762
|
+
* event (which may have been passed as argument) will also be cancelled.
|
|
763
|
+
* If no original `invalid` event has been passed then the `it-invalid`
|
|
764
|
+
* event will be cancelled before being dispatched.
|
|
765
|
+
*/
|
|
766
|
+
emitInvalidEvent(originalInvalidEvent) {
|
|
767
|
+
const itInvalidEvent = new CustomEvent('it-invalid', {
|
|
768
|
+
bubbles: false,
|
|
769
|
+
composed: false,
|
|
770
|
+
cancelable: true,
|
|
771
|
+
detail: {},
|
|
772
|
+
});
|
|
773
|
+
if (!originalInvalidEvent) {
|
|
774
|
+
itInvalidEvent.preventDefault();
|
|
775
|
+
}
|
|
776
|
+
if (!this.host.dispatchEvent(itInvalidEvent)) {
|
|
777
|
+
originalInvalidEvent?.preventDefault();
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
const translation$1 = {
|
|
783
|
+
$code: 'it',
|
|
784
|
+
$name: 'Italiano',
|
|
785
|
+
$dir: 'ltr',
|
|
786
|
+
validityRequired: 'Questo campo è obbligatorio.',
|
|
787
|
+
validityPattern: 'Il valore non corrisponde al formato richiesto.',
|
|
788
|
+
validityMinlength: 'Il valore deve essere lungo almeno {minlength} caratteri.',
|
|
789
|
+
validityMaxlength: 'Il valore deve essere lungo al massimo {maxlength} caratteri.',
|
|
790
|
+
};
|
|
791
|
+
|
|
792
|
+
registerTranslation(translation$1);
|
|
793
|
+
class FormControl extends BaseLocalizedComponent {
|
|
794
|
+
constructor() {
|
|
795
|
+
super(...arguments);
|
|
796
|
+
this.formControlController = new FormControlController(this, {
|
|
797
|
+
assumeInteractionOn: ['it-input', 'it-blur', 'it-change'],
|
|
798
|
+
});
|
|
799
|
+
// TODO: verificare se serve davvero con il fatto che usiamo form-controller
|
|
800
|
+
// static formAssociated = true;
|
|
801
|
+
// @property()
|
|
802
|
+
// internals = this.attachInternals();
|
|
803
|
+
this._touched = false;
|
|
804
|
+
/** The name of the input, submitted as a name/value pair with form data. */
|
|
805
|
+
this.name = '';
|
|
806
|
+
/** The current value of the input, submitted as a name/value pair with form data. */
|
|
807
|
+
this.value = '';
|
|
808
|
+
/** If the input is disabled. */
|
|
809
|
+
this.disabled = false;
|
|
810
|
+
/**
|
|
811
|
+
* By default, form controls are associated with the nearest containing `<form>` element. This attribute allows you
|
|
812
|
+
* to place the form control outside of a form and associate it with the form that has this `id`. The form must be in
|
|
813
|
+
* the same document or shadow root for this to work.
|
|
814
|
+
*/
|
|
815
|
+
this.form = '';
|
|
816
|
+
/** If you implement your custom validation and you won't to trigger default validation */
|
|
817
|
+
this.customValidation = false;
|
|
818
|
+
/** If your input is invalid from your custom validition, set this attribute with message validation */
|
|
819
|
+
this.validationText = '';
|
|
820
|
+
/**
|
|
821
|
+
* Specifies the granularity that the value must adhere to, or the special value `any` which means no stepping is
|
|
822
|
+
* implied, allowing any numeric value. Only applies to date and number input types.
|
|
823
|
+
*/
|
|
824
|
+
this.step = 'any';
|
|
825
|
+
/** The input's minimum length. */
|
|
826
|
+
this.minlength = -1;
|
|
827
|
+
/** The input's maximum length. */
|
|
828
|
+
this.maxlength = -1;
|
|
829
|
+
/** If the input is required. */
|
|
830
|
+
this.required = false;
|
|
831
|
+
this.validationMessage = '';
|
|
832
|
+
}
|
|
833
|
+
/** Gets the validity state object */
|
|
834
|
+
get validity() {
|
|
835
|
+
return this.inputElement?.validity;
|
|
836
|
+
}
|
|
837
|
+
// Form validation methods
|
|
838
|
+
checkValidity() {
|
|
839
|
+
const inputValid = this.inputElement?.checkValidity() ?? true; // this.inputElement.checkValidity() è la validazione del browser
|
|
840
|
+
return inputValid;
|
|
841
|
+
}
|
|
842
|
+
/** Gets the associated form, if one exists. */
|
|
843
|
+
getForm() {
|
|
844
|
+
return this.formControlController.getForm();
|
|
845
|
+
}
|
|
846
|
+
/** Checks for validity and shows the browser's validation message if the control is invalid. */
|
|
847
|
+
reportValidity() {
|
|
848
|
+
const ret = this.inputElement.checkValidity();
|
|
849
|
+
this.handleValidationMessages();
|
|
850
|
+
return ret; // this.inputElement.reportValidity();
|
|
851
|
+
}
|
|
852
|
+
/** Sets a custom validation message. Pass an empty string to restore validity. */
|
|
853
|
+
setCustomValidity(message) {
|
|
854
|
+
this.inputElement.setCustomValidity(message);
|
|
855
|
+
this.validationMessage = this.inputElement.validationMessage;
|
|
856
|
+
this.formControlController.updateValidity();
|
|
857
|
+
}
|
|
858
|
+
// Handlers
|
|
859
|
+
_handleReady() {
|
|
860
|
+
requestAnimationFrame(() => {
|
|
861
|
+
this.dispatchEvent(new CustomEvent('it-input-ready', { bubbles: true, detail: { el: this.inputElement } }));
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
865
|
+
_handleInput(e) {
|
|
866
|
+
this.handleValidationMessages();
|
|
867
|
+
this.dispatchEvent(new CustomEvent('it-input', {
|
|
868
|
+
detail: { value: this.inputElement.value, el: this.inputElement },
|
|
869
|
+
bubbles: true,
|
|
870
|
+
composed: true,
|
|
871
|
+
}));
|
|
872
|
+
}
|
|
873
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
874
|
+
_handleBlur(e) {
|
|
875
|
+
this._touched = true;
|
|
876
|
+
this.handleValidationMessages();
|
|
877
|
+
this.dispatchEvent(new FocusEvent('it-blur', { bubbles: true, composed: true }));
|
|
878
|
+
}
|
|
879
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
880
|
+
_handleFocus(e) {
|
|
881
|
+
this.dispatchEvent(new FocusEvent('it-focus', { bubbles: true, composed: true }));
|
|
882
|
+
}
|
|
883
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
884
|
+
_handleClick(e) {
|
|
885
|
+
this.dispatchEvent(new MouseEvent('it-click', { bubbles: true, composed: true }));
|
|
886
|
+
}
|
|
887
|
+
/*
|
|
888
|
+
Override default browser validation messages
|
|
889
|
+
*/
|
|
890
|
+
handleValidationMessages() {
|
|
891
|
+
if (!this.customValidation) {
|
|
892
|
+
const _v = this.inputElement.validity;
|
|
893
|
+
if (_v.valueMissing) {
|
|
894
|
+
this.setCustomValidity(this.$t('validityRequired'));
|
|
895
|
+
}
|
|
896
|
+
else if (_v.patternMismatch) {
|
|
897
|
+
this.setCustomValidity(this.$t('validityPattern'));
|
|
898
|
+
}
|
|
899
|
+
else if (_v.tooShort) {
|
|
900
|
+
this.setCustomValidity(this.$t('validityMinlength').replace('{minlength}', this.minlength.toString()));
|
|
901
|
+
}
|
|
902
|
+
else if (_v.tooLong) {
|
|
903
|
+
this.setCustomValidity(this.$t('validityMaxlength').replace('{maxlength}', this.maxlength.toString()));
|
|
904
|
+
}
|
|
905
|
+
else {
|
|
906
|
+
/* nothing. Usa il messaggio di errore della validazione
|
|
907
|
+
di default del browser per altri errori di validità come:
|
|
908
|
+
- typeMismatch
|
|
909
|
+
- rangeUnderflow
|
|
910
|
+
- rangeOverflow
|
|
911
|
+
- stepMismatch
|
|
912
|
+
- badInput */
|
|
913
|
+
const otherConstraintErrors = _v.typeMismatch || _v.rangeUnderflow || _v.rangeOverflow || _v.stepMismatch || _v.badInput;
|
|
914
|
+
if (!otherConstraintErrors) {
|
|
915
|
+
this.setCustomValidity('');
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
this.validationMessage = this.inputElement.validationMessage;
|
|
920
|
+
}
|
|
921
|
+
_handleInvalid(event) {
|
|
922
|
+
this.formControlController.setValidity(false);
|
|
923
|
+
this.formControlController.emitInvalidEvent(event);
|
|
924
|
+
}
|
|
925
|
+
_handleChange(e) {
|
|
926
|
+
const target = e.target;
|
|
927
|
+
let value;
|
|
928
|
+
if (target instanceof HTMLInputElement) {
|
|
929
|
+
switch (target.type) {
|
|
930
|
+
case 'checkbox':
|
|
931
|
+
case 'radio':
|
|
932
|
+
value = target.checked;
|
|
933
|
+
break;
|
|
934
|
+
case 'file':
|
|
935
|
+
value = target.files; // FileList
|
|
936
|
+
break;
|
|
937
|
+
default:
|
|
938
|
+
value = target.value;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
else if (target instanceof HTMLSelectElement) {
|
|
942
|
+
if (target.multiple) {
|
|
943
|
+
value = Array.from(target.selectedOptions).map((o) => o.value);
|
|
944
|
+
}
|
|
945
|
+
else {
|
|
946
|
+
value = target.value;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
else {
|
|
950
|
+
// textarea o altri input con value
|
|
951
|
+
value = target.value;
|
|
952
|
+
}
|
|
953
|
+
this.dispatchEvent(new CustomEvent('it-change', {
|
|
954
|
+
detail: { value, el: target },
|
|
955
|
+
bubbles: true,
|
|
956
|
+
composed: true,
|
|
957
|
+
}));
|
|
958
|
+
}
|
|
959
|
+
updated(changedProperties) {
|
|
960
|
+
super.updated?.(changedProperties);
|
|
961
|
+
if (this.customValidation) {
|
|
962
|
+
this.setCustomValidity(this.validationText ?? '');
|
|
963
|
+
}
|
|
964
|
+
else {
|
|
965
|
+
this.formControlController.updateValidity();
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
__decorate([
|
|
970
|
+
state(),
|
|
971
|
+
__metadata("design:type", Object)
|
|
972
|
+
], FormControl.prototype, "_touched", void 0);
|
|
973
|
+
__decorate([
|
|
974
|
+
query('.it-form__control'),
|
|
975
|
+
__metadata("design:type", HTMLInputElement)
|
|
976
|
+
], FormControl.prototype, "inputElement", void 0);
|
|
977
|
+
__decorate([
|
|
978
|
+
property({ type: String, reflect: true }) // from FormControl
|
|
979
|
+
,
|
|
980
|
+
__metadata("design:type", Object)
|
|
981
|
+
], FormControl.prototype, "name", void 0);
|
|
982
|
+
__decorate([
|
|
983
|
+
property({ reflect: true }),
|
|
984
|
+
__metadata("design:type", Object)
|
|
985
|
+
], FormControl.prototype, "value", void 0);
|
|
986
|
+
__decorate([
|
|
987
|
+
property({ type: Boolean, reflect: true }) // from FormControl
|
|
988
|
+
,
|
|
989
|
+
__metadata("design:type", Object)
|
|
990
|
+
], FormControl.prototype, "disabled", void 0);
|
|
991
|
+
__decorate([
|
|
992
|
+
property({ reflect: true, type: String }),
|
|
993
|
+
__metadata("design:type", Object)
|
|
994
|
+
], FormControl.prototype, "form", void 0);
|
|
995
|
+
__decorate([
|
|
996
|
+
property({ type: Boolean, reflect: true, attribute: 'custom-validation' }),
|
|
997
|
+
__metadata("design:type", Object)
|
|
998
|
+
], FormControl.prototype, "customValidation", void 0);
|
|
999
|
+
__decorate([
|
|
1000
|
+
property({ attribute: 'validity-message', reflect: true }),
|
|
1001
|
+
__metadata("design:type", String)
|
|
1002
|
+
], FormControl.prototype, "validationText", void 0);
|
|
1003
|
+
__decorate([
|
|
1004
|
+
property(),
|
|
1005
|
+
__metadata("design:type", String)
|
|
1006
|
+
], FormControl.prototype, "pattern", void 0);
|
|
1007
|
+
__decorate([
|
|
1008
|
+
property(),
|
|
1009
|
+
__metadata("design:type", Object)
|
|
1010
|
+
], FormControl.prototype, "min", void 0);
|
|
1011
|
+
__decorate([
|
|
1012
|
+
property(),
|
|
1013
|
+
__metadata("design:type", Object)
|
|
1014
|
+
], FormControl.prototype, "max", void 0);
|
|
1015
|
+
__decorate([
|
|
1016
|
+
property(),
|
|
1017
|
+
__metadata("design:type", Object)
|
|
1018
|
+
], FormControl.prototype, "step", void 0);
|
|
1019
|
+
__decorate([
|
|
1020
|
+
property({ type: Number }),
|
|
1021
|
+
__metadata("design:type", Object)
|
|
1022
|
+
], FormControl.prototype, "minlength", void 0);
|
|
1023
|
+
__decorate([
|
|
1024
|
+
property({ type: Number }),
|
|
1025
|
+
__metadata("design:type", Object)
|
|
1026
|
+
], FormControl.prototype, "maxlength", void 0);
|
|
1027
|
+
__decorate([
|
|
1028
|
+
property({ type: Boolean, reflect: true }) // from FormControl
|
|
1029
|
+
,
|
|
1030
|
+
__metadata("design:type", Object)
|
|
1031
|
+
], FormControl.prototype, "required", void 0);
|
|
1032
|
+
__decorate([
|
|
1033
|
+
state(),
|
|
1034
|
+
__metadata("design:type", Object)
|
|
1035
|
+
], FormControl.prototype, "validationMessage", void 0);
|
|
1036
|
+
|
|
608
1037
|
/**
|
|
609
1038
|
* Checks for repetition of characters in
|
|
610
1039
|
* a string
|
|
@@ -778,11 +1207,8 @@ const translation = {
|
|
|
778
1207
|
passwordSuggestionFollowedPlural: 'suggerimenti seguiti',
|
|
779
1208
|
passwordSuggestionOf: 'di',
|
|
780
1209
|
passwordSuggestionMetLabel: 'Soddisfatto:',
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
validityPattern: 'Il valore non corrisponde al formato richiesto.',
|
|
784
|
-
validityMinlength: 'Il valore deve essere lungo almeno {minlength} caratteri.',
|
|
785
|
-
validityMaxlength: 'Il valore deve essere lungo al massimo {maxlength} caratteri.',
|
|
1210
|
+
increaseValue: 'Aumenta il valore',
|
|
1211
|
+
decreaseValue: 'Diminuisci il valore',
|
|
786
1212
|
};
|
|
787
1213
|
|
|
788
1214
|
var styles = css`@charset "UTF-8";
|
|
@@ -911,9 +1337,8 @@ a {
|
|
|
911
1337
|
text-decoration-skip-ink: auto;
|
|
912
1338
|
text-underline-offset: 2px;
|
|
913
1339
|
}
|
|
914
|
-
a:hover
|
|
1340
|
+
a:hover {
|
|
915
1341
|
color: var(--bs-color-link-hover);
|
|
916
|
-
text-decoration: underline;
|
|
917
1342
|
}
|
|
918
1343
|
|
|
919
1344
|
a:not([href]):not([class]), a:not([href]):not([class]):hover {
|
|
@@ -1051,23 +1476,6 @@ fieldset {
|
|
|
1051
1476
|
border: 0;
|
|
1052
1477
|
}
|
|
1053
1478
|
|
|
1054
|
-
legend {
|
|
1055
|
-
float: left;
|
|
1056
|
-
width: 100%;
|
|
1057
|
-
padding: 0;
|
|
1058
|
-
margin-bottom: 0.5rem;
|
|
1059
|
-
font-size: calc(1.275rem + 0.3vw);
|
|
1060
|
-
line-height: inherit;
|
|
1061
|
-
}
|
|
1062
|
-
@media (min-width: 1200px) {
|
|
1063
|
-
legend {
|
|
1064
|
-
font-size: 1.5rem;
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
legend + * {
|
|
1068
|
-
clear: left;
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
1479
|
::-webkit-datetime-edit-fields-wrapper,
|
|
1072
1480
|
::-webkit-datetime-edit-text,
|
|
1073
1481
|
::-webkit-datetime-edit-minute,
|
|
@@ -1417,13 +1825,51 @@ a.btn-outline-danger:active {
|
|
|
1417
1825
|
.bg-dark .btn-link {
|
|
1418
1826
|
--bs-btn-text-color: var(--bs-color-text-inverse);
|
|
1419
1827
|
}
|
|
1828
|
+
.bg-dark a.btn-primary,
|
|
1829
|
+
.bg-dark .btn-primary {
|
|
1830
|
+
--bs-btn-text-color: var(--bs-color-text-primary);
|
|
1831
|
+
--bs-btn-background: var(--bs-color-background-inverse);
|
|
1832
|
+
}
|
|
1833
|
+
.bg-dark a.btn-primary:hover,
|
|
1834
|
+
.bg-dark .btn-primary:hover {
|
|
1835
|
+
--bs-btn-background: color-mix(in srgb, var(--bs-color-background-inverse) 85%, black);
|
|
1836
|
+
}
|
|
1837
|
+
.bg-dark a.btn-primary:active,
|
|
1838
|
+
.bg-dark .btn-primary:active {
|
|
1839
|
+
--bs-btn-background: color-mix(in srgb, var(--bs-color-background-inverse) 80%, black);
|
|
1840
|
+
}
|
|
1841
|
+
.bg-dark a.btn-secondary,
|
|
1842
|
+
.bg-dark .btn-secondary {
|
|
1843
|
+
--bs-btn-text-color: var(--bs-color-text-inverse);
|
|
1844
|
+
--bs-btn-background: var(--bs-color-background-secondary);
|
|
1845
|
+
}
|
|
1846
|
+
.bg-dark a.btn-secondary:hover, .bg-dark a.btn-secondary:active,
|
|
1847
|
+
.bg-dark .btn-secondary:hover,
|
|
1848
|
+
.bg-dark .btn-secondary:active {
|
|
1849
|
+
--bs-btn-background: color-mix(in srgb, var(--bs-color-background-secondary) 85%, black);
|
|
1850
|
+
}
|
|
1420
1851
|
.bg-dark .btn-outline-primary,
|
|
1421
|
-
.bg-dark a.btn-outline-primary
|
|
1852
|
+
.bg-dark a.btn-outline-primary {
|
|
1853
|
+
--bs-btn-outline-border-color: var(--bs-color-border-inverse);
|
|
1854
|
+
--bs-btn-text-color: var(--bs-color-text-inverse);
|
|
1855
|
+
}
|
|
1856
|
+
.bg-dark .btn-outline-primary:hover,
|
|
1857
|
+
.bg-dark a.btn-outline-primary:hover {
|
|
1858
|
+
--bs-btn-boxshadow-color-darken: color-mix(in srgb, var(--bs-color-border-inverse) 80%, black);
|
|
1859
|
+
--bs-btn-boxshadow-color-desaturated: color-mix(in srgb, var(--bs-btn-boxshadow-color-darken) 80%, gray);
|
|
1860
|
+
--bs-btn-outline-border-color: var(--bs-btn-boxshadow-color-desaturated);
|
|
1861
|
+
}
|
|
1422
1862
|
.bg-dark .btn-outline-secondary,
|
|
1423
1863
|
.bg-dark a.btn-outline-secondary {
|
|
1424
|
-
--bs-btn-outline-border-color: var(--bs-color-border-inverse);
|
|
1425
1864
|
--bs-btn-text-color: var(--bs-color-text-inverse);
|
|
1426
1865
|
}
|
|
1866
|
+
.bg-dark .btn-outline-secondary:hover, .bg-dark .btn-outline-secondary:active,
|
|
1867
|
+
.bg-dark a.btn-outline-secondary:hover,
|
|
1868
|
+
.bg-dark a.btn-outline-secondary:active {
|
|
1869
|
+
--bs-btn-boxshadow-color-darken: color-mix(in srgb, var(--bs-color-background-secondary) 80%, black);
|
|
1870
|
+
--bs-btn-boxshadow-color-desaturated: color-mix(in srgb, var(--bs-btn-boxshadow-color-darken) 80%, gray);
|
|
1871
|
+
--bs-btn-outline-border-color: var(--bs-btn-boxshadow-color-desaturated);
|
|
1872
|
+
}
|
|
1427
1873
|
|
|
1428
1874
|
.btn-close {
|
|
1429
1875
|
position: relative;
|
|
@@ -3208,8 +3654,8 @@ blockquote.blockquote-card.dark .blockquote-footer,
|
|
|
3208
3654
|
--bs-form-control-border-color: var(--bs-color-border-secondary);
|
|
3209
3655
|
--bs-form-control-border-radius: var(--bs-radius-smooth);
|
|
3210
3656
|
--bs-form-control-placeholder-color: var(--bs-color-text-muted);
|
|
3211
|
-
--bs-form-control-label-color: var(--bs-color-text-
|
|
3212
|
-
--bs-form-control-text-color: var(--bs-color-text-
|
|
3657
|
+
--bs-form-control-label-color: var(--bs-color-text-base);
|
|
3658
|
+
--bs-form-control-text-color: var(--bs-color-text-secondary);
|
|
3213
3659
|
--bs-form-control-font-size: var(--bs-body-font-size);
|
|
3214
3660
|
--bs-form-group-spacing-y: var(--bs-spacing-m);
|
|
3215
3661
|
--bs-form-checkbox-border-color: var(--bs-color-border-secondary);
|
|
@@ -3353,20 +3799,12 @@ input[type=time] {
|
|
|
3353
3799
|
}
|
|
3354
3800
|
|
|
3355
3801
|
fieldset legend {
|
|
3356
|
-
|
|
3357
|
-
display: block;
|
|
3358
|
-
width: auto;
|
|
3359
|
-
max-width: 100%;
|
|
3360
|
-
margin-bottom: 0;
|
|
3802
|
+
margin-bottom: var(--bs-spacing-s);
|
|
3361
3803
|
padding: 0 var(--bs-form-input-spacing-x);
|
|
3362
|
-
float: none;
|
|
3363
3804
|
background-color: transparent;
|
|
3364
|
-
color: var(--bs-form-
|
|
3365
|
-
font-size:
|
|
3366
|
-
font-weight:
|
|
3367
|
-
line-height: calc(2.5rem - 1px);
|
|
3368
|
-
transition: 0.2s ease-out;
|
|
3369
|
-
cursor: text;
|
|
3805
|
+
color: var(--bs-form-control-text-color);
|
|
3806
|
+
font-size: var(--bs-label-sm);
|
|
3807
|
+
font-weight: var(--bs-font-weight-solid);
|
|
3370
3808
|
}
|
|
3371
3809
|
|
|
3372
3810
|
::placeholder {
|
|
@@ -3432,8 +3870,8 @@ input::-webkit-datetime-edit {
|
|
|
3432
3870
|
|
|
3433
3871
|
.form-check {
|
|
3434
3872
|
position: relative;
|
|
3435
|
-
margin-bottom: var(--bs-spacing-s);
|
|
3436
3873
|
padding-left: 0;
|
|
3874
|
+
align-items: center;
|
|
3437
3875
|
}
|
|
3438
3876
|
.form-check + .form-check {
|
|
3439
3877
|
margin-top: var(--bs-spacing-s);
|
|
@@ -3451,11 +3889,11 @@ input::-webkit-datetime-edit {
|
|
|
3451
3889
|
position: relative;
|
|
3452
3890
|
display: flex;
|
|
3453
3891
|
align-items: center;
|
|
3454
|
-
padding-left:
|
|
3892
|
+
padding-left: 28px;
|
|
3455
3893
|
font-size: var(--bs-label-font-size);
|
|
3456
3894
|
font-weight: var(--bs-font-weight-solid);
|
|
3457
|
-
line-height: 1;
|
|
3458
3895
|
cursor: pointer;
|
|
3896
|
+
margin-bottom: 0;
|
|
3459
3897
|
user-select: none;
|
|
3460
3898
|
}
|
|
3461
3899
|
@media (min-width: 576px) {
|
|
@@ -3536,7 +3974,7 @@ input::-webkit-datetime-edit {
|
|
|
3536
3974
|
transition: all var(--bs-transition-instant) ease-out;
|
|
3537
3975
|
}
|
|
3538
3976
|
.form-check input[type=radio]:not(:checked) + label::after, .form-check input[type=radio]:not(:checked) + label::before {
|
|
3539
|
-
border-color: var(
|
|
3977
|
+
border-color: var(--bs-form-checkbox-border-color);
|
|
3540
3978
|
}
|
|
3541
3979
|
.form-check input[type=radio]:not(:checked) + label:after {
|
|
3542
3980
|
z-index: -1;
|
|
@@ -3614,6 +4052,13 @@ input::-webkit-datetime-edit {
|
|
|
3614
4052
|
background-color: var(--bs-form-checked-color);
|
|
3615
4053
|
}
|
|
3616
4054
|
|
|
4055
|
+
.form-check-inline {
|
|
4056
|
+
display: inline-block;
|
|
4057
|
+
}
|
|
4058
|
+
.form-check-inline:not(:last-child) {
|
|
4059
|
+
margin-right: var(--bs-spacing-m);
|
|
4060
|
+
}
|
|
4061
|
+
|
|
3617
4062
|
@media (prefers-reduced-motion: reduce) {
|
|
3618
4063
|
fieldset legend,
|
|
3619
4064
|
.form-group label,
|
|
@@ -3677,9 +4122,6 @@ input::-webkit-datetime-edit {
|
|
|
3677
4122
|
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23cc334d' viewBox='0 0 384 512'%3E%3Cpath d='M231.6 256l130.1-130.1c4.7-4.7 4.7-12.3 0-17l-22.6-22.6c-4.7-4.7-12.3-4.7-17 0L192 216.4 61.9 86.3c-4.7-4.7-12.3-4.7-17 0l-22.6 22.6c-4.7 4.7-4.7 12.3 0 17L152.4 256 22.3 386.1c-4.7 4.7-4.7 12.3 0 17l22.6 22.6c4.7 4.7 12.3 4.7 17 0L192 295.6l130.1 130.1c4.7 4.7 12.3 4.7 17 0l22.6-22.6c4.7-4.7 4.7-12.3 0-17L231.6 256z'/%3E%3C/svg%3E");
|
|
3678
4123
|
border-color: var(--bs-color-border-danger);
|
|
3679
4124
|
}
|
|
3680
|
-
.was-validated .form-control:invalid[type=number], .form-control.is-invalid[type=number] {
|
|
3681
|
-
background-size: 80px 30%;
|
|
3682
|
-
}
|
|
3683
4125
|
.form-control.warning {
|
|
3684
4126
|
background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%0A%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M2%2012C2%206.47715%206.47715%202%2012%202C14.6522%202%2017.1957%203.05357%2019.0711%204.92893C20.9464%206.8043%2022%209.34784%2022%2012C22%2017.5228%2017.5228%2022%2012%2022C6.47715%2022%202%2017.5228%202%2012ZM3%2012C3%2016.9706%207.02944%2021%2012%2021C16.9706%2021%2021%2016.9706%2021%2012C21%207.02944%2016.9706%203%2012%203C7.02944%203%203%207.02944%203%2012ZM11.5%2014.2V5.7H12.7V14.2H11.5ZM12.6%2018.3V16.5H11.4V18.3H12.6Z%22/%3E%0A%3C/svg%3E") no-repeat;
|
|
3685
4127
|
border-color: var(--bs-color-border-warning);
|
|
@@ -3771,6 +4213,106 @@ textarea.form-control-lg {
|
|
|
3771
4213
|
display: block;
|
|
3772
4214
|
}
|
|
3773
4215
|
|
|
4216
|
+
.input-number {
|
|
4217
|
+
position: relative;
|
|
4218
|
+
}
|
|
4219
|
+
.input-number.input-number-adaptive {
|
|
4220
|
+
width: fit-content;
|
|
4221
|
+
}
|
|
4222
|
+
.input-number.input-number-adaptive input[type=number] {
|
|
4223
|
+
width: auto;
|
|
4224
|
+
transition: all va(--bs-transition-instant);
|
|
4225
|
+
}
|
|
4226
|
+
.input-number input[type=number] {
|
|
4227
|
+
appearance: textfield;
|
|
4228
|
+
border-top-right-radius: var(--bs-form-control-border-radius) !important;
|
|
4229
|
+
border-bottom-right-radius: var(--bs-form-control-border-radius) !important;
|
|
4230
|
+
}
|
|
4231
|
+
.input-number input[type=number]::-webkit-inner-spin-button, .input-number input[type=number]::-webkit-outer-spin-button {
|
|
4232
|
+
-webkit-appearance: none;
|
|
4233
|
+
}
|
|
4234
|
+
.input-number input[type=number]::-ms-clear {
|
|
4235
|
+
display: none;
|
|
4236
|
+
}
|
|
4237
|
+
.input-number input[type=number]:not(:disabled) {
|
|
4238
|
+
border-left: 1px solid var(--bs-form-control-border-color);
|
|
4239
|
+
}
|
|
4240
|
+
.input-number input[type=number][readonly] ~ .input-group-text .input-number-add,
|
|
4241
|
+
.input-number input[type=number][readonly] ~ .input-group-text .input-number-sub {
|
|
4242
|
+
display: none;
|
|
4243
|
+
}
|
|
4244
|
+
.input-number.disabled button {
|
|
4245
|
+
display: none;
|
|
4246
|
+
pointer-events: none;
|
|
4247
|
+
}
|
|
4248
|
+
.input-number.disabled button:hover {
|
|
4249
|
+
cursor: not-allowed;
|
|
4250
|
+
}
|
|
4251
|
+
.input-number .input-group-text.align-buttons {
|
|
4252
|
+
position: absolute;
|
|
4253
|
+
top: 0;
|
|
4254
|
+
bottom: 0;
|
|
4255
|
+
right: 0;
|
|
4256
|
+
z-index: 10;
|
|
4257
|
+
padding-right: var(--bs-form-control-spacing);
|
|
4258
|
+
border: none;
|
|
4259
|
+
background: transparent;
|
|
4260
|
+
}
|
|
4261
|
+
.is-invalid + .input-number .input-group-text.align-buttons {
|
|
4262
|
+
bottom: 0;
|
|
4263
|
+
}
|
|
4264
|
+
.input-number .input-group-text button {
|
|
4265
|
+
position: relative;
|
|
4266
|
+
transition: opacity 0.1s;
|
|
4267
|
+
padding: 0;
|
|
4268
|
+
border: none;
|
|
4269
|
+
height: 50%;
|
|
4270
|
+
width: 16px;
|
|
4271
|
+
background: transparent;
|
|
4272
|
+
}
|
|
4273
|
+
.input-number .input-group-text button:after {
|
|
4274
|
+
position: absolute;
|
|
4275
|
+
top: 50%;
|
|
4276
|
+
left: 50%;
|
|
4277
|
+
transform: translateX(-50%) translateY(-50%);
|
|
4278
|
+
content: "";
|
|
4279
|
+
width: 0;
|
|
4280
|
+
height: 0;
|
|
4281
|
+
border-style: solid;
|
|
4282
|
+
}
|
|
4283
|
+
.input-number .input-group-text button:focus.input-number-add:after, .input-number .input-group-text button:hover.input-number-add:after {
|
|
4284
|
+
border-color: transparent transparent hsl(210, 54%, 20%) transparent;
|
|
4285
|
+
}
|
|
4286
|
+
.input-number .input-group-text button:focus.input-number-sub:after, .input-number .input-group-text button:hover.input-number-sub:after {
|
|
4287
|
+
border-color: hsl(210, 54%, 20%) transparent transparent transparent;
|
|
4288
|
+
}
|
|
4289
|
+
.input-number .input-group-text button:focus:not([data-focus-mouse=true]) {
|
|
4290
|
+
opacity: 1;
|
|
4291
|
+
}
|
|
4292
|
+
.input-number .input-group-text button.input-number-add:after {
|
|
4293
|
+
border-width: 0 5px 6px 5px;
|
|
4294
|
+
border-color: transparent transparent hsl(210, 17.6470588235%, 43.35%) transparent;
|
|
4295
|
+
}
|
|
4296
|
+
.input-number .input-group-text button.input-number-sub:after {
|
|
4297
|
+
border-width: 6px 5px 0 5px;
|
|
4298
|
+
border-color: hsl(210, 17.6470588235%, 43.35%) transparent transparent transparent;
|
|
4299
|
+
}
|
|
4300
|
+
.input-number .input-group-text button:hover {
|
|
4301
|
+
cursor: pointer;
|
|
4302
|
+
}
|
|
4303
|
+
|
|
4304
|
+
.input-number .input-group-text + input[type=number] {
|
|
4305
|
+
border-left: 0;
|
|
4306
|
+
}
|
|
4307
|
+
|
|
4308
|
+
@media (min-width: 1200px) {
|
|
4309
|
+
.input-number button {
|
|
4310
|
+
opacity: 0;
|
|
4311
|
+
}
|
|
4312
|
+
.input-number:hover button {
|
|
4313
|
+
opacity: 1;
|
|
4314
|
+
}
|
|
4315
|
+
}
|
|
3774
4316
|
.input-group {
|
|
3775
4317
|
position: relative;
|
|
3776
4318
|
display: flex;
|
|
@@ -3919,9 +4461,9 @@ textarea.just-validate-success-field {
|
|
|
3919
4461
|
border-bottom-width: 1px;
|
|
3920
4462
|
}
|
|
3921
4463
|
|
|
3922
|
-
input[type=checkbox].
|
|
3923
|
-
input[type=radio].
|
|
3924
|
-
color: var(--bs-color-
|
|
4464
|
+
input[type=checkbox].is-invalid,
|
|
4465
|
+
input[type=radio].is-invalid {
|
|
4466
|
+
--bs-form-checkbox-border-color: var(--bs-color-border-danger);
|
|
3925
4467
|
}
|
|
3926
4468
|
|
|
3927
4469
|
select.is-invalid {
|
|
@@ -4108,6 +4650,10 @@ select.just-validate-success-field {
|
|
|
4108
4650
|
display: none !important;
|
|
4109
4651
|
}
|
|
4110
4652
|
|
|
4653
|
+
.flex-column {
|
|
4654
|
+
flex-direction: column !important;
|
|
4655
|
+
}
|
|
4656
|
+
|
|
4111
4657
|
@media (min-width: 576px) {
|
|
4112
4658
|
.m-sm-0 {
|
|
4113
4659
|
margin: 0 !important;
|
|
@@ -4115,6 +4661,9 @@ select.just-validate-success-field {
|
|
|
4115
4661
|
.d-sm-none {
|
|
4116
4662
|
display: none !important;
|
|
4117
4663
|
}
|
|
4664
|
+
.flex-sm-column {
|
|
4665
|
+
flex-direction: column !important;
|
|
4666
|
+
}
|
|
4118
4667
|
}
|
|
4119
4668
|
@media (min-width: 768px) {
|
|
4120
4669
|
.m-md-0 {
|
|
@@ -4123,6 +4672,9 @@ select.just-validate-success-field {
|
|
|
4123
4672
|
.d-md-none {
|
|
4124
4673
|
display: none !important;
|
|
4125
4674
|
}
|
|
4675
|
+
.flex-md-column {
|
|
4676
|
+
flex-direction: column !important;
|
|
4677
|
+
}
|
|
4126
4678
|
}
|
|
4127
4679
|
@media (min-width: 992px) {
|
|
4128
4680
|
.m-lg-0 {
|
|
@@ -4131,6 +4683,9 @@ select.just-validate-success-field {
|
|
|
4131
4683
|
.d-lg-none {
|
|
4132
4684
|
display: none !important;
|
|
4133
4685
|
}
|
|
4686
|
+
.flex-lg-column {
|
|
4687
|
+
flex-direction: column !important;
|
|
4688
|
+
}
|
|
4134
4689
|
}
|
|
4135
4690
|
@media (min-width: 1200px) {
|
|
4136
4691
|
.m-xl-0 {
|
|
@@ -4139,6 +4694,9 @@ select.just-validate-success-field {
|
|
|
4139
4694
|
.d-xl-none {
|
|
4140
4695
|
display: none !important;
|
|
4141
4696
|
}
|
|
4697
|
+
.flex-xl-column {
|
|
4698
|
+
flex-direction: column !important;
|
|
4699
|
+
}
|
|
4142
4700
|
}
|
|
4143
4701
|
@media (min-width: 1400px) {
|
|
4144
4702
|
.m-xxl-0 {
|
|
@@ -4147,153 +4705,82 @@ select.just-validate-success-field {
|
|
|
4147
4705
|
.d-xxl-none {
|
|
4148
4706
|
display: none !important;
|
|
4149
4707
|
}
|
|
4708
|
+
.flex-xxl-column {
|
|
4709
|
+
flex-direction: column !important;
|
|
4710
|
+
}
|
|
4150
4711
|
}
|
|
4151
4712
|
@media print {
|
|
4152
4713
|
.d-print-none {
|
|
4153
4714
|
display: none !important;
|
|
4154
4715
|
}
|
|
4155
4716
|
}
|
|
4156
|
-
:host {
|
|
4157
|
-
display: block;
|
|
4158
|
-
}
|
|
4159
|
-
|
|
4160
4717
|
.password-icon {
|
|
4161
4718
|
top: calc(var(--bs-form-control-spacing) * 5);
|
|
4162
4719
|
--bs-icon-default: var(--bs-icon-primary);
|
|
4163
4720
|
}`;
|
|
4164
4721
|
|
|
4722
|
+
var ItInput_1;
|
|
4165
4723
|
registerTranslation(translation);
|
|
4166
|
-
let ItInput = class ItInput extends
|
|
4724
|
+
let ItInput = ItInput_1 = class ItInput extends FormControl {
|
|
4167
4725
|
constructor() {
|
|
4168
4726
|
super(...arguments);
|
|
4169
|
-
this.
|
|
4170
|
-
this.
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
this.label = '';
|
|
4176
|
-
this.labelHidden = false;
|
|
4727
|
+
this._slotPrepend = null;
|
|
4728
|
+
this._slotAppend = null;
|
|
4729
|
+
/**
|
|
4730
|
+
* The type of input. Works the same as a native `<input>` element, but only a subset of types are supported. Defaults
|
|
4731
|
+
* to `text`.
|
|
4732
|
+
*/
|
|
4177
4733
|
this.type = 'text';
|
|
4178
|
-
|
|
4734
|
+
/** If you want number-input to be adaptive in width */
|
|
4735
|
+
this.adaptive = false;
|
|
4736
|
+
/** If you want label to be hidden. */
|
|
4737
|
+
this.labelHidden = false;
|
|
4738
|
+
/** Placeholder text to show as a hint when the input is empty. */
|
|
4179
4739
|
this.placeholder = '';
|
|
4740
|
+
/** The input's help text. */
|
|
4180
4741
|
this.supportText = '';
|
|
4181
|
-
|
|
4742
|
+
/** If you want the input to be displayed as plaintext. */
|
|
4182
4743
|
this.plaintext = false;
|
|
4744
|
+
/** If the input is read-only. */
|
|
4183
4745
|
this.readonly = false;
|
|
4746
|
+
/** If your input is of type 'password' and you want to display a strength meter */
|
|
4184
4747
|
this.passwordStrengthMeter = false;
|
|
4748
|
+
/** If your input is of type 'password' and you want to show password suggestions. */
|
|
4185
4749
|
this.suggestions = false;
|
|
4186
|
-
this.minlength = -1;
|
|
4187
|
-
this.maxlength = -1;
|
|
4188
4750
|
this._passwordVisible = false;
|
|
4189
4751
|
this._strengthInfos = '';
|
|
4190
4752
|
this._score = 0;
|
|
4191
|
-
this._value = ''; // from validity mixin
|
|
4192
|
-
this._touched = false; // from validity mixin
|
|
4193
|
-
this.validityMessage = ''; // from validity mixin
|
|
4194
|
-
}
|
|
4195
|
-
static get formAssociated() {
|
|
4196
|
-
return true;
|
|
4197
|
-
}
|
|
4198
|
-
get value() {
|
|
4199
|
-
if (this._inputElement) {
|
|
4200
|
-
return this._inputElement.value;
|
|
4201
|
-
}
|
|
4202
|
-
return this._value;
|
|
4203
|
-
}
|
|
4204
|
-
set value(value) {
|
|
4205
|
-
const oldValue = this._value;
|
|
4206
|
-
this._value = value;
|
|
4207
|
-
this.internals.setFormValue(value); // <- Associa il valore al form
|
|
4208
|
-
// make sure that lit-element updates the right properties
|
|
4209
|
-
this.requestUpdate('value', oldValue);
|
|
4210
|
-
// we set the value directly on the input (when available)
|
|
4211
|
-
// so that programatic manipulation updates the UI correctly
|
|
4212
|
-
if (this._inputElement && this._inputElement.value !== value) {
|
|
4213
|
-
this._inputElement.value = value;
|
|
4214
|
-
}
|
|
4215
|
-
}
|
|
4216
|
-
// Getter pubblico per accedere all'input
|
|
4217
|
-
get inputElement() {
|
|
4218
|
-
return this.shadowRoot?.querySelector('input');
|
|
4219
4753
|
}
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
const { formData } = event;
|
|
4224
|
-
formData.append(this.name, this._value);
|
|
4225
|
-
}
|
|
4226
|
-
}
|
|
4227
|
-
_handleInput(e) {
|
|
4228
|
-
const input = e.target;
|
|
4229
|
-
this.value = input.value;
|
|
4230
|
-
if (this.passwordStrengthMeter) {
|
|
4231
|
-
this._checkPasswordStrength(input.value);
|
|
4232
|
-
}
|
|
4233
|
-
this.dispatchEvent(new CustomEvent('on-input', {
|
|
4234
|
-
detail: { value: input.value, el: input },
|
|
4235
|
-
bubbles: true,
|
|
4236
|
-
composed: true,
|
|
4237
|
-
}));
|
|
4238
|
-
}
|
|
4239
|
-
checkValidity() {
|
|
4240
|
-
if (!this.customValidation) {
|
|
4241
|
-
const inputValid = this._inputElement ? this._inputElement.checkValidity() : true; // this._inputElement.checkValidity() è la validazione del browser
|
|
4242
|
-
this._checkValidity({
|
|
4243
|
-
[VALIDATION_STATUS.INVALID]: this.$t('validityInvalid'),
|
|
4244
|
-
[VALIDATION_STATUS.ERROR_REQUIRED]: this.$t('validityRequired'),
|
|
4245
|
-
[VALIDATION_STATUS.PATTERN]: this.$t('validityPattern'),
|
|
4246
|
-
[VALIDATION_STATUS.MINLENGTH]: this.$t('validityMinlength'),
|
|
4247
|
-
[VALIDATION_STATUS.MAXLENGTH]: this.$t('validityMaxlength'),
|
|
4248
|
-
}, inputValid);
|
|
4754
|
+
get label() {
|
|
4755
|
+
if (this.labelElements.length > 0) {
|
|
4756
|
+
return this.labelElements[0].innerText.trim();
|
|
4249
4757
|
}
|
|
4758
|
+
return '';
|
|
4250
4759
|
}
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
this.checkValidity();
|
|
4760
|
+
get slotted() {
|
|
4761
|
+
return this._slotPrepend || this._slotAppend;
|
|
4254
4762
|
}
|
|
4255
4763
|
firstUpdated() {
|
|
4256
|
-
// this.addFocus(this.
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4764
|
+
// this.addFocus(this.inputElement); //NON serve per il momento perche sfruttiamo :focus-visible. Per gli input focus-visible si attiva anche al click perchè è il browser che lo gestisce
|
|
4765
|
+
this._slotPrepend = this.querySelector('[slot="prepend"]');
|
|
4766
|
+
this._slotAppend = this.querySelector('[slot="append"]');
|
|
4767
|
+
this._slotPrepend?.addEventListener('slotchange', () => {
|
|
4260
4768
|
this.requestUpdate();
|
|
4261
4769
|
});
|
|
4262
|
-
|
|
4770
|
+
this._slotAppend?.addEventListener('slotchange', () => {
|
|
4263
4771
|
this.requestUpdate();
|
|
4264
4772
|
});
|
|
4265
4773
|
}
|
|
4266
4774
|
connectedCallback() {
|
|
4267
4775
|
super.connectedCallback?.();
|
|
4268
|
-
/* così quando si scrive <it-input value="ciao"></it-input>, this.value viene impostato con 'ciao' */
|
|
4269
|
-
const attrValue = this.getAttribute('value');
|
|
4270
|
-
if (attrValue !== null) {
|
|
4271
|
-
this.value = attrValue;
|
|
4272
|
-
}
|
|
4273
4776
|
if (this.type === 'password' && this.minlength < 0) {
|
|
4274
4777
|
this.minlength = 8; // set default minlength for password
|
|
4275
4778
|
}
|
|
4276
|
-
|
|
4277
|
-
this.dispatchEvent(new CustomEvent('input-ready', { bubbles: true, detail: { el: this.inputElement } }));
|
|
4278
|
-
});
|
|
4779
|
+
this._handleReady();
|
|
4279
4780
|
}
|
|
4280
|
-
// protected override update(changedProperties: Map<string | number | symbol, unknown>): void {
|
|
4281
|
-
// if (changedProperties.has('value') || (changedProperties.has('required') && this.required)) {
|
|
4282
|
-
// this.updateComplete.then(() => {
|
|
4283
|
-
// this.checkValidity();
|
|
4284
|
-
// });
|
|
4285
|
-
// }
|
|
4286
|
-
// super.update(changedProperties);
|
|
4287
|
-
// }
|
|
4288
4781
|
updated(changedProperties) {
|
|
4289
4782
|
super.updated?.(changedProperties);
|
|
4290
|
-
|
|
4291
|
-
this.setCustomValidity(this.validationText);
|
|
4292
|
-
}
|
|
4293
|
-
if (this.invalid) {
|
|
4294
|
-
const message = this.validationText?.length > 0 ? this.validationText : (this.validityMessage ?? 'Campo non valido');
|
|
4295
|
-
this.internals.setValidity({ customError: this.invalid }, message);
|
|
4296
|
-
}
|
|
4783
|
+
// logger
|
|
4297
4784
|
if (this.passwordStrengthMeter && this.type !== 'password') {
|
|
4298
4785
|
this.logger.warn("The strength-meter property is enabled, but type isn't password. Please, remove strength-meter property.");
|
|
4299
4786
|
}
|
|
@@ -4304,10 +4791,21 @@ let ItInput = class ItInput extends ValidityMixin(FormMixin(BaseLocalizedCompone
|
|
|
4304
4791
|
this.logger.warn(`Label is required to ensure accessibility. Please, define a label for <it-input name="${this.name}" ... /> . Set attribute label-hidden="true" if you don't want to show label.`);
|
|
4305
4792
|
}
|
|
4306
4793
|
}
|
|
4794
|
+
_handleInput(e) {
|
|
4795
|
+
this.value = this.inputElement.value;
|
|
4796
|
+
if (this.value === '00') {
|
|
4797
|
+
this.value = '0';
|
|
4798
|
+
this.inputElement.value = '0';
|
|
4799
|
+
}
|
|
4800
|
+
if (this.passwordStrengthMeter) {
|
|
4801
|
+
this._checkPasswordStrength(this.inputElement.value);
|
|
4802
|
+
}
|
|
4803
|
+
super._handleInput(e);
|
|
4804
|
+
}
|
|
4307
4805
|
_togglePasswordVisibility() {
|
|
4308
4806
|
this._passwordVisible = !this._passwordVisible;
|
|
4309
|
-
if (this.
|
|
4310
|
-
this.
|
|
4807
|
+
if (this.inputElement) {
|
|
4808
|
+
this.inputElement.type = this._passwordVisible ? 'text' : 'password';
|
|
4311
4809
|
}
|
|
4312
4810
|
}
|
|
4313
4811
|
_checkPasswordStrength(value) {
|
|
@@ -4348,6 +4846,28 @@ let ItInput = class ItInput extends ValidityMixin(FormMixin(BaseLocalizedCompone
|
|
|
4348
4846
|
}
|
|
4349
4847
|
this._strengthInfos = text;
|
|
4350
4848
|
}
|
|
4849
|
+
static _cleanFloat(num) {
|
|
4850
|
+
return parseFloat(num.toPrecision(15));
|
|
4851
|
+
}
|
|
4852
|
+
_inputNumberIncDec(v) {
|
|
4853
|
+
const step = typeof this.step === 'number' ? this.step : Number(this.step) || 1;
|
|
4854
|
+
const value = typeof this.value === 'number' ? this.value : Number(this.value) || 0;
|
|
4855
|
+
const min = typeof this.min === 'number' ? this.min : Number(this.min);
|
|
4856
|
+
const max = typeof this.max === 'number' ? this.max : Number(this.max);
|
|
4857
|
+
const _v = v * step;
|
|
4858
|
+
const newValue = ItInput_1._cleanFloat(value + _v);
|
|
4859
|
+
if (newValue > max || newValue < min) ;
|
|
4860
|
+
else {
|
|
4861
|
+
const _value = newValue.toString();
|
|
4862
|
+
this.value = _value;
|
|
4863
|
+
this.inputElement.dispatchEvent(new Event('blur', { bubbles: true }));
|
|
4864
|
+
this.inputElement.dispatchEvent(new Event('change', { bubbles: true }));
|
|
4865
|
+
const liveRegion = this.shadowRoot?.querySelector(`#${this._id}-live-region`);
|
|
4866
|
+
if (liveRegion) {
|
|
4867
|
+
liveRegion.textContent = `${_value}`;
|
|
4868
|
+
}
|
|
4869
|
+
}
|
|
4870
|
+
}
|
|
4351
4871
|
_renderTogglePasswordButton() {
|
|
4352
4872
|
// Solo se type=password
|
|
4353
4873
|
if (this.type === 'password') {
|
|
@@ -4400,7 +4920,7 @@ let ItInput = class ItInput extends ValidityMixin(FormMixin(BaseLocalizedCompone
|
|
|
4400
4920
|
_renderpasswordStrengthMeter() {
|
|
4401
4921
|
if (this.type === 'password' && this.passwordStrengthMeter) {
|
|
4402
4922
|
const perc = this._score < 0 ? 0 : this._score;
|
|
4403
|
-
const color = this.
|
|
4923
|
+
const color = this.value?.length === 0 ? 'muted' : scoreColor(this._score);
|
|
4404
4924
|
return html `<div class="password-strength-meter">
|
|
4405
4925
|
${this._renderSuggestions()}
|
|
4406
4926
|
|
|
@@ -4433,9 +4953,9 @@ let ItInput = class ItInput extends ValidityMixin(FormMixin(BaseLocalizedCompone
|
|
|
4433
4953
|
}
|
|
4434
4954
|
return nothing;
|
|
4435
4955
|
}
|
|
4436
|
-
_renderInput(supportTextId) {
|
|
4437
|
-
const ariaDescribedBy = this.composeClass(this.supportText?.length > 0 ? supportTextId : '', this.passwordStrengthMeter ? `strengthMeterInfo_${this._id}` : '', this._ariaAttributes['aria-describedby']?.length > 0 ? this._ariaAttributes['aria-describedby'] : '',
|
|
4438
|
-
const inputClasses = this.composeClass(this.plaintext ? 'form-control-plaintext' : 'form-control', this.size ? `form-control-${this.size}` : '',
|
|
4956
|
+
_renderInput(supportTextId, invalid, validityMessage) {
|
|
4957
|
+
const ariaDescribedBy = this.composeClass(this.supportText?.length > 0 ? supportTextId : '', this.passwordStrengthMeter ? `strengthMeterInfo_${this._id}` : '', this._ariaAttributes['aria-describedby']?.length > 0 ? this._ariaAttributes['aria-describedby'] : '', validityMessage?.length > 0 ? `invalid-feedback-${this._id}` : '');
|
|
4958
|
+
const inputClasses = this.composeClass('it-form__control', this.plaintext ? 'form-control-plaintext' : 'form-control', this.size ? `form-control-${this.size}` : '', invalid ? 'is-invalid' : '', !invalid && this._touched && !this.readonly ? 'just-validate-success-field' : '');
|
|
4439
4959
|
let inputRender;
|
|
4440
4960
|
if (this.type === 'textarea') {
|
|
4441
4961
|
inputRender = html `
|
|
@@ -4443,139 +4963,149 @@ let ItInput = class ItInput extends ValidityMixin(FormMixin(BaseLocalizedCompone
|
|
|
4443
4963
|
part="textarea focusable"
|
|
4444
4964
|
${setAttributes(this._ariaAttributes)}
|
|
4445
4965
|
aria-describedby=${ifDefined(ariaDescribedBy || undefined)}
|
|
4446
|
-
?aria-invalid=${
|
|
4966
|
+
?aria-invalid=${invalid}
|
|
4447
4967
|
@input="${this._handleInput}"
|
|
4448
4968
|
@blur=${this._handleBlur}
|
|
4449
4969
|
@focus=${this._handleFocus}
|
|
4450
4970
|
@click=${this._handleClick}
|
|
4451
4971
|
@change=${this._handleChange}
|
|
4972
|
+
@invalid=${this._handleInvalid}
|
|
4452
4973
|
id="${this._id}"
|
|
4453
4974
|
name="${this.name}"
|
|
4454
4975
|
?disabled=${this.disabled}
|
|
4455
4976
|
?readonly=${this.readonly}
|
|
4456
4977
|
?required=${this.required}
|
|
4457
|
-
|
|
4978
|
+
minlength=${ifDefined(this.minlength)}
|
|
4979
|
+
maxlength=${ifDefined(this.maxlength)}
|
|
4980
|
+
pattern=${ifDefined(this.pattern)}
|
|
4981
|
+
?formNoValidate=${this.customValidation}
|
|
4982
|
+
.value="${live(this.value)}"
|
|
4458
4983
|
placeholder=${ifDefined(this.placeholder || undefined)}
|
|
4459
4984
|
class="${inputClasses}"
|
|
4460
4985
|
></textarea>
|
|
4461
4986
|
`;
|
|
4462
4987
|
}
|
|
4463
4988
|
else {
|
|
4989
|
+
let style = null;
|
|
4990
|
+
if (this.type === 'number' && this.adaptive) {
|
|
4991
|
+
style = `width: calc(${this.value.toString().length}ch + 70px);`;
|
|
4992
|
+
}
|
|
4464
4993
|
inputRender = html `
|
|
4465
4994
|
<input
|
|
4466
4995
|
part="input focusable"
|
|
4467
4996
|
${setAttributes(this._ariaAttributes)}
|
|
4468
4997
|
aria-describedby=${ifDefined(ariaDescribedBy || undefined)}
|
|
4469
|
-
?aria-invalid=${
|
|
4998
|
+
?aria-invalid=${invalid}
|
|
4470
4999
|
@input="${this._handleInput}"
|
|
4471
5000
|
@blur=${this._handleBlur}
|
|
4472
5001
|
@focus=${this._handleFocus}
|
|
4473
5002
|
@click=${this._handleClick}
|
|
4474
5003
|
@change=${this._handleChange}
|
|
5004
|
+
@invalid=${this._handleInvalid}
|
|
4475
5005
|
type="${this.type}"
|
|
4476
5006
|
id="${this._id}"
|
|
4477
5007
|
name="${this.name}"
|
|
4478
5008
|
?disabled=${this.disabled}
|
|
4479
5009
|
?readonly=${this.readonly}
|
|
4480
5010
|
?required=${this.required}
|
|
4481
|
-
|
|
5011
|
+
minlength=${ifDefined(this.minlength)}
|
|
5012
|
+
maxlength=${ifDefined(this.maxlength)}
|
|
5013
|
+
min=${ifDefined(this.min)}
|
|
5014
|
+
max=${ifDefined(this.max)}
|
|
5015
|
+
step=${ifDefined(this.step)}
|
|
5016
|
+
pattern=${ifDefined(this.pattern)}
|
|
5017
|
+
?formNoValidate=${this.customValidation}
|
|
5018
|
+
.value="${live(this.value)}"
|
|
4482
5019
|
placeholder=${ifDefined(this.placeholder || undefined)}
|
|
4483
5020
|
class="${inputClasses}"
|
|
5021
|
+
style=${ifDefined(style)}
|
|
4484
5022
|
/>${this._renderTogglePasswordButton()}
|
|
4485
5023
|
`;
|
|
4486
5024
|
}
|
|
4487
|
-
inputRender = html `
|
|
4488
|
-
${inputRender}
|
|
4489
|
-
<div
|
|
4490
|
-
role="alert"
|
|
4491
|
-
id="invalid-feedback-${this._id}"
|
|
4492
|
-
class="invalid-feedback form-feedback form-text form-feedback just-validate-error-label"
|
|
4493
|
-
?hidden=${!(this.validityMessage?.length > 0)}
|
|
4494
|
-
>
|
|
4495
|
-
<span class="visually-hidden">${this.label}: </span>${this.validityMessage}
|
|
4496
|
-
</div>
|
|
4497
|
-
`;
|
|
4498
5025
|
return inputRender;
|
|
4499
5026
|
}
|
|
4500
5027
|
// Render the UI as a function of component state
|
|
4501
5028
|
render() {
|
|
4502
5029
|
const supportTextId = `${this._id}-support-text`;
|
|
4503
5030
|
const supportTextRender = html ` ${when(this.supportText, () => html ` <small class="form-text" id="${supportTextId}">${this.supportText}</small> `)}`;
|
|
5031
|
+
const validityMessage = (this.validationMessage ) ?? '';
|
|
5032
|
+
const invalid = validityMessage?.length > 0 || (!this.customValidation && this.inputElement?.checkValidity() === false);
|
|
5033
|
+
const validityMessageRender = html `<div
|
|
5034
|
+
role="alert"
|
|
5035
|
+
id="invalid-feedback-${this._id}"
|
|
5036
|
+
class="invalid-feedback form-feedback form-text form-feedback just-validate-error-label"
|
|
5037
|
+
?hidden=${!(validityMessage?.length > 0)}
|
|
5038
|
+
>
|
|
5039
|
+
<span class="visually-hidden">${this.label}: </span>${validityMessage}
|
|
5040
|
+
</div>`;
|
|
4504
5041
|
return html `
|
|
4505
5042
|
<div class="form-group" part="input-wrapper">
|
|
4506
5043
|
<label
|
|
4507
5044
|
for="${ifDefined(this._id || undefined)}"
|
|
4508
5045
|
part="label"
|
|
4509
5046
|
class="${this.composeClass('active', this.labelHidden ? 'visually-hidden' : '')}"
|
|
4510
|
-
|
|
4511
|
-
>
|
|
4512
|
-
|
|
4513
|
-
${when(this.slotted, () => html
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
5047
|
+
><slot name="label"></slot
|
|
5048
|
+
></label>
|
|
5049
|
+
|
|
5050
|
+
${when(this.slotted || this.type === 'number', () => html `<div
|
|
5051
|
+
class="${this.composeClass('input-group ', this.type === 'number' ? 'input-number' : '', this.type === 'number' && this.adaptive ? 'input-number-adaptive' : '', this.disabled ? 'disabled' : '', this.readonly ? 'readonly' : '')}"
|
|
5052
|
+
>
|
|
5053
|
+
${when(this._slotPrepend, () => html ` <span class="input-group-text">
|
|
5054
|
+
<slot name="prepend" @slotchange=${() => this.requestUpdate()}></slot
|
|
5055
|
+
></span>`)}
|
|
5056
|
+
${this._renderInput(supportTextId, invalid, validityMessage)}
|
|
5057
|
+
${when(this.type === 'number', () => html `<span class="input-group-text align-buttons flex-column">
|
|
5058
|
+
<button
|
|
5059
|
+
class="input-number-add"
|
|
5060
|
+
@click=${() => this._inputNumberIncDec(1)}
|
|
5061
|
+
?disabled=${this.disabled || this.readonly}
|
|
5062
|
+
>
|
|
5063
|
+
<span class="visually-hidden">${this.$t('increaseValue')}</span>
|
|
5064
|
+
</button>
|
|
5065
|
+
<button
|
|
5066
|
+
class="input-number-sub"
|
|
5067
|
+
@click=${() => this._inputNumberIncDec(-1)}
|
|
5068
|
+
?disabled=${this.disabled || this.readonly}
|
|
5069
|
+
>
|
|
5070
|
+
<span class="visually-hidden">${this.$t('decreaseValue')}</span>
|
|
5071
|
+
</button>
|
|
5072
|
+
<div aria-live="polite" class="visually-hidden" id="${this._id}-live-region"></div>
|
|
5073
|
+
</span>`)}
|
|
5074
|
+
${when(this._slotAppend, () => html ` <div class="input-group-append">
|
|
5075
|
+
<slot name="append" @slotchange=${() => this.requestUpdate()}></slot>
|
|
5076
|
+
</div>`)}
|
|
4521
5077
|
</div>
|
|
4522
|
-
${supportTextRender} ${this._renderpasswordStrengthMeter()}`, () => html ` ${this._renderInput(supportTextId)} ${
|
|
5078
|
+
${validityMessageRender} ${supportTextRender} ${this._renderpasswordStrengthMeter()}`, () => html ` ${this._renderInput(supportTextId, invalid, validityMessage)} ${validityMessageRender}
|
|
5079
|
+
${supportTextRender} ${this._renderpasswordStrengthMeter()}`)}
|
|
4523
5080
|
</div>
|
|
4524
5081
|
`;
|
|
4525
5082
|
}
|
|
4526
5083
|
};
|
|
4527
5084
|
ItInput.styles = styles;
|
|
4528
5085
|
__decorate([
|
|
4529
|
-
|
|
4530
|
-
__metadata("design:type", Object)
|
|
4531
|
-
], ItInput.prototype, "internals", void 0);
|
|
4532
|
-
__decorate([
|
|
4533
|
-
property({ type: Boolean }),
|
|
4534
|
-
__metadata("design:type", Object)
|
|
4535
|
-
], ItInput.prototype, "slotted", void 0);
|
|
4536
|
-
__decorate([
|
|
4537
|
-
property({ type: Boolean, reflect: true }) // from validity mixin
|
|
4538
|
-
,
|
|
4539
|
-
__metadata("design:type", Object)
|
|
4540
|
-
], ItInput.prototype, "invalid", void 0);
|
|
4541
|
-
__decorate([
|
|
4542
|
-
property({ type: Boolean, reflect: true, attribute: 'custom-validation' }) // from validity mixin
|
|
4543
|
-
,
|
|
5086
|
+
state(),
|
|
4544
5087
|
__metadata("design:type", Object)
|
|
4545
|
-
], ItInput.prototype, "
|
|
5088
|
+
], ItInput.prototype, "_slotPrepend", void 0);
|
|
4546
5089
|
__decorate([
|
|
4547
|
-
|
|
4548
|
-
,
|
|
5090
|
+
state(),
|
|
4549
5091
|
__metadata("design:type", Object)
|
|
4550
|
-
], ItInput.prototype, "
|
|
5092
|
+
], ItInput.prototype, "_slotAppend", void 0);
|
|
4551
5093
|
__decorate([
|
|
4552
|
-
property({
|
|
5094
|
+
property({ type: String }),
|
|
4553
5095
|
__metadata("design:type", String)
|
|
4554
|
-
], ItInput.prototype, "
|
|
4555
|
-
__decorate([
|
|
4556
|
-
query('input'),
|
|
4557
|
-
__metadata("design:type", HTMLInputElement)
|
|
4558
|
-
], ItInput.prototype, "_inputElement", void 0);
|
|
5096
|
+
], ItInput.prototype, "type", void 0);
|
|
4559
5097
|
__decorate([
|
|
4560
|
-
property(
|
|
5098
|
+
property(),
|
|
4561
5099
|
__metadata("design:type", Object)
|
|
4562
5100
|
], ItInput.prototype, "size", void 0);
|
|
4563
5101
|
__decorate([
|
|
4564
|
-
property({ type:
|
|
5102
|
+
property({ type: Boolean }),
|
|
4565
5103
|
__metadata("design:type", Object)
|
|
4566
|
-
], ItInput.prototype, "
|
|
5104
|
+
], ItInput.prototype, "adaptive", void 0);
|
|
4567
5105
|
__decorate([
|
|
4568
5106
|
property({ type: Boolean, attribute: 'label-hidden' }),
|
|
4569
5107
|
__metadata("design:type", Object)
|
|
4570
5108
|
], ItInput.prototype, "labelHidden", void 0);
|
|
4571
|
-
__decorate([
|
|
4572
|
-
property({ type: String }),
|
|
4573
|
-
__metadata("design:type", String)
|
|
4574
|
-
], ItInput.prototype, "type", void 0);
|
|
4575
|
-
__decorate([
|
|
4576
|
-
property({ type: String }),
|
|
4577
|
-
__metadata("design:type", Object)
|
|
4578
|
-
], ItInput.prototype, "name", void 0);
|
|
4579
5109
|
__decorate([
|
|
4580
5110
|
property({ type: String }),
|
|
4581
5111
|
__metadata("design:type", Object)
|
|
@@ -4584,10 +5114,6 @@ __decorate([
|
|
|
4584
5114
|
property({ type: String, attribute: 'support-text' }),
|
|
4585
5115
|
__metadata("design:type", Object)
|
|
4586
5116
|
], ItInput.prototype, "supportText", void 0);
|
|
4587
|
-
__decorate([
|
|
4588
|
-
property({ type: Boolean }),
|
|
4589
|
-
__metadata("design:type", Object)
|
|
4590
|
-
], ItInput.prototype, "disabled", void 0);
|
|
4591
5117
|
__decorate([
|
|
4592
5118
|
property({ type: Boolean }),
|
|
4593
5119
|
__metadata("design:type", Object)
|
|
@@ -4605,17 +5131,9 @@ __decorate([
|
|
|
4605
5131
|
__metadata("design:type", Object)
|
|
4606
5132
|
], ItInput.prototype, "suggestions", void 0);
|
|
4607
5133
|
__decorate([
|
|
4608
|
-
|
|
4609
|
-
__metadata("design:type",
|
|
4610
|
-
], ItInput.prototype, "
|
|
4611
|
-
__decorate([
|
|
4612
|
-
property({ type: Number }),
|
|
4613
|
-
__metadata("design:type", Object)
|
|
4614
|
-
], ItInput.prototype, "maxlength", void 0);
|
|
4615
|
-
__decorate([
|
|
4616
|
-
property({ type: String }),
|
|
4617
|
-
__metadata("design:type", String)
|
|
4618
|
-
], ItInput.prototype, "pattern", void 0);
|
|
5134
|
+
queryAssignedElements({ slot: 'label' }),
|
|
5135
|
+
__metadata("design:type", Array)
|
|
5136
|
+
], ItInput.prototype, "labelElements", void 0);
|
|
4619
5137
|
__decorate([
|
|
4620
5138
|
state(),
|
|
4621
5139
|
__metadata("design:type", Object)
|
|
@@ -4628,24 +5146,7 @@ __decorate([
|
|
|
4628
5146
|
state(),
|
|
4629
5147
|
__metadata("design:type", Object)
|
|
4630
5148
|
], ItInput.prototype, "_score", void 0);
|
|
4631
|
-
__decorate([
|
|
4632
|
-
state(),
|
|
4633
|
-
__metadata("design:type", Object)
|
|
4634
|
-
], ItInput.prototype, "_value", void 0);
|
|
4635
|
-
__decorate([
|
|
4636
|
-
state(),
|
|
4637
|
-
__metadata("design:type", Object)
|
|
4638
|
-
], ItInput.prototype, "_touched", void 0);
|
|
4639
|
-
__decorate([
|
|
4640
|
-
property({ type: String }),
|
|
4641
|
-
__metadata("design:type", String)
|
|
4642
|
-
], ItInput.prototype, "validityMessage", void 0);
|
|
4643
|
-
__decorate([
|
|
4644
|
-
property({ reflect: true }),
|
|
4645
|
-
__metadata("design:type", Object),
|
|
4646
|
-
__metadata("design:paramtypes", [Object])
|
|
4647
|
-
], ItInput.prototype, "value", null);
|
|
4648
|
-
ItInput = __decorate([
|
|
5149
|
+
ItInput = ItInput_1 = __decorate([
|
|
4649
5150
|
customElement('it-input')
|
|
4650
5151
|
], ItInput);
|
|
4651
5152
|
|