wulf.js 1.9.3 → 2.0.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 +118 -78
- package/changelog.md +60 -0
- package/dist/focus-trap.esm.js +202 -136
- package/dist/focus-trap.esm.js.map +3 -3
- package/dist/focus-trap.global.js +203 -137
- 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 +2130 -858
- package/dist/index.esm.js.map +4 -4
- package/dist/index.global.js +2124 -852
- package/dist/index.global.js.map +4 -4
- package/dist/index.global.min.js +4 -4
- 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 +686 -330
- package/dist/mask.esm.js.map +3 -3
- package/dist/mask.global.js +687 -331
- package/dist/mask.global.js.map +3 -3
- package/dist/mask.global.min.js +4 -4
- package/dist/mask.global.min.js.map +4 -4
- package/dist/mask.layered.css +1 -0
- package/dist/mask.layered.css.map +7 -0
- package/dist/masonry.css +1 -1
- package/dist/masonry.css.map +2 -2
- package/dist/masonry.esm.js +248 -77
- package/dist/masonry.esm.js.map +3 -3
- package/dist/masonry.global.js +249 -78
- 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/masonry.layered.css +1 -0
- package/dist/masonry.layered.css.map +7 -0
- package/dist/scroll.css +1 -1
- package/dist/scroll.css.map +2 -2
- package/dist/scroll.esm.js +462 -129
- package/dist/scroll.esm.js.map +3 -3
- package/dist/scroll.global.js +463 -130
- package/dist/scroll.global.js.map +3 -3
- package/dist/scroll.global.min.js +4 -4
- package/dist/scroll.global.min.js.map +4 -4
- package/dist/scroll.layered.css +1 -0
- package/dist/scroll.layered.css.map +7 -0
- package/dist/shortcut.esm.js +164 -48
- package/dist/shortcut.esm.js.map +3 -3
- package/dist/shortcut.global.js +165 -49
- package/dist/shortcut.global.js.map +3 -3
- package/dist/shortcut.global.min.js +2 -2
- 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 +489 -124
- package/dist/toast.esm.js.map +3 -3
- package/dist/toast.global.js +490 -125
- package/dist/toast.global.js.map +3 -3
- package/dist/toast.global.min.js +3 -3
- package/dist/toast.global.min.js.map +4 -4
- package/dist/toast.layered.css +1 -0
- package/dist/toast.layered.css.map +7 -0
- package/dist/types/common/dom.d.ts +38 -0
- package/dist/types/focus-trap/FocusTrap.d.ts +14 -6
- package/dist/types/focus-trap/types.d.ts +2 -2
- package/dist/types/index.d.ts +10 -0
- package/dist/types/mask/BaseInputMask.d.ts +20 -0
- package/dist/types/mask/InputAmountMask.d.ts +2 -0
- package/dist/types/mask/InputEmailMask.d.ts +16 -1
- package/dist/types/mask/MaskEngine.d.ts +4 -0
- package/dist/types/masonry/Masonry.d.ts +10 -3
- package/dist/types/scroll/ScrollBlock.d.ts +31 -3
- package/dist/types/scroll/types.d.ts +13 -1
- package/dist/types/shortcut/ShortcutFormatter.d.ts +6 -0
- package/dist/types/shortcut/ShortcutManager.d.ts +1 -0
- package/dist/types/toast/Toast.d.ts +4 -0
- package/dist/types/toast/ToastInstance.d.ts +22 -10
- package/dist/types/toast/ToastManager.d.ts +37 -4
- package/dist/types/toast/i18n/types.d.ts +2 -0
- package/dist/types/toast/types.d.ts +9 -2
- package/package.json +16 -3
package/dist/masonry.global.js
CHANGED
|
@@ -31,6 +31,79 @@ 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
|
+
|
|
34
107
|
// src/masonry/LayoutEngine.ts
|
|
35
108
|
var LayoutEngine = class {
|
|
36
109
|
/**
|
|
@@ -110,11 +183,13 @@ var __WulfIIFE = (() => {
|
|
|
110
183
|
return Math.min(maxCols, parsed);
|
|
111
184
|
}
|
|
112
185
|
}
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
186
|
+
for (const cls of item.classList) {
|
|
187
|
+
const match = /^(?:span|col-span)-(\d+)$/.exec(cls);
|
|
188
|
+
if (match && match[1]) {
|
|
189
|
+
const parsed = parseInt(match[1], 10);
|
|
190
|
+
if (!isNaN(parsed) && parsed > 0) {
|
|
191
|
+
return Math.min(maxCols, parsed);
|
|
192
|
+
}
|
|
118
193
|
}
|
|
119
194
|
}
|
|
120
195
|
return 1;
|
|
@@ -206,7 +281,10 @@ var __WulfIIFE = (() => {
|
|
|
206
281
|
}
|
|
207
282
|
}
|
|
208
283
|
const itemW = span * colWidth + (span - 1) * gutterX;
|
|
209
|
-
const
|
|
284
|
+
const isRtl = typeof window !== "undefined" && typeof window.getComputedStyle === "function" && window.getComputedStyle(container).direction === "rtl";
|
|
285
|
+
const effectiveWidth = fittedWidth !== void 0 ? fittedWidth : containerWidth;
|
|
286
|
+
const rawX = targetCol * (colWidth + gutterX);
|
|
287
|
+
const targetX = isRtl ? Math.max(0, effectiveWidth - rawX - itemW) : rawX;
|
|
210
288
|
positions.push({
|
|
211
289
|
element: item,
|
|
212
290
|
x: targetX,
|
|
@@ -273,8 +351,11 @@ var __WulfIIFE = (() => {
|
|
|
273
351
|
const rawValue = element.getAttribute(attrName)?.trim();
|
|
274
352
|
if (!rawValue) return false;
|
|
275
353
|
const doc = element.ownerDocument || document;
|
|
354
|
+
const root = typeof element.getRootNode === "function" ? element.getRootNode() : doc;
|
|
276
355
|
const ids = rawValue.split(/\s+/).filter(Boolean);
|
|
277
|
-
const isValid = ids.length > 0 && ids.every(
|
|
356
|
+
const isValid = ids.length > 0 && ids.every(
|
|
357
|
+
(id) => Boolean(typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.getElementById(id) : doc.getElementById(id))
|
|
358
|
+
);
|
|
278
359
|
if (!isValid) {
|
|
279
360
|
warnings.push(
|
|
280
361
|
`Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`
|
|
@@ -286,6 +367,7 @@ var __WulfIIFE = (() => {
|
|
|
286
367
|
|
|
287
368
|
// src/common/LocalizedComponent.ts
|
|
288
369
|
var LocalizedComponent = class extends AuditableComponent {
|
|
370
|
+
static _i18n;
|
|
289
371
|
/**
|
|
290
372
|
* Définit la langue globale du composant (ex: 'fr', 'en', 'es').
|
|
291
373
|
*/
|
|
@@ -336,6 +418,10 @@ var __WulfIIFE = (() => {
|
|
|
336
418
|
static t(key, instanceOverride) {
|
|
337
419
|
return this._i18n ? this._i18n.t(key, instanceOverride) : String(key);
|
|
338
420
|
}
|
|
421
|
+
/**
|
|
422
|
+
* Surcharges de localisation spécifiques à cette instance.
|
|
423
|
+
*/
|
|
424
|
+
i18nOverrides;
|
|
339
425
|
constructor(i18nOverrides) {
|
|
340
426
|
super();
|
|
341
427
|
this.i18nOverrides = i18nOverrides;
|
|
@@ -366,7 +452,7 @@ var __WulfIIFE = (() => {
|
|
|
366
452
|
function assignDefined(target, source) {
|
|
367
453
|
if (!source || typeof source !== "object") return target;
|
|
368
454
|
for (const key of Object.keys(source)) {
|
|
369
|
-
if (isSafeKey(String(key)) && Object.
|
|
455
|
+
if (isSafeKey(String(key)) && Object.hasOwn(source, key) && source[key] !== void 0) {
|
|
370
456
|
target[key] = source[key];
|
|
371
457
|
}
|
|
372
458
|
}
|
|
@@ -427,7 +513,7 @@ var __WulfIIFE = (() => {
|
|
|
427
513
|
if (!isSafeKey(String(key))) {
|
|
428
514
|
return "";
|
|
429
515
|
}
|
|
430
|
-
if (instanceOverride && typeof instanceOverride === "object" && Object.
|
|
516
|
+
if (instanceOverride && typeof instanceOverride === "object" && Object.hasOwn(instanceOverride, key) && instanceOverride[key] !== void 0) {
|
|
431
517
|
return String(instanceOverride[key]);
|
|
432
518
|
}
|
|
433
519
|
if (globalOverrides[key] !== void 0) {
|
|
@@ -485,20 +571,28 @@ var __WulfIIFE = (() => {
|
|
|
485
571
|
|
|
486
572
|
// src/masonry/Masonry.ts
|
|
487
573
|
var Masonry = class extends LocalizedComponent {
|
|
574
|
+
static _i18n = masonryI18n;
|
|
575
|
+
static i18n = masonryI18n;
|
|
576
|
+
root;
|
|
577
|
+
isNativeCSSGrid = false;
|
|
578
|
+
_items = [];
|
|
579
|
+
options;
|
|
580
|
+
resizeObserver = null;
|
|
581
|
+
itemResizeObserver = null;
|
|
582
|
+
observedItems = /* @__PURE__ */ new Set();
|
|
583
|
+
observedItemHeights = /* @__PURE__ */ new WeakMap();
|
|
584
|
+
removingItems = /* @__PURE__ */ new WeakSet();
|
|
585
|
+
layoutRafId = null;
|
|
586
|
+
isDestroyed = false;
|
|
587
|
+
wasRoleInferred = false;
|
|
588
|
+
wasAriaLabelInferred = false;
|
|
589
|
+
hasExplicitAriaLabel = false;
|
|
590
|
+
lastInferredAriaLabel = "";
|
|
591
|
+
abortController = new AbortController();
|
|
592
|
+
watchedImages = /* @__PURE__ */ new WeakSet();
|
|
593
|
+
originalContainerStyles;
|
|
488
594
|
constructor(target, options = {}) {
|
|
489
595
|
super(options.i18n);
|
|
490
|
-
this.isNativeCSSGrid = false;
|
|
491
|
-
this._items = [];
|
|
492
|
-
this.resizeObserver = null;
|
|
493
|
-
this.itemResizeObserver = null;
|
|
494
|
-
this.layoutRafId = null;
|
|
495
|
-
this.isDestroyed = false;
|
|
496
|
-
this.wasRoleInferred = false;
|
|
497
|
-
this.wasAriaLabelInferred = false;
|
|
498
|
-
this.hasExplicitAriaLabel = false;
|
|
499
|
-
this.lastInferredAriaLabel = "";
|
|
500
|
-
this.removeTimers = /* @__PURE__ */ new Set();
|
|
501
|
-
this.pendingImageListeners = [];
|
|
502
596
|
if (typeof target === "string") {
|
|
503
597
|
let el = null;
|
|
504
598
|
try {
|
|
@@ -541,10 +635,11 @@ var __WulfIIFE = (() => {
|
|
|
541
635
|
}),
|
|
542
636
|
audit: options.audit ?? true
|
|
543
637
|
};
|
|
544
|
-
const supportsNativeCSS = typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("grid-template-rows", "masonry");
|
|
638
|
+
const supportsNativeCSS = typeof CSS !== "undefined" && typeof CSS.supports === "function" && (CSS.supports("display", "grid-lanes") || CSS.supports("grid-template-rows", "masonry"));
|
|
545
639
|
if (this.options.useNativeCSSGrid && supportsNativeCSS) {
|
|
546
640
|
this.isNativeCSSGrid = true;
|
|
547
641
|
this.root.classList.add("wulf-masonry", "wulf-masonry--native");
|
|
642
|
+
this.syncNativeGridVariables();
|
|
548
643
|
} else {
|
|
549
644
|
this.root.classList.add("wulf-masonry");
|
|
550
645
|
}
|
|
@@ -568,7 +663,7 @@ var __WulfIIFE = (() => {
|
|
|
568
663
|
this.wasRoleInferred = true;
|
|
569
664
|
}
|
|
570
665
|
const label = this.hasExplicitAriaLabel ? this.options.ariaLabel : this.t("gallery");
|
|
571
|
-
if (label && !this.root.hasAttribute("aria-label")) {
|
|
666
|
+
if (label && !this.root.hasAttribute("aria-label") && !this.root.hasAttribute("aria-labelledby")) {
|
|
572
667
|
this.root.setAttribute("aria-label", label);
|
|
573
668
|
this.lastInferredAriaLabel = label;
|
|
574
669
|
this.wasAriaLabelInferred = true;
|
|
@@ -596,7 +691,7 @@ var __WulfIIFE = (() => {
|
|
|
596
691
|
let durValue = "300ms";
|
|
597
692
|
if (typeof dur === "number" && Number.isFinite(dur) && dur >= 0) {
|
|
598
693
|
durValue = `${dur}ms`;
|
|
599
|
-
} else if (typeof dur === "string" && /^\s
|
|
694
|
+
} else if (typeof dur === "string" && /^\s*(?:\d+(?:\.\d+)?|\.\d+)(ms|s)\s*$/i.test(dur)) {
|
|
600
695
|
durValue = dur.trim();
|
|
601
696
|
}
|
|
602
697
|
this.root.style.setProperty("--wulf-masonry-duration", durValue);
|
|
@@ -609,24 +704,37 @@ var __WulfIIFE = (() => {
|
|
|
609
704
|
let matched = [];
|
|
610
705
|
if (this.options.itemSelector === "> *") {
|
|
611
706
|
matched = Array.from(this.root.children).filter(
|
|
612
|
-
(el) => el instanceof HTMLElement && !el.hasAttribute("data-masonry-ignore")
|
|
707
|
+
(el) => el instanceof HTMLElement && !el.hasAttribute("data-masonry-ignore") && !this.removingItems.has(el)
|
|
613
708
|
);
|
|
614
709
|
} else {
|
|
615
710
|
try {
|
|
616
|
-
|
|
617
|
-
|
|
711
|
+
const rawSelector = this.options.itemSelector.trim();
|
|
712
|
+
const selector = rawSelector.startsWith(">") ? `:scope ${rawSelector}` : rawSelector;
|
|
713
|
+
matched = Array.from(this.root.querySelectorAll(selector)).filter(
|
|
714
|
+
(el) => el.parentElement === this.root && !el.hasAttribute("data-masonry-ignore") && !this.removingItems.has(el)
|
|
618
715
|
);
|
|
619
716
|
} catch {
|
|
620
717
|
matched = Array.from(this.root.children).filter(
|
|
621
|
-
(el) => el instanceof HTMLElement && !el.hasAttribute("data-masonry-ignore")
|
|
718
|
+
(el) => el instanceof HTMLElement && !el.hasAttribute("data-masonry-ignore") && !this.removingItems.has(el)
|
|
622
719
|
);
|
|
623
720
|
}
|
|
624
721
|
}
|
|
722
|
+
if (this.itemResizeObserver) {
|
|
723
|
+
const nextSet = new Set(matched);
|
|
724
|
+
for (const prevEl of this.observedItems) {
|
|
725
|
+
if (!nextSet.has(prevEl)) {
|
|
726
|
+
this.itemResizeObserver.unobserve(prevEl);
|
|
727
|
+
this.observedItems.delete(prevEl);
|
|
728
|
+
this.observedItemHeights.delete(prevEl);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
}
|
|
625
732
|
this._items = matched;
|
|
626
733
|
for (const item of this._items) {
|
|
627
734
|
item.classList.add("wulf-masonry-item");
|
|
628
|
-
if (this.itemResizeObserver) {
|
|
735
|
+
if (this.itemResizeObserver && !this.observedItems.has(item)) {
|
|
629
736
|
this.itemResizeObserver.observe(item);
|
|
737
|
+
this.observedItems.add(item);
|
|
630
738
|
}
|
|
631
739
|
}
|
|
632
740
|
}
|
|
@@ -646,11 +754,52 @@ var __WulfIIFE = (() => {
|
|
|
646
754
|
}
|
|
647
755
|
});
|
|
648
756
|
this.resizeObserver.observe(this.root);
|
|
649
|
-
this.itemResizeObserver = new ResizeObserver(() => {
|
|
650
|
-
|
|
757
|
+
this.itemResizeObserver = new ResizeObserver((entries) => {
|
|
758
|
+
let heightChanged = false;
|
|
759
|
+
for (const entry of entries) {
|
|
760
|
+
const newH = entry.borderBoxSize?.[0]?.blockSize ?? entry.contentRect.height;
|
|
761
|
+
const prevH = this.observedItemHeights.get(entry.target);
|
|
762
|
+
if (prevH === void 0 || Math.abs(newH - prevH) >= 1) {
|
|
763
|
+
this.observedItemHeights.set(entry.target, newH);
|
|
764
|
+
if (prevH !== void 0) {
|
|
765
|
+
heightChanged = true;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
if (heightChanged) {
|
|
770
|
+
this.scheduleLayout();
|
|
771
|
+
}
|
|
651
772
|
});
|
|
652
773
|
for (const item of this._items) {
|
|
653
774
|
this.itemResizeObserver.observe(item);
|
|
775
|
+
this.observedItems.add(item);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* Synchronise les variables CSS du mode natif CSS Grid Level 3 depuis les options JS.
|
|
780
|
+
*/
|
|
781
|
+
syncNativeGridVariables() {
|
|
782
|
+
const { x: gutterX, y: gutterY } = LayoutEngine.parseGutter(this.options.gutter);
|
|
783
|
+
this.root.style.setProperty("--wulf-masonry-gutter-x", `${gutterX}px`);
|
|
784
|
+
this.root.style.setProperty("--wulf-masonry-gutter-y", `${gutterY}px`);
|
|
785
|
+
if (typeof this.options.columnWidth === "number" && Number.isFinite(this.options.columnWidth) && this.options.columnWidth > 0) {
|
|
786
|
+
this.root.style.setProperty("--wulf-masonry-col-min", `${this.options.columnWidth}px`);
|
|
787
|
+
} else if (this.options.columnWidth instanceof HTMLElement) {
|
|
788
|
+
const w = this.options.columnWidth.getBoundingClientRect().width;
|
|
789
|
+
if (w > 0) {
|
|
790
|
+
this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
|
|
791
|
+
}
|
|
792
|
+
} else if (typeof this.options.columnWidth === "string" && this.options.columnWidth.trim()) {
|
|
793
|
+
try {
|
|
794
|
+
const el = this.root.querySelector(this.options.columnWidth);
|
|
795
|
+
if (el) {
|
|
796
|
+
const w = el.getBoundingClientRect().width;
|
|
797
|
+
if (w > 0) {
|
|
798
|
+
this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
} catch {
|
|
802
|
+
}
|
|
654
803
|
}
|
|
655
804
|
}
|
|
656
805
|
/**
|
|
@@ -660,14 +809,12 @@ var __WulfIIFE = (() => {
|
|
|
660
809
|
if (!this.options.autoImages) return;
|
|
661
810
|
const images = Array.from(this.root.querySelectorAll("img"));
|
|
662
811
|
for (const img of images) {
|
|
663
|
-
if (!img.complete) {
|
|
812
|
+
if (!img.complete && !this.watchedImages.has(img)) {
|
|
813
|
+
this.watchedImages.add(img);
|
|
664
814
|
const attachLoadListener = () => {
|
|
665
|
-
|
|
666
|
-
this.pendingImageListeners = this.pendingImageListeners.filter((l) => l.handler !== onLoad);
|
|
815
|
+
img.addEventListener("load", () => {
|
|
667
816
|
if (!this.isDestroyed) this.scheduleLayout();
|
|
668
|
-
};
|
|
669
|
-
this.pendingImageListeners.push({ img, handler: onLoad });
|
|
670
|
-
img.addEventListener("load", onLoad, { once: true });
|
|
817
|
+
}, { once: true, signal: this.abortController.signal });
|
|
671
818
|
};
|
|
672
819
|
if (typeof img.decode === "function") {
|
|
673
820
|
img.decode().then(() => {
|
|
@@ -701,10 +848,17 @@ var __WulfIIFE = (() => {
|
|
|
701
848
|
if (this.isDestroyed) return;
|
|
702
849
|
this.syncAccessibilityLabels();
|
|
703
850
|
if (this.isNativeCSSGrid) {
|
|
851
|
+
this.syncNativeGridVariables();
|
|
852
|
+
for (const el of this._items) {
|
|
853
|
+
el.classList.remove("wulf-masonry-item--hidden");
|
|
854
|
+
}
|
|
704
855
|
this.options.onLayout([]);
|
|
705
856
|
return;
|
|
706
857
|
}
|
|
707
858
|
this.root.setAttribute("aria-busy", "true");
|
|
859
|
+
if (this.options.fitWidth && this.root.classList.contains("wulf-masonry--fit-width")) {
|
|
860
|
+
this.root.style.width = "";
|
|
861
|
+
}
|
|
708
862
|
const result = LayoutEngine.calculate(this.root, this._items, this.options);
|
|
709
863
|
this.root.style.height = `${result.containerHeight}px`;
|
|
710
864
|
if (this.options.fitWidth && result.fittedWidth !== void 0) {
|
|
@@ -714,6 +868,14 @@ var __WulfIIFE = (() => {
|
|
|
714
868
|
this.root.classList.remove("wulf-masonry--fit-width");
|
|
715
869
|
}
|
|
716
870
|
const stagger = this.options.stagger;
|
|
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)");
|
|
717
879
|
const usePercent = this.options.percentPosition && result.containerWidth > 0;
|
|
718
880
|
for (let i = 0; i < result.positions.length; i++) {
|
|
719
881
|
const pos = result.positions[i];
|
|
@@ -726,12 +888,13 @@ var __WulfIIFE = (() => {
|
|
|
726
888
|
}
|
|
727
889
|
item.style.setProperty("--wulf-masonry-x", `${pos.x}px`);
|
|
728
890
|
item.style.setProperty("--wulf-masonry-y", `${pos.y}px`);
|
|
729
|
-
if (
|
|
730
|
-
item.style.
|
|
891
|
+
if (validStagger && !supportsSiblingIndex) {
|
|
892
|
+
item.style.setProperty("--wulf-masonry-index", String(i));
|
|
731
893
|
} else {
|
|
732
|
-
item.style.removeProperty("
|
|
894
|
+
item.style.removeProperty("--wulf-masonry-index");
|
|
733
895
|
}
|
|
734
896
|
item.classList.remove("wulf-masonry-item--hidden");
|
|
897
|
+
this.observedItemHeights.set(item, pos.height);
|
|
735
898
|
this.options.onItemPlaced(item, pos);
|
|
736
899
|
}
|
|
737
900
|
this.root.setAttribute("aria-busy", "false");
|
|
@@ -746,7 +909,11 @@ var __WulfIIFE = (() => {
|
|
|
746
909
|
if (list.length === 0) return;
|
|
747
910
|
const frag = document.createDocumentFragment();
|
|
748
911
|
for (const el of list) {
|
|
749
|
-
|
|
912
|
+
if (this.isNativeCSSGrid) {
|
|
913
|
+
el.classList.add("wulf-masonry-item");
|
|
914
|
+
} else {
|
|
915
|
+
el.classList.add("wulf-masonry-item", "wulf-masonry-item--hidden");
|
|
916
|
+
}
|
|
750
917
|
frag.appendChild(el);
|
|
751
918
|
}
|
|
752
919
|
this.root.appendChild(frag);
|
|
@@ -764,7 +931,11 @@ var __WulfIIFE = (() => {
|
|
|
764
931
|
const first = this.root.firstChild;
|
|
765
932
|
const frag = document.createDocumentFragment();
|
|
766
933
|
for (const el of list) {
|
|
767
|
-
|
|
934
|
+
if (this.isNativeCSSGrid) {
|
|
935
|
+
el.classList.add("wulf-masonry-item");
|
|
936
|
+
} else {
|
|
937
|
+
el.classList.add("wulf-masonry-item", "wulf-masonry-item--hidden");
|
|
938
|
+
}
|
|
768
939
|
frag.appendChild(el);
|
|
769
940
|
}
|
|
770
941
|
this.root.insertBefore(frag, first);
|
|
@@ -773,44 +944,51 @@ var __WulfIIFE = (() => {
|
|
|
773
944
|
this.layout();
|
|
774
945
|
}
|
|
775
946
|
/**
|
|
776
|
-
* Supprime des éléments avec animation de fondu/sortie.
|
|
947
|
+
* Supprime des éléments avec animation de fondu/sortie synchronisée via Web Animations API.
|
|
777
948
|
*/
|
|
778
949
|
remove(elements) {
|
|
779
950
|
if (this.isDestroyed) return;
|
|
780
951
|
const list = Array.isArray(elements) ? elements : [elements];
|
|
781
952
|
if (list.length === 0) return;
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
}
|
|
785
|
-
const dur = typeof this.options.transitionDuration === "number" ? this.options.transitionDuration : 300;
|
|
786
|
-
if (dur <= 0) {
|
|
953
|
+
const finalizeRemoval = () => {
|
|
954
|
+
if (this.isDestroyed) return;
|
|
787
955
|
for (const el of list) {
|
|
956
|
+
this.removingItems.delete(el);
|
|
788
957
|
if (el.parentElement === this.root) {
|
|
789
958
|
if (this.itemResizeObserver) {
|
|
790
959
|
this.itemResizeObserver.unobserve(el);
|
|
960
|
+
this.observedItems.delete(el);
|
|
961
|
+
this.observedItemHeights.delete(el);
|
|
791
962
|
}
|
|
792
963
|
this.root.removeChild(el);
|
|
793
964
|
}
|
|
794
965
|
}
|
|
795
966
|
this.reloadItems();
|
|
796
967
|
this.layout();
|
|
968
|
+
};
|
|
969
|
+
for (const el of list) {
|
|
970
|
+
this.removingItems.add(el);
|
|
971
|
+
if (typeof document !== "undefined" && document.activeElement && el.contains(document.activeElement)) {
|
|
972
|
+
document.activeElement.blur?.();
|
|
973
|
+
}
|
|
974
|
+
el.setAttribute("inert", "");
|
|
975
|
+
el.style.transitionDelay = "0ms";
|
|
976
|
+
el.classList.add("wulf-masonry-item--hidden");
|
|
977
|
+
}
|
|
978
|
+
const dur = parseCssDurationMs(this.options.transitionDuration, 300);
|
|
979
|
+
if (dur <= 0 || this.isNativeCSSGrid) {
|
|
980
|
+
finalizeRemoval();
|
|
797
981
|
return;
|
|
798
982
|
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
}
|
|
807
|
-
this.root.removeChild(el);
|
|
808
|
-
}
|
|
983
|
+
this.reloadItems();
|
|
984
|
+
this.layout();
|
|
985
|
+
Promise.all(
|
|
986
|
+
list.map((el) => waitForAnimations(el, dur, this.abortController.signal))
|
|
987
|
+
).then(() => {
|
|
988
|
+
if (!this.abortController.signal.aborted) {
|
|
989
|
+
finalizeRemoval();
|
|
809
990
|
}
|
|
810
|
-
|
|
811
|
-
this.layout();
|
|
812
|
-
}, dur);
|
|
813
|
-
this.removeTimers.add(timerId);
|
|
991
|
+
});
|
|
814
992
|
}
|
|
815
993
|
/**
|
|
816
994
|
* Vérifie la conformité d'accessibilité WAI-ARIA de la grille Masonry
|
|
@@ -847,14 +1025,7 @@ var __WulfIIFE = (() => {
|
|
|
847
1025
|
destroy() {
|
|
848
1026
|
if (this.isDestroyed) return;
|
|
849
1027
|
this.isDestroyed = true;
|
|
850
|
-
|
|
851
|
-
clearTimeout(timerId);
|
|
852
|
-
}
|
|
853
|
-
this.removeTimers.clear();
|
|
854
|
-
for (const { img, handler } of this.pendingImageListeners) {
|
|
855
|
-
img.removeEventListener("load", handler);
|
|
856
|
-
}
|
|
857
|
-
this.pendingImageListeners = [];
|
|
1028
|
+
this.abortController.abort();
|
|
858
1029
|
if (this.layoutRafId !== null) {
|
|
859
1030
|
cancelAnimationFrame(this.layoutRafId);
|
|
860
1031
|
this.layoutRafId = null;
|
|
@@ -876,6 +1047,10 @@ var __WulfIIFE = (() => {
|
|
|
876
1047
|
this.root.removeAttribute("aria-label");
|
|
877
1048
|
}
|
|
878
1049
|
this.root.style.removeProperty("--wulf-masonry-duration");
|
|
1050
|
+
this.root.style.removeProperty("--wulf-masonry-stagger");
|
|
1051
|
+
this.root.style.removeProperty("--wulf-masonry-col-min");
|
|
1052
|
+
this.root.style.removeProperty("--wulf-masonry-gutter-x");
|
|
1053
|
+
this.root.style.removeProperty("--wulf-masonry-gutter-y");
|
|
879
1054
|
if (this.originalContainerStyles.height) {
|
|
880
1055
|
this.root.style.height = this.originalContainerStyles.height;
|
|
881
1056
|
} else {
|
|
@@ -891,20 +1066,16 @@ var __WulfIIFE = (() => {
|
|
|
891
1066
|
item.style.removeProperty("--wulf-masonry-w");
|
|
892
1067
|
item.style.removeProperty("--wulf-masonry-x");
|
|
893
1068
|
item.style.removeProperty("--wulf-masonry-y");
|
|
894
|
-
item.style.removeProperty("
|
|
1069
|
+
item.style.removeProperty("--wulf-masonry-index");
|
|
895
1070
|
}
|
|
896
1071
|
this._items = [];
|
|
897
1072
|
}
|
|
898
1073
|
};
|
|
899
|
-
Masonry._i18n = masonryI18n;
|
|
900
|
-
Masonry.i18n = masonryI18n;
|
|
901
1074
|
|
|
902
1075
|
// src/masonry/index.ts
|
|
903
1076
|
var index_default = Masonry;
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
const wulfNamespace = win.Wulf || {};
|
|
907
|
-
win.Wulf = wulfNamespace;
|
|
1077
|
+
var wulfNamespace = getSafeWulfNamespace();
|
|
1078
|
+
if (wulfNamespace) {
|
|
908
1079
|
wulfNamespace.Masonry = Object.assign(Masonry, {
|
|
909
1080
|
Masonry,
|
|
910
1081
|
LayoutEngine,
|
|
@@ -913,5 +1084,5 @@ var __WulfIIFE = (() => {
|
|
|
913
1084
|
}
|
|
914
1085
|
return __toCommonJS(index_exports);
|
|
915
1086
|
})();
|
|
916
|
-
if (typeof window !== "undefined") {
|
|
1087
|
+
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 __WulfIIFE) { if (Object.hasOwn(__WulfIIFE, k) && k !== "__proto__" && k !== "constructor" && k !== "prototype" && __w[k] === undefined) { try { Object.defineProperty(__w, k, { value: __WulfIIFE[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { __w[k] = __WulfIIFE[k]; } catch (__) {} } } } } }
|
|
917
1088
|
//# sourceMappingURL=masonry.global.js.map
|