reifyui 0.8.2 → 0.8.4
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 +6 -0
- package/dist/harness.cjs +34 -25
- package/dist/harness.cjs.map +1 -1
- package/dist/harness.js +34 -25
- package/dist/harness.js.map +1 -1
- package/dist/index.cjs +187 -112
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +187 -112
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/src/components/ChatPanel.jsx +39 -4
- package/src/harness/index.js +31 -18
- package/src/index.d.ts +2 -0
- package/src/sheet/SheetGrid.jsx +70 -13
- package/styles/sheet.css +38 -18
package/dist/index.cjs
CHANGED
|
@@ -937,6 +937,7 @@ function ChatPanel(props) {
|
|
|
937
937
|
const [draft, setDraft] = (0, import_react7.useState)("");
|
|
938
938
|
const [busy, setBusy] = (0, import_react7.useState)(false);
|
|
939
939
|
const [connecting, setConnecting] = (0, import_react7.useState)(false);
|
|
940
|
+
const [dropped, setDropped] = (0, import_react7.useState)(false);
|
|
940
941
|
const [histLoading, setHistLoading] = (0, import_react7.useState)(true);
|
|
941
942
|
const [staged, setStaged] = (0, import_react7.useState)([]);
|
|
942
943
|
const [attachErr, setAttachErr] = (0, import_react7.useState)("");
|
|
@@ -1008,12 +1009,18 @@ function ChatPanel(props) {
|
|
|
1008
1009
|
}
|
|
1009
1010
|
pendingRef.current = null;
|
|
1010
1011
|
setConnecting(false);
|
|
1012
|
+
if (out.dropped) {
|
|
1013
|
+
setDropped(true);
|
|
1014
|
+
return;
|
|
1015
|
+
}
|
|
1011
1016
|
updateLastAsst((a) => a.status === "running" ? { ...a, status: "done" } : a);
|
|
1012
1017
|
api.current.onChanged?.();
|
|
1013
|
-
} catch {
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1018
|
+
} catch (e) {
|
|
1019
|
+
updateLastAsst((a) => ({
|
|
1020
|
+
...a,
|
|
1021
|
+
blocks: a.blocks.length ? a.blocks : withText([], e && e.message || "The turn could not be started."),
|
|
1022
|
+
status: "failed"
|
|
1023
|
+
}));
|
|
1017
1024
|
} finally {
|
|
1018
1025
|
setBusy(false);
|
|
1019
1026
|
}
|
|
@@ -1075,6 +1082,26 @@ function ChatPanel(props) {
|
|
|
1075
1082
|
}, RETRY_MS);
|
|
1076
1083
|
return () => window.clearInterval(iv);
|
|
1077
1084
|
}, [connecting, busy, deliver]);
|
|
1085
|
+
(0, import_react7.useEffect)(() => {
|
|
1086
|
+
if (!dropped) return void 0;
|
|
1087
|
+
let dead = false;
|
|
1088
|
+
const tick = () => Promise.resolve(api.current.loadHistory(sessionId)).then((hist) => {
|
|
1089
|
+
if (dead || !hist?.length) return;
|
|
1090
|
+
const last = hist[hist.length - 1];
|
|
1091
|
+
const settled = !(last.role === "assistant" && last.status === "running") && !externalBusy;
|
|
1092
|
+
setMessages(hist);
|
|
1093
|
+
if (settled) {
|
|
1094
|
+
setDropped(false);
|
|
1095
|
+
api.current.onChanged?.();
|
|
1096
|
+
}
|
|
1097
|
+
}).catch(() => {
|
|
1098
|
+
});
|
|
1099
|
+
const iv = window.setInterval(tick, POLL_MS);
|
|
1100
|
+
return () => {
|
|
1101
|
+
dead = true;
|
|
1102
|
+
window.clearInterval(iv);
|
|
1103
|
+
};
|
|
1104
|
+
}, [dropped, externalBusy, sessionId]);
|
|
1078
1105
|
(0, import_react7.useEffect)(() => {
|
|
1079
1106
|
let dead = false;
|
|
1080
1107
|
let poll;
|
|
@@ -1186,7 +1213,8 @@ function ChatPanel(props) {
|
|
|
1186
1213
|
toggle,
|
|
1187
1214
|
title ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "uic-chat-title", title, children: title }) : null,
|
|
1188
1215
|
headerRight,
|
|
1189
|
-
connecting ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "uic-chat-conn", children: connectingLabel }) : null
|
|
1216
|
+
connecting ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "uic-chat-conn", children: connectingLabel }) : null,
|
|
1217
|
+
dropped ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "uic-chat-conn", children: workingLabel }) : null
|
|
1190
1218
|
] }),
|
|
1191
1219
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "uic-chat-body", ref: bodyRef, onScroll: onBodyScroll, role: "log", "aria-live": "polite", children: [
|
|
1192
1220
|
histLoading ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ChatMessagesSkeleton, {}) : empty && externalBusy ? busyState === void 0 ? defaultBusyState : busyState : empty ? emptyState : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
@@ -2329,6 +2357,9 @@ var COMPUTE_KINDS = [
|
|
|
2329
2357
|
];
|
|
2330
2358
|
var RESOURCE_KINDS = ["image", "sheet", "slides", "workflow", "graph"];
|
|
2331
2359
|
var RESOURCE_ICON = { image: "\u{1F5BC}", sheet: "\u25A6", slides: "\u25A4", workflow: "\u2699", graph: "\u25C9" };
|
|
2360
|
+
var POPOVER_EDITORS = /* @__PURE__ */ new Set(["select", "resource"]);
|
|
2361
|
+
var SINGLE_LINE_EDITORS = /* @__PURE__ */ new Set(["number", "date", "tags"]);
|
|
2362
|
+
var isMultiline = (col) => !SINGLE_LINE_EDITORS.has(col.type);
|
|
2332
2363
|
function PopPortal({ anchor, width = 250, estHeight = 300, className, children, onClose }) {
|
|
2333
2364
|
const boxRef = (0, import_react15.useRef)(null);
|
|
2334
2365
|
(0, import_react15.useEffect)(() => {
|
|
@@ -2501,6 +2532,7 @@ function SheetGrid({
|
|
|
2501
2532
|
document.body.style.cursor = "";
|
|
2502
2533
|
if (!d) return;
|
|
2503
2534
|
setSizeDraft({});
|
|
2535
|
+
if (d.last === d.start) return;
|
|
2504
2536
|
mutate((n) => {
|
|
2505
2537
|
if (d.kind === "col") {
|
|
2506
2538
|
const c = n.columns.find((x) => x.id === d.id);
|
|
@@ -2573,8 +2605,23 @@ function SheetGrid({
|
|
|
2573
2605
|
const numW = Math.max(48, 30 + String(rows.length || 1).length * 9);
|
|
2574
2606
|
const numStyle = { width: numW, minWidth: numW, maxWidth: numW };
|
|
2575
2607
|
const rowHeight = (row) => sizeDraft.row && sizeDraft.row[row.id] || row.height || void 0;
|
|
2608
|
+
const rowStyle = (row) => {
|
|
2609
|
+
const h = rowHeight(row);
|
|
2610
|
+
return {
|
|
2611
|
+
...h ? { height: h, "--shg-row-max": `${h - 1}px` } : null,
|
|
2612
|
+
// The grid's own text wraps and no longer reads this; it stays for host cell bodies that do.
|
|
2613
|
+
"--shg-clamp": Math.max(1, Math.floor(((h || 34) - 10) / 18))
|
|
2614
|
+
};
|
|
2615
|
+
};
|
|
2616
|
+
const fitRow = (rowId) => mutate((n) => {
|
|
2617
|
+
const r = n.rows.find((x) => x.id === rowId);
|
|
2618
|
+
if (r) delete r.height;
|
|
2619
|
+
});
|
|
2576
2620
|
(0, import_react15.useEffect)(() => {
|
|
2577
|
-
|
|
2621
|
+
const el = editing && inputRef.current;
|
|
2622
|
+
if (!el) return;
|
|
2623
|
+
el.focus();
|
|
2624
|
+
if (el.tagName === "TEXTAREA") el.setSelectionRange(el.value.length, el.value.length);
|
|
2578
2625
|
}, [editing]);
|
|
2579
2626
|
const mutate = (fn) => {
|
|
2580
2627
|
if (readOnly || !onChange) return;
|
|
@@ -2714,6 +2761,26 @@ function SheetGrid({
|
|
|
2714
2761
|
}
|
|
2715
2762
|
);
|
|
2716
2763
|
}
|
|
2764
|
+
if (isMultiline(col)) {
|
|
2765
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2766
|
+
"textarea",
|
|
2767
|
+
{
|
|
2768
|
+
ref: inputRef,
|
|
2769
|
+
className: "shg-input shg-input-area",
|
|
2770
|
+
value: draft,
|
|
2771
|
+
rows: 1,
|
|
2772
|
+
onChange: (e) => setDraft(e.target.value),
|
|
2773
|
+
onBlur: commitEdit,
|
|
2774
|
+
onKeyDown: (e) => {
|
|
2775
|
+
if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
|
|
2776
|
+
e.preventDefault();
|
|
2777
|
+
commitEdit();
|
|
2778
|
+
}
|
|
2779
|
+
if (e.key === "Escape") setEditing(null);
|
|
2780
|
+
}
|
|
2781
|
+
}
|
|
2782
|
+
);
|
|
2783
|
+
}
|
|
2717
2784
|
const inputType = col.type === "date" ? "date" : col.type === "number" ? "number" : "text";
|
|
2718
2785
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2719
2786
|
"input",
|
|
@@ -2772,114 +2839,122 @@ function SheetGrid({
|
|
|
2772
2839
|
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("th", { className: "shg-add-col", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { className: "shg-add", onClick: addColumn, title: "Add column", children: "+" }) })
|
|
2773
2840
|
] }) }),
|
|
2774
2841
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("tbody", { children: [
|
|
2775
|
-
rows.map((row, ri) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
"
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
style: numStyle,
|
|
2789
|
-
title: "Drag to reorder",
|
|
2790
|
-
...dndProps("row", row.id),
|
|
2791
|
-
children: [
|
|
2792
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: ri + 1 }),
|
|
2793
|
-
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { className: "shg-rowdel", onClick: () => deleteRow(row.id), title: "Delete row", children: "\xD7" }),
|
|
2794
|
-
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "shg-resize-row", onMouseDown: (e) => startResize(e, "row", row.id, rowHeight(row) || e.currentTarget.closest("tr").offsetHeight) })
|
|
2795
|
-
]
|
|
2796
|
-
}
|
|
2797
|
-
),
|
|
2798
|
-
columns.map((col) => {
|
|
2799
|
-
const c = cells[cellKey(row.id, col.id)] || {};
|
|
2800
|
-
const computed = isComputed(col);
|
|
2801
|
-
const isEditing = editing && editing.rowId === row.id && editing.colId === col.id;
|
|
2802
|
-
const peer = peerMarks && peerMarks[cellKey(row.id, col.id)];
|
|
2803
|
-
const custom = renderCell && renderCell({
|
|
2804
|
-
cell: c,
|
|
2805
|
-
column: col,
|
|
2806
|
-
row,
|
|
2807
|
-
rowIndex: ri,
|
|
2808
|
-
sheet,
|
|
2809
|
-
computed,
|
|
2810
|
-
width: colWidth(col),
|
|
2811
|
-
height: rowHeight(row),
|
|
2812
|
-
editing: !!isEditing,
|
|
2813
|
-
readOnly,
|
|
2814
|
-
setCell: (v) => setCell(row.id, col.id, v),
|
|
2815
|
-
runCell: onRunCell && !readOnly ? () => onRunCell(row.id, col.id) : null
|
|
2816
|
-
});
|
|
2817
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2818
|
-
"td",
|
|
2842
|
+
rows.map((row, ri) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("tr", { "data-row-id": row.id, style: rowStyle(row), children: [
|
|
2843
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2844
|
+
"td",
|
|
2845
|
+
{
|
|
2846
|
+
className: "shg-rownum" + dndClass("row", row.id),
|
|
2847
|
+
style: numStyle,
|
|
2848
|
+
title: "Drag to reorder",
|
|
2849
|
+
...dndProps("row", row.id),
|
|
2850
|
+
children: [
|
|
2851
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: ri + 1 }),
|
|
2852
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { className: "shg-rowdel", onClick: () => deleteRow(row.id), title: "Delete row", children: "\xD7" }),
|
|
2853
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2854
|
+
"span",
|
|
2819
2855
|
{
|
|
2820
|
-
"
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
}
|
|
2856
|
+
className: "shg-resize-row",
|
|
2857
|
+
title: "Drag to resize, double-click to fit",
|
|
2858
|
+
onMouseDown: (e) => startResize(e, "row", row.id, rowHeight(row) || e.currentTarget.closest("tr").offsetHeight),
|
|
2859
|
+
onDoubleClick: () => fitRow(row.id)
|
|
2860
|
+
}
|
|
2861
|
+
)
|
|
2862
|
+
]
|
|
2863
|
+
}
|
|
2864
|
+
),
|
|
2865
|
+
columns.map((col) => {
|
|
2866
|
+
const c = cells[cellKey(row.id, col.id)] || {};
|
|
2867
|
+
const computed = isComputed(col);
|
|
2868
|
+
const isEditing = editing && editing.rowId === row.id && editing.colId === col.id;
|
|
2869
|
+
const peer = peerMarks && peerMarks[cellKey(row.id, col.id)];
|
|
2870
|
+
const custom = renderCell && renderCell({
|
|
2871
|
+
cell: c,
|
|
2872
|
+
column: col,
|
|
2873
|
+
row,
|
|
2874
|
+
rowIndex: ri,
|
|
2875
|
+
sheet,
|
|
2876
|
+
computed,
|
|
2877
|
+
width: colWidth(col),
|
|
2878
|
+
height: rowHeight(row),
|
|
2879
|
+
editing: !!isEditing,
|
|
2880
|
+
readOnly,
|
|
2881
|
+
setCell: (v) => setCell(row.id, col.id, v),
|
|
2882
|
+
runCell: onRunCell && !readOnly ? () => onRunCell(row.id, col.id) : null
|
|
2883
|
+
});
|
|
2884
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2885
|
+
"td",
|
|
2886
|
+
{
|
|
2887
|
+
"data-col-id": col.id,
|
|
2888
|
+
className: "shg-cell" + (computed ? " shg-cell-compute" : "") + (c.status && computed ? ` shg-cell-${c.status}` : "") + (peer ? " shg-cell-peer" : ""),
|
|
2889
|
+
style: peer ? { boxShadow: `inset 0 0 0 2px ${peer.color}` } : void 0,
|
|
2890
|
+
onClick: (e) => {
|
|
2891
|
+
if (!isEditing) openEdit(row.id, col, e.currentTarget);
|
|
2892
|
+
},
|
|
2893
|
+
title: c.error || "",
|
|
2894
|
+
children: [
|
|
2895
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
2896
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2897
|
+
"span",
|
|
2898
|
+
{
|
|
2899
|
+
className: "shg-resize-col shg-resize-in-cell",
|
|
2900
|
+
onClick: (e) => e.stopPropagation(),
|
|
2901
|
+
onMouseDown: (e) => startResize(
|
|
2902
|
+
e,
|
|
2903
|
+
"col",
|
|
2904
|
+
col.id,
|
|
2905
|
+
colWidth(col) || e.currentTarget.closest("td").offsetWidth
|
|
2871
2906
|
)
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2907
|
+
}
|
|
2908
|
+
),
|
|
2909
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2910
|
+
"span",
|
|
2911
|
+
{
|
|
2912
|
+
className: "shg-resize-row shg-resize-in-cell",
|
|
2913
|
+
onClick: (e) => e.stopPropagation(),
|
|
2914
|
+
onMouseDown: (e) => startResize(
|
|
2915
|
+
e,
|
|
2916
|
+
"row",
|
|
2917
|
+
row.id,
|
|
2918
|
+
rowHeight(row) || e.currentTarget.closest("tr").offsetHeight
|
|
2919
|
+
),
|
|
2920
|
+
onDoubleClick: (e) => {
|
|
2921
|
+
e.stopPropagation();
|
|
2922
|
+
fitRow(row.id);
|
|
2923
|
+
}
|
|
2924
|
+
}
|
|
2925
|
+
)
|
|
2926
|
+
] }),
|
|
2927
|
+
peer && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "shg-peer-flag", style: { background: peer.color }, children: peer.name }),
|
|
2928
|
+
isEditing && renderEditor(col),
|
|
2929
|
+
isEditing && !POPOVER_EDITORS.has(col.type) ? (
|
|
2930
|
+
// The editor lies over the cell; this invisible copy of the draft holds the
|
|
2931
|
+
// cell's place, so the row keeps its height while you type and grows with
|
|
2932
|
+
// the draft, to the same cap as the value. The trailing zero-width space
|
|
2933
|
+
// gives a draft that ends in a line break its last, empty line.
|
|
2934
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "shg-val shg-val-mirror", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "shg-val-txt", children: `${typeof draft === "string" ? draft : ""}\u200B` }) })
|
|
2935
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "shg-val", children: custom !== void 0 ? custom : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
2936
|
+
computed && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(StatusDot, { status: c.status }),
|
|
2937
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CellValue, { cell: c, col, fetchBlobUrl, onOpenResource }),
|
|
2938
|
+
computed && !readOnly && onRunCell && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2939
|
+
"button",
|
|
2940
|
+
{
|
|
2941
|
+
className: "shg-runcell",
|
|
2942
|
+
title: "Run this cell",
|
|
2943
|
+
onClick: (e) => {
|
|
2944
|
+
e.stopPropagation();
|
|
2945
|
+
onRunCell(row.id, col.id);
|
|
2946
|
+
},
|
|
2947
|
+
children: "\u25B6"
|
|
2948
|
+
}
|
|
2949
|
+
)
|
|
2950
|
+
] }) })
|
|
2951
|
+
]
|
|
2952
|
+
},
|
|
2953
|
+
col.id
|
|
2954
|
+
);
|
|
2955
|
+
}),
|
|
2956
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("td", { className: "shg-pad" })
|
|
2957
|
+
] }, row.id)),
|
|
2883
2958
|
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("tr", { className: "shg-ghost-row", onClick: addRow, children: [
|
|
2884
2959
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("td", { className: "shg-rownum shg-ghost-num", style: numStyle, children: "+" }),
|
|
2885
2960
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("td", { className: "shg-ghost-cell", colSpan: columns.length + 1, children: "New row" })
|