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