@oneplatformdev/ui 0.0.1-beta.86 → 0.0.1-beta.87
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,38 +1,41 @@
|
|
1
|
-
import { jsxs as
|
2
|
-
import {
|
3
|
-
import { isFile as
|
4
|
-
import { X as
|
5
|
-
const
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
import { jsxs as s, jsx as r } from "react/jsx-runtime";
|
2
|
+
import { useMemo as c } from "react";
|
3
|
+
import { isFile as i } from "./DropzoneUtils.mjs";
|
4
|
+
import { X as a, FileIcon as u } from "lucide-react";
|
5
|
+
const d = (t) => {
|
6
|
+
if (!t) return "";
|
7
|
+
switch (!0) {
|
8
|
+
case (typeof t == "string" && !!t.trim() && t !== "null"):
|
9
|
+
return t;
|
10
|
+
case t instanceof File:
|
11
|
+
return URL.createObjectURL(t);
|
12
|
+
case t instanceof FileList:
|
13
|
+
return t[0] ? URL.createObjectURL(t[0]) : "";
|
14
|
+
default:
|
15
|
+
return "";
|
16
|
+
}
|
17
|
+
}, p = ({
|
18
|
+
item: t,
|
19
|
+
disabled: l,
|
20
|
+
onRemoveClick: n
|
9
21
|
}) => {
|
10
|
-
const
|
11
|
-
return
|
12
|
-
|
13
|
-
|
14
|
-
if (i.type.startsWith("image/")) {
|
15
|
-
const s = new FileReader();
|
16
|
-
s.onloadend = () => o(s.result), s.readAsDataURL(i);
|
17
|
-
} else
|
18
|
-
o(null);
|
19
|
-
} else
|
20
|
-
o(typeof e == "string" ? e : null);
|
21
|
-
}, [e, r]), /* @__PURE__ */ c("div", { className: "relative w-full h-64 sm:h-80 md:h-96 overflow-hidden outline-[#E4E4E7] outline-[2px] outline-dashed outline-offset-[-1px] rounded-lg", children: [
|
22
|
-
!a && /* @__PURE__ */ t("div", { className: "absolute top-2 right-2 cursor-pointer bg-white/70 rounded-[4px] p-1 shadow", onClick: d, children: /* @__PURE__ */ t(h, { size: 16, strokeWidth: 2, color: "black" }) }),
|
23
|
-
n ? /* @__PURE__ */ t(
|
22
|
+
const e = i(t) ? t.name : t, o = c(() => d(t), [t]);
|
23
|
+
return /* @__PURE__ */ s("div", { className: "relative w-full h-64 sm:h-80 md:h-96 overflow-hidden outline-[#E4E4E7] outline-[2px] outline-dashed outline-offset-[-1px] rounded-lg", children: [
|
24
|
+
!l && /* @__PURE__ */ r("div", { className: "absolute top-2 right-2 cursor-pointer bg-white/70 rounded-[4px] p-1 shadow", onClick: n, children: /* @__PURE__ */ r(a, { size: 16, strokeWidth: 2, color: "black" }) }),
|
25
|
+
o ? /* @__PURE__ */ r(
|
24
26
|
"img",
|
25
27
|
{
|
26
|
-
src:
|
27
|
-
alt:
|
28
|
+
src: o,
|
29
|
+
alt: e == null ? void 0 : e.toString(),
|
28
30
|
className: "w-full h-full object-cover rounded-lg "
|
29
31
|
}
|
30
|
-
) : /* @__PURE__ */
|
31
|
-
/* @__PURE__ */
|
32
|
-
/* @__PURE__ */
|
32
|
+
) : /* @__PURE__ */ s("div", { className: "w-full h-full flex flex-col items-center justify-center text-gray-600", children: [
|
33
|
+
/* @__PURE__ */ r(u, { size: 28 }),
|
34
|
+
/* @__PURE__ */ r("span", { className: "text-sm mt-2 break-all px-2 text-center", children: e == null ? void 0 : e.toString() })
|
33
35
|
] })
|
34
36
|
] });
|
35
37
|
};
|
36
38
|
export {
|
37
|
-
|
39
|
+
p as DropzoneSinglePickPreview,
|
40
|
+
d as transformImageToSrc
|
38
41
|
};
|