@copilotkit/react-ui 0.14.1 → 0.15.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +279 -196
- package/CHANGELOG.md +22 -0
- package/dist/chunk-47SYBLI2.mjs +110 -0
- package/dist/chunk-47SYBLI2.mjs.map +1 -0
- package/dist/chunk-6H3Y2XEI.mjs +56 -0
- package/dist/chunk-6H3Y2XEI.mjs.map +1 -0
- package/dist/chunk-7YXG7D47.mjs +191 -0
- package/dist/chunk-7YXG7D47.mjs.map +1 -0
- package/dist/chunk-DN3OI5WF.mjs +72 -0
- package/dist/chunk-DN3OI5WF.mjs.map +1 -0
- package/dist/chunk-DPUPEOGG.mjs +14 -0
- package/dist/chunk-DPUPEOGG.mjs.map +1 -0
- package/dist/chunk-FZRTAML3.mjs +3 -0
- package/dist/chunk-GPEJCUWA.mjs +14 -0
- package/dist/chunk-GPEJCUWA.mjs.map +1 -0
- package/dist/chunk-NXWVWC33.mjs +117 -0
- package/dist/chunk-NXWVWC33.mjs.map +1 -0
- package/dist/chunk-P4GBO6MW.mjs +3 -0
- package/dist/chunk-P4GBO6MW.mjs.map +1 -0
- package/dist/chunk-QFASQEFJ.mjs +51 -0
- package/dist/chunk-QFASQEFJ.mjs.map +1 -0
- package/dist/chunk-UIRFLYXI.mjs +53 -0
- package/dist/chunk-UIRFLYXI.mjs.map +1 -0
- package/dist/chunk-WB3YULQ4.mjs +3 -0
- package/dist/chunk-WB3YULQ4.mjs.map +1 -0
- package/dist/chunk-WM6BS77F.mjs +53 -0
- package/dist/chunk-WM6BS77F.mjs.map +1 -0
- package/dist/chunk-X3Z2EVFV.mjs +26 -0
- package/dist/chunk-X3Z2EVFV.mjs.map +1 -0
- package/dist/chunk-X4T6ZUVM.mjs +14 -0
- package/dist/chunk-X4T6ZUVM.mjs.map +1 -0
- package/dist/chunk-Y2RUG4B3.mjs +21 -0
- package/dist/chunk-Y2RUG4B3.mjs.map +1 -0
- package/dist/chunk-ZVAH2Z2W.mjs +61 -0
- package/dist/chunk-ZVAH2Z2W.mjs.map +1 -0
- package/dist/components/chat/Button.d.ts +7 -0
- package/dist/components/chat/Button.mjs +6 -0
- package/dist/components/chat/Button.mjs.map +1 -0
- package/dist/components/chat/Chat.d.ts +95 -0
- package/dist/components/chat/Chat.mjs +16 -0
- package/dist/components/chat/Chat.mjs.map +1 -0
- package/dist/components/chat/ChatContext.d.ts +105 -0
- package/dist/components/chat/ChatContext.mjs +5 -0
- package/dist/components/chat/ChatContext.mjs.map +1 -0
- package/dist/components/chat/CodeBlock.d.ts +14 -0
- package/dist/components/chat/CodeBlock.mjs +6 -0
- package/dist/components/chat/CodeBlock.mjs.map +1 -0
- package/dist/components/chat/Header.d.ts +7 -0
- package/dist/components/chat/Header.mjs +6 -0
- package/dist/components/chat/Header.mjs.map +1 -0
- package/dist/components/chat/Icons.d.ts +15 -0
- package/dist/components/chat/Icons.mjs +4 -0
- package/dist/components/chat/Icons.mjs.map +1 -0
- package/dist/components/chat/Input.d.ts +7 -0
- package/dist/components/chat/Input.mjs +7 -0
- package/dist/components/chat/Input.mjs.map +1 -0
- package/dist/components/chat/Markdown.d.ts +8 -0
- package/dist/components/chat/Markdown.mjs +7 -0
- package/dist/components/chat/Markdown.mjs.map +1 -0
- package/dist/components/chat/Messages.d.ts +7 -0
- package/dist/components/chat/Messages.mjs +9 -0
- package/dist/components/chat/Messages.mjs.map +1 -0
- package/dist/components/chat/Popup.d.ts +9 -0
- package/dist/components/chat/Popup.mjs +17 -0
- package/dist/components/chat/Popup.mjs.map +1 -0
- package/dist/components/chat/Response.d.ts +7 -0
- package/dist/components/chat/Response.mjs +6 -0
- package/dist/components/chat/Response.mjs.map +1 -0
- package/dist/components/chat/Sidebar.d.ts +12 -0
- package/dist/components/chat/Sidebar.mjs +17 -0
- package/dist/components/chat/Sidebar.mjs.map +1 -0
- package/dist/components/chat/Textarea.d.ts +13 -0
- package/dist/components/chat/Textarea.mjs +4 -0
- package/dist/components/chat/Textarea.mjs.map +1 -0
- package/dist/components/chat/Window.d.ts +6 -0
- package/dist/components/chat/Window.mjs +4 -0
- package/dist/components/chat/Window.mjs.map +1 -0
- package/dist/components/chat/index.d.ts +7 -0
- package/dist/components/chat/index.mjs +20 -0
- package/dist/components/chat/index.mjs.map +1 -0
- package/dist/components/chat/props.d.ts +33 -0
- package/dist/components/chat/props.mjs +3 -0
- package/dist/components/chat/props.mjs.map +1 -0
- package/dist/components/chat-components/copilot-chat.mjs +1 -1
- package/dist/components/chat-components/ui/badge.d.ts +1 -1
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.mjs +18 -2
- package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs +1 -1
- package/dist/components/sidebar/copilot-sidebar.mjs +1 -1
- package/dist/index.css +452 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +18 -2
- package/package.json +5 -5
- package/src/components/chat/Button.tsx +24 -0
- package/src/components/chat/Chat.tsx +186 -0
- package/src/components/chat/ChatContext.tsx +176 -0
- package/src/components/chat/CodeBlock.tsx +149 -0
- package/src/components/chat/Header.tsx +16 -0
- package/src/components/chat/Icons.tsx +179 -0
- package/src/components/chat/Input.tsx +51 -0
- package/src/components/chat/Markdown.tsx +62 -0
- package/src/components/chat/Messages.tsx +113 -0
- package/src/components/chat/Popup.tsx +10 -0
- package/src/components/chat/Response.tsx +13 -0
- package/src/components/chat/Sidebar.tsx +28 -0
- package/src/components/chat/Textarea.tsx +61 -0
- package/src/components/chat/Window.tsx +141 -0
- package/src/components/chat/index.tsx +3 -0
- package/src/components/chat/props.ts +36 -0
- package/src/components/index.ts +2 -0
- package/src/css/animations.css +29 -0
- package/src/css/button.css +54 -0
- package/src/css/colors.css +61 -0
- package/src/css/header.css +43 -0
- package/src/css/input.css +79 -0
- package/src/css/messages.css +57 -0
- package/src/css/popup.css +22 -0
- package/src/css/response.css +29 -0
- package/src/css/sidebar.css +34 -0
- package/src/css/window.css +58 -0
- package/src/styles.css +11 -0
- package/dist/chunk-U6NJWGTV.mjs +0 -3
- /package/dist/{chunk-U6NJWGTV.mjs.map → chunk-FZRTAML3.mjs.map} +0 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { DownloadIcon, CheckIcon, CopyIcon } from './chunk-7YXG7D47.mjs';
|
|
2
|
+
import { useCopyToClipboard } from './chunk-POVINPXX.mjs';
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
import { Prism } from 'react-syntax-highlighter';
|
|
5
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var CodeActionButton = ({ onClick, children }) => {
|
|
8
|
+
let className = "inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 ";
|
|
9
|
+
className += "hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0 ";
|
|
10
|
+
className += "hover:bg-accent hover:text-accent-foreground ";
|
|
11
|
+
className += "h-10 w-10";
|
|
12
|
+
return /* @__PURE__ */ jsx("button", { className, onClick, children });
|
|
13
|
+
};
|
|
14
|
+
var programmingLanguages = {
|
|
15
|
+
javascript: ".js",
|
|
16
|
+
python: ".py",
|
|
17
|
+
java: ".java",
|
|
18
|
+
c: ".c",
|
|
19
|
+
cpp: ".cpp",
|
|
20
|
+
"c++": ".cpp",
|
|
21
|
+
"c#": ".cs",
|
|
22
|
+
ruby: ".rb",
|
|
23
|
+
php: ".php",
|
|
24
|
+
swift: ".swift",
|
|
25
|
+
"objective-c": ".m",
|
|
26
|
+
kotlin: ".kt",
|
|
27
|
+
typescript: ".ts",
|
|
28
|
+
go: ".go",
|
|
29
|
+
perl: ".pl",
|
|
30
|
+
rust: ".rs",
|
|
31
|
+
scala: ".scala",
|
|
32
|
+
haskell: ".hs",
|
|
33
|
+
lua: ".lua",
|
|
34
|
+
shell: ".sh",
|
|
35
|
+
sql: ".sql",
|
|
36
|
+
html: ".html",
|
|
37
|
+
css: ".css"
|
|
38
|
+
// add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component
|
|
39
|
+
};
|
|
40
|
+
var generateRandomString = (length, lowercase = false) => {
|
|
41
|
+
const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789";
|
|
42
|
+
let result = "";
|
|
43
|
+
for (let i = 0; i < length; i++) {
|
|
44
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
45
|
+
}
|
|
46
|
+
return lowercase ? result.toLowerCase() : result;
|
|
47
|
+
};
|
|
48
|
+
var CodeBlock = memo(({ language, value }) => {
|
|
49
|
+
const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
|
|
50
|
+
const downloadAsFile = () => {
|
|
51
|
+
if (typeof window === "undefined") {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const fileExtension = programmingLanguages[language] || ".file";
|
|
55
|
+
const suggestedFileName = `file-${generateRandomString(3, true)}${fileExtension}`;
|
|
56
|
+
const fileName = window.prompt("Enter file name", suggestedFileName);
|
|
57
|
+
if (!fileName) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const blob = new Blob([value], { type: "text/plain" });
|
|
61
|
+
const url = URL.createObjectURL(blob);
|
|
62
|
+
const link = document.createElement("a");
|
|
63
|
+
link.download = fileName;
|
|
64
|
+
link.href = url;
|
|
65
|
+
link.style.display = "none";
|
|
66
|
+
document.body.appendChild(link);
|
|
67
|
+
link.click();
|
|
68
|
+
document.body.removeChild(link);
|
|
69
|
+
URL.revokeObjectURL(url);
|
|
70
|
+
};
|
|
71
|
+
const onCopy = () => {
|
|
72
|
+
if (isCopied)
|
|
73
|
+
return;
|
|
74
|
+
copyToClipboard(value);
|
|
75
|
+
};
|
|
76
|
+
return /* @__PURE__ */ jsxs("div", { className: "codeblock relative w-full bg-zinc-950 font-sans", children: [
|
|
77
|
+
/* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between bg-zinc-800 px-6 py-2 pr-4 text-zinc-100", children: [
|
|
78
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs lowercase", children: language }),
|
|
79
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-1", children: [
|
|
80
|
+
/* @__PURE__ */ jsxs(CodeActionButton, { onClick: downloadAsFile, children: [
|
|
81
|
+
/* @__PURE__ */ jsx(DownloadIcon, {}),
|
|
82
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Download" })
|
|
83
|
+
] }),
|
|
84
|
+
/* @__PURE__ */ jsxs(CodeActionButton, { onClick: onCopy, children: [
|
|
85
|
+
isCopied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {}),
|
|
86
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Copy code" })
|
|
87
|
+
] })
|
|
88
|
+
] })
|
|
89
|
+
] }),
|
|
90
|
+
/* @__PURE__ */ jsx(
|
|
91
|
+
Prism,
|
|
92
|
+
{
|
|
93
|
+
language,
|
|
94
|
+
PreTag: "div",
|
|
95
|
+
showLineNumbers: true,
|
|
96
|
+
customStyle: {
|
|
97
|
+
margin: 0,
|
|
98
|
+
width: "100%",
|
|
99
|
+
background: "transparent",
|
|
100
|
+
padding: "1.5rem 1rem"
|
|
101
|
+
},
|
|
102
|
+
codeTagProps: {
|
|
103
|
+
style: {
|
|
104
|
+
fontSize: "0.9rem",
|
|
105
|
+
fontFamily: "var(--font-mono)"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
children: value
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
] });
|
|
112
|
+
});
|
|
113
|
+
CodeBlock.displayName = "CodeBlock";
|
|
114
|
+
|
|
115
|
+
export { CodeBlock, generateRandomString, programmingLanguages };
|
|
116
|
+
//# sourceMappingURL=out.js.map
|
|
117
|
+
//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A,YACV,YAAY;AAAA,UACd;AAAA,QACF;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,KACF;AAEJ,CAAC;AACD,UAAU,cAAc","sourcesContent":["\"use client\";\n\nimport { FC, memo } from \"react\";\nimport { Prism as SyntaxHighlighter } from \"react-syntax-highlighter\";\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\nconst CodeActionButton: FC<CodeActionButtonProps> = ({ onClick, children }) => {\n let className =\n \"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background \" +\n \"transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring \" +\n \"focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 \";\n\n className +=\n \"hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0 \";\n className += \"hover:bg-accent hover:text-accent-foreground \";\n className += \"h-10 w-10\";\n\n return (\n <button className={className} onClick={onClick}>\n {children}\n </button>\n );\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=\"codeblock relative w-full bg-zinc-950 font-sans\">\n <div className=\"flex w-full items-center justify-between bg-zinc-800 px-6 py-2 pr-4 text-zinc-100\">\n <span className=\"text-xs lowercase\">{language}</span>\n <div className=\"flex items-center space-x-1\">\n <CodeActionButton onClick={downloadAsFile}>\n <DownloadIcon />\n <span className=\"sr-only\">Download</span>\n </CodeActionButton>\n <CodeActionButton onClick={onCopy}>\n {isCopied ? <CheckIcon /> : <CopyIcon />}\n <span className=\"sr-only\">Copy code</span>\n </CodeActionButton>\n </div>\n </div>\n <SyntaxHighlighter\n language={language}\n PreTag=\"div\"\n showLineNumbers\n customStyle={{\n margin: 0,\n width: \"100%\",\n background: \"transparent\",\n padding: \"1.5rem 1rem\",\n }}\n codeTagProps={{\n style: {\n fontSize: \"0.9rem\",\n fontFamily: \"var(--font-mono)\",\n },\n }}\n >\n {value}\n </SyntaxHighlighter>\n </div>\n );\n});\nCodeBlock.displayName = \"CodeBlock\";\n\nexport { CodeBlock };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Textarea_default } from './chunk-WM6BS77F.mjs';
|
|
2
|
+
import { useChatContext } from './chunk-6H3Y2XEI.mjs';
|
|
3
|
+
import { useRef, useState } from 'react';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
var Input = ({ inProgress, onSend, children }) => {
|
|
7
|
+
const context = useChatContext();
|
|
8
|
+
const textareaRef = useRef(null);
|
|
9
|
+
const handleDivClick = (event) => {
|
|
10
|
+
var _a;
|
|
11
|
+
if (event.target !== event.currentTarget)
|
|
12
|
+
return;
|
|
13
|
+
(_a = textareaRef.current) == null ? void 0 : _a.focus();
|
|
14
|
+
};
|
|
15
|
+
const [text, setText] = useState("");
|
|
16
|
+
const send = () => {
|
|
17
|
+
var _a;
|
|
18
|
+
if (inProgress)
|
|
19
|
+
return;
|
|
20
|
+
onSend(text);
|
|
21
|
+
setText("");
|
|
22
|
+
(_a = textareaRef.current) == null ? void 0 : _a.focus();
|
|
23
|
+
};
|
|
24
|
+
const icon = inProgress ? context.icons.activityIcon : context.icons.sendIcon;
|
|
25
|
+
const disabled = inProgress || text.length === 0;
|
|
26
|
+
return /* @__PURE__ */ jsxs("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
|
|
27
|
+
/* @__PURE__ */ jsx("span", { children }),
|
|
28
|
+
/* @__PURE__ */ jsx("button", { className: "copilotKitSendButton", disabled, onClick: send, children: icon }),
|
|
29
|
+
/* @__PURE__ */ jsx(
|
|
30
|
+
Textarea_default,
|
|
31
|
+
{
|
|
32
|
+
ref: textareaRef,
|
|
33
|
+
placeholder: context.labels.placeholder,
|
|
34
|
+
autoFocus: true,
|
|
35
|
+
maxRows: 5,
|
|
36
|
+
value: text,
|
|
37
|
+
onChange: (event) => setText(event.target.value),
|
|
38
|
+
onKeyDown: (event) => {
|
|
39
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
40
|
+
event.preventDefault();
|
|
41
|
+
send();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
] });
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export { Input };
|
|
50
|
+
//# sourceMappingURL=out.js.map
|
|
51
|
+
//# sourceMappingURL=chunk-QFASQEFJ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Input.tsx"],"names":[],"mappings":";;;;;;;;AAAA,SAAgB,QAAQ,gBAAgB;AA6BpC,SACE,KADF;AAxBG,IAAM,QAA8B,CAAC,EAAE,YAAY,QAAQ,SAAS,MAAM;AAC/E,QAAM,UAAU,eAAe;AAC/B,QAAM,cAAc,OAA4B,IAAI;AAEpD,QAAM,iBAAiB,CAAC,UAA4C;AATtE;AAWI,QAAI,MAAM,WAAW,MAAM;AAAe;AAE1C,sBAAY,YAAZ,mBAAqB;AAAA,EACvB;AAEA,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,EAAE;AACnC,QAAM,OAAO,MAAM;AAjBrB;AAkBI,QAAI;AAAY;AAChB,WAAO,IAAI;AACX,YAAQ,EAAE;AAEV,sBAAY,YAAZ,mBAAqB;AAAA,EACvB;AAEA,QAAM,OAAO,aAAa,QAAQ,MAAM,eAAe,QAAQ,MAAM;AACrE,QAAM,WAAW,cAAc,KAAK,WAAW;AAE/C,SACE,qBAAC,SAAI,WAAU,mBAAkB,SAAS,gBACxC;AAAA,wBAAC,UAAM,UAAS;AAAA,IAChB,oBAAC,YAAO,WAAU,wBAAuB,UAAoB,SAAS,MACnE,gBACH;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL,aAAa,QAAQ,OAAO;AAAA,QAC5B,WAAW;AAAA,QACX,SAAS;AAAA,QACT,OAAO;AAAA,QACP,UAAU,CAAC,UAAU,QAAQ,MAAM,OAAO,KAAK;AAAA,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: React.FC<InputProps> = ({ inProgress, onSend, children }) => {\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"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { CodeBlock } from './chunk-NXWVWC33.mjs';
|
|
2
|
+
import { __objRest, __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
import ReactMarkdown from 'react-markdown';
|
|
5
|
+
import remarkGfm from 'remark-gfm';
|
|
6
|
+
import remarkMath from 'remark-math';
|
|
7
|
+
import { jsx } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
var MemoizedReactMarkdown = memo(
|
|
10
|
+
ReactMarkdown,
|
|
11
|
+
(prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className
|
|
12
|
+
);
|
|
13
|
+
var Markdown = ({ content }) => {
|
|
14
|
+
return /* @__PURE__ */ jsx(
|
|
15
|
+
MemoizedReactMarkdown,
|
|
16
|
+
{
|
|
17
|
+
className: "prose break-words dark:prose-invert prose-p:leading-relaxed prose-pre:p-0 text-sm",
|
|
18
|
+
components,
|
|
19
|
+
remarkPlugins: [remarkGfm, remarkMath],
|
|
20
|
+
children: content
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
var components = {
|
|
25
|
+
p({ children }) {
|
|
26
|
+
return /* @__PURE__ */ jsx("p", { className: "mb-2 last:mb-0", children });
|
|
27
|
+
},
|
|
28
|
+
code(_a) {
|
|
29
|
+
var _b = _a, { children, className, inline } = _b, props = __objRest(_b, ["children", "className", "inline"]);
|
|
30
|
+
if (children.length) {
|
|
31
|
+
if (children[0] == "\u258D") {
|
|
32
|
+
return /* @__PURE__ */ jsx("span", { className: "mt-1 animate-pulse cursor-default", children: "\u258D" });
|
|
33
|
+
}
|
|
34
|
+
children[0] = children[0].replace("`\u258D`", "\u258D");
|
|
35
|
+
}
|
|
36
|
+
const match = /language-(\w+)/.exec(className || "");
|
|
37
|
+
if (inline) {
|
|
38
|
+
return /* @__PURE__ */ jsx("code", __spreadProps(__spreadValues({ className }, props), { children }));
|
|
39
|
+
}
|
|
40
|
+
return /* @__PURE__ */ jsx(
|
|
41
|
+
CodeBlock,
|
|
42
|
+
__spreadValues({
|
|
43
|
+
language: match && match[1] || "",
|
|
44
|
+
value: String(children).replace(/\n$/, "")
|
|
45
|
+
}, props),
|
|
46
|
+
Math.random()
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { Markdown };
|
|
52
|
+
//# sourceMappingURL=out.js.map
|
|
53
|
+
//# sourceMappingURL=chunk-UIRFLYXI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Markdown.tsx"],"names":[],"mappings":";;;;;;;;;;AACA,SAAa,YAAY;AACzB,OAAO,mBAA4C;AAEnD,OAAO,eAAe;AACtB,OAAO,gBAAgB;AAcnB;AAZJ,IAAM,wBAAqC;AAAA,EACzC;AAAA,EACA,CAAC,WAAW,cACV,UAAU,aAAa,UAAU,YAAY,UAAU,cAAc,UAAU;AACnF;AAMO,IAAM,WAAoC,CAAC,EAAE,QAAQ,MAAM;AAChE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV;AAAA,MACA,eAAe,CAAC,WAAW,UAAU;AAAA,MAEpC;AAAA;AAAA,EACH;AAEJ;AAEA,IAAM,aAAyB;AAAA,EAC7B,EAAE,EAAE,SAAS,GAAG;AACd,WAAO,oBAAC,OAAE,WAAU,kBAAkB,UAAS;AAAA,EACjD;AAAA,EACA,KAAK,IAA2C;AAA3C,iBAAE,YAAU,WAAW,OAjC9B,IAiCO,IAAkC,kBAAlC,IAAkC,CAAhC,YAAU,aAAW;AAC1B,QAAI,SAAS,QAAQ;AACnB,UAAI,SAAS,CAAC,KAAK,UAAK;AACtB,eAAO,oBAAC,UAAK,WAAU,qCAAoC,oBAAC;AAAA,MAC9D;AAEA,eAAS,CAAC,IAAK,SAAS,CAAC,EAAa,QAAQ,YAAO,QAAG;AAAA,IAC1D;AAEA,UAAM,QAAQ,iBAAiB,KAAK,aAAa,EAAE;AAEnD,QAAI,QAAQ;AACV,aACE,oBAAC,uCAAK,aAA0B,QAA/B,EACE,WACH;AAAA,IAEJ;AAEA,WACE;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 React from \"react\";\nimport { 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: React.FC<MarkdownProps> = ({ content }) => {\n return (\n <MemoizedReactMarkdown\n className=\"prose break-words dark:prose-invert prose-p:leading-relaxed prose-pre:p-0 text-sm\"\n components={components}\n remarkPlugins={[remarkGfm, remarkMath]}\n >\n {content}\n </MemoizedReactMarkdown>\n );\n};\n\nconst components: Components = {\n p({ children }) {\n return <p className=\"mb-2 last:mb-0\">{children}</p>;\n },\n code({ children, className, inline, ...props }) {\n if (children.length) {\n if (children[0] == \"▍\") {\n return <span className=\"mt-1 animate-pulse cursor-default\">▍</span>;\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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { forwardRef, useRef, useState, useImperativeHandle, useEffect } from 'react';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
// src/components/chat/Textarea.tsx
|
|
5
|
+
var AutoResizingTextarea = forwardRef(
|
|
6
|
+
({ maxRows = 1, placeholder, value, onChange, onKeyDown, autoFocus }, ref) => {
|
|
7
|
+
const internalTextareaRef = useRef(null);
|
|
8
|
+
const [maxHeight, setMaxHeight] = useState(0);
|
|
9
|
+
useImperativeHandle(ref, () => internalTextareaRef.current);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const calculateMaxHeight = () => {
|
|
12
|
+
const textarea = internalTextareaRef.current;
|
|
13
|
+
if (textarea) {
|
|
14
|
+
textarea.style.height = "auto";
|
|
15
|
+
const singleRowHeight = textarea.scrollHeight;
|
|
16
|
+
setMaxHeight(singleRowHeight * maxRows);
|
|
17
|
+
if (autoFocus) {
|
|
18
|
+
textarea.focus();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
calculateMaxHeight();
|
|
23
|
+
}, [maxRows]);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const textarea = internalTextareaRef.current;
|
|
26
|
+
if (textarea) {
|
|
27
|
+
textarea.style.height = "auto";
|
|
28
|
+
textarea.style.height = `${Math.min(textarea.scrollHeight, maxHeight)}px`;
|
|
29
|
+
}
|
|
30
|
+
}, [value, maxHeight]);
|
|
31
|
+
return /* @__PURE__ */ jsx(
|
|
32
|
+
"textarea",
|
|
33
|
+
{
|
|
34
|
+
ref: internalTextareaRef,
|
|
35
|
+
value,
|
|
36
|
+
onChange,
|
|
37
|
+
onKeyDown,
|
|
38
|
+
placeholder,
|
|
39
|
+
style: {
|
|
40
|
+
overflow: "hidden",
|
|
41
|
+
resize: "none",
|
|
42
|
+
maxHeight: `${maxHeight}px`
|
|
43
|
+
},
|
|
44
|
+
rows: 1
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
var Textarea_default = AutoResizingTextarea;
|
|
50
|
+
|
|
51
|
+
export { Textarea_default };
|
|
52
|
+
//# sourceMappingURL=out.js.map
|
|
53
|
+
//# sourceMappingURL=chunk-WM6BS77F.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Textarea.tsx"],"names":[],"mappings":";AAAA,SAAgB,UAAU,QAAQ,WAAW,YAAY,2BAA2B;AA2C9E;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,GAAG,KAAK,IAAI,SAAS,cAAc,SAAS;AAAA,MACtE;AAAA,IACF,GAAG,CAAC,OAAO,SAAS,CAAC;AAErB,WACE;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO;AAAA,UACL,UAAU;AAAA,UACV,QAAQ;AAAA,UACR,WAAW,GAAG;AAAA,QAChB;AAAA,QACA,MAAM;AAAA;AAAA,IACR;AAAA,EAEJ;AACF;AAEA,IAAO,mBAAQ","sourcesContent":["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"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CopilotKitChat } from './chunk-DN3OI5WF.mjs';
|
|
2
|
+
import { __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
var CopilotKitSidebar = (props) => {
|
|
7
|
+
props = __spreadProps(__spreadValues({}, props), {
|
|
8
|
+
className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
|
|
9
|
+
});
|
|
10
|
+
const [expandedClassName, setExpandedClassName] = useState(
|
|
11
|
+
props.defaultOpen ? "sidebarExpanded" : ""
|
|
12
|
+
);
|
|
13
|
+
const onSetOpen = (open) => {
|
|
14
|
+
var _a;
|
|
15
|
+
(_a = props.onSetOpen) == null ? void 0 : _a.call(props, open);
|
|
16
|
+
setExpandedClassName(open ? "sidebarExpanded" : "");
|
|
17
|
+
};
|
|
18
|
+
return /* @__PURE__ */ jsxs("div", { className: `copilotKitSidebarContentWrapper ${expandedClassName}`, children: [
|
|
19
|
+
props.children,
|
|
20
|
+
/* @__PURE__ */ jsx(CopilotKitChat, __spreadValues(__spreadValues({}, props), { onSetOpen }))
|
|
21
|
+
] });
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { CopilotKitSidebar };
|
|
25
|
+
//# sourceMappingURL=out.js.map
|
|
26
|
+
//# sourceMappingURL=chunk-X3Z2EVFV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Sidebar.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,SAAgB,gBAAgB;AAsB5B,SAEE,KAFF;AAfG,IAAM,oBAAsD,CAAC,UAAU;AAC5E,UAAQ,iCACH,QADG;AAAA,IAEN,WAAW,MAAM,YAAY,MAAM,YAAY,uBAAuB;AAAA,EACxE;AACA,QAAM,CAAC,mBAAmB,oBAAoB,IAAI;AAAA,IAChD,MAAM,cAAc,oBAAoB;AAAA,EAC1C;AAEA,QAAM,YAAY,CAAC,SAAkB;AAhBvC;AAiBI,gBAAM,cAAN,+BAAkB;AAClB,yBAAqB,OAAO,oBAAoB,EAAE;AAAA,EACpD;AAEA,SACE,qBAAC,SAAI,WAAW,mCAAmC,qBAChD;AAAA,UAAM;AAAA,IACP,oBAAC,kDAAmB,QAAW,EAAE,UAAU,EAAG;AAAA,KAChD;AAEJ","sourcesContent":["import React, { useState } from \"react\";\nimport { CopilotKitChat, CopilotKitChatProps } from \"./Chat\";\n\ninterface CopilotKitSidebarProps extends CopilotKitChatProps {\n children?: React.ReactNode;\n}\n\nexport const CopilotKitSidebar: React.FC<CopilotKitSidebarProps> = (props) => {\n props = {\n ...props,\n className: props.className ? props.className + \" copilotKitSidebar\" : \"copilotKitSidebar\",\n };\n const [expandedClassName, setExpandedClassName] = useState(\n props.defaultOpen ? \"sidebarExpanded\" : \"\",\n );\n\n const onSetOpen = (open: boolean) => {\n props.onSetOpen?.(open);\n setExpandedClassName(open ? \"sidebarExpanded\" : \"\");\n };\n\n return (\n <div className={`copilotKitSidebarContentWrapper ${expandedClassName}`}>\n {props.children}\n <CopilotKitChat {...props} {...{ onSetOpen }} />\n </div>\n );\n};\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CopilotKitChat } from './chunk-DN3OI5WF.mjs';
|
|
2
|
+
import { __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
var CopilotKitPopup = (props) => {
|
|
6
|
+
props = __spreadProps(__spreadValues({}, props), {
|
|
7
|
+
className: props.className ? props.className + " copilotKitPopup" : "copilotKitPopup"
|
|
8
|
+
});
|
|
9
|
+
return /* @__PURE__ */ jsx(CopilotKitChat, __spreadValues({}, props));
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { CopilotKitPopup };
|
|
13
|
+
//# sourceMappingURL=out.js.map
|
|
14
|
+
//# sourceMappingURL=chunk-X4T6ZUVM.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Popup.tsx"],"names":[],"mappings":";;;;;;;;;AAQS;AALF,IAAM,kBAAiD,CAAC,UAAU;AACvE,UAAQ,iCACH,QADG;AAAA,IAEN,WAAW,MAAM,YAAY,MAAM,YAAY,qBAAqB;AAAA,EACtE;AACA,SAAO,oBAAC,mCAAmB,MAAO;AACpC","sourcesContent":["import React from \"react\";\nimport { CopilotKitChat, CopilotKitChatProps } from \"./Chat\";\n\nexport const CopilotKitPopup: React.FC<CopilotKitChatProps> = (props) => {\n props = {\n ...props,\n className: props.className ? props.className + \" copilotKitPopup\" : \"copilotKitPopup\",\n };\n return <CopilotKitChat {...props} />;\n};\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useChatContext } from './chunk-6H3Y2XEI.mjs';
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
var Button = ({ open, setOpen }) => {
|
|
5
|
+
const context = useChatContext();
|
|
6
|
+
return /* @__PURE__ */ jsx("div", { onClick: () => setOpen(!open), children: /* @__PURE__ */ jsxs(
|
|
7
|
+
"button",
|
|
8
|
+
{
|
|
9
|
+
className: `copilotKitButton ${open ? "open" : ""}`,
|
|
10
|
+
"aria-label": open ? "Close Chat" : "Open Chat",
|
|
11
|
+
children: [
|
|
12
|
+
/* @__PURE__ */ jsx("div", { className: "copilotKitButtonIcon copilotKitButtonIconOpen", children: context.icons.openIcon }),
|
|
13
|
+
/* @__PURE__ */ jsx("div", { className: "copilotKitButtonIcon copilotKitButtonIconClose", children: context.icons.closeIcon })
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
) });
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { Button };
|
|
20
|
+
//# sourceMappingURL=out.js.map
|
|
21
|
+
//# sourceMappingURL=chunk-Y2RUG4B3.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Button.tsx"],"names":[],"mappings":";;;;;AAUM,SAIE,KAJF;AANC,IAAM,SAAgC,CAAC,EAAE,MAAM,QAAQ,MAAM;AAClE,QAAM,UAAU,eAAe;AAG/B,SACE,oBAAC,SAAI,SAAS,MAAM,QAAQ,CAAC,IAAI,GAC/B;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,oBAAoB,OAAO,SAAS;AAAA,MAC/C,cAAY,OAAO,eAAe;AAAA,MAElC;AAAA,4BAAC,SAAI,WAAU,iDACZ,kBAAQ,MAAM,UACjB;AAAA,QACA,oBAAC,SAAI,WAAU,kDACZ,kBAAQ,MAAM,WACjB;AAAA;AAAA;AAAA,EACF,GACF;AAEJ","sourcesContent":["import React from \"react\";\nimport { ButtonProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\n\nexport const Button: React.FC<ButtonProps> = ({ open, setOpen }) => {\n const context = useChatContext();\n // To ensure that the mouse handler fires even when the button is scaled down\n // we wrap the button in a div and attach the handler to the div\n return (\n <div onClick={() => setOpen(!open)}>\n <button\n className={`copilotKitButton ${open ? \"open\" : \"\"}`}\n aria-label={open ? \"Close Chat\" : \"Open Chat\"}\n >\n <div className=\"copilotKitButtonIcon copilotKitButtonIconOpen\">\n {context.icons.openIcon}\n </div>\n <div className=\"copilotKitButtonIcon copilotKitButtonIconClose\">\n {context.icons.closeIcon}\n </div>\n </button>\n </div>\n );\n};\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Markdown } from './chunk-UIRFLYXI.mjs';
|
|
2
|
+
import { useChatContext } from './chunk-6H3Y2XEI.mjs';
|
|
3
|
+
import React, { useMemo, useEffect } from 'react';
|
|
4
|
+
import { nanoid } from 'nanoid';
|
|
5
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var Messages = ({ messages, inProgress }) => {
|
|
8
|
+
const context = useChatContext();
|
|
9
|
+
const initialMessages = useMemo(
|
|
10
|
+
() => makeInitialMessages(context.labels.initial),
|
|
11
|
+
[context.labels.initial]
|
|
12
|
+
);
|
|
13
|
+
messages = [...initialMessages, ...messages];
|
|
14
|
+
const messagesEndRef = React.useRef(null);
|
|
15
|
+
const scrollToBottom = () => {
|
|
16
|
+
if (messagesEndRef.current) {
|
|
17
|
+
messagesEndRef.current.scrollIntoView({
|
|
18
|
+
behavior: "auto"
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
scrollToBottom();
|
|
24
|
+
}, [messages]);
|
|
25
|
+
return /* @__PURE__ */ jsxs("div", { className: "copilotKitMessages", children: [
|
|
26
|
+
messages.map((message, index) => {
|
|
27
|
+
const isCurrentMessage = index === messages.length - 1;
|
|
28
|
+
if (message.role === "user") {
|
|
29
|
+
return /* @__PURE__ */ jsx("div", { className: "copilotKitMessage copilotKitUserMessage", children: message.content }, index);
|
|
30
|
+
} else if (message.role == "assistant") {
|
|
31
|
+
if (isCurrentMessage && inProgress && !message.content) {
|
|
32
|
+
return /* @__PURE__ */ jsx("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: context.icons.spinnerIcon }, index);
|
|
33
|
+
} else if ((!inProgress || index != messages.length - 1) && !message.content && message.function_call) {
|
|
34
|
+
return /* @__PURE__ */ jsx("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: context.labels.done }, index);
|
|
35
|
+
} else {
|
|
36
|
+
return /* @__PURE__ */ jsx("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: /* @__PURE__ */ jsx(Markdown, { content: message.content }) }, index);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}),
|
|
40
|
+
/* @__PURE__ */ jsx("div", { ref: messagesEndRef })
|
|
41
|
+
] });
|
|
42
|
+
};
|
|
43
|
+
function makeInitialMessages(initial) {
|
|
44
|
+
let initialArray = [];
|
|
45
|
+
if (initial) {
|
|
46
|
+
if (Array.isArray(initial)) {
|
|
47
|
+
initialArray.push(...initial);
|
|
48
|
+
} else {
|
|
49
|
+
initialArray.push(initial);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return initialArray.map((message) => ({
|
|
53
|
+
id: nanoid(),
|
|
54
|
+
role: "assistant",
|
|
55
|
+
content: message
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { Messages };
|
|
60
|
+
//# sourceMappingURL=out.js.map
|
|
61
|
+
//# sourceMappingURL=chunk-ZVAH2Z2W.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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J;AAAA,MACF;AAAA,IAgBF,CAAC;AAAA,IACD,oBAAC,SAAI,KAAK,gBAAgB;AAAA,KAC5B;AAEJ;AAEA,SAAS,oBAAoB,SAAwC;AACnE,MAAI,eAAyB,CAAC;AAC9B,MAAI,SAAS;AACX,QAAI,MAAM,QAAQ,OAAO,GAAG;AAC1B,mBAAa,KAAK,GAAG,OAAO;AAAA,IAC9B,OAAO;AACL,mBAAa,KAAK,OAAO;AAAA,IAC3B;AAAA,EACF;AAEA,SAAO,aAAa,IAAI,CAAC,aAAa;AAAA,IACpC,IAAI,OAAO;AAAA,IACX,MAAM;AAAA,IACN,SAAS;AAAA,EACX,EAAE;AACJ","sourcesContent":["import React, { useEffect, useMemo } from \"react\";\nimport { MessagesProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\nimport { nanoid } from \"nanoid\";\nimport { Message } from \"@copilotkit/react-core\";\nimport { Markdown } from \"./Markdown\";\n\nexport const Messages: React.FC<MessagesProps> = ({ messages, inProgress }) => {\n const context = useChatContext();\n const initialMessages = useMemo(\n () => makeInitialMessages(context.labels.initial),\n [context.labels.initial],\n );\n messages = [...initialMessages, ...messages];\n\n const messagesEndRef = React.useRef<HTMLDivElement>(null);\n\n const scrollToBottom = () => {\n if (messagesEndRef.current) {\n messagesEndRef.current.scrollIntoView({\n behavior: \"auto\",\n });\n }\n };\n\n useEffect(() => {\n scrollToBottom();\n }, [messages]);\n\n return (\n <div className=\"copilotKitMessages\">\n {messages.map((message, index) => {\n const isCurrentMessage = index === messages.length - 1;\n\n if (message.role === \"user\") {\n return (\n <div key={index} className=\"copilotKitMessage copilotKitUserMessage\">\n {message.content}\n </div>\n );\n } else if (message.role == \"assistant\") {\n if (isCurrentMessage && inProgress && !message.content) {\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {context.icons.spinnerIcon}\n </div>\n );\n } else if (\n (!inProgress || index != messages.length - 1) &&\n !message.content &&\n message.function_call\n ) {\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {context.labels.done}\n </div>\n );\n }\n // TODO: Add back partial message\n // This shows up when the assistant is executing a function\n //\n // else if (message.status === \"partial\") {\n // return (\n // <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n // {context.labels.thinking} {context.icons.spinnerIcon}\n // </div>\n // );\n // }\n else {\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n <Markdown content={message.content} />\n </div>\n );\n }\n }\n // TODO: Add back function and error messages\n //\n // else if (message.role === \"function\" && message.status === \"success\") {\n // return (\n // <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n // {context.labels.done}\n // </div>\n // );\n // } else if (message.status === \"error\") {\n // return (\n // <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n // {context.labels.error}\n // </div>\n // );\n // }\n })}\n <div ref={messagesEndRef} />\n </div>\n );\n};\n\nfunction makeInitialMessages(initial?: string | string[]): Message[] {\n let initialArray: string[] = [];\n if (initial) {\n if (Array.isArray(initial)) {\n initialArray.push(...initial);\n } else {\n initialArray.push(initial);\n }\n }\n\n return initialArray.map((message) => ({\n id: nanoid(),\n role: \"assistant\",\n content: message,\n }));\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { CopilotKitChatIcons, CopilotKitChatLabels } from './ChatContext.js';
|
|
3
|
+
import { SystemMessageFunction } from '@copilotkit/react-core';
|
|
4
|
+
import { WindowProps, ButtonProps, HeaderProps, MessagesProps, InputProps, ResponseButtonProps } from './props.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Props for CopilotKitChat component.
|
|
8
|
+
*/
|
|
9
|
+
interface CopilotKitChatProps {
|
|
10
|
+
/**
|
|
11
|
+
* Custom instructions to be added to the system message. Use this property to
|
|
12
|
+
* provide additional context or guidance to the language model, influencing
|
|
13
|
+
* its responses. These instructions can include specific directions,
|
|
14
|
+
* preferences, or criteria that the model should consider when generating
|
|
15
|
+
* its output, thereby tailoring the conversation more precisely to the
|
|
16
|
+
* user's needs or the application's requirements.
|
|
17
|
+
*/
|
|
18
|
+
instructions?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Whether the chat window should be open by default.
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
defaultOpen?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* If the chat window should close when the user clicks outside of it.
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
clickOutsideToClose?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* If the chat window should close when the user hits the Escape key.
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
hitEscapeToClose?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* A callback that gets called when the chat window opens or closes.
|
|
36
|
+
*/
|
|
37
|
+
onSetOpen?: (open: boolean) => void;
|
|
38
|
+
/**
|
|
39
|
+
* The hotkey to open the chat window.
|
|
40
|
+
* Uses Command-<hotkey> on a Mac and Ctrl-<hotkey> on Windows.
|
|
41
|
+
* @default "e"
|
|
42
|
+
*/
|
|
43
|
+
hotkey?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Icons can be used to set custom icons for the chat window.
|
|
46
|
+
*/
|
|
47
|
+
icons?: CopilotKitChatIcons;
|
|
48
|
+
/**
|
|
49
|
+
* Labels can be used to set custom labels for the chat window.
|
|
50
|
+
*/
|
|
51
|
+
labels?: CopilotKitChatLabels;
|
|
52
|
+
/**
|
|
53
|
+
* A function that takes in context string and instructions and returns
|
|
54
|
+
* the system message to include in the chat request.
|
|
55
|
+
* Use this to completely override the system message, when providing
|
|
56
|
+
* instructions is not enough.
|
|
57
|
+
*/
|
|
58
|
+
makeSystemMessage?: SystemMessageFunction;
|
|
59
|
+
/**
|
|
60
|
+
* Whether to show the response button.
|
|
61
|
+
* @default true
|
|
62
|
+
*/
|
|
63
|
+
showResponseButton?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* A custom Window component to use instead of the default.
|
|
66
|
+
*/
|
|
67
|
+
Window?: React__default.ComponentType<WindowProps>;
|
|
68
|
+
/**
|
|
69
|
+
* A custom Button component to use instead of the default.
|
|
70
|
+
*/
|
|
71
|
+
Button?: React__default.ComponentType<ButtonProps>;
|
|
72
|
+
/**
|
|
73
|
+
* A custom Header component to use instead of the default.
|
|
74
|
+
*/
|
|
75
|
+
Header?: React__default.ComponentType<HeaderProps>;
|
|
76
|
+
/**
|
|
77
|
+
* A custom Messages component to use instead of the default.
|
|
78
|
+
*/
|
|
79
|
+
Messages?: React__default.ComponentType<MessagesProps>;
|
|
80
|
+
/**
|
|
81
|
+
* A custom Input component to use instead of the default.
|
|
82
|
+
*/
|
|
83
|
+
Input?: React__default.ComponentType<InputProps>;
|
|
84
|
+
/**
|
|
85
|
+
* A custom ResponseButton component to use instead of the default.
|
|
86
|
+
*/
|
|
87
|
+
ResponseButton?: React__default.ComponentType<ResponseButtonProps>;
|
|
88
|
+
/**
|
|
89
|
+
* A class name to apply to the root element.
|
|
90
|
+
*/
|
|
91
|
+
className?: string;
|
|
92
|
+
}
|
|
93
|
+
declare const CopilotKitChat: React__default.FC<CopilotKitChatProps>;
|
|
94
|
+
|
|
95
|
+
export { CopilotKitChat, CopilotKitChatProps };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { CopilotKitChat } from '../../chunk-DN3OI5WF.mjs';
|
|
2
|
+
import '../../chunk-47SYBLI2.mjs';
|
|
3
|
+
import '../../chunk-QFASQEFJ.mjs';
|
|
4
|
+
import '../../chunk-ZVAH2Z2W.mjs';
|
|
5
|
+
import '../../chunk-UIRFLYXI.mjs';
|
|
6
|
+
import '../../chunk-GPEJCUWA.mjs';
|
|
7
|
+
import '../../chunk-WM6BS77F.mjs';
|
|
8
|
+
import '../../chunk-Y2RUG4B3.mjs';
|
|
9
|
+
import '../../chunk-NXWVWC33.mjs';
|
|
10
|
+
import '../../chunk-DPUPEOGG.mjs';
|
|
11
|
+
import '../../chunk-6H3Y2XEI.mjs';
|
|
12
|
+
import '../../chunk-7YXG7D47.mjs';
|
|
13
|
+
import '../../chunk-POVINPXX.mjs';
|
|
14
|
+
import '../../chunk-MRXNTQOX.mjs';
|
|
15
|
+
//# sourceMappingURL=out.js.map
|
|
16
|
+
//# sourceMappingURL=Chat.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|