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.esm.js
CHANGED
|
@@ -21,6 +21,109 @@ __export(mask_exports, {
|
|
|
21
21
|
resolveMaskConstructorArgs: () => resolveMaskConstructorArgs
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
+
// src/common/dom.ts
|
|
25
|
+
function getSafeWulfNamespace() {
|
|
26
|
+
if (typeof window === "undefined") return null;
|
|
27
|
+
const win = window;
|
|
28
|
+
const existing = win.Wulf;
|
|
29
|
+
if (!existing || typeof existing !== "object" || typeof Node !== "undefined" && existing instanceof Node || typeof HTMLCollection !== "undefined" && existing instanceof HTMLCollection) {
|
|
30
|
+
const fresh = {};
|
|
31
|
+
win.Wulf = fresh;
|
|
32
|
+
return fresh;
|
|
33
|
+
}
|
|
34
|
+
return existing;
|
|
35
|
+
}
|
|
36
|
+
function safeCssEscape(value) {
|
|
37
|
+
if (typeof CSS !== "undefined" && typeof CSS.escape === "function") {
|
|
38
|
+
return CSS.escape(value);
|
|
39
|
+
}
|
|
40
|
+
return String(value).replace(/["\\\u0000-\u001F\u007F]/g, "\\$&");
|
|
41
|
+
}
|
|
42
|
+
function getDeepActiveElement(root) {
|
|
43
|
+
if (typeof document === "undefined") return null;
|
|
44
|
+
let active = (root ?? document).activeElement;
|
|
45
|
+
while (active && active.shadowRoot && active.shadowRoot.activeElement) {
|
|
46
|
+
active = active.shadowRoot.activeElement;
|
|
47
|
+
}
|
|
48
|
+
return active && typeof active.focus === "function" ? active : null;
|
|
49
|
+
}
|
|
50
|
+
function safeMove(parent, node, referenceNode = null) {
|
|
51
|
+
const moveBefore = parent.moveBefore;
|
|
52
|
+
if (typeof moveBefore === "function" && node.isConnected && parent.isConnected && typeof parent.getRootNode === "function" && typeof node.getRootNode === "function" && parent.getRootNode() === node.getRootNode()) {
|
|
53
|
+
try {
|
|
54
|
+
moveBefore.call(parent, node, referenceNode);
|
|
55
|
+
return;
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
parent.insertBefore(node, referenceNode);
|
|
60
|
+
}
|
|
61
|
+
function isImeComposing(event) {
|
|
62
|
+
return Boolean(
|
|
63
|
+
event.isComposing || event.key === "Process" || event.key === "Enter" && event.keyCode === 229
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
function parseCssDurationMs(duration, fallbackMs = 300, maxMs = 6e4) {
|
|
67
|
+
const safeFallback = Number.isFinite(fallbackMs) && fallbackMs >= 0 ? Math.min(fallbackMs, maxMs) : 300;
|
|
68
|
+
if (typeof duration === "number") {
|
|
69
|
+
return Number.isFinite(duration) && duration >= 0 ? Math.min(duration, maxMs) : safeFallback;
|
|
70
|
+
}
|
|
71
|
+
if (typeof duration === "string") {
|
|
72
|
+
const parts = duration.split(",");
|
|
73
|
+
let maxParsed = -1;
|
|
74
|
+
for (const part of parts) {
|
|
75
|
+
const match = /^\+?(\d+(?:\.\d+)?|\.\d+)(ms|s)?$/i.exec(part.trim());
|
|
76
|
+
if (match) {
|
|
77
|
+
const raw = parseFloat(match[1]);
|
|
78
|
+
if (Number.isFinite(raw) && raw >= 0) {
|
|
79
|
+
const ms = match[2]?.toLowerCase() === "s" ? raw * 1e3 : raw;
|
|
80
|
+
if (ms > maxParsed) {
|
|
81
|
+
maxParsed = ms;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (maxParsed >= 0) {
|
|
87
|
+
return Math.min(maxParsed, maxMs);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return safeFallback;
|
|
91
|
+
}
|
|
92
|
+
function prefersReducedMotion() {
|
|
93
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
94
|
+
}
|
|
95
|
+
function waitForAnimations(element, fallbackMs, signal) {
|
|
96
|
+
const safeFallback = Number.isFinite(fallbackMs) ? Math.min(fallbackMs, 6e4) : 300;
|
|
97
|
+
if (signal?.aborted || safeFallback <= 0 || prefersReducedMotion()) {
|
|
98
|
+
return Promise.resolve();
|
|
99
|
+
}
|
|
100
|
+
const animations = typeof element.getAnimations === "function" ? element.getAnimations().filter((a) => {
|
|
101
|
+
if (a.playState !== "running") return false;
|
|
102
|
+
const timing = a.effect?.getComputedTiming?.();
|
|
103
|
+
return timing ? Number.isFinite(timing.endTime) : true;
|
|
104
|
+
}) : [];
|
|
105
|
+
if (animations.length === 0) {
|
|
106
|
+
return Promise.resolve();
|
|
107
|
+
}
|
|
108
|
+
return new Promise((resolve) => {
|
|
109
|
+
let settled = false;
|
|
110
|
+
let timerId = null;
|
|
111
|
+
const finish = () => {
|
|
112
|
+
if (settled) return;
|
|
113
|
+
settled = true;
|
|
114
|
+
if (timerId !== null) {
|
|
115
|
+
clearTimeout(timerId);
|
|
116
|
+
timerId = null;
|
|
117
|
+
}
|
|
118
|
+
signal?.removeEventListener("abort", finish);
|
|
119
|
+
resolve();
|
|
120
|
+
};
|
|
121
|
+
signal?.addEventListener("abort", finish, { once: true });
|
|
122
|
+
timerId = setTimeout(finish, safeFallback);
|
|
123
|
+
Promise.allSettled(animations.map((a) => a.finished)).then(finish);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
24
127
|
// src/common/AuditableComponent.ts
|
|
25
128
|
var AuditableComponent = class {
|
|
26
129
|
/**
|
|
@@ -53,8 +156,11 @@ var AuditableComponent = class {
|
|
|
53
156
|
const rawValue = element.getAttribute(attrName)?.trim();
|
|
54
157
|
if (!rawValue) return false;
|
|
55
158
|
const doc = element.ownerDocument || document;
|
|
159
|
+
const root = typeof element.getRootNode === "function" ? element.getRootNode() : doc;
|
|
56
160
|
const ids = rawValue.split(/\s+/).filter(Boolean);
|
|
57
|
-
const isValid = ids.length > 0 && ids.every(
|
|
161
|
+
const isValid = ids.length > 0 && ids.every(
|
|
162
|
+
(id) => Boolean(typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.getElementById(id) : doc.getElementById(id))
|
|
163
|
+
);
|
|
58
164
|
if (!isValid) {
|
|
59
165
|
warnings.push(
|
|
60
166
|
`Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`
|
|
@@ -65,6 +171,7 @@ var AuditableComponent = class {
|
|
|
65
171
|
};
|
|
66
172
|
|
|
67
173
|
// src/mask/BaseInputMask.ts
|
|
174
|
+
var VALID_ALIGNS = /* @__PURE__ */ new Set(["left", "right", "center"]);
|
|
68
175
|
function resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOptions) {
|
|
69
176
|
const isSecondArgInput = Boolean(
|
|
70
177
|
inputOrOptions && typeof inputOrOptions === "object" && "tagName" in inputOrOptions && inputOrOptions.tagName === "INPUT"
|
|
@@ -83,59 +190,27 @@ function resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOption
|
|
|
83
190
|
};
|
|
84
191
|
}
|
|
85
192
|
var BaseInputMask = class extends AuditableComponent {
|
|
193
|
+
wrapper;
|
|
194
|
+
input;
|
|
195
|
+
options;
|
|
196
|
+
ghost = null;
|
|
197
|
+
isWrapperCreated = false;
|
|
198
|
+
wasWrapperFallbackStyled = false;
|
|
199
|
+
wasAlignSet = false;
|
|
200
|
+
hadInitialDataAlign = false;
|
|
201
|
+
isDestroyed = false;
|
|
202
|
+
isFocused = false;
|
|
203
|
+
isDispatchingNativeInput = false;
|
|
204
|
+
lastTrackedValue = "";
|
|
205
|
+
nativeValueDescriptor = null;
|
|
206
|
+
onCutHandler = () => {
|
|
207
|
+
};
|
|
208
|
+
onFormResetHandler;
|
|
209
|
+
mutationObserver = null;
|
|
210
|
+
focusSelectTimerId = null;
|
|
211
|
+
abortController = new AbortController();
|
|
86
212
|
constructor(targetOrWrapper, inputOrOptions, maybeOptions) {
|
|
87
213
|
super();
|
|
88
|
-
this.ghost = null;
|
|
89
|
-
this.isWrapperCreated = false;
|
|
90
|
-
this.isDestroyed = false;
|
|
91
|
-
this.isFocused = false;
|
|
92
|
-
this.isDispatchingNativeInput = false;
|
|
93
|
-
this.lastTrackedValue = "";
|
|
94
|
-
this.nativeValueDescriptor = null;
|
|
95
|
-
this.onCutHandler = () => {
|
|
96
|
-
};
|
|
97
|
-
this.mutationObserver = null;
|
|
98
|
-
this.focusSelectTimerId = null;
|
|
99
|
-
this.onBaseCopy = (e) => {
|
|
100
|
-
if (!this.options.copyRaw || this.options.disabled || this.input.type === "password") return;
|
|
101
|
-
const start = this.input.selectionStart ?? 0;
|
|
102
|
-
const end = this.input.selectionEnd ?? start;
|
|
103
|
-
let textToCopy = "";
|
|
104
|
-
if (start !== end) {
|
|
105
|
-
textToCopy = this.extractRawSnippet(this.input.value.slice(start, end));
|
|
106
|
-
} else {
|
|
107
|
-
textToCopy = this.getRawValue();
|
|
108
|
-
}
|
|
109
|
-
if (textToCopy && e.clipboardData) {
|
|
110
|
-
e.preventDefault();
|
|
111
|
-
e.clipboardData.setData("text/plain", textToCopy);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
this.onBaseFocus = () => {
|
|
115
|
-
this.isFocused = true;
|
|
116
|
-
if (this.options.selectAllOnFocus && this.input.value.length > 0) {
|
|
117
|
-
if (this.focusSelectTimerId !== null) {
|
|
118
|
-
clearTimeout(this.focusSelectTimerId);
|
|
119
|
-
}
|
|
120
|
-
this.focusSelectTimerId = window.setTimeout(() => {
|
|
121
|
-
this.focusSelectTimerId = null;
|
|
122
|
-
if (!this.isDestroyed && document.activeElement === this.input) {
|
|
123
|
-
this.input.select();
|
|
124
|
-
}
|
|
125
|
-
}, 0);
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
this.onBaseBlur = () => {
|
|
129
|
-
this.isFocused = false;
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* Synchronise le défilement horizontal du ghost avec celui du champ d'entrée natif.
|
|
133
|
-
*/
|
|
134
|
-
this.onScroll = () => {
|
|
135
|
-
if (this.ghost) {
|
|
136
|
-
this.ghost.scrollLeft = this.input.scrollLeft;
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
214
|
const { wrapper: providedWrapper, input, options } = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOptions);
|
|
140
215
|
if (!input || typeof input !== "object" || input.nodeType !== 1 || input.tagName !== "INPUT") {
|
|
141
216
|
throw new Error(`[${new.target.name || "InputMask"}] input (HTMLInputElement) est requis.`);
|
|
@@ -145,20 +220,26 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
145
220
|
const shouldCreateWrapper = Boolean(options.createWrapper ?? dataCreateWrapper);
|
|
146
221
|
let effectiveWrapper = providedWrapper;
|
|
147
222
|
if (!effectiveWrapper && shouldCreateWrapper) {
|
|
148
|
-
const
|
|
223
|
+
const doc = this.input.ownerDocument || document;
|
|
224
|
+
const span = doc.createElement("span");
|
|
149
225
|
span.className = "wulf-mask-wrapper";
|
|
150
|
-
span.style.display = "inline-grid";
|
|
151
|
-
span.style.gridTemplateColumns = "1fr";
|
|
152
|
-
span.style.gridTemplateRows = "1fr";
|
|
153
|
-
span.style.verticalAlign = "middle";
|
|
154
|
-
span.style.boxSizing = "border-box";
|
|
155
|
-
span.style.position = "relative";
|
|
156
226
|
if (this.input.parentNode) {
|
|
157
227
|
this.input.parentNode.insertBefore(span, this.input);
|
|
158
228
|
}
|
|
159
|
-
span
|
|
160
|
-
|
|
161
|
-
|
|
229
|
+
safeMove(span, this.input, null);
|
|
230
|
+
const view = doc.defaultView || (typeof window !== "undefined" ? window : null);
|
|
231
|
+
const needsFallbackStyles = !span.isConnected || !view || view.getComputedStyle(span).display !== "inline-grid";
|
|
232
|
+
if (needsFallbackStyles) {
|
|
233
|
+
span.style.display = "inline-grid";
|
|
234
|
+
span.style.gridTemplateColumns = "1fr";
|
|
235
|
+
span.style.gridTemplateRows = "1fr";
|
|
236
|
+
span.style.verticalAlign = "middle";
|
|
237
|
+
span.style.boxSizing = "border-box";
|
|
238
|
+
span.style.position = "relative";
|
|
239
|
+
this.input.style.gridArea = "1 / 1 / 2 / 2";
|
|
240
|
+
this.input.style.boxSizing = "border-box";
|
|
241
|
+
this.wasWrapperFallbackStyled = true;
|
|
242
|
+
}
|
|
162
243
|
effectiveWrapper = span;
|
|
163
244
|
this.isWrapperCreated = true;
|
|
164
245
|
}
|
|
@@ -171,12 +252,15 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
171
252
|
const dataDisabled = this.hasAttr("data-disabled");
|
|
172
253
|
const dataSelectAll = this.getAttr("data-mask-select-on-focus") === "true";
|
|
173
254
|
const dataCopyRaw = this.getAttr("data-mask-copy-raw") === "true";
|
|
174
|
-
const
|
|
255
|
+
const rawDataAlign = this.getAttr("data-mask-align") || this.getAttr("data-align");
|
|
256
|
+
const dataAlign = rawDataAlign && VALID_ALIGNS.has(rawDataAlign) ? rawDataAlign : null;
|
|
257
|
+
this.hadInitialDataAlign = this.wrapper.hasAttribute("data-align");
|
|
175
258
|
const dataAudit = this.getAttr("data-mask-audit");
|
|
176
259
|
const { disabled: optDisabled, align: optAlign, ...otherOptions } = options;
|
|
260
|
+
const validOptAlign = optAlign && VALID_ALIGNS.has(optAlign) ? optAlign : void 0;
|
|
177
261
|
const resolvedDisabled = optDisabled !== void 0 ? optDisabled : dataDisabled ? true : false;
|
|
178
262
|
const resolvedAudit = options.audit ?? (dataAudit !== null ? dataAudit !== "false" : true);
|
|
179
|
-
const isPassword = this.
|
|
263
|
+
const isPassword = this.isPasswordInput();
|
|
180
264
|
this.options = {
|
|
181
265
|
...otherOptions,
|
|
182
266
|
createWrapper: shouldCreateWrapper,
|
|
@@ -184,7 +268,7 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
184
268
|
selectAllOnFocus: options.selectAllOnFocus ?? dataSelectAll ?? false,
|
|
185
269
|
copyRaw: isPassword ? false : options.copyRaw ?? dataCopyRaw ?? false,
|
|
186
270
|
disabled: resolvedDisabled,
|
|
187
|
-
align:
|
|
271
|
+
align: validOptAlign ?? (dataAlign || void 0),
|
|
188
272
|
emitNativeInput: options.emitNativeInput ?? true,
|
|
189
273
|
audit: resolvedAudit
|
|
190
274
|
};
|
|
@@ -231,16 +315,54 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
231
315
|
* Attache les écouteurs de base pour focus/blur, copie brute et sélection.
|
|
232
316
|
*/
|
|
233
317
|
bindBaseEvents() {
|
|
234
|
-
|
|
235
|
-
this.input.addEventListener("
|
|
236
|
-
this.input.addEventListener("
|
|
318
|
+
const { signal } = this.abortController;
|
|
319
|
+
this.input.addEventListener("copy", this.onBaseCopy, { signal });
|
|
320
|
+
this.input.addEventListener("focus", this.onBaseFocus, { signal });
|
|
321
|
+
this.input.addEventListener("blur", this.onBaseBlur, { signal });
|
|
237
322
|
}
|
|
323
|
+
onBaseCopy = (e) => {
|
|
324
|
+
if (!this.options.copyRaw || this.options.disabled || this.input.type === "password") return;
|
|
325
|
+
const start = this.input.selectionStart ?? 0;
|
|
326
|
+
const end = this.input.selectionEnd ?? start;
|
|
327
|
+
let textToCopy = "";
|
|
328
|
+
if (start !== end) {
|
|
329
|
+
textToCopy = this.extractRawSnippet(this.input.value.slice(start, end));
|
|
330
|
+
} else {
|
|
331
|
+
textToCopy = this.getRawValue();
|
|
332
|
+
}
|
|
333
|
+
if (textToCopy && e.clipboardData) {
|
|
334
|
+
e.preventDefault();
|
|
335
|
+
e.clipboardData.setData("text/plain", textToCopy);
|
|
336
|
+
}
|
|
337
|
+
};
|
|
238
338
|
/**
|
|
239
339
|
* Extrait la valeur brute d'un extrait de chaîne sélectionné.
|
|
240
340
|
*/
|
|
241
341
|
extractRawSnippet(snippet) {
|
|
242
342
|
return snippet;
|
|
243
343
|
}
|
|
344
|
+
onBaseFocus = () => {
|
|
345
|
+
this.isFocused = true;
|
|
346
|
+
if (this.options.selectAllOnFocus && this.input.value.length > 0) {
|
|
347
|
+
if (this.focusSelectTimerId !== null) {
|
|
348
|
+
clearTimeout(this.focusSelectTimerId);
|
|
349
|
+
}
|
|
350
|
+
this.focusSelectTimerId = window.setTimeout(() => {
|
|
351
|
+
this.focusSelectTimerId = null;
|
|
352
|
+
if (!this.isDestroyed && document.activeElement === this.input) {
|
|
353
|
+
this.input.select();
|
|
354
|
+
}
|
|
355
|
+
}, 0);
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
onBaseBlur = () => {
|
|
359
|
+
this.isFocused = false;
|
|
360
|
+
if (this.isPasswordInput()) {
|
|
361
|
+
this.lastTrackedValue = "";
|
|
362
|
+
this.clearGhost();
|
|
363
|
+
this.wrapper.removeAttribute("data-mask");
|
|
364
|
+
}
|
|
365
|
+
};
|
|
244
366
|
/**
|
|
245
367
|
* Initialise l'observation des modifications dynamiques des attributs data-* et placeholder.
|
|
246
368
|
*/
|
|
@@ -279,21 +401,41 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
279
401
|
this.mutationObserver.observe(this.input, config);
|
|
280
402
|
}
|
|
281
403
|
}
|
|
404
|
+
/**
|
|
405
|
+
* Indique si le champ natif sous-jacent est de type mot de passe.
|
|
406
|
+
*/
|
|
407
|
+
isPasswordInput() {
|
|
408
|
+
return (this.input.type || "").toLowerCase() === "password";
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Calcule une empreinte non réversible pour détecter les changements sans conserver de secret en RAM.
|
|
412
|
+
*/
|
|
413
|
+
computePasswordDigest(val) {
|
|
414
|
+
let hash = 2166136261;
|
|
415
|
+
for (let i = 0; i < val.length; i++) {
|
|
416
|
+
hash ^= val.charCodeAt(i);
|
|
417
|
+
hash = Math.imul(hash, 16777619);
|
|
418
|
+
}
|
|
419
|
+
return `__pwd:${(hash >>> 0).toString(36)}:${val.length}`;
|
|
420
|
+
}
|
|
282
421
|
/**
|
|
283
422
|
* Modifie dynamiquement l'alignement du champ et du masque fantôme.
|
|
284
423
|
*/
|
|
285
424
|
setAlign(align) {
|
|
286
|
-
const
|
|
425
|
+
const normalized = align && VALID_ALIGNS.has(align) ? align : null;
|
|
426
|
+
const targetAlign = normalized || void 0;
|
|
287
427
|
const currentAttr = this.wrapper.getAttribute("data-align");
|
|
288
|
-
|
|
428
|
+
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");
|
|
429
|
+
if (this.options.align === targetAlign && currentAttr === normalized && hasExpectedClass) {
|
|
289
430
|
return;
|
|
290
431
|
}
|
|
291
432
|
this.options.align = targetAlign;
|
|
292
433
|
this.wrapper.classList.remove("align-left", "align-right", "align-center");
|
|
293
|
-
if (
|
|
294
|
-
this.wrapper.classList.add(`align-${
|
|
295
|
-
|
|
296
|
-
|
|
434
|
+
if (normalized) {
|
|
435
|
+
this.wrapper.classList.add(`align-${normalized}`);
|
|
436
|
+
this.wasAlignSet = true;
|
|
437
|
+
if (this.wrapper.getAttribute("data-align") !== normalized) {
|
|
438
|
+
this.wrapper.setAttribute("data-align", normalized);
|
|
297
439
|
}
|
|
298
440
|
} else {
|
|
299
441
|
if (this.wrapper.hasAttribute("data-align")) {
|
|
@@ -319,14 +461,18 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
319
461
|
} else if (attrName === "data-mask-select-on-focus") {
|
|
320
462
|
this.options.selectAllOnFocus = this.getAttr("data-mask-select-on-focus") === "true";
|
|
321
463
|
} else if (attrName === "data-mask-copy-raw") {
|
|
322
|
-
this.options.copyRaw = this.
|
|
464
|
+
this.options.copyRaw = this.isPasswordInput() ? false : this.getAttr("data-mask-copy-raw") === "true";
|
|
323
465
|
} else if (attrName === "type") {
|
|
324
|
-
if (this.
|
|
466
|
+
if (this.isPasswordInput()) {
|
|
325
467
|
this.options.copyRaw = false;
|
|
468
|
+
this.lastTrackedValue = "";
|
|
469
|
+
this.clearGhost();
|
|
470
|
+
this.wrapper.removeAttribute("data-mask");
|
|
326
471
|
this.onPasswordModeDetected();
|
|
327
472
|
}
|
|
328
473
|
} else if (attrName === "data-mask-align" || attrName === "data-align") {
|
|
329
|
-
const
|
|
474
|
+
const rawAlign = this.getAttr("data-mask-align") || this.getAttr("data-align");
|
|
475
|
+
const align = rawAlign && VALID_ALIGNS.has(rawAlign) ? rawAlign : null;
|
|
330
476
|
if (align !== (this.options.align ?? null)) {
|
|
331
477
|
this.setAlign(align);
|
|
332
478
|
}
|
|
@@ -354,15 +500,42 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
354
500
|
if (existing) {
|
|
355
501
|
existing.remove();
|
|
356
502
|
}
|
|
357
|
-
this.
|
|
503
|
+
const doc = this.input.ownerDocument || document;
|
|
504
|
+
this.ghost = doc.createElement("div");
|
|
358
505
|
this.ghost.className = "mask-ghost";
|
|
359
506
|
this.ghost.setAttribute("aria-hidden", "true");
|
|
360
507
|
this.ghost.style.display = "flex";
|
|
361
508
|
this.ghost.style.alignItems = "center";
|
|
362
509
|
this.wrapper.appendChild(this.ghost);
|
|
363
510
|
this.wrapper.classList.add("has-ghost");
|
|
511
|
+
const view = doc.defaultView || (typeof window !== "undefined" ? window : null);
|
|
512
|
+
if (!this.wrapper.isConnected || !view || view.getComputedStyle(this.ghost).pointerEvents !== "none") {
|
|
513
|
+
this.ghost.style.gridArea = "1 / 1 / 2 / 2";
|
|
514
|
+
this.ghost.style.pointerEvents = "none";
|
|
515
|
+
}
|
|
364
516
|
this.syncGhostStyles();
|
|
365
517
|
}
|
|
518
|
+
/**
|
|
519
|
+
* Met à jour atomiquement le contenu du conteneur fantôme et synchronise .has-visible-ghost.
|
|
520
|
+
*/
|
|
521
|
+
setGhostContent(...nodes) {
|
|
522
|
+
if (!this.ghost) return;
|
|
523
|
+
if (typeof this.ghost.replaceChildren === "function") {
|
|
524
|
+
this.ghost.replaceChildren(...nodes);
|
|
525
|
+
} else {
|
|
526
|
+
this.ghost.textContent = "";
|
|
527
|
+
for (const n of nodes) {
|
|
528
|
+
this.ghost.appendChild(typeof n === "string" ? document.createTextNode(n) : n);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
this.wrapper.classList.toggle("has-visible-ghost", nodes.length > 0);
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Vide atomiquement le conteneur fantôme et rétablit l'affichage du placeholder natif.
|
|
535
|
+
*/
|
|
536
|
+
clearGhost() {
|
|
537
|
+
this.setGhostContent();
|
|
538
|
+
}
|
|
366
539
|
/**
|
|
367
540
|
* Clone fidèlement la géométrie typographique et les espacements de l'input natif
|
|
368
541
|
* sur le conteneur fantôme pour garantir un alignement sub-pixel absolu quel que soit
|
|
@@ -395,12 +568,17 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
395
568
|
this.ghost.style.textAlign = style.textAlign;
|
|
396
569
|
this.ghost.style.direction = style.direction;
|
|
397
570
|
const isRtl = style.direction === "rtl" || this.input.getAttribute("dir") === "rtl" || this.wrapper.getAttribute("dir") === "rtl";
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
571
|
+
const textAlign = style.textAlign;
|
|
572
|
+
if (textAlign === "right") {
|
|
573
|
+
this.ghost.style.justifyContent = "right";
|
|
574
|
+
} else if (textAlign === "left") {
|
|
575
|
+
this.ghost.style.justifyContent = "left";
|
|
576
|
+
} else if (textAlign === "center") {
|
|
401
577
|
this.ghost.style.justifyContent = "center";
|
|
578
|
+
} else if (textAlign === "end") {
|
|
579
|
+
this.ghost.style.justifyContent = isRtl ? "left" : "right";
|
|
402
580
|
} else {
|
|
403
|
-
this.ghost.style.justifyContent = "
|
|
581
|
+
this.ghost.style.justifyContent = isRtl ? "right" : "left";
|
|
404
582
|
}
|
|
405
583
|
}
|
|
406
584
|
/**
|
|
@@ -424,15 +602,23 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
424
602
|
this.isDispatchingNativeInput = true;
|
|
425
603
|
try {
|
|
426
604
|
const tracker = this.input._valueTracker;
|
|
427
|
-
if (tracker && typeof tracker.setValue === "function") {
|
|
605
|
+
if (!this.isPasswordInput() && tracker && typeof tracker.setValue === "function") {
|
|
428
606
|
tracker.setValue(this.lastTrackedValue);
|
|
429
607
|
}
|
|
430
|
-
this.lastTrackedValue = this.input.value;
|
|
608
|
+
this.lastTrackedValue = this.isPasswordInput() ? "" : this.input.value;
|
|
431
609
|
this.input.dispatchEvent(new Event("input", { bubbles: true, cancelable: false }));
|
|
432
610
|
} finally {
|
|
433
611
|
this.isDispatchingNativeInput = false;
|
|
434
612
|
}
|
|
435
613
|
}
|
|
614
|
+
/**
|
|
615
|
+
* Synchronise le défilement horizontal du ghost avec celui du champ d'entrée natif.
|
|
616
|
+
*/
|
|
617
|
+
onScroll = () => {
|
|
618
|
+
if (this.ghost) {
|
|
619
|
+
this.ghost.scrollLeft = this.input.scrollLeft;
|
|
620
|
+
}
|
|
621
|
+
};
|
|
436
622
|
/**
|
|
437
623
|
* Intercepte les modifications directes de la propriété input.value (ex: input.value = '').
|
|
438
624
|
*/
|
|
@@ -544,15 +730,19 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
544
730
|
audit() {
|
|
545
731
|
const warnings = [];
|
|
546
732
|
const doc = this.input.ownerDocument || document;
|
|
733
|
+
const root = typeof this.input.getRootNode === "function" ? this.input.getRootNode() : doc;
|
|
734
|
+
const labelRoot = typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root : doc;
|
|
547
735
|
const ariaLabel = this.input.getAttribute("aria-label")?.trim();
|
|
548
736
|
const hasValidLabelledby = this.checkAriaIdReferences(this.input, "aria-labelledby", warnings);
|
|
549
737
|
const hasWrappingLabel = Boolean(this.input.closest("label"));
|
|
550
738
|
const hasNativeLabels = Boolean(this.input.labels && this.input.labels.length > 0);
|
|
551
739
|
let hasExplicitLabelFor = false;
|
|
552
|
-
if (this.input.id
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
740
|
+
if (this.input.id) {
|
|
741
|
+
try {
|
|
742
|
+
hasExplicitLabelFor = Boolean(labelRoot.querySelector(`label[for="${safeCssEscape(this.input.id)}"]`));
|
|
743
|
+
} catch {
|
|
744
|
+
hasExplicitLabelFor = false;
|
|
745
|
+
}
|
|
556
746
|
}
|
|
557
747
|
if (!ariaLabel && !hasValidLabelledby && !hasWrappingLabel && !hasNativeLabels && !hasExplicitLabelFor) {
|
|
558
748
|
warnings.push(
|
|
@@ -598,25 +788,41 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
598
788
|
this.mutationObserver.disconnect();
|
|
599
789
|
this.mutationObserver = null;
|
|
600
790
|
}
|
|
601
|
-
this.
|
|
602
|
-
this.
|
|
603
|
-
this.input.removeEventListener("blur", this.onBaseBlur);
|
|
791
|
+
this.abortController.abort();
|
|
792
|
+
this.lastTrackedValue = "";
|
|
604
793
|
this.unhookValueProperty();
|
|
605
794
|
if (this.ghost) {
|
|
606
795
|
this.ghost.remove();
|
|
607
796
|
this.ghost = null;
|
|
608
797
|
}
|
|
609
798
|
if (this.isWrapperCreated && this.wrapper) {
|
|
610
|
-
this.
|
|
611
|
-
|
|
612
|
-
|
|
799
|
+
if (this.wasWrapperFallbackStyled) {
|
|
800
|
+
this.input.style.gridArea = "";
|
|
801
|
+
this.input.style.boxSizing = "";
|
|
802
|
+
}
|
|
803
|
+
if (this.wrapper.parentElement) {
|
|
804
|
+
safeMove(this.wrapper.parentElement, this.input, this.wrapper);
|
|
805
|
+
} else if (this.wrapper.parentNode) {
|
|
613
806
|
this.wrapper.parentNode.insertBefore(this.input, this.wrapper);
|
|
614
807
|
}
|
|
615
808
|
this.wrapper.remove();
|
|
616
809
|
} else if (this.wrapper) {
|
|
617
810
|
this.wrapper.removeAttribute("data-mask");
|
|
618
811
|
this.wrapper.removeAttribute("data-disabled");
|
|
619
|
-
this.
|
|
812
|
+
if (this.wasAlignSet && !this.hadInitialDataAlign) {
|
|
813
|
+
this.wrapper.removeAttribute("data-align");
|
|
814
|
+
}
|
|
815
|
+
if (this.wasAlignSet) {
|
|
816
|
+
this.wrapper.classList.remove("align-left", "align-right", "align-center");
|
|
817
|
+
}
|
|
818
|
+
this.wrapper.classList.remove(
|
|
819
|
+
"is-complete",
|
|
820
|
+
"is-focused",
|
|
821
|
+
"mask-focus-only",
|
|
822
|
+
"has-selection",
|
|
823
|
+
"has-ghost",
|
|
824
|
+
"has-visible-ghost"
|
|
825
|
+
);
|
|
620
826
|
}
|
|
621
827
|
}
|
|
622
828
|
};
|
|
@@ -630,19 +836,34 @@ var DEFAULT_TOKENS = {
|
|
|
630
836
|
"#": { pattern: /[a-zA-Z0-9]/, transform: (c) => c.toUpperCase() }
|
|
631
837
|
};
|
|
632
838
|
var MaskEngine = class _MaskEngine {
|
|
839
|
+
pattern;
|
|
840
|
+
patterns = [];
|
|
841
|
+
subEngines = [];
|
|
842
|
+
activeEngine = null;
|
|
843
|
+
placeholderChar;
|
|
844
|
+
tokens;
|
|
845
|
+
slots = [];
|
|
846
|
+
fullMaskTemplate = "";
|
|
847
|
+
prefixSlotsCount = 0;
|
|
848
|
+
prefixString = "";
|
|
849
|
+
strict = true;
|
|
850
|
+
autoLowercase = false;
|
|
633
851
|
constructor(pattern, options = {}) {
|
|
634
|
-
this.patterns = [];
|
|
635
|
-
this.subEngines = [];
|
|
636
|
-
this.activeEngine = null;
|
|
637
|
-
this.slots = [];
|
|
638
|
-
this.fullMaskTemplate = "";
|
|
639
|
-
this.prefixSlotsCount = 0;
|
|
640
|
-
this.prefixString = "";
|
|
641
|
-
this.strict = true;
|
|
642
|
-
this.autoLowercase = false;
|
|
643
852
|
const opts = options || {};
|
|
644
|
-
|
|
645
|
-
this.
|
|
853
|
+
const rawPlaceholder = String(opts.placeholderChar || "_");
|
|
854
|
+
this.placeholderChar = Array.from(rawPlaceholder)[0] || "_";
|
|
855
|
+
const tokenMap = /* @__PURE__ */ Object.create(null);
|
|
856
|
+
for (const [k, v] of Object.entries(DEFAULT_TOKENS)) {
|
|
857
|
+
tokenMap[k] = v;
|
|
858
|
+
}
|
|
859
|
+
if (opts.tokens && typeof opts.tokens === "object") {
|
|
860
|
+
for (const [k, v] of Object.entries(opts.tokens)) {
|
|
861
|
+
if (k !== "__proto__" && k !== "constructor" && k !== "prototype" && v) {
|
|
862
|
+
tokenMap[k] = v;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
this.tokens = tokenMap;
|
|
646
867
|
this.strict = opts.strict !== false;
|
|
647
868
|
this.autoLowercase = opts.autoLowercase ?? false;
|
|
648
869
|
this.pattern = "";
|
|
@@ -702,7 +923,7 @@ var MaskEngine = class _MaskEngine {
|
|
|
702
923
|
i++;
|
|
703
924
|
char = this.pattern[i];
|
|
704
925
|
}
|
|
705
|
-
const token = !isEscaped ? this.tokens[char] : void 0;
|
|
926
|
+
const token = !isEscaped && Object.hasOwn(this.tokens, char) ? this.tokens[char] : void 0;
|
|
706
927
|
if (token) {
|
|
707
928
|
isPrefixMode = false;
|
|
708
929
|
this.slots.push({
|
|
@@ -749,7 +970,7 @@ var MaskEngine = class _MaskEngine {
|
|
|
749
970
|
return p.length > 0 && trimmed.toLowerCase().startsWith(p.trim().toLowerCase());
|
|
750
971
|
});
|
|
751
972
|
const candidates = withMatchingPrefix.length > 0 ? withMatchingPrefix : this.subEngines;
|
|
752
|
-
const maxCandidate =
|
|
973
|
+
const maxCandidate = candidates.toSorted((a, b) => b.getEditableCount() - a.getEditableCount())[0];
|
|
753
974
|
const raw = maxCandidate ? maxCandidate.extractRaw(trimmed) : trimmed;
|
|
754
975
|
const rawLen = raw.length;
|
|
755
976
|
for (const eng of candidates) {
|
|
@@ -805,6 +1026,18 @@ var MaskEngine = class _MaskEngine {
|
|
|
805
1026
|
*/
|
|
806
1027
|
setStrict(strict) {
|
|
807
1028
|
this.strict = strict;
|
|
1029
|
+
for (const sub of this.subEngines) {
|
|
1030
|
+
sub.setStrict(strict);
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
/**
|
|
1034
|
+
* Active ou désactive dynamiquement la mise en minuscules automatique.
|
|
1035
|
+
*/
|
|
1036
|
+
setAutoLowercase(autoLowercase) {
|
|
1037
|
+
this.autoLowercase = autoLowercase;
|
|
1038
|
+
for (const sub of this.subEngines) {
|
|
1039
|
+
sub.setAutoLowercase(autoLowercase);
|
|
1040
|
+
}
|
|
808
1041
|
}
|
|
809
1042
|
/**
|
|
810
1043
|
* Indique si le masque est en mode strict.
|
|
@@ -1029,9 +1262,10 @@ var MaskEngine = class _MaskEngine {
|
|
|
1029
1262
|
|
|
1030
1263
|
// src/mask/MaskHistory.ts
|
|
1031
1264
|
var MaskHistory = class {
|
|
1265
|
+
stack = [];
|
|
1266
|
+
index = -1;
|
|
1267
|
+
maxDepth;
|
|
1032
1268
|
constructor(maxDepth = 50) {
|
|
1033
|
-
this.stack = [];
|
|
1034
|
-
this.index = -1;
|
|
1035
1269
|
this.maxDepth = maxDepth;
|
|
1036
1270
|
}
|
|
1037
1271
|
/**
|
|
@@ -1109,6 +1343,7 @@ var MaskHistory = class {
|
|
|
1109
1343
|
|
|
1110
1344
|
// src/mask/MaskKeyboard.ts
|
|
1111
1345
|
var MaskKeyboard = class {
|
|
1346
|
+
delegate;
|
|
1112
1347
|
constructor(delegate) {
|
|
1113
1348
|
this.delegate = delegate;
|
|
1114
1349
|
}
|
|
@@ -1116,6 +1351,7 @@ var MaskKeyboard = class {
|
|
|
1116
1351
|
* Analyse et traite l'événement keydown de l'input.
|
|
1117
1352
|
*/
|
|
1118
1353
|
handleKeyDown(e) {
|
|
1354
|
+
if (isImeComposing(e)) return;
|
|
1119
1355
|
const input = this.delegate.getInput();
|
|
1120
1356
|
const engine = this.delegate.getEngine();
|
|
1121
1357
|
const history = this.delegate.getHistory();
|
|
@@ -1209,7 +1445,7 @@ var MaskKeyboard = class {
|
|
|
1209
1445
|
input.setSelectionRange(minPos, minPos);
|
|
1210
1446
|
return;
|
|
1211
1447
|
}
|
|
1212
|
-
if (e.key === "Home" && !e.shiftKey) {
|
|
1448
|
+
if (e.key === "Home" && minPos > 0 && !e.shiftKey && !e.ctrlKey && !e.metaKey && !e.altKey) {
|
|
1213
1449
|
e.preventDefault();
|
|
1214
1450
|
input.setSelectionRange(minPos, minPos);
|
|
1215
1451
|
return;
|
|
@@ -1314,6 +1550,23 @@ var MaskKeyboard = class {
|
|
|
1314
1550
|
|
|
1315
1551
|
// src/mask/InputMask.ts
|
|
1316
1552
|
var InputMask = class extends BaseInputMask {
|
|
1553
|
+
engine;
|
|
1554
|
+
history;
|
|
1555
|
+
keyboard;
|
|
1556
|
+
isComposing = false;
|
|
1557
|
+
isUndoingRedoing = false;
|
|
1558
|
+
isMouseDown = false;
|
|
1559
|
+
isApplyingMask = false;
|
|
1560
|
+
lastValue = "";
|
|
1561
|
+
lastInternalRemainingMask = "";
|
|
1562
|
+
isNotifying = false;
|
|
1563
|
+
hasPendingNotification = false;
|
|
1564
|
+
onChangeNativeHandler = () => {
|
|
1565
|
+
};
|
|
1566
|
+
wasInputModeInferred = false;
|
|
1567
|
+
cutTimerId = null;
|
|
1568
|
+
pasteTimerId = null;
|
|
1569
|
+
resetTimerId = null;
|
|
1317
1570
|
constructor(targetOrWrapper, inputOrOptions, options) {
|
|
1318
1571
|
const args = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, options);
|
|
1319
1572
|
const wrap = args.wrapper;
|
|
@@ -1346,20 +1599,6 @@ var InputMask = class extends BaseInputMask {
|
|
|
1346
1599
|
onComplete: opts.onComplete || opts.oncomplete
|
|
1347
1600
|
};
|
|
1348
1601
|
super(wrap, inp, resolvedOptions);
|
|
1349
|
-
this.isComposing = false;
|
|
1350
|
-
this.isUndoingRedoing = false;
|
|
1351
|
-
this.isMouseDown = false;
|
|
1352
|
-
this.isApplyingMask = false;
|
|
1353
|
-
this.lastValue = "";
|
|
1354
|
-
this.lastInternalRemainingMask = "";
|
|
1355
|
-
this.isNotifying = false;
|
|
1356
|
-
this.hasPendingNotification = false;
|
|
1357
|
-
this.onChangeNativeHandler = () => {
|
|
1358
|
-
};
|
|
1359
|
-
this.wasInputModeInferred = false;
|
|
1360
|
-
this.cutTimerId = null;
|
|
1361
|
-
this.pasteTimerId = null;
|
|
1362
|
-
this.resetTimerId = null;
|
|
1363
1602
|
this.history = new MaskHistory();
|
|
1364
1603
|
this.engine = new MaskEngine(this.options.mask || "", {
|
|
1365
1604
|
placeholderChar: this.options.placeholderChar,
|
|
@@ -1378,16 +1617,17 @@ var InputMask = class extends BaseInputMask {
|
|
|
1378
1617
|
enforceMinCursor: () => this.enforceMinCursor()
|
|
1379
1618
|
});
|
|
1380
1619
|
this.bindEvents();
|
|
1381
|
-
this.lastValue = this.input.value;
|
|
1620
|
+
this.lastValue = this.isPasswordInput() ? this.computePasswordDigest(this.input.value) : this.input.value;
|
|
1382
1621
|
this.syncInitialValue();
|
|
1383
1622
|
this.runAuditWarning(this.options.audit);
|
|
1384
1623
|
}
|
|
1385
1624
|
getSpecificAuditWarnings() {
|
|
1386
1625
|
const warnings = [];
|
|
1387
|
-
const
|
|
1626
|
+
const describedbyWarnings = [];
|
|
1627
|
+
const hasValidDescribedby = this.checkAriaIdReferences(this.input, "aria-describedby", describedbyWarnings);
|
|
1388
1628
|
const hasPlaceholder = Boolean(this.input.getAttribute("placeholder")?.trim());
|
|
1389
1629
|
const hasAriaPlaceholder = Boolean(this.input.getAttribute("aria-placeholder")?.trim());
|
|
1390
|
-
if (!
|
|
1630
|
+
if (!hasValidDescribedby && !hasPlaceholder && !hasAriaPlaceholder && !this.options.disabled) {
|
|
1391
1631
|
warnings.push(
|
|
1392
1632
|
"Indication du format attendu manquante : d\xE9finissez aria-describedby, placeholder ou aria-placeholder pour informer les technologies d'assistance (WCAG 3.3.2)."
|
|
1393
1633
|
);
|
|
@@ -1399,6 +1639,11 @@ var InputMask = class extends BaseInputMask {
|
|
|
1399
1639
|
}
|
|
1400
1640
|
onPasswordModeDetected() {
|
|
1401
1641
|
this.history.clear();
|
|
1642
|
+
this.lastValue = "";
|
|
1643
|
+
this.lastInternalRemainingMask = "";
|
|
1644
|
+
this.lastTrackedValue = "";
|
|
1645
|
+
this.clearGhost();
|
|
1646
|
+
this.wrapper.removeAttribute("data-mask");
|
|
1402
1647
|
}
|
|
1403
1648
|
/**
|
|
1404
1649
|
* Formate statiquement une valeur selon un masque donné sans nécessiter d'élément DOM.
|
|
@@ -1422,11 +1667,12 @@ var InputMask = class extends BaseInputMask {
|
|
|
1422
1667
|
if (disabled) {
|
|
1423
1668
|
this.wrapper.removeAttribute("data-mask");
|
|
1424
1669
|
this.wrapper.classList.remove("is-complete", "has-selection");
|
|
1425
|
-
|
|
1670
|
+
this.clearGhost();
|
|
1426
1671
|
this.checkValueChange();
|
|
1427
1672
|
} else {
|
|
1428
1673
|
this.applyMask(this.input.value, this.input.selectionStart ?? this.input.value.length);
|
|
1429
1674
|
}
|
|
1675
|
+
this.syncInferredInputMode();
|
|
1430
1676
|
}
|
|
1431
1677
|
/**
|
|
1432
1678
|
* Associe les écouteurs d'événements nécessaires.
|
|
@@ -1463,22 +1709,23 @@ var InputMask = class extends BaseInputMask {
|
|
|
1463
1709
|
if (this.isDestroyed) return;
|
|
1464
1710
|
this.checkValueChange();
|
|
1465
1711
|
};
|
|
1466
|
-
|
|
1467
|
-
this.input.addEventListener("
|
|
1468
|
-
this.input.addEventListener("
|
|
1469
|
-
this.input.addEventListener("
|
|
1470
|
-
this.input.addEventListener("
|
|
1471
|
-
this.input.addEventListener("
|
|
1472
|
-
this.input.addEventListener("
|
|
1473
|
-
this.input.addEventListener("
|
|
1474
|
-
this.input.addEventListener("
|
|
1475
|
-
this.input.addEventListener("
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
this.input.addEventListener("
|
|
1479
|
-
this.input.addEventListener("
|
|
1480
|
-
this.input.addEventListener("
|
|
1481
|
-
this.input.addEventListener("
|
|
1712
|
+
const { signal } = this.abortController;
|
|
1713
|
+
this.input.addEventListener("beforeinput", this.onBeforeInput, { signal });
|
|
1714
|
+
this.input.addEventListener("input", this.handleInput, { signal });
|
|
1715
|
+
this.input.addEventListener("keydown", this.onKeyDown, { signal });
|
|
1716
|
+
this.input.addEventListener("paste", this.onPaste, { signal });
|
|
1717
|
+
this.input.addEventListener("focus", this.onFocus, { signal });
|
|
1718
|
+
this.input.addEventListener("blur", this.onBlur, { signal });
|
|
1719
|
+
this.input.addEventListener("click", this.onClick, { signal });
|
|
1720
|
+
this.input.addEventListener("keyup", this.onKeyUp, { signal });
|
|
1721
|
+
this.input.addEventListener("select", this.onSelect, { signal });
|
|
1722
|
+
this.input.addEventListener("mousedown", this.onMouseDown, { signal });
|
|
1723
|
+
window.addEventListener("mouseup", this.onMouseUp, { signal });
|
|
1724
|
+
this.input.addEventListener("compositionstart", this.onCompositionStart, { signal });
|
|
1725
|
+
this.input.addEventListener("compositionend", this.onCompositionEnd, { signal });
|
|
1726
|
+
this.input.addEventListener("scroll", this.onScroll, { passive: true, signal });
|
|
1727
|
+
this.input.addEventListener("cut", this.onCutHandler, { signal });
|
|
1728
|
+
this.input.addEventListener("change", this.onChangeNativeHandler, { signal });
|
|
1482
1729
|
if (this.input.form) {
|
|
1483
1730
|
this.onFormResetHandler = () => {
|
|
1484
1731
|
if (this.resetTimerId !== null) clearTimeout(this.resetTimerId);
|
|
@@ -1492,7 +1739,7 @@ var InputMask = class extends BaseInputMask {
|
|
|
1492
1739
|
}
|
|
1493
1740
|
}, 0);
|
|
1494
1741
|
};
|
|
1495
|
-
this.input.form.addEventListener("reset", this.onFormResetHandler);
|
|
1742
|
+
this.input.form.addEventListener("reset", this.onFormResetHandler, { signal });
|
|
1496
1743
|
}
|
|
1497
1744
|
}
|
|
1498
1745
|
/**
|
|
@@ -1529,29 +1776,12 @@ var InputMask = class extends BaseInputMask {
|
|
|
1529
1776
|
clearTimeout(this.resetTimerId);
|
|
1530
1777
|
this.resetTimerId = null;
|
|
1531
1778
|
}
|
|
1532
|
-
this.input.removeEventListener("beforeinput", this.onBeforeInput);
|
|
1533
|
-
this.input.removeEventListener("input", this.handleInput);
|
|
1534
|
-
this.input.removeEventListener("keydown", this.onKeyDown);
|
|
1535
|
-
this.input.removeEventListener("paste", this.onPaste);
|
|
1536
|
-
this.input.removeEventListener("focus", this.onFocus);
|
|
1537
|
-
this.input.removeEventListener("blur", this.onBlur);
|
|
1538
|
-
this.input.removeEventListener("click", this.onClick);
|
|
1539
|
-
this.input.removeEventListener("keyup", this.onKeyUp);
|
|
1540
|
-
this.input.removeEventListener("select", this.onSelect);
|
|
1541
|
-
this.input.removeEventListener("mousedown", this.onMouseDown);
|
|
1542
|
-
window.removeEventListener("mouseup", this.onMouseUp);
|
|
1543
|
-
this.input.removeEventListener("compositionstart", this.onCompositionStart);
|
|
1544
|
-
this.input.removeEventListener("compositionend", this.onCompositionEnd);
|
|
1545
|
-
this.input.removeEventListener("scroll", this.onScroll);
|
|
1546
|
-
this.input.removeEventListener("cut", this.onCutHandler);
|
|
1547
|
-
this.input.removeEventListener("change", this.onChangeNativeHandler);
|
|
1548
|
-
if (this.input.form && this.onFormResetHandler) {
|
|
1549
|
-
this.input.form.removeEventListener("reset", this.onFormResetHandler);
|
|
1550
|
-
}
|
|
1551
1779
|
if (this.wasInputModeInferred && this.input.getAttribute("inputmode") === "numeric") {
|
|
1552
1780
|
this.input.removeAttribute("inputmode");
|
|
1553
1781
|
}
|
|
1554
1782
|
this.history.clear();
|
|
1783
|
+
this.lastValue = "";
|
|
1784
|
+
this.lastInternalRemainingMask = "";
|
|
1555
1785
|
super.destroy();
|
|
1556
1786
|
}
|
|
1557
1787
|
/**
|
|
@@ -1625,6 +1855,7 @@ var InputMask = class extends BaseInputMask {
|
|
|
1625
1855
|
this.setStrict(strictVal !== "false");
|
|
1626
1856
|
} else if (attrName === "data-mask-auto-lowercase") {
|
|
1627
1857
|
this.options.autoLowercase = this.getAttr("data-mask-auto-lowercase") === "true";
|
|
1858
|
+
this.engine.setAutoLowercase(this.options.autoLowercase);
|
|
1628
1859
|
this.engine.compile(this.options.mask || "");
|
|
1629
1860
|
this.applyMask(this.input.value, this.input.selectionStart ?? this.input.value.length);
|
|
1630
1861
|
} else if (attrName === "placeholder") {
|
|
@@ -1704,7 +1935,7 @@ var InputMask = class extends BaseInputMask {
|
|
|
1704
1935
|
if (this.options.disabled) return;
|
|
1705
1936
|
if (this.isComposing) return;
|
|
1706
1937
|
if (!this.engine.isStrict()) return;
|
|
1707
|
-
if (e.inputType === "insertFromPaste") return;
|
|
1938
|
+
if (e.inputType === "insertFromPaste" || e.inputType === "insertReplacementText") return;
|
|
1708
1939
|
if (e.inputType && e.inputType.startsWith("insert")) {
|
|
1709
1940
|
const totalSlots = this.engine.getEditableCount();
|
|
1710
1941
|
if (totalSlots > 0) {
|
|
@@ -1726,7 +1957,8 @@ var InputMask = class extends BaseInputMask {
|
|
|
1726
1957
|
if (this.isDispatchingNativeInput) return;
|
|
1727
1958
|
if (this.isComposing) return;
|
|
1728
1959
|
const hasOnInput = Boolean(this.options.onInput || this.options.oninput);
|
|
1729
|
-
|
|
1960
|
+
const currentComparison = this.isPasswordInput() ? this.computePasswordDigest(this.input.value) : this.input.value;
|
|
1961
|
+
if (hasOnInput && currentComparison !== this.lastValue) {
|
|
1730
1962
|
this.checkValueChange();
|
|
1731
1963
|
}
|
|
1732
1964
|
if (this.options.disabled) {
|
|
@@ -1820,8 +2052,14 @@ var InputMask = class extends BaseInputMask {
|
|
|
1820
2052
|
}
|
|
1821
2053
|
onBlur() {
|
|
1822
2054
|
this.wrapper.classList.remove("is-focused", "has-selection");
|
|
1823
|
-
if (this.
|
|
2055
|
+
if (this.isPasswordInput()) {
|
|
1824
2056
|
this.history.clear();
|
|
2057
|
+
this.lastValue = "";
|
|
2058
|
+
this.lastInternalRemainingMask = "";
|
|
2059
|
+
this.lastTrackedValue = "";
|
|
2060
|
+
this.clearGhost();
|
|
2061
|
+
this.wrapper.removeAttribute("data-mask");
|
|
2062
|
+
return;
|
|
1825
2063
|
}
|
|
1826
2064
|
this.updateGhost(this.input.value);
|
|
1827
2065
|
}
|
|
@@ -1875,26 +2113,25 @@ var InputMask = class extends BaseInputMask {
|
|
|
1875
2113
|
// ==========================================================================
|
|
1876
2114
|
updateGhost(formatted) {
|
|
1877
2115
|
if (!this.ghost) return;
|
|
1878
|
-
if (this.options.disabled) {
|
|
1879
|
-
this.
|
|
2116
|
+
if (this.options.disabled || this.isPasswordInput()) {
|
|
2117
|
+
this.clearGhost();
|
|
1880
2118
|
return;
|
|
1881
2119
|
}
|
|
1882
2120
|
const isCleanEmpty = !formatted || formatted === this.engine.getPrefix();
|
|
1883
2121
|
if (this.shouldHideGhostForPlaceholder(isCleanEmpty)) {
|
|
1884
|
-
this.
|
|
2122
|
+
this.clearGhost();
|
|
1885
2123
|
return;
|
|
1886
2124
|
}
|
|
1887
2125
|
const fullTemplate = this.engine.getFullMaskTemplate();
|
|
1888
2126
|
const rest = fullTemplate.length > formatted.length ? fullTemplate.substring(formatted.length) : "";
|
|
1889
|
-
this.
|
|
1890
|
-
const spanTyped =
|
|
2127
|
+
const doc = this.input.ownerDocument || document;
|
|
2128
|
+
const spanTyped = doc.createElement("span");
|
|
1891
2129
|
spanTyped.className = "mask-ghost-typed";
|
|
1892
2130
|
spanTyped.textContent = formatted;
|
|
1893
|
-
const spanRemaining =
|
|
2131
|
+
const spanRemaining = doc.createElement("span");
|
|
1894
2132
|
spanRemaining.className = "mask-ghost-remaining";
|
|
1895
2133
|
spanRemaining.textContent = rest;
|
|
1896
|
-
this.
|
|
1897
|
-
this.ghost.appendChild(spanRemaining);
|
|
2134
|
+
this.setGhostContent(spanTyped, spanRemaining);
|
|
1898
2135
|
this.ghost.scrollLeft = this.input.scrollLeft;
|
|
1899
2136
|
}
|
|
1900
2137
|
applyMask(rawOrPartial, cursorPosition, forceExactCursor = false) {
|
|
@@ -1905,10 +2142,17 @@ var InputMask = class extends BaseInputMask {
|
|
|
1905
2142
|
try {
|
|
1906
2143
|
formatted = this.engine.format(rawOrPartial);
|
|
1907
2144
|
const remainingMask = this.engine.getRemainingMask(formatted);
|
|
2145
|
+
const isPwd = this.isPasswordInput();
|
|
1908
2146
|
this.input.value = formatted;
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
2147
|
+
if (isPwd) {
|
|
2148
|
+
this.lastInternalRemainingMask = "";
|
|
2149
|
+
this.wrapper.removeAttribute("data-mask");
|
|
2150
|
+
this.clearGhost();
|
|
2151
|
+
} else {
|
|
2152
|
+
this.lastInternalRemainingMask = remainingMask;
|
|
2153
|
+
this.wrapper.setAttribute("data-mask", remainingMask);
|
|
2154
|
+
this.updateGhost(formatted);
|
|
2155
|
+
}
|
|
1912
2156
|
const minPos = this.engine.getPrefixLength();
|
|
1913
2157
|
let safeCursor;
|
|
1914
2158
|
if (forceExactCursor || this.isUndoingRedoing) {
|
|
@@ -1920,7 +2164,7 @@ var InputMask = class extends BaseInputMask {
|
|
|
1920
2164
|
this.input.setSelectionRange(safeCursor, safeCursor);
|
|
1921
2165
|
isCompleted = this.isComplete();
|
|
1922
2166
|
this.wrapper.classList.toggle("is-complete", isCompleted);
|
|
1923
|
-
if (
|
|
2167
|
+
if (isPwd) {
|
|
1924
2168
|
this.options.copyRaw = false;
|
|
1925
2169
|
this.history.clear();
|
|
1926
2170
|
} else if (!this.isUndoingRedoing) {
|
|
@@ -1932,10 +2176,11 @@ var InputMask = class extends BaseInputMask {
|
|
|
1932
2176
|
this.checkValueChange();
|
|
1933
2177
|
}
|
|
1934
2178
|
syncInitialValue() {
|
|
2179
|
+
const isPwd = this.isPasswordInput();
|
|
1935
2180
|
if (this.options.disabled) {
|
|
1936
2181
|
this.wrapper.removeAttribute("data-mask");
|
|
1937
|
-
|
|
1938
|
-
this.lastValue = this.input.value;
|
|
2182
|
+
this.clearGhost();
|
|
2183
|
+
this.lastValue = isPwd ? this.computePasswordDigest(this.input.value) : this.input.value;
|
|
1939
2184
|
this.checkValueChange();
|
|
1940
2185
|
return;
|
|
1941
2186
|
}
|
|
@@ -1948,13 +2193,17 @@ var InputMask = class extends BaseInputMask {
|
|
|
1948
2193
|
if (minPos > 0) {
|
|
1949
2194
|
this.applyMask("", minPos);
|
|
1950
2195
|
} else {
|
|
1951
|
-
if (
|
|
2196
|
+
if (!isPwd) {
|
|
1952
2197
|
this.history.push("", 0);
|
|
2198
|
+
const fullTemplate = this.engine.getFullMaskTemplate();
|
|
2199
|
+
this.lastInternalRemainingMask = fullTemplate;
|
|
2200
|
+
this.wrapper.setAttribute("data-mask", fullTemplate);
|
|
2201
|
+
this.updateGhost("");
|
|
2202
|
+
} else {
|
|
2203
|
+
this.lastInternalRemainingMask = "";
|
|
2204
|
+
this.wrapper.removeAttribute("data-mask");
|
|
2205
|
+
this.clearGhost();
|
|
1953
2206
|
}
|
|
1954
|
-
const fullTemplate = this.engine.getFullMaskTemplate();
|
|
1955
|
-
this.lastInternalRemainingMask = fullTemplate;
|
|
1956
|
-
this.wrapper.setAttribute("data-mask", fullTemplate);
|
|
1957
|
-
this.updateGhost("");
|
|
1958
2207
|
this.checkValueChange();
|
|
1959
2208
|
}
|
|
1960
2209
|
}
|
|
@@ -1964,8 +2213,10 @@ var InputMask = class extends BaseInputMask {
|
|
|
1964
2213
|
* Gère de manière sûre la réentrance pour permettre d'appeler setMask() directement dans le callback.
|
|
1965
2214
|
*/
|
|
1966
2215
|
checkValueChange(forceNotify = false) {
|
|
2216
|
+
const isPwd = this.isPasswordInput();
|
|
1967
2217
|
const currentVal = this.input.value;
|
|
1968
|
-
|
|
2218
|
+
const currentComparison = isPwd ? this.computePasswordDigest(currentVal) : currentVal;
|
|
2219
|
+
if (currentComparison === this.lastValue && !forceNotify && !this.hasPendingNotification) {
|
|
1969
2220
|
return;
|
|
1970
2221
|
}
|
|
1971
2222
|
if (this.isNotifying) {
|
|
@@ -1976,12 +2227,12 @@ var InputMask = class extends BaseInputMask {
|
|
|
1976
2227
|
try {
|
|
1977
2228
|
let iterations = 0;
|
|
1978
2229
|
const MAX_NOTIFICATION_ITERATIONS = 10;
|
|
1979
|
-
while ((this.input.value !== this.lastValue || this.hasPendingNotification || forceNotify) && iterations < MAX_NOTIFICATION_ITERATIONS) {
|
|
2230
|
+
while (((isPwd ? this.computePasswordDigest(this.input.value) : this.input.value) !== this.lastValue || this.hasPendingNotification || forceNotify) && iterations < MAX_NOTIFICATION_ITERATIONS) {
|
|
1980
2231
|
iterations++;
|
|
1981
2232
|
this.hasPendingNotification = false;
|
|
1982
2233
|
forceNotify = false;
|
|
1983
2234
|
const valToNotify = this.input.value;
|
|
1984
|
-
this.lastValue = valToNotify;
|
|
2235
|
+
this.lastValue = isPwd ? this.computePasswordDigest(valToNotify) : valToNotify;
|
|
1985
2236
|
const raw = this.options.disabled ? valToNotify : this.getRawValue();
|
|
1986
2237
|
const totalSlots = this.options.disabled ? 0 : this.engine.getEditableCount();
|
|
1987
2238
|
const isComplete = this.isComplete();
|
|
@@ -2019,6 +2270,7 @@ var InputMask = class extends BaseInputMask {
|
|
|
2019
2270
|
|
|
2020
2271
|
// src/mask/AmountEngine.ts
|
|
2021
2272
|
var AmountEngine = class _AmountEngine {
|
|
2273
|
+
options;
|
|
2022
2274
|
constructor(options = {}) {
|
|
2023
2275
|
let currency = options.currency ?? "";
|
|
2024
2276
|
if (!currency && options.unit) {
|
|
@@ -2231,6 +2483,16 @@ var AmountEngine = class _AmountEngine {
|
|
|
2231
2483
|
|
|
2232
2484
|
// src/mask/InputAmountMask.ts
|
|
2233
2485
|
var InputAmountMask = class extends BaseInputMask {
|
|
2486
|
+
engine;
|
|
2487
|
+
history;
|
|
2488
|
+
isUndoingRedoing = false;
|
|
2489
|
+
isApplying = false;
|
|
2490
|
+
isComposing = false;
|
|
2491
|
+
lastValue = "";
|
|
2492
|
+
wasInputModeInferred = false;
|
|
2493
|
+
cutTimerId = null;
|
|
2494
|
+
resetTimerId = null;
|
|
2495
|
+
cursorTimerId = null;
|
|
2234
2496
|
constructor(targetOrWrapper, inputOrOptions, options) {
|
|
2235
2497
|
const args = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, options);
|
|
2236
2498
|
const wrap = args.wrapper;
|
|
@@ -2244,13 +2506,10 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2244
2506
|
...opts
|
|
2245
2507
|
};
|
|
2246
2508
|
super(wrap, inp, resolvedOptions);
|
|
2247
|
-
this.
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
this.cutTimerId = null;
|
|
2252
|
-
this.resetTimerId = null;
|
|
2253
|
-
this.input.inputMode = "decimal";
|
|
2509
|
+
if (!this.input.hasAttribute("inputmode")) {
|
|
2510
|
+
this.input.inputMode = "decimal";
|
|
2511
|
+
this.wasInputModeInferred = true;
|
|
2512
|
+
}
|
|
2254
2513
|
this.history = new MaskHistory();
|
|
2255
2514
|
this.engine = new AmountEngine(this.options);
|
|
2256
2515
|
this.bindEvents();
|
|
@@ -2276,6 +2535,9 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2276
2535
|
}
|
|
2277
2536
|
onPasswordModeDetected() {
|
|
2278
2537
|
this.history.clear();
|
|
2538
|
+
this.lastValue = "";
|
|
2539
|
+
this.lastTrackedValue = "";
|
|
2540
|
+
this.clearGhost();
|
|
2279
2541
|
}
|
|
2280
2542
|
/**
|
|
2281
2543
|
* Formate statiquement une valeur sans nécessiter d'élément DOM.
|
|
@@ -2291,7 +2553,9 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2291
2553
|
this.applyAmount(strVal, strVal.length);
|
|
2292
2554
|
}
|
|
2293
2555
|
onDisabledChange(disabled) {
|
|
2294
|
-
if (
|
|
2556
|
+
if (disabled) {
|
|
2557
|
+
this.clearGhost();
|
|
2558
|
+
} else {
|
|
2295
2559
|
this.applyAmount(this.input.value, this.input.selectionStart ?? this.input.value.length);
|
|
2296
2560
|
}
|
|
2297
2561
|
}
|
|
@@ -2314,15 +2578,16 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2314
2578
|
this.applyAmount(this.input.value, cur);
|
|
2315
2579
|
}, 0);
|
|
2316
2580
|
};
|
|
2317
|
-
|
|
2318
|
-
this.input.addEventListener("
|
|
2319
|
-
this.input.addEventListener("
|
|
2320
|
-
this.input.addEventListener("
|
|
2321
|
-
this.input.addEventListener("
|
|
2322
|
-
this.input.addEventListener("
|
|
2323
|
-
this.input.addEventListener("
|
|
2324
|
-
this.input.addEventListener("
|
|
2325
|
-
this.input.addEventListener("
|
|
2581
|
+
const { signal } = this.abortController;
|
|
2582
|
+
this.input.addEventListener("input", this.handleInput, { signal });
|
|
2583
|
+
this.input.addEventListener("keydown", this.handleKeyDown, { signal });
|
|
2584
|
+
this.input.addEventListener("blur", this.handleBlur, { signal });
|
|
2585
|
+
this.input.addEventListener("focus", this.handleFocus, { signal });
|
|
2586
|
+
this.input.addEventListener("click", this.handleClick, { signal });
|
|
2587
|
+
this.input.addEventListener("scroll", this.onScroll, { passive: true, signal });
|
|
2588
|
+
this.input.addEventListener("cut", this.onCutHandler, { signal });
|
|
2589
|
+
this.input.addEventListener("compositionstart", this.onCompositionStart, { signal });
|
|
2590
|
+
this.input.addEventListener("compositionend", this.onCompositionEnd, { signal });
|
|
2326
2591
|
if (this.input.form) {
|
|
2327
2592
|
this.onFormResetHandler = () => {
|
|
2328
2593
|
if (this.resetTimerId !== null) {
|
|
@@ -2335,7 +2600,7 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2335
2600
|
this.applyAmount(this.input.value, this.input.value.length);
|
|
2336
2601
|
}, 0);
|
|
2337
2602
|
};
|
|
2338
|
-
this.input.form.addEventListener("reset", this.onFormResetHandler);
|
|
2603
|
+
this.input.form.addEventListener("reset", this.onFormResetHandler, { signal });
|
|
2339
2604
|
}
|
|
2340
2605
|
}
|
|
2341
2606
|
onCompositionStart() {
|
|
@@ -2354,15 +2619,20 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2354
2619
|
const result = this.engine.format(val, cursor);
|
|
2355
2620
|
this.setNativeValue(result.formatted);
|
|
2356
2621
|
this.input.setSelectionRange(result.cursor, result.cursor);
|
|
2357
|
-
|
|
2622
|
+
const isPwd = this.isPasswordInput();
|
|
2623
|
+
if (isPwd) {
|
|
2358
2624
|
this.options.copyRaw = false;
|
|
2359
2625
|
this.history.clear();
|
|
2360
|
-
|
|
2361
|
-
|
|
2626
|
+
this.clearGhost();
|
|
2627
|
+
} else {
|
|
2628
|
+
if (!this.isUndoingRedoing) {
|
|
2629
|
+
this.history.push(result.rawValue, result.cursor);
|
|
2630
|
+
}
|
|
2631
|
+
this.updateGhost(result);
|
|
2362
2632
|
}
|
|
2363
|
-
this.
|
|
2364
|
-
if (this.lastValue !==
|
|
2365
|
-
this.lastValue =
|
|
2633
|
+
const nextComparison = isPwd ? this.computePasswordDigest(result.formatted) : result.formatted;
|
|
2634
|
+
if (this.lastValue !== nextComparison) {
|
|
2635
|
+
this.lastValue = nextComparison;
|
|
2366
2636
|
this.notifyChange(result);
|
|
2367
2637
|
}
|
|
2368
2638
|
} finally {
|
|
@@ -2373,18 +2643,18 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2373
2643
|
if (!this.ghost) return;
|
|
2374
2644
|
if (!result.formatted) {
|
|
2375
2645
|
if (this.shouldHideGhostForPlaceholder(true)) {
|
|
2376
|
-
this.
|
|
2646
|
+
this.clearGhost();
|
|
2377
2647
|
return;
|
|
2378
2648
|
}
|
|
2379
2649
|
const hint = this.options.currency ? this.options.currencyPosition === "prefix" ? `${this.options.currency} 0` : `0 ${this.options.currency}` : "0,00";
|
|
2380
|
-
this.
|
|
2381
|
-
const span =
|
|
2650
|
+
const doc = this.input.ownerDocument || document;
|
|
2651
|
+
const span = doc.createElement("span");
|
|
2382
2652
|
span.className = "mask-ghost-remaining";
|
|
2383
2653
|
span.textContent = hint;
|
|
2384
|
-
this.
|
|
2654
|
+
this.setGhostContent(span);
|
|
2385
2655
|
return;
|
|
2386
2656
|
}
|
|
2387
|
-
this.
|
|
2657
|
+
this.clearGhost();
|
|
2388
2658
|
this.ghost.scrollLeft = this.input.scrollLeft;
|
|
2389
2659
|
}
|
|
2390
2660
|
handleInput() {
|
|
@@ -2395,7 +2665,7 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2395
2665
|
this.applyAmount(rawVal, cur);
|
|
2396
2666
|
}
|
|
2397
2667
|
handleKeyDown(e) {
|
|
2398
|
-
if (this.options.disabled) return;
|
|
2668
|
+
if (this.options.disabled || isImeComposing(e)) return;
|
|
2399
2669
|
if ((e.ctrlKey || e.metaKey) && (e.key === "z" || e.key === "Z")) {
|
|
2400
2670
|
e.preventDefault();
|
|
2401
2671
|
if (e.shiftKey) this.redo();
|
|
@@ -2447,10 +2717,18 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2447
2717
|
}
|
|
2448
2718
|
}
|
|
2449
2719
|
}
|
|
2450
|
-
|
|
2720
|
+
if (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Home" || e.key === "End") {
|
|
2721
|
+
if (this.cursorTimerId !== null) {
|
|
2722
|
+
clearTimeout(this.cursorTimerId);
|
|
2723
|
+
}
|
|
2724
|
+
this.cursorTimerId = window.setTimeout(() => {
|
|
2725
|
+
this.cursorTimerId = null;
|
|
2726
|
+
this.enforceCursorBounds();
|
|
2727
|
+
}, 0);
|
|
2728
|
+
}
|
|
2451
2729
|
}
|
|
2452
2730
|
enforceCursorBounds() {
|
|
2453
|
-
if (!this.input.value || this.options.disabled) return;
|
|
2731
|
+
if (this.isDestroyed || !this.isFocused || document.activeElement !== this.input || !this.input.value || this.options.disabled) return;
|
|
2454
2732
|
const start = this.input.selectionStart ?? 0;
|
|
2455
2733
|
const end = this.input.selectionEnd ?? 0;
|
|
2456
2734
|
if (start !== end) return;
|
|
@@ -2481,8 +2759,12 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2481
2759
|
}
|
|
2482
2760
|
handleBlur() {
|
|
2483
2761
|
this.wrapper.classList.remove("is-focused");
|
|
2484
|
-
if (this.
|
|
2762
|
+
if (this.isPasswordInput()) {
|
|
2485
2763
|
this.history.clear();
|
|
2764
|
+
this.lastValue = "";
|
|
2765
|
+
this.lastTrackedValue = "";
|
|
2766
|
+
this.clearGhost();
|
|
2767
|
+
return;
|
|
2486
2768
|
}
|
|
2487
2769
|
if (this.options.padDecimalsOnBlur && !this.options.disabled && this.input.value.trim().length > 0) {
|
|
2488
2770
|
const paddedResult = this.engine.format(this.input.value, this.input.value.length, true);
|
|
@@ -2578,30 +2860,62 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2578
2860
|
clearTimeout(this.resetTimerId);
|
|
2579
2861
|
this.resetTimerId = null;
|
|
2580
2862
|
}
|
|
2581
|
-
this.
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
this.input.
|
|
2586
|
-
|
|
2587
|
-
this.input.removeEventListener("cut", this.onCutHandler);
|
|
2588
|
-
this.input.removeEventListener("compositionstart", this.onCompositionStart);
|
|
2589
|
-
this.input.removeEventListener("compositionend", this.onCompositionEnd);
|
|
2590
|
-
if (this.input.form && this.onFormResetHandler) {
|
|
2591
|
-
this.input.form.removeEventListener("reset", this.onFormResetHandler);
|
|
2863
|
+
if (this.cursorTimerId !== null) {
|
|
2864
|
+
clearTimeout(this.cursorTimerId);
|
|
2865
|
+
this.cursorTimerId = null;
|
|
2866
|
+
}
|
|
2867
|
+
if (this.wasInputModeInferred && this.input.getAttribute("inputmode") === "decimal") {
|
|
2868
|
+
this.input.removeAttribute("inputmode");
|
|
2592
2869
|
}
|
|
2870
|
+
this.lastValue = "";
|
|
2593
2871
|
this.history.clear();
|
|
2594
2872
|
super.destroy();
|
|
2595
2873
|
}
|
|
2596
2874
|
};
|
|
2597
2875
|
|
|
2598
2876
|
// src/mask/EmailEngine.ts
|
|
2599
|
-
var
|
|
2877
|
+
var EmailEngine = class _EmailEngine {
|
|
2878
|
+
domains;
|
|
2879
|
+
tlds;
|
|
2880
|
+
suggestOnAt;
|
|
2881
|
+
defaultDomain = null;
|
|
2882
|
+
defaultTld = "__";
|
|
2883
|
+
static DEFAULT_DOMAINS = [
|
|
2884
|
+
"gmail.com",
|
|
2885
|
+
"outlook.com",
|
|
2886
|
+
"orange.fr",
|
|
2887
|
+
"free.fr",
|
|
2888
|
+
"sfr.fr",
|
|
2889
|
+
"yahoo.com",
|
|
2890
|
+
"hotmail.com",
|
|
2891
|
+
"icloud.com",
|
|
2892
|
+
"laposte.net",
|
|
2893
|
+
"proton.me"
|
|
2894
|
+
];
|
|
2895
|
+
static DEFAULT_TLDS = [
|
|
2896
|
+
"com",
|
|
2897
|
+
"fr",
|
|
2898
|
+
"net",
|
|
2899
|
+
"org",
|
|
2900
|
+
"eu",
|
|
2901
|
+
"io",
|
|
2902
|
+
"co",
|
|
2903
|
+
"info",
|
|
2904
|
+
"biz",
|
|
2905
|
+
"me",
|
|
2906
|
+
"tv",
|
|
2907
|
+
"fi",
|
|
2908
|
+
"be",
|
|
2909
|
+
"ch",
|
|
2910
|
+
"ca",
|
|
2911
|
+
"uk",
|
|
2912
|
+
"de",
|
|
2913
|
+
"es",
|
|
2914
|
+
"it"
|
|
2915
|
+
];
|
|
2600
2916
|
constructor(options = {}) {
|
|
2601
|
-
this.defaultDomain = null;
|
|
2602
|
-
this.defaultTld = "__";
|
|
2603
2917
|
this.domains = options.domains && options.domains.length > 0 ? options.domains : _EmailEngine.DEFAULT_DOMAINS;
|
|
2604
|
-
this.tlds = options.tlds && options.tlds.length > 0 ? options.tlds.map((t) => t.trim().replace(/^\./, "")).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
|
|
2918
|
+
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];
|
|
2605
2919
|
this.suggestOnAt = options.suggestOnAt ?? true;
|
|
2606
2920
|
this.setDefaultDomain(options.defaultDomain ?? null);
|
|
2607
2921
|
this.setDefaultTld(options.defaultTld !== void 0 ? options.defaultTld : "__");
|
|
@@ -2634,7 +2948,7 @@ var _EmailEngine = class _EmailEngine {
|
|
|
2634
2948
|
* Définit ou modifie la liste des extensions (TLD) proposées par ordre de priorité.
|
|
2635
2949
|
*/
|
|
2636
2950
|
setTlds(tlds) {
|
|
2637
|
-
this.tlds = tlds && tlds.length > 0 ? tlds.map((t) => t.trim().replace(/^\./, "")).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
|
|
2951
|
+
this.tlds = tlds && tlds.length > 0 ? tlds.slice(0, 200).map((t) => String(t).trim().replace(/^\./, "").slice(0, 32)).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
|
|
2638
2952
|
}
|
|
2639
2953
|
/**
|
|
2640
2954
|
* Retourne l'ensemble des extensions (TLD) correspondant au fragment saisi après le dernier point,
|
|
@@ -2705,22 +3019,22 @@ var _EmailEngine = class _EmailEngine {
|
|
|
2705
3019
|
};
|
|
2706
3020
|
}
|
|
2707
3021
|
if (domainPart.length === 0 || domainPart.startsWith(".")) {
|
|
2708
|
-
return { full:
|
|
3022
|
+
return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2709
3023
|
}
|
|
2710
3024
|
const lowerDomain = domainPart.toLowerCase();
|
|
2711
3025
|
if (this.domains.some((d) => d.toLowerCase() === lowerDomain)) {
|
|
2712
|
-
return { full:
|
|
3026
|
+
return { full: val, remaining: "", matchedDomain: domainPart, isHintOnly: false };
|
|
2713
3027
|
}
|
|
2714
3028
|
const lastDotIndex = domainPart.lastIndexOf(".");
|
|
2715
3029
|
if (lastDotIndex === -1) {
|
|
2716
3030
|
if (!this.defaultTld) {
|
|
2717
|
-
return { full:
|
|
3031
|
+
return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2718
3032
|
}
|
|
2719
3033
|
const isHint = this.defaultTld.includes("_");
|
|
2720
3034
|
const remaining = `.${this.defaultTld}`;
|
|
2721
3035
|
const fullDomain = `${domainPart}.${this.defaultTld}`;
|
|
2722
3036
|
return {
|
|
2723
|
-
full: isHint ?
|
|
3037
|
+
full: isHint ? val : `${localPart}@${fullDomain}`,
|
|
2724
3038
|
remaining,
|
|
2725
3039
|
matchedDomain: isHint ? null : fullDomain,
|
|
2726
3040
|
isHintOnly: isHint
|
|
@@ -2729,7 +3043,7 @@ var _EmailEngine = class _EmailEngine {
|
|
|
2729
3043
|
const hostPart = domainPart.substring(0, lastDotIndex);
|
|
2730
3044
|
const tldPart = domainPart.substring(lastDotIndex + 1);
|
|
2731
3045
|
if (!hostPart || hostPart.endsWith(".")) {
|
|
2732
|
-
return { full:
|
|
3046
|
+
return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2733
3047
|
}
|
|
2734
3048
|
if (tldPart.length === 0) {
|
|
2735
3049
|
if (this.defaultTld && !this.defaultTld.includes("_")) {
|
|
@@ -2743,15 +3057,18 @@ var _EmailEngine = class _EmailEngine {
|
|
|
2743
3057
|
}
|
|
2744
3058
|
if (this.defaultTld && this.defaultTld.includes("_")) {
|
|
2745
3059
|
return {
|
|
2746
|
-
full:
|
|
3060
|
+
full: val,
|
|
2747
3061
|
remaining: this.defaultTld,
|
|
2748
3062
|
matchedDomain: null,
|
|
2749
3063
|
isHintOnly: true
|
|
2750
3064
|
};
|
|
2751
3065
|
}
|
|
2752
|
-
return { full:
|
|
3066
|
+
return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2753
3067
|
}
|
|
2754
3068
|
const lowerTld = tldPart.toLowerCase();
|
|
3069
|
+
if (this.tlds.some((t) => t.toLowerCase() === lowerTld)) {
|
|
3070
|
+
return { full: val, remaining: "", matchedDomain: domainPart, isHintOnly: false };
|
|
3071
|
+
}
|
|
2755
3072
|
const matchingTlds = this.getMatchingTlds(tldPart);
|
|
2756
3073
|
if (matchingTlds.length > 0) {
|
|
2757
3074
|
const safeTldIndex = (matchIndex % matchingTlds.length + matchingTlds.length) % matchingTlds.length;
|
|
@@ -2769,53 +3086,34 @@ var _EmailEngine = class _EmailEngine {
|
|
|
2769
3086
|
const remaining = this.defaultTld.substring(tldPart.length);
|
|
2770
3087
|
if (remaining.includes("_")) {
|
|
2771
3088
|
return {
|
|
2772
|
-
full:
|
|
3089
|
+
full: val,
|
|
2773
3090
|
remaining,
|
|
2774
3091
|
matchedDomain: null,
|
|
2775
3092
|
isHintOnly: true
|
|
2776
3093
|
};
|
|
2777
3094
|
}
|
|
2778
3095
|
}
|
|
2779
|
-
return { full:
|
|
3096
|
+
return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2780
3097
|
}
|
|
2781
3098
|
};
|
|
2782
|
-
_EmailEngine.DEFAULT_DOMAINS = [
|
|
2783
|
-
"gmail.com",
|
|
2784
|
-
"outlook.com",
|
|
2785
|
-
"orange.fr",
|
|
2786
|
-
"free.fr",
|
|
2787
|
-
"sfr.fr",
|
|
2788
|
-
"yahoo.com",
|
|
2789
|
-
"hotmail.com",
|
|
2790
|
-
"icloud.com",
|
|
2791
|
-
"laposte.net",
|
|
2792
|
-
"proton.me"
|
|
2793
|
-
];
|
|
2794
|
-
_EmailEngine.DEFAULT_TLDS = [
|
|
2795
|
-
"com",
|
|
2796
|
-
"fr",
|
|
2797
|
-
"net",
|
|
2798
|
-
"org",
|
|
2799
|
-
"eu",
|
|
2800
|
-
"io",
|
|
2801
|
-
"co",
|
|
2802
|
-
"info",
|
|
2803
|
-
"biz",
|
|
2804
|
-
"me",
|
|
2805
|
-
"tv",
|
|
2806
|
-
"fi",
|
|
2807
|
-
"be",
|
|
2808
|
-
"ch",
|
|
2809
|
-
"ca",
|
|
2810
|
-
"uk",
|
|
2811
|
-
"de",
|
|
2812
|
-
"es",
|
|
2813
|
-
"it"
|
|
2814
|
-
];
|
|
2815
|
-
var EmailEngine = _EmailEngine;
|
|
2816
3099
|
|
|
2817
3100
|
// src/mask/InputEmailMask.ts
|
|
2818
3101
|
var InputEmailMask = class extends BaseInputMask {
|
|
3102
|
+
engine;
|
|
3103
|
+
currentSuggestion = { full: "", remaining: "", matchedDomain: null };
|
|
3104
|
+
currentSuggestionIndex = 0;
|
|
3105
|
+
wasAriaAutocompleteSet = false;
|
|
3106
|
+
wasAutocorrectSet = false;
|
|
3107
|
+
wasAutocapitalizeSet = false;
|
|
3108
|
+
wasSpellcheckSet = false;
|
|
3109
|
+
wasInputModeInferred = false;
|
|
3110
|
+
isComposing = false;
|
|
3111
|
+
lastNotifiedValue = "";
|
|
3112
|
+
srStatusEl = null;
|
|
3113
|
+
srAnnounceTimerId = null;
|
|
3114
|
+
lastAnnouncedSuggestion = "";
|
|
3115
|
+
cutTimerId = null;
|
|
3116
|
+
resetTimerId = null;
|
|
2819
3117
|
constructor(targetOrWrapper, inputOrOptions, options) {
|
|
2820
3118
|
const args = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, options);
|
|
2821
3119
|
const wrap = args.wrapper;
|
|
@@ -2841,30 +3139,55 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2841
3139
|
...resolvedDefaultTld !== void 0 ? { defaultTld: resolvedDefaultTld } : {}
|
|
2842
3140
|
};
|
|
2843
3141
|
super(wrap, inp, resolvedOptions);
|
|
2844
|
-
this.
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
this.
|
|
2849
|
-
|
|
3142
|
+
if (!this.input.hasAttribute("inputmode")) {
|
|
3143
|
+
this.input.inputMode = "email";
|
|
3144
|
+
this.wasInputModeInferred = true;
|
|
3145
|
+
}
|
|
3146
|
+
if (!this.input.hasAttribute("autocorrect")) {
|
|
3147
|
+
this.input.setAttribute("autocorrect", "off");
|
|
3148
|
+
this.wasAutocorrectSet = true;
|
|
3149
|
+
}
|
|
3150
|
+
if (!this.input.hasAttribute("autocapitalize")) {
|
|
3151
|
+
this.input.setAttribute("autocapitalize", "none");
|
|
3152
|
+
this.wasAutocapitalizeSet = true;
|
|
3153
|
+
}
|
|
3154
|
+
if (!this.input.hasAttribute("spellcheck")) {
|
|
3155
|
+
this.input.setAttribute("spellcheck", "false");
|
|
3156
|
+
this.wasSpellcheckSet = true;
|
|
3157
|
+
}
|
|
2850
3158
|
if (this.options.setAriaAutocomplete && !this.input.hasAttribute("aria-autocomplete")) {
|
|
2851
3159
|
this.input.setAttribute("aria-autocomplete", "inline");
|
|
2852
3160
|
this.wasAriaAutocompleteSet = true;
|
|
2853
3161
|
}
|
|
2854
3162
|
this.engine = new EmailEngine(this.options);
|
|
3163
|
+
this.lastNotifiedValue = this.isPasswordInput() ? "" : this.input.value;
|
|
2855
3164
|
this.bindEvents();
|
|
2856
|
-
if (!this.options.disabled) {
|
|
3165
|
+
if (!this.options.disabled && !this.isPasswordInput()) {
|
|
2857
3166
|
this.updateSuggestion();
|
|
2858
3167
|
}
|
|
2859
3168
|
this.runAuditWarning(this.options.audit);
|
|
2860
3169
|
}
|
|
3170
|
+
onPasswordModeDetected() {
|
|
3171
|
+
if (this.srAnnounceTimerId !== null) {
|
|
3172
|
+
clearTimeout(this.srAnnounceTimerId);
|
|
3173
|
+
this.srAnnounceTimerId = null;
|
|
3174
|
+
}
|
|
3175
|
+
this.lastNotifiedValue = "";
|
|
3176
|
+
this.lastTrackedValue = "";
|
|
3177
|
+
this.lastAnnouncedSuggestion = "";
|
|
3178
|
+
this.currentSuggestion = { full: "", remaining: "", matchedDomain: null };
|
|
3179
|
+
if (this.srStatusEl) {
|
|
3180
|
+
this.srStatusEl.textContent = "";
|
|
3181
|
+
}
|
|
3182
|
+
this.clearGhost();
|
|
3183
|
+
}
|
|
2861
3184
|
onNativeValueSet(_strVal) {
|
|
2862
|
-
if (this.options.disabled) return;
|
|
3185
|
+
if (this.options.disabled || this.isComposing || this.isPasswordInput()) return;
|
|
2863
3186
|
this.updateSuggestion();
|
|
2864
3187
|
}
|
|
2865
3188
|
onDisabledChange(disabled) {
|
|
2866
|
-
if (disabled) {
|
|
2867
|
-
|
|
3189
|
+
if (disabled || this.isPasswordInput()) {
|
|
3190
|
+
this.clearGhost();
|
|
2868
3191
|
} else {
|
|
2869
3192
|
this.updateSuggestion();
|
|
2870
3193
|
}
|
|
@@ -2880,16 +3203,26 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2880
3203
|
}
|
|
2881
3204
|
this.cutTimerId = window.setTimeout(() => {
|
|
2882
3205
|
this.cutTimerId = null;
|
|
2883
|
-
if (this.isDestroyed || this.options.disabled) return;
|
|
3206
|
+
if (this.isDestroyed || this.options.disabled || this.isPasswordInput()) return;
|
|
2884
3207
|
this.updateSuggestion();
|
|
2885
3208
|
}, 0);
|
|
2886
3209
|
};
|
|
2887
|
-
|
|
2888
|
-
this.input.addEventListener("
|
|
2889
|
-
this.input.addEventListener("
|
|
2890
|
-
this.input.addEventListener("
|
|
2891
|
-
this.input.addEventListener("
|
|
2892
|
-
this.input.addEventListener("
|
|
3210
|
+
const { signal } = this.abortController;
|
|
3211
|
+
this.input.addEventListener("input", this.handleInput, { signal });
|
|
3212
|
+
this.input.addEventListener("keydown", this.handleKeyDown, { signal });
|
|
3213
|
+
this.input.addEventListener("blur", this.handleBlur, { signal });
|
|
3214
|
+
this.input.addEventListener("focus", this.handleFocus, { signal });
|
|
3215
|
+
this.input.addEventListener("scroll", this.onScroll, { passive: true, signal });
|
|
3216
|
+
this.input.addEventListener("cut", this.onCutHandler, { signal });
|
|
3217
|
+
this.input.addEventListener("compositionstart", () => {
|
|
3218
|
+
this.isComposing = true;
|
|
3219
|
+
}, { signal });
|
|
3220
|
+
this.input.addEventListener("compositionend", () => {
|
|
3221
|
+
this.isComposing = false;
|
|
3222
|
+
if (!this.isDestroyed && !this.options.disabled && !this.isPasswordInput()) {
|
|
3223
|
+
this.handleInput();
|
|
3224
|
+
}
|
|
3225
|
+
}, { signal });
|
|
2893
3226
|
if (this.input.form) {
|
|
2894
3227
|
this.onFormResetHandler = () => {
|
|
2895
3228
|
if (this.resetTimerId !== null) {
|
|
@@ -2897,47 +3230,112 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2897
3230
|
}
|
|
2898
3231
|
this.resetTimerId = window.setTimeout(() => {
|
|
2899
3232
|
this.resetTimerId = null;
|
|
2900
|
-
if (this.isDestroyed || this.options.disabled) return;
|
|
3233
|
+
if (this.isDestroyed || this.options.disabled || this.isPasswordInput()) return;
|
|
2901
3234
|
this.updateSuggestion();
|
|
2902
3235
|
}, 0);
|
|
2903
3236
|
};
|
|
2904
|
-
this.input.form.addEventListener("reset", this.onFormResetHandler);
|
|
3237
|
+
this.input.form.addEventListener("reset", this.onFormResetHandler, { signal });
|
|
2905
3238
|
}
|
|
2906
3239
|
}
|
|
2907
|
-
|
|
2908
|
-
if (this.
|
|
2909
|
-
|
|
3240
|
+
ensureSrStatusEl() {
|
|
3241
|
+
if (this.srStatusEl && this.wrapper.contains(this.srStatusEl)) {
|
|
3242
|
+
return this.srStatusEl;
|
|
3243
|
+
}
|
|
3244
|
+
const doc = this.input.ownerDocument || (typeof document !== "undefined" ? document : null);
|
|
3245
|
+
if (!doc) return null;
|
|
3246
|
+
const status = doc.createElement("span");
|
|
3247
|
+
status.className = "wulf-mask-sr-status";
|
|
3248
|
+
status.setAttribute("aria-live", "polite");
|
|
3249
|
+
status.setAttribute("aria-atomic", "true");
|
|
3250
|
+
this.wrapper.appendChild(status);
|
|
3251
|
+
this.srStatusEl = status;
|
|
3252
|
+
return status;
|
|
3253
|
+
}
|
|
3254
|
+
scheduleSuggestionAnnouncement(immediate = false) {
|
|
3255
|
+
if (this.srAnnounceTimerId !== null) {
|
|
3256
|
+
clearTimeout(this.srAnnounceTimerId);
|
|
3257
|
+
this.srAnnounceTimerId = null;
|
|
3258
|
+
}
|
|
3259
|
+
if (!this.options.setAriaAutocomplete || !this.isFocused || this.isDestroyed || this.isPasswordInput()) {
|
|
3260
|
+
return;
|
|
3261
|
+
}
|
|
3262
|
+
const suggestion = this.currentSuggestion;
|
|
3263
|
+
if (!suggestion.remaining || suggestion.isHintOnly) {
|
|
3264
|
+
this.lastAnnouncedSuggestion = "";
|
|
3265
|
+
if (this.srStatusEl) {
|
|
3266
|
+
this.srStatusEl.textContent = "";
|
|
3267
|
+
}
|
|
3268
|
+
return;
|
|
3269
|
+
}
|
|
3270
|
+
const textToAnnounce = suggestion.full;
|
|
3271
|
+
if (textToAnnounce === this.lastAnnouncedSuggestion && !immediate) {
|
|
3272
|
+
return;
|
|
3273
|
+
}
|
|
3274
|
+
const run = () => {
|
|
3275
|
+
this.srAnnounceTimerId = null;
|
|
3276
|
+
if (this.isDestroyed || !this.isFocused || this.isPasswordInput()) return;
|
|
3277
|
+
this.lastAnnouncedSuggestion = textToAnnounce;
|
|
3278
|
+
const doc = this.input.ownerDocument || (typeof document !== "undefined" ? document : null);
|
|
3279
|
+
const docWithAriaNotify = doc;
|
|
3280
|
+
if (docWithAriaNotify && typeof docWithAriaNotify.ariaNotify === "function") {
|
|
3281
|
+
try {
|
|
3282
|
+
docWithAriaNotify.ariaNotify(textToAnnounce, { priority: "normal" });
|
|
3283
|
+
return;
|
|
3284
|
+
} catch {
|
|
3285
|
+
}
|
|
3286
|
+
}
|
|
3287
|
+
const statusEl = this.ensureSrStatusEl();
|
|
3288
|
+
if (statusEl) {
|
|
3289
|
+
statusEl.textContent = statusEl.textContent === textToAnnounce ? `${textToAnnounce}\xA0` : textToAnnounce;
|
|
3290
|
+
}
|
|
3291
|
+
};
|
|
3292
|
+
if (immediate) {
|
|
3293
|
+
run();
|
|
3294
|
+
} else {
|
|
3295
|
+
this.srAnnounceTimerId = window.setTimeout(run, 250);
|
|
3296
|
+
}
|
|
3297
|
+
}
|
|
3298
|
+
updateSuggestion(announceOptions) {
|
|
3299
|
+
if (this.options.disabled || this.isPasswordInput()) {
|
|
3300
|
+
this.currentSuggestion = { full: "", remaining: "", matchedDomain: null };
|
|
3301
|
+
this.clearGhost();
|
|
2910
3302
|
return;
|
|
2911
3303
|
}
|
|
2912
3304
|
const val = this.input.value;
|
|
2913
3305
|
this.currentSuggestion = this.engine.getSuggestion(val, this.currentSuggestionIndex);
|
|
2914
3306
|
if (!this.ghost) return;
|
|
2915
3307
|
if (this.shouldHideGhostForPlaceholder(val.length === 0)) {
|
|
2916
|
-
this.
|
|
3308
|
+
this.clearGhost();
|
|
2917
3309
|
} else if (this.currentSuggestion.remaining) {
|
|
2918
|
-
this.
|
|
2919
|
-
const spanTyped =
|
|
3310
|
+
const doc = this.input.ownerDocument || document;
|
|
3311
|
+
const spanTyped = doc.createElement("span");
|
|
2920
3312
|
spanTyped.className = "mask-ghost-typed";
|
|
2921
3313
|
spanTyped.textContent = val;
|
|
2922
|
-
const spanRemaining =
|
|
3314
|
+
const spanRemaining = doc.createElement("span");
|
|
2923
3315
|
spanRemaining.className = "mask-ghost-remaining";
|
|
2924
3316
|
spanRemaining.textContent = this.currentSuggestion.remaining;
|
|
2925
|
-
this.
|
|
2926
|
-
this.ghost.appendChild(spanRemaining);
|
|
3317
|
+
this.setGhostContent(spanTyped, spanRemaining);
|
|
2927
3318
|
} else {
|
|
2928
|
-
this.
|
|
3319
|
+
this.clearGhost();
|
|
2929
3320
|
}
|
|
2930
3321
|
this.ghost.scrollLeft = this.input.scrollLeft;
|
|
3322
|
+
if (announceOptions?.announce) {
|
|
3323
|
+
this.scheduleSuggestionAnnouncement(Boolean(announceOptions.immediate));
|
|
3324
|
+
}
|
|
2931
3325
|
const detail = this.getDetail();
|
|
2932
3326
|
if (this.options.onInput) {
|
|
2933
3327
|
this.options.onInput(detail);
|
|
2934
3328
|
}
|
|
2935
3329
|
this.input.dispatchEvent(new CustomEvent("mask:input", { bubbles: true, detail }));
|
|
2936
|
-
this.
|
|
3330
|
+
if (val !== this.lastNotifiedValue) {
|
|
3331
|
+
this.lastNotifiedValue = val;
|
|
3332
|
+
this.dispatchNativeInput();
|
|
3333
|
+
}
|
|
2937
3334
|
}
|
|
2938
|
-
handleInput() {
|
|
3335
|
+
handleInput(e) {
|
|
2939
3336
|
if (this.isDispatchingNativeInput) return;
|
|
2940
|
-
if (this.options.disabled) return;
|
|
3337
|
+
if (this.options.disabled || this.isPasswordInput()) return;
|
|
3338
|
+
if (this.isComposing || e && "isComposing" in e && e.isComposing) return;
|
|
2941
3339
|
if (this.options.autoLowercase) {
|
|
2942
3340
|
const start = this.input.selectionStart ?? 0;
|
|
2943
3341
|
const end = this.input.selectionEnd ?? start;
|
|
@@ -2948,10 +3346,11 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2948
3346
|
}
|
|
2949
3347
|
}
|
|
2950
3348
|
this.currentSuggestionIndex = 0;
|
|
2951
|
-
this.updateSuggestion();
|
|
3349
|
+
this.updateSuggestion({ announce: true, immediate: false });
|
|
2952
3350
|
}
|
|
2953
3351
|
handleKeyDown(e) {
|
|
2954
|
-
if (this.options.disabled) return;
|
|
3352
|
+
if (this.options.disabled || this.isPasswordInput() || isImeComposing(e)) return;
|
|
3353
|
+
if (e.shiftKey || e.ctrlKey || e.altKey || e.metaKey) return;
|
|
2955
3354
|
const hasSuggestion = Boolean(this.currentSuggestion.remaining) && !this.currentSuggestion.isHintOnly;
|
|
2956
3355
|
const cursor = this.input.selectionStart ?? 0;
|
|
2957
3356
|
const isAtEnd = cursor === this.input.value.length;
|
|
@@ -2960,13 +3359,13 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2960
3359
|
if (e.key === "ArrowDown") {
|
|
2961
3360
|
e.preventDefault();
|
|
2962
3361
|
this.currentSuggestionIndex++;
|
|
2963
|
-
this.updateSuggestion();
|
|
3362
|
+
this.updateSuggestion({ announce: true, immediate: true });
|
|
2964
3363
|
return;
|
|
2965
3364
|
}
|
|
2966
3365
|
if (e.key === "ArrowUp") {
|
|
2967
3366
|
e.preventDefault();
|
|
2968
3367
|
this.currentSuggestionIndex--;
|
|
2969
|
-
this.updateSuggestion();
|
|
3368
|
+
this.updateSuggestion({ announce: true, immediate: true });
|
|
2970
3369
|
return;
|
|
2971
3370
|
}
|
|
2972
3371
|
}
|
|
@@ -3033,6 +3432,20 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
3033
3432
|
}
|
|
3034
3433
|
handleBlur() {
|
|
3035
3434
|
this.wrapper.classList.remove("is-focused");
|
|
3435
|
+
if (this.srAnnounceTimerId !== null) {
|
|
3436
|
+
clearTimeout(this.srAnnounceTimerId);
|
|
3437
|
+
this.srAnnounceTimerId = null;
|
|
3438
|
+
}
|
|
3439
|
+
this.lastAnnouncedSuggestion = "";
|
|
3440
|
+
if (this.srStatusEl) {
|
|
3441
|
+
this.srStatusEl.textContent = "";
|
|
3442
|
+
}
|
|
3443
|
+
if (this.isPasswordInput()) {
|
|
3444
|
+
this.lastNotifiedValue = "";
|
|
3445
|
+
this.lastTrackedValue = "";
|
|
3446
|
+
this.clearGhost();
|
|
3447
|
+
return;
|
|
3448
|
+
}
|
|
3036
3449
|
this.updateSuggestion();
|
|
3037
3450
|
const detail = this.getDetail();
|
|
3038
3451
|
if (this.options.onChange) {
|
|
@@ -3078,18 +3491,31 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
3078
3491
|
clearTimeout(this.resetTimerId);
|
|
3079
3492
|
this.resetTimerId = null;
|
|
3080
3493
|
}
|
|
3081
|
-
this.
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3494
|
+
if (this.srAnnounceTimerId !== null) {
|
|
3495
|
+
clearTimeout(this.srAnnounceTimerId);
|
|
3496
|
+
this.srAnnounceTimerId = null;
|
|
3497
|
+
}
|
|
3498
|
+
if (this.srStatusEl) {
|
|
3499
|
+
this.srStatusEl.remove();
|
|
3500
|
+
this.srStatusEl = null;
|
|
3501
|
+
}
|
|
3502
|
+
this.lastNotifiedValue = "";
|
|
3503
|
+
this.lastAnnouncedSuggestion = "";
|
|
3504
|
+
if (this.wasInputModeInferred && this.input.getAttribute("inputmode") === "email") {
|
|
3505
|
+
this.input.removeAttribute("inputmode");
|
|
3089
3506
|
}
|
|
3090
3507
|
if (this.wasAriaAutocompleteSet && this.input.getAttribute("aria-autocomplete") === "inline") {
|
|
3091
3508
|
this.input.removeAttribute("aria-autocomplete");
|
|
3092
3509
|
}
|
|
3510
|
+
if (this.wasAutocorrectSet && this.input.getAttribute("autocorrect") === "off") {
|
|
3511
|
+
this.input.removeAttribute("autocorrect");
|
|
3512
|
+
}
|
|
3513
|
+
if (this.wasAutocapitalizeSet && this.input.getAttribute("autocapitalize") === "none") {
|
|
3514
|
+
this.input.removeAttribute("autocapitalize");
|
|
3515
|
+
}
|
|
3516
|
+
if (this.wasSpellcheckSet && this.input.getAttribute("spellcheck") === "false") {
|
|
3517
|
+
this.input.removeAttribute("spellcheck");
|
|
3518
|
+
}
|
|
3093
3519
|
super.destroy();
|
|
3094
3520
|
}
|
|
3095
3521
|
};
|
|
@@ -3106,10 +3532,8 @@ var Mask = {
|
|
|
3106
3532
|
EmailEngine,
|
|
3107
3533
|
InputEmailMask
|
|
3108
3534
|
};
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
const wulfNamespace = win.Wulf || {};
|
|
3112
|
-
win.Wulf = wulfNamespace;
|
|
3535
|
+
var wulfNamespace = getSafeWulfNamespace();
|
|
3536
|
+
if (wulfNamespace) {
|
|
3113
3537
|
wulfNamespace.Mask = Mask;
|
|
3114
3538
|
}
|
|
3115
3539
|
var mask_default = InputMask;
|
|
@@ -3129,6 +3553,7 @@ __export(scroll_exports, {
|
|
|
3129
3553
|
|
|
3130
3554
|
// src/common/LocalizedComponent.ts
|
|
3131
3555
|
var LocalizedComponent = class extends AuditableComponent {
|
|
3556
|
+
static _i18n;
|
|
3132
3557
|
/**
|
|
3133
3558
|
* Définit la langue globale du composant (ex: 'fr', 'en', 'es').
|
|
3134
3559
|
*/
|
|
@@ -3179,6 +3604,10 @@ var LocalizedComponent = class extends AuditableComponent {
|
|
|
3179
3604
|
static t(key, instanceOverride) {
|
|
3180
3605
|
return this._i18n ? this._i18n.t(key, instanceOverride) : String(key);
|
|
3181
3606
|
}
|
|
3607
|
+
/**
|
|
3608
|
+
* Surcharges de localisation spécifiques à cette instance.
|
|
3609
|
+
*/
|
|
3610
|
+
i18nOverrides;
|
|
3182
3611
|
constructor(i18nOverrides) {
|
|
3183
3612
|
super();
|
|
3184
3613
|
this.i18nOverrides = i18nOverrides;
|
|
@@ -3209,7 +3638,7 @@ function getPrimaryLanguage(normalizedLocale) {
|
|
|
3209
3638
|
function assignDefined(target, source) {
|
|
3210
3639
|
if (!source || typeof source !== "object") return target;
|
|
3211
3640
|
for (const key of Object.keys(source)) {
|
|
3212
|
-
if (isSafeKey(String(key)) && Object.
|
|
3641
|
+
if (isSafeKey(String(key)) && Object.hasOwn(source, key) && source[key] !== void 0) {
|
|
3213
3642
|
target[key] = source[key];
|
|
3214
3643
|
}
|
|
3215
3644
|
}
|
|
@@ -3270,7 +3699,7 @@ function createI18nManager(defaultLocale, locales) {
|
|
|
3270
3699
|
if (!isSafeKey(String(key))) {
|
|
3271
3700
|
return "";
|
|
3272
3701
|
}
|
|
3273
|
-
if (instanceOverride && typeof instanceOverride === "object" && Object.
|
|
3702
|
+
if (instanceOverride && typeof instanceOverride === "object" && Object.hasOwn(instanceOverride, key) && instanceOverride[key] !== void 0) {
|
|
3274
3703
|
return String(instanceOverride[key]);
|
|
3275
3704
|
}
|
|
3276
3705
|
if (globalOverrides[key] !== void 0) {
|
|
@@ -3333,21 +3762,60 @@ var scrollI18n = createI18nManager("fr", {
|
|
|
3333
3762
|
// src/scroll/ScrollBlock.ts
|
|
3334
3763
|
var idCounter = 0;
|
|
3335
3764
|
var ScrollBlock = class extends LocalizedComponent {
|
|
3765
|
+
static _i18n = scrollI18n;
|
|
3766
|
+
static i18n = scrollI18n;
|
|
3767
|
+
root;
|
|
3768
|
+
viewport;
|
|
3769
|
+
options;
|
|
3770
|
+
createdViewport = false;
|
|
3771
|
+
isDestroyed = false;
|
|
3772
|
+
wasIdGenerated = false;
|
|
3773
|
+
wasRoleInferred = false;
|
|
3774
|
+
wasAriaLabelInferred = false;
|
|
3775
|
+
hasExplicitAriaLabel = false;
|
|
3776
|
+
hasRootAriaLabel = false;
|
|
3777
|
+
propagatedRootLabel = null;
|
|
3778
|
+
lastInferredAriaLabel = "";
|
|
3779
|
+
trackY;
|
|
3780
|
+
thumbY;
|
|
3781
|
+
trackX;
|
|
3782
|
+
thumbX;
|
|
3783
|
+
resizeObserver;
|
|
3784
|
+
hideTimer;
|
|
3785
|
+
scrollEndFallbackTimer;
|
|
3786
|
+
rafId = null;
|
|
3787
|
+
resizeRafId = null;
|
|
3788
|
+
abortController = new AbortController();
|
|
3789
|
+
dragAbortController;
|
|
3790
|
+
activeScrollToController;
|
|
3791
|
+
supportsScrollEnd = typeof window !== "undefined" && "onscrollend" in window;
|
|
3792
|
+
// Cache de métriques géométriques mis à jour dans update() pour éviter tout forced reflow en cours de scroll
|
|
3793
|
+
cachedMaxTop = 0;
|
|
3794
|
+
cachedMaxLeft = 0;
|
|
3795
|
+
cachedTrackHeight = 0;
|
|
3796
|
+
cachedThumbHeight = 0;
|
|
3797
|
+
cachedTrackWidth = 0;
|
|
3798
|
+
cachedThumbWidth = 0;
|
|
3799
|
+
isDragging = false;
|
|
3800
|
+
dragAxis;
|
|
3801
|
+
dragPointerId;
|
|
3802
|
+
dragStartPos = 0;
|
|
3803
|
+
dragStartScroll = 0;
|
|
3804
|
+
atBottom = false;
|
|
3805
|
+
atTop = true;
|
|
3806
|
+
atRight = false;
|
|
3807
|
+
atLeft = true;
|
|
3808
|
+
// Références d'écouteurs d'événements pour les callbacks et le drag
|
|
3809
|
+
boundOnScroll;
|
|
3810
|
+
boundOnScrollEnd;
|
|
3811
|
+
boundOnMouseEnter;
|
|
3812
|
+
boundOnMouseLeave;
|
|
3813
|
+
boundOnFocusIn;
|
|
3814
|
+
boundOnFocusOut;
|
|
3815
|
+
boundPointerMove;
|
|
3816
|
+
boundPointerUp;
|
|
3336
3817
|
constructor(element, options) {
|
|
3337
3818
|
super(options?.i18n);
|
|
3338
|
-
this.createdViewport = false;
|
|
3339
|
-
this.wasIdGenerated = false;
|
|
3340
|
-
this.wasRoleInferred = false;
|
|
3341
|
-
this.wasAriaLabelInferred = false;
|
|
3342
|
-
this.hasExplicitAriaLabel = false;
|
|
3343
|
-
this.lastInferredAriaLabel = "";
|
|
3344
|
-
this.isDragging = false;
|
|
3345
|
-
this.dragStartPos = 0;
|
|
3346
|
-
this.dragStartScroll = 0;
|
|
3347
|
-
this.atBottom = false;
|
|
3348
|
-
this.atTop = true;
|
|
3349
|
-
this.atRight = false;
|
|
3350
|
-
this.atLeft = true;
|
|
3351
3819
|
let resolvedElement = null;
|
|
3352
3820
|
if (typeof element === "string") {
|
|
3353
3821
|
try {
|
|
@@ -3371,6 +3839,7 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3371
3839
|
const safeEdgeThreshold = typeof rawEdge === "number" && Number.isFinite(rawEdge) && rawEdge >= 0 ? rawEdge : 10;
|
|
3372
3840
|
this.options = {
|
|
3373
3841
|
axis: options?.axis || "y",
|
|
3842
|
+
mode: options?.mode || "custom",
|
|
3374
3843
|
autoHide: options?.autoHide ?? true,
|
|
3375
3844
|
autoHideDelay: safeAutoHideDelay,
|
|
3376
3845
|
alwaysVisible: options?.alwaysVisible ?? false,
|
|
@@ -3380,6 +3849,8 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3380
3849
|
edgeThreshold: safeEdgeThreshold,
|
|
3381
3850
|
onScroll: options?.onScroll || (() => {
|
|
3382
3851
|
}),
|
|
3852
|
+
onScrollEnd: options?.onScrollEnd || (() => {
|
|
3853
|
+
}),
|
|
3383
3854
|
onTotalScroll: options?.onTotalScroll || (() => {
|
|
3384
3855
|
}),
|
|
3385
3856
|
onTotalScrollBack: options?.onTotalScrollBack || (() => {
|
|
@@ -3387,6 +3858,7 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3387
3858
|
audit: options?.audit ?? true
|
|
3388
3859
|
};
|
|
3389
3860
|
this.boundOnScroll = this.handleScroll.bind(this);
|
|
3861
|
+
this.boundOnScrollEnd = this.handleScrollEnd.bind(this);
|
|
3390
3862
|
this.boundOnMouseEnter = this.handleMouseEnter.bind(this);
|
|
3391
3863
|
this.boundOnMouseLeave = this.handleMouseLeave.bind(this);
|
|
3392
3864
|
this.boundOnFocusIn = this.handleFocusIn.bind(this);
|
|
@@ -3406,6 +3878,9 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3406
3878
|
*/
|
|
3407
3879
|
setupViewport() {
|
|
3408
3880
|
this.root.classList.add("wulf-scrollblock");
|
|
3881
|
+
if (this.options.mode === "native") {
|
|
3882
|
+
this.root.classList.add("wulf-scrollblock--native");
|
|
3883
|
+
}
|
|
3409
3884
|
if (this.options.alwaysVisible) {
|
|
3410
3885
|
this.root.classList.add("is-always-visible");
|
|
3411
3886
|
}
|
|
@@ -3416,12 +3891,13 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3416
3891
|
if (existingViewport) {
|
|
3417
3892
|
return existingViewport;
|
|
3418
3893
|
}
|
|
3894
|
+
const existingChildren = Array.from(this.root.childNodes);
|
|
3419
3895
|
const viewport = document.createElement("div");
|
|
3420
3896
|
viewport.className = "wulf-scrollblock-viewport";
|
|
3421
|
-
while (this.root.firstChild) {
|
|
3422
|
-
viewport.appendChild(this.root.firstChild);
|
|
3423
|
-
}
|
|
3424
3897
|
this.root.appendChild(viewport);
|
|
3898
|
+
for (const child of existingChildren) {
|
|
3899
|
+
safeMove(viewport, child, null);
|
|
3900
|
+
}
|
|
3425
3901
|
this.createdViewport = true;
|
|
3426
3902
|
return viewport;
|
|
3427
3903
|
}
|
|
@@ -3438,8 +3914,27 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3438
3914
|
this.viewport.setAttribute("role", "region");
|
|
3439
3915
|
this.wasRoleInferred = true;
|
|
3440
3916
|
}
|
|
3441
|
-
|
|
3442
|
-
|
|
3917
|
+
const rootLabelledBy = this.root.getAttribute("aria-labelledby")?.trim();
|
|
3918
|
+
const rootAriaLabel = this.root.getAttribute("aria-label")?.trim();
|
|
3919
|
+
if (rootLabelledBy) {
|
|
3920
|
+
this.hasRootAriaLabel = true;
|
|
3921
|
+
if (!this.hasExplicitAriaLabel && !this.viewport.hasAttribute("aria-labelledby") && !this.viewport.hasAttribute("aria-label")) {
|
|
3922
|
+
this.viewport.setAttribute("aria-labelledby", rootLabelledBy);
|
|
3923
|
+
this.propagatedRootLabel = "aria-labelledby";
|
|
3924
|
+
}
|
|
3925
|
+
} else if (rootAriaLabel) {
|
|
3926
|
+
this.hasRootAriaLabel = true;
|
|
3927
|
+
if (!this.hasExplicitAriaLabel && !this.viewport.hasAttribute("aria-label") && !this.viewport.hasAttribute("aria-labelledby")) {
|
|
3928
|
+
this.viewport.setAttribute("aria-label", rootAriaLabel);
|
|
3929
|
+
this.propagatedRootLabel = "aria-label";
|
|
3930
|
+
}
|
|
3931
|
+
}
|
|
3932
|
+
if (this.hasExplicitAriaLabel && !this.viewport.hasAttribute("aria-label")) {
|
|
3933
|
+
this.viewport.setAttribute("aria-label", this.options.ariaLabel);
|
|
3934
|
+
this.lastInferredAriaLabel = this.options.ariaLabel;
|
|
3935
|
+
this.wasAriaLabelInferred = true;
|
|
3936
|
+
} else if (!this.viewport.hasAttribute("aria-label") && !this.viewport.hasAttribute("aria-labelledby")) {
|
|
3937
|
+
const label = this.t("viewport");
|
|
3443
3938
|
this.viewport.setAttribute("aria-label", label);
|
|
3444
3939
|
this.lastInferredAriaLabel = label;
|
|
3445
3940
|
this.wasAriaLabelInferred = true;
|
|
@@ -3469,10 +3964,12 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3469
3964
|
* Crée les rails et curseurs selon l'axe sélectionné.
|
|
3470
3965
|
*/
|
|
3471
3966
|
setupScrollbars() {
|
|
3967
|
+
if (this.options.mode === "native") {
|
|
3968
|
+
return;
|
|
3969
|
+
}
|
|
3472
3970
|
if (this.options.axis === "y" || this.options.axis === "both") {
|
|
3473
3971
|
this.trackY = document.createElement("div");
|
|
3474
3972
|
this.trackY.className = "wulf-scrollblock-track wulf-scrollblock-vertical";
|
|
3475
|
-
this.trackY.setAttribute("aria-hidden", "true");
|
|
3476
3973
|
this.thumbY = document.createElement("div");
|
|
3477
3974
|
this.thumbY.className = "wulf-scrollblock-thumb";
|
|
3478
3975
|
this.thumbY.setAttribute("role", "scrollbar");
|
|
@@ -3489,7 +3986,6 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3489
3986
|
if (this.options.axis === "x" || this.options.axis === "both") {
|
|
3490
3987
|
this.trackX = document.createElement("div");
|
|
3491
3988
|
this.trackX.className = "wulf-scrollblock-track wulf-scrollblock-horizontal";
|
|
3492
|
-
this.trackX.setAttribute("aria-hidden", "true");
|
|
3493
3989
|
this.thumbX = document.createElement("div");
|
|
3494
3990
|
this.thumbX.className = "wulf-scrollblock-thumb";
|
|
3495
3991
|
this.thumbX.setAttribute("role", "scrollbar");
|
|
@@ -3504,57 +4000,144 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3504
4000
|
this.attachTrackListeners(this.trackX, this.thumbX, "x");
|
|
3505
4001
|
}
|
|
3506
4002
|
}
|
|
4003
|
+
isRtl() {
|
|
4004
|
+
return typeof window !== "undefined" && window.getComputedStyle(this.viewport).direction === "rtl";
|
|
4005
|
+
}
|
|
3507
4006
|
/**
|
|
3508
|
-
* Attache les écouteurs sur un rail et son curseur.
|
|
4007
|
+
* Attache les écouteurs souris/pointeur et clavier WAI-ARIA sur un rail et son curseur.
|
|
3509
4008
|
*/
|
|
3510
4009
|
attachTrackListeners(track, thumb, axis) {
|
|
4010
|
+
const { signal } = this.abortController;
|
|
3511
4011
|
thumb.addEventListener("pointerdown", (e) => {
|
|
4012
|
+
if (e.button !== 0) return;
|
|
3512
4013
|
e.preventDefault();
|
|
3513
4014
|
e.stopPropagation();
|
|
4015
|
+
this.dragAbortController?.abort();
|
|
4016
|
+
this.dragAbortController = new AbortController();
|
|
4017
|
+
const dragSignal = this.dragAbortController.signal;
|
|
3514
4018
|
this.isDragging = true;
|
|
3515
4019
|
this.dragAxis = axis;
|
|
3516
4020
|
this.dragPointerId = e.pointerId;
|
|
3517
4021
|
this.dragStartPos = axis === "y" ? e.clientY : e.clientX;
|
|
3518
4022
|
this.dragStartScroll = axis === "y" ? this.viewport.scrollTop : this.viewport.scrollLeft;
|
|
3519
|
-
|
|
4023
|
+
try {
|
|
4024
|
+
thumb.setPointerCapture(e.pointerId);
|
|
4025
|
+
} catch {
|
|
4026
|
+
}
|
|
3520
4027
|
thumb.classList.add("is-active");
|
|
3521
4028
|
this.root.classList.add("is-dragging");
|
|
3522
|
-
window.addEventListener("pointermove", this.boundPointerMove);
|
|
3523
|
-
window.addEventListener("pointerup", this.boundPointerUp);
|
|
3524
|
-
window.addEventListener("pointercancel", this.boundPointerUp);
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
e.
|
|
3529
|
-
const
|
|
3530
|
-
const
|
|
3531
|
-
const
|
|
3532
|
-
|
|
3533
|
-
const
|
|
3534
|
-
const
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
4029
|
+
window.addEventListener("pointermove", this.boundPointerMove, { signal: dragSignal });
|
|
4030
|
+
window.addEventListener("pointerup", this.boundPointerUp, { signal: dragSignal });
|
|
4031
|
+
window.addEventListener("pointercancel", this.boundPointerUp, { signal: dragSignal });
|
|
4032
|
+
thumb.addEventListener("lostpointercapture", this.boundPointerUp, { signal: dragSignal });
|
|
4033
|
+
}, { signal });
|
|
4034
|
+
thumb.addEventListener("keydown", (e) => {
|
|
4035
|
+
if (e.ctrlKey || e.altKey || e.metaKey) return;
|
|
4036
|
+
const step = 40;
|
|
4037
|
+
const page = axis === "y" ? Math.max(step, Math.round(this.viewport.clientHeight * 0.9)) : Math.max(step, Math.round(this.viewport.clientWidth * 0.9));
|
|
4038
|
+
const maxScroll = axis === "y" ? this.cachedMaxTop : this.cachedMaxLeft;
|
|
4039
|
+
if (maxScroll <= 0) return;
|
|
4040
|
+
const rtl = axis === "x" && this.isRtl();
|
|
4041
|
+
const current = axis === "y" ? this.viewport.scrollTop : this.viewport.scrollLeft;
|
|
4042
|
+
let target = null;
|
|
4043
|
+
if (axis === "y") {
|
|
4044
|
+
switch (e.key) {
|
|
4045
|
+
case "ArrowDown":
|
|
4046
|
+
target = current + step;
|
|
4047
|
+
break;
|
|
4048
|
+
case "ArrowUp":
|
|
4049
|
+
target = current - step;
|
|
4050
|
+
break;
|
|
4051
|
+
case "PageDown":
|
|
4052
|
+
target = current + page;
|
|
4053
|
+
break;
|
|
4054
|
+
case "PageUp":
|
|
4055
|
+
target = current - page;
|
|
4056
|
+
break;
|
|
4057
|
+
case " ":
|
|
4058
|
+
target = current + (e.shiftKey ? -page : page);
|
|
4059
|
+
break;
|
|
4060
|
+
case "Home":
|
|
4061
|
+
target = 0;
|
|
4062
|
+
break;
|
|
4063
|
+
case "End":
|
|
4064
|
+
target = maxScroll;
|
|
4065
|
+
break;
|
|
4066
|
+
}
|
|
4067
|
+
} else {
|
|
4068
|
+
switch (e.key) {
|
|
4069
|
+
case "ArrowRight":
|
|
4070
|
+
target = current + step;
|
|
4071
|
+
break;
|
|
4072
|
+
case "ArrowLeft":
|
|
4073
|
+
target = current - step;
|
|
4074
|
+
break;
|
|
4075
|
+
case "PageDown":
|
|
4076
|
+
target = current + (rtl ? -page : page);
|
|
4077
|
+
break;
|
|
4078
|
+
case "PageUp":
|
|
4079
|
+
target = current + (rtl ? page : -page);
|
|
4080
|
+
break;
|
|
4081
|
+
case " ":
|
|
4082
|
+
target = current + (e.shiftKey ? rtl ? page : -page : rtl ? -page : page);
|
|
4083
|
+
break;
|
|
4084
|
+
case "Home":
|
|
4085
|
+
target = 0;
|
|
4086
|
+
break;
|
|
4087
|
+
case "End":
|
|
4088
|
+
target = rtl ? -maxScroll : maxScroll;
|
|
4089
|
+
break;
|
|
4090
|
+
}
|
|
4091
|
+
}
|
|
4092
|
+
if (target === null) return;
|
|
4093
|
+
e.preventDefault();
|
|
4094
|
+
e.stopPropagation();
|
|
4095
|
+
void this.scrollTo(axis === "y" ? { top: target } : { left: target }, { smooth: false });
|
|
4096
|
+
this.syncThumbs();
|
|
4097
|
+
}, { signal });
|
|
4098
|
+
track.addEventListener("pointerdown", (e) => {
|
|
4099
|
+
if (e.button !== 0 || e.target === thumb) return;
|
|
4100
|
+
e.preventDefault();
|
|
4101
|
+
const rtl = axis === "x" && this.isRtl();
|
|
4102
|
+
const rect = track.getBoundingClientRect();
|
|
4103
|
+
const clickPos = axis === "y" ? e.clientY - rect.top : rtl ? rect.right - e.clientX : e.clientX - rect.left;
|
|
4104
|
+
const trackSize = axis === "y" ? rect.height : rect.width;
|
|
4105
|
+
if (trackSize <= 0) return;
|
|
4106
|
+
const maxScroll = axis === "y" ? this.cachedMaxTop : this.cachedMaxLeft;
|
|
4107
|
+
const ratio = Math.max(0, Math.min(1, clickPos / trackSize));
|
|
4108
|
+
const targetScroll = rtl ? -(ratio * maxScroll) : ratio * maxScroll;
|
|
4109
|
+
void this.scrollTo(axis === "y" ? { top: targetScroll } : { left: targetScroll }, { smooth: true });
|
|
4110
|
+
}, { signal });
|
|
4111
|
+
}
|
|
4112
|
+
/**
|
|
4113
|
+
* Écouteurs globaux sur le viewport et les interactions.
|
|
4114
|
+
*/
|
|
4115
|
+
setupEventListeners() {
|
|
4116
|
+
const { signal } = this.abortController;
|
|
4117
|
+
this.viewport.addEventListener("scroll", this.boundOnScroll, { passive: true, signal });
|
|
4118
|
+
if (this.supportsScrollEnd) {
|
|
4119
|
+
this.viewport.addEventListener("scrollend", this.boundOnScrollEnd, { passive: true, signal });
|
|
4120
|
+
}
|
|
4121
|
+
if (this.options.mode !== "native" && this.options.autoHide && !this.options.alwaysVisible) {
|
|
4122
|
+
this.root.addEventListener("mouseenter", this.boundOnMouseEnter, { signal });
|
|
4123
|
+
this.root.addEventListener("mouseleave", this.boundOnMouseLeave, { signal });
|
|
4124
|
+
this.root.addEventListener("focusin", this.boundOnFocusIn, { signal });
|
|
4125
|
+
this.root.addEventListener("focusout", this.boundOnFocusOut, { signal });
|
|
4126
|
+
}
|
|
4127
|
+
}
|
|
4128
|
+
/**
|
|
4129
|
+
* Initialise le ResizeObserver réactif.
|
|
4130
|
+
*/
|
|
4131
|
+
setupObserver() {
|
|
4132
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
3556
4133
|
this.resizeObserver = new ResizeObserver(() => {
|
|
3557
|
-
|
|
4134
|
+
if (this.isDestroyed || this.resizeRafId !== null) return;
|
|
4135
|
+
this.resizeRafId = window.requestAnimationFrame(() => {
|
|
4136
|
+
this.resizeRafId = null;
|
|
4137
|
+
if (!this.isDestroyed) {
|
|
4138
|
+
this.update();
|
|
4139
|
+
}
|
|
4140
|
+
});
|
|
3558
4141
|
});
|
|
3559
4142
|
this.resizeObserver.observe(this.root);
|
|
3560
4143
|
this.resizeObserver.observe(this.viewport);
|
|
@@ -3568,22 +4151,20 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3568
4151
|
*/
|
|
3569
4152
|
handlePointerMove(e) {
|
|
3570
4153
|
if (!this.isDragging || !this.dragAxis) return;
|
|
4154
|
+
if (this.dragPointerId !== void 0 && e.pointerId !== this.dragPointerId) return;
|
|
3571
4155
|
const isY = this.dragAxis === "y";
|
|
3572
4156
|
const delta = (isY ? e.clientY : e.clientX) - this.dragStartPos;
|
|
3573
|
-
const
|
|
3574
|
-
const
|
|
3575
|
-
|
|
3576
|
-
const trackSize = isY ? track.clientHeight : track.clientWidth;
|
|
3577
|
-
const thumbSize = isY ? thumb.clientHeight : thumb.clientWidth;
|
|
3578
|
-
const clientSize = isY ? this.viewport.clientHeight : this.viewport.clientWidth;
|
|
3579
|
-
const scrollSize = isY ? this.viewport.scrollHeight : this.viewport.scrollWidth;
|
|
3580
|
-
const maxScroll = scrollSize - clientSize;
|
|
4157
|
+
const trackSize = isY ? this.cachedTrackHeight : this.cachedTrackWidth;
|
|
4158
|
+
const thumbSize = isY ? this.cachedThumbHeight : this.cachedThumbWidth;
|
|
4159
|
+
const maxScroll = isY ? this.cachedMaxTop : this.cachedMaxLeft;
|
|
3581
4160
|
const maxThumbTravel = trackSize - thumbSize;
|
|
3582
4161
|
if (maxThumbTravel <= 0 || maxScroll <= 0) return;
|
|
3583
4162
|
const ratio = maxScroll / maxThumbTravel;
|
|
3584
4163
|
const nextScroll = this.dragStartScroll + delta * ratio;
|
|
3585
4164
|
if (isY) {
|
|
3586
4165
|
this.viewport.scrollTop = Math.max(0, Math.min(maxScroll, nextScroll));
|
|
4166
|
+
} else if (this.isRtl()) {
|
|
4167
|
+
this.viewport.scrollLeft = Math.max(-maxScroll, Math.min(0, nextScroll));
|
|
3587
4168
|
} else {
|
|
3588
4169
|
this.viewport.scrollLeft = Math.max(0, Math.min(maxScroll, nextScroll));
|
|
3589
4170
|
}
|
|
@@ -3593,15 +4174,20 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3593
4174
|
*/
|
|
3594
4175
|
handlePointerUp(e) {
|
|
3595
4176
|
if (!this.isDragging) return;
|
|
4177
|
+
if (e && e.type !== "lostpointercapture" && this.dragPointerId !== void 0 && e.pointerId !== this.dragPointerId) {
|
|
4178
|
+
return;
|
|
4179
|
+
}
|
|
3596
4180
|
if (this.dragPointerId !== void 0) {
|
|
3597
4181
|
const activeThumb = this.dragAxis === "y" ? this.thumbY : this.thumbX;
|
|
3598
|
-
|
|
3599
|
-
activeThumb.
|
|
4182
|
+
try {
|
|
4183
|
+
if (activeThumb && activeThumb.hasPointerCapture(this.dragPointerId)) {
|
|
4184
|
+
activeThumb.releasePointerCapture(this.dragPointerId);
|
|
4185
|
+
}
|
|
4186
|
+
} catch {
|
|
3600
4187
|
}
|
|
3601
4188
|
}
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
window.removeEventListener("pointercancel", this.boundPointerUp);
|
|
4189
|
+
this.dragAbortController?.abort();
|
|
4190
|
+
this.dragAbortController = void 0;
|
|
3605
4191
|
this.isDragging = false;
|
|
3606
4192
|
this.dragAxis = void 0;
|
|
3607
4193
|
this.dragPointerId = void 0;
|
|
@@ -3610,24 +4196,31 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3610
4196
|
this.root.classList.remove("is-dragging");
|
|
3611
4197
|
this.scheduleAutoHide();
|
|
3612
4198
|
}
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
this.
|
|
3618
|
-
const
|
|
3619
|
-
const
|
|
3620
|
-
const
|
|
3621
|
-
|
|
3622
|
-
const progressX = maxLeft > 0 ? scrollLeft / maxLeft : 0;
|
|
3623
|
-
this.options.onScroll({
|
|
4199
|
+
getScrollInfo() {
|
|
4200
|
+
const { scrollTop, scrollLeft } = this.viewport;
|
|
4201
|
+
const maxTop = this.cachedMaxTop;
|
|
4202
|
+
const maxLeft = this.cachedMaxLeft;
|
|
4203
|
+
const rtl = this.isRtl();
|
|
4204
|
+
const logicalLeft = rtl ? Math.max(0, -scrollLeft) : Math.max(0, scrollLeft);
|
|
4205
|
+
const progressY = maxTop > 0 ? Math.max(0, Math.min(1, scrollTop / maxTop)) : 0;
|
|
4206
|
+
const progressX = maxLeft > 0 ? Math.max(0, Math.min(1, logicalLeft / maxLeft)) : 0;
|
|
4207
|
+
return {
|
|
3624
4208
|
top: scrollTop,
|
|
3625
4209
|
left: scrollLeft,
|
|
3626
4210
|
maxTop,
|
|
3627
4211
|
maxLeft,
|
|
3628
4212
|
progressY: Math.round(progressY * 100),
|
|
3629
4213
|
progressX: Math.round(progressX * 100)
|
|
3630
|
-
}
|
|
4214
|
+
};
|
|
4215
|
+
}
|
|
4216
|
+
/**
|
|
4217
|
+
* Gestionnaire d'événement de défilement natif.
|
|
4218
|
+
*/
|
|
4219
|
+
handleScroll() {
|
|
4220
|
+
this.scheduleSyncThumbs();
|
|
4221
|
+
const info = this.getScrollInfo();
|
|
4222
|
+
const { top: scrollTop, left: scrollLeft, maxTop, maxLeft } = info;
|
|
4223
|
+
this.options.onScroll(info);
|
|
3631
4224
|
const threshold = this.options.edgeThreshold;
|
|
3632
4225
|
if (maxTop > 0) {
|
|
3633
4226
|
const nowBottom = scrollTop >= maxTop - threshold;
|
|
@@ -3642,8 +4235,9 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3642
4235
|
this.atTop = nowTop;
|
|
3643
4236
|
}
|
|
3644
4237
|
if (maxLeft > 0) {
|
|
3645
|
-
const
|
|
3646
|
-
const
|
|
4238
|
+
const rtl = this.isRtl();
|
|
4239
|
+
const nowRight = rtl ? scrollLeft >= -threshold : scrollLeft >= maxLeft - threshold;
|
|
4240
|
+
const nowLeft = rtl ? scrollLeft <= -maxLeft + threshold : scrollLeft <= threshold;
|
|
3647
4241
|
if (nowRight && !this.atRight) {
|
|
3648
4242
|
this.options.onTotalScroll("right");
|
|
3649
4243
|
}
|
|
@@ -3653,37 +4247,71 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3653
4247
|
this.atRight = nowRight;
|
|
3654
4248
|
this.atLeft = nowLeft;
|
|
3655
4249
|
}
|
|
3656
|
-
if (this.options.autoHide && !this.options.alwaysVisible) {
|
|
4250
|
+
if (this.options.mode !== "native" && this.options.autoHide && !this.options.alwaysVisible) {
|
|
4251
|
+
this.clearAutoHideTimer();
|
|
3657
4252
|
this.root.classList.add("is-scrolling");
|
|
4253
|
+
if (!this.supportsScrollEnd) {
|
|
4254
|
+
this.scheduleAutoHide();
|
|
4255
|
+
}
|
|
4256
|
+
}
|
|
4257
|
+
if (!this.supportsScrollEnd) {
|
|
4258
|
+
if (this.scrollEndFallbackTimer !== void 0) {
|
|
4259
|
+
window.clearTimeout(this.scrollEndFallbackTimer);
|
|
4260
|
+
}
|
|
4261
|
+
this.scrollEndFallbackTimer = window.setTimeout(() => {
|
|
4262
|
+
this.scrollEndFallbackTimer = void 0;
|
|
4263
|
+
this.handleScrollEnd();
|
|
4264
|
+
}, 150);
|
|
4265
|
+
}
|
|
4266
|
+
}
|
|
4267
|
+
/**
|
|
4268
|
+
* Gestionnaire de fin de défilement (`scrollend` natif ou repli temporisé).
|
|
4269
|
+
*/
|
|
4270
|
+
handleScrollEnd() {
|
|
4271
|
+
this.options.onScrollEnd(this.getScrollInfo());
|
|
4272
|
+
if (this.options.mode !== "native" && this.options.autoHide && !this.options.alwaysVisible) {
|
|
3658
4273
|
this.scheduleAutoHide();
|
|
3659
4274
|
}
|
|
3660
4275
|
}
|
|
3661
4276
|
/**
|
|
3662
|
-
*
|
|
4277
|
+
* Planifie une synchronisation des curseurs calée sur la prochaine trame d'affichage.
|
|
4278
|
+
*/
|
|
4279
|
+
scheduleSyncThumbs() {
|
|
4280
|
+
if (this.options.mode === "native" || this.isDestroyed) return;
|
|
4281
|
+
if (this.rafId !== null) return;
|
|
4282
|
+
this.rafId = window.requestAnimationFrame(() => {
|
|
4283
|
+
this.rafId = null;
|
|
4284
|
+
if (!this.isDestroyed) {
|
|
4285
|
+
this.syncThumbs();
|
|
4286
|
+
}
|
|
4287
|
+
});
|
|
4288
|
+
}
|
|
4289
|
+
/**
|
|
4290
|
+
* Synchronise la position physique (via variables CSS) et ARIA des curseurs à partir des métriques en cache.
|
|
3663
4291
|
*/
|
|
3664
4292
|
syncThumbs() {
|
|
3665
|
-
|
|
4293
|
+
if (this.options.mode === "native" || this.isDestroyed) return;
|
|
4294
|
+
const { scrollTop, scrollLeft } = this.viewport;
|
|
3666
4295
|
if (this.thumbY && this.trackY) {
|
|
3667
|
-
const maxScrollY =
|
|
3668
|
-
const
|
|
3669
|
-
const thumbHeight = this.thumbY.clientHeight;
|
|
3670
|
-
const maxTravelY = trackHeight - thumbHeight;
|
|
4296
|
+
const maxScrollY = this.cachedMaxTop;
|
|
4297
|
+
const maxTravelY = this.cachedTrackHeight - this.cachedThumbHeight;
|
|
3671
4298
|
if (maxScrollY > 0 && maxTravelY > 0) {
|
|
3672
|
-
const ratioY = scrollTop / maxScrollY;
|
|
4299
|
+
const ratioY = Math.max(0, Math.min(1, scrollTop / maxScrollY));
|
|
3673
4300
|
const posY = Math.max(0, Math.min(maxTravelY, ratioY * maxTravelY));
|
|
3674
|
-
this.thumbY.style.
|
|
4301
|
+
this.thumbY.style.setProperty("--scrollblock-thumb-y", `${posY}px`);
|
|
3675
4302
|
this.thumbY.setAttribute("aria-valuenow", String(Math.round(ratioY * 100)));
|
|
3676
4303
|
}
|
|
3677
4304
|
}
|
|
3678
4305
|
if (this.thumbX && this.trackX) {
|
|
3679
|
-
const maxScrollX =
|
|
3680
|
-
const
|
|
3681
|
-
const thumbWidth = this.thumbX.clientWidth;
|
|
3682
|
-
const maxTravelX = trackWidth - thumbWidth;
|
|
4306
|
+
const maxScrollX = this.cachedMaxLeft;
|
|
4307
|
+
const maxTravelX = this.cachedTrackWidth - this.cachedThumbWidth;
|
|
3683
4308
|
if (maxScrollX > 0 && maxTravelX > 0) {
|
|
3684
|
-
const
|
|
4309
|
+
const rtl = this.isRtl();
|
|
4310
|
+
const logicalLeft = rtl ? Math.max(0, -scrollLeft) : Math.max(0, scrollLeft);
|
|
4311
|
+
const ratioX = Math.max(0, Math.min(1, logicalLeft / maxScrollX));
|
|
3685
4312
|
const posX = Math.max(0, Math.min(maxTravelX, ratioX * maxTravelX));
|
|
3686
|
-
|
|
4313
|
+
const signedPosX = rtl ? -posX : posX;
|
|
4314
|
+
this.thumbX.style.setProperty("--scrollblock-thumb-x", `${signedPosX}px`);
|
|
3687
4315
|
this.thumbX.setAttribute("aria-valuenow", String(Math.round(ratioX * 100)));
|
|
3688
4316
|
}
|
|
3689
4317
|
}
|
|
@@ -3720,10 +4348,37 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3720
4348
|
* Recalcule les dimensions et la visibilité des barres.
|
|
3721
4349
|
*/
|
|
3722
4350
|
update() {
|
|
4351
|
+
if (this.isDestroyed) return;
|
|
3723
4352
|
this.syncAccessibilityLabels();
|
|
3724
4353
|
const { scrollHeight, clientHeight, scrollWidth, clientWidth } = this.viewport;
|
|
4354
|
+
const trackHeight = this.trackY ? this.trackY.clientHeight : 0;
|
|
4355
|
+
const trackWidth = this.trackX ? this.trackX.clientWidth : 0;
|
|
4356
|
+
const cssMinY = this.thumbY && typeof window !== "undefined" ? parseFloat(window.getComputedStyle(this.thumbY).minBlockSize) || 0 : 0;
|
|
4357
|
+
const cssMinX = this.thumbX && typeof window !== "undefined" ? parseFloat(window.getComputedStyle(this.thumbX).minInlineSize) || 0 : 0;
|
|
4358
|
+
this.cachedMaxTop = Math.max(0, scrollHeight - clientHeight);
|
|
4359
|
+
this.cachedMaxLeft = Math.max(0, scrollWidth - clientWidth);
|
|
4360
|
+
this.cachedTrackHeight = trackHeight;
|
|
4361
|
+
this.cachedTrackWidth = trackWidth;
|
|
3725
4362
|
const canScrollY = scrollHeight > clientHeight;
|
|
3726
4363
|
const canScrollX = scrollWidth > clientWidth;
|
|
4364
|
+
let calculatedHeight = this.cachedThumbHeight;
|
|
4365
|
+
if (this.trackY && this.thumbY && canScrollY && scrollHeight > 0) {
|
|
4366
|
+
const effectiveMinY = Math.max(this.options.minThumbSize, cssMinY);
|
|
4367
|
+
calculatedHeight = Math.max(
|
|
4368
|
+
effectiveMinY,
|
|
4369
|
+
trackHeight * (clientHeight / scrollHeight)
|
|
4370
|
+
);
|
|
4371
|
+
this.cachedThumbHeight = calculatedHeight;
|
|
4372
|
+
}
|
|
4373
|
+
let calculatedWidth = this.cachedThumbWidth;
|
|
4374
|
+
if (this.trackX && this.thumbX && canScrollX && scrollWidth > 0) {
|
|
4375
|
+
const effectiveMinX = Math.max(this.options.minThumbSize, cssMinX);
|
|
4376
|
+
calculatedWidth = Math.max(
|
|
4377
|
+
effectiveMinX,
|
|
4378
|
+
trackWidth * (clientWidth / scrollWidth)
|
|
4379
|
+
);
|
|
4380
|
+
this.cachedThumbWidth = calculatedWidth;
|
|
4381
|
+
}
|
|
3727
4382
|
this.root.classList.toggle("has-scroll-y", canScrollY);
|
|
3728
4383
|
this.root.classList.toggle("has-scroll-x", canScrollX);
|
|
3729
4384
|
if (canScrollY || canScrollX) {
|
|
@@ -3732,37 +4387,40 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3732
4387
|
this.viewport.removeAttribute("tabindex");
|
|
3733
4388
|
}
|
|
3734
4389
|
if (this.trackY && this.thumbY) {
|
|
4390
|
+
this.trackY.hidden = !canScrollY;
|
|
3735
4391
|
if (canScrollY) {
|
|
3736
|
-
|
|
3737
|
-
const calculatedHeight = Math.max(
|
|
3738
|
-
this.options.minThumbSize,
|
|
3739
|
-
trackHeight * (clientHeight / scrollHeight)
|
|
3740
|
-
);
|
|
4392
|
+
this.thumbY.setAttribute("tabindex", "0");
|
|
3741
4393
|
this.thumbY.style.height = `${calculatedHeight}px`;
|
|
4394
|
+
} else {
|
|
4395
|
+
this.thumbY.removeAttribute("tabindex");
|
|
3742
4396
|
}
|
|
3743
4397
|
}
|
|
3744
4398
|
if (this.trackX && this.thumbX) {
|
|
4399
|
+
this.trackX.hidden = !canScrollX;
|
|
3745
4400
|
if (canScrollX) {
|
|
3746
|
-
|
|
3747
|
-
const calculatedWidth = Math.max(
|
|
3748
|
-
this.options.minThumbSize,
|
|
3749
|
-
trackWidth * (clientWidth / scrollWidth)
|
|
3750
|
-
);
|
|
4401
|
+
this.thumbX.setAttribute("tabindex", "0");
|
|
3751
4402
|
this.thumbX.style.width = `${calculatedWidth}px`;
|
|
4403
|
+
} else {
|
|
4404
|
+
this.thumbX.removeAttribute("tabindex");
|
|
3752
4405
|
}
|
|
3753
4406
|
}
|
|
3754
4407
|
this.syncThumbs();
|
|
3755
4408
|
}
|
|
3756
4409
|
/**
|
|
3757
4410
|
* Défilement programmatique direct ou lissé.
|
|
4411
|
+
* Retourne une Promesse résolue lorsque le défilement atteint sa cible.
|
|
3758
4412
|
*/
|
|
3759
4413
|
scrollTo(target, options) {
|
|
3760
|
-
|
|
4414
|
+
if (this.isDestroyed) return Promise.resolve();
|
|
3761
4415
|
const targetSmooth = typeof target === "object" && target !== null && !(target instanceof HTMLElement) ? target.smooth : void 0;
|
|
3762
|
-
const shouldSmooth = (options?.smooth ?? targetSmooth ?? true) && !prefersReducedMotion;
|
|
4416
|
+
const shouldSmooth = (options?.smooth ?? targetSmooth ?? true) && !prefersReducedMotion();
|
|
3763
4417
|
const behavior = shouldSmooth ? "smooth" : "auto";
|
|
3764
|
-
const
|
|
3765
|
-
const
|
|
4418
|
+
const rtl = this.isRtl();
|
|
4419
|
+
const { scrollHeight, clientHeight, scrollWidth, clientWidth, scrollTop, scrollLeft } = this.viewport;
|
|
4420
|
+
const maxTop = Math.max(0, scrollHeight - clientHeight);
|
|
4421
|
+
const maxLeft = Math.max(0, scrollWidth - clientWidth);
|
|
4422
|
+
this.cachedMaxTop = maxTop;
|
|
4423
|
+
this.cachedMaxLeft = maxLeft;
|
|
3766
4424
|
let targetTop;
|
|
3767
4425
|
let targetLeft;
|
|
3768
4426
|
if (typeof target === "number") {
|
|
@@ -3776,19 +4434,19 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3776
4434
|
targetTop = maxTop;
|
|
3777
4435
|
break;
|
|
3778
4436
|
case "left":
|
|
3779
|
-
targetLeft = 0;
|
|
4437
|
+
targetLeft = rtl ? -maxLeft : 0;
|
|
3780
4438
|
break;
|
|
3781
4439
|
case "right":
|
|
3782
|
-
targetLeft = maxLeft;
|
|
4440
|
+
targetLeft = rtl ? 0 : maxLeft;
|
|
3783
4441
|
break;
|
|
3784
4442
|
default: {
|
|
3785
4443
|
if (/^-?\d+(\.\d+)?%$/.test(target.trim())) {
|
|
3786
4444
|
const pct = Math.max(0, Math.min(100, parseFloat(target.trim()))) / 100;
|
|
3787
4445
|
if (this.options.axis === "x") {
|
|
3788
|
-
targetLeft = maxLeft * pct;
|
|
4446
|
+
targetLeft = rtl ? -maxLeft * pct : maxLeft * pct;
|
|
3789
4447
|
} else if (this.options.axis === "both") {
|
|
3790
4448
|
targetTop = maxTop * pct;
|
|
3791
|
-
targetLeft = maxLeft * pct;
|
|
4449
|
+
targetLeft = rtl ? -maxLeft * pct : maxLeft * pct;
|
|
3792
4450
|
} else {
|
|
3793
4451
|
targetTop = maxTop * pct;
|
|
3794
4452
|
}
|
|
@@ -3801,24 +4459,82 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3801
4459
|
el = null;
|
|
3802
4460
|
}
|
|
3803
4461
|
if (el) {
|
|
3804
|
-
|
|
3805
|
-
|
|
4462
|
+
const vpRect = this.viewport.getBoundingClientRect();
|
|
4463
|
+
const elRect = el.getBoundingClientRect();
|
|
4464
|
+
targetTop = elRect.top - vpRect.top + scrollTop;
|
|
4465
|
+
targetLeft = elRect.left - vpRect.left + scrollLeft;
|
|
3806
4466
|
}
|
|
3807
4467
|
break;
|
|
3808
4468
|
}
|
|
3809
4469
|
}
|
|
3810
4470
|
} else if (target instanceof HTMLElement) {
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
4471
|
+
const vpRect = this.viewport.getBoundingClientRect();
|
|
4472
|
+
const elRect = target.getBoundingClientRect();
|
|
4473
|
+
targetTop = elRect.top - vpRect.top + scrollTop;
|
|
4474
|
+
targetLeft = elRect.left - vpRect.left + scrollLeft;
|
|
4475
|
+
} else if (typeof target === "object" && target !== null) {
|
|
3814
4476
|
targetTop = target.top;
|
|
3815
4477
|
targetLeft = target.left;
|
|
3816
4478
|
}
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
4479
|
+
const clampedTop = targetTop !== void 0 && Number.isFinite(targetTop) ? Math.max(0, Math.min(maxTop, targetTop)) : void 0;
|
|
4480
|
+
const minLeftBound = rtl ? -maxLeft : 0;
|
|
4481
|
+
const maxLeftBound = rtl ? 0 : maxLeft;
|
|
4482
|
+
const clampedLeft = targetLeft !== void 0 && Number.isFinite(targetLeft) ? Math.max(minLeftBound, Math.min(maxLeftBound, targetLeft)) : void 0;
|
|
4483
|
+
const destTop = clampedTop ?? scrollTop;
|
|
4484
|
+
const destLeft = clampedLeft ?? scrollLeft;
|
|
4485
|
+
if (Math.abs(destTop - scrollTop) <= 1 && Math.abs(destLeft - scrollLeft) <= 1) {
|
|
4486
|
+
return Promise.resolve();
|
|
4487
|
+
}
|
|
4488
|
+
this.activeScrollToController?.abort();
|
|
4489
|
+
const waitController = new AbortController();
|
|
4490
|
+
this.activeScrollToController = waitController;
|
|
4491
|
+
const nativeResult = this.viewport.scrollTo({
|
|
4492
|
+
top: clampedTop,
|
|
4493
|
+
left: clampedLeft,
|
|
3820
4494
|
behavior
|
|
3821
4495
|
});
|
|
4496
|
+
if (nativeResult instanceof Promise) {
|
|
4497
|
+
return nativeResult.then(() => {
|
|
4498
|
+
if (this.activeScrollToController === waitController) {
|
|
4499
|
+
this.activeScrollToController = void 0;
|
|
4500
|
+
}
|
|
4501
|
+
});
|
|
4502
|
+
}
|
|
4503
|
+
if (behavior !== "smooth") {
|
|
4504
|
+
if (this.activeScrollToController === waitController) {
|
|
4505
|
+
this.activeScrollToController = void 0;
|
|
4506
|
+
}
|
|
4507
|
+
return Promise.resolve();
|
|
4508
|
+
}
|
|
4509
|
+
return new Promise((resolve) => {
|
|
4510
|
+
let settled = false;
|
|
4511
|
+
let idleTimerId;
|
|
4512
|
+
let maxTimerId;
|
|
4513
|
+
const finish = () => {
|
|
4514
|
+
if (settled) return;
|
|
4515
|
+
settled = true;
|
|
4516
|
+
if (idleTimerId !== void 0) window.clearTimeout(idleTimerId);
|
|
4517
|
+
if (maxTimerId !== void 0) window.clearTimeout(maxTimerId);
|
|
4518
|
+
if (this.activeScrollToController === waitController) {
|
|
4519
|
+
this.activeScrollToController = void 0;
|
|
4520
|
+
}
|
|
4521
|
+
waitController.abort();
|
|
4522
|
+
resolve();
|
|
4523
|
+
};
|
|
4524
|
+
waitController.signal.addEventListener("abort", finish, { once: true });
|
|
4525
|
+
this.abortController.signal.addEventListener("abort", finish, { once: true, signal: waitController.signal });
|
|
4526
|
+
if (this.supportsScrollEnd) {
|
|
4527
|
+
this.viewport.addEventListener("scrollend", finish, { once: true, signal: waitController.signal });
|
|
4528
|
+
} else {
|
|
4529
|
+
const bumpIdle = () => {
|
|
4530
|
+
if (idleTimerId !== void 0) window.clearTimeout(idleTimerId);
|
|
4531
|
+
idleTimerId = window.setTimeout(finish, 150);
|
|
4532
|
+
};
|
|
4533
|
+
this.viewport.addEventListener("scroll", bumpIdle, { passive: true, signal: waitController.signal });
|
|
4534
|
+
bumpIdle();
|
|
4535
|
+
}
|
|
4536
|
+
maxTimerId = window.setTimeout(finish, 2500);
|
|
4537
|
+
});
|
|
3822
4538
|
}
|
|
3823
4539
|
/**
|
|
3824
4540
|
* Vérifie la conformité d'accessibilité WAI-ARIA de la zone défilable
|
|
@@ -3831,12 +4547,12 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3831
4547
|
const hasValidLabelledby = hasViewportLabelledby || hasRootLabelledby;
|
|
3832
4548
|
const rootAriaLabel = this.root.getAttribute("aria-label")?.trim();
|
|
3833
4549
|
const hasCustomViewportAriaLabel = !this.wasAriaLabelInferred && Boolean(this.viewport.getAttribute("aria-label")?.trim());
|
|
3834
|
-
if (!this.hasExplicitAriaLabel && !hasCustomViewportAriaLabel && !rootAriaLabel && !hasValidLabelledby) {
|
|
4550
|
+
if (!this.hasExplicitAriaLabel && !this.hasRootAriaLabel && !hasCustomViewportAriaLabel && !rootAriaLabel && !hasValidLabelledby) {
|
|
3835
4551
|
warnings.push(
|
|
3836
4552
|
"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)."
|
|
3837
4553
|
);
|
|
3838
4554
|
}
|
|
3839
|
-
if (this.options.minThumbSize < 24) {
|
|
4555
|
+
if (this.options.mode !== "native" && this.options.minThumbSize < 24) {
|
|
3840
4556
|
warnings.push(
|
|
3841
4557
|
`Taille minimale du curseur insuffisante (minThumbSize: ${this.options.minThumbSize}px) : utilisez au moins 24px pour respecter WCAG 2.5.8.`
|
|
3842
4558
|
);
|
|
@@ -3853,22 +4569,34 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3853
4569
|
* Détruit le composant et libère toutes les ressources.
|
|
3854
4570
|
*/
|
|
3855
4571
|
destroy() {
|
|
4572
|
+
if (this.isDestroyed) return;
|
|
4573
|
+
this.isDestroyed = true;
|
|
3856
4574
|
this.clearAutoHideTimer();
|
|
4575
|
+
if (this.scrollEndFallbackTimer !== void 0) {
|
|
4576
|
+
window.clearTimeout(this.scrollEndFallbackTimer);
|
|
4577
|
+
this.scrollEndFallbackTimer = void 0;
|
|
4578
|
+
}
|
|
4579
|
+
if (this.rafId !== null) {
|
|
4580
|
+
window.cancelAnimationFrame(this.rafId);
|
|
4581
|
+
this.rafId = null;
|
|
4582
|
+
}
|
|
4583
|
+
if (this.resizeRafId !== null) {
|
|
4584
|
+
window.cancelAnimationFrame(this.resizeRafId);
|
|
4585
|
+
this.resizeRafId = null;
|
|
4586
|
+
}
|
|
4587
|
+
this.activeScrollToController?.abort();
|
|
4588
|
+
this.activeScrollToController = void 0;
|
|
4589
|
+
this.dragAbortController?.abort();
|
|
4590
|
+
this.dragAbortController = void 0;
|
|
4591
|
+
this.abortController.abort();
|
|
3857
4592
|
if (this.resizeObserver) {
|
|
3858
4593
|
this.resizeObserver.disconnect();
|
|
3859
4594
|
}
|
|
3860
|
-
this.viewport.removeEventListener("scroll", this.boundOnScroll);
|
|
3861
|
-
this.root.removeEventListener("mouseenter", this.boundOnMouseEnter);
|
|
3862
|
-
this.root.removeEventListener("mouseleave", this.boundOnMouseLeave);
|
|
3863
|
-
this.root.removeEventListener("focusin", this.boundOnFocusIn);
|
|
3864
|
-
this.root.removeEventListener("focusout", this.boundOnFocusOut);
|
|
3865
|
-
window.removeEventListener("pointermove", this.boundPointerMove);
|
|
3866
|
-
window.removeEventListener("pointerup", this.boundPointerUp);
|
|
3867
|
-
window.removeEventListener("pointercancel", this.boundPointerUp);
|
|
3868
4595
|
this.trackY?.remove();
|
|
3869
4596
|
this.trackX?.remove();
|
|
3870
4597
|
this.root.classList.remove(
|
|
3871
4598
|
"wulf-scrollblock",
|
|
4599
|
+
"wulf-scrollblock--native",
|
|
3872
4600
|
"has-scroll-y",
|
|
3873
4601
|
"has-scroll-x",
|
|
3874
4602
|
"has-both-axes",
|
|
@@ -3879,7 +4607,7 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3879
4607
|
);
|
|
3880
4608
|
if (this.createdViewport && this.viewport.parentElement === this.root) {
|
|
3881
4609
|
while (this.viewport.firstChild) {
|
|
3882
|
-
this.root
|
|
4610
|
+
safeMove(this.root, this.viewport.firstChild, this.viewport);
|
|
3883
4611
|
}
|
|
3884
4612
|
this.viewport.remove();
|
|
3885
4613
|
} else {
|
|
@@ -3890,14 +4618,15 @@ var ScrollBlock = class extends LocalizedComponent {
|
|
|
3890
4618
|
if (this.wasRoleInferred && this.viewport.getAttribute("role") === "region") {
|
|
3891
4619
|
this.viewport.removeAttribute("role");
|
|
3892
4620
|
}
|
|
4621
|
+
if (this.propagatedRootLabel) {
|
|
4622
|
+
this.viewport.removeAttribute(this.propagatedRootLabel);
|
|
4623
|
+
}
|
|
3893
4624
|
if (this.wasAriaLabelInferred && this.viewport.getAttribute("aria-label") === this.lastInferredAriaLabel) {
|
|
3894
4625
|
this.viewport.removeAttribute("aria-label");
|
|
3895
4626
|
}
|
|
3896
4627
|
}
|
|
3897
4628
|
}
|
|
3898
4629
|
};
|
|
3899
|
-
ScrollBlock._i18n = scrollI18n;
|
|
3900
|
-
ScrollBlock.i18n = scrollI18n;
|
|
3901
4630
|
|
|
3902
4631
|
// src/scroll/index.ts
|
|
3903
4632
|
var Scroll = {
|
|
@@ -3905,11 +4634,9 @@ var Scroll = {
|
|
|
3905
4634
|
i18n: scrollI18n
|
|
3906
4635
|
};
|
|
3907
4636
|
var scroll_default = ScrollBlock;
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
win.Wulf = wulfNamespace;
|
|
3912
|
-
wulfNamespace.Scroll = Scroll;
|
|
4637
|
+
var wulfNamespace2 = getSafeWulfNamespace();
|
|
4638
|
+
if (wulfNamespace2) {
|
|
4639
|
+
wulfNamespace2.Scroll = Scroll;
|
|
3913
4640
|
}
|
|
3914
4641
|
|
|
3915
4642
|
// src/masonry/index.ts
|
|
@@ -4004,11 +4731,13 @@ var LayoutEngine = class {
|
|
|
4004
4731
|
return Math.min(maxCols, parsed);
|
|
4005
4732
|
}
|
|
4006
4733
|
}
|
|
4007
|
-
const
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4734
|
+
for (const cls of item.classList) {
|
|
4735
|
+
const match = /^(?:span|col-span)-(\d+)$/.exec(cls);
|
|
4736
|
+
if (match && match[1]) {
|
|
4737
|
+
const parsed = parseInt(match[1], 10);
|
|
4738
|
+
if (!isNaN(parsed) && parsed > 0) {
|
|
4739
|
+
return Math.min(maxCols, parsed);
|
|
4740
|
+
}
|
|
4012
4741
|
}
|
|
4013
4742
|
}
|
|
4014
4743
|
return 1;
|
|
@@ -4100,7 +4829,10 @@ var LayoutEngine = class {
|
|
|
4100
4829
|
}
|
|
4101
4830
|
}
|
|
4102
4831
|
const itemW = span * colWidth + (span - 1) * gutterX;
|
|
4103
|
-
const
|
|
4832
|
+
const isRtl = typeof window !== "undefined" && typeof window.getComputedStyle === "function" && window.getComputedStyle(container).direction === "rtl";
|
|
4833
|
+
const effectiveWidth = fittedWidth !== void 0 ? fittedWidth : containerWidth;
|
|
4834
|
+
const rawX = targetCol * (colWidth + gutterX);
|
|
4835
|
+
const targetX = isRtl ? Math.max(0, effectiveWidth - rawX - itemW) : rawX;
|
|
4104
4836
|
positions.push({
|
|
4105
4837
|
element: item,
|
|
4106
4838
|
x: targetX,
|
|
@@ -4153,20 +4885,28 @@ var masonryI18n = createI18nManager("fr", {
|
|
|
4153
4885
|
|
|
4154
4886
|
// src/masonry/Masonry.ts
|
|
4155
4887
|
var Masonry = class extends LocalizedComponent {
|
|
4888
|
+
static _i18n = masonryI18n;
|
|
4889
|
+
static i18n = masonryI18n;
|
|
4890
|
+
root;
|
|
4891
|
+
isNativeCSSGrid = false;
|
|
4892
|
+
_items = [];
|
|
4893
|
+
options;
|
|
4894
|
+
resizeObserver = null;
|
|
4895
|
+
itemResizeObserver = null;
|
|
4896
|
+
observedItems = /* @__PURE__ */ new Set();
|
|
4897
|
+
observedItemHeights = /* @__PURE__ */ new WeakMap();
|
|
4898
|
+
removingItems = /* @__PURE__ */ new WeakSet();
|
|
4899
|
+
layoutRafId = null;
|
|
4900
|
+
isDestroyed = false;
|
|
4901
|
+
wasRoleInferred = false;
|
|
4902
|
+
wasAriaLabelInferred = false;
|
|
4903
|
+
hasExplicitAriaLabel = false;
|
|
4904
|
+
lastInferredAriaLabel = "";
|
|
4905
|
+
abortController = new AbortController();
|
|
4906
|
+
watchedImages = /* @__PURE__ */ new WeakSet();
|
|
4907
|
+
originalContainerStyles;
|
|
4156
4908
|
constructor(target, options = {}) {
|
|
4157
4909
|
super(options.i18n);
|
|
4158
|
-
this.isNativeCSSGrid = false;
|
|
4159
|
-
this._items = [];
|
|
4160
|
-
this.resizeObserver = null;
|
|
4161
|
-
this.itemResizeObserver = null;
|
|
4162
|
-
this.layoutRafId = null;
|
|
4163
|
-
this.isDestroyed = false;
|
|
4164
|
-
this.wasRoleInferred = false;
|
|
4165
|
-
this.wasAriaLabelInferred = false;
|
|
4166
|
-
this.hasExplicitAriaLabel = false;
|
|
4167
|
-
this.lastInferredAriaLabel = "";
|
|
4168
|
-
this.removeTimers = /* @__PURE__ */ new Set();
|
|
4169
|
-
this.pendingImageListeners = [];
|
|
4170
4910
|
if (typeof target === "string") {
|
|
4171
4911
|
let el = null;
|
|
4172
4912
|
try {
|
|
@@ -4209,10 +4949,11 @@ var Masonry = class extends LocalizedComponent {
|
|
|
4209
4949
|
}),
|
|
4210
4950
|
audit: options.audit ?? true
|
|
4211
4951
|
};
|
|
4212
|
-
const supportsNativeCSS = typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("grid-template-rows", "masonry");
|
|
4952
|
+
const supportsNativeCSS = typeof CSS !== "undefined" && typeof CSS.supports === "function" && (CSS.supports("display", "grid-lanes") || CSS.supports("grid-template-rows", "masonry"));
|
|
4213
4953
|
if (this.options.useNativeCSSGrid && supportsNativeCSS) {
|
|
4214
4954
|
this.isNativeCSSGrid = true;
|
|
4215
4955
|
this.root.classList.add("wulf-masonry", "wulf-masonry--native");
|
|
4956
|
+
this.syncNativeGridVariables();
|
|
4216
4957
|
} else {
|
|
4217
4958
|
this.root.classList.add("wulf-masonry");
|
|
4218
4959
|
}
|
|
@@ -4236,7 +4977,7 @@ var Masonry = class extends LocalizedComponent {
|
|
|
4236
4977
|
this.wasRoleInferred = true;
|
|
4237
4978
|
}
|
|
4238
4979
|
const label = this.hasExplicitAriaLabel ? this.options.ariaLabel : this.t("gallery");
|
|
4239
|
-
if (label && !this.root.hasAttribute("aria-label")) {
|
|
4980
|
+
if (label && !this.root.hasAttribute("aria-label") && !this.root.hasAttribute("aria-labelledby")) {
|
|
4240
4981
|
this.root.setAttribute("aria-label", label);
|
|
4241
4982
|
this.lastInferredAriaLabel = label;
|
|
4242
4983
|
this.wasAriaLabelInferred = true;
|
|
@@ -4264,7 +5005,7 @@ var Masonry = class extends LocalizedComponent {
|
|
|
4264
5005
|
let durValue = "300ms";
|
|
4265
5006
|
if (typeof dur === "number" && Number.isFinite(dur) && dur >= 0) {
|
|
4266
5007
|
durValue = `${dur}ms`;
|
|
4267
|
-
} else if (typeof dur === "string" && /^\s
|
|
5008
|
+
} else if (typeof dur === "string" && /^\s*(?:\d+(?:\.\d+)?|\.\d+)(ms|s)\s*$/i.test(dur)) {
|
|
4268
5009
|
durValue = dur.trim();
|
|
4269
5010
|
}
|
|
4270
5011
|
this.root.style.setProperty("--wulf-masonry-duration", durValue);
|
|
@@ -4277,24 +5018,37 @@ var Masonry = class extends LocalizedComponent {
|
|
|
4277
5018
|
let matched = [];
|
|
4278
5019
|
if (this.options.itemSelector === "> *") {
|
|
4279
5020
|
matched = Array.from(this.root.children).filter(
|
|
4280
|
-
(el) => el instanceof HTMLElement && !el.hasAttribute("data-masonry-ignore")
|
|
5021
|
+
(el) => el instanceof HTMLElement && !el.hasAttribute("data-masonry-ignore") && !this.removingItems.has(el)
|
|
4281
5022
|
);
|
|
4282
5023
|
} else {
|
|
4283
5024
|
try {
|
|
4284
|
-
|
|
4285
|
-
|
|
5025
|
+
const rawSelector = this.options.itemSelector.trim();
|
|
5026
|
+
const selector = rawSelector.startsWith(">") ? `:scope ${rawSelector}` : rawSelector;
|
|
5027
|
+
matched = Array.from(this.root.querySelectorAll(selector)).filter(
|
|
5028
|
+
(el) => el.parentElement === this.root && !el.hasAttribute("data-masonry-ignore") && !this.removingItems.has(el)
|
|
4286
5029
|
);
|
|
4287
5030
|
} catch {
|
|
4288
5031
|
matched = Array.from(this.root.children).filter(
|
|
4289
|
-
(el) => el instanceof HTMLElement && !el.hasAttribute("data-masonry-ignore")
|
|
5032
|
+
(el) => el instanceof HTMLElement && !el.hasAttribute("data-masonry-ignore") && !this.removingItems.has(el)
|
|
4290
5033
|
);
|
|
4291
5034
|
}
|
|
4292
5035
|
}
|
|
5036
|
+
if (this.itemResizeObserver) {
|
|
5037
|
+
const nextSet = new Set(matched);
|
|
5038
|
+
for (const prevEl of this.observedItems) {
|
|
5039
|
+
if (!nextSet.has(prevEl)) {
|
|
5040
|
+
this.itemResizeObserver.unobserve(prevEl);
|
|
5041
|
+
this.observedItems.delete(prevEl);
|
|
5042
|
+
this.observedItemHeights.delete(prevEl);
|
|
5043
|
+
}
|
|
5044
|
+
}
|
|
5045
|
+
}
|
|
4293
5046
|
this._items = matched;
|
|
4294
5047
|
for (const item of this._items) {
|
|
4295
5048
|
item.classList.add("wulf-masonry-item");
|
|
4296
|
-
if (this.itemResizeObserver) {
|
|
5049
|
+
if (this.itemResizeObserver && !this.observedItems.has(item)) {
|
|
4297
5050
|
this.itemResizeObserver.observe(item);
|
|
5051
|
+
this.observedItems.add(item);
|
|
4298
5052
|
}
|
|
4299
5053
|
}
|
|
4300
5054
|
}
|
|
@@ -4314,11 +5068,52 @@ var Masonry = class extends LocalizedComponent {
|
|
|
4314
5068
|
}
|
|
4315
5069
|
});
|
|
4316
5070
|
this.resizeObserver.observe(this.root);
|
|
4317
|
-
this.itemResizeObserver = new ResizeObserver(() => {
|
|
4318
|
-
|
|
5071
|
+
this.itemResizeObserver = new ResizeObserver((entries) => {
|
|
5072
|
+
let heightChanged = false;
|
|
5073
|
+
for (const entry of entries) {
|
|
5074
|
+
const newH = entry.borderBoxSize?.[0]?.blockSize ?? entry.contentRect.height;
|
|
5075
|
+
const prevH = this.observedItemHeights.get(entry.target);
|
|
5076
|
+
if (prevH === void 0 || Math.abs(newH - prevH) >= 1) {
|
|
5077
|
+
this.observedItemHeights.set(entry.target, newH);
|
|
5078
|
+
if (prevH !== void 0) {
|
|
5079
|
+
heightChanged = true;
|
|
5080
|
+
}
|
|
5081
|
+
}
|
|
5082
|
+
}
|
|
5083
|
+
if (heightChanged) {
|
|
5084
|
+
this.scheduleLayout();
|
|
5085
|
+
}
|
|
4319
5086
|
});
|
|
4320
5087
|
for (const item of this._items) {
|
|
4321
5088
|
this.itemResizeObserver.observe(item);
|
|
5089
|
+
this.observedItems.add(item);
|
|
5090
|
+
}
|
|
5091
|
+
}
|
|
5092
|
+
/**
|
|
5093
|
+
* Synchronise les variables CSS du mode natif CSS Grid Level 3 depuis les options JS.
|
|
5094
|
+
*/
|
|
5095
|
+
syncNativeGridVariables() {
|
|
5096
|
+
const { x: gutterX, y: gutterY } = LayoutEngine.parseGutter(this.options.gutter);
|
|
5097
|
+
this.root.style.setProperty("--wulf-masonry-gutter-x", `${gutterX}px`);
|
|
5098
|
+
this.root.style.setProperty("--wulf-masonry-gutter-y", `${gutterY}px`);
|
|
5099
|
+
if (typeof this.options.columnWidth === "number" && Number.isFinite(this.options.columnWidth) && this.options.columnWidth > 0) {
|
|
5100
|
+
this.root.style.setProperty("--wulf-masonry-col-min", `${this.options.columnWidth}px`);
|
|
5101
|
+
} else if (this.options.columnWidth instanceof HTMLElement) {
|
|
5102
|
+
const w = this.options.columnWidth.getBoundingClientRect().width;
|
|
5103
|
+
if (w > 0) {
|
|
5104
|
+
this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
|
|
5105
|
+
}
|
|
5106
|
+
} else if (typeof this.options.columnWidth === "string" && this.options.columnWidth.trim()) {
|
|
5107
|
+
try {
|
|
5108
|
+
const el = this.root.querySelector(this.options.columnWidth);
|
|
5109
|
+
if (el) {
|
|
5110
|
+
const w = el.getBoundingClientRect().width;
|
|
5111
|
+
if (w > 0) {
|
|
5112
|
+
this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
|
|
5113
|
+
}
|
|
5114
|
+
}
|
|
5115
|
+
} catch {
|
|
5116
|
+
}
|
|
4322
5117
|
}
|
|
4323
5118
|
}
|
|
4324
5119
|
/**
|
|
@@ -4328,14 +5123,12 @@ var Masonry = class extends LocalizedComponent {
|
|
|
4328
5123
|
if (!this.options.autoImages) return;
|
|
4329
5124
|
const images = Array.from(this.root.querySelectorAll("img"));
|
|
4330
5125
|
for (const img of images) {
|
|
4331
|
-
if (!img.complete) {
|
|
5126
|
+
if (!img.complete && !this.watchedImages.has(img)) {
|
|
5127
|
+
this.watchedImages.add(img);
|
|
4332
5128
|
const attachLoadListener = () => {
|
|
4333
|
-
|
|
4334
|
-
this.pendingImageListeners = this.pendingImageListeners.filter((l) => l.handler !== onLoad);
|
|
5129
|
+
img.addEventListener("load", () => {
|
|
4335
5130
|
if (!this.isDestroyed) this.scheduleLayout();
|
|
4336
|
-
};
|
|
4337
|
-
this.pendingImageListeners.push({ img, handler: onLoad });
|
|
4338
|
-
img.addEventListener("load", onLoad, { once: true });
|
|
5131
|
+
}, { once: true, signal: this.abortController.signal });
|
|
4339
5132
|
};
|
|
4340
5133
|
if (typeof img.decode === "function") {
|
|
4341
5134
|
img.decode().then(() => {
|
|
@@ -4369,10 +5162,17 @@ var Masonry = class extends LocalizedComponent {
|
|
|
4369
5162
|
if (this.isDestroyed) return;
|
|
4370
5163
|
this.syncAccessibilityLabels();
|
|
4371
5164
|
if (this.isNativeCSSGrid) {
|
|
5165
|
+
this.syncNativeGridVariables();
|
|
5166
|
+
for (const el of this._items) {
|
|
5167
|
+
el.classList.remove("wulf-masonry-item--hidden");
|
|
5168
|
+
}
|
|
4372
5169
|
this.options.onLayout([]);
|
|
4373
5170
|
return;
|
|
4374
5171
|
}
|
|
4375
5172
|
this.root.setAttribute("aria-busy", "true");
|
|
5173
|
+
if (this.options.fitWidth && this.root.classList.contains("wulf-masonry--fit-width")) {
|
|
5174
|
+
this.root.style.width = "";
|
|
5175
|
+
}
|
|
4376
5176
|
const result = LayoutEngine.calculate(this.root, this._items, this.options);
|
|
4377
5177
|
this.root.style.height = `${result.containerHeight}px`;
|
|
4378
5178
|
if (this.options.fitWidth && result.fittedWidth !== void 0) {
|
|
@@ -4382,6 +5182,14 @@ var Masonry = class extends LocalizedComponent {
|
|
|
4382
5182
|
this.root.classList.remove("wulf-masonry--fit-width");
|
|
4383
5183
|
}
|
|
4384
5184
|
const stagger = this.options.stagger;
|
|
5185
|
+
const validStagger = typeof stagger === "number" && Number.isFinite(stagger) && stagger > 0;
|
|
5186
|
+
if (validStagger) {
|
|
5187
|
+
this.root.style.setProperty("--wulf-masonry-stagger", `${stagger}ms`);
|
|
5188
|
+
} else {
|
|
5189
|
+
this.root.style.removeProperty("--wulf-masonry-stagger");
|
|
5190
|
+
}
|
|
5191
|
+
const hasIgnoredChildren = this._items.length !== this.root.children.length;
|
|
5192
|
+
const supportsSiblingIndex = !hasIgnoredChildren && typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("transition-delay", "calc(sibling-index() * 1ms)");
|
|
4385
5193
|
const usePercent = this.options.percentPosition && result.containerWidth > 0;
|
|
4386
5194
|
for (let i = 0; i < result.positions.length; i++) {
|
|
4387
5195
|
const pos = result.positions[i];
|
|
@@ -4394,12 +5202,13 @@ var Masonry = class extends LocalizedComponent {
|
|
|
4394
5202
|
}
|
|
4395
5203
|
item.style.setProperty("--wulf-masonry-x", `${pos.x}px`);
|
|
4396
5204
|
item.style.setProperty("--wulf-masonry-y", `${pos.y}px`);
|
|
4397
|
-
if (
|
|
4398
|
-
item.style.
|
|
5205
|
+
if (validStagger && !supportsSiblingIndex) {
|
|
5206
|
+
item.style.setProperty("--wulf-masonry-index", String(i));
|
|
4399
5207
|
} else {
|
|
4400
|
-
item.style.removeProperty("
|
|
5208
|
+
item.style.removeProperty("--wulf-masonry-index");
|
|
4401
5209
|
}
|
|
4402
5210
|
item.classList.remove("wulf-masonry-item--hidden");
|
|
5211
|
+
this.observedItemHeights.set(item, pos.height);
|
|
4403
5212
|
this.options.onItemPlaced(item, pos);
|
|
4404
5213
|
}
|
|
4405
5214
|
this.root.setAttribute("aria-busy", "false");
|
|
@@ -4414,7 +5223,11 @@ var Masonry = class extends LocalizedComponent {
|
|
|
4414
5223
|
if (list.length === 0) return;
|
|
4415
5224
|
const frag = document.createDocumentFragment();
|
|
4416
5225
|
for (const el of list) {
|
|
4417
|
-
|
|
5226
|
+
if (this.isNativeCSSGrid) {
|
|
5227
|
+
el.classList.add("wulf-masonry-item");
|
|
5228
|
+
} else {
|
|
5229
|
+
el.classList.add("wulf-masonry-item", "wulf-masonry-item--hidden");
|
|
5230
|
+
}
|
|
4418
5231
|
frag.appendChild(el);
|
|
4419
5232
|
}
|
|
4420
5233
|
this.root.appendChild(frag);
|
|
@@ -4432,7 +5245,11 @@ var Masonry = class extends LocalizedComponent {
|
|
|
4432
5245
|
const first = this.root.firstChild;
|
|
4433
5246
|
const frag = document.createDocumentFragment();
|
|
4434
5247
|
for (const el of list) {
|
|
4435
|
-
|
|
5248
|
+
if (this.isNativeCSSGrid) {
|
|
5249
|
+
el.classList.add("wulf-masonry-item");
|
|
5250
|
+
} else {
|
|
5251
|
+
el.classList.add("wulf-masonry-item", "wulf-masonry-item--hidden");
|
|
5252
|
+
}
|
|
4436
5253
|
frag.appendChild(el);
|
|
4437
5254
|
}
|
|
4438
5255
|
this.root.insertBefore(frag, first);
|
|
@@ -4441,44 +5258,51 @@ var Masonry = class extends LocalizedComponent {
|
|
|
4441
5258
|
this.layout();
|
|
4442
5259
|
}
|
|
4443
5260
|
/**
|
|
4444
|
-
* Supprime des éléments avec animation de fondu/sortie.
|
|
5261
|
+
* Supprime des éléments avec animation de fondu/sortie synchronisée via Web Animations API.
|
|
4445
5262
|
*/
|
|
4446
5263
|
remove(elements) {
|
|
4447
5264
|
if (this.isDestroyed) return;
|
|
4448
5265
|
const list = Array.isArray(elements) ? elements : [elements];
|
|
4449
5266
|
if (list.length === 0) return;
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
}
|
|
4453
|
-
const dur = typeof this.options.transitionDuration === "number" ? this.options.transitionDuration : 300;
|
|
4454
|
-
if (dur <= 0) {
|
|
5267
|
+
const finalizeRemoval = () => {
|
|
5268
|
+
if (this.isDestroyed) return;
|
|
4455
5269
|
for (const el of list) {
|
|
5270
|
+
this.removingItems.delete(el);
|
|
4456
5271
|
if (el.parentElement === this.root) {
|
|
4457
5272
|
if (this.itemResizeObserver) {
|
|
4458
5273
|
this.itemResizeObserver.unobserve(el);
|
|
5274
|
+
this.observedItems.delete(el);
|
|
5275
|
+
this.observedItemHeights.delete(el);
|
|
4459
5276
|
}
|
|
4460
5277
|
this.root.removeChild(el);
|
|
4461
5278
|
}
|
|
4462
5279
|
}
|
|
4463
5280
|
this.reloadItems();
|
|
4464
5281
|
this.layout();
|
|
5282
|
+
};
|
|
5283
|
+
for (const el of list) {
|
|
5284
|
+
this.removingItems.add(el);
|
|
5285
|
+
if (typeof document !== "undefined" && document.activeElement && el.contains(document.activeElement)) {
|
|
5286
|
+
document.activeElement.blur?.();
|
|
5287
|
+
}
|
|
5288
|
+
el.setAttribute("inert", "");
|
|
5289
|
+
el.style.transitionDelay = "0ms";
|
|
5290
|
+
el.classList.add("wulf-masonry-item--hidden");
|
|
5291
|
+
}
|
|
5292
|
+
const dur = parseCssDurationMs(this.options.transitionDuration, 300);
|
|
5293
|
+
if (dur <= 0 || this.isNativeCSSGrid) {
|
|
5294
|
+
finalizeRemoval();
|
|
4465
5295
|
return;
|
|
4466
5296
|
}
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
}
|
|
4475
|
-
this.root.removeChild(el);
|
|
4476
|
-
}
|
|
5297
|
+
this.reloadItems();
|
|
5298
|
+
this.layout();
|
|
5299
|
+
Promise.all(
|
|
5300
|
+
list.map((el) => waitForAnimations(el, dur, this.abortController.signal))
|
|
5301
|
+
).then(() => {
|
|
5302
|
+
if (!this.abortController.signal.aborted) {
|
|
5303
|
+
finalizeRemoval();
|
|
4477
5304
|
}
|
|
4478
|
-
|
|
4479
|
-
this.layout();
|
|
4480
|
-
}, dur);
|
|
4481
|
-
this.removeTimers.add(timerId);
|
|
5305
|
+
});
|
|
4482
5306
|
}
|
|
4483
5307
|
/**
|
|
4484
5308
|
* Vérifie la conformité d'accessibilité WAI-ARIA de la grille Masonry
|
|
@@ -4515,14 +5339,7 @@ var Masonry = class extends LocalizedComponent {
|
|
|
4515
5339
|
destroy() {
|
|
4516
5340
|
if (this.isDestroyed) return;
|
|
4517
5341
|
this.isDestroyed = true;
|
|
4518
|
-
|
|
4519
|
-
clearTimeout(timerId);
|
|
4520
|
-
}
|
|
4521
|
-
this.removeTimers.clear();
|
|
4522
|
-
for (const { img, handler } of this.pendingImageListeners) {
|
|
4523
|
-
img.removeEventListener("load", handler);
|
|
4524
|
-
}
|
|
4525
|
-
this.pendingImageListeners = [];
|
|
5342
|
+
this.abortController.abort();
|
|
4526
5343
|
if (this.layoutRafId !== null) {
|
|
4527
5344
|
cancelAnimationFrame(this.layoutRafId);
|
|
4528
5345
|
this.layoutRafId = null;
|
|
@@ -4544,6 +5361,10 @@ var Masonry = class extends LocalizedComponent {
|
|
|
4544
5361
|
this.root.removeAttribute("aria-label");
|
|
4545
5362
|
}
|
|
4546
5363
|
this.root.style.removeProperty("--wulf-masonry-duration");
|
|
5364
|
+
this.root.style.removeProperty("--wulf-masonry-stagger");
|
|
5365
|
+
this.root.style.removeProperty("--wulf-masonry-col-min");
|
|
5366
|
+
this.root.style.removeProperty("--wulf-masonry-gutter-x");
|
|
5367
|
+
this.root.style.removeProperty("--wulf-masonry-gutter-y");
|
|
4547
5368
|
if (this.originalContainerStyles.height) {
|
|
4548
5369
|
this.root.style.height = this.originalContainerStyles.height;
|
|
4549
5370
|
} else {
|
|
@@ -4559,21 +5380,17 @@ var Masonry = class extends LocalizedComponent {
|
|
|
4559
5380
|
item.style.removeProperty("--wulf-masonry-w");
|
|
4560
5381
|
item.style.removeProperty("--wulf-masonry-x");
|
|
4561
5382
|
item.style.removeProperty("--wulf-masonry-y");
|
|
4562
|
-
item.style.removeProperty("
|
|
5383
|
+
item.style.removeProperty("--wulf-masonry-index");
|
|
4563
5384
|
}
|
|
4564
5385
|
this._items = [];
|
|
4565
5386
|
}
|
|
4566
5387
|
};
|
|
4567
|
-
Masonry._i18n = masonryI18n;
|
|
4568
|
-
Masonry.i18n = masonryI18n;
|
|
4569
5388
|
|
|
4570
5389
|
// src/masonry/index.ts
|
|
4571
5390
|
var masonry_default = Masonry;
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
win.Wulf = wulfNamespace;
|
|
4576
|
-
wulfNamespace.Masonry = Object.assign(Masonry, {
|
|
5391
|
+
var wulfNamespace3 = getSafeWulfNamespace();
|
|
5392
|
+
if (wulfNamespace3) {
|
|
5393
|
+
wulfNamespace3.Masonry = Object.assign(Masonry, {
|
|
4577
5394
|
Masonry,
|
|
4578
5395
|
LayoutEngine,
|
|
4579
5396
|
i18n: masonryI18n
|
|
@@ -4596,12 +5413,14 @@ __export(toast_exports, {
|
|
|
4596
5413
|
|
|
4597
5414
|
// src/toast/i18n/fr.ts
|
|
4598
5415
|
var toastFr = {
|
|
4599
|
-
closeButton: "Fermer la notification"
|
|
5416
|
+
closeButton: "Fermer la notification",
|
|
5417
|
+
notificationsRegion: "Notifications"
|
|
4600
5418
|
};
|
|
4601
5419
|
|
|
4602
5420
|
// src/toast/i18n/en.ts
|
|
4603
5421
|
var toastEn = {
|
|
4604
|
-
closeButton: "Close notification"
|
|
5422
|
+
closeButton: "Close notification",
|
|
5423
|
+
notificationsRegion: "Notifications"
|
|
4605
5424
|
};
|
|
4606
5425
|
|
|
4607
5426
|
// src/toast/i18n/index.ts
|
|
@@ -4612,29 +5431,54 @@ var toastI18n = createI18nManager("fr", {
|
|
|
4612
5431
|
|
|
4613
5432
|
// src/toast/ToastInstance.ts
|
|
4614
5433
|
var nextToastId = 1;
|
|
5434
|
+
var DEFAULT_TOAST_DURATION = 5e3;
|
|
4615
5435
|
function isSafeCssValue(val) {
|
|
4616
5436
|
if (!val || typeof val !== "string" || val.length > 128) return false;
|
|
4617
|
-
|
|
5437
|
+
const trimmed = val.trim();
|
|
5438
|
+
if (!trimmed) return false;
|
|
5439
|
+
if (/[\u0000-\u001F\u007F;{}<>\\]|(?:url|image-set|-webkit-image-set|image|src|expression|attr|env)\s*\(/i.test(trimmed)) {
|
|
5440
|
+
return false;
|
|
5441
|
+
}
|
|
5442
|
+
if (typeof CSS !== "undefined" && typeof CSS.supports === "function") {
|
|
5443
|
+
return CSS.supports("color", trimmed) || CSS.supports("background-color", trimmed);
|
|
5444
|
+
}
|
|
5445
|
+
return true;
|
|
4618
5446
|
}
|
|
4619
5447
|
function sanitizeIconClasses(icon) {
|
|
4620
|
-
return icon.trim().split(/\s+/).filter((token) => /^[a-zA-Z0-9_-]+$/.test(token) && !token.startsWith("wulf-toast")).slice(0, 8).join(" ");
|
|
5448
|
+
return icon.slice(0, 128).trim().split(/\s+/).filter((token) => /^[a-zA-Z0-9_-]+$/.test(token) && !token.startsWith("wulf-toast")).slice(0, 8).join(" ");
|
|
4621
5449
|
}
|
|
4622
5450
|
var ToastInstance = class extends AuditableComponent {
|
|
5451
|
+
id;
|
|
5452
|
+
options;
|
|
5453
|
+
element;
|
|
5454
|
+
_isClosed = false;
|
|
5455
|
+
_isFinalized = false;
|
|
5456
|
+
closePromise = null;
|
|
5457
|
+
timerId = null;
|
|
5458
|
+
remainingTime = 0;
|
|
5459
|
+
hasDuration = false;
|
|
5460
|
+
timerStartTime = 0;
|
|
5461
|
+
isPausedByHover = false;
|
|
5462
|
+
isPausedByFocus = false;
|
|
5463
|
+
isPausedByVisibility = false;
|
|
5464
|
+
isPendingFocusDismiss = false;
|
|
5465
|
+
previousActiveElement = null;
|
|
5466
|
+
eventsAbortController = new AbortController();
|
|
5467
|
+
disposeAbortController = new AbortController();
|
|
5468
|
+
onDismissCallback;
|
|
4623
5469
|
constructor(options, onDismiss) {
|
|
4624
5470
|
super();
|
|
4625
|
-
this._isClosed = false;
|
|
4626
|
-
this.timerId = null;
|
|
4627
|
-
this.remainingTime = 0;
|
|
4628
|
-
this.timerStartTime = 0;
|
|
4629
|
-
this.isPaused = false;
|
|
4630
5471
|
this.id = `wulf-toast-${nextToastId++}`;
|
|
4631
5472
|
this.options = Object.freeze({ ...options });
|
|
4632
5473
|
this.onDismissCallback = onDismiss;
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
5474
|
+
this.previousActiveElement = typeof document !== "undefined" && document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
5475
|
+
const duration = options.duration === void 0 ? DEFAULT_TOAST_DURATION : options.duration;
|
|
5476
|
+
if (typeof duration === "number" && Number.isFinite(duration) && duration > 0) {
|
|
5477
|
+
this.remainingTime = Math.min(duration, 2147483647);
|
|
5478
|
+
this.hasDuration = true;
|
|
4636
5479
|
} else {
|
|
4637
5480
|
this.remainingTime = 0;
|
|
5481
|
+
this.hasDuration = false;
|
|
4638
5482
|
}
|
|
4639
5483
|
this.element = this.createDOM();
|
|
4640
5484
|
this.bindEvents();
|
|
@@ -4643,6 +5487,9 @@ var ToastInstance = class extends AuditableComponent {
|
|
|
4643
5487
|
get isClosed() {
|
|
4644
5488
|
return this._isClosed;
|
|
4645
5489
|
}
|
|
5490
|
+
getPreviousActiveElement() {
|
|
5491
|
+
return this.previousActiveElement;
|
|
5492
|
+
}
|
|
4646
5493
|
/**
|
|
4647
5494
|
* Vérifie la conformité d'accessibilité WAI-ARIA de la notification Toast
|
|
4648
5495
|
* et retourne la liste des contraintes manquantes.
|
|
@@ -4656,7 +5503,7 @@ var ToastInstance = class extends AuditableComponent {
|
|
|
4656
5503
|
"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)."
|
|
4657
5504
|
);
|
|
4658
5505
|
}
|
|
4659
|
-
const duration = this.options.duration === void 0 ?
|
|
5506
|
+
const duration = this.options.duration === void 0 ? DEFAULT_TOAST_DURATION : this.options.duration;
|
|
4660
5507
|
if (typeof duration === "number" && duration > 0 && duration < 5e3) {
|
|
4661
5508
|
warnings.push(
|
|
4662
5509
|
`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).`
|
|
@@ -4664,9 +5511,9 @@ var ToastInstance = class extends AuditableComponent {
|
|
|
4664
5511
|
}
|
|
4665
5512
|
const closable = this.options.closable ?? true;
|
|
4666
5513
|
const isPersistent = duration === false || typeof duration === "number" && duration <= 0;
|
|
4667
|
-
if (isPersistent && !closable
|
|
5514
|
+
if (isPersistent && !closable) {
|
|
4668
5515
|
warnings.push(
|
|
4669
|
-
"Notification persistante impossible \xE0 fermer : activez closable: true
|
|
5516
|
+
"Notification persistante impossible \xE0 fermer au clavier : activez closable: true lorsque duration est d\xE9sactiv\xE9 (WCAG 2.1.1)."
|
|
4670
5517
|
);
|
|
4671
5518
|
}
|
|
4672
5519
|
return warnings;
|
|
@@ -4679,15 +5526,13 @@ var ToastInstance = class extends AuditableComponent {
|
|
|
4679
5526
|
}
|
|
4680
5527
|
/**
|
|
4681
5528
|
* Construction du DOM de manière 100% sécurisée sans aucun `innerHTML`.
|
|
5529
|
+
* Les annonces sont gérées sur un canal unique dans `ToastManager` pour éviter tout doublon AT.
|
|
4682
5530
|
*/
|
|
4683
5531
|
createDOM() {
|
|
4684
5532
|
const el = document.createElement("div");
|
|
4685
5533
|
el.id = this.id;
|
|
4686
5534
|
el.className = "wulf-toast";
|
|
4687
|
-
|
|
4688
|
-
el.setAttribute("role", role);
|
|
4689
|
-
el.setAttribute("aria-live", role === "alert" ? "assertive" : "polite");
|
|
4690
|
-
el.setAttribute("aria-atomic", "true");
|
|
5535
|
+
el.setAttribute("data-toast-role", this.options.role === "alert" ? "alert" : "status");
|
|
4691
5536
|
if (this.options.backgroundColor && isSafeCssValue(this.options.backgroundColor)) {
|
|
4692
5537
|
el.style.setProperty("--wulf-toast-bg", this.options.backgroundColor.trim());
|
|
4693
5538
|
}
|
|
@@ -4733,7 +5578,6 @@ var ToastInstance = class extends AuditableComponent {
|
|
|
4733
5578
|
closeBtn.type = "button";
|
|
4734
5579
|
closeBtn.className = "wulf-toast-close";
|
|
4735
5580
|
closeBtn.setAttribute("aria-label", toastI18n.t("closeButton", this.options.i18n));
|
|
4736
|
-
closeBtn.setAttribute("tabindex", "0");
|
|
4737
5581
|
const closeIcon = document.createElement("span");
|
|
4738
5582
|
closeIcon.className = "wulf-toast-close-icon";
|
|
4739
5583
|
closeIcon.setAttribute("aria-hidden", "true");
|
|
@@ -4742,7 +5586,7 @@ var ToastInstance = class extends AuditableComponent {
|
|
|
4742
5586
|
closeBtn.addEventListener("click", (e) => {
|
|
4743
5587
|
e.stopPropagation();
|
|
4744
5588
|
this.close("close-button");
|
|
4745
|
-
});
|
|
5589
|
+
}, { signal: this.eventsAbortController.signal });
|
|
4746
5590
|
el.appendChild(closeBtn);
|
|
4747
5591
|
}
|
|
4748
5592
|
if (this.options.progressBar && this.remainingTime > 0) {
|
|
@@ -4756,7 +5600,6 @@ var ToastInstance = class extends AuditableComponent {
|
|
|
4756
5600
|
}
|
|
4757
5601
|
/**
|
|
4758
5602
|
* Injection de texte sécurisée gérant nativement les retours à la ligne (\n et \r\n).
|
|
4759
|
-
* Utilise document.createTextNode et des éléments <br> créés proprement (plafonné contre le DoS DOM).
|
|
4760
5603
|
*/
|
|
4761
5604
|
appendTextWithLineBreaks(container, text) {
|
|
4762
5605
|
const safeText = String(text ?? "").slice(0, 4096);
|
|
@@ -4769,9 +5612,10 @@ var ToastInstance = class extends AuditableComponent {
|
|
|
4769
5612
|
});
|
|
4770
5613
|
}
|
|
4771
5614
|
/**
|
|
4772
|
-
* Liaison des événements clavier, souris, et pause au survol
|
|
5615
|
+
* Liaison des événements clavier, souris, visibilité d'onglet et pause au survol/focus (WCAG 2.2).
|
|
4773
5616
|
*/
|
|
4774
5617
|
bindEvents() {
|
|
5618
|
+
const { signal } = this.eventsAbortController;
|
|
4775
5619
|
this.element.addEventListener("click", (e) => {
|
|
4776
5620
|
if (this.options.onClick) {
|
|
4777
5621
|
this.options.onClick(this, e);
|
|
@@ -4779,115 +5623,162 @@ var ToastInstance = class extends AuditableComponent {
|
|
|
4779
5623
|
if (this.options.closeOnClick) {
|
|
4780
5624
|
this.close("toast-click");
|
|
4781
5625
|
}
|
|
4782
|
-
});
|
|
4783
|
-
this.element.addEventListener("mouseenter", () => this.pauseTimer());
|
|
4784
|
-
this.element.addEventListener("mouseleave", () => this.resumeTimer());
|
|
4785
|
-
this.element.addEventListener("focusin", () => this.pauseTimer());
|
|
4786
|
-
this.element.addEventListener("focusout", () =>
|
|
5626
|
+
}, { signal });
|
|
5627
|
+
this.element.addEventListener("mouseenter", () => this.pauseTimer("hover"), { signal });
|
|
5628
|
+
this.element.addEventListener("mouseleave", () => this.resumeTimer("hover"), { signal });
|
|
5629
|
+
this.element.addEventListener("focusin", () => this.pauseTimer("focus"), { signal });
|
|
5630
|
+
this.element.addEventListener("focusout", (e) => {
|
|
5631
|
+
const nextFocused = e.relatedTarget;
|
|
5632
|
+
if (nextFocused && this.element.contains(nextFocused)) {
|
|
5633
|
+
return;
|
|
5634
|
+
}
|
|
5635
|
+
if (this.isPendingFocusDismiss && !this._isClosed) {
|
|
5636
|
+
this.isPendingFocusDismiss = false;
|
|
5637
|
+
this.close("timeout");
|
|
5638
|
+
return;
|
|
5639
|
+
}
|
|
5640
|
+
this.resumeTimer("focus");
|
|
5641
|
+
}, { signal });
|
|
5642
|
+
this.element.addEventListener("keydown", (e) => {
|
|
5643
|
+
if (e.key === "Escape" && (this.options.closable ?? true)) {
|
|
5644
|
+
e.stopPropagation();
|
|
5645
|
+
this.close("close-button");
|
|
5646
|
+
}
|
|
5647
|
+
}, { signal });
|
|
5648
|
+
if (typeof document !== "undefined") {
|
|
5649
|
+
document.addEventListener("visibilitychange", () => {
|
|
5650
|
+
if (document.visibilityState === "hidden") {
|
|
5651
|
+
this.pauseTimer("visibility");
|
|
5652
|
+
} else {
|
|
5653
|
+
this.resumeTimer("visibility");
|
|
5654
|
+
}
|
|
5655
|
+
}, { signal });
|
|
5656
|
+
}
|
|
5657
|
+
}
|
|
5658
|
+
get isPaused() {
|
|
5659
|
+
return this.isPausedByHover || this.isPausedByFocus || this.isPausedByVisibility;
|
|
4787
5660
|
}
|
|
4788
5661
|
/**
|
|
4789
|
-
* Démarrage du compte à rebours de disparition automatique
|
|
5662
|
+
* Démarrage du compte à rebours de disparition automatique (horloge monotone).
|
|
4790
5663
|
*/
|
|
4791
5664
|
startTimer() {
|
|
4792
|
-
if (this._isClosed || this.remainingTime <= 0) return;
|
|
4793
|
-
|
|
5665
|
+
if (this._isClosed || this.remainingTime <= 0 || this.isPaused) return;
|
|
5666
|
+
if (typeof document !== "undefined" && document.visibilityState === "hidden") {
|
|
5667
|
+
this.isPausedByVisibility = true;
|
|
5668
|
+
this.element.classList.add("is-paused");
|
|
5669
|
+
return;
|
|
5670
|
+
}
|
|
5671
|
+
if (this.timerId !== null) {
|
|
5672
|
+
window.clearTimeout(this.timerId);
|
|
5673
|
+
this.timerId = null;
|
|
5674
|
+
}
|
|
5675
|
+
this.timerStartTime = performance.now();
|
|
4794
5676
|
this.timerId = window.setTimeout(() => {
|
|
5677
|
+
this.timerId = null;
|
|
5678
|
+
if (typeof document !== "undefined" && this.element.contains(document.activeElement)) {
|
|
5679
|
+
this.isPendingFocusDismiss = true;
|
|
5680
|
+
return;
|
|
5681
|
+
}
|
|
4795
5682
|
this.close("timeout");
|
|
4796
5683
|
}, this.remainingTime);
|
|
4797
5684
|
}
|
|
4798
5685
|
/**
|
|
4799
|
-
* Met en pause le compte à rebours (au survol ou
|
|
5686
|
+
* Met en pause le compte à rebours (au survol, au focus ou à la perte de visibilité d'onglet).
|
|
4800
5687
|
*/
|
|
4801
|
-
pauseTimer() {
|
|
4802
|
-
if (this._isClosed || this.remainingTime <= 0
|
|
5688
|
+
pauseTimer(source = "interaction") {
|
|
5689
|
+
if (this._isClosed || !this.hasDuration || this.remainingTime <= 0) return;
|
|
5690
|
+
const wasPaused = this.isPaused;
|
|
5691
|
+
if (source === "visibility") {
|
|
5692
|
+
this.isPausedByVisibility = true;
|
|
5693
|
+
} else if (source === "focus") {
|
|
5694
|
+
this.isPausedByFocus = true;
|
|
5695
|
+
} else {
|
|
5696
|
+
this.isPausedByHover = true;
|
|
5697
|
+
}
|
|
5698
|
+
if (wasPaused) return;
|
|
4803
5699
|
if (this.timerId !== null) {
|
|
4804
5700
|
window.clearTimeout(this.timerId);
|
|
4805
5701
|
this.timerId = null;
|
|
5702
|
+
const elapsed = performance.now() - this.timerStartTime;
|
|
5703
|
+
this.remainingTime = Math.max(0, this.remainingTime - elapsed);
|
|
4806
5704
|
}
|
|
4807
|
-
const elapsed = Date.now() - this.timerStartTime;
|
|
4808
|
-
this.remainingTime = Math.max(0, this.remainingTime - elapsed);
|
|
4809
|
-
this.isPaused = true;
|
|
4810
5705
|
this.element.classList.add("is-paused");
|
|
4811
5706
|
}
|
|
4812
5707
|
/**
|
|
4813
|
-
* Reprend le compte à rebours
|
|
5708
|
+
* Reprend le compte à rebours si aucune autre cause de pause n'est active.
|
|
4814
5709
|
*/
|
|
4815
|
-
resumeTimer() {
|
|
4816
|
-
if (this._isClosed ||
|
|
4817
|
-
|
|
5710
|
+
resumeTimer(source = "interaction") {
|
|
5711
|
+
if (this._isClosed || !this.hasDuration) return;
|
|
5712
|
+
if (source === "visibility") {
|
|
5713
|
+
this.isPausedByVisibility = false;
|
|
5714
|
+
} else if (source === "focus") {
|
|
5715
|
+
this.isPausedByFocus = false;
|
|
5716
|
+
} else if (source === "hover") {
|
|
5717
|
+
this.isPausedByHover = false;
|
|
5718
|
+
} else {
|
|
5719
|
+
this.isPausedByHover = false;
|
|
5720
|
+
this.isPausedByFocus = false;
|
|
5721
|
+
}
|
|
5722
|
+
if (this.isPaused) return;
|
|
4818
5723
|
this.element.classList.remove("is-paused");
|
|
5724
|
+
if (this.remainingTime <= 0) {
|
|
5725
|
+
this.close("timeout");
|
|
5726
|
+
return;
|
|
5727
|
+
}
|
|
4819
5728
|
this.startTimer();
|
|
4820
5729
|
}
|
|
5730
|
+
finalizeDismiss(reason) {
|
|
5731
|
+
if (this._isFinalized) return;
|
|
5732
|
+
this._isFinalized = true;
|
|
5733
|
+
this.eventsAbortController.abort();
|
|
5734
|
+
if (this.onDismissCallback) {
|
|
5735
|
+
this.onDismissCallback(this, reason);
|
|
5736
|
+
}
|
|
5737
|
+
if (this.element.parentNode) {
|
|
5738
|
+
this.element.parentNode.removeChild(this.element);
|
|
5739
|
+
}
|
|
5740
|
+
if (this.options.onClose) {
|
|
5741
|
+
this.options.onClose(this, reason);
|
|
5742
|
+
}
|
|
5743
|
+
}
|
|
4821
5744
|
/**
|
|
4822
|
-
* Déclenche la destruction immédiate sans animation
|
|
5745
|
+
* Déclenche la destruction immédiate sans animation.
|
|
4823
5746
|
*/
|
|
4824
5747
|
destroyImmediate(reason = "replace") {
|
|
4825
|
-
if (this._isClosed) return;
|
|
4826
5748
|
this._isClosed = true;
|
|
4827
5749
|
if (this.timerId !== null) {
|
|
4828
5750
|
window.clearTimeout(this.timerId);
|
|
4829
5751
|
this.timerId = null;
|
|
4830
5752
|
}
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
}
|
|
4834
|
-
if (this.onDismissCallback) {
|
|
4835
|
-
this.onDismissCallback(this, reason);
|
|
4836
|
-
}
|
|
4837
|
-
if (this.options.onClose) {
|
|
4838
|
-
this.options.onClose(this, reason);
|
|
4839
|
-
}
|
|
5753
|
+
this.disposeAbortController.abort();
|
|
5754
|
+
this.finalizeDismiss(reason);
|
|
4840
5755
|
}
|
|
4841
5756
|
/**
|
|
4842
5757
|
* Déclenche la fermeture propre et l'animation de sortie du toast.
|
|
4843
|
-
* Si fast = true, utilise une disparition accélérée
|
|
5758
|
+
* Si fast = true, utilise une disparition accélérée pour le remplacement séquentiel.
|
|
4844
5759
|
*/
|
|
4845
5760
|
close(reason = "programmatic", fast = false) {
|
|
4846
|
-
if (this._isClosed)
|
|
5761
|
+
if (this._isClosed) {
|
|
5762
|
+
return this.closePromise ?? Promise.resolve();
|
|
5763
|
+
}
|
|
4847
5764
|
this._isClosed = true;
|
|
4848
5765
|
if (this.timerId !== null) {
|
|
4849
5766
|
window.clearTimeout(this.timerId);
|
|
4850
5767
|
this.timerId = null;
|
|
4851
5768
|
}
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
this.options.onClose(this, reason);
|
|
4863
|
-
}
|
|
4864
|
-
resolve();
|
|
4865
|
-
};
|
|
4866
|
-
const isReducedMotion = typeof window !== "undefined" && window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
4867
|
-
if (isReducedMotion) {
|
|
4868
|
-
handleAnimationEnd();
|
|
4869
|
-
} else if (fast) {
|
|
4870
|
-
window.setTimeout(handleAnimationEnd, 90);
|
|
4871
|
-
} else {
|
|
4872
|
-
let transitioned = false;
|
|
4873
|
-
let fallbackTimerId = null;
|
|
4874
|
-
const onEnd = () => {
|
|
4875
|
-
if (!transitioned) {
|
|
4876
|
-
transitioned = true;
|
|
4877
|
-
if (fallbackTimerId !== null) {
|
|
4878
|
-
window.clearTimeout(fallbackTimerId);
|
|
4879
|
-
fallbackTimerId = null;
|
|
4880
|
-
}
|
|
4881
|
-
this.element.removeEventListener("animationend", onEnd);
|
|
4882
|
-
this.element.removeEventListener("transitionend", onEnd);
|
|
4883
|
-
handleAnimationEnd();
|
|
4884
|
-
}
|
|
4885
|
-
};
|
|
4886
|
-
this.element.addEventListener("animationend", onEnd, { once: true });
|
|
4887
|
-
this.element.addEventListener("transitionend", onEnd, { once: true });
|
|
4888
|
-
fallbackTimerId = window.setTimeout(onEnd, 300);
|
|
5769
|
+
this.eventsAbortController.abort();
|
|
5770
|
+
this.element.classList.add(fast ? "wulf-toast-hiding-fast" : "wulf-toast-hiding");
|
|
5771
|
+
if (prefersReducedMotion()) {
|
|
5772
|
+
this.finalizeDismiss(reason);
|
|
5773
|
+
this.closePromise = Promise.resolve();
|
|
5774
|
+
return this.closePromise;
|
|
5775
|
+
}
|
|
5776
|
+
this.closePromise = waitForAnimations(this.element, fast ? 90 : 300, this.disposeAbortController.signal).then(() => {
|
|
5777
|
+
if (!this.disposeAbortController.signal.aborted) {
|
|
5778
|
+
this.finalizeDismiss(reason);
|
|
4889
5779
|
}
|
|
4890
5780
|
});
|
|
5781
|
+
return this.closePromise;
|
|
4891
5782
|
}
|
|
4892
5783
|
};
|
|
4893
5784
|
|
|
@@ -4903,12 +5794,35 @@ var VALID_POSITIONS = /* @__PURE__ */ new Set([
|
|
|
4903
5794
|
function normalizePosition(pos) {
|
|
4904
5795
|
return pos && VALID_POSITIONS.has(pos) ? pos : "top-right";
|
|
4905
5796
|
}
|
|
4906
|
-
var
|
|
5797
|
+
var FOCUSABLE_IN_TOAST = 'button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])';
|
|
5798
|
+
var ToastManager = class _ToastManager {
|
|
5799
|
+
static instance = null;
|
|
5800
|
+
containers = /* @__PURE__ */ new Map();
|
|
5801
|
+
activeToasts = /* @__PURE__ */ new Map();
|
|
5802
|
+
announcerEl = null;
|
|
5803
|
+
politeRegion = null;
|
|
5804
|
+
assertiveRegion = null;
|
|
5805
|
+
announceTimers = [];
|
|
5806
|
+
politeAnnounceTimerId = null;
|
|
5807
|
+
assertiveAnnounceTimerId = null;
|
|
5808
|
+
politeClearTimerId = null;
|
|
5809
|
+
assertiveClearTimerId = null;
|
|
5810
|
+
lastPoliteText = "";
|
|
5811
|
+
lastAssertiveText = "";
|
|
5812
|
+
announcerToggle = false;
|
|
5813
|
+
/**
|
|
5814
|
+
* Vérifie si un conteneur Popover est ouvert (compatible natif et polyfill OddBird).
|
|
5815
|
+
*/
|
|
5816
|
+
isPopoverOpen(container) {
|
|
5817
|
+
try {
|
|
5818
|
+
if (container.matches(":popover-open")) return true;
|
|
5819
|
+
} catch {
|
|
5820
|
+
}
|
|
5821
|
+
return container.classList.contains(":popover-open");
|
|
5822
|
+
}
|
|
5823
|
+
replaceTokens = /* @__PURE__ */ new Map();
|
|
5824
|
+
pendingReplacements = /* @__PURE__ */ new Set();
|
|
4907
5825
|
constructor() {
|
|
4908
|
-
this.containers = /* @__PURE__ */ new Map();
|
|
4909
|
-
this.activeToasts = /* @__PURE__ */ new Map();
|
|
4910
|
-
this.replaceTokens = /* @__PURE__ */ new Map();
|
|
4911
|
-
this.pendingReplacements = /* @__PURE__ */ new Set();
|
|
4912
5826
|
}
|
|
4913
5827
|
static getInstance() {
|
|
4914
5828
|
if (!_ToastManager.instance) {
|
|
@@ -4926,6 +5840,8 @@ var _ToastManager = class _ToastManager {
|
|
|
4926
5840
|
list = [];
|
|
4927
5841
|
this.activeToasts.set(position, list);
|
|
4928
5842
|
}
|
|
5843
|
+
const rawMax = toast.options.maxToasts;
|
|
5844
|
+
const maxToasts = typeof rawMax === "number" && Number.isFinite(rawMax) && rawMax > 0 ? Math.min(50, Math.max(1, Math.floor(rawMax))) : 5;
|
|
4929
5845
|
if (toast.options.replace && list.length > 0) {
|
|
4930
5846
|
const existing = [...list];
|
|
4931
5847
|
const token = (this.replaceTokens.get(position) || 0) + 1;
|
|
@@ -4935,14 +5851,17 @@ var _ToastManager = class _ToastManager {
|
|
|
4935
5851
|
Promise.all(promises).then(() => {
|
|
4936
5852
|
this.pendingReplacements.delete(position);
|
|
4937
5853
|
if (this.replaceTokens.get(position) !== token) {
|
|
5854
|
+
toast.destroyImmediate("replace");
|
|
4938
5855
|
return;
|
|
4939
5856
|
}
|
|
4940
|
-
this.mountToast(toast, position,
|
|
5857
|
+
this.mountToast(toast, position, maxToasts);
|
|
4941
5858
|
});
|
|
4942
5859
|
return;
|
|
4943
5860
|
}
|
|
4944
|
-
|
|
4945
|
-
|
|
5861
|
+
if (this.pendingReplacements.has(position)) {
|
|
5862
|
+
this.replaceTokens.set(position, (this.replaceTokens.get(position) || 0) + 1);
|
|
5863
|
+
this.pendingReplacements.delete(position);
|
|
5864
|
+
}
|
|
4946
5865
|
if (list.length >= maxToasts) {
|
|
4947
5866
|
const countToRemove = list.length - maxToasts + 1;
|
|
4948
5867
|
const oldestItems = list.splice(0, countToRemove);
|
|
@@ -4953,10 +5872,12 @@ var _ToastManager = class _ToastManager {
|
|
|
4953
5872
|
this.mountToast(toast, position, maxToasts);
|
|
4954
5873
|
}
|
|
4955
5874
|
/**
|
|
4956
|
-
* Insère l'élément toast dans le
|
|
5875
|
+
* Insère l'élément toast dans le conteneur Top Layer, annonce le message et démarre le minuteur.
|
|
4957
5876
|
*/
|
|
4958
5877
|
mountToast(toast, position, maxToasts = 5) {
|
|
4959
|
-
|
|
5878
|
+
if (toast.isClosed) return;
|
|
5879
|
+
const useTopLayer = toast.options.useTopLayer ?? true;
|
|
5880
|
+
const container = this.getOrCreateContainer(position, toast, useTopLayer);
|
|
4960
5881
|
let list = this.activeToasts.get(position);
|
|
4961
5882
|
if (!list) {
|
|
4962
5883
|
list = [];
|
|
@@ -4972,8 +5893,19 @@ var _ToastManager = class _ToastManager {
|
|
|
4972
5893
|
}
|
|
4973
5894
|
}
|
|
4974
5895
|
}
|
|
5896
|
+
if (useTopLayer && typeof container.showPopover === "function" && container.getAttribute("popover") === "manual") {
|
|
5897
|
+
try {
|
|
5898
|
+
const popoverEl = container;
|
|
5899
|
+
if (!this.isPopoverOpen(container)) {
|
|
5900
|
+
popoverEl.showPopover();
|
|
5901
|
+
}
|
|
5902
|
+
} catch {
|
|
5903
|
+
container.removeAttribute("popover");
|
|
5904
|
+
}
|
|
5905
|
+
}
|
|
4975
5906
|
container.appendChild(toast.element);
|
|
4976
5907
|
list.push(toast);
|
|
5908
|
+
this.announce(toast);
|
|
4977
5909
|
if (toast.options.onOpen) {
|
|
4978
5910
|
try {
|
|
4979
5911
|
toast.options.onOpen(toast);
|
|
@@ -4983,6 +5915,142 @@ var _ToastManager = class _ToastManager {
|
|
|
4983
5915
|
}
|
|
4984
5916
|
toast.startTimer();
|
|
4985
5917
|
}
|
|
5918
|
+
/**
|
|
5919
|
+
* Annonce la notification sur un canal unique pour éviter les doubles lectures AT.
|
|
5920
|
+
*/
|
|
5921
|
+
announce(toast) {
|
|
5922
|
+
const parts = [toast.options.title, toast.options.message].filter((val) => typeof val === "string" && val.trim().length > 0).map((val) => val.trim());
|
|
5923
|
+
if (parts.length === 0) return;
|
|
5924
|
+
const rawText = parts.join(". ");
|
|
5925
|
+
const text = rawText.length > 512 ? `${rawText.slice(0, 509)}...` : rawText;
|
|
5926
|
+
const isAlert = toast.options.role === "alert";
|
|
5927
|
+
const docWithAriaNotify = document;
|
|
5928
|
+
if (typeof docWithAriaNotify.ariaNotify === "function") {
|
|
5929
|
+
try {
|
|
5930
|
+
docWithAriaNotify.ariaNotify(text, { priority: isAlert ? "high" : "normal" });
|
|
5931
|
+
return;
|
|
5932
|
+
} catch {
|
|
5933
|
+
}
|
|
5934
|
+
}
|
|
5935
|
+
const wasCreated = !this.announcerEl || !this.announcerEl.isConnected;
|
|
5936
|
+
this.ensureAnnouncer();
|
|
5937
|
+
const region = isAlert ? this.assertiveRegion : this.politeRegion;
|
|
5938
|
+
if (!region) return;
|
|
5939
|
+
if (isAlert) {
|
|
5940
|
+
if (this.assertiveAnnounceTimerId !== null) {
|
|
5941
|
+
window.clearTimeout(this.assertiveAnnounceTimerId);
|
|
5942
|
+
this.assertiveAnnounceTimerId = null;
|
|
5943
|
+
}
|
|
5944
|
+
if (this.assertiveClearTimerId !== null) {
|
|
5945
|
+
window.clearTimeout(this.assertiveClearTimerId);
|
|
5946
|
+
this.assertiveClearTimerId = null;
|
|
5947
|
+
}
|
|
5948
|
+
} else {
|
|
5949
|
+
if (this.politeAnnounceTimerId !== null) {
|
|
5950
|
+
window.clearTimeout(this.politeAnnounceTimerId);
|
|
5951
|
+
this.politeAnnounceTimerId = null;
|
|
5952
|
+
}
|
|
5953
|
+
if (this.politeClearTimerId !== null) {
|
|
5954
|
+
window.clearTimeout(this.politeClearTimerId);
|
|
5955
|
+
this.politeClearTimerId = null;
|
|
5956
|
+
}
|
|
5957
|
+
}
|
|
5958
|
+
region.textContent = "";
|
|
5959
|
+
const lastText = isAlert ? this.lastAssertiveText : this.lastPoliteText;
|
|
5960
|
+
let finalMessage = text;
|
|
5961
|
+
if (text === lastText) {
|
|
5962
|
+
this.announcerToggle = !this.announcerToggle;
|
|
5963
|
+
finalMessage = this.announcerToggle ? `${text}\xA0` : text;
|
|
5964
|
+
} else {
|
|
5965
|
+
this.announcerToggle = false;
|
|
5966
|
+
}
|
|
5967
|
+
if (isAlert) {
|
|
5968
|
+
this.lastAssertiveText = text;
|
|
5969
|
+
} else {
|
|
5970
|
+
this.lastPoliteText = text;
|
|
5971
|
+
}
|
|
5972
|
+
const delay = wasCreated ? 120 : 50;
|
|
5973
|
+
const timerId = window.setTimeout(() => {
|
|
5974
|
+
const idx = this.announceTimers.indexOf(timerId);
|
|
5975
|
+
if (idx !== -1) this.announceTimers.splice(idx, 1);
|
|
5976
|
+
if (isAlert) {
|
|
5977
|
+
this.assertiveAnnounceTimerId = null;
|
|
5978
|
+
} else {
|
|
5979
|
+
this.politeAnnounceTimerId = null;
|
|
5980
|
+
}
|
|
5981
|
+
if (region.isConnected) {
|
|
5982
|
+
region.textContent = finalMessage;
|
|
5983
|
+
const clearId = window.setTimeout(() => {
|
|
5984
|
+
const cIdx = this.announceTimers.indexOf(clearId);
|
|
5985
|
+
if (cIdx !== -1) this.announceTimers.splice(cIdx, 1);
|
|
5986
|
+
if (region.isConnected && region.textContent === finalMessage) {
|
|
5987
|
+
region.textContent = "";
|
|
5988
|
+
}
|
|
5989
|
+
}, 4e3);
|
|
5990
|
+
this.announceTimers.push(clearId);
|
|
5991
|
+
if (isAlert) {
|
|
5992
|
+
this.assertiveClearTimerId = clearId;
|
|
5993
|
+
} else {
|
|
5994
|
+
this.politeClearTimerId = clearId;
|
|
5995
|
+
}
|
|
5996
|
+
}
|
|
5997
|
+
}, delay);
|
|
5998
|
+
this.announceTimers.push(timerId);
|
|
5999
|
+
if (isAlert) {
|
|
6000
|
+
this.assertiveAnnounceTimerId = timerId;
|
|
6001
|
+
} else {
|
|
6002
|
+
this.politeAnnounceTimerId = timerId;
|
|
6003
|
+
}
|
|
6004
|
+
}
|
|
6005
|
+
/**
|
|
6006
|
+
* Crée ou reconnecte le conteneur persistant des annonces ARIA hors du popover.
|
|
6007
|
+
*/
|
|
6008
|
+
ensureAnnouncer() {
|
|
6009
|
+
if (this.announcerEl && document.body.contains(this.announcerEl)) {
|
|
6010
|
+
return;
|
|
6011
|
+
}
|
|
6012
|
+
const wrapper = document.createElement("div");
|
|
6013
|
+
wrapper.className = "wulf-toast-announcer";
|
|
6014
|
+
wrapper.setAttribute("data-wulf-toast-announcer", "true");
|
|
6015
|
+
const polite = document.createElement("div");
|
|
6016
|
+
polite.setAttribute("role", "status");
|
|
6017
|
+
polite.setAttribute("aria-live", "polite");
|
|
6018
|
+
polite.setAttribute("aria-atomic", "true");
|
|
6019
|
+
const assertive = document.createElement("div");
|
|
6020
|
+
assertive.setAttribute("role", "alert");
|
|
6021
|
+
assertive.setAttribute("aria-live", "assertive");
|
|
6022
|
+
assertive.setAttribute("aria-atomic", "true");
|
|
6023
|
+
wrapper.appendChild(polite);
|
|
6024
|
+
wrapper.appendChild(assertive);
|
|
6025
|
+
document.body.appendChild(wrapper);
|
|
6026
|
+
this.announcerEl = wrapper;
|
|
6027
|
+
this.politeRegion = polite;
|
|
6028
|
+
this.assertiveRegion = assertive;
|
|
6029
|
+
}
|
|
6030
|
+
/**
|
|
6031
|
+
* Transfère le focus avant de retirer un toast focalisé pour éviter que le focus ne retombe sur <body>.
|
|
6032
|
+
*/
|
|
6033
|
+
handleFocusHandoff(toast, list) {
|
|
6034
|
+
if (!toast.element.contains(document.activeElement)) {
|
|
6035
|
+
return;
|
|
6036
|
+
}
|
|
6037
|
+
for (let i = list.length - 1; i >= 0; i--) {
|
|
6038
|
+
const sibling = list[i];
|
|
6039
|
+
if (sibling === toast || sibling.isClosed || !sibling.element.isConnected) continue;
|
|
6040
|
+
const target = sibling.element.querySelector(FOCUSABLE_IN_TOAST);
|
|
6041
|
+
if (target) {
|
|
6042
|
+
target.focus({ preventScroll: true });
|
|
6043
|
+
return;
|
|
6044
|
+
}
|
|
6045
|
+
}
|
|
6046
|
+
const prev = toast.getPreviousActiveElement();
|
|
6047
|
+
if (prev && prev.isConnected && typeof prev.focus === "function" && !prev.disabled && !prev.closest("[inert]") && prev.getAttribute("aria-hidden") !== "true") {
|
|
6048
|
+
try {
|
|
6049
|
+
prev.focus();
|
|
6050
|
+
} catch {
|
|
6051
|
+
}
|
|
6052
|
+
}
|
|
6053
|
+
}
|
|
4986
6054
|
/**
|
|
4987
6055
|
* Retire une notification de la pile et nettoie le conteneur s'il est vide.
|
|
4988
6056
|
*/
|
|
@@ -4994,16 +6062,32 @@ var _ToastManager = class _ToastManager {
|
|
|
4994
6062
|
if (index !== -1) {
|
|
4995
6063
|
list.splice(index, 1);
|
|
4996
6064
|
}
|
|
6065
|
+
this.handleFocusHandoff(toast, list);
|
|
6066
|
+
if (toast.element.parentNode) {
|
|
6067
|
+
toast.element.parentNode.removeChild(toast.element);
|
|
6068
|
+
}
|
|
4997
6069
|
if (list.length === 0 && !this.pendingReplacements.has(position)) {
|
|
4998
6070
|
const container = this.containers.get(position);
|
|
4999
6071
|
if (container && (!container.firstChild || container.children.length === 0)) {
|
|
5000
|
-
|
|
5001
|
-
container.parentNode.removeChild(container);
|
|
5002
|
-
}
|
|
6072
|
+
this.disposeContainer(container);
|
|
5003
6073
|
this.containers.delete(position);
|
|
5004
6074
|
this.activeToasts.delete(position);
|
|
5005
6075
|
}
|
|
5006
6076
|
}
|
|
6077
|
+
} else if (toast.element.parentNode) {
|
|
6078
|
+
toast.element.parentNode.removeChild(toast.element);
|
|
6079
|
+
}
|
|
6080
|
+
}
|
|
6081
|
+
disposeContainer(container) {
|
|
6082
|
+
try {
|
|
6083
|
+
const popoverEl = container;
|
|
6084
|
+
if (typeof popoverEl.hidePopover === "function" && this.isPopoverOpen(container)) {
|
|
6085
|
+
popoverEl.hidePopover();
|
|
6086
|
+
}
|
|
6087
|
+
} catch {
|
|
6088
|
+
}
|
|
6089
|
+
if (container.parentNode) {
|
|
6090
|
+
container.parentNode.removeChild(container);
|
|
5007
6091
|
}
|
|
5008
6092
|
}
|
|
5009
6093
|
/**
|
|
@@ -5012,6 +6096,8 @@ var _ToastManager = class _ToastManager {
|
|
|
5012
6096
|
clearAll(position) {
|
|
5013
6097
|
const promises = [];
|
|
5014
6098
|
if (position) {
|
|
6099
|
+
this.replaceTokens.set(position, (this.replaceTokens.get(position) || 0) + 1);
|
|
6100
|
+
this.pendingReplacements.delete(position);
|
|
5015
6101
|
const list = this.activeToasts.get(position);
|
|
5016
6102
|
if (list && list.length > 0) {
|
|
5017
6103
|
const copy = [...list];
|
|
@@ -5021,14 +6107,24 @@ var _ToastManager = class _ToastManager {
|
|
|
5021
6107
|
} else {
|
|
5022
6108
|
const container = this.containers.get(position);
|
|
5023
6109
|
if (container && (!container.firstChild || container.children.length === 0)) {
|
|
5024
|
-
|
|
5025
|
-
container.parentNode.removeChild(container);
|
|
5026
|
-
}
|
|
6110
|
+
this.disposeContainer(container);
|
|
5027
6111
|
this.containers.delete(position);
|
|
5028
6112
|
this.activeToasts.delete(position);
|
|
5029
6113
|
}
|
|
5030
6114
|
}
|
|
5031
6115
|
} else {
|
|
6116
|
+
for (const pos of this.replaceTokens.keys()) {
|
|
6117
|
+
this.replaceTokens.set(pos, (this.replaceTokens.get(pos) || 0) + 1);
|
|
6118
|
+
}
|
|
6119
|
+
this.pendingReplacements.clear();
|
|
6120
|
+
for (const timerId of this.announceTimers) {
|
|
6121
|
+
window.clearTimeout(timerId);
|
|
6122
|
+
}
|
|
6123
|
+
this.announceTimers = [];
|
|
6124
|
+
this.politeAnnounceTimerId = null;
|
|
6125
|
+
this.assertiveAnnounceTimerId = null;
|
|
6126
|
+
this.politeClearTimerId = null;
|
|
6127
|
+
this.assertiveClearTimerId = null;
|
|
5032
6128
|
const allPositions = /* @__PURE__ */ new Set([
|
|
5033
6129
|
...Array.from(this.containers.keys()),
|
|
5034
6130
|
...Array.from(this.activeToasts.keys())
|
|
@@ -5041,9 +6137,7 @@ var _ToastManager = class _ToastManager {
|
|
|
5041
6137
|
if (!position) {
|
|
5042
6138
|
for (const [pos, container] of Array.from(this.containers.entries())) {
|
|
5043
6139
|
if (!container.firstChild || container.children.length === 0) {
|
|
5044
|
-
|
|
5045
|
-
container.parentNode.removeChild(container);
|
|
5046
|
-
}
|
|
6140
|
+
this.disposeContainer(container);
|
|
5047
6141
|
this.containers.delete(pos);
|
|
5048
6142
|
this.activeToasts.delete(pos);
|
|
5049
6143
|
}
|
|
@@ -5051,27 +6145,58 @@ var _ToastManager = class _ToastManager {
|
|
|
5051
6145
|
}
|
|
5052
6146
|
});
|
|
5053
6147
|
}
|
|
6148
|
+
/**
|
|
6149
|
+
* Détruit immédiatement tous les toasts, conteneurs, annonceurs ARIA et temporisations en cours.
|
|
6150
|
+
*/
|
|
6151
|
+
destroy() {
|
|
6152
|
+
for (const timerId of this.announceTimers) {
|
|
6153
|
+
window.clearTimeout(timerId);
|
|
6154
|
+
}
|
|
6155
|
+
this.announceTimers = [];
|
|
6156
|
+
for (const list of Array.from(this.activeToasts.values())) {
|
|
6157
|
+
for (const toast of [...list]) {
|
|
6158
|
+
toast.destroyImmediate("programmatic");
|
|
6159
|
+
}
|
|
6160
|
+
}
|
|
6161
|
+
for (const container of Array.from(this.containers.values())) {
|
|
6162
|
+
this.disposeContainer(container);
|
|
6163
|
+
}
|
|
6164
|
+
this.containers.clear();
|
|
6165
|
+
this.activeToasts.clear();
|
|
6166
|
+
this.replaceTokens.clear();
|
|
6167
|
+
this.pendingReplacements.clear();
|
|
6168
|
+
if (this.announcerEl) {
|
|
6169
|
+
this.announcerEl.remove();
|
|
6170
|
+
this.announcerEl = null;
|
|
6171
|
+
this.politeRegion = null;
|
|
6172
|
+
this.assertiveRegion = null;
|
|
6173
|
+
}
|
|
6174
|
+
_ToastManager.instance = null;
|
|
6175
|
+
}
|
|
5054
6176
|
/**
|
|
5055
6177
|
* Récupère ou crée le conteneur DOM pour une position d'affichage.
|
|
5056
6178
|
*/
|
|
5057
|
-
getOrCreateContainer(position) {
|
|
6179
|
+
getOrCreateContainer(position, toast, useTopLayer) {
|
|
5058
6180
|
let container = this.containers.get(position);
|
|
5059
6181
|
if (!container || !document.body.contains(container)) {
|
|
5060
6182
|
container = document.createElement("div");
|
|
5061
6183
|
container.className = `wulf-toast-container wulf-toast-${position}`;
|
|
5062
|
-
container.setAttribute("
|
|
5063
|
-
container.setAttribute("aria-
|
|
6184
|
+
container.setAttribute("role", "region");
|
|
6185
|
+
container.setAttribute("aria-label", toastI18n.t("notificationsRegion", toast.options.i18n));
|
|
6186
|
+
if (useTopLayer && typeof container.showPopover === "function") {
|
|
6187
|
+
container.setAttribute("popover", "manual");
|
|
6188
|
+
}
|
|
5064
6189
|
document.body.appendChild(container);
|
|
5065
6190
|
this.containers.set(position, container);
|
|
5066
6191
|
}
|
|
5067
6192
|
return container;
|
|
5068
6193
|
}
|
|
5069
6194
|
};
|
|
5070
|
-
_ToastManager.instance = null;
|
|
5071
|
-
var ToastManager = _ToastManager;
|
|
5072
6195
|
|
|
5073
6196
|
// src/toast/Toast.ts
|
|
5074
6197
|
var Toast = class extends LocalizedComponent {
|
|
6198
|
+
static _i18n = toastI18n;
|
|
6199
|
+
static i18n = toastI18n;
|
|
5075
6200
|
audit() {
|
|
5076
6201
|
return [];
|
|
5077
6202
|
}
|
|
@@ -5098,17 +6223,19 @@ var Toast = class extends LocalizedComponent {
|
|
|
5098
6223
|
static clearAll(position) {
|
|
5099
6224
|
return ToastManager.getInstance().clearAll(position);
|
|
5100
6225
|
}
|
|
6226
|
+
/**
|
|
6227
|
+
* Détruit le gestionnaire de notifications (conteneurs, annonceurs ARIA et timers).
|
|
6228
|
+
*/
|
|
6229
|
+
static destroy() {
|
|
6230
|
+
ToastManager.getInstance().destroy();
|
|
6231
|
+
}
|
|
5101
6232
|
};
|
|
5102
|
-
Toast._i18n = toastI18n;
|
|
5103
|
-
Toast.i18n = toastI18n;
|
|
5104
6233
|
|
|
5105
6234
|
// src/toast/index.ts
|
|
5106
6235
|
var toast_default = Toast;
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
win.Wulf = wulfNamespace;
|
|
5111
|
-
wulfNamespace.Toast = Object.assign(Toast, {
|
|
6236
|
+
var wulfNamespace4 = getSafeWulfNamespace();
|
|
6237
|
+
if (wulfNamespace4) {
|
|
6238
|
+
wulfNamespace4.Toast = Object.assign(Toast, {
|
|
5112
6239
|
Toast,
|
|
5113
6240
|
i18n: toastI18n
|
|
5114
6241
|
});
|
|
@@ -5125,7 +6252,7 @@ __export(focus_trap_exports, {
|
|
|
5125
6252
|
var FOCUSABLE_SELECTOR = [
|
|
5126
6253
|
"a[href]",
|
|
5127
6254
|
"area[href]",
|
|
5128
|
-
|
|
6255
|
+
'input:not([disabled]):not([type="hidden"])',
|
|
5129
6256
|
"select:not([disabled])",
|
|
5130
6257
|
"textarea:not([disabled])",
|
|
5131
6258
|
"button:not([disabled])",
|
|
@@ -5138,12 +6265,6 @@ var FOCUSABLE_SELECTOR = [
|
|
|
5138
6265
|
'[contenteditable]:not([contenteditable="false"])',
|
|
5139
6266
|
'[tabindex]:not([tabindex="-1"])'
|
|
5140
6267
|
].join(",");
|
|
5141
|
-
function safeCssEscape(value) {
|
|
5142
|
-
if (typeof CSS !== "undefined" && typeof CSS.escape === "function") {
|
|
5143
|
-
return CSS.escape(value);
|
|
5144
|
-
}
|
|
5145
|
-
return String(value).replace(/["\\]/g, "\\$&");
|
|
5146
|
-
}
|
|
5147
6268
|
function safeQuerySelector(root, selector) {
|
|
5148
6269
|
if (!selector || typeof selector !== "string") return null;
|
|
5149
6270
|
try {
|
|
@@ -5154,27 +6275,34 @@ function safeQuerySelector(root, selector) {
|
|
|
5154
6275
|
}
|
|
5155
6276
|
var trapStack = [];
|
|
5156
6277
|
var FocusTrap = class extends AuditableComponent {
|
|
6278
|
+
element;
|
|
6279
|
+
options;
|
|
6280
|
+
active = false;
|
|
6281
|
+
paused = false;
|
|
6282
|
+
previousActiveElement = null;
|
|
6283
|
+
inertSiblings = [];
|
|
6284
|
+
addedContainerTabIndex = false;
|
|
6285
|
+
lastOutsidePointerDownTime = 0;
|
|
6286
|
+
abortController;
|
|
6287
|
+
// Handlers liés
|
|
6288
|
+
handleKeyDownBound;
|
|
6289
|
+
handleClickOutsideBound;
|
|
6290
|
+
handleFocusInBound;
|
|
5157
6291
|
constructor(target, options = {}) {
|
|
5158
6292
|
super();
|
|
5159
|
-
this.active = false;
|
|
5160
|
-
this.paused = false;
|
|
5161
|
-
this.previousActiveElement = null;
|
|
5162
|
-
this.inertSiblings = [];
|
|
5163
|
-
// Sentinelles anti-fuite de focus
|
|
5164
|
-
this.startSentinel = null;
|
|
5165
|
-
this.endSentinel = null;
|
|
5166
6293
|
const el = typeof target === "string" ? safeQuerySelector(document, target) : target;
|
|
5167
6294
|
if (!el || !(el instanceof HTMLElement)) {
|
|
5168
6295
|
throw new Error(`[Wulf.FocusTrap] Conteneur introuvable ou invalide : "${target}"`);
|
|
5169
6296
|
}
|
|
5170
6297
|
this.element = el;
|
|
6298
|
+
const allowOutsideClick = options.allowOutsideClick ?? false;
|
|
5171
6299
|
this.options = {
|
|
5172
6300
|
initialFocus: options.initialFocus !== void 0 ? options.initialFocus : "[data-autofocus], [autofocus]",
|
|
5173
6301
|
returnFocus: options.returnFocus ?? true,
|
|
5174
6302
|
fallbackReturnFocus: options.fallbackReturnFocus ?? "",
|
|
5175
6303
|
escapeDeactivates: options.escapeDeactivates ?? true,
|
|
5176
|
-
allowOutsideClick
|
|
5177
|
-
setInert: options.setInert ??
|
|
6304
|
+
allowOutsideClick,
|
|
6305
|
+
setInert: options.setInert ?? !allowOutsideClick,
|
|
5178
6306
|
onActivate: options.onActivate ?? (() => {
|
|
5179
6307
|
}),
|
|
5180
6308
|
onDeactivate: options.onDeactivate ?? (() => {
|
|
@@ -5186,25 +6314,57 @@ var FocusTrap = class extends AuditableComponent {
|
|
|
5186
6314
|
this.handleFocusInBound = this.handleFocusIn.bind(this);
|
|
5187
6315
|
this.runAuditWarning(this.options.audit);
|
|
5188
6316
|
}
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
6317
|
+
isNativeDialogElement() {
|
|
6318
|
+
return this.element.tagName.toLowerCase() === "dialog";
|
|
6319
|
+
}
|
|
6320
|
+
isNativeModalDialog() {
|
|
6321
|
+
if (!this.isNativeDialogElement()) return false;
|
|
6322
|
+
try {
|
|
6323
|
+
return this.element.matches(":modal");
|
|
6324
|
+
} catch {
|
|
6325
|
+
return false;
|
|
6326
|
+
}
|
|
6327
|
+
}
|
|
6328
|
+
isElementFocusableBase(el) {
|
|
5193
6329
|
if (!el || !el.isConnected) return false;
|
|
6330
|
+
if (el.tabIndex < 0) return false;
|
|
5194
6331
|
if (el.disabled) return false;
|
|
5195
|
-
|
|
6332
|
+
try {
|
|
6333
|
+
if (el.matches(":disabled")) return false;
|
|
6334
|
+
} catch {
|
|
6335
|
+
if (el.closest("fieldset[disabled]")) return false;
|
|
6336
|
+
}
|
|
5196
6337
|
if (el.hasAttribute("inert") || el.closest("[inert]")) return false;
|
|
5197
6338
|
if (el.hidden || el.closest("[hidden]")) return false;
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
6339
|
+
const elWithCheck = el;
|
|
6340
|
+
if (typeof elWithCheck.checkVisibility === "function") {
|
|
6341
|
+
if (!elWithCheck.checkVisibility({
|
|
6342
|
+
checkOpacity: false,
|
|
6343
|
+
checkVisibilityCSS: true,
|
|
6344
|
+
visibilityProperty: true
|
|
6345
|
+
})) {
|
|
6346
|
+
return false;
|
|
6347
|
+
}
|
|
6348
|
+
} else {
|
|
6349
|
+
if (el.style.display === "none" || el.style.visibility === "hidden") return false;
|
|
6350
|
+
const style = window.getComputedStyle(el);
|
|
6351
|
+
if (style.display === "none" || style.visibility === "hidden") return false;
|
|
6352
|
+
if (el.offsetWidth === 0 && el.offsetHeight === 0 && style.position !== "fixed") {
|
|
6353
|
+
return false;
|
|
6354
|
+
}
|
|
5203
6355
|
}
|
|
6356
|
+
return true;
|
|
6357
|
+
}
|
|
6358
|
+
/**
|
|
6359
|
+
* Vérifie si un élément est réellement focusable, visible et actif dans le DOM.
|
|
6360
|
+
*/
|
|
6361
|
+
isFocusable(el) {
|
|
6362
|
+
if (!this.isElementFocusableBase(el)) return false;
|
|
5204
6363
|
if (el instanceof HTMLInputElement && el.type === "radio" && el.name) {
|
|
5205
6364
|
const group = Array.from(
|
|
5206
6365
|
this.element.querySelectorAll(`input[type="radio"][name="${safeCssEscape(el.name)}"]`)
|
|
5207
|
-
);
|
|
6366
|
+
).filter((r) => r.form === el.form && this.isElementFocusableBase(r));
|
|
6367
|
+
if (group.length === 0) return false;
|
|
5208
6368
|
const checked = group.find((r) => r.checked);
|
|
5209
6369
|
if (checked) {
|
|
5210
6370
|
return el === checked;
|
|
@@ -5232,17 +6392,21 @@ var FocusTrap = class extends AuditableComponent {
|
|
|
5232
6392
|
this.active = true;
|
|
5233
6393
|
this.paused = false;
|
|
5234
6394
|
trapStack.push(this);
|
|
5235
|
-
|
|
5236
|
-
this.
|
|
5237
|
-
if (this.options.setInert) {
|
|
6395
|
+
const deepActive = getDeepActiveElement(document);
|
|
6396
|
+
this.previousActiveElement = deepActive instanceof HTMLElement ? deepActive : document.activeElement;
|
|
6397
|
+
if (this.options.setInert && !this.isNativeModalDialog()) {
|
|
5238
6398
|
this.applyInert();
|
|
5239
6399
|
}
|
|
5240
|
-
|
|
5241
|
-
|
|
6400
|
+
this.abortController?.abort();
|
|
6401
|
+
this.abortController = new AbortController();
|
|
6402
|
+
const { signal } = this.abortController;
|
|
6403
|
+
document.addEventListener("keydown", this.handleKeyDownBound, { capture: true, signal });
|
|
6404
|
+
document.addEventListener("focusin", this.handleFocusInBound, { capture: true, signal });
|
|
6405
|
+
document.addEventListener("pointerdown", this.handleClickOutsideBound, { capture: true, signal });
|
|
5242
6406
|
if (!this.options.allowOutsideClick) {
|
|
5243
|
-
document.addEventListener("
|
|
5244
|
-
document.addEventListener("
|
|
5245
|
-
document.addEventListener("
|
|
6407
|
+
document.addEventListener("mousedown", this.handleClickOutsideBound, { capture: true, signal });
|
|
6408
|
+
document.addEventListener("touchstart", this.handleClickOutsideBound, { capture: true, signal });
|
|
6409
|
+
document.addEventListener("click", this.handleClickOutsideBound, { capture: true, signal });
|
|
5246
6410
|
}
|
|
5247
6411
|
this.applyInitialFocus();
|
|
5248
6412
|
this.runAuditWarning(this.options.audit);
|
|
@@ -5260,34 +6424,42 @@ var FocusTrap = class extends AuditableComponent {
|
|
|
5260
6424
|
if (index !== -1) {
|
|
5261
6425
|
trapStack.splice(index, 1);
|
|
5262
6426
|
}
|
|
6427
|
+
this.abortController?.abort();
|
|
6428
|
+
this.abortController = void 0;
|
|
6429
|
+
this.removeInert();
|
|
6430
|
+
if (this.addedContainerTabIndex) {
|
|
6431
|
+
this.element.removeAttribute("tabindex");
|
|
6432
|
+
this.addedContainerTabIndex = false;
|
|
6433
|
+
}
|
|
5263
6434
|
const nextTop = trapStack[trapStack.length - 1];
|
|
5264
6435
|
if (nextTop) {
|
|
5265
6436
|
nextTop.unpause();
|
|
5266
6437
|
}
|
|
5267
|
-
document.removeEventListener("keydown", this.handleKeyDownBound, true);
|
|
5268
|
-
document.removeEventListener("focusin", this.handleFocusInBound, true);
|
|
5269
|
-
document.removeEventListener("pointerdown", this.handleClickOutsideBound, true);
|
|
5270
|
-
document.removeEventListener("mousedown", this.handleClickOutsideBound, true);
|
|
5271
|
-
document.removeEventListener("touchstart", this.handleClickOutsideBound, true);
|
|
5272
|
-
this.removeSentinels();
|
|
5273
|
-
this.removeInert();
|
|
5274
6438
|
if (this.options.returnFocus) {
|
|
5275
6439
|
this.restoreFocus();
|
|
5276
6440
|
}
|
|
6441
|
+
this.previousActiveElement = null;
|
|
5277
6442
|
this.options.onDeactivate();
|
|
5278
6443
|
return this;
|
|
5279
6444
|
}
|
|
5280
6445
|
/**
|
|
5281
6446
|
* Met en pause le trap (utilisé quand un trap fils s'ouvre au-dessus).
|
|
6447
|
+
* Retire temporairement `inert` pour ne pas bloquer une modale sœur ou enfant.
|
|
5282
6448
|
*/
|
|
5283
6449
|
pause() {
|
|
5284
6450
|
this.paused = true;
|
|
6451
|
+
this.removeInert();
|
|
5285
6452
|
}
|
|
5286
6453
|
/**
|
|
5287
|
-
* Sort de pause.
|
|
6454
|
+
* Sort de pause et réapplique l'isolation `inert` si active et si ce trap est bien au sommet de la pile.
|
|
5288
6455
|
*/
|
|
5289
6456
|
unpause() {
|
|
6457
|
+
if (!this.active) return;
|
|
6458
|
+
if (trapStack[trapStack.length - 1] !== this) return;
|
|
5290
6459
|
this.paused = false;
|
|
6460
|
+
if (this.options.setInert && !this.isNativeModalDialog()) {
|
|
6461
|
+
this.applyInert();
|
|
6462
|
+
}
|
|
5291
6463
|
}
|
|
5292
6464
|
/**
|
|
5293
6465
|
* Indique si le trap est actuellement actif et non en pause.
|
|
@@ -5302,17 +6474,35 @@ var FocusTrap = class extends AuditableComponent {
|
|
|
5302
6474
|
audit() {
|
|
5303
6475
|
const warnings = [];
|
|
5304
6476
|
const role = this.element.getAttribute("role");
|
|
5305
|
-
const isNativeDialog = this.
|
|
6477
|
+
const isNativeDialog = this.isNativeDialogElement();
|
|
5306
6478
|
const validRoles = ["dialog", "alertdialog", "menu", "listbox", "tree", "grid"];
|
|
5307
|
-
if (
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
6479
|
+
if (isNativeDialog) {
|
|
6480
|
+
if (role === "dialog") {
|
|
6481
|
+
warnings.push(
|
|
6482
|
+
'Attribut redondant : role="dialog" est d\xE9j\xE0 implicite sur une balise native <dialog>.'
|
|
6483
|
+
);
|
|
6484
|
+
}
|
|
6485
|
+
if (this.element.hasAttribute("aria-modal")) {
|
|
6486
|
+
warnings.push(
|
|
6487
|
+
'Attribut redondant : <dialog> ouvert via showModal() g\xE8re nativement la modalit\xE9 sans n\xE9cessiter aria-modal="true".'
|
|
6488
|
+
);
|
|
6489
|
+
}
|
|
6490
|
+
if (this.element.hasAttribute("open") && !this.isNativeModalDialog()) {
|
|
6491
|
+
warnings.push(
|
|
6492
|
+
"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."
|
|
6493
|
+
);
|
|
6494
|
+
}
|
|
6495
|
+
} else {
|
|
6496
|
+
if (!role || !validRoles.includes(role)) {
|
|
6497
|
+
warnings.push(
|
|
6498
|
+
'R\xF4le s\xE9mantique manquant ou inadapt\xE9 : d\xE9finissez role="dialog" (ou "alertdialog", "menu", "listbox") sur le conteneur.'
|
|
6499
|
+
);
|
|
6500
|
+
}
|
|
6501
|
+
if ((role === "dialog" || role === "alertdialog") && this.element.getAttribute("aria-modal") !== "true") {
|
|
6502
|
+
warnings.push(
|
|
6503
|
+
'Isolation modale manquante : d\xE9finissez aria-modal="true" sur le conteneur de dialogue (WCAG 4.1.2).'
|
|
6504
|
+
);
|
|
6505
|
+
}
|
|
5316
6506
|
}
|
|
5317
6507
|
const ariaLabel = this.element.getAttribute("aria-label")?.trim();
|
|
5318
6508
|
const hasValidLabelledby = this.checkAriaIdReferences(this.element, "aria-labelledby", warnings);
|
|
@@ -5348,15 +6538,15 @@ var FocusTrap = class extends AuditableComponent {
|
|
|
5348
6538
|
}
|
|
5349
6539
|
return false;
|
|
5350
6540
|
}
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
6541
|
+
isInsideToastContainer(target) {
|
|
6542
|
+
if (!target || !(target instanceof Element)) return false;
|
|
6543
|
+
return Boolean(target.closest(".wulf-toast-container"));
|
|
6544
|
+
}
|
|
6545
|
+
ensureContainerTabIndex() {
|
|
6546
|
+
if (this.element.getAttribute("tabindex") === null) {
|
|
6547
|
+
this.element.setAttribute("tabindex", "-1");
|
|
6548
|
+
this.addedContainerTabIndex = true;
|
|
6549
|
+
}
|
|
5360
6550
|
}
|
|
5361
6551
|
handleKeyDown(e) {
|
|
5362
6552
|
if (!this.isActive()) return;
|
|
@@ -5365,8 +6555,11 @@ var FocusTrap = class extends AuditableComponent {
|
|
|
5365
6555
|
return;
|
|
5366
6556
|
}
|
|
5367
6557
|
if (e.key === "Escape" && this.options.escapeDeactivates) {
|
|
5368
|
-
e
|
|
5369
|
-
|
|
6558
|
+
if (isImeComposing(e)) return;
|
|
6559
|
+
if (!this.isNativeModalDialog()) {
|
|
6560
|
+
e.preventDefault();
|
|
6561
|
+
e.stopPropagation();
|
|
6562
|
+
}
|
|
5370
6563
|
this.deactivate();
|
|
5371
6564
|
return;
|
|
5372
6565
|
}
|
|
@@ -5374,19 +6567,19 @@ var FocusTrap = class extends AuditableComponent {
|
|
|
5374
6567
|
const focusables = this.getFocusableElements();
|
|
5375
6568
|
if (focusables.length === 0) {
|
|
5376
6569
|
e.preventDefault();
|
|
5377
|
-
|
|
5378
|
-
this.element.setAttribute("tabindex", "-1");
|
|
5379
|
-
}
|
|
6570
|
+
this.ensureContainerTabIndex();
|
|
5380
6571
|
this.element.focus();
|
|
5381
6572
|
return;
|
|
5382
6573
|
}
|
|
5383
6574
|
const first = focusables[0];
|
|
5384
6575
|
const last = focusables[focusables.length - 1];
|
|
5385
|
-
const
|
|
5386
|
-
|
|
6576
|
+
const deepCurrent = getDeepActiveElement(document);
|
|
6577
|
+
const current = deepCurrent instanceof HTMLElement ? deepCurrent : document.activeElement;
|
|
6578
|
+
const isInside = current ? this.element.contains(current) || this.isEventInside(e, current) : false;
|
|
6579
|
+
if (!e.shiftKey && (current === last || !isInside)) {
|
|
5387
6580
|
e.preventDefault();
|
|
5388
6581
|
first.focus();
|
|
5389
|
-
} else if (e.shiftKey && (current === first ||
|
|
6582
|
+
} else if (e.shiftKey && (current === first || current === this.element || !isInside)) {
|
|
5390
6583
|
e.preventDefault();
|
|
5391
6584
|
last.focus();
|
|
5392
6585
|
}
|
|
@@ -5399,22 +6592,10 @@ var FocusTrap = class extends AuditableComponent {
|
|
|
5399
6592
|
}
|
|
5400
6593
|
const target = e.target;
|
|
5401
6594
|
if (!target) return;
|
|
5402
|
-
if (
|
|
5403
|
-
const focusables = this.getFocusableElements();
|
|
5404
|
-
if (focusables.length > 0) {
|
|
5405
|
-
focusables[focusables.length - 1].focus();
|
|
5406
|
-
} else {
|
|
5407
|
-
this.element.focus();
|
|
5408
|
-
}
|
|
6595
|
+
if (this.isInsideToastContainer(target)) {
|
|
5409
6596
|
return;
|
|
5410
6597
|
}
|
|
5411
|
-
if (
|
|
5412
|
-
const focusables = this.getFocusableElements();
|
|
5413
|
-
if (focusables.length > 0) {
|
|
5414
|
-
focusables[0].focus();
|
|
5415
|
-
} else {
|
|
5416
|
-
this.element.focus();
|
|
5417
|
-
}
|
|
6598
|
+
if (this.options.allowOutsideClick && performance.now() - this.lastOutsidePointerDownTime < 150) {
|
|
5418
6599
|
return;
|
|
5419
6600
|
}
|
|
5420
6601
|
if (!this.isEventInside(e, target)) {
|
|
@@ -5422,9 +6603,7 @@ var FocusTrap = class extends AuditableComponent {
|
|
|
5422
6603
|
if (focusables.length > 0) {
|
|
5423
6604
|
focusables[0].focus();
|
|
5424
6605
|
} else {
|
|
5425
|
-
|
|
5426
|
-
this.element.setAttribute("tabindex", "-1");
|
|
5427
|
-
}
|
|
6606
|
+
this.ensureContainerTabIndex();
|
|
5428
6607
|
this.element.focus();
|
|
5429
6608
|
}
|
|
5430
6609
|
}
|
|
@@ -5437,51 +6616,34 @@ var FocusTrap = class extends AuditableComponent {
|
|
|
5437
6616
|
}
|
|
5438
6617
|
const target = e.target;
|
|
5439
6618
|
if (target && !this.isEventInside(e, target)) {
|
|
6619
|
+
if (this.isInsideToastContainer(target)) {
|
|
6620
|
+
return;
|
|
6621
|
+
}
|
|
6622
|
+
if (this.options.allowOutsideClick) {
|
|
6623
|
+
this.lastOutsidePointerDownTime = performance.now();
|
|
6624
|
+
return;
|
|
6625
|
+
}
|
|
5440
6626
|
e.preventDefault();
|
|
5441
6627
|
e.stopPropagation();
|
|
5442
6628
|
}
|
|
5443
6629
|
}
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
this.startSentinel.setAttribute("aria-hidden", "true");
|
|
5449
|
-
this.startSentinel.className = "wulf-sentinel-start";
|
|
5450
|
-
this.applySentinelStyles(this.startSentinel);
|
|
5451
|
-
}
|
|
5452
|
-
if (!this.endSentinel) {
|
|
5453
|
-
this.endSentinel = document.createElement("span");
|
|
5454
|
-
this.endSentinel.setAttribute("tabindex", "0");
|
|
5455
|
-
this.endSentinel.setAttribute("aria-hidden", "true");
|
|
5456
|
-
this.endSentinel.className = "wulf-sentinel-end";
|
|
5457
|
-
this.applySentinelStyles(this.endSentinel);
|
|
5458
|
-
}
|
|
5459
|
-
if (this.element.parentNode) {
|
|
5460
|
-
this.element.parentNode.insertBefore(this.startSentinel, this.element);
|
|
5461
|
-
this.element.parentNode.insertBefore(this.endSentinel, this.element.nextSibling);
|
|
5462
|
-
}
|
|
5463
|
-
}
|
|
5464
|
-
removeSentinels() {
|
|
5465
|
-
this.startSentinel?.remove();
|
|
5466
|
-
this.endSentinel?.remove();
|
|
5467
|
-
this.startSentinel = null;
|
|
5468
|
-
this.endSentinel = null;
|
|
5469
|
-
}
|
|
6630
|
+
/**
|
|
6631
|
+
* Applique `inert` sur les éléments frères à chaque niveau hiérarchique jusqu'à <body>,
|
|
6632
|
+
* en préservant les conteneurs de notifications Toast en Top Layer.
|
|
6633
|
+
*/
|
|
5470
6634
|
applyInert() {
|
|
5471
|
-
this.
|
|
5472
|
-
let
|
|
5473
|
-
|
|
5474
|
-
while (
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
if (child instanceof HTMLElement && child !== currentChild && child !== this.startSentinel && child !== this.endSentinel && !child.hasAttribute("inert")) {
|
|
5481
|
-
child.setAttribute("inert", "");
|
|
5482
|
-
this.inertSiblings.push(child);
|
|
6635
|
+
this.removeInert();
|
|
6636
|
+
let current = this.element;
|
|
6637
|
+
const ignoredTags = /* @__PURE__ */ new Set(["SCRIPT", "STYLE", "TEMPLATE", "LINK", "META", "NOSCRIPT"]);
|
|
6638
|
+
while (current && current !== document.body && current.parentElement) {
|
|
6639
|
+
const parent = current.parentElement;
|
|
6640
|
+
for (const sibling of Array.from(parent.children)) {
|
|
6641
|
+
if (sibling instanceof HTMLElement && sibling !== current && !ignoredTags.has(sibling.tagName) && !sibling.hasAttribute("inert") && !sibling.matches(".wulf-toast-container, .wulf-toast-announcer")) {
|
|
6642
|
+
sibling.setAttribute("inert", "");
|
|
6643
|
+
this.inertSiblings.push(sibling);
|
|
5483
6644
|
}
|
|
5484
|
-
}
|
|
6645
|
+
}
|
|
6646
|
+
current = parent;
|
|
5485
6647
|
}
|
|
5486
6648
|
}
|
|
5487
6649
|
removeInert() {
|
|
@@ -5504,20 +6666,18 @@ var FocusTrap = class extends AuditableComponent {
|
|
|
5504
6666
|
if (focusables.length > 0) {
|
|
5505
6667
|
focusables[0].focus();
|
|
5506
6668
|
} else {
|
|
5507
|
-
|
|
5508
|
-
this.element.setAttribute("tabindex", "-1");
|
|
5509
|
-
}
|
|
6669
|
+
this.ensureContainerTabIndex();
|
|
5510
6670
|
this.element.focus();
|
|
5511
6671
|
}
|
|
5512
6672
|
}
|
|
5513
6673
|
restoreFocus() {
|
|
5514
|
-
if (this.previousActiveElement && this.previousActiveElement.isConnected) {
|
|
6674
|
+
if (this.previousActiveElement && this.previousActiveElement.isConnected && this.isElementFocusableBase(this.previousActiveElement)) {
|
|
5515
6675
|
this.previousActiveElement.focus();
|
|
5516
6676
|
return;
|
|
5517
6677
|
}
|
|
5518
6678
|
if (this.options.fallbackReturnFocus) {
|
|
5519
6679
|
const fallback = typeof this.options.fallbackReturnFocus === "string" ? safeQuerySelector(document, this.options.fallbackReturnFocus) : this.options.fallbackReturnFocus;
|
|
5520
|
-
if (fallback && fallback.isConnected) {
|
|
6680
|
+
if (fallback && fallback.isConnected && this.isElementFocusableBase(fallback)) {
|
|
5521
6681
|
fallback.focus();
|
|
5522
6682
|
}
|
|
5523
6683
|
}
|
|
@@ -5525,11 +6685,9 @@ var FocusTrap = class extends AuditableComponent {
|
|
|
5525
6685
|
};
|
|
5526
6686
|
|
|
5527
6687
|
// src/focus-trap/index.ts
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
win.Wulf = wulfNamespace;
|
|
5532
|
-
wulfNamespace.FocusTrap = Object.assign(FocusTrap, {
|
|
6688
|
+
var wulfNamespace5 = getSafeWulfNamespace();
|
|
6689
|
+
if (wulfNamespace5) {
|
|
6690
|
+
wulfNamespace5.FocusTrap = Object.assign(FocusTrap, {
|
|
5533
6691
|
FocusTrap
|
|
5534
6692
|
});
|
|
5535
6693
|
}
|
|
@@ -5569,6 +6727,9 @@ var ShortcutFormatter = class _ShortcutFormatter {
|
|
|
5569
6727
|
* Normalise un nom de touche unitaire pour les comparaisons.
|
|
5570
6728
|
*/
|
|
5571
6729
|
static normalizeKeyName(key) {
|
|
6730
|
+
if (key === " ") {
|
|
6731
|
+
return " ";
|
|
6732
|
+
}
|
|
5572
6733
|
const k = key.trim().toLowerCase();
|
|
5573
6734
|
switch (k) {
|
|
5574
6735
|
case "esc":
|
|
@@ -5578,6 +6739,8 @@ var ShortcutFormatter = class _ShortcutFormatter {
|
|
|
5578
6739
|
case "space":
|
|
5579
6740
|
case "spacebar":
|
|
5580
6741
|
return " ";
|
|
6742
|
+
case "plus":
|
|
6743
|
+
return "+";
|
|
5581
6744
|
case "del":
|
|
5582
6745
|
return "delete";
|
|
5583
6746
|
case "ins":
|
|
@@ -5602,30 +6765,41 @@ var ShortcutFormatter = class _ShortcutFormatter {
|
|
|
5602
6765
|
if (typeof combo !== "string") {
|
|
5603
6766
|
return [];
|
|
5604
6767
|
}
|
|
6768
|
+
if (combo === " ") {
|
|
6769
|
+
return [{ ctrl: false, alt: false, shift: false, meta: false, key: " " }];
|
|
6770
|
+
}
|
|
5605
6771
|
const trimmed = combo.slice(0, 512).trim();
|
|
5606
6772
|
if (!trimmed) {
|
|
5607
6773
|
return [];
|
|
5608
6774
|
}
|
|
5609
|
-
const
|
|
6775
|
+
const normalizedChordSpacing = trimmed.replace(
|
|
6776
|
+
/\b(ctrl|control|alt|option|opt|shift|maj|cmd|command|meta|win|super|mod|\$mod)\s*\+\s*/gi,
|
|
6777
|
+
"$1+"
|
|
6778
|
+
);
|
|
6779
|
+
const stepsRaw = normalizedChordSpacing.split(/\s+/).slice(0, 10);
|
|
5610
6780
|
const steps = [];
|
|
5611
6781
|
for (const rawStep of stepsRaw) {
|
|
5612
6782
|
const tokens = [];
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
tokens.
|
|
5621
|
-
|
|
6783
|
+
if (rawStep === "+") {
|
|
6784
|
+
tokens.push("+");
|
|
6785
|
+
} else {
|
|
6786
|
+
let currentToken = "";
|
|
6787
|
+
for (let i = 0; i < rawStep.length; i++) {
|
|
6788
|
+
const char = rawStep[i];
|
|
6789
|
+
if (char === "+") {
|
|
6790
|
+
if (currentToken === "" && tokens.length > 0) {
|
|
6791
|
+
tokens.push("+");
|
|
6792
|
+
} else if (currentToken !== "") {
|
|
6793
|
+
tokens.push(currentToken);
|
|
6794
|
+
currentToken = "";
|
|
6795
|
+
}
|
|
6796
|
+
} else {
|
|
6797
|
+
currentToken += char;
|
|
5622
6798
|
}
|
|
5623
|
-
} else {
|
|
5624
|
-
currentToken += char;
|
|
5625
6799
|
}
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
6800
|
+
if (currentToken !== "") {
|
|
6801
|
+
tokens.push(currentToken);
|
|
6802
|
+
}
|
|
5629
6803
|
}
|
|
5630
6804
|
let ctrl = false;
|
|
5631
6805
|
let alt = false;
|
|
@@ -5697,18 +6871,78 @@ var ShortcutFormatter = class _ShortcutFormatter {
|
|
|
5697
6871
|
/**
|
|
5698
6872
|
* Convertit un combo technique vers le format officiel WAI-ARIA `aria-keyshortcuts`.
|
|
5699
6873
|
* Standard W3C : les modificateurs sont 'Control', 'Alt', 'Shift', 'Meta' et le séparateur est '+'.
|
|
6874
|
+
* Attention : dans WAI-ARIA 1.2, l'espace délimite des raccourcis alternatifs et non une séquence temporelle.
|
|
6875
|
+
* 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.
|
|
5700
6876
|
*/
|
|
5701
6877
|
static toAriaKeyShortcuts(combo, isApple = _ShortcutFormatter.isApple()) {
|
|
5702
6878
|
const steps = _ShortcutFormatter.parseCombo(combo, isApple);
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
6879
|
+
if (steps.length !== 1) {
|
|
6880
|
+
return "";
|
|
6881
|
+
}
|
|
6882
|
+
const step = steps[0];
|
|
6883
|
+
const ariaKey = _ShortcutFormatter.formatAriaKey(step.key);
|
|
6884
|
+
if (!ariaKey) {
|
|
6885
|
+
return "";
|
|
6886
|
+
}
|
|
6887
|
+
const parts = [];
|
|
6888
|
+
if (step.ctrl) parts.push("Control");
|
|
6889
|
+
if (step.alt) parts.push("Alt");
|
|
6890
|
+
if (step.shift) parts.push("Shift");
|
|
6891
|
+
if (step.meta) parts.push("Meta");
|
|
6892
|
+
parts.push(ariaKey);
|
|
6893
|
+
return parts.join("+");
|
|
6894
|
+
}
|
|
6895
|
+
/**
|
|
6896
|
+
* Formate un nom de touche strictement conforme aux valeurs standard W3C UI Events / aria-keyshortcuts.
|
|
6897
|
+
*/
|
|
6898
|
+
static formatAriaKey(key) {
|
|
6899
|
+
if (!key) return "";
|
|
6900
|
+
switch (key.toLowerCase()) {
|
|
6901
|
+
case "escape":
|
|
6902
|
+
return "Escape";
|
|
6903
|
+
case "enter":
|
|
6904
|
+
return "Enter";
|
|
6905
|
+
case " ":
|
|
6906
|
+
return "Space";
|
|
6907
|
+
case "tab":
|
|
6908
|
+
return "Tab";
|
|
6909
|
+
case "backspace":
|
|
6910
|
+
return "Backspace";
|
|
6911
|
+
case "delete":
|
|
6912
|
+
return "Delete";
|
|
6913
|
+
case "insert":
|
|
6914
|
+
return "Insert";
|
|
6915
|
+
case "home":
|
|
6916
|
+
return "Home";
|
|
6917
|
+
case "end":
|
|
6918
|
+
return "End";
|
|
6919
|
+
case "pageup":
|
|
6920
|
+
return "PageUp";
|
|
6921
|
+
case "pagedown":
|
|
6922
|
+
return "PageDown";
|
|
6923
|
+
case "arrowup":
|
|
6924
|
+
return "ArrowUp";
|
|
6925
|
+
case "arrowdown":
|
|
6926
|
+
return "ArrowDown";
|
|
6927
|
+
case "arrowleft":
|
|
6928
|
+
return "ArrowLeft";
|
|
6929
|
+
case "arrowright":
|
|
6930
|
+
return "ArrowRight";
|
|
6931
|
+
case "printscreen":
|
|
6932
|
+
return "PrintScreen";
|
|
6933
|
+
case "scrolllock":
|
|
6934
|
+
return "ScrollLock";
|
|
6935
|
+
case "numlock":
|
|
6936
|
+
return "NumLock";
|
|
6937
|
+
case "capslock":
|
|
6938
|
+
return "CapsLock";
|
|
6939
|
+
case "contextmenu":
|
|
6940
|
+
return "ContextMenu";
|
|
6941
|
+
case "+":
|
|
6942
|
+
return "Plus";
|
|
6943
|
+
default:
|
|
6944
|
+
return key.length === 1 ? key.toUpperCase() : key.charAt(0).toUpperCase() + key.slice(1);
|
|
6945
|
+
}
|
|
5712
6946
|
}
|
|
5713
6947
|
static formatKeyDisplay(key, isApple) {
|
|
5714
6948
|
if (!key) return "";
|
|
@@ -5741,17 +6975,21 @@ var ShortcutFormatter = class _ShortcutFormatter {
|
|
|
5741
6975
|
|
|
5742
6976
|
// src/shortcut/ShortcutManager.ts
|
|
5743
6977
|
var ShortcutManager = class _ShortcutManager {
|
|
6978
|
+
options;
|
|
6979
|
+
shortcuts = /* @__PURE__ */ new Map();
|
|
6980
|
+
scopeStack = [];
|
|
6981
|
+
sequenceBuffer = [];
|
|
6982
|
+
sequenceTimer = null;
|
|
6983
|
+
isListening = true;
|
|
6984
|
+
boundListener = null;
|
|
6985
|
+
abortController = null;
|
|
6986
|
+
idCounter = 0;
|
|
5744
6987
|
constructor(options) {
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
this.sequenceBuffer = [];
|
|
5748
|
-
this.sequenceTimer = null;
|
|
5749
|
-
this.isListening = true;
|
|
5750
|
-
this.boundListener = null;
|
|
5751
|
-
this.idCounter = 0;
|
|
6988
|
+
const rawTimeout = options?.sequenceTimeout;
|
|
6989
|
+
const sequenceTimeout = typeof rawTimeout === "number" && Number.isFinite(rawTimeout) && rawTimeout > 0 ? Math.min(rawTimeout, 1e4) : 800;
|
|
5752
6990
|
this.options = {
|
|
5753
6991
|
defaultScope: options?.defaultScope || "global",
|
|
5754
|
-
sequenceTimeout
|
|
6992
|
+
sequenceTimeout,
|
|
5755
6993
|
target: options?.target || (typeof window !== "undefined" ? window : {}),
|
|
5756
6994
|
onError: options?.onError
|
|
5757
6995
|
};
|
|
@@ -5780,12 +7018,12 @@ var ShortcutManager = class _ShortcutManager {
|
|
|
5780
7018
|
return true;
|
|
5781
7019
|
}
|
|
5782
7020
|
const role = el.getAttribute("role");
|
|
5783
|
-
if (role === "textbox" || role === "searchbox") {
|
|
7021
|
+
if (role === "textbox" || role === "searchbox" || role === "combobox" || role === "spinbutton") {
|
|
5784
7022
|
return true;
|
|
5785
7023
|
}
|
|
5786
7024
|
if (typeof el.closest === "function") {
|
|
5787
7025
|
const editableAncestor = el.closest(
|
|
5788
|
-
'[contenteditable="true"], [contenteditable="plaintext-only"], [contenteditable=""], [role="textbox"], [role="searchbox"]'
|
|
7026
|
+
'[contenteditable="true"], [contenteditable="plaintext-only"], [contenteditable=""], [role="textbox"], [role="searchbox"], [role="combobox"], [role="spinbutton"]'
|
|
5789
7027
|
);
|
|
5790
7028
|
if (editableAncestor) {
|
|
5791
7029
|
return true;
|
|
@@ -5844,6 +7082,9 @@ var ShortcutManager = class _ShortcutManager {
|
|
|
5844
7082
|
* Retire tous les raccourcis correspondant à une combinaison et éventuellement un scope.
|
|
5845
7083
|
*/
|
|
5846
7084
|
unbind(combo, scope) {
|
|
7085
|
+
if (typeof combo !== "string" || !combo.trim()) {
|
|
7086
|
+
return;
|
|
7087
|
+
}
|
|
5847
7088
|
const formatted = ShortcutFormatter.format(combo);
|
|
5848
7089
|
for (const [id, s] of this.shortcuts.entries()) {
|
|
5849
7090
|
if (s.formattedCombo === formatted || s.combo.trim().toLowerCase() === combo.trim().toLowerCase()) {
|
|
@@ -5942,7 +7183,11 @@ var ShortcutManager = class _ShortcutManager {
|
|
|
5942
7183
|
attachAria(element, combo) {
|
|
5943
7184
|
if (element && typeof element.setAttribute === "function") {
|
|
5944
7185
|
const ariaValue = ShortcutFormatter.toAriaKeyShortcuts(combo);
|
|
5945
|
-
|
|
7186
|
+
if (ariaValue) {
|
|
7187
|
+
element.setAttribute("aria-keyshortcuts", ariaValue);
|
|
7188
|
+
} else if (typeof element.removeAttribute === "function") {
|
|
7189
|
+
element.removeAttribute("aria-keyshortcuts");
|
|
7190
|
+
}
|
|
5946
7191
|
}
|
|
5947
7192
|
}
|
|
5948
7193
|
/**
|
|
@@ -5966,23 +7211,30 @@ var ShortcutManager = class _ShortcutManager {
|
|
|
5966
7211
|
if (typeof window === "undefined" || !this.options.target) {
|
|
5967
7212
|
return;
|
|
5968
7213
|
}
|
|
7214
|
+
this.abortController = new AbortController();
|
|
5969
7215
|
this.boundListener = (event) => this.handleKeyDown(event);
|
|
5970
7216
|
const target = this.options.target;
|
|
5971
7217
|
if (typeof target.addEventListener === "function") {
|
|
5972
|
-
target.addEventListener("keydown", this.boundListener,
|
|
7218
|
+
target.addEventListener("keydown", this.boundListener, {
|
|
7219
|
+
capture: false,
|
|
7220
|
+
signal: this.abortController.signal
|
|
7221
|
+
});
|
|
5973
7222
|
}
|
|
5974
7223
|
}
|
|
5975
7224
|
removeListener() {
|
|
5976
|
-
if (this.
|
|
7225
|
+
if (this.abortController) {
|
|
7226
|
+
this.abortController.abort();
|
|
7227
|
+
this.abortController = null;
|
|
7228
|
+
} else if (this.boundListener && this.options.target) {
|
|
5977
7229
|
const target = this.options.target;
|
|
5978
7230
|
if (typeof target.removeEventListener === "function") {
|
|
5979
7231
|
target.removeEventListener("keydown", this.boundListener, false);
|
|
5980
7232
|
}
|
|
5981
|
-
this.boundListener = null;
|
|
5982
7233
|
}
|
|
7234
|
+
this.boundListener = null;
|
|
5983
7235
|
}
|
|
5984
7236
|
handleKeyDown(event) {
|
|
5985
|
-
if (!this.isListening) {
|
|
7237
|
+
if (!this.isListening || isImeComposing(event)) {
|
|
5986
7238
|
return;
|
|
5987
7239
|
}
|
|
5988
7240
|
const k = (event.key || "").toLowerCase();
|
|
@@ -6001,7 +7253,7 @@ var ShortcutManager = class _ShortcutManager {
|
|
|
6001
7253
|
meta: event.metaKey,
|
|
6002
7254
|
key: ShortcutFormatter.normalizeKeyName(event.key || "")
|
|
6003
7255
|
};
|
|
6004
|
-
const now = Date.now();
|
|
7256
|
+
const now = event.timeStamp > 0 ? event.timeStamp : typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
6005
7257
|
if (this.sequenceBuffer.length > 0) {
|
|
6006
7258
|
const last = this.sequenceBuffer[this.sequenceBuffer.length - 1];
|
|
6007
7259
|
if (now - last.timestamp > this.options.sequenceTimeout) {
|
|
@@ -6044,8 +7296,12 @@ var ShortcutManager = class _ShortcutManager {
|
|
|
6044
7296
|
continue;
|
|
6045
7297
|
}
|
|
6046
7298
|
const firstStep = shortcut.normalizedSteps[0];
|
|
6047
|
-
if (firstStep && firstStep.key.length === 1
|
|
6048
|
-
|
|
7299
|
+
if (firstStep && firstStep.key.length === 1) {
|
|
7300
|
+
const isUntouchedChar = !firstStep.ctrl && !firstStep.alt && !firstStep.meta;
|
|
7301
|
+
const isAltGrOrOptionChar = firstStep.ctrl && firstStep.alt && !firstStep.meta || firstStep.alt && !firstStep.ctrl && !firstStep.meta;
|
|
7302
|
+
if (isUntouchedChar || isAltGrOrOptionChar) {
|
|
7303
|
+
continue;
|
|
7304
|
+
}
|
|
6049
7305
|
}
|
|
6050
7306
|
}
|
|
6051
7307
|
list.push(shortcut);
|
|
@@ -6056,13 +7312,15 @@ var ShortcutManager = class _ShortcutManager {
|
|
|
6056
7312
|
if (step.ctrl !== eventStep.ctrl) return false;
|
|
6057
7313
|
if (step.alt !== eventStep.alt) return false;
|
|
6058
7314
|
if (step.meta !== eventStep.meta) return false;
|
|
6059
|
-
const
|
|
7315
|
+
const rawKey = typeof rawEvent?.key === "string" ? rawEvent.key : "";
|
|
7316
|
+
const keyMatches = step.key === eventStep.key || rawKey !== "" && step.key === rawKey.toLowerCase();
|
|
6060
7317
|
if (!keyMatches) return false;
|
|
6061
7318
|
if (step.shift === eventStep.shift) {
|
|
6062
7319
|
return true;
|
|
6063
7320
|
}
|
|
6064
7321
|
if (!step.shift && eventStep.shift) {
|
|
6065
|
-
|
|
7322
|
+
const isNonAlphaSymbol = step.key.length === 1 && !/^[a-z]$/i.test(step.key);
|
|
7323
|
+
if (rawKey !== "" && rawKey === step.key || isNonAlphaSymbol && eventStep.key === step.key) {
|
|
6066
7324
|
return true;
|
|
6067
7325
|
}
|
|
6068
7326
|
}
|
|
@@ -6158,11 +7416,9 @@ var ShortcutManager = class _ShortcutManager {
|
|
|
6158
7416
|
};
|
|
6159
7417
|
|
|
6160
7418
|
// src/shortcut/index.ts
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
win.Wulf = wulfNamespace;
|
|
6165
|
-
wulfNamespace.Shortcut = Object.assign(ShortcutManager, {
|
|
7419
|
+
var wulfNamespace6 = getSafeWulfNamespace();
|
|
7420
|
+
if (wulfNamespace6) {
|
|
7421
|
+
wulfNamespace6.Shortcut = Object.assign(ShortcutManager, {
|
|
6166
7422
|
ShortcutManager,
|
|
6167
7423
|
ShortcutFormatter
|
|
6168
7424
|
});
|
|
@@ -6176,6 +7432,7 @@ export {
|
|
|
6176
7432
|
InputAmountMask,
|
|
6177
7433
|
InputEmailMask,
|
|
6178
7434
|
InputMask,
|
|
7435
|
+
LayoutEngine,
|
|
6179
7436
|
LocalizedComponent,
|
|
6180
7437
|
mask_exports as Mask,
|
|
6181
7438
|
MaskEngine,
|
|
@@ -6183,12 +7440,27 @@ export {
|
|
|
6183
7440
|
MaskKeyboard,
|
|
6184
7441
|
masonry_exports as Masonry,
|
|
6185
7442
|
scroll_exports as Scroll,
|
|
7443
|
+
ScrollBlock,
|
|
6186
7444
|
shortcut_exports as Shortcut,
|
|
7445
|
+
ShortcutFormatter,
|
|
7446
|
+
ShortcutManager,
|
|
6187
7447
|
toast_exports as Toast,
|
|
7448
|
+
ToastInstance,
|
|
7449
|
+
ToastManager,
|
|
6188
7450
|
FocusTrap as WulfFocusTrap,
|
|
7451
|
+
Masonry as WulfMasonry,
|
|
6189
7452
|
ShortcutManager as WulfShortcut,
|
|
7453
|
+
Toast as WulfToast,
|
|
6190
7454
|
createI18nManager,
|
|
6191
7455
|
mask_default as default,
|
|
6192
|
-
|
|
7456
|
+
getDeepActiveElement,
|
|
7457
|
+
getSafeWulfNamespace,
|
|
7458
|
+
isImeComposing,
|
|
7459
|
+
parseCssDurationMs,
|
|
7460
|
+
prefersReducedMotion,
|
|
7461
|
+
resolveMaskConstructorArgs,
|
|
7462
|
+
safeCssEscape,
|
|
7463
|
+
safeMove,
|
|
7464
|
+
waitForAnimations
|
|
6193
7465
|
};
|
|
6194
7466
|
//# sourceMappingURL=index.esm.js.map
|