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.
- package/README.md +240 -4
- package/changelog.md +37 -0
- package/dist/focus-trap.esm.js +110 -37
- package/dist/focus-trap.esm.js.map +2 -2
- package/dist/focus-trap.global.js +110 -37
- 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 +3370 -337
- package/dist/index.esm.js.map +4 -4
- package/dist/index.global.js +3370 -337
- package/dist/index.global.js.map +4 -4
- package/dist/index.global.min.js +2 -2
- package/dist/index.global.min.js.map +4 -4
- package/dist/mask.css +1 -1
- package/dist/mask.css.map +2 -2
- package/dist/mask.esm.js +2826 -171
- package/dist/mask.esm.js.map +4 -4
- package/dist/mask.global.js +2816 -161
- package/dist/mask.global.js.map +4 -4
- package/dist/mask.global.min.js +2 -2
- package/dist/mask.global.min.js.map +4 -4
- package/dist/mask.layered.css +1 -1
- package/dist/mask.layered.css.map +2 -2
- package/dist/masonry.esm.js +175 -69
- package/dist/masonry.esm.js.map +2 -2
- package/dist/masonry.global.js +175 -69
- 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 +132 -40
- package/dist/scroll.esm.js.map +2 -2
- package/dist/scroll.global.js +132 -40
- 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 +116 -19
- package/dist/toast.esm.js.map +2 -2
- package/dist/toast.global.js +116 -19
- 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/AuditableComponent.d.ts +3 -3
- package/dist/types/common/dom.d.ts +5 -0
- package/dist/types/focus-trap/FocusTrap.d.ts +5 -2
- package/dist/types/mask/AmountEngine.d.ts +8 -0
- package/dist/types/mask/BaseInputMask.d.ts +18 -0
- package/dist/types/mask/DateUTCEngine.d.ts +187 -0
- package/dist/types/mask/InputAmountMask.d.ts +5 -0
- package/dist/types/mask/InputDateUTCMask.d.ts +110 -0
- package/dist/types/mask/InputEmailMask.d.ts +7 -0
- package/dist/types/mask/InputMask.d.ts +7 -5
- package/dist/types/mask/MaskEngine.d.ts +39 -7
- package/dist/types/mask/index.d.ts +12 -6
- package/dist/types/mask/paste.d.ts +15 -0
- package/dist/types/mask/types.d.ts +27 -2
- 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.global.js
CHANGED
|
@@ -83,24 +83,39 @@ var __WulfIIFE = (() => {
|
|
|
83
83
|
return warnings;
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
|
-
* Vérifie si un attribut de référence d'IDs ARIA (ex: aria-labelledby, aria-describedby)
|
|
87
|
-
* pointe vers des éléments réellement présents dans le document.
|
|
86
|
+
* Vérifie si un attribut de référence d'IDs ARIA (ex: aria-labelledby, aria-describedby, aria-errormessage)
|
|
87
|
+
* pointe vers des éléments réellement présents dans le document (et optionnellement non vides).
|
|
88
88
|
*/
|
|
89
|
-
checkAriaIdReferences(element, attrName, warnings) {
|
|
89
|
+
checkAriaIdReferences(element, attrName, warnings, requireNonEmptyText = false) {
|
|
90
90
|
const rawValue = element.getAttribute(attrName)?.trim();
|
|
91
91
|
if (!rawValue) return false;
|
|
92
92
|
const doc = element.ownerDocument || document;
|
|
93
93
|
const root = typeof element.getRootNode === "function" ? element.getRootNode() : doc;
|
|
94
94
|
const ids = rawValue.split(/\s+/).filter(Boolean);
|
|
95
|
-
const
|
|
96
|
-
(id) =>
|
|
95
|
+
const targets = ids.map(
|
|
96
|
+
(id) => typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.getElementById(id) : doc.getElementById(id)
|
|
97
97
|
);
|
|
98
|
-
|
|
98
|
+
const allFound = ids.length > 0 && targets.every((el) => Boolean(el));
|
|
99
|
+
if (!allFound) {
|
|
99
100
|
warnings.push(
|
|
100
101
|
`Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`
|
|
101
102
|
);
|
|
103
|
+
return false;
|
|
102
104
|
}
|
|
103
|
-
|
|
105
|
+
if (requireNonEmptyText) {
|
|
106
|
+
const hasNonEmptyText = targets.some((el) => {
|
|
107
|
+
if (!el) return false;
|
|
108
|
+
const text = el.textContent?.trim() || el.getAttribute("aria-label")?.trim() || "";
|
|
109
|
+
return text.length > 0;
|
|
110
|
+
});
|
|
111
|
+
if (!hasNonEmptyText) {
|
|
112
|
+
warnings.push(
|
|
113
|
+
`Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible ne contient aucun texte accessible.`
|
|
114
|
+
);
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return true;
|
|
104
119
|
}
|
|
105
120
|
};
|
|
106
121
|
|
|
@@ -334,6 +349,8 @@ var __WulfIIFE = (() => {
|
|
|
334
349
|
trackX;
|
|
335
350
|
thumbX;
|
|
336
351
|
resizeObserver;
|
|
352
|
+
mutationObserver;
|
|
353
|
+
observedChildren = /* @__PURE__ */ new Set();
|
|
337
354
|
hideTimer;
|
|
338
355
|
scrollEndFallbackTimer;
|
|
339
356
|
rafId = null;
|
|
@@ -385,7 +402,7 @@ var __WulfIIFE = (() => {
|
|
|
385
402
|
this.root = resolvedElement;
|
|
386
403
|
this.hasExplicitAriaLabel = Boolean(options?.ariaLabel || options?.i18n?.viewport);
|
|
387
404
|
const rawDelay = options?.autoHideDelay;
|
|
388
|
-
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;
|
|
389
406
|
const rawMinThumb = options?.minThumbSize;
|
|
390
407
|
const safeMinThumbSize = typeof rawMinThumb === "number" && Number.isFinite(rawMinThumb) && rawMinThumb > 0 ? rawMinThumb : 24;
|
|
391
408
|
const rawEdge = options?.edgeThreshold;
|
|
@@ -682,22 +699,28 @@ var __WulfIIFE = (() => {
|
|
|
682
699
|
* Initialise le ResizeObserver réactif.
|
|
683
700
|
*/
|
|
684
701
|
setupObserver() {
|
|
685
|
-
|
|
686
|
-
this.
|
|
687
|
-
|
|
688
|
-
this.resizeRafId =
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
}
|
|
693
|
-
});
|
|
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
|
+
}
|
|
694
709
|
});
|
|
710
|
+
};
|
|
711
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
712
|
+
this.resizeObserver = new ResizeObserver(scheduleUpdate);
|
|
695
713
|
this.resizeObserver.observe(this.root);
|
|
696
714
|
this.resizeObserver.observe(this.viewport);
|
|
697
|
-
|
|
698
|
-
this.resizeObserver.observe(
|
|
715
|
+
for (const child of Array.from(this.viewport.children)) {
|
|
716
|
+
this.resizeObserver.observe(child);
|
|
717
|
+
this.observedChildren.add(child);
|
|
699
718
|
}
|
|
700
719
|
}
|
|
720
|
+
if (typeof MutationObserver !== "undefined") {
|
|
721
|
+
this.mutationObserver = new MutationObserver(scheduleUpdate);
|
|
722
|
+
this.mutationObserver.observe(this.viewport, { childList: true });
|
|
723
|
+
}
|
|
701
724
|
}
|
|
702
725
|
/**
|
|
703
726
|
* Déplacement lors du glissement du curseur.
|
|
@@ -773,16 +796,28 @@ var __WulfIIFE = (() => {
|
|
|
773
796
|
this.scheduleSyncThumbs();
|
|
774
797
|
const info = this.getScrollInfo();
|
|
775
798
|
const { top: scrollTop, left: scrollLeft, maxTop, maxLeft } = info;
|
|
776
|
-
|
|
799
|
+
try {
|
|
800
|
+
this.options.onScroll(info);
|
|
801
|
+
} catch (err) {
|
|
802
|
+
console.error("[Wulf.Scroll] Erreur dans onScroll:", err);
|
|
803
|
+
}
|
|
777
804
|
const threshold = this.options.edgeThreshold;
|
|
778
805
|
if (maxTop > 0) {
|
|
779
806
|
const nowBottom = scrollTop >= maxTop - threshold;
|
|
780
807
|
const nowTop = scrollTop <= threshold;
|
|
781
808
|
if (nowBottom && !this.atBottom) {
|
|
782
|
-
|
|
809
|
+
try {
|
|
810
|
+
this.options.onTotalScroll("bottom");
|
|
811
|
+
} catch (err) {
|
|
812
|
+
console.error("[Wulf.Scroll] Erreur dans onTotalScroll:", err);
|
|
813
|
+
}
|
|
783
814
|
}
|
|
784
815
|
if (nowTop && !this.atTop) {
|
|
785
|
-
|
|
816
|
+
try {
|
|
817
|
+
this.options.onTotalScrollBack("top");
|
|
818
|
+
} catch (err) {
|
|
819
|
+
console.error("[Wulf.Scroll] Erreur dans onTotalScrollBack:", err);
|
|
820
|
+
}
|
|
786
821
|
}
|
|
787
822
|
this.atBottom = nowBottom;
|
|
788
823
|
this.atTop = nowTop;
|
|
@@ -792,10 +827,18 @@ var __WulfIIFE = (() => {
|
|
|
792
827
|
const nowRight = rtl ? scrollLeft >= -threshold : scrollLeft >= maxLeft - threshold;
|
|
793
828
|
const nowLeft = rtl ? scrollLeft <= -maxLeft + threshold : scrollLeft <= threshold;
|
|
794
829
|
if (nowRight && !this.atRight) {
|
|
795
|
-
|
|
830
|
+
try {
|
|
831
|
+
this.options.onTotalScroll("right");
|
|
832
|
+
} catch (err) {
|
|
833
|
+
console.error("[Wulf.Scroll] Erreur dans onTotalScroll:", err);
|
|
834
|
+
}
|
|
796
835
|
}
|
|
797
836
|
if (nowLeft && !this.atLeft) {
|
|
798
|
-
|
|
837
|
+
try {
|
|
838
|
+
this.options.onTotalScrollBack("left");
|
|
839
|
+
} catch (err) {
|
|
840
|
+
console.error("[Wulf.Scroll] Erreur dans onTotalScrollBack:", err);
|
|
841
|
+
}
|
|
799
842
|
}
|
|
800
843
|
this.atRight = nowRight;
|
|
801
844
|
this.atLeft = nowLeft;
|
|
@@ -821,7 +864,11 @@ var __WulfIIFE = (() => {
|
|
|
821
864
|
* Gestionnaire de fin de défilement (`scrollend` natif ou repli temporisé).
|
|
822
865
|
*/
|
|
823
866
|
handleScrollEnd() {
|
|
824
|
-
|
|
867
|
+
try {
|
|
868
|
+
this.options.onScrollEnd(this.getScrollInfo());
|
|
869
|
+
} catch (err) {
|
|
870
|
+
console.error("[Wulf.Scroll] Erreur dans onScrollEnd:", err);
|
|
871
|
+
}
|
|
825
872
|
if (this.options.mode !== "native" && this.options.autoHide && !this.options.alwaysVisible) {
|
|
826
873
|
this.scheduleAutoHide();
|
|
827
874
|
}
|
|
@@ -848,24 +895,34 @@ var __WulfIIFE = (() => {
|
|
|
848
895
|
if (this.thumbY && this.trackY) {
|
|
849
896
|
const maxScrollY = this.cachedMaxTop;
|
|
850
897
|
const maxTravelY = this.cachedTrackHeight - this.cachedThumbHeight;
|
|
851
|
-
if (maxScrollY > 0
|
|
898
|
+
if (maxScrollY > 0) {
|
|
852
899
|
const ratioY = Math.max(0, Math.min(1, scrollTop / maxScrollY));
|
|
853
|
-
const posY = Math.max(0, Math.min(maxTravelY, ratioY * maxTravelY));
|
|
854
|
-
this.thumbY.style.setProperty("--scrollblock-thumb-y", `${posY}px`);
|
|
855
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");
|
|
856
908
|
}
|
|
857
909
|
}
|
|
858
910
|
if (this.thumbX && this.trackX) {
|
|
859
911
|
const maxScrollX = this.cachedMaxLeft;
|
|
860
912
|
const maxTravelX = this.cachedTrackWidth - this.cachedThumbWidth;
|
|
861
|
-
if (maxScrollX > 0
|
|
913
|
+
if (maxScrollX > 0) {
|
|
862
914
|
const rtl = this.isRtl();
|
|
863
915
|
const logicalLeft = rtl ? Math.max(0, -scrollLeft) : Math.max(0, scrollLeft);
|
|
864
916
|
const ratioX = Math.max(0, Math.min(1, logicalLeft / maxScrollX));
|
|
865
|
-
const posX = Math.max(0, Math.min(maxTravelX, ratioX * maxTravelX));
|
|
866
|
-
const signedPosX = rtl ? -posX : posX;
|
|
867
|
-
this.thumbX.style.setProperty("--scrollblock-thumb-x", `${signedPosX}px`);
|
|
868
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");
|
|
869
926
|
}
|
|
870
927
|
}
|
|
871
928
|
}
|
|
@@ -903,6 +960,21 @@ var __WulfIIFE = (() => {
|
|
|
903
960
|
update() {
|
|
904
961
|
if (this.isDestroyed) return;
|
|
905
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
|
+
}
|
|
906
978
|
const { scrollHeight, clientHeight, scrollWidth, clientWidth } = this.viewport;
|
|
907
979
|
const trackHeight = this.trackY ? this.trackY.clientHeight : 0;
|
|
908
980
|
const trackWidth = this.trackX ? this.trackX.clientWidth : 0;
|
|
@@ -1014,17 +1086,19 @@ var __WulfIIFE = (() => {
|
|
|
1014
1086
|
if (el) {
|
|
1015
1087
|
const vpRect = this.viewport.getBoundingClientRect();
|
|
1016
1088
|
const elRect = el.getBoundingClientRect();
|
|
1017
|
-
targetTop = elRect.top - vpRect.top + scrollTop;
|
|
1018
|
-
targetLeft = elRect.left - vpRect.left + scrollLeft;
|
|
1089
|
+
targetTop = elRect.top - vpRect.top - this.viewport.clientTop + scrollTop;
|
|
1090
|
+
targetLeft = elRect.left - vpRect.left - this.viewport.clientLeft + scrollLeft;
|
|
1019
1091
|
}
|
|
1020
1092
|
break;
|
|
1021
1093
|
}
|
|
1022
1094
|
}
|
|
1023
1095
|
} else if (target instanceof HTMLElement) {
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
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
|
+
}
|
|
1028
1102
|
} else if (typeof target === "object" && target !== null) {
|
|
1029
1103
|
targetTop = target.top;
|
|
1030
1104
|
targetLeft = target.left;
|
|
@@ -1095,8 +1169,8 @@ var __WulfIIFE = (() => {
|
|
|
1095
1169
|
*/
|
|
1096
1170
|
audit() {
|
|
1097
1171
|
const warnings = [];
|
|
1098
|
-
const hasViewportLabelledby = this.checkAriaIdReferences(this.viewport, "aria-labelledby", warnings);
|
|
1099
|
-
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);
|
|
1100
1174
|
const hasValidLabelledby = hasViewportLabelledby || hasRootLabelledby;
|
|
1101
1175
|
const rootAriaLabel = this.root.getAttribute("aria-label")?.trim();
|
|
1102
1176
|
const hasCustomViewportAriaLabel = !this.wasAriaLabelInferred && Boolean(this.viewport.getAttribute("aria-label")?.trim());
|
|
@@ -1110,6 +1184,16 @@ var __WulfIIFE = (() => {
|
|
|
1110
1184
|
`Taille minimale du curseur insuffisante (minThumbSize: ${this.options.minThumbSize}px) : utilisez au moins 24px pour respecter WCAG 2.5.8.`
|
|
1111
1185
|
);
|
|
1112
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
|
+
}
|
|
1113
1197
|
return warnings;
|
|
1114
1198
|
}
|
|
1115
1199
|
getAuditPrefix() {
|
|
@@ -1123,6 +1207,9 @@ var __WulfIIFE = (() => {
|
|
|
1123
1207
|
*/
|
|
1124
1208
|
destroy() {
|
|
1125
1209
|
if (this.isDestroyed) return;
|
|
1210
|
+
if (this.isDragging) {
|
|
1211
|
+
this.handlePointerUp();
|
|
1212
|
+
}
|
|
1126
1213
|
this.isDestroyed = true;
|
|
1127
1214
|
this.clearAutoHideTimer();
|
|
1128
1215
|
if (this.scrollEndFallbackTimer !== void 0) {
|
|
@@ -1145,6 +1232,11 @@ var __WulfIIFE = (() => {
|
|
|
1145
1232
|
if (this.resizeObserver) {
|
|
1146
1233
|
this.resizeObserver.disconnect();
|
|
1147
1234
|
}
|
|
1235
|
+
if (this.mutationObserver) {
|
|
1236
|
+
this.mutationObserver.disconnect();
|
|
1237
|
+
this.mutationObserver = void 0;
|
|
1238
|
+
}
|
|
1239
|
+
this.observedChildren.clear();
|
|
1148
1240
|
this.trackY?.remove();
|
|
1149
1241
|
this.trackX?.remove();
|
|
1150
1242
|
this.root.classList.remove(
|