@copilotkit/react-ui 0.15.0-alpha.1 → 0.15.0-alpha.2
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/.turbo/turbo-build.log +192 -288
- package/CHANGELOG.md +16 -1
- package/dist/{chunk-ZVAH2Z2W.mjs → chunk-3M4HWSE7.mjs} +3 -3
- package/dist/chunk-3M4HWSE7.mjs.map +1 -0
- package/dist/{chunk-Y2RUG4B3.mjs → chunk-5O2MCJZ2.mjs} +2 -2
- package/dist/chunk-5O2MCJZ2.mjs.map +1 -0
- package/dist/{chunk-X3Z2EVFV.mjs → chunk-CKJXXQ2W.mjs} +5 -5
- package/dist/chunk-CKJXXQ2W.mjs.map +1 -0
- package/dist/{chunk-NXWVWC33.mjs → chunk-DPRH4HX3.mjs} +11 -24
- package/dist/chunk-DPRH4HX3.mjs.map +1 -0
- package/dist/{chunk-UIRFLYXI.mjs → chunk-GWGHQNRI.mjs} +14 -13
- package/dist/chunk-GWGHQNRI.mjs.map +1 -0
- package/dist/chunk-JD7BAH7U.mjs +3 -0
- package/dist/{chunk-X4T6ZUVM.mjs → chunk-KBGIPFXA.mjs} +5 -5
- package/dist/chunk-KBGIPFXA.mjs.map +1 -0
- package/dist/{chunk-DN3OI5WF.mjs → chunk-NNVWLSYK.mjs} +9 -9
- package/dist/chunk-NNVWLSYK.mjs.map +1 -0
- package/dist/{chunk-QFASQEFJ.mjs → chunk-NYLOXKYT.mjs} +2 -2
- package/dist/chunk-NYLOXKYT.mjs.map +1 -0
- package/dist/{chunk-6H3Y2XEI.mjs → chunk-OF66AL5Z.mjs} +1 -1
- package/dist/chunk-OF66AL5Z.mjs.map +1 -0
- package/dist/{chunk-DPUPEOGG.mjs → chunk-UWPFPWAW.mjs} +2 -2
- package/dist/chunk-UWPFPWAW.mjs.map +1 -0
- package/dist/{chunk-GPEJCUWA.mjs → chunk-Z34F3WLK.mjs} +2 -2
- package/dist/chunk-Z34F3WLK.mjs.map +1 -0
- package/dist/components/chat/Button.d.ts +2 -3
- package/dist/components/chat/Button.js +38 -0
- package/dist/components/chat/Button.js.map +1 -0
- package/dist/components/chat/Button.mjs +2 -2
- package/dist/components/chat/Chat.d.ts +15 -14
- package/dist/components/chat/Chat.js +800 -0
- package/dist/components/chat/Chat.js.map +1 -0
- package/dist/components/chat/Chat.mjs +9 -9
- package/dist/components/chat/ChatContext.d.ts +21 -21
- package/dist/components/chat/ChatContext.js +220 -0
- package/dist/components/chat/ChatContext.js.map +1 -0
- package/dist/components/chat/ChatContext.mjs +1 -1
- package/dist/components/chat/CodeBlock.js +221 -0
- package/dist/components/chat/CodeBlock.js.map +1 -0
- package/dist/components/chat/CodeBlock.mjs +1 -1
- package/dist/components/chat/Header.d.ts +2 -3
- package/dist/components/chat/Header.js +31 -0
- package/dist/components/chat/Header.js.map +1 -0
- package/dist/components/chat/Header.mjs +2 -2
- package/dist/components/chat/Icons.d.ts +4 -4
- package/dist/components/chat/Icons.js +233 -0
- package/dist/components/chat/Icons.js.map +1 -0
- package/dist/components/chat/Input.d.ts +2 -3
- package/dist/components/chat/Input.js +111 -0
- package/dist/components/chat/Input.js.map +1 -0
- package/dist/components/chat/Input.mjs +2 -2
- package/dist/components/chat/Markdown.d.ts +1 -3
- package/dist/components/chat/Markdown.js +269 -0
- package/dist/components/chat/Markdown.js.map +1 -0
- package/dist/components/chat/Markdown.mjs +2 -2
- package/dist/components/chat/Messages.d.ts +2 -3
- package/dist/components/chat/Messages.js +331 -0
- package/dist/components/chat/Messages.js.map +1 -0
- package/dist/components/chat/Messages.mjs +4 -4
- package/dist/components/chat/Popup.d.ts +5 -4
- package/dist/components/chat/Popup.js +806 -0
- package/dist/components/chat/Popup.js.map +1 -0
- package/dist/components/chat/Popup.mjs +10 -10
- package/dist/components/chat/Response.d.ts +2 -3
- package/dist/components/chat/Response.js +31 -0
- package/dist/components/chat/Response.js.map +1 -0
- package/dist/components/chat/Response.mjs +2 -2
- package/dist/components/chat/Sidebar.d.ts +7 -6
- package/dist/components/chat/Sidebar.js +817 -0
- package/dist/components/chat/Sidebar.js.map +1 -0
- package/dist/components/chat/Sidebar.mjs +10 -10
- package/dist/components/chat/Textarea.d.ts +4 -4
- package/dist/components/chat/Textarea.js +55 -0
- package/dist/components/chat/Textarea.js.map +1 -0
- package/dist/components/chat/Window.d.ts +1 -1
- package/dist/components/chat/Window.js +116 -0
- package/dist/components/chat/Window.js.map +1 -0
- package/dist/components/chat/index.d.ts +5 -4
- package/dist/components/chat/index.js +824 -0
- package/dist/components/chat/index.js.map +1 -0
- package/dist/components/chat/index.mjs +11 -11
- package/dist/components/chat/props.d.ts +1 -1
- package/dist/components/chat/props.js +4 -0
- package/dist/components/index.d.ts +5 -11
- package/dist/components/index.js +824 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +12 -33
- package/dist/context/index.js +4 -0
- package/dist/hooks/index.js +4 -0
- package/dist/hooks/use-copy-to-clipboard.js +47 -0
- package/dist/hooks/use-copy-to-clipboard.js.map +1 -0
- package/dist/index.css +112 -916
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +5 -11
- package/dist/index.js +824 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +13 -34
- package/dist/lib/utils.js +64 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/utils.mjs +38 -2
- package/dist/lib/utils.mjs.map +1 -1
- package/dist/lib/utils.test.js +10 -0
- package/dist/lib/utils.test.js.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/types.d.ts +1 -1
- package/dist/types/types.js +4 -0
- package/package.json +8 -7
- package/src/components/chat/Button.tsx +1 -2
- package/src/components/chat/Chat.tsx +7 -7
- package/src/components/chat/ChatContext.tsx +10 -10
- package/src/components/chat/CodeBlock.tsx +12 -36
- package/src/components/chat/Header.tsx +1 -2
- package/src/components/chat/Input.tsx +1 -1
- package/src/components/chat/Markdown.tsx +17 -11
- package/src/components/chat/Messages.tsx +2 -2
- package/src/components/chat/Popup.tsx +3 -4
- package/src/components/chat/Response.tsx +1 -2
- package/src/components/chat/Sidebar.tsx +4 -4
- package/src/components/chat/index.tsx +2 -2
- package/src/components/chat/props.ts +1 -1
- package/src/components/index.ts +0 -8
- package/src/css/animations.css +6 -0
- package/src/css/markdown.css +123 -0
- package/src/styles.css +1 -0
- package/src/types/types.ts +1 -1
- package/tsup.config.ts +1 -2
- package/dist/chunk-2KAF7NKC.mjs +0 -484
- package/dist/chunk-2KAF7NKC.mjs.map +0 -1
- package/dist/chunk-5KEDV5VC.mjs +0 -27
- package/dist/chunk-5KEDV5VC.mjs.map +0 -1
- package/dist/chunk-6H3Y2XEI.mjs.map +0 -1
- package/dist/chunk-6LAZQHEB.mjs +0 -129
- package/dist/chunk-6LAZQHEB.mjs.map +0 -1
- package/dist/chunk-C34L4AWW.mjs +0 -39
- package/dist/chunk-C34L4AWW.mjs.map +0 -1
- package/dist/chunk-CF3BK4OX.mjs +0 -53
- package/dist/chunk-CF3BK4OX.mjs.map +0 -1
- package/dist/chunk-CNQX2VY3.mjs +0 -66
- package/dist/chunk-CNQX2VY3.mjs.map +0 -1
- package/dist/chunk-DN3OI5WF.mjs.map +0 -1
- package/dist/chunk-DPUPEOGG.mjs.map +0 -1
- package/dist/chunk-FZRTAML3.mjs +0 -3
- package/dist/chunk-GCOPYGHH.mjs +0 -27
- package/dist/chunk-GCOPYGHH.mjs.map +0 -1
- package/dist/chunk-GPEJCUWA.mjs.map +0 -1
- package/dist/chunk-IJLMKBSZ.mjs +0 -25
- package/dist/chunk-IJLMKBSZ.mjs.map +0 -1
- package/dist/chunk-INCNMGJ7.mjs +0 -72
- package/dist/chunk-INCNMGJ7.mjs.map +0 -1
- package/dist/chunk-M3CZWJI3.mjs +0 -44
- package/dist/chunk-M3CZWJI3.mjs.map +0 -1
- package/dist/chunk-MC6KTH4X.mjs +0 -12
- package/dist/chunk-MC6KTH4X.mjs.map +0 -1
- package/dist/chunk-NXWVWC33.mjs.map +0 -1
- package/dist/chunk-OHWEJUCS.mjs +0 -18
- package/dist/chunk-OHWEJUCS.mjs.map +0 -1
- package/dist/chunk-OOBQC5H6.mjs +0 -34
- package/dist/chunk-OOBQC5H6.mjs.map +0 -1
- package/dist/chunk-Q6YO7LDK.mjs +0 -40
- package/dist/chunk-Q6YO7LDK.mjs.map +0 -1
- package/dist/chunk-QFASQEFJ.mjs.map +0 -1
- package/dist/chunk-RPTRCFSO.mjs +0 -42
- package/dist/chunk-RPTRCFSO.mjs.map +0 -1
- package/dist/chunk-SEH5PQVW.mjs +0 -52
- package/dist/chunk-SEH5PQVW.mjs.map +0 -1
- package/dist/chunk-SHOTWRKC.mjs +0 -18
- package/dist/chunk-SHOTWRKC.mjs.map +0 -1
- package/dist/chunk-SRBUGQTM.mjs +0 -109
- package/dist/chunk-SRBUGQTM.mjs.map +0 -1
- package/dist/chunk-TEYIQHMK.mjs +0 -12
- package/dist/chunk-TEYIQHMK.mjs.map +0 -1
- package/dist/chunk-UIRFLYXI.mjs.map +0 -1
- package/dist/chunk-VGX2W5ZB.mjs +0 -28
- package/dist/chunk-VGX2W5ZB.mjs.map +0 -1
- package/dist/chunk-X3Z2EVFV.mjs.map +0 -1
- package/dist/chunk-X4T6ZUVM.mjs.map +0 -1
- package/dist/chunk-XGUBRIUV.mjs +0 -72
- package/dist/chunk-XGUBRIUV.mjs.map +0 -1
- package/dist/chunk-Y2RUG4B3.mjs.map +0 -1
- package/dist/chunk-ZVAH2Z2W.mjs.map +0 -1
- package/dist/chunk-ZYC5YVDO.mjs +0 -21
- package/dist/chunk-ZYC5YVDO.mjs.map +0 -1
- package/dist/components/chat-components/chat-list.d.ts +0 -8
- package/dist/components/chat-components/chat-list.mjs +0 -13
- package/dist/components/chat-components/chat-message-actions.d.ts +0 -8
- package/dist/components/chat-components/chat-message-actions.mjs +0 -8
- package/dist/components/chat-components/chat-message.d.ts +0 -8
- package/dist/components/chat-components/chat-message.mjs +0 -11
- package/dist/components/chat-components/chat-panel.d.ts +0 -8
- package/dist/components/chat-components/chat-panel.mjs +0 -10
- package/dist/components/chat-components/chat-scroll-anchor.d.ts +0 -6
- package/dist/components/chat-components/chat-scroll-anchor.mjs +0 -5
- package/dist/components/chat-components/clear-history.d.ts +0 -9
- package/dist/components/chat-components/clear-history.mjs +0 -56
- package/dist/components/chat-components/clear-history.mjs.map +0 -1
- package/dist/components/chat-components/copilot-chat.d.ts +0 -12
- package/dist/components/chat-components/copilot-chat.mjs +0 -22
- package/dist/components/chat-components/copilot-chat.mjs.map +0 -1
- package/dist/components/chat-components/default-empty-screen.d.ts +0 -8
- package/dist/components/chat-components/default-empty-screen.mjs +0 -8
- package/dist/components/chat-components/default-empty-screen.mjs.map +0 -1
- package/dist/components/chat-components/external-link.d.ts +0 -6
- package/dist/components/chat-components/external-link.mjs +0 -4
- package/dist/components/chat-components/external-link.mjs.map +0 -1
- package/dist/components/chat-components/markdown.d.ts +0 -6
- package/dist/components/chat-components/markdown.mjs +0 -4
- package/dist/components/chat-components/markdown.mjs.map +0 -1
- package/dist/components/chat-components/prompt-form.d.ts +0 -9
- package/dist/components/chat-components/prompt-form.mjs +0 -9
- package/dist/components/chat-components/prompt-form.mjs.map +0 -1
- package/dist/components/chat-components/theme-toggle.d.ts +0 -3
- package/dist/components/chat-components/theme-toggle.mjs +0 -32
- package/dist/components/chat-components/theme-toggle.mjs.map +0 -1
- package/dist/components/chat-components/toaster.d.ts +0 -1
- package/dist/components/chat-components/toaster.mjs +0 -4
- package/dist/components/chat-components/toaster.mjs.map +0 -1
- package/dist/components/chat-components/ui/alert-dialog.d.ts +0 -20
- package/dist/components/chat-components/ui/alert-dialog.mjs +0 -6
- package/dist/components/chat-components/ui/alert-dialog.mjs.map +0 -1
- package/dist/components/chat-components/ui/badge.d.ts +0 -12
- package/dist/components/chat-components/ui/badge.mjs +0 -29
- package/dist/components/chat-components/ui/badge.mjs.map +0 -1
- package/dist/components/chat-components/ui/button.d.ts +0 -14
- package/dist/components/chat-components/ui/button.mjs +0 -5
- package/dist/components/chat-components/ui/button.mjs.map +0 -1
- package/dist/components/chat-components/ui/codeblock.d.ts +0 -14
- package/dist/components/chat-components/ui/codeblock.mjs +0 -8
- package/dist/components/chat-components/ui/codeblock.mjs.map +0 -1
- package/dist/components/chat-components/ui/dialog.d.ts +0 -18
- package/dist/components/chat-components/ui/dialog.mjs +0 -94
- package/dist/components/chat-components/ui/dialog.mjs.map +0 -1
- package/dist/components/chat-components/ui/dropdown-menu.d.ts +0 -24
- package/dist/components/chat-components/ui/dropdown-menu.mjs +0 -87
- package/dist/components/chat-components/ui/dropdown-menu.mjs.map +0 -1
- package/dist/components/chat-components/ui/icons.d.ts +0 -33
- package/dist/components/chat-components/ui/icons.mjs +0 -5
- package/dist/components/chat-components/ui/icons.mjs.map +0 -1
- package/dist/components/chat-components/ui/input.d.ts +0 -7
- package/dist/components/chat-components/ui/input.mjs +0 -26
- package/dist/components/chat-components/ui/input.mjs.map +0 -1
- package/dist/components/chat-components/ui/label.d.ts +0 -8
- package/dist/components/chat-components/ui/label.mjs +0 -19
- package/dist/components/chat-components/ui/label.mjs.map +0 -1
- package/dist/components/chat-components/ui/select.d.ts +0 -13
- package/dist/components/chat-components/ui/select.mjs +0 -101
- package/dist/components/chat-components/ui/select.mjs.map +0 -1
- package/dist/components/chat-components/ui/separator.d.ts +0 -6
- package/dist/components/chat-components/ui/separator.mjs +0 -5
- package/dist/components/chat-components/ui/separator.mjs.map +0 -1
- package/dist/components/chat-components/ui/sheet.d.ts +0 -19
- package/dist/components/chat-components/ui/sheet.mjs +0 -93
- package/dist/components/chat-components/ui/sheet.mjs.map +0 -1
- package/dist/components/chat-components/ui/switch.d.ts +0 -6
- package/dist/components/chat-components/ui/switch.mjs +0 -33
- package/dist/components/chat-components/ui/switch.mjs.map +0 -1
- package/dist/components/chat-components/ui/textarea.d.ts +0 -7
- package/dist/components/chat-components/ui/textarea.mjs +0 -25
- package/dist/components/chat-components/ui/textarea.mjs.map +0 -1
- package/dist/components/chat-components/ui/tooltip.d.ts +0 -9
- package/dist/components/chat-components/ui/tooltip.mjs +0 -5
- package/dist/components/chat-components/ui/tooltip.mjs.map +0 -1
- package/dist/components/sidebar/copilot-sidebar-ui-provider.d.ts +0 -8
- package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs +0 -25
- package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs.map +0 -1
- package/dist/components/sidebar/copilot-sidebar.d.ts +0 -6
- package/dist/components/sidebar/copilot-sidebar.mjs +0 -23
- package/dist/components/sidebar/copilot-sidebar.mjs.map +0 -1
- package/dist/components/sidebar/sidebar-context.d.ts +0 -9
- package/dist/components/sidebar/sidebar-context.mjs +0 -4
- package/dist/components/sidebar/sidebar-context.mjs.map +0 -1
- package/dist/hooks/use-at-bottom.d.ts +0 -3
- package/dist/hooks/use-at-bottom.mjs +0 -4
- package/dist/hooks/use-at-bottom.mjs.map +0 -1
- package/dist/hooks/use-enter-submit.d.ts +0 -8
- package/dist/hooks/use-enter-submit.mjs +0 -4
- package/dist/hooks/use-enter-submit.mjs.map +0 -1
- package/src/components/chat-components/chat-list.tsx +0 -28
- package/src/components/chat-components/chat-message-actions.tsx +0 -36
- package/src/components/chat-components/chat-message.tsx +0 -70
- package/src/components/chat-components/chat-panel.tsx +0 -64
- package/src/components/chat-components/chat-scroll-anchor.tsx +0 -29
- package/src/components/chat-components/clear-history.tsx +0 -72
- package/src/components/chat-components/copilot-chat.tsx +0 -57
- package/src/components/chat-components/default-empty-screen.tsx +0 -57
- package/src/components/chat-components/external-link.tsx +0 -17
- package/src/components/chat-components/markdown.tsx +0 -8
- package/src/components/chat-components/prompt-form.tsx +0 -85
- package/src/components/chat-components/theme-toggle.tsx +0 -31
- package/src/components/chat-components/toaster.tsx +0 -3
- package/src/components/chat-components/ui/alert-dialog.tsx +0 -126
- package/src/components/chat-components/ui/badge.tsx +0 -33
- package/src/components/chat-components/ui/button.tsx +0 -49
- package/src/components/chat-components/ui/codeblock.tsx +0 -137
- package/src/components/chat-components/ui/dialog.tsx +0 -106
- package/src/components/chat-components/ui/dropdown-menu.tsx +0 -117
- package/src/components/chat-components/ui/icons.tsx +0 -484
- package/src/components/chat-components/ui/input.tsx +0 -24
- package/src/components/chat-components/ui/label.tsx +0 -21
- package/src/components/chat-components/ui/select.tsx +0 -119
- package/src/components/chat-components/ui/separator.tsx +0 -26
- package/src/components/chat-components/ui/sheet.tsx +0 -106
- package/src/components/chat-components/ui/switch.tsx +0 -29
- package/src/components/chat-components/ui/textarea.tsx +0 -23
- package/src/components/chat-components/ui/tooltip.tsx +0 -30
- package/src/components/sidebar/copilot-sidebar-ui-provider.tsx +0 -73
- package/src/components/sidebar/copilot-sidebar.tsx +0 -38
- package/src/components/sidebar/sidebar-context.tsx +0 -11
- package/src/hooks/use-at-bottom.tsx +0 -20
- package/src/hooks/use-enter-submit.tsx +0 -17
- /package/dist/{chunk-FZRTAML3.mjs.map → chunk-JD7BAH7U.mjs.map} +0 -0
- /package/dist/components/{chat-components/chat-list.mjs.map → chat/props.js.map} +0 -0
- /package/dist/{components/chat-components/chat-message-actions.mjs.map → context/index.js.map} +0 -0
- /package/dist/{components/chat-components/chat-message.mjs.map → hooks/index.js.map} +0 -0
- /package/dist/{components/chat-components/chat-panel.mjs.map → types/index.js.map} +0 -0
- /package/dist/{components/chat-components/chat-scroll-anchor.mjs.map → types/types.js.map} +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
9
|
+
|
|
10
|
+
// src/components/chat/Input.tsx
|
|
11
|
+
var ChatContext = React__default.default.createContext(void 0);
|
|
12
|
+
function useChatContext() {
|
|
13
|
+
const context = React__default.default.useContext(ChatContext);
|
|
14
|
+
if (context === void 0) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
"Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?"
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
return context;
|
|
20
|
+
}
|
|
21
|
+
var AutoResizingTextarea = React.forwardRef(
|
|
22
|
+
({ maxRows = 1, placeholder, value, onChange, onKeyDown, autoFocus }, ref) => {
|
|
23
|
+
const internalTextareaRef = React.useRef(null);
|
|
24
|
+
const [maxHeight, setMaxHeight] = React.useState(0);
|
|
25
|
+
React.useImperativeHandle(ref, () => internalTextareaRef.current);
|
|
26
|
+
React.useEffect(() => {
|
|
27
|
+
const calculateMaxHeight = () => {
|
|
28
|
+
const textarea = internalTextareaRef.current;
|
|
29
|
+
if (textarea) {
|
|
30
|
+
textarea.style.height = "auto";
|
|
31
|
+
const singleRowHeight = textarea.scrollHeight;
|
|
32
|
+
setMaxHeight(singleRowHeight * maxRows);
|
|
33
|
+
if (autoFocus) {
|
|
34
|
+
textarea.focus();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
calculateMaxHeight();
|
|
39
|
+
}, [maxRows]);
|
|
40
|
+
React.useEffect(() => {
|
|
41
|
+
const textarea = internalTextareaRef.current;
|
|
42
|
+
if (textarea) {
|
|
43
|
+
textarea.style.height = "auto";
|
|
44
|
+
textarea.style.height = `${Math.min(textarea.scrollHeight, maxHeight)}px`;
|
|
45
|
+
}
|
|
46
|
+
}, [value, maxHeight]);
|
|
47
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
48
|
+
"textarea",
|
|
49
|
+
{
|
|
50
|
+
ref: internalTextareaRef,
|
|
51
|
+
value,
|
|
52
|
+
onChange,
|
|
53
|
+
onKeyDown,
|
|
54
|
+
placeholder,
|
|
55
|
+
style: {
|
|
56
|
+
overflow: "hidden",
|
|
57
|
+
resize: "none",
|
|
58
|
+
maxHeight: `${maxHeight}px`
|
|
59
|
+
},
|
|
60
|
+
rows: 1
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
var Textarea_default = AutoResizingTextarea;
|
|
66
|
+
var Input = ({ inProgress, onSend, children }) => {
|
|
67
|
+
const context = useChatContext();
|
|
68
|
+
const textareaRef = React.useRef(null);
|
|
69
|
+
const handleDivClick = (event) => {
|
|
70
|
+
var _a;
|
|
71
|
+
if (event.target !== event.currentTarget)
|
|
72
|
+
return;
|
|
73
|
+
(_a = textareaRef.current) == null ? void 0 : _a.focus();
|
|
74
|
+
};
|
|
75
|
+
const [text, setText] = React.useState("");
|
|
76
|
+
const send = () => {
|
|
77
|
+
var _a;
|
|
78
|
+
if (inProgress)
|
|
79
|
+
return;
|
|
80
|
+
onSend(text);
|
|
81
|
+
setText("");
|
|
82
|
+
(_a = textareaRef.current) == null ? void 0 : _a.focus();
|
|
83
|
+
};
|
|
84
|
+
const icon = inProgress ? context.icons.activityIcon : context.icons.sendIcon;
|
|
85
|
+
const disabled = inProgress || text.length === 0;
|
|
86
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
|
|
87
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children }),
|
|
88
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { className: "copilotKitSendButton", disabled, onClick: send, children: icon }),
|
|
89
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
90
|
+
Textarea_default,
|
|
91
|
+
{
|
|
92
|
+
ref: textareaRef,
|
|
93
|
+
placeholder: context.labels.placeholder,
|
|
94
|
+
autoFocus: true,
|
|
95
|
+
maxRows: 5,
|
|
96
|
+
value: text,
|
|
97
|
+
onChange: (event) => setText(event.target.value),
|
|
98
|
+
onKeyDown: (event) => {
|
|
99
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
100
|
+
event.preventDefault();
|
|
101
|
+
send();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
] });
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
exports.Input = Input;
|
|
110
|
+
//# sourceMappingURL=out.js.map
|
|
111
|
+
//# sourceMappingURL=Input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/chat/Input.tsx","../../../src/components/chat/ChatContext.tsx","../../../src/components/chat/Textarea.tsx"],"names":["useRef","useState","jsx"],"mappings":";AAAA,SAAgB,UAAAA,SAAQ,YAAAC,iBAAgB;;;ACAxC,OAAO,SAAS,eAAe;AA8KtB;AA7DF,IAAM,cAAc,MAAM,cAAuC,MAAS;AAE1E,SAAS,iBAA8B;AAC5C,QAAM,UAAU,MAAM,WAAW,WAAW;AAC5C,MAAI,YAAY,QAAW;AACzB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;;;AC3HA,SAAgB,UAAU,QAAQ,WAAW,YAAY,2BAA2B;AA2C9E,gBAAAC,YAAA;AAhCN,IAAM,uBAAuB;AAAA,EAC3B,CAAC,EAAE,UAAU,GAAG,aAAa,OAAO,UAAU,WAAW,UAAU,GAAG,QAAQ;AAC5E,UAAM,sBAAsB,OAA4B,IAAI;AAC5D,UAAM,CAAC,WAAW,YAAY,IAAI,SAAiB,CAAC;AAEpD,wBAAoB,KAAK,MAAM,oBAAoB,OAA8B;AAEjF,cAAU,MAAM;AACd,YAAM,qBAAqB,MAAM;AAC/B,cAAM,WAAW,oBAAoB;AACrC,YAAI,UAAU;AACZ,mBAAS,MAAM,SAAS;AACxB,gBAAM,kBAAkB,SAAS;AACjC,uBAAa,kBAAkB,OAAO;AACtC,cAAI,WAAW;AACb,qBAAS,MAAM;AAAA,UACjB;AAAA,QACF;AAAA,MACF;AAEA,yBAAmB;AAAA,IACrB,GAAG,CAAC,OAAO,CAAC;AAEZ,cAAU,MAAM;AACd,YAAM,WAAW,oBAAoB;AACrC,UAAI,UAAU;AACZ,iBAAS,MAAM,SAAS;AACxB,iBAAS,MAAM,SAAS,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,QAC/C,WAAW,CAAC,UAAU;AACpB,cAAI,MAAM,QAAQ,WAAW,CAAC,MAAM,UAAU;AAC5C,kBAAM,eAAe;AACrB,iBAAK;AAAA,UACP;AAAA,QACF;AAAA;AAAA,IACF;AAAA,KACF;AAEJ","sourcesContent":["import React, { useRef, useState } from \"react\";\nimport { InputProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\nimport AutoResizingTextarea from \"./Textarea\";\n\nexport const Input = ({ inProgress, onSend, children }: InputProps) => {\n const context = useChatContext();\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n const handleDivClick = (event: React.MouseEvent<HTMLDivElement>) => {\n // Check if the clicked element is not the textarea itself\n if (event.target !== event.currentTarget) return;\n\n textareaRef.current?.focus();\n };\n\n const [text, setText] = useState(\"\");\n const send = () => {\n if (inProgress) return;\n onSend(text);\n setText(\"\");\n\n textareaRef.current?.focus();\n };\n\n const icon = inProgress ? context.icons.activityIcon : context.icons.sendIcon;\n const disabled = inProgress || text.length === 0;\n\n return (\n <div className=\"copilotKitInput\" onClick={handleDivClick}>\n <span>{children}</span>\n <button className=\"copilotKitSendButton\" disabled={disabled} onClick={send}>\n {icon}\n </button>\n <AutoResizingTextarea\n ref={textareaRef}\n placeholder={context.labels.placeholder}\n autoFocus={true}\n maxRows={5}\n value={text}\n onChange={(event) => setText(event.target.value)}\n onKeyDown={(event) => {\n if (event.key === \"Enter\" && !event.shiftKey) {\n event.preventDefault();\n send();\n }\n }}\n />\n </div>\n );\n};\n","import React, { useMemo } from \"react\";\nimport * as DefaultIcons from \"./Icons\";\n\n/**\n * Icons for CopilotChat component.\n */\nexport interface CopilotChatIcons {\n /**\n * The icon to use for the open chat button.\n * @default <OpenIcon />\n */\n openIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button.\n * @default <CloseIcon />\n */\n closeIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button in the header.\n * @default <HeaderCloseIcon />\n */\n headerCloseIcon?: React.ReactNode;\n\n /**\n * The icon to use for the send button.\n * @default <SendIcon />\n */\n sendIcon?: React.ReactNode;\n\n /**\n * The icon to use for the activity indicator.\n * @default <ActivityIcon />\n */\n activityIcon?: React.ReactNode;\n\n /**\n * The icon to use for the spinner.\n * @default <SpinnerIcon />\n */\n spinnerIcon?: React.ReactNode;\n\n /**\n * The icon to use for the stop button.\n * @default <StopIcon />\n */\n stopIcon?: React.ReactNode;\n\n /**\n * The icon to use for the regenerate button.\n * @default <RegenerateIcon />\n */\n regenerateIcon?: React.ReactNode;\n}\n\n/**\n * Labels for CopilotChat component.\n */\nexport interface CopilotChatLabels {\n /**\n * The initial message(s) to display in the chat window.\n */\n initial?: string | string[];\n\n /**\n * The title to display in the header.\n * @default \"CopilotKit\"\n */\n title?: string;\n\n /**\n * The placeholder to display in the input.\n * @default \"Type a message...\"\n */\n placeholder?: string;\n\n /**\n * The message to display while the chat GPT is \"thinking\".\n * @default \"Thinking...\"\n */\n thinking?: string;\n\n /**\n * The message to display when the chat is done executing a function.\n * @default \"✅ Done\"\n */\n done?: string;\n\n /**\n * The message to display when an error occurs.\n * @default \"❌ An error occurred. Please try again.\"\n */\n error?: string;\n\n /**\n * The label to display on the stop button.\n * @default \"Stop generating\"\n */\n stopGenerating?: string;\n\n /**\n * The label to display on the regenerate button.\n * @default \"Regenerate response\"\n */\n regenerateResponse?: string;\n}\n\ninterface ChatContext {\n labels: Required<CopilotChatLabels>;\n icons: Required<CopilotChatIcons>;\n}\n\nexport const ChatContext = React.createContext<ChatContext | undefined>(undefined);\n\nexport function useChatContext(): ChatContext {\n const context = React.useContext(ChatContext);\n if (context === undefined) {\n throw new Error(\n \"Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?\",\n );\n }\n return context;\n}\n\ninterface ChatContextProps {\n // temperature?: number;\n // instructions?: string;\n // maxFeedback?: number;\n labels?: CopilotChatLabels;\n icons?: CopilotChatIcons;\n children?: React.ReactNode;\n}\n\nexport const ChatContextProvider = ({\n // temperature,\n // instructions,\n // maxFeedback,\n labels,\n icons,\n children,\n}: ChatContextProps) => {\n const context = useMemo(\n () => ({\n labels: {\n ...{\n initial: \"\",\n title: \"CopilotKit\",\n placeholder: \"Type a message...\",\n thinking: \"Thinking...\",\n done: \"✅ Done\",\n error: \"❌ An error occurred. Please try again.\",\n stopGenerating: \"Stop generating\",\n regenerateResponse: \"Regenerate response\",\n },\n ...labels,\n },\n\n icons: {\n ...{\n openIcon: DefaultIcons.OpenIcon,\n closeIcon: DefaultIcons.CloseIcon,\n headerCloseIcon: DefaultIcons.HeaderCloseIcon,\n sendIcon: DefaultIcons.SendIcon,\n activityIcon: DefaultIcons.ActivityIcon,\n spinnerIcon: DefaultIcons.SpinnerIcon,\n stopIcon: DefaultIcons.StopIcon,\n regenerateIcon: DefaultIcons.RegenerateIcon,\n },\n icons,\n },\n }),\n [labels, icons],\n );\n return <ChatContext.Provider value={context}>{children}</ChatContext.Provider>;\n};\n","import React, { useState, useRef, useEffect, forwardRef, useImperativeHandle } from \"react\";\n\ninterface AutoResizingTextareaProps {\n maxRows?: number;\n placeholder?: string;\n value: string;\n onChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;\n onKeyDown?: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;\n autoFocus?: boolean;\n}\n\nconst AutoResizingTextarea = forwardRef<HTMLTextAreaElement, AutoResizingTextareaProps>(\n ({ maxRows = 1, placeholder, value, onChange, onKeyDown, autoFocus }, ref) => {\n const internalTextareaRef = useRef<HTMLTextAreaElement>(null);\n const [maxHeight, setMaxHeight] = useState<number>(0);\n\n useImperativeHandle(ref, () => internalTextareaRef.current as HTMLTextAreaElement);\n\n useEffect(() => {\n const calculateMaxHeight = () => {\n const textarea = internalTextareaRef.current;\n if (textarea) {\n textarea.style.height = \"auto\";\n const singleRowHeight = textarea.scrollHeight;\n setMaxHeight(singleRowHeight * maxRows);\n if (autoFocus) {\n textarea.focus();\n }\n }\n };\n\n calculateMaxHeight();\n }, [maxRows]);\n\n useEffect(() => {\n const textarea = internalTextareaRef.current;\n if (textarea) {\n textarea.style.height = \"auto\";\n textarea.style.height = `${Math.min(textarea.scrollHeight, maxHeight)}px`;\n }\n }, [value, maxHeight]);\n\n return (\n <textarea\n ref={internalTextareaRef}\n value={value}\n onChange={onChange}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n style={{\n overflow: \"hidden\",\n resize: \"none\",\n maxHeight: `${maxHeight}px`,\n }}\n rows={1}\n />\n );\n },\n);\n\nexport default AutoResizingTextarea;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { Input } from '../../chunk-
|
|
1
|
+
export { Input } from '../../chunk-NYLOXKYT.mjs';
|
|
2
2
|
import '../../chunk-WM6BS77F.mjs';
|
|
3
|
-
import '../../chunk-
|
|
3
|
+
import '../../chunk-OF66AL5Z.mjs';
|
|
4
4
|
import '../../chunk-7YXG7D47.mjs';
|
|
5
5
|
import '../../chunk-MRXNTQOX.mjs';
|
|
6
6
|
//# sourceMappingURL=out.js.map
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var ReactMarkdown = require('react-markdown');
|
|
5
|
+
var reactSyntaxHighlighter = require('react-syntax-highlighter');
|
|
6
|
+
var prism = require('react-syntax-highlighter/dist/esm/styles/prism');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
var remarkGfm = require('remark-gfm');
|
|
9
|
+
var remarkMath = require('remark-math');
|
|
10
|
+
|
|
11
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
|
|
13
|
+
function _interopNamespace(e) {
|
|
14
|
+
if (e && e.__esModule) return e;
|
|
15
|
+
var n = Object.create(null);
|
|
16
|
+
if (e) {
|
|
17
|
+
Object.keys(e).forEach(function (k) {
|
|
18
|
+
if (k !== 'default') {
|
|
19
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
20
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return e[k]; }
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
n.default = e;
|
|
28
|
+
return Object.freeze(n);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
32
|
+
var ReactMarkdown__default = /*#__PURE__*/_interopDefault(ReactMarkdown);
|
|
33
|
+
var remarkGfm__default = /*#__PURE__*/_interopDefault(remarkGfm);
|
|
34
|
+
var remarkMath__default = /*#__PURE__*/_interopDefault(remarkMath);
|
|
35
|
+
|
|
36
|
+
var __defProp = Object.defineProperty;
|
|
37
|
+
var __defProps = Object.defineProperties;
|
|
38
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
39
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
40
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
41
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
42
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
43
|
+
var __spreadValues = (a, b) => {
|
|
44
|
+
for (var prop in b || (b = {}))
|
|
45
|
+
if (__hasOwnProp.call(b, prop))
|
|
46
|
+
__defNormalProp(a, prop, b[prop]);
|
|
47
|
+
if (__getOwnPropSymbols)
|
|
48
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
49
|
+
if (__propIsEnum.call(b, prop))
|
|
50
|
+
__defNormalProp(a, prop, b[prop]);
|
|
51
|
+
}
|
|
52
|
+
return a;
|
|
53
|
+
};
|
|
54
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
55
|
+
var __objRest = (source, exclude) => {
|
|
56
|
+
var target = {};
|
|
57
|
+
for (var prop in source)
|
|
58
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
59
|
+
target[prop] = source[prop];
|
|
60
|
+
if (source != null && __getOwnPropSymbols)
|
|
61
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
62
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
63
|
+
target[prop] = source[prop];
|
|
64
|
+
}
|
|
65
|
+
return target;
|
|
66
|
+
};
|
|
67
|
+
function useCopyToClipboard({ timeout = 2e3 }) {
|
|
68
|
+
const [isCopied, setIsCopied] = React__namespace.useState(false);
|
|
69
|
+
const copyToClipboard = (value) => {
|
|
70
|
+
var _a;
|
|
71
|
+
if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (!value) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
navigator.clipboard.writeText(value).then(() => {
|
|
78
|
+
setIsCopied(true);
|
|
79
|
+
setTimeout(() => {
|
|
80
|
+
setIsCopied(false);
|
|
81
|
+
}, timeout);
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
return { isCopied, copyToClipboard };
|
|
85
|
+
}
|
|
86
|
+
function CheckIcon(_a) {
|
|
87
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
88
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
89
|
+
"svg",
|
|
90
|
+
__spreadProps(__spreadValues({
|
|
91
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
92
|
+
viewBox: "0 0 256 256",
|
|
93
|
+
fill: "currentColor",
|
|
94
|
+
style: { height: "1rem", width: "1rem" },
|
|
95
|
+
className
|
|
96
|
+
}, props), {
|
|
97
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m229.66 77.66-128 128a8 8 0 0 1-11.32 0l-56-56a8 8 0 0 1 11.32-11.32L96 188.69 218.34 66.34a8 8 0 0 1 11.32 11.32Z" })
|
|
98
|
+
})
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
function DownloadIcon(_a) {
|
|
102
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
103
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
104
|
+
"svg",
|
|
105
|
+
__spreadProps(__spreadValues({
|
|
106
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
107
|
+
viewBox: "0 0 256 256",
|
|
108
|
+
fill: "currentColor",
|
|
109
|
+
style: { height: "1rem", width: "1rem" },
|
|
110
|
+
className
|
|
111
|
+
}, props), {
|
|
112
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M224 152v56a16 16 0 0 1-16 16H48a16 16 0 0 1-16-16v-56a8 8 0 0 1 16 0v56h160v-56a8 8 0 0 1 16 0Zm-101.66 5.66a8 8 0 0 0 11.32 0l40-40a8 8 0 0 0-11.32-11.32L136 132.69V40a8 8 0 0 0-16 0v92.69l-26.34-26.35a8 8 0 0 0-11.32 11.32Z" })
|
|
113
|
+
})
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
function CopyIcon(_a) {
|
|
117
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
118
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
119
|
+
"svg",
|
|
120
|
+
__spreadProps(__spreadValues({
|
|
121
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
122
|
+
viewBox: "0 0 256 256",
|
|
123
|
+
fill: "currentColor",
|
|
124
|
+
style: { height: "1rem", width: "1rem" },
|
|
125
|
+
className
|
|
126
|
+
}, props), {
|
|
127
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M216 32H88a8 8 0 0 0-8 8v40H40a8 8 0 0 0-8 8v128a8 8 0 0 0 8 8h128a8 8 0 0 0 8-8v-40h40a8 8 0 0 0 8-8V40a8 8 0 0 0-8-8Zm-56 176H48V96h112Zm48-48h-32V88a8 8 0 0 0-8-8H96V48h112Z" })
|
|
128
|
+
})
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
var programmingLanguages = {
|
|
132
|
+
javascript: ".js",
|
|
133
|
+
python: ".py",
|
|
134
|
+
java: ".java",
|
|
135
|
+
c: ".c",
|
|
136
|
+
cpp: ".cpp",
|
|
137
|
+
"c++": ".cpp",
|
|
138
|
+
"c#": ".cs",
|
|
139
|
+
ruby: ".rb",
|
|
140
|
+
php: ".php",
|
|
141
|
+
swift: ".swift",
|
|
142
|
+
"objective-c": ".m",
|
|
143
|
+
kotlin: ".kt",
|
|
144
|
+
typescript: ".ts",
|
|
145
|
+
go: ".go",
|
|
146
|
+
perl: ".pl",
|
|
147
|
+
rust: ".rs",
|
|
148
|
+
scala: ".scala",
|
|
149
|
+
haskell: ".hs",
|
|
150
|
+
lua: ".lua",
|
|
151
|
+
shell: ".sh",
|
|
152
|
+
sql: ".sql",
|
|
153
|
+
html: ".html",
|
|
154
|
+
css: ".css"
|
|
155
|
+
// add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component
|
|
156
|
+
};
|
|
157
|
+
var generateRandomString = (length, lowercase = false) => {
|
|
158
|
+
const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789";
|
|
159
|
+
let result = "";
|
|
160
|
+
for (let i = 0; i < length; i++) {
|
|
161
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
162
|
+
}
|
|
163
|
+
return lowercase ? result.toLowerCase() : result;
|
|
164
|
+
};
|
|
165
|
+
var CodeBlock = React.memo(({ language, value }) => {
|
|
166
|
+
const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
|
|
167
|
+
const downloadAsFile = () => {
|
|
168
|
+
if (typeof window === "undefined") {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const fileExtension = programmingLanguages[language] || ".file";
|
|
172
|
+
const suggestedFileName = `file-${generateRandomString(3, true)}${fileExtension}`;
|
|
173
|
+
const fileName = window.prompt("Enter file name", suggestedFileName);
|
|
174
|
+
if (!fileName) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const blob = new Blob([value], { type: "text/plain" });
|
|
178
|
+
const url = URL.createObjectURL(blob);
|
|
179
|
+
const link = document.createElement("a");
|
|
180
|
+
link.download = fileName;
|
|
181
|
+
link.href = url;
|
|
182
|
+
link.style.display = "none";
|
|
183
|
+
document.body.appendChild(link);
|
|
184
|
+
link.click();
|
|
185
|
+
document.body.removeChild(link);
|
|
186
|
+
URL.revokeObjectURL(url);
|
|
187
|
+
};
|
|
188
|
+
const onCopy = () => {
|
|
189
|
+
if (isCopied)
|
|
190
|
+
return;
|
|
191
|
+
copyToClipboard(value);
|
|
192
|
+
};
|
|
193
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "copilotKitCodeBlock", children: [
|
|
194
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "copilotKitCodeBlockToolbar", children: [
|
|
195
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "copilotKitCodeBlockToolbarLanguage", children: language }),
|
|
196
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "copilotKitCodeBlockToolbarButtons", children: [
|
|
197
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { className: "copilotKitCodeBlockToolbarButton", onClick: downloadAsFile, children: [
|
|
198
|
+
/* @__PURE__ */ jsxRuntime.jsx(DownloadIcon, {}),
|
|
199
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Download" })
|
|
200
|
+
] }),
|
|
201
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { className: "copilotKitCodeBlockToolbarButton", onClick: onCopy, children: [
|
|
202
|
+
isCopied ? /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(CopyIcon, {}),
|
|
203
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Copy code" })
|
|
204
|
+
] })
|
|
205
|
+
] })
|
|
206
|
+
] }),
|
|
207
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
208
|
+
reactSyntaxHighlighter.Prism,
|
|
209
|
+
{
|
|
210
|
+
language,
|
|
211
|
+
style: prism.vscDarkPlus,
|
|
212
|
+
PreTag: "div",
|
|
213
|
+
customStyle: {
|
|
214
|
+
margin: 0,
|
|
215
|
+
borderBottomLeftRadius: "0.375rem",
|
|
216
|
+
borderBottomRightRadius: "0.375rem"
|
|
217
|
+
},
|
|
218
|
+
children: value
|
|
219
|
+
}
|
|
220
|
+
)
|
|
221
|
+
] });
|
|
222
|
+
});
|
|
223
|
+
CodeBlock.displayName = "CodeBlock";
|
|
224
|
+
var MemoizedReactMarkdown = React.memo(
|
|
225
|
+
ReactMarkdown__default.default,
|
|
226
|
+
(prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className
|
|
227
|
+
);
|
|
228
|
+
var Markdown = ({ content }) => {
|
|
229
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ jsxRuntime.jsx(MemoizedReactMarkdown, { components, remarkPlugins: [remarkGfm__default.default, remarkMath__default.default], children: content }) });
|
|
230
|
+
};
|
|
231
|
+
var components = {
|
|
232
|
+
p({ children }) {
|
|
233
|
+
return /* @__PURE__ */ jsxRuntime.jsx("p", { children });
|
|
234
|
+
},
|
|
235
|
+
code(_a) {
|
|
236
|
+
var _b = _a, { children, className, inline } = _b, props = __objRest(_b, ["children", "className", "inline"]);
|
|
237
|
+
if (children.length) {
|
|
238
|
+
if (children[0] == "\u258D") {
|
|
239
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
240
|
+
"span",
|
|
241
|
+
{
|
|
242
|
+
style: {
|
|
243
|
+
animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
|
|
244
|
+
marginTop: "0.25rem"
|
|
245
|
+
},
|
|
246
|
+
children: "\u258D"
|
|
247
|
+
}
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
children[0] = children[0].replace("`\u258D`", "\u258D");
|
|
251
|
+
}
|
|
252
|
+
const match = /language-(\w+)/.exec(className || "");
|
|
253
|
+
if (inline) {
|
|
254
|
+
return /* @__PURE__ */ jsxRuntime.jsx("code", __spreadProps(__spreadValues({ className }, props), { children }));
|
|
255
|
+
}
|
|
256
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
257
|
+
CodeBlock,
|
|
258
|
+
__spreadValues({
|
|
259
|
+
language: match && match[1] || "",
|
|
260
|
+
value: String(children).replace(/\n$/, "")
|
|
261
|
+
}, props),
|
|
262
|
+
Math.random()
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
exports.Markdown = Markdown;
|
|
268
|
+
//# sourceMappingURL=out.js.map
|
|
269
|
+
//# sourceMappingURL=Markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/chat/Markdown.tsx","../../../src/components/chat/CodeBlock.tsx","../../../src/hooks/use-copy-to-clipboard.tsx","../../../src/components/chat/Icons.tsx"],"names":["memo","jsx","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAa,QAAAA,aAAY;AACzB,OAAO,mBAA4C;;;ACCnD,SAAa,YAAY;AACzB,SAAS,SAAS,yBAAyB;AAC3C,SAAS,eAAe,sBAAsB;;;ACF9C,YAAY,WAAW;AAMhB,SAAS,mBAAmB,EAAE,UAAU,IAAK,GAA4B;AAC9E,QAAM,CAAC,UAAU,WAAW,IAAU,eAAkB,KAAK;AAE7D,QAAM,kBAAkB,CAAC,UAAkB;AAX7C;AAYI,QAAI,OAAO,WAAW,eAAe,GAAC,eAAU,cAAV,mBAAqB,YAAW;AACpE;AAAA,IACF;AAEA,QAAI,CAAC,OAAO;AACV;AAAA,IACF;AAEA,cAAU,UAAU,UAAU,KAAK,EAAE,KAAK,MAAM;AAC9C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F;AAEJ;AAEA,IAAM,aAAyB;AAAA,EAC7B,EAAE,EAAE,SAAS,GAAG;AACd,WAAO,gBAAAA,KAAC,OAAG,UAAS;AAAA,EACtB;AAAA,EACA,KAAK,IAA2C;AAA3C,iBAAE,YAAU,WAAW,OA9B9B,IA8BO,IAAkC,kBAAlC,IAAkC,CAAhC,YAAU,aAAW;AAC1B,QAAI,SAAS,QAAQ;AACnB,UAAI,SAAS,CAAC,KAAK,UAAK;AACtB,eACE,gBAAAA;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,cACL,WAAW;AAAA,cACX,WAAW;AAAA,YACb;AAAA,YACD;AAAA;AAAA,QAED;AAAA,MAEJ;AAEA,eAAS,CAAC,IAAK,SAAS,CAAC,EAAa,QAAQ,YAAO,QAAG;AAAA,IAC1D;AAEA,UAAM,QAAQ,iBAAiB,KAAK,aAAa,EAAE;AAEnD,QAAI,QAAQ;AACV,aACE,gBAAAA,KAAC,uCAAK,aAA0B,QAA/B,EACE,WACH;AAAA,IAEJ;AAEA,WACE,gBAAAA;AAAA,MAAC;AAAA;AAAA,QAEC,UAAW,SAAS,MAAM,CAAC,KAAM;AAAA,QACjC,OAAO,OAAO,QAAQ,EAAE,QAAQ,OAAO,EAAE;AAAA,SACrC;AAAA,MAHC,KAAK,OAAO;AAAA,IAInB;AAAA,EAEJ;AACF","sourcesContent":["import { FC, memo } from \"react\";\nimport ReactMarkdown, { Options, Components } from \"react-markdown\";\nimport { CodeBlock } from \"./CodeBlock\";\nimport remarkGfm from \"remark-gfm\";\nimport remarkMath from \"remark-math\";\n\nconst MemoizedReactMarkdown: FC<Options> = memo(\n ReactMarkdown,\n (prevProps, nextProps) =>\n prevProps.children === nextProps.children && prevProps.className === nextProps.className,\n);\n\ntype MarkdownProps = {\n content: string;\n};\n\nexport const Markdown = ({ content }: MarkdownProps) => {\n return (\n <div className=\"copilotKitMarkdown\">\n <MemoizedReactMarkdown components={components} remarkPlugins={[remarkGfm, remarkMath]}>\n {content}\n </MemoizedReactMarkdown>\n </div>\n );\n};\n\nconst components: Components = {\n p({ children }) {\n return <p>{children}</p>;\n },\n code({ children, className, inline, ...props }) {\n if (children.length) {\n if (children[0] == \"▍\") {\n return (\n <span\n style={{\n animation: \"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite\",\n marginTop: \"0.25rem\",\n }}\n >\n ▍\n </span>\n );\n }\n\n children[0] = (children[0] as string).replace(\"`▍`\", \"▍\");\n }\n\n const match = /language-(\\w+)/.exec(className || \"\");\n\n if (inline) {\n return (\n <code className={className} {...props}>\n {children}\n </code>\n );\n }\n\n return (\n <CodeBlock\n key={Math.random()}\n language={(match && match[1]) || \"\"}\n value={String(children).replace(/\\n$/, \"\")}\n {...props}\n />\n );\n },\n};\n","\"use client\";\n\nimport { FC, memo } from \"react\";\nimport { Prism as SyntaxHighlighter } from \"react-syntax-highlighter\";\nimport { vscDarkPlus as highlightStyle } from \"react-syntax-highlighter/dist/esm/styles/prism\";\n\nimport { useCopyToClipboard } from \"../../hooks/use-copy-to-clipboard\";\nimport { CheckIcon, CopyIcon, DownloadIcon } from \"./Icons\";\n\ninterface CodeActionButtonProps {\n onClick: () => void;\n children: React.ReactNode;\n}\n\ninterface Props {\n language: string;\n value: string;\n}\n\ninterface languageMap {\n [key: string]: string | undefined;\n}\n\nexport const programmingLanguages: languageMap = {\n javascript: \".js\",\n python: \".py\",\n java: \".java\",\n c: \".c\",\n cpp: \".cpp\",\n \"c++\": \".cpp\",\n \"c#\": \".cs\",\n ruby: \".rb\",\n php: \".php\",\n swift: \".swift\",\n \"objective-c\": \".m\",\n kotlin: \".kt\",\n typescript: \".ts\",\n go: \".go\",\n perl: \".pl\",\n rust: \".rs\",\n scala: \".scala\",\n haskell: \".hs\",\n lua: \".lua\",\n shell: \".sh\",\n sql: \".sql\",\n html: \".html\",\n css: \".css\",\n // add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component\n};\n\nexport const generateRandomString = (length: number, lowercase = false) => {\n const chars = \"ABCDEFGHJKLMNPQRSTUVWXY3456789\"; // excluding similar looking characters like Z, 2, I, 1, O, 0\n let result = \"\";\n for (let i = 0; i < length; i++) {\n result += chars.charAt(Math.floor(Math.random() * chars.length));\n }\n return lowercase ? result.toLowerCase() : result;\n};\n\nconst CodeBlock: FC<Props> = memo(({ language, value }) => {\n const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2000 });\n\n const downloadAsFile = () => {\n if (typeof window === \"undefined\") {\n return;\n }\n const fileExtension = programmingLanguages[language] || \".file\";\n const suggestedFileName = `file-${generateRandomString(3, true)}${fileExtension}`;\n const fileName = window.prompt(\"Enter file name\" || \"\", suggestedFileName);\n\n if (!fileName) {\n // User pressed cancel on prompt.\n return;\n }\n\n const blob = new Blob([value], { type: \"text/plain\" });\n const url = URL.createObjectURL(blob);\n const link = document.createElement(\"a\");\n link.download = fileName;\n link.href = url;\n link.style.display = \"none\";\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n URL.revokeObjectURL(url);\n };\n\n const onCopy = () => {\n if (isCopied) return;\n copyToClipboard(value);\n };\n\n return (\n <div className=\"copilotKitCodeBlock\">\n <div className=\"copilotKitCodeBlockToolbar\">\n <span className=\"copilotKitCodeBlockToolbarLanguage\">{language}</span>\n <div className=\"copilotKitCodeBlockToolbarButtons\">\n <button className=\"copilotKitCodeBlockToolbarButton\" onClick={downloadAsFile}>\n <DownloadIcon />\n <span className=\"sr-only\">Download</span>\n </button>\n <button className=\"copilotKitCodeBlockToolbarButton\" onClick={onCopy}>\n {isCopied ? <CheckIcon /> : <CopyIcon />}\n <span className=\"sr-only\">Copy code</span>\n </button>\n </div>\n </div>\n <SyntaxHighlighter\n language={language}\n style={highlightStyle}\n PreTag=\"div\"\n customStyle={{\n margin: 0,\n borderBottomLeftRadius: \"0.375rem\",\n borderBottomRightRadius: \"0.375rem\",\n }}\n >\n {value}\n </SyntaxHighlighter>\n </div>\n );\n});\nCodeBlock.displayName = \"CodeBlock\";\n\nexport { CodeBlock };\n","\"use client\";\n\nimport * as React from \"react\";\n\nexport interface useCopyToClipboardProps {\n timeout?: number;\n}\n\nexport function useCopyToClipboard({ timeout = 2000 }: useCopyToClipboardProps) {\n const [isCopied, setIsCopied] = React.useState<Boolean>(false);\n\n const copyToClipboard = (value: string) => {\n if (typeof window === \"undefined\" || !navigator.clipboard?.writeText) {\n return;\n }\n\n if (!value) {\n return;\n }\n\n navigator.clipboard.writeText(value).then(() => {\n setIsCopied(true);\n\n setTimeout(() => {\n setIsCopied(false);\n }, timeout);\n });\n };\n\n return { isCopied, copyToClipboard };\n}\n","import React from \"react\";\n\nexport const OpenIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <g transform=\"translate(24, 0) scale(-1, 1)\">\n <path\n fillRule=\"evenodd\"\n d=\"M5.337 21.718a6.707 6.707 0 01-.533-.074.75.75 0 01-.44-1.223 3.73 3.73 0 00.814-1.686c.023-.115-.022-.317-.254-.543C3.274 16.587 2.25 14.41 2.25 12c0-5.03 4.428-9 9.75-9s9.75 3.97 9.75 9c0 5.03-4.428 9-9.75 9-.833 0-1.643-.097-2.417-.279a6.721 6.721 0 01-4.246.997z\"\n clipRule=\"evenodd\"\n />\n </g>\n </svg>\n);\n\nexport const CloseIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M19.5 8.25l-7.5 7.5-7.5-7.5\" />\n </svg>\n);\n\nexport const HeaderCloseIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n);\n\nexport const SendIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth={1.5}\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M6 12L3.269 3.126A59.768 59.768 0 0121.485 12 59.77 59.77 0 013.27 20.876L5.999 12zm0 0h7.5\"\n />\n </svg>\n);\n\nexport const SpinnerIcon = (\n <svg\n style={{\n animation: \"copilotKitSpinAnimation 1s linear infinite\",\n color: \"rgb(107 114 128)\",\n }}\n width=\"24\"\n height=\"24\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n >\n <circle\n style={{ opacity: 0.25 }}\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n ></circle>\n <path\n style={{ opacity: 0.75 }}\n fill=\"currentColor\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n ></path>\n </svg>\n);\n\nexport const ActivityIcon = (\n <svg\n style={{\n display: \"inline-block\",\n marginLeft: \"0.25rem\",\n marginRight: \"0.25rem\",\n }}\n height=\"24\"\n width=\"24\"\n viewBox=\"0 0 27 27\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"currentColor\"\n >\n <circle className=\"copilotKitActivityDot1\" cx=\"4\" cy=\"12\" r=\"3\" />\n <circle className=\"copilotKitActivityDot1 copilotKitActivityDot2\" cx=\"12\" cy=\"12\" r=\"3\" />\n <circle className=\"copilotKitActivityDot1 copilotKitActivityDot3\" cx=\"20\" cy=\"12\" r=\"3\" />\n </svg>\n);\n\nexport function CheckIcon({ className, ...props }: React.ComponentProps<\"svg\">) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n className={className}\n {...props}\n >\n <path d=\"m229.66 77.66-128 128a8 8 0 0 1-11.32 0l-56-56a8 8 0 0 1 11.32-11.32L96 188.69 218.34 66.34a8 8 0 0 1 11.32 11.32Z\" />\n </svg>\n );\n}\n\nexport function DownloadIcon({ className, ...props }: React.ComponentProps<\"svg\">) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n className={className}\n {...props}\n >\n <path d=\"M224 152v56a16 16 0 0 1-16 16H48a16 16 0 0 1-16-16v-56a8 8 0 0 1 16 0v56h160v-56a8 8 0 0 1 16 0Zm-101.66 5.66a8 8 0 0 0 11.32 0l40-40a8 8 0 0 0-11.32-11.32L136 132.69V40a8 8 0 0 0-16 0v92.69l-26.34-26.35a8 8 0 0 0-11.32 11.32Z\" />\n </svg>\n );\n}\n\nexport function CopyIcon({ className, ...props }: React.ComponentProps<\"svg\">) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n className={className}\n {...props}\n >\n <path d=\"M216 32H88a8 8 0 0 0-8 8v40H40a8 8 0 0 0-8 8v128a8 8 0 0 0 8 8h128a8 8 0 0 0 8-8v-40h40a8 8 0 0 0 8-8V40a8 8 0 0 0-8-8Zm-56 176H48V96h112Zm48-48h-32V88a8 8 0 0 0-8-8H96V48h112Z\" />\n </svg>\n );\n}\n\nexport const StopIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n >\n <path d=\"M128 24a104 104 0 1 0 104 104A104.11 104.11 0 0 0 128 24Zm0 192a88 88 0 1 1 88-88 88.1 88.1 0 0 1-88 88Zm24-120h-48a8 8 0 0 0-8 8v48a8 8 0 0 0 8 8h48a8 8 0 0 0 8-8v-48a8 8 0 0 0-8-8Zm-8 48h-32v-32h32Z\" />\n </svg>\n);\n\nexport const RegenerateIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n >\n <path d=\"M197.67 186.37a8 8 0 0 1 0 11.29C196.58 198.73 170.82 224 128 224c-37.39 0-64.53-22.4-80-39.85V208a8 8 0 0 1-16 0v-48a8 8 0 0 1 8-8h48a8 8 0 0 1 0 16H55.44C67.76 183.35 93 208 128 208c36 0 58.14-21.46 58.36-21.68a8 8 0 0 1 11.31.05ZM216 40a8 8 0 0 0-8 8v23.85C192.53 54.4 165.39 32 128 32c-42.82 0-68.58 25.27-69.66 26.34a8 8 0 0 0 11.3 11.34C69.86 69.46 92 48 128 48c35 0 60.24 24.65 72.56 40H168a8 8 0 0 0 0 16h48a8 8 0 0 0 8-8V48a8 8 0 0 0-8-8Z\" />\n </svg>\n);\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { Markdown } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
1
|
+
export { Markdown } from '../../chunk-GWGHQNRI.mjs';
|
|
2
|
+
import '../../chunk-DPRH4HX3.mjs';
|
|
3
3
|
import '../../chunk-7YXG7D47.mjs';
|
|
4
4
|
import '../../chunk-POVINPXX.mjs';
|
|
5
5
|
import '../../chunk-MRXNTQOX.mjs';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React__default from 'react';
|
|
2
1
|
import { MessagesProps } from './props.js';
|
|
3
|
-
import '@copilotkit/
|
|
2
|
+
import '@copilotkit/shared';
|
|
4
3
|
|
|
5
|
-
declare const Messages:
|
|
4
|
+
declare const Messages: ({ messages, inProgress }: MessagesProps) => JSX.Element;
|
|
6
5
|
|
|
7
6
|
export { Messages };
|