@trinityui/design-system 2.2.4 → 2.3.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/dist/forms.js CHANGED
@@ -1,22 +1,22 @@
1
- import { jsxs as f, jsx as e, Fragment as Re } from "react/jsx-runtime";
2
- import * as O from "react";
3
- import Fe, { createElement as Oe, useState as ae, useRef as Se, useCallback as S } from "react";
4
- import { useTheme as Me, Paper as de, Box as C, ListItem as pe, alpha as he, ListItemIcon as re, Checkbox as ge, ListItemText as ue, Divider as ye, Button as me, Autocomplete as Ae, Typography as _, Popper as Be, Chip as Ie, TextField as Ee, Alert as ve, Stack as ze, List as We, LinearProgress as je, ListItemSecondaryAction as Te, IconButton as $e } from "@mui/material";
5
- import { Check as le, Add as Ue, Close as be } from "@mui/icons-material";
6
- import ce from "@mui/icons-material/CloudUpload";
1
+ import { jsxs as f, jsx as e, Fragment as Se } from "react/jsx-runtime";
2
+ import * as M from "react";
3
+ import Oe, { createElement as Re, useState as le, useRef as Fe, useCallback as A } from "react";
4
+ import { useTheme as Me, Paper as pe, Box as L, ListItem as ue, alpha as he, ListItemIcon as te, Checkbox as ge, ListItemText as me, Divider as ye, Button as fe, Autocomplete as Ae, Typography as _, Popper as Be, Chip as Ie, TextField as Ee, Alert as ve, Stack as ze, List as We, LinearProgress as je, ListItemSecondaryAction as Te, IconButton as $e } from "@mui/material";
5
+ import { Check as ce, Add as Ue, Close as be } from "@mui/icons-material";
6
+ import de from "@mui/icons-material/CloudUpload";
7
7
  import Ve from "@mui/icons-material/InsertDriveFile";
8
- import _e from "@mui/icons-material/Delete";
8
+ import Ke from "@mui/icons-material/Delete";
9
9
  import ke from "@mui/icons-material/CheckCircle";
10
- import Ge from "@mui/icons-material/Error";
11
- import Ke from "@mui/icons-material/PictureAsPdf";
12
- import qe from "@mui/icons-material/Image";
10
+ import _e from "@mui/icons-material/Error";
11
+ import qe from "@mui/icons-material/PictureAsPdf";
12
+ import Ge from "@mui/icons-material/Image";
13
13
  import Ne from "@mui/icons-material/VideoLibrary";
14
14
  import He from "@mui/icons-material/Description";
15
15
  import { s as Ce } from "./app-shell.js";
16
- const xe = () => `new-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Je = (c) => /* @__PURE__ */ e(
16
+ const xe = () => `new-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Je = (d) => /* @__PURE__ */ e(
17
17
  Be,
18
18
  {
19
- ...c,
19
+ ...d,
20
20
  placement: "bottom-start",
21
21
  modifiers: [
22
22
  {
@@ -27,100 +27,110 @@ const xe = () => `new-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
27
27
  }
28
28
  ]
29
29
  }
30
- ), pr = O.forwardRef(function({
31
- options: d,
32
- value: n,
33
- defaultValue: D,
34
- onChange: b,
35
- creatable: x = !1,
36
- onCreate: w,
37
- createText: M = 'Create "{value}"',
38
- multiple: p = !1,
39
- placeholder: X = "Select...",
40
- label: G,
41
- helperText: a,
42
- error: K = !1,
43
- errorMessage: te,
44
- disabled: Y = !1,
45
- fullWidth: U = !1,
46
- size: W = "medium",
47
- limitTags: q = 3,
48
- showCheckbox: j = !0,
49
- groupBy: Z = !1,
50
- loading: V = !1,
51
- noOptionsText: N = "No options",
52
- filterOptions: H,
53
- renderOption: J,
54
- renderTag: T,
30
+ ), pr = M.forwardRef(function({
31
+ options: p,
32
+ value: s,
33
+ defaultValue: S,
34
+ onChange: x,
35
+ creatable: w = !1,
36
+ onCreate: I,
37
+ createText: B = 'Create "{value}"',
38
+ multiple: u = !1,
39
+ placeholder: Y = "Select...",
40
+ label: q,
41
+ helperText: l,
42
+ error: G = !1,
43
+ errorMessage: oe,
44
+ disabled: Z = !1,
45
+ fullWidth: V = !1,
46
+ size: j = "medium",
47
+ limitTags: N = 3,
48
+ showCheckbox: T = !0,
49
+ groupBy: ee = !1,
50
+ loading: K = !1,
51
+ noOptionsText: H = "No options",
52
+ filterOptions: J,
53
+ renderOption: Q,
54
+ renderTag: $,
55
55
  freeSolo: g = !1,
56
- autoHighlight: I = !0,
57
- clearOnEscape: oe = !0,
58
- showSelectAll: A = !1,
59
- selectAllText: ee = "Select All",
60
- className: ne,
61
- sx: se
56
+ autoHighlight: C = !0,
57
+ clearOnEscape: ne = !0,
58
+ showSelectAll: E = !1,
59
+ selectAllText: re = "Select All",
60
+ className: se,
61
+ sx: ae
62
62
  }, ie) {
63
- const Q = Me(), [y, $] = O.useState(""), [P, B] = O.useState(
64
- D || []
65
- ), L = n !== void 0 ? n : P, r = O.useCallback(
63
+ const X = Me(), [y, U] = M.useState(""), [O, z] = M.useState(
64
+ S || []
65
+ ), k = s !== void 0 ? s : O, r = M.useCallback(
66
66
  (t, o) => {
67
- if (H)
68
- return H(t, o);
69
- const s = o.inputValue.toLowerCase();
67
+ if (J)
68
+ return J(t, o);
69
+ const n = o.inputValue.toLowerCase();
70
70
  return t.filter(
71
- (u) => u.label.toLowerCase().includes(s) || u.secondary?.toLowerCase().includes(s)
71
+ (a) => a.label.toLowerCase().includes(n) || a.secondary?.toLowerCase().includes(n)
72
72
  );
73
73
  },
74
- [H]
75
- ), l = O.useMemo(() => !x || !y.trim() ? !1 : !d.some(
76
- (o) => o.label.toLowerCase() === y.toLowerCase()
77
- ), [x, y, d]), k = async (t, o) => {
78
- let s;
79
- if (p) {
80
- const u = o || [];
81
- s = await Promise.all(
82
- u.map(async (m) => typeof m == "string" ? x && w ? await w(m) : { id: xe(), label: m } : m)
74
+ [J]
75
+ ), c = M.useMemo(() => {
76
+ if (!w || !y.trim()) return !1;
77
+ const t = y.trim().toLowerCase(), o = p.some(
78
+ (a) => a.label.toLowerCase() === t
79
+ ), n = k.some(
80
+ (a) => a.label.toLowerCase() === t
81
+ );
82
+ return !o && !n;
83
+ }, [w, y, p, k]), D = async (t, o) => {
84
+ let n;
85
+ if (u) {
86
+ const m = o || [];
87
+ n = await Promise.all(
88
+ m.map(async (P) => typeof P == "string" ? w && I ? await I(P) : { id: xe(), label: P } : P)
83
89
  );
84
90
  } else
85
- o === null ? s = [] : typeof o == "string" ? x && w ? s = [await w(o)] : s = [{ id: xe(), label: o }] : s = [o];
86
- B(s), b?.(s);
87
- }, R = O.useMemo(() => {
88
- const t = d.filter((o) => !o.disabled);
91
+ o === null ? n = [] : typeof o == "string" ? w && I ? n = [await I(o)] : n = [{ id: xe(), label: o }] : n = [o];
92
+ const a = /* @__PURE__ */ new Set(), b = /* @__PURE__ */ new Set();
93
+ n = n.filter((m) => {
94
+ const P = m.label.toLowerCase();
95
+ return a.has(m.id) || b.has(P) ? !1 : (a.add(m.id), b.add(P), !0);
96
+ }), z(n), x?.(n);
97
+ }, R = M.useMemo(() => {
98
+ const t = p.filter((o) => !o.disabled);
89
99
  return t.length > 0 && t.every(
90
- (o) => L.some((s) => s.id === o.id)
100
+ (o) => k.some((n) => n.id === o.id)
91
101
  );
92
- }, [d, L]), v = O.useCallback(() => {
102
+ }, [p, k]), v = M.useCallback(() => {
93
103
  if (R)
94
- B([]), b?.([]);
104
+ z([]), x?.([]);
95
105
  else {
96
- const t = d.filter((o) => !o.disabled);
97
- B(t), b?.(t);
106
+ const t = p.filter((o) => !o.disabled);
107
+ z(t), x?.(t);
98
108
  }
99
- }, [R, d, b]), h = O.useCallback(async () => {
100
- if (!l || !w) return;
101
- const t = await w(y), o = p ? [...L, t] : [t];
102
- B(o), b?.(o), $("");
103
- }, [l, w, y, p, L, b]), E = (t) => /* @__PURE__ */ e(
109
+ }, [R, p, x]), h = M.useCallback(async () => {
110
+ if (!c || !I) return;
111
+ const t = await I(y), o = u ? [...k, t] : [t];
112
+ z(o), x?.(o), U("");
113
+ }, [c, I, y, u, k, x]), W = (t) => /* @__PURE__ */ e(
104
114
  Ee,
105
115
  {
106
116
  ...t,
107
- label: G,
108
- placeholder: L.length === 0 ? X : void 0,
109
- error: K,
110
- helperText: K ? te : a,
111
- size: W
117
+ label: q,
118
+ placeholder: k.length === 0 ? Y : void 0,
119
+ error: G,
120
+ helperText: G ? oe : l,
121
+ size: j
112
122
  }
113
123
  ), F = (t, o) => {
114
- const s = o;
115
- return (Array.isArray(t) ? t : []).map((m, z) => {
116
- const fe = s({ index: z });
117
- return T ? T(m, fe.onDelete) : /* @__PURE__ */ Oe(
124
+ const n = o;
125
+ return (Array.isArray(t) ? t : []).map((b, m) => {
126
+ const P = n({ index: m });
127
+ return $ ? $(b, P.onDelete) : /* @__PURE__ */ Re(
118
128
  Ie,
119
129
  {
120
- ...fe,
121
- key: typeof m == "object" ? m.id : z,
122
- label: typeof m == "object" ? m.label : String(m),
123
- size: W,
130
+ ...P,
131
+ key: typeof b == "object" ? b.id : m,
132
+ label: typeof b == "object" ? b.label : String(b),
133
+ size: j,
124
134
  deleteIcon: /* @__PURE__ */ e(be, { fontSize: "small" }),
125
135
  sx: {
126
136
  maxWidth: 150,
@@ -132,36 +142,36 @@ const xe = () => `new-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
132
142
  }
133
143
  );
134
144
  });
135
- }, i = O.useCallback(
145
+ }, i = M.useCallback(
136
146
  (t) => {
137
- const { children: o, ...s } = t;
138
- return /* @__PURE__ */ f(de, { ...s, elevation: 8, children: [
139
- p && A && /* @__PURE__ */ f(
140
- C,
147
+ const { children: o, ...n } = t;
148
+ return /* @__PURE__ */ f(pe, { ...n, elevation: 8, children: [
149
+ u && E && /* @__PURE__ */ f(
150
+ L,
141
151
  {
142
- onMouseDown: (u) => {
143
- u.preventDefault(), u.stopPropagation();
152
+ onMouseDown: (a) => {
153
+ a.preventDefault(), a.stopPropagation();
144
154
  },
145
- onClick: (u) => {
146
- u.preventDefault(), u.stopPropagation(), v();
155
+ onClick: (a) => {
156
+ a.preventDefault(), a.stopPropagation(), v();
147
157
  },
148
158
  children: [
149
159
  /* @__PURE__ */ f(
150
- pe,
160
+ ue,
151
161
  {
152
162
  dense: !0,
153
163
  sx: {
154
164
  cursor: "pointer",
155
165
  "&:hover": {
156
- backgroundColor: he(Q.palette.primary.main, 0.08)
166
+ backgroundColor: he(X.palette.primary.main, 0.08)
157
167
  }
158
168
  },
159
169
  children: [
160
- j && /* @__PURE__ */ e(re, { sx: { minWidth: 36, pointerEvents: "none" }, children: /* @__PURE__ */ e(
170
+ T && /* @__PURE__ */ e(te, { sx: { minWidth: 36, pointerEvents: "none" }, children: /* @__PURE__ */ e(
161
171
  ge,
162
172
  {
163
173
  icon: /* @__PURE__ */ e(
164
- C,
174
+ L,
165
175
  {
166
176
  sx: {
167
177
  width: 18,
@@ -174,7 +184,7 @@ const xe = () => `new-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
174
184
  }
175
185
  ),
176
186
  checkedIcon: /* @__PURE__ */ e(
177
- C,
187
+ L,
178
188
  {
179
189
  sx: {
180
190
  width: 18,
@@ -188,7 +198,7 @@ const xe = () => `new-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
188
198
  justifyContent: "center"
189
199
  },
190
200
  children: /* @__PURE__ */ e(
191
- le,
201
+ ce,
192
202
  {
193
203
  sx: {
194
204
  width: 14,
@@ -206,9 +216,9 @@ const xe = () => `new-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
206
216
  }
207
217
  ) }),
208
218
  /* @__PURE__ */ e(
209
- ue,
219
+ me,
210
220
  {
211
- primary: R ? "Deselect All" : ee,
221
+ primary: R ? "Deselect All" : re,
212
222
  slotProps: { primary: {
213
223
  variant: "body2",
214
224
  sx: { fontWeight: 500 }
@@ -223,13 +233,16 @@ const xe = () => `new-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
223
233
  }
224
234
  ),
225
235
  o,
226
- l && /* @__PURE__ */ f(Re, { children: [
236
+ c && /* @__PURE__ */ f(Se, { children: [
227
237
  /* @__PURE__ */ e(ye, {}),
228
238
  /* @__PURE__ */ e(
229
- me,
239
+ fe,
230
240
  {
231
241
  fullWidth: !0,
232
242
  startIcon: /* @__PURE__ */ e(Ue, {}),
243
+ onMouseDown: (a) => {
244
+ a.preventDefault();
245
+ },
233
246
  onClick: h,
234
247
  sx: {
235
248
  justifyContent: "flex-start",
@@ -239,109 +252,109 @@ const xe = () => `new-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
239
252
  color: "primary.main",
240
253
  borderRadius: 0,
241
254
  "&:hover": {
242
- backgroundColor: he(Q.palette.primary.main, 0.08)
255
+ backgroundColor: he(X.palette.primary.main, 0.08)
243
256
  }
244
257
  },
245
- children: M.replace("{value}", y)
258
+ children: B.replace("{value}", y)
246
259
  }
247
260
  )
248
261
  ] })
249
262
  ] });
250
263
  },
251
- [l, M, y, Q.palette.primary.main, h, p, A, j, v, R, ee]
252
- ), Le = d;
264
+ [c, B, y, X.palette.primary.main, h, u, E, T, v, R, re]
265
+ ), Le = p;
253
266
  return /* @__PURE__ */ e(
254
267
  Ae,
255
268
  {
256
269
  ref: ie,
257
- className: ne,
258
- sx: { width: U ? "100%" : 300, ...se },
259
- multiple: p,
270
+ className: se,
271
+ sx: { width: V ? "100%" : 300, ...ae },
272
+ multiple: u,
260
273
  options: Le,
261
- value: p ? L : L[0] || null,
262
- onChange: k,
274
+ value: u ? k : k[0] || null,
275
+ onChange: D,
263
276
  inputValue: y,
264
- onInputChange: (t, o) => $(o),
277
+ onInputChange: (t, o) => U(o),
265
278
  getOptionLabel: (t) => typeof t == "string" ? t : t.label,
266
279
  isOptionEqualToValue: (t, o) => t.id === o.id,
267
280
  getOptionDisabled: (t) => typeof t == "object" && t.disabled === !0,
268
- groupBy: Z ? (t) => t.group || "" : void 0,
281
+ groupBy: ee ? (t) => t.group || "" : void 0,
269
282
  filterOptions: r,
270
- renderInput: E,
271
- renderValue: p ? F : void 0,
272
- renderOption: (t, o, { selected: s }) => {
273
- const { key: u, ...m } = t, z = o;
274
- return J ? /* @__PURE__ */ e("li", { ...m, children: J(z, { selected: s }) }, u) : /* @__PURE__ */ f(pe, { ...m, dense: !0, children: [
275
- p && j && /* @__PURE__ */ e(re, { sx: { minWidth: 36 }, children: /* @__PURE__ */ e(
283
+ renderInput: W,
284
+ renderValue: u ? F : void 0,
285
+ renderOption: (t, o, { selected: n }) => {
286
+ const { key: a, ...b } = t, m = o;
287
+ return Q ? /* @__PURE__ */ e("li", { ...b, children: Q(m, { selected: n }) }, a) : /* @__PURE__ */ f(ue, { ...b, dense: !0, children: [
288
+ u && T && /* @__PURE__ */ e(te, { sx: { minWidth: 36 }, children: /* @__PURE__ */ e(
276
289
  ge,
277
290
  {
278
- icon: /* @__PURE__ */ e(C, { sx: { width: 18, height: 18, border: "2px solid", borderColor: "action.active", borderRadius: 0.5, backgroundColor: "transparent" } }),
279
- checkedIcon: /* @__PURE__ */ e(C, { sx: { width: 18, height: 18, border: "2px solid", borderColor: "primary.main", borderRadius: 0.5, backgroundColor: "primary.main", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ e(le, { sx: { width: 14, height: 14, color: "primary.contrastText" } }) }),
280
- checked: s,
291
+ icon: /* @__PURE__ */ e(L, { sx: { width: 18, height: 18, border: "2px solid", borderColor: "action.active", borderRadius: 0.5, backgroundColor: "transparent" } }),
292
+ checkedIcon: /* @__PURE__ */ e(L, { sx: { width: 18, height: 18, border: "2px solid", borderColor: "primary.main", borderRadius: 0.5, backgroundColor: "primary.main", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ e(ce, { sx: { width: 14, height: 14, color: "primary.contrastText" } }) }),
293
+ checked: n,
281
294
  size: "small"
282
295
  }
283
296
  ) }),
284
- z.icon && /* @__PURE__ */ e(re, { sx: { minWidth: 36 }, children: z.icon }),
297
+ m.icon && /* @__PURE__ */ e(te, { sx: { minWidth: 36 }, children: m.icon }),
285
298
  /* @__PURE__ */ e(
286
- ue,
299
+ me,
287
300
  {
288
- primary: z.label,
289
- secondary: z.secondary,
301
+ primary: m.label,
302
+ secondary: m.secondary,
290
303
  slotProps: { primary: { variant: "body2" }, secondary: { variant: "caption" } }
291
304
  }
292
305
  ),
293
- !p && s && /* @__PURE__ */ e(le, { sx: { ml: 1, color: "primary.main" }, fontSize: "small" })
294
- ] }, u);
306
+ !u && n && /* @__PURE__ */ e(ce, { sx: { ml: 1, color: "primary.main" }, fontSize: "small" })
307
+ ] }, a);
295
308
  },
296
309
  slots: {
297
- paper: x || p && A ? i : de,
310
+ paper: w || u && E ? i : pe,
298
311
  popper: Je
299
312
  },
300
- limitTags: q,
301
- disabled: Y,
302
- loading: V,
303
- noOptionsText: l ? /* @__PURE__ */ e(_, { variant: "body2", color: "text.secondary", children: "Press Enter or click below to create" }) : N,
304
- freeSolo: g || x,
305
- autoHighlight: I,
306
- clearOnEscape: oe,
307
- disableCloseOnSelect: p,
308
- slotProps: { chip: { size: W, deleteIcon: /* @__PURE__ */ e(be, { fontSize: "small" }) } }
313
+ limitTags: N,
314
+ disabled: Z,
315
+ loading: K,
316
+ noOptionsText: c ? /* @__PURE__ */ e(_, { variant: "body2", color: "text.secondary", children: "Press Enter or click below to create" }) : H,
317
+ freeSolo: g || w,
318
+ autoHighlight: C,
319
+ clearOnEscape: ne,
320
+ disableCloseOnSelect: u,
321
+ slotProps: { chip: { size: j, deleteIcon: /* @__PURE__ */ e(be, { fontSize: "small" }) } }
309
322
  }
310
323
  );
311
- }), De = (c) => {
312
- if (c === 0) return "0 Bytes";
313
- const d = 1024, n = ["Bytes", "KB", "MB", "GB"], D = Math.floor(Math.log(c) / Math.log(d));
314
- return parseFloat((c / Math.pow(d, D)).toFixed(2)) + " " + n[D];
315
- }, Pe = (c) => c.startsWith("image/") ? /* @__PURE__ */ e(qe, {}) : c.startsWith("video/") ? /* @__PURE__ */ e(Ne, {}) : c === "application/pdf" ? /* @__PURE__ */ e(Ke, {}) : c.includes("document") || c.includes("text") ? /* @__PURE__ */ e(He, {}) : /* @__PURE__ */ e(Ve, {}), Qe = () => `file-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, ur = Fe.forwardRef(function({
316
- variant: d = "dropzone",
317
- accept: n,
318
- multiple: D = !1,
319
- maxSize: b,
320
- maxFiles: x,
321
- files: w,
322
- onFilesChange: M,
323
- onFileSelect: p,
324
- onFileRemove: X,
325
- onUpload: G,
326
- disabled: a = !1,
327
- helperText: K,
328
- error: te,
329
- showFileList: Y = !0,
330
- size: U = "medium",
331
- sx: W
332
- }, q) {
333
- const [j, Z] = ae([]), [V, N] = ae(!1), [H, J] = ae(null), T = Se(null), g = w ?? j, I = S((r) => {
334
- typeof r == "function" ? M ? M(r(w ?? j)) : Z(r) : M ? M(r) : Z(r);
335
- }, [w, j, M]), oe = (r) => b && r.size > b ? `File "${r.name}" exceeds maximum size of ${De(b)}` : x && g.length >= x ? `Maximum ${x} files allowed` : null, A = S(
324
+ }), De = (d) => {
325
+ if (d === 0) return "0 Bytes";
326
+ const p = 1024, s = ["Bytes", "KB", "MB", "GB"], S = Math.floor(Math.log(d) / Math.log(p));
327
+ return parseFloat((d / Math.pow(p, S)).toFixed(2)) + " " + s[S];
328
+ }, Pe = (d) => d.startsWith("image/") ? /* @__PURE__ */ e(Ge, {}) : d.startsWith("video/") ? /* @__PURE__ */ e(Ne, {}) : d === "application/pdf" ? /* @__PURE__ */ e(qe, {}) : d.includes("document") || d.includes("text") ? /* @__PURE__ */ e(He, {}) : /* @__PURE__ */ e(Ve, {}), Qe = () => `file-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, ur = Oe.forwardRef(function({
329
+ variant: p = "dropzone",
330
+ accept: s,
331
+ multiple: S = !1,
332
+ maxSize: x,
333
+ maxFiles: w,
334
+ files: I,
335
+ onFilesChange: B,
336
+ onFileSelect: u,
337
+ onFileRemove: Y,
338
+ onUpload: q,
339
+ disabled: l = !1,
340
+ helperText: G,
341
+ error: oe,
342
+ showFileList: Z = !0,
343
+ size: V = "medium",
344
+ sx: j
345
+ }, N) {
346
+ const [T, ee] = le([]), [K, H] = le(!1), [J, Q] = le(null), $ = Fe(null), g = I ?? T, C = A((r) => {
347
+ typeof r == "function" ? B ? B(r(I ?? T)) : ee(r) : B ? B(r) : ee(r);
348
+ }, [I, T, B]), ne = (r) => x && r.size > x ? `File "${r.name}" exceeds maximum size of ${De(x)}` : w && g.length >= w ? `Maximum ${w} files allowed` : null, E = A(
336
349
  async (r) => {
337
- const l = Array.from(r), k = [], R = [];
338
- for (const v of l) {
339
- const h = oe(v);
350
+ const c = Array.from(r), D = [], R = [];
351
+ for (const v of c) {
352
+ const h = ne(v);
340
353
  if (h) {
341
354
  R.push(h);
342
355
  continue;
343
356
  }
344
- const E = {
357
+ const W = {
345
358
  id: Qe(),
346
359
  file: v,
347
360
  name: v.name,
@@ -351,166 +364,166 @@ const xe = () => `new-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
351
364
  status: "pending",
352
365
  preview: v.type.startsWith("image/") ? URL.createObjectURL(v) : void 0
353
366
  };
354
- k.push(E);
367
+ D.push(W);
355
368
  }
356
- if (R.length > 0 ? J(R[0]) : J(null), k.length > 0) {
357
- const v = D ? [...g, ...k] : k;
358
- if (I(v), p?.(k.map((h) => h.file)), G)
359
- for (const h of k)
369
+ if (R.length > 0 ? Q(R[0]) : Q(null), D.length > 0) {
370
+ const v = S ? [...g, ...D] : D;
371
+ if (C(v), u?.(D.map((h) => h.file)), q)
372
+ for (const h of D)
360
373
  try {
361
- I(
374
+ C(
362
375
  (F) => F.map(
363
376
  (i) => i.id === h.id ? { ...i, status: "uploading" } : i
364
377
  )
365
378
  );
366
- const E = setInterval(() => {
367
- I(
379
+ const W = setInterval(() => {
380
+ C(
368
381
  (F) => F.map(
369
382
  (i) => i.id === h.id && i.progress < 90 ? { ...i, progress: i.progress + 10 } : i
370
383
  )
371
384
  );
372
385
  }, 200);
373
- await G(h.file), clearInterval(E), I(
386
+ await q(h.file), clearInterval(W), C(
374
387
  (F) => F.map(
375
388
  (i) => i.id === h.id ? { ...i, status: "complete", progress: 100 } : i
376
389
  )
377
390
  );
378
- } catch (E) {
379
- I(
391
+ } catch (W) {
392
+ C(
380
393
  (F) => F.map(
381
394
  (i) => i.id === h.id ? {
382
395
  ...i,
383
396
  status: "error",
384
- error: E instanceof Error ? E.message : "Upload failed"
397
+ error: W instanceof Error ? W.message : "Upload failed"
385
398
  } : i
386
399
  )
387
400
  );
388
401
  }
389
402
  }
390
403
  },
391
- [g, I, b, x, D, p, G]
392
- ), ee = S((r) => {
393
- r.preventDefault(), r.stopPropagation(), a || N(!0);
394
- }, [a]), ne = S((r) => {
395
- r.preventDefault(), r.stopPropagation(), N(!1);
396
- }, []), se = S((r) => {
404
+ [g, C, x, w, S, u, q]
405
+ ), re = A((r) => {
406
+ r.preventDefault(), r.stopPropagation(), l || H(!0);
407
+ }, [l]), se = A((r) => {
408
+ r.preventDefault(), r.stopPropagation(), H(!1);
409
+ }, []), ae = A((r) => {
397
410
  r.preventDefault(), r.stopPropagation();
398
- }, []), ie = S(
411
+ }, []), ie = A(
399
412
  (r) => {
400
- if (r.preventDefault(), r.stopPropagation(), N(!1), a) return;
401
- const l = r.dataTransfer.files;
402
- l.length > 0 && A(l);
413
+ if (r.preventDefault(), r.stopPropagation(), H(!1), l) return;
414
+ const c = r.dataTransfer.files;
415
+ c.length > 0 && E(c);
403
416
  },
404
- [a, A]
405
- ), Q = S(
417
+ [l, E]
418
+ ), X = A(
406
419
  (r) => {
407
- const l = r.target.files;
408
- l && l.length > 0 && A(l), T.current && (T.current.value = "");
420
+ const c = r.target.files;
421
+ c && c.length > 0 && E(c), $.current && ($.current.value = "");
409
422
  },
410
- [A]
411
- ), y = S(
423
+ [E]
424
+ ), y = A(
412
425
  (r) => {
413
426
  r.preview && URL.revokeObjectURL(r.preview);
414
- const l = g.filter((k) => k.id !== r.id);
415
- I(l), X?.(r);
427
+ const c = g.filter((D) => D.id !== r.id);
428
+ C(c), Y?.(r);
416
429
  },
417
- [g, I, X]
418
- ), $ = () => {
419
- T.current?.click();
420
- }, P = te || H, B = /* @__PURE__ */ e(
430
+ [g, C, Y]
431
+ ), U = () => {
432
+ $.current?.click();
433
+ }, O = oe || J, z = /* @__PURE__ */ e(
421
434
  "input",
422
435
  {
423
- ref: T,
436
+ ref: $,
424
437
  type: "file",
425
- accept: n,
426
- multiple: D,
427
- onChange: Q,
438
+ accept: s,
439
+ multiple: S,
440
+ onChange: X,
428
441
  style: { display: "none" },
429
- disabled: a
442
+ disabled: l
430
443
  }
431
- ), L = S(
444
+ ), k = A(
432
445
  (r) => {
433
- (r.key === "Enter" || r.key === " ") && !a && (r.preventDefault(), $());
446
+ (r.key === "Enter" || r.key === " ") && !l && (r.preventDefault(), U());
434
447
  },
435
- [a]
448
+ [l]
436
449
  );
437
- return d === "dropzone" ? /* @__PURE__ */ f(C, { ref: q, sx: W, children: [
438
- B,
450
+ return p === "dropzone" ? /* @__PURE__ */ f(L, { ref: N, sx: j, children: [
451
+ z,
439
452
  /* @__PURE__ */ f(
440
- de,
453
+ pe,
441
454
  {
442
455
  role: "button",
443
- tabIndex: a ? -1 : 0,
444
- "aria-label": `Upload files${n ? `. Accepted formats: ${n}` : ""}. Drag and drop or press Enter to browse`,
445
- "aria-disabled": a,
446
- onDragEnter: ee,
447
- onDragLeave: ne,
448
- onDragOver: se,
456
+ tabIndex: l ? -1 : 0,
457
+ "aria-label": `Upload files${s ? `. Accepted formats: ${s}` : ""}. Drag and drop or press Enter to browse`,
458
+ "aria-disabled": l,
459
+ onDragEnter: re,
460
+ onDragLeave: se,
461
+ onDragOver: ae,
449
462
  onDrop: ie,
450
- onClick: $,
451
- onKeyDown: L,
463
+ onClick: U,
464
+ onKeyDown: k,
452
465
  sx: {
453
- p: U === "small" ? 3 : 4,
466
+ p: V === "small" ? 3 : 4,
454
467
  border: "2px dashed",
455
- borderColor: P ? "error.main" : V ? "primary.main" : "divider",
468
+ borderColor: O ? "error.main" : K ? "primary.main" : "divider",
456
469
  borderRadius: Ce.borders.radiusPx.lg,
457
- bgcolor: V ? "action.hover" : a ? "action.disabledBackground" : "background.paper",
470
+ bgcolor: K ? "action.hover" : l ? "action.disabledBackground" : "background.paper",
458
471
  textAlign: "center",
459
- cursor: a ? "not-allowed" : "pointer",
472
+ cursor: l ? "not-allowed" : "pointer",
460
473
  transition: "all 0.2s ease",
461
474
  "&:hover": {
462
- bgcolor: a ? void 0 : "action.hover",
463
- borderColor: a ? void 0 : "primary.main"
475
+ bgcolor: l ? void 0 : "action.hover",
476
+ borderColor: l ? void 0 : "primary.main"
464
477
  }
465
478
  },
466
479
  children: [
467
480
  /* @__PURE__ */ e(
468
- ce,
481
+ de,
469
482
  {
470
483
  sx: {
471
- fontSize: U === "small" ? 40 : 56,
472
- color: V ? "primary.main" : "action.active",
484
+ fontSize: V === "small" ? 40 : 56,
485
+ color: K ? "primary.main" : "action.active",
473
486
  mb: 2
474
487
  }
475
488
  }
476
489
  ),
477
- /* @__PURE__ */ e(_, { variant: U === "small" ? "body1" : "h6", gutterBottom: !0, children: V ? "Drop files here" : "Drag & drop files here" }),
490
+ /* @__PURE__ */ e(_, { variant: V === "small" ? "body1" : "h6", gutterBottom: !0, children: K ? "Drop files here" : "Drag & drop files here" }),
478
491
  /* @__PURE__ */ e(_, { variant: "body2", color: "text.secondary", gutterBottom: !0, children: "or click to browse" }),
479
- K && /* @__PURE__ */ e(_, { variant: "caption", color: "text.secondary", children: K })
492
+ G && /* @__PURE__ */ e(_, { variant: "caption", color: "text.secondary", children: G })
480
493
  ]
481
494
  }
482
495
  ),
483
- P && /* @__PURE__ */ e(ve, { severity: "error", sx: { mt: 2 }, children: P }),
484
- Y && g.length > 0 && /* @__PURE__ */ e(we, { files: g, onRemove: y })
485
- ] }) : d === "button" ? /* @__PURE__ */ f(C, { ref: q, sx: W, children: [
486
- B,
496
+ O && /* @__PURE__ */ e(ve, { severity: "error", sx: { mt: 2 }, children: O }),
497
+ Z && g.length > 0 && /* @__PURE__ */ e(we, { files: g, onRemove: y })
498
+ ] }) : p === "button" ? /* @__PURE__ */ f(L, { ref: N, sx: j, children: [
499
+ z,
487
500
  /* @__PURE__ */ f(
488
- me,
501
+ fe,
489
502
  {
490
503
  variant: "contained",
491
- startIcon: /* @__PURE__ */ e(ce, {}),
492
- onClick: $,
493
- disabled: a,
494
- size: U,
504
+ startIcon: /* @__PURE__ */ e(de, {}),
505
+ onClick: U,
506
+ disabled: l,
507
+ size: V,
495
508
  children: [
496
509
  "Upload ",
497
- D ? "Files" : "File"
510
+ S ? "Files" : "File"
498
511
  ]
499
512
  }
500
513
  ),
501
- P && /* @__PURE__ */ e(ve, { severity: "error", sx: { mt: 2 }, children: P }),
502
- Y && g.length > 0 && /* @__PURE__ */ e(we, { files: g, onRemove: y })
503
- ] }) : /* @__PURE__ */ f(C, { ref: q, sx: W, children: [
504
- B,
514
+ O && /* @__PURE__ */ e(ve, { severity: "error", sx: { mt: 2 }, children: O }),
515
+ Z && g.length > 0 && /* @__PURE__ */ e(we, { files: g, onRemove: y })
516
+ ] }) : /* @__PURE__ */ f(L, { ref: N, sx: j, children: [
517
+ z,
505
518
  /* @__PURE__ */ f(ze, { direction: "row", spacing: 1, useFlexGap: !0, sx: { alignItems: "center", flexWrap: "wrap" }, children: [
506
519
  /* @__PURE__ */ e(
507
- me,
520
+ fe,
508
521
  {
509
522
  variant: "outlined",
510
523
  size: "small",
511
- startIcon: /* @__PURE__ */ e(ce, {}),
512
- onClick: $,
513
- disabled: a,
524
+ startIcon: /* @__PURE__ */ e(de, {}),
525
+ onClick: U,
526
+ disabled: l,
514
527
  children: "Browse"
515
528
  }
516
529
  ),
@@ -533,29 +546,29 @@ const xe = () => `new-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
533
546
  r.id
534
547
  ))
535
548
  ] }),
536
- P && /* @__PURE__ */ e(_, { variant: "caption", color: "error", sx: { mt: 0.5, display: "block" }, children: P })
549
+ O && /* @__PURE__ */ e(_, { variant: "caption", color: "error", sx: { mt: 0.5, display: "block" }, children: O })
537
550
  ] });
538
- }), we = ({ files: c, onRemove: d }) => /* @__PURE__ */ e(We, { dense: !0, sx: { mt: 2 }, children: c.map((n) => /* @__PURE__ */ f(
539
- pe,
551
+ }), we = ({ files: d, onRemove: p }) => /* @__PURE__ */ e(We, { dense: !0, sx: { mt: 2 }, children: d.map((s) => /* @__PURE__ */ f(
552
+ ue,
540
553
  {
541
554
  sx: {
542
555
  bgcolor: "background.paper",
543
556
  borderRadius: Ce.borders.radiusPx.md,
544
557
  mb: 1,
545
558
  border: "1px solid",
546
- borderColor: n.status === "error" ? "error.light" : "divider"
559
+ borderColor: s.status === "error" ? "error.light" : "divider"
547
560
  },
548
561
  children: [
549
- /* @__PURE__ */ e(re, { children: n.status === "complete" ? /* @__PURE__ */ e(ke, { color: "success" }) : n.status === "error" ? /* @__PURE__ */ e(Ge, { color: "error" }) : Pe(n.type) }),
562
+ /* @__PURE__ */ e(te, { children: s.status === "complete" ? /* @__PURE__ */ e(ke, { color: "success" }) : s.status === "error" ? /* @__PURE__ */ e(_e, { color: "error" }) : Pe(s.type) }),
550
563
  /* @__PURE__ */ e(
551
- ue,
564
+ me,
552
565
  {
553
- primary: n.name,
554
- secondary: /* @__PURE__ */ f(C, { component: "span", children: [
555
- De(n.size),
556
- n.error && /* @__PURE__ */ f(_, { component: "span", color: "error", sx: { ml: 1 }, children: [
566
+ primary: s.name,
567
+ secondary: /* @__PURE__ */ f(L, { component: "span", children: [
568
+ De(s.size),
569
+ s.error && /* @__PURE__ */ f(_, { component: "span", color: "error", sx: { ml: 1 }, children: [
557
570
  "• ",
558
- n.error
571
+ s.error
559
572
  ] })
560
573
  ] }),
561
574
  sx: {
@@ -567,11 +580,11 @@ const xe = () => `new-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
567
580
  }
568
581
  }
569
582
  ),
570
- n.status === "uploading" && /* @__PURE__ */ e(C, { sx: { width: 100, mr: 2 }, children: /* @__PURE__ */ e(je, { variant: "determinate", value: n.progress }) }),
571
- /* @__PURE__ */ e(Te, { children: /* @__PURE__ */ e($e, { edge: "end", onClick: () => d(n), size: "small", children: /* @__PURE__ */ e(_e, { fontSize: "small" }) }) })
583
+ s.status === "uploading" && /* @__PURE__ */ e(L, { sx: { width: 100, mr: 2 }, children: /* @__PURE__ */ e(je, { variant: "determinate", value: s.progress }) }),
584
+ /* @__PURE__ */ e(Te, { children: /* @__PURE__ */ e($e, { edge: "end", onClick: () => p(s), size: "small", children: /* @__PURE__ */ e(Ke, { fontSize: "small" }) }) })
572
585
  ]
573
586
  },
574
- n.id
587
+ s.id
575
588
  )) });
576
589
  export {
577
590
  pr as C,