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/masonry.global.js
CHANGED
|
@@ -31,79 +31,6 @@ var __WulfIIFE = (() => {
|
|
|
31
31
|
masonryI18n: () => masonryI18n
|
|
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 parseCssDurationMs(duration, fallbackMs = 300, maxMs = 6e4) {
|
|
47
|
-
const safeFallback = Number.isFinite(fallbackMs) && fallbackMs >= 0 ? Math.min(fallbackMs, maxMs) : 300;
|
|
48
|
-
if (typeof duration === "number") {
|
|
49
|
-
return Number.isFinite(duration) && duration >= 0 ? Math.min(duration, maxMs) : safeFallback;
|
|
50
|
-
}
|
|
51
|
-
if (typeof duration === "string") {
|
|
52
|
-
const parts = duration.split(",");
|
|
53
|
-
let maxParsed = -1;
|
|
54
|
-
for (const part of parts) {
|
|
55
|
-
const match = /^\+?(\d+(?:\.\d+)?|\.\d+)(ms|s)?$/i.exec(part.trim());
|
|
56
|
-
if (match) {
|
|
57
|
-
const raw = parseFloat(match[1]);
|
|
58
|
-
if (Number.isFinite(raw) && raw >= 0) {
|
|
59
|
-
const ms = match[2]?.toLowerCase() === "s" ? raw * 1e3 : raw;
|
|
60
|
-
if (ms > maxParsed) {
|
|
61
|
-
maxParsed = ms;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (maxParsed >= 0) {
|
|
67
|
-
return Math.min(maxParsed, maxMs);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return safeFallback;
|
|
71
|
-
}
|
|
72
|
-
function prefersReducedMotion() {
|
|
73
|
-
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
74
|
-
}
|
|
75
|
-
function waitForAnimations(element, fallbackMs, signal) {
|
|
76
|
-
const safeFallback = Number.isFinite(fallbackMs) ? Math.min(fallbackMs, 6e4) : 300;
|
|
77
|
-
if (signal?.aborted || safeFallback <= 0 || prefersReducedMotion()) {
|
|
78
|
-
return Promise.resolve();
|
|
79
|
-
}
|
|
80
|
-
const animations = typeof element.getAnimations === "function" ? element.getAnimations().filter((a) => {
|
|
81
|
-
if (a.playState !== "running") return false;
|
|
82
|
-
const timing = a.effect?.getComputedTiming?.();
|
|
83
|
-
return timing ? Number.isFinite(timing.endTime) : true;
|
|
84
|
-
}) : [];
|
|
85
|
-
if (animations.length === 0) {
|
|
86
|
-
return Promise.resolve();
|
|
87
|
-
}
|
|
88
|
-
return new Promise((resolve) => {
|
|
89
|
-
let settled = false;
|
|
90
|
-
let timerId = null;
|
|
91
|
-
const finish = () => {
|
|
92
|
-
if (settled) return;
|
|
93
|
-
settled = true;
|
|
94
|
-
if (timerId !== null) {
|
|
95
|
-
clearTimeout(timerId);
|
|
96
|
-
timerId = null;
|
|
97
|
-
}
|
|
98
|
-
signal?.removeEventListener("abort", finish);
|
|
99
|
-
resolve();
|
|
100
|
-
};
|
|
101
|
-
signal?.addEventListener("abort", finish, { once: true });
|
|
102
|
-
timerId = setTimeout(finish, safeFallback);
|
|
103
|
-
Promise.allSettled(animations.map((a) => a.finished)).then(finish);
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
34
|
// src/masonry/LayoutEngine.ts
|
|
108
35
|
var LayoutEngine = class {
|
|
109
36
|
/**
|
|
@@ -228,9 +155,10 @@ var __WulfIIFE = (() => {
|
|
|
228
155
|
const colHeights = new Array(cols).fill(0);
|
|
229
156
|
const positions = [];
|
|
230
157
|
const itemHeights = items.map((item) => {
|
|
231
|
-
const h = item.getBoundingClientRect().height;
|
|
158
|
+
const h = item.classList.contains("wulf-masonry-item--hidden") && item.offsetHeight > 0 ? item.offsetHeight : item.getBoundingClientRect().height;
|
|
232
159
|
return h > 0 ? h : 50;
|
|
233
160
|
});
|
|
161
|
+
const isRtl = typeof window !== "undefined" && typeof window.getComputedStyle === "function" && window.getComputedStyle(container).direction === "rtl";
|
|
234
162
|
let currentHCol = 0;
|
|
235
163
|
for (let i = 0; i < items.length; i++) {
|
|
236
164
|
const item = items[i];
|
|
@@ -281,7 +209,6 @@ var __WulfIIFE = (() => {
|
|
|
281
209
|
}
|
|
282
210
|
}
|
|
283
211
|
const itemW = span * colWidth + (span - 1) * gutterX;
|
|
284
|
-
const isRtl = typeof window !== "undefined" && typeof window.getComputedStyle === "function" && window.getComputedStyle(container).direction === "rtl";
|
|
285
212
|
const effectiveWidth = fittedWidth !== void 0 ? fittedWidth : containerWidth;
|
|
286
213
|
const rawX = targetCol * (colWidth + gutterX);
|
|
287
214
|
const targetX = isRtl ? Math.max(0, effectiveWidth - rawX - itemW) : rawX;
|
|
@@ -450,6 +377,76 @@ var __WulfIIFE = (() => {
|
|
|
450
377
|
}
|
|
451
378
|
};
|
|
452
379
|
|
|
380
|
+
// src/common/dom.ts
|
|
381
|
+
function getDeepActiveElement(root) {
|
|
382
|
+
if (typeof document === "undefined") return null;
|
|
383
|
+
let active = (root ?? document).activeElement;
|
|
384
|
+
while (active && active.shadowRoot && active.shadowRoot.activeElement) {
|
|
385
|
+
active = active.shadowRoot.activeElement;
|
|
386
|
+
}
|
|
387
|
+
return active && typeof active.focus === "function" ? active : null;
|
|
388
|
+
}
|
|
389
|
+
function parseCssDurationMs(duration, fallbackMs = 300, maxMs = 6e4) {
|
|
390
|
+
const safeFallback = Number.isFinite(fallbackMs) && fallbackMs >= 0 ? Math.min(fallbackMs, maxMs) : 300;
|
|
391
|
+
if (typeof duration === "number") {
|
|
392
|
+
return Number.isFinite(duration) && duration >= 0 ? Math.min(duration, maxMs) : safeFallback;
|
|
393
|
+
}
|
|
394
|
+
if (typeof duration === "string") {
|
|
395
|
+
const parts = duration.split(",");
|
|
396
|
+
let maxParsed = -1;
|
|
397
|
+
for (const part of parts) {
|
|
398
|
+
const match = /^\+?(\d+(?:\.\d+)?|\.\d+)(ms|s)?$/i.exec(part.trim());
|
|
399
|
+
if (match) {
|
|
400
|
+
const raw = parseFloat(match[1]);
|
|
401
|
+
if (Number.isFinite(raw) && raw >= 0) {
|
|
402
|
+
const ms = match[2]?.toLowerCase() === "s" ? raw * 1e3 : raw;
|
|
403
|
+
if (ms > maxParsed) {
|
|
404
|
+
maxParsed = ms;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
if (maxParsed >= 0) {
|
|
410
|
+
return Math.min(maxParsed, maxMs);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return safeFallback;
|
|
414
|
+
}
|
|
415
|
+
function prefersReducedMotion() {
|
|
416
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
417
|
+
}
|
|
418
|
+
function waitForAnimations(element, fallbackMs, signal) {
|
|
419
|
+
const safeFallback = Number.isFinite(fallbackMs) ? Math.min(fallbackMs, 6e4) : 300;
|
|
420
|
+
if (signal?.aborted || safeFallback <= 0 || prefersReducedMotion()) {
|
|
421
|
+
return Promise.resolve();
|
|
422
|
+
}
|
|
423
|
+
const animations = typeof element.getAnimations === "function" ? element.getAnimations().filter((a) => {
|
|
424
|
+
if (a.playState !== "running") return false;
|
|
425
|
+
const timing = a.effect?.getComputedTiming?.();
|
|
426
|
+
return timing ? Number.isFinite(timing.endTime) : true;
|
|
427
|
+
}) : [];
|
|
428
|
+
if (animations.length === 0) {
|
|
429
|
+
return Promise.resolve();
|
|
430
|
+
}
|
|
431
|
+
return new Promise((resolve) => {
|
|
432
|
+
let settled = false;
|
|
433
|
+
let timerId = null;
|
|
434
|
+
const finish = () => {
|
|
435
|
+
if (settled) return;
|
|
436
|
+
settled = true;
|
|
437
|
+
if (timerId !== null) {
|
|
438
|
+
clearTimeout(timerId);
|
|
439
|
+
timerId = null;
|
|
440
|
+
}
|
|
441
|
+
signal?.removeEventListener("abort", finish);
|
|
442
|
+
resolve();
|
|
443
|
+
};
|
|
444
|
+
signal?.addEventListener("abort", finish, { once: true });
|
|
445
|
+
timerId = setTimeout(finish, safeFallback);
|
|
446
|
+
Promise.allSettled(animations.map((a) => a.finished)).then(finish);
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
|
|
453
450
|
// src/common/i18n.ts
|
|
454
451
|
var FORBIDDEN_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
455
452
|
function isSafeKey(key) {
|
|
@@ -585,6 +582,7 @@ var __WulfIIFE = (() => {
|
|
|
585
582
|
});
|
|
586
583
|
|
|
587
584
|
// src/masonry/Masonry.ts
|
|
585
|
+
var NATIVE_STRUCTURAL_TAGS = /* @__PURE__ */ new Set(["UL", "OL", "MAIN", "NAV", "ASIDE", "ARTICLE", "SECTION"]);
|
|
588
586
|
var Masonry = class extends LocalizedComponent {
|
|
589
587
|
static _i18n = masonryI18n;
|
|
590
588
|
static i18n = masonryI18n;
|
|
@@ -596,9 +594,11 @@ var __WulfIIFE = (() => {
|
|
|
596
594
|
itemResizeObserver = null;
|
|
597
595
|
observedItems = /* @__PURE__ */ new Set();
|
|
598
596
|
observedItemHeights = /* @__PURE__ */ new WeakMap();
|
|
599
|
-
removingItems = /* @__PURE__ */ new
|
|
597
|
+
removingItems = /* @__PURE__ */ new Set();
|
|
600
598
|
layoutRafId = null;
|
|
599
|
+
lastObservedWidth = 0;
|
|
601
600
|
isDestroyed = false;
|
|
601
|
+
hasExplicitAriaRole = false;
|
|
602
602
|
wasRoleInferred = false;
|
|
603
603
|
wasAriaLabelInferred = false;
|
|
604
604
|
hasExplicitAriaLabel = false;
|
|
@@ -609,6 +609,9 @@ var __WulfIIFE = (() => {
|
|
|
609
609
|
constructor(target, options = {}) {
|
|
610
610
|
super(options.i18n);
|
|
611
611
|
if (typeof target === "string") {
|
|
612
|
+
if (typeof document === "undefined") {
|
|
613
|
+
throw new Error("[Wulf.Masonry] Impossible de r\xE9soudre un s\xE9lecteur CSS sans environnement DOM (document).");
|
|
614
|
+
}
|
|
612
615
|
let el = null;
|
|
613
616
|
try {
|
|
614
617
|
el = document.querySelector(target);
|
|
@@ -619,7 +622,7 @@ var __WulfIIFE = (() => {
|
|
|
619
622
|
throw new Error(`[Wulf.Masonry] Conteneur introuvable pour le s\xE9lecteur : "${target}"`);
|
|
620
623
|
}
|
|
621
624
|
this.root = el;
|
|
622
|
-
} else if (target instanceof HTMLElement) {
|
|
625
|
+
} else if (typeof HTMLElement !== "undefined" && target instanceof HTMLElement) {
|
|
623
626
|
this.root = target;
|
|
624
627
|
} else {
|
|
625
628
|
throw new Error("[Wulf.Masonry] Cible invalide : fournissez un \xE9l\xE9ment HTMLElement ou un s\xE9lecteur valide.");
|
|
@@ -628,6 +631,7 @@ var __WulfIIFE = (() => {
|
|
|
628
631
|
height: this.root.style.height,
|
|
629
632
|
width: this.root.style.width
|
|
630
633
|
};
|
|
634
|
+
this.hasExplicitAriaRole = Boolean(options.ariaRole);
|
|
631
635
|
this.hasExplicitAriaLabel = Boolean(options.ariaLabel || options.i18n?.gallery);
|
|
632
636
|
this.options = {
|
|
633
637
|
itemSelector: options.itemSelector || "> *",
|
|
@@ -673,7 +677,7 @@ var __WulfIIFE = (() => {
|
|
|
673
677
|
* Initialise les attributs WAI-ARIA du conteneur.
|
|
674
678
|
*/
|
|
675
679
|
initAccessibility() {
|
|
676
|
-
if (this.options.ariaRole && !this.root.hasAttribute("role")) {
|
|
680
|
+
if (this.options.ariaRole && !this.root.hasAttribute("role") && (this.hasExplicitAriaRole || !NATIVE_STRUCTURAL_TAGS.has(this.root.tagName))) {
|
|
677
681
|
this.root.setAttribute("role", this.options.ariaRole);
|
|
678
682
|
this.wasRoleInferred = true;
|
|
679
683
|
}
|
|
@@ -705,9 +709,10 @@ var __WulfIIFE = (() => {
|
|
|
705
709
|
const dur = this.options.transitionDuration;
|
|
706
710
|
let durValue = "300ms";
|
|
707
711
|
if (typeof dur === "number" && Number.isFinite(dur) && dur >= 0) {
|
|
708
|
-
durValue = `${dur}ms`;
|
|
712
|
+
durValue = `${Math.min(dur, 6e4)}ms`;
|
|
709
713
|
} else if (typeof dur === "string" && /^\s*(?:\d+(?:\.\d+)?|\.\d+)(ms|s)\s*$/i.test(dur)) {
|
|
710
|
-
|
|
714
|
+
const parsedMs = parseCssDurationMs(dur, 300, 6e4);
|
|
715
|
+
durValue = parsedMs >= 6e4 ? "60000ms" : dur.trim();
|
|
711
716
|
}
|
|
712
717
|
this.root.style.setProperty("--wulf-masonry-duration", durValue);
|
|
713
718
|
}
|
|
@@ -758,12 +763,12 @@ var __WulfIIFE = (() => {
|
|
|
758
763
|
*/
|
|
759
764
|
initObservers() {
|
|
760
765
|
if (!this.options.resize || typeof ResizeObserver === "undefined") return;
|
|
761
|
-
|
|
766
|
+
this.lastObservedWidth = this.root.getBoundingClientRect().width;
|
|
762
767
|
this.resizeObserver = new ResizeObserver((entries) => {
|
|
763
768
|
for (const entry of entries) {
|
|
764
769
|
const currentWidth = entry.contentRect.width;
|
|
765
|
-
if (Math.abs(currentWidth -
|
|
766
|
-
|
|
770
|
+
if (Math.abs(currentWidth - this.lastObservedWidth) >= 1) {
|
|
771
|
+
this.lastObservedWidth = currentWidth;
|
|
767
772
|
this.scheduleLayout();
|
|
768
773
|
}
|
|
769
774
|
}
|
|
@@ -805,15 +810,23 @@ var __WulfIIFE = (() => {
|
|
|
805
810
|
this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
|
|
806
811
|
}
|
|
807
812
|
} else if (typeof this.options.columnWidth === "string" && this.options.columnWidth.trim()) {
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
813
|
+
const trimmed = this.options.columnWidth.trim();
|
|
814
|
+
if (/^\d+(\.\d+)?(px|%)?$/i.test(trimmed)) {
|
|
815
|
+
const w = LayoutEngine.resolveColumnWidth(this.root, null, trimmed);
|
|
816
|
+
if (w > 0) {
|
|
817
|
+
this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
|
|
818
|
+
}
|
|
819
|
+
} else {
|
|
820
|
+
try {
|
|
821
|
+
const el = this.root.querySelector(trimmed);
|
|
822
|
+
if (el) {
|
|
823
|
+
const w = el.getBoundingClientRect().width;
|
|
824
|
+
if (w > 0) {
|
|
825
|
+
this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
|
|
826
|
+
}
|
|
814
827
|
}
|
|
828
|
+
} catch {
|
|
815
829
|
}
|
|
816
|
-
} catch {
|
|
817
830
|
}
|
|
818
831
|
}
|
|
819
832
|
}
|
|
@@ -848,10 +861,14 @@ var __WulfIIFE = (() => {
|
|
|
848
861
|
*/
|
|
849
862
|
scheduleLayout() {
|
|
850
863
|
if (this.isDestroyed) return;
|
|
864
|
+
if (typeof window === "undefined" || typeof window.requestAnimationFrame !== "function") {
|
|
865
|
+
this.layout();
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
851
868
|
if (this.layoutRafId !== null) {
|
|
852
|
-
cancelAnimationFrame(this.layoutRafId);
|
|
869
|
+
window.cancelAnimationFrame(this.layoutRafId);
|
|
853
870
|
}
|
|
854
|
-
this.layoutRafId = requestAnimationFrame(() => {
|
|
871
|
+
this.layoutRafId = window.requestAnimationFrame(() => {
|
|
855
872
|
this.layoutRafId = null;
|
|
856
873
|
this.layout();
|
|
857
874
|
});
|
|
@@ -867,60 +884,80 @@ var __WulfIIFE = (() => {
|
|
|
867
884
|
for (const el of this._items) {
|
|
868
885
|
el.classList.remove("wulf-masonry-item--hidden");
|
|
869
886
|
}
|
|
870
|
-
|
|
887
|
+
try {
|
|
888
|
+
this.options.onLayout([]);
|
|
889
|
+
} catch (err) {
|
|
890
|
+
console.error("[Wulf.Masonry] Erreur dans onLayout:", err);
|
|
891
|
+
}
|
|
871
892
|
return;
|
|
872
893
|
}
|
|
873
894
|
this.root.setAttribute("aria-busy", "true");
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
this.root.
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
const validStagger = typeof stagger === "number" && Number.isFinite(stagger) && stagger > 0;
|
|
887
|
-
if (validStagger) {
|
|
888
|
-
this.root.style.setProperty("--wulf-masonry-stagger", `${stagger}ms`);
|
|
889
|
-
} else {
|
|
890
|
-
this.root.style.removeProperty("--wulf-masonry-stagger");
|
|
891
|
-
}
|
|
892
|
-
const hasIgnoredChildren = this._items.length !== this.root.children.length;
|
|
893
|
-
const supportsSiblingIndex = !hasIgnoredChildren && typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("transition-delay", "calc(sibling-index() * 1ms)");
|
|
894
|
-
const usePercent = this.options.percentPosition && result.containerWidth > 0;
|
|
895
|
-
for (let i = 0; i < result.positions.length; i++) {
|
|
896
|
-
const pos = result.positions[i];
|
|
897
|
-
const item = pos.element;
|
|
898
|
-
if (usePercent) {
|
|
899
|
-
const wPct = Number((pos.width / result.containerWidth * 100).toFixed(4));
|
|
900
|
-
item.style.setProperty("--wulf-masonry-w", `${wPct}%`);
|
|
895
|
+
let positionsResult = [];
|
|
896
|
+
try {
|
|
897
|
+
if (this.options.fitWidth && this.root.classList.contains("wulf-masonry--fit-width")) {
|
|
898
|
+
this.root.style.width = "";
|
|
899
|
+
}
|
|
900
|
+
const result = LayoutEngine.calculate(this.root, this._items, this.options);
|
|
901
|
+
positionsResult = result.positions;
|
|
902
|
+
this.root.style.height = `${result.containerHeight}px`;
|
|
903
|
+
if (this.options.fitWidth && result.fittedWidth !== void 0) {
|
|
904
|
+
this.root.style.width = `${result.fittedWidth}px`;
|
|
905
|
+
this.lastObservedWidth = result.fittedWidth;
|
|
906
|
+
this.root.classList.add("wulf-masonry--fit-width");
|
|
901
907
|
} else {
|
|
902
|
-
|
|
908
|
+
this.root.classList.remove("wulf-masonry--fit-width");
|
|
903
909
|
}
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
if (validStagger
|
|
907
|
-
|
|
910
|
+
const stagger = this.options.stagger;
|
|
911
|
+
const validStagger = typeof stagger === "number" && Number.isFinite(stagger) && stagger > 0;
|
|
912
|
+
if (validStagger) {
|
|
913
|
+
this.root.style.setProperty("--wulf-masonry-stagger", `${stagger}ms`);
|
|
908
914
|
} else {
|
|
909
|
-
|
|
915
|
+
this.root.style.removeProperty("--wulf-masonry-stagger");
|
|
910
916
|
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
this.options.
|
|
917
|
+
const hasIgnoredChildren = this._items.length !== this.root.children.length;
|
|
918
|
+
const supportsSiblingIndex = !hasIgnoredChildren && typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("transition-delay", "calc(sibling-index() * 1ms)");
|
|
919
|
+
const usePercent = this.options.percentPosition && result.containerWidth > 0;
|
|
920
|
+
for (let i = 0; i < result.positions.length; i++) {
|
|
921
|
+
const pos = result.positions[i];
|
|
922
|
+
const item = pos.element;
|
|
923
|
+
if (usePercent) {
|
|
924
|
+
const wPct = Number((pos.width / result.containerWidth * 100).toFixed(4));
|
|
925
|
+
item.style.setProperty("--wulf-masonry-w", `${wPct}%`);
|
|
926
|
+
} else {
|
|
927
|
+
item.style.setProperty("--wulf-masonry-w", `${pos.width}px`);
|
|
928
|
+
}
|
|
929
|
+
item.style.setProperty("--wulf-masonry-x", `${pos.x}px`);
|
|
930
|
+
item.style.setProperty("--wulf-masonry-y", `${pos.y}px`);
|
|
931
|
+
if (validStagger && !supportsSiblingIndex) {
|
|
932
|
+
item.style.setProperty("--wulf-masonry-index", String(i));
|
|
933
|
+
} else {
|
|
934
|
+
item.style.removeProperty("--wulf-masonry-index");
|
|
935
|
+
}
|
|
936
|
+
item.classList.remove("wulf-masonry-item--hidden");
|
|
937
|
+
this.observedItemHeights.set(item, pos.height);
|
|
938
|
+
try {
|
|
939
|
+
this.options.onItemPlaced(item, pos);
|
|
940
|
+
} catch (err) {
|
|
941
|
+
console.error("[Wulf.Masonry] Erreur dans onItemPlaced:", err);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
} finally {
|
|
945
|
+
this.root.setAttribute("aria-busy", "false");
|
|
946
|
+
}
|
|
947
|
+
try {
|
|
948
|
+
this.options.onLayout(positionsResult);
|
|
949
|
+
} catch (err) {
|
|
950
|
+
console.error("[Wulf.Masonry] Erreur dans onLayout:", err);
|
|
914
951
|
}
|
|
915
|
-
this.root.setAttribute("aria-busy", "false");
|
|
916
|
-
this.options.onLayout(result.positions);
|
|
917
952
|
}
|
|
918
953
|
/**
|
|
919
954
|
* Ajoute de nouveaux éléments à la fin du conteneur.
|
|
920
955
|
*/
|
|
921
956
|
append(elements) {
|
|
922
957
|
if (this.isDestroyed) return;
|
|
923
|
-
const list = Array.isArray(elements) ? elements : [elements]
|
|
958
|
+
const list = (Array.isArray(elements) ? elements : [elements]).filter(
|
|
959
|
+
(el) => el instanceof HTMLElement && !el.contains(this.root)
|
|
960
|
+
);
|
|
924
961
|
if (list.length === 0) return;
|
|
925
962
|
const frag = document.createDocumentFragment();
|
|
926
963
|
for (const el of list) {
|
|
@@ -941,7 +978,9 @@ var __WulfIIFE = (() => {
|
|
|
941
978
|
*/
|
|
942
979
|
prepend(elements) {
|
|
943
980
|
if (this.isDestroyed) return;
|
|
944
|
-
const list = Array.isArray(elements) ? elements : [elements]
|
|
981
|
+
const list = (Array.isArray(elements) ? elements : [elements]).filter(
|
|
982
|
+
(el) => el instanceof HTMLElement && !el.contains(this.root)
|
|
983
|
+
);
|
|
945
984
|
if (list.length === 0) return;
|
|
946
985
|
const first = this.root.firstChild;
|
|
947
986
|
const frag = document.createDocumentFragment();
|
|
@@ -963,7 +1002,9 @@ var __WulfIIFE = (() => {
|
|
|
963
1002
|
*/
|
|
964
1003
|
remove(elements) {
|
|
965
1004
|
if (this.isDestroyed) return;
|
|
966
|
-
const list = Array.isArray(elements) ? elements : [elements]
|
|
1005
|
+
const list = (Array.isArray(elements) ? elements : [elements]).filter(
|
|
1006
|
+
(el) => el instanceof HTMLElement
|
|
1007
|
+
);
|
|
967
1008
|
if (list.length === 0) return;
|
|
968
1009
|
const finalizeRemoval = () => {
|
|
969
1010
|
if (this.isDestroyed) return;
|
|
@@ -981,11 +1022,34 @@ var __WulfIIFE = (() => {
|
|
|
981
1022
|
this.reloadItems();
|
|
982
1023
|
this.layout();
|
|
983
1024
|
};
|
|
1025
|
+
const activeEl = getDeepActiveElement();
|
|
1026
|
+
if (activeEl && list.some((el) => el.contains(activeEl))) {
|
|
1027
|
+
const removeSet = new Set(list);
|
|
1028
|
+
const firstRemovedIdx = this._items.findIndex((item) => removeSet.has(item));
|
|
1029
|
+
const survivorsAfter = firstRemovedIdx >= 0 ? this._items.slice(firstRemovedIdx + 1).filter((item) => !removeSet.has(item)) : [];
|
|
1030
|
+
const survivorsBefore = firstRemovedIdx > 0 ? this._items.slice(0, firstRemovedIdx).filter((item) => !removeSet.has(item)).reverse() : [];
|
|
1031
|
+
const candidateItem = survivorsAfter[0] || survivorsBefore[0] || null;
|
|
1032
|
+
let handoffDone = false;
|
|
1033
|
+
if (candidateItem) {
|
|
1034
|
+
const focusableChild = candidateItem.querySelector(
|
|
1035
|
+
'a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
|
|
1036
|
+
);
|
|
1037
|
+
const focusTarget = focusableChild || (candidateItem.tabIndex >= 0 ? candidateItem : null);
|
|
1038
|
+
if (focusTarget) {
|
|
1039
|
+
try {
|
|
1040
|
+
focusTarget.focus({ preventScroll: true });
|
|
1041
|
+
handoffDone = true;
|
|
1042
|
+
} catch {
|
|
1043
|
+
handoffDone = false;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
if (!handoffDone) {
|
|
1048
|
+
activeEl.blur?.();
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
984
1051
|
for (const el of list) {
|
|
985
1052
|
this.removingItems.add(el);
|
|
986
|
-
if (typeof document !== "undefined" && document.activeElement && el.contains(document.activeElement)) {
|
|
987
|
-
document.activeElement.blur?.();
|
|
988
|
-
}
|
|
989
1053
|
el.setAttribute("inert", "");
|
|
990
1054
|
el.style.transitionDelay = "0ms";
|
|
991
1055
|
el.classList.add("wulf-masonry-item--hidden");
|
|
@@ -1011,7 +1075,7 @@ var __WulfIIFE = (() => {
|
|
|
1011
1075
|
*/
|
|
1012
1076
|
audit() {
|
|
1013
1077
|
const warnings = [];
|
|
1014
|
-
const hasValidLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings);
|
|
1078
|
+
const hasValidLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings, true);
|
|
1015
1079
|
const hasCustomRootAriaLabel = !this.wasAriaLabelInferred && Boolean(this.root.getAttribute("aria-label")?.trim());
|
|
1016
1080
|
if (!this.hasExplicitAriaLabel && !hasCustomRootAriaLabel && !hasValidLabelledby) {
|
|
1017
1081
|
warnings.push(
|
|
@@ -1026,6 +1090,19 @@ var __WulfIIFE = (() => {
|
|
|
1026
1090
|
`${imagesWithoutAlt.length} image(s) <img> d\xE9pourvue(s) d'attribut alt : renseignez alt="description" (ou alt="" si d\xE9corative) (WCAG 1.1.1).`
|
|
1027
1091
|
);
|
|
1028
1092
|
}
|
|
1093
|
+
const positiveTabIndexEls = Array.from(this.root.querySelectorAll("[tabindex]")).filter(
|
|
1094
|
+
(el) => el.tabIndex > 0
|
|
1095
|
+
);
|
|
1096
|
+
if (positiveTabIndexEls.length > 0) {
|
|
1097
|
+
warnings.push(
|
|
1098
|
+
`${positiveTabIndexEls.length} \xE9l\xE9ment(s) avec tabindex > 0 d\xE9tect\xE9(s) : utilisez uniquement tabindex="0" ou "-1" (WCAG 2.4.3).`
|
|
1099
|
+
);
|
|
1100
|
+
}
|
|
1101
|
+
if (!this.options.horizontalOrder && this.root.querySelector('a[href], button, input, select, textarea, [tabindex="0"]') !== null) {
|
|
1102
|
+
warnings.push(
|
|
1103
|
+
"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)."
|
|
1104
|
+
);
|
|
1105
|
+
}
|
|
1029
1106
|
return warnings;
|
|
1030
1107
|
}
|
|
1031
1108
|
getAuditPrefix() {
|
|
@@ -1042,7 +1119,9 @@ var __WulfIIFE = (() => {
|
|
|
1042
1119
|
this.isDestroyed = true;
|
|
1043
1120
|
this.abortController.abort();
|
|
1044
1121
|
if (this.layoutRafId !== null) {
|
|
1045
|
-
|
|
1122
|
+
if (typeof window !== "undefined" && typeof window.cancelAnimationFrame === "function") {
|
|
1123
|
+
window.cancelAnimationFrame(this.layoutRafId);
|
|
1124
|
+
}
|
|
1046
1125
|
this.layoutRafId = null;
|
|
1047
1126
|
}
|
|
1048
1127
|
if (this.resizeObserver) {
|
|
@@ -1076,6 +1155,16 @@ var __WulfIIFE = (() => {
|
|
|
1076
1155
|
} else {
|
|
1077
1156
|
this.root.style.removeProperty("width");
|
|
1078
1157
|
}
|
|
1158
|
+
for (const item of this.removingItems) {
|
|
1159
|
+
item.removeAttribute("inert");
|
|
1160
|
+
item.style.removeProperty("transition-delay");
|
|
1161
|
+
item.classList.remove("wulf-masonry-item", "wulf-masonry-item--hidden");
|
|
1162
|
+
item.style.removeProperty("--wulf-masonry-w");
|
|
1163
|
+
item.style.removeProperty("--wulf-masonry-x");
|
|
1164
|
+
item.style.removeProperty("--wulf-masonry-y");
|
|
1165
|
+
item.style.removeProperty("--wulf-masonry-index");
|
|
1166
|
+
}
|
|
1167
|
+
this.removingItems.clear();
|
|
1079
1168
|
for (const item of this._items) {
|
|
1080
1169
|
item.classList.remove("wulf-masonry-item", "wulf-masonry-item--hidden");
|
|
1081
1170
|
item.style.removeProperty("--wulf-masonry-w");
|
|
@@ -1089,15 +1178,7 @@ var __WulfIIFE = (() => {
|
|
|
1089
1178
|
|
|
1090
1179
|
// src/masonry/index.ts
|
|
1091
1180
|
var index_default = Masonry;
|
|
1092
|
-
var wulfNamespace = getSafeWulfNamespace();
|
|
1093
|
-
if (wulfNamespace) {
|
|
1094
|
-
wulfNamespace.Masonry = Object.assign(Masonry, {
|
|
1095
|
-
Masonry,
|
|
1096
|
-
LayoutEngine,
|
|
1097
|
-
i18n: masonryI18n
|
|
1098
|
-
});
|
|
1099
|
-
}
|
|
1100
1181
|
return __toCommonJS(index_exports);
|
|
1101
1182
|
})();
|
|
1102
|
-
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; } if (typeof __WulfIIFE !== "undefined" && __WulfIIFE) { for (var k in
|
|
1183
|
+
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.Masonry) __set(__w, "Masonry", Object.assign(__e.Masonry, { Masonry: __e.Masonry, LayoutEngine: __e.LayoutEngine, i18n: __e.masonryI18n })); }}
|
|
1103
1184
|
//# sourceMappingURL=masonry.global.js.map
|