@livestore/devtools-vite 0.3.0-dev.4 → 0.3.0-dev.41

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.
Files changed (38) hide show
  1. package/README.md +17 -0
  2. package/dist/devtools-bundle/data-grid-overlay-editor-BBAPzzoM.js +103 -0
  3. package/dist/devtools-bundle/devtools-react-bundle-BpYw33FL.js +137280 -0
  4. package/dist/devtools-bundle/devtools-vite.css +1 -0
  5. package/dist/devtools-bundle/index-IMEI-cgl.js +44 -0
  6. package/dist/devtools-bundle/index.js +4 -0
  7. package/dist/devtools-bundle/mod-2ScWT2NO.js +368 -0
  8. package/dist/devtools-bundle/number-overlay-editor-f7gD0_gg.js +596 -0
  9. package/dist/empty-module.d.ts +3 -0
  10. package/dist/empty-module.d.ts.map +1 -0
  11. package/dist/empty-module.js +3 -0
  12. package/dist/empty-module.js.map +1 -0
  13. package/dist/generous.d.ts +8 -0
  14. package/dist/generous.d.ts.map +1 -0
  15. package/dist/generous.js +101 -0
  16. package/dist/generous.js.map +1 -0
  17. package/dist/plugin.d.ts +28 -5
  18. package/dist/plugin.d.ts.map +1 -1
  19. package/dist/plugin.js +215 -48
  20. package/dist/plugin.js.map +1 -1
  21. package/dist/vite-path.d.ts +5 -0
  22. package/dist/vite-path.d.ts.map +1 -0
  23. package/dist/vite-path.js +6 -0
  24. package/dist/vite-path.js.map +1 -0
  25. package/dist/vite-path.test.d.ts +2 -0
  26. package/dist/vite-path.test.d.ts.map +1 -0
  27. package/dist/vite-path.test.js +14 -0
  28. package/dist/vite-path.test.js.map +1 -0
  29. package/package.json +8 -19
  30. package/dist/.tsbuildinfo +0 -1
  31. package/dist/devtools.d.ts +0 -2
  32. package/dist/devtools.d.ts.map +0 -1
  33. package/dist/devtools.js +0 -2
  34. package/dist/devtools.js.map +0 -1
  35. package/index.css +0 -1
  36. package/src/devtools.ts +0 -1
  37. package/src/plugin.ts +0 -112
  38. package/tsconfig.json +0 -12
package/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # @livestore/devtools-vite
2
+
3
+ Vite plugin for the LiveStore Devtools.
4
+
5
+ ## Usage
6
+
7
+ ```ts
8
+ // vite.config.ts
9
+ import { defineConfig } from 'vite'
10
+ import { livestoreVitePlugin } from '@livestore/devtools-vite'
11
+
12
+ export default defineConfig({
13
+ plugins: [
14
+ livestoreDevtoolsPlugin({ schemaPath: './src/livestore/schema.ts' }),
15
+ ],
16
+ })
17
+ ```
@@ -0,0 +1,103 @@
1
+ import { s as L, r, i as D, a as $, b as z, c as J, T as Q, C as U, m as Z } from "./devtools-react-bundle-BpYw33FL.js";
2
+ const ee = () => (t) => t.targetX, te = () => (t) => t.targetY, re = () => (t) => t.targetWidth, ne = () => (t) => t.targetHeight, ie = () => (t) => t.targetY + 10, se = () => (t) => Math.max(0, (t.targetHeight - 28) / 2), ae = /* @__PURE__ */ L("div")({
3
+ name: "DataGridOverlayEditorStyle",
4
+ class: "gdg-d19meir1",
5
+ propsAsIs: !1,
6
+ vars: {
7
+ "d19meir1-0": [te(), "px"],
8
+ "d19meir1-1": [ee(), "px"],
9
+ "d19meir1-2": [re(), "px"],
10
+ "d19meir1-3": [ne(), "px"],
11
+ "d19meir1-4": [ie(), "px"],
12
+ "d19meir1-5": [se(), "px"]
13
+ }
14
+ });
15
+ function oe() {
16
+ const [t, s] = r.useState();
17
+ return [t ?? void 0, s];
18
+ }
19
+ function de() {
20
+ const [t, s] = oe(), [n, p] = r.useState(0), [f, b] = r.useState(!0);
21
+ r.useLayoutEffect(() => {
22
+ if (t === void 0 || !("IntersectionObserver" in window))
23
+ return;
24
+ const a = new IntersectionObserver((o) => {
25
+ o.length !== 0 && b(o[0].isIntersecting);
26
+ }, { threshold: 1 });
27
+ return a.observe(t), () => a.disconnect();
28
+ }, [t]), r.useEffect(() => {
29
+ if (f || t === void 0)
30
+ return;
31
+ let a;
32
+ const o = () => {
33
+ const { right: v } = t.getBoundingClientRect();
34
+ p((g) => Math.min(g + window.innerWidth - v - 10, 0)), a = requestAnimationFrame(o);
35
+ };
36
+ return a = requestAnimationFrame(o), () => {
37
+ a !== void 0 && cancelAnimationFrame(a);
38
+ };
39
+ }, [t, f]);
40
+ const C = r.useMemo(() => ({ transform: `translateX(${n}px)` }), [n]);
41
+ return {
42
+ ref: s,
43
+ style: C
44
+ };
45
+ }
46
+ const ue = (t) => {
47
+ const { target: s, content: n, onFinishEditing: p, forceEditMode: f, initialValue: b, imageEditorOverride: C, markdownDivCreateNode: a, highlight: o, className: v, theme: g, id: G, cell: x, bloom: I, validateCell: m, getCellRenderer: w, provideEditor: F, isOutsideClick: H } = t, [d, X] = r.useState(f ? n : void 0), O = r.useRef(d ?? n);
48
+ O.current = d ?? n;
49
+ const [y, S] = r.useState(() => m === void 0 ? !0 : !(D(n) && m?.(x, n, O.current) === !1)), u = r.useCallback((e, i) => {
50
+ p(y ? e : void 0, i);
51
+ }, [y, p]), A = r.useCallback((e) => {
52
+ if (m !== void 0 && e !== void 0 && D(e)) {
53
+ const i = m(x, e, O.current);
54
+ i === !1 ? S(!1) : (typeof i == "object" && (e = i), S(!0));
55
+ }
56
+ X(e);
57
+ }, [x, m]), h = r.useRef(!1), c = r.useRef(void 0), K = r.useCallback(() => {
58
+ u(d, [0, 0]), h.current = !0;
59
+ }, [d, u]), W = r.useCallback((e, i) => {
60
+ u(e, i ?? c.current ?? [0, 0]), h.current = !0;
61
+ }, [u]), Y = r.useCallback(async (e) => {
62
+ let i = !1;
63
+ e.key === "Escape" ? (e.stopPropagation(), e.preventDefault(), c.current = [0, 0]) : e.key === "Enter" && !e.shiftKey ? (e.stopPropagation(), e.preventDefault(), c.current = [0, 1], i = !0) : e.key === "Tab" && (e.stopPropagation(), e.preventDefault(), c.current = [e.shiftKey ? -1 : 1, 0], i = !0), window.setTimeout(() => {
64
+ !h.current && c.current !== void 0 && (u(i ? d : void 0, c.current), h.current = !0);
65
+ }, 0);
66
+ }, [u, d]), k = d ?? n, [l, j] = r.useMemo(() => {
67
+ if ($(n))
68
+ return [];
69
+ const e = F?.(n);
70
+ return e !== void 0 ? [e, !1] : [w(n)?.provideEditor?.(n), !1];
71
+ }, [n, w, F]), { ref: q, style: B } = de();
72
+ let P = !0, M, _ = !0, E;
73
+ if (l !== void 0) {
74
+ P = l.disablePadding !== !0, _ = l.disableStyling !== !0;
75
+ const e = z(l);
76
+ e && (E = l.styleOverride);
77
+ const i = e ? l.editor : l;
78
+ M = r.createElement(i, { isHighlighted: o, onChange: A, value: k, initialValue: b, onFinishedEditing: W, validatedSelection: D(k) ? k.selectionRange : void 0, forceEditMode: f, target: s, imageEditorOverride: C, markdownDivCreateNode: a, isValid: y, theme: g });
79
+ }
80
+ E = { ...E, ...B };
81
+ const N = document.getElementById("portal");
82
+ if (N === null)
83
+ return console.error('Cannot open Data Grid overlay editor, because portal not found. Please add `<div id="portal" />` as the last child of your `<body>`.'), null;
84
+ let R = _ ? "gdg-style" : "gdg-unstyle";
85
+ y || (R += " gdg-invalid"), P && (R += " gdg-pad");
86
+ const T = I?.[0] ?? 1, V = I?.[1] ?? 1;
87
+ return J.createPortal(r.createElement(
88
+ Q.Provider,
89
+ { value: g },
90
+ r.createElement(
91
+ U,
92
+ { style: Z(g), className: v, onClickOutside: K, isOutsideClick: H },
93
+ r.createElement(
94
+ ae,
95
+ { ref: q, id: G, className: R, style: E, as: j === !0 ? "label" : void 0, targetX: s.x - T, targetY: s.y - V, targetWidth: s.width + T * 2, targetHeight: s.height + V * 2 },
96
+ r.createElement("div", { className: "gdg-clip-region", onKeyDown: Y }, M)
97
+ )
98
+ )
99
+ ), N);
100
+ };
101
+ export {
102
+ ue as default
103
+ };