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
@@ -349,6 +349,8 @@ var __WulfIIFE = (() => {
349
349
  trackX;
350
350
  thumbX;
351
351
  resizeObserver;
352
+ mutationObserver;
353
+ observedChildren = /* @__PURE__ */ new Set();
352
354
  hideTimer;
353
355
  scrollEndFallbackTimer;
354
356
  rafId = null;
@@ -400,7 +402,7 @@ var __WulfIIFE = (() => {
400
402
  this.root = resolvedElement;
401
403
  this.hasExplicitAriaLabel = Boolean(options?.ariaLabel || options?.i18n?.viewport);
402
404
  const rawDelay = options?.autoHideDelay;
403
- const safeAutoHideDelay = typeof rawDelay === "number" && Number.isFinite(rawDelay) && rawDelay >= 0 ? rawDelay : 1e3;
405
+ const safeAutoHideDelay = typeof rawDelay === "number" && Number.isFinite(rawDelay) && rawDelay >= 0 ? Math.min(rawDelay, 2147483647) : 1e3;
404
406
  const rawMinThumb = options?.minThumbSize;
405
407
  const safeMinThumbSize = typeof rawMinThumb === "number" && Number.isFinite(rawMinThumb) && rawMinThumb > 0 ? rawMinThumb : 24;
406
408
  const rawEdge = options?.edgeThreshold;
@@ -697,22 +699,28 @@ var __WulfIIFE = (() => {
697
699
  * Initialise le ResizeObserver réactif.
698
700
  */
699
701
  setupObserver() {
700
- if (typeof ResizeObserver !== "undefined") {
701
- this.resizeObserver = new ResizeObserver(() => {
702
- if (this.isDestroyed || this.resizeRafId !== null) return;
703
- this.resizeRafId = window.requestAnimationFrame(() => {
704
- this.resizeRafId = null;
705
- if (!this.isDestroyed) {
706
- this.update();
707
- }
708
- });
702
+ const scheduleUpdate = () => {
703
+ if (this.isDestroyed || this.resizeRafId !== null) return;
704
+ this.resizeRafId = window.requestAnimationFrame(() => {
705
+ this.resizeRafId = null;
706
+ if (!this.isDestroyed) {
707
+ this.update();
708
+ }
709
709
  });
710
+ };
711
+ if (typeof ResizeObserver !== "undefined") {
712
+ this.resizeObserver = new ResizeObserver(scheduleUpdate);
710
713
  this.resizeObserver.observe(this.root);
711
714
  this.resizeObserver.observe(this.viewport);
712
- if (this.viewport.firstElementChild) {
713
- this.resizeObserver.observe(this.viewport.firstElementChild);
715
+ for (const child of Array.from(this.viewport.children)) {
716
+ this.resizeObserver.observe(child);
717
+ this.observedChildren.add(child);
714
718
  }
715
719
  }
720
+ if (typeof MutationObserver !== "undefined") {
721
+ this.mutationObserver = new MutationObserver(scheduleUpdate);
722
+ this.mutationObserver.observe(this.viewport, { childList: true });
723
+ }
716
724
  }
717
725
  /**
718
726
  * Déplacement lors du glissement du curseur.
@@ -788,16 +796,28 @@ var __WulfIIFE = (() => {
788
796
  this.scheduleSyncThumbs();
789
797
  const info = this.getScrollInfo();
790
798
  const { top: scrollTop, left: scrollLeft, maxTop, maxLeft } = info;
791
- this.options.onScroll(info);
799
+ try {
800
+ this.options.onScroll(info);
801
+ } catch (err) {
802
+ console.error("[Wulf.Scroll] Erreur dans onScroll:", err);
803
+ }
792
804
  const threshold = this.options.edgeThreshold;
793
805
  if (maxTop > 0) {
794
806
  const nowBottom = scrollTop >= maxTop - threshold;
795
807
  const nowTop = scrollTop <= threshold;
796
808
  if (nowBottom && !this.atBottom) {
797
- this.options.onTotalScroll("bottom");
809
+ try {
810
+ this.options.onTotalScroll("bottom");
811
+ } catch (err) {
812
+ console.error("[Wulf.Scroll] Erreur dans onTotalScroll:", err);
813
+ }
798
814
  }
799
815
  if (nowTop && !this.atTop) {
800
- this.options.onTotalScrollBack("top");
816
+ try {
817
+ this.options.onTotalScrollBack("top");
818
+ } catch (err) {
819
+ console.error("[Wulf.Scroll] Erreur dans onTotalScrollBack:", err);
820
+ }
801
821
  }
802
822
  this.atBottom = nowBottom;
803
823
  this.atTop = nowTop;
@@ -807,10 +827,18 @@ var __WulfIIFE = (() => {
807
827
  const nowRight = rtl ? scrollLeft >= -threshold : scrollLeft >= maxLeft - threshold;
808
828
  const nowLeft = rtl ? scrollLeft <= -maxLeft + threshold : scrollLeft <= threshold;
809
829
  if (nowRight && !this.atRight) {
810
- this.options.onTotalScroll("right");
830
+ try {
831
+ this.options.onTotalScroll("right");
832
+ } catch (err) {
833
+ console.error("[Wulf.Scroll] Erreur dans onTotalScroll:", err);
834
+ }
811
835
  }
812
836
  if (nowLeft && !this.atLeft) {
813
- this.options.onTotalScrollBack("left");
837
+ try {
838
+ this.options.onTotalScrollBack("left");
839
+ } catch (err) {
840
+ console.error("[Wulf.Scroll] Erreur dans onTotalScrollBack:", err);
841
+ }
814
842
  }
815
843
  this.atRight = nowRight;
816
844
  this.atLeft = nowLeft;
@@ -836,7 +864,11 @@ var __WulfIIFE = (() => {
836
864
  * Gestionnaire de fin de défilement (`scrollend` natif ou repli temporisé).
837
865
  */
838
866
  handleScrollEnd() {
839
- this.options.onScrollEnd(this.getScrollInfo());
867
+ try {
868
+ this.options.onScrollEnd(this.getScrollInfo());
869
+ } catch (err) {
870
+ console.error("[Wulf.Scroll] Erreur dans onScrollEnd:", err);
871
+ }
840
872
  if (this.options.mode !== "native" && this.options.autoHide && !this.options.alwaysVisible) {
841
873
  this.scheduleAutoHide();
842
874
  }
@@ -863,24 +895,34 @@ var __WulfIIFE = (() => {
863
895
  if (this.thumbY && this.trackY) {
864
896
  const maxScrollY = this.cachedMaxTop;
865
897
  const maxTravelY = this.cachedTrackHeight - this.cachedThumbHeight;
866
- if (maxScrollY > 0 && maxTravelY > 0) {
898
+ if (maxScrollY > 0) {
867
899
  const ratioY = Math.max(0, Math.min(1, scrollTop / maxScrollY));
868
- const posY = Math.max(0, Math.min(maxTravelY, ratioY * maxTravelY));
869
- this.thumbY.style.setProperty("--scrollblock-thumb-y", `${posY}px`);
870
900
  this.thumbY.setAttribute("aria-valuenow", String(Math.round(ratioY * 100)));
901
+ if (maxTravelY > 0) {
902
+ const posY = Math.max(0, Math.min(maxTravelY, ratioY * maxTravelY));
903
+ this.thumbY.style.setProperty("--scrollblock-thumb-y", `${posY}px`);
904
+ }
905
+ } else {
906
+ this.thumbY.setAttribute("aria-valuenow", "0");
907
+ this.thumbY.style.setProperty("--scrollblock-thumb-y", "0px");
871
908
  }
872
909
  }
873
910
  if (this.thumbX && this.trackX) {
874
911
  const maxScrollX = this.cachedMaxLeft;
875
912
  const maxTravelX = this.cachedTrackWidth - this.cachedThumbWidth;
876
- if (maxScrollX > 0 && maxTravelX > 0) {
913
+ if (maxScrollX > 0) {
877
914
  const rtl = this.isRtl();
878
915
  const logicalLeft = rtl ? Math.max(0, -scrollLeft) : Math.max(0, scrollLeft);
879
916
  const ratioX = Math.max(0, Math.min(1, logicalLeft / maxScrollX));
880
- const posX = Math.max(0, Math.min(maxTravelX, ratioX * maxTravelX));
881
- const signedPosX = rtl ? -posX : posX;
882
- this.thumbX.style.setProperty("--scrollblock-thumb-x", `${signedPosX}px`);
883
917
  this.thumbX.setAttribute("aria-valuenow", String(Math.round(ratioX * 100)));
918
+ if (maxTravelX > 0) {
919
+ const posX = Math.max(0, Math.min(maxTravelX, ratioX * maxTravelX));
920
+ const signedPosX = rtl ? -posX : posX;
921
+ this.thumbX.style.setProperty("--scrollblock-thumb-x", `${signedPosX}px`);
922
+ }
923
+ } else {
924
+ this.thumbX.setAttribute("aria-valuenow", "0");
925
+ this.thumbX.style.setProperty("--scrollblock-thumb-x", "0px");
884
926
  }
885
927
  }
886
928
  }
@@ -918,6 +960,21 @@ var __WulfIIFE = (() => {
918
960
  update() {
919
961
  if (this.isDestroyed) return;
920
962
  this.syncAccessibilityLabels();
963
+ if (this.resizeObserver) {
964
+ const currentChildren = new Set(Array.from(this.viewport.children));
965
+ for (const prev of this.observedChildren) {
966
+ if (!currentChildren.has(prev)) {
967
+ this.resizeObserver.unobserve(prev);
968
+ this.observedChildren.delete(prev);
969
+ }
970
+ }
971
+ for (const child of currentChildren) {
972
+ if (!this.observedChildren.has(child)) {
973
+ this.resizeObserver.observe(child);
974
+ this.observedChildren.add(child);
975
+ }
976
+ }
977
+ }
921
978
  const { scrollHeight, clientHeight, scrollWidth, clientWidth } = this.viewport;
922
979
  const trackHeight = this.trackY ? this.trackY.clientHeight : 0;
923
980
  const trackWidth = this.trackX ? this.trackX.clientWidth : 0;
@@ -1036,10 +1093,12 @@ var __WulfIIFE = (() => {
1036
1093
  }
1037
1094
  }
1038
1095
  } else if (target instanceof HTMLElement) {
1039
- const vpRect = this.viewport.getBoundingClientRect();
1040
- const elRect = target.getBoundingClientRect();
1041
- targetTop = elRect.top - vpRect.top - this.viewport.clientTop + scrollTop;
1042
- targetLeft = elRect.left - vpRect.left - this.viewport.clientLeft + scrollLeft;
1096
+ if (target.isConnected && this.viewport.contains(target)) {
1097
+ const vpRect = this.viewport.getBoundingClientRect();
1098
+ const elRect = target.getBoundingClientRect();
1099
+ targetTop = elRect.top - vpRect.top - this.viewport.clientTop + scrollTop;
1100
+ targetLeft = elRect.left - vpRect.left - this.viewport.clientLeft + scrollLeft;
1101
+ }
1043
1102
  } else if (typeof target === "object" && target !== null) {
1044
1103
  targetTop = target.top;
1045
1104
  targetLeft = target.left;
@@ -1110,8 +1169,8 @@ var __WulfIIFE = (() => {
1110
1169
  */
1111
1170
  audit() {
1112
1171
  const warnings = [];
1113
- const hasViewportLabelledby = this.checkAriaIdReferences(this.viewport, "aria-labelledby", warnings);
1114
- const hasRootLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings);
1172
+ const hasViewportLabelledby = this.checkAriaIdReferences(this.viewport, "aria-labelledby", warnings, true);
1173
+ const hasRootLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings, true);
1115
1174
  const hasValidLabelledby = hasViewportLabelledby || hasRootLabelledby;
1116
1175
  const rootAriaLabel = this.root.getAttribute("aria-label")?.trim();
1117
1176
  const hasCustomViewportAriaLabel = !this.wasAriaLabelInferred && Boolean(this.viewport.getAttribute("aria-label")?.trim());
@@ -1125,6 +1184,16 @@ var __WulfIIFE = (() => {
1125
1184
  `Taille minimale du curseur insuffisante (minThumbSize: ${this.options.minThumbSize}px) : utilisez au moins 24px pour respecter WCAG 2.5.8.`
1126
1185
  );
1127
1186
  }
1187
+ if (this.root.tabIndex > 0 || this.viewport.tabIndex > 0) {
1188
+ warnings.push(
1189
+ 'Attribut tabindex > 0 d\xE9tect\xE9 sur la zone d\xE9filable : utilisez uniquement tabindex="0" ou "-1" (WCAG 2.4.3).'
1190
+ );
1191
+ }
1192
+ if (this.root.getAttribute("role") === "region" && this.viewport.getAttribute("role") === "region") {
1193
+ warnings.push(
1194
+ 'Landmark role="region" redondant : \xE9vitez de d\xE9clarer role="region" \xE0 la fois sur le conteneur racine et sur le viewport interne.'
1195
+ );
1196
+ }
1128
1197
  return warnings;
1129
1198
  }
1130
1199
  getAuditPrefix() {
@@ -1138,6 +1207,9 @@ var __WulfIIFE = (() => {
1138
1207
  */
1139
1208
  destroy() {
1140
1209
  if (this.isDestroyed) return;
1210
+ if (this.isDragging) {
1211
+ this.handlePointerUp();
1212
+ }
1141
1213
  this.isDestroyed = true;
1142
1214
  this.clearAutoHideTimer();
1143
1215
  if (this.scrollEndFallbackTimer !== void 0) {
@@ -1160,6 +1232,11 @@ var __WulfIIFE = (() => {
1160
1232
  if (this.resizeObserver) {
1161
1233
  this.resizeObserver.disconnect();
1162
1234
  }
1235
+ if (this.mutationObserver) {
1236
+ this.mutationObserver.disconnect();
1237
+ this.mutationObserver = void 0;
1238
+ }
1239
+ this.observedChildren.clear();
1163
1240
  this.trackY?.remove();
1164
1241
  this.trackX?.remove();
1165
1242
  this.root.classList.remove(