@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,119 @@
|
|
|
1
|
+
import { Button } from '@chatsdk-dev/ui/components/button';
|
|
2
|
+
import { cn } from '@chatsdk-dev/ui/lib/utils';
|
|
3
|
+
import { ArrowDownIcon, DownloadIcon } from 'lucide-react';
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
|
+
import { StickToBottom, useStickToBottomContext } from 'use-stick-to-bottom';
|
|
6
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
var Conversation = ({ className, ...props }) => /* @__PURE__ */ jsx(
|
|
9
|
+
StickToBottom,
|
|
10
|
+
{
|
|
11
|
+
className: cn("relative flex-1 overflow-y-hidden", className),
|
|
12
|
+
initial: "smooth",
|
|
13
|
+
resize: "smooth",
|
|
14
|
+
role: "log",
|
|
15
|
+
...props
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
var ConversationContent = ({
|
|
19
|
+
className,
|
|
20
|
+
...props
|
|
21
|
+
}) => /* @__PURE__ */ jsx(
|
|
22
|
+
StickToBottom.Content,
|
|
23
|
+
{
|
|
24
|
+
className: cn("flex flex-col gap-8 p-4", className),
|
|
25
|
+
...props
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
var ConversationEmptyState = ({
|
|
29
|
+
className,
|
|
30
|
+
title = "No messages yet",
|
|
31
|
+
description = "Start a conversation to see messages here",
|
|
32
|
+
icon,
|
|
33
|
+
children,
|
|
34
|
+
...props
|
|
35
|
+
}) => /* @__PURE__ */ jsx(
|
|
36
|
+
"div",
|
|
37
|
+
{
|
|
38
|
+
className: cn(
|
|
39
|
+
"flex size-full flex-col items-center justify-center gap-3 p-8 text-center",
|
|
40
|
+
className
|
|
41
|
+
),
|
|
42
|
+
...props,
|
|
43
|
+
children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
44
|
+
icon && /* @__PURE__ */ jsx("div", { className: "text-muted-foreground", children: icon }),
|
|
45
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
46
|
+
/* @__PURE__ */ jsx("h3", { className: "font-medium text-sm", children: title }),
|
|
47
|
+
description && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm", children: description })
|
|
48
|
+
] })
|
|
49
|
+
] })
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
var ConversationScrollButton = ({
|
|
53
|
+
className,
|
|
54
|
+
...props
|
|
55
|
+
}) => {
|
|
56
|
+
const { isAtBottom, scrollToBottom } = useStickToBottomContext();
|
|
57
|
+
const handleScrollToBottom = useCallback(() => {
|
|
58
|
+
scrollToBottom();
|
|
59
|
+
}, [scrollToBottom]);
|
|
60
|
+
return !isAtBottom && /* @__PURE__ */ jsx(
|
|
61
|
+
Button,
|
|
62
|
+
{
|
|
63
|
+
className: cn(
|
|
64
|
+
"absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full dark:bg-background dark:hover:bg-muted",
|
|
65
|
+
className
|
|
66
|
+
),
|
|
67
|
+
onClick: handleScrollToBottom,
|
|
68
|
+
size: "icon",
|
|
69
|
+
type: "button",
|
|
70
|
+
variant: "outline",
|
|
71
|
+
...props,
|
|
72
|
+
children: /* @__PURE__ */ jsx(ArrowDownIcon, { className: "size-4" })
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
var getMessageText = (message) => message.parts.filter((part) => part.type === "text").map((part) => part.text).join("");
|
|
77
|
+
var defaultFormatMessage = (message) => {
|
|
78
|
+
const roleLabel = message.role.charAt(0).toUpperCase() + message.role.slice(1);
|
|
79
|
+
return `**${roleLabel}:** ${getMessageText(message)}`;
|
|
80
|
+
};
|
|
81
|
+
var messagesToMarkdown = (messages, formatMessage = defaultFormatMessage) => messages.map((msg, i) => formatMessage(msg, i)).join("\n\n");
|
|
82
|
+
var ConversationDownload = ({
|
|
83
|
+
messages,
|
|
84
|
+
filename = "conversation.md",
|
|
85
|
+
formatMessage = defaultFormatMessage,
|
|
86
|
+
className,
|
|
87
|
+
children,
|
|
88
|
+
...props
|
|
89
|
+
}) => {
|
|
90
|
+
const handleDownload = useCallback(() => {
|
|
91
|
+
const markdown = messagesToMarkdown(messages, formatMessage);
|
|
92
|
+
const blob = new Blob([markdown], { type: "text/markdown" });
|
|
93
|
+
const url = URL.createObjectURL(blob);
|
|
94
|
+
const link = document.createElement("a");
|
|
95
|
+
link.href = url;
|
|
96
|
+
link.download = filename;
|
|
97
|
+
document.body.append(link);
|
|
98
|
+
link.click();
|
|
99
|
+
link.remove();
|
|
100
|
+
URL.revokeObjectURL(url);
|
|
101
|
+
}, [messages, filename, formatMessage]);
|
|
102
|
+
return /* @__PURE__ */ jsx(
|
|
103
|
+
Button,
|
|
104
|
+
{
|
|
105
|
+
className: cn(
|
|
106
|
+
"absolute top-4 right-4 rounded-full dark:bg-background dark:hover:bg-muted",
|
|
107
|
+
className
|
|
108
|
+
),
|
|
109
|
+
onClick: handleDownload,
|
|
110
|
+
size: "icon",
|
|
111
|
+
type: "button",
|
|
112
|
+
variant: "outline",
|
|
113
|
+
...props,
|
|
114
|
+
children: children ?? /* @__PURE__ */ jsx(DownloadIcon, { className: "size-4" })
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export { Conversation, ConversationContent, ConversationDownload, ConversationEmptyState, ConversationScrollButton, messagesToMarkdown };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { EdgeProps } from '@xyflow/react';
|
|
3
|
+
|
|
4
|
+
declare const Edge: {
|
|
5
|
+
Animated: ({ id, source, target, markerEnd, style }: EdgeProps) => react_jsx_runtime.JSX.Element | null;
|
|
6
|
+
Temporary: ({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, }: EdgeProps) => react_jsx_runtime.JSX.Element;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { Edge };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { getSimpleBezierPath, BaseEdge, useInternalNode, getBezierPath, Position } from '@xyflow/react';
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
// src/components/ai-elements/edge.tsx
|
|
5
|
+
var Temporary = ({
|
|
6
|
+
id,
|
|
7
|
+
sourceX,
|
|
8
|
+
sourceY,
|
|
9
|
+
targetX,
|
|
10
|
+
targetY,
|
|
11
|
+
sourcePosition,
|
|
12
|
+
targetPosition
|
|
13
|
+
}) => {
|
|
14
|
+
const [edgePath] = getSimpleBezierPath({
|
|
15
|
+
sourcePosition,
|
|
16
|
+
sourceX,
|
|
17
|
+
sourceY,
|
|
18
|
+
targetPosition,
|
|
19
|
+
targetX,
|
|
20
|
+
targetY
|
|
21
|
+
});
|
|
22
|
+
return /* @__PURE__ */ jsx(
|
|
23
|
+
BaseEdge,
|
|
24
|
+
{
|
|
25
|
+
className: "stroke-1 stroke-ring",
|
|
26
|
+
id,
|
|
27
|
+
path: edgePath,
|
|
28
|
+
style: {
|
|
29
|
+
strokeDasharray: "5, 5"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
var getHandleCoordsByPosition = (node, handlePosition) => {
|
|
35
|
+
const handleType = handlePosition === Position.Left ? "target" : "source";
|
|
36
|
+
const handle = node.internals.handleBounds?.[handleType]?.find(
|
|
37
|
+
(h) => h.position === handlePosition
|
|
38
|
+
);
|
|
39
|
+
if (!handle) {
|
|
40
|
+
return [0, 0];
|
|
41
|
+
}
|
|
42
|
+
let offsetX = handle.width / 2;
|
|
43
|
+
let offsetY = handle.height / 2;
|
|
44
|
+
switch (handlePosition) {
|
|
45
|
+
case Position.Left: {
|
|
46
|
+
offsetX = 0;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
case Position.Right: {
|
|
50
|
+
offsetX = handle.width;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
case Position.Top: {
|
|
54
|
+
offsetY = 0;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
case Position.Bottom: {
|
|
58
|
+
offsetY = handle.height;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
default: {
|
|
62
|
+
throw new Error(`Invalid handle position: ${handlePosition}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const x = node.internals.positionAbsolute.x + handle.x + offsetX;
|
|
66
|
+
const y = node.internals.positionAbsolute.y + handle.y + offsetY;
|
|
67
|
+
return [x, y];
|
|
68
|
+
};
|
|
69
|
+
var getEdgeParams = (source, target) => {
|
|
70
|
+
const sourcePos = Position.Right;
|
|
71
|
+
const [sx, sy] = getHandleCoordsByPosition(source, sourcePos);
|
|
72
|
+
const targetPos = Position.Left;
|
|
73
|
+
const [tx, ty] = getHandleCoordsByPosition(target, targetPos);
|
|
74
|
+
return {
|
|
75
|
+
sourcePos,
|
|
76
|
+
sx,
|
|
77
|
+
sy,
|
|
78
|
+
targetPos,
|
|
79
|
+
tx,
|
|
80
|
+
ty
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
var Animated = ({ id, source, target, markerEnd, style }) => {
|
|
84
|
+
const sourceNode = useInternalNode(source);
|
|
85
|
+
const targetNode = useInternalNode(target);
|
|
86
|
+
if (!(sourceNode && targetNode)) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
const { sx, sy, tx, ty, sourcePos, targetPos } = getEdgeParams(
|
|
90
|
+
sourceNode,
|
|
91
|
+
targetNode
|
|
92
|
+
);
|
|
93
|
+
const [edgePath] = getBezierPath({
|
|
94
|
+
sourcePosition: sourcePos,
|
|
95
|
+
sourceX: sx,
|
|
96
|
+
sourceY: sy,
|
|
97
|
+
targetPosition: targetPos,
|
|
98
|
+
targetX: tx,
|
|
99
|
+
targetY: ty
|
|
100
|
+
});
|
|
101
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
102
|
+
/* @__PURE__ */ jsx(BaseEdge, { id, markerEnd, path: edgePath, style }),
|
|
103
|
+
/* @__PURE__ */ jsx("circle", { fill: "var(--primary)", r: "4", children: /* @__PURE__ */ jsx("animateMotion", { dur: "2s", path: edgePath, repeatCount: "indefinite" }) })
|
|
104
|
+
] });
|
|
105
|
+
};
|
|
106
|
+
var Edge = {
|
|
107
|
+
Animated,
|
|
108
|
+
Temporary
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export { Edge };
|
|
@@ -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 { Button } from '@chatsdk-dev/ui/components/button';
|
|
4
|
+
import { Switch } from '@chatsdk-dev/ui/components/switch';
|
|
5
|
+
import { HTMLAttributes, ComponentProps } from 'react';
|
|
6
|
+
|
|
7
|
+
type EnvironmentVariablesProps = HTMLAttributes<HTMLDivElement> & {
|
|
8
|
+
showValues?: boolean;
|
|
9
|
+
defaultShowValues?: boolean;
|
|
10
|
+
onShowValuesChange?: (show: boolean) => void;
|
|
11
|
+
};
|
|
12
|
+
declare const EnvironmentVariables: ({ showValues: controlledShowValues, defaultShowValues, onShowValuesChange, className, children, ...props }: EnvironmentVariablesProps) => react_jsx_runtime.JSX.Element;
|
|
13
|
+
type EnvironmentVariablesHeaderProps = HTMLAttributes<HTMLDivElement>;
|
|
14
|
+
declare const EnvironmentVariablesHeader: ({ className, children, ...props }: EnvironmentVariablesHeaderProps) => react_jsx_runtime.JSX.Element;
|
|
15
|
+
type EnvironmentVariablesTitleProps = HTMLAttributes<HTMLHeadingElement>;
|
|
16
|
+
declare const EnvironmentVariablesTitle: ({ className, children, ...props }: EnvironmentVariablesTitleProps) => react_jsx_runtime.JSX.Element;
|
|
17
|
+
type EnvironmentVariablesToggleProps = ComponentProps<typeof Switch>;
|
|
18
|
+
declare const EnvironmentVariablesToggle: ({ className, ...props }: EnvironmentVariablesToggleProps) => react_jsx_runtime.JSX.Element;
|
|
19
|
+
type EnvironmentVariablesContentProps = HTMLAttributes<HTMLDivElement>;
|
|
20
|
+
declare const EnvironmentVariablesContent: ({ className, children, ...props }: EnvironmentVariablesContentProps) => react_jsx_runtime.JSX.Element;
|
|
21
|
+
type EnvironmentVariableGroupProps = HTMLAttributes<HTMLDivElement>;
|
|
22
|
+
declare const EnvironmentVariableGroup: ({ className, children, ...props }: EnvironmentVariableGroupProps) => react_jsx_runtime.JSX.Element;
|
|
23
|
+
type EnvironmentVariableNameProps = HTMLAttributes<HTMLSpanElement>;
|
|
24
|
+
declare const EnvironmentVariableName: ({ className, children, ...props }: EnvironmentVariableNameProps) => react_jsx_runtime.JSX.Element;
|
|
25
|
+
type EnvironmentVariableValueProps = HTMLAttributes<HTMLSpanElement>;
|
|
26
|
+
declare const EnvironmentVariableValue: ({ className, children, ...props }: EnvironmentVariableValueProps) => react_jsx_runtime.JSX.Element;
|
|
27
|
+
type EnvironmentVariableProps = HTMLAttributes<HTMLDivElement> & {
|
|
28
|
+
name: string;
|
|
29
|
+
value: string;
|
|
30
|
+
};
|
|
31
|
+
declare const EnvironmentVariable: ({ name, value, className, children, ...props }: EnvironmentVariableProps) => react_jsx_runtime.JSX.Element;
|
|
32
|
+
type EnvironmentVariableCopyButtonProps = ComponentProps<typeof Button> & {
|
|
33
|
+
onCopy?: () => void;
|
|
34
|
+
onError?: (error: Error) => void;
|
|
35
|
+
timeout?: number;
|
|
36
|
+
copyFormat?: "name" | "value" | "export";
|
|
37
|
+
};
|
|
38
|
+
declare const EnvironmentVariableCopyButton: ({ onCopy, onError, timeout, copyFormat, children, className, ...props }: EnvironmentVariableCopyButtonProps) => react_jsx_runtime.JSX.Element;
|
|
39
|
+
type EnvironmentVariableRequiredProps = ComponentProps<typeof Badge>;
|
|
40
|
+
declare const EnvironmentVariableRequired: ({ className, children, ...props }: EnvironmentVariableRequiredProps) => react_jsx_runtime.JSX.Element;
|
|
41
|
+
|
|
42
|
+
export { EnvironmentVariable, EnvironmentVariableCopyButton, type EnvironmentVariableCopyButtonProps, EnvironmentVariableGroup, type EnvironmentVariableGroupProps, EnvironmentVariableName, type EnvironmentVariableNameProps, type EnvironmentVariableProps, EnvironmentVariableRequired, type EnvironmentVariableRequiredProps, EnvironmentVariableValue, type EnvironmentVariableValueProps, EnvironmentVariables, EnvironmentVariablesContent, type EnvironmentVariablesContentProps, EnvironmentVariablesHeader, type EnvironmentVariablesHeaderProps, type EnvironmentVariablesProps, EnvironmentVariablesTitle, type EnvironmentVariablesTitleProps, EnvironmentVariablesToggle, type EnvironmentVariablesToggleProps };
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { Badge } from '@chatsdk-dev/ui/components/badge';
|
|
2
|
+
import { Button } from '@chatsdk-dev/ui/components/button';
|
|
3
|
+
import { Switch } from '@chatsdk-dev/ui/components/switch';
|
|
4
|
+
import { cn } from '@chatsdk-dev/ui/lib/utils';
|
|
5
|
+
import { EyeIcon, EyeOffIcon, CheckIcon, CopyIcon } from 'lucide-react';
|
|
6
|
+
import { createContext, useState, useCallback, useMemo, useContext, useRef, useEffect } from 'react';
|
|
7
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
var noop = () => {
|
|
10
|
+
};
|
|
11
|
+
var EnvironmentVariablesContext = createContext({
|
|
12
|
+
setShowValues: noop,
|
|
13
|
+
showValues: false
|
|
14
|
+
});
|
|
15
|
+
var EnvironmentVariables = ({
|
|
16
|
+
showValues: controlledShowValues,
|
|
17
|
+
defaultShowValues = false,
|
|
18
|
+
onShowValuesChange,
|
|
19
|
+
className,
|
|
20
|
+
children,
|
|
21
|
+
...props
|
|
22
|
+
}) => {
|
|
23
|
+
const [internalShowValues, setInternalShowValues] = useState(defaultShowValues);
|
|
24
|
+
const showValues = controlledShowValues ?? internalShowValues;
|
|
25
|
+
const setShowValues = useCallback(
|
|
26
|
+
(show) => {
|
|
27
|
+
setInternalShowValues(show);
|
|
28
|
+
onShowValuesChange?.(show);
|
|
29
|
+
},
|
|
30
|
+
[onShowValuesChange]
|
|
31
|
+
);
|
|
32
|
+
const contextValue = useMemo(
|
|
33
|
+
() => ({ setShowValues, showValues }),
|
|
34
|
+
[setShowValues, showValues]
|
|
35
|
+
);
|
|
36
|
+
return /* @__PURE__ */ jsx(EnvironmentVariablesContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
37
|
+
"div",
|
|
38
|
+
{
|
|
39
|
+
className: cn("rounded-lg border bg-background", className),
|
|
40
|
+
...props,
|
|
41
|
+
children
|
|
42
|
+
}
|
|
43
|
+
) });
|
|
44
|
+
};
|
|
45
|
+
var EnvironmentVariablesHeader = ({
|
|
46
|
+
className,
|
|
47
|
+
children,
|
|
48
|
+
...props
|
|
49
|
+
}) => /* @__PURE__ */ jsx(
|
|
50
|
+
"div",
|
|
51
|
+
{
|
|
52
|
+
className: cn(
|
|
53
|
+
"flex items-center justify-between border-b px-4 py-3",
|
|
54
|
+
className
|
|
55
|
+
),
|
|
56
|
+
...props,
|
|
57
|
+
children
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
var EnvironmentVariablesTitle = ({
|
|
61
|
+
className,
|
|
62
|
+
children,
|
|
63
|
+
...props
|
|
64
|
+
}) => /* @__PURE__ */ jsx("h3", { className: cn("font-medium text-sm", className), ...props, children: children ?? "Environment Variables" });
|
|
65
|
+
var EnvironmentVariablesToggle = ({
|
|
66
|
+
className,
|
|
67
|
+
...props
|
|
68
|
+
}) => {
|
|
69
|
+
const { showValues, setShowValues } = useContext(EnvironmentVariablesContext);
|
|
70
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex items-center gap-2", className), children: [
|
|
71
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-xs", children: showValues ? /* @__PURE__ */ jsx(EyeIcon, { size: 14 }) : /* @__PURE__ */ jsx(EyeOffIcon, { size: 14 }) }),
|
|
72
|
+
/* @__PURE__ */ jsx(
|
|
73
|
+
Switch,
|
|
74
|
+
{
|
|
75
|
+
"aria-label": "Toggle value visibility",
|
|
76
|
+
checked: showValues,
|
|
77
|
+
onCheckedChange: setShowValues,
|
|
78
|
+
...props
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
] });
|
|
82
|
+
};
|
|
83
|
+
var EnvironmentVariablesContent = ({
|
|
84
|
+
className,
|
|
85
|
+
children,
|
|
86
|
+
...props
|
|
87
|
+
}) => /* @__PURE__ */ jsx("div", { className: cn("divide-y", className), ...props, children });
|
|
88
|
+
var EnvironmentVariableContext = createContext({
|
|
89
|
+
name: "",
|
|
90
|
+
value: ""
|
|
91
|
+
});
|
|
92
|
+
var EnvironmentVariableGroup = ({
|
|
93
|
+
className,
|
|
94
|
+
children,
|
|
95
|
+
...props
|
|
96
|
+
}) => /* @__PURE__ */ jsx("div", { className: cn("flex items-center gap-2", className), ...props, children });
|
|
97
|
+
var EnvironmentVariableName = ({
|
|
98
|
+
className,
|
|
99
|
+
children,
|
|
100
|
+
...props
|
|
101
|
+
}) => {
|
|
102
|
+
const { name } = useContext(EnvironmentVariableContext);
|
|
103
|
+
return /* @__PURE__ */ jsx("span", { className: cn("font-mono text-sm", className), ...props, children: children ?? name });
|
|
104
|
+
};
|
|
105
|
+
var EnvironmentVariableValue = ({
|
|
106
|
+
className,
|
|
107
|
+
children,
|
|
108
|
+
...props
|
|
109
|
+
}) => {
|
|
110
|
+
const { value } = useContext(EnvironmentVariableContext);
|
|
111
|
+
const { showValues } = useContext(EnvironmentVariablesContext);
|
|
112
|
+
const displayValue = showValues ? value : "\u2022".repeat(Math.min(value.length, 20));
|
|
113
|
+
return /* @__PURE__ */ jsx(
|
|
114
|
+
"span",
|
|
115
|
+
{
|
|
116
|
+
className: cn(
|
|
117
|
+
"font-mono text-muted-foreground text-sm",
|
|
118
|
+
!showValues && "select-none",
|
|
119
|
+
className
|
|
120
|
+
),
|
|
121
|
+
...props,
|
|
122
|
+
children: children ?? displayValue
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
};
|
|
126
|
+
var EnvironmentVariable = ({
|
|
127
|
+
name,
|
|
128
|
+
value,
|
|
129
|
+
className,
|
|
130
|
+
children,
|
|
131
|
+
...props
|
|
132
|
+
}) => {
|
|
133
|
+
const envVarContextValue = useMemo(() => ({ name, value }), [name, value]);
|
|
134
|
+
return /* @__PURE__ */ jsx(EnvironmentVariableContext.Provider, { value: envVarContextValue, children: /* @__PURE__ */ jsx(
|
|
135
|
+
"div",
|
|
136
|
+
{
|
|
137
|
+
className: cn(
|
|
138
|
+
"flex items-center justify-between gap-4 px-4 py-3",
|
|
139
|
+
className
|
|
140
|
+
),
|
|
141
|
+
...props,
|
|
142
|
+
children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
143
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx(EnvironmentVariableName, {}) }),
|
|
144
|
+
/* @__PURE__ */ jsx(EnvironmentVariableValue, {})
|
|
145
|
+
] })
|
|
146
|
+
}
|
|
147
|
+
) });
|
|
148
|
+
};
|
|
149
|
+
var EnvironmentVariableCopyButton = ({
|
|
150
|
+
onCopy,
|
|
151
|
+
onError,
|
|
152
|
+
timeout = 2e3,
|
|
153
|
+
copyFormat = "value",
|
|
154
|
+
children,
|
|
155
|
+
className,
|
|
156
|
+
...props
|
|
157
|
+
}) => {
|
|
158
|
+
const [isCopied, setIsCopied] = useState(false);
|
|
159
|
+
const timeoutRef = useRef(0);
|
|
160
|
+
const { name, value } = useContext(EnvironmentVariableContext);
|
|
161
|
+
const getTextToCopy = useCallback(() => {
|
|
162
|
+
const formatMap = {
|
|
163
|
+
export: () => `export ${name}="${value}"`,
|
|
164
|
+
name: () => name,
|
|
165
|
+
value: () => value
|
|
166
|
+
};
|
|
167
|
+
return formatMap[copyFormat]();
|
|
168
|
+
}, [name, value, copyFormat]);
|
|
169
|
+
const copyToClipboard = useCallback(async () => {
|
|
170
|
+
if (typeof window === "undefined" || !navigator?.clipboard?.writeText) {
|
|
171
|
+
onError?.(new Error("Clipboard API not available"));
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
try {
|
|
175
|
+
await navigator.clipboard.writeText(getTextToCopy());
|
|
176
|
+
setIsCopied(true);
|
|
177
|
+
onCopy?.();
|
|
178
|
+
timeoutRef.current = window.setTimeout(() => setIsCopied(false), timeout);
|
|
179
|
+
} catch (error) {
|
|
180
|
+
onError?.(error);
|
|
181
|
+
}
|
|
182
|
+
}, [getTextToCopy, onCopy, onError, timeout]);
|
|
183
|
+
useEffect(
|
|
184
|
+
() => () => {
|
|
185
|
+
window.clearTimeout(timeoutRef.current);
|
|
186
|
+
},
|
|
187
|
+
[]
|
|
188
|
+
);
|
|
189
|
+
const Icon = isCopied ? CheckIcon : CopyIcon;
|
|
190
|
+
return /* @__PURE__ */ jsx(
|
|
191
|
+
Button,
|
|
192
|
+
{
|
|
193
|
+
className: cn("size-6 shrink-0", className),
|
|
194
|
+
onClick: copyToClipboard,
|
|
195
|
+
size: "icon",
|
|
196
|
+
variant: "ghost",
|
|
197
|
+
...props,
|
|
198
|
+
children: children ?? /* @__PURE__ */ jsx(Icon, { size: 12 })
|
|
199
|
+
}
|
|
200
|
+
);
|
|
201
|
+
};
|
|
202
|
+
var EnvironmentVariableRequired = ({
|
|
203
|
+
className,
|
|
204
|
+
children,
|
|
205
|
+
...props
|
|
206
|
+
}) => /* @__PURE__ */ jsx(Badge, { className: cn("text-xs", className), variant: "secondary", ...props, children: children ?? "Required" });
|
|
207
|
+
|
|
208
|
+
export { EnvironmentVariable, EnvironmentVariableCopyButton, EnvironmentVariableGroup, EnvironmentVariableName, EnvironmentVariableRequired, EnvironmentVariableValue, EnvironmentVariables, EnvironmentVariablesContent, EnvironmentVariablesHeader, EnvironmentVariablesTitle, EnvironmentVariablesToggle };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
type FileTreeProps = Omit<HTMLAttributes<HTMLDivElement>, "onSelect"> & {
|
|
5
|
+
expanded?: Set<string>;
|
|
6
|
+
defaultExpanded?: Set<string>;
|
|
7
|
+
selectedPath?: string;
|
|
8
|
+
onSelect?: (path: string) => void;
|
|
9
|
+
onExpandedChange?: (expanded: Set<string>) => void;
|
|
10
|
+
};
|
|
11
|
+
declare const FileTree: ({ expanded: controlledExpanded, defaultExpanded, selectedPath, onSelect, onExpandedChange, className, children, ...props }: FileTreeProps) => react_jsx_runtime.JSX.Element;
|
|
12
|
+
type FileTreeIconProps = HTMLAttributes<HTMLSpanElement>;
|
|
13
|
+
declare const FileTreeIcon: ({ className, children, ...props }: FileTreeIconProps) => react_jsx_runtime.JSX.Element;
|
|
14
|
+
type FileTreeNameProps = HTMLAttributes<HTMLSpanElement>;
|
|
15
|
+
declare const FileTreeName: ({ className, children, ...props }: FileTreeNameProps) => react_jsx_runtime.JSX.Element;
|
|
16
|
+
type FileTreeFolderProps = HTMLAttributes<HTMLDivElement> & {
|
|
17
|
+
path: string;
|
|
18
|
+
name: string;
|
|
19
|
+
};
|
|
20
|
+
declare const FileTreeFolder: ({ path, name, className, children, ...props }: FileTreeFolderProps) => react_jsx_runtime.JSX.Element;
|
|
21
|
+
type FileTreeFileProps = HTMLAttributes<HTMLDivElement> & {
|
|
22
|
+
path: string;
|
|
23
|
+
name: string;
|
|
24
|
+
icon?: ReactNode;
|
|
25
|
+
};
|
|
26
|
+
declare const FileTreeFile: ({ path, name, icon, className, children, ...props }: FileTreeFileProps) => react_jsx_runtime.JSX.Element;
|
|
27
|
+
type FileTreeActionsProps = HTMLAttributes<HTMLDivElement>;
|
|
28
|
+
declare const FileTreeActions: ({ className, children, ...props }: FileTreeActionsProps) => react_jsx_runtime.JSX.Element;
|
|
29
|
+
|
|
30
|
+
export { FileTree, FileTreeActions, type FileTreeActionsProps, FileTreeFile, type FileTreeFileProps, FileTreeFolder, type FileTreeFolderProps, FileTreeIcon, type FileTreeIconProps, FileTreeName, type FileTreeNameProps, type FileTreeProps };
|