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.esm.js
CHANGED
|
@@ -1,1075 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (typeof duration === "number") {
|
|
16
|
-
return Number.isFinite(duration) && duration >= 0 ? Math.min(duration, maxMs) : safeFallback;
|
|
17
|
-
}
|
|
18
|
-
if (typeof duration === "string") {
|
|
19
|
-
const parts = duration.split(",");
|
|
20
|
-
let maxParsed = -1;
|
|
21
|
-
for (const part of parts) {
|
|
22
|
-
const match = /^\+?(\d+(?:\.\d+)?|\.\d+)(ms|s)?$/i.exec(part.trim());
|
|
23
|
-
if (match) {
|
|
24
|
-
const raw = parseFloat(match[1]);
|
|
25
|
-
if (Number.isFinite(raw) && raw >= 0) {
|
|
26
|
-
const ms = match[2]?.toLowerCase() === "s" ? raw * 1e3 : raw;
|
|
27
|
-
if (ms > maxParsed) {
|
|
28
|
-
maxParsed = ms;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (maxParsed >= 0) {
|
|
34
|
-
return Math.min(maxParsed, maxMs);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return safeFallback;
|
|
38
|
-
}
|
|
39
|
-
function prefersReducedMotion() {
|
|
40
|
-
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
41
|
-
}
|
|
42
|
-
function waitForAnimations(element, fallbackMs, signal) {
|
|
43
|
-
const safeFallback = Number.isFinite(fallbackMs) ? Math.min(fallbackMs, 6e4) : 300;
|
|
44
|
-
if (signal?.aborted || safeFallback <= 0 || prefersReducedMotion()) {
|
|
45
|
-
return Promise.resolve();
|
|
46
|
-
}
|
|
47
|
-
const animations = typeof element.getAnimations === "function" ? element.getAnimations().filter((a) => {
|
|
48
|
-
if (a.playState !== "running") return false;
|
|
49
|
-
const timing = a.effect?.getComputedTiming?.();
|
|
50
|
-
return timing ? Number.isFinite(timing.endTime) : true;
|
|
51
|
-
}) : [];
|
|
52
|
-
if (animations.length === 0) {
|
|
53
|
-
return Promise.resolve();
|
|
54
|
-
}
|
|
55
|
-
return new Promise((resolve) => {
|
|
56
|
-
let settled = false;
|
|
57
|
-
let timerId = null;
|
|
58
|
-
const finish = () => {
|
|
59
|
-
if (settled) return;
|
|
60
|
-
settled = true;
|
|
61
|
-
if (timerId !== null) {
|
|
62
|
-
clearTimeout(timerId);
|
|
63
|
-
timerId = null;
|
|
64
|
-
}
|
|
65
|
-
signal?.removeEventListener("abort", finish);
|
|
66
|
-
resolve();
|
|
67
|
-
};
|
|
68
|
-
signal?.addEventListener("abort", finish, { once: true });
|
|
69
|
-
timerId = setTimeout(finish, safeFallback);
|
|
70
|
-
Promise.allSettled(animations.map((a) => a.finished)).then(finish);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// src/masonry/LayoutEngine.ts
|
|
75
|
-
var LayoutEngine = class {
|
|
76
|
-
/**
|
|
77
|
-
* Normalise les gouttières horizontales et verticales.
|
|
78
|
-
*/
|
|
79
|
-
static parseGutter(gutterOption) {
|
|
80
|
-
if (typeof gutterOption === "number") {
|
|
81
|
-
const v = Number.isFinite(gutterOption) ? Math.max(0, gutterOption) : 0;
|
|
82
|
-
return { x: v, y: v };
|
|
83
|
-
}
|
|
84
|
-
if (gutterOption && typeof gutterOption === "object") {
|
|
85
|
-
const rawX = Number(gutterOption.x);
|
|
86
|
-
const rawY = Number(gutterOption.y);
|
|
87
|
-
return {
|
|
88
|
-
x: Number.isFinite(rawX) ? Math.max(0, rawX) : 0,
|
|
89
|
-
y: Number.isFinite(rawY) ? Math.max(0, rawY) : 0
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
return { x: 0, y: 0 };
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Résout la largeur effective d'une colonne en pixels.
|
|
96
|
-
*/
|
|
97
|
-
static resolveColumnWidth(container, firstItem, columnWidthOption) {
|
|
98
|
-
if (typeof columnWidthOption === "number" && Number.isFinite(columnWidthOption) && columnWidthOption > 0) {
|
|
99
|
-
return columnWidthOption;
|
|
100
|
-
}
|
|
101
|
-
if (typeof columnWidthOption === "string") {
|
|
102
|
-
const trimmed = columnWidthOption.trim();
|
|
103
|
-
if (/^\d+(\.\d+)?(px|%)?$/i.test(trimmed)) {
|
|
104
|
-
const parsed = parseFloat(trimmed);
|
|
105
|
-
if (Number.isFinite(parsed) && parsed > 0) {
|
|
106
|
-
if (trimmed.endsWith("%")) {
|
|
107
|
-
const containerW2 = container.getBoundingClientRect().width;
|
|
108
|
-
const resolvedPct = containerW2 * parsed / 100;
|
|
109
|
-
if (resolvedPct > 0) return resolvedPct;
|
|
110
|
-
} else {
|
|
111
|
-
return parsed;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
} else if (trimmed) {
|
|
115
|
-
let el = null;
|
|
116
|
-
try {
|
|
117
|
-
el = container.querySelector(trimmed);
|
|
118
|
-
} catch {
|
|
119
|
-
el = null;
|
|
120
|
-
}
|
|
121
|
-
if (el) {
|
|
122
|
-
const w = el.getBoundingClientRect().width;
|
|
123
|
-
if (Number.isFinite(w) && w > 0) return w;
|
|
124
|
-
}
|
|
125
|
-
const parsed = parseFloat(trimmed);
|
|
126
|
-
if (Number.isFinite(parsed) && parsed > 0) {
|
|
127
|
-
return parsed;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (columnWidthOption instanceof HTMLElement) {
|
|
132
|
-
const w = columnWidthOption.getBoundingClientRect().width;
|
|
133
|
-
if (w > 0) return w;
|
|
134
|
-
}
|
|
135
|
-
if (firstItem) {
|
|
136
|
-
const w = firstItem.getBoundingClientRect().width;
|
|
137
|
-
if (w > 0) return w;
|
|
138
|
-
}
|
|
139
|
-
const containerW = container.getBoundingClientRect().width;
|
|
140
|
-
return containerW > 0 ? containerW : 200;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Extrait le facteur d'étalement (span) d'un item sur plusieurs colonnes.
|
|
144
|
-
*/
|
|
145
|
-
static getItemSpan(item, colWidth, gutterX, maxCols) {
|
|
146
|
-
const dataSpan = item.getAttribute("data-masonry-span") || item.dataset.masonrySpan;
|
|
147
|
-
if (dataSpan) {
|
|
148
|
-
const parsed = parseInt(dataSpan, 10);
|
|
149
|
-
if (!isNaN(parsed) && parsed > 0) {
|
|
150
|
-
return Math.min(maxCols, parsed);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
for (const cls of item.classList) {
|
|
154
|
-
const match = /^(?:span|col-span)-(\d+)$/.exec(cls);
|
|
155
|
-
if (match && match[1]) {
|
|
156
|
-
const parsed = parseInt(match[1], 10);
|
|
157
|
-
if (!isNaN(parsed) && parsed > 0) {
|
|
158
|
-
return Math.min(maxCols, parsed);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return 1;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Calcule les positions optimales de tous les items.
|
|
166
|
-
*/
|
|
167
|
-
static calculate(container, items, options) {
|
|
168
|
-
const containerRect = container.getBoundingClientRect();
|
|
169
|
-
const containerWidth = containerRect.width;
|
|
170
|
-
const { x: gutterX, y: gutterY } = this.parseGutter(options.gutter);
|
|
171
|
-
if (containerWidth <= 0 || items.length === 0) {
|
|
172
|
-
return {
|
|
173
|
-
cols: 1,
|
|
174
|
-
colWidth: containerWidth,
|
|
175
|
-
gutterX,
|
|
176
|
-
gutterY,
|
|
177
|
-
containerHeight: 0,
|
|
178
|
-
containerWidth,
|
|
179
|
-
positions: []
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
const firstItem = items[0] || null;
|
|
183
|
-
let colWidth = this.resolveColumnWidth(container, firstItem, options.columnWidth);
|
|
184
|
-
const denom = colWidth + gutterX;
|
|
185
|
-
let cols = denom > 0 ? Math.floor((containerWidth + gutterX) / denom) : 1;
|
|
186
|
-
if (!Number.isFinite(cols) || cols < 1) {
|
|
187
|
-
cols = 1;
|
|
188
|
-
} else if (cols > 1e3) {
|
|
189
|
-
cols = 1e3;
|
|
190
|
-
}
|
|
191
|
-
if (!options.columnWidth && cols > 1) {
|
|
192
|
-
colWidth = (containerWidth - (cols - 1) * gutterX) / cols;
|
|
193
|
-
}
|
|
194
|
-
const fittedWidth = options.fitWidth ? cols * colWidth + (cols - 1) * gutterX : void 0;
|
|
195
|
-
const colHeights = new Array(cols).fill(0);
|
|
196
|
-
const positions = [];
|
|
197
|
-
const itemHeights = items.map((item) => {
|
|
198
|
-
const h = item.getBoundingClientRect().height;
|
|
199
|
-
return h > 0 ? h : 50;
|
|
200
|
-
});
|
|
201
|
-
let currentHCol = 0;
|
|
202
|
-
for (let i = 0; i < items.length; i++) {
|
|
203
|
-
const item = items[i];
|
|
204
|
-
const itemH = itemHeights[i];
|
|
205
|
-
const span = this.getItemSpan(item, colWidth, gutterX, cols);
|
|
206
|
-
let targetCol = 0;
|
|
207
|
-
let targetY = 0;
|
|
208
|
-
if (options.horizontalOrder) {
|
|
209
|
-
if (currentHCol + span > cols) {
|
|
210
|
-
currentHCol = 0;
|
|
211
|
-
}
|
|
212
|
-
targetCol = currentHCol;
|
|
213
|
-
let maxY = 0;
|
|
214
|
-
for (let s = 0; s < span; s++) {
|
|
215
|
-
if (colHeights[targetCol + s] > maxY) {
|
|
216
|
-
maxY = colHeights[targetCol + s];
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
targetY = maxY;
|
|
220
|
-
currentHCol = (targetCol + span) % cols;
|
|
221
|
-
} else {
|
|
222
|
-
if (span === 1) {
|
|
223
|
-
let minH = colHeights[0];
|
|
224
|
-
targetCol = 0;
|
|
225
|
-
for (let c = 1; c < cols; c++) {
|
|
226
|
-
if (colHeights[c] < minH) {
|
|
227
|
-
minH = colHeights[c];
|
|
228
|
-
targetCol = c;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
targetY = minH;
|
|
232
|
-
} else {
|
|
233
|
-
let bestMax = Infinity;
|
|
234
|
-
targetCol = 0;
|
|
235
|
-
for (let c = 0; c <= cols - span; c++) {
|
|
236
|
-
let maxInSpan = 0;
|
|
237
|
-
for (let s = 0; s < span; s++) {
|
|
238
|
-
if (colHeights[c + s] > maxInSpan) {
|
|
239
|
-
maxInSpan = colHeights[c + s];
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
if (maxInSpan < bestMax) {
|
|
243
|
-
bestMax = maxInSpan;
|
|
244
|
-
targetCol = c;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
targetY = bestMax;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
const itemW = span * colWidth + (span - 1) * gutterX;
|
|
251
|
-
const isRtl = typeof window !== "undefined" && typeof window.getComputedStyle === "function" && window.getComputedStyle(container).direction === "rtl";
|
|
252
|
-
const effectiveWidth = fittedWidth !== void 0 ? fittedWidth : containerWidth;
|
|
253
|
-
const rawX = targetCol * (colWidth + gutterX);
|
|
254
|
-
const targetX = isRtl ? Math.max(0, effectiveWidth - rawX - itemW) : rawX;
|
|
255
|
-
positions.push({
|
|
256
|
-
element: item,
|
|
257
|
-
x: targetX,
|
|
258
|
-
y: targetY,
|
|
259
|
-
width: itemW,
|
|
260
|
-
height: itemH,
|
|
261
|
-
column: targetCol,
|
|
262
|
-
span
|
|
263
|
-
});
|
|
264
|
-
const nextY = targetY + itemH + gutterY;
|
|
265
|
-
for (let s = 0; s < span; s++) {
|
|
266
|
-
colHeights[targetCol + s] = nextY;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
let maxColH = 0;
|
|
270
|
-
for (let c = 0; c < cols; c++) {
|
|
271
|
-
if (colHeights[c] > maxColH) {
|
|
272
|
-
maxColH = colHeights[c];
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
const containerHeight = Math.max(0, maxColH > 0 ? maxColH - gutterY : 0);
|
|
276
|
-
return {
|
|
277
|
-
cols,
|
|
278
|
-
colWidth,
|
|
279
|
-
gutterX,
|
|
280
|
-
gutterY,
|
|
281
|
-
containerHeight,
|
|
282
|
-
containerWidth,
|
|
283
|
-
fittedWidth,
|
|
284
|
-
positions
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
// src/common/AuditableComponent.ts
|
|
290
|
-
var AuditableComponent = class {
|
|
291
|
-
/**
|
|
292
|
-
* Indication affichée en pied de warning pour expliquer comment désactiver l'audit.
|
|
293
|
-
*/
|
|
294
|
-
getAuditDisableHint() {
|
|
295
|
-
return "Passez { audit: false } dans les options pour d\xE9sactiver cet avertissement";
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Exécute l'audit d'accessibilité et émet un avertissement standardisé dans la console
|
|
299
|
-
* si l'audit est activé et que des contraintes manquent.
|
|
300
|
-
*/
|
|
301
|
-
runAuditWarning(enabled = true) {
|
|
302
|
-
if (!enabled) return [];
|
|
303
|
-
const warnings = this.audit();
|
|
304
|
-
if (warnings.length > 0 && typeof console !== "undefined" && typeof console.warn === "function") {
|
|
305
|
-
console.warn(
|
|
306
|
-
`[${this.getAuditPrefix()}] Audit d'accessibilit\xE9 \u2014 ${warnings.length} contrainte(s) manquante(s) sur ${this.getAuditTargetLabel()} :
|
|
307
|
-
` + warnings.map((w) => ` - ${w}`).join("\n") + `
|
|
308
|
-
(${this.getAuditDisableHint()})`
|
|
309
|
-
);
|
|
310
|
-
}
|
|
311
|
-
return warnings;
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Vérifie si un attribut de référence d'IDs ARIA (ex: aria-labelledby, aria-describedby, aria-errormessage)
|
|
315
|
-
* pointe vers des éléments réellement présents dans le document (et optionnellement non vides).
|
|
316
|
-
*/
|
|
317
|
-
checkAriaIdReferences(element, attrName, warnings, requireNonEmptyText = false) {
|
|
318
|
-
const rawValue = element.getAttribute(attrName)?.trim();
|
|
319
|
-
if (!rawValue) return false;
|
|
320
|
-
const doc = element.ownerDocument || document;
|
|
321
|
-
const root = typeof element.getRootNode === "function" ? element.getRootNode() : doc;
|
|
322
|
-
const ids = rawValue.split(/\s+/).filter(Boolean);
|
|
323
|
-
const targets = ids.map(
|
|
324
|
-
(id) => typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.getElementById(id) : doc.getElementById(id)
|
|
325
|
-
);
|
|
326
|
-
const allFound = ids.length > 0 && targets.every((el) => Boolean(el));
|
|
327
|
-
if (!allFound) {
|
|
328
|
-
warnings.push(
|
|
329
|
-
`Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`
|
|
330
|
-
);
|
|
331
|
-
return false;
|
|
332
|
-
}
|
|
333
|
-
if (requireNonEmptyText) {
|
|
334
|
-
const hasNonEmptyText = targets.some((el) => {
|
|
335
|
-
if (!el) return false;
|
|
336
|
-
const text = el.textContent?.trim() || el.getAttribute("aria-label")?.trim() || "";
|
|
337
|
-
return text.length > 0;
|
|
338
|
-
});
|
|
339
|
-
if (!hasNonEmptyText) {
|
|
340
|
-
warnings.push(
|
|
341
|
-
`Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible ne contient aucun texte accessible.`
|
|
342
|
-
);
|
|
343
|
-
return false;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
return true;
|
|
347
|
-
}
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
// src/common/LocalizedComponent.ts
|
|
351
|
-
var LocalizedComponent = class extends AuditableComponent {
|
|
352
|
-
static _i18n;
|
|
353
|
-
/**
|
|
354
|
-
* Définit la langue globale du composant (ex: 'fr', 'en', 'es').
|
|
355
|
-
*/
|
|
356
|
-
static setLocale(locale) {
|
|
357
|
-
if (this._i18n) {
|
|
358
|
-
this._i18n.setLocale(locale);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* Retourne la langue globale active du composant.
|
|
363
|
-
*/
|
|
364
|
-
static getLocale() {
|
|
365
|
-
return this._i18n ? this._i18n.getLocale() : "";
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* Enregistre un dictionnaire de traduction pour une langue donnée.
|
|
369
|
-
*/
|
|
370
|
-
static registerLocale(locale, translations) {
|
|
371
|
-
if (this._i18n) {
|
|
372
|
-
this._i18n.registerLocale(locale, translations);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* Surcharge les libellés globalement pour ce composant.
|
|
377
|
-
*/
|
|
378
|
-
static setI18n(overrides) {
|
|
379
|
-
if (this._i18n) {
|
|
380
|
-
this._i18n.setI18n(overrides);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* Retourne l'ensemble des libellés actifs résolus du composant.
|
|
385
|
-
*/
|
|
386
|
-
static getI18n() {
|
|
387
|
-
return this._i18n ? this._i18n.getAll() : {};
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* Réinitialise les réglages de langue et surcharges globales.
|
|
391
|
-
*/
|
|
392
|
-
static resetI18n() {
|
|
393
|
-
if (this._i18n) {
|
|
394
|
-
this._i18n.reset();
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* Résout une clé au niveau statique de la classe.
|
|
399
|
-
*/
|
|
400
|
-
static t(key, instanceOverride) {
|
|
401
|
-
return this._i18n ? this._i18n.t(key, instanceOverride) : String(key);
|
|
402
|
-
}
|
|
403
|
-
/**
|
|
404
|
-
* Surcharges de localisation spécifiques à cette instance.
|
|
405
|
-
*/
|
|
406
|
-
i18nOverrides;
|
|
407
|
-
constructor(i18nOverrides) {
|
|
408
|
-
super();
|
|
409
|
-
this.i18nOverrides = i18nOverrides;
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* Traduit une clé en tenant compte automatiquement des surcharges de l'instance courante.
|
|
413
|
-
*/
|
|
414
|
-
t(key) {
|
|
415
|
-
const ctor = this.constructor;
|
|
416
|
-
return ctor._i18n ? ctor._i18n.t(key, this.i18nOverrides) : String(key);
|
|
417
|
-
}
|
|
418
|
-
};
|
|
419
|
-
|
|
420
|
-
// src/common/i18n.ts
|
|
421
|
-
var FORBIDDEN_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
422
|
-
function isSafeKey(key) {
|
|
423
|
-
return Boolean(key) && !FORBIDDEN_KEYS.has(key);
|
|
424
|
-
}
|
|
425
|
-
function normalizeLocaleCode(locale) {
|
|
426
|
-
const norm = String(locale ?? "").trim().toLowerCase().replace(/_/g, "-");
|
|
427
|
-
return isSafeKey(norm) ? norm : "";
|
|
428
|
-
}
|
|
429
|
-
function getPrimaryLanguage(normalizedLocale) {
|
|
430
|
-
const dashIndex = normalizedLocale.indexOf("-");
|
|
431
|
-
const primary = dashIndex > 0 ? normalizedLocale.slice(0, dashIndex) : null;
|
|
432
|
-
return primary && isSafeKey(primary) ? primary : null;
|
|
433
|
-
}
|
|
434
|
-
function assignDefined(target, source) {
|
|
435
|
-
if (!source || typeof source !== "object") return target;
|
|
436
|
-
for (const key of Object.keys(source)) {
|
|
437
|
-
if (isSafeKey(String(key)) && Object.hasOwn(source, key) && source[key] !== void 0) {
|
|
438
|
-
target[key] = source[key];
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
return target;
|
|
442
|
-
}
|
|
443
|
-
function createI18nManager(defaultLocale, locales) {
|
|
444
|
-
const fallbackLocale = normalizeLocaleCode(defaultLocale) || "fr";
|
|
445
|
-
const initialLocales = /* @__PURE__ */ Object.create(null);
|
|
446
|
-
for (const [loc, dict] of Object.entries(locales)) {
|
|
447
|
-
const norm = normalizeLocaleCode(loc);
|
|
448
|
-
if (norm) {
|
|
449
|
-
initialLocales[norm] = assignDefined(/* @__PURE__ */ Object.create(null), dict);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
let currentLocale = fallbackLocale;
|
|
453
|
-
let activeLocales = /* @__PURE__ */ Object.create(null);
|
|
454
|
-
for (const [loc, dict] of Object.entries(initialLocales)) {
|
|
455
|
-
activeLocales[loc] = assignDefined(/* @__PURE__ */ Object.create(null), dict);
|
|
456
|
-
}
|
|
457
|
-
let globalOverrides = /* @__PURE__ */ Object.create(null);
|
|
458
|
-
function resolveActiveDictionaries() {
|
|
459
|
-
const dicts = [];
|
|
460
|
-
if (isSafeKey(currentLocale)) {
|
|
461
|
-
const exact = activeLocales[currentLocale];
|
|
462
|
-
if (exact) dicts.push(exact);
|
|
463
|
-
}
|
|
464
|
-
const primary = getPrimaryLanguage(currentLocale);
|
|
465
|
-
if (primary && activeLocales[primary]) {
|
|
466
|
-
dicts.push(activeLocales[primary]);
|
|
467
|
-
}
|
|
468
|
-
return dicts;
|
|
469
|
-
}
|
|
470
|
-
return {
|
|
471
|
-
setLocale(locale) {
|
|
472
|
-
if (locale && typeof locale === "string" && locale.trim()) {
|
|
473
|
-
const norm = normalizeLocaleCode(locale);
|
|
474
|
-
if (norm) {
|
|
475
|
-
currentLocale = norm;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
},
|
|
479
|
-
getLocale() {
|
|
480
|
-
return currentLocale;
|
|
481
|
-
},
|
|
482
|
-
registerLocale(locale, translations) {
|
|
483
|
-
if (!locale || typeof locale !== "string" || !locale.trim() || !translations) return;
|
|
484
|
-
const norm = normalizeLocaleCode(locale);
|
|
485
|
-
if (!norm) return;
|
|
486
|
-
const base = assignDefined(/* @__PURE__ */ Object.create(null), activeLocales[norm]);
|
|
487
|
-
activeLocales[norm] = assignDefined(base, translations);
|
|
488
|
-
},
|
|
489
|
-
setI18n(overrides) {
|
|
490
|
-
if (!overrides || typeof overrides !== "object") return;
|
|
491
|
-
const base = assignDefined(/* @__PURE__ */ Object.create(null), globalOverrides);
|
|
492
|
-
globalOverrides = assignDefined(base, overrides);
|
|
493
|
-
},
|
|
494
|
-
t(key, instanceOverride) {
|
|
495
|
-
if (!isSafeKey(String(key))) {
|
|
496
|
-
return "";
|
|
497
|
-
}
|
|
498
|
-
if (instanceOverride && typeof instanceOverride === "object" && Object.hasOwn(instanceOverride, key) && instanceOverride[key] !== void 0) {
|
|
499
|
-
return String(instanceOverride[key]);
|
|
500
|
-
}
|
|
501
|
-
if (globalOverrides[key] !== void 0) {
|
|
502
|
-
return String(globalOverrides[key]);
|
|
503
|
-
}
|
|
504
|
-
for (const dict of resolveActiveDictionaries()) {
|
|
505
|
-
if (dict[key] !== void 0) {
|
|
506
|
-
return String(dict[key]);
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
const fallbackDict = activeLocales[fallbackLocale] || initialLocales[fallbackLocale];
|
|
510
|
-
if (fallbackDict && fallbackDict[key] !== void 0) {
|
|
511
|
-
return String(fallbackDict[key]);
|
|
512
|
-
}
|
|
513
|
-
return String(key);
|
|
514
|
-
},
|
|
515
|
-
getAll(instanceOverride) {
|
|
516
|
-
const result = {};
|
|
517
|
-
const fallback = activeLocales[fallbackLocale] || initialLocales[fallbackLocale];
|
|
518
|
-
assignDefined(result, fallback);
|
|
519
|
-
const activeDicts = resolveActiveDictionaries().reverse();
|
|
520
|
-
for (const dict of activeDicts) {
|
|
521
|
-
assignDefined(result, dict);
|
|
522
|
-
}
|
|
523
|
-
assignDefined(result, globalOverrides);
|
|
524
|
-
assignDefined(result, instanceOverride);
|
|
525
|
-
return result;
|
|
526
|
-
},
|
|
527
|
-
reset() {
|
|
528
|
-
currentLocale = fallbackLocale;
|
|
529
|
-
globalOverrides = /* @__PURE__ */ Object.create(null);
|
|
530
|
-
activeLocales = /* @__PURE__ */ Object.create(null);
|
|
531
|
-
for (const [loc, dict] of Object.entries(initialLocales)) {
|
|
532
|
-
activeLocales[loc] = assignDefined(/* @__PURE__ */ Object.create(null), dict);
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
};
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
// src/masonry/i18n/fr.ts
|
|
539
|
-
var masonryFr = {
|
|
540
|
-
gallery: "Galerie en grille asym\xE9trique"
|
|
541
|
-
};
|
|
542
|
-
|
|
543
|
-
// src/masonry/i18n/en.ts
|
|
544
|
-
var masonryEn = {
|
|
545
|
-
gallery: "Masonry grid gallery"
|
|
546
|
-
};
|
|
547
|
-
|
|
548
|
-
// src/masonry/i18n/index.ts
|
|
549
|
-
var masonryI18n = createI18nManager("fr", {
|
|
550
|
-
fr: masonryFr,
|
|
551
|
-
en: masonryEn
|
|
552
|
-
});
|
|
553
|
-
|
|
554
|
-
// src/masonry/Masonry.ts
|
|
555
|
-
var Masonry = class extends LocalizedComponent {
|
|
556
|
-
static _i18n = masonryI18n;
|
|
557
|
-
static i18n = masonryI18n;
|
|
558
|
-
root;
|
|
559
|
-
isNativeCSSGrid = false;
|
|
560
|
-
_items = [];
|
|
561
|
-
options;
|
|
562
|
-
resizeObserver = null;
|
|
563
|
-
itemResizeObserver = null;
|
|
564
|
-
observedItems = /* @__PURE__ */ new Set();
|
|
565
|
-
observedItemHeights = /* @__PURE__ */ new WeakMap();
|
|
566
|
-
removingItems = /* @__PURE__ */ new WeakSet();
|
|
567
|
-
layoutRafId = null;
|
|
568
|
-
isDestroyed = false;
|
|
569
|
-
wasRoleInferred = false;
|
|
570
|
-
wasAriaLabelInferred = false;
|
|
571
|
-
hasExplicitAriaLabel = false;
|
|
572
|
-
lastInferredAriaLabel = "";
|
|
573
|
-
abortController = new AbortController();
|
|
574
|
-
watchedImages = /* @__PURE__ */ new WeakSet();
|
|
575
|
-
originalContainerStyles;
|
|
576
|
-
constructor(target, options = {}) {
|
|
577
|
-
super(options.i18n);
|
|
578
|
-
if (typeof target === "string") {
|
|
579
|
-
let el = null;
|
|
580
|
-
try {
|
|
581
|
-
el = document.querySelector(target);
|
|
582
|
-
} catch {
|
|
583
|
-
el = null;
|
|
584
|
-
}
|
|
585
|
-
if (!el) {
|
|
586
|
-
throw new Error(`[Wulf.Masonry] Conteneur introuvable pour le s\xE9lecteur : "${target}"`);
|
|
587
|
-
}
|
|
588
|
-
this.root = el;
|
|
589
|
-
} else if (target instanceof HTMLElement) {
|
|
590
|
-
this.root = target;
|
|
591
|
-
} else {
|
|
592
|
-
throw new Error("[Wulf.Masonry] Cible invalide : fournissez un \xE9l\xE9ment HTMLElement ou un s\xE9lecteur valide.");
|
|
593
|
-
}
|
|
594
|
-
this.originalContainerStyles = {
|
|
595
|
-
height: this.root.style.height,
|
|
596
|
-
width: this.root.style.width
|
|
597
|
-
};
|
|
598
|
-
this.hasExplicitAriaLabel = Boolean(options.ariaLabel || options.i18n?.gallery);
|
|
599
|
-
this.options = {
|
|
600
|
-
itemSelector: options.itemSelector || "> *",
|
|
601
|
-
columnWidth: options.columnWidth ?? 0,
|
|
602
|
-
gutter: options.gutter ?? 0,
|
|
603
|
-
percentPosition: Boolean(options.percentPosition),
|
|
604
|
-
fitWidth: Boolean(options.fitWidth),
|
|
605
|
-
horizontalOrder: Boolean(options.horizontalOrder),
|
|
606
|
-
transitionDuration: options.transitionDuration !== void 0 ? options.transitionDuration : 300,
|
|
607
|
-
stagger: options.stagger || 0,
|
|
608
|
-
resize: options.resize !== false,
|
|
609
|
-
autoImages: options.autoImages !== false,
|
|
610
|
-
useNativeCSSGrid: options.useNativeCSSGrid !== false,
|
|
611
|
-
ariaRole: options.ariaRole || "region",
|
|
612
|
-
ariaLabel: options.ariaLabel || this.t("gallery"),
|
|
613
|
-
i18n: options.i18n || {},
|
|
614
|
-
onLayout: options.onLayout || (() => {
|
|
615
|
-
}),
|
|
616
|
-
onItemPlaced: options.onItemPlaced || (() => {
|
|
617
|
-
}),
|
|
618
|
-
audit: options.audit ?? true
|
|
619
|
-
};
|
|
620
|
-
const supportsNativeCSS = typeof CSS !== "undefined" && typeof CSS.supports === "function" && (CSS.supports("display", "grid-lanes") || CSS.supports("grid-template-rows", "masonry"));
|
|
621
|
-
if (this.options.useNativeCSSGrid && supportsNativeCSS) {
|
|
622
|
-
this.isNativeCSSGrid = true;
|
|
623
|
-
this.root.classList.add("wulf-masonry", "wulf-masonry--native");
|
|
624
|
-
this.syncNativeGridVariables();
|
|
625
|
-
} else {
|
|
626
|
-
this.root.classList.add("wulf-masonry");
|
|
627
|
-
}
|
|
628
|
-
this.initAccessibility();
|
|
629
|
-
this.applyTransitionDuration();
|
|
630
|
-
this.reloadItems();
|
|
631
|
-
this.initObservers();
|
|
632
|
-
this.initImages();
|
|
633
|
-
this.layout();
|
|
634
|
-
this.runAuditWarning(this.options.audit);
|
|
635
|
-
}
|
|
636
|
-
get items() {
|
|
637
|
-
return [...this._items];
|
|
638
|
-
}
|
|
639
|
-
/**
|
|
640
|
-
* Initialise les attributs WAI-ARIA du conteneur.
|
|
641
|
-
*/
|
|
642
|
-
initAccessibility() {
|
|
643
|
-
if (this.options.ariaRole && !this.root.hasAttribute("role")) {
|
|
644
|
-
this.root.setAttribute("role", this.options.ariaRole);
|
|
645
|
-
this.wasRoleInferred = true;
|
|
646
|
-
}
|
|
647
|
-
const label = this.hasExplicitAriaLabel ? this.options.ariaLabel : this.t("gallery");
|
|
648
|
-
if (label && !this.root.hasAttribute("aria-label") && !this.root.hasAttribute("aria-labelledby")) {
|
|
649
|
-
this.root.setAttribute("aria-label", label);
|
|
650
|
-
this.lastInferredAriaLabel = label;
|
|
651
|
-
this.wasAriaLabelInferred = true;
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
/**
|
|
655
|
-
* Synchronise dynamiquement le libellé ARIA si la langue globale change après montage.
|
|
656
|
-
*/
|
|
657
|
-
syncAccessibilityLabels() {
|
|
658
|
-
if (this.wasAriaLabelInferred && !this.hasExplicitAriaLabel) {
|
|
659
|
-
const currentAttr = this.root.getAttribute("aria-label");
|
|
660
|
-
if (currentAttr === this.lastInferredAriaLabel) {
|
|
661
|
-
const nextLabel = this.t("gallery");
|
|
662
|
-
this.root.setAttribute("aria-label", nextLabel);
|
|
663
|
-
this.lastInferredAriaLabel = nextLabel;
|
|
664
|
-
this.options.ariaLabel = nextLabel;
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
/**
|
|
669
|
-
* Configure les variables CSS de transition sur le conteneur.
|
|
670
|
-
*/
|
|
671
|
-
applyTransitionDuration() {
|
|
672
|
-
const dur = this.options.transitionDuration;
|
|
673
|
-
let durValue = "300ms";
|
|
674
|
-
if (typeof dur === "number" && Number.isFinite(dur) && dur >= 0) {
|
|
675
|
-
durValue = `${dur}ms`;
|
|
676
|
-
} else if (typeof dur === "string" && /^\s*(?:\d+(?:\.\d+)?|\.\d+)(ms|s)\s*$/i.test(dur)) {
|
|
677
|
-
durValue = dur.trim();
|
|
678
|
-
}
|
|
679
|
-
this.root.style.setProperty("--wulf-masonry-duration", durValue);
|
|
680
|
-
}
|
|
681
|
-
/**
|
|
682
|
-
* Réindexe les éléments enfants ciblés par la disposition.
|
|
683
|
-
*/
|
|
684
|
-
reloadItems() {
|
|
685
|
-
if (this.isDestroyed) return;
|
|
686
|
-
let matched = [];
|
|
687
|
-
if (this.options.itemSelector === "> *") {
|
|
688
|
-
matched = Array.from(this.root.children).filter(
|
|
689
|
-
(el) => el instanceof HTMLElement && !el.hasAttribute("data-masonry-ignore") && !this.removingItems.has(el)
|
|
690
|
-
);
|
|
691
|
-
} else {
|
|
692
|
-
try {
|
|
693
|
-
const rawSelector = this.options.itemSelector.trim();
|
|
694
|
-
const selector = rawSelector.startsWith(">") ? `:scope ${rawSelector}` : rawSelector;
|
|
695
|
-
matched = Array.from(this.root.querySelectorAll(selector)).filter(
|
|
696
|
-
(el) => el.parentElement === this.root && !el.hasAttribute("data-masonry-ignore") && !this.removingItems.has(el)
|
|
697
|
-
);
|
|
698
|
-
} catch {
|
|
699
|
-
matched = Array.from(this.root.children).filter(
|
|
700
|
-
(el) => el instanceof HTMLElement && !el.hasAttribute("data-masonry-ignore") && !this.removingItems.has(el)
|
|
701
|
-
);
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
if (this.itemResizeObserver) {
|
|
705
|
-
const nextSet = new Set(matched);
|
|
706
|
-
for (const prevEl of this.observedItems) {
|
|
707
|
-
if (!nextSet.has(prevEl)) {
|
|
708
|
-
this.itemResizeObserver.unobserve(prevEl);
|
|
709
|
-
this.observedItems.delete(prevEl);
|
|
710
|
-
this.observedItemHeights.delete(prevEl);
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
this._items = matched;
|
|
715
|
-
for (const item of this._items) {
|
|
716
|
-
item.classList.add("wulf-masonry-item");
|
|
717
|
-
if (this.itemResizeObserver && !this.observedItems.has(item)) {
|
|
718
|
-
this.itemResizeObserver.observe(item);
|
|
719
|
-
this.observedItems.add(item);
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
/**
|
|
724
|
-
* Active ResizeObserver sur le conteneur et les éléments individuels.
|
|
725
|
-
*/
|
|
726
|
-
initObservers() {
|
|
727
|
-
if (!this.options.resize || typeof ResizeObserver === "undefined") return;
|
|
728
|
-
let prevWidth = this.root.getBoundingClientRect().width;
|
|
729
|
-
this.resizeObserver = new ResizeObserver((entries) => {
|
|
730
|
-
for (const entry of entries) {
|
|
731
|
-
const currentWidth = entry.contentRect.width;
|
|
732
|
-
if (Math.abs(currentWidth - prevWidth) >= 1) {
|
|
733
|
-
prevWidth = currentWidth;
|
|
734
|
-
this.scheduleLayout();
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
});
|
|
738
|
-
this.resizeObserver.observe(this.root);
|
|
739
|
-
this.itemResizeObserver = new ResizeObserver((entries) => {
|
|
740
|
-
let heightChanged = false;
|
|
741
|
-
for (const entry of entries) {
|
|
742
|
-
const newH = entry.borderBoxSize?.[0]?.blockSize ?? entry.contentRect.height;
|
|
743
|
-
const prevH = this.observedItemHeights.get(entry.target);
|
|
744
|
-
if (prevH === void 0 || Math.abs(newH - prevH) >= 1) {
|
|
745
|
-
this.observedItemHeights.set(entry.target, newH);
|
|
746
|
-
if (prevH !== void 0) {
|
|
747
|
-
heightChanged = true;
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
if (heightChanged) {
|
|
752
|
-
this.scheduleLayout();
|
|
753
|
-
}
|
|
754
|
-
});
|
|
755
|
-
for (const item of this._items) {
|
|
756
|
-
this.itemResizeObserver.observe(item);
|
|
757
|
-
this.observedItems.add(item);
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
/**
|
|
761
|
-
* Synchronise les variables CSS du mode natif CSS Grid Level 3 depuis les options JS.
|
|
762
|
-
*/
|
|
763
|
-
syncNativeGridVariables() {
|
|
764
|
-
const { x: gutterX, y: gutterY } = LayoutEngine.parseGutter(this.options.gutter);
|
|
765
|
-
this.root.style.setProperty("--wulf-masonry-gutter-x", `${gutterX}px`);
|
|
766
|
-
this.root.style.setProperty("--wulf-masonry-gutter-y", `${gutterY}px`);
|
|
767
|
-
if (typeof this.options.columnWidth === "number" && Number.isFinite(this.options.columnWidth) && this.options.columnWidth > 0) {
|
|
768
|
-
this.root.style.setProperty("--wulf-masonry-col-min", `${this.options.columnWidth}px`);
|
|
769
|
-
} else if (this.options.columnWidth instanceof HTMLElement) {
|
|
770
|
-
const w = this.options.columnWidth.getBoundingClientRect().width;
|
|
771
|
-
if (w > 0) {
|
|
772
|
-
this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
|
|
773
|
-
}
|
|
774
|
-
} else if (typeof this.options.columnWidth === "string" && this.options.columnWidth.trim()) {
|
|
775
|
-
try {
|
|
776
|
-
const el = this.root.querySelector(this.options.columnWidth);
|
|
777
|
-
if (el) {
|
|
778
|
-
const w = el.getBoundingClientRect().width;
|
|
779
|
-
if (w > 0) {
|
|
780
|
-
this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
} catch {
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
/**
|
|
788
|
-
* Détecte les balises <img> sans dimensions prédéfinies et attend leur décodage/chargement.
|
|
789
|
-
*/
|
|
790
|
-
initImages() {
|
|
791
|
-
if (!this.options.autoImages) return;
|
|
792
|
-
const images = Array.from(this.root.querySelectorAll("img"));
|
|
793
|
-
for (const img of images) {
|
|
794
|
-
if (!img.complete && !this.watchedImages.has(img)) {
|
|
795
|
-
this.watchedImages.add(img);
|
|
796
|
-
const attachLoadListener = () => {
|
|
797
|
-
img.addEventListener("load", () => {
|
|
798
|
-
if (!this.isDestroyed) this.scheduleLayout();
|
|
799
|
-
}, { once: true, signal: this.abortController.signal });
|
|
800
|
-
};
|
|
801
|
-
if (typeof img.decode === "function") {
|
|
802
|
-
img.decode().then(() => {
|
|
803
|
-
if (!this.isDestroyed) this.scheduleLayout();
|
|
804
|
-
}).catch(() => {
|
|
805
|
-
attachLoadListener();
|
|
806
|
-
});
|
|
807
|
-
} else {
|
|
808
|
-
attachLoadListener();
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
/**
|
|
814
|
-
* Planifie un recalcul au prochain tick d'animation via requestAnimationFrame.
|
|
815
|
-
*/
|
|
816
|
-
scheduleLayout() {
|
|
817
|
-
if (this.isDestroyed) return;
|
|
818
|
-
if (this.layoutRafId !== null) {
|
|
819
|
-
cancelAnimationFrame(this.layoutRafId);
|
|
820
|
-
}
|
|
821
|
-
this.layoutRafId = requestAnimationFrame(() => {
|
|
822
|
-
this.layoutRafId = null;
|
|
823
|
-
this.layout();
|
|
824
|
-
});
|
|
825
|
-
}
|
|
826
|
-
/**
|
|
827
|
-
* Calcule et applique les nouvelles coordonnées GPU de chaque item.
|
|
828
|
-
*/
|
|
829
|
-
layout() {
|
|
830
|
-
if (this.isDestroyed) return;
|
|
831
|
-
this.syncAccessibilityLabels();
|
|
832
|
-
if (this.isNativeCSSGrid) {
|
|
833
|
-
this.syncNativeGridVariables();
|
|
834
|
-
for (const el of this._items) {
|
|
835
|
-
el.classList.remove("wulf-masonry-item--hidden");
|
|
836
|
-
}
|
|
837
|
-
this.options.onLayout([]);
|
|
838
|
-
return;
|
|
839
|
-
}
|
|
840
|
-
this.root.setAttribute("aria-busy", "true");
|
|
841
|
-
if (this.options.fitWidth && this.root.classList.contains("wulf-masonry--fit-width")) {
|
|
842
|
-
this.root.style.width = "";
|
|
843
|
-
}
|
|
844
|
-
const result = LayoutEngine.calculate(this.root, this._items, this.options);
|
|
845
|
-
this.root.style.height = `${result.containerHeight}px`;
|
|
846
|
-
if (this.options.fitWidth && result.fittedWidth !== void 0) {
|
|
847
|
-
this.root.style.width = `${result.fittedWidth}px`;
|
|
848
|
-
this.root.classList.add("wulf-masonry--fit-width");
|
|
849
|
-
} else {
|
|
850
|
-
this.root.classList.remove("wulf-masonry--fit-width");
|
|
851
|
-
}
|
|
852
|
-
const stagger = this.options.stagger;
|
|
853
|
-
const validStagger = typeof stagger === "number" && Number.isFinite(stagger) && stagger > 0;
|
|
854
|
-
if (validStagger) {
|
|
855
|
-
this.root.style.setProperty("--wulf-masonry-stagger", `${stagger}ms`);
|
|
856
|
-
} else {
|
|
857
|
-
this.root.style.removeProperty("--wulf-masonry-stagger");
|
|
858
|
-
}
|
|
859
|
-
const hasIgnoredChildren = this._items.length !== this.root.children.length;
|
|
860
|
-
const supportsSiblingIndex = !hasIgnoredChildren && typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("transition-delay", "calc(sibling-index() * 1ms)");
|
|
861
|
-
const usePercent = this.options.percentPosition && result.containerWidth > 0;
|
|
862
|
-
for (let i = 0; i < result.positions.length; i++) {
|
|
863
|
-
const pos = result.positions[i];
|
|
864
|
-
const item = pos.element;
|
|
865
|
-
if (usePercent) {
|
|
866
|
-
const wPct = Number((pos.width / result.containerWidth * 100).toFixed(4));
|
|
867
|
-
item.style.setProperty("--wulf-masonry-w", `${wPct}%`);
|
|
868
|
-
} else {
|
|
869
|
-
item.style.setProperty("--wulf-masonry-w", `${pos.width}px`);
|
|
870
|
-
}
|
|
871
|
-
item.style.setProperty("--wulf-masonry-x", `${pos.x}px`);
|
|
872
|
-
item.style.setProperty("--wulf-masonry-y", `${pos.y}px`);
|
|
873
|
-
if (validStagger && !supportsSiblingIndex) {
|
|
874
|
-
item.style.setProperty("--wulf-masonry-index", String(i));
|
|
875
|
-
} else {
|
|
876
|
-
item.style.removeProperty("--wulf-masonry-index");
|
|
877
|
-
}
|
|
878
|
-
item.classList.remove("wulf-masonry-item--hidden");
|
|
879
|
-
this.observedItemHeights.set(item, pos.height);
|
|
880
|
-
this.options.onItemPlaced(item, pos);
|
|
881
|
-
}
|
|
882
|
-
this.root.setAttribute("aria-busy", "false");
|
|
883
|
-
this.options.onLayout(result.positions);
|
|
884
|
-
}
|
|
885
|
-
/**
|
|
886
|
-
* Ajoute de nouveaux éléments à la fin du conteneur.
|
|
887
|
-
*/
|
|
888
|
-
append(elements) {
|
|
889
|
-
if (this.isDestroyed) return;
|
|
890
|
-
const list = Array.isArray(elements) ? elements : [elements];
|
|
891
|
-
if (list.length === 0) return;
|
|
892
|
-
const frag = document.createDocumentFragment();
|
|
893
|
-
for (const el of list) {
|
|
894
|
-
if (this.isNativeCSSGrid) {
|
|
895
|
-
el.classList.add("wulf-masonry-item");
|
|
896
|
-
} else {
|
|
897
|
-
el.classList.add("wulf-masonry-item", "wulf-masonry-item--hidden");
|
|
898
|
-
}
|
|
899
|
-
frag.appendChild(el);
|
|
900
|
-
}
|
|
901
|
-
this.root.appendChild(frag);
|
|
902
|
-
this.reloadItems();
|
|
903
|
-
this.initImages();
|
|
904
|
-
this.layout();
|
|
905
|
-
}
|
|
906
|
-
/**
|
|
907
|
-
* Ajoute de nouveaux éléments au début du conteneur.
|
|
908
|
-
*/
|
|
909
|
-
prepend(elements) {
|
|
910
|
-
if (this.isDestroyed) return;
|
|
911
|
-
const list = Array.isArray(elements) ? elements : [elements];
|
|
912
|
-
if (list.length === 0) return;
|
|
913
|
-
const first = this.root.firstChild;
|
|
914
|
-
const frag = document.createDocumentFragment();
|
|
915
|
-
for (const el of list) {
|
|
916
|
-
if (this.isNativeCSSGrid) {
|
|
917
|
-
el.classList.add("wulf-masonry-item");
|
|
918
|
-
} else {
|
|
919
|
-
el.classList.add("wulf-masonry-item", "wulf-masonry-item--hidden");
|
|
920
|
-
}
|
|
921
|
-
frag.appendChild(el);
|
|
922
|
-
}
|
|
923
|
-
this.root.insertBefore(frag, first);
|
|
924
|
-
this.reloadItems();
|
|
925
|
-
this.initImages();
|
|
926
|
-
this.layout();
|
|
927
|
-
}
|
|
928
|
-
/**
|
|
929
|
-
* Supprime des éléments avec animation de fondu/sortie synchronisée via Web Animations API.
|
|
930
|
-
*/
|
|
931
|
-
remove(elements) {
|
|
932
|
-
if (this.isDestroyed) return;
|
|
933
|
-
const list = Array.isArray(elements) ? elements : [elements];
|
|
934
|
-
if (list.length === 0) return;
|
|
935
|
-
const finalizeRemoval = () => {
|
|
936
|
-
if (this.isDestroyed) return;
|
|
937
|
-
for (const el of list) {
|
|
938
|
-
this.removingItems.delete(el);
|
|
939
|
-
if (el.parentElement === this.root) {
|
|
940
|
-
if (this.itemResizeObserver) {
|
|
941
|
-
this.itemResizeObserver.unobserve(el);
|
|
942
|
-
this.observedItems.delete(el);
|
|
943
|
-
this.observedItemHeights.delete(el);
|
|
944
|
-
}
|
|
945
|
-
this.root.removeChild(el);
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
this.reloadItems();
|
|
949
|
-
this.layout();
|
|
950
|
-
};
|
|
951
|
-
for (const el of list) {
|
|
952
|
-
this.removingItems.add(el);
|
|
953
|
-
if (typeof document !== "undefined" && document.activeElement && el.contains(document.activeElement)) {
|
|
954
|
-
document.activeElement.blur?.();
|
|
955
|
-
}
|
|
956
|
-
el.setAttribute("inert", "");
|
|
957
|
-
el.style.transitionDelay = "0ms";
|
|
958
|
-
el.classList.add("wulf-masonry-item--hidden");
|
|
959
|
-
}
|
|
960
|
-
const dur = parseCssDurationMs(this.options.transitionDuration, 300);
|
|
961
|
-
if (dur <= 0 || this.isNativeCSSGrid) {
|
|
962
|
-
finalizeRemoval();
|
|
963
|
-
return;
|
|
964
|
-
}
|
|
965
|
-
this.reloadItems();
|
|
966
|
-
this.layout();
|
|
967
|
-
Promise.all(
|
|
968
|
-
list.map((el) => waitForAnimations(el, dur, this.abortController.signal))
|
|
969
|
-
).then(() => {
|
|
970
|
-
if (!this.abortController.signal.aborted) {
|
|
971
|
-
finalizeRemoval();
|
|
972
|
-
}
|
|
973
|
-
});
|
|
974
|
-
}
|
|
975
|
-
/**
|
|
976
|
-
* Vérifie la conformité d'accessibilité WAI-ARIA de la grille Masonry
|
|
977
|
-
* et retourne la liste des contraintes manquantes.
|
|
978
|
-
*/
|
|
979
|
-
audit() {
|
|
980
|
-
const warnings = [];
|
|
981
|
-
const hasValidLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings);
|
|
982
|
-
const hasCustomRootAriaLabel = !this.wasAriaLabelInferred && Boolean(this.root.getAttribute("aria-label")?.trim());
|
|
983
|
-
if (!this.hasExplicitAriaLabel && !hasCustomRootAriaLabel && !hasValidLabelledby) {
|
|
984
|
-
warnings.push(
|
|
985
|
-
"Libell\xE9 contextuel manquant : d\xE9finissez l'option ariaLabel (ou un attribut aria-label / aria-labelledby sur le conteneur) pour qualifier la grille (WCAG 4.1.2)."
|
|
986
|
-
);
|
|
987
|
-
}
|
|
988
|
-
const imagesWithoutAlt = Array.from(this.root.querySelectorAll("img")).filter(
|
|
989
|
-
(img) => !img.hasAttribute("alt") && img.getAttribute("aria-hidden") !== "true"
|
|
990
|
-
);
|
|
991
|
-
if (imagesWithoutAlt.length > 0) {
|
|
992
|
-
warnings.push(
|
|
993
|
-
`${imagesWithoutAlt.length} image(s) <img> d\xE9pourvue(s) d'attribut alt : renseignez alt="description" (ou alt="" si d\xE9corative) (WCAG 1.1.1).`
|
|
994
|
-
);
|
|
995
|
-
}
|
|
996
|
-
return warnings;
|
|
997
|
-
}
|
|
998
|
-
getAuditPrefix() {
|
|
999
|
-
return "Wulf.Masonry";
|
|
1000
|
-
}
|
|
1001
|
-
getAuditTargetLabel() {
|
|
1002
|
-
return this.root.id ? `#${this.root.id}` : `<${this.root.tagName.toLowerCase()}.wulf-masonry>`;
|
|
1003
|
-
}
|
|
1004
|
-
/**
|
|
1005
|
-
* Libère les ressources, déconnecte les observateurs et nettoie les styles injectés.
|
|
1006
|
-
*/
|
|
1007
|
-
destroy() {
|
|
1008
|
-
if (this.isDestroyed) return;
|
|
1009
|
-
this.isDestroyed = true;
|
|
1010
|
-
this.abortController.abort();
|
|
1011
|
-
if (this.layoutRafId !== null) {
|
|
1012
|
-
cancelAnimationFrame(this.layoutRafId);
|
|
1013
|
-
this.layoutRafId = null;
|
|
1014
|
-
}
|
|
1015
|
-
if (this.resizeObserver) {
|
|
1016
|
-
this.resizeObserver.disconnect();
|
|
1017
|
-
this.resizeObserver = null;
|
|
1018
|
-
}
|
|
1019
|
-
if (this.itemResizeObserver) {
|
|
1020
|
-
this.itemResizeObserver.disconnect();
|
|
1021
|
-
this.itemResizeObserver = null;
|
|
1022
|
-
}
|
|
1023
|
-
this.root.classList.remove("wulf-masonry", "wulf-masonry--native", "wulf-masonry--fit-width");
|
|
1024
|
-
this.root.removeAttribute("aria-busy");
|
|
1025
|
-
if (this.wasRoleInferred && this.root.getAttribute("role") === this.options.ariaRole) {
|
|
1026
|
-
this.root.removeAttribute("role");
|
|
1027
|
-
}
|
|
1028
|
-
if (this.wasAriaLabelInferred && this.root.getAttribute("aria-label") === this.lastInferredAriaLabel) {
|
|
1029
|
-
this.root.removeAttribute("aria-label");
|
|
1030
|
-
}
|
|
1031
|
-
this.root.style.removeProperty("--wulf-masonry-duration");
|
|
1032
|
-
this.root.style.removeProperty("--wulf-masonry-stagger");
|
|
1033
|
-
this.root.style.removeProperty("--wulf-masonry-col-min");
|
|
1034
|
-
this.root.style.removeProperty("--wulf-masonry-gutter-x");
|
|
1035
|
-
this.root.style.removeProperty("--wulf-masonry-gutter-y");
|
|
1036
|
-
if (this.originalContainerStyles.height) {
|
|
1037
|
-
this.root.style.height = this.originalContainerStyles.height;
|
|
1038
|
-
} else {
|
|
1039
|
-
this.root.style.removeProperty("height");
|
|
1040
|
-
}
|
|
1041
|
-
if (this.originalContainerStyles.width) {
|
|
1042
|
-
this.root.style.width = this.originalContainerStyles.width;
|
|
1043
|
-
} else {
|
|
1044
|
-
this.root.style.removeProperty("width");
|
|
1045
|
-
}
|
|
1046
|
-
for (const item of this._items) {
|
|
1047
|
-
item.classList.remove("wulf-masonry-item", "wulf-masonry-item--hidden");
|
|
1048
|
-
item.style.removeProperty("--wulf-masonry-w");
|
|
1049
|
-
item.style.removeProperty("--wulf-masonry-x");
|
|
1050
|
-
item.style.removeProperty("--wulf-masonry-y");
|
|
1051
|
-
item.style.removeProperty("--wulf-masonry-index");
|
|
1052
|
-
}
|
|
1053
|
-
this._items = [];
|
|
1054
|
-
}
|
|
1055
|
-
};
|
|
1056
|
-
|
|
1057
|
-
// src/masonry/index.ts
|
|
1058
|
-
var index_default = Masonry;
|
|
1059
|
-
var wulfNamespace = getSafeWulfNamespace();
|
|
1060
|
-
if (wulfNamespace) {
|
|
1061
|
-
wulfNamespace.Masonry = Object.assign(Masonry, {
|
|
1062
|
-
Masonry,
|
|
1063
|
-
LayoutEngine,
|
|
1064
|
-
i18n: masonryI18n
|
|
1065
|
-
});
|
|
1066
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
LayoutEngine,
|
|
3
|
+
Masonry,
|
|
4
|
+
masonryEn,
|
|
5
|
+
masonryFr,
|
|
6
|
+
masonryI18n,
|
|
7
|
+
masonry_default
|
|
8
|
+
} from "./chunks/chunk-AXZYYW7H.js";
|
|
9
|
+
import {
|
|
10
|
+
LocalizedComponent,
|
|
11
|
+
createI18nManager
|
|
12
|
+
} from "./chunks/chunk-QV46A7FV.js";
|
|
13
|
+
import "./chunks/chunk-22AIMRD5.js";
|
|
14
|
+
import "./chunks/chunk-VJO22BAT.js";
|
|
1067
15
|
export {
|
|
1068
16
|
LayoutEngine,
|
|
1069
17
|
LocalizedComponent,
|
|
1070
18
|
Masonry,
|
|
1071
19
|
createI18nManager,
|
|
1072
|
-
|
|
20
|
+
masonry_default as default,
|
|
1073
21
|
masonryEn,
|
|
1074
22
|
masonryFr,
|
|
1075
23
|
masonryI18n
|