reifyui 0.4.2 → 0.5.1

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/dist/index.cjs CHANGED
@@ -1741,18 +1741,23 @@ var import_react_dom2 = require("react-dom");
1741
1741
  var import_jsx_runtime11 = require("react/jsx-runtime");
1742
1742
  var cellKey = (rowId, colId) => `${rowId}:${colId}`;
1743
1743
  var uid = (p) => `${p}_${Math.random().toString(36).slice(2, 10)}`;
1744
- var TYPE_LABEL = {
1745
- text: "Text",
1746
- number: "Number",
1747
- select: "Select",
1748
- tags: "Tags",
1749
- checkbox: "Checkbox",
1750
- date: "Date",
1751
- url: "Link",
1752
- resource: "Resource",
1753
- compute: "Computed"
1754
- };
1755
- var MANUAL_TYPES = ["text", "number", "select", "tags", "checkbox", "date", "url", "resource"];
1744
+ var DEFAULT_COLUMN_TYPES = [
1745
+ { type: "text", label: "Text" },
1746
+ { type: "number", label: "Number" },
1747
+ { type: "select", label: "Select" },
1748
+ { type: "tags", label: "Tags" },
1749
+ { type: "checkbox", label: "Checkbox" },
1750
+ { type: "date", label: "Date" },
1751
+ { type: "url", label: "Link" },
1752
+ { type: "resource", label: "Resource" },
1753
+ {
1754
+ type: "compute",
1755
+ label: "Computed",
1756
+ computed: true,
1757
+ configKey: "compute",
1758
+ badge: (col) => col.compute?.kind
1759
+ }
1760
+ ];
1756
1761
  var COMPUTE_KINDS = [
1757
1762
  { kind: "prompt", label: "AI prompt" },
1758
1763
  { kind: "harness", label: "Agent (harness)" },
@@ -1762,22 +1767,30 @@ var COMPUTE_KINDS = [
1762
1767
  var RESOURCE_KINDS = ["image", "sheet", "slides", "workflow", "graph"];
1763
1768
  var RESOURCE_ICON = { image: "\u{1F5BC}", sheet: "\u25A6", slides: "\u25A4", workflow: "\u2699", graph: "\u25C9" };
1764
1769
  function PopPortal({ anchor, width = 250, estHeight = 300, className, children, onClose }) {
1770
+ const boxRef = (0, import_react12.useRef)(null);
1765
1771
  (0, import_react12.useEffect)(() => {
1766
1772
  if (!onClose) return void 0;
1767
1773
  const close = () => onClose();
1774
+ const onDown = (e) => {
1775
+ if (boxRef.current && boxRef.current.contains(e.target)) return;
1776
+ if (anchor && e.clientX >= anchor.left && e.clientX <= anchor.right && e.clientY >= anchor.top && e.clientY <= anchor.bottom) return;
1777
+ onClose();
1778
+ };
1779
+ window.addEventListener("mousedown", onDown);
1768
1780
  window.addEventListener("scroll", close, true);
1769
1781
  window.addEventListener("resize", close);
1770
1782
  return () => {
1783
+ window.removeEventListener("mousedown", onDown);
1771
1784
  window.removeEventListener("scroll", close, true);
1772
1785
  window.removeEventListener("resize", close);
1773
1786
  };
1774
- }, [onClose]);
1787
+ }, [onClose, anchor]);
1775
1788
  if (!anchor) return null;
1776
1789
  const left = Math.max(8, Math.min(anchor.right - width, window.innerWidth - width - 8));
1777
1790
  let top = anchor.bottom + 6;
1778
1791
  if (top + estHeight > window.innerHeight - 8) top = Math.max(8, anchor.top - estHeight - 6);
1779
1792
  return (0, import_react_dom2.createPortal)(
1780
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className, style: { position: "fixed", top, left, width, zIndex: 1e3 }, children }),
1793
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { ref: boxRef, className, style: { position: "fixed", top, left, width, zIndex: 1e3 }, children }),
1781
1794
  document.body
1782
1795
  );
1783
1796
  }
@@ -1869,7 +1882,20 @@ function CellValue({ cell, col, fetchBlobUrl, onOpenResource }) {
1869
1882
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-val-txt", children: typeof v === "object" ? JSON.stringify(v) : String(v) });
1870
1883
  }
1871
1884
  }
1872
- function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false, fetchBlobUrl, onOpenResource, peerMarks, onActiveCell }) {
1885
+ function SheetGrid({
1886
+ sheet,
1887
+ onChange,
1888
+ onRunCell,
1889
+ onRunColumn,
1890
+ readOnly = false,
1891
+ fetchBlobUrl,
1892
+ onOpenResource,
1893
+ peerMarks,
1894
+ onActiveCell,
1895
+ columnTypes = DEFAULT_COLUMN_TYPES,
1896
+ renderCell,
1897
+ renderColumnConfig
1898
+ }) {
1873
1899
  const columns = sheet?.columns || [];
1874
1900
  const rows = sheet?.rows || [];
1875
1901
  const cells = sheet?.cells || {};
@@ -1881,6 +1907,12 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
1881
1907
  const [dropAt, setDropAt] = (0, import_react12.useState)(null);
1882
1908
  const inputRef = (0, import_react12.useRef)(null);
1883
1909
  const dragRef = (0, import_react12.useRef)(null);
1910
+ const descOf = (type) => columnTypes.find((t) => t.type === type) || { type, label: type };
1911
+ const isComputed = (col) => !!descOf(col?.type).computed;
1912
+ const isEditable = (col) => {
1913
+ const d = descOf(col?.type);
1914
+ return d.editable ?? !d.computed;
1915
+ };
1884
1916
  const startResize = (e, kind, id, start) => {
1885
1917
  if (readOnly) return;
1886
1918
  e.preventDefault();
@@ -1986,11 +2018,14 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
1986
2018
  };
1987
2019
  const setCell = (rowId, colId, value) => mutate((n) => {
1988
2020
  n.cells = n.cells || {};
1989
- n.cells[cellKey(rowId, colId)] = { value, status: "done", updated_at: Math.floor(Date.now() / 1e3) };
2021
+ const k = cellKey(rowId, colId);
2022
+ const col = (n.columns || []).find((c) => c.id === colId);
2023
+ const prev = n.cells[k];
2024
+ n.cells[k] = isComputed(col) && prev ? { ...prev, value } : { value };
1990
2025
  });
1991
2026
  const openEdit = (rowId, col, anchorEl) => {
1992
2027
  if (readOnly) return;
1993
- if (col.type === "compute") return;
2028
+ if (!isEditable(col)) return;
1994
2029
  if (col.type === "checkbox") {
1995
2030
  const cur = cells[cellKey(rowId, col.id)];
1996
2031
  setCell(rowId, col.id, !(cur && cur.value));
@@ -2036,7 +2071,9 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
2036
2071
  const c = n.columns.find((x) => x.id === colId);
2037
2072
  if (!c) return;
2038
2073
  Object.assign(c, patch);
2039
- if (patch.type && patch.type !== "compute") delete c.compute;
2074
+ if (patch.type) {
2075
+ for (const d of columnTypes) if (d.configKey && d.type !== patch.type) delete c[d.configKey];
2076
+ }
2040
2077
  });
2041
2078
  const renderEditor = (col) => {
2042
2079
  if (col.type === "resource") {
@@ -2135,7 +2172,7 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
2135
2172
  columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2136
2173
  "th",
2137
2174
  {
2138
- className: "shg-col" + (col.type === "compute" ? " shg-col-compute" : "") + dndClass("col", col.id),
2175
+ className: "shg-col" + (isComputed(col) ? " shg-col-compute" : "") + dndClass("col", col.id),
2139
2176
  style: colWidth(col) ? { width: colWidth(col), minWidth: colWidth(col), maxWidth: colWidth(col) } : void 0,
2140
2177
  ...dndProps("col", col.id),
2141
2178
  children: [
@@ -2146,6 +2183,9 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
2146
2183
  col,
2147
2184
  columns,
2148
2185
  readOnly,
2186
+ desc: descOf(col.type),
2187
+ columnTypes,
2188
+ renderColumnConfig,
2149
2189
  menuOpen: menuCol?.id === col.id,
2150
2190
  menuAnchor: menuCol?.id === col.id ? menuCol.rect : null,
2151
2191
  onMenu: (e) => setMenuCol(menuCol?.id === col.id ? null : { id: col.id, rect: e.currentTarget.getBoundingClientRect() }),
@@ -2156,7 +2196,7 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
2156
2196
  setMenuCol(null);
2157
2197
  deleteColumn(col.id);
2158
2198
  },
2159
- onRun: col.type === "compute" && onRunColumn ? () => onRunColumn(col.id) : null
2199
+ onRun: isComputed(col) && onRunColumn ? () => onRunColumn(col.id) : null
2160
2200
  }
2161
2201
  ) })
2162
2202
  ]
@@ -2190,12 +2230,27 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
2190
2230
  ),
2191
2231
  columns.map((col) => {
2192
2232
  const c = cells[cellKey(row.id, col.id)] || {};
2233
+ const computed = isComputed(col);
2193
2234
  const isEditing = editing && editing.rowId === row.id && editing.colId === col.id;
2194
2235
  const peer = peerMarks && peerMarks[cellKey(row.id, col.id)];
2236
+ const custom = renderCell && renderCell({
2237
+ cell: c,
2238
+ column: col,
2239
+ row,
2240
+ rowIndex: ri,
2241
+ sheet,
2242
+ computed,
2243
+ width: colWidth(col),
2244
+ height: rowHeight(row),
2245
+ editing: !!isEditing,
2246
+ readOnly,
2247
+ setCell: (v) => setCell(row.id, col.id, v),
2248
+ runCell: onRunCell && !readOnly ? () => onRunCell(row.id, col.id) : null
2249
+ });
2195
2250
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2196
2251
  "td",
2197
2252
  {
2198
- className: "shg-cell" + (col.type === "compute" ? " shg-cell-compute" : "") + (c.status && col.type === "compute" ? ` shg-cell-${c.status}` : "") + (peer ? " shg-cell-peer" : ""),
2253
+ className: "shg-cell" + (computed ? " shg-cell-compute" : "") + (c.status && computed ? ` shg-cell-${c.status}` : "") + (peer ? " shg-cell-peer" : ""),
2199
2254
  style: peer ? { boxShadow: `inset 0 0 0 2px ${peer.color}` } : void 0,
2200
2255
  onClick: (e) => {
2201
2256
  if (!isEditing) openEdit(row.id, col, e.currentTarget);
@@ -2203,15 +2258,15 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
2203
2258
  title: c.error || "",
2204
2259
  children: [
2205
2260
  peer && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-peer-flag", style: { background: peer.color }, children: peer.name }),
2206
- isEditing ? renderEditor(col) : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2261
+ isEditing ? renderEditor(col) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2207
2262
  "div",
2208
2263
  {
2209
2264
  className: "shg-val",
2210
2265
  style: { maxWidth: colWidth(col) ? colWidth(col) - 20 : 400 },
2211
- children: [
2212
- col.type === "compute" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(StatusDot, { status: c.status }),
2266
+ children: custom !== void 0 ? custom : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
2267
+ computed && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(StatusDot, { status: c.status }),
2213
2268
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CellValue, { cell: c, col, fetchBlobUrl, onOpenResource }),
2214
- col.type === "compute" && !readOnly && onRunCell && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2269
+ computed && !readOnly && onRunCell && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2215
2270
  "button",
2216
2271
  {
2217
2272
  className: "shg-runcell",
@@ -2223,7 +2278,7 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
2223
2278
  children: "\u25B6"
2224
2279
  }
2225
2280
  )
2226
- ]
2281
+ ] })
2227
2282
  }
2228
2283
  )
2229
2284
  ]
@@ -2243,10 +2298,26 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
2243
2298
  ] })
2244
2299
  ] }) }) });
2245
2300
  }
2246
- function ColumnHeader({ col, columns, readOnly, menuOpen, menuAnchor, onMenu, onCloseMenu, onRename, onConfigure, onDelete, onRun }) {
2301
+ function ColumnHeader({
2302
+ col,
2303
+ columns,
2304
+ readOnly,
2305
+ desc,
2306
+ columnTypes,
2307
+ renderColumnConfig,
2308
+ menuOpen,
2309
+ menuAnchor,
2310
+ onMenu,
2311
+ onCloseMenu,
2312
+ onRename,
2313
+ onConfigure,
2314
+ onDelete,
2315
+ onRun
2316
+ }) {
2247
2317
  const [editing, setEditing] = (0, import_react12.useState)(false);
2248
2318
  const [name, setName] = (0, import_react12.useState)(col.name);
2249
2319
  (0, import_react12.useEffect)(() => setName(col.name), [col.name]);
2320
+ const badge = desc.badge ? desc.badge(col) : void 0;
2250
2321
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "shg-colhdr", children: [
2251
2322
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "shg-colhdr-main", children: [
2252
2323
  editing && !readOnly ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
@@ -2265,9 +2336,9 @@ function ColumnHeader({ col, columns, readOnly, menuOpen, menuAnchor, onMenu, on
2265
2336
  }
2266
2337
  }
2267
2338
  ) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "shg-colname", onDoubleClick: () => !readOnly && setEditing(true), title: col.name, children: col.name }),
2268
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "shg-coltype" + (col.type === "compute" ? " compute" : ""), children: [
2269
- TYPE_LABEL[col.type] || col.type,
2270
- col.type === "compute" && col.compute?.kind ? ` \xB7 ${col.compute.kind}` : ""
2339
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "shg-coltype" + (desc.computed ? " compute" : ""), children: [
2340
+ desc.label || col.type,
2341
+ badge ? ` \xB7 ${badge}` : ""
2271
2342
  ] })
2272
2343
  ] }),
2273
2344
  !readOnly && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "shg-colhdr-tools", children: [
@@ -2280,6 +2351,8 @@ function ColumnHeader({ col, columns, readOnly, menuOpen, menuAnchor, onMenu, on
2280
2351
  col,
2281
2352
  columns,
2282
2353
  anchor: menuAnchor,
2354
+ columnTypes,
2355
+ renderColumnConfig,
2283
2356
  onApply: (patch) => {
2284
2357
  onConfigure(col.id, patch);
2285
2358
  onCloseMenu();
@@ -2290,7 +2363,7 @@ function ColumnHeader({ col, columns, readOnly, menuOpen, menuAnchor, onMenu, on
2290
2363
  )
2291
2364
  ] });
2292
2365
  }
2293
- function ColumnMenu({ col, columns, anchor, onApply, onDelete, onClose }) {
2366
+ function ColumnMenu({ col, columns, anchor, columnTypes, renderColumnConfig, onApply, onDelete, onClose }) {
2294
2367
  const [type, setType] = (0, import_react12.useState)(col.type || "text");
2295
2368
  const [optText, setOptText] = (0, import_react12.useState)(
2296
2369
  normOptions(col.options).map((o) => o.label).join("\n")
@@ -2302,14 +2375,6 @@ function ColumnMenu({ col, columns, anchor, onApply, onDelete, onClose }) {
2302
2375
  const [wfSlug, setWfSlug] = (0, import_react12.useState)(comp.workflow_slug || "");
2303
2376
  const [outKey, setOutKey] = (0, import_react12.useState)(comp.output_key || "");
2304
2377
  const [deps, setDeps] = (0, import_react12.useState)(new Set(comp.deps || []));
2305
- const ref = (0, import_react12.useRef)(null);
2306
- (0, import_react12.useEffect)(() => {
2307
- const onDown = (e) => {
2308
- if (ref.current && !ref.current.contains(e.target)) onClose();
2309
- };
2310
- window.addEventListener("mousedown", onDown);
2311
- return () => window.removeEventListener("mousedown", onDown);
2312
- }, [onClose]);
2313
2378
  const others = columns.filter((c) => c.id !== col.id);
2314
2379
  const toggleDep = (id) => setDeps((s) => {
2315
2380
  const n = new Set(s);
@@ -2337,99 +2402,126 @@ function ColumnMenu({ col, columns, anchor, onApply, onDelete, onClose }) {
2337
2402
  }
2338
2403
  onApply(patch);
2339
2404
  };
2340
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PopPortal, { anchor, width: 250, estHeight: 340, className: "shg-menu", onClose, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { ref, onClick: (e) => e.stopPropagation(), children: [
2341
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
2342
- "Type",
2343
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("select", { className: "shg-menu-input", value: type, onChange: (e) => setType(e.target.value), children: [
2344
- MANUAL_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("option", { value: t, children: TYPE_LABEL[t] }, t)),
2345
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("option", { value: "compute", children: "Computed" })
2346
- ] })
2347
- ] }),
2348
- (type === "select" || type === "tags") && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
2349
- "Options (one per line)",
2350
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2351
- "textarea",
2352
- {
2353
- className: "shg-menu-input",
2354
- rows: 3,
2355
- value: optText,
2356
- onChange: (e) => setOptText(e.target.value),
2357
- placeholder: "Todo\nDoing\nDone"
2358
- }
2359
- )
2360
- ] }),
2361
- type === "compute" && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
2362
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
2363
- "Runs",
2364
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("select", { className: "shg-menu-input", value: kind, onChange: (e) => setKind(e.target.value), children: COMPUTE_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("option", { value: k.kind, children: k.label }, k.kind)) })
2365
- ] }),
2366
- (kind === "prompt" || kind === "harness") && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
2367
- "Prompt \u2014 reference columns as ",
2368
- "{{Name}}",
2369
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2370
- "textarea",
2371
- {
2372
- className: "shg-menu-input",
2373
- rows: 3,
2374
- value: prompt,
2375
- onChange: (e) => setPrompt(e.target.value),
2376
- placeholder: "Summarize {{Company}} in one line"
2377
- }
2378
- )
2379
- ] }),
2380
- kind === "harness" && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
2381
- "Agent id",
2382
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { className: "shg-menu-input", value: harnessId, onChange: (e) => setHarnessId(e.target.value), placeholder: "chrn_\u2026" })
2383
- ] }),
2384
- kind === "workflow" && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
2405
+ const custom = renderColumnConfig && renderColumnConfig({
2406
+ column: col,
2407
+ columns,
2408
+ type,
2409
+ applyPatch: (patch) => onApply({ type, ...patch }),
2410
+ deleteColumn: onDelete,
2411
+ close: onClose
2412
+ });
2413
+ const desc = columnTypes.find((t) => t.type === type) || {};
2414
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2415
+ PopPortal,
2416
+ {
2417
+ anchor,
2418
+ width: desc.configWidth || 250,
2419
+ estHeight: desc.configHeight || 340,
2420
+ className: "shg-menu",
2421
+ onClose,
2422
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { onClick: (e) => e.stopPropagation(), children: [
2385
2423
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
2386
- "Workflow id",
2387
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { className: "shg-menu-input", value: wfSlug, onChange: (e) => setWfSlug(e.target.value), placeholder: "my-workflow" })
2424
+ "Type",
2425
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("select", { className: "shg-menu-input", value: type, onChange: (e) => setType(e.target.value), children: columnTypes.map((t) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("option", { value: t.type, children: t.label }, t.type)) })
2388
2426
  ] }),
2389
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
2390
- "Output key (optional)",
2391
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { className: "shg-menu-input", value: outKey, onChange: (e) => setOutKey(e.target.value), placeholder: "summary" })
2427
+ (type === "select" || type === "tags") && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
2428
+ "Options (one per line)",
2429
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2430
+ "textarea",
2431
+ {
2432
+ className: "shg-menu-input",
2433
+ rows: 3,
2434
+ value: optText,
2435
+ onChange: (e) => setOptText(e.target.value),
2436
+ placeholder: "Todo\nDoing\nDone"
2437
+ }
2438
+ )
2439
+ ] }),
2440
+ custom !== void 0 ? custom : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
2441
+ type === "compute" && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
2442
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
2443
+ "Runs",
2444
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("select", { className: "shg-menu-input", value: kind, onChange: (e) => setKind(e.target.value), children: COMPUTE_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("option", { value: k.kind, children: k.label }, k.kind)) })
2445
+ ] }),
2446
+ (kind === "prompt" || kind === "harness") && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
2447
+ "Prompt \u2014 reference columns as ",
2448
+ "{{Name}}",
2449
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2450
+ "textarea",
2451
+ {
2452
+ className: "shg-menu-input",
2453
+ rows: 3,
2454
+ value: prompt,
2455
+ onChange: (e) => setPrompt(e.target.value),
2456
+ placeholder: "Summarize {{Company}} in one line"
2457
+ }
2458
+ )
2459
+ ] }),
2460
+ kind === "harness" && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
2461
+ "Agent id",
2462
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { className: "shg-menu-input", value: harnessId, onChange: (e) => setHarnessId(e.target.value), placeholder: "chrn_\u2026" })
2463
+ ] }),
2464
+ kind === "workflow" && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
2465
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
2466
+ "Workflow id",
2467
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { className: "shg-menu-input", value: wfSlug, onChange: (e) => setWfSlug(e.target.value), placeholder: "my-workflow" })
2468
+ ] }),
2469
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-lbl", children: [
2470
+ "Output key (optional)",
2471
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { className: "shg-menu-input", value: outKey, onChange: (e) => setOutKey(e.target.value), placeholder: "summary" })
2472
+ ] })
2473
+ ] }),
2474
+ others.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "shg-menu-lbl", children: [
2475
+ "Reads columns",
2476
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "shg-menu-deps", children: others.map((c) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-dep", children: [
2477
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { type: "checkbox", checked: deps.has(c.id), onChange: () => toggleDep(c.id) }),
2478
+ " ",
2479
+ c.name
2480
+ ] }, c.id)) })
2481
+ ] })
2482
+ ] }),
2483
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "shg-menu-actions", children: [
2484
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "shg-menu-del", onClick: onDelete, children: "Delete column" }),
2485
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "shg-menu-apply", onClick: apply, children: "Apply" })
2486
+ ] })
2392
2487
  ] })
2393
- ] }),
2394
- others.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "shg-menu-lbl", children: [
2395
- "Reads columns",
2396
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "shg-menu-deps", children: others.map((c) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "shg-menu-dep", children: [
2397
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { type: "checkbox", checked: deps.has(c.id), onChange: () => toggleDep(c.id) }),
2398
- " ",
2399
- c.name
2400
- ] }, c.id)) })
2401
2488
  ] })
2402
- ] }),
2403
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "shg-menu-actions", children: [
2404
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "shg-menu-del", onClick: onDelete, children: "Delete column" }),
2405
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "shg-menu-apply", onClick: apply, children: "Apply" })
2406
- ] })
2407
- ] }) });
2489
+ }
2490
+ );
2491
+ }
2492
+ function defaultCellText(cell) {
2493
+ const v = cell?.value;
2494
+ if (v == null) return "";
2495
+ if (Array.isArray(v)) return v.join(", ");
2496
+ if (typeof v === "object") return JSON.stringify(v);
2497
+ return String(v);
2408
2498
  }
2409
- function sheetToDelimited(sheet, sep = ",") {
2499
+ function sheetToDelimited(sheet, sep = ",", { cellText = defaultCellText } = {}) {
2410
2500
  const cols = sheet?.columns || [];
2411
2501
  const rows = sheet?.rows || [];
2412
2502
  const cells = sheet?.cells || {};
2413
- const esc = (v) => {
2414
- const s = v == null ? "" : Array.isArray(v) ? v.join(", ") : typeof v === "object" ? JSON.stringify(v) : String(v);
2503
+ const esc = (s) => {
2415
2504
  if (sep === "," && /[",\n]/.test(s)) return `"${s.replace(/"/g, '""')}"`;
2416
2505
  return s;
2417
2506
  };
2418
2507
  const header = cols.map((c) => esc(c.name)).join(sep);
2419
- const body = rows.map((r) => cols.map((c) => {
2420
- const cell = cells[cellKey(r.id, c.id)];
2421
- return esc(cell ? cell.value : "");
2422
- }).join(sep));
2508
+ const body = rows.map((r) => cols.map((c) => esc(String(cellText(cells[cellKey(r.id, c.id)], c) ?? ""))).join(sep));
2423
2509
  return [header, ...body].join("\n");
2424
2510
  }
2425
- function sheetToAoA(sheet) {
2511
+ function defaultCellValue(cell) {
2512
+ const v = cell?.value;
2513
+ if (v == null) return "";
2514
+ if (Array.isArray(v)) return v.join(", ");
2515
+ if (typeof v === "object") return JSON.stringify(v);
2516
+ return v;
2517
+ }
2518
+ function sheetToAoA(sheet, { cellText = defaultCellValue } = {}) {
2426
2519
  const cols = sheet?.columns || [];
2427
2520
  const rows = sheet?.rows || [];
2428
2521
  const cells = sheet?.cells || {};
2429
- const val = (v) => v == null ? "" : Array.isArray(v) ? v.join(", ") : typeof v === "object" ? JSON.stringify(v) : v;
2430
2522
  return [
2431
2523
  cols.map((c) => c.name),
2432
- ...rows.map((r) => cols.map((c) => val(cells[cellKey(r.id, c.id)]?.value)))
2524
+ ...rows.map((r) => cols.map((c) => cellText(cells[cellKey(r.id, c.id)], c) ?? ""))
2433
2525
  ];
2434
2526
  }
2435
2527
  //# sourceMappingURL=index.cjs.map