@kopexa/assistant 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/dist/chunk-OLZG7MMU.mjs +300 -0
- package/dist/chunk-S247BNPZ.mjs +94 -0
- package/dist/chunk-UIXG4SXX.mjs +103 -0
- package/dist/conversation.d.mts +34 -0
- package/dist/conversation.d.ts +34 -0
- package/dist/conversation.js +121 -0
- package/dist/conversation.mjs +14 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +519 -0
- package/dist/index.mjs +43 -0
- package/dist/message.d.mts +97 -0
- package/dist/message.d.ts +97 -0
- package/dist/message.js +328 -0
- package/dist/message.mjs +30 -0
- package/dist/prompt-input.d.mts +22 -0
- package/dist/prompt-input.d.ts +22 -0
- package/dist/prompt-input.js +123 -0
- package/dist/prompt-input.mjs +8 -0
- package/package.json +61 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
Conversation: () => Conversation,
|
|
25
|
+
ConversationContent: () => ConversationContent,
|
|
26
|
+
ConversationEmptyState: () => ConversationEmptyState,
|
|
27
|
+
ConversationScrollButton: () => ConversationScrollButton,
|
|
28
|
+
Message: () => Message,
|
|
29
|
+
MessageAction: () => MessageAction,
|
|
30
|
+
MessageActions: () => MessageActions,
|
|
31
|
+
MessageBranch: () => MessageBranch,
|
|
32
|
+
MessageBranchContent: () => MessageBranchContent,
|
|
33
|
+
MessageBranchNext: () => MessageBranchNext,
|
|
34
|
+
MessageBranchPage: () => MessageBranchPage,
|
|
35
|
+
MessageBranchPrevious: () => MessageBranchPrevious,
|
|
36
|
+
MessageBranchSelector: () => MessageBranchSelector,
|
|
37
|
+
MessageContent: () => MessageContent,
|
|
38
|
+
MessageResponse: () => MessageResponse,
|
|
39
|
+
MessageToolbar: () => MessageToolbar,
|
|
40
|
+
PromptInput: () => PromptInput
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(index_exports);
|
|
43
|
+
|
|
44
|
+
// src/conversation.tsx
|
|
45
|
+
var import_button = require("@kopexa/button");
|
|
46
|
+
var import_icons = require("@kopexa/icons");
|
|
47
|
+
var import_shared_utils = require("@kopexa/shared-utils");
|
|
48
|
+
var import_theme = require("@kopexa/theme");
|
|
49
|
+
var import_react = require("react");
|
|
50
|
+
var import_use_stick_to_bottom = require("use-stick-to-bottom");
|
|
51
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
52
|
+
var styles = (0, import_theme.conversation)();
|
|
53
|
+
function Conversation({ className, ...props }) {
|
|
54
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
55
|
+
import_use_stick_to_bottom.StickToBottom,
|
|
56
|
+
{
|
|
57
|
+
className: (0, import_shared_utils.cn)(styles.root(), className),
|
|
58
|
+
initial: "smooth",
|
|
59
|
+
resize: "smooth",
|
|
60
|
+
role: "log",
|
|
61
|
+
"data-slot": "conversation",
|
|
62
|
+
...props
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
Conversation.displayName = "Conversation";
|
|
67
|
+
function ConversationContent({
|
|
68
|
+
className,
|
|
69
|
+
...props
|
|
70
|
+
}) {
|
|
71
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
72
|
+
import_use_stick_to_bottom.StickToBottom.Content,
|
|
73
|
+
{
|
|
74
|
+
className: (0, import_shared_utils.cn)(styles.content(), className),
|
|
75
|
+
"data-slot": "conversation-content",
|
|
76
|
+
...props
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
ConversationContent.displayName = "ConversationContent";
|
|
81
|
+
function ConversationEmptyState({
|
|
82
|
+
className,
|
|
83
|
+
title = "No messages yet",
|
|
84
|
+
description = "Start a conversation to see messages here",
|
|
85
|
+
icon,
|
|
86
|
+
children,
|
|
87
|
+
...props
|
|
88
|
+
}) {
|
|
89
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
90
|
+
"div",
|
|
91
|
+
{
|
|
92
|
+
className: (0, import_shared_utils.cn)(styles.emptyState(), className),
|
|
93
|
+
"data-slot": "conversation-empty-state",
|
|
94
|
+
...props,
|
|
95
|
+
children: children != null ? children : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
96
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.emptyStateIcon(), children: icon }),
|
|
97
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-1", children: [
|
|
98
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: styles.emptyStateTitle(), children: title }),
|
|
99
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: styles.emptyStateDescription(), children: description })
|
|
100
|
+
] })
|
|
101
|
+
] })
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
ConversationEmptyState.displayName = "ConversationEmptyState";
|
|
106
|
+
function ConversationScrollButton({
|
|
107
|
+
className,
|
|
108
|
+
...props
|
|
109
|
+
}) {
|
|
110
|
+
const { isAtBottom, scrollToBottom } = (0, import_use_stick_to_bottom.useStickToBottomContext)();
|
|
111
|
+
const handleScrollToBottom = (0, import_react.useCallback)(() => {
|
|
112
|
+
scrollToBottom();
|
|
113
|
+
}, [scrollToBottom]);
|
|
114
|
+
return !isAtBottom && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
115
|
+
import_button.Button,
|
|
116
|
+
{
|
|
117
|
+
className: (0, import_shared_utils.cn)(styles.scrollButton(), className),
|
|
118
|
+
onClick: handleScrollToBottom,
|
|
119
|
+
isIconOnly: true,
|
|
120
|
+
type: "button",
|
|
121
|
+
variant: "outline",
|
|
122
|
+
"data-slot": "conversation-scroll-button",
|
|
123
|
+
...props,
|
|
124
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.ArrowDown, { className: "size-4" })
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
ConversationScrollButton.displayName = "ConversationScrollButton";
|
|
129
|
+
|
|
130
|
+
// src/message.tsx
|
|
131
|
+
var import_button2 = require("@kopexa/button");
|
|
132
|
+
var import_icons2 = require("@kopexa/icons");
|
|
133
|
+
var import_shared_utils2 = require("@kopexa/shared-utils");
|
|
134
|
+
var import_theme2 = require("@kopexa/theme");
|
|
135
|
+
var import_tooltip = require("@kopexa/tooltip");
|
|
136
|
+
var import_react2 = require("react");
|
|
137
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
138
|
+
var styles2 = (0, import_theme2.message)();
|
|
139
|
+
function Message({ className, from, ...props }) {
|
|
140
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
141
|
+
"div",
|
|
142
|
+
{
|
|
143
|
+
className: (0, import_shared_utils2.cn)(styles2.root({ from }), className),
|
|
144
|
+
"data-slot": "message",
|
|
145
|
+
"data-from": from,
|
|
146
|
+
...props
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
Message.displayName = "Message";
|
|
151
|
+
function MessageContent({
|
|
152
|
+
children,
|
|
153
|
+
className,
|
|
154
|
+
...props
|
|
155
|
+
}) {
|
|
156
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
157
|
+
"div",
|
|
158
|
+
{
|
|
159
|
+
className: (0, import_shared_utils2.cn)(styles2.content(), className),
|
|
160
|
+
"data-slot": "message-content",
|
|
161
|
+
...props,
|
|
162
|
+
children
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
MessageContent.displayName = "MessageContent";
|
|
167
|
+
function MessageActions({
|
|
168
|
+
className,
|
|
169
|
+
children,
|
|
170
|
+
...props
|
|
171
|
+
}) {
|
|
172
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
173
|
+
"div",
|
|
174
|
+
{
|
|
175
|
+
className: (0, import_shared_utils2.cn)(styles2.actions(), className),
|
|
176
|
+
"data-slot": "message-actions",
|
|
177
|
+
...props,
|
|
178
|
+
children
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
MessageActions.displayName = "MessageActions";
|
|
183
|
+
function MessageAction({
|
|
184
|
+
tooltip,
|
|
185
|
+
children,
|
|
186
|
+
label,
|
|
187
|
+
variant = "ghost",
|
|
188
|
+
size = "sm",
|
|
189
|
+
...props
|
|
190
|
+
}) {
|
|
191
|
+
var _a;
|
|
192
|
+
const ariaLabel = (_a = label != null ? label : tooltip) != null ? _a : "";
|
|
193
|
+
const button = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
194
|
+
import_button2.IconButton,
|
|
195
|
+
{
|
|
196
|
+
size,
|
|
197
|
+
type: "button",
|
|
198
|
+
variant,
|
|
199
|
+
"aria-label": ariaLabel,
|
|
200
|
+
...props,
|
|
201
|
+
children
|
|
202
|
+
}
|
|
203
|
+
);
|
|
204
|
+
if (tooltip) {
|
|
205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_tooltip.Tooltip, { content: tooltip, children: button });
|
|
206
|
+
}
|
|
207
|
+
return button;
|
|
208
|
+
}
|
|
209
|
+
MessageAction.displayName = "MessageAction";
|
|
210
|
+
function MessageToolbar({
|
|
211
|
+
className,
|
|
212
|
+
children,
|
|
213
|
+
...props
|
|
214
|
+
}) {
|
|
215
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
216
|
+
"div",
|
|
217
|
+
{
|
|
218
|
+
className: (0, import_shared_utils2.cn)(styles2.toolbar(), className),
|
|
219
|
+
"data-slot": "message-toolbar",
|
|
220
|
+
...props,
|
|
221
|
+
children
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
MessageToolbar.displayName = "MessageToolbar";
|
|
226
|
+
var MessageBranchContext = (0, import_react2.createContext)(
|
|
227
|
+
null
|
|
228
|
+
);
|
|
229
|
+
function useMessageBranch() {
|
|
230
|
+
const context = (0, import_react2.useContext)(MessageBranchContext);
|
|
231
|
+
if (!context) {
|
|
232
|
+
throw new Error(
|
|
233
|
+
"MessageBranch components must be used within MessageBranch"
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
return context;
|
|
237
|
+
}
|
|
238
|
+
function MessageBranch({
|
|
239
|
+
defaultBranch = 0,
|
|
240
|
+
onBranchChange,
|
|
241
|
+
className,
|
|
242
|
+
children,
|
|
243
|
+
...props
|
|
244
|
+
}) {
|
|
245
|
+
const [currentBranch, setCurrentBranch] = (0, import_react2.useState)(defaultBranch);
|
|
246
|
+
const [branches, setBranches] = (0, import_react2.useState)([]);
|
|
247
|
+
const handleBranchChange = (0, import_react2.useCallback)(
|
|
248
|
+
(newBranch) => {
|
|
249
|
+
setCurrentBranch(newBranch);
|
|
250
|
+
onBranchChange == null ? void 0 : onBranchChange(newBranch);
|
|
251
|
+
},
|
|
252
|
+
[onBranchChange]
|
|
253
|
+
);
|
|
254
|
+
const goToPrevious = (0, import_react2.useCallback)(() => {
|
|
255
|
+
const newBranch = currentBranch > 0 ? currentBranch - 1 : branches.length - 1;
|
|
256
|
+
handleBranchChange(newBranch);
|
|
257
|
+
}, [currentBranch, branches.length, handleBranchChange]);
|
|
258
|
+
const goToNext = (0, import_react2.useCallback)(() => {
|
|
259
|
+
const newBranch = currentBranch < branches.length - 1 ? currentBranch + 1 : 0;
|
|
260
|
+
handleBranchChange(newBranch);
|
|
261
|
+
}, [currentBranch, branches.length, handleBranchChange]);
|
|
262
|
+
const contextValue = {
|
|
263
|
+
currentBranch,
|
|
264
|
+
totalBranches: branches.length,
|
|
265
|
+
goToPrevious,
|
|
266
|
+
goToNext,
|
|
267
|
+
branches,
|
|
268
|
+
setBranches
|
|
269
|
+
};
|
|
270
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MessageBranchContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
271
|
+
"div",
|
|
272
|
+
{
|
|
273
|
+
className: (0, import_shared_utils2.cn)(styles2.branchRoot(), className),
|
|
274
|
+
"data-slot": "message-branch",
|
|
275
|
+
...props,
|
|
276
|
+
children
|
|
277
|
+
}
|
|
278
|
+
) });
|
|
279
|
+
}
|
|
280
|
+
MessageBranch.displayName = "MessageBranch";
|
|
281
|
+
function MessageBranchContent({
|
|
282
|
+
children,
|
|
283
|
+
...props
|
|
284
|
+
}) {
|
|
285
|
+
const { currentBranch, setBranches, branches } = useMessageBranch();
|
|
286
|
+
const childrenArray = Array.isArray(children) ? children : [children];
|
|
287
|
+
(0, import_react2.useEffect)(() => {
|
|
288
|
+
if (branches.length !== childrenArray.length) {
|
|
289
|
+
setBranches(childrenArray);
|
|
290
|
+
}
|
|
291
|
+
}, [childrenArray, branches, setBranches]);
|
|
292
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: childrenArray.map((branch, index) => {
|
|
293
|
+
var _a;
|
|
294
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
295
|
+
"div",
|
|
296
|
+
{
|
|
297
|
+
className: (0, import_shared_utils2.cn)(
|
|
298
|
+
styles2.branchContent(),
|
|
299
|
+
index === currentBranch ? "block" : "hidden"
|
|
300
|
+
),
|
|
301
|
+
"data-slot": "message-branch-content",
|
|
302
|
+
...props,
|
|
303
|
+
children: branch
|
|
304
|
+
},
|
|
305
|
+
(_a = branch.key) != null ? _a : index
|
|
306
|
+
);
|
|
307
|
+
}) });
|
|
308
|
+
}
|
|
309
|
+
MessageBranchContent.displayName = "MessageBranchContent";
|
|
310
|
+
function MessageBranchSelector({
|
|
311
|
+
className,
|
|
312
|
+
children,
|
|
313
|
+
...props
|
|
314
|
+
}) {
|
|
315
|
+
const { totalBranches } = useMessageBranch();
|
|
316
|
+
if (totalBranches <= 1) {
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
320
|
+
"div",
|
|
321
|
+
{
|
|
322
|
+
className: (0, import_shared_utils2.cn)(styles2.branchSelector(), className),
|
|
323
|
+
"data-slot": "message-branch-selector",
|
|
324
|
+
...props,
|
|
325
|
+
children
|
|
326
|
+
}
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
MessageBranchSelector.displayName = "MessageBranchSelector";
|
|
330
|
+
function MessageBranchPrevious({
|
|
331
|
+
children,
|
|
332
|
+
...props
|
|
333
|
+
}) {
|
|
334
|
+
const { goToPrevious, totalBranches } = useMessageBranch();
|
|
335
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
336
|
+
import_button2.IconButton,
|
|
337
|
+
{
|
|
338
|
+
"aria-label": "Previous branch",
|
|
339
|
+
disabled: totalBranches <= 1,
|
|
340
|
+
onClick: goToPrevious,
|
|
341
|
+
size: "sm",
|
|
342
|
+
type: "button",
|
|
343
|
+
variant: "ghost",
|
|
344
|
+
...props,
|
|
345
|
+
children: children != null ? children : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons2.ChevronLeftIcon, { className: "size-4" })
|
|
346
|
+
}
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
MessageBranchPrevious.displayName = "MessageBranchPrevious";
|
|
350
|
+
function MessageBranchNext({
|
|
351
|
+
children,
|
|
352
|
+
...props
|
|
353
|
+
}) {
|
|
354
|
+
const { goToNext, totalBranches } = useMessageBranch();
|
|
355
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
356
|
+
import_button2.IconButton,
|
|
357
|
+
{
|
|
358
|
+
"aria-label": "Next branch",
|
|
359
|
+
disabled: totalBranches <= 1,
|
|
360
|
+
onClick: goToNext,
|
|
361
|
+
size: "sm",
|
|
362
|
+
type: "button",
|
|
363
|
+
variant: "ghost",
|
|
364
|
+
...props,
|
|
365
|
+
children: children != null ? children : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons2.ChevronRightIcon, { className: "size-4" })
|
|
366
|
+
}
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
MessageBranchNext.displayName = "MessageBranchNext";
|
|
370
|
+
function MessageBranchPage({
|
|
371
|
+
className,
|
|
372
|
+
...props
|
|
373
|
+
}) {
|
|
374
|
+
const { currentBranch, totalBranches } = useMessageBranch();
|
|
375
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
376
|
+
"span",
|
|
377
|
+
{
|
|
378
|
+
className: (0, import_shared_utils2.cn)(styles2.branchPage(), className),
|
|
379
|
+
"data-slot": "message-branch-page",
|
|
380
|
+
...props,
|
|
381
|
+
children: [
|
|
382
|
+
currentBranch + 1,
|
|
383
|
+
" of ",
|
|
384
|
+
totalBranches
|
|
385
|
+
]
|
|
386
|
+
}
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
MessageBranchPage.displayName = "MessageBranchPage";
|
|
390
|
+
var MessageResponse = (0, import_react2.memo)(
|
|
391
|
+
({ className, children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
392
|
+
"div",
|
|
393
|
+
{
|
|
394
|
+
className: (0, import_shared_utils2.cn)(
|
|
395
|
+
"size-full prose prose-sm dark:prose-invert max-w-none",
|
|
396
|
+
"[&>*:first-child]:mt-0 [&>*:last-child]:mb-0",
|
|
397
|
+
className
|
|
398
|
+
),
|
|
399
|
+
"data-slot": "message-response",
|
|
400
|
+
...props,
|
|
401
|
+
children
|
|
402
|
+
}
|
|
403
|
+
)
|
|
404
|
+
);
|
|
405
|
+
MessageResponse.displayName = "MessageResponse";
|
|
406
|
+
|
|
407
|
+
// src/prompt-input.tsx
|
|
408
|
+
var import_button3 = require("@kopexa/button");
|
|
409
|
+
var import_icons3 = require("@kopexa/icons");
|
|
410
|
+
var import_shared_utils3 = require("@kopexa/shared-utils");
|
|
411
|
+
var import_theme3 = require("@kopexa/theme");
|
|
412
|
+
var import_react3 = require("react");
|
|
413
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
414
|
+
var styles3 = (0, import_theme3.promptInput)();
|
|
415
|
+
var PromptInput = (0, import_react3.forwardRef)(
|
|
416
|
+
({
|
|
417
|
+
className,
|
|
418
|
+
placeholder = "Type a message...",
|
|
419
|
+
value,
|
|
420
|
+
onValueChange,
|
|
421
|
+
onSubmit,
|
|
422
|
+
disabled,
|
|
423
|
+
isLoading,
|
|
424
|
+
submitLabel = "Send message",
|
|
425
|
+
...props
|
|
426
|
+
}, ref) => {
|
|
427
|
+
const textareaRef = (0, import_react3.useRef)(null);
|
|
428
|
+
const handleSubmit = (0, import_react3.useCallback)(
|
|
429
|
+
(e) => {
|
|
430
|
+
e.preventDefault();
|
|
431
|
+
const trimmedValue = value == null ? void 0 : value.trim();
|
|
432
|
+
if (trimmedValue && !disabled && !isLoading) {
|
|
433
|
+
onSubmit == null ? void 0 : onSubmit(trimmedValue);
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
[value, disabled, isLoading, onSubmit]
|
|
437
|
+
);
|
|
438
|
+
const handleKeyDown = (0, import_react3.useCallback)(
|
|
439
|
+
(e) => {
|
|
440
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
441
|
+
e.preventDefault();
|
|
442
|
+
const trimmedValue = value == null ? void 0 : value.trim();
|
|
443
|
+
if (trimmedValue && !disabled && !isLoading) {
|
|
444
|
+
onSubmit == null ? void 0 : onSubmit(trimmedValue);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
[value, disabled, isLoading, onSubmit]
|
|
449
|
+
);
|
|
450
|
+
const handleTextareaChange = (0, import_react3.useCallback)(
|
|
451
|
+
(e) => {
|
|
452
|
+
onValueChange == null ? void 0 : onValueChange(e.target.value);
|
|
453
|
+
const textarea = e.target;
|
|
454
|
+
textarea.style.height = "auto";
|
|
455
|
+
textarea.style.height = `${Math.min(textarea.scrollHeight, 200)}px`;
|
|
456
|
+
},
|
|
457
|
+
[onValueChange]
|
|
458
|
+
);
|
|
459
|
+
const canSubmit = !!(value == null ? void 0 : value.trim()) && !disabled && !isLoading;
|
|
460
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: (0, import_shared_utils3.cn)(styles3.root(), className), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
461
|
+
"form",
|
|
462
|
+
{
|
|
463
|
+
ref,
|
|
464
|
+
className: styles3.form(),
|
|
465
|
+
onSubmit: handleSubmit,
|
|
466
|
+
...props,
|
|
467
|
+
children: [
|
|
468
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
469
|
+
"textarea",
|
|
470
|
+
{
|
|
471
|
+
ref: textareaRef,
|
|
472
|
+
className: styles3.textarea(),
|
|
473
|
+
placeholder,
|
|
474
|
+
value,
|
|
475
|
+
onChange: handleTextareaChange,
|
|
476
|
+
onKeyDown: handleKeyDown,
|
|
477
|
+
disabled: disabled || isLoading,
|
|
478
|
+
rows: 1,
|
|
479
|
+
"aria-label": placeholder
|
|
480
|
+
}
|
|
481
|
+
),
|
|
482
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: styles3.actions(), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
483
|
+
import_button3.Button,
|
|
484
|
+
{
|
|
485
|
+
type: "submit",
|
|
486
|
+
isIconOnly: true,
|
|
487
|
+
disabled: !canSubmit,
|
|
488
|
+
isLoading,
|
|
489
|
+
className: styles3.submitButton(),
|
|
490
|
+
"aria-label": submitLabel,
|
|
491
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons3.ArrowUp, { className: "size-4" })
|
|
492
|
+
}
|
|
493
|
+
) })
|
|
494
|
+
]
|
|
495
|
+
}
|
|
496
|
+
) });
|
|
497
|
+
}
|
|
498
|
+
);
|
|
499
|
+
PromptInput.displayName = "PromptInput";
|
|
500
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
501
|
+
0 && (module.exports = {
|
|
502
|
+
Conversation,
|
|
503
|
+
ConversationContent,
|
|
504
|
+
ConversationEmptyState,
|
|
505
|
+
ConversationScrollButton,
|
|
506
|
+
Message,
|
|
507
|
+
MessageAction,
|
|
508
|
+
MessageActions,
|
|
509
|
+
MessageBranch,
|
|
510
|
+
MessageBranchContent,
|
|
511
|
+
MessageBranchNext,
|
|
512
|
+
MessageBranchPage,
|
|
513
|
+
MessageBranchPrevious,
|
|
514
|
+
MessageBranchSelector,
|
|
515
|
+
MessageContent,
|
|
516
|
+
MessageResponse,
|
|
517
|
+
MessageToolbar,
|
|
518
|
+
PromptInput
|
|
519
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Conversation,
|
|
4
|
+
ConversationContent,
|
|
5
|
+
ConversationEmptyState,
|
|
6
|
+
ConversationScrollButton
|
|
7
|
+
} from "./chunk-S247BNPZ.mjs";
|
|
8
|
+
import {
|
|
9
|
+
Message,
|
|
10
|
+
MessageAction,
|
|
11
|
+
MessageActions,
|
|
12
|
+
MessageBranch,
|
|
13
|
+
MessageBranchContent,
|
|
14
|
+
MessageBranchNext,
|
|
15
|
+
MessageBranchPage,
|
|
16
|
+
MessageBranchPrevious,
|
|
17
|
+
MessageBranchSelector,
|
|
18
|
+
MessageContent,
|
|
19
|
+
MessageResponse,
|
|
20
|
+
MessageToolbar
|
|
21
|
+
} from "./chunk-OLZG7MMU.mjs";
|
|
22
|
+
import {
|
|
23
|
+
PromptInput
|
|
24
|
+
} from "./chunk-UIXG4SXX.mjs";
|
|
25
|
+
export {
|
|
26
|
+
Conversation,
|
|
27
|
+
ConversationContent,
|
|
28
|
+
ConversationEmptyState,
|
|
29
|
+
ConversationScrollButton,
|
|
30
|
+
Message,
|
|
31
|
+
MessageAction,
|
|
32
|
+
MessageActions,
|
|
33
|
+
MessageBranch,
|
|
34
|
+
MessageBranchContent,
|
|
35
|
+
MessageBranchNext,
|
|
36
|
+
MessageBranchPage,
|
|
37
|
+
MessageBranchPrevious,
|
|
38
|
+
MessageBranchSelector,
|
|
39
|
+
MessageContent,
|
|
40
|
+
MessageResponse,
|
|
41
|
+
MessageToolbar,
|
|
42
|
+
PromptInput
|
|
43
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { HTMLAttributes, ComponentProps } from 'react';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import { IconButton } from '@kopexa/button';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Role of the message sender
|
|
8
|
+
*/
|
|
9
|
+
type MessageRole = "user" | "assistant" | "system";
|
|
10
|
+
type MessageProps = HTMLAttributes<HTMLDivElement> & {
|
|
11
|
+
/** Role of the message sender */
|
|
12
|
+
from: MessageRole;
|
|
13
|
+
};
|
|
14
|
+
declare function Message({ className, from, ...props }: MessageProps): react_jsx_runtime.JSX.Element;
|
|
15
|
+
declare namespace Message {
|
|
16
|
+
var displayName: string;
|
|
17
|
+
}
|
|
18
|
+
type MessageContentProps = HTMLAttributes<HTMLDivElement>;
|
|
19
|
+
declare function MessageContent({ children, className, ...props }: MessageContentProps): react_jsx_runtime.JSX.Element;
|
|
20
|
+
declare namespace MessageContent {
|
|
21
|
+
var displayName: string;
|
|
22
|
+
}
|
|
23
|
+
type MessageActionsProps = ComponentProps<"div">;
|
|
24
|
+
declare function MessageActions({ className, children, ...props }: MessageActionsProps): react_jsx_runtime.JSX.Element;
|
|
25
|
+
declare namespace MessageActions {
|
|
26
|
+
var displayName: string;
|
|
27
|
+
}
|
|
28
|
+
type MessageActionBaseProps = Omit<ComponentProps<typeof IconButton>, "aria-label" | "tooltip">;
|
|
29
|
+
type MessageActionProps = MessageActionBaseProps & ({
|
|
30
|
+
/** Tooltip text (also used as accessible label if label not provided) */
|
|
31
|
+
tooltip: string;
|
|
32
|
+
/** Accessible label (falls back to tooltip) */
|
|
33
|
+
label?: string;
|
|
34
|
+
} | {
|
|
35
|
+
/** Tooltip text */
|
|
36
|
+
tooltip?: undefined;
|
|
37
|
+
/** Accessible label (required if tooltip not provided) */
|
|
38
|
+
label: string;
|
|
39
|
+
});
|
|
40
|
+
declare function MessageAction({ tooltip, children, label, variant, size, ...props }: MessageActionProps): react_jsx_runtime.JSX.Element;
|
|
41
|
+
declare namespace MessageAction {
|
|
42
|
+
var displayName: string;
|
|
43
|
+
}
|
|
44
|
+
type MessageToolbarProps = ComponentProps<"div">;
|
|
45
|
+
declare function MessageToolbar({ className, children, ...props }: MessageToolbarProps): react_jsx_runtime.JSX.Element;
|
|
46
|
+
declare namespace MessageToolbar {
|
|
47
|
+
var displayName: string;
|
|
48
|
+
}
|
|
49
|
+
type MessageBranchProps = HTMLAttributes<HTMLDivElement> & {
|
|
50
|
+
/** Default branch index */
|
|
51
|
+
defaultBranch?: number;
|
|
52
|
+
/** Callback when branch changes */
|
|
53
|
+
onBranchChange?: (branchIndex: number) => void;
|
|
54
|
+
};
|
|
55
|
+
declare function MessageBranch({ defaultBranch, onBranchChange, className, children, ...props }: MessageBranchProps): react_jsx_runtime.JSX.Element;
|
|
56
|
+
declare namespace MessageBranch {
|
|
57
|
+
var displayName: string;
|
|
58
|
+
}
|
|
59
|
+
type MessageBranchContentProps = HTMLAttributes<HTMLDivElement>;
|
|
60
|
+
declare function MessageBranchContent({ children, ...props }: MessageBranchContentProps): react_jsx_runtime.JSX.Element;
|
|
61
|
+
declare namespace MessageBranchContent {
|
|
62
|
+
var displayName: string;
|
|
63
|
+
}
|
|
64
|
+
type MessageBranchSelectorProps = HTMLAttributes<HTMLDivElement>;
|
|
65
|
+
declare function MessageBranchSelector({ className, children, ...props }: MessageBranchSelectorProps): react_jsx_runtime.JSX.Element | null;
|
|
66
|
+
declare namespace MessageBranchSelector {
|
|
67
|
+
var displayName: string;
|
|
68
|
+
}
|
|
69
|
+
type MessageBranchPreviousProps = Omit<ComponentProps<typeof IconButton>, "aria-label">;
|
|
70
|
+
declare function MessageBranchPrevious({ children, ...props }: MessageBranchPreviousProps): react_jsx_runtime.JSX.Element;
|
|
71
|
+
declare namespace MessageBranchPrevious {
|
|
72
|
+
var displayName: string;
|
|
73
|
+
}
|
|
74
|
+
type MessageBranchNextProps = Omit<ComponentProps<typeof IconButton>, "aria-label">;
|
|
75
|
+
declare function MessageBranchNext({ children, ...props }: MessageBranchNextProps): react_jsx_runtime.JSX.Element;
|
|
76
|
+
declare namespace MessageBranchNext {
|
|
77
|
+
var displayName: string;
|
|
78
|
+
}
|
|
79
|
+
type MessageBranchPageProps = HTMLAttributes<HTMLSpanElement>;
|
|
80
|
+
declare function MessageBranchPage({ className, ...props }: MessageBranchPageProps): react_jsx_runtime.JSX.Element;
|
|
81
|
+
declare namespace MessageBranchPage {
|
|
82
|
+
var displayName: string;
|
|
83
|
+
}
|
|
84
|
+
type MessageResponseProps = HTMLAttributes<HTMLDivElement> & {
|
|
85
|
+
/** Markdown content to render */
|
|
86
|
+
children?: string;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* MessageResponse renders markdown content.
|
|
90
|
+
*
|
|
91
|
+
* Note: This is a basic implementation. For full markdown support with
|
|
92
|
+
* code highlighting, math, and mermaid diagrams, integrate with a
|
|
93
|
+
* markdown renderer like Streamdown or react-markdown.
|
|
94
|
+
*/
|
|
95
|
+
declare const MessageResponse: react.MemoExoticComponent<({ className, children, ...props }: MessageResponseProps) => react_jsx_runtime.JSX.Element>;
|
|
96
|
+
|
|
97
|
+
export { Message, MessageAction, type MessageActionProps, MessageActions, type MessageActionsProps, MessageBranch, MessageBranchContent, type MessageBranchContentProps, MessageBranchNext, type MessageBranchNextProps, MessageBranchPage, type MessageBranchPageProps, MessageBranchPrevious, type MessageBranchPreviousProps, type MessageBranchProps, MessageBranchSelector, type MessageBranchSelectorProps, MessageContent, type MessageContentProps, type MessageProps, MessageResponse, type MessageResponseProps, type MessageRole, MessageToolbar, type MessageToolbarProps };
|