numora 3.4.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 +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +344 -297
- package/dist/utils/event-handlers.d.ts +14 -0
- 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
|
|
6
|
-
function
|
|
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
|
+
function y(e) {
|
|
7
7
|
return e.replace(/[-[\]/{}()*+?.\\^$|]/g, "\\$&");
|
|
8
8
|
}
|
|
9
9
|
const P = /* @__PURE__ */ new Map();
|
|
10
|
-
function
|
|
10
|
+
function _(e, t = "g") {
|
|
11
11
|
const n = `${e}:${t}`;
|
|
12
12
|
let r = P.get(n);
|
|
13
13
|
return r || (r = new RegExp(e, t), P.set(n, r)), r;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
const n =
|
|
17
|
-
return
|
|
15
|
+
function ae(e, t = "g") {
|
|
16
|
+
const n = y(e);
|
|
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
|
-
function ce(e, t) {
|
|
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 oe(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, l = s ?? c;
|
|
46
|
-
t.value = a.slice(0, c) + n + a.slice(l);
|
|
47
|
-
const o = c + 1;
|
|
48
|
-
return t.setSelectionRange(o, o), !0;
|
|
49
|
-
}
|
|
50
|
-
return !1;
|
|
51
|
-
}
|
|
52
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,45 +52,45 @@ const le = (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
|
-
const s = e.includes(i), a = e.startsWith("-"), c = a ? e.slice(1) : e, [
|
|
78
|
-
if (!
|
|
79
|
-
const u =
|
|
59
|
+
const s = e.includes(i), a = e.startsWith("-"), c = a ? e.slice(1) : e, [o, l] = c.split(i);
|
|
60
|
+
if (!o) {
|
|
61
|
+
const u = l ? `${i}${l}` : c;
|
|
80
62
|
return a ? `-${u}` : u;
|
|
81
63
|
}
|
|
82
|
-
if (r &&
|
|
83
|
-
const u =
|
|
64
|
+
if (r && o.startsWith("0") && o.length > 1) {
|
|
65
|
+
const u = o.match(ue);
|
|
84
66
|
if (u) {
|
|
85
|
-
const S = u[1], E =
|
|
67
|
+
const S = u[1], E = o.slice(S.length);
|
|
86
68
|
if (E) {
|
|
87
|
-
const p = X(E, t, n),
|
|
88
|
-
return s ?
|
|
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 = X(
|
|
93
|
-
return s ?
|
|
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
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
|
|
83
|
+
case L.Thousand:
|
|
102
84
|
return j(e, t, D.thousand.size);
|
|
103
|
-
case
|
|
104
|
-
return
|
|
105
|
-
case
|
|
85
|
+
case L.Lakh:
|
|
86
|
+
return de(e, t);
|
|
87
|
+
case L.Wan:
|
|
106
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;
|
|
@@ -123,11 +105,11 @@ function j(e, t, 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 = ".",
|
|
@@ -179,12 +161,12 @@ function pe(e, t = {}) {
|
|
|
179
161
|
a.fill(!1, c + 1, e.length + 1);
|
|
180
162
|
}
|
|
181
163
|
for (let c = 0; c < e.length; c++) {
|
|
182
|
-
const
|
|
183
|
-
(n &&
|
|
164
|
+
const o = e[c];
|
|
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,112 +187,112 @@ function x(e, t, n, r) {
|
|
|
205
187
|
}
|
|
206
188
|
return (t === -1 || t > i) && (t = i), t;
|
|
207
189
|
}
|
|
208
|
-
const
|
|
190
|
+
const q = /(\d+\.?\d*)\s*[kmbt]$/i, pe = (e, t) => e === t;
|
|
209
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
|
-
const
|
|
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
|
-
c.isCharacterEquivalent ||
|
|
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
|
-
if (
|
|
239
|
-
return
|
|
220
|
+
if (o)
|
|
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 p =
|
|
233
|
+
const p = De(
|
|
252
234
|
e,
|
|
253
235
|
t,
|
|
254
236
|
n,
|
|
255
237
|
r,
|
|
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
|
-
let
|
|
264
|
-
for (let
|
|
265
|
-
let
|
|
266
|
-
for (let
|
|
245
|
+
let o = 0, l = 0, h = c;
|
|
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
|
-
if (
|
|
284
|
-
const
|
|
265
|
+
if (l > h) return h;
|
|
266
|
+
const g = t.length < e.length || i !== void 0 && i.isDelete === !1;
|
|
285
267
|
let u, S = !1, E = !1;
|
|
286
|
-
if (
|
|
287
|
-
u =
|
|
288
|
-
const
|
|
289
|
-
|
|
268
|
+
if (g) {
|
|
269
|
+
u = l;
|
|
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
|
-
u = n -
|
|
292
|
-
const p =
|
|
273
|
+
u = n - l < h - n ? l : h;
|
|
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,
|
|
309
291
|
r,
|
|
310
292
|
a,
|
|
311
|
-
|
|
293
|
+
l
|
|
312
294
|
);
|
|
313
|
-
const h =
|
|
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,
|
|
@@ -318,8 +300,8 @@ function Ne(e, t, n, r, i, s, a, c, l = {}, o = $) {
|
|
|
318
300
|
S,
|
|
319
301
|
s,
|
|
320
302
|
c,
|
|
321
|
-
|
|
322
|
-
), p = s === -1 || n <= s,
|
|
303
|
+
l
|
|
304
|
+
), p = s === -1 || n <= s, d = ve(
|
|
323
305
|
t,
|
|
324
306
|
E,
|
|
325
307
|
r,
|
|
@@ -327,30 +309,30 @@ function Ne(e, t, n, r, i, s, a, c, l = {}, o = $) {
|
|
|
327
309
|
c,
|
|
328
310
|
p,
|
|
329
311
|
a,
|
|
330
|
-
|
|
312
|
+
l
|
|
331
313
|
);
|
|
332
|
-
return
|
|
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),
|
|
319
|
+
const c = s(e, a, r), o = ge(
|
|
338
320
|
t,
|
|
339
321
|
c,
|
|
340
322
|
r
|
|
341
323
|
);
|
|
342
|
-
return
|
|
324
|
+
return o < t.length && t[o] !== r ? o + 1 : o;
|
|
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
|
-
const { start:
|
|
349
|
-
return h ? c(e,
|
|
330
|
+
const { start: l, isDelete: h } = a;
|
|
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,40 +341,40 @@ function q(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
|
-
const
|
|
346
|
+
const l = e.substring(0, a), h = c(l, l.length, n);
|
|
365
347
|
if (t <= h) {
|
|
366
|
-
const
|
|
367
|
-
|
|
348
|
+
const g = R(
|
|
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
|
-
const
|
|
356
|
+
const o = R(
|
|
375
357
|
e,
|
|
376
358
|
t,
|
|
377
359
|
n
|
|
378
360
|
);
|
|
379
|
-
return
|
|
361
|
+
return H(e, o, t, n, r, i, c);
|
|
380
362
|
}
|
|
381
|
-
function
|
|
382
|
-
const a = n >= e.length, c = s(e, n, r),
|
|
383
|
-
if (a || c ===
|
|
363
|
+
function De(e, t, n, r, i, s = $) {
|
|
364
|
+
const a = n >= e.length, c = s(e, n, r), o = s(e, e.length, r), l = s(t, t.length, r);
|
|
365
|
+
if (a || c === o)
|
|
384
366
|
return t.length;
|
|
385
|
-
const h =
|
|
386
|
-
let
|
|
387
|
-
h > 0 && !a && c <
|
|
367
|
+
const h = l - 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;
|
|
@@ -412,16 +394,16 @@ function we(e, t, n) {
|
|
|
412
394
|
isDelete: !0
|
|
413
395
|
};
|
|
414
396
|
}
|
|
415
|
-
const c = t.length,
|
|
416
|
-
if (!(
|
|
397
|
+
const c = t.length, o = n.length, l = c - o;
|
|
398
|
+
if (!(l <= 0))
|
|
417
399
|
return {
|
|
418
400
|
start: r,
|
|
419
|
-
end: r +
|
|
420
|
-
deletedLength:
|
|
401
|
+
end: r + l,
|
|
402
|
+
deletedLength: l,
|
|
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 Me(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) {
|
|
@@ -449,15 +431,15 @@ function H(e, t) {
|
|
|
449
431
|
return e.selectionStart !== null || e.selectionStart === 0 ? (e.focus(), e.setSelectionRange(t, t), !0) : (e.focus(), !1);
|
|
450
432
|
}
|
|
451
433
|
function ye(e, t, n) {
|
|
452
|
-
return e.selectionStart === 0 && e.selectionEnd === e.value.length ? null : (
|
|
453
|
-
e.value === n && e.selectionStart !== t &&
|
|
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
|
-
const { selectionStart: c = 0, selectionEnd:
|
|
471
|
-
let h =
|
|
472
|
-
{ selectionStart: c, selectionEnd:
|
|
452
|
+
const { selectionStart: c = 0, selectionEnd: o = 0, endOffset: l = 0 } = i;
|
|
453
|
+
let h = Ce(
|
|
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,
|
|
@@ -498,23 +480,23 @@ function Re(e, t, n, r, i, s, a) {
|
|
|
498
480
|
ye(e, p, n);
|
|
499
481
|
}
|
|
500
482
|
const Te = (e, t = !1, n = ".") => {
|
|
501
|
-
const r =
|
|
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,
|
|
512
|
-
return s ? "-" +
|
|
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));
|
|
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
|
-
const a = r.slice(0, s), c = r.slice(s),
|
|
538
|
-
return
|
|
519
|
+
const a = r.slice(0, s), c = r.slice(s), o = `${a}.${c}`;
|
|
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,26 +546,26 @@ 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("."),
|
|
573
|
-
let
|
|
554
|
+
const [a, c = ""] = n.split("."), o = a.replace(Be, "") || "0";
|
|
555
|
+
let l;
|
|
574
556
|
if (c.length === 0)
|
|
575
|
-
|
|
557
|
+
l = o + "0".repeat(s);
|
|
576
558
|
else if (c.length <= s) {
|
|
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
|
-
|
|
562
|
+
const h = c.slice(0, s), g = c.slice(s);
|
|
563
|
+
l = o + h + "." + g;
|
|
582
564
|
}
|
|
583
|
-
return
|
|
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
|
-
|
|
615
|
+
Xe(n, i, s)
|
|
634
616
|
), c = le(
|
|
635
617
|
a,
|
|
636
618
|
t,
|
|
637
619
|
i.decimalSeparator
|
|
638
|
-
),
|
|
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
|
-
function
|
|
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,57 +703,53 @@ 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 =
|
|
716
|
+
return i.value = l, s !== l && F(
|
|
678
717
|
i,
|
|
679
718
|
s,
|
|
680
|
-
|
|
719
|
+
l,
|
|
681
720
|
a,
|
|
682
721
|
n,
|
|
683
722
|
c,
|
|
684
723
|
r
|
|
685
|
-
), { formatted:
|
|
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")) || "",
|
|
695
|
-
|
|
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(
|
|
734
|
+
o,
|
|
696
735
|
t,
|
|
697
736
|
n,
|
|
698
737
|
!0
|
|
699
738
|
);
|
|
700
|
-
r.value =
|
|
701
|
-
const
|
|
739
|
+
r.value = l;
|
|
740
|
+
const g = Ye(
|
|
702
741
|
s || 0,
|
|
703
742
|
c.length,
|
|
704
|
-
|
|
705
|
-
|
|
743
|
+
o.length,
|
|
744
|
+
l.length
|
|
706
745
|
);
|
|
707
|
-
return r.setSelectionRange(
|
|
746
|
+
return r.setSelectionRange(g, g), { formatted: l, raw: h };
|
|
708
747
|
}
|
|
709
|
-
function
|
|
710
|
-
const n =
|
|
748
|
+
function Ve(e, t) {
|
|
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
|
}
|
|
725
|
-
function
|
|
764
|
+
function et(e, t) {
|
|
726
765
|
if (!e) return t;
|
|
727
|
-
const r =
|
|
766
|
+
const r = Fe(e === !0 ? void 0 : e);
|
|
728
767
|
return {
|
|
729
768
|
thousandSeparator: t.thousandSeparator ?? r.thousandSeparator,
|
|
730
769
|
decimalSeparator: t.decimalSeparator ?? r.decimalSeparator
|
|
731
770
|
};
|
|
732
771
|
}
|
|
733
|
-
function
|
|
734
|
-
|
|
772
|
+
function tt(e) {
|
|
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);
|
|
735
774
|
}
|
|
736
|
-
function
|
|
775
|
+
function nt(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,10 +832,10 @@ 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
841
|
function lt(e) {
|
|
@@ -815,36 +854,36 @@ function lt(e) {
|
|
|
815
854
|
);
|
|
816
855
|
}
|
|
817
856
|
}
|
|
818
|
-
function
|
|
857
|
+
function ot(e, t) {
|
|
819
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)})`
|
|
834
873
|
);
|
|
835
874
|
}
|
|
836
|
-
class
|
|
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
|
-
locale:
|
|
845
|
-
enableCompactNotation:
|
|
883
|
+
locale: o,
|
|
884
|
+
enableCompactNotation: l = W,
|
|
846
885
|
enableNegative: h = U,
|
|
847
|
-
enableLeadingZeros:
|
|
886
|
+
enableLeadingZeros: g = z,
|
|
848
887
|
rawValueMode: u = J,
|
|
849
888
|
onChange: S,
|
|
850
889
|
...E
|
|
@@ -853,16 +892,16 @@ class St {
|
|
|
853
892
|
w(this, "resolvedOptions");
|
|
854
893
|
w(this, "rawValue", "");
|
|
855
894
|
w(this, "caretPositionBeforeChange");
|
|
856
|
-
|
|
895
|
+
tt({
|
|
857
896
|
decimalMaxLength: n,
|
|
858
897
|
decimalMinLength: r,
|
|
859
898
|
formatOn: i,
|
|
860
899
|
thousandSeparator: s,
|
|
861
900
|
thousandStyle: a,
|
|
862
901
|
decimalSeparator: c,
|
|
863
|
-
enableCompactNotation:
|
|
902
|
+
enableCompactNotation: l,
|
|
864
903
|
enableNegative: h,
|
|
865
|
-
enableLeadingZeros:
|
|
904
|
+
enableLeadingZeros: g,
|
|
866
905
|
rawValueMode: u,
|
|
867
906
|
onChange: S
|
|
868
907
|
});
|
|
@@ -874,62 +913,62 @@ class St {
|
|
|
874
913
|
thousandSeparator: s,
|
|
875
914
|
thousandStyle: a,
|
|
876
915
|
decimalSeparator: c,
|
|
877
|
-
locale:
|
|
878
|
-
enableCompactNotation:
|
|
916
|
+
locale: o,
|
|
917
|
+
enableCompactNotation: l,
|
|
879
918
|
enableNegative: h,
|
|
880
|
-
enableLeadingZeros:
|
|
919
|
+
enableLeadingZeros: g,
|
|
881
920
|
rawValueMode: u,
|
|
882
921
|
...E
|
|
883
922
|
};
|
|
884
923
|
if (this.resolvedOptions = this.getResolvedOptions(p), this.createInputElement(t, p), this.setupEventListeners(), this.resolvedOptions.rawValueMode && this.element.value) {
|
|
885
|
-
const
|
|
886
|
-
this.rawValue =
|
|
924
|
+
const d = this.element.value, f = this.resolvedOptions.thousandSeparator ? v(d, this.resolvedOptions.thousandSeparator) : d;
|
|
925
|
+
this.rawValue = f, this.element.value = this.formatValueForDisplay(f);
|
|
887
926
|
} else if (this.element.value) {
|
|
888
|
-
const
|
|
889
|
-
this.element.value = this.formatValueForDisplay(
|
|
927
|
+
const d = this.element.value;
|
|
928
|
+
this.element.value = this.formatValueForDisplay(d);
|
|
890
929
|
}
|
|
891
930
|
}
|
|
892
931
|
createInputElement(t, n) {
|
|
893
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");
|
|
894
|
-
const r =
|
|
933
|
+
const r = Ve(this.resolvedOptions.decimalSeparator, this.resolvedOptions.enableNegative);
|
|
895
934
|
this.element.setAttribute("pattern", r);
|
|
896
935
|
const {
|
|
897
936
|
decimalMaxLength: i,
|
|
898
937
|
decimalMinLength: s,
|
|
899
938
|
formatOn: a,
|
|
900
939
|
thousandSeparator: c,
|
|
901
|
-
thousandStyle:
|
|
902
|
-
decimalSeparator:
|
|
940
|
+
thousandStyle: o,
|
|
941
|
+
decimalSeparator: l,
|
|
903
942
|
locale: h,
|
|
904
|
-
enableCompactNotation:
|
|
943
|
+
enableCompactNotation: g,
|
|
905
944
|
enableNegative: u,
|
|
906
945
|
enableLeadingZeros: S,
|
|
907
946
|
rawValueMode: E,
|
|
908
947
|
onChange: p,
|
|
909
|
-
value:
|
|
910
|
-
defaultValue:
|
|
911
|
-
type:
|
|
912
|
-
inputMode:
|
|
913
|
-
spellcheck:
|
|
914
|
-
autocomplete:
|
|
915
|
-
...
|
|
948
|
+
value: d,
|
|
949
|
+
defaultValue: f,
|
|
950
|
+
type: N,
|
|
951
|
+
inputMode: m,
|
|
952
|
+
spellcheck: te,
|
|
953
|
+
autocomplete: ut,
|
|
954
|
+
...ne
|
|
916
955
|
} = n;
|
|
917
|
-
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);
|
|
918
957
|
}
|
|
919
958
|
setupEventListeners() {
|
|
920
|
-
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)));
|
|
921
960
|
}
|
|
922
961
|
getResolvedOptions(t) {
|
|
923
|
-
const n =
|
|
962
|
+
const n = et(t.locale, {
|
|
924
963
|
thousandSeparator: t.thousandSeparator,
|
|
925
964
|
decimalSeparator: t.decimalSeparator
|
|
926
965
|
});
|
|
927
966
|
return {
|
|
928
|
-
decimalMaxLength: t.decimalMaxLength ??
|
|
929
|
-
decimalMinLength: t.decimalMinLength ??
|
|
930
|
-
formatOn: t.formatOn ??
|
|
931
|
-
thousandSeparator: n.thousandSeparator ??
|
|
932
|
-
thousandStyle: t.thousandStyle ??
|
|
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,
|
|
933
972
|
decimalSeparator: n.decimalSeparator ?? C,
|
|
934
973
|
enableCompactNotation: t.enableCompactNotation ?? W,
|
|
935
974
|
enableNegative: t.enableNegative ?? U,
|
|
@@ -961,7 +1000,7 @@ class St {
|
|
|
961
1000
|
if (!t)
|
|
962
1001
|
return t;
|
|
963
1002
|
const { thousandSeparator: n, thousandStyle: r, enableLeadingZeros: i, decimalSeparator: s } = this.resolvedOptions;
|
|
964
|
-
return n && r !==
|
|
1003
|
+
return n && r !== L.None ? Q(
|
|
965
1004
|
t,
|
|
966
1005
|
n,
|
|
967
1006
|
r,
|
|
@@ -969,8 +1008,15 @@ class St {
|
|
|
969
1008
|
s
|
|
970
1009
|
) : t;
|
|
971
1010
|
}
|
|
1011
|
+
handleBeforeInput(t) {
|
|
1012
|
+
je(
|
|
1013
|
+
t,
|
|
1014
|
+
this.resolvedOptions.decimalMaxLength,
|
|
1015
|
+
this.buildFormattingOptions()
|
|
1016
|
+
);
|
|
1017
|
+
}
|
|
972
1018
|
handleChange(t) {
|
|
973
|
-
const { formatted: n, raw: r } =
|
|
1019
|
+
const { formatted: n, raw: r } = Ke(
|
|
974
1020
|
t,
|
|
975
1021
|
this.resolvedOptions.decimalMaxLength,
|
|
976
1022
|
this.caretPositionBeforeChange,
|
|
@@ -995,20 +1041,20 @@ class St {
|
|
|
995
1041
|
};
|
|
996
1042
|
}
|
|
997
1043
|
handlePaste(t) {
|
|
998
|
-
const { formatted: n, raw: r } =
|
|
1044
|
+
const { formatted: n, raw: r } = Qe(t, this.resolvedOptions.decimalMaxLength, this.buildFormattingOptions());
|
|
999
1045
|
this.handleValueChange(n, r);
|
|
1000
1046
|
const i = new Event("input", { bubbles: !0, cancelable: !0 });
|
|
1001
1047
|
this.element.dispatchEvent(i);
|
|
1002
1048
|
}
|
|
1003
1049
|
handleFocus(t) {
|
|
1004
|
-
if (this.resolvedOptions.formatOn ===
|
|
1050
|
+
if (this.resolvedOptions.formatOn === b.Blur && this.resolvedOptions.thousandSeparator) {
|
|
1005
1051
|
const n = t.target;
|
|
1006
1052
|
n.value = v(n.value, this.resolvedOptions.thousandSeparator);
|
|
1007
1053
|
}
|
|
1008
1054
|
}
|
|
1009
1055
|
handleBlur(t) {
|
|
1010
1056
|
const n = t.target, { thousandSeparator: r, thousandStyle: i } = this.resolvedOptions;
|
|
1011
|
-
if (r && i !==
|
|
1057
|
+
if (r && i !== L.None && n.value) {
|
|
1012
1058
|
const s = this.formatValueForDisplay(n.value);
|
|
1013
1059
|
n.value = s;
|
|
1014
1060
|
const a = this.resolvedOptions.rawValueMode ? v(s, r) : void 0;
|
|
@@ -1068,7 +1114,7 @@ class St {
|
|
|
1068
1114
|
const t = this.getValue();
|
|
1069
1115
|
if (!t)
|
|
1070
1116
|
return NaN;
|
|
1071
|
-
const n = this.resolvedOptions.thousandSeparator ? v(t, this.resolvedOptions.thousandSeparator) : t, r = this.resolvedOptions.decimalSeparator && this.resolvedOptions.decimalSeparator !== "." ? n.replace(new RegExp(
|
|
1117
|
+
const n = this.resolvedOptions.thousandSeparator ? v(t, this.resolvedOptions.thousandSeparator) : t, r = this.resolvedOptions.decimalSeparator && this.resolvedOptions.decimalSeparator !== "." ? n.replace(new RegExp(y(this.resolvedOptions.decimalSeparator), "g"), ".") : n;
|
|
1072
1118
|
return parseFloat(r);
|
|
1073
1119
|
}
|
|
1074
1120
|
/**
|
|
@@ -1084,17 +1130,18 @@ class St {
|
|
|
1084
1130
|
}
|
|
1085
1131
|
}
|
|
1086
1132
|
export {
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1133
|
+
b as FormatOn,
|
|
1134
|
+
gt as NumoraInput,
|
|
1135
|
+
L as ThousandStyle,
|
|
1136
|
+
et as applyLocale,
|
|
1137
|
+
M as formatInputValue,
|
|
1138
|
+
ft as formatValueForDisplay,
|
|
1139
|
+
Ve as getNumoraPattern,
|
|
1140
|
+
Fe as getSeparatorsFromLocale,
|
|
1141
|
+
je as handleOnBeforeInputNumoraInput,
|
|
1142
|
+
Ke as handleOnChangeNumoraInput,
|
|
1096
1143
|
He as handleOnKeyDownNumoraInput,
|
|
1097
|
-
|
|
1144
|
+
Qe as handleOnPasteNumoraInput,
|
|
1098
1145
|
v as removeThousandSeparators,
|
|
1099
|
-
|
|
1146
|
+
tt as validateNumoraInputOptions
|
|
1100
1147
|
};
|