reifyui 0.12.0 → 0.13.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 +29 -0
- package/dist/chart.js +2 -0
- package/dist/chart.js.map +1 -1
- package/dist/chunk-EL2DHWOH.js +1710 -0
- package/dist/chunk-EL2DHWOH.js.map +1 -0
- package/dist/chunk-J633KV57.js +41 -0
- package/dist/chunk-J633KV57.js.map +1 -0
- package/dist/chunk-J7SECRIG.js +295 -0
- package/dist/chunk-J7SECRIG.js.map +1 -0
- package/dist/chunk-PIRPLH2Z.js +231 -0
- package/dist/chunk-PIRPLH2Z.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-UKG4Z6QK.js +130 -0
- package/dist/chunk-UKG4Z6QK.js.map +1 -0
- package/dist/chunk-ZYWE47EO.js +19 -0
- package/dist/chunk-ZYWE47EO.js.map +1 -0
- package/dist/collab.cjs +169 -0
- package/dist/collab.cjs.map +1 -0
- package/dist/collab.d.ts +30 -0
- package/dist/collab.js +18 -0
- package/dist/collab.js.map +1 -0
- package/dist/graph.cjs +2244 -0
- package/dist/graph.cjs.map +1 -0
- package/dist/graph.d.ts +41 -0
- package/dist/graph.js +1870 -0
- package/dist/graph.js.map +1 -0
- package/dist/harness.js +1 -0
- package/dist/harness.js.map +1 -1
- package/dist/index.cjs +1699 -817
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +680 -1769
- package/dist/index.js.map +1 -1
- package/dist/sheet-doc.cjs +235 -0
- package/dist/sheet-doc.cjs.map +1 -0
- package/dist/sheet-doc.d.ts +16 -0
- package/dist/sheet-doc.js +20 -0
- package/dist/sheet-doc.js.map +1 -0
- package/dist/sheet.cjs +2322 -0
- package/dist/sheet.cjs.map +1 -0
- package/dist/sheet.d.ts +23 -0
- package/dist/sheet.js +237 -0
- package/dist/sheet.js.map +1 -0
- package/dist/slides.js +2 -0
- package/dist/slides.js.map +1 -1
- package/package.json +34 -2
- package/src/auth/client.js +4 -2
- package/src/collab/colors.js +18 -0
- package/src/collab/index.d.ts +30 -0
- package/src/collab/index.js +8 -0
- package/src/collab/keepAlive.js +34 -0
- package/src/collab/useLiveDoc.js +76 -0
- package/src/components/CascadeMenu.jsx +9 -3
- package/src/components/Composer.jsx +37 -3
- package/src/components/resizable.jsx +82 -12
- package/src/graph/ConnectPane.jsx +634 -0
- package/src/graph/ConnectToolDetail.jsx +565 -0
- package/src/graph/LogsPane.jsx +328 -0
- package/src/graph/Skeleton.jsx +13 -0
- package/src/graph/draft.js +108 -0
- package/src/graph/format.js +37 -0
- package/src/graph/index.d.ts +41 -0
- package/src/graph/index.js +14 -0
- package/src/graph/useGraphCollab.js +299 -0
- package/src/graph/vgraph.js +215 -0
- package/src/index.d.ts +3 -0
- package/src/index.js +4 -1
- package/src/mention/MentionInput.jsx +420 -0
- package/src/mention/mentionModel.js +177 -0
- package/src/sheet/RunStrip.jsx +57 -0
- package/src/sheet/SheetGrid.jsx +448 -423
- package/src/sheet/doc.d.ts +16 -0
- package/src/sheet/index.d.ts +23 -0
- package/src/sheet/index.js +10 -0
- package/src/sheet/sheetDoc.js +203 -0
- package/src/sheet/useSheetCollab.js +102 -0
- package/src/sheet/useSheetRun.js +80 -0
- package/styles/chat.css +2 -0
- package/styles/graph.css +395 -0
- package/styles/mention.css +79 -0
- package/styles/sheet.css +156 -112
package/dist/index.cjs
CHANGED
|
@@ -71,6 +71,8 @@ __export(src_exports, {
|
|
|
71
71
|
IcTool: () => IcTool,
|
|
72
72
|
IcX: () => IcX,
|
|
73
73
|
Input: () => Input,
|
|
74
|
+
MentionInput: () => MentionInput,
|
|
75
|
+
MentionText: () => MentionText,
|
|
74
76
|
Modal: () => Modal,
|
|
75
77
|
PaneResizer: () => PaneResizer,
|
|
76
78
|
Panel: () => Panel,
|
|
@@ -103,7 +105,6 @@ __export(src_exports, {
|
|
|
103
105
|
createResponsesDispatcher: () => createResponsesDispatcher,
|
|
104
106
|
extOf: () => extOf,
|
|
105
107
|
fetchBalance: () => fetchBalance,
|
|
106
|
-
fitRowHeights: () => fitRowHeights,
|
|
107
108
|
getSession: () => getSession,
|
|
108
109
|
getToken: () => getToken,
|
|
109
110
|
googleSignIn: () => googleSignIn,
|
|
@@ -830,6 +831,8 @@ function Composer(props) {
|
|
|
830
831
|
inputAriaLabel,
|
|
831
832
|
attachments,
|
|
832
833
|
tray,
|
|
834
|
+
onFiles,
|
|
835
|
+
dropTargetRef,
|
|
833
836
|
accessoriesLeft,
|
|
834
837
|
accessoriesRight,
|
|
835
838
|
renderSend,
|
|
@@ -838,6 +841,50 @@ function Composer(props) {
|
|
|
838
841
|
} = props;
|
|
839
842
|
const ownRef = (0, import_react5.useRef)(null);
|
|
840
843
|
const taRef = inputRef || ownRef;
|
|
844
|
+
const rootRef = (0, import_react5.useRef)(null);
|
|
845
|
+
const [dropping, setDropping] = (0, import_react5.useState)(false);
|
|
846
|
+
(0, import_react5.useEffect)(() => {
|
|
847
|
+
if (!onFiles || disabled) return void 0;
|
|
848
|
+
const el = dropTargetRef && dropTargetRef.current || rootRef.current;
|
|
849
|
+
if (!el) return void 0;
|
|
850
|
+
let depth = 0;
|
|
851
|
+
const hasFiles = (e) => Array.from(e.dataTransfer && e.dataTransfer.types || []).includes("Files");
|
|
852
|
+
const enter = (e) => {
|
|
853
|
+
if (!hasFiles(e)) return;
|
|
854
|
+
e.preventDefault();
|
|
855
|
+
depth += 1;
|
|
856
|
+
setDropping(true);
|
|
857
|
+
};
|
|
858
|
+
const over = (e) => {
|
|
859
|
+
if (!hasFiles(e)) return;
|
|
860
|
+
e.preventDefault();
|
|
861
|
+
e.dataTransfer.dropEffect = "copy";
|
|
862
|
+
};
|
|
863
|
+
const leave = (e) => {
|
|
864
|
+
if (!hasFiles(e)) return;
|
|
865
|
+
e.preventDefault();
|
|
866
|
+
depth = Math.max(0, depth - 1);
|
|
867
|
+
if (depth === 0) setDropping(false);
|
|
868
|
+
};
|
|
869
|
+
const drop = (e) => {
|
|
870
|
+
if (!hasFiles(e)) return;
|
|
871
|
+
e.preventDefault();
|
|
872
|
+
depth = 0;
|
|
873
|
+
setDropping(false);
|
|
874
|
+
if (e.dataTransfer.files && e.dataTransfer.files.length) onFiles(e.dataTransfer.files);
|
|
875
|
+
};
|
|
876
|
+
el.addEventListener("dragenter", enter);
|
|
877
|
+
el.addEventListener("dragover", over);
|
|
878
|
+
el.addEventListener("dragleave", leave);
|
|
879
|
+
el.addEventListener("drop", drop);
|
|
880
|
+
return () => {
|
|
881
|
+
el.removeEventListener("dragenter", enter);
|
|
882
|
+
el.removeEventListener("dragover", over);
|
|
883
|
+
el.removeEventListener("dragleave", leave);
|
|
884
|
+
el.removeEventListener("drop", drop);
|
|
885
|
+
};
|
|
886
|
+
}, [onFiles, disabled, dropTargetRef]);
|
|
887
|
+
const rootClass = (classNames.root ?? "wbx-composer") + (dropping ? " is-dropping" : "");
|
|
841
888
|
(0, import_react5.useEffect)(() => {
|
|
842
889
|
if (!autoGrow) return;
|
|
843
890
|
const el = taRef.current;
|
|
@@ -851,7 +898,7 @@ function Composer(props) {
|
|
|
851
898
|
}, [value, autoGrow, maxRows, taRef]);
|
|
852
899
|
const sendEl = renderSend ? renderSend() : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "uic-send", disabled: sendDisabled, onClick: () => onSend(), "aria-label": "Send message", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(IcSend, {}) });
|
|
853
900
|
if (inline) {
|
|
854
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", {
|
|
901
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { ref: rootRef, className: rootClass, children: [
|
|
855
902
|
attachments,
|
|
856
903
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "uic-composer-line", children: [
|
|
857
904
|
accessoriesLeft,
|
|
@@ -881,7 +928,7 @@ function Composer(props) {
|
|
|
881
928
|
tray ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "uic-composer-tray", children: tray }) : null
|
|
882
929
|
] });
|
|
883
930
|
}
|
|
884
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", {
|
|
931
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { ref: rootRef, className: rootClass, children: [
|
|
885
932
|
attachments,
|
|
886
933
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
887
934
|
"textarea",
|
|
@@ -1499,15 +1546,21 @@ function useResizablePane(opts = {}) {
|
|
|
1499
1546
|
maxFraction = null,
|
|
1500
1547
|
// viewport-width fraction cap, e.g. 0.6 for 60vw (null = none)
|
|
1501
1548
|
fromRight = false,
|
|
1502
|
-
// divider sits on the pane's LEFT edge (dragging
|
|
1503
|
-
storageKey = null
|
|
1504
|
-
// persist the chosen
|
|
1549
|
+
// divider sits on the pane's LEFT/TOP edge (dragging toward it shrinks)
|
|
1550
|
+
storageKey = null,
|
|
1551
|
+
// persist the chosen size per user (localStorage)
|
|
1552
|
+
axis = "x"
|
|
1553
|
+
// 'x' = width (col-resize), 'y' = height (row-resize)
|
|
1505
1554
|
} = opts;
|
|
1555
|
+
const vertical = axis === "y";
|
|
1556
|
+
const coord = (e) => vertical ? e.clientY : e.clientX;
|
|
1557
|
+
const viewportExtent = () => typeof window === "undefined" ? 0 : vertical ? window.innerHeight : window.innerWidth;
|
|
1558
|
+
const cursor = vertical ? "row-resize" : "col-resize";
|
|
1506
1559
|
const clamp2 = (0, import_react9.useCallback)((x) => {
|
|
1507
1560
|
let hi = max ?? Infinity;
|
|
1508
|
-
if (maxFraction && typeof window !== "undefined") hi = Math.min(hi, Math.round(
|
|
1561
|
+
if (maxFraction && typeof window !== "undefined") hi = Math.min(hi, Math.round(viewportExtent() * maxFraction));
|
|
1509
1562
|
return Math.min(hi, Math.max(min, x));
|
|
1510
|
-
}, [min, max, maxFraction]);
|
|
1563
|
+
}, [min, max, maxFraction, vertical]);
|
|
1511
1564
|
const [width, setWidth] = (0, import_react9.useState)(() => {
|
|
1512
1565
|
if (storageKey && typeof window !== "undefined") {
|
|
1513
1566
|
try {
|
|
@@ -1529,9 +1582,9 @@ function useResizablePane(opts = {}) {
|
|
|
1529
1582
|
}, [storageKey]);
|
|
1530
1583
|
const onMouseDown = (0, import_react9.useCallback)((e) => {
|
|
1531
1584
|
e.preventDefault();
|
|
1532
|
-
const sx = e
|
|
1585
|
+
const sx = coord(e), base = widthRef.current, dir = fromRight ? -1 : 1;
|
|
1533
1586
|
document.body.classList.add("uic-resizing");
|
|
1534
|
-
const move = (ev) => setWidth(clamp2(base + dir * (ev
|
|
1587
|
+
const move = (ev) => setWidth(clamp2(base + dir * (coord(ev) - sx)));
|
|
1535
1588
|
const up = () => {
|
|
1536
1589
|
window.removeEventListener("mousemove", move);
|
|
1537
1590
|
window.removeEventListener("mouseup", up);
|
|
@@ -1541,8 +1594,35 @@ function useResizablePane(opts = {}) {
|
|
|
1541
1594
|
};
|
|
1542
1595
|
window.addEventListener("mousemove", move);
|
|
1543
1596
|
window.addEventListener("mouseup", up);
|
|
1544
|
-
document.body.style.cursor =
|
|
1545
|
-
}, [clamp2, fromRight, persist]);
|
|
1597
|
+
document.body.style.cursor = cursor;
|
|
1598
|
+
}, [clamp2, fromRight, persist, vertical]);
|
|
1599
|
+
const onPointerDown = (0, import_react9.useCallback)((e) => {
|
|
1600
|
+
if (e.pointerType === "mouse") return;
|
|
1601
|
+
e.preventDefault();
|
|
1602
|
+
const sx = coord(e), base = widthRef.current, dir = fromRight ? -1 : 1;
|
|
1603
|
+
const el = e.currentTarget;
|
|
1604
|
+
document.body.classList.add("uic-resizing");
|
|
1605
|
+
try {
|
|
1606
|
+
el.setPointerCapture(e.pointerId);
|
|
1607
|
+
} catch {
|
|
1608
|
+
}
|
|
1609
|
+
const move = (ev) => setWidth(clamp2(base + dir * (coord(ev) - sx)));
|
|
1610
|
+
const up = () => {
|
|
1611
|
+
el.removeEventListener("pointermove", move);
|
|
1612
|
+
el.removeEventListener("pointerup", up);
|
|
1613
|
+
el.removeEventListener("pointercancel", up);
|
|
1614
|
+
document.body.classList.remove("uic-resizing");
|
|
1615
|
+
persist(widthRef.current);
|
|
1616
|
+
};
|
|
1617
|
+
el.addEventListener("pointermove", move);
|
|
1618
|
+
el.addEventListener("pointerup", up);
|
|
1619
|
+
el.addEventListener("pointercancel", up);
|
|
1620
|
+
}, [clamp2, fromRight, persist, vertical]);
|
|
1621
|
+
const nudge = (0, import_react9.useCallback)((delta) => {
|
|
1622
|
+
const w = clamp2(widthRef.current + delta);
|
|
1623
|
+
setWidth(w);
|
|
1624
|
+
persist(w);
|
|
1625
|
+
}, [clamp2, persist]);
|
|
1546
1626
|
const reset = (0, import_react9.useCallback)(() => {
|
|
1547
1627
|
setWidth(initial);
|
|
1548
1628
|
if (storageKey) {
|
|
@@ -1552,18 +1632,41 @@ function useResizablePane(opts = {}) {
|
|
|
1552
1632
|
}
|
|
1553
1633
|
}
|
|
1554
1634
|
}, [initial, storageKey]);
|
|
1555
|
-
|
|
1635
|
+
let maxResolved = max ?? null;
|
|
1636
|
+
if (maxFraction && typeof window !== "undefined") {
|
|
1637
|
+
const frac = Math.round(viewportExtent() * maxFraction);
|
|
1638
|
+
maxResolved = maxResolved == null ? frac : Math.min(maxResolved, frac);
|
|
1639
|
+
}
|
|
1640
|
+
return { width, onMouseDown, onPointerDown, nudge, reset, min, max: maxResolved, fromRight, axis };
|
|
1556
1641
|
}
|
|
1557
1642
|
function PaneResizer(props) {
|
|
1558
1643
|
const { pane, className, title = "Drag to resize (double-click to reset)" } = props;
|
|
1644
|
+
const vertical = pane.axis === "y";
|
|
1645
|
+
const onKeyDown = (e) => {
|
|
1646
|
+
const keys = vertical ? ["ArrowUp", "ArrowDown"] : ["ArrowLeft", "ArrowRight"];
|
|
1647
|
+
if (!keys.includes(e.key)) return;
|
|
1648
|
+
if (!pane.nudge) return;
|
|
1649
|
+
e.preventDefault();
|
|
1650
|
+
const step = e.shiftKey ? 96 : 24;
|
|
1651
|
+
const forward = e.key === "ArrowRight" || e.key === "ArrowDown";
|
|
1652
|
+
const dir = (forward ? 1 : -1) * (pane.fromRight ? -1 : 1);
|
|
1653
|
+
pane.nudge(dir * step);
|
|
1654
|
+
};
|
|
1559
1655
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1560
1656
|
"div",
|
|
1561
1657
|
{
|
|
1562
|
-
className: className ?? "uic-vresize",
|
|
1658
|
+
className: className ?? (vertical ? "uic-hresize" : "uic-vresize"),
|
|
1563
1659
|
role: "separator",
|
|
1564
|
-
"aria-orientation": "vertical",
|
|
1660
|
+
"aria-orientation": vertical ? "horizontal" : "vertical",
|
|
1661
|
+
"aria-label": title,
|
|
1662
|
+
"aria-valuenow": Math.round(pane.width),
|
|
1663
|
+
"aria-valuemin": pane.min != null ? Math.round(pane.min) : void 0,
|
|
1664
|
+
"aria-valuemax": pane.max != null ? Math.round(pane.max) : void 0,
|
|
1665
|
+
tabIndex: 0,
|
|
1565
1666
|
title,
|
|
1566
1667
|
onMouseDown: pane.onMouseDown,
|
|
1668
|
+
onPointerDown: pane.onPointerDown,
|
|
1669
|
+
onKeyDown,
|
|
1567
1670
|
onDoubleClick: pane.reset
|
|
1568
1671
|
}
|
|
1569
1672
|
);
|
|
@@ -2007,15 +2110,16 @@ function CreateBody({ spec, onClose, t, titleId }) {
|
|
|
2007
2110
|
|
|
2008
2111
|
// src/auth/client.js
|
|
2009
2112
|
var _cfg = {
|
|
2010
|
-
|
|
2011
|
-
//
|
|
2113
|
+
// Same-origin. A product that forgets to configure gets the working default rather than the
|
|
2114
|
+
// engine's Azure FQDN, which no browser may call — its ingress admits only the VM that fronts
|
|
2115
|
+
// these apps, so a direct call 403s and reads as "Failed to fetch".
|
|
2116
|
+
engine: "/engine",
|
|
2012
2117
|
product: "",
|
|
2013
2118
|
loginHash: "#/login"
|
|
2014
2119
|
};
|
|
2015
2120
|
function configureAuth(cfg) {
|
|
2016
2121
|
Object.assign(_cfg, cfg);
|
|
2017
2122
|
if (!_cfg.product) throw new Error("configureAuth: product is required");
|
|
2018
|
-
if (!_cfg.engine) throw new Error("configureAuth: engine (auth backend base URL) is required");
|
|
2019
2123
|
}
|
|
2020
2124
|
function authConfig() {
|
|
2021
2125
|
return { ..._cfg };
|
|
@@ -2380,31 +2484,746 @@ function AuthForm({ onDone, subtitle: subtitle2, brand = null, productName = ""
|
|
|
2380
2484
|
}
|
|
2381
2485
|
|
|
2382
2486
|
// src/sheet/SheetGrid.jsx
|
|
2383
|
-
var
|
|
2487
|
+
var import_react17 = require("react");
|
|
2488
|
+
|
|
2489
|
+
// src/mention/MentionInput.jsx
|
|
2490
|
+
var import_react16 = __toESM(require("react"), 1);
|
|
2491
|
+
|
|
2492
|
+
// src/components/Popover.jsx
|
|
2493
|
+
var import_react15 = __toESM(require("react"), 1);
|
|
2384
2494
|
var import_react_dom2 = require("react-dom");
|
|
2385
2495
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2386
|
-
var
|
|
2387
|
-
var
|
|
2388
|
-
|
|
2496
|
+
var GAP = 6;
|
|
2497
|
+
var MARGIN = 8;
|
|
2498
|
+
function Popover(props) {
|
|
2499
|
+
const {
|
|
2500
|
+
open,
|
|
2501
|
+
anchorRef,
|
|
2502
|
+
onClose,
|
|
2503
|
+
width = 280,
|
|
2504
|
+
minHeight = 140,
|
|
2505
|
+
placement = "auto",
|
|
2506
|
+
children,
|
|
2507
|
+
className,
|
|
2508
|
+
label
|
|
2509
|
+
} = props;
|
|
2510
|
+
const popRef = (0, import_react15.useRef)(null);
|
|
2511
|
+
const [pos, setPos] = (0, import_react15.useState)(null);
|
|
2512
|
+
(0, import_react15.useEffect)(() => {
|
|
2513
|
+
if (!open) {
|
|
2514
|
+
setPos(null);
|
|
2515
|
+
return void 0;
|
|
2516
|
+
}
|
|
2517
|
+
const place = () => {
|
|
2518
|
+
const el = anchorRef?.current;
|
|
2519
|
+
if (!el) return;
|
|
2520
|
+
const r = el.getBoundingClientRect();
|
|
2521
|
+
const vw = window.innerWidth;
|
|
2522
|
+
const vh = window.innerHeight;
|
|
2523
|
+
const w = Math.min(width, vw - MARGIN * 2);
|
|
2524
|
+
const below = vh - r.bottom - GAP - MARGIN;
|
|
2525
|
+
const above = r.top - GAP - MARGIN;
|
|
2526
|
+
const up = placement === "above" || placement === "auto" && below < minHeight && above > below;
|
|
2527
|
+
const maxHeight = Math.max(minHeight, Math.floor(up ? above : below));
|
|
2528
|
+
const left = Math.max(MARGIN, Math.min(r.left, vw - w - MARGIN));
|
|
2529
|
+
setPos(up ? { left, bottom: Math.round(vh - r.top + GAP), width: w, maxHeight } : { left, top: Math.round(r.bottom + GAP), width: w, maxHeight });
|
|
2530
|
+
};
|
|
2531
|
+
place();
|
|
2532
|
+
window.addEventListener("resize", place);
|
|
2533
|
+
window.addEventListener("scroll", place, true);
|
|
2534
|
+
return () => {
|
|
2535
|
+
window.removeEventListener("resize", place);
|
|
2536
|
+
window.removeEventListener("scroll", place, true);
|
|
2537
|
+
};
|
|
2538
|
+
}, [open, anchorRef, width, minHeight, placement]);
|
|
2539
|
+
(0, import_react15.useEffect)(() => {
|
|
2540
|
+
if (!open) return void 0;
|
|
2541
|
+
const onDown = (e) => {
|
|
2542
|
+
if (popRef.current?.contains(e.target)) return;
|
|
2543
|
+
if (anchorRef?.current?.contains(e.target)) return;
|
|
2544
|
+
onClose?.();
|
|
2545
|
+
};
|
|
2546
|
+
document.addEventListener("pointerdown", onDown);
|
|
2547
|
+
return () => document.removeEventListener("pointerdown", onDown);
|
|
2548
|
+
}, [open, anchorRef, onClose]);
|
|
2549
|
+
const escape = (0, import_react15.useCallback)(() => onClose?.(), [onClose]);
|
|
2550
|
+
useOverlayEscape(open, escape);
|
|
2551
|
+
if (!open || !pos || typeof document === "undefined") return null;
|
|
2552
|
+
return (0, import_react_dom2.createPortal)(
|
|
2553
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2554
|
+
"div",
|
|
2555
|
+
{
|
|
2556
|
+
ref: popRef,
|
|
2557
|
+
className: ["uic-pop", className || ""].filter(Boolean).join(" "),
|
|
2558
|
+
style: pos,
|
|
2559
|
+
role: "dialog",
|
|
2560
|
+
"aria-label": label,
|
|
2561
|
+
children
|
|
2562
|
+
}
|
|
2563
|
+
),
|
|
2564
|
+
document.body
|
|
2565
|
+
);
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
// src/mention/mentionModel.js
|
|
2569
|
+
var CURLY = Object.freeze({ open: "{{", close: "}}" });
|
|
2570
|
+
var AT = Object.freeze({ open: "@", close: "" });
|
|
2571
|
+
var CHAT_LINK = Object.freeze({
|
|
2572
|
+
write: (item) => `[@${item.name}](#m-${item.id})`,
|
|
2573
|
+
pattern: /\[@(?<name>[^\]\n]+)\]\(#m-(?<id>[^)\s]+)\)/g
|
|
2574
|
+
});
|
|
2575
|
+
function makeResolver(items) {
|
|
2576
|
+
const byName = /* @__PURE__ */ new Map();
|
|
2577
|
+
const byId = /* @__PURE__ */ new Map();
|
|
2578
|
+
for (const it of items || []) {
|
|
2579
|
+
if (!it) continue;
|
|
2580
|
+
if (it.name) byName.set(it.name, it);
|
|
2581
|
+
if (it.id != null) byId.set(String(it.id), it);
|
|
2582
|
+
}
|
|
2583
|
+
const names = [...byName.keys()].sort((a, b) => b.length - a.length);
|
|
2584
|
+
return { get: (name) => byName.get(name) || null, byId: (id) => byId.get(String(id)) || null, names };
|
|
2585
|
+
}
|
|
2586
|
+
function parsePattern(text, format, resolver) {
|
|
2587
|
+
const out = [];
|
|
2588
|
+
const re = new RegExp(format.pattern.source, format.pattern.flags.includes("g") ? format.pattern.flags : format.pattern.flags + "g");
|
|
2589
|
+
let last = 0;
|
|
2590
|
+
let m;
|
|
2591
|
+
while (m = re.exec(text)) {
|
|
2592
|
+
if (m.index > last) out.push({ type: "text", text: text.slice(last, m.index) });
|
|
2593
|
+
const id = m.groups && m.groups.id != null ? m.groups.id : null;
|
|
2594
|
+
const name = m.groups && m.groups.name || "";
|
|
2595
|
+
const item = id != null && resolver && resolver.byId(id) || resolver && resolver.get(name) || { id: id ?? name, name, kind: null };
|
|
2596
|
+
out.push({ type: "mention", id: item.id, name: item.name || name, kind: item.kind || null, item });
|
|
2597
|
+
last = m.index + m[0].length;
|
|
2598
|
+
}
|
|
2599
|
+
if (last < text.length) out.push({ type: "text", text: text.slice(last) });
|
|
2600
|
+
return out;
|
|
2601
|
+
}
|
|
2602
|
+
function parseValue(value, format, resolver) {
|
|
2603
|
+
const text = value == null ? "" : String(value);
|
|
2604
|
+
if (format && format.pattern) return parsePattern(text, format, resolver);
|
|
2605
|
+
const { open, close } = format || CURLY;
|
|
2606
|
+
const out = [];
|
|
2607
|
+
let buf = "";
|
|
2608
|
+
let i = 0;
|
|
2609
|
+
const flush = () => {
|
|
2610
|
+
if (buf) {
|
|
2611
|
+
out.push({ type: "text", text: buf });
|
|
2612
|
+
buf = "";
|
|
2613
|
+
}
|
|
2614
|
+
};
|
|
2615
|
+
while (i < text.length) {
|
|
2616
|
+
if (resolver && text.startsWith(open, i)) {
|
|
2617
|
+
const boundary = close ? true : i === 0 || /[\s([{"'>]/.test(text[i - 1]);
|
|
2618
|
+
let hit = null;
|
|
2619
|
+
if (boundary) {
|
|
2620
|
+
for (const name of resolver.names) {
|
|
2621
|
+
const start = i + open.length;
|
|
2622
|
+
if (text.startsWith(name, start)) {
|
|
2623
|
+
const end = start + name.length;
|
|
2624
|
+
if (!close || text.startsWith(close, end)) {
|
|
2625
|
+
if (close || end === text.length || /[\s.,;:!?)\]}"']/.test(text[end])) {
|
|
2626
|
+
hit = { name, end: end + close.length };
|
|
2627
|
+
break;
|
|
2628
|
+
}
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2633
|
+
if (hit) {
|
|
2634
|
+
flush();
|
|
2635
|
+
const item = resolver.get(hit.name);
|
|
2636
|
+
out.push({ type: "mention", id: item.id, name: item.name, kind: item.kind || null, item });
|
|
2637
|
+
i = hit.end;
|
|
2638
|
+
continue;
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
buf += text[i];
|
|
2642
|
+
i += 1;
|
|
2643
|
+
}
|
|
2644
|
+
flush();
|
|
2645
|
+
return out;
|
|
2646
|
+
}
|
|
2647
|
+
function serializeSegments(segments, format) {
|
|
2648
|
+
const f = format || CURLY;
|
|
2649
|
+
if (f.write) return (segments || []).map((s) => s.type === "mention" ? f.write(s.item || s) : s.text).join("");
|
|
2650
|
+
const { open, close } = f;
|
|
2651
|
+
return (segments || []).map((s) => s.type === "mention" ? `${open}${s.name}${close}` : s.text).join("");
|
|
2652
|
+
}
|
|
2653
|
+
function mentionsOf(segments) {
|
|
2654
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2655
|
+
const out = [];
|
|
2656
|
+
for (const s of segments || []) {
|
|
2657
|
+
if (s.type !== "mention" || seen.has(s.id)) continue;
|
|
2658
|
+
seen.add(s.id);
|
|
2659
|
+
out.push({ id: s.id, name: s.name, kind: s.kind || null });
|
|
2660
|
+
}
|
|
2661
|
+
return out;
|
|
2662
|
+
}
|
|
2663
|
+
function norm(s) {
|
|
2664
|
+
return String(s || "").toLowerCase();
|
|
2665
|
+
}
|
|
2666
|
+
function subsequence(hay, needle) {
|
|
2667
|
+
let j = 0;
|
|
2668
|
+
for (let i = 0; i < hay.length && j < needle.length; i++) if (hay[i] === needle[j]) j++;
|
|
2669
|
+
return j === needle.length;
|
|
2670
|
+
}
|
|
2671
|
+
function scoreItem(item, query) {
|
|
2672
|
+
const q = norm(query).trim();
|
|
2673
|
+
if (!q) return 1;
|
|
2674
|
+
const name = norm(item.name);
|
|
2675
|
+
if (name === q) return 120;
|
|
2676
|
+
if (name.startsWith(q)) return 100;
|
|
2677
|
+
if (name.split(/[\s_-]+/).some((w) => w.startsWith(q))) return 80;
|
|
2678
|
+
if (name.includes(q)) return 60;
|
|
2679
|
+
const initials = name.split(/[\s_-]+/).map((w) => w[0]).join("");
|
|
2680
|
+
if (initials.startsWith(q)) return 50;
|
|
2681
|
+
if (subsequence(name, q)) return 30;
|
|
2682
|
+
const desc = norm(item.description);
|
|
2683
|
+
if (desc && desc.includes(q)) return 20;
|
|
2684
|
+
const kws = (item.keywords || []).map(norm);
|
|
2685
|
+
if (kws.some((k) => k.includes(q))) return 15;
|
|
2686
|
+
return 0;
|
|
2687
|
+
}
|
|
2688
|
+
function searchItems(items, query) {
|
|
2689
|
+
const scored = (items || []).map((it, i) => ({ it, i, s: scoreItem(it, query) })).filter((x) => x.s > 0);
|
|
2690
|
+
scored.sort((a, b) => b.s - a.s || a.i - b.i);
|
|
2691
|
+
return scored.map((x) => x.it);
|
|
2692
|
+
}
|
|
2693
|
+
function groupItems(items, query) {
|
|
2694
|
+
const groups = /* @__PURE__ */ new Map();
|
|
2695
|
+
for (const it of searchItems(items, query)) {
|
|
2696
|
+
const key = it.section || "";
|
|
2697
|
+
if (!groups.has(key)) groups.set(key, []);
|
|
2698
|
+
groups.get(key).push(it);
|
|
2699
|
+
}
|
|
2700
|
+
const order = [""];
|
|
2701
|
+
for (const it of items || []) {
|
|
2702
|
+
const k = it.section || "";
|
|
2703
|
+
if (!order.includes(k)) order.push(k);
|
|
2704
|
+
}
|
|
2705
|
+
return order.filter((k) => groups.has(k)).map((k) => ({ section: k, items: groups.get(k) }));
|
|
2706
|
+
}
|
|
2707
|
+
function activeTrigger(textBeforeCaret, trigger = "@", maxLen = 48) {
|
|
2708
|
+
const at = textBeforeCaret.lastIndexOf(trigger);
|
|
2709
|
+
if (at < 0) return null;
|
|
2710
|
+
if (at > 0 && !/[\s([{"'>]/.test(textBeforeCaret[at - 1])) return null;
|
|
2711
|
+
const query = textBeforeCaret.slice(at + trigger.length);
|
|
2712
|
+
if (query.length > maxLen || /\n/.test(query)) return null;
|
|
2713
|
+
return { start: at, query };
|
|
2714
|
+
}
|
|
2715
|
+
|
|
2716
|
+
// src/mention/MentionInput.jsx
|
|
2717
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2718
|
+
var MENTION_ATTR = "data-mention-id";
|
|
2719
|
+
function monogram(name) {
|
|
2720
|
+
const parts = String(name || "").trim().split(/\s+/).filter(Boolean);
|
|
2721
|
+
return ((parts[0] || "")[0] || "") + ((parts[1] || "")[0] || "") || "?";
|
|
2722
|
+
}
|
|
2723
|
+
function buildPillNode(item) {
|
|
2724
|
+
const el = document.createElement("span");
|
|
2725
|
+
el.className = "uic-mention";
|
|
2726
|
+
el.setAttribute(MENTION_ATTR, item.id);
|
|
2727
|
+
el.setAttribute("data-name", item.name);
|
|
2728
|
+
if (item.kind) el.setAttribute("data-kind", item.kind);
|
|
2729
|
+
el.setAttribute("contenteditable", "false");
|
|
2730
|
+
if (item.description) el.title = item.description;
|
|
2731
|
+
if (item.color) el.style.setProperty("--uic-mention-color", item.color);
|
|
2732
|
+
const ic = document.createElement("span");
|
|
2733
|
+
ic.className = "uic-mention-ic";
|
|
2734
|
+
if (item.avatar) {
|
|
2735
|
+
const img = document.createElement("img");
|
|
2736
|
+
img.src = item.avatar;
|
|
2737
|
+
img.alt = "";
|
|
2738
|
+
ic.appendChild(img);
|
|
2739
|
+
} else {
|
|
2740
|
+
ic.textContent = typeof item.icon === "string" && item.icon ? item.icon : monogram(item.name);
|
|
2741
|
+
if (!(typeof item.icon === "string" && item.icon)) ic.classList.add("is-mono");
|
|
2742
|
+
}
|
|
2743
|
+
const nm = document.createElement("span");
|
|
2744
|
+
nm.className = "uic-mention-name";
|
|
2745
|
+
nm.textContent = item.name;
|
|
2746
|
+
el.appendChild(ic);
|
|
2747
|
+
el.appendChild(nm);
|
|
2748
|
+
return el;
|
|
2749
|
+
}
|
|
2750
|
+
function readSegments(root, resolver) {
|
|
2751
|
+
const out = [];
|
|
2752
|
+
let buf = "";
|
|
2753
|
+
const flush = () => {
|
|
2754
|
+
if (buf) {
|
|
2755
|
+
out.push({ type: "text", text: buf });
|
|
2756
|
+
buf = "";
|
|
2757
|
+
}
|
|
2758
|
+
};
|
|
2759
|
+
const walk = (node, isLastAtRoot) => {
|
|
2760
|
+
const kids = Array.from(node.childNodes);
|
|
2761
|
+
kids.forEach((k, i) => {
|
|
2762
|
+
const last = isLastAtRoot && i === kids.length - 1;
|
|
2763
|
+
if (k.nodeType === 3) {
|
|
2764
|
+
buf += k.data.replace(/\u00a0/g, " ");
|
|
2765
|
+
return;
|
|
2766
|
+
}
|
|
2767
|
+
if (k.nodeType !== 1) return;
|
|
2768
|
+
const tag = k.tagName;
|
|
2769
|
+
if (tag === "BR") {
|
|
2770
|
+
if (!last) buf += "\n";
|
|
2771
|
+
return;
|
|
2772
|
+
}
|
|
2773
|
+
if (k.hasAttribute(MENTION_ATTR)) {
|
|
2774
|
+
flush();
|
|
2775
|
+
const id = k.getAttribute(MENTION_ATTR);
|
|
2776
|
+
const name = k.getAttribute("data-name") || "";
|
|
2777
|
+
const item = resolver.get(name) || { id, name, kind: k.getAttribute("data-kind") || null };
|
|
2778
|
+
out.push({ type: "mention", id: item.id, name: item.name, kind: item.kind || null, item });
|
|
2779
|
+
return;
|
|
2780
|
+
}
|
|
2781
|
+
if (tag === "DIV" || tag === "P") {
|
|
2782
|
+
if (out.length || buf) buf += "\n";
|
|
2783
|
+
walk(k, last);
|
|
2784
|
+
return;
|
|
2785
|
+
}
|
|
2786
|
+
walk(k, last);
|
|
2787
|
+
});
|
|
2788
|
+
};
|
|
2789
|
+
walk(root, true);
|
|
2790
|
+
flush();
|
|
2791
|
+
return out;
|
|
2792
|
+
}
|
|
2793
|
+
function writeSegments(root, segments) {
|
|
2794
|
+
root.textContent = "";
|
|
2795
|
+
for (const s of segments) {
|
|
2796
|
+
if (s.type === "mention") {
|
|
2797
|
+
root.appendChild(buildPillNode(s.item || s));
|
|
2798
|
+
continue;
|
|
2799
|
+
}
|
|
2800
|
+
const lines = String(s.text).split("\n");
|
|
2801
|
+
lines.forEach((line, i) => {
|
|
2802
|
+
if (i > 0) root.appendChild(document.createElement("br"));
|
|
2803
|
+
if (line) root.appendChild(document.createTextNode(line));
|
|
2804
|
+
});
|
|
2805
|
+
}
|
|
2806
|
+
root.appendChild(document.createElement("br"));
|
|
2807
|
+
}
|
|
2808
|
+
function placeCaretAfter(node) {
|
|
2809
|
+
const sel = window.getSelection();
|
|
2810
|
+
if (!sel) return;
|
|
2811
|
+
const r = document.createRange();
|
|
2812
|
+
r.setStartAfter(node);
|
|
2813
|
+
r.collapse(true);
|
|
2814
|
+
sel.removeAllRanges();
|
|
2815
|
+
sel.addRange(r);
|
|
2816
|
+
}
|
|
2817
|
+
function selectionIn(root) {
|
|
2818
|
+
const sel = typeof window !== "undefined" ? window.getSelection() : null;
|
|
2819
|
+
if (!sel || !sel.rangeCount) return null;
|
|
2820
|
+
const r = sel.getRangeAt(0);
|
|
2821
|
+
if (!root.contains(r.startContainer)) return null;
|
|
2822
|
+
return { sel, range: r };
|
|
2823
|
+
}
|
|
2824
|
+
var MentionInput = (0, import_react16.forwardRef)(function MentionInput2(props, ref) {
|
|
2825
|
+
const {
|
|
2826
|
+
value = "",
|
|
2827
|
+
onChange,
|
|
2828
|
+
items = [],
|
|
2829
|
+
format = CURLY,
|
|
2830
|
+
trigger = "@",
|
|
2831
|
+
placeholder,
|
|
2832
|
+
disabled = false,
|
|
2833
|
+
onSubmit,
|
|
2834
|
+
submitOnEnter = false,
|
|
2835
|
+
autoFocus = false,
|
|
2836
|
+
className = "",
|
|
2837
|
+
label,
|
|
2838
|
+
menuWidth = 360,
|
|
2839
|
+
menuTitle,
|
|
2840
|
+
emptyText = "No match",
|
|
2841
|
+
renderIcon,
|
|
2842
|
+
onOpenChange,
|
|
2843
|
+
onFocus,
|
|
2844
|
+
onBlur,
|
|
2845
|
+
onKeyDown,
|
|
2846
|
+
id
|
|
2847
|
+
} = props;
|
|
2848
|
+
const editorRef = (0, import_react16.useRef)(null);
|
|
2849
|
+
const resolver = (0, import_react16.useMemo)(() => makeResolver(items), [items]);
|
|
2850
|
+
const [menu, setMenu] = (0, import_react16.useState)(null);
|
|
2851
|
+
const [active, setActive] = (0, import_react16.useState)(0);
|
|
2852
|
+
const [empty, setEmpty] = (0, import_react16.useState)(!value);
|
|
2853
|
+
const listId = (0, import_react16.useMemo)(() => `uic-mention-${Math.random().toString(36).slice(2, 8)}`, []);
|
|
2854
|
+
const emit = (0, import_react16.useCallback)(() => {
|
|
2855
|
+
const root = editorRef.current;
|
|
2856
|
+
if (!root) return;
|
|
2857
|
+
const segs = readSegments(root, resolver);
|
|
2858
|
+
const next = serializeSegments(segs, format);
|
|
2859
|
+
setEmpty(!next);
|
|
2860
|
+
if (onChange) onChange(next, mentionsOf(segs));
|
|
2861
|
+
}, [resolver, format, onChange]);
|
|
2862
|
+
(0, import_react16.useLayoutEffect)(() => {
|
|
2863
|
+
const root = editorRef.current;
|
|
2864
|
+
if (!root) return;
|
|
2865
|
+
const current = serializeSegments(readSegments(root, resolver), format);
|
|
2866
|
+
if (current === (value || "")) return;
|
|
2867
|
+
writeSegments(root, parseValue(value || "", format, resolver));
|
|
2868
|
+
setEmpty(!value);
|
|
2869
|
+
}, [value, resolver, format]);
|
|
2870
|
+
(0, import_react16.useEffect)(() => {
|
|
2871
|
+
if (autoFocus && editorRef.current) editorRef.current.focus();
|
|
2872
|
+
}, [autoFocus]);
|
|
2873
|
+
const closeMenu = (0, import_react16.useCallback)(() => setMenu(null), []);
|
|
2874
|
+
(0, import_react16.useEffect)(() => {
|
|
2875
|
+
if (onOpenChange) onOpenChange(!!menu);
|
|
2876
|
+
}, [menu, onOpenChange]);
|
|
2877
|
+
const groups = (0, import_react16.useMemo)(() => menu ? groupItems(items, menu.query) : [], [items, menu]);
|
|
2878
|
+
const flat = (0, import_react16.useMemo)(() => groups.flatMap((g) => g.items), [groups]);
|
|
2879
|
+
(0, import_react16.useEffect)(() => {
|
|
2880
|
+
setActive(0);
|
|
2881
|
+
}, [menu && menu.query, groups.length]);
|
|
2882
|
+
const syncMenu = (0, import_react16.useCallback)(() => {
|
|
2883
|
+
const root = editorRef.current;
|
|
2884
|
+
const s = root && selectionIn(root);
|
|
2885
|
+
if (!s || !s.range.collapsed) {
|
|
2886
|
+
setMenu(null);
|
|
2887
|
+
return;
|
|
2888
|
+
}
|
|
2889
|
+
const node = s.range.startContainer;
|
|
2890
|
+
if (node.nodeType !== 3) {
|
|
2891
|
+
setMenu(null);
|
|
2892
|
+
return;
|
|
2893
|
+
}
|
|
2894
|
+
const hit = activeTrigger(node.data.slice(0, s.range.startOffset), trigger);
|
|
2895
|
+
if (!hit) {
|
|
2896
|
+
setMenu(null);
|
|
2897
|
+
return;
|
|
2898
|
+
}
|
|
2899
|
+
const r = document.createRange();
|
|
2900
|
+
r.setStart(node, hit.start);
|
|
2901
|
+
r.setEnd(node, Math.min(node.data.length, hit.start + 1));
|
|
2902
|
+
const rect = r.getBoundingClientRect();
|
|
2903
|
+
setMenu({ node, start: hit.start, query: hit.query, rect: rect.width || rect.height ? rect : root.getBoundingClientRect() });
|
|
2904
|
+
}, [trigger]);
|
|
2905
|
+
const anchorRef = (0, import_react16.useMemo)(() => ({
|
|
2906
|
+
current: {
|
|
2907
|
+
getBoundingClientRect: () => menu ? menu.rect : new DOMRect(),
|
|
2908
|
+
contains: () => false
|
|
2909
|
+
}
|
|
2910
|
+
}), [menu]);
|
|
2911
|
+
const insertPill = (0, import_react16.useCallback)((item, replace) => {
|
|
2912
|
+
const root = editorRef.current;
|
|
2913
|
+
if (!root || !item || item.disabled) return;
|
|
2914
|
+
const pill = buildPillNode(item);
|
|
2915
|
+
const space = document.createTextNode("\xA0");
|
|
2916
|
+
if (replace && replace.node && replace.node.parentNode === root) {
|
|
2917
|
+
const { node, start, query } = replace;
|
|
2918
|
+
node.deleteData(start, trigger.length + query.length);
|
|
2919
|
+
const after = node.splitText(start);
|
|
2920
|
+
root.insertBefore(pill, after);
|
|
2921
|
+
root.insertBefore(space, after);
|
|
2922
|
+
} else {
|
|
2923
|
+
const s = selectionIn(root);
|
|
2924
|
+
if (s) {
|
|
2925
|
+
s.range.deleteContents();
|
|
2926
|
+
s.range.insertNode(space);
|
|
2927
|
+
s.range.insertNode(pill);
|
|
2928
|
+
} else {
|
|
2929
|
+
root.appendChild(pill);
|
|
2930
|
+
root.appendChild(space);
|
|
2931
|
+
}
|
|
2932
|
+
}
|
|
2933
|
+
placeCaretAfter(space);
|
|
2934
|
+
setMenu(null);
|
|
2935
|
+
emit();
|
|
2936
|
+
}, [emit, trigger]);
|
|
2937
|
+
const pick = (0, import_react16.useCallback)((item) => insertPill(item, menu), [insertPill, menu]);
|
|
2938
|
+
const insertText = (0, import_react16.useCallback)((text) => {
|
|
2939
|
+
const root = editorRef.current;
|
|
2940
|
+
if (!root) return;
|
|
2941
|
+
root.focus();
|
|
2942
|
+
let done = false;
|
|
2943
|
+
try {
|
|
2944
|
+
done = document.execCommand("insertText", false, text);
|
|
2945
|
+
} catch {
|
|
2946
|
+
done = false;
|
|
2947
|
+
}
|
|
2948
|
+
if (!done) {
|
|
2949
|
+
const s = selectionIn(root);
|
|
2950
|
+
const tn = document.createTextNode(text);
|
|
2951
|
+
if (s) {
|
|
2952
|
+
s.range.deleteContents();
|
|
2953
|
+
s.range.insertNode(tn);
|
|
2954
|
+
placeCaretAfter(tn);
|
|
2955
|
+
} else root.appendChild(tn);
|
|
2956
|
+
}
|
|
2957
|
+
emit();
|
|
2958
|
+
syncMenu();
|
|
2959
|
+
}, [emit, syncMenu]);
|
|
2960
|
+
const wrapSelection = (0, import_react16.useCallback)((before, after = "") => {
|
|
2961
|
+
const root = editorRef.current;
|
|
2962
|
+
if (!root) return;
|
|
2963
|
+
root.focus();
|
|
2964
|
+
const s = selectionIn(root);
|
|
2965
|
+
const selected = s ? s.range.toString() : "";
|
|
2966
|
+
insertText(before + selected + after);
|
|
2967
|
+
if (!selected && after) {
|
|
2968
|
+
const sel = window.getSelection();
|
|
2969
|
+
for (let i = 0; i < after.length; i++) sel && sel.modify && sel.modify("move", "backward", "character");
|
|
2970
|
+
}
|
|
2971
|
+
}, [insertText]);
|
|
2972
|
+
const prefixLine = (0, import_react16.useCallback)((prefix) => {
|
|
2973
|
+
const root = editorRef.current;
|
|
2974
|
+
if (!root) return;
|
|
2975
|
+
root.focus();
|
|
2976
|
+
const s = selectionIn(root);
|
|
2977
|
+
const node = s && s.range.startContainer;
|
|
2978
|
+
const before = node && node.nodeType === 3 ? node.data.slice(0, s.range.startOffset) : "";
|
|
2979
|
+
const atLineStart = !before || /\n$/.test(before) || node && node.nodeType !== 3;
|
|
2980
|
+
insertText((atLineStart ? "" : "\n") + prefix);
|
|
2981
|
+
}, [insertText]);
|
|
2982
|
+
(0, import_react16.useImperativeHandle)(ref, () => ({
|
|
2983
|
+
focus: () => editorRef.current && editorRef.current.focus(),
|
|
2984
|
+
clear: () => {
|
|
2985
|
+
const root = editorRef.current;
|
|
2986
|
+
if (root) {
|
|
2987
|
+
writeSegments(root, []);
|
|
2988
|
+
emit();
|
|
2989
|
+
}
|
|
2990
|
+
},
|
|
2991
|
+
insertMention: (item) => insertPill(item, null),
|
|
2992
|
+
insertText,
|
|
2993
|
+
wrapSelection,
|
|
2994
|
+
prefixLine,
|
|
2995
|
+
get el() {
|
|
2996
|
+
return editorRef.current;
|
|
2997
|
+
}
|
|
2998
|
+
}), [emit, insertPill, insertText, wrapSelection, prefixLine]);
|
|
2999
|
+
const handleInput = () => {
|
|
3000
|
+
emit();
|
|
3001
|
+
syncMenu();
|
|
3002
|
+
};
|
|
3003
|
+
const handleKeyDown = (e) => {
|
|
3004
|
+
if (onKeyDown) onKeyDown(e);
|
|
3005
|
+
if (e.defaultPrevented) return;
|
|
3006
|
+
if (menu) {
|
|
3007
|
+
if (e.key === "ArrowDown") {
|
|
3008
|
+
e.preventDefault();
|
|
3009
|
+
setActive((a) => flat.length ? (a + 1) % flat.length : 0);
|
|
3010
|
+
return;
|
|
3011
|
+
}
|
|
3012
|
+
if (e.key === "ArrowUp") {
|
|
3013
|
+
e.preventDefault();
|
|
3014
|
+
setActive((a) => flat.length ? (a - 1 + flat.length) % flat.length : 0);
|
|
3015
|
+
return;
|
|
3016
|
+
}
|
|
3017
|
+
if ((e.key === "Enter" || e.key === "Tab") && flat.length) {
|
|
3018
|
+
e.preventDefault();
|
|
3019
|
+
pick(flat[active]);
|
|
3020
|
+
return;
|
|
3021
|
+
}
|
|
3022
|
+
if (e.key === "Escape") {
|
|
3023
|
+
e.preventDefault();
|
|
3024
|
+
setMenu(null);
|
|
3025
|
+
return;
|
|
3026
|
+
}
|
|
3027
|
+
}
|
|
3028
|
+
if (e.key === "Enter") {
|
|
3029
|
+
if (submitOnEnter && !e.shiftKey) {
|
|
3030
|
+
e.preventDefault();
|
|
3031
|
+
if (onSubmit) onSubmit();
|
|
3032
|
+
return;
|
|
3033
|
+
}
|
|
3034
|
+
e.preventDefault();
|
|
3035
|
+
insertText("\n");
|
|
3036
|
+
}
|
|
3037
|
+
};
|
|
3038
|
+
const handlePaste = (e) => {
|
|
3039
|
+
e.preventDefault();
|
|
3040
|
+
const text = e.clipboardData && e.clipboardData.getData("text/plain") || "";
|
|
3041
|
+
if (!text) return;
|
|
3042
|
+
const segs = parseValue(text, format, resolver);
|
|
3043
|
+
if (segs.every((s2) => s2.type === "text")) {
|
|
3044
|
+
insertText(text);
|
|
3045
|
+
return;
|
|
3046
|
+
}
|
|
3047
|
+
const root = editorRef.current;
|
|
3048
|
+
const s = selectionIn(root);
|
|
3049
|
+
if (!s) {
|
|
3050
|
+
insertText(text);
|
|
3051
|
+
return;
|
|
3052
|
+
}
|
|
3053
|
+
s.range.deleteContents();
|
|
3054
|
+
const frag = document.createDocumentFragment();
|
|
3055
|
+
let lastNode = null;
|
|
3056
|
+
for (const seg of segs) {
|
|
3057
|
+
if (seg.type === "mention") {
|
|
3058
|
+
lastNode = buildPillNode(seg.item || seg);
|
|
3059
|
+
frag.appendChild(lastNode);
|
|
3060
|
+
continue;
|
|
3061
|
+
}
|
|
3062
|
+
seg.text.split("\n").forEach((line, i) => {
|
|
3063
|
+
if (i > 0) {
|
|
3064
|
+
lastNode = document.createElement("br");
|
|
3065
|
+
frag.appendChild(lastNode);
|
|
3066
|
+
}
|
|
3067
|
+
if (line) {
|
|
3068
|
+
lastNode = document.createTextNode(line);
|
|
3069
|
+
frag.appendChild(lastNode);
|
|
3070
|
+
}
|
|
3071
|
+
});
|
|
3072
|
+
}
|
|
3073
|
+
s.range.insertNode(frag);
|
|
3074
|
+
if (lastNode) placeCaretAfter(lastNode);
|
|
3075
|
+
emit();
|
|
3076
|
+
syncMenu();
|
|
3077
|
+
};
|
|
3078
|
+
const handleBlur = (e) => {
|
|
3079
|
+
if (onBlur) onBlur(e);
|
|
3080
|
+
};
|
|
3081
|
+
const handleFocus = (e) => {
|
|
3082
|
+
if (onFocus) onFocus(e);
|
|
3083
|
+
};
|
|
3084
|
+
(0, import_react16.useEffect)(() => {
|
|
3085
|
+
if (!menu) return void 0;
|
|
3086
|
+
const onSel = () => syncMenu();
|
|
3087
|
+
document.addEventListener("selectionchange", onSel);
|
|
3088
|
+
return () => document.removeEventListener("selectionchange", onSel);
|
|
3089
|
+
}, [menu, syncMenu]);
|
|
3090
|
+
(0, import_react16.useEffect)(() => {
|
|
3091
|
+
if (!menu) return;
|
|
3092
|
+
const el = document.getElementById(`${listId}-${active}`);
|
|
3093
|
+
const list = el && el.closest(".uic-mention-menu");
|
|
3094
|
+
if (!el || !list) return;
|
|
3095
|
+
const top = el.offsetTop - list.offsetTop;
|
|
3096
|
+
const bottom = top + el.offsetHeight;
|
|
3097
|
+
if (top < list.scrollTop) list.scrollTop = top;
|
|
3098
|
+
else if (bottom > list.scrollTop + list.clientHeight) list.scrollTop = bottom - list.clientHeight;
|
|
3099
|
+
}, [active, menu, listId]);
|
|
3100
|
+
const iconOf = (item) => {
|
|
3101
|
+
if (renderIcon) {
|
|
3102
|
+
const n = renderIcon(item);
|
|
3103
|
+
if (n) return n;
|
|
3104
|
+
}
|
|
3105
|
+
if (item.avatar) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("img", { src: item.avatar, alt: "" });
|
|
3106
|
+
if (typeof item.icon === "string" && item.icon) return item.icon;
|
|
3107
|
+
if (item.icon) return item.icon;
|
|
3108
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "is-mono", children: monogram(item.name) });
|
|
3109
|
+
};
|
|
3110
|
+
let index = -1;
|
|
3111
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: ["uic-mention-field", disabled ? "is-disabled" : "", className].filter(Boolean).join(" "), children: [
|
|
3112
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3113
|
+
"div",
|
|
3114
|
+
{
|
|
3115
|
+
ref: editorRef,
|
|
3116
|
+
id,
|
|
3117
|
+
className: "uic-mention-editor" + (empty ? " is-empty" : ""),
|
|
3118
|
+
contentEditable: !disabled,
|
|
3119
|
+
suppressContentEditableWarning: true,
|
|
3120
|
+
role: "textbox",
|
|
3121
|
+
"aria-multiline": "true",
|
|
3122
|
+
"aria-label": label,
|
|
3123
|
+
"aria-autocomplete": "list",
|
|
3124
|
+
"aria-expanded": !!menu,
|
|
3125
|
+
"aria-controls": menu ? listId : void 0,
|
|
3126
|
+
"aria-activedescendant": menu && flat.length ? `${listId}-${active}` : void 0,
|
|
3127
|
+
"data-placeholder": placeholder || "",
|
|
3128
|
+
spellCheck: "true",
|
|
3129
|
+
onInput: handleInput,
|
|
3130
|
+
onKeyDown: handleKeyDown,
|
|
3131
|
+
onPaste: handlePaste,
|
|
3132
|
+
onFocus: handleFocus,
|
|
3133
|
+
onBlur: handleBlur
|
|
3134
|
+
}
|
|
3135
|
+
),
|
|
3136
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Popover, { open: !!menu, anchorRef, onClose: closeMenu, width: menuWidth, minHeight: 120, className: "uic-mention-pop", label: menuTitle || "Mentions", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "uic-mention-menu", role: "listbox", id: listId, onMouseDown: (e) => e.preventDefault(), children: [
|
|
3137
|
+
menuTitle ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "uic-mention-head", children: menuTitle }) : null,
|
|
3138
|
+
groups.map((g) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "uic-mention-group", children: [
|
|
3139
|
+
g.section ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "uic-mention-sec", children: g.section }) : null,
|
|
3140
|
+
g.items.map((item) => {
|
|
3141
|
+
index += 1;
|
|
3142
|
+
const i = index;
|
|
3143
|
+
const dis = !!item.disabled;
|
|
3144
|
+
const reason = typeof item.disabled === "string" ? item.disabled : null;
|
|
3145
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
3146
|
+
"button",
|
|
3147
|
+
{
|
|
3148
|
+
type: "button",
|
|
3149
|
+
id: `${listId}-${i}`,
|
|
3150
|
+
role: "option",
|
|
3151
|
+
"aria-selected": i === active,
|
|
3152
|
+
"aria-disabled": dis || void 0,
|
|
3153
|
+
className: "uic-mention-item" + (i === active ? " is-active" : "") + (dis ? " is-disabled" : ""),
|
|
3154
|
+
style: item.color ? { "--uic-mention-color": item.color } : void 0,
|
|
3155
|
+
onMouseEnter: () => setActive(i),
|
|
3156
|
+
onClick: () => {
|
|
3157
|
+
if (!dis) pick(item);
|
|
3158
|
+
},
|
|
3159
|
+
children: [
|
|
3160
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "uic-mention-ic", children: iconOf(item) }),
|
|
3161
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "uic-mention-text", children: [
|
|
3162
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "uic-mention-name", children: item.name }),
|
|
3163
|
+
item.description ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "uic-mention-desc", children: item.description }) : null
|
|
3164
|
+
] }),
|
|
3165
|
+
reason || item.tag ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "uic-mention-tag", children: reason || item.tag }) : null
|
|
3166
|
+
]
|
|
3167
|
+
},
|
|
3168
|
+
item.id
|
|
3169
|
+
);
|
|
3170
|
+
})
|
|
3171
|
+
] }, g.section || "_")),
|
|
3172
|
+
!flat.length ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "uic-mention-empty", children: emptyText }) : null
|
|
3173
|
+
] }) })
|
|
3174
|
+
] });
|
|
3175
|
+
});
|
|
3176
|
+
function MentionText({ value, items = [], format = CURLY, className = "", renderIcon }) {
|
|
3177
|
+
const resolver = (0, import_react16.useMemo)(() => makeResolver(items), [items]);
|
|
3178
|
+
const segs = (0, import_react16.useMemo)(() => parseValue(value || "", format, resolver), [value, format, resolver]);
|
|
3179
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: ["uic-mention-text-view", className].filter(Boolean).join(" "), children: segs.map((s, i) => {
|
|
3180
|
+
if (s.type === "text") return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react16.default.Fragment, { children: s.text }, i);
|
|
3181
|
+
const item = s.item || s;
|
|
3182
|
+
const icon = renderIcon ? renderIcon(item) : null;
|
|
3183
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
3184
|
+
"span",
|
|
3185
|
+
{
|
|
3186
|
+
className: "uic-mention",
|
|
3187
|
+
"data-kind": s.kind || void 0,
|
|
3188
|
+
title: item.description || void 0,
|
|
3189
|
+
style: item.color ? { "--uic-mention-color": item.color } : void 0,
|
|
3190
|
+
children: [
|
|
3191
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "uic-mention-ic" + (icon || typeof item.icon === "string" && item.icon || item.avatar ? "" : " is-mono"), children: icon || (item.avatar ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("img", { src: item.avatar, alt: "" }) : typeof item.icon === "string" && item.icon ? item.icon : monogram(item.name)) }),
|
|
3192
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "uic-mention-name", children: s.name })
|
|
3193
|
+
]
|
|
3194
|
+
},
|
|
3195
|
+
i
|
|
3196
|
+
);
|
|
3197
|
+
}) });
|
|
3198
|
+
}
|
|
3199
|
+
|
|
3200
|
+
// src/sheet/SheetGrid.jsx
|
|
3201
|
+
var import_react_dom3 = require("react-dom");
|
|
3202
|
+
|
|
3203
|
+
// src/collab/colors.js
|
|
3204
|
+
function withAlpha(hex, alpha) {
|
|
3205
|
+
const m = /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(String(hex || ""));
|
|
3206
|
+
if (!m) return hex;
|
|
3207
|
+
return `rgba(${parseInt(m[1], 16)}, ${parseInt(m[2], 16)}, ${parseInt(m[3], 16)}, ${alpha})`;
|
|
3208
|
+
}
|
|
3209
|
+
|
|
3210
|
+
// src/sheet/SheetGrid.jsx
|
|
3211
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2389
3212
|
var cellKey = (rowId, colId) => `${rowId}:${colId}`;
|
|
2390
3213
|
var uid = (p) => `${p}_${Math.random().toString(36).slice(2, 10)}`;
|
|
2391
|
-
var
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
configKey: "compute",
|
|
2405
|
-
badge: (col) => col.compute?.kind
|
|
2406
|
-
}
|
|
2407
|
-
];
|
|
3214
|
+
var TYPE_LABEL = {
|
|
3215
|
+
text: "Text",
|
|
3216
|
+
number: "Number",
|
|
3217
|
+
select: "Select",
|
|
3218
|
+
tags: "Tags",
|
|
3219
|
+
checkbox: "Checkbox",
|
|
3220
|
+
date: "Date",
|
|
3221
|
+
url: "Link",
|
|
3222
|
+
resource: "Resource",
|
|
3223
|
+
compute: "Computed"
|
|
3224
|
+
};
|
|
3225
|
+
var TYPE_GLYPH = { text: "Aa", number: "#", select: "\u25BE", tags: "#", checkbox: "\u2713", date: "\u25A6", url: "\u2197", resource: "\u25EB", compute: "\u2726" };
|
|
3226
|
+
var MANUAL_TYPES = ["text", "number", "select", "tags", "checkbox", "date", "url", "resource"];
|
|
2408
3227
|
var COMPUTE_KINDS = [
|
|
2409
3228
|
{ kind: "prompt", label: "AI prompt" },
|
|
2410
3229
|
{ kind: "harness", label: "Agent (harness)" },
|
|
@@ -2414,33 +3233,39 @@ var COMPUTE_KINDS = [
|
|
|
2414
3233
|
var RESOURCE_KINDS = ["image", "sheet", "slides", "workflow", "graph"];
|
|
2415
3234
|
var RESOURCE_ICON = { image: "\u{1F5BC}", sheet: "\u25A6", slides: "\u25A4", workflow: "\u2699", graph: "\u25C9" };
|
|
2416
3235
|
function PopPortal({ anchor, width = 250, estHeight = 300, className, children, onClose }) {
|
|
2417
|
-
const boxRef = (0,
|
|
2418
|
-
(0,
|
|
3236
|
+
const boxRef = (0, import_react17.useRef)(null);
|
|
3237
|
+
(0, import_react17.useEffect)(() => {
|
|
2419
3238
|
if (!onClose) return void 0;
|
|
2420
|
-
const close = () =>
|
|
2421
|
-
|
|
2422
|
-
if (boxRef.current && boxRef.current.contains(e.target)) return;
|
|
2423
|
-
if (anchor && e.clientX >= anchor.left && e.clientX <= anchor.right && e.clientY >= anchor.top && e.clientY <= anchor.bottom) return;
|
|
3239
|
+
const close = (e) => {
|
|
3240
|
+
if (e?.type === "scroll" && boxRef.current && e.target instanceof Node && boxRef.current.contains(e.target)) return;
|
|
2424
3241
|
onClose();
|
|
2425
3242
|
};
|
|
2426
|
-
window.addEventListener("mousedown", onDown);
|
|
2427
3243
|
window.addEventListener("scroll", close, true);
|
|
2428
3244
|
window.addEventListener("resize", close);
|
|
2429
3245
|
return () => {
|
|
2430
|
-
window.removeEventListener("mousedown", onDown);
|
|
2431
3246
|
window.removeEventListener("scroll", close, true);
|
|
2432
3247
|
window.removeEventListener("resize", close);
|
|
2433
3248
|
};
|
|
2434
|
-
}, [onClose
|
|
3249
|
+
}, [onClose]);
|
|
2435
3250
|
if (!anchor) return null;
|
|
2436
3251
|
const left = Math.max(8, Math.min(anchor.right - width, window.innerWidth - width - 8));
|
|
2437
3252
|
let top = anchor.bottom + 6;
|
|
2438
3253
|
if (top + estHeight > window.innerHeight - 8) top = Math.max(8, anchor.top - estHeight - 6);
|
|
2439
|
-
return (0,
|
|
2440
|
-
/* @__PURE__ */ (0,
|
|
3254
|
+
return (0, import_react_dom3.createPortal)(
|
|
3255
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { ref: boxRef, className, style: { position: "fixed", top, left, width, zIndex: 1e3 }, children }),
|
|
2441
3256
|
document.body
|
|
2442
3257
|
);
|
|
2443
3258
|
}
|
|
3259
|
+
var PILL_PALETTE = [
|
|
3260
|
+
{ name: "green", color: "#D1FAE5" },
|
|
3261
|
+
{ name: "red", color: "#FEE2E2" },
|
|
3262
|
+
{ name: "amber", color: "#FEF3C7" },
|
|
3263
|
+
{ name: "blue", color: "#DBEAFE" },
|
|
3264
|
+
{ name: "purple", color: "#EDE9FE" },
|
|
3265
|
+
{ name: "pink", color: "#FCE7F3" },
|
|
3266
|
+
{ name: "teal", color: "#CCFBF1" },
|
|
3267
|
+
{ name: "gray", color: "#E5E7EB" }
|
|
3268
|
+
];
|
|
2444
3269
|
var PILL_FALLBACKS = ["#E0E7FF", "#FCE7F3", "#D1FAE5", "#FEF3C7", "#E0F2FE", "#F3E8FF", "#FFE4E6"];
|
|
2445
3270
|
function normOptions(options) {
|
|
2446
3271
|
return (options || []).map((o, i) => {
|
|
@@ -2448,17 +3273,21 @@ function normOptions(options) {
|
|
|
2448
3273
|
return { label: o.label ?? String(o.value ?? ""), color: o.color || PILL_FALLBACKS[i % PILL_FALLBACKS.length] };
|
|
2449
3274
|
});
|
|
2450
3275
|
}
|
|
3276
|
+
var sameValue = (a, b) => String(a).trim().toLowerCase() === String(b).trim().toLowerCase();
|
|
3277
|
+
function optionFor(value, options) {
|
|
3278
|
+
if (value === void 0 || value === null || value === "") return null;
|
|
3279
|
+
return normOptions(options).find((o) => sameValue(o.label, value)) || null;
|
|
3280
|
+
}
|
|
2451
3281
|
function pillColor(label, options) {
|
|
2452
|
-
const
|
|
2453
|
-
const hit = opts.find((o) => o.label === label);
|
|
3282
|
+
const hit = optionFor(label, options);
|
|
2454
3283
|
if (hit) return hit.color;
|
|
2455
3284
|
let h = 0;
|
|
2456
3285
|
for (const ch of String(label)) h = h * 31 + ch.charCodeAt(0) >>> 0;
|
|
2457
3286
|
return PILL_FALLBACKS[h % PILL_FALLBACKS.length];
|
|
2458
3287
|
}
|
|
2459
3288
|
function RefImage({ refVal, fetchBlobUrl }) {
|
|
2460
|
-
const [src, setSrc] = (0,
|
|
2461
|
-
(0,
|
|
3289
|
+
const [src, setSrc] = (0, import_react17.useState)(/^https?:\/\//i.test(refVal.url || "") ? refVal.url : null);
|
|
3290
|
+
(0, import_react17.useEffect)(() => {
|
|
2462
3291
|
let dead = false;
|
|
2463
3292
|
let obj = null;
|
|
2464
3293
|
if (!src && refVal.url && fetchBlobUrl) {
|
|
@@ -2474,16 +3303,16 @@ function RefImage({ refVal, fetchBlobUrl }) {
|
|
|
2474
3303
|
if (obj) URL.revokeObjectURL(obj);
|
|
2475
3304
|
};
|
|
2476
3305
|
}, [refVal.url]);
|
|
2477
|
-
if (!src) return /* @__PURE__ */ (0,
|
|
3306
|
+
if (!src) return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "shg-refchip", children: [
|
|
2478
3307
|
RESOURCE_ICON.image,
|
|
2479
3308
|
" ",
|
|
2480
3309
|
refVal.name || "image"
|
|
2481
3310
|
] });
|
|
2482
|
-
return /* @__PURE__ */ (0,
|
|
3311
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("img", { className: "shg-refimg", src, alt: refVal.name || "", title: refVal.name || "" });
|
|
2483
3312
|
}
|
|
2484
3313
|
function ResourceChip({ refVal, onOpen }) {
|
|
2485
3314
|
const icon = RESOURCE_ICON[refVal.kind] || "\u25C7";
|
|
2486
|
-
return /* @__PURE__ */ (0,
|
|
3315
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2487
3316
|
"button",
|
|
2488
3317
|
{
|
|
2489
3318
|
className: "shg-refchip shg-refchip-btn",
|
|
@@ -2493,74 +3322,112 @@ function ResourceChip({ refVal, onOpen }) {
|
|
|
2493
3322
|
onOpen && onOpen(refVal);
|
|
2494
3323
|
},
|
|
2495
3324
|
children: [
|
|
2496
|
-
/* @__PURE__ */ (0,
|
|
2497
|
-
/* @__PURE__ */ (0,
|
|
3325
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "shg-refchip-ic", children: icon }),
|
|
3326
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "shg-refchip-name", children: refVal.name || refVal.id || refVal.kind })
|
|
2498
3327
|
]
|
|
2499
3328
|
}
|
|
2500
3329
|
);
|
|
2501
3330
|
}
|
|
2502
3331
|
function StatusDot({ status }) {
|
|
2503
|
-
if (!status || status === "empty") return null;
|
|
2504
|
-
return /* @__PURE__ */ (0,
|
|
3332
|
+
if (!status || status === "empty" || status === "done") return null;
|
|
3333
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: `shg-dot shg-dot-${status}`, title: status });
|
|
2505
3334
|
}
|
|
2506
3335
|
function CellValue({ cell, col, fetchBlobUrl, onOpenResource }) {
|
|
2507
3336
|
const v = cell?.value;
|
|
2508
|
-
if (v === void 0 || v === null || v === "") return /* @__PURE__ */ (0,
|
|
3337
|
+
if (v === void 0 || v === null || v === "") return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "shg-val-txt" });
|
|
2509
3338
|
if (v && typeof v === "object" && !Array.isArray(v) && v.kind) {
|
|
2510
|
-
if (v.kind === "image") return /* @__PURE__ */ (0,
|
|
2511
|
-
return /* @__PURE__ */ (0,
|
|
3339
|
+
if (v.kind === "image") return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(RefImage, { refVal: v, fetchBlobUrl });
|
|
3340
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ResourceChip, { refVal: v, onOpen: onOpenResource });
|
|
2512
3341
|
}
|
|
3342
|
+
const styled = col.type !== "tags" && optionFor(v, col.options);
|
|
3343
|
+
if (styled) return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "shg-pill", style: { background: styled.color }, children: styled.label });
|
|
2513
3344
|
switch (col.type) {
|
|
2514
3345
|
case "select":
|
|
2515
|
-
return /* @__PURE__ */ (0,
|
|
3346
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "shg-pill", style: { background: pillColor(String(v), col.options) }, children: String(v) });
|
|
2516
3347
|
case "tags": {
|
|
2517
3348
|
const tags = Array.isArray(v) ? v : String(v).split(",").map((s) => s.trim()).filter(Boolean);
|
|
2518
|
-
return /* @__PURE__ */ (0,
|
|
3349
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "shg-pills", children: tags.map((t) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "shg-pill", style: { background: pillColor(t, col.options) }, children: t }, t)) });
|
|
2519
3350
|
}
|
|
2520
3351
|
case "checkbox":
|
|
2521
|
-
return /* @__PURE__ */ (0,
|
|
3352
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "shg-check" + (v ? " on" : ""), children: v ? "\u2713" : "" });
|
|
2522
3353
|
case "url": {
|
|
2523
3354
|
const href = /^https?:\/\//i.test(String(v)) ? String(v) : `https://${v}`;
|
|
2524
|
-
return /* @__PURE__ */ (0,
|
|
3355
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("a", { className: "shg-link", href, target: "_blank", rel: "noreferrer", onClick: (e) => e.stopPropagation(), children: String(v) });
|
|
2525
3356
|
}
|
|
2526
3357
|
case "number":
|
|
2527
|
-
return /* @__PURE__ */ (0,
|
|
3358
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "shg-val-txt shg-num", children: String(v) });
|
|
2528
3359
|
default:
|
|
2529
|
-
return /* @__PURE__ */ (0,
|
|
3360
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "shg-val-txt", children: typeof v === "object" ? JSON.stringify(v) : String(v) });
|
|
2530
3361
|
}
|
|
2531
3362
|
}
|
|
2532
|
-
function SheetGrid({
|
|
2533
|
-
sheet,
|
|
2534
|
-
onChange,
|
|
2535
|
-
onRunCell,
|
|
2536
|
-
onRunColumn,
|
|
2537
|
-
readOnly = false,
|
|
2538
|
-
fetchBlobUrl,
|
|
2539
|
-
onOpenResource,
|
|
2540
|
-
peerMarks,
|
|
2541
|
-
onActiveCell,
|
|
2542
|
-
columnTypes = DEFAULT_COLUMN_TYPES,
|
|
2543
|
-
renderCell,
|
|
2544
|
-
renderColumnConfig
|
|
2545
|
-
}) {
|
|
3363
|
+
function SheetGrid({ sheet, ops, onRunCell, onRunColumn, readOnly = false, fetchBlobUrl, onOpenResource, peers, onPresence }) {
|
|
2546
3364
|
const columns = sheet?.columns || [];
|
|
2547
3365
|
const rows = sheet?.rows || [];
|
|
2548
3366
|
const cells = sheet?.cells || {};
|
|
2549
|
-
const
|
|
2550
|
-
const
|
|
2551
|
-
const [
|
|
2552
|
-
const [
|
|
2553
|
-
const [
|
|
2554
|
-
const [
|
|
2555
|
-
const
|
|
2556
|
-
const
|
|
2557
|
-
const
|
|
2558
|
-
const
|
|
2559
|
-
const
|
|
2560
|
-
const
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
3367
|
+
const tabId = sheet?.id;
|
|
3368
|
+
const canEdit = !readOnly && !!ops && !!tabId;
|
|
3369
|
+
const [editing, setEditing] = (0, import_react17.useState)(null);
|
|
3370
|
+
const [draft, setDraft] = (0, import_react17.useState)("");
|
|
3371
|
+
const [menuCol, setMenuCol] = (0, import_react17.useState)(null);
|
|
3372
|
+
const [sizeDraft, setSizeDraft] = (0, import_react17.useState)({});
|
|
3373
|
+
const [dnd, setDnd] = (0, import_react17.useState)(null);
|
|
3374
|
+
const [dropAt, setDropAt] = (0, import_react17.useState)(null);
|
|
3375
|
+
const inputRef = (0, import_react17.useRef)(null);
|
|
3376
|
+
const dragRef = (0, import_react17.useRef)(null);
|
|
3377
|
+
const [sel, setSel] = (0, import_react17.useState)(null);
|
|
3378
|
+
const dragSel = (0, import_react17.useRef)(false);
|
|
3379
|
+
const rootRef = (0, import_react17.useRef)(null);
|
|
3380
|
+
const presenceRef = (0, import_react17.useRef)(onPresence);
|
|
3381
|
+
presenceRef.current = onPresence;
|
|
3382
|
+
const range = sel ? {
|
|
3383
|
+
r0: Math.min(sel.a.r, sel.f.r),
|
|
3384
|
+
r1: Math.max(sel.a.r, sel.f.r),
|
|
3385
|
+
c0: Math.min(sel.a.c, sel.f.c),
|
|
3386
|
+
c1: Math.max(sel.a.c, sel.f.c)
|
|
3387
|
+
} : null;
|
|
3388
|
+
const inSel = (ri, ci) => !!range && ri >= range.r0 && ri <= range.r1 && ci >= range.c0 && ci <= range.c1;
|
|
3389
|
+
const isFocus = (ri, ci) => !!sel && sel.f.r === ri && sel.f.c === ci;
|
|
3390
|
+
const clampSel = (p) => ({ r: Math.max(0, Math.min(p.r, rows.length - 1)), c: Math.max(0, Math.min(p.c, columns.length - 1)) });
|
|
3391
|
+
const moveFocus = (dr, dc, extend) => setSel((cur) => {
|
|
3392
|
+
if (!cur || !rows.length || !columns.length) return cur;
|
|
3393
|
+
const f = clampSel({ r: cur.f.r + dr, c: cur.f.c + dc });
|
|
3394
|
+
return { a: extend ? cur.a : f, f };
|
|
3395
|
+
});
|
|
3396
|
+
(0, import_react17.useEffect)(() => {
|
|
3397
|
+
const up = () => {
|
|
3398
|
+
dragSel.current = false;
|
|
3399
|
+
};
|
|
3400
|
+
window.addEventListener("mouseup", up);
|
|
3401
|
+
return () => window.removeEventListener("mouseup", up);
|
|
3402
|
+
}, []);
|
|
3403
|
+
(0, import_react17.useEffect)(() => {
|
|
3404
|
+
const fn = presenceRef.current;
|
|
3405
|
+
if (!fn) return;
|
|
3406
|
+
const ids = (p) => [rows[p.r]?.id, columns[p.c]?.id];
|
|
3407
|
+
fn({
|
|
3408
|
+
sel: sel && rows[sel.f.r] && columns[sel.f.c] ? { a: ids(sel.a), f: ids(sel.f) } : null,
|
|
3409
|
+
typing: editing && typeof draft === "string" ? { key: cellKey(editing.rowId, editing.colId), text: draft } : null
|
|
3410
|
+
});
|
|
3411
|
+
}, [sel, editing, draft, rows, columns]);
|
|
3412
|
+
const peerLayer = (0, import_react17.useMemo)(() => {
|
|
3413
|
+
const focus = {}, tint = {}, typing = {};
|
|
3414
|
+
const rIdx = new Map(rows.map((r, i) => [r.id, i]));
|
|
3415
|
+
const cIdx = new Map(columns.map((c, i) => [c.id, i]));
|
|
3416
|
+
for (const p of peers || []) {
|
|
3417
|
+
if (p.typing && p.typing.key) typing[p.typing.key] = { text: p.typing.text, color: p.color, name: p.name };
|
|
3418
|
+
if (!p.sel || !p.sel.a || !p.sel.f) continue;
|
|
3419
|
+
const a = { r: rIdx.get(p.sel.a[0]), c: cIdx.get(p.sel.a[1]) }, f = { r: rIdx.get(p.sel.f[0]), c: cIdx.get(p.sel.f[1]) };
|
|
3420
|
+
if ([a.r, a.c, f.r, f.c].some((v) => v === void 0)) continue;
|
|
3421
|
+
focus[cellKey(p.sel.f[0], p.sel.f[1])] = p;
|
|
3422
|
+
for (let r = Math.min(a.r, f.r); r <= Math.max(a.r, f.r); r++) {
|
|
3423
|
+
for (let c = Math.min(a.c, f.c); c <= Math.max(a.c, f.c); c++) {
|
|
3424
|
+
const k = cellKey(rows[r].id, columns[c].id);
|
|
3425
|
+
if (!tint[k]) tint[k] = p.color;
|
|
3426
|
+
}
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3429
|
+
return { focus, tint, typing };
|
|
3430
|
+
}, [peers, rows, columns]);
|
|
2564
3431
|
const startResize = (e, kind, id, start) => {
|
|
2565
3432
|
if (readOnly) return;
|
|
2566
3433
|
e.preventDefault();
|
|
@@ -2583,34 +3450,32 @@ function SheetGrid({
|
|
|
2583
3450
|
document.body.style.cursor = "";
|
|
2584
3451
|
if (!d) return;
|
|
2585
3452
|
setSizeDraft({});
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
});
|
|
3453
|
+
if (!canEdit) return;
|
|
3454
|
+
if (d.kind === "col") {
|
|
3455
|
+
const c = columns.find((x) => x.id === d.id);
|
|
3456
|
+
if (c) ops.setColumn(tabId, { ...c, width: Math.round(d.last) });
|
|
3457
|
+
} else {
|
|
3458
|
+
const r = rows.find((x) => x.id === d.id);
|
|
3459
|
+
if (r) ops.setRow(tabId, { ...r, height: Math.round(d.last) });
|
|
3460
|
+
}
|
|
2595
3461
|
};
|
|
2596
3462
|
window.addEventListener("mousemove", onMove);
|
|
2597
3463
|
window.addEventListener("mouseup", onUp);
|
|
2598
3464
|
document.body.style.cursor = kind === "col" ? "col-resize" : "row-resize";
|
|
2599
3465
|
};
|
|
2600
3466
|
const colWidth = (col) => sizeDraft.col && sizeDraft.col[col.id] || col.width || void 0;
|
|
2601
|
-
const reorder = (kind, fromId, toId, after) =>
|
|
2602
|
-
|
|
2603
|
-
const
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
return;
|
|
2610
|
-
}
|
|
3467
|
+
const reorder = (kind, fromId, toId, after) => {
|
|
3468
|
+
if (!canEdit || fromId === toId) return;
|
|
3469
|
+
const arr = (kind === "col" ? columns : rows).map((x) => x.id);
|
|
3470
|
+
const i = arr.indexOf(fromId);
|
|
3471
|
+
if (i < 0) return;
|
|
3472
|
+
arr.splice(i, 1);
|
|
3473
|
+
let j = arr.indexOf(toId);
|
|
3474
|
+
if (j < 0) return;
|
|
2611
3475
|
if (after) j += 1;
|
|
2612
|
-
|
|
2613
|
-
|
|
3476
|
+
if (kind === "col") ops.moveColumn(tabId, fromId, j);
|
|
3477
|
+
else ops.moveRow(tabId, fromId, j);
|
|
3478
|
+
};
|
|
2614
3479
|
const dndProps = (kind, id) => readOnly ? {} : {
|
|
2615
3480
|
draggable: true,
|
|
2616
3481
|
onDragStart: (e) => {
|
|
@@ -2652,53 +3517,19 @@ function SheetGrid({
|
|
|
2652
3517
|
}
|
|
2653
3518
|
return cls;
|
|
2654
3519
|
};
|
|
2655
|
-
const numW = Math.max(
|
|
3520
|
+
const numW = Math.max(40, 24 + String(rows.length || 1).length * 9);
|
|
2656
3521
|
const numStyle = { width: numW, minWidth: numW, maxWidth: numW };
|
|
2657
3522
|
const rowHeight = (row) => sizeDraft.row && sizeDraft.row[row.id] || row.height || void 0;
|
|
2658
|
-
(0,
|
|
2659
|
-
if (editing && inputRef.current) inputRef.current.focus();
|
|
2660
|
-
}, [editing]);
|
|
2661
|
-
(
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
const trs = Array.from(rowsEl);
|
|
2665
|
-
for (const tr of trs) {
|
|
2666
|
-
tr.style.removeProperty("--shg-clamp");
|
|
2667
|
-
for (const td of tr.children) td.style.setProperty("--shg-clamp", "1");
|
|
2668
|
-
}
|
|
2669
|
-
const plan = trs.map((tr) => ({
|
|
2670
|
-
base: tr.offsetHeight,
|
|
2671
|
-
cells: Array.from(tr.children).map((td) => {
|
|
2672
|
-
const txt = td.querySelector(CLAMP_TEXT_SEL);
|
|
2673
|
-
const box = txt && txt.parentElement;
|
|
2674
|
-
return { td, extra: box ? Math.max(0, box.scrollHeight - txt.offsetHeight) : 0 };
|
|
2675
|
-
})
|
|
2676
|
-
}));
|
|
2677
|
-
for (const { base, cells: cells2 } of plan) {
|
|
2678
|
-
const floorLines = Math.max(1, Math.floor((base - CLAMP_PAD) / CLAMP_LINE));
|
|
2679
|
-
const need = Math.max(...cells2.map((c) => c.extra)) + floorLines * CLAMP_LINE + CLAMP_PAD;
|
|
2680
|
-
for (const { td, extra } of cells2) {
|
|
2681
|
-
const lines = Math.max(floorLines, Math.floor((need - extra - CLAMP_PAD) / CLAMP_LINE));
|
|
2682
|
-
td.style.setProperty("--shg-clamp", String(lines));
|
|
2683
|
-
}
|
|
2684
|
-
}
|
|
2685
|
-
});
|
|
2686
|
-
const mutate = (fn) => {
|
|
2687
|
-
if (readOnly || !onChange) return;
|
|
2688
|
-
const next = JSON.parse(JSON.stringify(sheet));
|
|
2689
|
-
fn(next);
|
|
2690
|
-
onChange(next);
|
|
3523
|
+
(0, import_react17.useEffect)(() => {
|
|
3524
|
+
if (editing && inputRef.current) inputRef.current.focus();
|
|
3525
|
+
}, [editing]);
|
|
3526
|
+
const setCell = (rowId, colId, value) => {
|
|
3527
|
+
if (!canEdit) return;
|
|
3528
|
+
ops.setCell(tabId, cellKey(rowId, colId), { value, status: "done", updated_at: Math.floor(Date.now() / 1e3) });
|
|
2691
3529
|
};
|
|
2692
|
-
const
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
const col = (n.columns || []).find((c) => c.id === colId);
|
|
2696
|
-
const prev = n.cells[k];
|
|
2697
|
-
n.cells[k] = isComputed(col) && prev ? { ...prev, value } : { value };
|
|
2698
|
-
});
|
|
2699
|
-
const openEdit = (rowId, col, anchorEl) => {
|
|
2700
|
-
if (readOnly) return;
|
|
2701
|
-
if (!isEditable(col)) return;
|
|
3530
|
+
const openEdit = (rowId, col, anchorEl, initial) => {
|
|
3531
|
+
if (!canEdit) return;
|
|
3532
|
+
if (col.type === "compute") return;
|
|
2702
3533
|
if (col.type === "checkbox") {
|
|
2703
3534
|
const cur = cells[cellKey(rowId, col.id)];
|
|
2704
3535
|
setCell(rowId, col.id, !(cur && cur.value));
|
|
@@ -2706,14 +3537,12 @@ function SheetGrid({
|
|
|
2706
3537
|
}
|
|
2707
3538
|
const c = cells[cellKey(rowId, col.id)];
|
|
2708
3539
|
const v = c?.value;
|
|
2709
|
-
if (col.type === "tags") setDraft(Array.isArray(v) ? v.join(", ") : v || "");
|
|
3540
|
+
if (col.type === "tags") setDraft(initial ?? (Array.isArray(v) ? v.join(", ") : v || ""));
|
|
2710
3541
|
else if (col.type === "resource") setDraft(v && typeof v === "object" ? v : { kind: "sheet", name: "", id: "", url: "" });
|
|
2711
|
-
else setDraft(v == null ? "" : String(v));
|
|
3542
|
+
else setDraft(initial ?? (v == null ? "" : String(v)));
|
|
2712
3543
|
setEditing({ rowId, colId: col.id, type: col.type, rect: anchorEl?.getBoundingClientRect?.() || null });
|
|
2713
|
-
onActiveCell && onActiveCell(cellKey(rowId, col.id));
|
|
2714
3544
|
};
|
|
2715
3545
|
const commitEdit = () => {
|
|
2716
|
-
onActiveCell && onActiveCell(null);
|
|
2717
3546
|
if (!editing) return;
|
|
2718
3547
|
const { rowId, colId, type } = editing;
|
|
2719
3548
|
let value = draft;
|
|
@@ -2722,37 +3551,129 @@ function SheetGrid({
|
|
|
2722
3551
|
setCell(rowId, colId, value);
|
|
2723
3552
|
setEditing(null);
|
|
2724
3553
|
};
|
|
2725
|
-
const addColumn = () =>
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
const
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
3554
|
+
const addColumn = () => canEdit && ops.setColumn(tabId, { id: uid("col"), name: `Column ${columns.length + 1}`, type: "text" });
|
|
3555
|
+
const addRow = () => canEdit && ops.setRow(tabId, { id: uid("row") });
|
|
3556
|
+
const deleteColumn = (colId) => canEdit && ops.deleteColumn(tabId, colId);
|
|
3557
|
+
const deleteRow = (rowId) => canEdit && ops.deleteRow(tabId, rowId);
|
|
3558
|
+
const renameColumn = (colId, name) => {
|
|
3559
|
+
const c = columns.find((x) => x.id === colId);
|
|
3560
|
+
if (canEdit && c) ops.setColumn(tabId, { ...c, name });
|
|
3561
|
+
};
|
|
3562
|
+
const configureColumn = (colId, patch) => {
|
|
3563
|
+
const c = columns.find((x) => x.id === colId);
|
|
3564
|
+
if (!canEdit || !c) return;
|
|
3565
|
+
const next = { ...c, ...patch };
|
|
3566
|
+
if (patch.type && patch.type !== "compute") delete next.compute;
|
|
3567
|
+
ops.setColumn(tabId, next);
|
|
3568
|
+
};
|
|
3569
|
+
const cellText = (c) => {
|
|
3570
|
+
const v = c?.value;
|
|
3571
|
+
if (v === void 0 || v === null) return "";
|
|
3572
|
+
if (Array.isArray(v)) return v.join(", ");
|
|
3573
|
+
if (typeof v === "object") return v.name || v.url || v.id || "";
|
|
3574
|
+
return String(v);
|
|
3575
|
+
};
|
|
3576
|
+
const copySelection = (e) => {
|
|
3577
|
+
if (!range || editing) return;
|
|
3578
|
+
const lines = [];
|
|
3579
|
+
for (let r = range.r0; r <= range.r1; r++) {
|
|
3580
|
+
const parts = [];
|
|
3581
|
+
for (let c = range.c0; c <= range.c1; c++) parts.push(cellText(cells[cellKey(rows[r].id, columns[c].id)]));
|
|
3582
|
+
lines.push(parts.join(" "));
|
|
2749
3583
|
}
|
|
2750
|
-
|
|
3584
|
+
e.clipboardData.setData("text/plain", lines.join("\n"));
|
|
3585
|
+
e.preventDefault();
|
|
3586
|
+
};
|
|
3587
|
+
const pasteAt = (e) => {
|
|
3588
|
+
if (!sel || editing || !canEdit) return;
|
|
3589
|
+
const text = e.clipboardData.getData("text/plain");
|
|
3590
|
+
if (!text) return;
|
|
3591
|
+
e.preventDefault();
|
|
3592
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
3593
|
+
const patch = {};
|
|
3594
|
+
const lines = text.replace(/\r/g, "").split("\n");
|
|
3595
|
+
if (lines.length > 1 && lines[lines.length - 1] === "") lines.pop();
|
|
3596
|
+
lines.forEach((line, dr) => line.split(" ").forEach((raw, dc) => {
|
|
3597
|
+
const row = rows[sel.f.r + dr], col = columns[sel.f.c + dc];
|
|
3598
|
+
if (!row || !col || col.type === "compute") return;
|
|
3599
|
+
let value = raw;
|
|
3600
|
+
if (col.type === "number") value = raw === "" ? null : Number(raw);
|
|
3601
|
+
else if (col.type === "checkbox") value = /^(true|yes|1|✓)$/i.test(raw.trim());
|
|
3602
|
+
else if (col.type === "tags") value = raw ? raw.split(",").map((x) => x.trim()).filter(Boolean) : [];
|
|
3603
|
+
patch[cellKey(row.id, col.id)] = value === null || value === "" ? null : { value, status: "done", updated_at: now };
|
|
3604
|
+
}));
|
|
3605
|
+
if (Object.keys(patch).length) ops.setCells(tabId, patch);
|
|
3606
|
+
setSel({ a: sel.f, f: clampSel({ r: sel.f.r + lines.length - 1, c: sel.f.c + Math.max(...lines.map((l) => l.split(" ").length)) - 1 }) });
|
|
3607
|
+
};
|
|
3608
|
+
const clearSelection = () => {
|
|
3609
|
+
if (!range || !canEdit) return;
|
|
3610
|
+
const patch = {};
|
|
3611
|
+
for (let r = range.r0; r <= range.r1; r++) {
|
|
3612
|
+
for (let c = range.c0; c <= range.c1; c++) {
|
|
3613
|
+
if (columns[c].type === "compute") continue;
|
|
3614
|
+
const k = cellKey(rows[r].id, columns[c].id);
|
|
3615
|
+
if (cells[k]) patch[k] = null;
|
|
3616
|
+
}
|
|
3617
|
+
}
|
|
3618
|
+
if (Object.keys(patch).length) ops.setCells(tabId, patch);
|
|
3619
|
+
};
|
|
3620
|
+
const onKeyDown = (e) => {
|
|
3621
|
+
if (editing || menuCol) return;
|
|
3622
|
+
if (!sel) return;
|
|
3623
|
+
const meta = e.metaKey || e.ctrlKey;
|
|
3624
|
+
if (meta && (e.key === "c" || e.key === "v" || e.key === "x")) return;
|
|
3625
|
+
const focusCell = () => ({ row: rows[sel.f.r], col: columns[sel.f.c] });
|
|
3626
|
+
switch (e.key) {
|
|
3627
|
+
case "ArrowUp":
|
|
3628
|
+
e.preventDefault();
|
|
3629
|
+
moveFocus(-1, 0, e.shiftKey);
|
|
3630
|
+
return;
|
|
3631
|
+
case "ArrowDown":
|
|
3632
|
+
e.preventDefault();
|
|
3633
|
+
moveFocus(1, 0, e.shiftKey);
|
|
3634
|
+
return;
|
|
3635
|
+
case "ArrowLeft":
|
|
3636
|
+
e.preventDefault();
|
|
3637
|
+
moveFocus(0, -1, e.shiftKey);
|
|
3638
|
+
return;
|
|
3639
|
+
case "ArrowRight":
|
|
3640
|
+
e.preventDefault();
|
|
3641
|
+
moveFocus(0, 1, e.shiftKey);
|
|
3642
|
+
return;
|
|
3643
|
+
case "Tab":
|
|
3644
|
+
e.preventDefault();
|
|
3645
|
+
moveFocus(0, e.shiftKey ? -1 : 1, false);
|
|
3646
|
+
return;
|
|
3647
|
+
case "Escape":
|
|
3648
|
+
setSel(null);
|
|
3649
|
+
return;
|
|
3650
|
+
case "Enter":
|
|
3651
|
+
case "F2": {
|
|
3652
|
+
e.preventDefault();
|
|
3653
|
+
const { row, col } = focusCell();
|
|
3654
|
+
if (row && col) openEdit(row.id, col, rootRef.current?.querySelector(`[data-cell="${cellKey(row.id, col.id)}"]`));
|
|
3655
|
+
return;
|
|
3656
|
+
}
|
|
3657
|
+
case "Delete":
|
|
3658
|
+
case "Backspace":
|
|
3659
|
+
e.preventDefault();
|
|
3660
|
+
clearSelection();
|
|
3661
|
+
return;
|
|
3662
|
+
default:
|
|
3663
|
+
}
|
|
3664
|
+
if (!meta && !e.altKey && e.key.length === 1) {
|
|
3665
|
+
const { row, col } = focusCell();
|
|
3666
|
+
if (row && col && col.type !== "compute" && col.type !== "checkbox") {
|
|
3667
|
+
e.preventDefault();
|
|
3668
|
+
openEdit(row.id, col, rootRef.current?.querySelector(`[data-cell="${cellKey(row.id, col.id)}"]`), e.key);
|
|
3669
|
+
}
|
|
3670
|
+
}
|
|
3671
|
+
};
|
|
2751
3672
|
const renderEditor = (col) => {
|
|
2752
3673
|
if (col.type === "resource") {
|
|
2753
3674
|
const d = typeof draft === "object" && draft ? draft : { kind: "sheet" };
|
|
2754
3675
|
const set = (k, v) => setDraft({ ...d, [k]: v });
|
|
2755
|
-
return /* @__PURE__ */ (0,
|
|
3676
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2756
3677
|
PopPortal,
|
|
2757
3678
|
{
|
|
2758
3679
|
anchor: editing.rect,
|
|
@@ -2760,17 +3681,17 @@ function SheetGrid({
|
|
|
2760
3681
|
estHeight: 230,
|
|
2761
3682
|
className: "shg-select-pop shg-ref-pop",
|
|
2762
3683
|
onClose: () => setEditing(null),
|
|
2763
|
-
children: /* @__PURE__ */ (0,
|
|
2764
|
-
/* @__PURE__ */ (0,
|
|
2765
|
-
/* @__PURE__ */ (0,
|
|
2766
|
-
/* @__PURE__ */ (0,
|
|
2767
|
-
/* @__PURE__ */ (0,
|
|
2768
|
-
/* @__PURE__ */ (0,
|
|
2769
|
-
/* @__PURE__ */ (0,
|
|
3684
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { onClick: (e) => e.stopPropagation(), children: [
|
|
3685
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("select", { className: "shg-menu-input", value: d.kind || "sheet", onChange: (e) => set("kind", e.target.value), children: RESOURCE_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: k, children: k }, k)) }),
|
|
3686
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("input", { className: "shg-menu-input", placeholder: "Name", value: d.name || "", onChange: (e) => set("name", e.target.value) }),
|
|
3687
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("input", { className: "shg-menu-input", placeholder: "Resource id (e.g. sheet.\u2026)", value: d.id || "", onChange: (e) => set("id", e.target.value) }),
|
|
3688
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("input", { className: "shg-menu-input", placeholder: "or URL", value: d.url || "", onChange: (e) => set("url", e.target.value) }),
|
|
3689
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "shg-menu-actions", children: [
|
|
3690
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { className: "shg-pop-clear", onClick: () => {
|
|
2770
3691
|
setCell(editing.rowId, editing.colId, null);
|
|
2771
3692
|
setEditing(null);
|
|
2772
3693
|
}, children: "Clear" }),
|
|
2773
|
-
/* @__PURE__ */ (0,
|
|
3694
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { className: "shg-menu-apply", onClick: () => {
|
|
2774
3695
|
setCell(editing.rowId, editing.colId, d);
|
|
2775
3696
|
setEditing(null);
|
|
2776
3697
|
}, children: "Set" })
|
|
@@ -2781,7 +3702,7 @@ function SheetGrid({
|
|
|
2781
3702
|
}
|
|
2782
3703
|
if (col.type === "select") {
|
|
2783
3704
|
const opts = normOptions(col.options);
|
|
2784
|
-
return /* @__PURE__ */ (0,
|
|
3705
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2785
3706
|
PopPortal,
|
|
2786
3707
|
{
|
|
2787
3708
|
anchor: editing.rect,
|
|
@@ -2790,8 +3711,8 @@ function SheetGrid({
|
|
|
2790
3711
|
className: "shg-select-pop",
|
|
2791
3712
|
onClose: () => setEditing(null),
|
|
2792
3713
|
children: [
|
|
2793
|
-
opts.length === 0 && /* @__PURE__ */ (0,
|
|
2794
|
-
opts.map((o) => /* @__PURE__ */ (0,
|
|
3714
|
+
opts.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "shg-pop-note", children: "No options yet \u2014 add them in the column menu." }),
|
|
3715
|
+
opts.map((o) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2795
3716
|
"button",
|
|
2796
3717
|
{
|
|
2797
3718
|
className: "shg-pill shg-pill-btn",
|
|
@@ -2805,7 +3726,7 @@ function SheetGrid({
|
|
|
2805
3726
|
},
|
|
2806
3727
|
o.label
|
|
2807
3728
|
)),
|
|
2808
|
-
/* @__PURE__ */ (0,
|
|
3729
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2809
3730
|
"button",
|
|
2810
3731
|
{
|
|
2811
3732
|
className: "shg-pop-clear",
|
|
@@ -2822,7 +3743,7 @@ function SheetGrid({
|
|
|
2822
3743
|
);
|
|
2823
3744
|
}
|
|
2824
3745
|
const inputType = col.type === "date" ? "date" : col.type === "number" ? "number" : "text";
|
|
2825
|
-
return /* @__PURE__ */ (0,
|
|
3746
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2826
3747
|
"input",
|
|
2827
3748
|
{
|
|
2828
3749
|
ref: inputRef,
|
|
@@ -2833,32 +3754,41 @@ function SheetGrid({
|
|
|
2833
3754
|
onChange: (e) => setDraft(e.target.value),
|
|
2834
3755
|
onBlur: commitEdit,
|
|
2835
3756
|
onKeyDown: (e) => {
|
|
2836
|
-
if (e.key === "Enter")
|
|
2837
|
-
|
|
3757
|
+
if (e.key === "Enter") {
|
|
3758
|
+
e.preventDefault();
|
|
3759
|
+
commitEdit();
|
|
3760
|
+
moveFocus(1, 0, false);
|
|
3761
|
+
rootRef.current?.focus();
|
|
3762
|
+
} else if (e.key === "Tab") {
|
|
3763
|
+
e.preventDefault();
|
|
3764
|
+
commitEdit();
|
|
3765
|
+
moveFocus(0, e.shiftKey ? -1 : 1, false);
|
|
3766
|
+
rootRef.current?.focus();
|
|
3767
|
+
} else if (e.key === "Escape") {
|
|
3768
|
+
setEditing(null);
|
|
3769
|
+
rootRef.current?.focus();
|
|
3770
|
+
}
|
|
2838
3771
|
}
|
|
2839
3772
|
}
|
|
2840
3773
|
);
|
|
2841
3774
|
};
|
|
2842
|
-
return /* @__PURE__ */ (0,
|
|
2843
|
-
/* @__PURE__ */ (0,
|
|
2844
|
-
/* @__PURE__ */ (0,
|
|
2845
|
-
columns.map((col) => /* @__PURE__ */ (0,
|
|
3775
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "shg", ref: rootRef, tabIndex: 0, onKeyDown, onCopy: copySelection, onPaste: pasteAt, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "shg-scroll", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("table", { className: "shg-table", children: [
|
|
3776
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("tr", { children: [
|
|
3777
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("th", { className: "shg-corner", style: numStyle }),
|
|
3778
|
+
columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2846
3779
|
"th",
|
|
2847
3780
|
{
|
|
2848
|
-
className: "shg-col" + (
|
|
3781
|
+
className: "shg-col" + (col.type === "compute" ? " shg-col-compute" : "") + dndClass("col", col.id),
|
|
2849
3782
|
style: colWidth(col) ? { width: colWidth(col), minWidth: colWidth(col), maxWidth: colWidth(col) } : void 0,
|
|
2850
3783
|
...dndProps("col", col.id),
|
|
2851
3784
|
children: [
|
|
2852
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
2853
|
-
/* @__PURE__ */ (0,
|
|
3785
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "shg-resize-col", onMouseDown: (e) => startResize(e, "col", col.id, colWidth(col) || e.currentTarget.closest("th").offsetWidth) }),
|
|
3786
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "shg-col-h", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2854
3787
|
ColumnHeader,
|
|
2855
3788
|
{
|
|
2856
3789
|
col,
|
|
2857
3790
|
columns,
|
|
2858
3791
|
readOnly,
|
|
2859
|
-
desc: descOf(col.type),
|
|
2860
|
-
columnTypes,
|
|
2861
|
-
renderColumnConfig,
|
|
2862
3792
|
menuOpen: menuCol?.id === col.id,
|
|
2863
3793
|
menuAnchor: menuCol?.id === col.id ? menuCol.rect : null,
|
|
2864
3794
|
onMenu: (e) => setMenuCol(menuCol?.id === col.id ? null : { id: col.id, rect: e.currentTarget.getBoundingClientRect() }),
|
|
@@ -2869,23 +3799,26 @@ function SheetGrid({
|
|
|
2869
3799
|
setMenuCol(null);
|
|
2870
3800
|
deleteColumn(col.id);
|
|
2871
3801
|
},
|
|
2872
|
-
onRun:
|
|
3802
|
+
onRun: col.type === "compute" && onRunColumn ? () => onRunColumn(col.id) : null,
|
|
3803
|
+
width: colWidth(col)
|
|
2873
3804
|
}
|
|
2874
3805
|
) })
|
|
2875
3806
|
]
|
|
2876
3807
|
},
|
|
2877
3808
|
col.id
|
|
2878
3809
|
)),
|
|
2879
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
3810
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("th", { className: "shg-add-col", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { className: "shg-add", onClick: addColumn, title: "Add column", children: "+" }) })
|
|
2880
3811
|
] }) }),
|
|
2881
|
-
/* @__PURE__ */ (0,
|
|
2882
|
-
rows.map((row, ri) => /* @__PURE__ */ (0,
|
|
3812
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("tbody", { children: [
|
|
3813
|
+
rows.map((row, ri) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2883
3814
|
"tr",
|
|
2884
3815
|
{
|
|
2885
|
-
|
|
2886
|
-
|
|
3816
|
+
style: {
|
|
3817
|
+
...rowHeight(row) ? { height: rowHeight(row) } : null,
|
|
3818
|
+
"--shg-clamp": Math.max(1, Math.floor(((rowHeight(row) || 34) - 10) / 18))
|
|
3819
|
+
},
|
|
2887
3820
|
children: [
|
|
2888
|
-
/* @__PURE__ */ (0,
|
|
3821
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2889
3822
|
"td",
|
|
2890
3823
|
{
|
|
2891
3824
|
className: "shg-rownum" + dndClass("row", row.id),
|
|
@@ -2893,127 +3826,102 @@ function SheetGrid({
|
|
|
2893
3826
|
title: "Drag to reorder",
|
|
2894
3827
|
...dndProps("row", row.id),
|
|
2895
3828
|
children: [
|
|
2896
|
-
/* @__PURE__ */ (0,
|
|
2897
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
2898
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
3829
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: ri + 1 }),
|
|
3830
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { className: "shg-rowdel", onClick: () => deleteRow(row.id), title: "Delete row", children: "\xD7" }),
|
|
3831
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "shg-resize-row", onMouseDown: (e) => startResize(e, "row", row.id, rowHeight(row) || e.currentTarget.closest("tr").offsetHeight) })
|
|
2899
3832
|
]
|
|
2900
3833
|
}
|
|
2901
3834
|
),
|
|
2902
|
-
columns.map((col) => {
|
|
2903
|
-
const
|
|
2904
|
-
const
|
|
3835
|
+
columns.map((col, ci) => {
|
|
3836
|
+
const key = cellKey(row.id, col.id);
|
|
3837
|
+
const c = cells[key] || {};
|
|
2905
3838
|
const isEditing = editing && editing.rowId === row.id && editing.colId === col.id;
|
|
2906
|
-
const peer =
|
|
2907
|
-
const
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
width: colWidth(col),
|
|
2915
|
-
height: rowHeight(row),
|
|
2916
|
-
editing: !!isEditing,
|
|
2917
|
-
readOnly,
|
|
2918
|
-
setCell: (v) => setCell(row.id, col.id, v),
|
|
2919
|
-
runCell: onRunCell && !readOnly ? () => onRunCell(row.id, col.id) : null
|
|
2920
|
-
});
|
|
2921
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
3839
|
+
const peer = peerLayer.focus[key];
|
|
3840
|
+
const ghost = !isEditing && peerLayer.typing[key];
|
|
3841
|
+
const selected = inSel(ri, ci), focused = isFocus(ri, ci);
|
|
3842
|
+
const shadows = [];
|
|
3843
|
+
if (focused) shadows.push("inset 0 0 0 2px var(--brand, #0E7490)");
|
|
3844
|
+
if (peer) shadows.push(`inset 0 0 0 2px ${peer.color}`);
|
|
3845
|
+
const tint = !selected && peerLayer.tint[key];
|
|
3846
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2922
3847
|
"td",
|
|
2923
3848
|
{
|
|
2924
|
-
"data-
|
|
2925
|
-
className: "shg-cell" + (
|
|
2926
|
-
style:
|
|
3849
|
+
"data-cell": key,
|
|
3850
|
+
className: "shg-cell" + (col.type === "compute" ? " shg-cell-compute" : "") + (c.status && col.type === "compute" ? ` shg-cell-${c.status}` : "") + (selected ? " shg-sel" : "") + (focused ? " shg-focus" : "") + (peer ? " shg-cell-peer" : ""),
|
|
3851
|
+
style: {
|
|
3852
|
+
...shadows.length ? { boxShadow: shadows.join(", ") } : null,
|
|
3853
|
+
...tint ? { background: withAlpha(tint, 0.1) } : null
|
|
3854
|
+
},
|
|
3855
|
+
onMouseDown: (e) => {
|
|
3856
|
+
if (e.button !== 0 || isEditing) return;
|
|
3857
|
+
if (editing) commitEdit();
|
|
3858
|
+
const p = { r: ri, c: ci };
|
|
3859
|
+
setSel((cur) => e.shiftKey && cur ? { a: cur.a, f: p } : { a: p, f: p });
|
|
3860
|
+
dragSel.current = true;
|
|
3861
|
+
e.preventDefault();
|
|
3862
|
+
rootRef.current?.focus();
|
|
3863
|
+
},
|
|
3864
|
+
onMouseEnter: () => {
|
|
3865
|
+
if (dragSel.current) setSel((cur) => cur ? { a: cur.a, f: { r: ri, c: ci } } : cur);
|
|
3866
|
+
},
|
|
2927
3867
|
onClick: (e) => {
|
|
3868
|
+
if (col.type === "checkbox" && !isEditing) openEdit(row.id, col, e.currentTarget);
|
|
3869
|
+
},
|
|
3870
|
+
onDoubleClick: (e) => {
|
|
2928
3871
|
if (!isEditing) openEdit(row.id, col, e.currentTarget);
|
|
2929
3872
|
},
|
|
2930
3873
|
title: c.error || "",
|
|
2931
3874
|
children: [
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
3875
|
+
peer && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "shg-peer-flag", style: { background: peer.color }, children: peer.name }),
|
|
3876
|
+
isEditing ? renderEditor(col) : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
3877
|
+
"div",
|
|
3878
|
+
{
|
|
3879
|
+
className: "shg-val",
|
|
3880
|
+
style: { maxWidth: colWidth(col) ? colWidth(col) - 20 : 400 },
|
|
3881
|
+
children: [
|
|
3882
|
+
col.type === "compute" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(StatusDot, { status: c.status }),
|
|
3883
|
+
ghost ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "shg-ghost", style: { color: ghost.color }, title: `${ghost.name} is typing`, children: ghost.text }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CellValue, { cell: c, col, fetchBlobUrl, onOpenResource }),
|
|
3884
|
+
col.type === "compute" && !readOnly && onRunCell && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3885
|
+
"button",
|
|
3886
|
+
{
|
|
3887
|
+
className: "shg-runcell",
|
|
3888
|
+
title: "Run this cell",
|
|
3889
|
+
onClick: (e) => {
|
|
3890
|
+
e.stopPropagation();
|
|
3891
|
+
onRunCell(row.id, col.id);
|
|
3892
|
+
},
|
|
3893
|
+
children: "\u25B6"
|
|
3894
|
+
}
|
|
2943
3895
|
)
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
"span",
|
|
2948
|
-
{
|
|
2949
|
-
className: "shg-resize-row shg-resize-in-cell",
|
|
2950
|
-
onClick: (e) => e.stopPropagation(),
|
|
2951
|
-
onMouseDown: (e) => startResize(
|
|
2952
|
-
e,
|
|
2953
|
-
"row",
|
|
2954
|
-
row.id,
|
|
2955
|
-
rowHeight(row) || e.currentTarget.closest("tr").offsetHeight
|
|
2956
|
-
)
|
|
2957
|
-
}
|
|
2958
|
-
)
|
|
2959
|
-
] }),
|
|
2960
|
-
peer && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "shg-peer-flag", style: { background: peer.color }, children: peer.name }),
|
|
2961
|
-
isEditing ? renderEditor(col) : /* @__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: [
|
|
2962
|
-
computed && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(StatusDot, { status: c.status }),
|
|
2963
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CellValue, { cell: c, col, fetchBlobUrl, onOpenResource }),
|
|
2964
|
-
computed && !readOnly && onRunCell && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2965
|
-
"button",
|
|
2966
|
-
{
|
|
2967
|
-
className: "shg-runcell",
|
|
2968
|
-
title: "Run this cell",
|
|
2969
|
-
onClick: (e) => {
|
|
2970
|
-
e.stopPropagation();
|
|
2971
|
-
onRunCell(row.id, col.id);
|
|
2972
|
-
},
|
|
2973
|
-
children: "\u25B6"
|
|
2974
|
-
}
|
|
2975
|
-
)
|
|
2976
|
-
] }) })
|
|
3896
|
+
]
|
|
3897
|
+
}
|
|
3898
|
+
)
|
|
2977
3899
|
]
|
|
2978
3900
|
},
|
|
2979
3901
|
col.id
|
|
2980
3902
|
);
|
|
2981
3903
|
}),
|
|
2982
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
3904
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("td", { className: "shg-pad" })
|
|
2983
3905
|
]
|
|
2984
3906
|
},
|
|
2985
3907
|
row.id
|
|
2986
3908
|
)),
|
|
2987
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
2988
|
-
/* @__PURE__ */ (0,
|
|
2989
|
-
/* @__PURE__ */ (0,
|
|
3909
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("tr", { className: "shg-ghost-row", onClick: addRow, children: [
|
|
3910
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("td", { className: "shg-rownum shg-ghost-num", style: numStyle, children: "+" }),
|
|
3911
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("td", { className: "shg-ghost-cell", colSpan: columns.length + 1, children: "New row" })
|
|
2990
3912
|
] })
|
|
2991
3913
|
] })
|
|
2992
3914
|
] }) }) });
|
|
2993
3915
|
}
|
|
2994
|
-
function ColumnHeader({
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
onMenu,
|
|
3004
|
-
onCloseMenu,
|
|
3005
|
-
onRename,
|
|
3006
|
-
onConfigure,
|
|
3007
|
-
onDelete,
|
|
3008
|
-
onRun
|
|
3009
|
-
}) {
|
|
3010
|
-
const [editing, setEditing] = (0, import_react15.useState)(false);
|
|
3011
|
-
const [name, setName] = (0, import_react15.useState)(col.name);
|
|
3012
|
-
(0, import_react15.useEffect)(() => setName(col.name), [col.name]);
|
|
3013
|
-
const badge = desc.badge ? desc.badge(col) : void 0;
|
|
3014
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "shg-colhdr", children: [
|
|
3015
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "shg-colhdr-main", children: [
|
|
3016
|
-
editing && !readOnly ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3916
|
+
function ColumnHeader({ col, columns, readOnly, menuOpen, menuAnchor, onMenu, onCloseMenu, onRename, onConfigure, onDelete, onRun, width }) {
|
|
3917
|
+
const [editing, setEditing] = (0, import_react17.useState)(false);
|
|
3918
|
+
const [name, setName] = (0, import_react17.useState)(col.name);
|
|
3919
|
+
(0, import_react17.useEffect)(() => setName(col.name), [col.name]);
|
|
3920
|
+
const w = Number(width) || 0;
|
|
3921
|
+
const fit = w && w < 160 ? " tight" : w && w < 200 ? " narrow" : "";
|
|
3922
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "shg-colhdr" + fit, children: [
|
|
3923
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "shg-colhdr-main", children: [
|
|
3924
|
+
editing && !readOnly ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3017
3925
|
"input",
|
|
3018
3926
|
{
|
|
3019
3927
|
className: "shg-colname-input",
|
|
@@ -3028,24 +3936,25 @@ function ColumnHeader({
|
|
|
3028
3936
|
if (e.key === "Enter") e.target.blur();
|
|
3029
3937
|
}
|
|
3030
3938
|
}
|
|
3031
|
-
) : /* @__PURE__ */ (0,
|
|
3032
|
-
/* @__PURE__ */ (0,
|
|
3033
|
-
|
|
3034
|
-
|
|
3939
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "shg-colname", onDoubleClick: () => !readOnly && setEditing(true), title: col.name, children: col.name }),
|
|
3940
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "shg-coltype" + (col.type === "compute" ? " compute" : ""), children: [
|
|
3941
|
+
TYPE_LABEL[col.type] || col.type,
|
|
3942
|
+
col.type === "compute" && col.compute?.kind ? ` \xB7 ${col.compute.kind}` : ""
|
|
3035
3943
|
] })
|
|
3036
3944
|
] }),
|
|
3037
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
3038
|
-
onRun && /* @__PURE__ */ (0,
|
|
3039
|
-
|
|
3945
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "shg-colhdr-tools", children: [
|
|
3946
|
+
onRun && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("button", { className: "shg-colrun", onClick: onRun, title: "Run this column", "aria-label": "Run this column", children: [
|
|
3947
|
+
"\u25B6",
|
|
3948
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "shg-colrun-label", children: " Run" })
|
|
3949
|
+
] }),
|
|
3950
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { className: "shg-colmenu-btn", onClick: (e) => onMenu(e), title: "Column settings", children: "\u22EF" })
|
|
3040
3951
|
] }),
|
|
3041
|
-
menuOpen && !readOnly && /* @__PURE__ */ (0,
|
|
3952
|
+
menuOpen && !readOnly && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3042
3953
|
ColumnMenu,
|
|
3043
3954
|
{
|
|
3044
3955
|
col,
|
|
3045
3956
|
columns,
|
|
3046
3957
|
anchor: menuAnchor,
|
|
3047
|
-
columnTypes,
|
|
3048
|
-
renderColumnConfig,
|
|
3049
3958
|
onApply: (patch) => {
|
|
3050
3959
|
onConfigure(col.id, patch);
|
|
3051
3960
|
onCloseMenu();
|
|
@@ -3056,30 +3965,130 @@ function ColumnHeader({
|
|
|
3056
3965
|
)
|
|
3057
3966
|
] });
|
|
3058
3967
|
}
|
|
3059
|
-
function
|
|
3060
|
-
const [
|
|
3061
|
-
const [
|
|
3062
|
-
|
|
3063
|
-
|
|
3968
|
+
function ValuePills({ values, onChange }) {
|
|
3969
|
+
const [text, setText] = (0, import_react17.useState)("");
|
|
3970
|
+
const [picking, setPicking] = (0, import_react17.useState)(null);
|
|
3971
|
+
const add = () => {
|
|
3972
|
+
const label = text.trim();
|
|
3973
|
+
if (!label) return;
|
|
3974
|
+
if (!values.some((v) => sameValue(v.label, label))) onChange([...values, { label }]);
|
|
3975
|
+
setText("");
|
|
3976
|
+
};
|
|
3977
|
+
const remove = (i) => {
|
|
3978
|
+
onChange(values.filter((_, j) => j !== i));
|
|
3979
|
+
setPicking(null);
|
|
3980
|
+
};
|
|
3981
|
+
const paint = (i, color) => {
|
|
3982
|
+
onChange(values.map((v, j) => j === i ? { ...v, color } : v));
|
|
3983
|
+
setPicking(null);
|
|
3984
|
+
};
|
|
3985
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "shg-values", onClick: (e) => {
|
|
3986
|
+
if (e.target === e.currentTarget) e.currentTarget.querySelector("input")?.focus();
|
|
3987
|
+
}, children: [
|
|
3988
|
+
values.map((v, i) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "shg-value", children: [
|
|
3989
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
3990
|
+
"button",
|
|
3991
|
+
{
|
|
3992
|
+
type: "button",
|
|
3993
|
+
className: "shg-pill shg-pill-btn",
|
|
3994
|
+
style: { background: v.color || PILL_FALLBACKS[i % PILL_FALLBACKS.length] },
|
|
3995
|
+
title: "Pick a color",
|
|
3996
|
+
"aria-expanded": picking === i,
|
|
3997
|
+
onClick: (e) => {
|
|
3998
|
+
e.stopPropagation();
|
|
3999
|
+
setPicking(picking === i ? null : i);
|
|
4000
|
+
},
|
|
4001
|
+
children: [
|
|
4002
|
+
v.label,
|
|
4003
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
4004
|
+
"span",
|
|
4005
|
+
{
|
|
4006
|
+
className: "shg-value-x",
|
|
4007
|
+
role: "button",
|
|
4008
|
+
"aria-label": `Remove ${v.label}`,
|
|
4009
|
+
onClick: (e) => {
|
|
4010
|
+
e.stopPropagation();
|
|
4011
|
+
remove(i);
|
|
4012
|
+
},
|
|
4013
|
+
children: "\xD7"
|
|
4014
|
+
}
|
|
4015
|
+
)
|
|
4016
|
+
]
|
|
4017
|
+
}
|
|
4018
|
+
),
|
|
4019
|
+
picking === i && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "shg-swatches", role: "listbox", "aria-label": `Color for ${v.label}`, children: PILL_PALETTE.map((p) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
4020
|
+
"button",
|
|
4021
|
+
{
|
|
4022
|
+
type: "button",
|
|
4023
|
+
role: "option",
|
|
4024
|
+
"aria-selected": v.color === p.color,
|
|
4025
|
+
className: "shg-swatch" + (v.color === p.color ? " on" : ""),
|
|
4026
|
+
style: { background: p.color },
|
|
4027
|
+
title: p.name,
|
|
4028
|
+
onClick: (e) => {
|
|
4029
|
+
e.stopPropagation();
|
|
4030
|
+
paint(i, p.color);
|
|
4031
|
+
}
|
|
4032
|
+
},
|
|
4033
|
+
p.name
|
|
4034
|
+
)) })
|
|
4035
|
+
] }, v.label)),
|
|
4036
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
4037
|
+
"input",
|
|
4038
|
+
{
|
|
4039
|
+
className: "shg-values-input",
|
|
4040
|
+
value: text,
|
|
4041
|
+
placeholder: values.length ? "" : "Type a value, press Enter",
|
|
4042
|
+
onChange: (e) => setText(e.target.value),
|
|
4043
|
+
onKeyDown: (e) => {
|
|
4044
|
+
if (e.key === "Enter" || e.key === ",") {
|
|
4045
|
+
e.preventDefault();
|
|
4046
|
+
add();
|
|
4047
|
+
} else if (e.key === "Backspace" && !text && values.length) remove(values.length - 1);
|
|
4048
|
+
},
|
|
4049
|
+
onBlur: add
|
|
4050
|
+
}
|
|
4051
|
+
)
|
|
4052
|
+
] });
|
|
4053
|
+
}
|
|
4054
|
+
function ColumnMenu({ col, columns, anchor, onApply, onDelete, onClose }) {
|
|
4055
|
+
const [type, setType] = (0, import_react17.useState)(col.type || "text");
|
|
4056
|
+
const [values, setValues] = (0, import_react17.useState)(() => (col.options || []).map((o) => typeof o === "string" ? { label: o } : { label: o.label ?? String(o.value ?? ""), ...o.color ? { color: o.color } : {} }));
|
|
3064
4057
|
const comp = col.compute || {};
|
|
3065
|
-
const [kind, setKind] = (0,
|
|
3066
|
-
const [prompt, setPrompt] = (0,
|
|
3067
|
-
const [harnessId, setHarnessId] = (0,
|
|
3068
|
-
const [wfSlug, setWfSlug] = (0,
|
|
3069
|
-
const [outKey, setOutKey] = (0,
|
|
3070
|
-
const [deps, setDeps] = (0,
|
|
3071
|
-
const
|
|
3072
|
-
|
|
3073
|
-
const
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
4058
|
+
const [kind, setKind] = (0, import_react17.useState)(comp.kind || "prompt");
|
|
4059
|
+
const [prompt, setPrompt] = (0, import_react17.useState)(comp.prompt || "");
|
|
4060
|
+
const [harnessId, setHarnessId] = (0, import_react17.useState)(comp.harness_id || "");
|
|
4061
|
+
const [wfSlug, setWfSlug] = (0, import_react17.useState)(comp.workflow_slug || "");
|
|
4062
|
+
const [outKey, setOutKey] = (0, import_react17.useState)(comp.output_key || "");
|
|
4063
|
+
const [deps, setDeps] = (0, import_react17.useState)(new Set(comp.deps || []));
|
|
4064
|
+
const ref = (0, import_react17.useRef)(null);
|
|
4065
|
+
(0, import_react17.useEffect)(() => {
|
|
4066
|
+
const onDown = (e) => {
|
|
4067
|
+
if (ref.current && !ref.current.contains(e.target) && !(e.target.closest && e.target.closest(".uic-pop"))) onClose();
|
|
4068
|
+
};
|
|
4069
|
+
window.addEventListener("mousedown", onDown);
|
|
4070
|
+
return () => window.removeEventListener("mousedown", onDown);
|
|
4071
|
+
}, [onClose]);
|
|
4072
|
+
const promptItems = (0, import_react17.useMemo)(() => {
|
|
4073
|
+
const at = columns.findIndex((c) => c.id === col.id);
|
|
4074
|
+
return columns.filter((c) => c.id !== col.id).map((c) => {
|
|
4075
|
+
const idx = columns.findIndex((x) => x.id === c.id);
|
|
4076
|
+
const right = at >= 0 && idx > at;
|
|
4077
|
+
return {
|
|
4078
|
+
id: c.id,
|
|
4079
|
+
name: c.name,
|
|
4080
|
+
kind: c.type,
|
|
4081
|
+
section: right ? "Fills after this column" : "Columns",
|
|
4082
|
+
icon: TYPE_GLYPH[c.type] || "Aa",
|
|
4083
|
+
description: TYPE_LABEL[c.type] || c.type,
|
|
4084
|
+
color: c.type === "compute" ? "#7C3AED" : void 0,
|
|
4085
|
+
disabled: right ? "to the right" : false
|
|
4086
|
+
};
|
|
4087
|
+
});
|
|
4088
|
+
}, [columns, col.id]);
|
|
3078
4089
|
const apply = () => {
|
|
3079
4090
|
const patch = { type };
|
|
3080
|
-
|
|
3081
|
-
patch.options = optText.split("\n").map((s) => s.trim()).filter(Boolean);
|
|
3082
|
-
}
|
|
4091
|
+
patch.options = values.map((v) => v.color ? { label: v.label, color: v.color } : v.label);
|
|
3083
4092
|
if (type === "compute") {
|
|
3084
4093
|
const compute = { kind, deps: [...deps] };
|
|
3085
4094
|
if (kind === "prompt") compute.prompt = prompt;
|
|
@@ -3095,147 +4104,93 @@ function ColumnMenu({ col, columns, anchor, columnTypes, renderColumnConfig, onA
|
|
|
3095
4104
|
}
|
|
3096
4105
|
onApply(patch);
|
|
3097
4106
|
};
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
4107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(PopPortal, { anchor, width: 250, estHeight: 340, className: "shg-menu", onClose, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { ref, onClick: (e) => e.stopPropagation(), children: [
|
|
4108
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "shg-menu-lbl", children: [
|
|
4109
|
+
"Type",
|
|
4110
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("select", { className: "shg-menu-input", value: type, onChange: (e) => setType(e.target.value), children: [
|
|
4111
|
+
MANUAL_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: t, children: TYPE_LABEL[t] }, t)),
|
|
4112
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: "compute", children: "Computed" })
|
|
4113
|
+
] })
|
|
4114
|
+
] }),
|
|
4115
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "shg-menu-lbl", children: [
|
|
4116
|
+
type === "select" || type === "tags" ? "Options" : "Values",
|
|
4117
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ValuePills, { values, onChange: setValues })
|
|
4118
|
+
] }),
|
|
4119
|
+
type === "compute" && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
4120
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "shg-menu-lbl", children: [
|
|
4121
|
+
"Runs",
|
|
4122
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("select", { className: "shg-menu-input", value: kind, onChange: (e) => setKind(e.target.value), children: COMPUTE_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: k.kind, children: k.label }, k.kind)) })
|
|
4123
|
+
] }),
|
|
4124
|
+
(kind === "prompt" || kind === "harness") && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "shg-menu-lbl", children: [
|
|
4125
|
+
"Prompt",
|
|
4126
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "shg-menu-input shg-menu-prompt", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
4127
|
+
MentionInput,
|
|
4128
|
+
{
|
|
4129
|
+
value: prompt,
|
|
4130
|
+
onChange: (v, ms) => {
|
|
4131
|
+
setPrompt(v);
|
|
4132
|
+
setDeps(new Set(ms.map((m) => m.id)));
|
|
4133
|
+
},
|
|
4134
|
+
items: promptItems,
|
|
4135
|
+
placeholder: "Summarize @Company in one line",
|
|
4136
|
+
menuTitle: "Columns this cell can read",
|
|
4137
|
+
emptyText: "No column by that name",
|
|
4138
|
+
label: "Prompt"
|
|
4139
|
+
}
|
|
4140
|
+
) }),
|
|
4141
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "shg-menu-hint", children: "Type @ to add a column from this row. Columns to the left fill first." })
|
|
4142
|
+
] }),
|
|
4143
|
+
kind === "harness" && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "shg-menu-lbl", children: [
|
|
4144
|
+
"Agent id",
|
|
4145
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("input", { className: "shg-menu-input", value: harnessId, onChange: (e) => setHarnessId(e.target.value), placeholder: "chrn_\u2026" })
|
|
4146
|
+
] }),
|
|
4147
|
+
kind === "workflow" && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
4148
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "shg-menu-lbl", children: [
|
|
4149
|
+
"Workflow id",
|
|
4150
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("input", { className: "shg-menu-input", value: wfSlug, onChange: (e) => setWfSlug(e.target.value), placeholder: "my-workflow" })
|
|
3132
4151
|
] }),
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
"Runs",
|
|
3137
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("select", { className: "shg-menu-input", value: kind, onChange: (e) => setKind(e.target.value), children: COMPUTE_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: k.kind, children: k.label }, k.kind)) })
|
|
3138
|
-
] }),
|
|
3139
|
-
(kind === "prompt" || kind === "harness") && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "shg-menu-lbl", children: [
|
|
3140
|
-
"Prompt \u2014 reference columns as ",
|
|
3141
|
-
"{{Name}}",
|
|
3142
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3143
|
-
"textarea",
|
|
3144
|
-
{
|
|
3145
|
-
className: "shg-menu-input",
|
|
3146
|
-
rows: 3,
|
|
3147
|
-
value: prompt,
|
|
3148
|
-
onChange: (e) => setPrompt(e.target.value),
|
|
3149
|
-
placeholder: "Summarize {{Company}} in one line"
|
|
3150
|
-
}
|
|
3151
|
-
)
|
|
3152
|
-
] }),
|
|
3153
|
-
kind === "harness" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "shg-menu-lbl", children: [
|
|
3154
|
-
"Agent id",
|
|
3155
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { className: "shg-menu-input", value: harnessId, onChange: (e) => setHarnessId(e.target.value), placeholder: "chrn_\u2026" })
|
|
3156
|
-
] }),
|
|
3157
|
-
kind === "workflow" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
3158
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "shg-menu-lbl", children: [
|
|
3159
|
-
"Workflow id",
|
|
3160
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { className: "shg-menu-input", value: wfSlug, onChange: (e) => setWfSlug(e.target.value), placeholder: "my-workflow" })
|
|
3161
|
-
] }),
|
|
3162
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "shg-menu-lbl", children: [
|
|
3163
|
-
"Output key (optional)",
|
|
3164
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { className: "shg-menu-input", value: outKey, onChange: (e) => setOutKey(e.target.value), placeholder: "summary" })
|
|
3165
|
-
] })
|
|
3166
|
-
] }),
|
|
3167
|
-
others.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "shg-menu-lbl", children: [
|
|
3168
|
-
"Reads columns",
|
|
3169
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "shg-menu-deps", children: others.map((c) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "shg-menu-dep", children: [
|
|
3170
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { type: "checkbox", checked: deps.has(c.id), onChange: () => toggleDep(c.id) }),
|
|
3171
|
-
" ",
|
|
3172
|
-
c.name
|
|
3173
|
-
] }, c.id)) })
|
|
3174
|
-
] })
|
|
3175
|
-
] }),
|
|
3176
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "shg-menu-actions", children: [
|
|
3177
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { className: "shg-menu-del", onClick: onDelete, children: "Delete column" }),
|
|
3178
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { className: "shg-menu-apply", onClick: apply, children: "Apply" })
|
|
3179
|
-
] })
|
|
4152
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "shg-menu-lbl", children: [
|
|
4153
|
+
"Output key (optional)",
|
|
4154
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("input", { className: "shg-menu-input", value: outKey, onChange: (e) => setOutKey(e.target.value), placeholder: "summary" })
|
|
3180
4155
|
] })
|
|
3181
4156
|
] })
|
|
3182
|
-
}
|
|
3183
|
-
|
|
3184
|
-
}
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
const rows = container.querySelectorAll("tr[data-row-id]");
|
|
3189
|
-
for (const tr of rows) {
|
|
3190
|
-
const id = tr.getAttribute("data-row-id");
|
|
3191
|
-
if (rowIds && !rowIds.includes(id)) continue;
|
|
3192
|
-
let tallest = 0;
|
|
3193
|
-
for (const cell of tr.querySelectorAll("td[data-col-id] .shg-val")) {
|
|
3194
|
-
tallest = Math.max(tallest, cell.scrollHeight);
|
|
3195
|
-
}
|
|
3196
|
-
if (tallest) out[id] = Math.min(max, Math.max(min, Math.round(tallest + padding)));
|
|
3197
|
-
}
|
|
3198
|
-
return out;
|
|
3199
|
-
}
|
|
3200
|
-
function defaultCellText(cell) {
|
|
3201
|
-
const v = cell?.value;
|
|
3202
|
-
if (v == null) return "";
|
|
3203
|
-
if (Array.isArray(v)) return v.join(", ");
|
|
3204
|
-
if (typeof v === "object") return JSON.stringify(v);
|
|
3205
|
-
return String(v);
|
|
4157
|
+
] }),
|
|
4158
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "shg-menu-actions", children: [
|
|
4159
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { className: "shg-menu-del", onClick: onDelete, children: "Delete column" }),
|
|
4160
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { className: "shg-menu-apply", onClick: apply, children: "Apply" })
|
|
4161
|
+
] })
|
|
4162
|
+
] }) });
|
|
3206
4163
|
}
|
|
3207
|
-
function sheetToDelimited(sheet, sep = ","
|
|
4164
|
+
function sheetToDelimited(sheet, sep = ",") {
|
|
3208
4165
|
const cols = sheet?.columns || [];
|
|
3209
4166
|
const rows = sheet?.rows || [];
|
|
3210
4167
|
const cells = sheet?.cells || {};
|
|
3211
|
-
const esc = (
|
|
4168
|
+
const esc = (v) => {
|
|
4169
|
+
const s = v == null ? "" : Array.isArray(v) ? v.join(", ") : typeof v === "object" ? JSON.stringify(v) : String(v);
|
|
3212
4170
|
if (sep === "," && /[",\n]/.test(s)) return `"${s.replace(/"/g, '""')}"`;
|
|
3213
4171
|
return s;
|
|
3214
4172
|
};
|
|
3215
4173
|
const header = cols.map((c) => esc(c.name)).join(sep);
|
|
3216
|
-
const body = rows.map((r) => cols.map((c) =>
|
|
4174
|
+
const body = rows.map((r) => cols.map((c) => {
|
|
4175
|
+
const cell = cells[cellKey(r.id, c.id)];
|
|
4176
|
+
return esc(cell ? cell.value : "");
|
|
4177
|
+
}).join(sep));
|
|
3217
4178
|
return [header, ...body].join("\n");
|
|
3218
4179
|
}
|
|
3219
|
-
function
|
|
3220
|
-
const v = cell?.value;
|
|
3221
|
-
if (v == null) return "";
|
|
3222
|
-
if (Array.isArray(v)) return v.join(", ");
|
|
3223
|
-
if (typeof v === "object") return JSON.stringify(v);
|
|
3224
|
-
return v;
|
|
3225
|
-
}
|
|
3226
|
-
function sheetToAoA(sheet, { cellText = defaultCellValue } = {}) {
|
|
4180
|
+
function sheetToAoA(sheet) {
|
|
3227
4181
|
const cols = sheet?.columns || [];
|
|
3228
4182
|
const rows = sheet?.rows || [];
|
|
3229
4183
|
const cells = sheet?.cells || {};
|
|
4184
|
+
const val = (v) => v == null ? "" : Array.isArray(v) ? v.join(", ") : typeof v === "object" ? JSON.stringify(v) : v;
|
|
3230
4185
|
return [
|
|
3231
4186
|
cols.map((c) => c.name),
|
|
3232
|
-
...rows.map((r) => cols.map((c) =>
|
|
4187
|
+
...rows.map((r) => cols.map((c) => val(cells[cellKey(r.id, c.id)]?.value)))
|
|
3233
4188
|
];
|
|
3234
4189
|
}
|
|
3235
4190
|
|
|
3236
4191
|
// src/components/FileTypeIcon.jsx
|
|
3237
|
-
var
|
|
3238
|
-
var
|
|
4192
|
+
var import_react18 = require("react");
|
|
4193
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
3239
4194
|
function extOf(name) {
|
|
3240
4195
|
const m = String(name || "").toLowerCase().match(/\.([a-z0-9]+)$/);
|
|
3241
4196
|
return m ? m[1] : "";
|
|
@@ -3243,9 +4198,9 @@ function extOf(name) {
|
|
|
3243
4198
|
var mod = null;
|
|
3244
4199
|
var tried = false;
|
|
3245
4200
|
function FileTypeIcon({ name, size = 36 }) {
|
|
3246
|
-
const [, force] = (0,
|
|
4201
|
+
const [, force] = (0, import_react18.useState)(0);
|
|
3247
4202
|
const ext = extOf(name);
|
|
3248
|
-
(0,
|
|
4203
|
+
(0, import_react18.useEffect)(() => {
|
|
3249
4204
|
if (tried || mod) return;
|
|
3250
4205
|
tried = true;
|
|
3251
4206
|
import("react-file-icon").then((m) => {
|
|
@@ -3256,15 +4211,15 @@ function FileTypeIcon({ name, size = 36 }) {
|
|
|
3256
4211
|
}, []);
|
|
3257
4212
|
const box = { width: size, height: Math.round(size * 1.16), display: "inline-block", flex: "0 0 auto" };
|
|
3258
4213
|
if (!mod) {
|
|
3259
|
-
return /* @__PURE__ */ (0,
|
|
4214
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "uic-fileglyph", style: box, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "uic-fileglyph-ext", children: (ext || "file").slice(0, 4) }) });
|
|
3260
4215
|
}
|
|
3261
4216
|
const { FileIcon, defaultStyles } = mod;
|
|
3262
4217
|
const style = defaultStyles?.[ext] || {};
|
|
3263
|
-
return /* @__PURE__ */ (0,
|
|
4218
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { style: box, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(FileIcon, { extension: ext || void 0, ...style }) });
|
|
3264
4219
|
}
|
|
3265
4220
|
|
|
3266
4221
|
// src/components/FileCard.jsx
|
|
3267
|
-
var
|
|
4222
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3268
4223
|
function subtitle(name, origin, bytes) {
|
|
3269
4224
|
const parts = [(extOf(name) || "file").toUpperCase()];
|
|
3270
4225
|
if (origin) parts.push(origin);
|
|
@@ -3282,7 +4237,7 @@ function FileCard({ name, origin = "output", bytes, onPreview, onDownload, class
|
|
|
3282
4237
|
e.stopPropagation();
|
|
3283
4238
|
onPreview();
|
|
3284
4239
|
} : void 0;
|
|
3285
|
-
return /* @__PURE__ */ (0,
|
|
4240
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
3286
4241
|
"div",
|
|
3287
4242
|
{
|
|
3288
4243
|
className: "uic-filecard" + (open ? " is-clickable" : "") + (className ? " " + className : ""),
|
|
@@ -3297,12 +4252,12 @@ function FileCard({ name, origin = "output", bytes, onPreview, onDownload, class
|
|
|
3297
4252
|
} : void 0,
|
|
3298
4253
|
title: name,
|
|
3299
4254
|
children: [
|
|
3300
|
-
/* @__PURE__ */ (0,
|
|
3301
|
-
/* @__PURE__ */ (0,
|
|
3302
|
-
/* @__PURE__ */ (0,
|
|
3303
|
-
/* @__PURE__ */ (0,
|
|
4255
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "uic-filecard-ic", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FileTypeIcon, { name, size: 32 }) }),
|
|
4256
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "uic-filecard-meta", children: [
|
|
4257
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "uic-filecard-name", children: name }),
|
|
4258
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "uic-filecard-sub", children: subtitle(name, origin, bytes) })
|
|
3304
4259
|
] }),
|
|
3305
|
-
onDownload && /* @__PURE__ */ (0,
|
|
4260
|
+
onDownload && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3306
4261
|
"button",
|
|
3307
4262
|
{
|
|
3308
4263
|
type: "button",
|
|
@@ -3313,18 +4268,18 @@ function FileCard({ name, origin = "output", bytes, onPreview, onDownload, class
|
|
|
3313
4268
|
e.stopPropagation();
|
|
3314
4269
|
onDownload();
|
|
3315
4270
|
},
|
|
3316
|
-
children: /* @__PURE__ */ (0,
|
|
4271
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(IcDownload, { size: 18 })
|
|
3317
4272
|
}
|
|
3318
4273
|
),
|
|
3319
|
-
onPreview && /* @__PURE__ */ (0,
|
|
4274
|
+
onPreview && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: "uic-filecard-open", "aria-label": `Preview ${name}`, onClick: open, children: "Preview" })
|
|
3320
4275
|
]
|
|
3321
4276
|
}
|
|
3322
4277
|
);
|
|
3323
4278
|
}
|
|
3324
4279
|
|
|
3325
4280
|
// src/components/FilePreview.jsx
|
|
3326
|
-
var
|
|
3327
|
-
var
|
|
4281
|
+
var import_react19 = require("react");
|
|
4282
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
3328
4283
|
var LANG = {
|
|
3329
4284
|
js: "javascript",
|
|
3330
4285
|
mjs: "javascript",
|
|
@@ -3400,11 +4355,11 @@ function delimitedToRows(text, sep) {
|
|
|
3400
4355
|
});
|
|
3401
4356
|
}
|
|
3402
4357
|
function Grid({ rows }) {
|
|
3403
|
-
if (!rows?.length) return /* @__PURE__ */ (0,
|
|
4358
|
+
if (!rows?.length) return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "uic-fp-empty", children: "This file is empty." });
|
|
3404
4359
|
const [head, ...body] = rows;
|
|
3405
|
-
return /* @__PURE__ */ (0,
|
|
3406
|
-
/* @__PURE__ */ (0,
|
|
3407
|
-
/* @__PURE__ */ (0,
|
|
4360
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "uic-fp-sheet", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("table", { children: [
|
|
4361
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("tr", { children: head.map((c, i) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("th", { children: c }, i)) }) }),
|
|
4362
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("tbody", { children: body.map((r, i) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("tr", { children: r.map((c, j) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("td", { children: c }, j)) }, i)) })
|
|
3408
4363
|
] }) });
|
|
3409
4364
|
}
|
|
3410
4365
|
var defaultDownload = (url, name) => {
|
|
@@ -3427,9 +4382,9 @@ function FilePreview({
|
|
|
3427
4382
|
title
|
|
3428
4383
|
}) {
|
|
3429
4384
|
const { url, name } = file || {};
|
|
3430
|
-
const [st, setSt] = (0,
|
|
3431
|
-
const [tab, setTab] = (0,
|
|
3432
|
-
(0,
|
|
4385
|
+
const [st, setSt] = (0, import_react19.useState)({ kind: "loading" });
|
|
4386
|
+
const [tab, setTab] = (0, import_react19.useState)(0);
|
|
4387
|
+
(0, import_react19.useEffect)(() => {
|
|
3433
4388
|
if (!url) return void 0;
|
|
3434
4389
|
let alive = true;
|
|
3435
4390
|
let obj;
|
|
@@ -3491,11 +4446,11 @@ function FilePreview({
|
|
|
3491
4446
|
};
|
|
3492
4447
|
}, [url, name, fetchFile, officePdfUrl, parseWorkbook]);
|
|
3493
4448
|
const download = () => onDownload ? onDownload(url, name) : defaultDownload(url, name);
|
|
3494
|
-
return /* @__PURE__ */ (0,
|
|
3495
|
-
/* @__PURE__ */ (0,
|
|
3496
|
-
/* @__PURE__ */ (0,
|
|
3497
|
-
/* @__PURE__ */ (0,
|
|
3498
|
-
/* @__PURE__ */ (0,
|
|
4449
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("aside", { className: "uic-fp", "aria-label": title || `Preview of ${name}`, children: [
|
|
4450
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("header", { className: "uic-fp-head", children: [
|
|
4451
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "uic-fp-ic", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FileTypeIcon, { name, size: 20 }) }),
|
|
4452
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "uic-fp-name", title: name, children: name }),
|
|
4453
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3499
4454
|
"button",
|
|
3500
4455
|
{
|
|
3501
4456
|
type: "button",
|
|
@@ -3503,10 +4458,10 @@ function FilePreview({
|
|
|
3503
4458
|
"aria-label": `Download ${name}`,
|
|
3504
4459
|
title: "Download",
|
|
3505
4460
|
onClick: download,
|
|
3506
|
-
children: /* @__PURE__ */ (0,
|
|
4461
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(IcDownload, {})
|
|
3507
4462
|
}
|
|
3508
4463
|
),
|
|
3509
|
-
onClose && /* @__PURE__ */ (0,
|
|
4464
|
+
onClose && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3510
4465
|
"button",
|
|
3511
4466
|
{
|
|
3512
4467
|
type: "button",
|
|
@@ -3514,22 +4469,22 @@ function FilePreview({
|
|
|
3514
4469
|
"aria-label": "Close preview",
|
|
3515
4470
|
title: "Close",
|
|
3516
4471
|
onClick: onClose,
|
|
3517
|
-
children: /* @__PURE__ */ (0,
|
|
4472
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(IcX, { size: 18 })
|
|
3518
4473
|
}
|
|
3519
4474
|
)
|
|
3520
4475
|
] }),
|
|
3521
|
-
/* @__PURE__ */ (0,
|
|
3522
|
-
st.kind === "loading" && /* @__PURE__ */ (0,
|
|
3523
|
-
st.kind === "image" && st.objUrl && /* @__PURE__ */ (0,
|
|
3524
|
-
st.kind === "pdf" && st.objUrl && /* @__PURE__ */ (0,
|
|
3525
|
-
st.kind === "video" && st.objUrl && /* @__PURE__ */ (0,
|
|
3526
|
-
st.kind === "audio" && st.objUrl && /* @__PURE__ */ (0,
|
|
3527
|
-
st.kind === "markdown" && /* @__PURE__ */ (0,
|
|
3528
|
-
st.kind === "code" && /* @__PURE__ */ (0,
|
|
3529
|
-
st.kind === "csv" && /* @__PURE__ */ (0,
|
|
3530
|
-
st.kind === "sheet" && st.sheets && /* @__PURE__ */ (0,
|
|
3531
|
-
st.sheets[tab]?.filled ? /* @__PURE__ */ (0,
|
|
3532
|
-
/* @__PURE__ */ (0,
|
|
4476
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "uic-fp-body", children: [
|
|
4477
|
+
st.kind === "loading" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "uic-fp-pad", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "uic-skel uic-fp-skel" }) }),
|
|
4478
|
+
st.kind === "image" && st.objUrl && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "uic-fp-center", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("img", { className: "uic-fp-img", src: st.objUrl, alt: name }) }),
|
|
4479
|
+
st.kind === "pdf" && st.objUrl && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("iframe", { className: "uic-fp-frame", src: st.objUrl, title: name }),
|
|
4480
|
+
st.kind === "video" && st.objUrl && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "uic-fp-center", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("video", { className: "uic-fp-media", src: st.objUrl, controls: true }) }),
|
|
4481
|
+
st.kind === "audio" && st.objUrl && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "uic-fp-center", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("audio", { src: st.objUrl, controls: true }) }),
|
|
4482
|
+
st.kind === "markdown" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "uic-fp-doc", children: renderMarkdown ? renderMarkdown(st.text || "") : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("pre", { className: "uic-fp-pre", children: st.text }) }),
|
|
4483
|
+
st.kind === "code" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CodeBlock, { code: st.text || "", lang: LANG[extOf(name)] || "plaintext" }),
|
|
4484
|
+
st.kind === "csv" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Grid, { rows: st.rows }),
|
|
4485
|
+
st.kind === "sheet" && st.sheets && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "uic-fp-xlsx", children: [
|
|
4486
|
+
st.sheets[tab]?.filled ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Grid, { rows: st.sheets[tab].rows }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "uic-fp-empty", children: "This sheet is empty." }),
|
|
4487
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "uic-fp-tabs", children: st.sheets.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3533
4488
|
"button",
|
|
3534
4489
|
{
|
|
3535
4490
|
type: "button",
|
|
@@ -3541,40 +4496,40 @@ function FilePreview({
|
|
|
3541
4496
|
s.name + i
|
|
3542
4497
|
)) })
|
|
3543
4498
|
] }),
|
|
3544
|
-
st.kind === "binary" && /* @__PURE__ */ (0,
|
|
3545
|
-
/* @__PURE__ */ (0,
|
|
3546
|
-
/* @__PURE__ */ (0,
|
|
3547
|
-
/* @__PURE__ */ (0,
|
|
4499
|
+
st.kind === "binary" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "uic-fp-center", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "uic-fp-fallback", children: [
|
|
4500
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FileTypeIcon, { name, size: 56 }),
|
|
4501
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { children: st.error || "No inline preview for this file type." }),
|
|
4502
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: "uic-fp-dl", onClick: download, children: "Download" })
|
|
3548
4503
|
] }) })
|
|
3549
4504
|
] })
|
|
3550
4505
|
] });
|
|
3551
4506
|
}
|
|
3552
4507
|
|
|
3553
4508
|
// src/components/form.jsx
|
|
3554
|
-
var
|
|
3555
|
-
var
|
|
4509
|
+
var import_react20 = require("react");
|
|
4510
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
3556
4511
|
function Field({ label, hint, error, htmlFor, required, children, className = "" }) {
|
|
3557
|
-
return /* @__PURE__ */ (0,
|
|
3558
|
-
label && /* @__PURE__ */ (0,
|
|
4512
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "uic-field" + (error ? " is-error" : "") + (className ? " " + className : ""), children: [
|
|
4513
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: "uic-field-label", htmlFor, children: [
|
|
3559
4514
|
label,
|
|
3560
|
-
required && /* @__PURE__ */ (0,
|
|
4515
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "uic-field-req", "aria-hidden": "true", children: "*" })
|
|
3561
4516
|
] }),
|
|
3562
4517
|
children,
|
|
3563
|
-
error ? /* @__PURE__ */ (0,
|
|
4518
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "uic-field-err", children: error }) : hint ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "uic-field-hint", children: hint }) : null
|
|
3564
4519
|
] });
|
|
3565
4520
|
}
|
|
3566
4521
|
function withField(Control) {
|
|
3567
4522
|
return function Fielded({ label, hint, error, required, id, className, ...rest }) {
|
|
3568
|
-
const auto = (0,
|
|
4523
|
+
const auto = (0, import_react20.useId)();
|
|
3569
4524
|
const inputId = id || auto;
|
|
3570
|
-
return /* @__PURE__ */ (0,
|
|
4525
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Field, { label, hint, error, required, htmlFor: inputId, className, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Control, { id: inputId, invalid: !!error, required, ...rest }) });
|
|
3571
4526
|
};
|
|
3572
4527
|
}
|
|
3573
4528
|
function BareInput({ invalid, ...rest }) {
|
|
3574
|
-
return /* @__PURE__ */ (0,
|
|
4529
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("input", { className: "uic-input" + (invalid ? " is-error" : ""), "aria-invalid": invalid || void 0, ...rest });
|
|
3575
4530
|
}
|
|
3576
4531
|
function BareTextarea({ invalid, rows = 4, ...rest }) {
|
|
3577
|
-
return /* @__PURE__ */ (0,
|
|
4532
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3578
4533
|
"textarea",
|
|
3579
4534
|
{
|
|
3580
4535
|
className: "uic-input uic-textarea" + (invalid ? " is-error" : ""),
|
|
@@ -3585,44 +4540,44 @@ function BareTextarea({ invalid, rows = 4, ...rest }) {
|
|
|
3585
4540
|
);
|
|
3586
4541
|
}
|
|
3587
4542
|
function BareSelect({ invalid, options = [], placeholder, ...rest }) {
|
|
3588
|
-
return /* @__PURE__ */ (0,
|
|
3589
|
-
/* @__PURE__ */ (0,
|
|
4543
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "uic-select-wrap", children: [
|
|
4544
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
3590
4545
|
"select",
|
|
3591
4546
|
{
|
|
3592
4547
|
className: "uic-input uic-select" + (invalid ? " is-error" : ""),
|
|
3593
4548
|
"aria-invalid": invalid || void 0,
|
|
3594
4549
|
...rest,
|
|
3595
4550
|
children: [
|
|
3596
|
-
placeholder && /* @__PURE__ */ (0,
|
|
4551
|
+
placeholder && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: "", children: placeholder }),
|
|
3597
4552
|
options.map((o) => {
|
|
3598
4553
|
const opt = typeof o === "string" ? { value: o, label: o } : o;
|
|
3599
|
-
return /* @__PURE__ */ (0,
|
|
4554
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: opt.value, disabled: opt.disabled, children: opt.label }, opt.value);
|
|
3600
4555
|
})
|
|
3601
4556
|
]
|
|
3602
4557
|
}
|
|
3603
4558
|
),
|
|
3604
|
-
/* @__PURE__ */ (0,
|
|
4559
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "uic-select-chev", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Chevron, { dir: "down", size: 14 }) })
|
|
3605
4560
|
] });
|
|
3606
4561
|
}
|
|
3607
4562
|
var Input = withField(BareInput);
|
|
3608
4563
|
var Textarea = withField(BareTextarea);
|
|
3609
4564
|
var Select = withField(BareSelect);
|
|
3610
4565
|
function FormActions({ children, align = "end", className = "" }) {
|
|
3611
|
-
return /* @__PURE__ */ (0,
|
|
4566
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: `uic-form-actions is-${align}${className ? " " + className : ""}`, children });
|
|
3612
4567
|
}
|
|
3613
4568
|
function Button({ variant = "default", size = "md", type = "button", className = "", ...rest }) {
|
|
3614
|
-
return /* @__PURE__ */ (0,
|
|
4569
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type, className: `uic-btn is-${variant} is-${size}${className ? " " + className : ""}`, ...rest });
|
|
3615
4570
|
}
|
|
3616
4571
|
|
|
3617
4572
|
// src/components/Carousel.jsx
|
|
3618
|
-
var
|
|
3619
|
-
var
|
|
4573
|
+
var import_react21 = __toESM(require("react"), 1);
|
|
4574
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
3620
4575
|
var EDGE = 2;
|
|
3621
4576
|
function Carousel(props) {
|
|
3622
4577
|
const { label, step, children, classNames = {} } = props;
|
|
3623
|
-
const ref = (0,
|
|
3624
|
-
const [edges, setEdges] = (0,
|
|
3625
|
-
const measure = (0,
|
|
4578
|
+
const ref = (0, import_react21.useRef)(null);
|
|
4579
|
+
const [edges, setEdges] = (0, import_react21.useState)({ start: true, end: true, overflow: false });
|
|
4580
|
+
const measure = (0, import_react21.useCallback)(() => {
|
|
3626
4581
|
const el = ref.current;
|
|
3627
4582
|
if (!el) return;
|
|
3628
4583
|
const overflow = el.scrollWidth - el.clientWidth > EDGE;
|
|
@@ -3632,7 +4587,7 @@ function Carousel(props) {
|
|
|
3632
4587
|
end: el.scrollLeft >= el.scrollWidth - el.clientWidth - EDGE
|
|
3633
4588
|
});
|
|
3634
4589
|
}, []);
|
|
3635
|
-
(0,
|
|
4590
|
+
(0, import_react21.useEffect)(() => {
|
|
3636
4591
|
const el = ref.current;
|
|
3637
4592
|
if (!el) return void 0;
|
|
3638
4593
|
measure();
|
|
@@ -3646,8 +4601,8 @@ function Carousel(props) {
|
|
|
3646
4601
|
if (!el) return;
|
|
3647
4602
|
el.scrollBy({ left: dir * (step || Math.round(el.clientWidth * 0.9)), behavior: "smooth" });
|
|
3648
4603
|
};
|
|
3649
|
-
return /* @__PURE__ */ (0,
|
|
3650
|
-
edges.overflow ? /* @__PURE__ */ (0,
|
|
4604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: ["uic-carousel-wrap", classNames.root || ""].filter(Boolean).join(" "), children: [
|
|
4605
|
+
edges.overflow ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3651
4606
|
"button",
|
|
3652
4607
|
{
|
|
3653
4608
|
type: "button",
|
|
@@ -3655,10 +4610,10 @@ function Carousel(props) {
|
|
|
3655
4610
|
onClick: () => scroll(-1),
|
|
3656
4611
|
disabled: edges.start,
|
|
3657
4612
|
"aria-label": `Scroll ${label} left`,
|
|
3658
|
-
children: /* @__PURE__ */ (0,
|
|
4613
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Chevron, { dir: "left" })
|
|
3659
4614
|
}
|
|
3660
4615
|
) : null,
|
|
3661
|
-
/* @__PURE__ */ (0,
|
|
4616
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3662
4617
|
"div",
|
|
3663
4618
|
{
|
|
3664
4619
|
className: ["uic-carousel", classNames.viewport || ""].filter(Boolean).join(" "),
|
|
@@ -3669,7 +4624,7 @@ function Carousel(props) {
|
|
|
3669
4624
|
children
|
|
3670
4625
|
}
|
|
3671
4626
|
),
|
|
3672
|
-
edges.overflow ? /* @__PURE__ */ (0,
|
|
4627
|
+
edges.overflow ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3673
4628
|
"button",
|
|
3674
4629
|
{
|
|
3675
4630
|
type: "button",
|
|
@@ -3677,42 +4632,42 @@ function Carousel(props) {
|
|
|
3677
4632
|
onClick: () => scroll(1),
|
|
3678
4633
|
disabled: edges.end,
|
|
3679
4634
|
"aria-label": `Scroll ${label} right`,
|
|
3680
|
-
children: /* @__PURE__ */ (0,
|
|
4635
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Chevron, { dir: "right" })
|
|
3681
4636
|
}
|
|
3682
4637
|
) : null
|
|
3683
4638
|
] });
|
|
3684
4639
|
}
|
|
3685
4640
|
|
|
3686
4641
|
// src/components/Card.jsx
|
|
3687
|
-
var
|
|
3688
|
-
var
|
|
4642
|
+
var import_react22 = __toESM(require("react"), 1);
|
|
4643
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
3689
4644
|
function Card(props) {
|
|
3690
4645
|
const { art, title, subtitle: subtitle2, onClick, selected = false, overlay, actions, classNames = {} } = props;
|
|
3691
|
-
const foot = /* @__PURE__ */ (0,
|
|
3692
|
-
/* @__PURE__ */ (0,
|
|
3693
|
-
subtitle2 ? /* @__PURE__ */ (0,
|
|
4646
|
+
const foot = /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "uic-card-foot", children: [
|
|
4647
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "uic-card-name", children: title }),
|
|
4648
|
+
subtitle2 ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "uic-card-sub", children: subtitle2 }) : null
|
|
3694
4649
|
] });
|
|
3695
|
-
return /* @__PURE__ */ (0,
|
|
3696
|
-
onClick ? /* @__PURE__ */ (0,
|
|
3697
|
-
/* @__PURE__ */ (0,
|
|
4650
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: ["uic-card", selected ? "is-selected" : "", classNames.root || ""].filter(Boolean).join(" "), children: [
|
|
4651
|
+
onClick ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("button", { type: "button", className: "uic-card-main", onClick, "aria-pressed": selected || void 0, children: [
|
|
4652
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "uic-card-art", children: art }),
|
|
3698
4653
|
foot
|
|
3699
|
-
] }) : /* @__PURE__ */ (0,
|
|
3700
|
-
/* @__PURE__ */ (0,
|
|
4654
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "uic-card-main", children: [
|
|
4655
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "uic-card-art", children: art }),
|
|
3701
4656
|
foot
|
|
3702
4657
|
] }),
|
|
3703
|
-
overlay ? /* @__PURE__ */ (0,
|
|
3704
|
-
actions ? /* @__PURE__ */ (0,
|
|
4658
|
+
overlay ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "uic-card-overlay", children: overlay }) : null,
|
|
4659
|
+
actions ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "uic-card-actions", children: actions }) : null
|
|
3705
4660
|
] });
|
|
3706
4661
|
}
|
|
3707
4662
|
|
|
3708
4663
|
// src/components/SearchField.jsx
|
|
3709
|
-
var
|
|
3710
|
-
var
|
|
4664
|
+
var import_react23 = __toESM(require("react"), 1);
|
|
4665
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
3711
4666
|
function SearchField(props) {
|
|
3712
4667
|
const { value, onChange, placeholder, clearLabel = "Clear search", className } = props;
|
|
3713
|
-
return /* @__PURE__ */ (0,
|
|
3714
|
-
/* @__PURE__ */ (0,
|
|
3715
|
-
/* @__PURE__ */ (0,
|
|
4668
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: ["uic-search", className || ""].filter(Boolean).join(" "), children: [
|
|
4669
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "uic-search-ic", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(IcSearch, {}) }),
|
|
4670
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3716
4671
|
"input",
|
|
3717
4672
|
{
|
|
3718
4673
|
type: "search",
|
|
@@ -3722,90 +4677,14 @@ function SearchField(props) {
|
|
|
3722
4677
|
onChange: (e) => onChange(e.target.value)
|
|
3723
4678
|
}
|
|
3724
4679
|
),
|
|
3725
|
-
value ? /* @__PURE__ */ (0,
|
|
4680
|
+
value ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: "uic-search-x", "aria-label": clearLabel, onClick: () => onChange(""), children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(IcX, { size: 12 }) }) : null
|
|
3726
4681
|
] });
|
|
3727
4682
|
}
|
|
3728
4683
|
|
|
3729
|
-
// src/components/Popover.jsx
|
|
3730
|
-
var import_react22 = __toESM(require("react"), 1);
|
|
3731
|
-
var import_react_dom3 = require("react-dom");
|
|
3732
|
-
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
3733
|
-
var GAP = 6;
|
|
3734
|
-
var MARGIN = 8;
|
|
3735
|
-
function Popover(props) {
|
|
3736
|
-
const {
|
|
3737
|
-
open,
|
|
3738
|
-
anchorRef,
|
|
3739
|
-
onClose,
|
|
3740
|
-
width = 280,
|
|
3741
|
-
minHeight = 140,
|
|
3742
|
-
placement = "auto",
|
|
3743
|
-
children,
|
|
3744
|
-
className,
|
|
3745
|
-
label
|
|
3746
|
-
} = props;
|
|
3747
|
-
const popRef = (0, import_react22.useRef)(null);
|
|
3748
|
-
const [pos, setPos] = (0, import_react22.useState)(null);
|
|
3749
|
-
(0, import_react22.useEffect)(() => {
|
|
3750
|
-
if (!open) {
|
|
3751
|
-
setPos(null);
|
|
3752
|
-
return void 0;
|
|
3753
|
-
}
|
|
3754
|
-
const place = () => {
|
|
3755
|
-
const el = anchorRef?.current;
|
|
3756
|
-
if (!el) return;
|
|
3757
|
-
const r = el.getBoundingClientRect();
|
|
3758
|
-
const vw = window.innerWidth;
|
|
3759
|
-
const vh = window.innerHeight;
|
|
3760
|
-
const w = Math.min(width, vw - MARGIN * 2);
|
|
3761
|
-
const below = vh - r.bottom - GAP - MARGIN;
|
|
3762
|
-
const above = r.top - GAP - MARGIN;
|
|
3763
|
-
const up = placement === "above" || placement === "auto" && below < minHeight && above > below;
|
|
3764
|
-
const maxHeight = Math.max(minHeight, Math.floor(up ? above : below));
|
|
3765
|
-
const left = Math.max(MARGIN, Math.min(r.left, vw - w - MARGIN));
|
|
3766
|
-
setPos(up ? { left, bottom: Math.round(vh - r.top + GAP), width: w, maxHeight } : { left, top: Math.round(r.bottom + GAP), width: w, maxHeight });
|
|
3767
|
-
};
|
|
3768
|
-
place();
|
|
3769
|
-
window.addEventListener("resize", place);
|
|
3770
|
-
window.addEventListener("scroll", place, true);
|
|
3771
|
-
return () => {
|
|
3772
|
-
window.removeEventListener("resize", place);
|
|
3773
|
-
window.removeEventListener("scroll", place, true);
|
|
3774
|
-
};
|
|
3775
|
-
}, [open, anchorRef, width, minHeight, placement]);
|
|
3776
|
-
(0, import_react22.useEffect)(() => {
|
|
3777
|
-
if (!open) return void 0;
|
|
3778
|
-
const onDown = (e) => {
|
|
3779
|
-
if (popRef.current?.contains(e.target)) return;
|
|
3780
|
-
if (anchorRef?.current?.contains(e.target)) return;
|
|
3781
|
-
onClose?.();
|
|
3782
|
-
};
|
|
3783
|
-
document.addEventListener("pointerdown", onDown);
|
|
3784
|
-
return () => document.removeEventListener("pointerdown", onDown);
|
|
3785
|
-
}, [open, anchorRef, onClose]);
|
|
3786
|
-
const escape = (0, import_react22.useCallback)(() => onClose?.(), [onClose]);
|
|
3787
|
-
useOverlayEscape(open, escape);
|
|
3788
|
-
if (!open || !pos || typeof document === "undefined") return null;
|
|
3789
|
-
return (0, import_react_dom3.createPortal)(
|
|
3790
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
3791
|
-
"div",
|
|
3792
|
-
{
|
|
3793
|
-
ref: popRef,
|
|
3794
|
-
className: ["uic-pop", className || ""].filter(Boolean).join(" "),
|
|
3795
|
-
style: pos,
|
|
3796
|
-
role: "dialog",
|
|
3797
|
-
"aria-label": label,
|
|
3798
|
-
children
|
|
3799
|
-
}
|
|
3800
|
-
),
|
|
3801
|
-
document.body
|
|
3802
|
-
);
|
|
3803
|
-
}
|
|
3804
|
-
|
|
3805
4684
|
// src/components/CascadeMenu.jsx
|
|
3806
|
-
var
|
|
3807
|
-
var
|
|
3808
|
-
var Tick = () => /* @__PURE__ */ (0,
|
|
4685
|
+
var import_react24 = __toESM(require("react"), 1);
|
|
4686
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
4687
|
+
var Tick = () => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Svg, { s: 14, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("path", { d: "M20 6 9 17l-5-5" }) });
|
|
3809
4688
|
var FILTER_PAST = 8;
|
|
3810
4689
|
var itemsOf = (groups) => groups.flatMap((g) => g.items);
|
|
3811
4690
|
function CascadeMenu(props) {
|
|
@@ -3823,26 +4702,27 @@ function CascadeMenu(props) {
|
|
|
3823
4702
|
noOptionsText = "Nothing to choose here.",
|
|
3824
4703
|
optionsLabel = "Options",
|
|
3825
4704
|
backLabel = "Back",
|
|
4705
|
+
optionsFooter,
|
|
3826
4706
|
width = 520,
|
|
3827
4707
|
stackBelow = 560,
|
|
3828
4708
|
className,
|
|
3829
4709
|
value
|
|
3830
4710
|
} = props;
|
|
3831
|
-
const rootRef = (0,
|
|
3832
|
-
const [q, setQ] = (0,
|
|
3833
|
-
const [activeId, setActiveId] = (0,
|
|
3834
|
-
const [stage, setStage] = (0,
|
|
3835
|
-
const [stacked, setStacked] = (0,
|
|
3836
|
-
const visible = (0,
|
|
4711
|
+
const rootRef = (0, import_react24.useRef)(null);
|
|
4712
|
+
const [q, setQ] = (0, import_react24.useState)("");
|
|
4713
|
+
const [activeId, setActiveId] = (0, import_react24.useState)(null);
|
|
4714
|
+
const [stage, setStage] = (0, import_react24.useState)("items");
|
|
4715
|
+
const [stacked, setStacked] = (0, import_react24.useState)(false);
|
|
4716
|
+
const visible = (0, import_react24.useMemo)(() => {
|
|
3837
4717
|
const needle = q.trim().toLowerCase();
|
|
3838
4718
|
if (!needle) return groups.filter((g) => g.items.length > 0);
|
|
3839
4719
|
return groups.map((g) => ({ ...g, items: g.items.filter((it) => String(it.label).toLowerCase().includes(needle)) })).filter((g) => g.items.length > 0);
|
|
3840
4720
|
}, [groups, q]);
|
|
3841
|
-
const flat = (0,
|
|
4721
|
+
const flat = (0, import_react24.useMemo)(() => itemsOf(visible), [visible]);
|
|
3842
4722
|
const active = flat.find((it) => it.id === activeId) || flat[0] || null;
|
|
3843
|
-
const options = (0,
|
|
4723
|
+
const options = (0, import_react24.useMemo)(() => active && optionsOf ? optionsOf(active) : [], [active, optionsOf]);
|
|
3844
4724
|
const showFilter = filter === true || filter === "auto" && itemsOf(groups).length > FILTER_PAST;
|
|
3845
|
-
(0,
|
|
4725
|
+
(0, import_react24.useEffect)(() => {
|
|
3846
4726
|
if (!open) return void 0;
|
|
3847
4727
|
setQ("");
|
|
3848
4728
|
setActiveId(value?.item ?? null);
|
|
@@ -3861,14 +4741,14 @@ function CascadeMenu(props) {
|
|
|
3861
4741
|
anchor?.focus?.({ preventScroll: true });
|
|
3862
4742
|
};
|
|
3863
4743
|
}, [open, stackBelow]);
|
|
3864
|
-
const focusIn = (0,
|
|
4744
|
+
const focusIn = (0, import_react24.useCallback)((col, index = 0) => {
|
|
3865
4745
|
const list = rootRef.current?.querySelectorAll(`.uic-cascade-${col} .uic-pop-item:not(:disabled)`);
|
|
3866
4746
|
if (!list || !list.length) return false;
|
|
3867
4747
|
const i = Math.max(0, Math.min(index, list.length - 1));
|
|
3868
4748
|
list[i].focus({ preventScroll: true });
|
|
3869
4749
|
return true;
|
|
3870
4750
|
}, []);
|
|
3871
|
-
const enterOptions = (0,
|
|
4751
|
+
const enterOptions = (0, import_react24.useCallback)(() => {
|
|
3872
4752
|
if (stacked) {
|
|
3873
4753
|
setStage("options");
|
|
3874
4754
|
requestAnimationFrame(() => focusIn("options"));
|
|
@@ -3908,7 +4788,7 @@ function CascadeMenu(props) {
|
|
|
3908
4788
|
};
|
|
3909
4789
|
const showItems = !stacked || stage === "items";
|
|
3910
4790
|
const showOptions = !stacked || stage === "options";
|
|
3911
|
-
return /* @__PURE__ */ (0,
|
|
4791
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3912
4792
|
Popover,
|
|
3913
4793
|
{
|
|
3914
4794
|
open,
|
|
@@ -3918,15 +4798,15 @@ function CascadeMenu(props) {
|
|
|
3918
4798
|
width: stacked ? 320 : width,
|
|
3919
4799
|
minHeight: 260,
|
|
3920
4800
|
className: ["uic-cascade-pop", className || ""].filter(Boolean).join(" "),
|
|
3921
|
-
children: /* @__PURE__ */ (0,
|
|
3922
|
-
showItems && /* @__PURE__ */ (0,
|
|
3923
|
-
showFilter ? /* @__PURE__ */ (0,
|
|
3924
|
-
/* @__PURE__ */ (0,
|
|
3925
|
-
visible.map((g, gi) => /* @__PURE__ */ (0,
|
|
3926
|
-
g.label ? /* @__PURE__ */ (0,
|
|
4801
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { ref: rootRef, className: "uic-cascade" + (stacked ? " is-stacked" : ""), onKeyDown: onKey2, children: [
|
|
4802
|
+
showItems && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "uic-cascade-col uic-cascade-items", children: [
|
|
4803
|
+
showFilter ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(SearchField, { className: "uic-cascade-filter", value: q, onChange: setQ, placeholder: filterPlaceholder }) : null,
|
|
4804
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "uic-pop-list", children: [
|
|
4805
|
+
visible.map((g, gi) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_react24.Fragment, { children: [
|
|
4806
|
+
g.label ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "uic-cascade-group", children: g.label }) : null,
|
|
3927
4807
|
g.items.map((it) => {
|
|
3928
4808
|
const on = active?.id === it.id;
|
|
3929
|
-
return /* @__PURE__ */ (0,
|
|
4809
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
3930
4810
|
"button",
|
|
3931
4811
|
{
|
|
3932
4812
|
type: "button",
|
|
@@ -3939,22 +4819,22 @@ function CascadeMenu(props) {
|
|
|
3939
4819
|
enterOptions();
|
|
3940
4820
|
},
|
|
3941
4821
|
children: [
|
|
3942
|
-
it.icon ? /* @__PURE__ */ (0,
|
|
3943
|
-
/* @__PURE__ */ (0,
|
|
3944
|
-
it.note ? /* @__PURE__ */ (0,
|
|
3945
|
-
/* @__PURE__ */ (0,
|
|
4822
|
+
it.icon ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "uic-cascade-ic", "aria-hidden": "true", children: it.icon }) : null,
|
|
4823
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "uic-chip-t", children: it.label }),
|
|
4824
|
+
it.note ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "uic-cascade-note", children: it.note }) : null,
|
|
4825
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "uic-cascade-chev", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Chevron, { dir: "right", size: 14 }) })
|
|
3946
4826
|
]
|
|
3947
4827
|
},
|
|
3948
4828
|
it.id
|
|
3949
4829
|
);
|
|
3950
4830
|
})
|
|
3951
4831
|
] }, g.label || gi)),
|
|
3952
|
-
flat.length === 0 ? /* @__PURE__ */ (0,
|
|
4832
|
+
flat.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "uic-pop-note", children: emptyText }) : null
|
|
3953
4833
|
] })
|
|
3954
4834
|
] }),
|
|
3955
|
-
showOptions && /* @__PURE__ */ (0,
|
|
3956
|
-
/* @__PURE__ */ (0,
|
|
3957
|
-
stacked ? /* @__PURE__ */ (0,
|
|
4835
|
+
showOptions && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "uic-cascade-col uic-cascade-options", role: "group", "aria-label": optionsLabel, children: [
|
|
4836
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "uic-cascade-head", children: [
|
|
4837
|
+
stacked ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3958
4838
|
"button",
|
|
3959
4839
|
{
|
|
3960
4840
|
type: "button",
|
|
@@ -3964,34 +4844,36 @@ function CascadeMenu(props) {
|
|
|
3964
4844
|
setStage("items");
|
|
3965
4845
|
requestAnimationFrame(() => focusIn("items", flat.indexOf(active)));
|
|
3966
4846
|
},
|
|
3967
|
-
children: /* @__PURE__ */ (0,
|
|
4847
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Chevron, { dir: "left", size: 14 })
|
|
3968
4848
|
}
|
|
3969
4849
|
) : null,
|
|
3970
|
-
active?.icon ? /* @__PURE__ */ (0,
|
|
3971
|
-
/* @__PURE__ */ (0,
|
|
4850
|
+
active?.icon ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "uic-cascade-ic", "aria-hidden": "true", children: active.icon }) : null,
|
|
4851
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "uic-chip-t", children: active ? active.label : "" })
|
|
3972
4852
|
] }),
|
|
3973
|
-
/* @__PURE__ */ (0,
|
|
4853
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "uic-pop-list", children: [
|
|
3974
4854
|
options.map((o) => {
|
|
3975
4855
|
const on = !!value && active?.id === value.item && o.id === value.option;
|
|
3976
|
-
return /* @__PURE__ */ (0,
|
|
4856
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
3977
4857
|
"button",
|
|
3978
4858
|
{
|
|
3979
4859
|
type: "button",
|
|
3980
|
-
className: "uic-pop-item uic-cascade-opt" + (on ? " is-on" : ""),
|
|
4860
|
+
className: "uic-pop-item uic-cascade-opt" + (on ? " is-on" : "") + (o.badge ? " has-badge" : ""),
|
|
3981
4861
|
"aria-current": on ? "true" : void 0,
|
|
3982
4862
|
disabled: !!o.disabled,
|
|
3983
4863
|
onClick: () => onPick?.(active, o),
|
|
3984
4864
|
children: [
|
|
3985
|
-
value ? /* @__PURE__ */ (0,
|
|
3986
|
-
/* @__PURE__ */ (0,
|
|
3987
|
-
o.note ? /* @__PURE__ */ (0,
|
|
4865
|
+
value ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "uic-pop-check", "aria-hidden": "true", children: on ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Tick, {}) : null }) : null,
|
|
4866
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "uic-chip-t", children: o.label }),
|
|
4867
|
+
o.note ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "uic-cascade-note", children: o.note }) : null,
|
|
4868
|
+
o.badge || null
|
|
3988
4869
|
]
|
|
3989
4870
|
},
|
|
3990
4871
|
o.id
|
|
3991
4872
|
);
|
|
3992
4873
|
}),
|
|
3993
|
-
active && options.length === 0 ? /* @__PURE__ */ (0,
|
|
3994
|
-
] })
|
|
4874
|
+
active && options.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "uic-pop-note", children: noOptionsText }) : null
|
|
4875
|
+
] }),
|
|
4876
|
+
optionsFooter || null
|
|
3995
4877
|
] })
|
|
3996
4878
|
] })
|
|
3997
4879
|
}
|
|
@@ -3999,9 +4881,9 @@ function CascadeMenu(props) {
|
|
|
3999
4881
|
}
|
|
4000
4882
|
|
|
4001
4883
|
// src/components/Modal.jsx
|
|
4002
|
-
var
|
|
4884
|
+
var import_react25 = __toESM(require("react"), 1);
|
|
4003
4885
|
var import_react_dom4 = require("react-dom");
|
|
4004
|
-
var
|
|
4886
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
4005
4887
|
function Modal(props) {
|
|
4006
4888
|
const {
|
|
4007
4889
|
open,
|
|
@@ -4015,10 +4897,10 @@ function Modal(props) {
|
|
|
4015
4897
|
children,
|
|
4016
4898
|
classNames = {}
|
|
4017
4899
|
} = props;
|
|
4018
|
-
const titleId = (0,
|
|
4019
|
-
const escape = (0,
|
|
4900
|
+
const titleId = (0, import_react25.useId)();
|
|
4901
|
+
const escape = (0, import_react25.useCallback)(() => onClose?.(), [onClose]);
|
|
4020
4902
|
useOverlayEscape(open, escape);
|
|
4021
|
-
(0,
|
|
4903
|
+
(0, import_react25.useEffect)(() => {
|
|
4022
4904
|
if (!open || typeof document === "undefined") return void 0;
|
|
4023
4905
|
const prev = document.body.style.overflow;
|
|
4024
4906
|
document.body.style.overflow = "hidden";
|
|
@@ -4031,12 +4913,12 @@ function Modal(props) {
|
|
|
4031
4913
|
if (e.target === e.currentTarget) onClose?.();
|
|
4032
4914
|
};
|
|
4033
4915
|
return (0, import_react_dom4.createPortal)(
|
|
4034
|
-
/* @__PURE__ */ (0,
|
|
4916
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4035
4917
|
"div",
|
|
4036
4918
|
{
|
|
4037
4919
|
className: ["uic-modal-backdrop", classNames.backdrop || ""].filter(Boolean).join(" "),
|
|
4038
4920
|
onMouseDown: onBackdrop,
|
|
4039
|
-
children: /* @__PURE__ */ (0,
|
|
4921
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
4040
4922
|
"div",
|
|
4041
4923
|
{
|
|
4042
4924
|
className: ["uic-modal", `is-${size}`, classNames.root || ""].filter(Boolean).join(" "),
|
|
@@ -4045,15 +4927,15 @@ function Modal(props) {
|
|
|
4045
4927
|
"aria-modal": "true",
|
|
4046
4928
|
"aria-labelledby": labelledBy || (title ? titleId : void 0),
|
|
4047
4929
|
children: [
|
|
4048
|
-
title || actions ? /* @__PURE__ */ (0,
|
|
4049
|
-
/* @__PURE__ */ (0,
|
|
4050
|
-
title ? /* @__PURE__ */ (0,
|
|
4051
|
-
description ? /* @__PURE__ */ (0,
|
|
4930
|
+
title || actions ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "uic-modal-h", children: [
|
|
4931
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "uic-modal-title", children: [
|
|
4932
|
+
title ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("h3", { id: titleId, children: title }) : null,
|
|
4933
|
+
description ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { children: description }) : null
|
|
4052
4934
|
] }),
|
|
4053
4935
|
actions,
|
|
4054
|
-
/* @__PURE__ */ (0,
|
|
4936
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("button", { type: "button", className: "uic-modal-x", "aria-label": "Close", onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(IcX, { size: 18 }) })
|
|
4055
4937
|
] }) : null,
|
|
4056
|
-
/* @__PURE__ */ (0,
|
|
4938
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: ["uic-modal-b", classNames.body || ""].filter(Boolean).join(" "), children })
|
|
4057
4939
|
]
|
|
4058
4940
|
}
|
|
4059
4941
|
)
|
|
@@ -4064,15 +4946,15 @@ function Modal(props) {
|
|
|
4064
4946
|
}
|
|
4065
4947
|
|
|
4066
4948
|
// src/hooks/useTypewriter.js
|
|
4067
|
-
var
|
|
4949
|
+
var import_react26 = require("react");
|
|
4068
4950
|
var CHAR_MS = 26;
|
|
4069
4951
|
var HOLD_MS = 2600;
|
|
4070
4952
|
function useTypewriter(phrases, { active = true } = {}) {
|
|
4071
4953
|
const list = phrases && phrases.length ? phrases : [""];
|
|
4072
|
-
const [text, setText] = (0,
|
|
4073
|
-
const listRef = (0,
|
|
4954
|
+
const [text, setText] = (0, import_react26.useState)(list[0]);
|
|
4955
|
+
const listRef = (0, import_react26.useRef)(list);
|
|
4074
4956
|
listRef.current = list;
|
|
4075
|
-
(0,
|
|
4957
|
+
(0, import_react26.useEffect)(() => {
|
|
4076
4958
|
if (!active) return void 0;
|
|
4077
4959
|
if (typeof window === "undefined") return void 0;
|
|
4078
4960
|
if (window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches) {
|
|
@@ -4103,7 +4985,7 @@ function useTypewriter(phrases, { active = true } = {}) {
|
|
|
4103
4985
|
}
|
|
4104
4986
|
|
|
4105
4987
|
// src/components/Panel.jsx
|
|
4106
|
-
var
|
|
4988
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
4107
4989
|
function Panel(props) {
|
|
4108
4990
|
const {
|
|
4109
4991
|
title,
|
|
@@ -4125,43 +5007,43 @@ function Panel(props) {
|
|
|
4125
5007
|
classNames = {},
|
|
4126
5008
|
children
|
|
4127
5009
|
} = props;
|
|
4128
|
-
const body = loading ? /* @__PURE__ */ (0,
|
|
4129
|
-
/* @__PURE__ */ (0,
|
|
4130
|
-
/* @__PURE__ */ (0,
|
|
4131
|
-
/* @__PURE__ */ (0,
|
|
4132
|
-
/* @__PURE__ */ (0,
|
|
4133
|
-
] }) : error ? /* @__PURE__ */ (0,
|
|
4134
|
-
/* @__PURE__ */ (0,
|
|
4135
|
-
/* @__PURE__ */ (0,
|
|
4136
|
-
errorDetail ? /* @__PURE__ */ (0,
|
|
4137
|
-
/* @__PURE__ */ (0,
|
|
4138
|
-
/* @__PURE__ */ (0,
|
|
5010
|
+
const body = loading ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "uic-panel-load", children: [
|
|
5011
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "uic-panel-load-bar" }),
|
|
5012
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "uic-panel-load-bar" }),
|
|
5013
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "uic-panel-load-bar" }),
|
|
5014
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "uic-sr", children: loadingLabel })
|
|
5015
|
+
] }) : error ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "uic-panel-fail", children: [
|
|
5016
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "uic-panel-fail-t", children: errorTitle }),
|
|
5017
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("pre", { className: "uic-panel-fail-m", children: error }),
|
|
5018
|
+
errorDetail ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("details", { className: "uic-panel-fail-d", children: [
|
|
5019
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("summary", { children: detailLabel }),
|
|
5020
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "uic-panel-fail-dd", children: errorDetail })
|
|
4139
5021
|
] }) : null,
|
|
4140
|
-
onRetry ? /* @__PURE__ */ (0,
|
|
5022
|
+
onRetry ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "uic-panel-fail-act", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Button, { size: "sm", onClick: onRetry, children: retryLabel }) }) : null
|
|
4141
5023
|
] }) : children;
|
|
4142
|
-
return /* @__PURE__ */ (0,
|
|
5024
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
4143
5025
|
"section",
|
|
4144
5026
|
{
|
|
4145
5027
|
className: ["uic-panel", className, classNames.root || ""].filter(Boolean).join(" "),
|
|
4146
5028
|
"aria-busy": loading || busy || void 0,
|
|
4147
5029
|
children: [
|
|
4148
|
-
/* @__PURE__ */ (0,
|
|
4149
|
-
/* @__PURE__ */ (0,
|
|
4150
|
-
title ? /* @__PURE__ */ (0,
|
|
4151
|
-
meta ? /* @__PURE__ */ (0,
|
|
5030
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("header", { className: ["uic-panel-head", classNames.head || ""].filter(Boolean).join(" "), children: [
|
|
5031
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "uic-panel-titles", children: [
|
|
5032
|
+
title ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Heading, { className: "uic-panel-title", children: title }) : null,
|
|
5033
|
+
meta ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "uic-panel-meta", children: meta }) : null
|
|
4152
5034
|
] }),
|
|
4153
|
-
actions ? /* @__PURE__ */ (0,
|
|
5035
|
+
actions ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "uic-panel-acts", children: actions }) : null
|
|
4154
5036
|
] }),
|
|
4155
|
-
busy ? /* @__PURE__ */ (0,
|
|
4156
|
-
/* @__PURE__ */ (0,
|
|
4157
|
-
footer ? /* @__PURE__ */ (0,
|
|
5037
|
+
busy ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "uic-panel-busy", role: "status", "aria-label": busyLabel }) : null,
|
|
5038
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: ["uic-panel-body", classNames.body || ""].filter(Boolean).join(" "), children: body }),
|
|
5039
|
+
footer ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("footer", { className: "uic-panel-foot", children: footer }) : null
|
|
4158
5040
|
]
|
|
4159
5041
|
}
|
|
4160
5042
|
);
|
|
4161
5043
|
}
|
|
4162
5044
|
|
|
4163
5045
|
// src/grid/PanelGrid.jsx
|
|
4164
|
-
var
|
|
5046
|
+
var import_react27 = __toESM(require("react"), 1);
|
|
4165
5047
|
|
|
4166
5048
|
// src/grid/layout.js
|
|
4167
5049
|
function sortLayout(layout2) {
|
|
@@ -4234,11 +5116,11 @@ function sameLayout(a, b) {
|
|
|
4234
5116
|
}
|
|
4235
5117
|
|
|
4236
5118
|
// src/grid/PanelGrid.jsx
|
|
4237
|
-
var
|
|
5119
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
4238
5120
|
function useMeasuredWidth() {
|
|
4239
|
-
const ref = (0,
|
|
4240
|
-
const [width, setWidth] = (0,
|
|
4241
|
-
(0,
|
|
5121
|
+
const ref = (0, import_react27.useRef)(null);
|
|
5122
|
+
const [width, setWidth] = (0, import_react27.useState)(0);
|
|
5123
|
+
(0, import_react27.useLayoutEffect)(() => {
|
|
4242
5124
|
const el = ref.current;
|
|
4243
5125
|
if (!el) return void 0;
|
|
4244
5126
|
const measure = () => setWidth(el.clientWidth);
|
|
@@ -4265,9 +5147,9 @@ function PanelGrid(props) {
|
|
|
4265
5147
|
className = ""
|
|
4266
5148
|
} = props;
|
|
4267
5149
|
const [wrapRef, width] = useMeasuredWidth();
|
|
4268
|
-
const [drag, setDrag] = (0,
|
|
4269
|
-
const dragRef = (0,
|
|
4270
|
-
const swallowClick = (0,
|
|
5150
|
+
const [drag, setDrag] = (0, import_react27.useState)(null);
|
|
5151
|
+
const dragRef = (0, import_react27.useRef)(null);
|
|
5152
|
+
const swallowClick = (0, import_react27.useRef)(false);
|
|
4271
5153
|
const stacked = width > 0 && width < stackAt;
|
|
4272
5154
|
const arrangeable = editable && !stacked;
|
|
4273
5155
|
const live = drag ? drag.preview : layout2;
|
|
@@ -4275,7 +5157,7 @@ function PanelGrid(props) {
|
|
|
4275
5157
|
const cellW = colW + gap;
|
|
4276
5158
|
const cellH = rowHeight + gap;
|
|
4277
5159
|
const rowsToPx = (h) => h * rowHeight + (h - 1) * gap;
|
|
4278
|
-
const stack2 = (0,
|
|
5160
|
+
const stack2 = (0, import_react27.useMemo)(() => {
|
|
4279
5161
|
if (!stacked) return null;
|
|
4280
5162
|
const tops = /* @__PURE__ */ new Map();
|
|
4281
5163
|
let y = 0;
|
|
@@ -4287,11 +5169,11 @@ function PanelGrid(props) {
|
|
|
4287
5169
|
}, [stacked, live, rowHeight, gap]);
|
|
4288
5170
|
const rows = layoutRows(live);
|
|
4289
5171
|
const height = stacked ? stack2.height : rows ? rowsToPx(rows) : 0;
|
|
4290
|
-
const commit = (0,
|
|
5172
|
+
const commit = (0, import_react27.useCallback)((next) => {
|
|
4291
5173
|
if (onLayoutChange && !sameLayout(next, layout2)) onLayoutChange(next);
|
|
4292
5174
|
}, [onLayoutChange, layout2]);
|
|
4293
|
-
const detach = (0,
|
|
4294
|
-
(0,
|
|
5175
|
+
const detach = (0, import_react27.useRef)(null);
|
|
5176
|
+
(0, import_react27.useEffect)(() => () => detach.current?.(), []);
|
|
4295
5177
|
const start = (id, mode) => (e) => {
|
|
4296
5178
|
if (!arrangeable || e.button !== 0) return;
|
|
4297
5179
|
const item = layout2.find((it) => it.i === id);
|
|
@@ -4356,7 +5238,7 @@ function PanelGrid(props) {
|
|
|
4356
5238
|
const byId = new Map(live.map((it) => [it.i, it]));
|
|
4357
5239
|
const ghost = drag && drag.mode === "move" && byId.has(drag.id) ? boxOf(byId.get(drag.id)) : null;
|
|
4358
5240
|
const cls = ["uic-pg", arrangeable ? "is-editable" : "", stacked ? "is-stacked" : "", className].filter(Boolean).join(" ");
|
|
4359
|
-
return /* @__PURE__ */ (0,
|
|
5241
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
4360
5242
|
"div",
|
|
4361
5243
|
{
|
|
4362
5244
|
ref: wrapRef,
|
|
@@ -4367,15 +5249,15 @@ function PanelGrid(props) {
|
|
|
4367
5249
|
swallowClick.current = false;
|
|
4368
5250
|
},
|
|
4369
5251
|
children: [
|
|
4370
|
-
ghost ? /* @__PURE__ */ (0,
|
|
4371
|
-
width > 0 &&
|
|
4372
|
-
if (!
|
|
5252
|
+
ghost ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "uic-pg-ghost", "aria-hidden": "true", style: ghost }) : null,
|
|
5253
|
+
width > 0 && import_react27.default.Children.map(children, (child) => {
|
|
5254
|
+
if (!import_react27.default.isValidElement(child) || child.key == null) return null;
|
|
4373
5255
|
const id = String(child.key).replace(/^\.\$/, "");
|
|
4374
5256
|
const it = byId.get(id);
|
|
4375
5257
|
if (!it) return null;
|
|
4376
5258
|
const moving = drag && drag.id === id;
|
|
4377
5259
|
const offset = moving && drag.mode === "move" ? { transform: `translate(${drag.dx}px, ${drag.dy}px)` } : null;
|
|
4378
|
-
return /* @__PURE__ */ (0,
|
|
5260
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
4379
5261
|
"div",
|
|
4380
5262
|
{
|
|
4381
5263
|
className: "uic-pg-item" + (moving ? " is-moving" : ""),
|
|
@@ -4383,7 +5265,7 @@ function PanelGrid(props) {
|
|
|
4383
5265
|
onPointerDown: arrangeable ? start(id, "move") : void 0,
|
|
4384
5266
|
children: [
|
|
4385
5267
|
child,
|
|
4386
|
-
arrangeable && !it.static ? /* @__PURE__ */ (0,
|
|
5268
|
+
arrangeable && !it.static ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
4387
5269
|
"button",
|
|
4388
5270
|
{
|
|
4389
5271
|
type: "button",
|
|
@@ -4391,7 +5273,7 @@ function PanelGrid(props) {
|
|
|
4391
5273
|
"aria-label": resizeLabel ? resizeLabel(id) : "Resize panel. Arrow keys resize it; shift with arrow keys moves it past its neighbours.",
|
|
4392
5274
|
onPointerDown: start(id, "resize"),
|
|
4393
5275
|
onKeyDown: onHandleKey(id),
|
|
4394
|
-
children: /* @__PURE__ */ (0,
|
|
5276
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("svg", { width: "10", height: "10", viewBox: "0 0 10 10", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("path", { d: "M9 1v8H1", fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round" }) })
|
|
4395
5277
|
}
|
|
4396
5278
|
) : null
|
|
4397
5279
|
]
|
|
@@ -4408,8 +5290,8 @@ function packLayout(layout2, cols = 12) {
|
|
|
4408
5290
|
}
|
|
4409
5291
|
|
|
4410
5292
|
// src/timeline/Timeline.jsx
|
|
4411
|
-
var
|
|
4412
|
-
var
|
|
5293
|
+
var import_react28 = require("react");
|
|
5294
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
4413
5295
|
var TL_MIN_PPS = 4;
|
|
4414
5296
|
var TL_MAX_PPS = 400;
|
|
4415
5297
|
var TL_DEFAULT_PPS = 26;
|
|
@@ -4498,21 +5380,21 @@ function Timeline({
|
|
|
4498
5380
|
emptyLabel = "Nothing here yet.",
|
|
4499
5381
|
className = ""
|
|
4500
5382
|
}) {
|
|
4501
|
-
const scroller = (0,
|
|
4502
|
-
const innerRef = (0,
|
|
4503
|
-
const [pps, setPps] = (0,
|
|
5383
|
+
const scroller = (0, import_react28.useRef)(null);
|
|
5384
|
+
const innerRef = (0, import_react28.useRef)(null);
|
|
5385
|
+
const [pps, setPps] = (0, import_react28.useState)(() => {
|
|
4504
5386
|
if (zoomStorageKey && typeof window !== "undefined") {
|
|
4505
5387
|
const n = parseFloat(window.localStorage.getItem(zoomStorageKey) || "");
|
|
4506
5388
|
if (Number.isFinite(n)) return clamp(n, TL_MIN_PPS, TL_MAX_PPS);
|
|
4507
5389
|
}
|
|
4508
5390
|
return TL_DEFAULT_PPS;
|
|
4509
5391
|
});
|
|
4510
|
-
const [snapping, setSnapping] = (0,
|
|
4511
|
-
const gesture = (0,
|
|
4512
|
-
const [drag, setDrag] = (0,
|
|
4513
|
-
const anchor = (0,
|
|
4514
|
-
const [dropAt, setDropAt] = (0,
|
|
4515
|
-
const rows = (0,
|
|
5392
|
+
const [snapping, setSnapping] = (0, import_react28.useState)(() => snapStorageKey && typeof window !== "undefined" ? window.localStorage.getItem(snapStorageKey) !== "0" : true);
|
|
5393
|
+
const gesture = (0, import_react28.useRef)(null);
|
|
5394
|
+
const [drag, setDrag] = (0, import_react28.useState)(null);
|
|
5395
|
+
const anchor = (0, import_react28.useRef)(null);
|
|
5396
|
+
const [dropAt, setDropAt] = (0, import_react28.useState)(null);
|
|
5397
|
+
const rows = (0, import_react28.useMemo)(
|
|
4516
5398
|
() => tracks.map((t) => ({
|
|
4517
5399
|
...t,
|
|
4518
5400
|
sequential: t.sequential !== false,
|
|
@@ -4520,12 +5402,12 @@ function Timeline({
|
|
|
4520
5402
|
})),
|
|
4521
5403
|
[tracks, pps]
|
|
4522
5404
|
);
|
|
4523
|
-
const contentSeconds = (0,
|
|
5405
|
+
const contentSeconds = (0, import_react28.useMemo)(() => {
|
|
4524
5406
|
let end = 0;
|
|
4525
5407
|
for (const t of rows) for (const l of t.laid) end = Math.max(end, l.t0 + l.w / pps);
|
|
4526
5408
|
return end;
|
|
4527
5409
|
}, [rows, pps]);
|
|
4528
|
-
const snapTimes = (0,
|
|
5410
|
+
const snapTimes = (0, import_react28.useMemo)(() => {
|
|
4529
5411
|
const out = [0, currentTime];
|
|
4530
5412
|
for (const t of rows) for (const l of t.laid) {
|
|
4531
5413
|
out.push(l.t0);
|
|
@@ -4533,7 +5415,7 @@ function Timeline({
|
|
|
4533
5415
|
}
|
|
4534
5416
|
return out;
|
|
4535
5417
|
}, [rows, pps, currentTime]);
|
|
4536
|
-
const setZoom = (0,
|
|
5418
|
+
const setZoom = (0, import_react28.useCallback)((next, clientX) => {
|
|
4537
5419
|
const v = clamp(next, TL_MIN_PPS, TL_MAX_PPS);
|
|
4538
5420
|
const el = scroller.current;
|
|
4539
5421
|
if (el) {
|
|
@@ -4549,21 +5431,21 @@ function Timeline({
|
|
|
4549
5431
|
}
|
|
4550
5432
|
}
|
|
4551
5433
|
}, [pps, zoomStorageKey]);
|
|
4552
|
-
const fitPps = (0,
|
|
5434
|
+
const fitPps = (0, import_react28.useCallback)((seconds) => {
|
|
4553
5435
|
const el = scroller.current;
|
|
4554
5436
|
if (!el || !(seconds > 0)) return null;
|
|
4555
5437
|
const room = el.clientWidth - TL_HEAD_W - 56;
|
|
4556
5438
|
return room > 0 ? clamp(room / seconds, TL_MIN_PPS, TL_MAX_PPS) : null;
|
|
4557
5439
|
}, []);
|
|
4558
|
-
const fit = (0,
|
|
5440
|
+
const fit = (0, import_react28.useCallback)(() => {
|
|
4559
5441
|
const v = fitPps(contentSeconds);
|
|
4560
5442
|
if (v !== null) {
|
|
4561
5443
|
setPps(v);
|
|
4562
5444
|
if (scroller.current) scroller.current.scrollLeft = 0;
|
|
4563
5445
|
}
|
|
4564
5446
|
}, [fitPps, contentSeconds]);
|
|
4565
|
-
const fitted = (0,
|
|
4566
|
-
(0,
|
|
5447
|
+
const fitted = (0, import_react28.useRef)(false);
|
|
5448
|
+
(0, import_react28.useLayoutEffect)(() => {
|
|
4567
5449
|
if (fitted.current || !(contentSeconds > 0)) return;
|
|
4568
5450
|
if (zoomStorageKey && typeof window !== "undefined" && window.localStorage.getItem(zoomStorageKey)) {
|
|
4569
5451
|
fitted.current = true;
|
|
@@ -4575,13 +5457,13 @@ function Timeline({
|
|
|
4575
5457
|
setPps(v);
|
|
4576
5458
|
}
|
|
4577
5459
|
}, [contentSeconds, fitPps, zoomStorageKey]);
|
|
4578
|
-
(0,
|
|
5460
|
+
(0, import_react28.useLayoutEffect)(() => {
|
|
4579
5461
|
const a = anchor.current;
|
|
4580
5462
|
if (!a || !scroller.current) return;
|
|
4581
5463
|
anchor.current = null;
|
|
4582
5464
|
scroller.current.scrollLeft = Math.max(0, TL_HEAD_W + a.t * pps - a.vx);
|
|
4583
5465
|
}, [pps]);
|
|
4584
|
-
(0,
|
|
5466
|
+
(0, import_react28.useEffect)(() => {
|
|
4585
5467
|
const el = scroller.current;
|
|
4586
5468
|
if (!el) return void 0;
|
|
4587
5469
|
const onWheel = (e) => {
|
|
@@ -4592,12 +5474,12 @@ function Timeline({
|
|
|
4592
5474
|
el.addEventListener("wheel", onWheel, { passive: false });
|
|
4593
5475
|
return () => el.removeEventListener("wheel", onWheel);
|
|
4594
5476
|
}, [pps, setZoom]);
|
|
4595
|
-
const timeAt = (0,
|
|
5477
|
+
const timeAt = (0, import_react28.useCallback)((clientX) => {
|
|
4596
5478
|
const el = innerRef.current;
|
|
4597
5479
|
if (!el) return 0;
|
|
4598
5480
|
return Math.max(0, (clientX - el.getBoundingClientRect().left - TL_HEAD_W) / pps);
|
|
4599
5481
|
}, [pps]);
|
|
4600
|
-
const beginGesture = (0,
|
|
5482
|
+
const beginGesture = (0, import_react28.useCallback)((e, spec) => {
|
|
4601
5483
|
e.preventDefault();
|
|
4602
5484
|
e.stopPropagation();
|
|
4603
5485
|
gesture.current = { ...spec, startX: e.clientX, active: false, value: null };
|
|
@@ -4631,12 +5513,12 @@ function Timeline({
|
|
|
4631
5513
|
window.addEventListener("pointermove", move);
|
|
4632
5514
|
window.addEventListener("pointerup", up);
|
|
4633
5515
|
}, [timeAt, snapping, snapTimes, pps, onSeek]);
|
|
4634
|
-
const onScrub = (0,
|
|
5516
|
+
const onScrub = (0, import_react28.useCallback)((e) => {
|
|
4635
5517
|
if (!onSeek) return;
|
|
4636
5518
|
onSeek(timeAt(e.clientX));
|
|
4637
5519
|
beginGesture(e, { kind: "scrub" });
|
|
4638
5520
|
}, [onSeek, timeAt, beginGesture]);
|
|
4639
|
-
const splitTarget = (0,
|
|
5521
|
+
const splitTarget = (0, import_react28.useMemo)(() => {
|
|
4640
5522
|
if (!onSplit) return null;
|
|
4641
5523
|
for (const track of rows) {
|
|
4642
5524
|
for (const l of track.laid) {
|
|
@@ -4648,17 +5530,17 @@ function Timeline({
|
|
|
4648
5530
|
}
|
|
4649
5531
|
return null;
|
|
4650
5532
|
}, [rows, currentTime, onSplit]);
|
|
4651
|
-
const doSplit = (0,
|
|
5533
|
+
const doSplit = (0, import_react28.useCallback)(() => {
|
|
4652
5534
|
if (!splitTarget) return;
|
|
4653
5535
|
onSplit(splitTarget.l.clip, currentTime - splitTarget.l.t0, splitTarget.track);
|
|
4654
5536
|
}, [splitTarget, currentTime, onSplit]);
|
|
4655
|
-
const selected = (0,
|
|
5537
|
+
const selected = (0, import_react28.useMemo)(() => {
|
|
4656
5538
|
for (const track of rows) for (const l of track.laid) {
|
|
4657
5539
|
if (l.clip.id === selectedClipId) return { track, l };
|
|
4658
5540
|
}
|
|
4659
5541
|
return null;
|
|
4660
5542
|
}, [rows, selectedClipId]);
|
|
4661
|
-
const onKeyDown = (0,
|
|
5543
|
+
const onKeyDown = (0, import_react28.useCallback)((e) => {
|
|
4662
5544
|
const tag = e.target?.tagName;
|
|
4663
5545
|
if (tag === "INPUT" || tag === "TEXTAREA" || e.target?.isContentEditable) return;
|
|
4664
5546
|
if (e.key === "+" || e.key === "=") {
|
|
@@ -4675,7 +5557,7 @@ function Timeline({
|
|
|
4675
5557
|
onDeleteClip(selected.l.clip, selected.track);
|
|
4676
5558
|
}
|
|
4677
5559
|
}, [pps, setZoom, doSplit, selected, onDeleteClip]);
|
|
4678
|
-
const toggleSnap = (0,
|
|
5560
|
+
const toggleSnap = (0, import_react28.useCallback)(() => {
|
|
4679
5561
|
setSnapping((v) => {
|
|
4680
5562
|
const next = !v;
|
|
4681
5563
|
if (snapStorageKey && typeof window !== "undefined") {
|
|
@@ -4692,9 +5574,9 @@ function Timeline({
|
|
|
4692
5574
|
const laneW = Math.max(contentSeconds * pps + 140, 320);
|
|
4693
5575
|
const ticks = [];
|
|
4694
5576
|
for (let t = 0; t <= contentSeconds + major; t += major) ticks.push(t);
|
|
4695
|
-
return /* @__PURE__ */ (0,
|
|
4696
|
-
/* @__PURE__ */ (0,
|
|
4697
|
-
onSplit && /* @__PURE__ */ (0,
|
|
5577
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: `rui-tl ${className}`, onKeyDown, tabIndex: 0, children: [
|
|
5578
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "rui-tl-bar", children: [
|
|
5579
|
+
onSplit && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
4698
5580
|
"button",
|
|
4699
5581
|
{
|
|
4700
5582
|
type: "button",
|
|
@@ -4703,7 +5585,7 @@ function Timeline({
|
|
|
4703
5585
|
disabled: !splitTarget,
|
|
4704
5586
|
title: splitTarget ? "Split at the playhead (B)" : "Move the playhead inside a clip to split it",
|
|
4705
5587
|
children: [
|
|
4706
|
-
/* @__PURE__ */ (0,
|
|
5588
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
4707
5589
|
"svg",
|
|
4708
5590
|
{
|
|
4709
5591
|
width: "13",
|
|
@@ -4715,19 +5597,19 @@ function Timeline({
|
|
|
4715
5597
|
strokeLinecap: "round",
|
|
4716
5598
|
"aria-hidden": "true",
|
|
4717
5599
|
children: [
|
|
4718
|
-
/* @__PURE__ */ (0,
|
|
4719
|
-
/* @__PURE__ */ (0,
|
|
4720
|
-
/* @__PURE__ */ (0,
|
|
4721
|
-
/* @__PURE__ */ (0,
|
|
4722
|
-
/* @__PURE__ */ (0,
|
|
5600
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("circle", { cx: "6", cy: "6", r: "3" }),
|
|
5601
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("circle", { cx: "6", cy: "18", r: "3" }),
|
|
5602
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("line", { x1: "20", y1: "4", x2: "8.12", y2: "15.88" }),
|
|
5603
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("line", { x1: "14.47", y1: "14.48", x2: "20", y2: "20" }),
|
|
5604
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("line", { x1: "8.12", y1: "8.12", x2: "12", y2: "12" })
|
|
4723
5605
|
]
|
|
4724
5606
|
}
|
|
4725
5607
|
),
|
|
4726
|
-
/* @__PURE__ */ (0,
|
|
5608
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { children: "Split" })
|
|
4727
5609
|
]
|
|
4728
5610
|
}
|
|
4729
5611
|
),
|
|
4730
|
-
onDeleteClip && /* @__PURE__ */ (0,
|
|
5612
|
+
onDeleteClip && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4731
5613
|
"button",
|
|
4732
5614
|
{
|
|
4733
5615
|
type: "button",
|
|
@@ -4738,7 +5620,7 @@ function Timeline({
|
|
|
4738
5620
|
children: "Remove"
|
|
4739
5621
|
}
|
|
4740
5622
|
),
|
|
4741
|
-
/* @__PURE__ */ (0,
|
|
5623
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4742
5624
|
"button",
|
|
4743
5625
|
{
|
|
4744
5626
|
type: "button",
|
|
@@ -4749,9 +5631,9 @@ function Timeline({
|
|
|
4749
5631
|
children: "Snap"
|
|
4750
5632
|
}
|
|
4751
5633
|
),
|
|
4752
|
-
/* @__PURE__ */ (0,
|
|
4753
|
-
/* @__PURE__ */ (0,
|
|
4754
|
-
/* @__PURE__ */ (0,
|
|
5634
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "rui-tl-time", "aria-label": "Playhead position", children: exactLabel(currentTime) }),
|
|
5635
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "rui-tl-spacer" }),
|
|
5636
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4755
5637
|
"button",
|
|
4756
5638
|
{
|
|
4757
5639
|
type: "button",
|
|
@@ -4763,7 +5645,7 @@ function Timeline({
|
|
|
4763
5645
|
children: "\u2212"
|
|
4764
5646
|
}
|
|
4765
5647
|
),
|
|
4766
|
-
/* @__PURE__ */ (0,
|
|
5648
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4767
5649
|
"button",
|
|
4768
5650
|
{
|
|
4769
5651
|
type: "button",
|
|
@@ -4775,7 +5657,7 @@ function Timeline({
|
|
|
4775
5657
|
children: "+"
|
|
4776
5658
|
}
|
|
4777
5659
|
),
|
|
4778
|
-
/* @__PURE__ */ (0,
|
|
5660
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4779
5661
|
"button",
|
|
4780
5662
|
{
|
|
4781
5663
|
type: "button",
|
|
@@ -4787,10 +5669,10 @@ function Timeline({
|
|
|
4787
5669
|
}
|
|
4788
5670
|
)
|
|
4789
5671
|
] }),
|
|
4790
|
-
/* @__PURE__ */ (0,
|
|
4791
|
-
/* @__PURE__ */ (0,
|
|
4792
|
-
/* @__PURE__ */ (0,
|
|
4793
|
-
/* @__PURE__ */ (0,
|
|
5672
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "rui-tl-scroll", ref: scroller, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "rui-tl-inner", ref: innerRef, style: { width: TL_HEAD_W + laneW }, children: [
|
|
5673
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "rui-tl-row rui-tl-rulerrow", children: [
|
|
5674
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "rui-tl-head rui-tl-rulerhead", "aria-hidden": "true" }),
|
|
5675
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4794
5676
|
"div",
|
|
4795
5677
|
{
|
|
4796
5678
|
className: "rui-tl-ruler",
|
|
@@ -4819,17 +5701,17 @@ function Timeline({
|
|
|
4819
5701
|
onSeek(currentTime + step);
|
|
4820
5702
|
}
|
|
4821
5703
|
} : void 0,
|
|
4822
|
-
children: ticks.map((t) => /* @__PURE__ */ (0,
|
|
5704
|
+
children: ticks.map((t) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "rui-tl-ticklbl", style: { left: t * pps }, children: tickLabel(t, major) }, t))
|
|
4823
5705
|
}
|
|
4824
5706
|
)
|
|
4825
5707
|
] }),
|
|
4826
|
-
rows.length === 0 && /* @__PURE__ */ (0,
|
|
4827
|
-
rows.map((track) => /* @__PURE__ */ (0,
|
|
4828
|
-
/* @__PURE__ */ (0,
|
|
5708
|
+
rows.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "rui-tl-empty", children: emptyLabel }),
|
|
5709
|
+
rows.map((track) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "rui-tl-row", children: [
|
|
5710
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "rui-tl-head", title: track.title || track.label, children: [
|
|
4829
5711
|
track.icon,
|
|
4830
|
-
/* @__PURE__ */ (0,
|
|
5712
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "rui-tl-headlbl", children: track.label })
|
|
4831
5713
|
] }),
|
|
4832
|
-
/* @__PURE__ */ (0,
|
|
5714
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
4833
5715
|
"div",
|
|
4834
5716
|
{
|
|
4835
5717
|
className: "rui-tl-lane" + (dropAt?.trackId === track.id ? " is-dropping" : ""),
|
|
@@ -4860,8 +5742,8 @@ function Timeline({
|
|
|
4860
5742
|
onDropClip(payload, { trackId: track.id, seconds: t, index });
|
|
4861
5743
|
} : void 0,
|
|
4862
5744
|
children: [
|
|
4863
|
-
track.laid.length === 0 && track.emptyLabel && /* @__PURE__ */ (0,
|
|
4864
|
-
track.laid.map((l) => /* @__PURE__ */ (0,
|
|
5745
|
+
track.laid.length === 0 && track.emptyLabel && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "rui-tl-laneempty", children: track.emptyLabel }),
|
|
5746
|
+
track.laid.map((l) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4865
5747
|
Clip,
|
|
4866
5748
|
{
|
|
4867
5749
|
l,
|
|
@@ -4877,7 +5759,7 @@ function Timeline({
|
|
|
4877
5759
|
},
|
|
4878
5760
|
l.clip.id ?? l.i
|
|
4879
5761
|
)),
|
|
4880
|
-
dropAt?.trackId === track.id && /* @__PURE__ */ (0,
|
|
5762
|
+
dropAt?.trackId === track.id && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4881
5763
|
"span",
|
|
4882
5764
|
{
|
|
4883
5765
|
className: "rui-tl-dropmark",
|
|
@@ -4885,7 +5767,7 @@ function Timeline({
|
|
|
4885
5767
|
"aria-hidden": "true"
|
|
4886
5768
|
}
|
|
4887
5769
|
),
|
|
4888
|
-
laneAppend && /* @__PURE__ */ (0,
|
|
5770
|
+
laneAppend && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4889
5771
|
"span",
|
|
4890
5772
|
{
|
|
4891
5773
|
className: "rui-tl-append",
|
|
@@ -4897,9 +5779,9 @@ function Timeline({
|
|
|
4897
5779
|
}
|
|
4898
5780
|
)
|
|
4899
5781
|
] }, track.id)),
|
|
4900
|
-
onDropClip && newLaneLabel && /* @__PURE__ */ (0,
|
|
4901
|
-
/* @__PURE__ */ (0,
|
|
4902
|
-
/* @__PURE__ */ (0,
|
|
5782
|
+
onDropClip && newLaneLabel && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "rui-tl-row", children: [
|
|
5783
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "rui-tl-head rui-tl-newhead", "aria-hidden": "true" }),
|
|
5784
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4903
5785
|
"div",
|
|
4904
5786
|
{
|
|
4905
5787
|
className: "rui-tl-newlane" + (dropAt?.trackId === null ? " is-dropping" : ""),
|
|
@@ -4921,11 +5803,11 @@ function Timeline({
|
|
|
4921
5803
|
e.preventDefault();
|
|
4922
5804
|
onDropClip(payload, { trackId: null, seconds: timeAt(e.clientX), index: 0 });
|
|
4923
5805
|
},
|
|
4924
|
-
children: /* @__PURE__ */ (0,
|
|
5806
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "rui-tl-newlbl", children: newLaneLabel })
|
|
4925
5807
|
}
|
|
4926
5808
|
)
|
|
4927
5809
|
] }),
|
|
4928
|
-
drag?.guide != null && /* @__PURE__ */ (0,
|
|
5810
|
+
drag?.guide != null && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4929
5811
|
"div",
|
|
4930
5812
|
{
|
|
4931
5813
|
className: "rui-tl-guide",
|
|
@@ -4933,16 +5815,16 @@ function Timeline({
|
|
|
4933
5815
|
"aria-hidden": "true"
|
|
4934
5816
|
}
|
|
4935
5817
|
),
|
|
4936
|
-
Number.isFinite(currentTime) && /* @__PURE__ */ (0,
|
|
5818
|
+
Number.isFinite(currentTime) && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4937
5819
|
"div",
|
|
4938
5820
|
{
|
|
4939
5821
|
className: "rui-tl-playhead",
|
|
4940
5822
|
style: { left: TL_HEAD_W + currentTime * pps },
|
|
4941
5823
|
"aria-hidden": "true",
|
|
4942
|
-
children: /* @__PURE__ */ (0,
|
|
5824
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "rui-tl-playhead-grip" })
|
|
4943
5825
|
}
|
|
4944
5826
|
),
|
|
4945
|
-
drag?.annotation && /* @__PURE__ */ (0,
|
|
5827
|
+
drag?.annotation && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "rui-tl-annot", style: { left: TL_HEAD_W + (drag.annotAt || 0) * pps }, children: drag.annotation })
|
|
4946
5828
|
] }) })
|
|
4947
5829
|
] });
|
|
4948
5830
|
}
|
|
@@ -5018,7 +5900,7 @@ function Clip({
|
|
|
5018
5900
|
click: onSelect
|
|
5019
5901
|
});
|
|
5020
5902
|
};
|
|
5021
|
-
return /* @__PURE__ */ (0,
|
|
5903
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
5022
5904
|
"article",
|
|
5023
5905
|
{
|
|
5024
5906
|
className: "rui-tl-clip" + (clip.state ? ` is-${clip.state}` : "") + (known ? "" : " is-unmeasured") + (selected ? " is-selected" : "") + (live ? " is-live" : ""),
|
|
@@ -5033,10 +5915,10 @@ function Clip({
|
|
|
5033
5915
|
}
|
|
5034
5916
|
},
|
|
5035
5917
|
children: [
|
|
5036
|
-
clip.poster ? /* @__PURE__ */ (0,
|
|
5918
|
+
clip.poster ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "rui-tl-strip", style: {
|
|
5037
5919
|
backgroundImage: `url("${String(clip.poster).replace(/"/g, '\\"')}")`,
|
|
5038
5920
|
backgroundSize: `${tileW}px 100%`
|
|
5039
|
-
} }) : clip.video ? /* @__PURE__ */ (0,
|
|
5921
|
+
} }) : clip.video ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5040
5922
|
"video",
|
|
5041
5923
|
{
|
|
5042
5924
|
className: "rui-tl-frame",
|
|
@@ -5047,12 +5929,12 @@ function Clip({
|
|
|
5047
5929
|
tabIndex: -1,
|
|
5048
5930
|
"aria-hidden": "true"
|
|
5049
5931
|
}
|
|
5050
|
-
) : /* @__PURE__ */ (0,
|
|
5051
|
-
clip.badge && /* @__PURE__ */ (0,
|
|
5052
|
-
known && width > 46 && /* @__PURE__ */ (0,
|
|
5053
|
-
clip.label && width > 104 && /* @__PURE__ */ (0,
|
|
5054
|
-
onTrim && known && /* @__PURE__ */ (0,
|
|
5055
|
-
/* @__PURE__ */ (0,
|
|
5932
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "rui-tl-blank", "aria-hidden": "true", children: clip.glyph }),
|
|
5933
|
+
clip.badge && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "rui-tl-badge", children: clip.badge }),
|
|
5934
|
+
known && width > 46 && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "rui-tl-dur", children: durationLabel(clip.duration) }),
|
|
5935
|
+
clip.label && width > 104 && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "rui-tl-name", children: clip.label }),
|
|
5936
|
+
onTrim && known && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
|
|
5937
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5056
5938
|
"span",
|
|
5057
5939
|
{
|
|
5058
5940
|
className: "rui-tl-trim l",
|
|
@@ -5061,7 +5943,7 @@ function Clip({
|
|
|
5061
5943
|
"aria-label": `Trim the start of ${clip.label || "this clip"}`
|
|
5062
5944
|
}
|
|
5063
5945
|
),
|
|
5064
|
-
/* @__PURE__ */ (0,
|
|
5946
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5065
5947
|
"span",
|
|
5066
5948
|
{
|
|
5067
5949
|
className: "rui-tl-trim r",
|