@docyrus/ui-pro-ai-assistant 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +415 -219
- package/dist/index.js.map +1 -1
- package/dist/styles.css +3 -0
- package/dist/tools/create-record.d.ts +12 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { Input } from '@docyrus/ui-pro-shared/components/input';
|
|
|
9
9
|
import { Tabs as Tabs$1, TabsList as TabsList$1, TabsTrigger as TabsTrigger$1, TabsContent as TabsContent$1 } from '@docyrus/ui-pro-shared/components/tabs';
|
|
10
10
|
import { cn } from '@docyrus/ui-pro-shared/lib/utils';
|
|
11
11
|
import { DefaultChatTransport, lastAssistantMessageIsCompleteWithToolCalls } from 'ai';
|
|
12
|
-
import { PilcrowIcon, Heading1Icon, Heading2Icon, Heading3Icon, SquareIcon, ListIcon, ListOrderedIcon, ChevronDownIcon, Code2Icon, QuoteIcon, LightbulbIcon, Columns3Icon, GripVertical, FileUpIcon, TableIcon, ImageIcon, FilmIcon, AudioLinesIcon, TableOfContentsIcon, RadicalIcon, RectangleVerticalIcon, CalendarIcon, PlusIcon, FileCodeIcon, MinusIcon, ChevronRightIcon, ListTree, PenToolIcon, Link2Icon, Check, Copy, FilesIcon, Link, Text, ExternalLink, Unlink, Bold, Italic, Underline, Strikethrough, Code2, MoreHorizontal, ArrowLeftIcon, ArrowRightIcon, Minus, Plus, CircleArrowDown, Minimize2, Trash2, FileUp, CheckCircle2, FileText, Loader2, CornerDownLeftIcon, PencilLineIcon, MessageSquareTextIcon, MessagesSquareIcon, ArrowUpIcon, CheckIcon, CaptionsIcon, ZoomInIcon, CircleArrowDownIcon, MoveUpRightIcon, MoreHorizontalIcon, Eye, Pencil, PlusCircle, HelpCircle, Maximize2, X, Download, FileSpreadsheet, ChevronDown, Search, Globe,
|
|
12
|
+
import { PilcrowIcon, Heading1Icon, Heading2Icon, Heading3Icon, SquareIcon, ListIcon, ListOrderedIcon, ChevronDownIcon, Code2Icon, QuoteIcon, LightbulbIcon, Columns3Icon, GripVertical, FileUpIcon, TableIcon, ImageIcon, FilmIcon, AudioLinesIcon, TableOfContentsIcon, RadicalIcon, RectangleVerticalIcon, CalendarIcon, PlusIcon, FileCodeIcon, MinusIcon, ChevronRightIcon, ListTree, PenToolIcon, Link2Icon, Check, Copy, FilesIcon, Link, Text, ExternalLink, Unlink, Bold, Italic, Underline, Strikethrough, Code2, MoreHorizontal, ArrowLeftIcon, ArrowRightIcon, Minus, Plus, CircleArrowDown, Minimize2, Trash2, FileUp, CheckCircle2, FileText, Loader2, CornerDownLeftIcon, PencilLineIcon, MessageSquareTextIcon, MessagesSquareIcon, ArrowUpIcon, CheckIcon, CaptionsIcon, ZoomInIcon, CircleArrowDownIcon, MoveUpRightIcon, MoreHorizontalIcon, Eye, Pencil, PlusCircle, HelpCircle, Maximize2, X, Download, FileSpreadsheet, ChevronDown, CheckCircle, XCircle, Search, Globe, FolderOpen, User, ArrowRight, MapPin, CalendarClock, List, RefreshCw, FilePlus, XIcon, CornerUpLeftIcon, AlbumIcon, FeatherIcon, ListMinusIcon, ListPlusIcon, ListEnd, Wand, LanguagesIcon, BadgeHelpIcon, PenLineIcon, SearchIcon, MusicIcon, CompassIcon, SmileIcon, LeafIcon, ClockIcon, AppleIcon, FlagIcon, StarIcon, DeleteIcon, AlignLeft, AlignCenter, AlignRight, RotateCcw, AlertTriangle, AlertCircle, ArrowUpDown, ArrowDownToLine, PenLine, PencilIcon, TrashIcon, RefreshCwIcon, PaintRoller, MessageSquareText, ArrowLeft, ChevronLeft, Bot, ChevronRight, Brain, Lightbulb, BookOpen, PenTool, SlidersHorizontal, Wand2, Mic, RefreshCcw, Code, Star, Trash, Edit, FolderInput, Archive, Sparkles, PanelLeft, MessageSquare, NotebookText, CirclePlus, MoreVertical, FileSearch, Microscope, Ruler, AudioLines, BrainCircuit, File as File$1, Plug, Inbox, Menu, LayoutDashboard, Table2, WandSparklesIcon, ArrowUpToLineIcon, BoldIcon, ItalicIcon, UnderlineIcon, StrikethroughIcon, HighlighterIcon, Undo2Icon, Redo2Icon, ArrowDownToLineIcon, AlignLeftIcon, AlignCenterIcon, AlignRightIcon, AlignJustifyIcon, ListOrdered, ListTodoIcon, ListCollapseIcon, Table, Grid3x3Icon, Combine, Ungroup, ArrowUp, ArrowDown, Trash2Icon, LinkIcon, WrapText, OutdentIcon, IndentIcon, EyeIcon, PenIcon } from 'lucide-react';
|
|
13
13
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
14
14
|
import { AsyncTokenManager, RestApiClient } from '@docyrus/api-client';
|
|
15
15
|
import { TooltipProvider, Tooltip as Tooltip$1, TooltipTrigger, TooltipContent } from '@docyrus/ui-pro-shared/components/tooltip';
|
|
@@ -4799,6 +4799,368 @@ function AssistantAnimations({
|
|
|
4799
4799
|
}
|
|
4800
4800
|
);
|
|
4801
4801
|
}
|
|
4802
|
+
function getFieldLabel(key, property) {
|
|
4803
|
+
if (property?.title) return property.title;
|
|
4804
|
+
return key.toString().replace(/_/g, " ").replace(/([A-Z])/g, " $1").split(" ").map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(" ").trim();
|
|
4805
|
+
}
|
|
4806
|
+
function formatLabel(key) {
|
|
4807
|
+
return key.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase());
|
|
4808
|
+
}
|
|
4809
|
+
function inferType(value) {
|
|
4810
|
+
if (value === null || value === void 0) return "string";
|
|
4811
|
+
if (Array.isArray(value)) return "array";
|
|
4812
|
+
if (typeof value === "object") return "object";
|
|
4813
|
+
return typeof value;
|
|
4814
|
+
}
|
|
4815
|
+
function formatValue(value, property) {
|
|
4816
|
+
if (value === null || value === void 0) return "\u2014";
|
|
4817
|
+
const type = property?.type;
|
|
4818
|
+
switch (type) {
|
|
4819
|
+
case "boolean":
|
|
4820
|
+
return value ? "Yes" : "No";
|
|
4821
|
+
case "number":
|
|
4822
|
+
case "integer":
|
|
4823
|
+
return String(value);
|
|
4824
|
+
case "string":
|
|
4825
|
+
if (property?.format === "date") return new Date(value).toLocaleDateString();
|
|
4826
|
+
if (property?.format === "date-time") return new Date(value).toLocaleString();
|
|
4827
|
+
if (typeof value === "object") return JSON.stringify(value, null, 2);
|
|
4828
|
+
return String(value);
|
|
4829
|
+
case "array":
|
|
4830
|
+
return Array.isArray(value) ? `${value.length} items` : "\u2014";
|
|
4831
|
+
case "object":
|
|
4832
|
+
return typeof value === "object" ? JSON.stringify(value, null, 2) : "\u2014";
|
|
4833
|
+
default:
|
|
4834
|
+
return String(value);
|
|
4835
|
+
}
|
|
4836
|
+
}
|
|
4837
|
+
function formatNestedObject(value) {
|
|
4838
|
+
if (value === null || value === void 0) return "\u2014";
|
|
4839
|
+
if (typeof value !== "object") return String(value);
|
|
4840
|
+
return Object.entries(value).map(([k, v]) => typeof v === "object" && v !== null ? `${k}: ${JSON.stringify(v)}` : `${k}: ${v}`).join("\n");
|
|
4841
|
+
}
|
|
4842
|
+
function formatNestedArray(value) {
|
|
4843
|
+
if (!Array.isArray(value)) return "\u2014";
|
|
4844
|
+
if (value.length === 0) return "(empty)";
|
|
4845
|
+
if (value.every((item) => typeof item !== "object" || item === null)) return value.join(", ");
|
|
4846
|
+
return `${value.length} items:
|
|
4847
|
+
${JSON.stringify(value[0], null, 2)}${value.length > 1 ? "\n..." : ""}`;
|
|
4848
|
+
}
|
|
4849
|
+
function formatPrimitive(value) {
|
|
4850
|
+
if (value === null || value === void 0) return "\u2014";
|
|
4851
|
+
if (typeof value === "boolean") return value ? "Yes" : "No";
|
|
4852
|
+
return String(value);
|
|
4853
|
+
}
|
|
4854
|
+
function getCitationsForField(basis, fieldKey) {
|
|
4855
|
+
if (!Array.isArray(basis) || basis.length === 0) return [];
|
|
4856
|
+
const entry = basis.find((item) => item.field === fieldKey);
|
|
4857
|
+
return entry?.citations || [];
|
|
4858
|
+
}
|
|
4859
|
+
function JsonSchemaArray({ schema, data, showHeader = true }) {
|
|
4860
|
+
const isEmpty = !data || data.length === 0;
|
|
4861
|
+
const isArrayOfObjects = !isEmpty && (schema?.items?.type === "object" || data.some((item) => typeof item === "object" && item !== null && !Array.isArray(item)));
|
|
4862
|
+
const columns = useMemo(() => {
|
|
4863
|
+
const itemSchema = schema?.items;
|
|
4864
|
+
if (itemSchema?.properties) {
|
|
4865
|
+
const cols = {};
|
|
4866
|
+
Object.keys(itemSchema.properties).forEach((key) => {
|
|
4867
|
+
cols[key] = {
|
|
4868
|
+
label: itemSchema.properties[key]?.title || formatLabel(key),
|
|
4869
|
+
property: itemSchema.properties[key]
|
|
4870
|
+
};
|
|
4871
|
+
});
|
|
4872
|
+
return cols;
|
|
4873
|
+
}
|
|
4874
|
+
if (isArrayOfObjects && data.length > 0) {
|
|
4875
|
+
const allKeys = /* @__PURE__ */ new Set();
|
|
4876
|
+
data.forEach((item) => {
|
|
4877
|
+
if (typeof item === "object" && item !== null) Object.keys(item).forEach((k) => allKeys.add(k));
|
|
4878
|
+
});
|
|
4879
|
+
const cols = {};
|
|
4880
|
+
allKeys.forEach((key) => {
|
|
4881
|
+
cols[key] = {
|
|
4882
|
+
label: formatLabel(key),
|
|
4883
|
+
property: { type: inferType(data[0]?.[key]) }
|
|
4884
|
+
};
|
|
4885
|
+
});
|
|
4886
|
+
return cols;
|
|
4887
|
+
}
|
|
4888
|
+
return {};
|
|
4889
|
+
}, [schema, data, isArrayOfObjects]);
|
|
4890
|
+
return /* @__PURE__ */ jsxs("div", { className: "w-full not-prose", children: [
|
|
4891
|
+
showHeader && schema?.title && /* @__PURE__ */ jsx("div", { className: "text-lg font-semibold text-slate-700 mb-3", children: schema.title }),
|
|
4892
|
+
showHeader && schema?.description && /* @__PURE__ */ jsx("div", { className: "text-sm text-slate-600 mb-3", children: schema.description }),
|
|
4893
|
+
isEmpty ? /* @__PURE__ */ jsx("div", { className: "text-sm text-slate-500 italic py-4", children: "No items" }) : isArrayOfObjects ? /* @__PURE__ */ jsx("div", { className: "overflow-x-auto overflow-hidden shadow-sm rounded-lg border border-slate-200", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-slate-200", children: [
|
|
4894
|
+
/* @__PURE__ */ jsx("thead", { className: "bg-slate-50", children: /* @__PURE__ */ jsx("tr", { children: Object.entries(columns).map(([key, col]) => /* @__PURE__ */ jsx(
|
|
4895
|
+
"th",
|
|
4896
|
+
{
|
|
4897
|
+
className: "px-4 py-3 text-left text-xs font-medium text-slate-700 uppercase tracking-wider",
|
|
4898
|
+
children: col.label
|
|
4899
|
+
},
|
|
4900
|
+
key
|
|
4901
|
+
)) }) }),
|
|
4902
|
+
/* @__PURE__ */ jsx("tbody", { className: "bg-white divide-y divide-slate-200", children: data.map((item, index) => /* @__PURE__ */ jsx("tr", { className: "hover:bg-slate-50", children: Object.entries(columns).map(([key, col]) => /* @__PURE__ */ jsx("td", { className: "px-4 py-3 text-sm text-slate-700", children: col.property?.type === "object" ? /* @__PURE__ */ jsx("div", { className: "text-xs font-mono bg-slate-100 rounded px-2 py-1 whitespace-pre-wrap break-all max-w-xs", children: formatNestedObject(item[key]) }) : col.property?.type === "array" ? /* @__PURE__ */ jsx("div", { className: "text-xs font-mono bg-slate-100 rounded px-2 py-1 whitespace-pre-wrap break-all max-w-xs", children: formatNestedArray(item[key]) }) : /* @__PURE__ */ jsx("span", { className: col.property?.type === "number" || col.property?.type === "integer" ? "font-mono" : "", children: formatValue(item[key], col.property) }) }, key)) }, index)) })
|
|
4903
|
+
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-2", children: data.map((item, index) => /* @__PURE__ */ jsx(
|
|
4904
|
+
"div",
|
|
4905
|
+
{
|
|
4906
|
+
className: "px-3 py-2 bg-white border border-slate-200 rounded-md text-sm text-slate-700",
|
|
4907
|
+
children: formatPrimitive(item)
|
|
4908
|
+
},
|
|
4909
|
+
index
|
|
4910
|
+
)) })
|
|
4911
|
+
] });
|
|
4912
|
+
}
|
|
4913
|
+
function JsonSchemaObject({ schema, data, basis = [] }) {
|
|
4914
|
+
const properties = schema?.properties || {};
|
|
4915
|
+
const required = schema?.required || [];
|
|
4916
|
+
return /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
4917
|
+
schema?.title && /* @__PURE__ */ jsx("div", { className: "text-lg font-semibold text-slate-700 mb-4", children: schema.title }),
|
|
4918
|
+
schema?.description && /* @__PURE__ */ jsx("div", { className: "text-sm text-slate-600 mb-4", children: schema.description }),
|
|
4919
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-4", children: Object.entries(properties).map(([key, property]) => {
|
|
4920
|
+
const isNestedObject = property?.type === "object" && property?.properties;
|
|
4921
|
+
const isArr = property?.type === "array";
|
|
4922
|
+
const citations = getCitationsForField(basis, key);
|
|
4923
|
+
const isReq = required.includes(key);
|
|
4924
|
+
if (isNestedObject) {
|
|
4925
|
+
return /* @__PURE__ */ jsx("div", { className: "border border-slate-200 rounded-lg p-4 bg-slate-50", children: /* @__PURE__ */ jsx(JsonSchemaObject, { schema: property, data: data?.[key] || {}, basis }) }, key);
|
|
4926
|
+
}
|
|
4927
|
+
if (isArr) {
|
|
4928
|
+
return /* @__PURE__ */ jsxs("div", { className: "border border-slate-200 rounded-lg p-4 bg-slate-50", children: [
|
|
4929
|
+
property?.title && /* @__PURE__ */ jsx("div", { className: "text-sm font-medium text-slate-700 mb-2", children: property.title }),
|
|
4930
|
+
/* @__PURE__ */ jsx(JsonSchemaArray, { schema: property, data: data?.[key] || [], showHeader: false })
|
|
4931
|
+
] }, key);
|
|
4932
|
+
}
|
|
4933
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
4934
|
+
/* @__PURE__ */ jsx("label", { className: `text-sm font-medium text-slate-700 mb-1${isReq ? " after:content-['*'] after:ml-0.5 after:text-red-500" : ""}`, children: getFieldLabel(key, property) }),
|
|
4935
|
+
property?.description && /* @__PURE__ */ jsx("div", { className: "text-xs text-slate-500 mb-1", children: property.description }),
|
|
4936
|
+
/* @__PURE__ */ jsx("div", { className: `px-3 py-2 bg-white border border-slate-300 rounded-md text-sm text-slate-700${property?.type === "number" || property?.type === "integer" ? " font-mono" : ""}`, children: formatValue(data?.[key], property) }),
|
|
4937
|
+
citations.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mt-2 text-xs text-slate-600 bg-slate-50 border border-slate-200 rounded-md p-3", children: [
|
|
4938
|
+
/* @__PURE__ */ jsxs("div", { className: "font-medium text-slate-700 mb-2 flex items-center gap-1", children: [
|
|
4939
|
+
/* @__PURE__ */ jsx("svg", { className: "w-3 h-3", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsx(
|
|
4940
|
+
"path",
|
|
4941
|
+
{
|
|
4942
|
+
fillRule: "evenodd",
|
|
4943
|
+
d: "M12.586 4.586a2 2 0 112.828 2.828l-3 3a2 2 0 01-2.828 0 1 1 0 00-1.414 1.414 4 4 0 005.656 0l3-3a4 4 0 00-5.656-5.656l-1.5 1.5a1 1 0 101.414 1.414l1.5-1.5zm-5 5a2 2 0 012.828 0 1 1 0 101.414-1.414 4 4 0 00-5.656 0l-3 3a4 4 0 105.656 5.656l1.5-1.5a1 1 0 10-1.414-1.414l-1.5 1.5a2 2 0 11-2.828-2.828l3-3z",
|
|
4944
|
+
clipRule: "evenodd"
|
|
4945
|
+
}
|
|
4946
|
+
) }),
|
|
4947
|
+
"Sources (",
|
|
4948
|
+
citations.length,
|
|
4949
|
+
")"
|
|
4950
|
+
] }),
|
|
4951
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-2", children: citations.map((citation, idx) => /* @__PURE__ */ jsxs("div", { className: "flex gap-2 scroll-mt-4", children: [
|
|
4952
|
+
/* @__PURE__ */ jsxs("span", { className: "font-mono text-slate-500", children: [
|
|
4953
|
+
"[",
|
|
4954
|
+
idx + 1,
|
|
4955
|
+
"]"
|
|
4956
|
+
] }),
|
|
4957
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
4958
|
+
/* @__PURE__ */ jsx(
|
|
4959
|
+
"a",
|
|
4960
|
+
{
|
|
4961
|
+
href: citation.url,
|
|
4962
|
+
target: "_blank",
|
|
4963
|
+
rel: "noopener noreferrer",
|
|
4964
|
+
className: "text-blue-600 hover:text-blue-800 hover:underline break-all truncate block",
|
|
4965
|
+
children: citation.url
|
|
4966
|
+
}
|
|
4967
|
+
),
|
|
4968
|
+
citation.excerpts && citation.excerpts.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mt-1 text-slate-600 italic truncate", children: [
|
|
4969
|
+
'"',
|
|
4970
|
+
citation.excerpts[0],
|
|
4971
|
+
'"'
|
|
4972
|
+
] })
|
|
4973
|
+
] })
|
|
4974
|
+
] }, idx)) })
|
|
4975
|
+
] })
|
|
4976
|
+
] }, key);
|
|
4977
|
+
}) })
|
|
4978
|
+
] });
|
|
4979
|
+
}
|
|
4980
|
+
function JsonSchemaLayout({ schema, data, basis = [] }) {
|
|
4981
|
+
const schemaType = schema?.type || (Array.isArray(data) ? "array" : "object");
|
|
4982
|
+
if (schemaType === "array") {
|
|
4983
|
+
return /* @__PURE__ */ jsx(JsonSchemaArray, { schema, data });
|
|
4984
|
+
}
|
|
4985
|
+
return /* @__PURE__ */ jsx(JsonSchemaObject, { schema, data, basis });
|
|
4986
|
+
}
|
|
4987
|
+
function generateSchemaFromValue(value) {
|
|
4988
|
+
if (value === null || value === void 0) return { type: "string" };
|
|
4989
|
+
if (Array.isArray(value)) {
|
|
4990
|
+
return {
|
|
4991
|
+
type: "array",
|
|
4992
|
+
items: value.length > 0 ? generateSchemaFromValue(value[0]) : { type: "string" }
|
|
4993
|
+
};
|
|
4994
|
+
}
|
|
4995
|
+
if (typeof value === "object") {
|
|
4996
|
+
const properties = {};
|
|
4997
|
+
for (const [k, v] of Object.entries(value)) {
|
|
4998
|
+
properties[k] = generateSchemaFromValue(v);
|
|
4999
|
+
}
|
|
5000
|
+
return { type: "object", properties };
|
|
5001
|
+
}
|
|
5002
|
+
if (typeof value === "number") return { type: Number.isInteger(value) ? "integer" : "number" };
|
|
5003
|
+
if (typeof value === "boolean") return { type: "boolean" };
|
|
5004
|
+
return { type: "string" };
|
|
5005
|
+
}
|
|
5006
|
+
function safeParse(value) {
|
|
5007
|
+
if (value == null) return null;
|
|
5008
|
+
if (typeof value === "string") {
|
|
5009
|
+
try {
|
|
5010
|
+
return JSON.parse(value);
|
|
5011
|
+
} catch {
|
|
5012
|
+
return null;
|
|
5013
|
+
}
|
|
5014
|
+
}
|
|
5015
|
+
return value;
|
|
5016
|
+
}
|
|
5017
|
+
function CreateRecord({
|
|
5018
|
+
dataSourceId,
|
|
5019
|
+
record,
|
|
5020
|
+
records,
|
|
5021
|
+
state,
|
|
5022
|
+
toolName = "createRecord",
|
|
5023
|
+
toolCallId,
|
|
5024
|
+
onToolAction
|
|
5025
|
+
}) {
|
|
5026
|
+
const apiClient = useApiClient();
|
|
5027
|
+
const [loading, setLoading] = useState(false);
|
|
5028
|
+
const [submitted, setSubmitted] = useState(false);
|
|
5029
|
+
const [resultMessage, setResultMessage] = useState("");
|
|
5030
|
+
const [resultError, setResultError] = useState(false);
|
|
5031
|
+
const parsedRecord = useMemo(() => safeParse(record), [record]);
|
|
5032
|
+
const parsedRecords = useMemo(() => {
|
|
5033
|
+
const parsed = safeParse(records);
|
|
5034
|
+
return Array.isArray(parsed) ? parsed : null;
|
|
5035
|
+
}, [records]);
|
|
5036
|
+
const isBatch = parsedRecords != null && parsedRecords.length > 0;
|
|
5037
|
+
const recordCount = isBatch ? parsedRecords.length : 1;
|
|
5038
|
+
const parsedData = isBatch ? parsedRecords : parsedRecord;
|
|
5039
|
+
const generatedSchema = useMemo(() => {
|
|
5040
|
+
if (!parsedData) return null;
|
|
5041
|
+
return generateSchemaFromValue(parsedData);
|
|
5042
|
+
}, [parsedData]);
|
|
5043
|
+
const handleApprove = useCallback(async () => {
|
|
5044
|
+
setLoading(true);
|
|
5045
|
+
setResultError(false);
|
|
5046
|
+
try {
|
|
5047
|
+
const metaRes = await apiClient.get(`/dev/data-sources/${dataSourceId}`);
|
|
5048
|
+
if (!metaRes.success || !metaRes.data) {
|
|
5049
|
+
throw new Error("Data source metadata not available");
|
|
5050
|
+
}
|
|
5051
|
+
const ds = metaRes.data;
|
|
5052
|
+
const appSlug = ds.app_slug || ds.app?.slug;
|
|
5053
|
+
const dsSlug = ds.slug;
|
|
5054
|
+
if (!appSlug || !dsSlug) {
|
|
5055
|
+
throw new Error("Data source metadata not available");
|
|
5056
|
+
}
|
|
5057
|
+
const endpoint = `/apps/${appSlug}/data-sources/${dsSlug}/items`;
|
|
5058
|
+
let result;
|
|
5059
|
+
if (isBatch) {
|
|
5060
|
+
result = await apiClient.post(endpoint, { records: parsedRecords });
|
|
5061
|
+
} else {
|
|
5062
|
+
result = await apiClient.post(endpoint, parsedRecord);
|
|
5063
|
+
}
|
|
5064
|
+
if (!result.success) {
|
|
5065
|
+
throw new Error(
|
|
5066
|
+
typeof result.error === "string" ? result.error : "Failed to create record(s)"
|
|
5067
|
+
);
|
|
5068
|
+
}
|
|
5069
|
+
setSubmitted(true);
|
|
5070
|
+
setResultMessage(
|
|
5071
|
+
isBatch ? `${recordCount} record(s) created successfully` : "Record created successfully"
|
|
5072
|
+
);
|
|
5073
|
+
onToolAction({
|
|
5074
|
+
tool: toolName,
|
|
5075
|
+
toolCallId,
|
|
5076
|
+
decision: "submit",
|
|
5077
|
+
input: {
|
|
5078
|
+
success: true,
|
|
5079
|
+
data: result.data,
|
|
5080
|
+
count: isBatch ? result.data?.length ?? recordCount : 1
|
|
5081
|
+
}
|
|
5082
|
+
});
|
|
5083
|
+
} catch (error) {
|
|
5084
|
+
const message = error instanceof Error ? error.message : "Failed to create record(s)";
|
|
5085
|
+
setResultError(true);
|
|
5086
|
+
setResultMessage(message);
|
|
5087
|
+
onToolAction({
|
|
5088
|
+
tool: toolName,
|
|
5089
|
+
toolCallId,
|
|
5090
|
+
decision: "submit",
|
|
5091
|
+
input: {
|
|
5092
|
+
success: false,
|
|
5093
|
+
error: message
|
|
5094
|
+
}
|
|
5095
|
+
});
|
|
5096
|
+
} finally {
|
|
5097
|
+
setLoading(false);
|
|
5098
|
+
}
|
|
5099
|
+
}, [
|
|
5100
|
+
apiClient,
|
|
5101
|
+
dataSourceId,
|
|
5102
|
+
isBatch,
|
|
5103
|
+
parsedRecord,
|
|
5104
|
+
parsedRecords,
|
|
5105
|
+
recordCount,
|
|
5106
|
+
toolName,
|
|
5107
|
+
toolCallId,
|
|
5108
|
+
onToolAction
|
|
5109
|
+
]);
|
|
5110
|
+
const handleReject = useCallback(() => {
|
|
5111
|
+
setSubmitted(true);
|
|
5112
|
+
setResultMessage("Record creation rejected by user");
|
|
5113
|
+
setResultError(true);
|
|
5114
|
+
onToolAction({
|
|
5115
|
+
tool: toolName,
|
|
5116
|
+
toolCallId,
|
|
5117
|
+
decision: "submit",
|
|
5118
|
+
input: {
|
|
5119
|
+
success: false,
|
|
5120
|
+
error: "User rejected the record creation"
|
|
5121
|
+
}
|
|
5122
|
+
});
|
|
5123
|
+
}, [toolName, toolCallId, onToolAction]);
|
|
5124
|
+
const showActions = state !== "output-available" && !submitted;
|
|
5125
|
+
return /* @__PURE__ */ jsxs("div", { className: "rounded-lg border bg-card p-4 space-y-3", children: [
|
|
5126
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
5127
|
+
/* @__PURE__ */ jsx(PlusCircle, { className: "size-5 text-blue-500" }),
|
|
5128
|
+
/* @__PURE__ */ jsx("h4", { className: "font-medium text-sm", children: isBatch ? `Create ${recordCount} new records` : "Create new record" })
|
|
5129
|
+
] }),
|
|
5130
|
+
parsedData && /* @__PURE__ */ jsx("div", { className: "max-h-80 overflow-auto", children: generatedSchema ? /* @__PURE__ */ jsx(JsonSchemaLayout, { schema: generatedSchema, data: parsedData }) : /* @__PURE__ */ jsx(CodeBlock, { code: JSON.stringify(parsedData, null, 2), language: "json", children: /* @__PURE__ */ jsx(CodeBlockCopyButton, {}) }) }),
|
|
5131
|
+
showActions && /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
5132
|
+
/* @__PURE__ */ jsx(
|
|
5133
|
+
Button,
|
|
5134
|
+
{
|
|
5135
|
+
size: "sm",
|
|
5136
|
+
onClick: handleApprove,
|
|
5137
|
+
disabled: loading,
|
|
5138
|
+
children: loading ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5139
|
+
/* @__PURE__ */ jsx(Loader2, { className: "size-3.5 mr-1.5 animate-spin" }),
|
|
5140
|
+
isBatch ? `Creating ${recordCount} Records\u2026` : "Creating\u2026"
|
|
5141
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5142
|
+
/* @__PURE__ */ jsx(CheckCircle, { className: "size-3.5 mr-1.5" }),
|
|
5143
|
+
isBatch ? `Create ${recordCount} Records` : "Create Record"
|
|
5144
|
+
] })
|
|
5145
|
+
}
|
|
5146
|
+
),
|
|
5147
|
+
/* @__PURE__ */ jsxs(
|
|
5148
|
+
Button,
|
|
5149
|
+
{
|
|
5150
|
+
size: "sm",
|
|
5151
|
+
variant: "outline",
|
|
5152
|
+
onClick: handleReject,
|
|
5153
|
+
disabled: loading,
|
|
5154
|
+
children: [
|
|
5155
|
+
/* @__PURE__ */ jsx(XCircle, { className: "size-3.5 mr-1.5" }),
|
|
5156
|
+
"Reject"
|
|
5157
|
+
]
|
|
5158
|
+
}
|
|
5159
|
+
)
|
|
5160
|
+
] }),
|
|
5161
|
+
resultMessage && /* @__PURE__ */ jsx("div", { className: `text-xs font-medium ${resultError ? "text-destructive" : "text-green-600"}`, children: resultMessage })
|
|
5162
|
+
] });
|
|
5163
|
+
}
|
|
4802
5164
|
function truncateText(text, maxLength) {
|
|
4803
5165
|
if (!text) return "";
|
|
4804
5166
|
return text.length > maxLength ? `${text.substring(0, maxLength)}...` : text;
|
|
@@ -6734,6 +7096,20 @@ function GenerativeUITool({
|
|
|
6734
7096
|
}
|
|
6735
7097
|
) });
|
|
6736
7098
|
}
|
|
7099
|
+
if (toolName === "createRecord") {
|
|
7100
|
+
return /* @__PURE__ */ jsx("div", { className: "not-prose mb-4 w-full", children: /* @__PURE__ */ jsx(
|
|
7101
|
+
CreateRecord,
|
|
7102
|
+
{
|
|
7103
|
+
dataSourceId: part.input?.dataSourceId,
|
|
7104
|
+
record: part.input?.record,
|
|
7105
|
+
records: part.input?.records,
|
|
7106
|
+
state: part.state,
|
|
7107
|
+
toolName,
|
|
7108
|
+
toolCallId: part.toolCallId,
|
|
7109
|
+
onToolAction
|
|
7110
|
+
}
|
|
7111
|
+
) });
|
|
7112
|
+
}
|
|
6737
7113
|
if (toolName === "showCreateRecordForm" || toolName === "showUpdateRecordForm" || toolName === "showRecordDetailsForm") {
|
|
6738
7114
|
const recordMode = toolName === "showCreateRecordForm" ? "add" : toolName === "showUpdateRecordForm" ? "edit" : "view";
|
|
6739
7115
|
const dataSourceId = part.input?.dataSourceId || part.output?.result?.dataSourceId;
|
|
@@ -7241,7 +7617,12 @@ var DISPLAY_ONLY_TOOLS = /* @__PURE__ */ new Set([
|
|
|
7241
7617
|
"showGeneratedContentOptions",
|
|
7242
7618
|
"createAgentTask"
|
|
7243
7619
|
]);
|
|
7244
|
-
var INTERACTIVE_GENERATIVE_TOOLS = /* @__PURE__ */ new Set([
|
|
7620
|
+
var INTERACTIVE_GENERATIVE_TOOLS = /* @__PURE__ */ new Set([
|
|
7621
|
+
"requestApproval",
|
|
7622
|
+
"previewCode",
|
|
7623
|
+
"requestUserInput",
|
|
7624
|
+
"createRecord"
|
|
7625
|
+
]);
|
|
7245
7626
|
function CopyButton({ text }) {
|
|
7246
7627
|
const { t } = useAssistantTranslation();
|
|
7247
7628
|
const [copied, setCopied] = useState(false);
|
|
@@ -9767,191 +10148,6 @@ function CanvasSpreadsheetView({
|
|
|
9767
10148
|
}
|
|
9768
10149
|
) });
|
|
9769
10150
|
}
|
|
9770
|
-
function getFieldLabel(key, property) {
|
|
9771
|
-
if (property?.title) return property.title;
|
|
9772
|
-
return key.toString().replace(/_/g, " ").replace(/([A-Z])/g, " $1").split(" ").map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(" ").trim();
|
|
9773
|
-
}
|
|
9774
|
-
function formatLabel(key) {
|
|
9775
|
-
return key.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase());
|
|
9776
|
-
}
|
|
9777
|
-
function inferType(value) {
|
|
9778
|
-
if (value === null || value === void 0) return "string";
|
|
9779
|
-
if (Array.isArray(value)) return "array";
|
|
9780
|
-
if (typeof value === "object") return "object";
|
|
9781
|
-
return typeof value;
|
|
9782
|
-
}
|
|
9783
|
-
function formatValue(value, property) {
|
|
9784
|
-
if (value === null || value === void 0) return "\u2014";
|
|
9785
|
-
const type = property?.type;
|
|
9786
|
-
switch (type) {
|
|
9787
|
-
case "boolean":
|
|
9788
|
-
return value ? "Yes" : "No";
|
|
9789
|
-
case "number":
|
|
9790
|
-
case "integer":
|
|
9791
|
-
return String(value);
|
|
9792
|
-
case "string":
|
|
9793
|
-
if (property?.format === "date") return new Date(value).toLocaleDateString();
|
|
9794
|
-
if (property?.format === "date-time") return new Date(value).toLocaleString();
|
|
9795
|
-
if (typeof value === "object") return JSON.stringify(value, null, 2);
|
|
9796
|
-
return String(value);
|
|
9797
|
-
case "array":
|
|
9798
|
-
return Array.isArray(value) ? `${value.length} items` : "\u2014";
|
|
9799
|
-
case "object":
|
|
9800
|
-
return typeof value === "object" ? JSON.stringify(value, null, 2) : "\u2014";
|
|
9801
|
-
default:
|
|
9802
|
-
return String(value);
|
|
9803
|
-
}
|
|
9804
|
-
}
|
|
9805
|
-
function formatNestedObject(value) {
|
|
9806
|
-
if (value === null || value === void 0) return "\u2014";
|
|
9807
|
-
if (typeof value !== "object") return String(value);
|
|
9808
|
-
return Object.entries(value).map(([k, v]) => typeof v === "object" && v !== null ? `${k}: ${JSON.stringify(v)}` : `${k}: ${v}`).join("\n");
|
|
9809
|
-
}
|
|
9810
|
-
function formatNestedArray(value) {
|
|
9811
|
-
if (!Array.isArray(value)) return "\u2014";
|
|
9812
|
-
if (value.length === 0) return "(empty)";
|
|
9813
|
-
if (value.every((item) => typeof item !== "object" || item === null)) return value.join(", ");
|
|
9814
|
-
return `${value.length} items:
|
|
9815
|
-
${JSON.stringify(value[0], null, 2)}${value.length > 1 ? "\n..." : ""}`;
|
|
9816
|
-
}
|
|
9817
|
-
function formatPrimitive(value) {
|
|
9818
|
-
if (value === null || value === void 0) return "\u2014";
|
|
9819
|
-
if (typeof value === "boolean") return value ? "Yes" : "No";
|
|
9820
|
-
return String(value);
|
|
9821
|
-
}
|
|
9822
|
-
function getCitationsForField(basis, fieldKey) {
|
|
9823
|
-
if (!Array.isArray(basis) || basis.length === 0) return [];
|
|
9824
|
-
const entry = basis.find((item) => item.field === fieldKey);
|
|
9825
|
-
return entry?.citations || [];
|
|
9826
|
-
}
|
|
9827
|
-
function JsonSchemaArray({ schema, data, showHeader = true }) {
|
|
9828
|
-
const isEmpty = !data || data.length === 0;
|
|
9829
|
-
const isArrayOfObjects = !isEmpty && (schema?.items?.type === "object" || data.some((item) => typeof item === "object" && item !== null && !Array.isArray(item)));
|
|
9830
|
-
const columns = useMemo(() => {
|
|
9831
|
-
const itemSchema = schema?.items;
|
|
9832
|
-
if (itemSchema?.properties) {
|
|
9833
|
-
const cols = {};
|
|
9834
|
-
Object.keys(itemSchema.properties).forEach((key) => {
|
|
9835
|
-
cols[key] = {
|
|
9836
|
-
label: itemSchema.properties[key]?.title || formatLabel(key),
|
|
9837
|
-
property: itemSchema.properties[key]
|
|
9838
|
-
};
|
|
9839
|
-
});
|
|
9840
|
-
return cols;
|
|
9841
|
-
}
|
|
9842
|
-
if (isArrayOfObjects && data.length > 0) {
|
|
9843
|
-
const allKeys = /* @__PURE__ */ new Set();
|
|
9844
|
-
data.forEach((item) => {
|
|
9845
|
-
if (typeof item === "object" && item !== null) Object.keys(item).forEach((k) => allKeys.add(k));
|
|
9846
|
-
});
|
|
9847
|
-
const cols = {};
|
|
9848
|
-
allKeys.forEach((key) => {
|
|
9849
|
-
cols[key] = {
|
|
9850
|
-
label: formatLabel(key),
|
|
9851
|
-
property: { type: inferType(data[0]?.[key]) }
|
|
9852
|
-
};
|
|
9853
|
-
});
|
|
9854
|
-
return cols;
|
|
9855
|
-
}
|
|
9856
|
-
return {};
|
|
9857
|
-
}, [schema, data, isArrayOfObjects]);
|
|
9858
|
-
return /* @__PURE__ */ jsxs("div", { className: "w-full not-prose", children: [
|
|
9859
|
-
showHeader && schema?.title && /* @__PURE__ */ jsx("div", { className: "text-lg font-semibold text-slate-700 mb-3", children: schema.title }),
|
|
9860
|
-
showHeader && schema?.description && /* @__PURE__ */ jsx("div", { className: "text-sm text-slate-600 mb-3", children: schema.description }),
|
|
9861
|
-
isEmpty ? /* @__PURE__ */ jsx("div", { className: "text-sm text-slate-500 italic py-4", children: "No items" }) : isArrayOfObjects ? /* @__PURE__ */ jsx("div", { className: "overflow-x-auto overflow-hidden shadow-sm rounded-lg border border-slate-200", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-slate-200", children: [
|
|
9862
|
-
/* @__PURE__ */ jsx("thead", { className: "bg-slate-50", children: /* @__PURE__ */ jsx("tr", { children: Object.entries(columns).map(([key, col]) => /* @__PURE__ */ jsx(
|
|
9863
|
-
"th",
|
|
9864
|
-
{
|
|
9865
|
-
className: "px-4 py-3 text-left text-xs font-medium text-slate-700 uppercase tracking-wider",
|
|
9866
|
-
children: col.label
|
|
9867
|
-
},
|
|
9868
|
-
key
|
|
9869
|
-
)) }) }),
|
|
9870
|
-
/* @__PURE__ */ jsx("tbody", { className: "bg-white divide-y divide-slate-200", children: data.map((item, index) => /* @__PURE__ */ jsx("tr", { className: "hover:bg-slate-50", children: Object.entries(columns).map(([key, col]) => /* @__PURE__ */ jsx("td", { className: "px-4 py-3 text-sm text-slate-700", children: col.property?.type === "object" ? /* @__PURE__ */ jsx("div", { className: "text-xs font-mono bg-slate-100 rounded px-2 py-1 whitespace-pre-wrap break-all max-w-xs", children: formatNestedObject(item[key]) }) : col.property?.type === "array" ? /* @__PURE__ */ jsx("div", { className: "text-xs font-mono bg-slate-100 rounded px-2 py-1 whitespace-pre-wrap break-all max-w-xs", children: formatNestedArray(item[key]) }) : /* @__PURE__ */ jsx("span", { className: col.property?.type === "number" || col.property?.type === "integer" ? "font-mono" : "", children: formatValue(item[key], col.property) }) }, key)) }, index)) })
|
|
9871
|
-
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-2", children: data.map((item, index) => /* @__PURE__ */ jsx(
|
|
9872
|
-
"div",
|
|
9873
|
-
{
|
|
9874
|
-
className: "px-3 py-2 bg-white border border-slate-200 rounded-md text-sm text-slate-700",
|
|
9875
|
-
children: formatPrimitive(item)
|
|
9876
|
-
},
|
|
9877
|
-
index
|
|
9878
|
-
)) })
|
|
9879
|
-
] });
|
|
9880
|
-
}
|
|
9881
|
-
function JsonSchemaObject({ schema, data, basis = [] }) {
|
|
9882
|
-
const properties = schema?.properties || {};
|
|
9883
|
-
const required = schema?.required || [];
|
|
9884
|
-
return /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
9885
|
-
schema?.title && /* @__PURE__ */ jsx("div", { className: "text-lg font-semibold text-slate-700 mb-4", children: schema.title }),
|
|
9886
|
-
schema?.description && /* @__PURE__ */ jsx("div", { className: "text-sm text-slate-600 mb-4", children: schema.description }),
|
|
9887
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-4", children: Object.entries(properties).map(([key, property]) => {
|
|
9888
|
-
const isNestedObject = property?.type === "object" && property?.properties;
|
|
9889
|
-
const isArr = property?.type === "array";
|
|
9890
|
-
const citations = getCitationsForField(basis, key);
|
|
9891
|
-
const isReq = required.includes(key);
|
|
9892
|
-
if (isNestedObject) {
|
|
9893
|
-
return /* @__PURE__ */ jsx("div", { className: "border border-slate-200 rounded-lg p-4 bg-slate-50", children: /* @__PURE__ */ jsx(JsonSchemaObject, { schema: property, data: data?.[key] || {}, basis }) }, key);
|
|
9894
|
-
}
|
|
9895
|
-
if (isArr) {
|
|
9896
|
-
return /* @__PURE__ */ jsxs("div", { className: "border border-slate-200 rounded-lg p-4 bg-slate-50", children: [
|
|
9897
|
-
property?.title && /* @__PURE__ */ jsx("div", { className: "text-sm font-medium text-slate-700 mb-2", children: property.title }),
|
|
9898
|
-
/* @__PURE__ */ jsx(JsonSchemaArray, { schema: property, data: data?.[key] || [], showHeader: false })
|
|
9899
|
-
] }, key);
|
|
9900
|
-
}
|
|
9901
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
9902
|
-
/* @__PURE__ */ jsx("label", { className: `text-sm font-medium text-slate-700 mb-1${isReq ? " after:content-['*'] after:ml-0.5 after:text-red-500" : ""}`, children: getFieldLabel(key, property) }),
|
|
9903
|
-
property?.description && /* @__PURE__ */ jsx("div", { className: "text-xs text-slate-500 mb-1", children: property.description }),
|
|
9904
|
-
/* @__PURE__ */ jsx("div", { className: `px-3 py-2 bg-white border border-slate-300 rounded-md text-sm text-slate-700${property?.type === "number" || property?.type === "integer" ? " font-mono" : ""}`, children: formatValue(data?.[key], property) }),
|
|
9905
|
-
citations.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mt-2 text-xs text-slate-600 bg-slate-50 border border-slate-200 rounded-md p-3", children: [
|
|
9906
|
-
/* @__PURE__ */ jsxs("div", { className: "font-medium text-slate-700 mb-2 flex items-center gap-1", children: [
|
|
9907
|
-
/* @__PURE__ */ jsx("svg", { className: "w-3 h-3", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsx(
|
|
9908
|
-
"path",
|
|
9909
|
-
{
|
|
9910
|
-
fillRule: "evenodd",
|
|
9911
|
-
d: "M12.586 4.586a2 2 0 112.828 2.828l-3 3a2 2 0 01-2.828 0 1 1 0 00-1.414 1.414 4 4 0 005.656 0l3-3a4 4 0 00-5.656-5.656l-1.5 1.5a1 1 0 101.414 1.414l1.5-1.5zm-5 5a2 2 0 012.828 0 1 1 0 101.414-1.414 4 4 0 00-5.656 0l-3 3a4 4 0 105.656 5.656l1.5-1.5a1 1 0 10-1.414-1.414l-1.5 1.5a2 2 0 11-2.828-2.828l3-3z",
|
|
9912
|
-
clipRule: "evenodd"
|
|
9913
|
-
}
|
|
9914
|
-
) }),
|
|
9915
|
-
"Sources (",
|
|
9916
|
-
citations.length,
|
|
9917
|
-
")"
|
|
9918
|
-
] }),
|
|
9919
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-2", children: citations.map((citation, idx) => /* @__PURE__ */ jsxs("div", { className: "flex gap-2 scroll-mt-4", children: [
|
|
9920
|
-
/* @__PURE__ */ jsxs("span", { className: "font-mono text-slate-500", children: [
|
|
9921
|
-
"[",
|
|
9922
|
-
idx + 1,
|
|
9923
|
-
"]"
|
|
9924
|
-
] }),
|
|
9925
|
-
/* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
9926
|
-
/* @__PURE__ */ jsx(
|
|
9927
|
-
"a",
|
|
9928
|
-
{
|
|
9929
|
-
href: citation.url,
|
|
9930
|
-
target: "_blank",
|
|
9931
|
-
rel: "noopener noreferrer",
|
|
9932
|
-
className: "text-blue-600 hover:text-blue-800 hover:underline break-all truncate block",
|
|
9933
|
-
children: citation.url
|
|
9934
|
-
}
|
|
9935
|
-
),
|
|
9936
|
-
citation.excerpts && citation.excerpts.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mt-1 text-slate-600 italic truncate", children: [
|
|
9937
|
-
'"',
|
|
9938
|
-
citation.excerpts[0],
|
|
9939
|
-
'"'
|
|
9940
|
-
] })
|
|
9941
|
-
] })
|
|
9942
|
-
] }, idx)) })
|
|
9943
|
-
] })
|
|
9944
|
-
] }, key);
|
|
9945
|
-
}) })
|
|
9946
|
-
] });
|
|
9947
|
-
}
|
|
9948
|
-
function JsonSchemaLayout({ schema, data, basis = [] }) {
|
|
9949
|
-
const schemaType = schema?.type || (Array.isArray(data) ? "array" : "object");
|
|
9950
|
-
if (schemaType === "array") {
|
|
9951
|
-
return /* @__PURE__ */ jsx(JsonSchemaArray, { schema, data });
|
|
9952
|
-
}
|
|
9953
|
-
return /* @__PURE__ */ jsx(JsonSchemaObject, { schema, data, basis });
|
|
9954
|
-
}
|
|
9955
10151
|
function CanvasDeepResearchView({
|
|
9956
10152
|
title,
|
|
9957
10153
|
output_schema,
|
|
@@ -10505,7 +10701,7 @@ var buttonVariants = cva(
|
|
|
10505
10701
|
}
|
|
10506
10702
|
}
|
|
10507
10703
|
);
|
|
10508
|
-
var
|
|
10704
|
+
var Button13 = withTooltip(({
|
|
10509
10705
|
active,
|
|
10510
10706
|
asChild = false,
|
|
10511
10707
|
children,
|
|
@@ -11113,7 +11309,7 @@ function AIMenu() {
|
|
|
11113
11309
|
}
|
|
11114
11310
|
),
|
|
11115
11311
|
/* @__PURE__ */ jsx(
|
|
11116
|
-
|
|
11312
|
+
Button13,
|
|
11117
11313
|
{
|
|
11118
11314
|
className: "no-focus-ring mt-1 shrink-0",
|
|
11119
11315
|
disabled: !isLoading && input.trim().length === 0,
|
|
@@ -11987,7 +12183,7 @@ function Comment(props) {
|
|
|
11987
12183
|
] }),
|
|
11988
12184
|
isMyComment && (hovering || dropdownOpen) && /* @__PURE__ */ jsxs("div", { className: "absolute top-0 right-0 flex space-x-1", children: [
|
|
11989
12185
|
index === 0 && /* @__PURE__ */ jsx(
|
|
11990
|
-
|
|
12186
|
+
Button13,
|
|
11991
12187
|
{
|
|
11992
12188
|
className: "h-6 p-1 text-muted-foreground",
|
|
11993
12189
|
onClick: onResolveComment,
|
|
@@ -12036,7 +12232,7 @@ function Comment(props) {
|
|
|
12036
12232
|
),
|
|
12037
12233
|
isEditing && /* @__PURE__ */ jsxs("div", { className: "ml-auto flex shrink-0 gap-1", children: [
|
|
12038
12234
|
/* @__PURE__ */ jsx(
|
|
12039
|
-
|
|
12235
|
+
Button13,
|
|
12040
12236
|
{
|
|
12041
12237
|
className: "size-[28px]",
|
|
12042
12238
|
onClick: (e) => {
|
|
@@ -12049,7 +12245,7 @@ function Comment(props) {
|
|
|
12049
12245
|
}
|
|
12050
12246
|
),
|
|
12051
12247
|
/* @__PURE__ */ jsx(
|
|
12052
|
-
|
|
12248
|
+
Button13,
|
|
12053
12249
|
{
|
|
12054
12250
|
onClick: (e) => {
|
|
12055
12251
|
e.stopPropagation();
|
|
@@ -12117,7 +12313,7 @@ function CommentMoreDropdown(props) {
|
|
|
12117
12313
|
onOpenChange: setDropdownOpen,
|
|
12118
12314
|
open: dropdownOpen,
|
|
12119
12315
|
children: [
|
|
12120
|
-
/* @__PURE__ */ jsx(DropdownMenuTrigger3, { asChild: true, onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx(
|
|
12316
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger3, { asChild: true, onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx(Button13, { className: cn("h-6 p-1 text-muted-foreground"), variant: "ghost", children: /* @__PURE__ */ jsx(MoreHorizontalIcon, { className: "size-4" }) }) }),
|
|
12121
12317
|
/* @__PURE__ */ jsx(
|
|
12122
12318
|
DropdownMenuContent3,
|
|
12123
12319
|
{
|
|
@@ -12289,7 +12485,7 @@ function CommentCreateForm({
|
|
|
12289
12485
|
}
|
|
12290
12486
|
),
|
|
12291
12487
|
/* @__PURE__ */ jsx(
|
|
12292
|
-
|
|
12488
|
+
Button13,
|
|
12293
12489
|
{
|
|
12294
12490
|
className: "absolute right-0 bottom-0 ml-auto shrink-0",
|
|
12295
12491
|
disabled: commentContent.trim().length === 0,
|
|
@@ -12623,7 +12819,7 @@ function BlockSuggestionCard({
|
|
|
12623
12819
|
)),
|
|
12624
12820
|
hovering && /* @__PURE__ */ jsxs("div", { className: "absolute top-4 right-4 flex gap-2", children: [
|
|
12625
12821
|
/* @__PURE__ */ jsx(
|
|
12626
|
-
|
|
12822
|
+
Button13,
|
|
12627
12823
|
{
|
|
12628
12824
|
variant: "ghost",
|
|
12629
12825
|
className: "size-6 p-1 text-muted-foreground",
|
|
@@ -12632,7 +12828,7 @@ function BlockSuggestionCard({
|
|
|
12632
12828
|
}
|
|
12633
12829
|
),
|
|
12634
12830
|
/* @__PURE__ */ jsx(
|
|
12635
|
-
|
|
12831
|
+
Button13,
|
|
12636
12832
|
{
|
|
12637
12833
|
variant: "ghost",
|
|
12638
12834
|
className: "size-6 p-1 text-muted-foreground",
|
|
@@ -13102,7 +13298,7 @@ var BlockCommentsContent = ({
|
|
|
13102
13298
|
}
|
|
13103
13299
|
),
|
|
13104
13300
|
totalCount > 0 && /* @__PURE__ */ jsx("div", { className: "relative left-0 size-0 select-none", children: /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
13105
|
-
|
|
13301
|
+
Button13,
|
|
13106
13302
|
{
|
|
13107
13303
|
className: "mt-1 ml-1 flex h-6 gap-1 px-1.5 py-0 text-muted-foreground/80 hover:text-muted-foreground/80 data-[active=true]:bg-muted",
|
|
13108
13304
|
contentEditable: false,
|
|
@@ -15018,7 +15214,7 @@ function BlockActionButton({
|
|
|
15018
15214
|
const editor = useEditorRef();
|
|
15019
15215
|
const element = useElement();
|
|
15020
15216
|
return /* @__PURE__ */ jsx(
|
|
15021
|
-
|
|
15217
|
+
Button13,
|
|
15022
15218
|
{
|
|
15023
15219
|
className: cn(
|
|
15024
15220
|
defaultStyles && "absolute top-1 right-1 opacity-0 transition-opacity group-hover:opacity-100",
|
|
@@ -15357,7 +15553,7 @@ function EmojiPickerSearchAndClear({
|
|
|
15357
15553
|
}
|
|
15358
15554
|
),
|
|
15359
15555
|
searchValue && /* @__PURE__ */ jsx(
|
|
15360
|
-
|
|
15556
|
+
Button13,
|
|
15361
15557
|
{
|
|
15362
15558
|
"aria-label": "Clear",
|
|
15363
15559
|
className: cn(
|
|
@@ -15446,7 +15642,7 @@ function EmojiPickerNavigation({
|
|
|
15446
15642
|
id: "emoji-nav",
|
|
15447
15643
|
children: /* @__PURE__ */ jsxs("div", { className: "relative flex items-center", children: [
|
|
15448
15644
|
emojiLibrary.getGrid().sections().map(({ id }) => /* @__PURE__ */ jsx(
|
|
15449
|
-
|
|
15645
|
+
Button13,
|
|
15450
15646
|
{
|
|
15451
15647
|
"aria-label": i18n.categories[id],
|
|
15452
15648
|
className: cn(
|
|
@@ -15608,7 +15804,7 @@ function CalloutElement(props) {
|
|
|
15608
15804
|
{
|
|
15609
15805
|
...emojiToolbarDropdownProps,
|
|
15610
15806
|
control: /* @__PURE__ */ jsx(
|
|
15611
|
-
|
|
15807
|
+
Button13,
|
|
15612
15808
|
{
|
|
15613
15809
|
className: "size-6 select-none p-1 text-[18px] hover:bg-muted-foreground/15",
|
|
15614
15810
|
contentEditable: false,
|
|
@@ -15847,7 +16043,7 @@ function CodeBlockElement(props) {
|
|
|
15847
16043
|
contentEditable: false,
|
|
15848
16044
|
children: [
|
|
15849
16045
|
/* @__PURE__ */ jsxs(
|
|
15850
|
-
|
|
16046
|
+
Button13,
|
|
15851
16047
|
{
|
|
15852
16048
|
className: "relative top-0 right-0 w-auto",
|
|
15853
16049
|
onClick: () => {
|
|
@@ -15892,7 +16088,7 @@ function CodeBlockCombobox({ className }) {
|
|
|
15892
16088
|
if (readOnly) return null;
|
|
15893
16089
|
return /* @__PURE__ */ jsxs(Popover, { onOpenChange: setOpen, open, children: [
|
|
15894
16090
|
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
15895
|
-
|
|
16091
|
+
Button13,
|
|
15896
16092
|
{
|
|
15897
16093
|
"aria-expanded": open,
|
|
15898
16094
|
className: cn(
|
|
@@ -16253,7 +16449,7 @@ function Draggable(props) {
|
|
|
16253
16449
|
),
|
|
16254
16450
|
children: [
|
|
16255
16451
|
/* @__PURE__ */ jsx(
|
|
16256
|
-
|
|
16452
|
+
Button13,
|
|
16257
16453
|
{
|
|
16258
16454
|
className: "absolute right-0 h-6 w-6 p-0",
|
|
16259
16455
|
"data-plate-prevent-deselect": true,
|
|
@@ -16440,7 +16636,7 @@ var DraggableInsertHandle = () => {
|
|
|
16440
16636
|
const editor = useEditorRef();
|
|
16441
16637
|
const element = useElement();
|
|
16442
16638
|
return /* @__PURE__ */ jsx(
|
|
16443
|
-
|
|
16639
|
+
Button13,
|
|
16444
16640
|
{
|
|
16445
16641
|
className: "size-6 shrink-0 p-1",
|
|
16446
16642
|
onClick: (event) => {
|
|
@@ -17671,7 +17867,7 @@ function EquationPopoverContent({
|
|
|
17671
17867
|
...props
|
|
17672
17868
|
}
|
|
17673
17869
|
),
|
|
17674
|
-
/* @__PURE__ */ jsxs(
|
|
17870
|
+
/* @__PURE__ */ jsxs(Button13, { className: "px-3", onClick: onClose, variant: "brand", children: [
|
|
17675
17871
|
"Done ",
|
|
17676
17872
|
/* @__PURE__ */ jsx(CornerDownLeftIcon, { className: "size-3.5" })
|
|
17677
17873
|
] })
|
|
@@ -18549,7 +18745,7 @@ function MediaPlaceholderPopover({ children }) {
|
|
|
18549
18745
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "password", children: "Embed link" })
|
|
18550
18746
|
] }),
|
|
18551
18747
|
/* @__PURE__ */ jsxs(TabsContent, { className: "w-[300px] px-3 py-2", value: "account", children: [
|
|
18552
|
-
/* @__PURE__ */ jsx(
|
|
18748
|
+
/* @__PURE__ */ jsx(Button13, { className: "w-full", onClick: openFilePicker, variant: "brand", children: currentMedia.buttonText }),
|
|
18553
18749
|
/* @__PURE__ */ jsx("div", { className: "mt-3 text-muted-foreground text-xs", children: "The maximum size per file is 5MB" })
|
|
18554
18750
|
] }),
|
|
18555
18751
|
/* @__PURE__ */ jsxs(
|
|
@@ -18567,7 +18763,7 @@ function MediaPlaceholderPopover({ children }) {
|
|
|
18567
18763
|
}
|
|
18568
18764
|
),
|
|
18569
18765
|
/* @__PURE__ */ jsx(
|
|
18570
|
-
|
|
18766
|
+
Button13,
|
|
18571
18767
|
{
|
|
18572
18768
|
className: "mt-2 w-full max-w-[300px]",
|
|
18573
18769
|
onClick: () => onEmbed(embedValue),
|
|
@@ -18687,12 +18883,12 @@ function ImagePreview() {
|
|
|
18687
18883
|
onClick: (e) => e.stopPropagation(),
|
|
18688
18884
|
children: [
|
|
18689
18885
|
!prevDisabled && !nextDisabled && /* @__PURE__ */ jsxs("div", { className: "flex rounded-sm bg-black/70", children: [
|
|
18690
|
-
/* @__PURE__ */ jsx(
|
|
18691
|
-
/* @__PURE__ */ jsx(
|
|
18886
|
+
/* @__PURE__ */ jsx(Button13, { ...prevProps, disabled: prevDisabled, children: /* @__PURE__ */ jsx(ArrowLeftIcon, { className: "size-5" }) }),
|
|
18887
|
+
/* @__PURE__ */ jsx(Button13, { ...nextProps, disabled: nextDisabled, children: /* @__PURE__ */ jsx(ArrowRightIcon, { className: "size-5" }) })
|
|
18692
18888
|
] }),
|
|
18693
18889
|
currentPreview && /* @__PURE__ */ jsxs("div", { className: "flex rounded-sm bg-black/70", children: [
|
|
18694
18890
|
/* @__PURE__ */ jsx(
|
|
18695
|
-
|
|
18891
|
+
Button13,
|
|
18696
18892
|
{
|
|
18697
18893
|
...zommOutProps,
|
|
18698
18894
|
disabled: zoomOutDisabled,
|
|
@@ -18705,7 +18901,7 @@ function ImagePreview() {
|
|
|
18705
18901
|
/* @__PURE__ */ jsx("div", { children: "%" })
|
|
18706
18902
|
] }),
|
|
18707
18903
|
/* @__PURE__ */ jsx(
|
|
18708
|
-
|
|
18904
|
+
Button13,
|
|
18709
18905
|
{
|
|
18710
18906
|
...zoomInProps,
|
|
18711
18907
|
disabled: zoomInDisabled,
|
|
@@ -18714,7 +18910,7 @@ function ImagePreview() {
|
|
|
18714
18910
|
}
|
|
18715
18911
|
),
|
|
18716
18912
|
/* @__PURE__ */ jsx(
|
|
18717
|
-
|
|
18913
|
+
Button13,
|
|
18718
18914
|
{
|
|
18719
18915
|
onClick: () => {
|
|
18720
18916
|
void downloadFile(currentPreview.url, currentPreview.id);
|
|
@@ -18723,7 +18919,7 @@ function ImagePreview() {
|
|
|
18723
18919
|
children: /* @__PURE__ */ jsx(CircleArrowDown, { className: "size-4" })
|
|
18724
18920
|
}
|
|
18725
18921
|
),
|
|
18726
|
-
/* @__PURE__ */ jsx(
|
|
18922
|
+
/* @__PURE__ */ jsx(Button13, { ...closeProps, tooltip: "Close", children: /* @__PURE__ */ jsx(Minimize2, { className: "size-4" }) })
|
|
18727
18923
|
] })
|
|
18728
18924
|
]
|
|
18729
18925
|
}
|
|
@@ -19363,7 +19559,7 @@ var TableElement = withHOC(
|
|
|
19363
19559
|
"group-has-[tr:last-child:hover]/table:opacity-100 max-sm:group-has-[tr[data-selected]:last-child]/table:opacity-100"
|
|
19364
19560
|
),
|
|
19365
19561
|
children: /* @__PURE__ */ jsx(
|
|
19366
|
-
|
|
19562
|
+
Button13,
|
|
19367
19563
|
{
|
|
19368
19564
|
className: "flex h-4 w-full grow items-center justify-center bg-muted",
|
|
19369
19565
|
onClick: () => tf.insert.tableRow({ at: editor.api.findPath(element) }),
|
|
@@ -19385,7 +19581,7 @@ var TableElement = withHOC(
|
|
|
19385
19581
|
"group-has-[td:last-child:hover,th:last-child:hover]/table:opacity-100 max-sm:group-has-[td[data-selected]:last-child,th[data-selected]:last-child]/table:opacity-100"
|
|
19386
19582
|
),
|
|
19387
19583
|
children: /* @__PURE__ */ jsx(
|
|
19388
|
-
|
|
19584
|
+
Button13,
|
|
19389
19585
|
{
|
|
19390
19586
|
className: "flex h-full w-4 grow items-center justify-center bg-muted",
|
|
19391
19587
|
onClick: () => tf.insert.tableColumn({
|
|
@@ -19409,7 +19605,7 @@ var TableElement = withHOC(
|
|
|
19409
19605
|
"group-has-[td:last-child:hover,th:last-child:hover]/table:group-has-[tr:last-child:hover]/table:opacity-100 max-sm:group-has-[td[data-selected]:last-child,th[data-selected]:last-child]/table:group-has-[tr[data-selected]:last-child]/table:opacity-100"
|
|
19410
19606
|
),
|
|
19411
19607
|
children: /* @__PURE__ */ jsx(
|
|
19412
|
-
|
|
19608
|
+
Button13,
|
|
19413
19609
|
{
|
|
19414
19610
|
className: "flex size-4 items-center justify-center rounded-full bg-muted",
|
|
19415
19611
|
onClick: () => {
|
|
@@ -19615,7 +19811,7 @@ function TocElement(props) {
|
|
|
19615
19811
|
const { headingList } = state;
|
|
19616
19812
|
return /* @__PURE__ */ jsxs(PlateElement, { ...props, className: "my-1", children: [
|
|
19617
19813
|
/* @__PURE__ */ jsx("div", { contentEditable: false, children: headingList.length > 0 ? headingList.map((item) => /* @__PURE__ */ jsx(
|
|
19618
|
-
|
|
19814
|
+
Button13,
|
|
19619
19815
|
{
|
|
19620
19816
|
"aria-current": true,
|
|
19621
19817
|
className: headingItemVariants({ depth: item.depth }),
|
|
@@ -20717,7 +20913,7 @@ function TocElementStatic(props) {
|
|
|
20717
20913
|
const headingList = getHeadingList(editor);
|
|
20718
20914
|
return /* @__PURE__ */ jsxs(SlateElement, { ...props, className: "mb-1 p-0", children: [
|
|
20719
20915
|
/* @__PURE__ */ jsx("div", { children: headingList.length > 0 ? headingList.map((item) => /* @__PURE__ */ jsx(
|
|
20720
|
-
|
|
20916
|
+
Button13,
|
|
20721
20917
|
{
|
|
20722
20918
|
className: headingItemVariants2({ depth: item.depth }),
|
|
20723
20919
|
variant: "ghost",
|