wulf.js 1.9.0 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +220 -19
- package/changelog.md +42 -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.esm.js +1179 -8
- package/dist/index.esm.js.map +4 -4
- package/dist/index.global.js +1180 -9
- package/dist/index.global.js.map +4 -4
- package/dist/index.global.min.js +5 -2
- package/dist/index.global.min.js.map +4 -4
- package/dist/mask.esm.js +106 -2
- package/dist/mask.esm.js.map +3 -3
- package/dist/mask.global.js +107 -3
- package/dist/mask.global.js.map +3 -3
- package/dist/mask.global.min.js +5 -2
- package/dist/mask.global.min.js.map +4 -4
- package/dist/masonry.esm.js +78 -3
- package/dist/masonry.esm.js.map +3 -3
- package/dist/masonry.global.js +79 -4
- package/dist/masonry.global.js.map +3 -3
- package/dist/masonry.global.min.js +5 -2
- package/dist/masonry.global.min.js.map +4 -4
- package/dist/scroll.esm.js +78 -3
- package/dist/scroll.esm.js.map +3 -3
- package/dist/scroll.global.js +79 -4
- package/dist/scroll.global.js.map +3 -3
- package/dist/scroll.global.min.js +5 -2
- package/dist/scroll.global.min.js.map +4 -4
- package/dist/shortcut.esm.js +584 -0
- package/dist/shortcut.esm.js.map +7 -0
- package/dist/shortcut.global.js +610 -0
- package/dist/shortcut.global.js.map +7 -0
- package/dist/shortcut.global.min.js +3 -0
- package/dist/shortcut.global.min.js.map +7 -0
- package/dist/toast.esm.js +91 -2
- package/dist/toast.esm.js.map +3 -3
- package/dist/toast.global.js +92 -3
- package/dist/toast.global.js.map +3 -3
- package/dist/toast.global.min.js +5 -2
- 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 +5 -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/shortcut/ShortcutFormatter.d.ts +31 -0
- package/dist/types/shortcut/ShortcutManager.d.ts +91 -0
- package/dist/types/shortcut/index.d.ts +4 -0
- package/dist/types/shortcut/types.d.ts +101 -0
- 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 +23 -10
- package/dist/index.cjs.js +0 -4783
- package/dist/index.cjs.js.map +0 -7
- package/dist/mask.cjs.js +0 -2982
- package/dist/mask.cjs.js.map +0 -7
- package/dist/masonry.cjs.js +0 -783
- package/dist/masonry.cjs.js.map +0 -7
- package/dist/scroll.cjs.js +0 -748
- package/dist/scroll.cjs.js.map +0 -7
- package/dist/toast.cjs.js +0 -626
- package/dist/toast.cjs.js.map +0 -7
package/dist/mask.esm.js
CHANGED
|
@@ -1,3 +1,46 @@
|
|
|
1
|
+
// src/common/AuditableComponent.ts
|
|
2
|
+
var AuditableComponent = class {
|
|
3
|
+
/**
|
|
4
|
+
* Indication affichée en pied de warning pour expliquer comment désactiver l'audit.
|
|
5
|
+
*/
|
|
6
|
+
getAuditDisableHint() {
|
|
7
|
+
return "Passez { audit: false } dans les options pour d\xE9sactiver cet avertissement";
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Exécute l'audit d'accessibilité et émet un avertissement standardisé dans la console
|
|
11
|
+
* si l'audit est activé et que des contraintes manquent.
|
|
12
|
+
*/
|
|
13
|
+
runAuditWarning(enabled = true) {
|
|
14
|
+
if (!enabled) return [];
|
|
15
|
+
const warnings = this.audit();
|
|
16
|
+
if (warnings.length > 0 && typeof console !== "undefined" && typeof console.warn === "function") {
|
|
17
|
+
console.warn(
|
|
18
|
+
`[${this.getAuditPrefix()}] Audit d'accessibilit\xE9 \u2014 ${warnings.length} contrainte(s) manquante(s) sur ${this.getAuditTargetLabel()} :
|
|
19
|
+
` + warnings.map((w) => ` - ${w}`).join("\n") + `
|
|
20
|
+
(${this.getAuditDisableHint()})`
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
return warnings;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Vérifie si un attribut de référence d'IDs ARIA (ex: aria-labelledby, aria-describedby)
|
|
27
|
+
* pointe vers des éléments réellement présents dans le document.
|
|
28
|
+
*/
|
|
29
|
+
checkAriaIdReferences(element, attrName, warnings) {
|
|
30
|
+
const rawValue = element.getAttribute(attrName)?.trim();
|
|
31
|
+
if (!rawValue) return false;
|
|
32
|
+
const doc = element.ownerDocument || document;
|
|
33
|
+
const ids = rawValue.split(/\s+/).filter(Boolean);
|
|
34
|
+
const isValid = ids.length > 0 && ids.every((id) => Boolean(doc.getElementById(id)));
|
|
35
|
+
if (!isValid) {
|
|
36
|
+
warnings.push(
|
|
37
|
+
`Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
return isValid;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
1
44
|
// src/mask/BaseInputMask.ts
|
|
2
45
|
function resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOptions) {
|
|
3
46
|
const isSecondArgInput = Boolean(
|
|
@@ -16,8 +59,9 @@ function resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOption
|
|
|
16
59
|
options: inputOrOptions && typeof inputOrOptions === "object" && !("tagName" in inputOrOptions) ? inputOrOptions : {}
|
|
17
60
|
};
|
|
18
61
|
}
|
|
19
|
-
var BaseInputMask = class {
|
|
62
|
+
var BaseInputMask = class extends AuditableComponent {
|
|
20
63
|
constructor(targetOrWrapper, inputOrOptions, maybeOptions) {
|
|
64
|
+
super();
|
|
21
65
|
this.ghost = null;
|
|
22
66
|
this.isWrapperCreated = false;
|
|
23
67
|
this.isDestroyed = false;
|
|
@@ -105,8 +149,10 @@ var BaseInputMask = class {
|
|
|
105
149
|
const dataSelectAll = this.getAttr("data-mask-select-on-focus") === "true";
|
|
106
150
|
const dataCopyRaw = this.getAttr("data-mask-copy-raw") === "true";
|
|
107
151
|
const dataAlign = this.getAttr("data-mask-align") || this.getAttr("data-align");
|
|
152
|
+
const dataAudit = this.getAttr("data-mask-audit");
|
|
108
153
|
const { disabled: optDisabled, align: optAlign, ...otherOptions } = options;
|
|
109
154
|
const resolvedDisabled = optDisabled !== void 0 ? optDisabled : dataDisabled ? true : false;
|
|
155
|
+
const resolvedAudit = options.audit ?? (dataAudit !== null ? dataAudit !== "false" : true);
|
|
110
156
|
const isPassword = this.input.type === "password";
|
|
111
157
|
this.options = {
|
|
112
158
|
...otherOptions,
|
|
@@ -116,7 +162,8 @@ var BaseInputMask = class {
|
|
|
116
162
|
copyRaw: isPassword ? false : options.copyRaw ?? dataCopyRaw ?? false,
|
|
117
163
|
disabled: resolvedDisabled,
|
|
118
164
|
align: optAlign ?? (dataAlign || void 0),
|
|
119
|
-
emitNativeInput: options.emitNativeInput ?? true
|
|
165
|
+
emitNativeInput: options.emitNativeInput ?? true,
|
|
166
|
+
audit: resolvedAudit
|
|
120
167
|
};
|
|
121
168
|
if (this.options.showMaskOnFocus) {
|
|
122
169
|
this.wrapper.classList.add("mask-focus-only");
|
|
@@ -461,6 +508,48 @@ var BaseInputMask = class {
|
|
|
461
508
|
getRawValue() {
|
|
462
509
|
return this.input.value;
|
|
463
510
|
}
|
|
511
|
+
/**
|
|
512
|
+
* Vérifie la conformité d'accessibilité WAI-ARIA du champ de saisie (étiquetage, format attendu)
|
|
513
|
+
* et retourne la liste des contraintes manquantes.
|
|
514
|
+
*/
|
|
515
|
+
audit() {
|
|
516
|
+
const warnings = [];
|
|
517
|
+
const doc = this.input.ownerDocument || document;
|
|
518
|
+
const ariaLabel = this.input.getAttribute("aria-label")?.trim();
|
|
519
|
+
const hasValidLabelledby = this.checkAriaIdReferences(this.input, "aria-labelledby", warnings);
|
|
520
|
+
const hasWrappingLabel = Boolean(this.input.closest("label"));
|
|
521
|
+
const hasNativeLabels = Boolean(this.input.labels && this.input.labels.length > 0);
|
|
522
|
+
let hasExplicitLabelFor = false;
|
|
523
|
+
if (this.input.id && typeof CSS !== "undefined" && typeof CSS.escape === "function") {
|
|
524
|
+
hasExplicitLabelFor = Boolean(doc.querySelector(`label[for="${CSS.escape(this.input.id)}"]`));
|
|
525
|
+
} else if (this.input.id) {
|
|
526
|
+
hasExplicitLabelFor = Boolean(doc.querySelector(`label[for="${this.input.id}"]`));
|
|
527
|
+
}
|
|
528
|
+
if (!ariaLabel && !hasValidLabelledby && !hasWrappingLabel && !hasNativeLabels && !hasExplicitLabelFor) {
|
|
529
|
+
warnings.push(
|
|
530
|
+
`\xC9tiquetage accessible manquant : associez un <label for="id"> (ou d\xE9finissez aria-label / aria-labelledby) sur l'input (WCAG 4.1.2).`
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
this.checkAriaIdReferences(this.input, "aria-describedby", warnings);
|
|
534
|
+
const extraWarnings = this.getSpecificAuditWarnings();
|
|
535
|
+
warnings.push(...extraWarnings);
|
|
536
|
+
return warnings;
|
|
537
|
+
}
|
|
538
|
+
getAuditPrefix() {
|
|
539
|
+
return `Wulf.Mask.${this.constructor.name || "InputMask"}`;
|
|
540
|
+
}
|
|
541
|
+
getAuditTargetLabel() {
|
|
542
|
+
return this.input.id ? `#${this.input.id}` : this.input.name ? `input[name="${this.input.name}"]` : "<input>";
|
|
543
|
+
}
|
|
544
|
+
getAuditDisableHint() {
|
|
545
|
+
return 'Passez { audit: false } ou data-mask-audit="false" pour d\xE9sactiver cet avertissement';
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Crochet permettant aux classes filles d'ajouter des vérifications d'audit spécifiques.
|
|
549
|
+
*/
|
|
550
|
+
getSpecificAuditWarnings() {
|
|
551
|
+
return [];
|
|
552
|
+
}
|
|
464
553
|
/**
|
|
465
554
|
* Supprime les éléments fantômes, restaure les propriétés et nettoie les attributs.
|
|
466
555
|
*/
|
|
@@ -1255,6 +1344,19 @@ var InputMask = class extends BaseInputMask {
|
|
|
1255
1344
|
this.bindEvents();
|
|
1256
1345
|
this.lastValue = this.input.value;
|
|
1257
1346
|
this.syncInitialValue();
|
|
1347
|
+
this.runAuditWarning(this.options.audit);
|
|
1348
|
+
}
|
|
1349
|
+
getSpecificAuditWarnings() {
|
|
1350
|
+
const warnings = [];
|
|
1351
|
+
const hasDescribedby = Boolean(this.input.getAttribute("aria-describedby")?.trim());
|
|
1352
|
+
const hasPlaceholder = Boolean(this.input.getAttribute("placeholder")?.trim());
|
|
1353
|
+
const hasAriaPlaceholder = Boolean(this.input.getAttribute("aria-placeholder")?.trim());
|
|
1354
|
+
if (!hasDescribedby && !hasPlaceholder && !hasAriaPlaceholder && !this.options.disabled) {
|
|
1355
|
+
warnings.push(
|
|
1356
|
+
"Indication du format attendu manquante : d\xE9finissez aria-describedby, placeholder ou aria-placeholder pour informer les technologies d'assistance (WCAG 3.3.2)."
|
|
1357
|
+
);
|
|
1358
|
+
}
|
|
1359
|
+
return warnings;
|
|
1258
1360
|
}
|
|
1259
1361
|
extractRawSnippet(snippet) {
|
|
1260
1362
|
return this.engine.extractRaw(snippet);
|
|
@@ -2104,6 +2206,7 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2104
2206
|
isValid: true
|
|
2105
2207
|
});
|
|
2106
2208
|
}
|
|
2209
|
+
this.runAuditWarning(this.options.audit);
|
|
2107
2210
|
}
|
|
2108
2211
|
extractRawSnippet(snippet) {
|
|
2109
2212
|
const p = this.engine.parse(snippet);
|
|
@@ -2686,6 +2789,7 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2686
2789
|
if (!this.options.disabled) {
|
|
2687
2790
|
this.updateSuggestion();
|
|
2688
2791
|
}
|
|
2792
|
+
this.runAuditWarning(this.options.audit);
|
|
2689
2793
|
}
|
|
2690
2794
|
onNativeValueSet(_strVal) {
|
|
2691
2795
|
if (this.options.disabled) return;
|