wulf.js 1.8.4 → 1.9.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 +18 -14
- package/changelog.md +55 -0
- package/dist/index.cjs.js +590 -54
- package/dist/index.cjs.js.map +3 -3
- package/dist/index.esm.js +590 -54
- package/dist/index.esm.js.map +3 -3
- package/dist/index.global.js +590 -54
- package/dist/index.global.js.map +3 -3
- package/dist/index.global.min.js +1 -1
- package/dist/index.global.min.js.map +4 -4
- package/dist/mask.cjs.js +231 -31
- package/dist/mask.cjs.js.map +2 -2
- package/dist/mask.css +1 -1
- package/dist/mask.css.map +2 -2
- package/dist/mask.esm.js +231 -31
- package/dist/mask.esm.js.map +2 -2
- package/dist/mask.global.js +231 -31
- package/dist/mask.global.js.map +2 -2
- package/dist/mask.global.min.js +1 -1
- package/dist/mask.global.min.js.map +3 -3
- package/dist/masonry.cjs.js +220 -9
- package/dist/masonry.cjs.js.map +3 -3
- package/dist/masonry.esm.js +220 -9
- package/dist/masonry.esm.js.map +3 -3
- package/dist/masonry.global.js +220 -9
- package/dist/masonry.global.js.map +3 -3
- package/dist/masonry.global.min.js +1 -1
- package/dist/masonry.global.min.js.map +4 -4
- package/dist/scroll.cjs.js +256 -8
- package/dist/scroll.cjs.js.map +3 -3
- package/dist/scroll.esm.js +256 -8
- package/dist/scroll.esm.js.map +3 -3
- package/dist/scroll.global.js +256 -8
- package/dist/scroll.global.js.map +3 -3
- package/dist/scroll.global.min.js +1 -1
- package/dist/scroll.global.min.js.map +4 -4
- package/dist/toast.cjs.js +199 -6
- package/dist/toast.cjs.js.map +3 -3
- package/dist/toast.css +1 -1
- package/dist/toast.css.map +2 -2
- package/dist/toast.esm.js +199 -6
- package/dist/toast.esm.js.map +3 -3
- package/dist/toast.global.js +199 -6
- package/dist/toast.global.js.map +3 -3
- package/dist/toast.global.min.js +1 -1
- package/dist/toast.global.min.js.map +4 -4
- package/dist/types/common/LocalizedComponent.d.ts +53 -0
- package/dist/types/common/i18n.d.ts +39 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/mask/BaseInputMask.d.ts +1 -0
- package/dist/types/mask/EmailEngine.d.ts +24 -2
- package/dist/types/mask/InputEmailMask.d.ts +8 -0
- package/dist/types/mask/InputMask.d.ts +8 -0
- package/dist/types/masonry/Masonry.d.ts +11 -1
- package/dist/types/masonry/i18n/en.d.ts +2 -0
- package/dist/types/masonry/i18n/fr.d.ts +2 -0
- package/dist/types/masonry/i18n/index.d.ts +9 -0
- package/dist/types/masonry/i18n/types.d.ts +7 -0
- package/dist/types/masonry/index.d.ts +1 -0
- package/dist/types/masonry/types.d.ts +8 -3
- package/dist/types/scroll/ScrollBlock.d.ts +14 -1
- package/dist/types/scroll/i18n/en.d.ts +2 -0
- package/dist/types/scroll/i18n/fr.d.ts +2 -0
- package/dist/types/scroll/i18n/index.d.ts +9 -0
- package/dist/types/scroll/i18n/types.d.ts +11 -0
- package/dist/types/scroll/index.d.ts +2 -0
- package/dist/types/scroll/types.d.ts +6 -1
- package/dist/types/toast/Toast.d.ts +5 -1
- package/dist/types/toast/i18n/en.d.ts +2 -0
- package/dist/types/toast/i18n/fr.d.ts +2 -0
- package/dist/types/toast/i18n/index.d.ts +9 -0
- package/dist/types/toast/i18n/types.d.ts +7 -0
- package/dist/types/toast/index.d.ts +1 -0
- package/dist/types/toast/types.d.ts +9 -1
- package/package.json +1 -1
package/dist/mask.cjs.js
CHANGED
|
@@ -65,6 +65,7 @@ var BaseInputMask = class {
|
|
|
65
65
|
this.onCutHandler = () => {
|
|
66
66
|
};
|
|
67
67
|
this.mutationObserver = null;
|
|
68
|
+
this.focusSelectTimerId = null;
|
|
68
69
|
this.onBaseCopy = (e) => {
|
|
69
70
|
if (!this.options.copyRaw || this.options.disabled || this.input.type === "password") return;
|
|
70
71
|
const start = this.input.selectionStart ?? 0;
|
|
@@ -83,7 +84,11 @@ var BaseInputMask = class {
|
|
|
83
84
|
this.onBaseFocus = () => {
|
|
84
85
|
this.isFocused = true;
|
|
85
86
|
if (this.options.selectAllOnFocus && this.input.value.length > 0) {
|
|
86
|
-
|
|
87
|
+
if (this.focusSelectTimerId !== null) {
|
|
88
|
+
clearTimeout(this.focusSelectTimerId);
|
|
89
|
+
}
|
|
90
|
+
this.focusSelectTimerId = window.setTimeout(() => {
|
|
91
|
+
this.focusSelectTimerId = null;
|
|
87
92
|
if (!this.isDestroyed && document.activeElement === this.input) {
|
|
88
93
|
this.input.select();
|
|
89
94
|
}
|
|
@@ -102,7 +107,7 @@ var BaseInputMask = class {
|
|
|
102
107
|
}
|
|
103
108
|
};
|
|
104
109
|
const { wrapper: providedWrapper, input, options } = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOptions);
|
|
105
|
-
if (!input ||
|
|
110
|
+
if (!input || typeof input !== "object" || input.nodeType !== 1 || input.tagName !== "INPUT") {
|
|
106
111
|
throw new Error(`[${new.target.name || "InputMask"}] input (HTMLInputElement) est requis.`);
|
|
107
112
|
}
|
|
108
113
|
this.input = input;
|
|
@@ -227,6 +232,8 @@ var BaseInputMask = class {
|
|
|
227
232
|
"data-mask-pad-decimals",
|
|
228
233
|
"data-mask-auto-lowercase",
|
|
229
234
|
"data-mask-cycle-suggestions",
|
|
235
|
+
"data-mask-default-tld",
|
|
236
|
+
"data-mask-tlds",
|
|
230
237
|
"data-disabled",
|
|
231
238
|
"data-mask-align",
|
|
232
239
|
"data-align",
|
|
@@ -497,6 +504,10 @@ var BaseInputMask = class {
|
|
|
497
504
|
destroy() {
|
|
498
505
|
if (this.isDestroyed) return;
|
|
499
506
|
this.isDestroyed = true;
|
|
507
|
+
if (this.focusSelectTimerId !== null) {
|
|
508
|
+
clearTimeout(this.focusSelectTimerId);
|
|
509
|
+
this.focusSelectTimerId = null;
|
|
510
|
+
}
|
|
500
511
|
if (this.mutationObserver) {
|
|
501
512
|
this.mutationObserver.disconnect();
|
|
502
513
|
this.mutationObserver = null;
|
|
@@ -1258,6 +1269,9 @@ var InputMask = class extends BaseInputMask {
|
|
|
1258
1269
|
this.onChangeNativeHandler = () => {
|
|
1259
1270
|
};
|
|
1260
1271
|
this.wasInputModeInferred = false;
|
|
1272
|
+
this.cutTimerId = null;
|
|
1273
|
+
this.pasteTimerId = null;
|
|
1274
|
+
this.resetTimerId = null;
|
|
1261
1275
|
this.history = new MaskHistory();
|
|
1262
1276
|
this.engine = new MaskEngine(this.options.mask || "", {
|
|
1263
1277
|
placeholderChar: this.options.placeholderChar,
|
|
@@ -1265,12 +1279,7 @@ var InputMask = class extends BaseInputMask {
|
|
|
1265
1279
|
strict: this.options.strict,
|
|
1266
1280
|
autoLowercase: this.options.autoLowercase
|
|
1267
1281
|
});
|
|
1268
|
-
|
|
1269
|
-
if (this.engine.isNumericOnly()) {
|
|
1270
|
-
this.input.inputMode = "numeric";
|
|
1271
|
-
this.wasInputModeInferred = true;
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1282
|
+
this.syncInferredInputMode();
|
|
1274
1283
|
this.keyboard = new MaskKeyboard({
|
|
1275
1284
|
getInput: () => this.input,
|
|
1276
1285
|
getEngine: () => this.engine,
|
|
@@ -1334,7 +1343,9 @@ var InputMask = class extends BaseInputMask {
|
|
|
1334
1343
|
this.onScroll = this.onScroll.bind(this);
|
|
1335
1344
|
this.onBeforeInput = this.onBeforeInput.bind(this);
|
|
1336
1345
|
this.onCutHandler = () => {
|
|
1337
|
-
|
|
1346
|
+
if (this.cutTimerId !== null) clearTimeout(this.cutTimerId);
|
|
1347
|
+
this.cutTimerId = window.setTimeout(() => {
|
|
1348
|
+
this.cutTimerId = null;
|
|
1338
1349
|
if (this.isDestroyed) return;
|
|
1339
1350
|
if (this.options.disabled) {
|
|
1340
1351
|
this.checkValueChange();
|
|
@@ -1366,7 +1377,9 @@ var InputMask = class extends BaseInputMask {
|
|
|
1366
1377
|
this.input.addEventListener("change", this.onChangeNativeHandler);
|
|
1367
1378
|
if (this.input.form) {
|
|
1368
1379
|
this.onFormResetHandler = () => {
|
|
1369
|
-
|
|
1380
|
+
if (this.resetTimerId !== null) clearTimeout(this.resetTimerId);
|
|
1381
|
+
this.resetTimerId = window.setTimeout(() => {
|
|
1382
|
+
this.resetTimerId = null;
|
|
1370
1383
|
if (this.isDestroyed) return;
|
|
1371
1384
|
if (this.options.disabled) {
|
|
1372
1385
|
this.checkValueChange();
|
|
@@ -1378,11 +1391,40 @@ var InputMask = class extends BaseInputMask {
|
|
|
1378
1391
|
this.input.form.addEventListener("reset", this.onFormResetHandler);
|
|
1379
1392
|
}
|
|
1380
1393
|
}
|
|
1394
|
+
/**
|
|
1395
|
+
* Synchronise dynamiquement l'attribut inputmode="numeric" selon le motif actif
|
|
1396
|
+
* sans jamais écraser un inputmode défini explicitement par l'hôte.
|
|
1397
|
+
*/
|
|
1398
|
+
syncInferredInputMode() {
|
|
1399
|
+
if (!this.options.inferInputMode) return;
|
|
1400
|
+
const isNum = !this.options.disabled && this.engine.isNumericOnly();
|
|
1401
|
+
if (isNum) {
|
|
1402
|
+
if (!this.input.hasAttribute("inputmode")) {
|
|
1403
|
+
this.input.inputMode = "numeric";
|
|
1404
|
+
this.wasInputModeInferred = true;
|
|
1405
|
+
}
|
|
1406
|
+
} else if (this.wasInputModeInferred && this.input.getAttribute("inputmode") === "numeric") {
|
|
1407
|
+
this.input.removeAttribute("inputmode");
|
|
1408
|
+
this.wasInputModeInferred = false;
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1381
1411
|
/**
|
|
1382
1412
|
* Supprime tous les écouteurs et nettoie les attributs associés.
|
|
1383
1413
|
*/
|
|
1384
1414
|
destroy() {
|
|
1385
1415
|
if (this.isDestroyed) return;
|
|
1416
|
+
if (this.cutTimerId !== null) {
|
|
1417
|
+
clearTimeout(this.cutTimerId);
|
|
1418
|
+
this.cutTimerId = null;
|
|
1419
|
+
}
|
|
1420
|
+
if (this.pasteTimerId !== null) {
|
|
1421
|
+
clearTimeout(this.pasteTimerId);
|
|
1422
|
+
this.pasteTimerId = null;
|
|
1423
|
+
}
|
|
1424
|
+
if (this.resetTimerId !== null) {
|
|
1425
|
+
clearTimeout(this.resetTimerId);
|
|
1426
|
+
this.resetTimerId = null;
|
|
1427
|
+
}
|
|
1386
1428
|
this.input.removeEventListener("beforeinput", this.onBeforeInput);
|
|
1387
1429
|
this.input.removeEventListener("input", this.handleInput);
|
|
1388
1430
|
this.input.removeEventListener("keydown", this.onKeyDown);
|
|
@@ -1444,6 +1486,7 @@ var InputMask = class extends BaseInputMask {
|
|
|
1444
1486
|
this.history.clear();
|
|
1445
1487
|
}
|
|
1446
1488
|
this.setDisabled(true);
|
|
1489
|
+
this.syncInferredInputMode();
|
|
1447
1490
|
return;
|
|
1448
1491
|
}
|
|
1449
1492
|
this.options.mask = newPattern;
|
|
@@ -1454,6 +1497,7 @@ var InputMask = class extends BaseInputMask {
|
|
|
1454
1497
|
this.history.clear();
|
|
1455
1498
|
}
|
|
1456
1499
|
this.setDisabled(false);
|
|
1500
|
+
this.syncInferredInputMode();
|
|
1457
1501
|
}
|
|
1458
1502
|
handleAttributeMutation(attrName) {
|
|
1459
1503
|
super.handleAttributeMutation(attrName);
|
|
@@ -1611,7 +1655,9 @@ var InputMask = class extends BaseInputMask {
|
|
|
1611
1655
|
}
|
|
1612
1656
|
onPaste(e) {
|
|
1613
1657
|
if (this.options.disabled) {
|
|
1614
|
-
|
|
1658
|
+
if (this.pasteTimerId !== null) clearTimeout(this.pasteTimerId);
|
|
1659
|
+
this.pasteTimerId = window.setTimeout(() => {
|
|
1660
|
+
this.pasteTimerId = null;
|
|
1615
1661
|
if (!this.isDestroyed) this.checkValueChange();
|
|
1616
1662
|
}, 0);
|
|
1617
1663
|
return;
|
|
@@ -2420,9 +2466,12 @@ var InputAmountMask = class extends BaseInputMask {
|
|
|
2420
2466
|
var _EmailEngine = class _EmailEngine {
|
|
2421
2467
|
constructor(options = {}) {
|
|
2422
2468
|
this.defaultDomain = null;
|
|
2469
|
+
this.defaultTld = "__";
|
|
2423
2470
|
this.domains = options.domains && options.domains.length > 0 ? options.domains : _EmailEngine.DEFAULT_DOMAINS;
|
|
2471
|
+
this.tlds = options.tlds && options.tlds.length > 0 ? options.tlds.map((t) => t.trim().replace(/^\./, "")).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
|
|
2424
2472
|
this.suggestOnAt = options.suggestOnAt ?? true;
|
|
2425
2473
|
this.setDefaultDomain(options.defaultDomain ?? null);
|
|
2474
|
+
this.setDefaultTld(options.defaultTld !== void 0 ? options.defaultTld : "__");
|
|
2426
2475
|
}
|
|
2427
2476
|
/**
|
|
2428
2477
|
* Définit ou modifie le domaine suggéré par défaut.
|
|
@@ -2436,6 +2485,35 @@ var _EmailEngine = class _EmailEngine {
|
|
|
2436
2485
|
this.defaultDomain = null;
|
|
2437
2486
|
}
|
|
2438
2487
|
}
|
|
2488
|
+
/**
|
|
2489
|
+
* Définit ou modifie l'extension (TLD) ou gabarit suggéré par défaut sur un domaine inconnu.
|
|
2490
|
+
*/
|
|
2491
|
+
setDefaultTld(tld) {
|
|
2492
|
+
if (tld === true) {
|
|
2493
|
+
this.defaultTld = this.tlds.length > 0 ? this.tlds[0] : null;
|
|
2494
|
+
} else if (typeof tld === "string" && tld.trim().length > 0) {
|
|
2495
|
+
this.defaultTld = tld.trim().replace(/^\./, "");
|
|
2496
|
+
} else {
|
|
2497
|
+
this.defaultTld = null;
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
/**
|
|
2501
|
+
* Définit ou modifie la liste des extensions (TLD) proposées par ordre de priorité.
|
|
2502
|
+
*/
|
|
2503
|
+
setTlds(tlds) {
|
|
2504
|
+
this.tlds = tlds && tlds.length > 0 ? tlds.map((t) => t.trim().replace(/^\./, "")).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
|
|
2505
|
+
}
|
|
2506
|
+
/**
|
|
2507
|
+
* Retourne l'ensemble des extensions (TLD) correspondant au fragment saisi après le dernier point,
|
|
2508
|
+
* dans l'ordre exact fourni par l'utilisateur.
|
|
2509
|
+
*/
|
|
2510
|
+
getMatchingTlds(tldInput) {
|
|
2511
|
+
const query = (tldInput ?? "").toLowerCase();
|
|
2512
|
+
if (query.length === 0) {
|
|
2513
|
+
return [...this.tlds];
|
|
2514
|
+
}
|
|
2515
|
+
return this.tlds.filter((t) => t.toLowerCase().startsWith(query) && t.toLowerCase() !== query);
|
|
2516
|
+
}
|
|
2439
2517
|
/**
|
|
2440
2518
|
* Retourne l'ensemble des domaines correspondant à la saisie courante.
|
|
2441
2519
|
*/
|
|
@@ -2456,10 +2534,10 @@ var _EmailEngine = class _EmailEngine {
|
|
|
2456
2534
|
return this.domains.filter((d) => d.toLowerCase().startsWith(query) && d.toLowerCase() !== query);
|
|
2457
2535
|
}
|
|
2458
2536
|
/**
|
|
2459
|
-
* Analyse la saisie courante et calcule la suggestion de domaine adaptée.
|
|
2537
|
+
* Analyse la saisie courante et calcule la suggestion de domaine ou d'extension (TLD) adaptée.
|
|
2460
2538
|
*
|
|
2461
2539
|
* @param input Saisie utilisateur
|
|
2462
|
-
* @param matchIndex Index de la suggestion à sélectionner si plusieurs domaines correspondent (permet le cyclage)
|
|
2540
|
+
* @param matchIndex Index de la suggestion à sélectionner si plusieurs domaines/TLD correspondent (permet le cyclage)
|
|
2463
2541
|
*/
|
|
2464
2542
|
getSuggestion(input, matchIndex = 0) {
|
|
2465
2543
|
const val = input ?? "";
|
|
@@ -2468,30 +2546,104 @@ var _EmailEngine = class _EmailEngine {
|
|
|
2468
2546
|
return {
|
|
2469
2547
|
full: val ? `${val}@${this.defaultDomain}` : `@${this.defaultDomain}`,
|
|
2470
2548
|
remaining: `@${this.defaultDomain}`,
|
|
2471
|
-
matchedDomain: this.defaultDomain
|
|
2549
|
+
matchedDomain: this.defaultDomain,
|
|
2550
|
+
isHintOnly: false
|
|
2472
2551
|
};
|
|
2473
2552
|
}
|
|
2474
|
-
return { full: val, remaining: "", matchedDomain: null };
|
|
2553
|
+
return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2475
2554
|
}
|
|
2476
2555
|
const atIndex = val.indexOf("@");
|
|
2477
2556
|
const localPart = val.substring(0, atIndex);
|
|
2478
2557
|
const domainPart = val.substring(atIndex + 1);
|
|
2479
2558
|
if (val.indexOf("@", atIndex + 1) !== -1) {
|
|
2480
|
-
return { full: val, remaining: "", matchedDomain: null };
|
|
2559
|
+
return { full: val, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2481
2560
|
}
|
|
2482
2561
|
const matches = this.getMatchingDomains(input);
|
|
2483
|
-
if (matches.length
|
|
2484
|
-
|
|
2562
|
+
if (matches.length > 0) {
|
|
2563
|
+
const safeIndex = (matchIndex % matches.length + matches.length) % matches.length;
|
|
2564
|
+
const matched = matches[safeIndex];
|
|
2565
|
+
const query = domainPart.toLowerCase();
|
|
2566
|
+
const remaining = matched.substring(query.length);
|
|
2567
|
+
return {
|
|
2568
|
+
full: `${localPart}@${matched}`,
|
|
2569
|
+
remaining,
|
|
2570
|
+
matchedDomain: matched,
|
|
2571
|
+
isHintOnly: false
|
|
2572
|
+
};
|
|
2485
2573
|
}
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
const
|
|
2490
|
-
|
|
2491
|
-
full:
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2574
|
+
if (domainPart.length === 0 || domainPart.startsWith(".")) {
|
|
2575
|
+
return { full: input, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2576
|
+
}
|
|
2577
|
+
const lowerDomain = domainPart.toLowerCase();
|
|
2578
|
+
if (this.domains.some((d) => d.toLowerCase() === lowerDomain)) {
|
|
2579
|
+
return { full: input, remaining: "", matchedDomain: domainPart, isHintOnly: false };
|
|
2580
|
+
}
|
|
2581
|
+
const lastDotIndex = domainPart.lastIndexOf(".");
|
|
2582
|
+
if (lastDotIndex === -1) {
|
|
2583
|
+
if (!this.defaultTld) {
|
|
2584
|
+
return { full: input, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2585
|
+
}
|
|
2586
|
+
const isHint = this.defaultTld.includes("_");
|
|
2587
|
+
const remaining = `.${this.defaultTld}`;
|
|
2588
|
+
const fullDomain = `${domainPart}.${this.defaultTld}`;
|
|
2589
|
+
return {
|
|
2590
|
+
full: isHint ? input : `${localPart}@${fullDomain}`,
|
|
2591
|
+
remaining,
|
|
2592
|
+
matchedDomain: isHint ? null : fullDomain,
|
|
2593
|
+
isHintOnly: isHint
|
|
2594
|
+
};
|
|
2595
|
+
}
|
|
2596
|
+
const hostPart = domainPart.substring(0, lastDotIndex);
|
|
2597
|
+
const tldPart = domainPart.substring(lastDotIndex + 1);
|
|
2598
|
+
if (!hostPart || hostPart.endsWith(".")) {
|
|
2599
|
+
return { full: input, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2600
|
+
}
|
|
2601
|
+
if (tldPart.length === 0) {
|
|
2602
|
+
if (this.defaultTld && !this.defaultTld.includes("_")) {
|
|
2603
|
+
const fullDomain = `${hostPart}.${this.defaultTld}`;
|
|
2604
|
+
return {
|
|
2605
|
+
full: `${localPart}@${fullDomain}`,
|
|
2606
|
+
remaining: this.defaultTld,
|
|
2607
|
+
matchedDomain: fullDomain,
|
|
2608
|
+
isHintOnly: false
|
|
2609
|
+
};
|
|
2610
|
+
}
|
|
2611
|
+
if (this.defaultTld && this.defaultTld.includes("_")) {
|
|
2612
|
+
return {
|
|
2613
|
+
full: input,
|
|
2614
|
+
remaining: this.defaultTld,
|
|
2615
|
+
matchedDomain: null,
|
|
2616
|
+
isHintOnly: true
|
|
2617
|
+
};
|
|
2618
|
+
}
|
|
2619
|
+
return { full: input, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2620
|
+
}
|
|
2621
|
+
const lowerTld = tldPart.toLowerCase();
|
|
2622
|
+
const matchingTlds = this.getMatchingTlds(tldPart);
|
|
2623
|
+
if (matchingTlds.length > 0) {
|
|
2624
|
+
const safeTldIndex = (matchIndex % matchingTlds.length + matchingTlds.length) % matchingTlds.length;
|
|
2625
|
+
const matchedTld = matchingTlds[safeTldIndex];
|
|
2626
|
+
const remaining = matchedTld.substring(lowerTld.length);
|
|
2627
|
+
const fullDomain = `${hostPart}.${matchedTld}`;
|
|
2628
|
+
return {
|
|
2629
|
+
full: `${localPart}@${fullDomain}`,
|
|
2630
|
+
remaining,
|
|
2631
|
+
matchedDomain: fullDomain,
|
|
2632
|
+
isHintOnly: false
|
|
2633
|
+
};
|
|
2634
|
+
}
|
|
2635
|
+
if (this.defaultTld && this.defaultTld.includes("_") && tldPart.length < this.defaultTld.length) {
|
|
2636
|
+
const remaining = this.defaultTld.substring(tldPart.length);
|
|
2637
|
+
if (remaining.includes("_")) {
|
|
2638
|
+
return {
|
|
2639
|
+
full: input,
|
|
2640
|
+
remaining,
|
|
2641
|
+
matchedDomain: null,
|
|
2642
|
+
isHintOnly: true
|
|
2643
|
+
};
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
return { full: input, remaining: "", matchedDomain: null, isHintOnly: false };
|
|
2495
2647
|
}
|
|
2496
2648
|
};
|
|
2497
2649
|
_EmailEngine.DEFAULT_DOMAINS = [
|
|
@@ -2506,6 +2658,27 @@ _EmailEngine.DEFAULT_DOMAINS = [
|
|
|
2506
2658
|
"laposte.net",
|
|
2507
2659
|
"proton.me"
|
|
2508
2660
|
];
|
|
2661
|
+
_EmailEngine.DEFAULT_TLDS = [
|
|
2662
|
+
"com",
|
|
2663
|
+
"fr",
|
|
2664
|
+
"net",
|
|
2665
|
+
"org",
|
|
2666
|
+
"eu",
|
|
2667
|
+
"io",
|
|
2668
|
+
"co",
|
|
2669
|
+
"info",
|
|
2670
|
+
"biz",
|
|
2671
|
+
"me",
|
|
2672
|
+
"tv",
|
|
2673
|
+
"fi",
|
|
2674
|
+
"be",
|
|
2675
|
+
"ch",
|
|
2676
|
+
"ca",
|
|
2677
|
+
"uk",
|
|
2678
|
+
"de",
|
|
2679
|
+
"es",
|
|
2680
|
+
"it"
|
|
2681
|
+
];
|
|
2509
2682
|
var EmailEngine = _EmailEngine;
|
|
2510
2683
|
|
|
2511
2684
|
// src/mask/InputEmailMask.ts
|
|
@@ -2519,6 +2692,10 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2519
2692
|
const dataAutoLower = wrap?.getAttribute("data-mask-auto-lowercase") === "true" || inp?.getAttribute("data-mask-auto-lowercase") === "true";
|
|
2520
2693
|
const dataAriaAuto = wrap?.getAttribute("data-mask-aria-autocomplete") ?? inp?.getAttribute("data-mask-aria-autocomplete");
|
|
2521
2694
|
const setAriaAutocomplete = opts.setAriaAutocomplete ?? (dataAriaAuto !== null ? dataAriaAuto !== "false" : true);
|
|
2695
|
+
const dataTlds = wrap?.getAttribute("data-mask-tlds") ?? inp?.getAttribute("data-mask-tlds");
|
|
2696
|
+
const parsedTlds = opts.tlds ?? (dataTlds ? dataTlds.split(",").map((s) => s.trim()).filter(Boolean) : void 0);
|
|
2697
|
+
const dataDefaultTld = wrap?.getAttribute("data-mask-default-tld") ?? inp?.getAttribute("data-mask-default-tld");
|
|
2698
|
+
const resolvedDefaultTld = opts.defaultTld !== void 0 ? opts.defaultTld : dataDefaultTld !== null ? dataDefaultTld === "false" || dataDefaultTld === "none" ? null : dataDefaultTld === "true" ? true : dataDefaultTld : void 0;
|
|
2522
2699
|
const resolvedOptions = {
|
|
2523
2700
|
completeOnTab: true,
|
|
2524
2701
|
completeOnArrowRight: true,
|
|
@@ -2526,7 +2703,9 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2526
2703
|
cycleSuggestions: opts.cycleSuggestions ?? dataCycle ?? false,
|
|
2527
2704
|
autoLowercase: opts.autoLowercase ?? dataAutoLower ?? false,
|
|
2528
2705
|
setAriaAutocomplete,
|
|
2529
|
-
...opts
|
|
2706
|
+
...opts,
|
|
2707
|
+
...parsedTlds !== void 0 ? { tlds: parsedTlds } : {},
|
|
2708
|
+
...resolvedDefaultTld !== void 0 ? { defaultTld: resolvedDefaultTld } : {}
|
|
2530
2709
|
};
|
|
2531
2710
|
super(wrap, inp, resolvedOptions);
|
|
2532
2711
|
this.currentSuggestion = { full: "", remaining: "", matchedDomain: null };
|
|
@@ -2639,7 +2818,7 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2639
2818
|
}
|
|
2640
2819
|
handleKeyDown(e) {
|
|
2641
2820
|
if (this.options.disabled) return;
|
|
2642
|
-
const hasSuggestion = Boolean(this.currentSuggestion.remaining);
|
|
2821
|
+
const hasSuggestion = Boolean(this.currentSuggestion.remaining) && !this.currentSuggestion.isHintOnly;
|
|
2643
2822
|
const cursor = this.input.selectionStart ?? 0;
|
|
2644
2823
|
const isAtEnd = cursor === this.input.value.length;
|
|
2645
2824
|
const isNotEmpty = this.input.value.length > 0;
|
|
@@ -2677,7 +2856,7 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2677
2856
|
* Valide et applique la suggestion courante dans le champ natif.
|
|
2678
2857
|
*/
|
|
2679
2858
|
acceptSuggestion() {
|
|
2680
|
-
if (!this.currentSuggestion.remaining || this.options.disabled || this.input.value.length === 0) return false;
|
|
2859
|
+
if (!this.currentSuggestion.remaining || this.currentSuggestion.isHintOnly || this.options.disabled || this.input.value.length === 0) return false;
|
|
2681
2860
|
const completed = this.currentSuggestion.full;
|
|
2682
2861
|
this.setNativeValue(completed);
|
|
2683
2862
|
this.input.setSelectionRange(completed.length, completed.length);
|
|
@@ -2698,6 +2877,21 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2698
2877
|
this.engine.setDefaultDomain(domain);
|
|
2699
2878
|
this.updateSuggestion();
|
|
2700
2879
|
}
|
|
2880
|
+
/**
|
|
2881
|
+
* Modifie dynamiquement l'extension (TLD) ou gabarit suggéré par défaut sur un domaine inconnu.
|
|
2882
|
+
*/
|
|
2883
|
+
setDefaultTld(tld) {
|
|
2884
|
+
this.engine.setDefaultTld(tld);
|
|
2885
|
+
this.updateSuggestion();
|
|
2886
|
+
}
|
|
2887
|
+
/**
|
|
2888
|
+
* Modifie dynamiquement la liste des extensions (TLD) connues.
|
|
2889
|
+
*/
|
|
2890
|
+
setTlds(tlds) {
|
|
2891
|
+
this.engine.setTlds(tlds);
|
|
2892
|
+
this.currentSuggestionIndex = 0;
|
|
2893
|
+
this.updateSuggestion();
|
|
2894
|
+
}
|
|
2701
2895
|
handleFocus() {
|
|
2702
2896
|
this.wrapper.classList.add("is-focused");
|
|
2703
2897
|
this.syncGhostStyles();
|
|
@@ -2718,6 +2912,12 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2718
2912
|
this.options.cycleSuggestions = this.getAttr("data-mask-cycle-suggestions") === "true";
|
|
2719
2913
|
} else if (attrName === "data-mask-auto-lowercase") {
|
|
2720
2914
|
this.options.autoLowercase = this.getAttr("data-mask-auto-lowercase") === "true";
|
|
2915
|
+
} else if (attrName === "data-mask-default-tld") {
|
|
2916
|
+
const val = this.getAttr("data-mask-default-tld");
|
|
2917
|
+
this.setDefaultTld(val === null || val === "false" || val === "none" ? null : val === "true" ? true : val);
|
|
2918
|
+
} else if (attrName === "data-mask-tlds") {
|
|
2919
|
+
const val = this.getAttr("data-mask-tlds");
|
|
2920
|
+
this.setTlds(val ? val.split(",").map((s) => s.trim()).filter(Boolean) : null);
|
|
2721
2921
|
} else if (attrName === "placeholder") {
|
|
2722
2922
|
this.updateSuggestion();
|
|
2723
2923
|
}
|
|
@@ -2725,7 +2925,7 @@ var InputEmailMask = class extends BaseInputMask {
|
|
|
2725
2925
|
getDetail() {
|
|
2726
2926
|
return {
|
|
2727
2927
|
value: this.input.value,
|
|
2728
|
-
suggestedValue: this.currentSuggestion.full,
|
|
2928
|
+
suggestedValue: this.currentSuggestion.isHintOnly ? "" : this.currentSuggestion.full,
|
|
2729
2929
|
domain: this.currentSuggestion.matchedDomain
|
|
2730
2930
|
};
|
|
2731
2931
|
}
|