@mci-ui/mci-ui 0.0.93 → 0.0.95

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.
Files changed (43) hide show
  1. package/dist/assets/png/empty.png.js +4 -0
  2. package/dist/index.css +1 -1
  3. package/dist/index.js +54 -50
  4. package/dist/shared/lib/uploadLanguage.js +6 -3
  5. package/dist/shared/ui/MciModal/MciModal.js +1 -1
  6. package/dist/shared/ui/mciAccordion/MciAccordion.js +4 -4
  7. package/dist/shared/ui/mciButton/MciButton.js +12 -10
  8. package/dist/shared/ui/mciCollapse/MciCollapse.js +1 -1
  9. package/dist/shared/ui/mciDrawer/MciDrawer.js +1 -1
  10. package/dist/shared/ui/mciEmpty/MciEmpty.js +41 -0
  11. package/dist/shared/ui/mciInput/MciInput.js +32 -32
  12. package/dist/shared/ui/mciPagination/MciPagination.js +32 -32
  13. package/dist/shared/ui/mciPhone/MciPhone.js +23 -23
  14. package/dist/shared/ui/mciPicker/MciPicker.js +2 -2
  15. package/dist/shared/ui/mciTable/MciTable.js +317 -165
  16. package/dist/shared/ui/mciTable/MciTableClamp2.js +5 -5
  17. package/dist/shared/ui/mciTabs/FilledTabs.js +38 -36
  18. package/dist/shared/ui/mciTabs/OutlinedTabs.js +28 -24
  19. package/dist/shared/ui/mciTabs/TabCountBadge.js +19 -0
  20. package/dist/shared/ui/mciTag/MciTag.js +17 -17
  21. package/dist/shared/ui/mciTextarea/MciTextarea.js +5 -5
  22. package/dist/shared/ui/mciTimePicker/MciTimePicker.js +368 -217
  23. package/dist/shared/ui/mciUpload/MciUpload.js +102 -352
  24. package/dist/shared/ui/mciUpload/MciUploadButton.js +143 -0
  25. package/dist/shared/ui/mciUpload/MciUploadFileList.js +167 -0
  26. package/dist/shared/ui/mciUpload/mci-upload.theme.js +103 -0
  27. package/dist/shared/ui/mciUpload/mci-upload.utils.js +90 -41
  28. package/dist/shared/ui/mciUpload/useMciUpload.js +183 -0
  29. package/dist/types/index.d.ts +4 -0
  30. package/dist/types/shared/lib/uploadLanguage.d.ts +2 -0
  31. package/dist/types/shared/types/ui/empty.types.d.ts +11 -0
  32. package/dist/types/shared/types/ui/index.d.ts +2 -1
  33. package/dist/types/shared/types/ui/tabs.types.d.ts +1 -0
  34. package/dist/types/shared/types/ui/time-picker.types.d.ts +7 -1
  35. package/dist/types/shared/types/ui/upload.types.d.ts +25 -1
  36. package/dist/types/shared/ui/mciEmpty/MciEmpty.d.ts +2 -0
  37. package/dist/types/shared/ui/mciTabs/TabCountBadge.d.ts +5 -0
  38. package/dist/types/shared/ui/mciUpload/MciUploadButton.d.ts +4 -0
  39. package/dist/types/shared/ui/mciUpload/MciUploadFileList.d.ts +18 -0
  40. package/dist/types/shared/ui/mciUpload/mci-upload.theme.d.ts +101 -0
  41. package/dist/types/shared/ui/mciUpload/mci-upload.utils.d.ts +7 -0
  42. package/dist/types/shared/ui/mciUpload/useMciUpload.d.ts +131 -0
  43. package/package.json +1 -1
@@ -1,382 +1,132 @@
1
- import { jsxs as o, jsx as t, Fragment as k } from "react/jsx-runtime";
2
- import { Upload as le, File as oe, Star2 as se, Eye as ne } from "@solar-icons/react";
3
- import ae from "../../../assets/icons/close.svg.js";
4
- import { useState as O, useRef as C, useMemo as T, useCallback as c, useEffect as ie } from "react";
5
- import { uploadLanguages as ce } from "../../lib/uploadLanguage.js";
6
- import { cn as s } from "../../lib/utils.js";
7
- import { buildSecureAccept as de, getAllowedFormatsHint as ge, validateFileSize as ue, validateFileType as be, createPreview as pe, getFileIcon as me, formatFileSize as he } from "./mci-upload.utils.js";
8
- const xe = {
9
- blue: {
10
- dropBorder: "border-blue-200 hover:border-blue-300",
11
- dropBg: "bg-blue-50/40 hover:bg-blue-50/60",
12
- dropActive: "border-blue-600 bg-blue-50",
13
- iconWrap: "text-blue-600",
14
- title: "text-blue-600",
15
- hint: "text-slate-500",
16
- progressFill: "bg-blue-600",
17
- fileIconImg: "bg-blue-50 text-blue-600",
18
- fileIconDoc: "bg-green-50 text-green-600"
19
- },
20
- yellow: {
21
- dropBorder: "border-yellow-300 hover:border-yellow-400",
22
- dropBg: "bg-yellow-50/60 hover:bg-yellow-100/60",
23
- dropActive: "border-yellow-500 bg-yellow-100/80",
24
- iconWrap: "text-yellow-600",
25
- title: "text-yellow-700",
26
- hint: "text-slate-500",
27
- progressFill: "bg-yellow-500",
28
- fileIconImg: "bg-blue-50 text-blue-600",
29
- fileIconDoc: "bg-green-50 text-green-600"
30
- },
31
- orange: {
32
- dropBorder: "border-orange-200 hover:border-orange-300",
33
- dropBg: "bg-orange-50/40 hover:bg-orange-50/60",
34
- dropActive: "border-orange-600 bg-orange-50",
35
- iconWrap: "text-orange-600",
36
- title: "text-orange-600",
37
- hint: "text-slate-500",
38
- progressFill: "bg-orange-600",
39
- fileIconImg: "bg-orange-50 text-orange-600",
40
- fileIconDoc: "bg-green-50 text-green-600"
41
- }
42
- }, fe = {
43
- blue: {
44
- dropBorder: "border-blue-800 hover:border-blue-700",
45
- dropBg: "bg-blue-950/40 hover:bg-blue-950/60",
46
- dropActive: "border-blue-500 bg-blue-950/60",
47
- iconWrap: "text-blue-400",
48
- title: "text-blue-400",
49
- hint: "text-slate-400",
50
- progressFill: "bg-blue-500",
51
- fileIconImg: "bg-blue-950 text-blue-400",
52
- fileIconDoc: "bg-green-950 text-green-400"
53
- },
54
- yellow: {
55
- dropBorder: "border-yellow-700 hover:border-yellow-600",
56
- dropBg: "bg-yellow-950/45 hover:bg-yellow-950/65",
57
- dropActive: "border-yellow-500 bg-yellow-950/70",
58
- iconWrap: "text-yellow-300",
59
- title: "text-yellow-300",
60
- hint: "text-slate-400",
61
- progressFill: "bg-yellow-400",
62
- fileIconImg: "bg-blue-950 text-blue-400",
63
- fileIconDoc: "bg-green-950 text-green-400"
64
- },
65
- orange: {
66
- dropBorder: "border-orange-800 hover:border-orange-700",
67
- dropBg: "bg-orange-950/40 hover:bg-orange-950/60",
68
- dropActive: "border-orange-600 bg-orange-950/60",
69
- iconWrap: "text-orange-400",
70
- title: "text-orange-400",
71
- hint: "text-slate-400",
72
- progressFill: "bg-orange-600",
73
- fileIconImg: "bg-orange-950 text-orange-400",
74
- fileIconDoc: "bg-green-950 text-green-400"
75
- }
76
- }, Be = ({
77
- multiple: y = !1,
78
- accept: h = "*/*",
79
- maxSize: N = 10,
80
- maxFiles: D = 5,
81
- disabled: g = !1,
82
- label: W,
83
- required: H = !1,
84
- error: F,
85
- className: z,
86
- onFilesChange: x,
87
- onUpload: w,
88
- showPreview: _ = !0,
89
- locale: q = "uz",
90
- showFileTypeIcon: K = !0,
91
- variant: R = "orange",
92
- customValidator: U,
93
- darkMode: i = !1
1
+ import { jsxs as o, jsx as e } from "react/jsx-runtime";
2
+ import { Upload as k } from "@solar-icons/react";
3
+ import { cn as l } from "../../lib/utils.js";
4
+ import { MciUploadFileList as E } from "./MciUploadFileList.js";
5
+ import { useMciUpload as G } from "./useMciUpload.js";
6
+ const X = ({
7
+ multiple: i = !1,
8
+ accept: p = "*/*",
9
+ maxSize: c = 10,
10
+ maxFiles: d = 5,
11
+ disabled: r = !1,
12
+ label: m,
13
+ required: f = !1,
14
+ error: a,
15
+ className: h,
16
+ onFilesChange: u,
17
+ onUpload: x,
18
+ defaultValue: g,
19
+ value: v,
20
+ onValueChange: N,
21
+ showPreview: b = !0,
22
+ locale: w = "uz",
23
+ showFileTypeIcon: D = !0,
24
+ variant: U = "orange",
25
+ customValidator: C,
26
+ darkMode: n = !1
94
27
  }) => {
95
- const [b, f] = O([]), [$, L] = O(!1), [I, P] = O(!1), A = C(null), n = ce[q], u = T(() => i ? fe[R] : xe[R], [R, i]), G = T(() => de(h), [h]), J = T(() => ge(h), [h]), v = C(/* @__PURE__ */ new Map()), B = c((e) => {
96
- const l = v.current.get(e);
97
- l && (URL.revokeObjectURL(l), v.current.delete(e));
98
- }, []), j = c(() => {
99
- for (const e of v.current.values())
100
- URL.revokeObjectURL(e);
101
- v.current.clear();
102
- }, []);
103
- ie(() => () => {
104
- j();
105
- }, [j]);
106
- const Q = c((e) => {
107
- let l = v.current.get(e.id);
108
- l || (l = URL.createObjectURL(e.file), v.current.set(e.id, l), setTimeout(() => B(e.id), 5 * 6e4)), window.open(l, "_blank", "noopener,noreferrer");
109
- }, [B]), E = c(
110
- async (e) => {
111
- const l = Array.from(e), d = [];
112
- for (const r of l) {
113
- if (b.length + d.length >= D) {
114
- alert(n.maxFilesError(D));
115
- break;
116
- }
117
- if (!ue(r, N)) {
118
- alert(n.fileSizeError(r.name, N));
119
- continue;
120
- }
121
- const a = be(r, h);
122
- if (!a.isValid) {
123
- a.reason === "blocked" ? alert(n.blockedFileTypeError(r.name)) : alert(n.fileTypeError(r.name));
124
- continue;
125
- }
126
- if (U) {
127
- const S = U(r);
128
- if (S) {
129
- alert(S);
130
- continue;
131
- }
132
- }
133
- const p = await pe(r), m = w ? "uploading" : "success", re = w ? 0 : 100;
134
- d.push({
135
- id: Math.random().toString(36).substr(2, 9),
136
- file: r,
137
- preview: p,
138
- progress: re,
139
- status: m
140
- });
141
- }
142
- if (d.length > 0) {
143
- const r = y ? [...b, ...d] : d;
144
- if (f(r), x?.(r.map((a) => a.file)), w) {
145
- P(!0);
146
- try {
147
- const a = r.map((p, m) => ({
148
- ...p,
149
- progress: Math.min(100, (m + 1) / r.length * 100)
150
- }));
151
- f(a), await w(a), f(
152
- (p) => p.map((m) => ({
153
- ...m,
154
- status: "success",
155
- progress: 100
156
- }))
157
- );
158
- } catch (a) {
159
- f(
160
- (p) => p.map((m) => ({
161
- ...m,
162
- status: "error",
163
- error: a instanceof Error ? a.message : n.uploadFailed
164
- }))
165
- );
166
- } finally {
167
- P(!1);
168
- }
169
- }
170
- }
171
- },
172
- [
173
- b,
174
- D,
175
- U,
176
- n,
177
- h,
178
- N,
179
- y,
180
- x,
181
- w
182
- ]
183
- ), V = c(
184
- (e) => {
185
- e.preventDefault(), g || L(!0);
186
- },
187
- [g]
188
- ), X = c((e) => {
189
- e.preventDefault(), L(!1);
190
- }, []), Y = c(
191
- (e) => {
192
- if (e.preventDefault(), L(!1), g) return;
193
- const l = e.dataTransfer.files;
194
- l.length > 0 && E(l);
195
- },
196
- [g, E]
197
- ), Z = c(
198
- (e) => {
199
- const l = e.target.files;
200
- l && l.length > 0 && (E(l), A.current && (A.current.value = ""));
201
- },
202
- [E]
203
- ), M = c(
204
- (e) => {
205
- B(e), f((l) => {
206
- const d = l.filter((r) => r.id !== e);
207
- return x?.(d.map((r) => r.file)), d;
208
- });
209
- },
210
- [x, B]
211
- ), ee = c(() => {
212
- j(), f([]), x?.([]);
213
- }, [x, j]), te = c(() => {
214
- A.current?.click();
215
- }, []);
216
- return /* @__PURE__ */ o("div", { className: s("w-full", z), children: [
217
- W && /* @__PURE__ */ o(
28
+ const j = G({
29
+ multiple: i,
30
+ accept: p,
31
+ maxSize: c,
32
+ maxFiles: d,
33
+ disabled: r,
34
+ defaultValue: g,
35
+ value: v,
36
+ onFilesChange: u,
37
+ onValueChange: N,
38
+ onUpload: x,
39
+ locale: w,
40
+ variant: U,
41
+ darkMode: n,
42
+ customValidator: C
43
+ }), {
44
+ files: y,
45
+ isDragging: A,
46
+ isUploading: R,
47
+ fileInputRef: F,
48
+ t: s,
49
+ theme: t,
50
+ secureAccept: L,
51
+ allowedFormatsHint: B,
52
+ handleDragOver: H,
53
+ handleDragLeave: I,
54
+ handleDrop: O,
55
+ handleFileInput: P,
56
+ handleRemoveFile: q,
57
+ handleClearAll: z,
58
+ handleUploadClick: T,
59
+ openPreview: W
60
+ } = j;
61
+ return /* @__PURE__ */ o("div", { className: l("w-full", h), children: [
62
+ m && /* @__PURE__ */ o(
218
63
  "label",
219
64
  {
220
- className: s(
65
+ className: l(
221
66
  "mb-2 block text-base font-medium",
222
- F ? "text-red-600" : i ? "text-slate-300" : "text-slate-700"
67
+ a ? "text-red-600" : n ? "text-slate-300" : "text-slate-700"
223
68
  ),
224
69
  children: [
225
- W,
226
- H && /* @__PURE__ */ t("span", { className: "ml-1 text-extra-small text-red-600", children: "*" })
70
+ m,
71
+ f && /* @__PURE__ */ e("span", { className: "ml-1 text-extra-small text-red-600", children: "*" })
227
72
  ]
228
73
  }
229
74
  ),
230
75
  /* @__PURE__ */ o(
231
76
  "div",
232
77
  {
233
- className: s(
78
+ className: l(
234
79
  "group relative flex min-h-[180px] w-full cursor-pointer items-center justify-center rounded-2xl border border-dashed p-6 text-center transition-all duration-300",
235
- u.dropBorder,
236
- u.dropBg,
237
- $ && u.dropActive,
238
- g && "cursor-not-allowed opacity-60",
239
- F && (i ? "border-red-500 bg-red-950/30" : "border-red-600 bg-red-50/30")
80
+ t.dropBorder,
81
+ t.dropBg,
82
+ A && t.dropActive,
83
+ r && "cursor-not-allowed opacity-60",
84
+ a && (n ? "border-red-500 bg-red-950/30" : "border-red-600 bg-red-50/30")
240
85
  ),
241
- onDragOver: V,
242
- onDragLeave: X,
243
- onDrop: Y,
244
- onClick: te,
86
+ onDragOver: H,
87
+ onDragLeave: I,
88
+ onDrop: O,
89
+ onClick: T,
245
90
  children: [
246
- /* @__PURE__ */ t(
91
+ /* @__PURE__ */ e(
247
92
  "input",
248
93
  {
249
- ref: A,
94
+ ref: F,
250
95
  type: "file",
251
- multiple: y,
252
- accept: G,
253
- onChange: Z,
254
- disabled: g,
96
+ multiple: i,
97
+ accept: L,
98
+ onChange: P,
99
+ disabled: r,
255
100
  className: "hidden"
256
101
  }
257
102
  ),
258
103
  /* @__PURE__ */ o("div", { className: "flex flex-col items-center gap-3", children: [
259
- /* @__PURE__ */ t("div", { className: s("flex h-12 w-12 items-center justify-center rounded-xl", u.iconWrap), children: /* @__PURE__ */ t(le, { size: 20 }) }),
260
- /* @__PURE__ */ t("p", { className: s("text-base font-medium", u.title), children: n.dropHereTitle }),
261
- /* @__PURE__ */ t("p", { className: s("text-sm font-normal", u.hint), children: n.fileRequirements(y, D, N, J) })
104
+ /* @__PURE__ */ e("div", { className: l("flex h-12 w-12 items-center justify-center rounded-xl", t.iconWrap), children: /* @__PURE__ */ e(k, { size: 20 }) }),
105
+ /* @__PURE__ */ e("p", { className: l("text-base font-medium", t.title), children: s.dropHereTitle }),
106
+ /* @__PURE__ */ e("p", { className: l("text-sm font-normal", t.hint), children: s.fileRequirements(i, d, c, B) })
262
107
  ] })
263
108
  ]
264
109
  }
265
110
  ),
266
- b.length > 0 && /* @__PURE__ */ o("div", { className: "mt-4 space-y-3", children: [
267
- /* @__PURE__ */ o("div", { className: "flex items-center justify-between", children: [
268
- /* @__PURE__ */ o("span", { className: s("text-sm font-medium", i ? "text-slate-300" : "text-slate-700"), children: [
269
- n.selectedFiles,
270
- " (",
271
- b.length,
272
- ")"
273
- ] }),
274
- b.length > 1 && /* @__PURE__ */ t(
275
- "button",
276
- {
277
- type: "button",
278
- onClick: ee,
279
- disabled: g || I,
280
- className: "cursor-pointer text-sm font-medium text-red-600 disabled:cursor-not-allowed disabled:opacity-50",
281
- children: n.clearAll
282
- }
283
- )
284
- ] }),
285
- /* @__PURE__ */ t("div", { className: "space-y-3", children: b.map((e) => {
286
- const d = !!e.preview ? u.fileIconImg : u.fileIconDoc, r = g || I || e.status === "uploading";
287
- return /* @__PURE__ */ o(
288
- "div",
289
- {
290
- className: s(
291
- "flex items-center justify-between rounded-2xl border p-4",
292
- i ? "border-neutral-700" : "border-slate-200",
293
- e.status === "error" && (i ? "border-red-500" : "border-red-600")
294
- ),
295
- children: [
296
- /* @__PURE__ */ o("div", { className: "flex min-w-0 items-center gap-4", children: [
297
- /* @__PURE__ */ t(
298
- "div",
299
- {
300
- className: s(
301
- "flex h-14 w-14 items-center justify-center rounded-2xl",
302
- d
303
- ),
304
- children: _ && e.preview ? /* @__PURE__ */ t(
305
- "img",
306
- {
307
- src: e.preview,
308
- alt: e.file.name,
309
- className: "h-10 w-10 rounded-xl object-cover"
310
- }
311
- ) : K ? me(e.file) : /* @__PURE__ */ t(oe, { className: "h-6 w-6 text-slate-500" })
312
- }
313
- ),
314
- /* @__PURE__ */ o("div", { className: "min-w-0", children: [
315
- /* @__PURE__ */ t("p", { className: s("truncate text-lg font-semibold", i ? "text-slate-100" : "text-primary"), children: e.file.name }),
316
- /* @__PURE__ */ o("div", { className: s("mt-1 flex flex-wrap items-center gap-2 text-sm", i ? "text-slate-400" : "text-slate-500"), children: [
317
- /* @__PURE__ */ t("span", { children: he(e.file.size) }),
318
- e.status === "uploading" && /* @__PURE__ */ o(k, { children: [
319
- /* @__PURE__ */ t("span", { children: "•" }),
320
- /* @__PURE__ */ o("span", { className: "inline-flex items-center", children: [
321
- /* @__PURE__ */ t(se, { className: "mr-1 h-5 w-5 animate-spin" }),
322
- n.uploading
323
- ] })
324
- ] }),
325
- e.status === "success" && /* @__PURE__ */ o(k, { children: [
326
- /* @__PURE__ */ t("span", { children: "•" }),
327
- /* @__PURE__ */ t("span", { className: "font-normal text-green-600", children: n.success })
328
- ] })
329
- ] }),
330
- e.status === "uploading" && /* @__PURE__ */ t("div", { className: s("mt-2 h-1.5 w-full rounded-full", i ? "bg-neutral-700" : "bg-slate-200"), children: /* @__PURE__ */ t(
331
- "div",
332
- {
333
- className: s(
334
- "h-1.5 rounded-full transition-all duration-300",
335
- u.progressFill
336
- ),
337
- style: { width: `${e.progress}%` }
338
- }
339
- ) }),
340
- e.status === "error" && e.error && /* @__PURE__ */ t("p", { className: "mt-2 text-sm font-normal text-red-600", children: e.error })
341
- ] })
342
- ] }),
343
- /* @__PURE__ */ o("div", { className: "flex items-center gap-2", children: [
344
- /* @__PURE__ */ t(
345
- "button",
346
- {
347
- type: "button",
348
- onClick: (a) => {
349
- a.stopPropagation(), r || Q(e);
350
- },
351
- disabled: r,
352
- className: s("rounded-xl p-2 hover:cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed", i ? "hover:bg-neutral-800" : "hover:bg-slate-100"),
353
- title: n.preview,
354
- children: /* @__PURE__ */ t(ne, { size: 20, className: "text-slate-400" })
355
- }
356
- ),
357
- /* @__PURE__ */ t(
358
- "button",
359
- {
360
- type: "button",
361
- onClick: (a) => {
362
- a.stopPropagation(), M(e.id);
363
- },
364
- disabled: g || I,
365
- className: s("rounded-xl p-2 hover:cursor-pointer disabled:cursor-not-allowed disabled:opacity-50", i ? "text-slate-400 hover:bg-neutral-800" : "text-slate-base hover:bg-slate-100"),
366
- title: n.remove,
367
- children: /* @__PURE__ */ t(ae, { className: "h-6 w-6" })
368
- }
369
- )
370
- ] })
371
- ]
372
- },
373
- e.id
374
- );
375
- }) })
376
- ] }),
377
- F && /* @__PURE__ */ t("p", { className: "mt-2 text-sm font-normal text-red-600", children: F })
111
+ /* @__PURE__ */ e(
112
+ E,
113
+ {
114
+ files: y,
115
+ theme: t,
116
+ t: s,
117
+ darkMode: n,
118
+ showPreview: b,
119
+ showFileTypeIcon: D,
120
+ disabled: r,
121
+ isUploading: R,
122
+ onPreview: W,
123
+ onRemove: q,
124
+ onClearAll: z
125
+ }
126
+ ),
127
+ a && /* @__PURE__ */ e("p", { className: "mt-2 text-sm font-normal text-red-600", children: a })
378
128
  ] });
379
129
  };
380
130
  export {
381
- Be as default
131
+ X as default
382
132
  };
@@ -0,0 +1,143 @@
1
+ import { jsxs as n, jsx as e } from "react/jsx-runtime";
2
+ import { Upload as H } from "@solar-icons/react";
3
+ import { cn as r } from "../../lib/utils.js";
4
+ import { MciUploadFileList as J } from "./MciUploadFileList.js";
5
+ import { useMciUpload as K } from "./useMciUpload.js";
6
+ const W = ({
7
+ multiple: o = !1,
8
+ accept: m = "*/*",
9
+ maxSize: d = 10,
10
+ maxFiles: f = 5,
11
+ disabled: l = !1,
12
+ label: i,
13
+ required: p = !1,
14
+ error: a,
15
+ className: u,
16
+ onFilesChange: x,
17
+ onUpload: h,
18
+ defaultValue: b,
19
+ value: w,
20
+ onValueChange: g,
21
+ showPreview: N = !0,
22
+ locale: v = "uz",
23
+ showFileTypeIcon: U = !0,
24
+ variant: C = "orange",
25
+ customValidator: y,
26
+ darkMode: t = !1,
27
+ buttonText: F,
28
+ fullWidth: j = !1
29
+ }) => {
30
+ const A = K({
31
+ multiple: o,
32
+ accept: m,
33
+ maxSize: d,
34
+ maxFiles: f,
35
+ disabled: l,
36
+ defaultValue: b,
37
+ value: w,
38
+ onFilesChange: x,
39
+ onValueChange: g,
40
+ onUpload: h,
41
+ locale: v,
42
+ variant: C,
43
+ darkMode: t,
44
+ customValidator: y
45
+ }), {
46
+ files: R,
47
+ isUploading: s,
48
+ fileInputRef: z,
49
+ t: c,
50
+ theme: I,
51
+ secureAccept: L,
52
+ handleFileInput: P,
53
+ handleRemoveFile: B,
54
+ handleClearAll: q,
55
+ handleUploadClick: D,
56
+ openPreview: E
57
+ } = A, G = F ?? c.uploadFile;
58
+ return /* @__PURE__ */ n("div", { className: r("w-full", u), children: [
59
+ i && /* @__PURE__ */ n(
60
+ "label",
61
+ {
62
+ className: r(
63
+ "mb-2 block text-base font-medium",
64
+ a ? "text-red-600" : t ? "text-slate-300" : "text-slate-700"
65
+ ),
66
+ children: [
67
+ i,
68
+ p && /* @__PURE__ */ e("span", { className: "ml-1 text-extra-small text-red-600", children: "*" })
69
+ ]
70
+ }
71
+ ),
72
+ /* @__PURE__ */ n(
73
+ "button",
74
+ {
75
+ type: "button",
76
+ onClick: D,
77
+ disabled: l || s,
78
+ className: r(
79
+ "inline-flex h-12 cursor-pointer overflow-hidden rounded-xl border text-left transition-colors",
80
+ j ? "w-full" : "w-fit min-w-70 max-w-full",
81
+ (l || s) && "cursor-not-allowed",
82
+ t ? "border-neutral-700 hover:border-neutral-600" : "border-slate-200 hover:border-slate-300",
83
+ l && "cursor-not-allowed opacity-60",
84
+ a && (t ? "border-red-500" : "border-red-600")
85
+ ),
86
+ children: [
87
+ /* @__PURE__ */ e(
88
+ "input",
89
+ {
90
+ ref: z,
91
+ type: "file",
92
+ multiple: o,
93
+ accept: L,
94
+ onChange: P,
95
+ disabled: l || s,
96
+ className: "hidden"
97
+ }
98
+ ),
99
+ /* @__PURE__ */ e(
100
+ "span",
101
+ {
102
+ className: r(
103
+ "flex h-12 w-12 shrink-0 items-center justify-center border-r",
104
+ t ? "border-neutral-700 bg-slate-800 text-slate-300" : "border-slate-200 bg-slate-200 text-slate-600"
105
+ ),
106
+ children: /* @__PURE__ */ e(H, { size: 22 })
107
+ }
108
+ ),
109
+ /* @__PURE__ */ e(
110
+ "span",
111
+ {
112
+ className: r(
113
+ "flex h-12 w-12 flex-1 items-center rounded-r-xl px-4",
114
+ t ? "bg-neutral-900 text-base text-slate-400" : "bg-white text-base text-slate-400"
115
+ ),
116
+ children: /* @__PURE__ */ e("span", { className: "truncate", children: G })
117
+ }
118
+ )
119
+ ]
120
+ }
121
+ ),
122
+ /* @__PURE__ */ e(
123
+ J,
124
+ {
125
+ files: R,
126
+ theme: I,
127
+ t: c,
128
+ darkMode: t,
129
+ showPreview: N,
130
+ showFileTypeIcon: U,
131
+ disabled: l,
132
+ isUploading: s,
133
+ onPreview: E,
134
+ onRemove: B,
135
+ onClearAll: q
136
+ }
137
+ ),
138
+ a && /* @__PURE__ */ e("p", { className: "mt-2 text-sm font-normal text-red-600", children: a })
139
+ ] });
140
+ };
141
+ export {
142
+ W as default
143
+ };