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