wulf.js 1.9.0 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -7
- package/changelog.md +21 -0
- package/dist/focus-trap.cjs.js +430 -0
- package/dist/focus-trap.cjs.js.map +7 -0
- package/dist/focus-trap.esm.js +407 -0
- package/dist/focus-trap.esm.js.map +7 -0
- package/dist/focus-trap.global.js +433 -0
- package/dist/focus-trap.global.js.map +7 -0
- package/dist/focus-trap.global.min.js +6 -0
- package/dist/focus-trap.global.min.js.map +7 -0
- package/dist/index.cjs.js +590 -8
- package/dist/index.cjs.js.map +3 -3
- package/dist/index.esm.js +590 -8
- package/dist/index.esm.js.map +3 -3
- package/dist/index.global.js +590 -8
- package/dist/index.global.js.map +3 -3
- package/dist/index.global.min.js +4 -1
- package/dist/index.global.min.js.map +4 -4
- package/dist/mask.cjs.js +106 -2
- package/dist/mask.cjs.js.map +3 -3
- package/dist/mask.esm.js +106 -2
- package/dist/mask.esm.js.map +3 -3
- package/dist/mask.global.js +106 -2
- package/dist/mask.global.js.map +3 -3
- package/dist/mask.global.min.js +4 -1
- package/dist/mask.global.min.js.map +4 -4
- package/dist/masonry.cjs.js +78 -3
- package/dist/masonry.cjs.js.map +3 -3
- package/dist/masonry.esm.js +78 -3
- package/dist/masonry.esm.js.map +3 -3
- package/dist/masonry.global.js +78 -3
- package/dist/masonry.global.js.map +3 -3
- package/dist/masonry.global.min.js +4 -1
- package/dist/masonry.global.min.js.map +4 -4
- package/dist/scroll.cjs.js +78 -3
- package/dist/scroll.cjs.js.map +3 -3
- package/dist/scroll.esm.js +78 -3
- package/dist/scroll.esm.js.map +3 -3
- package/dist/scroll.global.js +78 -3
- package/dist/scroll.global.js.map +3 -3
- package/dist/scroll.global.min.js +4 -1
- package/dist/scroll.global.min.js.map +4 -4
- package/dist/toast.cjs.js +91 -2
- package/dist/toast.cjs.js.map +3 -3
- package/dist/toast.esm.js +91 -2
- package/dist/toast.esm.js.map +3 -3
- package/dist/toast.global.js +91 -2
- package/dist/toast.global.js.map +3 -3
- package/dist/toast.global.min.js +4 -1
- package/dist/toast.global.min.js.map +4 -4
- package/dist/types/common/AuditableComponent.d.ts +45 -0
- package/dist/types/common/LocalizedComponent.d.ts +3 -2
- package/dist/types/focus-trap/FocusTrap.d.ts +64 -0
- package/dist/types/focus-trap/index.d.ts +3 -0
- package/dist/types/focus-trap/types.d.ts +45 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/mask/BaseInputMask.d.ts +14 -1
- package/dist/types/mask/InputMask.d.ts +1 -0
- package/dist/types/mask/types.d.ts +5 -2
- package/dist/types/masonry/Masonry.d.ts +7 -0
- package/dist/types/masonry/types.d.ts +7 -2
- package/dist/types/scroll/ScrollBlock.d.ts +7 -0
- package/dist/types/scroll/types.d.ts +3 -2
- package/dist/types/toast/Toast.d.ts +3 -0
- package/dist/types/toast/ToastInstance.d.ts +9 -1
- package/dist/types/toast/types.d.ts +3 -2
- package/package.json +9 -3
package/dist/index.global.js
CHANGED
|
@@ -22,8 +22,10 @@ var Wulf = (() => {
|
|
|
22
22
|
var index_exports = {};
|
|
23
23
|
__export(index_exports, {
|
|
24
24
|
AmountEngine: () => AmountEngine,
|
|
25
|
+
AuditableComponent: () => AuditableComponent,
|
|
25
26
|
BaseInputMask: () => BaseInputMask,
|
|
26
27
|
EmailEngine: () => EmailEngine,
|
|
28
|
+
FocusTrap: () => focus_trap_exports,
|
|
27
29
|
InputAmountMask: () => InputAmountMask,
|
|
28
30
|
InputEmailMask: () => InputEmailMask,
|
|
29
31
|
InputMask: () => InputMask,
|
|
@@ -35,6 +37,7 @@ var Wulf = (() => {
|
|
|
35
37
|
Masonry: () => masonry_exports,
|
|
36
38
|
Scroll: () => scroll_exports,
|
|
37
39
|
Toast: () => toast_exports,
|
|
40
|
+
WulfFocusTrap: () => FocusTrap,
|
|
38
41
|
createI18nManager: () => createI18nManager,
|
|
39
42
|
default: () => mask_default,
|
|
40
43
|
resolveMaskConstructorArgs: () => resolveMaskConstructorArgs
|
|
@@ -57,6 +60,49 @@ var Wulf = (() => {
|
|
|
57
60
|
resolveMaskConstructorArgs: () => resolveMaskConstructorArgs
|
|
58
61
|
});
|
|
59
62
|
|
|
63
|
+
// src/common/AuditableComponent.ts
|
|
64
|
+
var AuditableComponent = class {
|
|
65
|
+
/**
|
|
66
|
+
* Indication affichée en pied de warning pour expliquer comment désactiver l'audit.
|
|
67
|
+
*/
|
|
68
|
+
getAuditDisableHint() {
|
|
69
|
+
return "Passez { audit: false } dans les options pour d\xE9sactiver cet avertissement";
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Exécute l'audit d'accessibilité et émet un avertissement standardisé dans la console
|
|
73
|
+
* si l'audit est activé et que des contraintes manquent.
|
|
74
|
+
*/
|
|
75
|
+
runAuditWarning(enabled = true) {
|
|
76
|
+
if (!enabled) return [];
|
|
77
|
+
const warnings = this.audit();
|
|
78
|
+
if (warnings.length > 0 && typeof console !== "undefined" && typeof console.warn === "function") {
|
|
79
|
+
console.warn(
|
|
80
|
+
`[${this.getAuditPrefix()}] Audit d'accessibilit\xE9 \u2014 ${warnings.length} contrainte(s) manquante(s) sur ${this.getAuditTargetLabel()} :
|
|
81
|
+
` + warnings.map((w) => ` - ${w}`).join("\n") + `
|
|
82
|
+
(${this.getAuditDisableHint()})`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
return warnings;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Vérifie si un attribut de référence d'IDs ARIA (ex: aria-labelledby, aria-describedby)
|
|
89
|
+
* pointe vers des éléments réellement présents dans le document.
|
|
90
|
+
*/
|
|
91
|
+
checkAriaIdReferences(element, attrName, warnings) {
|
|
92
|
+
const rawValue = element.getAttribute(attrName)?.trim();
|
|
93
|
+
if (!rawValue) return false;
|
|
94
|
+
const doc = element.ownerDocument || document;
|
|
95
|
+
const ids = rawValue.split(/\s+/).filter(Boolean);
|
|
96
|
+
const isValid = ids.length > 0 && ids.every((id) => Boolean(doc.getElementById(id)));
|
|
97
|
+
if (!isValid) {
|
|
98
|
+
warnings.push(
|
|
99
|
+
`Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
return isValid;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
60
106
|
// src/mask/BaseInputMask.ts
|
|
61
107
|
function resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOptions) {
|
|
62
108
|
const isSecondArgInput = Boolean(
|
|
@@ -75,8 +121,9 @@ var Wulf = (() => {
|
|
|
75
121
|
options: inputOrOptions && typeof inputOrOptions === "object" && !("tagName" in inputOrOptions) ? inputOrOptions : {}
|
|
76
122
|
};
|
|
77
123
|
}
|
|
78
|
-
var BaseInputMask = class {
|
|
124
|
+
var BaseInputMask = class extends AuditableComponent {
|
|
79
125
|
constructor(targetOrWrapper, inputOrOptions, maybeOptions) {
|
|
126
|
+
super();
|
|
80
127
|
this.ghost = null;
|
|
81
128
|
this.isWrapperCreated = false;
|
|
82
129
|
this.isDestroyed = false;
|
|
@@ -164,8 +211,10 @@ var Wulf = (() => {
|
|
|
164
211
|
const dataSelectAll = this.getAttr("data-mask-select-on-focus") === "true";
|
|
165
212
|
const dataCopyRaw = this.getAttr("data-mask-copy-raw") === "true";
|
|
166
213
|
const dataAlign = this.getAttr("data-mask-align") || this.getAttr("data-align");
|
|
214
|
+
const dataAudit = this.getAttr("data-mask-audit");
|
|
167
215
|
const { disabled: optDisabled, align: optAlign, ...otherOptions } = options;
|
|
168
216
|
const resolvedDisabled = optDisabled !== void 0 ? optDisabled : dataDisabled ? true : false;
|
|
217
|
+
const resolvedAudit = options.audit ?? (dataAudit !== null ? dataAudit !== "false" : true);
|
|
169
218
|
const isPassword = this.input.type === "password";
|
|
170
219
|
this.options = {
|
|
171
220
|
...otherOptions,
|
|
@@ -175,7 +224,8 @@ var Wulf = (() => {
|
|
|
175
224
|
copyRaw: isPassword ? false : options.copyRaw ?? dataCopyRaw ?? false,
|
|
176
225
|
disabled: resolvedDisabled,
|
|
177
226
|
align: optAlign ?? (dataAlign || void 0),
|
|
178
|
-
emitNativeInput: options.emitNativeInput ?? true
|
|
227
|
+
emitNativeInput: options.emitNativeInput ?? true,
|
|
228
|
+
audit: resolvedAudit
|
|
179
229
|
};
|
|
180
230
|
if (this.options.showMaskOnFocus) {
|
|
181
231
|
this.wrapper.classList.add("mask-focus-only");
|
|
@@ -520,6 +570,48 @@ var Wulf = (() => {
|
|
|
520
570
|
getRawValue() {
|
|
521
571
|
return this.input.value;
|
|
522
572
|
}
|
|
573
|
+
/**
|
|
574
|
+
* Vérifie la conformité d'accessibilité WAI-ARIA du champ de saisie (étiquetage, format attendu)
|
|
575
|
+
* et retourne la liste des contraintes manquantes.
|
|
576
|
+
*/
|
|
577
|
+
audit() {
|
|
578
|
+
const warnings = [];
|
|
579
|
+
const doc = this.input.ownerDocument || document;
|
|
580
|
+
const ariaLabel = this.input.getAttribute("aria-label")?.trim();
|
|
581
|
+
const hasValidLabelledby = this.checkAriaIdReferences(this.input, "aria-labelledby", warnings);
|
|
582
|
+
const hasWrappingLabel = Boolean(this.input.closest("label"));
|
|
583
|
+
const hasNativeLabels = Boolean(this.input.labels && this.input.labels.length > 0);
|
|
584
|
+
let hasExplicitLabelFor = false;
|
|
585
|
+
if (this.input.id && typeof CSS !== "undefined" && typeof CSS.escape === "function") {
|
|
586
|
+
hasExplicitLabelFor = Boolean(doc.querySelector(`label[for="${CSS.escape(this.input.id)}"]`));
|
|
587
|
+
} else if (this.input.id) {
|
|
588
|
+
hasExplicitLabelFor = Boolean(doc.querySelector(`label[for="${this.input.id}"]`));
|
|
589
|
+
}
|
|
590
|
+
if (!ariaLabel && !hasValidLabelledby && !hasWrappingLabel && !hasNativeLabels && !hasExplicitLabelFor) {
|
|
591
|
+
warnings.push(
|
|
592
|
+
`\xC9tiquetage accessible manquant : associez un <label for="id"> (ou d\xE9finissez aria-label / aria-labelledby) sur l'input (WCAG 4.1.2).`
|
|
593
|
+
);
|
|
594
|
+
}
|
|
595
|
+
this.checkAriaIdReferences(this.input, "aria-describedby", warnings);
|
|
596
|
+
const extraWarnings = this.getSpecificAuditWarnings();
|
|
597
|
+
warnings.push(...extraWarnings);
|
|
598
|
+
return warnings;
|
|
599
|
+
}
|
|
600
|
+
getAuditPrefix() {
|
|
601
|
+
return `Wulf.Mask.${this.constructor.name || "InputMask"}`;
|
|
602
|
+
}
|
|
603
|
+
getAuditTargetLabel() {
|
|
604
|
+
return this.input.id ? `#${this.input.id}` : this.input.name ? `input[name="${this.input.name}"]` : "<input>";
|
|
605
|
+
}
|
|
606
|
+
getAuditDisableHint() {
|
|
607
|
+
return 'Passez { audit: false } ou data-mask-audit="false" pour d\xE9sactiver cet avertissement';
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Crochet permettant aux classes filles d'ajouter des vérifications d'audit spécifiques.
|
|
611
|
+
*/
|
|
612
|
+
getSpecificAuditWarnings() {
|
|
613
|
+
return [];
|
|
614
|
+
}
|
|
523
615
|
/**
|
|
524
616
|
* Supprime les éléments fantômes, restaure les propriétés et nettoie les attributs.
|
|
525
617
|
*/
|
|
@@ -1314,6 +1406,19 @@ var Wulf = (() => {
|
|
|
1314
1406
|
this.bindEvents();
|
|
1315
1407
|
this.lastValue = this.input.value;
|
|
1316
1408
|
this.syncInitialValue();
|
|
1409
|
+
this.runAuditWarning(this.options.audit);
|
|
1410
|
+
}
|
|
1411
|
+
getSpecificAuditWarnings() {
|
|
1412
|
+
const warnings = [];
|
|
1413
|
+
const hasDescribedby = Boolean(this.input.getAttribute("aria-describedby")?.trim());
|
|
1414
|
+
const hasPlaceholder = Boolean(this.input.getAttribute("placeholder")?.trim());
|
|
1415
|
+
const hasAriaPlaceholder = Boolean(this.input.getAttribute("aria-placeholder")?.trim());
|
|
1416
|
+
if (!hasDescribedby && !hasPlaceholder && !hasAriaPlaceholder && !this.options.disabled) {
|
|
1417
|
+
warnings.push(
|
|
1418
|
+
"Indication du format attendu manquante : d\xE9finissez aria-describedby, placeholder ou aria-placeholder pour informer les technologies d'assistance (WCAG 3.3.2)."
|
|
1419
|
+
);
|
|
1420
|
+
}
|
|
1421
|
+
return warnings;
|
|
1317
1422
|
}
|
|
1318
1423
|
extractRawSnippet(snippet) {
|
|
1319
1424
|
return this.engine.extractRaw(snippet);
|
|
@@ -2163,6 +2268,7 @@ var Wulf = (() => {
|
|
|
2163
2268
|
isValid: true
|
|
2164
2269
|
});
|
|
2165
2270
|
}
|
|
2271
|
+
this.runAuditWarning(this.options.audit);
|
|
2166
2272
|
}
|
|
2167
2273
|
extractRawSnippet(snippet) {
|
|
2168
2274
|
const p = this.engine.parse(snippet);
|
|
@@ -2745,6 +2851,7 @@ var Wulf = (() => {
|
|
|
2745
2851
|
if (!this.options.disabled) {
|
|
2746
2852
|
this.updateSuggestion();
|
|
2747
2853
|
}
|
|
2854
|
+
this.runAuditWarning(this.options.audit);
|
|
2748
2855
|
}
|
|
2749
2856
|
onNativeValueSet(_strVal) {
|
|
2750
2857
|
if (this.options.disabled) return;
|
|
@@ -3016,7 +3123,7 @@ var Wulf = (() => {
|
|
|
3016
3123
|
});
|
|
3017
3124
|
|
|
3018
3125
|
// src/common/LocalizedComponent.ts
|
|
3019
|
-
var LocalizedComponent = class {
|
|
3126
|
+
var LocalizedComponent = class extends AuditableComponent {
|
|
3020
3127
|
/**
|
|
3021
3128
|
* Définit la langue globale du composant (ex: 'fr', 'en', 'es').
|
|
3022
3129
|
*/
|
|
@@ -3068,6 +3175,7 @@ var Wulf = (() => {
|
|
|
3068
3175
|
return this._i18n ? this._i18n.t(key, instanceOverride) : String(key);
|
|
3069
3176
|
}
|
|
3070
3177
|
constructor(i18nOverrides) {
|
|
3178
|
+
super();
|
|
3071
3179
|
this.i18nOverrides = i18nOverrides;
|
|
3072
3180
|
}
|
|
3073
3181
|
/**
|
|
@@ -3217,7 +3325,7 @@ var Wulf = (() => {
|
|
|
3217
3325
|
throw new Error(`[ScrollBlock] \xC9l\xE9ment introuvable : "${element}".`);
|
|
3218
3326
|
}
|
|
3219
3327
|
this.root = resolvedElement;
|
|
3220
|
-
this.hasExplicitAriaLabel = Boolean(options?.ariaLabel);
|
|
3328
|
+
this.hasExplicitAriaLabel = Boolean(options?.ariaLabel || options?.i18n?.viewport);
|
|
3221
3329
|
this.options = {
|
|
3222
3330
|
axis: options?.axis || "y",
|
|
3223
3331
|
autoHide: options?.autoHide ?? true,
|
|
@@ -3232,7 +3340,8 @@ var Wulf = (() => {
|
|
|
3232
3340
|
onTotalScroll: options?.onTotalScroll || (() => {
|
|
3233
3341
|
}),
|
|
3234
3342
|
onTotalScrollBack: options?.onTotalScrollBack || (() => {
|
|
3235
|
-
})
|
|
3343
|
+
}),
|
|
3344
|
+
audit: options?.audit ?? true
|
|
3236
3345
|
};
|
|
3237
3346
|
this.boundOnScroll = this.handleScroll.bind(this);
|
|
3238
3347
|
this.boundOnMouseEnter = this.handleMouseEnter.bind(this);
|
|
@@ -3247,6 +3356,7 @@ var Wulf = (() => {
|
|
|
3247
3356
|
this.setupEventListeners();
|
|
3248
3357
|
this.setupObserver();
|
|
3249
3358
|
this.update();
|
|
3359
|
+
this.runAuditWarning(this.options.audit);
|
|
3250
3360
|
}
|
|
3251
3361
|
/**
|
|
3252
3362
|
* Prépare le viewport défilant sans altérer les éléments enfants.
|
|
@@ -3667,6 +3777,35 @@ var Wulf = (() => {
|
|
|
3667
3777
|
behavior
|
|
3668
3778
|
});
|
|
3669
3779
|
}
|
|
3780
|
+
/**
|
|
3781
|
+
* Vérifie la conformité d'accessibilité WAI-ARIA de la zone défilable
|
|
3782
|
+
* et retourne la liste des contraintes manquantes.
|
|
3783
|
+
*/
|
|
3784
|
+
audit() {
|
|
3785
|
+
const warnings = [];
|
|
3786
|
+
const hasViewportLabelledby = this.checkAriaIdReferences(this.viewport, "aria-labelledby", warnings);
|
|
3787
|
+
const hasRootLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings);
|
|
3788
|
+
const hasValidLabelledby = hasViewportLabelledby || hasRootLabelledby;
|
|
3789
|
+
const rootAriaLabel = this.root.getAttribute("aria-label")?.trim();
|
|
3790
|
+
const hasCustomViewportAriaLabel = !this.wasAriaLabelInferred && Boolean(this.viewport.getAttribute("aria-label")?.trim());
|
|
3791
|
+
if (!this.hasExplicitAriaLabel && !hasCustomViewportAriaLabel && !rootAriaLabel && !hasValidLabelledby) {
|
|
3792
|
+
warnings.push(
|
|
3793
|
+
"Libell\xE9 contextuel manquant : d\xE9finissez l'option ariaLabel (ou un attribut aria-label / aria-labelledby sur le conteneur) pour d\xE9crire la zone d\xE9filable (WCAG 4.1.2)."
|
|
3794
|
+
);
|
|
3795
|
+
}
|
|
3796
|
+
if (this.options.minThumbSize < 24) {
|
|
3797
|
+
warnings.push(
|
|
3798
|
+
`Taille minimale du curseur insuffisante (minThumbSize: ${this.options.minThumbSize}px) : utilisez au moins 24px pour respecter WCAG 2.5.8.`
|
|
3799
|
+
);
|
|
3800
|
+
}
|
|
3801
|
+
return warnings;
|
|
3802
|
+
}
|
|
3803
|
+
getAuditPrefix() {
|
|
3804
|
+
return "Wulf.Scroll";
|
|
3805
|
+
}
|
|
3806
|
+
getAuditTargetLabel() {
|
|
3807
|
+
return this.root.id ? `#${this.root.id}` : `<${this.root.tagName.toLowerCase()}.wulf-scrollblock>`;
|
|
3808
|
+
}
|
|
3670
3809
|
/**
|
|
3671
3810
|
* Détruit le composant et libère toutes les ressources.
|
|
3672
3811
|
*/
|
|
@@ -3977,7 +4116,7 @@ var Wulf = (() => {
|
|
|
3977
4116
|
height: this.root.style.height,
|
|
3978
4117
|
width: this.root.style.width
|
|
3979
4118
|
};
|
|
3980
|
-
this.hasExplicitAriaLabel = Boolean(options.ariaLabel);
|
|
4119
|
+
this.hasExplicitAriaLabel = Boolean(options.ariaLabel || options.i18n?.gallery);
|
|
3981
4120
|
this.options = {
|
|
3982
4121
|
itemSelector: options.itemSelector || "> *",
|
|
3983
4122
|
columnWidth: options.columnWidth ?? 0,
|
|
@@ -3996,7 +4135,8 @@ var Wulf = (() => {
|
|
|
3996
4135
|
onLayout: options.onLayout || (() => {
|
|
3997
4136
|
}),
|
|
3998
4137
|
onItemPlaced: options.onItemPlaced || (() => {
|
|
3999
|
-
})
|
|
4138
|
+
}),
|
|
4139
|
+
audit: options.audit ?? true
|
|
4000
4140
|
};
|
|
4001
4141
|
const supportsNativeCSS = typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("grid-template-rows", "masonry");
|
|
4002
4142
|
if (this.options.useNativeCSSGrid && supportsNativeCSS) {
|
|
@@ -4011,6 +4151,7 @@ var Wulf = (() => {
|
|
|
4011
4151
|
this.initObservers();
|
|
4012
4152
|
this.initImages();
|
|
4013
4153
|
this.layout();
|
|
4154
|
+
this.runAuditWarning(this.options.audit);
|
|
4014
4155
|
}
|
|
4015
4156
|
get items() {
|
|
4016
4157
|
return [...this._items];
|
|
@@ -4263,6 +4404,35 @@ var Wulf = (() => {
|
|
|
4263
4404
|
}, dur);
|
|
4264
4405
|
this.removeTimers.add(timerId);
|
|
4265
4406
|
}
|
|
4407
|
+
/**
|
|
4408
|
+
* Vérifie la conformité d'accessibilité WAI-ARIA de la grille Masonry
|
|
4409
|
+
* et retourne la liste des contraintes manquantes.
|
|
4410
|
+
*/
|
|
4411
|
+
audit() {
|
|
4412
|
+
const warnings = [];
|
|
4413
|
+
const hasValidLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings);
|
|
4414
|
+
const hasCustomRootAriaLabel = !this.wasAriaLabelInferred && Boolean(this.root.getAttribute("aria-label")?.trim());
|
|
4415
|
+
if (!this.hasExplicitAriaLabel && !hasCustomRootAriaLabel && !hasValidLabelledby) {
|
|
4416
|
+
warnings.push(
|
|
4417
|
+
"Libell\xE9 contextuel manquant : d\xE9finissez l'option ariaLabel (ou un attribut aria-label / aria-labelledby sur le conteneur) pour qualifier la grille (WCAG 4.1.2)."
|
|
4418
|
+
);
|
|
4419
|
+
}
|
|
4420
|
+
const imagesWithoutAlt = Array.from(this.root.querySelectorAll("img")).filter(
|
|
4421
|
+
(img) => !img.hasAttribute("alt") && img.getAttribute("aria-hidden") !== "true"
|
|
4422
|
+
);
|
|
4423
|
+
if (imagesWithoutAlt.length > 0) {
|
|
4424
|
+
warnings.push(
|
|
4425
|
+
`${imagesWithoutAlt.length} image(s) <img> d\xE9pourvue(s) d'attribut alt : renseignez alt="description" (ou alt="" si d\xE9corative) (WCAG 1.1.1).`
|
|
4426
|
+
);
|
|
4427
|
+
}
|
|
4428
|
+
return warnings;
|
|
4429
|
+
}
|
|
4430
|
+
getAuditPrefix() {
|
|
4431
|
+
return "Wulf.Masonry";
|
|
4432
|
+
}
|
|
4433
|
+
getAuditTargetLabel() {
|
|
4434
|
+
return this.root.id ? `#${this.root.id}` : `<${this.root.tagName.toLowerCase()}.wulf-masonry>`;
|
|
4435
|
+
}
|
|
4266
4436
|
/**
|
|
4267
4437
|
* Libère les ressources, déconnecte les observateurs et nettoie les styles injectés.
|
|
4268
4438
|
*/
|
|
@@ -4366,8 +4536,9 @@ var Wulf = (() => {
|
|
|
4366
4536
|
|
|
4367
4537
|
// src/toast/ToastInstance.ts
|
|
4368
4538
|
var nextToastId = 1;
|
|
4369
|
-
var ToastInstance = class {
|
|
4539
|
+
var ToastInstance = class extends AuditableComponent {
|
|
4370
4540
|
constructor(options, onDismiss) {
|
|
4541
|
+
super();
|
|
4371
4542
|
this._isClosed = false;
|
|
4372
4543
|
this.timerId = null;
|
|
4373
4544
|
this.remainingTime = 0;
|
|
@@ -4384,10 +4555,45 @@ var Wulf = (() => {
|
|
|
4384
4555
|
}
|
|
4385
4556
|
this.element = this.createDOM();
|
|
4386
4557
|
this.bindEvents();
|
|
4558
|
+
this.runAuditWarning(options.audit !== false);
|
|
4387
4559
|
}
|
|
4388
4560
|
get isClosed() {
|
|
4389
4561
|
return this._isClosed;
|
|
4390
4562
|
}
|
|
4563
|
+
/**
|
|
4564
|
+
* Vérifie la conformité d'accessibilité WAI-ARIA de la notification Toast
|
|
4565
|
+
* et retourne la liste des contraintes manquantes.
|
|
4566
|
+
*/
|
|
4567
|
+
audit() {
|
|
4568
|
+
const warnings = [];
|
|
4569
|
+
const hasTitle = Boolean(this.options.title && this.options.title.trim().length > 0);
|
|
4570
|
+
const hasMessage = Boolean(this.options.message && this.options.message.trim().length > 0);
|
|
4571
|
+
if (!hasTitle && !hasMessage) {
|
|
4572
|
+
warnings.push(
|
|
4573
|
+
"Contenu textuel vide : d\xE9finissez au moins un title ou un message pour que le lecteur d'\xE9cran puisse annoncer la notification (WCAG 4.1.3)."
|
|
4574
|
+
);
|
|
4575
|
+
}
|
|
4576
|
+
const duration = this.options.duration === void 0 ? 4e3 : this.options.duration;
|
|
4577
|
+
if (typeof duration === "number" && duration > 0 && duration < 5e3) {
|
|
4578
|
+
warnings.push(
|
|
4579
|
+
`Dur\xE9e d'affichage trop courte (duration: ${duration}ms) : pr\xE9voyez au moins 5000ms ou duration: false pour laisser le temps de lecture aux utilisateurs (WCAG 2.2.1).`
|
|
4580
|
+
);
|
|
4581
|
+
}
|
|
4582
|
+
const closable = this.options.closable ?? true;
|
|
4583
|
+
const isPersistent = duration === false || typeof duration === "number" && duration <= 0;
|
|
4584
|
+
if (isPersistent && !closable && !this.options.closeOnClick) {
|
|
4585
|
+
warnings.push(
|
|
4586
|
+
"Notification persistante impossible \xE0 fermer : activez closable: true ou closeOnClick: true lorsque duration est d\xE9sactiv\xE9 (WCAG 2.1.1)."
|
|
4587
|
+
);
|
|
4588
|
+
}
|
|
4589
|
+
return warnings;
|
|
4590
|
+
}
|
|
4591
|
+
getAuditPrefix() {
|
|
4592
|
+
return "Wulf.Toast";
|
|
4593
|
+
}
|
|
4594
|
+
getAuditTargetLabel() {
|
|
4595
|
+
return `#${this.id}`;
|
|
4596
|
+
}
|
|
4391
4597
|
/**
|
|
4392
4598
|
* Construction du DOM de manière 100% sécurisée sans aucun `innerHTML`.
|
|
4393
4599
|
*/
|
|
@@ -4748,6 +4954,15 @@ var Wulf = (() => {
|
|
|
4748
4954
|
|
|
4749
4955
|
// src/toast/Toast.ts
|
|
4750
4956
|
var Toast = class extends LocalizedComponent {
|
|
4957
|
+
audit() {
|
|
4958
|
+
return [];
|
|
4959
|
+
}
|
|
4960
|
+
getAuditPrefix() {
|
|
4961
|
+
return "Wulf.Toast";
|
|
4962
|
+
}
|
|
4963
|
+
getAuditTargetLabel() {
|
|
4964
|
+
return "Toast";
|
|
4965
|
+
}
|
|
4751
4966
|
/**
|
|
4752
4967
|
* Affiche une nouvelle notification Toast avec les options spécifiées.
|
|
4753
4968
|
*/
|
|
@@ -4780,6 +4995,373 @@ var Wulf = (() => {
|
|
|
4780
4995
|
i18n: toastI18n
|
|
4781
4996
|
});
|
|
4782
4997
|
}
|
|
4998
|
+
|
|
4999
|
+
// src/focus-trap/index.ts
|
|
5000
|
+
var focus_trap_exports = {};
|
|
5001
|
+
__export(focus_trap_exports, {
|
|
5002
|
+
FocusTrap: () => FocusTrap,
|
|
5003
|
+
default: () => FocusTrap
|
|
5004
|
+
});
|
|
5005
|
+
|
|
5006
|
+
// src/focus-trap/FocusTrap.ts
|
|
5007
|
+
var FOCUSABLE_SELECTOR = [
|
|
5008
|
+
"a[href]",
|
|
5009
|
+
"area[href]",
|
|
5010
|
+
"input:not([disabled])",
|
|
5011
|
+
"select:not([disabled])",
|
|
5012
|
+
"textarea:not([disabled])",
|
|
5013
|
+
"button:not([disabled])",
|
|
5014
|
+
"iframe",
|
|
5015
|
+
"object",
|
|
5016
|
+
"embed",
|
|
5017
|
+
'[contenteditable="true"]',
|
|
5018
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
5019
|
+
].join(",");
|
|
5020
|
+
var trapStack = [];
|
|
5021
|
+
var FocusTrap = class extends AuditableComponent {
|
|
5022
|
+
constructor(target, options = {}) {
|
|
5023
|
+
super();
|
|
5024
|
+
this.active = false;
|
|
5025
|
+
this.paused = false;
|
|
5026
|
+
this.previousActiveElement = null;
|
|
5027
|
+
this.inertSiblings = [];
|
|
5028
|
+
// Sentinelles anti-fuite de focus
|
|
5029
|
+
this.startSentinel = null;
|
|
5030
|
+
this.endSentinel = null;
|
|
5031
|
+
const el = typeof target === "string" ? document.querySelector(target) : target;
|
|
5032
|
+
if (!el || !(el instanceof HTMLElement)) {
|
|
5033
|
+
throw new Error(`[Wulf.FocusTrap] Conteneur introuvable ou invalide : "${target}"`);
|
|
5034
|
+
}
|
|
5035
|
+
this.element = el;
|
|
5036
|
+
this.options = {
|
|
5037
|
+
initialFocus: options.initialFocus !== void 0 ? options.initialFocus : "[data-autofocus], [autofocus]",
|
|
5038
|
+
returnFocus: options.returnFocus ?? true,
|
|
5039
|
+
fallbackReturnFocus: options.fallbackReturnFocus ?? "",
|
|
5040
|
+
escapeDeactivates: options.escapeDeactivates ?? true,
|
|
5041
|
+
allowOutsideClick: options.allowOutsideClick ?? false,
|
|
5042
|
+
setInert: options.setInert ?? false,
|
|
5043
|
+
onActivate: options.onActivate ?? (() => {
|
|
5044
|
+
}),
|
|
5045
|
+
onDeactivate: options.onDeactivate ?? (() => {
|
|
5046
|
+
}),
|
|
5047
|
+
audit: options.audit ?? true
|
|
5048
|
+
};
|
|
5049
|
+
this.handleKeyDownBound = this.handleKeyDown.bind(this);
|
|
5050
|
+
this.handleClickOutsideBound = this.handleClickOutside.bind(this);
|
|
5051
|
+
this.handleFocusInBound = this.handleFocusIn.bind(this);
|
|
5052
|
+
this.runAuditWarning(this.options.audit);
|
|
5053
|
+
}
|
|
5054
|
+
/**
|
|
5055
|
+
* Vérifie si un élément est réellement focusable, visible et actif dans le DOM.
|
|
5056
|
+
*/
|
|
5057
|
+
isFocusable(el) {
|
|
5058
|
+
if (!el || !el.isConnected) return false;
|
|
5059
|
+
if (el.disabled) return false;
|
|
5060
|
+
if (el.closest("fieldset[disabled]") && !el.closest("legend")) return false;
|
|
5061
|
+
if (el.hasAttribute("inert") || el.closest("[inert]")) return false;
|
|
5062
|
+
if (el.hidden || el.closest("[hidden]")) return false;
|
|
5063
|
+
if (el.style.display === "none" || el.style.visibility === "hidden") return false;
|
|
5064
|
+
const style = window.getComputedStyle(el);
|
|
5065
|
+
if (style.display === "none" || style.visibility === "hidden") return false;
|
|
5066
|
+
if (el.offsetWidth === 0 && el.offsetHeight === 0 && style.position !== "fixed") {
|
|
5067
|
+
return false;
|
|
5068
|
+
}
|
|
5069
|
+
if (el instanceof HTMLInputElement && el.type === "radio" && el.name) {
|
|
5070
|
+
const group = Array.from(
|
|
5071
|
+
this.element.querySelectorAll(`input[type="radio"][name="${CSS.escape(el.name)}"]`)
|
|
5072
|
+
);
|
|
5073
|
+
const checked = group.find((r) => r.checked);
|
|
5074
|
+
if (checked) {
|
|
5075
|
+
return el === checked;
|
|
5076
|
+
}
|
|
5077
|
+
return el === group[0];
|
|
5078
|
+
}
|
|
5079
|
+
return true;
|
|
5080
|
+
}
|
|
5081
|
+
/**
|
|
5082
|
+
* Retourne tous les éléments focusables réels ordonnés dans le conteneur.
|
|
5083
|
+
*/
|
|
5084
|
+
getFocusableElements() {
|
|
5085
|
+
const rawElements = Array.from(this.element.querySelectorAll(FOCUSABLE_SELECTOR));
|
|
5086
|
+
return rawElements.filter((el) => this.isFocusable(el));
|
|
5087
|
+
}
|
|
5088
|
+
/**
|
|
5089
|
+
* Active le trap.
|
|
5090
|
+
*/
|
|
5091
|
+
activate() {
|
|
5092
|
+
if (this.active) return this;
|
|
5093
|
+
const currentTop = trapStack[trapStack.length - 1];
|
|
5094
|
+
if (currentTop) {
|
|
5095
|
+
currentTop.pause();
|
|
5096
|
+
}
|
|
5097
|
+
this.active = true;
|
|
5098
|
+
this.paused = false;
|
|
5099
|
+
trapStack.push(this);
|
|
5100
|
+
this.previousActiveElement = document.activeElement;
|
|
5101
|
+
this.setupSentinels();
|
|
5102
|
+
if (this.options.setInert) {
|
|
5103
|
+
this.applyInert();
|
|
5104
|
+
}
|
|
5105
|
+
document.addEventListener("keydown", this.handleKeyDownBound, true);
|
|
5106
|
+
document.addEventListener("focusin", this.handleFocusInBound, true);
|
|
5107
|
+
if (!this.options.allowOutsideClick) {
|
|
5108
|
+
document.addEventListener("mousedown", this.handleClickOutsideBound, true);
|
|
5109
|
+
document.addEventListener("touchstart", this.handleClickOutsideBound, true);
|
|
5110
|
+
}
|
|
5111
|
+
this.applyInitialFocus();
|
|
5112
|
+
this.runAuditWarning(this.options.audit);
|
|
5113
|
+
this.options.onActivate();
|
|
5114
|
+
return this;
|
|
5115
|
+
}
|
|
5116
|
+
/**
|
|
5117
|
+
* Désactive le trap et libère les écouteurs.
|
|
5118
|
+
*/
|
|
5119
|
+
deactivate() {
|
|
5120
|
+
if (!this.active) return this;
|
|
5121
|
+
this.active = false;
|
|
5122
|
+
this.paused = false;
|
|
5123
|
+
const index = trapStack.indexOf(this);
|
|
5124
|
+
if (index !== -1) {
|
|
5125
|
+
trapStack.splice(index, 1);
|
|
5126
|
+
}
|
|
5127
|
+
const nextTop = trapStack[trapStack.length - 1];
|
|
5128
|
+
if (nextTop) {
|
|
5129
|
+
nextTop.unpause();
|
|
5130
|
+
}
|
|
5131
|
+
document.removeEventListener("keydown", this.handleKeyDownBound, true);
|
|
5132
|
+
document.removeEventListener("focusin", this.handleFocusInBound, true);
|
|
5133
|
+
document.removeEventListener("mousedown", this.handleClickOutsideBound, true);
|
|
5134
|
+
document.removeEventListener("touchstart", this.handleClickOutsideBound, true);
|
|
5135
|
+
this.removeSentinels();
|
|
5136
|
+
this.removeInert();
|
|
5137
|
+
if (this.options.returnFocus) {
|
|
5138
|
+
this.restoreFocus();
|
|
5139
|
+
}
|
|
5140
|
+
this.options.onDeactivate();
|
|
5141
|
+
return this;
|
|
5142
|
+
}
|
|
5143
|
+
/**
|
|
5144
|
+
* Met en pause le trap (utilisé quand un trap fils s'ouvre au-dessus).
|
|
5145
|
+
*/
|
|
5146
|
+
pause() {
|
|
5147
|
+
this.paused = true;
|
|
5148
|
+
}
|
|
5149
|
+
/**
|
|
5150
|
+
* Sort de pause.
|
|
5151
|
+
*/
|
|
5152
|
+
unpause() {
|
|
5153
|
+
this.paused = false;
|
|
5154
|
+
}
|
|
5155
|
+
/**
|
|
5156
|
+
* Indique si le trap est actuellement actif et non en pause.
|
|
5157
|
+
*/
|
|
5158
|
+
isActive() {
|
|
5159
|
+
return this.active && !this.paused;
|
|
5160
|
+
}
|
|
5161
|
+
/**
|
|
5162
|
+
* Vérifie la conformité d'accessibilité WAI-ARIA du conteneur FocusTrap
|
|
5163
|
+
* et retourne la liste des contraintes manquantes.
|
|
5164
|
+
*/
|
|
5165
|
+
audit() {
|
|
5166
|
+
const warnings = [];
|
|
5167
|
+
const role = this.element.getAttribute("role");
|
|
5168
|
+
const isNativeDialog = this.element.tagName.toLowerCase() === "dialog";
|
|
5169
|
+
const validRoles = ["dialog", "alertdialog", "menu", "listbox", "tree", "grid"];
|
|
5170
|
+
if (!isNativeDialog && (!role || !validRoles.includes(role))) {
|
|
5171
|
+
warnings.push(
|
|
5172
|
+
'R\xF4le s\xE9mantique manquant ou inadapt\xE9 : d\xE9finissez role="dialog" (ou "alertdialog", "menu", "listbox") sur le conteneur.'
|
|
5173
|
+
);
|
|
5174
|
+
}
|
|
5175
|
+
if ((isNativeDialog || role === "dialog" || role === "alertdialog") && this.element.getAttribute("aria-modal") !== "true") {
|
|
5176
|
+
warnings.push(
|
|
5177
|
+
'Isolation modale manquante : d\xE9finissez aria-modal="true" sur le conteneur de dialogue (WCAG 4.1.2).'
|
|
5178
|
+
);
|
|
5179
|
+
}
|
|
5180
|
+
const ariaLabel = this.element.getAttribute("aria-label")?.trim();
|
|
5181
|
+
const hasValidLabelledby = this.checkAriaIdReferences(this.element, "aria-labelledby", warnings);
|
|
5182
|
+
if (!ariaLabel && !hasValidLabelledby) {
|
|
5183
|
+
warnings.push(
|
|
5184
|
+
'Nom accessible manquant : d\xE9finissez aria-labelledby="id-titre" ou aria-label="..." sur le conteneur (WCAG 4.1.2).'
|
|
5185
|
+
);
|
|
5186
|
+
}
|
|
5187
|
+
return warnings;
|
|
5188
|
+
}
|
|
5189
|
+
getAuditPrefix() {
|
|
5190
|
+
return "Wulf.FocusTrap";
|
|
5191
|
+
}
|
|
5192
|
+
getAuditTargetLabel() {
|
|
5193
|
+
return this.element.id ? `#${this.element.id}` : `<${this.element.tagName.toLowerCase()}>`;
|
|
5194
|
+
}
|
|
5195
|
+
/**
|
|
5196
|
+
* Détruit l'instance proprement.
|
|
5197
|
+
*/
|
|
5198
|
+
destroy() {
|
|
5199
|
+
this.deactivate();
|
|
5200
|
+
}
|
|
5201
|
+
// --- Implémentation interne ---
|
|
5202
|
+
handleKeyDown(e) {
|
|
5203
|
+
if (!this.isActive()) return;
|
|
5204
|
+
if (e.key === "Escape" && this.options.escapeDeactivates) {
|
|
5205
|
+
e.preventDefault();
|
|
5206
|
+
e.stopPropagation();
|
|
5207
|
+
this.deactivate();
|
|
5208
|
+
return;
|
|
5209
|
+
}
|
|
5210
|
+
if (e.key !== "Tab") return;
|
|
5211
|
+
const focusables = this.getFocusableElements();
|
|
5212
|
+
if (focusables.length === 0) {
|
|
5213
|
+
e.preventDefault();
|
|
5214
|
+
if (this.element.getAttribute("tabindex") === null) {
|
|
5215
|
+
this.element.setAttribute("tabindex", "-1");
|
|
5216
|
+
}
|
|
5217
|
+
this.element.focus();
|
|
5218
|
+
return;
|
|
5219
|
+
}
|
|
5220
|
+
const first = focusables[0];
|
|
5221
|
+
const last = focusables[focusables.length - 1];
|
|
5222
|
+
const current = document.activeElement;
|
|
5223
|
+
if (!e.shiftKey && (current === last || !this.element.contains(current))) {
|
|
5224
|
+
e.preventDefault();
|
|
5225
|
+
first.focus();
|
|
5226
|
+
} else if (e.shiftKey && (current === first || !this.element.contains(current))) {
|
|
5227
|
+
e.preventDefault();
|
|
5228
|
+
last.focus();
|
|
5229
|
+
}
|
|
5230
|
+
}
|
|
5231
|
+
handleFocusIn(e) {
|
|
5232
|
+
if (!this.isActive()) return;
|
|
5233
|
+
const target = e.target;
|
|
5234
|
+
if (!target) return;
|
|
5235
|
+
if (target === this.startSentinel) {
|
|
5236
|
+
const focusables = this.getFocusableElements();
|
|
5237
|
+
if (focusables.length > 0) {
|
|
5238
|
+
focusables[focusables.length - 1].focus();
|
|
5239
|
+
} else {
|
|
5240
|
+
this.element.focus();
|
|
5241
|
+
}
|
|
5242
|
+
return;
|
|
5243
|
+
}
|
|
5244
|
+
if (target === this.endSentinel) {
|
|
5245
|
+
const focusables = this.getFocusableElements();
|
|
5246
|
+
if (focusables.length > 0) {
|
|
5247
|
+
focusables[0].focus();
|
|
5248
|
+
} else {
|
|
5249
|
+
this.element.focus();
|
|
5250
|
+
}
|
|
5251
|
+
return;
|
|
5252
|
+
}
|
|
5253
|
+
if (!this.element.contains(target)) {
|
|
5254
|
+
const focusables = this.getFocusableElements();
|
|
5255
|
+
if (focusables.length > 0) {
|
|
5256
|
+
focusables[0].focus();
|
|
5257
|
+
} else {
|
|
5258
|
+
if (this.element.getAttribute("tabindex") === null) {
|
|
5259
|
+
this.element.setAttribute("tabindex", "-1");
|
|
5260
|
+
}
|
|
5261
|
+
this.element.focus();
|
|
5262
|
+
}
|
|
5263
|
+
}
|
|
5264
|
+
}
|
|
5265
|
+
handleClickOutside(e) {
|
|
5266
|
+
if (!this.isActive()) return;
|
|
5267
|
+
const target = e.target;
|
|
5268
|
+
if (target && !this.element.contains(target)) {
|
|
5269
|
+
e.preventDefault();
|
|
5270
|
+
e.stopPropagation();
|
|
5271
|
+
}
|
|
5272
|
+
}
|
|
5273
|
+
setupSentinels() {
|
|
5274
|
+
if (!this.startSentinel) {
|
|
5275
|
+
this.startSentinel = document.createElement("span");
|
|
5276
|
+
this.startSentinel.setAttribute("tabindex", "0");
|
|
5277
|
+
this.startSentinel.setAttribute("aria-hidden", "true");
|
|
5278
|
+
this.startSentinel.className = "wulf-sentinel-start";
|
|
5279
|
+
this.startSentinel.style.cssText = "position:fixed;top:0;left:0;opacity:0;pointer-events:none;width:0;height:0;";
|
|
5280
|
+
}
|
|
5281
|
+
if (!this.endSentinel) {
|
|
5282
|
+
this.endSentinel = document.createElement("span");
|
|
5283
|
+
this.endSentinel.setAttribute("tabindex", "0");
|
|
5284
|
+
this.endSentinel.setAttribute("aria-hidden", "true");
|
|
5285
|
+
this.endSentinel.className = "wulf-sentinel-end";
|
|
5286
|
+
this.endSentinel.style.cssText = "position:fixed;top:0;left:0;opacity:0;pointer-events:none;width:0;height:0;";
|
|
5287
|
+
}
|
|
5288
|
+
if (this.element.parentNode) {
|
|
5289
|
+
this.element.parentNode.insertBefore(this.startSentinel, this.element);
|
|
5290
|
+
this.element.parentNode.insertBefore(this.endSentinel, this.element.nextSibling);
|
|
5291
|
+
}
|
|
5292
|
+
}
|
|
5293
|
+
removeSentinels() {
|
|
5294
|
+
this.startSentinel?.remove();
|
|
5295
|
+
this.endSentinel?.remove();
|
|
5296
|
+
this.startSentinel = null;
|
|
5297
|
+
this.endSentinel = null;
|
|
5298
|
+
}
|
|
5299
|
+
applyInert() {
|
|
5300
|
+
this.inertSiblings = [];
|
|
5301
|
+
let parent = this.element.parentElement;
|
|
5302
|
+
let currentChild = this.element;
|
|
5303
|
+
while (parent && parent !== document.body) {
|
|
5304
|
+
currentChild = parent;
|
|
5305
|
+
parent = parent.parentElement;
|
|
5306
|
+
}
|
|
5307
|
+
if (parent === document.body) {
|
|
5308
|
+
Array.from(document.body.children).forEach((child) => {
|
|
5309
|
+
if (child instanceof HTMLElement && child !== currentChild && child !== this.startSentinel && child !== this.endSentinel && !child.hasAttribute("inert")) {
|
|
5310
|
+
child.setAttribute("inert", "");
|
|
5311
|
+
this.inertSiblings.push(child);
|
|
5312
|
+
}
|
|
5313
|
+
});
|
|
5314
|
+
}
|
|
5315
|
+
}
|
|
5316
|
+
removeInert() {
|
|
5317
|
+
this.inertSiblings.forEach((el) => el.removeAttribute("inert"));
|
|
5318
|
+
this.inertSiblings = [];
|
|
5319
|
+
}
|
|
5320
|
+
applyInitialFocus() {
|
|
5321
|
+
if (this.options.initialFocus === false) return;
|
|
5322
|
+
let targetEl = null;
|
|
5323
|
+
if (typeof this.options.initialFocus === "string") {
|
|
5324
|
+
targetEl = this.element.querySelector(this.options.initialFocus);
|
|
5325
|
+
} else if (this.options.initialFocus instanceof HTMLElement) {
|
|
5326
|
+
targetEl = this.options.initialFocus;
|
|
5327
|
+
}
|
|
5328
|
+
if (targetEl && this.isFocusable(targetEl)) {
|
|
5329
|
+
targetEl.focus();
|
|
5330
|
+
return;
|
|
5331
|
+
}
|
|
5332
|
+
const focusables = this.getFocusableElements();
|
|
5333
|
+
if (focusables.length > 0) {
|
|
5334
|
+
focusables[0].focus();
|
|
5335
|
+
} else {
|
|
5336
|
+
if (this.element.getAttribute("tabindex") === null) {
|
|
5337
|
+
this.element.setAttribute("tabindex", "-1");
|
|
5338
|
+
}
|
|
5339
|
+
this.element.focus();
|
|
5340
|
+
}
|
|
5341
|
+
}
|
|
5342
|
+
restoreFocus() {
|
|
5343
|
+
if (this.previousActiveElement && this.previousActiveElement.isConnected) {
|
|
5344
|
+
this.previousActiveElement.focus();
|
|
5345
|
+
return;
|
|
5346
|
+
}
|
|
5347
|
+
if (this.options.fallbackReturnFocus) {
|
|
5348
|
+
const fallback = typeof this.options.fallbackReturnFocus === "string" ? document.querySelector(this.options.fallbackReturnFocus) : this.options.fallbackReturnFocus;
|
|
5349
|
+
if (fallback && fallback.isConnected) {
|
|
5350
|
+
fallback.focus();
|
|
5351
|
+
}
|
|
5352
|
+
}
|
|
5353
|
+
}
|
|
5354
|
+
};
|
|
5355
|
+
|
|
5356
|
+
// src/focus-trap/index.ts
|
|
5357
|
+
if (typeof window !== "undefined") {
|
|
5358
|
+
const win = window;
|
|
5359
|
+
const wulfNamespace = win.Wulf || {};
|
|
5360
|
+
win.Wulf = wulfNamespace;
|
|
5361
|
+
wulfNamespace.FocusTrap = Object.assign(FocusTrap, {
|
|
5362
|
+
FocusTrap
|
|
5363
|
+
});
|
|
5364
|
+
}
|
|
4783
5365
|
return __toCommonJS(index_exports);
|
|
4784
5366
|
})();
|
|
4785
5367
|
if (typeof window !== "undefined") { window.Wulf = window.Wulf || {}; if (typeof Wulf !== "undefined" && Wulf) { var targets = ["Mask", "Scroll", "Masonry", "Toast"]; for (var i = 0; i < targets.length; i++) { var t = targets[i]; if (Wulf[t] && window.Wulf[t] !== Wulf[t]) { try { Object.defineProperty(window.Wulf, t, { value: Wulf[t], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[t] = Wulf[t]; } catch (__) {} } } } for (var k in Wulf) { if (window.Wulf[k] === undefined) { try { Object.defineProperty(window.Wulf, k, { value: Wulf[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[k] = Wulf[k]; } catch (__) {} } } } } }
|