@italia/modal 1.0.0-alpha.9 → 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +57 -14
- package/dist/src/index.js.map +1 -1
- package/dist/src/it-modal.d.ts +3 -0
- package/dist/src/it-modal.d.ts.map +1 -1
- package/dist/src/it-modal.js +860 -151
- package/dist/src/it-modal.js.map +1 -1
- package/dist/src/types.d.ts +5 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +9 -9
- package/styles/globals.scss +2 -2
package/dist/src/it-modal.js
CHANGED
|
@@ -37,14 +37,80 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
37
37
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
+
const ARIA_IDREF_ATTRIBUTES = new Map([
|
|
41
|
+
['aria-activedescendant', 'ariaActivedescendantElement'],
|
|
42
|
+
['aria-controls', 'ariaControlsElements'],
|
|
43
|
+
['aria-describedby', 'ariaDescribedByElements'],
|
|
44
|
+
['aria-details', 'ariaDetailsElements'],
|
|
45
|
+
['aria-errormessage', 'ariaErrormessageElements'],
|
|
46
|
+
['aria-flowto', 'ariaFlowtoElements'],
|
|
47
|
+
['aria-labelledby', 'ariaLabelledByElements'],
|
|
48
|
+
['aria-owns', 'ariaOwnsElements'],
|
|
49
|
+
]);
|
|
50
|
+
function resolveAriaIdRefs(element, value) {
|
|
51
|
+
const ids = value
|
|
52
|
+
.trim()
|
|
53
|
+
.split(/\s+/)
|
|
54
|
+
.filter((id) => id.length > 0);
|
|
55
|
+
if (ids.length === 0)
|
|
56
|
+
return null;
|
|
57
|
+
const root = element.getRootNode();
|
|
58
|
+
let resolvedElements = [];
|
|
59
|
+
if (root instanceof ShadowRoot) {
|
|
60
|
+
resolvedElements = ids.map((id) => root.getElementById(id));
|
|
61
|
+
}
|
|
62
|
+
else if (root instanceof Document) {
|
|
63
|
+
resolvedElements = ids.map((id) => root.getElementById(id));
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
resolvedElements = ids.map((id) => document.getElementById(id));
|
|
67
|
+
}
|
|
68
|
+
if (resolvedElements.filter((el) => el !== null).length === 0) {
|
|
69
|
+
resolvedElements = ids.map((id) => document.getElementById(id));
|
|
70
|
+
}
|
|
71
|
+
const validElements = resolvedElements.filter((el) => el !== null);
|
|
72
|
+
return validElements.length === ids.length ? validElements : null;
|
|
73
|
+
}
|
|
74
|
+
function setInternalsProperty(el, name, resolvedElements) {
|
|
75
|
+
if (name === 'aria-activedescendant') {
|
|
76
|
+
const [firstElement] = resolvedElements;
|
|
77
|
+
// eslint-disable-next-line no-param-reassign
|
|
78
|
+
el[name] = firstElement;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
// eslint-disable-next-line no-param-reassign
|
|
82
|
+
el[name] = resolvedElements;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
40
85
|
class SetAttributesDirective extends Directive {
|
|
41
86
|
update(part, [attributes]) {
|
|
42
87
|
const el = part.element;
|
|
88
|
+
const internals = el.internals ?? null;
|
|
43
89
|
for (const [name, value] of Object.entries(attributes)) {
|
|
44
|
-
if (value
|
|
45
|
-
el.setAttribute(name, value);
|
|
46
|
-
else
|
|
90
|
+
if (value == null) {
|
|
47
91
|
el.removeAttribute(name);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
const internalsPropertyName = ARIA_IDREF_ATTRIBUTES.get(name);
|
|
95
|
+
if (internalsPropertyName) {
|
|
96
|
+
const resolvedElements = resolveAriaIdRefs(el, String(value));
|
|
97
|
+
if (resolvedElements) {
|
|
98
|
+
if (internals) {
|
|
99
|
+
// Set on ElementInternals
|
|
100
|
+
setInternalsProperty(internals, internalsPropertyName, resolvedElements);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
// Set internals property on shadowdom item
|
|
104
|
+
el.setAttribute(name, String(value));
|
|
105
|
+
setInternalsProperty(el, internalsPropertyName, resolvedElements);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
// Non-ARIA IDREF attributes: set normally
|
|
111
|
+
el.setAttribute(name, String(value));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
48
114
|
}
|
|
49
115
|
return null;
|
|
50
116
|
}
|
|
@@ -115,7 +181,9 @@ function registerTranslation(...translation) {
|
|
|
115
181
|
});
|
|
116
182
|
update();
|
|
117
183
|
}
|
|
118
|
-
window
|
|
184
|
+
if (typeof window !== 'undefined') {
|
|
185
|
+
window.registerTranslation = registerTranslation;
|
|
186
|
+
}
|
|
119
187
|
/**
|
|
120
188
|
* Localize Reactive Controller for components built with Lit
|
|
121
189
|
*
|
|
@@ -410,6 +478,26 @@ class BaseComponent extends LitElement {
|
|
|
410
478
|
// generate internal _id
|
|
411
479
|
const prefix = this.id?.length > 0 ? this.id : this.tagName.toLowerCase();
|
|
412
480
|
this._id = this.generateId(prefix);
|
|
481
|
+
this.ariaAttributesObserver = new MutationObserver((mutations) => {
|
|
482
|
+
const shouldUpdate = mutations.some((mutation) => {
|
|
483
|
+
if (mutation.type !== 'attributes' || !mutation.attributeName) {
|
|
484
|
+
return false;
|
|
485
|
+
}
|
|
486
|
+
return mutation.attributeName === 'it-role' || mutation.attributeName.startsWith('it-aria-');
|
|
487
|
+
});
|
|
488
|
+
if (shouldUpdate) {
|
|
489
|
+
this.requestUpdate();
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
this.ariaAttributesObserver.observe(this, {
|
|
493
|
+
attributes: true,
|
|
494
|
+
attributeOldValue: true,
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
disconnectedCallback() {
|
|
498
|
+
this.ariaAttributesObserver?.disconnect();
|
|
499
|
+
this.ariaAttributesObserver = undefined;
|
|
500
|
+
super.disconnectedCallback();
|
|
413
501
|
}
|
|
414
502
|
}
|
|
415
503
|
const BaseLocalizedComponent = LocalizeMixin(BaseComponent);
|
|
@@ -438,6 +526,158 @@ const BaseLocalizedComponent = LocalizeMixin(BaseComponent);
|
|
|
438
526
|
* focus-trap npm package, and a11y-dialog.
|
|
439
527
|
*/
|
|
440
528
|
class FocusTrapController {
|
|
529
|
+
static getManagedHostAncestor(element) {
|
|
530
|
+
let current = element;
|
|
531
|
+
while (current) {
|
|
532
|
+
const parentEl = current instanceof HTMLElement ? current.parentElement : null;
|
|
533
|
+
if (parentEl && parentEl.matches(FocusTrapController.MANAGED_HOST_SELECTORS))
|
|
534
|
+
return parentEl;
|
|
535
|
+
if (parentEl) {
|
|
536
|
+
current = parentEl;
|
|
537
|
+
continue;
|
|
538
|
+
}
|
|
539
|
+
const rootNode = current.getRootNode();
|
|
540
|
+
if (rootNode instanceof ShadowRoot) {
|
|
541
|
+
const hostElement = rootNode.host;
|
|
542
|
+
if (hostElement instanceof HTMLElement) {
|
|
543
|
+
if (hostElement.matches(FocusTrapController.MANAGED_HOST_SELECTORS))
|
|
544
|
+
return hostElement;
|
|
545
|
+
current = hostElement;
|
|
546
|
+
continue;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
break;
|
|
550
|
+
}
|
|
551
|
+
return null;
|
|
552
|
+
}
|
|
553
|
+
static isInsideManagedHost(element) {
|
|
554
|
+
return FocusTrapController.getManagedHostAncestor(element) !== null;
|
|
555
|
+
}
|
|
556
|
+
static getManagedMenuHostAncestor(element) {
|
|
557
|
+
let current = element;
|
|
558
|
+
while (current) {
|
|
559
|
+
const parentEl = current instanceof HTMLElement ? current.parentElement : null;
|
|
560
|
+
if (parentEl && parentEl.matches(FocusTrapController.MANAGED_MENU_HOST_SELECTORS))
|
|
561
|
+
return parentEl;
|
|
562
|
+
if (parentEl) {
|
|
563
|
+
current = parentEl;
|
|
564
|
+
continue;
|
|
565
|
+
}
|
|
566
|
+
const rootNode = current.getRootNode();
|
|
567
|
+
if (rootNode instanceof ShadowRoot) {
|
|
568
|
+
const hostElement = rootNode.host;
|
|
569
|
+
if (hostElement instanceof HTMLElement) {
|
|
570
|
+
if (hostElement.matches(FocusTrapController.MANAGED_MENU_HOST_SELECTORS))
|
|
571
|
+
return hostElement;
|
|
572
|
+
current = hostElement;
|
|
573
|
+
continue;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
break;
|
|
577
|
+
}
|
|
578
|
+
return null;
|
|
579
|
+
}
|
|
580
|
+
static collectFocusableCandidates(root, candidates, trigger, visited) {
|
|
581
|
+
const rootAsNode = root;
|
|
582
|
+
if (visited.has(rootAsNode))
|
|
583
|
+
return;
|
|
584
|
+
visited.add(rootAsNode);
|
|
585
|
+
const elements = Array.from(root.querySelectorAll('*'));
|
|
586
|
+
elements.forEach((el) => {
|
|
587
|
+
if (el === trigger)
|
|
588
|
+
return;
|
|
589
|
+
// Keep custom host components as single tab stops: their internal light/shadow
|
|
590
|
+
// descendants must not appear as separate trap candidates.
|
|
591
|
+
if (FocusTrapController.isInsideManagedHost(el))
|
|
592
|
+
return;
|
|
593
|
+
if (el.matches(FocusTrapController.FOCUSABLE_SELECTORS)) {
|
|
594
|
+
candidates.push(el);
|
|
595
|
+
// Stop here: focusCandidate() handles delegation to the inner focusable.
|
|
596
|
+
// Prevent recursion into this element's shadow DOM so inner buttons/triggers
|
|
597
|
+
// are not added as separate tab stops.
|
|
598
|
+
if (el.shadowRoot)
|
|
599
|
+
visited.add(el.shadowRoot);
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
if (el instanceof HTMLSlotElement) {
|
|
603
|
+
el.assignedElements({ flatten: true }).forEach((assigned) => {
|
|
604
|
+
if (!(assigned instanceof HTMLElement) || assigned === trigger)
|
|
605
|
+
return;
|
|
606
|
+
if (assigned.matches(FocusTrapController.FOCUSABLE_SELECTORS)) {
|
|
607
|
+
candidates.push(assigned);
|
|
608
|
+
// Same rule: don't recurse into a focusable element.
|
|
609
|
+
if (assigned.shadowRoot)
|
|
610
|
+
visited.add(assigned.shadowRoot);
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
FocusTrapController.collectFocusableCandidates(assigned, candidates, trigger, visited);
|
|
614
|
+
if (assigned.shadowRoot) {
|
|
615
|
+
FocusTrapController.collectFocusableCandidates(assigned.shadowRoot, candidates, trigger, visited);
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
if (el.shadowRoot) {
|
|
621
|
+
FocusTrapController.collectFocusableCandidates(el.shadowRoot, candidates, trigger, visited);
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
static getFirstFocusableInShadow(host) {
|
|
626
|
+
const visited = new Set();
|
|
627
|
+
const walk = (root) => {
|
|
628
|
+
const rootAsNode = root;
|
|
629
|
+
if (visited.has(rootAsNode))
|
|
630
|
+
return null;
|
|
631
|
+
visited.add(rootAsNode);
|
|
632
|
+
const direct = Array.from(root.querySelectorAll(FocusTrapController.NATIVE_FOCUSABLE_SELECTORS));
|
|
633
|
+
const firstDirect = direct.find((el) => FocusTrapController.isFocusable(el));
|
|
634
|
+
if (firstDirect)
|
|
635
|
+
return firstDirect;
|
|
636
|
+
const all = Array.from(root.querySelectorAll('*'));
|
|
637
|
+
for (const el of all) {
|
|
638
|
+
if (el instanceof HTMLSlotElement) {
|
|
639
|
+
const assigned = el.assignedElements({ flatten: true });
|
|
640
|
+
for (const assignedEl of assigned) {
|
|
641
|
+
if (!(assignedEl instanceof HTMLElement))
|
|
642
|
+
continue;
|
|
643
|
+
if (assignedEl.matches(FocusTrapController.NATIVE_FOCUSABLE_SELECTORS)) {
|
|
644
|
+
if (FocusTrapController.isFocusable(assignedEl))
|
|
645
|
+
return assignedEl;
|
|
646
|
+
}
|
|
647
|
+
const nestedAssigned = walk(assignedEl);
|
|
648
|
+
if (nestedAssigned)
|
|
649
|
+
return nestedAssigned;
|
|
650
|
+
if (assignedEl.shadowRoot) {
|
|
651
|
+
const nestedAssignedShadow = walk(assignedEl.shadowRoot);
|
|
652
|
+
if (nestedAssignedShadow)
|
|
653
|
+
return nestedAssignedShadow;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
if (el.shadowRoot) {
|
|
658
|
+
const nested = walk(el.shadowRoot);
|
|
659
|
+
if (nested)
|
|
660
|
+
return nested;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
return null;
|
|
664
|
+
};
|
|
665
|
+
if (!host.shadowRoot)
|
|
666
|
+
return null;
|
|
667
|
+
return walk(host.shadowRoot);
|
|
668
|
+
}
|
|
669
|
+
static focusCandidate(target) {
|
|
670
|
+
if (!target)
|
|
671
|
+
return;
|
|
672
|
+
if (target.tagName.toLowerCase().startsWith('it-')) {
|
|
673
|
+
const innerFocusable = FocusTrapController.getFirstFocusableInShadow(target);
|
|
674
|
+
if (innerFocusable) {
|
|
675
|
+
innerFocusable.focus({ preventScroll: true });
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
target.focus({ preventScroll: true });
|
|
680
|
+
}
|
|
441
681
|
/**
|
|
442
682
|
* Verifica se un elemento è effettivamente focusabile e tabbabile.
|
|
443
683
|
* Elementi con tabindex="-1" sono focusabili programmaticamente ma non tabbabili.
|
|
@@ -469,6 +709,10 @@ class FocusTrapController {
|
|
|
469
709
|
this._isActive = false;
|
|
470
710
|
this._previousActiveElement = null;
|
|
471
711
|
this._focusableElements = [];
|
|
712
|
+
/** Last known index resolved from real focusin events inside the trap.
|
|
713
|
+
* Used as a fallback when assistive tech retargeting makes activeElement
|
|
714
|
+
* temporarily unmappable during Tab navigation. */
|
|
715
|
+
this._lastKnownFocusIndex = -1;
|
|
472
716
|
/** Timer ID for the focus call scheduled inside activate(). Cancelled by deactivate()
|
|
473
717
|
* to prevent focus firing after the trap has been torn down (fast open/close, unmount). */
|
|
474
718
|
this._pendingFocusTimer = null;
|
|
@@ -487,6 +731,32 @@ class FocusTrapController {
|
|
|
487
731
|
break;
|
|
488
732
|
}
|
|
489
733
|
};
|
|
734
|
+
this._handleFocusIn = (event) => {
|
|
735
|
+
if (!this._isActive)
|
|
736
|
+
return;
|
|
737
|
+
if (this._focusableElements.length === 0) {
|
|
738
|
+
this.updateFocusableElements();
|
|
739
|
+
if (this._focusableElements.length === 0)
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
const path = event.composedPath();
|
|
743
|
+
let index = this._focusableElements.findIndex((candidate) => path.includes(candidate));
|
|
744
|
+
if (index === -1) {
|
|
745
|
+
const target = path[0];
|
|
746
|
+
if (target instanceof HTMLElement) {
|
|
747
|
+
index = this._focusableElements.indexOf(target);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
if (index === -1) {
|
|
751
|
+
const active = FocusTrapController.getActiveElement();
|
|
752
|
+
if (active) {
|
|
753
|
+
index = this._focusableElements.findIndex((candidate) => candidate.contains(active));
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
if (index !== -1) {
|
|
757
|
+
this._lastKnownFocusIndex = index;
|
|
758
|
+
}
|
|
759
|
+
};
|
|
490
760
|
this.host = host;
|
|
491
761
|
this.config = config;
|
|
492
762
|
this.host.addController(this);
|
|
@@ -517,7 +787,9 @@ class FocusTrapController {
|
|
|
517
787
|
// Usa document capture: cattura Tab/Escape prima di qualsiasi handler,
|
|
518
788
|
// indipendentemente da shadow DOM, delegatesFocus e slot retargeting.
|
|
519
789
|
document.addEventListener('keydown', this._handleKeyDown, true);
|
|
790
|
+
document.addEventListener('focusin', this._handleFocusIn, true);
|
|
520
791
|
this.updateFocusableElements();
|
|
792
|
+
this._lastKnownFocusIndex = -1;
|
|
521
793
|
// FIX Safari: trick engine
|
|
522
794
|
// Diamo al browser un istante per processare il ricalcolo del layout
|
|
523
795
|
requestAnimationFrame(() => {
|
|
@@ -533,6 +805,7 @@ class FocusTrapController {
|
|
|
533
805
|
}
|
|
534
806
|
}
|
|
535
807
|
else {
|
|
808
|
+
// eslint-disable-next-line no-console
|
|
536
809
|
console.warn("FocusTrap: missing 'initialFocus' callback, provide one");
|
|
537
810
|
}
|
|
538
811
|
});
|
|
@@ -548,6 +821,8 @@ class FocusTrapController {
|
|
|
548
821
|
}
|
|
549
822
|
this._isActive = false;
|
|
550
823
|
document.removeEventListener('keydown', this._handleKeyDown, true);
|
|
824
|
+
document.removeEventListener('focusin', this._handleFocusIn, true);
|
|
825
|
+
this._lastKnownFocusIndex = -1;
|
|
551
826
|
if (!options?.skipFocusRestore) {
|
|
552
827
|
this._restoreFocus();
|
|
553
828
|
}
|
|
@@ -569,20 +844,21 @@ class FocusTrapController {
|
|
|
569
844
|
return;
|
|
570
845
|
}
|
|
571
846
|
const candidates = [];
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
847
|
+
FocusTrapController.collectFocusableCandidates(container, candidates, trigger, new Set());
|
|
848
|
+
// Include anche i figli light DOM dell'host (es. contenuti slottati della modale)
|
|
849
|
+
Array.from(this.host.children).forEach((child) => {
|
|
850
|
+
if (!(child instanceof HTMLElement) || child === trigger)
|
|
851
|
+
return;
|
|
852
|
+
if (child.matches(FocusTrapController.FOCUSABLE_SELECTORS)) {
|
|
853
|
+
candidates.push(child);
|
|
854
|
+
// Don't recurse: same stop-on-focusable rule.
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
const childVisited = new Set();
|
|
858
|
+
FocusTrapController.collectFocusableCandidates(child, candidates, trigger, childVisited);
|
|
859
|
+
if (child.shadowRoot) {
|
|
860
|
+
FocusTrapController.collectFocusableCandidates(child.shadowRoot, candidates, trigger, childVisited);
|
|
861
|
+
}
|
|
586
862
|
});
|
|
587
863
|
// Filtra solo elementi veramente focusabili e rimuovi duplicati
|
|
588
864
|
this._focusableElements = Array.from(new Set(candidates)).filter((el) => {
|
|
@@ -615,15 +891,24 @@ class FocusTrapController {
|
|
|
615
891
|
return active;
|
|
616
892
|
}
|
|
617
893
|
_handleTab(event) {
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
894
|
+
const activeElement = FocusTrapController.getActiveElement();
|
|
895
|
+
// Let native Tab behavior handle navigation inside open dropdown/megamenu.
|
|
896
|
+
// This allows entering and traversing internal menu items correctly.
|
|
897
|
+
if (activeElement) {
|
|
898
|
+
const managedHost = FocusTrapController.getManagedMenuHostAncestor(activeElement);
|
|
899
|
+
if (managedHost && managedHost.getAttribute('data-it-aria-expanded') === 'true') {
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
// Ricalcola sempre al Tab: gli elementi slottati possono completare il render
|
|
904
|
+
// del proprio shadow DOM dopo l'attivazione iniziale del trap.
|
|
905
|
+
this.updateFocusableElements();
|
|
621
906
|
if (this._focusableElements.length === 0)
|
|
622
907
|
return; // Se è ancora vuoto, non bloccare il Tab
|
|
623
908
|
event.preventDefault();
|
|
624
|
-
const activeElement = FocusTrapController.getActiveElement();
|
|
625
909
|
let currentIndex = this._focusableElements.indexOf(activeElement);
|
|
626
910
|
if (currentIndex === -1 && activeElement) {
|
|
911
|
+
// 1. Walk shadow host chain (covers delegatesFocus custom elements)
|
|
627
912
|
let parent = activeElement.getRootNode()?.host;
|
|
628
913
|
while (parent && currentIndex === -1) {
|
|
629
914
|
currentIndex = this._focusableElements.indexOf(parent);
|
|
@@ -631,16 +916,43 @@ class FocusTrapController {
|
|
|
631
916
|
parent = parent.getRootNode()?.host;
|
|
632
917
|
}
|
|
633
918
|
}
|
|
919
|
+
if (currentIndex === -1) {
|
|
920
|
+
// 2. Composed path fallback: handles focus inside nested shadow/slotted
|
|
921
|
+
// content (e.g. anchors inside it-dropdown-item) by mapping the active
|
|
922
|
+
// target to the first focusable host found in the event path.
|
|
923
|
+
const composedPath = event.composedPath();
|
|
924
|
+
currentIndex = this._focusableElements.findIndex((candidate) => composedPath.includes(candidate));
|
|
925
|
+
}
|
|
926
|
+
if (currentIndex === -1 && activeElement) {
|
|
927
|
+
// 3. contains() fallback: handles focus inside an open dropdown/megamenu whose
|
|
928
|
+
// items live in light DOM (not shadow DOM), so the parent-walk above doesn't
|
|
929
|
+
// reach the host. Map to the host's index so Tab/Shift+Tab move to the
|
|
930
|
+
// correct adjacent element.
|
|
931
|
+
currentIndex = this._focusableElements.findIndex((candidate) => candidate.contains(activeElement));
|
|
932
|
+
}
|
|
933
|
+
if (currentIndex === -1) {
|
|
934
|
+
// 4. AT fallback: with some screen readers, document.activeElement and/or
|
|
935
|
+
// event target can be unreliable while navigating inside composite widgets.
|
|
936
|
+
// If a dropdown/megamenu is currently open, use its host index as anchor
|
|
937
|
+
// so forward/backward Tab continue from that position instead of wrapping.
|
|
938
|
+
currentIndex = this._focusableElements.findIndex((candidate) => candidate.matches('it-dropdown, it-megamenu') && candidate.getAttribute('data-it-aria-expanded') === 'true');
|
|
939
|
+
}
|
|
940
|
+
if (currentIndex === -1 && this._lastKnownFocusIndex >= 0) {
|
|
941
|
+
// 5. Last-known fallback: if assistive tech retargeting hides the active
|
|
942
|
+
// element for this key event, continue from the most recent resolved
|
|
943
|
+
// focus index captured via focusin.
|
|
944
|
+
currentIndex = Math.min(this._lastKnownFocusIndex, this._focusableElements.length - 1);
|
|
945
|
+
}
|
|
634
946
|
if (event.shiftKey) {
|
|
635
947
|
if (currentIndex <= 0)
|
|
636
|
-
this._last
|
|
948
|
+
FocusTrapController.focusCandidate(this._last);
|
|
637
949
|
else
|
|
638
|
-
this._focusableElements[currentIndex - 1]
|
|
950
|
+
FocusTrapController.focusCandidate(this._focusableElements[currentIndex - 1]);
|
|
639
951
|
}
|
|
640
952
|
else if (currentIndex === -1 || currentIndex >= this._focusableElements.length - 1)
|
|
641
|
-
this._first
|
|
953
|
+
FocusTrapController.focusCandidate(this._first);
|
|
642
954
|
else
|
|
643
|
-
this._focusableElements[currentIndex + 1]
|
|
955
|
+
FocusTrapController.focusCandidate(this._focusableElements[currentIndex + 1]);
|
|
644
956
|
}
|
|
645
957
|
_restoreFocus() {
|
|
646
958
|
const target = this._previousActiveElement;
|
|
@@ -665,6 +977,25 @@ FocusTrapController.FOCUSABLE_SELECTORS = [
|
|
|
665
977
|
'select:not([disabled])',
|
|
666
978
|
'[tabindex]',
|
|
667
979
|
'it-button:not([disabled])',
|
|
980
|
+
'it-dropdown:not([disabled])',
|
|
981
|
+
'it-megamenu:not([disabled])',
|
|
982
|
+
].join(',');
|
|
983
|
+
FocusTrapController.NATIVE_FOCUSABLE_SELECTORS = [
|
|
984
|
+
'a[href]',
|
|
985
|
+
'button:not([disabled])',
|
|
986
|
+
'textarea:not([disabled])',
|
|
987
|
+
'input:not([disabled]):not([type="hidden"])',
|
|
988
|
+
'select:not([disabled])',
|
|
989
|
+
'[tabindex]:not([tabindex="-1"])',
|
|
990
|
+
].join(',');
|
|
991
|
+
FocusTrapController.MANAGED_HOST_SELECTORS = [
|
|
992
|
+
'it-button:not([disabled])',
|
|
993
|
+
'it-dropdown:not([disabled])',
|
|
994
|
+
'it-megamenu:not([disabled])',
|
|
995
|
+
].join(',');
|
|
996
|
+
FocusTrapController.MANAGED_MENU_HOST_SELECTORS = [
|
|
997
|
+
'it-dropdown:not([disabled])',
|
|
998
|
+
'it-megamenu:not([disabled])',
|
|
668
999
|
].join(',');
|
|
669
1000
|
|
|
670
1001
|
//
|
|
@@ -1095,7 +1426,7 @@ class FormControl extends BaseLocalizedComponent {
|
|
|
1095
1426
|
});
|
|
1096
1427
|
// TODO: verificare se serve davvero con il fatto che usiamo form-controller
|
|
1097
1428
|
// static formAssociated = true;
|
|
1098
|
-
//
|
|
1429
|
+
// @property()
|
|
1099
1430
|
// internals = this.attachInternals();
|
|
1100
1431
|
this._touched = false;
|
|
1101
1432
|
/** The name of the input, submitted as a name/value pair with form data. */
|
|
@@ -1339,6 +1670,49 @@ __decorate([
|
|
|
1339
1670
|
__metadata("design:type", Object)
|
|
1340
1671
|
], FormControl.prototype, "validationMessage", void 0);
|
|
1341
1672
|
|
|
1673
|
+
/**
|
|
1674
|
+
* Dispatches a cancelable custom event and runs the provided default action
|
|
1675
|
+
* only if the consumer did not call `event.preventDefault()`.
|
|
1676
|
+
*
|
|
1677
|
+
* This is the shared convention used across components (Tabs, Modal, Chip, Alert,
|
|
1678
|
+
* Forward, Back) to provide a sensible default JavaScript behavior out of the box
|
|
1679
|
+
* while letting consumers intercept and override it. Notification deliberately does
|
|
1680
|
+
* NOT use this: its show/close are always caller-initiated (no default markup-driven
|
|
1681
|
+
* trigger to override), so there was no real use case for blocking them — see
|
|
1682
|
+
* it-notification.ts for the plain (non-cancelable) events it fires instead.
|
|
1683
|
+
*
|
|
1684
|
+
* ```js
|
|
1685
|
+
* el.addEventListener('it-alert-close', (e) => {
|
|
1686
|
+
* e.preventDefault(); // block the default removal
|
|
1687
|
+
* fetchConfirmation().then((ok) => { // async logic runs after prevention
|
|
1688
|
+
* if (ok) e.target.close();
|
|
1689
|
+
* });
|
|
1690
|
+
* });
|
|
1691
|
+
* ```
|
|
1692
|
+
*
|
|
1693
|
+
* Note: `preventDefault()` must be called synchronously inside the listener.
|
|
1694
|
+
* Async code can run afterward; call the component's public method when ready.
|
|
1695
|
+
*
|
|
1696
|
+
* @param host the element dispatching the event
|
|
1697
|
+
* @param name the event name (kebab-case, `it-` prefixed)
|
|
1698
|
+
* @param detail the event `detail` payload
|
|
1699
|
+
* @param defaultAction the behavior executed when the event is not prevented
|
|
1700
|
+
* @returns the dispatched event (inspect `defaultPrevented` if needed)
|
|
1701
|
+
*/
|
|
1702
|
+
function dispatchCancelable(host, name, detail, defaultAction) {
|
|
1703
|
+
const event = new CustomEvent(name, {
|
|
1704
|
+
bubbles: true,
|
|
1705
|
+
composed: true,
|
|
1706
|
+
cancelable: true,
|
|
1707
|
+
detail,
|
|
1708
|
+
});
|
|
1709
|
+
host.dispatchEvent(event);
|
|
1710
|
+
if (!event.defaultPrevented) {
|
|
1711
|
+
defaultAction();
|
|
1712
|
+
}
|
|
1713
|
+
return event;
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1342
1716
|
class WindowManager {
|
|
1343
1717
|
static init() {
|
|
1344
1718
|
if (this.initialized)
|
|
@@ -1421,110 +1795,11 @@ if (typeof window !== 'undefined') {
|
|
|
1421
1795
|
window._itAnalytics = window._itAnalytics || {};
|
|
1422
1796
|
window._itAnalytics = {
|
|
1423
1797
|
...window._itAnalytics,
|
|
1424
|
-
version: '1.0.0-
|
|
1798
|
+
version: '1.0.0-beta.0',
|
|
1425
1799
|
};
|
|
1426
1800
|
}
|
|
1427
1801
|
|
|
1428
1802
|
var styles = css`@charset "UTF-8";
|
|
1429
|
-
/***************************** 1 ****************************************/
|
|
1430
|
-
/***************************** 2 ****************************************/
|
|
1431
|
-
/***************************** 1 ****************************************/
|
|
1432
|
-
/***************************** 2 ****************************************/
|
|
1433
|
-
/***************************** 1 ****************************************/
|
|
1434
|
-
/***************************** 2 ****************************************/
|
|
1435
|
-
/***************************** 3 ****************************************/
|
|
1436
|
-
/***************************** 1 ****************************************/
|
|
1437
|
-
/***************************** 2 ****************************************/
|
|
1438
|
-
/***************************** 3 ****************************************/
|
|
1439
|
-
/***************************** NEUTRAL 1 ****************************************/
|
|
1440
|
-
/***************************** NEUTRAL 2 ****************************************/
|
|
1441
|
-
/***************************** NEUTRAL 2 / 3 ****************************************/
|
|
1442
|
-
.d-none {
|
|
1443
|
-
display: none !important;
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1446
|
-
.d-block {
|
|
1447
|
-
display: block !important;
|
|
1448
|
-
}
|
|
1449
|
-
|
|
1450
|
-
.d-flex {
|
|
1451
|
-
display: flex !important;
|
|
1452
|
-
}
|
|
1453
|
-
|
|
1454
|
-
.overflow-auto {
|
|
1455
|
-
overflow: auto !important;
|
|
1456
|
-
}
|
|
1457
|
-
|
|
1458
|
-
.overflow-hidden {
|
|
1459
|
-
overflow: hidden !important;
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
|
-
@media (min-width: 576px) {
|
|
1463
|
-
.d-sm-none {
|
|
1464
|
-
display: none !important;
|
|
1465
|
-
}
|
|
1466
|
-
.d-sm-block {
|
|
1467
|
-
display: block !important;
|
|
1468
|
-
}
|
|
1469
|
-
.d-sm-flex {
|
|
1470
|
-
display: flex !important;
|
|
1471
|
-
}
|
|
1472
|
-
}
|
|
1473
|
-
@media (min-width: 768px) {
|
|
1474
|
-
.d-md-none {
|
|
1475
|
-
display: none !important;
|
|
1476
|
-
}
|
|
1477
|
-
.d-md-block {
|
|
1478
|
-
display: block !important;
|
|
1479
|
-
}
|
|
1480
|
-
.d-md-flex {
|
|
1481
|
-
display: flex !important;
|
|
1482
|
-
}
|
|
1483
|
-
}
|
|
1484
|
-
@media (min-width: 992px) {
|
|
1485
|
-
.d-lg-none {
|
|
1486
|
-
display: none !important;
|
|
1487
|
-
}
|
|
1488
|
-
.d-lg-block {
|
|
1489
|
-
display: block !important;
|
|
1490
|
-
}
|
|
1491
|
-
.d-lg-flex {
|
|
1492
|
-
display: flex !important;
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
@media (min-width: 1200px) {
|
|
1496
|
-
.d-xl-none {
|
|
1497
|
-
display: none !important;
|
|
1498
|
-
}
|
|
1499
|
-
.d-xl-block {
|
|
1500
|
-
display: block !important;
|
|
1501
|
-
}
|
|
1502
|
-
.d-xl-flex {
|
|
1503
|
-
display: flex !important;
|
|
1504
|
-
}
|
|
1505
|
-
}
|
|
1506
|
-
@media (min-width: 1400px) {
|
|
1507
|
-
.d-xxl-none {
|
|
1508
|
-
display: none !important;
|
|
1509
|
-
}
|
|
1510
|
-
.d-xxl-block {
|
|
1511
|
-
display: block !important;
|
|
1512
|
-
}
|
|
1513
|
-
.d-xxl-flex {
|
|
1514
|
-
display: flex !important;
|
|
1515
|
-
}
|
|
1516
|
-
}
|
|
1517
|
-
@media print {
|
|
1518
|
-
.d-print-none {
|
|
1519
|
-
display: none !important;
|
|
1520
|
-
}
|
|
1521
|
-
.d-print-block {
|
|
1522
|
-
display: block !important;
|
|
1523
|
-
}
|
|
1524
|
-
.d-print-flex {
|
|
1525
|
-
display: flex !important;
|
|
1526
|
-
}
|
|
1527
|
-
}
|
|
1528
1803
|
.modal {
|
|
1529
1804
|
--bsi-modal-bg: var(--bsi-color-background-inverse);
|
|
1530
1805
|
--bsi-modal-border-color: transparent;
|
|
@@ -1923,6 +2198,299 @@ var styles = css`@charset "UTF-8";
|
|
|
1923
2198
|
height: calc(100vh - 128px);
|
|
1924
2199
|
}
|
|
1925
2200
|
}
|
|
2201
|
+
*,
|
|
2202
|
+
*::before,
|
|
2203
|
+
*::after {
|
|
2204
|
+
box-sizing: border-box;
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
2208
|
+
:root {
|
|
2209
|
+
scroll-behavior: smooth;
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2213
|
+
body {
|
|
2214
|
+
margin: 0;
|
|
2215
|
+
-webkit-text-size-adjust: 100%;
|
|
2216
|
+
-webkit-tap-highlight-color: hsla(0, 0%, 0%, 0);
|
|
2217
|
+
}
|
|
2218
|
+
|
|
2219
|
+
hr {
|
|
2220
|
+
margin: 1rem 0;
|
|
2221
|
+
color: inherit;
|
|
2222
|
+
border: 0;
|
|
2223
|
+
border-top: 1px solid;
|
|
2224
|
+
opacity: 0.25;
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
p {
|
|
2228
|
+
margin-top: 0;
|
|
2229
|
+
margin-bottom: var(--bsi-paragraph-spacing);
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2232
|
+
abbr[title] {
|
|
2233
|
+
text-decoration: underline dotted;
|
|
2234
|
+
cursor: help;
|
|
2235
|
+
text-decoration-skip-ink: none;
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2238
|
+
address {
|
|
2239
|
+
margin-bottom: var(--bsi-spacing-s);
|
|
2240
|
+
font-style: normal;
|
|
2241
|
+
line-height: inherit;
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
ol,
|
|
2245
|
+
ul {
|
|
2246
|
+
padding-left: var(--bsi-spacing-l);
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
ol,
|
|
2250
|
+
ul,
|
|
2251
|
+
dl {
|
|
2252
|
+
margin-top: 0;
|
|
2253
|
+
margin-bottom: var(--bsi-spacing-s);
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
ol ol,
|
|
2257
|
+
ul ul,
|
|
2258
|
+
ol ul,
|
|
2259
|
+
ul ol {
|
|
2260
|
+
margin-bottom: 0;
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
dt {
|
|
2264
|
+
font-weight: var(--bsi-font-weight-strong);
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
dd {
|
|
2268
|
+
margin-bottom: var(--bsi-spacing-xxs);
|
|
2269
|
+
margin-left: 0;
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
blockquote {
|
|
2273
|
+
margin: 0 0 var(--bsi-spacing-s);
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2276
|
+
sub,
|
|
2277
|
+
sup {
|
|
2278
|
+
position: relative;
|
|
2279
|
+
font-size: var(--bsi-font-size-1);
|
|
2280
|
+
line-height: 0;
|
|
2281
|
+
vertical-align: baseline;
|
|
2282
|
+
}
|
|
2283
|
+
|
|
2284
|
+
sub {
|
|
2285
|
+
bottom: -0.25em;
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
sup {
|
|
2289
|
+
top: -0.5em;
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
a {
|
|
2293
|
+
color: var(--bsi-color-link);
|
|
2294
|
+
text-decoration: underline;
|
|
2295
|
+
text-decoration-skip-ink: auto;
|
|
2296
|
+
text-underline-offset: 2px;
|
|
2297
|
+
}
|
|
2298
|
+
a:hover {
|
|
2299
|
+
color: var(--bsi-color-link-hover);
|
|
2300
|
+
cursor: pointer;
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2303
|
+
pre,
|
|
2304
|
+
code,
|
|
2305
|
+
kbd,
|
|
2306
|
+
samp {
|
|
2307
|
+
font-size: 1em;
|
|
2308
|
+
}
|
|
2309
|
+
|
|
2310
|
+
pre {
|
|
2311
|
+
display: block;
|
|
2312
|
+
margin-top: 0;
|
|
2313
|
+
margin-bottom: var(--bsi-paragraph-spacing);
|
|
2314
|
+
overflow: auto;
|
|
2315
|
+
}
|
|
2316
|
+
pre code {
|
|
2317
|
+
word-break: normal;
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
a > code {
|
|
2321
|
+
color: inherit;
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2324
|
+
figure {
|
|
2325
|
+
margin: 0 0 1rem;
|
|
2326
|
+
}
|
|
2327
|
+
|
|
2328
|
+
img,
|
|
2329
|
+
svg {
|
|
2330
|
+
vertical-align: middle;
|
|
2331
|
+
}
|
|
2332
|
+
|
|
2333
|
+
table {
|
|
2334
|
+
caption-side: bottom;
|
|
2335
|
+
border-collapse: collapse;
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
caption {
|
|
2339
|
+
padding-top: 0.5rem;
|
|
2340
|
+
padding-bottom: 0.5rem;
|
|
2341
|
+
color: hsl(210, 17%, 44%);
|
|
2342
|
+
text-align: left;
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2345
|
+
th {
|
|
2346
|
+
text-align: inherit;
|
|
2347
|
+
text-align: -webkit-match-parent;
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2350
|
+
thead,
|
|
2351
|
+
tbody,
|
|
2352
|
+
tfoot,
|
|
2353
|
+
tr,
|
|
2354
|
+
td,
|
|
2355
|
+
th {
|
|
2356
|
+
border-color: inherit;
|
|
2357
|
+
border-style: solid;
|
|
2358
|
+
border-width: 0;
|
|
2359
|
+
}
|
|
2360
|
+
|
|
2361
|
+
label {
|
|
2362
|
+
display: inline-block;
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
button {
|
|
2366
|
+
border-radius: 0;
|
|
2367
|
+
}
|
|
2368
|
+
|
|
2369
|
+
button:focus:not(:focus-visible) {
|
|
2370
|
+
outline: 0;
|
|
2371
|
+
}
|
|
2372
|
+
|
|
2373
|
+
input,
|
|
2374
|
+
button,
|
|
2375
|
+
select,
|
|
2376
|
+
optgroup,
|
|
2377
|
+
textarea {
|
|
2378
|
+
margin: 0;
|
|
2379
|
+
font-family: inherit;
|
|
2380
|
+
font-size: inherit;
|
|
2381
|
+
line-height: inherit;
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
button,
|
|
2385
|
+
select {
|
|
2386
|
+
text-transform: none;
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2389
|
+
[role=button] {
|
|
2390
|
+
cursor: pointer;
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
select {
|
|
2394
|
+
word-wrap: normal;
|
|
2395
|
+
}
|
|
2396
|
+
select:disabled {
|
|
2397
|
+
opacity: 1;
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2400
|
+
[list]:not([type=date]):not([type=datetime-local]):not([type=month]):not([type=week]):not([type=time])::-webkit-calendar-picker-indicator {
|
|
2401
|
+
display: none !important;
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2404
|
+
button,
|
|
2405
|
+
[type=button],
|
|
2406
|
+
[type=reset],
|
|
2407
|
+
[type=submit] {
|
|
2408
|
+
-webkit-appearance: button;
|
|
2409
|
+
}
|
|
2410
|
+
button:not(:disabled),
|
|
2411
|
+
[type=button]:not(:disabled),
|
|
2412
|
+
[type=reset]:not(:disabled),
|
|
2413
|
+
[type=submit]:not(:disabled) {
|
|
2414
|
+
cursor: pointer;
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2417
|
+
::-moz-focus-inner {
|
|
2418
|
+
padding: 0;
|
|
2419
|
+
border-style: none;
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2422
|
+
textarea {
|
|
2423
|
+
resize: vertical;
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2426
|
+
fieldset {
|
|
2427
|
+
min-width: 0;
|
|
2428
|
+
padding: 0;
|
|
2429
|
+
margin: 0;
|
|
2430
|
+
border: 0;
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
::-webkit-datetime-edit-fields-wrapper,
|
|
2434
|
+
::-webkit-datetime-edit-text,
|
|
2435
|
+
::-webkit-datetime-edit-minute,
|
|
2436
|
+
::-webkit-datetime-edit-hour-field,
|
|
2437
|
+
::-webkit-datetime-edit-day-field,
|
|
2438
|
+
::-webkit-datetime-edit-month-field,
|
|
2439
|
+
::-webkit-datetime-edit-year-field {
|
|
2440
|
+
padding: 0;
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
::-webkit-inner-spin-button {
|
|
2444
|
+
height: auto;
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
[type=search] {
|
|
2448
|
+
outline-offset: -2px;
|
|
2449
|
+
-webkit-appearance: textfield;
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
/* rtl:raw:
|
|
2453
|
+
[type="tel"],
|
|
2454
|
+
[type="url"],
|
|
2455
|
+
[type="email"],
|
|
2456
|
+
[type="number"] {
|
|
2457
|
+
direction: ltr;
|
|
2458
|
+
}
|
|
2459
|
+
*/
|
|
2460
|
+
::-webkit-search-decoration {
|
|
2461
|
+
-webkit-appearance: none;
|
|
2462
|
+
}
|
|
2463
|
+
|
|
2464
|
+
::-webkit-color-swatch-wrapper {
|
|
2465
|
+
padding: 0;
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2468
|
+
::file-selector-button {
|
|
2469
|
+
font: inherit;
|
|
2470
|
+
-webkit-appearance: button;
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
output {
|
|
2474
|
+
display: inline-block;
|
|
2475
|
+
}
|
|
2476
|
+
|
|
2477
|
+
iframe {
|
|
2478
|
+
border: 0;
|
|
2479
|
+
}
|
|
2480
|
+
|
|
2481
|
+
summary {
|
|
2482
|
+
display: list-item;
|
|
2483
|
+
cursor: pointer;
|
|
2484
|
+
}
|
|
2485
|
+
|
|
2486
|
+
progress {
|
|
2487
|
+
vertical-align: baseline;
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
[hidden] {
|
|
2491
|
+
display: none !important;
|
|
2492
|
+
}
|
|
2493
|
+
|
|
1926
2494
|
body {
|
|
1927
2495
|
font-family: var(--bsi-font-sans);
|
|
1928
2496
|
}
|
|
@@ -2233,6 +2801,92 @@ blockquote.blockquote-card.dark .blockquote-footer,
|
|
|
2233
2801
|
border: 0 !important;
|
|
2234
2802
|
}
|
|
2235
2803
|
|
|
2804
|
+
.d-none {
|
|
2805
|
+
display: none !important;
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
.d-block {
|
|
2809
|
+
display: block !important;
|
|
2810
|
+
}
|
|
2811
|
+
|
|
2812
|
+
.d-flex {
|
|
2813
|
+
display: flex !important;
|
|
2814
|
+
}
|
|
2815
|
+
|
|
2816
|
+
.overflow-auto {
|
|
2817
|
+
overflow: auto !important;
|
|
2818
|
+
}
|
|
2819
|
+
|
|
2820
|
+
.overflow-hidden {
|
|
2821
|
+
overflow: hidden !important;
|
|
2822
|
+
}
|
|
2823
|
+
|
|
2824
|
+
@media (min-width: 576px) {
|
|
2825
|
+
.d-sm-none {
|
|
2826
|
+
display: none !important;
|
|
2827
|
+
}
|
|
2828
|
+
.d-sm-block {
|
|
2829
|
+
display: block !important;
|
|
2830
|
+
}
|
|
2831
|
+
.d-sm-flex {
|
|
2832
|
+
display: flex !important;
|
|
2833
|
+
}
|
|
2834
|
+
}
|
|
2835
|
+
@media (min-width: 768px) {
|
|
2836
|
+
.d-md-none {
|
|
2837
|
+
display: none !important;
|
|
2838
|
+
}
|
|
2839
|
+
.d-md-block {
|
|
2840
|
+
display: block !important;
|
|
2841
|
+
}
|
|
2842
|
+
.d-md-flex {
|
|
2843
|
+
display: flex !important;
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
@media (min-width: 992px) {
|
|
2847
|
+
.d-lg-none {
|
|
2848
|
+
display: none !important;
|
|
2849
|
+
}
|
|
2850
|
+
.d-lg-block {
|
|
2851
|
+
display: block !important;
|
|
2852
|
+
}
|
|
2853
|
+
.d-lg-flex {
|
|
2854
|
+
display: flex !important;
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
@media (min-width: 1200px) {
|
|
2858
|
+
.d-xl-none {
|
|
2859
|
+
display: none !important;
|
|
2860
|
+
}
|
|
2861
|
+
.d-xl-block {
|
|
2862
|
+
display: block !important;
|
|
2863
|
+
}
|
|
2864
|
+
.d-xl-flex {
|
|
2865
|
+
display: flex !important;
|
|
2866
|
+
}
|
|
2867
|
+
}
|
|
2868
|
+
@media (min-width: 1400px) {
|
|
2869
|
+
.d-xxl-none {
|
|
2870
|
+
display: none !important;
|
|
2871
|
+
}
|
|
2872
|
+
.d-xxl-block {
|
|
2873
|
+
display: block !important;
|
|
2874
|
+
}
|
|
2875
|
+
.d-xxl-flex {
|
|
2876
|
+
display: flex !important;
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
@media print {
|
|
2880
|
+
.d-print-none {
|
|
2881
|
+
display: none !important;
|
|
2882
|
+
}
|
|
2883
|
+
.d-print-block {
|
|
2884
|
+
display: block !important;
|
|
2885
|
+
}
|
|
2886
|
+
.d-print-flex {
|
|
2887
|
+
display: flex !important;
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2236
2890
|
:host {
|
|
2237
2891
|
display: block;
|
|
2238
2892
|
--it-focus-ring-safari-fix: none;
|
|
@@ -2283,6 +2937,13 @@ blockquote.blockquote-card.dark .blockquote-footer,
|
|
|
2283
2937
|
overflow-y: auto;
|
|
2284
2938
|
}
|
|
2285
2939
|
|
|
2940
|
+
:host([close-button-placement=backdrop]) .btn-close[part~=close-button] {
|
|
2941
|
+
--bsi-icon-default: white;
|
|
2942
|
+
position: absolute;
|
|
2943
|
+
top: 1rem;
|
|
2944
|
+
right: -2.5rem;
|
|
2945
|
+
}
|
|
2946
|
+
|
|
2286
2947
|
.it-dialog-scrollable {
|
|
2287
2948
|
overflow-y: hidden;
|
|
2288
2949
|
}
|
|
@@ -2321,6 +2982,21 @@ blockquote.blockquote-card.dark .blockquote-footer,
|
|
|
2321
2982
|
right: 0;
|
|
2322
2983
|
}`;
|
|
2323
2984
|
|
|
2985
|
+
/**
|
|
2986
|
+
* Componente Modal per finestre di dialogo modali.
|
|
2987
|
+
*
|
|
2988
|
+
* @element it-modal
|
|
2989
|
+
*
|
|
2990
|
+
* @slot trigger - Elemento che apre la modale (es. it-button)
|
|
2991
|
+
* @slot content - Contenuto principale della modale (body)
|
|
2992
|
+
* @slot header-icon - Icona opzionale nell'header
|
|
2993
|
+
* @slot footer - Azioni del footer (pulsanti)
|
|
2994
|
+
*
|
|
2995
|
+
* @fires it-modal-open - Quando la modale si apre (cancelable: `preventDefault()` impedisce l'apertura)
|
|
2996
|
+
* @fires it-modal-close - Quando la modale si chiude (cancelable: `preventDefault()` impedisce la chiusura)
|
|
2997
|
+
*
|
|
2998
|
+
* @prop {string} close-button-placement - Posizione del pulsante di chiusura: `header` (default) o `backdrop` (sopra lo sfondo scuro, utile per menu offcanvas)
|
|
2999
|
+
*/
|
|
2324
3000
|
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
2325
3001
|
let ItModal = class ItModal extends BaseComponent {
|
|
2326
3002
|
get _triggerElement() {
|
|
@@ -2332,10 +3008,12 @@ let ItModal = class ItModal extends BaseComponent {
|
|
|
2332
3008
|
this.open = undefined;
|
|
2333
3009
|
this.modalTitle = '';
|
|
2334
3010
|
this.modalDescription = '';
|
|
3011
|
+
this.customHeader = false;
|
|
2335
3012
|
this.size = '';
|
|
2336
3013
|
this.scrollable = false;
|
|
2337
3014
|
this.staticBackdrop = false;
|
|
2338
3015
|
this.hideCloseButton = false;
|
|
3016
|
+
this.closeButtonPlacement = 'header';
|
|
2339
3017
|
this.itAriaLabel = '';
|
|
2340
3018
|
this.closeLabel = '';
|
|
2341
3019
|
this.disableAnimation = false;
|
|
@@ -2430,18 +3108,29 @@ let ItModal = class ItModal extends BaseComponent {
|
|
|
2430
3108
|
show() {
|
|
2431
3109
|
if (this.open || this.isAnimating)
|
|
2432
3110
|
return;
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
this
|
|
3111
|
+
// `it-modal-open` is cancelable: calling `preventDefault()` stops the modal
|
|
3112
|
+
// from opening (the consumer can open it later by calling `show()` again).
|
|
3113
|
+
dispatchCancelable(this, 'it-modal-open', { modal: this }, () => {
|
|
3114
|
+
this._originalTrigger = this._triggerElement;
|
|
3115
|
+
this.open = true;
|
|
3116
|
+
});
|
|
2436
3117
|
}
|
|
2437
3118
|
hide() {
|
|
2438
3119
|
if (!this.open || this.isAnimating)
|
|
2439
3120
|
return;
|
|
2440
|
-
|
|
2441
|
-
|
|
3121
|
+
// `it-modal-close` is cancelable: calling `preventDefault()` keeps the modal
|
|
3122
|
+
// open (the consumer can close it later by calling `hide()`).
|
|
3123
|
+
dispatchCancelable(this, 'it-modal-close', { modal: this }, () => {
|
|
3124
|
+
this._hideModal();
|
|
3125
|
+
});
|
|
2442
3126
|
}
|
|
2443
3127
|
toggle() {
|
|
2444
|
-
this.open
|
|
3128
|
+
if (this.open) {
|
|
3129
|
+
this.hide();
|
|
3130
|
+
}
|
|
3131
|
+
else {
|
|
3132
|
+
this.show();
|
|
3133
|
+
}
|
|
2445
3134
|
}
|
|
2446
3135
|
updated(changedProperties) {
|
|
2447
3136
|
if (changedProperties.has('open')) {
|
|
@@ -2708,19 +3397,38 @@ let ItModal = class ItModal extends BaseComponent {
|
|
|
2708
3397
|
'modal-xl': this.size === 'xl',
|
|
2709
3398
|
};
|
|
2710
3399
|
}
|
|
3400
|
+
_renderCloseButton() {
|
|
3401
|
+
if (this.hideCloseButton || this.variant === 'popconfirm') {
|
|
3402
|
+
return '';
|
|
3403
|
+
}
|
|
3404
|
+
return html `<it-button
|
|
3405
|
+
class="btn-close"
|
|
3406
|
+
variant="link"
|
|
3407
|
+
size="lg"
|
|
3408
|
+
part="close-button"
|
|
3409
|
+
exportparts="focusable, button, button:close-button-button"
|
|
3410
|
+
@click="${() => this.hide()}"
|
|
3411
|
+
>
|
|
3412
|
+
<it-icon name="it-close" size="lg"></it-icon>
|
|
3413
|
+
<span class="visually-hidden">${this.closeLabel}</span>
|
|
3414
|
+
</it-button>`;
|
|
3415
|
+
}
|
|
2711
3416
|
render() {
|
|
2712
|
-
const hasHeader = this.modalTitle ||
|
|
2713
|
-
const ariaLabel = !hasHeader ? this.itAriaLabel || undefined : undefined;
|
|
3417
|
+
const hasHeader = (this.modalTitle || this._headerSlot?.assignedElements({ flatten: true }).length > 0) && !this.customHeader;
|
|
2714
3418
|
const enableFocusContent = this.scrollable || this.position === 'left' || this.position === 'right';
|
|
3419
|
+
let ariaLabelledBy = hasHeader ? this._titleId : undefined;
|
|
3420
|
+
if (this.itAriaLabel) {
|
|
3421
|
+
ariaLabelledBy = undefined;
|
|
3422
|
+
}
|
|
2715
3423
|
return html `
|
|
2716
3424
|
<slot name="trigger" @slotchange=${this._onTriggerSlotChange}></slot>
|
|
2717
3425
|
<div
|
|
2718
3426
|
class="${classMap(this._modalClasses)}"
|
|
2719
3427
|
role="dialog"
|
|
2720
3428
|
aria-modal="true"
|
|
2721
|
-
aria-labelledby="${ifDefined(
|
|
3429
|
+
aria-labelledby="${ifDefined(ariaLabelledBy)}"
|
|
2722
3430
|
aria-describedby="${ifDefined(this._descriptionId)}"
|
|
2723
|
-
aria-label="${ifDefined(
|
|
3431
|
+
aria-label="${ifDefined(this.itAriaLabel || undefined)}"
|
|
2724
3432
|
aria-hidden="${!this.open}"
|
|
2725
3433
|
tabindex="-1"
|
|
2726
3434
|
@click="${this._handleBackdropClick}"
|
|
@@ -2739,6 +3447,7 @@ let ItModal = class ItModal extends BaseComponent {
|
|
|
2739
3447
|
@click="${this._handleDialogClick}"
|
|
2740
3448
|
part="modal-content-wrapper"
|
|
2741
3449
|
>
|
|
3450
|
+
${this.closeButtonPlacement === 'backdrop' ? this._renderCloseButton() : ''}
|
|
2742
3451
|
<div class="visually-hidden" id="${this._descriptionId}">
|
|
2743
3452
|
<slot name="description" @slotchange="${this._onHeaderSlotChange}">${this.modalDescription}</slot>
|
|
2744
3453
|
</div>
|
|
@@ -2748,20 +3457,12 @@ let ItModal = class ItModal extends BaseComponent {
|
|
|
2748
3457
|
part="modal-header"
|
|
2749
3458
|
>
|
|
2750
3459
|
<slot name="header-icon"></slot>
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
variant="link"
|
|
2758
|
-
size="lg"
|
|
2759
|
-
exportparts="focusable, button"
|
|
2760
|
-
@click="${() => this.hide()}"
|
|
2761
|
-
><it-icon name="it-close" size="lg"></it-icon
|
|
2762
|
-
><span class="visually-hidden">${this.closeLabel}</span></it-button
|
|
2763
|
-
>`
|
|
2764
|
-
: ''}
|
|
3460
|
+
${hasHeader
|
|
3461
|
+
? html `<h2 id="${this._titleId}" class="modal-title">
|
|
3462
|
+
<slot name="header" @slotchange="${this._onHeaderSlotChange}">${this.modalTitle}</slot>
|
|
3463
|
+
</h2>`
|
|
3464
|
+
: html `<div><slot name="header" @slotchange="${this._onHeaderSlotChange}"></slot></div>`}
|
|
3465
|
+
${this.closeButtonPlacement === 'header' ? this._renderCloseButton() : ''}
|
|
2765
3466
|
</div>
|
|
2766
3467
|
<div class="modal-body" tabindex="${enableFocusContent ? '0' : '-1'}" part="focusable modal-body">
|
|
2767
3468
|
<slot name="content"></slot>
|
|
@@ -2795,6 +3496,10 @@ __decorate([
|
|
|
2795
3496
|
property({ type: String, attribute: 'modal-description', reflect: true }),
|
|
2796
3497
|
__metadata("design:type", Object)
|
|
2797
3498
|
], ItModal.prototype, "modalDescription", void 0);
|
|
3499
|
+
__decorate([
|
|
3500
|
+
property({ type: Boolean, attribute: 'custom-header', reflect: true }),
|
|
3501
|
+
__metadata("design:type", Object)
|
|
3502
|
+
], ItModal.prototype, "customHeader", void 0);
|
|
2798
3503
|
__decorate([
|
|
2799
3504
|
property({ type: String, reflect: true }),
|
|
2800
3505
|
__metadata("design:type", String)
|
|
@@ -2815,6 +3520,10 @@ __decorate([
|
|
|
2815
3520
|
property({ type: Boolean, attribute: 'hide-close-button', reflect: true }),
|
|
2816
3521
|
__metadata("design:type", Object)
|
|
2817
3522
|
], ItModal.prototype, "hideCloseButton", void 0);
|
|
3523
|
+
__decorate([
|
|
3524
|
+
property({ type: String, attribute: 'close-button-placement', reflect: true }),
|
|
3525
|
+
__metadata("design:type", String)
|
|
3526
|
+
], ItModal.prototype, "closeButtonPlacement", void 0);
|
|
2818
3527
|
__decorate([
|
|
2819
3528
|
property({ type: String, reflect: true }),
|
|
2820
3529
|
__metadata("design:type", String)
|