laif-ds 0.1.98 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ui/chat-message.js +296 -122
- package/dist/components/ui/chat.js +150 -119
- package/dist/components/ui/dialog.js +45 -37
- package/dist/components/ui/message-input.js +1 -1
- package/dist/components/ui/message-list.js +21 -17
- package/dist/index.d.ts +12 -3
- package/dist/styles.v3.css +1 -1
- package/package.json +1 -1
|
@@ -1,228 +1,259 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { forwardRef as g, useRef as
|
|
4
|
-
import { cn as
|
|
5
|
-
import { useAutoScroll as
|
|
6
|
-
import { Button as
|
|
7
|
-
import { CopyButton as
|
|
8
|
-
import { MessageInput as
|
|
9
|
-
import { MessageList as
|
|
10
|
-
import { PromptSuggestions as
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
import { jsxs as N, Fragment as T, jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as g, useRef as U, useCallback as I, useState as E } from "react";
|
|
4
|
+
import { cn as M } from "../../lib/utils.js";
|
|
5
|
+
import { useAutoScroll as O } from "../../hooks/use-auto-scroll.js";
|
|
6
|
+
import { Button as w } from "./button.js";
|
|
7
|
+
import { CopyButton as k } from "./copy-button.js";
|
|
8
|
+
import { MessageInput as q } from "./message-input.js";
|
|
9
|
+
import { MessageList as H } from "./message-list.js";
|
|
10
|
+
import { PromptSuggestions as J } from "./prompt-suggestions.js";
|
|
11
|
+
import S from "../../node_modules/lucide-react/dist/esm/icons/save.js";
|
|
12
|
+
import K from "../../node_modules/lucide-react/dist/esm/icons/thumbs-up.js";
|
|
13
|
+
import Q from "../../node_modules/lucide-react/dist/esm/icons/thumbs-down.js";
|
|
14
|
+
import V from "../../node_modules/lucide-react/dist/esm/icons/arrow-down.js";
|
|
15
|
+
function W({
|
|
16
|
+
messages: o,
|
|
17
|
+
handleSubmit: r,
|
|
17
18
|
input: i,
|
|
18
19
|
handleInputChange: u,
|
|
19
|
-
stop:
|
|
20
|
+
stop: a,
|
|
20
21
|
isGenerating: c,
|
|
21
|
-
append:
|
|
22
|
-
suggestions:
|
|
23
|
-
className:
|
|
24
|
-
onRateResponse:
|
|
25
|
-
setMessages:
|
|
26
|
-
transcribeAudio:
|
|
22
|
+
append: f,
|
|
23
|
+
suggestions: m,
|
|
24
|
+
className: v,
|
|
25
|
+
onRateResponse: b,
|
|
26
|
+
setMessages: C,
|
|
27
|
+
transcribeAudio: F,
|
|
28
|
+
allowAttachments: _ = !1,
|
|
29
|
+
onEdit: j,
|
|
30
|
+
onMessageSave: d
|
|
27
31
|
}) {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
const
|
|
33
|
-
(
|
|
32
|
+
const L = o.at(-1), B = o.length === 0, y = L?.role === "user", x = U(o);
|
|
33
|
+
x.current = o;
|
|
34
|
+
const D = I(() => {
|
|
35
|
+
if (a?.(), !C) return;
|
|
36
|
+
const e = [...x.current], l = e.findLast(
|
|
37
|
+
(s) => s.role === "assistant"
|
|
34
38
|
);
|
|
35
39
|
if (!l) return;
|
|
36
|
-
let
|
|
40
|
+
let h = !1, p = { ...l };
|
|
37
41
|
if (l.toolInvocations) {
|
|
38
|
-
const
|
|
39
|
-
(
|
|
40
|
-
...
|
|
42
|
+
const s = l.toolInvocations.map(
|
|
43
|
+
(n) => n.state === "call" ? (h = !0, {
|
|
44
|
+
...n,
|
|
41
45
|
state: "result",
|
|
42
46
|
result: {
|
|
43
47
|
content: "Tool execution was cancelled",
|
|
44
48
|
__cancelled: !0
|
|
45
49
|
// Special marker to indicate cancellation
|
|
46
50
|
}
|
|
47
|
-
}) :
|
|
51
|
+
}) : n
|
|
48
52
|
);
|
|
49
|
-
|
|
50
|
-
...
|
|
51
|
-
toolInvocations:
|
|
53
|
+
h && (p = {
|
|
54
|
+
...p,
|
|
55
|
+
toolInvocations: s
|
|
52
56
|
});
|
|
53
57
|
}
|
|
54
58
|
if (l.parts && l.parts.length > 0) {
|
|
55
|
-
const
|
|
56
|
-
...
|
|
59
|
+
const s = l.parts.map((n) => n.type === "tool-invocation" && n.toolInvocation && n.toolInvocation.state === "call" ? (h = !0, {
|
|
60
|
+
...n,
|
|
57
61
|
toolInvocation: {
|
|
58
|
-
...
|
|
62
|
+
...n.toolInvocation,
|
|
59
63
|
state: "result",
|
|
60
64
|
result: {
|
|
61
65
|
content: "Tool execution was cancelled",
|
|
62
66
|
__cancelled: !0
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
|
-
}) :
|
|
66
|
-
|
|
67
|
-
...
|
|
68
|
-
parts:
|
|
69
|
+
}) : n);
|
|
70
|
+
h && (p = {
|
|
71
|
+
...p,
|
|
72
|
+
parts: s
|
|
69
73
|
});
|
|
70
74
|
}
|
|
71
|
-
if (
|
|
72
|
-
const
|
|
73
|
-
(
|
|
75
|
+
if (h) {
|
|
76
|
+
const s = e.findIndex(
|
|
77
|
+
(n) => n.id === l.id
|
|
74
78
|
);
|
|
75
|
-
|
|
79
|
+
s !== -1 && (e[s] = p, C(e));
|
|
76
80
|
}
|
|
77
|
-
}, [
|
|
78
|
-
(
|
|
79
|
-
actions:
|
|
81
|
+
}, [a, C, x]), P = I(
|
|
82
|
+
(e) => ({
|
|
83
|
+
actions: b ? /* @__PURE__ */ N(T, { children: [
|
|
80
84
|
/* @__PURE__ */ t("div", { className: "border-d-border border-r pr-1", children: /* @__PURE__ */ t(
|
|
81
|
-
|
|
85
|
+
k,
|
|
82
86
|
{
|
|
83
|
-
content:
|
|
87
|
+
content: e.content,
|
|
84
88
|
copyMessage: "Copied response to clipboard!"
|
|
85
89
|
}
|
|
86
90
|
) }),
|
|
91
|
+
d && /* @__PURE__ */ t("div", { className: "border-d-border border-r pr-1", children: /* @__PURE__ */ t(
|
|
92
|
+
w,
|
|
93
|
+
{
|
|
94
|
+
size: "icon",
|
|
95
|
+
variant: "ghost",
|
|
96
|
+
className: "h-6 w-6",
|
|
97
|
+
onClick: () => d(e.id, e.content),
|
|
98
|
+
title: "Save message",
|
|
99
|
+
children: /* @__PURE__ */ t(S, { className: "h-4 w-4" })
|
|
100
|
+
}
|
|
101
|
+
) }),
|
|
87
102
|
/* @__PURE__ */ t(
|
|
88
|
-
|
|
103
|
+
w,
|
|
89
104
|
{
|
|
90
105
|
size: "icon",
|
|
91
106
|
variant: "ghost",
|
|
92
107
|
className: "h-6 w-6",
|
|
93
|
-
onClick: () =>
|
|
94
|
-
children: /* @__PURE__ */ t(
|
|
108
|
+
onClick: () => b(e.id, "thumbs-up"),
|
|
109
|
+
children: /* @__PURE__ */ t(K, { className: "h-4 w-4" })
|
|
95
110
|
}
|
|
96
111
|
),
|
|
97
112
|
/* @__PURE__ */ t(
|
|
98
|
-
|
|
113
|
+
w,
|
|
99
114
|
{
|
|
100
115
|
size: "icon",
|
|
101
116
|
variant: "ghost",
|
|
102
117
|
className: "h-6 w-6",
|
|
103
|
-
onClick: () =>
|
|
104
|
-
children: /* @__PURE__ */ t(
|
|
118
|
+
onClick: () => b(e.id, "thumbs-down"),
|
|
119
|
+
children: /* @__PURE__ */ t(Q, { className: "h-4 w-4" })
|
|
105
120
|
}
|
|
106
121
|
)
|
|
107
|
-
] }) : /* @__PURE__ */
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
122
|
+
] }) : /* @__PURE__ */ N(T, { children: [
|
|
123
|
+
/* @__PURE__ */ t(
|
|
124
|
+
k,
|
|
125
|
+
{
|
|
126
|
+
content: e.content,
|
|
127
|
+
copyMessage: "Copied response to clipboard!"
|
|
128
|
+
}
|
|
129
|
+
),
|
|
130
|
+
d && /* @__PURE__ */ t("div", { className: "border-d-border border-l pl-1", children: /* @__PURE__ */ t(
|
|
131
|
+
w,
|
|
132
|
+
{
|
|
133
|
+
size: "icon",
|
|
134
|
+
variant: "ghost",
|
|
135
|
+
className: "h-6 w-6",
|
|
136
|
+
onClick: () => d(e.id, e.content),
|
|
137
|
+
title: "Save message",
|
|
138
|
+
children: /* @__PURE__ */ t(S, { className: "h-4 w-4" })
|
|
139
|
+
}
|
|
140
|
+
) })
|
|
141
|
+
] }),
|
|
142
|
+
onMessageSave: d
|
|
114
143
|
}),
|
|
115
|
-
[
|
|
144
|
+
[b, d]
|
|
116
145
|
);
|
|
117
|
-
return /* @__PURE__ */
|
|
118
|
-
|
|
119
|
-
|
|
146
|
+
return /* @__PURE__ */ N(z, { className: v, children: [
|
|
147
|
+
B && f && m ? /* @__PURE__ */ t(
|
|
148
|
+
J,
|
|
120
149
|
{
|
|
121
150
|
label: "Try these prompts ✨",
|
|
122
|
-
append:
|
|
123
|
-
suggestions:
|
|
151
|
+
append: f,
|
|
152
|
+
suggestions: m
|
|
124
153
|
}
|
|
125
154
|
) : null,
|
|
126
|
-
|
|
127
|
-
|
|
155
|
+
o.length > 0 ? /* @__PURE__ */ t(X, { messages: o, children: /* @__PURE__ */ t(
|
|
156
|
+
H,
|
|
128
157
|
{
|
|
129
|
-
messages:
|
|
158
|
+
messages: o,
|
|
130
159
|
isTyping: y,
|
|
131
|
-
messageOptions:
|
|
160
|
+
messageOptions: P,
|
|
161
|
+
onEdit: j,
|
|
162
|
+
onMessageSave: d
|
|
132
163
|
}
|
|
133
164
|
) }) : null,
|
|
134
165
|
/* @__PURE__ */ t(
|
|
135
|
-
|
|
166
|
+
A,
|
|
136
167
|
{
|
|
137
168
|
className: "flex-shrink-0",
|
|
138
169
|
isPending: c || y,
|
|
139
|
-
handleSubmit:
|
|
140
|
-
children: ({ files:
|
|
141
|
-
|
|
170
|
+
handleSubmit: r,
|
|
171
|
+
children: ({ files: e, setFiles: l }) => /* @__PURE__ */ t(
|
|
172
|
+
q,
|
|
142
173
|
{
|
|
143
174
|
value: i,
|
|
144
175
|
onChange: u,
|
|
145
|
-
allowAttachments:
|
|
146
|
-
files:
|
|
176
|
+
allowAttachments: _,
|
|
177
|
+
files: e,
|
|
147
178
|
setFiles: l,
|
|
148
|
-
stop:
|
|
179
|
+
stop: D,
|
|
149
180
|
isGenerating: c,
|
|
150
|
-
transcribeAudio:
|
|
181
|
+
transcribeAudio: F
|
|
151
182
|
}
|
|
152
183
|
)
|
|
153
184
|
}
|
|
154
185
|
)
|
|
155
186
|
] });
|
|
156
187
|
}
|
|
157
|
-
|
|
158
|
-
function
|
|
159
|
-
messages:
|
|
160
|
-
children:
|
|
188
|
+
W.displayName = "Chat";
|
|
189
|
+
function X({
|
|
190
|
+
messages: o,
|
|
191
|
+
children: r
|
|
161
192
|
}) {
|
|
162
193
|
const {
|
|
163
194
|
containerRef: i,
|
|
164
195
|
scrollToBottom: u,
|
|
165
|
-
handleScroll:
|
|
196
|
+
handleScroll: a,
|
|
166
197
|
shouldAutoScroll: c,
|
|
167
|
-
handleTouchStart:
|
|
168
|
-
} =
|
|
169
|
-
return /* @__PURE__ */
|
|
198
|
+
handleTouchStart: f
|
|
199
|
+
} = O([o]);
|
|
200
|
+
return /* @__PURE__ */ N(
|
|
170
201
|
"div",
|
|
171
202
|
{
|
|
172
203
|
className: "relative flex-1 overflow-y-auto pb-4",
|
|
173
204
|
ref: i,
|
|
174
|
-
onScroll:
|
|
175
|
-
onTouchStart:
|
|
205
|
+
onScroll: a,
|
|
206
|
+
onTouchStart: f,
|
|
176
207
|
children: [
|
|
177
|
-
/* @__PURE__ */ t("div", { className: "max-w-full", children:
|
|
208
|
+
/* @__PURE__ */ t("div", { className: "max-w-full", children: r }),
|
|
178
209
|
!c && /* @__PURE__ */ t("div", { className: "pointer-events-none absolute right-0 bottom-0 left-0 flex items-end justify-end", children: /* @__PURE__ */ t("div", { className: "sticky bottom-0 left-0 flex w-full justify-end", children: /* @__PURE__ */ t(
|
|
179
|
-
|
|
210
|
+
w,
|
|
180
211
|
{
|
|
181
212
|
onClick: u,
|
|
182
213
|
className: "animate-in fade-in-0 slide-in-from-bottom-1 pointer-events-auto h-8 w-8 rounded-full ease-in-out",
|
|
183
214
|
size: "icon",
|
|
184
215
|
variant: "ghost",
|
|
185
|
-
children: /* @__PURE__ */ t(
|
|
216
|
+
children: /* @__PURE__ */ t(V, { className: "h-4 w-4" })
|
|
186
217
|
}
|
|
187
218
|
) }) })
|
|
188
219
|
]
|
|
189
220
|
}
|
|
190
221
|
);
|
|
191
222
|
}
|
|
192
|
-
const
|
|
223
|
+
const z = g(({ className: o, ...r }, i) => /* @__PURE__ */ t(
|
|
193
224
|
"div",
|
|
194
225
|
{
|
|
195
226
|
ref: i,
|
|
196
|
-
className:
|
|
197
|
-
...
|
|
227
|
+
className: M("flex h-full max-h-full w-full flex-col", o),
|
|
228
|
+
...r
|
|
198
229
|
}
|
|
199
230
|
));
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
({ children:
|
|
203
|
-
const [
|
|
204
|
-
return /* @__PURE__ */ t("form", { ref: u, onSubmit: (
|
|
205
|
-
if (!
|
|
206
|
-
|
|
231
|
+
z.displayName = "ChatContainer";
|
|
232
|
+
const A = g(
|
|
233
|
+
({ children: o, handleSubmit: r, className: i }, u) => {
|
|
234
|
+
const [a, c] = E(null);
|
|
235
|
+
return /* @__PURE__ */ t("form", { ref: u, onSubmit: (m) => {
|
|
236
|
+
if (!a) {
|
|
237
|
+
r(m);
|
|
207
238
|
return;
|
|
208
239
|
}
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
}, className: i, children:
|
|
240
|
+
const v = Y(a);
|
|
241
|
+
r(m, { experimental_attachments: v }), c(null);
|
|
242
|
+
}, className: i, children: o({ files: a, setFiles: c }) });
|
|
212
243
|
}
|
|
213
244
|
);
|
|
214
|
-
|
|
215
|
-
function
|
|
245
|
+
A.displayName = "ChatForm";
|
|
246
|
+
function Y(o) {
|
|
216
247
|
if (typeof window > "u")
|
|
217
248
|
return {};
|
|
218
|
-
const
|
|
219
|
-
for (const i of Array.from(
|
|
220
|
-
|
|
221
|
-
return
|
|
249
|
+
const r = new DataTransfer();
|
|
250
|
+
for (const i of Array.from(o))
|
|
251
|
+
r.items.add(i);
|
|
252
|
+
return r.files;
|
|
222
253
|
}
|
|
223
254
|
export {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
255
|
+
W as Chat,
|
|
256
|
+
z as ChatContainer,
|
|
257
|
+
A as ChatForm,
|
|
258
|
+
X as ChatMessages
|
|
228
259
|
};
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as a, jsxs as n } from "react/jsx-runtime";
|
|
3
|
-
import { Root as
|
|
3
|
+
import { Root as c, Trigger as g, Content as f, Close as l, Title as u, Description as m, Portal as p, Overlay as x } from "../../node_modules/@radix-ui/react-dialog/dist/index.js";
|
|
4
4
|
import { cn as o } from "../../lib/utils.js";
|
|
5
|
-
import
|
|
6
|
-
function
|
|
5
|
+
import D from "../../node_modules/lucide-react/dist/esm/icons/x.js";
|
|
6
|
+
function C({
|
|
7
7
|
...t
|
|
8
8
|
}) {
|
|
9
|
-
return /* @__PURE__ */ a(
|
|
9
|
+
return /* @__PURE__ */ a(c, { "data-slot": "dialog", ...t });
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function k({
|
|
12
12
|
...t
|
|
13
13
|
}) {
|
|
14
|
-
return /* @__PURE__ */ a(
|
|
14
|
+
return /* @__PURE__ */ a(g, { "data-slot": "dialog-trigger", ...t });
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function v({
|
|
17
17
|
...t
|
|
18
18
|
}) {
|
|
19
|
-
return /* @__PURE__ */ a(
|
|
19
|
+
return /* @__PURE__ */ a(p, { "data-slot": "dialog-portal", ...t });
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function T({
|
|
22
22
|
...t
|
|
23
23
|
}) {
|
|
24
|
-
return /* @__PURE__ */ a(
|
|
24
|
+
return /* @__PURE__ */ a(l, { "data-slot": "dialog-close", ...t });
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function b({
|
|
27
27
|
className: t,
|
|
28
28
|
...e
|
|
29
29
|
}) {
|
|
30
30
|
return /* @__PURE__ */ a(
|
|
31
|
-
|
|
31
|
+
x,
|
|
32
32
|
{
|
|
33
33
|
"data-slot": "dialog-overlay",
|
|
34
34
|
className: o(
|
|
@@ -39,29 +39,37 @@ function D({
|
|
|
39
39
|
}
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function j({
|
|
43
43
|
className: t,
|
|
44
44
|
children: e,
|
|
45
|
+
size: r = "default",
|
|
45
46
|
...i
|
|
46
47
|
}) {
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
const d = {
|
|
49
|
+
sm: "sm:max-w-sm",
|
|
50
|
+
default: "sm:max-w-lg",
|
|
51
|
+
lg: "sm:max-w-2xl",
|
|
52
|
+
xl: "sm:max-w-3xl"
|
|
53
|
+
}[r];
|
|
54
|
+
return /* @__PURE__ */ n(v, { "data-slot": "dialog-portal", children: [
|
|
55
|
+
/* @__PURE__ */ a(b, {}),
|
|
49
56
|
/* @__PURE__ */ n(
|
|
50
|
-
|
|
57
|
+
f,
|
|
51
58
|
{
|
|
52
59
|
"data-slot": "dialog-content",
|
|
53
|
-
onPointerDownOutside: (
|
|
54
|
-
|
|
60
|
+
onPointerDownOutside: (s) => {
|
|
61
|
+
s.target?.closest("[data-command-portal]") && s.preventDefault();
|
|
55
62
|
},
|
|
56
63
|
className: o(
|
|
57
|
-
"bg-d-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 border-d-border fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200
|
|
64
|
+
"bg-d-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 border-d-border fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200",
|
|
65
|
+
d,
|
|
58
66
|
t
|
|
59
67
|
),
|
|
60
68
|
...i,
|
|
61
69
|
children: [
|
|
62
70
|
e,
|
|
63
|
-
/* @__PURE__ */ n(
|
|
64
|
-
/* @__PURE__ */ a(
|
|
71
|
+
/* @__PURE__ */ n(l, { className: "ring-offset-d-background focus:ring-d-ring data-[state=open]:bg-d-accent data-[state=open]:text-d-secondary-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", children: [
|
|
72
|
+
/* @__PURE__ */ a(D, {}),
|
|
65
73
|
/* @__PURE__ */ a("span", { className: "sr-only", children: "Close" })
|
|
66
74
|
] })
|
|
67
75
|
]
|
|
@@ -69,7 +77,7 @@ function k({
|
|
|
69
77
|
)
|
|
70
78
|
] });
|
|
71
79
|
}
|
|
72
|
-
function
|
|
80
|
+
function O({ className: t, ...e }) {
|
|
73
81
|
return /* @__PURE__ */ a(
|
|
74
82
|
"div",
|
|
75
83
|
{
|
|
@@ -79,7 +87,7 @@ function T({ className: t, ...e }) {
|
|
|
79
87
|
}
|
|
80
88
|
);
|
|
81
89
|
}
|
|
82
|
-
function
|
|
90
|
+
function P({ className: t, ...e }) {
|
|
83
91
|
return /* @__PURE__ */ a(
|
|
84
92
|
"div",
|
|
85
93
|
{
|
|
@@ -92,12 +100,12 @@ function j({ className: t, ...e }) {
|
|
|
92
100
|
}
|
|
93
101
|
);
|
|
94
102
|
}
|
|
95
|
-
function
|
|
103
|
+
function _({
|
|
96
104
|
className: t,
|
|
97
105
|
...e
|
|
98
106
|
}) {
|
|
99
107
|
return /* @__PURE__ */ a(
|
|
100
|
-
|
|
108
|
+
u,
|
|
101
109
|
{
|
|
102
110
|
"data-slot": "dialog-title",
|
|
103
111
|
className: o("text-lg leading-none font-semibold", t),
|
|
@@ -105,12 +113,12 @@ function O({
|
|
|
105
113
|
}
|
|
106
114
|
);
|
|
107
115
|
}
|
|
108
|
-
function
|
|
116
|
+
function F({
|
|
109
117
|
className: t,
|
|
110
118
|
...e
|
|
111
119
|
}) {
|
|
112
120
|
return /* @__PURE__ */ a(
|
|
113
|
-
|
|
121
|
+
m,
|
|
114
122
|
{
|
|
115
123
|
"data-slot": "dialog-description",
|
|
116
124
|
className: o("text-d-secondary-foreground text-sm", t),
|
|
@@ -119,14 +127,14 @@ function P({
|
|
|
119
127
|
);
|
|
120
128
|
}
|
|
121
129
|
export {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
C as Dialog,
|
|
131
|
+
T as DialogClose,
|
|
132
|
+
j as DialogContent,
|
|
133
|
+
F as DialogDescription,
|
|
134
|
+
P as DialogFooter,
|
|
135
|
+
O as DialogHeader,
|
|
136
|
+
b as DialogOverlay,
|
|
137
|
+
v as DialogPortal,
|
|
138
|
+
_ as DialogTitle,
|
|
139
|
+
k as DialogTrigger
|
|
132
140
|
};
|
|
@@ -127,7 +127,7 @@ function ie({
|
|
|
127
127
|
onPaste: K,
|
|
128
128
|
onKeyDown: U,
|
|
129
129
|
className: C(
|
|
130
|
-
"border-d-input bg-d-
|
|
130
|
+
"border-d-input bg-d-input ring-offset-d-background placeholder:text-d-muted-foreground focus-visible:border-d-primary z-10 w-full grow resize-none rounded-xl border p-3 pr-24 text-sm transition-[border] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
131
131
|
z && "pb-16",
|
|
132
132
|
n
|
|
133
133
|
),
|
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { ChatMessage as
|
|
4
|
-
import { TypingIndicator as
|
|
5
|
-
function
|
|
6
|
-
messages:
|
|
2
|
+
import { jsxs as l, jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { ChatMessage as s } from "./chat-message.js";
|
|
4
|
+
import { TypingIndicator as m } from "./typing-indicator.js";
|
|
5
|
+
function x({
|
|
6
|
+
messages: n,
|
|
7
7
|
showTimeStamps: e = !0,
|
|
8
|
-
isTyping:
|
|
9
|
-
messageOptions:
|
|
8
|
+
isTyping: a = !1,
|
|
9
|
+
messageOptions: i,
|
|
10
|
+
onEdit: t,
|
|
11
|
+
onMessageSave: c
|
|
10
12
|
}) {
|
|
11
|
-
return /* @__PURE__ */
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
return /* @__PURE__ */
|
|
15
|
-
|
|
13
|
+
return /* @__PURE__ */ l("div", { className: "space-y-4 overflow-visible", children: [
|
|
14
|
+
n.map((o, f) => {
|
|
15
|
+
const p = typeof i == "function" ? i(o) : i;
|
|
16
|
+
return /* @__PURE__ */ r(
|
|
17
|
+
s,
|
|
16
18
|
{
|
|
17
19
|
showTimeStamp: e,
|
|
18
|
-
...
|
|
19
|
-
...
|
|
20
|
+
...o,
|
|
21
|
+
...p,
|
|
22
|
+
onEdit: t ? (d) => t(o.id, d) : void 0,
|
|
23
|
+
onMessageSave: c
|
|
20
24
|
},
|
|
21
|
-
|
|
25
|
+
f
|
|
22
26
|
);
|
|
23
27
|
}),
|
|
24
|
-
|
|
28
|
+
a && /* @__PURE__ */ r(m, {})
|
|
25
29
|
] });
|
|
26
30
|
}
|
|
27
31
|
export {
|
|
28
|
-
|
|
32
|
+
x as MessageList
|
|
29
33
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -436,7 +436,7 @@ export declare function ChartTooltipContent({ active, payload, className, indica
|
|
|
436
436
|
labelKey?: string;
|
|
437
437
|
} & React_2.HTMLAttributes<HTMLDivElement>): JSX.Element | null;
|
|
438
438
|
|
|
439
|
-
export declare function Chat({ messages, handleSubmit, input, handleInputChange, stop, isGenerating, append, suggestions, className, onRateResponse, setMessages, transcribeAudio, }: ChatProps): JSX.Element;
|
|
439
|
+
export declare function Chat({ messages, handleSubmit, input, handleInputChange, stop, isGenerating, append, suggestions, className, onRateResponse, setMessages, transcribeAudio, allowAttachments, onEdit, onMessageSave, }: ChatProps): JSX.Element;
|
|
440
440
|
|
|
441
441
|
export declare namespace Chat {
|
|
442
442
|
var displayName: string;
|
|
@@ -471,6 +471,8 @@ export declare interface ChatMessageProps extends Message {
|
|
|
471
471
|
showTimeStamp?: boolean;
|
|
472
472
|
animation?: Animation_2;
|
|
473
473
|
actions?: default_3.ReactNode;
|
|
474
|
+
onEdit?: (newContent: string) => void;
|
|
475
|
+
onMessageSave?: (messageId: string, content: string) => void;
|
|
474
476
|
}
|
|
475
477
|
|
|
476
478
|
export declare function ChatMessages({ messages, children, }: React.PropsWithChildren<{
|
|
@@ -494,6 +496,9 @@ declare interface ChatPropsBase {
|
|
|
494
496
|
onRateResponse?: (messageId: string, rating: "thumbs-up" | "thumbs-down") => void;
|
|
495
497
|
setMessages?: (messages: any[]) => void;
|
|
496
498
|
transcribeAudio?: (blob: Blob) => Promise<string>;
|
|
499
|
+
allowAttachments?: boolean;
|
|
500
|
+
onEdit?: (messageId: string, newContent: string) => void;
|
|
501
|
+
onMessageSave?: (messageId: string, content: string) => void;
|
|
497
502
|
}
|
|
498
503
|
|
|
499
504
|
declare interface ChatPropsWithoutSuggestions extends ChatPropsBase {
|
|
@@ -791,7 +796,9 @@ declare interface DatePickerProps {
|
|
|
791
796
|
|
|
792
797
|
export declare function Dialog({ ...props }: React_2.ComponentProps<typeof DialogPrimitive.Root>): JSX.Element;
|
|
793
798
|
|
|
794
|
-
export declare function DialogContent({ className, children, ...props }: React_2.ComponentProps<typeof DialogPrimitive.Content>
|
|
799
|
+
export declare function DialogContent({ className, children, size, ...props }: React_2.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
800
|
+
size?: "sm" | "default" | "lg";
|
|
801
|
+
}): JSX.Element;
|
|
795
802
|
|
|
796
803
|
export declare function DialogDescription({ className, ...props }: React_2.ComponentProps<typeof DialogPrimitive.Description>): JSX.Element;
|
|
797
804
|
|
|
@@ -1171,13 +1178,15 @@ declare interface MessageInputWithoutAttachmentProps extends MessageInputBasePro
|
|
|
1171
1178
|
allowAttachments?: false;
|
|
1172
1179
|
}
|
|
1173
1180
|
|
|
1174
|
-
export declare function MessageList({ messages, showTimeStamps, isTyping, messageOptions, }: MessageListProps): JSX.Element;
|
|
1181
|
+
export declare function MessageList({ messages, showTimeStamps, isTyping, messageOptions, onEdit, onMessageSave, }: MessageListProps): JSX.Element;
|
|
1175
1182
|
|
|
1176
1183
|
declare interface MessageListProps {
|
|
1177
1184
|
messages: Message[];
|
|
1178
1185
|
showTimeStamps?: boolean;
|
|
1179
1186
|
isTyping?: boolean;
|
|
1180
1187
|
messageOptions?: AdditionalMessageOptions | ((message: Message) => AdditionalMessageOptions);
|
|
1188
|
+
onEdit?: (messageId: string, newContent: string) => void;
|
|
1189
|
+
onMessageSave?: (messageId: string, content: string) => void;
|
|
1181
1190
|
}
|
|
1182
1191
|
|
|
1183
1192
|
declare type MessagePart = TextPart | ReasoningPart | ToolInvocationPart | SourcePart;
|