@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.
@@ -1,655 +1,324 @@
1
- import { j as e } from "./jsx-runtime-BzflLqGi.js";
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,
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: p,
16
- labels: o,
17
- input: g,
18
- onDragOver: v,
19
- onDragLeave: z,
20
- onDrop: w,
21
- onFileChange: L
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 $ = g?.id || `file-upload-${Math.random().toString(36).substring(2, 11)}`;
24
- return /* @__PURE__ */ e.jsxs(
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: t ? void 0 : v,
28
- onDragLeave: t ? void 0 : z,
29
- onDrop: t ? void 0 : w,
30
- className: N(
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": d && !r && !t,
38
- "adm:border-destructive": r && !t,
39
- "adm:border-input": !d && !r,
40
- "adm:cursor-not-allowed adm:opacity-50": t
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__ */ e.jsx(
44
+ /* @__PURE__ */ t.jsx(
45
45
  "div",
46
46
  {
47
- className: N(
47
+ className: v(
48
48
  "adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",
49
- r && !t ? "adm:bg-destructive/10" : "adm:bg-primary-50"
49
+ a && !r ? "adm:bg-destructive/10" : "adm:bg-primary-50"
50
50
  ),
51
- children: /* @__PURE__ */ e.jsx(
52
- _,
51
+ children: /* @__PURE__ */ t.jsx(
52
+ A,
53
53
  {
54
54
  symbol: "text_snippet",
55
- className: r && !t ? "adm:text-destructive" : "adm:text-primary"
55
+ className: a && !r ? "adm:text-destructive" : "adm:text-primary"
56
56
  }
57
57
  )
58
58
  }
59
59
  ),
60
- /* @__PURE__ */ e.jsxs("div", { className: "adm:flex adm:flex-col adm:items-center adm:gap-2", 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
- /* @__PURE__ */ e.jsx(
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
- ...g,
67
- id: $,
66
+ ...p,
67
+ id: y,
68
68
  type: "file",
69
- accept: n,
70
- multiple: i,
71
- onChange: L,
72
- disabled: t,
69
+ accept: m,
70
+ multiple: d,
71
+ onChange: T,
72
+ disabled: r,
73
73
  className: "adm:hidden"
74
74
  }
75
75
  ),
76
- /* @__PURE__ */ e.jsx(
77
- M,
76
+ /* @__PURE__ */ t.jsx(
77
+ B,
78
78
  {
79
79
  asChild: !0,
80
80
  type: "button",
81
81
  variant: "link",
82
- className: N("adm:cursor-pointer", t && `
82
+ className: v("adm:cursor-pointer", r && `
83
83
  adm:pointer-events-none
84
84
  `),
85
- disabled: t,
86
- children: /* @__PURE__ */ e.jsx("span", { children: o?.selectFile || (i ? "Select files" : "Select the file") })
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__ */ 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` : ""}.`) })
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 ie({ file: d, invalid: i, disabled: r, onRemove: t }) {
97
- return /* @__PURE__ */ e.jsxs(
96
+ function ee({ file: i, invalid: d, disabled: a, onRemove: r }) {
97
+ return /* @__PURE__ */ t.jsxs(
98
98
  "div",
99
99
  {
100
- className: N(
100
+ className: v(
101
101
  "adm:flex adm:items-center adm:gap-4 adm:rounded-2xl adm:border adm:p-6",
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"
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__ */ e.jsx(
106
+ /* @__PURE__ */ t.jsx(
107
107
  "div",
108
108
  {
109
- className: N(
109
+ className: v(
110
110
  "adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",
111
- i && !r ? "adm:bg-destructive/10" : "adm:bg-primary-50"
111
+ d && !a ? "adm:bg-destructive/10" : "adm:bg-primary-50"
112
112
  ),
113
- children: /* @__PURE__ */ e.jsx(
114
- _,
113
+ children: /* @__PURE__ */ t.jsx(
114
+ A,
115
115
  {
116
116
  symbol: "text_snippet",
117
- className: i && !r ? "adm:text-destructive" : "adm:text-primary"
117
+ className: d && !a ? "adm:text-destructive" : "adm:text-primary"
118
118
  }
119
119
  )
120
120
  }
121
121
  ),
122
- /* @__PURE__ */ e.jsxs(
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__ */ 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),
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__ */ e.jsx(
138
- M,
137
+ /* @__PURE__ */ t.jsx(
138
+ B,
139
139
  {
140
140
  variant: "destructive-medium",
141
- onClick: t,
141
+ onClick: r,
142
142
  type: "button",
143
- disabled: r,
144
- children: /* @__PURE__ */ e.jsx(_, { symbol: "delete", className: "adm:text-destructive" })
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 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,
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: t,
162
+ disabled: r,
163
163
  children: "Clear all"
164
164
  }
165
165
  )
166
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(
167
+ i.map((f, l) => /* @__PURE__ */ t.jsx(
309
168
  ee,
310
169
  {
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: [
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
- p.id
175
+ `${f.name}-${l}`
492
176
  ))
493
177
  ] });
494
178
  }
495
- function xe({
496
- className: d,
497
- selectedFile: i,
498
- selectedFiles: r,
499
- onFileSelect: t,
500
- onFilesSelect: n,
501
- onFileAdd: u,
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: 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
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 [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);
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
- 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"] });
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 () => x.disconnect();
216
+ return () => s.disconnect();
534
217
  }, []);
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);
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 x = a.dataTransfer.files[0];
552
- if (x && c(x)) {
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
- }, 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);
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 x = a.target.files?.[0];
567
- if (x && c(x)) {
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
- a.target.value = "";
246
+ e.target.value = "";
573
247
  }
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]);
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
- 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");
587
- }
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]));
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__ */ 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,
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: b,
599
- isMultiple: l,
600
- invalid: y,
601
- disabled: D,
602
- labels: R,
603
- onRemoveFile: m,
604
- onClearAll: I
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
- (l || b.length === 0) && /* @__PURE__ */ e.jsx(
608
- de,
277
+ (o || x.length === 0) && /* @__PURE__ */ t.jsx(
278
+ S,
609
279
  {
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,
620
- onDragOver: H,
621
- onDragLeave: B,
622
- onDrop: J,
623
- onFileChange: s
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
- !l && b.length > 0 && /* @__PURE__ */ e.jsx(
627
- te,
296
+ !o && x.length > 0 && /* @__PURE__ */ t.jsx(
297
+ R,
628
298
  {
629
- files: b,
630
- isMultiple: l,
631
- invalid: y,
632
- disabled: D,
633
- labels: R,
634
- onRemoveFile: m,
635
- onClearAll: I
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
- l && $ === "below" && /* @__PURE__ */ e.jsx(
639
- te,
308
+ o && y === "below" && /* @__PURE__ */ t.jsx(
309
+ R,
640
310
  {
641
- files: b,
642
- isMultiple: l,
643
- invalid: y,
644
- disabled: D,
645
- labels: R,
646
- onRemoveFile: m,
647
- onClearAll: I
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
- he as FileUpload,
654
- xe as FileUploadV2
323
+ de as FileUpload
655
324
  };