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.
Files changed (75) hide show
  1. package/README.md +220 -19
  2. package/changelog.md +42 -0
  3. package/dist/focus-trap.esm.js +407 -0
  4. package/dist/focus-trap.esm.js.map +7 -0
  5. package/dist/focus-trap.global.js +433 -0
  6. package/dist/focus-trap.global.js.map +7 -0
  7. package/dist/focus-trap.global.min.js +6 -0
  8. package/dist/focus-trap.global.min.js.map +7 -0
  9. package/dist/index.esm.js +1179 -8
  10. package/dist/index.esm.js.map +4 -4
  11. package/dist/index.global.js +1180 -9
  12. package/dist/index.global.js.map +4 -4
  13. package/dist/index.global.min.js +5 -2
  14. package/dist/index.global.min.js.map +4 -4
  15. package/dist/mask.esm.js +106 -2
  16. package/dist/mask.esm.js.map +3 -3
  17. package/dist/mask.global.js +107 -3
  18. package/dist/mask.global.js.map +3 -3
  19. package/dist/mask.global.min.js +5 -2
  20. package/dist/mask.global.min.js.map +4 -4
  21. package/dist/masonry.esm.js +78 -3
  22. package/dist/masonry.esm.js.map +3 -3
  23. package/dist/masonry.global.js +79 -4
  24. package/dist/masonry.global.js.map +3 -3
  25. package/dist/masonry.global.min.js +5 -2
  26. package/dist/masonry.global.min.js.map +4 -4
  27. package/dist/scroll.esm.js +78 -3
  28. package/dist/scroll.esm.js.map +3 -3
  29. package/dist/scroll.global.js +79 -4
  30. package/dist/scroll.global.js.map +3 -3
  31. package/dist/scroll.global.min.js +5 -2
  32. package/dist/scroll.global.min.js.map +4 -4
  33. package/dist/shortcut.esm.js +584 -0
  34. package/dist/shortcut.esm.js.map +7 -0
  35. package/dist/shortcut.global.js +610 -0
  36. package/dist/shortcut.global.js.map +7 -0
  37. package/dist/shortcut.global.min.js +3 -0
  38. package/dist/shortcut.global.min.js.map +7 -0
  39. package/dist/toast.esm.js +91 -2
  40. package/dist/toast.esm.js.map +3 -3
  41. package/dist/toast.global.js +92 -3
  42. package/dist/toast.global.js.map +3 -3
  43. package/dist/toast.global.min.js +5 -2
  44. package/dist/toast.global.min.js.map +4 -4
  45. package/dist/types/common/AuditableComponent.d.ts +45 -0
  46. package/dist/types/common/LocalizedComponent.d.ts +3 -2
  47. package/dist/types/focus-trap/FocusTrap.d.ts +64 -0
  48. package/dist/types/focus-trap/index.d.ts +3 -0
  49. package/dist/types/focus-trap/types.d.ts +45 -0
  50. package/dist/types/index.d.ts +5 -0
  51. package/dist/types/mask/BaseInputMask.d.ts +14 -1
  52. package/dist/types/mask/InputMask.d.ts +1 -0
  53. package/dist/types/mask/types.d.ts +5 -2
  54. package/dist/types/masonry/Masonry.d.ts +7 -0
  55. package/dist/types/masonry/types.d.ts +7 -2
  56. package/dist/types/scroll/ScrollBlock.d.ts +7 -0
  57. package/dist/types/scroll/types.d.ts +3 -2
  58. package/dist/types/shortcut/ShortcutFormatter.d.ts +31 -0
  59. package/dist/types/shortcut/ShortcutManager.d.ts +91 -0
  60. package/dist/types/shortcut/index.d.ts +4 -0
  61. package/dist/types/shortcut/types.d.ts +101 -0
  62. package/dist/types/toast/Toast.d.ts +3 -0
  63. package/dist/types/toast/ToastInstance.d.ts +9 -1
  64. package/dist/types/toast/types.d.ts +3 -2
  65. package/package.json +23 -10
  66. package/dist/index.cjs.js +0 -4783
  67. package/dist/index.cjs.js.map +0 -7
  68. package/dist/mask.cjs.js +0 -2982
  69. package/dist/mask.cjs.js.map +0 -7
  70. package/dist/masonry.cjs.js +0 -783
  71. package/dist/masonry.cjs.js.map +0 -7
  72. package/dist/scroll.cjs.js +0 -748
  73. package/dist/scroll.cjs.js.map +0 -7
  74. package/dist/toast.cjs.js +0 -626
  75. package/dist/toast.cjs.js.map +0 -7
@@ -35,6 +35,49 @@ var Wulf = (() => {
35
35
  resolveMaskConstructorArgs: () => resolveMaskConstructorArgs
36
36
  });
37
37
 
38
+ // src/common/AuditableComponent.ts
39
+ var AuditableComponent = class {
40
+ /**
41
+ * Indication affichée en pied de warning pour expliquer comment désactiver l'audit.
42
+ */
43
+ getAuditDisableHint() {
44
+ return "Passez { audit: false } dans les options pour d\xE9sactiver cet avertissement";
45
+ }
46
+ /**
47
+ * Exécute l'audit d'accessibilité et émet un avertissement standardisé dans la console
48
+ * si l'audit est activé et que des contraintes manquent.
49
+ */
50
+ runAuditWarning(enabled = true) {
51
+ if (!enabled) return [];
52
+ const warnings = this.audit();
53
+ if (warnings.length > 0 && typeof console !== "undefined" && typeof console.warn === "function") {
54
+ console.warn(
55
+ `[${this.getAuditPrefix()}] Audit d'accessibilit\xE9 \u2014 ${warnings.length} contrainte(s) manquante(s) sur ${this.getAuditTargetLabel()} :
56
+ ` + warnings.map((w) => ` - ${w}`).join("\n") + `
57
+ (${this.getAuditDisableHint()})`
58
+ );
59
+ }
60
+ return warnings;
61
+ }
62
+ /**
63
+ * Vérifie si un attribut de référence d'IDs ARIA (ex: aria-labelledby, aria-describedby)
64
+ * pointe vers des éléments réellement présents dans le document.
65
+ */
66
+ checkAriaIdReferences(element, attrName, warnings) {
67
+ const rawValue = element.getAttribute(attrName)?.trim();
68
+ if (!rawValue) return false;
69
+ const doc = element.ownerDocument || document;
70
+ const ids = rawValue.split(/\s+/).filter(Boolean);
71
+ const isValid = ids.length > 0 && ids.every((id) => Boolean(doc.getElementById(id)));
72
+ if (!isValid) {
73
+ warnings.push(
74
+ `Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`
75
+ );
76
+ }
77
+ return isValid;
78
+ }
79
+ };
80
+
38
81
  // src/mask/BaseInputMask.ts
39
82
  function resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOptions) {
40
83
  const isSecondArgInput = Boolean(
@@ -53,8 +96,9 @@ var Wulf = (() => {
53
96
  options: inputOrOptions && typeof inputOrOptions === "object" && !("tagName" in inputOrOptions) ? inputOrOptions : {}
54
97
  };
55
98
  }
56
- var BaseInputMask = class {
99
+ var BaseInputMask = class extends AuditableComponent {
57
100
  constructor(targetOrWrapper, inputOrOptions, maybeOptions) {
101
+ super();
58
102
  this.ghost = null;
59
103
  this.isWrapperCreated = false;
60
104
  this.isDestroyed = false;
@@ -142,8 +186,10 @@ var Wulf = (() => {
142
186
  const dataSelectAll = this.getAttr("data-mask-select-on-focus") === "true";
143
187
  const dataCopyRaw = this.getAttr("data-mask-copy-raw") === "true";
144
188
  const dataAlign = this.getAttr("data-mask-align") || this.getAttr("data-align");
189
+ const dataAudit = this.getAttr("data-mask-audit");
145
190
  const { disabled: optDisabled, align: optAlign, ...otherOptions } = options;
146
191
  const resolvedDisabled = optDisabled !== void 0 ? optDisabled : dataDisabled ? true : false;
192
+ const resolvedAudit = options.audit ?? (dataAudit !== null ? dataAudit !== "false" : true);
147
193
  const isPassword = this.input.type === "password";
148
194
  this.options = {
149
195
  ...otherOptions,
@@ -153,7 +199,8 @@ var Wulf = (() => {
153
199
  copyRaw: isPassword ? false : options.copyRaw ?? dataCopyRaw ?? false,
154
200
  disabled: resolvedDisabled,
155
201
  align: optAlign ?? (dataAlign || void 0),
156
- emitNativeInput: options.emitNativeInput ?? true
202
+ emitNativeInput: options.emitNativeInput ?? true,
203
+ audit: resolvedAudit
157
204
  };
158
205
  if (this.options.showMaskOnFocus) {
159
206
  this.wrapper.classList.add("mask-focus-only");
@@ -498,6 +545,48 @@ var Wulf = (() => {
498
545
  getRawValue() {
499
546
  return this.input.value;
500
547
  }
548
+ /**
549
+ * Vérifie la conformité d'accessibilité WAI-ARIA du champ de saisie (étiquetage, format attendu)
550
+ * et retourne la liste des contraintes manquantes.
551
+ */
552
+ audit() {
553
+ const warnings = [];
554
+ const doc = this.input.ownerDocument || document;
555
+ const ariaLabel = this.input.getAttribute("aria-label")?.trim();
556
+ const hasValidLabelledby = this.checkAriaIdReferences(this.input, "aria-labelledby", warnings);
557
+ const hasWrappingLabel = Boolean(this.input.closest("label"));
558
+ const hasNativeLabels = Boolean(this.input.labels && this.input.labels.length > 0);
559
+ let hasExplicitLabelFor = false;
560
+ if (this.input.id && typeof CSS !== "undefined" && typeof CSS.escape === "function") {
561
+ hasExplicitLabelFor = Boolean(doc.querySelector(`label[for="${CSS.escape(this.input.id)}"]`));
562
+ } else if (this.input.id) {
563
+ hasExplicitLabelFor = Boolean(doc.querySelector(`label[for="${this.input.id}"]`));
564
+ }
565
+ if (!ariaLabel && !hasValidLabelledby && !hasWrappingLabel && !hasNativeLabels && !hasExplicitLabelFor) {
566
+ warnings.push(
567
+ `\xC9tiquetage accessible manquant : associez un <label for="id"> (ou d\xE9finissez aria-label / aria-labelledby) sur l'input (WCAG 4.1.2).`
568
+ );
569
+ }
570
+ this.checkAriaIdReferences(this.input, "aria-describedby", warnings);
571
+ const extraWarnings = this.getSpecificAuditWarnings();
572
+ warnings.push(...extraWarnings);
573
+ return warnings;
574
+ }
575
+ getAuditPrefix() {
576
+ return `Wulf.Mask.${this.constructor.name || "InputMask"}`;
577
+ }
578
+ getAuditTargetLabel() {
579
+ return this.input.id ? `#${this.input.id}` : this.input.name ? `input[name="${this.input.name}"]` : "<input>";
580
+ }
581
+ getAuditDisableHint() {
582
+ return 'Passez { audit: false } ou data-mask-audit="false" pour d\xE9sactiver cet avertissement';
583
+ }
584
+ /**
585
+ * Crochet permettant aux classes filles d'ajouter des vérifications d'audit spécifiques.
586
+ */
587
+ getSpecificAuditWarnings() {
588
+ return [];
589
+ }
501
590
  /**
502
591
  * Supprime les éléments fantômes, restaure les propriétés et nettoie les attributs.
503
592
  */
@@ -1292,6 +1381,19 @@ var Wulf = (() => {
1292
1381
  this.bindEvents();
1293
1382
  this.lastValue = this.input.value;
1294
1383
  this.syncInitialValue();
1384
+ this.runAuditWarning(this.options.audit);
1385
+ }
1386
+ getSpecificAuditWarnings() {
1387
+ const warnings = [];
1388
+ const hasDescribedby = Boolean(this.input.getAttribute("aria-describedby")?.trim());
1389
+ const hasPlaceholder = Boolean(this.input.getAttribute("placeholder")?.trim());
1390
+ const hasAriaPlaceholder = Boolean(this.input.getAttribute("aria-placeholder")?.trim());
1391
+ if (!hasDescribedby && !hasPlaceholder && !hasAriaPlaceholder && !this.options.disabled) {
1392
+ warnings.push(
1393
+ "Indication du format attendu manquante : d\xE9finissez aria-describedby, placeholder ou aria-placeholder pour informer les technologies d'assistance (WCAG 3.3.2)."
1394
+ );
1395
+ }
1396
+ return warnings;
1295
1397
  }
1296
1398
  extractRawSnippet(snippet) {
1297
1399
  return this.engine.extractRaw(snippet);
@@ -2141,6 +2243,7 @@ var Wulf = (() => {
2141
2243
  isValid: true
2142
2244
  });
2143
2245
  }
2246
+ this.runAuditWarning(this.options.audit);
2144
2247
  }
2145
2248
  extractRawSnippet(snippet) {
2146
2249
  const p = this.engine.parse(snippet);
@@ -2723,6 +2826,7 @@ var Wulf = (() => {
2723
2826
  if (!this.options.disabled) {
2724
2827
  this.updateSuggestion();
2725
2828
  }
2829
+ this.runAuditWarning(this.options.audit);
2726
2830
  }
2727
2831
  onNativeValueSet(_strVal) {
2728
2832
  if (this.options.disabled) return;
@@ -2981,5 +3085,5 @@ var Wulf = (() => {
2981
3085
  var index_default = InputMask;
2982
3086
  return __toCommonJS(index_exports);
2983
3087
  })();
2984
- if (typeof window !== "undefined") { window.Wulf = window.Wulf || {}; if (typeof Wulf !== "undefined" && Wulf) { var targets = ["Mask", "Scroll", "Masonry", "Toast"]; for (var i = 0; i < targets.length; i++) { var t = targets[i]; if (Wulf[t] && window.Wulf[t] !== Wulf[t]) { try { Object.defineProperty(window.Wulf, t, { value: Wulf[t], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[t] = Wulf[t]; } catch (__) {} } } } for (var k in Wulf) { if (window.Wulf[k] === undefined) { try { Object.defineProperty(window.Wulf, k, { value: Wulf[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[k] = Wulf[k]; } catch (__) {} } } } } }
3088
+ if (typeof window !== "undefined") { window.Wulf = window.Wulf || {}; if (typeof Wulf !== "undefined" && Wulf) { var targets = ["Mask", "Scroll", "Masonry", "Toast", "FocusTrap", "Shortcut"]; for (var i = 0; i < targets.length; i++) { var t = targets[i]; if (Wulf[t] && window.Wulf[t] !== Wulf[t]) { try { Object.defineProperty(window.Wulf, t, { value: Wulf[t], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[t] = Wulf[t]; } catch (__) {} } } } for (var k in Wulf) { if (window.Wulf[k] === undefined) { try { Object.defineProperty(window.Wulf, k, { value: Wulf[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[k] = Wulf[k]; } catch (__) {} } } } } }
2985
3089
  //# sourceMappingURL=mask.global.js.map