laif-ds 0.2.30 → 0.2.31
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.
- package/dist/_virtual/index2.js +2 -5
- package/dist/_virtual/index3.js +5 -2
- package/dist/_virtual/index6.js +2 -2
- package/dist/_virtual/index7.js +2 -2
- package/dist/_virtual/warning.js +8 -0
- package/dist/components/ui/file-previewer.js +46 -36
- package/dist/components/ui/secure-pdf-viewer.js +115 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +131 -129
- package/dist/laif-ds.css +1 -1
- package/dist/node_modules/dequal/dist/index.js +56 -0
- package/dist/node_modules/eventemitter3/index.js +1 -1
- package/dist/node_modules/eventemitter3/index2.js +1 -1
- package/dist/node_modules/make-cancellable-promise/dist/index.js +15 -0
- package/dist/node_modules/make-event-props/dist/index.js +114 -0
- package/dist/node_modules/merge-refs/dist/index.js +19 -0
- package/dist/node_modules/react-pdf/dist/Document.js +180 -0
- package/dist/node_modules/react-pdf/dist/DocumentContext.js +6 -0
- package/dist/node_modules/react-pdf/dist/LinkService.js +94 -0
- package/dist/node_modules/react-pdf/dist/Message.js +8 -0
- package/dist/node_modules/react-pdf/dist/Page/AnnotationLayer.js +97 -0
- package/dist/node_modules/react-pdf/dist/Page/Canvas.js +55 -0
- package/dist/node_modules/react-pdf/dist/Page/TextLayer.js +111 -0
- package/dist/node_modules/react-pdf/dist/Page.js +180 -0
- package/dist/node_modules/react-pdf/dist/PageContext.js +6 -0
- package/dist/node_modules/react-pdf/dist/PasswordResponses.js +8 -0
- package/dist/node_modules/react-pdf/dist/StructTree.js +44 -0
- package/dist/node_modules/react-pdf/dist/StructTreeItem.js +14 -0
- package/dist/node_modules/react-pdf/dist/index.js +9 -0
- package/dist/node_modules/react-pdf/dist/shared/constants.js +62 -0
- package/dist/node_modules/react-pdf/dist/shared/hooks/useDocumentContext.js +9 -0
- package/dist/node_modules/react-pdf/dist/shared/hooks/usePageContext.js +9 -0
- package/dist/node_modules/react-pdf/dist/shared/hooks/useResolver.js +20 -0
- package/dist/node_modules/react-pdf/dist/shared/structTreeUtils.js +55 -0
- package/dist/node_modules/react-pdf/dist/shared/utils.js +110 -0
- package/dist/node_modules/react-pdf/node_modules/pdfjs-dist/build/pdf.js +15282 -0
- package/dist/node_modules/recharts/es6/util/Events.js +1 -1
- package/dist/node_modules/style-to-object/cjs/index.js +1 -1
- package/dist/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +13 -0
- package/dist/node_modules/use-sync-external-store/shim/index.js +1 -1
- package/dist/node_modules/warning/warning.js +39 -0
- package/dist/styles.v3.css +1 -1
- package/package.json +3 -1
package/dist/_virtual/index2.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
import { __require as t } from "../node_modules/eventemitter3/index2.js";
|
|
4
|
-
var r = t();
|
|
5
|
-
const m = /* @__PURE__ */ e(r);
|
|
2
|
+
var e = { exports: {} };
|
|
6
3
|
export {
|
|
7
|
-
|
|
4
|
+
e as __module
|
|
8
5
|
};
|
package/dist/_virtual/index3.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
2
|
+
import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.js";
|
|
3
|
+
import { __require as t } from "../node_modules/eventemitter3/index2.js";
|
|
4
|
+
var r = t();
|
|
5
|
+
const m = /* @__PURE__ */ e(r);
|
|
3
6
|
export {
|
|
4
|
-
|
|
7
|
+
m as default
|
|
5
8
|
};
|
package/dist/_virtual/index6.js
CHANGED
package/dist/_virtual/index7.js
CHANGED
|
@@ -2,98 +2,108 @@
|
|
|
2
2
|
import { jsxs as f, jsx as r } from "react/jsx-runtime";
|
|
3
3
|
import { createAsk as w } from "../../node_modules/use-ask/dist/index.js";
|
|
4
4
|
import { Dialog as x, DialogContent as g, DialogHeader as N, DialogTitle as y } from "./dialog.js";
|
|
5
|
-
import { Icon as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { Icon as P } from "./icon.js";
|
|
6
|
+
import { SecurePdfViewer as b } from "./secure-pdf-viewer.js";
|
|
7
|
+
import { guessKind as A, isHttpUrl as D, getOfficeEmbedUrl as O } from "../../lib/file-preview.js";
|
|
8
|
+
import { cn as F } from "../../lib/utils.js";
|
|
8
9
|
import { useMemo as c } from "react";
|
|
9
|
-
const [p,
|
|
10
|
+
const [p, T] = w({});
|
|
10
11
|
function h(e) {
|
|
11
12
|
return typeof e == "string" ? { url: e } : e || {};
|
|
12
13
|
}
|
|
13
|
-
async function
|
|
14
|
+
async function q(e) {
|
|
14
15
|
return p.ask(h(e));
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
+
function B(e) {
|
|
17
18
|
return p.safeAsk(h(e));
|
|
18
19
|
}
|
|
19
|
-
const
|
|
20
|
-
const [{ payload: e }, { asking:
|
|
20
|
+
const E = () => {
|
|
21
|
+
const [{ payload: e }, { asking: i, ok: n }] = T(), l = e?.url, a = e?.readOnly, o = e?.page, t = c(() => e?.filename ? e?.filename : (e?.url || "").split(/[?#]/)[0].split("/").pop() || "" || "document", [e?.filename, e?.url]), m = c(() => {
|
|
21
22
|
if (!e?.url) return null;
|
|
22
23
|
const s = new URL(e?.url), u = s.searchParams.get("response-content-type") || s.searchParams.get("content-type"), d = e?.mimeType || u || "";
|
|
23
|
-
return
|
|
24
|
+
return A({
|
|
24
25
|
mimeType: d,
|
|
25
|
-
filename:
|
|
26
|
+
filename: t,
|
|
26
27
|
url: e?.url
|
|
27
28
|
});
|
|
28
|
-
}, [e?.mimeType,
|
|
29
|
+
}, [e?.mimeType, t, e?.url]), v = c(
|
|
29
30
|
() => /* @__PURE__ */ f("span", { className: "flex items-center gap-2", children: [
|
|
30
|
-
/* @__PURE__ */ r(
|
|
31
|
-
e?.title ||
|
|
31
|
+
/* @__PURE__ */ r(P, { name: "File", className: "h-4 w-4" }),
|
|
32
|
+
e?.title || t
|
|
32
33
|
] }),
|
|
33
|
-
[e?.title,
|
|
34
|
+
[e?.title, t]
|
|
34
35
|
);
|
|
35
|
-
return /* @__PURE__ */ r(x, { open:
|
|
36
|
+
return /* @__PURE__ */ r(x, { open: i, onOpenChange: (s) => !s && n(), children: /* @__PURE__ */ f(g, { size: "xl", className: "sm:max-w-4xl", children: [
|
|
36
37
|
/* @__PURE__ */ r(N, { children: /* @__PURE__ */ r(y, { children: v }) }),
|
|
37
|
-
/* @__PURE__ */ r("div", { className:
|
|
38
|
-
|
|
38
|
+
/* @__PURE__ */ r("div", { className: F("relative", "max-h-[80vh] overflow-auto p-1"), children: m && l ? /* @__PURE__ */ r(
|
|
39
|
+
j,
|
|
39
40
|
{
|
|
40
41
|
kind: m,
|
|
41
42
|
src: l,
|
|
42
43
|
officeUrl: l,
|
|
43
|
-
readOnly:
|
|
44
|
-
page:
|
|
44
|
+
readOnly: a,
|
|
45
|
+
page: o
|
|
45
46
|
}
|
|
46
47
|
) : null })
|
|
47
48
|
] }) });
|
|
48
|
-
},
|
|
49
|
+
}, j = ({
|
|
49
50
|
kind: e,
|
|
50
|
-
src:
|
|
51
|
+
src: i,
|
|
51
52
|
officeUrl: n,
|
|
52
53
|
readOnly: l = !1,
|
|
53
|
-
page:
|
|
54
|
+
page: a = 0
|
|
54
55
|
}) => {
|
|
55
|
-
if (!
|
|
56
|
+
if (!i && e !== "text" && e !== "office")
|
|
56
57
|
return /* @__PURE__ */ r("div", { className: "text-d-secondary-foreground", children: "Nessuna sorgente disponibile" });
|
|
57
58
|
switch (e) {
|
|
58
59
|
case "image":
|
|
59
60
|
return /* @__PURE__ */ r("div", { className: "grid place-items-center", children: /* @__PURE__ */ r(
|
|
60
61
|
"img",
|
|
61
62
|
{
|
|
62
|
-
src:
|
|
63
|
+
src: i,
|
|
63
64
|
alt: "preview",
|
|
64
65
|
className: "max-h-[78vh] w-auto max-w-full object-contain"
|
|
65
66
|
}
|
|
66
67
|
) });
|
|
67
68
|
case "pdf":
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
if (l && i)
|
|
70
|
+
return /* @__PURE__ */ r(
|
|
71
|
+
b,
|
|
72
|
+
{
|
|
73
|
+
url: i,
|
|
74
|
+
initialPage: a || 1,
|
|
75
|
+
className: "w-full"
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
let o = i;
|
|
79
|
+
return a > 0 && (o += "#page=" + a), /* @__PURE__ */ r(
|
|
70
80
|
"iframe",
|
|
71
81
|
{
|
|
72
|
-
src:
|
|
82
|
+
src: o,
|
|
73
83
|
title: "PDF Preview",
|
|
74
84
|
className: "h-[78vh] w-full rounded"
|
|
75
85
|
}
|
|
76
86
|
);
|
|
77
87
|
case "audio":
|
|
78
|
-
return /* @__PURE__ */ r("div", { className: "grid place-items-center", children: /* @__PURE__ */ r("audio", { controls: !0, className: "w-full max-w-2xl", children: /* @__PURE__ */ r("source", { src:
|
|
88
|
+
return /* @__PURE__ */ r("div", { className: "grid place-items-center", children: /* @__PURE__ */ r("audio", { controls: !0, className: "w-full max-w-2xl", children: /* @__PURE__ */ r("source", { src: i }) }) });
|
|
79
89
|
case "video":
|
|
80
|
-
return /* @__PURE__ */ r("div", { className: "grid place-items-center", children: /* @__PURE__ */ r("video", { controls: !0, className: "max-h-[78vh] w-full max-w-3xl rounded", children: /* @__PURE__ */ r("source", { src:
|
|
90
|
+
return /* @__PURE__ */ r("div", { className: "grid place-items-center", children: /* @__PURE__ */ r("video", { controls: !0, className: "max-h-[78vh] w-full max-w-3xl rounded", children: /* @__PURE__ */ r("source", { src: i }) }) });
|
|
81
91
|
case "text":
|
|
82
92
|
return /* @__PURE__ */ r(
|
|
83
93
|
"iframe",
|
|
84
94
|
{
|
|
85
|
-
src:
|
|
95
|
+
src: i,
|
|
86
96
|
title: "Text Preview",
|
|
87
97
|
className: "h-[78vh] w-full rounded"
|
|
88
98
|
}
|
|
89
99
|
);
|
|
90
100
|
case "office": {
|
|
91
|
-
if (n &&
|
|
92
|
-
const
|
|
101
|
+
if (n && D(n)) {
|
|
102
|
+
const t = O(n);
|
|
93
103
|
return /* @__PURE__ */ r(
|
|
94
104
|
"iframe",
|
|
95
105
|
{
|
|
96
|
-
src:
|
|
106
|
+
src: t,
|
|
97
107
|
title: "Office Preview",
|
|
98
108
|
className: "h-[78vh] w-full rounded"
|
|
99
109
|
}
|
|
@@ -106,7 +116,7 @@ const q = () => {
|
|
|
106
116
|
}
|
|
107
117
|
};
|
|
108
118
|
export {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
119
|
+
E as FilePreviewer,
|
|
120
|
+
q as previewFileModal,
|
|
121
|
+
B as safePreviewFileModal
|
|
112
122
|
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as o, jsx as e } from "react/jsx-runtime";
|
|
3
|
+
import { Button as p } from "./button.js";
|
|
4
|
+
import { Icon as i } from "./icon.js";
|
|
5
|
+
import { useState as s, useRef as C, useMemo as h, useEffect as x } from "react";
|
|
6
|
+
import "../../node_modules/react-pdf/dist/index.js";
|
|
7
|
+
/* empty css */
|
|
8
|
+
/* empty css */
|
|
9
|
+
import L from "../../node_modules/react-pdf/dist/Document.js";
|
|
10
|
+
import k from "../../node_modules/react-pdf/dist/Page.js";
|
|
11
|
+
import { GlobalWorkerOptions as W } from "../../node_modules/react-pdf/node_modules/pdfjs-dist/build/pdf.js";
|
|
12
|
+
W.workerSrc = "https://unpkg.com/pdfjs-dist@5.3.93/build/pdf.worker.min.mjs";
|
|
13
|
+
function G({
|
|
14
|
+
url: a,
|
|
15
|
+
initialPage: w = 1,
|
|
16
|
+
className: N = ""
|
|
17
|
+
}) {
|
|
18
|
+
const [c, g] = s(), [t, m] = s(w), [d, u] = s(null), n = C(null), [v, f] = s(950), b = h(() => ({ url: a }), [a]), P = h(
|
|
19
|
+
() => ({
|
|
20
|
+
cMapUrl: "https://unpkg.com/pdfjs-dist@5.3.93/cmaps/",
|
|
21
|
+
cMapPacked: !0
|
|
22
|
+
}),
|
|
23
|
+
[]
|
|
24
|
+
), E = ({ numPages: r }) => {
|
|
25
|
+
g(r), u(null), setTimeout(() => {
|
|
26
|
+
if (n.current) {
|
|
27
|
+
const l = n.current.clientWidth;
|
|
28
|
+
f(l - 32);
|
|
29
|
+
}
|
|
30
|
+
}, 50);
|
|
31
|
+
}, j = (r) => {
|
|
32
|
+
console.error("PDF Load Error:", r), u(r.message || "Errore nel caricamento del PDF");
|
|
33
|
+
};
|
|
34
|
+
return x(() => {
|
|
35
|
+
n.current && (n.current.scrollTop = 0);
|
|
36
|
+
}, [t]), x(() => {
|
|
37
|
+
const r = () => {
|
|
38
|
+
if (n.current) {
|
|
39
|
+
const l = n.current.clientWidth;
|
|
40
|
+
f(l - 32);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
return r(), window.addEventListener("resize", r), () => window.removeEventListener("resize", r);
|
|
44
|
+
}, []), d ? /* @__PURE__ */ o("div", { className: "text-d-destructive flex min-h-[600px] flex-col items-center justify-center gap-3", children: [
|
|
45
|
+
/* @__PURE__ */ e(i, { name: "AlertCircle", className: "h-12 w-12" }),
|
|
46
|
+
/* @__PURE__ */ e("p", { className: "font-semibold", children: "Errore nel caricamento del PDF" }),
|
|
47
|
+
/* @__PURE__ */ e("p", { className: "text-d-muted-foreground text-sm", children: d })
|
|
48
|
+
] }) : /* @__PURE__ */ o(
|
|
49
|
+
"div",
|
|
50
|
+
{
|
|
51
|
+
className: `flex min-h-[600px] w-full flex-col items-center ${N}`,
|
|
52
|
+
children: [
|
|
53
|
+
/* @__PURE__ */ e(
|
|
54
|
+
"div",
|
|
55
|
+
{
|
|
56
|
+
ref: n,
|
|
57
|
+
className: "border-d-border max-h-[500px] w-full overflow-auto rounded border",
|
|
58
|
+
children: /* @__PURE__ */ e(
|
|
59
|
+
L,
|
|
60
|
+
{
|
|
61
|
+
file: b,
|
|
62
|
+
onLoadSuccess: E,
|
|
63
|
+
onLoadError: j,
|
|
64
|
+
options: P,
|
|
65
|
+
loading: /* @__PURE__ */ e("div", { className: "flex min-h-[600px] items-center justify-center", children: /* @__PURE__ */ e(
|
|
66
|
+
i,
|
|
67
|
+
{
|
|
68
|
+
name: "Loader2",
|
|
69
|
+
className: "text-d-primary h-8 w-8 animate-spin"
|
|
70
|
+
}
|
|
71
|
+
) }),
|
|
72
|
+
error: /* @__PURE__ */ o("div", { className: "text-d-destructive flex min-h-[600px] flex-col items-center justify-center gap-2", children: [
|
|
73
|
+
/* @__PURE__ */ e(i, { name: "AlertCircle", className: "h-12 w-12" }),
|
|
74
|
+
/* @__PURE__ */ e("p", { children: "Errore nel caricamento del PDF" })
|
|
75
|
+
] }),
|
|
76
|
+
className: "h-full min-h-[600px] w-full border-0",
|
|
77
|
+
children: /* @__PURE__ */ e(k, { pageNumber: t, width: v })
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
/* @__PURE__ */ o("div", { className: "my-8 flex h-full w-full items-center justify-center gap-4", children: [
|
|
83
|
+
/* @__PURE__ */ e(
|
|
84
|
+
p,
|
|
85
|
+
{
|
|
86
|
+
onClick: () => m(Math.max(1, t - 1)),
|
|
87
|
+
disabled: t <= 1,
|
|
88
|
+
variant: "outline",
|
|
89
|
+
size: "sm",
|
|
90
|
+
children: /* @__PURE__ */ e(i, { name: "ChevronLeft", className: "h-4 w-4" })
|
|
91
|
+
}
|
|
92
|
+
),
|
|
93
|
+
/* @__PURE__ */ o("p", { className: "text-d-foreground text-sm", children: [
|
|
94
|
+
t,
|
|
95
|
+
" / ",
|
|
96
|
+
c
|
|
97
|
+
] }),
|
|
98
|
+
/* @__PURE__ */ e(
|
|
99
|
+
p,
|
|
100
|
+
{
|
|
101
|
+
onClick: () => m(Math.min(c || 1, t + 1)),
|
|
102
|
+
disabled: t >= (c || 1),
|
|
103
|
+
variant: "outline",
|
|
104
|
+
size: "sm",
|
|
105
|
+
children: /* @__PURE__ */ e(i, { name: "ChevronRight", className: "h-4 w-4" })
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
] })
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
export {
|
|
114
|
+
G as SecurePdfViewer
|
|
115
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1719,6 +1719,14 @@ export declare function ScrollArea({ className, children, ...props }: React_2.Co
|
|
|
1719
1719
|
|
|
1720
1720
|
export declare function ScrollBar({ className, orientation, ...props }: React_2.ComponentProps<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>): JSX.Element;
|
|
1721
1721
|
|
|
1722
|
+
export declare function SecurePdfViewer({ url, initialPage, className, }: SecurePdfViewerProps): JSX.Element;
|
|
1723
|
+
|
|
1724
|
+
declare interface SecurePdfViewerProps {
|
|
1725
|
+
url: string;
|
|
1726
|
+
initialPage?: number;
|
|
1727
|
+
className?: string;
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1722
1730
|
export declare function Select({ size, label, className, labelClassName, ...props }: SelectProps): JSX.Element;
|
|
1723
1731
|
|
|
1724
1732
|
export declare function SelectContent({ className, children, position, ...props }: React_2.ComponentProps<typeof SelectPrimitive.Content>): JSX.Element;
|