@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,83 @@
|
|
|
1
|
+
import { cloneElement } from 'react';
|
|
2
|
+
import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogCancel, AlertDialogAction } from '@chatsdk-dev/ui/components/alert-dialog';
|
|
3
|
+
import { Button } from '@chatsdk-dev/ui/components/button';
|
|
4
|
+
import { ButtonLoaderIcon } from '@chatsdk-dev/ui/components/button-loader';
|
|
5
|
+
import { Drawer, DrawerTrigger, DrawerContent, DrawerHeader, DrawerTitle, DrawerDescription, DrawerFooter, DrawerClose } from '@chatsdk-dev/ui/components/drawer';
|
|
6
|
+
import { useBreakpoint } from '@chatsdk-dev/ui/hooks/use-breakpoint';
|
|
7
|
+
import { useControllableState } from '@chatsdk-dev/ui/hooks/use-controllable-state';
|
|
8
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
9
|
+
|
|
10
|
+
// src/components/responsive-alert-dialog.tsx
|
|
11
|
+
function ResponsiveAlertDialog({
|
|
12
|
+
open,
|
|
13
|
+
onOpenChange,
|
|
14
|
+
children,
|
|
15
|
+
trigger,
|
|
16
|
+
title,
|
|
17
|
+
titleIcon,
|
|
18
|
+
description,
|
|
19
|
+
isPending,
|
|
20
|
+
action,
|
|
21
|
+
onAction,
|
|
22
|
+
cancelLabel,
|
|
23
|
+
onCancel
|
|
24
|
+
}) {
|
|
25
|
+
const [openState, setOpenState] = useControllableState({
|
|
26
|
+
value: open,
|
|
27
|
+
defaultValue: false,
|
|
28
|
+
onChange: onOpenChange
|
|
29
|
+
});
|
|
30
|
+
const sm = useBreakpoint("sm");
|
|
31
|
+
if (sm) {
|
|
32
|
+
return /* @__PURE__ */ jsxs(AlertDialog, { open: openState, onOpenChange: setOpenState, children: [
|
|
33
|
+
trigger && /* @__PURE__ */ jsx(
|
|
34
|
+
AlertDialogTrigger,
|
|
35
|
+
{
|
|
36
|
+
render: (props) => cloneElement(trigger, props)
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
/* @__PURE__ */ jsxs(AlertDialogContent, { className: "sm:max-w-106", children: [
|
|
40
|
+
/* @__PURE__ */ jsx(AlertDialogHeader, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
41
|
+
titleIcon,
|
|
42
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
43
|
+
/* @__PURE__ */ jsx(AlertDialogTitle, { children: title }),
|
|
44
|
+
/* @__PURE__ */ jsx(AlertDialogDescription, { children: description })
|
|
45
|
+
] })
|
|
46
|
+
] }) }),
|
|
47
|
+
children,
|
|
48
|
+
/* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
|
|
49
|
+
cancelLabel && /* @__PURE__ */ jsx(AlertDialogCancel, { onClick: onCancel, children: cancelLabel }),
|
|
50
|
+
typeof action === "string" ? /* @__PURE__ */ jsx(
|
|
51
|
+
AlertDialogAction,
|
|
52
|
+
{
|
|
53
|
+
onClick: onAction,
|
|
54
|
+
disabled: isPending,
|
|
55
|
+
variant: "destructive",
|
|
56
|
+
className: "relative inline-flex px-7",
|
|
57
|
+
children: /* @__PURE__ */ jsxs("div", { className: "relative flex items-center justify-center", children: [
|
|
58
|
+
isPending && /* @__PURE__ */ jsx(ButtonLoaderIcon, {}),
|
|
59
|
+
action
|
|
60
|
+
] })
|
|
61
|
+
}
|
|
62
|
+
) : action
|
|
63
|
+
] })
|
|
64
|
+
] })
|
|
65
|
+
] });
|
|
66
|
+
}
|
|
67
|
+
return /* @__PURE__ */ jsxs(Drawer, { open: openState, onOpenChange: setOpenState, children: [
|
|
68
|
+
/* @__PURE__ */ jsx(DrawerTrigger, { asChild: true, children: trigger }),
|
|
69
|
+
/* @__PURE__ */ jsxs(DrawerContent, { children: [
|
|
70
|
+
/* @__PURE__ */ jsxs(DrawerHeader, { className: "text-left", children: [
|
|
71
|
+
/* @__PURE__ */ jsx(DrawerTitle, { children: title }),
|
|
72
|
+
/* @__PURE__ */ jsx(DrawerDescription, { children: description })
|
|
73
|
+
] }),
|
|
74
|
+
children,
|
|
75
|
+
/* @__PURE__ */ jsxs(DrawerFooter, { className: "pt-2", children: [
|
|
76
|
+
cancelLabel && /* @__PURE__ */ jsx(DrawerClose, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "outline", children: cancelLabel }) }),
|
|
77
|
+
typeof action === "string" ? /* @__PURE__ */ jsx(Button, { variant: "destructive", onClick: onAction, children: action }) : action
|
|
78
|
+
] })
|
|
79
|
+
] })
|
|
80
|
+
] });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { ResponsiveAlertDialog };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// src/i18n/resources/en.json
|
|
2
|
+
var en_default = {
|
|
3
|
+
chat: {
|
|
4
|
+
"chat-card": {
|
|
5
|
+
"insufficient-credits-error": "This AI Chat is currently unavailable. If you are the owner, please check your account."
|
|
6
|
+
},
|
|
7
|
+
header: {
|
|
8
|
+
"history-tab-label": "History",
|
|
9
|
+
menu: {
|
|
10
|
+
"new-conversation-menu-item-label": "Start New Chat",
|
|
11
|
+
"history-menu-item-label": "View History"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
history: {
|
|
15
|
+
empty: {
|
|
16
|
+
title: "No conversations yet...",
|
|
17
|
+
description: "Start a conversation to see your history here"
|
|
18
|
+
},
|
|
19
|
+
"unitled-conversation": "Untitled conversation",
|
|
20
|
+
"new-conversation": "Start New Conversation"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// src/i18n/config.ts
|
|
26
|
+
var cookieName = "i18next";
|
|
27
|
+
var headerName = "x-i18next-current-language";
|
|
28
|
+
var fallbackLng = "en";
|
|
29
|
+
var languages = [fallbackLng];
|
|
30
|
+
var namespaces = ["chat"];
|
|
31
|
+
var defaultNamespace = "chat";
|
|
32
|
+
var resources = {
|
|
33
|
+
en: en_default
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { cookieName, defaultNamespace, fallbackLng, headerName, languages, namespaces, resources };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// src/features/molecule/utils.ts
|
|
2
|
+
function isObject(item) {
|
|
3
|
+
return item !== null && typeof item === "object" && !Array.isArray(item);
|
|
4
|
+
}
|
|
5
|
+
function deepMerge(target, ...sources) {
|
|
6
|
+
const result = { ...target };
|
|
7
|
+
for (const source of sources) {
|
|
8
|
+
if (!isObject(source)) {
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
for (const key in source) {
|
|
12
|
+
const targetValue = result[key];
|
|
13
|
+
const sourceValue = source[key];
|
|
14
|
+
if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
|
|
15
|
+
result[key] = sourceValue;
|
|
16
|
+
} else if (isObject(targetValue) && isObject(sourceValue)) {
|
|
17
|
+
result[key] = deepMerge(
|
|
18
|
+
targetValue,
|
|
19
|
+
sourceValue
|
|
20
|
+
);
|
|
21
|
+
} else if (sourceValue !== void 0 && sourceValue !== null) {
|
|
22
|
+
result[key] = sourceValue;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
function mergeObjectsOneLevel(a, b) {
|
|
29
|
+
if (!a && !b) return void 0;
|
|
30
|
+
if (!b) return a;
|
|
31
|
+
if (!a) return b;
|
|
32
|
+
const result = { ...a };
|
|
33
|
+
for (const key in b) {
|
|
34
|
+
result[key] = { ...result[key], ...b[key] };
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
function mergeFont(...fontConfigurations) {
|
|
39
|
+
if (!fontConfigurations) {
|
|
40
|
+
return void 0;
|
|
41
|
+
}
|
|
42
|
+
return Object.entries(fontConfigurations).reduce(
|
|
43
|
+
(acc, [key, value]) => {
|
|
44
|
+
return { ...acc, [key]: value };
|
|
45
|
+
},
|
|
46
|
+
{}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
function mergeTheme(...args) {
|
|
50
|
+
const mergedTheme = args.reduce(
|
|
51
|
+
(acc, curr) => {
|
|
52
|
+
if (!curr) return acc;
|
|
53
|
+
const { font: accFont, components: accComponents } = acc || {};
|
|
54
|
+
const currFiltered = Object.fromEntries(
|
|
55
|
+
Object.entries(curr).filter(
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
57
|
+
([_, value]) => value !== void 0 && value !== null
|
|
58
|
+
)
|
|
59
|
+
) || {};
|
|
60
|
+
const {
|
|
61
|
+
font: currFont,
|
|
62
|
+
components: currComponents,
|
|
63
|
+
...currRest
|
|
64
|
+
} = currFiltered || {};
|
|
65
|
+
const font = mergeFont(accFont || {}, currFont || {});
|
|
66
|
+
acc.components = accComponents || currComponents ? Object.keys({ ...accComponents, ...currComponents }).reduce(
|
|
67
|
+
(merged, key) => ({
|
|
68
|
+
...merged,
|
|
69
|
+
[key]: typeof accComponents?.[key] === "object" && typeof currComponents?.[key] === "object" ? {
|
|
70
|
+
...accComponents?.[key] || {},
|
|
71
|
+
...currComponents?.[key] || {}
|
|
72
|
+
} : currComponents?.[key] ?? accComponents?.[key]
|
|
73
|
+
}),
|
|
74
|
+
{}
|
|
75
|
+
) : void 0;
|
|
76
|
+
return { ...acc, ...currRest, font };
|
|
77
|
+
},
|
|
78
|
+
{}
|
|
79
|
+
);
|
|
80
|
+
return mergedTheme;
|
|
81
|
+
}
|
|
82
|
+
function mergeContext(globalContext, context) {
|
|
83
|
+
return { ...deepMerge(globalContext || {}, context || {}) };
|
|
84
|
+
}
|
|
85
|
+
function mergeLocale(globalLocale, locale) {
|
|
86
|
+
return locale || globalLocale;
|
|
87
|
+
}
|
|
88
|
+
function mergeTranslations(...args) {
|
|
89
|
+
const filteredArgs = args.filter((arg) => arg !== void 0);
|
|
90
|
+
return deepMerge({}, ...filteredArgs);
|
|
91
|
+
}
|
|
92
|
+
function mergeApi(globalApi, api) {
|
|
93
|
+
return { ...globalApi, ...api };
|
|
94
|
+
}
|
|
95
|
+
function mergeLogger(globalLogger, logger) {
|
|
96
|
+
return logger || globalLogger;
|
|
97
|
+
}
|
|
98
|
+
function mergeConfigs(...args) {
|
|
99
|
+
return args.reduce((acc, curr) => {
|
|
100
|
+
return {
|
|
101
|
+
...acc,
|
|
102
|
+
...curr,
|
|
103
|
+
theme: mergeTheme(acc.theme, curr.theme),
|
|
104
|
+
context: mergeContext(acc.context, curr.context),
|
|
105
|
+
locale: mergeLocale(acc.locale, curr.locale),
|
|
106
|
+
translations: mergeTranslations(acc.translations, curr.translations),
|
|
107
|
+
api: mergeApi(acc.api, curr.api),
|
|
108
|
+
logger: mergeLogger(acc.logger, curr.logger)
|
|
109
|
+
};
|
|
110
|
+
}, {});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export { deepMerge, mergeApi, mergeConfigs, mergeContext, mergeFont, mergeLocale, mergeLogger, mergeObjectsOneLevel, mergeTheme, mergeTranslations };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { UserIcon, BotIcon, RefreshCcwIcon, CopyIcon } from 'lucide-react';
|
|
2
|
+
import { Fragment } from 'react';
|
|
3
|
+
import { Reasoning, ReasoningTrigger, ReasoningContent } from '@chatsdk-dev/elements/components/ai-elements/reasoning';
|
|
4
|
+
import { Sources, SourcesTrigger, SourcesContent, Source } from '@chatsdk-dev/elements/components/ai-elements/sources';
|
|
5
|
+
import { useCopyToClipboard } from '@chatsdk-dev/elements/common/use-copy-to-clipboard';
|
|
6
|
+
import { Actions, Action } from '@chatsdk-dev/elements/components/ai-elements/actions';
|
|
7
|
+
import { Message, MessageContent } from '@chatsdk-dev/elements/components/ai-elements/message';
|
|
8
|
+
import { Response } from '@chatsdk-dev/elements/components/ai-elements/response';
|
|
9
|
+
import { cn } from '@chatsdk-dev/ui/lib/utils';
|
|
10
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
11
|
+
|
|
12
|
+
// src/features/chat/chat-message.tsx
|
|
13
|
+
function ChatMessage({
|
|
14
|
+
messages,
|
|
15
|
+
withAvatar = false
|
|
16
|
+
}) {
|
|
17
|
+
const [, copyToClipboard] = useCopyToClipboard();
|
|
18
|
+
return messages.map((message, messageIndex) => {
|
|
19
|
+
const isUser = message.role === "user";
|
|
20
|
+
const isAssistant = message.role === "assistant";
|
|
21
|
+
if (!message.parts.length) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
25
|
+
isAssistant && message.parts.filter((part) => part.type === "source-url").length > 0 && /* @__PURE__ */ jsxs(Sources, { children: [
|
|
26
|
+
/* @__PURE__ */ jsx(
|
|
27
|
+
SourcesTrigger,
|
|
28
|
+
{
|
|
29
|
+
count: message.parts.filter((part) => part.type === "source-url").length
|
|
30
|
+
}
|
|
31
|
+
),
|
|
32
|
+
message.parts.filter((part) => part.type === "source-url").map((part, i) => /* @__PURE__ */ jsx(SourcesContent, { children: /* @__PURE__ */ jsx(
|
|
33
|
+
Source,
|
|
34
|
+
{
|
|
35
|
+
href: part.url,
|
|
36
|
+
title: part.url
|
|
37
|
+
},
|
|
38
|
+
`${message.id}-${i}`
|
|
39
|
+
) }, `${message.id}-${i}`))
|
|
40
|
+
] }),
|
|
41
|
+
message.parts.map((part, messagePartIndex) => {
|
|
42
|
+
switch (part.type) {
|
|
43
|
+
case "text":
|
|
44
|
+
if (!part.text) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
48
|
+
/* @__PURE__ */ jsxs(
|
|
49
|
+
Message,
|
|
50
|
+
{
|
|
51
|
+
className: cn("flex gap-1.5", isUser && "flex-row-reverse"),
|
|
52
|
+
from: message.role,
|
|
53
|
+
children: [
|
|
54
|
+
withAvatar && /* @__PURE__ */ jsx(
|
|
55
|
+
"div",
|
|
56
|
+
{
|
|
57
|
+
className: cn(
|
|
58
|
+
"flex size-7 shrink-0 items-center justify-center rounded-full border text-xs",
|
|
59
|
+
isUser ? "bg-primary text-primary-foreground border-primary" : isAssistant ? "bg-zinc-100 text-zinc-600 border-zinc-200 dark:bg-zinc-800 dark:text-zinc-400 dark:border-zinc-700" : "bg-amber-50 text-amber-600 border-amber-200 dark:bg-amber-950 dark:text-amber-400 dark:border-amber-800"
|
|
60
|
+
),
|
|
61
|
+
children: isUser ? /* @__PURE__ */ jsx(UserIcon, { className: "size-3.5" }) : /* @__PURE__ */ jsx(BotIcon, { className: "size-3.5" })
|
|
62
|
+
}
|
|
63
|
+
),
|
|
64
|
+
/* @__PURE__ */ jsx(
|
|
65
|
+
MessageContent,
|
|
66
|
+
{
|
|
67
|
+
className: cn(
|
|
68
|
+
"rounded-lg px-3 py-2 text-sm",
|
|
69
|
+
isUser ? "bg-primary text-primary-foreground rounded-tr-sm" : isAssistant ? "bg-zinc-100 text-zinc-800 dark:bg-zinc-800 dark:text-zinc-100 rounded-tl-sm ring-1 ring-zinc-200 dark:ring-zinc-700" : "bg-amber-50 text-amber-800 dark:bg-amber-950 dark:text-amber-200 rounded-tl-sm ring-1 ring-amber-200 dark:ring-amber-800 italic"
|
|
70
|
+
),
|
|
71
|
+
children: /* @__PURE__ */ jsx(Response, { children: part.text })
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
),
|
|
77
|
+
isAssistant && /* @__PURE__ */ jsxs(
|
|
78
|
+
Actions,
|
|
79
|
+
{
|
|
80
|
+
className: cn(
|
|
81
|
+
"mt-[-6px] ml-[-10px] mb-[-20px]",
|
|
82
|
+
withAvatar && "ml-6"
|
|
83
|
+
),
|
|
84
|
+
children: [
|
|
85
|
+
/* @__PURE__ */ jsx(
|
|
86
|
+
Action,
|
|
87
|
+
{
|
|
88
|
+
label: "Retry",
|
|
89
|
+
children: /* @__PURE__ */ jsx(RefreshCcwIcon, { className: "size-3" })
|
|
90
|
+
}
|
|
91
|
+
),
|
|
92
|
+
/* @__PURE__ */ jsx(
|
|
93
|
+
Action,
|
|
94
|
+
{
|
|
95
|
+
onClick: () => copyToClipboard?.(part.text),
|
|
96
|
+
label: "Copy",
|
|
97
|
+
children: /* @__PURE__ */ jsx(CopyIcon, { className: "size-3" })
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
] }, `${message.id}-${messagePartIndex}`);
|
|
104
|
+
case "reasoning":
|
|
105
|
+
return /* @__PURE__ */ jsxs(
|
|
106
|
+
Reasoning,
|
|
107
|
+
{
|
|
108
|
+
className: "w-full",
|
|
109
|
+
isStreaming: status === "streaming" && messageIndex === message.parts.length - 1 && message.id === messages.at(-1)?.id,
|
|
110
|
+
children: [
|
|
111
|
+
/* @__PURE__ */ jsx(ReasoningTrigger, {}),
|
|
112
|
+
/* @__PURE__ */ jsx(ReasoningContent, { children: part.text })
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
`${message.id}-${messagePartIndex}`
|
|
116
|
+
);
|
|
117
|
+
default:
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
] }, message.id);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export { ChatMessage };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// src/features/chat/queries/query-keys.ts
|
|
2
|
+
var chatQueryKeys = {
|
|
3
|
+
all: () => ["chat"],
|
|
4
|
+
get: (chatId) => [...chatQueryKeys.all(), "get", chatId],
|
|
5
|
+
listConversations: (chatId) => [...chatQueryKeys.get(chatId), "conversations"],
|
|
6
|
+
conversation: (chatId, conversationId) => [...chatQueryKeys.get(chatId), "conversation", conversationId]
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { chatQueryKeys };
|