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/index.global.js
CHANGED
|
@@ -29,6 +29,7 @@ var __WulfIIFE = (() => {
|
|
|
29
29
|
InputAmountMask: () => InputAmountMask,
|
|
30
30
|
InputEmailMask: () => InputEmailMask,
|
|
31
31
|
InputMask: () => InputMask,
|
|
32
|
+
LayoutEngine: () => LayoutEngine,
|
|
32
33
|
LocalizedComponent: () => LocalizedComponent,
|
|
33
34
|
Mask: () => mask_exports,
|
|
34
35
|
MaskEngine: () => MaskEngine,
|
|
@@ -36,13 +37,28 @@ var __WulfIIFE = (() => {
|
|
|
36
37
|
MaskKeyboard: () => MaskKeyboard,
|
|
37
38
|
Masonry: () => masonry_exports,
|
|
38
39
|
Scroll: () => scroll_exports,
|
|
40
|
+
ScrollBlock: () => ScrollBlock,
|
|
39
41
|
Shortcut: () => shortcut_exports,
|
|
42
|
+
ShortcutFormatter: () => ShortcutFormatter,
|
|
43
|
+
ShortcutManager: () => ShortcutManager,
|
|
40
44
|
Toast: () => toast_exports,
|
|
45
|
+
ToastInstance: () => ToastInstance,
|
|
46
|
+
ToastManager: () => ToastManager,
|
|
41
47
|
WulfFocusTrap: () => FocusTrap,
|
|
48
|
+
WulfMasonry: () => Masonry,
|
|
42
49
|
WulfShortcut: () => ShortcutManager,
|
|
50
|
+
WulfToast: () => Toast,
|
|
43
51
|
createI18nManager: () => createI18nManager,
|
|
44
52
|
default: () => mask_default,
|
|
45
|
-
|
|
53
|
+
getDeepActiveElement: () => getDeepActiveElement,
|
|
54
|
+
getSafeWulfNamespace: () => getSafeWulfNamespace,
|
|
55
|
+
isImeComposing: () => isImeComposing,
|
|
56
|
+
parseCssDurationMs: () => parseCssDurationMs,
|
|
57
|
+
prefersReducedMotion: () => prefersReducedMotion,
|
|
58
|
+
resolveMaskConstructorArgs: () => resolveMaskConstructorArgs,
|
|
59
|
+
safeCssEscape: () => safeCssEscape,
|
|
60
|
+
safeMove: () => safeMove,
|
|
61
|
+
waitForAnimations: () => waitForAnimations
|
|
46
62
|
});
|
|
47
63
|
|
|
48
64
|
// src/mask/index.ts
|
|
@@ -62,6 +78,109 @@ var __WulfIIFE = (() => {
|
|
|
62
78
|
resolveMaskConstructorArgs: () => resolveMaskConstructorArgs
|
|
63
79
|
});
|
|
64
80
|
|
|
81
|
+
// src/common/dom.ts
|
|
82
|
+
function getSafeWulfNamespace() {
|
|
83
|
+
if (typeof window === "undefined") return null;
|
|
84
|
+
const win = window;
|
|
85
|
+
const existing = win.Wulf;
|
|
86
|
+
if (!existing || typeof existing !== "object" || typeof Node !== "undefined" && existing instanceof Node || typeof HTMLCollection !== "undefined" && existing instanceof HTMLCollection) {
|
|
87
|
+
const fresh = {};
|
|
88
|
+
win.Wulf = fresh;
|
|
89
|
+
return fresh;
|
|
90
|
+
}
|
|
91
|
+
return existing;
|
|
92
|
+
}
|
|
93
|
+
function safeCssEscape(value) {
|
|
94
|
+
if (typeof CSS !== "undefined" && typeof CSS.escape === "function") {
|
|
95
|
+
return CSS.escape(value);
|
|
96
|
+
}
|
|
97
|
+
return String(value).replace(/["\\\u0000-\u001F\u007F]/g, "\\$&");
|
|
98
|
+
}
|
|
99
|
+
function getDeepActiveElement(root) {
|
|
100
|
+
if (typeof document === "undefined") return null;
|
|
101
|
+
let active = (root ?? document).activeElement;
|
|
102
|
+
while (active && active.shadowRoot && active.shadowRoot.activeElement) {
|
|
103
|
+
active = active.shadowRoot.activeElement;
|
|
104
|
+
}
|
|
105
|
+
return active && typeof active.focus === "function" ? active : null;
|
|
106
|
+
}
|
|
107
|
+
function safeMove(parent, node, referenceNode = null) {
|
|
108
|
+
const moveBefore = parent.moveBefore;
|
|
109
|
+
if (typeof moveBefore === "function" && node.isConnected && parent.isConnected && typeof parent.getRootNode === "function" && typeof node.getRootNode === "function" && parent.getRootNode() === node.getRootNode()) {
|
|
110
|
+
try {
|
|
111
|
+
moveBefore.call(parent, node, referenceNode);
|
|
112
|
+
return;
|
|
113
|
+
} catch {
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
parent.insertBefore(node, referenceNode);
|
|
117
|
+
}
|
|
118
|
+
function isImeComposing(event) {
|
|
119
|
+
return Boolean(
|
|
120
|
+
event.isComposing || event.key === "Process" || event.key === "Enter" && event.keyCode === 229
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
function parseCssDurationMs(duration, fallbackMs = 300, maxMs = 6e4) {
|
|
124
|
+
const safeFallback = Number.isFinite(fallbackMs) && fallbackMs >= 0 ? Math.min(fallbackMs, maxMs) : 300;
|
|
125
|
+
if (typeof duration === "number") {
|
|
126
|
+
return Number.isFinite(duration) && duration >= 0 ? Math.min(duration, maxMs) : safeFallback;
|
|
127
|
+
}
|
|
128
|
+
if (typeof duration === "string") {
|
|
129
|
+
const parts = duration.split(",");
|
|
130
|
+
let maxParsed = -1;
|
|
131
|
+
for (const part of parts) {
|
|
132
|
+
const match = /^\+?(\d+(?:\.\d+)?|\.\d+)(ms|s)?$/i.exec(part.trim());
|
|
133
|
+
if (match) {
|
|
134
|
+
const raw = parseFloat(match[1]);
|
|
135
|
+
if (Number.isFinite(raw) && raw >= 0) {
|
|
136
|
+
const ms = match[2]?.toLowerCase() === "s" ? raw * 1e3 : raw;
|
|
137
|
+
if (ms > maxParsed) {
|
|
138
|
+
maxParsed = ms;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (maxParsed >= 0) {
|
|
144
|
+
return Math.min(maxParsed, maxMs);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return safeFallback;
|
|
148
|
+
}
|
|
149
|
+
function prefersReducedMotion() {
|
|
150
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
151
|
+
}
|
|
152
|
+
function waitForAnimations(element, fallbackMs, signal) {
|
|
153
|
+
const safeFallback = Number.isFinite(fallbackMs) ? Math.min(fallbackMs, 6e4) : 300;
|
|
154
|
+
if (signal?.aborted || safeFallback <= 0 || prefersReducedMotion()) {
|
|
155
|
+
return Promise.resolve();
|
|
156
|
+
}
|
|
157
|
+
const animations = typeof element.getAnimations === "function" ? element.getAnimations().filter((a) => {
|
|
158
|
+
if (a.playState !== "running") return false;
|
|
159
|
+
const timing = a.effect?.getComputedTiming?.();
|
|
160
|
+
return timing ? Number.isFinite(timing.endTime) : true;
|
|
161
|
+
}) : [];
|
|
162
|
+
if (animations.length === 0) {
|
|
163
|
+
return Promise.resolve();
|
|
164
|
+
}
|
|
165
|
+
return new Promise((resolve) => {
|
|
166
|
+
let settled = false;
|
|
167
|
+
let timerId = null;
|
|
168
|
+
const finish = () => {
|
|
169
|
+
if (settled) return;
|
|
170
|
+
settled = true;
|
|
171
|
+
if (timerId !== null) {
|
|
172
|
+
clearTimeout(timerId);
|
|
173
|
+
timerId = null;
|
|
174
|
+
}
|
|
175
|
+
signal?.removeEventListener("abort", finish);
|
|
176
|
+
resolve();
|
|
177
|
+
};
|
|
178
|
+
signal?.addEventListener("abort", finish, { once: true });
|
|
179
|
+
timerId = setTimeout(finish, safeFallback);
|
|
180
|
+
Promise.allSettled(animations.map((a) => a.finished)).then(finish);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
65
184
|
// src/common/AuditableComponent.ts
|
|
66
185
|
var AuditableComponent = class {
|
|
67
186
|
/**
|
|
@@ -94,8 +213,11 @@ var __WulfIIFE = (() => {
|
|
|
94
213
|
const rawValue = element.getAttribute(attrName)?.trim();
|
|
95
214
|
if (!rawValue) return false;
|
|
96
215
|
const doc = element.ownerDocument || document;
|
|
216
|
+
const root = typeof element.getRootNode === "function" ? element.getRootNode() : doc;
|
|
97
217
|
const ids = rawValue.split(/\s+/).filter(Boolean);
|
|
98
|
-
const isValid = ids.length > 0 && ids.every(
|
|
218
|
+
const isValid = ids.length > 0 && ids.every(
|
|
219
|
+
(id) => Boolean(typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.getElementById(id) : doc.getElementById(id))
|
|
220
|
+
);
|
|
99
221
|
if (!isValid) {
|
|
100
222
|
warnings.push(
|
|
101
223
|
`Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`
|
|
@@ -106,6 +228,7 @@ var __WulfIIFE = (() => {
|
|
|
106
228
|
};
|
|
107
229
|
|
|
108
230
|
// src/mask/BaseInputMask.ts
|
|
231
|
+
var VALID_ALIGNS = /* @__PURE__ */ new Set(["left", "right", "center"]);
|
|
109
232
|
function resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOptions) {
|
|
110
233
|
const isSecondArgInput = Boolean(
|
|
111
234
|
inputOrOptions && typeof inputOrOptions === "object" && "tagName" in inputOrOptions && inputOrOptions.tagName === "INPUT"
|
|
@@ -124,59 +247,27 @@ var __WulfIIFE = (() => {
|
|
|
124
247
|
};
|
|
125
248
|
}
|
|
126
249
|
var BaseInputMask = class extends AuditableComponent {
|
|
250
|
+
wrapper;
|
|
251
|
+
input;
|
|
252
|
+
options;
|
|
253
|
+
ghost = null;
|
|
254
|
+
isWrapperCreated = false;
|
|
255
|
+
wasWrapperFallbackStyled = false;
|
|
256
|
+
wasAlignSet = false;
|
|
257
|
+
hadInitialDataAlign = false;
|
|
258
|
+
isDestroyed = false;
|
|
259
|
+
isFocused = false;
|
|
260
|
+
isDispatchingNativeInput = false;
|
|
261
|
+
lastTrackedValue = "";
|
|
262
|
+
nativeValueDescriptor = null;
|
|
263
|
+
onCutHandler = () => {
|
|
264
|
+
};
|
|
265
|
+
onFormResetHandler;
|
|
266
|
+
mutationObserver = null;
|
|
267
|
+
focusSelectTimerId = null;
|
|
268
|
+
abortController = new AbortController();
|
|
127
269
|
constructor(targetOrWrapper, inputOrOptions, maybeOptions) {
|
|
128
270
|
super();
|
|
129
|
-
this.ghost = null;
|
|
130
|
-
this.isWrapperCreated = false;
|
|
131
|
-
this.isDestroyed = false;
|
|
132
|
-
this.isFocused = false;
|
|
133
|
-
this.isDispatchingNativeInput = false;
|
|
134
|
-
this.lastTrackedValue = "";
|
|
135
|
-
this.nativeValueDescriptor = null;
|
|
136
|
-
this.onCutHandler = () => {
|
|
137
|
-
};
|
|
138
|
-
this.mutationObserver = null;
|
|
139
|
-
this.focusSelectTimerId = null;
|
|
140
|
-
this.onBaseCopy = (e) => {
|
|
141
|
-
if (!this.options.copyRaw || this.options.disabled || this.input.type === "password") return;
|
|
142
|
-
const start = this.input.selectionStart ?? 0;
|
|
143
|
-
const end = this.input.selectionEnd ?? start;
|
|
144
|
-
let textToCopy = "";
|
|
145
|
-
if (start !== end) {
|
|
146
|
-
textToCopy = this.extractRawSnippet(this.input.value.slice(start, end));
|
|
147
|
-
} else {
|
|
148
|
-
textToCopy = this.getRawValue();
|
|
149
|
-
}
|
|
150
|
-
if (textToCopy && e.clipboardData) {
|
|
151
|
-
e.preventDefault();
|
|
152
|
-
e.clipboardData.setData("text/plain", textToCopy);
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
this.onBaseFocus = () => {
|
|
156
|
-
this.isFocused = true;
|
|
157
|
-
if (this.options.selectAllOnFocus && this.input.value.length > 0) {
|
|
158
|
-
if (this.focusSelectTimerId !== null) {
|
|
159
|
-
clearTimeout(this.focusSelectTimerId);
|
|
160
|
-
}
|
|
161
|
-
this.focusSelectTimerId = window.setTimeout(() => {
|
|
162
|
-
this.focusSelectTimerId = null;
|
|
163
|
-
if (!this.isDestroyed && document.activeElement === this.input) {
|
|
164
|
-
this.input.select();
|
|
165
|
-
}
|
|
166
|
-
}, 0);
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
this.onBaseBlur = () => {
|
|
170
|
-
this.isFocused = false;
|
|
171
|
-
};
|
|
172
|
-
/**
|
|
173
|
-
* Synchronise le défilement horizontal du ghost avec celui du champ d'entrée natif.
|
|
174
|
-
*/
|
|
175
|
-
this.onScroll = () => {
|
|
176
|
-
if (this.ghost) {
|
|
177
|
-
this.ghost.scrollLeft = this.input.scrollLeft;
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
271
|
const { wrapper: providedWrapper, input, options } = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOptions);
|
|
181
272
|
if (!input || typeof input !== "object" || input.nodeType !== 1 || input.tagName !== "INPUT") {
|
|
182
273
|
throw new Error(`[${new.target.name || "InputMask"}] input (HTMLInputElement) est requis.`);
|
|
@@ -186,20 +277,26 @@ var __WulfIIFE = (() => {
|
|
|
186
277
|
const shouldCreateWrapper = Boolean(options.createWrapper ?? dataCreateWrapper);
|
|
187
278
|
let effectiveWrapper = providedWrapper;
|
|
188
279
|
if (!effectiveWrapper && shouldCreateWrapper) {
|
|
189
|
-
const
|
|
280
|
+
const doc = this.input.ownerDocument || document;
|
|
281
|
+
const span = doc.createElement("span");
|
|
190
282
|
span.className = "wulf-mask-wrapper";
|
|
191
|
-
span.style.display = "inline-grid";
|
|
192
|
-
span.style.gridTemplateColumns = "1fr";
|
|
193
|
-
span.style.gridTemplateRows = "1fr";
|
|
194
|
-
span.style.verticalAlign = "middle";
|
|
195
|
-
span.style.boxSizing = "border-box";
|
|
196
|
-
span.style.position = "relative";
|
|
197
283
|
if (this.input.parentNode) {
|
|
198
284
|
this.input.parentNode.insertBefore(span, this.input);
|
|
199
285
|
}
|
|
200
|
-
span
|
|
201
|
-
|
|
202
|
-
|
|
286
|
+
safeMove(span, this.input, null);
|
|
287
|
+
const view = doc.defaultView || (typeof window !== "undefined" ? window : null);
|
|
288
|
+
const needsFallbackStyles = !span.isConnected || !view || view.getComputedStyle(span).display !== "inline-grid";
|
|
289
|
+
if (needsFallbackStyles) {
|
|
290
|
+
span.style.display = "inline-grid";
|
|
291
|
+
span.style.gridTemplateColumns = "1fr";
|
|
292
|
+
span.style.gridTemplateRows = "1fr";
|
|
293
|
+
span.style.verticalAlign = "middle";
|
|
294
|
+
span.style.boxSizing = "border-box";
|
|
295
|
+
span.style.position = "relative";
|
|
296
|
+
this.input.style.gridArea = "1 / 1 / 2 / 2";
|
|
297
|
+
this.input.style.boxSizing = "border-box";
|
|
298
|
+
this.wasWrapperFallbackStyled = true;
|
|
299
|
+
}
|
|
203
300
|
effectiveWrapper = span;
|
|
204
301
|
this.isWrapperCreated = true;
|
|
205
302
|
}
|
|
@@ -212,12 +309,15 @@ var __WulfIIFE = (() => {
|
|
|
212
309
|
const dataDisabled = this.hasAttr("data-disabled");
|
|
213
310
|
const dataSelectAll = this.getAttr("data-mask-select-on-focus") === "true";
|
|
214
311
|
const dataCopyRaw = this.getAttr("data-mask-copy-raw") === "true";
|
|
215
|
-
const
|
|
312
|
+
const rawDataAlign = this.getAttr("data-mask-align") || this.getAttr("data-align");
|
|
313
|
+
const dataAlign = rawDataAlign && VALID_ALIGNS.has(rawDataAlign) ? rawDataAlign : null;
|
|
314
|
+
this.hadInitialDataAlign = this.wrapper.hasAttribute("data-align");
|
|
216
315
|
const dataAudit = this.getAttr("data-mask-audit");
|
|
217
316
|
const { disabled: optDisabled, align: optAlign, ...otherOptions } = options;
|
|
317
|
+
const validOptAlign = optAlign && VALID_ALIGNS.has(optAlign) ? optAlign : void 0;
|
|
218
318
|
const resolvedDisabled = optDisabled !== void 0 ? optDisabled : dataDisabled ? true : false;
|
|
219
319
|
const resolvedAudit = options.audit ?? (dataAudit !== null ? dataAudit !== "false" : true);
|
|
220
|
-
const isPassword = this.
|
|
320
|
+
const isPassword = this.isPasswordInput();
|
|
221
321
|
this.options = {
|
|
222
322
|
...otherOptions,
|
|
223
323
|
createWrapper: shouldCreateWrapper,
|
|
@@ -225,7 +325,7 @@ var __WulfIIFE = (() => {
|
|
|
225
325
|
selectAllOnFocus: options.selectAllOnFocus ?? dataSelectAll ?? false,
|
|
226
326
|
copyRaw: isPassword ? false : options.copyRaw ?? dataCopyRaw ?? false,
|
|
227
327
|
disabled: resolvedDisabled,
|
|
228
|
-
align:
|
|
328
|
+
align: validOptAlign ?? (dataAlign || void 0),
|
|
229
329
|
emitNativeInput: options.emitNativeInput ?? true,
|
|
230
330
|
audit: resolvedAudit
|
|
231
331
|
};
|
|
@@ -272,16 +372,54 @@ var __WulfIIFE = (() => {
|
|
|
272
372
|
* Attache les écouteurs de base pour focus/blur, copie brute et sélection.
|
|
273
373
|
*/
|
|
274
374
|
bindBaseEvents() {
|
|
275
|
-
|
|
276
|
-
this.input.addEventListener("
|
|
277
|
-
this.input.addEventListener("
|
|
375
|
+
const { signal } = this.abortController;
|
|
376
|
+
this.input.addEventListener("copy", this.onBaseCopy, { signal });
|
|
377
|
+
this.input.addEventListener("focus", this.onBaseFocus, { signal });
|
|
378
|
+
this.input.addEventListener("blur", this.onBaseBlur, { signal });
|
|
278
379
|
}
|
|
380
|
+
onBaseCopy = (e) => {
|
|
381
|
+
if (!this.options.copyRaw || this.options.disabled || this.input.type === "password") return;
|
|
382
|
+
const start = this.input.selectionStart ?? 0;
|
|
383
|
+
const end = this.input.selectionEnd ?? start;
|
|
384
|
+
let textToCopy = "";
|
|
385
|
+
if (start !== end) {
|
|
386
|
+
textToCopy = this.extractRawSnippet(this.input.value.slice(start, end));
|
|
387
|
+
} else {
|
|
388
|
+
textToCopy = this.getRawValue();
|
|
389
|
+
}
|
|
390
|
+
if (textToCopy && e.clipboardData) {
|
|
391
|
+
e.preventDefault();
|
|
392
|
+
e.clipboardData.setData("text/plain", textToCopy);
|
|
393
|
+
}
|
|
394
|
+
};
|
|
279
395
|
/**
|
|
280
396
|
* Extrait la valeur brute d'un extrait de chaîne sélectionné.
|
|
281
397
|
*/
|
|
282
398
|
extractRawSnippet(snippet) {
|
|
283
399
|
return snippet;
|
|
284
400
|
}
|
|
401
|
+
onBaseFocus = () => {
|
|
402
|
+
this.isFocused = true;
|
|
403
|
+
if (this.options.selectAllOnFocus && this.input.value.length > 0) {
|
|
404
|
+
if (this.focusSelectTimerId !== null) {
|
|
405
|
+
clearTimeout(this.focusSelectTimerId);
|
|
406
|
+
}
|
|
407
|
+
this.focusSelectTimerId = window.setTimeout(() => {
|
|
408
|
+
this.focusSelectTimerId = null;
|
|
409
|
+
if (!this.isDestroyed && document.activeElement === this.input) {
|
|
410
|
+
this.input.select();
|
|
411
|
+
}
|
|
412
|
+
}, 0);
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
onBaseBlur = () => {
|
|
416
|
+
this.isFocused = false;
|
|
417
|
+
if (this.isPasswordInput()) {
|
|
418
|
+
this.lastTrackedValue = "";
|
|
419
|
+
this.clearGhost();
|
|
420
|
+
this.wrapper.removeAttribute("data-mask");
|
|
421
|
+
}
|
|
422
|
+
};
|
|
285
423
|
/**
|
|
286
424
|
* Initialise l'observation des modifications dynamiques des attributs data-* et placeholder.
|
|
287
425
|
*/
|
|
@@ -320,21 +458,41 @@ var __WulfIIFE = (() => {
|
|
|
320
458
|
this.mutationObserver.observe(this.input, config);
|
|
321
459
|
}
|
|
322
460
|
}
|
|
461
|
+
/**
|
|
462
|
+
* Indique si le champ natif sous-jacent est de type mot de passe.
|
|
463
|
+
*/
|
|
464
|
+
isPasswordInput() {
|
|
465
|
+
return (this.input.type || "").toLowerCase() === "password";
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Calcule une empreinte non réversible pour détecter les changements sans conserver de secret en RAM.
|
|
469
|
+
*/
|
|
470
|
+
computePasswordDigest(val) {
|
|
471
|
+
let hash = 2166136261;
|
|
472
|
+
for (let i = 0; i < val.length; i++) {
|
|
473
|
+
hash ^= val.charCodeAt(i);
|
|
474
|
+
hash = Math.imul(hash, 16777619);
|
|
475
|
+
}
|
|
476
|
+
return `__pwd:${(hash >>> 0).toString(36)}:${val.length}`;
|
|
477
|
+
}
|
|
323
478
|
/**
|
|
324
479
|
* Modifie dynamiquement l'alignement du champ et du masque fantôme.
|
|
325
480
|
*/
|
|
326
481
|
setAlign(align) {
|
|
327
|
-
const
|
|
482
|
+
const normalized = align && VALID_ALIGNS.has(align) ? align : null;
|
|
483
|
+
const targetAlign = normalized || void 0;
|
|
328
484
|
const currentAttr = this.wrapper.getAttribute("data-align");
|
|
329
|
-
|
|
485
|
+
const hasExpectedClass = normalized ? this.wrapper.classList.contains(`align-${normalized}`) : !this.wrapper.classList.contains("align-left") && !this.wrapper.classList.contains("align-right") && !this.wrapper.classList.contains("align-center");
|
|
486
|
+
if (this.options.align === targetAlign && currentAttr === normalized && hasExpectedClass) {
|
|
330
487
|
return;
|
|
331
488
|
}
|
|
332
489
|
this.options.align = targetAlign;
|
|
333
490
|
this.wrapper.classList.remove("align-left", "align-right", "align-center");
|
|
334
|
-
if (
|
|
335
|
-
this.wrapper.classList.add(`align-${
|
|
336
|
-
|
|
337
|
-
|
|
491
|
+
if (normalized) {
|
|
492
|
+
this.wrapper.classList.add(`align-${normalized}`);
|
|
493
|
+
this.wasAlignSet = true;
|
|
494
|
+
if (this.wrapper.getAttribute("data-align") !== normalized) {
|
|
495
|
+
this.wrapper.setAttribute("data-align", normalized);
|
|
338
496
|
}
|
|
339
497
|
} else {
|
|
340
498
|
if (this.wrapper.hasAttribute("data-align")) {
|
|
@@ -360,14 +518,18 @@ var __WulfIIFE = (() => {
|
|
|
360
518
|
} else if (attrName === "data-mask-select-on-focus") {
|
|
361
519
|
this.options.selectAllOnFocus = this.getAttr("data-mask-select-on-focus") === "true";
|
|
362
520
|
} else if (attrName === "data-mask-copy-raw") {
|
|
363
|
-
this.options.copyRaw = this.
|
|
521
|
+
this.options.copyRaw = this.isPasswordInput() ? false : this.getAttr("data-mask-copy-raw") === "true";
|
|
364
522
|
} else if (attrName === "type") {
|
|
365
|
-
if (this.
|
|
523
|
+
if (this.isPasswordInput()) {
|
|
366
524
|
this.options.copyRaw = false;
|
|
525
|
+
this.lastTrackedValue = "";
|
|
526
|
+
this.clearGhost();
|
|
527
|
+
this.wrapper.removeAttribute("data-mask");
|
|
367
528
|
this.onPasswordModeDetected();
|
|
368
529
|
}
|
|
369
530
|
} else if (attrName === "data-mask-align" || attrName === "data-align") {
|
|
370
|
-
const
|
|
531
|
+
const rawAlign = this.getAttr("data-mask-align") || this.getAttr("data-align");
|
|
532
|
+
const align = rawAlign && VALID_ALIGNS.has(rawAlign) ? rawAlign : null;
|
|
371
533
|
if (align !== (this.options.align ?? null)) {
|
|
372
534
|
this.setAlign(align);
|
|
373
535
|
}
|
|
@@ -395,15 +557,42 @@ var __WulfIIFE = (() => {
|
|
|
395
557
|
if (existing) {
|
|
396
558
|
existing.remove();
|
|
397
559
|
}
|
|
398
|
-
this.
|
|
560
|
+
const doc = this.input.ownerDocument || document;
|
|
561
|
+
this.ghost = doc.createElement("div");
|
|
399
562
|
this.ghost.className = "mask-ghost";
|
|
400
563
|
this.ghost.setAttribute("aria-hidden", "true");
|
|
401
564
|
this.ghost.style.display = "flex";
|
|
402
565
|
this.ghost.style.alignItems = "center";
|
|
403
566
|
this.wrapper.appendChild(this.ghost);
|
|
404
567
|
this.wrapper.classList.add("has-ghost");
|
|
568
|
+
const view = doc.defaultView || (typeof window !== "undefined" ? window : null);
|
|
569
|
+
if (!this.wrapper.isConnected || !view || view.getComputedStyle(this.ghost).pointerEvents !== "none") {
|
|
570
|
+
this.ghost.style.gridArea = "1 / 1 / 2 / 2";
|
|
571
|
+
this.ghost.style.pointerEvents = "none";
|
|
572
|
+
}
|
|
405
573
|
this.syncGhostStyles();
|
|
406
574
|
}
|
|
575
|
+
/**
|
|
576
|
+
* Met à jour atomiquement le contenu du conteneur fantôme et synchronise .has-visible-ghost.
|
|
577
|
+
*/
|
|
578
|
+
setGhostContent(...nodes) {
|
|
579
|
+
if (!this.ghost) return;
|
|
580
|
+
if (typeof this.ghost.replaceChildren === "function") {
|
|
581
|
+
this.ghost.replaceChildren(...nodes);
|
|
582
|
+
} else {
|
|
583
|
+
this.ghost.textContent = "";
|
|
584
|
+
for (const n of nodes) {
|
|
585
|
+
this.ghost.appendChild(typeof n === "string" ? document.createTextNode(n) : n);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
this.wrapper.classList.toggle("has-visible-ghost", nodes.length > 0);
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Vide atomiquement le conteneur fantôme et rétablit l'affichage du placeholder natif.
|
|
592
|
+
*/
|
|
593
|
+
clearGhost() {
|
|
594
|
+
this.setGhostContent();
|
|
595
|
+
}
|
|
407
596
|
/**
|
|
408
597
|
* Clone fidèlement la géométrie typographique et les espacements de l'input natif
|
|
409
598
|
* sur le conteneur fantôme pour garantir un alignement sub-pixel absolu quel que soit
|
|
@@ -436,12 +625,17 @@ var __WulfIIFE = (() => {
|
|
|
436
625
|
this.ghost.style.textAlign = style.textAlign;
|
|
437
626
|
this.ghost.style.direction = style.direction;
|
|
438
627
|
const isRtl = style.direction === "rtl" || this.input.getAttribute("dir") === "rtl" || this.wrapper.getAttribute("dir") === "rtl";
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
628
|
+
const textAlign = style.textAlign;
|
|
629
|
+
if (textAlign === "right") {
|
|
630
|
+
this.ghost.style.justifyContent = "right";
|
|
631
|
+
} else if (textAlign === "left") {
|
|
632
|
+
this.ghost.style.justifyContent = "left";
|
|
633
|
+
} else if (textAlign === "center") {
|
|
442
634
|
this.ghost.style.justifyContent = "center";
|
|
635
|
+
} else if (textAlign === "end") {
|
|
636
|
+
this.ghost.style.justifyContent = isRtl ? "left" : "right";
|
|
443
637
|
} else {
|
|
444
|
-
this.ghost.style.justifyContent = "
|
|
638
|
+
this.ghost.style.justifyContent = isRtl ? "right" : "left";
|
|
445
639
|
}
|
|
446
640
|
}
|
|
447
641
|
/**
|
|
@@ -465,15 +659,23 @@ var __WulfIIFE = (() => {
|
|
|
465
659
|
this.isDispatchingNativeInput = true;
|
|
466
660
|
try {
|
|
467
661
|
const tracker = this.input._valueTracker;
|
|
468
|
-
if (tracker && typeof tracker.setValue === "function") {
|
|
662
|
+
if (!this.isPasswordInput() && tracker && typeof tracker.setValue === "function") {
|
|
469
663
|
tracker.setValue(this.lastTrackedValue);
|
|
470
664
|
}
|
|
471
|
-
this.lastTrackedValue = this.input.value;
|
|
665
|
+
this.lastTrackedValue = this.isPasswordInput() ? "" : this.input.value;
|
|
472
666
|
this.input.dispatchEvent(new Event("input", { bubbles: true, cancelable: false }));
|
|
473
667
|
} finally {
|
|
474
668
|
this.isDispatchingNativeInput = false;
|
|
475
669
|
}
|
|
476
670
|
}
|
|
671
|
+
/**
|
|
672
|
+
* Synchronise le défilement horizontal du ghost avec celui du champ d'entrée natif.
|
|
673
|
+
*/
|
|
674
|
+
onScroll = () => {
|
|
675
|
+
if (this.ghost) {
|
|
676
|
+
this.ghost.scrollLeft = this.input.scrollLeft;
|
|
677
|
+
}
|
|
678
|
+
};
|
|
477
679
|
/**
|
|
478
680
|
* Intercepte les modifications directes de la propriété input.value (ex: input.value = '').
|
|
479
681
|
*/
|
|
@@ -585,15 +787,19 @@ var __WulfIIFE = (() => {
|
|
|
585
787
|
audit() {
|
|
586
788
|
const warnings = [];
|
|
587
789
|
const doc = this.input.ownerDocument || document;
|
|
790
|
+
const root = typeof this.input.getRootNode === "function" ? this.input.getRootNode() : doc;
|
|
791
|
+
const labelRoot = typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root : doc;
|
|
588
792
|
const ariaLabel = this.input.getAttribute("aria-label")?.trim();
|
|
589
793
|
const hasValidLabelledby = this.checkAriaIdReferences(this.input, "aria-labelledby", warnings);
|
|
590
794
|
const hasWrappingLabel = Boolean(this.input.closest("label"));
|
|
591
795
|
const hasNativeLabels = Boolean(this.input.labels && this.input.labels.length > 0);
|
|
592
796
|
let hasExplicitLabelFor = false;
|
|
593
|
-
if (this.input.id
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
797
|
+
if (this.input.id) {
|
|
798
|
+
try {
|
|
799
|
+
hasExplicitLabelFor = Boolean(labelRoot.querySelector(`label[for="${safeCssEscape(this.input.id)}"]`));
|
|
800
|
+
} catch {
|
|
801
|
+
hasExplicitLabelFor = false;
|
|
802
|
+
}
|
|
597
803
|
}
|
|
598
804
|
if (!ariaLabel && !hasValidLabelledby && !hasWrappingLabel && !hasNativeLabels && !hasExplicitLabelFor) {
|
|
599
805
|
warnings.push(
|
|
@@ -639,25 +845,41 @@ var __WulfIIFE = (() => {
|
|
|
639
845
|
this.mutationObserver.disconnect();
|
|
640
846
|
this.mutationObserver = null;
|
|
641
847
|
}
|
|
642
|
-
this.
|
|
643
|
-
this.
|
|
644
|
-
this.input.removeEventListener("blur", this.onBaseBlur);
|
|
848
|
+
this.abortController.abort();
|
|
849
|
+
this.lastTrackedValue = "";
|
|
645
850
|
this.unhookValueProperty();
|
|
646
851
|
if (this.ghost) {
|
|
647
852
|
this.ghost.remove();
|
|
648
853
|
this.ghost = null;
|
|
649
854
|
}
|
|
650
855
|
if (this.isWrapperCreated && this.wrapper) {
|
|
651
|
-
this.
|
|
652
|
-
|
|
653
|
-
|
|
856
|
+
if (this.wasWrapperFallbackStyled) {
|
|
857
|
+
this.input.style.gridArea = "";
|
|
858
|
+
this.input.style.boxSizing = "";
|
|
859
|
+
}
|
|
860
|
+
if (this.wrapper.parentElement) {
|
|
861
|
+
safeMove(this.wrapper.parentElement, this.input, this.wrapper);
|
|
862
|
+
} else if (this.wrapper.parentNode) {
|
|
654
863
|
this.wrapper.parentNode.insertBefore(this.input, this.wrapper);
|
|
655
864
|
}
|
|
656
865
|
this.wrapper.remove();
|
|
657
866
|
} else if (this.wrapper) {
|
|
658
867
|
this.wrapper.removeAttribute("data-mask");
|
|
659
868
|
this.wrapper.removeAttribute("data-disabled");
|
|
660
|
-
this.
|
|
869
|
+
if (this.wasAlignSet && !this.hadInitialDataAlign) {
|
|
870
|
+
this.wrapper.removeAttribute("data-align");
|
|
871
|
+
}
|
|
872
|
+
if (this.wasAlignSet) {
|
|
873
|
+
this.wrapper.classList.remove("align-left", "align-right", "align-center");
|
|
874
|
+
}
|
|
875
|
+
this.wrapper.classList.remove(
|
|
876
|
+
"is-complete",
|
|
877
|
+
"is-focused",
|
|
878
|
+
"mask-focus-only",
|
|
879
|
+
"has-selection",
|
|
880
|
+
"has-ghost",
|
|
881
|
+
"has-visible-ghost"
|
|
882
|
+
);
|
|
661
883
|
}
|
|
662
884
|
}
|
|
663
885
|
};
|
|
@@ -671,19 +893,34 @@ var __WulfIIFE = (() => {
|
|
|
671
893
|
"#": { pattern: /[a-zA-Z0-9]/, transform: (c) => c.toUpperCase() }
|
|
672
894
|
};
|
|
673
895
|
var MaskEngine = class _MaskEngine {
|
|
896
|
+
pattern;
|
|
897
|
+
patterns = [];
|
|
898
|
+
subEngines = [];
|
|
899
|
+
activeEngine = null;
|
|
900
|
+
placeholderChar;
|
|
901
|
+
tokens;
|
|
902
|
+
slots = [];
|
|
903
|
+
fullMaskTemplate = "";
|
|
904
|
+
prefixSlotsCount = 0;
|
|
905
|
+
prefixString = "";
|
|
906
|
+
strict = true;
|
|
907
|
+
autoLowercase = false;
|
|
674
908
|
constructor(pattern, options = {}) {
|
|
675
|
-
this.patterns = [];
|
|
676
|
-
this.subEngines = [];
|
|
677
|
-
this.activeEngine = null;
|
|
678
|
-
this.slots = [];
|
|
679
|
-
this.fullMaskTemplate = "";
|
|
680
|
-
this.prefixSlotsCount = 0;
|
|
681
|
-
this.prefixString = "";
|
|
682
|
-
this.strict = true;
|
|
683
|
-
this.autoLowercase = false;
|
|
684
909
|
const opts = options || {};
|
|
685
|
-
|
|
686
|
-
this.
|
|
910
|
+
const rawPlaceholder = String(opts.placeholderChar || "_");
|
|
911
|
+
this.placeholderChar = Array.from(rawPlaceholder)[0] || "_";
|
|
912
|
+
const tokenMap = /* @__PURE__ */ Object.create(null);
|
|
913
|
+
for (const [k, v] of Object.entries(DEFAULT_TOKENS)) {
|
|
914
|
+
tokenMap[k] = v;
|
|
915
|
+
}
|
|
916
|
+
if (opts.tokens && typeof opts.tokens === "object") {
|
|
917
|
+
for (const [k, v] of Object.entries(opts.tokens)) {
|
|
918
|
+
if (k !== "__proto__" && k !== "constructor" && k !== "prototype" && v) {
|
|
919
|
+
tokenMap[k] = v;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
this.tokens = tokenMap;
|
|
687
924
|
this.strict = opts.strict !== false;
|
|
688
925
|
this.autoLowercase = opts.autoLowercase ?? false;
|
|
689
926
|
this.pattern = "";
|
|
@@ -743,7 +980,7 @@ var __WulfIIFE = (() => {
|
|
|
743
980
|
i++;
|
|
744
981
|
char = this.pattern[i];
|
|
745
982
|
}
|
|
746
|
-
const token = !isEscaped ? this.tokens[char] : void 0;
|
|
983
|
+
const token = !isEscaped && Object.hasOwn(this.tokens, char) ? this.tokens[char] : void 0;
|
|
747
984
|
if (token) {
|
|
748
985
|
isPrefixMode = false;
|
|
749
986
|
this.slots.push({
|
|
@@ -790,7 +1027,7 @@ var __WulfIIFE = (() => {
|
|
|
790
1027
|
return p.length > 0 && trimmed.toLowerCase().startsWith(p.trim().toLowerCase());
|
|
791
1028
|
});
|
|
792
1029
|
const candidates = withMatchingPrefix.length > 0 ? withMatchingPrefix : this.subEngines;
|
|
793
|
-
const maxCandidate =
|
|
1030
|
+
const maxCandidate = candidates.toSorted((a, b) => b.getEditableCount() - a.getEditableCount())[0];
|
|
794
1031
|
const raw = maxCandidate ? maxCandidate.extractRaw(trimmed) : trimmed;
|
|
795
1032
|
const rawLen = raw.length;
|
|
796
1033
|
for (const eng of candidates) {
|
|
@@ -846,6 +1083,18 @@ var __WulfIIFE = (() => {
|
|
|
846
1083
|
*/
|
|
847
1084
|
setStrict(strict) {
|
|
848
1085
|
this.strict = strict;
|
|
1086
|
+
for (const sub of this.subEngines) {
|
|
1087
|
+
sub.setStrict(strict);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
/**
|
|
1091
|
+
* Active ou désactive dynamiquement la mise en minuscules automatique.
|
|
1092
|
+
*/
|
|
1093
|
+
setAutoLowercase(autoLowercase) {
|
|
1094
|
+
this.autoLowercase = autoLowercase;
|
|
1095
|
+
for (const sub of this.subEngines) {
|
|
1096
|
+
sub.setAutoLowercase(autoLowercase);
|
|
1097
|
+
}
|
|
849
1098
|
}
|
|
850
1099
|
/**
|
|
851
1100
|
* Indique si le masque est en mode strict.
|
|
@@ -1070,9 +1319,10 @@ var __WulfIIFE = (() => {
|
|
|
1070
1319
|
|
|
1071
1320
|
// src/mask/MaskHistory.ts
|
|
1072
1321
|
var MaskHistory = class {
|
|
1322
|
+
stack = [];
|
|
1323
|
+
index = -1;
|
|
1324
|
+
maxDepth;
|
|
1073
1325
|
constructor(maxDepth = 50) {
|
|
1074
|
-
this.stack = [];
|
|
1075
|
-
this.index = -1;
|
|
1076
1326
|
this.maxDepth = maxDepth;
|
|
1077
1327
|
}
|
|
1078
1328
|
/**
|
|
@@ -1150,6 +1400,7 @@ var __WulfIIFE = (() => {
|
|
|
1150
1400
|
|
|
1151
1401
|
// src/mask/MaskKeyboard.ts
|
|
1152
1402
|
var MaskKeyboard = class {
|
|
1403
|
+
delegate;
|
|
1153
1404
|
constructor(delegate) {
|
|
1154
1405
|
this.delegate = delegate;
|
|
1155
1406
|
}
|
|
@@ -1157,6 +1408,7 @@ var __WulfIIFE = (() => {
|
|
|
1157
1408
|
* Analyse et traite l'événement keydown de l'input.
|
|
1158
1409
|
*/
|
|
1159
1410
|
handleKeyDown(e) {
|
|
1411
|
+
if (isImeComposing(e)) return;
|
|
1160
1412
|
const input = this.delegate.getInput();
|
|
1161
1413
|
const engine = this.delegate.getEngine();
|
|
1162
1414
|
const history = this.delegate.getHistory();
|
|
@@ -1250,7 +1502,7 @@ var __WulfIIFE = (() => {
|
|
|
1250
1502
|
input.setSelectionRange(minPos, minPos);
|
|
1251
1503
|
return;
|
|
1252
1504
|
}
|
|
1253
|
-
if (e.key === "Home" && !e.shiftKey) {
|
|
1505
|
+
if (e.key === "Home" && minPos > 0 && !e.shiftKey && !e.ctrlKey && !e.metaKey && !e.altKey) {
|
|
1254
1506
|
e.preventDefault();
|
|
1255
1507
|
input.setSelectionRange(minPos, minPos);
|
|
1256
1508
|
return;
|
|
@@ -1355,6 +1607,23 @@ var __WulfIIFE = (() => {
|
|
|
1355
1607
|
|
|
1356
1608
|
// src/mask/InputMask.ts
|
|
1357
1609
|
var InputMask = class extends BaseInputMask {
|
|
1610
|
+
engine;
|
|
1611
|
+
history;
|
|
1612
|
+
keyboard;
|
|
1613
|
+
isComposing = false;
|
|
1614
|
+
isUndoingRedoing = false;
|
|
1615
|
+
isMouseDown = false;
|
|
1616
|
+
isApplyingMask = false;
|
|
1617
|
+
lastValue = "";
|
|
1618
|
+
lastInternalRemainingMask = "";
|
|
1619
|
+
isNotifying = false;
|
|
1620
|
+
hasPendingNotification = false;
|
|
1621
|
+
onChangeNativeHandler = () => {
|
|
1622
|
+
};
|
|
1623
|
+
wasInputModeInferred = false;
|
|
1624
|
+
cutTimerId = null;
|
|
1625
|
+
pasteTimerId = null;
|
|
1626
|
+
resetTimerId = null;
|
|
1358
1627
|
constructor(targetOrWrapper, inputOrOptions, options) {
|
|
1359
1628
|
const args = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, options);
|
|
1360
1629
|
const wrap = args.wrapper;
|
|
@@ -1387,20 +1656,6 @@ var __WulfIIFE = (() => {
|
|
|
1387
1656
|
onComplete: opts.onComplete || opts.oncomplete
|
|
1388
1657
|
};
|
|
1389
1658
|
super(wrap, inp, resolvedOptions);
|
|
1390
|
-
this.isComposing = false;
|
|
1391
|
-
this.isUndoingRedoing = false;
|
|
1392
|
-
this.isMouseDown = false;
|
|
1393
|
-
this.isApplyingMask = false;
|
|
1394
|
-
this.lastValue = "";
|
|
1395
|
-
this.lastInternalRemainingMask = "";
|
|
1396
|
-
this.isNotifying = false;
|
|
1397
|
-
this.hasPendingNotification = false;
|
|
1398
|
-
this.onChangeNativeHandler = () => {
|
|
1399
|
-
};
|
|
1400
|
-
this.wasInputModeInferred = false;
|
|
1401
|
-
this.cutTimerId = null;
|
|
1402
|
-
this.pasteTimerId = null;
|
|
1403
|
-
this.resetTimerId = null;
|
|
1404
1659
|
this.history = new MaskHistory();
|
|
1405
1660
|
this.engine = new MaskEngine(this.options.mask || "", {
|
|
1406
1661
|
placeholderChar: this.options.placeholderChar,
|
|
@@ -1419,16 +1674,17 @@ var __WulfIIFE = (() => {
|
|
|
1419
1674
|
enforceMinCursor: () => this.enforceMinCursor()
|
|
1420
1675
|
});
|
|
1421
1676
|
this.bindEvents();
|
|
1422
|
-
this.lastValue = this.input.value;
|
|
1677
|
+
this.lastValue = this.isPasswordInput() ? this.computePasswordDigest(this.input.value) : this.input.value;
|
|
1423
1678
|
this.syncInitialValue();
|
|
1424
1679
|
this.runAuditWarning(this.options.audit);
|
|
1425
1680
|
}
|
|
1426
1681
|
getSpecificAuditWarnings() {
|
|
1427
1682
|
const warnings = [];
|
|
1428
|
-
const
|
|
1683
|
+
const describedbyWarnings = [];
|
|
1684
|
+
const hasValidDescribedby = this.checkAriaIdReferences(this.input, "aria-describedby", describedbyWarnings);
|
|
1429
1685
|
const hasPlaceholder = Boolean(this.input.getAttribute("placeholder")?.trim());
|
|
1430
1686
|
const hasAriaPlaceholder = Boolean(this.input.getAttribute("aria-placeholder")?.trim());
|
|
1431
|
-
if (!
|
|
1687
|
+
if (!hasValidDescribedby && !hasPlaceholder && !hasAriaPlaceholder && !this.options.disabled) {
|
|
1432
1688
|
warnings.push(
|
|
1433
1689
|
"Indication du format attendu manquante : d\xE9finissez aria-describedby, placeholder ou aria-placeholder pour informer les technologies d'assistance (WCAG 3.3.2)."
|
|
1434
1690
|
);
|
|
@@ -1440,6 +1696,11 @@ var __WulfIIFE = (() => {
|
|
|
1440
1696
|
}
|
|
1441
1697
|
onPasswordModeDetected() {
|
|
1442
1698
|
this.history.clear();
|
|
1699
|
+
this.lastValue = "";
|
|
1700
|
+
this.lastInternalRemainingMask = "";
|
|
1701
|
+
this.lastTrackedValue = "";
|
|
1702
|
+
this.clearGhost();
|
|
1703
|
+
this.wrapper.removeAttribute("data-mask");
|
|
1443
1704
|
}
|
|
1444
1705
|
/**
|
|
1445
1706
|
* Formate statiquement une valeur selon un masque donné sans nécessiter d'élément DOM.
|
|
@@ -1463,11 +1724,12 @@ var __WulfIIFE = (() => {
|
|
|
1463
1724
|
if (disabled) {
|
|
1464
1725
|
this.wrapper.removeAttribute("data-mask");
|
|
1465
1726
|
this.wrapper.classList.remove("is-complete", "has-selection");
|
|
1466
|
-
|
|
1727
|
+
this.clearGhost();
|
|
1467
1728
|
this.checkValueChange();
|
|
1468
1729
|
} else {
|
|
1469
1730
|
this.applyMask(this.input.value, this.input.selectionStart ?? this.input.value.length);
|
|
1470
1731
|
}
|
|
1732
|
+
this.syncInferredInputMode();
|
|
1471
1733
|
}
|
|
1472
1734
|
/**
|
|
1473
1735
|
* Associe les écouteurs d'événements nécessaires.
|
|
@@ -1504,22 +1766,23 @@ var __WulfIIFE = (() => {
|
|
|
1504
1766
|
if (this.isDestroyed) return;
|
|
1505
1767
|
this.checkValueChange();
|
|
1506
1768
|
};
|
|
1507
|
-
|
|
1508
|
-
this.input.addEventListener("
|
|
1509
|
-
this.input.addEventListener("
|
|
1510
|
-
this.input.addEventListener("
|
|
1511
|
-
this.input.addEventListener("
|
|
1512
|
-
this.input.addEventListener("
|
|
1513
|
-
this.input.addEventListener("
|
|
1514
|
-
this.input.addEventListener("
|
|
1515
|
-
this.input.addEventListener("
|
|
1516
|
-
this.input.addEventListener("
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
this.input.addEventListener("
|
|
1520
|
-
this.input.addEventListener("
|
|
1521
|
-
this.input.addEventListener("
|
|
1522
|
-
this.input.addEventListener("
|
|
1769
|
+
const { signal } = this.abortController;
|
|
1770
|
+
this.input.addEventListener("beforeinput", this.onBeforeInput, { signal });
|
|
1771
|
+
this.input.addEventListener("input", this.handleInput, { signal });
|
|
1772
|
+
this.input.addEventListener("keydown", this.onKeyDown, { signal });
|
|
1773
|
+
this.input.addEventListener("paste", this.onPaste, { signal });
|
|
1774
|
+
this.input.addEventListener("focus", this.onFocus, { signal });
|
|
1775
|
+
this.input.addEventListener("blur", this.onBlur, { signal });
|
|
1776
|
+
this.input.addEventListener("click", this.onClick, { signal });
|
|
1777
|
+
this.input.addEventListener("keyup", this.onKeyUp, { signal });
|
|
1778
|
+
this.input.addEventListener("select", this.onSelect, { signal });
|
|
1779
|
+
this.input.addEventListener("mousedown", this.onMouseDown, { signal });
|
|
1780
|
+
window.addEventListener("mouseup", this.onMouseUp, { signal });
|
|
1781
|
+
this.input.addEventListener("compositionstart", this.onCompositionStart, { signal });
|
|
1782
|
+
this.input.addEventListener("compositionend", this.onCompositionEnd, { signal });
|
|
1783
|
+
this.input.addEventListener("scroll", this.onScroll, { passive: true, signal });
|
|
1784
|
+
this.input.addEventListener("cut", this.onCutHandler, { signal });
|
|
1785
|
+
this.input.addEventListener("change", this.onChangeNativeHandler, { signal });
|
|
1523
1786
|
if (this.input.form) {
|
|
1524
1787
|
this.onFormResetHandler = () => {
|
|
1525
1788
|
if (this.resetTimerId !== null) clearTimeout(this.resetTimerId);
|
|
@@ -1533,7 +1796,7 @@ var __WulfIIFE = (() => {
|
|
|
1533
1796
|
}
|
|
1534
1797
|
}, 0);
|
|
1535
1798
|
};
|
|
1536
|
-
this.input.form.addEventListener("reset", this.onFormResetHandler);
|
|
1799
|
+
this.input.form.addEventListener("reset", this.onFormResetHandler, { signal });
|
|
1537
1800
|
}
|
|
1538
1801
|
}
|
|
1539
1802
|
/**
|
|
@@ -1570,29 +1833,12 @@ var __WulfIIFE = (() => {
|
|
|
1570
1833
|
clearTimeout(this.resetTimerId);
|
|
1571
1834
|
this.resetTimerId = null;
|
|
1572
1835
|
}
|
|
1573
|
-
this.input.removeEventListener("beforeinput", this.onBeforeInput);
|
|
1574
|
-
this.input.removeEventListener("input", this.handleInput);
|
|
1575
|
-
this.input.removeEventListener("keydown", this.onKeyDown);
|
|
1576
|
-
this.input.removeEventListener("paste", this.onPaste);
|
|
1577
|
-
this.input.removeEventListener("focus", this.onFocus);
|
|
1578
|
-
this.input.removeEventListener("blur", this.onBlur);
|
|
1579
|
-
this.input.removeEventListener("click", this.onClick);
|
|
1580
|
-
this.input.removeEventListener("keyup", this.onKeyUp);
|
|
1581
|
-
this.input.removeEventListener("select", this.onSelect);
|
|
1582
|
-
this.input.removeEventListener("mousedown", this.onMouseDown);
|
|
1583
|
-
window.removeEventListener("mouseup", this.onMouseUp);
|
|
1584
|
-
this.input.removeEventListener("compositionstart", this.onCompositionStart);
|
|
1585
|
-
this.input.removeEventListener("compositionend", this.onCompositionEnd);
|
|
1586
|
-
this.input.removeEventListener("scroll", this.onScroll);
|
|
1587
|
-
this.input.removeEventListener("cut", this.onCutHandler);
|
|
1588
|
-
this.input.removeEventListener("change", this.onChangeNativeHandler);
|
|
1589
|
-
if (this.input.form && this.onFormResetHandler) {
|
|
1590
|
-
this.input.form.removeEventListener("reset", this.onFormResetHandler);
|
|
1591
|
-
}
|
|
1592
1836
|
if (this.wasInputModeInferred && this.input.getAttribute("inputmode") === "numeric") {
|
|
1593
1837
|
this.input.removeAttribute("inputmode");
|
|
1594
1838
|
}
|
|
1595
1839
|
this.history.clear();
|
|
1840
|
+
this.lastValue = "";
|
|
1841
|
+
this.lastInternalRemainingMask = "";
|
|
1596
1842
|
super.destroy();
|
|
1597
1843
|
}
|
|
1598
1844
|
/**
|
|
@@ -1666,6 +1912,7 @@ var __WulfIIFE = (() => {
|
|
|
1666
1912
|
this.setStrict(strictVal !== "false");
|
|
1667
1913
|
} else if (attrName === "data-mask-auto-lowercase") {
|
|
1668
1914
|
this.options.autoLowercase = this.getAttr("data-mask-auto-lowercase") === "true";
|
|
1915
|
+
this.engine.setAutoLowercase(this.options.autoLowercase);
|
|
1669
1916
|
this.engine.compile(this.options.mask || "");
|
|
1670
1917
|
this.applyMask(this.input.value, this.input.selectionStart ?? this.input.value.length);
|
|
1671
1918
|
} else if (attrName === "placeholder") {
|
|
@@ -1745,7 +1992,7 @@ var __WulfIIFE = (() => {
|
|
|
1745
1992
|
if (this.options.disabled) return;
|
|
1746
1993
|
if (this.isComposing) return;
|
|
1747
1994
|
if (!this.engine.isStrict()) return;
|
|
1748
|
-
if (e.inputType === "insertFromPaste") return;
|
|
1995
|
+
if (e.inputType === "insertFromPaste" || e.inputType === "insertReplacementText") return;
|
|
1749
1996
|
if (e.inputType && e.inputType.startsWith("insert")) {
|
|
1750
1997
|
const totalSlots = this.engine.getEditableCount();
|
|
1751
1998
|
if (totalSlots > 0) {
|
|
@@ -1767,7 +2014,8 @@ var __WulfIIFE = (() => {
|
|
|
1767
2014
|
if (this.isDispatchingNativeInput) return;
|
|
1768
2015
|
if (this.isComposing) return;
|
|
1769
2016
|
const hasOnInput = Boolean(this.options.onInput || this.options.oninput);
|
|
1770
|
-
|
|
2017
|
+
const currentComparison = this.isPasswordInput() ? this.computePasswordDigest(this.input.value) : this.input.value;
|
|
2018
|
+
if (hasOnInput && currentComparison !== this.lastValue) {
|
|
1771
2019
|
this.checkValueChange();
|
|
1772
2020
|
}
|
|
1773
2021
|
if (this.options.disabled) {
|
|
@@ -1861,8 +2109,14 @@ var __WulfIIFE = (() => {
|
|
|
1861
2109
|
}
|
|
1862
2110
|
onBlur() {
|
|
1863
2111
|
this.wrapper.classList.remove("is-focused", "has-selection");
|
|
1864
|
-
if (this.
|
|
2112
|
+
if (this.isPasswordInput()) {
|
|
1865
2113
|
this.history.clear();
|
|
2114
|
+
this.lastValue = "";
|
|
2115
|
+
this.lastInternalRemainingMask = "";
|
|
2116
|
+
this.lastTrackedValue = "";
|
|
2117
|
+
this.clearGhost();
|
|
2118
|
+
this.wrapper.removeAttribute("data-mask");
|
|
2119
|
+
return;
|
|
1866
2120
|
}
|
|
1867
2121
|
this.updateGhost(this.input.value);
|
|
1868
2122
|
}
|
|
@@ -1916,26 +2170,25 @@ var __WulfIIFE = (() => {
|
|
|
1916
2170
|
// ==========================================================================
|
|
1917
2171
|
updateGhost(formatted) {
|
|
1918
2172
|
if (!this.ghost) return;
|
|
1919
|
-
if (this.options.disabled) {
|
|
1920
|
-
this.
|
|
2173
|
+
if (this.options.disabled || this.isPasswordInput()) {
|
|
2174
|
+
this.clearGhost();
|
|
1921
2175
|
return;
|
|
1922
2176
|
}
|
|
1923
2177
|
const isCleanEmpty = !formatted || formatted === this.engine.getPrefix();
|
|
1924
2178
|
if (this.shouldHideGhostForPlaceholder(isCleanEmpty)) {
|
|
1925
|
-
this.
|
|
2179
|
+
this.clearGhost();
|
|
1926
2180
|
return;
|
|
1927
2181
|
}
|
|
1928
2182
|
const fullTemplate = this.engine.getFullMaskTemplate();
|
|
1929
2183
|
const rest = fullTemplate.length > formatted.length ? fullTemplate.substring(formatted.length) : "";
|
|
1930
|
-
this.
|
|
1931
|
-
const spanTyped =
|
|
2184
|
+
const doc = this.input.ownerDocument || document;
|
|
2185
|
+
const spanTyped = doc.createElement("span");
|
|
1932
2186
|
spanTyped.className = "mask-ghost-typed";
|
|
1933
2187
|
spanTyped.textContent = formatted;
|
|
1934
|
-
const spanRemaining =
|
|
2188
|
+
const spanRemaining = doc.createElement("span");
|
|
1935
2189
|
spanRemaining.className = "mask-ghost-remaining";
|
|
1936
2190
|
spanRemaining.textContent = rest;
|
|
1937
|
-
this.
|
|
1938
|
-
this.ghost.appendChild(spanRemaining);
|
|
2191
|
+
this.setGhostContent(spanTyped, spanRemaining);
|
|
1939
2192
|
this.ghost.scrollLeft = this.input.scrollLeft;
|
|
1940
2193
|
}
|
|
1941
2194
|
applyMask(rawOrPartial, cursorPosition, forceExactCursor = false) {
|
|
@@ -1946,10 +2199,17 @@ var __WulfIIFE = (() => {
|
|
|
1946
2199
|
try {
|
|
1947
2200
|
formatted = this.engine.format(rawOrPartial);
|
|
1948
2201
|
const remainingMask = this.engine.getRemainingMask(formatted);
|
|
2202
|
+
const isPwd = this.isPasswordInput();
|
|
1949
2203
|
this.input.value = formatted;
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
2204
|
+
if (isPwd) {
|
|
2205
|
+
this.lastInternalRemainingMask = "";
|
|
2206
|
+
this.wrapper.removeAttribute("data-mask");
|
|
2207
|
+
this.clearGhost();
|
|
2208
|
+
} else {
|
|
2209
|
+
this.lastInternalRemainingMask = remainingMask;
|
|
2210
|
+
this.wrapper.setAttribute("data-mask", remainingMask);
|
|
2211
|
+
this.updateGhost(formatted);
|
|
2212
|
+
}
|
|
1953
2213
|
const minPos = this.engine.getPrefixLength();
|
|
1954
2214
|
let safeCursor;
|
|
1955
2215
|
if (forceExactCursor || this.isUndoingRedoing) {
|
|
@@ -1961,7 +2221,7 @@ var __WulfIIFE = (() => {
|
|
|
1961
2221
|
this.input.setSelectionRange(safeCursor, safeCursor);
|
|
1962
2222
|
isCompleted = this.isComplete();
|
|
1963
2223
|
this.wrapper.classList.toggle("is-complete", isCompleted);
|
|
1964
|
-
if (
|
|
2224
|
+
if (isPwd) {
|
|
1965
2225
|
this.options.copyRaw = false;
|
|
1966
2226
|
this.history.clear();
|
|
1967
2227
|
} else if (!this.isUndoingRedoing) {
|
|
@@ -1973,10 +2233,11 @@ var __WulfIIFE = (() => {
|
|
|
1973
2233
|
this.checkValueChange();
|
|
1974
2234
|
}
|
|
1975
2235
|
syncInitialValue() {
|
|
2236
|
+
const isPwd = this.isPasswordInput();
|
|
1976
2237
|
if (this.options.disabled) {
|
|
1977
2238
|
this.wrapper.removeAttribute("data-mask");
|
|
1978
|
-
|
|
1979
|
-
this.lastValue = this.input.value;
|
|
2239
|
+
this.clearGhost();
|
|
2240
|
+
this.lastValue = isPwd ? this.computePasswordDigest(this.input.value) : this.input.value;
|
|
1980
2241
|
this.checkValueChange();
|
|
1981
2242
|
return;
|
|
1982
2243
|
}
|
|
@@ -1989,13 +2250,17 @@ var __WulfIIFE = (() => {
|
|
|
1989
2250
|
if (minPos > 0) {
|
|
1990
2251
|
this.applyMask("", minPos);
|
|
1991
2252
|
} else {
|
|
1992
|
-
if (
|
|
2253
|
+
if (!isPwd) {
|
|
1993
2254
|
this.history.push("", 0);
|
|
2255
|
+
const fullTemplate = this.engine.getFullMaskTemplate();
|
|
2256
|
+
this.lastInternalRemainingMask = fullTemplate;
|
|
2257
|
+
this.wrapper.setAttribute("data-mask", fullTemplate);
|
|
2258
|
+
this.updateGhost("");
|
|
2259
|
+
} else {
|
|
2260
|
+
this.lastInternalRemainingMask = "";
|
|
2261
|
+
this.wrapper.removeAttribute("data-mask");
|
|
2262
|
+
this.clearGhost();
|
|
1994
2263
|
}
|
|
1995
|
-
const fullTemplate = this.engine.getFullMaskTemplate();
|
|
1996
|
-
this.lastInternalRemainingMask = fullTemplate;
|
|
1997
|
-
this.wrapper.setAttribute("data-mask", fullTemplate);
|
|
1998
|
-
this.updateGhost("");
|
|
1999
2264
|
this.checkValueChange();
|
|
2000
2265
|
}
|
|
2001
2266
|
}
|
|
@@ -2005,8 +2270,10 @@ var __WulfIIFE = (() => {
|
|
|
2005
2270
|
* Gère de manière sûre la réentrance pour permettre d'appeler setMask() directement dans le callback.
|
|
2006
2271
|
*/
|
|
2007
2272
|
checkValueChange(forceNotify = false) {
|
|
2273
|
+
const isPwd = this.isPasswordInput();
|
|
2008
2274
|
const currentVal = this.input.value;
|
|
2009
|
-
|
|
2275
|
+
const currentComparison = isPwd ? this.computePasswordDigest(currentVal) : currentVal;
|
|
2276
|
+
if (currentComparison === this.lastValue && !forceNotify && !this.hasPendingNotification) {
|
|
2010
2277
|
return;
|
|
2011
2278
|
}
|
|
2012
2279
|
if (this.isNotifying) {
|
|
@@ -2017,12 +2284,12 @@ var __WulfIIFE = (() => {
|
|
|
2017
2284
|
try {
|
|
2018
2285
|
let iterations = 0;
|
|
2019
2286
|
const MAX_NOTIFICATION_ITERATIONS = 10;
|
|
2020
|
-
while ((this.input.value !== this.lastValue || this.hasPendingNotification || forceNotify) && iterations < MAX_NOTIFICATION_ITERATIONS) {
|
|
2287
|
+
while (((isPwd ? this.computePasswordDigest(this.input.value) : this.input.value) !== this.lastValue || this.hasPendingNotification || forceNotify) && iterations < MAX_NOTIFICATION_ITERATIONS) {
|
|
2021
2288
|
iterations++;
|
|
2022
2289
|
this.hasPendingNotification = false;
|
|
2023
2290
|
forceNotify = false;
|
|
2024
2291
|
const valToNotify = this.input.value;
|
|
2025
|
-
this.lastValue = valToNotify;
|
|
2292
|
+
this.lastValue = isPwd ? this.computePasswordDigest(valToNotify) : valToNotify;
|
|
2026
2293
|
const raw = this.options.disabled ? valToNotify : this.getRawValue();
|
|
2027
2294
|
const totalSlots = this.options.disabled ? 0 : this.engine.getEditableCount();
|
|
2028
2295
|
const isComplete = this.isComplete();
|
|
@@ -2060,6 +2327,7 @@ var __WulfIIFE = (() => {
|
|
|
2060
2327
|
|
|
2061
2328
|
// src/mask/AmountEngine.ts
|
|
2062
2329
|
var AmountEngine = class _AmountEngine {
|
|
2330
|
+
options;
|
|
2063
2331
|
constructor(options = {}) {
|
|
2064
2332
|
let currency = options.currency ?? "";
|
|
2065
2333
|
if (!currency && options.unit) {
|
|
@@ -2272,6 +2540,16 @@ var __WulfIIFE = (() => {
|
|
|
2272
2540
|
|
|
2273
2541
|
// src/mask/InputAmountMask.ts
|
|
2274
2542
|
var InputAmountMask = class extends BaseInputMask {
|
|
2543
|
+
engine;
|
|
2544
|
+
history;
|
|
2545
|
+
isUndoingRedoing = false;
|
|
2546
|
+
isApplying = false;
|
|
2547
|
+
isComposing = false;
|
|
2548
|
+
lastValue = "";
|
|
2549
|
+
wasInputModeInferred = false;
|
|
2550
|
+
cutTimerId = null;
|
|
2551
|
+
resetTimerId = null;
|
|
2552
|
+
cursorTimerId = null;
|
|
2275
2553
|
constructor(targetOrWrapper, inputOrOptions, options) {
|
|
2276
2554
|
const args = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, options);
|
|
2277
2555
|
const wrap = args.wrapper;
|
|
@@ -2285,13 +2563,10 @@ var __WulfIIFE = (() => {
|
|
|
2285
2563
|
...opts
|
|
2286
2564
|
};
|
|
2287
2565
|
super(wrap, inp, resolvedOptions);
|
|
2288
|
-
this.
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
this.cutTimerId = null;
|
|
2293
|
-
this.resetTimerId = null;
|
|
2294
|
-
this.input.inputMode = "decimal";
|
|
2566
|
+
if (!this.input.hasAttribute("inputmode")) {
|
|
2567
|
+
this.input.inputMode = "decimal";
|
|
2568
|
+
this.wasInputModeInferred = true;
|
|
2569
|
+
}
|
|
2295
2570
|
this.history = new MaskHistory();
|
|
2296
2571
|
this.engine = new AmountEngine(this.options);
|
|
2297
2572
|
this.bindEvents();
|
|
@@ -2317,6 +2592,9 @@ var __WulfIIFE = (() => {
|
|
|
2317
2592
|
}
|
|
2318
2593
|
onPasswordModeDetected() {
|
|
2319
2594
|
this.history.clear();
|
|
2595
|
+
this.lastValue = "";
|
|
2596
|
+
this.lastTrackedValue = "";
|
|
2597
|
+
this.clearGhost();
|
|
2320
2598
|
}
|
|
2321
2599
|
/**
|
|
2322
2600
|
* Formate statiquement une valeur sans nécessiter d'élément DOM.
|
|
@@ -2332,7 +2610,9 @@ var __WulfIIFE = (() => {
|
|
|
2332
2610
|
this.applyAmount(strVal, strVal.length);
|
|
2333
2611
|
}
|
|
2334
2612
|
onDisabledChange(disabled) {
|
|
2335
|
-
if (
|
|
2613
|
+
if (disabled) {
|
|
2614
|
+
this.clearGhost();
|
|
2615
|
+
} else {
|
|
2336
2616
|
this.applyAmount(this.input.value, this.input.selectionStart ?? this.input.value.length);
|
|
2337
2617
|
}
|
|
2338
2618
|
}
|
|
@@ -2355,15 +2635,16 @@ var __WulfIIFE = (() => {
|
|
|
2355
2635
|
this.applyAmount(this.input.value, cur);
|
|
2356
2636
|
}, 0);
|
|
2357
2637
|
};
|
|
2358
|
-
|
|
2359
|
-
this.input.addEventListener("
|
|
2360
|
-
this.input.addEventListener("
|
|
2361
|
-
this.input.addEventListener("
|
|
2362
|
-
this.input.addEventListener("
|
|
2363
|
-
this.input.addEventListener("
|
|
2364
|
-
this.input.addEventListener("
|
|
2365
|
-
this.input.addEventListener("
|
|
2366
|
-
this.input.addEventListener("
|
|
2638
|
+
const { signal } = this.abortController;
|
|
2639
|
+
this.input.addEventListener("input", this.handleInput, { signal });
|
|
2640
|
+
this.input.addEventListener("keydown", this.handleKeyDown, { signal });
|
|
2641
|
+
this.input.addEventListener("blur", this.handleBlur, { signal });
|
|
2642
|
+
this.input.addEventListener("focus", this.handleFocus, { signal });
|
|
2643
|
+
this.input.addEventListener("click", this.handleClick, { signal });
|
|
2644
|
+
this.input.addEventListener("scroll", this.onScroll, { passive: true, signal });
|
|
2645
|
+
this.input.addEventListener("cut", this.onCutHandler, { signal });
|
|
2646
|
+
this.input.addEventListener("compositionstart", this.onCompositionStart, { signal });
|
|
2647
|
+
this.input.addEventListener("compositionend", this.onCompositionEnd, { signal });
|
|
2367
2648
|
if (this.input.form) {
|
|
2368
2649
|
this.onFormResetHandler = () => {
|
|
2369
2650
|
if (this.resetTimerId !== null) {
|
|
@@ -2376,7 +2657,7 @@ var __WulfIIFE = (() => {
|
|
|
2376
2657
|
this.applyAmount(this.input.value, this.input.value.length);
|
|
2377
2658
|
}, 0);
|
|
2378
2659
|
};
|
|
2379
|
-
this.input.form.addEventListener("reset", this.onFormResetHandler);
|
|
2660
|
+
this.input.form.addEventListener("reset", this.onFormResetHandler, { signal });
|
|
2380
2661
|
}
|
|
2381
2662
|
}
|
|
2382
2663
|
onCompositionStart() {
|
|
@@ -2395,15 +2676,20 @@ var __WulfIIFE = (() => {
|
|
|
2395
2676
|
const result = this.engine.format(val, cursor);
|
|
2396
2677
|
this.setNativeValue(result.formatted);
|
|
2397
2678
|
this.input.setSelectionRange(result.cursor, result.cursor);
|
|
2398
|
-
|
|
2679
|
+
const isPwd = this.isPasswordInput();
|
|
2680
|
+
if (isPwd) {
|
|
2399
2681
|
this.options.copyRaw = false;
|
|
2400
2682
|
this.history.clear();
|
|
2401
|
-
|
|
2402
|
-
|
|
2683
|
+
this.clearGhost();
|
|
2684
|
+
} else {
|
|
2685
|
+
if (!this.isUndoingRedoing) {
|
|
2686
|
+
this.history.push(result.rawValue, result.cursor);
|
|
2687
|
+
}
|
|
2688
|
+
this.updateGhost(result);
|
|
2403
2689
|
}
|
|
2404
|
-
this.
|
|
2405
|
-
if (this.lastValue !==
|
|
2406
|
-
this.lastValue =
|
|
2690
|
+
const nextComparison = isPwd ? this.computePasswordDigest(result.formatted) : result.formatted;
|
|
2691
|
+
if (this.lastValue !== nextComparison) {
|
|
2692
|
+
this.lastValue = nextComparison;
|
|
2407
2693
|
this.notifyChange(result);
|
|
2408
2694
|
}
|
|
2409
2695
|
} finally {
|
|
@@ -2414,18 +2700,18 @@ var __WulfIIFE = (() => {
|
|
|
2414
2700
|
if (!this.ghost) return;
|
|
2415
2701
|
if (!result.formatted) {
|
|
2416
2702
|
if (this.shouldHideGhostForPlaceholder(true)) {
|
|
2417
|
-
this.
|
|
2703
|
+
this.clearGhost();
|
|
2418
2704
|
return;
|
|
2419
2705
|
}
|
|
2420
2706
|
const hint = this.options.currency ? this.options.currencyPosition === "prefix" ? `${this.options.currency} 0` : `0 ${this.options.currency}` : "0,00";
|
|
2421
|
-
this.
|
|
2422
|
-
const span =
|
|
2707
|
+
const doc = this.input.ownerDocument || document;
|
|
2708
|
+
const span = doc.createElement("span");
|
|
2423
2709
|
span.className = "mask-ghost-remaining";
|
|
2424
2710
|
span.textContent = hint;
|
|
2425
|
-
this.
|
|
2711
|
+
this.setGhostContent(span);
|
|
2426
2712
|
return;
|
|
2427
2713
|
}
|
|
2428
|
-
this.
|
|
2714
|
+
this.clearGhost();
|
|
2429
2715
|
this.ghost.scrollLeft = this.input.scrollLeft;
|
|
2430
2716
|
}
|
|
2431
2717
|
handleInput() {
|
|
@@ -2436,7 +2722,7 @@ var __WulfIIFE = (() => {
|
|
|
2436
2722
|
this.applyAmount(rawVal, cur);
|
|
2437
2723
|
}
|
|
2438
2724
|
handleKeyDown(e) {
|
|
2439
|
-
if (this.options.disabled) return;
|
|
2725
|
+
if (this.options.disabled || isImeComposing(e)) return;
|
|
2440
2726
|
if ((e.ctrlKey || e.metaKey) && (e.key === "z" || e.key === "Z")) {
|
|
2441
2727
|
e.preventDefault();
|
|
2442
2728
|
if (e.shiftKey) this.redo();
|
|
@@ -2488,10 +2774,18 @@ var __WulfIIFE = (() => {
|
|
|
2488
2774
|
}
|
|
2489
2775
|
}
|
|
2490
2776
|
}
|
|
2491
|
-
|
|
2777
|
+
if (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Home" || e.key === "End") {
|
|
2778
|
+
if (this.cursorTimerId !== null) {
|
|
2779
|
+
clearTimeout(this.cursorTimerId);
|
|
2780
|
+
}
|
|
2781
|
+
this.cursorTimerId = window.setTimeout(() => {
|
|
2782
|
+
this.cursorTimerId = null;
|
|
2783
|
+
this.enforceCursorBounds();
|
|
2784
|
+
}, 0);
|
|
2785
|
+
}
|
|
2492
2786
|
}
|
|
2493
2787
|
enforceCursorBounds() {
|
|
2494
|
-
if (!this.input.value || this.options.disabled) return;
|
|
2788
|
+
if (this.isDestroyed || !this.isFocused || document.activeElement !== this.input || !this.input.value || this.options.disabled) return;
|
|
2495
2789
|
const start = this.input.selectionStart ?? 0;
|
|
2496
2790
|
const end = this.input.selectionEnd ?? 0;
|
|
2497
2791
|
if (start !== end) return;
|
|
@@ -2522,8 +2816,12 @@ var __WulfIIFE = (() => {
|
|
|
2522
2816
|
}
|
|
2523
2817
|
handleBlur() {
|
|
2524
2818
|
this.wrapper.classList.remove("is-focused");
|
|
2525
|
-
if (this.
|
|
2819
|
+
if (this.isPasswordInput()) {
|
|
2526
2820
|
this.history.clear();
|
|
2821
|
+
this.lastValue = "";
|
|
2822
|
+
this.lastTrackedValue = "";
|
|
2823
|
+
this.clearGhost();
|
|
2824
|
+
return;
|
|
2527
2825
|
}
|
|
2528
2826
|
if (this.options.padDecimalsOnBlur && !this.options.disabled && this.input.value.trim().length > 0) {
|
|
2529
2827
|
const paddedResult = this.engine.format(this.input.value, this.input.value.length, true);
|
|
@@ -2619,30 +2917,62 @@ var __WulfIIFE = (() => {
|
|
|
2619
2917
|
clearTimeout(this.resetTimerId);
|
|
2620
2918
|
this.resetTimerId = null;
|
|
2621
2919
|
}
|
|
2622
|
-
this.
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
this.input.removeEventListener("focus", this.handleFocus);
|
|
2626
|
-
this.input.removeEventListener("click", this.handleClick);
|
|
2627
|
-
this.input.removeEventListener("scroll", this.onScroll);
|
|
2628
|
-
this.input.removeEventListener("cut", this.onCutHandler);
|
|
2629
|
-
this.input.removeEventListener("compositionstart", this.onCompositionStart);
|
|
2630
|
-
this.input.removeEventListener("compositionend", this.onCompositionEnd);
|
|
2631
|
-
if (this.input.form && this.onFormResetHandler) {
|
|
2632
|
-
this.input.form.removeEventListener("reset", this.onFormResetHandler);
|
|
2920
|
+
if (this.cursorTimerId !== null) {
|
|
2921
|
+
clearTimeout(this.cursorTimerId);
|
|
2922
|
+
this.cursorTimerId = null;
|
|
2633
2923
|
}
|
|
2924
|
+
if (this.wasInputModeInferred && this.input.getAttribute("inputmode") === "decimal") {
|
|
2925
|
+
this.input.removeAttribute("inputmode");
|
|
2926
|
+
}
|
|
2927
|
+
this.lastValue = "";
|
|
2634
2928
|
this.history.clear();
|
|
2635
2929
|
super.destroy();
|
|
2636
2930
|
}
|
|
2637
2931
|
};
|
|
2638
2932
|
|
|
2639
2933
|
// src/mask/EmailEngine.ts
|
|
2640
|
-
var
|
|
2934
|
+
var EmailEngine = class _EmailEngine {
|
|
2935
|
+
domains;
|
|
2936
|
+
tlds;
|
|
2937
|
+
suggestOnAt;
|
|
2938
|
+
defaultDomain = null;
|
|
2939
|
+
defaultTld = "__";
|
|
2940
|
+
static DEFAULT_DOMAINS = [
|
|
2941
|
+
"gmail.com",
|
|
2942
|
+
"outlook.com",
|
|
2943
|
+
"orange.fr",
|
|
2944
|
+
"free.fr",
|
|
2945
|
+
"sfr.fr",
|
|
2946
|
+
"yahoo.com",
|
|
2947
|
+
"hotmail.com",
|
|
2948
|
+
"icloud.com",
|
|
2949
|
+
"laposte.net",
|
|
2950
|
+
"proton.me"
|
|
2951
|
+
];
|
|
2952
|
+
static DEFAULT_TLDS = [
|
|
2953
|
+
"com",
|
|
2954
|
+
"fr",
|
|
2955
|
+
"net",
|
|
2956
|
+
"org",
|
|
2957
|
+
"eu",
|
|
2958
|
+
"io",
|
|
2959
|
+
"co",
|
|
2960
|
+
"info",
|
|
2961
|
+
"biz",
|
|
2962
|
+
"me",
|
|
2963
|
+
"tv",
|
|
2964
|
+
"fi",
|
|
2965
|
+
"be",
|
|
2966
|
+
"ch",
|
|
2967
|
+
"ca",
|
|
2968
|
+
"uk",
|
|
2969
|
+
"de",
|
|
2970
|
+
"es",
|
|
2971
|
+
"it"
|
|
2972
|
+
];
|
|
2641
2973
|
constructor(options = {}) {
|
|
2642
|
-
this.defaultDomain = null;
|
|
2643
|
-
this.defaultTld = "__";
|
|
2644
2974
|
this.domains = options.domains && options.domains.length > 0 ? options.domains : _EmailEngine.DEFAULT_DOMAINS;
|
|
2645
|
-
this.tlds = options.tlds && options.tlds.length > 0 ? options.tlds.map((t) => t.trim().replace(/^\./, "")).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
|
|
2975
|
+
this.tlds = options.tlds && options.tlds.length > 0 ? options.tlds.slice(0, 200).map((t) => String(t).trim().replace(/^\./, "").slice(0, 32)).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
|
|
2646
2976
|
this.suggestOnAt = options.suggestOnAt ?? true;
|
|
2647
2977
|
this.setDefaultDomain(options.defaultDomain ?? null);
|
|
2648
2978
|
this.setDefaultTld(options.defaultTld !== void 0 ? options.defaultTld : "__");
|
|
@@ -2675,7 +3005,7 @@ var __WulfIIFE = (() => {
|
|
|
2675
3005
|
* Définit ou modifie la liste des extensions (TLD) proposées par ordre de priorité.
|
|
2676
3006
|
*/
|
|
2677
3007
|
setTlds(tlds) {
|
|
2678
|
-
this.tlds = tlds && tlds.length > 0 ? tlds.map((t) => t.trim().replace(/^\./, "")).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
|
|
3008
|
+
this.tlds = tlds && tlds.length > 0 ? tlds.slice(0, 200).map((t) => String(t).trim().replace(/^\./, "").slice(0, 32)).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
|
|
2679
3009
|
}
|
|
2680
3010
|
/**
|
|
2681
3011
|
* Retourne l'ensemble des extensions (TLD) correspondant au fragment saisi après le dernier point,
|
|
@@ -2746,22 +3076,22 @@ var __WulfIIFE = (() => {
|
|
|
2746
3076
|
};
|
|
2747
3077
|
}
|
|
2748
3078
|
if (domainPart.length === 0 || domainPart.startsWith(".")) {
|
|
2749
|
-
return { full:
|
|
3079
|
+
return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2750
3080
|
}
|
|
2751
3081
|
const lowerDomain = domainPart.toLowerCase();
|
|
2752
3082
|
if (this.domains.some((d) => d.toLowerCase() === lowerDomain)) {
|
|
2753
|
-
return { full:
|
|
3083
|
+
return { full: val, remaining: "", matchedDomain: domainPart, isHintOnly: false };
|
|
2754
3084
|
}
|
|
2755
3085
|
const lastDotIndex = domainPart.lastIndexOf(".");
|
|
2756
3086
|
if (lastDotIndex === -1) {
|
|
2757
3087
|
if (!this.defaultTld) {
|
|
2758
|
-
return { full:
|
|
3088
|
+
return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2759
3089
|
}
|
|
2760
3090
|
const isHint = this.defaultTld.includes("_");
|
|
2761
3091
|
const remaining = `.${this.defaultTld}`;
|
|
2762
3092
|
const fullDomain = `${domainPart}.${this.defaultTld}`;
|
|
2763
3093
|
return {
|
|
2764
|
-
full: isHint ?
|
|
3094
|
+
full: isHint ? val : `${localPart}@${fullDomain}`,
|
|
2765
3095
|
remaining,
|
|
2766
3096
|
matchedDomain: isHint ? null : fullDomain,
|
|
2767
3097
|
isHintOnly: isHint
|
|
@@ -2770,7 +3100,7 @@ var __WulfIIFE = (() => {
|
|
|
2770
3100
|
const hostPart = domainPart.substring(0, lastDotIndex);
|
|
2771
3101
|
const tldPart = domainPart.substring(lastDotIndex + 1);
|
|
2772
3102
|
if (!hostPart || hostPart.endsWith(".")) {
|
|
2773
|
-
return { full:
|
|
3103
|
+
return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2774
3104
|
}
|
|
2775
3105
|
if (tldPart.length === 0) {
|
|
2776
3106
|
if (this.defaultTld && !this.defaultTld.includes("_")) {
|
|
@@ -2784,15 +3114,18 @@ var __WulfIIFE = (() => {
|
|
|
2784
3114
|
}
|
|
2785
3115
|
if (this.defaultTld && this.defaultTld.includes("_")) {
|
|
2786
3116
|
return {
|
|
2787
|
-
full:
|
|
3117
|
+
full: val,
|
|
2788
3118
|
remaining: this.defaultTld,
|
|
2789
3119
|
matchedDomain: null,
|
|
2790
3120
|
isHintOnly: true
|
|
2791
3121
|
};
|
|
2792
3122
|
}
|
|
2793
|
-
return { full:
|
|
3123
|
+
return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2794
3124
|
}
|
|
2795
3125
|
const lowerTld = tldPart.toLowerCase();
|
|
3126
|
+
if (this.tlds.some((t) => t.toLowerCase() === lowerTld)) {
|
|
3127
|
+
return { full: val, remaining: "", matchedDomain: domainPart, isHintOnly: false };
|
|
3128
|
+
}
|
|
2796
3129
|
const matchingTlds = this.getMatchingTlds(tldPart);
|
|
2797
3130
|
if (matchingTlds.length > 0) {
|
|
2798
3131
|
const safeTldIndex = (matchIndex % matchingTlds.length + matchingTlds.length) % matchingTlds.length;
|
|
@@ -2810,53 +3143,34 @@ var __WulfIIFE = (() => {
|
|
|
2810
3143
|
const remaining = this.defaultTld.substring(tldPart.length);
|
|
2811
3144
|
if (remaining.includes("_")) {
|
|
2812
3145
|
return {
|
|
2813
|
-
full:
|
|
3146
|
+
full: val,
|
|
2814
3147
|
remaining,
|
|
2815
3148
|
matchedDomain: null,
|
|
2816
3149
|
isHintOnly: true
|
|
2817
3150
|
};
|
|
2818
3151
|
}
|
|
2819
3152
|
}
|
|
2820
|
-
return { full:
|
|
3153
|
+
return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2821
3154
|
}
|
|
2822
3155
|
};
|
|
2823
|
-
_EmailEngine.DEFAULT_DOMAINS = [
|
|
2824
|
-
"gmail.com",
|
|
2825
|
-
"outlook.com",
|
|
2826
|
-
"orange.fr",
|
|
2827
|
-
"free.fr",
|
|
2828
|
-
"sfr.fr",
|
|
2829
|
-
"yahoo.com",
|
|
2830
|
-
"hotmail.com",
|
|
2831
|
-
"icloud.com",
|
|
2832
|
-
"laposte.net",
|
|
2833
|
-
"proton.me"
|
|
2834
|
-
];
|
|
2835
|
-
_EmailEngine.DEFAULT_TLDS = [
|
|
2836
|
-
"com",
|
|
2837
|
-
"fr",
|
|
2838
|
-
"net",
|
|
2839
|
-
"org",
|
|
2840
|
-
"eu",
|
|
2841
|
-
"io",
|
|
2842
|
-
"co",
|
|
2843
|
-
"info",
|
|
2844
|
-
"biz",
|
|
2845
|
-
"me",
|
|
2846
|
-
"tv",
|
|
2847
|
-
"fi",
|
|
2848
|
-
"be",
|
|
2849
|
-
"ch",
|
|
2850
|
-
"ca",
|
|
2851
|
-
"uk",
|
|
2852
|
-
"de",
|
|
2853
|
-
"es",
|
|
2854
|
-
"it"
|
|
2855
|
-
];
|
|
2856
|
-
var EmailEngine = _EmailEngine;
|
|
2857
3156
|
|
|
2858
3157
|
// src/mask/InputEmailMask.ts
|
|
2859
3158
|
var InputEmailMask = class extends BaseInputMask {
|
|
3159
|
+
engine;
|
|
3160
|
+
currentSuggestion = { full: "", remaining: "", matchedDomain: null };
|
|
3161
|
+
currentSuggestionIndex = 0;
|
|
3162
|
+
wasAriaAutocompleteSet = false;
|
|
3163
|
+
wasAutocorrectSet = false;
|
|
3164
|
+
wasAutocapitalizeSet = false;
|
|
3165
|
+
wasSpellcheckSet = false;
|
|
3166
|
+
wasInputModeInferred = false;
|
|
3167
|
+
isComposing = false;
|
|
3168
|
+
lastNotifiedValue = "";
|
|
3169
|
+
srStatusEl = null;
|
|
3170
|
+
srAnnounceTimerId = null;
|
|
3171
|
+
lastAnnouncedSuggestion = "";
|
|
3172
|
+
cutTimerId = null;
|
|
3173
|
+
resetTimerId = null;
|
|
2860
3174
|
constructor(targetOrWrapper, inputOrOptions, options) {
|
|
2861
3175
|
const args = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, options);
|
|
2862
3176
|
const wrap = args.wrapper;
|
|
@@ -2882,30 +3196,55 @@ var __WulfIIFE = (() => {
|
|
|
2882
3196
|
...resolvedDefaultTld !== void 0 ? { defaultTld: resolvedDefaultTld } : {}
|
|
2883
3197
|
};
|
|
2884
3198
|
super(wrap, inp, resolvedOptions);
|
|
2885
|
-
this.
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
this.
|
|
2890
|
-
|
|
3199
|
+
if (!this.input.hasAttribute("inputmode")) {
|
|
3200
|
+
this.input.inputMode = "email";
|
|
3201
|
+
this.wasInputModeInferred = true;
|
|
3202
|
+
}
|
|
3203
|
+
if (!this.input.hasAttribute("autocorrect")) {
|
|
3204
|
+
this.input.setAttribute("autocorrect", "off");
|
|
3205
|
+
this.wasAutocorrectSet = true;
|
|
3206
|
+
}
|
|
3207
|
+
if (!this.input.hasAttribute("autocapitalize")) {
|
|
3208
|
+
this.input.setAttribute("autocapitalize", "none");
|
|
3209
|
+
this.wasAutocapitalizeSet = true;
|
|
3210
|
+
}
|
|
3211
|
+
if (!this.input.hasAttribute("spellcheck")) {
|
|
3212
|
+
this.input.setAttribute("spellcheck", "false");
|
|
3213
|
+
this.wasSpellcheckSet = true;
|
|
3214
|
+
}
|
|
2891
3215
|
if (this.options.setAriaAutocomplete && !this.input.hasAttribute("aria-autocomplete")) {
|
|
2892
3216
|
this.input.setAttribute("aria-autocomplete", "inline");
|
|
2893
3217
|
this.wasAriaAutocompleteSet = true;
|
|
2894
3218
|
}
|
|
2895
3219
|
this.engine = new EmailEngine(this.options);
|
|
3220
|
+
this.lastNotifiedValue = this.isPasswordInput() ? "" : this.input.value;
|
|
2896
3221
|
this.bindEvents();
|
|
2897
|
-
if (!this.options.disabled) {
|
|
3222
|
+
if (!this.options.disabled && !this.isPasswordInput()) {
|
|
2898
3223
|
this.updateSuggestion();
|
|
2899
3224
|
}
|
|
2900
3225
|
this.runAuditWarning(this.options.audit);
|
|
2901
3226
|
}
|
|
3227
|
+
onPasswordModeDetected() {
|
|
3228
|
+
if (this.srAnnounceTimerId !== null) {
|
|
3229
|
+
clearTimeout(this.srAnnounceTimerId);
|
|
3230
|
+
this.srAnnounceTimerId = null;
|
|
3231
|
+
}
|
|
3232
|
+
this.lastNotifiedValue = "";
|
|
3233
|
+
this.lastTrackedValue = "";
|
|
3234
|
+
this.lastAnnouncedSuggestion = "";
|
|
3235
|
+
this.currentSuggestion = { full: "", remaining: "", matchedDomain: null };
|
|
3236
|
+
if (this.srStatusEl) {
|
|
3237
|
+
this.srStatusEl.textContent = "";
|
|
3238
|
+
}
|
|
3239
|
+
this.clearGhost();
|
|
3240
|
+
}
|
|
2902
3241
|
onNativeValueSet(_strVal) {
|
|
2903
|
-
if (this.options.disabled) return;
|
|
3242
|
+
if (this.options.disabled || this.isComposing || this.isPasswordInput()) return;
|
|
2904
3243
|
this.updateSuggestion();
|
|
2905
3244
|
}
|
|
2906
3245
|
onDisabledChange(disabled) {
|
|
2907
|
-
if (disabled) {
|
|
2908
|
-
|
|
3246
|
+
if (disabled || this.isPasswordInput()) {
|
|
3247
|
+
this.clearGhost();
|
|
2909
3248
|
} else {
|
|
2910
3249
|
this.updateSuggestion();
|
|
2911
3250
|
}
|
|
@@ -2921,16 +3260,26 @@ var __WulfIIFE = (() => {
|
|
|
2921
3260
|
}
|
|
2922
3261
|
this.cutTimerId = window.setTimeout(() => {
|
|
2923
3262
|
this.cutTimerId = null;
|
|
2924
|
-
if (this.isDestroyed || this.options.disabled) return;
|
|
3263
|
+
if (this.isDestroyed || this.options.disabled || this.isPasswordInput()) return;
|
|
2925
3264
|
this.updateSuggestion();
|
|
2926
3265
|
}, 0);
|
|
2927
3266
|
};
|
|
2928
|
-
|
|
2929
|
-
this.input.addEventListener("
|
|
2930
|
-
this.input.addEventListener("
|
|
2931
|
-
this.input.addEventListener("
|
|
2932
|
-
this.input.addEventListener("
|
|
2933
|
-
this.input.addEventListener("
|
|
3267
|
+
const { signal } = this.abortController;
|
|
3268
|
+
this.input.addEventListener("input", this.handleInput, { signal });
|
|
3269
|
+
this.input.addEventListener("keydown", this.handleKeyDown, { signal });
|
|
3270
|
+
this.input.addEventListener("blur", this.handleBlur, { signal });
|
|
3271
|
+
this.input.addEventListener("focus", this.handleFocus, { signal });
|
|
3272
|
+
this.input.addEventListener("scroll", this.onScroll, { passive: true, signal });
|
|
3273
|
+
this.input.addEventListener("cut", this.onCutHandler, { signal });
|
|
3274
|
+
this.input.addEventListener("compositionstart", () => {
|
|
3275
|
+
this.isComposing = true;
|
|
3276
|
+
}, { signal });
|
|
3277
|
+
this.input.addEventListener("compositionend", () => {
|
|
3278
|
+
this.isComposing = false;
|
|
3279
|
+
if (!this.isDestroyed && !this.options.disabled && !this.isPasswordInput()) {
|
|
3280
|
+
this.handleInput();
|
|
3281
|
+
}
|
|
3282
|
+
}, { signal });
|
|
2934
3283
|
if (this.input.form) {
|
|
2935
3284
|
this.onFormResetHandler = () => {
|
|
2936
3285
|
if (this.resetTimerId !== null) {
|
|
@@ -2938,47 +3287,112 @@ var __WulfIIFE = (() => {
|
|
|
2938
3287
|
}
|
|
2939
3288
|
this.resetTimerId = window.setTimeout(() => {
|
|
2940
3289
|
this.resetTimerId = null;
|
|
2941
|
-
if (this.isDestroyed || this.options.disabled) return;
|
|
3290
|
+
if (this.isDestroyed || this.options.disabled || this.isPasswordInput()) return;
|
|
2942
3291
|
this.updateSuggestion();
|
|
2943
3292
|
}, 0);
|
|
2944
3293
|
};
|
|
2945
|
-
this.input.form.addEventListener("reset", this.onFormResetHandler);
|
|
3294
|
+
this.input.form.addEventListener("reset", this.onFormResetHandler, { signal });
|
|
2946
3295
|
}
|
|
2947
3296
|
}
|
|
2948
|
-
|
|
2949
|
-
if (this.
|
|
2950
|
-
|
|
3297
|
+
ensureSrStatusEl() {
|
|
3298
|
+
if (this.srStatusEl && this.wrapper.contains(this.srStatusEl)) {
|
|
3299
|
+
return this.srStatusEl;
|
|
3300
|
+
}
|
|
3301
|
+
const doc = this.input.ownerDocument || (typeof document !== "undefined" ? document : null);
|
|
3302
|
+
if (!doc) return null;
|
|
3303
|
+
const status = doc.createElement("span");
|
|
3304
|
+
status.className = "wulf-mask-sr-status";
|
|
3305
|
+
status.setAttribute("aria-live", "polite");
|
|
3306
|
+
status.setAttribute("aria-atomic", "true");
|
|
3307
|
+
this.wrapper.appendChild(status);
|
|
3308
|
+
this.srStatusEl = status;
|
|
3309
|
+
return status;
|
|
3310
|
+
}
|
|
3311
|
+
scheduleSuggestionAnnouncement(immediate = false) {
|
|
3312
|
+
if (this.srAnnounceTimerId !== null) {
|
|
3313
|
+
clearTimeout(this.srAnnounceTimerId);
|
|
3314
|
+
this.srAnnounceTimerId = null;
|
|
3315
|
+
}
|
|
3316
|
+
if (!this.options.setAriaAutocomplete || !this.isFocused || this.isDestroyed || this.isPasswordInput()) {
|
|
3317
|
+
return;
|
|
3318
|
+
}
|
|
3319
|
+
const suggestion = this.currentSuggestion;
|
|
3320
|
+
if (!suggestion.remaining || suggestion.isHintOnly) {
|
|
3321
|
+
this.lastAnnouncedSuggestion = "";
|
|
3322
|
+
if (this.srStatusEl) {
|
|
3323
|
+
this.srStatusEl.textContent = "";
|
|
3324
|
+
}
|
|
3325
|
+
return;
|
|
3326
|
+
}
|
|
3327
|
+
const textToAnnounce = suggestion.full;
|
|
3328
|
+
if (textToAnnounce === this.lastAnnouncedSuggestion && !immediate) {
|
|
3329
|
+
return;
|
|
3330
|
+
}
|
|
3331
|
+
const run = () => {
|
|
3332
|
+
this.srAnnounceTimerId = null;
|
|
3333
|
+
if (this.isDestroyed || !this.isFocused || this.isPasswordInput()) return;
|
|
3334
|
+
this.lastAnnouncedSuggestion = textToAnnounce;
|
|
3335
|
+
const doc = this.input.ownerDocument || (typeof document !== "undefined" ? document : null);
|
|
3336
|
+
const docWithAriaNotify = doc;
|
|
3337
|
+
if (docWithAriaNotify && typeof docWithAriaNotify.ariaNotify === "function") {
|
|
3338
|
+
try {
|
|
3339
|
+
docWithAriaNotify.ariaNotify(textToAnnounce, { priority: "normal" });
|
|
3340
|
+
return;
|
|
3341
|
+
} catch {
|
|
3342
|
+
}
|
|
3343
|
+
}
|
|
3344
|
+
const statusEl = this.ensureSrStatusEl();
|
|
3345
|
+
if (statusEl) {
|
|
3346
|
+
statusEl.textContent = statusEl.textContent === textToAnnounce ? `${textToAnnounce}\xA0` : textToAnnounce;
|
|
3347
|
+
}
|
|
3348
|
+
};
|
|
3349
|
+
if (immediate) {
|
|
3350
|
+
run();
|
|
3351
|
+
} else {
|
|
3352
|
+
this.srAnnounceTimerId = window.setTimeout(run, 250);
|
|
3353
|
+
}
|
|
3354
|
+
}
|
|
3355
|
+
updateSuggestion(announceOptions) {
|
|
3356
|
+
if (this.options.disabled || this.isPasswordInput()) {
|
|
3357
|
+
this.currentSuggestion = { full: "", remaining: "", matchedDomain: null };
|
|
3358
|
+
this.clearGhost();
|
|
2951
3359
|
return;
|
|
2952
3360
|
}
|
|
2953
3361
|
const val = this.input.value;
|
|
2954
3362
|
this.currentSuggestion = this.engine.getSuggestion(val, this.currentSuggestionIndex);
|
|
2955
3363
|
if (!this.ghost) return;
|
|
2956
3364
|
if (this.shouldHideGhostForPlaceholder(val.length === 0)) {
|
|
2957
|
-
this.
|
|
3365
|
+
this.clearGhost();
|
|
2958
3366
|
} else if (this.currentSuggestion.remaining) {
|
|
2959
|
-
this.
|
|
2960
|
-
const spanTyped =
|
|
3367
|
+
const doc = this.input.ownerDocument || document;
|
|
3368
|
+
const spanTyped = doc.createElement("span");
|
|
2961
3369
|
spanTyped.className = "mask-ghost-typed";
|
|
2962
3370
|
spanTyped.textContent = val;
|
|
2963
|
-
const spanRemaining =
|
|
3371
|
+
const spanRemaining = doc.createElement("span");
|
|
2964
3372
|
spanRemaining.className = "mask-ghost-remaining";
|
|
2965
3373
|
spanRemaining.textContent = this.currentSuggestion.remaining;
|
|
2966
|
-
this.
|
|
2967
|
-
this.ghost.appendChild(spanRemaining);
|
|
3374
|
+
this.setGhostContent(spanTyped, spanRemaining);
|
|
2968
3375
|
} else {
|
|
2969
|
-
this.
|
|
3376
|
+
this.clearGhost();
|
|
2970
3377
|
}
|
|
2971
3378
|
this.ghost.scrollLeft = this.input.scrollLeft;
|
|
3379
|
+
if (announceOptions?.announce) {
|
|
3380
|
+
this.scheduleSuggestionAnnouncement(Boolean(announceOptions.immediate));
|
|
3381
|
+
}
|
|
2972
3382
|
const detail = this.getDetail();
|
|
2973
3383
|
if (this.options.onInput) {
|
|
2974
3384
|
this.options.onInput(detail);
|
|
2975
3385
|
}
|
|
2976
3386
|
this.input.dispatchEvent(new CustomEvent("mask:input", { bubbles: true, detail }));
|
|
2977
|
-
this.
|
|
3387
|
+
if (val !== this.lastNotifiedValue) {
|
|
3388
|
+
this.lastNotifiedValue = val;
|
|
3389
|
+
this.dispatchNativeInput();
|
|
3390
|
+
}
|
|
2978
3391
|
}
|
|
2979
|
-
handleInput() {
|
|
3392
|
+
handleInput(e) {
|
|
2980
3393
|
if (this.isDispatchingNativeInput) return;
|
|
2981
|
-
if (this.options.disabled) return;
|
|
3394
|
+
if (this.options.disabled || this.isPasswordInput()) return;
|
|
3395
|
+
if (this.isComposing || e && "isComposing" in e && e.isComposing) return;
|
|
2982
3396
|
if (this.options.autoLowercase) {
|
|
2983
3397
|
const start = this.input.selectionStart ?? 0;
|
|
2984
3398
|
const end = this.input.selectionEnd ?? start;
|
|
@@ -2989,10 +3403,11 @@ var __WulfIIFE = (() => {
|
|
|
2989
3403
|
}
|
|
2990
3404
|
}
|
|
2991
3405
|
this.currentSuggestionIndex = 0;
|
|
2992
|
-
this.updateSuggestion();
|
|
3406
|
+
this.updateSuggestion({ announce: true, immediate: false });
|
|
2993
3407
|
}
|
|
2994
3408
|
handleKeyDown(e) {
|
|
2995
|
-
if (this.options.disabled) return;
|
|
3409
|
+
if (this.options.disabled || this.isPasswordInput() || isImeComposing(e)) return;
|
|
3410
|
+
if (e.shiftKey || e.ctrlKey || e.altKey || e.metaKey) return;
|
|
2996
3411
|
const hasSuggestion = Boolean(this.currentSuggestion.remaining) && !this.currentSuggestion.isHintOnly;
|
|
2997
3412
|
const cursor = this.input.selectionStart ?? 0;
|
|
2998
3413
|
const isAtEnd = cursor === this.input.value.length;
|
|
@@ -3001,13 +3416,13 @@ var __WulfIIFE = (() => {
|
|
|
3001
3416
|
if (e.key === "ArrowDown") {
|
|
3002
3417
|
e.preventDefault();
|
|
3003
3418
|
this.currentSuggestionIndex++;
|
|
3004
|
-
this.updateSuggestion();
|
|
3419
|
+
this.updateSuggestion({ announce: true, immediate: true });
|
|
3005
3420
|
return;
|
|
3006
3421
|
}
|
|
3007
3422
|
if (e.key === "ArrowUp") {
|
|
3008
3423
|
e.preventDefault();
|
|
3009
3424
|
this.currentSuggestionIndex--;
|
|
3010
|
-
this.updateSuggestion();
|
|
3425
|
+
this.updateSuggestion({ announce: true, immediate: true });
|
|
3011
3426
|
return;
|
|
3012
3427
|
}
|
|
3013
3428
|
}
|
|
@@ -3074,6 +3489,20 @@ var __WulfIIFE = (() => {
|
|
|
3074
3489
|
}
|
|
3075
3490
|
handleBlur() {
|
|
3076
3491
|
this.wrapper.classList.remove("is-focused");
|
|
3492
|
+
if (this.srAnnounceTimerId !== null) {
|
|
3493
|
+
clearTimeout(this.srAnnounceTimerId);
|
|
3494
|
+
this.srAnnounceTimerId = null;
|
|
3495
|
+
}
|
|
3496
|
+
this.lastAnnouncedSuggestion = "";
|
|
3497
|
+
if (this.srStatusEl) {
|
|
3498
|
+
this.srStatusEl.textContent = "";
|
|
3499
|
+
}
|
|
3500
|
+
if (this.isPasswordInput()) {
|
|
3501
|
+
this.lastNotifiedValue = "";
|
|
3502
|
+
this.lastTrackedValue = "";
|
|
3503
|
+
this.clearGhost();
|
|
3504
|
+
return;
|
|
3505
|
+
}
|
|
3077
3506
|
this.updateSuggestion();
|
|
3078
3507
|
const detail = this.getDetail();
|
|
3079
3508
|
if (this.options.onChange) {
|
|
@@ -3119,18 +3548,31 @@ var __WulfIIFE = (() => {
|
|
|
3119
3548
|
clearTimeout(this.resetTimerId);
|
|
3120
3549
|
this.resetTimerId = null;
|
|
3121
3550
|
}
|
|
3122
|
-
this.
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3551
|
+
if (this.srAnnounceTimerId !== null) {
|
|
3552
|
+
clearTimeout(this.srAnnounceTimerId);
|
|
3553
|
+
this.srAnnounceTimerId = null;
|
|
3554
|
+
}
|
|
3555
|
+
if (this.srStatusEl) {
|
|
3556
|
+
this.srStatusEl.remove();
|
|
3557
|
+
this.srStatusEl = null;
|
|
3558
|
+
}
|
|
3559
|
+
this.lastNotifiedValue = "";
|
|
3560
|
+
this.lastAnnouncedSuggestion = "";
|
|
3561
|
+
if (this.wasInputModeInferred && this.input.getAttribute("inputmode") === "email") {
|
|
3562
|
+
this.input.removeAttribute("inputmode");
|
|
3130
3563
|
}
|
|
3131
3564
|
if (this.wasAriaAutocompleteSet && this.input.getAttribute("aria-autocomplete") === "inline") {
|
|
3132
3565
|
this.input.removeAttribute("aria-autocomplete");
|
|
3133
3566
|
}
|
|
3567
|
+
if (this.wasAutocorrectSet && this.input.getAttribute("autocorrect") === "off") {
|
|
3568
|
+
this.input.removeAttribute("autocorrect");
|
|
3569
|
+
}
|
|
3570
|
+
if (this.wasAutocapitalizeSet && this.input.getAttribute("autocapitalize") === "none") {
|
|
3571
|
+
this.input.removeAttribute("autocapitalize");
|
|
3572
|
+
}
|
|
3573
|
+
if (this.wasSpellcheckSet && this.input.getAttribute("spellcheck") === "false") {
|
|
3574
|
+
this.input.removeAttribute("spellcheck");
|
|
3575
|
+
}
|
|
3134
3576
|
super.destroy();
|
|
3135
3577
|
}
|
|
3136
3578
|
};
|
|
@@ -3147,10 +3589,8 @@ var __WulfIIFE = (() => {
|
|
|
3147
3589
|
EmailEngine,
|
|
3148
3590
|
InputEmailMask
|
|
3149
3591
|
};
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
const wulfNamespace = win.Wulf || {};
|
|
3153
|
-
win.Wulf = wulfNamespace;
|
|
3592
|
+
var wulfNamespace = getSafeWulfNamespace();
|
|
3593
|
+
if (wulfNamespace) {
|
|
3154
3594
|
wulfNamespace.Mask = Mask;
|
|
3155
3595
|
}
|
|
3156
3596
|
var mask_default = InputMask;
|
|
@@ -3170,6 +3610,7 @@ var __WulfIIFE = (() => {
|
|
|
3170
3610
|
|
|
3171
3611
|
// src/common/LocalizedComponent.ts
|
|
3172
3612
|
var LocalizedComponent = class extends AuditableComponent {
|
|
3613
|
+
static _i18n;
|
|
3173
3614
|
/**
|
|
3174
3615
|
* Définit la langue globale du composant (ex: 'fr', 'en', 'es').
|
|
3175
3616
|
*/
|
|
@@ -3220,6 +3661,10 @@ var __WulfIIFE = (() => {
|
|
|
3220
3661
|
static t(key, instanceOverride) {
|
|
3221
3662
|
return this._i18n ? this._i18n.t(key, instanceOverride) : String(key);
|
|
3222
3663
|
}
|
|
3664
|
+
/**
|
|
3665
|
+
* Surcharges de localisation spécifiques à cette instance.
|
|
3666
|
+
*/
|
|
3667
|
+
i18nOverrides;
|
|
3223
3668
|
constructor(i18nOverrides) {
|
|
3224
3669
|
super();
|
|
3225
3670
|
this.i18nOverrides = i18nOverrides;
|
|
@@ -3250,7 +3695,7 @@ var __WulfIIFE = (() => {
|
|
|
3250
3695
|
function assignDefined(target, source) {
|
|
3251
3696
|
if (!source || typeof source !== "object") return target;
|
|
3252
3697
|
for (const key of Object.keys(source)) {
|
|
3253
|
-
if (isSafeKey(String(key)) && Object.
|
|
3698
|
+
if (isSafeKey(String(key)) && Object.hasOwn(source, key) && source[key] !== void 0) {
|
|
3254
3699
|
target[key] = source[key];
|
|
3255
3700
|
}
|
|
3256
3701
|
}
|
|
@@ -3311,7 +3756,7 @@ var __WulfIIFE = (() => {
|
|
|
3311
3756
|
if (!isSafeKey(String(key))) {
|
|
3312
3757
|
return "";
|
|
3313
3758
|
}
|
|
3314
|
-
if (instanceOverride && typeof instanceOverride === "object" && Object.
|
|
3759
|
+
if (instanceOverride && typeof instanceOverride === "object" && Object.hasOwn(instanceOverride, key) && instanceOverride[key] !== void 0) {
|
|
3315
3760
|
return String(instanceOverride[key]);
|
|
3316
3761
|
}
|
|
3317
3762
|
if (globalOverrides[key] !== void 0) {
|
|
@@ -3374,21 +3819,60 @@ var __WulfIIFE = (() => {
|
|
|
3374
3819
|
// src/scroll/ScrollBlock.ts
|
|
3375
3820
|
var idCounter = 0;
|
|
3376
3821
|
var ScrollBlock = class extends LocalizedComponent {
|
|
3822
|
+
static _i18n = scrollI18n;
|
|
3823
|
+
static i18n = scrollI18n;
|
|
3824
|
+
root;
|
|
3825
|
+
viewport;
|
|
3826
|
+
options;
|
|
3827
|
+
createdViewport = false;
|
|
3828
|
+
isDestroyed = false;
|
|
3829
|
+
wasIdGenerated = false;
|
|
3830
|
+
wasRoleInferred = false;
|
|
3831
|
+
wasAriaLabelInferred = false;
|
|
3832
|
+
hasExplicitAriaLabel = false;
|
|
3833
|
+
hasRootAriaLabel = false;
|
|
3834
|
+
propagatedRootLabel = null;
|
|
3835
|
+
lastInferredAriaLabel = "";
|
|
3836
|
+
trackY;
|
|
3837
|
+
thumbY;
|
|
3838
|
+
trackX;
|
|
3839
|
+
thumbX;
|
|
3840
|
+
resizeObserver;
|
|
3841
|
+
hideTimer;
|
|
3842
|
+
scrollEndFallbackTimer;
|
|
3843
|
+
rafId = null;
|
|
3844
|
+
resizeRafId = null;
|
|
3845
|
+
abortController = new AbortController();
|
|
3846
|
+
dragAbortController;
|
|
3847
|
+
activeScrollToController;
|
|
3848
|
+
supportsScrollEnd = typeof window !== "undefined" && "onscrollend" in window;
|
|
3849
|
+
// Cache de métriques géométriques mis à jour dans update() pour éviter tout forced reflow en cours de scroll
|
|
3850
|
+
cachedMaxTop = 0;
|
|
3851
|
+
cachedMaxLeft = 0;
|
|
3852
|
+
cachedTrackHeight = 0;
|
|
3853
|
+
cachedThumbHeight = 0;
|
|
3854
|
+
cachedTrackWidth = 0;
|
|
3855
|
+
cachedThumbWidth = 0;
|
|
3856
|
+
isDragging = false;
|
|
3857
|
+
dragAxis;
|
|
3858
|
+
dragPointerId;
|
|
3859
|
+
dragStartPos = 0;
|
|
3860
|
+
dragStartScroll = 0;
|
|
3861
|
+
atBottom = false;
|
|
3862
|
+
atTop = true;
|
|
3863
|
+
atRight = false;
|
|
3864
|
+
atLeft = true;
|
|
3865
|
+
// Références d'écouteurs d'événements pour les callbacks et le drag
|
|
3866
|
+
boundOnScroll;
|
|
3867
|
+
boundOnScrollEnd;
|
|
3868
|
+
boundOnMouseEnter;
|
|
3869
|
+
boundOnMouseLeave;
|
|
3870
|
+
boundOnFocusIn;
|
|
3871
|
+
boundOnFocusOut;
|
|
3872
|
+
boundPointerMove;
|
|
3873
|
+
boundPointerUp;
|
|
3377
3874
|
constructor(element, options) {
|
|
3378
3875
|
super(options?.i18n);
|
|
3379
|
-
this.createdViewport = false;
|
|
3380
|
-
this.wasIdGenerated = false;
|
|
3381
|
-
this.wasRoleInferred = false;
|
|
3382
|
-
this.wasAriaLabelInferred = false;
|
|
3383
|
-
this.hasExplicitAriaLabel = false;
|
|
3384
|
-
this.lastInferredAriaLabel = "";
|
|
3385
|
-
this.isDragging = false;
|
|
3386
|
-
this.dragStartPos = 0;
|
|
3387
|
-
this.dragStartScroll = 0;
|
|
3388
|
-
this.atBottom = false;
|
|
3389
|
-
this.atTop = true;
|
|
3390
|
-
this.atRight = false;
|
|
3391
|
-
this.atLeft = true;
|
|
3392
3876
|
let resolvedElement = null;
|
|
3393
3877
|
if (typeof element === "string") {
|
|
3394
3878
|
try {
|
|
@@ -3412,6 +3896,7 @@ var __WulfIIFE = (() => {
|
|
|
3412
3896
|
const safeEdgeThreshold = typeof rawEdge === "number" && Number.isFinite(rawEdge) && rawEdge >= 0 ? rawEdge : 10;
|
|
3413
3897
|
this.options = {
|
|
3414
3898
|
axis: options?.axis || "y",
|
|
3899
|
+
mode: options?.mode || "custom",
|
|
3415
3900
|
autoHide: options?.autoHide ?? true,
|
|
3416
3901
|
autoHideDelay: safeAutoHideDelay,
|
|
3417
3902
|
alwaysVisible: options?.alwaysVisible ?? false,
|
|
@@ -3421,6 +3906,8 @@ var __WulfIIFE = (() => {
|
|
|
3421
3906
|
edgeThreshold: safeEdgeThreshold,
|
|
3422
3907
|
onScroll: options?.onScroll || (() => {
|
|
3423
3908
|
}),
|
|
3909
|
+
onScrollEnd: options?.onScrollEnd || (() => {
|
|
3910
|
+
}),
|
|
3424
3911
|
onTotalScroll: options?.onTotalScroll || (() => {
|
|
3425
3912
|
}),
|
|
3426
3913
|
onTotalScrollBack: options?.onTotalScrollBack || (() => {
|
|
@@ -3428,6 +3915,7 @@ var __WulfIIFE = (() => {
|
|
|
3428
3915
|
audit: options?.audit ?? true
|
|
3429
3916
|
};
|
|
3430
3917
|
this.boundOnScroll = this.handleScroll.bind(this);
|
|
3918
|
+
this.boundOnScrollEnd = this.handleScrollEnd.bind(this);
|
|
3431
3919
|
this.boundOnMouseEnter = this.handleMouseEnter.bind(this);
|
|
3432
3920
|
this.boundOnMouseLeave = this.handleMouseLeave.bind(this);
|
|
3433
3921
|
this.boundOnFocusIn = this.handleFocusIn.bind(this);
|
|
@@ -3447,6 +3935,9 @@ var __WulfIIFE = (() => {
|
|
|
3447
3935
|
*/
|
|
3448
3936
|
setupViewport() {
|
|
3449
3937
|
this.root.classList.add("wulf-scrollblock");
|
|
3938
|
+
if (this.options.mode === "native") {
|
|
3939
|
+
this.root.classList.add("wulf-scrollblock--native");
|
|
3940
|
+
}
|
|
3450
3941
|
if (this.options.alwaysVisible) {
|
|
3451
3942
|
this.root.classList.add("is-always-visible");
|
|
3452
3943
|
}
|
|
@@ -3457,12 +3948,13 @@ var __WulfIIFE = (() => {
|
|
|
3457
3948
|
if (existingViewport) {
|
|
3458
3949
|
return existingViewport;
|
|
3459
3950
|
}
|
|
3951
|
+
const existingChildren = Array.from(this.root.childNodes);
|
|
3460
3952
|
const viewport = document.createElement("div");
|
|
3461
3953
|
viewport.className = "wulf-scrollblock-viewport";
|
|
3462
|
-
while (this.root.firstChild) {
|
|
3463
|
-
viewport.appendChild(this.root.firstChild);
|
|
3464
|
-
}
|
|
3465
3954
|
this.root.appendChild(viewport);
|
|
3955
|
+
for (const child of existingChildren) {
|
|
3956
|
+
safeMove(viewport, child, null);
|
|
3957
|
+
}
|
|
3466
3958
|
this.createdViewport = true;
|
|
3467
3959
|
return viewport;
|
|
3468
3960
|
}
|
|
@@ -3479,8 +3971,27 @@ var __WulfIIFE = (() => {
|
|
|
3479
3971
|
this.viewport.setAttribute("role", "region");
|
|
3480
3972
|
this.wasRoleInferred = true;
|
|
3481
3973
|
}
|
|
3482
|
-
|
|
3483
|
-
|
|
3974
|
+
const rootLabelledBy = this.root.getAttribute("aria-labelledby")?.trim();
|
|
3975
|
+
const rootAriaLabel = this.root.getAttribute("aria-label")?.trim();
|
|
3976
|
+
if (rootLabelledBy) {
|
|
3977
|
+
this.hasRootAriaLabel = true;
|
|
3978
|
+
if (!this.hasExplicitAriaLabel && !this.viewport.hasAttribute("aria-labelledby") && !this.viewport.hasAttribute("aria-label")) {
|
|
3979
|
+
this.viewport.setAttribute("aria-labelledby", rootLabelledBy);
|
|
3980
|
+
this.propagatedRootLabel = "aria-labelledby";
|
|
3981
|
+
}
|
|
3982
|
+
} else if (rootAriaLabel) {
|
|
3983
|
+
this.hasRootAriaLabel = true;
|
|
3984
|
+
if (!this.hasExplicitAriaLabel && !this.viewport.hasAttribute("aria-label") && !this.viewport.hasAttribute("aria-labelledby")) {
|
|
3985
|
+
this.viewport.setAttribute("aria-label", rootAriaLabel);
|
|
3986
|
+
this.propagatedRootLabel = "aria-label";
|
|
3987
|
+
}
|
|
3988
|
+
}
|
|
3989
|
+
if (this.hasExplicitAriaLabel && !this.viewport.hasAttribute("aria-label")) {
|
|
3990
|
+
this.viewport.setAttribute("aria-label", this.options.ariaLabel);
|
|
3991
|
+
this.lastInferredAriaLabel = this.options.ariaLabel;
|
|
3992
|
+
this.wasAriaLabelInferred = true;
|
|
3993
|
+
} else if (!this.viewport.hasAttribute("aria-label") && !this.viewport.hasAttribute("aria-labelledby")) {
|
|
3994
|
+
const label = this.t("viewport");
|
|
3484
3995
|
this.viewport.setAttribute("aria-label", label);
|
|
3485
3996
|
this.lastInferredAriaLabel = label;
|
|
3486
3997
|
this.wasAriaLabelInferred = true;
|
|
@@ -3510,10 +4021,12 @@ var __WulfIIFE = (() => {
|
|
|
3510
4021
|
* Crée les rails et curseurs selon l'axe sélectionné.
|
|
3511
4022
|
*/
|
|
3512
4023
|
setupScrollbars() {
|
|
4024
|
+
if (this.options.mode === "native") {
|
|
4025
|
+
return;
|
|
4026
|
+
}
|
|
3513
4027
|
if (this.options.axis === "y" || this.options.axis === "both") {
|
|
3514
4028
|
this.trackY = document.createElement("div");
|
|
3515
4029
|
this.trackY.className = "wulf-scrollblock-track wulf-scrollblock-vertical";
|
|
3516
|
-
this.trackY.setAttribute("aria-hidden", "true");
|
|
3517
4030
|
this.thumbY = document.createElement("div");
|
|
3518
4031
|
this.thumbY.className = "wulf-scrollblock-thumb";
|
|
3519
4032
|
this.thumbY.setAttribute("role", "scrollbar");
|
|
@@ -3530,7 +4043,6 @@ var __WulfIIFE = (() => {
|
|
|
3530
4043
|
if (this.options.axis === "x" || this.options.axis === "both") {
|
|
3531
4044
|
this.trackX = document.createElement("div");
|
|
3532
4045
|
this.trackX.className = "wulf-scrollblock-track wulf-scrollblock-horizontal";
|
|
3533
|
-
this.trackX.setAttribute("aria-hidden", "true");
|
|
3534
4046
|
this.thumbX = document.createElement("div");
|
|
3535
4047
|
this.thumbX.className = "wulf-scrollblock-thumb";
|
|
3536
4048
|
this.thumbX.setAttribute("role", "scrollbar");
|
|
@@ -3545,48 +4057,129 @@ var __WulfIIFE = (() => {
|
|
|
3545
4057
|
this.attachTrackListeners(this.trackX, this.thumbX, "x");
|
|
3546
4058
|
}
|
|
3547
4059
|
}
|
|
4060
|
+
isRtl() {
|
|
4061
|
+
return typeof window !== "undefined" && window.getComputedStyle(this.viewport).direction === "rtl";
|
|
4062
|
+
}
|
|
3548
4063
|
/**
|
|
3549
|
-
* Attache les écouteurs sur un rail et son curseur.
|
|
4064
|
+
* Attache les écouteurs souris/pointeur et clavier WAI-ARIA sur un rail et son curseur.
|
|
3550
4065
|
*/
|
|
3551
4066
|
attachTrackListeners(track, thumb, axis) {
|
|
4067
|
+
const { signal } = this.abortController;
|
|
3552
4068
|
thumb.addEventListener("pointerdown", (e) => {
|
|
4069
|
+
if (e.button !== 0) return;
|
|
3553
4070
|
e.preventDefault();
|
|
3554
4071
|
e.stopPropagation();
|
|
4072
|
+
this.dragAbortController?.abort();
|
|
4073
|
+
this.dragAbortController = new AbortController();
|
|
4074
|
+
const dragSignal = this.dragAbortController.signal;
|
|
3555
4075
|
this.isDragging = true;
|
|
3556
4076
|
this.dragAxis = axis;
|
|
3557
4077
|
this.dragPointerId = e.pointerId;
|
|
3558
4078
|
this.dragStartPos = axis === "y" ? e.clientY : e.clientX;
|
|
3559
4079
|
this.dragStartScroll = axis === "y" ? this.viewport.scrollTop : this.viewport.scrollLeft;
|
|
3560
|
-
|
|
4080
|
+
try {
|
|
4081
|
+
thumb.setPointerCapture(e.pointerId);
|
|
4082
|
+
} catch {
|
|
4083
|
+
}
|
|
3561
4084
|
thumb.classList.add("is-active");
|
|
3562
4085
|
this.root.classList.add("is-dragging");
|
|
3563
|
-
window.addEventListener("pointermove", this.boundPointerMove);
|
|
3564
|
-
window.addEventListener("pointerup", this.boundPointerUp);
|
|
3565
|
-
window.addEventListener("pointercancel", this.boundPointerUp);
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
e.
|
|
3570
|
-
const
|
|
3571
|
-
const
|
|
3572
|
-
const
|
|
3573
|
-
|
|
3574
|
-
const
|
|
3575
|
-
const
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
4086
|
+
window.addEventListener("pointermove", this.boundPointerMove, { signal: dragSignal });
|
|
4087
|
+
window.addEventListener("pointerup", this.boundPointerUp, { signal: dragSignal });
|
|
4088
|
+
window.addEventListener("pointercancel", this.boundPointerUp, { signal: dragSignal });
|
|
4089
|
+
thumb.addEventListener("lostpointercapture", this.boundPointerUp, { signal: dragSignal });
|
|
4090
|
+
}, { signal });
|
|
4091
|
+
thumb.addEventListener("keydown", (e) => {
|
|
4092
|
+
if (e.ctrlKey || e.altKey || e.metaKey) return;
|
|
4093
|
+
const step = 40;
|
|
4094
|
+
const page = axis === "y" ? Math.max(step, Math.round(this.viewport.clientHeight * 0.9)) : Math.max(step, Math.round(this.viewport.clientWidth * 0.9));
|
|
4095
|
+
const maxScroll = axis === "y" ? this.cachedMaxTop : this.cachedMaxLeft;
|
|
4096
|
+
if (maxScroll <= 0) return;
|
|
4097
|
+
const rtl = axis === "x" && this.isRtl();
|
|
4098
|
+
const current = axis === "y" ? this.viewport.scrollTop : this.viewport.scrollLeft;
|
|
4099
|
+
let target = null;
|
|
4100
|
+
if (axis === "y") {
|
|
4101
|
+
switch (e.key) {
|
|
4102
|
+
case "ArrowDown":
|
|
4103
|
+
target = current + step;
|
|
4104
|
+
break;
|
|
4105
|
+
case "ArrowUp":
|
|
4106
|
+
target = current - step;
|
|
4107
|
+
break;
|
|
4108
|
+
case "PageDown":
|
|
4109
|
+
target = current + page;
|
|
4110
|
+
break;
|
|
4111
|
+
case "PageUp":
|
|
4112
|
+
target = current - page;
|
|
4113
|
+
break;
|
|
4114
|
+
case " ":
|
|
4115
|
+
target = current + (e.shiftKey ? -page : page);
|
|
4116
|
+
break;
|
|
4117
|
+
case "Home":
|
|
4118
|
+
target = 0;
|
|
4119
|
+
break;
|
|
4120
|
+
case "End":
|
|
4121
|
+
target = maxScroll;
|
|
4122
|
+
break;
|
|
4123
|
+
}
|
|
4124
|
+
} else {
|
|
4125
|
+
switch (e.key) {
|
|
4126
|
+
case "ArrowRight":
|
|
4127
|
+
target = current + step;
|
|
4128
|
+
break;
|
|
4129
|
+
case "ArrowLeft":
|
|
4130
|
+
target = current - step;
|
|
4131
|
+
break;
|
|
4132
|
+
case "PageDown":
|
|
4133
|
+
target = current + (rtl ? -page : page);
|
|
4134
|
+
break;
|
|
4135
|
+
case "PageUp":
|
|
4136
|
+
target = current + (rtl ? page : -page);
|
|
4137
|
+
break;
|
|
4138
|
+
case " ":
|
|
4139
|
+
target = current + (e.shiftKey ? rtl ? page : -page : rtl ? -page : page);
|
|
4140
|
+
break;
|
|
4141
|
+
case "Home":
|
|
4142
|
+
target = 0;
|
|
4143
|
+
break;
|
|
4144
|
+
case "End":
|
|
4145
|
+
target = rtl ? -maxScroll : maxScroll;
|
|
4146
|
+
break;
|
|
4147
|
+
}
|
|
4148
|
+
}
|
|
4149
|
+
if (target === null) return;
|
|
4150
|
+
e.preventDefault();
|
|
4151
|
+
e.stopPropagation();
|
|
4152
|
+
void this.scrollTo(axis === "y" ? { top: target } : { left: target }, { smooth: false });
|
|
4153
|
+
this.syncThumbs();
|
|
4154
|
+
}, { signal });
|
|
4155
|
+
track.addEventListener("pointerdown", (e) => {
|
|
4156
|
+
if (e.button !== 0 || e.target === thumb) return;
|
|
4157
|
+
e.preventDefault();
|
|
4158
|
+
const rtl = axis === "x" && this.isRtl();
|
|
4159
|
+
const rect = track.getBoundingClientRect();
|
|
4160
|
+
const clickPos = axis === "y" ? e.clientY - rect.top : rtl ? rect.right - e.clientX : e.clientX - rect.left;
|
|
4161
|
+
const trackSize = axis === "y" ? rect.height : rect.width;
|
|
4162
|
+
if (trackSize <= 0) return;
|
|
4163
|
+
const maxScroll = axis === "y" ? this.cachedMaxTop : this.cachedMaxLeft;
|
|
4164
|
+
const ratio = Math.max(0, Math.min(1, clickPos / trackSize));
|
|
4165
|
+
const targetScroll = rtl ? -(ratio * maxScroll) : ratio * maxScroll;
|
|
4166
|
+
void this.scrollTo(axis === "y" ? { top: targetScroll } : { left: targetScroll }, { smooth: true });
|
|
4167
|
+
}, { signal });
|
|
4168
|
+
}
|
|
4169
|
+
/**
|
|
4170
|
+
* Écouteurs globaux sur le viewport et les interactions.
|
|
4171
|
+
*/
|
|
4172
|
+
setupEventListeners() {
|
|
4173
|
+
const { signal } = this.abortController;
|
|
4174
|
+
this.viewport.addEventListener("scroll", this.boundOnScroll, { passive: true, signal });
|
|
4175
|
+
if (this.supportsScrollEnd) {
|
|
4176
|
+
this.viewport.addEventListener("scrollend", this.boundOnScrollEnd, { passive: true, signal });
|
|
4177
|
+
}
|
|
4178
|
+
if (this.options.mode !== "native" && this.options.autoHide && !this.options.alwaysVisible) {
|
|
4179
|
+
this.root.addEventListener("mouseenter", this.boundOnMouseEnter, { signal });
|
|
4180
|
+
this.root.addEventListener("mouseleave", this.boundOnMouseLeave, { signal });
|
|
4181
|
+
this.root.addEventListener("focusin", this.boundOnFocusIn, { signal });
|
|
4182
|
+
this.root.addEventListener("focusout", this.boundOnFocusOut, { signal });
|
|
3590
4183
|
}
|
|
3591
4184
|
}
|
|
3592
4185
|
/**
|
|
@@ -3595,7 +4188,13 @@ var __WulfIIFE = (() => {
|
|
|
3595
4188
|
setupObserver() {
|
|
3596
4189
|
if (typeof ResizeObserver !== "undefined") {
|
|
3597
4190
|
this.resizeObserver = new ResizeObserver(() => {
|
|
3598
|
-
|
|
4191
|
+
if (this.isDestroyed || this.resizeRafId !== null) return;
|
|
4192
|
+
this.resizeRafId = window.requestAnimationFrame(() => {
|
|
4193
|
+
this.resizeRafId = null;
|
|
4194
|
+
if (!this.isDestroyed) {
|
|
4195
|
+
this.update();
|
|
4196
|
+
}
|
|
4197
|
+
});
|
|
3599
4198
|
});
|
|
3600
4199
|
this.resizeObserver.observe(this.root);
|
|
3601
4200
|
this.resizeObserver.observe(this.viewport);
|
|
@@ -3609,22 +4208,20 @@ var __WulfIIFE = (() => {
|
|
|
3609
4208
|
*/
|
|
3610
4209
|
handlePointerMove(e) {
|
|
3611
4210
|
if (!this.isDragging || !this.dragAxis) return;
|
|
4211
|
+
if (this.dragPointerId !== void 0 && e.pointerId !== this.dragPointerId) return;
|
|
3612
4212
|
const isY = this.dragAxis === "y";
|
|
3613
4213
|
const delta = (isY ? e.clientY : e.clientX) - this.dragStartPos;
|
|
3614
|
-
const
|
|
3615
|
-
const
|
|
3616
|
-
|
|
3617
|
-
const trackSize = isY ? track.clientHeight : track.clientWidth;
|
|
3618
|
-
const thumbSize = isY ? thumb.clientHeight : thumb.clientWidth;
|
|
3619
|
-
const clientSize = isY ? this.viewport.clientHeight : this.viewport.clientWidth;
|
|
3620
|
-
const scrollSize = isY ? this.viewport.scrollHeight : this.viewport.scrollWidth;
|
|
3621
|
-
const maxScroll = scrollSize - clientSize;
|
|
4214
|
+
const trackSize = isY ? this.cachedTrackHeight : this.cachedTrackWidth;
|
|
4215
|
+
const thumbSize = isY ? this.cachedThumbHeight : this.cachedThumbWidth;
|
|
4216
|
+
const maxScroll = isY ? this.cachedMaxTop : this.cachedMaxLeft;
|
|
3622
4217
|
const maxThumbTravel = trackSize - thumbSize;
|
|
3623
4218
|
if (maxThumbTravel <= 0 || maxScroll <= 0) return;
|
|
3624
4219
|
const ratio = maxScroll / maxThumbTravel;
|
|
3625
4220
|
const nextScroll = this.dragStartScroll + delta * ratio;
|
|
3626
4221
|
if (isY) {
|
|
3627
4222
|
this.viewport.scrollTop = Math.max(0, Math.min(maxScroll, nextScroll));
|
|
4223
|
+
} else if (this.isRtl()) {
|
|
4224
|
+
this.viewport.scrollLeft = Math.max(-maxScroll, Math.min(0, nextScroll));
|
|
3628
4225
|
} else {
|
|
3629
4226
|
this.viewport.scrollLeft = Math.max(0, Math.min(maxScroll, nextScroll));
|
|
3630
4227
|
}
|
|
@@ -3634,15 +4231,20 @@ var __WulfIIFE = (() => {
|
|
|
3634
4231
|
*/
|
|
3635
4232
|
handlePointerUp(e) {
|
|
3636
4233
|
if (!this.isDragging) return;
|
|
4234
|
+
if (e && e.type !== "lostpointercapture" && this.dragPointerId !== void 0 && e.pointerId !== this.dragPointerId) {
|
|
4235
|
+
return;
|
|
4236
|
+
}
|
|
3637
4237
|
if (this.dragPointerId !== void 0) {
|
|
3638
4238
|
const activeThumb = this.dragAxis === "y" ? this.thumbY : this.thumbX;
|
|
3639
|
-
|
|
3640
|
-
activeThumb.
|
|
4239
|
+
try {
|
|
4240
|
+
if (activeThumb && activeThumb.hasPointerCapture(this.dragPointerId)) {
|
|
4241
|
+
activeThumb.releasePointerCapture(this.dragPointerId);
|
|
4242
|
+
}
|
|
4243
|
+
} catch {
|
|
3641
4244
|
}
|
|
3642
4245
|
}
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
window.removeEventListener("pointercancel", this.boundPointerUp);
|
|
4246
|
+
this.dragAbortController?.abort();
|
|
4247
|
+
this.dragAbortController = void 0;
|
|
3646
4248
|
this.isDragging = false;
|
|
3647
4249
|
this.dragAxis = void 0;
|
|
3648
4250
|
this.dragPointerId = void 0;
|
|
@@ -3651,24 +4253,31 @@ var __WulfIIFE = (() => {
|
|
|
3651
4253
|
this.root.classList.remove("is-dragging");
|
|
3652
4254
|
this.scheduleAutoHide();
|
|
3653
4255
|
}
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
this.
|
|
3659
|
-
const
|
|
3660
|
-
const
|
|
3661
|
-
const
|
|
3662
|
-
|
|
3663
|
-
const progressX = maxLeft > 0 ? scrollLeft / maxLeft : 0;
|
|
3664
|
-
this.options.onScroll({
|
|
4256
|
+
getScrollInfo() {
|
|
4257
|
+
const { scrollTop, scrollLeft } = this.viewport;
|
|
4258
|
+
const maxTop = this.cachedMaxTop;
|
|
4259
|
+
const maxLeft = this.cachedMaxLeft;
|
|
4260
|
+
const rtl = this.isRtl();
|
|
4261
|
+
const logicalLeft = rtl ? Math.max(0, -scrollLeft) : Math.max(0, scrollLeft);
|
|
4262
|
+
const progressY = maxTop > 0 ? Math.max(0, Math.min(1, scrollTop / maxTop)) : 0;
|
|
4263
|
+
const progressX = maxLeft > 0 ? Math.max(0, Math.min(1, logicalLeft / maxLeft)) : 0;
|
|
4264
|
+
return {
|
|
3665
4265
|
top: scrollTop,
|
|
3666
4266
|
left: scrollLeft,
|
|
3667
4267
|
maxTop,
|
|
3668
4268
|
maxLeft,
|
|
3669
4269
|
progressY: Math.round(progressY * 100),
|
|
3670
4270
|
progressX: Math.round(progressX * 100)
|
|
3671
|
-
}
|
|
4271
|
+
};
|
|
4272
|
+
}
|
|
4273
|
+
/**
|
|
4274
|
+
* Gestionnaire d'événement de défilement natif.
|
|
4275
|
+
*/
|
|
4276
|
+
handleScroll() {
|
|
4277
|
+
this.scheduleSyncThumbs();
|
|
4278
|
+
const info = this.getScrollInfo();
|
|
4279
|
+
const { top: scrollTop, left: scrollLeft, maxTop, maxLeft } = info;
|
|
4280
|
+
this.options.onScroll(info);
|
|
3672
4281
|
const threshold = this.options.edgeThreshold;
|
|
3673
4282
|
if (maxTop > 0) {
|
|
3674
4283
|
const nowBottom = scrollTop >= maxTop - threshold;
|
|
@@ -3683,8 +4292,9 @@ var __WulfIIFE = (() => {
|
|
|
3683
4292
|
this.atTop = nowTop;
|
|
3684
4293
|
}
|
|
3685
4294
|
if (maxLeft > 0) {
|
|
3686
|
-
const
|
|
3687
|
-
const
|
|
4295
|
+
const rtl = this.isRtl();
|
|
4296
|
+
const nowRight = rtl ? scrollLeft >= -threshold : scrollLeft >= maxLeft - threshold;
|
|
4297
|
+
const nowLeft = rtl ? scrollLeft <= -maxLeft + threshold : scrollLeft <= threshold;
|
|
3688
4298
|
if (nowRight && !this.atRight) {
|
|
3689
4299
|
this.options.onTotalScroll("right");
|
|
3690
4300
|
}
|
|
@@ -3694,37 +4304,71 @@ var __WulfIIFE = (() => {
|
|
|
3694
4304
|
this.atRight = nowRight;
|
|
3695
4305
|
this.atLeft = nowLeft;
|
|
3696
4306
|
}
|
|
3697
|
-
if (this.options.autoHide && !this.options.alwaysVisible) {
|
|
4307
|
+
if (this.options.mode !== "native" && this.options.autoHide && !this.options.alwaysVisible) {
|
|
4308
|
+
this.clearAutoHideTimer();
|
|
3698
4309
|
this.root.classList.add("is-scrolling");
|
|
4310
|
+
if (!this.supportsScrollEnd) {
|
|
4311
|
+
this.scheduleAutoHide();
|
|
4312
|
+
}
|
|
4313
|
+
}
|
|
4314
|
+
if (!this.supportsScrollEnd) {
|
|
4315
|
+
if (this.scrollEndFallbackTimer !== void 0) {
|
|
4316
|
+
window.clearTimeout(this.scrollEndFallbackTimer);
|
|
4317
|
+
}
|
|
4318
|
+
this.scrollEndFallbackTimer = window.setTimeout(() => {
|
|
4319
|
+
this.scrollEndFallbackTimer = void 0;
|
|
4320
|
+
this.handleScrollEnd();
|
|
4321
|
+
}, 150);
|
|
4322
|
+
}
|
|
4323
|
+
}
|
|
4324
|
+
/**
|
|
4325
|
+
* Gestionnaire de fin de défilement (`scrollend` natif ou repli temporisé).
|
|
4326
|
+
*/
|
|
4327
|
+
handleScrollEnd() {
|
|
4328
|
+
this.options.onScrollEnd(this.getScrollInfo());
|
|
4329
|
+
if (this.options.mode !== "native" && this.options.autoHide && !this.options.alwaysVisible) {
|
|
3699
4330
|
this.scheduleAutoHide();
|
|
3700
4331
|
}
|
|
3701
4332
|
}
|
|
3702
4333
|
/**
|
|
3703
|
-
*
|
|
4334
|
+
* Planifie une synchronisation des curseurs calée sur la prochaine trame d'affichage.
|
|
4335
|
+
*/
|
|
4336
|
+
scheduleSyncThumbs() {
|
|
4337
|
+
if (this.options.mode === "native" || this.isDestroyed) return;
|
|
4338
|
+
if (this.rafId !== null) return;
|
|
4339
|
+
this.rafId = window.requestAnimationFrame(() => {
|
|
4340
|
+
this.rafId = null;
|
|
4341
|
+
if (!this.isDestroyed) {
|
|
4342
|
+
this.syncThumbs();
|
|
4343
|
+
}
|
|
4344
|
+
});
|
|
4345
|
+
}
|
|
4346
|
+
/**
|
|
4347
|
+
* Synchronise la position physique (via variables CSS) et ARIA des curseurs à partir des métriques en cache.
|
|
3704
4348
|
*/
|
|
3705
4349
|
syncThumbs() {
|
|
3706
|
-
|
|
4350
|
+
if (this.options.mode === "native" || this.isDestroyed) return;
|
|
4351
|
+
const { scrollTop, scrollLeft } = this.viewport;
|
|
3707
4352
|
if (this.thumbY && this.trackY) {
|
|
3708
|
-
const maxScrollY =
|
|
3709
|
-
const
|
|
3710
|
-
const thumbHeight = this.thumbY.clientHeight;
|
|
3711
|
-
const maxTravelY = trackHeight - thumbHeight;
|
|
4353
|
+
const maxScrollY = this.cachedMaxTop;
|
|
4354
|
+
const maxTravelY = this.cachedTrackHeight - this.cachedThumbHeight;
|
|
3712
4355
|
if (maxScrollY > 0 && maxTravelY > 0) {
|
|
3713
|
-
const ratioY = scrollTop / maxScrollY;
|
|
4356
|
+
const ratioY = Math.max(0, Math.min(1, scrollTop / maxScrollY));
|
|
3714
4357
|
const posY = Math.max(0, Math.min(maxTravelY, ratioY * maxTravelY));
|
|
3715
|
-
this.thumbY.style.
|
|
4358
|
+
this.thumbY.style.setProperty("--scrollblock-thumb-y", `${posY}px`);
|
|
3716
4359
|
this.thumbY.setAttribute("aria-valuenow", String(Math.round(ratioY * 100)));
|
|
3717
4360
|
}
|
|
3718
4361
|
}
|
|
3719
4362
|
if (this.thumbX && this.trackX) {
|
|
3720
|
-
const maxScrollX =
|
|
3721
|
-
const
|
|
3722
|
-
const thumbWidth = this.thumbX.clientWidth;
|
|
3723
|
-
const maxTravelX = trackWidth - thumbWidth;
|
|
4363
|
+
const maxScrollX = this.cachedMaxLeft;
|
|
4364
|
+
const maxTravelX = this.cachedTrackWidth - this.cachedThumbWidth;
|
|
3724
4365
|
if (maxScrollX > 0 && maxTravelX > 0) {
|
|
3725
|
-
const
|
|
4366
|
+
const rtl = this.isRtl();
|
|
4367
|
+
const logicalLeft = rtl ? Math.max(0, -scrollLeft) : Math.max(0, scrollLeft);
|
|
4368
|
+
const ratioX = Math.max(0, Math.min(1, logicalLeft / maxScrollX));
|
|
3726
4369
|
const posX = Math.max(0, Math.min(maxTravelX, ratioX * maxTravelX));
|
|
3727
|
-
|
|
4370
|
+
const signedPosX = rtl ? -posX : posX;
|
|
4371
|
+
this.thumbX.style.setProperty("--scrollblock-thumb-x", `${signedPosX}px`);
|
|
3728
4372
|
this.thumbX.setAttribute("aria-valuenow", String(Math.round(ratioX * 100)));
|
|
3729
4373
|
}
|
|
3730
4374
|
}
|
|
@@ -3761,10 +4405,37 @@ var __WulfIIFE = (() => {
|
|
|
3761
4405
|
* Recalcule les dimensions et la visibilité des barres.
|
|
3762
4406
|
*/
|
|
3763
4407
|
update() {
|
|
4408
|
+
if (this.isDestroyed) return;
|
|
3764
4409
|
this.syncAccessibilityLabels();
|
|
3765
4410
|
const { scrollHeight, clientHeight, scrollWidth, clientWidth } = this.viewport;
|
|
4411
|
+
const trackHeight = this.trackY ? this.trackY.clientHeight : 0;
|
|
4412
|
+
const trackWidth = this.trackX ? this.trackX.clientWidth : 0;
|
|
4413
|
+
const cssMinY = this.thumbY && typeof window !== "undefined" ? parseFloat(window.getComputedStyle(this.thumbY).minBlockSize) || 0 : 0;
|
|
4414
|
+
const cssMinX = this.thumbX && typeof window !== "undefined" ? parseFloat(window.getComputedStyle(this.thumbX).minInlineSize) || 0 : 0;
|
|
4415
|
+
this.cachedMaxTop = Math.max(0, scrollHeight - clientHeight);
|
|
4416
|
+
this.cachedMaxLeft = Math.max(0, scrollWidth - clientWidth);
|
|
4417
|
+
this.cachedTrackHeight = trackHeight;
|
|
4418
|
+
this.cachedTrackWidth = trackWidth;
|
|
3766
4419
|
const canScrollY = scrollHeight > clientHeight;
|
|
3767
4420
|
const canScrollX = scrollWidth > clientWidth;
|
|
4421
|
+
let calculatedHeight = this.cachedThumbHeight;
|
|
4422
|
+
if (this.trackY && this.thumbY && canScrollY && scrollHeight > 0) {
|
|
4423
|
+
const effectiveMinY = Math.max(this.options.minThumbSize, cssMinY);
|
|
4424
|
+
calculatedHeight = Math.max(
|
|
4425
|
+
effectiveMinY,
|
|
4426
|
+
trackHeight * (clientHeight / scrollHeight)
|
|
4427
|
+
);
|
|
4428
|
+
this.cachedThumbHeight = calculatedHeight;
|
|
4429
|
+
}
|
|
4430
|
+
let calculatedWidth = this.cachedThumbWidth;
|
|
4431
|
+
if (this.trackX && this.thumbX && canScrollX && scrollWidth > 0) {
|
|
4432
|
+
const effectiveMinX = Math.max(this.options.minThumbSize, cssMinX);
|
|
4433
|
+
calculatedWidth = Math.max(
|
|
4434
|
+
effectiveMinX,
|
|
4435
|
+
trackWidth * (clientWidth / scrollWidth)
|
|
4436
|
+
);
|
|
4437
|
+
this.cachedThumbWidth = calculatedWidth;
|
|
4438
|
+
}
|
|
3768
4439
|
this.root.classList.toggle("has-scroll-y", canScrollY);
|
|
3769
4440
|
this.root.classList.toggle("has-scroll-x", canScrollX);
|
|
3770
4441
|
if (canScrollY || canScrollX) {
|
|
@@ -3773,37 +4444,40 @@ var __WulfIIFE = (() => {
|
|
|
3773
4444
|
this.viewport.removeAttribute("tabindex");
|
|
3774
4445
|
}
|
|
3775
4446
|
if (this.trackY && this.thumbY) {
|
|
4447
|
+
this.trackY.hidden = !canScrollY;
|
|
3776
4448
|
if (canScrollY) {
|
|
3777
|
-
|
|
3778
|
-
const calculatedHeight = Math.max(
|
|
3779
|
-
this.options.minThumbSize,
|
|
3780
|
-
trackHeight * (clientHeight / scrollHeight)
|
|
3781
|
-
);
|
|
4449
|
+
this.thumbY.setAttribute("tabindex", "0");
|
|
3782
4450
|
this.thumbY.style.height = `${calculatedHeight}px`;
|
|
4451
|
+
} else {
|
|
4452
|
+
this.thumbY.removeAttribute("tabindex");
|
|
3783
4453
|
}
|
|
3784
4454
|
}
|
|
3785
4455
|
if (this.trackX && this.thumbX) {
|
|
4456
|
+
this.trackX.hidden = !canScrollX;
|
|
3786
4457
|
if (canScrollX) {
|
|
3787
|
-
|
|
3788
|
-
const calculatedWidth = Math.max(
|
|
3789
|
-
this.options.minThumbSize,
|
|
3790
|
-
trackWidth * (clientWidth / scrollWidth)
|
|
3791
|
-
);
|
|
4458
|
+
this.thumbX.setAttribute("tabindex", "0");
|
|
3792
4459
|
this.thumbX.style.width = `${calculatedWidth}px`;
|
|
4460
|
+
} else {
|
|
4461
|
+
this.thumbX.removeAttribute("tabindex");
|
|
3793
4462
|
}
|
|
3794
4463
|
}
|
|
3795
4464
|
this.syncThumbs();
|
|
3796
4465
|
}
|
|
3797
4466
|
/**
|
|
3798
4467
|
* Défilement programmatique direct ou lissé.
|
|
4468
|
+
* Retourne une Promesse résolue lorsque le défilement atteint sa cible.
|
|
3799
4469
|
*/
|
|
3800
4470
|
scrollTo(target, options) {
|
|
3801
|
-
|
|
4471
|
+
if (this.isDestroyed) return Promise.resolve();
|
|
3802
4472
|
const targetSmooth = typeof target === "object" && target !== null && !(target instanceof HTMLElement) ? target.smooth : void 0;
|
|
3803
|
-
const shouldSmooth = (options?.smooth ?? targetSmooth ?? true) && !prefersReducedMotion;
|
|
4473
|
+
const shouldSmooth = (options?.smooth ?? targetSmooth ?? true) && !prefersReducedMotion();
|
|
3804
4474
|
const behavior = shouldSmooth ? "smooth" : "auto";
|
|
3805
|
-
const
|
|
3806
|
-
const
|
|
4475
|
+
const rtl = this.isRtl();
|
|
4476
|
+
const { scrollHeight, clientHeight, scrollWidth, clientWidth, scrollTop, scrollLeft } = this.viewport;
|
|
4477
|
+
const maxTop = Math.max(0, scrollHeight - clientHeight);
|
|
4478
|
+
const maxLeft = Math.max(0, scrollWidth - clientWidth);
|
|
4479
|
+
this.cachedMaxTop = maxTop;
|
|
4480
|
+
this.cachedMaxLeft = maxLeft;
|
|
3807
4481
|
let targetTop;
|
|
3808
4482
|
let targetLeft;
|
|
3809
4483
|
if (typeof target === "number") {
|
|
@@ -3817,19 +4491,19 @@ var __WulfIIFE = (() => {
|
|
|
3817
4491
|
targetTop = maxTop;
|
|
3818
4492
|
break;
|
|
3819
4493
|
case "left":
|
|
3820
|
-
targetLeft = 0;
|
|
4494
|
+
targetLeft = rtl ? -maxLeft : 0;
|
|
3821
4495
|
break;
|
|
3822
4496
|
case "right":
|
|
3823
|
-
targetLeft = maxLeft;
|
|
4497
|
+
targetLeft = rtl ? 0 : maxLeft;
|
|
3824
4498
|
break;
|
|
3825
4499
|
default: {
|
|
3826
4500
|
if (/^-?\d+(\.\d+)?%$/.test(target.trim())) {
|
|
3827
4501
|
const pct = Math.max(0, Math.min(100, parseFloat(target.trim()))) / 100;
|
|
3828
4502
|
if (this.options.axis === "x") {
|
|
3829
|
-
targetLeft = maxLeft * pct;
|
|
4503
|
+
targetLeft = rtl ? -maxLeft * pct : maxLeft * pct;
|
|
3830
4504
|
} else if (this.options.axis === "both") {
|
|
3831
4505
|
targetTop = maxTop * pct;
|
|
3832
|
-
targetLeft = maxLeft * pct;
|
|
4506
|
+
targetLeft = rtl ? -maxLeft * pct : maxLeft * pct;
|
|
3833
4507
|
} else {
|
|
3834
4508
|
targetTop = maxTop * pct;
|
|
3835
4509
|
}
|
|
@@ -3842,24 +4516,82 @@ var __WulfIIFE = (() => {
|
|
|
3842
4516
|
el = null;
|
|
3843
4517
|
}
|
|
3844
4518
|
if (el) {
|
|
3845
|
-
|
|
3846
|
-
|
|
4519
|
+
const vpRect = this.viewport.getBoundingClientRect();
|
|
4520
|
+
const elRect = el.getBoundingClientRect();
|
|
4521
|
+
targetTop = elRect.top - vpRect.top + scrollTop;
|
|
4522
|
+
targetLeft = elRect.left - vpRect.left + scrollLeft;
|
|
3847
4523
|
}
|
|
3848
4524
|
break;
|
|
3849
4525
|
}
|
|
3850
4526
|
}
|
|
3851
4527
|
} else if (target instanceof HTMLElement) {
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
4528
|
+
const vpRect = this.viewport.getBoundingClientRect();
|
|
4529
|
+
const elRect = target.getBoundingClientRect();
|
|
4530
|
+
targetTop = elRect.top - vpRect.top + scrollTop;
|
|
4531
|
+
targetLeft = elRect.left - vpRect.left + scrollLeft;
|
|
4532
|
+
} else if (typeof target === "object" && target !== null) {
|
|
3855
4533
|
targetTop = target.top;
|
|
3856
4534
|
targetLeft = target.left;
|
|
3857
4535
|
}
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
4536
|
+
const clampedTop = targetTop !== void 0 && Number.isFinite(targetTop) ? Math.max(0, Math.min(maxTop, targetTop)) : void 0;
|
|
4537
|
+
const minLeftBound = rtl ? -maxLeft : 0;
|
|
4538
|
+
const maxLeftBound = rtl ? 0 : maxLeft;
|
|
4539
|
+
const clampedLeft = targetLeft !== void 0 && Number.isFinite(targetLeft) ? Math.max(minLeftBound, Math.min(maxLeftBound, targetLeft)) : void 0;
|
|
4540
|
+
const destTop = clampedTop ?? scrollTop;
|
|
4541
|
+
const destLeft = clampedLeft ?? scrollLeft;
|
|
4542
|
+
if (Math.abs(destTop - scrollTop) <= 1 && Math.abs(destLeft - scrollLeft) <= 1) {
|
|
4543
|
+
return Promise.resolve();
|
|
4544
|
+
}
|
|
4545
|
+
this.activeScrollToController?.abort();
|
|
4546
|
+
const waitController = new AbortController();
|
|
4547
|
+
this.activeScrollToController = waitController;
|
|
4548
|
+
const nativeResult = this.viewport.scrollTo({
|
|
4549
|
+
top: clampedTop,
|
|
4550
|
+
left: clampedLeft,
|
|
3861
4551
|
behavior
|
|
3862
4552
|
});
|
|
4553
|
+
if (nativeResult instanceof Promise) {
|
|
4554
|
+
return nativeResult.then(() => {
|
|
4555
|
+
if (this.activeScrollToController === waitController) {
|
|
4556
|
+
this.activeScrollToController = void 0;
|
|
4557
|
+
}
|
|
4558
|
+
});
|
|
4559
|
+
}
|
|
4560
|
+
if (behavior !== "smooth") {
|
|
4561
|
+
if (this.activeScrollToController === waitController) {
|
|
4562
|
+
this.activeScrollToController = void 0;
|
|
4563
|
+
}
|
|
4564
|
+
return Promise.resolve();
|
|
4565
|
+
}
|
|
4566
|
+
return new Promise((resolve) => {
|
|
4567
|
+
let settled = false;
|
|
4568
|
+
let idleTimerId;
|
|
4569
|
+
let maxTimerId;
|
|
4570
|
+
const finish = () => {
|
|
4571
|
+
if (settled) return;
|
|
4572
|
+
settled = true;
|
|
4573
|
+
if (idleTimerId !== void 0) window.clearTimeout(idleTimerId);
|
|
4574
|
+
if (maxTimerId !== void 0) window.clearTimeout(maxTimerId);
|
|
4575
|
+
if (this.activeScrollToController === waitController) {
|
|
4576
|
+
this.activeScrollToController = void 0;
|
|
4577
|
+
}
|
|
4578
|
+
waitController.abort();
|
|
4579
|
+
resolve();
|
|
4580
|
+
};
|
|
4581
|
+
waitController.signal.addEventListener("abort", finish, { once: true });
|
|
4582
|
+
this.abortController.signal.addEventListener("abort", finish, { once: true, signal: waitController.signal });
|
|
4583
|
+
if (this.supportsScrollEnd) {
|
|
4584
|
+
this.viewport.addEventListener("scrollend", finish, { once: true, signal: waitController.signal });
|
|
4585
|
+
} else {
|
|
4586
|
+
const bumpIdle = () => {
|
|
4587
|
+
if (idleTimerId !== void 0) window.clearTimeout(idleTimerId);
|
|
4588
|
+
idleTimerId = window.setTimeout(finish, 150);
|
|
4589
|
+
};
|
|
4590
|
+
this.viewport.addEventListener("scroll", bumpIdle, { passive: true, signal: waitController.signal });
|
|
4591
|
+
bumpIdle();
|
|
4592
|
+
}
|
|
4593
|
+
maxTimerId = window.setTimeout(finish, 2500);
|
|
4594
|
+
});
|
|
3863
4595
|
}
|
|
3864
4596
|
/**
|
|
3865
4597
|
* Vérifie la conformité d'accessibilité WAI-ARIA de la zone défilable
|
|
@@ -3872,12 +4604,12 @@ var __WulfIIFE = (() => {
|
|
|
3872
4604
|
const hasValidLabelledby = hasViewportLabelledby || hasRootLabelledby;
|
|
3873
4605
|
const rootAriaLabel = this.root.getAttribute("aria-label")?.trim();
|
|
3874
4606
|
const hasCustomViewportAriaLabel = !this.wasAriaLabelInferred && Boolean(this.viewport.getAttribute("aria-label")?.trim());
|
|
3875
|
-
if (!this.hasExplicitAriaLabel && !hasCustomViewportAriaLabel && !rootAriaLabel && !hasValidLabelledby) {
|
|
4607
|
+
if (!this.hasExplicitAriaLabel && !this.hasRootAriaLabel && !hasCustomViewportAriaLabel && !rootAriaLabel && !hasValidLabelledby) {
|
|
3876
4608
|
warnings.push(
|
|
3877
4609
|
"Libell\xE9 contextuel manquant : d\xE9finissez l'option ariaLabel (ou un attribut aria-label / aria-labelledby sur le conteneur) pour d\xE9crire la zone d\xE9filable (WCAG 4.1.2)."
|
|
3878
4610
|
);
|
|
3879
4611
|
}
|
|
3880
|
-
if (this.options.minThumbSize < 24) {
|
|
4612
|
+
if (this.options.mode !== "native" && this.options.minThumbSize < 24) {
|
|
3881
4613
|
warnings.push(
|
|
3882
4614
|
`Taille minimale du curseur insuffisante (minThumbSize: ${this.options.minThumbSize}px) : utilisez au moins 24px pour respecter WCAG 2.5.8.`
|
|
3883
4615
|
);
|
|
@@ -3894,22 +4626,34 @@ var __WulfIIFE = (() => {
|
|
|
3894
4626
|
* Détruit le composant et libère toutes les ressources.
|
|
3895
4627
|
*/
|
|
3896
4628
|
destroy() {
|
|
4629
|
+
if (this.isDestroyed) return;
|
|
4630
|
+
this.isDestroyed = true;
|
|
3897
4631
|
this.clearAutoHideTimer();
|
|
4632
|
+
if (this.scrollEndFallbackTimer !== void 0) {
|
|
4633
|
+
window.clearTimeout(this.scrollEndFallbackTimer);
|
|
4634
|
+
this.scrollEndFallbackTimer = void 0;
|
|
4635
|
+
}
|
|
4636
|
+
if (this.rafId !== null) {
|
|
4637
|
+
window.cancelAnimationFrame(this.rafId);
|
|
4638
|
+
this.rafId = null;
|
|
4639
|
+
}
|
|
4640
|
+
if (this.resizeRafId !== null) {
|
|
4641
|
+
window.cancelAnimationFrame(this.resizeRafId);
|
|
4642
|
+
this.resizeRafId = null;
|
|
4643
|
+
}
|
|
4644
|
+
this.activeScrollToController?.abort();
|
|
4645
|
+
this.activeScrollToController = void 0;
|
|
4646
|
+
this.dragAbortController?.abort();
|
|
4647
|
+
this.dragAbortController = void 0;
|
|
4648
|
+
this.abortController.abort();
|
|
3898
4649
|
if (this.resizeObserver) {
|
|
3899
4650
|
this.resizeObserver.disconnect();
|
|
3900
4651
|
}
|
|
3901
|
-
this.viewport.removeEventListener("scroll", this.boundOnScroll);
|
|
3902
|
-
this.root.removeEventListener("mouseenter", this.boundOnMouseEnter);
|
|
3903
|
-
this.root.removeEventListener("mouseleave", this.boundOnMouseLeave);
|
|
3904
|
-
this.root.removeEventListener("focusin", this.boundOnFocusIn);
|
|
3905
|
-
this.root.removeEventListener("focusout", this.boundOnFocusOut);
|
|
3906
|
-
window.removeEventListener("pointermove", this.boundPointerMove);
|
|
3907
|
-
window.removeEventListener("pointerup", this.boundPointerUp);
|
|
3908
|
-
window.removeEventListener("pointercancel", this.boundPointerUp);
|
|
3909
4652
|
this.trackY?.remove();
|
|
3910
4653
|
this.trackX?.remove();
|
|
3911
4654
|
this.root.classList.remove(
|
|
3912
4655
|
"wulf-scrollblock",
|
|
4656
|
+
"wulf-scrollblock--native",
|
|
3913
4657
|
"has-scroll-y",
|
|
3914
4658
|
"has-scroll-x",
|
|
3915
4659
|
"has-both-axes",
|
|
@@ -3920,7 +4664,7 @@ var __WulfIIFE = (() => {
|
|
|
3920
4664
|
);
|
|
3921
4665
|
if (this.createdViewport && this.viewport.parentElement === this.root) {
|
|
3922
4666
|
while (this.viewport.firstChild) {
|
|
3923
|
-
this.root
|
|
4667
|
+
safeMove(this.root, this.viewport.firstChild, this.viewport);
|
|
3924
4668
|
}
|
|
3925
4669
|
this.viewport.remove();
|
|
3926
4670
|
} else {
|
|
@@ -3931,14 +4675,15 @@ var __WulfIIFE = (() => {
|
|
|
3931
4675
|
if (this.wasRoleInferred && this.viewport.getAttribute("role") === "region") {
|
|
3932
4676
|
this.viewport.removeAttribute("role");
|
|
3933
4677
|
}
|
|
4678
|
+
if (this.propagatedRootLabel) {
|
|
4679
|
+
this.viewport.removeAttribute(this.propagatedRootLabel);
|
|
4680
|
+
}
|
|
3934
4681
|
if (this.wasAriaLabelInferred && this.viewport.getAttribute("aria-label") === this.lastInferredAriaLabel) {
|
|
3935
4682
|
this.viewport.removeAttribute("aria-label");
|
|
3936
4683
|
}
|
|
3937
4684
|
}
|
|
3938
4685
|
}
|
|
3939
4686
|
};
|
|
3940
|
-
ScrollBlock._i18n = scrollI18n;
|
|
3941
|
-
ScrollBlock.i18n = scrollI18n;
|
|
3942
4687
|
|
|
3943
4688
|
// src/scroll/index.ts
|
|
3944
4689
|
var Scroll = {
|
|
@@ -3946,11 +4691,9 @@ var __WulfIIFE = (() => {
|
|
|
3946
4691
|
i18n: scrollI18n
|
|
3947
4692
|
};
|
|
3948
4693
|
var scroll_default = ScrollBlock;
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
win.Wulf = wulfNamespace;
|
|
3953
|
-
wulfNamespace.Scroll = Scroll;
|
|
4694
|
+
var wulfNamespace2 = getSafeWulfNamespace();
|
|
4695
|
+
if (wulfNamespace2) {
|
|
4696
|
+
wulfNamespace2.Scroll = Scroll;
|
|
3954
4697
|
}
|
|
3955
4698
|
|
|
3956
4699
|
// src/masonry/index.ts
|
|
@@ -4045,11 +4788,13 @@ var __WulfIIFE = (() => {
|
|
|
4045
4788
|
return Math.min(maxCols, parsed);
|
|
4046
4789
|
}
|
|
4047
4790
|
}
|
|
4048
|
-
const
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4791
|
+
for (const cls of item.classList) {
|
|
4792
|
+
const match = /^(?:span|col-span)-(\d+)$/.exec(cls);
|
|
4793
|
+
if (match && match[1]) {
|
|
4794
|
+
const parsed = parseInt(match[1], 10);
|
|
4795
|
+
if (!isNaN(parsed) && parsed > 0) {
|
|
4796
|
+
return Math.min(maxCols, parsed);
|
|
4797
|
+
}
|
|
4053
4798
|
}
|
|
4054
4799
|
}
|
|
4055
4800
|
return 1;
|
|
@@ -4141,7 +4886,10 @@ var __WulfIIFE = (() => {
|
|
|
4141
4886
|
}
|
|
4142
4887
|
}
|
|
4143
4888
|
const itemW = span * colWidth + (span - 1) * gutterX;
|
|
4144
|
-
const
|
|
4889
|
+
const isRtl = typeof window !== "undefined" && typeof window.getComputedStyle === "function" && window.getComputedStyle(container).direction === "rtl";
|
|
4890
|
+
const effectiveWidth = fittedWidth !== void 0 ? fittedWidth : containerWidth;
|
|
4891
|
+
const rawX = targetCol * (colWidth + gutterX);
|
|
4892
|
+
const targetX = isRtl ? Math.max(0, effectiveWidth - rawX - itemW) : rawX;
|
|
4145
4893
|
positions.push({
|
|
4146
4894
|
element: item,
|
|
4147
4895
|
x: targetX,
|
|
@@ -4194,20 +4942,28 @@ var __WulfIIFE = (() => {
|
|
|
4194
4942
|
|
|
4195
4943
|
// src/masonry/Masonry.ts
|
|
4196
4944
|
var Masonry = class extends LocalizedComponent {
|
|
4945
|
+
static _i18n = masonryI18n;
|
|
4946
|
+
static i18n = masonryI18n;
|
|
4947
|
+
root;
|
|
4948
|
+
isNativeCSSGrid = false;
|
|
4949
|
+
_items = [];
|
|
4950
|
+
options;
|
|
4951
|
+
resizeObserver = null;
|
|
4952
|
+
itemResizeObserver = null;
|
|
4953
|
+
observedItems = /* @__PURE__ */ new Set();
|
|
4954
|
+
observedItemHeights = /* @__PURE__ */ new WeakMap();
|
|
4955
|
+
removingItems = /* @__PURE__ */ new WeakSet();
|
|
4956
|
+
layoutRafId = null;
|
|
4957
|
+
isDestroyed = false;
|
|
4958
|
+
wasRoleInferred = false;
|
|
4959
|
+
wasAriaLabelInferred = false;
|
|
4960
|
+
hasExplicitAriaLabel = false;
|
|
4961
|
+
lastInferredAriaLabel = "";
|
|
4962
|
+
abortController = new AbortController();
|
|
4963
|
+
watchedImages = /* @__PURE__ */ new WeakSet();
|
|
4964
|
+
originalContainerStyles;
|
|
4197
4965
|
constructor(target, options = {}) {
|
|
4198
4966
|
super(options.i18n);
|
|
4199
|
-
this.isNativeCSSGrid = false;
|
|
4200
|
-
this._items = [];
|
|
4201
|
-
this.resizeObserver = null;
|
|
4202
|
-
this.itemResizeObserver = null;
|
|
4203
|
-
this.layoutRafId = null;
|
|
4204
|
-
this.isDestroyed = false;
|
|
4205
|
-
this.wasRoleInferred = false;
|
|
4206
|
-
this.wasAriaLabelInferred = false;
|
|
4207
|
-
this.hasExplicitAriaLabel = false;
|
|
4208
|
-
this.lastInferredAriaLabel = "";
|
|
4209
|
-
this.removeTimers = /* @__PURE__ */ new Set();
|
|
4210
|
-
this.pendingImageListeners = [];
|
|
4211
4967
|
if (typeof target === "string") {
|
|
4212
4968
|
let el = null;
|
|
4213
4969
|
try {
|
|
@@ -4250,10 +5006,11 @@ var __WulfIIFE = (() => {
|
|
|
4250
5006
|
}),
|
|
4251
5007
|
audit: options.audit ?? true
|
|
4252
5008
|
};
|
|
4253
|
-
const supportsNativeCSS = typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("grid-template-rows", "masonry");
|
|
5009
|
+
const supportsNativeCSS = typeof CSS !== "undefined" && typeof CSS.supports === "function" && (CSS.supports("display", "grid-lanes") || CSS.supports("grid-template-rows", "masonry"));
|
|
4254
5010
|
if (this.options.useNativeCSSGrid && supportsNativeCSS) {
|
|
4255
5011
|
this.isNativeCSSGrid = true;
|
|
4256
5012
|
this.root.classList.add("wulf-masonry", "wulf-masonry--native");
|
|
5013
|
+
this.syncNativeGridVariables();
|
|
4257
5014
|
} else {
|
|
4258
5015
|
this.root.classList.add("wulf-masonry");
|
|
4259
5016
|
}
|
|
@@ -4277,7 +5034,7 @@ var __WulfIIFE = (() => {
|
|
|
4277
5034
|
this.wasRoleInferred = true;
|
|
4278
5035
|
}
|
|
4279
5036
|
const label = this.hasExplicitAriaLabel ? this.options.ariaLabel : this.t("gallery");
|
|
4280
|
-
if (label && !this.root.hasAttribute("aria-label")) {
|
|
5037
|
+
if (label && !this.root.hasAttribute("aria-label") && !this.root.hasAttribute("aria-labelledby")) {
|
|
4281
5038
|
this.root.setAttribute("aria-label", label);
|
|
4282
5039
|
this.lastInferredAriaLabel = label;
|
|
4283
5040
|
this.wasAriaLabelInferred = true;
|
|
@@ -4305,7 +5062,7 @@ var __WulfIIFE = (() => {
|
|
|
4305
5062
|
let durValue = "300ms";
|
|
4306
5063
|
if (typeof dur === "number" && Number.isFinite(dur) && dur >= 0) {
|
|
4307
5064
|
durValue = `${dur}ms`;
|
|
4308
|
-
} else if (typeof dur === "string" && /^\s
|
|
5065
|
+
} else if (typeof dur === "string" && /^\s*(?:\d+(?:\.\d+)?|\.\d+)(ms|s)\s*$/i.test(dur)) {
|
|
4309
5066
|
durValue = dur.trim();
|
|
4310
5067
|
}
|
|
4311
5068
|
this.root.style.setProperty("--wulf-masonry-duration", durValue);
|
|
@@ -4318,24 +5075,37 @@ var __WulfIIFE = (() => {
|
|
|
4318
5075
|
let matched = [];
|
|
4319
5076
|
if (this.options.itemSelector === "> *") {
|
|
4320
5077
|
matched = Array.from(this.root.children).filter(
|
|
4321
|
-
(el) => el instanceof HTMLElement && !el.hasAttribute("data-masonry-ignore")
|
|
5078
|
+
(el) => el instanceof HTMLElement && !el.hasAttribute("data-masonry-ignore") && !this.removingItems.has(el)
|
|
4322
5079
|
);
|
|
4323
5080
|
} else {
|
|
4324
5081
|
try {
|
|
4325
|
-
|
|
4326
|
-
|
|
5082
|
+
const rawSelector = this.options.itemSelector.trim();
|
|
5083
|
+
const selector = rawSelector.startsWith(">") ? `:scope ${rawSelector}` : rawSelector;
|
|
5084
|
+
matched = Array.from(this.root.querySelectorAll(selector)).filter(
|
|
5085
|
+
(el) => el.parentElement === this.root && !el.hasAttribute("data-masonry-ignore") && !this.removingItems.has(el)
|
|
4327
5086
|
);
|
|
4328
5087
|
} catch {
|
|
4329
5088
|
matched = Array.from(this.root.children).filter(
|
|
4330
|
-
(el) => el instanceof HTMLElement && !el.hasAttribute("data-masonry-ignore")
|
|
5089
|
+
(el) => el instanceof HTMLElement && !el.hasAttribute("data-masonry-ignore") && !this.removingItems.has(el)
|
|
4331
5090
|
);
|
|
4332
5091
|
}
|
|
4333
5092
|
}
|
|
5093
|
+
if (this.itemResizeObserver) {
|
|
5094
|
+
const nextSet = new Set(matched);
|
|
5095
|
+
for (const prevEl of this.observedItems) {
|
|
5096
|
+
if (!nextSet.has(prevEl)) {
|
|
5097
|
+
this.itemResizeObserver.unobserve(prevEl);
|
|
5098
|
+
this.observedItems.delete(prevEl);
|
|
5099
|
+
this.observedItemHeights.delete(prevEl);
|
|
5100
|
+
}
|
|
5101
|
+
}
|
|
5102
|
+
}
|
|
4334
5103
|
this._items = matched;
|
|
4335
5104
|
for (const item of this._items) {
|
|
4336
5105
|
item.classList.add("wulf-masonry-item");
|
|
4337
|
-
if (this.itemResizeObserver) {
|
|
5106
|
+
if (this.itemResizeObserver && !this.observedItems.has(item)) {
|
|
4338
5107
|
this.itemResizeObserver.observe(item);
|
|
5108
|
+
this.observedItems.add(item);
|
|
4339
5109
|
}
|
|
4340
5110
|
}
|
|
4341
5111
|
}
|
|
@@ -4355,11 +5125,52 @@ var __WulfIIFE = (() => {
|
|
|
4355
5125
|
}
|
|
4356
5126
|
});
|
|
4357
5127
|
this.resizeObserver.observe(this.root);
|
|
4358
|
-
this.itemResizeObserver = new ResizeObserver(() => {
|
|
4359
|
-
|
|
5128
|
+
this.itemResizeObserver = new ResizeObserver((entries) => {
|
|
5129
|
+
let heightChanged = false;
|
|
5130
|
+
for (const entry of entries) {
|
|
5131
|
+
const newH = entry.borderBoxSize?.[0]?.blockSize ?? entry.contentRect.height;
|
|
5132
|
+
const prevH = this.observedItemHeights.get(entry.target);
|
|
5133
|
+
if (prevH === void 0 || Math.abs(newH - prevH) >= 1) {
|
|
5134
|
+
this.observedItemHeights.set(entry.target, newH);
|
|
5135
|
+
if (prevH !== void 0) {
|
|
5136
|
+
heightChanged = true;
|
|
5137
|
+
}
|
|
5138
|
+
}
|
|
5139
|
+
}
|
|
5140
|
+
if (heightChanged) {
|
|
5141
|
+
this.scheduleLayout();
|
|
5142
|
+
}
|
|
4360
5143
|
});
|
|
4361
5144
|
for (const item of this._items) {
|
|
4362
5145
|
this.itemResizeObserver.observe(item);
|
|
5146
|
+
this.observedItems.add(item);
|
|
5147
|
+
}
|
|
5148
|
+
}
|
|
5149
|
+
/**
|
|
5150
|
+
* Synchronise les variables CSS du mode natif CSS Grid Level 3 depuis les options JS.
|
|
5151
|
+
*/
|
|
5152
|
+
syncNativeGridVariables() {
|
|
5153
|
+
const { x: gutterX, y: gutterY } = LayoutEngine.parseGutter(this.options.gutter);
|
|
5154
|
+
this.root.style.setProperty("--wulf-masonry-gutter-x", `${gutterX}px`);
|
|
5155
|
+
this.root.style.setProperty("--wulf-masonry-gutter-y", `${gutterY}px`);
|
|
5156
|
+
if (typeof this.options.columnWidth === "number" && Number.isFinite(this.options.columnWidth) && this.options.columnWidth > 0) {
|
|
5157
|
+
this.root.style.setProperty("--wulf-masonry-col-min", `${this.options.columnWidth}px`);
|
|
5158
|
+
} else if (this.options.columnWidth instanceof HTMLElement) {
|
|
5159
|
+
const w = this.options.columnWidth.getBoundingClientRect().width;
|
|
5160
|
+
if (w > 0) {
|
|
5161
|
+
this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
|
|
5162
|
+
}
|
|
5163
|
+
} else if (typeof this.options.columnWidth === "string" && this.options.columnWidth.trim()) {
|
|
5164
|
+
try {
|
|
5165
|
+
const el = this.root.querySelector(this.options.columnWidth);
|
|
5166
|
+
if (el) {
|
|
5167
|
+
const w = el.getBoundingClientRect().width;
|
|
5168
|
+
if (w > 0) {
|
|
5169
|
+
this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
|
|
5170
|
+
}
|
|
5171
|
+
}
|
|
5172
|
+
} catch {
|
|
5173
|
+
}
|
|
4363
5174
|
}
|
|
4364
5175
|
}
|
|
4365
5176
|
/**
|
|
@@ -4369,14 +5180,12 @@ var __WulfIIFE = (() => {
|
|
|
4369
5180
|
if (!this.options.autoImages) return;
|
|
4370
5181
|
const images = Array.from(this.root.querySelectorAll("img"));
|
|
4371
5182
|
for (const img of images) {
|
|
4372
|
-
if (!img.complete) {
|
|
5183
|
+
if (!img.complete && !this.watchedImages.has(img)) {
|
|
5184
|
+
this.watchedImages.add(img);
|
|
4373
5185
|
const attachLoadListener = () => {
|
|
4374
|
-
|
|
4375
|
-
this.pendingImageListeners = this.pendingImageListeners.filter((l) => l.handler !== onLoad);
|
|
5186
|
+
img.addEventListener("load", () => {
|
|
4376
5187
|
if (!this.isDestroyed) this.scheduleLayout();
|
|
4377
|
-
};
|
|
4378
|
-
this.pendingImageListeners.push({ img, handler: onLoad });
|
|
4379
|
-
img.addEventListener("load", onLoad, { once: true });
|
|
5188
|
+
}, { once: true, signal: this.abortController.signal });
|
|
4380
5189
|
};
|
|
4381
5190
|
if (typeof img.decode === "function") {
|
|
4382
5191
|
img.decode().then(() => {
|
|
@@ -4410,10 +5219,17 @@ var __WulfIIFE = (() => {
|
|
|
4410
5219
|
if (this.isDestroyed) return;
|
|
4411
5220
|
this.syncAccessibilityLabels();
|
|
4412
5221
|
if (this.isNativeCSSGrid) {
|
|
5222
|
+
this.syncNativeGridVariables();
|
|
5223
|
+
for (const el of this._items) {
|
|
5224
|
+
el.classList.remove("wulf-masonry-item--hidden");
|
|
5225
|
+
}
|
|
4413
5226
|
this.options.onLayout([]);
|
|
4414
5227
|
return;
|
|
4415
5228
|
}
|
|
4416
5229
|
this.root.setAttribute("aria-busy", "true");
|
|
5230
|
+
if (this.options.fitWidth && this.root.classList.contains("wulf-masonry--fit-width")) {
|
|
5231
|
+
this.root.style.width = "";
|
|
5232
|
+
}
|
|
4417
5233
|
const result = LayoutEngine.calculate(this.root, this._items, this.options);
|
|
4418
5234
|
this.root.style.height = `${result.containerHeight}px`;
|
|
4419
5235
|
if (this.options.fitWidth && result.fittedWidth !== void 0) {
|
|
@@ -4423,6 +5239,14 @@ var __WulfIIFE = (() => {
|
|
|
4423
5239
|
this.root.classList.remove("wulf-masonry--fit-width");
|
|
4424
5240
|
}
|
|
4425
5241
|
const stagger = this.options.stagger;
|
|
5242
|
+
const validStagger = typeof stagger === "number" && Number.isFinite(stagger) && stagger > 0;
|
|
5243
|
+
if (validStagger) {
|
|
5244
|
+
this.root.style.setProperty("--wulf-masonry-stagger", `${stagger}ms`);
|
|
5245
|
+
} else {
|
|
5246
|
+
this.root.style.removeProperty("--wulf-masonry-stagger");
|
|
5247
|
+
}
|
|
5248
|
+
const hasIgnoredChildren = this._items.length !== this.root.children.length;
|
|
5249
|
+
const supportsSiblingIndex = !hasIgnoredChildren && typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("transition-delay", "calc(sibling-index() * 1ms)");
|
|
4426
5250
|
const usePercent = this.options.percentPosition && result.containerWidth > 0;
|
|
4427
5251
|
for (let i = 0; i < result.positions.length; i++) {
|
|
4428
5252
|
const pos = result.positions[i];
|
|
@@ -4435,12 +5259,13 @@ var __WulfIIFE = (() => {
|
|
|
4435
5259
|
}
|
|
4436
5260
|
item.style.setProperty("--wulf-masonry-x", `${pos.x}px`);
|
|
4437
5261
|
item.style.setProperty("--wulf-masonry-y", `${pos.y}px`);
|
|
4438
|
-
if (
|
|
4439
|
-
item.style.
|
|
5262
|
+
if (validStagger && !supportsSiblingIndex) {
|
|
5263
|
+
item.style.setProperty("--wulf-masonry-index", String(i));
|
|
4440
5264
|
} else {
|
|
4441
|
-
item.style.removeProperty("
|
|
5265
|
+
item.style.removeProperty("--wulf-masonry-index");
|
|
4442
5266
|
}
|
|
4443
5267
|
item.classList.remove("wulf-masonry-item--hidden");
|
|
5268
|
+
this.observedItemHeights.set(item, pos.height);
|
|
4444
5269
|
this.options.onItemPlaced(item, pos);
|
|
4445
5270
|
}
|
|
4446
5271
|
this.root.setAttribute("aria-busy", "false");
|
|
@@ -4455,7 +5280,11 @@ var __WulfIIFE = (() => {
|
|
|
4455
5280
|
if (list.length === 0) return;
|
|
4456
5281
|
const frag = document.createDocumentFragment();
|
|
4457
5282
|
for (const el of list) {
|
|
4458
|
-
|
|
5283
|
+
if (this.isNativeCSSGrid) {
|
|
5284
|
+
el.classList.add("wulf-masonry-item");
|
|
5285
|
+
} else {
|
|
5286
|
+
el.classList.add("wulf-masonry-item", "wulf-masonry-item--hidden");
|
|
5287
|
+
}
|
|
4459
5288
|
frag.appendChild(el);
|
|
4460
5289
|
}
|
|
4461
5290
|
this.root.appendChild(frag);
|
|
@@ -4473,7 +5302,11 @@ var __WulfIIFE = (() => {
|
|
|
4473
5302
|
const first = this.root.firstChild;
|
|
4474
5303
|
const frag = document.createDocumentFragment();
|
|
4475
5304
|
for (const el of list) {
|
|
4476
|
-
|
|
5305
|
+
if (this.isNativeCSSGrid) {
|
|
5306
|
+
el.classList.add("wulf-masonry-item");
|
|
5307
|
+
} else {
|
|
5308
|
+
el.classList.add("wulf-masonry-item", "wulf-masonry-item--hidden");
|
|
5309
|
+
}
|
|
4477
5310
|
frag.appendChild(el);
|
|
4478
5311
|
}
|
|
4479
5312
|
this.root.insertBefore(frag, first);
|
|
@@ -4482,44 +5315,51 @@ var __WulfIIFE = (() => {
|
|
|
4482
5315
|
this.layout();
|
|
4483
5316
|
}
|
|
4484
5317
|
/**
|
|
4485
|
-
* Supprime des éléments avec animation de fondu/sortie.
|
|
5318
|
+
* Supprime des éléments avec animation de fondu/sortie synchronisée via Web Animations API.
|
|
4486
5319
|
*/
|
|
4487
5320
|
remove(elements) {
|
|
4488
5321
|
if (this.isDestroyed) return;
|
|
4489
5322
|
const list = Array.isArray(elements) ? elements : [elements];
|
|
4490
5323
|
if (list.length === 0) return;
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
}
|
|
4494
|
-
const dur = typeof this.options.transitionDuration === "number" ? this.options.transitionDuration : 300;
|
|
4495
|
-
if (dur <= 0) {
|
|
5324
|
+
const finalizeRemoval = () => {
|
|
5325
|
+
if (this.isDestroyed) return;
|
|
4496
5326
|
for (const el of list) {
|
|
5327
|
+
this.removingItems.delete(el);
|
|
4497
5328
|
if (el.parentElement === this.root) {
|
|
4498
5329
|
if (this.itemResizeObserver) {
|
|
4499
5330
|
this.itemResizeObserver.unobserve(el);
|
|
5331
|
+
this.observedItems.delete(el);
|
|
5332
|
+
this.observedItemHeights.delete(el);
|
|
4500
5333
|
}
|
|
4501
5334
|
this.root.removeChild(el);
|
|
4502
5335
|
}
|
|
4503
5336
|
}
|
|
4504
5337
|
this.reloadItems();
|
|
4505
5338
|
this.layout();
|
|
5339
|
+
};
|
|
5340
|
+
for (const el of list) {
|
|
5341
|
+
this.removingItems.add(el);
|
|
5342
|
+
if (typeof document !== "undefined" && document.activeElement && el.contains(document.activeElement)) {
|
|
5343
|
+
document.activeElement.blur?.();
|
|
5344
|
+
}
|
|
5345
|
+
el.setAttribute("inert", "");
|
|
5346
|
+
el.style.transitionDelay = "0ms";
|
|
5347
|
+
el.classList.add("wulf-masonry-item--hidden");
|
|
5348
|
+
}
|
|
5349
|
+
const dur = parseCssDurationMs(this.options.transitionDuration, 300);
|
|
5350
|
+
if (dur <= 0 || this.isNativeCSSGrid) {
|
|
5351
|
+
finalizeRemoval();
|
|
4506
5352
|
return;
|
|
4507
5353
|
}
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
}
|
|
4516
|
-
this.root.removeChild(el);
|
|
4517
|
-
}
|
|
5354
|
+
this.reloadItems();
|
|
5355
|
+
this.layout();
|
|
5356
|
+
Promise.all(
|
|
5357
|
+
list.map((el) => waitForAnimations(el, dur, this.abortController.signal))
|
|
5358
|
+
).then(() => {
|
|
5359
|
+
if (!this.abortController.signal.aborted) {
|
|
5360
|
+
finalizeRemoval();
|
|
4518
5361
|
}
|
|
4519
|
-
|
|
4520
|
-
this.layout();
|
|
4521
|
-
}, dur);
|
|
4522
|
-
this.removeTimers.add(timerId);
|
|
5362
|
+
});
|
|
4523
5363
|
}
|
|
4524
5364
|
/**
|
|
4525
5365
|
* Vérifie la conformité d'accessibilité WAI-ARIA de la grille Masonry
|
|
@@ -4556,14 +5396,7 @@ var __WulfIIFE = (() => {
|
|
|
4556
5396
|
destroy() {
|
|
4557
5397
|
if (this.isDestroyed) return;
|
|
4558
5398
|
this.isDestroyed = true;
|
|
4559
|
-
|
|
4560
|
-
clearTimeout(timerId);
|
|
4561
|
-
}
|
|
4562
|
-
this.removeTimers.clear();
|
|
4563
|
-
for (const { img, handler } of this.pendingImageListeners) {
|
|
4564
|
-
img.removeEventListener("load", handler);
|
|
4565
|
-
}
|
|
4566
|
-
this.pendingImageListeners = [];
|
|
5399
|
+
this.abortController.abort();
|
|
4567
5400
|
if (this.layoutRafId !== null) {
|
|
4568
5401
|
cancelAnimationFrame(this.layoutRafId);
|
|
4569
5402
|
this.layoutRafId = null;
|
|
@@ -4585,6 +5418,10 @@ var __WulfIIFE = (() => {
|
|
|
4585
5418
|
this.root.removeAttribute("aria-label");
|
|
4586
5419
|
}
|
|
4587
5420
|
this.root.style.removeProperty("--wulf-masonry-duration");
|
|
5421
|
+
this.root.style.removeProperty("--wulf-masonry-stagger");
|
|
5422
|
+
this.root.style.removeProperty("--wulf-masonry-col-min");
|
|
5423
|
+
this.root.style.removeProperty("--wulf-masonry-gutter-x");
|
|
5424
|
+
this.root.style.removeProperty("--wulf-masonry-gutter-y");
|
|
4588
5425
|
if (this.originalContainerStyles.height) {
|
|
4589
5426
|
this.root.style.height = this.originalContainerStyles.height;
|
|
4590
5427
|
} else {
|
|
@@ -4600,21 +5437,17 @@ var __WulfIIFE = (() => {
|
|
|
4600
5437
|
item.style.removeProperty("--wulf-masonry-w");
|
|
4601
5438
|
item.style.removeProperty("--wulf-masonry-x");
|
|
4602
5439
|
item.style.removeProperty("--wulf-masonry-y");
|
|
4603
|
-
item.style.removeProperty("
|
|
5440
|
+
item.style.removeProperty("--wulf-masonry-index");
|
|
4604
5441
|
}
|
|
4605
5442
|
this._items = [];
|
|
4606
5443
|
}
|
|
4607
5444
|
};
|
|
4608
|
-
Masonry._i18n = masonryI18n;
|
|
4609
|
-
Masonry.i18n = masonryI18n;
|
|
4610
5445
|
|
|
4611
5446
|
// src/masonry/index.ts
|
|
4612
5447
|
var masonry_default = Masonry;
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
win.Wulf = wulfNamespace;
|
|
4617
|
-
wulfNamespace.Masonry = Object.assign(Masonry, {
|
|
5448
|
+
var wulfNamespace3 = getSafeWulfNamespace();
|
|
5449
|
+
if (wulfNamespace3) {
|
|
5450
|
+
wulfNamespace3.Masonry = Object.assign(Masonry, {
|
|
4618
5451
|
Masonry,
|
|
4619
5452
|
LayoutEngine,
|
|
4620
5453
|
i18n: masonryI18n
|
|
@@ -4637,12 +5470,14 @@ var __WulfIIFE = (() => {
|
|
|
4637
5470
|
|
|
4638
5471
|
// src/toast/i18n/fr.ts
|
|
4639
5472
|
var toastFr = {
|
|
4640
|
-
closeButton: "Fermer la notification"
|
|
5473
|
+
closeButton: "Fermer la notification",
|
|
5474
|
+
notificationsRegion: "Notifications"
|
|
4641
5475
|
};
|
|
4642
5476
|
|
|
4643
5477
|
// src/toast/i18n/en.ts
|
|
4644
5478
|
var toastEn = {
|
|
4645
|
-
closeButton: "Close notification"
|
|
5479
|
+
closeButton: "Close notification",
|
|
5480
|
+
notificationsRegion: "Notifications"
|
|
4646
5481
|
};
|
|
4647
5482
|
|
|
4648
5483
|
// src/toast/i18n/index.ts
|
|
@@ -4653,29 +5488,54 @@ var __WulfIIFE = (() => {
|
|
|
4653
5488
|
|
|
4654
5489
|
// src/toast/ToastInstance.ts
|
|
4655
5490
|
var nextToastId = 1;
|
|
5491
|
+
var DEFAULT_TOAST_DURATION = 5e3;
|
|
4656
5492
|
function isSafeCssValue(val) {
|
|
4657
5493
|
if (!val || typeof val !== "string" || val.length > 128) return false;
|
|
4658
|
-
|
|
5494
|
+
const trimmed = val.trim();
|
|
5495
|
+
if (!trimmed) return false;
|
|
5496
|
+
if (/[\u0000-\u001F\u007F;{}<>\\]|(?:url|image-set|-webkit-image-set|image|src|expression|attr|env)\s*\(/i.test(trimmed)) {
|
|
5497
|
+
return false;
|
|
5498
|
+
}
|
|
5499
|
+
if (typeof CSS !== "undefined" && typeof CSS.supports === "function") {
|
|
5500
|
+
return CSS.supports("color", trimmed) || CSS.supports("background-color", trimmed);
|
|
5501
|
+
}
|
|
5502
|
+
return true;
|
|
4659
5503
|
}
|
|
4660
5504
|
function sanitizeIconClasses(icon) {
|
|
4661
|
-
return icon.trim().split(/\s+/).filter((token) => /^[a-zA-Z0-9_-]+$/.test(token) && !token.startsWith("wulf-toast")).slice(0, 8).join(" ");
|
|
5505
|
+
return icon.slice(0, 128).trim().split(/\s+/).filter((token) => /^[a-zA-Z0-9_-]+$/.test(token) && !token.startsWith("wulf-toast")).slice(0, 8).join(" ");
|
|
4662
5506
|
}
|
|
4663
5507
|
var ToastInstance = class extends AuditableComponent {
|
|
5508
|
+
id;
|
|
5509
|
+
options;
|
|
5510
|
+
element;
|
|
5511
|
+
_isClosed = false;
|
|
5512
|
+
_isFinalized = false;
|
|
5513
|
+
closePromise = null;
|
|
5514
|
+
timerId = null;
|
|
5515
|
+
remainingTime = 0;
|
|
5516
|
+
hasDuration = false;
|
|
5517
|
+
timerStartTime = 0;
|
|
5518
|
+
isPausedByHover = false;
|
|
5519
|
+
isPausedByFocus = false;
|
|
5520
|
+
isPausedByVisibility = false;
|
|
5521
|
+
isPendingFocusDismiss = false;
|
|
5522
|
+
previousActiveElement = null;
|
|
5523
|
+
eventsAbortController = new AbortController();
|
|
5524
|
+
disposeAbortController = new AbortController();
|
|
5525
|
+
onDismissCallback;
|
|
4664
5526
|
constructor(options, onDismiss) {
|
|
4665
5527
|
super();
|
|
4666
|
-
this._isClosed = false;
|
|
4667
|
-
this.timerId = null;
|
|
4668
|
-
this.remainingTime = 0;
|
|
4669
|
-
this.timerStartTime = 0;
|
|
4670
|
-
this.isPaused = false;
|
|
4671
5528
|
this.id = `wulf-toast-${nextToastId++}`;
|
|
4672
5529
|
this.options = Object.freeze({ ...options });
|
|
4673
5530
|
this.onDismissCallback = onDismiss;
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
5531
|
+
this.previousActiveElement = typeof document !== "undefined" && document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
5532
|
+
const duration = options.duration === void 0 ? DEFAULT_TOAST_DURATION : options.duration;
|
|
5533
|
+
if (typeof duration === "number" && Number.isFinite(duration) && duration > 0) {
|
|
5534
|
+
this.remainingTime = Math.min(duration, 2147483647);
|
|
5535
|
+
this.hasDuration = true;
|
|
4677
5536
|
} else {
|
|
4678
5537
|
this.remainingTime = 0;
|
|
5538
|
+
this.hasDuration = false;
|
|
4679
5539
|
}
|
|
4680
5540
|
this.element = this.createDOM();
|
|
4681
5541
|
this.bindEvents();
|
|
@@ -4684,6 +5544,9 @@ var __WulfIIFE = (() => {
|
|
|
4684
5544
|
get isClosed() {
|
|
4685
5545
|
return this._isClosed;
|
|
4686
5546
|
}
|
|
5547
|
+
getPreviousActiveElement() {
|
|
5548
|
+
return this.previousActiveElement;
|
|
5549
|
+
}
|
|
4687
5550
|
/**
|
|
4688
5551
|
* Vérifie la conformité d'accessibilité WAI-ARIA de la notification Toast
|
|
4689
5552
|
* et retourne la liste des contraintes manquantes.
|
|
@@ -4697,7 +5560,7 @@ var __WulfIIFE = (() => {
|
|
|
4697
5560
|
"Contenu textuel vide : d\xE9finissez au moins un title ou un message pour que le lecteur d'\xE9cran puisse annoncer la notification (WCAG 4.1.3)."
|
|
4698
5561
|
);
|
|
4699
5562
|
}
|
|
4700
|
-
const duration = this.options.duration === void 0 ?
|
|
5563
|
+
const duration = this.options.duration === void 0 ? DEFAULT_TOAST_DURATION : this.options.duration;
|
|
4701
5564
|
if (typeof duration === "number" && duration > 0 && duration < 5e3) {
|
|
4702
5565
|
warnings.push(
|
|
4703
5566
|
`Dur\xE9e d'affichage trop courte (duration: ${duration}ms) : pr\xE9voyez au moins 5000ms ou duration: false pour laisser le temps de lecture aux utilisateurs (WCAG 2.2.1).`
|
|
@@ -4705,9 +5568,9 @@ var __WulfIIFE = (() => {
|
|
|
4705
5568
|
}
|
|
4706
5569
|
const closable = this.options.closable ?? true;
|
|
4707
5570
|
const isPersistent = duration === false || typeof duration === "number" && duration <= 0;
|
|
4708
|
-
if (isPersistent && !closable
|
|
5571
|
+
if (isPersistent && !closable) {
|
|
4709
5572
|
warnings.push(
|
|
4710
|
-
"Notification persistante impossible \xE0 fermer : activez closable: true
|
|
5573
|
+
"Notification persistante impossible \xE0 fermer au clavier : activez closable: true lorsque duration est d\xE9sactiv\xE9 (WCAG 2.1.1)."
|
|
4711
5574
|
);
|
|
4712
5575
|
}
|
|
4713
5576
|
return warnings;
|
|
@@ -4720,15 +5583,13 @@ var __WulfIIFE = (() => {
|
|
|
4720
5583
|
}
|
|
4721
5584
|
/**
|
|
4722
5585
|
* Construction du DOM de manière 100% sécurisée sans aucun `innerHTML`.
|
|
5586
|
+
* Les annonces sont gérées sur un canal unique dans `ToastManager` pour éviter tout doublon AT.
|
|
4723
5587
|
*/
|
|
4724
5588
|
createDOM() {
|
|
4725
5589
|
const el = document.createElement("div");
|
|
4726
5590
|
el.id = this.id;
|
|
4727
5591
|
el.className = "wulf-toast";
|
|
4728
|
-
|
|
4729
|
-
el.setAttribute("role", role);
|
|
4730
|
-
el.setAttribute("aria-live", role === "alert" ? "assertive" : "polite");
|
|
4731
|
-
el.setAttribute("aria-atomic", "true");
|
|
5592
|
+
el.setAttribute("data-toast-role", this.options.role === "alert" ? "alert" : "status");
|
|
4732
5593
|
if (this.options.backgroundColor && isSafeCssValue(this.options.backgroundColor)) {
|
|
4733
5594
|
el.style.setProperty("--wulf-toast-bg", this.options.backgroundColor.trim());
|
|
4734
5595
|
}
|
|
@@ -4774,7 +5635,6 @@ var __WulfIIFE = (() => {
|
|
|
4774
5635
|
closeBtn.type = "button";
|
|
4775
5636
|
closeBtn.className = "wulf-toast-close";
|
|
4776
5637
|
closeBtn.setAttribute("aria-label", toastI18n.t("closeButton", this.options.i18n));
|
|
4777
|
-
closeBtn.setAttribute("tabindex", "0");
|
|
4778
5638
|
const closeIcon = document.createElement("span");
|
|
4779
5639
|
closeIcon.className = "wulf-toast-close-icon";
|
|
4780
5640
|
closeIcon.setAttribute("aria-hidden", "true");
|
|
@@ -4783,7 +5643,7 @@ var __WulfIIFE = (() => {
|
|
|
4783
5643
|
closeBtn.addEventListener("click", (e) => {
|
|
4784
5644
|
e.stopPropagation();
|
|
4785
5645
|
this.close("close-button");
|
|
4786
|
-
});
|
|
5646
|
+
}, { signal: this.eventsAbortController.signal });
|
|
4787
5647
|
el.appendChild(closeBtn);
|
|
4788
5648
|
}
|
|
4789
5649
|
if (this.options.progressBar && this.remainingTime > 0) {
|
|
@@ -4797,7 +5657,6 @@ var __WulfIIFE = (() => {
|
|
|
4797
5657
|
}
|
|
4798
5658
|
/**
|
|
4799
5659
|
* Injection de texte sécurisée gérant nativement les retours à la ligne (\n et \r\n).
|
|
4800
|
-
* Utilise document.createTextNode et des éléments <br> créés proprement (plafonné contre le DoS DOM).
|
|
4801
5660
|
*/
|
|
4802
5661
|
appendTextWithLineBreaks(container, text) {
|
|
4803
5662
|
const safeText = String(text ?? "").slice(0, 4096);
|
|
@@ -4810,9 +5669,10 @@ var __WulfIIFE = (() => {
|
|
|
4810
5669
|
});
|
|
4811
5670
|
}
|
|
4812
5671
|
/**
|
|
4813
|
-
* Liaison des événements clavier, souris, et pause au survol
|
|
5672
|
+
* Liaison des événements clavier, souris, visibilité d'onglet et pause au survol/focus (WCAG 2.2).
|
|
4814
5673
|
*/
|
|
4815
5674
|
bindEvents() {
|
|
5675
|
+
const { signal } = this.eventsAbortController;
|
|
4816
5676
|
this.element.addEventListener("click", (e) => {
|
|
4817
5677
|
if (this.options.onClick) {
|
|
4818
5678
|
this.options.onClick(this, e);
|
|
@@ -4820,115 +5680,162 @@ var __WulfIIFE = (() => {
|
|
|
4820
5680
|
if (this.options.closeOnClick) {
|
|
4821
5681
|
this.close("toast-click");
|
|
4822
5682
|
}
|
|
4823
|
-
});
|
|
4824
|
-
this.element.addEventListener("mouseenter", () => this.pauseTimer());
|
|
4825
|
-
this.element.addEventListener("mouseleave", () => this.resumeTimer());
|
|
4826
|
-
this.element.addEventListener("focusin", () => this.pauseTimer());
|
|
4827
|
-
this.element.addEventListener("focusout", () =>
|
|
5683
|
+
}, { signal });
|
|
5684
|
+
this.element.addEventListener("mouseenter", () => this.pauseTimer("hover"), { signal });
|
|
5685
|
+
this.element.addEventListener("mouseleave", () => this.resumeTimer("hover"), { signal });
|
|
5686
|
+
this.element.addEventListener("focusin", () => this.pauseTimer("focus"), { signal });
|
|
5687
|
+
this.element.addEventListener("focusout", (e) => {
|
|
5688
|
+
const nextFocused = e.relatedTarget;
|
|
5689
|
+
if (nextFocused && this.element.contains(nextFocused)) {
|
|
5690
|
+
return;
|
|
5691
|
+
}
|
|
5692
|
+
if (this.isPendingFocusDismiss && !this._isClosed) {
|
|
5693
|
+
this.isPendingFocusDismiss = false;
|
|
5694
|
+
this.close("timeout");
|
|
5695
|
+
return;
|
|
5696
|
+
}
|
|
5697
|
+
this.resumeTimer("focus");
|
|
5698
|
+
}, { signal });
|
|
5699
|
+
this.element.addEventListener("keydown", (e) => {
|
|
5700
|
+
if (e.key === "Escape" && (this.options.closable ?? true)) {
|
|
5701
|
+
e.stopPropagation();
|
|
5702
|
+
this.close("close-button");
|
|
5703
|
+
}
|
|
5704
|
+
}, { signal });
|
|
5705
|
+
if (typeof document !== "undefined") {
|
|
5706
|
+
document.addEventListener("visibilitychange", () => {
|
|
5707
|
+
if (document.visibilityState === "hidden") {
|
|
5708
|
+
this.pauseTimer("visibility");
|
|
5709
|
+
} else {
|
|
5710
|
+
this.resumeTimer("visibility");
|
|
5711
|
+
}
|
|
5712
|
+
}, { signal });
|
|
5713
|
+
}
|
|
5714
|
+
}
|
|
5715
|
+
get isPaused() {
|
|
5716
|
+
return this.isPausedByHover || this.isPausedByFocus || this.isPausedByVisibility;
|
|
4828
5717
|
}
|
|
4829
5718
|
/**
|
|
4830
|
-
* Démarrage du compte à rebours de disparition automatique
|
|
5719
|
+
* Démarrage du compte à rebours de disparition automatique (horloge monotone).
|
|
4831
5720
|
*/
|
|
4832
5721
|
startTimer() {
|
|
4833
|
-
if (this._isClosed || this.remainingTime <= 0) return;
|
|
4834
|
-
|
|
5722
|
+
if (this._isClosed || this.remainingTime <= 0 || this.isPaused) return;
|
|
5723
|
+
if (typeof document !== "undefined" && document.visibilityState === "hidden") {
|
|
5724
|
+
this.isPausedByVisibility = true;
|
|
5725
|
+
this.element.classList.add("is-paused");
|
|
5726
|
+
return;
|
|
5727
|
+
}
|
|
5728
|
+
if (this.timerId !== null) {
|
|
5729
|
+
window.clearTimeout(this.timerId);
|
|
5730
|
+
this.timerId = null;
|
|
5731
|
+
}
|
|
5732
|
+
this.timerStartTime = performance.now();
|
|
4835
5733
|
this.timerId = window.setTimeout(() => {
|
|
5734
|
+
this.timerId = null;
|
|
5735
|
+
if (typeof document !== "undefined" && this.element.contains(document.activeElement)) {
|
|
5736
|
+
this.isPendingFocusDismiss = true;
|
|
5737
|
+
return;
|
|
5738
|
+
}
|
|
4836
5739
|
this.close("timeout");
|
|
4837
5740
|
}, this.remainingTime);
|
|
4838
5741
|
}
|
|
4839
5742
|
/**
|
|
4840
|
-
* Met en pause le compte à rebours (au survol ou
|
|
5743
|
+
* Met en pause le compte à rebours (au survol, au focus ou à la perte de visibilité d'onglet).
|
|
4841
5744
|
*/
|
|
4842
|
-
pauseTimer() {
|
|
4843
|
-
if (this._isClosed || this.remainingTime <= 0
|
|
5745
|
+
pauseTimer(source = "interaction") {
|
|
5746
|
+
if (this._isClosed || !this.hasDuration || this.remainingTime <= 0) return;
|
|
5747
|
+
const wasPaused = this.isPaused;
|
|
5748
|
+
if (source === "visibility") {
|
|
5749
|
+
this.isPausedByVisibility = true;
|
|
5750
|
+
} else if (source === "focus") {
|
|
5751
|
+
this.isPausedByFocus = true;
|
|
5752
|
+
} else {
|
|
5753
|
+
this.isPausedByHover = true;
|
|
5754
|
+
}
|
|
5755
|
+
if (wasPaused) return;
|
|
4844
5756
|
if (this.timerId !== null) {
|
|
4845
5757
|
window.clearTimeout(this.timerId);
|
|
4846
5758
|
this.timerId = null;
|
|
5759
|
+
const elapsed = performance.now() - this.timerStartTime;
|
|
5760
|
+
this.remainingTime = Math.max(0, this.remainingTime - elapsed);
|
|
4847
5761
|
}
|
|
4848
|
-
const elapsed = Date.now() - this.timerStartTime;
|
|
4849
|
-
this.remainingTime = Math.max(0, this.remainingTime - elapsed);
|
|
4850
|
-
this.isPaused = true;
|
|
4851
5762
|
this.element.classList.add("is-paused");
|
|
4852
5763
|
}
|
|
4853
5764
|
/**
|
|
4854
|
-
* Reprend le compte à rebours
|
|
5765
|
+
* Reprend le compte à rebours si aucune autre cause de pause n'est active.
|
|
4855
5766
|
*/
|
|
4856
|
-
resumeTimer() {
|
|
4857
|
-
if (this._isClosed ||
|
|
4858
|
-
|
|
5767
|
+
resumeTimer(source = "interaction") {
|
|
5768
|
+
if (this._isClosed || !this.hasDuration) return;
|
|
5769
|
+
if (source === "visibility") {
|
|
5770
|
+
this.isPausedByVisibility = false;
|
|
5771
|
+
} else if (source === "focus") {
|
|
5772
|
+
this.isPausedByFocus = false;
|
|
5773
|
+
} else if (source === "hover") {
|
|
5774
|
+
this.isPausedByHover = false;
|
|
5775
|
+
} else {
|
|
5776
|
+
this.isPausedByHover = false;
|
|
5777
|
+
this.isPausedByFocus = false;
|
|
5778
|
+
}
|
|
5779
|
+
if (this.isPaused) return;
|
|
4859
5780
|
this.element.classList.remove("is-paused");
|
|
5781
|
+
if (this.remainingTime <= 0) {
|
|
5782
|
+
this.close("timeout");
|
|
5783
|
+
return;
|
|
5784
|
+
}
|
|
4860
5785
|
this.startTimer();
|
|
4861
5786
|
}
|
|
5787
|
+
finalizeDismiss(reason) {
|
|
5788
|
+
if (this._isFinalized) return;
|
|
5789
|
+
this._isFinalized = true;
|
|
5790
|
+
this.eventsAbortController.abort();
|
|
5791
|
+
if (this.onDismissCallback) {
|
|
5792
|
+
this.onDismissCallback(this, reason);
|
|
5793
|
+
}
|
|
5794
|
+
if (this.element.parentNode) {
|
|
5795
|
+
this.element.parentNode.removeChild(this.element);
|
|
5796
|
+
}
|
|
5797
|
+
if (this.options.onClose) {
|
|
5798
|
+
this.options.onClose(this, reason);
|
|
5799
|
+
}
|
|
5800
|
+
}
|
|
4862
5801
|
/**
|
|
4863
|
-
* Déclenche la destruction immédiate sans animation
|
|
5802
|
+
* Déclenche la destruction immédiate sans animation.
|
|
4864
5803
|
*/
|
|
4865
5804
|
destroyImmediate(reason = "replace") {
|
|
4866
|
-
if (this._isClosed) return;
|
|
4867
5805
|
this._isClosed = true;
|
|
4868
5806
|
if (this.timerId !== null) {
|
|
4869
5807
|
window.clearTimeout(this.timerId);
|
|
4870
5808
|
this.timerId = null;
|
|
4871
5809
|
}
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
}
|
|
4875
|
-
if (this.onDismissCallback) {
|
|
4876
|
-
this.onDismissCallback(this, reason);
|
|
4877
|
-
}
|
|
4878
|
-
if (this.options.onClose) {
|
|
4879
|
-
this.options.onClose(this, reason);
|
|
4880
|
-
}
|
|
5810
|
+
this.disposeAbortController.abort();
|
|
5811
|
+
this.finalizeDismiss(reason);
|
|
4881
5812
|
}
|
|
4882
5813
|
/**
|
|
4883
5814
|
* Déclenche la fermeture propre et l'animation de sortie du toast.
|
|
4884
|
-
* Si fast = true, utilise une disparition accélérée
|
|
5815
|
+
* Si fast = true, utilise une disparition accélérée pour le remplacement séquentiel.
|
|
4885
5816
|
*/
|
|
4886
5817
|
close(reason = "programmatic", fast = false) {
|
|
4887
|
-
if (this._isClosed)
|
|
5818
|
+
if (this._isClosed) {
|
|
5819
|
+
return this.closePromise ?? Promise.resolve();
|
|
5820
|
+
}
|
|
4888
5821
|
this._isClosed = true;
|
|
4889
5822
|
if (this.timerId !== null) {
|
|
4890
5823
|
window.clearTimeout(this.timerId);
|
|
4891
5824
|
this.timerId = null;
|
|
4892
5825
|
}
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
this.options.onClose(this, reason);
|
|
4904
|
-
}
|
|
4905
|
-
resolve();
|
|
4906
|
-
};
|
|
4907
|
-
const isReducedMotion = typeof window !== "undefined" && window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
4908
|
-
if (isReducedMotion) {
|
|
4909
|
-
handleAnimationEnd();
|
|
4910
|
-
} else if (fast) {
|
|
4911
|
-
window.setTimeout(handleAnimationEnd, 90);
|
|
4912
|
-
} else {
|
|
4913
|
-
let transitioned = false;
|
|
4914
|
-
let fallbackTimerId = null;
|
|
4915
|
-
const onEnd = () => {
|
|
4916
|
-
if (!transitioned) {
|
|
4917
|
-
transitioned = true;
|
|
4918
|
-
if (fallbackTimerId !== null) {
|
|
4919
|
-
window.clearTimeout(fallbackTimerId);
|
|
4920
|
-
fallbackTimerId = null;
|
|
4921
|
-
}
|
|
4922
|
-
this.element.removeEventListener("animationend", onEnd);
|
|
4923
|
-
this.element.removeEventListener("transitionend", onEnd);
|
|
4924
|
-
handleAnimationEnd();
|
|
4925
|
-
}
|
|
4926
|
-
};
|
|
4927
|
-
this.element.addEventListener("animationend", onEnd, { once: true });
|
|
4928
|
-
this.element.addEventListener("transitionend", onEnd, { once: true });
|
|
4929
|
-
fallbackTimerId = window.setTimeout(onEnd, 300);
|
|
5826
|
+
this.eventsAbortController.abort();
|
|
5827
|
+
this.element.classList.add(fast ? "wulf-toast-hiding-fast" : "wulf-toast-hiding");
|
|
5828
|
+
if (prefersReducedMotion()) {
|
|
5829
|
+
this.finalizeDismiss(reason);
|
|
5830
|
+
this.closePromise = Promise.resolve();
|
|
5831
|
+
return this.closePromise;
|
|
5832
|
+
}
|
|
5833
|
+
this.closePromise = waitForAnimations(this.element, fast ? 90 : 300, this.disposeAbortController.signal).then(() => {
|
|
5834
|
+
if (!this.disposeAbortController.signal.aborted) {
|
|
5835
|
+
this.finalizeDismiss(reason);
|
|
4930
5836
|
}
|
|
4931
5837
|
});
|
|
5838
|
+
return this.closePromise;
|
|
4932
5839
|
}
|
|
4933
5840
|
};
|
|
4934
5841
|
|
|
@@ -4944,12 +5851,35 @@ var __WulfIIFE = (() => {
|
|
|
4944
5851
|
function normalizePosition(pos) {
|
|
4945
5852
|
return pos && VALID_POSITIONS.has(pos) ? pos : "top-right";
|
|
4946
5853
|
}
|
|
4947
|
-
var
|
|
5854
|
+
var FOCUSABLE_IN_TOAST = 'button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])';
|
|
5855
|
+
var ToastManager = class _ToastManager {
|
|
5856
|
+
static instance = null;
|
|
5857
|
+
containers = /* @__PURE__ */ new Map();
|
|
5858
|
+
activeToasts = /* @__PURE__ */ new Map();
|
|
5859
|
+
announcerEl = null;
|
|
5860
|
+
politeRegion = null;
|
|
5861
|
+
assertiveRegion = null;
|
|
5862
|
+
announceTimers = [];
|
|
5863
|
+
politeAnnounceTimerId = null;
|
|
5864
|
+
assertiveAnnounceTimerId = null;
|
|
5865
|
+
politeClearTimerId = null;
|
|
5866
|
+
assertiveClearTimerId = null;
|
|
5867
|
+
lastPoliteText = "";
|
|
5868
|
+
lastAssertiveText = "";
|
|
5869
|
+
announcerToggle = false;
|
|
5870
|
+
/**
|
|
5871
|
+
* Vérifie si un conteneur Popover est ouvert (compatible natif et polyfill OddBird).
|
|
5872
|
+
*/
|
|
5873
|
+
isPopoverOpen(container) {
|
|
5874
|
+
try {
|
|
5875
|
+
if (container.matches(":popover-open")) return true;
|
|
5876
|
+
} catch {
|
|
5877
|
+
}
|
|
5878
|
+
return container.classList.contains(":popover-open");
|
|
5879
|
+
}
|
|
5880
|
+
replaceTokens = /* @__PURE__ */ new Map();
|
|
5881
|
+
pendingReplacements = /* @__PURE__ */ new Set();
|
|
4948
5882
|
constructor() {
|
|
4949
|
-
this.containers = /* @__PURE__ */ new Map();
|
|
4950
|
-
this.activeToasts = /* @__PURE__ */ new Map();
|
|
4951
|
-
this.replaceTokens = /* @__PURE__ */ new Map();
|
|
4952
|
-
this.pendingReplacements = /* @__PURE__ */ new Set();
|
|
4953
5883
|
}
|
|
4954
5884
|
static getInstance() {
|
|
4955
5885
|
if (!_ToastManager.instance) {
|
|
@@ -4967,6 +5897,8 @@ var __WulfIIFE = (() => {
|
|
|
4967
5897
|
list = [];
|
|
4968
5898
|
this.activeToasts.set(position, list);
|
|
4969
5899
|
}
|
|
5900
|
+
const rawMax = toast.options.maxToasts;
|
|
5901
|
+
const maxToasts = typeof rawMax === "number" && Number.isFinite(rawMax) && rawMax > 0 ? Math.min(50, Math.max(1, Math.floor(rawMax))) : 5;
|
|
4970
5902
|
if (toast.options.replace && list.length > 0) {
|
|
4971
5903
|
const existing = [...list];
|
|
4972
5904
|
const token = (this.replaceTokens.get(position) || 0) + 1;
|
|
@@ -4976,14 +5908,17 @@ var __WulfIIFE = (() => {
|
|
|
4976
5908
|
Promise.all(promises).then(() => {
|
|
4977
5909
|
this.pendingReplacements.delete(position);
|
|
4978
5910
|
if (this.replaceTokens.get(position) !== token) {
|
|
5911
|
+
toast.destroyImmediate("replace");
|
|
4979
5912
|
return;
|
|
4980
5913
|
}
|
|
4981
|
-
this.mountToast(toast, position,
|
|
5914
|
+
this.mountToast(toast, position, maxToasts);
|
|
4982
5915
|
});
|
|
4983
5916
|
return;
|
|
4984
5917
|
}
|
|
4985
|
-
|
|
4986
|
-
|
|
5918
|
+
if (this.pendingReplacements.has(position)) {
|
|
5919
|
+
this.replaceTokens.set(position, (this.replaceTokens.get(position) || 0) + 1);
|
|
5920
|
+
this.pendingReplacements.delete(position);
|
|
5921
|
+
}
|
|
4987
5922
|
if (list.length >= maxToasts) {
|
|
4988
5923
|
const countToRemove = list.length - maxToasts + 1;
|
|
4989
5924
|
const oldestItems = list.splice(0, countToRemove);
|
|
@@ -4994,10 +5929,12 @@ var __WulfIIFE = (() => {
|
|
|
4994
5929
|
this.mountToast(toast, position, maxToasts);
|
|
4995
5930
|
}
|
|
4996
5931
|
/**
|
|
4997
|
-
* Insère l'élément toast dans le
|
|
5932
|
+
* Insère l'élément toast dans le conteneur Top Layer, annonce le message et démarre le minuteur.
|
|
4998
5933
|
*/
|
|
4999
5934
|
mountToast(toast, position, maxToasts = 5) {
|
|
5000
|
-
|
|
5935
|
+
if (toast.isClosed) return;
|
|
5936
|
+
const useTopLayer = toast.options.useTopLayer ?? true;
|
|
5937
|
+
const container = this.getOrCreateContainer(position, toast, useTopLayer);
|
|
5001
5938
|
let list = this.activeToasts.get(position);
|
|
5002
5939
|
if (!list) {
|
|
5003
5940
|
list = [];
|
|
@@ -5013,8 +5950,19 @@ var __WulfIIFE = (() => {
|
|
|
5013
5950
|
}
|
|
5014
5951
|
}
|
|
5015
5952
|
}
|
|
5953
|
+
if (useTopLayer && typeof container.showPopover === "function" && container.getAttribute("popover") === "manual") {
|
|
5954
|
+
try {
|
|
5955
|
+
const popoverEl = container;
|
|
5956
|
+
if (!this.isPopoverOpen(container)) {
|
|
5957
|
+
popoverEl.showPopover();
|
|
5958
|
+
}
|
|
5959
|
+
} catch {
|
|
5960
|
+
container.removeAttribute("popover");
|
|
5961
|
+
}
|
|
5962
|
+
}
|
|
5016
5963
|
container.appendChild(toast.element);
|
|
5017
5964
|
list.push(toast);
|
|
5965
|
+
this.announce(toast);
|
|
5018
5966
|
if (toast.options.onOpen) {
|
|
5019
5967
|
try {
|
|
5020
5968
|
toast.options.onOpen(toast);
|
|
@@ -5024,6 +5972,142 @@ var __WulfIIFE = (() => {
|
|
|
5024
5972
|
}
|
|
5025
5973
|
toast.startTimer();
|
|
5026
5974
|
}
|
|
5975
|
+
/**
|
|
5976
|
+
* Annonce la notification sur un canal unique pour éviter les doubles lectures AT.
|
|
5977
|
+
*/
|
|
5978
|
+
announce(toast) {
|
|
5979
|
+
const parts = [toast.options.title, toast.options.message].filter((val) => typeof val === "string" && val.trim().length > 0).map((val) => val.trim());
|
|
5980
|
+
if (parts.length === 0) return;
|
|
5981
|
+
const rawText = parts.join(". ");
|
|
5982
|
+
const text = rawText.length > 512 ? `${rawText.slice(0, 509)}...` : rawText;
|
|
5983
|
+
const isAlert = toast.options.role === "alert";
|
|
5984
|
+
const docWithAriaNotify = document;
|
|
5985
|
+
if (typeof docWithAriaNotify.ariaNotify === "function") {
|
|
5986
|
+
try {
|
|
5987
|
+
docWithAriaNotify.ariaNotify(text, { priority: isAlert ? "high" : "normal" });
|
|
5988
|
+
return;
|
|
5989
|
+
} catch {
|
|
5990
|
+
}
|
|
5991
|
+
}
|
|
5992
|
+
const wasCreated = !this.announcerEl || !this.announcerEl.isConnected;
|
|
5993
|
+
this.ensureAnnouncer();
|
|
5994
|
+
const region = isAlert ? this.assertiveRegion : this.politeRegion;
|
|
5995
|
+
if (!region) return;
|
|
5996
|
+
if (isAlert) {
|
|
5997
|
+
if (this.assertiveAnnounceTimerId !== null) {
|
|
5998
|
+
window.clearTimeout(this.assertiveAnnounceTimerId);
|
|
5999
|
+
this.assertiveAnnounceTimerId = null;
|
|
6000
|
+
}
|
|
6001
|
+
if (this.assertiveClearTimerId !== null) {
|
|
6002
|
+
window.clearTimeout(this.assertiveClearTimerId);
|
|
6003
|
+
this.assertiveClearTimerId = null;
|
|
6004
|
+
}
|
|
6005
|
+
} else {
|
|
6006
|
+
if (this.politeAnnounceTimerId !== null) {
|
|
6007
|
+
window.clearTimeout(this.politeAnnounceTimerId);
|
|
6008
|
+
this.politeAnnounceTimerId = null;
|
|
6009
|
+
}
|
|
6010
|
+
if (this.politeClearTimerId !== null) {
|
|
6011
|
+
window.clearTimeout(this.politeClearTimerId);
|
|
6012
|
+
this.politeClearTimerId = null;
|
|
6013
|
+
}
|
|
6014
|
+
}
|
|
6015
|
+
region.textContent = "";
|
|
6016
|
+
const lastText = isAlert ? this.lastAssertiveText : this.lastPoliteText;
|
|
6017
|
+
let finalMessage = text;
|
|
6018
|
+
if (text === lastText) {
|
|
6019
|
+
this.announcerToggle = !this.announcerToggle;
|
|
6020
|
+
finalMessage = this.announcerToggle ? `${text}\xA0` : text;
|
|
6021
|
+
} else {
|
|
6022
|
+
this.announcerToggle = false;
|
|
6023
|
+
}
|
|
6024
|
+
if (isAlert) {
|
|
6025
|
+
this.lastAssertiveText = text;
|
|
6026
|
+
} else {
|
|
6027
|
+
this.lastPoliteText = text;
|
|
6028
|
+
}
|
|
6029
|
+
const delay = wasCreated ? 120 : 50;
|
|
6030
|
+
const timerId = window.setTimeout(() => {
|
|
6031
|
+
const idx = this.announceTimers.indexOf(timerId);
|
|
6032
|
+
if (idx !== -1) this.announceTimers.splice(idx, 1);
|
|
6033
|
+
if (isAlert) {
|
|
6034
|
+
this.assertiveAnnounceTimerId = null;
|
|
6035
|
+
} else {
|
|
6036
|
+
this.politeAnnounceTimerId = null;
|
|
6037
|
+
}
|
|
6038
|
+
if (region.isConnected) {
|
|
6039
|
+
region.textContent = finalMessage;
|
|
6040
|
+
const clearId = window.setTimeout(() => {
|
|
6041
|
+
const cIdx = this.announceTimers.indexOf(clearId);
|
|
6042
|
+
if (cIdx !== -1) this.announceTimers.splice(cIdx, 1);
|
|
6043
|
+
if (region.isConnected && region.textContent === finalMessage) {
|
|
6044
|
+
region.textContent = "";
|
|
6045
|
+
}
|
|
6046
|
+
}, 4e3);
|
|
6047
|
+
this.announceTimers.push(clearId);
|
|
6048
|
+
if (isAlert) {
|
|
6049
|
+
this.assertiveClearTimerId = clearId;
|
|
6050
|
+
} else {
|
|
6051
|
+
this.politeClearTimerId = clearId;
|
|
6052
|
+
}
|
|
6053
|
+
}
|
|
6054
|
+
}, delay);
|
|
6055
|
+
this.announceTimers.push(timerId);
|
|
6056
|
+
if (isAlert) {
|
|
6057
|
+
this.assertiveAnnounceTimerId = timerId;
|
|
6058
|
+
} else {
|
|
6059
|
+
this.politeAnnounceTimerId = timerId;
|
|
6060
|
+
}
|
|
6061
|
+
}
|
|
6062
|
+
/**
|
|
6063
|
+
* Crée ou reconnecte le conteneur persistant des annonces ARIA hors du popover.
|
|
6064
|
+
*/
|
|
6065
|
+
ensureAnnouncer() {
|
|
6066
|
+
if (this.announcerEl && document.body.contains(this.announcerEl)) {
|
|
6067
|
+
return;
|
|
6068
|
+
}
|
|
6069
|
+
const wrapper = document.createElement("div");
|
|
6070
|
+
wrapper.className = "wulf-toast-announcer";
|
|
6071
|
+
wrapper.setAttribute("data-wulf-toast-announcer", "true");
|
|
6072
|
+
const polite = document.createElement("div");
|
|
6073
|
+
polite.setAttribute("role", "status");
|
|
6074
|
+
polite.setAttribute("aria-live", "polite");
|
|
6075
|
+
polite.setAttribute("aria-atomic", "true");
|
|
6076
|
+
const assertive = document.createElement("div");
|
|
6077
|
+
assertive.setAttribute("role", "alert");
|
|
6078
|
+
assertive.setAttribute("aria-live", "assertive");
|
|
6079
|
+
assertive.setAttribute("aria-atomic", "true");
|
|
6080
|
+
wrapper.appendChild(polite);
|
|
6081
|
+
wrapper.appendChild(assertive);
|
|
6082
|
+
document.body.appendChild(wrapper);
|
|
6083
|
+
this.announcerEl = wrapper;
|
|
6084
|
+
this.politeRegion = polite;
|
|
6085
|
+
this.assertiveRegion = assertive;
|
|
6086
|
+
}
|
|
6087
|
+
/**
|
|
6088
|
+
* Transfère le focus avant de retirer un toast focalisé pour éviter que le focus ne retombe sur <body>.
|
|
6089
|
+
*/
|
|
6090
|
+
handleFocusHandoff(toast, list) {
|
|
6091
|
+
if (!toast.element.contains(document.activeElement)) {
|
|
6092
|
+
return;
|
|
6093
|
+
}
|
|
6094
|
+
for (let i = list.length - 1; i >= 0; i--) {
|
|
6095
|
+
const sibling = list[i];
|
|
6096
|
+
if (sibling === toast || sibling.isClosed || !sibling.element.isConnected) continue;
|
|
6097
|
+
const target = sibling.element.querySelector(FOCUSABLE_IN_TOAST);
|
|
6098
|
+
if (target) {
|
|
6099
|
+
target.focus({ preventScroll: true });
|
|
6100
|
+
return;
|
|
6101
|
+
}
|
|
6102
|
+
}
|
|
6103
|
+
const prev = toast.getPreviousActiveElement();
|
|
6104
|
+
if (prev && prev.isConnected && typeof prev.focus === "function" && !prev.disabled && !prev.closest("[inert]") && prev.getAttribute("aria-hidden") !== "true") {
|
|
6105
|
+
try {
|
|
6106
|
+
prev.focus();
|
|
6107
|
+
} catch {
|
|
6108
|
+
}
|
|
6109
|
+
}
|
|
6110
|
+
}
|
|
5027
6111
|
/**
|
|
5028
6112
|
* Retire une notification de la pile et nettoie le conteneur s'il est vide.
|
|
5029
6113
|
*/
|
|
@@ -5035,16 +6119,32 @@ var __WulfIIFE = (() => {
|
|
|
5035
6119
|
if (index !== -1) {
|
|
5036
6120
|
list.splice(index, 1);
|
|
5037
6121
|
}
|
|
6122
|
+
this.handleFocusHandoff(toast, list);
|
|
6123
|
+
if (toast.element.parentNode) {
|
|
6124
|
+
toast.element.parentNode.removeChild(toast.element);
|
|
6125
|
+
}
|
|
5038
6126
|
if (list.length === 0 && !this.pendingReplacements.has(position)) {
|
|
5039
6127
|
const container = this.containers.get(position);
|
|
5040
6128
|
if (container && (!container.firstChild || container.children.length === 0)) {
|
|
5041
|
-
|
|
5042
|
-
container.parentNode.removeChild(container);
|
|
5043
|
-
}
|
|
6129
|
+
this.disposeContainer(container);
|
|
5044
6130
|
this.containers.delete(position);
|
|
5045
6131
|
this.activeToasts.delete(position);
|
|
5046
6132
|
}
|
|
5047
6133
|
}
|
|
6134
|
+
} else if (toast.element.parentNode) {
|
|
6135
|
+
toast.element.parentNode.removeChild(toast.element);
|
|
6136
|
+
}
|
|
6137
|
+
}
|
|
6138
|
+
disposeContainer(container) {
|
|
6139
|
+
try {
|
|
6140
|
+
const popoverEl = container;
|
|
6141
|
+
if (typeof popoverEl.hidePopover === "function" && this.isPopoverOpen(container)) {
|
|
6142
|
+
popoverEl.hidePopover();
|
|
6143
|
+
}
|
|
6144
|
+
} catch {
|
|
6145
|
+
}
|
|
6146
|
+
if (container.parentNode) {
|
|
6147
|
+
container.parentNode.removeChild(container);
|
|
5048
6148
|
}
|
|
5049
6149
|
}
|
|
5050
6150
|
/**
|
|
@@ -5053,6 +6153,8 @@ var __WulfIIFE = (() => {
|
|
|
5053
6153
|
clearAll(position) {
|
|
5054
6154
|
const promises = [];
|
|
5055
6155
|
if (position) {
|
|
6156
|
+
this.replaceTokens.set(position, (this.replaceTokens.get(position) || 0) + 1);
|
|
6157
|
+
this.pendingReplacements.delete(position);
|
|
5056
6158
|
const list = this.activeToasts.get(position);
|
|
5057
6159
|
if (list && list.length > 0) {
|
|
5058
6160
|
const copy = [...list];
|
|
@@ -5062,14 +6164,24 @@ var __WulfIIFE = (() => {
|
|
|
5062
6164
|
} else {
|
|
5063
6165
|
const container = this.containers.get(position);
|
|
5064
6166
|
if (container && (!container.firstChild || container.children.length === 0)) {
|
|
5065
|
-
|
|
5066
|
-
container.parentNode.removeChild(container);
|
|
5067
|
-
}
|
|
6167
|
+
this.disposeContainer(container);
|
|
5068
6168
|
this.containers.delete(position);
|
|
5069
6169
|
this.activeToasts.delete(position);
|
|
5070
6170
|
}
|
|
5071
6171
|
}
|
|
5072
6172
|
} else {
|
|
6173
|
+
for (const pos of this.replaceTokens.keys()) {
|
|
6174
|
+
this.replaceTokens.set(pos, (this.replaceTokens.get(pos) || 0) + 1);
|
|
6175
|
+
}
|
|
6176
|
+
this.pendingReplacements.clear();
|
|
6177
|
+
for (const timerId of this.announceTimers) {
|
|
6178
|
+
window.clearTimeout(timerId);
|
|
6179
|
+
}
|
|
6180
|
+
this.announceTimers = [];
|
|
6181
|
+
this.politeAnnounceTimerId = null;
|
|
6182
|
+
this.assertiveAnnounceTimerId = null;
|
|
6183
|
+
this.politeClearTimerId = null;
|
|
6184
|
+
this.assertiveClearTimerId = null;
|
|
5073
6185
|
const allPositions = /* @__PURE__ */ new Set([
|
|
5074
6186
|
...Array.from(this.containers.keys()),
|
|
5075
6187
|
...Array.from(this.activeToasts.keys())
|
|
@@ -5082,9 +6194,7 @@ var __WulfIIFE = (() => {
|
|
|
5082
6194
|
if (!position) {
|
|
5083
6195
|
for (const [pos, container] of Array.from(this.containers.entries())) {
|
|
5084
6196
|
if (!container.firstChild || container.children.length === 0) {
|
|
5085
|
-
|
|
5086
|
-
container.parentNode.removeChild(container);
|
|
5087
|
-
}
|
|
6197
|
+
this.disposeContainer(container);
|
|
5088
6198
|
this.containers.delete(pos);
|
|
5089
6199
|
this.activeToasts.delete(pos);
|
|
5090
6200
|
}
|
|
@@ -5092,27 +6202,58 @@ var __WulfIIFE = (() => {
|
|
|
5092
6202
|
}
|
|
5093
6203
|
});
|
|
5094
6204
|
}
|
|
6205
|
+
/**
|
|
6206
|
+
* Détruit immédiatement tous les toasts, conteneurs, annonceurs ARIA et temporisations en cours.
|
|
6207
|
+
*/
|
|
6208
|
+
destroy() {
|
|
6209
|
+
for (const timerId of this.announceTimers) {
|
|
6210
|
+
window.clearTimeout(timerId);
|
|
6211
|
+
}
|
|
6212
|
+
this.announceTimers = [];
|
|
6213
|
+
for (const list of Array.from(this.activeToasts.values())) {
|
|
6214
|
+
for (const toast of [...list]) {
|
|
6215
|
+
toast.destroyImmediate("programmatic");
|
|
6216
|
+
}
|
|
6217
|
+
}
|
|
6218
|
+
for (const container of Array.from(this.containers.values())) {
|
|
6219
|
+
this.disposeContainer(container);
|
|
6220
|
+
}
|
|
6221
|
+
this.containers.clear();
|
|
6222
|
+
this.activeToasts.clear();
|
|
6223
|
+
this.replaceTokens.clear();
|
|
6224
|
+
this.pendingReplacements.clear();
|
|
6225
|
+
if (this.announcerEl) {
|
|
6226
|
+
this.announcerEl.remove();
|
|
6227
|
+
this.announcerEl = null;
|
|
6228
|
+
this.politeRegion = null;
|
|
6229
|
+
this.assertiveRegion = null;
|
|
6230
|
+
}
|
|
6231
|
+
_ToastManager.instance = null;
|
|
6232
|
+
}
|
|
5095
6233
|
/**
|
|
5096
6234
|
* Récupère ou crée le conteneur DOM pour une position d'affichage.
|
|
5097
6235
|
*/
|
|
5098
|
-
getOrCreateContainer(position) {
|
|
6236
|
+
getOrCreateContainer(position, toast, useTopLayer) {
|
|
5099
6237
|
let container = this.containers.get(position);
|
|
5100
6238
|
if (!container || !document.body.contains(container)) {
|
|
5101
6239
|
container = document.createElement("div");
|
|
5102
6240
|
container.className = `wulf-toast-container wulf-toast-${position}`;
|
|
5103
|
-
container.setAttribute("
|
|
5104
|
-
container.setAttribute("aria-
|
|
6241
|
+
container.setAttribute("role", "region");
|
|
6242
|
+
container.setAttribute("aria-label", toastI18n.t("notificationsRegion", toast.options.i18n));
|
|
6243
|
+
if (useTopLayer && typeof container.showPopover === "function") {
|
|
6244
|
+
container.setAttribute("popover", "manual");
|
|
6245
|
+
}
|
|
5105
6246
|
document.body.appendChild(container);
|
|
5106
6247
|
this.containers.set(position, container);
|
|
5107
6248
|
}
|
|
5108
6249
|
return container;
|
|
5109
6250
|
}
|
|
5110
6251
|
};
|
|
5111
|
-
_ToastManager.instance = null;
|
|
5112
|
-
var ToastManager = _ToastManager;
|
|
5113
6252
|
|
|
5114
6253
|
// src/toast/Toast.ts
|
|
5115
6254
|
var Toast = class extends LocalizedComponent {
|
|
6255
|
+
static _i18n = toastI18n;
|
|
6256
|
+
static i18n = toastI18n;
|
|
5116
6257
|
audit() {
|
|
5117
6258
|
return [];
|
|
5118
6259
|
}
|
|
@@ -5139,17 +6280,19 @@ var __WulfIIFE = (() => {
|
|
|
5139
6280
|
static clearAll(position) {
|
|
5140
6281
|
return ToastManager.getInstance().clearAll(position);
|
|
5141
6282
|
}
|
|
6283
|
+
/**
|
|
6284
|
+
* Détruit le gestionnaire de notifications (conteneurs, annonceurs ARIA et timers).
|
|
6285
|
+
*/
|
|
6286
|
+
static destroy() {
|
|
6287
|
+
ToastManager.getInstance().destroy();
|
|
6288
|
+
}
|
|
5142
6289
|
};
|
|
5143
|
-
Toast._i18n = toastI18n;
|
|
5144
|
-
Toast.i18n = toastI18n;
|
|
5145
6290
|
|
|
5146
6291
|
// src/toast/index.ts
|
|
5147
6292
|
var toast_default = Toast;
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
win.Wulf = wulfNamespace;
|
|
5152
|
-
wulfNamespace.Toast = Object.assign(Toast, {
|
|
6293
|
+
var wulfNamespace4 = getSafeWulfNamespace();
|
|
6294
|
+
if (wulfNamespace4) {
|
|
6295
|
+
wulfNamespace4.Toast = Object.assign(Toast, {
|
|
5153
6296
|
Toast,
|
|
5154
6297
|
i18n: toastI18n
|
|
5155
6298
|
});
|
|
@@ -5166,7 +6309,7 @@ var __WulfIIFE = (() => {
|
|
|
5166
6309
|
var FOCUSABLE_SELECTOR = [
|
|
5167
6310
|
"a[href]",
|
|
5168
6311
|
"area[href]",
|
|
5169
|
-
|
|
6312
|
+
'input:not([disabled]):not([type="hidden"])',
|
|
5170
6313
|
"select:not([disabled])",
|
|
5171
6314
|
"textarea:not([disabled])",
|
|
5172
6315
|
"button:not([disabled])",
|
|
@@ -5179,12 +6322,6 @@ var __WulfIIFE = (() => {
|
|
|
5179
6322
|
'[contenteditable]:not([contenteditable="false"])',
|
|
5180
6323
|
'[tabindex]:not([tabindex="-1"])'
|
|
5181
6324
|
].join(",");
|
|
5182
|
-
function safeCssEscape(value) {
|
|
5183
|
-
if (typeof CSS !== "undefined" && typeof CSS.escape === "function") {
|
|
5184
|
-
return CSS.escape(value);
|
|
5185
|
-
}
|
|
5186
|
-
return String(value).replace(/["\\]/g, "\\$&");
|
|
5187
|
-
}
|
|
5188
6325
|
function safeQuerySelector(root, selector) {
|
|
5189
6326
|
if (!selector || typeof selector !== "string") return null;
|
|
5190
6327
|
try {
|
|
@@ -5195,27 +6332,34 @@ var __WulfIIFE = (() => {
|
|
|
5195
6332
|
}
|
|
5196
6333
|
var trapStack = [];
|
|
5197
6334
|
var FocusTrap = class extends AuditableComponent {
|
|
6335
|
+
element;
|
|
6336
|
+
options;
|
|
6337
|
+
active = false;
|
|
6338
|
+
paused = false;
|
|
6339
|
+
previousActiveElement = null;
|
|
6340
|
+
inertSiblings = [];
|
|
6341
|
+
addedContainerTabIndex = false;
|
|
6342
|
+
lastOutsidePointerDownTime = 0;
|
|
6343
|
+
abortController;
|
|
6344
|
+
// Handlers liés
|
|
6345
|
+
handleKeyDownBound;
|
|
6346
|
+
handleClickOutsideBound;
|
|
6347
|
+
handleFocusInBound;
|
|
5198
6348
|
constructor(target, options = {}) {
|
|
5199
6349
|
super();
|
|
5200
|
-
this.active = false;
|
|
5201
|
-
this.paused = false;
|
|
5202
|
-
this.previousActiveElement = null;
|
|
5203
|
-
this.inertSiblings = [];
|
|
5204
|
-
// Sentinelles anti-fuite de focus
|
|
5205
|
-
this.startSentinel = null;
|
|
5206
|
-
this.endSentinel = null;
|
|
5207
6350
|
const el = typeof target === "string" ? safeQuerySelector(document, target) : target;
|
|
5208
6351
|
if (!el || !(el instanceof HTMLElement)) {
|
|
5209
6352
|
throw new Error(`[Wulf.FocusTrap] Conteneur introuvable ou invalide : "${target}"`);
|
|
5210
6353
|
}
|
|
5211
6354
|
this.element = el;
|
|
6355
|
+
const allowOutsideClick = options.allowOutsideClick ?? false;
|
|
5212
6356
|
this.options = {
|
|
5213
6357
|
initialFocus: options.initialFocus !== void 0 ? options.initialFocus : "[data-autofocus], [autofocus]",
|
|
5214
6358
|
returnFocus: options.returnFocus ?? true,
|
|
5215
6359
|
fallbackReturnFocus: options.fallbackReturnFocus ?? "",
|
|
5216
6360
|
escapeDeactivates: options.escapeDeactivates ?? true,
|
|
5217
|
-
allowOutsideClick
|
|
5218
|
-
setInert: options.setInert ??
|
|
6361
|
+
allowOutsideClick,
|
|
6362
|
+
setInert: options.setInert ?? !allowOutsideClick,
|
|
5219
6363
|
onActivate: options.onActivate ?? (() => {
|
|
5220
6364
|
}),
|
|
5221
6365
|
onDeactivate: options.onDeactivate ?? (() => {
|
|
@@ -5227,25 +6371,57 @@ var __WulfIIFE = (() => {
|
|
|
5227
6371
|
this.handleFocusInBound = this.handleFocusIn.bind(this);
|
|
5228
6372
|
this.runAuditWarning(this.options.audit);
|
|
5229
6373
|
}
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
6374
|
+
isNativeDialogElement() {
|
|
6375
|
+
return this.element.tagName.toLowerCase() === "dialog";
|
|
6376
|
+
}
|
|
6377
|
+
isNativeModalDialog() {
|
|
6378
|
+
if (!this.isNativeDialogElement()) return false;
|
|
6379
|
+
try {
|
|
6380
|
+
return this.element.matches(":modal");
|
|
6381
|
+
} catch {
|
|
6382
|
+
return false;
|
|
6383
|
+
}
|
|
6384
|
+
}
|
|
6385
|
+
isElementFocusableBase(el) {
|
|
5234
6386
|
if (!el || !el.isConnected) return false;
|
|
6387
|
+
if (el.tabIndex < 0) return false;
|
|
5235
6388
|
if (el.disabled) return false;
|
|
5236
|
-
|
|
6389
|
+
try {
|
|
6390
|
+
if (el.matches(":disabled")) return false;
|
|
6391
|
+
} catch {
|
|
6392
|
+
if (el.closest("fieldset[disabled]")) return false;
|
|
6393
|
+
}
|
|
5237
6394
|
if (el.hasAttribute("inert") || el.closest("[inert]")) return false;
|
|
5238
6395
|
if (el.hidden || el.closest("[hidden]")) return false;
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
6396
|
+
const elWithCheck = el;
|
|
6397
|
+
if (typeof elWithCheck.checkVisibility === "function") {
|
|
6398
|
+
if (!elWithCheck.checkVisibility({
|
|
6399
|
+
checkOpacity: false,
|
|
6400
|
+
checkVisibilityCSS: true,
|
|
6401
|
+
visibilityProperty: true
|
|
6402
|
+
})) {
|
|
6403
|
+
return false;
|
|
6404
|
+
}
|
|
6405
|
+
} else {
|
|
6406
|
+
if (el.style.display === "none" || el.style.visibility === "hidden") return false;
|
|
6407
|
+
const style = window.getComputedStyle(el);
|
|
6408
|
+
if (style.display === "none" || style.visibility === "hidden") return false;
|
|
6409
|
+
if (el.offsetWidth === 0 && el.offsetHeight === 0 && style.position !== "fixed") {
|
|
6410
|
+
return false;
|
|
6411
|
+
}
|
|
5244
6412
|
}
|
|
6413
|
+
return true;
|
|
6414
|
+
}
|
|
6415
|
+
/**
|
|
6416
|
+
* Vérifie si un élément est réellement focusable, visible et actif dans le DOM.
|
|
6417
|
+
*/
|
|
6418
|
+
isFocusable(el) {
|
|
6419
|
+
if (!this.isElementFocusableBase(el)) return false;
|
|
5245
6420
|
if (el instanceof HTMLInputElement && el.type === "radio" && el.name) {
|
|
5246
6421
|
const group = Array.from(
|
|
5247
6422
|
this.element.querySelectorAll(`input[type="radio"][name="${safeCssEscape(el.name)}"]`)
|
|
5248
|
-
);
|
|
6423
|
+
).filter((r) => r.form === el.form && this.isElementFocusableBase(r));
|
|
6424
|
+
if (group.length === 0) return false;
|
|
5249
6425
|
const checked = group.find((r) => r.checked);
|
|
5250
6426
|
if (checked) {
|
|
5251
6427
|
return el === checked;
|
|
@@ -5273,17 +6449,21 @@ var __WulfIIFE = (() => {
|
|
|
5273
6449
|
this.active = true;
|
|
5274
6450
|
this.paused = false;
|
|
5275
6451
|
trapStack.push(this);
|
|
5276
|
-
|
|
5277
|
-
this.
|
|
5278
|
-
if (this.options.setInert) {
|
|
6452
|
+
const deepActive = getDeepActiveElement(document);
|
|
6453
|
+
this.previousActiveElement = deepActive instanceof HTMLElement ? deepActive : document.activeElement;
|
|
6454
|
+
if (this.options.setInert && !this.isNativeModalDialog()) {
|
|
5279
6455
|
this.applyInert();
|
|
5280
6456
|
}
|
|
5281
|
-
|
|
5282
|
-
|
|
6457
|
+
this.abortController?.abort();
|
|
6458
|
+
this.abortController = new AbortController();
|
|
6459
|
+
const { signal } = this.abortController;
|
|
6460
|
+
document.addEventListener("keydown", this.handleKeyDownBound, { capture: true, signal });
|
|
6461
|
+
document.addEventListener("focusin", this.handleFocusInBound, { capture: true, signal });
|
|
6462
|
+
document.addEventListener("pointerdown", this.handleClickOutsideBound, { capture: true, signal });
|
|
5283
6463
|
if (!this.options.allowOutsideClick) {
|
|
5284
|
-
document.addEventListener("
|
|
5285
|
-
document.addEventListener("
|
|
5286
|
-
document.addEventListener("
|
|
6464
|
+
document.addEventListener("mousedown", this.handleClickOutsideBound, { capture: true, signal });
|
|
6465
|
+
document.addEventListener("touchstart", this.handleClickOutsideBound, { capture: true, signal });
|
|
6466
|
+
document.addEventListener("click", this.handleClickOutsideBound, { capture: true, signal });
|
|
5287
6467
|
}
|
|
5288
6468
|
this.applyInitialFocus();
|
|
5289
6469
|
this.runAuditWarning(this.options.audit);
|
|
@@ -5301,34 +6481,42 @@ var __WulfIIFE = (() => {
|
|
|
5301
6481
|
if (index !== -1) {
|
|
5302
6482
|
trapStack.splice(index, 1);
|
|
5303
6483
|
}
|
|
6484
|
+
this.abortController?.abort();
|
|
6485
|
+
this.abortController = void 0;
|
|
6486
|
+
this.removeInert();
|
|
6487
|
+
if (this.addedContainerTabIndex) {
|
|
6488
|
+
this.element.removeAttribute("tabindex");
|
|
6489
|
+
this.addedContainerTabIndex = false;
|
|
6490
|
+
}
|
|
5304
6491
|
const nextTop = trapStack[trapStack.length - 1];
|
|
5305
6492
|
if (nextTop) {
|
|
5306
6493
|
nextTop.unpause();
|
|
5307
6494
|
}
|
|
5308
|
-
document.removeEventListener("keydown", this.handleKeyDownBound, true);
|
|
5309
|
-
document.removeEventListener("focusin", this.handleFocusInBound, true);
|
|
5310
|
-
document.removeEventListener("pointerdown", this.handleClickOutsideBound, true);
|
|
5311
|
-
document.removeEventListener("mousedown", this.handleClickOutsideBound, true);
|
|
5312
|
-
document.removeEventListener("touchstart", this.handleClickOutsideBound, true);
|
|
5313
|
-
this.removeSentinels();
|
|
5314
|
-
this.removeInert();
|
|
5315
6495
|
if (this.options.returnFocus) {
|
|
5316
6496
|
this.restoreFocus();
|
|
5317
6497
|
}
|
|
6498
|
+
this.previousActiveElement = null;
|
|
5318
6499
|
this.options.onDeactivate();
|
|
5319
6500
|
return this;
|
|
5320
6501
|
}
|
|
5321
6502
|
/**
|
|
5322
6503
|
* Met en pause le trap (utilisé quand un trap fils s'ouvre au-dessus).
|
|
6504
|
+
* Retire temporairement `inert` pour ne pas bloquer une modale sœur ou enfant.
|
|
5323
6505
|
*/
|
|
5324
6506
|
pause() {
|
|
5325
6507
|
this.paused = true;
|
|
6508
|
+
this.removeInert();
|
|
5326
6509
|
}
|
|
5327
6510
|
/**
|
|
5328
|
-
* Sort de pause.
|
|
6511
|
+
* Sort de pause et réapplique l'isolation `inert` si active et si ce trap est bien au sommet de la pile.
|
|
5329
6512
|
*/
|
|
5330
6513
|
unpause() {
|
|
6514
|
+
if (!this.active) return;
|
|
6515
|
+
if (trapStack[trapStack.length - 1] !== this) return;
|
|
5331
6516
|
this.paused = false;
|
|
6517
|
+
if (this.options.setInert && !this.isNativeModalDialog()) {
|
|
6518
|
+
this.applyInert();
|
|
6519
|
+
}
|
|
5332
6520
|
}
|
|
5333
6521
|
/**
|
|
5334
6522
|
* Indique si le trap est actuellement actif et non en pause.
|
|
@@ -5343,17 +6531,35 @@ var __WulfIIFE = (() => {
|
|
|
5343
6531
|
audit() {
|
|
5344
6532
|
const warnings = [];
|
|
5345
6533
|
const role = this.element.getAttribute("role");
|
|
5346
|
-
const isNativeDialog = this.
|
|
6534
|
+
const isNativeDialog = this.isNativeDialogElement();
|
|
5347
6535
|
const validRoles = ["dialog", "alertdialog", "menu", "listbox", "tree", "grid"];
|
|
5348
|
-
if (
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
6536
|
+
if (isNativeDialog) {
|
|
6537
|
+
if (role === "dialog") {
|
|
6538
|
+
warnings.push(
|
|
6539
|
+
'Attribut redondant : role="dialog" est d\xE9j\xE0 implicite sur une balise native <dialog>.'
|
|
6540
|
+
);
|
|
6541
|
+
}
|
|
6542
|
+
if (this.element.hasAttribute("aria-modal")) {
|
|
6543
|
+
warnings.push(
|
|
6544
|
+
'Attribut redondant : <dialog> ouvert via showModal() g\xE8re nativement la modalit\xE9 sans n\xE9cessiter aria-modal="true".'
|
|
6545
|
+
);
|
|
6546
|
+
}
|
|
6547
|
+
if (this.element.hasAttribute("open") && !this.isNativeModalDialog()) {
|
|
6548
|
+
warnings.push(
|
|
6549
|
+
"Dialogue non modal d\xE9tect\xE9 : pr\xE9f\xE9rez dialog.showModal() plut\xF4t que l'attribut open pour obtenir la Top Layer et l'inertie natives."
|
|
6550
|
+
);
|
|
6551
|
+
}
|
|
6552
|
+
} else {
|
|
6553
|
+
if (!role || !validRoles.includes(role)) {
|
|
6554
|
+
warnings.push(
|
|
6555
|
+
'R\xF4le s\xE9mantique manquant ou inadapt\xE9 : d\xE9finissez role="dialog" (ou "alertdialog", "menu", "listbox") sur le conteneur.'
|
|
6556
|
+
);
|
|
6557
|
+
}
|
|
6558
|
+
if ((role === "dialog" || role === "alertdialog") && this.element.getAttribute("aria-modal") !== "true") {
|
|
6559
|
+
warnings.push(
|
|
6560
|
+
'Isolation modale manquante : d\xE9finissez aria-modal="true" sur le conteneur de dialogue (WCAG 4.1.2).'
|
|
6561
|
+
);
|
|
6562
|
+
}
|
|
5357
6563
|
}
|
|
5358
6564
|
const ariaLabel = this.element.getAttribute("aria-label")?.trim();
|
|
5359
6565
|
const hasValidLabelledby = this.checkAriaIdReferences(this.element, "aria-labelledby", warnings);
|
|
@@ -5389,15 +6595,15 @@ var __WulfIIFE = (() => {
|
|
|
5389
6595
|
}
|
|
5390
6596
|
return false;
|
|
5391
6597
|
}
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
6598
|
+
isInsideToastContainer(target) {
|
|
6599
|
+
if (!target || !(target instanceof Element)) return false;
|
|
6600
|
+
return Boolean(target.closest(".wulf-toast-container"));
|
|
6601
|
+
}
|
|
6602
|
+
ensureContainerTabIndex() {
|
|
6603
|
+
if (this.element.getAttribute("tabindex") === null) {
|
|
6604
|
+
this.element.setAttribute("tabindex", "-1");
|
|
6605
|
+
this.addedContainerTabIndex = true;
|
|
6606
|
+
}
|
|
5401
6607
|
}
|
|
5402
6608
|
handleKeyDown(e) {
|
|
5403
6609
|
if (!this.isActive()) return;
|
|
@@ -5406,8 +6612,11 @@ var __WulfIIFE = (() => {
|
|
|
5406
6612
|
return;
|
|
5407
6613
|
}
|
|
5408
6614
|
if (e.key === "Escape" && this.options.escapeDeactivates) {
|
|
5409
|
-
e
|
|
5410
|
-
|
|
6615
|
+
if (isImeComposing(e)) return;
|
|
6616
|
+
if (!this.isNativeModalDialog()) {
|
|
6617
|
+
e.preventDefault();
|
|
6618
|
+
e.stopPropagation();
|
|
6619
|
+
}
|
|
5411
6620
|
this.deactivate();
|
|
5412
6621
|
return;
|
|
5413
6622
|
}
|
|
@@ -5415,19 +6624,19 @@ var __WulfIIFE = (() => {
|
|
|
5415
6624
|
const focusables = this.getFocusableElements();
|
|
5416
6625
|
if (focusables.length === 0) {
|
|
5417
6626
|
e.preventDefault();
|
|
5418
|
-
|
|
5419
|
-
this.element.setAttribute("tabindex", "-1");
|
|
5420
|
-
}
|
|
6627
|
+
this.ensureContainerTabIndex();
|
|
5421
6628
|
this.element.focus();
|
|
5422
6629
|
return;
|
|
5423
6630
|
}
|
|
5424
6631
|
const first = focusables[0];
|
|
5425
6632
|
const last = focusables[focusables.length - 1];
|
|
5426
|
-
const
|
|
5427
|
-
|
|
6633
|
+
const deepCurrent = getDeepActiveElement(document);
|
|
6634
|
+
const current = deepCurrent instanceof HTMLElement ? deepCurrent : document.activeElement;
|
|
6635
|
+
const isInside = current ? this.element.contains(current) || this.isEventInside(e, current) : false;
|
|
6636
|
+
if (!e.shiftKey && (current === last || !isInside)) {
|
|
5428
6637
|
e.preventDefault();
|
|
5429
6638
|
first.focus();
|
|
5430
|
-
} else if (e.shiftKey && (current === first ||
|
|
6639
|
+
} else if (e.shiftKey && (current === first || current === this.element || !isInside)) {
|
|
5431
6640
|
e.preventDefault();
|
|
5432
6641
|
last.focus();
|
|
5433
6642
|
}
|
|
@@ -5440,22 +6649,10 @@ var __WulfIIFE = (() => {
|
|
|
5440
6649
|
}
|
|
5441
6650
|
const target = e.target;
|
|
5442
6651
|
if (!target) return;
|
|
5443
|
-
if (
|
|
5444
|
-
const focusables = this.getFocusableElements();
|
|
5445
|
-
if (focusables.length > 0) {
|
|
5446
|
-
focusables[focusables.length - 1].focus();
|
|
5447
|
-
} else {
|
|
5448
|
-
this.element.focus();
|
|
5449
|
-
}
|
|
6652
|
+
if (this.isInsideToastContainer(target)) {
|
|
5450
6653
|
return;
|
|
5451
6654
|
}
|
|
5452
|
-
if (
|
|
5453
|
-
const focusables = this.getFocusableElements();
|
|
5454
|
-
if (focusables.length > 0) {
|
|
5455
|
-
focusables[0].focus();
|
|
5456
|
-
} else {
|
|
5457
|
-
this.element.focus();
|
|
5458
|
-
}
|
|
6655
|
+
if (this.options.allowOutsideClick && performance.now() - this.lastOutsidePointerDownTime < 150) {
|
|
5459
6656
|
return;
|
|
5460
6657
|
}
|
|
5461
6658
|
if (!this.isEventInside(e, target)) {
|
|
@@ -5463,9 +6660,7 @@ var __WulfIIFE = (() => {
|
|
|
5463
6660
|
if (focusables.length > 0) {
|
|
5464
6661
|
focusables[0].focus();
|
|
5465
6662
|
} else {
|
|
5466
|
-
|
|
5467
|
-
this.element.setAttribute("tabindex", "-1");
|
|
5468
|
-
}
|
|
6663
|
+
this.ensureContainerTabIndex();
|
|
5469
6664
|
this.element.focus();
|
|
5470
6665
|
}
|
|
5471
6666
|
}
|
|
@@ -5478,51 +6673,34 @@ var __WulfIIFE = (() => {
|
|
|
5478
6673
|
}
|
|
5479
6674
|
const target = e.target;
|
|
5480
6675
|
if (target && !this.isEventInside(e, target)) {
|
|
6676
|
+
if (this.isInsideToastContainer(target)) {
|
|
6677
|
+
return;
|
|
6678
|
+
}
|
|
6679
|
+
if (this.options.allowOutsideClick) {
|
|
6680
|
+
this.lastOutsidePointerDownTime = performance.now();
|
|
6681
|
+
return;
|
|
6682
|
+
}
|
|
5481
6683
|
e.preventDefault();
|
|
5482
6684
|
e.stopPropagation();
|
|
5483
6685
|
}
|
|
5484
6686
|
}
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
this.startSentinel.setAttribute("aria-hidden", "true");
|
|
5490
|
-
this.startSentinel.className = "wulf-sentinel-start";
|
|
5491
|
-
this.applySentinelStyles(this.startSentinel);
|
|
5492
|
-
}
|
|
5493
|
-
if (!this.endSentinel) {
|
|
5494
|
-
this.endSentinel = document.createElement("span");
|
|
5495
|
-
this.endSentinel.setAttribute("tabindex", "0");
|
|
5496
|
-
this.endSentinel.setAttribute("aria-hidden", "true");
|
|
5497
|
-
this.endSentinel.className = "wulf-sentinel-end";
|
|
5498
|
-
this.applySentinelStyles(this.endSentinel);
|
|
5499
|
-
}
|
|
5500
|
-
if (this.element.parentNode) {
|
|
5501
|
-
this.element.parentNode.insertBefore(this.startSentinel, this.element);
|
|
5502
|
-
this.element.parentNode.insertBefore(this.endSentinel, this.element.nextSibling);
|
|
5503
|
-
}
|
|
5504
|
-
}
|
|
5505
|
-
removeSentinels() {
|
|
5506
|
-
this.startSentinel?.remove();
|
|
5507
|
-
this.endSentinel?.remove();
|
|
5508
|
-
this.startSentinel = null;
|
|
5509
|
-
this.endSentinel = null;
|
|
5510
|
-
}
|
|
6687
|
+
/**
|
|
6688
|
+
* Applique `inert` sur les éléments frères à chaque niveau hiérarchique jusqu'à <body>,
|
|
6689
|
+
* en préservant les conteneurs de notifications Toast en Top Layer.
|
|
6690
|
+
*/
|
|
5511
6691
|
applyInert() {
|
|
5512
|
-
this.
|
|
5513
|
-
let
|
|
5514
|
-
|
|
5515
|
-
while (
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
if (child instanceof HTMLElement && child !== currentChild && child !== this.startSentinel && child !== this.endSentinel && !child.hasAttribute("inert")) {
|
|
5522
|
-
child.setAttribute("inert", "");
|
|
5523
|
-
this.inertSiblings.push(child);
|
|
6692
|
+
this.removeInert();
|
|
6693
|
+
let current = this.element;
|
|
6694
|
+
const ignoredTags = /* @__PURE__ */ new Set(["SCRIPT", "STYLE", "TEMPLATE", "LINK", "META", "NOSCRIPT"]);
|
|
6695
|
+
while (current && current !== document.body && current.parentElement) {
|
|
6696
|
+
const parent = current.parentElement;
|
|
6697
|
+
for (const sibling of Array.from(parent.children)) {
|
|
6698
|
+
if (sibling instanceof HTMLElement && sibling !== current && !ignoredTags.has(sibling.tagName) && !sibling.hasAttribute("inert") && !sibling.matches(".wulf-toast-container, .wulf-toast-announcer")) {
|
|
6699
|
+
sibling.setAttribute("inert", "");
|
|
6700
|
+
this.inertSiblings.push(sibling);
|
|
5524
6701
|
}
|
|
5525
|
-
}
|
|
6702
|
+
}
|
|
6703
|
+
current = parent;
|
|
5526
6704
|
}
|
|
5527
6705
|
}
|
|
5528
6706
|
removeInert() {
|
|
@@ -5545,20 +6723,18 @@ var __WulfIIFE = (() => {
|
|
|
5545
6723
|
if (focusables.length > 0) {
|
|
5546
6724
|
focusables[0].focus();
|
|
5547
6725
|
} else {
|
|
5548
|
-
|
|
5549
|
-
this.element.setAttribute("tabindex", "-1");
|
|
5550
|
-
}
|
|
6726
|
+
this.ensureContainerTabIndex();
|
|
5551
6727
|
this.element.focus();
|
|
5552
6728
|
}
|
|
5553
6729
|
}
|
|
5554
6730
|
restoreFocus() {
|
|
5555
|
-
if (this.previousActiveElement && this.previousActiveElement.isConnected) {
|
|
6731
|
+
if (this.previousActiveElement && this.previousActiveElement.isConnected && this.isElementFocusableBase(this.previousActiveElement)) {
|
|
5556
6732
|
this.previousActiveElement.focus();
|
|
5557
6733
|
return;
|
|
5558
6734
|
}
|
|
5559
6735
|
if (this.options.fallbackReturnFocus) {
|
|
5560
6736
|
const fallback = typeof this.options.fallbackReturnFocus === "string" ? safeQuerySelector(document, this.options.fallbackReturnFocus) : this.options.fallbackReturnFocus;
|
|
5561
|
-
if (fallback && fallback.isConnected) {
|
|
6737
|
+
if (fallback && fallback.isConnected && this.isElementFocusableBase(fallback)) {
|
|
5562
6738
|
fallback.focus();
|
|
5563
6739
|
}
|
|
5564
6740
|
}
|
|
@@ -5566,11 +6742,9 @@ var __WulfIIFE = (() => {
|
|
|
5566
6742
|
};
|
|
5567
6743
|
|
|
5568
6744
|
// src/focus-trap/index.ts
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
win.Wulf = wulfNamespace;
|
|
5573
|
-
wulfNamespace.FocusTrap = Object.assign(FocusTrap, {
|
|
6745
|
+
var wulfNamespace5 = getSafeWulfNamespace();
|
|
6746
|
+
if (wulfNamespace5) {
|
|
6747
|
+
wulfNamespace5.FocusTrap = Object.assign(FocusTrap, {
|
|
5574
6748
|
FocusTrap
|
|
5575
6749
|
});
|
|
5576
6750
|
}
|
|
@@ -5610,6 +6784,9 @@ var __WulfIIFE = (() => {
|
|
|
5610
6784
|
* Normalise un nom de touche unitaire pour les comparaisons.
|
|
5611
6785
|
*/
|
|
5612
6786
|
static normalizeKeyName(key) {
|
|
6787
|
+
if (key === " ") {
|
|
6788
|
+
return " ";
|
|
6789
|
+
}
|
|
5613
6790
|
const k = key.trim().toLowerCase();
|
|
5614
6791
|
switch (k) {
|
|
5615
6792
|
case "esc":
|
|
@@ -5619,6 +6796,8 @@ var __WulfIIFE = (() => {
|
|
|
5619
6796
|
case "space":
|
|
5620
6797
|
case "spacebar":
|
|
5621
6798
|
return " ";
|
|
6799
|
+
case "plus":
|
|
6800
|
+
return "+";
|
|
5622
6801
|
case "del":
|
|
5623
6802
|
return "delete";
|
|
5624
6803
|
case "ins":
|
|
@@ -5643,30 +6822,41 @@ var __WulfIIFE = (() => {
|
|
|
5643
6822
|
if (typeof combo !== "string") {
|
|
5644
6823
|
return [];
|
|
5645
6824
|
}
|
|
6825
|
+
if (combo === " ") {
|
|
6826
|
+
return [{ ctrl: false, alt: false, shift: false, meta: false, key: " " }];
|
|
6827
|
+
}
|
|
5646
6828
|
const trimmed = combo.slice(0, 512).trim();
|
|
5647
6829
|
if (!trimmed) {
|
|
5648
6830
|
return [];
|
|
5649
6831
|
}
|
|
5650
|
-
const
|
|
6832
|
+
const normalizedChordSpacing = trimmed.replace(
|
|
6833
|
+
/\b(ctrl|control|alt|option|opt|shift|maj|cmd|command|meta|win|super|mod|\$mod)\s*\+\s*/gi,
|
|
6834
|
+
"$1+"
|
|
6835
|
+
);
|
|
6836
|
+
const stepsRaw = normalizedChordSpacing.split(/\s+/).slice(0, 10);
|
|
5651
6837
|
const steps = [];
|
|
5652
6838
|
for (const rawStep of stepsRaw) {
|
|
5653
6839
|
const tokens = [];
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
tokens.
|
|
5662
|
-
|
|
6840
|
+
if (rawStep === "+") {
|
|
6841
|
+
tokens.push("+");
|
|
6842
|
+
} else {
|
|
6843
|
+
let currentToken = "";
|
|
6844
|
+
for (let i = 0; i < rawStep.length; i++) {
|
|
6845
|
+
const char = rawStep[i];
|
|
6846
|
+
if (char === "+") {
|
|
6847
|
+
if (currentToken === "" && tokens.length > 0) {
|
|
6848
|
+
tokens.push("+");
|
|
6849
|
+
} else if (currentToken !== "") {
|
|
6850
|
+
tokens.push(currentToken);
|
|
6851
|
+
currentToken = "";
|
|
6852
|
+
}
|
|
6853
|
+
} else {
|
|
6854
|
+
currentToken += char;
|
|
5663
6855
|
}
|
|
5664
|
-
} else {
|
|
5665
|
-
currentToken += char;
|
|
5666
6856
|
}
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
|
|
6857
|
+
if (currentToken !== "") {
|
|
6858
|
+
tokens.push(currentToken);
|
|
6859
|
+
}
|
|
5670
6860
|
}
|
|
5671
6861
|
let ctrl = false;
|
|
5672
6862
|
let alt = false;
|
|
@@ -5738,18 +6928,78 @@ var __WulfIIFE = (() => {
|
|
|
5738
6928
|
/**
|
|
5739
6929
|
* Convertit un combo technique vers le format officiel WAI-ARIA `aria-keyshortcuts`.
|
|
5740
6930
|
* Standard W3C : les modificateurs sont 'Control', 'Alt', 'Shift', 'Meta' et le séparateur est '+'.
|
|
6931
|
+
* Attention : dans WAI-ARIA 1.2, l'espace délimite des raccourcis alternatifs et non une séquence temporelle.
|
|
6932
|
+
* Pour une séquence multi-étapes (ex: "g i"), retourne une chaîne vide afin de ne pas induire le lecteur d'écran en erreur.
|
|
5741
6933
|
*/
|
|
5742
6934
|
static toAriaKeyShortcuts(combo, isApple = _ShortcutFormatter.isApple()) {
|
|
5743
6935
|
const steps = _ShortcutFormatter.parseCombo(combo, isApple);
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
6936
|
+
if (steps.length !== 1) {
|
|
6937
|
+
return "";
|
|
6938
|
+
}
|
|
6939
|
+
const step = steps[0];
|
|
6940
|
+
const ariaKey = _ShortcutFormatter.formatAriaKey(step.key);
|
|
6941
|
+
if (!ariaKey) {
|
|
6942
|
+
return "";
|
|
6943
|
+
}
|
|
6944
|
+
const parts = [];
|
|
6945
|
+
if (step.ctrl) parts.push("Control");
|
|
6946
|
+
if (step.alt) parts.push("Alt");
|
|
6947
|
+
if (step.shift) parts.push("Shift");
|
|
6948
|
+
if (step.meta) parts.push("Meta");
|
|
6949
|
+
parts.push(ariaKey);
|
|
6950
|
+
return parts.join("+");
|
|
6951
|
+
}
|
|
6952
|
+
/**
|
|
6953
|
+
* Formate un nom de touche strictement conforme aux valeurs standard W3C UI Events / aria-keyshortcuts.
|
|
6954
|
+
*/
|
|
6955
|
+
static formatAriaKey(key) {
|
|
6956
|
+
if (!key) return "";
|
|
6957
|
+
switch (key.toLowerCase()) {
|
|
6958
|
+
case "escape":
|
|
6959
|
+
return "Escape";
|
|
6960
|
+
case "enter":
|
|
6961
|
+
return "Enter";
|
|
6962
|
+
case " ":
|
|
6963
|
+
return "Space";
|
|
6964
|
+
case "tab":
|
|
6965
|
+
return "Tab";
|
|
6966
|
+
case "backspace":
|
|
6967
|
+
return "Backspace";
|
|
6968
|
+
case "delete":
|
|
6969
|
+
return "Delete";
|
|
6970
|
+
case "insert":
|
|
6971
|
+
return "Insert";
|
|
6972
|
+
case "home":
|
|
6973
|
+
return "Home";
|
|
6974
|
+
case "end":
|
|
6975
|
+
return "End";
|
|
6976
|
+
case "pageup":
|
|
6977
|
+
return "PageUp";
|
|
6978
|
+
case "pagedown":
|
|
6979
|
+
return "PageDown";
|
|
6980
|
+
case "arrowup":
|
|
6981
|
+
return "ArrowUp";
|
|
6982
|
+
case "arrowdown":
|
|
6983
|
+
return "ArrowDown";
|
|
6984
|
+
case "arrowleft":
|
|
6985
|
+
return "ArrowLeft";
|
|
6986
|
+
case "arrowright":
|
|
6987
|
+
return "ArrowRight";
|
|
6988
|
+
case "printscreen":
|
|
6989
|
+
return "PrintScreen";
|
|
6990
|
+
case "scrolllock":
|
|
6991
|
+
return "ScrollLock";
|
|
6992
|
+
case "numlock":
|
|
6993
|
+
return "NumLock";
|
|
6994
|
+
case "capslock":
|
|
6995
|
+
return "CapsLock";
|
|
6996
|
+
case "contextmenu":
|
|
6997
|
+
return "ContextMenu";
|
|
6998
|
+
case "+":
|
|
6999
|
+
return "Plus";
|
|
7000
|
+
default:
|
|
7001
|
+
return key.length === 1 ? key.toUpperCase() : key.charAt(0).toUpperCase() + key.slice(1);
|
|
7002
|
+
}
|
|
5753
7003
|
}
|
|
5754
7004
|
static formatKeyDisplay(key, isApple) {
|
|
5755
7005
|
if (!key) return "";
|
|
@@ -5782,17 +7032,21 @@ var __WulfIIFE = (() => {
|
|
|
5782
7032
|
|
|
5783
7033
|
// src/shortcut/ShortcutManager.ts
|
|
5784
7034
|
var ShortcutManager = class _ShortcutManager {
|
|
7035
|
+
options;
|
|
7036
|
+
shortcuts = /* @__PURE__ */ new Map();
|
|
7037
|
+
scopeStack = [];
|
|
7038
|
+
sequenceBuffer = [];
|
|
7039
|
+
sequenceTimer = null;
|
|
7040
|
+
isListening = true;
|
|
7041
|
+
boundListener = null;
|
|
7042
|
+
abortController = null;
|
|
7043
|
+
idCounter = 0;
|
|
5785
7044
|
constructor(options) {
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
this.sequenceBuffer = [];
|
|
5789
|
-
this.sequenceTimer = null;
|
|
5790
|
-
this.isListening = true;
|
|
5791
|
-
this.boundListener = null;
|
|
5792
|
-
this.idCounter = 0;
|
|
7045
|
+
const rawTimeout = options?.sequenceTimeout;
|
|
7046
|
+
const sequenceTimeout = typeof rawTimeout === "number" && Number.isFinite(rawTimeout) && rawTimeout > 0 ? Math.min(rawTimeout, 1e4) : 800;
|
|
5793
7047
|
this.options = {
|
|
5794
7048
|
defaultScope: options?.defaultScope || "global",
|
|
5795
|
-
sequenceTimeout
|
|
7049
|
+
sequenceTimeout,
|
|
5796
7050
|
target: options?.target || (typeof window !== "undefined" ? window : {}),
|
|
5797
7051
|
onError: options?.onError
|
|
5798
7052
|
};
|
|
@@ -5821,12 +7075,12 @@ var __WulfIIFE = (() => {
|
|
|
5821
7075
|
return true;
|
|
5822
7076
|
}
|
|
5823
7077
|
const role = el.getAttribute("role");
|
|
5824
|
-
if (role === "textbox" || role === "searchbox") {
|
|
7078
|
+
if (role === "textbox" || role === "searchbox" || role === "combobox" || role === "spinbutton") {
|
|
5825
7079
|
return true;
|
|
5826
7080
|
}
|
|
5827
7081
|
if (typeof el.closest === "function") {
|
|
5828
7082
|
const editableAncestor = el.closest(
|
|
5829
|
-
'[contenteditable="true"], [contenteditable="plaintext-only"], [contenteditable=""], [role="textbox"], [role="searchbox"]'
|
|
7083
|
+
'[contenteditable="true"], [contenteditable="plaintext-only"], [contenteditable=""], [role="textbox"], [role="searchbox"], [role="combobox"], [role="spinbutton"]'
|
|
5830
7084
|
);
|
|
5831
7085
|
if (editableAncestor) {
|
|
5832
7086
|
return true;
|
|
@@ -5885,6 +7139,9 @@ var __WulfIIFE = (() => {
|
|
|
5885
7139
|
* Retire tous les raccourcis correspondant à une combinaison et éventuellement un scope.
|
|
5886
7140
|
*/
|
|
5887
7141
|
unbind(combo, scope) {
|
|
7142
|
+
if (typeof combo !== "string" || !combo.trim()) {
|
|
7143
|
+
return;
|
|
7144
|
+
}
|
|
5888
7145
|
const formatted = ShortcutFormatter.format(combo);
|
|
5889
7146
|
for (const [id, s] of this.shortcuts.entries()) {
|
|
5890
7147
|
if (s.formattedCombo === formatted || s.combo.trim().toLowerCase() === combo.trim().toLowerCase()) {
|
|
@@ -5983,7 +7240,11 @@ var __WulfIIFE = (() => {
|
|
|
5983
7240
|
attachAria(element, combo) {
|
|
5984
7241
|
if (element && typeof element.setAttribute === "function") {
|
|
5985
7242
|
const ariaValue = ShortcutFormatter.toAriaKeyShortcuts(combo);
|
|
5986
|
-
|
|
7243
|
+
if (ariaValue) {
|
|
7244
|
+
element.setAttribute("aria-keyshortcuts", ariaValue);
|
|
7245
|
+
} else if (typeof element.removeAttribute === "function") {
|
|
7246
|
+
element.removeAttribute("aria-keyshortcuts");
|
|
7247
|
+
}
|
|
5987
7248
|
}
|
|
5988
7249
|
}
|
|
5989
7250
|
/**
|
|
@@ -6007,23 +7268,30 @@ var __WulfIIFE = (() => {
|
|
|
6007
7268
|
if (typeof window === "undefined" || !this.options.target) {
|
|
6008
7269
|
return;
|
|
6009
7270
|
}
|
|
7271
|
+
this.abortController = new AbortController();
|
|
6010
7272
|
this.boundListener = (event) => this.handleKeyDown(event);
|
|
6011
7273
|
const target = this.options.target;
|
|
6012
7274
|
if (typeof target.addEventListener === "function") {
|
|
6013
|
-
target.addEventListener("keydown", this.boundListener,
|
|
7275
|
+
target.addEventListener("keydown", this.boundListener, {
|
|
7276
|
+
capture: false,
|
|
7277
|
+
signal: this.abortController.signal
|
|
7278
|
+
});
|
|
6014
7279
|
}
|
|
6015
7280
|
}
|
|
6016
7281
|
removeListener() {
|
|
6017
|
-
if (this.
|
|
7282
|
+
if (this.abortController) {
|
|
7283
|
+
this.abortController.abort();
|
|
7284
|
+
this.abortController = null;
|
|
7285
|
+
} else if (this.boundListener && this.options.target) {
|
|
6018
7286
|
const target = this.options.target;
|
|
6019
7287
|
if (typeof target.removeEventListener === "function") {
|
|
6020
7288
|
target.removeEventListener("keydown", this.boundListener, false);
|
|
6021
7289
|
}
|
|
6022
|
-
this.boundListener = null;
|
|
6023
7290
|
}
|
|
7291
|
+
this.boundListener = null;
|
|
6024
7292
|
}
|
|
6025
7293
|
handleKeyDown(event) {
|
|
6026
|
-
if (!this.isListening) {
|
|
7294
|
+
if (!this.isListening || isImeComposing(event)) {
|
|
6027
7295
|
return;
|
|
6028
7296
|
}
|
|
6029
7297
|
const k = (event.key || "").toLowerCase();
|
|
@@ -6042,7 +7310,7 @@ var __WulfIIFE = (() => {
|
|
|
6042
7310
|
meta: event.metaKey,
|
|
6043
7311
|
key: ShortcutFormatter.normalizeKeyName(event.key || "")
|
|
6044
7312
|
};
|
|
6045
|
-
const now = Date.now();
|
|
7313
|
+
const now = event.timeStamp > 0 ? event.timeStamp : typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
6046
7314
|
if (this.sequenceBuffer.length > 0) {
|
|
6047
7315
|
const last = this.sequenceBuffer[this.sequenceBuffer.length - 1];
|
|
6048
7316
|
if (now - last.timestamp > this.options.sequenceTimeout) {
|
|
@@ -6085,8 +7353,12 @@ var __WulfIIFE = (() => {
|
|
|
6085
7353
|
continue;
|
|
6086
7354
|
}
|
|
6087
7355
|
const firstStep = shortcut.normalizedSteps[0];
|
|
6088
|
-
if (firstStep && firstStep.key.length === 1
|
|
6089
|
-
|
|
7356
|
+
if (firstStep && firstStep.key.length === 1) {
|
|
7357
|
+
const isUntouchedChar = !firstStep.ctrl && !firstStep.alt && !firstStep.meta;
|
|
7358
|
+
const isAltGrOrOptionChar = firstStep.ctrl && firstStep.alt && !firstStep.meta || firstStep.alt && !firstStep.ctrl && !firstStep.meta;
|
|
7359
|
+
if (isUntouchedChar || isAltGrOrOptionChar) {
|
|
7360
|
+
continue;
|
|
7361
|
+
}
|
|
6090
7362
|
}
|
|
6091
7363
|
}
|
|
6092
7364
|
list.push(shortcut);
|
|
@@ -6097,13 +7369,15 @@ var __WulfIIFE = (() => {
|
|
|
6097
7369
|
if (step.ctrl !== eventStep.ctrl) return false;
|
|
6098
7370
|
if (step.alt !== eventStep.alt) return false;
|
|
6099
7371
|
if (step.meta !== eventStep.meta) return false;
|
|
6100
|
-
const
|
|
7372
|
+
const rawKey = typeof rawEvent?.key === "string" ? rawEvent.key : "";
|
|
7373
|
+
const keyMatches = step.key === eventStep.key || rawKey !== "" && step.key === rawKey.toLowerCase();
|
|
6101
7374
|
if (!keyMatches) return false;
|
|
6102
7375
|
if (step.shift === eventStep.shift) {
|
|
6103
7376
|
return true;
|
|
6104
7377
|
}
|
|
6105
7378
|
if (!step.shift && eventStep.shift) {
|
|
6106
|
-
|
|
7379
|
+
const isNonAlphaSymbol = step.key.length === 1 && !/^[a-z]$/i.test(step.key);
|
|
7380
|
+
if (rawKey !== "" && rawKey === step.key || isNonAlphaSymbol && eventStep.key === step.key) {
|
|
6107
7381
|
return true;
|
|
6108
7382
|
}
|
|
6109
7383
|
}
|
|
@@ -6199,16 +7473,14 @@ var __WulfIIFE = (() => {
|
|
|
6199
7473
|
};
|
|
6200
7474
|
|
|
6201
7475
|
// src/shortcut/index.ts
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
win.Wulf = wulfNamespace;
|
|
6206
|
-
wulfNamespace.Shortcut = Object.assign(ShortcutManager, {
|
|
7476
|
+
var wulfNamespace6 = getSafeWulfNamespace();
|
|
7477
|
+
if (wulfNamespace6) {
|
|
7478
|
+
wulfNamespace6.Shortcut = Object.assign(ShortcutManager, {
|
|
6207
7479
|
ShortcutManager,
|
|
6208
7480
|
ShortcutFormatter
|
|
6209
7481
|
});
|
|
6210
7482
|
}
|
|
6211
7483
|
return __toCommonJS(index_exports);
|
|
6212
7484
|
})();
|
|
6213
|
-
if (typeof window !== "undefined") {
|
|
7485
|
+
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 (__) {} } } } } }
|
|
6214
7486
|
//# sourceMappingURL=index.global.js.map
|