@italia/modal 1.0.0-alpha.10

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.
@@ -0,0 +1,3160 @@
1
+ import { directive, Directive } from 'lit/directive.js';
2
+ import { LitElement, css, html } from 'lit';
3
+ import { state, query, property, customElement } from 'lit/decorators.js';
4
+ import { classMap } from 'lit/directives/class-map.js';
5
+ import { ifDefined } from 'lit/directives/if-defined.js';
6
+
7
+ /******************************************************************************
8
+ Copyright (c) Microsoft Corporation.
9
+
10
+ Permission to use, copy, modify, and/or distribute this software for any
11
+ purpose with or without fee is hereby granted.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
+ PERFORMANCE OF THIS SOFTWARE.
20
+ ***************************************************************************** */
21
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
22
+
23
+
24
+ function __decorate(decorators, target, key, desc) {
25
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
26
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
27
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
28
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
29
+ }
30
+
31
+ function __metadata(metadataKey, metadataValue) {
32
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
33
+ }
34
+
35
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
36
+ var e = new Error(message);
37
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
38
+ };
39
+
40
+ class SetAttributesDirective extends Directive {
41
+ update(part, [attributes]) {
42
+ const el = part.element;
43
+ for (const [name, value] of Object.entries(attributes)) {
44
+ if (value != null)
45
+ el.setAttribute(name, value);
46
+ else
47
+ el.removeAttribute(name);
48
+ }
49
+ return null;
50
+ }
51
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
52
+ render(_attributes) {
53
+ return null;
54
+ }
55
+ }
56
+ /* How to use:
57
+
58
+ <textarea ${setAttributes(this._ariaAttributes)} ... />
59
+ */
60
+ directive(SetAttributesDirective);
61
+
62
+ 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}
63
+
64
+ const connectedElements = new Set();
65
+ if (window && !window.translations) {
66
+ window.translations = new Map();
67
+ }
68
+ const { translations } = window;
69
+ let fallback;
70
+ // TODO: We need some way for users to be able to set these on the server.
71
+ let documentDirection = 'ltr';
72
+ // Fallback for server.
73
+ let documentLanguage = 'en';
74
+ const isClient = typeof MutationObserver !== 'undefined' &&
75
+ typeof document !== 'undefined' &&
76
+ typeof document.documentElement !== 'undefined';
77
+ /** Updates all localized elements that are currently connected */
78
+ function update() {
79
+ if (isClient) {
80
+ documentDirection = document.documentElement.dir || 'ltr';
81
+ documentLanguage = document.documentElement.lang || navigator.language;
82
+ }
83
+ [...connectedElements.keys()].forEach((el) => {
84
+ const litEl = el;
85
+ if (typeof litEl.requestUpdate === 'function') {
86
+ litEl.requestUpdate();
87
+ }
88
+ });
89
+ }
90
+ if (isClient) {
91
+ const documentElementObserver = new MutationObserver(update);
92
+ documentDirection = document.documentElement.dir || 'ltr';
93
+ documentLanguage = document.documentElement.lang || navigator.language;
94
+ // Watch for changes on <html lang>
95
+ documentElementObserver.observe(document.documentElement, {
96
+ attributes: true,
97
+ attributeFilter: ['dir', 'lang'],
98
+ });
99
+ }
100
+ /** Registers one or more translations */
101
+ function registerTranslation(...translation) {
102
+ translation.forEach((t) => {
103
+ const code = t.$code.toLowerCase();
104
+ if (translations.has(code)) {
105
+ // Merge translations that share the same language code
106
+ translations.set(code, { ...translations.get(code), ...t });
107
+ }
108
+ else {
109
+ translations.set(code, t);
110
+ }
111
+ // The first translation that's registered is the fallback
112
+ if (!fallback) {
113
+ fallback = t;
114
+ }
115
+ });
116
+ update();
117
+ }
118
+ if (typeof window !== 'undefined') {
119
+ window.registerTranslation = registerTranslation;
120
+ }
121
+ /**
122
+ * Localize Reactive Controller for components built with Lit
123
+ *
124
+ * To use this controller, import the class and instantiate it in a custom element constructor:
125
+ *
126
+ * private localize = new LocalizeController(this);
127
+ *
128
+ * This will add the element to the set and make it respond to changes to <html dir|lang> automatically. To make it
129
+ * respond to changes to its own dir|lang properties, make it a property:
130
+ *
131
+ * @property() dir: string;
132
+ * @property() lang: string;
133
+ *
134
+ * To use a translation method, call it like this:
135
+ *
136
+ * ${this.localize.term('term_key_here')}
137
+ * ${this.localize.date('2021-12-03')}
138
+ * ${this.localize.number(1000000)}
139
+ */
140
+ class LocalizeController {
141
+ constructor(host) {
142
+ this.host = host;
143
+ this.host.addController(this);
144
+ }
145
+ hostConnected() {
146
+ connectedElements.add(this.host);
147
+ }
148
+ hostDisconnected() {
149
+ connectedElements.delete(this.host);
150
+ }
151
+ /**
152
+ * Gets the host element's directionality as determined by the `dir` attribute. The return value is transformed to
153
+ * lowercase.
154
+ */
155
+ dir() {
156
+ return `${this.host.dir || documentDirection}`.toLowerCase();
157
+ }
158
+ /**
159
+ * Gets the host element's language as determined by the `lang` attribute. The return value is transformed to
160
+ * lowercase.
161
+ */
162
+ lang() {
163
+ return `${this.host.lang || documentLanguage}`.toLowerCase();
164
+ }
165
+ // eslint-disable-next-line class-methods-use-this
166
+ getTranslationData(lang) {
167
+ // Convert "en_US" to "en-US". Note that both underscores and dashes are allowed per spec, but underscores result in
168
+ // a RangeError by the call to `new Intl.Locale()`. See: https://unicode.org/reports/tr35/#unicode-locale-identifier
169
+ const locale = new Intl.Locale(lang.replace(/_/g, '-'));
170
+ const language = locale?.language.toLowerCase();
171
+ const region = locale?.region?.toLowerCase() ?? '';
172
+ const primary = translations.get(`${language}-${region}`);
173
+ const secondary = translations.get(language);
174
+ return { locale, language, region, primary, secondary };
175
+ }
176
+ /** Determines if the specified term exists, optionally checking the fallback translation. */
177
+ exists(key, options) {
178
+ const { primary, secondary } = this.getTranslationData(options.lang ?? this.lang());
179
+ const mergedOptions = {
180
+ includeFallback: false,
181
+ ...options,
182
+ };
183
+ if ((primary && primary[key]) ||
184
+ (secondary && secondary[key]) ||
185
+ (mergedOptions.includeFallback && fallback && fallback[key])) {
186
+ return true;
187
+ }
188
+ return false;
189
+ }
190
+ /** Outputs a translated term. */
191
+ term(key, ...args) {
192
+ const { primary, secondary } = this.getTranslationData(this.lang());
193
+ let term;
194
+ // Look for a matching term using regionCode, code, then the fallback
195
+ if (primary && primary[key]) {
196
+ term = primary[key];
197
+ }
198
+ else if (secondary && secondary[key]) {
199
+ term = secondary[key];
200
+ }
201
+ else if (fallback && fallback[key]) {
202
+ term = fallback[key];
203
+ }
204
+ else {
205
+ // eslint-disable-next-line no-console
206
+ console.error(`No translation found for: ${String(key)}`);
207
+ return String(key);
208
+ }
209
+ if (typeof term === 'function') {
210
+ return term(...args);
211
+ }
212
+ return term;
213
+ }
214
+ /** Outputs a localized date in the specified format. */
215
+ date(dateToFormat, options) {
216
+ const date = new Date(dateToFormat);
217
+ return new Intl.DateTimeFormat(this.lang(), options).format(date);
218
+ }
219
+ /** Outputs a localized number in the specified format. */
220
+ number(numberToFormat, options) {
221
+ const num = Number(numberToFormat);
222
+ return Number.isNaN(num) ? '' : new Intl.NumberFormat(this.lang(), options).format(num);
223
+ }
224
+ /** Outputs a localized time in relative format. */
225
+ relativeTime(value, unit, options) {
226
+ return new Intl.RelativeTimeFormat(this.lang(), options).format(value, unit);
227
+ }
228
+ }
229
+
230
+ /**
231
+ * @param Base The base class.
232
+ * @returns A mix-in implementing `localizations` method.
233
+ *
234
+ *@example
235
+ * <!-- Terms -->
236
+ ${this.$localize.term('hello')}
237
+ or
238
+ ${this.$t('hello')}
239
+
240
+ <!-- Dates -->
241
+ ${this.$localize.date('2021-09-15 14:00:00 ET', { month: 'long', day: 'numeric', year: 'numeric' })}
242
+ or
243
+ ${this.$d('2021-09-15 14:00:00 ET', { month: 'long', day: 'numeric', year: 'numeric' })}
244
+
245
+ <!-- Numbers/currency -->
246
+ ${this.$localize.number(1000, { style: 'currency', currency: 'USD'})}
247
+ or
248
+ ${this.$n(1000,{ style: 'currency', currency: 'USD'})}
249
+
250
+ <!-- Determining language -->
251
+ ${this.$localize.lang()}
252
+
253
+ <!-- Determining directionality, e.g. 'ltr' or 'rtl' -->
254
+ ${this.$localize.dir()}
255
+
256
+
257
+ *** HOW TO DEFINE TRANSLATIONS: ***
258
+ // Simple terms
259
+ upload: 'Upload',
260
+
261
+ // Terms with placeholders
262
+ greetUser: (name: string) => `Hello, ${name}!`,
263
+
264
+ // Plurals
265
+ numFilesSelected: (count: number) => {
266
+ if (count === 0) return 'No files selected';
267
+ if (count === 1) return '1 file selected';
268
+ return `${count} files selected`;
269
+ }
270
+ */
271
+ const LocalizeMixin = (Base) => class extends Base {
272
+ constructor() {
273
+ super(...arguments);
274
+ this.localize = new LocalizeController(this);
275
+ }
276
+ // Provide default values to avoid definite assignment errors and avoid decorators
277
+ // commentati perchè danno problemi su React.js. Sono attributi nativi, e assegnare un valore di default a react da fastidio
278
+ // dir: string = '';
279
+ // lang: string = '';
280
+ /**
281
+ * Restituisce tutta l'utility di traduzione
282
+ *
283
+
284
+ *
285
+ * @returns tutta l'utility di traduzione
286
+ *
287
+ * @example
288
+ * this.$localize.lang() -> ritorna la lingua corrente
289
+ * this.$localize.dir() -> ritorna la direzione della lingua corrente
290
+ */
291
+ get $localize() {
292
+ return this.localize;
293
+ }
294
+ /**
295
+ * Restituisce una stringa localizzata a partire da una chiave di termine.
296
+ *
297
+ * Utilizza il `LocalizeController` per accedere al dizionario corrente e
298
+ * tradurre la chiave fornita secondo la lingua attiva.
299
+ *
300
+ * @param t - La chiave del termine da localizzare (es. 'hello', 'submit', ecc.).
301
+ * @returns La stringa tradotta in base alla lingua attiva. Se la chiave non è trovata, restituisce la chiave stessa.
302
+ *
303
+ * @example
304
+ * this.$t('hello'); // → "Ciao" (in locale it-IT)
305
+ */
306
+ $t(t) {
307
+ // format term
308
+ return this.localize.term(t);
309
+ }
310
+ /**
311
+ * Formatta una data in base alla localizzazione attiva.
312
+ *
313
+ * Utilizza il `LocalizeController` per restituire una stringa localizzata
314
+ * secondo le opzioni fornite (es. mese esteso, anno, ecc.).
315
+ *
316
+ * @param n - La data da formattare come stringa compatibile (es. ISO o con timezone, es. '2021-09-15 14:00:00 ET').
317
+ * @param p - Le opzioni di formattazione per `Intl.DateTimeFormat` (es. { year: 'numeric', month: 'long', day: 'numeric' }).
318
+ * @returns Una stringa rappresentante la data formattata secondo la localizzazione attiva.
319
+ *
320
+ * @example
321
+ * this.$d('2021-09-15 14:00:00 ET', { year: 'numeric', month: 'long', day: 'numeric' });
322
+ * // → "15 settembre 2021" (in locale it-IT)
323
+ */
324
+ $d(d, p) {
325
+ // format date
326
+ return this.localize.date(d, p);
327
+ }
328
+ /**
329
+ * Formatta un numero secondo le impostazioni locali dell'utente corrente.
330
+ *
331
+ * Utilizza il `LocalizeController` per applicare formattazione numerica,
332
+ * incluse opzioni come separatori, decimali, valute, ecc.
333
+ *
334
+ * @param d - Il numero da formattare.
335
+ * @param p - Le opzioni di formattazione (es. { style: 'currency', currency: 'EUR' }).
336
+ * @returns Una stringa rappresentante il numero formattato secondo la localizzazione attiva.
337
+ *
338
+ * @example
339
+ * this.$n(1234.56, { style: 'currency', currency: 'USD' }); // → "$1,234.56" (in locale en-US)
340
+ */
341
+ $n(d, p) {
342
+ return this.localize.number(d, p);
343
+ }
344
+ };
345
+
346
+ /* eslint-disable no-console */
347
+ class Logger {
348
+ constructor(tag) {
349
+ this.tag = tag;
350
+ }
351
+ format(level, msg) {
352
+ return [`[${this.tag}] ${msg}`];
353
+ }
354
+ warn(msg) {
355
+ console.warn(...this.format('warn', msg));
356
+ }
357
+ error(msg) {
358
+ console.error(...this.format('error', msg));
359
+ }
360
+ info(msg) {
361
+ console.info(...this.format('info', msg));
362
+ }
363
+ }
364
+
365
+ /**
366
+ * Factory function per creare una base class estendibile
367
+ * con stili personalizzati.
368
+ */
369
+ class BaseComponent extends LitElement {
370
+ constructor() {
371
+ super();
372
+ this.composeClass = clsx;
373
+ this.logger = new Logger(this.tagName.toLowerCase());
374
+ }
375
+ get _ariaAttributes() {
376
+ const attributes = {};
377
+ for (const attr of this.getAttributeNames()) {
378
+ if (attr === 'it-role') {
379
+ attributes.role = this.getAttribute(attr);
380
+ }
381
+ else if (attr.startsWith('it-aria-')) {
382
+ attributes[attr.replace(/^it-/, '')] = this.getAttribute(attr);
383
+ }
384
+ }
385
+ return attributes;
386
+ }
387
+ // eslint-disable-next-line class-methods-use-this
388
+ generateId(prefix) {
389
+ return `${prefix}-${Math.random().toString(36).slice(2)}`;
390
+ }
391
+ // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
392
+ addFocus(element) {
393
+ // 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.
394
+ }
395
+ // eslint-disable-next-line class-methods-use-this
396
+ getActiveElement() {
397
+ let active = document.activeElement;
398
+ while (active && active.shadowRoot && active.shadowRoot.activeElement) {
399
+ active = active.shadowRoot.activeElement;
400
+ }
401
+ return active;
402
+ }
403
+ get focusElement() {
404
+ return this;
405
+ }
406
+ // eslint-disable-next-line class-methods-use-this
407
+ get prefersReducedMotion() {
408
+ return window.matchMedia('(prefers-reduced-motion: reduce)').matches;
409
+ }
410
+ connectedCallback() {
411
+ super.connectedCallback();
412
+ // generate internal _id
413
+ const prefix = this.id?.length > 0 ? this.id : this.tagName.toLowerCase();
414
+ this._id = this.generateId(prefix);
415
+ }
416
+ }
417
+ const BaseLocalizedComponent = LocalizeMixin(BaseComponent);
418
+
419
+ /**
420
+ * Safari/VoiceOver iOS workarounds catalogue — why timers exist here:
421
+ *
422
+ * 1. `activate()` rAF + setTimeout(50): Safari does not reliably update the VoiceOver
423
+ * accessibility tree synchronously. rAF ensures the element is painted before we
424
+ * attempt to focus it. setTimeout(50) yields 50ms so VoiceOver can settle its
425
+ * accessibility tree before announcing the newly focused element.
426
+ * Empirically, VoiceOver iOS needs 100–300ms; the animated path in it-modal already
427
+ * provides ~316ms naturally via animation.finished, so the 50ms here only truly
428
+ * matters for the no-animation / prefers-reduced-motion path.
429
+ *
430
+ * 2. `_restoreFocus()` setTimeout(0): Same settle reason on close. The caller
431
+ * (it-modal finishHide) adds a belt-and-suspenders 20ms setTimeout; _restoreFocus
432
+ * is skipped via { skipFocusRestore: true } in that case to avoid double-focus.
433
+ *
434
+ * 3. `activate()` iOS body-focus fallback: On iOS Safari, tapping a button does not
435
+ * reliably move document.activeElement away from body. We fall back to getTrigger()
436
+ * so _previousActiveElement is always a real DOM element to restore focus to on close.
437
+ *
438
+ * There is no WebKit/Safari API to detect when VoiceOver has settled its accessibility
439
+ * tree. setTimeout-based workarounds are the same pattern used by Bootstrap 5, the
440
+ * focus-trap npm package, and a11y-dialog.
441
+ */
442
+ class FocusTrapController {
443
+ static getManagedHostAncestor(element) {
444
+ let current = element;
445
+ while (current) {
446
+ const parentEl = current instanceof HTMLElement ? current.parentElement : null;
447
+ if (parentEl && parentEl.matches(FocusTrapController.MANAGED_HOST_SELECTORS))
448
+ return parentEl;
449
+ if (parentEl) {
450
+ current = parentEl;
451
+ continue;
452
+ }
453
+ const rootNode = current.getRootNode();
454
+ if (rootNode instanceof ShadowRoot) {
455
+ const hostElement = rootNode.host;
456
+ if (hostElement instanceof HTMLElement) {
457
+ if (hostElement.matches(FocusTrapController.MANAGED_HOST_SELECTORS))
458
+ return hostElement;
459
+ current = hostElement;
460
+ continue;
461
+ }
462
+ }
463
+ break;
464
+ }
465
+ return null;
466
+ }
467
+ static isInsideManagedHost(element) {
468
+ return FocusTrapController.getManagedHostAncestor(element) !== null;
469
+ }
470
+ static getManagedMenuHostAncestor(element) {
471
+ let current = element;
472
+ while (current) {
473
+ const parentEl = current instanceof HTMLElement ? current.parentElement : null;
474
+ if (parentEl && parentEl.matches(FocusTrapController.MANAGED_MENU_HOST_SELECTORS))
475
+ return parentEl;
476
+ if (parentEl) {
477
+ current = parentEl;
478
+ continue;
479
+ }
480
+ const rootNode = current.getRootNode();
481
+ if (rootNode instanceof ShadowRoot) {
482
+ const hostElement = rootNode.host;
483
+ if (hostElement instanceof HTMLElement) {
484
+ if (hostElement.matches(FocusTrapController.MANAGED_MENU_HOST_SELECTORS))
485
+ return hostElement;
486
+ current = hostElement;
487
+ continue;
488
+ }
489
+ }
490
+ break;
491
+ }
492
+ return null;
493
+ }
494
+ static collectFocusableCandidates(root, candidates, trigger, visited) {
495
+ const rootAsNode = root;
496
+ if (visited.has(rootAsNode))
497
+ return;
498
+ visited.add(rootAsNode);
499
+ const elements = Array.from(root.querySelectorAll('*'));
500
+ elements.forEach((el) => {
501
+ if (el === trigger)
502
+ return;
503
+ // Keep custom host components as single tab stops: their internal light/shadow
504
+ // descendants must not appear as separate trap candidates.
505
+ if (FocusTrapController.isInsideManagedHost(el))
506
+ return;
507
+ if (el.matches(FocusTrapController.FOCUSABLE_SELECTORS)) {
508
+ candidates.push(el);
509
+ // Stop here: focusCandidate() handles delegation to the inner focusable.
510
+ // Prevent recursion into this element's shadow DOM so inner buttons/triggers
511
+ // are not added as separate tab stops.
512
+ if (el.shadowRoot)
513
+ visited.add(el.shadowRoot);
514
+ return;
515
+ }
516
+ if (el instanceof HTMLSlotElement) {
517
+ el.assignedElements({ flatten: true }).forEach((assigned) => {
518
+ if (!(assigned instanceof HTMLElement) || assigned === trigger)
519
+ return;
520
+ if (assigned.matches(FocusTrapController.FOCUSABLE_SELECTORS)) {
521
+ candidates.push(assigned);
522
+ // Same rule: don't recurse into a focusable element.
523
+ if (assigned.shadowRoot)
524
+ visited.add(assigned.shadowRoot);
525
+ return;
526
+ }
527
+ FocusTrapController.collectFocusableCandidates(assigned, candidates, trigger, visited);
528
+ if (assigned.shadowRoot) {
529
+ FocusTrapController.collectFocusableCandidates(assigned.shadowRoot, candidates, trigger, visited);
530
+ }
531
+ });
532
+ return;
533
+ }
534
+ if (el.shadowRoot) {
535
+ FocusTrapController.collectFocusableCandidates(el.shadowRoot, candidates, trigger, visited);
536
+ }
537
+ });
538
+ }
539
+ static getFirstFocusableInShadow(host) {
540
+ const visited = new Set();
541
+ const walk = (root) => {
542
+ const rootAsNode = root;
543
+ if (visited.has(rootAsNode))
544
+ return null;
545
+ visited.add(rootAsNode);
546
+ const direct = Array.from(root.querySelectorAll(FocusTrapController.NATIVE_FOCUSABLE_SELECTORS));
547
+ const firstDirect = direct.find((el) => FocusTrapController.isFocusable(el));
548
+ if (firstDirect)
549
+ return firstDirect;
550
+ const all = Array.from(root.querySelectorAll('*'));
551
+ for (const el of all) {
552
+ if (el instanceof HTMLSlotElement) {
553
+ const assigned = el.assignedElements({ flatten: true });
554
+ for (const assignedEl of assigned) {
555
+ if (!(assignedEl instanceof HTMLElement))
556
+ continue;
557
+ if (assignedEl.matches(FocusTrapController.NATIVE_FOCUSABLE_SELECTORS)) {
558
+ if (FocusTrapController.isFocusable(assignedEl))
559
+ return assignedEl;
560
+ }
561
+ const nestedAssigned = walk(assignedEl);
562
+ if (nestedAssigned)
563
+ return nestedAssigned;
564
+ if (assignedEl.shadowRoot) {
565
+ const nestedAssignedShadow = walk(assignedEl.shadowRoot);
566
+ if (nestedAssignedShadow)
567
+ return nestedAssignedShadow;
568
+ }
569
+ }
570
+ }
571
+ if (el.shadowRoot) {
572
+ const nested = walk(el.shadowRoot);
573
+ if (nested)
574
+ return nested;
575
+ }
576
+ }
577
+ return null;
578
+ };
579
+ if (!host.shadowRoot)
580
+ return null;
581
+ return walk(host.shadowRoot);
582
+ }
583
+ static focusCandidate(target) {
584
+ if (!target)
585
+ return;
586
+ if (target.tagName.toLowerCase().startsWith('it-')) {
587
+ const innerFocusable = FocusTrapController.getFirstFocusableInShadow(target);
588
+ if (innerFocusable) {
589
+ innerFocusable.focus({ preventScroll: true });
590
+ return;
591
+ }
592
+ }
593
+ target.focus({ preventScroll: true });
594
+ }
595
+ /**
596
+ * Verifica se un elemento è effettivamente focusabile e tabbabile.
597
+ * Elementi con tabindex="-1" sono focusabili programmaticamente ma non tabbabili.
598
+ */
599
+ static isFocusable(el) {
600
+ if (typeof el.focus !== 'function')
601
+ return false;
602
+ if (el.hasAttribute('disabled') || el.hasAttribute('inert') || el.hasAttribute('it-inert'))
603
+ return false;
604
+ const tabindex = el.getAttribute('tabindex');
605
+ if (tabindex && parseInt(tabindex, 10) < 0)
606
+ return false;
607
+ if (el.tagName.toLowerCase().startsWith('it-')) {
608
+ if (tabindex && parseInt(tabindex, 10) < 0)
609
+ return false;
610
+ return true;
611
+ }
612
+ // Fix Race Condition Safari: durante l'apertura non fidarti di getClientRects o opacità
613
+ try {
614
+ const style = window.getComputedStyle(el);
615
+ return style && style.display !== 'none' && style.visibility !== 'hidden';
616
+ }
617
+ catch {
618
+ return false;
619
+ }
620
+ }
621
+ constructor(host, config) {
622
+ this.observer = null;
623
+ this._isActive = false;
624
+ this._previousActiveElement = null;
625
+ this._focusableElements = [];
626
+ /** Last known index resolved from real focusin events inside the trap.
627
+ * Used as a fallback when assistive tech retargeting makes activeElement
628
+ * temporarily unmappable during Tab navigation. */
629
+ this._lastKnownFocusIndex = -1;
630
+ /** Timer ID for the focus call scheduled inside activate(). Cancelled by deactivate()
631
+ * to prevent focus firing after the trap has been torn down (fast open/close, unmount). */
632
+ this._pendingFocusTimer = null;
633
+ this._handleKeyDown = (event) => {
634
+ if (!this._isActive)
635
+ return;
636
+ switch (event.key) {
637
+ case 'Escape':
638
+ if (!this.config.disableEscape && this.config.onEscape) {
639
+ event.preventDefault();
640
+ this.config.onEscape();
641
+ }
642
+ break;
643
+ case 'Tab':
644
+ this._handleTab(event);
645
+ break;
646
+ }
647
+ };
648
+ this._handleFocusIn = (event) => {
649
+ if (!this._isActive)
650
+ return;
651
+ if (this._focusableElements.length === 0) {
652
+ this.updateFocusableElements();
653
+ if (this._focusableElements.length === 0)
654
+ return;
655
+ }
656
+ const path = event.composedPath();
657
+ let index = this._focusableElements.findIndex((candidate) => path.includes(candidate));
658
+ if (index === -1) {
659
+ const target = path[0];
660
+ if (target instanceof HTMLElement) {
661
+ index = this._focusableElements.indexOf(target);
662
+ }
663
+ }
664
+ if (index === -1) {
665
+ const active = FocusTrapController.getActiveElement();
666
+ if (active) {
667
+ index = this._focusableElements.findIndex((candidate) => candidate.contains(active));
668
+ }
669
+ }
670
+ if (index !== -1) {
671
+ this._lastKnownFocusIndex = index;
672
+ }
673
+ };
674
+ this.host = host;
675
+ this.config = config;
676
+ this.host.addController(this);
677
+ }
678
+ hostConnected() {
679
+ const observerOptions = { childList: true, attributes: true, subtree: true };
680
+ this.observer = new MutationObserver(this.updateFocusableElements.bind(this));
681
+ this.observer.observe(this.host, observerOptions);
682
+ }
683
+ hostDisconnected() {
684
+ this.deactivate();
685
+ if (this.observer) {
686
+ this.observer.disconnect();
687
+ this.observer = null;
688
+ }
689
+ }
690
+ get isActive() {
691
+ return this._isActive;
692
+ }
693
+ activate() {
694
+ if (this._isActive)
695
+ return;
696
+ this._isActive = true;
697
+ // FIX iOS: Safari non dà focus al tap. Se activeElement è body, salviamo il trigger della config.
698
+ const currentActive = FocusTrapController.getActiveElement();
699
+ this._previousActiveElement =
700
+ !currentActive || currentActive === document.body ? this.config.getTrigger() : currentActive;
701
+ // Usa document capture: cattura Tab/Escape prima di qualsiasi handler,
702
+ // indipendentemente da shadow DOM, delegatesFocus e slot retargeting.
703
+ document.addEventListener('keydown', this._handleKeyDown, true);
704
+ document.addEventListener('focusin', this._handleFocusIn, true);
705
+ this.updateFocusableElements();
706
+ this._lastKnownFocusIndex = -1;
707
+ // FIX Safari: trick engine
708
+ // Diamo al browser un istante per processare il ricalcolo del layout
709
+ requestAnimationFrame(() => {
710
+ if (this.config.initialFocus) {
711
+ const el = this.config.initialFocus();
712
+ if (el) {
713
+ // 50ms gives VoiceOver iOS time to settle its accessibility tree before
714
+ // announcing the focused element. See class-level comment for details.
715
+ this._pendingFocusTimer = setTimeout(() => {
716
+ this._pendingFocusTimer = null;
717
+ el.focus({ preventScroll: true });
718
+ }, 50);
719
+ }
720
+ }
721
+ else {
722
+ console.warn("FocusTrap: missing 'initialFocus' callback, provide one");
723
+ }
724
+ });
725
+ }
726
+ deactivate(options) {
727
+ if (!this._isActive)
728
+ return;
729
+ // Cancel any in-flight focus timer so it cannot fire after the trap is torn down
730
+ // (e.g. fast open/close cycle, component unmounted while opening).
731
+ if (this._pendingFocusTimer !== null) {
732
+ clearTimeout(this._pendingFocusTimer);
733
+ this._pendingFocusTimer = null;
734
+ }
735
+ this._isActive = false;
736
+ document.removeEventListener('keydown', this._handleKeyDown, true);
737
+ document.removeEventListener('focusin', this._handleFocusIn, true);
738
+ this._lastKnownFocusIndex = -1;
739
+ if (!options?.skipFocusRestore) {
740
+ this._restoreFocus();
741
+ }
742
+ else {
743
+ this._previousActiveElement = null;
744
+ }
745
+ }
746
+ /**
747
+ * Aggiorna la lista degli elementi focusabili.
748
+ * Chiamare dopo modifiche al DOM.
749
+ */
750
+ updateFocusableElements() {
751
+ const container = this.config.getContainer();
752
+ const trigger = this.config.getTrigger();
753
+ if (!container) {
754
+ this._focusableElements = [];
755
+ this._first = undefined;
756
+ this._last = undefined;
757
+ return;
758
+ }
759
+ const candidates = [];
760
+ FocusTrapController.collectFocusableCandidates(container, candidates, trigger, new Set());
761
+ // Include anche i figli light DOM dell'host (es. contenuti slottati della modale)
762
+ Array.from(this.host.children).forEach((child) => {
763
+ if (!(child instanceof HTMLElement) || child === trigger)
764
+ return;
765
+ if (child.matches(FocusTrapController.FOCUSABLE_SELECTORS)) {
766
+ candidates.push(child);
767
+ // Don't recurse: same stop-on-focusable rule.
768
+ return;
769
+ }
770
+ const childVisited = new Set();
771
+ FocusTrapController.collectFocusableCandidates(child, candidates, trigger, childVisited);
772
+ if (child.shadowRoot) {
773
+ FocusTrapController.collectFocusableCandidates(child.shadowRoot, candidates, trigger, childVisited);
774
+ }
775
+ });
776
+ // Filtra solo elementi veramente focusabili e rimuovi duplicati
777
+ this._focusableElements = Array.from(new Set(candidates)).filter((el) => {
778
+ // Escludi esplicitamente il container/dialog stesso
779
+ if (el === this.config.getContainer())
780
+ return false;
781
+ return FocusTrapController.isFocusable(el);
782
+ });
783
+ // Aggiorna primo/ultimo
784
+ this._first = this._focusableElements?.[0];
785
+ this._last = this._focusableElements[this._focusableElements.length - 1];
786
+ }
787
+ /** Sposta il focus sul primo elemento focusabile */
788
+ focusFirst() {
789
+ if (this._first)
790
+ this._first.focus();
791
+ }
792
+ /** Sposta il focus sull'ultimo elemento focusabile */
793
+ focusLast() {
794
+ if (this._last) {
795
+ this._last.focus();
796
+ }
797
+ }
798
+ /** Ritorna l'elemento attivo corrente, attraversando shadow DOM e slot */
799
+ static getActiveElement() {
800
+ let active = document.activeElement;
801
+ while (active && active.shadowRoot && active.shadowRoot.activeElement) {
802
+ active = active.shadowRoot.activeElement;
803
+ }
804
+ return active;
805
+ }
806
+ _handleTab(event) {
807
+ const activeElement = FocusTrapController.getActiveElement();
808
+ // Let native Tab behavior handle navigation inside open dropdown/megamenu.
809
+ // This allows entering and traversing internal menu items correctly.
810
+ if (activeElement) {
811
+ const managedHost = FocusTrapController.getManagedMenuHostAncestor(activeElement);
812
+ if (managedHost && managedHost.getAttribute('data-it-aria-expanded') === 'true') {
813
+ return;
814
+ }
815
+ }
816
+ // Ricalcola sempre al Tab: gli elementi slottati possono completare il render
817
+ // del proprio shadow DOM dopo l'attivazione iniziale del trap.
818
+ this.updateFocusableElements();
819
+ if (this._focusableElements.length === 0)
820
+ return; // Se è ancora vuoto, non bloccare il Tab
821
+ event.preventDefault();
822
+ let currentIndex = this._focusableElements.indexOf(activeElement);
823
+ if (currentIndex === -1 && activeElement) {
824
+ // 1. Walk shadow host chain (covers delegatesFocus custom elements)
825
+ let parent = activeElement.getRootNode()?.host;
826
+ while (parent && currentIndex === -1) {
827
+ currentIndex = this._focusableElements.indexOf(parent);
828
+ if (currentIndex === -1)
829
+ parent = parent.getRootNode()?.host;
830
+ }
831
+ }
832
+ if (currentIndex === -1) {
833
+ // 2. Composed path fallback: handles focus inside nested shadow/slotted
834
+ // content (e.g. anchors inside it-dropdown-item) by mapping the active
835
+ // target to the first focusable host found in the event path.
836
+ const composedPath = event.composedPath();
837
+ currentIndex = this._focusableElements.findIndex((candidate) => composedPath.includes(candidate));
838
+ }
839
+ if (currentIndex === -1 && activeElement) {
840
+ // 3. contains() fallback: handles focus inside an open dropdown/megamenu whose
841
+ // items live in light DOM (not shadow DOM), so the parent-walk above doesn't
842
+ // reach the host. Map to the host's index so Tab/Shift+Tab move to the
843
+ // correct adjacent element.
844
+ currentIndex = this._focusableElements.findIndex((candidate) => candidate.contains(activeElement));
845
+ }
846
+ if (currentIndex === -1) {
847
+ // 4. AT fallback: with some screen readers, document.activeElement and/or
848
+ // event target can be unreliable while navigating inside composite widgets.
849
+ // If a dropdown/megamenu is currently open, use its host index as anchor
850
+ // so forward/backward Tab continue from that position instead of wrapping.
851
+ currentIndex = this._focusableElements.findIndex((candidate) => candidate.matches('it-dropdown, it-megamenu') && candidate.getAttribute('data-it-aria-expanded') === 'true');
852
+ }
853
+ if (currentIndex === -1 && this._lastKnownFocusIndex >= 0) {
854
+ // 5. Last-known fallback: if assistive tech retargeting hides the active
855
+ // element for this key event, continue from the most recent resolved
856
+ // focus index captured via focusin.
857
+ currentIndex = Math.min(this._lastKnownFocusIndex, this._focusableElements.length - 1);
858
+ }
859
+ if (event.shiftKey) {
860
+ if (currentIndex <= 0)
861
+ FocusTrapController.focusCandidate(this._last);
862
+ else
863
+ FocusTrapController.focusCandidate(this._focusableElements[currentIndex - 1]);
864
+ }
865
+ else if (currentIndex === -1 || currentIndex >= this._focusableElements.length - 1)
866
+ FocusTrapController.focusCandidate(this._first);
867
+ else
868
+ FocusTrapController.focusCandidate(this._focusableElements[currentIndex + 1]);
869
+ }
870
+ _restoreFocus() {
871
+ const target = this._previousActiveElement;
872
+ this._previousActiveElement = null;
873
+ if (target && typeof target.focus === 'function' && document.contains(target)) {
874
+ // FIX Safari: blur the current element first so VoiceOver doesn't stay on the
875
+ // modal element while the accessibility tree processes the focus change.
876
+ FocusTrapController.getActiveElement()?.blur();
877
+ // FIX Safari/VoiceOver iOS: defer to the next macrotask so the accessibility
878
+ // tree has time to process the DOM mutation before announcing the restored element.
879
+ setTimeout(() => {
880
+ target.focus({ preventScroll: true });
881
+ }, 0);
882
+ }
883
+ }
884
+ }
885
+ FocusTrapController.FOCUSABLE_SELECTORS = [
886
+ 'a[href]',
887
+ 'button:not([disabled])',
888
+ 'textarea:not([disabled])',
889
+ 'input:not([disabled]):not([type="hidden"])',
890
+ 'select:not([disabled])',
891
+ '[tabindex]',
892
+ 'it-button:not([disabled])',
893
+ 'it-dropdown:not([disabled])',
894
+ 'it-megamenu:not([disabled])',
895
+ ].join(',');
896
+ FocusTrapController.NATIVE_FOCUSABLE_SELECTORS = [
897
+ 'a[href]',
898
+ 'button:not([disabled])',
899
+ 'textarea:not([disabled])',
900
+ 'input:not([disabled]):not([type="hidden"])',
901
+ 'select:not([disabled])',
902
+ '[tabindex]:not([tabindex="-1"])',
903
+ ].join(',');
904
+ FocusTrapController.MANAGED_HOST_SELECTORS = [
905
+ 'it-button:not([disabled])',
906
+ 'it-dropdown:not([disabled])',
907
+ 'it-megamenu:not([disabled])',
908
+ ].join(',');
909
+ FocusTrapController.MANAGED_MENU_HOST_SELECTORS = [
910
+ 'it-dropdown:not([disabled])',
911
+ 'it-megamenu:not([disabled])',
912
+ ].join(',');
913
+
914
+ //
915
+ // We store a WeakMap of forms + controls so we can keep references to all FormControl within a given form. As
916
+ // elements connect and disconnect to/from the DOM, their containing form is used as the key and the form control is
917
+ // added and removed from the form's set, respectively.
918
+ //
919
+ const formCollections = new WeakMap();
920
+ //
921
+ // We store a WeakMap of reportValidity() overloads so we can override it when form controls connect to the DOM and
922
+ // restore the original behavior when they disconnect.
923
+ //
924
+ const reportValidityOverloads = new WeakMap();
925
+ const checkValidityOverloads = new WeakMap();
926
+ //
927
+ // We store a Set of controls that users have interacted with. This allows us to determine the interaction state
928
+ // without littering the DOM with additional data attributes.
929
+ //
930
+ const userInteractedControls = new WeakSet();
931
+ //
932
+ // We store a WeakMap of interactions for each form control so we can track when all conditions are met for validation.
933
+ //
934
+ const interactions = new WeakMap();
935
+ /** A reactive controller to allow form controls to participate in form submission, validation, etc. */
936
+ class FormControlController {
937
+ constructor(host, options) {
938
+ this.submittedOnce = false;
939
+ this.handleFormData = (event) => {
940
+ // console.log('handleFormData');
941
+ const disabled = this.options.disabled(this.host);
942
+ const name = this.options.name(this.host);
943
+ const value = this.options.value(this.host);
944
+ const tagName = this.host.tagName.toLowerCase();
945
+ // For buttons, we only submit the value if they were the submitter. This is currently done in doAction() by
946
+ // injecting the name/value on a temporary button, so we can just skip them here.
947
+ const isButton = tagName === 'it-button';
948
+ if (this.host.isConnected &&
949
+ !disabled &&
950
+ !isButton &&
951
+ typeof name === 'string' &&
952
+ name.length > 0 &&
953
+ typeof value !== 'undefined') {
954
+ switch (tagName) {
955
+ case 'it-radio':
956
+ if (this.host.checked) {
957
+ event.formData.append(name, value);
958
+ }
959
+ break;
960
+ case 'it-checkbox':
961
+ case 'it-toggle':
962
+ if (this.host.checked) {
963
+ if (event.formData.getAll(name).indexOf(value) < 0) {
964
+ // handle group checkbox
965
+ event.formData.append(name, value);
966
+ }
967
+ }
968
+ break;
969
+ case 'it-checkbox-group':
970
+ case 'it-toggle-group':
971
+ // non settare valori in formData, perchè ogni singola checkbox setta il suo valore
972
+ break;
973
+ case 'it-upload':
974
+ // value is File[] — append each File object directly (not as string)
975
+ if (Array.isArray(value)) {
976
+ value.forEach((file) => {
977
+ event.formData.append(name, file);
978
+ });
979
+ }
980
+ break;
981
+ default:
982
+ if (Array.isArray(value)) {
983
+ value.forEach((val) => {
984
+ event.formData.append(name, val.toString());
985
+ });
986
+ }
987
+ else {
988
+ event.formData.append(name, value.toString());
989
+ }
990
+ }
991
+ }
992
+ };
993
+ this.handleFormSubmit = (event) => {
994
+ const disabled = this.options.disabled(this.host);
995
+ const reportValidity = this.options.reportValidity;
996
+ // Update the interacted state for all controls when the form is submitted
997
+ if (this.form && !this.form.noValidate) {
998
+ formCollections.get(this.form)?.forEach((control) => {
999
+ this.setUserInteracted(control, true);
1000
+ });
1001
+ }
1002
+ const resReportValidity = reportValidity(this.host);
1003
+ if (this.form && !this.form.noValidate && !disabled && !resReportValidity) {
1004
+ event.preventDefault();
1005
+ // event.stopImmediatePropagation(); // se lo attiviamo, valida un campo alla volta
1006
+ // Scroll al primo controllo non valido
1007
+ const formControls = formCollections.get(this.form);
1008
+ if (formControls) {
1009
+ for (const control of formControls) {
1010
+ if (!control.validity?.valid) {
1011
+ // Scroll smooth verso il controllo non valido
1012
+ control.scrollIntoView({
1013
+ behavior: 'smooth',
1014
+ block: 'center',
1015
+ });
1016
+ break;
1017
+ }
1018
+ }
1019
+ }
1020
+ }
1021
+ this.submittedOnce = true;
1022
+ };
1023
+ this.handleFormReset = () => {
1024
+ this.options.setValue(this.host, '');
1025
+ this.submittedOnce = false;
1026
+ this.setUserInteracted(this.host, false);
1027
+ interactions.set(this.host, []);
1028
+ };
1029
+ this.handleInteraction = (event) => {
1030
+ const emittedEvents = interactions.get(this.host);
1031
+ if (!emittedEvents.includes(event.type)) {
1032
+ emittedEvents.push(event.type);
1033
+ }
1034
+ // Mark it as user-interacted as soon as all associated events have been emitted
1035
+ if (emittedEvents.length === this.options.assumeInteractionOn.length) {
1036
+ this.setUserInteracted(this.host, true);
1037
+ }
1038
+ };
1039
+ this.checkFormValidity = () => {
1040
+ // console.log('checkFormValidity');
1041
+ //
1042
+ // This is very similar to the `reportFormValidity` function, but it does not trigger native constraint validation
1043
+ // Allow the user to simply check if the form is valid and handling validity in their own way.
1044
+ //
1045
+ // We preserve the original method in a WeakMap, but we don't call it from the overload because that would trigger
1046
+ // validations in an unexpected order. When the element disconnects, we revert to the original behavior. This won't
1047
+ // be necessary once we can use ElementInternals.
1048
+ //
1049
+ // Note that we're also honoring the form's novalidate attribute.
1050
+ //
1051
+ if (this.form && !this.form.noValidate) {
1052
+ // This seems sloppy, but checking all elements will cover native inputs, Shoelace inputs, and other custom
1053
+ // elements that support the constraint validation API.
1054
+ const elements = this.form.querySelectorAll('*');
1055
+ for (const element of elements) {
1056
+ if (typeof element.checkValidity === 'function') {
1057
+ if (!element.checkValidity()) {
1058
+ return false;
1059
+ }
1060
+ }
1061
+ }
1062
+ }
1063
+ return true;
1064
+ };
1065
+ this.reportFormValidity = () => {
1066
+ // console.log('reportFormValidity');
1067
+ //
1068
+ // FormControl work hard to act like regular form controls. They support the Constraint Validation API
1069
+ // and its associated methods such as setCustomValidity() and reportValidity(). However, the HTMLFormElement also
1070
+ // has a reportValidity() method that will trigger validation on all child controls. Since we're not yet using
1071
+ // ElementInternals, we need to overload this method so it looks for any element with the reportValidity() method.
1072
+ //
1073
+ // We preserve the original method in a WeakMap, but we don't call it from the overload because that would trigger
1074
+ // validations in an unexpected order. When the element disconnects, we revert to the original behavior. This won't
1075
+ // be necessary once we can use ElementInternals.
1076
+ //
1077
+ // Note that we're also honoring the form's novalidate attribute.
1078
+ //
1079
+ if (this.form && !this.form.noValidate) {
1080
+ // This seems sloppy, but checking all elements will cover native inputs, Shoelace inputs, and other custom
1081
+ // elements that support the constraint validation API.
1082
+ const elements = this.form.querySelectorAll('*');
1083
+ for (const element of elements) {
1084
+ if (typeof element.reportValidity === 'function') {
1085
+ if (!element.reportValidity()) {
1086
+ return false;
1087
+ }
1088
+ }
1089
+ }
1090
+ }
1091
+ return true;
1092
+ };
1093
+ (this.host = host).addController(this);
1094
+ this.options = {
1095
+ form: (input) => {
1096
+ // If there's a form attribute, use it to find the target form by id
1097
+ // Controls may not always reflect the 'form' property. For example, `<it-button>` doesn't reflect.
1098
+ const formId = input.form;
1099
+ if (formId) {
1100
+ const root = input.getRootNode();
1101
+ const form = root.querySelector(`#${formId}`);
1102
+ if (form) {
1103
+ return form;
1104
+ }
1105
+ }
1106
+ return input.closest('form');
1107
+ },
1108
+ name: (input) => input.name,
1109
+ value: (input) => input.value,
1110
+ disabled: (input) => input.disabled ?? false,
1111
+ reportValidity: (input) => typeof input.reportValidity === 'function' ? input.reportValidity() : true,
1112
+ checkValidity: (input) => (typeof input.checkValidity === 'function' ? input.checkValidity() : true),
1113
+ setValue: (input, value) => {
1114
+ // eslint-disable-next-line no-param-reassign
1115
+ input.value = value;
1116
+ },
1117
+ assumeInteractionOn: ['it-input'],
1118
+ ...options,
1119
+ };
1120
+ }
1121
+ hostConnected() {
1122
+ const form = this.options.form(this.host);
1123
+ if (form) {
1124
+ this.attachForm(form);
1125
+ }
1126
+ // Listen for interactions
1127
+ interactions.set(this.host, []);
1128
+ this.options.assumeInteractionOn.forEach((event) => {
1129
+ this.host.addEventListener(event, this.handleInteraction);
1130
+ });
1131
+ }
1132
+ hostDisconnected() {
1133
+ this.detachForm();
1134
+ // Clean up interactions
1135
+ interactions.delete(this.host);
1136
+ this.options.assumeInteractionOn.forEach((event) => {
1137
+ this.host.removeEventListener(event, this.handleInteraction);
1138
+ });
1139
+ }
1140
+ hostUpdated() {
1141
+ const form = this.options.form(this.host);
1142
+ // Detach if the form no longer exists
1143
+ if (!form) {
1144
+ this.detachForm();
1145
+ }
1146
+ // If the form has changed, reattach it
1147
+ if (form && this.form !== form) {
1148
+ this.detachForm();
1149
+ this.attachForm(form);
1150
+ }
1151
+ if (this.host.hasUpdated) {
1152
+ this.setValidity(this.host.validity.valid);
1153
+ }
1154
+ }
1155
+ attachForm(form) {
1156
+ if (form) {
1157
+ this.form = form;
1158
+ // Add this element to the form's collection
1159
+ if (formCollections.has(this.form)) {
1160
+ formCollections.get(this.form).add(this.host);
1161
+ }
1162
+ else {
1163
+ formCollections.set(this.form, new Set([this.host]));
1164
+ }
1165
+ this.form.addEventListener('formdata', this.handleFormData);
1166
+ this.form.addEventListener('submit', this.handleFormSubmit);
1167
+ this.form.addEventListener('reset', this.handleFormReset);
1168
+ // Overload the form's reportValidity() method so it looks at FormControl
1169
+ if (!reportValidityOverloads.has(this.form)) {
1170
+ reportValidityOverloads.set(this.form, this.form.reportValidity);
1171
+ this.form.reportValidity = () => this.reportFormValidity();
1172
+ }
1173
+ // Overload the form's checkValidity() method so it looks at FormControl
1174
+ if (!checkValidityOverloads.has(this.form)) {
1175
+ checkValidityOverloads.set(this.form, this.form.checkValidity);
1176
+ this.form.checkValidity = () => this.checkFormValidity();
1177
+ }
1178
+ }
1179
+ else {
1180
+ this.form = undefined;
1181
+ }
1182
+ }
1183
+ detachForm() {
1184
+ if (!this.form)
1185
+ return;
1186
+ const formCollection = formCollections.get(this.form);
1187
+ if (!formCollection) {
1188
+ return;
1189
+ }
1190
+ this.submittedOnce = false;
1191
+ // Remove this host from the form's collection
1192
+ formCollection.delete(this.host);
1193
+ // Check to make sure there's no other form controls in the collection. If we do this
1194
+ // without checking if any other controls are still in the collection, then we will wipe out the
1195
+ // validity checks for all other elements.
1196
+ // see: https://github.com/shoelace-style/shoelace/issues/1703
1197
+ if (formCollection.size <= 0) {
1198
+ this.form.removeEventListener('formdata', this.handleFormData);
1199
+ this.form.removeEventListener('submit', this.handleFormSubmit);
1200
+ this.form.removeEventListener('reset', this.handleFormReset);
1201
+ // Remove the overload and restore the original method
1202
+ if (reportValidityOverloads.has(this.form)) {
1203
+ this.form.reportValidity = reportValidityOverloads.get(this.form);
1204
+ reportValidityOverloads.delete(this.form);
1205
+ }
1206
+ if (checkValidityOverloads.has(this.form)) {
1207
+ this.form.checkValidity = checkValidityOverloads.get(this.form);
1208
+ checkValidityOverloads.delete(this.form);
1209
+ }
1210
+ // So it looks weird here to not always set the form to undefined. But I _think_ if we unattach this.form here,
1211
+ // we end up in this fun spot where future validity checks don't have a reference to the form validity handler.
1212
+ // 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.
1213
+ this.form = undefined;
1214
+ }
1215
+ }
1216
+ // eslint-disable-next-line class-methods-use-this
1217
+ setUserInteracted(el, hasInteracted) {
1218
+ if (hasInteracted) {
1219
+ userInteractedControls.add(el);
1220
+ }
1221
+ else {
1222
+ userInteractedControls.delete(el);
1223
+ }
1224
+ el.requestUpdate();
1225
+ }
1226
+ doAction(type, submitter) {
1227
+ // console.log('doaction', type);
1228
+ if (this.form) {
1229
+ const button = document.createElement('button');
1230
+ button.type = type;
1231
+ button.style.position = 'absolute';
1232
+ button.style.width = '0';
1233
+ button.style.height = '0';
1234
+ button.style.clipPath = 'inset(50%)';
1235
+ button.style.overflow = 'hidden';
1236
+ button.style.whiteSpace = 'nowrap';
1237
+ // Pass name, value, and form attributes through to the temporary button
1238
+ if (submitter) {
1239
+ button.name = submitter.name;
1240
+ button.value = submitter.value;
1241
+ ['formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget'].forEach((attr) => {
1242
+ if (submitter.hasAttribute(attr)) {
1243
+ button.setAttribute(attr, submitter.getAttribute(attr));
1244
+ }
1245
+ });
1246
+ }
1247
+ this.form.append(button);
1248
+ button.click();
1249
+ button.remove();
1250
+ }
1251
+ }
1252
+ /** Returns the associated `<form>` element, if one exists. */
1253
+ getForm() {
1254
+ return this.form ?? null;
1255
+ }
1256
+ /** Resets the form, restoring all the control to their default value */
1257
+ reset(submitter) {
1258
+ this.doAction('reset', submitter);
1259
+ }
1260
+ /** Submits the form, triggering validation and form data injection. */
1261
+ submit(submitter) {
1262
+ // Calling form.submit() bypasses the submit event and constraint validation. To prevent this, we can inject a
1263
+ // native submit button into the form, "click" it, then remove it to simulate a standard form submission.
1264
+ this.doAction('submit', submitter);
1265
+ }
1266
+ /**
1267
+ * Synchronously sets the form control's validity. Call this when you know the future validity but need to update
1268
+ * the host element immediately, i.e. before Lit updates the component in the next update.
1269
+ */
1270
+ setValidity(isValid) {
1271
+ const host = this.host;
1272
+ const hasInteracted = Boolean(userInteractedControls.has(host));
1273
+ const required = Boolean(host.required);
1274
+ //
1275
+ // We're mapping the following "states" to data attributes. In the future, we can use ElementInternals.states to
1276
+ // create a similar mapping, but instead of [data-invalid] it will look like :--invalid.
1277
+ //
1278
+ // See this RFC for more details: https://github.com/shoelace-style/shoelace/issues/1011
1279
+ //
1280
+ host.toggleAttribute('data-required', required);
1281
+ host.toggleAttribute('data-optional', !required);
1282
+ host.toggleAttribute('data-invalid', !isValid);
1283
+ host.toggleAttribute('data-valid', isValid);
1284
+ host.toggleAttribute('data-user-invalid', !isValid && hasInteracted);
1285
+ host.toggleAttribute('data-user-valid', isValid && hasInteracted);
1286
+ }
1287
+ userInteracted() {
1288
+ const hasInteracted = Boolean(userInteractedControls.has(this.host));
1289
+ return hasInteracted;
1290
+ }
1291
+ /**
1292
+ * Updates the form control's validity based on the current value of `host.validity.valid`. Call this when anything
1293
+ * that affects constraint validation changes so the component receives the correct validity states.
1294
+ */
1295
+ updateValidity() {
1296
+ const host = this.host;
1297
+ this.setValidity(host.validity.valid);
1298
+ }
1299
+ /**
1300
+ * Dispatches a non-bubbling, cancelable custom event of type `it-invalid`.
1301
+ * If the `it-invalid` event will be cancelled then the original `invalid`
1302
+ * event (which may have been passed as argument) will also be cancelled.
1303
+ * If no original `invalid` event has been passed then the `it-invalid`
1304
+ * event will be cancelled before being dispatched.
1305
+ */
1306
+ emitInvalidEvent(originalInvalidEvent) {
1307
+ const itInvalidEvent = new CustomEvent('it-invalid', {
1308
+ bubbles: false,
1309
+ composed: false,
1310
+ cancelable: true,
1311
+ detail: {},
1312
+ });
1313
+ if (!originalInvalidEvent) {
1314
+ itInvalidEvent.preventDefault();
1315
+ }
1316
+ if (!this.host.dispatchEvent(itInvalidEvent)) {
1317
+ originalInvalidEvent?.preventDefault();
1318
+ }
1319
+ }
1320
+ }
1321
+
1322
+ const translation = {
1323
+ $code: 'it',
1324
+ $name: 'Italiano',
1325
+ $dir: 'ltr',
1326
+ validityRequired: 'Questo campo è obbligatorio.',
1327
+ validityGroupRequired: "Scegli almeno un'opzione",
1328
+ validityPattern: 'Il valore non corrisponde al formato richiesto.',
1329
+ validityMinlength: 'Il valore deve essere lungo almeno {minlength} caratteri.',
1330
+ validityMaxlength: 'Il valore deve essere lungo al massimo {maxlength} caratteri.',
1331
+ };
1332
+
1333
+ registerTranslation(translation);
1334
+ class FormControl extends BaseLocalizedComponent {
1335
+ constructor() {
1336
+ super(...arguments);
1337
+ this.formControlController = new FormControlController(this, {
1338
+ assumeInteractionOn: ['it-input', 'it-blur', 'it-change'],
1339
+ });
1340
+ // TODO: verificare se serve davvero con il fatto che usiamo form-controller
1341
+ // static formAssociated = true;
1342
+ // @property()
1343
+ // internals = this.attachInternals();
1344
+ this._touched = false;
1345
+ /** The name of the input, submitted as a name/value pair with form data. */
1346
+ this.name = '';
1347
+ /** The current value of the input, submitted as a name/value pair with form data. */
1348
+ this.value = '';
1349
+ /** If the input is disabled. */
1350
+ this.disabled = false;
1351
+ /**
1352
+ * By default, form controls are associated with the nearest containing `<form>` element. This attribute allows you
1353
+ * to place the form control outside of a form and associate it with the form that has this `id`. The form must be in
1354
+ * the same document or shadow root for this to work.
1355
+ */
1356
+ this.form = '';
1357
+ /** If you implement your custom validation and you won't to trigger default validation */
1358
+ this.customValidation = false;
1359
+ /** If your input is invalid from your custom validition, set this attribute with message validation */
1360
+ this.validationText = '';
1361
+ /**
1362
+ * Specifies the granularity that the value must adhere to, or the special value `any` which means no stepping is
1363
+ * implied, allowing any numeric value. Only applies to date and number input types.
1364
+ */
1365
+ this.step = 'any';
1366
+ /** The input's minimum length. */
1367
+ this.minlength = -1;
1368
+ /** The input's maximum length. */
1369
+ this.maxlength = -1;
1370
+ /** If the input is required. */
1371
+ this.required = false;
1372
+ /* For grouped input, like checkbox-group */
1373
+ this.isInGroup = false;
1374
+ this.validationMessage = '';
1375
+ }
1376
+ /** Gets the validity state object */
1377
+ get validity() {
1378
+ return this.inputElement?.validity;
1379
+ }
1380
+ /** Gets the associated form, if one exists. */
1381
+ getForm() {
1382
+ return this.formControlController.getForm();
1383
+ }
1384
+ // Form validation methods
1385
+ checkValidity() {
1386
+ const inputValid = this.inputElement?.checkValidity() ?? true; // this.inputElement.checkValidity() è la validazione del browser
1387
+ return inputValid;
1388
+ }
1389
+ /** Checks for validity and shows the browser's validation message if the control is invalid. */
1390
+ reportValidity() {
1391
+ // const ret = this.inputElement.checkValidity();
1392
+ const ret = this.checkValidity(); // chiama la checkValidity, che se è stata overridata chiama quella
1393
+ this.handleValidationMessages();
1394
+ return ret; // this.inputElement.reportValidity();
1395
+ }
1396
+ /** Sets a custom validation message. Pass an empty string to restore validity. */
1397
+ setCustomValidity(message) {
1398
+ this.inputElement.setCustomValidity(message);
1399
+ this.validationMessage = this.inputElement.validationMessage;
1400
+ this.formControlController.updateValidity();
1401
+ }
1402
+ // Handlers
1403
+ _handleReady() {
1404
+ requestAnimationFrame(() => {
1405
+ this.dispatchEvent(new CustomEvent('it-input-ready', { bubbles: true, detail: { el: this.inputElement } }));
1406
+ });
1407
+ }
1408
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1409
+ _handleInput(e) {
1410
+ this.handleValidationMessages();
1411
+ this.dispatchEvent(new CustomEvent('it-input', {
1412
+ detail: { value: this.inputElement.value, el: this.inputElement },
1413
+ bubbles: true,
1414
+ composed: true,
1415
+ }));
1416
+ }
1417
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1418
+ _handleBlur(e) {
1419
+ this._touched = true;
1420
+ this.handleValidationMessages();
1421
+ this.dispatchEvent(new FocusEvent('it-blur', { bubbles: true, composed: true }));
1422
+ }
1423
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1424
+ _handleFocus(e) {
1425
+ this.dispatchEvent(new FocusEvent('it-focus', { bubbles: true, composed: true }));
1426
+ }
1427
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1428
+ _handleClick(e) {
1429
+ this.dispatchEvent(new MouseEvent('it-click', { bubbles: true, composed: true }));
1430
+ }
1431
+ /*
1432
+ Override default browser validation messages
1433
+ */
1434
+ handleValidationMessages() {
1435
+ if (!this.customValidation) {
1436
+ const _v = this.inputElement.validity;
1437
+ const isRequiredHandledByGroup = this.isInGroup === true;
1438
+ if (_v.valueMissing && !isRequiredHandledByGroup) {
1439
+ this.setCustomValidity(this.$t('validityRequired'));
1440
+ }
1441
+ else if (_v.patternMismatch) {
1442
+ this.setCustomValidity(this.$t('validityPattern'));
1443
+ }
1444
+ else if (_v.tooShort) {
1445
+ this.setCustomValidity(this.$t('validityMinlength').replace('{minlength}', this.minlength.toString()));
1446
+ }
1447
+ else if (_v.tooLong) {
1448
+ this.setCustomValidity(this.$t('validityMaxlength').replace('{maxlength}', this.maxlength.toString()));
1449
+ }
1450
+ else {
1451
+ /* nothing. Usa il messaggio di errore della validazione
1452
+ di default del browser per altri errori di validità come:
1453
+ - typeMismatch
1454
+ - rangeUnderflow
1455
+ - rangeOverflow
1456
+ - stepMismatch
1457
+ - badInput */
1458
+ const otherConstraintErrors = _v.typeMismatch || _v.rangeUnderflow || _v.rangeOverflow || _v.stepMismatch || _v.badInput;
1459
+ if (!otherConstraintErrors) {
1460
+ this.setCustomValidity('');
1461
+ }
1462
+ }
1463
+ }
1464
+ this.validationMessage = this.inputElement.validationMessage;
1465
+ }
1466
+ _handleInvalid(event) {
1467
+ this.formControlController.setValidity(false);
1468
+ this.formControlController.emitInvalidEvent(event);
1469
+ }
1470
+ _handleChange(e) {
1471
+ const target = e.target;
1472
+ let value;
1473
+ if (target instanceof HTMLInputElement) {
1474
+ switch (target.type) {
1475
+ case 'checkbox':
1476
+ case 'radio':
1477
+ value = target.checked;
1478
+ break;
1479
+ case 'file':
1480
+ value = target.files; // FileList
1481
+ break;
1482
+ default:
1483
+ value = target.value;
1484
+ }
1485
+ }
1486
+ else if (target instanceof HTMLSelectElement) {
1487
+ if (target.multiple) {
1488
+ value = Array.from(target.selectedOptions).map((o) => o.value);
1489
+ }
1490
+ else {
1491
+ value = target.value;
1492
+ }
1493
+ }
1494
+ else {
1495
+ // textarea o altri input con value
1496
+ value = target.value;
1497
+ }
1498
+ this.dispatchEvent(new CustomEvent('it-change', {
1499
+ detail: { value, el: target },
1500
+ bubbles: true,
1501
+ composed: true,
1502
+ }));
1503
+ }
1504
+ updated(changedProperties) {
1505
+ super.updated?.(changedProperties);
1506
+ if (this.customValidation) {
1507
+ this.setCustomValidity(this.validationText ?? '');
1508
+ }
1509
+ else if (this.formControlController.userInteracted()) {
1510
+ this.formControlController.updateValidity();
1511
+ }
1512
+ }
1513
+ }
1514
+ __decorate([
1515
+ state(),
1516
+ __metadata("design:type", Object)
1517
+ ], FormControl.prototype, "_touched", void 0);
1518
+ __decorate([
1519
+ query('.it-form__control'),
1520
+ __metadata("design:type", HTMLInputElement)
1521
+ ], FormControl.prototype, "inputElement", void 0);
1522
+ __decorate([
1523
+ property({ type: String, reflect: true }) // from FormControl
1524
+ ,
1525
+ __metadata("design:type", Object)
1526
+ ], FormControl.prototype, "name", void 0);
1527
+ __decorate([
1528
+ property({ reflect: true }),
1529
+ __metadata("design:type", Object)
1530
+ ], FormControl.prototype, "value", void 0);
1531
+ __decorate([
1532
+ property({ type: Boolean, reflect: true }) // from FormControl
1533
+ ,
1534
+ __metadata("design:type", Object)
1535
+ ], FormControl.prototype, "disabled", void 0);
1536
+ __decorate([
1537
+ property({ reflect: true, type: String }),
1538
+ __metadata("design:type", Object)
1539
+ ], FormControl.prototype, "form", void 0);
1540
+ __decorate([
1541
+ property({ type: Boolean, reflect: true, attribute: 'custom-validation' }),
1542
+ __metadata("design:type", Object)
1543
+ ], FormControl.prototype, "customValidation", void 0);
1544
+ __decorate([
1545
+ property({ attribute: 'validity-message', reflect: true }),
1546
+ __metadata("design:type", String)
1547
+ ], FormControl.prototype, "validationText", void 0);
1548
+ __decorate([
1549
+ property(),
1550
+ __metadata("design:type", String)
1551
+ ], FormControl.prototype, "pattern", void 0);
1552
+ __decorate([
1553
+ property(),
1554
+ __metadata("design:type", Object)
1555
+ ], FormControl.prototype, "min", void 0);
1556
+ __decorate([
1557
+ property(),
1558
+ __metadata("design:type", Object)
1559
+ ], FormControl.prototype, "max", void 0);
1560
+ __decorate([
1561
+ property(),
1562
+ __metadata("design:type", Object)
1563
+ ], FormControl.prototype, "step", void 0);
1564
+ __decorate([
1565
+ property({ type: Number }),
1566
+ __metadata("design:type", Object)
1567
+ ], FormControl.prototype, "minlength", void 0);
1568
+ __decorate([
1569
+ property({ type: Number }),
1570
+ __metadata("design:type", Object)
1571
+ ], FormControl.prototype, "maxlength", void 0);
1572
+ __decorate([
1573
+ property({ type: Boolean, reflect: true }) // from FormControl
1574
+ ,
1575
+ __metadata("design:type", Object)
1576
+ ], FormControl.prototype, "required", void 0);
1577
+ __decorate([
1578
+ property({ type: Boolean }),
1579
+ __metadata("design:type", Object)
1580
+ ], FormControl.prototype, "isInGroup", void 0);
1581
+ __decorate([
1582
+ state(),
1583
+ __metadata("design:type", Object)
1584
+ ], FormControl.prototype, "validationMessage", void 0);
1585
+
1586
+ class WindowManager {
1587
+ static init() {
1588
+ if (this.initialized)
1589
+ return;
1590
+ this.lastScrollY = window.scrollY;
1591
+ this.lastWidth = window.innerWidth;
1592
+ this.lastHeight = window.innerHeight;
1593
+ window.addEventListener('scroll', () => {
1594
+ this.lastScrollY = window.scrollY;
1595
+ this.requestTick();
1596
+ });
1597
+ window.addEventListener('resize', () => {
1598
+ this.lastWidth = window.innerWidth;
1599
+ this.lastHeight = window.innerHeight;
1600
+ this.requestTick(true); // force recalculation
1601
+ });
1602
+ this.initialized = true;
1603
+ }
1604
+ static requestTick(forceRecalc = false) {
1605
+ if (!this.ticking) {
1606
+ requestAnimationFrame(() => this.tick(forceRecalc));
1607
+ this.ticking = true;
1608
+ }
1609
+ }
1610
+ static tick(forceRecalc) {
1611
+ this.ticking = false;
1612
+ const state = {
1613
+ scrollY: this.lastScrollY,
1614
+ width: this.lastWidth,
1615
+ height: this.lastHeight,
1616
+ };
1617
+ this.subscribers.forEach((cb) => cb(state, forceRecalc));
1618
+ }
1619
+ static subscribe(cb) {
1620
+ this.subscribers.add(cb);
1621
+ }
1622
+ static unsubscribe(cb) {
1623
+ this.subscribers.delete(cb);
1624
+ }
1625
+ /**
1626
+ * Blocca lo scroll del body. Usa ref counting per gestire modal nested.
1627
+ * Chiamare unlockBodyScroll() per ogni lockBodyScroll().
1628
+ */
1629
+ static lockBodyScroll() {
1630
+ this.scrollLockCount += 1;
1631
+ if (this.scrollLockCount === 1) {
1632
+ this.scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
1633
+ document.body.classList.add('modal-open');
1634
+ document.body.style.overflow = 'hidden';
1635
+ document.body.style.paddingRight = `${this.scrollbarWidth}px`;
1636
+ }
1637
+ }
1638
+ /**
1639
+ * Sblocca lo scroll del body. Rimuove il lock solo quando tutti i consumer hanno chiamato unlock.
1640
+ */
1641
+ static unlockBodyScroll() {
1642
+ this.scrollLockCount = Math.max(0, this.scrollLockCount - 1);
1643
+ if (this.scrollLockCount === 0) {
1644
+ document.body.classList.remove('modal-open');
1645
+ document.body.style.overflow = '';
1646
+ document.body.style.paddingRight = '';
1647
+ }
1648
+ }
1649
+ /** Ritorna la larghezza della scrollbar (utile per compensazioni) */
1650
+ static getScrollbarWidth() {
1651
+ return this.scrollbarWidth || window.innerWidth - document.documentElement.clientWidth;
1652
+ }
1653
+ }
1654
+ WindowManager.initialized = false;
1655
+ WindowManager.subscribers = new Set();
1656
+ WindowManager.lastScrollY = 0;
1657
+ WindowManager.lastWidth = 0;
1658
+ WindowManager.lastHeight = 0;
1659
+ WindowManager.ticking = false;
1660
+ // Body scroll lock (ref counting per modal nested)
1661
+ WindowManager.scrollLockCount = 0;
1662
+ WindowManager.scrollbarWidth = 0;
1663
+
1664
+ if (typeof window !== 'undefined') {
1665
+ window._itAnalytics = window._itAnalytics || {};
1666
+ window._itAnalytics = {
1667
+ ...window._itAnalytics,
1668
+ version: '1.0.0-alpha.10',
1669
+ };
1670
+ }
1671
+
1672
+ var styles = css`@charset "UTF-8";
1673
+ /***************************** 1 ****************************************/
1674
+ /***************************** 2 ****************************************/
1675
+ /***************************** 1 ****************************************/
1676
+ /***************************** 2 ****************************************/
1677
+ /***************************** 1 ****************************************/
1678
+ /***************************** 2 ****************************************/
1679
+ /***************************** 3 ****************************************/
1680
+ /***************************** 1 ****************************************/
1681
+ /***************************** 2 ****************************************/
1682
+ /***************************** 3 ****************************************/
1683
+ /***************************** NEUTRAL 1 ****************************************/
1684
+ /***************************** NEUTRAL 2 ****************************************/
1685
+ /***************************** NEUTRAL 2 / 3 ****************************************/
1686
+ .d-none {
1687
+ display: none !important;
1688
+ }
1689
+
1690
+ .d-block {
1691
+ display: block !important;
1692
+ }
1693
+
1694
+ .d-flex {
1695
+ display: flex !important;
1696
+ }
1697
+
1698
+ .overflow-auto {
1699
+ overflow: auto !important;
1700
+ }
1701
+
1702
+ .overflow-hidden {
1703
+ overflow: hidden !important;
1704
+ }
1705
+
1706
+ @media (min-width: 576px) {
1707
+ .d-sm-none {
1708
+ display: none !important;
1709
+ }
1710
+ .d-sm-block {
1711
+ display: block !important;
1712
+ }
1713
+ .d-sm-flex {
1714
+ display: flex !important;
1715
+ }
1716
+ }
1717
+ @media (min-width: 768px) {
1718
+ .d-md-none {
1719
+ display: none !important;
1720
+ }
1721
+ .d-md-block {
1722
+ display: block !important;
1723
+ }
1724
+ .d-md-flex {
1725
+ display: flex !important;
1726
+ }
1727
+ }
1728
+ @media (min-width: 992px) {
1729
+ .d-lg-none {
1730
+ display: none !important;
1731
+ }
1732
+ .d-lg-block {
1733
+ display: block !important;
1734
+ }
1735
+ .d-lg-flex {
1736
+ display: flex !important;
1737
+ }
1738
+ }
1739
+ @media (min-width: 1200px) {
1740
+ .d-xl-none {
1741
+ display: none !important;
1742
+ }
1743
+ .d-xl-block {
1744
+ display: block !important;
1745
+ }
1746
+ .d-xl-flex {
1747
+ display: flex !important;
1748
+ }
1749
+ }
1750
+ @media (min-width: 1400px) {
1751
+ .d-xxl-none {
1752
+ display: none !important;
1753
+ }
1754
+ .d-xxl-block {
1755
+ display: block !important;
1756
+ }
1757
+ .d-xxl-flex {
1758
+ display: flex !important;
1759
+ }
1760
+ }
1761
+ @media print {
1762
+ .d-print-none {
1763
+ display: none !important;
1764
+ }
1765
+ .d-print-block {
1766
+ display: block !important;
1767
+ }
1768
+ .d-print-flex {
1769
+ display: flex !important;
1770
+ }
1771
+ }
1772
+ .modal {
1773
+ --bsi-modal-bg: var(--bsi-color-background-inverse);
1774
+ --bsi-modal-border-color: transparent;
1775
+ --bsi-modal-border-radius: var(--bsi-radius-smooth);
1776
+ --bsi-modal-border-width: 0;
1777
+ --bsi-modal-box-shadow: var(--bsi-elevation-medium);
1778
+ --bsi-modal-footer-bg: transparent;
1779
+ --bsi-modal-footer-border-color: var(--bsi-modal-header-border-color);
1780
+ --bsi-modal-footer-border-width: var(--bsi-modal-header-border-width);
1781
+ --bsi-modal-footer-gap: var(--bsi-spacing-s);
1782
+ --bsi-modal-header-border-color: var(--bsi-color-border-subtle);
1783
+ --bsi-modal-header-border-width: 0;
1784
+ --bsi-modal-inner-border-radius: var(--bsi-radius-smooth);
1785
+ --bsi-modal-margin: auto;
1786
+ --bsi-modal-padding: var(--bsi-spacing-m);
1787
+ --bsi-modal-title-font-size: var(--bsi-heading-5-font-size);
1788
+ --bsi-modal-title-font-weight: var(--bsi-heading-font-weight-weak);
1789
+ --bsi-modal-title-line-height: var(--bsi-heading-line-height);
1790
+ --bsi-modal-transition: transform 0.3s ease-in-out;
1791
+ --bsi-modal-width: 500px;
1792
+ --bsi-modal-zindex: 1055;
1793
+ }
1794
+
1795
+ .modal-dialog {
1796
+ position: relative;
1797
+ width: auto;
1798
+ margin: var(--bsi-modal-margin);
1799
+ pointer-events: none;
1800
+ }
1801
+ .modal.show .modal-dialog {
1802
+ transform: none;
1803
+ }
1804
+ .modal.modal-static .modal-dialog {
1805
+ transform: scale(1.02);
1806
+ }
1807
+
1808
+ .modal-dialog-scrollable {
1809
+ height: calc(100% - var(--bsi-modal-margin) * 2);
1810
+ }
1811
+ .modal-dialog-scrollable .modal-content {
1812
+ max-height: 100%;
1813
+ overflow: hidden;
1814
+ }
1815
+ .modal-dialog-scrollable .modal-body {
1816
+ overflow-y: auto;
1817
+ }
1818
+
1819
+ .modal-dialog-centered {
1820
+ display: flex;
1821
+ align-items: center;
1822
+ min-height: calc(100% - var(--bsi-modal-margin) * 2);
1823
+ }
1824
+
1825
+ .modal-body {
1826
+ position: relative;
1827
+ flex: 1 1 auto;
1828
+ padding: var(--bsi-modal-padding);
1829
+ color: var(--bsi-color-text-base);
1830
+ }
1831
+
1832
+ .modal-content {
1833
+ position: relative;
1834
+ display: flex;
1835
+ flex-direction: column;
1836
+ width: 100%;
1837
+ border: var(--bsi-modal-border-width) solid var(--bsi-modal-border-color);
1838
+ outline: 0;
1839
+ background-color: var(--bsi-modal-bg);
1840
+ pointer-events: auto;
1841
+ background-clip: padding-box;
1842
+ border-radius: var(--bsi-modal-border-radius);
1843
+ }
1844
+
1845
+ .modal-backdrop {
1846
+ --bsi-backdrop-zindex: 1050;
1847
+ --bsi-backdrop-bg: hsl(0, 0%, 0%);
1848
+ --bsi-backdrop-opacity: 0.8;
1849
+ position: fixed;
1850
+ top: 0;
1851
+ left: 0;
1852
+ z-index: var(--bsi-backdrop-zindex);
1853
+ width: 100vw;
1854
+ height: 100vh;
1855
+ background-color: var(--bsi-backdrop-bg);
1856
+ }
1857
+ .modal-backdrop.fade {
1858
+ opacity: 0;
1859
+ }
1860
+ .modal-backdrop.show {
1861
+ opacity: var(--bsi-backdrop-opacity);
1862
+ }
1863
+
1864
+ .modal-header {
1865
+ display: flex;
1866
+ flex-shrink: 0;
1867
+ align-items: center;
1868
+ justify-content: space-between;
1869
+ padding: var(--bsi-modal-padding) var(--bsi-modal-padding) 0;
1870
+ border-bottom: var(--bsi-modal-header-border-width) solid var(--bsi-modal-header-border-color);
1871
+ }
1872
+
1873
+ .modal-footer {
1874
+ position: relative;
1875
+ display: flex;
1876
+ flex-shrink: 0;
1877
+ flex-wrap: wrap;
1878
+ gap: var(--bsi-modal-footer-gap);
1879
+ align-items: center;
1880
+ justify-content: flex-end;
1881
+ padding: 0 var(--bsi-modal-padding) var(--bsi-modal-padding);
1882
+ border-top: var(--bsi-modal-footer-border-width) solid var(--bsi-modal-footer-border-color);
1883
+ background-color: var(--bsi-modal-footer-bg);
1884
+ border-bottom-right-radius: var(--bsi-modal-border-radius);
1885
+ border-bottom-left-radius: var(--bsi-modal-border-radius);
1886
+ }
1887
+ .modal-footer.modal-footer-shadow {
1888
+ box-shadow: 0 15px 25px 5px rgba(0, 0, 0, 0.3);
1889
+ }
1890
+
1891
+ .modal-title {
1892
+ margin-bottom: 0;
1893
+ font-size: var(--bsi-modal-title-font-size);
1894
+ font-weight: var(--bsi-modal-title-font-weight);
1895
+ line-height: var(--bsi-modal-title-line-height);
1896
+ }
1897
+
1898
+ @media (min-width: 576px) {
1899
+ .modal {
1900
+ --bsi-modal-margin: 1.5rem;
1901
+ --bsi-modal-box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
1902
+ }
1903
+ .modal-dialog {
1904
+ max-width: var(--bsi-modal-width);
1905
+ }
1906
+ .modal-sm {
1907
+ --bsi-modal-width: 300px;
1908
+ }
1909
+ }
1910
+ @media (min-width: 992px) {
1911
+ .modal-lg,
1912
+ .modal-xl {
1913
+ --bsi-modal-width: 800px;
1914
+ }
1915
+ }
1916
+ @media (min-width: 1200px) {
1917
+ .modal-xl {
1918
+ --bsi-modal-width: 1140px;
1919
+ }
1920
+ }
1921
+ .modal-fullscreen {
1922
+ width: 100vw;
1923
+ max-width: none;
1924
+ height: 100%;
1925
+ margin: 0;
1926
+ }
1927
+ .modal-fullscreen .modal-content {
1928
+ height: 100%;
1929
+ border: 0;
1930
+ border-radius: 0;
1931
+ }
1932
+ .modal-fullscreen .modal-header,
1933
+ .modal-fullscreen .modal-footer {
1934
+ border-radius: 0;
1935
+ }
1936
+ .modal-fullscreen .modal-body {
1937
+ overflow-y: auto;
1938
+ }
1939
+
1940
+ @media (max-width: 575.98px) {
1941
+ .modal-fullscreen-sm-down {
1942
+ width: 100vw;
1943
+ max-width: none;
1944
+ height: 100%;
1945
+ margin: 0;
1946
+ }
1947
+ .modal-fullscreen-sm-down .modal-content {
1948
+ height: 100%;
1949
+ border: 0;
1950
+ border-radius: 0;
1951
+ }
1952
+ .modal-fullscreen-sm-down .modal-header,
1953
+ .modal-fullscreen-sm-down .modal-footer {
1954
+ border-radius: 0;
1955
+ }
1956
+ .modal-fullscreen-sm-down .modal-body {
1957
+ overflow-y: auto;
1958
+ }
1959
+ }
1960
+ @media (max-width: 767.98px) {
1961
+ .modal-fullscreen-md-down {
1962
+ width: 100vw;
1963
+ max-width: none;
1964
+ height: 100%;
1965
+ margin: 0;
1966
+ }
1967
+ .modal-fullscreen-md-down .modal-content {
1968
+ height: 100%;
1969
+ border: 0;
1970
+ border-radius: 0;
1971
+ }
1972
+ .modal-fullscreen-md-down .modal-header,
1973
+ .modal-fullscreen-md-down .modal-footer {
1974
+ border-radius: 0;
1975
+ }
1976
+ .modal-fullscreen-md-down .modal-body {
1977
+ overflow-y: auto;
1978
+ }
1979
+ }
1980
+ @media (max-width: 991.98px) {
1981
+ .modal-fullscreen-lg-down {
1982
+ width: 100vw;
1983
+ max-width: none;
1984
+ height: 100%;
1985
+ margin: 0;
1986
+ }
1987
+ .modal-fullscreen-lg-down .modal-content {
1988
+ height: 100%;
1989
+ border: 0;
1990
+ border-radius: 0;
1991
+ }
1992
+ .modal-fullscreen-lg-down .modal-header,
1993
+ .modal-fullscreen-lg-down .modal-footer {
1994
+ border-radius: 0;
1995
+ }
1996
+ .modal-fullscreen-lg-down .modal-body {
1997
+ overflow-y: auto;
1998
+ }
1999
+ }
2000
+ @media (max-width: 1199.98px) {
2001
+ .modal-fullscreen-xl-down {
2002
+ width: 100vw;
2003
+ max-width: none;
2004
+ height: 100%;
2005
+ margin: 0;
2006
+ }
2007
+ .modal-fullscreen-xl-down .modal-content {
2008
+ height: 100%;
2009
+ border: 0;
2010
+ border-radius: 0;
2011
+ }
2012
+ .modal-fullscreen-xl-down .modal-header,
2013
+ .modal-fullscreen-xl-down .modal-footer {
2014
+ border-radius: 0;
2015
+ }
2016
+ .modal-fullscreen-xl-down .modal-body {
2017
+ overflow-y: auto;
2018
+ }
2019
+ }
2020
+ @media (max-width: 1399.98px) {
2021
+ .modal-fullscreen-xxl-down {
2022
+ width: 100vw;
2023
+ max-width: none;
2024
+ height: 100%;
2025
+ margin: 0;
2026
+ }
2027
+ .modal-fullscreen-xxl-down .modal-content {
2028
+ height: 100%;
2029
+ border: 0;
2030
+ border-radius: 0;
2031
+ }
2032
+ .modal-fullscreen-xxl-down .modal-header,
2033
+ .modal-fullscreen-xxl-down .modal-footer {
2034
+ border-radius: 0;
2035
+ }
2036
+ .modal-fullscreen-xxl-down .modal-body {
2037
+ overflow-y: auto;
2038
+ }
2039
+ }
2040
+ /* stylelint-disable-next-line no-duplicate-selectors */
2041
+ .modal {
2042
+ position: fixed;
2043
+ top: 0;
2044
+ left: 0;
2045
+ z-index: var(--bsi-modal-zindex);
2046
+ display: none;
2047
+ width: 100%;
2048
+ height: 100%;
2049
+ padding-right: 0 !important;
2050
+ overflow-x: hidden;
2051
+ overflow-y: auto;
2052
+ outline: 0;
2053
+ }
2054
+ .modal.alert-modal .modal-dialog .modal-content .modal-header {
2055
+ align-items: start;
2056
+ justify-content: left;
2057
+ }
2058
+ .modal.alert-modal .modal-dialog .modal-content .modal-header .icon {
2059
+ flex-shrink: 0;
2060
+ margin-right: 16px;
2061
+ fill: hsl(210, 100%, 40%);
2062
+ }
2063
+ .modal.it-dialog-link-list .modal-dialog .modal-content .modal-header {
2064
+ --bsi-modal-header-border-color: var(--bsi-color-border-subtle);
2065
+ --bsi-modal-header-border-width: 1px;
2066
+ padding-bottom: var(--bsi-modal-padding);
2067
+ }
2068
+ .modal.it-dialog-link-list .modal-dialog .modal-content .modal-body .link-list-wrapper .link-list {
2069
+ margin-bottom: 0;
2070
+ padding-bottom: var(--bsi-modal-padding);
2071
+ }
2072
+ .modal.popconfirm-modal .modal-dialog {
2073
+ margin-right: auto;
2074
+ margin-left: auto;
2075
+ }
2076
+ .modal.popconfirm-modal .modal-dialog .modal-body p {
2077
+ font-size: var(--bsi-caption-font-size);
2078
+ line-height: var(--bsi-caption-leading);
2079
+ }
2080
+ .modal.popconfirm-modal .modal-dialog .modal-footer {
2081
+ justify-content: flex-start;
2082
+ }
2083
+ .modal.it-dialog-scrollable .modal-dialog .modal-content {
2084
+ display: flex;
2085
+ flex-direction: column;
2086
+ height: calc(100vh - 208px);
2087
+ border-radius: 0;
2088
+ }
2089
+ .modal.it-dialog-scrollable .modal-dialog .modal-content .modal-header {
2090
+ flex-shrink: 0;
2091
+ padding-bottom: var(--bsi-modal-padding);
2092
+ }
2093
+ .modal.it-dialog-scrollable .modal-dialog .modal-content .modal-body {
2094
+ padding-top: 0;
2095
+ overflow-y: auto;
2096
+ }
2097
+ .modal.it-dialog-scrollable .modal-dialog .modal-content .modal-footer {
2098
+ padding-top: var(--bsi-modal-padding);
2099
+ flex-shrink: 0;
2100
+ }
2101
+ .modal.it-dialog-scrollable .modal-dialog.modal-dialog-left {
2102
+ height: 100vh;
2103
+ margin: 0 var(--bsi-spacing-m) 0 0;
2104
+ }
2105
+ .modal.it-dialog-scrollable .modal-dialog.modal-dialog-left .modal-content {
2106
+ height: 100vh;
2107
+ }
2108
+ .modal.it-dialog-scrollable .modal-dialog.modal-dialog-right {
2109
+ height: 100vh;
2110
+ margin: 0 0 0 var(--bsi-spacing-m);
2111
+ float: right;
2112
+ }
2113
+ .modal.it-dialog-scrollable .modal-dialog.modal-dialog-right .modal-content {
2114
+ height: 100vh;
2115
+ }
2116
+ .modal.fade .modal-dialog {
2117
+ transition: var(--bsi-modal-transition);
2118
+ }
2119
+ @media (prefers-reduced-motion: reduce) {
2120
+ .modal.fade .modal-dialog {
2121
+ transition: none;
2122
+ }
2123
+ }
2124
+ .modal.fade .modal-dialog.modal-dialog-left {
2125
+ transform: translateX(-100%);
2126
+ transition: transform 0.3s ease-in-out;
2127
+ }
2128
+ .modal.fade .modal-dialog.modal-dialog-right {
2129
+ transform: translateX(100%);
2130
+ transition: transform 0.3s ease-in-out;
2131
+ }
2132
+ .modal.fade .modal-dialog.modal-dialog-centered {
2133
+ transform: translate(0, -5%);
2134
+ }
2135
+ .modal.fade.show .modal-dialog.modal-dialog-left {
2136
+ transform: translateX(0);
2137
+ }
2138
+ .modal.fade.show .modal-dialog.modal-dialog-right {
2139
+ transform: translateX(0);
2140
+ }
2141
+ .modal.fade.show .modal-dialog.modal-dialog-centered {
2142
+ transform: translate(0, 0);
2143
+ }
2144
+
2145
+ @media (min-width: 768px) {
2146
+ .modal .modal-dialog {
2147
+ margin-right: auto;
2148
+ margin-left: auto;
2149
+ }
2150
+ .modal .modal-dialog.modal-dialog-left {
2151
+ margin: 0;
2152
+ }
2153
+ .modal .modal-dialog.modal-dialog-left .modal-content {
2154
+ height: 100vh;
2155
+ }
2156
+ .modal .modal-dialog.modal-dialog-right {
2157
+ margin: 0;
2158
+ float: right;
2159
+ }
2160
+ .modal .modal-dialog.modal-dialog-right .modal-content {
2161
+ height: 100vh;
2162
+ }
2163
+ .modal.it-dialog-scrollable .modal-dialog {
2164
+ margin: 64px auto;
2165
+ }
2166
+ .modal.it-dialog-scrollable .modal-dialog .modal-content {
2167
+ height: calc(100vh - 128px);
2168
+ }
2169
+ }
2170
+ body {
2171
+ font-family: var(--bsi-font-sans);
2172
+ }
2173
+
2174
+ p,
2175
+ ul,
2176
+ ol,
2177
+ dl {
2178
+ font-size: var(--bsi-body-font-size);
2179
+ line-height: var(--bsi-body-leading);
2180
+ }
2181
+
2182
+ caption,
2183
+ figcaption {
2184
+ font-size: var(--bsi-caption-font-size);
2185
+ line-height: var(--bsi-caption-leading);
2186
+ }
2187
+
2188
+ b,
2189
+ strong {
2190
+ font-weight: var(--bsi-font-weight-strong);
2191
+ }
2192
+
2193
+ mark,
2194
+ code {
2195
+ padding: 0 var(--bsi-spacing-3xs);
2196
+ }
2197
+
2198
+ mark {
2199
+ background-color: var(--bsi-highlight-background);
2200
+ }
2201
+
2202
+ pre,
2203
+ code,
2204
+ kbd,
2205
+ samp {
2206
+ border-radius: var(--bsi-radius-smooth);
2207
+ font-family: var(--bsi-font-mono);
2208
+ }
2209
+
2210
+ ins,
2211
+ del {
2212
+ position: relative;
2213
+ display: flex;
2214
+ align-items: center;
2215
+ padding: var(--bsi-spacing-3xs) var(--bsi-spacing-m);
2216
+ font: var(--bsi-body-font-size);
2217
+ text-decoration: none;
2218
+ }
2219
+
2220
+ ins {
2221
+ background-color: var(--bsi-ins-background);
2222
+ text-decoration: none;
2223
+ }
2224
+
2225
+ del {
2226
+ background-color: var(--bsi-del-background);
2227
+ }
2228
+
2229
+ del::before,
2230
+ ins::before {
2231
+ position: absolute;
2232
+ left: 0.5rem;
2233
+ }
2234
+
2235
+ del::before {
2236
+ content: "−";
2237
+ }
2238
+
2239
+ ins::before {
2240
+ content: "+";
2241
+ }
2242
+
2243
+ kbd {
2244
+ margin: 0 2px;
2245
+ padding: 2px var(--bsi-spacing-3xs);
2246
+ border: var(--bsi-border-base) solid var(--bsi-color-border-subtle);
2247
+ background-color: var(--bsi-color-background-secondary-lighter);
2248
+ box-shadow: var(--bsi-elevation-low), 0 2px 0 0 hsla(255, 0%, 100%, 0.7) inset;
2249
+ color: var(--bsi-color-text-secondary);
2250
+ font-size: var(--bsi-font-size-1);
2251
+ font-weight: var(--bsi-font-weight-solid);
2252
+ white-space: nowrap;
2253
+ }
2254
+ kbd kbd {
2255
+ padding: 0;
2256
+ font-size: var(--bsi-code-font-size);
2257
+ }
2258
+
2259
+ small,
2260
+ .small {
2261
+ font-size: var(--bsi-caption-font-size);
2262
+ }
2263
+
2264
+ .x-small {
2265
+ font-size: var(--bsi-font-size-1);
2266
+ }
2267
+
2268
+ h1,
2269
+ .h1 {
2270
+ font-size: var(--bsi-heading-1-font-size);
2271
+ }
2272
+
2273
+ h2,
2274
+ .h2 {
2275
+ font-size: var(--bsi-heading-2-font-size);
2276
+ }
2277
+
2278
+ h3,
2279
+ .h3 {
2280
+ font-size: var(--bsi-heading-3-font-size);
2281
+ }
2282
+
2283
+ h4,
2284
+ .h4 {
2285
+ font-size: var(--bsi-heading-4-font-size);
2286
+ }
2287
+
2288
+ h5,
2289
+ .h5 {
2290
+ font-size: var(--bsi-heading-5-font-size);
2291
+ }
2292
+
2293
+ h6,
2294
+ .h6 {
2295
+ font-size: var(--bsi-heading-6-font-size);
2296
+ }
2297
+
2298
+ h1,
2299
+ .h1,
2300
+ h2,
2301
+ .h2,
2302
+ h3,
2303
+ .h3,
2304
+ h4,
2305
+ .h4,
2306
+ h5,
2307
+ .h5,
2308
+ h6,
2309
+ .h6 {
2310
+ margin-top: 0;
2311
+ margin-bottom: var(--bsi-heading-spacing);
2312
+ line-height: var(--bsi-heading-leading);
2313
+ }
2314
+ :is(h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6) + h1, p + h1,
2315
+ :is(h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6) + .h1,
2316
+ p + .h1,
2317
+ :is(h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6) + h2,
2318
+ p + h2,
2319
+ :is(h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6) + .h2,
2320
+ p + .h2,
2321
+ :is(h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6) + h3,
2322
+ p + h3,
2323
+ :is(h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6) + .h3,
2324
+ p + .h3,
2325
+ :is(h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6) + h4,
2326
+ p + h4,
2327
+ :is(h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6) + .h4,
2328
+ p + .h4,
2329
+ :is(h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6) + h5,
2330
+ p + h5,
2331
+ :is(h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6) + .h5,
2332
+ p + .h5,
2333
+ :is(h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6) + h6,
2334
+ p + h6,
2335
+ :is(h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6) + .h6,
2336
+ p + .h6 {
2337
+ padding-top: var(--bsi-spacing-s);
2338
+ }
2339
+
2340
+ h1,
2341
+ h2,
2342
+ h3,
2343
+ .h1,
2344
+ .h2,
2345
+ .h3 {
2346
+ font-weight: var(--bsi-heading-font-weight);
2347
+ }
2348
+
2349
+ h4,
2350
+ h5,
2351
+ h6,
2352
+ .h4,
2353
+ .h5,
2354
+ .h6 {
2355
+ font-weight: var(--bsi-heading-font-weight-weak);
2356
+ }
2357
+
2358
+ h1,
2359
+ .h1,
2360
+ .display-1 {
2361
+ letter-spacing: -1px;
2362
+ }
2363
+
2364
+ .font-serif {
2365
+ font-family: var(--bsi-font-serif) !important;
2366
+ }
2367
+
2368
+ .font-sans-serif {
2369
+ font-family: var(--bsi-font-sans) !important;
2370
+ }
2371
+
2372
+ .font-monospace {
2373
+ font-family: var(--bsi-font-mono) !important;
2374
+ }
2375
+
2376
+ .display-1 {
2377
+ font-size: var(--bsi-display-font-size);
2378
+ font-weight: var(--bsi-heading-font-weight);
2379
+ line-height: var(--bsi-heading-leading);
2380
+ }
2381
+
2382
+ .lead {
2383
+ font-size: var(--bsi-lead-font-size);
2384
+ font-weight: var(--bsi-lead-font-weight);
2385
+ line-height: var(--bsi-lead-leading);
2386
+ }
2387
+
2388
+ blockquote,
2389
+ .blockquote {
2390
+ margin: var(--bsi-spacing-m) 0;
2391
+ margin-left: var(--bsi-spacin-inline-xs);
2392
+ padding: var(--bsi-spacing-s);
2393
+ border-left: var(--bsi-border-thick) solid var(--bsi-border-color-secondary);
2394
+ font-size: var(--bsi-body-font-size);
2395
+ line-height: var(--bsi-body-leading);
2396
+ }
2397
+ blockquote > :last-child,
2398
+ .blockquote > :last-child {
2399
+ margin-bottom: 0;
2400
+ }
2401
+ blockquote.text-end,
2402
+ .blockquote.text-end {
2403
+ margin-right: var(--bsi-spacin-inline-xs);
2404
+ border-right: var(--bsi-border-thick) solid var(--bsi-border-color-secondary);
2405
+ }
2406
+ blockquote.text-center, blockquote.text-end, blockquote.blockquote-simple,
2407
+ .blockquote.text-center,
2408
+ .blockquote.text-end,
2409
+ .blockquote.blockquote-simple {
2410
+ margin-left: 0;
2411
+ border-right: none;
2412
+ border-left: none;
2413
+ }
2414
+ blockquote.text-center, blockquote.blockquote-simple,
2415
+ .blockquote.text-center,
2416
+ .blockquote.blockquote-simple {
2417
+ padding: 0;
2418
+ }
2419
+ blockquote.blockquote-simple,
2420
+ .blockquote.blockquote-simple {
2421
+ font-style: italic;
2422
+ }
2423
+ blockquote.blockquote-card,
2424
+ .blockquote.blockquote-card {
2425
+ margin-left: 0;
2426
+ padding: var(--bsi-spacing-m);
2427
+ background-color: var(--bsi-color-background-inverse);
2428
+ box-shadow: var(--bsi-elevation-low);
2429
+ }
2430
+ blockquote.blockquote-card .blockquote-footer,
2431
+ .blockquote.blockquote-card .blockquote-footer {
2432
+ font-size: inherit;
2433
+ }
2434
+ blockquote.blockquote-card .blockquote-footer:before,
2435
+ .blockquote.blockquote-card .blockquote-footer:before {
2436
+ content: none;
2437
+ }
2438
+ blockquote.blockquote-card.dark,
2439
+ .blockquote.blockquote-card.dark {
2440
+ border-left: none;
2441
+ background-color: var(--bsi-color-background-primary);
2442
+ color: var(--bsi-color-text-inverse);
2443
+ }
2444
+ blockquote.blockquote-card.dark .blockquote-footer,
2445
+ .blockquote.blockquote-card.dark .blockquote-footer {
2446
+ color: var(--bsi-color-text-inverse);
2447
+ }
2448
+
2449
+ .blockquote-footer {
2450
+ margin-top: 0;
2451
+ margin-bottom: var(--bsi-spacing-s);
2452
+ color: var(--bsi-color-text-secondary);
2453
+ font-size: var(--bsi-label-font-size);
2454
+ }
2455
+ .blockquote-footer::before {
2456
+ content: "— ";
2457
+ }
2458
+ .bg-dark .blockquote-footer {
2459
+ color: var(--bsi-color-text-muted);
2460
+ }
2461
+
2462
+ .initialism {
2463
+ font-size: var(--bsi-label-font-size-s);
2464
+ text-transform: uppercase;
2465
+ }
2466
+
2467
+ .visually-hidden,
2468
+ .visually-hidden-focusable:not(:focus):not(:focus-within) {
2469
+ position: absolute !important;
2470
+ width: 1px !important;
2471
+ height: 1px !important;
2472
+ padding: 0 !important;
2473
+ margin: -1px !important;
2474
+ overflow: hidden !important;
2475
+ clip: rect(0, 0, 0, 0) !important;
2476
+ white-space: nowrap !important;
2477
+ border: 0 !important;
2478
+ }
2479
+
2480
+ :host {
2481
+ display: block;
2482
+ --it-focus-ring-safari-fix: none;
2483
+ }
2484
+
2485
+ /* Rimuovi il flash visivo solo durante l'apertura programmata */
2486
+ [part=modal]:focus {
2487
+ box-shadow: var(--it-focus-ring-safari-fix) !important;
2488
+ outline: var(--it-focus-ring-safari-fix) !important;
2489
+ }
2490
+
2491
+ [role=dialog]:focus,
2492
+ [role=dialog]:focus-visible,
2493
+ .btn-close:focus:not(:focus-visible) {
2494
+ box-shadow: none !important;
2495
+ outline: 0 !important;
2496
+ }
2497
+
2498
+ .btn-close:focus-visible {
2499
+ outline: 2px solid var(--it-focus-color) !important;
2500
+ }
2501
+
2502
+ :host(:not([open])) .modal,
2503
+ :host(:not([open])) .modal-backdrop {
2504
+ display: none !important;
2505
+ }
2506
+
2507
+ .modal-backdrop {
2508
+ position: fixed;
2509
+ z-index: 1050;
2510
+ top: 0;
2511
+ left: 0;
2512
+ width: 100vw;
2513
+ height: 100vh;
2514
+ background-color: hsl(0, 0%, 0%);
2515
+ }
2516
+
2517
+ .modal {
2518
+ position: fixed;
2519
+ z-index: 1055;
2520
+ top: 0;
2521
+ left: 0;
2522
+ display: flex;
2523
+ width: 100%;
2524
+ height: 100%;
2525
+ outline: 0;
2526
+ overflow-x: hidden;
2527
+ overflow-y: auto;
2528
+ }
2529
+
2530
+ :host([close-button-placement=backdrop]) .btn-close[part~=close-button] {
2531
+ --bsi-icon-default: white;
2532
+ position: absolute;
2533
+ top: 1rem;
2534
+ right: -2.5rem;
2535
+ }
2536
+
2537
+ .it-dialog-scrollable {
2538
+ overflow-y: hidden;
2539
+ }
2540
+
2541
+ .modal-dialog {
2542
+ height: fit-content;
2543
+ }
2544
+ @media (min-width: 768px) {
2545
+ .modal-dialog {
2546
+ margin: 64px auto;
2547
+ }
2548
+ }
2549
+
2550
+ .modal-footer {
2551
+ flex-shrink: 0;
2552
+ padding-top: var(--bsi-modal-padding);
2553
+ }
2554
+
2555
+ .modal-dialog-scrollable {
2556
+ height: unset;
2557
+ }
2558
+
2559
+ .modal-dialog-centered {
2560
+ min-height: unset;
2561
+ margin: auto;
2562
+ }
2563
+
2564
+ .modal.alert-modal .modal-dialog .modal-content .modal-header {
2565
+ align-items: center;
2566
+ justify-content: space-between;
2567
+ gap: var(--it-spacing-2x);
2568
+ }
2569
+
2570
+ .modal.it-dialog-scrollable .modal-dialog.modal-dialog-right {
2571
+ position: fixed;
2572
+ right: 0;
2573
+ }`;
2574
+
2575
+ /**
2576
+ * Componente Modal per finestre di dialogo modali.
2577
+ *
2578
+ * @element it-modal
2579
+ *
2580
+ * @slot trigger - Elemento che apre la modale (es. it-button)
2581
+ * @slot content - Contenuto principale della modale (body)
2582
+ * @slot header-icon - Icona opzionale nell'header
2583
+ * @slot footer - Azioni del footer (pulsanti)
2584
+ *
2585
+ * @fires it-modal-open - Quando la modale si apre
2586
+ * @fires it-modal-close - Quando la modale si chiude
2587
+ *
2588
+ * @prop {string} close-button-placement - Posizione del pulsante di chiusura: `header` (default) o `backdrop` (sopra lo sfondo scuro, utile per menu offcanvas)
2589
+ */
2590
+ const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
2591
+ let ItModal = class ItModal extends BaseComponent {
2592
+ get _triggerElement() {
2593
+ const elements = this._triggerSlot?.assignedElements({ flatten: true });
2594
+ return elements?.[0] || null;
2595
+ }
2596
+ constructor() {
2597
+ super();
2598
+ this.open = undefined;
2599
+ this.modalTitle = '';
2600
+ this.modalDescription = '';
2601
+ this.customHeader = false;
2602
+ this.size = '';
2603
+ this.scrollable = false;
2604
+ this.staticBackdrop = false;
2605
+ this.hideCloseButton = false;
2606
+ this.closeButtonPlacement = 'header';
2607
+ this.itAriaLabel = '';
2608
+ this.closeLabel = '';
2609
+ this.disableAnimation = false;
2610
+ this.footerShadow = false;
2611
+ this._titleId = '';
2612
+ this._triggerId = '';
2613
+ this._descriptionId = '';
2614
+ this.isAnimating = false;
2615
+ this._isSelfClosing = false;
2616
+ this._originalTrigger = null;
2617
+ this._safariMouseInteraction = false;
2618
+ this._dialogAnimationDuration = 300;
2619
+ this._backdropAnimationDuration = 150;
2620
+ this._inertElements = [];
2621
+ this._triggerPointerBefore = null;
2622
+ /** Timer ID for the focus-restore call in finishHide. Cancelled on reconnect/unmount
2623
+ * to prevent a stale focus from a previous close cycle firing during a new open. */
2624
+ this._restoreFocusTimer = null;
2625
+ // eslint-disable-next-line class-methods-use-this
2626
+ this._handleDialogClick = (event) => {
2627
+ const path = event.composedPath();
2628
+ // Check that is not footer or react synthetic events break on buttons
2629
+ const isInFooter = path.some((el) => el instanceof HTMLElement && el.slot === 'footer');
2630
+ if (!isInFooter) {
2631
+ event.stopPropagation(); // solo per backdrop
2632
+ }
2633
+ };
2634
+ this._handleBackdropClick = () => {
2635
+ if (!this.staticBackdrop) {
2636
+ this.hide();
2637
+ }
2638
+ };
2639
+ this._onTriggerSlotChange = () => {
2640
+ this._setupTriggerListeners();
2641
+ };
2642
+ this._onHeaderSlotChange = () => {
2643
+ this.requestUpdate();
2644
+ };
2645
+ this._onTriggerClick = async (event) => {
2646
+ event.stopPropagation();
2647
+ const trigger = this._triggerElement;
2648
+ if (!trigger)
2649
+ return;
2650
+ if (isSafari) {
2651
+ this._safariMouseInteraction = true;
2652
+ }
2653
+ await this.updateComplete; // Assicurati che l'update sia completo prima di applicare il focus workaround
2654
+ this.show();
2655
+ };
2656
+ this._onTriggerKeydown = async (event) => {
2657
+ if (event.key === 'Enter' || event.key === ' ') {
2658
+ event.preventDefault();
2659
+ this.show();
2660
+ }
2661
+ else {
2662
+ const trigger = this._triggerElement;
2663
+ if (!trigger)
2664
+ return;
2665
+ if (isSafari) {
2666
+ this._safariMouseInteraction = false;
2667
+ }
2668
+ await this.updateComplete; // Assicurati che l'update sia completo prima di applicare il focus workaround
2669
+ }
2670
+ };
2671
+ this._triggerId = this.generateId('modal-trigger');
2672
+ this._titleId = this.generateId('modal-title');
2673
+ this._descriptionId = this.generateId('modal-description');
2674
+ this._focusTrap = new FocusTrapController(this, {
2675
+ getContainer: () => this._modalElement,
2676
+ initialFocus: () => this._modalElement,
2677
+ getTrigger: () => this._triggerElement,
2678
+ onEscape: () => {
2679
+ this._safariMouseInteraction = false;
2680
+ this.hide();
2681
+ },
2682
+ });
2683
+ }
2684
+ connectedCallback() {
2685
+ super.connectedCallback?.();
2686
+ }
2687
+ disconnectedCallback() {
2688
+ super.disconnectedCallback?.();
2689
+ this._removeTriggerListeners();
2690
+ this._cleanupAnimations();
2691
+ this._removeInert();
2692
+ if (this._restoreFocusTimer !== null) {
2693
+ clearTimeout(this._restoreFocusTimer);
2694
+ this._restoreFocusTimer = null;
2695
+ }
2696
+ WindowManager.unlockBodyScroll();
2697
+ }
2698
+ show() {
2699
+ if (this.open || this.isAnimating)
2700
+ return;
2701
+ this._originalTrigger = this._triggerElement;
2702
+ this.dispatchEvent(new CustomEvent('it-modal-open', { detail: { modal: this }, bubbles: true, composed: true }));
2703
+ this.open = true;
2704
+ }
2705
+ hide() {
2706
+ if (!this.open || this.isAnimating)
2707
+ return;
2708
+ this.dispatchEvent(new CustomEvent('it-modal-close', { detail: { modal: this }, bubbles: true, composed: true }));
2709
+ this._hideModal();
2710
+ }
2711
+ toggle() {
2712
+ this.open = !this.open;
2713
+ }
2714
+ updated(changedProperties) {
2715
+ if (changedProperties.has('open')) {
2716
+ if (this._isSelfClosing) {
2717
+ this._isSelfClosing = false;
2718
+ return;
2719
+ }
2720
+ this._cleanupAnimations();
2721
+ if (this.open !== undefined) {
2722
+ if (this.open)
2723
+ this._showModal();
2724
+ else
2725
+ this._hideModal();
2726
+ }
2727
+ }
2728
+ if (changedProperties.has('_safariMouseInteraction')) {
2729
+ let realButton = this._triggerElement;
2730
+ if (realButton?.tagName.toLowerCase() === 'it-button') {
2731
+ realButton = this._triggerElement?.shadowRoot?.querySelector('button');
2732
+ }
2733
+ if (!realButton)
2734
+ return;
2735
+ // Fix Safari: se l'interazione è da mouse, rimuovi outline e box-shadow forzati per evitare il doppio focus ring
2736
+ if (this._safariMouseInteraction) {
2737
+ realButton.style.setProperty('outline', '0', 'important');
2738
+ realButton.style.setProperty('box-shadow', 'none', 'important');
2739
+ }
2740
+ else {
2741
+ realButton.style.removeProperty('outline');
2742
+ realButton.style.removeProperty('box-shadow');
2743
+ }
2744
+ }
2745
+ }
2746
+ _applyInert() {
2747
+ this._removeInert();
2748
+ const trigger = this._triggerElement;
2749
+ if (trigger) {
2750
+ this._triggerPointerBefore = trigger.style.pointerEvents;
2751
+ trigger.style.pointerEvents = 'none';
2752
+ trigger.setAttribute('inert', '');
2753
+ if (trigger.tagName.toLowerCase().startsWith('it-')) {
2754
+ trigger.setAttribute('it-inert', '');
2755
+ }
2756
+ }
2757
+ const ignored = new Set(['SCRIPT', 'STYLE', 'TEMPLATE', 'LINK']);
2758
+ for (let cur = this; cur && cur !== document.body; cur = cur.parentElement) {
2759
+ const parent = cur.parentElement;
2760
+ if (!parent)
2761
+ break;
2762
+ Array.from(parent.children).forEach((node) => {
2763
+ if (node !== cur && !ignored.has(node.tagName) && node instanceof HTMLElement) {
2764
+ node.setAttribute('inert', '');
2765
+ // // FIX FOR SAFARI/VOICEOVER:
2766
+ // // If it's a web component with a shadow root, VoiceOver might still
2767
+ // // find the inner button.
2768
+ if (node.shadowRoot && isSafari) {
2769
+ node.setAttribute('inert', '');
2770
+ node.setAttribute('it-inert', '');
2771
+ }
2772
+ this._inertElements.push(node);
2773
+ }
2774
+ });
2775
+ }
2776
+ }
2777
+ _removeInert() {
2778
+ this._inertElements.forEach((el) => {
2779
+ el.removeAttribute('inert');
2780
+ el.removeAttribute('it-inert');
2781
+ });
2782
+ if (this._triggerElement && this._triggerPointerBefore !== null) {
2783
+ this._triggerElement.style.pointerEvents = this._triggerPointerBefore;
2784
+ this._triggerElement.removeAttribute('inert');
2785
+ this._triggerElement.removeAttribute('it-inert');
2786
+ }
2787
+ this._inertElements = [];
2788
+ this._triggerPointerBefore = null;
2789
+ }
2790
+ async _showModal() {
2791
+ if (this.isAnimating)
2792
+ return;
2793
+ // Cancel any stale close-focus-restore timer so it doesn't fire during the new open.
2794
+ if (this._restoreFocusTimer !== null) {
2795
+ clearTimeout(this._restoreFocusTimer);
2796
+ this._restoreFocusTimer = null;
2797
+ }
2798
+ this.isAnimating = true;
2799
+ this._applyInert();
2800
+ WindowManager.lockBodyScroll();
2801
+ // ASPETTA LIT o race conditions solo per Safari
2802
+ await this.updateComplete;
2803
+ requestAnimationFrame(() => {
2804
+ // Determine transform based on position
2805
+ let dialogStartTransform = 'translate(0, 0)'; // default: no transform
2806
+ if (this.position === 'center') {
2807
+ dialogStartTransform = 'translate(0, -5%)';
2808
+ }
2809
+ else if (this.position === 'left') {
2810
+ dialogStartTransform = 'translateX(-100%)';
2811
+ }
2812
+ else if (this.position === 'right') {
2813
+ dialogStartTransform = 'translateX(100%)';
2814
+ }
2815
+ const dialogDuration = !this.disableAnimation && !this.prefersReducedMotion ? this._dialogAnimationDuration : 0;
2816
+ const backdropDuration = !this.disableAnimation && !this.prefersReducedMotion ? this._backdropAnimationDuration : 0;
2817
+ // Animate backdrop fade in
2818
+ if (this._backdropElement) {
2819
+ this._backdropAnimation = this._backdropElement.animate([{ opacity: '0' }, { opacity: '0.8' }], {
2820
+ duration: backdropDuration,
2821
+ easing: 'linear',
2822
+ fill: 'forwards',
2823
+ });
2824
+ }
2825
+ // Animate dialog transform (slide/drop in)
2826
+ if (this._dialogElement && dialogDuration > 0) {
2827
+ this._dialogAnimation = this._dialogElement.animate([{ transform: dialogStartTransform }, { transform: 'translate(0, 0)' }], {
2828
+ duration: dialogDuration,
2829
+ easing: 'ease-in-out',
2830
+ fill: 'forwards',
2831
+ });
2832
+ this._dialogAnimation.finished
2833
+ .then(() => {
2834
+ if (this.open) {
2835
+ this._focusTrap.activate();
2836
+ }
2837
+ })
2838
+ .finally(() => {
2839
+ this.isAnimating = false;
2840
+ });
2841
+ }
2842
+ else {
2843
+ // No animation: activate immediately. The 50ms inside activate()'s setTimeout
2844
+ // gives VoiceOver iOS enough time to settle its accessibility tree.
2845
+ // See FocusTrapController class comment for full rationale.
2846
+ this._focusTrap.activate();
2847
+ this.isAnimating = false;
2848
+ }
2849
+ });
2850
+ }
2851
+ _hideModal() {
2852
+ if (this.isAnimating)
2853
+ return;
2854
+ this.isAnimating = true;
2855
+ // Determine end transform based on position
2856
+ let dialogEndTransform = 'translate(0, 0)'; // default: no transform
2857
+ let dialogCloseDuration = this._dialogAnimationDuration / 1.33;
2858
+ if (this.position === 'center') {
2859
+ dialogEndTransform = 'translate(0, -5%)';
2860
+ // Dialog più veloce quando è centrato per una chiusura più reattiva
2861
+ dialogCloseDuration = this._dialogAnimationDuration / 2;
2862
+ }
2863
+ else if (this.position === 'left') {
2864
+ dialogEndTransform = 'translateX(-100%)';
2865
+ }
2866
+ else if (this.position === 'right') {
2867
+ dialogEndTransform = 'translateX(100%)';
2868
+ }
2869
+ const dialogDuration = !this.disableAnimation && !this.prefersReducedMotion ? dialogCloseDuration : 0;
2870
+ const backdropDuration = !this.disableAnimation && !this.prefersReducedMotion ? this._backdropAnimationDuration / 1.33 : 0;
2871
+ const finishHide = () => {
2872
+ const target = this._originalTrigger ?? this._triggerElement;
2873
+ this._removeInert();
2874
+ this._cleanupAnimations();
2875
+ // skipFocusRestore: we manage focus restore ourselves with the timer below.
2876
+ // Without this, _restoreFocus() fires at 0ms and the timer fires at 20ms,
2877
+ // causing VoiceOver to announce the restored element twice.
2878
+ this._focusTrap.deactivate({ skipFocusRestore: true });
2879
+ WindowManager.unlockBodyScroll();
2880
+ this._isSelfClosing = true;
2881
+ this.isAnimating = false;
2882
+ this.open = false;
2883
+ if (target) {
2884
+ this._restoreFocusTimer = setTimeout(() => {
2885
+ this._restoreFocusTimer = null;
2886
+ if (!this.open)
2887
+ target.focus({ preventScroll: true });
2888
+ }, 20);
2889
+ }
2890
+ this._originalTrigger = null;
2891
+ if (isSafari)
2892
+ this._safariMouseInteraction = false;
2893
+ };
2894
+ // Animate dialog and backdrop in parallel for smoother close
2895
+ const animations = [];
2896
+ if (this._dialogElement && dialogDuration > 0) {
2897
+ this._dialogAnimation = this._dialogElement.animate([
2898
+ { transform: 'translate(0, 0)', opacity: '1' },
2899
+ { transform: dialogEndTransform, opacity: '0' },
2900
+ ], {
2901
+ duration: dialogDuration,
2902
+ easing: 'ease-in',
2903
+ fill: 'forwards',
2904
+ });
2905
+ animations.push(this._dialogAnimation.finished);
2906
+ }
2907
+ if (this._backdropElement && backdropDuration > 0) {
2908
+ this._backdropAnimation = this._backdropElement.animate([{ opacity: '0.8' }, { opacity: '0' }], {
2909
+ duration: backdropDuration,
2910
+ easing: 'linear',
2911
+ fill: 'forwards',
2912
+ });
2913
+ animations.push(this._backdropAnimation.finished);
2914
+ }
2915
+ if (animations.length > 0) {
2916
+ Promise.all(animations)
2917
+ .then(() => finishHide())
2918
+ .catch(() => {
2919
+ // Animation was cancelled
2920
+ finishHide();
2921
+ })
2922
+ .finally(() => {
2923
+ this.isAnimating = false;
2924
+ });
2925
+ }
2926
+ else {
2927
+ // No animation, finish immediately
2928
+ finishHide();
2929
+ }
2930
+ }
2931
+ _cleanupAnimations() {
2932
+ this._dialogAnimation?.cancel();
2933
+ this._backdropAnimation?.cancel();
2934
+ this._dialogAnimation = undefined;
2935
+ this._backdropAnimation = undefined;
2936
+ }
2937
+ _setupTriggerListeners() {
2938
+ const trigger = this._triggerElement;
2939
+ if (!trigger)
2940
+ return;
2941
+ trigger.setAttribute('id', this._triggerId);
2942
+ // Rimuovi eventuali listener precedenti
2943
+ trigger.removeEventListener('click', this._onTriggerClick);
2944
+ trigger.removeEventListener('keydown', this._onTriggerKeydown);
2945
+ // Aggiungi nuovi listener
2946
+ trigger.addEventListener('click', this._onTriggerClick);
2947
+ trigger.addEventListener('keydown', this._onTriggerKeydown);
2948
+ }
2949
+ _removeTriggerListeners() {
2950
+ const trigger = this._triggerElement;
2951
+ if (!trigger)
2952
+ return;
2953
+ trigger.removeEventListener('click', this._onTriggerClick);
2954
+ trigger.removeEventListener('keydown', this._onTriggerKeydown);
2955
+ }
2956
+ get _modalClasses() {
2957
+ return {
2958
+ modal: true,
2959
+ fade: !this.disableAnimation,
2960
+ show: Boolean(this.open) && !this.disableAnimation,
2961
+ 'alert-modal': this.variant === 'alert',
2962
+ 'popconfirm-modal': this.variant === 'popconfirm',
2963
+ 'it-dialog-link-list': this.variant === 'link-list',
2964
+ 'it-dialog-scrollable': this.scrollable || this.position === 'left' || this.position === 'right',
2965
+ };
2966
+ }
2967
+ get _modalBodyClasses() {
2968
+ return {
2969
+ 'modal-dialog': true,
2970
+ 'modal-dialog-centered': this.position === 'center',
2971
+ 'modal-dialog-left': this.position === 'left',
2972
+ 'modal-dialog-right': this.position === 'right',
2973
+ 'modal-dialog-scrollable': this.scrollable,
2974
+ 'modal-sm': this.size === 'sm',
2975
+ 'modal-lg': this.size === 'lg',
2976
+ 'modal-xl': this.size === 'xl',
2977
+ };
2978
+ }
2979
+ _renderCloseButton() {
2980
+ if (this.hideCloseButton || this.variant === 'popconfirm') {
2981
+ return '';
2982
+ }
2983
+ return html `<it-button
2984
+ class="btn-close"
2985
+ variant="link"
2986
+ size="lg"
2987
+ part="close-button"
2988
+ exportparts="focusable, button, button:close-button-button"
2989
+ @click="${() => this.hide()}"
2990
+ >
2991
+ <it-icon name="it-close" size="lg"></it-icon>
2992
+ <span class="visually-hidden">${this.closeLabel}</span>
2993
+ </it-button>`;
2994
+ }
2995
+ render() {
2996
+ const hasHeader = (this.modalTitle || this._headerSlot?.assignedElements({ flatten: true }).length > 0) && !this.customHeader;
2997
+ const enableFocusContent = this.scrollable || this.position === 'left' || this.position === 'right';
2998
+ let ariaLabelledBy = hasHeader ? this._titleId : undefined;
2999
+ if (this.itAriaLabel) {
3000
+ ariaLabelledBy = undefined;
3001
+ }
3002
+ return html `
3003
+ <slot name="trigger" @slotchange=${this._onTriggerSlotChange}></slot>
3004
+ <div
3005
+ class="${classMap(this._modalClasses)}"
3006
+ role="dialog"
3007
+ aria-modal="true"
3008
+ aria-labelledby="${ifDefined(ariaLabelledBy)}"
3009
+ aria-describedby="${ifDefined(this._descriptionId)}"
3010
+ aria-label="${ifDefined(this.itAriaLabel || undefined)}"
3011
+ aria-hidden="${!this.open}"
3012
+ tabindex="-1"
3013
+ @click="${this._handleBackdropClick}"
3014
+ part="modal"
3015
+ >
3016
+ <!-- TRICK SAFARI ENGINE -->
3017
+ <div
3018
+ id="safari-focus-anchor"
3019
+ tabindex="-1"
3020
+ aria-hidden="true"
3021
+ style="position: absolute; width: 0; height: 0; outline: none;"
3022
+ ></div>
3023
+ <div
3024
+ class="${classMap(this._modalBodyClasses)}"
3025
+ role="document"
3026
+ @click="${this._handleDialogClick}"
3027
+ part="modal-content-wrapper"
3028
+ >
3029
+ ${this.closeButtonPlacement === 'backdrop' ? this._renderCloseButton() : ''}
3030
+ <div class="visually-hidden" id="${this._descriptionId}">
3031
+ <slot name="description" @slotchange="${this._onHeaderSlotChange}">${this.modalDescription}</slot>
3032
+ </div>
3033
+ <div class="modal-content" part="modal-content">
3034
+ <div
3035
+ class="${hasHeader || (this.variant !== 'popconfirm' && !this.hideCloseButton) ? 'modal-header' : ''}"
3036
+ part="modal-header"
3037
+ >
3038
+ <slot name="header-icon"></slot>
3039
+ ${hasHeader
3040
+ ? html `<h2 id="${this._titleId}" class="modal-title">
3041
+ <slot name="header" @slotchange="${this._onHeaderSlotChange}">${this.modalTitle}</slot>
3042
+ </h2>`
3043
+ : html `<div><slot name="header" @slotchange="${this._onHeaderSlotChange}"></slot></div>`}
3044
+ ${this.closeButtonPlacement === 'header' ? this._renderCloseButton() : ''}
3045
+ </div>
3046
+ <div class="modal-body" tabindex="${enableFocusContent ? '0' : '-1'}" part="focusable modal-body">
3047
+ <slot name="content"></slot>
3048
+ </div>
3049
+ <div class="modal-footer ${this.footerShadow ? 'modal-footer-shadow' : ''}" part="modal-footer">
3050
+ <slot name="footer"></slot>
3051
+ </div>
3052
+ </div>
3053
+ </div>
3054
+ </div>
3055
+ <div
3056
+ class="modal-backdrop ${this.disableAnimation ? 'fade' : ''} ${this.open ? 'show' : ''}"
3057
+ aria-hidden="true"
3058
+ @click="${() => !this.staticBackdrop && this.hide()}"
3059
+ part="modal-backdrop"
3060
+ ></div>
3061
+ `;
3062
+ }
3063
+ };
3064
+ ItModal.styles = styles;
3065
+ ItModal.shadowRootOptions = { ...BaseComponent.shadowRootOptions, delegatesFocus: true };
3066
+ __decorate([
3067
+ property({ type: Boolean, reflect: true }),
3068
+ __metadata("design:type", Object)
3069
+ ], ItModal.prototype, "open", void 0);
3070
+ __decorate([
3071
+ property({ type: String, attribute: 'modal-title', reflect: true }),
3072
+ __metadata("design:type", Object)
3073
+ ], ItModal.prototype, "modalTitle", void 0);
3074
+ __decorate([
3075
+ property({ type: String, attribute: 'modal-description', reflect: true }),
3076
+ __metadata("design:type", Object)
3077
+ ], ItModal.prototype, "modalDescription", void 0);
3078
+ __decorate([
3079
+ property({ type: Boolean, attribute: 'custom-header', reflect: true }),
3080
+ __metadata("design:type", Object)
3081
+ ], ItModal.prototype, "customHeader", void 0);
3082
+ __decorate([
3083
+ property({ type: String, reflect: true }),
3084
+ __metadata("design:type", String)
3085
+ ], ItModal.prototype, "size", void 0);
3086
+ __decorate([
3087
+ property({ type: String, reflect: true }),
3088
+ __metadata("design:type", String)
3089
+ ], ItModal.prototype, "position", void 0);
3090
+ __decorate([
3091
+ property({ type: Boolean, reflect: true }),
3092
+ __metadata("design:type", Object)
3093
+ ], ItModal.prototype, "scrollable", void 0);
3094
+ __decorate([
3095
+ property({ type: Boolean, attribute: 'static-backdrop', reflect: true }),
3096
+ __metadata("design:type", Object)
3097
+ ], ItModal.prototype, "staticBackdrop", void 0);
3098
+ __decorate([
3099
+ property({ type: Boolean, attribute: 'hide-close-button', reflect: true }),
3100
+ __metadata("design:type", Object)
3101
+ ], ItModal.prototype, "hideCloseButton", void 0);
3102
+ __decorate([
3103
+ property({ type: String, attribute: 'close-button-placement', reflect: true }),
3104
+ __metadata("design:type", String)
3105
+ ], ItModal.prototype, "closeButtonPlacement", void 0);
3106
+ __decorate([
3107
+ property({ type: String, reflect: true }),
3108
+ __metadata("design:type", String)
3109
+ ], ItModal.prototype, "variant", void 0);
3110
+ __decorate([
3111
+ property({ type: String, attribute: 'it-aria-label' }),
3112
+ __metadata("design:type", Object)
3113
+ ], ItModal.prototype, "itAriaLabel", void 0);
3114
+ __decorate([
3115
+ property({ type: String, attribute: 'close-label', reflect: true }),
3116
+ __metadata("design:type", Object)
3117
+ ], ItModal.prototype, "closeLabel", void 0);
3118
+ __decorate([
3119
+ property({ type: Boolean, attribute: 'disable-animation', reflect: true }),
3120
+ __metadata("design:type", Object)
3121
+ ], ItModal.prototype, "disableAnimation", void 0);
3122
+ __decorate([
3123
+ property({ type: Boolean, attribute: 'footer-shadow', reflect: true }),
3124
+ __metadata("design:type", Object)
3125
+ ], ItModal.prototype, "footerShadow", void 0);
3126
+ __decorate([
3127
+ query('[role="dialog"]'),
3128
+ __metadata("design:type", HTMLElement)
3129
+ ], ItModal.prototype, "_modalElement", void 0);
3130
+ __decorate([
3131
+ query('slot[name="trigger"]'),
3132
+ __metadata("design:type", HTMLSlotElement)
3133
+ ], ItModal.prototype, "_triggerSlot", void 0);
3134
+ __decorate([
3135
+ query('slot[name="header"]'),
3136
+ __metadata("design:type", HTMLSlotElement)
3137
+ ], ItModal.prototype, "_headerSlot", void 0);
3138
+ __decorate([
3139
+ query('slot[name="description"]'),
3140
+ __metadata("design:type", HTMLSlotElement)
3141
+ ], ItModal.prototype, "_descriptionSlot", void 0);
3142
+ __decorate([
3143
+ query('.modal-backdrop'),
3144
+ __metadata("design:type", HTMLElement)
3145
+ ], ItModal.prototype, "_backdropElement", void 0);
3146
+ __decorate([
3147
+ query('.modal-dialog'),
3148
+ __metadata("design:type", HTMLElement)
3149
+ ], ItModal.prototype, "_dialogElement", void 0);
3150
+ __decorate([
3151
+ state(),
3152
+ __metadata("design:type", Object)
3153
+ ], ItModal.prototype, "_safariMouseInteraction", void 0);
3154
+ ItModal = __decorate([
3155
+ customElement('it-modal'),
3156
+ __metadata("design:paramtypes", [])
3157
+ ], ItModal);
3158
+
3159
+ export { ItModal };
3160
+ //# sourceMappingURL=it-modal.js.map