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