numora 3.3.0 → 3.5.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/dist/NumoraInput.d.ts +3 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.mjs +329 -280
- package/dist/types.d.ts +1 -2
- package/dist/utils/event-handlers.d.ts +14 -0
- package/dist/utils/locale.d.ts +3 -6
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var w = (e, t, n) =>
|
|
4
|
-
var
|
|
5
|
-
const
|
|
1
|
+
var re = Object.defineProperty;
|
|
2
|
+
var ie = (e, t, n) => t in e ? re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var w = (e, t, n) => ie(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
var b = /* @__PURE__ */ ((e) => (e.Blur = "blur", e.Change = "change", e))(b || {}), L = /* @__PURE__ */ ((e) => (e.None = "none", e.Thousand = "thousand", e.Lakh = "lakh", e.Wan = "wan", e))(L || {});
|
|
5
|
+
const B = 2, G = 0, k = b.Blur, se = ",", Z = L.None, C = ".", W = !1, U = !1, z = !1, J = !1;
|
|
6
6
|
function y(e) {
|
|
7
7
|
return e.replace(/[-[\]/{}()*+?.\\^$|]/g, "\\$&");
|
|
8
8
|
}
|
|
9
|
-
const
|
|
10
|
-
function
|
|
9
|
+
const P = /* @__PURE__ */ new Map();
|
|
10
|
+
function _(e, t = "g") {
|
|
11
11
|
const n = `${e}:${t}`;
|
|
12
|
-
let r =
|
|
13
|
-
return r || (r = new RegExp(e, t),
|
|
12
|
+
let r = P.get(n);
|
|
13
|
+
return r || (r = new RegExp(e, t), P.set(n, r)), r;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function ae(e, t = "g") {
|
|
16
16
|
const n = y(e);
|
|
17
|
-
return
|
|
17
|
+
return _(n, t);
|
|
18
18
|
}
|
|
19
|
-
const
|
|
20
|
-
function
|
|
19
|
+
const ce = /[.,]/g;
|
|
20
|
+
function x(e) {
|
|
21
21
|
return {
|
|
22
22
|
decimalSeparator: (e == null ? void 0 : e.decimalSeparator) ?? C,
|
|
23
23
|
thousandSeparator: e == null ? void 0 : e.thousandSeparator
|
|
@@ -31,35 +31,17 @@ function Y(e, t) {
|
|
|
31
31
|
decimal: s
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
if (!e.value.includes(t)) return !1;
|
|
36
|
-
const { selectionStart: n, selectionEnd: r, value: i } = e;
|
|
37
|
-
return !i.slice(n ?? 0, r ?? 0).includes(t);
|
|
38
|
-
}
|
|
39
|
-
function le(e, t, n) {
|
|
40
|
-
const { key: r } = e;
|
|
41
|
-
if (r !== "," && r !== ".") return !1;
|
|
42
|
-
if (ce(t, n))
|
|
43
|
-
return !0;
|
|
44
|
-
if (r !== n) {
|
|
45
|
-
const { selectionStart: i, selectionEnd: s, value: a } = t, c = i ?? 0, o = s ?? c;
|
|
46
|
-
t.value = a.slice(0, c) + n + a.slice(o);
|
|
47
|
-
const l = c + 1;
|
|
48
|
-
return t.setSelectionRange(l, l), !0;
|
|
49
|
-
}
|
|
50
|
-
return !1;
|
|
51
|
-
}
|
|
52
|
-
const oe = (e, t, n = C) => {
|
|
34
|
+
const le = (e, t, n = C) => {
|
|
53
35
|
const { sign: r, integer: i, decimal: s } = Y(e, n);
|
|
54
36
|
if (!s) return e;
|
|
55
37
|
const a = s.slice(0, t);
|
|
56
38
|
return `${r}${i}${n}${a}`;
|
|
57
|
-
},
|
|
39
|
+
}, oe = (e, t = C) => {
|
|
58
40
|
const n = e.indexOf(t);
|
|
59
41
|
if (n === -1 || n === e.length - 1) return e;
|
|
60
|
-
const r = e.slice(0, n + 1), i = e.slice(n + 1), a = t === "." || t === "," ?
|
|
42
|
+
const r = e.slice(0, n + 1), i = e.slice(n + 1), a = t === "." || t === "," ? ce : _("[,\\." + y(t) + "]", "g");
|
|
61
43
|
return r + i.replace(a, "");
|
|
62
|
-
},
|
|
44
|
+
}, he = (e, t = 0, n = C) => {
|
|
63
45
|
if (t <= 0) return e;
|
|
64
46
|
const { sign: r, integer: i, decimal: s } = Y(e, n);
|
|
65
47
|
if (s.length >= t)
|
|
@@ -70,8 +52,8 @@ const oe = (e, t, n = C) => {
|
|
|
70
52
|
thousand: { size: 3 },
|
|
71
53
|
lakh: { firstGroup: 3, restGroup: 2 },
|
|
72
54
|
wan: { size: 4 }
|
|
73
|
-
},
|
|
74
|
-
function Q(e, t, n =
|
|
55
|
+
}, ue = /^(0+)/;
|
|
56
|
+
function Q(e, t, n = L.Thousand, r = !1, i = ".") {
|
|
75
57
|
if (!e || e === "0" || e === i || e === "-" || e === `-${i}`)
|
|
76
58
|
return e;
|
|
77
59
|
const s = e.includes(i), a = e.startsWith("-"), c = a ? e.slice(1) : e, [o, l] = c.split(i);
|
|
@@ -80,35 +62,35 @@ function Q(e, t, n = p.Thousand, r = !1, i = ".") {
|
|
|
80
62
|
return a ? `-${u}` : u;
|
|
81
63
|
}
|
|
82
64
|
if (r && o.startsWith("0") && o.length > 1) {
|
|
83
|
-
const u = o.match(
|
|
65
|
+
const u = o.match(ue);
|
|
84
66
|
if (u) {
|
|
85
67
|
const S = u[1], E = o.slice(S.length);
|
|
86
68
|
if (E) {
|
|
87
|
-
const
|
|
88
|
-
return s ? l ? `${
|
|
69
|
+
const p = X(E, t, n), d = S + p, f = a ? "-" : "";
|
|
70
|
+
return s ? l ? `${f}${d}${i}${l}` : `${f}${d}${i}` : `${f}${d}`;
|
|
89
71
|
}
|
|
90
72
|
}
|
|
91
73
|
}
|
|
92
|
-
const h =
|
|
93
|
-
return s ? l ? `${
|
|
74
|
+
const h = X(o, t, n), g = a ? "-" : "";
|
|
75
|
+
return s ? l ? `${g}${h}${i}${l}` : `${g}${h}${i}` : `${g}${h}`;
|
|
94
76
|
}
|
|
95
|
-
function
|
|
77
|
+
function X(e, t, n) {
|
|
96
78
|
if (e === "0" || e === "")
|
|
97
79
|
return e;
|
|
98
80
|
switch (n) {
|
|
99
|
-
case
|
|
81
|
+
case L.None:
|
|
100
82
|
return e;
|
|
101
|
-
case
|
|
102
|
-
return
|
|
103
|
-
case
|
|
104
|
-
return
|
|
105
|
-
case
|
|
106
|
-
return
|
|
83
|
+
case L.Thousand:
|
|
84
|
+
return j(e, t, D.thousand.size);
|
|
85
|
+
case L.Lakh:
|
|
86
|
+
return de(e, t);
|
|
87
|
+
case L.Wan:
|
|
88
|
+
return j(e, t, D.wan.size);
|
|
107
89
|
default:
|
|
108
90
|
return e;
|
|
109
91
|
}
|
|
110
92
|
}
|
|
111
|
-
function
|
|
93
|
+
function de(e, t) {
|
|
112
94
|
if (e.length <= D.lakh.firstGroup)
|
|
113
95
|
return e;
|
|
114
96
|
const n = [], r = e.length - D.lakh.firstGroup;
|
|
@@ -117,17 +99,17 @@ function fe(e, t) {
|
|
|
117
99
|
n.unshift(e.slice(Math.max(0, i - D.lakh.restGroup), i));
|
|
118
100
|
return n.join(t);
|
|
119
101
|
}
|
|
120
|
-
function
|
|
102
|
+
function j(e, t, n) {
|
|
121
103
|
const r = [];
|
|
122
104
|
for (let i = e.length; i > 0; i -= n)
|
|
123
105
|
r.unshift(e.slice(Math.max(0, i - n), i));
|
|
124
106
|
return r.join(t);
|
|
125
107
|
}
|
|
126
|
-
function
|
|
127
|
-
return (t == null ? void 0 : t.formatOn) ===
|
|
108
|
+
function fe(e, t, n) {
|
|
109
|
+
return (t == null ? void 0 : t.formatOn) === b.Change && t.thousandSeparator ? Q(
|
|
128
110
|
e,
|
|
129
111
|
t.thousandSeparator,
|
|
130
|
-
t.ThousandStyle ??
|
|
112
|
+
t.ThousandStyle ?? L.None,
|
|
131
113
|
t.enableLeadingZeros,
|
|
132
114
|
(n == null ? void 0 : n.decimalSeparator) ?? C
|
|
133
115
|
) : e;
|
|
@@ -138,7 +120,7 @@ function $(e, t, n) {
|
|
|
138
120
|
e[i] !== n && r++;
|
|
139
121
|
return r;
|
|
140
122
|
}
|
|
141
|
-
function
|
|
123
|
+
function ge(e, t, n) {
|
|
142
124
|
if (t === 0)
|
|
143
125
|
return 0;
|
|
144
126
|
let r = 0;
|
|
@@ -166,8 +148,8 @@ function R(e, t, n) {
|
|
|
166
148
|
function V(e, t, n) {
|
|
167
149
|
return t < 0 || t >= e.length ? !1 : e[t] === n;
|
|
168
150
|
}
|
|
169
|
-
const
|
|
170
|
-
function
|
|
151
|
+
const Se = /\d/;
|
|
152
|
+
function Ee(e, t = {}) {
|
|
171
153
|
const {
|
|
172
154
|
thousandSeparator: n,
|
|
173
155
|
decimalSeparator: r = ".",
|
|
@@ -180,11 +162,11 @@ function me(e, t = {}) {
|
|
|
180
162
|
}
|
|
181
163
|
for (let c = 0; c < e.length; c++) {
|
|
182
164
|
const o = e[c];
|
|
183
|
-
(n && o === n || o === r) && (a[c] = !1, c + 1 < e.length && !
|
|
165
|
+
(n && o === n || o === r) && (a[c] = !1, c + 1 < e.length && !Se.test(e[c + 1]) && (a[c + 1] = !1));
|
|
184
166
|
}
|
|
185
167
|
return a.some((c) => c) || a.fill(!0), a;
|
|
186
168
|
}
|
|
187
|
-
function
|
|
169
|
+
function O(e, t, n, r) {
|
|
188
170
|
const i = e.length;
|
|
189
171
|
if (t = Math.max(0, Math.min(t, i)), r === "left") {
|
|
190
172
|
for (; t >= 0 && !n[t]; )
|
|
@@ -205,50 +187,50 @@ function x(e, t, n, r) {
|
|
|
205
187
|
}
|
|
206
188
|
return (t === -1 || t > i) && (t = i), t;
|
|
207
189
|
}
|
|
208
|
-
const
|
|
209
|
-
function
|
|
190
|
+
const q = /(\d+\.?\d*)\s*[kmbt]$/i, pe = (e, t) => e === t;
|
|
191
|
+
function me(e, t, n, r, i, s, a = ".", c = {}) {
|
|
210
192
|
if (n < 0)
|
|
211
193
|
return 0;
|
|
212
|
-
if (n > e.length || e === "" || t === "" ||
|
|
194
|
+
if (n > e.length || e === "" || t === "" || q.test(e) && !q.test(t) && t.length > e.length && n >= e.length - 1)
|
|
213
195
|
return t.length;
|
|
214
196
|
const o = t.length < e.length, l = V(
|
|
215
197
|
e,
|
|
216
198
|
n,
|
|
217
199
|
r
|
|
218
|
-
), h = e.indexOf(a),
|
|
200
|
+
), h = e.indexOf(a), g = t.indexOf(a);
|
|
219
201
|
if (c.isCharacterEquivalent && e !== t) {
|
|
220
|
-
const
|
|
202
|
+
const d = {
|
|
221
203
|
thousandSeparator: r || void 0,
|
|
222
204
|
...c
|
|
223
|
-
},
|
|
205
|
+
}, f = be(
|
|
224
206
|
e,
|
|
225
207
|
t,
|
|
226
208
|
n,
|
|
227
209
|
c.isCharacterEquivalent || pe,
|
|
228
210
|
s,
|
|
229
|
-
|
|
211
|
+
d
|
|
230
212
|
);
|
|
231
|
-
if (
|
|
232
|
-
return
|
|
213
|
+
if (f !== void 0)
|
|
214
|
+
return f;
|
|
233
215
|
}
|
|
234
|
-
const S = /* @__PURE__ */ new Map(), E = (
|
|
235
|
-
const
|
|
236
|
-
return S.has(
|
|
216
|
+
const S = /* @__PURE__ */ new Map(), E = (d, f, N) => {
|
|
217
|
+
const m = `${d === e ? "o" : "n"}:${f}`;
|
|
218
|
+
return S.has(m) || S.set(m, $(d, f, r)), S.get(m);
|
|
237
219
|
};
|
|
238
220
|
if (o)
|
|
239
|
-
return
|
|
221
|
+
return Le(
|
|
240
222
|
e,
|
|
241
223
|
t,
|
|
242
224
|
n,
|
|
243
225
|
r,
|
|
244
226
|
l,
|
|
245
227
|
h,
|
|
246
|
-
|
|
228
|
+
g,
|
|
247
229
|
s,
|
|
248
230
|
c,
|
|
249
231
|
E
|
|
250
232
|
);
|
|
251
|
-
const
|
|
233
|
+
const p = De(
|
|
252
234
|
e,
|
|
253
235
|
t,
|
|
254
236
|
n,
|
|
@@ -256,53 +238,53 @@ function be(e, t, n, r, i, s, a = ".", c = {}) {
|
|
|
256
238
|
l,
|
|
257
239
|
E
|
|
258
240
|
);
|
|
259
|
-
return c.boundary ?
|
|
241
|
+
return c.boundary ? O(t, p, c.boundary) : p;
|
|
260
242
|
}
|
|
261
|
-
function
|
|
243
|
+
function be(e, t, n, r, i, s) {
|
|
262
244
|
const a = e.length, c = t.length;
|
|
263
245
|
let o = 0, l = 0, h = c;
|
|
264
|
-
for (let
|
|
265
|
-
let
|
|
266
|
-
for (let
|
|
246
|
+
for (let f = 0; f < a; f++) {
|
|
247
|
+
let N = -1;
|
|
248
|
+
for (let m = o; m < c; m++)
|
|
267
249
|
if (r(
|
|
268
|
-
e[
|
|
269
|
-
t[
|
|
250
|
+
e[f],
|
|
251
|
+
t[m],
|
|
270
252
|
{
|
|
271
253
|
oldValue: e,
|
|
272
254
|
newValue: t,
|
|
273
255
|
typedRange: i,
|
|
274
|
-
oldIndex:
|
|
275
|
-
newIndex:
|
|
256
|
+
oldIndex: f,
|
|
257
|
+
newIndex: m
|
|
276
258
|
}
|
|
277
259
|
)) {
|
|
278
|
-
|
|
260
|
+
N = m;
|
|
279
261
|
break;
|
|
280
262
|
}
|
|
281
|
-
|
|
263
|
+
N !== -1 && (o = N + 1, f < n ? l = N + 1 : h === c && /\d/.test(e[f]) && (h = N));
|
|
282
264
|
}
|
|
283
265
|
if (l > h) return h;
|
|
284
|
-
const
|
|
266
|
+
const g = t.length < e.length || i !== void 0 && i.isDelete === !1;
|
|
285
267
|
let u, S = !1, E = !1;
|
|
286
|
-
if (
|
|
268
|
+
if (g) {
|
|
287
269
|
u = l;
|
|
288
|
-
const
|
|
289
|
-
|
|
270
|
+
const f = s.thousandSeparator, N = s.decimalSeparator ?? ".", m = u < t.length ? t[u] : "";
|
|
271
|
+
f && m === f ? (n > 0 ? e[n - 1] : "") === f ? (u = h, S = !0) : E = !0 : m === N && (E = !0);
|
|
290
272
|
} else
|
|
291
273
|
u = n - l < h - n ? l : h;
|
|
292
|
-
const
|
|
274
|
+
const p = g && !S ? "left" : "right";
|
|
293
275
|
if (s.boundary)
|
|
294
|
-
return E ? u :
|
|
295
|
-
const
|
|
296
|
-
if (!E &&
|
|
297
|
-
if (
|
|
298
|
-
for (; u > 0 && t[u] ===
|
|
276
|
+
return E ? u : O(t, u, s.boundary, p);
|
|
277
|
+
const d = s.thousandSeparator;
|
|
278
|
+
if (!E && d && u >= 0 && u < t.length && t[u] === d)
|
|
279
|
+
if (g && !S)
|
|
280
|
+
for (; u > 0 && t[u] === d; ) u--;
|
|
299
281
|
else
|
|
300
|
-
for (; u < t.length && t[u] ===
|
|
282
|
+
for (; u < t.length && t[u] === d; ) u++;
|
|
301
283
|
return u;
|
|
302
284
|
}
|
|
303
|
-
function
|
|
285
|
+
function Le(e, t, n, r, i, s, a, c, o = {}, l = $) {
|
|
304
286
|
if (i)
|
|
305
|
-
return
|
|
287
|
+
return Ne(
|
|
306
288
|
e,
|
|
307
289
|
t,
|
|
308
290
|
n,
|
|
@@ -310,7 +292,7 @@ function Ne(e, t, n, r, i, s, a, c, o = {}, l = $) {
|
|
|
310
292
|
a,
|
|
311
293
|
l
|
|
312
294
|
);
|
|
313
|
-
const h = l(e, n, r),
|
|
295
|
+
const h = l(e, n, r), g = l(e, e.length, r), u = l(t, t.length, r), S = g - u, E = $e(
|
|
314
296
|
e,
|
|
315
297
|
n,
|
|
316
298
|
r,
|
|
@@ -319,22 +301,22 @@ function Ne(e, t, n, r, i, s, a, c, o = {}, l = $) {
|
|
|
319
301
|
s,
|
|
320
302
|
c,
|
|
321
303
|
l
|
|
322
|
-
),
|
|
304
|
+
), p = s === -1 || n <= s, d = ve(
|
|
323
305
|
t,
|
|
324
306
|
E,
|
|
325
307
|
r,
|
|
326
308
|
S,
|
|
327
309
|
c,
|
|
328
|
-
|
|
310
|
+
p,
|
|
329
311
|
a,
|
|
330
312
|
l
|
|
331
313
|
);
|
|
332
|
-
return o.boundary ?
|
|
314
|
+
return o.boundary ? O(t, d, o.boundary) : d;
|
|
333
315
|
}
|
|
334
|
-
function
|
|
316
|
+
function Ne(e, t, n, r, i, s = $) {
|
|
335
317
|
const a = n + 1;
|
|
336
318
|
if (a < e.length) {
|
|
337
|
-
const c = s(e, a, r), o =
|
|
319
|
+
const c = s(e, a, r), o = ge(
|
|
338
320
|
t,
|
|
339
321
|
c,
|
|
340
322
|
r
|
|
@@ -343,14 +325,14 @@ function $e(e, t, n, r, i, s = $) {
|
|
|
343
325
|
}
|
|
344
326
|
return n;
|
|
345
327
|
}
|
|
346
|
-
function
|
|
328
|
+
function $e(e, t, n, r, i, s, a, c = $) {
|
|
347
329
|
if (a) {
|
|
348
330
|
const { start: l, isDelete: h } = a;
|
|
349
331
|
return h ? c(e, l, n) : Math.max(0, c(e, l, n));
|
|
350
332
|
}
|
|
351
333
|
return t > 0 && e[t - 1] === n && i > 0 ? r + 1 : r;
|
|
352
334
|
}
|
|
353
|
-
function
|
|
335
|
+
function H(e, t, n, r, i, s, a = $) {
|
|
354
336
|
if (t > 0 && t < e.length && a(e, t, r) === n) {
|
|
355
337
|
if (e[t] === r && s && i > 0 && t < e.length - 1)
|
|
356
338
|
return t + 1;
|
|
@@ -359,16 +341,16 @@ function K(e, t, n, r, i, s, a = $) {
|
|
|
359
341
|
}
|
|
360
342
|
return t;
|
|
361
343
|
}
|
|
362
|
-
function
|
|
344
|
+
function ve(e, t, n, r, i, s, a, c = $) {
|
|
363
345
|
if (s && a !== -1) {
|
|
364
346
|
const l = e.substring(0, a), h = c(l, l.length, n);
|
|
365
347
|
if (t <= h) {
|
|
366
|
-
const
|
|
348
|
+
const g = R(
|
|
367
349
|
l,
|
|
368
350
|
t,
|
|
369
351
|
n
|
|
370
352
|
);
|
|
371
|
-
return
|
|
353
|
+
return H(l, g, t, n, r, i, c);
|
|
372
354
|
}
|
|
373
355
|
}
|
|
374
356
|
const o = R(
|
|
@@ -376,23 +358,23 @@ function De(e, t, n, r, i, s, a, c = $) {
|
|
|
376
358
|
t,
|
|
377
359
|
n
|
|
378
360
|
);
|
|
379
|
-
return
|
|
361
|
+
return H(e, o, t, n, r, i, c);
|
|
380
362
|
}
|
|
381
|
-
function
|
|
363
|
+
function De(e, t, n, r, i, s = $) {
|
|
382
364
|
const a = n >= e.length, c = s(e, n, r), o = s(e, e.length, r), l = s(t, t.length, r);
|
|
383
365
|
if (a || c === o)
|
|
384
366
|
return t.length;
|
|
385
367
|
const h = l - o;
|
|
386
|
-
let
|
|
387
|
-
h > 0 && !a && c < o && (
|
|
368
|
+
let g = c;
|
|
369
|
+
h > 0 && !a && c < o && (g = c + 1);
|
|
388
370
|
const u = R(
|
|
389
371
|
t,
|
|
390
|
-
|
|
372
|
+
g,
|
|
391
373
|
r
|
|
392
374
|
);
|
|
393
375
|
return i && !V(t, u, r) ? Math.max(0, u - 1) : u;
|
|
394
376
|
}
|
|
395
|
-
function
|
|
377
|
+
function Ce(e, t, n) {
|
|
396
378
|
const { selectionStart: r, selectionEnd: i, endOffset: s = 0 } = e;
|
|
397
379
|
if (r !== i) {
|
|
398
380
|
const h = i - r;
|
|
@@ -421,7 +403,7 @@ function we(e, t, n) {
|
|
|
421
403
|
isDelete: !1
|
|
422
404
|
};
|
|
423
405
|
}
|
|
424
|
-
function
|
|
406
|
+
function we(e, t) {
|
|
425
407
|
if (e === t)
|
|
426
408
|
return;
|
|
427
409
|
let n = 0;
|
|
@@ -439,7 +421,7 @@ function ye(e, t) {
|
|
|
439
421
|
isDelete: s > a
|
|
440
422
|
};
|
|
441
423
|
}
|
|
442
|
-
function
|
|
424
|
+
function K(e, t) {
|
|
443
425
|
if (e.value = e.value, e === null)
|
|
444
426
|
return !1;
|
|
445
427
|
if (e.createTextRange) {
|
|
@@ -448,16 +430,16 @@ function q(e, t) {
|
|
|
448
430
|
}
|
|
449
431
|
return e.selectionStart !== null || e.selectionStart === 0 ? (e.focus(), e.setSelectionRange(t, t), !0) : (e.focus(), !1);
|
|
450
432
|
}
|
|
451
|
-
function
|
|
452
|
-
return e.selectionStart === 0 && e.selectionEnd === e.value.length ? null : (
|
|
453
|
-
e.value === n && e.selectionStart !== t &&
|
|
433
|
+
function ye(e, t, n) {
|
|
434
|
+
return e.selectionStart === 0 && e.selectionEnd === e.value.length ? null : (K(e, t), setTimeout(() => {
|
|
435
|
+
e.value === n && e.selectionStart !== t && K(e, t);
|
|
454
436
|
}, 0));
|
|
455
437
|
}
|
|
456
|
-
function
|
|
438
|
+
function Ie(e) {
|
|
457
439
|
return Math.max(e.selectionStart, e.selectionEnd);
|
|
458
440
|
}
|
|
459
|
-
function
|
|
460
|
-
if ((n == null ? void 0 : n.formatOn) !==
|
|
441
|
+
function Me(e, t, n) {
|
|
442
|
+
if ((n == null ? void 0 : n.formatOn) !== b.Change || !n.thousandSeparator)
|
|
461
443
|
return;
|
|
462
444
|
const { selectionStart: r, selectionEnd: i, value: s } = t;
|
|
463
445
|
if (r === null || i === null || r !== i)
|
|
@@ -465,27 +447,27 @@ function Ie(e, t, n) {
|
|
|
465
447
|
const { key: a } = e, c = n.thousandSeparator;
|
|
466
448
|
a === "Backspace" && r > 0 && s[r - 1] === c && t.setSelectionRange(r - 1, r - 1), a === "Delete" && s[r] === c && t.setSelectionRange(r + 1, r + 1);
|
|
467
449
|
}
|
|
468
|
-
function
|
|
450
|
+
function F(e, t, n, r, i, s, a) {
|
|
469
451
|
if (!i) return;
|
|
470
452
|
const { selectionStart: c = 0, selectionEnd: o = 0, endOffset: l = 0 } = i;
|
|
471
|
-
let h =
|
|
453
|
+
let h = Ce(
|
|
472
454
|
{ selectionStart: c, selectionEnd: o, endOffset: l },
|
|
473
455
|
t,
|
|
474
456
|
n
|
|
475
457
|
);
|
|
476
|
-
if (h || (h =
|
|
477
|
-
const
|
|
458
|
+
if (h || (h = we(t, n)), !h) return;
|
|
459
|
+
const g = Ee(n, {
|
|
478
460
|
thousandSeparator: (a == null ? void 0 : a.thousandSeparator) ?? s.thousandSeparator,
|
|
479
461
|
decimalSeparator: s.decimalSeparator
|
|
480
462
|
}), u = {
|
|
481
463
|
thousandSeparator: (a == null ? void 0 : a.thousandSeparator) ?? s.thousandSeparator,
|
|
482
464
|
decimalSeparator: s.decimalSeparator,
|
|
483
|
-
isCharacterEquivalent: (
|
|
484
|
-
const
|
|
485
|
-
return
|
|
465
|
+
isCharacterEquivalent: (d, f) => {
|
|
466
|
+
const N = (a == null ? void 0 : a.thousandSeparator) ?? s.thousandSeparator;
|
|
467
|
+
return N && d === N ? !1 : d === f;
|
|
486
468
|
},
|
|
487
|
-
boundary:
|
|
488
|
-
}, S = (a == null ? void 0 : a.thousandSeparator) ?? s.thousandSeparator ?? ",", E = (a == null ? void 0 : a.ThousandStyle) ??
|
|
469
|
+
boundary: g
|
|
470
|
+
}, S = (a == null ? void 0 : a.thousandSeparator) ?? s.thousandSeparator ?? ",", E = (a == null ? void 0 : a.ThousandStyle) ?? L.None, p = me(
|
|
489
471
|
t,
|
|
490
472
|
n,
|
|
491
473
|
r,
|
|
@@ -495,26 +477,26 @@ function Re(e, t, n, r, i, s, a) {
|
|
|
495
477
|
s.decimalSeparator,
|
|
496
478
|
u
|
|
497
479
|
);
|
|
498
|
-
|
|
480
|
+
ye(e, p, n);
|
|
499
481
|
}
|
|
500
482
|
const Te = (e, t = !1, n = ".") => {
|
|
501
|
-
const r = y(n), i =
|
|
483
|
+
const r = y(n), i = _(`[^0-9${r}]`, "g");
|
|
502
484
|
if (!t)
|
|
503
485
|
return e.replace(i, "");
|
|
504
486
|
const s = e.startsWith("-"), a = e.replace(i, "");
|
|
505
487
|
return s && (a.length > 0 || e === "-") ? "-" + a : a;
|
|
506
|
-
},
|
|
507
|
-
function
|
|
508
|
-
return !e.includes("e") && !e.includes("E") ? e : e.replace(
|
|
488
|
+
}, Ae = /([+-]?\d+\.?\d*)[eE]([+-]?\d+)/g, ee = /^0+$/, T = /\.?0+$/;
|
|
489
|
+
function Re(e) {
|
|
490
|
+
return !e.includes("e") && !e.includes("E") ? e : e.replace(Ae, (t, n, r) => {
|
|
509
491
|
const i = parseInt(r, 10);
|
|
510
492
|
if (i === 0) return n;
|
|
511
|
-
const s = n.startsWith("-"), a = s ? n.slice(1) : n, [c, o = ""] = a.split("."), l = i > 0 ?
|
|
493
|
+
const s = n.startsWith("-"), a = s ? n.slice(1) : n, [c, o = ""] = a.split("."), l = i > 0 ? _e(c, o, i) : xe(c, o, Math.abs(i));
|
|
512
494
|
return s ? "-" + l : l;
|
|
513
495
|
});
|
|
514
496
|
}
|
|
515
|
-
function
|
|
497
|
+
function _e(e, t, n) {
|
|
516
498
|
const r = e + t;
|
|
517
|
-
if (r === "0" ||
|
|
499
|
+
if (r === "0" || ee.test(r))
|
|
518
500
|
return "0";
|
|
519
501
|
const i = t.length;
|
|
520
502
|
if (n <= i) {
|
|
@@ -524,37 +506,37 @@ function Oe(e, t, n) {
|
|
|
524
506
|
const s = n - i;
|
|
525
507
|
return r + "0".repeat(s);
|
|
526
508
|
}
|
|
527
|
-
function
|
|
509
|
+
function xe(e, t, n) {
|
|
528
510
|
const r = e + t;
|
|
529
|
-
if (r === "0" ||
|
|
511
|
+
if (r === "0" || ee.test(r))
|
|
530
512
|
return "0";
|
|
531
513
|
const s = e.length - n;
|
|
532
514
|
if (s <= 0) {
|
|
533
515
|
const a = Math.abs(s), c = `0.${"0".repeat(a)}${r}`;
|
|
534
|
-
return
|
|
516
|
+
return A(c);
|
|
535
517
|
}
|
|
536
518
|
if (s < e.length) {
|
|
537
519
|
const a = r.slice(0, s), c = r.slice(s), o = `${a}.${c}`;
|
|
538
|
-
return
|
|
520
|
+
return A(o);
|
|
539
521
|
}
|
|
540
|
-
return
|
|
522
|
+
return A(r);
|
|
541
523
|
}
|
|
542
|
-
function
|
|
524
|
+
function A(e) {
|
|
543
525
|
if (!e.includes("."))
|
|
544
526
|
return e;
|
|
545
527
|
if (e === "0.")
|
|
546
528
|
return "0";
|
|
547
529
|
if (e.startsWith("0.")) {
|
|
548
|
-
const t = e.replace(
|
|
530
|
+
const t = e.replace(T, "");
|
|
549
531
|
return t === "0" ? "0" : t || "0";
|
|
550
532
|
}
|
|
551
533
|
if (e.startsWith("-0.")) {
|
|
552
|
-
const t = e.replace(
|
|
534
|
+
const t = e.replace(T, "");
|
|
553
535
|
return t === "-0" || t === "0" ? "0" : t || "0";
|
|
554
536
|
}
|
|
555
|
-
return e.replace(
|
|
537
|
+
return e.replace(T, "") || e;
|
|
556
538
|
}
|
|
557
|
-
const
|
|
539
|
+
const Oe = /(\d+\.?\d*)\s*([kmbt])/gi, Be = /^0+/, Ge = /^(-?)0+([1-9])/, ke = /^-?0+$/, Ze = /\.?0+$/, We = {
|
|
558
540
|
k: 3,
|
|
559
541
|
// Thousand
|
|
560
542
|
m: 6,
|
|
@@ -564,12 +546,12 @@ const Be = /(\d+\.?\d*)\s*([kmbt])/gi, Ze = /^0+/, ke = /^(-?)0+([1-9])/, We = /
|
|
|
564
546
|
t: 12
|
|
565
547
|
// Trillion
|
|
566
548
|
};
|
|
567
|
-
function
|
|
568
|
-
return e.replace(
|
|
569
|
-
const i = r.toLowerCase(), s =
|
|
549
|
+
function Ue(e) {
|
|
550
|
+
return e.replace(Oe, (t, n, r) => {
|
|
551
|
+
const i = r.toLowerCase(), s = We[i];
|
|
570
552
|
if (!s)
|
|
571
553
|
return t;
|
|
572
|
-
const [a, c = ""] = n.split("."), o = a.replace(
|
|
554
|
+
const [a, c = ""] = n.split("."), o = a.replace(Be, "") || "0";
|
|
573
555
|
let l;
|
|
574
556
|
if (c.length === 0)
|
|
575
557
|
l = o + "0".repeat(s);
|
|
@@ -577,13 +559,13 @@ function Je(e) {
|
|
|
577
559
|
const h = s - c.length;
|
|
578
560
|
l = o + c + "0".repeat(h);
|
|
579
561
|
} else {
|
|
580
|
-
const h = c.slice(0, s),
|
|
581
|
-
l = o + h + "." +
|
|
562
|
+
const h = c.slice(0, s), g = c.slice(s);
|
|
563
|
+
l = o + h + "." + g;
|
|
582
564
|
}
|
|
583
|
-
return l = l.replace(
|
|
565
|
+
return l = l.replace(Ge, "$1$2"), ke.test(l) && (l = "0"), l.includes(".") && (l = l.replace(Ze, "")), l;
|
|
584
566
|
});
|
|
585
567
|
}
|
|
586
|
-
function
|
|
568
|
+
function ze(e) {
|
|
587
569
|
if (!e || e === "0" || e === "-0" || e === "-" || e === ".")
|
|
588
570
|
return e;
|
|
589
571
|
const t = e.startsWith("-"), n = t ? e.slice(1) : e;
|
|
@@ -603,22 +585,22 @@ function Pe(e) {
|
|
|
603
585
|
}
|
|
604
586
|
return e;
|
|
605
587
|
}
|
|
606
|
-
function
|
|
588
|
+
function Je(e) {
|
|
607
589
|
return e.replace(/[\s\u200B]/g, "");
|
|
608
590
|
}
|
|
609
591
|
function v(e, t) {
|
|
610
|
-
const n =
|
|
592
|
+
const n = ae(t);
|
|
611
593
|
return e.replace(n, "");
|
|
612
594
|
}
|
|
613
|
-
const
|
|
614
|
-
let n =
|
|
615
|
-
return t != null && t.thousandSeparator && (n = v(n, t.thousandSeparator)), t != null && t.enableCompactNotation && (n =
|
|
595
|
+
const Pe = (e, t) => {
|
|
596
|
+
let n = Je(e);
|
|
597
|
+
return t != null && t.thousandSeparator && (n = v(n, t.thousandSeparator)), t != null && t.enableCompactNotation && (n = Ue(n)), n = Re(n), n = Te(
|
|
616
598
|
n,
|
|
617
599
|
t == null ? void 0 : t.enableNegative,
|
|
618
600
|
t == null ? void 0 : t.decimalSeparator
|
|
619
|
-
), n =
|
|
601
|
+
), n = oe(n, t == null ? void 0 : t.decimalSeparator), t != null && t.enableLeadingZeros || (n = ze(n)), n;
|
|
620
602
|
};
|
|
621
|
-
function
|
|
603
|
+
function Xe(e, t, n) {
|
|
622
604
|
return {
|
|
623
605
|
enableCompactNotation: e == null ? void 0 : e.enableCompactNotation,
|
|
624
606
|
enableNegative: e == null ? void 0 : e.enableNegative,
|
|
@@ -627,30 +609,91 @@ function Ke(e, t, n) {
|
|
|
627
609
|
thousandSeparator: n ? t.thousandSeparator : void 0
|
|
628
610
|
};
|
|
629
611
|
}
|
|
630
|
-
function
|
|
631
|
-
const i =
|
|
612
|
+
function M(e, t, n, r) {
|
|
613
|
+
const i = x(n), s = r ?? (n == null ? void 0 : n.formatOn) === b.Change, a = Pe(
|
|
632
614
|
e,
|
|
633
|
-
|
|
634
|
-
), c =
|
|
615
|
+
Xe(n, i, s)
|
|
616
|
+
), c = le(
|
|
635
617
|
a,
|
|
636
618
|
t,
|
|
637
619
|
i.decimalSeparator
|
|
638
|
-
), o = (n == null ? void 0 : n.decimalMinLength) ?? 0, l =
|
|
620
|
+
), o = (n == null ? void 0 : n.decimalMinLength) ?? 0, l = he(
|
|
639
621
|
c,
|
|
640
622
|
o,
|
|
641
623
|
i.decimalSeparator
|
|
642
624
|
);
|
|
643
|
-
return { formatted:
|
|
625
|
+
return { formatted: fe(l, n, i), raw: l };
|
|
644
626
|
}
|
|
645
627
|
function ft(e, t, n) {
|
|
646
628
|
const r = !!(n != null && n.thousandSeparator);
|
|
647
|
-
return
|
|
629
|
+
return M(
|
|
648
630
|
e,
|
|
649
631
|
t,
|
|
650
632
|
n,
|
|
651
633
|
r
|
|
652
634
|
);
|
|
653
635
|
}
|
|
636
|
+
function je(e, t, n) {
|
|
637
|
+
if (e.inputType === "insertFromPaste" || e.inputType === "insertFromDrop")
|
|
638
|
+
return null;
|
|
639
|
+
const r = e.target, i = r.value, s = r.selectionStart ?? 0, a = r.selectionEnd ?? 0, c = x(n);
|
|
640
|
+
let o = e.data ?? "";
|
|
641
|
+
if (e.inputType === "insertText" && (e.data === "," || e.data === ".")) {
|
|
642
|
+
const d = c.decimalSeparator;
|
|
643
|
+
if ((i.slice(0, s) + i.slice(a)).includes(d))
|
|
644
|
+
return e.preventDefault(), null;
|
|
645
|
+
o = d;
|
|
646
|
+
}
|
|
647
|
+
let l, h;
|
|
648
|
+
switch (e.inputType) {
|
|
649
|
+
case "insertText": {
|
|
650
|
+
l = i.slice(0, s) + o + i.slice(a), h = s + o.length;
|
|
651
|
+
break;
|
|
652
|
+
}
|
|
653
|
+
case "deleteContentBackward": {
|
|
654
|
+
if (s !== a)
|
|
655
|
+
l = i.slice(0, s) + i.slice(a), h = s;
|
|
656
|
+
else {
|
|
657
|
+
const d = Math.max(0, s - 1);
|
|
658
|
+
l = i.slice(0, d) + i.slice(s), h = d;
|
|
659
|
+
}
|
|
660
|
+
break;
|
|
661
|
+
}
|
|
662
|
+
case "deleteContentForward": {
|
|
663
|
+
s !== a ? (l = i.slice(0, s) + i.slice(a), h = s) : (l = i.slice(0, s) + i.slice(s + 1), h = s);
|
|
664
|
+
break;
|
|
665
|
+
}
|
|
666
|
+
case "deleteByCut":
|
|
667
|
+
case "deleteByDrag": {
|
|
668
|
+
l = i.slice(0, s) + i.slice(a), h = s;
|
|
669
|
+
break;
|
|
670
|
+
}
|
|
671
|
+
default:
|
|
672
|
+
return null;
|
|
673
|
+
}
|
|
674
|
+
e.preventDefault();
|
|
675
|
+
const g = (n == null ? void 0 : n.formatOn) === b.Change, { formatted: u, raw: S } = M(
|
|
676
|
+
l,
|
|
677
|
+
t,
|
|
678
|
+
n,
|
|
679
|
+
g
|
|
680
|
+
);
|
|
681
|
+
r.setRangeText(u, 0, i.length, "end");
|
|
682
|
+
const E = e.inputType === "deleteContentForward" ? 1 : 0;
|
|
683
|
+
return l !== u ? F(
|
|
684
|
+
r,
|
|
685
|
+
l,
|
|
686
|
+
u,
|
|
687
|
+
h,
|
|
688
|
+
{
|
|
689
|
+
selectionStart: s,
|
|
690
|
+
selectionEnd: a,
|
|
691
|
+
endOffset: E
|
|
692
|
+
},
|
|
693
|
+
c,
|
|
694
|
+
n
|
|
695
|
+
) : r.setSelectionRange(h, h), { formatted: u, raw: S };
|
|
696
|
+
}
|
|
654
697
|
function qe(e, t, n) {
|
|
655
698
|
if (e === "Backspace" || e === "Delete")
|
|
656
699
|
return e === "Delete" && t === n ? {
|
|
@@ -660,21 +703,17 @@ function qe(e, t, n) {
|
|
|
660
703
|
};
|
|
661
704
|
}
|
|
662
705
|
function He(e, t) {
|
|
663
|
-
const
|
|
664
|
-
|
|
665
|
-
e.preventDefault();
|
|
666
|
-
return;
|
|
667
|
-
}
|
|
668
|
-
return Ie(e, r, t), qe(e.key, r.selectionStart, r.selectionEnd);
|
|
706
|
+
const n = e.target;
|
|
707
|
+
return Me(e, n, t), qe(e.key, n.selectionStart, n.selectionEnd);
|
|
669
708
|
}
|
|
670
|
-
function
|
|
671
|
-
const i = e.target, s = i.value, a =
|
|
709
|
+
function Ke(e, t, n, r) {
|
|
710
|
+
const i = e.target, s = i.value, a = Ie(i), c = x(r), o = (r == null ? void 0 : r.formatOn) === b.Change, { formatted: l, raw: h } = M(
|
|
672
711
|
s,
|
|
673
712
|
t,
|
|
674
713
|
r,
|
|
675
714
|
o
|
|
676
715
|
);
|
|
677
|
-
return i.value = l, s !== l &&
|
|
716
|
+
return i.value = l, s !== l && F(
|
|
678
717
|
i,
|
|
679
718
|
s,
|
|
680
719
|
l,
|
|
@@ -684,33 +723,33 @@ function Ye(e, t, n, r) {
|
|
|
684
723
|
r
|
|
685
724
|
), { formatted: l, raw: h };
|
|
686
725
|
}
|
|
687
|
-
function
|
|
726
|
+
function Ye(e, t, n, r) {
|
|
688
727
|
const i = r - n;
|
|
689
728
|
return e + t + i;
|
|
690
729
|
}
|
|
691
|
-
function
|
|
730
|
+
function Qe(e, t, n) {
|
|
692
731
|
var u;
|
|
693
732
|
e.preventDefault();
|
|
694
|
-
const r = e.target, { value: i, selectionStart: s, selectionEnd: a } = r, c = ((u = e.clipboardData) == null ? void 0 : u.getData("text/plain")) || "", o = i.slice(0, s || 0) + c + i.slice(a || 0), { formatted: l, raw: h } =
|
|
733
|
+
const r = e.target, { value: i, selectionStart: s, selectionEnd: a } = r, c = ((u = e.clipboardData) == null ? void 0 : u.getData("text/plain")) || "", o = i.slice(0, s || 0) + c + i.slice(a || 0), { formatted: l, raw: h } = M(
|
|
695
734
|
o,
|
|
696
735
|
t,
|
|
697
736
|
n,
|
|
698
737
|
!0
|
|
699
738
|
);
|
|
700
739
|
r.value = l;
|
|
701
|
-
const
|
|
740
|
+
const g = Ye(
|
|
702
741
|
s || 0,
|
|
703
742
|
c.length,
|
|
704
743
|
o.length,
|
|
705
744
|
l.length
|
|
706
745
|
);
|
|
707
|
-
return r.setSelectionRange(
|
|
746
|
+
return r.setSelectionRange(g, g), { formatted: l, raw: h };
|
|
708
747
|
}
|
|
709
|
-
function
|
|
748
|
+
function Ve(e, t) {
|
|
710
749
|
const n = y(e);
|
|
711
750
|
return t ? `^-?[0-9]*[${n}]?[0-9]*$` : `^[0-9]*[${n}]?[0-9]*$`;
|
|
712
751
|
}
|
|
713
|
-
function
|
|
752
|
+
function Fe(e) {
|
|
714
753
|
var t, n;
|
|
715
754
|
try {
|
|
716
755
|
const i = new Intl.NumberFormat(e).formatToParts(123456789e-2);
|
|
@@ -722,18 +761,18 @@ function et(e) {
|
|
|
722
761
|
return { thousandSeparator: ",", decimalSeparator: "." };
|
|
723
762
|
}
|
|
724
763
|
}
|
|
764
|
+
function et(e, t) {
|
|
765
|
+
if (!e) return t;
|
|
766
|
+
const r = Fe(e === !0 ? void 0 : e);
|
|
767
|
+
return {
|
|
768
|
+
thousandSeparator: t.thousandSeparator ?? r.thousandSeparator,
|
|
769
|
+
decimalSeparator: t.decimalSeparator ?? r.decimalSeparator
|
|
770
|
+
};
|
|
771
|
+
}
|
|
725
772
|
function tt(e) {
|
|
726
|
-
|
|
727
|
-
if (e.thousandStyle === p.Locale || e.decimalSeparator === "auto") {
|
|
728
|
-
const s = et();
|
|
729
|
-
e.thousandStyle === p.Locale && (t = e.thousandSeparator ?? s.thousandSeparator, n = e.decimalSeparator === "auto" || e.decimalSeparator === void 0 ? s.decimalSeparator : e.decimalSeparator, r = p.Thousand), e.decimalSeparator === "auto" && (n = s.decimalSeparator);
|
|
730
|
-
}
|
|
731
|
-
return { thousandSeparator: t, thousandStyle: r, decimalSeparator: n };
|
|
773
|
+
nt(e.decimalMaxLength), rt(e.decimalMinLength), it(e.decimalMinLength, e.decimalMaxLength), st(e.formatOn), at(e.thousandSeparator), ct(e.thousandStyle), lt(e.decimalSeparator), ot(e.thousandSeparator, e.decimalSeparator), I("enableCompactNotation", e.enableCompactNotation), I("enableNegative", e.enableNegative), I("enableLeadingZeros", e.enableLeadingZeros), I("rawValueMode", e.rawValueMode), ht(e.onChange);
|
|
732
774
|
}
|
|
733
775
|
function nt(e) {
|
|
734
|
-
rt(e.decimalMaxLength), it(e.decimalMinLength), st(e.decimalMinLength, e.decimalMaxLength), at(e.formatOn), ct(e.thousandSeparator), lt(e.thousandStyle), ot(e.decimalSeparator), ht(e.thousandSeparator, e.decimalSeparator), M("enableCompactNotation", e.enableCompactNotation), M("enableNegative", e.enableNegative), M("enableLeadingZeros", e.enableLeadingZeros), M("rawValueMode", e.rawValueMode), ut(e.onChange);
|
|
735
|
-
}
|
|
736
|
-
function rt(e) {
|
|
737
776
|
if (e !== void 0) {
|
|
738
777
|
if (typeof e != "number")
|
|
739
778
|
throw new Error(
|
|
@@ -749,7 +788,7 @@ function rt(e) {
|
|
|
749
788
|
);
|
|
750
789
|
}
|
|
751
790
|
}
|
|
752
|
-
function
|
|
791
|
+
function rt(e) {
|
|
753
792
|
if (e !== void 0) {
|
|
754
793
|
if (typeof e != "number")
|
|
755
794
|
throw new Error(
|
|
@@ -765,19 +804,19 @@ function it(e) {
|
|
|
765
804
|
);
|
|
766
805
|
}
|
|
767
806
|
}
|
|
768
|
-
function
|
|
807
|
+
function it(e, t) {
|
|
769
808
|
if (!(e === void 0 || t === void 0) && e > t)
|
|
770
809
|
throw new Error(
|
|
771
810
|
`decimalMinLength (${e}) cannot be greater than decimalMaxLength (${t}).`
|
|
772
811
|
);
|
|
773
812
|
}
|
|
774
|
-
function
|
|
775
|
-
if (e !== void 0 && e !==
|
|
813
|
+
function st(e) {
|
|
814
|
+
if (e !== void 0 && e !== b.Blur && e !== b.Change)
|
|
776
815
|
throw new Error(
|
|
777
|
-
`formatOn must be either ${
|
|
816
|
+
`formatOn must be either ${b.Blur} or ${b.Change}. Received: ${JSON.stringify(e)}`
|
|
778
817
|
);
|
|
779
818
|
}
|
|
780
|
-
function
|
|
819
|
+
function at(e) {
|
|
781
820
|
if (e !== void 0) {
|
|
782
821
|
if (typeof e != "string")
|
|
783
822
|
throw new Error(
|
|
@@ -793,14 +832,14 @@ function ct(e) {
|
|
|
793
832
|
);
|
|
794
833
|
}
|
|
795
834
|
}
|
|
796
|
-
function
|
|
797
|
-
if (e !== void 0 && !Object.values(
|
|
835
|
+
function ct(e) {
|
|
836
|
+
if (e !== void 0 && !Object.values(L).includes(e))
|
|
798
837
|
throw new Error(
|
|
799
|
-
`ThousandStyle must be one of: ${Object.values(
|
|
838
|
+
`ThousandStyle must be one of: ${Object.values(L).map((t) => `'${t}'`).join(", ")}. Received: ${JSON.stringify(e)}`
|
|
800
839
|
);
|
|
801
840
|
}
|
|
802
|
-
function
|
|
803
|
-
if (
|
|
841
|
+
function lt(e) {
|
|
842
|
+
if (e !== void 0) {
|
|
804
843
|
if (typeof e != "string")
|
|
805
844
|
throw new Error(
|
|
806
845
|
`decimalSeparator must be a string. Received: ${typeof e} (${JSON.stringify(e)})`
|
|
@@ -815,19 +854,19 @@ function ot(e) {
|
|
|
815
854
|
);
|
|
816
855
|
}
|
|
817
856
|
}
|
|
818
|
-
function
|
|
819
|
-
if (!(e === void 0 || t === void 0) &&
|
|
857
|
+
function ot(e, t) {
|
|
858
|
+
if (!(e === void 0 || t === void 0) && e === t)
|
|
820
859
|
throw new Error(
|
|
821
860
|
`Decimal separator can't be same as thousand separator. thousandSeparator: ${e}, decimalSeparator: ${t}`
|
|
822
861
|
);
|
|
823
862
|
}
|
|
824
|
-
function
|
|
863
|
+
function I(e, t) {
|
|
825
864
|
if (t !== void 0 && typeof t != "boolean")
|
|
826
865
|
throw new Error(
|
|
827
866
|
`${e} must be a boolean. Received: ${typeof t} (${JSON.stringify(t)})`
|
|
828
867
|
);
|
|
829
868
|
}
|
|
830
|
-
function
|
|
869
|
+
function ht(e) {
|
|
831
870
|
if (e !== void 0 && typeof e != "function")
|
|
832
871
|
throw new Error(
|
|
833
872
|
`onChange must be a function or undefined. Received: ${typeof e} (${JSON.stringify(e)})`
|
|
@@ -835,61 +874,63 @@ function ut(e) {
|
|
|
835
874
|
}
|
|
836
875
|
class gt {
|
|
837
876
|
constructor(t, {
|
|
838
|
-
decimalMaxLength: n =
|
|
839
|
-
decimalMinLength: r =
|
|
840
|
-
formatOn: i =
|
|
877
|
+
decimalMaxLength: n = B,
|
|
878
|
+
decimalMinLength: r = G,
|
|
879
|
+
formatOn: i = k,
|
|
841
880
|
thousandSeparator: s,
|
|
842
|
-
thousandStyle: a =
|
|
881
|
+
thousandStyle: a = Z,
|
|
843
882
|
decimalSeparator: c,
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
883
|
+
locale: o,
|
|
884
|
+
enableCompactNotation: l = W,
|
|
885
|
+
enableNegative: h = U,
|
|
886
|
+
enableLeadingZeros: g = z,
|
|
887
|
+
rawValueMode: u = J,
|
|
888
|
+
onChange: S,
|
|
889
|
+
...E
|
|
850
890
|
}) {
|
|
851
891
|
w(this, "element");
|
|
852
892
|
w(this, "resolvedOptions");
|
|
853
893
|
w(this, "rawValue", "");
|
|
854
894
|
w(this, "caretPositionBeforeChange");
|
|
855
|
-
|
|
895
|
+
tt({
|
|
856
896
|
decimalMaxLength: n,
|
|
857
897
|
decimalMinLength: r,
|
|
858
898
|
formatOn: i,
|
|
859
899
|
thousandSeparator: s,
|
|
860
900
|
thousandStyle: a,
|
|
861
901
|
decimalSeparator: c,
|
|
862
|
-
enableCompactNotation:
|
|
863
|
-
enableNegative:
|
|
864
|
-
enableLeadingZeros:
|
|
865
|
-
rawValueMode:
|
|
866
|
-
onChange:
|
|
902
|
+
enableCompactNotation: l,
|
|
903
|
+
enableNegative: h,
|
|
904
|
+
enableLeadingZeros: g,
|
|
905
|
+
rawValueMode: u,
|
|
906
|
+
onChange: S
|
|
867
907
|
});
|
|
868
|
-
const
|
|
908
|
+
const p = {
|
|
869
909
|
decimalMaxLength: n,
|
|
870
910
|
decimalMinLength: r,
|
|
871
|
-
onChange:
|
|
911
|
+
onChange: S,
|
|
872
912
|
formatOn: i,
|
|
873
913
|
thousandSeparator: s,
|
|
874
914
|
thousandStyle: a,
|
|
875
915
|
decimalSeparator: c,
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
916
|
+
locale: o,
|
|
917
|
+
enableCompactNotation: l,
|
|
918
|
+
enableNegative: h,
|
|
919
|
+
enableLeadingZeros: g,
|
|
920
|
+
rawValueMode: u,
|
|
921
|
+
...E
|
|
881
922
|
};
|
|
882
|
-
if (this.resolvedOptions = this.getResolvedOptions(
|
|
883
|
-
const
|
|
923
|
+
if (this.resolvedOptions = this.getResolvedOptions(p), this.createInputElement(t, p), this.setupEventListeners(), this.resolvedOptions.rawValueMode && this.element.value) {
|
|
924
|
+
const d = this.element.value, f = this.resolvedOptions.thousandSeparator ? v(d, this.resolvedOptions.thousandSeparator) : d;
|
|
884
925
|
this.rawValue = f, this.element.value = this.formatValueForDisplay(f);
|
|
885
926
|
} else if (this.element.value) {
|
|
886
|
-
const
|
|
887
|
-
this.element.value = this.formatValueForDisplay(
|
|
927
|
+
const d = this.element.value;
|
|
928
|
+
this.element.value = this.formatValueForDisplay(d);
|
|
888
929
|
}
|
|
889
930
|
}
|
|
890
931
|
createInputElement(t, n) {
|
|
891
932
|
this.element = document.createElement("input"), this.element.setAttribute("type", "text"), this.element.setAttribute("inputmode", "decimal"), this.element.setAttribute("spellcheck", "false"), this.element.setAttribute("autocomplete", "off");
|
|
892
|
-
const r =
|
|
933
|
+
const r = Ve(this.resolvedOptions.decimalSeparator, this.resolvedOptions.enableNegative);
|
|
893
934
|
this.element.setAttribute("pattern", r);
|
|
894
935
|
const {
|
|
895
936
|
decimalMaxLength: i,
|
|
@@ -898,41 +939,41 @@ class gt {
|
|
|
898
939
|
thousandSeparator: c,
|
|
899
940
|
thousandStyle: o,
|
|
900
941
|
decimalSeparator: l,
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
942
|
+
locale: h,
|
|
943
|
+
enableCompactNotation: g,
|
|
944
|
+
enableNegative: u,
|
|
945
|
+
enableLeadingZeros: S,
|
|
946
|
+
rawValueMode: E,
|
|
947
|
+
onChange: p,
|
|
948
|
+
value: d,
|
|
907
949
|
defaultValue: f,
|
|
908
|
-
type:
|
|
909
|
-
inputMode:
|
|
910
|
-
spellcheck:
|
|
911
|
-
autocomplete:
|
|
912
|
-
...
|
|
950
|
+
type: N,
|
|
951
|
+
inputMode: m,
|
|
952
|
+
spellcheck: te,
|
|
953
|
+
autocomplete: ut,
|
|
954
|
+
...ne
|
|
913
955
|
} = n;
|
|
914
|
-
Object.assign(this.element,
|
|
956
|
+
Object.assign(this.element, ne), d !== void 0 ? this.element.value = d : f !== void 0 && (this.element.defaultValue = f, this.element.value = f), t.appendChild(this.element);
|
|
915
957
|
}
|
|
916
958
|
setupEventListeners() {
|
|
917
|
-
this.element.addEventListener("input", this.handleChange.bind(this)), this.element.addEventListener("keydown", this.handleKeyDown.bind(this)), this.element.addEventListener("paste", this.handlePaste.bind(this)), this.resolvedOptions.formatOn ===
|
|
959
|
+
this.element.addEventListener("beforeinput", this.handleBeforeInput.bind(this)), this.element.addEventListener("input", this.handleChange.bind(this)), this.element.addEventListener("keydown", this.handleKeyDown.bind(this)), this.element.addEventListener("paste", this.handlePaste.bind(this)), this.resolvedOptions.formatOn === b.Blur && this.resolvedOptions.thousandSeparator && (this.element.addEventListener("focus", this.handleFocus.bind(this)), this.element.addEventListener("blur", this.handleBlur.bind(this)));
|
|
918
960
|
}
|
|
919
961
|
getResolvedOptions(t) {
|
|
920
|
-
const n =
|
|
962
|
+
const n = et(t.locale, {
|
|
921
963
|
thousandSeparator: t.thousandSeparator,
|
|
922
|
-
thousandStyle: t.thousandStyle,
|
|
923
964
|
decimalSeparator: t.decimalSeparator
|
|
924
965
|
});
|
|
925
966
|
return {
|
|
926
|
-
decimalMaxLength: t.decimalMaxLength ??
|
|
927
|
-
decimalMinLength: t.decimalMinLength ??
|
|
928
|
-
formatOn: t.formatOn ??
|
|
929
|
-
thousandSeparator: n.thousandSeparator,
|
|
930
|
-
thousandStyle:
|
|
931
|
-
decimalSeparator: n.decimalSeparator,
|
|
932
|
-
enableCompactNotation: t.enableCompactNotation ??
|
|
933
|
-
enableNegative: t.enableNegative ??
|
|
934
|
-
enableLeadingZeros: t.enableLeadingZeros ??
|
|
935
|
-
rawValueMode: t.rawValueMode ??
|
|
967
|
+
decimalMaxLength: t.decimalMaxLength ?? B,
|
|
968
|
+
decimalMinLength: t.decimalMinLength ?? G,
|
|
969
|
+
formatOn: t.formatOn ?? k,
|
|
970
|
+
thousandSeparator: n.thousandSeparator ?? se,
|
|
971
|
+
thousandStyle: t.thousandStyle ?? Z,
|
|
972
|
+
decimalSeparator: n.decimalSeparator ?? C,
|
|
973
|
+
enableCompactNotation: t.enableCompactNotation ?? W,
|
|
974
|
+
enableNegative: t.enableNegative ?? U,
|
|
975
|
+
enableLeadingZeros: t.enableLeadingZeros ?? z,
|
|
976
|
+
rawValueMode: t.rawValueMode ?? J,
|
|
936
977
|
onChange: t.onChange
|
|
937
978
|
};
|
|
938
979
|
}
|
|
@@ -959,7 +1000,7 @@ class gt {
|
|
|
959
1000
|
if (!t)
|
|
960
1001
|
return t;
|
|
961
1002
|
const { thousandSeparator: n, thousandStyle: r, enableLeadingZeros: i, decimalSeparator: s } = this.resolvedOptions;
|
|
962
|
-
return n && r !==
|
|
1003
|
+
return n && r !== L.None ? Q(
|
|
963
1004
|
t,
|
|
964
1005
|
n,
|
|
965
1006
|
r,
|
|
@@ -967,8 +1008,15 @@ class gt {
|
|
|
967
1008
|
s
|
|
968
1009
|
) : t;
|
|
969
1010
|
}
|
|
1011
|
+
handleBeforeInput(t) {
|
|
1012
|
+
je(
|
|
1013
|
+
t,
|
|
1014
|
+
this.resolvedOptions.decimalMaxLength,
|
|
1015
|
+
this.buildFormattingOptions()
|
|
1016
|
+
);
|
|
1017
|
+
}
|
|
970
1018
|
handleChange(t) {
|
|
971
|
-
const { formatted: n, raw: r } =
|
|
1019
|
+
const { formatted: n, raw: r } = Ke(
|
|
972
1020
|
t,
|
|
973
1021
|
this.resolvedOptions.decimalMaxLength,
|
|
974
1022
|
this.caretPositionBeforeChange,
|
|
@@ -993,20 +1041,20 @@ class gt {
|
|
|
993
1041
|
};
|
|
994
1042
|
}
|
|
995
1043
|
handlePaste(t) {
|
|
996
|
-
const { formatted: n, raw: r } =
|
|
1044
|
+
const { formatted: n, raw: r } = Qe(t, this.resolvedOptions.decimalMaxLength, this.buildFormattingOptions());
|
|
997
1045
|
this.handleValueChange(n, r);
|
|
998
1046
|
const i = new Event("input", { bubbles: !0, cancelable: !0 });
|
|
999
1047
|
this.element.dispatchEvent(i);
|
|
1000
1048
|
}
|
|
1001
1049
|
handleFocus(t) {
|
|
1002
|
-
if (this.resolvedOptions.formatOn ===
|
|
1050
|
+
if (this.resolvedOptions.formatOn === b.Blur && this.resolvedOptions.thousandSeparator) {
|
|
1003
1051
|
const n = t.target;
|
|
1004
1052
|
n.value = v(n.value, this.resolvedOptions.thousandSeparator);
|
|
1005
1053
|
}
|
|
1006
1054
|
}
|
|
1007
1055
|
handleBlur(t) {
|
|
1008
1056
|
const n = t.target, { thousandSeparator: r, thousandStyle: i } = this.resolvedOptions;
|
|
1009
|
-
if (r && i !==
|
|
1057
|
+
if (r && i !== L.None && n.value) {
|
|
1010
1058
|
const s = this.formatValueForDisplay(n.value);
|
|
1011
1059
|
n.value = s;
|
|
1012
1060
|
const a = this.resolvedOptions.rawValueMode ? v(s, r) : void 0;
|
|
@@ -1082,17 +1130,18 @@ class gt {
|
|
|
1082
1130
|
}
|
|
1083
1131
|
}
|
|
1084
1132
|
export {
|
|
1085
|
-
|
|
1133
|
+
b as FormatOn,
|
|
1086
1134
|
gt as NumoraInput,
|
|
1087
|
-
|
|
1088
|
-
|
|
1135
|
+
L as ThousandStyle,
|
|
1136
|
+
et as applyLocale,
|
|
1137
|
+
M as formatInputValue,
|
|
1089
1138
|
ft as formatValueForDisplay,
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1139
|
+
Ve as getNumoraPattern,
|
|
1140
|
+
Fe as getSeparatorsFromLocale,
|
|
1141
|
+
je as handleOnBeforeInputNumoraInput,
|
|
1142
|
+
Ke as handleOnChangeNumoraInput,
|
|
1093
1143
|
He as handleOnKeyDownNumoraInput,
|
|
1094
|
-
|
|
1144
|
+
Qe as handleOnPasteNumoraInput,
|
|
1095
1145
|
v as removeThousandSeparators,
|
|
1096
|
-
tt as
|
|
1097
|
-
nt as validateNumoraInputOptions
|
|
1146
|
+
tt as validateNumoraInputOptions
|
|
1098
1147
|
};
|