laif-ds 0.2.9 → 0.2.11

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,108 +1,126 @@
1
1
  "use client";
2
- import { jsx as r, jsxs as a } from "react/jsx-runtime";
3
- import c, { useEffect as P } from "react";
4
- import { motion as b } from "framer-motion";
5
- import { Button as j } from "../../dist/components/ui/button.js";
6
- import { Icon as p } from "../../dist/components/ui/icon.js";
7
- import { Tooltip as C, TooltipTrigger as W, TooltipContent as k } from "../../dist/components/ui/tooltip.js";
8
- import { Command as U, CommandGroup as R, CommandItem as h } from "../../dist/components/ui/command.js";
9
- import { Popover as L, PopoverTrigger as z, PopoverContent as S } from "../../dist/components/ui/popover.js";
10
- import { cn as N } from "../../dist/lib/utils.js";
11
- import f from "../../node_modules/lucide-react/dist/esm/icons/x.js";
2
+ import { jsx as t, jsxs as o } from "react/jsx-runtime";
3
+ import p, { useEffect as T } from "react";
4
+ import { motion as h } from "framer-motion";
5
+ import { Button as P } from "../../dist/components/ui/button.js";
6
+ import { Icon as x } from "../../dist/components/ui/icon.js";
7
+ import { Tooltip as C, TooltipTrigger as k, TooltipContent as U } from "../../dist/components/ui/tooltip.js";
8
+ import { Command as R, CommandGroup as L, CommandItem as b } from "../../dist/components/ui/command.js";
9
+ import { Popover as z, PopoverTrigger as S, PopoverContent as E } from "../../dist/components/ui/popover.js";
10
+ import { cn as v } from "../../dist/lib/utils.js";
11
+ import g from "../../node_modules/lucide-react/dist/esm/icons/x.js";
12
12
  import I from "../../node_modules/lucide-react/dist/esm/icons/file.js";
13
- const x = ({ url: e, onPreview: t, onDownload: i, onRemove: s }) => /* @__PURE__ */ a(L, { children: [
14
- /* @__PURE__ */ r(z, { asChild: !0, children: /* @__PURE__ */ r(j, { variant: "ghost", size: "icon", children: /* @__PURE__ */ r(p, { name: "Menu", size: "sm" }) }) }),
15
- /* @__PURE__ */ r(S, { className: "w-42 p-0", align: "end", children: /* @__PURE__ */ r(U, { children: /* @__PURE__ */ a(R, { children: [
16
- t && /* @__PURE__ */ a(h, { onSelect: () => t(e), children: [
17
- /* @__PURE__ */ r(p, { name: "Presentation", size: "sm" }),
18
- /* @__PURE__ */ r("span", { children: "Anteprima" })
13
+ const y = ({ url: e, onPreview: r, onDownload: n, onRemove: s }) => /* @__PURE__ */ o(z, { children: [
14
+ /* @__PURE__ */ t(S, { asChild: !0, children: /* @__PURE__ */ t(P, { variant: "ghost", size: "icon", children: /* @__PURE__ */ t(x, { name: "Menu", size: "sm" }) }) }),
15
+ /* @__PURE__ */ t(E, { className: "w-42 p-0", align: "end", children: /* @__PURE__ */ t(R, { children: /* @__PURE__ */ o(L, { children: [
16
+ r && /* @__PURE__ */ o(b, { onSelect: () => r(e), children: [
17
+ /* @__PURE__ */ t(x, { name: "Presentation", size: "sm" }),
18
+ /* @__PURE__ */ t("span", { children: "Anteprima" })
19
19
  ] }),
20
- i && /* @__PURE__ */ a(h, { onSelect: () => i(e), children: [
21
- /* @__PURE__ */ r(p, { name: "Download", size: "sm" }),
22
- /* @__PURE__ */ r("span", { children: "Download" })
20
+ n && /* @__PURE__ */ o(b, { onSelect: () => n(e), children: [
21
+ /* @__PURE__ */ t(x, { name: "Download", size: "sm" }),
22
+ /* @__PURE__ */ t("span", { children: "Download" })
23
23
  ] }),
24
- s && /* @__PURE__ */ a(
25
- h,
24
+ s && /* @__PURE__ */ o(
25
+ b,
26
26
  {
27
27
  onSelect: () => s(e),
28
28
  className: "text-red-500",
29
29
  children: [
30
- /* @__PURE__ */ r(p, { name: "Trash", className: "text-red-500", size: "sm" }),
31
- /* @__PURE__ */ r("span", { children: "Elimina" })
30
+ /* @__PURE__ */ t(x, { name: "Trash", className: "text-red-500", size: "sm" }),
31
+ /* @__PURE__ */ t("span", { children: "Elimina" })
32
32
  ]
33
33
  }
34
34
  )
35
35
  ] }) }) })
36
36
  ] });
37
- function y({ text: e }) {
38
- return /* @__PURE__ */ a(C, { children: [
39
- /* @__PURE__ */ r(W, { className: "w-full truncate", children: /* @__PURE__ */ r("span", { className: "text-d-secondary-foreground w-full truncate", children: e }) }),
40
- /* @__PURE__ */ r(k, { children: /* @__PURE__ */ r("span", { children: e }) })
37
+ function w({ text: e }) {
38
+ return /* @__PURE__ */ o(C, { children: [
39
+ /* @__PURE__ */ t(k, { "data-slot": "tooltip-trigger", className: "w-full min-w-0", children: /* @__PURE__ */ t("span", { className: "block w-full truncate text-d-secondary-foreground", children: e }) }),
40
+ /* @__PURE__ */ t(U, { children: /* @__PURE__ */ t("span", { children: e }) })
41
41
  ] });
42
42
  }
43
- const m = (e) => "type" in e && typeof e.type == "string" && e instanceof File, $ = (e) => {
44
- if (m(e) || e.type)
43
+ const u = (e) => "type" in e && typeof e.type == "string" && e instanceof File, $ = (e) => {
44
+ if (u(e) || e.type)
45
45
  return e.type;
46
- const t = e.name.toLowerCase();
47
- return t.endsWith(".jpg") || t.endsWith(".jpeg") || t.endsWith(".png") || t.endsWith(".gif") || t.endsWith(".webp") ? "image/" + t.split(".").pop() : t.endsWith(".txt") || t.endsWith(".md") ? "text/plain" : "application/octet-stream";
48
- }, G = c.forwardRef(
49
- (e, t) => {
50
- const i = $(e.file);
51
- return i.startsWith("image/") ? /* @__PURE__ */ r(v, { ...e, ref: t }) : i.startsWith("text/") || e.file.name.endsWith(".txt") || e.file.name.endsWith(".md") ? /* @__PURE__ */ r(F, { ...e, ref: t }) : /* @__PURE__ */ r(T, { ...e, ref: t });
46
+ const r = (i) => {
47
+ if (!i) return "";
48
+ const m = i.split(/[?#]/)[0].split("/").pop() || "", d = m.lastIndexOf(".");
49
+ return d >= 0 ? m.substring(d + 1).toLowerCase() : "";
50
+ }, n = r(e.name || ""), s = "url" in e ? r(e.url || "") : "", a = n || s;
51
+ if (a && (/* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "webp", "bmp", "svg", "tiff"])).has(a))
52
+ return `image/${a === "jpg" ? "jpeg" : a}`;
53
+ if (a === "txt" || a === "md")
54
+ return "text/plain";
55
+ const l = {
56
+ pdf: "application/pdf",
57
+ csv: "text/csv",
58
+ doc: "application/msword",
59
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
60
+ xls: "application/vnd.ms-excel",
61
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
62
+ ppt: "application/vnd.ms-powerpoint",
63
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation"
64
+ };
65
+ return a && l[a] ? l[a] : "application/octet-stream";
66
+ }, O = p.forwardRef(
67
+ (e, r) => {
68
+ const n = $(e.file);
69
+ return n.startsWith("image/") ? /* @__PURE__ */ t(N, { ...e, ref: r }) : n.startsWith("text/") || e.file.name.endsWith(".txt") || e.file.name.endsWith(".md") ? /* @__PURE__ */ t(F, { ...e, ref: r }) : /* @__PURE__ */ t(j, { ...e, ref: r });
52
70
  }
53
71
  );
54
- G.displayName = "FilePreview";
55
- const v = c.forwardRef(
72
+ O.displayName = "FilePreview";
73
+ const N = p.forwardRef(
56
74
  ({
57
75
  file: e,
58
- onRemove: t,
59
- onPreview: i,
76
+ onRemove: r,
77
+ onPreview: n,
60
78
  onDownload: s,
61
- showActionMenu: d = !1,
62
- className: l
63
- }, o) => {
64
- const n = m(e) ? URL.createObjectURL(e) : e.url;
65
- return /* @__PURE__ */ a(
66
- b.div,
79
+ showActionMenu: a = !1,
80
+ className: c
81
+ }, l) => {
82
+ const i = u(e) ? URL.createObjectURL(e) : e.url;
83
+ return /* @__PURE__ */ o(
84
+ h.div,
67
85
  {
68
- ref: o,
69
- className: N(
86
+ ref: l,
87
+ className: v(
70
88
  "border-d-border relative flex max-w-[200px] rounded-md border p-1.5 pr-2 text-xs",
71
- l
89
+ c
72
90
  ),
73
91
  layout: !0,
74
92
  initial: { opacity: 0, y: "100%" },
75
93
  animate: { opacity: 1, y: 0 },
76
94
  exit: { opacity: 0, y: "100%" },
77
95
  children: [
78
- /* @__PURE__ */ a("div", { className: "flex w-full items-center space-x-2", children: [
79
- /* @__PURE__ */ r(
96
+ /* @__PURE__ */ o("div", { className: "flex w-full min-w-0 items-center space-x-2", children: [
97
+ /* @__PURE__ */ t(
80
98
  "img",
81
99
  {
82
100
  alt: `Attachment ${e.name}`,
83
101
  className: "bg-d-secondary border-d-border grid h-10 w-10 shrink-0 place-items-center rounded-sm border object-cover",
84
- src: n
102
+ src: i
85
103
  }
86
104
  ),
87
- /* @__PURE__ */ r(y, { text: e.name }),
88
- d && /* @__PURE__ */ r(
89
- x,
105
+ /* @__PURE__ */ t(w, { text: e.name }),
106
+ a && /* @__PURE__ */ t(
107
+ y,
90
108
  {
91
- url: n,
92
- onPreview: i,
109
+ url: i,
110
+ onPreview: n,
93
111
  onDownload: s,
94
- onRemove: t
112
+ onRemove: r
95
113
  }
96
114
  )
97
115
  ] }),
98
- !d && t ? /* @__PURE__ */ r(
116
+ !a && r ? /* @__PURE__ */ t(
99
117
  "button",
100
118
  {
101
119
  className: "bg-d-background border-d-border absolute -top-2 -right-2 flex h-4 w-4 items-center justify-center rounded-full border",
102
120
  type: "button",
103
- onClick: () => t(n),
121
+ onClick: () => r(i),
104
122
  "aria-label": "Remove attachment",
105
- children: /* @__PURE__ */ r(f, { className: "h-2.5 w-2.5" })
123
+ children: /* @__PURE__ */ t(g, { className: "h-2.5 w-2.5" })
106
124
  }
107
125
  ) : null
108
126
  ]
@@ -110,51 +128,51 @@ const v = c.forwardRef(
110
128
  );
111
129
  }
112
130
  );
113
- v.displayName = "ImageFilePreview";
114
- const F = c.forwardRef(
115
- ({ file: e, onRemove: t, onPreview: i, onDownload: s, showActionMenu: d = !1 }, l) => {
116
- const [o, n] = c.useState(""), g = m(e) ? URL.createObjectURL(e) : e.url;
117
- return P(() => {
118
- if (m(e)) {
119
- const w = new FileReader();
120
- w.onload = (u) => {
121
- u.target?.result && n(
122
- typeof u.target.result == "string" ? u.target.result.slice(0, 100) : ""
131
+ N.displayName = "ImageFilePreview";
132
+ const F = p.forwardRef(
133
+ ({ file: e, onRemove: r, onPreview: n, onDownload: s, showActionMenu: a = !1 }, c) => {
134
+ const [l, i] = p.useState(""), f = u(e) ? URL.createObjectURL(e) : e.url;
135
+ return T(() => {
136
+ if (u(e)) {
137
+ const m = new FileReader();
138
+ m.onload = (d) => {
139
+ d.target?.result && i(
140
+ typeof d.target.result == "string" ? d.target.result.slice(0, 100) : ""
123
141
  );
124
- }, w.readAsText(e);
142
+ }, m.readAsText(e);
125
143
  } else
126
- n("Anteprima non disponibile");
127
- }, [e]), /* @__PURE__ */ a(
128
- b.div,
144
+ i("Anteprima non disponibile");
145
+ }, [e]), /* @__PURE__ */ o(
146
+ h.div,
129
147
  {
130
- ref: l,
148
+ ref: c,
131
149
  className: "border-d-border relative flex max-w-[200px] rounded-md border p-1.5 pr-2 text-xs",
132
150
  layout: !0,
133
151
  initial: { opacity: 0, y: "100%" },
134
152
  animate: { opacity: 1, y: 0 },
135
153
  exit: { opacity: 0, y: "100%" },
136
154
  children: [
137
- /* @__PURE__ */ a("div", { className: "flex w-full items-center space-x-2", children: [
138
- /* @__PURE__ */ r("div", { className: "bg-d-secondary border-d-border grid h-10 w-10 shrink-0 place-items-center rounded rounded-sm border p-1 text-[8px]", children: o }),
139
- /* @__PURE__ */ r(y, { text: e.name }),
140
- d && /* @__PURE__ */ r(
141
- x,
155
+ /* @__PURE__ */ o("div", { className: "flex w-full min-w-0 items-center space-x-2", children: [
156
+ /* @__PURE__ */ t("div", { className: "bg-d-secondary border-d-border grid h-10 w-10 shrink-0 place-items-center rounded rounded-sm border p-1 text-[8px]", children: l }),
157
+ /* @__PURE__ */ t(w, { text: e.name }),
158
+ a && /* @__PURE__ */ t(
159
+ y,
142
160
  {
143
- url: g,
144
- onPreview: i,
161
+ url: f,
162
+ onPreview: n,
145
163
  onDownload: s,
146
- onRemove: t
164
+ onRemove: r
147
165
  }
148
166
  )
149
167
  ] }),
150
- !d && t ? /* @__PURE__ */ r(
168
+ !a && r ? /* @__PURE__ */ t(
151
169
  "button",
152
170
  {
153
171
  className: "bg-d-background border-d-border absolute -top-2 -right-2 flex h-4 w-4 items-center justify-center rounded-full border",
154
172
  type: "button",
155
- onClick: () => t(g),
173
+ onClick: () => r(f),
156
174
  "aria-label": "Remove attachment",
157
- children: /* @__PURE__ */ r(f, { className: "h-2.5 w-2.5" })
175
+ children: /* @__PURE__ */ t(g, { className: "h-2.5 w-2.5" })
158
176
  }
159
177
  ) : null
160
178
  ]
@@ -163,50 +181,50 @@ const F = c.forwardRef(
163
181
  }
164
182
  );
165
183
  F.displayName = "TextFilePreview";
166
- const T = c.forwardRef(
184
+ const j = p.forwardRef(
167
185
  ({
168
186
  file: e,
169
- onRemove: t,
170
- onPreview: i,
187
+ onRemove: r,
188
+ onPreview: n,
171
189
  onDownload: s,
172
- showActionMenu: d = !1,
173
- className: l
174
- }, o) => {
175
- const n = m(e) ? URL.createObjectURL(e) : e.url;
176
- return /* @__PURE__ */ a(
177
- b.div,
190
+ showActionMenu: a = !1,
191
+ className: c
192
+ }, l) => {
193
+ const i = u(e) ? URL.createObjectURL(e) : e.url;
194
+ return /* @__PURE__ */ o(
195
+ h.div,
178
196
  {
179
- ref: o,
180
- className: N(
197
+ ref: l,
198
+ className: v(
181
199
  "border-d-border relative flex max-w-[200px] rounded-md border p-1.5 pr-2 text-xs",
182
- l
200
+ c
183
201
  ),
184
202
  layout: !0,
185
203
  initial: { opacity: 0, y: "100%" },
186
204
  animate: { opacity: 1, y: 0 },
187
205
  exit: { opacity: 0, y: "100%" },
188
206
  children: [
189
- /* @__PURE__ */ a("div", { className: "flex w-full cursor-pointer items-center space-x-2", children: [
190
- /* @__PURE__ */ r("div", { className: "bg-d-secondary border-d-border grid h-10 w-10 shrink-0 place-items-center rounded-sm border", children: /* @__PURE__ */ r(I, { className: "h-5 w-5" }) }),
191
- /* @__PURE__ */ r(y, { text: e.name }),
192
- d && /* @__PURE__ */ r(
193
- x,
207
+ /* @__PURE__ */ o("div", { className: "flex w-full min-w-0 cursor-pointer items-center space-x-2", children: [
208
+ /* @__PURE__ */ t("div", { className: "bg-d-secondary border-d-border grid h-10 w-10 shrink-0 place-items-center rounded-sm border", children: /* @__PURE__ */ t(I, { className: "h-5 w-5" }) }),
209
+ /* @__PURE__ */ t(w, { text: e.name }),
210
+ a && /* @__PURE__ */ t(
211
+ y,
194
212
  {
195
- url: n,
196
- onPreview: i,
213
+ url: i,
214
+ onPreview: n,
197
215
  onDownload: s,
198
- onRemove: t
216
+ onRemove: r
199
217
  }
200
218
  )
201
219
  ] }),
202
- !d && t ? /* @__PURE__ */ r(
220
+ !a && r ? /* @__PURE__ */ t(
203
221
  "button",
204
222
  {
205
223
  className: "bg-d-background border-d-border absolute -top-2 -right-2 flex h-4 w-4 items-center justify-center rounded-full border",
206
224
  type: "button",
207
- onClick: () => t(n),
225
+ onClick: () => r(i),
208
226
  "aria-label": "Remove attachment",
209
- children: /* @__PURE__ */ r(f, { className: "h-2.5 w-2.5" })
227
+ children: /* @__PURE__ */ t(g, { className: "h-2.5 w-2.5" })
210
228
  }
211
229
  ) : null
212
230
  ]
@@ -214,8 +232,8 @@ const T = c.forwardRef(
214
232
  );
215
233
  }
216
234
  );
217
- T.displayName = "GenericFilePreview";
235
+ j.displayName = "GenericFilePreview";
218
236
  export {
219
- G as FilePreview,
220
- y as default
237
+ O as FilePreview,
238
+ w as default
221
239
  };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { jsxs as D, jsx as r, Fragment as L } from "react/jsx-runtime";
2
+ import { jsxs as I, jsx as r, Fragment as L } from "react/jsx-runtime";
3
3
  import c from "react";
4
4
  import { FilePreview as C } from "./file-preview.js";
5
5
  import { Card as A, CardHeader as S, CardTitle as B, CardContent as P } from "./card.js";
@@ -22,28 +22,28 @@ const H = {
22
22
  image: "image/*",
23
23
  video: "video/*",
24
24
  audio: "audio/*"
25
- }, $ = (u) => Math.ceil(u / (1024 * 1024)), Q = ({
26
- accept: u,
25
+ }, $ = (p) => Math.ceil(p / (1024 * 1024)), Q = ({
26
+ accept: p,
27
27
  extensions: y = ["pdf", "image", "video", "audio"],
28
28
  multiple: d = !1,
29
29
  onUpload: v,
30
30
  description: b = "Trascina un file o clicca per selezionare",
31
- formatDescription: I = "Formato accettato: PDF, Immagini, Video, Audio",
31
+ formatDescription: N = "Formato accettato: PDF, Immagini, Video, Audio",
32
32
  selectedLabel: m = "File selezionati",
33
33
  maxTotalSize: n,
34
34
  maxFiles: g
35
35
  }) => {
36
- const f = u ?? y.map((e) => H[e]).join(","), [o, x] = c.useState([]), [w, a] = c.useState(""), N = (e) => {
36
+ const f = p ?? y.map((e) => H[e]).join(","), [o, x] = c.useState([]), [w, D] = c.useState(""), a = (e) => {
37
37
  const i = Array.from(e).filter(
38
38
  (s) => f.split(",").some((t) => (t = t.trim(), s.type.startsWith(t.replace("/*", "")) || s.name.toLowerCase().endsWith(t.replace("*", ""))))
39
39
  );
40
40
  let l = [];
41
- const p = [];
41
+ const u = [];
42
42
  if (d) {
43
43
  let s = i;
44
44
  if (typeof g == "number") {
45
45
  const t = Math.max(g - o.length, 0);
46
- t < i.length && (s = i.slice(0, t), p.push(`Max ${g} file`));
46
+ t < i.length && (s = i.slice(0, t), u.push(`Max ${g} file`));
47
47
  }
48
48
  if (typeof n == "number") {
49
49
  const t = n;
@@ -51,7 +51,7 @@ const H = {
51
51
  const j = [];
52
52
  let z = !1;
53
53
  for (const h of s)
54
- M + (h.size || 0) <= t ? (j.push(h), M += h.size || 0) : z || (p.push(`Max ${$(t)} MB`), z = !0);
54
+ M + (h.size || 0) <= t ? (j.push(h), M += h.size || 0) : z || (u.push(`Max ${$(t)} MB`), z = !0);
55
55
  s = j;
56
56
  }
57
57
  l = [...o, ...s];
@@ -59,20 +59,20 @@ const H = {
59
59
  const s = i[0] ? [i[0]] : [];
60
60
  if (typeof n == "number" && s[0]) {
61
61
  const t = n;
62
- (s[0].size || 0) > t ? (p.push(`Max ${$(t)} MB`), l = o) : l = s;
62
+ (s[0].size || 0) > t ? (u.push(`Max ${$(t)} MB`), l = o) : l = s;
63
63
  } else
64
64
  l = s;
65
65
  }
66
- x(l), a(p.join(" • ")), v?.(l);
66
+ x(l), D(u.join(" • ")), v?.(l);
67
67
  }, R = (e) => {
68
- e.target.files && N(e.target.files), e.target.value = "";
68
+ e.target.files && a(e.target.files), e.target.value = "";
69
69
  }, k = (e) => {
70
- e.preventDefault(), N(e.dataTransfer.files);
70
+ e.preventDefault(), a(e.dataTransfer.files);
71
71
  }, F = (e) => {
72
- const i = o.filter((l, p) => p !== e);
73
- x(i), a(""), v?.(i);
72
+ const i = o.filter((l, u) => u !== e);
73
+ x(i), D(""), v?.(i);
74
74
  };
75
- return /* @__PURE__ */ D("div", { className: "mx-auto w-full space-y-4", children: [
75
+ return /* @__PURE__ */ I("div", { className: "mx-auto w-full space-y-4", children: [
76
76
  (d || o.length === 0) && /* @__PURE__ */ r(
77
77
  K,
78
78
  {
@@ -81,11 +81,11 @@ const H = {
81
81
  onDrop: k,
82
82
  onChange: R,
83
83
  description: b,
84
- formatDescription: I,
84
+ formatDescription: N,
85
85
  errorCaption: w
86
86
  }
87
87
  ),
88
- o.length > 0 && /* @__PURE__ */ r(L, { children: /* @__PURE__ */ D(A, { size: "sm", className: "shadow-none", children: [
88
+ o.length > 0 && /* @__PURE__ */ r(L, { children: /* @__PURE__ */ I(A, { size: "sm", className: "shadow-none", children: [
89
89
  /* @__PURE__ */ r(S, { children: /* @__PURE__ */ r(B, { children: m }) }),
90
90
  /* @__PURE__ */ r(P, { children: d ? /* @__PURE__ */ r("div", { className: "flex flex-nowrap gap-2 overflow-x-auto py-2", children: o.map((e, i) => /* @__PURE__ */ r(
91
91
  C,
@@ -98,16 +98,16 @@ const H = {
98
98
  ] }) })
99
99
  ] });
100
100
  }, K = ({
101
- accept: u,
101
+ accept: p,
102
102
  multiple: y,
103
103
  onDrop: d,
104
104
  onChange: v,
105
105
  description: b,
106
- formatDescription: I,
106
+ formatDescription: N,
107
107
  errorCaption: m
108
108
  }) => {
109
- const n = c.useRef(null), [g, f] = c.useState(!1), o = c.useId(), x = c.useId(), w = c.useId();
110
- return /* @__PURE__ */ D(
109
+ const n = c.useRef(null), [g, f] = c.useState(!1), o = c.useId(), x = c.useId(), w = c.useId(), D = c.useId();
110
+ return /* @__PURE__ */ I(
111
111
  "div",
112
112
  {
113
113
  role: "button",
@@ -135,14 +135,14 @@ const H = {
135
135
  className: "text-d-muted-foreground h-10 w-10"
136
136
  }
137
137
  ),
138
- /* @__PURE__ */ D("div", { className: "max-w-xs text-center", children: [
138
+ /* @__PURE__ */ I("div", { className: "max-w-xs text-center", children: [
139
139
  /* @__PURE__ */ r("p", { id: o, className: "text-d-muted-foreground text-sm font-medium", children: b }),
140
140
  /* @__PURE__ */ r(
141
141
  "p",
142
142
  {
143
143
  id: x,
144
144
  className: "text-d-muted-foreground text-muted-foreground mt-1 text-xs",
145
- children: I
145
+ children: N
146
146
  }
147
147
  ),
148
148
  m ? /* @__PURE__ */ r("p", { id: w, className: "mt-2 text-xs font-medium text-red-600", children: m }) : null
@@ -151,10 +151,10 @@ const H = {
151
151
  W,
152
152
  {
153
153
  ref: n,
154
- id: "file",
154
+ id: D,
155
155
  type: "file",
156
156
  className: "hidden",
157
- accept: u,
157
+ accept: p,
158
158
  multiple: y,
159
159
  onChange: v
160
160
  }
@@ -1,16 +1,16 @@
1
1
  "use client";
2
2
  import { jsxs as o, jsx as e } from "react/jsx-runtime";
3
- import { useState as y, useEffect as S, useRef as J } from "react";
4
- import { AnimatePresence as v, motion as w } from "framer-motion";
5
- import { a as T } from "../../node_modules/remeda/dist/chunk-KI5X74E2.js";
6
- import { cn as C } from "../../lib/utils.js";
3
+ import { useState as y, useEffect as S, useRef as W } from "react";
4
+ import { AnimatePresence as v, motion as x } from "framer-motion";
5
+ import { a as J } from "../../node_modules/remeda/dist/chunk-KI5X74E2.js";
6
+ import { cn as T } from "../../lib/utils.js";
7
7
  import { useAudioRecording as Q } from "../../hooks/use-audio-recording.js";
8
8
  import { useAutosizeTextArea as X } from "../../hooks/use-autosize-textarea.js";
9
9
  import { AudioVisualizer as Y } from "./audio-visualizer.js";
10
10
  import { Button as g } from "./button.js";
11
11
  import { FilePreview as Z } from "./file-preview.js";
12
12
  import { InterruptPrompt as _ } from "./interrupt-prompt.js";
13
- import P from "../../node_modules/lucide-react/dist/esm/icons/paperclip.js";
13
+ import C from "../../node_modules/lucide-react/dist/esm/icons/paperclip.js";
14
14
  import $ from "../../node_modules/lucide-react/dist/esm/icons/mic.js";
15
15
  import G from "../../node_modules/lucide-react/dist/esm/icons/square.js";
16
16
  import ee from "../../node_modules/lucide-react/dist/esm/icons/arrow-up.js";
@@ -18,25 +18,25 @@ import te from "../../node_modules/lucide-react/dist/esm/icons/info.js";
18
18
  import re from "../../node_modules/lucide-react/dist/esm/icons/loader-circle.js";
19
19
  function ie({
20
20
  placeholder: i = "Ask AI...",
21
- className: n,
21
+ className: a,
22
22
  onKeyDown: d,
23
23
  submitOnEnter: l = !0,
24
24
  stop: s,
25
25
  isGenerating: u,
26
26
  enableInterrupt: A = !0,
27
- transcribeAudio: I,
27
+ transcribeAudio: P,
28
28
  ...r
29
29
  }) {
30
- const [R, x] = y(!1), [N, f] = y(!1), {
31
- isListening: F,
32
- isSpeechSupported: L,
30
+ const [I, w] = y(!1), [N, f] = y(!1), {
31
+ isListening: R,
32
+ isSpeechSupported: F,
33
33
  isRecording: D,
34
- isTranscribing: M,
35
- audioStream: O,
36
- toggleListening: j,
34
+ isTranscribing: L,
35
+ audioStream: M,
36
+ toggleListening: O,
37
37
  stopRecording: k
38
38
  } = Q({
39
- transcribeAudio: I,
39
+ transcribeAudio: P,
40
40
  onTranscriptionComplete: (t) => {
41
41
  r.onChange?.({ target: { value: t } });
42
42
  }
@@ -45,32 +45,32 @@ function ie({
45
45
  u || f(!1);
46
46
  }, [u]);
47
47
  const h = (t) => {
48
- r.allowAttachments && r.setFiles((a) => a === null ? t : t === null ? a : [...a, ...t]);
48
+ r.allowAttachments && r.setFiles((n) => n === null ? t : t === null ? n : [...n, ...t]);
49
+ }, j = (t) => {
50
+ r.allowAttachments === !0 && (t.preventDefault(), w(!0));
49
51
  }, q = (t) => {
50
- r.allowAttachments === !0 && (t.preventDefault(), x(!0));
52
+ r.allowAttachments === !0 && (t.preventDefault(), w(!1));
51
53
  }, E = (t) => {
52
- r.allowAttachments === !0 && (t.preventDefault(), x(!1));
53
- }, H = (t) => {
54
- if (x(!1), r.allowAttachments !== !0) return;
54
+ if (w(!1), r.allowAttachments !== !0) return;
55
55
  t.preventDefault();
56
- const a = t.dataTransfer;
57
- a.files.length && h(Array.from(a.files));
58
- }, K = (t) => {
59
- const a = t.clipboardData?.items;
60
- if (!a) return;
56
+ const n = t.dataTransfer;
57
+ n.files.length && h(Array.from(n.files));
58
+ }, H = (t) => {
59
+ const n = t.clipboardData?.items;
60
+ if (!n) return;
61
61
  const c = t.clipboardData.getData("text");
62
62
  if (c && c.length > 500 && r.allowAttachments) {
63
63
  t.preventDefault();
64
- const m = new Blob([c], { type: "text/plain" }), W = new File([m], "Pasted text", {
64
+ const m = new Blob([c], { type: "text/plain" }), B = new File([m], "Pasted text", {
65
65
  type: "text/plain",
66
66
  lastModified: Date.now()
67
67
  });
68
- h([W]);
68
+ h([B]);
69
69
  return;
70
70
  }
71
- const b = Array.from(a).map((m) => m.getAsFile()).filter((m) => m !== null);
71
+ const b = Array.from(n).map((m) => m.getAsFile()).filter((m) => m !== null);
72
72
  r.allowAttachments && b.length > 0 && h(b);
73
- }, U = (t) => {
73
+ }, K = (t) => {
74
74
  if (l && t.key === "Enter" && !t.shiftKey) {
75
75
  if (t.preventDefault(), u && s && A) {
76
76
  if (N)
@@ -83,11 +83,11 @@ function ie({
83
83
  t.currentTarget.form?.requestSubmit();
84
84
  }
85
85
  d?.(t);
86
- }, p = J(
86
+ }, p = W(
87
87
  null
88
- ), [V, B] = y(0);
88
+ ), [U, V] = y(0);
89
89
  S(() => {
90
- p.current && B(p.current.offsetHeight);
90
+ p.current && V(p.current.offsetHeight);
91
91
  }, [r.value]);
92
92
  const z = r.allowAttachments && r.files && r.files.length > 0;
93
93
  return X({
@@ -99,9 +99,9 @@ function ie({
99
99
  "div",
100
100
  {
101
101
  className: "relative flex w-full",
102
- onDragOver: q,
103
- onDragLeave: E,
104
- onDrop: H,
102
+ onDragOver: j,
103
+ onDragLeave: q,
104
+ onDrop: E,
105
105
  children: [
106
106
  A && /* @__PURE__ */ e(
107
107
  _,
@@ -124,14 +124,14 @@ function ie({
124
124
  "aria-label": "Write your prompt here",
125
125
  placeholder: i,
126
126
  ref: p,
127
- onPaste: K,
128
- onKeyDown: U,
129
- className: C(
127
+ onPaste: H,
128
+ onKeyDown: K,
129
+ className: T(
130
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
- n
132
+ a
133
133
  ),
134
- ...r.allowAttachments ? T(r, ["allowAttachments", "files", "setFiles"]) : T(r, ["allowAttachments"])
134
+ ...J(r, ["allowAttachments", "files", "setFiles"])
135
135
  }
136
136
  ),
137
137
  r.allowAttachments && /* @__PURE__ */ e("div", { className: "absolute inset-x-3 bottom-2 z-20 overflow-x-scroll py-3 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden", children: /* @__PURE__ */ e("div", { className: "flex space-x-3", children: /* @__PURE__ */ e(v, { mode: "popLayout", children: r.files?.map((t) => /* @__PURE__ */ e(
@@ -139,9 +139,9 @@ function ie({
139
139
  {
140
140
  file: t,
141
141
  onRemove: () => {
142
- r.setFiles((a) => {
143
- if (!a) return null;
144
- const c = Array.from(a).filter(
142
+ r.setFiles((n) => {
143
+ if (!n) return null;
144
+ const c = Array.from(n).filter(
145
145
  (b) => b !== t
146
146
  );
147
147
  return c.length === 0 ? null : c;
@@ -161,21 +161,21 @@ function ie({
161
161
  className: "h-8 w-8",
162
162
  "aria-label": "Attach a file",
163
163
  onClick: async () => {
164
- const t = await ne();
164
+ const t = await ae();
165
165
  h(t);
166
166
  },
167
- children: /* @__PURE__ */ e(P, { className: "h-4 w-4" })
167
+ children: /* @__PURE__ */ e(C, { className: "h-4 w-4" })
168
168
  }
169
169
  ),
170
- L && /* @__PURE__ */ e(
170
+ F && /* @__PURE__ */ e(
171
171
  g,
172
172
  {
173
173
  type: "button",
174
174
  variant: "outline",
175
- className: C("h-8 w-8", F && "text-d-primary"),
175
+ className: T("h-8 w-8", R && "text-d-primary"),
176
176
  "aria-label": "Voice input",
177
177
  size: "icon",
178
- onClick: j,
178
+ onClick: O,
179
179
  children: /* @__PURE__ */ e($, { className: "h-4 w-4" })
180
180
  }
181
181
  ),
@@ -201,14 +201,14 @@ function ie({
201
201
  }
202
202
  )
203
203
  ] }),
204
- r.allowAttachments && /* @__PURE__ */ e(ae, { isDragging: R }),
204
+ r.allowAttachments && /* @__PURE__ */ e(ne, { isDragging: I }),
205
205
  /* @__PURE__ */ e(
206
206
  se,
207
207
  {
208
208
  isRecording: D,
209
- isTranscribing: M,
210
- audioStream: O,
211
- textAreaHeight: V,
209
+ isTranscribing: L,
210
+ audioStream: M,
211
+ textAreaHeight: U,
212
212
  onStopRecording: k
213
213
  }
214
214
  )
@@ -217,9 +217,9 @@ function ie({
217
217
  );
218
218
  }
219
219
  ie.displayName = "MessageInput";
220
- function ae({ isDragging: i }) {
220
+ function ne({ isDragging: i }) {
221
221
  return /* @__PURE__ */ e(v, { children: i && /* @__PURE__ */ o(
222
- w.div,
222
+ x.div,
223
223
  {
224
224
  className: "border-d-border bg-d-background text-d-secondary-foreground pointer-events-none absolute inset-0 z-20 flex items-center justify-center space-x-2 rounded-xl border border-dashed text-sm",
225
225
  initial: { opacity: 0 },
@@ -228,30 +228,30 @@ function ae({ isDragging: i }) {
228
228
  transition: { duration: 0.2 },
229
229
  "aria-hidden": !0,
230
230
  children: [
231
- /* @__PURE__ */ e(P, { className: "h-4 w-4" }),
231
+ /* @__PURE__ */ e(C, { className: "h-4 w-4" }),
232
232
  /* @__PURE__ */ e("span", { children: "Drop your files here to attach them." })
233
233
  ]
234
234
  }
235
235
  ) });
236
236
  }
237
- function ne() {
237
+ function ae() {
238
238
  if (typeof document > "u")
239
239
  return Promise.resolve(null);
240
240
  const i = document.createElement("input");
241
- return i.type = "file", i.multiple = !0, i.accept = "*/*", i.click(), new Promise((n) => {
241
+ return i.type = "file", i.multiple = !0, i.accept = "*/*", i.click(), new Promise((a) => {
242
242
  i.onchange = (d) => {
243
243
  const l = d.currentTarget.files;
244
244
  if (l) {
245
- n(Array.from(l));
245
+ a(Array.from(l));
246
246
  return;
247
247
  }
248
- n(null);
248
+ a(null);
249
249
  };
250
250
  });
251
251
  }
252
252
  function le() {
253
253
  return /* @__PURE__ */ o(
254
- w.div,
254
+ x.div,
255
255
  {
256
256
  className: "bg-d-background/80 flex h-full w-full flex-col items-center justify-center rounded-xl backdrop-blur-sm",
257
257
  initial: { opacity: 0 },
@@ -262,7 +262,7 @@ function le() {
262
262
  /* @__PURE__ */ o("div", { className: "relative", children: [
263
263
  /* @__PURE__ */ e(re, { className: "text-d-primary h-8 w-8 animate-spin" }),
264
264
  /* @__PURE__ */ e(
265
- w.div,
265
+ x.div,
266
266
  {
267
267
  className: "bg-d-primary/20 absolute inset-0 h-8 w-8 animate-pulse rounded-full",
268
268
  initial: { scale: 0.8, opacity: 0 },
@@ -281,9 +281,9 @@ function le() {
281
281
  }
282
282
  );
283
283
  }
284
- function oe({ isVisible: i, onStopRecording: n }) {
284
+ function oe({ isVisible: i, onStopRecording: a }) {
285
285
  return /* @__PURE__ */ e(v, { children: i && /* @__PURE__ */ e(
286
- w.div,
286
+ x.div,
287
287
  {
288
288
  initial: { top: 0, filter: "blur(5px)" },
289
289
  animate: {
@@ -296,7 +296,7 @@ function oe({ isVisible: i, onStopRecording: n }) {
296
296
  },
297
297
  exit: { top: 0, filter: "blur(5px)" },
298
298
  className: "bg-d-background border-d-border text-d-secondary-foreground absolute left-1/2 flex -translate-x-1/2 cursor-pointer overflow-hidden rounded-full border py-1 text-center text-sm whitespace-nowrap",
299
- onClick: n,
299
+ onClick: a,
300
300
  children: /* @__PURE__ */ o("span", { className: "mx-2.5 flex items-center", children: [
301
301
  /* @__PURE__ */ e(te, { className: "mr-2 h-3 w-3" }),
302
302
  "Click to finish recording"
@@ -306,7 +306,7 @@ function oe({ isVisible: i, onStopRecording: n }) {
306
306
  }
307
307
  function se({
308
308
  isRecording: i,
309
- isTranscribing: n,
309
+ isTranscribing: a,
310
310
  audioStream: d,
311
311
  textAreaHeight: l,
312
312
  onStopRecording: s
@@ -325,7 +325,7 @@ function se({
325
325
  }
326
326
  )
327
327
  }
328
- ) : n ? /* @__PURE__ */ e(
328
+ ) : a ? /* @__PURE__ */ e(
329
329
  "div",
330
330
  {
331
331
  className: "absolute inset-[1px] z-50 overflow-hidden rounded-xl",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "laif-ds",
3
3
  "private": false,
4
- "version": "0.2.9",
4
+ "version": "0.2.11",
5
5
  "type": "module",
6
6
  "main": "dist/index.es.js",
7
7
  "module": "dist/index.es.js",