reifyui 0.5.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -3
- package/dist/{chunk-2LYV4PIX.js → chunk-NTIWFHR4.js} +26 -2
- package/dist/chunk-NTIWFHR4.js.map +1 -0
- package/dist/harness.cjs +72 -21
- package/dist/harness.cjs.map +1 -1
- package/dist/harness.d.ts +23 -0
- package/dist/harness.js +52 -23
- package/dist/harness.js.map +1 -1
- package/dist/index.cjs +1126 -296
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +260 -1
- package/dist/index.js +1101 -293
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Card.jsx +49 -0
- package/src/components/Carousel.jsx +80 -0
- package/src/components/ChatPanel.jsx +461 -0
- package/src/components/Chip.jsx +61 -0
- package/src/components/Composer.jsx +20 -1
- package/src/components/Dialog.jsx +5 -10
- package/src/components/Modal.jsx +75 -0
- package/src/components/Popover.jsx +86 -0
- package/src/components/SearchField.jsx +30 -0
- package/src/components/icons.jsx +9 -0
- package/src/components/overlay.js +63 -0
- package/src/format.js +10 -0
- package/src/harness/attach.js +63 -0
- package/src/harness/index.d.ts +23 -0
- package/src/harness/index.js +6 -18
- package/src/hooks/useTypewriter.js +53 -0
- package/src/index.d.ts +260 -1
- package/src/index.js +27 -1
- package/src/input/dictate.js +60 -0
- package/src/state/turns.js +30 -0
- package/styles/chat.css +131 -1
- package/styles/chip.css +53 -0
- package/styles/dialog.css +42 -37
- package/styles/library.css +205 -0
- package/styles/preview.css +73 -0
- package/styles/sheet.css +16 -14
- package/styles/themes/dark.css +20 -0
- package/styles/themes/light.css +23 -0
- package/dist/chunk-2LYV4PIX.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createResponsesDispatcher,
|
|
3
3
|
pumpResponsesStream,
|
|
4
|
-
readSSEStream
|
|
5
|
-
|
|
4
|
+
readSSEStream,
|
|
5
|
+
turnsToMessages
|
|
6
|
+
} from "./chunk-NTIWFHR4.js";
|
|
6
7
|
|
|
7
8
|
// src/state/blocks.js
|
|
8
9
|
function withText(blocks, d) {
|
|
@@ -171,6 +172,16 @@ var IcSend = () => /* @__PURE__ */ jsxs(Svg, { s: 16, children: [
|
|
|
171
172
|
/* @__PURE__ */ jsx("path", { d: "M12 19V5" }),
|
|
172
173
|
/* @__PURE__ */ jsx("path", { d: "M5 12l7-7 7 7" })
|
|
173
174
|
] });
|
|
175
|
+
var IcX = ({ size = 14 }) => /* @__PURE__ */ jsx(Svg, { s: size, children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" }) });
|
|
176
|
+
var IcMic = ({ size = 15 }) => /* @__PURE__ */ jsxs(Svg, { s: size, children: [
|
|
177
|
+
/* @__PURE__ */ jsx("rect", { x: "9", y: "2", width: "6", height: "12", rx: "3" }),
|
|
178
|
+
/* @__PURE__ */ jsx("path", { d: "M5 11a7 7 0 0 0 14 0M12 18v4M8 22h8" })
|
|
179
|
+
] });
|
|
180
|
+
var IcPaperclip = ({ size = 16 }) => /* @__PURE__ */ jsx(Svg, { s: size, children: /* @__PURE__ */ jsx("path", { d: "M21.4 11.1 12.2 20.3a5.5 5.5 0 0 1-7.8-7.8l9.2-9.2a3.7 3.7 0 0 1 5.2 5.2l-9.2 9.2a1.8 1.8 0 0 1-2.6-2.6l8.5-8.5" }) });
|
|
181
|
+
var IcPanelRight = ({ size = 17 }) => /* @__PURE__ */ jsxs(Svg, { s: size, children: [
|
|
182
|
+
/* @__PURE__ */ jsx("rect", { x: "3", y: "4", width: "18", height: "16", rx: "2" }),
|
|
183
|
+
/* @__PURE__ */ jsx("path", { d: "M15 4v16" })
|
|
184
|
+
] });
|
|
174
185
|
|
|
175
186
|
// src/components/toolMeta.js
|
|
176
187
|
function humanize(s) {
|
|
@@ -538,6 +549,11 @@ function Composer(props) {
|
|
|
538
549
|
rows = 1,
|
|
539
550
|
autoGrow = true,
|
|
540
551
|
maxRows = 15,
|
|
552
|
+
autoFocus,
|
|
553
|
+
// The composer on a landing page often has an ANIMATING placeholder (a typewriter cycling
|
|
554
|
+
// through example prompts), and a placeholder is the textarea's only accessible name unless
|
|
555
|
+
// one is given — so the field announces a different name every few seconds.
|
|
556
|
+
inputAriaLabel,
|
|
541
557
|
attachments,
|
|
542
558
|
accessoriesLeft,
|
|
543
559
|
accessoriesRight,
|
|
@@ -569,12 +585,13 @@ function Composer(props) {
|
|
|
569
585
|
value,
|
|
570
586
|
disabled,
|
|
571
587
|
rows,
|
|
588
|
+
autoFocus,
|
|
589
|
+
"aria-label": inputAriaLabel,
|
|
572
590
|
onChange: (e) => onChange(e.target.value),
|
|
573
591
|
onKeyDown: (e) => {
|
|
574
|
-
if (e.key
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
}
|
|
592
|
+
if (e.key !== "Enter" || e.shiftKey) return;
|
|
593
|
+
e.preventDefault();
|
|
594
|
+
if (!sendDisabled) onSend();
|
|
578
595
|
}
|
|
579
596
|
}
|
|
580
597
|
),
|
|
@@ -587,9 +604,462 @@ function Composer(props) {
|
|
|
587
604
|
] });
|
|
588
605
|
}
|
|
589
606
|
|
|
590
|
-
// src/components/
|
|
607
|
+
// src/components/ChatPanel.jsx
|
|
608
|
+
import React6, { useCallback, useEffect as useEffect3, useRef as useRef2, useState as useState2 } from "react";
|
|
609
|
+
|
|
610
|
+
// src/components/Chip.jsx
|
|
591
611
|
import React5 from "react";
|
|
592
|
-
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
612
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
613
|
+
function Chip(props) {
|
|
614
|
+
const { label, icon, title, selected = false, onClick, onRemove, removeLabel, className } = props;
|
|
615
|
+
const cls = [
|
|
616
|
+
"uic-chip",
|
|
617
|
+
selected ? "is-selected" : "",
|
|
618
|
+
onClick && !selected ? "is-open" : "",
|
|
619
|
+
className || ""
|
|
620
|
+
].filter(Boolean).join(" ");
|
|
621
|
+
const body = /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
622
|
+
icon ? /* @__PURE__ */ jsx5("span", { className: "uic-chip-ic", "aria-hidden": "true", children: icon }) : null,
|
|
623
|
+
/* @__PURE__ */ jsx5("span", { className: "uic-chip-l", children: label })
|
|
624
|
+
] });
|
|
625
|
+
if (onClick && onRemove) {
|
|
626
|
+
return /* @__PURE__ */ jsxs5("span", { className: cls, title, children: [
|
|
627
|
+
/* @__PURE__ */ jsx5("button", { type: "button", className: "uic-chip-press", onClick, children: body }),
|
|
628
|
+
/* @__PURE__ */ jsx5("button", { type: "button", className: "uic-chip-x", "aria-label": removeLabel, onClick: onRemove, children: /* @__PURE__ */ jsx5(IcX, { size: 12 }) })
|
|
629
|
+
] });
|
|
630
|
+
}
|
|
631
|
+
if (onClick) {
|
|
632
|
+
return /* @__PURE__ */ jsx5("button", { type: "button", className: cls, title, onClick, children: body });
|
|
633
|
+
}
|
|
634
|
+
return /* @__PURE__ */ jsxs5("span", { className: cls, title, children: [
|
|
635
|
+
body,
|
|
636
|
+
onRemove ? /* @__PURE__ */ jsx5("button", { type: "button", className: "uic-chip-x", "aria-label": removeLabel, onClick: onRemove, children: /* @__PURE__ */ jsx5(IcX, { size: 12 }) }) : null
|
|
637
|
+
] });
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
// src/format.js
|
|
641
|
+
function bytesLabel(n) {
|
|
642
|
+
if (n == null) return "";
|
|
643
|
+
if (n < 1024) return `${n} B`;
|
|
644
|
+
if (n < 1048576) return `${Math.round(n / 1024)} KB`;
|
|
645
|
+
return `${(n / 1048576).toFixed(1)} MB`;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
// src/components/ChatPanel.jsx
|
|
649
|
+
import { Fragment as Fragment3, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
650
|
+
var POLL_MS = 3e3;
|
|
651
|
+
var RETRY_MS = 2e4;
|
|
652
|
+
var PIN_PX = 80;
|
|
653
|
+
var PANEL_STATUS_LABELS = {
|
|
654
|
+
failed: "This turn failed. Please try again.",
|
|
655
|
+
cancelled: "Stopped",
|
|
656
|
+
incomplete: "The turn hit its limit. Send a follow up to continue."
|
|
657
|
+
};
|
|
658
|
+
function ChatPanel(props) {
|
|
659
|
+
const {
|
|
660
|
+
sessionId,
|
|
661
|
+
runTurn,
|
|
662
|
+
loadHistory,
|
|
663
|
+
onSessionStarted,
|
|
664
|
+
onChanged,
|
|
665
|
+
seed = "",
|
|
666
|
+
onSeedConsumed,
|
|
667
|
+
externalBusy = false,
|
|
668
|
+
attachments = null,
|
|
669
|
+
dictation = null,
|
|
670
|
+
title = "",
|
|
671
|
+
headerRight = null,
|
|
672
|
+
collapsed = false,
|
|
673
|
+
onToggleCollapse,
|
|
674
|
+
width,
|
|
675
|
+
placeholder = "Message",
|
|
676
|
+
emptyState = null,
|
|
677
|
+
busyState,
|
|
678
|
+
connectingLabel = "connecting",
|
|
679
|
+
connectingNote = "Still connecting. Your message will be sent as soon as it is online.",
|
|
680
|
+
workingLabel = "Working\u2026",
|
|
681
|
+
statusLabels = PANEL_STATUS_LABELS,
|
|
682
|
+
renderMarkdown,
|
|
683
|
+
userExtras,
|
|
684
|
+
toolLabels,
|
|
685
|
+
classNames = {}
|
|
686
|
+
} = props;
|
|
687
|
+
const [messages, setMessages] = useState2([]);
|
|
688
|
+
const [draft, setDraft] = useState2("");
|
|
689
|
+
const [busy, setBusy] = useState2(false);
|
|
690
|
+
const [connecting, setConnecting] = useState2(false);
|
|
691
|
+
const [histLoading, setHistLoading] = useState2(true);
|
|
692
|
+
const [staged, setStaged] = useState2([]);
|
|
693
|
+
const [attachErr, setAttachErr] = useState2("");
|
|
694
|
+
const [listening2, setListening] = useState2(false);
|
|
695
|
+
const pendingRef = useRef2(null);
|
|
696
|
+
const seededRef = useRef2(false);
|
|
697
|
+
const adoptedRef = useRef2(null);
|
|
698
|
+
const bodyRef = useRef2(null);
|
|
699
|
+
const fileRef = useRef2(null);
|
|
700
|
+
const pinnedRef = useRef2(true);
|
|
701
|
+
const prevExternalBusyRef = useRef2(false);
|
|
702
|
+
const prevIdRef = useRef2(sessionId);
|
|
703
|
+
const api = useRef2(null);
|
|
704
|
+
api.current = { runTurn, loadHistory, onSessionStarted, onChanged, onSeedConsumed };
|
|
705
|
+
useEffect3(() => () => dictation?.stop(), [dictation]);
|
|
706
|
+
function updateLastAsst(fn) {
|
|
707
|
+
setMessages((m) => {
|
|
708
|
+
const out = m.slice();
|
|
709
|
+
for (let i = out.length - 1; i >= 0; i -= 1) {
|
|
710
|
+
if (out[i].role === "assistant") {
|
|
711
|
+
out[i] = fn({ ...out[i] });
|
|
712
|
+
break;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
return out;
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
function dropRunningAsst() {
|
|
719
|
+
setMessages((m) => m.length && m[m.length - 1].role === "assistant" && m[m.length - 1].status === "running" ? m.slice(0, -1) : m);
|
|
720
|
+
}
|
|
721
|
+
const onBodyScroll = () => {
|
|
722
|
+
const el = bodyRef.current;
|
|
723
|
+
if (el) pinnedRef.current = el.scrollHeight - el.scrollTop - el.clientHeight <= PIN_PX;
|
|
724
|
+
};
|
|
725
|
+
useEffect3(() => {
|
|
726
|
+
const el = bodyRef.current;
|
|
727
|
+
if (el && pinnedRef.current) el.scrollTo({ top: el.scrollHeight });
|
|
728
|
+
}, [messages, connecting, histLoading]);
|
|
729
|
+
const deliver = useCallback(async (text, files = []) => {
|
|
730
|
+
setBusy(true);
|
|
731
|
+
setMessages((m) => [...m, { role: "assistant", blocks: [], status: "running" }]);
|
|
732
|
+
try {
|
|
733
|
+
const out = await api.current.runTurn({
|
|
734
|
+
sessionId,
|
|
735
|
+
text,
|
|
736
|
+
attachments: files,
|
|
737
|
+
handlers: {
|
|
738
|
+
onSession: (sid) => {
|
|
739
|
+
if (sid && sid !== sessionId) adoptedRef.current = sid;
|
|
740
|
+
api.current.onSessionStarted?.(sid);
|
|
741
|
+
},
|
|
742
|
+
onReasoningDelta: (d) => updateLastAsst((a) => ({ ...a, blocks: withReasoning(a.blocks, d) })),
|
|
743
|
+
onToolCall: (name, args, callId) => updateLastAsst((a) => ({ ...a, blocks: withStep(a.blocks, { name, args, callId }) })),
|
|
744
|
+
onToolResult: (callId, output) => updateLastAsst((a) => ({ ...a, blocks: withResult(a.blocks, callId, output) })),
|
|
745
|
+
onTextDelta: (d) => updateLastAsst((a) => ({ ...a, blocks: withText(a.blocks, d) })),
|
|
746
|
+
onDone: (status) => updateLastAsst((a) => ({ ...a, status: status === "completed" ? "done" : status })),
|
|
747
|
+
onError: () => updateLastAsst((a) => ({
|
|
748
|
+
...a,
|
|
749
|
+
blocks: a.blocks.length ? a.blocks : withText([], "Something went wrong. Please try again."),
|
|
750
|
+
status: "failed"
|
|
751
|
+
}))
|
|
752
|
+
}
|
|
753
|
+
}) || {};
|
|
754
|
+
if (out.connecting) {
|
|
755
|
+
dropRunningAsst();
|
|
756
|
+
pendingRef.current = { text, files };
|
|
757
|
+
setConnecting(true);
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
pendingRef.current = null;
|
|
761
|
+
setConnecting(false);
|
|
762
|
+
updateLastAsst((a) => a.status === "running" ? { ...a, status: "done" } : a);
|
|
763
|
+
api.current.onChanged?.();
|
|
764
|
+
} catch {
|
|
765
|
+
dropRunningAsst();
|
|
766
|
+
pendingRef.current = { text, files };
|
|
767
|
+
setConnecting(true);
|
|
768
|
+
} finally {
|
|
769
|
+
setBusy(false);
|
|
770
|
+
}
|
|
771
|
+
}, [sessionId]);
|
|
772
|
+
const preparing = staged.some((f) => f.pending);
|
|
773
|
+
const sendBlocked = busy || histLoading || preparing;
|
|
774
|
+
function send() {
|
|
775
|
+
const t = draft.trim();
|
|
776
|
+
if (!t || sendBlocked) return;
|
|
777
|
+
if (listening2) {
|
|
778
|
+
dictation?.stop();
|
|
779
|
+
setListening(false);
|
|
780
|
+
}
|
|
781
|
+
const files = staged;
|
|
782
|
+
setMessages((m) => [...m, { role: "user", text: t, files: files.map((f) => f.name) }]);
|
|
783
|
+
setDraft("");
|
|
784
|
+
setStaged([]);
|
|
785
|
+
setAttachErr("");
|
|
786
|
+
deliver(t, files);
|
|
787
|
+
}
|
|
788
|
+
useEffect3(() => {
|
|
789
|
+
const adopted = adoptedRef.current;
|
|
790
|
+
adoptedRef.current = null;
|
|
791
|
+
if (adopted && adopted === sessionId) {
|
|
792
|
+
prevIdRef.current = sessionId;
|
|
793
|
+
return void 0;
|
|
794
|
+
}
|
|
795
|
+
if (prevIdRef.current !== sessionId) {
|
|
796
|
+
prevIdRef.current = sessionId;
|
|
797
|
+
setMessages([]);
|
|
798
|
+
setHistLoading(true);
|
|
799
|
+
setStaged([]);
|
|
800
|
+
setAttachErr("");
|
|
801
|
+
seededRef.current = false;
|
|
802
|
+
}
|
|
803
|
+
if (seed) api.current.onSeedConsumed?.();
|
|
804
|
+
let dead = false;
|
|
805
|
+
Promise.resolve(api.current.loadHistory(sessionId)).then((hist) => {
|
|
806
|
+
if (dead) return;
|
|
807
|
+
if (hist?.length) setMessages(hist);
|
|
808
|
+
setHistLoading(false);
|
|
809
|
+
if (seed && !seededRef.current && !hist?.length) {
|
|
810
|
+
seededRef.current = true;
|
|
811
|
+
setMessages([{ role: "user", text: seed }]);
|
|
812
|
+
deliver(seed);
|
|
813
|
+
}
|
|
814
|
+
}).catch(() => {
|
|
815
|
+
if (!dead) setHistLoading(false);
|
|
816
|
+
});
|
|
817
|
+
return () => {
|
|
818
|
+
dead = true;
|
|
819
|
+
};
|
|
820
|
+
}, [sessionId]);
|
|
821
|
+
useEffect3(() => {
|
|
822
|
+
if (!connecting) return void 0;
|
|
823
|
+
const iv = window.setInterval(() => {
|
|
824
|
+
const p = pendingRef.current;
|
|
825
|
+
if (p && !busy) deliver(p.text, p.files);
|
|
826
|
+
}, RETRY_MS);
|
|
827
|
+
return () => window.clearInterval(iv);
|
|
828
|
+
}, [connecting, busy, deliver]);
|
|
829
|
+
useEffect3(() => {
|
|
830
|
+
let dead = false;
|
|
831
|
+
let poll;
|
|
832
|
+
const reload = () => Promise.resolve(api.current.loadHistory(sessionId)).then((hist) => {
|
|
833
|
+
if (!dead && hist?.length && !busy && !pendingRef.current) setMessages(hist);
|
|
834
|
+
}).catch(() => {
|
|
835
|
+
});
|
|
836
|
+
if (externalBusy && messages.length === 0 && !busy) poll = window.setInterval(reload, POLL_MS);
|
|
837
|
+
if (prevExternalBusyRef.current && !externalBusy) {
|
|
838
|
+
reload();
|
|
839
|
+
api.current.onChanged?.();
|
|
840
|
+
}
|
|
841
|
+
prevExternalBusyRef.current = externalBusy;
|
|
842
|
+
return () => {
|
|
843
|
+
dead = true;
|
|
844
|
+
if (poll) window.clearInterval(poll);
|
|
845
|
+
};
|
|
846
|
+
}, [externalBusy, messages.length, busy, sessionId]);
|
|
847
|
+
function pick(list) {
|
|
848
|
+
if (!attachments?.prepare) return;
|
|
849
|
+
setAttachErr("");
|
|
850
|
+
for (const file of list) {
|
|
851
|
+
const entry = { name: file.name, size: file.size, pending: true };
|
|
852
|
+
setStaged((cur) => [...cur, entry]);
|
|
853
|
+
Promise.resolve(attachments.prepare(file)).then((ready) => {
|
|
854
|
+
setStaged((cur) => cur.map((s) => s === entry ? { name: entry.name, size: entry.size, ...ready } : s));
|
|
855
|
+
}).catch((e) => {
|
|
856
|
+
setStaged((cur) => cur.filter((s) => s !== entry));
|
|
857
|
+
setAttachErr(e?.message || `${file.name} could not be attached.`);
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
function toggleDictation() {
|
|
862
|
+
if (!dictation) return;
|
|
863
|
+
if (listening2) {
|
|
864
|
+
dictation.stop();
|
|
865
|
+
setListening(false);
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
setListening(true);
|
|
869
|
+
dictation.start({
|
|
870
|
+
onText: (text) => setDraft((cur) => cur ? `${cur.replace(/\s+$/, "")} ${text}` : text),
|
|
871
|
+
onEnd: () => setListening(false),
|
|
872
|
+
onError: () => setListening(false)
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
const rootCls = ["uic-chat", collapsed ? "is-collapsed" : "", classNames.root || ""].filter(Boolean).join(" ");
|
|
876
|
+
const toggle = onToggleCollapse ? /* @__PURE__ */ jsx6(
|
|
877
|
+
"button",
|
|
878
|
+
{
|
|
879
|
+
type: "button",
|
|
880
|
+
className: "uic-panel-toggle",
|
|
881
|
+
onClick: onToggleCollapse,
|
|
882
|
+
title: collapsed ? "Show the conversation" : "Hide the conversation",
|
|
883
|
+
"aria-label": collapsed ? "Show the conversation" : "Hide the conversation",
|
|
884
|
+
"aria-expanded": !collapsed,
|
|
885
|
+
children: /* @__PURE__ */ jsx6(IcPanelRight, {})
|
|
886
|
+
}
|
|
887
|
+
) : null;
|
|
888
|
+
if (collapsed) {
|
|
889
|
+
return /* @__PURE__ */ jsx6("aside", { className: rootCls, children: /* @__PURE__ */ jsx6("div", { className: "uic-chat-h", children: toggle }) });
|
|
890
|
+
}
|
|
891
|
+
const empty = messages.length === 0;
|
|
892
|
+
const attachControl = attachments ? /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
893
|
+
/* @__PURE__ */ jsx6(
|
|
894
|
+
"input",
|
|
895
|
+
{
|
|
896
|
+
ref: fileRef,
|
|
897
|
+
type: "file",
|
|
898
|
+
hidden: true,
|
|
899
|
+
accept: attachments.accept,
|
|
900
|
+
multiple: attachments.multiple !== false,
|
|
901
|
+
onChange: (e) => {
|
|
902
|
+
pick([...e.target.files]);
|
|
903
|
+
e.target.value = "";
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
),
|
|
907
|
+
/* @__PURE__ */ jsx6(
|
|
908
|
+
"button",
|
|
909
|
+
{
|
|
910
|
+
type: "button",
|
|
911
|
+
className: "uic-chat-icon",
|
|
912
|
+
"aria-label": "Attach a file",
|
|
913
|
+
disabled: busy,
|
|
914
|
+
onClick: () => fileRef.current?.click(),
|
|
915
|
+
children: /* @__PURE__ */ jsx6(IcPaperclip, {})
|
|
916
|
+
}
|
|
917
|
+
)
|
|
918
|
+
] }) : null;
|
|
919
|
+
const micControl = dictation ? /* @__PURE__ */ jsx6(
|
|
920
|
+
"button",
|
|
921
|
+
{
|
|
922
|
+
type: "button",
|
|
923
|
+
className: "uic-chat-icon" + (listening2 ? " is-on" : ""),
|
|
924
|
+
"aria-label": listening2 ? "Stop dictating" : "Dictate",
|
|
925
|
+
"aria-pressed": listening2,
|
|
926
|
+
disabled: busy,
|
|
927
|
+
onClick: toggleDictation,
|
|
928
|
+
children: /* @__PURE__ */ jsx6(IcMic, {})
|
|
929
|
+
}
|
|
930
|
+
) : null;
|
|
931
|
+
const defaultBusyState = /* @__PURE__ */ jsxs6("div", { className: "uic-chat-empty", children: [
|
|
932
|
+
/* @__PURE__ */ jsx6("span", { className: "uic-chat-pulse", "aria-hidden": "true" }),
|
|
933
|
+
/* @__PURE__ */ jsx6("div", { className: "uic-chat-empty-t", children: workingLabel })
|
|
934
|
+
] });
|
|
935
|
+
return /* @__PURE__ */ jsxs6("aside", { className: rootCls, style: width ? { flex: `0 0 ${width}px` } : void 0, children: [
|
|
936
|
+
/* @__PURE__ */ jsxs6("div", { className: "uic-chat-h", children: [
|
|
937
|
+
toggle,
|
|
938
|
+
title ? /* @__PURE__ */ jsx6("span", { className: "uic-chat-title", title, children: title }) : null,
|
|
939
|
+
headerRight,
|
|
940
|
+
connecting ? /* @__PURE__ */ jsx6("span", { className: "uic-chat-conn", children: connectingLabel }) : null
|
|
941
|
+
] }),
|
|
942
|
+
/* @__PURE__ */ jsxs6("div", { className: "uic-chat-body", ref: bodyRef, onScroll: onBodyScroll, role: "log", "aria-live": "polite", children: [
|
|
943
|
+
histLoading ? /* @__PURE__ */ jsx6(ChatMessagesSkeleton, {}) : empty && externalBusy ? busyState === void 0 ? defaultBusyState : busyState : empty ? emptyState : /* @__PURE__ */ jsx6(
|
|
944
|
+
ChatMessages,
|
|
945
|
+
{
|
|
946
|
+
messages,
|
|
947
|
+
renderMarkdown,
|
|
948
|
+
userExtras: (m, i) => {
|
|
949
|
+
const own = userExtras?.(m, i);
|
|
950
|
+
if (own !== void 0) return own;
|
|
951
|
+
if (!m.files?.length) return void 0;
|
|
952
|
+
return /* @__PURE__ */ jsx6("span", { className: "uic-chat-msg-files", children: m.files.map((n) => /* @__PURE__ */ jsx6(Chip, { icon: /* @__PURE__ */ jsx6(IcPaperclip, { size: 11 }), label: n, title: n }, n)) });
|
|
953
|
+
},
|
|
954
|
+
workingLabel,
|
|
955
|
+
toolLabels: { workingLabel, ...toolLabels || {} },
|
|
956
|
+
statusLabels
|
|
957
|
+
}
|
|
958
|
+
),
|
|
959
|
+
connecting ? /* @__PURE__ */ jsxs6("div", { className: "uic-chat-note", role: "status", children: [
|
|
960
|
+
/* @__PURE__ */ jsx6("span", { className: "uic-chat-dot", "aria-hidden": "true" }),
|
|
961
|
+
connectingNote
|
|
962
|
+
] }) : null
|
|
963
|
+
] }),
|
|
964
|
+
/* @__PURE__ */ jsx6(
|
|
965
|
+
Composer,
|
|
966
|
+
{
|
|
967
|
+
value: draft,
|
|
968
|
+
onChange: setDraft,
|
|
969
|
+
onSend: send,
|
|
970
|
+
disabled: histLoading,
|
|
971
|
+
sendDisabled: sendBlocked || !draft.trim(),
|
|
972
|
+
placeholder,
|
|
973
|
+
rows: 2,
|
|
974
|
+
autoGrow: false,
|
|
975
|
+
classNames: { root: "uic-chat-cmp", input: "uic-chat-cmp-input", row: "uic-chat-cmp-row" },
|
|
976
|
+
attachments: staged.length > 0 || attachErr ? /* @__PURE__ */ jsxs6("div", { className: "uic-chat-files", children: [
|
|
977
|
+
staged.map((f, i) => /* @__PURE__ */ jsx6(
|
|
978
|
+
Chip,
|
|
979
|
+
{
|
|
980
|
+
icon: /* @__PURE__ */ jsx6(IcPaperclip, { size: 11 }),
|
|
981
|
+
title: f.name,
|
|
982
|
+
label: /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
983
|
+
/* @__PURE__ */ jsx6("span", { className: "uic-chip-t", children: f.name }),
|
|
984
|
+
/* @__PURE__ */ jsx6("span", { className: "uic-chip-meta", children: f.pending ? "\u2026" : bytesLabel(f.size) })
|
|
985
|
+
] }),
|
|
986
|
+
onRemove: () => setStaged((c) => c.filter((_, j) => j !== i)),
|
|
987
|
+
removeLabel: `Remove ${f.name}`
|
|
988
|
+
},
|
|
989
|
+
`${f.name}-${i}`
|
|
990
|
+
)),
|
|
991
|
+
attachErr ? /* @__PURE__ */ jsx6("span", { className: "uic-chat-file-err", children: attachErr }) : null
|
|
992
|
+
] }) : null,
|
|
993
|
+
accessoriesLeft: attachControl,
|
|
994
|
+
accessoriesRight: micControl,
|
|
995
|
+
renderSend: () => /* @__PURE__ */ jsx6(
|
|
996
|
+
"button",
|
|
997
|
+
{
|
|
998
|
+
type: "button",
|
|
999
|
+
className: "uic-chat-send",
|
|
1000
|
+
onClick: send,
|
|
1001
|
+
disabled: sendBlocked || !draft.trim(),
|
|
1002
|
+
"aria-label": "Send message",
|
|
1003
|
+
children: /* @__PURE__ */ jsx6(IcSend, {})
|
|
1004
|
+
}
|
|
1005
|
+
)
|
|
1006
|
+
}
|
|
1007
|
+
)
|
|
1008
|
+
] });
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
// src/input/dictate.js
|
|
1012
|
+
var Impl = typeof window !== "undefined" ? window.SpeechRecognition || window.webkitSpeechRecognition : null;
|
|
1013
|
+
function createDictation({ lang } = {}) {
|
|
1014
|
+
if (!Impl) return null;
|
|
1015
|
+
let rec = null;
|
|
1016
|
+
return {
|
|
1017
|
+
/** onText fires once per finished phrase, so the draft grows as you speak rather than being
|
|
1018
|
+
* rewritten from scratch on every interim guess. */
|
|
1019
|
+
start({ onText, onEnd, onError }) {
|
|
1020
|
+
this.stop();
|
|
1021
|
+
rec = new Impl();
|
|
1022
|
+
rec.lang = lang || navigator.language || "en-US";
|
|
1023
|
+
rec.continuous = true;
|
|
1024
|
+
rec.interimResults = false;
|
|
1025
|
+
rec.onresult = (e) => {
|
|
1026
|
+
for (let i = e.resultIndex; i < e.results.length; i += 1) {
|
|
1027
|
+
if (!e.results[i].isFinal) continue;
|
|
1028
|
+
const text = String(e.results[i][0]?.transcript || "").trim();
|
|
1029
|
+
if (text) onText?.(text);
|
|
1030
|
+
}
|
|
1031
|
+
};
|
|
1032
|
+
rec.onerror = (e) => {
|
|
1033
|
+
rec = null;
|
|
1034
|
+
if (e.error === "no-speech" || e.error === "aborted") onEnd?.();
|
|
1035
|
+
else onError?.(e.error || "Dictation stopped.");
|
|
1036
|
+
};
|
|
1037
|
+
rec.onend = () => {
|
|
1038
|
+
rec = null;
|
|
1039
|
+
onEnd?.();
|
|
1040
|
+
};
|
|
1041
|
+
try {
|
|
1042
|
+
rec.start();
|
|
1043
|
+
} catch (e) {
|
|
1044
|
+
rec = null;
|
|
1045
|
+
onError?.(e?.message || "Dictation could not start.");
|
|
1046
|
+
}
|
|
1047
|
+
},
|
|
1048
|
+
stop() {
|
|
1049
|
+
if (!rec) return;
|
|
1050
|
+
const r = rec;
|
|
1051
|
+
rec = null;
|
|
1052
|
+
try {
|
|
1053
|
+
r.stop();
|
|
1054
|
+
} catch {
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
// src/components/CodeBlock.jsx
|
|
1061
|
+
import React7 from "react";
|
|
1062
|
+
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
593
1063
|
var _hljsPromise = null;
|
|
594
1064
|
function loadHljs() {
|
|
595
1065
|
if (!_hljsPromise) {
|
|
@@ -660,8 +1130,8 @@ function CodeBlock(props) {
|
|
|
660
1130
|
const { code, language, className } = props;
|
|
661
1131
|
const src = String(code || "");
|
|
662
1132
|
const lang = canonicalLang(language);
|
|
663
|
-
const [hl, setHl] =
|
|
664
|
-
|
|
1133
|
+
const [hl, setHl] = React7.useState(null);
|
|
1134
|
+
React7.useEffect(() => {
|
|
665
1135
|
if (!lang || !src) return void 0;
|
|
666
1136
|
let cancelled = false;
|
|
667
1137
|
const timer = setTimeout(() => {
|
|
@@ -681,15 +1151,15 @@ function CodeBlock(props) {
|
|
|
681
1151
|
}, [src, lang]);
|
|
682
1152
|
const html = hl && hl.src === src ? hl.html : null;
|
|
683
1153
|
const label = String(language || "").toLowerCase();
|
|
684
|
-
return /* @__PURE__ */
|
|
685
|
-
label ? /* @__PURE__ */
|
|
686
|
-
html != null ? /* @__PURE__ */
|
|
1154
|
+
return /* @__PURE__ */ jsxs7("pre", { className: "wbx-code" + (className ? " " + className : ""), children: [
|
|
1155
|
+
label ? /* @__PURE__ */ jsx7("span", { className: "wbx-code-lang", "aria-hidden": "true", children: label }) : null,
|
|
1156
|
+
html != null ? /* @__PURE__ */ jsx7("code", { className: "hljs language-" + label, dangerouslySetInnerHTML: { __html: html } }) : /* @__PURE__ */ jsx7("code", { className: label ? "language-" + label : void 0, children: src })
|
|
687
1157
|
] });
|
|
688
1158
|
}
|
|
689
1159
|
|
|
690
1160
|
// src/components/resizable.jsx
|
|
691
|
-
import
|
|
692
|
-
import { jsx as
|
|
1161
|
+
import React8, { useCallback as useCallback2, useRef as useRef3, useState as useState3 } from "react";
|
|
1162
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
693
1163
|
function useResizablePane(opts = {}) {
|
|
694
1164
|
const {
|
|
695
1165
|
initial = 380,
|
|
@@ -703,12 +1173,12 @@ function useResizablePane(opts = {}) {
|
|
|
703
1173
|
storageKey = null
|
|
704
1174
|
// persist the chosen width per user (localStorage)
|
|
705
1175
|
} = opts;
|
|
706
|
-
const clamp =
|
|
1176
|
+
const clamp = useCallback2((x) => {
|
|
707
1177
|
let hi = max ?? Infinity;
|
|
708
1178
|
if (maxFraction && typeof window !== "undefined") hi = Math.min(hi, Math.round(window.innerWidth * maxFraction));
|
|
709
1179
|
return Math.min(hi, Math.max(min, x));
|
|
710
1180
|
}, [min, max, maxFraction]);
|
|
711
|
-
const [width, setWidth] =
|
|
1181
|
+
const [width, setWidth] = useState3(() => {
|
|
712
1182
|
if (storageKey && typeof window !== "undefined") {
|
|
713
1183
|
try {
|
|
714
1184
|
const n = parseInt(window.localStorage.getItem(storageKey) || "", 10);
|
|
@@ -718,16 +1188,16 @@ function useResizablePane(opts = {}) {
|
|
|
718
1188
|
}
|
|
719
1189
|
return initial;
|
|
720
1190
|
});
|
|
721
|
-
const widthRef =
|
|
1191
|
+
const widthRef = useRef3(width);
|
|
722
1192
|
widthRef.current = width;
|
|
723
|
-
const persist =
|
|
1193
|
+
const persist = useCallback2((w) => {
|
|
724
1194
|
if (!storageKey) return;
|
|
725
1195
|
try {
|
|
726
1196
|
window.localStorage.setItem(storageKey, String(w));
|
|
727
1197
|
} catch {
|
|
728
1198
|
}
|
|
729
1199
|
}, [storageKey]);
|
|
730
|
-
const onMouseDown =
|
|
1200
|
+
const onMouseDown = useCallback2((e) => {
|
|
731
1201
|
e.preventDefault();
|
|
732
1202
|
const sx = e.clientX, base = widthRef.current, dir = fromRight ? -1 : 1;
|
|
733
1203
|
document.body.classList.add("uic-resizing");
|
|
@@ -743,7 +1213,7 @@ function useResizablePane(opts = {}) {
|
|
|
743
1213
|
window.addEventListener("mouseup", up);
|
|
744
1214
|
document.body.style.cursor = "col-resize";
|
|
745
1215
|
}, [clamp, fromRight, persist]);
|
|
746
|
-
const reset =
|
|
1216
|
+
const reset = useCallback2(() => {
|
|
747
1217
|
setWidth(initial);
|
|
748
1218
|
if (storageKey) {
|
|
749
1219
|
try {
|
|
@@ -756,7 +1226,7 @@ function useResizablePane(opts = {}) {
|
|
|
756
1226
|
}
|
|
757
1227
|
function PaneResizer(props) {
|
|
758
1228
|
const { pane, className, title = "Drag to resize (double-click to reset)" } = props;
|
|
759
|
-
return /* @__PURE__ */
|
|
1229
|
+
return /* @__PURE__ */ jsx8(
|
|
760
1230
|
"div",
|
|
761
1231
|
{
|
|
762
1232
|
className: className ?? "uic-vresize",
|
|
@@ -770,8 +1240,8 @@ function PaneResizer(props) {
|
|
|
770
1240
|
}
|
|
771
1241
|
|
|
772
1242
|
// src/components/TaskList.jsx
|
|
773
|
-
import { useCallback as
|
|
774
|
-
import { Fragment as
|
|
1243
|
+
import { useCallback as useCallback3, useEffect as useEffect4, useMemo, useRef as useRef4, useState as useState4 } from "react";
|
|
1244
|
+
import { Fragment as Fragment4, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
775
1245
|
var STATUS_GROUPS = {
|
|
776
1246
|
all: () => true,
|
|
777
1247
|
working: (s) => ["running", "starting", "queued", "in_progress"].includes(s),
|
|
@@ -809,17 +1279,17 @@ function TaskList({
|
|
|
809
1279
|
statusKey = "status",
|
|
810
1280
|
timeKey = "updated_at"
|
|
811
1281
|
}) {
|
|
812
|
-
const [head, setHead] =
|
|
813
|
-
const [tail, setTail] =
|
|
814
|
-
const [cursor, setCursor] =
|
|
815
|
-
const [loadingMore, setLoadingMore] =
|
|
816
|
-
const [q, setQ] =
|
|
817
|
-
const [statusFilter, setStatusFilter] =
|
|
818
|
-
const alive =
|
|
819
|
-
|
|
1282
|
+
const [head, setHead] = useState4(null);
|
|
1283
|
+
const [tail, setTail] = useState4([]);
|
|
1284
|
+
const [cursor, setCursor] = useState4("");
|
|
1285
|
+
const [loadingMore, setLoadingMore] = useState4(false);
|
|
1286
|
+
const [q, setQ] = useState4("");
|
|
1287
|
+
const [statusFilter, setStatusFilter] = useState4("all");
|
|
1288
|
+
const alive = useRef4(true);
|
|
1289
|
+
useEffect4(() => () => {
|
|
820
1290
|
alive.current = false;
|
|
821
1291
|
}, []);
|
|
822
|
-
|
|
1292
|
+
useEffect4(() => {
|
|
823
1293
|
let ok = true;
|
|
824
1294
|
Promise.resolve(fetchPage("")).then((r) => {
|
|
825
1295
|
if (!ok) return;
|
|
@@ -832,7 +1302,7 @@ function TaskList({
|
|
|
832
1302
|
ok = false;
|
|
833
1303
|
};
|
|
834
1304
|
}, [fetchPage, refreshNonce]);
|
|
835
|
-
const loadMore =
|
|
1305
|
+
const loadMore = useCallback3(() => {
|
|
836
1306
|
if (!cursor || loadingMore) return;
|
|
837
1307
|
setLoadingMore(true);
|
|
838
1308
|
Promise.resolve(fetchPage(cursor)).then((r) => {
|
|
@@ -862,14 +1332,14 @@ function TaskList({
|
|
|
862
1332
|
const el = e.currentTarget;
|
|
863
1333
|
if (el.scrollTop + el.clientHeight > el.scrollHeight - 140) loadMore();
|
|
864
1334
|
};
|
|
865
|
-
return /* @__PURE__ */
|
|
866
|
-
header ? /* @__PURE__ */
|
|
867
|
-
onNew ? /* @__PURE__ */
|
|
1335
|
+
return /* @__PURE__ */ jsxs8("div", { className: "rui-tasks", children: [
|
|
1336
|
+
header ? /* @__PURE__ */ jsx9("div", { className: "rui-tasks-header", children: header }) : null,
|
|
1337
|
+
onNew ? /* @__PURE__ */ jsxs8("button", { type: "button", className: "rui-tasks-new", onClick: onNew, children: [
|
|
868
1338
|
"+ ",
|
|
869
1339
|
newLabel
|
|
870
1340
|
] }) : null,
|
|
871
|
-
/* @__PURE__ */
|
|
872
|
-
/* @__PURE__ */
|
|
1341
|
+
/* @__PURE__ */ jsxs8("div", { className: "rui-tasks-filters", children: [
|
|
1342
|
+
/* @__PURE__ */ jsx9(
|
|
873
1343
|
"input",
|
|
874
1344
|
{
|
|
875
1345
|
className: "rui-tasks-search",
|
|
@@ -879,7 +1349,7 @@ function TaskList({
|
|
|
879
1349
|
"aria-label": "Filter tasks"
|
|
880
1350
|
}
|
|
881
1351
|
),
|
|
882
|
-
/* @__PURE__ */
|
|
1352
|
+
/* @__PURE__ */ jsxs8(
|
|
883
1353
|
"select",
|
|
884
1354
|
{
|
|
885
1355
|
className: "rui-tasks-status",
|
|
@@ -887,19 +1357,19 @@ function TaskList({
|
|
|
887
1357
|
onChange: (e) => setStatusFilter(e.target.value),
|
|
888
1358
|
"aria-label": "Filter by status",
|
|
889
1359
|
children: [
|
|
890
|
-
/* @__PURE__ */
|
|
891
|
-
/* @__PURE__ */
|
|
892
|
-
/* @__PURE__ */
|
|
893
|
-
/* @__PURE__ */
|
|
1360
|
+
/* @__PURE__ */ jsx9("option", { value: "all", children: "All" }),
|
|
1361
|
+
/* @__PURE__ */ jsx9("option", { value: "working", children: "Working" }),
|
|
1362
|
+
/* @__PURE__ */ jsx9("option", { value: "done", children: "Done" }),
|
|
1363
|
+
/* @__PURE__ */ jsx9("option", { value: "failed", children: "Failed" })
|
|
894
1364
|
]
|
|
895
1365
|
}
|
|
896
1366
|
)
|
|
897
1367
|
] }),
|
|
898
|
-
/* @__PURE__ */
|
|
899
|
-
head === null ? /* @__PURE__ */
|
|
1368
|
+
/* @__PURE__ */ jsxs8("div", { className: "rui-tasks-list", onScroll, children: [
|
|
1369
|
+
head === null ? /* @__PURE__ */ jsx9("div", { className: "rui-tasks-empty", children: "Loading\u2026" }) : shown.length === 0 ? /* @__PURE__ */ jsx9("div", { className: "rui-tasks-empty", children: items.length ? "No matching tasks" : emptyLabel }) : shown.map((it) => {
|
|
900
1370
|
const id = it?.[idKey];
|
|
901
1371
|
const group = taskStatusGroup(it?.[statusKey]);
|
|
902
|
-
return /* @__PURE__ */
|
|
1372
|
+
return /* @__PURE__ */ jsxs8(
|
|
903
1373
|
"div",
|
|
904
1374
|
{
|
|
905
1375
|
className: `rui-task${id === selected ? " is-selected" : ""}`,
|
|
@@ -910,15 +1380,15 @@ function TaskList({
|
|
|
910
1380
|
if (e.key === "Enter" || e.key === " ") onSelect?.(id);
|
|
911
1381
|
},
|
|
912
1382
|
children: [
|
|
913
|
-
/* @__PURE__ */
|
|
914
|
-
/* @__PURE__ */
|
|
915
|
-
/* @__PURE__ */
|
|
916
|
-
/* @__PURE__ */
|
|
917
|
-
/* @__PURE__ */
|
|
918
|
-
it?.[timeKey] ? /* @__PURE__ */
|
|
1383
|
+
/* @__PURE__ */ jsxs8("div", { className: "rui-task-main", children: [
|
|
1384
|
+
/* @__PURE__ */ jsx9("div", { className: "rui-task-title", children: it?.[titleKey] || "Untitled task" }),
|
|
1385
|
+
/* @__PURE__ */ jsx9("div", { className: "rui-task-meta", children: renderMeta ? renderMeta(it) : /* @__PURE__ */ jsxs8(Fragment4, { children: [
|
|
1386
|
+
/* @__PURE__ */ jsx9("span", { className: `rui-task-dot is-${group}` }),
|
|
1387
|
+
/* @__PURE__ */ jsx9("span", { className: "rui-task-status", children: it?.[statusKey] || "" }),
|
|
1388
|
+
it?.[timeKey] ? /* @__PURE__ */ jsx9("span", { className: "rui-task-time", children: relTime(it[timeKey]) }) : null
|
|
919
1389
|
] }) })
|
|
920
1390
|
] }),
|
|
921
|
-
onDelete ? /* @__PURE__ */
|
|
1391
|
+
onDelete ? /* @__PURE__ */ jsx9(
|
|
922
1392
|
"button",
|
|
923
1393
|
{
|
|
924
1394
|
type: "button",
|
|
@@ -936,7 +1406,7 @@ function TaskList({
|
|
|
936
1406
|
id
|
|
937
1407
|
);
|
|
938
1408
|
}),
|
|
939
|
-
loadingMore ? /* @__PURE__ */
|
|
1409
|
+
loadingMore ? /* @__PURE__ */ jsx9("div", { className: "rui-tasks-empty", children: "Loading more\u2026" }) : null
|
|
940
1410
|
] })
|
|
941
1411
|
] });
|
|
942
1412
|
}
|
|
@@ -944,16 +1414,55 @@ function TaskList({
|
|
|
944
1414
|
// src/components/Dialog.jsx
|
|
945
1415
|
import {
|
|
946
1416
|
createContext,
|
|
947
|
-
useCallback as
|
|
1417
|
+
useCallback as useCallback4,
|
|
948
1418
|
useContext,
|
|
949
|
-
useEffect as
|
|
1419
|
+
useEffect as useEffect6,
|
|
950
1420
|
useId,
|
|
951
1421
|
useMemo as useMemo2,
|
|
952
|
-
useRef as
|
|
953
|
-
useState as
|
|
1422
|
+
useRef as useRef5,
|
|
1423
|
+
useState as useState5
|
|
954
1424
|
} from "react";
|
|
955
1425
|
import { createPortal } from "react-dom";
|
|
956
|
-
|
|
1426
|
+
|
|
1427
|
+
// src/components/overlay.js
|
|
1428
|
+
import { useEffect as useEffect5 } from "react";
|
|
1429
|
+
var stack = [];
|
|
1430
|
+
var listening = false;
|
|
1431
|
+
function onKey(e) {
|
|
1432
|
+
if (e.key !== "Escape") return;
|
|
1433
|
+
const top = stack[stack.length - 1];
|
|
1434
|
+
if (!top) return;
|
|
1435
|
+
e.preventDefault();
|
|
1436
|
+
top.onEscape?.();
|
|
1437
|
+
}
|
|
1438
|
+
function listen() {
|
|
1439
|
+
if (listening || typeof document === "undefined") return;
|
|
1440
|
+
document.addEventListener("keydown", onKey);
|
|
1441
|
+
listening = true;
|
|
1442
|
+
}
|
|
1443
|
+
function unlisten() {
|
|
1444
|
+
if (!listening || stack.length) return;
|
|
1445
|
+
document.removeEventListener("keydown", onKey);
|
|
1446
|
+
listening = false;
|
|
1447
|
+
}
|
|
1448
|
+
function pushOverlay(entry) {
|
|
1449
|
+
stack.push(entry);
|
|
1450
|
+
listen();
|
|
1451
|
+
return () => {
|
|
1452
|
+
const i = stack.indexOf(entry);
|
|
1453
|
+
if (i >= 0) stack.splice(i, 1);
|
|
1454
|
+
unlisten();
|
|
1455
|
+
};
|
|
1456
|
+
}
|
|
1457
|
+
function useOverlayEscape(active, onEscape) {
|
|
1458
|
+
useEffect5(() => {
|
|
1459
|
+
if (!active) return void 0;
|
|
1460
|
+
return pushOverlay({ onEscape });
|
|
1461
|
+
}, [active, onEscape]);
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
// src/components/Dialog.jsx
|
|
1465
|
+
import { Fragment as Fragment5, jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
957
1466
|
var DialogCtx = createContext(null);
|
|
958
1467
|
var LABELS = {
|
|
959
1468
|
en: { confirm: "Confirm", cancel: "Cancel", ok: "OK", create: "Create", required: "Please enter a value" },
|
|
@@ -961,15 +1470,15 @@ var LABELS = {
|
|
|
961
1470
|
};
|
|
962
1471
|
var _idSeq = 0;
|
|
963
1472
|
function DialogHost({ children, locale = "en", labels }) {
|
|
964
|
-
const [
|
|
1473
|
+
const [stack2, setStack] = useState5([]);
|
|
965
1474
|
const t = useMemo2(
|
|
966
1475
|
() => ({ ...LABELS[locale] || LABELS.en, ...labels || {} }),
|
|
967
1476
|
[locale, labels]
|
|
968
1477
|
);
|
|
969
|
-
const open =
|
|
1478
|
+
const open = useCallback4((spec) => new Promise((resolve) => {
|
|
970
1479
|
setStack((s) => [...s, { id: `dlg_${++_idSeq}`, spec, resolve }]);
|
|
971
1480
|
}), []);
|
|
972
|
-
const close =
|
|
1481
|
+
const close = useCallback4((id, value) => {
|
|
973
1482
|
setStack((s) => {
|
|
974
1483
|
const target = s.find((d) => d.id === id);
|
|
975
1484
|
if (target) target.resolve(value);
|
|
@@ -983,10 +1492,10 @@ function DialogHost({ children, locale = "en", labels }) {
|
|
|
983
1492
|
create: (opts) => open({ kind: "create", ...opts }),
|
|
984
1493
|
labels: t
|
|
985
1494
|
}), [open, t]);
|
|
986
|
-
return /* @__PURE__ */
|
|
1495
|
+
return /* @__PURE__ */ jsxs9(DialogCtx.Provider, { value: ctx, children: [
|
|
987
1496
|
children,
|
|
988
|
-
|
|
989
|
-
/* @__PURE__ */
|
|
1497
|
+
stack2.length > 0 && typeof document !== "undefined" && createPortal(
|
|
1498
|
+
/* @__PURE__ */ jsx10("div", { className: "rui-dlg-root", role: "presentation", children: stack2.map((d, i) => /* @__PURE__ */ jsx10(DialogShell, { dialog: d, isTop: i === stack2.length - 1, onClose: close, t }, d.id)) }),
|
|
990
1499
|
document.body
|
|
991
1500
|
)
|
|
992
1501
|
] });
|
|
@@ -999,19 +1508,11 @@ function useDialog() {
|
|
|
999
1508
|
var cancelValue = (kind) => kind === "prompt" || kind === "create" ? null : false;
|
|
1000
1509
|
function DialogShell({ dialog, isTop, onClose, t }) {
|
|
1001
1510
|
const { id, spec } = dialog;
|
|
1002
|
-
const ref =
|
|
1511
|
+
const ref = useRef5(null);
|
|
1003
1512
|
const titleId = useId();
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
if (e.key !== "Escape") return;
|
|
1008
|
-
e.preventDefault();
|
|
1009
|
-
onClose(id, cancelValue(spec.kind));
|
|
1010
|
-
};
|
|
1011
|
-
document.addEventListener("keydown", onKey);
|
|
1012
|
-
return () => document.removeEventListener("keydown", onKey);
|
|
1013
|
-
}, [id, isTop, onClose, spec.kind]);
|
|
1014
|
-
useEffect4(() => {
|
|
1513
|
+
const escape = useCallback4(() => onClose(id, cancelValue(spec.kind)), [id, onClose, spec.kind]);
|
|
1514
|
+
useOverlayEscape(isTop, escape);
|
|
1515
|
+
useEffect6(() => {
|
|
1015
1516
|
if (!isTop || !ref.current) return;
|
|
1016
1517
|
const el = ref.current.querySelector("input, textarea") || ref.current.querySelector(".rui-dlg-primary") || ref.current.querySelector("button");
|
|
1017
1518
|
el?.focus();
|
|
@@ -1020,7 +1521,7 @@ function DialogShell({ dialog, isTop, onClose, t }) {
|
|
|
1020
1521
|
if (e.target === e.currentTarget && isTop) onClose(id, cancelValue(spec.kind));
|
|
1021
1522
|
};
|
|
1022
1523
|
const done = (v) => onClose(id, v);
|
|
1023
|
-
return /* @__PURE__ */
|
|
1524
|
+
return /* @__PURE__ */ jsx10("div", { className: "rui-dlg-backdrop", onClick: onBackdrop, children: /* @__PURE__ */ jsxs9(
|
|
1024
1525
|
"div",
|
|
1025
1526
|
{
|
|
1026
1527
|
ref,
|
|
@@ -1029,34 +1530,34 @@ function DialogShell({ dialog, isTop, onClose, t }) {
|
|
|
1029
1530
|
"aria-labelledby": spec.title ? titleId : void 0,
|
|
1030
1531
|
className: `rui-dlg-card${spec.kind === "create" ? " is-wide" : ""}`,
|
|
1031
1532
|
children: [
|
|
1032
|
-
spec.kind === "alert" && /* @__PURE__ */
|
|
1033
|
-
spec.kind === "confirm" && /* @__PURE__ */
|
|
1034
|
-
spec.kind === "prompt" && /* @__PURE__ */
|
|
1035
|
-
spec.kind === "create" && /* @__PURE__ */
|
|
1533
|
+
spec.kind === "alert" && /* @__PURE__ */ jsx10(AlertBody, { spec, onClose: done, t, titleId }),
|
|
1534
|
+
spec.kind === "confirm" && /* @__PURE__ */ jsx10(ConfirmBody, { spec, onClose: done, t, titleId }),
|
|
1535
|
+
spec.kind === "prompt" && /* @__PURE__ */ jsx10(PromptBody, { spec, onClose: done, t, titleId }),
|
|
1536
|
+
spec.kind === "create" && /* @__PURE__ */ jsx10(CreateBody, { spec, onClose: done, t, titleId })
|
|
1036
1537
|
]
|
|
1037
1538
|
}
|
|
1038
1539
|
) });
|
|
1039
1540
|
}
|
|
1040
1541
|
function Header({ title, variant, titleId }) {
|
|
1041
1542
|
if (!title) return null;
|
|
1042
|
-
return /* @__PURE__ */
|
|
1543
|
+
return /* @__PURE__ */ jsx10("div", { className: `rui-dlg-h${variant ? ` is-${variant}` : ""}`, children: /* @__PURE__ */ jsx10("div", { className: "rui-dlg-title", id: titleId, children: title }) });
|
|
1043
1544
|
}
|
|
1044
|
-
var Footer = ({ children }) => /* @__PURE__ */
|
|
1545
|
+
var Footer = ({ children }) => /* @__PURE__ */ jsx10("div", { className: "rui-dlg-f", children });
|
|
1045
1546
|
function AlertBody({ spec, onClose, t, titleId }) {
|
|
1046
|
-
return /* @__PURE__ */
|
|
1047
|
-
/* @__PURE__ */
|
|
1048
|
-
/* @__PURE__ */
|
|
1049
|
-
/* @__PURE__ */
|
|
1547
|
+
return /* @__PURE__ */ jsxs9(Fragment5, { children: [
|
|
1548
|
+
/* @__PURE__ */ jsx10(Header, { title: spec.title, variant: spec.variant, titleId }),
|
|
1549
|
+
/* @__PURE__ */ jsx10("div", { className: "rui-dlg-b", children: spec.message ? /* @__PURE__ */ jsx10("div", { className: "rui-dlg-msg", children: spec.message }) : null }),
|
|
1550
|
+
/* @__PURE__ */ jsx10(Footer, { children: /* @__PURE__ */ jsx10("button", { type: "button", className: "rui-dlg-btn rui-dlg-primary", onClick: () => onClose(true), children: spec.confirmLabel || t.ok }) })
|
|
1050
1551
|
] });
|
|
1051
1552
|
}
|
|
1052
1553
|
function ConfirmBody({ spec, onClose, t, titleId }) {
|
|
1053
1554
|
const destructive = !!spec.destructive;
|
|
1054
|
-
return /* @__PURE__ */
|
|
1055
|
-
/* @__PURE__ */
|
|
1056
|
-
/* @__PURE__ */
|
|
1057
|
-
/* @__PURE__ */
|
|
1058
|
-
/* @__PURE__ */
|
|
1059
|
-
/* @__PURE__ */
|
|
1555
|
+
return /* @__PURE__ */ jsxs9(Fragment5, { children: [
|
|
1556
|
+
/* @__PURE__ */ jsx10(Header, { title: spec.title, variant: destructive ? "destructive" : spec.variant, titleId }),
|
|
1557
|
+
/* @__PURE__ */ jsx10("div", { className: "rui-dlg-b", children: spec.message ? /* @__PURE__ */ jsx10("div", { className: "rui-dlg-msg", children: spec.message }) : null }),
|
|
1558
|
+
/* @__PURE__ */ jsxs9(Footer, { children: [
|
|
1559
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: "rui-dlg-btn rui-dlg-secondary", onClick: () => onClose(false), children: spec.cancelLabel || t.cancel }),
|
|
1560
|
+
/* @__PURE__ */ jsx10(
|
|
1060
1561
|
"button",
|
|
1061
1562
|
{
|
|
1062
1563
|
type: "button",
|
|
@@ -1069,8 +1570,8 @@ function ConfirmBody({ spec, onClose, t, titleId }) {
|
|
|
1069
1570
|
] });
|
|
1070
1571
|
}
|
|
1071
1572
|
function PromptBody({ spec, onClose, t, titleId }) {
|
|
1072
|
-
const [value, setValue] =
|
|
1073
|
-
const [err, setErr] =
|
|
1573
|
+
const [value, setValue] = useState5(spec.defaultValue ?? "");
|
|
1574
|
+
const [err, setErr] = useState5(null);
|
|
1074
1575
|
const inputId = useId();
|
|
1075
1576
|
const Field = spec.multiline ? "textarea" : "input";
|
|
1076
1577
|
const submit = () => {
|
|
@@ -1085,12 +1586,12 @@ function PromptBody({ spec, onClose, t, titleId }) {
|
|
|
1085
1586
|
}
|
|
1086
1587
|
onClose(String(value));
|
|
1087
1588
|
};
|
|
1088
|
-
return /* @__PURE__ */
|
|
1089
|
-
/* @__PURE__ */
|
|
1090
|
-
/* @__PURE__ */
|
|
1091
|
-
spec.message ? /* @__PURE__ */
|
|
1092
|
-
spec.label ? /* @__PURE__ */
|
|
1093
|
-
/* @__PURE__ */
|
|
1589
|
+
return /* @__PURE__ */ jsxs9(Fragment5, { children: [
|
|
1590
|
+
/* @__PURE__ */ jsx10(Header, { title: spec.title, variant: spec.variant, titleId }),
|
|
1591
|
+
/* @__PURE__ */ jsxs9("div", { className: "rui-dlg-b", children: [
|
|
1592
|
+
spec.message ? /* @__PURE__ */ jsx10("div", { className: "rui-dlg-msg", children: spec.message }) : null,
|
|
1593
|
+
spec.label ? /* @__PURE__ */ jsx10("label", { className: "rui-dlg-label", htmlFor: inputId, children: spec.label }) : null,
|
|
1594
|
+
/* @__PURE__ */ jsx10(
|
|
1094
1595
|
Field,
|
|
1095
1596
|
{
|
|
1096
1597
|
id: inputId,
|
|
@@ -1113,20 +1614,20 @@ function PromptBody({ spec, onClose, t, titleId }) {
|
|
|
1113
1614
|
spellCheck: "false"
|
|
1114
1615
|
}
|
|
1115
1616
|
),
|
|
1116
|
-
err ? /* @__PURE__ */
|
|
1117
|
-
!err && spec.help ? /* @__PURE__ */
|
|
1617
|
+
err ? /* @__PURE__ */ jsx10("div", { className: "rui-dlg-err", children: err }) : null,
|
|
1618
|
+
!err && spec.help ? /* @__PURE__ */ jsx10("div", { className: "rui-dlg-help", children: spec.help }) : null
|
|
1118
1619
|
] }),
|
|
1119
|
-
/* @__PURE__ */
|
|
1120
|
-
/* @__PURE__ */
|
|
1121
|
-
/* @__PURE__ */
|
|
1620
|
+
/* @__PURE__ */ jsxs9(Footer, { children: [
|
|
1621
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: "rui-dlg-btn rui-dlg-secondary", onClick: () => onClose(null), children: spec.cancelLabel || t.cancel }),
|
|
1622
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: "rui-dlg-btn rui-dlg-primary", onClick: submit, children: spec.confirmLabel || t.confirm })
|
|
1122
1623
|
] })
|
|
1123
1624
|
] });
|
|
1124
1625
|
}
|
|
1125
1626
|
function CreateBody({ spec, onClose, t, titleId }) {
|
|
1126
1627
|
const types = spec.types || [];
|
|
1127
|
-
const [kind, setKind] =
|
|
1128
|
-
const [value, setValue] =
|
|
1129
|
-
const [err, setErr] =
|
|
1628
|
+
const [kind, setKind] = useState5(spec.defaultKind || types[0]?.kind || "");
|
|
1629
|
+
const [value, setValue] = useState5(spec.defaultValue ?? "");
|
|
1630
|
+
const [err, setErr] = useState5(null);
|
|
1130
1631
|
const inputId = useId();
|
|
1131
1632
|
const sel = types.find((x) => x.kind === kind) || types[0] || {};
|
|
1132
1633
|
const submit = () => {
|
|
@@ -1136,24 +1637,24 @@ function CreateBody({ spec, onClose, t, titleId }) {
|
|
|
1136
1637
|
}
|
|
1137
1638
|
onClose({ kind, name: String(value).trim() });
|
|
1138
1639
|
};
|
|
1139
|
-
return /* @__PURE__ */
|
|
1140
|
-
/* @__PURE__ */
|
|
1141
|
-
/* @__PURE__ */
|
|
1142
|
-
types.length > 0 ? /* @__PURE__ */
|
|
1640
|
+
return /* @__PURE__ */ jsxs9(Fragment5, { children: [
|
|
1641
|
+
/* @__PURE__ */ jsx10(Header, { title: spec.title, titleId }),
|
|
1642
|
+
/* @__PURE__ */ jsxs9("div", { className: "rui-dlg-b", children: [
|
|
1643
|
+
types.length > 0 ? /* @__PURE__ */ jsx10("div", { className: "rui-dlg-typegrid", children: types.map((ty) => /* @__PURE__ */ jsxs9(
|
|
1143
1644
|
"button",
|
|
1144
1645
|
{
|
|
1145
1646
|
type: "button",
|
|
1146
1647
|
className: `rui-dlg-type${ty.kind === kind ? " is-on" : ""}`,
|
|
1147
1648
|
onClick: () => setKind(ty.kind),
|
|
1148
1649
|
children: [
|
|
1149
|
-
ty.icon ? /* @__PURE__ */
|
|
1150
|
-
/* @__PURE__ */
|
|
1650
|
+
ty.icon ? /* @__PURE__ */ jsx10("span", { className: "rui-dlg-type-ic", style: ty.color ? { color: ty.color, background: `${ty.color}1f` } : void 0, children: ty.icon }) : null,
|
|
1651
|
+
/* @__PURE__ */ jsx10("span", { className: "rui-dlg-type-lbl", children: ty.label })
|
|
1151
1652
|
]
|
|
1152
1653
|
},
|
|
1153
1654
|
ty.kind
|
|
1154
1655
|
)) }) : null,
|
|
1155
|
-
/* @__PURE__ */
|
|
1156
|
-
/* @__PURE__ */
|
|
1656
|
+
/* @__PURE__ */ jsx10("label", { className: "rui-dlg-label", htmlFor: inputId, children: spec.label || `${sel.label || "Item"} name` }),
|
|
1657
|
+
/* @__PURE__ */ jsx10(
|
|
1157
1658
|
"input",
|
|
1158
1659
|
{
|
|
1159
1660
|
id: inputId,
|
|
@@ -1174,11 +1675,11 @@ function CreateBody({ spec, onClose, t, titleId }) {
|
|
|
1174
1675
|
spellCheck: "false"
|
|
1175
1676
|
}
|
|
1176
1677
|
),
|
|
1177
|
-
err ? /* @__PURE__ */
|
|
1678
|
+
err ? /* @__PURE__ */ jsx10("div", { className: "rui-dlg-err", children: err }) : null
|
|
1178
1679
|
] }),
|
|
1179
|
-
/* @__PURE__ */
|
|
1180
|
-
/* @__PURE__ */
|
|
1181
|
-
/* @__PURE__ */
|
|
1680
|
+
/* @__PURE__ */ jsxs9(Footer, { children: [
|
|
1681
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: "rui-dlg-btn rui-dlg-secondary", onClick: () => onClose(null), children: spec.cancelLabel || t.cancel }),
|
|
1682
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: "rui-dlg-btn rui-dlg-primary", onClick: submit, children: spec.confirmLabel || t.create })
|
|
1182
1683
|
] })
|
|
1183
1684
|
] });
|
|
1184
1685
|
}
|
|
@@ -1332,18 +1833,18 @@ async function fetchBalance() {
|
|
|
1332
1833
|
}
|
|
1333
1834
|
|
|
1334
1835
|
// src/auth/AuthForm.jsx
|
|
1335
|
-
import { useState as
|
|
1836
|
+
import { useState as useState7 } from "react";
|
|
1336
1837
|
|
|
1337
1838
|
// src/auth/GoogleButton.jsx
|
|
1338
|
-
import { useEffect as
|
|
1339
|
-
import { Fragment as
|
|
1839
|
+
import { useEffect as useEffect7, useRef as useRef6, useState as useState6 } from "react";
|
|
1840
|
+
import { Fragment as Fragment6, jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1340
1841
|
var CLIENT_ID = "247853836408-ojk91u8901hdlbkevid4fohmrfdot17l.apps.googleusercontent.com";
|
|
1341
1842
|
function GoogleButton({ onCredential, onError }) {
|
|
1342
|
-
const ref =
|
|
1343
|
-
const [failed, setFailed] =
|
|
1344
|
-
const cb =
|
|
1843
|
+
const ref = useRef6(null);
|
|
1844
|
+
const [failed, setFailed] = useState6(false);
|
|
1845
|
+
const cb = useRef6({ onCredential, onError });
|
|
1345
1846
|
cb.current = { onCredential, onError };
|
|
1346
|
-
|
|
1847
|
+
useEffect7(() => {
|
|
1347
1848
|
if (!CLIENT_ID || !ref.current) return void 0;
|
|
1348
1849
|
const SRC = "https://accounts.google.com/gsi/client";
|
|
1349
1850
|
let done = false;
|
|
@@ -1394,24 +1895,24 @@ function GoogleButton({ onCredential, onError }) {
|
|
|
1394
1895
|
};
|
|
1395
1896
|
}, []);
|
|
1396
1897
|
if (!CLIENT_ID || failed) return null;
|
|
1397
|
-
return /* @__PURE__ */
|
|
1398
|
-
/* @__PURE__ */
|
|
1399
|
-
/* @__PURE__ */
|
|
1898
|
+
return /* @__PURE__ */ jsxs10(Fragment6, { children: [
|
|
1899
|
+
/* @__PURE__ */ jsx11("div", { className: "auth-or", children: /* @__PURE__ */ jsx11("span", { children: "or" }) }),
|
|
1900
|
+
/* @__PURE__ */ jsx11("div", { ref, className: "auth-gwrap" })
|
|
1400
1901
|
] });
|
|
1401
1902
|
}
|
|
1402
1903
|
var GOOGLE_ENABLED = !!CLIENT_ID;
|
|
1403
1904
|
|
|
1404
1905
|
// src/auth/AuthForm.jsx
|
|
1405
|
-
import { Fragment as
|
|
1906
|
+
import { Fragment as Fragment7, jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1406
1907
|
function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
|
|
1407
|
-
const [mode, setMode] =
|
|
1408
|
-
const [email, setEmail] =
|
|
1409
|
-
const [password, setPassword] =
|
|
1410
|
-
const [name, setName] =
|
|
1411
|
-
const [err, setErr] =
|
|
1412
|
-
const [busy, setBusy] =
|
|
1413
|
-
const [choices, setChoices] =
|
|
1414
|
-
const [resetSent, setResetSent] =
|
|
1908
|
+
const [mode, setMode] = useState7("signin");
|
|
1909
|
+
const [email, setEmail] = useState7("");
|
|
1910
|
+
const [password, setPassword] = useState7("");
|
|
1911
|
+
const [name, setName] = useState7("");
|
|
1912
|
+
const [err, setErr] = useState7("");
|
|
1913
|
+
const [busy, setBusy] = useState7(false);
|
|
1914
|
+
const [choices, setChoices] = useState7(null);
|
|
1915
|
+
const [resetSent, setResetSent] = useState7(false);
|
|
1415
1916
|
async function enter(orgId) {
|
|
1416
1917
|
const session = await switchOrg(orgId);
|
|
1417
1918
|
onDone(session);
|
|
@@ -1452,10 +1953,10 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
|
|
|
1452
1953
|
}
|
|
1453
1954
|
}
|
|
1454
1955
|
if (choices) {
|
|
1455
|
-
return /* @__PURE__ */
|
|
1456
|
-
/* @__PURE__ */
|
|
1457
|
-
/* @__PURE__ */
|
|
1458
|
-
/* @__PURE__ */
|
|
1956
|
+
return /* @__PURE__ */ jsxs11("div", { children: [
|
|
1957
|
+
/* @__PURE__ */ jsx12("div", { className: "logo", children: brand }),
|
|
1958
|
+
/* @__PURE__ */ jsx12("h1", { children: "Choose workspace" }),
|
|
1959
|
+
/* @__PURE__ */ jsx12("div", { className: "org-list", children: choices.map((o) => /* @__PURE__ */ jsx12(
|
|
1459
1960
|
"button",
|
|
1460
1961
|
{
|
|
1461
1962
|
type: "button",
|
|
@@ -1473,20 +1974,20 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
|
|
|
1473
1974
|
},
|
|
1474
1975
|
o.id
|
|
1475
1976
|
)) }),
|
|
1476
|
-
err && /* @__PURE__ */
|
|
1977
|
+
err && /* @__PURE__ */ jsx12("div", { className: "auth-err", children: err })
|
|
1477
1978
|
] });
|
|
1478
1979
|
}
|
|
1479
|
-
return /* @__PURE__ */
|
|
1480
|
-
/* @__PURE__ */
|
|
1481
|
-
/* @__PURE__ */
|
|
1482
|
-
/* @__PURE__ */
|
|
1483
|
-
mode === "forgot" ? resetSent ? /* @__PURE__ */
|
|
1484
|
-
/* @__PURE__ */
|
|
1980
|
+
return /* @__PURE__ */ jsxs11("form", { onSubmit: submit, children: [
|
|
1981
|
+
/* @__PURE__ */ jsx12("div", { className: "logo", children: brand }),
|
|
1982
|
+
/* @__PURE__ */ jsx12("h1", { children: mode === "register" ? "Create your account" : mode === "forgot" ? "Reset password" : "Sign in" }),
|
|
1983
|
+
/* @__PURE__ */ jsx12("p", { className: "sub", children: mode === "register" ? "Get started in seconds." : mode === "forgot" ? "We will email you a reset link." : subtitle || "Welcome back." }),
|
|
1984
|
+
mode === "forgot" ? resetSent ? /* @__PURE__ */ jsxs11(Fragment7, { children: [
|
|
1985
|
+
/* @__PURE__ */ jsxs11("div", { className: "auth-note", children: [
|
|
1485
1986
|
"If an account exists for ",
|
|
1486
|
-
/* @__PURE__ */
|
|
1987
|
+
/* @__PURE__ */ jsx12("b", { children: email.trim() }),
|
|
1487
1988
|
", a password reset link is on its way. It is valid for 1 hour."
|
|
1488
1989
|
] }),
|
|
1489
|
-
/* @__PURE__ */
|
|
1990
|
+
/* @__PURE__ */ jsx12(
|
|
1490
1991
|
"button",
|
|
1491
1992
|
{
|
|
1492
1993
|
type: "button",
|
|
@@ -1500,36 +2001,36 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
|
|
|
1500
2001
|
children: "Back to sign in"
|
|
1501
2002
|
}
|
|
1502
2003
|
)
|
|
1503
|
-
] }) : /* @__PURE__ */
|
|
1504
|
-
/* @__PURE__ */
|
|
1505
|
-
/* @__PURE__ */
|
|
1506
|
-
/* @__PURE__ */
|
|
2004
|
+
] }) : /* @__PURE__ */ jsxs11(Fragment7, { children: [
|
|
2005
|
+
/* @__PURE__ */ jsxs11("div", { className: "field", children: [
|
|
2006
|
+
/* @__PURE__ */ jsx12("label", { children: "Email" }),
|
|
2007
|
+
/* @__PURE__ */ jsx12("input", { className: "input", type: "email", value: email, onChange: (e) => setEmail(e.target.value), autoFocus: true, required: true, autoComplete: "email" })
|
|
1507
2008
|
] }),
|
|
1508
|
-
err && /* @__PURE__ */
|
|
1509
|
-
/* @__PURE__ */
|
|
1510
|
-
/* @__PURE__ */
|
|
2009
|
+
err && /* @__PURE__ */ jsx12("div", { className: "auth-err", children: err }),
|
|
2010
|
+
/* @__PURE__ */ jsx12("button", { type: "submit", className: "btn primary lg", style: { width: "100%", marginTop: 8 }, disabled: busy, children: busy ? "Please wait..." : "Send reset link" }),
|
|
2011
|
+
/* @__PURE__ */ jsx12("p", { className: "auth-switch", children: /* @__PURE__ */ jsx12("button", { type: "button", onClick: () => {
|
|
1511
2012
|
setErr("");
|
|
1512
2013
|
setMode("signin");
|
|
1513
2014
|
}, children: "Back to sign in" }) })
|
|
1514
|
-
] }) : /* @__PURE__ */
|
|
1515
|
-
mode === "register" && /* @__PURE__ */
|
|
1516
|
-
/* @__PURE__ */
|
|
1517
|
-
/* @__PURE__ */
|
|
2015
|
+
] }) : /* @__PURE__ */ jsxs11(Fragment7, { children: [
|
|
2016
|
+
mode === "register" && /* @__PURE__ */ jsxs11("div", { className: "field", children: [
|
|
2017
|
+
/* @__PURE__ */ jsx12("label", { children: "Name" }),
|
|
2018
|
+
/* @__PURE__ */ jsx12("input", { className: "input", value: name, onChange: (e) => setName(e.target.value), autoComplete: "name", placeholder: "Jane Doe" })
|
|
1518
2019
|
] }),
|
|
1519
|
-
/* @__PURE__ */
|
|
1520
|
-
/* @__PURE__ */
|
|
1521
|
-
/* @__PURE__ */
|
|
2020
|
+
/* @__PURE__ */ jsxs11("div", { className: "field", children: [
|
|
2021
|
+
/* @__PURE__ */ jsx12("label", { children: "Email" }),
|
|
2022
|
+
/* @__PURE__ */ jsx12("input", { className: "input", type: "email", value: email, onChange: (e) => setEmail(e.target.value), autoFocus: true, required: true, autoComplete: "email" })
|
|
1522
2023
|
] }),
|
|
1523
|
-
/* @__PURE__ */
|
|
1524
|
-
/* @__PURE__ */
|
|
1525
|
-
/* @__PURE__ */
|
|
1526
|
-
mode === "signin" && /* @__PURE__ */
|
|
2024
|
+
/* @__PURE__ */ jsxs11("div", { className: "field", children: [
|
|
2025
|
+
/* @__PURE__ */ jsxs11("div", { className: "field-row", children: [
|
|
2026
|
+
/* @__PURE__ */ jsx12("label", { children: "Password" }),
|
|
2027
|
+
mode === "signin" && /* @__PURE__ */ jsx12("button", { type: "button", className: "link-sm", onClick: () => {
|
|
1527
2028
|
setErr("");
|
|
1528
2029
|
setResetSent(false);
|
|
1529
2030
|
setMode("forgot");
|
|
1530
2031
|
}, children: "Forgot password?" })
|
|
1531
2032
|
] }),
|
|
1532
|
-
/* @__PURE__ */
|
|
2033
|
+
/* @__PURE__ */ jsx12(
|
|
1533
2034
|
"input",
|
|
1534
2035
|
{
|
|
1535
2036
|
className: "input",
|
|
@@ -1542,13 +2043,13 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
|
|
|
1542
2043
|
}
|
|
1543
2044
|
)
|
|
1544
2045
|
] }),
|
|
1545
|
-
err && /* @__PURE__ */
|
|
1546
|
-
/* @__PURE__ */
|
|
1547
|
-
GOOGLE_ENABLED && /* @__PURE__ */
|
|
1548
|
-
/* @__PURE__ */
|
|
2046
|
+
err && /* @__PURE__ */ jsx12("div", { className: "auth-err", children: err }),
|
|
2047
|
+
/* @__PURE__ */ jsx12("button", { type: "submit", className: "btn primary lg", style: { width: "100%", marginTop: 8 }, disabled: busy, children: busy ? "Please wait..." : mode === "register" ? "Create account" : "Sign in" }),
|
|
2048
|
+
GOOGLE_ENABLED && /* @__PURE__ */ jsx12(GoogleButton, { onCredential: onGoogle, onError: setErr }),
|
|
2049
|
+
/* @__PURE__ */ jsxs11("p", { className: "auth-switch", children: [
|
|
1549
2050
|
mode === "register" ? "Already have an account?" : `New to ${productName || "the product"}?`,
|
|
1550
2051
|
" ",
|
|
1551
|
-
/* @__PURE__ */
|
|
2052
|
+
/* @__PURE__ */ jsx12("button", { type: "button", onClick: () => {
|
|
1552
2053
|
setErr("");
|
|
1553
2054
|
setMode(mode === "register" ? "signin" : "register");
|
|
1554
2055
|
}, children: mode === "register" ? "Sign in" : "Create one" })
|
|
@@ -1558,9 +2059,9 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
|
|
|
1558
2059
|
}
|
|
1559
2060
|
|
|
1560
2061
|
// src/sheet/SheetGrid.jsx
|
|
1561
|
-
import { useEffect as
|
|
2062
|
+
import { useEffect as useEffect8, useRef as useRef7, useState as useState8 } from "react";
|
|
1562
2063
|
import { createPortal as createPortal2 } from "react-dom";
|
|
1563
|
-
import { Fragment as
|
|
2064
|
+
import { Fragment as Fragment8, jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1564
2065
|
var cellKey = (rowId, colId) => `${rowId}:${colId}`;
|
|
1565
2066
|
var uid = (p) => `${p}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1566
2067
|
var DEFAULT_COLUMN_TYPES = [
|
|
@@ -1589,8 +2090,8 @@ var COMPUTE_KINDS = [
|
|
|
1589
2090
|
var RESOURCE_KINDS = ["image", "sheet", "slides", "workflow", "graph"];
|
|
1590
2091
|
var RESOURCE_ICON = { image: "\u{1F5BC}", sheet: "\u25A6", slides: "\u25A4", workflow: "\u2699", graph: "\u25C9" };
|
|
1591
2092
|
function PopPortal({ anchor, width = 250, estHeight = 300, className, children, onClose }) {
|
|
1592
|
-
const boxRef =
|
|
1593
|
-
|
|
2093
|
+
const boxRef = useRef7(null);
|
|
2094
|
+
useEffect8(() => {
|
|
1594
2095
|
if (!onClose) return void 0;
|
|
1595
2096
|
const close = () => onClose();
|
|
1596
2097
|
const onDown = (e) => {
|
|
@@ -1612,7 +2113,7 @@ function PopPortal({ anchor, width = 250, estHeight = 300, className, children,
|
|
|
1612
2113
|
let top = anchor.bottom + 6;
|
|
1613
2114
|
if (top + estHeight > window.innerHeight - 8) top = Math.max(8, anchor.top - estHeight - 6);
|
|
1614
2115
|
return createPortal2(
|
|
1615
|
-
/* @__PURE__ */
|
|
2116
|
+
/* @__PURE__ */ jsx13("div", { ref: boxRef, className, style: { position: "fixed", top, left, width, zIndex: 1e3 }, children }),
|
|
1616
2117
|
document.body
|
|
1617
2118
|
);
|
|
1618
2119
|
}
|
|
@@ -1632,8 +2133,8 @@ function pillColor(label, options) {
|
|
|
1632
2133
|
return PILL_FALLBACKS[h % PILL_FALLBACKS.length];
|
|
1633
2134
|
}
|
|
1634
2135
|
function RefImage({ refVal, fetchBlobUrl }) {
|
|
1635
|
-
const [src, setSrc] =
|
|
1636
|
-
|
|
2136
|
+
const [src, setSrc] = useState8(/^https?:\/\//i.test(refVal.url || "") ? refVal.url : null);
|
|
2137
|
+
useEffect8(() => {
|
|
1637
2138
|
let dead = false;
|
|
1638
2139
|
let obj = null;
|
|
1639
2140
|
if (!src && refVal.url && fetchBlobUrl) {
|
|
@@ -1649,16 +2150,16 @@ function RefImage({ refVal, fetchBlobUrl }) {
|
|
|
1649
2150
|
if (obj) URL.revokeObjectURL(obj);
|
|
1650
2151
|
};
|
|
1651
2152
|
}, [refVal.url]);
|
|
1652
|
-
if (!src) return /* @__PURE__ */
|
|
2153
|
+
if (!src) return /* @__PURE__ */ jsxs12("span", { className: "shg-refchip", children: [
|
|
1653
2154
|
RESOURCE_ICON.image,
|
|
1654
2155
|
" ",
|
|
1655
2156
|
refVal.name || "image"
|
|
1656
2157
|
] });
|
|
1657
|
-
return /* @__PURE__ */
|
|
2158
|
+
return /* @__PURE__ */ jsx13("img", { className: "shg-refimg", src, alt: refVal.name || "", title: refVal.name || "" });
|
|
1658
2159
|
}
|
|
1659
2160
|
function ResourceChip({ refVal, onOpen }) {
|
|
1660
2161
|
const icon = RESOURCE_ICON[refVal.kind] || "\u25C7";
|
|
1661
|
-
return /* @__PURE__ */
|
|
2162
|
+
return /* @__PURE__ */ jsxs12(
|
|
1662
2163
|
"button",
|
|
1663
2164
|
{
|
|
1664
2165
|
className: "shg-refchip shg-refchip-btn",
|
|
@@ -1668,40 +2169,40 @@ function ResourceChip({ refVal, onOpen }) {
|
|
|
1668
2169
|
onOpen && onOpen(refVal);
|
|
1669
2170
|
},
|
|
1670
2171
|
children: [
|
|
1671
|
-
/* @__PURE__ */
|
|
1672
|
-
/* @__PURE__ */
|
|
2172
|
+
/* @__PURE__ */ jsx13("span", { className: "shg-refchip-ic", children: icon }),
|
|
2173
|
+
/* @__PURE__ */ jsx13("span", { className: "shg-refchip-name", children: refVal.name || refVal.id || refVal.kind })
|
|
1673
2174
|
]
|
|
1674
2175
|
}
|
|
1675
2176
|
);
|
|
1676
2177
|
}
|
|
1677
2178
|
function StatusDot({ status }) {
|
|
1678
2179
|
if (!status || status === "empty") return null;
|
|
1679
|
-
return /* @__PURE__ */
|
|
2180
|
+
return /* @__PURE__ */ jsx13("span", { className: `shg-dot shg-dot-${status}`, title: status });
|
|
1680
2181
|
}
|
|
1681
2182
|
function CellValue({ cell, col, fetchBlobUrl, onOpenResource }) {
|
|
1682
2183
|
const v = cell?.value;
|
|
1683
|
-
if (v === void 0 || v === null || v === "") return /* @__PURE__ */
|
|
2184
|
+
if (v === void 0 || v === null || v === "") return /* @__PURE__ */ jsx13("span", { className: "shg-val-txt" });
|
|
1684
2185
|
if (v && typeof v === "object" && !Array.isArray(v) && v.kind) {
|
|
1685
|
-
if (v.kind === "image") return /* @__PURE__ */
|
|
1686
|
-
return /* @__PURE__ */
|
|
2186
|
+
if (v.kind === "image") return /* @__PURE__ */ jsx13(RefImage, { refVal: v, fetchBlobUrl });
|
|
2187
|
+
return /* @__PURE__ */ jsx13(ResourceChip, { refVal: v, onOpen: onOpenResource });
|
|
1687
2188
|
}
|
|
1688
2189
|
switch (col.type) {
|
|
1689
2190
|
case "select":
|
|
1690
|
-
return /* @__PURE__ */
|
|
2191
|
+
return /* @__PURE__ */ jsx13("span", { className: "shg-pill", style: { background: pillColor(String(v), col.options) }, children: String(v) });
|
|
1691
2192
|
case "tags": {
|
|
1692
2193
|
const tags = Array.isArray(v) ? v : String(v).split(",").map((s) => s.trim()).filter(Boolean);
|
|
1693
|
-
return /* @__PURE__ */
|
|
2194
|
+
return /* @__PURE__ */ jsx13("span", { className: "shg-pills", children: tags.map((t) => /* @__PURE__ */ jsx13("span", { className: "shg-pill", style: { background: pillColor(t, col.options) }, children: t }, t)) });
|
|
1694
2195
|
}
|
|
1695
2196
|
case "checkbox":
|
|
1696
|
-
return /* @__PURE__ */
|
|
2197
|
+
return /* @__PURE__ */ jsx13("span", { className: "shg-check" + (v ? " on" : ""), children: v ? "\u2713" : "" });
|
|
1697
2198
|
case "url": {
|
|
1698
2199
|
const href = /^https?:\/\//i.test(String(v)) ? String(v) : `https://${v}`;
|
|
1699
|
-
return /* @__PURE__ */
|
|
2200
|
+
return /* @__PURE__ */ jsx13("a", { className: "shg-link", href, target: "_blank", rel: "noreferrer", onClick: (e) => e.stopPropagation(), children: String(v) });
|
|
1700
2201
|
}
|
|
1701
2202
|
case "number":
|
|
1702
|
-
return /* @__PURE__ */
|
|
2203
|
+
return /* @__PURE__ */ jsx13("span", { className: "shg-val-txt shg-num", children: String(v) });
|
|
1703
2204
|
default:
|
|
1704
|
-
return /* @__PURE__ */
|
|
2205
|
+
return /* @__PURE__ */ jsx13("span", { className: "shg-val-txt", children: typeof v === "object" ? JSON.stringify(v) : String(v) });
|
|
1705
2206
|
}
|
|
1706
2207
|
}
|
|
1707
2208
|
function SheetGrid({
|
|
@@ -1721,14 +2222,14 @@ function SheetGrid({
|
|
|
1721
2222
|
const columns = sheet?.columns || [];
|
|
1722
2223
|
const rows = sheet?.rows || [];
|
|
1723
2224
|
const cells = sheet?.cells || {};
|
|
1724
|
-
const [editing, setEditing] =
|
|
1725
|
-
const [draft, setDraft] =
|
|
1726
|
-
const [menuCol, setMenuCol] =
|
|
1727
|
-
const [sizeDraft, setSizeDraft] =
|
|
1728
|
-
const [dnd, setDnd] =
|
|
1729
|
-
const [dropAt, setDropAt] =
|
|
1730
|
-
const inputRef =
|
|
1731
|
-
const dragRef =
|
|
2225
|
+
const [editing, setEditing] = useState8(null);
|
|
2226
|
+
const [draft, setDraft] = useState8("");
|
|
2227
|
+
const [menuCol, setMenuCol] = useState8(null);
|
|
2228
|
+
const [sizeDraft, setSizeDraft] = useState8({});
|
|
2229
|
+
const [dnd, setDnd] = useState8(null);
|
|
2230
|
+
const [dropAt, setDropAt] = useState8(null);
|
|
2231
|
+
const inputRef = useRef7(null);
|
|
2232
|
+
const dragRef = useRef7(null);
|
|
1732
2233
|
const descOf = (type) => columnTypes.find((t) => t.type === type) || { type, label: type };
|
|
1733
2234
|
const isComputed = (col) => !!descOf(col?.type).computed;
|
|
1734
2235
|
const isEditable = (col) => {
|
|
@@ -1829,7 +2330,7 @@ function SheetGrid({
|
|
|
1829
2330
|
const numW = Math.max(40, 24 + String(rows.length || 1).length * 9);
|
|
1830
2331
|
const numStyle = { width: numW, minWidth: numW, maxWidth: numW };
|
|
1831
2332
|
const rowHeight = (row) => sizeDraft.row && sizeDraft.row[row.id] || row.height || void 0;
|
|
1832
|
-
|
|
2333
|
+
useEffect8(() => {
|
|
1833
2334
|
if (editing && inputRef.current) inputRef.current.focus();
|
|
1834
2335
|
}, [editing]);
|
|
1835
2336
|
const mutate = (fn) => {
|
|
@@ -1901,7 +2402,7 @@ function SheetGrid({
|
|
|
1901
2402
|
if (col.type === "resource") {
|
|
1902
2403
|
const d = typeof draft === "object" && draft ? draft : { kind: "sheet" };
|
|
1903
2404
|
const set = (k, v) => setDraft({ ...d, [k]: v });
|
|
1904
|
-
return /* @__PURE__ */
|
|
2405
|
+
return /* @__PURE__ */ jsx13(
|
|
1905
2406
|
PopPortal,
|
|
1906
2407
|
{
|
|
1907
2408
|
anchor: editing.rect,
|
|
@@ -1909,17 +2410,17 @@ function SheetGrid({
|
|
|
1909
2410
|
estHeight: 230,
|
|
1910
2411
|
className: "shg-select-pop shg-ref-pop",
|
|
1911
2412
|
onClose: () => setEditing(null),
|
|
1912
|
-
children: /* @__PURE__ */
|
|
1913
|
-
/* @__PURE__ */
|
|
1914
|
-
/* @__PURE__ */
|
|
1915
|
-
/* @__PURE__ */
|
|
1916
|
-
/* @__PURE__ */
|
|
1917
|
-
/* @__PURE__ */
|
|
1918
|
-
/* @__PURE__ */
|
|
2413
|
+
children: /* @__PURE__ */ jsxs12("div", { onClick: (e) => e.stopPropagation(), children: [
|
|
2414
|
+
/* @__PURE__ */ jsx13("select", { className: "shg-menu-input", value: d.kind || "sheet", onChange: (e) => set("kind", e.target.value), children: RESOURCE_KINDS.map((k) => /* @__PURE__ */ jsx13("option", { value: k, children: k }, k)) }),
|
|
2415
|
+
/* @__PURE__ */ jsx13("input", { className: "shg-menu-input", placeholder: "Name", value: d.name || "", onChange: (e) => set("name", e.target.value) }),
|
|
2416
|
+
/* @__PURE__ */ jsx13("input", { className: "shg-menu-input", placeholder: "Resource id (e.g. sheet.\u2026)", value: d.id || "", onChange: (e) => set("id", e.target.value) }),
|
|
2417
|
+
/* @__PURE__ */ jsx13("input", { className: "shg-menu-input", placeholder: "or URL", value: d.url || "", onChange: (e) => set("url", e.target.value) }),
|
|
2418
|
+
/* @__PURE__ */ jsxs12("div", { className: "shg-menu-actions", children: [
|
|
2419
|
+
/* @__PURE__ */ jsx13("button", { className: "shg-pop-clear", onClick: () => {
|
|
1919
2420
|
setCell(editing.rowId, editing.colId, null);
|
|
1920
2421
|
setEditing(null);
|
|
1921
2422
|
}, children: "Clear" }),
|
|
1922
|
-
/* @__PURE__ */
|
|
2423
|
+
/* @__PURE__ */ jsx13("button", { className: "shg-menu-apply", onClick: () => {
|
|
1923
2424
|
setCell(editing.rowId, editing.colId, d);
|
|
1924
2425
|
setEditing(null);
|
|
1925
2426
|
}, children: "Set" })
|
|
@@ -1930,7 +2431,7 @@ function SheetGrid({
|
|
|
1930
2431
|
}
|
|
1931
2432
|
if (col.type === "select") {
|
|
1932
2433
|
const opts = normOptions(col.options);
|
|
1933
|
-
return /* @__PURE__ */
|
|
2434
|
+
return /* @__PURE__ */ jsxs12(
|
|
1934
2435
|
PopPortal,
|
|
1935
2436
|
{
|
|
1936
2437
|
anchor: editing.rect,
|
|
@@ -1939,8 +2440,8 @@ function SheetGrid({
|
|
|
1939
2440
|
className: "shg-select-pop",
|
|
1940
2441
|
onClose: () => setEditing(null),
|
|
1941
2442
|
children: [
|
|
1942
|
-
opts.length === 0 && /* @__PURE__ */
|
|
1943
|
-
opts.map((o) => /* @__PURE__ */
|
|
2443
|
+
opts.length === 0 && /* @__PURE__ */ jsx13("div", { className: "shg-pop-note", children: "No options yet \u2014 add them in the column menu." }),
|
|
2444
|
+
opts.map((o) => /* @__PURE__ */ jsx13(
|
|
1944
2445
|
"button",
|
|
1945
2446
|
{
|
|
1946
2447
|
className: "shg-pill shg-pill-btn",
|
|
@@ -1954,7 +2455,7 @@ function SheetGrid({
|
|
|
1954
2455
|
},
|
|
1955
2456
|
o.label
|
|
1956
2457
|
)),
|
|
1957
|
-
/* @__PURE__ */
|
|
2458
|
+
/* @__PURE__ */ jsx13(
|
|
1958
2459
|
"button",
|
|
1959
2460
|
{
|
|
1960
2461
|
className: "shg-pop-clear",
|
|
@@ -1971,7 +2472,7 @@ function SheetGrid({
|
|
|
1971
2472
|
);
|
|
1972
2473
|
}
|
|
1973
2474
|
const inputType = col.type === "date" ? "date" : col.type === "number" ? "number" : "text";
|
|
1974
|
-
return /* @__PURE__ */
|
|
2475
|
+
return /* @__PURE__ */ jsx13(
|
|
1975
2476
|
"input",
|
|
1976
2477
|
{
|
|
1977
2478
|
ref: inputRef,
|
|
@@ -1988,18 +2489,18 @@ function SheetGrid({
|
|
|
1988
2489
|
}
|
|
1989
2490
|
);
|
|
1990
2491
|
};
|
|
1991
|
-
return /* @__PURE__ */
|
|
1992
|
-
/* @__PURE__ */
|
|
1993
|
-
/* @__PURE__ */
|
|
1994
|
-
columns.map((col) => /* @__PURE__ */
|
|
2492
|
+
return /* @__PURE__ */ jsx13("div", { className: "shg", children: /* @__PURE__ */ jsx13("div", { className: "shg-scroll", children: /* @__PURE__ */ jsxs12("table", { className: "shg-table", children: [
|
|
2493
|
+
/* @__PURE__ */ jsx13("thead", { children: /* @__PURE__ */ jsxs12("tr", { children: [
|
|
2494
|
+
/* @__PURE__ */ jsx13("th", { className: "shg-corner", style: numStyle }),
|
|
2495
|
+
columns.map((col) => /* @__PURE__ */ jsxs12(
|
|
1995
2496
|
"th",
|
|
1996
2497
|
{
|
|
1997
2498
|
className: "shg-col" + (isComputed(col) ? " shg-col-compute" : "") + dndClass("col", col.id),
|
|
1998
2499
|
style: colWidth(col) ? { width: colWidth(col), minWidth: colWidth(col), maxWidth: colWidth(col) } : void 0,
|
|
1999
2500
|
...dndProps("col", col.id),
|
|
2000
2501
|
children: [
|
|
2001
|
-
!readOnly && /* @__PURE__ */
|
|
2002
|
-
/* @__PURE__ */
|
|
2502
|
+
!readOnly && /* @__PURE__ */ jsx13("span", { className: "shg-resize-col", onMouseDown: (e) => startResize(e, "col", col.id, colWidth(col) || e.currentTarget.closest("th").offsetWidth) }),
|
|
2503
|
+
/* @__PURE__ */ jsx13("div", { className: "shg-col-h", children: /* @__PURE__ */ jsx13(
|
|
2003
2504
|
ColumnHeader,
|
|
2004
2505
|
{
|
|
2005
2506
|
col,
|
|
@@ -2025,10 +2526,10 @@ function SheetGrid({
|
|
|
2025
2526
|
},
|
|
2026
2527
|
col.id
|
|
2027
2528
|
)),
|
|
2028
|
-
!readOnly && /* @__PURE__ */
|
|
2529
|
+
!readOnly && /* @__PURE__ */ jsx13("th", { className: "shg-add-col", children: /* @__PURE__ */ jsx13("button", { className: "shg-add", onClick: addColumn, title: "Add column", children: "+" }) })
|
|
2029
2530
|
] }) }),
|
|
2030
|
-
/* @__PURE__ */
|
|
2031
|
-
rows.map((row, ri) => /* @__PURE__ */
|
|
2531
|
+
/* @__PURE__ */ jsxs12("tbody", { children: [
|
|
2532
|
+
rows.map((row, ri) => /* @__PURE__ */ jsxs12(
|
|
2032
2533
|
"tr",
|
|
2033
2534
|
{
|
|
2034
2535
|
style: {
|
|
@@ -2036,7 +2537,7 @@ function SheetGrid({
|
|
|
2036
2537
|
"--shg-clamp": Math.max(1, Math.floor(((rowHeight(row) || 34) - 10) / 18))
|
|
2037
2538
|
},
|
|
2038
2539
|
children: [
|
|
2039
|
-
/* @__PURE__ */
|
|
2540
|
+
/* @__PURE__ */ jsxs12(
|
|
2040
2541
|
"td",
|
|
2041
2542
|
{
|
|
2042
2543
|
className: "shg-rownum" + dndClass("row", row.id),
|
|
@@ -2044,9 +2545,9 @@ function SheetGrid({
|
|
|
2044
2545
|
title: "Drag to reorder",
|
|
2045
2546
|
...dndProps("row", row.id),
|
|
2046
2547
|
children: [
|
|
2047
|
-
/* @__PURE__ */
|
|
2048
|
-
!readOnly && /* @__PURE__ */
|
|
2049
|
-
!readOnly && /* @__PURE__ */
|
|
2548
|
+
/* @__PURE__ */ jsx13("span", { children: ri + 1 }),
|
|
2549
|
+
!readOnly && /* @__PURE__ */ jsx13("button", { className: "shg-rowdel", onClick: () => deleteRow(row.id), title: "Delete row", children: "\xD7" }),
|
|
2550
|
+
!readOnly && /* @__PURE__ */ jsx13("span", { className: "shg-resize-row", onMouseDown: (e) => startResize(e, "row", row.id, rowHeight(row) || e.currentTarget.closest("tr").offsetHeight) })
|
|
2050
2551
|
]
|
|
2051
2552
|
}
|
|
2052
2553
|
),
|
|
@@ -2069,7 +2570,7 @@ function SheetGrid({
|
|
|
2069
2570
|
setCell: (v) => setCell(row.id, col.id, v),
|
|
2070
2571
|
runCell: onRunCell && !readOnly ? () => onRunCell(row.id, col.id) : null
|
|
2071
2572
|
});
|
|
2072
|
-
return /* @__PURE__ */
|
|
2573
|
+
return /* @__PURE__ */ jsxs12(
|
|
2073
2574
|
"td",
|
|
2074
2575
|
{
|
|
2075
2576
|
className: "shg-cell" + (computed ? " shg-cell-compute" : "") + (c.status && computed ? ` shg-cell-${c.status}` : "") + (peer ? " shg-cell-peer" : ""),
|
|
@@ -2079,16 +2580,16 @@ function SheetGrid({
|
|
|
2079
2580
|
},
|
|
2080
2581
|
title: c.error || "",
|
|
2081
2582
|
children: [
|
|
2082
|
-
peer && /* @__PURE__ */
|
|
2083
|
-
isEditing ? renderEditor(col) : /* @__PURE__ */
|
|
2583
|
+
peer && /* @__PURE__ */ jsx13("span", { className: "shg-peer-flag", style: { background: peer.color }, children: peer.name }),
|
|
2584
|
+
isEditing ? renderEditor(col) : /* @__PURE__ */ jsx13(
|
|
2084
2585
|
"div",
|
|
2085
2586
|
{
|
|
2086
2587
|
className: "shg-val",
|
|
2087
2588
|
style: { maxWidth: colWidth(col) ? colWidth(col) - 20 : 400 },
|
|
2088
|
-
children: custom !== void 0 ? custom : /* @__PURE__ */
|
|
2089
|
-
computed && /* @__PURE__ */
|
|
2090
|
-
/* @__PURE__ */
|
|
2091
|
-
computed && !readOnly && onRunCell && /* @__PURE__ */
|
|
2589
|
+
children: custom !== void 0 ? custom : /* @__PURE__ */ jsxs12(Fragment8, { children: [
|
|
2590
|
+
computed && /* @__PURE__ */ jsx13(StatusDot, { status: c.status }),
|
|
2591
|
+
/* @__PURE__ */ jsx13(CellValue, { cell: c, col, fetchBlobUrl, onOpenResource }),
|
|
2592
|
+
computed && !readOnly && onRunCell && /* @__PURE__ */ jsx13(
|
|
2092
2593
|
"button",
|
|
2093
2594
|
{
|
|
2094
2595
|
className: "shg-runcell",
|
|
@@ -2108,14 +2609,14 @@ function SheetGrid({
|
|
|
2108
2609
|
col.id
|
|
2109
2610
|
);
|
|
2110
2611
|
}),
|
|
2111
|
-
!readOnly && /* @__PURE__ */
|
|
2612
|
+
!readOnly && /* @__PURE__ */ jsx13("td", { className: "shg-pad" })
|
|
2112
2613
|
]
|
|
2113
2614
|
},
|
|
2114
2615
|
row.id
|
|
2115
2616
|
)),
|
|
2116
|
-
!readOnly && /* @__PURE__ */
|
|
2117
|
-
/* @__PURE__ */
|
|
2118
|
-
/* @__PURE__ */
|
|
2617
|
+
!readOnly && /* @__PURE__ */ jsxs12("tr", { className: "shg-ghost-row", onClick: addRow, children: [
|
|
2618
|
+
/* @__PURE__ */ jsx13("td", { className: "shg-rownum shg-ghost-num", style: numStyle, children: "+" }),
|
|
2619
|
+
/* @__PURE__ */ jsx13("td", { className: "shg-ghost-cell", colSpan: columns.length + 1, children: "New row" })
|
|
2119
2620
|
] })
|
|
2120
2621
|
] })
|
|
2121
2622
|
] }) }) });
|
|
@@ -2136,13 +2637,13 @@ function ColumnHeader({
|
|
|
2136
2637
|
onDelete,
|
|
2137
2638
|
onRun
|
|
2138
2639
|
}) {
|
|
2139
|
-
const [editing, setEditing] =
|
|
2140
|
-
const [name, setName] =
|
|
2141
|
-
|
|
2640
|
+
const [editing, setEditing] = useState8(false);
|
|
2641
|
+
const [name, setName] = useState8(col.name);
|
|
2642
|
+
useEffect8(() => setName(col.name), [col.name]);
|
|
2142
2643
|
const badge = desc.badge ? desc.badge(col) : void 0;
|
|
2143
|
-
return /* @__PURE__ */
|
|
2144
|
-
/* @__PURE__ */
|
|
2145
|
-
editing && !readOnly ? /* @__PURE__ */
|
|
2644
|
+
return /* @__PURE__ */ jsxs12("div", { className: "shg-colhdr", children: [
|
|
2645
|
+
/* @__PURE__ */ jsxs12("div", { className: "shg-colhdr-main", children: [
|
|
2646
|
+
editing && !readOnly ? /* @__PURE__ */ jsx13(
|
|
2146
2647
|
"input",
|
|
2147
2648
|
{
|
|
2148
2649
|
className: "shg-colname-input",
|
|
@@ -2157,17 +2658,17 @@ function ColumnHeader({
|
|
|
2157
2658
|
if (e.key === "Enter") e.target.blur();
|
|
2158
2659
|
}
|
|
2159
2660
|
}
|
|
2160
|
-
) : /* @__PURE__ */
|
|
2161
|
-
/* @__PURE__ */
|
|
2661
|
+
) : /* @__PURE__ */ jsx13("span", { className: "shg-colname", onDoubleClick: () => !readOnly && setEditing(true), title: col.name, children: col.name }),
|
|
2662
|
+
/* @__PURE__ */ jsxs12("span", { className: "shg-coltype" + (desc.computed ? " compute" : ""), children: [
|
|
2162
2663
|
desc.label || col.type,
|
|
2163
2664
|
badge ? ` \xB7 ${badge}` : ""
|
|
2164
2665
|
] })
|
|
2165
2666
|
] }),
|
|
2166
|
-
!readOnly && /* @__PURE__ */
|
|
2167
|
-
onRun && /* @__PURE__ */
|
|
2168
|
-
/* @__PURE__ */
|
|
2667
|
+
!readOnly && /* @__PURE__ */ jsxs12("div", { className: "shg-colhdr-tools", children: [
|
|
2668
|
+
onRun && /* @__PURE__ */ jsx13("button", { className: "shg-colrun", onClick: onRun, title: "Run this column", children: "\u25B6 Run" }),
|
|
2669
|
+
/* @__PURE__ */ jsx13("button", { className: "shg-colmenu-btn", onClick: (e) => onMenu(e), title: "Column settings", children: "\u22EF" })
|
|
2169
2670
|
] }),
|
|
2170
|
-
menuOpen && !readOnly && /* @__PURE__ */
|
|
2671
|
+
menuOpen && !readOnly && /* @__PURE__ */ jsx13(
|
|
2171
2672
|
ColumnMenu,
|
|
2172
2673
|
{
|
|
2173
2674
|
col,
|
|
@@ -2186,17 +2687,17 @@ function ColumnHeader({
|
|
|
2186
2687
|
] });
|
|
2187
2688
|
}
|
|
2188
2689
|
function ColumnMenu({ col, columns, anchor, columnTypes, renderColumnConfig, onApply, onDelete, onClose }) {
|
|
2189
|
-
const [type, setType] =
|
|
2190
|
-
const [optText, setOptText] =
|
|
2690
|
+
const [type, setType] = useState8(col.type || "text");
|
|
2691
|
+
const [optText, setOptText] = useState8(
|
|
2191
2692
|
normOptions(col.options).map((o) => o.label).join("\n")
|
|
2192
2693
|
);
|
|
2193
2694
|
const comp = col.compute || {};
|
|
2194
|
-
const [kind, setKind] =
|
|
2195
|
-
const [prompt, setPrompt] =
|
|
2196
|
-
const [harnessId, setHarnessId] =
|
|
2197
|
-
const [wfSlug, setWfSlug] =
|
|
2198
|
-
const [outKey, setOutKey] =
|
|
2199
|
-
const [deps, setDeps] =
|
|
2695
|
+
const [kind, setKind] = useState8(comp.kind || "prompt");
|
|
2696
|
+
const [prompt, setPrompt] = useState8(comp.prompt || "");
|
|
2697
|
+
const [harnessId, setHarnessId] = useState8(comp.harness_id || "");
|
|
2698
|
+
const [wfSlug, setWfSlug] = useState8(comp.workflow_slug || "");
|
|
2699
|
+
const [outKey, setOutKey] = useState8(comp.output_key || "");
|
|
2700
|
+
const [deps, setDeps] = useState8(new Set(comp.deps || []));
|
|
2200
2701
|
const others = columns.filter((c) => c.id !== col.id);
|
|
2201
2702
|
const toggleDep = (id) => setDeps((s) => {
|
|
2202
2703
|
const n = new Set(s);
|
|
@@ -2233,7 +2734,7 @@ function ColumnMenu({ col, columns, anchor, columnTypes, renderColumnConfig, onA
|
|
|
2233
2734
|
close: onClose
|
|
2234
2735
|
});
|
|
2235
2736
|
const desc = columnTypes.find((t) => t.type === type) || {};
|
|
2236
|
-
return /* @__PURE__ */
|
|
2737
|
+
return /* @__PURE__ */ jsx13(
|
|
2237
2738
|
PopPortal,
|
|
2238
2739
|
{
|
|
2239
2740
|
anchor,
|
|
@@ -2241,14 +2742,14 @@ function ColumnMenu({ col, columns, anchor, columnTypes, renderColumnConfig, onA
|
|
|
2241
2742
|
estHeight: desc.configHeight || 340,
|
|
2242
2743
|
className: "shg-menu",
|
|
2243
2744
|
onClose,
|
|
2244
|
-
children: /* @__PURE__ */
|
|
2245
|
-
/* @__PURE__ */
|
|
2745
|
+
children: /* @__PURE__ */ jsxs12("div", { onClick: (e) => e.stopPropagation(), children: [
|
|
2746
|
+
/* @__PURE__ */ jsxs12("label", { className: "shg-menu-lbl", children: [
|
|
2246
2747
|
"Type",
|
|
2247
|
-
/* @__PURE__ */
|
|
2748
|
+
/* @__PURE__ */ jsx13("select", { className: "shg-menu-input", value: type, onChange: (e) => setType(e.target.value), children: columnTypes.map((t) => /* @__PURE__ */ jsx13("option", { value: t.type, children: t.label }, t.type)) })
|
|
2248
2749
|
] }),
|
|
2249
|
-
(type === "select" || type === "tags") && /* @__PURE__ */
|
|
2750
|
+
(type === "select" || type === "tags") && /* @__PURE__ */ jsxs12("label", { className: "shg-menu-lbl", children: [
|
|
2250
2751
|
"Options (one per line)",
|
|
2251
|
-
/* @__PURE__ */
|
|
2752
|
+
/* @__PURE__ */ jsx13(
|
|
2252
2753
|
"textarea",
|
|
2253
2754
|
{
|
|
2254
2755
|
className: "shg-menu-input",
|
|
@@ -2259,16 +2760,16 @@ function ColumnMenu({ col, columns, anchor, columnTypes, renderColumnConfig, onA
|
|
|
2259
2760
|
}
|
|
2260
2761
|
)
|
|
2261
2762
|
] }),
|
|
2262
|
-
custom !== void 0 ? custom : /* @__PURE__ */
|
|
2263
|
-
type === "compute" && /* @__PURE__ */
|
|
2264
|
-
/* @__PURE__ */
|
|
2763
|
+
custom !== void 0 ? custom : /* @__PURE__ */ jsxs12(Fragment8, { children: [
|
|
2764
|
+
type === "compute" && /* @__PURE__ */ jsxs12(Fragment8, { children: [
|
|
2765
|
+
/* @__PURE__ */ jsxs12("label", { className: "shg-menu-lbl", children: [
|
|
2265
2766
|
"Runs",
|
|
2266
|
-
/* @__PURE__ */
|
|
2767
|
+
/* @__PURE__ */ jsx13("select", { className: "shg-menu-input", value: kind, onChange: (e) => setKind(e.target.value), children: COMPUTE_KINDS.map((k) => /* @__PURE__ */ jsx13("option", { value: k.kind, children: k.label }, k.kind)) })
|
|
2267
2768
|
] }),
|
|
2268
|
-
(kind === "prompt" || kind === "harness") && /* @__PURE__ */
|
|
2769
|
+
(kind === "prompt" || kind === "harness") && /* @__PURE__ */ jsxs12("label", { className: "shg-menu-lbl", children: [
|
|
2269
2770
|
"Prompt \u2014 reference columns as ",
|
|
2270
2771
|
"{{Name}}",
|
|
2271
|
-
/* @__PURE__ */
|
|
2772
|
+
/* @__PURE__ */ jsx13(
|
|
2272
2773
|
"textarea",
|
|
2273
2774
|
{
|
|
2274
2775
|
className: "shg-menu-input",
|
|
@@ -2279,32 +2780,32 @@ function ColumnMenu({ col, columns, anchor, columnTypes, renderColumnConfig, onA
|
|
|
2279
2780
|
}
|
|
2280
2781
|
)
|
|
2281
2782
|
] }),
|
|
2282
|
-
kind === "harness" && /* @__PURE__ */
|
|
2783
|
+
kind === "harness" && /* @__PURE__ */ jsxs12("label", { className: "shg-menu-lbl", children: [
|
|
2283
2784
|
"Agent id",
|
|
2284
|
-
/* @__PURE__ */
|
|
2785
|
+
/* @__PURE__ */ jsx13("input", { className: "shg-menu-input", value: harnessId, onChange: (e) => setHarnessId(e.target.value), placeholder: "chrn_\u2026" })
|
|
2285
2786
|
] }),
|
|
2286
|
-
kind === "workflow" && /* @__PURE__ */
|
|
2287
|
-
/* @__PURE__ */
|
|
2787
|
+
kind === "workflow" && /* @__PURE__ */ jsxs12(Fragment8, { children: [
|
|
2788
|
+
/* @__PURE__ */ jsxs12("label", { className: "shg-menu-lbl", children: [
|
|
2288
2789
|
"Workflow id",
|
|
2289
|
-
/* @__PURE__ */
|
|
2790
|
+
/* @__PURE__ */ jsx13("input", { className: "shg-menu-input", value: wfSlug, onChange: (e) => setWfSlug(e.target.value), placeholder: "my-workflow" })
|
|
2290
2791
|
] }),
|
|
2291
|
-
/* @__PURE__ */
|
|
2792
|
+
/* @__PURE__ */ jsxs12("label", { className: "shg-menu-lbl", children: [
|
|
2292
2793
|
"Output key (optional)",
|
|
2293
|
-
/* @__PURE__ */
|
|
2794
|
+
/* @__PURE__ */ jsx13("input", { className: "shg-menu-input", value: outKey, onChange: (e) => setOutKey(e.target.value), placeholder: "summary" })
|
|
2294
2795
|
] })
|
|
2295
2796
|
] }),
|
|
2296
|
-
others.length > 0 && /* @__PURE__ */
|
|
2797
|
+
others.length > 0 && /* @__PURE__ */ jsxs12("div", { className: "shg-menu-lbl", children: [
|
|
2297
2798
|
"Reads columns",
|
|
2298
|
-
/* @__PURE__ */
|
|
2299
|
-
/* @__PURE__ */
|
|
2799
|
+
/* @__PURE__ */ jsx13("div", { className: "shg-menu-deps", children: others.map((c) => /* @__PURE__ */ jsxs12("label", { className: "shg-menu-dep", children: [
|
|
2800
|
+
/* @__PURE__ */ jsx13("input", { type: "checkbox", checked: deps.has(c.id), onChange: () => toggleDep(c.id) }),
|
|
2300
2801
|
" ",
|
|
2301
2802
|
c.name
|
|
2302
2803
|
] }, c.id)) })
|
|
2303
2804
|
] })
|
|
2304
2805
|
] }),
|
|
2305
|
-
/* @__PURE__ */
|
|
2306
|
-
/* @__PURE__ */
|
|
2307
|
-
/* @__PURE__ */
|
|
2806
|
+
/* @__PURE__ */ jsxs12("div", { className: "shg-menu-actions", children: [
|
|
2807
|
+
/* @__PURE__ */ jsx13("button", { className: "shg-menu-del", onClick: onDelete, children: "Delete column" }),
|
|
2808
|
+
/* @__PURE__ */ jsx13("button", { className: "shg-menu-apply", onClick: apply, children: "Apply" })
|
|
2308
2809
|
] })
|
|
2309
2810
|
] })
|
|
2310
2811
|
] })
|
|
@@ -2346,12 +2847,308 @@ function sheetToAoA(sheet, { cellText = defaultCellValue } = {}) {
|
|
|
2346
2847
|
...rows.map((r) => cols.map((c) => cellText(cells[cellKey(r.id, c.id)], c) ?? ""))
|
|
2347
2848
|
];
|
|
2348
2849
|
}
|
|
2850
|
+
|
|
2851
|
+
// src/components/Carousel.jsx
|
|
2852
|
+
import React9, { useCallback as useCallback5, useEffect as useEffect9, useRef as useRef8, useState as useState9 } from "react";
|
|
2853
|
+
import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2854
|
+
var EDGE = 2;
|
|
2855
|
+
function Carousel(props) {
|
|
2856
|
+
const { label, step, children, classNames = {} } = props;
|
|
2857
|
+
const ref = useRef8(null);
|
|
2858
|
+
const [edges, setEdges] = useState9({ start: true, end: true, overflow: false });
|
|
2859
|
+
const measure = useCallback5(() => {
|
|
2860
|
+
const el = ref.current;
|
|
2861
|
+
if (!el) return;
|
|
2862
|
+
const overflow = el.scrollWidth - el.clientWidth > EDGE;
|
|
2863
|
+
setEdges({
|
|
2864
|
+
overflow,
|
|
2865
|
+
start: el.scrollLeft <= EDGE,
|
|
2866
|
+
end: el.scrollLeft >= el.scrollWidth - el.clientWidth - EDGE
|
|
2867
|
+
});
|
|
2868
|
+
}, []);
|
|
2869
|
+
useEffect9(() => {
|
|
2870
|
+
const el = ref.current;
|
|
2871
|
+
if (!el) return void 0;
|
|
2872
|
+
measure();
|
|
2873
|
+
const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(measure) : null;
|
|
2874
|
+
ro?.observe(el);
|
|
2875
|
+
for (const child of el.children) ro?.observe(child);
|
|
2876
|
+
return () => ro?.disconnect();
|
|
2877
|
+
}, [measure, children]);
|
|
2878
|
+
const scroll = (dir) => {
|
|
2879
|
+
const el = ref.current;
|
|
2880
|
+
if (!el) return;
|
|
2881
|
+
el.scrollBy({ left: dir * (step || Math.round(el.clientWidth * 0.9)), behavior: "smooth" });
|
|
2882
|
+
};
|
|
2883
|
+
return /* @__PURE__ */ jsxs13("div", { className: ["uic-carousel-wrap", classNames.root || ""].filter(Boolean).join(" "), children: [
|
|
2884
|
+
edges.overflow ? /* @__PURE__ */ jsx14(
|
|
2885
|
+
"button",
|
|
2886
|
+
{
|
|
2887
|
+
type: "button",
|
|
2888
|
+
className: ["uic-carousel-nav is-left", classNames.button || ""].filter(Boolean).join(" "),
|
|
2889
|
+
onClick: () => scroll(-1),
|
|
2890
|
+
disabled: edges.start,
|
|
2891
|
+
"aria-label": `Scroll ${label} left`,
|
|
2892
|
+
children: /* @__PURE__ */ jsx14(Chevron, { dir: "left" })
|
|
2893
|
+
}
|
|
2894
|
+
) : null,
|
|
2895
|
+
/* @__PURE__ */ jsx14(
|
|
2896
|
+
"div",
|
|
2897
|
+
{
|
|
2898
|
+
className: ["uic-carousel", classNames.viewport || ""].filter(Boolean).join(" "),
|
|
2899
|
+
ref,
|
|
2900
|
+
onScroll: measure,
|
|
2901
|
+
role: "group",
|
|
2902
|
+
"aria-label": label,
|
|
2903
|
+
children
|
|
2904
|
+
}
|
|
2905
|
+
),
|
|
2906
|
+
edges.overflow ? /* @__PURE__ */ jsx14(
|
|
2907
|
+
"button",
|
|
2908
|
+
{
|
|
2909
|
+
type: "button",
|
|
2910
|
+
className: ["uic-carousel-nav is-right", classNames.button || ""].filter(Boolean).join(" "),
|
|
2911
|
+
onClick: () => scroll(1),
|
|
2912
|
+
disabled: edges.end,
|
|
2913
|
+
"aria-label": `Scroll ${label} right`,
|
|
2914
|
+
children: /* @__PURE__ */ jsx14(Chevron, { dir: "right" })
|
|
2915
|
+
}
|
|
2916
|
+
) : null
|
|
2917
|
+
] });
|
|
2918
|
+
}
|
|
2919
|
+
|
|
2920
|
+
// src/components/Card.jsx
|
|
2921
|
+
import React10 from "react";
|
|
2922
|
+
import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2923
|
+
function Card(props) {
|
|
2924
|
+
const { art, title, subtitle, onClick, selected = false, overlay, actions, classNames = {} } = props;
|
|
2925
|
+
const foot = /* @__PURE__ */ jsxs14("span", { className: "uic-card-foot", children: [
|
|
2926
|
+
/* @__PURE__ */ jsx15("span", { className: "uic-card-name", children: title }),
|
|
2927
|
+
subtitle ? /* @__PURE__ */ jsx15("span", { className: "uic-card-sub", children: subtitle }) : null
|
|
2928
|
+
] });
|
|
2929
|
+
return /* @__PURE__ */ jsxs14("div", { className: ["uic-card", selected ? "is-selected" : "", classNames.root || ""].filter(Boolean).join(" "), children: [
|
|
2930
|
+
onClick ? /* @__PURE__ */ jsxs14("button", { type: "button", className: "uic-card-main", onClick, "aria-pressed": selected || void 0, children: [
|
|
2931
|
+
/* @__PURE__ */ jsx15("span", { className: "uic-card-art", children: art }),
|
|
2932
|
+
foot
|
|
2933
|
+
] }) : /* @__PURE__ */ jsxs14("div", { className: "uic-card-main", children: [
|
|
2934
|
+
/* @__PURE__ */ jsx15("span", { className: "uic-card-art", children: art }),
|
|
2935
|
+
foot
|
|
2936
|
+
] }),
|
|
2937
|
+
overlay ? /* @__PURE__ */ jsx15("div", { className: "uic-card-overlay", children: overlay }) : null,
|
|
2938
|
+
actions ? /* @__PURE__ */ jsx15("div", { className: "uic-card-actions", children: actions }) : null
|
|
2939
|
+
] });
|
|
2940
|
+
}
|
|
2941
|
+
|
|
2942
|
+
// src/components/SearchField.jsx
|
|
2943
|
+
import React11 from "react";
|
|
2944
|
+
import { jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2945
|
+
function SearchField(props) {
|
|
2946
|
+
const { value, onChange, placeholder, clearLabel = "Clear search", className } = props;
|
|
2947
|
+
return /* @__PURE__ */ jsxs15("label", { className: ["uic-search", className || ""].filter(Boolean).join(" "), children: [
|
|
2948
|
+
/* @__PURE__ */ jsx16("span", { className: "uic-search-ic", "aria-hidden": "true", children: /* @__PURE__ */ jsx16(IcSearch, {}) }),
|
|
2949
|
+
/* @__PURE__ */ jsx16(
|
|
2950
|
+
"input",
|
|
2951
|
+
{
|
|
2952
|
+
type: "search",
|
|
2953
|
+
value,
|
|
2954
|
+
placeholder,
|
|
2955
|
+
"aria-label": placeholder,
|
|
2956
|
+
onChange: (e) => onChange(e.target.value)
|
|
2957
|
+
}
|
|
2958
|
+
),
|
|
2959
|
+
value ? /* @__PURE__ */ jsx16("button", { type: "button", className: "uic-search-x", "aria-label": clearLabel, onClick: () => onChange(""), children: /* @__PURE__ */ jsx16(IcX, { size: 12 }) }) : null
|
|
2960
|
+
] });
|
|
2961
|
+
}
|
|
2962
|
+
|
|
2963
|
+
// src/components/Popover.jsx
|
|
2964
|
+
import React12, { useCallback as useCallback6, useEffect as useEffect10, useRef as useRef9, useState as useState10 } from "react";
|
|
2965
|
+
import { createPortal as createPortal3 } from "react-dom";
|
|
2966
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
2967
|
+
var GAP = 6;
|
|
2968
|
+
var MARGIN = 8;
|
|
2969
|
+
function Popover(props) {
|
|
2970
|
+
const {
|
|
2971
|
+
open,
|
|
2972
|
+
anchorRef,
|
|
2973
|
+
onClose,
|
|
2974
|
+
width = 280,
|
|
2975
|
+
minHeight = 140,
|
|
2976
|
+
placement = "auto",
|
|
2977
|
+
children,
|
|
2978
|
+
className,
|
|
2979
|
+
label
|
|
2980
|
+
} = props;
|
|
2981
|
+
const popRef = useRef9(null);
|
|
2982
|
+
const [pos, setPos] = useState10(null);
|
|
2983
|
+
useEffect10(() => {
|
|
2984
|
+
if (!open) {
|
|
2985
|
+
setPos(null);
|
|
2986
|
+
return void 0;
|
|
2987
|
+
}
|
|
2988
|
+
const place = () => {
|
|
2989
|
+
const el = anchorRef?.current;
|
|
2990
|
+
if (!el) return;
|
|
2991
|
+
const r = el.getBoundingClientRect();
|
|
2992
|
+
const vw = window.innerWidth;
|
|
2993
|
+
const vh = window.innerHeight;
|
|
2994
|
+
const w = Math.min(width, vw - MARGIN * 2);
|
|
2995
|
+
const below = vh - r.bottom - GAP - MARGIN;
|
|
2996
|
+
const above = r.top - GAP - MARGIN;
|
|
2997
|
+
const up = placement === "above" || placement === "auto" && below < minHeight && above > below;
|
|
2998
|
+
const maxHeight = Math.max(minHeight, Math.floor(up ? above : below));
|
|
2999
|
+
const left = Math.max(MARGIN, Math.min(r.left, vw - w - MARGIN));
|
|
3000
|
+
setPos(up ? { left, bottom: Math.round(vh - r.top + GAP), width: w, maxHeight } : { left, top: Math.round(r.bottom + GAP), width: w, maxHeight });
|
|
3001
|
+
};
|
|
3002
|
+
place();
|
|
3003
|
+
window.addEventListener("resize", place);
|
|
3004
|
+
window.addEventListener("scroll", place, true);
|
|
3005
|
+
return () => {
|
|
3006
|
+
window.removeEventListener("resize", place);
|
|
3007
|
+
window.removeEventListener("scroll", place, true);
|
|
3008
|
+
};
|
|
3009
|
+
}, [open, anchorRef, width, minHeight, placement]);
|
|
3010
|
+
useEffect10(() => {
|
|
3011
|
+
if (!open) return void 0;
|
|
3012
|
+
const onDown = (e) => {
|
|
3013
|
+
if (popRef.current?.contains(e.target)) return;
|
|
3014
|
+
if (anchorRef?.current?.contains(e.target)) return;
|
|
3015
|
+
onClose?.();
|
|
3016
|
+
};
|
|
3017
|
+
document.addEventListener("pointerdown", onDown);
|
|
3018
|
+
return () => document.removeEventListener("pointerdown", onDown);
|
|
3019
|
+
}, [open, anchorRef, onClose]);
|
|
3020
|
+
const escape = useCallback6(() => onClose?.(), [onClose]);
|
|
3021
|
+
useOverlayEscape(open, escape);
|
|
3022
|
+
if (!open || !pos || typeof document === "undefined") return null;
|
|
3023
|
+
return createPortal3(
|
|
3024
|
+
/* @__PURE__ */ jsx17(
|
|
3025
|
+
"div",
|
|
3026
|
+
{
|
|
3027
|
+
ref: popRef,
|
|
3028
|
+
className: ["uic-pop", className || ""].filter(Boolean).join(" "),
|
|
3029
|
+
style: pos,
|
|
3030
|
+
role: "dialog",
|
|
3031
|
+
"aria-label": label,
|
|
3032
|
+
children
|
|
3033
|
+
}
|
|
3034
|
+
),
|
|
3035
|
+
document.body
|
|
3036
|
+
);
|
|
3037
|
+
}
|
|
3038
|
+
|
|
3039
|
+
// src/components/Modal.jsx
|
|
3040
|
+
import React13, { useCallback as useCallback7, useEffect as useEffect11, useId as useId2 } from "react";
|
|
3041
|
+
import { createPortal as createPortal4 } from "react-dom";
|
|
3042
|
+
import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
3043
|
+
function Modal(props) {
|
|
3044
|
+
const {
|
|
3045
|
+
open,
|
|
3046
|
+
onClose,
|
|
3047
|
+
title,
|
|
3048
|
+
description,
|
|
3049
|
+
actions,
|
|
3050
|
+
size = "md",
|
|
3051
|
+
width,
|
|
3052
|
+
labelledBy,
|
|
3053
|
+
children,
|
|
3054
|
+
classNames = {}
|
|
3055
|
+
} = props;
|
|
3056
|
+
const titleId = useId2();
|
|
3057
|
+
const escape = useCallback7(() => onClose?.(), [onClose]);
|
|
3058
|
+
useOverlayEscape(open, escape);
|
|
3059
|
+
useEffect11(() => {
|
|
3060
|
+
if (!open || typeof document === "undefined") return void 0;
|
|
3061
|
+
const prev = document.body.style.overflow;
|
|
3062
|
+
document.body.style.overflow = "hidden";
|
|
3063
|
+
return () => {
|
|
3064
|
+
document.body.style.overflow = prev;
|
|
3065
|
+
};
|
|
3066
|
+
}, [open]);
|
|
3067
|
+
if (!open || typeof document === "undefined") return null;
|
|
3068
|
+
const onBackdrop = (e) => {
|
|
3069
|
+
if (e.target === e.currentTarget) onClose?.();
|
|
3070
|
+
};
|
|
3071
|
+
return createPortal4(
|
|
3072
|
+
/* @__PURE__ */ jsx18(
|
|
3073
|
+
"div",
|
|
3074
|
+
{
|
|
3075
|
+
className: ["uic-modal-backdrop", classNames.backdrop || ""].filter(Boolean).join(" "),
|
|
3076
|
+
onMouseDown: onBackdrop,
|
|
3077
|
+
children: /* @__PURE__ */ jsxs16(
|
|
3078
|
+
"div",
|
|
3079
|
+
{
|
|
3080
|
+
className: ["uic-modal", `is-${size}`, classNames.root || ""].filter(Boolean).join(" "),
|
|
3081
|
+
style: width ? { width } : void 0,
|
|
3082
|
+
role: "dialog",
|
|
3083
|
+
"aria-modal": "true",
|
|
3084
|
+
"aria-labelledby": labelledBy || (title ? titleId : void 0),
|
|
3085
|
+
children: [
|
|
3086
|
+
title || actions ? /* @__PURE__ */ jsxs16("div", { className: "uic-modal-h", children: [
|
|
3087
|
+
/* @__PURE__ */ jsxs16("div", { className: "uic-modal-title", children: [
|
|
3088
|
+
title ? /* @__PURE__ */ jsx18("h3", { id: titleId, children: title }) : null,
|
|
3089
|
+
description ? /* @__PURE__ */ jsx18("p", { children: description }) : null
|
|
3090
|
+
] }),
|
|
3091
|
+
actions,
|
|
3092
|
+
/* @__PURE__ */ jsx18("button", { type: "button", className: "uic-modal-x", "aria-label": "Close", onClick: onClose, children: /* @__PURE__ */ jsx18(IcX, { size: 18 }) })
|
|
3093
|
+
] }) : null,
|
|
3094
|
+
/* @__PURE__ */ jsx18("div", { className: ["uic-modal-b", classNames.body || ""].filter(Boolean).join(" "), children })
|
|
3095
|
+
]
|
|
3096
|
+
}
|
|
3097
|
+
)
|
|
3098
|
+
}
|
|
3099
|
+
),
|
|
3100
|
+
document.body
|
|
3101
|
+
);
|
|
3102
|
+
}
|
|
3103
|
+
|
|
3104
|
+
// src/hooks/useTypewriter.js
|
|
3105
|
+
import { useEffect as useEffect12, useRef as useRef10, useState as useState11 } from "react";
|
|
3106
|
+
var CHAR_MS = 26;
|
|
3107
|
+
var HOLD_MS = 2600;
|
|
3108
|
+
function useTypewriter(phrases, { active = true } = {}) {
|
|
3109
|
+
const list = phrases && phrases.length ? phrases : [""];
|
|
3110
|
+
const [text, setText] = useState11(list[0]);
|
|
3111
|
+
const listRef = useRef10(list);
|
|
3112
|
+
listRef.current = list;
|
|
3113
|
+
useEffect12(() => {
|
|
3114
|
+
if (!active) return void 0;
|
|
3115
|
+
if (typeof window === "undefined") return void 0;
|
|
3116
|
+
if (window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches) {
|
|
3117
|
+
setText(listRef.current[0]);
|
|
3118
|
+
return void 0;
|
|
3119
|
+
}
|
|
3120
|
+
let i = 0;
|
|
3121
|
+
let pos = 0;
|
|
3122
|
+
let timer;
|
|
3123
|
+
const tick = () => {
|
|
3124
|
+
const cur = listRef.current[i % listRef.current.length];
|
|
3125
|
+
if (pos <= cur.length) {
|
|
3126
|
+
setText(cur.slice(0, pos));
|
|
3127
|
+
pos += 1;
|
|
3128
|
+
timer = window.setTimeout(tick, CHAR_MS);
|
|
3129
|
+
} else {
|
|
3130
|
+
timer = window.setTimeout(() => {
|
|
3131
|
+
i += 1;
|
|
3132
|
+
pos = 0;
|
|
3133
|
+
tick();
|
|
3134
|
+
}, HOLD_MS);
|
|
3135
|
+
}
|
|
3136
|
+
};
|
|
3137
|
+
tick();
|
|
3138
|
+
return () => window.clearTimeout(timer);
|
|
3139
|
+
}, [active]);
|
|
3140
|
+
return text;
|
|
3141
|
+
}
|
|
2349
3142
|
export {
|
|
2350
3143
|
AssistantTurn,
|
|
2351
3144
|
AuthForm,
|
|
3145
|
+
Card,
|
|
3146
|
+
Carousel,
|
|
2352
3147
|
ChatMessages,
|
|
2353
3148
|
ChatMessagesSkeleton,
|
|
3149
|
+
ChatPanel,
|
|
2354
3150
|
Chevron,
|
|
3151
|
+
Chip,
|
|
2355
3152
|
CodeBlock,
|
|
2356
3153
|
Composer,
|
|
2357
3154
|
DEFAULT_STATUS_LABELS,
|
|
@@ -2362,6 +3159,9 @@ export {
|
|
|
2362
3159
|
IcDoc,
|
|
2363
3160
|
IcGlobe,
|
|
2364
3161
|
IcList,
|
|
3162
|
+
IcMic,
|
|
3163
|
+
IcPanelRight,
|
|
3164
|
+
IcPaperclip,
|
|
2365
3165
|
IcPlug,
|
|
2366
3166
|
IcScroll,
|
|
2367
3167
|
IcSearch,
|
|
@@ -2371,8 +3171,12 @@ export {
|
|
|
2371
3171
|
IcTerminal,
|
|
2372
3172
|
IcThink,
|
|
2373
3173
|
IcTool,
|
|
3174
|
+
IcX,
|
|
3175
|
+
Modal,
|
|
2374
3176
|
PaneResizer,
|
|
3177
|
+
Popover,
|
|
2375
3178
|
SESSION_EVENT,
|
|
3179
|
+
SearchField,
|
|
2376
3180
|
SheetGrid,
|
|
2377
3181
|
Svg,
|
|
2378
3182
|
TaskList,
|
|
@@ -2383,9 +3187,11 @@ export {
|
|
|
2383
3187
|
authConfig,
|
|
2384
3188
|
authFetch,
|
|
2385
3189
|
baseName,
|
|
3190
|
+
bytesLabel,
|
|
2386
3191
|
clearSession,
|
|
2387
3192
|
configureAuth,
|
|
2388
3193
|
createConversationStore,
|
|
3194
|
+
createDictation,
|
|
2389
3195
|
createResponsesDispatcher,
|
|
2390
3196
|
fetchBalance,
|
|
2391
3197
|
getSession,
|
|
@@ -2409,8 +3215,10 @@ export {
|
|
|
2409
3215
|
switchOrg,
|
|
2410
3216
|
taskStatusGroup,
|
|
2411
3217
|
toolMeta,
|
|
3218
|
+
turnsToMessages,
|
|
2412
3219
|
useDialog,
|
|
2413
3220
|
useResizablePane,
|
|
3221
|
+
useTypewriter,
|
|
2414
3222
|
withReasoning,
|
|
2415
3223
|
withResult,
|
|
2416
3224
|
withStep,
|