@copilotkit/react-ui 0.15.0-alpha.8 → 0.15.0-alpha.9
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 +148 -168
- package/CHANGELOG.md +12 -0
- package/dist/chunk-3M4HWSE7.mjs +13 -7
- package/dist/chunk-3M4HWSE7.mjs.map +1 -1
- package/dist/chunk-47SYBLI2.mjs +5 -5
- package/dist/chunk-47SYBLI2.mjs.map +1 -1
- package/dist/chunk-5O2MCJZ2.mjs +8 -4
- package/dist/chunk-5O2MCJZ2.mjs.map +1 -1
- package/dist/chunk-7NSRDJ5C.mjs +0 -2
- package/dist/chunk-7NSRDJ5C.mjs.map +1 -1
- package/dist/chunk-7YXG7D47.mjs +20 -4
- package/dist/chunk-7YXG7D47.mjs.map +1 -1
- package/dist/chunk-CKJXXQ2W.mjs +13 -6
- package/dist/chunk-CKJXXQ2W.mjs.map +1 -1
- package/dist/chunk-DPRH4HX3.mjs +20 -10
- package/dist/chunk-DPRH4HX3.mjs.map +1 -1
- package/dist/chunk-GWGHQNRI.mjs +17 -9
- package/dist/chunk-GWGHQNRI.mjs.map +1 -1
- package/dist/chunk-H4VKQGVU.mjs +0 -2
- package/dist/chunk-H4VKQGVU.mjs.map +1 -1
- package/dist/chunk-IU3WTXLQ.mjs +0 -2
- package/dist/chunk-IU3WTXLQ.mjs.map +1 -1
- package/dist/chunk-JD7BAH7U.mjs +0 -2
- package/dist/chunk-JD7BAH7U.mjs.map +1 -1
- package/dist/chunk-KBGIPFXA.mjs +12 -5
- package/dist/chunk-KBGIPFXA.mjs.map +1 -1
- package/dist/chunk-MRXNTQOX.mjs +6 -2
- package/dist/chunk-MRXNTQOX.mjs.map +1 -1
- package/dist/chunk-NNVWLSYK.mjs +32 -14
- package/dist/chunk-NNVWLSYK.mjs.map +1 -1
- package/dist/chunk-NYLOXKYT.mjs +12 -6
- package/dist/chunk-NYLOXKYT.mjs.map +1 -1
- package/dist/chunk-OF66AL5Z.mjs +22 -6
- package/dist/chunk-OF66AL5Z.mjs.map +1 -1
- package/dist/chunk-P4GBO6MW.mjs +0 -2
- package/dist/chunk-P4GBO6MW.mjs.map +1 -1
- package/dist/chunk-POVINPXX.mjs +4 -4
- package/dist/chunk-POVINPXX.mjs.map +1 -1
- package/dist/chunk-UWPFPWAW.mjs +8 -4
- package/dist/chunk-UWPFPWAW.mjs.map +1 -1
- package/dist/chunk-WB3YULQ4.mjs +0 -2
- package/dist/chunk-WB3YULQ4.mjs.map +1 -1
- package/dist/chunk-WM6BS77F.mjs +5 -5
- package/dist/chunk-WM6BS77F.mjs.map +1 -1
- package/dist/chunk-Z34F3WLK.mjs +8 -4
- package/dist/chunk-Z34F3WLK.mjs.map +1 -1
- package/dist/components/chat/Button.js +48 -15
- package/dist/components/chat/Button.js.map +1 -1
- package/dist/components/chat/Button.mjs +9 -5
- package/dist/components/chat/Button.mjs.map +1 -1
- package/dist/components/chat/Chat.js +204 -138
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +19 -15
- package/dist/components/chat/Chat.mjs.map +1 -1
- package/dist/components/chat/ChatContext.js +71 -37
- package/dist/components/chat/ChatContext.js.map +1 -1
- package/dist/components/chat/ChatContext.mjs +12 -4
- package/dist/components/chat/ChatContext.mjs.map +1 -1
- package/dist/components/chat/CodeBlock.js +75 -53
- package/dist/components/chat/CodeBlock.js.map +1 -1
- package/dist/components/chat/CodeBlock.mjs +14 -5
- package/dist/components/chat/CodeBlock.mjs.map +1 -1
- package/dist/components/chat/Header.js +48 -15
- package/dist/components/chat/Header.js.map +1 -1
- package/dist/components/chat/Header.mjs +9 -5
- package/dist/components/chat/Header.mjs.map +1 -1
- package/dist/components/chat/Icons.js +73 -42
- package/dist/components/chat/Icons.js.map +1 -1
- package/dist/components/chat/Icons.mjs +27 -3
- package/dist/components/chat/Icons.mjs.map +1 -1
- package/dist/components/chat/Input.js +64 -26
- package/dist/components/chat/Input.js.map +1 -1
- package/dist/components/chat/Input.mjs +10 -6
- package/dist/components/chat/Input.mjs.map +1 -1
- package/dist/components/chat/Markdown.js +86 -66
- package/dist/components/chat/Markdown.js.map +1 -1
- package/dist/components/chat/Markdown.mjs +10 -6
- package/dist/components/chat/Markdown.mjs.map +1 -1
- package/dist/components/chat/Messages.js +113 -79
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +12 -8
- package/dist/components/chat/Messages.mjs.map +1 -1
- package/dist/components/chat/Popup.js +210 -139
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +20 -16
- package/dist/components/chat/Popup.mjs.map +1 -1
- package/dist/components/chat/Response.js +47 -14
- package/dist/components/chat/Response.js.map +1 -1
- package/dist/components/chat/Response.mjs +9 -5
- package/dist/components/chat/Response.mjs.map +1 -1
- package/dist/components/chat/Sidebar.js +213 -141
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +20 -16
- package/dist/components/chat/Sidebar.mjs.map +1 -1
- package/dist/components/chat/Textarea.js +32 -14
- package/dist/components/chat/Textarea.js.map +1 -1
- package/dist/components/chat/Textarea.mjs +7 -3
- package/dist/components/chat/Textarea.mjs.map +1 -1
- package/dist/components/chat/Window.js +45 -17
- package/dist/components/chat/Window.js.map +1 -1
- package/dist/components/chat/Window.mjs +7 -3
- package/dist/components/chat/Window.mjs.map +1 -1
- package/dist/components/chat/index.js +219 -143
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +26 -19
- package/dist/components/chat/index.mjs.map +1 -1
- package/dist/components/chat/props.js +17 -2
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/chat/props.mjs +1 -2
- package/dist/components/chat/props.mjs.map +1 -1
- package/dist/components/index.js +219 -143
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +27 -20
- package/dist/components/index.mjs.map +1 -1
- package/dist/context/index.js +17 -2
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +1 -2
- package/dist/context/index.mjs.map +1 -1
- package/dist/hooks/index.js +17 -2
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +1 -2
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/hooks/use-copy-to-clipboard.js +40 -26
- package/dist/hooks/use-copy-to-clipboard.js.map +1 -1
- package/dist/hooks/use-copy-to-clipboard.mjs +8 -3
- package/dist/hooks/use-copy-to-clipboard.mjs.map +1 -1
- package/dist/index.js +219 -143
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -23
- package/dist/index.mjs.map +1 -1
- package/dist/lib/utils.js +40 -14
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/utils.mjs +13 -7
- package/dist/lib/utils.mjs.map +1 -1
- package/dist/lib/utils.test.js +1 -2
- package/dist/lib/utils.test.js.map +1 -1
- package/dist/lib/utils.test.mjs +0 -1
- package/dist/lib/utils.test.mjs.map +1 -1
- package/dist/types/index.js +17 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +1 -2
- package/dist/types/index.mjs.map +1 -1
- package/dist/types/types.js +17 -2
- package/dist/types/types.js.map +1 -1
- package/dist/types/types.mjs +0 -2
- package/dist/types/types.mjs.map +1 -1
- package/package.json +8 -8
|
@@ -1,44 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
-
var reactCore = require('@copilotkit/react-core');
|
|
6
|
-
var nanoid = require('nanoid');
|
|
7
|
-
var ReactMarkdown = require('react-markdown');
|
|
8
|
-
var reactSyntaxHighlighter = require('react-syntax-highlighter');
|
|
9
|
-
var prism = require('react-syntax-highlighter/dist/esm/styles/prism');
|
|
10
|
-
var remarkGfm = require('remark-gfm');
|
|
11
|
-
var remarkMath = require('remark-math');
|
|
12
|
-
|
|
13
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
-
|
|
15
|
-
function _interopNamespace(e) {
|
|
16
|
-
if (e && e.__esModule) return e;
|
|
17
|
-
var n = Object.create(null);
|
|
18
|
-
if (e) {
|
|
19
|
-
Object.keys(e).forEach(function (k) {
|
|
20
|
-
if (k !== 'default') {
|
|
21
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
22
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function () { return e[k]; }
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
n.default = e;
|
|
30
|
-
return Object.freeze(n);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
34
|
-
var ReactMarkdown__default = /*#__PURE__*/_interopDefault(ReactMarkdown);
|
|
35
|
-
var remarkGfm__default = /*#__PURE__*/_interopDefault(remarkGfm);
|
|
36
|
-
var remarkMath__default = /*#__PURE__*/_interopDefault(remarkMath);
|
|
37
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
38
3
|
var __defProp = Object.defineProperty;
|
|
39
4
|
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
40
6
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
41
8
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
42
10
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
43
11
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
44
12
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -66,6 +34,27 @@ var __objRest = (source, exclude) => {
|
|
|
66
34
|
}
|
|
67
35
|
return target;
|
|
68
36
|
};
|
|
37
|
+
var __export = (target, all) => {
|
|
38
|
+
for (var name in all)
|
|
39
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
40
|
+
};
|
|
41
|
+
var __copyProps = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
+
for (let key of __getOwnPropNames(from))
|
|
44
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
46
|
+
}
|
|
47
|
+
return to;
|
|
48
|
+
};
|
|
49
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
50
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
51
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
52
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
53
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
54
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
55
|
+
mod
|
|
56
|
+
));
|
|
57
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
69
58
|
var __async = (__this, __arguments, generator) => {
|
|
70
59
|
return new Promise((resolve, reject) => {
|
|
71
60
|
var fulfilled = (value) => {
|
|
@@ -86,7 +75,23 @@ var __async = (__this, __arguments, generator) => {
|
|
|
86
75
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
87
76
|
});
|
|
88
77
|
};
|
|
89
|
-
|
|
78
|
+
|
|
79
|
+
// src/components/chat/Popup.tsx
|
|
80
|
+
var Popup_exports = {};
|
|
81
|
+
__export(Popup_exports, {
|
|
82
|
+
CopilotPopup: () => CopilotPopup
|
|
83
|
+
});
|
|
84
|
+
module.exports = __toCommonJS(Popup_exports);
|
|
85
|
+
|
|
86
|
+
// src/components/chat/Chat.tsx
|
|
87
|
+
var import_react8 = __toESM(require("react"));
|
|
88
|
+
|
|
89
|
+
// src/components/chat/ChatContext.tsx
|
|
90
|
+
var import_react = __toESM(require("react"));
|
|
91
|
+
|
|
92
|
+
// src/components/chat/Icons.tsx
|
|
93
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
94
|
+
var OpenIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
90
95
|
"svg",
|
|
91
96
|
{
|
|
92
97
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -94,7 +99,7 @@ var OpenIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
94
99
|
fill: "currentColor",
|
|
95
100
|
width: "24",
|
|
96
101
|
height: "24",
|
|
97
|
-
children: /* @__PURE__ */
|
|
102
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", { transform: "translate(24, 0) scale(-1, 1)", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
98
103
|
"path",
|
|
99
104
|
{
|
|
100
105
|
fillRule: "evenodd",
|
|
@@ -104,7 +109,7 @@ var OpenIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
104
109
|
) })
|
|
105
110
|
}
|
|
106
111
|
);
|
|
107
|
-
var CloseIcon = /* @__PURE__ */
|
|
112
|
+
var CloseIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
108
113
|
"svg",
|
|
109
114
|
{
|
|
110
115
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -114,10 +119,10 @@ var CloseIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
114
119
|
stroke: "currentColor",
|
|
115
120
|
width: "24",
|
|
116
121
|
height: "24",
|
|
117
|
-
children: /* @__PURE__ */
|
|
122
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" })
|
|
118
123
|
}
|
|
119
124
|
);
|
|
120
|
-
var HeaderCloseIcon = /* @__PURE__ */
|
|
125
|
+
var HeaderCloseIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
121
126
|
"svg",
|
|
122
127
|
{
|
|
123
128
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -127,10 +132,10 @@ var HeaderCloseIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
127
132
|
stroke: "currentColor",
|
|
128
133
|
width: "24",
|
|
129
134
|
height: "24",
|
|
130
|
-
children: /* @__PURE__ */
|
|
135
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
|
|
131
136
|
}
|
|
132
137
|
);
|
|
133
|
-
var SendIcon = /* @__PURE__ */
|
|
138
|
+
var SendIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
134
139
|
"svg",
|
|
135
140
|
{
|
|
136
141
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -140,7 +145,7 @@ var SendIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
140
145
|
stroke: "currentColor",
|
|
141
146
|
width: "24",
|
|
142
147
|
height: "24",
|
|
143
|
-
children: /* @__PURE__ */
|
|
148
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
144
149
|
"path",
|
|
145
150
|
{
|
|
146
151
|
strokeLinecap: "round",
|
|
@@ -150,7 +155,7 @@ var SendIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
150
155
|
)
|
|
151
156
|
}
|
|
152
157
|
);
|
|
153
|
-
var SpinnerIcon = /* @__PURE__ */
|
|
158
|
+
var SpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
154
159
|
"svg",
|
|
155
160
|
{
|
|
156
161
|
style: {
|
|
@@ -163,7 +168,7 @@ var SpinnerIcon = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
|
163
168
|
fill: "none",
|
|
164
169
|
viewBox: "0 0 24 24",
|
|
165
170
|
children: [
|
|
166
|
-
/* @__PURE__ */
|
|
171
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
167
172
|
"circle",
|
|
168
173
|
{
|
|
169
174
|
style: { opacity: 0.25 },
|
|
@@ -174,7 +179,7 @@ var SpinnerIcon = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
|
174
179
|
strokeWidth: "4"
|
|
175
180
|
}
|
|
176
181
|
),
|
|
177
|
-
/* @__PURE__ */
|
|
182
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
178
183
|
"path",
|
|
179
184
|
{
|
|
180
185
|
style: { opacity: 0.75 },
|
|
@@ -185,7 +190,7 @@ var SpinnerIcon = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
|
185
190
|
]
|
|
186
191
|
}
|
|
187
192
|
);
|
|
188
|
-
var ActivityIcon = /* @__PURE__ */
|
|
193
|
+
var ActivityIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
189
194
|
"svg",
|
|
190
195
|
{
|
|
191
196
|
style: {
|
|
@@ -199,15 +204,15 @@ var ActivityIcon = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
|
199
204
|
xmlns: "http://www.w3.org/2000/svg",
|
|
200
205
|
fill: "currentColor",
|
|
201
206
|
children: [
|
|
202
|
-
/* @__PURE__ */
|
|
203
|
-
/* @__PURE__ */
|
|
204
|
-
/* @__PURE__ */
|
|
207
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { className: "copilotKitActivityDot1", cx: "4", cy: "12", r: "3" }),
|
|
208
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { className: "copilotKitActivityDot1 copilotKitActivityDot2", cx: "12", cy: "12", r: "3" }),
|
|
209
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { className: "copilotKitActivityDot1 copilotKitActivityDot3", cx: "20", cy: "12", r: "3" })
|
|
205
210
|
]
|
|
206
211
|
}
|
|
207
212
|
);
|
|
208
213
|
function CheckIcon(_a) {
|
|
209
214
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
210
|
-
return /* @__PURE__ */
|
|
215
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
211
216
|
"svg",
|
|
212
217
|
__spreadProps(__spreadValues({
|
|
213
218
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -216,13 +221,13 @@ function CheckIcon(_a) {
|
|
|
216
221
|
style: { height: "1rem", width: "1rem" },
|
|
217
222
|
className
|
|
218
223
|
}, props), {
|
|
219
|
-
children: /* @__PURE__ */
|
|
224
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.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" })
|
|
220
225
|
})
|
|
221
226
|
);
|
|
222
227
|
}
|
|
223
228
|
function DownloadIcon(_a) {
|
|
224
229
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
225
|
-
return /* @__PURE__ */
|
|
230
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
226
231
|
"svg",
|
|
227
232
|
__spreadProps(__spreadValues({
|
|
228
233
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -231,13 +236,13 @@ function DownloadIcon(_a) {
|
|
|
231
236
|
style: { height: "1rem", width: "1rem" },
|
|
232
237
|
className
|
|
233
238
|
}, props), {
|
|
234
|
-
children: /* @__PURE__ */
|
|
239
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.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" })
|
|
235
240
|
})
|
|
236
241
|
);
|
|
237
242
|
}
|
|
238
243
|
function CopyIcon(_a) {
|
|
239
244
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
240
|
-
return /* @__PURE__ */
|
|
245
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
241
246
|
"svg",
|
|
242
247
|
__spreadProps(__spreadValues({
|
|
243
248
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -246,33 +251,36 @@ function CopyIcon(_a) {
|
|
|
246
251
|
style: { height: "1rem", width: "1rem" },
|
|
247
252
|
className
|
|
248
253
|
}, props), {
|
|
249
|
-
children: /* @__PURE__ */
|
|
254
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.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" })
|
|
250
255
|
})
|
|
251
256
|
);
|
|
252
257
|
}
|
|
253
|
-
var StopIcon = /* @__PURE__ */
|
|
258
|
+
var StopIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
254
259
|
"svg",
|
|
255
260
|
{
|
|
256
261
|
xmlns: "http://www.w3.org/2000/svg",
|
|
257
262
|
viewBox: "0 0 256 256",
|
|
258
263
|
fill: "currentColor",
|
|
259
264
|
style: { height: "1rem", width: "1rem" },
|
|
260
|
-
children: /* @__PURE__ */
|
|
265
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("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" })
|
|
261
266
|
}
|
|
262
267
|
);
|
|
263
|
-
var RegenerateIcon = /* @__PURE__ */
|
|
268
|
+
var RegenerateIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
264
269
|
"svg",
|
|
265
270
|
{
|
|
266
271
|
xmlns: "http://www.w3.org/2000/svg",
|
|
267
272
|
viewBox: "0 0 256 256",
|
|
268
273
|
fill: "currentColor",
|
|
269
274
|
style: { height: "1rem", width: "1rem" },
|
|
270
|
-
children: /* @__PURE__ */
|
|
275
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("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" })
|
|
271
276
|
}
|
|
272
277
|
);
|
|
273
|
-
|
|
278
|
+
|
|
279
|
+
// src/components/chat/ChatContext.tsx
|
|
280
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
281
|
+
var ChatContext = import_react.default.createContext(void 0);
|
|
274
282
|
function useChatContext() {
|
|
275
|
-
const context =
|
|
283
|
+
const context = import_react.default.useContext(ChatContext);
|
|
276
284
|
if (context === void 0) {
|
|
277
285
|
throw new Error(
|
|
278
286
|
"Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?"
|
|
@@ -288,7 +296,7 @@ var ChatContextProvider = ({
|
|
|
288
296
|
icons,
|
|
289
297
|
children
|
|
290
298
|
}) => {
|
|
291
|
-
const context =
|
|
299
|
+
const context = (0, import_react.useMemo)(
|
|
292
300
|
() => ({
|
|
293
301
|
labels: __spreadValues(__spreadValues({}, {
|
|
294
302
|
initial: "",
|
|
@@ -315,8 +323,15 @@ var ChatContextProvider = ({
|
|
|
315
323
|
}),
|
|
316
324
|
[labels, icons]
|
|
317
325
|
);
|
|
318
|
-
return /* @__PURE__ */
|
|
326
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ChatContext.Provider, { value: context, children });
|
|
319
327
|
};
|
|
328
|
+
|
|
329
|
+
// src/components/chat/Chat.tsx
|
|
330
|
+
var import_react_core = require("@copilotkit/react-core");
|
|
331
|
+
|
|
332
|
+
// src/components/chat/Window.tsx
|
|
333
|
+
var import_react2 = __toESM(require("react"));
|
|
334
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
320
335
|
var Window = ({
|
|
321
336
|
open,
|
|
322
337
|
setOpen,
|
|
@@ -325,8 +340,8 @@ var Window = ({
|
|
|
325
340
|
hotkey,
|
|
326
341
|
hitEscapeToClose
|
|
327
342
|
}) => {
|
|
328
|
-
const windowRef =
|
|
329
|
-
const handleClickOutside =
|
|
343
|
+
const windowRef = import_react2.default.useRef(null);
|
|
344
|
+
const handleClickOutside = (0, import_react2.useCallback)(
|
|
330
345
|
(event) => {
|
|
331
346
|
var _a;
|
|
332
347
|
if (!clickOutsideToClose) {
|
|
@@ -339,7 +354,7 @@ var Window = ({
|
|
|
339
354
|
},
|
|
340
355
|
[clickOutsideToClose, open, setOpen]
|
|
341
356
|
);
|
|
342
|
-
const handleKeyDown =
|
|
357
|
+
const handleKeyDown = (0, import_react2.useCallback)(
|
|
343
358
|
(event) => {
|
|
344
359
|
var _a;
|
|
345
360
|
const target = event.target;
|
|
@@ -353,7 +368,7 @@ var Window = ({
|
|
|
353
368
|
},
|
|
354
369
|
[hitEscapeToClose, hotkey, open, setOpen]
|
|
355
370
|
);
|
|
356
|
-
const adjustForMobile =
|
|
371
|
+
const adjustForMobile = (0, import_react2.useCallback)(() => {
|
|
357
372
|
const copilotKitWindow = windowRef.current;
|
|
358
373
|
const vv = window.visualViewport;
|
|
359
374
|
if (!copilotKitWindow || !vv) {
|
|
@@ -384,7 +399,7 @@ var Window = ({
|
|
|
384
399
|
document.body.removeEventListener("touchmove", preventScroll);
|
|
385
400
|
}
|
|
386
401
|
}, [open]);
|
|
387
|
-
|
|
402
|
+
(0, import_react2.useEffect)(() => {
|
|
388
403
|
document.addEventListener("mousedown", handleClickOutside);
|
|
389
404
|
document.addEventListener("keydown", handleKeyDown);
|
|
390
405
|
if (window.visualViewport) {
|
|
@@ -399,7 +414,7 @@ var Window = ({
|
|
|
399
414
|
}
|
|
400
415
|
};
|
|
401
416
|
}, [adjustForMobile, handleClickOutside, handleKeyDown]);
|
|
402
|
-
return /* @__PURE__ */
|
|
417
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `copilotKitWindow${open ? " open" : ""}`, ref: windowRef, children });
|
|
403
418
|
};
|
|
404
419
|
var preventScroll = (event) => {
|
|
405
420
|
let targetElement = event.target;
|
|
@@ -419,29 +434,51 @@ var preventScroll = (event) => {
|
|
|
419
434
|
function isMacOS() {
|
|
420
435
|
return /Mac|iMac|Macintosh/i.test(navigator.userAgent);
|
|
421
436
|
}
|
|
437
|
+
|
|
438
|
+
// src/components/chat/Button.tsx
|
|
439
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
422
440
|
var Button = ({ open, setOpen }) => {
|
|
423
441
|
const context = useChatContext();
|
|
424
|
-
return /* @__PURE__ */
|
|
442
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { onClick: () => setOpen(!open), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
425
443
|
"button",
|
|
426
444
|
{
|
|
427
445
|
className: `copilotKitButton ${open ? "open" : ""}`,
|
|
428
446
|
"aria-label": open ? "Close Chat" : "Open Chat",
|
|
429
447
|
children: [
|
|
430
|
-
/* @__PURE__ */
|
|
431
|
-
/* @__PURE__ */
|
|
448
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "copilotKitButtonIcon copilotKitButtonIconOpen", children: context.icons.openIcon }),
|
|
449
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "copilotKitButtonIcon copilotKitButtonIconClose", children: context.icons.closeIcon })
|
|
432
450
|
]
|
|
433
451
|
}
|
|
434
452
|
) });
|
|
435
453
|
};
|
|
454
|
+
|
|
455
|
+
// src/components/chat/Header.tsx
|
|
456
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
436
457
|
var Header = ({ setOpen }) => {
|
|
437
458
|
const context = useChatContext();
|
|
438
|
-
return /* @__PURE__ */
|
|
439
|
-
/* @__PURE__ */
|
|
440
|
-
/* @__PURE__ */
|
|
459
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "copilotKitHeader", children: [
|
|
460
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: context.labels.title }),
|
|
461
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { onClick: () => setOpen(false), "aria-label": "Close", children: context.icons.headerCloseIcon })
|
|
441
462
|
] });
|
|
442
463
|
};
|
|
464
|
+
|
|
465
|
+
// src/components/chat/Messages.tsx
|
|
466
|
+
var import_react5 = __toESM(require("react"));
|
|
467
|
+
var import_nanoid = require("nanoid");
|
|
468
|
+
|
|
469
|
+
// src/components/chat/Markdown.tsx
|
|
470
|
+
var import_react4 = require("react");
|
|
471
|
+
var import_react_markdown = __toESM(require("react-markdown"));
|
|
472
|
+
|
|
473
|
+
// src/components/chat/CodeBlock.tsx
|
|
474
|
+
var import_react3 = require("react");
|
|
475
|
+
var import_react_syntax_highlighter = require("react-syntax-highlighter");
|
|
476
|
+
var import_prism = require("react-syntax-highlighter/dist/esm/styles/prism");
|
|
477
|
+
|
|
478
|
+
// src/hooks/use-copy-to-clipboard.tsx
|
|
479
|
+
var React3 = __toESM(require("react"));
|
|
443
480
|
function useCopyToClipboard({ timeout = 2e3 }) {
|
|
444
|
-
const [isCopied, setIsCopied] =
|
|
481
|
+
const [isCopied, setIsCopied] = React3.useState(false);
|
|
445
482
|
const copyToClipboard = (value) => {
|
|
446
483
|
var _a;
|
|
447
484
|
if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
|
|
@@ -459,6 +496,9 @@ function useCopyToClipboard({ timeout = 2e3 }) {
|
|
|
459
496
|
};
|
|
460
497
|
return { isCopied, copyToClipboard };
|
|
461
498
|
}
|
|
499
|
+
|
|
500
|
+
// src/components/chat/CodeBlock.tsx
|
|
501
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
462
502
|
var programmingLanguages = {
|
|
463
503
|
javascript: ".js",
|
|
464
504
|
python: ".py",
|
|
@@ -493,7 +533,7 @@ var generateRandomString = (length, lowercase = false) => {
|
|
|
493
533
|
}
|
|
494
534
|
return lowercase ? result.toLowerCase() : result;
|
|
495
535
|
};
|
|
496
|
-
var CodeBlock =
|
|
536
|
+
var CodeBlock = (0, import_react3.memo)(({ language, value }) => {
|
|
497
537
|
const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
|
|
498
538
|
const downloadAsFile = () => {
|
|
499
539
|
if (typeof window === "undefined") {
|
|
@@ -521,25 +561,25 @@ var CodeBlock = React.memo(({ language, value }) => {
|
|
|
521
561
|
return;
|
|
522
562
|
copyToClipboard(value);
|
|
523
563
|
};
|
|
524
|
-
return /* @__PURE__ */
|
|
525
|
-
/* @__PURE__ */
|
|
526
|
-
/* @__PURE__ */
|
|
527
|
-
/* @__PURE__ */
|
|
528
|
-
/* @__PURE__ */
|
|
529
|
-
/* @__PURE__ */
|
|
530
|
-
/* @__PURE__ */
|
|
564
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitCodeBlock", children: [
|
|
565
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitCodeBlockToolbar", children: [
|
|
566
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "copilotKitCodeBlockToolbarLanguage", children: language }),
|
|
567
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitCodeBlockToolbarButtons", children: [
|
|
568
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: downloadAsFile, children: [
|
|
569
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DownloadIcon, {}),
|
|
570
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "sr-only", children: "Download" })
|
|
531
571
|
] }),
|
|
532
|
-
/* @__PURE__ */
|
|
533
|
-
isCopied ? /* @__PURE__ */
|
|
534
|
-
/* @__PURE__ */
|
|
572
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: onCopy, children: [
|
|
573
|
+
isCopied ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CopyIcon, {}),
|
|
574
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "sr-only", children: "Copy code" })
|
|
535
575
|
] })
|
|
536
576
|
] })
|
|
537
577
|
] }),
|
|
538
|
-
/* @__PURE__ */
|
|
539
|
-
|
|
578
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
579
|
+
import_react_syntax_highlighter.Prism,
|
|
540
580
|
{
|
|
541
581
|
language,
|
|
542
|
-
style:
|
|
582
|
+
style: import_prism.vscDarkPlus,
|
|
543
583
|
PreTag: "div",
|
|
544
584
|
customStyle: {
|
|
545
585
|
margin: 0,
|
|
@@ -552,22 +592,27 @@ var CodeBlock = React.memo(({ language, value }) => {
|
|
|
552
592
|
] });
|
|
553
593
|
});
|
|
554
594
|
CodeBlock.displayName = "CodeBlock";
|
|
555
|
-
|
|
556
|
-
|
|
595
|
+
|
|
596
|
+
// src/components/chat/Markdown.tsx
|
|
597
|
+
var import_remark_gfm = __toESM(require("remark-gfm"));
|
|
598
|
+
var import_remark_math = __toESM(require("remark-math"));
|
|
599
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
600
|
+
var MemoizedReactMarkdown = (0, import_react4.memo)(
|
|
601
|
+
import_react_markdown.default,
|
|
557
602
|
(prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className
|
|
558
603
|
);
|
|
559
604
|
var Markdown = ({ content }) => {
|
|
560
|
-
return /* @__PURE__ */
|
|
605
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MemoizedReactMarkdown, { components, remarkPlugins: [import_remark_gfm.default, import_remark_math.default], children: content }) });
|
|
561
606
|
};
|
|
562
607
|
var components = {
|
|
563
608
|
p({ children }) {
|
|
564
|
-
return /* @__PURE__ */
|
|
609
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { children });
|
|
565
610
|
},
|
|
566
611
|
code(_a) {
|
|
567
612
|
var _b = _a, { children, className, inline } = _b, props = __objRest(_b, ["children", "className", "inline"]);
|
|
568
613
|
if (children.length) {
|
|
569
614
|
if (children[0] == "\u258D") {
|
|
570
|
-
return /* @__PURE__ */
|
|
615
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
571
616
|
"span",
|
|
572
617
|
{
|
|
573
618
|
style: {
|
|
@@ -582,9 +627,9 @@ var components = {
|
|
|
582
627
|
}
|
|
583
628
|
const match = /language-(\w+)/.exec(className || "");
|
|
584
629
|
if (inline) {
|
|
585
|
-
return /* @__PURE__ */
|
|
630
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", __spreadProps(__spreadValues({ className }, props), { children }));
|
|
586
631
|
}
|
|
587
|
-
return /* @__PURE__ */
|
|
632
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
588
633
|
CodeBlock,
|
|
589
634
|
__spreadValues({
|
|
590
635
|
language: match && match[1] || "",
|
|
@@ -594,14 +639,17 @@ var components = {
|
|
|
594
639
|
);
|
|
595
640
|
}
|
|
596
641
|
};
|
|
642
|
+
|
|
643
|
+
// src/components/chat/Messages.tsx
|
|
644
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
597
645
|
var Messages = ({ messages, inProgress }) => {
|
|
598
646
|
const context = useChatContext();
|
|
599
|
-
const initialMessages =
|
|
647
|
+
const initialMessages = (0, import_react5.useMemo)(
|
|
600
648
|
() => makeInitialMessages(context.labels.initial),
|
|
601
649
|
[context.labels.initial]
|
|
602
650
|
);
|
|
603
651
|
messages = [...initialMessages, ...messages];
|
|
604
|
-
const messagesEndRef =
|
|
652
|
+
const messagesEndRef = import_react5.default.useRef(null);
|
|
605
653
|
const scrollToBottom = () => {
|
|
606
654
|
if (messagesEndRef.current) {
|
|
607
655
|
messagesEndRef.current.scrollIntoView({
|
|
@@ -609,25 +657,25 @@ var Messages = ({ messages, inProgress }) => {
|
|
|
609
657
|
});
|
|
610
658
|
}
|
|
611
659
|
};
|
|
612
|
-
|
|
660
|
+
(0, import_react5.useEffect)(() => {
|
|
613
661
|
scrollToBottom();
|
|
614
662
|
}, [messages]);
|
|
615
|
-
return /* @__PURE__ */
|
|
663
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "copilotKitMessages", children: [
|
|
616
664
|
messages.map((message, index) => {
|
|
617
665
|
const isCurrentMessage = index === messages.length - 1;
|
|
618
666
|
if (message.role === "user") {
|
|
619
|
-
return /* @__PURE__ */
|
|
667
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "copilotKitMessage copilotKitUserMessage", children: message.content }, index);
|
|
620
668
|
} else if (message.role == "assistant") {
|
|
621
669
|
if (isCurrentMessage && inProgress && !message.content) {
|
|
622
|
-
return /* @__PURE__ */
|
|
670
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: context.icons.spinnerIcon }, index);
|
|
623
671
|
} else if ((!inProgress || index != messages.length - 1) && !message.content && message.function_call) {
|
|
624
|
-
return /* @__PURE__ */
|
|
672
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: context.labels.done }, index);
|
|
625
673
|
} else {
|
|
626
|
-
return /* @__PURE__ */
|
|
674
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Markdown, { content: message.content }) }, index);
|
|
627
675
|
}
|
|
628
676
|
}
|
|
629
677
|
}),
|
|
630
|
-
/* @__PURE__ */
|
|
678
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: messagesEndRef })
|
|
631
679
|
] });
|
|
632
680
|
};
|
|
633
681
|
function makeInitialMessages(initial) {
|
|
@@ -640,17 +688,24 @@ function makeInitialMessages(initial) {
|
|
|
640
688
|
}
|
|
641
689
|
}
|
|
642
690
|
return initialArray.map((message) => ({
|
|
643
|
-
id:
|
|
691
|
+
id: (0, import_nanoid.nanoid)(),
|
|
644
692
|
role: "assistant",
|
|
645
693
|
content: message
|
|
646
694
|
}));
|
|
647
695
|
}
|
|
648
|
-
|
|
696
|
+
|
|
697
|
+
// src/components/chat/Input.tsx
|
|
698
|
+
var import_react7 = require("react");
|
|
699
|
+
|
|
700
|
+
// src/components/chat/Textarea.tsx
|
|
701
|
+
var import_react6 = require("react");
|
|
702
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
703
|
+
var AutoResizingTextarea = (0, import_react6.forwardRef)(
|
|
649
704
|
({ maxRows = 1, placeholder, value, onChange, onKeyDown, autoFocus }, ref) => {
|
|
650
|
-
const internalTextareaRef =
|
|
651
|
-
const [maxHeight, setMaxHeight] =
|
|
652
|
-
|
|
653
|
-
|
|
705
|
+
const internalTextareaRef = (0, import_react6.useRef)(null);
|
|
706
|
+
const [maxHeight, setMaxHeight] = (0, import_react6.useState)(0);
|
|
707
|
+
(0, import_react6.useImperativeHandle)(ref, () => internalTextareaRef.current);
|
|
708
|
+
(0, import_react6.useEffect)(() => {
|
|
654
709
|
const calculateMaxHeight = () => {
|
|
655
710
|
const textarea = internalTextareaRef.current;
|
|
656
711
|
if (textarea) {
|
|
@@ -664,14 +719,14 @@ var AutoResizingTextarea = React.forwardRef(
|
|
|
664
719
|
};
|
|
665
720
|
calculateMaxHeight();
|
|
666
721
|
}, [maxRows]);
|
|
667
|
-
|
|
722
|
+
(0, import_react6.useEffect)(() => {
|
|
668
723
|
const textarea = internalTextareaRef.current;
|
|
669
724
|
if (textarea) {
|
|
670
725
|
textarea.style.height = "auto";
|
|
671
726
|
textarea.style.height = `${Math.min(textarea.scrollHeight, maxHeight)}px`;
|
|
672
727
|
}
|
|
673
728
|
}, [value, maxHeight]);
|
|
674
|
-
return /* @__PURE__ */
|
|
729
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
675
730
|
"textarea",
|
|
676
731
|
{
|
|
677
732
|
ref: internalTextareaRef,
|
|
@@ -690,16 +745,19 @@ var AutoResizingTextarea = React.forwardRef(
|
|
|
690
745
|
}
|
|
691
746
|
);
|
|
692
747
|
var Textarea_default = AutoResizingTextarea;
|
|
748
|
+
|
|
749
|
+
// src/components/chat/Input.tsx
|
|
750
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
693
751
|
var Input = ({ inProgress, onSend, children }) => {
|
|
694
752
|
const context = useChatContext();
|
|
695
|
-
const textareaRef =
|
|
753
|
+
const textareaRef = (0, import_react7.useRef)(null);
|
|
696
754
|
const handleDivClick = (event) => {
|
|
697
755
|
var _a;
|
|
698
756
|
if (event.target !== event.currentTarget)
|
|
699
757
|
return;
|
|
700
758
|
(_a = textareaRef.current) == null ? void 0 : _a.focus();
|
|
701
759
|
};
|
|
702
|
-
const [text, setText] =
|
|
760
|
+
const [text, setText] = (0, import_react7.useState)("");
|
|
703
761
|
const send = () => {
|
|
704
762
|
var _a;
|
|
705
763
|
if (inProgress)
|
|
@@ -710,10 +768,10 @@ var Input = ({ inProgress, onSend, children }) => {
|
|
|
710
768
|
};
|
|
711
769
|
const icon = inProgress ? context.icons.activityIcon : context.icons.sendIcon;
|
|
712
770
|
const disabled = inProgress || text.length === 0;
|
|
713
|
-
return /* @__PURE__ */
|
|
714
|
-
/* @__PURE__ */
|
|
715
|
-
/* @__PURE__ */
|
|
716
|
-
/* @__PURE__ */
|
|
771
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
|
|
772
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children }),
|
|
773
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { className: "copilotKitSendButton", disabled, onClick: send, children: icon }),
|
|
774
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
717
775
|
Textarea_default,
|
|
718
776
|
{
|
|
719
777
|
ref: textareaRef,
|
|
@@ -732,13 +790,22 @@ var Input = ({ inProgress, onSend, children }) => {
|
|
|
732
790
|
)
|
|
733
791
|
] });
|
|
734
792
|
};
|
|
793
|
+
|
|
794
|
+
// src/components/chat/Chat.tsx
|
|
795
|
+
var import_nanoid2 = require("nanoid");
|
|
796
|
+
|
|
797
|
+
// src/components/chat/Response.tsx
|
|
798
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
735
799
|
var ResponseButton = ({ onClick, inProgress }) => {
|
|
736
800
|
const context = useChatContext();
|
|
737
|
-
return /* @__PURE__ */
|
|
738
|
-
/* @__PURE__ */
|
|
801
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("button", { onClick, className: "copilotKitResponseButton", children: [
|
|
802
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: inProgress ? context.icons.stopIcon : context.icons.regenerateIcon }),
|
|
739
803
|
inProgress ? context.labels.stopGenerating : context.labels.regenerateResponse
|
|
740
804
|
] });
|
|
741
805
|
};
|
|
806
|
+
|
|
807
|
+
// src/components/chat/Chat.tsx
|
|
808
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
742
809
|
var CopilotChat = ({
|
|
743
810
|
instructions,
|
|
744
811
|
defaultOpen = false,
|
|
@@ -758,26 +825,26 @@ var CopilotChat = ({
|
|
|
758
825
|
ResponseButton: ResponseButton2 = ResponseButton,
|
|
759
826
|
className
|
|
760
827
|
}) => {
|
|
761
|
-
const { visibleMessages, append, reload, stop, isLoading, input, setInput } =
|
|
762
|
-
id:
|
|
828
|
+
const { visibleMessages, append, reload, stop, isLoading, input, setInput } = (0, import_react_core.useCopilotChat)({
|
|
829
|
+
id: (0, import_nanoid2.nanoid)(),
|
|
763
830
|
makeSystemMessage,
|
|
764
831
|
additionalInstructions: instructions
|
|
765
832
|
});
|
|
766
|
-
const [openState, setOpenState] =
|
|
833
|
+
const [openState, setOpenState] = import_react8.default.useState(defaultOpen);
|
|
767
834
|
const setOpen = (open) => {
|
|
768
835
|
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
769
836
|
setOpenState(open);
|
|
770
837
|
};
|
|
771
838
|
const sendMessage = (message) => __async(void 0, null, function* () {
|
|
772
839
|
append({
|
|
773
|
-
id:
|
|
840
|
+
id: (0, import_nanoid2.nanoid)(),
|
|
774
841
|
content: message,
|
|
775
842
|
role: "user"
|
|
776
843
|
});
|
|
777
844
|
});
|
|
778
|
-
return /* @__PURE__ */
|
|
779
|
-
/* @__PURE__ */
|
|
780
|
-
/* @__PURE__ */
|
|
845
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChatContextProvider, { icons, labels, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className, children: [
|
|
846
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button2, { open: openState, setOpen }),
|
|
847
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
781
848
|
Window2,
|
|
782
849
|
{
|
|
783
850
|
open: openState,
|
|
@@ -786,21 +853,25 @@ var CopilotChat = ({
|
|
|
786
853
|
hotkey,
|
|
787
854
|
hitEscapeToClose,
|
|
788
855
|
children: [
|
|
789
|
-
/* @__PURE__ */
|
|
790
|
-
/* @__PURE__ */
|
|
791
|
-
/* @__PURE__ */
|
|
856
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Header2, { open: openState, setOpen }),
|
|
857
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Messages2, { messages: visibleMessages, inProgress: isLoading }),
|
|
858
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Input2, { inProgress: isLoading, onSend: sendMessage, children: showResponseButton && visibleMessages.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ResponseButton2, { onClick: isLoading ? stop : reload, inProgress: isLoading }) })
|
|
792
859
|
]
|
|
793
860
|
}
|
|
794
861
|
)
|
|
795
862
|
] }) });
|
|
796
863
|
};
|
|
864
|
+
|
|
865
|
+
// src/components/chat/Popup.tsx
|
|
866
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
797
867
|
var CopilotPopup = (props) => {
|
|
798
868
|
props = __spreadProps(__spreadValues({}, props), {
|
|
799
869
|
className: props.className ? props.className + " copilotKitPopup" : "copilotKitPopup"
|
|
800
870
|
});
|
|
801
|
-
return /* @__PURE__ */
|
|
871
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CopilotChat, __spreadValues({}, props));
|
|
802
872
|
};
|
|
803
|
-
|
|
804
|
-
exports
|
|
805
|
-
|
|
873
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
874
|
+
0 && (module.exports = {
|
|
875
|
+
CopilotPopup
|
|
876
|
+
});
|
|
806
877
|
//# sourceMappingURL=Popup.js.map
|