hoodini-viz 0.1.4 → 0.2.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.
@@ -1,10 +1,12 @@
1
- import { s as Te, R as X, r as T } from "./index-DoUR8EOn.js";
2
- const Be = /* @__PURE__ */ Te("div")({
1
+ import * as ie from "react";
2
+ import Q, { useRef as X, useState as xe, useEffect as ve, useMemo as Fe, useLayoutEffect as je } from "react";
3
+ import { s as Le } from "./index-MmB2RSTX.js";
4
+ const Me = /* @__PURE__ */ Le("div")({
3
5
  name: "NumberOverlayEditorStyle",
4
6
  class: "gdg-n15fjm3e",
5
7
  propsAsIs: !1
6
8
  });
7
- function Se(e, t) {
9
+ function ye(e, t) {
8
10
  var r = {};
9
11
  for (var n in e)
10
12
  Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
@@ -17,9 +19,9 @@ var re;
17
19
  (function(e) {
18
20
  e.event = "event", e.props = "prop";
19
21
  })(re || (re = {}));
20
- function q() {
22
+ function Z() {
21
23
  }
22
- function Fe(e) {
24
+ function ke(e) {
23
25
  var t, r = void 0;
24
26
  return function() {
25
27
  for (var n = [], a = arguments.length; a--; ) n[a] = arguments[a];
@@ -34,16 +36,16 @@ function ae(e) {
34
36
  function Y(e) {
35
37
  return e == null;
36
38
  }
37
- function _e(e) {
39
+ function Pe(e) {
38
40
  return typeof e == "number" && isNaN(e);
39
41
  }
40
- function pe(e) {
41
- return Y(e) || _e(e) || typeof e == "number" && !isFinite(e);
42
+ function be(e) {
43
+ return Y(e) || Pe(e) || typeof e == "number" && !isFinite(e);
42
44
  }
43
- function xe(e) {
45
+ function Ve(e) {
44
46
  return e.replace(/[-[\]/{}()*+?.\\^$|]/g, "\\$&");
45
47
  }
46
- function je(e) {
48
+ function Ke(e) {
47
49
  switch (e) {
48
50
  case "lakh":
49
51
  return /(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/g;
@@ -53,20 +55,20 @@ function je(e) {
53
55
  return /(\d)(?=(\d{3})+(?!\d))/g;
54
56
  }
55
57
  }
56
- function Le(e, t, r) {
57
- var n = je(r), a = e.search(/[1-9]/);
58
+ function We(e, t, r) {
59
+ var n = Ke(r), a = e.search(/[1-9]/);
58
60
  return a = a === -1 ? e.length : a, e.substring(0, a) + e.substring(a, e.length).replace(n, "$1" + t);
59
61
  }
60
- function Me(e) {
61
- var t = T.useRef(e);
62
+ function Ue(e) {
63
+ var t = X(e);
62
64
  t.current = e;
63
- var r = T.useRef(function() {
65
+ var r = X(function() {
64
66
  for (var n = [], a = arguments.length; a--; ) n[a] = arguments[a];
65
67
  return t.current.apply(t, n);
66
68
  });
67
69
  return r.current;
68
70
  }
69
- function se(e, t) {
71
+ function de(e, t) {
70
72
  t === void 0 && (t = !0);
71
73
  var r = e[0] === "-", n = r && t;
72
74
  e = e.replace("-", "");
@@ -78,7 +80,7 @@ function se(e, t) {
78
80
  addNegation: n
79
81
  };
80
82
  }
81
- function ke(e) {
83
+ function $e(e) {
82
84
  if (!e)
83
85
  return e;
84
86
  var t = e[0] === "-";
@@ -86,15 +88,15 @@ function ke(e) {
86
88
  var r = e.split("."), n = r[0].replace(/^0+/, "") || "0", a = r[1] || "";
87
89
  return (t ? "-" : "") + n + (a ? "." + a : "");
88
90
  }
89
- function ye(e, t, r) {
91
+ function Ne(e, t, r) {
90
92
  for (var n = "", a = r ? "0" : "", i = 0; i <= t - 1; i++)
91
93
  n += e[i] || a;
92
94
  return n;
93
95
  }
94
- function de(e, t) {
96
+ function me(e, t) {
95
97
  return Array(t + 1).join(e);
96
98
  }
97
- function be(e) {
99
+ function we(e) {
98
100
  var t = e + "", r = t[0] === "-" ? "-" : "";
99
101
  r && (t = t.substring(1));
100
102
  var n = t.split(/[eE]/g), a = n[0], i = n[1];
@@ -102,19 +104,19 @@ function be(e) {
102
104
  return r + a;
103
105
  a = a.replace(".", "");
104
106
  var l = 1 + i, m = a.length;
105
- return l < 0 ? a = "0." + de("0", Math.abs(l)) + a : l >= m ? a = a + de("0", l - m) : a = (a.substring(0, l) || "0") + "." + a.substring(l), r + a;
107
+ return l < 0 ? a = "0." + me("0", Math.abs(l)) + a : l >= m ? a = a + me("0", l - m) : a = (a.substring(0, l) || "0") + "." + a.substring(l), r + a;
106
108
  }
107
- function ge(e, t, r) {
109
+ function he(e, t, r) {
108
110
  if (["", "-"].indexOf(e) !== -1)
109
111
  return e;
110
- var n = (e.indexOf(".") !== -1 || r) && t, a = se(e), i = a.beforeDecimal, l = a.afterDecimal, m = a.hasNegation, S = parseFloat("0." + (l || "0")), p = l.length <= t ? "0." + l : S.toFixed(t), h = p.split("."), c = i;
112
+ var n = (e.indexOf(".") !== -1 || r) && t, a = de(e), i = a.beforeDecimal, l = a.afterDecimal, m = a.hasNegation, S = parseFloat("0." + (l || "0")), p = l.length <= t ? "0." + l : S.toFixed(t), h = p.split("."), c = i;
111
113
  i && Number(h[0]) && (c = i.split("").reverse().reduce(function(I, C, g) {
112
114
  return I.length > g ? (Number(I[0]) + Number(C)).toString() + I.substring(1, I.length) : C + I;
113
115
  }, h[0]));
114
- var x = ye(h[1] || "", t, r), y = m ? "-" : "", s = n ? "." : "";
115
- return "" + y + c + s + x;
116
+ var x = Ne(h[1] || "", t, r), y = m ? "-" : "", v = n ? "." : "";
117
+ return "" + y + c + v + x;
116
118
  }
117
- function H(e, t) {
119
+ function z(e, t) {
118
120
  if (e.value = e.value, e !== null) {
119
121
  if (e.createTextRange) {
120
122
  var r = e.createTextRange();
@@ -123,7 +125,7 @@ function H(e, t) {
123
125
  return e.selectionStart || e.selectionStart === 0 ? (e.focus(), e.setSelectionRange(t, t), !0) : (e.focus(), !1);
124
126
  }
125
127
  }
126
- var Ve = Fe(function(e, t) {
128
+ var De = ke(function(e, t) {
127
129
  for (var r = 0, n = 0, a = e.length, i = t.length; e[r] === t[r] && r < a; )
128
130
  r++;
129
131
  for (; e[a - 1 - n] === t[i - 1 - n] && i - n > r && a - n > r; )
@@ -132,23 +134,23 @@ var Ve = Fe(function(e, t) {
132
134
  from: { start: r, end: a - n },
133
135
  to: { start: r, end: i - n }
134
136
  };
135
- }), Pe = function(e, t) {
137
+ }), Ge = function(e, t) {
136
138
  var r = Math.min(e.selectionStart, t);
137
139
  return {
138
140
  from: { start: r, end: e.selectionEnd },
139
141
  to: { start: r, end: t }
140
142
  };
141
143
  };
142
- function Ke(e, t, r) {
144
+ function Ze(e, t, r) {
143
145
  return Math.min(Math.max(e, t), r);
144
146
  }
145
- function ce(e) {
147
+ function se(e) {
146
148
  return Math.max(e.selectionStart, e.selectionEnd);
147
149
  }
148
- function We() {
150
+ function qe() {
149
151
  return typeof navigator < "u" && !(navigator.platform && /iPhone|iPod/.test(navigator.platform));
150
152
  }
151
- function Ue(e) {
153
+ function ze(e) {
152
154
  return {
153
155
  from: {
154
156
  start: 0,
@@ -161,43 +163,43 @@ function Ue(e) {
161
163
  lastValue: ""
162
164
  };
163
165
  }
164
- function $e(e) {
166
+ function He(e) {
165
167
  var t = e.currentValue, r = e.formattedValue, n = e.currentValueIndex, a = e.formattedValueIndex;
166
168
  return t[n] === r[a];
167
169
  }
168
- function Ge(e, t, r, n, a, i, l) {
169
- l === void 0 && (l = $e);
170
- var m = a.findIndex(function(k) {
171
- return k;
170
+ function Je(e, t, r, n, a, i, l) {
171
+ l === void 0 && (l = He);
172
+ var m = a.findIndex(function(M) {
173
+ return M;
172
174
  }), S = e.slice(0, m);
173
175
  !t && !r.startsWith(S) && (t = S, r = S + r, n = n + S.length);
174
176
  for (var p = r.length, h = e.length, c = {}, x = new Array(p), y = 0; y < p; y++) {
175
177
  x[y] = -1;
176
- for (var s = 0, I = h; s < I; s++) {
178
+ for (var v = 0, I = h; v < I; v++) {
177
179
  var C = l({
178
180
  currentValue: r,
179
181
  lastValue: t,
180
182
  formattedValue: e,
181
183
  currentValueIndex: y,
182
- formattedValueIndex: s
184
+ formattedValueIndex: v
183
185
  });
184
- if (C && c[s] !== !0) {
185
- x[y] = s, c[s] = !0;
186
+ if (C && c[v] !== !0) {
187
+ x[y] = v, c[v] = !0;
186
188
  break;
187
189
  }
188
190
  }
189
191
  }
190
192
  for (var g = n; g < p && (x[g] === -1 || !i(r[g])); )
191
193
  g++;
192
- var B = g === p || x[g] === -1 ? h : x[g];
194
+ var T = g === p || x[g] === -1 ? h : x[g];
193
195
  for (g = n - 1; g > 0 && x[g] === -1; )
194
196
  g--;
195
- var F = g === -1 || x[g] === -1 ? 0 : x[g] + 1;
196
- return F > B ? B : n - F < B - n ? F : B;
197
+ var B = g === -1 || x[g] === -1 ? 0 : x[g] + 1;
198
+ return B > T ? T : n - B < T - n ? B : T;
197
199
  }
198
- function me(e, t, r, n) {
200
+ function Se(e, t, r, n) {
199
201
  var a = e.length;
200
- if (t = Ke(t, 0, a), n === "left") {
202
+ if (t = Ze(t, 0, a), n === "left") {
201
203
  for (; t >= 0 && !r[t]; )
202
204
  t--;
203
205
  t === -1 && (t = r.indexOf(!0));
@@ -208,192 +210,192 @@ function me(e, t, r, n) {
208
210
  }
209
211
  return t === -1 && (t = a), t;
210
212
  }
211
- function Ze(e) {
213
+ function Qe(e) {
212
214
  for (var t = Array.from({ length: e.length + 1 }).map(function() {
213
215
  return !0;
214
216
  }), r = 0, n = t.length; r < n; r++)
215
217
  t[r] = !!(ae(e[r]) || ae(e[r - 1]));
216
218
  return t;
217
219
  }
218
- function Ne(e, t, r, n, a, i) {
219
- i === void 0 && (i = q);
220
- var l = Me(function(s, I) {
220
+ function Ie(e, t, r, n, a, i) {
221
+ i === void 0 && (i = Z);
222
+ var l = Ue(function(v, I) {
221
223
  var C, g;
222
- return pe(s) ? (g = "", C = "") : typeof s == "number" || I ? (g = typeof s == "number" ? be(s) : s, C = n(g)) : (g = a(s, void 0), C = n(g)), { formattedValue: C, numAsString: g };
223
- }), m = T.useState(function() {
224
+ return be(v) ? (g = "", C = "") : typeof v == "number" || I ? (g = typeof v == "number" ? we(v) : v, C = n(g)) : (g = a(v, void 0), C = n(g)), { formattedValue: C, numAsString: g };
225
+ }), m = xe(function() {
224
226
  return l(Y(e) ? t : e, r);
225
- }), S = m[0], p = m[1], h = function(s, I) {
226
- s.formattedValue !== S.formattedValue && p({
227
- formattedValue: s.formattedValue,
228
- numAsString: s.value
229
- }), i(s, I);
227
+ }), S = m[0], p = m[1], h = function(v, I) {
228
+ v.formattedValue !== S.formattedValue && p({
229
+ formattedValue: v.formattedValue,
230
+ numAsString: v.value
231
+ }), i(v, I);
230
232
  }, c = e, x = r;
231
233
  Y(e) && (c = S.numAsString, x = !0);
232
234
  var y = l(c, x);
233
- return T.useMemo(function() {
235
+ return Fe(function() {
234
236
  p(y);
235
237
  }, [y.formattedValue]), [S, h];
236
238
  }
237
- function qe(e) {
239
+ function Xe(e) {
238
240
  return e.replace(/[^0-9]/g, "");
239
241
  }
240
- function ze(e) {
242
+ function Ye(e) {
241
243
  return e;
242
244
  }
243
- function He(e) {
245
+ function et(e) {
244
246
  var t = e.type;
245
247
  t === void 0 && (t = "text");
246
248
  var r = e.displayType;
247
249
  r === void 0 && (r = "input");
248
250
  var n = e.customInput, a = e.renderText, i = e.getInputRef, l = e.format;
249
- l === void 0 && (l = ze);
251
+ l === void 0 && (l = Ye);
250
252
  var m = e.removeFormatting;
251
- m === void 0 && (m = qe);
253
+ m === void 0 && (m = Xe);
252
254
  var S = e.defaultValue, p = e.valueIsNumericString, h = e.onValueChange, c = e.isAllowed, x = e.onChange;
253
- x === void 0 && (x = q);
255
+ x === void 0 && (x = Z);
254
256
  var y = e.onKeyDown;
255
- y === void 0 && (y = q);
256
- var s = e.onMouseUp;
257
- s === void 0 && (s = q);
257
+ y === void 0 && (y = Z);
258
+ var v = e.onMouseUp;
259
+ v === void 0 && (v = Z);
258
260
  var I = e.onFocus;
259
- I === void 0 && (I = q);
261
+ I === void 0 && (I = Z);
260
262
  var C = e.onBlur;
261
- C === void 0 && (C = q);
262
- var g = e.value, B = e.getCaretBoundary;
263
- B === void 0 && (B = Ze);
264
- var F = e.isValidInputCharacter;
265
- F === void 0 && (F = ae);
266
- var k = e.isCharacterSame, j = Se(e, ["type", "displayType", "customInput", "renderText", "getInputRef", "format", "removeFormatting", "defaultValue", "valueIsNumericString", "onValueChange", "isAllowed", "onChange", "onKeyDown", "onMouseUp", "onFocus", "onBlur", "value", "getCaretBoundary", "isValidInputCharacter", "isCharacterSame"]), z = Ne(g, S, !!p, l, m, h), P = z[0], V = P.formattedValue, L = P.numAsString, W = z[1], M = T.useRef(), U = T.useRef({ formattedValue: V, numAsString: L }), $ = function(o, u) {
267
- U.current = { formattedValue: o.formattedValue, numAsString: o.value }, W(o, u);
268
- }, J = T.useState(!1), ee = J[0], d = J[1], f = T.useRef(null), N = T.useRef({
263
+ C === void 0 && (C = Z);
264
+ var g = e.value, T = e.getCaretBoundary;
265
+ T === void 0 && (T = Qe);
266
+ var B = e.isValidInputCharacter;
267
+ B === void 0 && (B = ae);
268
+ var M = e.isCharacterSame, F = ye(e, ["type", "displayType", "customInput", "renderText", "getInputRef", "format", "removeFormatting", "defaultValue", "valueIsNumericString", "onValueChange", "isAllowed", "onChange", "onKeyDown", "onMouseUp", "onFocus", "onBlur", "value", "getCaretBoundary", "isValidInputCharacter", "isCharacterSame"]), q = Ie(g, S, !!p, l, m, h), k = q[0], V = k.formattedValue, j = k.numAsString, K = q[1], L = X(), W = X({ formattedValue: V, numAsString: j }), U = function(o, u) {
269
+ W.current = { formattedValue: o.formattedValue, numAsString: o.value }, K(o, u);
270
+ }, H = xe(!1), ee = H[0], d = H[1], f = X(null), N = X({
269
271
  setCaretTimeout: null,
270
272
  focusTimeout: null
271
273
  });
272
- T.useEffect(function() {
274
+ ve(function() {
273
275
  return d(!0), function() {
274
276
  clearTimeout(N.current.setCaretTimeout), clearTimeout(N.current.focusTimeout);
275
277
  };
276
278
  }, []);
277
- var R = l, A = function(o, u) {
278
- var v = parseFloat(u);
279
+ var A = l, O = function(o, u) {
280
+ var s = parseFloat(u);
279
281
  return {
280
282
  formattedValue: o,
281
283
  value: u,
282
- floatValue: isNaN(v) ? void 0 : v
284
+ floatValue: isNaN(s) ? void 0 : s
283
285
  };
284
- }, E = function(o, u, v) {
285
- o.selectionStart === 0 && o.selectionEnd === o.value.length || (H(o, u), N.current.setCaretTimeout = setTimeout(function() {
286
- o.value === v && o.selectionStart !== u && H(o, u);
286
+ }, E = function(o, u, s) {
287
+ o.selectionStart === 0 && o.selectionEnd === o.value.length || (z(o, u), N.current.setCaretTimeout = setTimeout(function() {
288
+ o.value === s && o.selectionStart !== u && z(o, u);
287
289
  }, 0));
288
- }, O = function(o, u, v) {
289
- return me(o, u, B(o), v);
290
- }, Q = function(o, u, v) {
291
- var w = B(u), _ = Ge(u, V, o, v, w, F, k);
292
- return _ = me(u, _, w), _;
293
- }, oe = function(o) {
290
+ }, R = function(o, u, s) {
291
+ return Se(o, u, T(o), s);
292
+ }, J = function(o, u, s) {
293
+ var w = T(u), _ = Je(u, V, o, s, w, B, M);
294
+ return _ = Se(u, _, w), _;
295
+ }, ue = function(o) {
294
296
  var u = o.formattedValue;
295
297
  u === void 0 && (u = "");
296
- var v = o.input, w = o.source, _ = o.event, D = o.numAsString, b;
297
- if (v) {
298
- var K = o.inputValue || v.value, G = ce(v);
299
- v.value = u, b = Q(K, u, G), b !== void 0 && E(v, b, u);
298
+ var s = o.input, w = o.source, _ = o.event, D = o.numAsString, b;
299
+ if (s) {
300
+ var P = o.inputValue || s.value, $ = se(s);
301
+ s.value = u, b = J(P, u, $), b !== void 0 && E(s, b, u);
300
302
  }
301
- u !== V && $(A(u, D), { event: _, source: w });
303
+ u !== V && U(O(u, D), { event: _, source: w });
302
304
  };
303
- T.useEffect(function() {
304
- var o = U.current, u = o.formattedValue, v = o.numAsString;
305
- (V !== u || L !== v) && $(A(V, L), {
305
+ ve(function() {
306
+ var o = W.current, u = o.formattedValue, s = o.numAsString;
307
+ (V !== u || j !== s) && U(O(V, j), {
306
308
  event: void 0,
307
309
  source: re.props
308
310
  });
309
- }, [V, L]);
310
- var te = f.current ? ce(f.current) : void 0, ne = typeof window < "u" ? T.useLayoutEffect : T.useEffect;
311
+ }, [V, j]);
312
+ var te = f.current ? se(f.current) : void 0, ne = typeof window < "u" ? je : ve;
311
313
  ne(function() {
312
314
  var o = f.current;
313
- if (V !== U.current.formattedValue && o) {
314
- var u = Q(U.current.formattedValue, V, te);
315
+ if (V !== W.current.formattedValue && o) {
316
+ var u = J(W.current.formattedValue, V, te);
315
317
  o.value = V, E(o, u, V);
316
318
  }
317
319
  }, [V]);
318
- var ue = function(o, u, v) {
319
- var w = u.target, _ = M.current ? Pe(M.current, w.selectionEnd) : Ve(V, o), D = Object.assign(Object.assign({}, _), { lastValue: V }), b = m(o, D), K = R(b);
320
- if (b = m(K, void 0), c && !c(A(K, b))) {
321
- var G = u.target, Z = ce(G), fe = Q(o, V, Z);
322
- return G.value = V, E(G, fe, V), !1;
320
+ var le = function(o, u, s) {
321
+ var w = u.target, _ = L.current ? Ge(L.current, w.selectionEnd) : De(V, o), D = Object.assign(Object.assign({}, _), { lastValue: V }), b = m(o, D), P = A(b);
322
+ if (b = m(P, void 0), c && !c(O(P, b))) {
323
+ var $ = u.target, G = se($), ce = J(o, V, G);
324
+ return $.value = V, E($, ce, V), !1;
323
325
  }
324
- return oe({
325
- formattedValue: K,
326
+ return ue({
327
+ formattedValue: P,
326
328
  numAsString: b,
327
329
  inputValue: o,
328
330
  event: u,
329
- source: v,
331
+ source: s,
330
332
  input: u.target
331
333
  }), !0;
332
- }, le = function(o, u) {
334
+ }, fe = function(o, u) {
333
335
  u === void 0 && (u = 0);
334
- var v = o.selectionStart, w = o.selectionEnd;
335
- M.current = { selectionStart: v, selectionEnd: w + u };
336
- }, De = function(o) {
337
- var u = o.target, v = u.value, w = ue(v, o, re.event);
338
- w && x(o), M.current = void 0;
339
- }, Ie = function(o) {
340
- var u = o.target, v = o.key, w = u.selectionStart, _ = u.selectionEnd, D = u.value;
336
+ var s = o.selectionStart, w = o.selectionEnd;
337
+ L.current = { selectionStart: s, selectionEnd: w + u };
338
+ }, Ee = function(o) {
339
+ var u = o.target, s = u.value, w = le(s, o, re.event);
340
+ w && x(o), L.current = void 0;
341
+ }, Ae = function(o) {
342
+ var u = o.target, s = o.key, w = u.selectionStart, _ = u.selectionEnd, D = u.value;
341
343
  D === void 0 && (D = "");
342
344
  var b;
343
- v === "ArrowLeft" || v === "Backspace" ? b = Math.max(w - 1, 0) : v === "ArrowRight" ? b = Math.min(w + 1, D.length) : v === "Delete" && (b = w);
344
- var K = 0;
345
- v === "Delete" && w === _ && (K = 1);
346
- var G = v === "ArrowLeft" || v === "ArrowRight";
347
- if (b === void 0 || w !== _ && !G) {
348
- y(o), le(u, K);
345
+ s === "ArrowLeft" || s === "Backspace" ? b = Math.max(w - 1, 0) : s === "ArrowRight" ? b = Math.min(w + 1, D.length) : s === "Delete" && (b = w);
346
+ var P = 0;
347
+ s === "Delete" && w === _ && (P = 1);
348
+ var $ = s === "ArrowLeft" || s === "ArrowRight";
349
+ if (b === void 0 || w !== _ && !$) {
350
+ y(o), fe(u, P);
349
351
  return;
350
352
  }
351
- var Z = b;
352
- if (G) {
353
- var fe = v === "ArrowLeft" ? "left" : "right";
354
- Z = O(D, b, fe), Z !== b && o.preventDefault();
355
- } else v === "Delete" && !F(D[b]) ? Z = O(D, b, "right") : v === "Backspace" && !F(D[b]) && (Z = O(D, b, "left"));
356
- Z !== b && E(u, Z, D), y(o), le(u, K);
357
- }, Ce = function(o) {
358
- var u = o.target, v = function() {
353
+ var G = b;
354
+ if ($) {
355
+ var ce = s === "ArrowLeft" ? "left" : "right";
356
+ G = R(D, b, ce), G !== b && o.preventDefault();
357
+ } else s === "Delete" && !B(D[b]) ? G = R(D, b, "right") : s === "Backspace" && !B(D[b]) && (G = R(D, b, "left"));
358
+ G !== b && E(u, G, D), y(o), fe(u, P);
359
+ }, Oe = function(o) {
360
+ var u = o.target, s = function() {
359
361
  var w = u.selectionStart, _ = u.selectionEnd, D = u.value;
360
362
  if (D === void 0 && (D = ""), w === _) {
361
- var b = O(D, w);
363
+ var b = R(D, w);
362
364
  b !== w && E(u, b, D);
363
365
  }
364
366
  };
365
- v(), requestAnimationFrame(function() {
366
- v();
367
- }), s(o), le(u);
368
- }, Ee = function(o) {
367
+ s(), requestAnimationFrame(function() {
368
+ s();
369
+ }), v(o), fe(u);
370
+ }, Re = function(o) {
369
371
  o.persist && o.persist();
370
- var u = o.target, v = o.currentTarget;
372
+ var u = o.target, s = o.currentTarget;
371
373
  f.current = u, N.current.focusTimeout = setTimeout(function() {
372
374
  var w = u.selectionStart, _ = u.selectionEnd, D = u.value;
373
375
  D === void 0 && (D = "");
374
- var b = O(D, w);
375
- b !== w && !(w === 0 && _ === D.length) && E(u, b, D), I(Object.assign(Object.assign({}, o), { currentTarget: v }));
376
+ var b = R(D, w);
377
+ b !== w && !(w === 0 && _ === D.length) && E(u, b, D), I(Object.assign(Object.assign({}, o), { currentTarget: s }));
376
378
  }, 0);
377
- }, Re = function(o) {
379
+ }, Te = function(o) {
378
380
  f.current = null, clearTimeout(N.current.focusTimeout), clearTimeout(N.current.setCaretTimeout), C(o);
379
- }, Ae = ee && We() ? "numeric" : void 0, ve = Object.assign({ inputMode: Ae }, j, {
381
+ }, Be = ee && qe() ? "numeric" : void 0, ge = Object.assign({ inputMode: Be }, F, {
380
382
  type: t,
381
383
  value: V,
382
- onChange: De,
383
- onKeyDown: Ie,
384
- onMouseUp: Ce,
385
- onFocus: Ee,
386
- onBlur: Re
384
+ onChange: Ee,
385
+ onKeyDown: Ae,
386
+ onMouseUp: Oe,
387
+ onFocus: Re,
388
+ onBlur: Te
387
389
  });
388
390
  if (r === "text")
389
- return a ? X.createElement(X.Fragment, null, a(V, j) || null) : X.createElement("span", Object.assign({}, j, { ref: i }), V);
391
+ return a ? Q.createElement(Q.Fragment, null, a(V, F) || null) : Q.createElement("span", Object.assign({}, F, { ref: i }), V);
390
392
  if (n) {
391
- var Oe = n;
392
- return X.createElement(Oe, Object.assign({}, ve, { ref: i }));
393
+ var _e = n;
394
+ return Q.createElement(_e, Object.assign({}, ge, { ref: i }));
393
395
  }
394
- return X.createElement("input", Object.assign({}, ve, { ref: i }));
396
+ return Q.createElement("input", Object.assign({}, ge, { ref: i }));
395
397
  }
396
- function he(e, t) {
398
+ function pe(e, t) {
397
399
  var r = t.decimalScale, n = t.fixedDecimalScale, a = t.prefix;
398
400
  a === void 0 && (a = "");
399
401
  var i = t.suffix;
@@ -401,10 +403,10 @@ function he(e, t) {
401
403
  var l = t.allowNegative, m = t.thousandsGroupStyle;
402
404
  if (m === void 0 && (m = "thousand"), e === "" || e === "-")
403
405
  return e;
404
- var S = ie(t), p = S.thousandSeparator, h = S.decimalSeparator, c = r !== 0 && e.indexOf(".") !== -1 || r && n, x = se(e, l), y = x.beforeDecimal, s = x.afterDecimal, I = x.addNegation;
405
- return r !== void 0 && (s = ye(s, r, !!n)), p && (y = Le(y, p, m)), a && (y = a + y), i && (s = s + i), I && (y = "-" + y), e = y + (c && h || "") + s, e;
406
+ var S = oe(t), p = S.thousandSeparator, h = S.decimalSeparator, c = r !== 0 && e.indexOf(".") !== -1 || r && n, x = de(e, l), y = x.beforeDecimal, v = x.afterDecimal, I = x.addNegation;
407
+ return r !== void 0 && (v = Ne(v, r, !!n)), p && (y = We(y, p, m)), a && (y = a + y), i && (v = v + i), I && (y = "-" + y), e = y + (c && h || "") + v, e;
406
408
  }
407
- function ie(e) {
409
+ function oe(e) {
408
410
  var t = e.decimalSeparator;
409
411
  t === void 0 && (t = ".");
410
412
  var r = e.thousandSeparator, n = e.allowedDecimalSeparators;
@@ -414,52 +416,52 @@ function ie(e) {
414
416
  allowedDecimalSeparators: n
415
417
  };
416
418
  }
417
- function Je(e, t) {
419
+ function tt(e, t) {
418
420
  e === void 0 && (e = "");
419
421
  var r = new RegExp("(-)"), n = new RegExp("(-)(.)*(-)"), a = r.test(e), i = n.test(e);
420
422
  return e = e.replace(/-/g, ""), a && !i && t && (e = "-" + e), e;
421
423
  }
422
- function Qe(e, t) {
423
- return new RegExp("(^-)|[0-9]|" + xe(e), "g");
424
+ function rt(e, t) {
425
+ return new RegExp("(^-)|[0-9]|" + Ve(e), "g");
424
426
  }
425
- function Xe(e, t, r) {
427
+ function at(e, t, r) {
426
428
  return e === "" ? !0 : !t?.match(/\d/) && !r?.match(/\d/) && typeof e == "string" && !isNaN(Number(e));
427
429
  }
428
- function Ye(e, t, r) {
430
+ function nt(e, t, r) {
429
431
  var n;
430
- t === void 0 && (t = Ue(e));
432
+ t === void 0 && (t = ze(e));
431
433
  var a = r.allowNegative, i = r.prefix;
432
434
  i === void 0 && (i = "");
433
435
  var l = r.suffix;
434
436
  l === void 0 && (l = "");
435
- var m = r.decimalScale, S = t.from, p = t.to, h = p.start, c = p.end, x = ie(r), y = x.allowedDecimalSeparators, s = x.decimalSeparator, I = e[c] === s;
437
+ var m = r.decimalScale, S = t.from, p = t.to, h = p.start, c = p.end, x = oe(r), y = x.allowedDecimalSeparators, v = x.decimalSeparator, I = e[c] === v;
436
438
  if (ae(e) && (e === i || e === l) && t.lastValue === "")
437
439
  return e;
438
440
  if (c - h === 1 && y.indexOf(e[h]) !== -1) {
439
- var C = m === 0 ? "" : s;
441
+ var C = m === 0 ? "" : v;
440
442
  e = e.substring(0, h) + C + e.substring(h + 1, e.length);
441
443
  }
442
- var g = function(f, N, R) {
443
- var A = !1, E = !1;
444
- i.startsWith("-") ? A = !1 : f.startsWith("--") ? (A = !1, E = !0) : l.startsWith("-") && f.length === l.length ? A = !1 : f[0] === "-" && (A = !0);
445
- var O = A ? 1 : 0;
446
- return E && (O = 2), O && (f = f.substring(O), N -= O, R -= O), { value: f, start: N, end: R, hasNegation: A };
447
- }, B = g(e, h, c), F = B.hasNegation;
448
- n = B, e = n.value, h = n.start, c = n.end;
449
- var k = g(t.lastValue, S.start, S.end), j = k.start, z = k.end, P = k.value, V = e.substring(h, c);
450
- e.length && P.length && (j > P.length - l.length || z < i.length) && !(V && l.startsWith(V)) && (e = P);
451
- var L = 0;
452
- e.startsWith(i) ? L += i.length : h < i.length && (L = h), e = e.substring(L), c -= L;
453
- var W = e.length, M = e.length - l.length;
454
- e.endsWith(l) ? W = M : (c > M || c > e.length - l.length) && (W = c), e = e.substring(0, W), e = Je(F ? "-" + e : e, a), e = (e.match(Qe(s)) || []).join("");
455
- var U = e.indexOf(s);
456
- e = e.replace(new RegExp(xe(s), "g"), function(f, N) {
457
- return N === U ? "." : "";
444
+ var g = function(f, N, A) {
445
+ var O = !1, E = !1;
446
+ i.startsWith("-") ? O = !1 : f.startsWith("--") ? (O = !1, E = !0) : l.startsWith("-") && f.length === l.length ? O = !1 : f[0] === "-" && (O = !0);
447
+ var R = O ? 1 : 0;
448
+ return E && (R = 2), R && (f = f.substring(R), N -= R, A -= R), { value: f, start: N, end: A, hasNegation: O };
449
+ }, T = g(e, h, c), B = T.hasNegation;
450
+ n = T, e = n.value, h = n.start, c = n.end;
451
+ var M = g(t.lastValue, S.start, S.end), F = M.start, q = M.end, k = M.value, V = e.substring(h, c);
452
+ e.length && k.length && (F > k.length - l.length || q < i.length) && !(V && l.startsWith(V)) && (e = k);
453
+ var j = 0;
454
+ e.startsWith(i) ? j += i.length : h < i.length && (j = h), e = e.substring(j), c -= j;
455
+ var K = e.length, L = e.length - l.length;
456
+ e.endsWith(l) ? K = L : (c > L || c > e.length - l.length) && (K = c), e = e.substring(0, K), e = tt(B ? "-" + e : e, a), e = (e.match(rt(v)) || []).join("");
457
+ var W = e.indexOf(v);
458
+ e = e.replace(new RegExp(Ve(v), "g"), function(f, N) {
459
+ return N === W ? "." : "";
458
460
  });
459
- var $ = se(e, a), J = $.beforeDecimal, ee = $.afterDecimal, d = $.addNegation;
460
- return p.end - p.start < S.end - S.start && J === "" && I && !parseFloat(ee) && (e = d ? "-" : ""), e;
461
+ var U = de(e, a), H = U.beforeDecimal, ee = U.afterDecimal, d = U.addNegation;
462
+ return p.end - p.start < S.end - S.start && H === "" && I && !parseFloat(ee) && (e = d ? "-" : ""), e;
461
463
  }
462
- function et(e, t) {
464
+ function it(e, t) {
463
465
  var r = t.prefix;
464
466
  r === void 0 && (r = "");
465
467
  var n = t.suffix;
@@ -471,8 +473,8 @@ function et(e, t) {
471
473
  var l = e.length;
472
474
  return a.fill(!1, l - n.length + 1, l + 1), a;
473
475
  }
474
- function tt(e) {
475
- var t = ie(e), r = t.thousandSeparator, n = t.decimalSeparator, a = e.prefix;
476
+ function ot(e) {
477
+ var t = oe(e), r = t.thousandSeparator, n = t.decimalSeparator, a = e.prefix;
476
478
  a === void 0 && (a = "");
477
479
  var i = e.allowNegative;
478
480
  if (i === void 0 && (i = !0), r === n)
@@ -487,40 +489,40 @@ function tt(e) {
487
489
  allowNegative: ` + i + `
488
490
  `), i = !1), Object.assign(Object.assign({}, e), { allowNegative: i });
489
491
  }
490
- function rt(e) {
491
- e = tt(e), e.decimalSeparator, e.allowedDecimalSeparators, e.thousandsGroupStyle;
492
+ function ut(e) {
493
+ e = ot(e), e.decimalSeparator, e.allowedDecimalSeparators, e.thousandsGroupStyle;
492
494
  var t = e.suffix, r = e.allowNegative, n = e.allowLeadingZeros, a = e.onKeyDown;
493
- a === void 0 && (a = q);
495
+ a === void 0 && (a = Z);
494
496
  var i = e.onBlur;
495
- i === void 0 && (i = q);
497
+ i === void 0 && (i = Z);
496
498
  var l = e.thousandSeparator, m = e.decimalScale, S = e.fixedDecimalScale, p = e.prefix;
497
499
  p === void 0 && (p = "");
498
- var h = e.defaultValue, c = e.value, x = e.valueIsNumericString, y = e.onValueChange, s = Se(e, ["decimalSeparator", "allowedDecimalSeparators", "thousandsGroupStyle", "suffix", "allowNegative", "allowLeadingZeros", "onKeyDown", "onBlur", "thousandSeparator", "decimalScale", "fixedDecimalScale", "prefix", "defaultValue", "value", "valueIsNumericString", "onValueChange"]), I = ie(e), C = I.decimalSeparator, g = I.allowedDecimalSeparators, B = function(d) {
499
- return he(d, e);
500
- }, F = function(d, f) {
501
- return Ye(d, f, e);
502
- }, k = Y(c) ? h : c, j = x ?? Xe(k, p, t);
503
- Y(c) ? Y(h) || (j = j || typeof h == "number") : j = j || typeof c == "number";
504
- var z = function(d) {
505
- return pe(d) ? d : (typeof d == "number" && (d = be(d)), j && typeof m == "number" ? ge(d, m, !!S) : d);
506
- }, P = Ne(z(c), z(h), !!j, B, F, y), V = P[0], L = V.numAsString, W = V.formattedValue, M = P[1], U = function(d) {
507
- var f = d.target, N = d.key, R = f.selectionStart, A = f.selectionEnd, E = f.value;
508
- if (E === void 0 && (E = ""), (N === "Backspace" || N === "Delete") && A < p.length) {
500
+ var h = e.defaultValue, c = e.value, x = e.valueIsNumericString, y = e.onValueChange, v = ye(e, ["decimalSeparator", "allowedDecimalSeparators", "thousandsGroupStyle", "suffix", "allowNegative", "allowLeadingZeros", "onKeyDown", "onBlur", "thousandSeparator", "decimalScale", "fixedDecimalScale", "prefix", "defaultValue", "value", "valueIsNumericString", "onValueChange"]), I = oe(e), C = I.decimalSeparator, g = I.allowedDecimalSeparators, T = function(d) {
501
+ return pe(d, e);
502
+ }, B = function(d, f) {
503
+ return nt(d, f, e);
504
+ }, M = Y(c) ? h : c, F = x ?? at(M, p, t);
505
+ Y(c) ? Y(h) || (F = F || typeof h == "number") : F = F || typeof c == "number";
506
+ var q = function(d) {
507
+ return be(d) ? d : (typeof d == "number" && (d = we(d)), F && typeof m == "number" ? he(d, m, !!S) : d);
508
+ }, k = Ie(q(c), q(h), !!F, T, B, y), V = k[0], j = V.numAsString, K = V.formattedValue, L = k[1], W = function(d) {
509
+ var f = d.target, N = d.key, A = f.selectionStart, O = f.selectionEnd, E = f.value;
510
+ if (E === void 0 && (E = ""), (N === "Backspace" || N === "Delete") && O < p.length) {
509
511
  d.preventDefault();
510
512
  return;
511
513
  }
512
- if (R !== A) {
514
+ if (A !== O) {
513
515
  a(d);
514
516
  return;
515
517
  }
516
- N === "Backspace" && E[0] === "-" && R === p.length + 1 && r && H(f, 1), m && S && (N === "Backspace" && E[R - 1] === C ? (H(f, R - 1), d.preventDefault()) : N === "Delete" && E[R] === C && d.preventDefault()), g?.includes(N) && E[R] === C && H(f, R + 1);
517
- var O = l === !0 ? "," : l;
518
- N === "Backspace" && E[R - 1] === O && H(f, R - 1), N === "Delete" && E[R] === O && H(f, R + 1), a(d);
519
- }, $ = function(d) {
520
- var f = L;
521
- if (f.match(/\d/g) || (f = ""), n || (f = ke(f)), S && m && (f = ge(f, m, S)), f !== L) {
522
- var N = he(f, e);
523
- M({
518
+ N === "Backspace" && E[0] === "-" && A === p.length + 1 && r && z(f, 1), m && S && (N === "Backspace" && E[A - 1] === C ? (z(f, A - 1), d.preventDefault()) : N === "Delete" && E[A] === C && d.preventDefault()), g?.includes(N) && E[A] === C && z(f, A + 1);
519
+ var R = l === !0 ? "," : l;
520
+ N === "Backspace" && E[A - 1] === R && z(f, A - 1), N === "Delete" && E[A] === R && z(f, A + 1), a(d);
521
+ }, U = function(d) {
522
+ var f = j;
523
+ if (f.match(/\d/g) || (f = ""), n || (f = $e(f)), S && m && (f = he(f, m, S)), f !== j) {
524
+ var N = pe(f, e);
525
+ L({
524
526
  formattedValue: N,
525
527
  value: f,
526
528
  floatValue: parseFloat(f)
@@ -530,50 +532,50 @@ function rt(e) {
530
532
  });
531
533
  }
532
534
  i(d);
533
- }, J = function(d) {
535
+ }, H = function(d) {
534
536
  return d === C ? !0 : ae(d);
535
537
  }, ee = function(d) {
536
- var f = d.currentValue, N = d.lastValue, R = d.formattedValue, A = d.currentValueIndex, E = d.formattedValueIndex, O = f[A], Q = R[E], oe = Ve(N, f), te = oe.to, ne = function(ue) {
537
- return F(ue).indexOf(".") + p.length;
538
+ var f = d.currentValue, N = d.lastValue, A = d.formattedValue, O = d.currentValueIndex, E = d.formattedValueIndex, R = f[O], J = A[E], ue = De(N, f), te = ue.to, ne = function(le) {
539
+ return B(le).indexOf(".") + p.length;
538
540
  };
539
- return c === 0 && S && m && f[te.start] === C && ne(f) < A && ne(R) > E ? !1 : A >= te.start && A < te.end && g && g.includes(O) && Q === C ? !0 : O === Q;
541
+ return c === 0 && S && m && f[te.start] === C && ne(f) < O && ne(A) > E ? !1 : O >= te.start && O < te.end && g && g.includes(R) && J === C ? !0 : R === J;
540
542
  };
541
- return Object.assign(Object.assign({}, s), {
542
- value: W,
543
+ return Object.assign(Object.assign({}, v), {
544
+ value: K,
543
545
  valueIsNumericString: !1,
544
- isValidInputCharacter: J,
546
+ isValidInputCharacter: H,
545
547
  isCharacterSame: ee,
546
- onValueChange: M,
547
- format: B,
548
- removeFormatting: F,
548
+ onValueChange: L,
549
+ format: T,
550
+ removeFormatting: B,
549
551
  getCaretBoundary: function(d) {
550
- return et(d, e);
552
+ return it(d, e);
551
553
  },
552
- onKeyDown: U,
553
- onBlur: $
554
+ onKeyDown: W,
555
+ onBlur: U
554
556
  });
555
557
  }
556
- function at(e) {
557
- var t = rt(e);
558
- return X.createElement(He, Object.assign({}, t));
558
+ function lt(e) {
559
+ var t = ut(e);
560
+ return Q.createElement(et, Object.assign({}, t));
559
561
  }
560
- function we() {
562
+ function Ce() {
561
563
  return Intl.NumberFormat()?.formatToParts(1.1)?.find((r) => r.type === "decimal")?.value ?? ".";
562
564
  }
563
- function nt() {
564
- return we() === "." ? "," : ".";
565
+ function ft() {
566
+ return Ce() === "." ? "," : ".";
565
567
  }
566
- const ot = (e) => {
567
- const { value: t, onChange: r, disabled: n, highlight: a, validatedSelection: i, fixedDecimals: l, allowNegative: m, thousandSeparator: S, decimalSeparator: p } = e, h = T.useRef();
568
- return T.useLayoutEffect(() => {
568
+ const st = (e) => {
569
+ const { value: t, onChange: r, disabled: n, highlight: a, validatedSelection: i, fixedDecimals: l, allowNegative: m, thousandSeparator: S, decimalSeparator: p } = e, h = ie.useRef();
570
+ return ie.useLayoutEffect(() => {
569
571
  if (i !== void 0) {
570
572
  const c = typeof i == "number" ? [i, null] : i;
571
573
  h.current?.setSelectionRange(c[0], c[1]);
572
574
  }
573
- }, [i]), T.createElement(
574
- Be,
575
+ }, [i]), ie.createElement(
576
+ Me,
575
577
  null,
576
- T.createElement(at, {
578
+ ie.createElement(lt, {
577
579
  autoFocus: !0,
578
580
  getInputRef: h,
579
581
  className: "gdg-input",
@@ -581,8 +583,8 @@ const ot = (e) => {
581
583
  disabled: n === !0,
582
584
  decimalScale: l,
583
585
  allowNegative: m,
584
- thousandSeparator: S ?? nt(),
585
- decimalSeparator: p ?? we(),
586
+ thousandSeparator: S ?? ft(),
587
+ decimalSeparator: p ?? Ce(),
586
588
  value: Object.is(t, -0) ? "-" : t ?? "",
587
589
  // decimalScale={3}
588
590
  // prefix={"$"}
@@ -591,5 +593,5 @@ const ot = (e) => {
591
593
  );
592
594
  };
593
595
  export {
594
- ot as default
596
+ st as default
595
597
  };