wulf.js 2.1.0 → 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 (59) hide show
  1. package/changelog.md +10 -0
  2. package/dist/focus-trap.esm.js +88 -30
  3. package/dist/focus-trap.esm.js.map +2 -2
  4. package/dist/focus-trap.global.js +88 -30
  5. package/dist/focus-trap.global.js.map +2 -2
  6. package/dist/focus-trap.global.min.js +2 -2
  7. package/dist/focus-trap.global.min.js.map +3 -3
  8. package/dist/index.esm.js +541 -162
  9. package/dist/index.esm.js.map +2 -2
  10. package/dist/index.global.js +541 -162
  11. package/dist/index.global.js.map +2 -2
  12. package/dist/index.global.min.js +2 -2
  13. package/dist/index.global.min.js.map +3 -3
  14. package/dist/mask.esm.js +4 -4
  15. package/dist/mask.esm.js.map +2 -2
  16. package/dist/mask.global.js +4 -4
  17. package/dist/mask.global.js.map +2 -2
  18. package/dist/mask.global.min.js +2 -2
  19. package/dist/mask.global.min.js.map +3 -3
  20. package/dist/masonry.esm.js +153 -62
  21. package/dist/masonry.esm.js.map +2 -2
  22. package/dist/masonry.global.js +153 -62
  23. package/dist/masonry.global.js.map +2 -2
  24. package/dist/masonry.global.min.js +3 -3
  25. package/dist/masonry.global.min.js.map +3 -3
  26. package/dist/scroll.css +1 -1
  27. package/dist/scroll.css.map +2 -2
  28. package/dist/scroll.esm.js +108 -31
  29. package/dist/scroll.esm.js.map +2 -2
  30. package/dist/scroll.global.js +108 -31
  31. package/dist/scroll.global.js.map +2 -2
  32. package/dist/scroll.global.min.js +2 -2
  33. package/dist/scroll.global.min.js.map +3 -3
  34. package/dist/scroll.layered.css +1 -1
  35. package/dist/scroll.layered.css.map +2 -2
  36. package/dist/shortcut.esm.js +182 -22
  37. package/dist/shortcut.esm.js.map +3 -3
  38. package/dist/shortcut.global.js +182 -22
  39. package/dist/shortcut.global.js.map +3 -3
  40. package/dist/shortcut.global.min.js +4 -1
  41. package/dist/shortcut.global.min.js.map +4 -4
  42. package/dist/toast.css +1 -1
  43. package/dist/toast.css.map +2 -2
  44. package/dist/toast.esm.js +92 -13
  45. package/dist/toast.esm.js.map +2 -2
  46. package/dist/toast.global.js +92 -13
  47. package/dist/toast.global.js.map +2 -2
  48. package/dist/toast.global.min.js +3 -3
  49. package/dist/toast.global.min.js.map +3 -3
  50. package/dist/toast.layered.css +1 -1
  51. package/dist/toast.layered.css.map +2 -2
  52. package/dist/types/common/dom.d.ts +5 -0
  53. package/dist/types/focus-trap/FocusTrap.d.ts +5 -2
  54. package/dist/types/mask/paste.d.ts +2 -5
  55. package/dist/types/masonry/Masonry.d.ts +2 -0
  56. package/dist/types/scroll/ScrollBlock.d.ts +2 -0
  57. package/dist/types/shortcut/ShortcutManager.d.ts +14 -3
  58. package/dist/types/toast/ToastManager.d.ts +2 -0
  59. package/package.json +1 -1
@@ -316,6 +316,8 @@ var ScrollBlock = class extends LocalizedComponent {
316
316
  trackX;
317
317
  thumbX;
318
318
  resizeObserver;
319
+ mutationObserver;
320
+ observedChildren = /* @__PURE__ */ new Set();
319
321
  hideTimer;
320
322
  scrollEndFallbackTimer;
321
323
  rafId = null;
@@ -367,7 +369,7 @@ var ScrollBlock = class extends LocalizedComponent {
367
369
  this.root = resolvedElement;
368
370
  this.hasExplicitAriaLabel = Boolean(options?.ariaLabel || options?.i18n?.viewport);
369
371
  const rawDelay = options?.autoHideDelay;
370
- 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;
371
373
  const rawMinThumb = options?.minThumbSize;
372
374
  const safeMinThumbSize = typeof rawMinThumb === "number" && Number.isFinite(rawMinThumb) && rawMinThumb > 0 ? rawMinThumb : 24;
373
375
  const rawEdge = options?.edgeThreshold;
@@ -664,22 +666,28 @@ var ScrollBlock = class extends LocalizedComponent {
664
666
  * Initialise le ResizeObserver réactif.
665
667
  */
666
668
  setupObserver() {
667
- if (typeof ResizeObserver !== "undefined") {
668
- this.resizeObserver = new ResizeObserver(() => {
669
- if (this.isDestroyed || this.resizeRafId !== null) return;
670
- this.resizeRafId = window.requestAnimationFrame(() => {
671
- this.resizeRafId = null;
672
- if (!this.isDestroyed) {
673
- this.update();
674
- }
675
- });
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
+ }
676
676
  });
677
+ };
678
+ if (typeof ResizeObserver !== "undefined") {
679
+ this.resizeObserver = new ResizeObserver(scheduleUpdate);
677
680
  this.resizeObserver.observe(this.root);
678
681
  this.resizeObserver.observe(this.viewport);
679
- if (this.viewport.firstElementChild) {
680
- 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);
681
685
  }
682
686
  }
687
+ if (typeof MutationObserver !== "undefined") {
688
+ this.mutationObserver = new MutationObserver(scheduleUpdate);
689
+ this.mutationObserver.observe(this.viewport, { childList: true });
690
+ }
683
691
  }
684
692
  /**
685
693
  * Déplacement lors du glissement du curseur.
@@ -755,16 +763,28 @@ var ScrollBlock = class extends LocalizedComponent {
755
763
  this.scheduleSyncThumbs();
756
764
  const info = this.getScrollInfo();
757
765
  const { top: scrollTop, left: scrollLeft, maxTop, maxLeft } = info;
758
- this.options.onScroll(info);
766
+ try {
767
+ this.options.onScroll(info);
768
+ } catch (err) {
769
+ console.error("[Wulf.Scroll] Erreur dans onScroll:", err);
770
+ }
759
771
  const threshold = this.options.edgeThreshold;
760
772
  if (maxTop > 0) {
761
773
  const nowBottom = scrollTop >= maxTop - threshold;
762
774
  const nowTop = scrollTop <= threshold;
763
775
  if (nowBottom && !this.atBottom) {
764
- this.options.onTotalScroll("bottom");
776
+ try {
777
+ this.options.onTotalScroll("bottom");
778
+ } catch (err) {
779
+ console.error("[Wulf.Scroll] Erreur dans onTotalScroll:", err);
780
+ }
765
781
  }
766
782
  if (nowTop && !this.atTop) {
767
- this.options.onTotalScrollBack("top");
783
+ try {
784
+ this.options.onTotalScrollBack("top");
785
+ } catch (err) {
786
+ console.error("[Wulf.Scroll] Erreur dans onTotalScrollBack:", err);
787
+ }
768
788
  }
769
789
  this.atBottom = nowBottom;
770
790
  this.atTop = nowTop;
@@ -774,10 +794,18 @@ var ScrollBlock = class extends LocalizedComponent {
774
794
  const nowRight = rtl ? scrollLeft >= -threshold : scrollLeft >= maxLeft - threshold;
775
795
  const nowLeft = rtl ? scrollLeft <= -maxLeft + threshold : scrollLeft <= threshold;
776
796
  if (nowRight && !this.atRight) {
777
- this.options.onTotalScroll("right");
797
+ try {
798
+ this.options.onTotalScroll("right");
799
+ } catch (err) {
800
+ console.error("[Wulf.Scroll] Erreur dans onTotalScroll:", err);
801
+ }
778
802
  }
779
803
  if (nowLeft && !this.atLeft) {
780
- this.options.onTotalScrollBack("left");
804
+ try {
805
+ this.options.onTotalScrollBack("left");
806
+ } catch (err) {
807
+ console.error("[Wulf.Scroll] Erreur dans onTotalScrollBack:", err);
808
+ }
781
809
  }
782
810
  this.atRight = nowRight;
783
811
  this.atLeft = nowLeft;
@@ -803,7 +831,11 @@ var ScrollBlock = class extends LocalizedComponent {
803
831
  * Gestionnaire de fin de défilement (`scrollend` natif ou repli temporisé).
804
832
  */
805
833
  handleScrollEnd() {
806
- 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
+ }
807
839
  if (this.options.mode !== "native" && this.options.autoHide && !this.options.alwaysVisible) {
808
840
  this.scheduleAutoHide();
809
841
  }
@@ -830,24 +862,34 @@ var ScrollBlock = class extends LocalizedComponent {
830
862
  if (this.thumbY && this.trackY) {
831
863
  const maxScrollY = this.cachedMaxTop;
832
864
  const maxTravelY = this.cachedTrackHeight - this.cachedThumbHeight;
833
- if (maxScrollY > 0 && maxTravelY > 0) {
865
+ if (maxScrollY > 0) {
834
866
  const ratioY = Math.max(0, Math.min(1, scrollTop / maxScrollY));
835
- const posY = Math.max(0, Math.min(maxTravelY, ratioY * maxTravelY));
836
- this.thumbY.style.setProperty("--scrollblock-thumb-y", `${posY}px`);
837
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");
838
875
  }
839
876
  }
840
877
  if (this.thumbX && this.trackX) {
841
878
  const maxScrollX = this.cachedMaxLeft;
842
879
  const maxTravelX = this.cachedTrackWidth - this.cachedThumbWidth;
843
- if (maxScrollX > 0 && maxTravelX > 0) {
880
+ if (maxScrollX > 0) {
844
881
  const rtl = this.isRtl();
845
882
  const logicalLeft = rtl ? Math.max(0, -scrollLeft) : Math.max(0, scrollLeft);
846
883
  const ratioX = Math.max(0, Math.min(1, logicalLeft / maxScrollX));
847
- const posX = Math.max(0, Math.min(maxTravelX, ratioX * maxTravelX));
848
- const signedPosX = rtl ? -posX : posX;
849
- this.thumbX.style.setProperty("--scrollblock-thumb-x", `${signedPosX}px`);
850
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");
851
893
  }
852
894
  }
853
895
  }
@@ -885,6 +927,21 @@ var ScrollBlock = class extends LocalizedComponent {
885
927
  update() {
886
928
  if (this.isDestroyed) return;
887
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
+ }
888
945
  const { scrollHeight, clientHeight, scrollWidth, clientWidth } = this.viewport;
889
946
  const trackHeight = this.trackY ? this.trackY.clientHeight : 0;
890
947
  const trackWidth = this.trackX ? this.trackX.clientWidth : 0;
@@ -1003,10 +1060,12 @@ var ScrollBlock = class extends LocalizedComponent {
1003
1060
  }
1004
1061
  }
1005
1062
  } else if (target instanceof HTMLElement) {
1006
- const vpRect = this.viewport.getBoundingClientRect();
1007
- const elRect = target.getBoundingClientRect();
1008
- targetTop = elRect.top - vpRect.top - this.viewport.clientTop + scrollTop;
1009
- targetLeft = elRect.left - vpRect.left - this.viewport.clientLeft + 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
+ }
1010
1069
  } else if (typeof target === "object" && target !== null) {
1011
1070
  targetTop = target.top;
1012
1071
  targetLeft = target.left;
@@ -1077,8 +1136,8 @@ var ScrollBlock = class extends LocalizedComponent {
1077
1136
  */
1078
1137
  audit() {
1079
1138
  const warnings = [];
1080
- const hasViewportLabelledby = this.checkAriaIdReferences(this.viewport, "aria-labelledby", warnings);
1081
- 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);
1082
1141
  const hasValidLabelledby = hasViewportLabelledby || hasRootLabelledby;
1083
1142
  const rootAriaLabel = this.root.getAttribute("aria-label")?.trim();
1084
1143
  const hasCustomViewportAriaLabel = !this.wasAriaLabelInferred && Boolean(this.viewport.getAttribute("aria-label")?.trim());
@@ -1092,6 +1151,16 @@ var ScrollBlock = class extends LocalizedComponent {
1092
1151
  `Taille minimale du curseur insuffisante (minThumbSize: ${this.options.minThumbSize}px) : utilisez au moins 24px pour respecter WCAG 2.5.8.`
1093
1152
  );
1094
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
+ }
1095
1164
  return warnings;
1096
1165
  }
1097
1166
  getAuditPrefix() {
@@ -1105,6 +1174,9 @@ var ScrollBlock = class extends LocalizedComponent {
1105
1174
  */
1106
1175
  destroy() {
1107
1176
  if (this.isDestroyed) return;
1177
+ if (this.isDragging) {
1178
+ this.handlePointerUp();
1179
+ }
1108
1180
  this.isDestroyed = true;
1109
1181
  this.clearAutoHideTimer();
1110
1182
  if (this.scrollEndFallbackTimer !== void 0) {
@@ -1127,6 +1199,11 @@ var ScrollBlock = class extends LocalizedComponent {
1127
1199
  if (this.resizeObserver) {
1128
1200
  this.resizeObserver.disconnect();
1129
1201
  }
1202
+ if (this.mutationObserver) {
1203
+ this.mutationObserver.disconnect();
1204
+ this.mutationObserver = void 0;
1205
+ }
1206
+ this.observedChildren.clear();
1130
1207
  this.trackY?.remove();
1131
1208
  this.trackX?.remove();
1132
1209
  this.root.classList.remove(