numora 2.0.5 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/features/decimals.d.ts +3 -34
- package/dist/features/formatting/digit-counting.d.ts +3 -3
- package/dist/features/formatting/index.d.ts +1 -0
- package/dist/features/formatting/numeric-formatting-utils.d.ts +24 -0
- package/dist/features/formatting/thousand-grouping.d.ts +1 -1
- package/dist/features/sanitization.d.ts +3 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +386 -388
- package/dist/utils/format-utils.d.ts +8 -8
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,81 +1,82 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var Q = Object.defineProperty;
|
|
2
|
+
var X = (e, t, n) => t in e ? Q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var $ = (e, t, n) => X(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
var v = /* @__PURE__ */ ((e) => (e.Blur = "blur", e.Change = "change", e))(v || {}), S = /* @__PURE__ */ ((e) => (e.None = "none", e.Thousand = "thousand", e.Lakh = "lakh", e.Wan = "wan", e))(S || {});
|
|
5
|
-
const I = 2,
|
|
6
|
-
function D(e) {
|
|
7
|
-
return e.replace(/[-[\]/{}()*+?.\\^$|]/g, "\\$&");
|
|
8
|
-
}
|
|
5
|
+
const I = 2, O = 0, R = v.Blur, _ = ",", B = S.None, m = ".", Y = !1, P = !1, W = !1, k = !1;
|
|
9
6
|
function A(e) {
|
|
10
7
|
return {
|
|
11
|
-
decimalSeparator: (e == null ? void 0 : e.decimalSeparator) ??
|
|
8
|
+
decimalSeparator: (e == null ? void 0 : e.decimalSeparator) ?? m,
|
|
12
9
|
thousandSeparator: e == null ? void 0 : e.thousandSeparator
|
|
13
10
|
};
|
|
14
11
|
}
|
|
15
|
-
function
|
|
16
|
-
const n = e.
|
|
17
|
-
return
|
|
12
|
+
function U(e, t) {
|
|
13
|
+
const n = e.startsWith("-"), r = n ? e.slice(1) : e, [s = "", i = ""] = r.split(t);
|
|
14
|
+
return {
|
|
15
|
+
sign: n ? "-" : "",
|
|
16
|
+
integer: s,
|
|
17
|
+
decimal: i
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function V(e, t) {
|
|
21
|
+
if (!e.value.includes(t)) return !1;
|
|
22
|
+
const { selectionStart: n, selectionEnd: r, value: s } = e;
|
|
23
|
+
return !s.slice(n ?? 0, r ?? 0).includes(t);
|
|
18
24
|
}
|
|
19
|
-
function
|
|
20
|
-
const {
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
if (Y(e, r))
|
|
25
|
+
function F(e, t, n, r) {
|
|
26
|
+
const { key: s } = e;
|
|
27
|
+
if (s !== "," && s !== ".") return !1;
|
|
28
|
+
if (V(t, r))
|
|
24
29
|
return !0;
|
|
25
|
-
if (
|
|
26
|
-
const
|
|
27
|
-
t.value =
|
|
28
|
-
const
|
|
29
|
-
return t.setSelectionRange(
|
|
30
|
+
if (s !== r) {
|
|
31
|
+
const { selectionStart: i, selectionEnd: a, value: o } = t, c = i ?? 0, l = a ?? c;
|
|
32
|
+
t.value = o.slice(0, c) + r + o.slice(l);
|
|
33
|
+
const h = c + 1;
|
|
34
|
+
return t.setSelectionRange(h, h), !0;
|
|
30
35
|
}
|
|
31
36
|
return !1;
|
|
32
37
|
}
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const c = t - a.length, l = a + "0".repeat(c);
|
|
51
|
-
return i ? `-${s}${n}${l}` : `${s}${n}${l}`;
|
|
52
|
-
}
|
|
53
|
-
return e;
|
|
38
|
+
const ee = (e, t, n = m) => {
|
|
39
|
+
const { sign: r, integer: s, decimal: i } = U(e, n);
|
|
40
|
+
if (!e.includes(n)) return e;
|
|
41
|
+
const o = i.slice(0, t);
|
|
42
|
+
return `${r}${s}${n}${o}`;
|
|
43
|
+
}, te = (e, t = m) => {
|
|
44
|
+
const n = e.indexOf(t);
|
|
45
|
+
if (n === -1) return e;
|
|
46
|
+
const r = e.slice(0, n + 1), i = e.slice(n + 1).split(",").join("").split(".").join("").split(t).join("");
|
|
47
|
+
return r + i;
|
|
48
|
+
}, ne = (e, t = 0, n = m) => {
|
|
49
|
+
if (t <= 0) return e;
|
|
50
|
+
const { sign: r, integer: s, decimal: i } = U(e, n);
|
|
51
|
+
if (i.length >= t)
|
|
52
|
+
return e.includes(n) ? e : `${r}${s}${n}${i}`;
|
|
53
|
+
const a = i.padEnd(t, "0");
|
|
54
|
+
return `${r}${s}${n}${a}`;
|
|
54
55
|
}, N = {
|
|
55
56
|
thousand: { size: 3 },
|
|
56
57
|
lakh: { firstGroup: 3, restGroup: 2 },
|
|
57
58
|
wan: { size: 4 }
|
|
58
59
|
};
|
|
59
|
-
function
|
|
60
|
-
if (!e || e === "0" || e ===
|
|
60
|
+
function j(e, t, n = S.Thousand, r = !1, s = ".") {
|
|
61
|
+
if (!e || e === "0" || e === s || e === "-" || e === `-${s}`)
|
|
61
62
|
return e;
|
|
62
|
-
const
|
|
63
|
+
const i = e.includes(s), a = e.startsWith("-"), o = a ? e.slice(1) : e, [c, l] = o.split(s);
|
|
63
64
|
if (!c) {
|
|
64
|
-
const u = l ? `${
|
|
65
|
-
return
|
|
65
|
+
const u = l ? `${s}${l}` : o;
|
|
66
|
+
return a ? `-${u}` : u;
|
|
66
67
|
}
|
|
67
68
|
if (r && c.startsWith("0") && c.length > 1) {
|
|
68
69
|
const u = c.match(/^(0+)/);
|
|
69
70
|
if (u) {
|
|
70
71
|
const g = u[1], f = c.slice(g.length);
|
|
71
72
|
if (f) {
|
|
72
|
-
const p = Z(f, t, n),
|
|
73
|
-
return
|
|
73
|
+
const p = Z(f, t, n), E = g + p, w = a ? "-" : "";
|
|
74
|
+
return i ? l ? `${w}${E}${s}${l}` : `${w}${E}${s}` : `${w}${E}`;
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
|
-
const h = Z(c, t, n), d =
|
|
78
|
-
return
|
|
78
|
+
const h = Z(c, t, n), d = a ? "-" : "";
|
|
79
|
+
return i ? l ? `${d}${h}${s}${l}` : `${d}${h}${s}` : `${d}${h}`;
|
|
79
80
|
}
|
|
80
81
|
function Z(e, t, n) {
|
|
81
82
|
if (e === "0" || e === "")
|
|
@@ -84,117 +85,111 @@ function Z(e, t, n) {
|
|
|
84
85
|
case S.None:
|
|
85
86
|
return e;
|
|
86
87
|
case S.Thousand:
|
|
87
|
-
return ne(e, t);
|
|
88
|
-
case S.Lakh:
|
|
89
88
|
return re(e, t);
|
|
89
|
+
case S.Lakh:
|
|
90
|
+
return ie(e, t);
|
|
90
91
|
case S.Wan:
|
|
91
92
|
return se(e, t);
|
|
92
93
|
default:
|
|
93
94
|
return e;
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
|
-
function ne(e, t) {
|
|
97
|
-
return U(e, t, N.thousand.size);
|
|
98
|
-
}
|
|
99
97
|
function re(e, t) {
|
|
98
|
+
return z(e, t, N.thousand.size);
|
|
99
|
+
}
|
|
100
|
+
function ie(e, t) {
|
|
100
101
|
if (e.length <= N.lakh.firstGroup)
|
|
101
102
|
return e;
|
|
102
|
-
const n = e.split("").reverse(), r = [],
|
|
103
|
-
r.push(
|
|
104
|
-
for (let
|
|
105
|
-
r.push(n.slice(
|
|
103
|
+
const n = e.split("").reverse(), r = [], s = n.slice(0, N.lakh.firstGroup).reverse().join("");
|
|
104
|
+
r.push(s);
|
|
105
|
+
for (let i = N.lakh.firstGroup; i < n.length; i += N.lakh.restGroup)
|
|
106
|
+
r.push(n.slice(i, i + N.lakh.restGroup).reverse().join(""));
|
|
106
107
|
return r.reverse().join(t);
|
|
107
108
|
}
|
|
108
109
|
function se(e, t) {
|
|
109
|
-
return
|
|
110
|
+
return z(e, t, N.wan.size);
|
|
110
111
|
}
|
|
111
|
-
function
|
|
112
|
-
const r = e.split("").reverse(),
|
|
113
|
-
for (let
|
|
114
|
-
|
|
115
|
-
return
|
|
112
|
+
function z(e, t, n) {
|
|
113
|
+
const r = e.split("").reverse(), s = [];
|
|
114
|
+
for (let i = 0; i < r.length; i += n)
|
|
115
|
+
s.push(r.slice(i, i + n).reverse().join(""));
|
|
116
|
+
return s.reverse().join(t);
|
|
116
117
|
}
|
|
117
|
-
function
|
|
118
|
-
return (t == null ? void 0 : t.formatOn) === "change" && t.thousandSeparator ?
|
|
118
|
+
function ae(e, t, n) {
|
|
119
|
+
return (t == null ? void 0 : t.formatOn) === "change" && t.thousandSeparator ? j(
|
|
119
120
|
e,
|
|
120
121
|
t.thousandSeparator,
|
|
121
122
|
t.ThousandStyle ?? S.None,
|
|
122
123
|
t.enableLeadingZeros,
|
|
123
|
-
(n == null ? void 0 : n.decimalSeparator) ??
|
|
124
|
+
(n == null ? void 0 : n.decimalSeparator) ?? m
|
|
124
125
|
) : e;
|
|
125
126
|
}
|
|
126
127
|
function b(e, t, n, r = ".") {
|
|
127
|
-
let
|
|
128
|
-
for (let
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
return i;
|
|
128
|
+
let s = 0;
|
|
129
|
+
for (let i = 0; i < t && i < e.length; i++)
|
|
130
|
+
e[i] !== n && s++;
|
|
131
|
+
return s;
|
|
133
132
|
}
|
|
134
133
|
function oe(e, t, n, r = ".") {
|
|
135
134
|
if (t === 0)
|
|
136
135
|
return 0;
|
|
137
|
-
let
|
|
138
|
-
for (let
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
i++;
|
|
136
|
+
let s = 0;
|
|
137
|
+
for (let i = 0; i < e.length; i++)
|
|
138
|
+
if (e[i] !== n) {
|
|
139
|
+
if (s === t - 1)
|
|
140
|
+
return i + 1;
|
|
141
|
+
s++;
|
|
144
142
|
}
|
|
145
|
-
}
|
|
146
143
|
return e.length;
|
|
147
144
|
}
|
|
148
145
|
function C(e, t, n, r = ".") {
|
|
149
146
|
if (t === 0)
|
|
150
147
|
return 0;
|
|
151
|
-
let
|
|
152
|
-
for (let
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return o;
|
|
148
|
+
let s = 0;
|
|
149
|
+
for (let i = 0; i < e.length; i++)
|
|
150
|
+
if (e[i] !== n) {
|
|
151
|
+
if (s++, s === t)
|
|
152
|
+
return i + 1;
|
|
153
|
+
if (s > t)
|
|
154
|
+
return i;
|
|
159
155
|
}
|
|
160
|
-
}
|
|
161
156
|
return e.length;
|
|
162
157
|
}
|
|
163
|
-
function
|
|
158
|
+
function J(e, t, n) {
|
|
164
159
|
return t < 0 || t >= e.length ? !1 : e[t] === n;
|
|
165
160
|
}
|
|
166
|
-
function
|
|
161
|
+
function ce(e, t = {}) {
|
|
167
162
|
const {
|
|
168
163
|
thousandSeparator: n,
|
|
169
164
|
decimalSeparator: r = ".",
|
|
170
|
-
prefix:
|
|
171
|
-
suffix:
|
|
172
|
-
} = t,
|
|
173
|
-
if (
|
|
174
|
-
const
|
|
175
|
-
|
|
165
|
+
prefix: s = "",
|
|
166
|
+
suffix: i = ""
|
|
167
|
+
} = t, a = Array.from({ length: e.length + 1 }).map(() => !0);
|
|
168
|
+
if (s && a.fill(!1, 0, s.length), i) {
|
|
169
|
+
const o = e.length - i.length;
|
|
170
|
+
a.fill(!1, o + 1, e.length + 1);
|
|
176
171
|
}
|
|
177
|
-
for (let
|
|
178
|
-
const c = e[
|
|
179
|
-
(n && c === n || c === r) && (
|
|
172
|
+
for (let o = 0; o < e.length; o++) {
|
|
173
|
+
const c = e[o];
|
|
174
|
+
(n && c === n || c === r) && (a[o] = !1, o + 1 < e.length && !/\d/.test(e[o + 1]) && (a[o + 1] = !1));
|
|
180
175
|
}
|
|
181
|
-
return
|
|
176
|
+
return a.some((o) => o) || a.fill(!0), a;
|
|
182
177
|
}
|
|
183
178
|
function T(e, t, n, r) {
|
|
184
|
-
const
|
|
185
|
-
if (t = Math.max(0, Math.min(t,
|
|
186
|
-
let
|
|
187
|
-
for (;
|
|
188
|
-
|
|
189
|
-
let
|
|
190
|
-
for (;
|
|
191
|
-
|
|
192
|
-
|
|
179
|
+
const s = e.length;
|
|
180
|
+
if (t = Math.max(0, Math.min(t, s)), !n[t]) {
|
|
181
|
+
let i = t;
|
|
182
|
+
for (; i <= s && !n[i]; )
|
|
183
|
+
i++;
|
|
184
|
+
let a = t;
|
|
185
|
+
for (; a >= 0 && !n[a]; )
|
|
186
|
+
a--;
|
|
187
|
+
i <= s && a >= 0 ? t = t - a < i - t ? a : i : i <= s ? t = i : a >= 0 && (t = a);
|
|
193
188
|
}
|
|
194
|
-
return (t === -1 || t >
|
|
189
|
+
return (t === -1 || t > s) && (t = s), t;
|
|
195
190
|
}
|
|
196
|
-
const
|
|
197
|
-
function
|
|
191
|
+
const K = (e, t) => e === t;
|
|
192
|
+
function le(e, t, n, r, s, i, a = ".", o = {}) {
|
|
198
193
|
if (n < 0)
|
|
199
194
|
return 0;
|
|
200
195
|
if (n > e.length || e === "" || t === "")
|
|
@@ -202,25 +197,25 @@ function ce(e, t, n, r, i, o, s = ".", a = {}) {
|
|
|
202
197
|
const c = /(\d+\.?\d*)\s*[kmbMTOQaqiSxsxSpOoNn]$/i;
|
|
203
198
|
if (c.test(e) && !c.test(t) && t.length > e.length && n >= e.length - 1)
|
|
204
199
|
return t.length;
|
|
205
|
-
const l = t.length < e.length, h =
|
|
200
|
+
const l = t.length < e.length, h = J(
|
|
206
201
|
e,
|
|
207
202
|
n,
|
|
208
203
|
r
|
|
209
|
-
), d = e.indexOf(
|
|
210
|
-
if (
|
|
211
|
-
const p =
|
|
204
|
+
), d = e.indexOf(a), u = t.indexOf(a);
|
|
205
|
+
if (o.isCharacterEquivalent && e !== t) {
|
|
206
|
+
const p = he(
|
|
212
207
|
e,
|
|
213
208
|
t,
|
|
214
209
|
n,
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
210
|
+
o.isCharacterEquivalent || K,
|
|
211
|
+
i,
|
|
212
|
+
o
|
|
218
213
|
);
|
|
219
214
|
if (p !== void 0)
|
|
220
215
|
return p;
|
|
221
216
|
}
|
|
222
217
|
if (l)
|
|
223
|
-
return
|
|
218
|
+
return ue(
|
|
224
219
|
e,
|
|
225
220
|
t,
|
|
226
221
|
n,
|
|
@@ -228,25 +223,25 @@ function ce(e, t, n, r, i, o, s = ".", a = {}) {
|
|
|
228
223
|
h,
|
|
229
224
|
d,
|
|
230
225
|
u,
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
226
|
+
i,
|
|
227
|
+
a,
|
|
228
|
+
o
|
|
234
229
|
);
|
|
235
|
-
const f =
|
|
230
|
+
const f = pe(
|
|
236
231
|
e,
|
|
237
232
|
t,
|
|
238
233
|
n,
|
|
239
234
|
r,
|
|
240
235
|
h,
|
|
241
|
-
|
|
236
|
+
a
|
|
242
237
|
);
|
|
243
|
-
return
|
|
238
|
+
return o.boundary ? T(t, f, o.boundary) : f;
|
|
244
239
|
}
|
|
245
|
-
function
|
|
246
|
-
const
|
|
247
|
-
for (let f = 0; f <
|
|
240
|
+
function he(e, t, n, r, s, i) {
|
|
241
|
+
const a = e.length, o = t.length, c = {}, l = new Array(a);
|
|
242
|
+
for (let f = 0; f < a; f++) {
|
|
248
243
|
l[f] = -1;
|
|
249
|
-
for (let p = 0; p <
|
|
244
|
+
for (let p = 0; p < o; p++) {
|
|
250
245
|
if (c[p]) continue;
|
|
251
246
|
if (r(
|
|
252
247
|
e[f],
|
|
@@ -254,7 +249,7 @@ function le(e, t, n, r, i, o) {
|
|
|
254
249
|
{
|
|
255
250
|
oldValue: e,
|
|
256
251
|
newValue: t,
|
|
257
|
-
typedRange:
|
|
252
|
+
typedRange: s,
|
|
258
253
|
oldIndex: f,
|
|
259
254
|
newIndex: p
|
|
260
255
|
}
|
|
@@ -265,23 +260,23 @@ function le(e, t, n, r, i, o) {
|
|
|
265
260
|
}
|
|
266
261
|
}
|
|
267
262
|
let h = n;
|
|
268
|
-
for (; h <
|
|
263
|
+
for (; h < a && (l[h] === -1 || !/\d/.test(e[h])); )
|
|
269
264
|
h++;
|
|
270
|
-
const d = h ===
|
|
265
|
+
const d = h === a || l[h] === -1 ? o : l[h];
|
|
271
266
|
for (h = n - 1; h >= 0 && l[h] === -1; ) h--;
|
|
272
267
|
const u = h === -1 || l[h] === -1 ? 0 : l[h] + 1;
|
|
273
268
|
if (u > d) return d;
|
|
274
269
|
const g = n - u < d - n ? u : d;
|
|
275
|
-
return
|
|
270
|
+
return i.boundary ? T(t, g, i.boundary) : g;
|
|
276
271
|
}
|
|
277
|
-
function
|
|
278
|
-
if (
|
|
279
|
-
return
|
|
272
|
+
function ue(e, t, n, r, s, i, a, o, c, l = {}) {
|
|
273
|
+
if (s)
|
|
274
|
+
return de(
|
|
280
275
|
e,
|
|
281
276
|
t,
|
|
282
277
|
n,
|
|
283
278
|
r,
|
|
284
|
-
|
|
279
|
+
a,
|
|
285
280
|
c
|
|
286
281
|
);
|
|
287
282
|
const h = b(
|
|
@@ -299,86 +294,86 @@ function he(e, t, n, r, i, o, s, a, c, l = {}) {
|
|
|
299
294
|
t.length,
|
|
300
295
|
r,
|
|
301
296
|
c
|
|
302
|
-
), g = d - u, f =
|
|
297
|
+
), g = d - u, f = fe(
|
|
303
298
|
e,
|
|
304
299
|
n,
|
|
305
300
|
r,
|
|
306
301
|
h,
|
|
307
302
|
g,
|
|
303
|
+
i,
|
|
308
304
|
o,
|
|
309
|
-
a,
|
|
310
305
|
c
|
|
311
|
-
), p =
|
|
306
|
+
), p = i === -1 || n <= i, E = ge(
|
|
312
307
|
t,
|
|
313
308
|
f,
|
|
314
309
|
r,
|
|
315
310
|
g,
|
|
316
|
-
|
|
311
|
+
o,
|
|
317
312
|
c,
|
|
318
313
|
p,
|
|
319
|
-
|
|
314
|
+
a
|
|
320
315
|
);
|
|
321
|
-
return l.boundary ? T(t,
|
|
316
|
+
return l.boundary ? T(t, E, l.boundary) : E;
|
|
322
317
|
}
|
|
323
|
-
function
|
|
324
|
-
const
|
|
325
|
-
if (
|
|
326
|
-
const
|
|
318
|
+
function de(e, t, n, r, s, i) {
|
|
319
|
+
const a = n + 1;
|
|
320
|
+
if (a < e.length) {
|
|
321
|
+
const o = b(
|
|
327
322
|
e,
|
|
328
|
-
|
|
323
|
+
a,
|
|
329
324
|
r,
|
|
330
|
-
|
|
325
|
+
i
|
|
331
326
|
), c = oe(
|
|
332
327
|
t,
|
|
333
|
-
|
|
328
|
+
o,
|
|
334
329
|
r,
|
|
335
|
-
|
|
330
|
+
i
|
|
336
331
|
);
|
|
337
332
|
return c < t.length && t[c] !== r ? c + 1 : c;
|
|
338
333
|
}
|
|
339
334
|
return n;
|
|
340
335
|
}
|
|
341
|
-
function
|
|
342
|
-
if (
|
|
343
|
-
const { start: l, isDelete: h } =
|
|
336
|
+
function fe(e, t, n, r, s, i, a, o) {
|
|
337
|
+
if (a) {
|
|
338
|
+
const { start: l, isDelete: h } = a;
|
|
344
339
|
return h ? b(
|
|
345
340
|
e,
|
|
346
341
|
l,
|
|
347
342
|
n,
|
|
348
|
-
|
|
343
|
+
o
|
|
349
344
|
) : Math.max(0, b(
|
|
350
345
|
e,
|
|
351
346
|
l,
|
|
352
347
|
n,
|
|
353
|
-
|
|
348
|
+
o
|
|
354
349
|
));
|
|
355
350
|
}
|
|
356
|
-
return t > 0 && e[t - 1] === n &&
|
|
351
|
+
return t > 0 && e[t - 1] === n && s > 0 ? r + 1 : r;
|
|
357
352
|
}
|
|
358
|
-
function
|
|
359
|
-
if (
|
|
360
|
-
const l = e.substring(0,
|
|
353
|
+
function ge(e, t, n, r, s, i, a, o) {
|
|
354
|
+
if (a && o !== -1) {
|
|
355
|
+
const l = e.substring(0, o), h = b(
|
|
361
356
|
l,
|
|
362
357
|
l.length,
|
|
363
358
|
n,
|
|
364
|
-
|
|
359
|
+
i
|
|
365
360
|
);
|
|
366
361
|
if (t <= h) {
|
|
367
362
|
const d = C(
|
|
368
363
|
l,
|
|
369
364
|
t,
|
|
370
365
|
n,
|
|
371
|
-
|
|
366
|
+
i
|
|
372
367
|
);
|
|
373
368
|
if (d > 0 && d < l.length && b(
|
|
374
369
|
l,
|
|
375
370
|
d,
|
|
376
371
|
n,
|
|
377
|
-
|
|
372
|
+
i
|
|
378
373
|
) === t) {
|
|
379
|
-
if (l[d] === n &&
|
|
374
|
+
if (l[d] === n && s && r > 0 && d < l.length - 1)
|
|
380
375
|
return d + 1;
|
|
381
|
-
if (!
|
|
376
|
+
if (!s && r > 0 && d < l.length - 1)
|
|
382
377
|
return Math.min(d + 1, l.length);
|
|
383
378
|
}
|
|
384
379
|
return d;
|
|
@@ -388,64 +383,64 @@ function fe(e, t, n, r, i, o, s, a) {
|
|
|
388
383
|
e,
|
|
389
384
|
t,
|
|
390
385
|
n,
|
|
391
|
-
|
|
386
|
+
i
|
|
392
387
|
);
|
|
393
388
|
if (c > 0 && c < e.length && b(
|
|
394
389
|
e,
|
|
395
390
|
c,
|
|
396
391
|
n,
|
|
397
|
-
|
|
392
|
+
i
|
|
398
393
|
) === t) {
|
|
399
|
-
if (e[c] === n &&
|
|
394
|
+
if (e[c] === n && s && r > 0 && c < e.length - 1)
|
|
400
395
|
return c + 1;
|
|
401
|
-
if (!
|
|
396
|
+
if (!s && r > 0 && c < e.length - 1)
|
|
402
397
|
return Math.min(c + 1, e.length);
|
|
403
398
|
}
|
|
404
399
|
return c;
|
|
405
400
|
}
|
|
406
|
-
function
|
|
407
|
-
const
|
|
401
|
+
function pe(e, t, n, r, s, i) {
|
|
402
|
+
const a = n >= e.length, o = b(
|
|
408
403
|
e,
|
|
409
404
|
n,
|
|
410
405
|
r,
|
|
411
|
-
|
|
406
|
+
i
|
|
412
407
|
), c = b(
|
|
413
408
|
e,
|
|
414
409
|
e.length,
|
|
415
410
|
r,
|
|
416
|
-
|
|
411
|
+
i
|
|
417
412
|
), l = b(
|
|
418
413
|
t,
|
|
419
414
|
t.length,
|
|
420
415
|
r,
|
|
421
|
-
|
|
416
|
+
i
|
|
422
417
|
);
|
|
423
|
-
if (
|
|
418
|
+
if (a || o === c)
|
|
424
419
|
return t.length;
|
|
425
420
|
const h = l - c;
|
|
426
|
-
let d =
|
|
427
|
-
h > 0 && !
|
|
421
|
+
let d = o;
|
|
422
|
+
h > 0 && !a && o < c && (d = o + 1);
|
|
428
423
|
const u = C(
|
|
429
424
|
t,
|
|
430
425
|
d,
|
|
431
426
|
r,
|
|
432
|
-
|
|
427
|
+
i
|
|
433
428
|
);
|
|
434
|
-
return
|
|
429
|
+
return s && !J(t, u, r) ? Math.max(0, u - 1) : u;
|
|
435
430
|
}
|
|
436
|
-
function
|
|
437
|
-
const { selectionStart: r, selectionEnd:
|
|
438
|
-
if (r !==
|
|
439
|
-
const h =
|
|
431
|
+
function Se(e, t, n) {
|
|
432
|
+
const { selectionStart: r, selectionEnd: s, endOffset: i = 0 } = e;
|
|
433
|
+
if (r !== s) {
|
|
434
|
+
const h = s - r;
|
|
440
435
|
return {
|
|
441
436
|
start: r,
|
|
442
|
-
end:
|
|
437
|
+
end: s,
|
|
443
438
|
deletedLength: h,
|
|
444
439
|
isDelete: !1
|
|
445
440
|
};
|
|
446
441
|
}
|
|
447
|
-
if (
|
|
448
|
-
const h =
|
|
442
|
+
if (i > 0) {
|
|
443
|
+
const h = i;
|
|
449
444
|
return {
|
|
450
445
|
start: r,
|
|
451
446
|
end: r + h,
|
|
@@ -453,7 +448,7 @@ function pe(e, t, n) {
|
|
|
453
448
|
isDelete: !0
|
|
454
449
|
};
|
|
455
450
|
}
|
|
456
|
-
const
|
|
451
|
+
const o = t.length, c = n.length, l = o - c;
|
|
457
452
|
if (!(l <= 0))
|
|
458
453
|
return {
|
|
459
454
|
start: r,
|
|
@@ -462,25 +457,25 @@ function pe(e, t, n) {
|
|
|
462
457
|
isDelete: !1
|
|
463
458
|
};
|
|
464
459
|
}
|
|
465
|
-
function
|
|
460
|
+
function be(e, t) {
|
|
466
461
|
if (e === t)
|
|
467
462
|
return;
|
|
468
463
|
let n = 0;
|
|
469
464
|
for (; n < e.length && n < t.length && e[n] === t[n]; )
|
|
470
465
|
n++;
|
|
471
|
-
let r = e.length - 1,
|
|
472
|
-
for (; r >= n &&
|
|
473
|
-
r--,
|
|
474
|
-
const
|
|
475
|
-
if (!(
|
|
466
|
+
let r = e.length - 1, s = t.length - 1;
|
|
467
|
+
for (; r >= n && s >= n && e[r] === t[s]; )
|
|
468
|
+
r--, s--;
|
|
469
|
+
const i = r - n + 1, a = s - n + 1;
|
|
470
|
+
if (!(i === 0 && a === 0))
|
|
476
471
|
return {
|
|
477
472
|
start: n,
|
|
478
473
|
end: r + 1,
|
|
479
|
-
deletedLength:
|
|
480
|
-
isDelete:
|
|
474
|
+
deletedLength: i,
|
|
475
|
+
isDelete: i > a
|
|
481
476
|
};
|
|
482
477
|
}
|
|
483
|
-
function
|
|
478
|
+
function G(e, t) {
|
|
484
479
|
if (e.value = e.value, e === null)
|
|
485
480
|
return !1;
|
|
486
481
|
if (e.createTextRange) {
|
|
@@ -489,106 +484,109 @@ function z(e, t) {
|
|
|
489
484
|
}
|
|
490
485
|
return e.selectionStart !== null || e.selectionStart === 0 ? (e.focus(), e.setSelectionRange(t, t), !0) : (e.focus(), !1);
|
|
491
486
|
}
|
|
492
|
-
function
|
|
493
|
-
return e.selectionStart === 0 && e.selectionEnd === e.value.length ? null : (
|
|
494
|
-
e.value === n && e.selectionStart !== t &&
|
|
487
|
+
function ve(e, t, n) {
|
|
488
|
+
return e.selectionStart === 0 && e.selectionEnd === e.value.length ? null : (G(e, t), setTimeout(() => {
|
|
489
|
+
e.value === n && e.selectionStart !== t && G(e, t);
|
|
495
490
|
}, 0));
|
|
496
491
|
}
|
|
497
|
-
function
|
|
492
|
+
function Ee(e) {
|
|
498
493
|
return Math.max(e.selectionStart, e.selectionEnd);
|
|
499
494
|
}
|
|
500
|
-
function
|
|
495
|
+
function me(e, t, n) {
|
|
501
496
|
if ((n == null ? void 0 : n.formatOn) !== v.Change || !n.thousandSeparator)
|
|
502
497
|
return;
|
|
503
|
-
const { selectionStart: r, selectionEnd:
|
|
504
|
-
if (r === null ||
|
|
498
|
+
const { selectionStart: r, selectionEnd: s, value: i } = t;
|
|
499
|
+
if (r === null || s === null || r !== s)
|
|
505
500
|
return;
|
|
506
|
-
const { key:
|
|
507
|
-
|
|
501
|
+
const { key: a } = e, o = n.thousandSeparator;
|
|
502
|
+
a === "Backspace" && r > 0 && i[r - 1] === o && t.setSelectionRange(r - 1, r - 1), a === "Delete" && i[r] === o && t.setSelectionRange(r + 1, r + 1);
|
|
508
503
|
}
|
|
509
|
-
function
|
|
510
|
-
if (!
|
|
511
|
-
const { selectionStart:
|
|
512
|
-
let h =
|
|
513
|
-
{ selectionStart:
|
|
504
|
+
function Ne(e, t, n, r, s, i, a) {
|
|
505
|
+
if (!s) return;
|
|
506
|
+
const { selectionStart: o = 0, selectionEnd: c = 0, endOffset: l = 0 } = s;
|
|
507
|
+
let h = Se(
|
|
508
|
+
{ selectionStart: o, selectionEnd: c, endOffset: l },
|
|
514
509
|
t,
|
|
515
510
|
n
|
|
516
511
|
);
|
|
517
|
-
if (h || (h =
|
|
518
|
-
const d =
|
|
519
|
-
thousandSeparator: (
|
|
520
|
-
decimalSeparator:
|
|
512
|
+
if (h || (h = be(t, n)), !h) return;
|
|
513
|
+
const d = ce(n, {
|
|
514
|
+
thousandSeparator: (a == null ? void 0 : a.thousandSeparator) ?? i.thousandSeparator,
|
|
515
|
+
decimalSeparator: i.decimalSeparator
|
|
521
516
|
}), u = {
|
|
522
|
-
thousandSeparator: (
|
|
523
|
-
isCharacterEquivalent:
|
|
517
|
+
thousandSeparator: (a == null ? void 0 : a.thousandSeparator) ?? i.thousandSeparator,
|
|
518
|
+
isCharacterEquivalent: K,
|
|
524
519
|
boundary: d
|
|
525
|
-
}, g = (
|
|
520
|
+
}, g = (a == null ? void 0 : a.thousandSeparator) ?? i.thousandSeparator ?? ",", f = (a == null ? void 0 : a.ThousandStyle) ?? S.None, p = le(
|
|
526
521
|
t,
|
|
527
522
|
n,
|
|
528
523
|
r,
|
|
529
524
|
g,
|
|
530
525
|
f,
|
|
531
526
|
h,
|
|
532
|
-
|
|
527
|
+
i.decimalSeparator,
|
|
533
528
|
u
|
|
534
529
|
);
|
|
535
|
-
|
|
530
|
+
ve(e, p, n);
|
|
531
|
+
}
|
|
532
|
+
function M(e) {
|
|
533
|
+
return e.replace(/[-[\]/{}()*+?.\\^$|]/g, "\\$&");
|
|
536
534
|
}
|
|
537
|
-
const
|
|
538
|
-
const r =
|
|
535
|
+
const $e = (e, t = !1, n = ".") => {
|
|
536
|
+
const r = M(n), s = new RegExp(`[^0-9${r}]`, "g");
|
|
539
537
|
if (!t)
|
|
540
|
-
return e.replace(
|
|
541
|
-
const
|
|
542
|
-
if (
|
|
543
|
-
if (
|
|
544
|
-
return "-" +
|
|
538
|
+
return e.replace(s, "");
|
|
539
|
+
const i = e.startsWith("-"), a = e.replace(s, "");
|
|
540
|
+
if (i) {
|
|
541
|
+
if (a.length > 0)
|
|
542
|
+
return "-" + a;
|
|
545
543
|
if (e === "-")
|
|
546
544
|
return "-";
|
|
547
545
|
}
|
|
548
|
-
return
|
|
546
|
+
return a;
|
|
549
547
|
};
|
|
550
548
|
function Le(e) {
|
|
551
549
|
const t = /([+-]?\d+\.?\d*)[eE]([+-]?\d+)/g;
|
|
552
550
|
let n = e, r;
|
|
553
|
-
const
|
|
551
|
+
const s = [];
|
|
554
552
|
for (; (r = t.exec(e)) !== null; ) {
|
|
555
|
-
const
|
|
553
|
+
const i = r[0], a = r[1], o = parseInt(r[2], 10);
|
|
556
554
|
let c;
|
|
557
|
-
if (
|
|
558
|
-
c =
|
|
555
|
+
if (o === 0)
|
|
556
|
+
c = a;
|
|
559
557
|
else {
|
|
560
|
-
const l =
|
|
561
|
-
|
|
558
|
+
const l = a.startsWith("-"), h = l ? a.slice(1) : a, [d, u = ""] = h.split(".");
|
|
559
|
+
o > 0 ? c = we(d, u, o) : c = De(d, u, Math.abs(o)), l && (c = "-" + c);
|
|
562
560
|
}
|
|
563
|
-
|
|
561
|
+
s.push({ full: i, expanded: c });
|
|
564
562
|
}
|
|
565
|
-
for (const { full:
|
|
566
|
-
n = n.replace(
|
|
563
|
+
for (const { full: i, expanded: a } of s)
|
|
564
|
+
n = n.replace(i, a);
|
|
567
565
|
return n;
|
|
568
566
|
}
|
|
569
567
|
function we(e, t, n) {
|
|
570
568
|
const r = e + t;
|
|
571
569
|
if (r === "0" || r.match(/^0+$/))
|
|
572
570
|
return "0";
|
|
573
|
-
const
|
|
574
|
-
if (n <=
|
|
575
|
-
const
|
|
576
|
-
return
|
|
571
|
+
const s = t.length;
|
|
572
|
+
if (n <= s) {
|
|
573
|
+
const a = r.slice(0, e.length + n), o = r.slice(e.length + n);
|
|
574
|
+
return o ? `${a}.${o}` : a;
|
|
577
575
|
}
|
|
578
|
-
const
|
|
579
|
-
return r + "0".repeat(
|
|
576
|
+
const i = n - s;
|
|
577
|
+
return r + "0".repeat(i);
|
|
580
578
|
}
|
|
581
579
|
function De(e, t, n) {
|
|
582
580
|
const r = e + t;
|
|
583
581
|
if (r === "0" || r.match(/^0+$/))
|
|
584
582
|
return "0";
|
|
585
|
-
const
|
|
586
|
-
if (
|
|
587
|
-
const
|
|
583
|
+
const a = e.length - n;
|
|
584
|
+
if (a <= 0) {
|
|
585
|
+
const o = Math.abs(a), c = `0.${"0".repeat(o)}${r}`;
|
|
588
586
|
return y(c);
|
|
589
587
|
}
|
|
590
|
-
if (
|
|
591
|
-
const
|
|
588
|
+
if (a < e.length) {
|
|
589
|
+
const o = r.slice(0, a), c = r.slice(a), l = `${o}.${c}`;
|
|
592
590
|
return y(l);
|
|
593
591
|
}
|
|
594
592
|
return y(r);
|
|
@@ -608,10 +606,10 @@ function y(e) {
|
|
|
608
606
|
}
|
|
609
607
|
return e.replace(/\.?0+$/, "") || e;
|
|
610
608
|
}
|
|
611
|
-
function
|
|
609
|
+
function Me(e) {
|
|
612
610
|
const t = /(\d+\.?\d*)\s*(Qa|Qi|Sx|Sp|[kmbMTO]|N)/gi;
|
|
613
|
-
return e.replace(t, (n, r,
|
|
614
|
-
const
|
|
611
|
+
return e.replace(t, (n, r, s) => {
|
|
612
|
+
const i = {
|
|
615
613
|
k: 3,
|
|
616
614
|
// Thousand
|
|
617
615
|
K: 3,
|
|
@@ -629,66 +627,66 @@ function me(e) {
|
|
|
629
627
|
t: 12
|
|
630
628
|
// Trillion
|
|
631
629
|
};
|
|
632
|
-
let
|
|
633
|
-
if (
|
|
634
|
-
const g =
|
|
635
|
-
|
|
630
|
+
let a;
|
|
631
|
+
if (s.length > 1) {
|
|
632
|
+
const g = s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
|
|
633
|
+
a = i[s] || i[g];
|
|
636
634
|
} else {
|
|
637
|
-
const g =
|
|
638
|
-
|
|
635
|
+
const g = s.toLowerCase();
|
|
636
|
+
a = i[s] || i[g];
|
|
639
637
|
}
|
|
640
|
-
if (!
|
|
638
|
+
if (!a)
|
|
641
639
|
return n;
|
|
642
|
-
const
|
|
640
|
+
const o = r.startsWith("-"), c = o ? r.slice(1) : r, [l, h = ""] = c.split("."), d = l.replace(/^0+/, "") || "0";
|
|
643
641
|
let u;
|
|
644
642
|
if (h.length === 0)
|
|
645
|
-
u = d + "0".repeat(
|
|
646
|
-
else if (h.length <=
|
|
647
|
-
const g =
|
|
643
|
+
u = d + "0".repeat(a);
|
|
644
|
+
else if (h.length <= a) {
|
|
645
|
+
const g = a - h.length;
|
|
648
646
|
u = d + h + "0".repeat(g);
|
|
649
647
|
} else {
|
|
650
|
-
const g = h.slice(0,
|
|
648
|
+
const g = h.slice(0, a), f = h.slice(a);
|
|
651
649
|
u = d + g + "." + f;
|
|
652
650
|
}
|
|
653
|
-
return u = u.replace(/^(-?)0+([1-9])/, "$1$2"), u.match(/^-?0+$/) && (u =
|
|
651
|
+
return u = u.replace(/^(-?)0+([1-9])/, "$1$2"), u.match(/^-?0+$/) && (u = o ? "-0" : "0"), u.includes(".") && (u = u.replace(/\.?0+$/, "")), o && !u.startsWith("-") ? "-" + u : u;
|
|
654
652
|
});
|
|
655
653
|
}
|
|
656
|
-
function
|
|
654
|
+
function ye(e) {
|
|
657
655
|
if (!e || e === "0" || e === "-0" || e === "-" || e === ".")
|
|
658
656
|
return e;
|
|
659
657
|
const t = e.startsWith("-"), n = t ? e.slice(1) : e;
|
|
660
658
|
if (!n || n === "0" || n === ".")
|
|
661
659
|
return e;
|
|
662
660
|
if (n.includes(".")) {
|
|
663
|
-
const [
|
|
664
|
-
if (
|
|
665
|
-
const
|
|
666
|
-
return t ? "-" +
|
|
661
|
+
const [s, i] = n.split(".");
|
|
662
|
+
if (s && s.length > 0) {
|
|
663
|
+
const o = (s.replace(/^0+/, "") || "0") + "." + i;
|
|
664
|
+
return t ? "-" + o : o;
|
|
667
665
|
}
|
|
668
666
|
return e;
|
|
669
667
|
}
|
|
670
668
|
if (n.startsWith("0") && n.length > 1) {
|
|
671
|
-
const
|
|
672
|
-
return t ? "-" +
|
|
669
|
+
const s = n.replace(/^0+/, "") || "0";
|
|
670
|
+
return t ? "-" + s : s;
|
|
673
671
|
}
|
|
674
672
|
return e;
|
|
675
673
|
}
|
|
676
|
-
function
|
|
674
|
+
function Ce(e) {
|
|
677
675
|
return e.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000]/g, " ").replace(/\s/g, "");
|
|
678
676
|
}
|
|
679
|
-
function
|
|
680
|
-
const n =
|
|
677
|
+
function L(e, t) {
|
|
678
|
+
const n = M(t);
|
|
681
679
|
return e.replace(new RegExp(n, "g"), "");
|
|
682
680
|
}
|
|
683
|
-
const
|
|
684
|
-
let n =
|
|
685
|
-
return t != null && t.thousandSeparator && (n =
|
|
681
|
+
const Ae = (e, t) => {
|
|
682
|
+
let n = Ce(e);
|
|
683
|
+
return t != null && t.thousandSeparator && (n = L(n, t.thousandSeparator)), t != null && t.enableCompactNotation && (n = Me(n)), n = Le(n), n = $e(
|
|
686
684
|
n,
|
|
687
685
|
t == null ? void 0 : t.enableNegative,
|
|
688
686
|
t == null ? void 0 : t.decimalSeparator
|
|
689
|
-
), n =
|
|
687
|
+
), n = te(n, (t == null ? void 0 : t.decimalSeparator) || m), t != null && t.enableLeadingZeros || (n = ye(n)), n;
|
|
690
688
|
};
|
|
691
|
-
function
|
|
689
|
+
function Te(e, t, n) {
|
|
692
690
|
return {
|
|
693
691
|
enableCompactNotation: e == null ? void 0 : e.enableCompactNotation,
|
|
694
692
|
enableNegative: e == null ? void 0 : e.enableNegative,
|
|
@@ -698,21 +696,21 @@ function Ae(e, t, n) {
|
|
|
698
696
|
};
|
|
699
697
|
}
|
|
700
698
|
function x(e, t, n, r) {
|
|
701
|
-
const
|
|
699
|
+
const s = A(n), i = r ?? (n == null ? void 0 : n.formatOn) === v.Change, a = Ae(
|
|
702
700
|
e,
|
|
703
|
-
|
|
704
|
-
),
|
|
705
|
-
s,
|
|
706
|
-
t,
|
|
707
|
-
i.decimalSeparator
|
|
708
|
-
), c = (n == null ? void 0 : n.decimalMinLength) ?? 0, l = te(
|
|
701
|
+
Te(n, s, i)
|
|
702
|
+
), o = ee(
|
|
709
703
|
a,
|
|
704
|
+
t,
|
|
705
|
+
s.decimalSeparator
|
|
706
|
+
), c = (n == null ? void 0 : n.decimalMinLength) ?? 0, l = ne(
|
|
707
|
+
o,
|
|
710
708
|
c,
|
|
711
|
-
|
|
709
|
+
s.decimalSeparator
|
|
712
710
|
), h = l;
|
|
713
|
-
return { formatted:
|
|
711
|
+
return { formatted: ae(l, n, s), raw: h };
|
|
714
712
|
}
|
|
715
|
-
function
|
|
713
|
+
function Qe(e, t, n) {
|
|
716
714
|
const r = !!(n != null && n.thousandSeparator);
|
|
717
715
|
return x(
|
|
718
716
|
e,
|
|
@@ -721,7 +719,7 @@ function Ke(e, t, n) {
|
|
|
721
719
|
r
|
|
722
720
|
);
|
|
723
721
|
}
|
|
724
|
-
function
|
|
722
|
+
function xe(e, t, n) {
|
|
725
723
|
if (e === "Backspace" || e === "Delete")
|
|
726
724
|
return e === "Delete" && t === n ? {
|
|
727
725
|
endOffset: 1
|
|
@@ -729,39 +727,39 @@ function Te(e, t, n) {
|
|
|
729
727
|
endOffset: 0
|
|
730
728
|
};
|
|
731
729
|
}
|
|
732
|
-
function
|
|
730
|
+
function Ie(e, t) {
|
|
733
731
|
const { decimalSeparator: n } = A(t), r = e.target;
|
|
734
|
-
if (
|
|
732
|
+
if (F(e, r, t, n)) {
|
|
735
733
|
e.preventDefault();
|
|
736
734
|
return;
|
|
737
735
|
}
|
|
738
|
-
return
|
|
736
|
+
return me(e, r, t), xe(e.key, r.selectionStart, r.selectionEnd);
|
|
739
737
|
}
|
|
740
|
-
function
|
|
741
|
-
const
|
|
742
|
-
|
|
738
|
+
function Oe(e, t, n, r) {
|
|
739
|
+
const s = e.target, i = s.value, a = Ee(s), o = A(r), c = (r == null ? void 0 : r.formatOn) === v.Change, { formatted: l, raw: h } = x(
|
|
740
|
+
i,
|
|
743
741
|
t,
|
|
744
742
|
r,
|
|
745
743
|
c
|
|
746
744
|
);
|
|
747
|
-
return
|
|
745
|
+
return s.value = l, i !== l && Ne(
|
|
746
|
+
s,
|
|
748
747
|
i,
|
|
749
|
-
o,
|
|
750
748
|
l,
|
|
751
|
-
s,
|
|
752
|
-
n,
|
|
753
749
|
a,
|
|
750
|
+
n,
|
|
751
|
+
o,
|
|
754
752
|
r
|
|
755
753
|
), { formatted: l, raw: h };
|
|
756
754
|
}
|
|
757
755
|
function Re(e, t, n, r) {
|
|
758
|
-
const
|
|
759
|
-
return e + t +
|
|
756
|
+
const s = r - n;
|
|
757
|
+
return e + t + s;
|
|
760
758
|
}
|
|
761
|
-
function
|
|
759
|
+
function _e(e, t, n) {
|
|
762
760
|
var u;
|
|
763
761
|
e.preventDefault();
|
|
764
|
-
const r = e.target, { value:
|
|
762
|
+
const r = e.target, { value: s, selectionStart: i, selectionEnd: a } = r, o = ((u = e.clipboardData) == null ? void 0 : u.getData("text/plain")) || "", c = s.slice(0, i || 0) + o + s.slice(a || 0), { formatted: l, raw: h } = x(
|
|
765
763
|
c,
|
|
766
764
|
t,
|
|
767
765
|
n,
|
|
@@ -769,21 +767,21 @@ function Oe(e, t, n) {
|
|
|
769
767
|
);
|
|
770
768
|
r.value = l;
|
|
771
769
|
const d = Re(
|
|
772
|
-
|
|
773
|
-
|
|
770
|
+
i || 0,
|
|
771
|
+
o.length,
|
|
774
772
|
c.length,
|
|
775
773
|
l.length
|
|
776
774
|
);
|
|
777
775
|
return r.setSelectionRange(d, d), { formatted: l, raw: h };
|
|
778
776
|
}
|
|
779
|
-
function
|
|
780
|
-
const n =
|
|
777
|
+
function Be(e, t) {
|
|
778
|
+
const n = M(e);
|
|
781
779
|
return t ? `^-?[0-9]*[${n}]?[0-9]*$` : `^[0-9]*[${n}]?[0-9]*$`;
|
|
782
780
|
}
|
|
783
|
-
function Be(e) {
|
|
784
|
-
Pe(e.decimalMaxLength), We(e.decimalMinLength), ke(e.decimalMinLength, e.decimalMaxLength), Ze(e.formatOn), ze(e.thousandSeparator), Ge(e.thousandStyle), Ue(e.decimalSeparator), je(e.thousandSeparator, e.decimalSeparator), M("enableCompactNotation", e.enableCompactNotation), M("enableNegative", e.enableNegative), M("enableLeadingZeros", e.enableLeadingZeros), M("rawValueMode", e.rawValueMode), Je(e.onChange);
|
|
785
|
-
}
|
|
786
781
|
function Pe(e) {
|
|
782
|
+
We(e.decimalMaxLength), ke(e.decimalMinLength), Ze(e.decimalMinLength, e.decimalMaxLength), Ge(e.formatOn), Ue(e.thousandSeparator), je(e.thousandStyle), ze(e.decimalSeparator), Je(e.thousandSeparator, e.decimalSeparator), D("enableCompactNotation", e.enableCompactNotation), D("enableNegative", e.enableNegative), D("enableLeadingZeros", e.enableLeadingZeros), D("rawValueMode", e.rawValueMode), Ke(e.onChange);
|
|
783
|
+
}
|
|
784
|
+
function We(e) {
|
|
787
785
|
if (e !== void 0) {
|
|
788
786
|
if (typeof e != "number")
|
|
789
787
|
throw new Error(
|
|
@@ -799,7 +797,7 @@ function Pe(e) {
|
|
|
799
797
|
);
|
|
800
798
|
}
|
|
801
799
|
}
|
|
802
|
-
function
|
|
800
|
+
function ke(e) {
|
|
803
801
|
if (e !== void 0) {
|
|
804
802
|
if (typeof e != "number")
|
|
805
803
|
throw new Error(
|
|
@@ -815,19 +813,19 @@ function We(e) {
|
|
|
815
813
|
);
|
|
816
814
|
}
|
|
817
815
|
}
|
|
818
|
-
function
|
|
816
|
+
function Ze(e, t) {
|
|
819
817
|
if (!(e === void 0 || t === void 0) && e > t)
|
|
820
818
|
throw new Error(
|
|
821
819
|
`decimalMinLength (${e}) cannot be greater than decimalMaxLength (${t}).`
|
|
822
820
|
);
|
|
823
821
|
}
|
|
824
|
-
function
|
|
822
|
+
function Ge(e) {
|
|
825
823
|
if (e !== void 0 && e !== v.Blur && e !== v.Change)
|
|
826
824
|
throw new Error(
|
|
827
825
|
`formatOn must be either ${v.Blur} or ${v.Change}. Received: ${JSON.stringify(e)}`
|
|
828
826
|
);
|
|
829
827
|
}
|
|
830
|
-
function
|
|
828
|
+
function Ue(e) {
|
|
831
829
|
if (e !== void 0) {
|
|
832
830
|
if (typeof e != "string")
|
|
833
831
|
throw new Error(
|
|
@@ -843,13 +841,13 @@ function ze(e) {
|
|
|
843
841
|
);
|
|
844
842
|
}
|
|
845
843
|
}
|
|
846
|
-
function
|
|
844
|
+
function je(e) {
|
|
847
845
|
if (e !== void 0 && !Object.values(S).includes(e))
|
|
848
846
|
throw new Error(
|
|
849
847
|
`ThousandStyle must be one of: ${Object.values(S).map((t) => `'${t}'`).join(", ")}. Received: ${JSON.stringify(e)}`
|
|
850
848
|
);
|
|
851
849
|
}
|
|
852
|
-
function
|
|
850
|
+
function ze(e) {
|
|
853
851
|
if (e !== void 0) {
|
|
854
852
|
if (typeof e != "string")
|
|
855
853
|
throw new Error(
|
|
@@ -865,32 +863,32 @@ function Ue(e) {
|
|
|
865
863
|
);
|
|
866
864
|
}
|
|
867
865
|
}
|
|
868
|
-
function
|
|
866
|
+
function Je(e, t) {
|
|
869
867
|
if (!(e === void 0 || t === void 0) && e === t)
|
|
870
868
|
throw new Error(
|
|
871
869
|
`Decimal separator can't be same as thousand separator. thousandSeparator: ${e}, decimalSeparator: ${t}`
|
|
872
870
|
);
|
|
873
871
|
}
|
|
874
|
-
function
|
|
872
|
+
function D(e, t) {
|
|
875
873
|
if (t !== void 0 && typeof t != "boolean")
|
|
876
874
|
throw new Error(
|
|
877
875
|
`${e} must be a boolean. Received: ${typeof t} (${JSON.stringify(t)})`
|
|
878
876
|
);
|
|
879
877
|
}
|
|
880
|
-
function
|
|
878
|
+
function Ke(e) {
|
|
881
879
|
if (e !== void 0 && typeof e != "function")
|
|
882
880
|
throw new Error(
|
|
883
881
|
`onChange must be a function or undefined. Received: ${typeof e} (${JSON.stringify(e)})`
|
|
884
882
|
);
|
|
885
883
|
}
|
|
886
|
-
class
|
|
884
|
+
class Xe {
|
|
887
885
|
constructor(t, {
|
|
888
886
|
decimalMaxLength: n = I,
|
|
889
|
-
decimalMinLength: r =
|
|
890
|
-
formatOn:
|
|
891
|
-
thousandSeparator:
|
|
892
|
-
thousandStyle:
|
|
893
|
-
decimalSeparator:
|
|
887
|
+
decimalMinLength: r = O,
|
|
888
|
+
formatOn: s = R,
|
|
889
|
+
thousandSeparator: i = _,
|
|
890
|
+
thousandStyle: a = B,
|
|
891
|
+
decimalSeparator: o = m,
|
|
894
892
|
enableCompactNotation: c = !0,
|
|
895
893
|
enableNegative: l = P,
|
|
896
894
|
enableLeadingZeros: h = W,
|
|
@@ -898,18 +896,18 @@ class Qe {
|
|
|
898
896
|
onChange: u,
|
|
899
897
|
...g
|
|
900
898
|
}) {
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
if (
|
|
899
|
+
$(this, "element");
|
|
900
|
+
$(this, "options");
|
|
901
|
+
$(this, "resolvedOptions");
|
|
902
|
+
$(this, "rawValue", "");
|
|
903
|
+
$(this, "caretPositionBeforeChange");
|
|
904
|
+
if (Pe({
|
|
907
905
|
decimalMaxLength: n,
|
|
908
906
|
decimalMinLength: r,
|
|
909
|
-
formatOn:
|
|
910
|
-
thousandSeparator:
|
|
911
|
-
thousandStyle:
|
|
912
|
-
decimalSeparator:
|
|
907
|
+
formatOn: s,
|
|
908
|
+
thousandSeparator: i,
|
|
909
|
+
thousandStyle: a,
|
|
910
|
+
decimalSeparator: o,
|
|
913
911
|
enableCompactNotation: c,
|
|
914
912
|
enableNegative: l,
|
|
915
913
|
enableLeadingZeros: h,
|
|
@@ -919,17 +917,17 @@ class Qe {
|
|
|
919
917
|
decimalMaxLength: n,
|
|
920
918
|
decimalMinLength: r,
|
|
921
919
|
onChange: u,
|
|
922
|
-
formatOn:
|
|
923
|
-
thousandSeparator:
|
|
924
|
-
thousandStyle:
|
|
925
|
-
decimalSeparator:
|
|
920
|
+
formatOn: s,
|
|
921
|
+
thousandSeparator: i,
|
|
922
|
+
thousandStyle: a,
|
|
923
|
+
decimalSeparator: o,
|
|
926
924
|
enableCompactNotation: c,
|
|
927
925
|
enableNegative: l,
|
|
928
926
|
enableLeadingZeros: h,
|
|
929
927
|
rawValueMode: d,
|
|
930
928
|
...g
|
|
931
929
|
}, this.resolvedOptions = this.getResolvedOptions(), this.createInputElement(t), this.setupEventListeners(), this.resolvedOptions.rawValueMode && this.element.value) {
|
|
932
|
-
const f = this.element.value, p = this.resolvedOptions.thousandSeparator ?
|
|
930
|
+
const f = this.element.value, p = this.resolvedOptions.thousandSeparator ? L(f, this.resolvedOptions.thousandSeparator) : f;
|
|
933
931
|
this.rawValue = p, this.element.value = this.formatValueForDisplay(p);
|
|
934
932
|
} else if (this.element.value) {
|
|
935
933
|
const f = this.element.value;
|
|
@@ -938,16 +936,16 @@ class Qe {
|
|
|
938
936
|
}
|
|
939
937
|
createInputElement(t) {
|
|
940
938
|
if (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"), this.resolvedOptions.decimalSeparator !== void 0 && this.resolvedOptions.enableNegative !== void 0) {
|
|
941
|
-
const H =
|
|
939
|
+
const H = Be(this.resolvedOptions.decimalSeparator, this.resolvedOptions.enableNegative);
|
|
942
940
|
this.element.setAttribute("pattern", H);
|
|
943
941
|
}
|
|
944
942
|
const {
|
|
945
943
|
decimalMaxLength: n,
|
|
946
944
|
decimalMinLength: r,
|
|
947
|
-
formatOn:
|
|
948
|
-
thousandSeparator:
|
|
949
|
-
thousandStyle:
|
|
950
|
-
decimalSeparator:
|
|
945
|
+
formatOn: s,
|
|
946
|
+
thousandSeparator: i,
|
|
947
|
+
thousandStyle: a,
|
|
948
|
+
decimalSeparator: o,
|
|
951
949
|
enableCompactNotation: c,
|
|
952
950
|
enableNegative: l,
|
|
953
951
|
enableLeadingZeros: h,
|
|
@@ -956,8 +954,8 @@ class Qe {
|
|
|
956
954
|
value: g,
|
|
957
955
|
defaultValue: f,
|
|
958
956
|
type: p,
|
|
959
|
-
inputMode:
|
|
960
|
-
spellcheck:
|
|
957
|
+
inputMode: E,
|
|
958
|
+
spellcheck: w,
|
|
961
959
|
autocomplete: qe,
|
|
962
960
|
...q
|
|
963
961
|
} = this.options;
|
|
@@ -969,12 +967,12 @@ class Qe {
|
|
|
969
967
|
getResolvedOptions() {
|
|
970
968
|
return {
|
|
971
969
|
decimalMaxLength: this.options.decimalMaxLength ?? I,
|
|
972
|
-
decimalMinLength: this.options.decimalMinLength ??
|
|
973
|
-
formatOn: this.options.formatOn ??
|
|
970
|
+
decimalMinLength: this.options.decimalMinLength ?? O,
|
|
971
|
+
formatOn: this.options.formatOn ?? R,
|
|
974
972
|
thousandSeparator: this.options.thousandSeparator ?? _,
|
|
975
973
|
thousandStyle: this.options.thousandStyle ?? B,
|
|
976
|
-
decimalSeparator: this.options.decimalSeparator ??
|
|
977
|
-
enableCompactNotation: this.options.enableCompactNotation ??
|
|
974
|
+
decimalSeparator: this.options.decimalSeparator ?? m,
|
|
975
|
+
enableCompactNotation: this.options.enableCompactNotation ?? Y,
|
|
978
976
|
enableNegative: this.options.enableNegative ?? P,
|
|
979
977
|
enableLeadingZeros: this.options.enableLeadingZeros ?? W,
|
|
980
978
|
rawValueMode: this.options.rawValueMode ?? k,
|
|
@@ -1003,17 +1001,17 @@ class Qe {
|
|
|
1003
1001
|
formatValueForDisplay(t) {
|
|
1004
1002
|
if (!t)
|
|
1005
1003
|
return t;
|
|
1006
|
-
const { thousandSeparator: n, thousandStyle: r, enableLeadingZeros:
|
|
1007
|
-
return n && r !== S.None ?
|
|
1004
|
+
const { thousandSeparator: n, thousandStyle: r, enableLeadingZeros: s, decimalSeparator: i } = this.resolvedOptions;
|
|
1005
|
+
return n && r !== S.None ? j(
|
|
1008
1006
|
t,
|
|
1009
1007
|
n,
|
|
1010
1008
|
r,
|
|
1011
|
-
|
|
1012
|
-
|
|
1009
|
+
s,
|
|
1010
|
+
i
|
|
1013
1011
|
) : t;
|
|
1014
1012
|
}
|
|
1015
1013
|
handleChange(t) {
|
|
1016
|
-
const { formatted: n, raw: r } =
|
|
1014
|
+
const { formatted: n, raw: r } = Oe(
|
|
1017
1015
|
t,
|
|
1018
1016
|
this.resolvedOptions.decimalMaxLength,
|
|
1019
1017
|
this.caretPositionBeforeChange,
|
|
@@ -1022,40 +1020,40 @@ class Qe {
|
|
|
1022
1020
|
this.caretPositionBeforeChange = void 0, this.handleValueChange(n, r);
|
|
1023
1021
|
}
|
|
1024
1022
|
handleKeyDown(t) {
|
|
1025
|
-
const n = t.target, { selectionStart: r, selectionEnd:
|
|
1026
|
-
formatOn:
|
|
1027
|
-
thousandSeparator:
|
|
1028
|
-
ThousandStyle:
|
|
1029
|
-
decimalSeparator:
|
|
1023
|
+
const n = t.target, { selectionStart: r, selectionEnd: s } = n, i = this.buildFormattingOptions(), a = Ie(t, {
|
|
1024
|
+
formatOn: i.formatOn,
|
|
1025
|
+
thousandSeparator: i.thousandSeparator,
|
|
1026
|
+
ThousandStyle: i.ThousandStyle,
|
|
1027
|
+
decimalSeparator: i.decimalSeparator
|
|
1030
1028
|
});
|
|
1031
|
-
|
|
1029
|
+
a ? this.caretPositionBeforeChange = {
|
|
1032
1030
|
selectionStart: r ?? 0,
|
|
1033
|
-
selectionEnd:
|
|
1034
|
-
endOffset:
|
|
1031
|
+
selectionEnd: s ?? 0,
|
|
1032
|
+
endOffset: a.endOffset
|
|
1035
1033
|
} : this.caretPositionBeforeChange = {
|
|
1036
1034
|
selectionStart: r ?? 0,
|
|
1037
|
-
selectionEnd:
|
|
1035
|
+
selectionEnd: s ?? 0
|
|
1038
1036
|
};
|
|
1039
1037
|
}
|
|
1040
1038
|
handlePaste(t) {
|
|
1041
|
-
const { formatted: n, raw: r } =
|
|
1039
|
+
const { formatted: n, raw: r } = _e(t, this.resolvedOptions.decimalMaxLength, this.buildFormattingOptions());
|
|
1042
1040
|
this.handleValueChange(n, r);
|
|
1043
|
-
const
|
|
1044
|
-
this.element.dispatchEvent(
|
|
1041
|
+
const s = new Event("input", { bubbles: !0, cancelable: !0 });
|
|
1042
|
+
this.element.dispatchEvent(s);
|
|
1045
1043
|
}
|
|
1046
1044
|
handleFocus(t) {
|
|
1047
1045
|
if (this.resolvedOptions.formatOn === v.Blur && this.resolvedOptions.thousandSeparator) {
|
|
1048
1046
|
const n = t.target;
|
|
1049
|
-
n.value =
|
|
1047
|
+
n.value = L(n.value, this.resolvedOptions.thousandSeparator);
|
|
1050
1048
|
}
|
|
1051
1049
|
}
|
|
1052
1050
|
handleBlur(t) {
|
|
1053
|
-
const n = t.target, { thousandSeparator: r, thousandStyle:
|
|
1054
|
-
if (r &&
|
|
1055
|
-
const
|
|
1056
|
-
n.value =
|
|
1057
|
-
const
|
|
1058
|
-
if (this.handleValueChange(
|
|
1051
|
+
const n = t.target, { thousandSeparator: r, thousandStyle: s } = this.resolvedOptions;
|
|
1052
|
+
if (r && s !== S.None && n.value) {
|
|
1053
|
+
const i = n.value, a = this.formatValueForDisplay(n.value);
|
|
1054
|
+
n.value = a;
|
|
1055
|
+
const o = this.resolvedOptions.rawValueMode ? L(a, r) : void 0;
|
|
1056
|
+
if (this.handleValueChange(a, o), i !== a) {
|
|
1059
1057
|
const c = new Event("input", { bubbles: !0, cancelable: !0 });
|
|
1060
1058
|
this.element.dispatchEvent(c);
|
|
1061
1059
|
const l = new Event("change", { bubbles: !0, cancelable: !0 });
|
|
@@ -1068,7 +1066,7 @@ class Qe {
|
|
|
1068
1066
|
}
|
|
1069
1067
|
setValue(t) {
|
|
1070
1068
|
if (this.resolvedOptions.rawValueMode) {
|
|
1071
|
-
const n = this.resolvedOptions.thousandSeparator ?
|
|
1069
|
+
const n = this.resolvedOptions.thousandSeparator ? L(t, this.resolvedOptions.thousandSeparator) : t;
|
|
1072
1070
|
this.rawValue = n, this.element.value = this.formatValueForDisplay(n);
|
|
1073
1071
|
} else
|
|
1074
1072
|
this.element.value = t;
|
|
@@ -1116,7 +1114,7 @@ class Qe {
|
|
|
1116
1114
|
const t = this.getValue();
|
|
1117
1115
|
if (!t)
|
|
1118
1116
|
return NaN;
|
|
1119
|
-
const n = this.resolvedOptions.thousandSeparator ?
|
|
1117
|
+
const n = this.resolvedOptions.thousandSeparator ? L(t, this.resolvedOptions.thousandSeparator) : t, r = this.resolvedOptions.decimalSeparator && this.resolvedOptions.decimalSeparator !== "." ? n.replace(new RegExp(M(this.resolvedOptions.decimalSeparator), "g"), ".") : n;
|
|
1120
1118
|
return parseFloat(r);
|
|
1121
1119
|
}
|
|
1122
1120
|
/**
|
|
@@ -1133,11 +1131,11 @@ class Qe {
|
|
|
1133
1131
|
}
|
|
1134
1132
|
export {
|
|
1135
1133
|
v as FormatOn,
|
|
1136
|
-
|
|
1134
|
+
Xe as NumoraInput,
|
|
1137
1135
|
S as ThousandStyle,
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1136
|
+
x as formatInputValue,
|
|
1137
|
+
Qe as formatValueForDisplay,
|
|
1138
|
+
Oe as handleOnChangeNumoraInput,
|
|
1139
|
+
Ie as handleOnKeyDownNumoraInput,
|
|
1140
|
+
_e as handleOnPasteNumoraInput
|
|
1143
1141
|
};
|