wulf.js 2.0.1 → 2.1.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.
Files changed (75) hide show
  1. package/README.md +240 -4
  2. package/changelog.md +37 -0
  3. package/dist/focus-trap.esm.js +110 -37
  4. package/dist/focus-trap.esm.js.map +2 -2
  5. package/dist/focus-trap.global.js +110 -37
  6. package/dist/focus-trap.global.js.map +2 -2
  7. package/dist/focus-trap.global.min.js +2 -2
  8. package/dist/focus-trap.global.min.js.map +3 -3
  9. package/dist/index.esm.js +3370 -337
  10. package/dist/index.esm.js.map +4 -4
  11. package/dist/index.global.js +3370 -337
  12. package/dist/index.global.js.map +4 -4
  13. package/dist/index.global.min.js +2 -2
  14. package/dist/index.global.min.js.map +4 -4
  15. package/dist/mask.css +1 -1
  16. package/dist/mask.css.map +2 -2
  17. package/dist/mask.esm.js +2826 -171
  18. package/dist/mask.esm.js.map +4 -4
  19. package/dist/mask.global.js +2816 -161
  20. package/dist/mask.global.js.map +4 -4
  21. package/dist/mask.global.min.js +2 -2
  22. package/dist/mask.global.min.js.map +4 -4
  23. package/dist/mask.layered.css +1 -1
  24. package/dist/mask.layered.css.map +2 -2
  25. package/dist/masonry.esm.js +175 -69
  26. package/dist/masonry.esm.js.map +2 -2
  27. package/dist/masonry.global.js +175 -69
  28. package/dist/masonry.global.js.map +2 -2
  29. package/dist/masonry.global.min.js +3 -3
  30. package/dist/masonry.global.min.js.map +3 -3
  31. package/dist/scroll.css +1 -1
  32. package/dist/scroll.css.map +2 -2
  33. package/dist/scroll.esm.js +132 -40
  34. package/dist/scroll.esm.js.map +2 -2
  35. package/dist/scroll.global.js +132 -40
  36. package/dist/scroll.global.js.map +2 -2
  37. package/dist/scroll.global.min.js +2 -2
  38. package/dist/scroll.global.min.js.map +3 -3
  39. package/dist/scroll.layered.css +1 -1
  40. package/dist/scroll.layered.css.map +2 -2
  41. package/dist/shortcut.esm.js +182 -22
  42. package/dist/shortcut.esm.js.map +3 -3
  43. package/dist/shortcut.global.js +182 -22
  44. package/dist/shortcut.global.js.map +3 -3
  45. package/dist/shortcut.global.min.js +4 -1
  46. package/dist/shortcut.global.min.js.map +4 -4
  47. package/dist/toast.css +1 -1
  48. package/dist/toast.css.map +2 -2
  49. package/dist/toast.esm.js +116 -19
  50. package/dist/toast.esm.js.map +2 -2
  51. package/dist/toast.global.js +116 -19
  52. package/dist/toast.global.js.map +2 -2
  53. package/dist/toast.global.min.js +3 -3
  54. package/dist/toast.global.min.js.map +3 -3
  55. package/dist/toast.layered.css +1 -1
  56. package/dist/toast.layered.css.map +2 -2
  57. package/dist/types/common/AuditableComponent.d.ts +3 -3
  58. package/dist/types/common/dom.d.ts +5 -0
  59. package/dist/types/focus-trap/FocusTrap.d.ts +5 -2
  60. package/dist/types/mask/AmountEngine.d.ts +8 -0
  61. package/dist/types/mask/BaseInputMask.d.ts +18 -0
  62. package/dist/types/mask/DateUTCEngine.d.ts +187 -0
  63. package/dist/types/mask/InputAmountMask.d.ts +5 -0
  64. package/dist/types/mask/InputDateUTCMask.d.ts +110 -0
  65. package/dist/types/mask/InputEmailMask.d.ts +7 -0
  66. package/dist/types/mask/InputMask.d.ts +7 -5
  67. package/dist/types/mask/MaskEngine.d.ts +39 -7
  68. package/dist/types/mask/index.d.ts +12 -6
  69. package/dist/types/mask/paste.d.ts +15 -0
  70. package/dist/types/mask/types.d.ts +27 -2
  71. package/dist/types/masonry/Masonry.d.ts +2 -0
  72. package/dist/types/scroll/ScrollBlock.d.ts +2 -0
  73. package/dist/types/shortcut/ShortcutManager.d.ts +14 -3
  74. package/dist/types/toast/ToastManager.d.ts +2 -0
  75. package/package.json +1 -1
@@ -50,24 +50,39 @@ var AuditableComponent = class {
50
50
  return warnings;
51
51
  }
52
52
  /**
53
- * Vérifie si un attribut de référence d'IDs ARIA (ex: aria-labelledby, aria-describedby)
54
- * pointe vers des éléments réellement présents dans le document.
53
+ * Vérifie si un attribut de référence d'IDs ARIA (ex: aria-labelledby, aria-describedby, aria-errormessage)
54
+ * pointe vers des éléments réellement présents dans le document (et optionnellement non vides).
55
55
  */
56
- checkAriaIdReferences(element, attrName, warnings) {
56
+ checkAriaIdReferences(element, attrName, warnings, requireNonEmptyText = false) {
57
57
  const rawValue = element.getAttribute(attrName)?.trim();
58
58
  if (!rawValue) return false;
59
59
  const doc = element.ownerDocument || document;
60
60
  const root = typeof element.getRootNode === "function" ? element.getRootNode() : doc;
61
61
  const ids = rawValue.split(/\s+/).filter(Boolean);
62
- const isValid = ids.length > 0 && ids.every(
63
- (id) => Boolean(typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.getElementById(id) : doc.getElementById(id))
62
+ const targets = ids.map(
63
+ (id) => typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.getElementById(id) : doc.getElementById(id)
64
64
  );
65
- if (!isValid) {
65
+ const allFound = ids.length > 0 && targets.every((el) => Boolean(el));
66
+ if (!allFound) {
66
67
  warnings.push(
67
68
  `Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`
68
69
  );
70
+ return false;
69
71
  }
70
- return isValid;
72
+ if (requireNonEmptyText) {
73
+ const hasNonEmptyText = targets.some((el) => {
74
+ if (!el) return false;
75
+ const text = el.textContent?.trim() || el.getAttribute("aria-label")?.trim() || "";
76
+ return text.length > 0;
77
+ });
78
+ if (!hasNonEmptyText) {
79
+ warnings.push(
80
+ `Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible ne contient aucun texte accessible.`
81
+ );
82
+ return false;
83
+ }
84
+ }
85
+ return true;
71
86
  }
72
87
  };
73
88
 
@@ -301,6 +316,8 @@ var ScrollBlock = class extends LocalizedComponent {
301
316
  trackX;
302
317
  thumbX;
303
318
  resizeObserver;
319
+ mutationObserver;
320
+ observedChildren = /* @__PURE__ */ new Set();
304
321
  hideTimer;
305
322
  scrollEndFallbackTimer;
306
323
  rafId = null;
@@ -352,7 +369,7 @@ var ScrollBlock = class extends LocalizedComponent {
352
369
  this.root = resolvedElement;
353
370
  this.hasExplicitAriaLabel = Boolean(options?.ariaLabel || options?.i18n?.viewport);
354
371
  const rawDelay = options?.autoHideDelay;
355
- const safeAutoHideDelay = typeof rawDelay === "number" && Number.isFinite(rawDelay) && rawDelay >= 0 ? rawDelay : 1e3;
372
+ const safeAutoHideDelay = typeof rawDelay === "number" && Number.isFinite(rawDelay) && rawDelay >= 0 ? Math.min(rawDelay, 2147483647) : 1e3;
356
373
  const rawMinThumb = options?.minThumbSize;
357
374
  const safeMinThumbSize = typeof rawMinThumb === "number" && Number.isFinite(rawMinThumb) && rawMinThumb > 0 ? rawMinThumb : 24;
358
375
  const rawEdge = options?.edgeThreshold;
@@ -649,22 +666,28 @@ var ScrollBlock = class extends LocalizedComponent {
649
666
  * Initialise le ResizeObserver réactif.
650
667
  */
651
668
  setupObserver() {
652
- if (typeof ResizeObserver !== "undefined") {
653
- this.resizeObserver = new ResizeObserver(() => {
654
- if (this.isDestroyed || this.resizeRafId !== null) return;
655
- this.resizeRafId = window.requestAnimationFrame(() => {
656
- this.resizeRafId = null;
657
- if (!this.isDestroyed) {
658
- this.update();
659
- }
660
- });
669
+ const scheduleUpdate = () => {
670
+ if (this.isDestroyed || this.resizeRafId !== null) return;
671
+ this.resizeRafId = window.requestAnimationFrame(() => {
672
+ this.resizeRafId = null;
673
+ if (!this.isDestroyed) {
674
+ this.update();
675
+ }
661
676
  });
677
+ };
678
+ if (typeof ResizeObserver !== "undefined") {
679
+ this.resizeObserver = new ResizeObserver(scheduleUpdate);
662
680
  this.resizeObserver.observe(this.root);
663
681
  this.resizeObserver.observe(this.viewport);
664
- if (this.viewport.firstElementChild) {
665
- this.resizeObserver.observe(this.viewport.firstElementChild);
682
+ for (const child of Array.from(this.viewport.children)) {
683
+ this.resizeObserver.observe(child);
684
+ this.observedChildren.add(child);
666
685
  }
667
686
  }
687
+ if (typeof MutationObserver !== "undefined") {
688
+ this.mutationObserver = new MutationObserver(scheduleUpdate);
689
+ this.mutationObserver.observe(this.viewport, { childList: true });
690
+ }
668
691
  }
669
692
  /**
670
693
  * Déplacement lors du glissement du curseur.
@@ -740,16 +763,28 @@ var ScrollBlock = class extends LocalizedComponent {
740
763
  this.scheduleSyncThumbs();
741
764
  const info = this.getScrollInfo();
742
765
  const { top: scrollTop, left: scrollLeft, maxTop, maxLeft } = info;
743
- this.options.onScroll(info);
766
+ try {
767
+ this.options.onScroll(info);
768
+ } catch (err) {
769
+ console.error("[Wulf.Scroll] Erreur dans onScroll:", err);
770
+ }
744
771
  const threshold = this.options.edgeThreshold;
745
772
  if (maxTop > 0) {
746
773
  const nowBottom = scrollTop >= maxTop - threshold;
747
774
  const nowTop = scrollTop <= threshold;
748
775
  if (nowBottom && !this.atBottom) {
749
- this.options.onTotalScroll("bottom");
776
+ try {
777
+ this.options.onTotalScroll("bottom");
778
+ } catch (err) {
779
+ console.error("[Wulf.Scroll] Erreur dans onTotalScroll:", err);
780
+ }
750
781
  }
751
782
  if (nowTop && !this.atTop) {
752
- this.options.onTotalScrollBack("top");
783
+ try {
784
+ this.options.onTotalScrollBack("top");
785
+ } catch (err) {
786
+ console.error("[Wulf.Scroll] Erreur dans onTotalScrollBack:", err);
787
+ }
753
788
  }
754
789
  this.atBottom = nowBottom;
755
790
  this.atTop = nowTop;
@@ -759,10 +794,18 @@ var ScrollBlock = class extends LocalizedComponent {
759
794
  const nowRight = rtl ? scrollLeft >= -threshold : scrollLeft >= maxLeft - threshold;
760
795
  const nowLeft = rtl ? scrollLeft <= -maxLeft + threshold : scrollLeft <= threshold;
761
796
  if (nowRight && !this.atRight) {
762
- this.options.onTotalScroll("right");
797
+ try {
798
+ this.options.onTotalScroll("right");
799
+ } catch (err) {
800
+ console.error("[Wulf.Scroll] Erreur dans onTotalScroll:", err);
801
+ }
763
802
  }
764
803
  if (nowLeft && !this.atLeft) {
765
- this.options.onTotalScrollBack("left");
804
+ try {
805
+ this.options.onTotalScrollBack("left");
806
+ } catch (err) {
807
+ console.error("[Wulf.Scroll] Erreur dans onTotalScrollBack:", err);
808
+ }
766
809
  }
767
810
  this.atRight = nowRight;
768
811
  this.atLeft = nowLeft;
@@ -788,7 +831,11 @@ var ScrollBlock = class extends LocalizedComponent {
788
831
  * Gestionnaire de fin de défilement (`scrollend` natif ou repli temporisé).
789
832
  */
790
833
  handleScrollEnd() {
791
- this.options.onScrollEnd(this.getScrollInfo());
834
+ try {
835
+ this.options.onScrollEnd(this.getScrollInfo());
836
+ } catch (err) {
837
+ console.error("[Wulf.Scroll] Erreur dans onScrollEnd:", err);
838
+ }
792
839
  if (this.options.mode !== "native" && this.options.autoHide && !this.options.alwaysVisible) {
793
840
  this.scheduleAutoHide();
794
841
  }
@@ -815,24 +862,34 @@ var ScrollBlock = class extends LocalizedComponent {
815
862
  if (this.thumbY && this.trackY) {
816
863
  const maxScrollY = this.cachedMaxTop;
817
864
  const maxTravelY = this.cachedTrackHeight - this.cachedThumbHeight;
818
- if (maxScrollY > 0 && maxTravelY > 0) {
865
+ if (maxScrollY > 0) {
819
866
  const ratioY = Math.max(0, Math.min(1, scrollTop / maxScrollY));
820
- const posY = Math.max(0, Math.min(maxTravelY, ratioY * maxTravelY));
821
- this.thumbY.style.setProperty("--scrollblock-thumb-y", `${posY}px`);
822
867
  this.thumbY.setAttribute("aria-valuenow", String(Math.round(ratioY * 100)));
868
+ if (maxTravelY > 0) {
869
+ const posY = Math.max(0, Math.min(maxTravelY, ratioY * maxTravelY));
870
+ this.thumbY.style.setProperty("--scrollblock-thumb-y", `${posY}px`);
871
+ }
872
+ } else {
873
+ this.thumbY.setAttribute("aria-valuenow", "0");
874
+ this.thumbY.style.setProperty("--scrollblock-thumb-y", "0px");
823
875
  }
824
876
  }
825
877
  if (this.thumbX && this.trackX) {
826
878
  const maxScrollX = this.cachedMaxLeft;
827
879
  const maxTravelX = this.cachedTrackWidth - this.cachedThumbWidth;
828
- if (maxScrollX > 0 && maxTravelX > 0) {
880
+ if (maxScrollX > 0) {
829
881
  const rtl = this.isRtl();
830
882
  const logicalLeft = rtl ? Math.max(0, -scrollLeft) : Math.max(0, scrollLeft);
831
883
  const ratioX = Math.max(0, Math.min(1, logicalLeft / maxScrollX));
832
- const posX = Math.max(0, Math.min(maxTravelX, ratioX * maxTravelX));
833
- const signedPosX = rtl ? -posX : posX;
834
- this.thumbX.style.setProperty("--scrollblock-thumb-x", `${signedPosX}px`);
835
884
  this.thumbX.setAttribute("aria-valuenow", String(Math.round(ratioX * 100)));
885
+ if (maxTravelX > 0) {
886
+ const posX = Math.max(0, Math.min(maxTravelX, ratioX * maxTravelX));
887
+ const signedPosX = rtl ? -posX : posX;
888
+ this.thumbX.style.setProperty("--scrollblock-thumb-x", `${signedPosX}px`);
889
+ }
890
+ } else {
891
+ this.thumbX.setAttribute("aria-valuenow", "0");
892
+ this.thumbX.style.setProperty("--scrollblock-thumb-x", "0px");
836
893
  }
837
894
  }
838
895
  }
@@ -870,6 +927,21 @@ var ScrollBlock = class extends LocalizedComponent {
870
927
  update() {
871
928
  if (this.isDestroyed) return;
872
929
  this.syncAccessibilityLabels();
930
+ if (this.resizeObserver) {
931
+ const currentChildren = new Set(Array.from(this.viewport.children));
932
+ for (const prev of this.observedChildren) {
933
+ if (!currentChildren.has(prev)) {
934
+ this.resizeObserver.unobserve(prev);
935
+ this.observedChildren.delete(prev);
936
+ }
937
+ }
938
+ for (const child of currentChildren) {
939
+ if (!this.observedChildren.has(child)) {
940
+ this.resizeObserver.observe(child);
941
+ this.observedChildren.add(child);
942
+ }
943
+ }
944
+ }
873
945
  const { scrollHeight, clientHeight, scrollWidth, clientWidth } = this.viewport;
874
946
  const trackHeight = this.trackY ? this.trackY.clientHeight : 0;
875
947
  const trackWidth = this.trackX ? this.trackX.clientWidth : 0;
@@ -981,17 +1053,19 @@ var ScrollBlock = class extends LocalizedComponent {
981
1053
  if (el) {
982
1054
  const vpRect = this.viewport.getBoundingClientRect();
983
1055
  const elRect = el.getBoundingClientRect();
984
- targetTop = elRect.top - vpRect.top + scrollTop;
985
- targetLeft = elRect.left - vpRect.left + scrollLeft;
1056
+ targetTop = elRect.top - vpRect.top - this.viewport.clientTop + scrollTop;
1057
+ targetLeft = elRect.left - vpRect.left - this.viewport.clientLeft + scrollLeft;
986
1058
  }
987
1059
  break;
988
1060
  }
989
1061
  }
990
1062
  } else if (target instanceof HTMLElement) {
991
- const vpRect = this.viewport.getBoundingClientRect();
992
- const elRect = target.getBoundingClientRect();
993
- targetTop = elRect.top - vpRect.top + scrollTop;
994
- targetLeft = elRect.left - vpRect.left + scrollLeft;
1063
+ if (target.isConnected && this.viewport.contains(target)) {
1064
+ const vpRect = this.viewport.getBoundingClientRect();
1065
+ const elRect = target.getBoundingClientRect();
1066
+ targetTop = elRect.top - vpRect.top - this.viewport.clientTop + scrollTop;
1067
+ targetLeft = elRect.left - vpRect.left - this.viewport.clientLeft + scrollLeft;
1068
+ }
995
1069
  } else if (typeof target === "object" && target !== null) {
996
1070
  targetTop = target.top;
997
1071
  targetLeft = target.left;
@@ -1062,8 +1136,8 @@ var ScrollBlock = class extends LocalizedComponent {
1062
1136
  */
1063
1137
  audit() {
1064
1138
  const warnings = [];
1065
- const hasViewportLabelledby = this.checkAriaIdReferences(this.viewport, "aria-labelledby", warnings);
1066
- const hasRootLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings);
1139
+ const hasViewportLabelledby = this.checkAriaIdReferences(this.viewport, "aria-labelledby", warnings, true);
1140
+ const hasRootLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings, true);
1067
1141
  const hasValidLabelledby = hasViewportLabelledby || hasRootLabelledby;
1068
1142
  const rootAriaLabel = this.root.getAttribute("aria-label")?.trim();
1069
1143
  const hasCustomViewportAriaLabel = !this.wasAriaLabelInferred && Boolean(this.viewport.getAttribute("aria-label")?.trim());
@@ -1077,6 +1151,16 @@ var ScrollBlock = class extends LocalizedComponent {
1077
1151
  `Taille minimale du curseur insuffisante (minThumbSize: ${this.options.minThumbSize}px) : utilisez au moins 24px pour respecter WCAG 2.5.8.`
1078
1152
  );
1079
1153
  }
1154
+ if (this.root.tabIndex > 0 || this.viewport.tabIndex > 0) {
1155
+ warnings.push(
1156
+ 'Attribut tabindex > 0 d\xE9tect\xE9 sur la zone d\xE9filable : utilisez uniquement tabindex="0" ou "-1" (WCAG 2.4.3).'
1157
+ );
1158
+ }
1159
+ if (this.root.getAttribute("role") === "region" && this.viewport.getAttribute("role") === "region") {
1160
+ warnings.push(
1161
+ 'Landmark role="region" redondant : \xE9vitez de d\xE9clarer role="region" \xE0 la fois sur le conteneur racine et sur le viewport interne.'
1162
+ );
1163
+ }
1080
1164
  return warnings;
1081
1165
  }
1082
1166
  getAuditPrefix() {
@@ -1090,6 +1174,9 @@ var ScrollBlock = class extends LocalizedComponent {
1090
1174
  */
1091
1175
  destroy() {
1092
1176
  if (this.isDestroyed) return;
1177
+ if (this.isDragging) {
1178
+ this.handlePointerUp();
1179
+ }
1093
1180
  this.isDestroyed = true;
1094
1181
  this.clearAutoHideTimer();
1095
1182
  if (this.scrollEndFallbackTimer !== void 0) {
@@ -1112,6 +1199,11 @@ var ScrollBlock = class extends LocalizedComponent {
1112
1199
  if (this.resizeObserver) {
1113
1200
  this.resizeObserver.disconnect();
1114
1201
  }
1202
+ if (this.mutationObserver) {
1203
+ this.mutationObserver.disconnect();
1204
+ this.mutationObserver = void 0;
1205
+ }
1206
+ this.observedChildren.clear();
1115
1207
  this.trackY?.remove();
1116
1208
  this.trackX?.remove();
1117
1209
  this.root.classList.remove(