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.
- package/changelog.md +10 -0
- package/dist/focus-trap.esm.js +88 -30
- package/dist/focus-trap.esm.js.map +2 -2
- package/dist/focus-trap.global.js +88 -30
- package/dist/focus-trap.global.js.map +2 -2
- package/dist/focus-trap.global.min.js +2 -2
- package/dist/focus-trap.global.min.js.map +3 -3
- package/dist/index.esm.js +541 -162
- package/dist/index.esm.js.map +2 -2
- package/dist/index.global.js +541 -162
- package/dist/index.global.js.map +2 -2
- package/dist/index.global.min.js +2 -2
- package/dist/index.global.min.js.map +3 -3
- package/dist/mask.esm.js +4 -4
- package/dist/mask.esm.js.map +2 -2
- package/dist/mask.global.js +4 -4
- package/dist/mask.global.js.map +2 -2
- package/dist/mask.global.min.js +2 -2
- package/dist/mask.global.min.js.map +3 -3
- package/dist/masonry.esm.js +153 -62
- package/dist/masonry.esm.js.map +2 -2
- package/dist/masonry.global.js +153 -62
- package/dist/masonry.global.js.map +2 -2
- package/dist/masonry.global.min.js +3 -3
- package/dist/masonry.global.min.js.map +3 -3
- package/dist/scroll.css +1 -1
- package/dist/scroll.css.map +2 -2
- package/dist/scroll.esm.js +108 -31
- package/dist/scroll.esm.js.map +2 -2
- package/dist/scroll.global.js +108 -31
- package/dist/scroll.global.js.map +2 -2
- package/dist/scroll.global.min.js +2 -2
- package/dist/scroll.global.min.js.map +3 -3
- package/dist/scroll.layered.css +1 -1
- package/dist/scroll.layered.css.map +2 -2
- package/dist/shortcut.esm.js +182 -22
- package/dist/shortcut.esm.js.map +3 -3
- package/dist/shortcut.global.js +182 -22
- package/dist/shortcut.global.js.map +3 -3
- package/dist/shortcut.global.min.js +4 -1
- package/dist/shortcut.global.min.js.map +4 -4
- package/dist/toast.css +1 -1
- package/dist/toast.css.map +2 -2
- package/dist/toast.esm.js +92 -13
- package/dist/toast.esm.js.map +2 -2
- package/dist/toast.global.js +92 -13
- package/dist/toast.global.js.map +2 -2
- package/dist/toast.global.min.js +3 -3
- package/dist/toast.global.min.js.map +3 -3
- package/dist/toast.layered.css +1 -1
- package/dist/toast.layered.css.map +2 -2
- package/dist/types/common/dom.d.ts +5 -0
- package/dist/types/focus-trap/FocusTrap.d.ts +5 -2
- package/dist/types/mask/paste.d.ts +2 -5
- package/dist/types/masonry/Masonry.d.ts +2 -0
- package/dist/types/scroll/ScrollBlock.d.ts +2 -0
- package/dist/types/shortcut/ShortcutManager.d.ts +14 -3
- package/dist/types/toast/ToastManager.d.ts +2 -0
- package/package.json +1 -1
package/dist/scroll.esm.js
CHANGED
|
@@ -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
|
-
|
|
668
|
-
this.
|
|
669
|
-
|
|
670
|
-
this.resizeRafId =
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
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
|
-
|
|
680
|
-
this.resizeObserver.observe(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
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(
|