reifyui 0.8.3 → 0.8.5
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/index.cjs +154 -107
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +154 -107
- package/dist/index.js.map +1 -1
- package/dist/slides.cjs +29 -6
- package/dist/slides.cjs.map +1 -1
- package/dist/slides.js +29 -6
- package/dist/slides.js.map +1 -1
- package/package.json +7 -6
- package/src/index.d.ts +2 -0
- package/src/sheet/SheetGrid.jsx +70 -13
- package/src/slides/elements.jsx +34 -5
- package/styles/sheet.css +38 -18
package/dist/index.d.ts
CHANGED
|
@@ -496,6 +496,8 @@ export interface SheetColumn {
|
|
|
496
496
|
options?: Array<string | { label?: string; value?: unknown; color?: string }>;
|
|
497
497
|
[key: string]: unknown;
|
|
498
498
|
}
|
|
499
|
+
/** With no `height` a row fits its tallest cell, up to --shg-row-max (eight lines by default), and
|
|
500
|
+
* a cell holding more scrolls inside itself. A `height` is a row someone sized: exactly that tall. */
|
|
499
501
|
export interface SheetRow { id: string; height?: number; [key: string]: unknown }
|
|
500
502
|
export interface SheetCell { value?: unknown; status?: string; error?: string | null; [key: string]: unknown }
|
|
501
503
|
export interface Sheet {
|
package/dist/index.js
CHANGED
|
@@ -2126,6 +2126,9 @@ var COMPUTE_KINDS = [
|
|
|
2126
2126
|
];
|
|
2127
2127
|
var RESOURCE_KINDS = ["image", "sheet", "slides", "workflow", "graph"];
|
|
2128
2128
|
var RESOURCE_ICON = { image: "\u{1F5BC}", sheet: "\u25A6", slides: "\u25A4", workflow: "\u2699", graph: "\u25C9" };
|
|
2129
|
+
var POPOVER_EDITORS = /* @__PURE__ */ new Set(["select", "resource"]);
|
|
2130
|
+
var SINGLE_LINE_EDITORS = /* @__PURE__ */ new Set(["number", "date", "tags"]);
|
|
2131
|
+
var isMultiline = (col) => !SINGLE_LINE_EDITORS.has(col.type);
|
|
2129
2132
|
function PopPortal({ anchor, width = 250, estHeight = 300, className, children, onClose }) {
|
|
2130
2133
|
const boxRef = useRef7(null);
|
|
2131
2134
|
useEffect8(() => {
|
|
@@ -2298,6 +2301,7 @@ function SheetGrid({
|
|
|
2298
2301
|
document.body.style.cursor = "";
|
|
2299
2302
|
if (!d) return;
|
|
2300
2303
|
setSizeDraft({});
|
|
2304
|
+
if (d.last === d.start) return;
|
|
2301
2305
|
mutate((n) => {
|
|
2302
2306
|
if (d.kind === "col") {
|
|
2303
2307
|
const c = n.columns.find((x) => x.id === d.id);
|
|
@@ -2370,8 +2374,23 @@ function SheetGrid({
|
|
|
2370
2374
|
const numW = Math.max(48, 30 + String(rows.length || 1).length * 9);
|
|
2371
2375
|
const numStyle = { width: numW, minWidth: numW, maxWidth: numW };
|
|
2372
2376
|
const rowHeight = (row) => sizeDraft.row && sizeDraft.row[row.id] || row.height || void 0;
|
|
2377
|
+
const rowStyle = (row) => {
|
|
2378
|
+
const h = rowHeight(row);
|
|
2379
|
+
return {
|
|
2380
|
+
...h ? { height: h, "--shg-row-max": `${h - 1}px` } : null,
|
|
2381
|
+
// The grid's own text wraps and no longer reads this; it stays for host cell bodies that do.
|
|
2382
|
+
"--shg-clamp": Math.max(1, Math.floor(((h || 34) - 10) / 18))
|
|
2383
|
+
};
|
|
2384
|
+
};
|
|
2385
|
+
const fitRow = (rowId) => mutate((n) => {
|
|
2386
|
+
const r = n.rows.find((x) => x.id === rowId);
|
|
2387
|
+
if (r) delete r.height;
|
|
2388
|
+
});
|
|
2373
2389
|
useEffect8(() => {
|
|
2374
|
-
|
|
2390
|
+
const el = editing && inputRef.current;
|
|
2391
|
+
if (!el) return;
|
|
2392
|
+
el.focus();
|
|
2393
|
+
if (el.tagName === "TEXTAREA") el.setSelectionRange(el.value.length, el.value.length);
|
|
2375
2394
|
}, [editing]);
|
|
2376
2395
|
const mutate = (fn) => {
|
|
2377
2396
|
if (readOnly || !onChange) return;
|
|
@@ -2511,6 +2530,26 @@ function SheetGrid({
|
|
|
2511
2530
|
}
|
|
2512
2531
|
);
|
|
2513
2532
|
}
|
|
2533
|
+
if (isMultiline(col)) {
|
|
2534
|
+
return /* @__PURE__ */ jsx13(
|
|
2535
|
+
"textarea",
|
|
2536
|
+
{
|
|
2537
|
+
ref: inputRef,
|
|
2538
|
+
className: "shg-input shg-input-area",
|
|
2539
|
+
value: draft,
|
|
2540
|
+
rows: 1,
|
|
2541
|
+
onChange: (e) => setDraft(e.target.value),
|
|
2542
|
+
onBlur: commitEdit,
|
|
2543
|
+
onKeyDown: (e) => {
|
|
2544
|
+
if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
|
|
2545
|
+
e.preventDefault();
|
|
2546
|
+
commitEdit();
|
|
2547
|
+
}
|
|
2548
|
+
if (e.key === "Escape") setEditing(null);
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
);
|
|
2552
|
+
}
|
|
2514
2553
|
const inputType = col.type === "date" ? "date" : col.type === "number" ? "number" : "text";
|
|
2515
2554
|
return /* @__PURE__ */ jsx13(
|
|
2516
2555
|
"input",
|
|
@@ -2569,114 +2608,122 @@ function SheetGrid({
|
|
|
2569
2608
|
!readOnly && /* @__PURE__ */ jsx13("th", { className: "shg-add-col", children: /* @__PURE__ */ jsx13("button", { className: "shg-add", onClick: addColumn, title: "Add column", children: "+" }) })
|
|
2570
2609
|
] }) }),
|
|
2571
2610
|
/* @__PURE__ */ jsxs12("tbody", { children: [
|
|
2572
|
-
rows.map((row, ri) => /* @__PURE__ */ jsxs12(
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
"
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
style: numStyle,
|
|
2586
|
-
title: "Drag to reorder",
|
|
2587
|
-
...dndProps("row", row.id),
|
|
2588
|
-
children: [
|
|
2589
|
-
/* @__PURE__ */ jsx13("span", { children: ri + 1 }),
|
|
2590
|
-
!readOnly && /* @__PURE__ */ jsx13("button", { className: "shg-rowdel", onClick: () => deleteRow(row.id), title: "Delete row", children: "\xD7" }),
|
|
2591
|
-
!readOnly && /* @__PURE__ */ jsx13("span", { className: "shg-resize-row", onMouseDown: (e) => startResize(e, "row", row.id, rowHeight(row) || e.currentTarget.closest("tr").offsetHeight) })
|
|
2592
|
-
]
|
|
2593
|
-
}
|
|
2594
|
-
),
|
|
2595
|
-
columns.map((col) => {
|
|
2596
|
-
const c = cells[cellKey(row.id, col.id)] || {};
|
|
2597
|
-
const computed = isComputed(col);
|
|
2598
|
-
const isEditing = editing && editing.rowId === row.id && editing.colId === col.id;
|
|
2599
|
-
const peer = peerMarks && peerMarks[cellKey(row.id, col.id)];
|
|
2600
|
-
const custom = renderCell && renderCell({
|
|
2601
|
-
cell: c,
|
|
2602
|
-
column: col,
|
|
2603
|
-
row,
|
|
2604
|
-
rowIndex: ri,
|
|
2605
|
-
sheet,
|
|
2606
|
-
computed,
|
|
2607
|
-
width: colWidth(col),
|
|
2608
|
-
height: rowHeight(row),
|
|
2609
|
-
editing: !!isEditing,
|
|
2610
|
-
readOnly,
|
|
2611
|
-
setCell: (v) => setCell(row.id, col.id, v),
|
|
2612
|
-
runCell: onRunCell && !readOnly ? () => onRunCell(row.id, col.id) : null
|
|
2613
|
-
});
|
|
2614
|
-
return /* @__PURE__ */ jsxs12(
|
|
2615
|
-
"td",
|
|
2611
|
+
rows.map((row, ri) => /* @__PURE__ */ jsxs12("tr", { "data-row-id": row.id, style: rowStyle(row), children: [
|
|
2612
|
+
/* @__PURE__ */ jsxs12(
|
|
2613
|
+
"td",
|
|
2614
|
+
{
|
|
2615
|
+
className: "shg-rownum" + dndClass("row", row.id),
|
|
2616
|
+
style: numStyle,
|
|
2617
|
+
title: "Drag to reorder",
|
|
2618
|
+
...dndProps("row", row.id),
|
|
2619
|
+
children: [
|
|
2620
|
+
/* @__PURE__ */ jsx13("span", { children: ri + 1 }),
|
|
2621
|
+
!readOnly && /* @__PURE__ */ jsx13("button", { className: "shg-rowdel", onClick: () => deleteRow(row.id), title: "Delete row", children: "\xD7" }),
|
|
2622
|
+
!readOnly && /* @__PURE__ */ jsx13(
|
|
2623
|
+
"span",
|
|
2616
2624
|
{
|
|
2617
|
-
"
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
}
|
|
2625
|
+
className: "shg-resize-row",
|
|
2626
|
+
title: "Drag to resize, double-click to fit",
|
|
2627
|
+
onMouseDown: (e) => startResize(e, "row", row.id, rowHeight(row) || e.currentTarget.closest("tr").offsetHeight),
|
|
2628
|
+
onDoubleClick: () => fitRow(row.id)
|
|
2629
|
+
}
|
|
2630
|
+
)
|
|
2631
|
+
]
|
|
2632
|
+
}
|
|
2633
|
+
),
|
|
2634
|
+
columns.map((col) => {
|
|
2635
|
+
const c = cells[cellKey(row.id, col.id)] || {};
|
|
2636
|
+
const computed = isComputed(col);
|
|
2637
|
+
const isEditing = editing && editing.rowId === row.id && editing.colId === col.id;
|
|
2638
|
+
const peer = peerMarks && peerMarks[cellKey(row.id, col.id)];
|
|
2639
|
+
const custom = renderCell && renderCell({
|
|
2640
|
+
cell: c,
|
|
2641
|
+
column: col,
|
|
2642
|
+
row,
|
|
2643
|
+
rowIndex: ri,
|
|
2644
|
+
sheet,
|
|
2645
|
+
computed,
|
|
2646
|
+
width: colWidth(col),
|
|
2647
|
+
height: rowHeight(row),
|
|
2648
|
+
editing: !!isEditing,
|
|
2649
|
+
readOnly,
|
|
2650
|
+
setCell: (v) => setCell(row.id, col.id, v),
|
|
2651
|
+
runCell: onRunCell && !readOnly ? () => onRunCell(row.id, col.id) : null
|
|
2652
|
+
});
|
|
2653
|
+
return /* @__PURE__ */ jsxs12(
|
|
2654
|
+
"td",
|
|
2655
|
+
{
|
|
2656
|
+
"data-col-id": col.id,
|
|
2657
|
+
className: "shg-cell" + (computed ? " shg-cell-compute" : "") + (c.status && computed ? ` shg-cell-${c.status}` : "") + (peer ? " shg-cell-peer" : ""),
|
|
2658
|
+
style: peer ? { boxShadow: `inset 0 0 0 2px ${peer.color}` } : void 0,
|
|
2659
|
+
onClick: (e) => {
|
|
2660
|
+
if (!isEditing) openEdit(row.id, col, e.currentTarget);
|
|
2661
|
+
},
|
|
2662
|
+
title: c.error || "",
|
|
2663
|
+
children: [
|
|
2664
|
+
!readOnly && /* @__PURE__ */ jsxs12(Fragment8, { children: [
|
|
2665
|
+
/* @__PURE__ */ jsx13(
|
|
2666
|
+
"span",
|
|
2667
|
+
{
|
|
2668
|
+
className: "shg-resize-col shg-resize-in-cell",
|
|
2669
|
+
onClick: (e) => e.stopPropagation(),
|
|
2670
|
+
onMouseDown: (e) => startResize(
|
|
2671
|
+
e,
|
|
2672
|
+
"col",
|
|
2673
|
+
col.id,
|
|
2674
|
+
colWidth(col) || e.currentTarget.closest("td").offsetWidth
|
|
2668
2675
|
)
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2676
|
+
}
|
|
2677
|
+
),
|
|
2678
|
+
/* @__PURE__ */ jsx13(
|
|
2679
|
+
"span",
|
|
2680
|
+
{
|
|
2681
|
+
className: "shg-resize-row shg-resize-in-cell",
|
|
2682
|
+
onClick: (e) => e.stopPropagation(),
|
|
2683
|
+
onMouseDown: (e) => startResize(
|
|
2684
|
+
e,
|
|
2685
|
+
"row",
|
|
2686
|
+
row.id,
|
|
2687
|
+
rowHeight(row) || e.currentTarget.closest("tr").offsetHeight
|
|
2688
|
+
),
|
|
2689
|
+
onDoubleClick: (e) => {
|
|
2690
|
+
e.stopPropagation();
|
|
2691
|
+
fitRow(row.id);
|
|
2692
|
+
}
|
|
2693
|
+
}
|
|
2694
|
+
)
|
|
2695
|
+
] }),
|
|
2696
|
+
peer && /* @__PURE__ */ jsx13("span", { className: "shg-peer-flag", style: { background: peer.color }, children: peer.name }),
|
|
2697
|
+
isEditing && renderEditor(col),
|
|
2698
|
+
isEditing && !POPOVER_EDITORS.has(col.type) ? (
|
|
2699
|
+
// The editor lies over the cell; this invisible copy of the draft holds the
|
|
2700
|
+
// cell's place, so the row keeps its height while you type and grows with
|
|
2701
|
+
// the draft, to the same cap as the value. The trailing zero-width space
|
|
2702
|
+
// gives a draft that ends in a line break its last, empty line.
|
|
2703
|
+
/* @__PURE__ */ jsx13("div", { className: "shg-val shg-val-mirror", "aria-hidden": "true", children: /* @__PURE__ */ jsx13("span", { className: "shg-val-txt", children: `${typeof draft === "string" ? draft : ""}\u200B` }) })
|
|
2704
|
+
) : /* @__PURE__ */ jsx13("div", { className: "shg-val", children: custom !== void 0 ? custom : /* @__PURE__ */ jsxs12(Fragment8, { children: [
|
|
2705
|
+
computed && /* @__PURE__ */ jsx13(StatusDot, { status: c.status }),
|
|
2706
|
+
/* @__PURE__ */ jsx13(CellValue, { cell: c, col, fetchBlobUrl, onOpenResource }),
|
|
2707
|
+
computed && !readOnly && onRunCell && /* @__PURE__ */ jsx13(
|
|
2708
|
+
"button",
|
|
2709
|
+
{
|
|
2710
|
+
className: "shg-runcell",
|
|
2711
|
+
title: "Run this cell",
|
|
2712
|
+
onClick: (e) => {
|
|
2713
|
+
e.stopPropagation();
|
|
2714
|
+
onRunCell(row.id, col.id);
|
|
2715
|
+
},
|
|
2716
|
+
children: "\u25B6"
|
|
2717
|
+
}
|
|
2718
|
+
)
|
|
2719
|
+
] }) })
|
|
2720
|
+
]
|
|
2721
|
+
},
|
|
2722
|
+
col.id
|
|
2723
|
+
);
|
|
2724
|
+
}),
|
|
2725
|
+
!readOnly && /* @__PURE__ */ jsx13("td", { className: "shg-pad" })
|
|
2726
|
+
] }, row.id)),
|
|
2680
2727
|
!readOnly && /* @__PURE__ */ jsxs12("tr", { className: "shg-ghost-row", onClick: addRow, children: [
|
|
2681
2728
|
/* @__PURE__ */ jsx13("td", { className: "shg-rownum shg-ghost-num", style: numStyle, children: "+" }),
|
|
2682
2729
|
/* @__PURE__ */ jsx13("td", { className: "shg-ghost-cell", colSpan: columns.length + 1, children: "New row" })
|