@adamosuiteservices/ui 2.18.0 → 2.18.1
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/components/ui/file-upload/index.d.ts +0 -1
- package/dist/components/ui/file-upload-v2/index.d.ts +1 -0
- package/dist/file-upload-v2.cjs +8 -0
- package/dist/file-upload-v2.js +339 -0
- package/dist/file-upload.cjs +4 -11
- package/dist/file-upload.js +200 -531
- package/docs/components/ui/file-upload-v2.md +14 -11
- package/docs/components/ui/file-upload.md +2 -0
- package/llm.txt +1 -1
- package/package.json +5 -1
- /package/dist/components/ui/{file-upload → file-upload-v2}/file-upload-v2.d.ts +0 -0
package/dist/file-upload.js
CHANGED
|
@@ -1,655 +1,324 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { B
|
|
3
|
-
import { I as
|
|
4
|
-
import { T as
|
|
5
|
-
import { c as
|
|
6
|
-
import { useState as
|
|
7
|
-
function
|
|
8
|
-
isDragging:
|
|
9
|
-
isMultiple:
|
|
10
|
-
invalid:
|
|
11
|
-
disabled:
|
|
12
|
-
accept:
|
|
13
|
-
acceptedExtensions:
|
|
1
|
+
import { j as t } from "./jsx-runtime-BzflLqGi.js";
|
|
2
|
+
import { B } from "./button-BnUlAtuD.js";
|
|
3
|
+
import { I as A } from "./icon-BFQz1tQC.js";
|
|
4
|
+
import { T as $ } from "./typography-MnY0LQoZ.js";
|
|
5
|
+
import { c as v } from "./index-CRiPKpXj.js";
|
|
6
|
+
import { useState as U, useRef as P, useEffect as F } from "react";
|
|
7
|
+
function S({
|
|
8
|
+
isDragging: i,
|
|
9
|
+
isMultiple: d,
|
|
10
|
+
invalid: a,
|
|
11
|
+
disabled: r,
|
|
12
|
+
accept: m,
|
|
13
|
+
acceptedExtensions: c,
|
|
14
14
|
maxSizeInMB: h,
|
|
15
|
-
maxFiles:
|
|
16
|
-
labels:
|
|
17
|
-
input:
|
|
18
|
-
onDragOver:
|
|
19
|
-
onDragLeave:
|
|
20
|
-
onDrop:
|
|
21
|
-
onFileChange:
|
|
15
|
+
maxFiles: f,
|
|
16
|
+
labels: l,
|
|
17
|
+
input: p,
|
|
18
|
+
onDragOver: g,
|
|
19
|
+
onDragLeave: w,
|
|
20
|
+
onDrop: j,
|
|
21
|
+
onFileChange: T
|
|
22
22
|
}) {
|
|
23
|
-
const
|
|
24
|
-
return /* @__PURE__ */
|
|
23
|
+
const y = p?.id || `file-upload-${Math.random().toString(36).substring(2, 11)}`;
|
|
24
|
+
return /* @__PURE__ */ t.jsxs(
|
|
25
25
|
"div",
|
|
26
26
|
{
|
|
27
|
-
onDragOver:
|
|
28
|
-
onDragLeave:
|
|
29
|
-
onDrop:
|
|
30
|
-
className:
|
|
27
|
+
onDragOver: r ? void 0 : g,
|
|
28
|
+
onDragLeave: r ? void 0 : w,
|
|
29
|
+
onDrop: r ? void 0 : j,
|
|
30
|
+
className: v(
|
|
31
31
|
`
|
|
32
32
|
adm:flex adm:flex-col adm:items-center adm:gap-6 adm:rounded-2xl
|
|
33
33
|
adm:border-2
|
|
34
34
|
`,
|
|
35
35
|
"adm:border-dashed adm:bg-background adm:p-6 adm:transition-colors",
|
|
36
36
|
{
|
|
37
|
-
"adm:border-primary":
|
|
38
|
-
"adm:border-destructive":
|
|
39
|
-
"adm:border-input": !
|
|
40
|
-
"adm:cursor-not-allowed adm:opacity-50":
|
|
37
|
+
"adm:border-primary": i && !a && !r,
|
|
38
|
+
"adm:border-destructive": a && !r,
|
|
39
|
+
"adm:border-input": !i && !a,
|
|
40
|
+
"adm:cursor-not-allowed adm:opacity-50": r
|
|
41
41
|
}
|
|
42
42
|
),
|
|
43
43
|
children: [
|
|
44
|
-
/* @__PURE__ */
|
|
44
|
+
/* @__PURE__ */ t.jsx(
|
|
45
45
|
"div",
|
|
46
46
|
{
|
|
47
|
-
className:
|
|
47
|
+
className: v(
|
|
48
48
|
"adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",
|
|
49
|
-
|
|
49
|
+
a && !r ? "adm:bg-destructive/10" : "adm:bg-primary-50"
|
|
50
50
|
),
|
|
51
|
-
children: /* @__PURE__ */
|
|
52
|
-
|
|
51
|
+
children: /* @__PURE__ */ t.jsx(
|
|
52
|
+
A,
|
|
53
53
|
{
|
|
54
54
|
symbol: "text_snippet",
|
|
55
|
-
className:
|
|
55
|
+
className: a && !r ? "adm:text-destructive" : "adm:text-primary"
|
|
56
56
|
}
|
|
57
57
|
)
|
|
58
58
|
}
|
|
59
59
|
),
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
-
/* @__PURE__ */
|
|
62
|
-
/* @__PURE__ */
|
|
63
|
-
/* @__PURE__ */
|
|
60
|
+
/* @__PURE__ */ t.jsxs("div", { className: "adm:flex adm:flex-col adm:items-center adm:gap-2", children: [
|
|
61
|
+
/* @__PURE__ */ t.jsx($, { color: a && !r ? "destructive" : void 0, children: l?.dragDrop || (d ? "Drag and drop your files here or" : "Drag and drop your file here or") }),
|
|
62
|
+
/* @__PURE__ */ t.jsxs("label", { htmlFor: y, children: [
|
|
63
|
+
/* @__PURE__ */ t.jsx(
|
|
64
64
|
"input",
|
|
65
65
|
{
|
|
66
|
-
...
|
|
67
|
-
id:
|
|
66
|
+
...p,
|
|
67
|
+
id: y,
|
|
68
68
|
type: "file",
|
|
69
|
-
accept:
|
|
70
|
-
multiple:
|
|
71
|
-
onChange:
|
|
72
|
-
disabled:
|
|
69
|
+
accept: m,
|
|
70
|
+
multiple: d,
|
|
71
|
+
onChange: T,
|
|
72
|
+
disabled: r,
|
|
73
73
|
className: "adm:hidden"
|
|
74
74
|
}
|
|
75
75
|
),
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
|
|
76
|
+
/* @__PURE__ */ t.jsx(
|
|
77
|
+
B,
|
|
78
78
|
{
|
|
79
79
|
asChild: !0,
|
|
80
80
|
type: "button",
|
|
81
81
|
variant: "link",
|
|
82
|
-
className:
|
|
82
|
+
className: v("adm:cursor-pointer", r && `
|
|
83
83
|
adm:pointer-events-none
|
|
84
84
|
`),
|
|
85
|
-
disabled:
|
|
86
|
-
children: /* @__PURE__ */
|
|
85
|
+
disabled: r,
|
|
86
|
+
children: /* @__PURE__ */ t.jsx("span", { children: l?.selectFile || (d ? "Select files" : "Select the file") })
|
|
87
87
|
}
|
|
88
88
|
)
|
|
89
89
|
] })
|
|
90
90
|
] }),
|
|
91
|
-
/* @__PURE__ */
|
|
91
|
+
/* @__PURE__ */ t.jsx($, { className: "adm:text-center", color: a && !r ? "destructive" : "muted", children: l?.fileRequirements || (c && c.length > 0 ? `Allowed files: ${c.join(", ")}. Maximum size ${h} MB${d ? `. Up to ${f} files` : ""}.` : `Maximum size ${h} MB${d ? `. Up to ${f} files` : ""}.`) })
|
|
92
92
|
]
|
|
93
93
|
}
|
|
94
94
|
);
|
|
95
95
|
}
|
|
96
|
-
function
|
|
97
|
-
return /* @__PURE__ */
|
|
96
|
+
function ee({ file: i, invalid: d, disabled: a, onRemove: r }) {
|
|
97
|
+
return /* @__PURE__ */ t.jsxs(
|
|
98
98
|
"div",
|
|
99
99
|
{
|
|
100
|
-
className:
|
|
100
|
+
className: v(
|
|
101
101
|
"adm:flex adm:items-center adm:gap-4 adm:rounded-2xl adm:border adm:p-6",
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
d && !a ? "adm:border-destructive adm:bg-destructive/5" : "adm:border-input adm:bg-muted",
|
|
103
|
+
a && "adm:cursor-not-allowed adm:opacity-50"
|
|
104
104
|
),
|
|
105
105
|
children: [
|
|
106
|
-
/* @__PURE__ */
|
|
106
|
+
/* @__PURE__ */ t.jsx(
|
|
107
107
|
"div",
|
|
108
108
|
{
|
|
109
|
-
className:
|
|
109
|
+
className: v(
|
|
110
110
|
"adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",
|
|
111
|
-
|
|
111
|
+
d && !a ? "adm:bg-destructive/10" : "adm:bg-primary-50"
|
|
112
112
|
),
|
|
113
|
-
children: /* @__PURE__ */
|
|
114
|
-
|
|
113
|
+
children: /* @__PURE__ */ t.jsx(
|
|
114
|
+
A,
|
|
115
115
|
{
|
|
116
116
|
symbol: "text_snippet",
|
|
117
|
-
className:
|
|
117
|
+
className: d && !a ? "adm:text-destructive" : "adm:text-primary"
|
|
118
118
|
}
|
|
119
119
|
)
|
|
120
120
|
}
|
|
121
121
|
),
|
|
122
|
-
/* @__PURE__ */
|
|
122
|
+
/* @__PURE__ */ t.jsxs(
|
|
123
123
|
"div",
|
|
124
124
|
{
|
|
125
125
|
className: `
|
|
126
126
|
adm:flex adm:min-w-0 adm:flex-1 adm:items-start adm:gap-3
|
|
127
127
|
`,
|
|
128
128
|
children: [
|
|
129
|
-
/* @__PURE__ */
|
|
130
|
-
/* @__PURE__ */
|
|
131
|
-
(
|
|
129
|
+
/* @__PURE__ */ t.jsx("div", { className: "adm:min-w-0 adm:flex-1", children: /* @__PURE__ */ t.jsx($, { className: "adm:truncate adm:font-semibold", children: i.name }) }),
|
|
130
|
+
/* @__PURE__ */ t.jsxs($, { className: "adm:shrink-0", color: "muted", children: [
|
|
131
|
+
(i.size / 1024 / 1024).toFixed(1),
|
|
132
132
|
" MB"
|
|
133
133
|
] })
|
|
134
134
|
]
|
|
135
135
|
}
|
|
136
136
|
),
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
-
|
|
137
|
+
/* @__PURE__ */ t.jsx(
|
|
138
|
+
B,
|
|
139
139
|
{
|
|
140
140
|
variant: "destructive-medium",
|
|
141
|
-
onClick:
|
|
141
|
+
onClick: r,
|
|
142
142
|
type: "button",
|
|
143
|
-
disabled:
|
|
144
|
-
children: /* @__PURE__ */
|
|
143
|
+
disabled: a,
|
|
144
|
+
children: /* @__PURE__ */ t.jsx(A, { symbol: "delete", className: "adm:text-destructive" })
|
|
145
145
|
}
|
|
146
146
|
)
|
|
147
147
|
]
|
|
148
148
|
}
|
|
149
149
|
);
|
|
150
150
|
}
|
|
151
|
-
function
|
|
152
|
-
return
|
|
153
|
-
|
|
154
|
-
/* @__PURE__ */
|
|
155
|
-
/* @__PURE__ */
|
|
156
|
-
|
|
151
|
+
function R({ files: i, isMultiple: d, invalid: a, disabled: r, labels: m, onRemoveFile: c, onClearAll: h }) {
|
|
152
|
+
return i.length === 0 ? null : /* @__PURE__ */ t.jsxs("div", { className: "adm:flex adm:flex-col adm:gap-3", children: [
|
|
153
|
+
d && i.length > 1 && /* @__PURE__ */ t.jsxs("div", { className: "adm:flex adm:items-center adm:justify-between", children: [
|
|
154
|
+
/* @__PURE__ */ t.jsx($, { className: "adm:text-sm adm:font-medium", color: a && !r ? "destructive" : void 0, children: m?.filesSelected?.(i.length) || `${i.length} file${i.length !== 1 ? "s" : ""} selected` }),
|
|
155
|
+
/* @__PURE__ */ t.jsx(
|
|
156
|
+
B,
|
|
157
157
|
{
|
|
158
158
|
variant: "ghost",
|
|
159
159
|
size: "sm",
|
|
160
160
|
onClick: h,
|
|
161
161
|
type: "button",
|
|
162
|
-
disabled:
|
|
162
|
+
disabled: r,
|
|
163
163
|
children: "Clear all"
|
|
164
164
|
}
|
|
165
165
|
)
|
|
166
166
|
] }),
|
|
167
|
-
|
|
168
|
-
ie,
|
|
169
|
-
{
|
|
170
|
-
file: p,
|
|
171
|
-
invalid: r,
|
|
172
|
-
disabled: t,
|
|
173
|
-
onRemove: () => u(o)
|
|
174
|
-
},
|
|
175
|
-
`${p.name}-${o}`
|
|
176
|
-
))
|
|
177
|
-
] });
|
|
178
|
-
}
|
|
179
|
-
function he({
|
|
180
|
-
className: d,
|
|
181
|
-
selectedFile: i,
|
|
182
|
-
selectedFiles: r,
|
|
183
|
-
onFileSelect: t,
|
|
184
|
-
onFilesSelect: n,
|
|
185
|
-
onFileAdd: u,
|
|
186
|
-
onFileRemove: h,
|
|
187
|
-
onFilesAdd: p,
|
|
188
|
-
onFilesRemove: o,
|
|
189
|
-
onInvalidFile: g,
|
|
190
|
-
acceptedExtensions: v,
|
|
191
|
-
maxSizeInMB: z = 50,
|
|
192
|
-
maxFiles: w = 10,
|
|
193
|
-
multiple: L = !1,
|
|
194
|
-
filesPosition: $ = "below",
|
|
195
|
-
invalid: Q = !1,
|
|
196
|
-
disabled: X = !1,
|
|
197
|
-
"aria-invalid": Y,
|
|
198
|
-
labels: A,
|
|
199
|
-
input: R,
|
|
200
|
-
...Z
|
|
201
|
-
}) {
|
|
202
|
-
const [W, G] = K(!1), [q, P] = K(!1), O = ae(null);
|
|
203
|
-
se(() => {
|
|
204
|
-
const s = () => {
|
|
205
|
-
if (O.current) {
|
|
206
|
-
const c = O.current.closest("fieldset");
|
|
207
|
-
P(c?.disabled ?? !1);
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
s();
|
|
211
|
-
const m = new MutationObserver(s);
|
|
212
|
-
if (O.current) {
|
|
213
|
-
const c = O.current.closest("fieldset");
|
|
214
|
-
c && m.observe(c, { attributes: !0, attributeFilter: ["disabled"] });
|
|
215
|
-
}
|
|
216
|
-
return () => m.disconnect();
|
|
217
|
-
}, []);
|
|
218
|
-
const T = v?.join(",") || "", E = z * 1024 * 1024, j = L || r !== void 0 || n !== void 0, l = j ? r || [] : i ? [i] : [], b = Q || Y, y = X || q, D = (s) => {
|
|
219
|
-
y || (s.preventDefault(), G(!0));
|
|
220
|
-
}, re = (s) => {
|
|
221
|
-
y || (s.preventDefault(), G(!1));
|
|
222
|
-
}, F = (s) => {
|
|
223
|
-
if (!y)
|
|
224
|
-
if (s.preventDefault(), G(!1), j) {
|
|
225
|
-
const c = Array.from(s.dataTransfer.files).filter(B);
|
|
226
|
-
if (c.length > 0) {
|
|
227
|
-
const a = [...r || [], ...c].slice(0, w);
|
|
228
|
-
n && n(a), p && p(c);
|
|
229
|
-
}
|
|
230
|
-
} else {
|
|
231
|
-
const m = s.dataTransfer.files[0];
|
|
232
|
-
m && B(m) && (t && t(m), u && u(m));
|
|
233
|
-
}
|
|
234
|
-
}, V = (s) => {
|
|
235
|
-
if (!y) {
|
|
236
|
-
if (j) {
|
|
237
|
-
const c = (s.target.files ? Array.from(s.target.files) : []).filter(B);
|
|
238
|
-
if (c.length > 0) {
|
|
239
|
-
const a = [...r || [], ...c].slice(0, w);
|
|
240
|
-
n && n(a), p && p(c);
|
|
241
|
-
}
|
|
242
|
-
} else {
|
|
243
|
-
const m = s.target.files?.[0];
|
|
244
|
-
m && B(m) && (t && t(m), u && u(m));
|
|
245
|
-
}
|
|
246
|
-
s.target.value = "";
|
|
247
|
-
}
|
|
248
|
-
}, H = (s) => {
|
|
249
|
-
if (y) return;
|
|
250
|
-
const m = l[s];
|
|
251
|
-
if (j) {
|
|
252
|
-
const c = l.filter((I, a) => a !== s);
|
|
253
|
-
n && n(c), o && m && o([m]);
|
|
254
|
-
} else
|
|
255
|
-
t && t(null), h && m && h(m);
|
|
256
|
-
}, B = (s) => {
|
|
257
|
-
const m = s.name.substring(s.name.lastIndexOf(".")), c = !v || v.length === 0 || v.includes(m.toLowerCase()), I = s.size <= E;
|
|
258
|
-
return !c && g ? g(s, "extension") : !I && g && g(s, "size"), c && I;
|
|
259
|
-
}, J = () => {
|
|
260
|
-
if (y) return;
|
|
261
|
-
const s = [...l];
|
|
262
|
-
j ? (n && n([]), o && s.length > 0 && o(s)) : (t && t(null), h && s.length > 0 && h(s[0]));
|
|
263
|
-
};
|
|
264
|
-
return /* @__PURE__ */ e.jsxs("div", { ref: O, className: N("adm:flex adm:flex-col adm:gap-4", d), ...Z, children: [
|
|
265
|
-
j && $ === "above" && /* @__PURE__ */ e.jsx(
|
|
266
|
-
ee,
|
|
267
|
-
{
|
|
268
|
-
files: l,
|
|
269
|
-
isMultiple: j,
|
|
270
|
-
invalid: b,
|
|
271
|
-
disabled: y,
|
|
272
|
-
labels: A,
|
|
273
|
-
onRemoveFile: H,
|
|
274
|
-
onClearAll: J
|
|
275
|
-
}
|
|
276
|
-
),
|
|
277
|
-
(j || l.length === 0) && /* @__PURE__ */ e.jsx(
|
|
278
|
-
ne,
|
|
279
|
-
{
|
|
280
|
-
isDragging: W,
|
|
281
|
-
isMultiple: j,
|
|
282
|
-
invalid: b,
|
|
283
|
-
disabled: y,
|
|
284
|
-
accept: T,
|
|
285
|
-
acceptedExtensions: v,
|
|
286
|
-
maxSizeInMB: z,
|
|
287
|
-
maxFiles: w,
|
|
288
|
-
labels: A,
|
|
289
|
-
input: R,
|
|
290
|
-
onDragOver: D,
|
|
291
|
-
onDragLeave: re,
|
|
292
|
-
onDrop: F,
|
|
293
|
-
onFileChange: V
|
|
294
|
-
}
|
|
295
|
-
),
|
|
296
|
-
!j && l.length > 0 && /* @__PURE__ */ e.jsx(
|
|
297
|
-
ee,
|
|
298
|
-
{
|
|
299
|
-
files: l,
|
|
300
|
-
isMultiple: j,
|
|
301
|
-
invalid: b,
|
|
302
|
-
disabled: y,
|
|
303
|
-
labels: A,
|
|
304
|
-
onRemoveFile: H,
|
|
305
|
-
onClearAll: J
|
|
306
|
-
}
|
|
307
|
-
),
|
|
308
|
-
j && $ === "below" && /* @__PURE__ */ e.jsx(
|
|
167
|
+
i.map((f, l) => /* @__PURE__ */ t.jsx(
|
|
309
168
|
ee,
|
|
310
169
|
{
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
labels: A,
|
|
316
|
-
onRemoveFile: H,
|
|
317
|
-
onClearAll: J
|
|
318
|
-
}
|
|
319
|
-
)
|
|
320
|
-
] });
|
|
321
|
-
}
|
|
322
|
-
function de({
|
|
323
|
-
isDragging: d,
|
|
324
|
-
isMultiple: i,
|
|
325
|
-
invalid: r,
|
|
326
|
-
disabled: t,
|
|
327
|
-
accept: n,
|
|
328
|
-
acceptedExtensions: u,
|
|
329
|
-
maxSizeInMB: h,
|
|
330
|
-
maxFiles: p,
|
|
331
|
-
labels: o,
|
|
332
|
-
input: g,
|
|
333
|
-
onDragOver: v,
|
|
334
|
-
onDragLeave: z,
|
|
335
|
-
onDrop: w,
|
|
336
|
-
onFileChange: L
|
|
337
|
-
}) {
|
|
338
|
-
const $ = g?.id || `file-upload-v2-${Math.random().toString(36).substring(2, 11)}`;
|
|
339
|
-
return /* @__PURE__ */ e.jsxs(
|
|
340
|
-
"div",
|
|
341
|
-
{
|
|
342
|
-
onDragOver: t ? void 0 : v,
|
|
343
|
-
onDragLeave: t ? void 0 : z,
|
|
344
|
-
onDrop: t ? void 0 : w,
|
|
345
|
-
className: N(
|
|
346
|
-
`
|
|
347
|
-
adm:flex adm:flex-col adm:items-center adm:gap-6 adm:rounded-2xl
|
|
348
|
-
adm:border-2
|
|
349
|
-
`,
|
|
350
|
-
"adm:border-dashed adm:bg-background adm:p-6 adm:transition-colors",
|
|
351
|
-
{
|
|
352
|
-
"adm:border-primary": d && !r && !t,
|
|
353
|
-
"adm:border-destructive": r && !t,
|
|
354
|
-
"adm:border-input": !d && !r,
|
|
355
|
-
"adm:cursor-not-allowed adm:opacity-50": t
|
|
356
|
-
}
|
|
357
|
-
),
|
|
358
|
-
children: [
|
|
359
|
-
/* @__PURE__ */ e.jsx(
|
|
360
|
-
"div",
|
|
361
|
-
{
|
|
362
|
-
className: N(
|
|
363
|
-
"adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",
|
|
364
|
-
r && !t ? "adm:bg-destructive/10" : "adm:bg-primary-50"
|
|
365
|
-
),
|
|
366
|
-
children: /* @__PURE__ */ e.jsx(
|
|
367
|
-
_,
|
|
368
|
-
{
|
|
369
|
-
symbol: "text_snippet",
|
|
370
|
-
className: r && !t ? "adm:text-destructive" : "adm:text-primary"
|
|
371
|
-
}
|
|
372
|
-
)
|
|
373
|
-
}
|
|
374
|
-
),
|
|
375
|
-
/* @__PURE__ */ e.jsxs("div", { className: "adm:flex adm:flex-col adm:items-center adm:gap-2", children: [
|
|
376
|
-
/* @__PURE__ */ e.jsx(k, { color: r && !t ? "destructive" : void 0, children: o?.dragDrop || (i ? "Drag and drop your files here or" : "Drag and drop your file here or") }),
|
|
377
|
-
/* @__PURE__ */ e.jsxs("label", { htmlFor: $, children: [
|
|
378
|
-
/* @__PURE__ */ e.jsx(
|
|
379
|
-
"input",
|
|
380
|
-
{
|
|
381
|
-
...g,
|
|
382
|
-
id: $,
|
|
383
|
-
type: "file",
|
|
384
|
-
accept: n,
|
|
385
|
-
multiple: i,
|
|
386
|
-
onChange: L,
|
|
387
|
-
disabled: t,
|
|
388
|
-
className: "adm:hidden"
|
|
389
|
-
}
|
|
390
|
-
),
|
|
391
|
-
/* @__PURE__ */ e.jsx(
|
|
392
|
-
M,
|
|
393
|
-
{
|
|
394
|
-
asChild: !0,
|
|
395
|
-
type: "button",
|
|
396
|
-
variant: "link",
|
|
397
|
-
className: N("adm:cursor-pointer", t && `
|
|
398
|
-
adm:pointer-events-none
|
|
399
|
-
`),
|
|
400
|
-
disabled: t,
|
|
401
|
-
children: /* @__PURE__ */ e.jsx("span", { children: o?.selectFile || (i ? "Select files" : "Select the file") })
|
|
402
|
-
}
|
|
403
|
-
)
|
|
404
|
-
] })
|
|
405
|
-
] }),
|
|
406
|
-
/* @__PURE__ */ e.jsx(k, { className: "adm:text-center", color: r && !t ? "destructive" : "muted", children: o?.fileRequirements || (u && u.length > 0 ? `Allowed files: ${u.join(", ")}. Maximum size ${h} MB${i ? `. Up to ${p} files` : ""}.` : `Maximum size ${h} MB${i ? `. Up to ${p} files` : ""}.`) })
|
|
407
|
-
]
|
|
408
|
-
}
|
|
409
|
-
);
|
|
410
|
-
}
|
|
411
|
-
function me({ fileWithMetadata: d, invalid: i, disabled: r, onRemove: t }) {
|
|
412
|
-
const { file: n } = d;
|
|
413
|
-
return /* @__PURE__ */ e.jsxs(
|
|
414
|
-
"div",
|
|
415
|
-
{
|
|
416
|
-
className: N(
|
|
417
|
-
"adm:flex adm:items-center adm:gap-4 adm:rounded-2xl adm:border adm:p-6",
|
|
418
|
-
i && !r ? "adm:border-destructive adm:bg-destructive/5" : "adm:border-input adm:bg-muted",
|
|
419
|
-
r && "adm:cursor-not-allowed adm:opacity-50"
|
|
420
|
-
),
|
|
421
|
-
children: [
|
|
422
|
-
/* @__PURE__ */ e.jsx(
|
|
423
|
-
"div",
|
|
424
|
-
{
|
|
425
|
-
className: N(
|
|
426
|
-
"adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",
|
|
427
|
-
i && !r ? "adm:bg-destructive/10" : "adm:bg-primary-50"
|
|
428
|
-
),
|
|
429
|
-
children: /* @__PURE__ */ e.jsx(
|
|
430
|
-
_,
|
|
431
|
-
{
|
|
432
|
-
symbol: "text_snippet",
|
|
433
|
-
className: i && !r ? "adm:text-destructive" : "adm:text-primary"
|
|
434
|
-
}
|
|
435
|
-
)
|
|
436
|
-
}
|
|
437
|
-
),
|
|
438
|
-
/* @__PURE__ */ e.jsxs(
|
|
439
|
-
"div",
|
|
440
|
-
{
|
|
441
|
-
className: `
|
|
442
|
-
adm:flex adm:min-w-0 adm:flex-1 adm:items-start adm:gap-3
|
|
443
|
-
`,
|
|
444
|
-
children: [
|
|
445
|
-
/* @__PURE__ */ e.jsx("div", { className: "adm:min-w-0 adm:flex-1", children: /* @__PURE__ */ e.jsx(k, { className: "adm:truncate adm:font-semibold", children: n.name }) }),
|
|
446
|
-
/* @__PURE__ */ e.jsxs(k, { className: "adm:shrink-0", color: "muted", children: [
|
|
447
|
-
(n.size / 1024 / 1024).toFixed(1),
|
|
448
|
-
" MB"
|
|
449
|
-
] })
|
|
450
|
-
]
|
|
451
|
-
}
|
|
452
|
-
),
|
|
453
|
-
/* @__PURE__ */ e.jsx(
|
|
454
|
-
M,
|
|
455
|
-
{
|
|
456
|
-
variant: "destructive-medium",
|
|
457
|
-
onClick: t,
|
|
458
|
-
type: "button",
|
|
459
|
-
disabled: r,
|
|
460
|
-
children: /* @__PURE__ */ e.jsx(_, { symbol: "delete", className: "adm:text-destructive" })
|
|
461
|
-
}
|
|
462
|
-
)
|
|
463
|
-
]
|
|
464
|
-
}
|
|
465
|
-
);
|
|
466
|
-
}
|
|
467
|
-
function te({ files: d, isMultiple: i, invalid: r, disabled: t, labels: n, onRemoveFile: u, onClearAll: h }) {
|
|
468
|
-
return d.length === 0 ? null : /* @__PURE__ */ e.jsxs("div", { className: "adm:flex adm:flex-col adm:gap-3", children: [
|
|
469
|
-
i && d.length > 1 && /* @__PURE__ */ e.jsxs("div", { className: "adm:flex adm:items-center adm:justify-between", children: [
|
|
470
|
-
/* @__PURE__ */ e.jsx(k, { className: "adm:text-sm adm:font-medium", color: r && !t ? "destructive" : void 0, children: n?.filesSelected?.(d.length) || `${d.length} file${d.length !== 1 ? "s" : ""} selected` }),
|
|
471
|
-
/* @__PURE__ */ e.jsx(
|
|
472
|
-
M,
|
|
473
|
-
{
|
|
474
|
-
variant: "ghost",
|
|
475
|
-
size: "sm",
|
|
476
|
-
onClick: h,
|
|
477
|
-
type: "button",
|
|
478
|
-
disabled: t,
|
|
479
|
-
children: "Clear all"
|
|
480
|
-
}
|
|
481
|
-
)
|
|
482
|
-
] }),
|
|
483
|
-
d.map((p, o) => /* @__PURE__ */ e.jsx(
|
|
484
|
-
me,
|
|
485
|
-
{
|
|
486
|
-
fileWithMetadata: p,
|
|
487
|
-
invalid: r,
|
|
488
|
-
disabled: t,
|
|
489
|
-
onRemove: () => u(o)
|
|
170
|
+
file: f,
|
|
171
|
+
invalid: a,
|
|
172
|
+
disabled: r,
|
|
173
|
+
onRemove: () => c(l)
|
|
490
174
|
},
|
|
491
|
-
|
|
175
|
+
`${f.name}-${l}`
|
|
492
176
|
))
|
|
493
177
|
] });
|
|
494
178
|
}
|
|
495
|
-
function
|
|
496
|
-
className:
|
|
497
|
-
selectedFile:
|
|
498
|
-
selectedFiles:
|
|
499
|
-
onFileSelect:
|
|
500
|
-
onFilesSelect:
|
|
501
|
-
onFileAdd:
|
|
179
|
+
function de({
|
|
180
|
+
className: i,
|
|
181
|
+
selectedFile: d,
|
|
182
|
+
selectedFiles: a,
|
|
183
|
+
onFileSelect: r,
|
|
184
|
+
onFilesSelect: m,
|
|
185
|
+
onFileAdd: c,
|
|
502
186
|
onFileRemove: h,
|
|
503
|
-
onFilesAdd:
|
|
504
|
-
onFilesRemove:
|
|
505
|
-
onInvalidFile:
|
|
506
|
-
acceptedExtensions:
|
|
507
|
-
maxSizeInMB:
|
|
508
|
-
maxFiles:
|
|
509
|
-
multiple:
|
|
510
|
-
filesPosition:
|
|
511
|
-
invalid:
|
|
512
|
-
disabled:
|
|
513
|
-
"aria-invalid":
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
...W
|
|
187
|
+
onFilesAdd: f,
|
|
188
|
+
onFilesRemove: l,
|
|
189
|
+
onInvalidFile: p,
|
|
190
|
+
acceptedExtensions: g,
|
|
191
|
+
maxSizeInMB: w = 50,
|
|
192
|
+
maxFiles: j = 10,
|
|
193
|
+
multiple: T = !1,
|
|
194
|
+
filesPosition: y = "below",
|
|
195
|
+
invalid: V = !1,
|
|
196
|
+
disabled: _ = !1,
|
|
197
|
+
"aria-invalid": M,
|
|
198
|
+
labels: C,
|
|
199
|
+
input: q,
|
|
200
|
+
...G
|
|
518
201
|
}) {
|
|
519
|
-
const [
|
|
520
|
-
|
|
521
|
-
const
|
|
522
|
-
if (
|
|
523
|
-
const
|
|
524
|
-
|
|
202
|
+
const [H, I] = U(!1), [J, K] = U(!1), b = P(null);
|
|
203
|
+
F(() => {
|
|
204
|
+
const e = () => {
|
|
205
|
+
if (b.current) {
|
|
206
|
+
const n = b.current.closest("fieldset");
|
|
207
|
+
K(n?.disabled ?? !1);
|
|
525
208
|
}
|
|
526
209
|
};
|
|
527
|
-
|
|
528
|
-
const
|
|
529
|
-
if (
|
|
530
|
-
const
|
|
531
|
-
|
|
210
|
+
e();
|
|
211
|
+
const s = new MutationObserver(e);
|
|
212
|
+
if (b.current) {
|
|
213
|
+
const n = b.current.closest("fieldset");
|
|
214
|
+
n && s.observe(n, { attributes: !0, attributeFilter: ["disabled"] });
|
|
532
215
|
}
|
|
533
|
-
return () =>
|
|
216
|
+
return () => s.disconnect();
|
|
534
217
|
}, []);
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
if (f.length > 0) {
|
|
547
|
-
const C = f.map(V), S = [...r || [], ...C].slice(0, w);
|
|
548
|
-
n && n(S), p && p(C);
|
|
218
|
+
const Q = g?.join(",") || "", W = w * 1024 * 1024, o = T || a !== void 0 || m !== void 0, x = o ? a || [] : d ? [d] : [], k = V || M, u = _ || J, X = (e) => {
|
|
219
|
+
u || (e.preventDefault(), I(!0));
|
|
220
|
+
}, Y = (e) => {
|
|
221
|
+
u || (e.preventDefault(), I(!1));
|
|
222
|
+
}, Z = (e) => {
|
|
223
|
+
if (!u)
|
|
224
|
+
if (e.preventDefault(), I(!1), o) {
|
|
225
|
+
const n = Array.from(e.dataTransfer.files).filter(z);
|
|
226
|
+
if (n.length > 0) {
|
|
227
|
+
const N = [...a || [], ...n].slice(0, j);
|
|
228
|
+
m && m(N), f && f(n);
|
|
549
229
|
}
|
|
550
230
|
} else {
|
|
551
|
-
const
|
|
552
|
-
|
|
553
|
-
const f = V(x);
|
|
554
|
-
t && t(f), u && u(f);
|
|
555
|
-
}
|
|
231
|
+
const s = e.dataTransfer.files[0];
|
|
232
|
+
s && z(s) && (r && r(s), c && c(s));
|
|
556
233
|
}
|
|
557
|
-
},
|
|
558
|
-
if (!
|
|
559
|
-
if (
|
|
560
|
-
const
|
|
561
|
-
if (
|
|
562
|
-
const
|
|
563
|
-
|
|
234
|
+
}, E = (e) => {
|
|
235
|
+
if (!u) {
|
|
236
|
+
if (o) {
|
|
237
|
+
const n = (e.target.files ? Array.from(e.target.files) : []).filter(z);
|
|
238
|
+
if (n.length > 0) {
|
|
239
|
+
const N = [...a || [], ...n].slice(0, j);
|
|
240
|
+
m && m(N), f && f(n);
|
|
564
241
|
}
|
|
565
242
|
} else {
|
|
566
|
-
const
|
|
567
|
-
|
|
568
|
-
const f = V(x);
|
|
569
|
-
t && t(f), u && u(f);
|
|
570
|
-
}
|
|
243
|
+
const s = e.target.files?.[0];
|
|
244
|
+
s && z(s) && (r && r(s), c && c(s));
|
|
571
245
|
}
|
|
572
|
-
|
|
246
|
+
e.target.value = "";
|
|
573
247
|
}
|
|
574
|
-
},
|
|
575
|
-
if (
|
|
576
|
-
const
|
|
577
|
-
if (
|
|
578
|
-
const
|
|
579
|
-
|
|
248
|
+
}, L = (e) => {
|
|
249
|
+
if (u) return;
|
|
250
|
+
const s = x[e];
|
|
251
|
+
if (o) {
|
|
252
|
+
const n = x.filter((D, N) => N !== e);
|
|
253
|
+
m && m(n), l && s && l([s]);
|
|
580
254
|
} else
|
|
581
|
-
|
|
582
|
-
},
|
|
583
|
-
const
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
}, I = () => {
|
|
590
|
-
if (D) return;
|
|
591
|
-
const a = [...b];
|
|
592
|
-
l ? (n && n([]), o && a.length > 0 && o(a)) : (t && t(null), h && a.length > 0 && h(a[0]));
|
|
255
|
+
r && r(null), h && s && h(s);
|
|
256
|
+
}, z = (e) => {
|
|
257
|
+
const s = e.name.substring(e.name.lastIndexOf(".")), n = !g || g.length === 0 || g.includes(s.toLowerCase()), D = e.size <= W;
|
|
258
|
+
return !n && p ? p(e, "extension") : !D && p && p(e, "size"), n && D;
|
|
259
|
+
}, O = () => {
|
|
260
|
+
if (u) return;
|
|
261
|
+
const e = [...x];
|
|
262
|
+
o ? (m && m([]), l && e.length > 0 && l(e)) : (r && r(null), h && e.length > 0 && h(e[0]));
|
|
593
263
|
};
|
|
594
|
-
return /* @__PURE__ */
|
|
595
|
-
|
|
596
|
-
|
|
264
|
+
return /* @__PURE__ */ t.jsxs("div", { ref: b, className: v("adm:flex adm:flex-col adm:gap-4", i), ...G, children: [
|
|
265
|
+
o && y === "above" && /* @__PURE__ */ t.jsx(
|
|
266
|
+
R,
|
|
597
267
|
{
|
|
598
|
-
files:
|
|
599
|
-
isMultiple:
|
|
600
|
-
invalid:
|
|
601
|
-
disabled:
|
|
602
|
-
labels:
|
|
603
|
-
onRemoveFile:
|
|
604
|
-
onClearAll:
|
|
268
|
+
files: x,
|
|
269
|
+
isMultiple: o,
|
|
270
|
+
invalid: k,
|
|
271
|
+
disabled: u,
|
|
272
|
+
labels: C,
|
|
273
|
+
onRemoveFile: L,
|
|
274
|
+
onClearAll: O
|
|
605
275
|
}
|
|
606
276
|
),
|
|
607
|
-
(
|
|
608
|
-
|
|
277
|
+
(o || x.length === 0) && /* @__PURE__ */ t.jsx(
|
|
278
|
+
S,
|
|
609
279
|
{
|
|
610
|
-
isDragging:
|
|
611
|
-
isMultiple:
|
|
612
|
-
invalid:
|
|
613
|
-
disabled:
|
|
614
|
-
accept:
|
|
615
|
-
acceptedExtensions:
|
|
616
|
-
maxSizeInMB:
|
|
617
|
-
maxFiles:
|
|
618
|
-
labels:
|
|
619
|
-
input:
|
|
620
|
-
onDragOver:
|
|
621
|
-
onDragLeave:
|
|
622
|
-
onDrop:
|
|
623
|
-
onFileChange:
|
|
280
|
+
isDragging: H,
|
|
281
|
+
isMultiple: o,
|
|
282
|
+
invalid: k,
|
|
283
|
+
disabled: u,
|
|
284
|
+
accept: Q,
|
|
285
|
+
acceptedExtensions: g,
|
|
286
|
+
maxSizeInMB: w,
|
|
287
|
+
maxFiles: j,
|
|
288
|
+
labels: C,
|
|
289
|
+
input: q,
|
|
290
|
+
onDragOver: X,
|
|
291
|
+
onDragLeave: Y,
|
|
292
|
+
onDrop: Z,
|
|
293
|
+
onFileChange: E
|
|
624
294
|
}
|
|
625
295
|
),
|
|
626
|
-
!
|
|
627
|
-
|
|
296
|
+
!o && x.length > 0 && /* @__PURE__ */ t.jsx(
|
|
297
|
+
R,
|
|
628
298
|
{
|
|
629
|
-
files:
|
|
630
|
-
isMultiple:
|
|
631
|
-
invalid:
|
|
632
|
-
disabled:
|
|
633
|
-
labels:
|
|
634
|
-
onRemoveFile:
|
|
635
|
-
onClearAll:
|
|
299
|
+
files: x,
|
|
300
|
+
isMultiple: o,
|
|
301
|
+
invalid: k,
|
|
302
|
+
disabled: u,
|
|
303
|
+
labels: C,
|
|
304
|
+
onRemoveFile: L,
|
|
305
|
+
onClearAll: O
|
|
636
306
|
}
|
|
637
307
|
),
|
|
638
|
-
|
|
639
|
-
|
|
308
|
+
o && y === "below" && /* @__PURE__ */ t.jsx(
|
|
309
|
+
R,
|
|
640
310
|
{
|
|
641
|
-
files:
|
|
642
|
-
isMultiple:
|
|
643
|
-
invalid:
|
|
644
|
-
disabled:
|
|
645
|
-
labels:
|
|
646
|
-
onRemoveFile:
|
|
647
|
-
onClearAll:
|
|
311
|
+
files: x,
|
|
312
|
+
isMultiple: o,
|
|
313
|
+
invalid: k,
|
|
314
|
+
disabled: u,
|
|
315
|
+
labels: C,
|
|
316
|
+
onRemoveFile: L,
|
|
317
|
+
onClearAll: O
|
|
648
318
|
}
|
|
649
319
|
)
|
|
650
320
|
] });
|
|
651
321
|
}
|
|
652
322
|
export {
|
|
653
|
-
|
|
654
|
-
xe as FileUploadV2
|
|
323
|
+
de as FileUpload
|
|
655
324
|
};
|