zidane-gui 9.1.16 → 9.1.17
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/out/main/index.js +851 -59
- package/out/preload/index.mjs +31 -2
- package/out/renderer/assets/{43YPWK3Q-DqQmzBPu.js → 43YPWK3Q-1wyGHRhG.js} +8 -8
- package/out/renderer/assets/{45MVAN6X-CYP7xDN8.js → 45MVAN6X-CCX59Sl8.js} +7 -7
- package/out/renderer/assets/{46GJKBLZ-Co9yrG8W.js → 46GJKBLZ-BfO42B_T.js} +12 -12
- package/out/renderer/assets/{63WH7YNF-JjkWKCFV.js → 63WH7YNF-CML8-yHW.js} +10 -10
- package/out/renderer/assets/{6DDU7VKX-BbtUMWO4.js → 6DDU7VKX-CYg_yoLw.js} +8 -8
- package/out/renderer/assets/{CLQLV5VT-Ba6obVJu.js → CLQLV5VT-Bg0M-SGs.js} +8 -8
- package/out/renderer/assets/{CUSPXG5M-BeHLB3vL.js → CUSPXG5M-CsYKrsuv.js} +8 -8
- package/out/renderer/assets/{CodeEditor-DAvsCy4c.js → CodeEditor-mxUtgGJl.js} +5 -5
- package/out/renderer/assets/{ComposerEditor-CmebUdQf.js → ComposerEditor-CzlLgqm3.js} +6 -6
- package/out/renderer/assets/{D3L7O4X2-Bz5JjvM3.js → D3L7O4X2-DUIFiQQs.js} +6 -6
- package/out/renderer/assets/{D5TW5CPZ-COD7XA6N.js → D5TW5CPZ-B5G-YYi_.js} +1 -1
- package/out/renderer/assets/{DiffsTab-Cg5SMPpy.js → DiffsTab-DTkod12Z.js} +12 -12
- package/out/renderer/assets/{EGADTWYV-DnX4xYm9.js → EGADTWYV-C5ja_Lm2.js} +7 -7
- package/out/renderer/assets/{EOJSJZXM-C1MKUH-z.js → EOJSJZXM-Dda_vMqK.js} +10 -10
- package/out/renderer/assets/{EditorWorkers-BfFVQ69E.js → EditorWorkers-4yw3sh7s.js} +9 -8
- package/out/renderer/assets/{FileIcon-acads6Ac.js → FileIcon-DlpPG4Tv.js} +1 -1
- package/out/renderer/assets/{FilesTab-RbqMfCrC.js → FilesTab-DwqtloUX.js} +337 -36
- package/out/renderer/assets/{G2OEIG6X-Dtesfr7X.js → G2OEIG6X-8IWIlJoy.js} +7 -7
- package/out/renderer/assets/{GXJ2T77W-BkncFrMb.js → GXJ2T77W-K_AYpQU1.js} +8 -8
- package/out/renderer/assets/{HX3UMAK7-DyzWjT_c.js → HX3UMAK7-CXREbgl0.js} +7 -7
- package/out/renderer/assets/{IU7WZTP6-C4qRhHoM.js → IU7WZTP6-DxZaf96h.js} +1 -1
- package/out/renderer/assets/{J5J2NR2G-2GjekDt4.js → J5J2NR2G-DvD4FXRy.js} +6 -6
- package/out/renderer/assets/{JRCWTJEL-Dto8Fjzi.js → JRCWTJEL-Dl83Hlzn.js} +5 -5
- package/out/renderer/assets/{KHUP5TOH-DWatm9RV.js → KHUP5TOH-CsVBjKaO.js} +1 -1
- package/out/renderer/assets/{L74FQTH5-YWQWDmAR.js → L74FQTH5-DWSyibfN.js} +6 -6
- package/out/renderer/assets/{LAV4ZXOS-BDeemsOt.js → LAV4ZXOS-DCtpD44i.js} +8 -8
- package/out/renderer/assets/{LBIZYCRR-CuJZ9kCp.js → LBIZYCRR-DpNXkUqg.js} +9 -9
- package/out/renderer/assets/{LFFXNLRS-CYLYOq-d.js → LFFXNLRS-CfnB3vZl.js} +5 -5
- package/out/renderer/assets/{LLLWOAQD-B6r0O-b8.js → LLLWOAQD-BOJG2YQq.js} +1 -1
- package/out/renderer/assets/{LTYQZ5U5-C6Vwu29l.js → LTYQZ5U5-Dw9W0QpI.js} +8 -8
- package/out/renderer/assets/{NDSCUZ25-D49aLwGZ.js → NDSCUZ25-B7bWy0v0.js} +2 -2
- package/out/renderer/assets/{NMN3IKWL-CmFbUlVt.js → NMN3IKWL-YWUccb3M.js} +11 -11
- package/out/renderer/assets/{NMUA3R2D-BmYN27sp.js → NMUA3R2D-PM0msfx1.js} +9 -9
- package/out/renderer/assets/{NY5A6PPW-CFmWX6Y1.js → NY5A6PPW-BiV0tPIy.js} +5 -5
- package/out/renderer/assets/{OHJ2EJXK-BkSNlV9q.js → OHJ2EJXK-B1XaNGkt.js} +1 -1
- package/out/renderer/assets/{OU2GIT2H-Df8P_VMV.js → OU2GIT2H-CnRIS6XL.js} +6 -6
- package/out/renderer/assets/{PDMLSE6I-B1fxTWPk.js → PDMLSE6I-D2L4rd2W.js} +2 -2
- package/out/renderer/assets/{PJ7X32S5-jmIr_WuS.js → PJ7X32S5-BDIGjA8B.js} +7 -7
- package/out/renderer/assets/{RLLQ44NJ-Bk5ATCRc.js → RLLQ44NJ-Du6_4Ch9.js} +9 -9
- package/out/renderer/assets/{S6DWMCK5-ru17f61y.js → S6DWMCK5-BCek3BK9.js} +10 -10
- package/out/renderer/assets/{STIOTUT7-D3W8oemx.js → STIOTUT7-Di8tUtxD.js} +8 -8
- package/out/renderer/assets/{SXSLPWUD-BP8ObIM3.js → SXSLPWUD-CUkLp4Fg.js} +2 -2
- package/out/renderer/assets/{TR4WJQGX-DwQDLHm2.js → TR4WJQGX-DghxArE6.js} +1 -1
- package/out/renderer/assets/TranscriptViews-D-F4TCT7.js +28 -0
- package/out/renderer/assets/{UWRPUF3N-BefBSoyh.js → UWRPUF3N-qS1g5ho1.js} +1 -1
- package/out/renderer/assets/{VSWIZJ7B-QwUQICP_.js → VSWIZJ7B-BKZhRmsN.js} +1 -1
- package/out/renderer/assets/ViewBlock-BcCbp_nS.js +1536 -0
- package/out/renderer/assets/ViewCharts-DuQAWU2F.js +6350 -0
- package/out/renderer/assets/ViewCustom-D5CeSx32.js +240 -0
- package/out/renderer/assets/ViewExtension-q6W__eQm.js +74 -0
- package/out/renderer/assets/ViewInputs-BwIsKHHk.js +407 -0
- package/out/renderer/assets/ViewMcpApp-BJxpfIUe.js +607 -0
- package/out/renderer/assets/ViewTables-D7FxVTon.js +284 -0
- package/out/renderer/assets/{WM7NR6YK-CRccSJmx.js → WM7NR6YK-BCt1dKcj.js} +6 -6
- package/out/renderer/assets/{WXKV2YEK-AiJtxeS-.js → WXKV2YEK-C1EL6EKw.js} +5 -5
- package/out/renderer/assets/{XLHPVVFU-CISC9r_V.js → XLHPVVFU-BN2wXqoc.js} +1 -1
- package/out/renderer/assets/{YNX532HU-CY_1HOiG.js → YNX532HU-BtmHcbvF.js} +7 -7
- package/out/renderer/assets/{YUPSMAUO-Cv2Ryk3Q.js → YUPSMAUO-CyZdB_Cb.js} +1 -1
- package/out/renderer/assets/{ZFRCZTLK-xOx-Cqik.js → ZFRCZTLK-aAZ7jHr_.js} +8 -8
- package/out/renderer/assets/{ZZDR4CN3-CDsCY6PX.js → ZZDR4CN3-BdJdxId6.js} +6 -6
- package/out/renderer/assets/{core-Drnj1qQL.js → core-CPNc3zNs.js} +1 -1
- package/out/renderer/assets/{core-Cst33ux7.js → core-CZ6gd8oJ.js} +2414 -435
- package/out/renderer/assets/{file-tabs--M9K6eWf.js → file-tabs-CgISplTF.js} +10 -9
- package/out/renderer/assets/ghostty-vt-CC3key_8.wasm +0 -0
- package/out/renderer/assets/{ghostty-web-DsF2lzXq.js → ghostty-web-DoJg8mwQ.js} +3 -3
- package/out/renderer/assets/{hastToHtml-AUrFnNH_.js → hastToHtml-Lx-c_BvK.js} +1 -1
- package/out/renderer/assets/heic-to-AUnw0rrk.js +57 -0
- package/out/renderer/assets/{highlights-BWQ-BGwF.js → highlights-BkRUNyAa.js} +7 -7
- package/out/renderer/assets/{highlights-D9DV-gLr.js → highlights-DqzA57PQ.js} +4 -4
- package/out/renderer/assets/{index-DcoAavzj.js → index-2ScxmF2I.js} +336 -195
- package/out/renderer/assets/{index-DhpOdP7M.js → index-CF84dbuf.js} +1 -1
- package/out/renderer/assets/input-preview-DTTTULd2.js +5 -0
- package/out/renderer/assets/{kit-BRekmBoz.js → kit-CjkT3Ius.js} +10084 -6109
- package/out/renderer/assets/{langs-CC8eNbvY.js → langs-CDfkqznm.js} +3 -3
- package/out/renderer/assets/{lazy-DtE8TmIe.js → lazy-BrSdiwQa.js} +3 -3
- package/out/renderer/assets/{loader-BWgWjzVT.js → loader-D2zAtI-u.js} +3 -3
- package/out/renderer/assets/{pierre-theme-DkKyEYzW.js → pierre-theme-BuOZsexm.js} +9 -9
- package/out/renderer/assets/{shiki-CahOMWmD.js → shiki-Dfvytwwf.js} +8 -8
- package/out/renderer/assets/{stream-tokenizer-CtslDDLQ.js → stream-tokenizer-BVf54Cm5.js} +2 -2
- package/out/renderer/assets/{index-C5y0Nb6N.css → styles-BsuQ5hRd.css} +641 -20
- package/out/renderer/assets/theme-watch-0b-hqR9T.js +37 -0
- package/out/renderer/assets/{themes-BVPDzAaq.js → themes-DByaI0Ud.js} +6 -6
- package/out/renderer/assets/{useDetachCleanup-1eMIugni.js → useDetachCleanup-Dn-cfZgC.js} +4 -4
- package/out/renderer/assets/{useFolderChanges-Cqv3OcO_.js → useFolderChanges-Dh2Z47jL.js} +10 -8
- package/out/renderer/assets/{vendor-BpwX-s_O.js → vendor-CadCDYU0.js} +1 -1
- package/out/renderer/assets/{vendor-editor-Cx3SvGyZ.js → vendor-editor-BJIeGzeh.js} +2 -2
- package/out/renderer/assets/{vendor-motion-BgQeucLF.js → vendor-motion-u3N9isCo.js} +1 -1
- package/out/renderer/assets/{vendor-react-bPTwWURR.js → vendor-react-BSxSjatM.js} +5 -4
- package/out/renderer/assets/view-preview-B7F51KZx.js +375 -0
- package/out/renderer/assets/zoom-reset-BfXcQTFh.js +13 -0
- package/out/renderer/index.html +8 -8
- package/out/renderer/view-preview.html +23 -0
- package/package.json +2 -2
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
import { r as reactExports, j as jsxRuntimeExports } from "./vendor-react-BSxSjatM.js";
|
|
2
|
+
import { eB as nodePathOf } from "./core-CZ6gd8oJ.js";
|
|
3
|
+
import { h as useViewsLabels, K as useViewsInputs, o as buttonClass, u as useViewsHost, M as useOptionalChatHost, O as useViewAnswer, P as viewAnswerKey, Q as Checkbox, S as ChoiceCards, U as FIELD_LABEL_CLASS, V as TEXTAREA_CLASS, W as INPUT_CLASS, N as Notice } from "./kit-CjkT3Ius.js";
|
|
4
|
+
import { s as str, b as arr } from "./ViewBlock-BcCbp_nS.js";
|
|
5
|
+
import { V as ViewInputsPreviewContext } from "./input-preview-DTTTULd2.js";
|
|
6
|
+
import "./vendor-CadCDYU0.js";
|
|
7
|
+
import "./vendor-motion-u3N9isCo.js";
|
|
8
|
+
import "./vendor-editor-BJIeGzeh.js";
|
|
9
|
+
function isTrustedEvent(event) {
|
|
10
|
+
return event.isTrusted === true;
|
|
11
|
+
}
|
|
12
|
+
function optionsOf(p) {
|
|
13
|
+
return arr(p.options).map((option) => {
|
|
14
|
+
if (option && typeof option === "object" && !Array.isArray(option)) {
|
|
15
|
+
const label2 = str(option.label) ?? "";
|
|
16
|
+
const description = str(option.description);
|
|
17
|
+
const category = str(option.category);
|
|
18
|
+
return {
|
|
19
|
+
label: label2,
|
|
20
|
+
value: str(option.value) ?? label2,
|
|
21
|
+
...description ? { description } : {},
|
|
22
|
+
...category ? { category } : {}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const label = str(option) ?? "";
|
|
26
|
+
return { label, value: label };
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const FIELD_TYPES = ["text", "textarea", "number", "select", "checkbox", "date"];
|
|
30
|
+
const SECRET_FIELD = /password|passphrase|secret|api[\s_-]?key|token|credential/i;
|
|
31
|
+
function fieldsOf(p) {
|
|
32
|
+
return arr(p.fields).flatMap((field) => {
|
|
33
|
+
if (!field || typeof field !== "object" || Array.isArray(field)) return [];
|
|
34
|
+
const name = str(field.name) ?? "";
|
|
35
|
+
const label = str(field.label) ?? name;
|
|
36
|
+
if (!name || SECRET_FIELD.test(name) || SECRET_FIELD.test(label)) return [];
|
|
37
|
+
const type = FIELD_TYPES.find((t) => t === field.type) ?? "text";
|
|
38
|
+
const fallback = field.default;
|
|
39
|
+
const initial = type === "checkbox" ? fallback === true : typeof fallback === "string" || typeof fallback === "number" ? String(fallback) : "";
|
|
40
|
+
const placeholder = str(field.placeholder);
|
|
41
|
+
return [
|
|
42
|
+
{
|
|
43
|
+
name,
|
|
44
|
+
label,
|
|
45
|
+
type,
|
|
46
|
+
options: arr(field.options).flatMap((o) => typeof o === "string" ? [o] : []),
|
|
47
|
+
...placeholder ? { placeholder } : {},
|
|
48
|
+
required: field.required === true,
|
|
49
|
+
initial
|
|
50
|
+
}
|
|
51
|
+
];
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function choiceColumns(count) {
|
|
55
|
+
return count <= 3 ? Math.max(1, count) : count === 4 ? 2 : 3;
|
|
56
|
+
}
|
|
57
|
+
function choiceGrid(count) {
|
|
58
|
+
const columns = choiceColumns(count);
|
|
59
|
+
return {
|
|
60
|
+
display: "grid",
|
|
61
|
+
gridTemplateColumns: `repeat(auto-fit, minmax(min(100%, max(12rem, calc(100% / ${columns} - 1rem))), 1fr))`
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function StaticInput({ node, note }) {
|
|
65
|
+
const p = node.props;
|
|
66
|
+
const off = /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-zg-label text-[var(--zg-text-muted)]", children: note });
|
|
67
|
+
if (node.type === "Action")
|
|
68
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
69
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", disabled: true, className: buttonClass({ size: "sm" }), children: str(p.label) }),
|
|
70
|
+
off
|
|
71
|
+
] });
|
|
72
|
+
if (node.type === "Choice") {
|
|
73
|
+
const options = optionsOf(p);
|
|
74
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
75
|
+
str(p.prompt) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-zg-ui", children: str(p.prompt) }) : null,
|
|
76
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
77
|
+
"ul",
|
|
78
|
+
{
|
|
79
|
+
className: "m-0 p-0 list-none gap-2",
|
|
80
|
+
style: choiceGrid(options.length),
|
|
81
|
+
"data-zg-choice-grid": choiceColumns(options.length),
|
|
82
|
+
children: options.map((option, i) => /* @__PURE__ */ jsxRuntimeExports.jsxs("li", { className: "zg-raised border rounded-zg-md px-2.5 py-1.5 text-zg-ui min-w-0", children: [
|
|
83
|
+
option.label,
|
|
84
|
+
option.description ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "block text-zg-label text-[var(--zg-text-muted)]", children: option.description }) : null
|
|
85
|
+
] }, i))
|
|
86
|
+
}
|
|
87
|
+
),
|
|
88
|
+
off
|
|
89
|
+
] });
|
|
90
|
+
}
|
|
91
|
+
const fields = arr(p.fields).flatMap(
|
|
92
|
+
(field) => field && typeof field === "object" && !Array.isArray(field) ? [{ label: str(field.label) ?? "", hint: str(field.placeholder) }] : []
|
|
93
|
+
);
|
|
94
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
95
|
+
str(p.title) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-zg-ui font-medium", children: str(p.title) }) : null,
|
|
96
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("dl", { className: "m-0 grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1 text-zg-ui", children: fields.map((field, i) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "contents", children: [
|
|
97
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("dt", { className: "text-[var(--zg-text-muted)]", children: field.label }),
|
|
98
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("dd", { className: "m-0 text-zg-label text-[var(--zg-text-muted)]", children: field.hint ?? "" })
|
|
99
|
+
] }, i)) }),
|
|
100
|
+
off
|
|
101
|
+
] });
|
|
102
|
+
}
|
|
103
|
+
function useInputAnswer(node, scope) {
|
|
104
|
+
const chat = useOptionalChatHost();
|
|
105
|
+
const path = reactExports.useMemo(() => scope ? nodePathOf(scope.tree, node) : void 0, [scope, node]);
|
|
106
|
+
const answer = useViewAnswer(scope && path ? viewAnswerKey(scope.viewId, path) : null);
|
|
107
|
+
const [state, setState] = reactExports.useState("idle");
|
|
108
|
+
const done = state === "sent" || answer !== void 0;
|
|
109
|
+
const send = async (kind, text, value) => {
|
|
110
|
+
if (!scope || !path || !chat?.send || done || state === "sending" || !text.trim()) return;
|
|
111
|
+
setState("sending");
|
|
112
|
+
const view = { sessionId: scope.sessionId, viewId: scope.viewId, nodePath: path, kind, value };
|
|
113
|
+
try {
|
|
114
|
+
await chat.send({
|
|
115
|
+
sessionId: scope.sessionId,
|
|
116
|
+
prompt: text,
|
|
117
|
+
origin: { kind: "user", source: "view", view },
|
|
118
|
+
literal: true,
|
|
119
|
+
keepDraft: true,
|
|
120
|
+
delivery: "queue"
|
|
121
|
+
});
|
|
122
|
+
setState("sent");
|
|
123
|
+
} catch {
|
|
124
|
+
setState("failed");
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
return { scope, path, answer, state, setState, done, send, canSend: Boolean(scope && path && chat?.send) };
|
|
128
|
+
}
|
|
129
|
+
function Status({ input, extra }) {
|
|
130
|
+
const labels = useViewsLabels();
|
|
131
|
+
if (input.done) return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-zg-label text-[var(--zg-text-muted)]", children: labels.viewInputsSent });
|
|
132
|
+
if (input.state === "failed")
|
|
133
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Notice, { tone: "error", compact: true, children: labels.viewInputsFailed });
|
|
134
|
+
return extra ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: extra }) : null;
|
|
135
|
+
}
|
|
136
|
+
function pickedValues(answer) {
|
|
137
|
+
const value = answer?.value;
|
|
138
|
+
if (typeof value === "string") return [value];
|
|
139
|
+
return Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
|
|
140
|
+
}
|
|
141
|
+
function ChoiceInput({ node, input }) {
|
|
142
|
+
const labels = useViewsLabels();
|
|
143
|
+
const p = node.props;
|
|
144
|
+
const options = reactExports.useMemo(() => optionsOf(p), [p]);
|
|
145
|
+
const multiple = p.multiple === true;
|
|
146
|
+
const [picked, setPicked] = reactExports.useState([]);
|
|
147
|
+
const answered = input.answer ? pickedValues(input.answer) : null;
|
|
148
|
+
const shown = answered ? options.flatMap((option, i) => answered.includes(option.value) ? [i] : []) : picked;
|
|
149
|
+
const locked = input.done || input.state === "sending";
|
|
150
|
+
const prompt = str(p.prompt);
|
|
151
|
+
const onSend = (event) => {
|
|
152
|
+
if (!isTrustedEvent(event.nativeEvent) || picked.length === 0) return;
|
|
153
|
+
const chosen = picked.flatMap((i) => options[i] ? [options[i]] : []);
|
|
154
|
+
const text = chosen.map((option) => option.label).join(", ");
|
|
155
|
+
void input.send("choice", text, multiple ? chosen.map((option) => option.value) : chosen[0].value);
|
|
156
|
+
};
|
|
157
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", "data-zg-view-input": "choice", children: [
|
|
158
|
+
prompt ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-zg-ui", children: prompt }) : null,
|
|
159
|
+
input.done ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
160
|
+
"ul",
|
|
161
|
+
{
|
|
162
|
+
className: "m-0 p-0 list-none gap-2",
|
|
163
|
+
style: choiceGrid(options.length),
|
|
164
|
+
"data-zg-choice-grid": choiceColumns(options.length),
|
|
165
|
+
"aria-label": prompt ?? labels.viewChoiceOptions,
|
|
166
|
+
children: options.map((option, i) => {
|
|
167
|
+
const on = shown.includes(i);
|
|
168
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
169
|
+
"li",
|
|
170
|
+
{
|
|
171
|
+
"data-picked": on ? "" : void 0,
|
|
172
|
+
"aria-current": on ? "true" : void 0,
|
|
173
|
+
className: `flex items-center gap-2 rounded-zg-md px-2 py-1 text-zg-ui border ${on ? "zg-raised ring-1 ring-[color-mix(in_srgb,var(--zg-accent)_55%,transparent)] text-[var(--zg-text)]" : "border-transparent text-[var(--zg-text-muted)]"}`,
|
|
174
|
+
children: [
|
|
175
|
+
option.label,
|
|
176
|
+
on ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { "aria-hidden": true, className: "i-ph-check-bold text-[var(--zg-accent)]" }) : null
|
|
177
|
+
]
|
|
178
|
+
},
|
|
179
|
+
i
|
|
180
|
+
);
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
) : multiple ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { role: "group", "aria-label": prompt ?? labels.viewChoiceOptions, className: "flex flex-col gap-1", children: options.map((option, i) => {
|
|
184
|
+
const on = shown.includes(i);
|
|
185
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
186
|
+
"button",
|
|
187
|
+
{
|
|
188
|
+
type: "button",
|
|
189
|
+
role: "checkbox",
|
|
190
|
+
"aria-checked": on,
|
|
191
|
+
disabled: locked,
|
|
192
|
+
onClick: () => setPicked((now) => now.includes(i) ? now.filter((n) => n !== i) : [...now, i]),
|
|
193
|
+
className: "zg-press-subtle flex items-start gap-2 text-left px-2 py-1.5 rounded-zg-md bg-transparent border-0 cursor-pointer text-[var(--zg-text)] hover:before:bg-[var(--zg-row-hover)] disabled:cursor-default disabled:opacity-zg-disabled zg-focus-ring",
|
|
194
|
+
children: [
|
|
195
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Checkbox, { checked: on }),
|
|
196
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex flex-col min-w-0", children: [
|
|
197
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-zg-ui", children: option.label }),
|
|
198
|
+
option.description ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-zg-label text-[var(--zg-text-muted)]", children: option.description }) : null
|
|
199
|
+
] })
|
|
200
|
+
]
|
|
201
|
+
},
|
|
202
|
+
i
|
|
203
|
+
);
|
|
204
|
+
}) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
205
|
+
ChoiceCards,
|
|
206
|
+
{
|
|
207
|
+
value: shown[0] !== void 0 ? String(shown[0]) : void 0,
|
|
208
|
+
onChange: (value) => {
|
|
209
|
+
if (!locked) setPicked([Number(value)]);
|
|
210
|
+
},
|
|
211
|
+
options: options.map((option, i) => ({
|
|
212
|
+
value: String(i),
|
|
213
|
+
title: option.label,
|
|
214
|
+
...option.description ? { description: option.description } : {},
|
|
215
|
+
...option.category ? { category: option.category } : {}
|
|
216
|
+
})),
|
|
217
|
+
strong: true,
|
|
218
|
+
inTray: true,
|
|
219
|
+
style: choiceGrid(options.length),
|
|
220
|
+
ariaLabel: prompt ?? labels.viewChoiceOptions
|
|
221
|
+
}
|
|
222
|
+
),
|
|
223
|
+
input.done ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
224
|
+
"button",
|
|
225
|
+
{
|
|
226
|
+
type: "button",
|
|
227
|
+
disabled: picked.length === 0 || locked,
|
|
228
|
+
onClick: onSend,
|
|
229
|
+
className: buttonClass({ variant: "primary", size: "sm" }),
|
|
230
|
+
children: input.state === "sending" ? labels.viewInputsSending : labels.viewInputsSend
|
|
231
|
+
}
|
|
232
|
+
) }),
|
|
233
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Status, { input })
|
|
234
|
+
] });
|
|
235
|
+
}
|
|
236
|
+
function FormInput({ node, input }) {
|
|
237
|
+
const labels = useViewsLabels();
|
|
238
|
+
const p = node.props;
|
|
239
|
+
const fields = reactExports.useMemo(() => fieldsOf(p), [p]);
|
|
240
|
+
const [values, setValues] = reactExports.useState(
|
|
241
|
+
() => Object.fromEntries(fields.map((field) => [field.name, field.initial]))
|
|
242
|
+
);
|
|
243
|
+
const answered = input.answer?.value;
|
|
244
|
+
const shown = answered && typeof answered === "object" && !Array.isArray(answered) ? Object.fromEntries(
|
|
245
|
+
fields.map((field) => {
|
|
246
|
+
const v = answered[field.name];
|
|
247
|
+
return [
|
|
248
|
+
field.name,
|
|
249
|
+
field.type === "checkbox" ? v === true : v === void 0 || v === null ? "" : String(v)
|
|
250
|
+
];
|
|
251
|
+
})
|
|
252
|
+
) : values;
|
|
253
|
+
const locked = input.done || input.state === "sending";
|
|
254
|
+
const title = str(p.title);
|
|
255
|
+
const set = (name, value) => setValues((now) => ({ ...now, [name]: value }));
|
|
256
|
+
const onSubmit = (event) => {
|
|
257
|
+
event.preventDefault();
|
|
258
|
+
if (!isTrustedEvent(event.nativeEvent) || locked) return;
|
|
259
|
+
const value = {};
|
|
260
|
+
const lines = title ? [title] : [];
|
|
261
|
+
for (const field of fields) {
|
|
262
|
+
const raw = values[field.name];
|
|
263
|
+
if (field.type === "checkbox") {
|
|
264
|
+
value[field.name] = raw === true;
|
|
265
|
+
lines.push(`${field.label}: ${raw === true ? labels.viewFormYes : labels.viewFormNo}`);
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
const text = typeof raw === "string" ? raw.trim() : "";
|
|
269
|
+
if (!text) continue;
|
|
270
|
+
const number = field.type === "number" ? Number(text) : NaN;
|
|
271
|
+
value[field.name] = field.type === "number" && Number.isFinite(number) ? number : text;
|
|
272
|
+
lines.push(`${field.label}: ${text}`);
|
|
273
|
+
}
|
|
274
|
+
void input.send("form", lines.join("\n"), value);
|
|
275
|
+
};
|
|
276
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { className: "flex flex-col gap-3", onSubmit, "data-zg-view-input": "form", children: [
|
|
277
|
+
title ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-zg-ui font-medium", children: title }) : null,
|
|
278
|
+
fields.map((field) => {
|
|
279
|
+
const value = shown[field.name];
|
|
280
|
+
if (field.type === "checkbox")
|
|
281
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center gap-2 text-zg-ui cursor-pointer", children: [
|
|
282
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
283
|
+
"input",
|
|
284
|
+
{
|
|
285
|
+
type: "checkbox",
|
|
286
|
+
name: field.name,
|
|
287
|
+
checked: value === true,
|
|
288
|
+
disabled: locked,
|
|
289
|
+
onChange: (e) => set(field.name, e.target.checked),
|
|
290
|
+
className: "zg-focus-ring"
|
|
291
|
+
}
|
|
292
|
+
),
|
|
293
|
+
field.label
|
|
294
|
+
] }, field.name);
|
|
295
|
+
const common = {
|
|
296
|
+
name: field.name,
|
|
297
|
+
value: typeof value === "string" ? value : "",
|
|
298
|
+
disabled: locked,
|
|
299
|
+
required: field.required,
|
|
300
|
+
...field.placeholder ? { placeholder: field.placeholder } : {}
|
|
301
|
+
};
|
|
302
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "block", children: [
|
|
303
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: FIELD_LABEL_CLASS, children: field.label }),
|
|
304
|
+
field.type === "textarea" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
305
|
+
"textarea",
|
|
306
|
+
{
|
|
307
|
+
...common,
|
|
308
|
+
rows: 3,
|
|
309
|
+
className: TEXTAREA_CLASS,
|
|
310
|
+
onChange: (e) => set(field.name, e.target.value)
|
|
311
|
+
}
|
|
312
|
+
) : field.type === "select" ? /* @__PURE__ */ jsxRuntimeExports.jsxs("select", { ...common, className: INPUT_CLASS, onChange: (e) => set(field.name, e.target.value), children: [
|
|
313
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "" }),
|
|
314
|
+
field.options.map((option) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: option, children: option }, option))
|
|
315
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
316
|
+
"input",
|
|
317
|
+
{
|
|
318
|
+
...common,
|
|
319
|
+
type: field.type,
|
|
320
|
+
className: INPUT_CLASS,
|
|
321
|
+
onChange: (e) => set(field.name, e.target.value)
|
|
322
|
+
}
|
|
323
|
+
)
|
|
324
|
+
] }, field.name);
|
|
325
|
+
}),
|
|
326
|
+
input.done ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "submit", disabled: locked, className: buttonClass({ variant: "primary", size: "sm" }), children: input.state === "sending" ? labels.viewInputsSending : str(p.submitLabel) ?? labels.viewInputsSend }) }),
|
|
327
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Status, { input })
|
|
328
|
+
] });
|
|
329
|
+
}
|
|
330
|
+
const TONE = { primary: "primary", danger: "danger", default: "secondary" };
|
|
331
|
+
function ActionInput({ node, input }) {
|
|
332
|
+
const labels = useViewsLabels();
|
|
333
|
+
const host = useViewsHost();
|
|
334
|
+
const p = node.props;
|
|
335
|
+
const label = str(p.label) ?? "";
|
|
336
|
+
const tool = str(p.tool);
|
|
337
|
+
const message = str(p.message);
|
|
338
|
+
const text = message && message !== label ? message : label;
|
|
339
|
+
const [action, setAction] = reactExports.useState("idle");
|
|
340
|
+
const runAction = host?.runAction;
|
|
341
|
+
const locked = input.done || input.state === "sending" || action === "waiting";
|
|
342
|
+
const onClick = async (event) => {
|
|
343
|
+
if (!isTrustedEvent(event.nativeEvent) || locked) return;
|
|
344
|
+
if (!tool) {
|
|
345
|
+
void input.send("action", text, { label });
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
const { scope, path } = input;
|
|
349
|
+
if (!scope || !path || !runAction) return;
|
|
350
|
+
setAction("waiting");
|
|
351
|
+
const result = await runAction(scope.sessionId, scope.viewId, path, scope.original);
|
|
352
|
+
if (!result.ok || result.value === "missing") setAction("failed");
|
|
353
|
+
else if (result.value === "denied") setAction("denied");
|
|
354
|
+
else if (result.value === "approved") {
|
|
355
|
+
setAction("idle");
|
|
356
|
+
input.setState("sent");
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", "data-zg-view-input": "action", children: [
|
|
360
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [
|
|
361
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
362
|
+
"button",
|
|
363
|
+
{
|
|
364
|
+
type: "button",
|
|
365
|
+
disabled: locked,
|
|
366
|
+
onClick: (e) => void onClick(e),
|
|
367
|
+
className: buttonClass({ variant: TONE[str(p.tone) ?? "default"] ?? "secondary", size: "sm" }),
|
|
368
|
+
children: label
|
|
369
|
+
}
|
|
370
|
+
),
|
|
371
|
+
tool ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-zg-label text-[var(--zg-text-muted)]", children: labels.viewActionRuns(tool) }) : text !== label ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-zg-label text-[var(--zg-text-muted)]", children: labels.viewActionSends(text) }) : null
|
|
372
|
+
] }),
|
|
373
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
374
|
+
Status,
|
|
375
|
+
{
|
|
376
|
+
input,
|
|
377
|
+
extra: action === "waiting" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-zg-label text-[var(--zg-text-muted)]", children: labels.viewActionWaiting }) : action === "denied" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-zg-label text-[var(--zg-text-muted)]", children: labels.viewActionDenied }) : action === "failed" ? /* @__PURE__ */ jsxRuntimeExports.jsx(Notice, { tone: "error", compact: true, children: labels.viewActionFailed }) : null
|
|
378
|
+
}
|
|
379
|
+
)
|
|
380
|
+
] });
|
|
381
|
+
}
|
|
382
|
+
function LiveInput({ node, scope }) {
|
|
383
|
+
const labels = useViewsLabels();
|
|
384
|
+
const host = useViewsHost();
|
|
385
|
+
const input = useInputAnswer(node, scope);
|
|
386
|
+
const preview = reactExports.useContext(ViewInputsPreviewContext);
|
|
387
|
+
if (preview)
|
|
388
|
+
return node.type === "Choice" ? /* @__PURE__ */ jsxRuntimeExports.jsx(ChoiceInput, { node, input }) : node.type === "Form" ? /* @__PURE__ */ jsxRuntimeExports.jsx(FormInput, { node, input }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ActionInput, { node, input });
|
|
389
|
+
if (!scope || !input.path) return /* @__PURE__ */ jsxRuntimeExports.jsx(StaticInput, { node, note: labels.viewInputsPending });
|
|
390
|
+
const needsHost = node.type === "Action" && typeof node.props.tool === "string" && node.props.tool !== "";
|
|
391
|
+
if (needsHost ? !host?.runAction : !input.canSend)
|
|
392
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(StaticInput, { node, note: labels.viewInputsUnsupported });
|
|
393
|
+
if (node.type === "Choice") return /* @__PURE__ */ jsxRuntimeExports.jsx(ChoiceInput, { node, input });
|
|
394
|
+
if (node.type === "Form") return /* @__PURE__ */ jsxRuntimeExports.jsx(FormInput, { node, input });
|
|
395
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(ActionInput, { node, input });
|
|
396
|
+
}
|
|
397
|
+
const ViewInput = reactExports.memo(function ViewInput2({ node, scope = null }) {
|
|
398
|
+
const labels = useViewsLabels();
|
|
399
|
+
const inputs = useViewsInputs();
|
|
400
|
+
const preview = reactExports.useContext(ViewInputsPreviewContext);
|
|
401
|
+
if (!inputs && !preview) return /* @__PURE__ */ jsxRuntimeExports.jsx(StaticInput, { node, note: labels.viewInputsOff });
|
|
402
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(LiveInput, { node, scope });
|
|
403
|
+
});
|
|
404
|
+
export {
|
|
405
|
+
ViewInput,
|
|
406
|
+
choiceColumns
|
|
407
|
+
};
|