wulf.js 1.9.2 → 1.9.3
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 +6 -0
- package/changelog.md +45 -0
- package/dist/focus-trap.esm.js +62 -9
- package/dist/focus-trap.esm.js.map +2 -2
- package/dist/focus-trap.global.js +64 -11
- package/dist/focus-trap.global.js.map +2 -2
- package/dist/focus-trap.global.min.js +3 -3
- package/dist/focus-trap.global.min.js.map +3 -3
- package/dist/index.esm.js +364 -107
- package/dist/index.esm.js.map +2 -2
- package/dist/index.global.js +366 -109
- package/dist/index.global.js.map +2 -2
- package/dist/index.global.min.js +3 -3
- package/dist/index.global.min.js.map +3 -3
- package/dist/mask.esm.js +66 -22
- package/dist/mask.esm.js.map +2 -2
- package/dist/mask.global.js +68 -24
- package/dist/mask.global.js.map +2 -2
- package/dist/mask.global.min.js +3 -3
- package/dist/mask.global.min.js.map +3 -3
- package/dist/masonry.esm.js +96 -40
- package/dist/masonry.esm.js.map +2 -2
- package/dist/masonry.global.js +98 -42
- package/dist/masonry.global.js.map +2 -2
- package/dist/masonry.global.min.js +3 -3
- package/dist/masonry.global.min.js.map +3 -3
- package/dist/scroll.esm.js +66 -28
- package/dist/scroll.esm.js.map +2 -2
- package/dist/scroll.global.js +68 -30
- package/dist/scroll.global.js.map +2 -2
- package/dist/scroll.global.min.js +4 -4
- package/dist/scroll.global.min.js.map +3 -3
- package/dist/shortcut.esm.js +53 -6
- package/dist/shortcut.esm.js.map +3 -3
- package/dist/shortcut.global.js +55 -8
- package/dist/shortcut.global.js.map +2 -2
- package/dist/shortcut.global.min.js +2 -2
- package/dist/shortcut.global.min.js.map +3 -3
- package/dist/toast.css +1 -1
- package/dist/toast.css.map +2 -2
- package/dist/toast.esm.js +109 -44
- package/dist/toast.esm.js.map +2 -2
- package/dist/toast.global.js +111 -46
- package/dist/toast.global.js.map +2 -2
- package/dist/toast.global.min.js +4 -4
- package/dist/toast.global.min.js.map +3 -3
- package/dist/types/focus-trap/FocusTrap.d.ts +2 -0
- package/dist/types/mask/AmountEngine.d.ts +1 -0
- package/dist/types/mask/BaseInputMask.d.ts +4 -0
- package/dist/types/mask/InputAmountMask.d.ts +1 -0
- package/dist/types/mask/InputMask.d.ts +1 -0
- package/dist/types/shortcut/ShortcutManager.d.ts +4 -0
- package/dist/types/toast/ToastInstance.d.ts +1 -1
- package/dist/types/toast/types.d.ts +5 -0
- package/package.json +5 -3
package/dist/mask.global.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
2
|
+
var __WulfIIFE = (() => {
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -284,7 +284,8 @@ var Wulf = (() => {
|
|
|
284
284
|
"data-disabled",
|
|
285
285
|
"data-mask-align",
|
|
286
286
|
"data-align",
|
|
287
|
-
"placeholder"
|
|
287
|
+
"placeholder",
|
|
288
|
+
"type"
|
|
288
289
|
]
|
|
289
290
|
};
|
|
290
291
|
this.mutationObserver.observe(this.wrapper, config);
|
|
@@ -332,7 +333,12 @@ var Wulf = (() => {
|
|
|
332
333
|
} else if (attrName === "data-mask-select-on-focus") {
|
|
333
334
|
this.options.selectAllOnFocus = this.getAttr("data-mask-select-on-focus") === "true";
|
|
334
335
|
} else if (attrName === "data-mask-copy-raw") {
|
|
335
|
-
this.options.copyRaw = this.getAttr("data-mask-copy-raw") === "true";
|
|
336
|
+
this.options.copyRaw = this.input.type === "password" ? false : this.getAttr("data-mask-copy-raw") === "true";
|
|
337
|
+
} else if (attrName === "type") {
|
|
338
|
+
if (this.input.type === "password") {
|
|
339
|
+
this.options.copyRaw = false;
|
|
340
|
+
this.onPasswordModeDetected();
|
|
341
|
+
}
|
|
336
342
|
} else if (attrName === "data-mask-align" || attrName === "data-align") {
|
|
337
343
|
const align = this.getAttr("data-mask-align") || this.getAttr("data-align");
|
|
338
344
|
if (align !== (this.options.align ?? null)) {
|
|
@@ -587,6 +593,11 @@ var Wulf = (() => {
|
|
|
587
593
|
getSpecificAuditWarnings() {
|
|
588
594
|
return [];
|
|
589
595
|
}
|
|
596
|
+
/**
|
|
597
|
+
* Crochet appelé lorsque l'input bascule dynamiquement en type="password" (ex: toggle afficher/masquer).
|
|
598
|
+
*/
|
|
599
|
+
onPasswordModeDetected() {
|
|
600
|
+
}
|
|
590
601
|
/**
|
|
591
602
|
* Supprime les éléments fantômes, restaure les propriétés et nettoie les attributs.
|
|
592
603
|
*/
|
|
@@ -671,11 +682,11 @@ var Wulf = (() => {
|
|
|
671
682
|
compile(newPattern) {
|
|
672
683
|
if (newPattern !== void 0) {
|
|
673
684
|
if (Array.isArray(newPattern)) {
|
|
674
|
-
this.patterns =
|
|
685
|
+
this.patterns = newPattern.slice(0, 32).map((p) => String(p ?? "").slice(0, 512));
|
|
675
686
|
this.pattern = this.patterns[0] || "";
|
|
676
687
|
} else {
|
|
677
688
|
this.patterns = [];
|
|
678
|
-
this.pattern = newPattern;
|
|
689
|
+
this.pattern = String(newPattern ?? "").slice(0, 512);
|
|
679
690
|
}
|
|
680
691
|
}
|
|
681
692
|
if (this.patterns.length > 0) {
|
|
@@ -826,7 +837,8 @@ var Wulf = (() => {
|
|
|
826
837
|
return engine.extractRaw(input);
|
|
827
838
|
}
|
|
828
839
|
}
|
|
829
|
-
const
|
|
840
|
+
const maxInputLen = Math.max(4096, this.slots.length * 4);
|
|
841
|
+
const str = String(input ?? "").slice(0, maxInputLen);
|
|
830
842
|
if (!str) return "";
|
|
831
843
|
let raw = "";
|
|
832
844
|
let inputIdx = 0;
|
|
@@ -895,7 +907,8 @@ var Wulf = (() => {
|
|
|
895
907
|
return engine.format(rawValue);
|
|
896
908
|
}
|
|
897
909
|
}
|
|
898
|
-
const
|
|
910
|
+
const maxInputLen = Math.max(4096, this.slots.length * 4);
|
|
911
|
+
const rawStr = String(rawValue ?? "").slice(0, maxInputLen);
|
|
899
912
|
if (!this.slots.length) return rawStr;
|
|
900
913
|
const cleanRaw = this.extractRaw(rawStr);
|
|
901
914
|
if (cleanRaw.length === 0) {
|
|
@@ -1398,6 +1411,9 @@ var Wulf = (() => {
|
|
|
1398
1411
|
extractRawSnippet(snippet) {
|
|
1399
1412
|
return this.engine.extractRaw(snippet);
|
|
1400
1413
|
}
|
|
1414
|
+
onPasswordModeDetected() {
|
|
1415
|
+
this.history.clear();
|
|
1416
|
+
}
|
|
1401
1417
|
/**
|
|
1402
1418
|
* Formate statiquement une valeur selon un masque donné sans nécessiter d'élément DOM.
|
|
1403
1419
|
*
|
|
@@ -1766,7 +1782,7 @@ var Wulf = (() => {
|
|
|
1766
1782
|
}
|
|
1767
1783
|
e.preventDefault();
|
|
1768
1784
|
this.history.updateCurrentCursor(this.input.selectionStart ?? 0);
|
|
1769
|
-
const rawPasted = e.clipboardData?.getData("text") || "";
|
|
1785
|
+
const rawPasted = (e.clipboardData?.getData("text") || "").slice(0, 4096);
|
|
1770
1786
|
const pastedText = rawPasted.trim();
|
|
1771
1787
|
if (!pastedText) return;
|
|
1772
1788
|
const minPos = this.engine.getPrefixLength();
|
|
@@ -1918,7 +1934,10 @@ var Wulf = (() => {
|
|
|
1918
1934
|
this.input.setSelectionRange(safeCursor, safeCursor);
|
|
1919
1935
|
isCompleted = this.isComplete();
|
|
1920
1936
|
this.wrapper.classList.toggle("is-complete", isCompleted);
|
|
1921
|
-
if (
|
|
1937
|
+
if (this.input.type === "password") {
|
|
1938
|
+
this.options.copyRaw = false;
|
|
1939
|
+
this.history.clear();
|
|
1940
|
+
} else if (!this.isUndoingRedoing) {
|
|
1922
1941
|
this.history.push(this.getRawValue(), safeCursor);
|
|
1923
1942
|
}
|
|
1924
1943
|
} finally {
|
|
@@ -1969,7 +1988,10 @@ var Wulf = (() => {
|
|
|
1969
1988
|
}
|
|
1970
1989
|
this.isNotifying = true;
|
|
1971
1990
|
try {
|
|
1972
|
-
|
|
1991
|
+
let iterations = 0;
|
|
1992
|
+
const MAX_NOTIFICATION_ITERATIONS = 10;
|
|
1993
|
+
while ((this.input.value !== this.lastValue || this.hasPendingNotification || forceNotify) && iterations < MAX_NOTIFICATION_ITERATIONS) {
|
|
1994
|
+
iterations++;
|
|
1973
1995
|
this.hasPendingNotification = false;
|
|
1974
1996
|
forceNotify = false;
|
|
1975
1997
|
const valToNotify = this.input.value;
|
|
@@ -2017,13 +2039,15 @@ var Wulf = (() => {
|
|
|
2017
2039
|
currency = options.unit;
|
|
2018
2040
|
}
|
|
2019
2041
|
const defaultPosition = currency === "$" || currency === "\xA3" || currency === "\xA5" ? "prefix" : "suffix";
|
|
2042
|
+
const rawDecimals = options.decimals !== void 0 ? Number(options.decimals) : 2;
|
|
2043
|
+
const safeDecimals = Number.isFinite(rawDecimals) ? Math.min(20, Math.max(0, Math.floor(rawDecimals))) : 2;
|
|
2020
2044
|
this.options = {
|
|
2021
|
-
currency,
|
|
2022
|
-
unit: options.unit ?? currency,
|
|
2045
|
+
currency: String(currency).slice(0, 32),
|
|
2046
|
+
unit: String(options.unit ?? currency).slice(0, 32),
|
|
2023
2047
|
currencyPosition: options.currencyPosition ?? defaultPosition,
|
|
2024
|
-
decimals:
|
|
2025
|
-
decimalSeparator: options.decimalSeparator ?? ",",
|
|
2026
|
-
thousandSeparator: options.thousandSeparator ?? "\xA0",
|
|
2048
|
+
decimals: safeDecimals,
|
|
2049
|
+
decimalSeparator: String(options.decimalSeparator ?? ",").slice(0, 4) || ",",
|
|
2050
|
+
thousandSeparator: String(options.thousandSeparator ?? "\xA0").slice(0, 4),
|
|
2027
2051
|
// Espace insécable
|
|
2028
2052
|
allowNegative: options.allowNegative ?? false,
|
|
2029
2053
|
min: options.min ?? -Infinity,
|
|
@@ -2034,7 +2058,7 @@ var Wulf = (() => {
|
|
|
2034
2058
|
* Analyse et nettoie une saisie utilisateur pour extraire ses composantes numériques.
|
|
2035
2059
|
*/
|
|
2036
2060
|
parse(input) {
|
|
2037
|
-
let str = input.trim();
|
|
2061
|
+
let str = String(input ?? "").slice(0, 512).trim();
|
|
2038
2062
|
let isNegative = false;
|
|
2039
2063
|
if (this.options.allowNegative && str.includes("-")) {
|
|
2040
2064
|
isNegative = true;
|
|
@@ -2075,7 +2099,9 @@ var Wulf = (() => {
|
|
|
2075
2099
|
* @param rawCursor Position actuelle du curseur dans l'input natif
|
|
2076
2100
|
*/
|
|
2077
2101
|
format(input, rawCursor = input.length, padDecimals = false) {
|
|
2078
|
-
|
|
2102
|
+
const safeInput = String(input ?? "").slice(0, 512);
|
|
2103
|
+
const safeRawCursor = Math.max(0, Math.min(rawCursor, safeInput.length));
|
|
2104
|
+
if (!safeInput || safeInput.trim() === "" || safeInput === this.options.currency.trim()) {
|
|
2079
2105
|
return {
|
|
2080
2106
|
formatted: "",
|
|
2081
2107
|
rawNumber: null,
|
|
@@ -2084,10 +2110,10 @@ var Wulf = (() => {
|
|
|
2084
2110
|
isValid: true
|
|
2085
2111
|
};
|
|
2086
2112
|
}
|
|
2087
|
-
const prefixBeforeCursor =
|
|
2113
|
+
const prefixBeforeCursor = safeInput.substring(0, safeRawCursor);
|
|
2088
2114
|
const digitsBeforeCursor = prefixBeforeCursor.replace(/\D/g, "").length;
|
|
2089
2115
|
const hadDecimalBeforeCursor = this.options.decimals > 0 && /[,.]/.test(prefixBeforeCursor);
|
|
2090
|
-
const { isNegative, integerPart, decimalPart, hasDecimal } = this.parse(
|
|
2116
|
+
const { isNegative, integerPart, decimalPart, hasDecimal } = this.parse(safeInput);
|
|
2091
2117
|
let effectiveDecimal = decimalPart;
|
|
2092
2118
|
let effectiveHasDecimal = hasDecimal;
|
|
2093
2119
|
if (padDecimals && this.options.decimals > 0 && (integerPart || decimalPart !== null)) {
|
|
@@ -2127,7 +2153,7 @@ var Wulf = (() => {
|
|
|
2127
2153
|
isValid: true
|
|
2128
2154
|
};
|
|
2129
2155
|
}
|
|
2130
|
-
const formattedInteger = (integerPart || "0")
|
|
2156
|
+
const formattedInteger = this.formatThousands(integerPart || "0");
|
|
2131
2157
|
let numberCore = formattedInteger;
|
|
2132
2158
|
if (effectiveHasDecimal && this.options.decimals > 0) {
|
|
2133
2159
|
numberCore += this.options.decimalSeparator + (effectiveDecimal ?? "");
|
|
@@ -2200,6 +2226,18 @@ var Wulf = (() => {
|
|
|
2200
2226
|
const str = typeof value === "number" ? value.toString() : value;
|
|
2201
2227
|
return engine.format(str).formatted;
|
|
2202
2228
|
}
|
|
2229
|
+
formatThousands(digits) {
|
|
2230
|
+
const sep = this.options.thousandSeparator;
|
|
2231
|
+
if (!sep || digits.length <= 3) return digits;
|
|
2232
|
+
const parts = [];
|
|
2233
|
+
let i = digits.length;
|
|
2234
|
+
while (i > 0) {
|
|
2235
|
+
const start = Math.max(0, i - 3);
|
|
2236
|
+
parts.push(digits.slice(start, i));
|
|
2237
|
+
i = start;
|
|
2238
|
+
}
|
|
2239
|
+
return parts.reverse().join(sep);
|
|
2240
|
+
}
|
|
2203
2241
|
escapeRegExp(string) {
|
|
2204
2242
|
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2205
2243
|
}
|
|
@@ -2250,6 +2288,9 @@ var Wulf = (() => {
|
|
|
2250
2288
|
if (!p.integerPart && !p.decimalPart) return "";
|
|
2251
2289
|
return (p.isNegative ? "-" : "") + (p.integerPart || "0") + (p.decimalPart ? "." + p.decimalPart : "");
|
|
2252
2290
|
}
|
|
2291
|
+
onPasswordModeDetected() {
|
|
2292
|
+
this.history.clear();
|
|
2293
|
+
}
|
|
2253
2294
|
/**
|
|
2254
2295
|
* Formate statiquement une valeur sans nécessiter d'élément DOM.
|
|
2255
2296
|
*/
|
|
@@ -2327,7 +2368,10 @@ var Wulf = (() => {
|
|
|
2327
2368
|
const result = this.engine.format(val, cursor);
|
|
2328
2369
|
this.setNativeValue(result.formatted);
|
|
2329
2370
|
this.input.setSelectionRange(result.cursor, result.cursor);
|
|
2330
|
-
if (
|
|
2371
|
+
if (this.input.type === "password") {
|
|
2372
|
+
this.options.copyRaw = false;
|
|
2373
|
+
this.history.clear();
|
|
2374
|
+
} else if (!this.isUndoingRedoing) {
|
|
2331
2375
|
this.history.push(result.rawValue, result.cursor);
|
|
2332
2376
|
}
|
|
2333
2377
|
this.updateGhost(result);
|
|
@@ -2621,7 +2665,7 @@ var Wulf = (() => {
|
|
|
2621
2665
|
* Retourne l'ensemble des domaines correspondant à la saisie courante.
|
|
2622
2666
|
*/
|
|
2623
2667
|
getMatchingDomains(input) {
|
|
2624
|
-
const val = input ?? "";
|
|
2668
|
+
const val = String(input ?? "").slice(0, 512);
|
|
2625
2669
|
if (!val.includes("@")) {
|
|
2626
2670
|
return this.defaultDomain ? [this.defaultDomain] : [];
|
|
2627
2671
|
}
|
|
@@ -2643,7 +2687,7 @@ var Wulf = (() => {
|
|
|
2643
2687
|
* @param matchIndex Index de la suggestion à sélectionner si plusieurs domaines/TLD correspondent (permet le cyclage)
|
|
2644
2688
|
*/
|
|
2645
2689
|
getSuggestion(input, matchIndex = 0) {
|
|
2646
|
-
const val = input ?? "";
|
|
2690
|
+
const val = String(input ?? "").slice(0, 512);
|
|
2647
2691
|
if (!val.includes("@")) {
|
|
2648
2692
|
if (this.defaultDomain) {
|
|
2649
2693
|
return {
|
|
@@ -3085,5 +3129,5 @@ var Wulf = (() => {
|
|
|
3085
3129
|
var index_default = InputMask;
|
|
3086
3130
|
return __toCommonJS(index_exports);
|
|
3087
3131
|
})();
|
|
3088
|
-
if (typeof window !== "undefined") { window.Wulf = window.Wulf || {}; if (typeof
|
|
3132
|
+
if (typeof window !== "undefined") { window.Wulf = window.Wulf || {}; if (typeof __WulfIIFE !== "undefined" && __WulfIIFE) { for (var k in __WulfIIFE) { if (Object.prototype.hasOwnProperty.call(__WulfIIFE, k) && k !== "__proto__" && k !== "constructor" && k !== "prototype" && window.Wulf[k] === undefined) { try { Object.defineProperty(window.Wulf, k, { value: __WulfIIFE[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[k] = __WulfIIFE[k]; } catch (__) {} } } } } }
|
|
3089
3133
|
//# sourceMappingURL=mask.global.js.map
|