@flytedan/flytebot-design-system 0.71.7 → 0.73.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/dist/index.cjs +214 -147
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +64 -15
- package/dist/index.d.ts +64 -15
- package/dist/index.js +212 -147
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/styles/components.css +10 -5
package/dist/index.js
CHANGED
|
@@ -940,7 +940,7 @@ function Collapsible({
|
|
|
940
940
|
import * as React6 from "react";
|
|
941
941
|
import { createPortal as createPortal2 } from "react-dom";
|
|
942
942
|
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
943
|
-
function Drawer({ open: open2 = true, title, onClose, footer, children, className = "", ...rest }) {
|
|
943
|
+
function Drawer({ open: open2 = true, title, label, onClose, footer, bare = false, children, className = "", ...rest }) {
|
|
944
944
|
const asideRef = React6.useRef(null);
|
|
945
945
|
const [closing, setClosing] = React6.useState(false);
|
|
946
946
|
const close2 = React6.useCallback(() => {
|
|
@@ -950,16 +950,22 @@ function Drawer({ open: open2 = true, title, onClose, footer, children, classNam
|
|
|
950
950
|
}, [onClose]);
|
|
951
951
|
const layer = useStackedLayer({ active: !!open2, containerRef: asideRef, trap: true, onEscape: onClose ? close2 : void 0 });
|
|
952
952
|
const zIndex = useLayerZIndex(layer);
|
|
953
|
+
const titleId = React6.useId();
|
|
954
|
+
const accessibleName = bare ? label ?? (typeof title === "string" ? title : void 0) : label;
|
|
955
|
+
const unnamed = !!open2 && bare && !accessibleName;
|
|
956
|
+
React6.useEffect(() => {
|
|
957
|
+
if (process.env.NODE_ENV !== "production" && unnamed) console.warn("Drawer: a bare Drawer has no header to name it. Pass `label`, or a string `title`, so the dialog has an accessible name.");
|
|
958
|
+
}, [unnamed]);
|
|
953
959
|
if (!open2) return null;
|
|
954
960
|
return createPortal2(
|
|
955
961
|
/* @__PURE__ */ jsxs6(StackedLayerProvider, { layer, children: [
|
|
956
962
|
/* @__PURE__ */ jsx9("div", { className: "fd-scrim" + (closing ? " is-closing" : ""), style: { display: "block", zIndex: zIndex - LAYER_STEP }, onClick: close2 }),
|
|
957
|
-
/* @__PURE__ */ jsxs6("aside", { ref: asideRef, className: ["fd-drawer", closing ? "is-closing" : "", className].filter(Boolean).join(" "), role: "dialog", "aria-modal": "true", ...rest, style: { zIndex }, children: [
|
|
958
|
-
/* @__PURE__ */ jsxs6("div", { className: "fd-card-head", style: { flex: "none" }, children: [
|
|
959
|
-
/* @__PURE__ */ jsx9("span", { className: "fd-card-head-title", title: truncationTitle(title), children: title }),
|
|
963
|
+
/* @__PURE__ */ jsxs6("aside", { ref: asideRef, className: ["fd-drawer", bare ? "is-bare" : "", closing ? "is-closing" : "", className].filter(Boolean).join(" "), role: "dialog", "aria-modal": "true", "aria-label": accessibleName, "aria-labelledby": bare || label ? void 0 : titleId, ...rest, style: { zIndex }, children: [
|
|
964
|
+
bare ? null : /* @__PURE__ */ jsxs6("div", { className: "fd-card-head", style: { flex: "none" }, children: [
|
|
965
|
+
/* @__PURE__ */ jsx9("span", { id: titleId, className: "fd-card-head-title", title: truncationTitle(title), children: title }),
|
|
960
966
|
onClose ? /* @__PURE__ */ jsx9("button", { type: "button", className: "fd-btn-icon", "aria-label": "Close", onClick: close2, children: /* @__PURE__ */ jsx9("i", { className: "ph ph-x" }) }) : null
|
|
961
967
|
] }),
|
|
962
|
-
/* @__PURE__ */ jsx9("div", { style: { flex: "1 1 auto", minHeight: 0, overflow: "auto", padding: 20 }, children }),
|
|
968
|
+
/* @__PURE__ */ jsx9("div", { style: bare ? { flex: "1 1 auto", minHeight: 0, display: "flex", flexDirection: "column" } : { flex: "1 1 auto", minHeight: 0, overflow: "auto", padding: 20 }, children: typeof children === "function" ? children(close2) : children }),
|
|
963
969
|
footer ? /* @__PURE__ */ jsx9("div", { className: "fd-card-foot", style: { flex: "none" }, children: typeof footer === "function" ? footer(close2) : footer }) : null
|
|
964
970
|
] })
|
|
965
971
|
] }),
|
|
@@ -1529,8 +1535,16 @@ function Topbar({
|
|
|
1529
1535
|
|
|
1530
1536
|
// src/kits/useResponsiveRail.ts
|
|
1531
1537
|
import * as React15 from "react";
|
|
1538
|
+
|
|
1539
|
+
// src/kits/overlayLayout.ts
|
|
1540
|
+
var OVERLAY_BREAKPOINT = 1024;
|
|
1541
|
+
function useOverlayLayout() {
|
|
1542
|
+
return useIsNarrow(OVERLAY_BREAKPOINT);
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
// src/kits/useResponsiveRail.ts
|
|
1532
1546
|
function useResponsiveRail(options = {}) {
|
|
1533
|
-
const { breakpoint =
|
|
1547
|
+
const { breakpoint = OVERLAY_BREAKPOINT, initialOpen = true, onPersist } = options;
|
|
1534
1548
|
const navRef = React15.useRef(null);
|
|
1535
1549
|
const overlay = useIsNarrow(breakpoint);
|
|
1536
1550
|
const [open2, setOpenRaw] = React15.useState(() => overlay ? false : initialOpen);
|
|
@@ -1571,7 +1585,7 @@ function AppShell({
|
|
|
1571
1585
|
navFooter,
|
|
1572
1586
|
initialNavOpen = true,
|
|
1573
1587
|
onNavOpenChange,
|
|
1574
|
-
railBreakpoint =
|
|
1588
|
+
railBreakpoint = OVERLAY_BREAKPOINT,
|
|
1575
1589
|
crumbs,
|
|
1576
1590
|
loading,
|
|
1577
1591
|
actions,
|
|
@@ -3891,7 +3905,7 @@ import { jsx as jsx50, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
|
3891
3905
|
var TAIL_CHARS = 12;
|
|
3892
3906
|
var graphemes = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
3893
3907
|
function splitForMiddleEllipsis(text) {
|
|
3894
|
-
const chars = Array.from(graphemes.segment(text), (
|
|
3908
|
+
const chars = Array.from(graphemes.segment(text), (part2) => part2.segment);
|
|
3895
3909
|
if (chars.length <= TAIL_CHARS) return { head: text, tail: "" };
|
|
3896
3910
|
return { head: chars.slice(0, -TAIL_CHARS).join(""), tail: chars.slice(-TAIL_CHARS).join("") };
|
|
3897
3911
|
}
|
|
@@ -5897,7 +5911,8 @@ function StepList({
|
|
|
5897
5911
|
onToggle,
|
|
5898
5912
|
showDurations = true,
|
|
5899
5913
|
dense = false,
|
|
5900
|
-
className = ""
|
|
5914
|
+
className = "",
|
|
5915
|
+
active = false
|
|
5901
5916
|
}) {
|
|
5902
5917
|
const [openState, setOpenState] = React39.useState(defaultOpen);
|
|
5903
5918
|
const open2 = openProp == null ? openState : openProp;
|
|
@@ -5907,15 +5922,15 @@ function StepList({
|
|
|
5907
5922
|
const failed = steps.filter((s) => s.status === "error").length;
|
|
5908
5923
|
const total = steps.reduce((n, s) => n + (s.durationMs || 0), 0);
|
|
5909
5924
|
const current2 = steps.filter((s) => s.status === "running").slice(-1)[0];
|
|
5910
|
-
const summary = label || (running ? current2 ? current2.label : "Working" : total ? "Worked for " + formatDuration(total) : "Steps");
|
|
5925
|
+
const summary = label || (running ? current2 ? current2.label : "Working" : active ? "Steps so far" : total ? "Worked for " + formatDuration(total) : "Steps");
|
|
5911
5926
|
const toggle = () => {
|
|
5912
5927
|
const next = !open2;
|
|
5913
5928
|
if (openProp == null) setOpenState(next);
|
|
5914
5929
|
onToggle && onToggle(next);
|
|
5915
5930
|
};
|
|
5916
|
-
return /* @__PURE__ */ jsxs51("div", { className: ["fd-steps", dense ? "is-dense" : "", open2 ? "is-open" : "", className].filter(Boolean).join(" "), children: [
|
|
5931
|
+
return /* @__PURE__ */ jsxs51("div", { className: ["fd-steps", dense ? "is-dense" : "", active ? "is-active" : "", open2 ? "is-open" : "", className].filter(Boolean).join(" "), children: [
|
|
5917
5932
|
/* @__PURE__ */ jsxs51("button", { type: "button", className: "fd-steps-head", onClick: toggle, "aria-expanded": open2, children: [
|
|
5918
|
-
running ? /* @__PURE__ */ jsx61("span", { className: "fd-steps-spin", "aria-hidden": "true" }) : /* @__PURE__ */ jsx61("i", { className: "ph ph-" + (failed ? "warning-circle" : "check-circle"), "aria-hidden": "true" }),
|
|
5933
|
+
running ? /* @__PURE__ */ jsx61("span", { className: "fd-steps-spin", "aria-hidden": "true" }) : /* @__PURE__ */ jsx61("i", { className: "ph ph-" + (failed ? "warning-circle" : active ? "list-checks" : "check-circle"), "aria-hidden": "true" }),
|
|
5919
5934
|
/* @__PURE__ */ jsx61("span", { className: "fd-steps-title", title: truncationTitle(summary), children: summary }),
|
|
5920
5935
|
/* @__PURE__ */ jsxs51("span", { className: "fd-steps-count fd-tabular", children: [
|
|
5921
5936
|
steps.length,
|
|
@@ -12387,17 +12402,13 @@ function PreferenceMeter({
|
|
|
12387
12402
|
}
|
|
12388
12403
|
|
|
12389
12404
|
// src/components/chat/AgentChatPanel.tsx
|
|
12390
|
-
import * as
|
|
12405
|
+
import * as React76 from "react";
|
|
12391
12406
|
|
|
12392
12407
|
// src/components/chat/chatEngine.ts
|
|
12408
|
+
import * as React71 from "react";
|
|
12409
|
+
|
|
12410
|
+
// src/components/chat/chatStore.ts
|
|
12393
12411
|
import * as React70 from "react";
|
|
12394
|
-
var CHAT_UNAVAILABLE = "chat_unavailable";
|
|
12395
|
-
var JOB_PENDING = ["queued", "running"];
|
|
12396
|
-
var JOB_SUCCESS = ["completed", "recovered"];
|
|
12397
|
-
var STORAGE_PREFIX = "fdchat:job:";
|
|
12398
|
-
var seq = 0;
|
|
12399
|
-
var uid = (p) => p + "_" + ++seq + "_" + Date.now().toString(36);
|
|
12400
|
-
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
12401
12412
|
var safeStore = {
|
|
12402
12413
|
get(k) {
|
|
12403
12414
|
try {
|
|
@@ -12419,6 +12430,38 @@ var safeStore = {
|
|
|
12419
12430
|
}
|
|
12420
12431
|
}
|
|
12421
12432
|
};
|
|
12433
|
+
var part = (v) => encodeURIComponent(v);
|
|
12434
|
+
var jobKey = (threadId) => "fdchat:job:" + part(threadId);
|
|
12435
|
+
var draftKey = (owner, contextType, contextId) => "fdchat:draft:" + [owner, contextType, contextId].map(part).join(":");
|
|
12436
|
+
function useChatDraft(owner, contextType, contextId, store = safeStore) {
|
|
12437
|
+
if (owner === "") throw new Error("useChatDraft: draftOwner is an empty string; pass the signed-in user's id, or null for no owner.");
|
|
12438
|
+
const key = owner === null ? null : draftKey(owner, contextType, contextId);
|
|
12439
|
+
const read2 = (k) => k ? store.get(k) || "" : "";
|
|
12440
|
+
const [state, setState] = React70.useState(() => ({ key, text: read2(key) }));
|
|
12441
|
+
let current2 = state;
|
|
12442
|
+
if (state.key !== key) {
|
|
12443
|
+
current2 = { key, text: read2(key) };
|
|
12444
|
+
setState(current2);
|
|
12445
|
+
}
|
|
12446
|
+
const setText = React70.useCallback((text) => {
|
|
12447
|
+
if (key) {
|
|
12448
|
+
if (text) {
|
|
12449
|
+
store.set(key, text);
|
|
12450
|
+
if (store.get(key) !== text) store.del(key);
|
|
12451
|
+
} else store.del(key);
|
|
12452
|
+
}
|
|
12453
|
+
setState({ key, text });
|
|
12454
|
+
}, [key, store]);
|
|
12455
|
+
return [current2.text, setText];
|
|
12456
|
+
}
|
|
12457
|
+
|
|
12458
|
+
// src/components/chat/chatEngine.ts
|
|
12459
|
+
var CHAT_UNAVAILABLE = "chat_unavailable";
|
|
12460
|
+
var JOB_PENDING = ["queued", "running"];
|
|
12461
|
+
var JOB_SUCCESS = ["completed", "recovered"];
|
|
12462
|
+
var seq = 0;
|
|
12463
|
+
var uid = (p) => p + "_" + ++seq + "_" + Date.now().toString(36);
|
|
12464
|
+
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
12422
12465
|
var isSystemMessage = (m) => !!m && (m.role === "system" || m.metadata != null && m.metadata.type === "system");
|
|
12423
12466
|
var visibleMessages = (list) => (list || []).filter((m) => !isSystemMessage(m));
|
|
12424
12467
|
function jobBucket(status) {
|
|
@@ -12427,6 +12470,20 @@ function jobBucket(status) {
|
|
|
12427
12470
|
if (JOB_SUCCESS.indexOf(s) !== -1) return "success";
|
|
12428
12471
|
return "failure";
|
|
12429
12472
|
}
|
|
12473
|
+
function defaultDescribeWaiting(pending) {
|
|
12474
|
+
return "Waiting on " + pending.length + " background " + (pending.length === 1 ? "task" : "tasks");
|
|
12475
|
+
}
|
|
12476
|
+
function withWaiting(list, describe) {
|
|
12477
|
+
const pending = list.filter((m) => m.taskPending);
|
|
12478
|
+
let turn = -1;
|
|
12479
|
+
list.forEach((m, i) => {
|
|
12480
|
+
if (m.working) turn = i;
|
|
12481
|
+
});
|
|
12482
|
+
return list.map((m, i) => {
|
|
12483
|
+
const want = i === turn && pending.length ? describe(pending) : void 0;
|
|
12484
|
+
return m.waitingFor === want ? m : Object.assign({}, m, { waitingFor: want });
|
|
12485
|
+
});
|
|
12486
|
+
}
|
|
12430
12487
|
function useChatEngine(opts) {
|
|
12431
12488
|
const {
|
|
12432
12489
|
contextType,
|
|
@@ -12436,6 +12493,7 @@ function useChatEngine(opts) {
|
|
|
12436
12493
|
threadId: threadIdProp,
|
|
12437
12494
|
pollIntervalMs = 1500,
|
|
12438
12495
|
pendingTimeoutMs = 18e4,
|
|
12496
|
+
describeWaiting = defaultDescribeWaiting,
|
|
12439
12497
|
store = safeStore,
|
|
12440
12498
|
onPacket,
|
|
12441
12499
|
onThreadReady,
|
|
@@ -12444,35 +12502,38 @@ function useChatEngine(opts) {
|
|
|
12444
12502
|
onClear,
|
|
12445
12503
|
onFeedback
|
|
12446
12504
|
} = opts || {};
|
|
12447
|
-
const [status, setStatus] =
|
|
12448
|
-
const [threadId, setThreadId] =
|
|
12449
|
-
const [messages, setMessages] =
|
|
12450
|
-
const [queue, setQueue] =
|
|
12451
|
-
const [fatal, setFatal] =
|
|
12452
|
-
const [busy, setBusy] =
|
|
12453
|
-
const [turnStartedAt, setTurnStartedAt] =
|
|
12454
|
-
const listRef =
|
|
12455
|
-
const queueRef =
|
|
12456
|
-
const busyRef =
|
|
12457
|
-
const loadedRef =
|
|
12458
|
-
const stoppedRef =
|
|
12459
|
-
const abortRef =
|
|
12460
|
-
const serverCount =
|
|
12461
|
-
const serverIds =
|
|
12462
|
-
const liveTurn =
|
|
12463
|
-
const lastTurnOwn =
|
|
12464
|
-
const retired =
|
|
12465
|
-
const threadRef =
|
|
12466
|
-
const mounted =
|
|
12467
|
-
|
|
12505
|
+
const [status, setStatus] = React71.useState("idle");
|
|
12506
|
+
const [threadId, setThreadId] = React71.useState(null);
|
|
12507
|
+
const [messages, setMessages] = React71.useState([]);
|
|
12508
|
+
const [queue, setQueue] = React71.useState([]);
|
|
12509
|
+
const [fatal, setFatal] = React71.useState(null);
|
|
12510
|
+
const [busy, setBusy] = React71.useState(false);
|
|
12511
|
+
const [turnStartedAt, setTurnStartedAt] = React71.useState(null);
|
|
12512
|
+
const listRef = React71.useRef([]);
|
|
12513
|
+
const queueRef = React71.useRef([]);
|
|
12514
|
+
const busyRef = React71.useRef(false);
|
|
12515
|
+
const loadedRef = React71.useRef(false);
|
|
12516
|
+
const stoppedRef = React71.useRef(false);
|
|
12517
|
+
const abortRef = React71.useRef(null);
|
|
12518
|
+
const serverCount = React71.useRef(0);
|
|
12519
|
+
const serverIds = React71.useRef(/* @__PURE__ */ new Set());
|
|
12520
|
+
const liveTurn = React71.useRef(null);
|
|
12521
|
+
const lastTurnOwn = React71.useRef(/* @__PURE__ */ new Set());
|
|
12522
|
+
const retired = React71.useRef(/* @__PURE__ */ new Set());
|
|
12523
|
+
const threadRef = React71.useRef(null);
|
|
12524
|
+
const mounted = React71.useRef(true);
|
|
12525
|
+
React71.useEffect(() => {
|
|
12468
12526
|
mounted.current = true;
|
|
12469
12527
|
return () => {
|
|
12470
12528
|
mounted.current = false;
|
|
12471
12529
|
};
|
|
12472
12530
|
}, []);
|
|
12531
|
+
const describeWaitingRef = React71.useRef(describeWaiting);
|
|
12532
|
+
describeWaitingRef.current = describeWaiting;
|
|
12473
12533
|
const commit = (next) => {
|
|
12474
|
-
|
|
12475
|
-
|
|
12534
|
+
const derived = withWaiting(next, (pending) => describeWaitingRef.current(pending));
|
|
12535
|
+
listRef.current = derived;
|
|
12536
|
+
if (mounted.current) setMessages(derived);
|
|
12476
12537
|
};
|
|
12477
12538
|
const patch = (id, p) => commit(listRef.current.map((m) => m.id === id ? Object.assign({}, m, typeof p === "function" ? p(m) : p) : m));
|
|
12478
12539
|
const push = (...msgs) => commit(listRef.current.concat(msgs));
|
|
@@ -12486,7 +12547,7 @@ function useChatEngine(opts) {
|
|
|
12486
12547
|
}
|
|
12487
12548
|
return false;
|
|
12488
12549
|
};
|
|
12489
|
-
const loadThread =
|
|
12550
|
+
const loadThread = React71.useCallback(async (id) => {
|
|
12490
12551
|
const data = await apiAdapter.getThread(id);
|
|
12491
12552
|
const list = [...data && data.messages || []];
|
|
12492
12553
|
serverCount.current = list.length;
|
|
@@ -12526,7 +12587,7 @@ function useChatEngine(opts) {
|
|
|
12526
12587
|
packet: progress.packet ?? holder.packet
|
|
12527
12588
|
});
|
|
12528
12589
|
}
|
|
12529
|
-
|
|
12590
|
+
React71.useEffect(() => {
|
|
12530
12591
|
if (!apiAdapter) {
|
|
12531
12592
|
setStatus("idle");
|
|
12532
12593
|
setFatal(null);
|
|
@@ -12573,7 +12634,7 @@ function useChatEngine(opts) {
|
|
|
12573
12634
|
setStatus("ready");
|
|
12574
12635
|
loadedRef.current = true;
|
|
12575
12636
|
onThreadReady && onThreadReady(id);
|
|
12576
|
-
const stored = store.get(
|
|
12637
|
+
const stored = store.get(jobKey(id));
|
|
12577
12638
|
const last = [...visibleMessages(listRef.current)].reverse().find((m) => m.role === "assistant");
|
|
12578
12639
|
if (stored) resumeJob(stored);
|
|
12579
12640
|
else if (last && last.working && last.jobId) resumeJob(last.jobId, last.id);
|
|
@@ -12592,7 +12653,7 @@ function useChatEngine(opts) {
|
|
|
12592
12653
|
};
|
|
12593
12654
|
}, [apiAdapter, contextType, contextId, threadIdProp]);
|
|
12594
12655
|
async function pollJob(jobId, placeholderId) {
|
|
12595
|
-
store.set(
|
|
12656
|
+
store.set(jobKey(threadRef.current), jobId);
|
|
12596
12657
|
const deadline = Date.now() + pendingTimeoutMs;
|
|
12597
12658
|
while (true) {
|
|
12598
12659
|
if (stoppedRef.current) break;
|
|
@@ -12640,7 +12701,7 @@ function useChatEngine(opts) {
|
|
|
12640
12701
|
}
|
|
12641
12702
|
}
|
|
12642
12703
|
async function finishJob(_jobId, _job) {
|
|
12643
|
-
store.del(
|
|
12704
|
+
store.del(jobKey(threadRef.current));
|
|
12644
12705
|
try {
|
|
12645
12706
|
const list = await loadThread(threadRef.current);
|
|
12646
12707
|
const withPacket = [...list].reverse().find((m) => m && m.packet);
|
|
@@ -12650,7 +12711,7 @@ function useChatEngine(opts) {
|
|
|
12650
12711
|
}
|
|
12651
12712
|
}
|
|
12652
12713
|
function recordFailure(placeholderId, code, retryable, job) {
|
|
12653
|
-
store.del(
|
|
12714
|
+
store.del(jobKey(threadRef.current));
|
|
12654
12715
|
if (!listRef.current.some((m) => m.id === placeholderId)) {
|
|
12655
12716
|
push({ id: placeholderId, role: "assistant", text: null });
|
|
12656
12717
|
}
|
|
@@ -12758,7 +12819,7 @@ function useChatEngine(opts) {
|
|
|
12758
12819
|
await dispatchTurn(turn);
|
|
12759
12820
|
}
|
|
12760
12821
|
}
|
|
12761
|
-
const send =
|
|
12822
|
+
const send = React71.useCallback((text, attachments) => {
|
|
12762
12823
|
const body = (text || "").trim();
|
|
12763
12824
|
if (!body && !(attachments && attachments.length)) return;
|
|
12764
12825
|
if (status === "disconnected") return;
|
|
@@ -12768,7 +12829,7 @@ function useChatEngine(opts) {
|
|
|
12768
12829
|
stoppedRef.current = false;
|
|
12769
12830
|
drain();
|
|
12770
12831
|
}, [status]);
|
|
12771
|
-
const stop =
|
|
12832
|
+
const stop = React71.useCallback(() => {
|
|
12772
12833
|
stoppedRef.current = true;
|
|
12773
12834
|
const ac = abortRef.current;
|
|
12774
12835
|
if (ac) {
|
|
@@ -12784,14 +12845,14 @@ function useChatEngine(opts) {
|
|
|
12784
12845
|
Promise.resolve(apiAdapter.cancelJob(holder.jobId)).catch(() => {
|
|
12785
12846
|
});
|
|
12786
12847
|
}
|
|
12787
|
-
store.del(
|
|
12848
|
+
store.del(jobKey(threadRef.current));
|
|
12788
12849
|
}
|
|
12789
12850
|
}, [apiAdapter]);
|
|
12790
|
-
const removeQueued =
|
|
12851
|
+
const removeQueued = React71.useCallback((id) => {
|
|
12791
12852
|
queueRef.current = queueRef.current.filter((t) => t.id !== id);
|
|
12792
12853
|
setQueue(queueRef.current.slice());
|
|
12793
12854
|
}, []);
|
|
12794
|
-
const retry =
|
|
12855
|
+
const retry = React71.useCallback(() => {
|
|
12795
12856
|
const list = listRef.current;
|
|
12796
12857
|
let at = -1;
|
|
12797
12858
|
for (let i = list.length - 1; i >= 0; i--) if (list[i].role === "user") {
|
|
@@ -12808,19 +12869,19 @@ function useChatEngine(opts) {
|
|
|
12808
12869
|
setQueue(queueRef.current.slice());
|
|
12809
12870
|
drain();
|
|
12810
12871
|
}, []);
|
|
12811
|
-
const clear =
|
|
12872
|
+
const clear = React71.useCallback(() => {
|
|
12812
12873
|
commit([]);
|
|
12813
12874
|
serverCount.current = 0;
|
|
12814
12875
|
queueRef.current = [];
|
|
12815
12876
|
setQueue([]);
|
|
12816
12877
|
onClear && onClear();
|
|
12817
12878
|
}, [onClear]);
|
|
12818
|
-
const setFeedback =
|
|
12879
|
+
const setFeedback = React71.useCallback((id, value) => {
|
|
12819
12880
|
patch(id, (m) => ({ feedback: m.feedback === value ? null : value }));
|
|
12820
12881
|
const msg = listRef.current.find((m) => m.id === id);
|
|
12821
12882
|
onFeedback && onFeedback({ message: msg, feedback: msg ? msg.feedback : value });
|
|
12822
12883
|
}, [onFeedback]);
|
|
12823
|
-
const reload =
|
|
12884
|
+
const reload = React71.useCallback(async () => {
|
|
12824
12885
|
if (!threadRef.current) return;
|
|
12825
12886
|
setStatus("loading");
|
|
12826
12887
|
try {
|
|
@@ -12858,10 +12919,10 @@ var ChatKit = {
|
|
|
12858
12919
|
};
|
|
12859
12920
|
|
|
12860
12921
|
// src/components/chat/ChatTranscript.tsx
|
|
12861
|
-
import * as
|
|
12922
|
+
import * as React73 from "react";
|
|
12862
12923
|
|
|
12863
12924
|
// src/components/chat/ChatTurn.tsx
|
|
12864
|
-
import * as
|
|
12925
|
+
import * as React72 from "react";
|
|
12865
12926
|
import { jsx as jsx101, jsxs as jsxs88 } from "react/jsx-runtime";
|
|
12866
12927
|
function JsonView({ value }) {
|
|
12867
12928
|
let text;
|
|
@@ -12898,7 +12959,7 @@ function PacketCard({ packet, schema, render, onApply, applied }) {
|
|
|
12898
12959
|
] });
|
|
12899
12960
|
}
|
|
12900
12961
|
function ThinkingBlock({ text, durationMs, streaming, defaultOpen = false }) {
|
|
12901
|
-
const [open2, setOpen] =
|
|
12962
|
+
const [open2, setOpen] = React72.useState(defaultOpen);
|
|
12902
12963
|
if (!text) return null;
|
|
12903
12964
|
return /* @__PURE__ */ jsxs88("div", { className: "fdc-think" + (open2 ? " is-open" : ""), children: [
|
|
12904
12965
|
/* @__PURE__ */ jsxs88("button", { type: "button", className: "fdc-think-head", onClick: () => setOpen((v) => !v), "aria-expanded": open2, children: [
|
|
@@ -12915,7 +12976,7 @@ function ThinkingBlock({ text, durationMs, streaming, defaultOpen = false }) {
|
|
|
12915
12976
|
] });
|
|
12916
12977
|
}
|
|
12917
12978
|
function Citations({ items = [], onOpen }) {
|
|
12918
|
-
const [open2, setOpen] =
|
|
12979
|
+
const [open2, setOpen] = React72.useState(false);
|
|
12919
12980
|
if (!items.length) return null;
|
|
12920
12981
|
return /* @__PURE__ */ jsxs88("div", { className: "fdc-cites", children: [
|
|
12921
12982
|
/* @__PURE__ */ jsxs88("button", { type: "button", className: "fdc-cites-head", onClick: () => setOpen((v) => !v), "aria-expanded": open2, children: [
|
|
@@ -12941,7 +13002,7 @@ function clampText(text, max) {
|
|
|
12941
13002
|
return (at > max * 0.6 ? cut.slice(0, at) : cut).trimEnd() + "\u2026";
|
|
12942
13003
|
}
|
|
12943
13004
|
function MessageBody({ message: m, ctx }) {
|
|
12944
|
-
const [expanded, setExpanded] =
|
|
13005
|
+
const [expanded, setExpanded] = React72.useState(false);
|
|
12945
13006
|
const isUser = m.role === "user";
|
|
12946
13007
|
const raw = m.text || "";
|
|
12947
13008
|
const clamped = !expanded && !m.streaming ? clampText(raw, ctx.maxVisibleChars) : null;
|
|
@@ -12949,7 +13010,7 @@ function MessageBody({ message: m, ctx }) {
|
|
|
12949
13010
|
const showMd = ctx.markdown && !isUser;
|
|
12950
13011
|
return /* @__PURE__ */ jsxs88("div", { className: "fdc-body", children: [
|
|
12951
13012
|
m.thinking && ctx.showThinking ? /* @__PURE__ */ jsx101(ThinkingBlock, { text: m.thinking, durationMs: m.thinkingMs, streaming: m.streaming && !m.text }) : null,
|
|
12952
|
-
m.steps && m.steps.length && ctx.showSteps ? /* @__PURE__ */ jsx101(StepList, { steps: m.steps, defaultOpen: m.steps.some((s) => s.status === "running"), dense: true }) : null,
|
|
13013
|
+
m.steps && m.steps.length && ctx.showSteps ? /* @__PURE__ */ jsx101(StepList, { steps: m.steps, defaultOpen: m.steps.some((s) => s.status === "running"), active: !!m.working, dense: true }) : null,
|
|
12953
13014
|
body ? /* @__PURE__ */ jsxs88("div", { className: "fdc-text" + (isUser ? " is-user" : ""), children: [
|
|
12954
13015
|
showMd ? /* @__PURE__ */ jsx101(Markdown, { source: body, headingOffset: 2, codeProps: { collapseAfter: 22 }, renderCitation: ctx.renderCitation }) : /* @__PURE__ */ jsx101("div", { className: "fdc-plain", children: body }),
|
|
12955
13016
|
m.streaming ? /* @__PURE__ */ jsx101("span", { className: "fdc-caret", "aria-hidden": "true" }) : null
|
|
@@ -12981,8 +13042,8 @@ function MessageBody({ message: m, ctx }) {
|
|
|
12981
13042
|
/* @__PURE__ */ jsx101("span", {})
|
|
12982
13043
|
] }),
|
|
12983
13044
|
/* @__PURE__ */ jsxs88("span", { className: "fdc-working-label", children: [
|
|
12984
|
-
m.resumed ? "Resuming" : "Working",
|
|
12985
|
-
m.job && m.job.status ? /* @__PURE__ */ jsxs88("span", { className: "fdc-working-job", children: [
|
|
13045
|
+
m.waitingFor || (m.resumed ? "Resuming" : "Working"),
|
|
13046
|
+
!m.waitingFor && m.job && m.job.status ? /* @__PURE__ */ jsxs88("span", { className: "fdc-working-job", children: [
|
|
12986
13047
|
" \xB7 ",
|
|
12987
13048
|
m.job.status
|
|
12988
13049
|
] }) : null,
|
|
@@ -12990,8 +13051,7 @@ function MessageBody({ message: m, ctx }) {
|
|
|
12990
13051
|
" \xB7 ",
|
|
12991
13052
|
m.job.detail
|
|
12992
13053
|
] }) : null
|
|
12993
|
-
] })
|
|
12994
|
-
m.jobId ? /* @__PURE__ */ jsx101("span", { className: "fdc-working-id fd-mono", children: String(m.jobId).slice(0, 12) }) : null
|
|
13054
|
+
] })
|
|
12995
13055
|
] }) : null,
|
|
12996
13056
|
m.stopped ? /* @__PURE__ */ jsxs88("div", { className: "fdc-stopped", children: [
|
|
12997
13057
|
/* @__PURE__ */ jsx101("i", { className: "ph ph-stop-circle", "aria-hidden": "true" }),
|
|
@@ -13021,7 +13081,7 @@ function RunActions({ group, ctx }) {
|
|
|
13021
13081
|
] }),
|
|
13022
13082
|
isAssistant && ctx.onRetry ? /* @__PURE__ */ jsx101("button", { type: "button", className: "fdc-act", onClick: ctx.onRetry, "aria-label": "Retry this turn", children: /* @__PURE__ */ jsx101("i", { className: "ph ph-arrow-clockwise", "aria-hidden": "true" }) }) : null,
|
|
13023
13083
|
group.role === "user" && ctx.onEdit ? /* @__PURE__ */ jsx101("button", { type: "button", className: "fdc-act", onClick: () => ctx.onEdit(last), "aria-label": "Edit and resend", children: /* @__PURE__ */ jsx101("i", { className: "ph ph-pencil-simple", "aria-hidden": "true" }) }) : null,
|
|
13024
|
-
isAssistant && ctx.onFeedback ? /* @__PURE__ */ jsxs88(
|
|
13084
|
+
isAssistant && ctx.onFeedback ? /* @__PURE__ */ jsxs88(React72.Fragment, { children: [
|
|
13025
13085
|
/* @__PURE__ */ jsx101("button", { type: "button", className: "fdc-act" + (fb === "up" ? " is-on" : ""), onClick: () => ctx.onFeedback(last.id, "up"), "aria-pressed": fb === "up", "aria-label": "Good response", children: /* @__PURE__ */ jsx101("i", { className: "ph ph-thumbs-up", "aria-hidden": "true" }) }),
|
|
13026
13086
|
/* @__PURE__ */ jsx101("button", { type: "button", className: "fdc-act" + (fb === "down" ? " is-on" : ""), onClick: () => ctx.onFeedback(last.id, "down"), "aria-pressed": fb === "down", "aria-label": "Bad response", children: /* @__PURE__ */ jsx101("i", { className: "ph ph-thumbs-down", "aria-hidden": "true" }) })
|
|
13027
13087
|
] }) : null,
|
|
@@ -13116,10 +13176,10 @@ function ChatTranscript({
|
|
|
13116
13176
|
renderEmpty,
|
|
13117
13177
|
className = ""
|
|
13118
13178
|
}) {
|
|
13119
|
-
const scroller =
|
|
13120
|
-
const stick =
|
|
13121
|
-
const [pill, setPill] =
|
|
13122
|
-
const seen =
|
|
13179
|
+
const scroller = React73.useRef(null);
|
|
13180
|
+
const stick = React73.useRef(true);
|
|
13181
|
+
const [pill, setPill] = React73.useState(0);
|
|
13182
|
+
const seen = React73.useRef(0);
|
|
13123
13183
|
const toBottom = (smooth) => {
|
|
13124
13184
|
const el = scroller.current;
|
|
13125
13185
|
if (!el) return;
|
|
@@ -13138,7 +13198,7 @@ function ChatTranscript({
|
|
|
13138
13198
|
seen.current = messages.length;
|
|
13139
13199
|
}
|
|
13140
13200
|
};
|
|
13141
|
-
|
|
13201
|
+
React73.useLayoutEffect(() => {
|
|
13142
13202
|
const el = scroller.current;
|
|
13143
13203
|
if (!el) return;
|
|
13144
13204
|
if (stick.current) {
|
|
@@ -13146,7 +13206,7 @@ function ChatTranscript({
|
|
|
13146
13206
|
seen.current = messages.length;
|
|
13147
13207
|
} else setPill(Math.max(0, messages.length - seen.current));
|
|
13148
13208
|
}, [messages]);
|
|
13149
|
-
|
|
13209
|
+
React73.useEffect(() => {
|
|
13150
13210
|
const el = scroller.current;
|
|
13151
13211
|
const inner = el && el.firstChild;
|
|
13152
13212
|
if (!el || !inner || typeof ResizeObserver === "undefined") return;
|
|
@@ -13156,7 +13216,7 @@ function ChatTranscript({
|
|
|
13156
13216
|
ro.observe(inner);
|
|
13157
13217
|
return () => ro.disconnect();
|
|
13158
13218
|
}, []);
|
|
13159
|
-
const groups =
|
|
13219
|
+
const groups = React73.useMemo(() => groupMessages(messages), [messages]);
|
|
13160
13220
|
const empty = !messages.length && status === "ready";
|
|
13161
13221
|
return /* @__PURE__ */ jsxs89("div", { className: ["fdc-scroll", className].filter(Boolean).join(" "), ref: scroller, onScroll, children: [
|
|
13162
13222
|
/* @__PURE__ */ jsxs89("div", { className: "fdc-log", role: "log", "aria-label": "Conversation", children: [
|
|
@@ -13180,7 +13240,7 @@ function ChatTranscript({
|
|
|
13180
13240
|
const prev = groups[i - 1];
|
|
13181
13241
|
const k = dayKey(g.messages[0].timestamp);
|
|
13182
13242
|
const showDay = !!k && (!prev || dayKey(prev.messages[0].timestamp) !== k);
|
|
13183
|
-
return /* @__PURE__ */ jsxs89(
|
|
13243
|
+
return /* @__PURE__ */ jsxs89(React73.Fragment, { children: [
|
|
13184
13244
|
showDay ? /* @__PURE__ */ jsx102("div", { className: "fdc-day", children: /* @__PURE__ */ jsx102("span", { children: dayLabel(k) }) }) : null,
|
|
13185
13245
|
/* @__PURE__ */ jsx102(ChatTurn, { group: g, ctx })
|
|
13186
13246
|
] }, g.key || i);
|
|
@@ -13197,7 +13257,7 @@ function ChatTranscript({
|
|
|
13197
13257
|
var TranscriptKit = { groupMessages };
|
|
13198
13258
|
|
|
13199
13259
|
// src/components/chat/ChatComposer.tsx
|
|
13200
|
-
import * as
|
|
13260
|
+
import * as React74 from "react";
|
|
13201
13261
|
import { jsx as jsx103, jsxs as jsxs90 } from "react/jsx-runtime";
|
|
13202
13262
|
function ChatComposer({
|
|
13203
13263
|
onSubmit,
|
|
@@ -13225,17 +13285,17 @@ function ChatComposer({
|
|
|
13225
13285
|
onReject,
|
|
13226
13286
|
onOpenAttachment
|
|
13227
13287
|
}) {
|
|
13228
|
-
const [text, setText] =
|
|
13229
|
-
const [trigger, setTrigger] =
|
|
13230
|
-
const [mentionItems, setMentionItems] =
|
|
13231
|
-
const [listening, setListening] =
|
|
13232
|
-
const [notice, setNotice] =
|
|
13233
|
-
const editor =
|
|
13234
|
-
const wrap =
|
|
13235
|
-
const stopVoice =
|
|
13288
|
+
const [text, setText] = React74.useState(draft || "");
|
|
13289
|
+
const [trigger, setTrigger] = React74.useState(null);
|
|
13290
|
+
const [mentionItems, setMentionItems] = React74.useState([]);
|
|
13291
|
+
const [listening, setListening] = React74.useState(false);
|
|
13292
|
+
const [notice, setNotice] = React74.useState(null);
|
|
13293
|
+
const editor = React74.useRef(null);
|
|
13294
|
+
const wrap = React74.useRef(null);
|
|
13295
|
+
const stopVoice = React74.useRef(null);
|
|
13236
13296
|
const staged = useStagedFiles(fileUploadHandler, { onError: () => {
|
|
13237
13297
|
} });
|
|
13238
|
-
|
|
13298
|
+
React74.useEffect(() => {
|
|
13239
13299
|
if (draft != null && draft !== text) setText(draft);
|
|
13240
13300
|
}, [draft]);
|
|
13241
13301
|
const change = (v) => {
|
|
@@ -13271,7 +13331,7 @@ function ChatComposer({
|
|
|
13271
13331
|
e.preventDefault();
|
|
13272
13332
|
staged.add(found.files);
|
|
13273
13333
|
};
|
|
13274
|
-
|
|
13334
|
+
React74.useEffect(() => {
|
|
13275
13335
|
if (!trigger || trigger.type !== "mention" || !mentionSources) {
|
|
13276
13336
|
setMentionItems([]);
|
|
13277
13337
|
return;
|
|
@@ -13289,7 +13349,7 @@ function ChatComposer({
|
|
|
13289
13349
|
const q = (trigger.query || "").toLowerCase();
|
|
13290
13350
|
setMentionItems(mentionSources.filter((m) => !q || (m.label + " " + (m.description || "")).toLowerCase().includes(q)));
|
|
13291
13351
|
}, [trigger, mentionSources]);
|
|
13292
|
-
const slashItems =
|
|
13352
|
+
const slashItems = React74.useMemo(() => {
|
|
13293
13353
|
if (!trigger || trigger.type !== "slash" || !slashCommands) return [];
|
|
13294
13354
|
const q = (trigger.query || "").toLowerCase();
|
|
13295
13355
|
return slashCommands.filter((c) => !q || (c.id + " " + c.label + " " + (c.description || "")).toLowerCase().includes(q));
|
|
@@ -13459,12 +13519,12 @@ function ChatComposer({
|
|
|
13459
13519
|
}
|
|
13460
13520
|
|
|
13461
13521
|
// src/components/chat/ChatSessionBar.tsx
|
|
13462
|
-
import * as
|
|
13522
|
+
import * as React75 from "react";
|
|
13463
13523
|
import { jsx as jsx104, jsxs as jsxs91 } from "react/jsx-runtime";
|
|
13464
13524
|
var compact2 = meterFormats.compact;
|
|
13465
13525
|
function ChatSessionBar({ sessionStats, contextUsage, usageLimits, onClear, extras }) {
|
|
13466
|
-
const [open2, setOpen] =
|
|
13467
|
-
const anchor =
|
|
13526
|
+
const [open2, setOpen] = React75.useState(false);
|
|
13527
|
+
const anchor = React75.useRef(null);
|
|
13468
13528
|
const stats = sessionStats || null;
|
|
13469
13529
|
const cu = contextUsage || null;
|
|
13470
13530
|
const limits = usageLimits || null;
|
|
@@ -13479,7 +13539,7 @@ function ChatSessionBar({ sessionStats, contextUsage, usageLimits, onClear, extr
|
|
|
13479
13539
|
if (stats && stats.runningTasks) bits.push(stats.runningTasks + " running task" + (stats.runningTasks === 1 ? "" : "s"));
|
|
13480
13540
|
if (cu) bits.push(pct + "% context");
|
|
13481
13541
|
const expandable = !!(cu || limits);
|
|
13482
|
-
return /* @__PURE__ */ jsxs91(
|
|
13542
|
+
return /* @__PURE__ */ jsxs91(React75.Fragment, { children: [
|
|
13483
13543
|
/* @__PURE__ */ jsxs91("div", { className: "fdc-bar", children: [
|
|
13484
13544
|
/* @__PURE__ */ jsxs91(
|
|
13485
13545
|
"button",
|
|
@@ -13620,7 +13680,7 @@ function ModelControls({
|
|
|
13620
13680
|
] })
|
|
13621
13681
|
});
|
|
13622
13682
|
}
|
|
13623
|
-
return /* @__PURE__ */ jsxs91(
|
|
13683
|
+
return /* @__PURE__ */ jsxs91(React75.Fragment, { children: [
|
|
13624
13684
|
/* @__PURE__ */ jsx104(
|
|
13625
13685
|
MenuButton,
|
|
13626
13686
|
{
|
|
@@ -13659,6 +13719,7 @@ function AgentChatPanel({
|
|
|
13659
13719
|
/* required */
|
|
13660
13720
|
contextType,
|
|
13661
13721
|
contextId,
|
|
13722
|
+
draftOwner,
|
|
13662
13723
|
apiAdapter,
|
|
13663
13724
|
threadId,
|
|
13664
13725
|
/* identity + chrome */
|
|
@@ -13688,6 +13749,7 @@ function AgentChatPanel({
|
|
|
13688
13749
|
packetRenderers,
|
|
13689
13750
|
onApplyPacket,
|
|
13690
13751
|
pendingTimeoutMs,
|
|
13752
|
+
describeWaiting,
|
|
13691
13753
|
onOpenAttachment,
|
|
13692
13754
|
errorCopy,
|
|
13693
13755
|
/* composer */
|
|
@@ -13738,11 +13800,11 @@ function AgentChatPanel({
|
|
|
13738
13800
|
onFeedback,
|
|
13739
13801
|
onEditMessage
|
|
13740
13802
|
}) {
|
|
13741
|
-
const [panelWidth, setPanelWidth] =
|
|
13742
|
-
const [applied, setApplied] =
|
|
13743
|
-
const [draft, setDraft] =
|
|
13744
|
-
const dragging =
|
|
13745
|
-
|
|
13803
|
+
const [panelWidth, setPanelWidth] = React76.useState(width);
|
|
13804
|
+
const [applied, setApplied] = React76.useState({});
|
|
13805
|
+
const [draft, setDraft] = useChatDraft(draftOwner, contextType, contextId);
|
|
13806
|
+
const dragging = React76.useRef(null);
|
|
13807
|
+
React76.useEffect(() => setPanelWidth(width), [width]);
|
|
13746
13808
|
const engine = useChatEngine({
|
|
13747
13809
|
contextType,
|
|
13748
13810
|
contextId,
|
|
@@ -13750,6 +13812,7 @@ function AgentChatPanel({
|
|
|
13750
13812
|
initialMessage,
|
|
13751
13813
|
threadId,
|
|
13752
13814
|
pendingTimeoutMs,
|
|
13815
|
+
describeWaiting,
|
|
13753
13816
|
onPacket,
|
|
13754
13817
|
onThreadReady,
|
|
13755
13818
|
onError,
|
|
@@ -13947,7 +14010,7 @@ function AgentChatPanel({
|
|
|
13947
14010
|
}
|
|
13948
14011
|
|
|
13949
14012
|
// src/components/files/FileViewer.tsx
|
|
13950
|
-
import * as
|
|
14013
|
+
import * as React77 from "react";
|
|
13951
14014
|
import { jsx as jsx106, jsxs as jsxs93 } from "react/jsx-runtime";
|
|
13952
14015
|
function previewKindOf(file) {
|
|
13953
14016
|
const mime = (file.mime || "").toLowerCase();
|
|
@@ -14004,13 +14067,13 @@ function parseDelimited(text, delimiter) {
|
|
|
14004
14067
|
return rows;
|
|
14005
14068
|
}
|
|
14006
14069
|
function usePreview(file, kind, resolveUrl) {
|
|
14007
|
-
const [state, setState] =
|
|
14008
|
-
const [attempt, setAttempt] =
|
|
14009
|
-
const resolveRef =
|
|
14010
|
-
|
|
14070
|
+
const [state, setState] = React77.useState({ status: "loading" });
|
|
14071
|
+
const [attempt, setAttempt] = React77.useState(0);
|
|
14072
|
+
const resolveRef = React77.useRef(resolveUrl);
|
|
14073
|
+
React77.useEffect(() => {
|
|
14011
14074
|
resolveRef.current = resolveUrl;
|
|
14012
14075
|
}, [resolveUrl]);
|
|
14013
|
-
|
|
14076
|
+
React77.useEffect(() => {
|
|
14014
14077
|
if (kind === "none") {
|
|
14015
14078
|
setState({ status: "ready" });
|
|
14016
14079
|
return;
|
|
@@ -14040,7 +14103,7 @@ function usePreview(file, kind, resolveUrl) {
|
|
|
14040
14103
|
if (ac) ac.abort();
|
|
14041
14104
|
};
|
|
14042
14105
|
}, [file.id, kind, attempt]);
|
|
14043
|
-
return { ...state, retry:
|
|
14106
|
+
return { ...state, retry: React77.useCallback(() => setAttempt((a) => a + 1), []) };
|
|
14044
14107
|
}
|
|
14045
14108
|
function PreviewBody({ file, kind, state }) {
|
|
14046
14109
|
if (kind === "image") return /* @__PURE__ */ jsx106("img", { className: "fd-fv-image", src: state.url, alt: file.name || "Preview" });
|
|
@@ -14085,13 +14148,13 @@ function PreviewBody({ file, kind, state }) {
|
|
|
14085
14148
|
] });
|
|
14086
14149
|
}
|
|
14087
14150
|
function FileViewer({ file, resolveUrl, sidePanel, sidePanelLabel = "Details", onClose, actions, className = "" }) {
|
|
14088
|
-
const kind =
|
|
14151
|
+
const kind = React77.useMemo(() => previewKindOf(file), [file]);
|
|
14089
14152
|
const preview = usePreview(file, kind, resolveUrl);
|
|
14090
|
-
const [tab, setTab] =
|
|
14091
|
-
const [downloading, setDownloading] =
|
|
14092
|
-
const [downloadError, setDownloadError] =
|
|
14153
|
+
const [tab, setTab] = React77.useState("preview");
|
|
14154
|
+
const [downloading, setDownloading] = React77.useState(false);
|
|
14155
|
+
const [downloadError, setDownloadError] = React77.useState(null);
|
|
14093
14156
|
const hasSide = sidePanel != null;
|
|
14094
|
-
|
|
14157
|
+
React77.useEffect(() => {
|
|
14095
14158
|
setTab("preview");
|
|
14096
14159
|
}, [file.id]);
|
|
14097
14160
|
const download = () => {
|
|
@@ -14158,7 +14221,7 @@ function FileViewer({ file, resolveUrl, sidePanel, sidePanelLabel = "Details", o
|
|
|
14158
14221
|
}
|
|
14159
14222
|
|
|
14160
14223
|
// src/components/files/FileBrowser.tsx
|
|
14161
|
-
import * as
|
|
14224
|
+
import * as React78 from "react";
|
|
14162
14225
|
import { Fragment as Fragment31, jsx as jsx107, jsxs as jsxs94 } from "react/jsx-runtime";
|
|
14163
14226
|
function childrenOf(folders, parentId) {
|
|
14164
14227
|
return folders.filter((f) => f.parentId === parentId).sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -14268,8 +14331,8 @@ function FolderPickerMenu({
|
|
|
14268
14331
|
] });
|
|
14269
14332
|
}
|
|
14270
14333
|
function RowShell({ icon, name, meta, onOpen, draggableId, isDropTarget, onDropPayload, actions, className = "" }) {
|
|
14271
|
-
const [over, setOver] =
|
|
14272
|
-
const dragCounter =
|
|
14334
|
+
const [over, setOver] = React78.useState(false);
|
|
14335
|
+
const dragCounter = React78.useRef(0);
|
|
14273
14336
|
const dropHandlers = isDropTarget ? {
|
|
14274
14337
|
onDragEnter: (e) => {
|
|
14275
14338
|
if (!hasInternalPayload(e)) return;
|
|
@@ -14317,8 +14380,8 @@ function RowShell({ icon, name, meta, onOpen, draggableId, isDropTarget, onDropP
|
|
|
14317
14380
|
}
|
|
14318
14381
|
function TreeNode({ folder, depth, folders, currentFolderId, onNavigate, onMoveInto, canMove }) {
|
|
14319
14382
|
const kids = childrenOf(folders, folder.id);
|
|
14320
|
-
const [expanded, setExpanded] =
|
|
14321
|
-
|
|
14383
|
+
const [expanded, setExpanded] = React78.useState(() => currentFolderId != null && isSelfOrDescendant(folders, folder.id, currentFolderId));
|
|
14384
|
+
React78.useEffect(() => {
|
|
14322
14385
|
if (currentFolderId != null && isSelfOrDescendant(folders, folder.id, currentFolderId)) setExpanded(true);
|
|
14323
14386
|
}, [currentFolderId, folder.id, folders]);
|
|
14324
14387
|
const isCurrent = folder.id === currentFolderId;
|
|
@@ -14384,15 +14447,15 @@ function FileBrowser({
|
|
|
14384
14447
|
const canUpload = perm.canUpload !== false && !!onUpload;
|
|
14385
14448
|
const canRemoveFile = perm.canRemoveFile !== false && !!onRemoveFile;
|
|
14386
14449
|
const canDeleteFolder = perm.canDeleteFolder !== false && !!onDeleteFolder;
|
|
14387
|
-
const [createOpen, setCreateOpen] =
|
|
14388
|
-
const [createName, setCreateName] =
|
|
14389
|
-
const [renameTarget, setRenameTarget] =
|
|
14390
|
-
const [renameValue, setRenameValue] =
|
|
14391
|
-
const [deleteTarget, setDeleteTarget] =
|
|
14392
|
-
const uploadInputRef =
|
|
14393
|
-
const crumbFolders =
|
|
14394
|
-
const subfolders =
|
|
14395
|
-
const currentFiles =
|
|
14450
|
+
const [createOpen, setCreateOpen] = React78.useState(false);
|
|
14451
|
+
const [createName, setCreateName] = React78.useState("");
|
|
14452
|
+
const [renameTarget, setRenameTarget] = React78.useState(null);
|
|
14453
|
+
const [renameValue, setRenameValue] = React78.useState("");
|
|
14454
|
+
const [deleteTarget, setDeleteTarget] = React78.useState(null);
|
|
14455
|
+
const uploadInputRef = React78.useRef(null);
|
|
14456
|
+
const crumbFolders = React78.useMemo(() => ancestorsOf(folders, currentFolderId), [folders, currentFolderId]);
|
|
14457
|
+
const subfolders = React78.useMemo(() => childrenOf(folders, currentFolderId), [folders, currentFolderId]);
|
|
14458
|
+
const currentFiles = React78.useMemo(
|
|
14396
14459
|
() => files.filter((f) => f.folderId === currentFolderId).sort((a, b) => a.name.localeCompare(b.name)),
|
|
14397
14460
|
[files, currentFolderId]
|
|
14398
14461
|
);
|
|
@@ -14624,8 +14687,8 @@ function BreadcrumbCrumb({
|
|
|
14624
14687
|
isDropTarget,
|
|
14625
14688
|
onDropPayload
|
|
14626
14689
|
}) {
|
|
14627
|
-
const [over, setOver] =
|
|
14628
|
-
const dragCounter =
|
|
14690
|
+
const [over, setOver] = React78.useState(false);
|
|
14691
|
+
const dragCounter = React78.useRef(0);
|
|
14629
14692
|
const dropHandlers = isDropTarget ? {
|
|
14630
14693
|
onDragEnter: (e) => {
|
|
14631
14694
|
if (!hasInternalPayload(e)) return;
|
|
@@ -14654,7 +14717,7 @@ function BreadcrumbCrumb({
|
|
|
14654
14717
|
}
|
|
14655
14718
|
|
|
14656
14719
|
// src/kits/query.ts
|
|
14657
|
-
import * as
|
|
14720
|
+
import * as React79 from "react";
|
|
14658
14721
|
|
|
14659
14722
|
// src/kits/queryUrl.ts
|
|
14660
14723
|
var historyUrlAdapter = {
|
|
@@ -14792,38 +14855,38 @@ function requestFor(params, query, paging, after) {
|
|
|
14792
14855
|
}
|
|
14793
14856
|
var toError = (e) => e instanceof Error ? e : new Error(String(e));
|
|
14794
14857
|
function useServerTable({ endpoint, params, defaults, deps, prefsKey, paging = "page", url }) {
|
|
14795
|
-
const [base] =
|
|
14858
|
+
const [base] = React79.useState(() => {
|
|
14796
14859
|
const store = PREFS || window.PlannerPrefs;
|
|
14797
14860
|
const saved = prefsKey && store ? store.getTable(prefsKey) : {};
|
|
14798
14861
|
return { ...DEFAULTS, ...defaults || {}, ...saved.pageSize ? { pageSize: saved.pageSize } : {}, ...saved.sort ? { sort: saved.sort, dir: saved.dir || "desc" } : {} };
|
|
14799
14862
|
});
|
|
14800
|
-
const [mountParams] =
|
|
14801
|
-
const address =
|
|
14802
|
-
const [query, setQuery] =
|
|
14803
|
-
const savePref =
|
|
14863
|
+
const [mountParams] = React79.useState(() => url ? (url.adapter ?? historyUrlAdapter).read() : null);
|
|
14864
|
+
const address = React79.useRef(mountParams);
|
|
14865
|
+
const [query, setQuery] = React79.useState(() => url && mountParams ? readQueryFromUrl(mountParams, url.scope, base, paging) : base);
|
|
14866
|
+
const savePref = React79.useCallback((patch2) => {
|
|
14804
14867
|
const store = PREFS || window.PlannerPrefs;
|
|
14805
14868
|
if (prefsKey && store) store.setTable(prefsKey, patch2);
|
|
14806
14869
|
}, [prefsKey]);
|
|
14807
|
-
const [res, setRes] =
|
|
14808
|
-
const [loading, setLoading] =
|
|
14809
|
-
const [loadingMore, setLoadingMore] =
|
|
14810
|
-
const [failure, setFailure] =
|
|
14811
|
-
const [reloadToken, setReloadToken] =
|
|
14812
|
-
const moreController =
|
|
14870
|
+
const [res, setRes] = React79.useState(null);
|
|
14871
|
+
const [loading, setLoading] = React79.useState(true);
|
|
14872
|
+
const [loadingMore, setLoadingMore] = React79.useState(false);
|
|
14873
|
+
const [failure, setFailure] = React79.useState(null);
|
|
14874
|
+
const [reloadToken, setReloadToken] = React79.useState(0);
|
|
14875
|
+
const moreController = React79.useRef(null);
|
|
14813
14876
|
const depKey = (deps || []).join("|");
|
|
14814
14877
|
const paramKey = JSON.stringify(params || {});
|
|
14815
14878
|
const queryKey = JSON.stringify(query);
|
|
14816
|
-
const lifetime =
|
|
14817
|
-
|
|
14879
|
+
const lifetime = React79.useRef(null);
|
|
14880
|
+
React79.useEffect(() => {
|
|
14818
14881
|
const controller = new AbortController();
|
|
14819
14882
|
lifetime.current = controller;
|
|
14820
14883
|
return () => controller.abort();
|
|
14821
14884
|
}, []);
|
|
14822
|
-
const latest =
|
|
14823
|
-
|
|
14885
|
+
const latest = React79.useRef({ res, loading, query, params, endpoint, url, base });
|
|
14886
|
+
React79.useLayoutEffect(() => {
|
|
14824
14887
|
latest.current = { res, loading, query, params, endpoint, url, base };
|
|
14825
14888
|
});
|
|
14826
|
-
|
|
14889
|
+
React79.useEffect(() => {
|
|
14827
14890
|
const controller = new AbortController();
|
|
14828
14891
|
const { signal } = controller;
|
|
14829
14892
|
setLoading(true);
|
|
@@ -14859,7 +14922,7 @@ function useServerTable({ endpoint, params, defaults, deps, prefsKey, paging = "
|
|
|
14859
14922
|
};
|
|
14860
14923
|
}, [endpoint, queryKey, paramKey, depKey, paging, reloadToken]);
|
|
14861
14924
|
const adapter = url ? url.adapter ?? historyUrlAdapter : null;
|
|
14862
|
-
|
|
14925
|
+
React79.useEffect(() => {
|
|
14863
14926
|
if (!adapter) return;
|
|
14864
14927
|
return adapter.subscribe((params2) => {
|
|
14865
14928
|
const { url: u, base: b } = latest.current;
|
|
@@ -15209,12 +15272,12 @@ function createVersionStore(initialState, options) {
|
|
|
15209
15272
|
}
|
|
15210
15273
|
|
|
15211
15274
|
// src/kits/documentTitle.ts
|
|
15212
|
-
import * as
|
|
15275
|
+
import * as React80 from "react";
|
|
15213
15276
|
function formatDocumentTitle(routeTitle, appName) {
|
|
15214
|
-
return [routeTitle, appName, "Flytedesk"].filter((
|
|
15277
|
+
return [routeTitle, appName, "Flytedesk"].filter((part2) => !!part2 && part2.length > 0).join(" \xB7 ");
|
|
15215
15278
|
}
|
|
15216
15279
|
function useDocumentTitle(routeTitle, appName) {
|
|
15217
|
-
|
|
15280
|
+
React80.useEffect(() => {
|
|
15218
15281
|
if (typeof document === "undefined") return;
|
|
15219
15282
|
document.title = formatDocumentTitle(routeTitle, appName);
|
|
15220
15283
|
}, [routeTitle, appName]);
|
|
@@ -15324,6 +15387,7 @@ export {
|
|
|
15324
15387
|
ModeSwitch,
|
|
15325
15388
|
ModelControls,
|
|
15326
15389
|
NumberInput,
|
|
15390
|
+
OVERLAY_BREAKPOINT,
|
|
15327
15391
|
OVERLAY_CEILING,
|
|
15328
15392
|
POPOVER_BODY_MIN,
|
|
15329
15393
|
PacketCard,
|
|
@@ -15448,6 +15512,7 @@ export {
|
|
|
15448
15512
|
useDocumentTitle,
|
|
15449
15513
|
useFeatureStatus,
|
|
15450
15514
|
useLayerZIndex,
|
|
15515
|
+
useOverlayLayout,
|
|
15451
15516
|
usePopoverPosition,
|
|
15452
15517
|
useResponsiveRail,
|
|
15453
15518
|
useRuntimeMode,
|