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/masonry.global.js
CHANGED
|
@@ -43,6 +43,14 @@ var __WulfIIFE = (() => {
|
|
|
43
43
|
}
|
|
44
44
|
return existing;
|
|
45
45
|
}
|
|
46
|
+
function getDeepActiveElement(root) {
|
|
47
|
+
if (typeof document === "undefined") return null;
|
|
48
|
+
let active = (root ?? document).activeElement;
|
|
49
|
+
while (active && active.shadowRoot && active.shadowRoot.activeElement) {
|
|
50
|
+
active = active.shadowRoot.activeElement;
|
|
51
|
+
}
|
|
52
|
+
return active && typeof active.focus === "function" ? active : null;
|
|
53
|
+
}
|
|
46
54
|
function parseCssDurationMs(duration, fallbackMs = 300, maxMs = 6e4) {
|
|
47
55
|
const safeFallback = Number.isFinite(fallbackMs) && fallbackMs >= 0 ? Math.min(fallbackMs, maxMs) : 300;
|
|
48
56
|
if (typeof duration === "number") {
|
|
@@ -228,9 +236,10 @@ var __WulfIIFE = (() => {
|
|
|
228
236
|
const colHeights = new Array(cols).fill(0);
|
|
229
237
|
const positions = [];
|
|
230
238
|
const itemHeights = items.map((item) => {
|
|
231
|
-
const h = item.getBoundingClientRect().height;
|
|
239
|
+
const h = item.classList.contains("wulf-masonry-item--hidden") && item.offsetHeight > 0 ? item.offsetHeight : item.getBoundingClientRect().height;
|
|
232
240
|
return h > 0 ? h : 50;
|
|
233
241
|
});
|
|
242
|
+
const isRtl = typeof window !== "undefined" && typeof window.getComputedStyle === "function" && window.getComputedStyle(container).direction === "rtl";
|
|
234
243
|
let currentHCol = 0;
|
|
235
244
|
for (let i = 0; i < items.length; i++) {
|
|
236
245
|
const item = items[i];
|
|
@@ -281,7 +290,6 @@ var __WulfIIFE = (() => {
|
|
|
281
290
|
}
|
|
282
291
|
}
|
|
283
292
|
const itemW = span * colWidth + (span - 1) * gutterX;
|
|
284
|
-
const isRtl = typeof window !== "undefined" && typeof window.getComputedStyle === "function" && window.getComputedStyle(container).direction === "rtl";
|
|
285
293
|
const effectiveWidth = fittedWidth !== void 0 ? fittedWidth : containerWidth;
|
|
286
294
|
const rawX = targetCol * (colWidth + gutterX);
|
|
287
295
|
const targetX = isRtl ? Math.max(0, effectiveWidth - rawX - itemW) : rawX;
|
|
@@ -344,24 +352,39 @@ var __WulfIIFE = (() => {
|
|
|
344
352
|
return warnings;
|
|
345
353
|
}
|
|
346
354
|
/**
|
|
347
|
-
* Vérifie si un attribut de référence d'IDs ARIA (ex: aria-labelledby, aria-describedby)
|
|
348
|
-
* pointe vers des éléments réellement présents dans le document.
|
|
355
|
+
* Vérifie si un attribut de référence d'IDs ARIA (ex: aria-labelledby, aria-describedby, aria-errormessage)
|
|
356
|
+
* pointe vers des éléments réellement présents dans le document (et optionnellement non vides).
|
|
349
357
|
*/
|
|
350
|
-
checkAriaIdReferences(element, attrName, warnings) {
|
|
358
|
+
checkAriaIdReferences(element, attrName, warnings, requireNonEmptyText = false) {
|
|
351
359
|
const rawValue = element.getAttribute(attrName)?.trim();
|
|
352
360
|
if (!rawValue) return false;
|
|
353
361
|
const doc = element.ownerDocument || document;
|
|
354
362
|
const root = typeof element.getRootNode === "function" ? element.getRootNode() : doc;
|
|
355
363
|
const ids = rawValue.split(/\s+/).filter(Boolean);
|
|
356
|
-
const
|
|
357
|
-
(id) =>
|
|
364
|
+
const targets = ids.map(
|
|
365
|
+
(id) => typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.getElementById(id) : doc.getElementById(id)
|
|
358
366
|
);
|
|
359
|
-
|
|
367
|
+
const allFound = ids.length > 0 && targets.every((el) => Boolean(el));
|
|
368
|
+
if (!allFound) {
|
|
360
369
|
warnings.push(
|
|
361
370
|
`Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`
|
|
362
371
|
);
|
|
372
|
+
return false;
|
|
363
373
|
}
|
|
364
|
-
|
|
374
|
+
if (requireNonEmptyText) {
|
|
375
|
+
const hasNonEmptyText = targets.some((el) => {
|
|
376
|
+
if (!el) return false;
|
|
377
|
+
const text = el.textContent?.trim() || el.getAttribute("aria-label")?.trim() || "";
|
|
378
|
+
return text.length > 0;
|
|
379
|
+
});
|
|
380
|
+
if (!hasNonEmptyText) {
|
|
381
|
+
warnings.push(
|
|
382
|
+
`Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible ne contient aucun texte accessible.`
|
|
383
|
+
);
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return true;
|
|
365
388
|
}
|
|
366
389
|
};
|
|
367
390
|
|
|
@@ -570,6 +593,7 @@ var __WulfIIFE = (() => {
|
|
|
570
593
|
});
|
|
571
594
|
|
|
572
595
|
// src/masonry/Masonry.ts
|
|
596
|
+
var NATIVE_STRUCTURAL_TAGS = /* @__PURE__ */ new Set(["UL", "OL", "MAIN", "NAV", "ASIDE", "ARTICLE", "SECTION"]);
|
|
573
597
|
var Masonry = class extends LocalizedComponent {
|
|
574
598
|
static _i18n = masonryI18n;
|
|
575
599
|
static i18n = masonryI18n;
|
|
@@ -581,9 +605,11 @@ var __WulfIIFE = (() => {
|
|
|
581
605
|
itemResizeObserver = null;
|
|
582
606
|
observedItems = /* @__PURE__ */ new Set();
|
|
583
607
|
observedItemHeights = /* @__PURE__ */ new WeakMap();
|
|
584
|
-
removingItems = /* @__PURE__ */ new
|
|
608
|
+
removingItems = /* @__PURE__ */ new Set();
|
|
585
609
|
layoutRafId = null;
|
|
610
|
+
lastObservedWidth = 0;
|
|
586
611
|
isDestroyed = false;
|
|
612
|
+
hasExplicitAriaRole = false;
|
|
587
613
|
wasRoleInferred = false;
|
|
588
614
|
wasAriaLabelInferred = false;
|
|
589
615
|
hasExplicitAriaLabel = false;
|
|
@@ -613,6 +639,7 @@ var __WulfIIFE = (() => {
|
|
|
613
639
|
height: this.root.style.height,
|
|
614
640
|
width: this.root.style.width
|
|
615
641
|
};
|
|
642
|
+
this.hasExplicitAriaRole = Boolean(options.ariaRole);
|
|
616
643
|
this.hasExplicitAriaLabel = Boolean(options.ariaLabel || options.i18n?.gallery);
|
|
617
644
|
this.options = {
|
|
618
645
|
itemSelector: options.itemSelector || "> *",
|
|
@@ -658,7 +685,7 @@ var __WulfIIFE = (() => {
|
|
|
658
685
|
* Initialise les attributs WAI-ARIA du conteneur.
|
|
659
686
|
*/
|
|
660
687
|
initAccessibility() {
|
|
661
|
-
if (this.options.ariaRole && !this.root.hasAttribute("role")) {
|
|
688
|
+
if (this.options.ariaRole && !this.root.hasAttribute("role") && (this.hasExplicitAriaRole || !NATIVE_STRUCTURAL_TAGS.has(this.root.tagName))) {
|
|
662
689
|
this.root.setAttribute("role", this.options.ariaRole);
|
|
663
690
|
this.wasRoleInferred = true;
|
|
664
691
|
}
|
|
@@ -690,9 +717,10 @@ var __WulfIIFE = (() => {
|
|
|
690
717
|
const dur = this.options.transitionDuration;
|
|
691
718
|
let durValue = "300ms";
|
|
692
719
|
if (typeof dur === "number" && Number.isFinite(dur) && dur >= 0) {
|
|
693
|
-
durValue = `${dur}ms`;
|
|
720
|
+
durValue = `${Math.min(dur, 6e4)}ms`;
|
|
694
721
|
} else if (typeof dur === "string" && /^\s*(?:\d+(?:\.\d+)?|\.\d+)(ms|s)\s*$/i.test(dur)) {
|
|
695
|
-
|
|
722
|
+
const parsedMs = parseCssDurationMs(dur, 300, 6e4);
|
|
723
|
+
durValue = parsedMs >= 6e4 ? "60000ms" : dur.trim();
|
|
696
724
|
}
|
|
697
725
|
this.root.style.setProperty("--wulf-masonry-duration", durValue);
|
|
698
726
|
}
|
|
@@ -743,12 +771,12 @@ var __WulfIIFE = (() => {
|
|
|
743
771
|
*/
|
|
744
772
|
initObservers() {
|
|
745
773
|
if (!this.options.resize || typeof ResizeObserver === "undefined") return;
|
|
746
|
-
|
|
774
|
+
this.lastObservedWidth = this.root.getBoundingClientRect().width;
|
|
747
775
|
this.resizeObserver = new ResizeObserver((entries) => {
|
|
748
776
|
for (const entry of entries) {
|
|
749
777
|
const currentWidth = entry.contentRect.width;
|
|
750
|
-
if (Math.abs(currentWidth -
|
|
751
|
-
|
|
778
|
+
if (Math.abs(currentWidth - this.lastObservedWidth) >= 1) {
|
|
779
|
+
this.lastObservedWidth = currentWidth;
|
|
752
780
|
this.scheduleLayout();
|
|
753
781
|
}
|
|
754
782
|
}
|
|
@@ -790,15 +818,23 @@ var __WulfIIFE = (() => {
|
|
|
790
818
|
this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
|
|
791
819
|
}
|
|
792
820
|
} else if (typeof this.options.columnWidth === "string" && this.options.columnWidth.trim()) {
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
821
|
+
const trimmed = this.options.columnWidth.trim();
|
|
822
|
+
if (/^\d+(\.\d+)?(px|%)?$/i.test(trimmed)) {
|
|
823
|
+
const w = LayoutEngine.resolveColumnWidth(this.root, null, trimmed);
|
|
824
|
+
if (w > 0) {
|
|
825
|
+
this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
|
|
826
|
+
}
|
|
827
|
+
} else {
|
|
828
|
+
try {
|
|
829
|
+
const el = this.root.querySelector(trimmed);
|
|
830
|
+
if (el) {
|
|
831
|
+
const w = el.getBoundingClientRect().width;
|
|
832
|
+
if (w > 0) {
|
|
833
|
+
this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
|
|
834
|
+
}
|
|
799
835
|
}
|
|
836
|
+
} catch {
|
|
800
837
|
}
|
|
801
|
-
} catch {
|
|
802
838
|
}
|
|
803
839
|
}
|
|
804
840
|
}
|
|
@@ -852,60 +888,80 @@ var __WulfIIFE = (() => {
|
|
|
852
888
|
for (const el of this._items) {
|
|
853
889
|
el.classList.remove("wulf-masonry-item--hidden");
|
|
854
890
|
}
|
|
855
|
-
|
|
891
|
+
try {
|
|
892
|
+
this.options.onLayout([]);
|
|
893
|
+
} catch (err) {
|
|
894
|
+
console.error("[Wulf.Masonry] Erreur dans onLayout:", err);
|
|
895
|
+
}
|
|
856
896
|
return;
|
|
857
897
|
}
|
|
858
898
|
this.root.setAttribute("aria-busy", "true");
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
this.root.
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
const validStagger = typeof stagger === "number" && Number.isFinite(stagger) && stagger > 0;
|
|
872
|
-
if (validStagger) {
|
|
873
|
-
this.root.style.setProperty("--wulf-masonry-stagger", `${stagger}ms`);
|
|
874
|
-
} else {
|
|
875
|
-
this.root.style.removeProperty("--wulf-masonry-stagger");
|
|
876
|
-
}
|
|
877
|
-
const hasIgnoredChildren = this._items.length !== this.root.children.length;
|
|
878
|
-
const supportsSiblingIndex = !hasIgnoredChildren && typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("transition-delay", "calc(sibling-index() * 1ms)");
|
|
879
|
-
const usePercent = this.options.percentPosition && result.containerWidth > 0;
|
|
880
|
-
for (let i = 0; i < result.positions.length; i++) {
|
|
881
|
-
const pos = result.positions[i];
|
|
882
|
-
const item = pos.element;
|
|
883
|
-
if (usePercent) {
|
|
884
|
-
const wPct = Number((pos.width / result.containerWidth * 100).toFixed(4));
|
|
885
|
-
item.style.setProperty("--wulf-masonry-w", `${wPct}%`);
|
|
899
|
+
let positionsResult = [];
|
|
900
|
+
try {
|
|
901
|
+
if (this.options.fitWidth && this.root.classList.contains("wulf-masonry--fit-width")) {
|
|
902
|
+
this.root.style.width = "";
|
|
903
|
+
}
|
|
904
|
+
const result = LayoutEngine.calculate(this.root, this._items, this.options);
|
|
905
|
+
positionsResult = result.positions;
|
|
906
|
+
this.root.style.height = `${result.containerHeight}px`;
|
|
907
|
+
if (this.options.fitWidth && result.fittedWidth !== void 0) {
|
|
908
|
+
this.root.style.width = `${result.fittedWidth}px`;
|
|
909
|
+
this.lastObservedWidth = result.fittedWidth;
|
|
910
|
+
this.root.classList.add("wulf-masonry--fit-width");
|
|
886
911
|
} else {
|
|
887
|
-
|
|
912
|
+
this.root.classList.remove("wulf-masonry--fit-width");
|
|
888
913
|
}
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
if (validStagger
|
|
892
|
-
|
|
914
|
+
const stagger = this.options.stagger;
|
|
915
|
+
const validStagger = typeof stagger === "number" && Number.isFinite(stagger) && stagger > 0;
|
|
916
|
+
if (validStagger) {
|
|
917
|
+
this.root.style.setProperty("--wulf-masonry-stagger", `${stagger}ms`);
|
|
893
918
|
} else {
|
|
894
|
-
|
|
919
|
+
this.root.style.removeProperty("--wulf-masonry-stagger");
|
|
895
920
|
}
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
this.options.
|
|
921
|
+
const hasIgnoredChildren = this._items.length !== this.root.children.length;
|
|
922
|
+
const supportsSiblingIndex = !hasIgnoredChildren && typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("transition-delay", "calc(sibling-index() * 1ms)");
|
|
923
|
+
const usePercent = this.options.percentPosition && result.containerWidth > 0;
|
|
924
|
+
for (let i = 0; i < result.positions.length; i++) {
|
|
925
|
+
const pos = result.positions[i];
|
|
926
|
+
const item = pos.element;
|
|
927
|
+
if (usePercent) {
|
|
928
|
+
const wPct = Number((pos.width / result.containerWidth * 100).toFixed(4));
|
|
929
|
+
item.style.setProperty("--wulf-masonry-w", `${wPct}%`);
|
|
930
|
+
} else {
|
|
931
|
+
item.style.setProperty("--wulf-masonry-w", `${pos.width}px`);
|
|
932
|
+
}
|
|
933
|
+
item.style.setProperty("--wulf-masonry-x", `${pos.x}px`);
|
|
934
|
+
item.style.setProperty("--wulf-masonry-y", `${pos.y}px`);
|
|
935
|
+
if (validStagger && !supportsSiblingIndex) {
|
|
936
|
+
item.style.setProperty("--wulf-masonry-index", String(i));
|
|
937
|
+
} else {
|
|
938
|
+
item.style.removeProperty("--wulf-masonry-index");
|
|
939
|
+
}
|
|
940
|
+
item.classList.remove("wulf-masonry-item--hidden");
|
|
941
|
+
this.observedItemHeights.set(item, pos.height);
|
|
942
|
+
try {
|
|
943
|
+
this.options.onItemPlaced(item, pos);
|
|
944
|
+
} catch (err) {
|
|
945
|
+
console.error("[Wulf.Masonry] Erreur dans onItemPlaced:", err);
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
} finally {
|
|
949
|
+
this.root.setAttribute("aria-busy", "false");
|
|
950
|
+
}
|
|
951
|
+
try {
|
|
952
|
+
this.options.onLayout(positionsResult);
|
|
953
|
+
} catch (err) {
|
|
954
|
+
console.error("[Wulf.Masonry] Erreur dans onLayout:", err);
|
|
899
955
|
}
|
|
900
|
-
this.root.setAttribute("aria-busy", "false");
|
|
901
|
-
this.options.onLayout(result.positions);
|
|
902
956
|
}
|
|
903
957
|
/**
|
|
904
958
|
* Ajoute de nouveaux éléments à la fin du conteneur.
|
|
905
959
|
*/
|
|
906
960
|
append(elements) {
|
|
907
961
|
if (this.isDestroyed) return;
|
|
908
|
-
const list = Array.isArray(elements) ? elements : [elements]
|
|
962
|
+
const list = (Array.isArray(elements) ? elements : [elements]).filter(
|
|
963
|
+
(el) => el instanceof HTMLElement && !el.contains(this.root)
|
|
964
|
+
);
|
|
909
965
|
if (list.length === 0) return;
|
|
910
966
|
const frag = document.createDocumentFragment();
|
|
911
967
|
for (const el of list) {
|
|
@@ -926,7 +982,9 @@ var __WulfIIFE = (() => {
|
|
|
926
982
|
*/
|
|
927
983
|
prepend(elements) {
|
|
928
984
|
if (this.isDestroyed) return;
|
|
929
|
-
const list = Array.isArray(elements) ? elements : [elements]
|
|
985
|
+
const list = (Array.isArray(elements) ? elements : [elements]).filter(
|
|
986
|
+
(el) => el instanceof HTMLElement && !el.contains(this.root)
|
|
987
|
+
);
|
|
930
988
|
if (list.length === 0) return;
|
|
931
989
|
const first = this.root.firstChild;
|
|
932
990
|
const frag = document.createDocumentFragment();
|
|
@@ -948,7 +1006,9 @@ var __WulfIIFE = (() => {
|
|
|
948
1006
|
*/
|
|
949
1007
|
remove(elements) {
|
|
950
1008
|
if (this.isDestroyed) return;
|
|
951
|
-
const list = Array.isArray(elements) ? elements : [elements]
|
|
1009
|
+
const list = (Array.isArray(elements) ? elements : [elements]).filter(
|
|
1010
|
+
(el) => el instanceof HTMLElement
|
|
1011
|
+
);
|
|
952
1012
|
if (list.length === 0) return;
|
|
953
1013
|
const finalizeRemoval = () => {
|
|
954
1014
|
if (this.isDestroyed) return;
|
|
@@ -966,11 +1026,34 @@ var __WulfIIFE = (() => {
|
|
|
966
1026
|
this.reloadItems();
|
|
967
1027
|
this.layout();
|
|
968
1028
|
};
|
|
1029
|
+
const activeEl = getDeepActiveElement();
|
|
1030
|
+
if (activeEl && list.some((el) => el.contains(activeEl))) {
|
|
1031
|
+
const removeSet = new Set(list);
|
|
1032
|
+
const firstRemovedIdx = this._items.findIndex((item) => removeSet.has(item));
|
|
1033
|
+
const survivorsAfter = firstRemovedIdx >= 0 ? this._items.slice(firstRemovedIdx + 1).filter((item) => !removeSet.has(item)) : [];
|
|
1034
|
+
const survivorsBefore = firstRemovedIdx > 0 ? this._items.slice(0, firstRemovedIdx).filter((item) => !removeSet.has(item)).reverse() : [];
|
|
1035
|
+
const candidateItem = survivorsAfter[0] || survivorsBefore[0] || null;
|
|
1036
|
+
let handoffDone = false;
|
|
1037
|
+
if (candidateItem) {
|
|
1038
|
+
const focusableChild = candidateItem.querySelector(
|
|
1039
|
+
'a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
|
|
1040
|
+
);
|
|
1041
|
+
const focusTarget = focusableChild || (candidateItem.tabIndex >= 0 ? candidateItem : null);
|
|
1042
|
+
if (focusTarget) {
|
|
1043
|
+
try {
|
|
1044
|
+
focusTarget.focus({ preventScroll: true });
|
|
1045
|
+
handoffDone = true;
|
|
1046
|
+
} catch {
|
|
1047
|
+
handoffDone = false;
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
if (!handoffDone) {
|
|
1052
|
+
activeEl.blur?.();
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
969
1055
|
for (const el of list) {
|
|
970
1056
|
this.removingItems.add(el);
|
|
971
|
-
if (typeof document !== "undefined" && document.activeElement && el.contains(document.activeElement)) {
|
|
972
|
-
document.activeElement.blur?.();
|
|
973
|
-
}
|
|
974
1057
|
el.setAttribute("inert", "");
|
|
975
1058
|
el.style.transitionDelay = "0ms";
|
|
976
1059
|
el.classList.add("wulf-masonry-item--hidden");
|
|
@@ -996,7 +1079,7 @@ var __WulfIIFE = (() => {
|
|
|
996
1079
|
*/
|
|
997
1080
|
audit() {
|
|
998
1081
|
const warnings = [];
|
|
999
|
-
const hasValidLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings);
|
|
1082
|
+
const hasValidLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings, true);
|
|
1000
1083
|
const hasCustomRootAriaLabel = !this.wasAriaLabelInferred && Boolean(this.root.getAttribute("aria-label")?.trim());
|
|
1001
1084
|
if (!this.hasExplicitAriaLabel && !hasCustomRootAriaLabel && !hasValidLabelledby) {
|
|
1002
1085
|
warnings.push(
|
|
@@ -1011,6 +1094,19 @@ var __WulfIIFE = (() => {
|
|
|
1011
1094
|
`${imagesWithoutAlt.length} image(s) <img> d\xE9pourvue(s) d'attribut alt : renseignez alt="description" (ou alt="" si d\xE9corative) (WCAG 1.1.1).`
|
|
1012
1095
|
);
|
|
1013
1096
|
}
|
|
1097
|
+
const positiveTabIndexEls = Array.from(this.root.querySelectorAll("[tabindex]")).filter(
|
|
1098
|
+
(el) => el.tabIndex > 0
|
|
1099
|
+
);
|
|
1100
|
+
if (positiveTabIndexEls.length > 0) {
|
|
1101
|
+
warnings.push(
|
|
1102
|
+
`${positiveTabIndexEls.length} \xE9l\xE9ment(s) avec tabindex > 0 d\xE9tect\xE9(s) : utilisez uniquement tabindex="0" ou "-1" (WCAG 2.4.3).`
|
|
1103
|
+
);
|
|
1104
|
+
}
|
|
1105
|
+
if (!this.options.horizontalOrder && this.root.querySelector('a[href], button, input, select, textarea, [tabindex="0"]') !== null) {
|
|
1106
|
+
warnings.push(
|
|
1107
|
+
"Grille interactive avec horizontalOrder: false : l'ordre visuel peut diverger de l'ordre de tabulation ; envisagez horizontalOrder: true (WCAG 1.3.2 / 2.4.3)."
|
|
1108
|
+
);
|
|
1109
|
+
}
|
|
1014
1110
|
return warnings;
|
|
1015
1111
|
}
|
|
1016
1112
|
getAuditPrefix() {
|
|
@@ -1061,6 +1157,16 @@ var __WulfIIFE = (() => {
|
|
|
1061
1157
|
} else {
|
|
1062
1158
|
this.root.style.removeProperty("width");
|
|
1063
1159
|
}
|
|
1160
|
+
for (const item of this.removingItems) {
|
|
1161
|
+
item.removeAttribute("inert");
|
|
1162
|
+
item.style.removeProperty("transition-delay");
|
|
1163
|
+
item.classList.remove("wulf-masonry-item", "wulf-masonry-item--hidden");
|
|
1164
|
+
item.style.removeProperty("--wulf-masonry-w");
|
|
1165
|
+
item.style.removeProperty("--wulf-masonry-x");
|
|
1166
|
+
item.style.removeProperty("--wulf-masonry-y");
|
|
1167
|
+
item.style.removeProperty("--wulf-masonry-index");
|
|
1168
|
+
}
|
|
1169
|
+
this.removingItems.clear();
|
|
1064
1170
|
for (const item of this._items) {
|
|
1065
1171
|
item.classList.remove("wulf-masonry-item", "wulf-masonry-item--hidden");
|
|
1066
1172
|
item.style.removeProperty("--wulf-masonry-w");
|