numora 3.0.0 → 3.0.1
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 +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +752 -514
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,195 +1,195 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
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 v = (e, t, n) => ie(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
var $ = /* @__PURE__ */ ((e) => (e.Blur = "blur", e.Change = "change", e))($ || {}), S = /* @__PURE__ */ ((e) => (e.None = "none", e.Thousand = "thousand", e.Lakh = "lakh", e.Wan = "wan", e))(S || {});
|
|
5
|
+
const _ = 2, z = 0, Z = $.Blur, B = ",", W = S.None, N = ".", oe = !1, k = !1, U = !1, G = !1;
|
|
6
|
+
function T(e) {
|
|
7
7
|
return {
|
|
8
|
-
decimalSeparator: (e == null ? void 0 : e.decimalSeparator) ??
|
|
8
|
+
decimalSeparator: (e == null ? void 0 : e.decimalSeparator) ?? N,
|
|
9
9
|
thousandSeparator: e == null ? void 0 : e.thousandSeparator
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
const n = e.startsWith("-"),
|
|
12
|
+
function K(e, t) {
|
|
13
|
+
const n = e.startsWith("-"), s = n ? e.slice(1) : e, [o = "", r = ""] = s.split(t);
|
|
14
14
|
return {
|
|
15
15
|
sign: n ? "-" : "",
|
|
16
|
-
integer:
|
|
17
|
-
decimal:
|
|
16
|
+
integer: o,
|
|
17
|
+
decimal: r
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function ae(e, t) {
|
|
21
21
|
if (!e.value.includes(t)) return !1;
|
|
22
|
-
const { selectionStart: n, selectionEnd:
|
|
23
|
-
return !
|
|
22
|
+
const { selectionStart: n, selectionEnd: s, value: o } = e;
|
|
23
|
+
return !o.slice(n ?? 0, s ?? 0).includes(t);
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function ce(e, t, n) {
|
|
26
26
|
const { key: s } = e;
|
|
27
27
|
if (s !== "," && s !== ".") return !1;
|
|
28
|
-
if (
|
|
28
|
+
if (ae(t, n))
|
|
29
29
|
return !0;
|
|
30
|
-
if (s !==
|
|
31
|
-
const { selectionStart:
|
|
32
|
-
t.value =
|
|
33
|
-
const
|
|
34
|
-
return t.setSelectionRange(
|
|
30
|
+
if (s !== n) {
|
|
31
|
+
const { selectionStart: o, selectionEnd: r, value: i } = t, a = o ?? 0, c = r ?? a;
|
|
32
|
+
t.value = i.slice(0, a) + n + i.slice(c);
|
|
33
|
+
const l = a + 1;
|
|
34
|
+
return t.setSelectionRange(l, l), !0;
|
|
35
35
|
}
|
|
36
36
|
return !1;
|
|
37
37
|
}
|
|
38
|
-
const
|
|
39
|
-
const { sign:
|
|
38
|
+
const le = (e, t, n = N) => {
|
|
39
|
+
const { sign: s, integer: o, decimal: r } = K(e, n);
|
|
40
40
|
if (!e.includes(n)) return e;
|
|
41
|
-
const
|
|
42
|
-
return `${
|
|
43
|
-
},
|
|
41
|
+
const a = r.slice(0, t);
|
|
42
|
+
return `${s}${o}${n}${a}`;
|
|
43
|
+
}, he = (e, t = N) => {
|
|
44
44
|
const n = e.indexOf(t);
|
|
45
45
|
if (n === -1) return e;
|
|
46
|
-
const
|
|
47
|
-
return
|
|
48
|
-
},
|
|
46
|
+
const s = e.slice(0, n + 1), r = e.slice(n + 1).split(",").join("").split(".").join("").split(t).join("");
|
|
47
|
+
return s + r;
|
|
48
|
+
}, ue = (e, t = 0, n = N) => {
|
|
49
49
|
if (t <= 0) return e;
|
|
50
|
-
const { sign:
|
|
51
|
-
if (
|
|
52
|
-
return e.includes(n) ? e : `${
|
|
53
|
-
const
|
|
54
|
-
return `${
|
|
55
|
-
},
|
|
50
|
+
const { sign: s, integer: o, decimal: r } = K(e, n);
|
|
51
|
+
if (r.length >= t)
|
|
52
|
+
return e.includes(n) ? e : `${s}${o}${n}${r}`;
|
|
53
|
+
const i = r.padEnd(t, "0");
|
|
54
|
+
return `${s}${o}${n}${i}`;
|
|
55
|
+
}, L = {
|
|
56
56
|
thousand: { size: 3 },
|
|
57
57
|
lakh: { firstGroup: 3, restGroup: 2 },
|
|
58
58
|
wan: { size: 4 }
|
|
59
59
|
};
|
|
60
|
-
function
|
|
61
|
-
if (!e || e === "0" || e ===
|
|
60
|
+
function y(e, t, n = S.Thousand, s = !1, o = ".") {
|
|
61
|
+
if (!e || e === "0" || e === o || e === "-" || e === `-${o}`)
|
|
62
62
|
return e;
|
|
63
|
-
const
|
|
63
|
+
const r = e.includes(o), i = e.startsWith("-"), a = i ? e.slice(1) : e, [c, l] = a.split(o);
|
|
64
64
|
if (!c) {
|
|
65
|
-
const
|
|
66
|
-
return
|
|
65
|
+
const f = l ? `${o}${l}` : a;
|
|
66
|
+
return i ? `-${f}` : f;
|
|
67
67
|
}
|
|
68
|
-
if (
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
73
|
-
const p =
|
|
74
|
-
return
|
|
68
|
+
if (s && c.startsWith("0") && c.length > 1) {
|
|
69
|
+
const f = c.match(/^(0+)/);
|
|
70
|
+
if (f) {
|
|
71
|
+
const d = f[1], g = c.slice(d.length);
|
|
72
|
+
if (g) {
|
|
73
|
+
const p = j(g, t, n), m = d + p, D = i ? "-" : "";
|
|
74
|
+
return r ? l ? `${D}${m}${o}${l}` : `${D}${m}${o}` : `${D}${m}`;
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
const h =
|
|
79
|
-
return
|
|
78
|
+
const h = j(c, t, n), u = i ? "-" : "";
|
|
79
|
+
return r ? l ? `${u}${h}${o}${l}` : `${u}${h}${o}` : `${u}${h}`;
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
function j(e, t, n) {
|
|
82
82
|
if (e === "0" || e === "")
|
|
83
83
|
return e;
|
|
84
84
|
switch (n) {
|
|
85
85
|
case S.None:
|
|
86
86
|
return e;
|
|
87
87
|
case S.Thousand:
|
|
88
|
-
return
|
|
88
|
+
return fe(e, t);
|
|
89
89
|
case S.Lakh:
|
|
90
|
-
return
|
|
90
|
+
return de(e, t);
|
|
91
91
|
case S.Wan:
|
|
92
|
-
return
|
|
92
|
+
return ge(e, t);
|
|
93
93
|
default:
|
|
94
94
|
return e;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
return
|
|
97
|
+
function fe(e, t) {
|
|
98
|
+
return q(e, t, L.thousand.size);
|
|
99
99
|
}
|
|
100
|
-
function
|
|
101
|
-
if (e.length <=
|
|
100
|
+
function de(e, t) {
|
|
101
|
+
if (e.length <= L.lakh.firstGroup)
|
|
102
102
|
return e;
|
|
103
|
-
const n = e.split("").reverse(),
|
|
104
|
-
|
|
105
|
-
for (let
|
|
106
|
-
|
|
107
|
-
return r.reverse().join(t);
|
|
108
|
-
}
|
|
109
|
-
function se(e, t) {
|
|
110
|
-
return z(e, t, N.wan.size);
|
|
111
|
-
}
|
|
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(""));
|
|
103
|
+
const n = e.split("").reverse(), s = [], o = n.slice(0, L.lakh.firstGroup).reverse().join("");
|
|
104
|
+
s.push(o);
|
|
105
|
+
for (let r = L.lakh.firstGroup; r < n.length; r += L.lakh.restGroup)
|
|
106
|
+
s.push(n.slice(r, r + L.lakh.restGroup).reverse().join(""));
|
|
116
107
|
return s.reverse().join(t);
|
|
117
108
|
}
|
|
118
|
-
function
|
|
119
|
-
return (t
|
|
109
|
+
function ge(e, t) {
|
|
110
|
+
return q(e, t, L.wan.size);
|
|
111
|
+
}
|
|
112
|
+
function q(e, t, n) {
|
|
113
|
+
const s = e.split("").reverse(), o = [];
|
|
114
|
+
for (let r = 0; r < s.length; r += n)
|
|
115
|
+
o.push(s.slice(r, r + n).reverse().join(""));
|
|
116
|
+
return o.reverse().join(t);
|
|
117
|
+
}
|
|
118
|
+
function pe(e, t, n) {
|
|
119
|
+
return (t == null ? void 0 : t.formatOn) === $.Change && t.thousandSeparator ? y(
|
|
120
120
|
e,
|
|
121
121
|
t.thousandSeparator,
|
|
122
122
|
t.ThousandStyle ?? S.None,
|
|
123
123
|
t.enableLeadingZeros,
|
|
124
|
-
(n == null ? void 0 : n.decimalSeparator) ??
|
|
124
|
+
(n == null ? void 0 : n.decimalSeparator) ?? N
|
|
125
125
|
) : e;
|
|
126
126
|
}
|
|
127
|
-
function b(e, t, n,
|
|
128
|
-
let
|
|
129
|
-
for (let
|
|
130
|
-
e[
|
|
131
|
-
return
|
|
127
|
+
function b(e, t, n, s = ".") {
|
|
128
|
+
let o = 0;
|
|
129
|
+
for (let r = 0; r < t && r < e.length; r++)
|
|
130
|
+
e[r] !== n && o++;
|
|
131
|
+
return o;
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function Se(e, t, n, s = ".") {
|
|
134
134
|
if (t === 0)
|
|
135
135
|
return 0;
|
|
136
|
-
let
|
|
137
|
-
for (let
|
|
138
|
-
if (e[
|
|
139
|
-
if (
|
|
140
|
-
return
|
|
141
|
-
|
|
136
|
+
let o = 0;
|
|
137
|
+
for (let r = 0; r < e.length; r++)
|
|
138
|
+
if (e[r] !== n) {
|
|
139
|
+
if (o === t - 1)
|
|
140
|
+
return r + 1;
|
|
141
|
+
o++;
|
|
142
142
|
}
|
|
143
143
|
return e.length;
|
|
144
144
|
}
|
|
145
|
-
function
|
|
145
|
+
function A(e, t, n, s = ".") {
|
|
146
146
|
if (t === 0)
|
|
147
147
|
return 0;
|
|
148
|
-
let
|
|
149
|
-
for (let
|
|
150
|
-
if (e[
|
|
151
|
-
if (
|
|
152
|
-
return
|
|
153
|
-
if (
|
|
154
|
-
return
|
|
148
|
+
let o = 0;
|
|
149
|
+
for (let r = 0; r < e.length; r++)
|
|
150
|
+
if (e[r] !== n) {
|
|
151
|
+
if (o++, o === t)
|
|
152
|
+
return r + 1;
|
|
153
|
+
if (o > t)
|
|
154
|
+
return r;
|
|
155
155
|
}
|
|
156
156
|
return e.length;
|
|
157
157
|
}
|
|
158
|
-
function
|
|
158
|
+
function Q(e, t, n) {
|
|
159
159
|
return t < 0 || t >= e.length ? !1 : e[t] === n;
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function me(e, t = {}) {
|
|
162
162
|
const {
|
|
163
163
|
thousandSeparator: n,
|
|
164
|
-
decimalSeparator:
|
|
165
|
-
prefix:
|
|
166
|
-
suffix:
|
|
167
|
-
} = t,
|
|
168
|
-
if (
|
|
169
|
-
const
|
|
170
|
-
|
|
164
|
+
decimalSeparator: s = ".",
|
|
165
|
+
prefix: o = "",
|
|
166
|
+
suffix: r = ""
|
|
167
|
+
} = t, i = Array.from({ length: e.length + 1 }).map(() => !0);
|
|
168
|
+
if (o && i.fill(!1, 0, o.length), r) {
|
|
169
|
+
const a = e.length - r.length;
|
|
170
|
+
i.fill(!1, a + 1, e.length + 1);
|
|
171
171
|
}
|
|
172
|
-
for (let
|
|
173
|
-
const c = e[
|
|
174
|
-
(n && c === n || c ===
|
|
172
|
+
for (let a = 0; a < e.length; a++) {
|
|
173
|
+
const c = e[a];
|
|
174
|
+
(n && c === n || c === s) && (i[a] = !1, a + 1 < e.length && !/\d/.test(e[a + 1]) && (i[a + 1] = !1));
|
|
175
175
|
}
|
|
176
|
-
return
|
|
176
|
+
return i.some((a) => a) || i.fill(!0), i;
|
|
177
177
|
}
|
|
178
|
-
function
|
|
179
|
-
const
|
|
180
|
-
if (t = Math.max(0, Math.min(t,
|
|
178
|
+
function I(e, t, n, s) {
|
|
179
|
+
const o = e.length;
|
|
180
|
+
if (t = Math.max(0, Math.min(t, o)), !n[t]) {
|
|
181
|
+
let r = t;
|
|
182
|
+
for (; r <= o && !n[r]; )
|
|
183
|
+
r++;
|
|
181
184
|
let i = t;
|
|
182
|
-
for (; i
|
|
183
|
-
i
|
|
184
|
-
|
|
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);
|
|
185
|
+
for (; i >= 0 && !n[i]; )
|
|
186
|
+
i--;
|
|
187
|
+
r <= o && i >= 0 ? t = t - i < r - t ? i : r : r <= o ? t = r : i >= 0 && (t = i);
|
|
188
188
|
}
|
|
189
|
-
return (t === -1 || t >
|
|
189
|
+
return (t === -1 || t > o) && (t = o), t;
|
|
190
190
|
}
|
|
191
|
-
const
|
|
192
|
-
function
|
|
191
|
+
const H = (e, t) => e === t;
|
|
192
|
+
function $e(e, t, n, s, o, r, i = ".", a = {}) {
|
|
193
193
|
if (n < 0)
|
|
194
194
|
return 0;
|
|
195
195
|
if (n > e.length || e === "" || t === "")
|
|
@@ -197,285 +197,285 @@ function le(e, t, n, r, s, i, a = ".", o = {}) {
|
|
|
197
197
|
const c = /(\d+\.?\d*)\s*[kmbMTOQaqiSxsxSpOoNn]$/i;
|
|
198
198
|
if (c.test(e) && !c.test(t) && t.length > e.length && n >= e.length - 1)
|
|
199
199
|
return t.length;
|
|
200
|
-
const l = t.length < e.length, h =
|
|
200
|
+
const l = t.length < e.length, h = Q(
|
|
201
201
|
e,
|
|
202
202
|
n,
|
|
203
|
-
|
|
204
|
-
),
|
|
205
|
-
if (
|
|
206
|
-
const p =
|
|
203
|
+
s
|
|
204
|
+
), u = e.indexOf(i), f = t.indexOf(i);
|
|
205
|
+
if (a.isCharacterEquivalent && e !== t) {
|
|
206
|
+
const p = be(
|
|
207
207
|
e,
|
|
208
208
|
t,
|
|
209
209
|
n,
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
210
|
+
a.isCharacterEquivalent || H,
|
|
211
|
+
r,
|
|
212
|
+
a
|
|
213
213
|
);
|
|
214
214
|
if (p !== void 0)
|
|
215
215
|
return p;
|
|
216
216
|
}
|
|
217
217
|
if (l)
|
|
218
|
-
return
|
|
218
|
+
return Ne(
|
|
219
219
|
e,
|
|
220
220
|
t,
|
|
221
221
|
n,
|
|
222
|
-
|
|
222
|
+
s,
|
|
223
223
|
h,
|
|
224
|
-
d,
|
|
225
224
|
u,
|
|
225
|
+
f,
|
|
226
|
+
r,
|
|
226
227
|
i,
|
|
227
|
-
a
|
|
228
|
-
o
|
|
228
|
+
a
|
|
229
229
|
);
|
|
230
|
-
const
|
|
230
|
+
const g = ve(
|
|
231
231
|
e,
|
|
232
232
|
t,
|
|
233
233
|
n,
|
|
234
|
-
|
|
234
|
+
s,
|
|
235
235
|
h,
|
|
236
|
-
|
|
236
|
+
i
|
|
237
237
|
);
|
|
238
|
-
return
|
|
238
|
+
return a.boundary ? I(t, g, a.boundary) : g;
|
|
239
239
|
}
|
|
240
|
-
function
|
|
241
|
-
const
|
|
242
|
-
for (let
|
|
243
|
-
l[
|
|
244
|
-
for (let p = 0; p <
|
|
240
|
+
function be(e, t, n, s, o, r) {
|
|
241
|
+
const i = e.length, a = t.length, c = {}, l = new Array(i);
|
|
242
|
+
for (let g = 0; g < i; g++) {
|
|
243
|
+
l[g] = -1;
|
|
244
|
+
for (let p = 0; p < a; p++) {
|
|
245
245
|
if (c[p]) continue;
|
|
246
|
-
if (
|
|
247
|
-
e[
|
|
246
|
+
if (s(
|
|
247
|
+
e[g],
|
|
248
248
|
t[p],
|
|
249
249
|
{
|
|
250
250
|
oldValue: e,
|
|
251
251
|
newValue: t,
|
|
252
|
-
typedRange:
|
|
253
|
-
oldIndex:
|
|
252
|
+
typedRange: o,
|
|
253
|
+
oldIndex: g,
|
|
254
254
|
newIndex: p
|
|
255
255
|
}
|
|
256
256
|
)) {
|
|
257
|
-
l[
|
|
257
|
+
l[g] = p, c[p] = !0;
|
|
258
258
|
break;
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
let h = n;
|
|
263
|
-
for (; h <
|
|
263
|
+
for (; h < i && (l[h] === -1 || !/\d/.test(e[h])); )
|
|
264
264
|
h++;
|
|
265
|
-
const
|
|
265
|
+
const u = h === i || l[h] === -1 ? a : l[h];
|
|
266
266
|
for (h = n - 1; h >= 0 && l[h] === -1; ) h--;
|
|
267
|
-
const
|
|
268
|
-
if (
|
|
269
|
-
const
|
|
270
|
-
return
|
|
271
|
-
}
|
|
272
|
-
function
|
|
273
|
-
if (
|
|
274
|
-
return
|
|
267
|
+
const f = h === -1 || l[h] === -1 ? 0 : l[h] + 1;
|
|
268
|
+
if (f > u) return u;
|
|
269
|
+
const d = n - f < u - n ? f : u;
|
|
270
|
+
return r.boundary ? I(t, d, r.boundary) : d;
|
|
271
|
+
}
|
|
272
|
+
function Ne(e, t, n, s, o, r, i, a, c, l = {}) {
|
|
273
|
+
if (o)
|
|
274
|
+
return De(
|
|
275
275
|
e,
|
|
276
276
|
t,
|
|
277
277
|
n,
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
s,
|
|
279
|
+
i,
|
|
280
280
|
c
|
|
281
281
|
);
|
|
282
282
|
const h = b(
|
|
283
283
|
e,
|
|
284
284
|
n,
|
|
285
|
-
|
|
285
|
+
s,
|
|
286
286
|
c
|
|
287
|
-
),
|
|
287
|
+
), u = b(
|
|
288
288
|
e,
|
|
289
289
|
e.length,
|
|
290
|
-
|
|
290
|
+
s,
|
|
291
291
|
c
|
|
292
|
-
),
|
|
292
|
+
), f = b(
|
|
293
293
|
t,
|
|
294
294
|
t.length,
|
|
295
|
-
|
|
295
|
+
s,
|
|
296
296
|
c
|
|
297
|
-
),
|
|
297
|
+
), d = u - f, g = Ee(
|
|
298
298
|
e,
|
|
299
299
|
n,
|
|
300
|
-
|
|
300
|
+
s,
|
|
301
301
|
h,
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
302
|
+
d,
|
|
303
|
+
r,
|
|
304
|
+
a,
|
|
305
305
|
c
|
|
306
|
-
), p =
|
|
306
|
+
), p = r === -1 || n <= r, m = Le(
|
|
307
307
|
t,
|
|
308
|
-
f,
|
|
309
|
-
r,
|
|
310
308
|
g,
|
|
311
|
-
|
|
309
|
+
s,
|
|
310
|
+
d,
|
|
311
|
+
a,
|
|
312
312
|
c,
|
|
313
313
|
p,
|
|
314
|
-
|
|
314
|
+
i
|
|
315
315
|
);
|
|
316
|
-
return l.boundary ?
|
|
316
|
+
return l.boundary ? I(t, m, l.boundary) : m;
|
|
317
317
|
}
|
|
318
|
-
function
|
|
319
|
-
const
|
|
320
|
-
if (
|
|
321
|
-
const
|
|
318
|
+
function De(e, t, n, s, o, r) {
|
|
319
|
+
const i = n + 1;
|
|
320
|
+
if (i < e.length) {
|
|
321
|
+
const a = b(
|
|
322
322
|
e,
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
), c =
|
|
323
|
+
i,
|
|
324
|
+
s,
|
|
325
|
+
r
|
|
326
|
+
), c = Se(
|
|
327
327
|
t,
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
328
|
+
a,
|
|
329
|
+
s,
|
|
330
|
+
r
|
|
331
331
|
);
|
|
332
|
-
return c < t.length && t[c] !==
|
|
332
|
+
return c < t.length && t[c] !== s ? c + 1 : c;
|
|
333
333
|
}
|
|
334
334
|
return n;
|
|
335
335
|
}
|
|
336
|
-
function
|
|
337
|
-
if (
|
|
338
|
-
const { start: l, isDelete: h } =
|
|
336
|
+
function Ee(e, t, n, s, o, r, i, a) {
|
|
337
|
+
if (i) {
|
|
338
|
+
const { start: l, isDelete: h } = i;
|
|
339
339
|
return h ? b(
|
|
340
340
|
e,
|
|
341
341
|
l,
|
|
342
342
|
n,
|
|
343
|
-
|
|
343
|
+
a
|
|
344
344
|
) : Math.max(0, b(
|
|
345
345
|
e,
|
|
346
346
|
l,
|
|
347
347
|
n,
|
|
348
|
-
|
|
348
|
+
a
|
|
349
349
|
));
|
|
350
350
|
}
|
|
351
|
-
return t > 0 && e[t - 1] === n &&
|
|
351
|
+
return t > 0 && e[t - 1] === n && o > 0 ? s + 1 : s;
|
|
352
352
|
}
|
|
353
|
-
function
|
|
354
|
-
if (
|
|
355
|
-
const l = e.substring(0,
|
|
353
|
+
function Le(e, t, n, s, o, r, i, a) {
|
|
354
|
+
if (i && a !== -1) {
|
|
355
|
+
const l = e.substring(0, a), h = b(
|
|
356
356
|
l,
|
|
357
357
|
l.length,
|
|
358
358
|
n,
|
|
359
|
-
|
|
359
|
+
r
|
|
360
360
|
);
|
|
361
361
|
if (t <= h) {
|
|
362
|
-
const
|
|
362
|
+
const u = A(
|
|
363
363
|
l,
|
|
364
364
|
t,
|
|
365
365
|
n,
|
|
366
|
-
|
|
366
|
+
r
|
|
367
367
|
);
|
|
368
|
-
if (
|
|
368
|
+
if (u > 0 && u < l.length && b(
|
|
369
369
|
l,
|
|
370
|
-
|
|
370
|
+
u,
|
|
371
371
|
n,
|
|
372
|
-
|
|
372
|
+
r
|
|
373
373
|
) === t) {
|
|
374
|
-
if (l[
|
|
375
|
-
return
|
|
376
|
-
if (!
|
|
377
|
-
return Math.min(
|
|
374
|
+
if (l[u] === n && o && s > 0 && u < l.length - 1)
|
|
375
|
+
return u + 1;
|
|
376
|
+
if (!o && s > 0 && u < l.length - 1)
|
|
377
|
+
return Math.min(u + 1, l.length);
|
|
378
378
|
}
|
|
379
|
-
return
|
|
379
|
+
return u;
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
|
-
const c =
|
|
382
|
+
const c = A(
|
|
383
383
|
e,
|
|
384
384
|
t,
|
|
385
385
|
n,
|
|
386
|
-
|
|
386
|
+
r
|
|
387
387
|
);
|
|
388
388
|
if (c > 0 && c < e.length && b(
|
|
389
389
|
e,
|
|
390
390
|
c,
|
|
391
391
|
n,
|
|
392
|
-
|
|
392
|
+
r
|
|
393
393
|
) === t) {
|
|
394
|
-
if (e[c] === n &&
|
|
394
|
+
if (e[c] === n && o && s > 0 && c < e.length - 1)
|
|
395
395
|
return c + 1;
|
|
396
|
-
if (!
|
|
396
|
+
if (!o && s > 0 && c < e.length - 1)
|
|
397
397
|
return Math.min(c + 1, e.length);
|
|
398
398
|
}
|
|
399
399
|
return c;
|
|
400
400
|
}
|
|
401
|
-
function
|
|
402
|
-
const
|
|
401
|
+
function ve(e, t, n, s, o, r) {
|
|
402
|
+
const i = n >= e.length, a = b(
|
|
403
403
|
e,
|
|
404
404
|
n,
|
|
405
|
-
|
|
406
|
-
|
|
405
|
+
s,
|
|
406
|
+
r
|
|
407
407
|
), c = b(
|
|
408
408
|
e,
|
|
409
409
|
e.length,
|
|
410
|
-
|
|
411
|
-
|
|
410
|
+
s,
|
|
411
|
+
r
|
|
412
412
|
), l = b(
|
|
413
413
|
t,
|
|
414
414
|
t.length,
|
|
415
|
-
|
|
416
|
-
|
|
415
|
+
s,
|
|
416
|
+
r
|
|
417
417
|
);
|
|
418
|
-
if (
|
|
418
|
+
if (i || a === c)
|
|
419
419
|
return t.length;
|
|
420
420
|
const h = l - c;
|
|
421
|
-
let
|
|
422
|
-
h > 0 && !
|
|
423
|
-
const
|
|
421
|
+
let u = a;
|
|
422
|
+
h > 0 && !i && a < c && (u = a + 1);
|
|
423
|
+
const f = A(
|
|
424
424
|
t,
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
425
|
+
u,
|
|
426
|
+
s,
|
|
427
|
+
r
|
|
428
428
|
);
|
|
429
|
-
return
|
|
429
|
+
return o && !Q(t, f, s) ? Math.max(0, f - 1) : f;
|
|
430
430
|
}
|
|
431
|
-
function
|
|
432
|
-
const { selectionStart:
|
|
433
|
-
if (
|
|
434
|
-
const h =
|
|
431
|
+
function we(e, t, n) {
|
|
432
|
+
const { selectionStart: s, selectionEnd: o, endOffset: r = 0 } = e;
|
|
433
|
+
if (s !== o) {
|
|
434
|
+
const h = o - s;
|
|
435
435
|
return {
|
|
436
|
-
start:
|
|
437
|
-
end:
|
|
436
|
+
start: s,
|
|
437
|
+
end: o,
|
|
438
438
|
deletedLength: h,
|
|
439
439
|
isDelete: !1
|
|
440
440
|
};
|
|
441
441
|
}
|
|
442
|
-
if (
|
|
443
|
-
const h =
|
|
442
|
+
if (r > 0) {
|
|
443
|
+
const h = r;
|
|
444
444
|
return {
|
|
445
|
-
start:
|
|
446
|
-
end:
|
|
445
|
+
start: s,
|
|
446
|
+
end: s + h,
|
|
447
447
|
deletedLength: h,
|
|
448
448
|
isDelete: !0
|
|
449
449
|
};
|
|
450
450
|
}
|
|
451
|
-
const
|
|
451
|
+
const a = t.length, c = n.length, l = a - c;
|
|
452
452
|
if (!(l <= 0))
|
|
453
453
|
return {
|
|
454
|
-
start:
|
|
455
|
-
end:
|
|
454
|
+
start: s,
|
|
455
|
+
end: s + l,
|
|
456
456
|
deletedLength: l,
|
|
457
457
|
isDelete: !1
|
|
458
458
|
};
|
|
459
459
|
}
|
|
460
|
-
function
|
|
460
|
+
function ye(e, t) {
|
|
461
461
|
if (e === t)
|
|
462
462
|
return;
|
|
463
463
|
let n = 0;
|
|
464
464
|
for (; n < e.length && n < t.length && e[n] === t[n]; )
|
|
465
465
|
n++;
|
|
466
|
-
let
|
|
467
|
-
for (;
|
|
468
|
-
|
|
469
|
-
const
|
|
470
|
-
if (!(
|
|
466
|
+
let s = e.length - 1, o = t.length - 1;
|
|
467
|
+
for (; s >= n && o >= n && e[s] === t[o]; )
|
|
468
|
+
s--, o--;
|
|
469
|
+
const r = s - n + 1, i = o - n + 1;
|
|
470
|
+
if (!(r === 0 && i === 0))
|
|
471
471
|
return {
|
|
472
472
|
start: n,
|
|
473
|
-
end:
|
|
474
|
-
deletedLength:
|
|
475
|
-
isDelete:
|
|
473
|
+
end: s + 1,
|
|
474
|
+
deletedLength: r,
|
|
475
|
+
isDelete: r > i
|
|
476
476
|
};
|
|
477
477
|
}
|
|
478
|
-
function
|
|
478
|
+
function J(e, t) {
|
|
479
479
|
if (e.value = e.value, e === null)
|
|
480
480
|
return !1;
|
|
481
481
|
if (e.createTextRange) {
|
|
@@ -484,114 +484,348 @@ function G(e, t) {
|
|
|
484
484
|
}
|
|
485
485
|
return e.selectionStart !== null || e.selectionStart === 0 ? (e.focus(), e.setSelectionRange(t, t), !0) : (e.focus(), !1);
|
|
486
486
|
}
|
|
487
|
-
function
|
|
488
|
-
return e.selectionStart === 0 && e.selectionEnd === e.value.length ? null : (
|
|
489
|
-
e.value === n && e.selectionStart !== t &&
|
|
487
|
+
function Me(e, t, n) {
|
|
488
|
+
return e.selectionStart === 0 && e.selectionEnd === e.value.length ? null : (J(e, t), setTimeout(() => {
|
|
489
|
+
e.value === n && e.selectionStart !== t && J(e, t);
|
|
490
490
|
}, 0));
|
|
491
491
|
}
|
|
492
|
-
function
|
|
492
|
+
function xe(e) {
|
|
493
493
|
return Math.max(e.selectionStart, e.selectionEnd);
|
|
494
494
|
}
|
|
495
|
-
function
|
|
496
|
-
if ((n == null ? void 0 : n.formatOn) !==
|
|
495
|
+
function Ce(e, t, n) {
|
|
496
|
+
if ((n == null ? void 0 : n.formatOn) !== $.Change || !n.thousandSeparator)
|
|
497
497
|
return;
|
|
498
|
-
const { selectionStart:
|
|
499
|
-
if (
|
|
498
|
+
const { selectionStart: s, selectionEnd: o, value: r } = t;
|
|
499
|
+
if (s === null || o === null || s !== o)
|
|
500
500
|
return;
|
|
501
|
-
const { key:
|
|
502
|
-
|
|
503
|
-
}
|
|
504
|
-
function
|
|
505
|
-
if (!
|
|
506
|
-
const { selectionStart:
|
|
507
|
-
let h =
|
|
508
|
-
{ selectionStart:
|
|
501
|
+
const { key: i } = e, a = n.thousandSeparator;
|
|
502
|
+
i === "Backspace" && s > 0 && r[s - 1] === a && t.setSelectionRange(s - 1, s - 1), i === "Delete" && r[s] === a && t.setSelectionRange(s + 1, s + 1);
|
|
503
|
+
}
|
|
504
|
+
function Ae(e, t, n, s, o, r, i) {
|
|
505
|
+
if (!o) return;
|
|
506
|
+
const { selectionStart: a = 0, selectionEnd: c = 0, endOffset: l = 0 } = o;
|
|
507
|
+
let h = we(
|
|
508
|
+
{ selectionStart: a, selectionEnd: c, endOffset: l },
|
|
509
509
|
t,
|
|
510
510
|
n
|
|
511
511
|
);
|
|
512
|
-
if (h || (h =
|
|
513
|
-
const
|
|
514
|
-
thousandSeparator: (
|
|
515
|
-
decimalSeparator:
|
|
516
|
-
}),
|
|
517
|
-
thousandSeparator: (
|
|
518
|
-
isCharacterEquivalent:
|
|
519
|
-
boundary:
|
|
520
|
-
},
|
|
512
|
+
if (h || (h = ye(t, n)), !h) return;
|
|
513
|
+
const u = me(n, {
|
|
514
|
+
thousandSeparator: (i == null ? void 0 : i.thousandSeparator) ?? r.thousandSeparator,
|
|
515
|
+
decimalSeparator: r.decimalSeparator
|
|
516
|
+
}), f = {
|
|
517
|
+
thousandSeparator: (i == null ? void 0 : i.thousandSeparator) ?? r.thousandSeparator,
|
|
518
|
+
isCharacterEquivalent: H,
|
|
519
|
+
boundary: u
|
|
520
|
+
}, d = (i == null ? void 0 : i.thousandSeparator) ?? r.thousandSeparator ?? ",", g = (i == null ? void 0 : i.ThousandStyle) ?? S.None, p = $e(
|
|
521
521
|
t,
|
|
522
522
|
n,
|
|
523
|
-
|
|
523
|
+
s,
|
|
524
|
+
d,
|
|
524
525
|
g,
|
|
526
|
+
h,
|
|
527
|
+
r.decimalSeparator,
|
|
528
|
+
f
|
|
529
|
+
);
|
|
530
|
+
Me(e, p, n);
|
|
531
|
+
}
|
|
532
|
+
function V(e) {
|
|
533
|
+
const [t, n = ""] = e.split(".");
|
|
534
|
+
return t.length + n.length > 30;
|
|
535
|
+
}
|
|
536
|
+
function X(e, t) {
|
|
537
|
+
const n = e.replace(".", ""), s = t.replace(".", ""), o = Math.max(n.length, s.length), r = n.padStart(o, "0"), i = s.padStart(o, "0");
|
|
538
|
+
for (let a = 0; a < o; a++) {
|
|
539
|
+
const c = parseInt(r[a], 10), l = parseInt(i[a], 10);
|
|
540
|
+
if (c !== l)
|
|
541
|
+
return c - l;
|
|
542
|
+
}
|
|
543
|
+
return 0;
|
|
544
|
+
}
|
|
545
|
+
const Te = [
|
|
546
|
+
{ suffix: "N", zeros: 30 },
|
|
547
|
+
// Nonillion
|
|
548
|
+
{ suffix: "O", zeros: 27 },
|
|
549
|
+
// Octillion
|
|
550
|
+
{ suffix: "Sp", zeros: 24 },
|
|
551
|
+
// Septillion
|
|
552
|
+
{ suffix: "Sx", zeros: 21 },
|
|
553
|
+
// Sextillion
|
|
554
|
+
{ suffix: "Qi", zeros: 18 },
|
|
555
|
+
// Quintillion
|
|
556
|
+
{ suffix: "Qa", zeros: 15 },
|
|
557
|
+
// Quadrillion
|
|
558
|
+
{ suffix: "T", zeros: 12 },
|
|
559
|
+
// Trillion
|
|
560
|
+
{ suffix: "B", zeros: 9 },
|
|
561
|
+
// Billion
|
|
562
|
+
{ suffix: "M", zeros: 6 },
|
|
563
|
+
// Million
|
|
564
|
+
{ suffix: "k", zeros: 3 }
|
|
565
|
+
// Thousand
|
|
566
|
+
];
|
|
567
|
+
function Y(e, t, n = 0) {
|
|
568
|
+
const [s, o = ""] = e.split(t), r = s.replace(/^0+/, "") || "0";
|
|
569
|
+
for (const i of Te)
|
|
570
|
+
if (i.zeros >= n && (r.length > i.zeros || r.length === i.zeros && o.length > 0)) {
|
|
571
|
+
const a = i.zeros;
|
|
572
|
+
if (r.length > a) {
|
|
573
|
+
const c = r.slice(0, -a), u = (r.slice(-a) + o).replace(/0+$/, "");
|
|
574
|
+
return { scaledValue: u ? `${c}${t}${u}` : c, scaleSuffix: i.suffix };
|
|
575
|
+
} else {
|
|
576
|
+
const c = a - r.length, l = "0", u = ("0".repeat(c) + r + o).replace(/0+$/, "");
|
|
577
|
+
return { scaledValue: u ? `${l}${t}${u}` : l, scaleSuffix: i.suffix };
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
return { scaledValue: e, scaleSuffix: "" };
|
|
581
|
+
}
|
|
582
|
+
function P(e, t, n, s, o = !1, r = !1) {
|
|
583
|
+
if (r && o && n > 0)
|
|
584
|
+
return `0${s}${"0".repeat(n)}`;
|
|
585
|
+
const [i, a = ""] = e.split(s);
|
|
586
|
+
let c;
|
|
587
|
+
if (t === 0)
|
|
588
|
+
c = i;
|
|
589
|
+
else if (a.length === 0) {
|
|
590
|
+
const l = "0".repeat(Math.max(t, n));
|
|
591
|
+
c = `${i}${s}${l}`;
|
|
592
|
+
} else if (a.length < t) {
|
|
593
|
+
const l = Math.max(t - a.length, n - a.length);
|
|
594
|
+
c = `${i}${s}${a}${"0".repeat(l)}`;
|
|
595
|
+
} else
|
|
596
|
+
c = `${i}${s}${a.slice(0, t)}`;
|
|
597
|
+
if (n > 0) {
|
|
598
|
+
const [l, h = ""] = c.split(s);
|
|
599
|
+
if (h.length < n) {
|
|
600
|
+
const u = n - h.length;
|
|
601
|
+
c = `${l}${s}${h}${"0".repeat(u)}`;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
if (n === 0)
|
|
605
|
+
c = c.replace(/(\.[0-9]*?)0+$/, "$1").replace(/\.$/, "");
|
|
606
|
+
else {
|
|
607
|
+
const [l, h = ""] = c.split(s);
|
|
608
|
+
if (h) {
|
|
609
|
+
const u = h.replace(/0+$/, ""), f = u.length >= n ? u : h.slice(0, n);
|
|
610
|
+
c = f ? `${l}${s}${f}` : l;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
return c;
|
|
614
|
+
}
|
|
615
|
+
function F(e, t) {
|
|
616
|
+
return !e || e === "0" || e === t || e === "-" || e === `-${t}`;
|
|
617
|
+
}
|
|
618
|
+
function ee(e) {
|
|
619
|
+
const t = e.startsWith("-");
|
|
620
|
+
return { isNegative: t, absoluteValue: t ? e.slice(1) : e };
|
|
621
|
+
}
|
|
622
|
+
function te(e, t) {
|
|
623
|
+
if (!e || e === "0")
|
|
624
|
+
return "0";
|
|
625
|
+
const n = e.includes(t), [s, o = ""] = n ? e.split(t) : [e, ""];
|
|
626
|
+
let r;
|
|
627
|
+
if (o.length <= 2) {
|
|
628
|
+
const a = 2 - o.length;
|
|
629
|
+
r = s + o + "0".repeat(a);
|
|
630
|
+
} else
|
|
631
|
+
r = s + o.slice(0, 2) + t + o.slice(2);
|
|
632
|
+
let i = r.replace(/^0+/, "") || "0";
|
|
633
|
+
if (i.startsWith(t) && (i = "0" + i), i.includes(t)) {
|
|
634
|
+
const [a, c] = i.split(t);
|
|
635
|
+
return a === "0" && !c ? "0" : i;
|
|
636
|
+
}
|
|
637
|
+
return i;
|
|
638
|
+
}
|
|
639
|
+
function Ie(e, t) {
|
|
640
|
+
const { decimals: n, decimalSeparator: s, thousandSeparator: o, thousandStyle: r, decimalsMin: i = 0 } = t;
|
|
641
|
+
if (F(e, s))
|
|
642
|
+
return "0";
|
|
643
|
+
const { isNegative: a, absoluteValue: c } = ee(e), l = te(c, s);
|
|
644
|
+
let h = l;
|
|
645
|
+
o && r !== S.None && (h = y(l, o, r, !1, s));
|
|
646
|
+
const u = P(
|
|
647
|
+
h,
|
|
648
|
+
n,
|
|
649
|
+
i,
|
|
650
|
+
s,
|
|
651
|
+
!1,
|
|
652
|
+
e === "0"
|
|
653
|
+
);
|
|
654
|
+
return `${a ? "-" : ""}${u}`;
|
|
655
|
+
}
|
|
656
|
+
function ot(e, t = 2, n = N, s, o = S.None) {
|
|
657
|
+
const r = Ie(e, {
|
|
658
|
+
decimals: t,
|
|
659
|
+
decimalSeparator: n,
|
|
660
|
+
thousandSeparator: s,
|
|
661
|
+
thousandStyle: o,
|
|
662
|
+
decimalsMin: t
|
|
663
|
+
// Use decimals as decimalsMin to ensure trailing zeros are shown
|
|
664
|
+
});
|
|
665
|
+
return r === "0" ? "0%" : `${r}%`;
|
|
666
|
+
}
|
|
667
|
+
function at(e, t = 2, n = {}) {
|
|
668
|
+
const {
|
|
669
|
+
missingPlaceholder: s = "?",
|
|
670
|
+
veryLargePlaceholder: o = "🔥",
|
|
671
|
+
decimalsUnder: r = 1e3,
|
|
672
|
+
decimalSeparator: i = N,
|
|
673
|
+
thousandSeparator: a,
|
|
674
|
+
thousandStyle: c = S.None
|
|
675
|
+
} = n;
|
|
676
|
+
if (e == null || e === "")
|
|
677
|
+
return s;
|
|
678
|
+
if (F(e, i))
|
|
679
|
+
return "0%";
|
|
680
|
+
const { isNegative: l, absoluteValue: h } = ee(e), u = te(h, i);
|
|
681
|
+
if (V(u))
|
|
682
|
+
return o;
|
|
683
|
+
const { scaledValue: f, scaleSuffix: d } = Y(u, i), p = X(f, r.toString()) < 0 ? t : 0;
|
|
684
|
+
let m = f;
|
|
685
|
+
a && c !== S.None && (m = y(f, a, c, !1, i));
|
|
686
|
+
const D = P(
|
|
687
|
+
m,
|
|
688
|
+
p,
|
|
689
|
+
p,
|
|
690
|
+
i,
|
|
691
|
+
!1,
|
|
692
|
+
!1
|
|
693
|
+
);
|
|
694
|
+
return `${l ? "-" : ""}${D}${d}%`;
|
|
695
|
+
}
|
|
696
|
+
function Pe(e) {
|
|
697
|
+
const t = "₀₁₂₃₄₅₆₇₈₉";
|
|
698
|
+
return e.replace(/[0-9]/g, (n) => t[+n]);
|
|
699
|
+
}
|
|
700
|
+
function ct(e, t = 8, n = N) {
|
|
701
|
+
if (!e || !e.includes(n))
|
|
702
|
+
return e;
|
|
703
|
+
const s = e.startsWith("-"), o = s ? e.slice(1) : e, [r, i] = o.split(n);
|
|
704
|
+
if (!i || !i.length)
|
|
705
|
+
return e;
|
|
706
|
+
const a = i.match(/^(0{3,})/);
|
|
707
|
+
if (!a)
|
|
708
|
+
return e;
|
|
709
|
+
const l = a[1].length, h = i.slice(l), u = r === "0" && l >= 5 ? l + 1 : l, f = Pe(u.toString());
|
|
710
|
+
let d = `0${f}${h}`;
|
|
711
|
+
const g = f.length, p = Math.max(0, t - g - 1);
|
|
712
|
+
h.length > p && (d = `0${f}${h.slice(0, p)}`), d = d.replace(/0+$/, "");
|
|
713
|
+
const m = r === "0" ? d : `${r}${d}`;
|
|
714
|
+
return s ? `-${m}` : m;
|
|
715
|
+
}
|
|
716
|
+
const E = {
|
|
717
|
+
minScale: 0,
|
|
718
|
+
decimalsUnder: 1e3,
|
|
719
|
+
decimals: 2,
|
|
720
|
+
decimalsMin: 0,
|
|
721
|
+
decimalsMinAppliesToZero: !1,
|
|
722
|
+
veryLargePlaceholder: "🔥",
|
|
723
|
+
decimalSeparator: N
|
|
724
|
+
};
|
|
725
|
+
function lt(e, t = {}) {
|
|
726
|
+
const {
|
|
727
|
+
minScale: n = E.minScale,
|
|
728
|
+
decimalsUnder: s = E.decimalsUnder,
|
|
729
|
+
decimals: o = E.decimals,
|
|
730
|
+
decimalsMin: r = E.decimalsMin,
|
|
731
|
+
decimalsMinAppliesToZero: i = E.decimalsMinAppliesToZero,
|
|
732
|
+
veryLargePlaceholder: a = E.veryLargePlaceholder,
|
|
733
|
+
decimalSeparator: c = E.decimalSeparator,
|
|
734
|
+
thousandSeparator: l,
|
|
735
|
+
thousandStyle: h = S.None
|
|
736
|
+
} = t;
|
|
737
|
+
if (!e || e === "0" || e === c || e === "-" || e === `-${c}`)
|
|
738
|
+
return i && r > 0 ? `0${c}${"0".repeat(r)}` : "0";
|
|
739
|
+
const u = e.startsWith("-"), f = u ? e.slice(1) : e;
|
|
740
|
+
if (V(f))
|
|
741
|
+
return a;
|
|
742
|
+
const { scaledValue: d, scaleSuffix: g } = Y(
|
|
525
743
|
f,
|
|
744
|
+
c,
|
|
745
|
+
n
|
|
746
|
+
), m = X(d, s.toString()) < 0 ? o : 0;
|
|
747
|
+
let D = d;
|
|
748
|
+
l && h !== S.None && (D = y(
|
|
749
|
+
d,
|
|
750
|
+
l,
|
|
526
751
|
h,
|
|
527
|
-
|
|
528
|
-
|
|
752
|
+
!1,
|
|
753
|
+
c
|
|
754
|
+
));
|
|
755
|
+
const R = P(
|
|
756
|
+
D,
|
|
757
|
+
m,
|
|
758
|
+
r,
|
|
759
|
+
c,
|
|
760
|
+
i,
|
|
761
|
+
e === "0"
|
|
762
|
+
// Pass whether the original value is '0'
|
|
529
763
|
);
|
|
530
|
-
|
|
764
|
+
return `${u ? "-" : ""}${R}${g}`;
|
|
531
765
|
}
|
|
532
|
-
function
|
|
766
|
+
function x(e) {
|
|
533
767
|
return e.replace(/[-[\]/{}()*+?.\\^$|]/g, "\\$&");
|
|
534
768
|
}
|
|
535
|
-
const
|
|
536
|
-
const
|
|
769
|
+
const Oe = (e, t = !1, n = ".") => {
|
|
770
|
+
const s = x(n), o = new RegExp(`[^0-9${s}]`, "g");
|
|
537
771
|
if (!t)
|
|
538
|
-
return e.replace(
|
|
539
|
-
const
|
|
540
|
-
if (
|
|
541
|
-
if (
|
|
542
|
-
return "-" +
|
|
772
|
+
return e.replace(o, "");
|
|
773
|
+
const r = e.startsWith("-"), i = e.replace(o, "");
|
|
774
|
+
if (r) {
|
|
775
|
+
if (i.length > 0)
|
|
776
|
+
return "-" + i;
|
|
543
777
|
if (e === "-")
|
|
544
778
|
return "-";
|
|
545
779
|
}
|
|
546
|
-
return
|
|
780
|
+
return i;
|
|
547
781
|
};
|
|
548
|
-
function
|
|
782
|
+
function Re(e) {
|
|
549
783
|
const t = /([+-]?\d+\.?\d*)[eE]([+-]?\d+)/g;
|
|
550
|
-
let n = e,
|
|
551
|
-
const
|
|
552
|
-
for (; (
|
|
553
|
-
const
|
|
784
|
+
let n = e, s;
|
|
785
|
+
const o = [];
|
|
786
|
+
for (; (s = t.exec(e)) !== null; ) {
|
|
787
|
+
const r = s[0], i = s[1], a = parseInt(s[2], 10);
|
|
554
788
|
let c;
|
|
555
|
-
if (
|
|
556
|
-
c =
|
|
789
|
+
if (a === 0)
|
|
790
|
+
c = i;
|
|
557
791
|
else {
|
|
558
|
-
const l =
|
|
559
|
-
|
|
792
|
+
const l = i.startsWith("-"), h = l ? i.slice(1) : i, [u, f = ""] = h.split(".");
|
|
793
|
+
a > 0 ? c = _e(u, f, a) : c = ze(u, f, Math.abs(a)), l && (c = "-" + c);
|
|
560
794
|
}
|
|
561
|
-
|
|
795
|
+
o.push({ full: r, expanded: c });
|
|
562
796
|
}
|
|
563
|
-
for (const { full:
|
|
564
|
-
n = n.replace(
|
|
797
|
+
for (const { full: r, expanded: i } of o)
|
|
798
|
+
n = n.replace(r, i);
|
|
565
799
|
return n;
|
|
566
800
|
}
|
|
567
|
-
function
|
|
568
|
-
const
|
|
569
|
-
if (
|
|
801
|
+
function _e(e, t, n) {
|
|
802
|
+
const s = e + t;
|
|
803
|
+
if (s === "0" || s.match(/^0+$/))
|
|
570
804
|
return "0";
|
|
571
|
-
const
|
|
572
|
-
if (n <=
|
|
573
|
-
const
|
|
574
|
-
return
|
|
805
|
+
const o = t.length;
|
|
806
|
+
if (n <= o) {
|
|
807
|
+
const i = s.slice(0, e.length + n), a = s.slice(e.length + n);
|
|
808
|
+
return a ? `${i}.${a}` : i;
|
|
575
809
|
}
|
|
576
|
-
const
|
|
577
|
-
return
|
|
810
|
+
const r = n - o;
|
|
811
|
+
return s + "0".repeat(r);
|
|
578
812
|
}
|
|
579
|
-
function
|
|
580
|
-
const
|
|
581
|
-
if (
|
|
813
|
+
function ze(e, t, n) {
|
|
814
|
+
const s = e + t;
|
|
815
|
+
if (s === "0" || s.match(/^0+$/))
|
|
582
816
|
return "0";
|
|
583
|
-
const
|
|
584
|
-
if (
|
|
585
|
-
const
|
|
586
|
-
return
|
|
817
|
+
const i = e.length - n;
|
|
818
|
+
if (i <= 0) {
|
|
819
|
+
const a = Math.abs(i), c = `0.${"0".repeat(a)}${s}`;
|
|
820
|
+
return C(c);
|
|
587
821
|
}
|
|
588
|
-
if (
|
|
589
|
-
const
|
|
590
|
-
return
|
|
822
|
+
if (i < e.length) {
|
|
823
|
+
const a = s.slice(0, i), c = s.slice(i), l = `${a}.${c}`;
|
|
824
|
+
return C(l);
|
|
591
825
|
}
|
|
592
|
-
return
|
|
826
|
+
return C(s);
|
|
593
827
|
}
|
|
594
|
-
function
|
|
828
|
+
function C(e) {
|
|
595
829
|
if (!e.includes("."))
|
|
596
830
|
return e;
|
|
597
831
|
if (e === "0" || e === "0.")
|
|
@@ -606,10 +840,10 @@ function y(e) {
|
|
|
606
840
|
}
|
|
607
841
|
return e.replace(/\.?0+$/, "") || e;
|
|
608
842
|
}
|
|
609
|
-
function
|
|
843
|
+
function Ze(e) {
|
|
610
844
|
const t = /(\d+\.?\d*)\s*(Qa|Qi|Sx|Sp|[kmbMTO]|N)/gi;
|
|
611
|
-
return e.replace(t, (n,
|
|
612
|
-
const
|
|
845
|
+
return e.replace(t, (n, s, o) => {
|
|
846
|
+
const r = {
|
|
613
847
|
k: 3,
|
|
614
848
|
// Thousand
|
|
615
849
|
K: 3,
|
|
@@ -627,66 +861,66 @@ function Me(e) {
|
|
|
627
861
|
t: 12
|
|
628
862
|
// Trillion
|
|
629
863
|
};
|
|
630
|
-
let
|
|
631
|
-
if (
|
|
632
|
-
const
|
|
633
|
-
|
|
864
|
+
let i;
|
|
865
|
+
if (o.length > 1) {
|
|
866
|
+
const d = o.charAt(0).toUpperCase() + o.slice(1).toLowerCase();
|
|
867
|
+
i = r[o] || r[d];
|
|
634
868
|
} else {
|
|
635
|
-
const
|
|
636
|
-
|
|
869
|
+
const d = o.toLowerCase();
|
|
870
|
+
i = r[o] || r[d];
|
|
637
871
|
}
|
|
638
|
-
if (!
|
|
872
|
+
if (!i)
|
|
639
873
|
return n;
|
|
640
|
-
const
|
|
641
|
-
let
|
|
874
|
+
const a = s.startsWith("-"), c = a ? s.slice(1) : s, [l, h = ""] = c.split("."), u = l.replace(/^0+/, "") || "0";
|
|
875
|
+
let f;
|
|
642
876
|
if (h.length === 0)
|
|
643
|
-
|
|
644
|
-
else if (h.length <=
|
|
645
|
-
const
|
|
646
|
-
|
|
877
|
+
f = u + "0".repeat(i);
|
|
878
|
+
else if (h.length <= i) {
|
|
879
|
+
const d = i - h.length;
|
|
880
|
+
f = u + h + "0".repeat(d);
|
|
647
881
|
} else {
|
|
648
|
-
const
|
|
649
|
-
|
|
882
|
+
const d = h.slice(0, i), g = h.slice(i);
|
|
883
|
+
f = u + d + "." + g;
|
|
650
884
|
}
|
|
651
|
-
return
|
|
885
|
+
return f = f.replace(/^(-?)0+([1-9])/, "$1$2"), f.match(/^-?0+$/) && (f = a ? "-0" : "0"), f.includes(".") && (f = f.replace(/\.?0+$/, "")), a && !f.startsWith("-") ? "-" + f : f;
|
|
652
886
|
});
|
|
653
887
|
}
|
|
654
|
-
function
|
|
888
|
+
function Be(e) {
|
|
655
889
|
if (!e || e === "0" || e === "-0" || e === "-" || e === ".")
|
|
656
890
|
return e;
|
|
657
891
|
const t = e.startsWith("-"), n = t ? e.slice(1) : e;
|
|
658
892
|
if (!n || n === "0" || n === ".")
|
|
659
893
|
return e;
|
|
660
894
|
if (n.includes(".")) {
|
|
661
|
-
const [
|
|
662
|
-
if (
|
|
663
|
-
const
|
|
664
|
-
return t ? "-" +
|
|
895
|
+
const [o, r] = n.split(".");
|
|
896
|
+
if (o && o.length > 0) {
|
|
897
|
+
const a = (o.replace(/^0+/, "") || "0") + "." + r;
|
|
898
|
+
return t ? "-" + a : a;
|
|
665
899
|
}
|
|
666
900
|
return e;
|
|
667
901
|
}
|
|
668
902
|
if (n.startsWith("0") && n.length > 1) {
|
|
669
|
-
const
|
|
670
|
-
return t ? "-" +
|
|
903
|
+
const o = n.replace(/^0+/, "") || "0";
|
|
904
|
+
return t ? "-" + o : o;
|
|
671
905
|
}
|
|
672
906
|
return e;
|
|
673
907
|
}
|
|
674
|
-
function
|
|
908
|
+
function We(e) {
|
|
675
909
|
return e.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000]/g, " ").replace(/\s/g, "");
|
|
676
910
|
}
|
|
677
|
-
function
|
|
678
|
-
const n =
|
|
911
|
+
function w(e, t) {
|
|
912
|
+
const n = x(t);
|
|
679
913
|
return e.replace(new RegExp(n, "g"), "");
|
|
680
914
|
}
|
|
681
|
-
const
|
|
682
|
-
let n =
|
|
683
|
-
return t != null && t.thousandSeparator && (n =
|
|
915
|
+
const ke = (e, t) => {
|
|
916
|
+
let n = We(e);
|
|
917
|
+
return t != null && t.thousandSeparator && (n = w(n, t.thousandSeparator)), t != null && t.enableCompactNotation && (n = Ze(n)), n = Re(n), n = Oe(
|
|
684
918
|
n,
|
|
685
919
|
t == null ? void 0 : t.enableNegative,
|
|
686
920
|
t == null ? void 0 : t.decimalSeparator
|
|
687
|
-
), n =
|
|
921
|
+
), n = he(n, (t == null ? void 0 : t.decimalSeparator) || N), t != null && t.enableLeadingZeros || (n = Be(n)), n;
|
|
688
922
|
};
|
|
689
|
-
function
|
|
923
|
+
function Ue(e, t, n) {
|
|
690
924
|
return {
|
|
691
925
|
enableCompactNotation: e == null ? void 0 : e.enableCompactNotation,
|
|
692
926
|
enableNegative: e == null ? void 0 : e.enableNegative,
|
|
@@ -695,31 +929,31 @@ function Te(e, t, n) {
|
|
|
695
929
|
thousandSeparator: n ? t.thousandSeparator : void 0
|
|
696
930
|
};
|
|
697
931
|
}
|
|
698
|
-
function
|
|
699
|
-
const
|
|
932
|
+
function O(e, t, n, s) {
|
|
933
|
+
const o = T(n), r = s ?? (n == null ? void 0 : n.formatOn) === $.Change, i = ke(
|
|
700
934
|
e,
|
|
701
|
-
|
|
702
|
-
),
|
|
703
|
-
|
|
935
|
+
Ue(n, o, r)
|
|
936
|
+
), a = le(
|
|
937
|
+
i,
|
|
704
938
|
t,
|
|
705
|
-
|
|
706
|
-
), c = (n == null ? void 0 : n.decimalMinLength) ?? 0, l =
|
|
707
|
-
|
|
939
|
+
o.decimalSeparator
|
|
940
|
+
), c = (n == null ? void 0 : n.decimalMinLength) ?? 0, l = ue(
|
|
941
|
+
a,
|
|
708
942
|
c,
|
|
709
|
-
|
|
943
|
+
o.decimalSeparator
|
|
710
944
|
), h = l;
|
|
711
|
-
return { formatted:
|
|
945
|
+
return { formatted: pe(l, n, o), raw: h };
|
|
712
946
|
}
|
|
713
|
-
function
|
|
714
|
-
const
|
|
715
|
-
return
|
|
947
|
+
function ht(e, t, n) {
|
|
948
|
+
const s = !!(n != null && n.thousandSeparator);
|
|
949
|
+
return O(
|
|
716
950
|
e,
|
|
717
951
|
t,
|
|
718
952
|
n,
|
|
719
|
-
|
|
953
|
+
s
|
|
720
954
|
);
|
|
721
955
|
}
|
|
722
|
-
function
|
|
956
|
+
function Ge(e, t, n) {
|
|
723
957
|
if (e === "Backspace" || e === "Delete")
|
|
724
958
|
return e === "Delete" && t === n ? {
|
|
725
959
|
endOffset: 1
|
|
@@ -727,61 +961,61 @@ function xe(e, t, n) {
|
|
|
727
961
|
endOffset: 0
|
|
728
962
|
};
|
|
729
963
|
}
|
|
730
|
-
function
|
|
731
|
-
const { decimalSeparator: n } =
|
|
732
|
-
if (
|
|
964
|
+
function je(e, t) {
|
|
965
|
+
const { decimalSeparator: n } = T(t), s = e.target;
|
|
966
|
+
if (ce(e, s, n)) {
|
|
733
967
|
e.preventDefault();
|
|
734
968
|
return;
|
|
735
969
|
}
|
|
736
|
-
return
|
|
970
|
+
return Ce(e, s, t), Ge(e.key, s.selectionStart, s.selectionEnd);
|
|
737
971
|
}
|
|
738
|
-
function
|
|
739
|
-
const
|
|
740
|
-
i,
|
|
741
|
-
t,
|
|
972
|
+
function Je(e, t, n, s) {
|
|
973
|
+
const o = e.target, r = o.value, i = xe(o), a = T(s), c = (s == null ? void 0 : s.formatOn) === $.Change, { formatted: l, raw: h } = O(
|
|
742
974
|
r,
|
|
975
|
+
t,
|
|
976
|
+
s,
|
|
743
977
|
c
|
|
744
978
|
);
|
|
745
|
-
return
|
|
746
|
-
|
|
747
|
-
|
|
979
|
+
return o.value = l, r !== l && Ae(
|
|
980
|
+
o,
|
|
981
|
+
r,
|
|
748
982
|
l,
|
|
749
|
-
|
|
983
|
+
i,
|
|
750
984
|
n,
|
|
751
|
-
|
|
752
|
-
|
|
985
|
+
a,
|
|
986
|
+
s
|
|
753
987
|
), { formatted: l, raw: h };
|
|
754
988
|
}
|
|
755
|
-
function
|
|
756
|
-
const
|
|
757
|
-
return e + t +
|
|
989
|
+
function Ke(e, t, n, s) {
|
|
990
|
+
const o = s - n;
|
|
991
|
+
return e + t + o;
|
|
758
992
|
}
|
|
759
|
-
function
|
|
760
|
-
var
|
|
993
|
+
function qe(e, t, n) {
|
|
994
|
+
var f;
|
|
761
995
|
e.preventDefault();
|
|
762
|
-
const
|
|
996
|
+
const s = e.target, { value: o, selectionStart: r, selectionEnd: i } = s, a = ((f = e.clipboardData) == null ? void 0 : f.getData("text/plain")) || "", c = o.slice(0, r || 0) + a + o.slice(i || 0), { formatted: l, raw: h } = O(
|
|
763
997
|
c,
|
|
764
998
|
t,
|
|
765
999
|
n,
|
|
766
1000
|
!0
|
|
767
1001
|
);
|
|
768
|
-
|
|
769
|
-
const
|
|
770
|
-
|
|
771
|
-
|
|
1002
|
+
s.value = l;
|
|
1003
|
+
const u = Ke(
|
|
1004
|
+
r || 0,
|
|
1005
|
+
a.length,
|
|
772
1006
|
c.length,
|
|
773
1007
|
l.length
|
|
774
1008
|
);
|
|
775
|
-
return
|
|
1009
|
+
return s.setSelectionRange(u, u), { formatted: l, raw: h };
|
|
776
1010
|
}
|
|
777
|
-
function
|
|
778
|
-
const n =
|
|
1011
|
+
function Qe(e, t) {
|
|
1012
|
+
const n = x(e);
|
|
779
1013
|
return t ? `^-?[0-9]*[${n}]?[0-9]*$` : `^[0-9]*[${n}]?[0-9]*$`;
|
|
780
1014
|
}
|
|
781
|
-
function
|
|
782
|
-
|
|
1015
|
+
function He(e) {
|
|
1016
|
+
Ve(e.decimalMaxLength), Xe(e.decimalMinLength), Ye(e.decimalMinLength, e.decimalMaxLength), Fe(e.formatOn), et(e.thousandSeparator), tt(e.thousandStyle), nt(e.decimalSeparator), st(e.thousandSeparator, e.decimalSeparator), M("enableCompactNotation", e.enableCompactNotation), M("enableNegative", e.enableNegative), M("enableLeadingZeros", e.enableLeadingZeros), M("rawValueMode", e.rawValueMode), rt(e.onChange);
|
|
783
1017
|
}
|
|
784
|
-
function
|
|
1018
|
+
function Ve(e) {
|
|
785
1019
|
if (e !== void 0) {
|
|
786
1020
|
if (typeof e != "number")
|
|
787
1021
|
throw new Error(
|
|
@@ -797,7 +1031,7 @@ function We(e) {
|
|
|
797
1031
|
);
|
|
798
1032
|
}
|
|
799
1033
|
}
|
|
800
|
-
function
|
|
1034
|
+
function Xe(e) {
|
|
801
1035
|
if (e !== void 0) {
|
|
802
1036
|
if (typeof e != "number")
|
|
803
1037
|
throw new Error(
|
|
@@ -813,19 +1047,19 @@ function ke(e) {
|
|
|
813
1047
|
);
|
|
814
1048
|
}
|
|
815
1049
|
}
|
|
816
|
-
function
|
|
1050
|
+
function Ye(e, t) {
|
|
817
1051
|
if (!(e === void 0 || t === void 0) && e > t)
|
|
818
1052
|
throw new Error(
|
|
819
1053
|
`decimalMinLength (${e}) cannot be greater than decimalMaxLength (${t}).`
|
|
820
1054
|
);
|
|
821
1055
|
}
|
|
822
|
-
function
|
|
823
|
-
if (e !== void 0 && e !==
|
|
1056
|
+
function Fe(e) {
|
|
1057
|
+
if (e !== void 0 && e !== $.Blur && e !== $.Change)
|
|
824
1058
|
throw new Error(
|
|
825
|
-
`formatOn must be either ${
|
|
1059
|
+
`formatOn must be either ${$.Blur} or ${$.Change}. Received: ${JSON.stringify(e)}`
|
|
826
1060
|
);
|
|
827
1061
|
}
|
|
828
|
-
function
|
|
1062
|
+
function et(e) {
|
|
829
1063
|
if (e !== void 0) {
|
|
830
1064
|
if (typeof e != "string")
|
|
831
1065
|
throw new Error(
|
|
@@ -841,13 +1075,13 @@ function Ue(e) {
|
|
|
841
1075
|
);
|
|
842
1076
|
}
|
|
843
1077
|
}
|
|
844
|
-
function
|
|
1078
|
+
function tt(e) {
|
|
845
1079
|
if (e !== void 0 && !Object.values(S).includes(e))
|
|
846
1080
|
throw new Error(
|
|
847
1081
|
`ThousandStyle must be one of: ${Object.values(S).map((t) => `'${t}'`).join(", ")}. Received: ${JSON.stringify(e)}`
|
|
848
1082
|
);
|
|
849
1083
|
}
|
|
850
|
-
function
|
|
1084
|
+
function nt(e) {
|
|
851
1085
|
if (e !== void 0) {
|
|
852
1086
|
if (typeof e != "string")
|
|
853
1087
|
throw new Error(
|
|
@@ -863,119 +1097,119 @@ function ze(e) {
|
|
|
863
1097
|
);
|
|
864
1098
|
}
|
|
865
1099
|
}
|
|
866
|
-
function
|
|
1100
|
+
function st(e, t) {
|
|
867
1101
|
if (!(e === void 0 || t === void 0) && e === t)
|
|
868
1102
|
throw new Error(
|
|
869
1103
|
`Decimal separator can't be same as thousand separator. thousandSeparator: ${e}, decimalSeparator: ${t}`
|
|
870
1104
|
);
|
|
871
1105
|
}
|
|
872
|
-
function
|
|
1106
|
+
function M(e, t) {
|
|
873
1107
|
if (t !== void 0 && typeof t != "boolean")
|
|
874
1108
|
throw new Error(
|
|
875
1109
|
`${e} must be a boolean. Received: ${typeof t} (${JSON.stringify(t)})`
|
|
876
1110
|
);
|
|
877
1111
|
}
|
|
878
|
-
function
|
|
1112
|
+
function rt(e) {
|
|
879
1113
|
if (e !== void 0 && typeof e != "function")
|
|
880
1114
|
throw new Error(
|
|
881
1115
|
`onChange must be a function or undefined. Received: ${typeof e} (${JSON.stringify(e)})`
|
|
882
1116
|
);
|
|
883
1117
|
}
|
|
884
|
-
class
|
|
1118
|
+
class ut {
|
|
885
1119
|
constructor(t, {
|
|
886
|
-
decimalMaxLength: n =
|
|
887
|
-
decimalMinLength:
|
|
888
|
-
formatOn:
|
|
889
|
-
thousandSeparator:
|
|
890
|
-
thousandStyle:
|
|
891
|
-
decimalSeparator:
|
|
1120
|
+
decimalMaxLength: n = _,
|
|
1121
|
+
decimalMinLength: s = z,
|
|
1122
|
+
formatOn: o = Z,
|
|
1123
|
+
thousandSeparator: r = B,
|
|
1124
|
+
thousandStyle: i = W,
|
|
1125
|
+
decimalSeparator: a = N,
|
|
892
1126
|
enableCompactNotation: c = !0,
|
|
893
|
-
enableNegative: l =
|
|
894
|
-
enableLeadingZeros: h =
|
|
895
|
-
rawValueMode:
|
|
896
|
-
onChange:
|
|
897
|
-
...
|
|
1127
|
+
enableNegative: l = k,
|
|
1128
|
+
enableLeadingZeros: h = U,
|
|
1129
|
+
rawValueMode: u = G,
|
|
1130
|
+
onChange: f,
|
|
1131
|
+
...d
|
|
898
1132
|
}) {
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
if (
|
|
1133
|
+
v(this, "element");
|
|
1134
|
+
v(this, "options");
|
|
1135
|
+
v(this, "resolvedOptions");
|
|
1136
|
+
v(this, "rawValue", "");
|
|
1137
|
+
v(this, "caretPositionBeforeChange");
|
|
1138
|
+
if (He({
|
|
905
1139
|
decimalMaxLength: n,
|
|
906
|
-
decimalMinLength:
|
|
907
|
-
formatOn:
|
|
908
|
-
thousandSeparator:
|
|
909
|
-
thousandStyle:
|
|
910
|
-
decimalSeparator:
|
|
1140
|
+
decimalMinLength: s,
|
|
1141
|
+
formatOn: o,
|
|
1142
|
+
thousandSeparator: r,
|
|
1143
|
+
thousandStyle: i,
|
|
1144
|
+
decimalSeparator: a,
|
|
911
1145
|
enableCompactNotation: c,
|
|
912
1146
|
enableNegative: l,
|
|
913
1147
|
enableLeadingZeros: h,
|
|
914
|
-
rawValueMode:
|
|
915
|
-
onChange:
|
|
1148
|
+
rawValueMode: u,
|
|
1149
|
+
onChange: f
|
|
916
1150
|
}), this.options = {
|
|
917
1151
|
decimalMaxLength: n,
|
|
918
|
-
decimalMinLength:
|
|
919
|
-
onChange:
|
|
920
|
-
formatOn:
|
|
921
|
-
thousandSeparator:
|
|
922
|
-
thousandStyle:
|
|
923
|
-
decimalSeparator:
|
|
1152
|
+
decimalMinLength: s,
|
|
1153
|
+
onChange: f,
|
|
1154
|
+
formatOn: o,
|
|
1155
|
+
thousandSeparator: r,
|
|
1156
|
+
thousandStyle: i,
|
|
1157
|
+
decimalSeparator: a,
|
|
924
1158
|
enableCompactNotation: c,
|
|
925
1159
|
enableNegative: l,
|
|
926
1160
|
enableLeadingZeros: h,
|
|
927
|
-
rawValueMode:
|
|
928
|
-
...
|
|
1161
|
+
rawValueMode: u,
|
|
1162
|
+
...d
|
|
929
1163
|
}, this.resolvedOptions = this.getResolvedOptions(), this.createInputElement(t), this.setupEventListeners(), this.resolvedOptions.rawValueMode && this.element.value) {
|
|
930
|
-
const
|
|
1164
|
+
const g = this.element.value, p = this.resolvedOptions.thousandSeparator ? w(g, this.resolvedOptions.thousandSeparator) : g;
|
|
931
1165
|
this.rawValue = p, this.element.value = this.formatValueForDisplay(p);
|
|
932
1166
|
} else if (this.element.value) {
|
|
933
|
-
const
|
|
934
|
-
this.element.value = this.formatValueForDisplay(
|
|
1167
|
+
const g = this.element.value;
|
|
1168
|
+
this.element.value = this.formatValueForDisplay(g);
|
|
935
1169
|
}
|
|
936
1170
|
}
|
|
937
1171
|
createInputElement(t) {
|
|
938
1172
|
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) {
|
|
939
|
-
const
|
|
940
|
-
this.element.setAttribute("pattern",
|
|
1173
|
+
const se = Qe(this.resolvedOptions.decimalSeparator, this.resolvedOptions.enableNegative);
|
|
1174
|
+
this.element.setAttribute("pattern", se);
|
|
941
1175
|
}
|
|
942
1176
|
const {
|
|
943
1177
|
decimalMaxLength: n,
|
|
944
|
-
decimalMinLength:
|
|
945
|
-
formatOn:
|
|
946
|
-
thousandSeparator:
|
|
947
|
-
thousandStyle:
|
|
948
|
-
decimalSeparator:
|
|
1178
|
+
decimalMinLength: s,
|
|
1179
|
+
formatOn: o,
|
|
1180
|
+
thousandSeparator: r,
|
|
1181
|
+
thousandStyle: i,
|
|
1182
|
+
decimalSeparator: a,
|
|
949
1183
|
enableCompactNotation: c,
|
|
950
1184
|
enableNegative: l,
|
|
951
1185
|
enableLeadingZeros: h,
|
|
952
|
-
rawValueMode:
|
|
953
|
-
onChange:
|
|
954
|
-
value:
|
|
955
|
-
defaultValue:
|
|
1186
|
+
rawValueMode: u,
|
|
1187
|
+
onChange: f,
|
|
1188
|
+
value: d,
|
|
1189
|
+
defaultValue: g,
|
|
956
1190
|
type: p,
|
|
957
|
-
inputMode:
|
|
958
|
-
spellcheck:
|
|
959
|
-
autocomplete:
|
|
960
|
-
...
|
|
1191
|
+
inputMode: m,
|
|
1192
|
+
spellcheck: D,
|
|
1193
|
+
autocomplete: R,
|
|
1194
|
+
...ne
|
|
961
1195
|
} = this.options;
|
|
962
|
-
Object.assign(this.element,
|
|
1196
|
+
Object.assign(this.element, ne), d !== void 0 ? this.element.value = d : g !== void 0 && (this.element.defaultValue = g, this.element.value = g), t.appendChild(this.element);
|
|
963
1197
|
}
|
|
964
1198
|
setupEventListeners() {
|
|
965
|
-
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 ===
|
|
1199
|
+
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 === $.Blur && this.resolvedOptions.thousandSeparator && (this.element.addEventListener("focus", this.handleFocus.bind(this)), this.element.addEventListener("blur", this.handleBlur.bind(this)));
|
|
966
1200
|
}
|
|
967
1201
|
getResolvedOptions() {
|
|
968
1202
|
return {
|
|
969
|
-
decimalMaxLength: this.options.decimalMaxLength ??
|
|
970
|
-
decimalMinLength: this.options.decimalMinLength ??
|
|
971
|
-
formatOn: this.options.formatOn ??
|
|
972
|
-
thousandSeparator: this.options.thousandSeparator ??
|
|
973
|
-
thousandStyle: this.options.thousandStyle ??
|
|
974
|
-
decimalSeparator: this.options.decimalSeparator ??
|
|
975
|
-
enableCompactNotation: this.options.enableCompactNotation ??
|
|
976
|
-
enableNegative: this.options.enableNegative ??
|
|
977
|
-
enableLeadingZeros: this.options.enableLeadingZeros ??
|
|
978
|
-
rawValueMode: this.options.rawValueMode ??
|
|
1203
|
+
decimalMaxLength: this.options.decimalMaxLength ?? _,
|
|
1204
|
+
decimalMinLength: this.options.decimalMinLength ?? z,
|
|
1205
|
+
formatOn: this.options.formatOn ?? Z,
|
|
1206
|
+
thousandSeparator: this.options.thousandSeparator ?? B,
|
|
1207
|
+
thousandStyle: this.options.thousandStyle ?? W,
|
|
1208
|
+
decimalSeparator: this.options.decimalSeparator ?? N,
|
|
1209
|
+
enableCompactNotation: this.options.enableCompactNotation ?? oe,
|
|
1210
|
+
enableNegative: this.options.enableNegative ?? k,
|
|
1211
|
+
enableLeadingZeros: this.options.enableLeadingZeros ?? U,
|
|
1212
|
+
rawValueMode: this.options.rawValueMode ?? G,
|
|
979
1213
|
onChange: this.options.onChange
|
|
980
1214
|
};
|
|
981
1215
|
}
|
|
@@ -994,66 +1228,66 @@ class Xe {
|
|
|
994
1228
|
}
|
|
995
1229
|
handleValueChange(t, n) {
|
|
996
1230
|
if (this.resolvedOptions.rawValueMode && n !== void 0 && (this.rawValue = n), this.resolvedOptions.onChange) {
|
|
997
|
-
const
|
|
998
|
-
this.resolvedOptions.onChange(
|
|
1231
|
+
const s = this.resolvedOptions.rawValueMode ? this.rawValue : t;
|
|
1232
|
+
this.resolvedOptions.onChange(s);
|
|
999
1233
|
}
|
|
1000
1234
|
}
|
|
1001
1235
|
formatValueForDisplay(t) {
|
|
1002
1236
|
if (!t)
|
|
1003
1237
|
return t;
|
|
1004
|
-
const { thousandSeparator: n, thousandStyle:
|
|
1005
|
-
return n &&
|
|
1238
|
+
const { thousandSeparator: n, thousandStyle: s, enableLeadingZeros: o, decimalSeparator: r } = this.resolvedOptions;
|
|
1239
|
+
return n && s !== S.None ? y(
|
|
1006
1240
|
t,
|
|
1007
1241
|
n,
|
|
1008
|
-
r,
|
|
1009
1242
|
s,
|
|
1010
|
-
|
|
1243
|
+
o,
|
|
1244
|
+
r
|
|
1011
1245
|
) : t;
|
|
1012
1246
|
}
|
|
1013
1247
|
handleChange(t) {
|
|
1014
|
-
const { formatted: n, raw:
|
|
1248
|
+
const { formatted: n, raw: s } = Je(
|
|
1015
1249
|
t,
|
|
1016
1250
|
this.resolvedOptions.decimalMaxLength,
|
|
1017
1251
|
this.caretPositionBeforeChange,
|
|
1018
1252
|
this.buildFormattingOptions()
|
|
1019
1253
|
);
|
|
1020
|
-
this.caretPositionBeforeChange = void 0, this.handleValueChange(n,
|
|
1254
|
+
this.caretPositionBeforeChange = void 0, this.handleValueChange(n, s);
|
|
1021
1255
|
}
|
|
1022
1256
|
handleKeyDown(t) {
|
|
1023
|
-
const n = t.target, { selectionStart:
|
|
1024
|
-
formatOn:
|
|
1025
|
-
thousandSeparator:
|
|
1026
|
-
ThousandStyle:
|
|
1027
|
-
decimalSeparator:
|
|
1257
|
+
const n = t.target, { selectionStart: s, selectionEnd: o } = n, r = this.buildFormattingOptions(), i = je(t, {
|
|
1258
|
+
formatOn: r.formatOn,
|
|
1259
|
+
thousandSeparator: r.thousandSeparator,
|
|
1260
|
+
ThousandStyle: r.ThousandStyle,
|
|
1261
|
+
decimalSeparator: r.decimalSeparator
|
|
1028
1262
|
});
|
|
1029
|
-
|
|
1030
|
-
selectionStart:
|
|
1031
|
-
selectionEnd:
|
|
1032
|
-
endOffset:
|
|
1263
|
+
i ? this.caretPositionBeforeChange = {
|
|
1264
|
+
selectionStart: s ?? 0,
|
|
1265
|
+
selectionEnd: o ?? 0,
|
|
1266
|
+
endOffset: i.endOffset
|
|
1033
1267
|
} : this.caretPositionBeforeChange = {
|
|
1034
|
-
selectionStart:
|
|
1035
|
-
selectionEnd:
|
|
1268
|
+
selectionStart: s ?? 0,
|
|
1269
|
+
selectionEnd: o ?? 0
|
|
1036
1270
|
};
|
|
1037
1271
|
}
|
|
1038
1272
|
handlePaste(t) {
|
|
1039
|
-
const { formatted: n, raw:
|
|
1040
|
-
this.handleValueChange(n,
|
|
1041
|
-
const
|
|
1042
|
-
this.element.dispatchEvent(
|
|
1273
|
+
const { formatted: n, raw: s } = qe(t, this.resolvedOptions.decimalMaxLength, this.buildFormattingOptions());
|
|
1274
|
+
this.handleValueChange(n, s);
|
|
1275
|
+
const o = new Event("input", { bubbles: !0, cancelable: !0 });
|
|
1276
|
+
this.element.dispatchEvent(o);
|
|
1043
1277
|
}
|
|
1044
1278
|
handleFocus(t) {
|
|
1045
|
-
if (this.resolvedOptions.formatOn ===
|
|
1279
|
+
if (this.resolvedOptions.formatOn === $.Blur && this.resolvedOptions.thousandSeparator) {
|
|
1046
1280
|
const n = t.target;
|
|
1047
|
-
n.value =
|
|
1281
|
+
n.value = w(n.value, this.resolvedOptions.thousandSeparator);
|
|
1048
1282
|
}
|
|
1049
1283
|
}
|
|
1050
1284
|
handleBlur(t) {
|
|
1051
|
-
const n = t.target, { thousandSeparator:
|
|
1052
|
-
if (
|
|
1053
|
-
const
|
|
1054
|
-
n.value =
|
|
1055
|
-
const
|
|
1056
|
-
if (this.handleValueChange(
|
|
1285
|
+
const n = t.target, { thousandSeparator: s, thousandStyle: o } = this.resolvedOptions;
|
|
1286
|
+
if (s && o !== S.None && n.value) {
|
|
1287
|
+
const r = n.value, i = this.formatValueForDisplay(n.value);
|
|
1288
|
+
n.value = i;
|
|
1289
|
+
const a = this.resolvedOptions.rawValueMode ? w(i, s) : void 0;
|
|
1290
|
+
if (this.handleValueChange(i, a), r !== i) {
|
|
1057
1291
|
const c = new Event("input", { bubbles: !0, cancelable: !0 });
|
|
1058
1292
|
this.element.dispatchEvent(c);
|
|
1059
1293
|
const l = new Event("change", { bubbles: !0, cancelable: !0 });
|
|
@@ -1066,7 +1300,7 @@ class Xe {
|
|
|
1066
1300
|
}
|
|
1067
1301
|
setValue(t) {
|
|
1068
1302
|
if (this.resolvedOptions.rawValueMode) {
|
|
1069
|
-
const n = this.resolvedOptions.thousandSeparator ?
|
|
1303
|
+
const n = this.resolvedOptions.thousandSeparator ? w(t, this.resolvedOptions.thousandSeparator) : t;
|
|
1070
1304
|
this.rawValue = n, this.element.value = this.formatValueForDisplay(n);
|
|
1071
1305
|
} else
|
|
1072
1306
|
this.element.value = t;
|
|
@@ -1114,8 +1348,8 @@ class Xe {
|
|
|
1114
1348
|
const t = this.getValue();
|
|
1115
1349
|
if (!t)
|
|
1116
1350
|
return NaN;
|
|
1117
|
-
const n = this.resolvedOptions.thousandSeparator ?
|
|
1118
|
-
return parseFloat(
|
|
1351
|
+
const n = this.resolvedOptions.thousandSeparator ? w(t, this.resolvedOptions.thousandSeparator) : t, s = this.resolvedOptions.decimalSeparator && this.resolvedOptions.decimalSeparator !== "." ? n.replace(new RegExp(x(this.resolvedOptions.decimalSeparator), "g"), ".") : n;
|
|
1352
|
+
return parseFloat(s);
|
|
1119
1353
|
}
|
|
1120
1354
|
/**
|
|
1121
1355
|
* Sets the value from a number, similar to HTMLInputElement.valueAsNumber.
|
|
@@ -1130,12 +1364,16 @@ class Xe {
|
|
|
1130
1364
|
}
|
|
1131
1365
|
}
|
|
1132
1366
|
export {
|
|
1133
|
-
|
|
1134
|
-
|
|
1367
|
+
$ as FormatOn,
|
|
1368
|
+
ut as NumoraInput,
|
|
1135
1369
|
S as ThousandStyle,
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1370
|
+
ct as condenseDecimalZeros,
|
|
1371
|
+
O as formatInputValue,
|
|
1372
|
+
lt as formatLargeNumber,
|
|
1373
|
+
at as formatLargePercent,
|
|
1374
|
+
ot as formatPercent,
|
|
1375
|
+
ht as formatValueForDisplay,
|
|
1376
|
+
Je as handleOnChangeNumoraInput,
|
|
1377
|
+
je as handleOnKeyDownNumoraInput,
|
|
1378
|
+
qe as handleOnPasteNumoraInput
|
|
1141
1379
|
};
|