numora 3.3.0 → 3.5.0

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