wulf.js 1.8.4 → 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 +93 -21
- package/changelog.md +76 -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 +1177 -59
- package/dist/index.cjs.js.map +3 -3
- package/dist/index.esm.js +1177 -59
- package/dist/index.esm.js.map +3 -3
- package/dist/index.global.js +1177 -59
- 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 +337 -33
- package/dist/mask.cjs.js.map +3 -3
- package/dist/mask.css +1 -1
- package/dist/mask.css.map +2 -2
- package/dist/mask.esm.js +337 -33
- package/dist/mask.esm.js.map +3 -3
- package/dist/mask.global.js +337 -33
- 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 +296 -10
- package/dist/masonry.cjs.js.map +3 -3
- package/dist/masonry.esm.js +296 -10
- package/dist/masonry.esm.js.map +3 -3
- package/dist/masonry.global.js +296 -10
- 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 +332 -9
- package/dist/scroll.cjs.js.map +3 -3
- package/dist/scroll.esm.js +332 -9
- package/dist/scroll.esm.js.map +3 -3
- package/dist/scroll.global.js +332 -9
- 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 +289 -7
- package/dist/toast.cjs.js.map +3 -3
- package/dist/toast.css +1 -1
- package/dist/toast.css.map +2 -2
- package/dist/toast.esm.js +289 -7
- package/dist/toast.esm.js.map +3 -3
- package/dist/toast.global.js +289 -7
- 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 +54 -0
- package/dist/types/common/i18n.d.ts +39 -0
- 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 +5 -0
- package/dist/types/mask/BaseInputMask.d.ts +15 -1
- package/dist/types/mask/EmailEngine.d.ts +24 -2
- package/dist/types/mask/InputEmailMask.d.ts +8 -0
- package/dist/types/mask/InputMask.d.ts +9 -0
- package/dist/types/mask/types.d.ts +5 -2
- package/dist/types/masonry/Masonry.d.ts +18 -1
- package/dist/types/masonry/i18n/en.d.ts +2 -0
- package/dist/types/masonry/i18n/fr.d.ts +2 -0
- package/dist/types/masonry/i18n/index.d.ts +9 -0
- package/dist/types/masonry/i18n/types.d.ts +7 -0
- package/dist/types/masonry/index.d.ts +1 -0
- package/dist/types/masonry/types.d.ts +15 -5
- package/dist/types/scroll/ScrollBlock.d.ts +21 -1
- package/dist/types/scroll/i18n/en.d.ts +2 -0
- package/dist/types/scroll/i18n/fr.d.ts +2 -0
- package/dist/types/scroll/i18n/index.d.ts +9 -0
- package/dist/types/scroll/i18n/types.d.ts +11 -0
- package/dist/types/scroll/index.d.ts +2 -0
- package/dist/types/scroll/types.d.ts +9 -3
- package/dist/types/toast/Toast.d.ts +8 -1
- package/dist/types/toast/ToastInstance.d.ts +9 -1
- package/dist/types/toast/i18n/en.d.ts +2 -0
- package/dist/types/toast/i18n/fr.d.ts +2 -0
- package/dist/types/toast/i18n/index.d.ts +9 -0
- package/dist/types/toast/i18n/types.d.ts +7 -0
- package/dist/types/toast/index.d.ts +1 -0
- package/dist/types/toast/types.d.ts +12 -3
- package/package.json +9 -3
package/dist/index.esm.js
CHANGED
|
@@ -21,6 +21,49 @@ __export(mask_exports, {
|
|
|
21
21
|
resolveMaskConstructorArgs: () => resolveMaskConstructorArgs
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
+
// src/common/AuditableComponent.ts
|
|
25
|
+
var AuditableComponent = class {
|
|
26
|
+
/**
|
|
27
|
+
* Indication affichée en pied de warning pour expliquer comment désactiver l'audit.
|
|
28
|
+
*/
|
|
29
|
+
getAuditDisableHint() {
|
|
30
|
+
return "Passez { audit: false } dans les options pour d\xE9sactiver cet avertissement";
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Exécute l'audit d'accessibilité et émet un avertissement standardisé dans la console
|
|
34
|
+
* si l'audit est activé et que des contraintes manquent.
|
|
35
|
+
*/
|
|
36
|
+
runAuditWarning(enabled = true) {
|
|
37
|
+
if (!enabled) return [];
|
|
38
|
+
const warnings = this.audit();
|
|
39
|
+
if (warnings.length > 0 && typeof console !== "undefined" && typeof console.warn === "function") {
|
|
40
|
+
console.warn(
|
|
41
|
+
`[${this.getAuditPrefix()}] Audit d'accessibilit\xE9 \u2014 ${warnings.length} contrainte(s) manquante(s) sur ${this.getAuditTargetLabel()} :
|
|
42
|
+
` + warnings.map((w) => ` - ${w}`).join("\n") + `
|
|
43
|
+
(${this.getAuditDisableHint()})`
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
return warnings;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Vérifie si un attribut de référence d'IDs ARIA (ex: aria-labelledby, aria-describedby)
|
|
50
|
+
* pointe vers des éléments réellement présents dans le document.
|
|
51
|
+
*/
|
|
52
|
+
checkAriaIdReferences(element, attrName, warnings) {
|
|
53
|
+
const rawValue = element.getAttribute(attrName)?.trim();
|
|
54
|
+
if (!rawValue) return false;
|
|
55
|
+
const doc = element.ownerDocument || document;
|
|
56
|
+
const ids = rawValue.split(/\s+/).filter(Boolean);
|
|
57
|
+
const isValid = ids.length > 0 && ids.every((id) => Boolean(doc.getElementById(id)));
|
|
58
|
+
if (!isValid) {
|
|
59
|
+
warnings.push(
|
|
60
|
+
`Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
return isValid;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
24
67
|
// src/mask/BaseInputMask.ts
|
|
25
68
|
function resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOptions) {
|
|
26
69
|
const isSecondArgInput = Boolean(
|
|
@@ -39,8 +82,9 @@ function resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOption
|
|
|
39
82
|
options: inputOrOptions && typeof inputOrOptions === "object" && !("tagName" in inputOrOptions) ? inputOrOptions : {}
|
|
40
83
|
};
|
|
41
84
|
}
|
|
42
|
-
var BaseInputMask = class {
|
|
85
|
+
var BaseInputMask = class extends AuditableComponent {
|
|
43
86
|
constructor(targetOrWrapper, inputOrOptions, maybeOptions) {
|
|
87
|
+
super();
|
|
44
88
|
this.ghost = null;
|
|
45
89
|
this.isWrapperCreated = false;
|
|
46
90
|
this.isDestroyed = false;
|
|
@@ -51,6 +95,7 @@ var BaseInputMask = class {
|
|
|
51
95
|
this.onCutHandler = () => {
|
|
52
96
|
};
|
|
53
97
|
this.mutationObserver = null;
|
|
98
|
+
this.focusSelectTimerId = null;
|
|
54
99
|
this.onBaseCopy = (e) => {
|
|
55
100
|
if (!this.options.copyRaw || this.options.disabled || this.input.type === "password") return;
|
|
56
101
|
const start = this.input.selectionStart ?? 0;
|
|
@@ -69,7 +114,11 @@ var BaseInputMask = class {
|
|
|
69
114
|
this.onBaseFocus = () => {
|
|
70
115
|
this.isFocused = true;
|
|
71
116
|
if (this.options.selectAllOnFocus && this.input.value.length > 0) {
|
|
72
|
-
|
|
117
|
+
if (this.focusSelectTimerId !== null) {
|
|
118
|
+
clearTimeout(this.focusSelectTimerId);
|
|
119
|
+
}
|
|
120
|
+
this.focusSelectTimerId = window.setTimeout(() => {
|
|
121
|
+
this.focusSelectTimerId = null;
|
|
73
122
|
if (!this.isDestroyed && document.activeElement === this.input) {
|
|
74
123
|
this.input.select();
|
|
75
124
|
}
|
|
@@ -88,7 +137,7 @@ var BaseInputMask = class {
|
|
|
88
137
|
}
|
|
89
138
|
};
|
|
90
139
|
const { wrapper: providedWrapper, input, options } = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOptions);
|
|
91
|
-
if (!input ||
|
|
140
|
+
if (!input || typeof input !== "object" || input.nodeType !== 1 || input.tagName !== "INPUT") {
|
|
92
141
|
throw new Error(`[${new.target.name || "InputMask"}] input (HTMLInputElement) est requis.`);
|
|
93
142
|
}
|
|
94
143
|
this.input = input;
|
|
@@ -123,8 +172,10 @@ var BaseInputMask = class {
|
|
|
123
172
|
const dataSelectAll = this.getAttr("data-mask-select-on-focus") === "true";
|
|
124
173
|
const dataCopyRaw = this.getAttr("data-mask-copy-raw") === "true";
|
|
125
174
|
const dataAlign = this.getAttr("data-mask-align") || this.getAttr("data-align");
|
|
175
|
+
const dataAudit = this.getAttr("data-mask-audit");
|
|
126
176
|
const { disabled: optDisabled, align: optAlign, ...otherOptions } = options;
|
|
127
177
|
const resolvedDisabled = optDisabled !== void 0 ? optDisabled : dataDisabled ? true : false;
|
|
178
|
+
const resolvedAudit = options.audit ?? (dataAudit !== null ? dataAudit !== "false" : true);
|
|
128
179
|
const isPassword = this.input.type === "password";
|
|
129
180
|
this.options = {
|
|
130
181
|
...otherOptions,
|
|
@@ -134,7 +185,8 @@ var BaseInputMask = class {
|
|
|
134
185
|
copyRaw: isPassword ? false : options.copyRaw ?? dataCopyRaw ?? false,
|
|
135
186
|
disabled: resolvedDisabled,
|
|
136
187
|
align: optAlign ?? (dataAlign || void 0),
|
|
137
|
-
emitNativeInput: options.emitNativeInput ?? true
|
|
188
|
+
emitNativeInput: options.emitNativeInput ?? true,
|
|
189
|
+
audit: resolvedAudit
|
|
138
190
|
};
|
|
139
191
|
if (this.options.showMaskOnFocus) {
|
|
140
192
|
this.wrapper.classList.add("mask-focus-only");
|
|
@@ -213,6 +265,8 @@ var BaseInputMask = class {
|
|
|
213
265
|
"data-mask-pad-decimals",
|
|
214
266
|
"data-mask-auto-lowercase",
|
|
215
267
|
"data-mask-cycle-suggestions",
|
|
268
|
+
"data-mask-default-tld",
|
|
269
|
+
"data-mask-tlds",
|
|
216
270
|
"data-disabled",
|
|
217
271
|
"data-mask-align",
|
|
218
272
|
"data-align",
|
|
@@ -477,12 +531,58 @@ var BaseInputMask = class {
|
|
|
477
531
|
getRawValue() {
|
|
478
532
|
return this.input.value;
|
|
479
533
|
}
|
|
534
|
+
/**
|
|
535
|
+
* Vérifie la conformité d'accessibilité WAI-ARIA du champ de saisie (étiquetage, format attendu)
|
|
536
|
+
* et retourne la liste des contraintes manquantes.
|
|
537
|
+
*/
|
|
538
|
+
audit() {
|
|
539
|
+
const warnings = [];
|
|
540
|
+
const doc = this.input.ownerDocument || document;
|
|
541
|
+
const ariaLabel = this.input.getAttribute("aria-label")?.trim();
|
|
542
|
+
const hasValidLabelledby = this.checkAriaIdReferences(this.input, "aria-labelledby", warnings);
|
|
543
|
+
const hasWrappingLabel = Boolean(this.input.closest("label"));
|
|
544
|
+
const hasNativeLabels = Boolean(this.input.labels && this.input.labels.length > 0);
|
|
545
|
+
let hasExplicitLabelFor = false;
|
|
546
|
+
if (this.input.id && typeof CSS !== "undefined" && typeof CSS.escape === "function") {
|
|
547
|
+
hasExplicitLabelFor = Boolean(doc.querySelector(`label[for="${CSS.escape(this.input.id)}"]`));
|
|
548
|
+
} else if (this.input.id) {
|
|
549
|
+
hasExplicitLabelFor = Boolean(doc.querySelector(`label[for="${this.input.id}"]`));
|
|
550
|
+
}
|
|
551
|
+
if (!ariaLabel && !hasValidLabelledby && !hasWrappingLabel && !hasNativeLabels && !hasExplicitLabelFor) {
|
|
552
|
+
warnings.push(
|
|
553
|
+
`\xC9tiquetage accessible manquant : associez un <label for="id"> (ou d\xE9finissez aria-label / aria-labelledby) sur l'input (WCAG 4.1.2).`
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
this.checkAriaIdReferences(this.input, "aria-describedby", warnings);
|
|
557
|
+
const extraWarnings = this.getSpecificAuditWarnings();
|
|
558
|
+
warnings.push(...extraWarnings);
|
|
559
|
+
return warnings;
|
|
560
|
+
}
|
|
561
|
+
getAuditPrefix() {
|
|
562
|
+
return `Wulf.Mask.${this.constructor.name || "InputMask"}`;
|
|
563
|
+
}
|
|
564
|
+
getAuditTargetLabel() {
|
|
565
|
+
return this.input.id ? `#${this.input.id}` : this.input.name ? `input[name="${this.input.name}"]` : "<input>";
|
|
566
|
+
}
|
|
567
|
+
getAuditDisableHint() {
|
|
568
|
+
return 'Passez { audit: false } ou data-mask-audit="false" pour d\xE9sactiver cet avertissement';
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Crochet permettant aux classes filles d'ajouter des vérifications d'audit spécifiques.
|
|
572
|
+
*/
|
|
573
|
+
getSpecificAuditWarnings() {
|
|
574
|
+
return [];
|
|
575
|
+
}
|
|
480
576
|
/**
|
|
481
577
|
* Supprime les éléments fantômes, restaure les propriétés et nettoie les attributs.
|
|
482
578
|
*/
|
|
483
579
|
destroy() {
|
|
484
580
|
if (this.isDestroyed) return;
|
|
485
581
|
this.isDestroyed = true;
|
|
582
|
+
if (this.focusSelectTimerId !== null) {
|
|
583
|
+
clearTimeout(this.focusSelectTimerId);
|
|
584
|
+
this.focusSelectTimerId = null;
|
|
585
|
+
}
|
|
486
586
|
if (this.mutationObserver) {
|
|
487
587
|
this.mutationObserver.disconnect();
|
|
488
588
|
this.mutationObserver = null;
|
|
@@ -1244,6 +1344,9 @@ var InputMask = class extends BaseInputMask {
|
|
|
1244
1344
|
this.onChangeNativeHandler = () => {
|
|
1245
1345
|
};
|
|
1246
1346
|
this.wasInputModeInferred = false;
|
|
1347
|
+
this.cutTimerId = null;
|
|
1348
|
+
this.pasteTimerId = null;
|
|
1349
|
+
this.resetTimerId = null;
|
|
1247
1350
|
this.history = new MaskHistory();
|
|
1248
1351
|
this.engine = new MaskEngine(this.options.mask || "", {
|
|
1249
1352
|
placeholderChar: this.options.placeholderChar,
|
|
@@ -1251,12 +1354,7 @@ var InputMask = class extends BaseInputMask {
|
|
|
1251
1354
|
strict: this.options.strict,
|
|
1252
1355
|
autoLowercase: this.options.autoLowercase
|
|
1253
1356
|
});
|
|
1254
|
-
|
|
1255
|
-
if (this.engine.isNumericOnly()) {
|
|
1256
|
-
this.input.inputMode = "numeric";
|
|
1257
|
-
this.wasInputModeInferred = true;
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1357
|
+
this.syncInferredInputMode();
|
|
1260
1358
|
this.keyboard = new MaskKeyboard({
|
|
1261
1359
|
getInput: () => this.input,
|
|
1262
1360
|
getEngine: () => this.engine,
|
|
@@ -1269,6 +1367,19 @@ var InputMask = class extends BaseInputMask {
|
|
|
1269
1367
|
this.bindEvents();
|
|
1270
1368
|
this.lastValue = this.input.value;
|
|
1271
1369
|
this.syncInitialValue();
|
|
1370
|
+
this.runAuditWarning(this.options.audit);
|
|
1371
|
+
}
|
|
1372
|
+
getSpecificAuditWarnings() {
|
|
1373
|
+
const warnings = [];
|
|
1374
|
+
const hasDescribedby = Boolean(this.input.getAttribute("aria-describedby")?.trim());
|
|
1375
|
+
const hasPlaceholder = Boolean(this.input.getAttribute("placeholder")?.trim());
|
|
1376
|
+
const hasAriaPlaceholder = Boolean(this.input.getAttribute("aria-placeholder")?.trim());
|
|
1377
|
+
if (!hasDescribedby && !hasPlaceholder && !hasAriaPlaceholder && !this.options.disabled) {
|
|
1378
|
+
warnings.push(
|
|
1379
|
+
"Indication du format attendu manquante : d\xE9finissez aria-describedby, placeholder ou aria-placeholder pour informer les technologies d'assistance (WCAG 3.3.2)."
|
|
1380
|
+
);
|
|
1381
|
+
}
|
|
1382
|
+
return warnings;
|
|
1272
1383
|
}
|
|
1273
1384
|
extractRawSnippet(snippet) {
|
|
1274
1385
|
return this.engine.extractRaw(snippet);
|
|
@@ -1320,7 +1431,9 @@ var InputMask = class extends BaseInputMask {
|
|
|
1320
1431
|
this.onScroll = this.onScroll.bind(this);
|
|
1321
1432
|
this.onBeforeInput = this.onBeforeInput.bind(this);
|
|
1322
1433
|
this.onCutHandler = () => {
|
|
1323
|
-
|
|
1434
|
+
if (this.cutTimerId !== null) clearTimeout(this.cutTimerId);
|
|
1435
|
+
this.cutTimerId = window.setTimeout(() => {
|
|
1436
|
+
this.cutTimerId = null;
|
|
1324
1437
|
if (this.isDestroyed) return;
|
|
1325
1438
|
if (this.options.disabled) {
|
|
1326
1439
|
this.checkValueChange();
|
|
@@ -1352,7 +1465,9 @@ var InputMask = class extends BaseInputMask {
|
|
|
1352
1465
|
this.input.addEventListener("change", this.onChangeNativeHandler);
|
|
1353
1466
|
if (this.input.form) {
|
|
1354
1467
|
this.onFormResetHandler = () => {
|
|
1355
|
-
|
|
1468
|
+
if (this.resetTimerId !== null) clearTimeout(this.resetTimerId);
|
|
1469
|
+
this.resetTimerId = window.setTimeout(() => {
|
|
1470
|
+
this.resetTimerId = null;
|
|
1356
1471
|
if (this.isDestroyed) return;
|
|
1357
1472
|
if (this.options.disabled) {
|
|
1358
1473
|
this.checkValueChange();
|
|
@@ -1364,11 +1479,40 @@ var InputMask = class extends BaseInputMask {
|
|
|
1364
1479
|
this.input.form.addEventListener("reset", this.onFormResetHandler);
|
|
1365
1480
|
}
|
|
1366
1481
|
}
|
|
1482
|
+
/**
|
|
1483
|
+
* Synchronise dynamiquement l'attribut inputmode="numeric" selon le motif actif
|
|
1484
|
+
* sans jamais écraser un inputmode défini explicitement par l'hôte.
|
|
1485
|
+
*/
|
|
1486
|
+
syncInferredInputMode() {
|
|
1487
|
+
if (!this.options.inferInputMode) return;
|
|
1488
|
+
const isNum = !this.options.disabled && this.engine.isNumericOnly();
|
|
1489
|
+
if (isNum) {
|
|
1490
|
+
if (!this.input.hasAttribute("inputmode")) {
|
|
1491
|
+
this.input.inputMode = "numeric";
|
|
1492
|
+
this.wasInputModeInferred = true;
|
|
1493
|
+
}
|
|
1494
|
+
} else if (this.wasInputModeInferred && this.input.getAttribute("inputmode") === "numeric") {
|
|
1495
|
+
this.input.removeAttribute("inputmode");
|
|
1496
|
+
this.wasInputModeInferred = false;
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1367
1499
|
/**
|
|
1368
1500
|
* Supprime tous les écouteurs et nettoie les attributs associés.
|
|
1369
1501
|
*/
|
|
1370
1502
|
destroy() {
|
|
1371
1503
|
if (this.isDestroyed) return;
|
|
1504
|
+
if (this.cutTimerId !== null) {
|
|
1505
|
+
clearTimeout(this.cutTimerId);
|
|
1506
|
+
this.cutTimerId = null;
|
|
1507
|
+
}
|
|
1508
|
+
if (this.pasteTimerId !== null) {
|
|
1509
|
+
clearTimeout(this.pasteTimerId);
|
|
1510
|
+
this.pasteTimerId = null;
|
|
1511
|
+
}
|
|
1512
|
+
if (this.resetTimerId !== null) {
|
|
1513
|
+
clearTimeout(this.resetTimerId);
|
|
1514
|
+
this.resetTimerId = null;
|
|
1515
|
+
}
|
|
1372
1516
|
this.input.removeEventListener("beforeinput", this.onBeforeInput);
|
|
1373
1517
|
this.input.removeEventListener("input", this.handleInput);
|
|
1374
1518
|
this.input.removeEventListener("keydown", this.onKeyDown);
|
|
@@ -1430,6 +1574,7 @@ var InputMask = class extends BaseInputMask {
|
|
|
1430
1574
|
this.history.clear();
|
|
1431
1575
|
}
|
|
1432
1576
|
this.setDisabled(true);
|
|
1577
|
+
this.syncInferredInputMode();
|
|
1433
1578
|
return;
|
|
1434
1579
|
}
|
|
1435
1580
|
this.options.mask = newPattern;
|
|
@@ -1440,6 +1585,7 @@ var InputMask = class extends BaseInputMask {
|
|
|
1440
1585
|
this.history.clear();
|
|
1441
1586
|
}
|
|
1442
1587
|
this.setDisabled(false);
|
|
1588
|
+
this.syncInferredInputMode();
|
|
1443
1589
|
}
|
|
1444
1590
|
handleAttributeMutation(attrName) {
|
|
1445
1591
|
super.handleAttributeMutation(attrName);
|
|
@@ -1597,7 +1743,9 @@ var InputMask = class extends BaseInputMask {
|
|
|
1597
1743
|
}
|
|
1598
1744
|
onPaste(e) {
|
|
1599
1745
|
if (this.options.disabled) {
|
|
1600
|
-
|
|
1746
|
+
if (this.pasteTimerId !== null) clearTimeout(this.pasteTimerId);
|
|
1747
|
+
this.pasteTimerId = window.setTimeout(() => {
|
|
1748
|
+
this.pasteTimerId = null;
|
|
1601
1749
|
if (!this.isDestroyed) this.checkValueChange();
|
|
1602
1750
|
}, 0);
|
|
1603
1751
|
return;
|
|
@@ -2081,6 +2229,7 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2081
2229
|
isValid: true
|
|
2082
2230
|
});
|
|
2083
2231
|
}
|
|
2232
|
+
this.runAuditWarning(this.options.audit);
|
|
2084
2233
|
}
|
|
2085
2234
|
extractRawSnippet(snippet) {
|
|
2086
2235
|
const p = this.engine.parse(snippet);
|
|
@@ -2406,9 +2555,12 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2406
2555
|
var _EmailEngine = class _EmailEngine {
|
|
2407
2556
|
constructor(options = {}) {
|
|
2408
2557
|
this.defaultDomain = null;
|
|
2558
|
+
this.defaultTld = "__";
|
|
2409
2559
|
this.domains = options.domains && options.domains.length > 0 ? options.domains : _EmailEngine.DEFAULT_DOMAINS;
|
|
2560
|
+
this.tlds = options.tlds && options.tlds.length > 0 ? options.tlds.map((t) => t.trim().replace(/^\./, "")).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
|
|
2410
2561
|
this.suggestOnAt = options.suggestOnAt ?? true;
|
|
2411
2562
|
this.setDefaultDomain(options.defaultDomain ?? null);
|
|
2563
|
+
this.setDefaultTld(options.defaultTld !== void 0 ? options.defaultTld : "__");
|
|
2412
2564
|
}
|
|
2413
2565
|
/**
|
|
2414
2566
|
* Définit ou modifie le domaine suggéré par défaut.
|
|
@@ -2422,6 +2574,35 @@ var _EmailEngine = class _EmailEngine {
|
|
|
2422
2574
|
this.defaultDomain = null;
|
|
2423
2575
|
}
|
|
2424
2576
|
}
|
|
2577
|
+
/**
|
|
2578
|
+
* Définit ou modifie l'extension (TLD) ou gabarit suggéré par défaut sur un domaine inconnu.
|
|
2579
|
+
*/
|
|
2580
|
+
setDefaultTld(tld) {
|
|
2581
|
+
if (tld === true) {
|
|
2582
|
+
this.defaultTld = this.tlds.length > 0 ? this.tlds[0] : null;
|
|
2583
|
+
} else if (typeof tld === "string" && tld.trim().length > 0) {
|
|
2584
|
+
this.defaultTld = tld.trim().replace(/^\./, "");
|
|
2585
|
+
} else {
|
|
2586
|
+
this.defaultTld = null;
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
/**
|
|
2590
|
+
* Définit ou modifie la liste des extensions (TLD) proposées par ordre de priorité.
|
|
2591
|
+
*/
|
|
2592
|
+
setTlds(tlds) {
|
|
2593
|
+
this.tlds = tlds && tlds.length > 0 ? tlds.map((t) => t.trim().replace(/^\./, "")).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
|
|
2594
|
+
}
|
|
2595
|
+
/**
|
|
2596
|
+
* Retourne l'ensemble des extensions (TLD) correspondant au fragment saisi après le dernier point,
|
|
2597
|
+
* dans l'ordre exact fourni par l'utilisateur.
|
|
2598
|
+
*/
|
|
2599
|
+
getMatchingTlds(tldInput) {
|
|
2600
|
+
const query = (tldInput ?? "").toLowerCase();
|
|
2601
|
+
if (query.length === 0) {
|
|
2602
|
+
return [...this.tlds];
|
|
2603
|
+
}
|
|
2604
|
+
return this.tlds.filter((t) => t.toLowerCase().startsWith(query) && t.toLowerCase() !== query);
|
|
2605
|
+
}
|
|
2425
2606
|
/**
|
|
2426
2607
|
* Retourne l'ensemble des domaines correspondant à la saisie courante.
|
|
2427
2608
|
*/
|
|
@@ -2442,10 +2623,10 @@ var _EmailEngine = class _EmailEngine {
|
|
|
2442
2623
|
return this.domains.filter((d) => d.toLowerCase().startsWith(query) && d.toLowerCase() !== query);
|
|
2443
2624
|
}
|
|
2444
2625
|
/**
|
|
2445
|
-
* Analyse la saisie courante et calcule la suggestion de domaine adaptée.
|
|
2626
|
+
* Analyse la saisie courante et calcule la suggestion de domaine ou d'extension (TLD) adaptée.
|
|
2446
2627
|
*
|
|
2447
2628
|
* @param input Saisie utilisateur
|
|
2448
|
-
* @param matchIndex Index de la suggestion à sélectionner si plusieurs domaines correspondent (permet le cyclage)
|
|
2629
|
+
* @param matchIndex Index de la suggestion à sélectionner si plusieurs domaines/TLD correspondent (permet le cyclage)
|
|
2449
2630
|
*/
|
|
2450
2631
|
getSuggestion(input, matchIndex = 0) {
|
|
2451
2632
|
const val = input ?? "";
|
|
@@ -2454,30 +2635,104 @@ var _EmailEngine = class _EmailEngine {
|
|
|
2454
2635
|
return {
|
|
2455
2636
|
full: val ? `${val}@${this.defaultDomain}` : `@${this.defaultDomain}`,
|
|
2456
2637
|
remaining: `@${this.defaultDomain}`,
|
|
2457
|
-
matchedDomain: this.defaultDomain
|
|
2638
|
+
matchedDomain: this.defaultDomain,
|
|
2639
|
+
isHintOnly: false
|
|
2458
2640
|
};
|
|
2459
2641
|
}
|
|
2460
|
-
return { full: val, remaining: "", matchedDomain: null };
|
|
2642
|
+
return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2461
2643
|
}
|
|
2462
2644
|
const atIndex = val.indexOf("@");
|
|
2463
2645
|
const localPart = val.substring(0, atIndex);
|
|
2464
2646
|
const domainPart = val.substring(atIndex + 1);
|
|
2465
2647
|
if (val.indexOf("@", atIndex + 1) !== -1) {
|
|
2466
|
-
return { full: val, remaining: "", matchedDomain: null };
|
|
2648
|
+
return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2467
2649
|
}
|
|
2468
2650
|
const matches = this.getMatchingDomains(input);
|
|
2469
|
-
if (matches.length
|
|
2470
|
-
|
|
2651
|
+
if (matches.length > 0) {
|
|
2652
|
+
const safeIndex = (matchIndex % matches.length + matches.length) % matches.length;
|
|
2653
|
+
const matched = matches[safeIndex];
|
|
2654
|
+
const query = domainPart.toLowerCase();
|
|
2655
|
+
const remaining = matched.substring(query.length);
|
|
2656
|
+
return {
|
|
2657
|
+
full: `${localPart}@${matched}`,
|
|
2658
|
+
remaining,
|
|
2659
|
+
matchedDomain: matched,
|
|
2660
|
+
isHintOnly: false
|
|
2661
|
+
};
|
|
2471
2662
|
}
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
const
|
|
2476
|
-
|
|
2477
|
-
full:
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2663
|
+
if (domainPart.length === 0 || domainPart.startsWith(".")) {
|
|
2664
|
+
return { full: input, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2665
|
+
}
|
|
2666
|
+
const lowerDomain = domainPart.toLowerCase();
|
|
2667
|
+
if (this.domains.some((d) => d.toLowerCase() === lowerDomain)) {
|
|
2668
|
+
return { full: input, remaining: "", matchedDomain: domainPart, isHintOnly: false };
|
|
2669
|
+
}
|
|
2670
|
+
const lastDotIndex = domainPart.lastIndexOf(".");
|
|
2671
|
+
if (lastDotIndex === -1) {
|
|
2672
|
+
if (!this.defaultTld) {
|
|
2673
|
+
return { full: input, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2674
|
+
}
|
|
2675
|
+
const isHint = this.defaultTld.includes("_");
|
|
2676
|
+
const remaining = `.${this.defaultTld}`;
|
|
2677
|
+
const fullDomain = `${domainPart}.${this.defaultTld}`;
|
|
2678
|
+
return {
|
|
2679
|
+
full: isHint ? input : `${localPart}@${fullDomain}`,
|
|
2680
|
+
remaining,
|
|
2681
|
+
matchedDomain: isHint ? null : fullDomain,
|
|
2682
|
+
isHintOnly: isHint
|
|
2683
|
+
};
|
|
2684
|
+
}
|
|
2685
|
+
const hostPart = domainPart.substring(0, lastDotIndex);
|
|
2686
|
+
const tldPart = domainPart.substring(lastDotIndex + 1);
|
|
2687
|
+
if (!hostPart || hostPart.endsWith(".")) {
|
|
2688
|
+
return { full: input, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2689
|
+
}
|
|
2690
|
+
if (tldPart.length === 0) {
|
|
2691
|
+
if (this.defaultTld && !this.defaultTld.includes("_")) {
|
|
2692
|
+
const fullDomain = `${hostPart}.${this.defaultTld}`;
|
|
2693
|
+
return {
|
|
2694
|
+
full: `${localPart}@${fullDomain}`,
|
|
2695
|
+
remaining: this.defaultTld,
|
|
2696
|
+
matchedDomain: fullDomain,
|
|
2697
|
+
isHintOnly: false
|
|
2698
|
+
};
|
|
2699
|
+
}
|
|
2700
|
+
if (this.defaultTld && this.defaultTld.includes("_")) {
|
|
2701
|
+
return {
|
|
2702
|
+
full: input,
|
|
2703
|
+
remaining: this.defaultTld,
|
|
2704
|
+
matchedDomain: null,
|
|
2705
|
+
isHintOnly: true
|
|
2706
|
+
};
|
|
2707
|
+
}
|
|
2708
|
+
return { full: input, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2709
|
+
}
|
|
2710
|
+
const lowerTld = tldPart.toLowerCase();
|
|
2711
|
+
const matchingTlds = this.getMatchingTlds(tldPart);
|
|
2712
|
+
if (matchingTlds.length > 0) {
|
|
2713
|
+
const safeTldIndex = (matchIndex % matchingTlds.length + matchingTlds.length) % matchingTlds.length;
|
|
2714
|
+
const matchedTld = matchingTlds[safeTldIndex];
|
|
2715
|
+
const remaining = matchedTld.substring(lowerTld.length);
|
|
2716
|
+
const fullDomain = `${hostPart}.${matchedTld}`;
|
|
2717
|
+
return {
|
|
2718
|
+
full: `${localPart}@${fullDomain}`,
|
|
2719
|
+
remaining,
|
|
2720
|
+
matchedDomain: fullDomain,
|
|
2721
|
+
isHintOnly: false
|
|
2722
|
+
};
|
|
2723
|
+
}
|
|
2724
|
+
if (this.defaultTld && this.defaultTld.includes("_") && tldPart.length < this.defaultTld.length) {
|
|
2725
|
+
const remaining = this.defaultTld.substring(tldPart.length);
|
|
2726
|
+
if (remaining.includes("_")) {
|
|
2727
|
+
return {
|
|
2728
|
+
full: input,
|
|
2729
|
+
remaining,
|
|
2730
|
+
matchedDomain: null,
|
|
2731
|
+
isHintOnly: true
|
|
2732
|
+
};
|
|
2733
|
+
}
|
|
2734
|
+
}
|
|
2735
|
+
return { full: input, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2481
2736
|
}
|
|
2482
2737
|
};
|
|
2483
2738
|
_EmailEngine.DEFAULT_DOMAINS = [
|
|
@@ -2492,6 +2747,27 @@ _EmailEngine.DEFAULT_DOMAINS = [
|
|
|
2492
2747
|
"laposte.net",
|
|
2493
2748
|
"proton.me"
|
|
2494
2749
|
];
|
|
2750
|
+
_EmailEngine.DEFAULT_TLDS = [
|
|
2751
|
+
"com",
|
|
2752
|
+
"fr",
|
|
2753
|
+
"net",
|
|
2754
|
+
"org",
|
|
2755
|
+
"eu",
|
|
2756
|
+
"io",
|
|
2757
|
+
"co",
|
|
2758
|
+
"info",
|
|
2759
|
+
"biz",
|
|
2760
|
+
"me",
|
|
2761
|
+
"tv",
|
|
2762
|
+
"fi",
|
|
2763
|
+
"be",
|
|
2764
|
+
"ch",
|
|
2765
|
+
"ca",
|
|
2766
|
+
"uk",
|
|
2767
|
+
"de",
|
|
2768
|
+
"es",
|
|
2769
|
+
"it"
|
|
2770
|
+
];
|
|
2495
2771
|
var EmailEngine = _EmailEngine;
|
|
2496
2772
|
|
|
2497
2773
|
// src/mask/InputEmailMask.ts
|
|
@@ -2505,6 +2781,10 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2505
2781
|
const dataAutoLower = wrap?.getAttribute("data-mask-auto-lowercase") === "true" || inp?.getAttribute("data-mask-auto-lowercase") === "true";
|
|
2506
2782
|
const dataAriaAuto = wrap?.getAttribute("data-mask-aria-autocomplete") ?? inp?.getAttribute("data-mask-aria-autocomplete");
|
|
2507
2783
|
const setAriaAutocomplete = opts.setAriaAutocomplete ?? (dataAriaAuto !== null ? dataAriaAuto !== "false" : true);
|
|
2784
|
+
const dataTlds = wrap?.getAttribute("data-mask-tlds") ?? inp?.getAttribute("data-mask-tlds");
|
|
2785
|
+
const parsedTlds = opts.tlds ?? (dataTlds ? dataTlds.split(",").map((s) => s.trim()).filter(Boolean) : void 0);
|
|
2786
|
+
const dataDefaultTld = wrap?.getAttribute("data-mask-default-tld") ?? inp?.getAttribute("data-mask-default-tld");
|
|
2787
|
+
const resolvedDefaultTld = opts.defaultTld !== void 0 ? opts.defaultTld : dataDefaultTld !== null ? dataDefaultTld === "false" || dataDefaultTld === "none" ? null : dataDefaultTld === "true" ? true : dataDefaultTld : void 0;
|
|
2508
2788
|
const resolvedOptions = {
|
|
2509
2789
|
completeOnTab: true,
|
|
2510
2790
|
completeOnArrowRight: true,
|
|
@@ -2512,7 +2792,9 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2512
2792
|
cycleSuggestions: opts.cycleSuggestions ?? dataCycle ?? false,
|
|
2513
2793
|
autoLowercase: opts.autoLowercase ?? dataAutoLower ?? false,
|
|
2514
2794
|
setAriaAutocomplete,
|
|
2515
|
-
...opts
|
|
2795
|
+
...opts,
|
|
2796
|
+
...parsedTlds !== void 0 ? { tlds: parsedTlds } : {},
|
|
2797
|
+
...resolvedDefaultTld !== void 0 ? { defaultTld: resolvedDefaultTld } : {}
|
|
2516
2798
|
};
|
|
2517
2799
|
super(wrap, inp, resolvedOptions);
|
|
2518
2800
|
this.currentSuggestion = { full: "", remaining: "", matchedDomain: null };
|
|
@@ -2530,6 +2812,7 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2530
2812
|
if (!this.options.disabled) {
|
|
2531
2813
|
this.updateSuggestion();
|
|
2532
2814
|
}
|
|
2815
|
+
this.runAuditWarning(this.options.audit);
|
|
2533
2816
|
}
|
|
2534
2817
|
onNativeValueSet(_strVal) {
|
|
2535
2818
|
if (this.options.disabled) return;
|
|
@@ -2625,7 +2908,7 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2625
2908
|
}
|
|
2626
2909
|
handleKeyDown(e) {
|
|
2627
2910
|
if (this.options.disabled) return;
|
|
2628
|
-
const hasSuggestion = Boolean(this.currentSuggestion.remaining);
|
|
2911
|
+
const hasSuggestion = Boolean(this.currentSuggestion.remaining) && !this.currentSuggestion.isHintOnly;
|
|
2629
2912
|
const cursor = this.input.selectionStart ?? 0;
|
|
2630
2913
|
const isAtEnd = cursor === this.input.value.length;
|
|
2631
2914
|
const isNotEmpty = this.input.value.length > 0;
|
|
@@ -2663,7 +2946,7 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2663
2946
|
* Valide et applique la suggestion courante dans le champ natif.
|
|
2664
2947
|
*/
|
|
2665
2948
|
acceptSuggestion() {
|
|
2666
|
-
if (!this.currentSuggestion.remaining || this.options.disabled || this.input.value.length === 0) return false;
|
|
2949
|
+
if (!this.currentSuggestion.remaining || this.currentSuggestion.isHintOnly || this.options.disabled || this.input.value.length === 0) return false;
|
|
2667
2950
|
const completed = this.currentSuggestion.full;
|
|
2668
2951
|
this.setNativeValue(completed);
|
|
2669
2952
|
this.input.setSelectionRange(completed.length, completed.length);
|
|
@@ -2684,6 +2967,21 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2684
2967
|
this.engine.setDefaultDomain(domain);
|
|
2685
2968
|
this.updateSuggestion();
|
|
2686
2969
|
}
|
|
2970
|
+
/**
|
|
2971
|
+
* Modifie dynamiquement l'extension (TLD) ou gabarit suggéré par défaut sur un domaine inconnu.
|
|
2972
|
+
*/
|
|
2973
|
+
setDefaultTld(tld) {
|
|
2974
|
+
this.engine.setDefaultTld(tld);
|
|
2975
|
+
this.updateSuggestion();
|
|
2976
|
+
}
|
|
2977
|
+
/**
|
|
2978
|
+
* Modifie dynamiquement la liste des extensions (TLD) connues.
|
|
2979
|
+
*/
|
|
2980
|
+
setTlds(tlds) {
|
|
2981
|
+
this.engine.setTlds(tlds);
|
|
2982
|
+
this.currentSuggestionIndex = 0;
|
|
2983
|
+
this.updateSuggestion();
|
|
2984
|
+
}
|
|
2687
2985
|
handleFocus() {
|
|
2688
2986
|
this.wrapper.classList.add("is-focused");
|
|
2689
2987
|
this.syncGhostStyles();
|
|
@@ -2704,6 +3002,12 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2704
3002
|
this.options.cycleSuggestions = this.getAttr("data-mask-cycle-suggestions") === "true";
|
|
2705
3003
|
} else if (attrName === "data-mask-auto-lowercase") {
|
|
2706
3004
|
this.options.autoLowercase = this.getAttr("data-mask-auto-lowercase") === "true";
|
|
3005
|
+
} else if (attrName === "data-mask-default-tld") {
|
|
3006
|
+
const val = this.getAttr("data-mask-default-tld");
|
|
3007
|
+
this.setDefaultTld(val === null || val === "false" || val === "none" ? null : val === "true" ? true : val);
|
|
3008
|
+
} else if (attrName === "data-mask-tlds") {
|
|
3009
|
+
const val = this.getAttr("data-mask-tlds");
|
|
3010
|
+
this.setTlds(val ? val.split(",").map((s) => s.trim()).filter(Boolean) : null);
|
|
2707
3011
|
} else if (attrName === "placeholder") {
|
|
2708
3012
|
this.updateSuggestion();
|
|
2709
3013
|
}
|
|
@@ -2711,7 +3015,7 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2711
3015
|
getDetail() {
|
|
2712
3016
|
return {
|
|
2713
3017
|
value: this.input.value,
|
|
2714
|
-
suggestedValue: this.currentSuggestion.full,
|
|
3018
|
+
suggestedValue: this.currentSuggestion.isHintOnly ? "" : this.currentSuggestion.full,
|
|
2715
3019
|
domain: this.currentSuggestion.matchedDomain
|
|
2716
3020
|
};
|
|
2717
3021
|
}
|
|
@@ -2769,16 +3073,207 @@ var mask_default = InputMask;
|
|
|
2769
3073
|
// src/scroll/index.ts
|
|
2770
3074
|
var scroll_exports = {};
|
|
2771
3075
|
__export(scroll_exports, {
|
|
3076
|
+
LocalizedComponent: () => LocalizedComponent,
|
|
2772
3077
|
Scroll: () => Scroll,
|
|
2773
3078
|
ScrollBlock: () => ScrollBlock,
|
|
2774
|
-
|
|
3079
|
+
createI18nManager: () => createI18nManager,
|
|
3080
|
+
default: () => scroll_default,
|
|
3081
|
+
scrollEn: () => scrollEn,
|
|
3082
|
+
scrollFr: () => scrollFr,
|
|
3083
|
+
scrollI18n: () => scrollI18n
|
|
3084
|
+
});
|
|
3085
|
+
|
|
3086
|
+
// src/common/LocalizedComponent.ts
|
|
3087
|
+
var LocalizedComponent = class extends AuditableComponent {
|
|
3088
|
+
/**
|
|
3089
|
+
* Définit la langue globale du composant (ex: 'fr', 'en', 'es').
|
|
3090
|
+
*/
|
|
3091
|
+
static setLocale(locale) {
|
|
3092
|
+
if (this._i18n) {
|
|
3093
|
+
this._i18n.setLocale(locale);
|
|
3094
|
+
}
|
|
3095
|
+
}
|
|
3096
|
+
/**
|
|
3097
|
+
* Retourne la langue globale active du composant.
|
|
3098
|
+
*/
|
|
3099
|
+
static getLocale() {
|
|
3100
|
+
return this._i18n ? this._i18n.getLocale() : "";
|
|
3101
|
+
}
|
|
3102
|
+
/**
|
|
3103
|
+
* Enregistre un dictionnaire de traduction pour une langue donnée.
|
|
3104
|
+
*/
|
|
3105
|
+
static registerLocale(locale, translations) {
|
|
3106
|
+
if (this._i18n) {
|
|
3107
|
+
this._i18n.registerLocale(locale, translations);
|
|
3108
|
+
}
|
|
3109
|
+
}
|
|
3110
|
+
/**
|
|
3111
|
+
* Surcharge les libellés globalement pour ce composant.
|
|
3112
|
+
*/
|
|
3113
|
+
static setI18n(overrides) {
|
|
3114
|
+
if (this._i18n) {
|
|
3115
|
+
this._i18n.setI18n(overrides);
|
|
3116
|
+
}
|
|
3117
|
+
}
|
|
3118
|
+
/**
|
|
3119
|
+
* Retourne l'ensemble des libellés actifs résolus du composant.
|
|
3120
|
+
*/
|
|
3121
|
+
static getI18n() {
|
|
3122
|
+
return this._i18n ? this._i18n.getAll() : {};
|
|
3123
|
+
}
|
|
3124
|
+
/**
|
|
3125
|
+
* Réinitialise les réglages de langue et surcharges globales.
|
|
3126
|
+
*/
|
|
3127
|
+
static resetI18n() {
|
|
3128
|
+
if (this._i18n) {
|
|
3129
|
+
this._i18n.reset();
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
3132
|
+
/**
|
|
3133
|
+
* Résout une clé au niveau statique de la classe.
|
|
3134
|
+
*/
|
|
3135
|
+
static t(key, instanceOverride) {
|
|
3136
|
+
return this._i18n ? this._i18n.t(key, instanceOverride) : String(key);
|
|
3137
|
+
}
|
|
3138
|
+
constructor(i18nOverrides) {
|
|
3139
|
+
super();
|
|
3140
|
+
this.i18nOverrides = i18nOverrides;
|
|
3141
|
+
}
|
|
3142
|
+
/**
|
|
3143
|
+
* Traduit une clé en tenant compte automatiquement des surcharges de l'instance courante.
|
|
3144
|
+
*/
|
|
3145
|
+
t(key) {
|
|
3146
|
+
const ctor = this.constructor;
|
|
3147
|
+
return ctor._i18n ? ctor._i18n.t(key, this.i18nOverrides) : String(key);
|
|
3148
|
+
}
|
|
3149
|
+
};
|
|
3150
|
+
|
|
3151
|
+
// src/common/i18n.ts
|
|
3152
|
+
function normalizeLocaleCode(locale) {
|
|
3153
|
+
return locale.trim().toLowerCase().replace(/_/g, "-");
|
|
3154
|
+
}
|
|
3155
|
+
function getPrimaryLanguage(normalizedLocale) {
|
|
3156
|
+
const dashIndex = normalizedLocale.indexOf("-");
|
|
3157
|
+
return dashIndex > 0 ? normalizedLocale.slice(0, dashIndex) : null;
|
|
3158
|
+
}
|
|
3159
|
+
function assignDefined(target, source) {
|
|
3160
|
+
if (!source) return target;
|
|
3161
|
+
for (const key of Object.keys(source)) {
|
|
3162
|
+
if (source[key] !== void 0) {
|
|
3163
|
+
target[key] = source[key];
|
|
3164
|
+
}
|
|
3165
|
+
}
|
|
3166
|
+
return target;
|
|
3167
|
+
}
|
|
3168
|
+
function createI18nManager(defaultLocale, locales) {
|
|
3169
|
+
const fallbackLocale = normalizeLocaleCode(defaultLocale);
|
|
3170
|
+
const initialLocales = {};
|
|
3171
|
+
for (const [loc, dict] of Object.entries(locales)) {
|
|
3172
|
+
initialLocales[normalizeLocaleCode(loc)] = { ...dict };
|
|
3173
|
+
}
|
|
3174
|
+
let currentLocale = fallbackLocale;
|
|
3175
|
+
let activeLocales = { ...initialLocales };
|
|
3176
|
+
let globalOverrides = {};
|
|
3177
|
+
function resolveActiveDictionaries() {
|
|
3178
|
+
const dicts = [];
|
|
3179
|
+
const exact = activeLocales[currentLocale];
|
|
3180
|
+
if (exact) dicts.push(exact);
|
|
3181
|
+
const primary = getPrimaryLanguage(currentLocale);
|
|
3182
|
+
if (primary && activeLocales[primary]) {
|
|
3183
|
+
dicts.push(activeLocales[primary]);
|
|
3184
|
+
}
|
|
3185
|
+
return dicts;
|
|
3186
|
+
}
|
|
3187
|
+
return {
|
|
3188
|
+
setLocale(locale) {
|
|
3189
|
+
if (locale && locale.trim()) {
|
|
3190
|
+
currentLocale = normalizeLocaleCode(locale);
|
|
3191
|
+
}
|
|
3192
|
+
},
|
|
3193
|
+
getLocale() {
|
|
3194
|
+
return currentLocale;
|
|
3195
|
+
},
|
|
3196
|
+
registerLocale(locale, translations) {
|
|
3197
|
+
if (!locale || !locale.trim() || !translations) return;
|
|
3198
|
+
const norm = normalizeLocaleCode(locale);
|
|
3199
|
+
activeLocales[norm] = assignDefined({ ...activeLocales[norm] || {} }, translations);
|
|
3200
|
+
},
|
|
3201
|
+
setI18n(overrides) {
|
|
3202
|
+
if (!overrides) return;
|
|
3203
|
+
globalOverrides = assignDefined({ ...globalOverrides }, overrides);
|
|
3204
|
+
},
|
|
3205
|
+
t(key, instanceOverride) {
|
|
3206
|
+
if (instanceOverride && instanceOverride[key] !== void 0) {
|
|
3207
|
+
return String(instanceOverride[key]);
|
|
3208
|
+
}
|
|
3209
|
+
if (globalOverrides[key] !== void 0) {
|
|
3210
|
+
return String(globalOverrides[key]);
|
|
3211
|
+
}
|
|
3212
|
+
for (const dict of resolveActiveDictionaries()) {
|
|
3213
|
+
if (dict[key] !== void 0) {
|
|
3214
|
+
return String(dict[key]);
|
|
3215
|
+
}
|
|
3216
|
+
}
|
|
3217
|
+
const fallbackDict = activeLocales[fallbackLocale] || initialLocales[fallbackLocale];
|
|
3218
|
+
if (fallbackDict && fallbackDict[key] !== void 0) {
|
|
3219
|
+
return String(fallbackDict[key]);
|
|
3220
|
+
}
|
|
3221
|
+
return String(key);
|
|
3222
|
+
},
|
|
3223
|
+
getAll(instanceOverride) {
|
|
3224
|
+
const result = {};
|
|
3225
|
+
const fallback = activeLocales[fallbackLocale] || initialLocales[fallbackLocale];
|
|
3226
|
+
assignDefined(result, fallback);
|
|
3227
|
+
const activeDicts = resolveActiveDictionaries().reverse();
|
|
3228
|
+
for (const dict of activeDicts) {
|
|
3229
|
+
assignDefined(result, dict);
|
|
3230
|
+
}
|
|
3231
|
+
assignDefined(result, globalOverrides);
|
|
3232
|
+
assignDefined(result, instanceOverride);
|
|
3233
|
+
return result;
|
|
3234
|
+
},
|
|
3235
|
+
reset() {
|
|
3236
|
+
currentLocale = fallbackLocale;
|
|
3237
|
+
globalOverrides = {};
|
|
3238
|
+
activeLocales = {};
|
|
3239
|
+
for (const [loc, dict] of Object.entries(initialLocales)) {
|
|
3240
|
+
activeLocales[loc] = { ...dict };
|
|
3241
|
+
}
|
|
3242
|
+
}
|
|
3243
|
+
};
|
|
3244
|
+
}
|
|
3245
|
+
|
|
3246
|
+
// src/scroll/i18n/fr.ts
|
|
3247
|
+
var scrollFr = {
|
|
3248
|
+
viewport: "Zone de contenu d\xE9filable",
|
|
3249
|
+
verticalThumb: "D\xE9filement vertical",
|
|
3250
|
+
horizontalThumb: "D\xE9filement horizontal"
|
|
3251
|
+
};
|
|
3252
|
+
|
|
3253
|
+
// src/scroll/i18n/en.ts
|
|
3254
|
+
var scrollEn = {
|
|
3255
|
+
viewport: "Scrollable content area",
|
|
3256
|
+
verticalThumb: "Vertical scroll",
|
|
3257
|
+
horizontalThumb: "Horizontal scroll"
|
|
3258
|
+
};
|
|
3259
|
+
|
|
3260
|
+
// src/scroll/i18n/index.ts
|
|
3261
|
+
var scrollI18n = createI18nManager("fr", {
|
|
3262
|
+
fr: scrollFr,
|
|
3263
|
+
en: scrollEn
|
|
2775
3264
|
});
|
|
2776
3265
|
|
|
2777
3266
|
// src/scroll/ScrollBlock.ts
|
|
2778
3267
|
var idCounter = 0;
|
|
2779
|
-
var ScrollBlock = class {
|
|
3268
|
+
var ScrollBlock = class extends LocalizedComponent {
|
|
2780
3269
|
constructor(element, options) {
|
|
3270
|
+
super(options?.i18n);
|
|
2781
3271
|
this.createdViewport = false;
|
|
3272
|
+
this.wasIdGenerated = false;
|
|
3273
|
+
this.wasRoleInferred = false;
|
|
3274
|
+
this.wasAriaLabelInferred = false;
|
|
3275
|
+
this.hasExplicitAriaLabel = false;
|
|
3276
|
+
this.lastInferredAriaLabel = "";
|
|
2782
3277
|
this.isDragging = false;
|
|
2783
3278
|
this.dragStartPos = 0;
|
|
2784
3279
|
this.dragStartScroll = 0;
|
|
@@ -2791,12 +3286,14 @@ var ScrollBlock = class {
|
|
|
2791
3286
|
throw new Error(`[ScrollBlock] \xC9l\xE9ment introuvable : "${element}".`);
|
|
2792
3287
|
}
|
|
2793
3288
|
this.root = resolvedElement;
|
|
3289
|
+
this.hasExplicitAriaLabel = Boolean(options?.ariaLabel || options?.i18n?.viewport);
|
|
2794
3290
|
this.options = {
|
|
2795
3291
|
axis: options?.axis || "y",
|
|
2796
3292
|
autoHide: options?.autoHide ?? true,
|
|
2797
3293
|
autoHideDelay: options?.autoHideDelay ?? 1e3,
|
|
2798
3294
|
alwaysVisible: options?.alwaysVisible ?? false,
|
|
2799
|
-
ariaLabel: options?.ariaLabel || "
|
|
3295
|
+
ariaLabel: options?.ariaLabel || this.t("viewport"),
|
|
3296
|
+
i18n: options?.i18n || {},
|
|
2800
3297
|
minThumbSize: options?.minThumbSize ?? 24,
|
|
2801
3298
|
edgeThreshold: options?.edgeThreshold ?? 10,
|
|
2802
3299
|
onScroll: options?.onScroll || (() => {
|
|
@@ -2804,7 +3301,8 @@ var ScrollBlock = class {
|
|
|
2804
3301
|
onTotalScroll: options?.onTotalScroll || (() => {
|
|
2805
3302
|
}),
|
|
2806
3303
|
onTotalScrollBack: options?.onTotalScrollBack || (() => {
|
|
2807
|
-
})
|
|
3304
|
+
}),
|
|
3305
|
+
audit: options?.audit ?? true
|
|
2808
3306
|
};
|
|
2809
3307
|
this.boundOnScroll = this.handleScroll.bind(this);
|
|
2810
3308
|
this.boundOnMouseEnter = this.handleMouseEnter.bind(this);
|
|
@@ -2819,6 +3317,7 @@ var ScrollBlock = class {
|
|
|
2819
3317
|
this.setupEventListeners();
|
|
2820
3318
|
this.setupObserver();
|
|
2821
3319
|
this.update();
|
|
3320
|
+
this.runAuditWarning(this.options.audit);
|
|
2822
3321
|
}
|
|
2823
3322
|
/**
|
|
2824
3323
|
* Prépare le viewport défilant sans altérer les éléments enfants.
|
|
@@ -2851,9 +3350,38 @@ var ScrollBlock = class {
|
|
|
2851
3350
|
if (!this.viewport.id) {
|
|
2852
3351
|
idCounter += 1;
|
|
2853
3352
|
this.viewport.id = `wulf-scrollblock-vp-${idCounter}`;
|
|
3353
|
+
this.wasIdGenerated = true;
|
|
3354
|
+
}
|
|
3355
|
+
if (!this.viewport.hasAttribute("role")) {
|
|
3356
|
+
this.viewport.setAttribute("role", "region");
|
|
3357
|
+
this.wasRoleInferred = true;
|
|
3358
|
+
}
|
|
3359
|
+
if (!this.viewport.hasAttribute("aria-label")) {
|
|
3360
|
+
const label = this.hasExplicitAriaLabel ? this.options.ariaLabel : this.t("viewport");
|
|
3361
|
+
this.viewport.setAttribute("aria-label", label);
|
|
3362
|
+
this.lastInferredAriaLabel = label;
|
|
3363
|
+
this.wasAriaLabelInferred = true;
|
|
3364
|
+
}
|
|
3365
|
+
}
|
|
3366
|
+
/**
|
|
3367
|
+
* Synchronise dynamiquement les libellés ARIA si la langue globale change après montage.
|
|
3368
|
+
*/
|
|
3369
|
+
syncAccessibilityLabels() {
|
|
3370
|
+
if (this.wasAriaLabelInferred && !this.hasExplicitAriaLabel) {
|
|
3371
|
+
const currentAttr = this.viewport.getAttribute("aria-label");
|
|
3372
|
+
if (currentAttr === this.lastInferredAriaLabel) {
|
|
3373
|
+
const nextLabel = this.t("viewport");
|
|
3374
|
+
this.viewport.setAttribute("aria-label", nextLabel);
|
|
3375
|
+
this.lastInferredAriaLabel = nextLabel;
|
|
3376
|
+
this.options.ariaLabel = nextLabel;
|
|
3377
|
+
}
|
|
3378
|
+
}
|
|
3379
|
+
if (this.thumbY) {
|
|
3380
|
+
this.thumbY.setAttribute("aria-label", this.t("verticalThumb"));
|
|
3381
|
+
}
|
|
3382
|
+
if (this.thumbX) {
|
|
3383
|
+
this.thumbX.setAttribute("aria-label", this.t("horizontalThumb"));
|
|
2854
3384
|
}
|
|
2855
|
-
this.viewport.setAttribute("role", "region");
|
|
2856
|
-
this.viewport.setAttribute("aria-label", this.options.ariaLabel);
|
|
2857
3385
|
}
|
|
2858
3386
|
/**
|
|
2859
3387
|
* Crée les rails et curseurs selon l'axe sélectionné.
|
|
@@ -2871,7 +3399,7 @@ var ScrollBlock = class {
|
|
|
2871
3399
|
this.thumbY.setAttribute("aria-valuenow", "0");
|
|
2872
3400
|
this.thumbY.setAttribute("aria-valuemin", "0");
|
|
2873
3401
|
this.thumbY.setAttribute("aria-valuemax", "100");
|
|
2874
|
-
this.thumbY.setAttribute("aria-label", "
|
|
3402
|
+
this.thumbY.setAttribute("aria-label", this.t("verticalThumb"));
|
|
2875
3403
|
this.trackY.appendChild(this.thumbY);
|
|
2876
3404
|
this.root.appendChild(this.trackY);
|
|
2877
3405
|
this.attachTrackListeners(this.trackY, this.thumbY, "y");
|
|
@@ -2888,7 +3416,7 @@ var ScrollBlock = class {
|
|
|
2888
3416
|
this.thumbX.setAttribute("aria-valuenow", "0");
|
|
2889
3417
|
this.thumbX.setAttribute("aria-valuemin", "0");
|
|
2890
3418
|
this.thumbX.setAttribute("aria-valuemax", "100");
|
|
2891
|
-
this.thumbX.setAttribute("aria-label", "
|
|
3419
|
+
this.thumbX.setAttribute("aria-label", this.t("horizontalThumb"));
|
|
2892
3420
|
this.trackX.appendChild(this.thumbX);
|
|
2893
3421
|
this.root.appendChild(this.trackX);
|
|
2894
3422
|
this.attachTrackListeners(this.trackX, this.thumbX, "x");
|
|
@@ -3110,6 +3638,7 @@ var ScrollBlock = class {
|
|
|
3110
3638
|
* Recalcule les dimensions et la visibilité des barres.
|
|
3111
3639
|
*/
|
|
3112
3640
|
update() {
|
|
3641
|
+
this.syncAccessibilityLabels();
|
|
3113
3642
|
const { scrollHeight, clientHeight, scrollWidth, clientWidth } = this.viewport;
|
|
3114
3643
|
const canScrollY = scrollHeight > clientHeight;
|
|
3115
3644
|
const canScrollX = scrollWidth > clientWidth;
|
|
@@ -3171,6 +3700,18 @@ var ScrollBlock = class {
|
|
|
3171
3700
|
targetLeft = maxLeft;
|
|
3172
3701
|
break;
|
|
3173
3702
|
default: {
|
|
3703
|
+
if (/^-?\d+(\.\d+)?%$/.test(target.trim())) {
|
|
3704
|
+
const pct = Math.max(0, Math.min(100, parseFloat(target.trim()))) / 100;
|
|
3705
|
+
if (this.options.axis === "x") {
|
|
3706
|
+
targetLeft = maxLeft * pct;
|
|
3707
|
+
} else if (this.options.axis === "both") {
|
|
3708
|
+
targetTop = maxTop * pct;
|
|
3709
|
+
targetLeft = maxLeft * pct;
|
|
3710
|
+
} else {
|
|
3711
|
+
targetTop = maxTop * pct;
|
|
3712
|
+
}
|
|
3713
|
+
break;
|
|
3714
|
+
}
|
|
3174
3715
|
let el = null;
|
|
3175
3716
|
try {
|
|
3176
3717
|
el = this.viewport.querySelector(target);
|
|
@@ -3197,6 +3738,35 @@ var ScrollBlock = class {
|
|
|
3197
3738
|
behavior
|
|
3198
3739
|
});
|
|
3199
3740
|
}
|
|
3741
|
+
/**
|
|
3742
|
+
* Vérifie la conformité d'accessibilité WAI-ARIA de la zone défilable
|
|
3743
|
+
* et retourne la liste des contraintes manquantes.
|
|
3744
|
+
*/
|
|
3745
|
+
audit() {
|
|
3746
|
+
const warnings = [];
|
|
3747
|
+
const hasViewportLabelledby = this.checkAriaIdReferences(this.viewport, "aria-labelledby", warnings);
|
|
3748
|
+
const hasRootLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings);
|
|
3749
|
+
const hasValidLabelledby = hasViewportLabelledby || hasRootLabelledby;
|
|
3750
|
+
const rootAriaLabel = this.root.getAttribute("aria-label")?.trim();
|
|
3751
|
+
const hasCustomViewportAriaLabel = !this.wasAriaLabelInferred && Boolean(this.viewport.getAttribute("aria-label")?.trim());
|
|
3752
|
+
if (!this.hasExplicitAriaLabel && !hasCustomViewportAriaLabel && !rootAriaLabel && !hasValidLabelledby) {
|
|
3753
|
+
warnings.push(
|
|
3754
|
+
"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)."
|
|
3755
|
+
);
|
|
3756
|
+
}
|
|
3757
|
+
if (this.options.minThumbSize < 24) {
|
|
3758
|
+
warnings.push(
|
|
3759
|
+
`Taille minimale du curseur insuffisante (minThumbSize: ${this.options.minThumbSize}px) : utilisez au moins 24px pour respecter WCAG 2.5.8.`
|
|
3760
|
+
);
|
|
3761
|
+
}
|
|
3762
|
+
return warnings;
|
|
3763
|
+
}
|
|
3764
|
+
getAuditPrefix() {
|
|
3765
|
+
return "Wulf.Scroll";
|
|
3766
|
+
}
|
|
3767
|
+
getAuditTargetLabel() {
|
|
3768
|
+
return this.root.id ? `#${this.root.id}` : `<${this.root.tagName.toLowerCase()}.wulf-scrollblock>`;
|
|
3769
|
+
}
|
|
3200
3770
|
/**
|
|
3201
3771
|
* Détruit le composant et libère toutes les ressources.
|
|
3202
3772
|
*/
|
|
@@ -3230,13 +3800,27 @@ var ScrollBlock = class {
|
|
|
3230
3800
|
this.root.insertBefore(this.viewport.firstChild, this.viewport);
|
|
3231
3801
|
}
|
|
3232
3802
|
this.viewport.remove();
|
|
3803
|
+
} else {
|
|
3804
|
+
this.viewport.removeAttribute("tabindex");
|
|
3805
|
+
if (this.wasIdGenerated) {
|
|
3806
|
+
this.viewport.removeAttribute("id");
|
|
3807
|
+
}
|
|
3808
|
+
if (this.wasRoleInferred && this.viewport.getAttribute("role") === "region") {
|
|
3809
|
+
this.viewport.removeAttribute("role");
|
|
3810
|
+
}
|
|
3811
|
+
if (this.wasAriaLabelInferred && this.viewport.getAttribute("aria-label") === this.lastInferredAriaLabel) {
|
|
3812
|
+
this.viewport.removeAttribute("aria-label");
|
|
3813
|
+
}
|
|
3233
3814
|
}
|
|
3234
3815
|
}
|
|
3235
3816
|
};
|
|
3817
|
+
ScrollBlock._i18n = scrollI18n;
|
|
3818
|
+
ScrollBlock.i18n = scrollI18n;
|
|
3236
3819
|
|
|
3237
3820
|
// src/scroll/index.ts
|
|
3238
3821
|
var Scroll = {
|
|
3239
|
-
ScrollBlock
|
|
3822
|
+
ScrollBlock,
|
|
3823
|
+
i18n: scrollI18n
|
|
3240
3824
|
};
|
|
3241
3825
|
var scroll_default = ScrollBlock;
|
|
3242
3826
|
if (typeof window !== "undefined") {
|
|
@@ -3250,8 +3834,13 @@ if (typeof window !== "undefined") {
|
|
|
3250
3834
|
var masonry_exports = {};
|
|
3251
3835
|
__export(masonry_exports, {
|
|
3252
3836
|
LayoutEngine: () => LayoutEngine,
|
|
3837
|
+
LocalizedComponent: () => LocalizedComponent,
|
|
3253
3838
|
Masonry: () => Masonry,
|
|
3254
|
-
|
|
3839
|
+
createI18nManager: () => createI18nManager,
|
|
3840
|
+
default: () => masonry_default,
|
|
3841
|
+
masonryEn: () => masonryEn,
|
|
3842
|
+
masonryFr: () => masonryFr,
|
|
3843
|
+
masonryI18n: () => masonryI18n
|
|
3255
3844
|
});
|
|
3256
3845
|
|
|
3257
3846
|
// src/masonry/LayoutEngine.ts
|
|
@@ -3441,9 +4030,26 @@ var LayoutEngine = class {
|
|
|
3441
4030
|
}
|
|
3442
4031
|
};
|
|
3443
4032
|
|
|
4033
|
+
// src/masonry/i18n/fr.ts
|
|
4034
|
+
var masonryFr = {
|
|
4035
|
+
gallery: "Galerie en grille asym\xE9trique"
|
|
4036
|
+
};
|
|
4037
|
+
|
|
4038
|
+
// src/masonry/i18n/en.ts
|
|
4039
|
+
var masonryEn = {
|
|
4040
|
+
gallery: "Masonry grid gallery"
|
|
4041
|
+
};
|
|
4042
|
+
|
|
4043
|
+
// src/masonry/i18n/index.ts
|
|
4044
|
+
var masonryI18n = createI18nManager("fr", {
|
|
4045
|
+
fr: masonryFr,
|
|
4046
|
+
en: masonryEn
|
|
4047
|
+
});
|
|
4048
|
+
|
|
3444
4049
|
// src/masonry/Masonry.ts
|
|
3445
|
-
var Masonry = class {
|
|
4050
|
+
var Masonry = class extends LocalizedComponent {
|
|
3446
4051
|
constructor(target, options = {}) {
|
|
4052
|
+
super(options.i18n);
|
|
3447
4053
|
this.isNativeCSSGrid = false;
|
|
3448
4054
|
this._items = [];
|
|
3449
4055
|
this.resizeObserver = null;
|
|
@@ -3452,6 +4058,8 @@ var Masonry = class {
|
|
|
3452
4058
|
this.isDestroyed = false;
|
|
3453
4059
|
this.wasRoleInferred = false;
|
|
3454
4060
|
this.wasAriaLabelInferred = false;
|
|
4061
|
+
this.hasExplicitAriaLabel = false;
|
|
4062
|
+
this.lastInferredAriaLabel = "";
|
|
3455
4063
|
this.removeTimers = /* @__PURE__ */ new Set();
|
|
3456
4064
|
this.pendingImageListeners = [];
|
|
3457
4065
|
if (typeof target === "string") {
|
|
@@ -3469,11 +4077,12 @@ var Masonry = class {
|
|
|
3469
4077
|
height: this.root.style.height,
|
|
3470
4078
|
width: this.root.style.width
|
|
3471
4079
|
};
|
|
4080
|
+
this.hasExplicitAriaLabel = Boolean(options.ariaLabel || options.i18n?.gallery);
|
|
3472
4081
|
this.options = {
|
|
3473
4082
|
itemSelector: options.itemSelector || "> *",
|
|
3474
4083
|
columnWidth: options.columnWidth ?? 0,
|
|
3475
4084
|
gutter: options.gutter ?? 0,
|
|
3476
|
-
percentPosition: options.percentPosition
|
|
4085
|
+
percentPosition: Boolean(options.percentPosition),
|
|
3477
4086
|
fitWidth: Boolean(options.fitWidth),
|
|
3478
4087
|
horizontalOrder: Boolean(options.horizontalOrder),
|
|
3479
4088
|
transitionDuration: options.transitionDuration !== void 0 ? options.transitionDuration : 300,
|
|
@@ -3482,11 +4091,13 @@ var Masonry = class {
|
|
|
3482
4091
|
autoImages: options.autoImages !== false,
|
|
3483
4092
|
useNativeCSSGrid: options.useNativeCSSGrid !== false,
|
|
3484
4093
|
ariaRole: options.ariaRole || "region",
|
|
3485
|
-
ariaLabel: options.ariaLabel || "
|
|
4094
|
+
ariaLabel: options.ariaLabel || this.t("gallery"),
|
|
4095
|
+
i18n: options.i18n || {},
|
|
3486
4096
|
onLayout: options.onLayout || (() => {
|
|
3487
4097
|
}),
|
|
3488
4098
|
onItemPlaced: options.onItemPlaced || (() => {
|
|
3489
|
-
})
|
|
4099
|
+
}),
|
|
4100
|
+
audit: options.audit ?? true
|
|
3490
4101
|
};
|
|
3491
4102
|
const supportsNativeCSS = typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("grid-template-rows", "masonry");
|
|
3492
4103
|
if (this.options.useNativeCSSGrid && supportsNativeCSS) {
|
|
@@ -3501,6 +4112,7 @@ var Masonry = class {
|
|
|
3501
4112
|
this.initObservers();
|
|
3502
4113
|
this.initImages();
|
|
3503
4114
|
this.layout();
|
|
4115
|
+
this.runAuditWarning(this.options.audit);
|
|
3504
4116
|
}
|
|
3505
4117
|
get items() {
|
|
3506
4118
|
return [...this._items];
|
|
@@ -3513,11 +4125,27 @@ var Masonry = class {
|
|
|
3513
4125
|
this.root.setAttribute("role", this.options.ariaRole);
|
|
3514
4126
|
this.wasRoleInferred = true;
|
|
3515
4127
|
}
|
|
3516
|
-
|
|
3517
|
-
|
|
4128
|
+
const label = this.hasExplicitAriaLabel ? this.options.ariaLabel : this.t("gallery");
|
|
4129
|
+
if (label && !this.root.hasAttribute("aria-label")) {
|
|
4130
|
+
this.root.setAttribute("aria-label", label);
|
|
4131
|
+
this.lastInferredAriaLabel = label;
|
|
3518
4132
|
this.wasAriaLabelInferred = true;
|
|
3519
4133
|
}
|
|
3520
4134
|
}
|
|
4135
|
+
/**
|
|
4136
|
+
* Synchronise dynamiquement le libellé ARIA si la langue globale change après montage.
|
|
4137
|
+
*/
|
|
4138
|
+
syncAccessibilityLabels() {
|
|
4139
|
+
if (this.wasAriaLabelInferred && !this.hasExplicitAriaLabel) {
|
|
4140
|
+
const currentAttr = this.root.getAttribute("aria-label");
|
|
4141
|
+
if (currentAttr === this.lastInferredAriaLabel) {
|
|
4142
|
+
const nextLabel = this.t("gallery");
|
|
4143
|
+
this.root.setAttribute("aria-label", nextLabel);
|
|
4144
|
+
this.lastInferredAriaLabel = nextLabel;
|
|
4145
|
+
this.options.ariaLabel = nextLabel;
|
|
4146
|
+
}
|
|
4147
|
+
}
|
|
4148
|
+
}
|
|
3521
4149
|
/**
|
|
3522
4150
|
* Configure les variables CSS de transition sur le conteneur.
|
|
3523
4151
|
*/
|
|
@@ -3624,6 +4252,7 @@ var Masonry = class {
|
|
|
3624
4252
|
*/
|
|
3625
4253
|
layout() {
|
|
3626
4254
|
if (this.isDestroyed) return;
|
|
4255
|
+
this.syncAccessibilityLabels();
|
|
3627
4256
|
if (this.isNativeCSSGrid) {
|
|
3628
4257
|
this.options.onLayout([]);
|
|
3629
4258
|
return;
|
|
@@ -3638,10 +4267,16 @@ var Masonry = class {
|
|
|
3638
4267
|
this.root.classList.remove("wulf-masonry--fit-width");
|
|
3639
4268
|
}
|
|
3640
4269
|
const stagger = this.options.stagger;
|
|
4270
|
+
const usePercent = this.options.percentPosition && result.containerWidth > 0;
|
|
3641
4271
|
for (let i = 0; i < result.positions.length; i++) {
|
|
3642
4272
|
const pos = result.positions[i];
|
|
3643
4273
|
const item = pos.element;
|
|
3644
|
-
|
|
4274
|
+
if (usePercent) {
|
|
4275
|
+
const wPct = Number((pos.width / result.containerWidth * 100).toFixed(4));
|
|
4276
|
+
item.style.setProperty("--wulf-masonry-w", `${wPct}%`);
|
|
4277
|
+
} else {
|
|
4278
|
+
item.style.setProperty("--wulf-masonry-w", `${pos.width}px`);
|
|
4279
|
+
}
|
|
3645
4280
|
item.style.setProperty("--wulf-masonry-x", `${pos.x}px`);
|
|
3646
4281
|
item.style.setProperty("--wulf-masonry-y", `${pos.y}px`);
|
|
3647
4282
|
if (stagger > 0) {
|
|
@@ -3730,6 +4365,35 @@ var Masonry = class {
|
|
|
3730
4365
|
}, dur);
|
|
3731
4366
|
this.removeTimers.add(timerId);
|
|
3732
4367
|
}
|
|
4368
|
+
/**
|
|
4369
|
+
* Vérifie la conformité d'accessibilité WAI-ARIA de la grille Masonry
|
|
4370
|
+
* et retourne la liste des contraintes manquantes.
|
|
4371
|
+
*/
|
|
4372
|
+
audit() {
|
|
4373
|
+
const warnings = [];
|
|
4374
|
+
const hasValidLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings);
|
|
4375
|
+
const hasCustomRootAriaLabel = !this.wasAriaLabelInferred && Boolean(this.root.getAttribute("aria-label")?.trim());
|
|
4376
|
+
if (!this.hasExplicitAriaLabel && !hasCustomRootAriaLabel && !hasValidLabelledby) {
|
|
4377
|
+
warnings.push(
|
|
4378
|
+
"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)."
|
|
4379
|
+
);
|
|
4380
|
+
}
|
|
4381
|
+
const imagesWithoutAlt = Array.from(this.root.querySelectorAll("img")).filter(
|
|
4382
|
+
(img) => !img.hasAttribute("alt") && img.getAttribute("aria-hidden") !== "true"
|
|
4383
|
+
);
|
|
4384
|
+
if (imagesWithoutAlt.length > 0) {
|
|
4385
|
+
warnings.push(
|
|
4386
|
+
`${imagesWithoutAlt.length} image(s) <img> d\xE9pourvue(s) d'attribut alt : renseignez alt="description" (ou alt="" si d\xE9corative) (WCAG 1.1.1).`
|
|
4387
|
+
);
|
|
4388
|
+
}
|
|
4389
|
+
return warnings;
|
|
4390
|
+
}
|
|
4391
|
+
getAuditPrefix() {
|
|
4392
|
+
return "Wulf.Masonry";
|
|
4393
|
+
}
|
|
4394
|
+
getAuditTargetLabel() {
|
|
4395
|
+
return this.root.id ? `#${this.root.id}` : `<${this.root.tagName.toLowerCase()}.wulf-masonry>`;
|
|
4396
|
+
}
|
|
3733
4397
|
/**
|
|
3734
4398
|
* Libère les ressources, déconnecte les observateurs et nettoie les styles injectés.
|
|
3735
4399
|
*/
|
|
@@ -3761,7 +4425,7 @@ var Masonry = class {
|
|
|
3761
4425
|
if (this.wasRoleInferred && this.root.getAttribute("role") === this.options.ariaRole) {
|
|
3762
4426
|
this.root.removeAttribute("role");
|
|
3763
4427
|
}
|
|
3764
|
-
if (this.wasAriaLabelInferred && this.root.getAttribute("aria-label") === this.
|
|
4428
|
+
if (this.wasAriaLabelInferred && this.root.getAttribute("aria-label") === this.lastInferredAriaLabel) {
|
|
3765
4429
|
this.root.removeAttribute("aria-label");
|
|
3766
4430
|
}
|
|
3767
4431
|
this.root.style.removeProperty("--wulf-masonry-duration");
|
|
@@ -3785,6 +4449,8 @@ var Masonry = class {
|
|
|
3785
4449
|
this._items = [];
|
|
3786
4450
|
}
|
|
3787
4451
|
};
|
|
4452
|
+
Masonry._i18n = masonryI18n;
|
|
4453
|
+
Masonry.i18n = masonryI18n;
|
|
3788
4454
|
|
|
3789
4455
|
// src/masonry/index.ts
|
|
3790
4456
|
var masonry_default = Masonry;
|
|
@@ -3794,23 +4460,46 @@ if (typeof window !== "undefined") {
|
|
|
3794
4460
|
win.Wulf = wulfNamespace;
|
|
3795
4461
|
wulfNamespace.Masonry = Object.assign(Masonry, {
|
|
3796
4462
|
Masonry,
|
|
3797
|
-
LayoutEngine
|
|
4463
|
+
LayoutEngine,
|
|
4464
|
+
i18n: masonryI18n
|
|
3798
4465
|
});
|
|
3799
4466
|
}
|
|
3800
4467
|
|
|
3801
4468
|
// src/toast/index.ts
|
|
3802
4469
|
var toast_exports = {};
|
|
3803
4470
|
__export(toast_exports, {
|
|
4471
|
+
LocalizedComponent: () => LocalizedComponent,
|
|
3804
4472
|
Toast: () => Toast,
|
|
3805
4473
|
ToastInstance: () => ToastInstance,
|
|
3806
4474
|
ToastManager: () => ToastManager,
|
|
3807
|
-
|
|
4475
|
+
createI18nManager: () => createI18nManager,
|
|
4476
|
+
default: () => toast_default,
|
|
4477
|
+
toastEn: () => toastEn,
|
|
4478
|
+
toastFr: () => toastFr,
|
|
4479
|
+
toastI18n: () => toastI18n
|
|
4480
|
+
});
|
|
4481
|
+
|
|
4482
|
+
// src/toast/i18n/fr.ts
|
|
4483
|
+
var toastFr = {
|
|
4484
|
+
closeButton: "Fermer la notification"
|
|
4485
|
+
};
|
|
4486
|
+
|
|
4487
|
+
// src/toast/i18n/en.ts
|
|
4488
|
+
var toastEn = {
|
|
4489
|
+
closeButton: "Close notification"
|
|
4490
|
+
};
|
|
4491
|
+
|
|
4492
|
+
// src/toast/i18n/index.ts
|
|
4493
|
+
var toastI18n = createI18nManager("fr", {
|
|
4494
|
+
fr: toastFr,
|
|
4495
|
+
en: toastEn
|
|
3808
4496
|
});
|
|
3809
4497
|
|
|
3810
4498
|
// src/toast/ToastInstance.ts
|
|
3811
4499
|
var nextToastId = 1;
|
|
3812
|
-
var ToastInstance = class {
|
|
4500
|
+
var ToastInstance = class extends AuditableComponent {
|
|
3813
4501
|
constructor(options, onDismiss) {
|
|
4502
|
+
super();
|
|
3814
4503
|
this._isClosed = false;
|
|
3815
4504
|
this.timerId = null;
|
|
3816
4505
|
this.remainingTime = 0;
|
|
@@ -3827,10 +4516,45 @@ var ToastInstance = class {
|
|
|
3827
4516
|
}
|
|
3828
4517
|
this.element = this.createDOM();
|
|
3829
4518
|
this.bindEvents();
|
|
4519
|
+
this.runAuditWarning(options.audit !== false);
|
|
3830
4520
|
}
|
|
3831
4521
|
get isClosed() {
|
|
3832
4522
|
return this._isClosed;
|
|
3833
4523
|
}
|
|
4524
|
+
/**
|
|
4525
|
+
* Vérifie la conformité d'accessibilité WAI-ARIA de la notification Toast
|
|
4526
|
+
* et retourne la liste des contraintes manquantes.
|
|
4527
|
+
*/
|
|
4528
|
+
audit() {
|
|
4529
|
+
const warnings = [];
|
|
4530
|
+
const hasTitle = Boolean(this.options.title && this.options.title.trim().length > 0);
|
|
4531
|
+
const hasMessage = Boolean(this.options.message && this.options.message.trim().length > 0);
|
|
4532
|
+
if (!hasTitle && !hasMessage) {
|
|
4533
|
+
warnings.push(
|
|
4534
|
+
"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)."
|
|
4535
|
+
);
|
|
4536
|
+
}
|
|
4537
|
+
const duration = this.options.duration === void 0 ? 4e3 : this.options.duration;
|
|
4538
|
+
if (typeof duration === "number" && duration > 0 && duration < 5e3) {
|
|
4539
|
+
warnings.push(
|
|
4540
|
+
`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).`
|
|
4541
|
+
);
|
|
4542
|
+
}
|
|
4543
|
+
const closable = this.options.closable ?? true;
|
|
4544
|
+
const isPersistent = duration === false || typeof duration === "number" && duration <= 0;
|
|
4545
|
+
if (isPersistent && !closable && !this.options.closeOnClick) {
|
|
4546
|
+
warnings.push(
|
|
4547
|
+
"Notification persistante impossible \xE0 fermer : activez closable: true ou closeOnClick: true lorsque duration est d\xE9sactiv\xE9 (WCAG 2.1.1)."
|
|
4548
|
+
);
|
|
4549
|
+
}
|
|
4550
|
+
return warnings;
|
|
4551
|
+
}
|
|
4552
|
+
getAuditPrefix() {
|
|
4553
|
+
return "Wulf.Toast";
|
|
4554
|
+
}
|
|
4555
|
+
getAuditTargetLabel() {
|
|
4556
|
+
return `#${this.id}`;
|
|
4557
|
+
}
|
|
3834
4558
|
/**
|
|
3835
4559
|
* Construction du DOM de manière 100% sécurisée sans aucun `innerHTML`.
|
|
3836
4560
|
*/
|
|
@@ -3878,12 +4602,12 @@ var ToastInstance = class {
|
|
|
3878
4602
|
content.appendChild(messageEl);
|
|
3879
4603
|
}
|
|
3880
4604
|
el.appendChild(content);
|
|
3881
|
-
const closable = this.options.closable
|
|
4605
|
+
const closable = this.options.closable ?? true;
|
|
3882
4606
|
if (closable) {
|
|
3883
4607
|
const closeBtn = document.createElement("button");
|
|
3884
4608
|
closeBtn.type = "button";
|
|
3885
4609
|
closeBtn.className = "wulf-toast-close";
|
|
3886
|
-
closeBtn.setAttribute("aria-label", "
|
|
4610
|
+
closeBtn.setAttribute("aria-label", toastI18n.t("closeButton", this.options.i18n));
|
|
3887
4611
|
closeBtn.setAttribute("tabindex", "0");
|
|
3888
4612
|
const closeIcon = document.createElement("span");
|
|
3889
4613
|
closeIcon.className = "wulf-toast-close-icon";
|
|
@@ -3919,6 +4643,9 @@ var ToastInstance = class {
|
|
|
3919
4643
|
if (this.options.onClick) {
|
|
3920
4644
|
this.options.onClick(this, e);
|
|
3921
4645
|
}
|
|
4646
|
+
if (this.options.closeOnClick) {
|
|
4647
|
+
this.close("toast-click");
|
|
4648
|
+
}
|
|
3922
4649
|
});
|
|
3923
4650
|
this.element.addEventListener("mouseenter", () => this.pauseTimer());
|
|
3924
4651
|
this.element.addEventListener("mouseleave", () => this.resumeTimer());
|
|
@@ -4008,9 +4735,14 @@ var ToastInstance = class {
|
|
|
4008
4735
|
window.setTimeout(handleAnimationEnd, 90);
|
|
4009
4736
|
} else {
|
|
4010
4737
|
let transitioned = false;
|
|
4738
|
+
let fallbackTimerId = null;
|
|
4011
4739
|
const onEnd = () => {
|
|
4012
4740
|
if (!transitioned) {
|
|
4013
4741
|
transitioned = true;
|
|
4742
|
+
if (fallbackTimerId !== null) {
|
|
4743
|
+
window.clearTimeout(fallbackTimerId);
|
|
4744
|
+
fallbackTimerId = null;
|
|
4745
|
+
}
|
|
4014
4746
|
this.element.removeEventListener("animationend", onEnd);
|
|
4015
4747
|
this.element.removeEventListener("transitionend", onEnd);
|
|
4016
4748
|
handleAnimationEnd();
|
|
@@ -4018,7 +4750,7 @@ var ToastInstance = class {
|
|
|
4018
4750
|
};
|
|
4019
4751
|
this.element.addEventListener("animationend", onEnd, { once: true });
|
|
4020
4752
|
this.element.addEventListener("transitionend", onEnd, { once: true });
|
|
4021
|
-
window.setTimeout(onEnd, 300);
|
|
4753
|
+
fallbackTimerId = window.setTimeout(onEnd, 300);
|
|
4022
4754
|
}
|
|
4023
4755
|
});
|
|
4024
4756
|
}
|
|
@@ -4182,7 +4914,16 @@ _ToastManager.instance = null;
|
|
|
4182
4914
|
var ToastManager = _ToastManager;
|
|
4183
4915
|
|
|
4184
4916
|
// src/toast/Toast.ts
|
|
4185
|
-
var Toast = class {
|
|
4917
|
+
var Toast = class extends LocalizedComponent {
|
|
4918
|
+
audit() {
|
|
4919
|
+
return [];
|
|
4920
|
+
}
|
|
4921
|
+
getAuditPrefix() {
|
|
4922
|
+
return "Wulf.Toast";
|
|
4923
|
+
}
|
|
4924
|
+
getAuditTargetLabel() {
|
|
4925
|
+
return "Toast";
|
|
4926
|
+
}
|
|
4186
4927
|
/**
|
|
4187
4928
|
* Affiche une nouvelle notification Toast avec les options spécifiées.
|
|
4188
4929
|
*/
|
|
@@ -4201,6 +4942,8 @@ var Toast = class {
|
|
|
4201
4942
|
return ToastManager.getInstance().clearAll(position);
|
|
4202
4943
|
}
|
|
4203
4944
|
};
|
|
4945
|
+
Toast._i18n = toastI18n;
|
|
4946
|
+
Toast.i18n = toastI18n;
|
|
4204
4947
|
|
|
4205
4948
|
// src/toast/index.ts
|
|
4206
4949
|
var toast_default = Toast;
|
|
@@ -4208,15 +4951,388 @@ if (typeof window !== "undefined") {
|
|
|
4208
4951
|
const win = window;
|
|
4209
4952
|
const wulfNamespace = win.Wulf || {};
|
|
4210
4953
|
win.Wulf = wulfNamespace;
|
|
4211
|
-
wulfNamespace.Toast = Toast
|
|
4954
|
+
wulfNamespace.Toast = Object.assign(Toast, {
|
|
4955
|
+
Toast,
|
|
4956
|
+
i18n: toastI18n
|
|
4957
|
+
});
|
|
4958
|
+
}
|
|
4959
|
+
|
|
4960
|
+
// src/focus-trap/index.ts
|
|
4961
|
+
var focus_trap_exports = {};
|
|
4962
|
+
__export(focus_trap_exports, {
|
|
4963
|
+
FocusTrap: () => FocusTrap,
|
|
4964
|
+
default: () => FocusTrap
|
|
4965
|
+
});
|
|
4966
|
+
|
|
4967
|
+
// src/focus-trap/FocusTrap.ts
|
|
4968
|
+
var FOCUSABLE_SELECTOR = [
|
|
4969
|
+
"a[href]",
|
|
4970
|
+
"area[href]",
|
|
4971
|
+
"input:not([disabled])",
|
|
4972
|
+
"select:not([disabled])",
|
|
4973
|
+
"textarea:not([disabled])",
|
|
4974
|
+
"button:not([disabled])",
|
|
4975
|
+
"iframe",
|
|
4976
|
+
"object",
|
|
4977
|
+
"embed",
|
|
4978
|
+
'[contenteditable="true"]',
|
|
4979
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
4980
|
+
].join(",");
|
|
4981
|
+
var trapStack = [];
|
|
4982
|
+
var FocusTrap = class extends AuditableComponent {
|
|
4983
|
+
constructor(target, options = {}) {
|
|
4984
|
+
super();
|
|
4985
|
+
this.active = false;
|
|
4986
|
+
this.paused = false;
|
|
4987
|
+
this.previousActiveElement = null;
|
|
4988
|
+
this.inertSiblings = [];
|
|
4989
|
+
// Sentinelles anti-fuite de focus
|
|
4990
|
+
this.startSentinel = null;
|
|
4991
|
+
this.endSentinel = null;
|
|
4992
|
+
const el = typeof target === "string" ? document.querySelector(target) : target;
|
|
4993
|
+
if (!el || !(el instanceof HTMLElement)) {
|
|
4994
|
+
throw new Error(`[Wulf.FocusTrap] Conteneur introuvable ou invalide : "${target}"`);
|
|
4995
|
+
}
|
|
4996
|
+
this.element = el;
|
|
4997
|
+
this.options = {
|
|
4998
|
+
initialFocus: options.initialFocus !== void 0 ? options.initialFocus : "[data-autofocus], [autofocus]",
|
|
4999
|
+
returnFocus: options.returnFocus ?? true,
|
|
5000
|
+
fallbackReturnFocus: options.fallbackReturnFocus ?? "",
|
|
5001
|
+
escapeDeactivates: options.escapeDeactivates ?? true,
|
|
5002
|
+
allowOutsideClick: options.allowOutsideClick ?? false,
|
|
5003
|
+
setInert: options.setInert ?? false,
|
|
5004
|
+
onActivate: options.onActivate ?? (() => {
|
|
5005
|
+
}),
|
|
5006
|
+
onDeactivate: options.onDeactivate ?? (() => {
|
|
5007
|
+
}),
|
|
5008
|
+
audit: options.audit ?? true
|
|
5009
|
+
};
|
|
5010
|
+
this.handleKeyDownBound = this.handleKeyDown.bind(this);
|
|
5011
|
+
this.handleClickOutsideBound = this.handleClickOutside.bind(this);
|
|
5012
|
+
this.handleFocusInBound = this.handleFocusIn.bind(this);
|
|
5013
|
+
this.runAuditWarning(this.options.audit);
|
|
5014
|
+
}
|
|
5015
|
+
/**
|
|
5016
|
+
* Vérifie si un élément est réellement focusable, visible et actif dans le DOM.
|
|
5017
|
+
*/
|
|
5018
|
+
isFocusable(el) {
|
|
5019
|
+
if (!el || !el.isConnected) return false;
|
|
5020
|
+
if (el.disabled) return false;
|
|
5021
|
+
if (el.closest("fieldset[disabled]") && !el.closest("legend")) return false;
|
|
5022
|
+
if (el.hasAttribute("inert") || el.closest("[inert]")) return false;
|
|
5023
|
+
if (el.hidden || el.closest("[hidden]")) return false;
|
|
5024
|
+
if (el.style.display === "none" || el.style.visibility === "hidden") return false;
|
|
5025
|
+
const style = window.getComputedStyle(el);
|
|
5026
|
+
if (style.display === "none" || style.visibility === "hidden") return false;
|
|
5027
|
+
if (el.offsetWidth === 0 && el.offsetHeight === 0 && style.position !== "fixed") {
|
|
5028
|
+
return false;
|
|
5029
|
+
}
|
|
5030
|
+
if (el instanceof HTMLInputElement && el.type === "radio" && el.name) {
|
|
5031
|
+
const group = Array.from(
|
|
5032
|
+
this.element.querySelectorAll(`input[type="radio"][name="${CSS.escape(el.name)}"]`)
|
|
5033
|
+
);
|
|
5034
|
+
const checked = group.find((r) => r.checked);
|
|
5035
|
+
if (checked) {
|
|
5036
|
+
return el === checked;
|
|
5037
|
+
}
|
|
5038
|
+
return el === group[0];
|
|
5039
|
+
}
|
|
5040
|
+
return true;
|
|
5041
|
+
}
|
|
5042
|
+
/**
|
|
5043
|
+
* Retourne tous les éléments focusables réels ordonnés dans le conteneur.
|
|
5044
|
+
*/
|
|
5045
|
+
getFocusableElements() {
|
|
5046
|
+
const rawElements = Array.from(this.element.querySelectorAll(FOCUSABLE_SELECTOR));
|
|
5047
|
+
return rawElements.filter((el) => this.isFocusable(el));
|
|
5048
|
+
}
|
|
5049
|
+
/**
|
|
5050
|
+
* Active le trap.
|
|
5051
|
+
*/
|
|
5052
|
+
activate() {
|
|
5053
|
+
if (this.active) return this;
|
|
5054
|
+
const currentTop = trapStack[trapStack.length - 1];
|
|
5055
|
+
if (currentTop) {
|
|
5056
|
+
currentTop.pause();
|
|
5057
|
+
}
|
|
5058
|
+
this.active = true;
|
|
5059
|
+
this.paused = false;
|
|
5060
|
+
trapStack.push(this);
|
|
5061
|
+
this.previousActiveElement = document.activeElement;
|
|
5062
|
+
this.setupSentinels();
|
|
5063
|
+
if (this.options.setInert) {
|
|
5064
|
+
this.applyInert();
|
|
5065
|
+
}
|
|
5066
|
+
document.addEventListener("keydown", this.handleKeyDownBound, true);
|
|
5067
|
+
document.addEventListener("focusin", this.handleFocusInBound, true);
|
|
5068
|
+
if (!this.options.allowOutsideClick) {
|
|
5069
|
+
document.addEventListener("mousedown", this.handleClickOutsideBound, true);
|
|
5070
|
+
document.addEventListener("touchstart", this.handleClickOutsideBound, true);
|
|
5071
|
+
}
|
|
5072
|
+
this.applyInitialFocus();
|
|
5073
|
+
this.runAuditWarning(this.options.audit);
|
|
5074
|
+
this.options.onActivate();
|
|
5075
|
+
return this;
|
|
5076
|
+
}
|
|
5077
|
+
/**
|
|
5078
|
+
* Désactive le trap et libère les écouteurs.
|
|
5079
|
+
*/
|
|
5080
|
+
deactivate() {
|
|
5081
|
+
if (!this.active) return this;
|
|
5082
|
+
this.active = false;
|
|
5083
|
+
this.paused = false;
|
|
5084
|
+
const index = trapStack.indexOf(this);
|
|
5085
|
+
if (index !== -1) {
|
|
5086
|
+
trapStack.splice(index, 1);
|
|
5087
|
+
}
|
|
5088
|
+
const nextTop = trapStack[trapStack.length - 1];
|
|
5089
|
+
if (nextTop) {
|
|
5090
|
+
nextTop.unpause();
|
|
5091
|
+
}
|
|
5092
|
+
document.removeEventListener("keydown", this.handleKeyDownBound, true);
|
|
5093
|
+
document.removeEventListener("focusin", this.handleFocusInBound, true);
|
|
5094
|
+
document.removeEventListener("mousedown", this.handleClickOutsideBound, true);
|
|
5095
|
+
document.removeEventListener("touchstart", this.handleClickOutsideBound, true);
|
|
5096
|
+
this.removeSentinels();
|
|
5097
|
+
this.removeInert();
|
|
5098
|
+
if (this.options.returnFocus) {
|
|
5099
|
+
this.restoreFocus();
|
|
5100
|
+
}
|
|
5101
|
+
this.options.onDeactivate();
|
|
5102
|
+
return this;
|
|
5103
|
+
}
|
|
5104
|
+
/**
|
|
5105
|
+
* Met en pause le trap (utilisé quand un trap fils s'ouvre au-dessus).
|
|
5106
|
+
*/
|
|
5107
|
+
pause() {
|
|
5108
|
+
this.paused = true;
|
|
5109
|
+
}
|
|
5110
|
+
/**
|
|
5111
|
+
* Sort de pause.
|
|
5112
|
+
*/
|
|
5113
|
+
unpause() {
|
|
5114
|
+
this.paused = false;
|
|
5115
|
+
}
|
|
5116
|
+
/**
|
|
5117
|
+
* Indique si le trap est actuellement actif et non en pause.
|
|
5118
|
+
*/
|
|
5119
|
+
isActive() {
|
|
5120
|
+
return this.active && !this.paused;
|
|
5121
|
+
}
|
|
5122
|
+
/**
|
|
5123
|
+
* Vérifie la conformité d'accessibilité WAI-ARIA du conteneur FocusTrap
|
|
5124
|
+
* et retourne la liste des contraintes manquantes.
|
|
5125
|
+
*/
|
|
5126
|
+
audit() {
|
|
5127
|
+
const warnings = [];
|
|
5128
|
+
const role = this.element.getAttribute("role");
|
|
5129
|
+
const isNativeDialog = this.element.tagName.toLowerCase() === "dialog";
|
|
5130
|
+
const validRoles = ["dialog", "alertdialog", "menu", "listbox", "tree", "grid"];
|
|
5131
|
+
if (!isNativeDialog && (!role || !validRoles.includes(role))) {
|
|
5132
|
+
warnings.push(
|
|
5133
|
+
'R\xF4le s\xE9mantique manquant ou inadapt\xE9 : d\xE9finissez role="dialog" (ou "alertdialog", "menu", "listbox") sur le conteneur.'
|
|
5134
|
+
);
|
|
5135
|
+
}
|
|
5136
|
+
if ((isNativeDialog || role === "dialog" || role === "alertdialog") && this.element.getAttribute("aria-modal") !== "true") {
|
|
5137
|
+
warnings.push(
|
|
5138
|
+
'Isolation modale manquante : d\xE9finissez aria-modal="true" sur le conteneur de dialogue (WCAG 4.1.2).'
|
|
5139
|
+
);
|
|
5140
|
+
}
|
|
5141
|
+
const ariaLabel = this.element.getAttribute("aria-label")?.trim();
|
|
5142
|
+
const hasValidLabelledby = this.checkAriaIdReferences(this.element, "aria-labelledby", warnings);
|
|
5143
|
+
if (!ariaLabel && !hasValidLabelledby) {
|
|
5144
|
+
warnings.push(
|
|
5145
|
+
'Nom accessible manquant : d\xE9finissez aria-labelledby="id-titre" ou aria-label="..." sur le conteneur (WCAG 4.1.2).'
|
|
5146
|
+
);
|
|
5147
|
+
}
|
|
5148
|
+
return warnings;
|
|
5149
|
+
}
|
|
5150
|
+
getAuditPrefix() {
|
|
5151
|
+
return "Wulf.FocusTrap";
|
|
5152
|
+
}
|
|
5153
|
+
getAuditTargetLabel() {
|
|
5154
|
+
return this.element.id ? `#${this.element.id}` : `<${this.element.tagName.toLowerCase()}>`;
|
|
5155
|
+
}
|
|
5156
|
+
/**
|
|
5157
|
+
* Détruit l'instance proprement.
|
|
5158
|
+
*/
|
|
5159
|
+
destroy() {
|
|
5160
|
+
this.deactivate();
|
|
5161
|
+
}
|
|
5162
|
+
// --- Implémentation interne ---
|
|
5163
|
+
handleKeyDown(e) {
|
|
5164
|
+
if (!this.isActive()) return;
|
|
5165
|
+
if (e.key === "Escape" && this.options.escapeDeactivates) {
|
|
5166
|
+
e.preventDefault();
|
|
5167
|
+
e.stopPropagation();
|
|
5168
|
+
this.deactivate();
|
|
5169
|
+
return;
|
|
5170
|
+
}
|
|
5171
|
+
if (e.key !== "Tab") return;
|
|
5172
|
+
const focusables = this.getFocusableElements();
|
|
5173
|
+
if (focusables.length === 0) {
|
|
5174
|
+
e.preventDefault();
|
|
5175
|
+
if (this.element.getAttribute("tabindex") === null) {
|
|
5176
|
+
this.element.setAttribute("tabindex", "-1");
|
|
5177
|
+
}
|
|
5178
|
+
this.element.focus();
|
|
5179
|
+
return;
|
|
5180
|
+
}
|
|
5181
|
+
const first = focusables[0];
|
|
5182
|
+
const last = focusables[focusables.length - 1];
|
|
5183
|
+
const current = document.activeElement;
|
|
5184
|
+
if (!e.shiftKey && (current === last || !this.element.contains(current))) {
|
|
5185
|
+
e.preventDefault();
|
|
5186
|
+
first.focus();
|
|
5187
|
+
} else if (e.shiftKey && (current === first || !this.element.contains(current))) {
|
|
5188
|
+
e.preventDefault();
|
|
5189
|
+
last.focus();
|
|
5190
|
+
}
|
|
5191
|
+
}
|
|
5192
|
+
handleFocusIn(e) {
|
|
5193
|
+
if (!this.isActive()) return;
|
|
5194
|
+
const target = e.target;
|
|
5195
|
+
if (!target) return;
|
|
5196
|
+
if (target === this.startSentinel) {
|
|
5197
|
+
const focusables = this.getFocusableElements();
|
|
5198
|
+
if (focusables.length > 0) {
|
|
5199
|
+
focusables[focusables.length - 1].focus();
|
|
5200
|
+
} else {
|
|
5201
|
+
this.element.focus();
|
|
5202
|
+
}
|
|
5203
|
+
return;
|
|
5204
|
+
}
|
|
5205
|
+
if (target === this.endSentinel) {
|
|
5206
|
+
const focusables = this.getFocusableElements();
|
|
5207
|
+
if (focusables.length > 0) {
|
|
5208
|
+
focusables[0].focus();
|
|
5209
|
+
} else {
|
|
5210
|
+
this.element.focus();
|
|
5211
|
+
}
|
|
5212
|
+
return;
|
|
5213
|
+
}
|
|
5214
|
+
if (!this.element.contains(target)) {
|
|
5215
|
+
const focusables = this.getFocusableElements();
|
|
5216
|
+
if (focusables.length > 0) {
|
|
5217
|
+
focusables[0].focus();
|
|
5218
|
+
} else {
|
|
5219
|
+
if (this.element.getAttribute("tabindex") === null) {
|
|
5220
|
+
this.element.setAttribute("tabindex", "-1");
|
|
5221
|
+
}
|
|
5222
|
+
this.element.focus();
|
|
5223
|
+
}
|
|
5224
|
+
}
|
|
5225
|
+
}
|
|
5226
|
+
handleClickOutside(e) {
|
|
5227
|
+
if (!this.isActive()) return;
|
|
5228
|
+
const target = e.target;
|
|
5229
|
+
if (target && !this.element.contains(target)) {
|
|
5230
|
+
e.preventDefault();
|
|
5231
|
+
e.stopPropagation();
|
|
5232
|
+
}
|
|
5233
|
+
}
|
|
5234
|
+
setupSentinels() {
|
|
5235
|
+
if (!this.startSentinel) {
|
|
5236
|
+
this.startSentinel = document.createElement("span");
|
|
5237
|
+
this.startSentinel.setAttribute("tabindex", "0");
|
|
5238
|
+
this.startSentinel.setAttribute("aria-hidden", "true");
|
|
5239
|
+
this.startSentinel.className = "wulf-sentinel-start";
|
|
5240
|
+
this.startSentinel.style.cssText = "position:fixed;top:0;left:0;opacity:0;pointer-events:none;width:0;height:0;";
|
|
5241
|
+
}
|
|
5242
|
+
if (!this.endSentinel) {
|
|
5243
|
+
this.endSentinel = document.createElement("span");
|
|
5244
|
+
this.endSentinel.setAttribute("tabindex", "0");
|
|
5245
|
+
this.endSentinel.setAttribute("aria-hidden", "true");
|
|
5246
|
+
this.endSentinel.className = "wulf-sentinel-end";
|
|
5247
|
+
this.endSentinel.style.cssText = "position:fixed;top:0;left:0;opacity:0;pointer-events:none;width:0;height:0;";
|
|
5248
|
+
}
|
|
5249
|
+
if (this.element.parentNode) {
|
|
5250
|
+
this.element.parentNode.insertBefore(this.startSentinel, this.element);
|
|
5251
|
+
this.element.parentNode.insertBefore(this.endSentinel, this.element.nextSibling);
|
|
5252
|
+
}
|
|
5253
|
+
}
|
|
5254
|
+
removeSentinels() {
|
|
5255
|
+
this.startSentinel?.remove();
|
|
5256
|
+
this.endSentinel?.remove();
|
|
5257
|
+
this.startSentinel = null;
|
|
5258
|
+
this.endSentinel = null;
|
|
5259
|
+
}
|
|
5260
|
+
applyInert() {
|
|
5261
|
+
this.inertSiblings = [];
|
|
5262
|
+
let parent = this.element.parentElement;
|
|
5263
|
+
let currentChild = this.element;
|
|
5264
|
+
while (parent && parent !== document.body) {
|
|
5265
|
+
currentChild = parent;
|
|
5266
|
+
parent = parent.parentElement;
|
|
5267
|
+
}
|
|
5268
|
+
if (parent === document.body) {
|
|
5269
|
+
Array.from(document.body.children).forEach((child) => {
|
|
5270
|
+
if (child instanceof HTMLElement && child !== currentChild && child !== this.startSentinel && child !== this.endSentinel && !child.hasAttribute("inert")) {
|
|
5271
|
+
child.setAttribute("inert", "");
|
|
5272
|
+
this.inertSiblings.push(child);
|
|
5273
|
+
}
|
|
5274
|
+
});
|
|
5275
|
+
}
|
|
5276
|
+
}
|
|
5277
|
+
removeInert() {
|
|
5278
|
+
this.inertSiblings.forEach((el) => el.removeAttribute("inert"));
|
|
5279
|
+
this.inertSiblings = [];
|
|
5280
|
+
}
|
|
5281
|
+
applyInitialFocus() {
|
|
5282
|
+
if (this.options.initialFocus === false) return;
|
|
5283
|
+
let targetEl = null;
|
|
5284
|
+
if (typeof this.options.initialFocus === "string") {
|
|
5285
|
+
targetEl = this.element.querySelector(this.options.initialFocus);
|
|
5286
|
+
} else if (this.options.initialFocus instanceof HTMLElement) {
|
|
5287
|
+
targetEl = this.options.initialFocus;
|
|
5288
|
+
}
|
|
5289
|
+
if (targetEl && this.isFocusable(targetEl)) {
|
|
5290
|
+
targetEl.focus();
|
|
5291
|
+
return;
|
|
5292
|
+
}
|
|
5293
|
+
const focusables = this.getFocusableElements();
|
|
5294
|
+
if (focusables.length > 0) {
|
|
5295
|
+
focusables[0].focus();
|
|
5296
|
+
} else {
|
|
5297
|
+
if (this.element.getAttribute("tabindex") === null) {
|
|
5298
|
+
this.element.setAttribute("tabindex", "-1");
|
|
5299
|
+
}
|
|
5300
|
+
this.element.focus();
|
|
5301
|
+
}
|
|
5302
|
+
}
|
|
5303
|
+
restoreFocus() {
|
|
5304
|
+
if (this.previousActiveElement && this.previousActiveElement.isConnected) {
|
|
5305
|
+
this.previousActiveElement.focus();
|
|
5306
|
+
return;
|
|
5307
|
+
}
|
|
5308
|
+
if (this.options.fallbackReturnFocus) {
|
|
5309
|
+
const fallback = typeof this.options.fallbackReturnFocus === "string" ? document.querySelector(this.options.fallbackReturnFocus) : this.options.fallbackReturnFocus;
|
|
5310
|
+
if (fallback && fallback.isConnected) {
|
|
5311
|
+
fallback.focus();
|
|
5312
|
+
}
|
|
5313
|
+
}
|
|
5314
|
+
}
|
|
5315
|
+
};
|
|
5316
|
+
|
|
5317
|
+
// src/focus-trap/index.ts
|
|
5318
|
+
if (typeof window !== "undefined") {
|
|
5319
|
+
const win = window;
|
|
5320
|
+
const wulfNamespace = win.Wulf || {};
|
|
5321
|
+
win.Wulf = wulfNamespace;
|
|
5322
|
+
wulfNamespace.FocusTrap = Object.assign(FocusTrap, {
|
|
5323
|
+
FocusTrap
|
|
5324
|
+
});
|
|
4212
5325
|
}
|
|
4213
5326
|
export {
|
|
4214
5327
|
AmountEngine,
|
|
5328
|
+
AuditableComponent,
|
|
4215
5329
|
BaseInputMask,
|
|
4216
5330
|
EmailEngine,
|
|
5331
|
+
focus_trap_exports as FocusTrap,
|
|
4217
5332
|
InputAmountMask,
|
|
4218
5333
|
InputEmailMask,
|
|
4219
5334
|
InputMask,
|
|
5335
|
+
LocalizedComponent,
|
|
4220
5336
|
mask_exports as Mask,
|
|
4221
5337
|
MaskEngine,
|
|
4222
5338
|
MaskHistory,
|
|
@@ -4224,6 +5340,8 @@ export {
|
|
|
4224
5340
|
masonry_exports as Masonry,
|
|
4225
5341
|
scroll_exports as Scroll,
|
|
4226
5342
|
toast_exports as Toast,
|
|
5343
|
+
FocusTrap as WulfFocusTrap,
|
|
5344
|
+
createI18nManager,
|
|
4227
5345
|
mask_default as default,
|
|
4228
5346
|
resolveMaskConstructorArgs
|
|
4229
5347
|
};
|