laif-ds 0.1.99 → 0.2.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.
@@ -1,218 +1,255 @@
1
1
  "use client";
2
- import { jsxs as C, jsx as t, Fragment as j } from "react/jsx-runtime";
3
- import { forwardRef as g, useRef as L, useCallback as N, useState as z } from "react";
4
- import { cn as B } from "../../lib/utils.js";
5
- import { useAutoScroll as D } from "../../hooks/use-auto-scroll.js";
6
- import { Button as x } from "./button.js";
7
- import { CopyButton as T } from "./copy-button.js";
8
- import { MessageInput as P } from "./message-input.js";
9
- import { MessageList as U } from "./message-list.js";
10
- import { PromptSuggestions as E } from "./prompt-suggestions.js";
11
- import O from "../../node_modules/lucide-react/dist/esm/icons/thumbs-up.js";
12
- import q from "../../node_modules/lucide-react/dist/esm/icons/thumbs-down.js";
13
- import H from "../../node_modules/lucide-react/dist/esm/icons/arrow-down.js";
14
- function J({
2
+ import { jsxs as v, Fragment as y, jsx as t } from "react/jsx-runtime";
3
+ import { forwardRef as A, useRef as M, useCallback as k, useState as O } from "react";
4
+ import { cn as q } from "../../lib/utils.js";
5
+ import { useAutoScroll as H } from "../../hooks/use-auto-scroll.js";
6
+ import { Button as N } from "./button.js";
7
+ import { CopyButton as S } from "./copy-button.js";
8
+ import { MessageInput as J } from "./message-input.js";
9
+ import { MessageList as K } from "./message-list.js";
10
+ import { PromptSuggestions as Q } from "./prompt-suggestions.js";
11
+ import { Typo as z } from "./typo.js";
12
+ import j from "../../node_modules/lucide-react/dist/esm/icons/save.js";
13
+ import V from "../../node_modules/lucide-react/dist/esm/icons/thumbs-up.js";
14
+ import W from "../../node_modules/lucide-react/dist/esm/icons/thumbs-down.js";
15
+ import X from "../../node_modules/lucide-react/dist/esm/icons/arrow-down.js";
16
+ function Y({
15
17
  messages: e,
16
- handleSubmit: n,
17
- input: i,
18
- handleInputChange: u,
18
+ welcomeTitle: n = "Da dove iniziamo?",
19
+ handleSubmit: i,
20
+ input: m,
21
+ handleInputChange: c,
19
22
  stop: s,
20
- isGenerating: c,
21
- append: d,
22
- suggestions: f,
23
- className: w,
24
- onRateResponse: p,
25
- setMessages: v,
26
- transcribeAudio: M
23
+ isGenerating: u,
24
+ append: f,
25
+ suggestions: h,
26
+ className: D,
27
+ onRateResponse: w,
28
+ setMessages: x,
29
+ transcribeAudio: L,
30
+ allowAttachments: g = !1,
31
+ onEdit: B,
32
+ onMessageSave: d
27
33
  }) {
28
- const k = e.at(-1), A = e.length === 0, y = k?.role === "user", b = L(e);
29
- b.current = e;
30
- const F = N(() => {
31
- if (s?.(), !v) return;
32
- const r = [...b.current], l = r.findLast(
34
+ const P = e.at(-1), T = e.length === 0, I = P?.role === "user", C = M(e);
35
+ C.current = e;
36
+ const U = k(() => {
37
+ if (s?.(), !x) return;
38
+ const o = [...C.current], l = o.findLast(
33
39
  (a) => a.role === "assistant"
34
40
  );
35
41
  if (!l) return;
36
- let m = !1, h = { ...l };
42
+ let p = !1, b = { ...l };
37
43
  if (l.toolInvocations) {
38
44
  const a = l.toolInvocations.map(
39
- (o) => o.state === "call" ? (m = !0, {
40
- ...o,
45
+ (r) => r.state === "call" ? (p = !0, {
46
+ ...r,
41
47
  state: "result",
42
48
  result: {
43
49
  content: "Tool execution was cancelled",
44
50
  __cancelled: !0
45
51
  // Special marker to indicate cancellation
46
52
  }
47
- }) : o
53
+ }) : r
48
54
  );
49
- m && (h = {
50
- ...h,
55
+ p && (b = {
56
+ ...b,
51
57
  toolInvocations: a
52
58
  });
53
59
  }
54
60
  if (l.parts && l.parts.length > 0) {
55
- const a = l.parts.map((o) => o.type === "tool-invocation" && o.toolInvocation && o.toolInvocation.state === "call" ? (m = !0, {
56
- ...o,
61
+ const a = l.parts.map((r) => r.type === "tool-invocation" && r.toolInvocation && r.toolInvocation.state === "call" ? (p = !0, {
62
+ ...r,
57
63
  toolInvocation: {
58
- ...o.toolInvocation,
64
+ ...r.toolInvocation,
59
65
  state: "result",
60
66
  result: {
61
67
  content: "Tool execution was cancelled",
62
68
  __cancelled: !0
63
69
  }
64
70
  }
65
- }) : o);
66
- m && (h = {
67
- ...h,
71
+ }) : r);
72
+ p && (b = {
73
+ ...b,
68
74
  parts: a
69
75
  });
70
76
  }
71
- if (m) {
72
- const a = r.findIndex(
73
- (o) => o.id === l.id
77
+ if (p) {
78
+ const a = o.findIndex(
79
+ (r) => r.id === l.id
74
80
  );
75
- a !== -1 && (r[a] = h, v(r));
81
+ a !== -1 && (o[a] = b, x(o));
76
82
  }
77
- }, [s, v, b]), _ = N(
78
- (r) => ({
79
- actions: p ? /* @__PURE__ */ C(j, { children: [
83
+ }, [s, x, C]), E = k(
84
+ (o) => ({
85
+ actions: w ? /* @__PURE__ */ v(y, { children: [
80
86
  /* @__PURE__ */ t("div", { className: "border-d-border border-r pr-1", children: /* @__PURE__ */ t(
81
- T,
87
+ S,
82
88
  {
83
- content: r.content,
89
+ content: o.content,
84
90
  copyMessage: "Copied response to clipboard!"
85
91
  }
86
92
  ) }),
93
+ d && /* @__PURE__ */ t("div", { className: "border-d-border border-r pr-1", children: /* @__PURE__ */ t(
94
+ N,
95
+ {
96
+ size: "icon",
97
+ variant: "ghost",
98
+ className: "h-6 w-6",
99
+ onClick: () => d(o.id, o.content),
100
+ title: "Save message",
101
+ children: /* @__PURE__ */ t(j, { className: "h-4 w-4" })
102
+ }
103
+ ) }),
87
104
  /* @__PURE__ */ t(
88
- x,
105
+ N,
89
106
  {
90
107
  size: "icon",
91
108
  variant: "ghost",
92
109
  className: "h-6 w-6",
93
- onClick: () => p(r.id, "thumbs-up"),
94
- children: /* @__PURE__ */ t(O, { className: "h-4 w-4" })
110
+ onClick: () => w(o.id, "thumbs-up"),
111
+ children: /* @__PURE__ */ t(V, { className: "h-4 w-4" })
95
112
  }
96
113
  ),
97
114
  /* @__PURE__ */ t(
98
- x,
115
+ N,
99
116
  {
100
117
  size: "icon",
101
118
  variant: "ghost",
102
119
  className: "h-6 w-6",
103
- onClick: () => p(r.id, "thumbs-down"),
104
- children: /* @__PURE__ */ t(q, { className: "h-4 w-4" })
120
+ onClick: () => w(o.id, "thumbs-down"),
121
+ children: /* @__PURE__ */ t(W, { className: "h-4 w-4" })
105
122
  }
106
123
  )
107
- ] }) : /* @__PURE__ */ t(
108
- T,
124
+ ] }) : /* @__PURE__ */ v(y, { children: [
125
+ /* @__PURE__ */ t(
126
+ S,
127
+ {
128
+ content: o.content,
129
+ copyMessage: "Copied response to clipboard!"
130
+ }
131
+ ),
132
+ d && /* @__PURE__ */ t("div", { className: "border-d-border border-l pl-1", children: /* @__PURE__ */ t(
133
+ N,
134
+ {
135
+ size: "icon",
136
+ variant: "ghost",
137
+ className: "h-6 w-6",
138
+ onClick: () => d(o.id, o.content),
139
+ title: "Save message",
140
+ children: /* @__PURE__ */ t(j, { className: "h-4 w-4" })
141
+ }
142
+ ) })
143
+ ] }),
144
+ onMessageSave: d
145
+ }),
146
+ [w, d]
147
+ );
148
+ return /* @__PURE__ */ v(F, { className: D, children: [
149
+ T && /* @__PURE__ */ t("div", { className: "flex flex-1 flex-col items-center justify-center p-8", children: f && h && /* @__PURE__ */ v(y, { children: [
150
+ /* @__PURE__ */ t(z, { variant: "h3", className: "mb-8 text-center", children: n }),
151
+ /* @__PURE__ */ t(
152
+ Q,
109
153
  {
110
- content: r.content,
111
- copyMessage: "Copied response to clipboard!"
154
+ label: "",
155
+ append: f,
156
+ suggestions: h
112
157
  }
113
158
  )
114
- }),
115
- [p]
116
- );
117
- return /* @__PURE__ */ C(S, { className: w, children: [
118
- A && d && f ? /* @__PURE__ */ t(
119
- E,
120
- {
121
- label: "Try these prompts ✨",
122
- append: d,
123
- suggestions: f
124
- }
125
- ) : null,
126
- e.length > 0 ? /* @__PURE__ */ t(K, { messages: e, children: /* @__PURE__ */ t(
127
- U,
159
+ ] }) }),
160
+ e.length > 0 ? /* @__PURE__ */ t(Z, { messages: e, children: /* @__PURE__ */ t(
161
+ K,
128
162
  {
129
163
  messages: e,
130
- isTyping: y,
131
- messageOptions: _
164
+ isTyping: I,
165
+ messageOptions: E,
166
+ onEdit: B,
167
+ onMessageSave: d
132
168
  }
133
169
  ) }) : null,
170
+ T && !f && !h && /* @__PURE__ */ t(z, { variant: "h3", className: "mb-8 text-center", children: n }),
134
171
  /* @__PURE__ */ t(
135
- I,
172
+ _,
136
173
  {
137
174
  className: "flex-shrink-0",
138
- isPending: c || y,
139
- handleSubmit: n,
140
- children: ({ files: r, setFiles: l }) => /* @__PURE__ */ t(
141
- P,
175
+ isPending: u || I,
176
+ handleSubmit: i,
177
+ children: ({ files: o, setFiles: l }) => /* @__PURE__ */ t(
178
+ J,
142
179
  {
143
- value: i,
144
- onChange: u,
145
- allowAttachments: !0,
146
- files: r,
180
+ value: m,
181
+ onChange: c,
182
+ allowAttachments: g,
183
+ files: o,
147
184
  setFiles: l,
148
- stop: F,
149
- isGenerating: c,
150
- transcribeAudio: M
185
+ stop: U,
186
+ isGenerating: u,
187
+ transcribeAudio: L
151
188
  }
152
189
  )
153
190
  }
154
191
  )
155
192
  ] });
156
193
  }
157
- J.displayName = "Chat";
158
- function K({
194
+ Y.displayName = "Chat";
195
+ function Z({
159
196
  messages: e,
160
197
  children: n
161
198
  }) {
162
199
  const {
163
200
  containerRef: i,
164
- scrollToBottom: u,
165
- handleScroll: s,
166
- shouldAutoScroll: c,
167
- handleTouchStart: d
168
- } = D([e]);
169
- return /* @__PURE__ */ C(
201
+ scrollToBottom: m,
202
+ handleScroll: c,
203
+ shouldAutoScroll: s,
204
+ handleTouchStart: u
205
+ } = H([e]);
206
+ return /* @__PURE__ */ v(
170
207
  "div",
171
208
  {
172
209
  className: "relative flex-1 overflow-y-auto pb-4",
173
210
  ref: i,
174
- onScroll: s,
175
- onTouchStart: d,
211
+ onScroll: c,
212
+ onTouchStart: u,
176
213
  children: [
177
214
  /* @__PURE__ */ t("div", { className: "max-w-full", children: n }),
178
- !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
- x,
215
+ !s && /* @__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(
216
+ N,
180
217
  {
181
- onClick: u,
218
+ onClick: m,
182
219
  className: "animate-in fade-in-0 slide-in-from-bottom-1 pointer-events-auto h-8 w-8 rounded-full ease-in-out",
183
220
  size: "icon",
184
221
  variant: "ghost",
185
- children: /* @__PURE__ */ t(H, { className: "h-4 w-4" })
222
+ children: /* @__PURE__ */ t(X, { className: "h-4 w-4" })
186
223
  }
187
224
  ) }) })
188
225
  ]
189
226
  }
190
227
  );
191
228
  }
192
- const S = g(({ className: e, ...n }, i) => /* @__PURE__ */ t(
229
+ const F = A(({ className: e, ...n }, i) => /* @__PURE__ */ t(
193
230
  "div",
194
231
  {
195
232
  ref: i,
196
- className: B("flex h-full max-h-full w-full flex-col", e),
233
+ className: q("flex h-full max-h-full w-full flex-col", e),
197
234
  ...n
198
235
  }
199
236
  ));
200
- S.displayName = "ChatContainer";
201
- const I = g(
202
- ({ children: e, handleSubmit: n, className: i }, u) => {
203
- const [s, c] = z(null);
204
- return /* @__PURE__ */ t("form", { ref: u, onSubmit: (f) => {
205
- if (!s) {
237
+ F.displayName = "ChatContainer";
238
+ const _ = A(
239
+ ({ children: e, handleSubmit: n, className: i }, m) => {
240
+ const [c, s] = O(null);
241
+ return /* @__PURE__ */ t("form", { ref: m, onSubmit: (f) => {
242
+ if (!c) {
206
243
  n(f);
207
244
  return;
208
245
  }
209
- const w = Q(s);
210
- n(f, { experimental_attachments: w }), c(null);
211
- }, className: i, children: e({ files: s, setFiles: c }) });
246
+ const h = $(c);
247
+ n(f, { experimental_attachments: h }), s(null);
248
+ }, className: i, children: e({ files: c, setFiles: s }) });
212
249
  }
213
250
  );
214
- I.displayName = "ChatForm";
215
- function Q(e) {
251
+ _.displayName = "ChatForm";
252
+ function $(e) {
216
253
  if (typeof window > "u")
217
254
  return {};
218
255
  const n = new DataTransfer();
@@ -221,8 +258,8 @@ function Q(e) {
221
258
  return n.files;
222
259
  }
223
260
  export {
224
- J as Chat,
225
- S as ChatContainer,
226
- I as ChatForm,
227
- K as ChatMessages
261
+ Y as Chat,
262
+ F as ChatContainer,
263
+ _ as ChatForm,
264
+ Z as ChatMessages
228
265
  };
@@ -127,7 +127,7 @@ function ie({
127
127
  onPaste: K,
128
128
  onKeyDown: U,
129
129
  className: C(
130
- "border-d-input bg-d-background ring-offset-d-background placeholder:text-d-secondary-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",
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 c, jsx as o } from "react/jsx-runtime";
3
- import { ChatMessage as f } from "./chat-message.js";
4
- import { TypingIndicator as p } from "./typing-indicator.js";
5
- function d({
6
- messages: r,
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: n = !1,
9
- messageOptions: t
8
+ isTyping: a = !1,
9
+ messageOptions: i,
10
+ onEdit: t,
11
+ onMessageSave: c
10
12
  }) {
11
- return /* @__PURE__ */ c("div", { className: "space-y-4 overflow-visible", children: [
12
- r.map((i, a) => {
13
- const s = typeof t == "function" ? t(i) : t;
14
- return /* @__PURE__ */ o(
15
- f,
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
- ...i,
19
- ...s
20
+ ...o,
21
+ ...p,
22
+ onEdit: t ? (d) => t(o.id, d) : void 0,
23
+ onMessageSave: c
20
24
  },
21
- a
25
+ f
22
26
  );
23
27
  }),
24
- n && /* @__PURE__ */ o(p, {})
28
+ a && /* @__PURE__ */ r(m, {})
25
29
  ] });
26
30
  }
27
31
  export {
28
- d as MessageList
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, welcomeTitle, 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,10 @@ 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;
502
+ welcomeTitle?: string;
497
503
  }
498
504
 
499
505
  declare interface ChatPropsWithoutSuggestions extends ChatPropsBase {
@@ -1173,13 +1179,15 @@ declare interface MessageInputWithoutAttachmentProps extends MessageInputBasePro
1173
1179
  allowAttachments?: false;
1174
1180
  }
1175
1181
 
1176
- export declare function MessageList({ messages, showTimeStamps, isTyping, messageOptions, }: MessageListProps): JSX.Element;
1182
+ export declare function MessageList({ messages, showTimeStamps, isTyping, messageOptions, onEdit, onMessageSave, }: MessageListProps): JSX.Element;
1177
1183
 
1178
1184
  declare interface MessageListProps {
1179
1185
  messages: Message[];
1180
1186
  showTimeStamps?: boolean;
1181
1187
  isTyping?: boolean;
1182
1188
  messageOptions?: AdditionalMessageOptions | ((message: Message) => AdditionalMessageOptions);
1189
+ onEdit?: (messageId: string, newContent: string) => void;
1190
+ onMessageSave?: (messageId: string, content: string) => void;
1183
1191
  }
1184
1192
 
1185
1193
  declare type MessagePart = TextPart | ReasoningPart | ToolInvocationPart | SourcePart;
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import e from "../../_virtual/index3.js";
2
+ import e from "../../_virtual/index5.js";
3
3
  export {
4
4
  e as EventEmitter,
5
5
  e as default
@@ -3,7 +3,7 @@ import { stringify as w } from "../../comma-separated-tokens/index.js";
3
3
  import { ok as u } from "../../devlop/lib/default.js";
4
4
  import { svg as m, html as C } from "../../property-information/index.js";
5
5
  import { stringify as N } from "../../space-separated-tokens/index.js";
6
- import S from "../../../_virtual/index4.js";
6
+ import S from "../../../_virtual/index3.js";
7
7
  import { whitespace as j } from "../../hast-util-whitespace/lib/index.js";
8
8
  import { name as x } from "../../estree-util-is-identifier-name/lib/index.js";
9
9
  import { VFileMessage as h } from "../../vfile-message/lib/index.js";
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import e from "../../../../_virtual/index3.js";
2
+ import e from "../../../../_virtual/index5.js";
3
3
  var r = new e(), n = "recharts.syncEvent.tooltip";
4
4
  export {
5
5
  n as TOOLTIP_SYNC_EVENT,
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { bail as P } from "../../bail/index.js";
3
- import y from "../../../_virtual/index5.js";
3
+ import y from "../../../_virtual/index4.js";
4
4
  import z from "../../is-plain-obj/index.js";
5
5
  import { CallableInstance as C } from "./callable-instance.js";
6
6
  import { trough as A } from "../../trough/lib/index.js";