@pixpilot/shadcn 0.1.1 → 0.1.2

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 (204) hide show
  1. package/dist/{OrContinueWithSeparator-D2E12axp.d.ts → OrContinueWithSeparator-BQalGx6O.d.ts} +2 -2
  2. package/dist/{alert-BOmOAVab.d.cts → alert-BDcOuBrO.d.ts} +5 -5
  3. package/dist/{alert-dialog-TlaRRoQl.d.ts → alert-dialog-Iw5UG8d3.d.ts} +12 -12
  4. package/dist/{avatar-C0o0LZHK.d.cts → avatar-BRZS2oIf.d.ts} +4 -4
  5. package/dist/{badge-BwMa0yrU.d.cts → badge-Dwxq7JaA.d.ts} +3 -3
  6. package/dist/{button-DS2onC5z.d.cts → button-CSw4bOk7.d.ts} +3 -3
  7. package/dist/{calendar-2na2Z1lC.d.cts → calendar-Vx7GBiN5.d.ts} +4 -4
  8. package/dist/{card-WGLY-CGJ.d.ts → card-CN1Wv1_W.d.ts} +8 -8
  9. package/dist/{checkbox-qfDakeFS.d.cts → checkbox-COC2Igpo.d.ts} +2 -2
  10. package/dist/{command-Jg-MECH0.d.ts → command-CJXf3-UR.d.ts} +11 -11
  11. package/dist/components/{index-9UbR5pav.d.ts → index-2Smtu_1u.d.ts} +29 -29
  12. package/dist/components/ui/{OrContinueWithSeparator-Deko0a05.d.ts → OrContinueWithSeparator-OYGOTHTw.d.ts} +1 -1
  13. package/dist/components/ui/alert-DuyLuX68.d.ts +2 -0
  14. package/dist/components/ui/{alert-dialog-B1O4SkCO.d.ts → alert-dialog-CUL8nAeI.d.ts} +1 -1
  15. package/dist/components/ui/avatar-DAQzpqqD.d.ts +2 -0
  16. package/dist/components/ui/badge-BM6RVFS5.d.ts +2 -0
  17. package/dist/components/ui/{button-xAUU71CK.d.ts → button-D9y8v_Tt.d.ts} +1 -1
  18. package/dist/components/ui/{calendar-CdHQnChE.d.ts → calendar-B9zfwi7H.d.ts} +1 -1
  19. package/dist/components/ui/{card-B33oFk7g.d.ts → card-BYi1Jf3z.d.ts} +1 -1
  20. package/dist/components/ui/checkbox-QkowwGnR.d.ts +2 -0
  21. package/dist/components/ui/{command-CiYsTw-N.d.ts → command-BkXDbodx.d.ts} +1 -1
  22. package/dist/components/ui/{dialog-BLmUGWhm.d.ts → dialog-BvEqiJH6.d.ts} +1 -1
  23. package/dist/components/ui/{dropdown-menu-BiTw8JoY.d.ts → dropdown-menu-BJ2FNIH4.d.ts} +1 -1
  24. package/dist/components/ui/{file-upload-B5xI4UMr.d.ts → file-upload-DZGaOzQS.d.ts} +1 -1
  25. package/dist/components/ui/{form-Di2tTY-R.d.ts → form-CpVuTht7.d.ts} +1 -1
  26. package/dist/components/ui/{index-8A2fRq2u.d.ts → index-q7RUuYJ2.d.ts} +29 -29
  27. package/dist/components/ui/input-DVpolrW-.d.ts +2 -0
  28. package/dist/components/ui/label-BW9JhwyW.d.ts +2 -0
  29. package/dist/components/ui/{pagination-CEb9cpQ4.d.ts → pagination-CDtFyXkC.d.ts} +1 -1
  30. package/dist/components/ui/{popover-DnnrgVi3.d.ts → popover-B6PDCy8U.d.ts} +1 -1
  31. package/dist/components/ui/{radio-group-DIjhsevH.d.ts → radio-group-DuGtPMcp.d.ts} +1 -1
  32. package/dist/components/ui/{select-d1uVKLd4.d.ts → select-DAN9r02Z.d.ts} +1 -1
  33. package/dist/components/ui/separator-D53tTv-J.d.ts +2 -0
  34. package/dist/components/ui/shadcn-io/tags/{index-D0RWMGB5.d.ts → index-CnMq6aeV.d.ts} +1 -1
  35. package/dist/components/ui/shadcn-io/tags-input-inline/{index-DVGMC27L.d.ts → index-D7OIPdfu.d.ts} +1 -1
  36. package/dist/components/ui/{sheet-oRvo5v4N.d.ts → sheet-Bo7lvlRA.d.ts} +1 -1
  37. package/dist/components/ui/slider-lAthKpva.d.ts +2 -0
  38. package/dist/components/ui/switch-D7WzMqgv.d.ts +2 -0
  39. package/dist/components/ui/tabs-CnjGY6eE.d.ts +2 -0
  40. package/dist/components/ui/textarea-BJpu8fK5.d.ts +2 -0
  41. package/dist/components/ui/{tooltip-B05vLa7i.d.ts → tooltip-JdLdCVsY.d.ts} +1 -1
  42. package/dist/{dialog-BeJ4W_wL.d.cts → dialog-a61KKgp5.d.ts} +11 -11
  43. package/dist/{dropdown-menu-pJlZRoLy.d.cts → dropdown-menu-DTRzUFxv.d.ts} +16 -16
  44. package/dist/{file-upload-Cd99SBNZ.d.ts → file-upload-C38U9nyT.d.ts} +11 -11
  45. package/dist/{form-C4ktVmIn.d.ts → form-Cx2k120Z.d.ts} +7 -7
  46. package/dist/{index-DOMvBE84.d.ts → index-2apAhpYW.d.ts} +29 -29
  47. package/dist/{index-fofN1DBY.d.ts → index-B6o0TAoD.d.ts} +7 -7
  48. package/dist/{index-DvlthbVs.d.cts → index-B9p9Ocoz.d.ts} +9 -9
  49. package/dist/{index-VLXQAOef.d.ts → index-fkXKhUlW.d.ts} +13 -13
  50. package/dist/input-DCWzuP_2.d.ts +11 -0
  51. package/dist/{label-FC0f8Usj.d.cts → label-pEqCQKel.d.ts} +2 -2
  52. package/dist/{popover-BX6CaTPU.d.cts → popover-RnfYQfGo.d.ts} +5 -5
  53. package/dist/{radio-group-CcjDx3W6.d.ts → radio-group-BNj4EfLg.d.ts} +3 -3
  54. package/dist/{select-Fa42Z4LL.d.ts → select-B4b-ZC31.d.ts} +11 -11
  55. package/dist/{separator-CfeHjQ3U.d.ts → separator-izY8KL7y.d.ts} +2 -2
  56. package/dist/{sheet-BjXx7ddJ.d.ts → sheet-Dag7L2Xd.d.ts} +9 -9
  57. package/dist/{slider-B3CoyrXu.d.cts → slider-DEUGdZC4.d.ts} +2 -2
  58. package/dist/{switch-B5LyLweM.d.ts → switch-RbFzvnvM.d.ts} +2 -2
  59. package/dist/{tabs-BPdlT-mo.d.ts → tabs-had5ildI.d.ts} +5 -5
  60. package/dist/{textarea-CqY_xh2i.d.cts → textarea-s8H46Zg0.d.ts} +2 -2
  61. package/dist/{tooltip-D1pZ34pY.d.ts → tooltip-CS40su1S.d.ts} +5 -5
  62. package/package.json +1 -1
  63. package/dist/OrContinueWithSeparator-BvzntFX7.cjs +0 -34
  64. package/dist/OrContinueWithSeparator-D_x7OhtS.d.cts +0 -11
  65. package/dist/alert-CwZayX3S.d.ts +0 -24
  66. package/dist/alert-D-l745dk.cjs +0 -57
  67. package/dist/alert-dialog-UlVI8Jfl.d.cts +0 -48
  68. package/dist/avatar-DXl-ag7U.d.ts +0 -19
  69. package/dist/avatar-w_kyvah6.cjs +0 -50
  70. package/dist/badge-3M1AQ3yx.cjs +0 -39
  71. package/dist/badge-_7r9g75U.d.ts +0 -19
  72. package/dist/button-BNmxKjOB.cjs +0 -58
  73. package/dist/button-CESLc3CQ.d.ts +0 -21
  74. package/dist/calendar-CELLMIIj.cjs +0 -119
  75. package/dist/calendar-b33t89Qe.d.ts +0 -26
  76. package/dist/card-C4hKT5Pm.d.cts +0 -34
  77. package/dist/card-Dvch7YjH.cjs +0 -100
  78. package/dist/checkbox-B_9kOHN4.d.ts +0 -11
  79. package/dist/checkbox-DBOuQN-K.cjs +0 -30
  80. package/dist/command-C4R-OiAQ.d.cts +0 -52
  81. package/dist/command-DX6woPdY.cjs +0 -142
  82. package/dist/components/index-IQG8KA86.d.cts +0 -30
  83. package/dist/components/index.cjs +0 -187
  84. package/dist/components/ui/OrContinueWithSeparator-Dvc8cDyM.d.cts +0 -2
  85. package/dist/components/ui/OrContinueWithSeparator.cjs +0 -7
  86. package/dist/components/ui/alert-Byz-rs0N.d.ts +0 -2
  87. package/dist/components/ui/alert-EgfaSBxF.d.cts +0 -2
  88. package/dist/components/ui/alert-dialog-DduTXxp5.d.cts +0 -2
  89. package/dist/components/ui/alert-dialog.cjs +0 -45
  90. package/dist/components/ui/alert.cjs +0 -8
  91. package/dist/components/ui/avatar-C27hFzFH.d.ts +0 -2
  92. package/dist/components/ui/avatar-hpkEskr5.d.cts +0 -2
  93. package/dist/components/ui/avatar.cjs +0 -8
  94. package/dist/components/ui/badge-Bn_Si704.d.ts +0 -2
  95. package/dist/components/ui/badge-KcziaqyK.d.cts +0 -2
  96. package/dist/components/ui/badge.cjs +0 -7
  97. package/dist/components/ui/button-OMnV_24p.d.cts +0 -2
  98. package/dist/components/ui/button.cjs +0 -7
  99. package/dist/components/ui/calendar-BEbds-zF.d.cts +0 -2
  100. package/dist/components/ui/calendar.cjs +0 -8
  101. package/dist/components/ui/card-BDrM5yPN.d.cts +0 -2
  102. package/dist/components/ui/card.cjs +0 -12
  103. package/dist/components/ui/checkbox-0VdiyPZJ.d.ts +0 -2
  104. package/dist/components/ui/checkbox-DAUiq-4T.d.cts +0 -2
  105. package/dist/components/ui/checkbox.cjs +0 -8
  106. package/dist/components/ui/command-DCzWKK9H.d.cts +0 -2
  107. package/dist/components/ui/command.cjs +0 -17
  108. package/dist/components/ui/dialog-BgbuIKOa.d.cts +0 -2
  109. package/dist/components/ui/dialog.cjs +0 -15
  110. package/dist/components/ui/dropdown-menu-BkKMo0ox.d.cts +0 -2
  111. package/dist/components/ui/dropdown-menu.cjs +0 -20
  112. package/dist/components/ui/file-upload-DiSeXl5J.d.cts +0 -2
  113. package/dist/components/ui/file-upload.cjs +0 -28
  114. package/dist/components/ui/form-Ou4AQTb6.d.cts +0 -2
  115. package/dist/components/ui/form.cjs +0 -14
  116. package/dist/components/ui/index-G20FcqoN.d.cts +0 -30
  117. package/dist/components/ui/index.cjs +0 -187
  118. package/dist/components/ui/input-DUQcmWuH.d.cts +0 -2
  119. package/dist/components/ui/input-gUHpQ5sH.d.ts +0 -2
  120. package/dist/components/ui/input.cjs +0 -6
  121. package/dist/components/ui/label-D0-7tdhM.d.ts +0 -2
  122. package/dist/components/ui/label-DimrvHz0.d.cts +0 -2
  123. package/dist/components/ui/label.cjs +0 -6
  124. package/dist/components/ui/pagination-C3bwMwwX.d.cts +0 -2
  125. package/dist/components/ui/pagination.cjs +0 -39
  126. package/dist/components/ui/popover-BMsEOeZk.d.cts +0 -2
  127. package/dist/components/ui/popover.cjs +0 -9
  128. package/dist/components/ui/radio-group-LhGeL5Jq.d.cts +0 -2
  129. package/dist/components/ui/radio-group.cjs +0 -7
  130. package/dist/components/ui/select-DEocx6ny.d.cts +0 -2
  131. package/dist/components/ui/select.cjs +0 -17
  132. package/dist/components/ui/separator-B9ar107P.d.ts +0 -2
  133. package/dist/components/ui/separator-CRHUHLVk.d.cts +0 -2
  134. package/dist/components/ui/separator.cjs +0 -6
  135. package/dist/components/ui/shadcn-io/tags/index-C7ircX0x.d.cts +0 -2
  136. package/dist/components/ui/shadcn-io/tags/index.cjs +0 -21
  137. package/dist/components/ui/shadcn-io/tags-input-inline/index-DpTV34EG.d.cts +0 -2
  138. package/dist/components/ui/shadcn-io/tags-input-inline/index.cjs +0 -10
  139. package/dist/components/ui/sheet-DrTt0RCh.d.cts +0 -2
  140. package/dist/components/ui/sheet.cjs +0 -13
  141. package/dist/components/ui/slider-B_Ct6RDR.d.ts +0 -2
  142. package/dist/components/ui/slider-qhTDbebA.d.cts +0 -2
  143. package/dist/components/ui/slider.cjs +0 -6
  144. package/dist/components/ui/switch-BN9A2aWi.d.ts +0 -2
  145. package/dist/components/ui/switch-D6yB-Ovv.d.cts +0 -2
  146. package/dist/components/ui/switch.cjs +0 -8
  147. package/dist/components/ui/tabs-BThS9Ifx.d.cts +0 -2
  148. package/dist/components/ui/tabs-BXfCBX9q.d.ts +0 -2
  149. package/dist/components/ui/tabs.cjs +0 -9
  150. package/dist/components/ui/textarea-BfSbPfQE.d.ts +0 -2
  151. package/dist/components/ui/textarea-CQzW61Gx.d.cts +0 -2
  152. package/dist/components/ui/textarea.cjs +0 -6
  153. package/dist/components/ui/tooltip-BRCqK0UP.d.cts +0 -2
  154. package/dist/components/ui/tooltip.cjs +0 -9
  155. package/dist/dialog-C1-NCU47.d.ts +0 -47
  156. package/dist/dialog-DFENsfgQ.cjs +0 -149
  157. package/dist/dropdown-menu-B2D2pr52.cjs +0 -216
  158. package/dist/dropdown-menu-CGyKEAjo.d.ts +0 -77
  159. package/dist/file-upload-9q25L_mV.d.cts +0 -94
  160. package/dist/file-upload-DGFPUCSi.cjs +0 -973
  161. package/dist/form-C9YnHr1i.cjs +0 -137
  162. package/dist/form-DHHxQebW.d.cts +0 -45
  163. package/dist/index-B_2R7TER.d.cts +0 -31
  164. package/dist/index-Blt-EW0e.d.cts +0 -31
  165. package/dist/index-Cgz59HyA.d.ts +0 -39
  166. package/dist/index-Ctvuv0vV.d.cts +0 -1
  167. package/dist/index-DxMmAsPK.d.cts +0 -70
  168. package/dist/index.cjs +0 -188
  169. package/dist/input-BGQuRFda.d.ts +0 -11
  170. package/dist/input-BfxJHE4U.cjs +0 -23
  171. package/dist/input-C5RDMgi3.d.cts +0 -11
  172. package/dist/jsx-runtime-BlVTPSwi.cjs +0 -283
  173. package/dist/label-B92w7LNc.cjs +0 -24
  174. package/dist/label-C82lEB8P.d.ts +0 -11
  175. package/dist/lib/index-D0-THr8a.d.cts +0 -2
  176. package/dist/lib/index.cjs +0 -4
  177. package/dist/lib/utils-lNm-CqH0.d.cts +0 -2
  178. package/dist/lib/utils.cjs +0 -3
  179. package/dist/lib-CkvvICiv.cjs +0 -0
  180. package/dist/popover-C7XolifE.d.ts +0 -22
  181. package/dist/popover-CxQjRK9q.cjs +0 -62
  182. package/dist/radio-group-BGPJ_D8q.cjs +0 -43
  183. package/dist/radio-group-oSmZ0ztd.d.cts +0 -15
  184. package/dist/select-BAngGmNL.d.cts +0 -52
  185. package/dist/select-BZfB9A8R.cjs +0 -160
  186. package/dist/separator-3CugGxfw.cjs +0 -26
  187. package/dist/separator-4yrIPr8r.d.cts +0 -13
  188. package/dist/sheet-CHuRM3o6.cjs +0 -133
  189. package/dist/sheet-DP0qGWDN.d.cts +0 -40
  190. package/dist/slider-3-mzOHpV.cjs +0 -45
  191. package/dist/slider-D3ozng9Y.d.ts +0 -15
  192. package/dist/src-Bx8pdty8.cjs +0 -266
  193. package/dist/switch-BIfMlSaF.d.cts +0 -11
  194. package/dist/switch-L23w_mnL.cjs +0 -28
  195. package/dist/tabs-CaKdT_iv.cjs +0 -63
  196. package/dist/tabs-DB6AHtkj.d.cts +0 -23
  197. package/dist/tags-VzxSgWuS.cjs +0 -184
  198. package/dist/tags-input-inline-CNZb7USn.cjs +0 -94
  199. package/dist/textarea-CRkBubLj.cjs +0 -22
  200. package/dist/textarea-_V7biagy.d.ts +0 -10
  201. package/dist/tooltip-C7py127U.d.cts +0 -23
  202. package/dist/tooltip-DelLkXOp.cjs +0 -63
  203. package/dist/utils-DyQCiavd.cjs +0 -16
  204. package/dist/utils-tcGMjZkT.d.cts +0 -6
@@ -1,973 +0,0 @@
1
- const require_jsx_runtime$1 = require('./jsx-runtime-BlVTPSwi.cjs');
2
- const require_utils = require('./utils-DyQCiavd.cjs');
3
- let react = require("react");
4
- react = require_jsx_runtime$1.__toESM(react);
5
- let __radix_ui_react_slot = require("@radix-ui/react-slot");
6
- let lucide_react = require("lucide-react");
7
- let __radix_ui_react_direction = require("@radix-ui/react-direction");
8
-
9
- //#region src/components/ui/file-upload.tsx
10
- var import_jsx_runtime = /* @__PURE__ */ require_jsx_runtime$1.__toESM(require_jsx_runtime$1.require_jsx_runtime());
11
- const ROOT_NAME = "FileUpload";
12
- const DROPZONE_NAME = "FileUploadDropzone";
13
- const TRIGGER_NAME = "FileUploadTrigger";
14
- const LIST_NAME = "FileUploadList";
15
- const ITEM_NAME = "FileUploadItem";
16
- const ITEM_PREVIEW_NAME = "FileUploadItemPreview";
17
- const ITEM_METADATA_NAME = "FileUploadItemMetadata";
18
- const ITEM_PROGRESS_NAME = "FileUploadItemProgress";
19
- const ITEM_DELETE_NAME = "FileUploadItemDelete";
20
- const CLEAR_NAME = "FileUploadClear";
21
- function useLazyRef(fn) {
22
- const ref = react.useRef(null);
23
- if (ref.current === null) ref.current = fn();
24
- return ref;
25
- }
26
- function createStore(listeners, files, urlCache, invalid, onValueChange) {
27
- let state = {
28
- files,
29
- dragOver: false,
30
- invalid
31
- };
32
- function reducer(state$1, action) {
33
- switch (action.type) {
34
- case "ADD_FILES":
35
- for (const file of action.files) files.set(file, {
36
- file,
37
- progress: 0,
38
- status: "idle"
39
- });
40
- if (onValueChange) onValueChange(Array.from(files.values()).map((fileState) => fileState.file));
41
- return {
42
- ...state$1,
43
- files
44
- };
45
- case "SET_FILES": {
46
- const newFileSet = new Set(action.files);
47
- for (const existingFile of files.keys()) if (!newFileSet.has(existingFile)) files.delete(existingFile);
48
- for (const file of action.files) if (!files.get(file)) files.set(file, {
49
- file,
50
- progress: 0,
51
- status: "idle"
52
- });
53
- return {
54
- ...state$1,
55
- files
56
- };
57
- }
58
- case "SET_PROGRESS": {
59
- const fileState = files.get(action.file);
60
- if (fileState) files.set(action.file, {
61
- ...fileState,
62
- progress: action.progress,
63
- status: "uploading"
64
- });
65
- return {
66
- ...state$1,
67
- files
68
- };
69
- }
70
- case "SET_SUCCESS": {
71
- const fileState = files.get(action.file);
72
- if (fileState) files.set(action.file, {
73
- ...fileState,
74
- progress: 100,
75
- status: "success"
76
- });
77
- return {
78
- ...state$1,
79
- files
80
- };
81
- }
82
- case "SET_ERROR": {
83
- const fileState = files.get(action.file);
84
- if (fileState) files.set(action.file, {
85
- ...fileState,
86
- error: action.error,
87
- status: "error"
88
- });
89
- return {
90
- ...state$1,
91
- files
92
- };
93
- }
94
- case "REMOVE_FILE":
95
- if (urlCache) {
96
- const cachedUrl = urlCache.get(action.file);
97
- if (cachedUrl) {
98
- URL.revokeObjectURL(cachedUrl);
99
- urlCache.delete(action.file);
100
- }
101
- }
102
- files.delete(action.file);
103
- if (onValueChange) onValueChange(Array.from(files.values()).map((fileState) => fileState.file));
104
- return {
105
- ...state$1,
106
- files
107
- };
108
- case "SET_DRAG_OVER": return {
109
- ...state$1,
110
- dragOver: action.dragOver
111
- };
112
- case "SET_INVALID": return {
113
- ...state$1,
114
- invalid: action.invalid
115
- };
116
- case "CLEAR":
117
- if (urlCache) for (const file of files.keys()) {
118
- const cachedUrl = urlCache.get(file);
119
- if (cachedUrl) {
120
- URL.revokeObjectURL(cachedUrl);
121
- urlCache.delete(file);
122
- }
123
- }
124
- files.clear();
125
- if (onValueChange) onValueChange([]);
126
- return {
127
- ...state$1,
128
- files,
129
- invalid: false
130
- };
131
- default: return state$1;
132
- }
133
- }
134
- function getState() {
135
- return state;
136
- }
137
- function dispatch(action) {
138
- state = reducer(state, action);
139
- for (const listener of listeners) listener();
140
- }
141
- function subscribe(listener) {
142
- listeners.add(listener);
143
- return () => listeners.delete(listener);
144
- }
145
- return {
146
- getState,
147
- dispatch,
148
- subscribe
149
- };
150
- }
151
- const StoreContext = react.createContext(null);
152
- function useStoreContext(consumerName) {
153
- const context = react.use(StoreContext);
154
- if (!context) throw new Error(`\`${consumerName}\` must be used within \`${ROOT_NAME}\``);
155
- return context;
156
- }
157
- function useStore(selector) {
158
- const store = useStoreContext("useStore");
159
- const lastValueRef = useLazyRef(() => null);
160
- const getSnapshot = react.useCallback(() => {
161
- const state = store.getState();
162
- const prevValue = lastValueRef.current;
163
- if (prevValue && prevValue.state === state) return prevValue.value;
164
- const nextValue = selector(state);
165
- lastValueRef.current = {
166
- value: nextValue,
167
- state
168
- };
169
- return nextValue;
170
- }, [
171
- store,
172
- selector,
173
- lastValueRef
174
- ]);
175
- return react.useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
176
- }
177
- const FileUploadContext = react.createContext(null);
178
- function useFileUploadContext(consumerName) {
179
- const context = react.use(FileUploadContext);
180
- if (!context) throw new Error(`\`${consumerName}\` must be used within \`${ROOT_NAME}\``);
181
- return context;
182
- }
183
- function FileUploadRoot(props) {
184
- const { value, defaultValue, onValueChange, onAccept, onFileAccept, onFileReject, onFilesReject, onFileValidate, onUpload, accept, maxFiles, maxSize, dir: dirProp, label, name, asChild, disabled = false, invalid = false, multiple = false, required = false, children, className, ...rootProps } = props;
185
- const inputId = react.useId();
186
- const dropzoneId = react.useId();
187
- const listId = react.useId();
188
- const labelId = react.useId();
189
- const dir = (0, __radix_ui_react_direction.useDirection)(dirProp);
190
- const listeners = useLazyRef(() => /* @__PURE__ */ new Set()).current;
191
- const files = useLazyRef(() => /* @__PURE__ */ new Map()).current;
192
- const urlCache = useLazyRef(() => /* @__PURE__ */ new WeakMap()).current;
193
- const inputRef = react.useRef(null);
194
- const isControlled = value !== void 0;
195
- const store = react.useMemo(() => createStore(listeners, files, urlCache, invalid, onValueChange), [
196
- listeners,
197
- files,
198
- invalid,
199
- onValueChange,
200
- urlCache
201
- ]);
202
- const acceptTypes = react.useMemo(() => accept?.split(",").map((t) => t.trim()) ?? null, [accept]);
203
- const onProgress = useLazyRef(() => {
204
- let frame = 0;
205
- return (file, progress) => {
206
- if (frame) return;
207
- frame = requestAnimationFrame(() => {
208
- frame = 0;
209
- store.dispatch({
210
- type: "SET_PROGRESS",
211
- file,
212
- progress: Math.min(Math.max(0, progress), 100)
213
- });
214
- });
215
- };
216
- }).current;
217
- react.useEffect(() => {
218
- if (isControlled) store.dispatch({
219
- type: "SET_FILES",
220
- files: value
221
- });
222
- else if (defaultValue && defaultValue.length > 0 && !store.getState().files.size) store.dispatch({
223
- type: "SET_FILES",
224
- files: defaultValue
225
- });
226
- }, [
227
- value,
228
- defaultValue,
229
- isControlled,
230
- store
231
- ]);
232
- react.useEffect(() => {
233
- return () => {
234
- for (const file of files.keys()) {
235
- const cachedUrl = urlCache.get(file);
236
- if (cachedUrl) URL.revokeObjectURL(cachedUrl);
237
- }
238
- };
239
- }, [files, urlCache]);
240
- const onFilesUpload = react.useCallback(async (files$1) => {
241
- try {
242
- for (const file of files$1) store.dispatch({
243
- type: "SET_PROGRESS",
244
- file,
245
- progress: 0
246
- });
247
- if (onUpload) await onUpload(files$1, {
248
- onProgress,
249
- onSuccess: (file) => {
250
- store.dispatch({
251
- type: "SET_SUCCESS",
252
- file
253
- });
254
- },
255
- onError: (file, error) => {
256
- store.dispatch({
257
- type: "SET_ERROR",
258
- file,
259
- error: error.message ?? "Upload failed"
260
- });
261
- }
262
- });
263
- else for (const file of files$1) store.dispatch({
264
- type: "SET_SUCCESS",
265
- file
266
- });
267
- } catch (error) {
268
- const errorMessage = error instanceof Error ? error.message : "Upload failed";
269
- for (const file of files$1) store.dispatch({
270
- type: "SET_ERROR",
271
- file,
272
- error: errorMessage
273
- });
274
- }
275
- }, [
276
- store,
277
- onUpload,
278
- onProgress
279
- ]);
280
- const onFilesChange = react.useCallback((originalFiles) => {
281
- if (disabled) return;
282
- let filesToProcess = [...originalFiles];
283
- let invalid$1 = false;
284
- const allRejectedFiles = [];
285
- if (maxFiles) {
286
- const currentCount = store.getState().files.size;
287
- const remainingSlotCount = Math.max(0, maxFiles - currentCount);
288
- if (remainingSlotCount < filesToProcess.length) {
289
- const rejectedFromMaxFiles = filesToProcess.slice(remainingSlotCount);
290
- invalid$1 = true;
291
- filesToProcess = filesToProcess.slice(0, remainingSlotCount);
292
- for (const file of rejectedFromMaxFiles) {
293
- let rejectionMessage = `Maximum ${maxFiles} files allowed`;
294
- if (onFileValidate) {
295
- const validationMessage = onFileValidate(file);
296
- if (validationMessage) rejectionMessage = validationMessage;
297
- }
298
- onFileReject?.(file, rejectionMessage);
299
- allRejectedFiles.push({
300
- file,
301
- message: rejectionMessage
302
- });
303
- }
304
- }
305
- }
306
- const acceptedFiles = [];
307
- const rejectedFiles = [];
308
- for (const file of filesToProcess) {
309
- let rejected = false;
310
- let rejectionMessage = "";
311
- if (onFileValidate) {
312
- const validationMessage = onFileValidate(file);
313
- if (validationMessage) {
314
- rejectionMessage = validationMessage;
315
- onFileReject?.(file, rejectionMessage);
316
- rejected = true;
317
- invalid$1 = true;
318
- continue;
319
- }
320
- }
321
- if (acceptTypes) {
322
- const fileType = file.type;
323
- const fileExtension = `.${file.name.split(".").pop()}`;
324
- if (!acceptTypes.some((type) => type === fileType || type === fileExtension || type.includes("/*") && fileType.startsWith(type.replace("/*", "/")))) {
325
- rejectionMessage = "File type not accepted";
326
- onFileReject?.(file, rejectionMessage);
327
- rejected = true;
328
- invalid$1 = true;
329
- }
330
- }
331
- if (maxSize && file.size > maxSize) {
332
- rejectionMessage = "File too large";
333
- onFileReject?.(file, rejectionMessage);
334
- rejected = true;
335
- invalid$1 = true;
336
- }
337
- if (!rejected) acceptedFiles.push(file);
338
- else rejectedFiles.push({
339
- file,
340
- message: rejectionMessage
341
- });
342
- }
343
- allRejectedFiles.push(...rejectedFiles);
344
- if (invalid$1) {
345
- store.dispatch({
346
- type: "SET_INVALID",
347
- invalid: invalid$1
348
- });
349
- setTimeout(() => {
350
- store.dispatch({
351
- type: "SET_INVALID",
352
- invalid: false
353
- });
354
- }, 2e3);
355
- }
356
- if (allRejectedFiles.length > 0) onFilesReject?.(allRejectedFiles);
357
- if (acceptedFiles.length > 0) {
358
- store.dispatch({
359
- type: "ADD_FILES",
360
- files: acceptedFiles
361
- });
362
- if (isControlled && onValueChange) onValueChange([...Array.from(store.getState().files.values()).map((f) => f.file)]);
363
- if (onAccept) onAccept(acceptedFiles);
364
- for (const file of acceptedFiles) onFileAccept?.(file);
365
- if (onUpload) requestAnimationFrame(() => {
366
- onFilesUpload(acceptedFiles);
367
- });
368
- }
369
- }, [
370
- store,
371
- isControlled,
372
- onValueChange,
373
- onAccept,
374
- onFileAccept,
375
- onUpload,
376
- onFilesUpload,
377
- maxFiles,
378
- onFileValidate,
379
- onFileReject,
380
- onFilesReject,
381
- acceptTypes,
382
- maxSize,
383
- disabled
384
- ]);
385
- const onInputChange = react.useCallback((event) => {
386
- onFilesChange(Array.from(event.target.files ?? []));
387
- event.target.value = "";
388
- }, [onFilesChange]);
389
- const contextValue = react.useMemo(() => ({
390
- dropzoneId,
391
- inputId,
392
- listId,
393
- labelId,
394
- dir,
395
- disabled,
396
- inputRef,
397
- urlCache
398
- }), [
399
- dropzoneId,
400
- inputId,
401
- listId,
402
- labelId,
403
- dir,
404
- disabled,
405
- urlCache
406
- ]);
407
- const RootPrimitive = asChild ? __radix_ui_react_slot.Slot : "div";
408
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StoreContext.Provider, {
409
- value: store,
410
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FileUploadContext.Provider, {
411
- value: contextValue,
412
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(RootPrimitive, {
413
- "data-disabled": disabled ? "" : void 0,
414
- "data-slot": "file-upload",
415
- dir,
416
- ...rootProps,
417
- className: require_utils.cn("relative flex flex-col gap-2", className),
418
- children: [
419
- children,
420
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
421
- type: "file",
422
- id: inputId,
423
- "aria-labelledby": labelId,
424
- "aria-describedby": dropzoneId,
425
- ref: inputRef,
426
- tabIndex: -1,
427
- accept,
428
- name,
429
- className: "sr-only",
430
- disabled,
431
- multiple,
432
- required,
433
- onChange: onInputChange
434
- }),
435
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
436
- id: labelId,
437
- className: "sr-only",
438
- children: label ?? "File upload"
439
- })
440
- ]
441
- })
442
- })
443
- });
444
- }
445
- function FileUploadDropzone(props) {
446
- const { asChild, className, onClick: onClickProp, onDragOver: onDragOverProp, onDragEnter: onDragEnterProp, onDragLeave: onDragLeaveProp, onDrop: onDropProp, onPaste: onPasteProp, onKeyDown: onKeyDownProp, ...dropzoneProps } = props;
447
- const context = useFileUploadContext(DROPZONE_NAME);
448
- const store = useStoreContext(DROPZONE_NAME);
449
- const dragOver = useStore((state) => state.dragOver);
450
- const invalid = useStore((state) => state.invalid);
451
- const onClick = react.useCallback((event) => {
452
- onClickProp?.(event);
453
- if (event.defaultPrevented) return;
454
- const { target } = event;
455
- if (!(target instanceof HTMLElement && target.closest("[data-slot=\"file-upload-trigger\"]"))) context.inputRef.current?.click();
456
- }, [context.inputRef, onClickProp]);
457
- const onDragOver = react.useCallback((event) => {
458
- onDragOverProp?.(event);
459
- if (event.defaultPrevented) return;
460
- event.preventDefault();
461
- store.dispatch({
462
- type: "SET_DRAG_OVER",
463
- dragOver: true
464
- });
465
- }, [store, onDragOverProp]);
466
- const onDragEnter = react.useCallback((event) => {
467
- onDragEnterProp?.(event);
468
- if (event.defaultPrevented) return;
469
- event.preventDefault();
470
- store.dispatch({
471
- type: "SET_DRAG_OVER",
472
- dragOver: true
473
- });
474
- }, [store, onDragEnterProp]);
475
- const onDragLeave = react.useCallback((event) => {
476
- onDragLeaveProp?.(event);
477
- if (event.defaultPrevented) return;
478
- const { relatedTarget } = event;
479
- if (relatedTarget && relatedTarget instanceof Node && event.currentTarget.contains(relatedTarget)) return;
480
- event.preventDefault();
481
- store.dispatch({
482
- type: "SET_DRAG_OVER",
483
- dragOver: false
484
- });
485
- }, [store, onDragLeaveProp]);
486
- const onDrop = react.useCallback((event) => {
487
- onDropProp?.(event);
488
- if (event.defaultPrevented) return;
489
- event.preventDefault();
490
- store.dispatch({
491
- type: "SET_DRAG_OVER",
492
- dragOver: false
493
- });
494
- const files = Array.from(event.dataTransfer.files);
495
- const inputElement = context.inputRef.current;
496
- if (!inputElement) return;
497
- const dataTransfer = new DataTransfer();
498
- for (const file of files) dataTransfer.items.add(file);
499
- inputElement.files = dataTransfer.files;
500
- inputElement.dispatchEvent(new Event("change", { bubbles: true }));
501
- }, [
502
- store,
503
- context.inputRef,
504
- onDropProp
505
- ]);
506
- const onPaste = react.useCallback((event) => {
507
- onPasteProp?.(event);
508
- if (event.defaultPrevented) return;
509
- event.preventDefault();
510
- store.dispatch({
511
- type: "SET_DRAG_OVER",
512
- dragOver: false
513
- });
514
- const items = event.clipboardData?.items;
515
- if (!items) return;
516
- const files = [];
517
- for (let i = 0; i < items.length; i++) {
518
- const item = items[i];
519
- if (item?.kind === "file") {
520
- const file = item.getAsFile();
521
- if (file) files.push(file);
522
- }
523
- }
524
- if (files.length === 0) return;
525
- const inputElement = context.inputRef.current;
526
- if (!inputElement) return;
527
- const dataTransfer = new DataTransfer();
528
- for (const file of files) dataTransfer.items.add(file);
529
- inputElement.files = dataTransfer.files;
530
- inputElement.dispatchEvent(new Event("change", { bubbles: true }));
531
- }, [
532
- store,
533
- context.inputRef,
534
- onPasteProp
535
- ]);
536
- const onKeyDown = react.useCallback((event) => {
537
- onKeyDownProp?.(event);
538
- if (!event.defaultPrevented && (event.key === "Enter" || event.key === " ")) {
539
- event.preventDefault();
540
- context.inputRef.current?.click();
541
- }
542
- }, [context.inputRef, onKeyDownProp]);
543
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(asChild ? __radix_ui_react_slot.Slot : "div", {
544
- role: "region",
545
- id: context.dropzoneId,
546
- "aria-controls": `${context.inputId} ${context.listId}`,
547
- "aria-disabled": context.disabled,
548
- "aria-invalid": invalid,
549
- "data-disabled": context.disabled ? "" : void 0,
550
- "data-dragging": dragOver ? "" : void 0,
551
- "data-invalid": invalid ? "" : void 0,
552
- "data-slot": "file-upload-dropzone",
553
- dir: context.dir,
554
- tabIndex: context.disabled ? void 0 : 0,
555
- ...dropzoneProps,
556
- className: require_utils.cn("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", className),
557
- onClick,
558
- onDragEnter,
559
- onDragLeave,
560
- onDragOver,
561
- onDrop,
562
- onKeyDown,
563
- onPaste
564
- });
565
- }
566
- function FileUploadTrigger(props) {
567
- const { asChild, onClick: onClickProp, ...triggerProps } = props;
568
- const context = useFileUploadContext(TRIGGER_NAME);
569
- const onClick = react.useCallback((event) => {
570
- onClickProp?.(event);
571
- if (event.defaultPrevented) return;
572
- context.inputRef.current?.click();
573
- }, [context.inputRef, onClickProp]);
574
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(asChild ? __radix_ui_react_slot.Slot : "button", {
575
- type: "button",
576
- "aria-controls": context.inputId,
577
- "data-disabled": context.disabled ? "" : void 0,
578
- "data-slot": "file-upload-trigger",
579
- ...triggerProps,
580
- disabled: context.disabled,
581
- onClick
582
- });
583
- }
584
- function FileUploadList(props) {
585
- const { className, orientation = "vertical", asChild, forceMount, ...listProps } = props;
586
- const context = useFileUploadContext(LIST_NAME);
587
- const fileCount = useStore((state) => state.files.size);
588
- const shouldRender = forceMount || fileCount > 0;
589
- if (!shouldRender) return null;
590
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(asChild ? __radix_ui_react_slot.Slot : "div", {
591
- role: "list",
592
- id: context.listId,
593
- "aria-orientation": orientation,
594
- "data-orientation": orientation,
595
- "data-slot": "file-upload-list",
596
- "data-state": shouldRender ? "active" : "inactive",
597
- dir: context.dir,
598
- ...listProps,
599
- className: require_utils.cn("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", orientation === "horizontal" && "flex-row overflow-x-auto p-1.5", className)
600
- });
601
- }
602
- const FileUploadItemContext = react.createContext(null);
603
- function useFileUploadItemContext(consumerName) {
604
- const context = react.use(FileUploadItemContext);
605
- if (!context) throw new Error(`\`${consumerName}\` must be used within \`${ITEM_NAME}\``);
606
- return context;
607
- }
608
- function FileUploadItem(props) {
609
- const { value, asChild, className, ...itemProps } = props;
610
- const id = react.useId();
611
- const statusId = `${id}-status`;
612
- const nameId = `${id}-name`;
613
- const sizeId = `${id}-size`;
614
- const messageId = `${id}-message`;
615
- const context = useFileUploadContext(ITEM_NAME);
616
- const fileState = useStore((state) => state.files.get(value));
617
- const fileCount = useStore((state) => state.files.size);
618
- const fileIndex = useStore((state) => {
619
- return Array.from(state.files.keys()).indexOf(value) + 1;
620
- });
621
- const itemContext = react.useMemo(() => ({
622
- id,
623
- fileState,
624
- nameId,
625
- sizeId,
626
- statusId,
627
- messageId
628
- }), [
629
- id,
630
- fileState,
631
- statusId,
632
- nameId,
633
- sizeId,
634
- messageId
635
- ]);
636
- if (!fileState) return null;
637
- const statusText = fileState.error ? `Error: ${fileState.error}` : fileState.status === "uploading" ? `Uploading: ${fileState.progress}% complete` : fileState.status === "success" ? "Upload complete" : "Ready to upload";
638
- const ItemPrimitive = asChild ? __radix_ui_react_slot.Slot : "div";
639
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FileUploadItemContext.Provider, {
640
- value: itemContext,
641
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ItemPrimitive, {
642
- role: "listitem",
643
- id,
644
- "aria-setsize": fileCount,
645
- "aria-posinset": fileIndex,
646
- "aria-describedby": `${nameId} ${sizeId} ${statusId} ${fileState.error ? messageId : ""}`,
647
- "aria-labelledby": nameId,
648
- "data-slot": "file-upload-item",
649
- dir: context.dir,
650
- ...itemProps,
651
- className: require_utils.cn("relative flex items-center rounded-md border p-3", className),
652
- children: [props.children, /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
653
- id: statusId,
654
- className: "sr-only",
655
- children: statusText
656
- })]
657
- })
658
- });
659
- }
660
- function formatBytes(bytes) {
661
- if (bytes === 0) return "0 B";
662
- const sizes = [
663
- "B",
664
- "KB",
665
- "MB",
666
- "GB",
667
- "TB"
668
- ];
669
- const i = Math.floor(Math.log(bytes) / Math.log(1024));
670
- return `${(bytes / 1024 ** i).toFixed(i ? 1 : 0)} ${sizes[i]}`;
671
- }
672
- function getFileIcon(file) {
673
- const { type } = file;
674
- const extension = file.name.split(".").pop()?.toLowerCase() ?? "";
675
- if (type.startsWith("video/")) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucide_react.FileVideoIcon, {});
676
- if (type.startsWith("audio/")) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucide_react.FileAudioIcon, {});
677
- if (type.startsWith("text/") || [
678
- "txt",
679
- "md",
680
- "rtf",
681
- "pdf"
682
- ].includes(extension)) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucide_react.FileTextIcon, {});
683
- if ([
684
- "html",
685
- "css",
686
- "js",
687
- "jsx",
688
- "ts",
689
- "tsx",
690
- "json",
691
- "xml",
692
- "php",
693
- "py",
694
- "rb",
695
- "java",
696
- "c",
697
- "cpp",
698
- "cs"
699
- ].includes(extension)) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucide_react.FileCodeIcon, {});
700
- if ([
701
- "zip",
702
- "rar",
703
- "7z",
704
- "tar",
705
- "gz",
706
- "bz2"
707
- ].includes(extension)) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucide_react.FileArchiveIcon, {});
708
- if ([
709
- "exe",
710
- "msi",
711
- "app",
712
- "apk",
713
- "deb",
714
- "rpm"
715
- ].includes(extension) || type.startsWith("application/")) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucide_react.FileCogIcon, {});
716
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucide_react.FileIcon, {});
717
- }
718
- function FileUploadItemPreview(props) {
719
- const { render, asChild, children, className, ...previewProps } = props;
720
- const itemContext = useFileUploadItemContext(ITEM_PREVIEW_NAME);
721
- const context = useFileUploadContext(ITEM_PREVIEW_NAME);
722
- const getDefaultRender = react.useCallback((file) => {
723
- if (itemContext.fileState?.file.type.startsWith("image/")) {
724
- let url = context.urlCache.get(file);
725
- if (!url) {
726
- url = URL.createObjectURL(file);
727
- context.urlCache.set(file, url);
728
- }
729
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
730
- src: url,
731
- alt: file.name,
732
- className: "size-full object-cover"
733
- });
734
- }
735
- return getFileIcon(file);
736
- }, [itemContext.fileState?.file.type, context.urlCache]);
737
- const onPreviewRender = react.useCallback(async (file) => {
738
- if (render) return render(file, () => getDefaultRender(file));
739
- return getDefaultRender(file);
740
- }, [render, getDefaultRender]);
741
- if (!itemContext.fileState) return null;
742
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(asChild ? __radix_ui_react_slot.Slot : "div", {
743
- "aria-labelledby": itemContext.nameId,
744
- "data-slot": "file-upload-preview",
745
- ...previewProps,
746
- className: require_utils.cn("relative flex size-10 shrink-0 items-center justify-center overflow-hidden rounded border bg-accent/50 [&>svg]:size-10", className),
747
- children: [onPreviewRender(itemContext.fileState.file), children]
748
- });
749
- }
750
- function FileUploadItemMetadata(props) {
751
- const { asChild, size = "default", children, className, ...metadataProps } = props;
752
- const context = useFileUploadContext(ITEM_METADATA_NAME);
753
- const itemContext = useFileUploadItemContext(ITEM_METADATA_NAME);
754
- if (!itemContext.fileState) return null;
755
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(asChild ? __radix_ui_react_slot.Slot : "div", {
756
- "data-slot": "file-upload-metadata",
757
- dir: context.dir,
758
- ...metadataProps,
759
- className: require_utils.cn("flex min-w-0 flex-1 flex-col", className),
760
- children: children ?? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
761
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
762
- id: itemContext.nameId,
763
- className: require_utils.cn("truncate font-medium text-sm", size === "sm" && "font-normal text-[13px] leading-snug"),
764
- children: itemContext.fileState.file.name
765
- }),
766
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
767
- id: itemContext.sizeId,
768
- className: require_utils.cn("truncate text-muted-foreground text-xs", size === "sm" && "text-[11px] leading-snug"),
769
- children: formatBytes(itemContext.fileState.file.size)
770
- }),
771
- itemContext.fileState.error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
772
- id: itemContext.messageId,
773
- className: "text-destructive text-xs",
774
- children: itemContext.fileState.error
775
- })
776
- ] })
777
- });
778
- }
779
- function FileUploadItemProgress(props) {
780
- const { variant = "linear", size = 40, asChild, forceMount, className, ...progressProps } = props;
781
- const itemContext = useFileUploadItemContext(ITEM_PROGRESS_NAME);
782
- if (!itemContext.fileState) return null;
783
- if (!(forceMount || itemContext.fileState.progress !== 100)) return null;
784
- const ItemProgressPrimitive = asChild ? __radix_ui_react_slot.Slot : "div";
785
- switch (variant) {
786
- case "circular": {
787
- const circumference = 2 * Math.PI * ((size - 4) / 2);
788
- const strokeDashoffset = circumference - itemContext.fileState.progress / 100 * circumference;
789
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemProgressPrimitive, {
790
- role: "progressbar",
791
- "aria-valuemin": 0,
792
- "aria-valuemax": 100,
793
- "aria-valuenow": itemContext.fileState.progress,
794
- "aria-valuetext": `${itemContext.fileState.progress}%`,
795
- "aria-labelledby": itemContext.nameId,
796
- "data-slot": "file-upload-progress",
797
- ...progressProps,
798
- className: require_utils.cn("-translate-x-1/2 -translate-y-1/2 absolute top-1/2 left-1/2", className),
799
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
800
- className: "-rotate-90 transform",
801
- width: size,
802
- height: size,
803
- viewBox: `0 0 ${size} ${size}`,
804
- fill: "none",
805
- stroke: "currentColor",
806
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", {
807
- className: "text-primary/20",
808
- strokeWidth: "2",
809
- cx: size / 2,
810
- cy: size / 2,
811
- r: (size - 4) / 2
812
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", {
813
- className: "text-primary transition-[stroke-dashoffset] duration-300 ease-linear",
814
- strokeWidth: "2",
815
- strokeLinecap: "round",
816
- strokeDasharray: circumference,
817
- strokeDashoffset,
818
- cx: size / 2,
819
- cy: size / 2,
820
- r: (size - 4) / 2
821
- })]
822
- })
823
- });
824
- }
825
- case "fill": {
826
- const progressPercentage = itemContext.fileState.progress;
827
- const topInset = 100 - progressPercentage;
828
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemProgressPrimitive, {
829
- role: "progressbar",
830
- "aria-valuemin": 0,
831
- "aria-valuemax": 100,
832
- "aria-valuenow": progressPercentage,
833
- "aria-valuetext": `${progressPercentage}%`,
834
- "aria-labelledby": itemContext.nameId,
835
- "data-slot": "file-upload-progress",
836
- ...progressProps,
837
- className: require_utils.cn("absolute inset-0 bg-primary/50 transition-[clip-path] duration-300 ease-linear", className),
838
- style: { clipPath: `inset(${topInset}% 0% 0% 0%)` }
839
- });
840
- }
841
- default: return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemProgressPrimitive, {
842
- role: "progressbar",
843
- "aria-valuemin": 0,
844
- "aria-valuemax": 100,
845
- "aria-valuenow": itemContext.fileState.progress,
846
- "aria-valuetext": `${itemContext.fileState.progress}%`,
847
- "aria-labelledby": itemContext.nameId,
848
- "data-slot": "file-upload-progress",
849
- ...progressProps,
850
- className: require_utils.cn("relative h-1.5 w-full overflow-hidden rounded-full bg-primary/20", className),
851
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
852
- className: "h-full w-full flex-1 bg-primary transition-transform duration-300 ease-linear",
853
- style: { transform: `translateX(-${100 - itemContext.fileState.progress}%)` }
854
- })
855
- });
856
- }
857
- }
858
- function FileUploadItemDelete(props) {
859
- const { asChild, onClick: onClickProp, ...deleteProps } = props;
860
- const store = useStoreContext(ITEM_DELETE_NAME);
861
- const itemContext = useFileUploadItemContext(ITEM_DELETE_NAME);
862
- const onClick = react.useCallback((event) => {
863
- onClickProp?.(event);
864
- if (!itemContext.fileState || event.defaultPrevented) return;
865
- store.dispatch({
866
- type: "REMOVE_FILE",
867
- file: itemContext.fileState.file
868
- });
869
- }, [
870
- store,
871
- itemContext.fileState,
872
- onClickProp
873
- ]);
874
- if (!itemContext.fileState) return null;
875
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(asChild ? __radix_ui_react_slot.Slot : "button", {
876
- type: "button",
877
- "aria-controls": itemContext.id,
878
- "aria-describedby": itemContext.nameId,
879
- "data-slot": "file-upload-item-delete",
880
- ...deleteProps,
881
- onClick
882
- });
883
- }
884
- function FileUploadClear(props) {
885
- const { asChild, forceMount, disabled, onClick: onClickProp, ...clearProps } = props;
886
- const context = useFileUploadContext(CLEAR_NAME);
887
- const store = useStoreContext(CLEAR_NAME);
888
- const fileCount = useStore((state) => state.files.size);
889
- const isDisabled = disabled || context.disabled;
890
- const onClick = react.useCallback((event) => {
891
- onClickProp?.(event);
892
- if (event.defaultPrevented) return;
893
- store.dispatch({ type: "CLEAR" });
894
- }, [store, onClickProp]);
895
- if (!(forceMount || fileCount > 0)) return null;
896
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(asChild ? __radix_ui_react_slot.Slot : "button", {
897
- type: "button",
898
- "aria-controls": context.listId,
899
- "data-slot": "file-upload-clear",
900
- "data-disabled": isDisabled ? "" : void 0,
901
- ...clearProps,
902
- disabled: isDisabled,
903
- onClick
904
- });
905
- }
906
-
907
- //#endregion
908
- Object.defineProperty(exports, 'FileUploadClear', {
909
- enumerable: true,
910
- get: function () {
911
- return FileUploadClear;
912
- }
913
- });
914
- Object.defineProperty(exports, 'FileUploadDropzone', {
915
- enumerable: true,
916
- get: function () {
917
- return FileUploadDropzone;
918
- }
919
- });
920
- Object.defineProperty(exports, 'FileUploadItem', {
921
- enumerable: true,
922
- get: function () {
923
- return FileUploadItem;
924
- }
925
- });
926
- Object.defineProperty(exports, 'FileUploadItemDelete', {
927
- enumerable: true,
928
- get: function () {
929
- return FileUploadItemDelete;
930
- }
931
- });
932
- Object.defineProperty(exports, 'FileUploadItemMetadata', {
933
- enumerable: true,
934
- get: function () {
935
- return FileUploadItemMetadata;
936
- }
937
- });
938
- Object.defineProperty(exports, 'FileUploadItemPreview', {
939
- enumerable: true,
940
- get: function () {
941
- return FileUploadItemPreview;
942
- }
943
- });
944
- Object.defineProperty(exports, 'FileUploadItemProgress', {
945
- enumerable: true,
946
- get: function () {
947
- return FileUploadItemProgress;
948
- }
949
- });
950
- Object.defineProperty(exports, 'FileUploadList', {
951
- enumerable: true,
952
- get: function () {
953
- return FileUploadList;
954
- }
955
- });
956
- Object.defineProperty(exports, 'FileUploadRoot', {
957
- enumerable: true,
958
- get: function () {
959
- return FileUploadRoot;
960
- }
961
- });
962
- Object.defineProperty(exports, 'FileUploadTrigger', {
963
- enumerable: true,
964
- get: function () {
965
- return FileUploadTrigger;
966
- }
967
- });
968
- Object.defineProperty(exports, 'useStore', {
969
- enumerable: true,
970
- get: function () {
971
- return useStore;
972
- }
973
- });