wulf.js 2.1.0 → 2.2.0
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/README.md +217 -11
- package/changelog.md +60 -0
- package/dist/anchor.esm.js +9 -0
- package/dist/anchor.esm.js.map +7 -0
- package/dist/anchor.global.js +695 -0
- package/dist/anchor.global.js.map +7 -0
- package/dist/anchor.global.min.js +6 -0
- package/dist/anchor.global.min.js.map +7 -0
- package/dist/autosize.css +1 -0
- package/dist/autosize.css.map +7 -0
- package/dist/autosize.esm.js +10 -0
- package/dist/autosize.esm.js.map +7 -0
- package/dist/autosize.global.js +657 -0
- package/dist/autosize.global.js.map +7 -0
- package/dist/autosize.global.min.js +6 -0
- package/dist/autosize.global.min.js.map +7 -0
- package/dist/autosize.layered.css +1 -0
- package/dist/autosize.layered.css.map +7 -0
- package/dist/chunks/chunk-22AIMRD5.js +119 -0
- package/dist/chunks/chunk-22AIMRD5.js.map +7 -0
- package/dist/chunks/chunk-5N2IRGDM.js +766 -0
- package/dist/chunks/chunk-5N2IRGDM.js.map +7 -0
- package/dist/chunks/chunk-72FVCNNZ.js +863 -0
- package/dist/chunks/chunk-72FVCNNZ.js.map +7 -0
- package/dist/chunks/chunk-AXZYYW7H.js +865 -0
- package/dist/chunks/chunk-AXZYYW7H.js.map +7 -0
- package/dist/chunks/chunk-CM3SBIVQ.js +1116 -0
- package/dist/chunks/chunk-CM3SBIVQ.js.map +7 -0
- package/dist/chunks/chunk-H4GRLGQ3.js +578 -0
- package/dist/chunks/chunk-H4GRLGQ3.js.map +7 -0
- package/dist/chunks/chunk-ITRU2RFV.js +1195 -0
- package/dist/chunks/chunk-ITRU2RFV.js.map +7 -0
- package/dist/chunks/chunk-NLUQZEL4.js +1029 -0
- package/dist/chunks/chunk-NLUQZEL4.js.map +7 -0
- package/dist/chunks/chunk-QV46A7FV.js +197 -0
- package/dist/chunks/chunk-QV46A7FV.js.map +7 -0
- package/dist/chunks/chunk-SXLUXN6W.js +612 -0
- package/dist/chunks/chunk-SXLUXN6W.js.map +7 -0
- package/dist/chunks/chunk-T2H4EJCW.js +621 -0
- package/dist/chunks/chunk-T2H4EJCW.js.map +7 -0
- package/dist/chunks/chunk-TILLYEF2.js +6044 -0
- package/dist/chunks/chunk-TILLYEF2.js.map +7 -0
- package/dist/chunks/chunk-VJO22BAT.js +72 -0
- package/dist/chunks/chunk-VJO22BAT.js.map +7 -0
- package/dist/chunks/chunk-ZGUU6DMM.js +77 -0
- package/dist/chunks/chunk-ZGUU6DMM.js.map +7 -0
- package/dist/focus-trap.esm.js +6 -536
- package/dist/focus-trap.esm.js.map +3 -3
- package/dist/focus-trap.global.js +260 -87
- package/dist/focus-trap.global.js.map +3 -3
- package/dist/focus-trap.global.min.js +4 -4
- package/dist/focus-trap.global.min.js.map +4 -4
- package/dist/index.esm.js +79 -10069
- package/dist/index.esm.js.map +4 -4
- package/dist/index.global.js +4192 -355
- package/dist/index.global.js.map +4 -4
- package/dist/index.global.min.js +6 -3
- package/dist/index.global.min.js.map +4 -4
- package/dist/mask.esm.js +16 -6094
- package/dist/mask.esm.js.map +4 -4
- package/dist/mask.global.js +44 -55
- package/dist/mask.global.js.map +3 -3
- package/dist/mask.global.min.js +3 -3
- package/dist/mask.global.min.js.map +4 -4
- package/dist/masonry.esm.js +15 -1067
- package/dist/masonry.esm.js.map +4 -4
- package/dist/masonry.global.js +229 -148
- package/dist/masonry.global.js.map +3 -3
- package/dist/masonry.global.min.js +4 -4
- package/dist/masonry.global.min.js.map +4 -4
- package/dist/scroll.css +1 -1
- package/dist/scroll.css.map +2 -2
- package/dist/scroll.esm.js +14 -1175
- package/dist/scroll.esm.js.map +3 -3
- package/dist/scroll.global.js +171 -88
- package/dist/scroll.global.js.map +3 -3
- package/dist/scroll.global.min.js +3 -3
- package/dist/scroll.global.min.js.map +4 -4
- package/dist/scroll.layered.css +1 -1
- package/dist/scroll.layered.css.map +2 -2
- package/dist/shortcut.esm.js +6 -741
- package/dist/shortcut.esm.js.map +4 -4
- package/dist/shortcut.global.js +225 -58
- package/dist/shortcut.global.js.map +3 -3
- package/dist/shortcut.global.min.js +8 -2
- package/dist/shortcut.global.min.js.map +4 -4
- package/dist/size-report.json +319 -0
- package/dist/sortable.css +1 -0
- package/dist/sortable.css.map +7 -0
- package/dist/sortable.esm.js +22 -0
- package/dist/sortable.esm.js.map +7 -0
- package/dist/sortable.global.js +1477 -0
- package/dist/sortable.global.js.map +7 -0
- package/dist/sortable.global.min.js +6 -0
- package/dist/sortable.global.min.js.map +7 -0
- package/dist/sortable.layered.css +1 -0
- package/dist/sortable.layered.css.map +7 -0
- package/dist/sri-manifest.json +64 -0
- package/dist/toast.css +1 -1
- package/dist/toast.css.map +2 -2
- package/dist/toast.esm.js +19 -1129
- package/dist/toast.esm.js.map +3 -3
- package/dist/toast.global.js +386 -104
- package/dist/toast.global.js.map +3 -3
- package/dist/toast.global.min.js +4 -4
- package/dist/toast.global.min.js.map +4 -4
- package/dist/toast.layered.css +1 -1
- package/dist/toast.layered.css.map +2 -2
- package/dist/types/anchor/Anchor.d.ts +41 -0
- package/dist/types/anchor/index.d.ts +3 -0
- package/dist/types/anchor/types.d.ts +115 -0
- package/dist/types/autosize/Autosize.d.ts +71 -0
- package/dist/types/autosize/index.d.ts +3 -0
- package/dist/types/autosize/types.d.ts +66 -0
- package/dist/types/common/AuditableComponent.d.ts +1 -1
- package/dist/types/common/dom.d.ts +5 -0
- package/dist/types/common/registry.d.ts +40 -0
- package/dist/types/focus-trap/FocusTrap.d.ts +8 -3
- package/dist/types/index.d.ts +13 -1
- 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/scroll/types.d.ts +6 -0
- package/dist/types/shortcut/ShortcutManager.d.ts +16 -3
- package/dist/types/shortcut/types.d.ts +5 -0
- package/dist/types/sortable/Sortable.d.ts +75 -0
- package/dist/types/sortable/i18n/en.d.ts +2 -0
- package/dist/types/sortable/i18n/fr.d.ts +2 -0
- package/dist/types/sortable/i18n/index.d.ts +9 -0
- package/dist/types/sortable/i18n/types.d.ts +15 -0
- package/dist/types/sortable/index.d.ts +4 -0
- package/dist/types/sortable/types.d.ts +112 -0
- package/dist/types/toast/Toast.d.ts +6 -1
- package/dist/types/toast/ToastInstance.d.ts +7 -0
- package/dist/types/toast/ToastManager.d.ts +4 -2
- package/dist/types/toast/types.d.ts +27 -1
- package/dist/types/undo/UndoManager.d.ts +112 -0
- package/dist/types/undo/i18n/en.d.ts +2 -0
- package/dist/types/undo/i18n/fr.d.ts +2 -0
- package/dist/types/undo/i18n/index.d.ts +9 -0
- package/dist/types/undo/i18n/types.d.ts +6 -0
- package/dist/types/undo/index.d.ts +5 -0
- package/dist/types/undo/types.d.ts +106 -0
- package/dist/undo.esm.js +23 -0
- package/dist/undo.esm.js.map +7 -0
- package/dist/undo.global.js +1029 -0
- package/dist/undo.global.js.map +7 -0
- package/dist/undo.global.min.js +6 -0
- package/dist/undo.global.min.js.map +7 -0
- package/package.json +54 -5
package/dist/scroll.global.js
CHANGED
|
@@ -31,33 +31,6 @@ var __WulfIIFE = (() => {
|
|
|
31
31
|
scrollI18n: () => scrollI18n
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
// src/common/dom.ts
|
|
35
|
-
function getSafeWulfNamespace() {
|
|
36
|
-
if (typeof window === "undefined") return null;
|
|
37
|
-
const win = window;
|
|
38
|
-
const existing = win.Wulf;
|
|
39
|
-
if (!existing || typeof existing !== "object" || typeof Node !== "undefined" && existing instanceof Node || typeof HTMLCollection !== "undefined" && existing instanceof HTMLCollection) {
|
|
40
|
-
const fresh = {};
|
|
41
|
-
win.Wulf = fresh;
|
|
42
|
-
return fresh;
|
|
43
|
-
}
|
|
44
|
-
return existing;
|
|
45
|
-
}
|
|
46
|
-
function safeMove(parent, node, referenceNode = null) {
|
|
47
|
-
const moveBefore = parent.moveBefore;
|
|
48
|
-
if (typeof moveBefore === "function" && node.isConnected && parent.isConnected && typeof parent.getRootNode === "function" && typeof node.getRootNode === "function" && parent.getRootNode() === node.getRootNode()) {
|
|
49
|
-
try {
|
|
50
|
-
moveBefore.call(parent, node, referenceNode);
|
|
51
|
-
return;
|
|
52
|
-
} catch {
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
parent.insertBefore(node, referenceNode);
|
|
56
|
-
}
|
|
57
|
-
function prefersReducedMotion() {
|
|
58
|
-
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
34
|
// src/common/AuditableComponent.ts
|
|
62
35
|
var AuditableComponent = class {
|
|
63
36
|
/**
|
|
@@ -189,6 +162,22 @@ var __WulfIIFE = (() => {
|
|
|
189
162
|
}
|
|
190
163
|
};
|
|
191
164
|
|
|
165
|
+
// src/common/dom.ts
|
|
166
|
+
function safeMove(parent, node, referenceNode = null) {
|
|
167
|
+
const moveBefore = parent.moveBefore;
|
|
168
|
+
if (typeof moveBefore === "function" && node.isConnected && parent.isConnected && typeof parent.getRootNode === "function" && typeof node.getRootNode === "function" && parent.getRootNode() === node.getRootNode()) {
|
|
169
|
+
try {
|
|
170
|
+
moveBefore.call(parent, node, referenceNode);
|
|
171
|
+
return;
|
|
172
|
+
} catch {
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
parent.insertBefore(node, referenceNode);
|
|
176
|
+
}
|
|
177
|
+
function prefersReducedMotion() {
|
|
178
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
179
|
+
}
|
|
180
|
+
|
|
192
181
|
// src/common/i18n.ts
|
|
193
182
|
var FORBIDDEN_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
194
183
|
function isSafeKey(key) {
|
|
@@ -349,6 +338,8 @@ var __WulfIIFE = (() => {
|
|
|
349
338
|
trackX;
|
|
350
339
|
thumbX;
|
|
351
340
|
resizeObserver;
|
|
341
|
+
mutationObserver;
|
|
342
|
+
observedChildren = /* @__PURE__ */ new Set();
|
|
352
343
|
hideTimer;
|
|
353
344
|
scrollEndFallbackTimer;
|
|
354
345
|
rafId = null;
|
|
@@ -386,6 +377,9 @@ var __WulfIIFE = (() => {
|
|
|
386
377
|
super(options?.i18n);
|
|
387
378
|
let resolvedElement = null;
|
|
388
379
|
if (typeof element === "string") {
|
|
380
|
+
if (typeof document === "undefined") {
|
|
381
|
+
throw new Error("[ScrollBlock] Impossible de r\xE9soudre un s\xE9lecteur CSS sans environnement DOM (document).");
|
|
382
|
+
}
|
|
389
383
|
try {
|
|
390
384
|
resolvedElement = document.querySelector(element);
|
|
391
385
|
} catch {
|
|
@@ -394,13 +388,13 @@ var __WulfIIFE = (() => {
|
|
|
394
388
|
} else {
|
|
395
389
|
resolvedElement = element;
|
|
396
390
|
}
|
|
397
|
-
if (!resolvedElement || !(resolvedElement instanceof HTMLElement)) {
|
|
391
|
+
if (!resolvedElement || typeof HTMLElement === "undefined" || !(resolvedElement instanceof HTMLElement)) {
|
|
398
392
|
throw new Error(`[ScrollBlock] \xC9l\xE9ment introuvable : "${element}".`);
|
|
399
393
|
}
|
|
400
394
|
this.root = resolvedElement;
|
|
401
395
|
this.hasExplicitAriaLabel = Boolean(options?.ariaLabel || options?.i18n?.viewport);
|
|
402
396
|
const rawDelay = options?.autoHideDelay;
|
|
403
|
-
const safeAutoHideDelay = typeof rawDelay === "number" && Number.isFinite(rawDelay) && rawDelay >= 0 ? rawDelay : 1e3;
|
|
397
|
+
const safeAutoHideDelay = typeof rawDelay === "number" && Number.isFinite(rawDelay) && rawDelay >= 0 ? Math.min(rawDelay, 2147483647) : 1e3;
|
|
404
398
|
const rawMinThumb = options?.minThumbSize;
|
|
405
399
|
const safeMinThumbSize = typeof rawMinThumb === "number" && Number.isFinite(rawMinThumb) && rawMinThumb > 0 ? rawMinThumb : 24;
|
|
406
400
|
const rawEdge = options?.edgeThreshold;
|
|
@@ -411,6 +405,7 @@ var __WulfIIFE = (() => {
|
|
|
411
405
|
autoHide: options?.autoHide ?? true,
|
|
412
406
|
autoHideDelay: safeAutoHideDelay,
|
|
413
407
|
alwaysVisible: options?.alwaysVisible ?? false,
|
|
408
|
+
scrollShadows: options?.scrollShadows ?? false,
|
|
414
409
|
ariaLabel: options?.ariaLabel || this.t("viewport"),
|
|
415
410
|
i18n: options?.i18n || {},
|
|
416
411
|
minThumbSize: safeMinThumbSize,
|
|
@@ -445,7 +440,10 @@ var __WulfIIFE = (() => {
|
|
|
445
440
|
* Prépare le viewport défilant sans altérer les éléments enfants.
|
|
446
441
|
*/
|
|
447
442
|
setupViewport() {
|
|
448
|
-
this.root.classList.add("wulf-scrollblock");
|
|
443
|
+
this.root.classList.add("wulf-scrollblock", `wulf-scrollblock--axis-${this.options.axis}`);
|
|
444
|
+
if (this.options.scrollShadows) {
|
|
445
|
+
this.root.classList.add("wulf-scrollblock--shadows");
|
|
446
|
+
}
|
|
449
447
|
if (this.options.mode === "native") {
|
|
450
448
|
this.root.classList.add("wulf-scrollblock--native");
|
|
451
449
|
}
|
|
@@ -594,9 +592,11 @@ var __WulfIIFE = (() => {
|
|
|
594
592
|
}
|
|
595
593
|
thumb.classList.add("is-active");
|
|
596
594
|
this.root.classList.add("is-dragging");
|
|
597
|
-
window
|
|
598
|
-
|
|
599
|
-
|
|
595
|
+
if (typeof window !== "undefined") {
|
|
596
|
+
window.addEventListener("pointermove", this.boundPointerMove, { signal: dragSignal });
|
|
597
|
+
window.addEventListener("pointerup", this.boundPointerUp, { signal: dragSignal });
|
|
598
|
+
window.addEventListener("pointercancel", this.boundPointerUp, { signal: dragSignal });
|
|
599
|
+
}
|
|
600
600
|
thumb.addEventListener("lostpointercapture", this.boundPointerUp, { signal: dragSignal });
|
|
601
601
|
}, { signal });
|
|
602
602
|
thumb.addEventListener("keydown", (e) => {
|
|
@@ -697,22 +697,28 @@ var __WulfIIFE = (() => {
|
|
|
697
697
|
* Initialise le ResizeObserver réactif.
|
|
698
698
|
*/
|
|
699
699
|
setupObserver() {
|
|
700
|
-
|
|
701
|
-
this.
|
|
702
|
-
|
|
703
|
-
this.resizeRafId =
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
}
|
|
708
|
-
});
|
|
700
|
+
const scheduleUpdate = () => {
|
|
701
|
+
if (this.isDestroyed || this.resizeRafId !== null || typeof window === "undefined") return;
|
|
702
|
+
this.resizeRafId = window.requestAnimationFrame(() => {
|
|
703
|
+
this.resizeRafId = null;
|
|
704
|
+
if (!this.isDestroyed) {
|
|
705
|
+
this.update();
|
|
706
|
+
}
|
|
709
707
|
});
|
|
708
|
+
};
|
|
709
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
710
|
+
this.resizeObserver = new ResizeObserver(scheduleUpdate);
|
|
710
711
|
this.resizeObserver.observe(this.root);
|
|
711
712
|
this.resizeObserver.observe(this.viewport);
|
|
712
|
-
|
|
713
|
-
this.resizeObserver.observe(
|
|
713
|
+
for (const child of Array.from(this.viewport.children)) {
|
|
714
|
+
this.resizeObserver.observe(child);
|
|
715
|
+
this.observedChildren.add(child);
|
|
714
716
|
}
|
|
715
717
|
}
|
|
718
|
+
if (typeof MutationObserver !== "undefined") {
|
|
719
|
+
this.mutationObserver = new MutationObserver(scheduleUpdate);
|
|
720
|
+
this.mutationObserver.observe(this.viewport, { childList: true });
|
|
721
|
+
}
|
|
716
722
|
}
|
|
717
723
|
/**
|
|
718
724
|
* Déplacement lors du glissement du curseur.
|
|
@@ -788,16 +794,28 @@ var __WulfIIFE = (() => {
|
|
|
788
794
|
this.scheduleSyncThumbs();
|
|
789
795
|
const info = this.getScrollInfo();
|
|
790
796
|
const { top: scrollTop, left: scrollLeft, maxTop, maxLeft } = info;
|
|
791
|
-
|
|
797
|
+
try {
|
|
798
|
+
this.options.onScroll(info);
|
|
799
|
+
} catch (err) {
|
|
800
|
+
console.error("[Wulf.Scroll] Erreur dans onScroll:", err);
|
|
801
|
+
}
|
|
792
802
|
const threshold = this.options.edgeThreshold;
|
|
793
803
|
if (maxTop > 0) {
|
|
794
804
|
const nowBottom = scrollTop >= maxTop - threshold;
|
|
795
805
|
const nowTop = scrollTop <= threshold;
|
|
796
806
|
if (nowBottom && !this.atBottom) {
|
|
797
|
-
|
|
807
|
+
try {
|
|
808
|
+
this.options.onTotalScroll("bottom");
|
|
809
|
+
} catch (err) {
|
|
810
|
+
console.error("[Wulf.Scroll] Erreur dans onTotalScroll:", err);
|
|
811
|
+
}
|
|
798
812
|
}
|
|
799
813
|
if (nowTop && !this.atTop) {
|
|
800
|
-
|
|
814
|
+
try {
|
|
815
|
+
this.options.onTotalScrollBack("top");
|
|
816
|
+
} catch (err) {
|
|
817
|
+
console.error("[Wulf.Scroll] Erreur dans onTotalScrollBack:", err);
|
|
818
|
+
}
|
|
801
819
|
}
|
|
802
820
|
this.atBottom = nowBottom;
|
|
803
821
|
this.atTop = nowTop;
|
|
@@ -807,10 +825,18 @@ var __WulfIIFE = (() => {
|
|
|
807
825
|
const nowRight = rtl ? scrollLeft >= -threshold : scrollLeft >= maxLeft - threshold;
|
|
808
826
|
const nowLeft = rtl ? scrollLeft <= -maxLeft + threshold : scrollLeft <= threshold;
|
|
809
827
|
if (nowRight && !this.atRight) {
|
|
810
|
-
|
|
828
|
+
try {
|
|
829
|
+
this.options.onTotalScroll("right");
|
|
830
|
+
} catch (err) {
|
|
831
|
+
console.error("[Wulf.Scroll] Erreur dans onTotalScroll:", err);
|
|
832
|
+
}
|
|
811
833
|
}
|
|
812
834
|
if (nowLeft && !this.atLeft) {
|
|
813
|
-
|
|
835
|
+
try {
|
|
836
|
+
this.options.onTotalScrollBack("left");
|
|
837
|
+
} catch (err) {
|
|
838
|
+
console.error("[Wulf.Scroll] Erreur dans onTotalScrollBack:", err);
|
|
839
|
+
}
|
|
814
840
|
}
|
|
815
841
|
this.atRight = nowRight;
|
|
816
842
|
this.atLeft = nowLeft;
|
|
@@ -822,7 +848,7 @@ var __WulfIIFE = (() => {
|
|
|
822
848
|
this.scheduleAutoHide();
|
|
823
849
|
}
|
|
824
850
|
}
|
|
825
|
-
if (!this.supportsScrollEnd) {
|
|
851
|
+
if (!this.supportsScrollEnd && typeof window !== "undefined") {
|
|
826
852
|
if (this.scrollEndFallbackTimer !== void 0) {
|
|
827
853
|
window.clearTimeout(this.scrollEndFallbackTimer);
|
|
828
854
|
}
|
|
@@ -836,7 +862,11 @@ var __WulfIIFE = (() => {
|
|
|
836
862
|
* Gestionnaire de fin de défilement (`scrollend` natif ou repli temporisé).
|
|
837
863
|
*/
|
|
838
864
|
handleScrollEnd() {
|
|
839
|
-
|
|
865
|
+
try {
|
|
866
|
+
this.options.onScrollEnd(this.getScrollInfo());
|
|
867
|
+
} catch (err) {
|
|
868
|
+
console.error("[Wulf.Scroll] Erreur dans onScrollEnd:", err);
|
|
869
|
+
}
|
|
840
870
|
if (this.options.mode !== "native" && this.options.autoHide && !this.options.alwaysVisible) {
|
|
841
871
|
this.scheduleAutoHide();
|
|
842
872
|
}
|
|
@@ -845,7 +875,7 @@ var __WulfIIFE = (() => {
|
|
|
845
875
|
* Planifie une synchronisation des curseurs calée sur la prochaine trame d'affichage.
|
|
846
876
|
*/
|
|
847
877
|
scheduleSyncThumbs() {
|
|
848
|
-
if (this.options.mode === "native" || this.isDestroyed) return;
|
|
878
|
+
if (this.options.mode === "native" || this.isDestroyed || typeof window === "undefined") return;
|
|
849
879
|
if (this.rafId !== null) return;
|
|
850
880
|
this.rafId = window.requestAnimationFrame(() => {
|
|
851
881
|
this.rafId = null;
|
|
@@ -863,24 +893,34 @@ var __WulfIIFE = (() => {
|
|
|
863
893
|
if (this.thumbY && this.trackY) {
|
|
864
894
|
const maxScrollY = this.cachedMaxTop;
|
|
865
895
|
const maxTravelY = this.cachedTrackHeight - this.cachedThumbHeight;
|
|
866
|
-
if (maxScrollY > 0
|
|
896
|
+
if (maxScrollY > 0) {
|
|
867
897
|
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
898
|
this.thumbY.setAttribute("aria-valuenow", String(Math.round(ratioY * 100)));
|
|
899
|
+
if (maxTravelY > 0) {
|
|
900
|
+
const posY = Math.max(0, Math.min(maxTravelY, ratioY * maxTravelY));
|
|
901
|
+
this.thumbY.style.setProperty("--scrollblock-thumb-y", `${posY}px`);
|
|
902
|
+
}
|
|
903
|
+
} else {
|
|
904
|
+
this.thumbY.setAttribute("aria-valuenow", "0");
|
|
905
|
+
this.thumbY.style.setProperty("--scrollblock-thumb-y", "0px");
|
|
871
906
|
}
|
|
872
907
|
}
|
|
873
908
|
if (this.thumbX && this.trackX) {
|
|
874
909
|
const maxScrollX = this.cachedMaxLeft;
|
|
875
910
|
const maxTravelX = this.cachedTrackWidth - this.cachedThumbWidth;
|
|
876
|
-
if (maxScrollX > 0
|
|
911
|
+
if (maxScrollX > 0) {
|
|
877
912
|
const rtl = this.isRtl();
|
|
878
913
|
const logicalLeft = rtl ? Math.max(0, -scrollLeft) : Math.max(0, scrollLeft);
|
|
879
914
|
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
915
|
this.thumbX.setAttribute("aria-valuenow", String(Math.round(ratioX * 100)));
|
|
916
|
+
if (maxTravelX > 0) {
|
|
917
|
+
const posX = Math.max(0, Math.min(maxTravelX, ratioX * maxTravelX));
|
|
918
|
+
const signedPosX = rtl ? -posX : posX;
|
|
919
|
+
this.thumbX.style.setProperty("--scrollblock-thumb-x", `${signedPosX}px`);
|
|
920
|
+
}
|
|
921
|
+
} else {
|
|
922
|
+
this.thumbX.setAttribute("aria-valuenow", "0");
|
|
923
|
+
this.thumbX.style.setProperty("--scrollblock-thumb-x", "0px");
|
|
884
924
|
}
|
|
885
925
|
}
|
|
886
926
|
}
|
|
@@ -899,13 +939,13 @@ var __WulfIIFE = (() => {
|
|
|
899
939
|
this.scheduleAutoHide();
|
|
900
940
|
}
|
|
901
941
|
clearAutoHideTimer() {
|
|
902
|
-
if (this.hideTimer) {
|
|
942
|
+
if (this.hideTimer && typeof window !== "undefined") {
|
|
903
943
|
window.clearTimeout(this.hideTimer);
|
|
904
|
-
this.hideTimer = void 0;
|
|
905
944
|
}
|
|
945
|
+
this.hideTimer = void 0;
|
|
906
946
|
}
|
|
907
947
|
scheduleAutoHide() {
|
|
908
|
-
if (this.options.alwaysVisible || !this.options.autoHide || this.isDragging) return;
|
|
948
|
+
if (this.options.alwaysVisible || !this.options.autoHide || this.isDragging || typeof window === "undefined") return;
|
|
909
949
|
this.clearAutoHideTimer();
|
|
910
950
|
this.hideTimer = window.setTimeout(() => {
|
|
911
951
|
this.root.classList.remove("is-scrolling");
|
|
@@ -918,6 +958,21 @@ var __WulfIIFE = (() => {
|
|
|
918
958
|
update() {
|
|
919
959
|
if (this.isDestroyed) return;
|
|
920
960
|
this.syncAccessibilityLabels();
|
|
961
|
+
if (this.resizeObserver) {
|
|
962
|
+
const currentChildren = new Set(Array.from(this.viewport.children));
|
|
963
|
+
for (const prev of this.observedChildren) {
|
|
964
|
+
if (!currentChildren.has(prev)) {
|
|
965
|
+
this.resizeObserver.unobserve(prev);
|
|
966
|
+
this.observedChildren.delete(prev);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
for (const child of currentChildren) {
|
|
970
|
+
if (!this.observedChildren.has(child)) {
|
|
971
|
+
this.resizeObserver.observe(child);
|
|
972
|
+
this.observedChildren.add(child);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
921
976
|
const { scrollHeight, clientHeight, scrollWidth, clientWidth } = this.viewport;
|
|
922
977
|
const trackHeight = this.trackY ? this.trackY.clientHeight : 0;
|
|
923
978
|
const trackWidth = this.trackX ? this.trackX.clientWidth : 0;
|
|
@@ -1036,10 +1091,12 @@ var __WulfIIFE = (() => {
|
|
|
1036
1091
|
}
|
|
1037
1092
|
}
|
|
1038
1093
|
} else if (target instanceof HTMLElement) {
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1094
|
+
if (target.isConnected && this.viewport.contains(target)) {
|
|
1095
|
+
const vpRect = this.viewport.getBoundingClientRect();
|
|
1096
|
+
const elRect = target.getBoundingClientRect();
|
|
1097
|
+
targetTop = elRect.top - vpRect.top - this.viewport.clientTop + scrollTop;
|
|
1098
|
+
targetLeft = elRect.left - vpRect.left - this.viewport.clientLeft + scrollLeft;
|
|
1099
|
+
}
|
|
1043
1100
|
} else if (typeof target === "object" && target !== null) {
|
|
1044
1101
|
targetTop = target.top;
|
|
1045
1102
|
targetLeft = target.left;
|
|
@@ -1081,8 +1138,10 @@ var __WulfIIFE = (() => {
|
|
|
1081
1138
|
const finish = () => {
|
|
1082
1139
|
if (settled) return;
|
|
1083
1140
|
settled = true;
|
|
1084
|
-
if (
|
|
1085
|
-
|
|
1141
|
+
if (typeof window !== "undefined") {
|
|
1142
|
+
if (idleTimerId !== void 0) window.clearTimeout(idleTimerId);
|
|
1143
|
+
if (maxTimerId !== void 0) window.clearTimeout(maxTimerId);
|
|
1144
|
+
}
|
|
1086
1145
|
if (this.activeScrollToController === waitController) {
|
|
1087
1146
|
this.activeScrollToController = void 0;
|
|
1088
1147
|
}
|
|
@@ -1093,7 +1152,7 @@ var __WulfIIFE = (() => {
|
|
|
1093
1152
|
this.abortController.signal.addEventListener("abort", finish, { once: true, signal: waitController.signal });
|
|
1094
1153
|
if (this.supportsScrollEnd) {
|
|
1095
1154
|
this.viewport.addEventListener("scrollend", finish, { once: true, signal: waitController.signal });
|
|
1096
|
-
} else {
|
|
1155
|
+
} else if (typeof window !== "undefined") {
|
|
1097
1156
|
const bumpIdle = () => {
|
|
1098
1157
|
if (idleTimerId !== void 0) window.clearTimeout(idleTimerId);
|
|
1099
1158
|
idleTimerId = window.setTimeout(finish, 150);
|
|
@@ -1101,7 +1160,11 @@ var __WulfIIFE = (() => {
|
|
|
1101
1160
|
this.viewport.addEventListener("scroll", bumpIdle, { passive: true, signal: waitController.signal });
|
|
1102
1161
|
bumpIdle();
|
|
1103
1162
|
}
|
|
1104
|
-
|
|
1163
|
+
if (typeof window !== "undefined") {
|
|
1164
|
+
maxTimerId = window.setTimeout(finish, 2500);
|
|
1165
|
+
} else {
|
|
1166
|
+
finish();
|
|
1167
|
+
}
|
|
1105
1168
|
});
|
|
1106
1169
|
}
|
|
1107
1170
|
/**
|
|
@@ -1110,8 +1173,8 @@ var __WulfIIFE = (() => {
|
|
|
1110
1173
|
*/
|
|
1111
1174
|
audit() {
|
|
1112
1175
|
const warnings = [];
|
|
1113
|
-
const hasViewportLabelledby = this.checkAriaIdReferences(this.viewport, "aria-labelledby", warnings);
|
|
1114
|
-
const hasRootLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings);
|
|
1176
|
+
const hasViewportLabelledby = this.checkAriaIdReferences(this.viewport, "aria-labelledby", warnings, true);
|
|
1177
|
+
const hasRootLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings, true);
|
|
1115
1178
|
const hasValidLabelledby = hasViewportLabelledby || hasRootLabelledby;
|
|
1116
1179
|
const rootAriaLabel = this.root.getAttribute("aria-label")?.trim();
|
|
1117
1180
|
const hasCustomViewportAriaLabel = !this.wasAriaLabelInferred && Boolean(this.viewport.getAttribute("aria-label")?.trim());
|
|
@@ -1125,6 +1188,16 @@ var __WulfIIFE = (() => {
|
|
|
1125
1188
|
`Taille minimale du curseur insuffisante (minThumbSize: ${this.options.minThumbSize}px) : utilisez au moins 24px pour respecter WCAG 2.5.8.`
|
|
1126
1189
|
);
|
|
1127
1190
|
}
|
|
1191
|
+
if (this.root.tabIndex > 0 || this.viewport.tabIndex > 0) {
|
|
1192
|
+
warnings.push(
|
|
1193
|
+
'Attribut tabindex > 0 d\xE9tect\xE9 sur la zone d\xE9filable : utilisez uniquement tabindex="0" ou "-1" (WCAG 2.4.3).'
|
|
1194
|
+
);
|
|
1195
|
+
}
|
|
1196
|
+
if (this.root.getAttribute("role") === "region" && this.viewport.getAttribute("role") === "region") {
|
|
1197
|
+
warnings.push(
|
|
1198
|
+
'Landmark role="region" redondant : \xE9vitez de d\xE9clarer role="region" \xE0 la fois sur le conteneur racine et sur le viewport interne.'
|
|
1199
|
+
);
|
|
1200
|
+
}
|
|
1128
1201
|
return warnings;
|
|
1129
1202
|
}
|
|
1130
1203
|
getAuditPrefix() {
|
|
@@ -1138,20 +1211,25 @@ var __WulfIIFE = (() => {
|
|
|
1138
1211
|
*/
|
|
1139
1212
|
destroy() {
|
|
1140
1213
|
if (this.isDestroyed) return;
|
|
1214
|
+
if (this.isDragging) {
|
|
1215
|
+
this.handlePointerUp();
|
|
1216
|
+
}
|
|
1141
1217
|
this.isDestroyed = true;
|
|
1142
1218
|
this.clearAutoHideTimer();
|
|
1143
|
-
if (
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
this.resizeRafId = null;
|
|
1219
|
+
if (typeof window !== "undefined") {
|
|
1220
|
+
if (this.scrollEndFallbackTimer !== void 0) {
|
|
1221
|
+
window.clearTimeout(this.scrollEndFallbackTimer);
|
|
1222
|
+
}
|
|
1223
|
+
if (this.rafId !== null) {
|
|
1224
|
+
window.cancelAnimationFrame(this.rafId);
|
|
1225
|
+
}
|
|
1226
|
+
if (this.resizeRafId !== null) {
|
|
1227
|
+
window.cancelAnimationFrame(this.resizeRafId);
|
|
1228
|
+
}
|
|
1154
1229
|
}
|
|
1230
|
+
this.scrollEndFallbackTimer = void 0;
|
|
1231
|
+
this.rafId = null;
|
|
1232
|
+
this.resizeRafId = null;
|
|
1155
1233
|
this.activeScrollToController?.abort();
|
|
1156
1234
|
this.activeScrollToController = void 0;
|
|
1157
1235
|
this.dragAbortController?.abort();
|
|
@@ -1160,11 +1238,20 @@ var __WulfIIFE = (() => {
|
|
|
1160
1238
|
if (this.resizeObserver) {
|
|
1161
1239
|
this.resizeObserver.disconnect();
|
|
1162
1240
|
}
|
|
1241
|
+
if (this.mutationObserver) {
|
|
1242
|
+
this.mutationObserver.disconnect();
|
|
1243
|
+
this.mutationObserver = void 0;
|
|
1244
|
+
}
|
|
1245
|
+
this.observedChildren.clear();
|
|
1163
1246
|
this.trackY?.remove();
|
|
1164
1247
|
this.trackX?.remove();
|
|
1165
1248
|
this.root.classList.remove(
|
|
1166
1249
|
"wulf-scrollblock",
|
|
1167
1250
|
"wulf-scrollblock--native",
|
|
1251
|
+
"wulf-scrollblock--shadows",
|
|
1252
|
+
"wulf-scrollblock--axis-y",
|
|
1253
|
+
"wulf-scrollblock--axis-x",
|
|
1254
|
+
"wulf-scrollblock--axis-both",
|
|
1168
1255
|
"has-scroll-y",
|
|
1169
1256
|
"has-scroll-x",
|
|
1170
1257
|
"has-both-axes",
|
|
@@ -1202,11 +1289,7 @@ var __WulfIIFE = (() => {
|
|
|
1202
1289
|
i18n: scrollI18n
|
|
1203
1290
|
};
|
|
1204
1291
|
var index_default = ScrollBlock;
|
|
1205
|
-
var wulfNamespace = getSafeWulfNamespace();
|
|
1206
|
-
if (wulfNamespace) {
|
|
1207
|
-
wulfNamespace.Scroll = Scroll;
|
|
1208
|
-
}
|
|
1209
1292
|
return __toCommonJS(index_exports);
|
|
1210
1293
|
})();
|
|
1211
|
-
if (typeof window !== "undefined") { var __w = window.Wulf; if (!__w || typeof __w !== "object" || (typeof Node !== "undefined" && __w instanceof Node) || (typeof HTMLCollection !== "undefined" && __w instanceof HTMLCollection)) { __w = {}; window.Wulf = __w; }
|
|
1294
|
+
if (typeof window !== "undefined") { var __w = window.Wulf; if (!__w || typeof __w !== "object" || (typeof Node !== "undefined" && __w instanceof Node) || (typeof HTMLCollection !== "undefined" && __w instanceof HTMLCollection)) { __w = {}; window.Wulf = __w; } var __set = function(obj, key, val) { try { Object.defineProperty(obj, key, { value: val, writable: true, configurable: true, enumerable: true }); } catch (_) { try { obj[key] = val; } catch (__) {} } }; if (typeof __WulfIIFE !== "undefined" && __WulfIIFE) { var __e = __WulfIIFE; var __skip = ["__proto__","constructor","prototype"]; for (var k in __e) { if (Object.hasOwn(__e, k) && __skip.indexOf(k) === -1 && __w[k] === undefined) { __set(__w, k, __e[k]); } } if (__e.Scroll) __set(__w, "Scroll", __e.Scroll); }}
|
|
1212
1295
|
//# sourceMappingURL=scroll.global.js.map
|