@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,212 @@
|
|
|
1
|
+
import { Collapsible, CollapsibleTrigger, CollapsibleContent } from '@chatsdk-dev/ui/components/collapsible';
|
|
2
|
+
import { cn } from '@chatsdk-dev/ui/lib/utils';
|
|
3
|
+
import { ChevronRightIcon, FolderOpenIcon, FolderIcon, FileIcon } from 'lucide-react';
|
|
4
|
+
import { createContext, useState, useCallback, useMemo, useContext } from 'react';
|
|
5
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var noop = () => {
|
|
8
|
+
};
|
|
9
|
+
var FileTreeContext = createContext({
|
|
10
|
+
// oxlint-disable-next-line eslint-plugin-unicorn(no-new-builtin)
|
|
11
|
+
expandedPaths: /* @__PURE__ */ new Set(),
|
|
12
|
+
togglePath: noop
|
|
13
|
+
});
|
|
14
|
+
var FileTree = ({
|
|
15
|
+
expanded: controlledExpanded,
|
|
16
|
+
defaultExpanded = /* @__PURE__ */ new Set(),
|
|
17
|
+
selectedPath,
|
|
18
|
+
onSelect,
|
|
19
|
+
onExpandedChange,
|
|
20
|
+
className,
|
|
21
|
+
children,
|
|
22
|
+
...props
|
|
23
|
+
}) => {
|
|
24
|
+
const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);
|
|
25
|
+
const expandedPaths = controlledExpanded ?? internalExpanded;
|
|
26
|
+
const togglePath = useCallback(
|
|
27
|
+
(path) => {
|
|
28
|
+
const newExpanded = new Set(expandedPaths);
|
|
29
|
+
if (newExpanded.has(path)) {
|
|
30
|
+
newExpanded.delete(path);
|
|
31
|
+
} else {
|
|
32
|
+
newExpanded.add(path);
|
|
33
|
+
}
|
|
34
|
+
setInternalExpanded(newExpanded);
|
|
35
|
+
onExpandedChange?.(newExpanded);
|
|
36
|
+
},
|
|
37
|
+
[expandedPaths, onExpandedChange]
|
|
38
|
+
);
|
|
39
|
+
const contextValue = useMemo(
|
|
40
|
+
() => ({ expandedPaths, onSelect, selectedPath, togglePath }),
|
|
41
|
+
[expandedPaths, onSelect, selectedPath, togglePath]
|
|
42
|
+
);
|
|
43
|
+
return /* @__PURE__ */ jsx(FileTreeContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
44
|
+
"div",
|
|
45
|
+
{
|
|
46
|
+
className: cn(
|
|
47
|
+
"rounded-lg border bg-background font-mono text-sm",
|
|
48
|
+
className
|
|
49
|
+
),
|
|
50
|
+
role: "tree",
|
|
51
|
+
...props,
|
|
52
|
+
children: /* @__PURE__ */ jsx("div", { className: "p-2", children })
|
|
53
|
+
}
|
|
54
|
+
) });
|
|
55
|
+
};
|
|
56
|
+
var FileTreeIcon = ({
|
|
57
|
+
className,
|
|
58
|
+
children,
|
|
59
|
+
...props
|
|
60
|
+
}) => /* @__PURE__ */ jsx("span", { className: cn("shrink-0", className), ...props, children });
|
|
61
|
+
var FileTreeName = ({
|
|
62
|
+
className,
|
|
63
|
+
children,
|
|
64
|
+
...props
|
|
65
|
+
}) => /* @__PURE__ */ jsx("span", { className: cn("truncate", className), ...props, children });
|
|
66
|
+
var FileTreeFolderContext = createContext({
|
|
67
|
+
isExpanded: false,
|
|
68
|
+
name: "",
|
|
69
|
+
path: ""
|
|
70
|
+
});
|
|
71
|
+
var FileTreeFolder = ({
|
|
72
|
+
path,
|
|
73
|
+
name,
|
|
74
|
+
className,
|
|
75
|
+
children,
|
|
76
|
+
...props
|
|
77
|
+
}) => {
|
|
78
|
+
const { expandedPaths, togglePath, selectedPath, onSelect } = useContext(FileTreeContext);
|
|
79
|
+
const isExpanded = expandedPaths.has(path);
|
|
80
|
+
const isSelected = selectedPath === path;
|
|
81
|
+
const handleOpenChange = useCallback(() => {
|
|
82
|
+
togglePath(path);
|
|
83
|
+
}, [togglePath, path]);
|
|
84
|
+
const handleSelect = useCallback(() => {
|
|
85
|
+
onSelect?.(path);
|
|
86
|
+
}, [onSelect, path]);
|
|
87
|
+
const folderContextValue = useMemo(
|
|
88
|
+
() => ({ isExpanded, name, path }),
|
|
89
|
+
[isExpanded, name, path]
|
|
90
|
+
);
|
|
91
|
+
return /* @__PURE__ */ jsx(FileTreeFolderContext.Provider, { value: folderContextValue, children: /* @__PURE__ */ jsx(Collapsible, { onOpenChange: handleOpenChange, open: isExpanded, children: /* @__PURE__ */ jsxs(
|
|
92
|
+
"div",
|
|
93
|
+
{
|
|
94
|
+
className: cn("", className),
|
|
95
|
+
role: "treeitem",
|
|
96
|
+
tabIndex: 0,
|
|
97
|
+
...props,
|
|
98
|
+
children: [
|
|
99
|
+
/* @__PURE__ */ jsxs(
|
|
100
|
+
"div",
|
|
101
|
+
{
|
|
102
|
+
className: cn(
|
|
103
|
+
"flex w-full items-center gap-1 rounded px-2 py-1 text-left transition-colors hover:bg-muted/50",
|
|
104
|
+
isSelected && "bg-muted"
|
|
105
|
+
),
|
|
106
|
+
children: [
|
|
107
|
+
/* @__PURE__ */ jsx(
|
|
108
|
+
CollapsibleTrigger,
|
|
109
|
+
{
|
|
110
|
+
render: () => /* @__PURE__ */ jsx(
|
|
111
|
+
"button",
|
|
112
|
+
{
|
|
113
|
+
className: "flex shrink-0 cursor-pointer items-center border-none bg-transparent p-0",
|
|
114
|
+
type: "button",
|
|
115
|
+
children: /* @__PURE__ */ jsx(
|
|
116
|
+
ChevronRightIcon,
|
|
117
|
+
{
|
|
118
|
+
className: cn(
|
|
119
|
+
"size-4 shrink-0 text-muted-foreground transition-transform",
|
|
120
|
+
isExpanded && "rotate-90"
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
),
|
|
128
|
+
/* @__PURE__ */ jsxs(
|
|
129
|
+
"button",
|
|
130
|
+
{
|
|
131
|
+
className: "flex min-w-0 flex-1 cursor-pointer items-center gap-1 border-none bg-transparent p-0 text-left",
|
|
132
|
+
onClick: handleSelect,
|
|
133
|
+
type: "button",
|
|
134
|
+
children: [
|
|
135
|
+
/* @__PURE__ */ jsx(FileTreeIcon, { children: isExpanded ? /* @__PURE__ */ jsx(FolderOpenIcon, { className: "size-4 text-blue-500" }) : /* @__PURE__ */ jsx(FolderIcon, { className: "size-4 text-blue-500" }) }),
|
|
136
|
+
/* @__PURE__ */ jsx(FileTreeName, { children: name })
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
)
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
),
|
|
143
|
+
/* @__PURE__ */ jsx(CollapsibleContent, { children: /* @__PURE__ */ jsx("div", { className: "ml-4 border-l pl-2", children }) })
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
) }) });
|
|
147
|
+
};
|
|
148
|
+
var FileTreeFileContext = createContext({
|
|
149
|
+
name: "",
|
|
150
|
+
path: ""
|
|
151
|
+
});
|
|
152
|
+
var FileTreeFile = ({
|
|
153
|
+
path,
|
|
154
|
+
name,
|
|
155
|
+
icon,
|
|
156
|
+
className,
|
|
157
|
+
children,
|
|
158
|
+
...props
|
|
159
|
+
}) => {
|
|
160
|
+
const { selectedPath, onSelect } = useContext(FileTreeContext);
|
|
161
|
+
const isSelected = selectedPath === path;
|
|
162
|
+
const handleClick = useCallback(() => {
|
|
163
|
+
onSelect?.(path);
|
|
164
|
+
}, [onSelect, path]);
|
|
165
|
+
const handleKeyDown = useCallback(
|
|
166
|
+
(e) => {
|
|
167
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
168
|
+
onSelect?.(path);
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
[onSelect, path]
|
|
172
|
+
);
|
|
173
|
+
const fileContextValue = useMemo(() => ({ name, path }), [name, path]);
|
|
174
|
+
return /* @__PURE__ */ jsx(FileTreeFileContext.Provider, { value: fileContextValue, children: /* @__PURE__ */ jsx(
|
|
175
|
+
"div",
|
|
176
|
+
{
|
|
177
|
+
className: cn(
|
|
178
|
+
"flex cursor-pointer items-center gap-1 rounded px-2 py-1 transition-colors hover:bg-muted/50",
|
|
179
|
+
isSelected && "bg-muted",
|
|
180
|
+
className
|
|
181
|
+
),
|
|
182
|
+
onClick: handleClick,
|
|
183
|
+
onKeyDown: handleKeyDown,
|
|
184
|
+
role: "treeitem",
|
|
185
|
+
tabIndex: 0,
|
|
186
|
+
...props,
|
|
187
|
+
children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
188
|
+
/* @__PURE__ */ jsx("span", { className: "size-4 shrink-0" }),
|
|
189
|
+
/* @__PURE__ */ jsx(FileTreeIcon, { children: icon ?? /* @__PURE__ */ jsx(FileIcon, { className: "size-4 text-muted-foreground" }) }),
|
|
190
|
+
/* @__PURE__ */ jsx(FileTreeName, { children: name })
|
|
191
|
+
] })
|
|
192
|
+
}
|
|
193
|
+
) });
|
|
194
|
+
};
|
|
195
|
+
var stopPropagation = (e) => e.stopPropagation();
|
|
196
|
+
var FileTreeActions = ({
|
|
197
|
+
className,
|
|
198
|
+
children,
|
|
199
|
+
...props
|
|
200
|
+
}) => /* @__PURE__ */ jsx(
|
|
201
|
+
"div",
|
|
202
|
+
{
|
|
203
|
+
className: cn("ml-auto flex items-center gap-1", className),
|
|
204
|
+
onClick: stopPropagation,
|
|
205
|
+
onKeyDown: stopPropagation,
|
|
206
|
+
role: "group",
|
|
207
|
+
...props,
|
|
208
|
+
children
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
export { FileTree, FileTreeActions, FileTreeFile, FileTreeFolder, FileTreeIcon, FileTreeName };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Experimental_GeneratedImage } from 'ai';
|
|
3
|
+
|
|
4
|
+
type ImageProps = Experimental_GeneratedImage & {
|
|
5
|
+
className?: string;
|
|
6
|
+
alt?: string;
|
|
7
|
+
};
|
|
8
|
+
declare const Image: ({ base64, uint8Array: _uint8Array, mediaType, ...props }: ImageProps) => react_jsx_runtime.JSX.Element;
|
|
9
|
+
|
|
10
|
+
export { Image, type ImageProps };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { cn } from '@chatsdk-dev/ui/lib/utils';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
// src/components/ai-elements/image.tsx
|
|
5
|
+
var Image = ({
|
|
6
|
+
base64,
|
|
7
|
+
uint8Array: _uint8Array,
|
|
8
|
+
mediaType,
|
|
9
|
+
...props
|
|
10
|
+
}) => /* @__PURE__ */ jsx(
|
|
11
|
+
"img",
|
|
12
|
+
{
|
|
13
|
+
...props,
|
|
14
|
+
alt: props.alt,
|
|
15
|
+
className: cn(
|
|
16
|
+
"h-auto max-w-full overflow-hidden rounded-md",
|
|
17
|
+
props.className
|
|
18
|
+
),
|
|
19
|
+
src: `data:${mediaType};base64,${base64}`
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export { Image };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Badge } from '@chatsdk-dev/ui/components/badge';
|
|
3
|
+
import { Carousel } from '@chatsdk-dev/ui/components/carousel';
|
|
4
|
+
import { HoverCard } from '@chatsdk-dev/ui/components/hover-card';
|
|
5
|
+
import { ComponentProps } from 'react';
|
|
6
|
+
|
|
7
|
+
type InlineCitationProps = ComponentProps<"span">;
|
|
8
|
+
declare const InlineCitation: ({ className, ...props }: InlineCitationProps) => react_jsx_runtime.JSX.Element;
|
|
9
|
+
type InlineCitationTextProps = ComponentProps<"span">;
|
|
10
|
+
declare const InlineCitationText: ({ className, ...props }: InlineCitationTextProps) => react_jsx_runtime.JSX.Element;
|
|
11
|
+
type InlineCitationCardProps = ComponentProps<typeof HoverCard>;
|
|
12
|
+
declare const InlineCitationCard: (props: InlineCitationCardProps) => react_jsx_runtime.JSX.Element;
|
|
13
|
+
type InlineCitationCardTriggerProps = ComponentProps<typeof Badge> & {
|
|
14
|
+
sources: string[];
|
|
15
|
+
};
|
|
16
|
+
declare const InlineCitationCardTrigger: ({ sources, className, ...props }: InlineCitationCardTriggerProps) => react_jsx_runtime.JSX.Element;
|
|
17
|
+
type InlineCitationCardBodyProps = ComponentProps<"div">;
|
|
18
|
+
declare const InlineCitationCardBody: ({ className, ...props }: InlineCitationCardBodyProps) => react_jsx_runtime.JSX.Element;
|
|
19
|
+
type InlineCitationCarouselProps = ComponentProps<typeof Carousel>;
|
|
20
|
+
declare const InlineCitationCarousel: ({ className, children, ...props }: InlineCitationCarouselProps) => react_jsx_runtime.JSX.Element;
|
|
21
|
+
type InlineCitationCarouselContentProps = ComponentProps<"div">;
|
|
22
|
+
declare const InlineCitationCarouselContent: (props: InlineCitationCarouselContentProps) => react_jsx_runtime.JSX.Element;
|
|
23
|
+
type InlineCitationCarouselItemProps = ComponentProps<"div">;
|
|
24
|
+
declare const InlineCitationCarouselItem: ({ className, ...props }: InlineCitationCarouselItemProps) => react_jsx_runtime.JSX.Element;
|
|
25
|
+
type InlineCitationCarouselHeaderProps = ComponentProps<"div">;
|
|
26
|
+
declare const InlineCitationCarouselHeader: ({ className, ...props }: InlineCitationCarouselHeaderProps) => react_jsx_runtime.JSX.Element;
|
|
27
|
+
type InlineCitationCarouselIndexProps = ComponentProps<"div">;
|
|
28
|
+
declare const InlineCitationCarouselIndex: ({ children, className, ...props }: InlineCitationCarouselIndexProps) => react_jsx_runtime.JSX.Element;
|
|
29
|
+
type InlineCitationCarouselPrevProps = ComponentProps<"button">;
|
|
30
|
+
declare const InlineCitationCarouselPrev: ({ className, ...props }: InlineCitationCarouselPrevProps) => react_jsx_runtime.JSX.Element;
|
|
31
|
+
type InlineCitationCarouselNextProps = ComponentProps<"button">;
|
|
32
|
+
declare const InlineCitationCarouselNext: ({ className, ...props }: InlineCitationCarouselNextProps) => react_jsx_runtime.JSX.Element;
|
|
33
|
+
type InlineCitationSourceProps = ComponentProps<"div"> & {
|
|
34
|
+
title?: string;
|
|
35
|
+
url?: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
};
|
|
38
|
+
declare const InlineCitationSource: ({ title, url, description, className, children, ...props }: InlineCitationSourceProps) => react_jsx_runtime.JSX.Element;
|
|
39
|
+
type InlineCitationQuoteProps = ComponentProps<"blockquote">;
|
|
40
|
+
declare const InlineCitationQuote: ({ children, className, ...props }: InlineCitationQuoteProps) => react_jsx_runtime.JSX.Element;
|
|
41
|
+
|
|
42
|
+
export { InlineCitation, InlineCitationCard, InlineCitationCardBody, type InlineCitationCardBodyProps, type InlineCitationCardProps, InlineCitationCardTrigger, type InlineCitationCardTriggerProps, InlineCitationCarousel, InlineCitationCarouselContent, type InlineCitationCarouselContentProps, InlineCitationCarouselHeader, type InlineCitationCarouselHeaderProps, InlineCitationCarouselIndex, type InlineCitationCarouselIndexProps, InlineCitationCarouselItem, type InlineCitationCarouselItemProps, InlineCitationCarouselNext, type InlineCitationCarouselNextProps, InlineCitationCarouselPrev, type InlineCitationCarouselPrevProps, type InlineCitationCarouselProps, type InlineCitationProps, InlineCitationQuote, type InlineCitationQuoteProps, InlineCitationSource, type InlineCitationSourceProps, InlineCitationText, type InlineCitationTextProps };
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { Badge } from '@chatsdk-dev/ui/components/badge';
|
|
2
|
+
import { Carousel, CarouselContent, CarouselItem } from '@chatsdk-dev/ui/components/carousel';
|
|
3
|
+
import { HoverCard, HoverCardTrigger, HoverCardContent } from '@chatsdk-dev/ui/components/hover-card';
|
|
4
|
+
import { cn } from '@chatsdk-dev/ui/lib/utils';
|
|
5
|
+
import { ArrowLeftIcon, ArrowRightIcon } from 'lucide-react';
|
|
6
|
+
import { createContext, useState, useCallback, useEffect, useContext } from 'react';
|
|
7
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
var InlineCitation = ({
|
|
10
|
+
className,
|
|
11
|
+
...props
|
|
12
|
+
}) => /* @__PURE__ */ jsx(
|
|
13
|
+
"span",
|
|
14
|
+
{
|
|
15
|
+
className: cn("group inline items-center gap-1", className),
|
|
16
|
+
...props
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
var InlineCitationText = ({
|
|
20
|
+
className,
|
|
21
|
+
...props
|
|
22
|
+
}) => /* @__PURE__ */ jsx(
|
|
23
|
+
"span",
|
|
24
|
+
{
|
|
25
|
+
className: cn("transition-colors group-hover:bg-accent", className),
|
|
26
|
+
...props
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
var InlineCitationCard = (props) => /* @__PURE__ */ jsx(HoverCard, { ...props });
|
|
30
|
+
var InlineCitationCardTrigger = ({
|
|
31
|
+
sources,
|
|
32
|
+
className,
|
|
33
|
+
...props
|
|
34
|
+
}) => /* @__PURE__ */ jsx(
|
|
35
|
+
HoverCardTrigger,
|
|
36
|
+
{
|
|
37
|
+
render: () => /* @__PURE__ */ jsx(
|
|
38
|
+
Badge,
|
|
39
|
+
{
|
|
40
|
+
className: cn("ml-1 rounded-full", className),
|
|
41
|
+
variant: "secondary",
|
|
42
|
+
...props,
|
|
43
|
+
children: sources[0] ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
44
|
+
new URL(sources[0]).hostname,
|
|
45
|
+
" ",
|
|
46
|
+
sources.length > 1 && `+${sources.length - 1}`
|
|
47
|
+
] }) : "unknown"
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
var InlineCitationCardBody = ({
|
|
53
|
+
className,
|
|
54
|
+
...props
|
|
55
|
+
}) => /* @__PURE__ */ jsx(HoverCardContent, { className: cn("relative w-80 p-0", className), ...props });
|
|
56
|
+
var CarouselApiContext = createContext(void 0);
|
|
57
|
+
var useCarouselApi = () => {
|
|
58
|
+
const context = useContext(CarouselApiContext);
|
|
59
|
+
return context;
|
|
60
|
+
};
|
|
61
|
+
var InlineCitationCarousel = ({
|
|
62
|
+
className,
|
|
63
|
+
children,
|
|
64
|
+
...props
|
|
65
|
+
}) => {
|
|
66
|
+
const [api, setApi] = useState();
|
|
67
|
+
return /* @__PURE__ */ jsx(CarouselApiContext.Provider, { value: api, children: /* @__PURE__ */ jsx(Carousel, { className: cn("w-full", className), setApi, ...props, children }) });
|
|
68
|
+
};
|
|
69
|
+
var InlineCitationCarouselContent = (props) => /* @__PURE__ */ jsx(CarouselContent, { ...props });
|
|
70
|
+
var InlineCitationCarouselItem = ({
|
|
71
|
+
className,
|
|
72
|
+
...props
|
|
73
|
+
}) => /* @__PURE__ */ jsx(
|
|
74
|
+
CarouselItem,
|
|
75
|
+
{
|
|
76
|
+
className: cn("w-full space-y-2 p-4 pl-8", className),
|
|
77
|
+
...props
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
var InlineCitationCarouselHeader = ({
|
|
81
|
+
className,
|
|
82
|
+
...props
|
|
83
|
+
}) => /* @__PURE__ */ jsx(
|
|
84
|
+
"div",
|
|
85
|
+
{
|
|
86
|
+
className: cn(
|
|
87
|
+
"flex items-center justify-between gap-2 rounded-t-md bg-secondary p-2",
|
|
88
|
+
className
|
|
89
|
+
),
|
|
90
|
+
...props
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
var InlineCitationCarouselIndex = ({
|
|
94
|
+
children,
|
|
95
|
+
className,
|
|
96
|
+
...props
|
|
97
|
+
}) => {
|
|
98
|
+
const api = useCarouselApi();
|
|
99
|
+
const [current, setCurrent] = useState(0);
|
|
100
|
+
const [count, setCount] = useState(0);
|
|
101
|
+
const syncState = useCallback(() => {
|
|
102
|
+
if (!api) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
setCount(api.scrollSnapList().length);
|
|
106
|
+
setCurrent(api.selectedScrollSnap() + 1);
|
|
107
|
+
}, [api]);
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if (!api) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
syncState();
|
|
113
|
+
api.on("select", syncState);
|
|
114
|
+
return () => {
|
|
115
|
+
api.off("select", syncState);
|
|
116
|
+
};
|
|
117
|
+
}, [api, syncState]);
|
|
118
|
+
return /* @__PURE__ */ jsx(
|
|
119
|
+
"div",
|
|
120
|
+
{
|
|
121
|
+
className: cn(
|
|
122
|
+
"flex flex-1 items-center justify-end px-3 py-1 text-muted-foreground text-xs",
|
|
123
|
+
className
|
|
124
|
+
),
|
|
125
|
+
...props,
|
|
126
|
+
children: children ?? `${current}/${count}`
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
var InlineCitationCarouselPrev = ({
|
|
131
|
+
className,
|
|
132
|
+
...props
|
|
133
|
+
}) => {
|
|
134
|
+
const api = useCarouselApi();
|
|
135
|
+
const handleClick = useCallback(() => {
|
|
136
|
+
if (api) {
|
|
137
|
+
api.scrollPrev();
|
|
138
|
+
}
|
|
139
|
+
}, [api]);
|
|
140
|
+
return /* @__PURE__ */ jsx(
|
|
141
|
+
"button",
|
|
142
|
+
{
|
|
143
|
+
"aria-label": "Previous",
|
|
144
|
+
className: cn("shrink-0", className),
|
|
145
|
+
onClick: handleClick,
|
|
146
|
+
type: "button",
|
|
147
|
+
...props,
|
|
148
|
+
children: /* @__PURE__ */ jsx(ArrowLeftIcon, { className: "size-4 text-muted-foreground" })
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
};
|
|
152
|
+
var InlineCitationCarouselNext = ({
|
|
153
|
+
className,
|
|
154
|
+
...props
|
|
155
|
+
}) => {
|
|
156
|
+
const api = useCarouselApi();
|
|
157
|
+
const handleClick = useCallback(() => {
|
|
158
|
+
if (api) {
|
|
159
|
+
api.scrollNext();
|
|
160
|
+
}
|
|
161
|
+
}, [api]);
|
|
162
|
+
return /* @__PURE__ */ jsx(
|
|
163
|
+
"button",
|
|
164
|
+
{
|
|
165
|
+
"aria-label": "Next",
|
|
166
|
+
className: cn("shrink-0", className),
|
|
167
|
+
onClick: handleClick,
|
|
168
|
+
type: "button",
|
|
169
|
+
...props,
|
|
170
|
+
children: /* @__PURE__ */ jsx(ArrowRightIcon, { className: "size-4 text-muted-foreground" })
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
};
|
|
174
|
+
var InlineCitationSource = ({
|
|
175
|
+
title,
|
|
176
|
+
url,
|
|
177
|
+
description,
|
|
178
|
+
className,
|
|
179
|
+
children,
|
|
180
|
+
...props
|
|
181
|
+
}) => /* @__PURE__ */ jsxs("div", { className: cn("space-y-1", className), ...props, children: [
|
|
182
|
+
title && /* @__PURE__ */ jsx("h4", { className: "truncate font-medium text-sm leading-tight", children: title }),
|
|
183
|
+
url && /* @__PURE__ */ jsx("p", { className: "truncate break-all text-muted-foreground text-xs", children: url }),
|
|
184
|
+
description && /* @__PURE__ */ jsx("p", { className: "line-clamp-3 text-muted-foreground text-sm leading-relaxed", children: description }),
|
|
185
|
+
children
|
|
186
|
+
] });
|
|
187
|
+
var InlineCitationQuote = ({
|
|
188
|
+
children,
|
|
189
|
+
className,
|
|
190
|
+
...props
|
|
191
|
+
}) => /* @__PURE__ */ jsx(
|
|
192
|
+
"blockquote",
|
|
193
|
+
{
|
|
194
|
+
className: cn(
|
|
195
|
+
"border-muted border-l-2 pl-3 text-muted-foreground text-sm italic",
|
|
196
|
+
className
|
|
197
|
+
),
|
|
198
|
+
...props,
|
|
199
|
+
children
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
export { InlineCitation, InlineCitationCard, InlineCitationCardBody, InlineCitationCardTrigger, InlineCitationCarousel, InlineCitationCarouselContent, InlineCitationCarouselHeader, InlineCitationCarouselIndex, InlineCitationCarouselItem, InlineCitationCarouselNext, InlineCitationCarouselPrev, InlineCitationQuote, InlineCitationSource, InlineCitationText };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentProps, ReactNode } from 'react';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import { TProps } from 'react-jsx-parser';
|
|
5
|
+
|
|
6
|
+
interface JSXPreviewContextValue {
|
|
7
|
+
jsx: string;
|
|
8
|
+
processedJsx: string;
|
|
9
|
+
isStreaming: boolean;
|
|
10
|
+
error: Error | null;
|
|
11
|
+
setError: (error: Error | null) => void;
|
|
12
|
+
setLastGoodJsx: (jsx: string) => void;
|
|
13
|
+
components: TProps["components"];
|
|
14
|
+
bindings: TProps["bindings"];
|
|
15
|
+
onErrorProp?: (error: Error) => void;
|
|
16
|
+
}
|
|
17
|
+
declare const useJSXPreview: () => JSXPreviewContextValue;
|
|
18
|
+
type JSXPreviewProps = ComponentProps<"div"> & {
|
|
19
|
+
jsx: string;
|
|
20
|
+
isStreaming?: boolean;
|
|
21
|
+
components?: TProps["components"];
|
|
22
|
+
bindings?: TProps["bindings"];
|
|
23
|
+
onError?: (error: Error) => void;
|
|
24
|
+
};
|
|
25
|
+
declare const JSXPreview: react.MemoExoticComponent<({ jsx, isStreaming, components, bindings, onError, className, children, ...props }: JSXPreviewProps) => react_jsx_runtime.JSX.Element>;
|
|
26
|
+
type JSXPreviewContentProps = Omit<ComponentProps<"div">, "children">;
|
|
27
|
+
declare const JSXPreviewContent: react.MemoExoticComponent<({ className, ...props }: JSXPreviewContentProps) => react_jsx_runtime.JSX.Element>;
|
|
28
|
+
type JSXPreviewErrorProps = ComponentProps<"div"> & {
|
|
29
|
+
children?: ReactNode | ((error: Error) => ReactNode);
|
|
30
|
+
};
|
|
31
|
+
declare const JSXPreviewError: react.MemoExoticComponent<({ className, children, ...props }: JSXPreviewErrorProps) => react_jsx_runtime.JSX.Element | null>;
|
|
32
|
+
|
|
33
|
+
export { JSXPreview, JSXPreviewContent, type JSXPreviewContentProps, JSXPreviewError, type JSXPreviewErrorProps, type JSXPreviewProps, useJSXPreview };
|