laif-ds 0.2.16 → 0.2.19

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,8 @@
1
1
  "use client";
2
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);
3
+ import { __require as t } from "../node_modules/eventemitter3/index2.js";
4
+ var r = t();
5
+ const m = /* @__PURE__ */ e(r);
6
6
  export {
7
- x as default
7
+ m as default
8
8
  };
@@ -1,8 +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
+ import { __require as r } from "../node_modules/extend/index.js";
4
+ var t = r();
5
+ const x = /* @__PURE__ */ e(t);
6
6
  export {
7
- m as default
7
+ x as default
8
8
  };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { jsxs as m, jsx as r } from "react/jsx-runtime";
2
+ import { jsxs as u, jsx as r } from "react/jsx-runtime";
3
3
  import { createAsk as h } from "../../node_modules/use-ask/dist/index.js";
4
4
  import { Dialog as v, DialogContent as w, DialogHeader as x, DialogTitle as g } from "./dialog.js";
5
5
  import { Icon as N } from "./icon.js";
@@ -7,47 +7,48 @@ import { guessKind as y, isHttpUrl as b, getOfficeEmbedUrl as P } from "../../li
7
7
  import { cn as A } from "../../lib/utils.js";
8
8
  import { useMemo as s } from "react";
9
9
  const [d, D] = h({});
10
- function u(e) {
10
+ function f(e) {
11
11
  return typeof e == "string" ? { url: e } : e || {};
12
12
  }
13
13
  async function z(e) {
14
- return d.ask(u(e));
14
+ return d.ask(f(e));
15
15
  }
16
16
  function C(e) {
17
- return d.safeAsk(u(e));
17
+ return d.safeAsk(f(e));
18
18
  }
19
19
  const H = () => {
20
- const [{ payload: e }, { asking: i, cancel: t }] = D(), a = e?.url, l = s(() => e?.filename ? e.filename : (e?.url || "").split(/[?#]/)[0].split("/").pop() || "" || "document", [e?.filename, e?.url]), f = s(() => {
21
- const n = new URL(e?.url || window?.location?.href || ""), o = n.searchParams.get("response-content-type") || n.searchParams.get("content-type"), c = e?.mimeType || o || "";
20
+ const [{ payload: e }, { asking: t, cancel: i }] = D(), n = e?.url, a = s(() => e?.filename ? e?.filename : (e?.url || "").split(/[?#]/)[0].split("/").pop() || "" || "document", [e?.filename, e?.url]), o = s(() => {
21
+ if (!e?.url) return null;
22
+ const l = new URL(e?.url), c = l.searchParams.get("response-content-type") || l.searchParams.get("content-type"), m = e?.mimeType || c || "";
22
23
  return y({
23
- mimeType: c,
24
- filename: l,
24
+ mimeType: m,
25
+ filename: a,
25
26
  url: e?.url
26
27
  });
27
- }, [e?.mimeType, l, e?.url]), p = s(
28
- () => /* @__PURE__ */ m("span", { className: "flex items-center gap-2", children: [
28
+ }, [e?.mimeType, a, e?.url]), p = s(
29
+ () => /* @__PURE__ */ u("span", { className: "flex items-center gap-2", children: [
29
30
  /* @__PURE__ */ r(N, { name: "File", className: "h-4 w-4" }),
30
- e?.title || l
31
+ e?.title || a
31
32
  ] }),
32
- [e?.title, l]
33
+ [e?.title, a]
33
34
  );
34
- return /* @__PURE__ */ r(v, { open: i, onOpenChange: (n) => !n && t(), children: /* @__PURE__ */ m(w, { size: "xl", className: "sm:max-w-4xl", children: [
35
+ return /* @__PURE__ */ r(v, { open: t, onOpenChange: (l) => !l && i(), children: /* @__PURE__ */ u(w, { size: "xl", className: "sm:max-w-4xl", children: [
35
36
  /* @__PURE__ */ r(x, { children: /* @__PURE__ */ r(g, { children: p }) }),
36
- /* @__PURE__ */ r("div", { className: A("relative", "max-h-[80vh] overflow-auto p-1"), children: /* @__PURE__ */ r(F, { kind: f, src: a, officeUrl: a }) })
37
+ /* @__PURE__ */ r("div", { className: A("relative", "max-h-[80vh] overflow-auto p-1"), children: o && n ? /* @__PURE__ */ r(F, { kind: o, src: n, officeUrl: n }) : null })
37
38
  ] }) });
38
39
  }, F = ({
39
40
  kind: e,
40
- src: i,
41
- officeUrl: t
41
+ src: t,
42
+ officeUrl: i
42
43
  }) => {
43
- if (!i && e !== "text" && e !== "office")
44
+ if (!t && e !== "text" && e !== "office")
44
45
  return /* @__PURE__ */ r("div", { className: "text-d-secondary-foreground", children: "Nessuna sorgente disponibile" });
45
46
  switch (e) {
46
47
  case "image":
47
48
  return /* @__PURE__ */ r("div", { className: "grid place-items-center", children: /* @__PURE__ */ r(
48
49
  "img",
49
50
  {
50
- src: i,
51
+ src: t,
51
52
  alt: "preview",
52
53
  className: "max-h-[78vh] w-auto max-w-full object-contain"
53
54
  }
@@ -56,31 +57,31 @@ const H = () => {
56
57
  return /* @__PURE__ */ r(
57
58
  "iframe",
58
59
  {
59
- src: i,
60
+ src: t,
60
61
  title: "PDF Preview",
61
62
  className: "h-[78vh] w-full rounded"
62
63
  }
63
64
  );
64
65
  case "audio":
65
- 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 }) }) });
66
+ 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: t }) }) });
66
67
  case "video":
67
- 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 }) }) });
68
+ 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: t }) }) });
68
69
  case "text":
69
70
  return /* @__PURE__ */ r(
70
71
  "iframe",
71
72
  {
72
- src: i,
73
+ src: t,
73
74
  title: "Text Preview",
74
75
  className: "h-[78vh] w-full rounded"
75
76
  }
76
77
  );
77
78
  case "office": {
78
- if (t && b(t)) {
79
- const a = P(t);
79
+ if (i && b(i)) {
80
+ const n = P(i);
80
81
  return /* @__PURE__ */ r(
81
82
  "iframe",
82
83
  {
83
- src: a,
84
+ src: n,
84
85
  title: "Office Preview",
85
86
  className: "h-[78vh] w-full rounded"
86
87
  }
package/dist/lib/utils.js CHANGED
@@ -1,47 +1,53 @@
1
1
  "use client";
2
- import { clsx as r } from "../node_modules/clsx/dist/clsx.js";
3
- import { twMerge as l } from "../node_modules/tailwind-merge/dist/bundle-mjs.js";
4
- function g(...t) {
5
- return l(r(t));
2
+ import { guessKind as l, getOfficeEmbedUrl as m } from "./file-preview.js";
3
+ import { clsx as d } from "../node_modules/clsx/dist/clsx.js";
4
+ import { twMerge as p } from "../node_modules/tailwind-merge/dist/bundle-mjs.js";
5
+ function u(...n) {
6
+ return p(d(n));
6
7
  }
7
- const h = (t) => {
8
- if (!t) return "#777777";
9
- let n = 0;
10
- for (let p = 0; p < t.length; p += 1)
11
- n = t.charCodeAt(p) + ((n << 5) - n), n &= n;
12
- let e = n >> 16 & 255, o = n >> 8 & 255, c = n & 255;
13
- const i = 60, a = 200;
14
- e = Math.min(a, Math.max(i, e)), o = Math.min(a, Math.max(i, o)), c = Math.min(a, Math.max(i, c));
15
- const s = (p) => p.toString(16).padStart(2, "0");
16
- return `#${s(e)}${s(o)}${s(c)}`;
17
- }, x = (t, n) => {
18
- let e = t.replace("#", "");
19
- e.length === 3 && (e = e.split("").map((s) => s + s).join(""));
20
- const o = parseInt(e, 16), c = o >> 16 & 255, i = o >> 8 & 255, a = o & 255;
21
- return `rgba(${c}, ${i}, ${a}, ${n})`;
22
- }, b = (t) => {
23
- const n = parseInt(t.replace("#", ""), 16), e = n >> 16 & 255, o = n >> 8 & 255, c = n & 255;
24
- return (0.299 * e + 0.587 * o + 0.114 * c) / 255 > 0.5 ? "#000000" : "#FFFFFF";
25
- }, f = (t, n) => {
26
- if (!t) return;
27
- const e = n?.split(".").pop()?.toLowerCase() || "";
28
- if (["pdf", "jpg", "jpeg", "png", "gif", "bmp", "webp", "svg"].includes(e))
29
- window.open(t, "_blank");
30
- else if (["doc", "docx", "xls", "xlsx", "ppt", "pptx"].includes(e)) {
31
- const o = `https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(t)}`;
32
- window.open(o, "_blank");
33
- } else
34
- window.open(t, "_blank");
35
- }, w = (t, n) => {
36
- if (!t) return;
37
- const e = document.createElement("a");
38
- e.href = t, e.download = n || "document", e.style.display = "none", document.body.appendChild(e), e.click(), document.body.removeChild(e);
8
+ const b = (n) => {
9
+ if (!n) return "#777777";
10
+ let e = 0;
11
+ for (let s = 0; s < n.length; s += 1)
12
+ e = n.charCodeAt(s) + ((e << 5) - e), e &= e;
13
+ let t = e >> 16 & 255, o = e >> 8 & 255, r = e & 255;
14
+ const c = 60, a = 200;
15
+ t = Math.min(a, Math.max(c, t)), o = Math.min(a, Math.max(c, o)), r = Math.min(a, Math.max(c, r));
16
+ const i = (s) => s.toString(16).padStart(2, "0");
17
+ return `#${i(t)}${i(o)}${i(r)}`;
18
+ }, w = (n, e) => {
19
+ let t = n.replace("#", "");
20
+ t.length === 3 && (t = t.split("").map((i) => i + i).join(""));
21
+ const o = parseInt(t, 16), r = o >> 16 & 255, c = o >> 8 & 255, a = o & 255;
22
+ return `rgba(${r}, ${c}, ${a}, ${e})`;
23
+ }, x = (n) => {
24
+ const e = parseInt(n.replace("#", ""), 16), t = e >> 16 & 255, o = e >> 8 & 255, r = e & 255;
25
+ return (0.299 * t + 0.587 * o + 0.114 * r) / 255 > 0.5 ? "#000000" : "#FFFFFF";
26
+ }, y = (n, e) => {
27
+ if (!n) return;
28
+ const t = n.split("?")[1] || "";
29
+ let o = "";
30
+ try {
31
+ const c = new URLSearchParams(t);
32
+ o = c.get("response-content-type") || c.get("content-type") || "";
33
+ } catch {
34
+ }
35
+ if (l({ mimeType: o, filename: e, url: n }) === "office") {
36
+ const c = m(n);
37
+ window.open(c, "_blank");
38
+ return;
39
+ }
40
+ window.open(n, "_blank");
41
+ }, F = (n, e) => {
42
+ if (!n) return;
43
+ const t = document.createElement("a");
44
+ t.href = n, t.download = e || "document", t.style.display = "none", document.body.appendChild(t), t.click(), document.body.removeChild(t);
39
45
  };
40
46
  export {
41
- g as cn,
42
- w as downloadFile,
43
- b as hexContrast,
44
- x as hexToRgba,
45
- f as previewFile,
46
- h as stringToHexColor
47
+ u as cn,
48
+ F as downloadFile,
49
+ x as hexContrast,
50
+ w as hexToRgba,
51
+ y as previewFile,
52
+ b as stringToHexColor
47
53
  };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import e from "../../_virtual/index5.js";
2
+ import e from "../../_virtual/index3.js";
3
3
  export {
4
4
  e as EventEmitter,
5
5
  e as default
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import e from "../../../../_virtual/index5.js";
2
+ import e from "../../../../_virtual/index3.js";
3
3
  var r = new e(), n = "recharts.syncEvent.tooltip";
4
4
  export {
5
5
  n as TOOLTIP_SYNC_EVENT,
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { bail as P } from "../../bail/index.js";
3
- import y from "../../../_virtual/index3.js";
3
+ import y from "../../../_virtual/index5.js";
4
4
  import z from "../../is-plain-obj/index.js";
5
5
  import { CallableInstance as C } from "./callable-instance.js";
6
6
  import { trough as A } from "../../trough/lib/index.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "laif-ds",
3
3
  "private": false,
4
- "version": "0.2.16",
4
+ "version": "0.2.19",
5
5
  "type": "module",
6
6
  "main": "dist/index.es.js",
7
7
  "module": "dist/index.es.js",
@@ -61,6 +61,7 @@
61
61
  "@tailwindcss/postcss": "^4.1.10",
62
62
  "@types/lodash": "^4.17.18",
63
63
  "@types/node": "^24.0.4",
64
+ "@types/papaparse": "^5.3.16",
64
65
  "@types/react": "^19.1.8",
65
66
  "@types/react-dom": "^19.1.6",
66
67
  "@types/react-window": "^1.8.8",
@@ -138,6 +139,7 @@
138
139
  "lexical": "^0.32.1",
139
140
  "lucide-react": "^0.523.0",
140
141
  "next-themes": "^0.4.6",
142
+ "papaparse": "^5.5.3",
141
143
  "react-colorful": "^5.6.1",
142
144
  "react-day-picker": "^9.7.0",
143
145
  "react-hook-form": "^7.58.1",