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/mask.esm.js
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
// src/common/dom.ts
|
|
2
|
+
function getSafeWulfNamespace() {
|
|
3
|
+
if (typeof window === "undefined") return null;
|
|
4
|
+
const win = window;
|
|
5
|
+
const existing = win.Wulf;
|
|
6
|
+
if (!existing || typeof existing !== "object" || typeof Node !== "undefined" && existing instanceof Node || typeof HTMLCollection !== "undefined" && existing instanceof HTMLCollection) {
|
|
7
|
+
const fresh = {};
|
|
8
|
+
win.Wulf = fresh;
|
|
9
|
+
return fresh;
|
|
10
|
+
}
|
|
11
|
+
return existing;
|
|
12
|
+
}
|
|
13
|
+
function safeCssEscape(value) {
|
|
14
|
+
if (typeof CSS !== "undefined" && typeof CSS.escape === "function") {
|
|
15
|
+
return CSS.escape(value);
|
|
16
|
+
}
|
|
17
|
+
return String(value).replace(/["\\\u0000-\u001F\u007F]/g, "\\$&");
|
|
18
|
+
}
|
|
19
|
+
function safeMove(parent, node, referenceNode = null) {
|
|
20
|
+
const moveBefore = parent.moveBefore;
|
|
21
|
+
if (typeof moveBefore === "function" && node.isConnected && parent.isConnected && typeof parent.getRootNode === "function" && typeof node.getRootNode === "function" && parent.getRootNode() === node.getRootNode()) {
|
|
22
|
+
try {
|
|
23
|
+
moveBefore.call(parent, node, referenceNode);
|
|
24
|
+
return;
|
|
25
|
+
} catch {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
parent.insertBefore(node, referenceNode);
|
|
29
|
+
}
|
|
30
|
+
function isImeComposing(event) {
|
|
31
|
+
return Boolean(
|
|
32
|
+
event.isComposing || event.key === "Process" || event.key === "Enter" && event.keyCode === 229
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
1
36
|
// src/common/AuditableComponent.ts
|
|
2
37
|
var AuditableComponent = class {
|
|
3
38
|
/**
|
|
@@ -30,8 +65,11 @@ var AuditableComponent = class {
|
|
|
30
65
|
const rawValue = element.getAttribute(attrName)?.trim();
|
|
31
66
|
if (!rawValue) return false;
|
|
32
67
|
const doc = element.ownerDocument || document;
|
|
68
|
+
const root = typeof element.getRootNode === "function" ? element.getRootNode() : doc;
|
|
33
69
|
const ids = rawValue.split(/\s+/).filter(Boolean);
|
|
34
|
-
const isValid = ids.length > 0 && ids.every(
|
|
70
|
+
const isValid = ids.length > 0 && ids.every(
|
|
71
|
+
(id) => Boolean(typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.getElementById(id) : doc.getElementById(id))
|
|
72
|
+
);
|
|
35
73
|
if (!isValid) {
|
|
36
74
|
warnings.push(
|
|
37
75
|
`Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`
|
|
@@ -42,6 +80,7 @@ var AuditableComponent = class {
|
|
|
42
80
|
};
|
|
43
81
|
|
|
44
82
|
// src/mask/BaseInputMask.ts
|
|
83
|
+
var VALID_ALIGNS = /* @__PURE__ */ new Set(["left", "right", "center"]);
|
|
45
84
|
function resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOptions) {
|
|
46
85
|
const isSecondArgInput = Boolean(
|
|
47
86
|
inputOrOptions && typeof inputOrOptions === "object" && "tagName" in inputOrOptions && inputOrOptions.tagName === "INPUT"
|
|
@@ -60,59 +99,27 @@ function resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOption
|
|
|
60
99
|
};
|
|
61
100
|
}
|
|
62
101
|
var BaseInputMask = class extends AuditableComponent {
|
|
102
|
+
wrapper;
|
|
103
|
+
input;
|
|
104
|
+
options;
|
|
105
|
+
ghost = null;
|
|
106
|
+
isWrapperCreated = false;
|
|
107
|
+
wasWrapperFallbackStyled = false;
|
|
108
|
+
wasAlignSet = false;
|
|
109
|
+
hadInitialDataAlign = false;
|
|
110
|
+
isDestroyed = false;
|
|
111
|
+
isFocused = false;
|
|
112
|
+
isDispatchingNativeInput = false;
|
|
113
|
+
lastTrackedValue = "";
|
|
114
|
+
nativeValueDescriptor = null;
|
|
115
|
+
onCutHandler = () => {
|
|
116
|
+
};
|
|
117
|
+
onFormResetHandler;
|
|
118
|
+
mutationObserver = null;
|
|
119
|
+
focusSelectTimerId = null;
|
|
120
|
+
abortController = new AbortController();
|
|
63
121
|
constructor(targetOrWrapper, inputOrOptions, maybeOptions) {
|
|
64
122
|
super();
|
|
65
|
-
this.ghost = null;
|
|
66
|
-
this.isWrapperCreated = false;
|
|
67
|
-
this.isDestroyed = false;
|
|
68
|
-
this.isFocused = false;
|
|
69
|
-
this.isDispatchingNativeInput = false;
|
|
70
|
-
this.lastTrackedValue = "";
|
|
71
|
-
this.nativeValueDescriptor = null;
|
|
72
|
-
this.onCutHandler = () => {
|
|
73
|
-
};
|
|
74
|
-
this.mutationObserver = null;
|
|
75
|
-
this.focusSelectTimerId = null;
|
|
76
|
-
this.onBaseCopy = (e) => {
|
|
77
|
-
if (!this.options.copyRaw || this.options.disabled || this.input.type === "password") return;
|
|
78
|
-
const start = this.input.selectionStart ?? 0;
|
|
79
|
-
const end = this.input.selectionEnd ?? start;
|
|
80
|
-
let textToCopy = "";
|
|
81
|
-
if (start !== end) {
|
|
82
|
-
textToCopy = this.extractRawSnippet(this.input.value.slice(start, end));
|
|
83
|
-
} else {
|
|
84
|
-
textToCopy = this.getRawValue();
|
|
85
|
-
}
|
|
86
|
-
if (textToCopy && e.clipboardData) {
|
|
87
|
-
e.preventDefault();
|
|
88
|
-
e.clipboardData.setData("text/plain", textToCopy);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
this.onBaseFocus = () => {
|
|
92
|
-
this.isFocused = true;
|
|
93
|
-
if (this.options.selectAllOnFocus && this.input.value.length > 0) {
|
|
94
|
-
if (this.focusSelectTimerId !== null) {
|
|
95
|
-
clearTimeout(this.focusSelectTimerId);
|
|
96
|
-
}
|
|
97
|
-
this.focusSelectTimerId = window.setTimeout(() => {
|
|
98
|
-
this.focusSelectTimerId = null;
|
|
99
|
-
if (!this.isDestroyed && document.activeElement === this.input) {
|
|
100
|
-
this.input.select();
|
|
101
|
-
}
|
|
102
|
-
}, 0);
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
this.onBaseBlur = () => {
|
|
106
|
-
this.isFocused = false;
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Synchronise le défilement horizontal du ghost avec celui du champ d'entrée natif.
|
|
110
|
-
*/
|
|
111
|
-
this.onScroll = () => {
|
|
112
|
-
if (this.ghost) {
|
|
113
|
-
this.ghost.scrollLeft = this.input.scrollLeft;
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
123
|
const { wrapper: providedWrapper, input, options } = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOptions);
|
|
117
124
|
if (!input || typeof input !== "object" || input.nodeType !== 1 || input.tagName !== "INPUT") {
|
|
118
125
|
throw new Error(`[${new.target.name || "InputMask"}] input (HTMLInputElement) est requis.`);
|
|
@@ -122,20 +129,26 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
122
129
|
const shouldCreateWrapper = Boolean(options.createWrapper ?? dataCreateWrapper);
|
|
123
130
|
let effectiveWrapper = providedWrapper;
|
|
124
131
|
if (!effectiveWrapper && shouldCreateWrapper) {
|
|
125
|
-
const
|
|
132
|
+
const doc = this.input.ownerDocument || document;
|
|
133
|
+
const span = doc.createElement("span");
|
|
126
134
|
span.className = "wulf-mask-wrapper";
|
|
127
|
-
span.style.display = "inline-grid";
|
|
128
|
-
span.style.gridTemplateColumns = "1fr";
|
|
129
|
-
span.style.gridTemplateRows = "1fr";
|
|
130
|
-
span.style.verticalAlign = "middle";
|
|
131
|
-
span.style.boxSizing = "border-box";
|
|
132
|
-
span.style.position = "relative";
|
|
133
135
|
if (this.input.parentNode) {
|
|
134
136
|
this.input.parentNode.insertBefore(span, this.input);
|
|
135
137
|
}
|
|
136
|
-
span
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
safeMove(span, this.input, null);
|
|
139
|
+
const view = doc.defaultView || (typeof window !== "undefined" ? window : null);
|
|
140
|
+
const needsFallbackStyles = !span.isConnected || !view || view.getComputedStyle(span).display !== "inline-grid";
|
|
141
|
+
if (needsFallbackStyles) {
|
|
142
|
+
span.style.display = "inline-grid";
|
|
143
|
+
span.style.gridTemplateColumns = "1fr";
|
|
144
|
+
span.style.gridTemplateRows = "1fr";
|
|
145
|
+
span.style.verticalAlign = "middle";
|
|
146
|
+
span.style.boxSizing = "border-box";
|
|
147
|
+
span.style.position = "relative";
|
|
148
|
+
this.input.style.gridArea = "1 / 1 / 2 / 2";
|
|
149
|
+
this.input.style.boxSizing = "border-box";
|
|
150
|
+
this.wasWrapperFallbackStyled = true;
|
|
151
|
+
}
|
|
139
152
|
effectiveWrapper = span;
|
|
140
153
|
this.isWrapperCreated = true;
|
|
141
154
|
}
|
|
@@ -148,12 +161,15 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
148
161
|
const dataDisabled = this.hasAttr("data-disabled");
|
|
149
162
|
const dataSelectAll = this.getAttr("data-mask-select-on-focus") === "true";
|
|
150
163
|
const dataCopyRaw = this.getAttr("data-mask-copy-raw") === "true";
|
|
151
|
-
const
|
|
164
|
+
const rawDataAlign = this.getAttr("data-mask-align") || this.getAttr("data-align");
|
|
165
|
+
const dataAlign = rawDataAlign && VALID_ALIGNS.has(rawDataAlign) ? rawDataAlign : null;
|
|
166
|
+
this.hadInitialDataAlign = this.wrapper.hasAttribute("data-align");
|
|
152
167
|
const dataAudit = this.getAttr("data-mask-audit");
|
|
153
168
|
const { disabled: optDisabled, align: optAlign, ...otherOptions } = options;
|
|
169
|
+
const validOptAlign = optAlign && VALID_ALIGNS.has(optAlign) ? optAlign : void 0;
|
|
154
170
|
const resolvedDisabled = optDisabled !== void 0 ? optDisabled : dataDisabled ? true : false;
|
|
155
171
|
const resolvedAudit = options.audit ?? (dataAudit !== null ? dataAudit !== "false" : true);
|
|
156
|
-
const isPassword = this.
|
|
172
|
+
const isPassword = this.isPasswordInput();
|
|
157
173
|
this.options = {
|
|
158
174
|
...otherOptions,
|
|
159
175
|
createWrapper: shouldCreateWrapper,
|
|
@@ -161,7 +177,7 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
161
177
|
selectAllOnFocus: options.selectAllOnFocus ?? dataSelectAll ?? false,
|
|
162
178
|
copyRaw: isPassword ? false : options.copyRaw ?? dataCopyRaw ?? false,
|
|
163
179
|
disabled: resolvedDisabled,
|
|
164
|
-
align:
|
|
180
|
+
align: validOptAlign ?? (dataAlign || void 0),
|
|
165
181
|
emitNativeInput: options.emitNativeInput ?? true,
|
|
166
182
|
audit: resolvedAudit
|
|
167
183
|
};
|
|
@@ -208,16 +224,54 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
208
224
|
* Attache les écouteurs de base pour focus/blur, copie brute et sélection.
|
|
209
225
|
*/
|
|
210
226
|
bindBaseEvents() {
|
|
211
|
-
|
|
212
|
-
this.input.addEventListener("
|
|
213
|
-
this.input.addEventListener("
|
|
227
|
+
const { signal } = this.abortController;
|
|
228
|
+
this.input.addEventListener("copy", this.onBaseCopy, { signal });
|
|
229
|
+
this.input.addEventListener("focus", this.onBaseFocus, { signal });
|
|
230
|
+
this.input.addEventListener("blur", this.onBaseBlur, { signal });
|
|
214
231
|
}
|
|
232
|
+
onBaseCopy = (e) => {
|
|
233
|
+
if (!this.options.copyRaw || this.options.disabled || this.input.type === "password") return;
|
|
234
|
+
const start = this.input.selectionStart ?? 0;
|
|
235
|
+
const end = this.input.selectionEnd ?? start;
|
|
236
|
+
let textToCopy = "";
|
|
237
|
+
if (start !== end) {
|
|
238
|
+
textToCopy = this.extractRawSnippet(this.input.value.slice(start, end));
|
|
239
|
+
} else {
|
|
240
|
+
textToCopy = this.getRawValue();
|
|
241
|
+
}
|
|
242
|
+
if (textToCopy && e.clipboardData) {
|
|
243
|
+
e.preventDefault();
|
|
244
|
+
e.clipboardData.setData("text/plain", textToCopy);
|
|
245
|
+
}
|
|
246
|
+
};
|
|
215
247
|
/**
|
|
216
248
|
* Extrait la valeur brute d'un extrait de chaîne sélectionné.
|
|
217
249
|
*/
|
|
218
250
|
extractRawSnippet(snippet) {
|
|
219
251
|
return snippet;
|
|
220
252
|
}
|
|
253
|
+
onBaseFocus = () => {
|
|
254
|
+
this.isFocused = true;
|
|
255
|
+
if (this.options.selectAllOnFocus && this.input.value.length > 0) {
|
|
256
|
+
if (this.focusSelectTimerId !== null) {
|
|
257
|
+
clearTimeout(this.focusSelectTimerId);
|
|
258
|
+
}
|
|
259
|
+
this.focusSelectTimerId = window.setTimeout(() => {
|
|
260
|
+
this.focusSelectTimerId = null;
|
|
261
|
+
if (!this.isDestroyed && document.activeElement === this.input) {
|
|
262
|
+
this.input.select();
|
|
263
|
+
}
|
|
264
|
+
}, 0);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
onBaseBlur = () => {
|
|
268
|
+
this.isFocused = false;
|
|
269
|
+
if (this.isPasswordInput()) {
|
|
270
|
+
this.lastTrackedValue = "";
|
|
271
|
+
this.clearGhost();
|
|
272
|
+
this.wrapper.removeAttribute("data-mask");
|
|
273
|
+
}
|
|
274
|
+
};
|
|
221
275
|
/**
|
|
222
276
|
* Initialise l'observation des modifications dynamiques des attributs data-* et placeholder.
|
|
223
277
|
*/
|
|
@@ -256,21 +310,41 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
256
310
|
this.mutationObserver.observe(this.input, config);
|
|
257
311
|
}
|
|
258
312
|
}
|
|
313
|
+
/**
|
|
314
|
+
* Indique si le champ natif sous-jacent est de type mot de passe.
|
|
315
|
+
*/
|
|
316
|
+
isPasswordInput() {
|
|
317
|
+
return (this.input.type || "").toLowerCase() === "password";
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Calcule une empreinte non réversible pour détecter les changements sans conserver de secret en RAM.
|
|
321
|
+
*/
|
|
322
|
+
computePasswordDigest(val) {
|
|
323
|
+
let hash = 2166136261;
|
|
324
|
+
for (let i = 0; i < val.length; i++) {
|
|
325
|
+
hash ^= val.charCodeAt(i);
|
|
326
|
+
hash = Math.imul(hash, 16777619);
|
|
327
|
+
}
|
|
328
|
+
return `__pwd:${(hash >>> 0).toString(36)}:${val.length}`;
|
|
329
|
+
}
|
|
259
330
|
/**
|
|
260
331
|
* Modifie dynamiquement l'alignement du champ et du masque fantôme.
|
|
261
332
|
*/
|
|
262
333
|
setAlign(align) {
|
|
263
|
-
const
|
|
334
|
+
const normalized = align && VALID_ALIGNS.has(align) ? align : null;
|
|
335
|
+
const targetAlign = normalized || void 0;
|
|
264
336
|
const currentAttr = this.wrapper.getAttribute("data-align");
|
|
265
|
-
|
|
337
|
+
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");
|
|
338
|
+
if (this.options.align === targetAlign && currentAttr === normalized && hasExpectedClass) {
|
|
266
339
|
return;
|
|
267
340
|
}
|
|
268
341
|
this.options.align = targetAlign;
|
|
269
342
|
this.wrapper.classList.remove("align-left", "align-right", "align-center");
|
|
270
|
-
if (
|
|
271
|
-
this.wrapper.classList.add(`align-${
|
|
272
|
-
|
|
273
|
-
|
|
343
|
+
if (normalized) {
|
|
344
|
+
this.wrapper.classList.add(`align-${normalized}`);
|
|
345
|
+
this.wasAlignSet = true;
|
|
346
|
+
if (this.wrapper.getAttribute("data-align") !== normalized) {
|
|
347
|
+
this.wrapper.setAttribute("data-align", normalized);
|
|
274
348
|
}
|
|
275
349
|
} else {
|
|
276
350
|
if (this.wrapper.hasAttribute("data-align")) {
|
|
@@ -296,14 +370,18 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
296
370
|
} else if (attrName === "data-mask-select-on-focus") {
|
|
297
371
|
this.options.selectAllOnFocus = this.getAttr("data-mask-select-on-focus") === "true";
|
|
298
372
|
} else if (attrName === "data-mask-copy-raw") {
|
|
299
|
-
this.options.copyRaw = this.
|
|
373
|
+
this.options.copyRaw = this.isPasswordInput() ? false : this.getAttr("data-mask-copy-raw") === "true";
|
|
300
374
|
} else if (attrName === "type") {
|
|
301
|
-
if (this.
|
|
375
|
+
if (this.isPasswordInput()) {
|
|
302
376
|
this.options.copyRaw = false;
|
|
377
|
+
this.lastTrackedValue = "";
|
|
378
|
+
this.clearGhost();
|
|
379
|
+
this.wrapper.removeAttribute("data-mask");
|
|
303
380
|
this.onPasswordModeDetected();
|
|
304
381
|
}
|
|
305
382
|
} else if (attrName === "data-mask-align" || attrName === "data-align") {
|
|
306
|
-
const
|
|
383
|
+
const rawAlign = this.getAttr("data-mask-align") || this.getAttr("data-align");
|
|
384
|
+
const align = rawAlign && VALID_ALIGNS.has(rawAlign) ? rawAlign : null;
|
|
307
385
|
if (align !== (this.options.align ?? null)) {
|
|
308
386
|
this.setAlign(align);
|
|
309
387
|
}
|
|
@@ -331,15 +409,42 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
331
409
|
if (existing) {
|
|
332
410
|
existing.remove();
|
|
333
411
|
}
|
|
334
|
-
this.
|
|
412
|
+
const doc = this.input.ownerDocument || document;
|
|
413
|
+
this.ghost = doc.createElement("div");
|
|
335
414
|
this.ghost.className = "mask-ghost";
|
|
336
415
|
this.ghost.setAttribute("aria-hidden", "true");
|
|
337
416
|
this.ghost.style.display = "flex";
|
|
338
417
|
this.ghost.style.alignItems = "center";
|
|
339
418
|
this.wrapper.appendChild(this.ghost);
|
|
340
419
|
this.wrapper.classList.add("has-ghost");
|
|
420
|
+
const view = doc.defaultView || (typeof window !== "undefined" ? window : null);
|
|
421
|
+
if (!this.wrapper.isConnected || !view || view.getComputedStyle(this.ghost).pointerEvents !== "none") {
|
|
422
|
+
this.ghost.style.gridArea = "1 / 1 / 2 / 2";
|
|
423
|
+
this.ghost.style.pointerEvents = "none";
|
|
424
|
+
}
|
|
341
425
|
this.syncGhostStyles();
|
|
342
426
|
}
|
|
427
|
+
/**
|
|
428
|
+
* Met à jour atomiquement le contenu du conteneur fantôme et synchronise .has-visible-ghost.
|
|
429
|
+
*/
|
|
430
|
+
setGhostContent(...nodes) {
|
|
431
|
+
if (!this.ghost) return;
|
|
432
|
+
if (typeof this.ghost.replaceChildren === "function") {
|
|
433
|
+
this.ghost.replaceChildren(...nodes);
|
|
434
|
+
} else {
|
|
435
|
+
this.ghost.textContent = "";
|
|
436
|
+
for (const n of nodes) {
|
|
437
|
+
this.ghost.appendChild(typeof n === "string" ? document.createTextNode(n) : n);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
this.wrapper.classList.toggle("has-visible-ghost", nodes.length > 0);
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Vide atomiquement le conteneur fantôme et rétablit l'affichage du placeholder natif.
|
|
444
|
+
*/
|
|
445
|
+
clearGhost() {
|
|
446
|
+
this.setGhostContent();
|
|
447
|
+
}
|
|
343
448
|
/**
|
|
344
449
|
* Clone fidèlement la géométrie typographique et les espacements de l'input natif
|
|
345
450
|
* sur le conteneur fantôme pour garantir un alignement sub-pixel absolu quel que soit
|
|
@@ -372,12 +477,17 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
372
477
|
this.ghost.style.textAlign = style.textAlign;
|
|
373
478
|
this.ghost.style.direction = style.direction;
|
|
374
479
|
const isRtl = style.direction === "rtl" || this.input.getAttribute("dir") === "rtl" || this.wrapper.getAttribute("dir") === "rtl";
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
480
|
+
const textAlign = style.textAlign;
|
|
481
|
+
if (textAlign === "right") {
|
|
482
|
+
this.ghost.style.justifyContent = "right";
|
|
483
|
+
} else if (textAlign === "left") {
|
|
484
|
+
this.ghost.style.justifyContent = "left";
|
|
485
|
+
} else if (textAlign === "center") {
|
|
378
486
|
this.ghost.style.justifyContent = "center";
|
|
487
|
+
} else if (textAlign === "end") {
|
|
488
|
+
this.ghost.style.justifyContent = isRtl ? "left" : "right";
|
|
379
489
|
} else {
|
|
380
|
-
this.ghost.style.justifyContent = "
|
|
490
|
+
this.ghost.style.justifyContent = isRtl ? "right" : "left";
|
|
381
491
|
}
|
|
382
492
|
}
|
|
383
493
|
/**
|
|
@@ -401,15 +511,23 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
401
511
|
this.isDispatchingNativeInput = true;
|
|
402
512
|
try {
|
|
403
513
|
const tracker = this.input._valueTracker;
|
|
404
|
-
if (tracker && typeof tracker.setValue === "function") {
|
|
514
|
+
if (!this.isPasswordInput() && tracker && typeof tracker.setValue === "function") {
|
|
405
515
|
tracker.setValue(this.lastTrackedValue);
|
|
406
516
|
}
|
|
407
|
-
this.lastTrackedValue = this.input.value;
|
|
517
|
+
this.lastTrackedValue = this.isPasswordInput() ? "" : this.input.value;
|
|
408
518
|
this.input.dispatchEvent(new Event("input", { bubbles: true, cancelable: false }));
|
|
409
519
|
} finally {
|
|
410
520
|
this.isDispatchingNativeInput = false;
|
|
411
521
|
}
|
|
412
522
|
}
|
|
523
|
+
/**
|
|
524
|
+
* Synchronise le défilement horizontal du ghost avec celui du champ d'entrée natif.
|
|
525
|
+
*/
|
|
526
|
+
onScroll = () => {
|
|
527
|
+
if (this.ghost) {
|
|
528
|
+
this.ghost.scrollLeft = this.input.scrollLeft;
|
|
529
|
+
}
|
|
530
|
+
};
|
|
413
531
|
/**
|
|
414
532
|
* Intercepte les modifications directes de la propriété input.value (ex: input.value = '').
|
|
415
533
|
*/
|
|
@@ -521,15 +639,19 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
521
639
|
audit() {
|
|
522
640
|
const warnings = [];
|
|
523
641
|
const doc = this.input.ownerDocument || document;
|
|
642
|
+
const root = typeof this.input.getRootNode === "function" ? this.input.getRootNode() : doc;
|
|
643
|
+
const labelRoot = typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root : doc;
|
|
524
644
|
const ariaLabel = this.input.getAttribute("aria-label")?.trim();
|
|
525
645
|
const hasValidLabelledby = this.checkAriaIdReferences(this.input, "aria-labelledby", warnings);
|
|
526
646
|
const hasWrappingLabel = Boolean(this.input.closest("label"));
|
|
527
647
|
const hasNativeLabels = Boolean(this.input.labels && this.input.labels.length > 0);
|
|
528
648
|
let hasExplicitLabelFor = false;
|
|
529
|
-
if (this.input.id
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
649
|
+
if (this.input.id) {
|
|
650
|
+
try {
|
|
651
|
+
hasExplicitLabelFor = Boolean(labelRoot.querySelector(`label[for="${safeCssEscape(this.input.id)}"]`));
|
|
652
|
+
} catch {
|
|
653
|
+
hasExplicitLabelFor = false;
|
|
654
|
+
}
|
|
533
655
|
}
|
|
534
656
|
if (!ariaLabel && !hasValidLabelledby && !hasWrappingLabel && !hasNativeLabels && !hasExplicitLabelFor) {
|
|
535
657
|
warnings.push(
|
|
@@ -575,25 +697,41 @@ var BaseInputMask = class extends AuditableComponent {
|
|
|
575
697
|
this.mutationObserver.disconnect();
|
|
576
698
|
this.mutationObserver = null;
|
|
577
699
|
}
|
|
578
|
-
this.
|
|
579
|
-
this.
|
|
580
|
-
this.input.removeEventListener("blur", this.onBaseBlur);
|
|
700
|
+
this.abortController.abort();
|
|
701
|
+
this.lastTrackedValue = "";
|
|
581
702
|
this.unhookValueProperty();
|
|
582
703
|
if (this.ghost) {
|
|
583
704
|
this.ghost.remove();
|
|
584
705
|
this.ghost = null;
|
|
585
706
|
}
|
|
586
707
|
if (this.isWrapperCreated && this.wrapper) {
|
|
587
|
-
this.
|
|
588
|
-
|
|
589
|
-
|
|
708
|
+
if (this.wasWrapperFallbackStyled) {
|
|
709
|
+
this.input.style.gridArea = "";
|
|
710
|
+
this.input.style.boxSizing = "";
|
|
711
|
+
}
|
|
712
|
+
if (this.wrapper.parentElement) {
|
|
713
|
+
safeMove(this.wrapper.parentElement, this.input, this.wrapper);
|
|
714
|
+
} else if (this.wrapper.parentNode) {
|
|
590
715
|
this.wrapper.parentNode.insertBefore(this.input, this.wrapper);
|
|
591
716
|
}
|
|
592
717
|
this.wrapper.remove();
|
|
593
718
|
} else if (this.wrapper) {
|
|
594
719
|
this.wrapper.removeAttribute("data-mask");
|
|
595
720
|
this.wrapper.removeAttribute("data-disabled");
|
|
596
|
-
this.
|
|
721
|
+
if (this.wasAlignSet && !this.hadInitialDataAlign) {
|
|
722
|
+
this.wrapper.removeAttribute("data-align");
|
|
723
|
+
}
|
|
724
|
+
if (this.wasAlignSet) {
|
|
725
|
+
this.wrapper.classList.remove("align-left", "align-right", "align-center");
|
|
726
|
+
}
|
|
727
|
+
this.wrapper.classList.remove(
|
|
728
|
+
"is-complete",
|
|
729
|
+
"is-focused",
|
|
730
|
+
"mask-focus-only",
|
|
731
|
+
"has-selection",
|
|
732
|
+
"has-ghost",
|
|
733
|
+
"has-visible-ghost"
|
|
734
|
+
);
|
|
597
735
|
}
|
|
598
736
|
}
|
|
599
737
|
};
|
|
@@ -607,19 +745,34 @@ var DEFAULT_TOKENS = {
|
|
|
607
745
|
"#": { pattern: /[a-zA-Z0-9]/, transform: (c) => c.toUpperCase() }
|
|
608
746
|
};
|
|
609
747
|
var MaskEngine = class _MaskEngine {
|
|
748
|
+
pattern;
|
|
749
|
+
patterns = [];
|
|
750
|
+
subEngines = [];
|
|
751
|
+
activeEngine = null;
|
|
752
|
+
placeholderChar;
|
|
753
|
+
tokens;
|
|
754
|
+
slots = [];
|
|
755
|
+
fullMaskTemplate = "";
|
|
756
|
+
prefixSlotsCount = 0;
|
|
757
|
+
prefixString = "";
|
|
758
|
+
strict = true;
|
|
759
|
+
autoLowercase = false;
|
|
610
760
|
constructor(pattern, options = {}) {
|
|
611
|
-
this.patterns = [];
|
|
612
|
-
this.subEngines = [];
|
|
613
|
-
this.activeEngine = null;
|
|
614
|
-
this.slots = [];
|
|
615
|
-
this.fullMaskTemplate = "";
|
|
616
|
-
this.prefixSlotsCount = 0;
|
|
617
|
-
this.prefixString = "";
|
|
618
|
-
this.strict = true;
|
|
619
|
-
this.autoLowercase = false;
|
|
620
761
|
const opts = options || {};
|
|
621
|
-
|
|
622
|
-
this.
|
|
762
|
+
const rawPlaceholder = String(opts.placeholderChar || "_");
|
|
763
|
+
this.placeholderChar = Array.from(rawPlaceholder)[0] || "_";
|
|
764
|
+
const tokenMap = /* @__PURE__ */ Object.create(null);
|
|
765
|
+
for (const [k, v] of Object.entries(DEFAULT_TOKENS)) {
|
|
766
|
+
tokenMap[k] = v;
|
|
767
|
+
}
|
|
768
|
+
if (opts.tokens && typeof opts.tokens === "object") {
|
|
769
|
+
for (const [k, v] of Object.entries(opts.tokens)) {
|
|
770
|
+
if (k !== "__proto__" && k !== "constructor" && k !== "prototype" && v) {
|
|
771
|
+
tokenMap[k] = v;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
this.tokens = tokenMap;
|
|
623
776
|
this.strict = opts.strict !== false;
|
|
624
777
|
this.autoLowercase = opts.autoLowercase ?? false;
|
|
625
778
|
this.pattern = "";
|
|
@@ -679,7 +832,7 @@ var MaskEngine = class _MaskEngine {
|
|
|
679
832
|
i++;
|
|
680
833
|
char = this.pattern[i];
|
|
681
834
|
}
|
|
682
|
-
const token = !isEscaped ? this.tokens[char] : void 0;
|
|
835
|
+
const token = !isEscaped && Object.hasOwn(this.tokens, char) ? this.tokens[char] : void 0;
|
|
683
836
|
if (token) {
|
|
684
837
|
isPrefixMode = false;
|
|
685
838
|
this.slots.push({
|
|
@@ -726,7 +879,7 @@ var MaskEngine = class _MaskEngine {
|
|
|
726
879
|
return p.length > 0 && trimmed.toLowerCase().startsWith(p.trim().toLowerCase());
|
|
727
880
|
});
|
|
728
881
|
const candidates = withMatchingPrefix.length > 0 ? withMatchingPrefix : this.subEngines;
|
|
729
|
-
const maxCandidate =
|
|
882
|
+
const maxCandidate = candidates.toSorted((a, b) => b.getEditableCount() - a.getEditableCount())[0];
|
|
730
883
|
const raw = maxCandidate ? maxCandidate.extractRaw(trimmed) : trimmed;
|
|
731
884
|
const rawLen = raw.length;
|
|
732
885
|
for (const eng of candidates) {
|
|
@@ -782,6 +935,18 @@ var MaskEngine = class _MaskEngine {
|
|
|
782
935
|
*/
|
|
783
936
|
setStrict(strict) {
|
|
784
937
|
this.strict = strict;
|
|
938
|
+
for (const sub of this.subEngines) {
|
|
939
|
+
sub.setStrict(strict);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
/**
|
|
943
|
+
* Active ou désactive dynamiquement la mise en minuscules automatique.
|
|
944
|
+
*/
|
|
945
|
+
setAutoLowercase(autoLowercase) {
|
|
946
|
+
this.autoLowercase = autoLowercase;
|
|
947
|
+
for (const sub of this.subEngines) {
|
|
948
|
+
sub.setAutoLowercase(autoLowercase);
|
|
949
|
+
}
|
|
785
950
|
}
|
|
786
951
|
/**
|
|
787
952
|
* Indique si le masque est en mode strict.
|
|
@@ -1006,9 +1171,10 @@ var MaskEngine = class _MaskEngine {
|
|
|
1006
1171
|
|
|
1007
1172
|
// src/mask/MaskHistory.ts
|
|
1008
1173
|
var MaskHistory = class {
|
|
1174
|
+
stack = [];
|
|
1175
|
+
index = -1;
|
|
1176
|
+
maxDepth;
|
|
1009
1177
|
constructor(maxDepth = 50) {
|
|
1010
|
-
this.stack = [];
|
|
1011
|
-
this.index = -1;
|
|
1012
1178
|
this.maxDepth = maxDepth;
|
|
1013
1179
|
}
|
|
1014
1180
|
/**
|
|
@@ -1086,6 +1252,7 @@ var MaskHistory = class {
|
|
|
1086
1252
|
|
|
1087
1253
|
// src/mask/MaskKeyboard.ts
|
|
1088
1254
|
var MaskKeyboard = class {
|
|
1255
|
+
delegate;
|
|
1089
1256
|
constructor(delegate) {
|
|
1090
1257
|
this.delegate = delegate;
|
|
1091
1258
|
}
|
|
@@ -1093,6 +1260,7 @@ var MaskKeyboard = class {
|
|
|
1093
1260
|
* Analyse et traite l'événement keydown de l'input.
|
|
1094
1261
|
*/
|
|
1095
1262
|
handleKeyDown(e) {
|
|
1263
|
+
if (isImeComposing(e)) return;
|
|
1096
1264
|
const input = this.delegate.getInput();
|
|
1097
1265
|
const engine = this.delegate.getEngine();
|
|
1098
1266
|
const history = this.delegate.getHistory();
|
|
@@ -1186,7 +1354,7 @@ var MaskKeyboard = class {
|
|
|
1186
1354
|
input.setSelectionRange(minPos, minPos);
|
|
1187
1355
|
return;
|
|
1188
1356
|
}
|
|
1189
|
-
if (e.key === "Home" && !e.shiftKey) {
|
|
1357
|
+
if (e.key === "Home" && minPos > 0 && !e.shiftKey && !e.ctrlKey && !e.metaKey && !e.altKey) {
|
|
1190
1358
|
e.preventDefault();
|
|
1191
1359
|
input.setSelectionRange(minPos, minPos);
|
|
1192
1360
|
return;
|
|
@@ -1291,6 +1459,23 @@ var MaskKeyboard = class {
|
|
|
1291
1459
|
|
|
1292
1460
|
// src/mask/InputMask.ts
|
|
1293
1461
|
var InputMask = class extends BaseInputMask {
|
|
1462
|
+
engine;
|
|
1463
|
+
history;
|
|
1464
|
+
keyboard;
|
|
1465
|
+
isComposing = false;
|
|
1466
|
+
isUndoingRedoing = false;
|
|
1467
|
+
isMouseDown = false;
|
|
1468
|
+
isApplyingMask = false;
|
|
1469
|
+
lastValue = "";
|
|
1470
|
+
lastInternalRemainingMask = "";
|
|
1471
|
+
isNotifying = false;
|
|
1472
|
+
hasPendingNotification = false;
|
|
1473
|
+
onChangeNativeHandler = () => {
|
|
1474
|
+
};
|
|
1475
|
+
wasInputModeInferred = false;
|
|
1476
|
+
cutTimerId = null;
|
|
1477
|
+
pasteTimerId = null;
|
|
1478
|
+
resetTimerId = null;
|
|
1294
1479
|
constructor(targetOrWrapper, inputOrOptions, options) {
|
|
1295
1480
|
const args = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, options);
|
|
1296
1481
|
const wrap = args.wrapper;
|
|
@@ -1323,20 +1508,6 @@ var InputMask = class extends BaseInputMask {
|
|
|
1323
1508
|
onComplete: opts.onComplete || opts.oncomplete
|
|
1324
1509
|
};
|
|
1325
1510
|
super(wrap, inp, resolvedOptions);
|
|
1326
|
-
this.isComposing = false;
|
|
1327
|
-
this.isUndoingRedoing = false;
|
|
1328
|
-
this.isMouseDown = false;
|
|
1329
|
-
this.isApplyingMask = false;
|
|
1330
|
-
this.lastValue = "";
|
|
1331
|
-
this.lastInternalRemainingMask = "";
|
|
1332
|
-
this.isNotifying = false;
|
|
1333
|
-
this.hasPendingNotification = false;
|
|
1334
|
-
this.onChangeNativeHandler = () => {
|
|
1335
|
-
};
|
|
1336
|
-
this.wasInputModeInferred = false;
|
|
1337
|
-
this.cutTimerId = null;
|
|
1338
|
-
this.pasteTimerId = null;
|
|
1339
|
-
this.resetTimerId = null;
|
|
1340
1511
|
this.history = new MaskHistory();
|
|
1341
1512
|
this.engine = new MaskEngine(this.options.mask || "", {
|
|
1342
1513
|
placeholderChar: this.options.placeholderChar,
|
|
@@ -1355,16 +1526,17 @@ var InputMask = class extends BaseInputMask {
|
|
|
1355
1526
|
enforceMinCursor: () => this.enforceMinCursor()
|
|
1356
1527
|
});
|
|
1357
1528
|
this.bindEvents();
|
|
1358
|
-
this.lastValue = this.input.value;
|
|
1529
|
+
this.lastValue = this.isPasswordInput() ? this.computePasswordDigest(this.input.value) : this.input.value;
|
|
1359
1530
|
this.syncInitialValue();
|
|
1360
1531
|
this.runAuditWarning(this.options.audit);
|
|
1361
1532
|
}
|
|
1362
1533
|
getSpecificAuditWarnings() {
|
|
1363
1534
|
const warnings = [];
|
|
1364
|
-
const
|
|
1535
|
+
const describedbyWarnings = [];
|
|
1536
|
+
const hasValidDescribedby = this.checkAriaIdReferences(this.input, "aria-describedby", describedbyWarnings);
|
|
1365
1537
|
const hasPlaceholder = Boolean(this.input.getAttribute("placeholder")?.trim());
|
|
1366
1538
|
const hasAriaPlaceholder = Boolean(this.input.getAttribute("aria-placeholder")?.trim());
|
|
1367
|
-
if (!
|
|
1539
|
+
if (!hasValidDescribedby && !hasPlaceholder && !hasAriaPlaceholder && !this.options.disabled) {
|
|
1368
1540
|
warnings.push(
|
|
1369
1541
|
"Indication du format attendu manquante : d\xE9finissez aria-describedby, placeholder ou aria-placeholder pour informer les technologies d'assistance (WCAG 3.3.2)."
|
|
1370
1542
|
);
|
|
@@ -1376,6 +1548,11 @@ var InputMask = class extends BaseInputMask {
|
|
|
1376
1548
|
}
|
|
1377
1549
|
onPasswordModeDetected() {
|
|
1378
1550
|
this.history.clear();
|
|
1551
|
+
this.lastValue = "";
|
|
1552
|
+
this.lastInternalRemainingMask = "";
|
|
1553
|
+
this.lastTrackedValue = "";
|
|
1554
|
+
this.clearGhost();
|
|
1555
|
+
this.wrapper.removeAttribute("data-mask");
|
|
1379
1556
|
}
|
|
1380
1557
|
/**
|
|
1381
1558
|
* Formate statiquement une valeur selon un masque donné sans nécessiter d'élément DOM.
|
|
@@ -1399,11 +1576,12 @@ var InputMask = class extends BaseInputMask {
|
|
|
1399
1576
|
if (disabled) {
|
|
1400
1577
|
this.wrapper.removeAttribute("data-mask");
|
|
1401
1578
|
this.wrapper.classList.remove("is-complete", "has-selection");
|
|
1402
|
-
|
|
1579
|
+
this.clearGhost();
|
|
1403
1580
|
this.checkValueChange();
|
|
1404
1581
|
} else {
|
|
1405
1582
|
this.applyMask(this.input.value, this.input.selectionStart ?? this.input.value.length);
|
|
1406
1583
|
}
|
|
1584
|
+
this.syncInferredInputMode();
|
|
1407
1585
|
}
|
|
1408
1586
|
/**
|
|
1409
1587
|
* Associe les écouteurs d'événements nécessaires.
|
|
@@ -1440,22 +1618,23 @@ var InputMask = class extends BaseInputMask {
|
|
|
1440
1618
|
if (this.isDestroyed) return;
|
|
1441
1619
|
this.checkValueChange();
|
|
1442
1620
|
};
|
|
1443
|
-
|
|
1444
|
-
this.input.addEventListener("
|
|
1445
|
-
this.input.addEventListener("
|
|
1446
|
-
this.input.addEventListener("
|
|
1447
|
-
this.input.addEventListener("
|
|
1448
|
-
this.input.addEventListener("
|
|
1449
|
-
this.input.addEventListener("
|
|
1450
|
-
this.input.addEventListener("
|
|
1451
|
-
this.input.addEventListener("
|
|
1452
|
-
this.input.addEventListener("
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
this.input.addEventListener("
|
|
1456
|
-
this.input.addEventListener("
|
|
1457
|
-
this.input.addEventListener("
|
|
1458
|
-
this.input.addEventListener("
|
|
1621
|
+
const { signal } = this.abortController;
|
|
1622
|
+
this.input.addEventListener("beforeinput", this.onBeforeInput, { signal });
|
|
1623
|
+
this.input.addEventListener("input", this.handleInput, { signal });
|
|
1624
|
+
this.input.addEventListener("keydown", this.onKeyDown, { signal });
|
|
1625
|
+
this.input.addEventListener("paste", this.onPaste, { signal });
|
|
1626
|
+
this.input.addEventListener("focus", this.onFocus, { signal });
|
|
1627
|
+
this.input.addEventListener("blur", this.onBlur, { signal });
|
|
1628
|
+
this.input.addEventListener("click", this.onClick, { signal });
|
|
1629
|
+
this.input.addEventListener("keyup", this.onKeyUp, { signal });
|
|
1630
|
+
this.input.addEventListener("select", this.onSelect, { signal });
|
|
1631
|
+
this.input.addEventListener("mousedown", this.onMouseDown, { signal });
|
|
1632
|
+
window.addEventListener("mouseup", this.onMouseUp, { signal });
|
|
1633
|
+
this.input.addEventListener("compositionstart", this.onCompositionStart, { signal });
|
|
1634
|
+
this.input.addEventListener("compositionend", this.onCompositionEnd, { signal });
|
|
1635
|
+
this.input.addEventListener("scroll", this.onScroll, { passive: true, signal });
|
|
1636
|
+
this.input.addEventListener("cut", this.onCutHandler, { signal });
|
|
1637
|
+
this.input.addEventListener("change", this.onChangeNativeHandler, { signal });
|
|
1459
1638
|
if (this.input.form) {
|
|
1460
1639
|
this.onFormResetHandler = () => {
|
|
1461
1640
|
if (this.resetTimerId !== null) clearTimeout(this.resetTimerId);
|
|
@@ -1469,7 +1648,7 @@ var InputMask = class extends BaseInputMask {
|
|
|
1469
1648
|
}
|
|
1470
1649
|
}, 0);
|
|
1471
1650
|
};
|
|
1472
|
-
this.input.form.addEventListener("reset", this.onFormResetHandler);
|
|
1651
|
+
this.input.form.addEventListener("reset", this.onFormResetHandler, { signal });
|
|
1473
1652
|
}
|
|
1474
1653
|
}
|
|
1475
1654
|
/**
|
|
@@ -1506,29 +1685,12 @@ var InputMask = class extends BaseInputMask {
|
|
|
1506
1685
|
clearTimeout(this.resetTimerId);
|
|
1507
1686
|
this.resetTimerId = null;
|
|
1508
1687
|
}
|
|
1509
|
-
this.input.removeEventListener("beforeinput", this.onBeforeInput);
|
|
1510
|
-
this.input.removeEventListener("input", this.handleInput);
|
|
1511
|
-
this.input.removeEventListener("keydown", this.onKeyDown);
|
|
1512
|
-
this.input.removeEventListener("paste", this.onPaste);
|
|
1513
|
-
this.input.removeEventListener("focus", this.onFocus);
|
|
1514
|
-
this.input.removeEventListener("blur", this.onBlur);
|
|
1515
|
-
this.input.removeEventListener("click", this.onClick);
|
|
1516
|
-
this.input.removeEventListener("keyup", this.onKeyUp);
|
|
1517
|
-
this.input.removeEventListener("select", this.onSelect);
|
|
1518
|
-
this.input.removeEventListener("mousedown", this.onMouseDown);
|
|
1519
|
-
window.removeEventListener("mouseup", this.onMouseUp);
|
|
1520
|
-
this.input.removeEventListener("compositionstart", this.onCompositionStart);
|
|
1521
|
-
this.input.removeEventListener("compositionend", this.onCompositionEnd);
|
|
1522
|
-
this.input.removeEventListener("scroll", this.onScroll);
|
|
1523
|
-
this.input.removeEventListener("cut", this.onCutHandler);
|
|
1524
|
-
this.input.removeEventListener("change", this.onChangeNativeHandler);
|
|
1525
|
-
if (this.input.form && this.onFormResetHandler) {
|
|
1526
|
-
this.input.form.removeEventListener("reset", this.onFormResetHandler);
|
|
1527
|
-
}
|
|
1528
1688
|
if (this.wasInputModeInferred && this.input.getAttribute("inputmode") === "numeric") {
|
|
1529
1689
|
this.input.removeAttribute("inputmode");
|
|
1530
1690
|
}
|
|
1531
1691
|
this.history.clear();
|
|
1692
|
+
this.lastValue = "";
|
|
1693
|
+
this.lastInternalRemainingMask = "";
|
|
1532
1694
|
super.destroy();
|
|
1533
1695
|
}
|
|
1534
1696
|
/**
|
|
@@ -1602,6 +1764,7 @@ var InputMask = class extends BaseInputMask {
|
|
|
1602
1764
|
this.setStrict(strictVal !== "false");
|
|
1603
1765
|
} else if (attrName === "data-mask-auto-lowercase") {
|
|
1604
1766
|
this.options.autoLowercase = this.getAttr("data-mask-auto-lowercase") === "true";
|
|
1767
|
+
this.engine.setAutoLowercase(this.options.autoLowercase);
|
|
1605
1768
|
this.engine.compile(this.options.mask || "");
|
|
1606
1769
|
this.applyMask(this.input.value, this.input.selectionStart ?? this.input.value.length);
|
|
1607
1770
|
} else if (attrName === "placeholder") {
|
|
@@ -1681,7 +1844,7 @@ var InputMask = class extends BaseInputMask {
|
|
|
1681
1844
|
if (this.options.disabled) return;
|
|
1682
1845
|
if (this.isComposing) return;
|
|
1683
1846
|
if (!this.engine.isStrict()) return;
|
|
1684
|
-
if (e.inputType === "insertFromPaste") return;
|
|
1847
|
+
if (e.inputType === "insertFromPaste" || e.inputType === "insertReplacementText") return;
|
|
1685
1848
|
if (e.inputType && e.inputType.startsWith("insert")) {
|
|
1686
1849
|
const totalSlots = this.engine.getEditableCount();
|
|
1687
1850
|
if (totalSlots > 0) {
|
|
@@ -1703,7 +1866,8 @@ var InputMask = class extends BaseInputMask {
|
|
|
1703
1866
|
if (this.isDispatchingNativeInput) return;
|
|
1704
1867
|
if (this.isComposing) return;
|
|
1705
1868
|
const hasOnInput = Boolean(this.options.onInput || this.options.oninput);
|
|
1706
|
-
|
|
1869
|
+
const currentComparison = this.isPasswordInput() ? this.computePasswordDigest(this.input.value) : this.input.value;
|
|
1870
|
+
if (hasOnInput && currentComparison !== this.lastValue) {
|
|
1707
1871
|
this.checkValueChange();
|
|
1708
1872
|
}
|
|
1709
1873
|
if (this.options.disabled) {
|
|
@@ -1797,8 +1961,14 @@ var InputMask = class extends BaseInputMask {
|
|
|
1797
1961
|
}
|
|
1798
1962
|
onBlur() {
|
|
1799
1963
|
this.wrapper.classList.remove("is-focused", "has-selection");
|
|
1800
|
-
if (this.
|
|
1964
|
+
if (this.isPasswordInput()) {
|
|
1801
1965
|
this.history.clear();
|
|
1966
|
+
this.lastValue = "";
|
|
1967
|
+
this.lastInternalRemainingMask = "";
|
|
1968
|
+
this.lastTrackedValue = "";
|
|
1969
|
+
this.clearGhost();
|
|
1970
|
+
this.wrapper.removeAttribute("data-mask");
|
|
1971
|
+
return;
|
|
1802
1972
|
}
|
|
1803
1973
|
this.updateGhost(this.input.value);
|
|
1804
1974
|
}
|
|
@@ -1852,26 +2022,25 @@ var InputMask = class extends BaseInputMask {
|
|
|
1852
2022
|
// ==========================================================================
|
|
1853
2023
|
updateGhost(formatted) {
|
|
1854
2024
|
if (!this.ghost) return;
|
|
1855
|
-
if (this.options.disabled) {
|
|
1856
|
-
this.
|
|
2025
|
+
if (this.options.disabled || this.isPasswordInput()) {
|
|
2026
|
+
this.clearGhost();
|
|
1857
2027
|
return;
|
|
1858
2028
|
}
|
|
1859
2029
|
const isCleanEmpty = !formatted || formatted === this.engine.getPrefix();
|
|
1860
2030
|
if (this.shouldHideGhostForPlaceholder(isCleanEmpty)) {
|
|
1861
|
-
this.
|
|
2031
|
+
this.clearGhost();
|
|
1862
2032
|
return;
|
|
1863
2033
|
}
|
|
1864
2034
|
const fullTemplate = this.engine.getFullMaskTemplate();
|
|
1865
2035
|
const rest = fullTemplate.length > formatted.length ? fullTemplate.substring(formatted.length) : "";
|
|
1866
|
-
this.
|
|
1867
|
-
const spanTyped =
|
|
2036
|
+
const doc = this.input.ownerDocument || document;
|
|
2037
|
+
const spanTyped = doc.createElement("span");
|
|
1868
2038
|
spanTyped.className = "mask-ghost-typed";
|
|
1869
2039
|
spanTyped.textContent = formatted;
|
|
1870
|
-
const spanRemaining =
|
|
2040
|
+
const spanRemaining = doc.createElement("span");
|
|
1871
2041
|
spanRemaining.className = "mask-ghost-remaining";
|
|
1872
2042
|
spanRemaining.textContent = rest;
|
|
1873
|
-
this.
|
|
1874
|
-
this.ghost.appendChild(spanRemaining);
|
|
2043
|
+
this.setGhostContent(spanTyped, spanRemaining);
|
|
1875
2044
|
this.ghost.scrollLeft = this.input.scrollLeft;
|
|
1876
2045
|
}
|
|
1877
2046
|
applyMask(rawOrPartial, cursorPosition, forceExactCursor = false) {
|
|
@@ -1882,10 +2051,17 @@ var InputMask = class extends BaseInputMask {
|
|
|
1882
2051
|
try {
|
|
1883
2052
|
formatted = this.engine.format(rawOrPartial);
|
|
1884
2053
|
const remainingMask = this.engine.getRemainingMask(formatted);
|
|
2054
|
+
const isPwd = this.isPasswordInput();
|
|
1885
2055
|
this.input.value = formatted;
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
2056
|
+
if (isPwd) {
|
|
2057
|
+
this.lastInternalRemainingMask = "";
|
|
2058
|
+
this.wrapper.removeAttribute("data-mask");
|
|
2059
|
+
this.clearGhost();
|
|
2060
|
+
} else {
|
|
2061
|
+
this.lastInternalRemainingMask = remainingMask;
|
|
2062
|
+
this.wrapper.setAttribute("data-mask", remainingMask);
|
|
2063
|
+
this.updateGhost(formatted);
|
|
2064
|
+
}
|
|
1889
2065
|
const minPos = this.engine.getPrefixLength();
|
|
1890
2066
|
let safeCursor;
|
|
1891
2067
|
if (forceExactCursor || this.isUndoingRedoing) {
|
|
@@ -1897,7 +2073,7 @@ var InputMask = class extends BaseInputMask {
|
|
|
1897
2073
|
this.input.setSelectionRange(safeCursor, safeCursor);
|
|
1898
2074
|
isCompleted = this.isComplete();
|
|
1899
2075
|
this.wrapper.classList.toggle("is-complete", isCompleted);
|
|
1900
|
-
if (
|
|
2076
|
+
if (isPwd) {
|
|
1901
2077
|
this.options.copyRaw = false;
|
|
1902
2078
|
this.history.clear();
|
|
1903
2079
|
} else if (!this.isUndoingRedoing) {
|
|
@@ -1909,10 +2085,11 @@ var InputMask = class extends BaseInputMask {
|
|
|
1909
2085
|
this.checkValueChange();
|
|
1910
2086
|
}
|
|
1911
2087
|
syncInitialValue() {
|
|
2088
|
+
const isPwd = this.isPasswordInput();
|
|
1912
2089
|
if (this.options.disabled) {
|
|
1913
2090
|
this.wrapper.removeAttribute("data-mask");
|
|
1914
|
-
|
|
1915
|
-
this.lastValue = this.input.value;
|
|
2091
|
+
this.clearGhost();
|
|
2092
|
+
this.lastValue = isPwd ? this.computePasswordDigest(this.input.value) : this.input.value;
|
|
1916
2093
|
this.checkValueChange();
|
|
1917
2094
|
return;
|
|
1918
2095
|
}
|
|
@@ -1925,13 +2102,17 @@ var InputMask = class extends BaseInputMask {
|
|
|
1925
2102
|
if (minPos > 0) {
|
|
1926
2103
|
this.applyMask("", minPos);
|
|
1927
2104
|
} else {
|
|
1928
|
-
if (
|
|
2105
|
+
if (!isPwd) {
|
|
1929
2106
|
this.history.push("", 0);
|
|
2107
|
+
const fullTemplate = this.engine.getFullMaskTemplate();
|
|
2108
|
+
this.lastInternalRemainingMask = fullTemplate;
|
|
2109
|
+
this.wrapper.setAttribute("data-mask", fullTemplate);
|
|
2110
|
+
this.updateGhost("");
|
|
2111
|
+
} else {
|
|
2112
|
+
this.lastInternalRemainingMask = "";
|
|
2113
|
+
this.wrapper.removeAttribute("data-mask");
|
|
2114
|
+
this.clearGhost();
|
|
1930
2115
|
}
|
|
1931
|
-
const fullTemplate = this.engine.getFullMaskTemplate();
|
|
1932
|
-
this.lastInternalRemainingMask = fullTemplate;
|
|
1933
|
-
this.wrapper.setAttribute("data-mask", fullTemplate);
|
|
1934
|
-
this.updateGhost("");
|
|
1935
2116
|
this.checkValueChange();
|
|
1936
2117
|
}
|
|
1937
2118
|
}
|
|
@@ -1941,8 +2122,10 @@ var InputMask = class extends BaseInputMask {
|
|
|
1941
2122
|
* Gère de manière sûre la réentrance pour permettre d'appeler setMask() directement dans le callback.
|
|
1942
2123
|
*/
|
|
1943
2124
|
checkValueChange(forceNotify = false) {
|
|
2125
|
+
const isPwd = this.isPasswordInput();
|
|
1944
2126
|
const currentVal = this.input.value;
|
|
1945
|
-
|
|
2127
|
+
const currentComparison = isPwd ? this.computePasswordDigest(currentVal) : currentVal;
|
|
2128
|
+
if (currentComparison === this.lastValue && !forceNotify && !this.hasPendingNotification) {
|
|
1946
2129
|
return;
|
|
1947
2130
|
}
|
|
1948
2131
|
if (this.isNotifying) {
|
|
@@ -1953,12 +2136,12 @@ var InputMask = class extends BaseInputMask {
|
|
|
1953
2136
|
try {
|
|
1954
2137
|
let iterations = 0;
|
|
1955
2138
|
const MAX_NOTIFICATION_ITERATIONS = 10;
|
|
1956
|
-
while ((this.input.value !== this.lastValue || this.hasPendingNotification || forceNotify) && iterations < MAX_NOTIFICATION_ITERATIONS) {
|
|
2139
|
+
while (((isPwd ? this.computePasswordDigest(this.input.value) : this.input.value) !== this.lastValue || this.hasPendingNotification || forceNotify) && iterations < MAX_NOTIFICATION_ITERATIONS) {
|
|
1957
2140
|
iterations++;
|
|
1958
2141
|
this.hasPendingNotification = false;
|
|
1959
2142
|
forceNotify = false;
|
|
1960
2143
|
const valToNotify = this.input.value;
|
|
1961
|
-
this.lastValue = valToNotify;
|
|
2144
|
+
this.lastValue = isPwd ? this.computePasswordDigest(valToNotify) : valToNotify;
|
|
1962
2145
|
const raw = this.options.disabled ? valToNotify : this.getRawValue();
|
|
1963
2146
|
const totalSlots = this.options.disabled ? 0 : this.engine.getEditableCount();
|
|
1964
2147
|
const isComplete = this.isComplete();
|
|
@@ -1996,6 +2179,7 @@ var InputMask = class extends BaseInputMask {
|
|
|
1996
2179
|
|
|
1997
2180
|
// src/mask/AmountEngine.ts
|
|
1998
2181
|
var AmountEngine = class _AmountEngine {
|
|
2182
|
+
options;
|
|
1999
2183
|
constructor(options = {}) {
|
|
2000
2184
|
let currency = options.currency ?? "";
|
|
2001
2185
|
if (!currency && options.unit) {
|
|
@@ -2208,6 +2392,16 @@ var AmountEngine = class _AmountEngine {
|
|
|
2208
2392
|
|
|
2209
2393
|
// src/mask/InputAmountMask.ts
|
|
2210
2394
|
var InputAmountMask = class extends BaseInputMask {
|
|
2395
|
+
engine;
|
|
2396
|
+
history;
|
|
2397
|
+
isUndoingRedoing = false;
|
|
2398
|
+
isApplying = false;
|
|
2399
|
+
isComposing = false;
|
|
2400
|
+
lastValue = "";
|
|
2401
|
+
wasInputModeInferred = false;
|
|
2402
|
+
cutTimerId = null;
|
|
2403
|
+
resetTimerId = null;
|
|
2404
|
+
cursorTimerId = null;
|
|
2211
2405
|
constructor(targetOrWrapper, inputOrOptions, options) {
|
|
2212
2406
|
const args = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, options);
|
|
2213
2407
|
const wrap = args.wrapper;
|
|
@@ -2221,13 +2415,10 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2221
2415
|
...opts
|
|
2222
2416
|
};
|
|
2223
2417
|
super(wrap, inp, resolvedOptions);
|
|
2224
|
-
this.
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
this.cutTimerId = null;
|
|
2229
|
-
this.resetTimerId = null;
|
|
2230
|
-
this.input.inputMode = "decimal";
|
|
2418
|
+
if (!this.input.hasAttribute("inputmode")) {
|
|
2419
|
+
this.input.inputMode = "decimal";
|
|
2420
|
+
this.wasInputModeInferred = true;
|
|
2421
|
+
}
|
|
2231
2422
|
this.history = new MaskHistory();
|
|
2232
2423
|
this.engine = new AmountEngine(this.options);
|
|
2233
2424
|
this.bindEvents();
|
|
@@ -2253,6 +2444,9 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2253
2444
|
}
|
|
2254
2445
|
onPasswordModeDetected() {
|
|
2255
2446
|
this.history.clear();
|
|
2447
|
+
this.lastValue = "";
|
|
2448
|
+
this.lastTrackedValue = "";
|
|
2449
|
+
this.clearGhost();
|
|
2256
2450
|
}
|
|
2257
2451
|
/**
|
|
2258
2452
|
* Formate statiquement une valeur sans nécessiter d'élément DOM.
|
|
@@ -2268,7 +2462,9 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2268
2462
|
this.applyAmount(strVal, strVal.length);
|
|
2269
2463
|
}
|
|
2270
2464
|
onDisabledChange(disabled) {
|
|
2271
|
-
if (
|
|
2465
|
+
if (disabled) {
|
|
2466
|
+
this.clearGhost();
|
|
2467
|
+
} else {
|
|
2272
2468
|
this.applyAmount(this.input.value, this.input.selectionStart ?? this.input.value.length);
|
|
2273
2469
|
}
|
|
2274
2470
|
}
|
|
@@ -2291,15 +2487,16 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2291
2487
|
this.applyAmount(this.input.value, cur);
|
|
2292
2488
|
}, 0);
|
|
2293
2489
|
};
|
|
2294
|
-
|
|
2295
|
-
this.input.addEventListener("
|
|
2296
|
-
this.input.addEventListener("
|
|
2297
|
-
this.input.addEventListener("
|
|
2298
|
-
this.input.addEventListener("
|
|
2299
|
-
this.input.addEventListener("
|
|
2300
|
-
this.input.addEventListener("
|
|
2301
|
-
this.input.addEventListener("
|
|
2302
|
-
this.input.addEventListener("
|
|
2490
|
+
const { signal } = this.abortController;
|
|
2491
|
+
this.input.addEventListener("input", this.handleInput, { signal });
|
|
2492
|
+
this.input.addEventListener("keydown", this.handleKeyDown, { signal });
|
|
2493
|
+
this.input.addEventListener("blur", this.handleBlur, { signal });
|
|
2494
|
+
this.input.addEventListener("focus", this.handleFocus, { signal });
|
|
2495
|
+
this.input.addEventListener("click", this.handleClick, { signal });
|
|
2496
|
+
this.input.addEventListener("scroll", this.onScroll, { passive: true, signal });
|
|
2497
|
+
this.input.addEventListener("cut", this.onCutHandler, { signal });
|
|
2498
|
+
this.input.addEventListener("compositionstart", this.onCompositionStart, { signal });
|
|
2499
|
+
this.input.addEventListener("compositionend", this.onCompositionEnd, { signal });
|
|
2303
2500
|
if (this.input.form) {
|
|
2304
2501
|
this.onFormResetHandler = () => {
|
|
2305
2502
|
if (this.resetTimerId !== null) {
|
|
@@ -2312,7 +2509,7 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2312
2509
|
this.applyAmount(this.input.value, this.input.value.length);
|
|
2313
2510
|
}, 0);
|
|
2314
2511
|
};
|
|
2315
|
-
this.input.form.addEventListener("reset", this.onFormResetHandler);
|
|
2512
|
+
this.input.form.addEventListener("reset", this.onFormResetHandler, { signal });
|
|
2316
2513
|
}
|
|
2317
2514
|
}
|
|
2318
2515
|
onCompositionStart() {
|
|
@@ -2331,15 +2528,20 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2331
2528
|
const result = this.engine.format(val, cursor);
|
|
2332
2529
|
this.setNativeValue(result.formatted);
|
|
2333
2530
|
this.input.setSelectionRange(result.cursor, result.cursor);
|
|
2334
|
-
|
|
2531
|
+
const isPwd = this.isPasswordInput();
|
|
2532
|
+
if (isPwd) {
|
|
2335
2533
|
this.options.copyRaw = false;
|
|
2336
2534
|
this.history.clear();
|
|
2337
|
-
|
|
2338
|
-
|
|
2535
|
+
this.clearGhost();
|
|
2536
|
+
} else {
|
|
2537
|
+
if (!this.isUndoingRedoing) {
|
|
2538
|
+
this.history.push(result.rawValue, result.cursor);
|
|
2539
|
+
}
|
|
2540
|
+
this.updateGhost(result);
|
|
2339
2541
|
}
|
|
2340
|
-
this.
|
|
2341
|
-
if (this.lastValue !==
|
|
2342
|
-
this.lastValue =
|
|
2542
|
+
const nextComparison = isPwd ? this.computePasswordDigest(result.formatted) : result.formatted;
|
|
2543
|
+
if (this.lastValue !== nextComparison) {
|
|
2544
|
+
this.lastValue = nextComparison;
|
|
2343
2545
|
this.notifyChange(result);
|
|
2344
2546
|
}
|
|
2345
2547
|
} finally {
|
|
@@ -2350,18 +2552,18 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2350
2552
|
if (!this.ghost) return;
|
|
2351
2553
|
if (!result.formatted) {
|
|
2352
2554
|
if (this.shouldHideGhostForPlaceholder(true)) {
|
|
2353
|
-
this.
|
|
2555
|
+
this.clearGhost();
|
|
2354
2556
|
return;
|
|
2355
2557
|
}
|
|
2356
2558
|
const hint = this.options.currency ? this.options.currencyPosition === "prefix" ? `${this.options.currency} 0` : `0 ${this.options.currency}` : "0,00";
|
|
2357
|
-
this.
|
|
2358
|
-
const span =
|
|
2559
|
+
const doc = this.input.ownerDocument || document;
|
|
2560
|
+
const span = doc.createElement("span");
|
|
2359
2561
|
span.className = "mask-ghost-remaining";
|
|
2360
2562
|
span.textContent = hint;
|
|
2361
|
-
this.
|
|
2563
|
+
this.setGhostContent(span);
|
|
2362
2564
|
return;
|
|
2363
2565
|
}
|
|
2364
|
-
this.
|
|
2566
|
+
this.clearGhost();
|
|
2365
2567
|
this.ghost.scrollLeft = this.input.scrollLeft;
|
|
2366
2568
|
}
|
|
2367
2569
|
handleInput() {
|
|
@@ -2372,7 +2574,7 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2372
2574
|
this.applyAmount(rawVal, cur);
|
|
2373
2575
|
}
|
|
2374
2576
|
handleKeyDown(e) {
|
|
2375
|
-
if (this.options.disabled) return;
|
|
2577
|
+
if (this.options.disabled || isImeComposing(e)) return;
|
|
2376
2578
|
if ((e.ctrlKey || e.metaKey) && (e.key === "z" || e.key === "Z")) {
|
|
2377
2579
|
e.preventDefault();
|
|
2378
2580
|
if (e.shiftKey) this.redo();
|
|
@@ -2424,10 +2626,18 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2424
2626
|
}
|
|
2425
2627
|
}
|
|
2426
2628
|
}
|
|
2427
|
-
|
|
2629
|
+
if (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Home" || e.key === "End") {
|
|
2630
|
+
if (this.cursorTimerId !== null) {
|
|
2631
|
+
clearTimeout(this.cursorTimerId);
|
|
2632
|
+
}
|
|
2633
|
+
this.cursorTimerId = window.setTimeout(() => {
|
|
2634
|
+
this.cursorTimerId = null;
|
|
2635
|
+
this.enforceCursorBounds();
|
|
2636
|
+
}, 0);
|
|
2637
|
+
}
|
|
2428
2638
|
}
|
|
2429
2639
|
enforceCursorBounds() {
|
|
2430
|
-
if (!this.input.value || this.options.disabled) return;
|
|
2640
|
+
if (this.isDestroyed || !this.isFocused || document.activeElement !== this.input || !this.input.value || this.options.disabled) return;
|
|
2431
2641
|
const start = this.input.selectionStart ?? 0;
|
|
2432
2642
|
const end = this.input.selectionEnd ?? 0;
|
|
2433
2643
|
if (start !== end) return;
|
|
@@ -2458,8 +2668,12 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2458
2668
|
}
|
|
2459
2669
|
handleBlur() {
|
|
2460
2670
|
this.wrapper.classList.remove("is-focused");
|
|
2461
|
-
if (this.
|
|
2671
|
+
if (this.isPasswordInput()) {
|
|
2462
2672
|
this.history.clear();
|
|
2673
|
+
this.lastValue = "";
|
|
2674
|
+
this.lastTrackedValue = "";
|
|
2675
|
+
this.clearGhost();
|
|
2676
|
+
return;
|
|
2463
2677
|
}
|
|
2464
2678
|
if (this.options.padDecimalsOnBlur && !this.options.disabled && this.input.value.trim().length > 0) {
|
|
2465
2679
|
const paddedResult = this.engine.format(this.input.value, this.input.value.length, true);
|
|
@@ -2555,30 +2769,62 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2555
2769
|
clearTimeout(this.resetTimerId);
|
|
2556
2770
|
this.resetTimerId = null;
|
|
2557
2771
|
}
|
|
2558
|
-
this.
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
this.input.
|
|
2563
|
-
|
|
2564
|
-
this.input.removeEventListener("cut", this.onCutHandler);
|
|
2565
|
-
this.input.removeEventListener("compositionstart", this.onCompositionStart);
|
|
2566
|
-
this.input.removeEventListener("compositionend", this.onCompositionEnd);
|
|
2567
|
-
if (this.input.form && this.onFormResetHandler) {
|
|
2568
|
-
this.input.form.removeEventListener("reset", this.onFormResetHandler);
|
|
2772
|
+
if (this.cursorTimerId !== null) {
|
|
2773
|
+
clearTimeout(this.cursorTimerId);
|
|
2774
|
+
this.cursorTimerId = null;
|
|
2775
|
+
}
|
|
2776
|
+
if (this.wasInputModeInferred && this.input.getAttribute("inputmode") === "decimal") {
|
|
2777
|
+
this.input.removeAttribute("inputmode");
|
|
2569
2778
|
}
|
|
2779
|
+
this.lastValue = "";
|
|
2570
2780
|
this.history.clear();
|
|
2571
2781
|
super.destroy();
|
|
2572
2782
|
}
|
|
2573
2783
|
};
|
|
2574
2784
|
|
|
2575
2785
|
// src/mask/EmailEngine.ts
|
|
2576
|
-
var
|
|
2786
|
+
var EmailEngine = class _EmailEngine {
|
|
2787
|
+
domains;
|
|
2788
|
+
tlds;
|
|
2789
|
+
suggestOnAt;
|
|
2790
|
+
defaultDomain = null;
|
|
2791
|
+
defaultTld = "__";
|
|
2792
|
+
static DEFAULT_DOMAINS = [
|
|
2793
|
+
"gmail.com",
|
|
2794
|
+
"outlook.com",
|
|
2795
|
+
"orange.fr",
|
|
2796
|
+
"free.fr",
|
|
2797
|
+
"sfr.fr",
|
|
2798
|
+
"yahoo.com",
|
|
2799
|
+
"hotmail.com",
|
|
2800
|
+
"icloud.com",
|
|
2801
|
+
"laposte.net",
|
|
2802
|
+
"proton.me"
|
|
2803
|
+
];
|
|
2804
|
+
static DEFAULT_TLDS = [
|
|
2805
|
+
"com",
|
|
2806
|
+
"fr",
|
|
2807
|
+
"net",
|
|
2808
|
+
"org",
|
|
2809
|
+
"eu",
|
|
2810
|
+
"io",
|
|
2811
|
+
"co",
|
|
2812
|
+
"info",
|
|
2813
|
+
"biz",
|
|
2814
|
+
"me",
|
|
2815
|
+
"tv",
|
|
2816
|
+
"fi",
|
|
2817
|
+
"be",
|
|
2818
|
+
"ch",
|
|
2819
|
+
"ca",
|
|
2820
|
+
"uk",
|
|
2821
|
+
"de",
|
|
2822
|
+
"es",
|
|
2823
|
+
"it"
|
|
2824
|
+
];
|
|
2577
2825
|
constructor(options = {}) {
|
|
2578
|
-
this.defaultDomain = null;
|
|
2579
|
-
this.defaultTld = "__";
|
|
2580
2826
|
this.domains = options.domains && options.domains.length > 0 ? options.domains : _EmailEngine.DEFAULT_DOMAINS;
|
|
2581
|
-
this.tlds = options.tlds && options.tlds.length > 0 ? options.tlds.map((t) => t.trim().replace(/^\./, "")).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
|
|
2827
|
+
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];
|
|
2582
2828
|
this.suggestOnAt = options.suggestOnAt ?? true;
|
|
2583
2829
|
this.setDefaultDomain(options.defaultDomain ?? null);
|
|
2584
2830
|
this.setDefaultTld(options.defaultTld !== void 0 ? options.defaultTld : "__");
|
|
@@ -2611,7 +2857,7 @@ var _EmailEngine = class _EmailEngine {
|
|
|
2611
2857
|
* Définit ou modifie la liste des extensions (TLD) proposées par ordre de priorité.
|
|
2612
2858
|
*/
|
|
2613
2859
|
setTlds(tlds) {
|
|
2614
|
-
this.tlds = tlds && tlds.length > 0 ? tlds.map((t) => t.trim().replace(/^\./, "")).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
|
|
2860
|
+
this.tlds = tlds && tlds.length > 0 ? tlds.slice(0, 200).map((t) => String(t).trim().replace(/^\./, "").slice(0, 32)).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
|
|
2615
2861
|
}
|
|
2616
2862
|
/**
|
|
2617
2863
|
* Retourne l'ensemble des extensions (TLD) correspondant au fragment saisi après le dernier point,
|
|
@@ -2682,22 +2928,22 @@ var _EmailEngine = class _EmailEngine {
|
|
|
2682
2928
|
};
|
|
2683
2929
|
}
|
|
2684
2930
|
if (domainPart.length === 0 || domainPart.startsWith(".")) {
|
|
2685
|
-
return { full:
|
|
2931
|
+
return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2686
2932
|
}
|
|
2687
2933
|
const lowerDomain = domainPart.toLowerCase();
|
|
2688
2934
|
if (this.domains.some((d) => d.toLowerCase() === lowerDomain)) {
|
|
2689
|
-
return { full:
|
|
2935
|
+
return { full: val, remaining: "", matchedDomain: domainPart, isHintOnly: false };
|
|
2690
2936
|
}
|
|
2691
2937
|
const lastDotIndex = domainPart.lastIndexOf(".");
|
|
2692
2938
|
if (lastDotIndex === -1) {
|
|
2693
2939
|
if (!this.defaultTld) {
|
|
2694
|
-
return { full:
|
|
2940
|
+
return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2695
2941
|
}
|
|
2696
2942
|
const isHint = this.defaultTld.includes("_");
|
|
2697
2943
|
const remaining = `.${this.defaultTld}`;
|
|
2698
2944
|
const fullDomain = `${domainPart}.${this.defaultTld}`;
|
|
2699
2945
|
return {
|
|
2700
|
-
full: isHint ?
|
|
2946
|
+
full: isHint ? val : `${localPart}@${fullDomain}`,
|
|
2701
2947
|
remaining,
|
|
2702
2948
|
matchedDomain: isHint ? null : fullDomain,
|
|
2703
2949
|
isHintOnly: isHint
|
|
@@ -2706,7 +2952,7 @@ var _EmailEngine = class _EmailEngine {
|
|
|
2706
2952
|
const hostPart = domainPart.substring(0, lastDotIndex);
|
|
2707
2953
|
const tldPart = domainPart.substring(lastDotIndex + 1);
|
|
2708
2954
|
if (!hostPart || hostPart.endsWith(".")) {
|
|
2709
|
-
return { full:
|
|
2955
|
+
return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2710
2956
|
}
|
|
2711
2957
|
if (tldPart.length === 0) {
|
|
2712
2958
|
if (this.defaultTld && !this.defaultTld.includes("_")) {
|
|
@@ -2720,15 +2966,18 @@ var _EmailEngine = class _EmailEngine {
|
|
|
2720
2966
|
}
|
|
2721
2967
|
if (this.defaultTld && this.defaultTld.includes("_")) {
|
|
2722
2968
|
return {
|
|
2723
|
-
full:
|
|
2969
|
+
full: val,
|
|
2724
2970
|
remaining: this.defaultTld,
|
|
2725
2971
|
matchedDomain: null,
|
|
2726
2972
|
isHintOnly: true
|
|
2727
2973
|
};
|
|
2728
2974
|
}
|
|
2729
|
-
return { full:
|
|
2975
|
+
return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2730
2976
|
}
|
|
2731
2977
|
const lowerTld = tldPart.toLowerCase();
|
|
2978
|
+
if (this.tlds.some((t) => t.toLowerCase() === lowerTld)) {
|
|
2979
|
+
return { full: val, remaining: "", matchedDomain: domainPart, isHintOnly: false };
|
|
2980
|
+
}
|
|
2732
2981
|
const matchingTlds = this.getMatchingTlds(tldPart);
|
|
2733
2982
|
if (matchingTlds.length > 0) {
|
|
2734
2983
|
const safeTldIndex = (matchIndex % matchingTlds.length + matchingTlds.length) % matchingTlds.length;
|
|
@@ -2746,53 +2995,34 @@ var _EmailEngine = class _EmailEngine {
|
|
|
2746
2995
|
const remaining = this.defaultTld.substring(tldPart.length);
|
|
2747
2996
|
if (remaining.includes("_")) {
|
|
2748
2997
|
return {
|
|
2749
|
-
full:
|
|
2998
|
+
full: val,
|
|
2750
2999
|
remaining,
|
|
2751
3000
|
matchedDomain: null,
|
|
2752
3001
|
isHintOnly: true
|
|
2753
3002
|
};
|
|
2754
3003
|
}
|
|
2755
3004
|
}
|
|
2756
|
-
return { full:
|
|
3005
|
+
return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2757
3006
|
}
|
|
2758
3007
|
};
|
|
2759
|
-
_EmailEngine.DEFAULT_DOMAINS = [
|
|
2760
|
-
"gmail.com",
|
|
2761
|
-
"outlook.com",
|
|
2762
|
-
"orange.fr",
|
|
2763
|
-
"free.fr",
|
|
2764
|
-
"sfr.fr",
|
|
2765
|
-
"yahoo.com",
|
|
2766
|
-
"hotmail.com",
|
|
2767
|
-
"icloud.com",
|
|
2768
|
-
"laposte.net",
|
|
2769
|
-
"proton.me"
|
|
2770
|
-
];
|
|
2771
|
-
_EmailEngine.DEFAULT_TLDS = [
|
|
2772
|
-
"com",
|
|
2773
|
-
"fr",
|
|
2774
|
-
"net",
|
|
2775
|
-
"org",
|
|
2776
|
-
"eu",
|
|
2777
|
-
"io",
|
|
2778
|
-
"co",
|
|
2779
|
-
"info",
|
|
2780
|
-
"biz",
|
|
2781
|
-
"me",
|
|
2782
|
-
"tv",
|
|
2783
|
-
"fi",
|
|
2784
|
-
"be",
|
|
2785
|
-
"ch",
|
|
2786
|
-
"ca",
|
|
2787
|
-
"uk",
|
|
2788
|
-
"de",
|
|
2789
|
-
"es",
|
|
2790
|
-
"it"
|
|
2791
|
-
];
|
|
2792
|
-
var EmailEngine = _EmailEngine;
|
|
2793
3008
|
|
|
2794
3009
|
// src/mask/InputEmailMask.ts
|
|
2795
3010
|
var InputEmailMask = class extends BaseInputMask {
|
|
3011
|
+
engine;
|
|
3012
|
+
currentSuggestion = { full: "", remaining: "", matchedDomain: null };
|
|
3013
|
+
currentSuggestionIndex = 0;
|
|
3014
|
+
wasAriaAutocompleteSet = false;
|
|
3015
|
+
wasAutocorrectSet = false;
|
|
3016
|
+
wasAutocapitalizeSet = false;
|
|
3017
|
+
wasSpellcheckSet = false;
|
|
3018
|
+
wasInputModeInferred = false;
|
|
3019
|
+
isComposing = false;
|
|
3020
|
+
lastNotifiedValue = "";
|
|
3021
|
+
srStatusEl = null;
|
|
3022
|
+
srAnnounceTimerId = null;
|
|
3023
|
+
lastAnnouncedSuggestion = "";
|
|
3024
|
+
cutTimerId = null;
|
|
3025
|
+
resetTimerId = null;
|
|
2796
3026
|
constructor(targetOrWrapper, inputOrOptions, options) {
|
|
2797
3027
|
const args = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, options);
|
|
2798
3028
|
const wrap = args.wrapper;
|
|
@@ -2818,30 +3048,55 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2818
3048
|
...resolvedDefaultTld !== void 0 ? { defaultTld: resolvedDefaultTld } : {}
|
|
2819
3049
|
};
|
|
2820
3050
|
super(wrap, inp, resolvedOptions);
|
|
2821
|
-
this.
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
this.
|
|
2826
|
-
|
|
3051
|
+
if (!this.input.hasAttribute("inputmode")) {
|
|
3052
|
+
this.input.inputMode = "email";
|
|
3053
|
+
this.wasInputModeInferred = true;
|
|
3054
|
+
}
|
|
3055
|
+
if (!this.input.hasAttribute("autocorrect")) {
|
|
3056
|
+
this.input.setAttribute("autocorrect", "off");
|
|
3057
|
+
this.wasAutocorrectSet = true;
|
|
3058
|
+
}
|
|
3059
|
+
if (!this.input.hasAttribute("autocapitalize")) {
|
|
3060
|
+
this.input.setAttribute("autocapitalize", "none");
|
|
3061
|
+
this.wasAutocapitalizeSet = true;
|
|
3062
|
+
}
|
|
3063
|
+
if (!this.input.hasAttribute("spellcheck")) {
|
|
3064
|
+
this.input.setAttribute("spellcheck", "false");
|
|
3065
|
+
this.wasSpellcheckSet = true;
|
|
3066
|
+
}
|
|
2827
3067
|
if (this.options.setAriaAutocomplete && !this.input.hasAttribute("aria-autocomplete")) {
|
|
2828
3068
|
this.input.setAttribute("aria-autocomplete", "inline");
|
|
2829
3069
|
this.wasAriaAutocompleteSet = true;
|
|
2830
3070
|
}
|
|
2831
3071
|
this.engine = new EmailEngine(this.options);
|
|
3072
|
+
this.lastNotifiedValue = this.isPasswordInput() ? "" : this.input.value;
|
|
2832
3073
|
this.bindEvents();
|
|
2833
|
-
if (!this.options.disabled) {
|
|
3074
|
+
if (!this.options.disabled && !this.isPasswordInput()) {
|
|
2834
3075
|
this.updateSuggestion();
|
|
2835
3076
|
}
|
|
2836
3077
|
this.runAuditWarning(this.options.audit);
|
|
2837
3078
|
}
|
|
3079
|
+
onPasswordModeDetected() {
|
|
3080
|
+
if (this.srAnnounceTimerId !== null) {
|
|
3081
|
+
clearTimeout(this.srAnnounceTimerId);
|
|
3082
|
+
this.srAnnounceTimerId = null;
|
|
3083
|
+
}
|
|
3084
|
+
this.lastNotifiedValue = "";
|
|
3085
|
+
this.lastTrackedValue = "";
|
|
3086
|
+
this.lastAnnouncedSuggestion = "";
|
|
3087
|
+
this.currentSuggestion = { full: "", remaining: "", matchedDomain: null };
|
|
3088
|
+
if (this.srStatusEl) {
|
|
3089
|
+
this.srStatusEl.textContent = "";
|
|
3090
|
+
}
|
|
3091
|
+
this.clearGhost();
|
|
3092
|
+
}
|
|
2838
3093
|
onNativeValueSet(_strVal) {
|
|
2839
|
-
if (this.options.disabled) return;
|
|
3094
|
+
if (this.options.disabled || this.isComposing || this.isPasswordInput()) return;
|
|
2840
3095
|
this.updateSuggestion();
|
|
2841
3096
|
}
|
|
2842
3097
|
onDisabledChange(disabled) {
|
|
2843
|
-
if (disabled) {
|
|
2844
|
-
|
|
3098
|
+
if (disabled || this.isPasswordInput()) {
|
|
3099
|
+
this.clearGhost();
|
|
2845
3100
|
} else {
|
|
2846
3101
|
this.updateSuggestion();
|
|
2847
3102
|
}
|
|
@@ -2857,16 +3112,26 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2857
3112
|
}
|
|
2858
3113
|
this.cutTimerId = window.setTimeout(() => {
|
|
2859
3114
|
this.cutTimerId = null;
|
|
2860
|
-
if (this.isDestroyed || this.options.disabled) return;
|
|
3115
|
+
if (this.isDestroyed || this.options.disabled || this.isPasswordInput()) return;
|
|
2861
3116
|
this.updateSuggestion();
|
|
2862
3117
|
}, 0);
|
|
2863
3118
|
};
|
|
2864
|
-
|
|
2865
|
-
this.input.addEventListener("
|
|
2866
|
-
this.input.addEventListener("
|
|
2867
|
-
this.input.addEventListener("
|
|
2868
|
-
this.input.addEventListener("
|
|
2869
|
-
this.input.addEventListener("
|
|
3119
|
+
const { signal } = this.abortController;
|
|
3120
|
+
this.input.addEventListener("input", this.handleInput, { signal });
|
|
3121
|
+
this.input.addEventListener("keydown", this.handleKeyDown, { signal });
|
|
3122
|
+
this.input.addEventListener("blur", this.handleBlur, { signal });
|
|
3123
|
+
this.input.addEventListener("focus", this.handleFocus, { signal });
|
|
3124
|
+
this.input.addEventListener("scroll", this.onScroll, { passive: true, signal });
|
|
3125
|
+
this.input.addEventListener("cut", this.onCutHandler, { signal });
|
|
3126
|
+
this.input.addEventListener("compositionstart", () => {
|
|
3127
|
+
this.isComposing = true;
|
|
3128
|
+
}, { signal });
|
|
3129
|
+
this.input.addEventListener("compositionend", () => {
|
|
3130
|
+
this.isComposing = false;
|
|
3131
|
+
if (!this.isDestroyed && !this.options.disabled && !this.isPasswordInput()) {
|
|
3132
|
+
this.handleInput();
|
|
3133
|
+
}
|
|
3134
|
+
}, { signal });
|
|
2870
3135
|
if (this.input.form) {
|
|
2871
3136
|
this.onFormResetHandler = () => {
|
|
2872
3137
|
if (this.resetTimerId !== null) {
|
|
@@ -2874,47 +3139,112 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2874
3139
|
}
|
|
2875
3140
|
this.resetTimerId = window.setTimeout(() => {
|
|
2876
3141
|
this.resetTimerId = null;
|
|
2877
|
-
if (this.isDestroyed || this.options.disabled) return;
|
|
3142
|
+
if (this.isDestroyed || this.options.disabled || this.isPasswordInput()) return;
|
|
2878
3143
|
this.updateSuggestion();
|
|
2879
3144
|
}, 0);
|
|
2880
3145
|
};
|
|
2881
|
-
this.input.form.addEventListener("reset", this.onFormResetHandler);
|
|
3146
|
+
this.input.form.addEventListener("reset", this.onFormResetHandler, { signal });
|
|
2882
3147
|
}
|
|
2883
3148
|
}
|
|
2884
|
-
|
|
2885
|
-
if (this.
|
|
2886
|
-
|
|
3149
|
+
ensureSrStatusEl() {
|
|
3150
|
+
if (this.srStatusEl && this.wrapper.contains(this.srStatusEl)) {
|
|
3151
|
+
return this.srStatusEl;
|
|
3152
|
+
}
|
|
3153
|
+
const doc = this.input.ownerDocument || (typeof document !== "undefined" ? document : null);
|
|
3154
|
+
if (!doc) return null;
|
|
3155
|
+
const status = doc.createElement("span");
|
|
3156
|
+
status.className = "wulf-mask-sr-status";
|
|
3157
|
+
status.setAttribute("aria-live", "polite");
|
|
3158
|
+
status.setAttribute("aria-atomic", "true");
|
|
3159
|
+
this.wrapper.appendChild(status);
|
|
3160
|
+
this.srStatusEl = status;
|
|
3161
|
+
return status;
|
|
3162
|
+
}
|
|
3163
|
+
scheduleSuggestionAnnouncement(immediate = false) {
|
|
3164
|
+
if (this.srAnnounceTimerId !== null) {
|
|
3165
|
+
clearTimeout(this.srAnnounceTimerId);
|
|
3166
|
+
this.srAnnounceTimerId = null;
|
|
3167
|
+
}
|
|
3168
|
+
if (!this.options.setAriaAutocomplete || !this.isFocused || this.isDestroyed || this.isPasswordInput()) {
|
|
3169
|
+
return;
|
|
3170
|
+
}
|
|
3171
|
+
const suggestion = this.currentSuggestion;
|
|
3172
|
+
if (!suggestion.remaining || suggestion.isHintOnly) {
|
|
3173
|
+
this.lastAnnouncedSuggestion = "";
|
|
3174
|
+
if (this.srStatusEl) {
|
|
3175
|
+
this.srStatusEl.textContent = "";
|
|
3176
|
+
}
|
|
3177
|
+
return;
|
|
3178
|
+
}
|
|
3179
|
+
const textToAnnounce = suggestion.full;
|
|
3180
|
+
if (textToAnnounce === this.lastAnnouncedSuggestion && !immediate) {
|
|
3181
|
+
return;
|
|
3182
|
+
}
|
|
3183
|
+
const run = () => {
|
|
3184
|
+
this.srAnnounceTimerId = null;
|
|
3185
|
+
if (this.isDestroyed || !this.isFocused || this.isPasswordInput()) return;
|
|
3186
|
+
this.lastAnnouncedSuggestion = textToAnnounce;
|
|
3187
|
+
const doc = this.input.ownerDocument || (typeof document !== "undefined" ? document : null);
|
|
3188
|
+
const docWithAriaNotify = doc;
|
|
3189
|
+
if (docWithAriaNotify && typeof docWithAriaNotify.ariaNotify === "function") {
|
|
3190
|
+
try {
|
|
3191
|
+
docWithAriaNotify.ariaNotify(textToAnnounce, { priority: "normal" });
|
|
3192
|
+
return;
|
|
3193
|
+
} catch {
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3196
|
+
const statusEl = this.ensureSrStatusEl();
|
|
3197
|
+
if (statusEl) {
|
|
3198
|
+
statusEl.textContent = statusEl.textContent === textToAnnounce ? `${textToAnnounce}\xA0` : textToAnnounce;
|
|
3199
|
+
}
|
|
3200
|
+
};
|
|
3201
|
+
if (immediate) {
|
|
3202
|
+
run();
|
|
3203
|
+
} else {
|
|
3204
|
+
this.srAnnounceTimerId = window.setTimeout(run, 250);
|
|
3205
|
+
}
|
|
3206
|
+
}
|
|
3207
|
+
updateSuggestion(announceOptions) {
|
|
3208
|
+
if (this.options.disabled || this.isPasswordInput()) {
|
|
3209
|
+
this.currentSuggestion = { full: "", remaining: "", matchedDomain: null };
|
|
3210
|
+
this.clearGhost();
|
|
2887
3211
|
return;
|
|
2888
3212
|
}
|
|
2889
3213
|
const val = this.input.value;
|
|
2890
3214
|
this.currentSuggestion = this.engine.getSuggestion(val, this.currentSuggestionIndex);
|
|
2891
3215
|
if (!this.ghost) return;
|
|
2892
3216
|
if (this.shouldHideGhostForPlaceholder(val.length === 0)) {
|
|
2893
|
-
this.
|
|
3217
|
+
this.clearGhost();
|
|
2894
3218
|
} else if (this.currentSuggestion.remaining) {
|
|
2895
|
-
this.
|
|
2896
|
-
const spanTyped =
|
|
3219
|
+
const doc = this.input.ownerDocument || document;
|
|
3220
|
+
const spanTyped = doc.createElement("span");
|
|
2897
3221
|
spanTyped.className = "mask-ghost-typed";
|
|
2898
3222
|
spanTyped.textContent = val;
|
|
2899
|
-
const spanRemaining =
|
|
3223
|
+
const spanRemaining = doc.createElement("span");
|
|
2900
3224
|
spanRemaining.className = "mask-ghost-remaining";
|
|
2901
3225
|
spanRemaining.textContent = this.currentSuggestion.remaining;
|
|
2902
|
-
this.
|
|
2903
|
-
this.ghost.appendChild(spanRemaining);
|
|
3226
|
+
this.setGhostContent(spanTyped, spanRemaining);
|
|
2904
3227
|
} else {
|
|
2905
|
-
this.
|
|
3228
|
+
this.clearGhost();
|
|
2906
3229
|
}
|
|
2907
3230
|
this.ghost.scrollLeft = this.input.scrollLeft;
|
|
3231
|
+
if (announceOptions?.announce) {
|
|
3232
|
+
this.scheduleSuggestionAnnouncement(Boolean(announceOptions.immediate));
|
|
3233
|
+
}
|
|
2908
3234
|
const detail = this.getDetail();
|
|
2909
3235
|
if (this.options.onInput) {
|
|
2910
3236
|
this.options.onInput(detail);
|
|
2911
3237
|
}
|
|
2912
3238
|
this.input.dispatchEvent(new CustomEvent("mask:input", { bubbles: true, detail }));
|
|
2913
|
-
this.
|
|
3239
|
+
if (val !== this.lastNotifiedValue) {
|
|
3240
|
+
this.lastNotifiedValue = val;
|
|
3241
|
+
this.dispatchNativeInput();
|
|
3242
|
+
}
|
|
2914
3243
|
}
|
|
2915
|
-
handleInput() {
|
|
3244
|
+
handleInput(e) {
|
|
2916
3245
|
if (this.isDispatchingNativeInput) return;
|
|
2917
|
-
if (this.options.disabled) return;
|
|
3246
|
+
if (this.options.disabled || this.isPasswordInput()) return;
|
|
3247
|
+
if (this.isComposing || e && "isComposing" in e && e.isComposing) return;
|
|
2918
3248
|
if (this.options.autoLowercase) {
|
|
2919
3249
|
const start = this.input.selectionStart ?? 0;
|
|
2920
3250
|
const end = this.input.selectionEnd ?? start;
|
|
@@ -2925,10 +3255,11 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2925
3255
|
}
|
|
2926
3256
|
}
|
|
2927
3257
|
this.currentSuggestionIndex = 0;
|
|
2928
|
-
this.updateSuggestion();
|
|
3258
|
+
this.updateSuggestion({ announce: true, immediate: false });
|
|
2929
3259
|
}
|
|
2930
3260
|
handleKeyDown(e) {
|
|
2931
|
-
if (this.options.disabled) return;
|
|
3261
|
+
if (this.options.disabled || this.isPasswordInput() || isImeComposing(e)) return;
|
|
3262
|
+
if (e.shiftKey || e.ctrlKey || e.altKey || e.metaKey) return;
|
|
2932
3263
|
const hasSuggestion = Boolean(this.currentSuggestion.remaining) && !this.currentSuggestion.isHintOnly;
|
|
2933
3264
|
const cursor = this.input.selectionStart ?? 0;
|
|
2934
3265
|
const isAtEnd = cursor === this.input.value.length;
|
|
@@ -2937,13 +3268,13 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2937
3268
|
if (e.key === "ArrowDown") {
|
|
2938
3269
|
e.preventDefault();
|
|
2939
3270
|
this.currentSuggestionIndex++;
|
|
2940
|
-
this.updateSuggestion();
|
|
3271
|
+
this.updateSuggestion({ announce: true, immediate: true });
|
|
2941
3272
|
return;
|
|
2942
3273
|
}
|
|
2943
3274
|
if (e.key === "ArrowUp") {
|
|
2944
3275
|
e.preventDefault();
|
|
2945
3276
|
this.currentSuggestionIndex--;
|
|
2946
|
-
this.updateSuggestion();
|
|
3277
|
+
this.updateSuggestion({ announce: true, immediate: true });
|
|
2947
3278
|
return;
|
|
2948
3279
|
}
|
|
2949
3280
|
}
|
|
@@ -3010,6 +3341,20 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
3010
3341
|
}
|
|
3011
3342
|
handleBlur() {
|
|
3012
3343
|
this.wrapper.classList.remove("is-focused");
|
|
3344
|
+
if (this.srAnnounceTimerId !== null) {
|
|
3345
|
+
clearTimeout(this.srAnnounceTimerId);
|
|
3346
|
+
this.srAnnounceTimerId = null;
|
|
3347
|
+
}
|
|
3348
|
+
this.lastAnnouncedSuggestion = "";
|
|
3349
|
+
if (this.srStatusEl) {
|
|
3350
|
+
this.srStatusEl.textContent = "";
|
|
3351
|
+
}
|
|
3352
|
+
if (this.isPasswordInput()) {
|
|
3353
|
+
this.lastNotifiedValue = "";
|
|
3354
|
+
this.lastTrackedValue = "";
|
|
3355
|
+
this.clearGhost();
|
|
3356
|
+
return;
|
|
3357
|
+
}
|
|
3013
3358
|
this.updateSuggestion();
|
|
3014
3359
|
const detail = this.getDetail();
|
|
3015
3360
|
if (this.options.onChange) {
|
|
@@ -3055,18 +3400,31 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
3055
3400
|
clearTimeout(this.resetTimerId);
|
|
3056
3401
|
this.resetTimerId = null;
|
|
3057
3402
|
}
|
|
3058
|
-
this.
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3403
|
+
if (this.srAnnounceTimerId !== null) {
|
|
3404
|
+
clearTimeout(this.srAnnounceTimerId);
|
|
3405
|
+
this.srAnnounceTimerId = null;
|
|
3406
|
+
}
|
|
3407
|
+
if (this.srStatusEl) {
|
|
3408
|
+
this.srStatusEl.remove();
|
|
3409
|
+
this.srStatusEl = null;
|
|
3410
|
+
}
|
|
3411
|
+
this.lastNotifiedValue = "";
|
|
3412
|
+
this.lastAnnouncedSuggestion = "";
|
|
3413
|
+
if (this.wasInputModeInferred && this.input.getAttribute("inputmode") === "email") {
|
|
3414
|
+
this.input.removeAttribute("inputmode");
|
|
3066
3415
|
}
|
|
3067
3416
|
if (this.wasAriaAutocompleteSet && this.input.getAttribute("aria-autocomplete") === "inline") {
|
|
3068
3417
|
this.input.removeAttribute("aria-autocomplete");
|
|
3069
3418
|
}
|
|
3419
|
+
if (this.wasAutocorrectSet && this.input.getAttribute("autocorrect") === "off") {
|
|
3420
|
+
this.input.removeAttribute("autocorrect");
|
|
3421
|
+
}
|
|
3422
|
+
if (this.wasAutocapitalizeSet && this.input.getAttribute("autocapitalize") === "none") {
|
|
3423
|
+
this.input.removeAttribute("autocapitalize");
|
|
3424
|
+
}
|
|
3425
|
+
if (this.wasSpellcheckSet && this.input.getAttribute("spellcheck") === "false") {
|
|
3426
|
+
this.input.removeAttribute("spellcheck");
|
|
3427
|
+
}
|
|
3070
3428
|
super.destroy();
|
|
3071
3429
|
}
|
|
3072
3430
|
};
|
|
@@ -3083,10 +3441,8 @@ var Mask = {
|
|
|
3083
3441
|
EmailEngine,
|
|
3084
3442
|
InputEmailMask
|
|
3085
3443
|
};
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
const wulfNamespace = win.Wulf || {};
|
|
3089
|
-
win.Wulf = wulfNamespace;
|
|
3444
|
+
var wulfNamespace = getSafeWulfNamespace();
|
|
3445
|
+
if (wulfNamespace) {
|
|
3090
3446
|
wulfNamespace.Mask = Mask;
|
|
3091
3447
|
}
|
|
3092
3448
|
var index_default = InputMask;
|