reifyui 0.1.0 → 0.2.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 +5 -3
- package/dist/index.cjs +344 -170
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +18 -0
- package/dist/index.js +344 -170
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/styles/tasks.css +59 -0
package/dist/index.js
CHANGED
|
@@ -854,6 +854,178 @@ function PaneResizer(props) {
|
|
|
854
854
|
);
|
|
855
855
|
}
|
|
856
856
|
|
|
857
|
+
// src/components/TaskList.jsx
|
|
858
|
+
import { useCallback as useCallback2, useEffect as useEffect3, useMemo, useRef as useRef3, useState as useState3 } from "react";
|
|
859
|
+
import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
860
|
+
var STATUS_GROUPS = {
|
|
861
|
+
all: () => true,
|
|
862
|
+
working: (s) => ["running", "starting", "queued", "in_progress"].includes(s),
|
|
863
|
+
done: (s) => ["done", "completed"].includes(s),
|
|
864
|
+
failed: (s) => ["failed", "cancelled", "incomplete", "error"].includes(s)
|
|
865
|
+
};
|
|
866
|
+
function taskStatusGroup(status) {
|
|
867
|
+
const s = String(status || "").toLowerCase();
|
|
868
|
+
for (const k of ["working", "done", "failed"]) if (STATUS_GROUPS[k](s)) return k;
|
|
869
|
+
return "idle";
|
|
870
|
+
}
|
|
871
|
+
function relTime(ts) {
|
|
872
|
+
const n = Number(ts) || 0;
|
|
873
|
+
if (!n) return "";
|
|
874
|
+
const ms = n > 1e12 ? n : n * 1e3;
|
|
875
|
+
const d = Math.max(0, Date.now() - ms) / 1e3;
|
|
876
|
+
if (d < 60) return "just now";
|
|
877
|
+
if (d < 3600) return `${Math.floor(d / 60)}m ago`;
|
|
878
|
+
if (d < 86400) return `${Math.floor(d / 3600)}h ago`;
|
|
879
|
+
return `${Math.floor(d / 86400)}d ago`;
|
|
880
|
+
}
|
|
881
|
+
function TaskList({
|
|
882
|
+
fetchPage,
|
|
883
|
+
selected,
|
|
884
|
+
onSelect,
|
|
885
|
+
onNew,
|
|
886
|
+
onDelete,
|
|
887
|
+
header,
|
|
888
|
+
renderMeta,
|
|
889
|
+
refreshNonce = 0,
|
|
890
|
+
emptyLabel = "No tasks yet",
|
|
891
|
+
newLabel = "New task",
|
|
892
|
+
idKey = "id",
|
|
893
|
+
titleKey = "title",
|
|
894
|
+
statusKey = "status",
|
|
895
|
+
timeKey = "updated_at"
|
|
896
|
+
}) {
|
|
897
|
+
const [head, setHead] = useState3(null);
|
|
898
|
+
const [tail, setTail] = useState3([]);
|
|
899
|
+
const [cursor, setCursor] = useState3("");
|
|
900
|
+
const [loadingMore, setLoadingMore] = useState3(false);
|
|
901
|
+
const [q, setQ] = useState3("");
|
|
902
|
+
const [statusFilter, setStatusFilter] = useState3("all");
|
|
903
|
+
const alive = useRef3(true);
|
|
904
|
+
useEffect3(() => () => {
|
|
905
|
+
alive.current = false;
|
|
906
|
+
}, []);
|
|
907
|
+
useEffect3(() => {
|
|
908
|
+
let ok = true;
|
|
909
|
+
Promise.resolve(fetchPage("")).then((r) => {
|
|
910
|
+
if (!ok) return;
|
|
911
|
+
setHead(Array.isArray(r?.items) ? r.items : []);
|
|
912
|
+
setCursor(r?.cursor || "");
|
|
913
|
+
}).catch(() => {
|
|
914
|
+
if (ok) setHead((p) => p ?? []);
|
|
915
|
+
});
|
|
916
|
+
return () => {
|
|
917
|
+
ok = false;
|
|
918
|
+
};
|
|
919
|
+
}, [fetchPage, refreshNonce]);
|
|
920
|
+
const loadMore = useCallback2(() => {
|
|
921
|
+
if (!cursor || loadingMore) return;
|
|
922
|
+
setLoadingMore(true);
|
|
923
|
+
Promise.resolve(fetchPage(cursor)).then((r) => {
|
|
924
|
+
if (!alive.current) return;
|
|
925
|
+
if (Array.isArray(r?.items)) setTail((t) => [...t, ...r.items]);
|
|
926
|
+
setCursor(r?.cursor || "");
|
|
927
|
+
}).catch(() => {
|
|
928
|
+
}).finally(() => {
|
|
929
|
+
if (alive.current) setLoadingMore(false);
|
|
930
|
+
});
|
|
931
|
+
}, [cursor, loadingMore, fetchPage]);
|
|
932
|
+
const items = useMemo(() => {
|
|
933
|
+
const h = head || [];
|
|
934
|
+
const seen = new Set(h.map((x) => x?.[idKey]));
|
|
935
|
+
return [...h, ...tail.filter((t) => !seen.has(t?.[idKey]))];
|
|
936
|
+
}, [head, tail, idKey]);
|
|
937
|
+
const shown = useMemo(() => {
|
|
938
|
+
const needle = q.trim().toLowerCase();
|
|
939
|
+
const pass = STATUS_GROUPS[statusFilter] || STATUS_GROUPS.all;
|
|
940
|
+
return items.filter((it) => {
|
|
941
|
+
if (!pass(String(it?.[statusKey] || "").toLowerCase())) return false;
|
|
942
|
+
if (!needle) return true;
|
|
943
|
+
return String(it?.[titleKey] || "").toLowerCase().includes(needle);
|
|
944
|
+
});
|
|
945
|
+
}, [items, q, statusFilter, statusKey, titleKey]);
|
|
946
|
+
const onScroll = (e) => {
|
|
947
|
+
const el = e.currentTarget;
|
|
948
|
+
if (el.scrollTop + el.clientHeight > el.scrollHeight - 140) loadMore();
|
|
949
|
+
};
|
|
950
|
+
return /* @__PURE__ */ jsxs6("div", { className: "rui-tasks", children: [
|
|
951
|
+
header ? /* @__PURE__ */ jsx7("div", { className: "rui-tasks-header", children: header }) : null,
|
|
952
|
+
onNew ? /* @__PURE__ */ jsxs6("button", { type: "button", className: "rui-tasks-new", onClick: onNew, children: [
|
|
953
|
+
"+ ",
|
|
954
|
+
newLabel
|
|
955
|
+
] }) : null,
|
|
956
|
+
/* @__PURE__ */ jsxs6("div", { className: "rui-tasks-filters", children: [
|
|
957
|
+
/* @__PURE__ */ jsx7(
|
|
958
|
+
"input",
|
|
959
|
+
{
|
|
960
|
+
className: "rui-tasks-search",
|
|
961
|
+
value: q,
|
|
962
|
+
placeholder: "Filter tasks\u2026",
|
|
963
|
+
onChange: (e) => setQ(e.target.value),
|
|
964
|
+
"aria-label": "Filter tasks"
|
|
965
|
+
}
|
|
966
|
+
),
|
|
967
|
+
/* @__PURE__ */ jsxs6(
|
|
968
|
+
"select",
|
|
969
|
+
{
|
|
970
|
+
className: "rui-tasks-status",
|
|
971
|
+
value: statusFilter,
|
|
972
|
+
onChange: (e) => setStatusFilter(e.target.value),
|
|
973
|
+
"aria-label": "Filter by status",
|
|
974
|
+
children: [
|
|
975
|
+
/* @__PURE__ */ jsx7("option", { value: "all", children: "All" }),
|
|
976
|
+
/* @__PURE__ */ jsx7("option", { value: "working", children: "Working" }),
|
|
977
|
+
/* @__PURE__ */ jsx7("option", { value: "done", children: "Done" }),
|
|
978
|
+
/* @__PURE__ */ jsx7("option", { value: "failed", children: "Failed" })
|
|
979
|
+
]
|
|
980
|
+
}
|
|
981
|
+
)
|
|
982
|
+
] }),
|
|
983
|
+
/* @__PURE__ */ jsxs6("div", { className: "rui-tasks-list", onScroll, children: [
|
|
984
|
+
head === null ? /* @__PURE__ */ jsx7("div", { className: "rui-tasks-empty", children: "Loading\u2026" }) : shown.length === 0 ? /* @__PURE__ */ jsx7("div", { className: "rui-tasks-empty", children: items.length ? "No matching tasks" : emptyLabel }) : shown.map((it) => {
|
|
985
|
+
const id = it?.[idKey];
|
|
986
|
+
const group = taskStatusGroup(it?.[statusKey]);
|
|
987
|
+
return /* @__PURE__ */ jsxs6(
|
|
988
|
+
"div",
|
|
989
|
+
{
|
|
990
|
+
className: `rui-task${id === selected ? " is-selected" : ""}`,
|
|
991
|
+
onClick: () => onSelect?.(id),
|
|
992
|
+
role: "button",
|
|
993
|
+
tabIndex: 0,
|
|
994
|
+
onKeyDown: (e) => {
|
|
995
|
+
if (e.key === "Enter" || e.key === " ") onSelect?.(id);
|
|
996
|
+
},
|
|
997
|
+
children: [
|
|
998
|
+
/* @__PURE__ */ jsxs6("div", { className: "rui-task-main", children: [
|
|
999
|
+
/* @__PURE__ */ jsx7("div", { className: "rui-task-title", children: it?.[titleKey] || "Untitled task" }),
|
|
1000
|
+
/* @__PURE__ */ jsx7("div", { className: "rui-task-meta", children: renderMeta ? renderMeta(it) : /* @__PURE__ */ jsxs6(Fragment2, { children: [
|
|
1001
|
+
/* @__PURE__ */ jsx7("span", { className: `rui-task-dot is-${group}` }),
|
|
1002
|
+
/* @__PURE__ */ jsx7("span", { className: "rui-task-status", children: it?.[statusKey] || "" }),
|
|
1003
|
+
it?.[timeKey] ? /* @__PURE__ */ jsx7("span", { className: "rui-task-time", children: relTime(it[timeKey]) }) : null
|
|
1004
|
+
] }) })
|
|
1005
|
+
] }),
|
|
1006
|
+
onDelete ? /* @__PURE__ */ jsx7(
|
|
1007
|
+
"button",
|
|
1008
|
+
{
|
|
1009
|
+
type: "button",
|
|
1010
|
+
className: "rui-task-del",
|
|
1011
|
+
"aria-label": "Delete task",
|
|
1012
|
+
onClick: (e) => {
|
|
1013
|
+
e.stopPropagation();
|
|
1014
|
+
onDelete(it);
|
|
1015
|
+
},
|
|
1016
|
+
children: "\xD7"
|
|
1017
|
+
}
|
|
1018
|
+
) : null
|
|
1019
|
+
]
|
|
1020
|
+
},
|
|
1021
|
+
id
|
|
1022
|
+
);
|
|
1023
|
+
}),
|
|
1024
|
+
loadingMore ? /* @__PURE__ */ jsx7("div", { className: "rui-tasks-empty", children: "Loading more\u2026" }) : null
|
|
1025
|
+
] })
|
|
1026
|
+
] });
|
|
1027
|
+
}
|
|
1028
|
+
|
|
857
1029
|
// src/auth/client.js
|
|
858
1030
|
var _cfg = {
|
|
859
1031
|
engine: "",
|
|
@@ -1003,18 +1175,18 @@ async function fetchBalance() {
|
|
|
1003
1175
|
}
|
|
1004
1176
|
|
|
1005
1177
|
// src/auth/AuthForm.jsx
|
|
1006
|
-
import { useState as
|
|
1178
|
+
import { useState as useState5 } from "react";
|
|
1007
1179
|
|
|
1008
1180
|
// src/auth/GoogleButton.jsx
|
|
1009
|
-
import { useEffect as
|
|
1010
|
-
import { Fragment as
|
|
1181
|
+
import { useEffect as useEffect4, useRef as useRef4, useState as useState4 } from "react";
|
|
1182
|
+
import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1011
1183
|
var CLIENT_ID = "247853836408-ojk91u8901hdlbkevid4fohmrfdot17l.apps.googleusercontent.com";
|
|
1012
1184
|
function GoogleButton({ onCredential, onError }) {
|
|
1013
|
-
const ref =
|
|
1014
|
-
const [failed, setFailed] =
|
|
1015
|
-
const cb =
|
|
1185
|
+
const ref = useRef4(null);
|
|
1186
|
+
const [failed, setFailed] = useState4(false);
|
|
1187
|
+
const cb = useRef4({ onCredential, onError });
|
|
1016
1188
|
cb.current = { onCredential, onError };
|
|
1017
|
-
|
|
1189
|
+
useEffect4(() => {
|
|
1018
1190
|
if (!CLIENT_ID || !ref.current) return void 0;
|
|
1019
1191
|
const SRC = "https://accounts.google.com/gsi/client";
|
|
1020
1192
|
let done = false;
|
|
@@ -1065,24 +1237,24 @@ function GoogleButton({ onCredential, onError }) {
|
|
|
1065
1237
|
};
|
|
1066
1238
|
}, []);
|
|
1067
1239
|
if (!CLIENT_ID || failed) return null;
|
|
1068
|
-
return /* @__PURE__ */
|
|
1069
|
-
/* @__PURE__ */
|
|
1070
|
-
/* @__PURE__ */
|
|
1240
|
+
return /* @__PURE__ */ jsxs7(Fragment3, { children: [
|
|
1241
|
+
/* @__PURE__ */ jsx8("div", { className: "auth-or", children: /* @__PURE__ */ jsx8("span", { children: "or" }) }),
|
|
1242
|
+
/* @__PURE__ */ jsx8("div", { ref, className: "auth-gwrap" })
|
|
1071
1243
|
] });
|
|
1072
1244
|
}
|
|
1073
1245
|
var GOOGLE_ENABLED = !!CLIENT_ID;
|
|
1074
1246
|
|
|
1075
1247
|
// src/auth/AuthForm.jsx
|
|
1076
|
-
import { Fragment as
|
|
1248
|
+
import { Fragment as Fragment4, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1077
1249
|
function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
|
|
1078
|
-
const [mode, setMode] =
|
|
1079
|
-
const [email, setEmail] =
|
|
1080
|
-
const [password, setPassword] =
|
|
1081
|
-
const [name, setName] =
|
|
1082
|
-
const [err, setErr] =
|
|
1083
|
-
const [busy, setBusy] =
|
|
1084
|
-
const [choices, setChoices] =
|
|
1085
|
-
const [resetSent, setResetSent] =
|
|
1250
|
+
const [mode, setMode] = useState5("signin");
|
|
1251
|
+
const [email, setEmail] = useState5("");
|
|
1252
|
+
const [password, setPassword] = useState5("");
|
|
1253
|
+
const [name, setName] = useState5("");
|
|
1254
|
+
const [err, setErr] = useState5("");
|
|
1255
|
+
const [busy, setBusy] = useState5(false);
|
|
1256
|
+
const [choices, setChoices] = useState5(null);
|
|
1257
|
+
const [resetSent, setResetSent] = useState5(false);
|
|
1086
1258
|
async function enter(orgId) {
|
|
1087
1259
|
const session = await switchOrg(orgId);
|
|
1088
1260
|
onDone(session);
|
|
@@ -1123,10 +1295,10 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
|
|
|
1123
1295
|
}
|
|
1124
1296
|
}
|
|
1125
1297
|
if (choices) {
|
|
1126
|
-
return /* @__PURE__ */
|
|
1127
|
-
/* @__PURE__ */
|
|
1128
|
-
/* @__PURE__ */
|
|
1129
|
-
/* @__PURE__ */
|
|
1298
|
+
return /* @__PURE__ */ jsxs8("div", { children: [
|
|
1299
|
+
/* @__PURE__ */ jsx9("div", { className: "logo", children: brand }),
|
|
1300
|
+
/* @__PURE__ */ jsx9("h1", { children: "Choose workspace" }),
|
|
1301
|
+
/* @__PURE__ */ jsx9("div", { className: "org-list", children: choices.map((o) => /* @__PURE__ */ jsx9(
|
|
1130
1302
|
"button",
|
|
1131
1303
|
{
|
|
1132
1304
|
type: "button",
|
|
@@ -1144,20 +1316,20 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
|
|
|
1144
1316
|
},
|
|
1145
1317
|
o.id
|
|
1146
1318
|
)) }),
|
|
1147
|
-
err && /* @__PURE__ */
|
|
1319
|
+
err && /* @__PURE__ */ jsx9("div", { className: "auth-err", children: err })
|
|
1148
1320
|
] });
|
|
1149
1321
|
}
|
|
1150
|
-
return /* @__PURE__ */
|
|
1151
|
-
/* @__PURE__ */
|
|
1152
|
-
/* @__PURE__ */
|
|
1153
|
-
/* @__PURE__ */
|
|
1154
|
-
mode === "forgot" ? resetSent ? /* @__PURE__ */
|
|
1155
|
-
/* @__PURE__ */
|
|
1322
|
+
return /* @__PURE__ */ jsxs8("form", { onSubmit: submit, children: [
|
|
1323
|
+
/* @__PURE__ */ jsx9("div", { className: "logo", children: brand }),
|
|
1324
|
+
/* @__PURE__ */ jsx9("h1", { children: mode === "register" ? "Create your account" : mode === "forgot" ? "Reset password" : "Sign in" }),
|
|
1325
|
+
/* @__PURE__ */ jsx9("p", { className: "sub", children: mode === "register" ? "Get started in seconds." : mode === "forgot" ? "We will email you a reset link." : subtitle || "Welcome back." }),
|
|
1326
|
+
mode === "forgot" ? resetSent ? /* @__PURE__ */ jsxs8(Fragment4, { children: [
|
|
1327
|
+
/* @__PURE__ */ jsxs8("div", { className: "auth-note", children: [
|
|
1156
1328
|
"If an account exists for ",
|
|
1157
|
-
/* @__PURE__ */
|
|
1329
|
+
/* @__PURE__ */ jsx9("b", { children: email.trim() }),
|
|
1158
1330
|
", a password reset link is on its way. It is valid for 1 hour."
|
|
1159
1331
|
] }),
|
|
1160
|
-
/* @__PURE__ */
|
|
1332
|
+
/* @__PURE__ */ jsx9(
|
|
1161
1333
|
"button",
|
|
1162
1334
|
{
|
|
1163
1335
|
type: "button",
|
|
@@ -1171,36 +1343,36 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
|
|
|
1171
1343
|
children: "Back to sign in"
|
|
1172
1344
|
}
|
|
1173
1345
|
)
|
|
1174
|
-
] }) : /* @__PURE__ */
|
|
1175
|
-
/* @__PURE__ */
|
|
1176
|
-
/* @__PURE__ */
|
|
1177
|
-
/* @__PURE__ */
|
|
1346
|
+
] }) : /* @__PURE__ */ jsxs8(Fragment4, { children: [
|
|
1347
|
+
/* @__PURE__ */ jsxs8("div", { className: "field", children: [
|
|
1348
|
+
/* @__PURE__ */ jsx9("label", { children: "Email" }),
|
|
1349
|
+
/* @__PURE__ */ jsx9("input", { className: "input", type: "email", value: email, onChange: (e) => setEmail(e.target.value), autoFocus: true, required: true, autoComplete: "email" })
|
|
1178
1350
|
] }),
|
|
1179
|
-
err && /* @__PURE__ */
|
|
1180
|
-
/* @__PURE__ */
|
|
1181
|
-
/* @__PURE__ */
|
|
1351
|
+
err && /* @__PURE__ */ jsx9("div", { className: "auth-err", children: err }),
|
|
1352
|
+
/* @__PURE__ */ jsx9("button", { type: "submit", className: "btn primary lg", style: { width: "100%", marginTop: 8 }, disabled: busy, children: busy ? "Please wait..." : "Send reset link" }),
|
|
1353
|
+
/* @__PURE__ */ jsx9("p", { className: "auth-switch", children: /* @__PURE__ */ jsx9("button", { type: "button", onClick: () => {
|
|
1182
1354
|
setErr("");
|
|
1183
1355
|
setMode("signin");
|
|
1184
1356
|
}, children: "Back to sign in" }) })
|
|
1185
|
-
] }) : /* @__PURE__ */
|
|
1186
|
-
mode === "register" && /* @__PURE__ */
|
|
1187
|
-
/* @__PURE__ */
|
|
1188
|
-
/* @__PURE__ */
|
|
1357
|
+
] }) : /* @__PURE__ */ jsxs8(Fragment4, { children: [
|
|
1358
|
+
mode === "register" && /* @__PURE__ */ jsxs8("div", { className: "field", children: [
|
|
1359
|
+
/* @__PURE__ */ jsx9("label", { children: "Name" }),
|
|
1360
|
+
/* @__PURE__ */ jsx9("input", { className: "input", value: name, onChange: (e) => setName(e.target.value), autoComplete: "name", placeholder: "Jane Doe" })
|
|
1189
1361
|
] }),
|
|
1190
|
-
/* @__PURE__ */
|
|
1191
|
-
/* @__PURE__ */
|
|
1192
|
-
/* @__PURE__ */
|
|
1362
|
+
/* @__PURE__ */ jsxs8("div", { className: "field", children: [
|
|
1363
|
+
/* @__PURE__ */ jsx9("label", { children: "Email" }),
|
|
1364
|
+
/* @__PURE__ */ jsx9("input", { className: "input", type: "email", value: email, onChange: (e) => setEmail(e.target.value), autoFocus: true, required: true, autoComplete: "email" })
|
|
1193
1365
|
] }),
|
|
1194
|
-
/* @__PURE__ */
|
|
1195
|
-
/* @__PURE__ */
|
|
1196
|
-
/* @__PURE__ */
|
|
1197
|
-
mode === "signin" && /* @__PURE__ */
|
|
1366
|
+
/* @__PURE__ */ jsxs8("div", { className: "field", children: [
|
|
1367
|
+
/* @__PURE__ */ jsxs8("div", { className: "field-row", children: [
|
|
1368
|
+
/* @__PURE__ */ jsx9("label", { children: "Password" }),
|
|
1369
|
+
mode === "signin" && /* @__PURE__ */ jsx9("button", { type: "button", className: "link-sm", onClick: () => {
|
|
1198
1370
|
setErr("");
|
|
1199
1371
|
setResetSent(false);
|
|
1200
1372
|
setMode("forgot");
|
|
1201
1373
|
}, children: "Forgot password?" })
|
|
1202
1374
|
] }),
|
|
1203
|
-
/* @__PURE__ */
|
|
1375
|
+
/* @__PURE__ */ jsx9(
|
|
1204
1376
|
"input",
|
|
1205
1377
|
{
|
|
1206
1378
|
className: "input",
|
|
@@ -1213,13 +1385,13 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
|
|
|
1213
1385
|
}
|
|
1214
1386
|
)
|
|
1215
1387
|
] }),
|
|
1216
|
-
err && /* @__PURE__ */
|
|
1217
|
-
/* @__PURE__ */
|
|
1218
|
-
GOOGLE_ENABLED && /* @__PURE__ */
|
|
1219
|
-
/* @__PURE__ */
|
|
1388
|
+
err && /* @__PURE__ */ jsx9("div", { className: "auth-err", children: err }),
|
|
1389
|
+
/* @__PURE__ */ jsx9("button", { type: "submit", className: "btn primary lg", style: { width: "100%", marginTop: 8 }, disabled: busy, children: busy ? "Please wait..." : mode === "register" ? "Create account" : "Sign in" }),
|
|
1390
|
+
GOOGLE_ENABLED && /* @__PURE__ */ jsx9(GoogleButton, { onCredential: onGoogle, onError: setErr }),
|
|
1391
|
+
/* @__PURE__ */ jsxs8("p", { className: "auth-switch", children: [
|
|
1220
1392
|
mode === "register" ? "Already have an account?" : `New to ${productName || "the product"}?`,
|
|
1221
1393
|
" ",
|
|
1222
|
-
/* @__PURE__ */
|
|
1394
|
+
/* @__PURE__ */ jsx9("button", { type: "button", onClick: () => {
|
|
1223
1395
|
setErr("");
|
|
1224
1396
|
setMode(mode === "register" ? "signin" : "register");
|
|
1225
1397
|
}, children: mode === "register" ? "Sign in" : "Create one" })
|
|
@@ -1229,9 +1401,9 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
|
|
|
1229
1401
|
}
|
|
1230
1402
|
|
|
1231
1403
|
// src/sheet/SheetGrid.jsx
|
|
1232
|
-
import { useEffect as
|
|
1404
|
+
import { useEffect as useEffect5, useRef as useRef5, useState as useState6 } from "react";
|
|
1233
1405
|
import { createPortal } from "react-dom";
|
|
1234
|
-
import { Fragment as
|
|
1406
|
+
import { Fragment as Fragment5, jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1235
1407
|
var cellKey = (rowId, colId) => `${rowId}:${colId}`;
|
|
1236
1408
|
var uid = (p) => `${p}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1237
1409
|
var TYPE_LABEL = {
|
|
@@ -1255,7 +1427,7 @@ var COMPUTE_KINDS = [
|
|
|
1255
1427
|
var RESOURCE_KINDS = ["image", "sheet", "slides", "workflow", "graph"];
|
|
1256
1428
|
var RESOURCE_ICON = { image: "\u{1F5BC}", sheet: "\u25A6", slides: "\u25A4", workflow: "\u2699", graph: "\u25C9" };
|
|
1257
1429
|
function PopPortal({ anchor, width = 250, estHeight = 300, className, children, onClose }) {
|
|
1258
|
-
|
|
1430
|
+
useEffect5(() => {
|
|
1259
1431
|
if (!onClose) return void 0;
|
|
1260
1432
|
const close = () => onClose();
|
|
1261
1433
|
window.addEventListener("scroll", close, true);
|
|
@@ -1270,7 +1442,7 @@ function PopPortal({ anchor, width = 250, estHeight = 300, className, children,
|
|
|
1270
1442
|
let top = anchor.bottom + 6;
|
|
1271
1443
|
if (top + estHeight > window.innerHeight - 8) top = Math.max(8, anchor.top - estHeight - 6);
|
|
1272
1444
|
return createPortal(
|
|
1273
|
-
/* @__PURE__ */
|
|
1445
|
+
/* @__PURE__ */ jsx10("div", { className, style: { position: "fixed", top, left, width, zIndex: 1e3 }, children }),
|
|
1274
1446
|
document.body
|
|
1275
1447
|
);
|
|
1276
1448
|
}
|
|
@@ -1290,8 +1462,8 @@ function pillColor(label, options) {
|
|
|
1290
1462
|
return PILL_FALLBACKS[h % PILL_FALLBACKS.length];
|
|
1291
1463
|
}
|
|
1292
1464
|
function RefImage({ refVal, fetchBlobUrl }) {
|
|
1293
|
-
const [src, setSrc] =
|
|
1294
|
-
|
|
1465
|
+
const [src, setSrc] = useState6(/^https?:\/\//i.test(refVal.url || "") ? refVal.url : null);
|
|
1466
|
+
useEffect5(() => {
|
|
1295
1467
|
let dead = false;
|
|
1296
1468
|
let obj = null;
|
|
1297
1469
|
if (!src && refVal.url && fetchBlobUrl) {
|
|
@@ -1307,16 +1479,16 @@ function RefImage({ refVal, fetchBlobUrl }) {
|
|
|
1307
1479
|
if (obj) URL.revokeObjectURL(obj);
|
|
1308
1480
|
};
|
|
1309
1481
|
}, [refVal.url]);
|
|
1310
|
-
if (!src) return /* @__PURE__ */
|
|
1482
|
+
if (!src) return /* @__PURE__ */ jsxs9("span", { className: "shg-refchip", children: [
|
|
1311
1483
|
RESOURCE_ICON.image,
|
|
1312
1484
|
" ",
|
|
1313
1485
|
refVal.name || "image"
|
|
1314
1486
|
] });
|
|
1315
|
-
return /* @__PURE__ */
|
|
1487
|
+
return /* @__PURE__ */ jsx10("img", { className: "shg-refimg", src, alt: refVal.name || "", title: refVal.name || "" });
|
|
1316
1488
|
}
|
|
1317
1489
|
function ResourceChip({ refVal, onOpen }) {
|
|
1318
1490
|
const icon = RESOURCE_ICON[refVal.kind] || "\u25C7";
|
|
1319
|
-
return /* @__PURE__ */
|
|
1491
|
+
return /* @__PURE__ */ jsxs9(
|
|
1320
1492
|
"button",
|
|
1321
1493
|
{
|
|
1322
1494
|
className: "shg-refchip shg-refchip-btn",
|
|
@@ -1326,54 +1498,54 @@ function ResourceChip({ refVal, onOpen }) {
|
|
|
1326
1498
|
onOpen && onOpen(refVal);
|
|
1327
1499
|
},
|
|
1328
1500
|
children: [
|
|
1329
|
-
/* @__PURE__ */
|
|
1330
|
-
/* @__PURE__ */
|
|
1501
|
+
/* @__PURE__ */ jsx10("span", { className: "shg-refchip-ic", children: icon }),
|
|
1502
|
+
/* @__PURE__ */ jsx10("span", { className: "shg-refchip-name", children: refVal.name || refVal.id || refVal.kind })
|
|
1331
1503
|
]
|
|
1332
1504
|
}
|
|
1333
1505
|
);
|
|
1334
1506
|
}
|
|
1335
1507
|
function StatusDot({ status }) {
|
|
1336
1508
|
if (!status || status === "empty") return null;
|
|
1337
|
-
return /* @__PURE__ */
|
|
1509
|
+
return /* @__PURE__ */ jsx10("span", { className: `shg-dot shg-dot-${status}`, title: status });
|
|
1338
1510
|
}
|
|
1339
1511
|
function CellValue({ cell, col, fetchBlobUrl, onOpenResource }) {
|
|
1340
1512
|
const v = cell?.value;
|
|
1341
|
-
if (v === void 0 || v === null || v === "") return /* @__PURE__ */
|
|
1513
|
+
if (v === void 0 || v === null || v === "") return /* @__PURE__ */ jsx10("span", { className: "shg-val-txt" });
|
|
1342
1514
|
if (v && typeof v === "object" && !Array.isArray(v) && v.kind) {
|
|
1343
|
-
if (v.kind === "image") return /* @__PURE__ */
|
|
1344
|
-
return /* @__PURE__ */
|
|
1515
|
+
if (v.kind === "image") return /* @__PURE__ */ jsx10(RefImage, { refVal: v, fetchBlobUrl });
|
|
1516
|
+
return /* @__PURE__ */ jsx10(ResourceChip, { refVal: v, onOpen: onOpenResource });
|
|
1345
1517
|
}
|
|
1346
1518
|
switch (col.type) {
|
|
1347
1519
|
case "select":
|
|
1348
|
-
return /* @__PURE__ */
|
|
1520
|
+
return /* @__PURE__ */ jsx10("span", { className: "shg-pill", style: { background: pillColor(String(v), col.options) }, children: String(v) });
|
|
1349
1521
|
case "tags": {
|
|
1350
1522
|
const tags = Array.isArray(v) ? v : String(v).split(",").map((s) => s.trim()).filter(Boolean);
|
|
1351
|
-
return /* @__PURE__ */
|
|
1523
|
+
return /* @__PURE__ */ jsx10("span", { className: "shg-pills", children: tags.map((t) => /* @__PURE__ */ jsx10("span", { className: "shg-pill", style: { background: pillColor(t, col.options) }, children: t }, t)) });
|
|
1352
1524
|
}
|
|
1353
1525
|
case "checkbox":
|
|
1354
|
-
return /* @__PURE__ */
|
|
1526
|
+
return /* @__PURE__ */ jsx10("span", { className: "shg-check" + (v ? " on" : ""), children: v ? "\u2713" : "" });
|
|
1355
1527
|
case "url": {
|
|
1356
1528
|
const href = /^https?:\/\//i.test(String(v)) ? String(v) : `https://${v}`;
|
|
1357
|
-
return /* @__PURE__ */
|
|
1529
|
+
return /* @__PURE__ */ jsx10("a", { className: "shg-link", href, target: "_blank", rel: "noreferrer", onClick: (e) => e.stopPropagation(), children: String(v) });
|
|
1358
1530
|
}
|
|
1359
1531
|
case "number":
|
|
1360
|
-
return /* @__PURE__ */
|
|
1532
|
+
return /* @__PURE__ */ jsx10("span", { className: "shg-val-txt shg-num", children: String(v) });
|
|
1361
1533
|
default:
|
|
1362
|
-
return /* @__PURE__ */
|
|
1534
|
+
return /* @__PURE__ */ jsx10("span", { className: "shg-val-txt", children: typeof v === "object" ? JSON.stringify(v) : String(v) });
|
|
1363
1535
|
}
|
|
1364
1536
|
}
|
|
1365
1537
|
function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false, fetchBlobUrl, onOpenResource, peerMarks, onActiveCell }) {
|
|
1366
1538
|
const columns = sheet?.columns || [];
|
|
1367
1539
|
const rows = sheet?.rows || [];
|
|
1368
1540
|
const cells = sheet?.cells || {};
|
|
1369
|
-
const [editing, setEditing] =
|
|
1370
|
-
const [draft, setDraft] =
|
|
1371
|
-
const [menuCol, setMenuCol] =
|
|
1372
|
-
const [sizeDraft, setSizeDraft] =
|
|
1373
|
-
const [dnd, setDnd] =
|
|
1374
|
-
const [dropAt, setDropAt] =
|
|
1375
|
-
const inputRef =
|
|
1376
|
-
const dragRef =
|
|
1541
|
+
const [editing, setEditing] = useState6(null);
|
|
1542
|
+
const [draft, setDraft] = useState6("");
|
|
1543
|
+
const [menuCol, setMenuCol] = useState6(null);
|
|
1544
|
+
const [sizeDraft, setSizeDraft] = useState6({});
|
|
1545
|
+
const [dnd, setDnd] = useState6(null);
|
|
1546
|
+
const [dropAt, setDropAt] = useState6(null);
|
|
1547
|
+
const inputRef = useRef5(null);
|
|
1548
|
+
const dragRef = useRef5(null);
|
|
1377
1549
|
const startResize = (e, kind, id, start) => {
|
|
1378
1550
|
if (readOnly) return;
|
|
1379
1551
|
e.preventDefault();
|
|
@@ -1468,7 +1640,7 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
|
|
|
1468
1640
|
const numW = Math.max(40, 24 + String(rows.length || 1).length * 9);
|
|
1469
1641
|
const numStyle = { width: numW, minWidth: numW, maxWidth: numW };
|
|
1470
1642
|
const rowHeight = (row) => sizeDraft.row && sizeDraft.row[row.id] || row.height || void 0;
|
|
1471
|
-
|
|
1643
|
+
useEffect5(() => {
|
|
1472
1644
|
if (editing && inputRef.current) inputRef.current.focus();
|
|
1473
1645
|
}, [editing]);
|
|
1474
1646
|
const mutate = (fn) => {
|
|
@@ -1535,7 +1707,7 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
|
|
|
1535
1707
|
if (col.type === "resource") {
|
|
1536
1708
|
const d = typeof draft === "object" && draft ? draft : { kind: "sheet" };
|
|
1537
1709
|
const set = (k, v) => setDraft({ ...d, [k]: v });
|
|
1538
|
-
return /* @__PURE__ */
|
|
1710
|
+
return /* @__PURE__ */ jsx10(
|
|
1539
1711
|
PopPortal,
|
|
1540
1712
|
{
|
|
1541
1713
|
anchor: editing.rect,
|
|
@@ -1543,17 +1715,17 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
|
|
|
1543
1715
|
estHeight: 230,
|
|
1544
1716
|
className: "shg-select-pop shg-ref-pop",
|
|
1545
1717
|
onClose: () => setEditing(null),
|
|
1546
|
-
children: /* @__PURE__ */
|
|
1547
|
-
/* @__PURE__ */
|
|
1548
|
-
/* @__PURE__ */
|
|
1549
|
-
/* @__PURE__ */
|
|
1550
|
-
/* @__PURE__ */
|
|
1551
|
-
/* @__PURE__ */
|
|
1552
|
-
/* @__PURE__ */
|
|
1718
|
+
children: /* @__PURE__ */ jsxs9("div", { onClick: (e) => e.stopPropagation(), children: [
|
|
1719
|
+
/* @__PURE__ */ jsx10("select", { className: "shg-menu-input", value: d.kind || "sheet", onChange: (e) => set("kind", e.target.value), children: RESOURCE_KINDS.map((k) => /* @__PURE__ */ jsx10("option", { value: k, children: k }, k)) }),
|
|
1720
|
+
/* @__PURE__ */ jsx10("input", { className: "shg-menu-input", placeholder: "Name", value: d.name || "", onChange: (e) => set("name", e.target.value) }),
|
|
1721
|
+
/* @__PURE__ */ jsx10("input", { className: "shg-menu-input", placeholder: "Resource id (e.g. sheet.\u2026)", value: d.id || "", onChange: (e) => set("id", e.target.value) }),
|
|
1722
|
+
/* @__PURE__ */ jsx10("input", { className: "shg-menu-input", placeholder: "or URL", value: d.url || "", onChange: (e) => set("url", e.target.value) }),
|
|
1723
|
+
/* @__PURE__ */ jsxs9("div", { className: "shg-menu-actions", children: [
|
|
1724
|
+
/* @__PURE__ */ jsx10("button", { className: "shg-pop-clear", onClick: () => {
|
|
1553
1725
|
setCell(editing.rowId, editing.colId, null);
|
|
1554
1726
|
setEditing(null);
|
|
1555
1727
|
}, children: "Clear" }),
|
|
1556
|
-
/* @__PURE__ */
|
|
1728
|
+
/* @__PURE__ */ jsx10("button", { className: "shg-menu-apply", onClick: () => {
|
|
1557
1729
|
setCell(editing.rowId, editing.colId, d);
|
|
1558
1730
|
setEditing(null);
|
|
1559
1731
|
}, children: "Set" })
|
|
@@ -1564,7 +1736,7 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
|
|
|
1564
1736
|
}
|
|
1565
1737
|
if (col.type === "select") {
|
|
1566
1738
|
const opts = normOptions(col.options);
|
|
1567
|
-
return /* @__PURE__ */
|
|
1739
|
+
return /* @__PURE__ */ jsxs9(
|
|
1568
1740
|
PopPortal,
|
|
1569
1741
|
{
|
|
1570
1742
|
anchor: editing.rect,
|
|
@@ -1573,8 +1745,8 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
|
|
|
1573
1745
|
className: "shg-select-pop",
|
|
1574
1746
|
onClose: () => setEditing(null),
|
|
1575
1747
|
children: [
|
|
1576
|
-
opts.length === 0 && /* @__PURE__ */
|
|
1577
|
-
opts.map((o) => /* @__PURE__ */
|
|
1748
|
+
opts.length === 0 && /* @__PURE__ */ jsx10("div", { className: "shg-pop-note", children: "No options yet \u2014 add them in the column menu." }),
|
|
1749
|
+
opts.map((o) => /* @__PURE__ */ jsx10(
|
|
1578
1750
|
"button",
|
|
1579
1751
|
{
|
|
1580
1752
|
className: "shg-pill shg-pill-btn",
|
|
@@ -1588,7 +1760,7 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
|
|
|
1588
1760
|
},
|
|
1589
1761
|
o.label
|
|
1590
1762
|
)),
|
|
1591
|
-
/* @__PURE__ */
|
|
1763
|
+
/* @__PURE__ */ jsx10(
|
|
1592
1764
|
"button",
|
|
1593
1765
|
{
|
|
1594
1766
|
className: "shg-pop-clear",
|
|
@@ -1605,7 +1777,7 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
|
|
|
1605
1777
|
);
|
|
1606
1778
|
}
|
|
1607
1779
|
const inputType = col.type === "date" ? "date" : col.type === "number" ? "number" : "text";
|
|
1608
|
-
return /* @__PURE__ */
|
|
1780
|
+
return /* @__PURE__ */ jsx10(
|
|
1609
1781
|
"input",
|
|
1610
1782
|
{
|
|
1611
1783
|
ref: inputRef,
|
|
@@ -1622,18 +1794,18 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
|
|
|
1622
1794
|
}
|
|
1623
1795
|
);
|
|
1624
1796
|
};
|
|
1625
|
-
return /* @__PURE__ */
|
|
1626
|
-
/* @__PURE__ */
|
|
1627
|
-
/* @__PURE__ */
|
|
1628
|
-
columns.map((col) => /* @__PURE__ */
|
|
1797
|
+
return /* @__PURE__ */ jsx10("div", { className: "shg", children: /* @__PURE__ */ jsx10("div", { className: "shg-scroll", children: /* @__PURE__ */ jsxs9("table", { className: "shg-table", children: [
|
|
1798
|
+
/* @__PURE__ */ jsx10("thead", { children: /* @__PURE__ */ jsxs9("tr", { children: [
|
|
1799
|
+
/* @__PURE__ */ jsx10("th", { className: "shg-corner", style: numStyle }),
|
|
1800
|
+
columns.map((col) => /* @__PURE__ */ jsxs9(
|
|
1629
1801
|
"th",
|
|
1630
1802
|
{
|
|
1631
1803
|
className: "shg-col" + (col.type === "compute" ? " shg-col-compute" : "") + dndClass("col", col.id),
|
|
1632
1804
|
style: colWidth(col) ? { width: colWidth(col), minWidth: colWidth(col), maxWidth: colWidth(col) } : void 0,
|
|
1633
1805
|
...dndProps("col", col.id),
|
|
1634
1806
|
children: [
|
|
1635
|
-
!readOnly && /* @__PURE__ */
|
|
1636
|
-
/* @__PURE__ */
|
|
1807
|
+
!readOnly && /* @__PURE__ */ jsx10("span", { className: "shg-resize-col", onMouseDown: (e) => startResize(e, "col", col.id, colWidth(col) || e.currentTarget.closest("th").offsetWidth) }),
|
|
1808
|
+
/* @__PURE__ */ jsx10("div", { className: "shg-col-h", children: /* @__PURE__ */ jsx10(
|
|
1637
1809
|
ColumnHeader,
|
|
1638
1810
|
{
|
|
1639
1811
|
col,
|
|
@@ -1656,10 +1828,10 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
|
|
|
1656
1828
|
},
|
|
1657
1829
|
col.id
|
|
1658
1830
|
)),
|
|
1659
|
-
!readOnly && /* @__PURE__ */
|
|
1831
|
+
!readOnly && /* @__PURE__ */ jsx10("th", { className: "shg-add-col", children: /* @__PURE__ */ jsx10("button", { className: "shg-add", onClick: addColumn, title: "Add column", children: "+" }) })
|
|
1660
1832
|
] }) }),
|
|
1661
|
-
/* @__PURE__ */
|
|
1662
|
-
rows.map((row, ri) => /* @__PURE__ */
|
|
1833
|
+
/* @__PURE__ */ jsxs9("tbody", { children: [
|
|
1834
|
+
rows.map((row, ri) => /* @__PURE__ */ jsxs9(
|
|
1663
1835
|
"tr",
|
|
1664
1836
|
{
|
|
1665
1837
|
style: {
|
|
@@ -1667,7 +1839,7 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
|
|
|
1667
1839
|
"--shg-clamp": Math.max(1, Math.floor(((rowHeight(row) || 34) - 10) / 18))
|
|
1668
1840
|
},
|
|
1669
1841
|
children: [
|
|
1670
|
-
/* @__PURE__ */
|
|
1842
|
+
/* @__PURE__ */ jsxs9(
|
|
1671
1843
|
"td",
|
|
1672
1844
|
{
|
|
1673
1845
|
className: "shg-rownum" + dndClass("row", row.id),
|
|
@@ -1675,9 +1847,9 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
|
|
|
1675
1847
|
title: "Drag to reorder",
|
|
1676
1848
|
...dndProps("row", row.id),
|
|
1677
1849
|
children: [
|
|
1678
|
-
/* @__PURE__ */
|
|
1679
|
-
!readOnly && /* @__PURE__ */
|
|
1680
|
-
!readOnly && /* @__PURE__ */
|
|
1850
|
+
/* @__PURE__ */ jsx10("span", { children: ri + 1 }),
|
|
1851
|
+
!readOnly && /* @__PURE__ */ jsx10("button", { className: "shg-rowdel", onClick: () => deleteRow(row.id), title: "Delete row", children: "\xD7" }),
|
|
1852
|
+
!readOnly && /* @__PURE__ */ jsx10("span", { className: "shg-resize-row", onMouseDown: (e) => startResize(e, "row", row.id, rowHeight(row) || e.currentTarget.closest("tr").offsetHeight) })
|
|
1681
1853
|
]
|
|
1682
1854
|
}
|
|
1683
1855
|
),
|
|
@@ -1685,7 +1857,7 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
|
|
|
1685
1857
|
const c = cells[cellKey(row.id, col.id)] || {};
|
|
1686
1858
|
const isEditing = editing && editing.rowId === row.id && editing.colId === col.id;
|
|
1687
1859
|
const peer = peerMarks && peerMarks[cellKey(row.id, col.id)];
|
|
1688
|
-
return /* @__PURE__ */
|
|
1860
|
+
return /* @__PURE__ */ jsxs9(
|
|
1689
1861
|
"td",
|
|
1690
1862
|
{
|
|
1691
1863
|
className: "shg-cell" + (col.type === "compute" ? " shg-cell-compute" : "") + (c.status && col.type === "compute" ? ` shg-cell-${c.status}` : "") + (peer ? " shg-cell-peer" : ""),
|
|
@@ -1695,16 +1867,16 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
|
|
|
1695
1867
|
},
|
|
1696
1868
|
title: c.error || "",
|
|
1697
1869
|
children: [
|
|
1698
|
-
peer && /* @__PURE__ */
|
|
1699
|
-
isEditing ? renderEditor(col) : /* @__PURE__ */
|
|
1870
|
+
peer && /* @__PURE__ */ jsx10("span", { className: "shg-peer-flag", style: { background: peer.color }, children: peer.name }),
|
|
1871
|
+
isEditing ? renderEditor(col) : /* @__PURE__ */ jsxs9(
|
|
1700
1872
|
"div",
|
|
1701
1873
|
{
|
|
1702
1874
|
className: "shg-val",
|
|
1703
1875
|
style: { maxWidth: colWidth(col) ? colWidth(col) - 20 : 400 },
|
|
1704
1876
|
children: [
|
|
1705
|
-
col.type === "compute" && /* @__PURE__ */
|
|
1706
|
-
/* @__PURE__ */
|
|
1707
|
-
col.type === "compute" && !readOnly && onRunCell && /* @__PURE__ */
|
|
1877
|
+
col.type === "compute" && /* @__PURE__ */ jsx10(StatusDot, { status: c.status }),
|
|
1878
|
+
/* @__PURE__ */ jsx10(CellValue, { cell: c, col, fetchBlobUrl, onOpenResource }),
|
|
1879
|
+
col.type === "compute" && !readOnly && onRunCell && /* @__PURE__ */ jsx10(
|
|
1708
1880
|
"button",
|
|
1709
1881
|
{
|
|
1710
1882
|
className: "shg-runcell",
|
|
@@ -1724,25 +1896,25 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
|
|
|
1724
1896
|
col.id
|
|
1725
1897
|
);
|
|
1726
1898
|
}),
|
|
1727
|
-
!readOnly && /* @__PURE__ */
|
|
1899
|
+
!readOnly && /* @__PURE__ */ jsx10("td", { className: "shg-pad" })
|
|
1728
1900
|
]
|
|
1729
1901
|
},
|
|
1730
1902
|
row.id
|
|
1731
1903
|
)),
|
|
1732
|
-
!readOnly && /* @__PURE__ */
|
|
1733
|
-
/* @__PURE__ */
|
|
1734
|
-
/* @__PURE__ */
|
|
1904
|
+
!readOnly && /* @__PURE__ */ jsxs9("tr", { className: "shg-ghost-row", onClick: addRow, children: [
|
|
1905
|
+
/* @__PURE__ */ jsx10("td", { className: "shg-rownum shg-ghost-num", style: numStyle, children: "+" }),
|
|
1906
|
+
/* @__PURE__ */ jsx10("td", { className: "shg-ghost-cell", colSpan: columns.length + 1, children: "New row" })
|
|
1735
1907
|
] })
|
|
1736
1908
|
] })
|
|
1737
1909
|
] }) }) });
|
|
1738
1910
|
}
|
|
1739
1911
|
function ColumnHeader({ col, columns, readOnly, menuOpen, menuAnchor, onMenu, onCloseMenu, onRename, onConfigure, onDelete, onRun }) {
|
|
1740
|
-
const [editing, setEditing] =
|
|
1741
|
-
const [name, setName] =
|
|
1742
|
-
|
|
1743
|
-
return /* @__PURE__ */
|
|
1744
|
-
/* @__PURE__ */
|
|
1745
|
-
editing && !readOnly ? /* @__PURE__ */
|
|
1912
|
+
const [editing, setEditing] = useState6(false);
|
|
1913
|
+
const [name, setName] = useState6(col.name);
|
|
1914
|
+
useEffect5(() => setName(col.name), [col.name]);
|
|
1915
|
+
return /* @__PURE__ */ jsxs9("div", { className: "shg-colhdr", children: [
|
|
1916
|
+
/* @__PURE__ */ jsxs9("div", { className: "shg-colhdr-main", children: [
|
|
1917
|
+
editing && !readOnly ? /* @__PURE__ */ jsx10(
|
|
1746
1918
|
"input",
|
|
1747
1919
|
{
|
|
1748
1920
|
className: "shg-colname-input",
|
|
@@ -1757,17 +1929,17 @@ function ColumnHeader({ col, columns, readOnly, menuOpen, menuAnchor, onMenu, on
|
|
|
1757
1929
|
if (e.key === "Enter") e.target.blur();
|
|
1758
1930
|
}
|
|
1759
1931
|
}
|
|
1760
|
-
) : /* @__PURE__ */
|
|
1761
|
-
/* @__PURE__ */
|
|
1932
|
+
) : /* @__PURE__ */ jsx10("span", { className: "shg-colname", onDoubleClick: () => !readOnly && setEditing(true), title: col.name, children: col.name }),
|
|
1933
|
+
/* @__PURE__ */ jsxs9("span", { className: "shg-coltype" + (col.type === "compute" ? " compute" : ""), children: [
|
|
1762
1934
|
TYPE_LABEL[col.type] || col.type,
|
|
1763
1935
|
col.type === "compute" && col.compute?.kind ? ` \xB7 ${col.compute.kind}` : ""
|
|
1764
1936
|
] })
|
|
1765
1937
|
] }),
|
|
1766
|
-
!readOnly && /* @__PURE__ */
|
|
1767
|
-
onRun && /* @__PURE__ */
|
|
1768
|
-
/* @__PURE__ */
|
|
1938
|
+
!readOnly && /* @__PURE__ */ jsxs9("div", { className: "shg-colhdr-tools", children: [
|
|
1939
|
+
onRun && /* @__PURE__ */ jsx10("button", { className: "shg-colrun", onClick: onRun, title: "Run this column", children: "\u25B6 Run" }),
|
|
1940
|
+
/* @__PURE__ */ jsx10("button", { className: "shg-colmenu-btn", onClick: (e) => onMenu(e), title: "Column settings", children: "\u22EF" })
|
|
1769
1941
|
] }),
|
|
1770
|
-
menuOpen && !readOnly && /* @__PURE__ */
|
|
1942
|
+
menuOpen && !readOnly && /* @__PURE__ */ jsx10(
|
|
1771
1943
|
ColumnMenu,
|
|
1772
1944
|
{
|
|
1773
1945
|
col,
|
|
@@ -1784,19 +1956,19 @@ function ColumnHeader({ col, columns, readOnly, menuOpen, menuAnchor, onMenu, on
|
|
|
1784
1956
|
] });
|
|
1785
1957
|
}
|
|
1786
1958
|
function ColumnMenu({ col, columns, anchor, onApply, onDelete, onClose }) {
|
|
1787
|
-
const [type, setType] =
|
|
1788
|
-
const [optText, setOptText] =
|
|
1959
|
+
const [type, setType] = useState6(col.type || "text");
|
|
1960
|
+
const [optText, setOptText] = useState6(
|
|
1789
1961
|
normOptions(col.options).map((o) => o.label).join("\n")
|
|
1790
1962
|
);
|
|
1791
1963
|
const comp = col.compute || {};
|
|
1792
|
-
const [kind, setKind] =
|
|
1793
|
-
const [prompt, setPrompt] =
|
|
1794
|
-
const [harnessId, setHarnessId] =
|
|
1795
|
-
const [wfSlug, setWfSlug] =
|
|
1796
|
-
const [outKey, setOutKey] =
|
|
1797
|
-
const [deps, setDeps] =
|
|
1798
|
-
const ref =
|
|
1799
|
-
|
|
1964
|
+
const [kind, setKind] = useState6(comp.kind || "prompt");
|
|
1965
|
+
const [prompt, setPrompt] = useState6(comp.prompt || "");
|
|
1966
|
+
const [harnessId, setHarnessId] = useState6(comp.harness_id || "");
|
|
1967
|
+
const [wfSlug, setWfSlug] = useState6(comp.workflow_slug || "");
|
|
1968
|
+
const [outKey, setOutKey] = useState6(comp.output_key || "");
|
|
1969
|
+
const [deps, setDeps] = useState6(new Set(comp.deps || []));
|
|
1970
|
+
const ref = useRef5(null);
|
|
1971
|
+
useEffect5(() => {
|
|
1800
1972
|
const onDown = (e) => {
|
|
1801
1973
|
if (ref.current && !ref.current.contains(e.target)) onClose();
|
|
1802
1974
|
};
|
|
@@ -1830,17 +2002,17 @@ function ColumnMenu({ col, columns, anchor, onApply, onDelete, onClose }) {
|
|
|
1830
2002
|
}
|
|
1831
2003
|
onApply(patch);
|
|
1832
2004
|
};
|
|
1833
|
-
return /* @__PURE__ */
|
|
1834
|
-
/* @__PURE__ */
|
|
2005
|
+
return /* @__PURE__ */ jsx10(PopPortal, { anchor, width: 250, estHeight: 340, className: "shg-menu", onClose, children: /* @__PURE__ */ jsxs9("div", { ref, onClick: (e) => e.stopPropagation(), children: [
|
|
2006
|
+
/* @__PURE__ */ jsxs9("label", { className: "shg-menu-lbl", children: [
|
|
1835
2007
|
"Type",
|
|
1836
|
-
/* @__PURE__ */
|
|
1837
|
-
MANUAL_TYPES.map((t) => /* @__PURE__ */
|
|
1838
|
-
/* @__PURE__ */
|
|
2008
|
+
/* @__PURE__ */ jsxs9("select", { className: "shg-menu-input", value: type, onChange: (e) => setType(e.target.value), children: [
|
|
2009
|
+
MANUAL_TYPES.map((t) => /* @__PURE__ */ jsx10("option", { value: t, children: TYPE_LABEL[t] }, t)),
|
|
2010
|
+
/* @__PURE__ */ jsx10("option", { value: "compute", children: "Computed" })
|
|
1839
2011
|
] })
|
|
1840
2012
|
] }),
|
|
1841
|
-
(type === "select" || type === "tags") && /* @__PURE__ */
|
|
2013
|
+
(type === "select" || type === "tags") && /* @__PURE__ */ jsxs9("label", { className: "shg-menu-lbl", children: [
|
|
1842
2014
|
"Options (one per line)",
|
|
1843
|
-
/* @__PURE__ */
|
|
2015
|
+
/* @__PURE__ */ jsx10(
|
|
1844
2016
|
"textarea",
|
|
1845
2017
|
{
|
|
1846
2018
|
className: "shg-menu-input",
|
|
@@ -1851,15 +2023,15 @@ function ColumnMenu({ col, columns, anchor, onApply, onDelete, onClose }) {
|
|
|
1851
2023
|
}
|
|
1852
2024
|
)
|
|
1853
2025
|
] }),
|
|
1854
|
-
type === "compute" && /* @__PURE__ */
|
|
1855
|
-
/* @__PURE__ */
|
|
2026
|
+
type === "compute" && /* @__PURE__ */ jsxs9(Fragment5, { children: [
|
|
2027
|
+
/* @__PURE__ */ jsxs9("label", { className: "shg-menu-lbl", children: [
|
|
1856
2028
|
"Runs",
|
|
1857
|
-
/* @__PURE__ */
|
|
2029
|
+
/* @__PURE__ */ jsx10("select", { className: "shg-menu-input", value: kind, onChange: (e) => setKind(e.target.value), children: COMPUTE_KINDS.map((k) => /* @__PURE__ */ jsx10("option", { value: k.kind, children: k.label }, k.kind)) })
|
|
1858
2030
|
] }),
|
|
1859
|
-
(kind === "prompt" || kind === "harness") && /* @__PURE__ */
|
|
2031
|
+
(kind === "prompt" || kind === "harness") && /* @__PURE__ */ jsxs9("label", { className: "shg-menu-lbl", children: [
|
|
1860
2032
|
"Prompt \u2014 reference columns as ",
|
|
1861
2033
|
"{{Name}}",
|
|
1862
|
-
/* @__PURE__ */
|
|
2034
|
+
/* @__PURE__ */ jsx10(
|
|
1863
2035
|
"textarea",
|
|
1864
2036
|
{
|
|
1865
2037
|
className: "shg-menu-input",
|
|
@@ -1870,32 +2042,32 @@ function ColumnMenu({ col, columns, anchor, onApply, onDelete, onClose }) {
|
|
|
1870
2042
|
}
|
|
1871
2043
|
)
|
|
1872
2044
|
] }),
|
|
1873
|
-
kind === "harness" && /* @__PURE__ */
|
|
2045
|
+
kind === "harness" && /* @__PURE__ */ jsxs9("label", { className: "shg-menu-lbl", children: [
|
|
1874
2046
|
"Agent id",
|
|
1875
|
-
/* @__PURE__ */
|
|
2047
|
+
/* @__PURE__ */ jsx10("input", { className: "shg-menu-input", value: harnessId, onChange: (e) => setHarnessId(e.target.value), placeholder: "chrn_\u2026" })
|
|
1876
2048
|
] }),
|
|
1877
|
-
kind === "workflow" && /* @__PURE__ */
|
|
1878
|
-
/* @__PURE__ */
|
|
2049
|
+
kind === "workflow" && /* @__PURE__ */ jsxs9(Fragment5, { children: [
|
|
2050
|
+
/* @__PURE__ */ jsxs9("label", { className: "shg-menu-lbl", children: [
|
|
1879
2051
|
"Workflow id",
|
|
1880
|
-
/* @__PURE__ */
|
|
2052
|
+
/* @__PURE__ */ jsx10("input", { className: "shg-menu-input", value: wfSlug, onChange: (e) => setWfSlug(e.target.value), placeholder: "my-workflow" })
|
|
1881
2053
|
] }),
|
|
1882
|
-
/* @__PURE__ */
|
|
2054
|
+
/* @__PURE__ */ jsxs9("label", { className: "shg-menu-lbl", children: [
|
|
1883
2055
|
"Output key (optional)",
|
|
1884
|
-
/* @__PURE__ */
|
|
2056
|
+
/* @__PURE__ */ jsx10("input", { className: "shg-menu-input", value: outKey, onChange: (e) => setOutKey(e.target.value), placeholder: "summary" })
|
|
1885
2057
|
] })
|
|
1886
2058
|
] }),
|
|
1887
|
-
others.length > 0 && /* @__PURE__ */
|
|
2059
|
+
others.length > 0 && /* @__PURE__ */ jsxs9("div", { className: "shg-menu-lbl", children: [
|
|
1888
2060
|
"Reads columns",
|
|
1889
|
-
/* @__PURE__ */
|
|
1890
|
-
/* @__PURE__ */
|
|
2061
|
+
/* @__PURE__ */ jsx10("div", { className: "shg-menu-deps", children: others.map((c) => /* @__PURE__ */ jsxs9("label", { className: "shg-menu-dep", children: [
|
|
2062
|
+
/* @__PURE__ */ jsx10("input", { type: "checkbox", checked: deps.has(c.id), onChange: () => toggleDep(c.id) }),
|
|
1891
2063
|
" ",
|
|
1892
2064
|
c.name
|
|
1893
2065
|
] }, c.id)) })
|
|
1894
2066
|
] })
|
|
1895
2067
|
] }),
|
|
1896
|
-
/* @__PURE__ */
|
|
1897
|
-
/* @__PURE__ */
|
|
1898
|
-
/* @__PURE__ */
|
|
2068
|
+
/* @__PURE__ */ jsxs9("div", { className: "shg-menu-actions", children: [
|
|
2069
|
+
/* @__PURE__ */ jsx10("button", { className: "shg-menu-del", onClick: onDelete, children: "Delete column" }),
|
|
2070
|
+
/* @__PURE__ */ jsx10("button", { className: "shg-menu-apply", onClick: apply, children: "Apply" })
|
|
1899
2071
|
] })
|
|
1900
2072
|
] }) });
|
|
1901
2073
|
}
|
|
@@ -1953,6 +2125,7 @@ export {
|
|
|
1953
2125
|
SESSION_EVENT,
|
|
1954
2126
|
SheetGrid,
|
|
1955
2127
|
Svg,
|
|
2128
|
+
TaskList,
|
|
1956
2129
|
ToolGroup,
|
|
1957
2130
|
ToolRow,
|
|
1958
2131
|
UserTurn,
|
|
@@ -1984,6 +2157,7 @@ export {
|
|
|
1984
2157
|
sheetToDelimited,
|
|
1985
2158
|
summarizeSteps,
|
|
1986
2159
|
switchOrg,
|
|
2160
|
+
taskStatusGroup,
|
|
1987
2161
|
toolMeta,
|
|
1988
2162
|
useResizablePane,
|
|
1989
2163
|
withReasoning,
|