laif-ds 0.2.13 → 0.2.14

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,8 +1,5 @@
1
1
  "use client";
2
- import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.js";
3
- import { __require as r } from "../node_modules/extend/index.js";
4
- var t = r();
5
- const x = /* @__PURE__ */ e(t);
2
+ var e = { exports: {} };
6
3
  export {
7
- x as default
4
+ e as __module
8
5
  };
@@ -1,8 +1,8 @@
1
1
  "use client";
2
- import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
3
- import { __require as e } from "../node_modules/style-to-js/cjs/index.js";
4
- var t = e();
5
- const a = /* @__PURE__ */ r(t);
2
+ import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.js";
3
+ import { __require as r } from "../node_modules/extend/index.js";
4
+ var t = r();
5
+ const x = /* @__PURE__ */ e(t);
6
6
  export {
7
- a as default
7
+ x as default
8
8
  };
@@ -1,5 +1,8 @@
1
1
  "use client";
2
- var e = {};
2
+ import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
3
+ import { __require as e } from "../node_modules/style-to-js/cjs/index.js";
4
+ var t = e();
5
+ const a = /* @__PURE__ */ r(t);
3
6
  export {
4
- e as __exports
7
+ a as default
5
8
  };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- var e = { exports: {} };
2
+ var e = {};
3
3
  export {
4
- e as __module
4
+ e as __exports
5
5
  };
@@ -4,8 +4,8 @@ import * as l from "react";
4
4
  import k from "../../node_modules/embla-carousel-react/esm/embla-carousel-react.esm.js";
5
5
  import { cn as d } from "../../lib/utils.js";
6
6
  import { Button as v } from "./button.js";
7
- import z from "../../node_modules/lucide-react/dist/esm/icons/arrow-left.js";
8
- import g from "../../node_modules/lucide-react/dist/esm/icons/arrow-right.js";
7
+ import z from "../../node_modules/lucide-react/dist/esm/icons/arrow-right.js";
8
+ import g from "../../node_modules/lucide-react/dist/esm/icons/arrow-left.js";
9
9
  const p = l.createContext(null);
10
10
  function m() {
11
11
  const o = l.useContext(p);
@@ -136,7 +136,7 @@ function q({
136
136
  onClick: i,
137
137
  ...s,
138
138
  children: [
139
- /* @__PURE__ */ a(z, {}),
139
+ /* @__PURE__ */ a(g, {}),
140
140
  /* @__PURE__ */ a("span", { className: "sr-only", children: "Previous slide" })
141
141
  ]
142
142
  }
@@ -164,7 +164,7 @@ function F({
164
164
  onClick: i,
165
165
  ...s,
166
166
  children: [
167
- /* @__PURE__ */ a(g, {}),
167
+ /* @__PURE__ */ a(z, {}),
168
168
  /* @__PURE__ */ a("span", { className: "sr-only", children: "Next slide" })
169
169
  ]
170
170
  }
@@ -2,8 +2,8 @@
2
2
  import { jsx as s, jsxs as f, Fragment as L } from "react/jsx-runtime";
3
3
  import * as p from "react";
4
4
  import { cn as l } from "../../lib/utils.js";
5
- import { Tooltip as T } from "../../node_modules/recharts/es6/component/Tooltip.js";
6
- import { Legend as I } from "../../node_modules/recharts/es6/component/Legend.js";
5
+ import { Legend as T } from "../../node_modules/recharts/es6/component/Legend.js";
6
+ import { Tooltip as I } from "../../node_modules/recharts/es6/component/Tooltip.js";
7
7
  import { ResponsiveContainer as K } from "../../node_modules/recharts/es6/component/ResponsiveContainer.js";
8
8
  const P = { light: "", dark: ".dark" }, N = p.createContext(null);
9
9
  function j() {
@@ -60,7 +60,7 @@ ${t.map(([d, o]) => {
60
60
  }
61
61
  }
62
62
  ) : null;
63
- }, z = T;
63
+ }, z = I;
64
64
  function A({
65
65
  active: c,
66
66
  payload: e,
@@ -155,7 +155,7 @@ function A({
155
155
  }
156
156
  );
157
157
  }
158
- const B = I;
158
+ const B = T;
159
159
  function D({
160
160
  className: c,
161
161
  hideIcon: e = !1,
@@ -0,0 +1,170 @@
1
+ "use client";
2
+ import { jsx as t, jsxs as T } from "react/jsx-runtime";
3
+ import { createAsk as j } from "../../node_modules/use-ask/dist/index.js";
4
+ import { Dialog as U, DialogContent as O, DialogHeader as E, DialogTitle as L, DialogDescription as k } from "./dialog.js";
5
+ import { Icon as C } from "./icon.js";
6
+ import { getExt as M, guessKind as S, isHttpUrl as A, getOfficeEmbedUrl as z } from "../../lib/file-preview.js";
7
+ import { cn as H } from "../../lib/utils.js";
8
+ import { useRef as q, useState as x, useEffect as N, useMemo as g } from "react";
9
+ const [R, B] = j({});
10
+ function D(r) {
11
+ return typeof r == "string" ? { url: r } : r instanceof File ? { file: r, filename: r.name, mimeType: r.type } : typeof r == "function" ? { loader: r } : r && typeof r.then == "function" ? { loader: r } : r || {};
12
+ }
13
+ async function _(r) {
14
+ return R.ask(D(r));
15
+ }
16
+ function $(r) {
17
+ return R.safeAsk(D(r));
18
+ }
19
+ function I(r, s, a) {
20
+ const n = q(null), [d, u] = x(!1), [v, m] = x(null), [y, c] = x(null), [e, p] = x({});
21
+ N(() => {
22
+ if (!s) {
23
+ p({}), u(!1), m(null);
24
+ return;
25
+ }
26
+ const i = r || {};
27
+ p({
28
+ url: i.url,
29
+ file: i.file,
30
+ filename: i.filename,
31
+ mimeType: i.mimeType,
32
+ title: i.title
33
+ });
34
+ const o = i.loader;
35
+ if (!o) return;
36
+ let f = !1;
37
+ return u(!0), m(null), (async () => {
38
+ try {
39
+ const l = typeof o == "function" ? await o() : await o;
40
+ if (f) return;
41
+ typeof l == "string" ? p((h) => ({ ...h, url: l })) : l instanceof File ? p((h) => ({
42
+ ...h,
43
+ file: l,
44
+ filename: l.name,
45
+ mimeType: l.type
46
+ })) : l && typeof l == "object" && p((h) => ({ ...h, ...l }));
47
+ } catch (l) {
48
+ f || m(l?.message || "Errore durante il caricamento della preview");
49
+ } finally {
50
+ f || u(!1);
51
+ }
52
+ })(), () => {
53
+ f = !0;
54
+ };
55
+ }, [s, a, r]), N(() => {
56
+ if (e.file) {
57
+ const i = URL.createObjectURL(e.file);
58
+ return n.current = i, () => {
59
+ n.current && (URL.revokeObjectURL(n.current), n.current = null);
60
+ };
61
+ }
62
+ }, [e.file]);
63
+ const F = g(
64
+ () => e.file ? n.current || void 0 : e.url,
65
+ [e.file, e.url]
66
+ ), w = g(
67
+ () => e.filename || e.file?.name || M(e.url || "") || "document",
68
+ [e.filename, e.file, e.url]
69
+ ), b = g(
70
+ () => S({
71
+ mimeType: e.mimeType,
72
+ filename: w,
73
+ url: e.url
74
+ }),
75
+ [e.mimeType, w, e.url]
76
+ );
77
+ N(() => {
78
+ if (c(null), b === "text")
79
+ if (e.file) {
80
+ const i = new FileReader();
81
+ i.onload = (o) => {
82
+ if (typeof o.target?.result == "string") {
83
+ const f = o.target.result.length > 2e5 ? o.target.result.slice(0, 2e5) + `
84
+ …` : o.target.result;
85
+ c(f);
86
+ }
87
+ }, i.readAsText(e.file);
88
+ } else e.url && A(e.url) ? fetch(e.url).then((i) => i.text()).then(
89
+ (i) => c(i.length > 2e5 ? i.slice(0, 2e5) + `
90
+ …` : i)
91
+ ).catch(() => c("Anteprima non disponibile")) : c("Anteprima non disponibile");
92
+ }, [b, e.file, e.url, a]);
93
+ const P = g(
94
+ () => /* @__PURE__ */ T("span", { className: "flex items-center gap-2", children: [
95
+ /* @__PURE__ */ t(C, { name: "File", className: "h-4 w-4" }),
96
+ r?.title || e.title || w
97
+ ] }),
98
+ [r, e.title, w]
99
+ );
100
+ return { loading: d, error: v, src: F, text: y, kind: b, title: P };
101
+ }
102
+ const ee = () => {
103
+ const [{ key: r, payload: s }, { asking: a, cancel: n }] = B(), { loading: d, error: u, src: v, text: m, kind: y, title: c } = I(
104
+ s,
105
+ a,
106
+ r
107
+ );
108
+ return /* @__PURE__ */ t(U, { open: a, onOpenChange: (e) => !e && n(), children: /* @__PURE__ */ T(O, { size: "xl", className: "sm:max-w-4xl", children: [
109
+ /* @__PURE__ */ T(E, { children: [
110
+ /* @__PURE__ */ t(L, { children: c }),
111
+ u ? /* @__PURE__ */ t(k, { className: "text-red-600", children: u }) : null
112
+ ] }),
113
+ /* @__PURE__ */ t("div", { className: H("relative", "max-h-[80vh] overflow-auto p-1"), children: d ? /* @__PURE__ */ t("div", { className: "grid h-[60vh] place-items-center", children: /* @__PURE__ */ t("div", { className: "border-d-border border-t-d-foreground h-10 w-10 animate-spin rounded-full border-2" }) }) : /* @__PURE__ */ t(K, { kind: y, src: v, text: m, officeUrl: v }) })
114
+ ] }) });
115
+ }, K = ({
116
+ kind: r,
117
+ src: s,
118
+ text: a,
119
+ officeUrl: n
120
+ }) => {
121
+ if (!s && r !== "text" && r !== "office")
122
+ return /* @__PURE__ */ t("div", { className: "text-d-secondary-foreground", children: "Nessuna sorgente disponibile" });
123
+ switch (r) {
124
+ case "image":
125
+ return /* @__PURE__ */ t("div", { className: "grid place-items-center", children: /* @__PURE__ */ t(
126
+ "img",
127
+ {
128
+ src: s,
129
+ alt: "preview",
130
+ className: "max-h-[78vh] w-auto max-w-full object-contain"
131
+ }
132
+ ) });
133
+ case "pdf":
134
+ return /* @__PURE__ */ t(
135
+ "iframe",
136
+ {
137
+ src: s,
138
+ title: "PDF Preview",
139
+ className: "h-[78vh] w-full rounded"
140
+ }
141
+ );
142
+ case "audio":
143
+ return /* @__PURE__ */ t("div", { className: "grid place-items-center", children: /* @__PURE__ */ t("audio", { controls: !0, className: "w-full max-w-2xl", children: /* @__PURE__ */ t("source", { src: s }) }) });
144
+ case "video":
145
+ return /* @__PURE__ */ t("div", { className: "grid place-items-center", children: /* @__PURE__ */ t("video", { controls: !0, className: "max-h-[78vh] w-full max-w-3xl rounded", children: /* @__PURE__ */ t("source", { src: s }) }) });
146
+ case "text":
147
+ return /* @__PURE__ */ t("pre", { className: "max-h-[78vh] overflow-auto rounded border p-3 text-sm whitespace-pre-wrap", children: a || "Caricamento…" });
148
+ case "office": {
149
+ if (n && A(n)) {
150
+ const d = z(n);
151
+ return /* @__PURE__ */ t(
152
+ "iframe",
153
+ {
154
+ src: d,
155
+ title: "Office Preview",
156
+ className: "h-[78vh] w-full rounded"
157
+ }
158
+ );
159
+ }
160
+ return /* @__PURE__ */ t("div", { className: "rounded border p-3 text-sm", children: 'Anteprima Office non disponibile per file locali. Usa "Apri in nuova scheda" o "Download".' });
161
+ }
162
+ default:
163
+ return /* @__PURE__ */ t("div", { className: "rounded border p-3 text-sm", children: "Anteprima non disponibile per questo tipo di file." });
164
+ }
165
+ };
166
+ export {
167
+ ee as FilePreviewer,
168
+ _ as previewFileModal,
169
+ $ as safePreviewFileModal
170
+ };
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsxs as i, jsx as e } from "react/jsx-runtime";
3
- import { Root as d, List as s, Item as u, Content as l, Trigger as g, Link as c, Indicator as m, Viewport as v } from "../../node_modules/@radix-ui/react-navigation-menu/dist/index.js";
3
+ import { Root as d, Content as s, Indicator as u, Item as l, Link as g, List as c, Trigger as m, Viewport as v } from "../../node_modules/@radix-ui/react-navigation-menu/dist/index.js";
4
4
  import { cva as f } from "../../node_modules/class-variance-authority/dist/index.js";
5
5
  import { cn as o } from "../../lib/utils.js";
6
6
  import p from "../../node_modules/lucide-react/dist/esm/icons/chevron-down.js";
@@ -32,7 +32,7 @@ function j({
32
32
  ...a
33
33
  }) {
34
34
  return /* @__PURE__ */ e(
35
- s,
35
+ c,
36
36
  {
37
37
  "data-slot": "navigation-menu-list",
38
38
  className: o(
@@ -48,7 +48,7 @@ function k({
48
48
  ...a
49
49
  }) {
50
50
  return /* @__PURE__ */ e(
51
- u,
51
+ l,
52
52
  {
53
53
  "data-slot": "navigation-menu-item",
54
54
  className: o("relative", t),
@@ -65,7 +65,7 @@ function I({
65
65
  ...n
66
66
  }) {
67
67
  return /* @__PURE__ */ i(
68
- g,
68
+ m,
69
69
  {
70
70
  "data-slot": "navigation-menu-trigger",
71
71
  className: o(w(), "group", t),
@@ -89,7 +89,7 @@ function L({
89
89
  ...a
90
90
  }) {
91
91
  return /* @__PURE__ */ e(
92
- l,
92
+ s,
93
93
  {
94
94
  "data-slot": "navigation-menu-content",
95
95
  className: o(
@@ -130,7 +130,7 @@ function C({
130
130
  ...a
131
131
  }) {
132
132
  return /* @__PURE__ */ e(
133
- c,
133
+ g,
134
134
  {
135
135
  "data-slot": "navigation-menu-link",
136
136
  className: o(
@@ -146,7 +146,7 @@ function T({
146
146
  ...a
147
147
  }) {
148
148
  return /* @__PURE__ */ e(
149
- m,
149
+ u,
150
150
  {
151
151
  "data-slot": "navigation-menu-indicator",
152
152
  className: o(
@@ -1,19 +1,28 @@
1
1
  "use client";
2
- import { jsx as i } from "react/jsx-runtime";
3
- import { cn as d } from "../../lib/utils.js";
4
- function o({ className: r, ...e }) {
5
- return /* @__PURE__ */ i(
6
- "textarea",
7
- {
8
- "data-slot": "textarea",
9
- className: d(
10
- "border-d-input placeholder:text-d-secondary-foreground focus-visible:border-d-ring focus-visible:ring-d-ring/50 aria-invalid:ring-d-destructive/20 dark:aria-invalid:ring-d-destructive/40 aria-invalid:border-d-destructive dark:bg-d-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
11
- r
12
- ),
13
- ...e
14
- }
15
- );
2
+ import { jsxs as t, Fragment as a, jsx as r } from "react/jsx-runtime";
3
+ import { cn as n } from "../../lib/utils.js";
4
+ import { Label as o } from "./label.js";
5
+ function c({
6
+ className: d,
7
+ label: e,
8
+ ...i
9
+ }) {
10
+ return /* @__PURE__ */ t(a, { children: [
11
+ e && /* @__PURE__ */ r(o, { htmlFor: i.id, children: e }),
12
+ /* @__PURE__ */ r(
13
+ "textarea",
14
+ {
15
+ id: i.id,
16
+ "data-slot": "textarea",
17
+ className: n(
18
+ "border-d-input placeholder:text-d-muted-foreground focus-visible:border-d-ring focus-visible:ring-d-ring/50 aria-invalid:ring-d-destructive/20 dark:aria-invalid:ring-d-destructive/40 aria-invalid:border-d-destructive dark:bg-d-input/30 !bg-d-input flex field-sizing-content min-h-16 w-full rounded-md border px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
19
+ d
20
+ ),
21
+ ...i
22
+ }
23
+ )
24
+ ] });
16
25
  }
17
26
  export {
18
- o as Textarea
27
+ c as Textarea
19
28
  };
package/dist/index.d.ts CHANGED
@@ -56,6 +56,7 @@ import { Toaster as Toaster_2 } from 'sonner';
56
56
  import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
57
57
  import * as TogglePrimitive from '@radix-ui/react-toggle';
58
58
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
59
+ import { UseAskResult } from 'use-ask';
59
60
  import { UseEmblaCarouselType } from 'embla-carousel-react';
60
61
  import { VariantProps } from 'class-variance-authority';
61
62
 
@@ -814,7 +815,7 @@ declare interface DatePickerProps {
814
815
  export declare function Dialog({ ...props }: React_2.ComponentProps<typeof DialogPrimitive.Root>): JSX.Element;
815
816
 
816
817
  export declare function DialogContent({ className, children, size, ...props }: React_2.ComponentProps<typeof DialogPrimitive.Content> & {
817
- size?: "sm" | "default" | "lg";
818
+ size?: "sm" | "default" | "lg" | "xl";
818
819
  }): JSX.Element;
819
820
 
820
821
  export declare function DialogDescription({ className, ...props }: React_2.ComponentProps<typeof DialogPrimitive.Description>): JSX.Element;
@@ -878,6 +879,8 @@ export declare enum ELogicalFilterOperator {
878
879
 
879
880
  export declare const FilePreview: default_2.ForwardRefExoticComponent<FilePreviewProps & default_2.RefAttributes<HTMLDivElement>>;
880
881
 
882
+ export declare const FilePreviewer: () => JSX.Element;
883
+
881
884
  declare interface FilePreviewProps {
882
885
  file: IFilePreviewCallbackReturn;
883
886
  onRemove?: (url: string) => void;
@@ -1139,6 +1142,14 @@ export declare interface IServerOptionsProps {
1139
1142
 
1140
1143
  export declare function Label({ className, ...props }: React_2.ComponentProps<typeof LabelPrimitive.Root>): JSX.Element;
1141
1144
 
1145
+ declare type LoaderReturn = string | File | {
1146
+ url?: string;
1147
+ file?: File;
1148
+ filename?: string;
1149
+ mimeType?: string;
1150
+ title?: React.ReactNode;
1151
+ };
1152
+
1142
1153
  export declare function MarkdownRenderer({ children }: MarkdownRendererProps): JSX.Element;
1143
1154
 
1144
1155
  declare interface MarkdownRendererProps {
@@ -1429,8 +1440,21 @@ export declare function PopoverContent({ className, align, sideOffset, container
1429
1440
 
1430
1441
  export declare function PopoverTrigger({ ...props }: React_2.ComponentProps<typeof PopoverPrimitive.Trigger>): JSX.Element;
1431
1442
 
1443
+ declare type PreviewArg = string | File | PreviewOptions | (() => Promise<LoaderReturn>) | Promise<LoaderReturn>;
1444
+
1432
1445
  export declare const previewFile: (url: string, filename?: string) => void;
1433
1446
 
1447
+ export declare function previewFileModal(arg: PreviewArg): Promise<void>;
1448
+
1449
+ declare interface PreviewOptions {
1450
+ url?: string;
1451
+ file?: File;
1452
+ filename?: string;
1453
+ mimeType?: string;
1454
+ title?: React.ReactNode;
1455
+ loader?: (() => Promise<LoaderReturn>) | Promise<LoaderReturn>;
1456
+ }
1457
+
1434
1458
  export declare function Progress({ className, value, ...props }: React_2.ComponentProps<typeof ProgressPrimitive.Root>): JSX.Element;
1435
1459
 
1436
1460
  export declare function PromptSuggestions({ label, append, suggestions, }: PromptSuggestionsProps): JSX.Element;
@@ -1522,6 +1546,8 @@ export declare function ResizablePanel({ ...props }: React_2.ComponentProps<type
1522
1546
 
1523
1547
  export declare function ResizablePanelGroup({ className, ...props }: React_2.ComponentProps<typeof ResizablePrimitive.PanelGroup>): JSX.Element;
1524
1548
 
1549
+ export declare function safePreviewFileModal(arg: PreviewArg): Promise<UseAskResult<void, unknown>>;
1550
+
1525
1551
  export declare function ScrollArea({ className, children, ...props }: React_2.ComponentProps<typeof ScrollAreaPrimitive.Root>): JSX.Element;
1526
1552
 
1527
1553
  export declare function ScrollBar({ className, orientation, ...props }: React_2.ComponentProps<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>): JSX.Element;
@@ -1727,7 +1753,9 @@ export declare function TabsList({ className, ...props }: React_2.ComponentProps
1727
1753
 
1728
1754
  export declare function TabsTrigger({ className, ...props }: React_2.ComponentProps<typeof TabsPrimitive.Trigger>): JSX.Element;
1729
1755
 
1730
- export declare function Textarea({ className, ...props }: React_2.ComponentProps<"textarea">): JSX.Element;
1756
+ export declare function Textarea({ className, label, ...props }: React_2.ComponentProps<"textarea"> & {
1757
+ label?: React_2.ReactNode;
1758
+ }): JSX.Element;
1731
1759
 
1732
1760
  declare interface TextPart {
1733
1761
  type: "text";