@brett_lamy/ui 4.0.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/animated-height.d.ts +3 -1
- package/dist/components/animated-height.d.ts.map +1 -1
- package/dist/components/animated-height.js +11 -11
- package/dist/components/artifact-chat-container.d.ts.map +1 -1
- package/dist/components/artifact-chat-container.js +81 -82
- package/dist/components/button.d.ts +4 -3
- package/dist/components/button.d.ts.map +1 -1
- package/dist/components/button.js +22 -9
- package/dist/components/canvas.d.ts +91 -0
- package/dist/components/canvas.d.ts.map +1 -0
- package/dist/components/canvas.js +296 -0
- package/dist/components/composer/composer-cards.d.ts +55 -0
- package/dist/components/composer/composer-cards.d.ts.map +1 -0
- package/dist/components/composer/composer-cards.js +351 -0
- package/dist/components/composer/composer.d.ts +9 -1
- package/dist/components/composer/composer.d.ts.map +1 -1
- package/dist/components/composer/composer.js +179 -154
- package/dist/components/context-menu.d.ts +25 -0
- package/dist/components/context-menu.d.ts.map +1 -0
- package/dist/components/context-menu.js +127 -0
- package/dist/components/credenza.d.ts.map +1 -1
- package/dist/components/credenza.js +52 -92
- package/dist/components/cron-editor.d.ts +47 -0
- package/dist/components/cron-editor.d.ts.map +1 -0
- package/dist/components/cron-editor.js +297 -0
- package/dist/components/dropdown-menu.d.ts +3 -1
- package/dist/components/dropdown-menu.d.ts.map +1 -1
- package/dist/components/dropdown-menu.js +5 -5
- package/dist/components/edge-drawer.d.ts.map +1 -1
- package/dist/components/edge-drawer.js +1 -0
- package/dist/components/file-upload.d.ts +121 -0
- package/dist/components/file-upload.d.ts.map +1 -0
- package/dist/components/file-upload.js +405 -0
- package/dist/components/filter-input.d.ts +22 -0
- package/dist/components/filter-input.d.ts.map +1 -0
- package/dist/components/filter-input.js +126 -0
- package/dist/components/filter.d.ts +154 -0
- package/dist/components/filter.d.ts.map +1 -0
- package/dist/components/filter.js +815 -0
- package/dist/components/floating-chat.d.ts.map +1 -1
- package/dist/components/floating-chat.js +71 -88
- package/dist/components/floating-sheet.d.ts.map +1 -1
- package/dist/components/floating-sheet.js +93 -104
- package/dist/components/markdown-editor.d.ts +2 -0
- package/dist/components/markdown-editor.d.ts.map +1 -1
- package/dist/components/markdown-editor.js +46 -45
- package/dist/components/markdown-view.d.ts +6 -1
- package/dist/components/markdown-view.d.ts.map +1 -1
- package/dist/components/markdown-view.js +13 -11
- package/dist/components/navigation-stack.d.ts +3 -5
- package/dist/components/navigation-stack.d.ts.map +1 -1
- package/dist/components/navigation-stack.js +212 -382
- package/dist/components/passkey-enroll-dialog.d.ts +36 -0
- package/dist/components/passkey-enroll-dialog.d.ts.map +1 -0
- package/dist/components/passkey-enroll-dialog.js +234 -0
- package/dist/components/result-table.d.ts +38 -0
- package/dist/components/result-table.d.ts.map +1 -0
- package/dist/components/result-table.js +161 -0
- package/dist/components/schema-tree.d.ts +19 -0
- package/dist/components/schema-tree.d.ts.map +1 -0
- package/dist/components/schema-tree.js +172 -0
- package/dist/components/side-drawer.d.ts.map +1 -1
- package/dist/components/side-drawer.js +117 -143
- package/dist/components/slider.d.ts.map +1 -1
- package/dist/components/slider.js +4 -1
- package/dist/components/spinner-shapes.d.ts +263 -0
- package/dist/components/spinner-shapes.d.ts.map +1 -0
- package/dist/components/spinner-shapes.js +771 -0
- package/dist/components/spinner.d.ts +133 -3
- package/dist/components/spinner.d.ts.map +1 -1
- package/dist/components/spinner.js +445 -29
- package/dist/components/sql-console.d.ts +28 -0
- package/dist/components/sql-console.d.ts.map +1 -0
- package/dist/components/sql-console.js +348 -0
- package/dist/components/sql-editor.d.ts +47 -0
- package/dist/components/sql-editor.d.ts.map +1 -0
- package/dist/components/sql-editor.js +170 -0
- package/dist/components/tab-view.d.ts +2 -2
- package/dist/components/tab-view.d.ts.map +1 -1
- package/dist/components/tab-view.js +63 -49
- package/dist/components/tailscale-login-button.d.ts +53 -0
- package/dist/components/tailscale-login-button.d.ts.map +1 -0
- package/dist/components/tailscale-login-button.js +197 -0
- package/dist/components/time-input.d.ts +46 -0
- package/dist/components/time-input.d.ts.map +1 -0
- package/dist/components/time-input.js +258 -0
- package/dist/components/toast.d.ts +5 -2
- package/dist/components/toast.d.ts.map +1 -1
- package/dist/components/toast.js +249 -125
- package/dist/components/vault-gate.d.ts +60 -0
- package/dist/components/vault-gate.d.ts.map +1 -0
- package/dist/components/vault-gate.js +382 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +85 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +129 -83
- package/dist/lib/back-history.d.ts +5 -0
- package/dist/lib/back-history.d.ts.map +1 -0
- package/dist/lib/back-history.js +44 -0
- package/dist/lib/canvas-math.d.ts +82 -0
- package/dist/lib/canvas-math.d.ts.map +1 -0
- package/dist/lib/canvas-math.js +226 -0
- package/dist/lib/controllable-state.d.ts +4 -0
- package/dist/lib/controllable-state.d.ts.map +1 -0
- package/dist/lib/controllable-state.js +11 -0
- package/dist/lib/cron.d.ts +55 -0
- package/dist/lib/cron.d.ts.map +1 -0
- package/dist/lib/cron.js +269 -0
- package/dist/lib/edge-swipe.d.ts +36 -0
- package/dist/lib/edge-swipe.d.ts.map +1 -0
- package/dist/lib/edge-swipe.js +73 -0
- package/dist/lib/file-upload.d.ts +187 -0
- package/dist/lib/file-upload.d.ts.map +1 -0
- package/dist/lib/file-upload.js +349 -0
- package/dist/lib/filter-query.d.ts +90 -0
- package/dist/lib/filter-query.d.ts.map +1 -0
- package/dist/lib/filter-query.js +459 -0
- package/dist/lib/filter.d.ts +120 -0
- package/dist/lib/filter.d.ts.map +1 -0
- package/dist/lib/filter.js +399 -0
- package/dist/lib/format-bytes.d.ts +3 -0
- package/dist/lib/format-bytes.d.ts.map +1 -0
- package/dist/lib/format-bytes.js +16 -0
- package/dist/lib/gpu-cron.d.ts +51 -0
- package/dist/lib/gpu-cron.d.ts.map +1 -0
- package/dist/lib/gpu-cron.js +81 -0
- package/dist/lib/gpu-query/featurize.d.ts +19 -0
- package/dist/lib/gpu-query/featurize.d.ts.map +1 -0
- package/dist/lib/gpu-query/featurize.js +88 -0
- package/dist/lib/gpu-query/index.d.ts +73 -0
- package/dist/lib/gpu-query/index.d.ts.map +1 -0
- package/dist/lib/gpu-query/index.js +117 -0
- package/dist/lib/gpu-query/kernel.wgsl.d.ts +30 -0
- package/dist/lib/gpu-query/kernel.wgsl.d.ts.map +1 -0
- package/dist/lib/gpu-query/model.d.ts +8 -0
- package/dist/lib/gpu-query/model.d.ts.map +1 -0
- package/dist/lib/gpu-query/model.js +91 -0
- package/dist/lib/gpu-query/schema.d.ts +40 -0
- package/dist/lib/gpu-query/schema.d.ts.map +1 -0
- package/dist/lib/gpu-query/schema.js +0 -0
- package/dist/lib/gpu-query/webgpu.d.ts +12 -0
- package/dist/lib/gpu-query/webgpu.d.ts.map +1 -0
- package/dist/lib/gpu-query/weights.d.ts +17 -0
- package/dist/lib/gpu-query/weights.d.ts.map +1 -0
- package/dist/lib/gpu-query/weights.js +40 -0
- package/dist/lib/gpu-query/weights.json.d.ts +3 -0
- package/dist/lib/gpu-query/weights2.js +25 -0
- package/dist/lib/gpu-time.d.ts +77 -0
- package/dist/lib/gpu-time.d.ts.map +1 -0
- package/dist/lib/gpu-time.js +260 -0
- package/dist/lib/morph-path.d.ts +22 -0
- package/dist/lib/morph-path.d.ts.map +1 -0
- package/dist/lib/morph-path.js +42 -0
- package/dist/lib/passkey.d.ts +120 -0
- package/dist/lib/passkey.d.ts.map +1 -0
- package/dist/lib/passkey.js +186 -0
- package/dist/lib/persistent-state.d.ts +9 -0
- package/dist/lib/persistent-state.d.ts.map +1 -0
- package/dist/lib/persistent-state.js +37 -0
- package/dist/lib/pglite-core.d.ts +219 -0
- package/dist/lib/pglite-core.d.ts.map +1 -0
- package/dist/lib/pglite-core.js +273 -0
- package/dist/lib/pglite-files.d.ts +7 -0
- package/dist/lib/pglite-files.d.ts.map +1 -0
- package/dist/lib/pglite-files.js +17 -0
- package/dist/lib/pglite-schema.d.ts +58 -0
- package/dist/lib/pglite-schema.d.ts.map +1 -0
- package/dist/lib/pglite-schema.js +105 -0
- package/dist/lib/pglite-storage.d.ts +33 -0
- package/dist/lib/pglite-storage.d.ts.map +1 -0
- package/dist/lib/pglite-storage.js +55 -0
- package/dist/lib/pglite-transfer.d.ts +53 -0
- package/dist/lib/pglite-transfer.d.ts.map +1 -0
- package/dist/lib/pglite-transfer.js +126 -0
- package/dist/lib/pglite.d.ts +106 -0
- package/dist/lib/pglite.d.ts.map +1 -0
- package/dist/lib/pglite.js +298 -0
- package/dist/lib/pull-to-refresh.d.ts +24 -0
- package/dist/lib/pull-to-refresh.d.ts.map +1 -0
- package/dist/lib/pull-to-refresh.js +74 -0
- package/dist/lib/scroll-hidden.d.ts +6 -0
- package/dist/lib/scroll-hidden.d.ts.map +1 -0
- package/dist/lib/scroll-hidden.js +21 -0
- package/dist/lib/sql-format.d.ts +62 -0
- package/dist/lib/sql-format.d.ts.map +1 -0
- package/dist/lib/sql-format.js +175 -0
- package/dist/lib/sql-lex.d.ts +25 -0
- package/dist/lib/sql-lex.d.ts.map +1 -0
- package/dist/lib/sql-lex.js +135 -0
- package/dist/lib/tab-lock.d.ts +28 -0
- package/dist/lib/tab-lock.d.ts.map +1 -0
- package/dist/lib/tab-lock.js +80 -0
- package/dist/lib/tailscale-connect.d.ts +56 -0
- package/dist/lib/tailscale-connect.d.ts.map +1 -0
- package/dist/lib/tailscale-connect.js +99 -0
- package/dist/lib/tailscale-fake.d.ts +33 -0
- package/dist/lib/tailscale-fake.d.ts.map +1 -0
- package/dist/lib/tailscale-fake.js +80 -0
- package/dist/lib/tailscale-policy.d.ts +71 -0
- package/dist/lib/tailscale-policy.d.ts.map +1 -0
- package/dist/lib/tailscale-policy.js +244 -0
- package/dist/lib/tailscale-react.d.ts +20 -0
- package/dist/lib/tailscale-react.d.ts.map +1 -0
- package/dist/lib/tailscale-react.js +37 -0
- package/dist/lib/tailscale-router/bridge.d.ts +60 -0
- package/dist/lib/tailscale-router/bridge.d.ts.map +1 -0
- package/dist/lib/tailscale-router/bridge.js +198 -0
- package/dist/lib/tailscale-router/react.d.ts +19 -0
- package/dist/lib/tailscale-router/react.d.ts.map +1 -0
- package/dist/lib/tailscale-router/react.js +52 -0
- package/dist/lib/tailscale.d.ts +204 -0
- package/dist/lib/tailscale.d.ts.map +1 -0
- package/dist/lib/tailscale.js +443 -0
- package/dist/lib/title-flight.d.ts +34 -0
- package/dist/lib/title-flight.d.ts.map +1 -0
- package/dist/lib/title-flight.js +123 -0
- package/dist/lib/vault-react.d.ts +49 -0
- package/dist/lib/vault-react.d.ts.map +1 -0
- package/dist/lib/vault-react.js +196 -0
- package/dist/lib/vault-storage.d.ts +30 -0
- package/dist/lib/vault-storage.d.ts.map +1 -0
- package/dist/lib/vault-storage.js +105 -0
- package/dist/lib/vault.d.ts +200 -0
- package/dist/lib/vault.d.ts.map +1 -0
- package/dist/lib/vault.js +641 -0
- package/dist/tailscale-sw.js +332 -0
- package/package.json +35 -5
- package/dist/components/icon-button.d.ts +0 -19
- package/dist/components/icon-button.d.ts.map +0 -1
- package/dist/components/icon-button.js +0 -31
- package/dist/components/measure-h.d.ts +0 -7
- package/dist/components/measure-h.d.ts.map +0 -1
- package/dist/components/measure-h.js +0 -20
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../lib/utils.js";
|
|
3
|
+
import { useContainerSize as t } from "../lib/container.js";
|
|
4
|
+
import { dist as n, fitCamera as r, toBoard as i, toScreen as a, zoomAt as o } from "../lib/canvas-math.js";
|
|
5
|
+
import { createContext as s, useCallback as c, useContext as l, useEffect as u, useMemo as d, useRef as f, useState as p } from "react";
|
|
6
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/canvas.tsx
|
|
8
|
+
var _ = s(null);
|
|
9
|
+
function v() {
|
|
10
|
+
let e = l(_);
|
|
11
|
+
if (!e) throw Error("useCanvas must be used within <Canvas>");
|
|
12
|
+
return e;
|
|
13
|
+
}
|
|
14
|
+
var y = {
|
|
15
|
+
x: 0,
|
|
16
|
+
y: 0,
|
|
17
|
+
z: 1
|
|
18
|
+
};
|
|
19
|
+
function b({ camera: s, defaultCamera: l = y, onCameraChange: m, background: v = "dots", panning: b, fit: x, cursor: S = "default", autoFocus: C, onCanvasPointerDown: w, onCanvasPointerMove: T, onCanvasPointerUp: ee, onCanvasDoubleClick: te, onNavigationStart: E, onCanvasKeyDown: D, "aria-label": O = "Canvas", overlay: k, children: A, className: j, style: M }) {
|
|
20
|
+
let [N, P] = t({
|
|
21
|
+
width: 1e3,
|
|
22
|
+
height: 700
|
|
23
|
+
}), [F, I] = p(l), L = s ?? F, R = f(L);
|
|
24
|
+
R.current = L;
|
|
25
|
+
let z = f(m);
|
|
26
|
+
z.current = m;
|
|
27
|
+
let B = c((e) => {
|
|
28
|
+
let t = e(R.current);
|
|
29
|
+
R.current = t, I(t), z.current?.(t);
|
|
30
|
+
}, []), V = f(/* @__PURE__ */ new Map()), H = f(null), [U, W] = p(!1), [G, K] = p(!1);
|
|
31
|
+
u(() => {
|
|
32
|
+
C && N.current?.focus({ preventScroll: !0 });
|
|
33
|
+
}, [C, N]);
|
|
34
|
+
let q = c((e) => {
|
|
35
|
+
let t = N.current?.getBoundingClientRect();
|
|
36
|
+
return {
|
|
37
|
+
x: e.clientX - (t?.left ?? 0),
|
|
38
|
+
y: e.clientY - (t?.top ?? 0)
|
|
39
|
+
};
|
|
40
|
+
}, [N]), J = (e) => ({
|
|
41
|
+
screen: e,
|
|
42
|
+
board: i(R.current, e.x, e.y),
|
|
43
|
+
camera: R.current
|
|
44
|
+
}), Y = (e) => {
|
|
45
|
+
let t = N.current;
|
|
46
|
+
if (!t) return;
|
|
47
|
+
t.focus({ preventScroll: !0 });
|
|
48
|
+
let r = q(e);
|
|
49
|
+
if (e.pointerType === "touch" && (V.current.set(e.pointerId, r), V.current.size === 2)) {
|
|
50
|
+
let [e, t] = [...V.current.values()];
|
|
51
|
+
H.current = {
|
|
52
|
+
k: "pinch",
|
|
53
|
+
d: n(e, t),
|
|
54
|
+
mid: {
|
|
55
|
+
x: (e.x + t.x) / 2,
|
|
56
|
+
y: (e.y + t.y) / 2
|
|
57
|
+
}
|
|
58
|
+
}, E?.();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (e.pointerType !== "mouse" || e.button === 0 || e.button === 1) {
|
|
62
|
+
if (t.setPointerCapture(e.pointerId), e.button === 1 || U || b) {
|
|
63
|
+
H.current = {
|
|
64
|
+
k: "pan",
|
|
65
|
+
sx: r.x,
|
|
66
|
+
sy: r.y,
|
|
67
|
+
cam: R.current
|
|
68
|
+
}, K(!0);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
w?.(e, J(r));
|
|
72
|
+
}
|
|
73
|
+
}, X = (e) => {
|
|
74
|
+
let t = q(e);
|
|
75
|
+
if (e.pointerType === "touch" && V.current.has(e.pointerId)) {
|
|
76
|
+
V.current.set(e.pointerId, t);
|
|
77
|
+
let r = H.current;
|
|
78
|
+
if (r?.k === "pinch" && V.current.size >= 2) {
|
|
79
|
+
let [e, t] = [...V.current.values()], i = n(e, t), a = {
|
|
80
|
+
x: (e.x + t.x) / 2,
|
|
81
|
+
y: (e.y + t.y) / 2
|
|
82
|
+
};
|
|
83
|
+
B((e) => {
|
|
84
|
+
let t = o(e, i / r.d, a.x, a.y);
|
|
85
|
+
return {
|
|
86
|
+
...t,
|
|
87
|
+
x: t.x + (a.x - r.mid.x),
|
|
88
|
+
y: t.y + (a.y - r.mid.y)
|
|
89
|
+
};
|
|
90
|
+
}), H.current = {
|
|
91
|
+
k: "pinch",
|
|
92
|
+
d: i,
|
|
93
|
+
mid: a
|
|
94
|
+
};
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
let r = H.current;
|
|
99
|
+
if (r?.k === "pan") {
|
|
100
|
+
B(() => ({
|
|
101
|
+
...r.cam,
|
|
102
|
+
x: r.cam.x + t.x - r.sx,
|
|
103
|
+
y: r.cam.y + t.y - r.sy
|
|
104
|
+
}));
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
T?.(e, J(t));
|
|
108
|
+
}, Z = (e) => {
|
|
109
|
+
V.current.delete(e.pointerId);
|
|
110
|
+
let t = H.current;
|
|
111
|
+
if (t?.k === "pinch") {
|
|
112
|
+
V.current.size < 2 && (H.current = null);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (t?.k === "pan") {
|
|
116
|
+
H.current = null, K(!1);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
ee?.(e, J(q(e)));
|
|
120
|
+
}, Q = f(() => {});
|
|
121
|
+
Q.current = (e) => {
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
let t = e.deltaMode === 1 ? 16 : 1;
|
|
124
|
+
if (e.ctrlKey || e.metaKey) {
|
|
125
|
+
let n = q(e);
|
|
126
|
+
B((r) => o(r, Math.exp(-Math.max(-50, Math.min(50, e.deltaY * t)) * .009), n.x, n.y));
|
|
127
|
+
} else B((n) => ({
|
|
128
|
+
...n,
|
|
129
|
+
x: n.x - e.deltaX * t,
|
|
130
|
+
y: n.y - e.deltaY * t
|
|
131
|
+
}));
|
|
132
|
+
}, u(() => {
|
|
133
|
+
let e = N.current;
|
|
134
|
+
if (!e) return;
|
|
135
|
+
let t = (e) => Q.current(e);
|
|
136
|
+
return e.addEventListener("wheel", t, { passive: !1 }), () => e.removeEventListener("wheel", t);
|
|
137
|
+
}, [N]);
|
|
138
|
+
let ne = (e) => {
|
|
139
|
+
let t = e.metaKey || e.ctrlKey, n = e.key.toLowerCase(), i = (e) => B((t) => o(t, e, P.width / 2, P.height / 2));
|
|
140
|
+
if (n === " " && !t) {
|
|
141
|
+
e.preventDefault(), W(!0);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (t && (n === "=" || n === "+")) {
|
|
145
|
+
e.preventDefault(), i(1.25);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (t && n === "-") {
|
|
149
|
+
e.preventDefault(), i(.8);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (t && n === "0") {
|
|
153
|
+
e.preventDefault(), B(() => r(x ?? null, P));
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (t && n === "1") {
|
|
157
|
+
e.preventDefault(), B((e) => o(e, 1 / e.z, P.width / 2, P.height / 2));
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
D?.(e);
|
|
161
|
+
}, $ = L.z, re = d(() => {
|
|
162
|
+
if (v === "none") return {};
|
|
163
|
+
let e = (v === "dots" ? 24 : 40) * L.z;
|
|
164
|
+
for (; e < 12;) e *= 2;
|
|
165
|
+
let t = "color-mix(in srgb, var(--muted-foreground) 34%, transparent)", n = `${L.x}px ${L.y}px`;
|
|
166
|
+
return v === "dots" ? {
|
|
167
|
+
backgroundImage: `radial-gradient(${t} 1.1px, transparent 1.4px)`,
|
|
168
|
+
backgroundSize: `${e}px ${e}px`,
|
|
169
|
+
backgroundPosition: n
|
|
170
|
+
} : {
|
|
171
|
+
backgroundImage: `linear-gradient(to right, ${t} 1px, transparent 1px), linear-gradient(to bottom, ${t} 1px, transparent 1px)`,
|
|
172
|
+
backgroundSize: `${e}px ${e}px`,
|
|
173
|
+
backgroundPosition: n
|
|
174
|
+
};
|
|
175
|
+
}, [
|
|
176
|
+
v,
|
|
177
|
+
L.x,
|
|
178
|
+
L.y,
|
|
179
|
+
L.z
|
|
180
|
+
]), ie = d(() => ({
|
|
181
|
+
camera: L,
|
|
182
|
+
zoom: $,
|
|
183
|
+
size: P,
|
|
184
|
+
local: q,
|
|
185
|
+
toBoard: (e) => {
|
|
186
|
+
let t = q(e);
|
|
187
|
+
return i(L, t.x, t.y);
|
|
188
|
+
},
|
|
189
|
+
toScreen: (e) => a(L, e),
|
|
190
|
+
update: B
|
|
191
|
+
}), [
|
|
192
|
+
L,
|
|
193
|
+
$,
|
|
194
|
+
P,
|
|
195
|
+
q,
|
|
196
|
+
B
|
|
197
|
+
]);
|
|
198
|
+
return /* @__PURE__ */ h(_.Provider, {
|
|
199
|
+
value: ie,
|
|
200
|
+
children: /* @__PURE__ */ g("div", {
|
|
201
|
+
ref: N,
|
|
202
|
+
"data-slot": "canvas",
|
|
203
|
+
tabIndex: 0,
|
|
204
|
+
role: "application",
|
|
205
|
+
"aria-label": O,
|
|
206
|
+
onPointerDown: Y,
|
|
207
|
+
onPointerMove: X,
|
|
208
|
+
onPointerUp: Z,
|
|
209
|
+
onPointerCancel: Z,
|
|
210
|
+
onDoubleClick: (e) => te?.(e, J(q(e))),
|
|
211
|
+
onKeyDown: ne,
|
|
212
|
+
onKeyUp: (e) => {
|
|
213
|
+
e.key === " " && W(!1);
|
|
214
|
+
},
|
|
215
|
+
onBlur: () => W(!1),
|
|
216
|
+
className: e("absolute inset-0 touch-none overflow-hidden bg-background outline-none select-none focus-visible:outline-none", j),
|
|
217
|
+
style: {
|
|
218
|
+
...re,
|
|
219
|
+
cursor: G ? "grabbing" : U || b ? "grab" : S,
|
|
220
|
+
...M
|
|
221
|
+
},
|
|
222
|
+
children: [/* @__PURE__ */ h("div", {
|
|
223
|
+
"data-slot": "canvas-board",
|
|
224
|
+
className: "absolute top-0 left-0 origin-top-left text-foreground",
|
|
225
|
+
style: { transform: `translate(${L.x}px, ${L.y}px) scale(${$})` },
|
|
226
|
+
children: A
|
|
227
|
+
}), k]
|
|
228
|
+
})
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
var x = 10;
|
|
232
|
+
function S({ frame: e, dashed: t, offset: n = 3 }) {
|
|
233
|
+
let { zoom: r } = v();
|
|
234
|
+
return /* @__PURE__ */ h("div", {
|
|
235
|
+
"data-slot": "canvas-frame",
|
|
236
|
+
"aria-hidden": "true",
|
|
237
|
+
className: "pointer-events-none absolute",
|
|
238
|
+
style: {
|
|
239
|
+
left: e.x,
|
|
240
|
+
top: e.y,
|
|
241
|
+
width: e.w,
|
|
242
|
+
height: e.h,
|
|
243
|
+
transform: e.rot ? `rotate(${e.rot}deg)` : void 0,
|
|
244
|
+
outline: `${1.6 / r}px ${t ? "dashed" : "solid"} var(--primary)`,
|
|
245
|
+
outlineOffset: n / r,
|
|
246
|
+
borderRadius: 2 / r
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
function C({ handles: t }) {
|
|
251
|
+
let { zoom: n } = v(), r = x / n;
|
|
252
|
+
return /* @__PURE__ */ h(m, { children: t.map((t) => /* @__PURE__ */ h("span", {
|
|
253
|
+
"data-slot": "canvas-handle",
|
|
254
|
+
"data-handle": t.id,
|
|
255
|
+
"aria-hidden": "true",
|
|
256
|
+
className: e("pointer-events-none absolute bg-background", t.id === "rot" || t.id === "from" || t.id === "to" ? "rounded-full" : "rounded-[2px]"),
|
|
257
|
+
style: {
|
|
258
|
+
left: t.pt.x - r / 2,
|
|
259
|
+
top: t.pt.y - r / 2,
|
|
260
|
+
width: r,
|
|
261
|
+
height: r,
|
|
262
|
+
border: `${1.6 / n}px solid var(--primary)`
|
|
263
|
+
}
|
|
264
|
+
}, t.id)) });
|
|
265
|
+
}
|
|
266
|
+
function w({ rect: e }) {
|
|
267
|
+
let { zoom: t } = v();
|
|
268
|
+
return /* @__PURE__ */ h("span", {
|
|
269
|
+
"data-slot": "canvas-marquee",
|
|
270
|
+
"aria-hidden": "true",
|
|
271
|
+
className: "pointer-events-none absolute bg-primary/10",
|
|
272
|
+
style: {
|
|
273
|
+
left: e.x,
|
|
274
|
+
top: e.y,
|
|
275
|
+
width: e.w,
|
|
276
|
+
height: e.h,
|
|
277
|
+
border: `${1 / t}px solid var(--primary)`
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
function T({ guides: e }) {
|
|
282
|
+
let { zoom: t } = v();
|
|
283
|
+
return /* @__PURE__ */ h(m, { children: e.map((e, n) => /* @__PURE__ */ h("span", {
|
|
284
|
+
"data-slot": "canvas-guide",
|
|
285
|
+
"aria-hidden": "true",
|
|
286
|
+
className: "pointer-events-none absolute bg-primary",
|
|
287
|
+
style: {
|
|
288
|
+
left: e.x1,
|
|
289
|
+
top: e.y1,
|
|
290
|
+
width: Math.max(e.x2 - e.x1, 1 / t),
|
|
291
|
+
height: Math.max(e.y2 - e.y1, 1 / t)
|
|
292
|
+
}
|
|
293
|
+
}, n)) });
|
|
294
|
+
}
|
|
295
|
+
//#endregion
|
|
296
|
+
export { b as Canvas, S as CanvasFrame, T as CanvasGuides, C as CanvasHandles, w as CanvasMarquee, v as useCanvas };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ComposerAttachment } from './composer';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export interface ComposerCardsProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/** Above the composer (`top`, default) or below it. */
|
|
5
|
+
side?: 'top' | 'bottom';
|
|
6
|
+
/** Space between a card and the surface it came out of, at rest (px, at least REACH so they separate). */
|
|
7
|
+
gap?: number;
|
|
8
|
+
/** Morph in the cards that are there when the tray mounts (default: they are simply there). */
|
|
9
|
+
animateOnMount?: boolean;
|
|
10
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A tray of ComposerMorphCards on one side of the composer. Place it among the Composer's children (it orders itself
|
|
14
|
+
* outside the bumps on its side). Cards are keyed children: add one and it morphs out, remove it and it sinks back.
|
|
15
|
+
*/
|
|
16
|
+
export declare function ComposerCards({ side, gap, animateOnMount, className, style, children, ref, ...props }: ComposerCardsProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export interface ComposerMorphCardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
18
|
+
/** Called when the card has sunk back into its source after being removed. */
|
|
19
|
+
onExited?: () => void;
|
|
20
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
21
|
+
}
|
|
22
|
+
/** A card in a ComposerCards tray. Give it a stable `key`; it morphs out when added and sinks back when removed. */
|
|
23
|
+
export declare function ComposerMorphCard({ onExited, className, children, ref, ...props }: ComposerMorphCardProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export interface ComposerQueueItem {
|
|
25
|
+
id: string;
|
|
26
|
+
/** The queued draft as Markdown (attachment chips as `attachment:` refs, as in onSubmit). */
|
|
27
|
+
markdown: string;
|
|
28
|
+
attachments: ComposerAttachment[];
|
|
29
|
+
}
|
|
30
|
+
export interface ComposerQueueProps extends Omit<ComposerCardsProps, 'children' | 'onChange'> {
|
|
31
|
+
/** Controlled queue. */
|
|
32
|
+
items?: ComposerQueueItem[];
|
|
33
|
+
defaultItems?: ComposerQueueItem[];
|
|
34
|
+
onItemsChange?: (items: ComposerQueueItem[]) => void;
|
|
35
|
+
/** Send the first queued message by itself once the reply ends (default true). */
|
|
36
|
+
autoSend?: boolean;
|
|
37
|
+
/** Draws a queued message's card (default: its text, attachment count, and Edit / Send now / Remove). */
|
|
38
|
+
renderItem?: (item: ComposerQueueItem, actions: ComposerQueueActions) => React.ReactNode;
|
|
39
|
+
}
|
|
40
|
+
export interface ComposerQueueActions {
|
|
41
|
+
/** Merges the card back into the composer and puts its text back in the draft. */
|
|
42
|
+
edit: () => void;
|
|
43
|
+
/** Stops the reply (if one is streaming) and sends this message now. */
|
|
44
|
+
sendNow: () => void;
|
|
45
|
+
/** Takes the card out of the queue. */
|
|
46
|
+
remove: () => void;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Message queueing for a chat Composer. While `streaming`, sending puts the draft in a card that morphs out of the top
|
|
50
|
+
* of the composer (out of a top bump, when there is one); when the reply ends the first card merges back in and goes
|
|
51
|
+
* to `onSubmit`, then the next after the following reply. Cards can be edited (back into the draft), sent now (stops
|
|
52
|
+
* the reply), or removed.
|
|
53
|
+
*/
|
|
54
|
+
export declare function ComposerQueue({ items: itemsProp, defaultItems, onItemsChange, autoSend, renderItem, side, 'aria-label': ariaLabel, ...props }: ComposerQueueProps): import("react/jsx-runtime").JSX.Element;
|
|
55
|
+
//# sourceMappingURL=composer-cards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composer-cards.d.ts","sourceRoot":"","sources":["../../../src/components/composer/composer-cards.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,OAAO,EAA+B,KAAK,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAiHzG,MAAM,WAAW,kBAAmB,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAC9E,uDAAuD;IACvD,IAAI,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IACxB,0GAA0G;IAC1G,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,+FAA+F;IAC/F,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;CACjC;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAAE,IAAY,EAAE,GAAO,EAAE,cAAsB,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,EAAE,kBAAkB,2CA6I7I;AAED,MAAM,WAAW,sBAAuB,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAClF,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;CACjC;AAED,oHAAoH;AACpH,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,EAAE,sBAAsB,2CAiHzG;AAGD,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,6FAA6F;IAC7F,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,kBAAkB,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,kBAAkB,EAAE,UAAU,GAAG,UAAU,CAAC;IAC3F,wBAAwB;IACxB,KAAK,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC5B,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACnC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,IAAI,CAAC;IACrD,kFAAkF;IAClF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yGAAyG;IACzG,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,oBAAoB,KAAK,KAAK,CAAC,SAAS,CAAC;CAC1F;AAED,MAAM,WAAW,oBAAoB;IACnC,kFAAkF;IAClF,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,wEAAwE;IACxE,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,uCAAuC;IACvC,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAaD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EAAE,SAAS,EAChB,YAAiB,EACjB,aAAa,EACb,QAAe,EACf,UAAU,EACV,IAAY,EACZ,YAAY,EAAE,SAA6B,EAC3C,GAAG,KAAK,EACT,EAAE,kBAAkB,2CAqFpB"}
|