@chatsdk-dev/elements 0.0.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 +43 -0
- package/dist/chunk-2LHKM7RD.js +14 -0
- package/dist/chunk-5UMYP6MD.js +10 -0
- package/dist/chunk-AP4MG32M.js +36 -0
- package/dist/chunk-CFM57HOS.js +358 -0
- package/dist/chunk-EGIUE7H2.js +37 -0
- package/dist/chunk-M5OONVIO.js +90 -0
- package/dist/chunk-MXTBCHYC.js +31 -0
- package/dist/chunk-NIC3MOMY.js +55 -0
- package/dist/chunk-QTRMNIG3.js +83 -0
- package/dist/chunk-R7G3RQLU.js +36 -0
- package/dist/chunk-RJG5D2TM.js +113 -0
- package/dist/chunk-SLJNKQ2G.js +125 -0
- package/dist/chunk-TDEFIW2L.js +9 -0
- package/dist/chunk-TDP6D7U7.js +551 -0
- package/dist/chunk-V2ITXC65.js +24 -0
- package/dist/chunk-VS55HRUS.js +16 -0
- package/dist/chunk-VYDYCGJL.js +25 -0
- package/dist/chunk-X5YUF2YM.js +113 -0
- package/dist/chunk-YX46JVQN.js +78 -0
- package/dist/chunk-YXAMLTTT.js +16 -0
- package/dist/chunk-YXFVHSY4.js +51 -0
- package/dist/chunk-ZCSZX3OI.js +4 -0
- package/dist/common/use-copy-to-clipboard.d.ts +3 -0
- package/dist/common/use-copy-to-clipboard.js +33 -0
- package/dist/common/utilts.d.ts +8 -0
- package/dist/common/utilts.js +28 -0
- package/dist/components/ai-elements/actions.d.ts +13 -0
- package/dist/components/ai-elements/actions.js +42 -0
- package/dist/components/ai-elements/agent.d.ts +31 -0
- package/dist/components/ai-elements/agent.js +77 -0
- package/dist/components/ai-elements/artifact.d.ts +27 -0
- package/dist/components/ai-elements/artifact.js +108 -0
- package/dist/components/ai-elements/attachments.d.ts +57 -0
- package/dist/components/ai-elements/attachments.js +258 -0
- package/dist/components/ai-elements/audio-player.d.ts +33 -0
- package/dist/components/ai-elements/audio-player.js +199 -0
- package/dist/components/ai-elements/canvas.d.ts +10 -0
- package/dist/components/ai-elements/canvas.js +24 -0
- package/dist/components/ai-elements/chain-of-thought.d.ts +34 -0
- package/dist/components/ai-elements/chain-of-thought.js +159 -0
- package/dist/components/ai-elements/checkpoint.d.ts +16 -0
- package/dist/components/ai-elements/checkpoint.js +47 -0
- package/dist/components/ai-elements/code-block.d.ts +48 -0
- package/dist/components/ai-elements/code-block.js +1 -0
- package/dist/components/ai-elements/commit.d.ts +68 -0
- package/dist/components/ai-elements/commit.js +314 -0
- package/dist/components/ai-elements/confirmation.d.ts +52 -0
- package/dist/components/ai-elements/confirmation.js +76 -0
- package/dist/components/ai-elements/connection.d.ts +5 -0
- package/dist/components/ai-elements/connection.js +34 -0
- package/dist/components/ai-elements/context.d.ts +36 -0
- package/dist/components/ai-elements/context.js +320 -0
- package/dist/components/ai-elements/controls.d.ts +8 -0
- package/dist/components/ai-elements/controls.js +17 -0
- package/dist/components/ai-elements/conversation.d.ts +27 -0
- package/dist/components/ai-elements/conversation.js +119 -0
- package/dist/components/ai-elements/edge.d.ts +9 -0
- package/dist/components/ai-elements/edge.js +111 -0
- package/dist/components/ai-elements/environment-variables.d.ts +42 -0
- package/dist/components/ai-elements/environment-variables.js +208 -0
- package/dist/components/ai-elements/file-tree.d.ts +30 -0
- package/dist/components/ai-elements/file-tree.js +212 -0
- package/dist/components/ai-elements/image.d.ts +10 -0
- package/dist/components/ai-elements/image.js +23 -0
- package/dist/components/ai-elements/inline-citation.d.ts +42 -0
- package/dist/components/ai-elements/inline-citation.js +203 -0
- package/dist/components/ai-elements/jsx-preview.d.ts +33 -0
- package/dist/components/ai-elements/jsx-preview.js +206 -0
- package/dist/components/ai-elements/loader.d.ts +9 -0
- package/dist/components/ai-elements/loader.js +115 -0
- package/dist/components/ai-elements/message.d.ts +42 -0
- package/dist/components/ai-elements/message.js +259 -0
- package/dist/components/ai-elements/mic-selector.d.ts +49 -0
- package/dist/components/ai-elements/mic-selector.js +252 -0
- package/dist/components/ai-elements/model-selector.d.ts +39 -0
- package/dist/components/ai-elements/model-selector.js +73 -0
- package/dist/components/ai-elements/node.d.ts +25 -0
- package/dist/components/ai-elements/node.js +41 -0
- package/dist/components/ai-elements/open-in-chat.d.ts +32 -0
- package/dist/components/ai-elements/open-in-chat.js +366 -0
- package/dist/components/ai-elements/package-info.d.ts +32 -0
- package/dist/components/ai-elements/package-info.js +162 -0
- package/dist/components/ai-elements/panel.d.ts +8 -0
- package/dist/components/ai-elements/panel.js +17 -0
- package/dist/components/ai-elements/persona.d.ts +50 -0
- package/dist/components/ai-elements/persona.js +209 -0
- package/dist/components/ai-elements/plan.d.ts +29 -0
- package/dist/components/ai-elements/plan.js +95 -0
- package/dist/components/ai-elements/prompt-input.d.ts +153 -0
- package/dist/components/ai-elements/prompt-input.js +939 -0
- package/dist/components/ai-elements/queue.d.ts +65 -0
- package/dist/components/ai-elements/queue.js +179 -0
- package/dist/components/ai-elements/reasoning.d.ts +30 -0
- package/dist/components/ai-elements/reasoning.js +161 -0
- package/dist/components/ai-elements/response.d.ts +9 -0
- package/dist/components/ai-elements/response.js +33 -0
- package/dist/components/ai-elements/sandbox.d.ts +28 -0
- package/dist/components/ai-elements/sandbox.js +98 -0
- package/dist/components/ai-elements/schema-display.d.ts +58 -0
- package/dist/components/ai-elements/schema-display.js +313 -0
- package/dist/components/ai-elements/shimmer.d.ts +14 -0
- package/dist/components/ai-elements/shimmer.js +1 -0
- package/dist/components/ai-elements/snippet.d.ts +22 -0
- package/dist/components/ai-elements/snippet.js +90 -0
- package/dist/components/ai-elements/sources.d.ts +16 -0
- package/dist/components/ai-elements/sources.js +62 -0
- package/dist/components/ai-elements/speech-input.d.ts +57 -0
- package/dist/components/ai-elements/speech-input.js +206 -0
- package/dist/components/ai-elements/stack-trace.d.ts +42 -0
- package/dist/components/ai-elements/stack-trace.js +377 -0
- package/dist/components/ai-elements/suggestion.d.ts +14 -0
- package/dist/components/ai-elements/suggestion.js +41 -0
- package/dist/components/ai-elements/task.d.ts +18 -0
- package/dist/components/ai-elements/task.js +60 -0
- package/dist/components/ai-elements/terminal.d.ts +31 -0
- package/dist/components/ai-elements/terminal.js +203 -0
- package/dist/components/ai-elements/test-results.d.ts +61 -0
- package/dist/components/ai-elements/test-results.js +349 -0
- package/dist/components/ai-elements/tool.d.ts +35 -0
- package/dist/components/ai-elements/tool.js +2 -0
- package/dist/components/ai-elements/toolbar.d.ts +8 -0
- package/dist/components/ai-elements/toolbar.js +18 -0
- package/dist/components/ai-elements/transcription.d.ts +19 -0
- package/dist/components/ai-elements/transcription.js +90 -0
- package/dist/components/ai-elements/voice-selector.d.ts +66 -0
- package/dist/components/ai-elements/voice-selector.js +332 -0
- package/dist/components/ai-elements/web-preview.d.ts +38 -0
- package/dist/components/ai-elements/web-preview.js +214 -0
- package/dist/components/info-card.d.ts +14 -0
- package/dist/components/info-card.js +1 -0
- package/dist/components/responsive-alert-dialog.d.ts +19 -0
- package/dist/components/responsive-alert-dialog.js +1 -0
- package/dist/components/responsive-dialog.d.ts +14 -0
- package/dist/components/responsive-dialog.js +1 -0
- package/dist/config-IcWUmjwj.d.ts +239 -0
- package/dist/features/chat/chat-card.d.ts +5 -0
- package/dist/features/chat/chat-card.js +14 -0
- package/dist/features/chat/chat-element/chat-element.d.ts +8 -0
- package/dist/features/chat/chat-element/chat-element.js +14 -0
- package/dist/features/chat/chat-element/use-chat.d.ts +21 -0
- package/dist/features/chat/chat-element/use-chat.js +14 -0
- package/dist/features/chat/chat-element/use-initial-messages.d.ts +20 -0
- package/dist/features/chat/chat-element/use-initial-messages.js +14 -0
- package/dist/features/chat/chat-header/chat-header.d.ts +8 -0
- package/dist/features/chat/chat-header/chat-header.js +14 -0
- package/dist/features/chat/chat-header/chat-menu.d.ts +5 -0
- package/dist/features/chat/chat-header/chat-menu.js +2 -0
- package/dist/features/chat/chat-history/chat-history-empty.d.ts +5 -0
- package/dist/features/chat/chat-history/chat-history-empty.js +1 -0
- package/dist/features/chat/chat-history/chat-history.d.ts +5 -0
- package/dist/features/chat/chat-history/chat-history.js +14 -0
- package/dist/features/chat/chat-message.d.ts +10 -0
- package/dist/features/chat/chat-message.js +1 -0
- package/dist/features/chat/chat-molecule.d.ts +35 -0
- package/dist/features/chat/chat-molecule.js +14 -0
- package/dist/features/chat/chat-prompt-input.d.ts +16 -0
- package/dist/features/chat/chat-prompt-input.js +14 -0
- package/dist/features/chat/chat.context.d.ts +26 -0
- package/dist/features/chat/chat.context.js +13 -0
- package/dist/features/chat/index.d.ts +14 -0
- package/dist/features/chat/index.js +14 -0
- package/dist/features/chat/queries/query-keys.d.ts +8 -0
- package/dist/features/chat/queries/query-keys.js +1 -0
- package/dist/features/chat/queries/use-create-conversation-mutation.d.ts +29 -0
- package/dist/features/chat/queries/use-create-conversation-mutation.js +38 -0
- package/dist/features/chat/queries/use-get-chat-query.d.ts +9 -0
- package/dist/features/chat/queries/use-get-chat-query.js +14 -0
- package/dist/features/chat/queries/use-get-conversation-query.d.ts +62 -0
- package/dist/features/chat/queries/use-get-conversation-query.js +14 -0
- package/dist/features/chat/queries/use-list-conversations-query.d.ts +29 -0
- package/dist/features/chat/queries/use-list-conversations-query.js +14 -0
- package/dist/features/chat/store.d.ts +13 -0
- package/dist/features/chat/store.js +1 -0
- package/dist/features/chat/utils.d.ts +5 -0
- package/dist/features/chat/utils.js +1 -0
- package/dist/features/data-fetching/use-api-client.d.ts +5 -0
- package/dist/features/data-fetching/use-api-client.js +14 -0
- package/dist/features/logger/logger.d.ts +9 -0
- package/dist/features/logger/logger.js +1 -0
- package/dist/features/molecule/chatsdk-provider.d.ts +19 -0
- package/dist/features/molecule/chatsdk-provider.js +26 -0
- package/dist/features/molecule/constants.d.ts +3 -0
- package/dist/features/molecule/constants.js +1 -0
- package/dist/features/molecule/molecule-provider.d.ts +39 -0
- package/dist/features/molecule/molecule-provider.js +1 -0
- package/dist/features/molecule/store.d.ts +53 -0
- package/dist/features/molecule/store.js +3 -0
- package/dist/features/molecule/types/api.d.ts +8 -0
- package/dist/features/molecule/types/api.js +1 -0
- package/dist/features/molecule/types/callbacks.d.ts +22 -0
- package/dist/features/molecule/types/callbacks.js +1 -0
- package/dist/features/molecule/types/config.d.ts +10 -0
- package/dist/features/molecule/types/config.js +1 -0
- package/dist/features/molecule/types/context.d.ts +11 -0
- package/dist/features/molecule/types/context.js +1 -0
- package/dist/features/molecule/types/locale.d.ts +9 -0
- package/dist/features/molecule/types/locale.js +1 -0
- package/dist/features/molecule/types/theme.d.ts +38 -0
- package/dist/features/molecule/types/theme.js +1 -0
- package/dist/features/molecule/types/translations.d.ts +10 -0
- package/dist/features/molecule/types/translations.js +1 -0
- package/dist/features/molecule/use-merge-global-config.d.ts +22 -0
- package/dist/features/molecule/use-merge-global-config.js +5 -0
- package/dist/features/molecule/use-molecule-config.d.ts +41 -0
- package/dist/features/molecule/use-molecule-config.js +6 -0
- package/dist/features/molecule/utils.d.ts +10 -0
- package/dist/features/molecule/utils.js +1 -0
- package/dist/i18n/config.d.ts +61 -0
- package/dist/i18n/config.js +1 -0
- package/dist/i18n/i18next.d.ts +11 -0
- package/dist/i18n/i18next.js +2 -0
- package/dist/i18n/utils.d.ts +11 -0
- package/dist/i18n/utils.js +6 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +20 -0
- package/dist/styles.css +6811 -0
- package/package.json +123 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { CodeBlock } from './chunk-CFM57HOS.js';
|
|
2
|
+
import { Badge } from '@chatsdk-dev/ui/components/badge';
|
|
3
|
+
import { Collapsible, CollapsibleTrigger, CollapsibleContent } from '@chatsdk-dev/ui/components/collapsible';
|
|
4
|
+
import { cn } from '@chatsdk-dev/ui/lib/utils';
|
|
5
|
+
import { WrenchIcon, ChevronDownIcon, XCircleIcon, CheckCircleIcon, CircleIcon, ClockIcon } from 'lucide-react';
|
|
6
|
+
import { isValidElement } from 'react';
|
|
7
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
var Tool = ({ className, ...props }) => /* @__PURE__ */ jsx(
|
|
10
|
+
Collapsible,
|
|
11
|
+
{
|
|
12
|
+
className: cn("group not-prose mb-4 w-full rounded-md border", className),
|
|
13
|
+
...props
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
var statusLabels = {
|
|
17
|
+
"approval-requested": "Awaiting Approval",
|
|
18
|
+
"approval-responded": "Responded",
|
|
19
|
+
"input-available": "Running",
|
|
20
|
+
"input-streaming": "Pending",
|
|
21
|
+
"output-available": "Completed",
|
|
22
|
+
"output-denied": "Denied",
|
|
23
|
+
"output-error": "Error"
|
|
24
|
+
};
|
|
25
|
+
var statusIcons = {
|
|
26
|
+
"approval-requested": /* @__PURE__ */ jsx(ClockIcon, { className: "size-4 text-yellow-600" }),
|
|
27
|
+
"approval-responded": /* @__PURE__ */ jsx(CheckCircleIcon, { className: "size-4 text-blue-600" }),
|
|
28
|
+
"input-available": /* @__PURE__ */ jsx(ClockIcon, { className: "size-4 animate-pulse" }),
|
|
29
|
+
"input-streaming": /* @__PURE__ */ jsx(CircleIcon, { className: "size-4" }),
|
|
30
|
+
"output-available": /* @__PURE__ */ jsx(CheckCircleIcon, { className: "size-4 text-green-600" }),
|
|
31
|
+
"output-denied": /* @__PURE__ */ jsx(XCircleIcon, { className: "size-4 text-orange-600" }),
|
|
32
|
+
"output-error": /* @__PURE__ */ jsx(XCircleIcon, { className: "size-4 text-red-600" })
|
|
33
|
+
};
|
|
34
|
+
var getStatusBadge = (status) => /* @__PURE__ */ jsxs(Badge, { className: "gap-1.5 rounded-full text-xs", variant: "secondary", children: [
|
|
35
|
+
statusIcons[status],
|
|
36
|
+
statusLabels[status]
|
|
37
|
+
] });
|
|
38
|
+
var ToolHeader = ({
|
|
39
|
+
className,
|
|
40
|
+
title,
|
|
41
|
+
type,
|
|
42
|
+
state,
|
|
43
|
+
toolName,
|
|
44
|
+
...props
|
|
45
|
+
}) => {
|
|
46
|
+
const derivedName = type === "dynamic-tool" ? toolName : type.split("-").slice(1).join("-");
|
|
47
|
+
return /* @__PURE__ */ jsxs(
|
|
48
|
+
CollapsibleTrigger,
|
|
49
|
+
{
|
|
50
|
+
className: cn(
|
|
51
|
+
"flex w-full items-center justify-between gap-4 p-3",
|
|
52
|
+
className
|
|
53
|
+
),
|
|
54
|
+
...props,
|
|
55
|
+
children: [
|
|
56
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
57
|
+
/* @__PURE__ */ jsx(WrenchIcon, { className: "size-4 text-muted-foreground" }),
|
|
58
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-sm", children: title ?? derivedName }),
|
|
59
|
+
getStatusBadge(state)
|
|
60
|
+
] }),
|
|
61
|
+
/* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180" })
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
var ToolContent = ({ className, ...props }) => /* @__PURE__ */ jsx(
|
|
67
|
+
CollapsibleContent,
|
|
68
|
+
{
|
|
69
|
+
className: cn(
|
|
70
|
+
"data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 space-y-4 p-4 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",
|
|
71
|
+
className
|
|
72
|
+
),
|
|
73
|
+
...props
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
var ToolInput = ({ className, input, ...props }) => /* @__PURE__ */ jsxs("div", { className: cn("space-y-2 overflow-hidden", className), ...props, children: [
|
|
77
|
+
/* @__PURE__ */ jsx("h4", { className: "font-medium text-muted-foreground text-xs uppercase tracking-wide", children: "Parameters" }),
|
|
78
|
+
/* @__PURE__ */ jsx("div", { className: "rounded-md bg-muted/50", children: /* @__PURE__ */ jsx(CodeBlock, { code: JSON.stringify(input, null, 2), language: "json" }) })
|
|
79
|
+
] });
|
|
80
|
+
var ToolOutput = ({
|
|
81
|
+
className,
|
|
82
|
+
output,
|
|
83
|
+
errorText,
|
|
84
|
+
...props
|
|
85
|
+
}) => {
|
|
86
|
+
if (!(output || errorText)) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
let Output = /* @__PURE__ */ jsx("div", { children: output });
|
|
90
|
+
if (typeof output === "object" && !isValidElement(output)) {
|
|
91
|
+
Output = /* @__PURE__ */ jsx(CodeBlock, { code: JSON.stringify(output, null, 2), language: "json" });
|
|
92
|
+
} else if (typeof output === "string") {
|
|
93
|
+
Output = /* @__PURE__ */ jsx(CodeBlock, { code: output, language: "json" });
|
|
94
|
+
}
|
|
95
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("space-y-2", className), ...props, children: [
|
|
96
|
+
/* @__PURE__ */ jsx("h4", { className: "font-medium text-muted-foreground text-xs uppercase tracking-wide", children: errorText ? "Error" : "Result" }),
|
|
97
|
+
/* @__PURE__ */ jsxs(
|
|
98
|
+
"div",
|
|
99
|
+
{
|
|
100
|
+
className: cn(
|
|
101
|
+
"overflow-x-auto rounded-md text-xs [&_table]:w-full",
|
|
102
|
+
errorText ? "bg-destructive/10 text-destructive" : "bg-muted/50 text-foreground"
|
|
103
|
+
),
|
|
104
|
+
children: [
|
|
105
|
+
errorText && /* @__PURE__ */ jsx("div", { children: errorText }),
|
|
106
|
+
Output
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
)
|
|
110
|
+
] });
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export { Tool, ToolContent, ToolHeader, ToolInput, ToolOutput, getStatusBadge };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { deepMerge } from './chunk-RJG5D2TM.js';
|
|
2
|
+
import { LOCAL_STORAGE_PREFIX } from './chunk-ZCSZX3OI.js';
|
|
3
|
+
import { create } from 'zustand';
|
|
4
|
+
import { persist, createJSONStorage } from 'zustand/middleware';
|
|
5
|
+
|
|
6
|
+
var defaultInitialState = {
|
|
7
|
+
context: { actor: { id: crypto.randomUUID() } },
|
|
8
|
+
api: {
|
|
9
|
+
version: "v1",
|
|
10
|
+
baseUrl: "/api/proxy",
|
|
11
|
+
credentials: "include"
|
|
12
|
+
},
|
|
13
|
+
locale: { language: "en" }
|
|
14
|
+
};
|
|
15
|
+
var createChatSDKStore = (customInitialState) => {
|
|
16
|
+
const initialState = { ...defaultInitialState, ...customInitialState };
|
|
17
|
+
return create()(
|
|
18
|
+
persist(
|
|
19
|
+
(set) => ({
|
|
20
|
+
...initialState,
|
|
21
|
+
setContext: (context) => set((state) => ({
|
|
22
|
+
...state,
|
|
23
|
+
context: deepMerge({ ...state.context, ...context })
|
|
24
|
+
})),
|
|
25
|
+
setLogger: (logger) => set((state) => ({ ...state, logger })),
|
|
26
|
+
setTheme: (theme) => set((state) => ({ ...state, theme: { ...state.theme, ...theme } })),
|
|
27
|
+
setApi: (api) => set((state) => ({
|
|
28
|
+
...state,
|
|
29
|
+
api: {
|
|
30
|
+
...state.api,
|
|
31
|
+
...api,
|
|
32
|
+
headers: state.api?.headers || api?.headers ? { ...state.api?.headers, ...api?.headers } : void 0
|
|
33
|
+
}
|
|
34
|
+
})),
|
|
35
|
+
setTranslations: (translations, merge = true) => set((state) => ({
|
|
36
|
+
...state,
|
|
37
|
+
translations: merge ? { ...state.translations, ...translations } : translations
|
|
38
|
+
})),
|
|
39
|
+
setLocale: (locale) => {
|
|
40
|
+
set((state) => ({ ...state, locale }));
|
|
41
|
+
},
|
|
42
|
+
setConfig: (newConfig, merge = true) => {
|
|
43
|
+
set((state) => {
|
|
44
|
+
const config = merge ? state : initialState;
|
|
45
|
+
return {
|
|
46
|
+
...config,
|
|
47
|
+
...newConfig,
|
|
48
|
+
api: { ...config.api, ...newConfig.api },
|
|
49
|
+
context: deepMerge({
|
|
50
|
+
...config.context,
|
|
51
|
+
...newConfig.context
|
|
52
|
+
}),
|
|
53
|
+
theme: { ...config.theme, ...newConfig.theme },
|
|
54
|
+
translations: {
|
|
55
|
+
...config.translations,
|
|
56
|
+
...newConfig.translations
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
reset: (config) => {
|
|
62
|
+
set({ ...initialState, theme: {}, ...config });
|
|
63
|
+
},
|
|
64
|
+
setOptions: (options) => set((state) => ({ ...state, options }))
|
|
65
|
+
}),
|
|
66
|
+
{
|
|
67
|
+
partialize: (state) => {
|
|
68
|
+
return { context: { actor: state.context?.actor } };
|
|
69
|
+
},
|
|
70
|
+
name: LOCAL_STORAGE_PREFIX + "elements-store",
|
|
71
|
+
storage: createJSONStorage(() => localStorage)
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
var useChatSDKStore = createChatSDKStore();
|
|
77
|
+
|
|
78
|
+
export { createChatSDKStore, useChatSDKStore };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FolderCode } from 'lucide-react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { Empty, EmptyHeader, EmptyMedia, EmptyTitle, EmptyDescription } from '@chatsdk-dev/ui/components/empty';
|
|
4
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
// src/features/chat/chat-history/chat-history-empty.tsx
|
|
7
|
+
function ChatHistoryEmpty() {
|
|
8
|
+
const { t } = useTranslation("chat", { keyPrefix: "history.empty" });
|
|
9
|
+
return /* @__PURE__ */ jsx(Empty, { className: "w-full h-full hover:bg-blue pb-32", children: /* @__PURE__ */ jsxs(EmptyHeader, { children: [
|
|
10
|
+
/* @__PURE__ */ jsx(EmptyMedia, { className: "size-8", variant: "icon", children: /* @__PURE__ */ jsx(FolderCode, { className: "size-4.5" }) }),
|
|
11
|
+
/* @__PURE__ */ jsx(EmptyTitle, { children: t("title") }),
|
|
12
|
+
/* @__PURE__ */ jsx(EmptyDescription, { children: t("description") })
|
|
13
|
+
] }) });
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { ChatHistoryEmpty };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { cloneElement } from 'react';
|
|
2
|
+
import { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter } from '@chatsdk-dev/ui/components/dialog';
|
|
3
|
+
import { Drawer, DrawerTrigger, DrawerContent, DrawerHeader, DrawerTitle, DrawerDescription, DrawerFooter } from '@chatsdk-dev/ui/components/drawer';
|
|
4
|
+
import { useBreakpoint } from '@chatsdk-dev/ui/hooks/use-breakpoint';
|
|
5
|
+
import { useControllableState } from '@chatsdk-dev/ui/hooks/use-controllable-state';
|
|
6
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
// src/components/responsive-dialog.tsx
|
|
9
|
+
function ResponsiveDialog({
|
|
10
|
+
open,
|
|
11
|
+
onOpenChange,
|
|
12
|
+
trigger,
|
|
13
|
+
children,
|
|
14
|
+
title,
|
|
15
|
+
description,
|
|
16
|
+
footer
|
|
17
|
+
}) {
|
|
18
|
+
const [openState, setOpenState] = useControllableState({
|
|
19
|
+
value: open,
|
|
20
|
+
defaultValue: false,
|
|
21
|
+
onChange: onOpenChange
|
|
22
|
+
});
|
|
23
|
+
const sm = useBreakpoint("sm");
|
|
24
|
+
if (sm) {
|
|
25
|
+
const renderTrigger = trigger ? (triggerProps) => cloneElement(trigger, triggerProps) : void 0;
|
|
26
|
+
return /* @__PURE__ */ jsxs(Dialog, { open: openState, onOpenChange: setOpenState, children: [
|
|
27
|
+
trigger && /* @__PURE__ */ jsx(DialogTrigger, { render: renderTrigger }),
|
|
28
|
+
/* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-106 px-6", children: [
|
|
29
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [
|
|
30
|
+
/* @__PURE__ */ jsx(DialogTitle, { children: title }),
|
|
31
|
+
/* @__PURE__ */ jsx(DialogDescription, { children: description })
|
|
32
|
+
] }),
|
|
33
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto min-h-0 -mx-6 px-6 pb-1", children }),
|
|
34
|
+
footer && /* @__PURE__ */ jsx(DialogFooter, { children: footer })
|
|
35
|
+
] })
|
|
36
|
+
] });
|
|
37
|
+
}
|
|
38
|
+
return /* @__PURE__ */ jsxs(Drawer, { open: openState, onOpenChange: setOpenState, children: [
|
|
39
|
+
/* @__PURE__ */ jsx(DrawerTrigger, { asChild: true, children: trigger }),
|
|
40
|
+
/* @__PURE__ */ jsxs(DrawerContent, { className: "p-6", children: [
|
|
41
|
+
/* @__PURE__ */ jsxs(DrawerHeader, { className: "text-left", children: [
|
|
42
|
+
/* @__PURE__ */ jsx(DrawerTitle, { children: title }),
|
|
43
|
+
/* @__PURE__ */ jsx(DrawerDescription, { children: description })
|
|
44
|
+
] }),
|
|
45
|
+
/* @__PURE__ */ jsx("div", { className: "overflow-y-auto -mx-6 px-6 pb-1", children }),
|
|
46
|
+
footer && /* @__PURE__ */ jsx(DrawerFooter, { children: footer })
|
|
47
|
+
] })
|
|
48
|
+
] });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { ResponsiveDialog };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
// src/common/use-copy-to-clipboard.ts
|
|
4
|
+
function oldSchoolCopy(text) {
|
|
5
|
+
const tempTextArea = document.createElement("textarea");
|
|
6
|
+
tempTextArea.value = text;
|
|
7
|
+
document.body.appendChild(tempTextArea);
|
|
8
|
+
tempTextArea.select();
|
|
9
|
+
document.execCommand("copy");
|
|
10
|
+
document.body.removeChild(tempTextArea);
|
|
11
|
+
}
|
|
12
|
+
function useCopyToClipboard() {
|
|
13
|
+
const [state, setState] = useState(null);
|
|
14
|
+
const copyToClipboard = useCallback((value) => {
|
|
15
|
+
const handleCopy = async () => {
|
|
16
|
+
try {
|
|
17
|
+
if (navigator?.clipboard?.writeText) {
|
|
18
|
+
await navigator.clipboard.writeText(value);
|
|
19
|
+
setState(value);
|
|
20
|
+
} else {
|
|
21
|
+
throw new Error("writeText not supported");
|
|
22
|
+
}
|
|
23
|
+
} catch (error) {
|
|
24
|
+
oldSchoolCopy(value);
|
|
25
|
+
setState(value);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
handleCopy();
|
|
29
|
+
}, []);
|
|
30
|
+
return [state, copyToClipboard];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { useCopyToClipboard };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// src/common/utilts.ts
|
|
2
|
+
function renderRelativeTime({
|
|
3
|
+
date,
|
|
4
|
+
now,
|
|
5
|
+
locale
|
|
6
|
+
}) {
|
|
7
|
+
const _date = date instanceof Date ? date : new Date(date);
|
|
8
|
+
const _now = now ?? /* @__PURE__ */ new Date();
|
|
9
|
+
const diffMs = _date.getTime() - _now.getTime();
|
|
10
|
+
const diffSec = Math.round(diffMs / 1e3);
|
|
11
|
+
const diffMin = Math.round(diffSec / 60);
|
|
12
|
+
const diffHr = Math.round(diffMin / 60);
|
|
13
|
+
const diffDay = Math.round(diffHr / 24);
|
|
14
|
+
const diffWeek = Math.round(diffDay / 7);
|
|
15
|
+
const diffMonth = Math.round(diffDay / 30);
|
|
16
|
+
const diffYear = Math.round(diffDay / 365);
|
|
17
|
+
const _locale = locale ?? "en";
|
|
18
|
+
const rtf = new Intl.RelativeTimeFormat(_locale, { numeric: "auto" });
|
|
19
|
+
if (Math.abs(diffSec) < 60) return rtf.format(diffSec, "second");
|
|
20
|
+
if (Math.abs(diffMin) < 60) return rtf.format(diffMin, "minute");
|
|
21
|
+
if (Math.abs(diffHr) < 24) return rtf.format(diffHr, "hour");
|
|
22
|
+
if (Math.abs(diffDay) < 7) return rtf.format(diffDay, "day");
|
|
23
|
+
if (Math.abs(diffWeek) < 4) return rtf.format(diffWeek, "week");
|
|
24
|
+
if (Math.abs(diffMonth) < 12) return rtf.format(diffMonth, "month");
|
|
25
|
+
return rtf.format(diffYear, "year");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { renderRelativeTime };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
import { ButtonProps } from '@chatsdk-dev/ui/components/button';
|
|
4
|
+
|
|
5
|
+
type ActionsProps = ComponentProps<"div">;
|
|
6
|
+
declare const Actions: ({ className, children, ...props }: ActionsProps) => react_jsx_runtime.JSX.Element;
|
|
7
|
+
type ActionProps = ButtonProps & {
|
|
8
|
+
tooltip?: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
};
|
|
11
|
+
declare const Action: ({ tooltip, children, label, className, variant, size, ...props }: ActionProps) => react_jsx_runtime.JSX.Element;
|
|
12
|
+
|
|
13
|
+
export { Action, type ActionProps, Actions, type ActionsProps };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Button } from '@chatsdk-dev/ui/components/button';
|
|
2
|
+
import { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent } from '@chatsdk-dev/ui/components/tooltip';
|
|
3
|
+
import { cn } from '@chatsdk-dev/ui/lib/utils';
|
|
4
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
var Actions = ({ className, children, ...props }) => /* @__PURE__ */ jsx("div", { className: cn("flex items-center gap-", className), ...props, children });
|
|
7
|
+
var Action = ({
|
|
8
|
+
tooltip,
|
|
9
|
+
children,
|
|
10
|
+
label,
|
|
11
|
+
className,
|
|
12
|
+
variant = "ghost",
|
|
13
|
+
size = "sm",
|
|
14
|
+
...props
|
|
15
|
+
}) => {
|
|
16
|
+
const button = /* @__PURE__ */ jsxs(
|
|
17
|
+
Button,
|
|
18
|
+
{
|
|
19
|
+
className: cn(
|
|
20
|
+
"size-9 p-1.5 bg-transparent text-muted-foreground hover:text-foreground hover:bg-transparent relative",
|
|
21
|
+
className
|
|
22
|
+
),
|
|
23
|
+
size,
|
|
24
|
+
type: "button",
|
|
25
|
+
variant,
|
|
26
|
+
...props,
|
|
27
|
+
children: [
|
|
28
|
+
children,
|
|
29
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: label || tooltip })
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
if (tooltip) {
|
|
34
|
+
return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
35
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { children: button }),
|
|
36
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: tooltip }) })
|
|
37
|
+
] }) });
|
|
38
|
+
}
|
|
39
|
+
return button;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { Action, Actions };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import { AccordionItem, Accordion } from '@chatsdk-dev/ui/components/accordion';
|
|
5
|
+
import { Tool } from 'ai';
|
|
6
|
+
|
|
7
|
+
type AgentProps = ComponentProps<"div">;
|
|
8
|
+
declare const Agent: react.MemoExoticComponent<({ className, ...props }: AgentProps) => react_jsx_runtime.JSX.Element>;
|
|
9
|
+
type AgentHeaderProps = ComponentProps<"div"> & {
|
|
10
|
+
name: string;
|
|
11
|
+
model?: string;
|
|
12
|
+
};
|
|
13
|
+
declare const AgentHeader: react.MemoExoticComponent<({ className, name, model, ...props }: AgentHeaderProps) => react_jsx_runtime.JSX.Element>;
|
|
14
|
+
type AgentContentProps = ComponentProps<"div">;
|
|
15
|
+
declare const AgentContent: react.MemoExoticComponent<({ className, ...props }: AgentContentProps) => react_jsx_runtime.JSX.Element>;
|
|
16
|
+
type AgentInstructionsProps = ComponentProps<"div"> & {
|
|
17
|
+
children: string;
|
|
18
|
+
};
|
|
19
|
+
declare const AgentInstructions: react.MemoExoticComponent<({ className, children, ...props }: AgentInstructionsProps) => react_jsx_runtime.JSX.Element>;
|
|
20
|
+
type AgentToolsProps = ComponentProps<typeof Accordion>;
|
|
21
|
+
declare const AgentTools: react.MemoExoticComponent<({ className, ...props }: AgentToolsProps) => react_jsx_runtime.JSX.Element>;
|
|
22
|
+
type AgentToolProps = ComponentProps<typeof AccordionItem> & {
|
|
23
|
+
tool: Tool;
|
|
24
|
+
};
|
|
25
|
+
declare const AgentTool: react.MemoExoticComponent<({ className, tool, value, ...props }: AgentToolProps) => react_jsx_runtime.JSX.Element>;
|
|
26
|
+
type AgentOutputProps = ComponentProps<"div"> & {
|
|
27
|
+
schema: string;
|
|
28
|
+
};
|
|
29
|
+
declare const AgentOutput: react.MemoExoticComponent<({ className, schema, ...props }: AgentOutputProps) => react_jsx_runtime.JSX.Element>;
|
|
30
|
+
|
|
31
|
+
export { Agent, AgentContent, type AgentContentProps, AgentHeader, type AgentHeaderProps, AgentInstructions, type AgentInstructionsProps, AgentOutput, type AgentOutputProps, type AgentProps, AgentTool, type AgentToolProps, AgentTools, type AgentToolsProps };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { CodeBlock } from '../../chunk-CFM57HOS.js';
|
|
2
|
+
import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from '@chatsdk-dev/ui/components/accordion';
|
|
3
|
+
import { Badge } from '@chatsdk-dev/ui/components/badge';
|
|
4
|
+
import { cn } from '@chatsdk-dev/ui/lib/utils';
|
|
5
|
+
import { BotIcon } from 'lucide-react';
|
|
6
|
+
import { memo } from 'react';
|
|
7
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
var Agent = memo(({ className, ...props }) => /* @__PURE__ */ jsx(
|
|
10
|
+
"div",
|
|
11
|
+
{
|
|
12
|
+
className: cn("not-prose w-full rounded-md border", className),
|
|
13
|
+
...props
|
|
14
|
+
}
|
|
15
|
+
));
|
|
16
|
+
var AgentHeader = memo(
|
|
17
|
+
({ className, name, model, ...props }) => /* @__PURE__ */ jsx(
|
|
18
|
+
"div",
|
|
19
|
+
{
|
|
20
|
+
className: cn(
|
|
21
|
+
"flex w-full items-center justify-between gap-4 p-3",
|
|
22
|
+
className
|
|
23
|
+
),
|
|
24
|
+
...props,
|
|
25
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
26
|
+
/* @__PURE__ */ jsx(BotIcon, { className: "size-4 text-muted-foreground" }),
|
|
27
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-sm", children: name }),
|
|
28
|
+
model && /* @__PURE__ */ jsx(Badge, { className: "font-mono text-xs", variant: "secondary", children: model })
|
|
29
|
+
] })
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
);
|
|
33
|
+
var AgentContent = memo(
|
|
34
|
+
({ className, ...props }) => /* @__PURE__ */ jsx("div", { className: cn("space-y-4 p-4 pt-0", className), ...props })
|
|
35
|
+
);
|
|
36
|
+
var AgentInstructions = memo(
|
|
37
|
+
({ className, children, ...props }) => /* @__PURE__ */ jsxs("div", { className: cn("space-y-2", className), ...props, children: [
|
|
38
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-muted-foreground text-sm", children: "Instructions" }),
|
|
39
|
+
/* @__PURE__ */ jsx("div", { className: "rounded-md bg-muted/50 p-3 text-muted-foreground text-sm", children: /* @__PURE__ */ jsx("p", { children }) })
|
|
40
|
+
] })
|
|
41
|
+
);
|
|
42
|
+
var AgentTools = memo(({ className, ...props }) => /* @__PURE__ */ jsxs("div", { className: cn("space-y-2", className), children: [
|
|
43
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-muted-foreground text-sm", children: "Tools" }),
|
|
44
|
+
/* @__PURE__ */ jsx(Accordion, { className: "rounded-md border", ...props })
|
|
45
|
+
] }));
|
|
46
|
+
var AgentTool = memo(
|
|
47
|
+
({ className, tool, value, ...props }) => {
|
|
48
|
+
const schema = "jsonSchema" in tool && tool.jsonSchema ? tool.jsonSchema : tool.inputSchema;
|
|
49
|
+
return /* @__PURE__ */ jsxs(
|
|
50
|
+
AccordionItem,
|
|
51
|
+
{
|
|
52
|
+
className: cn("border-b last:border-b-0", className),
|
|
53
|
+
value,
|
|
54
|
+
...props,
|
|
55
|
+
children: [
|
|
56
|
+
/* @__PURE__ */ jsx(AccordionTrigger, { className: "px-3 py-2 text-sm hover:no-underline", children: tool.description ?? "No description" }),
|
|
57
|
+
/* @__PURE__ */ jsx(AccordionContent, { className: "px-3 pb-3", children: /* @__PURE__ */ jsx("div", { className: "rounded-md bg-muted/50", children: /* @__PURE__ */ jsx(CodeBlock, { code: JSON.stringify(schema, null, 2), language: "json" }) }) })
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
var AgentOutput = memo(
|
|
64
|
+
({ className, schema, ...props }) => /* @__PURE__ */ jsxs("div", { className: cn("space-y-2", className), ...props, children: [
|
|
65
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-muted-foreground text-sm", children: "Output Schema" }),
|
|
66
|
+
/* @__PURE__ */ jsx("div", { className: "rounded-md bg-muted/50", children: /* @__PURE__ */ jsx(CodeBlock, { code: schema, language: "typescript" }) })
|
|
67
|
+
] })
|
|
68
|
+
);
|
|
69
|
+
Agent.displayName = "Agent";
|
|
70
|
+
AgentHeader.displayName = "AgentHeader";
|
|
71
|
+
AgentContent.displayName = "AgentContent";
|
|
72
|
+
AgentInstructions.displayName = "AgentInstructions";
|
|
73
|
+
AgentTools.displayName = "AgentTools";
|
|
74
|
+
AgentTool.displayName = "AgentTool";
|
|
75
|
+
AgentOutput.displayName = "AgentOutput";
|
|
76
|
+
|
|
77
|
+
export { Agent, AgentContent, AgentHeader, AgentInstructions, AgentOutput, AgentTool, AgentTools };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Button } from '@chatsdk-dev/ui/components/button';
|
|
3
|
+
import { LucideIcon } from 'lucide-react';
|
|
4
|
+
import { HTMLAttributes, ComponentProps } from 'react';
|
|
5
|
+
|
|
6
|
+
type ArtifactProps = HTMLAttributes<HTMLDivElement>;
|
|
7
|
+
declare const Artifact: ({ className, ...props }: ArtifactProps) => react_jsx_runtime.JSX.Element;
|
|
8
|
+
type ArtifactHeaderProps = HTMLAttributes<HTMLDivElement>;
|
|
9
|
+
declare const ArtifactHeader: ({ className, ...props }: ArtifactHeaderProps) => react_jsx_runtime.JSX.Element;
|
|
10
|
+
type ArtifactCloseProps = ComponentProps<typeof Button>;
|
|
11
|
+
declare const ArtifactClose: ({ className, children, size, variant, ...props }: ArtifactCloseProps) => react_jsx_runtime.JSX.Element;
|
|
12
|
+
type ArtifactTitleProps = HTMLAttributes<HTMLParagraphElement>;
|
|
13
|
+
declare const ArtifactTitle: ({ className, ...props }: ArtifactTitleProps) => react_jsx_runtime.JSX.Element;
|
|
14
|
+
type ArtifactDescriptionProps = HTMLAttributes<HTMLParagraphElement>;
|
|
15
|
+
declare const ArtifactDescription: ({ className, ...props }: ArtifactDescriptionProps) => react_jsx_runtime.JSX.Element;
|
|
16
|
+
type ArtifactActionsProps = HTMLAttributes<HTMLDivElement>;
|
|
17
|
+
declare const ArtifactActions: ({ className, ...props }: ArtifactActionsProps) => react_jsx_runtime.JSX.Element;
|
|
18
|
+
type ArtifactActionProps = ComponentProps<typeof Button> & {
|
|
19
|
+
tooltip?: string;
|
|
20
|
+
label?: string;
|
|
21
|
+
icon?: LucideIcon;
|
|
22
|
+
};
|
|
23
|
+
declare const ArtifactAction: ({ tooltip, label, icon: Icon, children, className, size, variant, ...props }: ArtifactActionProps) => react_jsx_runtime.JSX.Element;
|
|
24
|
+
type ArtifactContentProps = HTMLAttributes<HTMLDivElement>;
|
|
25
|
+
declare const ArtifactContent: ({ className, ...props }: ArtifactContentProps) => react_jsx_runtime.JSX.Element;
|
|
26
|
+
|
|
27
|
+
export { Artifact, ArtifactAction, type ArtifactActionProps, ArtifactActions, type ArtifactActionsProps, ArtifactClose, type ArtifactCloseProps, ArtifactContent, type ArtifactContentProps, ArtifactDescription, type ArtifactDescriptionProps, ArtifactHeader, type ArtifactHeaderProps, type ArtifactProps, ArtifactTitle, type ArtifactTitleProps };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Button } from '@chatsdk-dev/ui/components/button';
|
|
2
|
+
import { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent } from '@chatsdk-dev/ui/components/tooltip';
|
|
3
|
+
import { cn } from '@chatsdk-dev/ui/lib/utils';
|
|
4
|
+
import { XIcon } from 'lucide-react';
|
|
5
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var Artifact = ({ className, ...props }) => /* @__PURE__ */ jsx(
|
|
8
|
+
"div",
|
|
9
|
+
{
|
|
10
|
+
className: cn(
|
|
11
|
+
"flex flex-col overflow-hidden rounded-lg border bg-background shadow-sm",
|
|
12
|
+
className
|
|
13
|
+
),
|
|
14
|
+
...props
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
var ArtifactHeader = ({
|
|
18
|
+
className,
|
|
19
|
+
...props
|
|
20
|
+
}) => /* @__PURE__ */ jsx(
|
|
21
|
+
"div",
|
|
22
|
+
{
|
|
23
|
+
className: cn(
|
|
24
|
+
"flex items-center justify-between border-b bg-muted/50 px-4 py-3",
|
|
25
|
+
className
|
|
26
|
+
),
|
|
27
|
+
...props
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
var ArtifactClose = ({
|
|
31
|
+
className,
|
|
32
|
+
children,
|
|
33
|
+
size = "sm",
|
|
34
|
+
variant = "ghost",
|
|
35
|
+
...props
|
|
36
|
+
}) => /* @__PURE__ */ jsxs(
|
|
37
|
+
Button,
|
|
38
|
+
{
|
|
39
|
+
className: cn(
|
|
40
|
+
"size-8 p-0 text-muted-foreground hover:text-foreground",
|
|
41
|
+
className
|
|
42
|
+
),
|
|
43
|
+
size,
|
|
44
|
+
type: "button",
|
|
45
|
+
variant,
|
|
46
|
+
...props,
|
|
47
|
+
children: [
|
|
48
|
+
children ?? /* @__PURE__ */ jsx(XIcon, { className: "size-4" }),
|
|
49
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
var ArtifactTitle = ({ className, ...props }) => /* @__PURE__ */ jsx(
|
|
54
|
+
"p",
|
|
55
|
+
{
|
|
56
|
+
className: cn("font-medium text-foreground text-sm", className),
|
|
57
|
+
...props
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
var ArtifactDescription = ({
|
|
61
|
+
className,
|
|
62
|
+
...props
|
|
63
|
+
}) => /* @__PURE__ */ jsx("p", { className: cn("text-muted-foreground text-sm", className), ...props });
|
|
64
|
+
var ArtifactActions = ({
|
|
65
|
+
className,
|
|
66
|
+
...props
|
|
67
|
+
}) => /* @__PURE__ */ jsx("div", { className: cn("flex items-center gap-1", className), ...props });
|
|
68
|
+
var ArtifactAction = ({
|
|
69
|
+
tooltip,
|
|
70
|
+
label,
|
|
71
|
+
icon: Icon,
|
|
72
|
+
children,
|
|
73
|
+
className,
|
|
74
|
+
size = "sm",
|
|
75
|
+
variant = "ghost",
|
|
76
|
+
...props
|
|
77
|
+
}) => {
|
|
78
|
+
const button = /* @__PURE__ */ jsxs(
|
|
79
|
+
Button,
|
|
80
|
+
{
|
|
81
|
+
className: cn(
|
|
82
|
+
"size-8 p-0 text-muted-foreground hover:text-foreground",
|
|
83
|
+
className
|
|
84
|
+
),
|
|
85
|
+
size,
|
|
86
|
+
type: "button",
|
|
87
|
+
variant,
|
|
88
|
+
...props,
|
|
89
|
+
children: [
|
|
90
|
+
Icon ? /* @__PURE__ */ jsx(Icon, { className: "size-4" }) : children,
|
|
91
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: label || tooltip })
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
if (tooltip) {
|
|
96
|
+
return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
97
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { render: button }),
|
|
98
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: tooltip }) })
|
|
99
|
+
] }) });
|
|
100
|
+
}
|
|
101
|
+
return button;
|
|
102
|
+
};
|
|
103
|
+
var ArtifactContent = ({
|
|
104
|
+
className,
|
|
105
|
+
...props
|
|
106
|
+
}) => /* @__PURE__ */ jsx("div", { className: cn("flex-1 overflow-auto p-4", className), ...props });
|
|
107
|
+
|
|
108
|
+
export { Artifact, ArtifactAction, ArtifactActions, ArtifactClose, ArtifactContent, ArtifactDescription, ArtifactHeader, ArtifactTitle };
|