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