@oneplatformdev/ui 0.0.1-beta.14 → 0.0.1-beta.17
Sign up to get free protection for your applications and to get access to all the features.
- package/Dropzone/Dropzone.mjs +58 -62
- package/Dropzone/{FilePreview.mjs → DropzoneFilePreview.mjs} +1 -1
- package/Dropzone/index.mjs +1 -1
- package/FormDropzone/FormDropzone.mjs +12 -13
- package/FormSelect/FormSelect.types.d.ts +1 -1
- package/index.mjs +1 -1
- package/package.json +1 -1
- /package/Dropzone/{FilePreview.d.ts → DropzoneFilePreview.d.ts} +0 -0
- /package/{FilePreview-Dhtv8F4u.js → DropzoneFilePreview-Dhtv8F4u.js} +0 -0
package/Dropzone/Dropzone.mjs
CHANGED
@@ -1,106 +1,102 @@
|
|
1
|
-
import { jsxs as
|
2
|
-
import { forwardRef as L, useState as
|
3
|
-
import { useDropzone as
|
4
|
-
import { Card as
|
5
|
-
import { File as
|
6
|
-
import { cn as
|
7
|
-
import { F as
|
8
|
-
import { isFile as v, extractName as
|
9
|
-
const
|
1
|
+
import { jsxs as t, jsx as o } from "react/jsx-runtime";
|
2
|
+
import { forwardRef as L, useState as g } from "react";
|
3
|
+
import { useDropzone as M } from "react-dropzone";
|
4
|
+
import { Card as U } from "../Card/Card.mjs";
|
5
|
+
import { File as j, X as O } from "lucide-react";
|
6
|
+
import { cn as m } from "@oneplatformdev/utils";
|
7
|
+
import { F as X, D as Y } from "../DropzoneFilePreview-Dhtv8F4u.js";
|
8
|
+
import { isFile as v, extractName as q } from "./DropzoneUtils.mjs";
|
9
|
+
const G = L(
|
10
10
|
({
|
11
|
-
acceptTypes:
|
12
|
-
maxSizeMB:
|
13
|
-
maxFiles:
|
14
|
-
onErrors:
|
15
|
-
hideErrors:
|
11
|
+
acceptTypes: y = Y,
|
12
|
+
maxSizeMB: w,
|
13
|
+
maxFiles: a = 1,
|
14
|
+
onErrors: x,
|
15
|
+
hideErrors: b = !1,
|
16
16
|
disabled: p = !1,
|
17
17
|
classNames: l,
|
18
|
-
value:
|
18
|
+
value: u = [],
|
19
19
|
onChangeValue: s,
|
20
|
-
className:
|
20
|
+
className: F,
|
21
21
|
labelDropzonePrompt: z = "Drop files here or click to select",
|
22
|
-
labelOrClickToSelect:
|
22
|
+
labelOrClickToSelect: H = "Click to select files",
|
23
23
|
labelSelectedFiles: D = "Selected Files",
|
24
24
|
labelUploadErrors: I = "Upload Errors",
|
25
25
|
labelFileTooLarge: k = "File is too large",
|
26
|
-
labelInvalidFileType:
|
27
|
-
...
|
26
|
+
labelInvalidFileType: S = "Invalid file type",
|
27
|
+
...E
|
28
28
|
}, P) => {
|
29
|
-
const [c,
|
30
|
-
|
31
|
-
a
|
32
|
-
|
33
|
-
const W = (e, i) => {
|
34
|
-
N(i), g && g(i);
|
35
|
-
const t = [...c, ...e].slice(0, h);
|
36
|
-
a(t), s == null || s(t);
|
29
|
+
const [c, h] = g(u), [d, N] = g([]), W = (e, i) => {
|
30
|
+
N(i), x && x(i);
|
31
|
+
const r = [...c, ...e].slice(0, a);
|
32
|
+
h(r), s == null || s(r);
|
37
33
|
}, T = (e, i) => {
|
38
34
|
if (p) return;
|
39
35
|
e.stopPropagation();
|
40
|
-
const
|
41
|
-
|
42
|
-
}, { getRootProps: _, getInputProps: A, isDragActive: B } =
|
36
|
+
const r = c.filter((n, f) => f !== i);
|
37
|
+
h(r), s == null || s(r);
|
38
|
+
}, { getRootProps: _, getInputProps: A, isDragActive: B } = M({
|
43
39
|
onDrop: W,
|
44
|
-
accept:
|
45
|
-
maxSize:
|
46
|
-
maxFiles:
|
40
|
+
accept: y.reduce((e, i) => (e[i] = [], e), {}),
|
41
|
+
maxSize: w * 1024 * 1024,
|
42
|
+
maxFiles: a,
|
47
43
|
disabled: p
|
48
44
|
});
|
49
|
-
return /* @__PURE__ */
|
50
|
-
|
45
|
+
return /* @__PURE__ */ t(
|
46
|
+
U,
|
51
47
|
{
|
52
48
|
..._(),
|
53
|
-
...
|
54
|
-
className:
|
49
|
+
...E,
|
50
|
+
className: m(
|
55
51
|
"border-dashed border-2 p-6 text-center flex flex-col items-center justify-center",
|
56
52
|
p && "bg-gray-300 pointer-events-none",
|
57
53
|
d.length > 0 ? "border-red-500" : "border-gray-300",
|
58
54
|
B && "bg-gray-100",
|
59
|
-
|
55
|
+
F
|
60
56
|
),
|
61
57
|
ref: P,
|
62
58
|
children: [
|
63
59
|
/* @__PURE__ */ o("input", { ...A() }),
|
64
|
-
c.length === 0 && d.length === 0 && /* @__PURE__ */
|
60
|
+
c.length === 0 && d.length === 0 && /* @__PURE__ */ t(
|
65
61
|
"div",
|
66
62
|
{
|
67
|
-
className:
|
63
|
+
className: m(
|
68
64
|
"flex flex-col items-center gap-1",
|
69
65
|
l == null ? void 0 : l.idleWrapper
|
70
66
|
),
|
71
67
|
children: [
|
72
|
-
/* @__PURE__ */ o(
|
73
|
-
!p && /* @__PURE__ */ o("
|
68
|
+
/* @__PURE__ */ o(j, { className: "w-8 h-8 text-gray-500" }),
|
69
|
+
!p && /* @__PURE__ */ o("pre", { className: "font-semibold text-gray-600", children: z })
|
74
70
|
]
|
75
71
|
}
|
76
72
|
),
|
77
|
-
c.length > 0 && /* @__PURE__ */
|
78
|
-
/* @__PURE__ */
|
73
|
+
c.length > 0 && /* @__PURE__ */ t("div", { className: m("w-full mt-2", l == null ? void 0 : l.previewWrapper), children: [
|
74
|
+
/* @__PURE__ */ t("pre", { className: "font-semibold text-gray-600", children: [
|
79
75
|
D,
|
80
76
|
":"
|
81
77
|
] }),
|
82
78
|
/* @__PURE__ */ o("ul", { className: "mt-2 text-sm text-gray-500 flex flex-wrap gap-4 items-start justify-center", children: c.map((e, i) => {
|
83
|
-
const
|
84
|
-
return /* @__PURE__ */
|
79
|
+
const r = v(e) ? e.name : q(e), n = v(e) ? (e.size / (1024 * 1024)).toFixed(2) + " MB" : "";
|
80
|
+
return /* @__PURE__ */ t(
|
85
81
|
"li",
|
86
82
|
{
|
87
83
|
className: "flex flex-col items-center gap-2 relative",
|
88
84
|
children: [
|
89
|
-
/* @__PURE__ */
|
90
|
-
/* @__PURE__ */ o(
|
85
|
+
/* @__PURE__ */ t("div", { className: "relative", children: [
|
86
|
+
/* @__PURE__ */ o(X, { item: e, styles: l }),
|
91
87
|
/* @__PURE__ */ o("div", { className: "absolute top-0 right-0 cursor-pointer bg-gray-300 rounded-sm", children: /* @__PURE__ */ o(
|
92
|
-
|
88
|
+
O,
|
93
89
|
{
|
94
90
|
size: 16,
|
95
91
|
strokeWidth: 1,
|
96
92
|
color: "black",
|
97
|
-
onClick: (
|
93
|
+
onClick: (f) => T(f, i)
|
98
94
|
}
|
99
95
|
) })
|
100
96
|
] }),
|
101
|
-
/* @__PURE__ */
|
102
|
-
/* @__PURE__ */ o("span", { className: "max-w-[80px] text-ellipsis overflow-hidden whitespace-nowrap", children:
|
103
|
-
n && /* @__PURE__ */
|
97
|
+
/* @__PURE__ */ t("span", { className: "inline-flex flex-col items-center", children: [
|
98
|
+
/* @__PURE__ */ o("span", { className: "max-w-[80px] text-ellipsis overflow-hidden whitespace-nowrap", children: r }),
|
99
|
+
n && /* @__PURE__ */ t("span", { children: [
|
104
100
|
"(",
|
105
101
|
n,
|
106
102
|
")"
|
@@ -112,20 +108,20 @@ const H = L(
|
|
112
108
|
);
|
113
109
|
}) })
|
114
110
|
] }),
|
115
|
-
d.length > 0 && /* @__PURE__ */
|
116
|
-
/* @__PURE__ */
|
111
|
+
d.length > 0 && /* @__PURE__ */ t("div", { className: m("w-full mt-4", l == null ? void 0 : l.errorWrapper), children: [
|
112
|
+
/* @__PURE__ */ t("span", { className: "font-semibold text-red-500", children: [
|
117
113
|
I,
|
118
114
|
":"
|
119
115
|
] }),
|
120
|
-
/* @__PURE__ */ o("ul", { className: "mt-2 text-sm text-red-500 list-disc list-inside", children: d.map((e, i) => /* @__PURE__ */
|
116
|
+
/* @__PURE__ */ o("ul", { className: "mt-2 text-sm text-red-500 list-disc list-inside", children: d.map((e, i) => /* @__PURE__ */ t("li", { children: [
|
121
117
|
e.file.name,
|
122
118
|
" (",
|
123
119
|
(e.file.size / (1024 * 1024)).toFixed(2),
|
124
120
|
" MB)",
|
125
|
-
!
|
126
|
-
|
127
|
-
|
128
|
-
|
121
|
+
!b && /* @__PURE__ */ o("ul", { className: "ml-4 list-disc list-inside", children: e.errors.map((r, n) => /* @__PURE__ */ t("li", { children: [
|
122
|
+
r.code === "file-too-large" && k,
|
123
|
+
r.code === "file-invalid-type" && S,
|
124
|
+
r.code !== "file-too-large" && r.code !== "file-invalid-type" && r.message
|
129
125
|
] }, n)) })
|
130
126
|
] }, i)) })
|
131
127
|
] })
|
@@ -134,7 +130,7 @@ const H = L(
|
|
134
130
|
);
|
135
131
|
}
|
136
132
|
);
|
137
|
-
|
133
|
+
G.displayName = "Dropzone";
|
138
134
|
export {
|
139
|
-
|
135
|
+
G as Dropzone
|
140
136
|
};
|
package/Dropzone/index.mjs
CHANGED
@@ -1,22 +1,21 @@
|
|
1
|
-
import { jsx as
|
2
|
-
import { FormControl as
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
2
|
+
import { FormControl as a } from "../Form/Form.mjs";
|
3
3
|
import { FormRenderControl as l } from "../Form/FormRenderControl.mjs";
|
4
|
-
import { Dropzone as
|
5
|
-
const h = (
|
6
|
-
const { form:
|
7
|
-
return /* @__PURE__ */
|
4
|
+
import { Dropzone as f } from "../Dropzone/Dropzone.mjs";
|
5
|
+
const h = (n) => {
|
6
|
+
const { form: e, label: m, name: t, ...p } = n;
|
7
|
+
return /* @__PURE__ */ o(
|
8
8
|
l,
|
9
9
|
{
|
10
|
-
form:
|
10
|
+
form: e,
|
11
11
|
label: m,
|
12
12
|
name: t,
|
13
|
-
render: ({ field:
|
14
|
-
|
13
|
+
render: ({ field: r }) => /* @__PURE__ */ o(a, { children: /* @__PURE__ */ o(
|
14
|
+
f,
|
15
15
|
{
|
16
|
-
...
|
17
|
-
...
|
18
|
-
|
19
|
-
onChangeValue: o.onChange
|
16
|
+
...p,
|
17
|
+
...r,
|
18
|
+
onChangeValue: r.onChange
|
20
19
|
}
|
21
20
|
) })
|
22
21
|
}
|
@@ -3,5 +3,5 @@ import { FormRenderControlExtendProps } from '../Form';
|
|
3
3
|
import { UseFormReturn } from 'react-hook-form';
|
4
4
|
import { FieldValues } from 'react-hook-form/dist/types/fields';
|
5
5
|
|
6
|
-
export interface FormSelectProps<Data extends FieldValues, Form extends UseFormReturn<Data>, ExtendOptionData> extends FormRenderControlExtendProps<Data, Form>, SelectProps<ExtendOptionData> {
|
6
|
+
export interface FormSelectProps<Data extends FieldValues, Form extends UseFormReturn<Data>, ExtendOptionData> extends FormRenderControlExtendProps<Data, Form>, Omit<SelectProps<ExtendOptionData>, 'onChange'> {
|
7
7
|
}
|
package/index.mjs
CHANGED
@@ -78,7 +78,7 @@ import { ToggleGroup as cn, ToggleGroupItem as Mn } from "./ToggleGroup/ToggleGr
|
|
78
78
|
import { TooltipContent as An, TooltipProvider as In, TooltipRoot as wn, TooltipTrigger as hn } from "./Tooltip/TooltipRoot.mjs";
|
79
79
|
import { Tooltip as Fn } from "./Tooltip/Tooltip.mjs";
|
80
80
|
import { Dropzone as Bn } from "./Dropzone/Dropzone.mjs";
|
81
|
-
import { D as Rn, a as kn } from "./
|
81
|
+
import { D as Rn, a as kn } from "./DropzoneFilePreview-Dhtv8F4u.js";
|
82
82
|
import { FormDropzone as Nn } from "./FormDropzone/FormDropzone.mjs";
|
83
83
|
export {
|
84
84
|
e as Accordion,
|
package/package.json
CHANGED
File without changes
|
File without changes
|