laif-ds 0.2.0 → 0.2.2

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,259 +1,265 @@
1
1
  "use client";
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,
18
- input: i,
19
- handleInputChange: u,
20
- stop: a,
21
- isGenerating: c,
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({
17
+ messages: e,
18
+ welcomeTitle: n = "Da dove iniziamo?",
19
+ handleSubmit: i,
20
+ input: m,
21
+ handleInputChange: c,
22
+ stop: s,
23
+ isGenerating: u,
22
24
  append: f,
23
- suggestions: m,
24
- className: v,
25
- onRateResponse: b,
26
- setMessages: C,
27
- transcribeAudio: F,
28
- allowAttachments: _ = !1,
29
- onEdit: j,
25
+ suggestions: h,
26
+ className: D,
27
+ onRateResponse: w,
28
+ setMessages: x,
29
+ transcribeAudio: L,
30
+ allowAttachments: g = !1,
31
+ onEdit: B,
30
32
  onMessageSave: d
31
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
+ 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(
39
+ (a) => a.role === "assistant"
38
40
  );
39
41
  if (!l) return;
40
- let h = !1, p = { ...l };
42
+ let p = !1, b = { ...l };
41
43
  if (l.toolInvocations) {
42
- const s = l.toolInvocations.map(
43
- (n) => n.state === "call" ? (h = !0, {
44
- ...n,
44
+ const a = l.toolInvocations.map(
45
+ (r) => r.state === "call" ? (p = !0, {
46
+ ...r,
45
47
  state: "result",
46
48
  result: {
47
49
  content: "Tool execution was cancelled",
48
50
  __cancelled: !0
49
51
  // Special marker to indicate cancellation
50
52
  }
51
- }) : n
53
+ }) : r
52
54
  );
53
- h && (p = {
54
- ...p,
55
- toolInvocations: s
55
+ p && (b = {
56
+ ...b,
57
+ toolInvocations: a
56
58
  });
57
59
  }
58
60
  if (l.parts && l.parts.length > 0) {
59
- const s = l.parts.map((n) => n.type === "tool-invocation" && n.toolInvocation && n.toolInvocation.state === "call" ? (h = !0, {
60
- ...n,
61
+ const a = l.parts.map((r) => r.type === "tool-invocation" && r.toolInvocation && r.toolInvocation.state === "call" ? (p = !0, {
62
+ ...r,
61
63
  toolInvocation: {
62
- ...n.toolInvocation,
64
+ ...r.toolInvocation,
63
65
  state: "result",
64
66
  result: {
65
67
  content: "Tool execution was cancelled",
66
68
  __cancelled: !0
67
69
  }
68
70
  }
69
- }) : n);
70
- h && (p = {
71
- ...p,
72
- parts: s
71
+ }) : r);
72
+ p && (b = {
73
+ ...b,
74
+ parts: a
73
75
  });
74
76
  }
75
- if (h) {
76
- const s = e.findIndex(
77
- (n) => n.id === l.id
77
+ if (p) {
78
+ const a = o.findIndex(
79
+ (r) => r.id === l.id
78
80
  );
79
- s !== -1 && (e[s] = p, C(e));
81
+ a !== -1 && (o[a] = b, x(o));
80
82
  }
81
- }, [a, C, x]), P = I(
82
- (e) => ({
83
- actions: b ? /* @__PURE__ */ N(T, { children: [
83
+ }, [s, x, C]), E = k(
84
+ (o) => ({
85
+ actions: w ? /* @__PURE__ */ v(y, { children: [
84
86
  /* @__PURE__ */ t("div", { className: "border-d-border border-r pr-1", children: /* @__PURE__ */ t(
85
- k,
87
+ S,
86
88
  {
87
- content: e.content,
89
+ content: o.content,
88
90
  copyMessage: "Copied response to clipboard!"
89
91
  }
90
92
  ) }),
91
93
  d && /* @__PURE__ */ t("div", { className: "border-d-border border-r pr-1", children: /* @__PURE__ */ t(
92
- w,
94
+ N,
93
95
  {
94
96
  size: "icon",
95
97
  variant: "ghost",
96
98
  className: "h-6 w-6",
97
- onClick: () => d(e.id, e.content),
99
+ onClick: () => d(o.id, o.content),
98
100
  title: "Save message",
99
- children: /* @__PURE__ */ t(S, { className: "h-4 w-4" })
101
+ children: /* @__PURE__ */ t(j, { className: "h-4 w-4" })
100
102
  }
101
103
  ) }),
102
104
  /* @__PURE__ */ t(
103
- w,
105
+ N,
104
106
  {
105
107
  size: "icon",
106
108
  variant: "ghost",
107
109
  className: "h-6 w-6",
108
- onClick: () => b(e.id, "thumbs-up"),
109
- children: /* @__PURE__ */ t(K, { className: "h-4 w-4" })
110
+ onClick: () => w(o.id, "thumbs-up"),
111
+ children: /* @__PURE__ */ t(V, { className: "h-4 w-4" })
110
112
  }
111
113
  ),
112
114
  /* @__PURE__ */ t(
113
- w,
115
+ N,
114
116
  {
115
117
  size: "icon",
116
118
  variant: "ghost",
117
119
  className: "h-6 w-6",
118
- onClick: () => b(e.id, "thumbs-down"),
119
- 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" })
120
122
  }
121
123
  )
122
- ] }) : /* @__PURE__ */ N(T, { children: [
124
+ ] }) : /* @__PURE__ */ v(y, { children: [
123
125
  /* @__PURE__ */ t(
124
- k,
126
+ S,
125
127
  {
126
- content: e.content,
128
+ content: o.content,
127
129
  copyMessage: "Copied response to clipboard!"
128
130
  }
129
131
  ),
130
132
  d && /* @__PURE__ */ t("div", { className: "border-d-border border-l pl-1", children: /* @__PURE__ */ t(
131
- w,
133
+ N,
132
134
  {
133
135
  size: "icon",
134
136
  variant: "ghost",
135
137
  className: "h-6 w-6",
136
- onClick: () => d(e.id, e.content),
138
+ onClick: () => d(o.id, o.content),
137
139
  title: "Save message",
138
- children: /* @__PURE__ */ t(S, { className: "h-4 w-4" })
140
+ children: /* @__PURE__ */ t(j, { className: "h-4 w-4" })
139
141
  }
140
142
  ) })
141
143
  ] }),
142
144
  onMessageSave: d
143
145
  }),
144
- [b, d]
146
+ [w, d]
145
147
  );
146
- return /* @__PURE__ */ N(z, { className: v, children: [
147
- B && f && m ? /* @__PURE__ */ t(
148
- J,
149
- {
150
- label: "Try these prompts ✨",
151
- append: f,
152
- suggestions: m
153
- }
154
- ) : null,
155
- o.length > 0 ? /* @__PURE__ */ t(X, { messages: o, children: /* @__PURE__ */ t(
156
- H,
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,
153
+ {
154
+ label: "",
155
+ append: f,
156
+ suggestions: h
157
+ }
158
+ )
159
+ ] }) }),
160
+ e.length > 0 ? /* @__PURE__ */ t(Z, { messages: e, children: /* @__PURE__ */ t(
161
+ K,
157
162
  {
158
- messages: o,
159
- isTyping: y,
160
- messageOptions: P,
161
- onEdit: j,
163
+ messages: e,
164
+ isTyping: I,
165
+ messageOptions: E,
166
+ onEdit: B,
162
167
  onMessageSave: d
163
168
  }
164
169
  ) }) : null,
170
+ T && !f && !h && /* @__PURE__ */ t(z, { variant: "h3", className: "mb-8 text-center", children: n }),
165
171
  /* @__PURE__ */ t(
166
- A,
172
+ _,
167
173
  {
168
174
  className: "flex-shrink-0",
169
- isPending: c || y,
170
- handleSubmit: r,
171
- children: ({ files: e, setFiles: l }) => /* @__PURE__ */ t(
172
- q,
175
+ isPending: u || I,
176
+ handleSubmit: i,
177
+ children: ({ files: o, setFiles: l }) => /* @__PURE__ */ t(
178
+ J,
173
179
  {
174
- value: i,
175
- onChange: u,
176
- allowAttachments: _,
177
- files: e,
180
+ value: m,
181
+ onChange: c,
182
+ allowAttachments: g,
183
+ files: o,
178
184
  setFiles: l,
179
- stop: D,
180
- isGenerating: c,
181
- transcribeAudio: F
185
+ stop: U,
186
+ isGenerating: u,
187
+ transcribeAudio: L
182
188
  }
183
189
  )
184
190
  }
185
191
  )
186
192
  ] });
187
193
  }
188
- W.displayName = "Chat";
189
- function X({
190
- messages: o,
191
- children: r
194
+ Y.displayName = "Chat";
195
+ function Z({
196
+ messages: e,
197
+ children: n
192
198
  }) {
193
199
  const {
194
200
  containerRef: i,
195
- scrollToBottom: u,
196
- handleScroll: a,
197
- shouldAutoScroll: c,
198
- handleTouchStart: f
199
- } = O([o]);
200
- return /* @__PURE__ */ N(
201
+ scrollToBottom: m,
202
+ handleScroll: c,
203
+ shouldAutoScroll: s,
204
+ handleTouchStart: u
205
+ } = H([e]);
206
+ return /* @__PURE__ */ v(
201
207
  "div",
202
208
  {
203
209
  className: "relative flex-1 overflow-y-auto pb-4",
204
210
  ref: i,
205
- onScroll: a,
206
- onTouchStart: f,
211
+ onScroll: c,
212
+ onTouchStart: u,
207
213
  children: [
208
- /* @__PURE__ */ t("div", { className: "max-w-full", children: r }),
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(
210
- w,
214
+ /* @__PURE__ */ t("div", { className: "max-w-full", children: n }),
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,
211
217
  {
212
- onClick: u,
218
+ onClick: m,
213
219
  className: "animate-in fade-in-0 slide-in-from-bottom-1 pointer-events-auto h-8 w-8 rounded-full ease-in-out",
214
220
  size: "icon",
215
221
  variant: "ghost",
216
- children: /* @__PURE__ */ t(V, { className: "h-4 w-4" })
222
+ children: /* @__PURE__ */ t(X, { className: "h-4 w-4" })
217
223
  }
218
224
  ) }) })
219
225
  ]
220
226
  }
221
227
  );
222
228
  }
223
- const z = g(({ className: o, ...r }, i) => /* @__PURE__ */ t(
229
+ const F = A(({ className: e, ...n }, i) => /* @__PURE__ */ t(
224
230
  "div",
225
231
  {
226
232
  ref: i,
227
- className: M("flex h-full max-h-full w-full flex-col", o),
228
- ...r
233
+ className: q("flex h-full max-h-full w-full flex-col", e),
234
+ ...n
229
235
  }
230
236
  ));
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);
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) {
243
+ n(f);
238
244
  return;
239
245
  }
240
- const v = Y(a);
241
- r(m, { experimental_attachments: v }), c(null);
242
- }, className: i, children: o({ files: a, setFiles: c }) });
246
+ const h = $(c);
247
+ n(f, { experimental_attachments: h }), s(null);
248
+ }, className: i, children: e({ files: c, setFiles: s }) });
243
249
  }
244
250
  );
245
- A.displayName = "ChatForm";
246
- function Y(o) {
251
+ _.displayName = "ChatForm";
252
+ function $(e) {
247
253
  if (typeof window > "u")
248
254
  return {};
249
- const r = new DataTransfer();
250
- for (const i of Array.from(o))
251
- r.items.add(i);
252
- return r.files;
255
+ const n = new DataTransfer();
256
+ for (const i of Array.from(e))
257
+ n.items.add(i);
258
+ return n.files;
253
259
  }
254
260
  export {
255
- W as Chat,
256
- z as ChatContainer,
257
- A as ChatForm,
258
- X as ChatMessages
261
+ Y as Chat,
262
+ F as ChatContainer,
263
+ _ as ChatForm,
264
+ Z as ChatMessages
259
265
  };
@@ -1,33 +1,33 @@
1
1
  "use client";
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({
2
+ import { jsxs as a, jsx as r } from "react/jsx-runtime";
3
+ import { ChatMessage as l } from "./chat-message.js";
4
+ import { TypingIndicator as u } from "./typing-indicator.js";
5
+ function h({
6
6
  messages: n,
7
- showTimeStamps: e = !0,
8
- isTyping: a = !1,
9
- messageOptions: i,
7
+ showTimeStamps: c = !0,
8
+ isTyping: d = !1,
9
+ messageOptions: o,
10
10
  onEdit: t,
11
- onMessageSave: c
11
+ onMessageSave: e
12
12
  }) {
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;
13
+ return /* @__PURE__ */ a("div", { className: "space-y-4 overflow-visible", children: [
14
+ n.map((i) => {
15
+ const f = typeof o == "function" ? o(i) : o;
16
16
  return /* @__PURE__ */ r(
17
- s,
17
+ l,
18
18
  {
19
- showTimeStamp: e,
20
- ...o,
21
- ...p,
22
- onEdit: t ? (d) => t(o.id, d) : void 0,
23
- onMessageSave: c
19
+ showTimeStamp: c,
20
+ ...i,
21
+ ...f,
22
+ onEdit: t ? (p) => t(i.id, p) : void 0,
23
+ onMessageSave: e
24
24
  },
25
- f
25
+ i.id
26
26
  );
27
27
  }),
28
- a && /* @__PURE__ */ r(m, {})
28
+ d && /* @__PURE__ */ r(u, {})
29
29
  ] });
30
30
  }
31
31
  export {
32
- x as MessageList
32
+ h as MessageList
33
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, allowAttachments, onEdit, onMessageSave, }: 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,7 @@ export declare interface ChatMessageProps extends Message {
471
471
  showTimeStamp?: boolean;
472
472
  animation?: Animation_2;
473
473
  actions?: default_3.ReactNode;
474
+ editable?: boolean;
474
475
  onEdit?: (newContent: string) => void;
475
476
  onMessageSave?: (messageId: string, content: string) => void;
476
477
  }
@@ -499,6 +500,7 @@ declare interface ChatPropsBase {
499
500
  allowAttachments?: boolean;
500
501
  onEdit?: (messageId: string, newContent: string) => void;
501
502
  onMessageSave?: (messageId: string, content: string) => void;
503
+ welcomeTitle?: string;
502
504
  }
503
505
 
504
506
  declare interface ChatPropsWithoutSuggestions extends ChatPropsBase {
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { __module as x } from "../../_virtual/index7.js";
2
+ import { __module as x } from "../../_virtual/index6.js";
3
3
  var w;
4
4
  function O() {
5
5
  return w ? x.exports : (w = 1, function(d) {
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { __exports as r } from "../../../_virtual/index6.js";
2
+ import { __exports as r } from "../../../_virtual/index7.js";
3
3
  import { __require as c } from "../../inline-style-parser/index.js";
4
4
  var f;
5
5
  function j() {