@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.
@@ -1,120 +1,120 @@
1
1
  import { j as e } from "./jsx-runtime-BzflLqGi.js";
2
- import { B as O } from "./button-BnUlAtuD.js";
3
- import { I as L } from "./icon-BFQz1tQC.js";
4
- import { T as y } from "./typography-MnY0LQoZ.js";
5
- import { c as v } from "./index-CRiPKpXj.js";
6
- import { useState as B, useRef as W, useEffect as X } from "react";
7
- function Y({
8
- isDragging: n,
9
- isMultiple: d,
10
- invalid: a,
11
- disabled: r,
12
- accept: m,
13
- acceptedExtensions: l,
14
- maxSizeInMB: c,
15
- maxFiles: x,
16
- labels: f,
17
- input: b,
18
- onDragOver: D,
19
- onDragLeave: w,
20
- onDrop: C,
21
- onFileChange: A
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 p = b?.id || `file-upload-${Math.random().toString(36).substring(2, 11)}`;
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: r ? void 0 : D,
28
- onDragLeave: r ? void 0 : w,
29
- onDrop: r ? void 0 : C,
30
- className: v(
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": n && !a && !r,
38
- "adm:border-destructive": a && !r,
39
- "adm:border-input": !n && !a,
40
- "adm:cursor-not-allowed adm:opacity-50": r
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: v(
47
+ className: N(
48
48
  "adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",
49
- a && !r ? "adm:bg-destructive/10" : "adm:bg-primary-50"
49
+ r && !t ? "adm:bg-destructive/10" : "adm:bg-primary-50"
50
50
  ),
51
51
  children: /* @__PURE__ */ e.jsx(
52
- L,
52
+ _,
53
53
  {
54
54
  symbol: "text_snippet",
55
- className: a && !r ? "adm:text-destructive" : "adm:text-primary"
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(y, { color: a && !r ? "destructive" : void 0, children: f?.dragDrop || (d ? "Drag and drop your files here or" : "Drag and drop your file here or") }),
62
- /* @__PURE__ */ e.jsxs("label", { htmlFor: p, children: [
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
- ...b,
67
- id: p,
66
+ ...g,
67
+ id: $,
68
68
  type: "file",
69
- accept: m,
70
- multiple: d,
71
- onChange: A,
72
- disabled: r,
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
- O,
77
+ M,
78
78
  {
79
79
  asChild: !0,
80
80
  type: "button",
81
81
  variant: "link",
82
- className: v("adm:cursor-pointer", r && `
82
+ className: N("adm:cursor-pointer", t && `
83
83
  adm:pointer-events-none
84
84
  `),
85
- disabled: r,
86
- children: /* @__PURE__ */ e.jsx("span", { children: f?.selectFile || (d ? "Select files" : "Select the file") })
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(y, { className: "adm:text-center", color: a && !r ? "destructive" : "muted", children: f?.fileRequirements || (l && l.length > 0 ? `Allowed files: ${l.join(", ")}. Maximum size ${c} MB${d ? `. Up to ${x} files` : ""}.` : `Maximum size ${c} MB${d ? `. Up to ${x} files` : ""}.`) })
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 Z({ file: n, invalid: d, disabled: a, onRemove: r }) {
96
+ function ie({ file: d, invalid: i, disabled: r, onRemove: t }) {
97
97
  return /* @__PURE__ */ e.jsxs(
98
98
  "div",
99
99
  {
100
- className: v(
100
+ className: N(
101
101
  "adm:flex adm:items-center adm:gap-4 adm:rounded-2xl adm:border adm:p-6",
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"
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: v(
109
+ className: N(
110
110
  "adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",
111
- d && !a ? "adm:bg-destructive/10" : "adm:bg-primary-50"
111
+ i && !r ? "adm:bg-destructive/10" : "adm:bg-primary-50"
112
112
  ),
113
113
  children: /* @__PURE__ */ e.jsx(
114
- L,
114
+ _,
115
115
  {
116
116
  symbol: "text_snippet",
117
- className: d && !a ? "adm:text-destructive" : "adm:text-primary"
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(y, { className: "adm:truncate adm:font-semibold", children: n.name }) }),
130
- /* @__PURE__ */ e.jsxs(y, { className: "adm:shrink-0", color: "muted", children: [
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
- O,
454
+ M,
139
455
  {
140
456
  variant: "destructive-medium",
141
- onClick: r,
457
+ onClick: t,
142
458
  type: "button",
143
- disabled: a,
144
- children: /* @__PURE__ */ e.jsx(L, { symbol: "delete", className: "adm:text-destructive" })
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 I({ files: n, isMultiple: d, invalid: a, disabled: r, labels: m, onRemoveFile: l, onClearAll: c }) {
152
- return n.length === 0 ? null : /* @__PURE__ */ e.jsxs("div", { className: "adm:flex adm:flex-col adm:gap-3", children: [
153
- d && n.length > 1 && /* @__PURE__ */ e.jsxs("div", { className: "adm:flex adm:items-center adm:justify-between", children: [
154
- /* @__PURE__ */ e.jsx(y, { className: "adm:text-sm adm:font-medium", color: a && !r ? "destructive" : void 0, children: m?.filesSelected?.(n.length) || `${n.length} file${n.length !== 1 ? "s" : ""} selected` }),
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
- O,
472
+ M,
157
473
  {
158
474
  variant: "ghost",
159
475
  size: "sm",
160
- onClick: c,
476
+ onClick: h,
161
477
  type: "button",
162
- disabled: r,
478
+ disabled: t,
163
479
  children: "Clear all"
164
480
  }
165
481
  )
166
482
  ] }),
167
- n.map((x, f) => /* @__PURE__ */ e.jsx(
168
- Z,
483
+ d.map((p, o) => /* @__PURE__ */ e.jsx(
484
+ me,
169
485
  {
170
- file: x,
171
- invalid: a,
172
- disabled: r,
173
- onRemove: () => l(f)
486
+ fileWithMetadata: p,
487
+ invalid: r,
488
+ disabled: t,
489
+ onRemove: () => u(o)
174
490
  },
175
- `${x.name}-${f}`
491
+ p.id
176
492
  ))
177
493
  ] });
178
494
  }
179
- function ae({
180
- className: n,
181
- selectedFile: d,
182
- selectedFiles: a,
183
- onFileSelect: r,
184
- onFilesSelect: m,
185
- onInvalidFile: l,
186
- acceptedExtensions: c,
187
- maxSizeInMB: x = 50,
188
- maxFiles: f = 10,
189
- multiple: b = !1,
190
- filesPosition: D = "below",
191
- invalid: w = !1,
192
- disabled: C = !1,
193
- "aria-invalid": A,
194
- labels: p,
195
- input: T,
196
- ...U
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 [V, R] = B(!1), [_, M] = B(!1), j = W(null);
199
- X(() => {
200
- const t = () => {
201
- if (j.current) {
202
- const i = j.current.closest("fieldset");
203
- M(i?.disabled ?? !1);
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
- t();
207
- const s = new MutationObserver(t);
208
- if (j.current) {
209
- const i = j.current.closest("fieldset");
210
- i && s.observe(i, { attributes: !0, attributeFilter: ["disabled"] });
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 () => s.disconnect();
533
+ return () => x.disconnect();
213
534
  }, []);
214
- const q = c?.join(",") || "", G = x * 1024 * 1024, o = b || a !== void 0 || m !== void 0, h = o ? a || [] : d ? [d] : [], N = w || A, u = C || _, H = (t) => {
215
- u || (t.preventDefault(), R(!0));
216
- }, J = (t) => {
217
- u || (t.preventDefault(), R(!1));
218
- }, K = (t) => {
219
- if (!u)
220
- if (t.preventDefault(), R(!1), o) {
221
- const i = Array.from(t.dataTransfer.files).filter($);
222
- if (i.length > 0) {
223
- const F = [...a || [], ...i].slice(0, f);
224
- m && m(F);
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 s = t.dataTransfer.files[0];
228
- s && $(s) && r && r(s);
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
- }, Q = (t) => {
231
- if (!u) {
232
- if (o) {
233
- const i = (t.target.files ? Array.from(t.target.files) : []).filter($);
234
- if (i.length > 0) {
235
- const F = [...a || [], ...i].slice(0, f);
236
- m && m(F);
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 s = t.target.files?.[0];
240
- s && $(s) && r && r(s);
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
- t.target.value = "";
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
- }, k = (t) => {
245
- if (!u)
246
- if (o) {
247
- const s = h.filter((i, g) => g !== t);
248
- m && m(s);
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: j, className: v("adm:flex adm:flex-col adm:gap-4", n), ...U, children: [
258
- o && D === "above" && /* @__PURE__ */ e.jsx(
259
- I,
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: h,
262
- isMultiple: o,
263
- invalid: N,
264
- disabled: u,
265
- labels: p,
266
- onRemoveFile: k,
267
- onClearAll: z
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
- (o || h.length === 0) && /* @__PURE__ */ e.jsx(
271
- Y,
607
+ (l || b.length === 0) && /* @__PURE__ */ e.jsx(
608
+ de,
272
609
  {
273
- isDragging: V,
274
- isMultiple: o,
275
- invalid: N,
276
- disabled: u,
277
- accept: q,
278
- acceptedExtensions: c,
279
- maxSizeInMB: x,
280
- maxFiles: f,
281
- labels: p,
282
- input: T,
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: J,
285
- onDrop: K,
286
- onFileChange: Q
621
+ onDragLeave: B,
622
+ onDrop: J,
623
+ onFileChange: s
287
624
  }
288
625
  ),
289
- !o && h.length > 0 && /* @__PURE__ */ e.jsx(
290
- I,
626
+ !l && b.length > 0 && /* @__PURE__ */ e.jsx(
627
+ te,
291
628
  {
292
- files: h,
293
- isMultiple: o,
294
- invalid: N,
295
- disabled: u,
296
- labels: p,
297
- onRemoveFile: k,
298
- onClearAll: z
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
- o && D === "below" && /* @__PURE__ */ e.jsx(
302
- I,
638
+ l && $ === "below" && /* @__PURE__ */ e.jsx(
639
+ te,
303
640
  {
304
- files: h,
305
- isMultiple: o,
306
- invalid: N,
307
- disabled: u,
308
- labels: p,
309
- onRemoveFile: k,
310
- onClearAll: z
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
- ae as FileUpload
653
+ he as FileUpload,
654
+ xe as FileUploadV2
317
655
  };