laif-ds 0.2.53 → 0.2.55

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,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsxs as f, jsx as t } from "react/jsx-runtime";
3
- import { Calendar as w } from "./calendar.js";
3
+ import { Calendar as T } from "./calendar.js";
4
4
  import { Icon as E } from "./icon.js";
5
5
  import { Label as L } from "./label.js";
6
6
  import { Popover as q, PopoverTrigger as A, PopoverContent as B } from "./popover.js";
@@ -17,7 +17,7 @@ function v({
17
17
  placeholder: I = "Seleziona data",
18
18
  dateFormat: a = "dd/MM/yyyy",
19
19
  className: M,
20
- disabled: n = !1,
20
+ disabled: s = !1,
21
21
  size: m = "default",
22
22
  firstDate: l,
23
23
  lastDate: u,
@@ -30,21 +30,21 @@ function v({
30
30
  }) {
31
31
  const [r, y] = c.useState(e), [O, C] = c.useState(
32
32
  g
33
- ), [S, R] = c.useState(!1), z = (s) => {
34
- y(s), s && C(s), p && p(s);
33
+ ), [S, R] = c.useState(!1), w = (n) => {
34
+ y(n), n && C(n), p && p(n);
35
35
  };
36
36
  let i = [];
37
37
  l && i.push({ before: l }), u && i.push({ after: u }), h?.length && i.push(
38
- (s) => !h.some(
39
- (T) => H(T, s)
38
+ (n) => !h.some(
39
+ (z) => H(z, n)
40
40
  )
41
- ), n && (i = [!0]), F(() => {
41
+ ), s && (i = [!0]), F(() => {
42
42
  y(r), C(r || g);
43
43
  }, [r]);
44
44
  const b = c.useId();
45
45
  return /* @__PURE__ */ f("div", { className: P("flex flex-col gap-1.5", k), children: [
46
46
  x && /* @__PURE__ */ t(L, { htmlFor: b, children: x }),
47
- /* @__PURE__ */ f(q, { open: n ? !1 : S, onOpenChange: R, children: [
47
+ /* @__PURE__ */ f(q, { open: s ? !1 : S, onOpenChange: R, children: [
48
48
  /* @__PURE__ */ t(A, { asChild: !0, children: /* @__PURE__ */ f(
49
49
  "div",
50
50
  {
@@ -59,16 +59,16 @@ function v({
59
59
  S && o.activeRing,
60
60
  "hover:border-d-ring cursor-pointer transition-colors",
61
61
  !r && "text-d-muted-foreground",
62
- n && "cursor-not-allowed opacity-50",
62
+ s && "cursor-not-allowed opacity-50",
63
63
  m === "default" && o.sizes.default,
64
64
  m === "sm" && o.sizes.sm,
65
65
  m === "lg" && o.sizes.lg,
66
66
  M
67
67
  ),
68
- "aria-disabled": n,
68
+ "aria-disabled": s,
69
69
  role: "button",
70
- tabIndex: n ? -1 : 0,
71
- onClick: n ? void 0 : () => {
70
+ tabIndex: s ? -1 : 0,
71
+ onClick: s ? void 0 : () => {
72
72
  },
73
73
  children: [
74
74
  /* @__PURE__ */ t(
@@ -86,13 +86,13 @@ function v({
86
86
  ]
87
87
  }
88
88
  ) }),
89
- /* @__PURE__ */ t(B, { className: "w-auto p-0", children: /* @__PURE__ */ t(
90
- w,
89
+ /* @__PURE__ */ t(B, { className: "w-auto p-0 shadow", children: /* @__PURE__ */ t(
90
+ T,
91
91
  {
92
92
  ...j || {
93
93
  mode: "single",
94
94
  selected: r,
95
- onSelect: z
95
+ onSelect: w
96
96
  },
97
97
  autoFocus: !0,
98
98
  disabled: i,
@@ -1,316 +1,263 @@
1
1
  "use client";
2
- import { jsx as t, jsxs as o } from "react/jsx-runtime";
3
- import { getExt as C, imageExts as W } from "../../lib/file-preview.js";
4
- import { motion as F } from "framer-motion";
5
- import f, { useEffect as E } from "react";
6
- import { Button as R } from "./button.js";
7
- import { Command as B, CommandGroup as $, CommandItem as v } from "./command.js";
8
- import { Icon as y } from "./icon.js";
9
- import { Popover as A, PopoverTrigger as S, PopoverContent as D } from "./popover.js";
10
- import { Tooltip as G, TooltipTrigger as M, TooltipContent as V } from "./tooltip.js";
11
- import { cn as N } from "../../lib/utils.js";
12
- import z from "../../node_modules/lucide-react/dist/esm/icons/x.js";
13
- import O from "../../node_modules/lucide-react/dist/esm/icons/file-audio.js";
14
- import P from "../../node_modules/lucide-react/dist/esm/icons/file-video.js";
15
- import h from "../../node_modules/lucide-react/dist/esm/icons/file-text.js";
16
- import X from "../../node_modules/lucide-react/dist/esm/icons/file.js";
17
- import _ from "../../node_modules/lucide-react/dist/esm/icons/file-code.js";
18
- import K from "../../node_modules/lucide-react/dist/esm/icons/file-archive.js";
19
- import q from "../../node_modules/lucide-react/dist/esm/icons/file-spreadsheet.js";
20
- const d = (e) => "type" in e && typeof e.type == "string" && e instanceof File, T = (e) => e.name || "url" in e && e.url || "", U = (e) => {
21
- if (d(e)) return e.type || "";
22
- const r = e.type;
23
- return typeof r == "string" ? r : "";
24
- }, H = (e, r) => {
25
- if (!e && r) {
26
- if (r.startsWith("audio/"))
27
- return { icon: O, colorClass: "text-violet-600" };
28
- if (r.startsWith("video/"))
29
- return { icon: P, colorClass: "text-rose-600" };
30
- if (r.startsWith("text/"))
31
- return { icon: h, colorClass: "text-gray-600" };
32
- }
33
- switch (e) {
34
- case "pdf":
35
- return { icon: h, colorClass: "text-red-600" };
36
- case "doc":
37
- case "docx":
38
- return { icon: h, colorClass: "text-blue-600" };
39
- case "xls":
40
- case "xlsx":
41
- case "csv":
42
- return { icon: q, colorClass: "text-green-600" };
43
- case "ppt":
44
- case "pptx":
45
- return { icon: h, colorClass: "text-orange-600" };
46
- case "txt":
47
- case "md":
48
- return { icon: h, colorClass: "text-gray-600" };
49
- case "zip":
50
- case "rar":
51
- case "7z":
52
- case "tar":
53
- case "gz":
54
- case "tgz":
55
- return { icon: K, colorClass: "text-amber-600" };
56
- case "mp3":
57
- case "wav":
58
- case "ogg":
59
- case "flac":
60
- case "m4a":
61
- return { icon: O, colorClass: "text-violet-600" };
62
- case "mp4":
63
- case "mov":
64
- case "avi":
65
- case "mkv":
66
- case "webm":
67
- return { icon: P, colorClass: "text-rose-600" };
68
- case "js":
69
- case "ts":
70
- case "jsx":
71
- case "tsx":
72
- case "json":
73
- case "xml":
74
- case "yml":
75
- case "yaml":
76
- case "html":
77
- case "css":
78
- case "scss":
79
- return { icon: _, colorClass: "text-indigo-600" };
80
- default:
81
- return { icon: X, colorClass: "text-d-secondary-foreground" };
82
- }
83
- }, L = (e) => {
2
+ import { jsx as i, jsxs as a, Fragment as g } from "react/jsx-runtime";
3
+ import { getExt as h, imageExts as P } from "../../lib/file-preview.js";
4
+ import { motion as k } from "framer-motion";
5
+ import c, { useEffect as j } from "react";
6
+ import { AppTextTooltip as z } from "./app-tooltip.js";
7
+ import { Button as L } from "./button.js";
8
+ import { Command as A, CommandGroup as T, CommandItem as B } from "./command.js";
9
+ import { Icon as p } from "./icon.js";
10
+ import { Popover as I, PopoverTrigger as U, PopoverContent as E } from "./popover.js";
11
+ import { cn as b } from "../../lib/utils.js";
12
+ import l from "../../node_modules/lucide-react/dist/esm/icons/file-text.js";
13
+ import F from "../../node_modules/lucide-react/dist/esm/icons/file-audio.js";
14
+ import N from "../../node_modules/lucide-react/dist/esm/icons/file-video.js";
15
+ import S from "../../node_modules/lucide-react/dist/esm/icons/file.js";
16
+ import O from "../../node_modules/lucide-react/dist/esm/icons/file-spreadsheet.js";
17
+ import R from "../../node_modules/lucide-react/dist/esm/icons/file-archive.js";
18
+ import $ from "../../node_modules/lucide-react/dist/esm/icons/file-code.js";
19
+ const u = (e) => "type" in e && typeof e.type == "string" && e instanceof File, d = (e) => e.name || "url" in e && e.url || "", v = (e) => {
20
+ if (u(e)) return e.type || "";
21
+ const t = e.type;
22
+ return typeof t == "string" ? t : "";
23
+ }, W = (e, t) => {
24
+ const o = {
25
+ pdf: { icon: l, colorClass: "text-red-600" },
26
+ doc: { icon: l, colorClass: "text-blue-600" },
27
+ docx: { icon: l, colorClass: "text-blue-600" },
28
+ ppt: { icon: l, colorClass: "text-orange-600" },
29
+ pptx: { icon: l, colorClass: "text-orange-600" },
30
+ txt: { icon: l, colorClass: "text-gray-600" },
31
+ md: { icon: l, colorClass: "text-gray-600" }
32
+ }, r = (s, n) => s.forEach((m) => o[m] = n);
33
+ return r(["xls", "xlsx", "csv"], {
34
+ icon: O,
35
+ colorClass: "text-green-600"
36
+ }), r(["zip", "rar", "7z", "tar", "gz", "tgz"], {
37
+ icon: R,
38
+ colorClass: "text-amber-600"
39
+ }), r(["mp3", "wav", "ogg", "flac", "m4a"], {
40
+ icon: F,
41
+ colorClass: "text-violet-600"
42
+ }), r(["mp4", "mov", "avi", "mkv", "webm"], {
43
+ icon: N,
44
+ colorClass: "text-rose-600"
45
+ }), r(
46
+ [
47
+ "js",
48
+ "ts",
49
+ "jsx",
50
+ "tsx",
51
+ "json",
52
+ "xml",
53
+ "yml",
54
+ "yaml",
55
+ "html",
56
+ "css",
57
+ "scss"
58
+ ],
59
+ {
60
+ icon: $,
61
+ colorClass: "text-indigo-600"
62
+ }
63
+ ), e && o[e] ? o[e] : t?.startsWith("audio/") ? { icon: F, colorClass: "text-violet-600" } : t?.startsWith("video/") ? { icon: N, colorClass: "text-rose-600" } : t?.startsWith("text/") ? { icon: l, colorClass: "text-gray-600" } : { icon: S, colorClass: "text-d-secondary-foreground" };
64
+ }, _ = (e) => {
84
65
  if (!Number.isFinite(e) || e < 0) return "";
85
- const r = ["B", "KB", "MB", "GB", "TB"];
86
- let s = 0, a = e;
87
- for (; a >= 1024 && s < r.length - 1; )
88
- a /= 1024, s++;
89
- const n = s > 0 && a < 100 ? 2 : 0;
90
- return `${a.toFixed(n)}${r[s]}`;
91
- }, j = (e) => {
92
- const r = C(T(e));
93
- if (r) return r.toUpperCase();
94
- const s = U(e);
95
- return s ? s === "application/pdf" ? "PDF" : s.startsWith("image/") ? s.split("/")[1]?.toUpperCase() || "IMAGE" : s.startsWith("audio/") ? "AUDIO" : s.startsWith("video/") ? "VIDEO" : s.startsWith("text/") ? "TEXT" : s.includes("officedocument") || s.includes("msword") || s.includes("ms-excel") || s.includes("ms-powerpoint") ? "OFFICE" : "" : "";
96
- }, k = ({
66
+ if (e === 0) return "0B";
67
+ const t = ["B", "KB", "MB", "GB", "TB"], o = Math.min(
68
+ Math.floor(Math.log(e) / Math.log(1024)),
69
+ t.length - 1
70
+ ), r = e / 1024 ** o, s = o > 0 && r < 100 ? 2 : 0;
71
+ return `${r.toFixed(s)}${t[o]}`;
72
+ }, G = (e) => {
73
+ const t = u(e) ? _(e.size) : "", o = V(e);
74
+ return { sizeLabel: t, formatLabel: o };
75
+ }, D = (e, t) => e && t ? `${e} · ${t}` : e || t || null, K = {
76
+ layout: !0,
77
+ initial: { opacity: 0, y: "100%" },
78
+ animate: { opacity: 1, y: 0 },
79
+ exit: { opacity: 0, y: "100%" }
80
+ }, y = ({
81
+ sizeLabel: e,
82
+ formatLabel: t
83
+ }) => {
84
+ const o = D(e, t);
85
+ return o ? /* @__PURE__ */ i("div", { className: "text-d-secondary-foreground/70 text-xs", children: o }) : null;
86
+ }, V = (e) => {
87
+ const t = h(d(e));
88
+ if (t) return t.toUpperCase();
89
+ const o = v(e);
90
+ if (!o) return "";
91
+ if (o === "application/pdf") return "PDF";
92
+ const [r, s] = o.split("/");
93
+ return r === "image" ? s?.toUpperCase() || "IMAGE" : r === "audio" || r === "video" || r === "text" ? r.toUpperCase() : /(officedocument|msword|ms-excel|ms-powerpoint)/.test(o) ? "OFFICE" : "";
94
+ }, X = ({
97
95
  url: e,
98
- onPreview: r,
99
- onDownload: s,
100
- onRemove: a
101
- }) => /* @__PURE__ */ o(A, { children: [
102
- /* @__PURE__ */ t(S, { asChild: !0, children: /* @__PURE__ */ t(R, { variant: "ghost", size: "icon", children: /* @__PURE__ */ t(y, { name: "Menu", size: "sm" }) }) }),
103
- /* @__PURE__ */ t(D, { className: "w-42 p-0", align: "end", children: /* @__PURE__ */ t(B, { children: /* @__PURE__ */ o($, { children: [
104
- r && /* @__PURE__ */ o(v, { onSelect: () => r(e), children: [
105
- /* @__PURE__ */ t(y, { name: "Presentation", size: "sm" }),
106
- /* @__PURE__ */ t("span", { children: "Anteprima" })
107
- ] }),
108
- s && /* @__PURE__ */ o(v, { onSelect: () => s(e), children: [
109
- /* @__PURE__ */ t(y, { name: "Download", size: "sm" }),
110
- /* @__PURE__ */ t("span", { children: "Download" })
111
- ] }),
112
- a && /* @__PURE__ */ o(
113
- v,
96
+ onPreview: t,
97
+ onDownload: o,
98
+ onRemove: r
99
+ }) => /* @__PURE__ */ a(I, { children: [
100
+ /* @__PURE__ */ i(U, { asChild: !0, children: /* @__PURE__ */ i(L, { variant: "ghost", size: "icon", children: /* @__PURE__ */ i(p, { name: "Menu", size: "sm" }) }) }),
101
+ /* @__PURE__ */ i(E, { className: "w-42 p-0", align: "end", children: /* @__PURE__ */ i(A, { children: /* @__PURE__ */ i(T, { children: [
102
+ {
103
+ key: "preview",
104
+ cond: !!t,
105
+ icon: "Presentation",
106
+ label: "Anteprima",
107
+ onSelect: t
108
+ },
109
+ {
110
+ key: "download",
111
+ cond: !!o,
112
+ icon: "Download",
113
+ label: "Download",
114
+ onSelect: o
115
+ },
116
+ {
117
+ key: "remove",
118
+ cond: !!r,
119
+ icon: "Trash",
120
+ label: "Elimina",
121
+ onSelect: r,
122
+ danger: !0
123
+ }
124
+ ].map(
125
+ (n) => n.cond && /* @__PURE__ */ a(
126
+ B,
114
127
  {
115
- onSelect: () => a(e),
116
- className: "text-red-500",
128
+ onSelect: () => n.onSelect?.(e),
129
+ className: n.danger ? "text-d-destructive" : void 0,
117
130
  children: [
118
- /* @__PURE__ */ t(y, { name: "Trash", className: "text-red-500", size: "sm" }),
119
- /* @__PURE__ */ t("span", { children: "Elimina" })
131
+ /* @__PURE__ */ i(
132
+ p,
133
+ {
134
+ name: n.icon,
135
+ size: "sm",
136
+ className: n.danger ? "text-d-destructive" : void 0
137
+ }
138
+ ),
139
+ /* @__PURE__ */ i("span", { children: n.label })
120
140
  ]
121
- }
141
+ },
142
+ n.key
122
143
  )
123
- ] }) }) })
124
- ] });
125
- function I({ text: e }) {
126
- return /* @__PURE__ */ o(G, { children: [
127
- /* @__PURE__ */ t(M, { "data-slot": "tooltip-trigger", className: "w-full min-w-0", children: /* @__PURE__ */ t("span", { className: "text-d-secondary-foreground block w-full truncate", children: e }) }),
128
- /* @__PURE__ */ t(V, { children: /* @__PURE__ */ t("span", { children: e }) })
129
- ] });
130
- }
131
- const be = f.forwardRef(
132
- (e, r) => {
133
- const s = T(e.file), a = C(s), n = U(e.file), m = a === "csv" || n === "text/csv";
134
- return n && n.startsWith("image/") || a && W.has(a) ? /* @__PURE__ */ t(J, { ...e, ref: r }) : !m && (a === "txt" || a === "md" || n && n.startsWith("text/")) ? /* @__PURE__ */ t(Q, { ...e, ref: r }) : /* @__PURE__ */ t(Y, { ...e, ref: r });
144
+ ) }) }) })
145
+ ] }), xe = c.forwardRef(
146
+ (e, t) => {
147
+ const o = d(e.file), r = h(o), s = v(e.file), n = r === "csv" || s === "text/csv";
148
+ return s && s.startsWith("image/") || r && P.has(r) ? /* @__PURE__ */ i(q, { ...e, ref: t }) : !n && (r === "txt" || r === "md" || s && s.startsWith("text/")) ? /* @__PURE__ */ i(H, { ...e, ref: t }) : /* @__PURE__ */ i(J, { ...e, ref: t });
135
149
  }
136
- ), J = f.forwardRef(
150
+ ), C = c.forwardRef(
137
151
  ({
138
152
  file: e,
139
- onRemove: r,
140
- onPreview: s,
141
- onDownload: a,
142
- showActionMenu: n = !1,
143
- className: m
144
- }, p) => {
145
- const i = d(e) ? URL.createObjectURL(e) : e.url, l = d(e) ? L(e.size) : "", c = j(e);
146
- return /* @__PURE__ */ o(
147
- F.div,
153
+ onRemove: t,
154
+ onPreview: o,
155
+ onDownload: r,
156
+ showActionMenu: s = !1,
157
+ className: n,
158
+ defaultClassName: m,
159
+ children: w
160
+ }, f) => {
161
+ const x = u(e) ? URL.createObjectURL(e) : e.url, M = G(e);
162
+ return /* @__PURE__ */ a(
163
+ k.div,
148
164
  {
149
- ref: p,
150
- className: N(
151
- "border-d-border relative flex max-w-[200px] rounded-md border p-1.5 pr-2 text-xs",
152
- m
165
+ ref: f,
166
+ className: b(
167
+ "border-d-border relative flex items-center rounded-md border text-xs",
168
+ m,
169
+ n
153
170
  ),
154
- layout: !0,
155
- initial: { opacity: 0, y: "100%" },
156
- animate: { opacity: 1, y: 0 },
157
- exit: { opacity: 0, y: "100%" },
171
+ ...K,
158
172
  children: [
159
- /* @__PURE__ */ o("div", { className: "flex w-full min-w-0 items-center space-x-2", children: [
160
- /* @__PURE__ */ t(
161
- "img",
162
- {
163
- alt: `Attachment ${e.name}`,
164
- className: "bg-d-secondary border-d-border grid h-10 w-10 shrink-0 place-items-center rounded-sm border object-cover",
165
- src: i
166
- }
167
- ),
168
- /* @__PURE__ */ o("div", { className: "min-w-0", children: [
169
- /* @__PURE__ */ t(I, { text: e.name }),
170
- (l || c) && /* @__PURE__ */ o("div", { className: "text-d-secondary-foreground/70 mt-0.5 text-[10px] leading-3", children: [
171
- l,
172
- c ? l ? ` · ${c}` : c : ""
173
- ] })
174
- ] }),
175
- n && /* @__PURE__ */ t(
176
- k,
173
+ /* @__PURE__ */ a("div", { className: "flex w-full min-w-0 items-center gap-2", children: [
174
+ w(x, M),
175
+ s && /* @__PURE__ */ i(
176
+ X,
177
177
  {
178
- url: i,
179
- onPreview: s,
180
- onDownload: a,
181
- onRemove: r
178
+ url: x,
179
+ onPreview: o,
180
+ onDownload: r,
181
+ onRemove: t
182
182
  }
183
183
  )
184
184
  ] }),
185
- !n && r ? /* @__PURE__ */ t(
186
- "button",
185
+ !s && t ? /* @__PURE__ */ i(
186
+ L,
187
187
  {
188
- className: "bg-d-background border-d-border absolute -top-2 -right-2 flex h-4 w-4 items-center justify-center rounded-full border",
189
- type: "button",
190
- onClick: () => r(i),
191
- "aria-label": "Remove attachment",
192
- children: /* @__PURE__ */ t(z, { className: "h-2.5 w-2.5" })
188
+ className: "bg-d-background hover:bg-d-background absolute -top-2 -right-2 flex !size-3.5 rounded-full text-xs",
189
+ variant: "outline",
190
+ size: "icon",
191
+ onClick: () => t(x),
192
+ children: /* @__PURE__ */ i(p, { name: "X", className: "h-2.5 max-w-2.5" })
193
193
  }
194
194
  ) : null
195
195
  ]
196
196
  }
197
197
  );
198
198
  }
199
- ), Q = f.forwardRef(({ file: e, onRemove: r, onPreview: s, onDownload: a, showActionMenu: n = !1 }, m) => {
200
- const [p, i] = f.useState(""), l = d(e) ? URL.createObjectURL(e) : e.url, c = d(e) ? L(e.size) : "", u = j(e);
201
- return E(() => {
202
- if (d(e)) {
203
- const b = new FileReader();
204
- b.onload = (x) => {
205
- x.target?.result && i(
206
- typeof x.target.result == "string" ? x.target.result.slice(0, 100) : ""
207
- );
208
- }, b.readAsText(e);
209
- } else
210
- i("Anteprima non disponibile");
211
- }, [e]), /* @__PURE__ */ o(
212
- F.div,
199
+ ), q = c.forwardRef((e, t) => /* @__PURE__ */ i(C, { ...e, ref: t, defaultClassName: "gap-2 p-1.5 pr-2", children: (o, r) => /* @__PURE__ */ a(g, { children: [
200
+ /* @__PURE__ */ i(
201
+ "img",
213
202
  {
214
- ref: m,
215
- className: "border-d-border relative flex max-w-[200px] rounded-md border p-1.5 pr-2 text-xs",
216
- layout: !0,
217
- initial: { opacity: 0, y: "100%" },
218
- animate: { opacity: 1, y: 0 },
219
- exit: { opacity: 0, y: "100%" },
220
- children: [
221
- /* @__PURE__ */ o("div", { className: "flex w-full min-w-0 items-center space-x-2", children: [
222
- /* @__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: p }),
223
- /* @__PURE__ */ o("div", { className: "min-w-0", children: [
224
- /* @__PURE__ */ t(I, { text: e.name }),
225
- (c || u) && /* @__PURE__ */ o("div", { className: "text-d-secondary-foreground/70 mt-0.5 text-[10px] leading-3", children: [
226
- c,
227
- u ? c ? ` · ${u}` : u : ""
228
- ] })
229
- ] }),
230
- n && /* @__PURE__ */ t(
231
- k,
232
- {
233
- url: l,
234
- onPreview: s,
235
- onDownload: a,
236
- onRemove: r
237
- }
238
- )
239
- ] }),
240
- !n && r ? /* @__PURE__ */ t(
241
- "button",
242
- {
243
- className: "bg-d-background border-d-border absolute -top-2 -right-2 flex h-4 w-4 items-center justify-center rounded-full border",
244
- type: "button",
245
- onClick: () => r(l),
246
- "aria-label": "Remove attachment",
247
- children: /* @__PURE__ */ t(z, { className: "h-2.5 w-2.5" })
248
- }
249
- ) : null
250
- ]
203
+ alt: `Attachment ${d(e.file)}`,
204
+ className: b(
205
+ "bg-d-secondary border-d-border h-10 w-10 shrink-0 rounded-sm border object-cover"
206
+ ),
207
+ src: o
251
208
  }
252
- );
253
- }), Y = f.forwardRef(
254
- ({
255
- file: e,
256
- onRemove: r,
257
- onPreview: s,
258
- onDownload: a,
259
- showActionMenu: n = !1,
260
- className: m
261
- }, p) => {
262
- const i = d(e) ? URL.createObjectURL(e) : e.url, l = T(e), c = C(l), u = U(e), { icon: b, colorClass: x } = H(c, u), w = d(e) ? L(e.size) : "", g = j(e);
263
- return /* @__PURE__ */ o(
264
- F.div,
209
+ ),
210
+ /* @__PURE__ */ a("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
211
+ /* @__PURE__ */ i(z, { text: d(e.file) }),
212
+ /* @__PURE__ */ i(
213
+ y,
265
214
  {
266
- ref: p,
267
- className: N(
268
- "border-d-border relative flex max-w-[200px] rounded-md border p-1.5 pr-2 text-xs",
269
- m
270
- ),
271
- layout: !0,
272
- initial: { opacity: 0, y: "100%" },
273
- animate: { opacity: 1, y: 0 },
274
- exit: { opacity: 0, y: "100%" },
275
- children: [
276
- /* @__PURE__ */ o("div", { className: "flex w-full min-w-0 cursor-pointer items-center space-x-2", children: [
277
- /* @__PURE__ */ t("div", { className: "bg-d-secondary grid h-10 w-10 shrink-0 place-items-center rounded-sm", children: /* @__PURE__ */ t(b, { className: N("h-5 w-5", x) }) }),
278
- /* @__PURE__ */ o("div", { className: "min-w-0", children: [
279
- /* @__PURE__ */ t(I, { text: e.name }),
280
- (w || g) && /* @__PURE__ */ o("div", { className: "text-d-secondary-foreground/70 mt-0.5 text-[10px] leading-3", children: [
281
- w,
282
- g ? w ? ` · ${g}` : g : ""
283
- ] })
284
- ] }),
285
- n && /* @__PURE__ */ t(
286
- k,
287
- {
288
- url: i,
289
- onPreview: s,
290
- onDownload: a,
291
- onRemove: r
292
- }
293
- )
294
- ] }),
295
- !n && r ? /* @__PURE__ */ t(
296
- "button",
297
- {
298
- className: "bg-d-background border-d-border absolute -top-2 -right-2 flex h-4 w-4 items-center justify-center rounded-full border",
299
- type: "button",
300
- onClick: () => r(i),
301
- "aria-label": "Remove attachment",
302
- children: /* @__PURE__ */ t(z, { className: "h-2.5 w-2.5" })
303
- }
304
- ) : null
305
- ]
215
+ sizeLabel: r.sizeLabel,
216
+ formatLabel: r.formatLabel
306
217
  }
307
- );
308
- }
309
- );
218
+ )
219
+ ] })
220
+ ] }) })), H = c.forwardRef((e, t) => {
221
+ const [o, r] = c.useState("");
222
+ return j(() => {
223
+ if (u(e.file)) {
224
+ const s = new FileReader();
225
+ s.onload = (n) => {
226
+ n.target?.result && r(
227
+ typeof n.target.result == "string" ? n.target.result.slice(0, 100) : ""
228
+ );
229
+ }, s.readAsText(e.file);
230
+ } else
231
+ r("Anteprima non disponibile");
232
+ }, [e.file]), /* @__PURE__ */ i(C, { ...e, ref: t, defaultClassName: "gap-2 p-1.5 pr-2", children: (s, n) => /* @__PURE__ */ a(g, { children: [
233
+ /* @__PURE__ */ i("div", { className: "bg-d-secondary border-d-border flex h-10 w-10 shrink-0 items-center justify-center rounded-sm border p-1 text-[8px]", children: o }),
234
+ /* @__PURE__ */ i("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ i(
235
+ y,
236
+ {
237
+ sizeLabel: n.sizeLabel,
238
+ formatLabel: n.formatLabel
239
+ }
240
+ ) })
241
+ ] }) });
242
+ }), J = c.forwardRef((e, t) => {
243
+ const o = d(e.file), r = h(o), s = v(e.file), { icon: n, colorClass: m } = W(r, s);
244
+ return /* @__PURE__ */ i(C, { ...e, ref: t, defaultClassName: "gap-2 p-1.5 pr-2", children: (w, f) => /* @__PURE__ */ a(g, { children: [
245
+ /* @__PURE__ */ i("div", { className: "bg-d-secondary flex h-10 w-10 shrink-0 items-center justify-center rounded-sm", children: /* @__PURE__ */ i(n, { className: b("h-5 w-5", m) }) }),
246
+ /* @__PURE__ */ a("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
247
+ /* @__PURE__ */ i(z, { text: o }),
248
+ /* @__PURE__ */ i(
249
+ y,
250
+ {
251
+ sizeLabel: f.sizeLabel,
252
+ formatLabel: f.formatLabel
253
+ }
254
+ )
255
+ ] })
256
+ ] }) });
257
+ });
310
258
  export {
311
- be as FilePreview,
312
- Y as GenericFilePreview,
313
- J as ImageFilePreview,
314
- Q as TextFilePreview,
315
- I as default
259
+ xe as FilePreview,
260
+ J as GenericFilePreview,
261
+ q as ImageFilePreview,
262
+ H as TextFilePreview
316
263
  };