@vlrc-fe/components 1.0.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.
Files changed (219) hide show
  1. package/README.md +193 -0
  2. package/dist/index.cjs +1 -0
  3. package/dist/index.js +42 -0
  4. package/dist/index10.cjs +1 -0
  5. package/dist/index10.js +85 -0
  6. package/dist/index100.cjs +1 -0
  7. package/dist/index100.js +65 -0
  8. package/dist/index101.cjs +1 -0
  9. package/dist/index101.js +48 -0
  10. package/dist/index102.cjs +1 -0
  11. package/dist/index102.js +67 -0
  12. package/dist/index103.cjs +1 -0
  13. package/dist/index103.js +151 -0
  14. package/dist/index104.cjs +1 -0
  15. package/dist/index104.js +23 -0
  16. package/dist/index105.cjs +1 -0
  17. package/dist/index105.js +27 -0
  18. package/dist/index106.cjs +1 -0
  19. package/dist/index106.js +53 -0
  20. package/dist/index107.cjs +1 -0
  21. package/dist/index107.js +161 -0
  22. package/dist/index108.cjs +1 -0
  23. package/dist/index108.js +16 -0
  24. package/dist/index109.cjs +1 -0
  25. package/dist/index11.cjs +1 -0
  26. package/dist/index11.js +86 -0
  27. package/dist/index12.cjs +1 -0
  28. package/dist/index12.js +122 -0
  29. package/dist/index13.cjs +1 -0
  30. package/dist/index13.js +14 -0
  31. package/dist/index14.cjs +1 -0
  32. package/dist/index14.js +16 -0
  33. package/dist/index15.cjs +1 -0
  34. package/dist/index15.js +115 -0
  35. package/dist/index16.cjs +1 -0
  36. package/dist/index16.js +727 -0
  37. package/dist/index17.cjs +1 -0
  38. package/dist/index17.js +348 -0
  39. package/dist/index18.cjs +1 -0
  40. package/dist/index18.js +76 -0
  41. package/dist/index19.cjs +1 -0
  42. package/dist/index19.js +14 -0
  43. package/dist/index2.cjs +1 -0
  44. package/dist/index2.js +122 -0
  45. package/dist/index20.cjs +1 -0
  46. package/dist/index20.js +116 -0
  47. package/dist/index21.cjs +1 -0
  48. package/dist/index21.js +35 -0
  49. package/dist/index22.cjs +1 -0
  50. package/dist/index22.js +18 -0
  51. package/dist/index23.cjs +1 -0
  52. package/dist/index23.js +27 -0
  53. package/dist/index24.cjs +1 -0
  54. package/dist/index24.js +35 -0
  55. package/dist/index25.cjs +1 -0
  56. package/dist/index25.js +97 -0
  57. package/dist/index26.cjs +1 -0
  58. package/dist/index26.js +28 -0
  59. package/dist/index27.cjs +1 -0
  60. package/dist/index27.js +14 -0
  61. package/dist/index28.cjs +1 -0
  62. package/dist/index28.js +67 -0
  63. package/dist/index29.cjs +1 -0
  64. package/dist/index29.js +13 -0
  65. package/dist/index3.cjs +1 -0
  66. package/dist/index3.js +8 -0
  67. package/dist/index30.cjs +1 -0
  68. package/dist/index30.js +35 -0
  69. package/dist/index31.cjs +1 -0
  70. package/dist/index31.js +43 -0
  71. package/dist/index32.cjs +1 -0
  72. package/dist/index32.js +14 -0
  73. package/dist/index33.cjs +1 -0
  74. package/dist/index33.js +64 -0
  75. package/dist/index34.cjs +1 -0
  76. package/dist/index34.js +23 -0
  77. package/dist/index35.cjs +1 -0
  78. package/dist/index35.js +34 -0
  79. package/dist/index36.cjs +1 -0
  80. package/dist/index36.js +27 -0
  81. package/dist/index37.cjs +1 -0
  82. package/dist/index37.js +26 -0
  83. package/dist/index38.cjs +1 -0
  84. package/dist/index38.js +157 -0
  85. package/dist/index39.cjs +1 -0
  86. package/dist/index39.js +34 -0
  87. package/dist/index4.cjs +1 -0
  88. package/dist/index4.js +43 -0
  89. package/dist/index40.cjs +1 -0
  90. package/dist/index40.js +46 -0
  91. package/dist/index41.cjs +1 -0
  92. package/dist/index41.js +118 -0
  93. package/dist/index42.cjs +1 -0
  94. package/dist/index42.js +125 -0
  95. package/dist/index43.cjs +1 -0
  96. package/dist/index43.js +26 -0
  97. package/dist/index44.cjs +1 -0
  98. package/dist/index44.js +88 -0
  99. package/dist/index45.cjs +1 -0
  100. package/dist/index45.js +221 -0
  101. package/dist/index46.cjs +1 -0
  102. package/dist/index46.js +166 -0
  103. package/dist/index47.cjs +1 -0
  104. package/dist/index47.js +126 -0
  105. package/dist/index48.cjs +1 -0
  106. package/dist/index48.js +15 -0
  107. package/dist/index49.cjs +1 -0
  108. package/dist/index49.js +9 -0
  109. package/dist/index5.cjs +1 -0
  110. package/dist/index5.js +24 -0
  111. package/dist/index50.cjs +1 -0
  112. package/dist/index50.js +17 -0
  113. package/dist/index51.cjs +1 -0
  114. package/dist/index51.js +22 -0
  115. package/dist/index52.cjs +1 -0
  116. package/dist/index52.js +18 -0
  117. package/dist/index53.cjs +1 -0
  118. package/dist/index53.js +6 -0
  119. package/dist/index54.cjs +1 -0
  120. package/dist/index54.js +7 -0
  121. package/dist/index55.cjs +1 -0
  122. package/dist/index55.js +8 -0
  123. package/dist/index56.cjs +1 -0
  124. package/dist/index56.js +7 -0
  125. package/dist/index57.cjs +1 -0
  126. package/dist/index57.js +7 -0
  127. package/dist/index58.cjs +1 -0
  128. package/dist/index58.js +9 -0
  129. package/dist/index59.cjs +1 -0
  130. package/dist/index59.js +69 -0
  131. package/dist/index6.cjs +1 -0
  132. package/dist/index6.js +51 -0
  133. package/dist/index60.cjs +1 -0
  134. package/dist/index60.js +11 -0
  135. package/dist/index61.cjs +1 -0
  136. package/dist/index61.js +202 -0
  137. package/dist/index62.cjs +1 -0
  138. package/dist/index62.js +124 -0
  139. package/dist/index63.cjs +1 -0
  140. package/dist/index63.js +32 -0
  141. package/dist/index64.cjs +1 -0
  142. package/dist/index64.js +20 -0
  143. package/dist/index65.cjs +1 -0
  144. package/dist/index65.js +69 -0
  145. package/dist/index66.cjs +1 -0
  146. package/dist/index66.js +32 -0
  147. package/dist/index67.cjs +1 -0
  148. package/dist/index67.js +11 -0
  149. package/dist/index68.cjs +1 -0
  150. package/dist/index68.js +280 -0
  151. package/dist/index69.cjs +1 -0
  152. package/dist/index69.js +157 -0
  153. package/dist/index7.cjs +1 -0
  154. package/dist/index7.js +88 -0
  155. package/dist/index70.cjs +1 -0
  156. package/dist/index70.js +20 -0
  157. package/dist/index71.cjs +1 -0
  158. package/dist/index71.js +10 -0
  159. package/dist/index72.cjs +1 -0
  160. package/dist/index72.js +14 -0
  161. package/dist/index73.cjs +1 -0
  162. package/dist/index73.js +8 -0
  163. package/dist/index74.cjs +1 -0
  164. package/dist/index74.js +8 -0
  165. package/dist/index75.cjs +1 -0
  166. package/dist/index75.js +11 -0
  167. package/dist/index76.cjs +1 -0
  168. package/dist/index76.js +10 -0
  169. package/dist/index77.cjs +1 -0
  170. package/dist/index77.js +6 -0
  171. package/dist/index78.cjs +1 -0
  172. package/dist/index78.js +8 -0
  173. package/dist/index79.cjs +1 -0
  174. package/dist/index79.js +8 -0
  175. package/dist/index8.cjs +1 -0
  176. package/dist/index8.js +68 -0
  177. package/dist/index80.cjs +1 -0
  178. package/dist/index80.js +10 -0
  179. package/dist/index81.cjs +1 -0
  180. package/dist/index81.js +11 -0
  181. package/dist/index82.cjs +1 -0
  182. package/dist/index82.js +15 -0
  183. package/dist/index83.cjs +1 -0
  184. package/dist/index83.js +11 -0
  185. package/dist/index84.cjs +1 -0
  186. package/dist/index84.js +11 -0
  187. package/dist/index85.cjs +1 -0
  188. package/dist/index85.js +6 -0
  189. package/dist/index86.cjs +1 -0
  190. package/dist/index86.js +43 -0
  191. package/dist/index87.cjs +1 -0
  192. package/dist/index87.js +382 -0
  193. package/dist/index88.cjs +1 -0
  194. package/dist/index88.js +40 -0
  195. package/dist/index89.cjs +1 -0
  196. package/dist/index89.js +23 -0
  197. package/dist/index9.cjs +1 -0
  198. package/dist/index9.js +20 -0
  199. package/dist/index90.cjs +1 -0
  200. package/dist/index90.js +59 -0
  201. package/dist/index91.cjs +1 -0
  202. package/dist/index91.js +55 -0
  203. package/dist/index92.cjs +1 -0
  204. package/dist/index92.js +54 -0
  205. package/dist/index93.cjs +1 -0
  206. package/dist/index93.js +57 -0
  207. package/dist/index94.cjs +1 -0
  208. package/dist/index94.js +57 -0
  209. package/dist/index95.cjs +1 -0
  210. package/dist/index95.js +88 -0
  211. package/dist/index96.cjs +1 -0
  212. package/dist/index96.js +66 -0
  213. package/dist/index97.cjs +1 -0
  214. package/dist/index97.js +594 -0
  215. package/dist/index98.cjs +9 -0
  216. package/dist/index98.js +30 -0
  217. package/dist/index99.cjs +1 -0
  218. package/dist/index99.js +50 -0
  219. package/package.json +82 -0
@@ -0,0 +1,727 @@
1
+ "use client";
2
+ import { cn as e } from "./index3.js";
3
+ import { FileArchiveIcon as t, FileAudioIcon as n, FileCodeIcon as r, FileCogIcon as i, FileIcon as a, FileTextIcon as o, FileVideoIcon as s } from "lucide-react";
4
+ import * as c from "react";
5
+ import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
6
+ import { Slot as f } from "@radix-ui/react-slot";
7
+ import { useDirection as p } from "@radix-ui/react-direction";
8
+ //#region src/ui/file-upload.tsx
9
+ var m = "FileUpload", h = "FileUploadDropzone", g = "FileUploadTrigger", _ = "FileUploadList", v = "FileUploadItem", y = "FileUploadItemPreview", b = "FileUploadItemMetadata", x = "FileUploadItemProgress", S = "FileUploadItemDelete", C = "FileUploadClear";
10
+ function w(e) {
11
+ let t = c.useRef(null);
12
+ return t.current === null && (t.current = e()), t;
13
+ }
14
+ function T(e, t, n, r, i) {
15
+ let a = {
16
+ files: t,
17
+ dragOver: !1,
18
+ invalid: r
19
+ };
20
+ function o(e, r) {
21
+ switch (r.type) {
22
+ case "ADD_FILES":
23
+ for (let e of r.files) t.set(e, {
24
+ file: e,
25
+ progress: 0,
26
+ status: "idle"
27
+ });
28
+ return i && i(Array.from(t.values()).map((e) => e.file)), {
29
+ ...e,
30
+ files: t
31
+ };
32
+ case "SET_FILES": {
33
+ let n = new Set(r.files);
34
+ for (let e of t.keys()) n.has(e) || t.delete(e);
35
+ for (let e of r.files) t.get(e) || t.set(e, {
36
+ file: e,
37
+ progress: 0,
38
+ status: "idle"
39
+ });
40
+ return {
41
+ ...e,
42
+ files: t
43
+ };
44
+ }
45
+ case "SET_PROGRESS": {
46
+ let n = t.get(r.file);
47
+ return n && t.set(r.file, {
48
+ ...n,
49
+ progress: r.progress,
50
+ status: "uploading"
51
+ }), {
52
+ ...e,
53
+ files: t
54
+ };
55
+ }
56
+ case "SET_SUCCESS": {
57
+ let n = t.get(r.file);
58
+ return n && t.set(r.file, {
59
+ ...n,
60
+ progress: 100,
61
+ status: "success"
62
+ }), {
63
+ ...e,
64
+ files: t
65
+ };
66
+ }
67
+ case "SET_ERROR": {
68
+ let n = t.get(r.file);
69
+ return n && t.set(r.file, {
70
+ ...n,
71
+ error: r.error,
72
+ status: "error"
73
+ }), {
74
+ ...e,
75
+ files: t
76
+ };
77
+ }
78
+ case "REMOVE_FILE":
79
+ if (n) {
80
+ let e = n.get(r.file);
81
+ e && (URL.revokeObjectURL(e), n.delete(r.file));
82
+ }
83
+ return t.delete(r.file), i && i(Array.from(t.values()).map((e) => e.file)), {
84
+ ...e,
85
+ files: t
86
+ };
87
+ case "SET_DRAG_OVER": return {
88
+ ...e,
89
+ dragOver: r.dragOver
90
+ };
91
+ case "SET_INVALID": return {
92
+ ...e,
93
+ invalid: r.invalid
94
+ };
95
+ case "CLEAR":
96
+ if (n) for (let e of t.keys()) {
97
+ let t = n.get(e);
98
+ t && (URL.revokeObjectURL(t), n.delete(e));
99
+ }
100
+ return t.clear(), i && i([]), {
101
+ ...e,
102
+ files: t,
103
+ invalid: !1
104
+ };
105
+ default: return e;
106
+ }
107
+ }
108
+ function s() {
109
+ return a;
110
+ }
111
+ function c(t) {
112
+ a = o(a, t);
113
+ for (let t of e) t();
114
+ }
115
+ function l(t) {
116
+ return e.add(t), () => e.delete(t);
117
+ }
118
+ return {
119
+ getState: s,
120
+ dispatch: c,
121
+ subscribe: l
122
+ };
123
+ }
124
+ var E = c.createContext(null);
125
+ function D(e) {
126
+ let t = c.useContext(E);
127
+ if (!t) throw Error(`\`${e}\` must be used within \`${m}\``);
128
+ return t;
129
+ }
130
+ function O(e) {
131
+ let t = D("useStore"), n = w(() => null), r = c.useCallback(() => {
132
+ let r = t.getState(), i = n.current;
133
+ if (i && i.state === r) return i.value;
134
+ let a = e(r);
135
+ return n.current = {
136
+ value: a,
137
+ state: r
138
+ }, a;
139
+ }, [
140
+ t,
141
+ e,
142
+ n
143
+ ]);
144
+ return c.useSyncExternalStore(t.subscribe, r, r);
145
+ }
146
+ var k = c.createContext(null);
147
+ function A(e) {
148
+ let t = c.useContext(k);
149
+ if (!t) throw Error(`\`${e}\` must be used within \`${m}\``);
150
+ return t;
151
+ }
152
+ function j(t) {
153
+ let { value: n, defaultValue: r, onValueChange: i, onAccept: a, onFileAccept: o, onFileReject: s, onFileValidate: l, onUpload: m, accept: h, maxFiles: g, maxSize: _, dir: v, label: y, name: b, asChild: x, disabled: S = !1, invalid: C = !1, multiple: D = !1, required: O = !1, children: A, className: j, ...M } = t, N = c.useId(), P = c.useId(), F = c.useId(), I = c.useId(), L = p(v), R = w(() => /* @__PURE__ */ new Set()).current, z = w(() => /* @__PURE__ */ new Map()).current, B = w(() => /* @__PURE__ */ new WeakMap()).current, V = c.useRef(null), H = n !== void 0, U = c.useMemo(() => T(R, z, B, C, i), [
154
+ R,
155
+ z,
156
+ C,
157
+ i,
158
+ B
159
+ ]), W = c.useMemo(() => h?.split(",").map((e) => e.trim()) ?? null, [h]), G = w(() => {
160
+ let e = 0;
161
+ return (t, n) => {
162
+ e ||= requestAnimationFrame(() => {
163
+ e = 0, U.dispatch({
164
+ type: "SET_PROGRESS",
165
+ file: t,
166
+ progress: Math.min(Math.max(0, n), 100)
167
+ });
168
+ });
169
+ };
170
+ }).current;
171
+ c.useEffect(() => {
172
+ H ? U.dispatch({
173
+ type: "SET_FILES",
174
+ files: n
175
+ }) : r && r.length > 0 && !U.getState().files.size && U.dispatch({
176
+ type: "SET_FILES",
177
+ files: r
178
+ });
179
+ }, [
180
+ n,
181
+ r,
182
+ H,
183
+ U
184
+ ]), c.useEffect(() => () => {
185
+ for (let e of z.keys()) {
186
+ let t = B.get(e);
187
+ t && URL.revokeObjectURL(t);
188
+ }
189
+ }, [z, B]);
190
+ let K = c.useCallback(async (e) => {
191
+ try {
192
+ for (let t of e) U.dispatch({
193
+ type: "SET_PROGRESS",
194
+ file: t,
195
+ progress: 0
196
+ });
197
+ if (m) await m(e, {
198
+ onProgress: G,
199
+ onSuccess: (e) => {
200
+ U.dispatch({
201
+ type: "SET_SUCCESS",
202
+ file: e
203
+ });
204
+ },
205
+ onError: (e, t) => {
206
+ U.dispatch({
207
+ type: "SET_ERROR",
208
+ file: e,
209
+ error: t.message ?? "Upload failed"
210
+ });
211
+ }
212
+ });
213
+ else for (let t of e) U.dispatch({
214
+ type: "SET_SUCCESS",
215
+ file: t
216
+ });
217
+ } catch (t) {
218
+ let n = t instanceof Error ? t.message : "Upload failed";
219
+ for (let t of e) U.dispatch({
220
+ type: "SET_ERROR",
221
+ file: t,
222
+ error: n
223
+ });
224
+ }
225
+ }, [
226
+ U,
227
+ m,
228
+ G
229
+ ]), q = c.useCallback((e) => {
230
+ if (S) return;
231
+ let t = [...e], n = !1;
232
+ if (g) {
233
+ let e = U.getState().files.size;
234
+ if (g === 1 && e > 0 && t.length > 0) U.dispatch({ type: "CLEAR" });
235
+ else {
236
+ let r = Math.max(0, g - e);
237
+ if (r < t.length) {
238
+ let e = t.slice(r);
239
+ n = !0, t = t.slice(0, r);
240
+ for (let t of e) {
241
+ let e = `Maximum ${g} files allowed`;
242
+ if (l) {
243
+ let n = l(t);
244
+ n && (e = n);
245
+ }
246
+ s?.(t, e);
247
+ }
248
+ }
249
+ }
250
+ }
251
+ let r = [], c = [];
252
+ for (let e of t) {
253
+ let t = !1, i = "";
254
+ if (l) {
255
+ let r = l(e);
256
+ if (r) {
257
+ i = r, s?.(e, i), t = !0, n = !0;
258
+ continue;
259
+ }
260
+ }
261
+ if (W) {
262
+ let r = e.type, a = `.${e.name.split(".").pop()}`;
263
+ W.some((e) => e === r || e === a || e.includes("/*") && r.startsWith(e.replace("/*", "/"))) || (i = "File type not accepted", s?.(e, i), t = !0, n = !0);
264
+ }
265
+ _ && e.size > _ && (i = "File too large", s?.(e, i), t = !0, n = !0), t ? c.push({
266
+ file: e,
267
+ message: i
268
+ }) : r.push(e);
269
+ }
270
+ if (n && (U.dispatch({
271
+ type: "SET_INVALID",
272
+ invalid: n
273
+ }), setTimeout(() => {
274
+ U.dispatch({
275
+ type: "SET_INVALID",
276
+ invalid: !1
277
+ });
278
+ }, 2e3)), r.length > 0) {
279
+ U.dispatch({
280
+ type: "ADD_FILES",
281
+ files: r
282
+ }), H && i && i([...Array.from(U.getState().files.values()).map((e) => e.file)]), a && a(r);
283
+ for (let e of r) o?.(e);
284
+ m && requestAnimationFrame(() => {
285
+ K(r);
286
+ });
287
+ }
288
+ }, [
289
+ U,
290
+ H,
291
+ i,
292
+ a,
293
+ o,
294
+ m,
295
+ K,
296
+ g,
297
+ l,
298
+ s,
299
+ W,
300
+ _,
301
+ S
302
+ ]), J = c.useCallback((e) => {
303
+ q(Array.from(e.target.files ?? [])), e.target.value = "";
304
+ }, [q]), Y = c.useMemo(() => ({
305
+ dropzoneId: P,
306
+ inputId: N,
307
+ listId: F,
308
+ labelId: I,
309
+ dir: L,
310
+ disabled: S,
311
+ inputRef: V,
312
+ urlCache: B
313
+ }), [
314
+ P,
315
+ N,
316
+ F,
317
+ I,
318
+ L,
319
+ S,
320
+ B
321
+ ]), X = x ? f : "div";
322
+ return /* @__PURE__ */ u(E.Provider, {
323
+ value: U,
324
+ children: /* @__PURE__ */ u(k.Provider, {
325
+ value: Y,
326
+ children: /* @__PURE__ */ d(X, {
327
+ "data-disabled": S ? "" : void 0,
328
+ "data-slot": "file-upload",
329
+ dir: L,
330
+ ...M,
331
+ className: e("relative flex flex-col gap-2", j),
332
+ children: [
333
+ A,
334
+ /* @__PURE__ */ u("input", {
335
+ type: "file",
336
+ id: N,
337
+ "aria-labelledby": I,
338
+ "aria-describedby": P,
339
+ ref: V,
340
+ tabIndex: -1,
341
+ accept: h,
342
+ name: b,
343
+ className: "sr-only",
344
+ disabled: S,
345
+ multiple: D,
346
+ required: O,
347
+ onChange: J
348
+ }),
349
+ /* @__PURE__ */ u("span", {
350
+ id: I,
351
+ className: "sr-only",
352
+ children: y ?? "File upload"
353
+ })
354
+ ]
355
+ })
356
+ })
357
+ });
358
+ }
359
+ function M(t) {
360
+ let { asChild: n, className: r, onClick: i, onDragOver: a, onDragEnter: o, onDragLeave: s, onDrop: l, onPaste: d, onKeyDown: p, ...m } = t, g = A(h), _ = D(h), v = O((e) => e.dragOver), y = O((e) => e.invalid), b = c.useCallback((e) => {
361
+ if (i?.(e), e.defaultPrevented) return;
362
+ let t = e.target;
363
+ t instanceof HTMLElement && t.closest("[data-slot=\"file-upload-trigger\"]") || g.inputRef.current?.click();
364
+ }, [g.inputRef, i]), x = c.useCallback((e) => {
365
+ a?.(e), !e.defaultPrevented && (e.preventDefault(), _.dispatch({
366
+ type: "SET_DRAG_OVER",
367
+ dragOver: !0
368
+ }));
369
+ }, [_, a]), S = c.useCallback((e) => {
370
+ o?.(e), !e.defaultPrevented && (e.preventDefault(), _.dispatch({
371
+ type: "SET_DRAG_OVER",
372
+ dragOver: !0
373
+ }));
374
+ }, [_, o]), C = c.useCallback((e) => {
375
+ if (s?.(e), e.defaultPrevented) return;
376
+ let t = e.relatedTarget;
377
+ t && t instanceof Node && e.currentTarget.contains(t) || (e.preventDefault(), _.dispatch({
378
+ type: "SET_DRAG_OVER",
379
+ dragOver: !1
380
+ }));
381
+ }, [_, s]), w = c.useCallback((e) => {
382
+ if (l?.(e), e.defaultPrevented) return;
383
+ e.preventDefault(), _.dispatch({
384
+ type: "SET_DRAG_OVER",
385
+ dragOver: !1
386
+ });
387
+ let t = Array.from(e.dataTransfer.files), n = g.inputRef.current;
388
+ if (!n) return;
389
+ let r = new DataTransfer();
390
+ for (let e of t) r.items.add(e);
391
+ n.files = r.files, n.dispatchEvent(new Event("change", { bubbles: !0 }));
392
+ }, [
393
+ _,
394
+ g.inputRef,
395
+ l
396
+ ]), T = c.useCallback((e) => {
397
+ if (d?.(e), e.defaultPrevented) return;
398
+ e.preventDefault(), _.dispatch({
399
+ type: "SET_DRAG_OVER",
400
+ dragOver: !1
401
+ });
402
+ let t = e.clipboardData?.items;
403
+ if (!t) return;
404
+ let n = [];
405
+ for (let e = 0; e < t.length; e++) {
406
+ let r = t[e];
407
+ if (r?.kind === "file") {
408
+ let e = r.getAsFile();
409
+ e && n.push(e);
410
+ }
411
+ }
412
+ if (n.length === 0) return;
413
+ let r = g.inputRef.current;
414
+ if (!r) return;
415
+ let i = new DataTransfer();
416
+ for (let e of n) i.items.add(e);
417
+ r.files = i.files, r.dispatchEvent(new Event("change", { bubbles: !0 }));
418
+ }, [
419
+ _,
420
+ g.inputRef,
421
+ d
422
+ ]), E = c.useCallback((e) => {
423
+ p?.(e), !e.defaultPrevented && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), g.inputRef.current?.click());
424
+ }, [g.inputRef, p]);
425
+ return /* @__PURE__ */ u(n ? f : "div", {
426
+ role: "region",
427
+ id: g.dropzoneId,
428
+ "aria-controls": `${g.inputId} ${g.listId}`,
429
+ "aria-disabled": g.disabled,
430
+ "aria-invalid": y,
431
+ "data-disabled": g.disabled ? "" : void 0,
432
+ "data-dragging": v ? "" : void 0,
433
+ "data-invalid": y ? "" : void 0,
434
+ "data-slot": "file-upload-dropzone",
435
+ dir: g.dir,
436
+ tabIndex: g.disabled ? void 0 : 0,
437
+ ...m,
438
+ className: e("relative flex select-none flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed p-6 outline-none transition-colors hover:bg-accent/30 focus-visible:border-ring/50 data-disabled:pointer-events-none data-dragging:border-primary/30 data-invalid:border-destructive data-dragging:bg-accent/30 data-invalid:ring-destructive/20", r),
439
+ onClick: b,
440
+ onDragEnter: S,
441
+ onDragLeave: C,
442
+ onDragOver: x,
443
+ onDrop: w,
444
+ onKeyDown: E,
445
+ onPaste: T
446
+ });
447
+ }
448
+ function N(e) {
449
+ let { asChild: t, onClick: n, ...r } = e, i = A(g), a = c.useCallback((e) => {
450
+ n?.(e), !e.defaultPrevented && i.inputRef.current?.click();
451
+ }, [i.inputRef, n]);
452
+ return /* @__PURE__ */ u(t ? f : "button", {
453
+ type: "button",
454
+ "aria-controls": i.inputId,
455
+ "data-disabled": i.disabled ? "" : void 0,
456
+ "data-slot": "file-upload-trigger",
457
+ ...r,
458
+ disabled: i.disabled,
459
+ onClick: a
460
+ });
461
+ }
462
+ function P(t) {
463
+ let { className: n, orientation: r = "vertical", asChild: i, forceMount: a, ...o } = t, s = A(_), c = O((e) => e.files.size), l = a || c > 0;
464
+ return l ? /* @__PURE__ */ u(i ? f : "div", {
465
+ role: "list",
466
+ id: s.listId,
467
+ "aria-orientation": r,
468
+ "data-orientation": r,
469
+ "data-slot": "file-upload-list",
470
+ "data-state": l ? "active" : "inactive",
471
+ dir: s.dir,
472
+ ...o,
473
+ className: e("data-[state=inactive]:fade-out-0 data-[state=active]:fade-in-0 data-[state=inactive]:slide-out-to-top-2 data-[state=active]:slide-in-from-top-2 flex flex-col gap-2 data-[state=active]:animate-in data-[state=inactive]:animate-out", r === "horizontal" && "flex-row overflow-x-auto p-1.5", n)
474
+ }) : null;
475
+ }
476
+ var F = c.createContext(null);
477
+ function I(e) {
478
+ let t = c.useContext(F);
479
+ if (!t) throw Error(`\`${e}\` must be used within \`${v}\``);
480
+ return t;
481
+ }
482
+ function L(t) {
483
+ let { value: n, asChild: r, className: i, ...a } = t, o = c.useId(), s = `${o}-status`, l = `${o}-name`, p = `${o}-size`, m = `${o}-message`, h = A(v), g = O((e) => e.files.get(n)), _ = O((e) => e.files.size), y = O((e) => Array.from(e.files.keys()).indexOf(n) + 1), b = c.useMemo(() => ({
484
+ id: o,
485
+ fileState: g,
486
+ nameId: l,
487
+ sizeId: p,
488
+ statusId: s,
489
+ messageId: m
490
+ }), [
491
+ o,
492
+ g,
493
+ s,
494
+ l,
495
+ p,
496
+ m
497
+ ]);
498
+ if (!g) return null;
499
+ let x = g.error ? `Error: ${g.error}` : g.status === "uploading" ? `Uploading: ${g.progress}% complete` : g.status === "success" ? "Upload complete" : "Ready to upload", S = r ? f : "div";
500
+ return /* @__PURE__ */ u(F.Provider, {
501
+ value: b,
502
+ children: /* @__PURE__ */ d(S, {
503
+ role: "listitem",
504
+ id: o,
505
+ "aria-setsize": _,
506
+ "aria-posinset": y,
507
+ "aria-describedby": `${l} ${p} ${s} ${g.error ? m : ""}`,
508
+ "aria-labelledby": l,
509
+ "data-slot": "file-upload-item",
510
+ dir: h.dir,
511
+ ...a,
512
+ className: e("relative flex items-center gap-2.5 rounded-md border p-3", i),
513
+ children: [t.children, /* @__PURE__ */ u("span", {
514
+ id: s,
515
+ className: "sr-only",
516
+ children: x
517
+ })]
518
+ })
519
+ });
520
+ }
521
+ function R(e) {
522
+ if (e === 0) return "0 B";
523
+ let t = [
524
+ "B",
525
+ "KB",
526
+ "MB",
527
+ "GB",
528
+ "TB"
529
+ ], n = Math.floor(Math.log(e) / Math.log(1024));
530
+ return `${(e / 1024 ** n).toFixed(+!!n)} ${t[n]}`;
531
+ }
532
+ function z(e) {
533
+ let c = e.type, l = e.name.split(".").pop()?.toLowerCase() ?? "";
534
+ return c.startsWith("video/") ? /* @__PURE__ */ u(s, {}) : c.startsWith("audio/") ? /* @__PURE__ */ u(n, {}) : c.startsWith("text/") || [
535
+ "txt",
536
+ "md",
537
+ "rtf",
538
+ "pdf"
539
+ ].includes(l) ? /* @__PURE__ */ u(o, {}) : [
540
+ "html",
541
+ "css",
542
+ "js",
543
+ "jsx",
544
+ "ts",
545
+ "tsx",
546
+ "json",
547
+ "xml",
548
+ "php",
549
+ "py",
550
+ "rb",
551
+ "java",
552
+ "c",
553
+ "cpp",
554
+ "cs"
555
+ ].includes(l) ? /* @__PURE__ */ u(r, {}) : [
556
+ "zip",
557
+ "rar",
558
+ "7z",
559
+ "tar",
560
+ "gz",
561
+ "bz2"
562
+ ].includes(l) ? /* @__PURE__ */ u(t, {}) : [
563
+ "exe",
564
+ "msi",
565
+ "app",
566
+ "apk",
567
+ "deb",
568
+ "rpm"
569
+ ].includes(l) || c.startsWith("application/") ? /* @__PURE__ */ u(i, {}) : /* @__PURE__ */ u(a, {});
570
+ }
571
+ function B(t) {
572
+ let { render: n, asChild: r, children: i, className: a, ...o } = t, s = I(y), l = A(y), p = c.useCallback((e) => {
573
+ if (s.fileState?.file.type.startsWith("image/")) {
574
+ let t = l.urlCache.get(e);
575
+ return t || (t = URL.createObjectURL(e), l.urlCache.set(e, t)), /* @__PURE__ */ u("img", {
576
+ src: t,
577
+ alt: e.name,
578
+ className: "size-full object-cover"
579
+ });
580
+ }
581
+ return z(e);
582
+ }, [s.fileState?.file.type, l.urlCache]), m = c.useCallback((e) => n ? n(e, () => p(e)) : p(e), [n, p]);
583
+ return s.fileState ? /* @__PURE__ */ d(r ? f : "div", {
584
+ "aria-labelledby": s.nameId,
585
+ "data-slot": "file-upload-preview",
586
+ ...o,
587
+ className: e("relative flex size-10 shrink-0 items-center justify-center overflow-hidden rounded border bg-accent/50 [&>svg]:size-10", a),
588
+ children: [m(s.fileState.file), i]
589
+ }) : null;
590
+ }
591
+ function V(t) {
592
+ let { asChild: n, size: r = "default", children: i, className: a, ...o } = t, s = A(b), c = I(b);
593
+ return c.fileState ? /* @__PURE__ */ u(n ? f : "div", {
594
+ "data-slot": "file-upload-metadata",
595
+ dir: s.dir,
596
+ ...o,
597
+ className: e("flex min-w-0 flex-1 flex-col", a),
598
+ children: i ?? /* @__PURE__ */ d(l, { children: [
599
+ /* @__PURE__ */ u("span", {
600
+ id: c.nameId,
601
+ className: e("truncate font-medium text-sm", r === "sm" && "font-normal text-[13px] leading-snug"),
602
+ children: c.fileState.file.name
603
+ }),
604
+ /* @__PURE__ */ u("span", {
605
+ id: c.sizeId,
606
+ className: e("truncate text-muted-foreground text-xs", r === "sm" && "text-[11px] leading-snug"),
607
+ children: R(c.fileState.file.size)
608
+ }),
609
+ c.fileState.error && /* @__PURE__ */ u("span", {
610
+ id: c.messageId,
611
+ className: "text-destructive text-xs",
612
+ children: c.fileState.error
613
+ })
614
+ ] })
615
+ }) : null;
616
+ }
617
+ function H(t) {
618
+ let { variant: n = "linear", size: r = 40, asChild: i, forceMount: a, className: o, ...s } = t, c = I(x);
619
+ if (!c.fileState || !(a || c.fileState.progress !== 100)) return null;
620
+ let l = i ? f : "div";
621
+ switch (n) {
622
+ case "circular": {
623
+ let t = 2 * Math.PI * ((r - 4) / 2), n = t - c.fileState.progress / 100 * t;
624
+ return /* @__PURE__ */ u(l, {
625
+ role: "progressbar",
626
+ "aria-valuemin": 0,
627
+ "aria-valuemax": 100,
628
+ "aria-valuenow": c.fileState.progress,
629
+ "aria-valuetext": `${c.fileState.progress}%`,
630
+ "aria-labelledby": c.nameId,
631
+ "data-slot": "file-upload-progress",
632
+ ...s,
633
+ className: e("-translate-x-1/2 -translate-y-1/2 absolute top-1/2 left-1/2", o),
634
+ children: /* @__PURE__ */ d("svg", {
635
+ className: "-rotate-90 transform",
636
+ width: r,
637
+ height: r,
638
+ viewBox: `0 0 ${r} ${r}`,
639
+ fill: "none",
640
+ stroke: "currentColor",
641
+ children: [/* @__PURE__ */ u("circle", {
642
+ className: "text-primary/20",
643
+ strokeWidth: "2",
644
+ cx: r / 2,
645
+ cy: r / 2,
646
+ r: (r - 4) / 2
647
+ }), /* @__PURE__ */ u("circle", {
648
+ className: "text-primary transition-[stroke-dashoffset] duration-300 ease-linear",
649
+ strokeWidth: "2",
650
+ strokeLinecap: "round",
651
+ strokeDasharray: t,
652
+ strokeDashoffset: n,
653
+ cx: r / 2,
654
+ cy: r / 2,
655
+ r: (r - 4) / 2
656
+ })]
657
+ })
658
+ });
659
+ }
660
+ case "fill": {
661
+ let t = c.fileState.progress, n = 100 - t;
662
+ return /* @__PURE__ */ u(l, {
663
+ role: "progressbar",
664
+ "aria-valuemin": 0,
665
+ "aria-valuemax": 100,
666
+ "aria-valuenow": t,
667
+ "aria-valuetext": `${t}%`,
668
+ "aria-labelledby": c.nameId,
669
+ "data-slot": "file-upload-progress",
670
+ ...s,
671
+ className: e("absolute inset-0 bg-primary/50 transition-[clip-path] duration-300 ease-linear", o),
672
+ style: { clipPath: `inset(${n}% 0% 0% 0%)` }
673
+ });
674
+ }
675
+ default: return /* @__PURE__ */ u(l, {
676
+ role: "progressbar",
677
+ "aria-valuemin": 0,
678
+ "aria-valuemax": 100,
679
+ "aria-valuenow": c.fileState.progress,
680
+ "aria-valuetext": `${c.fileState.progress}%`,
681
+ "aria-labelledby": c.nameId,
682
+ "data-slot": "file-upload-progress",
683
+ ...s,
684
+ className: e("relative h-1.5 w-full overflow-hidden rounded-full bg-primary/20", o),
685
+ children: /* @__PURE__ */ u("div", {
686
+ className: "h-full w-full flex-1 bg-primary transition-transform duration-300 ease-linear",
687
+ style: { transform: `translateX(-${100 - c.fileState.progress}%)` }
688
+ })
689
+ });
690
+ }
691
+ }
692
+ function U(e) {
693
+ let { asChild: t, onClick: n, ...r } = e, i = D(S), a = I(S), o = c.useCallback((e) => {
694
+ n?.(e), !(!a.fileState || e.defaultPrevented) && i.dispatch({
695
+ type: "REMOVE_FILE",
696
+ file: a.fileState.file
697
+ });
698
+ }, [
699
+ i,
700
+ a.fileState,
701
+ n
702
+ ]);
703
+ return a.fileState ? /* @__PURE__ */ u(t ? f : "button", {
704
+ type: "button",
705
+ "aria-controls": a.id,
706
+ "aria-describedby": a.nameId,
707
+ "data-slot": "file-upload-item-delete",
708
+ ...r,
709
+ onClick: o
710
+ }) : null;
711
+ }
712
+ function W(e) {
713
+ let { asChild: t, forceMount: n, disabled: r, onClick: i, ...a } = e, o = A(C), s = D(C), l = O((e) => e.files.size), d = r || o.disabled, p = c.useCallback((e) => {
714
+ i?.(e), !e.defaultPrevented && s.dispatch({ type: "CLEAR" });
715
+ }, [s, i]);
716
+ return n || l > 0 ? /* @__PURE__ */ u(t ? f : "button", {
717
+ type: "button",
718
+ "aria-controls": o.listId,
719
+ "data-slot": "file-upload-clear",
720
+ "data-disabled": d ? "" : void 0,
721
+ ...a,
722
+ disabled: d,
723
+ onClick: p
724
+ }) : null;
725
+ }
726
+ //#endregion
727
+ export { W as FileUploadClear, M as FileUploadDropzone, L as FileUploadItem, U as FileUploadItemDelete, V as FileUploadItemMetadata, B as FileUploadItemPreview, H as FileUploadItemProgress, P as FileUploadList, j as FileUploadRoot, N as FileUploadTrigger, O as useStore };