@copilotkitnext/react 1.52.0-next.5 → 1.52.0-next.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/WildcardToolCallRender.cjs +13 -13
- package/dist/components/WildcardToolCallRender.cjs.map +1 -1
- package/dist/components/WildcardToolCallRender.mjs +13 -13
- package/dist/components/WildcardToolCallRender.mjs.map +1 -1
- package/dist/components/chat/CopilotChat.cjs.map +1 -1
- package/dist/components/chat/CopilotChat.mjs.map +1 -1
- package/dist/components/chat/CopilotChatAssistantMessage.cjs +36 -28
- package/dist/components/chat/CopilotChatAssistantMessage.cjs.map +1 -1
- package/dist/components/chat/CopilotChatAssistantMessage.mjs +37 -29
- package/dist/components/chat/CopilotChatAssistantMessage.mjs.map +1 -1
- package/dist/components/chat/CopilotChatAudioRecorder.cjs +2 -2
- package/dist/components/chat/CopilotChatAudioRecorder.cjs.map +1 -1
- package/dist/components/chat/CopilotChatAudioRecorder.mjs +2 -2
- package/dist/components/chat/CopilotChatAudioRecorder.mjs.map +1 -1
- package/dist/components/chat/CopilotChatInput.cjs +59 -51
- package/dist/components/chat/CopilotChatInput.cjs.map +1 -1
- package/dist/components/chat/CopilotChatInput.d.cts.map +1 -1
- package/dist/components/chat/CopilotChatInput.d.mts.map +1 -1
- package/dist/components/chat/CopilotChatInput.mjs +59 -51
- package/dist/components/chat/CopilotChatInput.mjs.map +1 -1
- package/dist/components/chat/CopilotChatMessageView.cjs +28 -10
- package/dist/components/chat/CopilotChatMessageView.cjs.map +1 -1
- package/dist/components/chat/CopilotChatMessageView.d.cts +1 -0
- package/dist/components/chat/CopilotChatMessageView.d.cts.map +1 -1
- package/dist/components/chat/CopilotChatMessageView.d.mts +1 -0
- package/dist/components/chat/CopilotChatMessageView.d.mts.map +1 -1
- package/dist/components/chat/CopilotChatMessageView.mjs +29 -11
- package/dist/components/chat/CopilotChatMessageView.mjs.map +1 -1
- package/dist/components/chat/CopilotChatReasoningMessage.cjs +24 -20
- package/dist/components/chat/CopilotChatReasoningMessage.cjs.map +1 -1
- package/dist/components/chat/CopilotChatReasoningMessage.d.cts.map +1 -1
- package/dist/components/chat/CopilotChatReasoningMessage.d.mts.map +1 -1
- package/dist/components/chat/CopilotChatReasoningMessage.mjs +25 -21
- package/dist/components/chat/CopilotChatReasoningMessage.mjs.map +1 -1
- package/dist/components/chat/CopilotChatSuggestionPill.cjs +6 -5
- package/dist/components/chat/CopilotChatSuggestionPill.cjs.map +1 -1
- package/dist/components/chat/CopilotChatSuggestionPill.mjs +6 -5
- package/dist/components/chat/CopilotChatSuggestionPill.mjs.map +1 -1
- package/dist/components/chat/CopilotChatSuggestionView.cjs +24 -12
- package/dist/components/chat/CopilotChatSuggestionView.cjs.map +1 -1
- package/dist/components/chat/CopilotChatSuggestionView.d.cts.map +1 -1
- package/dist/components/chat/CopilotChatSuggestionView.d.mts.map +1 -1
- package/dist/components/chat/CopilotChatSuggestionView.mjs +25 -13
- package/dist/components/chat/CopilotChatSuggestionView.mjs.map +1 -1
- package/dist/components/chat/CopilotChatToggleButton.cjs +7 -6
- package/dist/components/chat/CopilotChatToggleButton.cjs.map +1 -1
- package/dist/components/chat/CopilotChatToggleButton.d.cts.map +1 -1
- package/dist/components/chat/CopilotChatToggleButton.d.mts.map +1 -1
- package/dist/components/chat/CopilotChatToggleButton.mjs +7 -6
- package/dist/components/chat/CopilotChatToggleButton.mjs.map +1 -1
- package/dist/components/chat/CopilotChatUserMessage.cjs +29 -24
- package/dist/components/chat/CopilotChatUserMessage.cjs.map +1 -1
- package/dist/components/chat/CopilotChatUserMessage.d.cts.map +1 -1
- package/dist/components/chat/CopilotChatUserMessage.d.mts.map +1 -1
- package/dist/components/chat/CopilotChatUserMessage.mjs +30 -25
- package/dist/components/chat/CopilotChatUserMessage.mjs.map +1 -1
- package/dist/components/chat/CopilotChatView.cjs +45 -35
- package/dist/components/chat/CopilotChatView.cjs.map +1 -1
- package/dist/components/chat/CopilotChatView.d.cts +1 -1
- package/dist/components/chat/CopilotChatView.d.cts.map +1 -1
- package/dist/components/chat/CopilotChatView.d.mts +1 -1
- package/dist/components/chat/CopilotChatView.d.mts.map +1 -1
- package/dist/components/chat/CopilotChatView.mjs +45 -35
- package/dist/components/chat/CopilotChatView.mjs.map +1 -1
- package/dist/components/chat/CopilotModalHeader.cjs +8 -8
- package/dist/components/chat/CopilotModalHeader.cjs.map +1 -1
- package/dist/components/chat/CopilotModalHeader.d.cts.map +1 -1
- package/dist/components/chat/CopilotModalHeader.d.mts.map +1 -1
- package/dist/components/chat/CopilotModalHeader.mjs +8 -8
- package/dist/components/chat/CopilotModalHeader.mjs.map +1 -1
- package/dist/components/chat/CopilotPopupView.cjs +20 -15
- package/dist/components/chat/CopilotPopupView.cjs.map +1 -1
- package/dist/components/chat/CopilotPopupView.d.cts.map +1 -1
- package/dist/components/chat/CopilotPopupView.d.mts.map +1 -1
- package/dist/components/chat/CopilotPopupView.mjs +20 -15
- package/dist/components/chat/CopilotPopupView.mjs.map +1 -1
- package/dist/components/chat/CopilotSidebarView.cjs +54 -43
- package/dist/components/chat/CopilotSidebarView.cjs.map +1 -1
- package/dist/components/chat/CopilotSidebarView.d.cts.map +1 -1
- package/dist/components/chat/CopilotSidebarView.d.mts.map +1 -1
- package/dist/components/chat/CopilotSidebarView.mjs +55 -44
- package/dist/components/chat/CopilotSidebarView.mjs.map +1 -1
- package/dist/components/ui/button.cjs +42 -42
- package/dist/components/ui/button.cjs.map +1 -1
- package/dist/components/ui/button.mjs +42 -42
- package/dist/components/ui/button.mjs.map +1 -1
- package/dist/components/ui/dropdown-menu.cjs +7 -6
- package/dist/components/ui/dropdown-menu.cjs.map +1 -1
- package/dist/components/ui/dropdown-menu.mjs +7 -6
- package/dist/components/ui/dropdown-menu.mjs.map +1 -1
- package/dist/components/ui/tooltip.cjs +3 -2
- package/dist/components/ui/tooltip.cjs.map +1 -1
- package/dist/components/ui/tooltip.mjs +3 -2
- package/dist/components/ui/tooltip.mjs.map +1 -1
- package/dist/hooks/index.cjs +1 -0
- package/dist/hooks/index.d.cts +2 -1
- package/dist/hooks/index.d.mts +2 -1
- package/dist/hooks/index.mjs +1 -0
- package/dist/hooks/use-component.cjs +18 -5
- package/dist/hooks/use-component.cjs.map +1 -1
- package/dist/hooks/use-component.d.cts +21 -7
- package/dist/hooks/use-component.d.cts.map +1 -1
- package/dist/hooks/use-component.d.mts +21 -7
- package/dist/hooks/use-component.d.mts.map +1 -1
- package/dist/hooks/use-component.mjs +18 -5
- package/dist/hooks/use-component.mjs.map +1 -1
- package/dist/hooks/use-default-render-tool.cjs +2 -2
- package/dist/hooks/use-default-render-tool.cjs.map +1 -1
- package/dist/hooks/use-default-render-tool.d.cts +3 -3
- package/dist/hooks/use-default-render-tool.d.cts.map +1 -1
- package/dist/hooks/use-default-render-tool.d.mts +3 -3
- package/dist/hooks/use-default-render-tool.d.mts.map +1 -1
- package/dist/hooks/use-default-render-tool.mjs +2 -2
- package/dist/hooks/use-default-render-tool.mjs.map +1 -1
- package/dist/hooks/use-interrupt.cjs +171 -0
- package/dist/hooks/use-interrupt.cjs.map +1 -0
- package/dist/hooks/use-interrupt.d.cts +102 -0
- package/dist/hooks/use-interrupt.d.cts.map +1 -0
- package/dist/hooks/use-interrupt.d.mts +102 -0
- package/dist/hooks/use-interrupt.d.mts.map +1 -0
- package/dist/hooks/use-interrupt.mjs +170 -0
- package/dist/hooks/use-interrupt.mjs.map +1 -0
- package/dist/hooks/use-render-tool.cjs +15 -9
- package/dist/hooks/use-render-tool.cjs.map +1 -1
- package/dist/hooks/use-render-tool.d.cts +9 -9
- package/dist/hooks/use-render-tool.d.cts.map +1 -1
- package/dist/hooks/use-render-tool.d.mts +9 -9
- package/dist/hooks/use-render-tool.d.mts.map +1 -1
- package/dist/hooks/use-render-tool.mjs +15 -9
- package/dist/hooks/use-render-tool.mjs.map +1 -1
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +3 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +2 -1
- package/dist/index.umd.js +625 -342
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/react-core.cjs +13 -0
- package/dist/lib/react-core.cjs.map +1 -1
- package/dist/lib/react-core.d.cts +8 -0
- package/dist/lib/react-core.d.cts.map +1 -1
- package/dist/lib/react-core.d.mts +8 -0
- package/dist/lib/react-core.d.mts.map +1 -1
- package/dist/lib/react-core.mjs +13 -0
- package/dist/lib/react-core.mjs.map +1 -1
- package/dist/lib/utils.cjs +2 -1
- package/dist/lib/utils.cjs.map +1 -1
- package/dist/lib/utils.mjs +3 -2
- package/dist/lib/utils.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/index.d.cts +2 -1
- package/dist/types/index.d.mts +2 -1
- package/dist/types/interrupt.d.cts +17 -0
- package/dist/types/interrupt.d.cts.map +1 -0
- package/dist/types/interrupt.d.mts +17 -0
- package/dist/types/interrupt.d.mts.map +1 -0
- package/eslint-rules/README.md +52 -0
- package/eslint-rules/require-cpk-prefix.mjs +375 -0
- package/eslint.config.mjs +17 -0
- package/package.json +8 -7
|
@@ -36,7 +36,7 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
36
36
|
});
|
|
37
37
|
const showBranchNavigation = numberOfBranches && numberOfBranches > 1 && onSwitchToBranch;
|
|
38
38
|
const BoundToolbar = require_slots.renderSlot(toolbar, CopilotChatUserMessage.Toolbar, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
39
|
-
className: "flex items-center gap-1 justify-end",
|
|
39
|
+
className: "cpk:flex cpk:items-center cpk:gap-1 cpk:justify-end",
|
|
40
40
|
children: [
|
|
41
41
|
additionalToolbarItems,
|
|
42
42
|
BoundCopyButton,
|
|
@@ -44,19 +44,24 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
44
44
|
showBranchNavigation && BoundBranchNavigation
|
|
45
45
|
]
|
|
46
46
|
}) });
|
|
47
|
-
if (children) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
47
|
+
if (children) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
48
|
+
"data-copilotkit": true,
|
|
49
|
+
style: { display: "contents" },
|
|
50
|
+
children: children({
|
|
51
|
+
messageRenderer: BoundMessageRenderer,
|
|
52
|
+
toolbar: BoundToolbar,
|
|
53
|
+
copyButton: BoundCopyButton,
|
|
54
|
+
editButton: BoundEditButton,
|
|
55
|
+
branchNavigation: BoundBranchNavigation,
|
|
56
|
+
message,
|
|
57
|
+
branchIndex,
|
|
58
|
+
numberOfBranches,
|
|
59
|
+
additionalToolbarItems
|
|
60
|
+
})
|
|
61
|
+
});
|
|
58
62
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
59
|
-
|
|
63
|
+
"data-copilotkit": true,
|
|
64
|
+
className: (0, tailwind_merge.twMerge)("cpk:flex cpk:flex-col cpk:items-end cpk:group cpk:pt-10", className),
|
|
60
65
|
"data-message-id": message.id,
|
|
61
66
|
...props,
|
|
62
67
|
children: [BoundMessageRenderer, BoundToolbar]
|
|
@@ -64,16 +69,16 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
64
69
|
}
|
|
65
70
|
(function(_CopilotChatUserMessage) {
|
|
66
71
|
_CopilotChatUserMessage.Container = ({ children, className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
67
|
-
className: (0, tailwind_merge.twMerge)("flex flex-col items-end group", className),
|
|
72
|
+
className: (0, tailwind_merge.twMerge)("cpk:flex cpk:flex-col cpk:items-end cpk:group", className),
|
|
68
73
|
...props,
|
|
69
74
|
children
|
|
70
75
|
});
|
|
71
76
|
_CopilotChatUserMessage.MessageRenderer = ({ content, className }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
72
|
-
className: (0, tailwind_merge.twMerge)("prose dark:prose-invert bg-muted relative max-w-[80%] rounded-[18px] px-4 py-1.5 data-[multiline]:py-3 inline-block whitespace-pre-wrap", className),
|
|
77
|
+
className: (0, tailwind_merge.twMerge)("cpk:prose cpk:dark:prose-invert cpk:bg-muted cpk:relative cpk:max-w-[80%] cpk:rounded-[18px] cpk:px-4 cpk:py-1.5 cpk:data-[multiline]:py-3 cpk:inline-block cpk:whitespace-pre-wrap", className),
|
|
73
78
|
children: content
|
|
74
79
|
});
|
|
75
80
|
_CopilotChatUserMessage.Toolbar = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
76
|
-
className: (0, tailwind_merge.twMerge)("w-full bg-transparent flex items-center justify-end
|
|
81
|
+
className: (0, tailwind_merge.twMerge)("cpk:w-full cpk:bg-transparent cpk:flex cpk:items-center cpk:justify-end cpk:-mr-[5px] cpk:mt-[4px] cpk:invisible cpk:group-hover:visible", className),
|
|
77
82
|
...props
|
|
78
83
|
});
|
|
79
84
|
const ToolbarButton = _CopilotChatUserMessage.ToolbarButton = ({ title, children, className, ...props }) => {
|
|
@@ -105,7 +110,7 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
105
110
|
onClick: handleClick,
|
|
106
111
|
className,
|
|
107
112
|
...props,
|
|
108
|
-
children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, { className: "size-[18px]" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Copy, { className: "size-[18px]" })
|
|
113
|
+
children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, { className: "cpk:size-[18px]" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Copy, { className: "cpk:size-[18px]" })
|
|
109
114
|
});
|
|
110
115
|
};
|
|
111
116
|
_CopilotChatUserMessage.EditButton = ({ className, title, ...props }) => {
|
|
@@ -114,7 +119,7 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
114
119
|
title: title || labels.userMessageToolbarEditMessageLabel,
|
|
115
120
|
className,
|
|
116
121
|
...props,
|
|
117
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Edit, { className: "size-[18px]" })
|
|
122
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Edit, { className: "cpk:size-[18px]" })
|
|
118
123
|
});
|
|
119
124
|
};
|
|
120
125
|
_CopilotChatUserMessage.BranchNavigation = ({ className, currentBranch = 0, numberOfBranches = 1, onSwitchToBranch, message, ...props }) => {
|
|
@@ -122,7 +127,7 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
122
127
|
const canGoPrev = currentBranch > 0;
|
|
123
128
|
const canGoNext = currentBranch < numberOfBranches - 1;
|
|
124
129
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
125
|
-
className: (0, tailwind_merge.twMerge)("flex items-center gap-1", className),
|
|
130
|
+
className: (0, tailwind_merge.twMerge)("cpk:flex cpk:items-center cpk:gap-1", className),
|
|
126
131
|
...props,
|
|
127
132
|
children: [
|
|
128
133
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_button.Button, {
|
|
@@ -134,11 +139,11 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
134
139
|
message
|
|
135
140
|
}),
|
|
136
141
|
disabled: !canGoPrev,
|
|
137
|
-
className: "h-6 w-6 p-0",
|
|
138
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronLeft, { className: "size-[20px]" })
|
|
142
|
+
className: "cpk:h-6 cpk:w-6 cpk:p-0",
|
|
143
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronLeft, { className: "cpk:size-[20px]" })
|
|
139
144
|
}),
|
|
140
145
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
141
|
-
className: "text-sm text-muted-foreground px-0 font-medium",
|
|
146
|
+
className: "cpk:text-sm cpk:text-muted-foreground cpk:px-0 cpk:font-medium",
|
|
142
147
|
children: [
|
|
143
148
|
currentBranch + 1,
|
|
144
149
|
"/",
|
|
@@ -154,8 +159,8 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
154
159
|
message
|
|
155
160
|
}),
|
|
156
161
|
disabled: !canGoNext,
|
|
157
|
-
className: "h-6 w-6 p-0",
|
|
158
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, { className: "size-[20px]" })
|
|
162
|
+
className: "cpk:h-6 cpk:w-6 cpk:p-0",
|
|
163
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, { className: "cpk:size-[20px]" })
|
|
159
164
|
})
|
|
160
165
|
]
|
|
161
166
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopilotChatUserMessage.cjs","names":["renderSlot","Tooltip","TooltipTrigger","Button","TooltipContent","useCopilotChatConfiguration","CopilotChatDefaultLabels","Check","Copy","Edit","ChevronLeft","ChevronRight"],"sources":["../../../src/components/chat/CopilotChatUserMessage.tsx"],"sourcesContent":["import { useMemo, useState } from \"react\";\nimport { Copy, Check, Edit, ChevronLeft, ChevronRight } from \"lucide-react\";\nimport {\n useCopilotChatConfiguration,\n CopilotChatDefaultLabels,\n} from \"@/providers/CopilotChatConfigurationProvider\";\nimport { twMerge } from \"tailwind-merge\";\nimport { Button } from \"@/components/ui/button\";\nimport { UserMessage } from \"@ag-ui/core\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"@/components/ui/tooltip\";\nimport { renderSlot, WithSlots } from \"@/lib/slots\";\n\nfunction flattenUserMessageContent(content?: UserMessage[\"content\"]): string {\n if (!content) {\n return \"\";\n }\n\n if (typeof content === \"string\") {\n return content;\n }\n\n return content\n .map((part) => {\n if (\n part &&\n typeof part === \"object\" &&\n \"type\" in part &&\n (part as { type?: unknown }).type === \"text\" &&\n typeof (part as { text?: unknown }).text === \"string\"\n ) {\n return (part as { text: string }).text;\n }\n return \"\";\n })\n .filter((text) => text.length > 0)\n .join(\"\\n\");\n}\n\nexport interface CopilotChatUserMessageOnEditMessageProps {\n message: UserMessage;\n}\n\nexport interface CopilotChatUserMessageOnSwitchToBranchProps {\n message: UserMessage;\n branchIndex: number;\n numberOfBranches: number;\n}\n\nexport type CopilotChatUserMessageProps = WithSlots<\n {\n messageRenderer: typeof CopilotChatUserMessage.MessageRenderer;\n toolbar: typeof CopilotChatUserMessage.Toolbar;\n copyButton: typeof CopilotChatUserMessage.CopyButton;\n editButton: typeof CopilotChatUserMessage.EditButton;\n branchNavigation: typeof CopilotChatUserMessage.BranchNavigation;\n },\n {\n onEditMessage?: (props: CopilotChatUserMessageOnEditMessageProps) => void;\n onSwitchToBranch?: (\n props: CopilotChatUserMessageOnSwitchToBranchProps,\n ) => void;\n message: UserMessage;\n branchIndex?: number;\n numberOfBranches?: number;\n additionalToolbarItems?: React.ReactNode;\n } & React.HTMLAttributes<HTMLDivElement>\n>;\n\nexport function CopilotChatUserMessage({\n message,\n onEditMessage,\n branchIndex,\n numberOfBranches,\n onSwitchToBranch,\n additionalToolbarItems,\n messageRenderer,\n toolbar,\n copyButton,\n editButton,\n branchNavigation,\n children,\n className,\n ...props\n}: CopilotChatUserMessageProps) {\n const flattenedContent = useMemo(\n () => flattenUserMessageContent(message.content),\n [message.content],\n );\n\n const BoundMessageRenderer = renderSlot(\n messageRenderer,\n CopilotChatUserMessage.MessageRenderer,\n {\n content: flattenedContent,\n },\n );\n\n const BoundCopyButton = renderSlot(\n copyButton,\n CopilotChatUserMessage.CopyButton,\n {\n onClick: async () => {\n if (flattenedContent) {\n try {\n await navigator.clipboard.writeText(flattenedContent);\n } catch (err) {\n console.error(\"Failed to copy message:\", err);\n }\n }\n },\n },\n );\n\n const BoundEditButton = renderSlot(\n editButton,\n CopilotChatUserMessage.EditButton,\n {\n onClick: () => onEditMessage?.({ message }),\n },\n );\n\n const BoundBranchNavigation = renderSlot(\n branchNavigation,\n CopilotChatUserMessage.BranchNavigation,\n {\n currentBranch: branchIndex,\n numberOfBranches,\n onSwitchToBranch,\n message,\n },\n );\n\n const showBranchNavigation =\n numberOfBranches && numberOfBranches > 1 && onSwitchToBranch;\n\n const BoundToolbar = renderSlot(toolbar, CopilotChatUserMessage.Toolbar, {\n children: (\n <div className=\"flex items-center gap-1 justify-end\">\n {additionalToolbarItems}\n {BoundCopyButton}\n {onEditMessage && BoundEditButton}\n {showBranchNavigation && BoundBranchNavigation}\n </div>\n ),\n });\n\n if (children) {\n return (\n <>\n {children({\n messageRenderer: BoundMessageRenderer,\n toolbar: BoundToolbar,\n copyButton: BoundCopyButton,\n editButton: BoundEditButton,\n branchNavigation: BoundBranchNavigation,\n message,\n branchIndex,\n numberOfBranches,\n additionalToolbarItems,\n })}\n </>\n );\n }\n\n return (\n <div\n className={twMerge(\"flex flex-col items-end group pt-10\", className)}\n data-message-id={message.id}\n {...props}\n >\n {BoundMessageRenderer}\n {BoundToolbar}\n </div>\n );\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace CopilotChatUserMessage {\n export const Container: React.FC<\n React.PropsWithChildren<React.HTMLAttributes<HTMLDivElement>>\n > = ({ children, className, ...props }) => (\n <div\n className={twMerge(\"flex flex-col items-end group\", className)}\n {...props}\n >\n {children}\n </div>\n );\n\n export const MessageRenderer: React.FC<{\n content: string;\n className?: string;\n }> = ({ content, className }) => (\n <div\n className={twMerge(\n \"prose dark:prose-invert bg-muted relative max-w-[80%] rounded-[18px] px-4 py-1.5 data-[multiline]:py-3 inline-block whitespace-pre-wrap\",\n className,\n )}\n >\n {content}\n </div>\n );\n\n export const Toolbar: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({\n className,\n ...props\n }) => (\n <div\n className={twMerge(\n \"w-full bg-transparent flex items-center justify-end -mr-[5px] mt-[4px] invisible group-hover:visible\",\n className,\n )}\n {...props}\n />\n );\n\n export const ToolbarButton: React.FC<\n React.ButtonHTMLAttributes<HTMLButtonElement> & {\n title: string;\n children: React.ReactNode;\n }\n > = ({ title, children, className, ...props }) => {\n return (\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n type=\"button\"\n variant=\"assistantMessageToolbarButton\"\n aria-label={title}\n className={twMerge(className)}\n {...props}\n >\n {children}\n </Button>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">\n <p>{title}</p>\n </TooltipContent>\n </Tooltip>\n );\n };\n\n export const CopyButton: React.FC<\n React.ButtonHTMLAttributes<HTMLButtonElement> & { copied?: boolean }\n > = ({ className, title, onClick, ...props }) => {\n const config = useCopilotChatConfiguration();\n const labels = config?.labels ?? CopilotChatDefaultLabels;\n const [copied, setCopied] = useState(false);\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n\n if (onClick) {\n onClick(event);\n }\n };\n\n return (\n <ToolbarButton\n title={title || labels.userMessageToolbarCopyMessageLabel}\n onClick={handleClick}\n className={className}\n {...props}\n >\n {copied ? (\n <Check className=\"size-[18px]\" />\n ) : (\n <Copy className=\"size-[18px]\" />\n )}\n </ToolbarButton>\n );\n };\n\n export const EditButton: React.FC<\n React.ButtonHTMLAttributes<HTMLButtonElement>\n > = ({ className, title, ...props }) => {\n const config = useCopilotChatConfiguration();\n const labels = config?.labels ?? CopilotChatDefaultLabels;\n return (\n <ToolbarButton\n title={title || labels.userMessageToolbarEditMessageLabel}\n className={className}\n {...props}\n >\n <Edit className=\"size-[18px]\" />\n </ToolbarButton>\n );\n };\n\n export const BranchNavigation: React.FC<\n React.HTMLAttributes<HTMLDivElement> & {\n currentBranch?: number;\n numberOfBranches?: number;\n onSwitchToBranch?: (\n props: CopilotChatUserMessageOnSwitchToBranchProps,\n ) => void;\n message: UserMessage;\n }\n > = ({\n className,\n currentBranch = 0,\n numberOfBranches = 1,\n onSwitchToBranch,\n message,\n ...props\n }) => {\n if (!numberOfBranches || numberOfBranches <= 1 || !onSwitchToBranch) {\n return null;\n }\n\n const canGoPrev = currentBranch > 0;\n const canGoNext = currentBranch < numberOfBranches - 1;\n\n return (\n <div className={twMerge(\"flex items-center gap-1\", className)} {...props}>\n <Button\n type=\"button\"\n variant=\"assistantMessageToolbarButton\"\n onClick={() =>\n onSwitchToBranch?.({\n branchIndex: currentBranch - 1,\n numberOfBranches,\n message,\n })\n }\n disabled={!canGoPrev}\n className=\"h-6 w-6 p-0\"\n >\n <ChevronLeft className=\"size-[20px]\" />\n </Button>\n <span className=\"text-sm text-muted-foreground px-0 font-medium\">\n {currentBranch + 1}/{numberOfBranches}\n </span>\n <Button\n type=\"button\"\n variant=\"assistantMessageToolbarButton\"\n onClick={() =>\n onSwitchToBranch?.({\n branchIndex: currentBranch + 1,\n numberOfBranches,\n message,\n })\n }\n disabled={!canGoNext}\n className=\"h-6 w-6 p-0\"\n >\n <ChevronRight className=\"size-[20px]\" />\n </Button>\n </div>\n );\n };\n}\n\nCopilotChatUserMessage.Container.displayName =\n \"CopilotChatUserMessage.Container\";\nCopilotChatUserMessage.MessageRenderer.displayName =\n \"CopilotChatUserMessage.MessageRenderer\";\nCopilotChatUserMessage.Toolbar.displayName = \"CopilotChatUserMessage.Toolbar\";\nCopilotChatUserMessage.ToolbarButton.displayName =\n \"CopilotChatUserMessage.ToolbarButton\";\nCopilotChatUserMessage.CopyButton.displayName =\n \"CopilotChatUserMessage.CopyButton\";\nCopilotChatUserMessage.EditButton.displayName =\n \"CopilotChatUserMessage.EditButton\";\nCopilotChatUserMessage.BranchNavigation.displayName =\n \"CopilotChatUserMessage.BranchNavigation\";\n\nexport default CopilotChatUserMessage;\n"],"mappings":";;;;;;;;;;;AAgBA,SAAS,0BAA0B,SAA0C;AAC3E,KAAI,CAAC,QACH,QAAO;AAGT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,MAAM,YAAY,gBAAgB;EAClC,MAAM,YAAY,gBAAgB,mBAAmB;AAErD,SACE,4CAAC;GAAI,uCAAmB,2BAA2B,UAAU;GAAE,GAAI;;IACjE,2CAACN;KACC,MAAK;KACL,SAAQ;KACR,eACE,mBAAmB;MACjB,aAAa,gBAAgB;MAC7B;MACA;MACD,CAAC;KAEJ,UAAU,CAAC;KACX,WAAU;eAEV,2CAACO,4BAAY,WAAU,gBAAgB;MAChC;IACT,4CAAC;KAAK,WAAU;;MACb,gBAAgB;MAAE;MAAE;;MAChB;IACP,2CAACP;KACC,MAAK;KACL,SAAQ;KACR,eACE,mBAAmB;MACjB,aAAa,gBAAgB;MAC7B;MACA;MACD,CAAC;KAEJ,UAAU,CAAC;KACX,WAAU;eAEV,2CAACQ,6BAAa,WAAU,gBAAgB;MACjC;;IACL;;;AAKZ,uBAAuB,UAAU,cAC/B;AACF,uBAAuB,gBAAgB,cACrC;AACF,uBAAuB,QAAQ,cAAc;AAC7C,uBAAuB,cAAc,cACnC;AACF,uBAAuB,WAAW,cAChC;AACF,uBAAuB,WAAW,cAChC;AACF,uBAAuB,iBAAiB,cACtC;AAEF,qCAAe"}
|
|
1
|
+
{"version":3,"file":"CopilotChatUserMessage.cjs","names":["renderSlot","Tooltip","TooltipTrigger","Button","TooltipContent","useCopilotChatConfiguration","CopilotChatDefaultLabels","Check","Copy","Edit","ChevronLeft","ChevronRight"],"sources":["../../../src/components/chat/CopilotChatUserMessage.tsx"],"sourcesContent":["import { useMemo, useState } from \"react\";\nimport { Copy, Check, Edit, ChevronLeft, ChevronRight } from \"lucide-react\";\nimport {\n useCopilotChatConfiguration,\n CopilotChatDefaultLabels,\n} from \"@/providers/CopilotChatConfigurationProvider\";\nimport { twMerge } from \"tailwind-merge\";\nimport { Button } from \"@/components/ui/button\";\nimport { UserMessage } from \"@ag-ui/core\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"@/components/ui/tooltip\";\nimport { renderSlot, WithSlots } from \"@/lib/slots\";\n\nfunction flattenUserMessageContent(content?: UserMessage[\"content\"]): string {\n if (!content) {\n return \"\";\n }\n\n if (typeof content === \"string\") {\n return content;\n }\n\n return content\n .map((part) => {\n if (\n part &&\n typeof part === \"object\" &&\n \"type\" in part &&\n (part as { type?: unknown }).type === \"text\" &&\n typeof (part as { text?: unknown }).text === \"string\"\n ) {\n return (part as { text: string }).text;\n }\n return \"\";\n })\n .filter((text) => text.length > 0)\n .join(\"\\n\");\n}\n\nexport interface CopilotChatUserMessageOnEditMessageProps {\n message: UserMessage;\n}\n\nexport interface CopilotChatUserMessageOnSwitchToBranchProps {\n message: UserMessage;\n branchIndex: number;\n numberOfBranches: number;\n}\n\nexport type CopilotChatUserMessageProps = WithSlots<\n {\n messageRenderer: typeof CopilotChatUserMessage.MessageRenderer;\n toolbar: typeof CopilotChatUserMessage.Toolbar;\n copyButton: typeof CopilotChatUserMessage.CopyButton;\n editButton: typeof CopilotChatUserMessage.EditButton;\n branchNavigation: typeof CopilotChatUserMessage.BranchNavigation;\n },\n {\n onEditMessage?: (props: CopilotChatUserMessageOnEditMessageProps) => void;\n onSwitchToBranch?: (\n props: CopilotChatUserMessageOnSwitchToBranchProps,\n ) => void;\n message: UserMessage;\n branchIndex?: number;\n numberOfBranches?: number;\n additionalToolbarItems?: React.ReactNode;\n } & React.HTMLAttributes<HTMLDivElement>\n>;\n\nexport function CopilotChatUserMessage({\n message,\n onEditMessage,\n branchIndex,\n numberOfBranches,\n onSwitchToBranch,\n additionalToolbarItems,\n messageRenderer,\n toolbar,\n copyButton,\n editButton,\n branchNavigation,\n children,\n className,\n ...props\n}: CopilotChatUserMessageProps) {\n const flattenedContent = useMemo(\n () => flattenUserMessageContent(message.content),\n [message.content],\n );\n\n const BoundMessageRenderer = renderSlot(\n messageRenderer,\n CopilotChatUserMessage.MessageRenderer,\n {\n content: flattenedContent,\n },\n );\n\n const BoundCopyButton = renderSlot(\n copyButton,\n CopilotChatUserMessage.CopyButton,\n {\n onClick: async () => {\n if (flattenedContent) {\n try {\n await navigator.clipboard.writeText(flattenedContent);\n } catch (err) {\n console.error(\"Failed to copy message:\", err);\n }\n }\n },\n },\n );\n\n const BoundEditButton = renderSlot(\n editButton,\n CopilotChatUserMessage.EditButton,\n {\n onClick: () => onEditMessage?.({ message }),\n },\n );\n\n const BoundBranchNavigation = renderSlot(\n branchNavigation,\n CopilotChatUserMessage.BranchNavigation,\n {\n currentBranch: branchIndex,\n numberOfBranches,\n onSwitchToBranch,\n message,\n },\n );\n\n const showBranchNavigation =\n numberOfBranches && numberOfBranches > 1 && onSwitchToBranch;\n\n const BoundToolbar = renderSlot(toolbar, CopilotChatUserMessage.Toolbar, {\n children: (\n <div className=\"cpk:flex cpk:items-center cpk:gap-1 cpk:justify-end\">\n {additionalToolbarItems}\n {BoundCopyButton}\n {onEditMessage && BoundEditButton}\n {showBranchNavigation && BoundBranchNavigation}\n </div>\n ),\n });\n\n if (children) {\n return (\n <div data-copilotkit style={{ display: \"contents\" }}>\n {children({\n messageRenderer: BoundMessageRenderer,\n toolbar: BoundToolbar,\n copyButton: BoundCopyButton,\n editButton: BoundEditButton,\n branchNavigation: BoundBranchNavigation,\n message,\n branchIndex,\n numberOfBranches,\n additionalToolbarItems,\n })}\n </div>\n );\n }\n\n return (\n <div\n data-copilotkit\n className={twMerge(\n \"cpk:flex cpk:flex-col cpk:items-end cpk:group cpk:pt-10\",\n className,\n )}\n data-message-id={message.id}\n {...props}\n >\n {BoundMessageRenderer}\n {BoundToolbar}\n </div>\n );\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace CopilotChatUserMessage {\n export const Container: React.FC<\n React.PropsWithChildren<React.HTMLAttributes<HTMLDivElement>>\n > = ({ children, className, ...props }) => (\n <div\n className={twMerge(\n \"cpk:flex cpk:flex-col cpk:items-end cpk:group\",\n className,\n )}\n {...props}\n >\n {children}\n </div>\n );\n\n export const MessageRenderer: React.FC<{\n content: string;\n className?: string;\n }> = ({ content, className }) => (\n <div\n className={twMerge(\n \"cpk:prose cpk:dark:prose-invert cpk:bg-muted cpk:relative cpk:max-w-[80%] cpk:rounded-[18px] cpk:px-4 cpk:py-1.5 cpk:data-[multiline]:py-3 cpk:inline-block cpk:whitespace-pre-wrap\",\n className,\n )}\n >\n {content}\n </div>\n );\n\n export const Toolbar: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({\n className,\n ...props\n }) => (\n <div\n className={twMerge(\n \"cpk:w-full cpk:bg-transparent cpk:flex cpk:items-center cpk:justify-end cpk:-mr-[5px] cpk:mt-[4px] cpk:invisible cpk:group-hover:visible\",\n className,\n )}\n {...props}\n />\n );\n\n export const ToolbarButton: React.FC<\n React.ButtonHTMLAttributes<HTMLButtonElement> & {\n title: string;\n children: React.ReactNode;\n }\n > = ({ title, children, className, ...props }) => {\n return (\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n type=\"button\"\n variant=\"assistantMessageToolbarButton\"\n aria-label={title}\n className={twMerge(className)}\n {...props}\n >\n {children}\n </Button>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">\n <p>{title}</p>\n </TooltipContent>\n </Tooltip>\n );\n };\n\n export const CopyButton: React.FC<\n React.ButtonHTMLAttributes<HTMLButtonElement> & { copied?: boolean }\n > = ({ className, title, onClick, ...props }) => {\n const config = useCopilotChatConfiguration();\n const labels = config?.labels ?? CopilotChatDefaultLabels;\n const [copied, setCopied] = useState(false);\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n\n if (onClick) {\n onClick(event);\n }\n };\n\n return (\n <ToolbarButton\n title={title || labels.userMessageToolbarCopyMessageLabel}\n onClick={handleClick}\n className={className}\n {...props}\n >\n {copied ? (\n <Check className=\"cpk:size-[18px]\" />\n ) : (\n <Copy className=\"cpk:size-[18px]\" />\n )}\n </ToolbarButton>\n );\n };\n\n export const EditButton: React.FC<\n React.ButtonHTMLAttributes<HTMLButtonElement>\n > = ({ className, title, ...props }) => {\n const config = useCopilotChatConfiguration();\n const labels = config?.labels ?? CopilotChatDefaultLabels;\n return (\n <ToolbarButton\n title={title || labels.userMessageToolbarEditMessageLabel}\n className={className}\n {...props}\n >\n <Edit className=\"cpk:size-[18px]\" />\n </ToolbarButton>\n );\n };\n\n export const BranchNavigation: React.FC<\n React.HTMLAttributes<HTMLDivElement> & {\n currentBranch?: number;\n numberOfBranches?: number;\n onSwitchToBranch?: (\n props: CopilotChatUserMessageOnSwitchToBranchProps,\n ) => void;\n message: UserMessage;\n }\n > = ({\n className,\n currentBranch = 0,\n numberOfBranches = 1,\n onSwitchToBranch,\n message,\n ...props\n }) => {\n if (!numberOfBranches || numberOfBranches <= 1 || !onSwitchToBranch) {\n return null;\n }\n\n const canGoPrev = currentBranch > 0;\n const canGoNext = currentBranch < numberOfBranches - 1;\n\n return (\n <div\n className={twMerge(\"cpk:flex cpk:items-center cpk:gap-1\", className)}\n {...props}\n >\n <Button\n type=\"button\"\n variant=\"assistantMessageToolbarButton\"\n onClick={() =>\n onSwitchToBranch?.({\n branchIndex: currentBranch - 1,\n numberOfBranches,\n message,\n })\n }\n disabled={!canGoPrev}\n className=\"cpk:h-6 cpk:w-6 cpk:p-0\"\n >\n <ChevronLeft className=\"cpk:size-[20px]\" />\n </Button>\n <span className=\"cpk:text-sm cpk:text-muted-foreground cpk:px-0 cpk:font-medium\">\n {currentBranch + 1}/{numberOfBranches}\n </span>\n <Button\n type=\"button\"\n variant=\"assistantMessageToolbarButton\"\n onClick={() =>\n onSwitchToBranch?.({\n branchIndex: currentBranch + 1,\n numberOfBranches,\n message,\n })\n }\n disabled={!canGoNext}\n className=\"cpk:h-6 cpk:w-6 cpk:p-0\"\n >\n <ChevronRight className=\"cpk:size-[20px]\" />\n </Button>\n </div>\n );\n };\n}\n\nCopilotChatUserMessage.Container.displayName =\n \"CopilotChatUserMessage.Container\";\nCopilotChatUserMessage.MessageRenderer.displayName =\n \"CopilotChatUserMessage.MessageRenderer\";\nCopilotChatUserMessage.Toolbar.displayName = \"CopilotChatUserMessage.Toolbar\";\nCopilotChatUserMessage.ToolbarButton.displayName =\n \"CopilotChatUserMessage.ToolbarButton\";\nCopilotChatUserMessage.CopyButton.displayName =\n \"CopilotChatUserMessage.CopyButton\";\nCopilotChatUserMessage.EditButton.displayName =\n \"CopilotChatUserMessage.EditButton\";\nCopilotChatUserMessage.BranchNavigation.displayName =\n \"CopilotChatUserMessage.BranchNavigation\";\n\nexport default CopilotChatUserMessage;\n"],"mappings":";;;;;;;;;;;AAgBA,SAAS,0BAA0B,SAA0C;AAC3E,KAAI,CAAC,QACH,QAAO;AAGT,KAAI,OAAO,YAAY,SACrB,QAAO;AAGT,QAAO,QACJ,KAAK,SAAS;AACb,MACE,QACA,OAAO,SAAS,YAChB,UAAU,QACT,KAA4B,SAAS,UACtC,OAAQ,KAA4B,SAAS,SAE7C,QAAQ,KAA0B;AAEpC,SAAO;GACP,CACD,QAAQ,SAAS,KAAK,SAAS,EAAE,CACjC,KAAK,KAAK;;AAiCf,SAAgB,uBAAuB,EACrC,SACA,eACA,aACA,kBACA,kBACA,wBACA,iBACA,SACA,YACA,YACA,kBACA,UACA,WACA,GAAG,SAC2B;CAC9B,MAAM,4CACE,0BAA0B,QAAQ,QAAQ,EAChD,CAAC,QAAQ,QAAQ,CAClB;CAED,MAAM,uBAAuBA,yBAC3B,iBACA,uBAAuB,iBACvB,EACE,SAAS,kBACV,CACF;CAED,MAAM,kBAAkBA,yBACtB,YACA,uBAAuB,YACvB,EACE,SAAS,YAAY;AACnB,MAAI,iBACF,KAAI;AACF,SAAM,UAAU,UAAU,UAAU,iBAAiB;WAC9C,KAAK;AACZ,WAAQ,MAAM,2BAA2B,IAAI;;IAIpD,CACF;CAED,MAAM,kBAAkBA,yBACtB,YACA,uBAAuB,YACvB,EACE,eAAe,gBAAgB,EAAE,SAAS,CAAC,EAC5C,CACF;CAED,MAAM,wBAAwBA,yBAC5B,kBACA,uBAAuB,kBACvB;EACE,eAAe;EACf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ACvB,SAAS;GACE;GACX,GAAI;aAEH,SACC,2CAACC,sBAAM,WAAU,oBAAoB,GAErC,2CAACC,qBAAK,WAAU,oBAAoB;IAExB;;uCAMf,EAAE,WAAW,OAAO,GAAG,YAAY;EAEtC,MAAM,SADSH,sEAA6B,EACrB,UAAUC;AACjC,SACE,2CAAC;GACC,OAAO,SAAS,OAAO;GACZ;GACX,GAAI;aAEJ,2CAACG,qBAAK,WAAU,oBAAoB;IACtB;;6CAaf,EACH,WACA,gBAAgB,GAChB,mBAAmB,GACnB,kBACA,SACA,GAAG,YACC;AACJ,MAAI,CAAC,oBAAoB,oBAAoB,KAAK,CAAC,iBACjD,QAAO;EAGT,MAAM,YAAY,gBAAgB;EAClC,MAAM,YAAY,gBAAgB,mBAAmB;AAErD,SACE,4CAAC;GACC,uCAAmB,uCAAuC,UAAU;GACpE,GAAI;;IAEJ,2CAACN;KACC,MAAK;KACL,SAAQ;KACR,eACE,mBAAmB;MACjB,aAAa,gBAAgB;MAC7B;MACA;MACD,CAAC;KAEJ,UAAU,CAAC;KACX,WAAU;eAEV,2CAACO,4BAAY,WAAU,oBAAoB;MACpC;IACT,4CAAC;KAAK,WAAU;;MACb,gBAAgB;MAAE;MAAE;;MAChB;IACP,2CAACP;KACC,MAAK;KACL,SAAQ;KACR,eACE,mBAAmB;MACjB,aAAa,gBAAgB;MAC7B;MACA;MACD,CAAC;KAEJ,UAAU,CAAC;KACX,WAAU;eAEV,2CAACQ,6BAAa,WAAU,oBAAoB;MACrC;;IACL;;;AAKZ,uBAAuB,UAAU,cAC/B;AACF,uBAAuB,gBAAgB,cACrC;AACF,uBAAuB,QAAQ,cAAc;AAC7C,uBAAuB,cAAc,cACnC;AACF,uBAAuB,WAAW,cAChC;AACF,uBAAuB,WAAW,cAChC;AACF,uBAAuB,iBAAiB,cACtC;AAEF,qCAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopilotChatUserMessage.d.cts","names":[],"sources":["../../../src/components/chat/CopilotChatUserMessage.tsx"],"mappings":";;;;;UA0CiB,wCAAA;EACf,OAAA,EAAS,WAAA;AAAA;AAAA,UAGM,2CAAA;EACf,OAAA,EAAS,WAAA;EACT,WAAA;EACA,gBAAA;AAAA;AAAA,KAGU,2BAAA,GAA8B,SAAA;EAEtC,eAAA,SAAwB,sBAAA,CAAuB,eAAA;EAC/C,OAAA,SAAgB,sBAAA,CAAuB,OAAA;EACvC,UAAA,SAAmB,sBAAA,CAAuB,UAAA;EAC1C,UAAA,SAAmB,sBAAA,CAAuB,UAAA;EAC1C,gBAAA,SAAyB,sBAAA,CAAuB,gBAAA;AAAA;EAGhD,aAAA,IAAiB,KAAA,EAAO,wCAAA;EACxB,gBAAA,IACE,KAAA,EAAO,2CAAA;EAET,OAAA,EAAS,WAAA;EACT,WAAA;EACA,gBAAA;EACA,sBAAA,GAAyB,KAAA,CAAM,SAAA;AAAA,IAC7B,KAAA,CAAM,cAAA,CAAe,cAAA;AAAA,iBAGX,sBAAA,CAAA;EACd,OAAA;EACA,aAAA;EACA,WAAA;EACA,gBAAA;EACA,gBAAA;EACA,sBAAA;EACA,eAAA;EACA,OAAA;EACA,UAAA;EACA,UAAA;EACA,gBAAA;EACA,QAAA;EACA,SAAA;EAAA,GACG;AAAA,GACF,2BAAA,GAA2B,kBAAA,CAAA,GAAA,CAAA,OAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"CopilotChatUserMessage.d.cts","names":[],"sources":["../../../src/components/chat/CopilotChatUserMessage.tsx"],"mappings":";;;;;UA0CiB,wCAAA;EACf,OAAA,EAAS,WAAA;AAAA;AAAA,UAGM,2CAAA;EACf,OAAA,EAAS,WAAA;EACT,WAAA;EACA,gBAAA;AAAA;AAAA,KAGU,2BAAA,GAA8B,SAAA;EAEtC,eAAA,SAAwB,sBAAA,CAAuB,eAAA;EAC/C,OAAA,SAAgB,sBAAA,CAAuB,OAAA;EACvC,UAAA,SAAmB,sBAAA,CAAuB,UAAA;EAC1C,UAAA,SAAmB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ACE,KAAA,EAAO,2CAAA;IAET,OAAA,EAAS,WAAA;EAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopilotChatUserMessage.d.mts","names":[],"sources":["../../../src/components/chat/CopilotChatUserMessage.tsx"],"mappings":";;;;;UA0CiB,wCAAA;EACf,OAAA,EAAS,WAAA;AAAA;AAAA,UAGM,2CAAA;EACf,OAAA,EAAS,WAAA;EACT,WAAA;EACA,gBAAA;AAAA;AAAA,KAGU,2BAAA,GAA8B,SAAA;EAEtC,eAAA,SAAwB,sBAAA,CAAuB,eAAA;EAC/C,OAAA,SAAgB,sBAAA,CAAuB,OAAA;EACvC,UAAA,SAAmB,sBAAA,CAAuB,UAAA;EAC1C,UAAA,SAAmB,sBAAA,CAAuB,UAAA;EAC1C,gBAAA,SAAyB,sBAAA,CAAuB,gBAAA;AAAA;EAGhD,aAAA,IAAiB,KAAA,EAAO,wCAAA;EACxB,gBAAA,IACE,KAAA,EAAO,2CAAA;EAET,OAAA,EAAS,WAAA;EACT,WAAA;EACA,gBAAA;EACA,sBAAA,GAAyB,KAAA,CAAM,SAAA;AAAA,IAC7B,KAAA,CAAM,cAAA,CAAe,cAAA;AAAA,iBAGX,sBAAA,CAAA;EACd,OAAA;EACA,aAAA;EACA,WAAA;EACA,gBAAA;EACA,gBAAA;EACA,sBAAA;EACA,eAAA;EACA,OAAA;EACA,UAAA;EACA,UAAA;EACA,gBAAA;EACA,QAAA;EACA,SAAA;EAAA,GACG;AAAA,GACF,2BAAA,GAA2B,kBAAA,CAAA,GAAA,CAAA,OAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"CopilotChatUserMessage.d.mts","names":[],"sources":["../../../src/components/chat/CopilotChatUserMessage.tsx"],"mappings":";;;;;UA0CiB,wCAAA;EACf,OAAA,EAAS,WAAA;AAAA;AAAA,UAGM,2CAAA;EACf,OAAA,EAAS,WAAA;EACT,WAAA;EACA,gBAAA;AAAA;AAAA,KAGU,2BAAA,GAA8B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A,CAAM,oBAAA,CAAqB,iBAAA;EAAA,MAehB,gBAAA,EAAkB,KAAA,CAAM,EAAA,CACnC,KAAA,CAAM,cAAA,CAAe,cAAA;IACnB,aAAA;IACA,gBAAA;IACA,gBAAA,IACE,KAAA,EAAO,2CAAA;IAET,OAAA,EAAS,WAAA;EAAA;AAAA"}
|
|
@@ -5,7 +5,7 @@ import { renderSlot } from "../../lib/slots.mjs";
|
|
|
5
5
|
import { useMemo, useState } from "react";
|
|
6
6
|
import { twMerge } from "tailwind-merge";
|
|
7
7
|
import { Check, ChevronLeft, ChevronRight, Copy, Edit } from "lucide-react";
|
|
8
|
-
import {
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
|
|
10
10
|
//#region src/components/chat/CopilotChatUserMessage.tsx
|
|
11
11
|
function flattenUserMessageContent(content) {
|
|
@@ -35,7 +35,7 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
35
35
|
});
|
|
36
36
|
const showBranchNavigation = numberOfBranches && numberOfBranches > 1 && onSwitchToBranch;
|
|
37
37
|
const BoundToolbar = renderSlot(toolbar, CopilotChatUserMessage.Toolbar, { children: /* @__PURE__ */ jsxs("div", {
|
|
38
|
-
className: "flex items-center gap-1 justify-end",
|
|
38
|
+
className: "cpk:flex cpk:items-center cpk:gap-1 cpk:justify-end",
|
|
39
39
|
children: [
|
|
40
40
|
additionalToolbarItems,
|
|
41
41
|
BoundCopyButton,
|
|
@@ -43,19 +43,24 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
43
43
|
showBranchNavigation && BoundBranchNavigation
|
|
44
44
|
]
|
|
45
45
|
}) });
|
|
46
|
-
if (children) return /* @__PURE__ */ jsx(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
if (children) return /* @__PURE__ */ jsx("div", {
|
|
47
|
+
"data-copilotkit": true,
|
|
48
|
+
style: { display: "contents" },
|
|
49
|
+
children: children({
|
|
50
|
+
messageRenderer: BoundMessageRenderer,
|
|
51
|
+
toolbar: BoundToolbar,
|
|
52
|
+
copyButton: BoundCopyButton,
|
|
53
|
+
editButton: BoundEditButton,
|
|
54
|
+
branchNavigation: BoundBranchNavigation,
|
|
55
|
+
message,
|
|
56
|
+
branchIndex,
|
|
57
|
+
numberOfBranches,
|
|
58
|
+
additionalToolbarItems
|
|
59
|
+
})
|
|
60
|
+
});
|
|
57
61
|
return /* @__PURE__ */ jsxs("div", {
|
|
58
|
-
|
|
62
|
+
"data-copilotkit": true,
|
|
63
|
+
className: twMerge("cpk:flex cpk:flex-col cpk:items-end cpk:group cpk:pt-10", className),
|
|
59
64
|
"data-message-id": message.id,
|
|
60
65
|
...props,
|
|
61
66
|
children: [BoundMessageRenderer, BoundToolbar]
|
|
@@ -63,16 +68,16 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
63
68
|
}
|
|
64
69
|
(function(_CopilotChatUserMessage) {
|
|
65
70
|
_CopilotChatUserMessage.Container = ({ children, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
66
|
-
className: twMerge("flex flex-col items-end group", className),
|
|
71
|
+
className: twMerge("cpk:flex cpk:flex-col cpk:items-end cpk:group", className),
|
|
67
72
|
...props,
|
|
68
73
|
children
|
|
69
74
|
});
|
|
70
75
|
_CopilotChatUserMessage.MessageRenderer = ({ content, className }) => /* @__PURE__ */ jsx("div", {
|
|
71
|
-
className: twMerge("prose dark:prose-invert bg-muted relative max-w-[80%] rounded-[18px] px-4 py-1.5 data-[multiline]:py-3 inline-block whitespace-pre-wrap", className),
|
|
76
|
+
className: twMerge("cpk:prose cpk:dark:prose-invert cpk:bg-muted cpk:relative cpk:max-w-[80%] cpk:rounded-[18px] cpk:px-4 cpk:py-1.5 cpk:data-[multiline]:py-3 cpk:inline-block cpk:whitespace-pre-wrap", className),
|
|
72
77
|
children: content
|
|
73
78
|
});
|
|
74
79
|
_CopilotChatUserMessage.Toolbar = ({ className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
75
|
-
className: twMerge("w-full bg-transparent flex items-center justify-end
|
|
80
|
+
className: twMerge("cpk:w-full cpk:bg-transparent cpk:flex cpk:items-center cpk:justify-end cpk:-mr-[5px] cpk:mt-[4px] cpk:invisible cpk:group-hover:visible", className),
|
|
76
81
|
...props
|
|
77
82
|
});
|
|
78
83
|
const ToolbarButton = _CopilotChatUserMessage.ToolbarButton = ({ title, children, className, ...props }) => {
|
|
@@ -104,7 +109,7 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
104
109
|
onClick: handleClick,
|
|
105
110
|
className,
|
|
106
111
|
...props,
|
|
107
|
-
children: copied ? /* @__PURE__ */ jsx(Check, { className: "size-[18px]" }) : /* @__PURE__ */ jsx(Copy, { className: "size-[18px]" })
|
|
112
|
+
children: copied ? /* @__PURE__ */ jsx(Check, { className: "cpk:size-[18px]" }) : /* @__PURE__ */ jsx(Copy, { className: "cpk:size-[18px]" })
|
|
108
113
|
});
|
|
109
114
|
};
|
|
110
115
|
_CopilotChatUserMessage.EditButton = ({ className, title, ...props }) => {
|
|
@@ -113,7 +118,7 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
113
118
|
title: title || labels.userMessageToolbarEditMessageLabel,
|
|
114
119
|
className,
|
|
115
120
|
...props,
|
|
116
|
-
children: /* @__PURE__ */ jsx(Edit, { className: "size-[18px]" })
|
|
121
|
+
children: /* @__PURE__ */ jsx(Edit, { className: "cpk:size-[18px]" })
|
|
117
122
|
});
|
|
118
123
|
};
|
|
119
124
|
_CopilotChatUserMessage.BranchNavigation = ({ className, currentBranch = 0, numberOfBranches = 1, onSwitchToBranch, message, ...props }) => {
|
|
@@ -121,7 +126,7 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
121
126
|
const canGoPrev = currentBranch > 0;
|
|
122
127
|
const canGoNext = currentBranch < numberOfBranches - 1;
|
|
123
128
|
return /* @__PURE__ */ jsxs("div", {
|
|
124
|
-
className: twMerge("flex items-center gap-1", className),
|
|
129
|
+
className: twMerge("cpk:flex cpk:items-center cpk:gap-1", className),
|
|
125
130
|
...props,
|
|
126
131
|
children: [
|
|
127
132
|
/* @__PURE__ */ jsx(Button, {
|
|
@@ -133,11 +138,11 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
133
138
|
message
|
|
134
139
|
}),
|
|
135
140
|
disabled: !canGoPrev,
|
|
136
|
-
className: "h-6 w-6 p-0",
|
|
137
|
-
children: /* @__PURE__ */ jsx(ChevronLeft, { className: "size-[20px]" })
|
|
141
|
+
className: "cpk:h-6 cpk:w-6 cpk:p-0",
|
|
142
|
+
children: /* @__PURE__ */ jsx(ChevronLeft, { className: "cpk:size-[20px]" })
|
|
138
143
|
}),
|
|
139
144
|
/* @__PURE__ */ jsxs("span", {
|
|
140
|
-
className: "text-sm text-muted-foreground px-0 font-medium",
|
|
145
|
+
className: "cpk:text-sm cpk:text-muted-foreground cpk:px-0 cpk:font-medium",
|
|
141
146
|
children: [
|
|
142
147
|
currentBranch + 1,
|
|
143
148
|
"/",
|
|
@@ -153,8 +158,8 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
153
158
|
message
|
|
154
159
|
}),
|
|
155
160
|
disabled: !canGoNext,
|
|
156
|
-
className: "h-6 w-6 p-0",
|
|
157
|
-
children: /* @__PURE__ */ jsx(ChevronRight, { className: "size-[20px]" })
|
|
161
|
+
className: "cpk:h-6 cpk:w-6 cpk:p-0",
|
|
162
|
+
children: /* @__PURE__ */ jsx(ChevronRight, { className: "cpk:size-[20px]" })
|
|
158
163
|
})
|
|
159
164
|
]
|
|
160
165
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopilotChatUserMessage.mjs","names":[],"sources":["../../../src/components/chat/CopilotChatUserMessage.tsx"],"sourcesContent":["import { useMemo, useState } from \"react\";\nimport { Copy, Check, Edit, ChevronLeft, ChevronRight } from \"lucide-react\";\nimport {\n useCopilotChatConfiguration,\n CopilotChatDefaultLabels,\n} from \"@/providers/CopilotChatConfigurationProvider\";\nimport { twMerge } from \"tailwind-merge\";\nimport { Button } from \"@/components/ui/button\";\nimport { UserMessage } from \"@ag-ui/core\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"@/components/ui/tooltip\";\nimport { renderSlot, WithSlots } from \"@/lib/slots\";\n\nfunction flattenUserMessageContent(content?: UserMessage[\"content\"]): string {\n if (!content) {\n return \"\";\n }\n\n if (typeof content === \"string\") {\n return content;\n }\n\n return content\n .map((part) => {\n if (\n part &&\n typeof part === \"object\" &&\n \"type\" in part &&\n (part as { type?: unknown }).type === \"text\" &&\n typeof (part as { text?: unknown }).text === \"string\"\n ) {\n return (part as { text: string }).text;\n }\n return \"\";\n })\n .filter((text) => text.length > 0)\n .join(\"\\n\");\n}\n\nexport interface CopilotChatUserMessageOnEditMessageProps {\n message: UserMessage;\n}\n\nexport interface CopilotChatUserMessageOnSwitchToBranchProps {\n message: UserMessage;\n branchIndex: number;\n numberOfBranches: number;\n}\n\nexport type CopilotChatUserMessageProps = WithSlots<\n {\n messageRenderer: typeof CopilotChatUserMessage.MessageRenderer;\n toolbar: typeof CopilotChatUserMessage.Toolbar;\n copyButton: typeof CopilotChatUserMessage.CopyButton;\n editButton: typeof CopilotChatUserMessage.EditButton;\n branchNavigation: typeof CopilotChatUserMessage.BranchNavigation;\n },\n {\n onEditMessage?: (props: CopilotChatUserMessageOnEditMessageProps) => void;\n onSwitchToBranch?: (\n props: CopilotChatUserMessageOnSwitchToBranchProps,\n ) => void;\n message: UserMessage;\n branchIndex?: number;\n numberOfBranches?: number;\n additionalToolbarItems?: React.ReactNode;\n } & React.HTMLAttributes<HTMLDivElement>\n>;\n\nexport function CopilotChatUserMessage({\n message,\n onEditMessage,\n branchIndex,\n numberOfBranches,\n onSwitchToBranch,\n additionalToolbarItems,\n messageRenderer,\n toolbar,\n copyButton,\n editButton,\n branchNavigation,\n children,\n className,\n ...props\n}: CopilotChatUserMessageProps) {\n const flattenedContent = useMemo(\n () => flattenUserMessageContent(message.content),\n [message.content],\n );\n\n const BoundMessageRenderer = renderSlot(\n messageRenderer,\n CopilotChatUserMessage.MessageRenderer,\n {\n content: flattenedContent,\n },\n );\n\n const BoundCopyButton = renderSlot(\n copyButton,\n CopilotChatUserMessage.CopyButton,\n {\n onClick: async () => {\n if (flattenedContent) {\n try {\n await navigator.clipboard.writeText(flattenedContent);\n } catch (err) {\n console.error(\"Failed to copy message:\", err);\n }\n }\n },\n },\n );\n\n const BoundEditButton = renderSlot(\n editButton,\n CopilotChatUserMessage.EditButton,\n {\n onClick: () => onEditMessage?.({ message }),\n },\n );\n\n const BoundBranchNavigation = renderSlot(\n branchNavigation,\n CopilotChatUserMessage.BranchNavigation,\n {\n currentBranch: branchIndex,\n numberOfBranches,\n onSwitchToBranch,\n message,\n },\n );\n\n const showBranchNavigation =\n numberOfBranches && numberOfBranches > 1 && onSwitchToBranch;\n\n const BoundToolbar = renderSlot(toolbar, CopilotChatUserMessage.Toolbar, {\n children: (\n <div className=\"flex items-center gap-1 justify-end\">\n {additionalToolbarItems}\n {BoundCopyButton}\n {onEditMessage && BoundEditButton}\n {showBranchNavigation && BoundBranchNavigation}\n </div>\n ),\n });\n\n if (children) {\n return (\n <>\n {children({\n messageRenderer: BoundMessageRenderer,\n toolbar: BoundToolbar,\n copyButton: BoundCopyButton,\n editButton: BoundEditButton,\n branchNavigation: BoundBranchNavigation,\n message,\n branchIndex,\n numberOfBranches,\n additionalToolbarItems,\n })}\n </>\n );\n }\n\n return (\n <div\n className={twMerge(\"flex flex-col items-end group pt-10\", className)}\n data-message-id={message.id}\n {...props}\n >\n {BoundMessageRenderer}\n {BoundToolbar}\n </div>\n );\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace CopilotChatUserMessage {\n export const Container: React.FC<\n React.PropsWithChildren<React.HTMLAttributes<HTMLDivElement>>\n > = ({ children, className, ...props }) => (\n <div\n className={twMerge(\"flex flex-col items-end group\", className)}\n {...props}\n >\n {children}\n </div>\n );\n\n export const MessageRenderer: React.FC<{\n content: string;\n className?: string;\n }> = ({ content, className }) => (\n <div\n className={twMerge(\n \"prose dark:prose-invert bg-muted relative max-w-[80%] rounded-[18px] px-4 py-1.5 data-[multiline]:py-3 inline-block whitespace-pre-wrap\",\n className,\n )}\n >\n {content}\n </div>\n );\n\n export const Toolbar: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({\n className,\n ...props\n }) => (\n <div\n className={twMerge(\n \"w-full bg-transparent flex items-center justify-end -mr-[5px] mt-[4px] invisible group-hover:visible\",\n className,\n )}\n {...props}\n />\n );\n\n export const ToolbarButton: React.FC<\n React.ButtonHTMLAttributes<HTMLButtonElement> & {\n title: string;\n children: React.ReactNode;\n }\n > = ({ title, children, className, ...props }) => {\n return (\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n type=\"button\"\n variant=\"assistantMessageToolbarButton\"\n aria-label={title}\n className={twMerge(className)}\n {...props}\n >\n {children}\n </Button>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">\n <p>{title}</p>\n </TooltipContent>\n </Tooltip>\n );\n };\n\n export const CopyButton: React.FC<\n React.ButtonHTMLAttributes<HTMLButtonElement> & { copied?: boolean }\n > = ({ className, title, onClick, ...props }) => {\n const config = useCopilotChatConfiguration();\n const labels = config?.labels ?? CopilotChatDefaultLabels;\n const [copied, setCopied] = useState(false);\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n\n if (onClick) {\n onClick(event);\n }\n };\n\n return (\n <ToolbarButton\n title={title || labels.userMessageToolbarCopyMessageLabel}\n onClick={handleClick}\n className={className}\n {...props}\n >\n {copied ? (\n <Check className=\"size-[18px]\" />\n ) : (\n <Copy className=\"size-[18px]\" />\n )}\n </ToolbarButton>\n );\n };\n\n export const EditButton: React.FC<\n React.ButtonHTMLAttributes<HTMLButtonElement>\n > = ({ className, title, ...props }) => {\n const config = useCopilotChatConfiguration();\n const labels = config?.labels ?? CopilotChatDefaultLabels;\n return (\n <ToolbarButton\n title={title || labels.userMessageToolbarEditMessageLabel}\n className={className}\n {...props}\n >\n <Edit className=\"size-[18px]\" />\n </ToolbarButton>\n );\n };\n\n export const BranchNavigation: React.FC<\n React.HTMLAttributes<HTMLDivElement> & {\n currentBranch?: number;\n numberOfBranches?: number;\n onSwitchToBranch?: (\n props: CopilotChatUserMessageOnSwitchToBranchProps,\n ) => void;\n message: UserMessage;\n }\n > = ({\n className,\n currentBranch = 0,\n numberOfBranches = 1,\n onSwitchToBranch,\n message,\n ...props\n }) => {\n if (!numberOfBranches || numberOfBranches <= 1 || !onSwitchToBranch) {\n return null;\n }\n\n const canGoPrev = currentBranch > 0;\n const canGoNext = currentBranch < numberOfBranches - 1;\n\n return (\n <div className={twMerge(\"flex items-center gap-1\", className)} {...props}>\n <Button\n type=\"button\"\n variant=\"assistantMessageToolbarButton\"\n onClick={() =>\n onSwitchToBranch?.({\n branchIndex: currentBranch - 1,\n numberOfBranches,\n message,\n })\n }\n disabled={!canGoPrev}\n className=\"h-6 w-6 p-0\"\n >\n <ChevronLeft className=\"size-[20px]\" />\n </Button>\n <span className=\"text-sm text-muted-foreground px-0 font-medium\">\n {currentBranch + 1}/{numberOfBranches}\n </span>\n <Button\n type=\"button\"\n variant=\"assistantMessageToolbarButton\"\n onClick={() =>\n onSwitchToBranch?.({\n branchIndex: currentBranch + 1,\n numberOfBranches,\n message,\n })\n }\n disabled={!canGoNext}\n className=\"h-6 w-6 p-0\"\n >\n <ChevronRight className=\"size-[20px]\" />\n </Button>\n </div>\n );\n };\n}\n\nCopilotChatUserMessage.Container.displayName =\n \"CopilotChatUserMessage.Container\";\nCopilotChatUserMessage.MessageRenderer.displayName =\n \"CopilotChatUserMessage.MessageRenderer\";\nCopilotChatUserMessage.Toolbar.displayName = \"CopilotChatUserMessage.Toolbar\";\nCopilotChatUserMessage.ToolbarButton.displayName =\n \"CopilotChatUserMessage.ToolbarButton\";\nCopilotChatUserMessage.CopyButton.displayName =\n \"CopilotChatUserMessage.CopyButton\";\nCopilotChatUserMessage.EditButton.displayName =\n \"CopilotChatUserMessage.EditButton\";\nCopilotChatUserMessage.BranchNavigation.displayName =\n \"CopilotChatUserMessage.BranchNavigation\";\n\nexport default CopilotChatUserMessage;\n"],"mappings":";;;;;;;;;;AAgBA,SAAS,0BAA0B,SAA0C;AAC3E,KAAI,CAAC,QACH,QAAO;AAGT,KAAI,OAAO,YAAY,SACrB,QAAO;AAGT,QAAO,QACJ,KAAK,SAAS;AACb,MACE,QACA,OAAO,SAAS,YAChB,UAAU,QACT,KAA4B,SAAS,UACtC,OAAQ,KAA4B,SAAS,SAE7C,QAAQ,KAA0B;AAEpC,SAAO;GACP,CACD,QAAQ,SAAS,KAAK,SAAS,EAAE,CACjC,KAAK,KAAK;;AAiCf,SAAgB,uBAAuB,EACrC,SACA,eACA,aACA,kBACA,kBACA,wBACA,iBACA,SACA,YACA,YACA,kBACA,UACA,WACA,GAAG,SAC2B;CAC9B,MAAM,mBAAmB,cACjB,0BAA0B,QAAQ,QAAQ,EAChD,CAAC,QAAQ,QAAQ,CAClB;CAED,MAAM,uBAAuB,WAC3B,iBACA,uBAAuB,iBACvB,EACE,SAAS,kBACV,CACF;CAED,MAAM,kBAAkB,WACtB,YACA,uBAAuB,YACvB,EACE,SAAS,YAAY;AACnB,MAAI,iBACF,KAAI;AACF,SAAM,UAAU,UAAU,UAAU,iBAAiB;WAC9C,KAAK;AACZ,WAAQ,MAAM,2BAA2B,IAAI;;IAIpD,CACF;CAED,MAAM,kBAAkB,WACtB,YACA,uBAAuB,YACvB,EACE,eAAe,gBAAgB,EAAE,SAAS,CAAC,EAC5C,CACF;CAED,MAAM,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"sources":["../../../src/components/chat/CopilotChatUserMessage.tsx"],"sourcesContent":["import { useMemo, useState } from \"react\";\nimport { Copy, Check, Edit, ChevronLeft, ChevronRight } from \"lucide-react\";\nimport {\n useCopilotChatConfiguration,\n CopilotChatDefaultLabels,\n} from \"@/providers/CopilotChatConfigurationProvider\";\nimport { twMerge } from \"tailwind-merge\";\nimport { Button } from \"@/components/ui/button\";\nimport { UserMessage } from \"@ag-ui/core\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"@/components/ui/tooltip\";\nimport { renderSlot, WithSlots } from \"@/lib/slots\";\n\nfunction flattenUserMessageContent(content?: UserMessage[\"content\"]): string {\n if (!content) {\n return \"\";\n }\n\n if (typeof content === \"string\") {\n return content;\n }\n\n return content\n .map((part) => {\n if (\n part &&\n typeof part === \"object\" &&\n \"type\" in part &&\n (part as { type?: unknown }).type === \"text\" &&\n typeof (part as { text?: unknown }).text === \"string\"\n ) {\n return (part as { text: string }).text;\n }\n return \"\";\n })\n .filter((text) => text.length > 0)\n .join(\"\\n\");\n}\n\nexport interface CopilotChatUserMessageOnEditMessageProps {\n message: UserMessage;\n}\n\nexport interface CopilotChatUserMessageOnSwitchToBranchProps {\n message: UserMessage;\n branchIndex: number;\n numberOfBranches: number;\n}\n\nexport type CopilotChatUserMessageProps = WithSlots<\n {\n messageRenderer: typeof CopilotChatUserMessage.MessageRenderer;\n toolbar: typeof CopilotChatUserMessage.Toolbar;\n copyButton: typeof CopilotChatUserMessage.CopyButton;\n editButton: typeof CopilotChatUserMessage.EditButton;\n branchNavigation: typeof CopilotChatUserMessage.BranchNavigation;\n },\n {\n onEditMessage?: (props: CopilotChatUserMessageOnEditMessageProps) => void;\n onSwitchToBranch?: (\n props: CopilotChatUserMessageOnSwitchToBranchProps,\n ) => void;\n message: UserMessage;\n branchIndex?: number;\n numberOfBranches?: number;\n additionalToolbarItems?: React.ReactNode;\n } & React.HTMLAttributes<HTMLDivElement>\n>;\n\nexport function CopilotChatUserMessage({\n message,\n onEditMessage,\n branchIndex,\n numberOfBranches,\n onSwitchToBranch,\n additionalToolbarItems,\n messageRenderer,\n toolbar,\n copyButton,\n editButton,\n branchNavigation,\n children,\n className,\n ...props\n}: CopilotChatUserMessageProps) {\n const flattenedContent = useMemo(\n () => flattenUserMessageContent(message.content),\n [message.content],\n );\n\n const BoundMessageRenderer = renderSlot(\n messageRenderer,\n CopilotChatUserMessage.MessageRenderer,\n {\n content: flattenedContent,\n },\n );\n\n const BoundCopyButton = renderSlot(\n copyButton,\n CopilotChatUserMessage.CopyButton,\n {\n onClick: async () => {\n if (flattenedContent) {\n try {\n await navigator.clipboard.writeText(flattenedContent);\n } catch (err) {\n console.error(\"Failed to copy message:\", err);\n }\n }\n },\n },\n );\n\n const BoundEditButton = renderSlot(\n editButton,\n CopilotChatUserMessage.EditButton,\n {\n onClick: () => onEditMessage?.({ message }),\n },\n );\n\n const BoundBranchNavigation = renderSlot(\n branchNavigation,\n CopilotChatUserMessage.BranchNavigation,\n {\n currentBranch: branchIndex,\n numberOfBranches,\n onSwitchToBranch,\n message,\n },\n );\n\n const showBranchNavigation =\n numberOfBranches && numberOfBranches > 1 && onSwitchToBranch;\n\n const BoundToolbar = renderSlot(toolbar, CopilotChatUserMessage.Toolbar, {\n children: (\n <div className=\"cpk:flex cpk:items-center cpk:gap-1 cpk:justify-end\">\n {additionalToolbarItems}\n {BoundCopyButton}\n {onEditMessage && BoundEditButton}\n {showBranchNavigation && BoundBranchNavigation}\n </div>\n ),\n });\n\n if (children) {\n return (\n <div data-copilotkit style={{ display: \"contents\" }}>\n {children({\n messageRenderer: BoundMessageRenderer,\n toolbar: BoundToolbar,\n copyButton: BoundCopyButton,\n editButton: BoundEditButton,\n branchNavigation: BoundBranchNavigation,\n message,\n branchIndex,\n numberOfBranches,\n additionalToolbarItems,\n })}\n </div>\n );\n }\n\n return (\n <div\n data-copilotkit\n className={twMerge(\n \"cpk:flex cpk:flex-col cpk:items-end cpk:group cpk:pt-10\",\n className,\n )}\n data-message-id={message.id}\n {...props}\n >\n {BoundMessageRenderer}\n {BoundToolbar}\n </div>\n );\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace CopilotChatUserMessage {\n export const Container: React.FC<\n React.PropsWithChildren<React.HTMLAttributes<HTMLDivElement>>\n > = ({ children, className, ...props }) => (\n <div\n className={twMerge(\n \"cpk:flex cpk:flex-col cpk:items-end cpk:group\",\n className,\n )}\n {...props}\n >\n {children}\n </div>\n );\n\n export const MessageRenderer: React.FC<{\n content: string;\n className?: string;\n }> = ({ content, className }) => (\n <div\n className={twMerge(\n \"cpk:prose cpk:dark:prose-invert cpk:bg-muted cpk:relative cpk:max-w-[80%] cpk:rounded-[18px] cpk:px-4 cpk:py-1.5 cpk:data-[multiline]:py-3 cpk:inline-block cpk:whitespace-pre-wrap\",\n className,\n )}\n >\n {content}\n </div>\n );\n\n export const Toolbar: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({\n className,\n ...props\n }) => (\n <div\n className={twMerge(\n \"cpk:w-full cpk:bg-transparent cpk:flex cpk:items-center cpk:justify-end cpk:-mr-[5px] cpk:mt-[4px] cpk:invisible cpk:group-hover:visible\",\n className,\n )}\n {...props}\n />\n );\n\n export const ToolbarButton: React.FC<\n React.ButtonHTMLAttributes<HTMLButtonElement> & {\n title: string;\n children: React.ReactNode;\n }\n > = ({ title, children, className, ...props }) => {\n return (\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n type=\"button\"\n variant=\"assistantMessageToolbarButton\"\n aria-label={title}\n className={twMerge(className)}\n {...props}\n >\n {children}\n </Button>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">\n <p>{title}</p>\n </TooltipContent>\n </Tooltip>\n );\n };\n\n export const CopyButton: React.FC<\n React.ButtonHTMLAttributes<HTMLButtonElement> & { copied?: boolean }\n > = ({ className, title, onClick, ...props }) => {\n const config = useCopilotChatConfiguration();\n const labels = config?.labels ?? CopilotChatDefaultLabels;\n const [copied, setCopied] = useState(false);\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n\n if (onClick) {\n onClick(event);\n }\n };\n\n return (\n <ToolbarButton\n title={title || labels.userMessageToolbarCopyMessageLabel}\n onClick={handleClick}\n className={className}\n {...props}\n >\n {copied ? (\n <Check className=\"cpk:size-[18px]\" />\n ) : (\n <Copy className=\"cpk:size-[18px]\" />\n )}\n </ToolbarButton>\n );\n };\n\n export const EditButton: React.FC<\n React.ButtonHTMLAttributes<HTMLButtonElement>\n > = ({ className, title, ...props }) => {\n const config = useCopilotChatConfiguration();\n const labels = config?.labels ?? CopilotChatDefaultLabels;\n return (\n <ToolbarButton\n title={title || labels.userMessageToolbarEditMessageLabel}\n className={className}\n {...props}\n >\n <Edit className=\"cpk:size-[18px]\" />\n </ToolbarButton>\n );\n };\n\n export const BranchNavigation: React.FC<\n React.HTMLAttributes<HTMLDivElement> & {\n currentBranch?: number;\n numberOfBranches?: number;\n onSwitchToBranch?: (\n props: CopilotChatUserMessageOnSwitchToBranchProps,\n ) => void;\n message: UserMessage;\n }\n > = ({\n className,\n currentBranch = 0,\n numberOfBranches = 1,\n onSwitchToBranch,\n message,\n ...props\n }) => {\n if (!numberOfBranches || numberOfBranches <= 1 || !onSwitchToBranch) {\n return null;\n }\n\n const canGoPrev = currentBranch > 0;\n const canGoNext = currentBranch < numberOfBranches - 1;\n\n return (\n <div\n className={twMerge(\"cpk:flex cpk:items-center cpk:gap-1\", className)}\n {...props}\n >\n <Button\n type=\"button\"\n variant=\"assistantMessageToolbarButton\"\n onClick={() =>\n onSwitchToBranch?.({\n branchIndex: currentBranch - 1,\n numberOfBranches,\n message,\n })\n }\n disabled={!canGoPrev}\n className=\"cpk:h-6 cpk:w-6 cpk:p-0\"\n >\n <ChevronLeft className=\"cpk:size-[20px]\" />\n </Button>\n <span className=\"cpk:text-sm cpk:text-muted-foreground cpk:px-0 cpk:font-medium\">\n {currentBranch + 1}/{numberOfBranches}\n </span>\n <Button\n type=\"button\"\n variant=\"assistantMessageToolbarButton\"\n onClick={() =>\n onSwitchToBranch?.({\n branchIndex: currentBranch + 1,\n numberOfBranches,\n message,\n })\n }\n disabled={!canGoNext}\n className=\"cpk:h-6 cpk:w-6 cpk:p-0\"\n >\n <ChevronRight className=\"cpk:size-[20px]\" />\n </Button>\n </div>\n );\n };\n}\n\nCopilotChatUserMessage.Container.displayName =\n \"CopilotChatUserMessage.Container\";\nCopilotChatUserMessage.MessageRenderer.displayName =\n \"CopilotChatUserMessage.MessageRenderer\";\nCopilotChatUserMessage.Toolbar.displayName = \"CopilotChatUserMessage.Toolbar\";\nCopilotChatUserMessage.ToolbarButton.displayName =\n \"CopilotChatUserMessage.ToolbarButton\";\nCopilotChatUserMessage.CopyButton.displayName =\n \"CopilotChatUserMessage.CopyButton\";\nCopilotChatUserMessage.EditButton.displayName =\n \"CopilotChatUserMessage.EditButton\";\nCopilotChatUserMessage.BranchNavigation.displayName =\n \"CopilotChatUserMessage.BranchNavigation\";\n\nexport default CopilotChatUserMessage;\n"],"mappings":";;;;;;;;;;AAgBA,SAAS,0BAA0B,SAA0C;AAC3E,KAAI,CAAC,QACH,QAAO;AAGT,KAAI,OAAO,YAAY,SACrB,QAAO;AAGT,QAAO,QACJ,KAAK,SAAS;AACb,MACE,QACA,OAAO,SAAS,YAChB,UAAU,QACT,KAA4B,SAAS,UACtC,OAAQ,KAA4B,SAAS,SAE7C,QAAQ,KAA0B;AAEpC,SAAO;GACP,CACD,QAAQ,SAAS,KAAK,SAAS,EAAE,CACjC,KAAK,KAAK;;AAiCf,SAAgB,uBAAuB,EACrC,SACA,eACA,aACA,kBACA,kBACA,wBACA,iBACA,SACA,YACA,YACA,kBACA,UACA,WACA,GAAG,SAC2B;CAC9B,MAAM,mBAAmB,cACjB,0BAA0B,QAAQ,QAAQ,EAChD,CAAC,QAAQ,QAAQ,CAClB;CAED,MAAM,uBAAuB,WAC3B,iBACA,uBAAuB,iBACvB,EACE,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AC;KAEJ,UAAU,CAAC;KACX,WAAU;eAEV,oBAAC,gBAAa,WAAU,oBAAoB;MACrC;;IACL;;;AAKZ,uBAAuB,UAAU,cAC/B;AACF,uBAAuB,gBAAgB,cACrC;AACF,uBAAuB,QAAQ,cAAc;AAC7C,uBAAuB,cAAc,cACnC;AACF,uBAAuB,WAAW,cAChC;AACF,uBAAuB,WAAW,cAChC;AACF,uBAAuB,iBAAiB,cACtC;AAEF,qCAAe"}
|
|
@@ -73,7 +73,7 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
73
73
|
suggestions,
|
|
74
74
|
loadingIndexes: suggestionLoadingIndexes,
|
|
75
75
|
onSelectSuggestion,
|
|
76
|
-
className: "mb-3 lg:ml-4 lg:mr-4 ml-0 mr-0"
|
|
76
|
+
className: "cpk:mb-3 cpk:lg:ml-4 cpk:lg:mr-4 cpk:ml-0 cpk:mr-0"
|
|
77
77
|
}) : null;
|
|
78
78
|
const BoundScrollView = require_slots.renderSlot(scrollView, CopilotChatView.ScrollView, {
|
|
79
79
|
autoScroll,
|
|
@@ -82,9 +82,9 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
82
82
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
83
83
|
style: { paddingBottom: `${inputContainerHeight + FEATHER_HEIGHT + (hasSuggestions ? 4 : 32)}px` },
|
|
84
84
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
85
|
-
className: "max-w-3xl mx-auto",
|
|
85
|
+
className: "cpk:max-w-3xl cpk:mx-auto",
|
|
86
86
|
children: [BoundMessageView, hasSuggestions ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
87
|
-
className: "pl-0 pr-4 sm:px-0 mt-4",
|
|
87
|
+
className: "cpk:pl-0 cpk:pr-4 cpk:sm:px-0 cpk:mt-4",
|
|
88
88
|
children: BoundSuggestionView
|
|
89
89
|
}) : null]
|
|
90
90
|
})
|
|
@@ -110,19 +110,25 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
110
110
|
suggestionView: BoundSuggestionView ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, {})
|
|
111
111
|
});
|
|
112
112
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
113
|
-
|
|
113
|
+
"data-copilotkit": true,
|
|
114
|
+
className: (0, tailwind_merge.twMerge)("cpk:relative cpk:h-full cpk:flex cpk:flex-col", className),
|
|
114
115
|
...props,
|
|
115
116
|
children: BoundWelcomeScreen
|
|
116
117
|
});
|
|
117
118
|
}
|
|
118
|
-
if (children) return
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
if (children) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
120
|
+
"data-copilotkit": true,
|
|
121
|
+
style: { display: "contents" },
|
|
122
|
+
children: children({
|
|
123
|
+
messageView: BoundMessageView,
|
|
124
|
+
input: BoundInput,
|
|
125
|
+
scrollView: BoundScrollView,
|
|
126
|
+
suggestionView: BoundSuggestionView ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, {})
|
|
127
|
+
})
|
|
123
128
|
});
|
|
124
129
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
125
|
-
|
|
130
|
+
"data-copilotkit": true,
|
|
131
|
+
className: (0, tailwind_merge.twMerge)("cpk:relative cpk:h-full", className),
|
|
126
132
|
...props,
|
|
127
133
|
children: [BoundScrollView, BoundInput]
|
|
128
134
|
});
|
|
@@ -133,19 +139,19 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
133
139
|
const BoundFeather = require_slots.renderSlot(feather, CopilotChatView.Feather, {});
|
|
134
140
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
135
141
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(use_stick_to_bottom.StickToBottom.Content, {
|
|
136
|
-
className: "overflow-y-scroll overflow-x-hidden",
|
|
142
|
+
className: "cpk:overflow-y-scroll cpk:overflow-x-hidden",
|
|
137
143
|
style: {
|
|
138
144
|
flex: "1 1 0%",
|
|
139
145
|
minHeight: 0
|
|
140
146
|
},
|
|
141
147
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
142
|
-
className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6",
|
|
148
|
+
className: "cpk:px-4 cpk:sm:px-0 cpk:[div[data-sidebar-chat]_&]:px-8 cpk:[div[data-popup-chat]_&]:px-6",
|
|
143
149
|
children
|
|
144
150
|
})
|
|
145
151
|
}),
|
|
146
152
|
BoundFeather,
|
|
147
153
|
!isAtBottom && !isResizing && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
148
|
-
className: "absolute inset-x-0 flex justify-center z-30 pointer-events-none",
|
|
154
|
+
className: "cpk:absolute cpk:inset-x-0 cpk:flex cpk:justify-center cpk:z-30 cpk:pointer-events-none",
|
|
149
155
|
style: { bottom: `${inputContainerHeight + FEATHER_HEIGHT + 16}px` },
|
|
150
156
|
children: require_slots.renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, { onClick: () => scrollToBottom() })
|
|
151
157
|
})
|
|
@@ -175,9 +181,9 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
175
181
|
};
|
|
176
182
|
}, [scrollRef, autoScroll]);
|
|
177
183
|
if (!hasMounted) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
178
|
-
className: "h-full max-h-full flex flex-col min-h-0 overflow-y-scroll overflow-x-hidden",
|
|
184
|
+
className: "cpk:h-full cpk:max-h-full cpk:flex cpk:flex-col cpk:min-h-0 cpk:overflow-y-scroll cpk:overflow-x-hidden",
|
|
179
185
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
180
|
-
className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6",
|
|
186
|
+
className: "cpk:px-4 cpk:sm:px-0 cpk:[div[data-sidebar-chat]_&]:px-8 cpk:[div[data-popup-chat]_&]:px-6",
|
|
181
187
|
children
|
|
182
188
|
})
|
|
183
189
|
});
|
|
@@ -185,17 +191,17 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
185
191
|
const BoundFeather = require_slots.renderSlot(feather, CopilotChatView.Feather, {});
|
|
186
192
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
187
193
|
ref: scrollRef,
|
|
188
|
-
className: require_utils.cn("h-full max-h-full flex flex-col min-h-0 overflow-y-scroll overflow-x-hidden relative", className),
|
|
194
|
+
className: require_utils.cn("cpk:h-full cpk:max-h-full cpk:flex cpk:flex-col cpk:min-h-0 cpk:overflow-y-scroll cpk:overflow-x-hidden cpk:relative", className),
|
|
189
195
|
...props,
|
|
190
196
|
children: [
|
|
191
197
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
192
198
|
ref: contentRef,
|
|
193
|
-
className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6",
|
|
199
|
+
className: "cpk:px-4 cpk:sm:px-0 cpk:[div[data-sidebar-chat]_&]:px-8 cpk:[div[data-popup-chat]_&]:px-6",
|
|
194
200
|
children
|
|
195
201
|
}),
|
|
196
202
|
BoundFeather,
|
|
197
203
|
showScrollButton && !isResizing && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
198
|
-
className: "absolute inset-x-0 flex justify-center z-30 pointer-events-none",
|
|
204
|
+
className: "cpk:absolute cpk:inset-x-0 cpk:flex cpk:justify-center cpk:z-30 cpk:pointer-events-none",
|
|
199
205
|
style: { bottom: `${inputContainerHeight + FEATHER_HEIGHT + 16}px` },
|
|
200
206
|
children: require_slots.renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, { onClick: () => scrollToBottom() })
|
|
201
207
|
})
|
|
@@ -203,7 +209,7 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
203
209
|
});
|
|
204
210
|
}
|
|
205
211
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(use_stick_to_bottom.StickToBottom, {
|
|
206
|
-
className: require_utils.cn("h-full max-h-full flex flex-col min-h-0 relative", className),
|
|
212
|
+
className: require_utils.cn("cpk:h-full cpk:max-h-full cpk:flex cpk:flex-col cpk:min-h-0 cpk:relative", className),
|
|
207
213
|
resize: "smooth",
|
|
208
214
|
initial: "smooth",
|
|
209
215
|
...props,
|
|
@@ -219,48 +225,52 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
219
225
|
_CopilotChatView.ScrollToBottomButton = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_button.Button, {
|
|
220
226
|
variant: "outline",
|
|
221
227
|
size: "sm",
|
|
222
|
-
className: (0, tailwind_merge.twMerge)("rounded-full w-10 h-10 p-0 pointer-events-auto", "bg-white dark:bg-gray-900", "shadow-lg border border-gray-200 dark:border-gray-700", "hover:bg-gray-50 dark:hover:bg-gray-800", "flex items-center justify-center cursor-pointer", className),
|
|
228
|
+
className: (0, tailwind_merge.twMerge)("cpk:rounded-full cpk:w-10 cpk:h-10 cpk:p-0 cpk:pointer-events-auto", "cpk:bg-white cpk:dark:bg-gray-900", "cpk:shadow-lg cpk:border cpk:border-gray-200 cpk:dark:border-gray-700", "cpk:hover:bg-gray-50 cpk:dark:hover:bg-gray-800", "cpk:flex cpk:items-center cpk:justify-center cpk:cursor-pointer", className),
|
|
223
229
|
...props,
|
|
224
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, { className: "w-4 h-4 text-gray-600 dark:text-white" })
|
|
230
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, { className: "cpk:w-4 cpk:h-4 cpk:text-gray-600 cpk:dark:text-white" })
|
|
225
231
|
});
|
|
226
232
|
_CopilotChatView.Feather = ({ className, style, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
227
|
-
className: require_utils.cn("absolute bottom-0 left-0 right-4 h-24 pointer-events-none z-10 bg-gradient-to-t", "from-white via-white to-transparent", "dark:from-[rgb(33,33,33)] dark:via-[rgb(33,33,33)]", className),
|
|
233
|
+
className: require_utils.cn("cpk:absolute cpk:bottom-0 cpk:left-0 cpk:right-4 cpk:h-24 cpk:pointer-events-none cpk:z-10 cpk:bg-gradient-to-t", "cpk:from-white cpk:via-white cpk:to-transparent", "cpk:dark:from-[rgb(33,33,33)] cpk:dark:via-[rgb(33,33,33)]", className),
|
|
228
234
|
style,
|
|
229
235
|
...props
|
|
230
236
|
});
|
|
231
237
|
_CopilotChatView.WelcomeMessage = ({ className, ...props }) => {
|
|
232
238
|
const labels = require_CopilotChatConfigurationProvider.useCopilotChatConfiguration()?.labels ?? require_CopilotChatConfigurationProvider.CopilotChatDefaultLabels;
|
|
233
239
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
|
|
234
|
-
className: require_utils.cn("text-xl sm:text-2xl font-medium text-foreground text-center", className),
|
|
240
|
+
className: require_utils.cn("cpk:text-xl cpk:sm:text-2xl cpk:font-medium cpk:text-foreground cpk:text-center", className),
|
|
235
241
|
...props,
|
|
236
242
|
children: labels.welcomeMessageText
|
|
237
243
|
});
|
|
238
244
|
};
|
|
239
245
|
_CopilotChatView.WelcomeScreen = ({ welcomeMessage, input, suggestionView, className, children, ...props }) => {
|
|
240
246
|
const BoundWelcomeMessage = require_slots.renderSlot(welcomeMessage, CopilotChatView.WelcomeMessage, {});
|
|
241
|
-
if (children) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
247
|
+
if (children) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
248
|
+
"data-copilotkit": true,
|
|
249
|
+
style: { display: "contents" },
|
|
250
|
+
children: children({
|
|
251
|
+
welcomeMessage: BoundWelcomeMessage,
|
|
252
|
+
input,
|
|
253
|
+
suggestionView,
|
|
254
|
+
className,
|
|
255
|
+
...props
|
|
256
|
+
})
|
|
257
|
+
});
|
|
248
258
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
249
|
-
className: require_utils.cn("flex-1 flex flex-col items-center justify-center px-4", className),
|
|
259
|
+
className: require_utils.cn("cpk:flex-1 cpk:flex cpk:flex-col cpk:items-center cpk:justify-center cpk:px-4", className),
|
|
250
260
|
...props,
|
|
251
261
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
252
|
-
className: "w-full max-w-3xl flex flex-col items-center",
|
|
262
|
+
className: "cpk:w-full cpk:max-w-3xl cpk:flex cpk:flex-col cpk:items-center",
|
|
253
263
|
children: [
|
|
254
264
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
255
|
-
className: "mb-6",
|
|
265
|
+
className: "cpk:mb-6",
|
|
256
266
|
children: BoundWelcomeMessage
|
|
257
267
|
}),
|
|
258
268
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
259
|
-
className: "w-full",
|
|
269
|
+
className: "cpk:w-full",
|
|
260
270
|
children: input
|
|
261
271
|
}),
|
|
262
272
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
263
|
-
className: "mt-4 flex justify-center",
|
|
273
|
+
className: "cpk:mt-4 cpk:flex cpk:justify-center",
|
|
264
274
|
children: suggestionView
|
|
265
275
|
})
|
|
266
276
|
]
|