@startdownnotez404/ui 1.3.5 → 1.3.6

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 (254) hide show
  1. package/dist/AutocompleteField-653233JU.mjs +203 -0
  2. package/dist/AutocompleteField-653233JU.mjs.map +1 -0
  3. package/dist/AvatarField-KFASMVZU.mjs +378 -0
  4. package/dist/AvatarField-KFASMVZU.mjs.map +1 -0
  5. package/dist/{DateField-ZYMZFHL4.mjs → DateField-CDJ6W6XF.mjs} +19 -7
  6. package/dist/DateField-CDJ6W6XF.mjs.map +1 -0
  7. package/dist/DateRangeField-ZWSFT5KV.mjs +118 -0
  8. package/dist/DateRangeField-ZWSFT5KV.mjs.map +1 -0
  9. package/dist/{DateTimeField-TPTJ7YIZ.mjs → DateTimeField-SFAF4I6A.mjs} +36 -11
  10. package/dist/DateTimeField-SFAF4I6A.mjs.map +1 -0
  11. package/dist/FileUploadField-TSNCSLXX.mjs +101 -0
  12. package/dist/FileUploadField-TSNCSLXX.mjs.map +1 -0
  13. package/dist/{JSONEditorField-TMRWGXVR.mjs → JSONEditorField-3KXC2GOG.mjs} +7 -6
  14. package/dist/{JSONEditorField-TMRWGXVR.mjs.map → JSONEditorField-3KXC2GOG.mjs.map} +1 -1
  15. package/dist/{PopperMenu-LJ36RPBW.mjs → PopperMenu-PSHLKIEZ.mjs} +26 -12
  16. package/dist/{PopperMenu-LJ36RPBW.mjs.map → PopperMenu-PSHLKIEZ.mjs.map} +1 -1
  17. package/dist/{TelField-LOGRVZ4I.mjs → TelField-FRQT2UBJ.mjs} +8 -7
  18. package/dist/{TelField-LOGRVZ4I.mjs.map → TelField-FRQT2UBJ.mjs.map} +1 -1
  19. package/dist/TimeField-XVWXBJID.mjs +94 -0
  20. package/dist/TimeField-XVWXBJID.mjs.map +1 -0
  21. package/dist/alert.d.mts +148 -18
  22. package/dist/alert.d.ts +148 -18
  23. package/dist/alert.js +698 -254
  24. package/dist/alert.js.map +1 -1
  25. package/dist/alert.mjs +46 -10
  26. package/dist/autocomplete.d.mts +438 -4
  27. package/dist/autocomplete.d.ts +438 -4
  28. package/dist/autocomplete.js +632 -21
  29. package/dist/autocomplete.js.map +1 -1
  30. package/dist/autocomplete.mjs +26 -7
  31. package/dist/avatar.js +2 -1
  32. package/dist/avatar.js.map +1 -1
  33. package/dist/avatar.mjs +12 -11
  34. package/dist/box.mjs +2 -1
  35. package/dist/button.mjs +3 -2
  36. package/dist/chart.mjs +3 -2
  37. package/dist/checkbox.mjs +3 -2
  38. package/dist/chunk-2FK24ZPJ.mjs +78 -0
  39. package/dist/chunk-2FK24ZPJ.mjs.map +1 -0
  40. package/dist/{chunk-V26V2S3W.mjs → chunk-3O3N6X6D.mjs} +3 -3
  41. package/dist/{chunk-Y74ALKBL.mjs → chunk-4MSPA7U7.mjs} +11 -9
  42. package/dist/{chunk-Y74ALKBL.mjs.map → chunk-4MSPA7U7.mjs.map} +1 -1
  43. package/dist/{chunk-24XDGNJ6.mjs → chunk-4P45Z5LR.mjs} +63 -41
  44. package/dist/chunk-4P45Z5LR.mjs.map +1 -0
  45. package/dist/chunk-4SSJY32J.mjs +1182 -0
  46. package/dist/chunk-4SSJY32J.mjs.map +1 -0
  47. package/dist/{chunk-XJ2SXC2Q.mjs → chunk-6B6I27TT.mjs} +18 -16
  48. package/dist/{chunk-XJ2SXC2Q.mjs.map → chunk-6B6I27TT.mjs.map} +1 -1
  49. package/dist/chunk-6JKMEH2L.mjs +205 -0
  50. package/dist/chunk-6JKMEH2L.mjs.map +1 -0
  51. package/dist/{chunk-IN3O4R7Q.mjs → chunk-7O526A2D.mjs} +6 -4
  52. package/dist/{chunk-IN3O4R7Q.mjs.map → chunk-7O526A2D.mjs.map} +1 -1
  53. package/dist/chunk-AFLEG5ZC.mjs +28 -0
  54. package/dist/chunk-AFLEG5ZC.mjs.map +1 -0
  55. package/dist/{chunk-UGMRJMFZ.mjs → chunk-BO5CU4ZM.mjs} +4 -4
  56. package/dist/{chunk-JIU5GVM7.mjs → chunk-D4XPNSSI.mjs} +5 -3
  57. package/dist/{chunk-JIU5GVM7.mjs.map → chunk-D4XPNSSI.mjs.map} +1 -1
  58. package/dist/chunk-DPIMA5IO.mjs +72 -0
  59. package/dist/chunk-DPIMA5IO.mjs.map +1 -0
  60. package/dist/chunk-F2CGFVIZ.mjs +83 -0
  61. package/dist/chunk-F2CGFVIZ.mjs.map +1 -0
  62. package/dist/{chunk-R5MKQN6D.mjs → chunk-FBLSJQWK.mjs} +3 -3
  63. package/dist/{chunk-BGB7JHIU.mjs → chunk-FMGZCOJC.mjs} +5 -3
  64. package/dist/{chunk-BGB7JHIU.mjs.map → chunk-FMGZCOJC.mjs.map} +1 -1
  65. package/dist/{chunk-UTVSYS6S.mjs → chunk-FNSIQ2B7.mjs} +18 -6
  66. package/dist/chunk-FNSIQ2B7.mjs.map +1 -0
  67. package/dist/{chunk-JWANK42G.mjs → chunk-FUZ2JNTZ.mjs} +3 -3
  68. package/dist/{chunk-CRYIEYZZ.mjs → chunk-HAJWE62X.mjs} +66 -42
  69. package/dist/chunk-HAJWE62X.mjs.map +1 -0
  70. package/dist/{chunk-CWFWRZWU.mjs → chunk-KSN33A6I.mjs} +3 -2
  71. package/dist/{chunk-CWFWRZWU.mjs.map → chunk-KSN33A6I.mjs.map} +1 -1
  72. package/dist/chunk-KYTHGFFY.mjs +866 -0
  73. package/dist/chunk-KYTHGFFY.mjs.map +1 -0
  74. package/dist/{chunk-QKGCW37O.mjs → chunk-LDFM46LV.mjs} +5 -3
  75. package/dist/{chunk-QKGCW37O.mjs.map → chunk-LDFM46LV.mjs.map} +1 -1
  76. package/dist/chunk-LQNDBPHU.mjs +142 -0
  77. package/dist/chunk-LQNDBPHU.mjs.map +1 -0
  78. package/dist/{chunk-E3I2VDHZ.mjs → chunk-M2PYXSAF.mjs} +6 -4
  79. package/dist/{chunk-E3I2VDHZ.mjs.map → chunk-M2PYXSAF.mjs.map} +1 -1
  80. package/dist/{chunk-DELCADNF.mjs → chunk-ODVKRIVN.mjs} +30 -30
  81. package/dist/{chunk-HR3A4H4E.mjs → chunk-PEJL2T2K.mjs} +13 -11
  82. package/dist/{chunk-HR3A4H4E.mjs.map → chunk-PEJL2T2K.mjs.map} +1 -1
  83. package/dist/{chunk-OGNGPI3M.mjs → chunk-PL55YKT4.mjs} +2 -2
  84. package/dist/{chunk-S6EZVRZC.mjs → chunk-PNSJC6PC.mjs} +5 -28
  85. package/dist/chunk-PNSJC6PC.mjs.map +1 -0
  86. package/dist/{chunk-TDRA5EZI.mjs → chunk-PUREEN2J.mjs} +7 -7
  87. package/dist/chunk-QFS5CENY.mjs +659 -0
  88. package/dist/chunk-QFS5CENY.mjs.map +1 -0
  89. package/dist/chunk-RSN7NH2J.mjs +250 -0
  90. package/dist/chunk-RSN7NH2J.mjs.map +1 -0
  91. package/dist/{chunk-UDREPVEY.mjs → chunk-RVSMEZE3.mjs} +12 -78
  92. package/dist/chunk-RVSMEZE3.mjs.map +1 -0
  93. package/dist/{chunk-SRWPHN2N.mjs → chunk-S64IYJ6Y.mjs} +2 -2
  94. package/dist/{chunk-ZG3NQI77.mjs → chunk-SMD7OEUW.mjs} +6 -4
  95. package/dist/{chunk-ZG3NQI77.mjs.map → chunk-SMD7OEUW.mjs.map} +1 -1
  96. package/dist/{chunk-NJYNJLT7.mjs → chunk-SWFB3A3G.mjs} +2 -2
  97. package/dist/{chunk-RXBQ7KXF.mjs → chunk-USXGNKWJ.mjs} +98 -44
  98. package/dist/chunk-USXGNKWJ.mjs.map +1 -0
  99. package/dist/{chunk-OJV6V7YZ.mjs → chunk-VL7V52YD.mjs} +27 -20
  100. package/dist/chunk-VL7V52YD.mjs.map +1 -0
  101. package/dist/{chunk-2ZZJTBTE.mjs → chunk-WJZ3IYET.mjs} +2 -2
  102. package/dist/chunk-XAJAMVAG.mjs +1720 -0
  103. package/dist/chunk-XAJAMVAG.mjs.map +1 -0
  104. package/dist/chunk-YIJ5QVJ6.mjs +277 -0
  105. package/dist/chunk-YIJ5QVJ6.mjs.map +1 -0
  106. package/dist/{chunk-T6AMRENK.mjs → chunk-YRW5NKD7.mjs} +148 -112
  107. package/dist/chunk-YRW5NKD7.mjs.map +1 -0
  108. package/dist/chunk-ZMJKG2UI.mjs +71 -0
  109. package/dist/chunk-ZMJKG2UI.mjs.map +1 -0
  110. package/dist/confirm.d.mts +48 -0
  111. package/dist/confirm.d.ts +48 -0
  112. package/dist/confirm.js +334 -0
  113. package/dist/confirm.js.map +1 -0
  114. package/dist/confirm.mjs +20 -0
  115. package/dist/datePicker.d.mts +256 -14
  116. package/dist/datePicker.d.ts +256 -14
  117. package/dist/datePicker.js +1624 -145
  118. package/dist/datePicker.js.map +1 -1
  119. package/dist/datePicker.mjs +19 -6
  120. package/dist/dialog.d.mts +166 -0
  121. package/dist/dialog.d.ts +166 -0
  122. package/dist/dialog.js +362 -0
  123. package/dist/dialog.js.map +1 -0
  124. package/dist/dialog.mjs +45 -0
  125. package/dist/emptyState.d.mts +17 -0
  126. package/dist/emptyState.d.ts +17 -0
  127. package/dist/emptyState.js +253 -0
  128. package/dist/emptyState.js.map +1 -0
  129. package/dist/emptyState.mjs +12 -0
  130. package/dist/emptyState.mjs.map +1 -0
  131. package/dist/errorState.d.mts +18 -0
  132. package/dist/errorState.d.ts +18 -0
  133. package/dist/{displayFile.js → errorState.js} +107 -156
  134. package/dist/errorState.js.map +1 -0
  135. package/dist/errorState.mjs +15 -0
  136. package/dist/errorState.mjs.map +1 -0
  137. package/dist/fileUpload.d.mts +197 -0
  138. package/dist/fileUpload.d.ts +197 -0
  139. package/dist/fileUpload.js +1483 -0
  140. package/dist/fileUpload.js.map +1 -0
  141. package/dist/fileUpload.mjs +65 -0
  142. package/dist/fileUpload.mjs.map +1 -0
  143. package/dist/flowMap.mjs +7 -6
  144. package/dist/flowMap.mjs.map +1 -1
  145. package/dist/image.js +1195 -429
  146. package/dist/image.js.map +1 -1
  147. package/dist/image.mjs +8 -6
  148. package/dist/index.d.ts +7 -2
  149. package/dist/index.js +8606 -4087
  150. package/dist/index.js.map +1 -1
  151. package/dist/index.mjs +314 -152
  152. package/dist/inlineError.d.mts +16 -0
  153. package/dist/inlineError.d.ts +16 -0
  154. package/dist/inlineError.js +297 -0
  155. package/dist/inlineError.js.map +1 -0
  156. package/dist/inlineError.mjs +15 -0
  157. package/dist/inlineError.mjs.map +1 -0
  158. package/dist/input.mjs +8 -7
  159. package/dist/jsonEditor.mjs +3 -2
  160. package/dist/list.mjs +7 -6
  161. package/dist/loading.mjs +8 -6
  162. package/dist/markdown.mjs +7 -6
  163. package/dist/markdown.mjs.map +1 -1
  164. package/dist/menu.mjs +9 -8
  165. package/dist/modal.js +2 -1
  166. package/dist/modal.js.map +1 -1
  167. package/dist/modal.mjs +7 -5
  168. package/dist/process.d.mts +33 -75
  169. package/dist/process.d.ts +33 -75
  170. package/dist/process.js +1275 -203
  171. package/dist/process.js.map +1 -1
  172. package/dist/process.mjs +12 -9
  173. package/dist/scrollToLoad.mjs +4 -3
  174. package/dist/select.mjs +10 -9
  175. package/dist/skeleton.d.mts +15 -1
  176. package/dist/skeleton.d.ts +15 -1
  177. package/dist/skeleton.js +114 -2
  178. package/dist/skeleton.js.map +1 -1
  179. package/dist/skeleton.mjs +6 -3
  180. package/dist/stepper.mjs +4 -3
  181. package/dist/tab.mjs +10 -9
  182. package/dist/table.d.mts +269 -85
  183. package/dist/table.d.ts +269 -85
  184. package/dist/table.js +5102 -3153
  185. package/dist/table.js.map +1 -1
  186. package/dist/table.mjs +21 -19
  187. package/dist/theme.js +1766 -432
  188. package/dist/theme.js.map +1 -1
  189. package/dist/theme.mjs +32 -25
  190. package/dist/timeline.mjs +4 -3
  191. package/dist/toast.d.mts +49 -0
  192. package/dist/toast.d.ts +49 -0
  193. package/dist/toast.js +175 -0
  194. package/dist/toast.js.map +1 -0
  195. package/dist/toast.mjs +9 -0
  196. package/dist/toast.mjs.map +1 -0
  197. package/dist/toggleButtonGroup.mjs +3 -2
  198. package/dist/useForm.d.mts +270 -86
  199. package/dist/useForm.d.ts +270 -86
  200. package/dist/useForm.js +4672 -2727
  201. package/dist/useForm.js.map +1 -1
  202. package/dist/useForm.mjs +18 -16
  203. package/dist/useSearch.mjs +13 -12
  204. package/dist/variablesRenderer.mjs +8 -7
  205. package/package.json +3 -3
  206. package/dist/AutocompleteField-ZKNU2IRR.mjs +0 -181
  207. package/dist/AutocompleteField-ZKNU2IRR.mjs.map +0 -1
  208. package/dist/AvatarField-SAODT3CZ.mjs +0 -275
  209. package/dist/AvatarField-SAODT3CZ.mjs.map +0 -1
  210. package/dist/DateField-ZYMZFHL4.mjs.map +0 -1
  211. package/dist/DateTimeField-TPTJ7YIZ.mjs.map +0 -1
  212. package/dist/FileUploadField-NTMWBJER.mjs +0 -78
  213. package/dist/FileUploadField-NTMWBJER.mjs.map +0 -1
  214. package/dist/chunk-24XDGNJ6.mjs.map +0 -1
  215. package/dist/chunk-27KYFU7R.mjs +0 -30
  216. package/dist/chunk-27KYFU7R.mjs.map +0 -1
  217. package/dist/chunk-AAH2O24U.mjs +0 -325
  218. package/dist/chunk-AAH2O24U.mjs.map +0 -1
  219. package/dist/chunk-CRYIEYZZ.mjs.map +0 -1
  220. package/dist/chunk-EEH7HACG.mjs +0 -249
  221. package/dist/chunk-EEH7HACG.mjs.map +0 -1
  222. package/dist/chunk-EKPULYPU.mjs +0 -497
  223. package/dist/chunk-EKPULYPU.mjs.map +0 -1
  224. package/dist/chunk-OJV6V7YZ.mjs.map +0 -1
  225. package/dist/chunk-RXBQ7KXF.mjs.map +0 -1
  226. package/dist/chunk-S6EZVRZC.mjs.map +0 -1
  227. package/dist/chunk-SGCUDWO3.mjs +0 -396
  228. package/dist/chunk-SGCUDWO3.mjs.map +0 -1
  229. package/dist/chunk-T6AMRENK.mjs.map +0 -1
  230. package/dist/chunk-UDREPVEY.mjs.map +0 -1
  231. package/dist/chunk-UTVSYS6S.mjs.map +0 -1
  232. package/dist/chunk-XIMFP6RB.mjs +0 -161
  233. package/dist/chunk-XIMFP6RB.mjs.map +0 -1
  234. package/dist/displayFile.d.mts +0 -95
  235. package/dist/displayFile.d.ts +0 -95
  236. package/dist/displayFile.js.map +0 -1
  237. package/dist/displayFile.mjs +0 -19
  238. package/dist/fileUploader.d.mts +0 -86
  239. package/dist/fileUploader.d.ts +0 -86
  240. package/dist/fileUploader.js +0 -722
  241. package/dist/fileUploader.js.map +0 -1
  242. package/dist/fileUploader.mjs +0 -16
  243. /package/dist/{chunk-V26V2S3W.mjs.map → chunk-3O3N6X6D.mjs.map} +0 -0
  244. /package/dist/{chunk-UGMRJMFZ.mjs.map → chunk-BO5CU4ZM.mjs.map} +0 -0
  245. /package/dist/{chunk-R5MKQN6D.mjs.map → chunk-FBLSJQWK.mjs.map} +0 -0
  246. /package/dist/{chunk-JWANK42G.mjs.map → chunk-FUZ2JNTZ.mjs.map} +0 -0
  247. /package/dist/{chunk-DELCADNF.mjs.map → chunk-ODVKRIVN.mjs.map} +0 -0
  248. /package/dist/{chunk-OGNGPI3M.mjs.map → chunk-PL55YKT4.mjs.map} +0 -0
  249. /package/dist/{chunk-TDRA5EZI.mjs.map → chunk-PUREEN2J.mjs.map} +0 -0
  250. /package/dist/{chunk-SRWPHN2N.mjs.map → chunk-S64IYJ6Y.mjs.map} +0 -0
  251. /package/dist/{chunk-NJYNJLT7.mjs.map → chunk-SWFB3A3G.mjs.map} +0 -0
  252. /package/dist/{chunk-2ZZJTBTE.mjs.map → chunk-WJZ3IYET.mjs.map} +0 -0
  253. /package/dist/{displayFile.mjs.map → confirm.mjs.map} +0 -0
  254. /package/dist/{fileUploader.mjs.map → dialog.mjs.map} +0 -0
package/dist/image.js CHANGED
@@ -134,10 +134,37 @@ function CropperLayout({
134
134
  overflow: "auto"
135
135
  },
136
136
  children: [
137
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_Box.default, { sx: { display: "flex", flexDirection: "column", justifyContent: "space-between", minHeight: 0, height: "100%", alignItems: "center", width: "-webkit-fill-available" }, children: [
138
- left,
139
- leftFooter
140
- ] }),
137
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
138
+ import_Box.default,
139
+ {
140
+ sx: {
141
+ display: "flex",
142
+ flexDirection: "column",
143
+ justifyContent: "space-between",
144
+ minHeight: 0,
145
+ height: "100%",
146
+ alignItems: "center",
147
+ width: "-webkit-fill-available"
148
+ },
149
+ children: [
150
+ left,
151
+ leftFooter ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
152
+ import_Box.default,
153
+ {
154
+ "data-testid": "cropper-left-footer",
155
+ sx: {
156
+ width: "100%",
157
+ display: "flex",
158
+ justifyContent: "center",
159
+ alignItems: "center",
160
+ pt: 1
161
+ },
162
+ children: leftFooter
163
+ }
164
+ ) : null
165
+ ]
166
+ }
167
+ ),
141
168
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_Box.default, { sx: { display: "flex", flexDirection: "column", justifyContent: "space-between", minHeight: 0, height: "100%" }, children: [
142
169
  right,
143
170
  footer
@@ -544,476 +571,1215 @@ function CropperActionSection({
544
571
  // src/components/elemental/Image/src/Cropper/sections/CropperFileSelector.tsx
545
572
  var import_react3 = __toESM(require("react"));
546
573
 
547
- // src/components/compound/FileUploader/src/ReactDropzone.tsx
574
+ // src/components/elemental/FileUpload/src/FileUpload.tsx
548
575
  var import_react2 = require("react");
549
- var import_react_dropzone = require("react-dropzone");
550
576
 
551
- // src/components/compound/FileUploader/src/theme.ts
552
- var fileUploaderRootSx = {
553
- "--dropzone-bg": "var(--mui-palette-background-paper)",
554
- "--dropzone-text-color": "var(--mui-palette-text-secondary)",
555
- "--dropzone-border-hover": "var(--mui-palette-primary-main)",
556
- "--dropzone-bg-hover": "var(--mui-palette-action-hover)"
577
+ // src/components/elemental/Form/src/FormLabel/FormLabel.tsx
578
+ var import_FormLabel = __toESM(require("@mui/material/FormLabel"));
579
+ var import_jsx_runtime8 = require("react/jsx-runtime");
580
+ function MuiFormLabel(props) {
581
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_FormLabel.default, { ...props });
582
+ }
583
+
584
+ // src/components/elemental/Form/src/index.ts
585
+ var import_FormControl = __toESM(require("@mui/material/FormControl"));
586
+ var import_FormHelperText = __toESM(require("@mui/material/FormHelperText"));
587
+ var import_InputAdornment = __toESM(require("@mui/material/InputAdornment"));
588
+ var import_InputLabel = __toESM(require("@mui/material/InputLabel"));
589
+
590
+ // src/components/elemental/Progress/src/LinearProgress.tsx
591
+ var import_LinearProgress = __toESM(require("@mui/material/LinearProgress"));
592
+ var import_jsx_runtime9 = require("react/jsx-runtime");
593
+ var LinearProgress = (props) => {
594
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_LinearProgress.default, { ...props });
557
595
  };
558
596
 
559
- // src/_utils/_func/downloadFile.ts
560
- var import_file_type = require("file-type");
561
- async function downloadFile(url, fetchOptions) {
562
- const res = await fetch(url, fetchOptions);
563
- const blob = await res.blob();
564
- const buffer = await blob.arrayBuffer();
565
- const fType = await (0, import_file_type.fileTypeFromBuffer)(buffer);
566
- const data = {
567
- blobUrl: URL.createObjectURL(blob),
568
- size: blob.size,
569
- mimeType: fType?.mime || blob.type
570
- // use file-type to get the mime type
571
- };
572
- const nonImgRes = {
573
- ...data,
574
- dimensions: {
575
- width: 0,
576
- height: 0
577
- }
578
- };
579
- try {
580
- if (data.mimeType.includes("image/")) {
581
- const dimensions = await handleImageDownload(data.blobUrl);
582
- return {
583
- ...data,
584
- dimensions
585
- };
586
- } else {
587
- return nonImgRes;
588
- }
589
- } catch (err) {
590
- console.warn("Failed to handle image download:", err);
591
- return nonImgRes;
592
- }
593
- }
594
- async function handleImageDownload(blobUrl) {
595
- const img = new Image();
596
- img.src = blobUrl;
597
- await new Promise((resolve, reject) => {
598
- img.onload = resolve;
599
- img.onerror = reject;
600
- });
601
- const metaData = {
602
- width: img.width,
603
- height: img.height
604
- };
605
- img.remove();
606
- return metaData;
607
- }
597
+ // src/components/elemental/FileUpload/src/FileUpload.tsx
598
+ var import_react_file_icon = require("react-file-icon");
608
599
 
609
- // src/_utils/_const/file.ts
610
- var FILE_STATUSs = {
611
- // local status
612
- uploadingToLocal: "local-uploading",
613
- uploadedToLocal: "local-uploaded",
614
- localError: "local-error",
615
- pending: "pending",
616
- // upload s3
617
- uploadPending: "upload-pending",
618
- gettingSignedURL: "upload-gettingSignedURL",
619
- beginUploadToS3: "upload-beginUploadToS3",
620
- uploadedToCloud: "upload-uploadedToCloud",
621
- error: "upload-error",
622
- // download
623
- downloadPending: "download-pending",
624
- downloading: "download-in-progress",
625
- downloaded: "download-completed",
626
- downloadError: "download-error"
600
+ // src/components/elemental/FileUpload/src/theme.ts
601
+ var fileUploadRootSx = {
602
+ "--fu-border": "var(--mui-palette-border-1)",
603
+ "--fu-border-hover": "var(--mui-palette-border-hover-1, var(--mui-palette-text-secondary))",
604
+ "--fu-border-active": "color-mix(in srgb, var(--mui-palette-text-secondary) 65%, transparent)",
605
+ "--fu-border-error": "var(--mui-palette-error-main)",
606
+ "--fu-surface": "color-mix(in srgb, var(--mui-palette-background-paper) 78%, transparent)",
607
+ "--fu-surface-hover": "color-mix(in srgb, var(--mui-palette-background-paper) 92%, transparent)",
608
+ "--fu-surface-active": "color-mix(in srgb, var(--mui-palette-primary-main) 8%, var(--mui-palette-background-paper))",
609
+ "--fu-item-bg": "color-mix(in srgb, var(--mui-palette-background-paper) 88%, transparent)",
610
+ "--fu-icon": "var(--mui-palette-text-secondary)",
611
+ "--fu-text": "var(--mui-palette-text-primary)",
612
+ "--fu-text-secondary": "var(--mui-palette-text-secondary)",
613
+ "--fu-shadow": "inset 0 1px 0 color-mix(in srgb, var(--mui-palette-common-white) 6%, transparent)",
614
+ "--fu-radius": "16px",
615
+ "--fu-item-radius": "12px",
616
+ display: "flex",
617
+ flexDirection: "column",
618
+ gap: 1,
619
+ width: "100%",
620
+ boxSizing: "border-box",
621
+ '[color-scheme="dark"] &': {
622
+ "--fu-surface": "color-mix(in srgb, var(--mui-palette-background-paper) 70%, transparent)",
623
+ "--fu-surface-hover": "color-mix(in srgb, var(--mui-palette-background-paper) 88%, transparent)",
624
+ "--fu-item-bg": "color-mix(in srgb, var(--mui-palette-background-paper) 82%, transparent)",
625
+ "--fu-shadow": "inset 0 1px 0 color-mix(in srgb, var(--mui-palette-common-white) 8%, transparent), 0 1px 2px rgba(0,0,0,0.18)"
626
+ }
627
627
  };
628
- var FILE_TYPEs = {
629
- image: "image",
630
- video: "video",
631
- audio: "audio",
632
- pdf: "pdf",
633
- doc: "doc",
634
- xls: "xls",
635
- ppt: "ppt",
636
- txt: "txt",
637
- zip: "zip",
638
- json: "json",
639
- other: "other"
628
+ var fileUploadDropzoneSx = {
629
+ display: "flex",
630
+ flexDirection: "column",
631
+ alignItems: "center",
632
+ justifyContent: "center",
633
+ textAlign: "center",
634
+ gap: 0.75,
635
+ px: 3,
636
+ py: 3.5,
637
+ minHeight: 140,
638
+ borderRadius: "var(--fu-radius)",
639
+ border: "1px dashed var(--fu-drop-border, var(--fu-border))",
640
+ backgroundColor: "var(--fu-drop-bg, var(--fu-surface))",
641
+ boxShadow: "var(--fu-shadow)",
642
+ color: "var(--fu-text-secondary)",
643
+ cursor: "pointer",
644
+ outline: "none",
645
+ boxSizing: "border-box",
646
+ transition: "border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease",
647
+ "&:hover": {
648
+ borderColor: "var(--fu-border-hover)",
649
+ backgroundColor: "var(--fu-surface-hover)"
650
+ },
651
+ "&:focus-visible": {
652
+ borderColor: "var(--fu-border-active)",
653
+ borderStyle: "solid"
654
+ },
655
+ '&[data-active="true"]': {
656
+ borderColor: "var(--fu-border-active)",
657
+ borderStyle: "solid",
658
+ backgroundColor: "var(--fu-surface-active)"
659
+ },
660
+ '&[data-error="true"]': {
661
+ "--fu-drop-border": "var(--fu-border-error)"
662
+ },
663
+ '&[data-disabled="true"]': {
664
+ opacity: 0.58,
665
+ cursor: "default",
666
+ pointerEvents: "none"
667
+ }
640
668
  };
641
-
642
- // src/_utils/classes/PreviewableFile.ts
643
- var PreviewableFile = class {
644
- path;
645
- blobUrl;
646
- filename;
647
- randomName;
648
- fileType;
649
- mimeType;
650
- size;
651
- displaySize;
652
- url;
653
- fetchOptions;
654
- putUrl;
655
- getUrl;
656
- status;
657
- revokeable;
658
- imageProps;
659
- constructor(props = {}) {
660
- this.path = props.path ?? "";
661
- this.blobUrl = props.blobUrl ?? "";
662
- this.filename = props.filename ?? "";
663
- this.randomName = props.randomName ?? "";
664
- this.fileType = props.fileType ?? getFileType(props.mimeType ?? "");
665
- this.mimeType = props.mimeType ?? "";
666
- this.size = props.size ?? 0;
667
- this.displaySize = props.displaySize ?? displayFileSize(props.size ?? 0);
668
- this.url = props.url ?? "";
669
- this.fetchOptions = props.fetchOptions ?? {};
670
- this.putUrl = props.putUrl ?? "";
671
- this.getUrl = props.getUrl ?? "";
672
- this.status = props.status ?? FILE_STATUSs.pending;
673
- this.revokeable = props.revokeable ?? true;
674
- this.imageProps = props.imageProps ?? {
675
- width: 0,
676
- height: 0
677
- };
678
- Object.preventExtensions(this);
669
+ var fileUploadItemSx = {
670
+ display: "flex",
671
+ alignItems: "center",
672
+ gap: 1.25,
673
+ px: 1.25,
674
+ py: 1,
675
+ borderRadius: "var(--fu-item-radius)",
676
+ border: "1px solid var(--fu-border)",
677
+ backgroundColor: "var(--fu-item-bg)",
678
+ boxShadow: "var(--fu-shadow)",
679
+ boxSizing: "border-box",
680
+ minWidth: 0,
681
+ '&[data-status="error"]': {
682
+ borderColor: "color-mix(in srgb, var(--mui-palette-error-main) 55%, var(--fu-border))",
683
+ backgroundColor: "color-mix(in srgb, var(--mui-palette-error-main) 8%, var(--fu-item-bg))"
679
684
  }
680
- toPlainObj() {
681
- return {
682
- ...this
683
- };
685
+ };
686
+ var fileUploadThumbSx = {
687
+ width: 36,
688
+ height: 36,
689
+ minWidth: 36,
690
+ borderRadius: "8px",
691
+ objectFit: "cover",
692
+ flexShrink: 0,
693
+ border: "1px solid var(--fu-border)",
694
+ backgroundColor: "var(--fu-item-bg)",
695
+ display: "block",
696
+ boxSizing: "border-box"
697
+ };
698
+ var fileUploadIconWellSx = {
699
+ width: 36,
700
+ height: 36,
701
+ minWidth: 36,
702
+ borderRadius: "8px",
703
+ flexShrink: 0,
704
+ display: "flex",
705
+ alignItems: "center",
706
+ justifyContent: "center",
707
+ border: "1px solid var(--fu-border)",
708
+ backgroundColor: "color-mix(in srgb, var(--mui-palette-background-paper) 55%, transparent)",
709
+ boxSizing: "border-box",
710
+ overflow: "hidden"
711
+ };
712
+ var fileUploadLibIconSx = {
713
+ width: 24,
714
+ height: 30,
715
+ lineHeight: 0,
716
+ flexShrink: 0,
717
+ // Keep library colors vivid (no opacity / filter / color overrides).
718
+ color: "unset",
719
+ filter: "none",
720
+ opacity: 1,
721
+ "& svg": {
722
+ width: "100%",
723
+ height: "100%",
724
+ display: "block",
725
+ // Prevent inherited MUI text color from washing glyph/label fills.
726
+ color: "unset"
684
727
  }
685
- updateFile(file) {
686
- if (!file) return;
687
- this.path = file.path;
688
- this.blobUrl = file.blobUrl;
689
- this.filename = file.filename;
690
- this.randomName = file.randomName;
691
- this.fileType = file.fileType;
692
- this.size = file.size;
693
- this.displaySize = file.displaySize;
694
- this.url = file.url;
695
- this.fetchOptions = file.fetchOptions;
696
- this.putUrl = file.putUrl;
697
- this.getUrl = file.getUrl;
698
- this.status = file.status;
699
- this.revokeable = file.revokeable;
700
- this.imageProps = file.imageProps;
728
+ };
729
+ var fileUploadButtonSx = {
730
+ alignSelf: "flex-start",
731
+ textTransform: "none",
732
+ fontWeight: 600,
733
+ fontSize: "0.8125rem",
734
+ lineHeight: 1.25,
735
+ borderRadius: "10px",
736
+ px: 1.5,
737
+ py: 0.75,
738
+ minHeight: 36,
739
+ border: "1px solid var(--fu-border)",
740
+ backgroundColor: "var(--fu-surface)",
741
+ color: "var(--fu-text)",
742
+ boxShadow: "var(--fu-shadow)",
743
+ transition: "border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease",
744
+ "&:hover": {
745
+ borderColor: "var(--fu-border-hover)",
746
+ backgroundColor: "var(--fu-surface-hover)"
747
+ },
748
+ "&:focus-visible": {
749
+ borderColor: "var(--fu-border-active)",
750
+ outline: "none"
751
+ },
752
+ '&[data-active="true"]': {
753
+ borderColor: "var(--fu-border-active)",
754
+ backgroundColor: "var(--fu-surface-active)"
755
+ },
756
+ '&[data-error="true"]': {
757
+ borderColor: "var(--fu-border-error)",
758
+ color: "var(--fu-border-error)"
759
+ },
760
+ "&.Mui-disabled": {
761
+ opacity: 0.58,
762
+ borderColor: "var(--fu-border)",
763
+ color: "var(--fu-text-secondary)"
764
+ },
765
+ "& .MuiButton-startIcon": {
766
+ marginRight: "8px",
767
+ marginLeft: 0,
768
+ color: "var(--fu-icon)"
701
769
  }
702
- updateStatus(status) {
703
- this.status = status;
770
+ };
771
+ var fileUploadTileListSx = {
772
+ display: "flex",
773
+ flexWrap: "wrap",
774
+ gap: 1.25,
775
+ m: 0,
776
+ p: 0,
777
+ listStyle: "none"
778
+ };
779
+ var fileUploadTileSx = {
780
+ "--fu-tile-size": "80px",
781
+ position: "relative",
782
+ width: "var(--fu-tile-size)",
783
+ height: "var(--fu-tile-size)",
784
+ minWidth: "var(--fu-tile-size)",
785
+ borderRadius: "12px",
786
+ border: "1px solid var(--fu-border)",
787
+ backgroundColor: "var(--fu-item-bg)",
788
+ boxShadow: "var(--fu-shadow)",
789
+ boxSizing: "border-box",
790
+ overflow: "hidden",
791
+ flexShrink: 0,
792
+ '&[data-status="error"]': {
793
+ borderColor: "color-mix(in srgb, var(--mui-palette-error-main) 55%, var(--fu-border))"
794
+ },
795
+ "&:hover .fu-tile-remove, &:focus-within .fu-tile-remove": {
796
+ opacity: 1,
797
+ pointerEvents: "auto"
704
798
  }
705
- async downloadFile() {
706
- if (!this.url) return this;
707
- try {
708
- const res = await downloadFile(this.url, this.fetchOptions);
709
- this.url = res.blobUrl;
710
- this.path = res.blobUrl;
711
- this.status = FILE_STATUSs.downloaded;
712
- this.blobUrl = res.blobUrl;
713
- this.fileType = getFileType(res.mimeType);
714
- this.mimeType = res.mimeType;
715
- this.size = res.size;
716
- this.displaySize = displayFileSize(res.size);
717
- this.imageProps = res.dimensions;
718
- return this;
719
- } catch (err) {
720
- console.log(err);
721
- return this;
722
- }
799
+ };
800
+ var fileUploadTileMediaSx = {
801
+ width: "100%",
802
+ height: "100%",
803
+ objectFit: "cover",
804
+ display: "block",
805
+ borderRadius: "inherit"
806
+ };
807
+ var fileUploadTileIconWellSx = {
808
+ width: "100%",
809
+ height: "100%",
810
+ display: "flex",
811
+ alignItems: "center",
812
+ justifyContent: "center",
813
+ backgroundColor: "color-mix(in srgb, var(--mui-palette-background-paper) 55%, transparent)",
814
+ border: "none",
815
+ borderRadius: 0,
816
+ boxSizing: "border-box",
817
+ overflow: "hidden"
818
+ };
819
+ var fileUploadTileLibIconSx = {
820
+ width: 36,
821
+ height: 44,
822
+ lineHeight: 0,
823
+ flexShrink: 0,
824
+ color: "unset",
825
+ filter: "none",
826
+ opacity: 1,
827
+ "& svg": {
828
+ width: "100%",
829
+ height: "100%",
830
+ display: "block",
831
+ color: "unset"
723
832
  }
724
- _displayFileSize() {
725
- return displayFileSize(this.size);
833
+ };
834
+ var fileUploadTileRemoveSx = {
835
+ position: "absolute",
836
+ top: 4,
837
+ right: 4,
838
+ zIndex: 2,
839
+ width: 22,
840
+ height: 22,
841
+ p: 0,
842
+ opacity: 0,
843
+ pointerEvents: "none",
844
+ backgroundColor: "#fff",
845
+ color: "rgba(15, 23, 42, 0.72)",
846
+ boxShadow: "0 1px 3px rgba(0,0,0,0.22)",
847
+ border: "1px solid color-mix(in srgb, var(--mui-palette-common-black) 8%, transparent)",
848
+ transition: "opacity 140ms ease, background-color 140ms ease",
849
+ "&:hover": {
850
+ backgroundColor: "#fff",
851
+ color: "rgba(15, 23, 42, 0.92)"
852
+ },
853
+ "&.Mui-disabled": {
854
+ opacity: 0
726
855
  }
727
- getUploadFormat() {
728
- return {
729
- url: this.putUrl,
730
- keyPath: this.putUrl,
731
- filename: this.filename,
732
- fileType: this.mimeType,
733
- hostname: ""
734
- };
856
+ };
857
+ var fileUploadTileProgressSx = {
858
+ position: "absolute",
859
+ left: 0,
860
+ right: 0,
861
+ bottom: 0,
862
+ zIndex: 1,
863
+ height: 3,
864
+ borderRadius: 0,
865
+ backgroundColor: "color-mix(in srgb, var(--mui-palette-common-black) 25%, transparent)",
866
+ "& .MuiLinearProgress-bar": {
867
+ borderRadius: 0
735
868
  }
736
869
  };
737
- function displayFileSize(size) {
738
- const units = ["B", "KB", "MB", "GB", "TB"];
739
- let unitIndex = 0;
740
- while (size >= 1024 && unitIndex < units.length - 1) {
741
- size /= 1024;
742
- unitIndex++;
870
+
871
+ // src/components/elemental/FileUpload/src/utils.ts
872
+ var idSeq = 0;
873
+ function createFileUploadId() {
874
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
875
+ return crypto.randomUUID();
743
876
  }
744
- const sizeWithUnit = size.toFixed(2) + " " + units[unitIndex];
745
- return `[${sizeWithUnit}]`;
877
+ idSeq += 1;
878
+ return `fu-${Date.now()}-${idSeq}`;
879
+ }
880
+ function createFileUploadItem(file) {
881
+ return {
882
+ id: createFileUploadId(),
883
+ file,
884
+ status: "idle",
885
+ progress: 0
886
+ };
746
887
  }
747
- function getFileType(mimeType) {
748
- const types = Object.values(FILE_TYPEs);
749
- const [type] = mimeType.split("/");
750
- if (types.includes(type)) {
751
- return type;
888
+ function formatFileSize(bytes) {
889
+ if (!Number.isFinite(bytes) || bytes < 0) return "\u2014";
890
+ if (bytes < 1024) return `${bytes} B`;
891
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
892
+ if (bytes < 1024 * 1024 * 1024) {
893
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
752
894
  }
753
- const found = types.find((t) => mimeType.includes(t) && t !== FILE_TYPEs.other);
754
- if (found) {
755
- return found;
895
+ return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
896
+ }
897
+ function parseAccept(accept) {
898
+ if (!accept || !accept.trim()) return [];
899
+ return accept.split(",").map((p) => p.trim()).filter(Boolean).map((token) => {
900
+ if (token.startsWith(".")) {
901
+ return { type: "ext", value: token.toLowerCase() };
902
+ }
903
+ return { type: "mime", value: token.toLowerCase() };
904
+ });
905
+ }
906
+ function matchesAccept(file, rules) {
907
+ if (rules.length === 0) return true;
908
+ const name = file.name.toLowerCase();
909
+ const mime = (file.type || "").toLowerCase();
910
+ return rules.some((rule) => {
911
+ if (rule.type === "ext") {
912
+ return name.endsWith(rule.value);
913
+ }
914
+ if (rule.value.endsWith("/*")) {
915
+ const prefix = rule.value.slice(0, -1);
916
+ return mime.startsWith(prefix);
917
+ }
918
+ return mime === rule.value;
919
+ });
920
+ }
921
+ function validateFiles(incoming, opts) {
922
+ const rules = parseAccept(opts.accept);
923
+ const accepted = [];
924
+ const rejections = [];
925
+ const hardCap = opts.multiple ? opts.maxFiles != null && opts.maxFiles > 0 ? opts.maxFiles : Infinity : 1;
926
+ for (const file of incoming) {
927
+ const errors = [];
928
+ if (!matchesAccept(file, rules)) {
929
+ errors.push("file-invalid-type");
930
+ }
931
+ if (opts.maxSize != null && opts.maxSize > 0 && file.size > opts.maxSize) {
932
+ errors.push("file-too-large");
933
+ }
934
+ if (opts.currentCount + accepted.length >= hardCap) {
935
+ errors.push("too-many-files");
936
+ }
937
+ if (errors.length > 0) {
938
+ rejections.push({ file, errors });
939
+ } else {
940
+ accepted.push(file);
941
+ }
756
942
  }
757
- return FILE_TYPEs.other;
943
+ return { accepted, rejections };
758
944
  }
759
-
760
- // src/components/compound/DisplayFile/src/DisplayFile.tsx
761
- var import_jsx_runtime8 = require("react/jsx-runtime");
762
- var getFileIcon = (fileType) => {
763
- switch (fileType) {
764
- case FILE_TYPEs.image:
765
- return import_ImageOutlined.default;
766
- case FILE_TYPEs.pdf:
767
- return import_PictureAsPdf.default;
768
- case FILE_TYPEs.audio:
769
- return import_AudioFile.default;
770
- case FILE_TYPEs.video:
771
- return import_VideoFile.default;
772
- case FILE_TYPEs.xls:
773
- return import_TableChart.default;
774
- case FILE_TYPEs.zip:
775
- return import_FolderZip.default;
776
- case FILE_TYPEs.json:
777
- return import_DataObject.default;
778
- case FILE_TYPEs.ppt:
779
- case FILE_TYPEs.doc:
780
- case FILE_TYPEs.txt:
781
- return import_Description.default;
782
- default:
783
- return import_InsertDriveFile.default;
945
+ var MIME_TO_EXT = {
946
+ "application/pdf": "pdf",
947
+ "application/zip": "zip",
948
+ "application/x-zip-compressed": "zip",
949
+ "application/gzip": "gz",
950
+ "application/x-gzip": "gz",
951
+ "application/x-rar-compressed": "rar",
952
+ "application/vnd.rar": "rar",
953
+ "application/x-7z-compressed": "7z",
954
+ "application/x-tar": "tar",
955
+ "application/json": "json",
956
+ "application/msword": "doc",
957
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
958
+ "application/vnd.ms-excel": "xls",
959
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
960
+ "application/vnd.ms-powerpoint": "ppt",
961
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
962
+ "text/plain": "txt",
963
+ "text/csv": "csv",
964
+ "text/markdown": "md",
965
+ "image/jpeg": "jpg",
966
+ "image/png": "png",
967
+ "image/gif": "gif",
968
+ "image/webp": "webp",
969
+ "image/svg+xml": "svg",
970
+ "audio/mpeg": "mp3",
971
+ "audio/wav": "wav",
972
+ "video/mp4": "mp4",
973
+ "video/webm": "webm"
974
+ };
975
+ function getFileExtension(file) {
976
+ const name = file.name || "";
977
+ const dot = name.lastIndexOf(".");
978
+ if (dot > 0 && dot < name.length - 1) {
979
+ return name.slice(dot + 1).toLowerCase();
784
980
  }
981
+ const mime = (file.type || "").toLowerCase();
982
+ return MIME_TO_EXT[mime] ?? "";
983
+ }
984
+ function isImageFile(file) {
985
+ return typeof file.type === "string" && file.type.startsWith("image/");
986
+ }
987
+ var EXT_ALIASES = {
988
+ "7z": "7zip",
989
+ tgz: "gz",
990
+ tbz: "gz",
991
+ tbz2: "gz"
992
+ };
993
+ var ARCHIVE_FILE_ICON_STYLE = {
994
+ type: "compressed",
995
+ labelColor: "#E2A903",
996
+ labelTextColor: "#1A1A1A",
997
+ labelUppercase: true,
998
+ foldColor: "#C48E02",
999
+ color: "#F6E7A8",
1000
+ glyphColor: "rgba(40, 30, 0, 0.35)"
785
1001
  };
786
- var FileThumbnail = ({ file, size = 60 }) => {
787
- const isImage = file.fileType === FILE_TYPEs.image;
788
- const FileIcon = getFileIcon(file.fileType || "");
789
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1002
+ var ARCHIVE_EXTS = /* @__PURE__ */ new Set([
1003
+ "zip",
1004
+ "zipx",
1005
+ "rar",
1006
+ "7z",
1007
+ "7zip",
1008
+ "gz",
1009
+ "tar",
1010
+ "tgz",
1011
+ "sitx",
1012
+ "bz2"
1013
+ ]);
1014
+ var TYPE_COLOR_FALLBACKS = {
1015
+ "3d": {
1016
+ type: "3d",
1017
+ labelColor: "#5FB9AD",
1018
+ foldColor: "#4A9E94",
1019
+ color: "#E5F6F4"
1020
+ },
1021
+ acrobat: {
1022
+ type: "acrobat",
1023
+ labelColor: "#D93831",
1024
+ foldColor: "#B82E28",
1025
+ color: "#FCE8E7"
1026
+ },
1027
+ android: {
1028
+ type: "android",
1029
+ labelColor: "#3DDC84",
1030
+ foldColor: "#2BB86A",
1031
+ color: "#E6FBF0"
1032
+ },
1033
+ audio: {
1034
+ type: "audio",
1035
+ labelColor: "#9B59B6",
1036
+ foldColor: "#7E3F9A",
1037
+ color: "#F3E9F8"
1038
+ },
1039
+ binary: {
1040
+ type: "binary",
1041
+ labelColor: "#E67E22",
1042
+ foldColor: "#C86A1A",
1043
+ color: "#FDF0E4"
1044
+ },
1045
+ code: {
1046
+ type: "code",
1047
+ labelColor: "#3498DB",
1048
+ foldColor: "#2A7AB0",
1049
+ color: "#E7F3FB"
1050
+ },
1051
+ compressed: { ...ARCHIVE_FILE_ICON_STYLE },
1052
+ document: {
1053
+ type: "document",
1054
+ labelColor: "#5B8DEF",
1055
+ labelUppercase: true,
1056
+ foldColor: "#4A75C9",
1057
+ color: "#E8EEF9",
1058
+ glyphColor: "rgba(40, 60, 120, 0.35)"
1059
+ },
1060
+ drive: {
1061
+ type: "drive",
1062
+ labelColor: "#27AE60",
1063
+ foldColor: "#1E8A4B",
1064
+ color: "#E5F7ED"
1065
+ },
1066
+ font: {
1067
+ type: "font",
1068
+ labelColor: "#8E44AD",
1069
+ foldColor: "#71368A",
1070
+ color: "#F2E8F7"
1071
+ },
1072
+ image: {
1073
+ type: "image",
1074
+ labelColor: "#1ABC9C",
1075
+ foldColor: "#14967C",
1076
+ color: "#E4F8F3"
1077
+ },
1078
+ presentation: {
1079
+ type: "presentation",
1080
+ labelColor: "#D35400",
1081
+ labelUppercase: true,
1082
+ foldColor: "#A84300",
1083
+ color: "#FCEADE",
1084
+ glyphColor: "rgba(120, 50, 0, 0.35)"
1085
+ },
1086
+ settings: {
1087
+ type: "settings",
1088
+ labelColor: "#16A085",
1089
+ foldColor: "#117A65",
1090
+ color: "#E4F6F2"
1091
+ },
1092
+ spreadsheet: {
1093
+ type: "spreadsheet",
1094
+ labelColor: "#2D7D46",
1095
+ labelUppercase: true,
1096
+ foldColor: "#246338",
1097
+ color: "#E5F2EA",
1098
+ glyphColor: "rgba(20, 60, 30, 0.35)"
1099
+ },
1100
+ vector: {
1101
+ type: "vector",
1102
+ labelColor: "#FF7F18",
1103
+ foldColor: "#D96A12",
1104
+ color: "#FFF0E4"
1105
+ },
1106
+ video: {
1107
+ type: "video",
1108
+ labelColor: "#E74C3C",
1109
+ foldColor: "#C0392B",
1110
+ color: "#FCE9E7"
1111
+ }
1112
+ };
1113
+ var UNKNOWN_FILE_ICON_STYLE = {
1114
+ type: "document",
1115
+ labelColor: "#5B8DEF",
1116
+ labelTextColor: "#FFFFFF",
1117
+ labelUppercase: true,
1118
+ foldColor: "#4A75C9",
1119
+ color: "#E8EEF9",
1120
+ glyphColor: "rgba(40, 60, 120, 0.35)"
1121
+ };
1122
+ var MONO_PAGE_COLORS = /* @__PURE__ */ new Set([
1123
+ "",
1124
+ "whitesmoke",
1125
+ "#fff",
1126
+ "#ffffff",
1127
+ "white",
1128
+ "#f5f5f5",
1129
+ "#fafafa"
1130
+ ]);
1131
+ function hasVividColor(style) {
1132
+ if (typeof style.labelColor === "string" && style.labelColor.trim()) {
1133
+ return true;
1134
+ }
1135
+ if (typeof style.color === "string") {
1136
+ const c = style.color.trim().toLowerCase();
1137
+ if (c && !MONO_PAGE_COLORS.has(c)) return true;
1138
+ }
1139
+ return false;
1140
+ }
1141
+ function mergeColorEnrichment(lib, enrichment) {
1142
+ return {
1143
+ ...enrichment,
1144
+ ...lib,
1145
+ labelColor: lib.labelColor ?? enrichment.labelColor,
1146
+ labelTextColor: lib.labelTextColor ?? enrichment.labelTextColor,
1147
+ foldColor: lib.foldColor ?? enrichment.foldColor,
1148
+ color: lib.color ?? enrichment.color,
1149
+ glyphColor: lib.glyphColor ?? enrichment.glyphColor,
1150
+ labelUppercase: lib.labelUppercase ?? enrichment.labelUppercase,
1151
+ type: lib.type ?? enrichment.type
1152
+ };
1153
+ }
1154
+ function resolveFileIconStyle(file, defaultStyles2) {
1155
+ const rawExt = getFileExtension(file);
1156
+ const styleKey = (EXT_ALIASES[rawExt] ?? rawExt).toLowerCase();
1157
+ const displayExt = rawExt || styleKey || void 0;
1158
+ const lib = {
1159
+ ...(styleKey ? defaultStyles2[styleKey] : void 0) ?? {}
1160
+ };
1161
+ const isArchive = ARCHIVE_EXTS.has(rawExt) || ARCHIVE_EXTS.has(styleKey) || lib.type === "compressed";
1162
+ let style;
1163
+ if (isArchive) {
1164
+ style = { ...lib, ...ARCHIVE_FILE_ICON_STYLE };
1165
+ } else if (hasVividColor(lib)) {
1166
+ style = { ...lib };
1167
+ } else if (lib.type && TYPE_COLOR_FALLBACKS[lib.type]) {
1168
+ style = mergeColorEnrichment(lib, TYPE_COLOR_FALLBACKS[lib.type]);
1169
+ } else {
1170
+ style = mergeColorEnrichment(lib, UNKNOWN_FILE_ICON_STYLE);
1171
+ }
1172
+ return {
1173
+ extension: displayExt,
1174
+ styleKey,
1175
+ style
1176
+ };
1177
+ }
1178
+
1179
+ // src/components/elemental/FileUpload/src/FileUpload.tsx
1180
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1181
+ function mergeSx2(...parts) {
1182
+ const out = [];
1183
+ for (const p of parts) {
1184
+ if (!p) continue;
1185
+ if (Array.isArray(p)) out.push(...p);
1186
+ else out.push(p);
1187
+ }
1188
+ return out;
1189
+ }
1190
+ var FileUpload = (0, import_react2.forwardRef)(
1191
+ function FileUpload2(props, ref) {
1192
+ const {
1193
+ value: valueProp,
1194
+ defaultValue,
1195
+ onChange,
1196
+ onRemove,
1197
+ onReject,
1198
+ multiple = true,
1199
+ accept,
1200
+ maxSize,
1201
+ maxFiles,
1202
+ disabled = false,
1203
+ hideDropzone = false,
1204
+ disableRemove = false,
1205
+ readOnly = false,
1206
+ label,
1207
+ name,
1208
+ helperText,
1209
+ error = false,
1210
+ required = false,
1211
+ variant = "dropzone",
1212
+ itemVariant = "row",
1213
+ buttonLabel = "Upload file",
1214
+ dropzoneTitle = "Drag & drop files here",
1215
+ dropzoneDescription = "or click to browse",
1216
+ id: idProp,
1217
+ className,
1218
+ sx,
1219
+ "data-testid": dataTestId = "file-upload"
1220
+ } = props;
1221
+ const reactId = (0, import_react2.useId)();
1222
+ const inputId = idProp ?? `file-upload-${reactId}`;
1223
+ const helperId = `${inputId}-helper`;
1224
+ const inputRef = (0, import_react2.useRef)(null);
1225
+ const isControlled = valueProp !== void 0;
1226
+ const [uncontrolled, setUncontrolled] = (0, import_react2.useState)(
1227
+ () => defaultValue ?? []
1228
+ );
1229
+ const items = (0, import_react2.useMemo)(
1230
+ () => isControlled ? valueProp ?? [] : uncontrolled,
1231
+ [isControlled, valueProp, uncontrolled]
1232
+ );
1233
+ const [active, setActive] = (0, import_react2.useState)(false);
1234
+ const dragDepth = (0, import_react2.useRef)(0);
1235
+ const atCapacity = (0, import_react2.useMemo)(() => {
1236
+ if (!multiple) return items.length >= 1;
1237
+ if (maxFiles != null && maxFiles > 0) return items.length >= maxFiles;
1238
+ return false;
1239
+ }, [items.length, maxFiles, multiple]);
1240
+ const commit = (0, import_react2.useCallback)(
1241
+ (next) => {
1242
+ if (!isControlled) setUncontrolled(next);
1243
+ onChange?.(next);
1244
+ },
1245
+ [isControlled, onChange]
1246
+ );
1247
+ const ingest = (0, import_react2.useCallback)(
1248
+ (fileList) => {
1249
+ if (disabled) return;
1250
+ const incoming = Array.from(fileList);
1251
+ if (incoming.length === 0) return;
1252
+ const { accepted, rejections } = validateFiles(incoming, {
1253
+ accept,
1254
+ maxSize,
1255
+ maxFiles,
1256
+ currentCount: items.length,
1257
+ multiple
1258
+ });
1259
+ if (rejections.length > 0) {
1260
+ onReject?.(rejections);
1261
+ }
1262
+ if (accepted.length === 0) return;
1263
+ const nextItems = accepted.map(createFileUploadItem);
1264
+ if (!multiple) {
1265
+ commit(nextItems.slice(0, 1));
1266
+ return;
1267
+ }
1268
+ commit([...items, ...nextItems]);
1269
+ },
1270
+ [
1271
+ accept,
1272
+ disabled,
1273
+ items,
1274
+ maxFiles,
1275
+ maxSize,
1276
+ multiple,
1277
+ onReject,
1278
+ commit
1279
+ ]
1280
+ );
1281
+ const handleRemove = (0, import_react2.useCallback)(
1282
+ (item) => {
1283
+ if (disabled) return;
1284
+ const next = items.filter((i) => i.id !== item.id);
1285
+ commit(next);
1286
+ onRemove?.(item, next);
1287
+ if (inputRef.current) inputRef.current.value = "";
1288
+ },
1289
+ [commit, disabled, items, onRemove]
1290
+ );
1291
+ const openPicker = (0, import_react2.useCallback)(() => {
1292
+ if (disabled || atCapacity) return;
1293
+ inputRef.current?.click();
1294
+ }, [atCapacity, disabled]);
1295
+ const onInputChange = (0, import_react2.useCallback)(
1296
+ (e) => {
1297
+ if (e.target.files) ingest(e.target.files);
1298
+ e.target.value = "";
1299
+ },
1300
+ [ingest]
1301
+ );
1302
+ const onDragEnter = (0, import_react2.useCallback)(
1303
+ (e) => {
1304
+ e.preventDefault();
1305
+ e.stopPropagation();
1306
+ if (disabled || atCapacity) return;
1307
+ dragDepth.current += 1;
1308
+ setActive(true);
1309
+ },
1310
+ [atCapacity, disabled]
1311
+ );
1312
+ const onDragLeave = (0, import_react2.useCallback)((e) => {
1313
+ e.preventDefault();
1314
+ e.stopPropagation();
1315
+ dragDepth.current = Math.max(0, dragDepth.current - 1);
1316
+ if (dragDepth.current === 0) setActive(false);
1317
+ }, []);
1318
+ const onDragOver = (0, import_react2.useCallback)((e) => {
1319
+ e.preventDefault();
1320
+ e.stopPropagation();
1321
+ }, []);
1322
+ const onDrop = (0, import_react2.useCallback)(
1323
+ (e) => {
1324
+ e.preventDefault();
1325
+ e.stopPropagation();
1326
+ dragDepth.current = 0;
1327
+ setActive(false);
1328
+ if (disabled || atCapacity) return;
1329
+ if (e.dataTransfer.files?.length) {
1330
+ ingest(e.dataTransfer.files);
1331
+ }
1332
+ },
1333
+ [atCapacity, disabled, ingest]
1334
+ );
1335
+ const queueOnly = readOnly || hideDropzone;
1336
+ const removeDisabled = readOnly || disableRemove || disabled;
1337
+ const showTrigger = !queueOnly && !atCapacity;
1338
+ const isButton = variant === "button";
1339
+ const fileInput = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1340
+ "input",
1341
+ {
1342
+ ref: inputRef,
1343
+ id: inputId,
1344
+ name,
1345
+ type: "file",
1346
+ accept,
1347
+ multiple,
1348
+ disabled,
1349
+ onChange: onInputChange,
1350
+ style: { display: "none" },
1351
+ "aria-hidden": true,
1352
+ tabIndex: -1
1353
+ }
1354
+ );
1355
+ const dragHandlers = {
1356
+ onDragEnter,
1357
+ onDragLeave,
1358
+ onDragOver,
1359
+ onDrop
1360
+ };
1361
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1362
+ import_Box.default,
1363
+ {
1364
+ ref,
1365
+ className,
1366
+ "data-testid": dataTestId,
1367
+ "data-variant": variant,
1368
+ "data-readonly": readOnly || queueOnly ? "true" : void 0,
1369
+ sx: mergeSx2(fileUploadRootSx, sx),
1370
+ children: [
1371
+ label ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1372
+ MuiFormLabel,
1373
+ {
1374
+ htmlFor: showTrigger ? inputId : void 0,
1375
+ required,
1376
+ error,
1377
+ sx: {
1378
+ mb: 0.25,
1379
+ color: error ? "error.main" : "text.secondary",
1380
+ fontSize: "0.8rem",
1381
+ fontWeight: 600
1382
+ },
1383
+ children: label
1384
+ }
1385
+ ) : null,
1386
+ fileInput,
1387
+ showTrigger ? isButton ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1388
+ Button,
1389
+ {
1390
+ type: "button",
1391
+ disableElevation: true,
1392
+ disabled,
1393
+ "aria-invalid": error || void 0,
1394
+ "aria-describedby": helperText ? helperId : void 0,
1395
+ "data-active": active ? "true" : "false",
1396
+ "data-error": error ? "true" : "false",
1397
+ "data-testid": `${dataTestId}-button`,
1398
+ startIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_CloudUpload.default, { sx: { fontSize: "1.15rem" } }),
1399
+ onClick: openPicker,
1400
+ sx: fileUploadButtonSx,
1401
+ ...dragHandlers,
1402
+ children: buttonLabel
1403
+ }
1404
+ ) : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1405
+ import_Box.default,
1406
+ {
1407
+ role: "button",
1408
+ tabIndex: disabled ? -1 : 0,
1409
+ "aria-disabled": disabled || void 0,
1410
+ "aria-invalid": error || void 0,
1411
+ "aria-describedby": helperText ? helperId : void 0,
1412
+ "data-active": active ? "true" : "false",
1413
+ "data-error": error ? "true" : "false",
1414
+ "data-disabled": disabled ? "true" : "false",
1415
+ "data-testid": `${dataTestId}-dropzone`,
1416
+ sx: fileUploadDropzoneSx,
1417
+ onClick: openPicker,
1418
+ onKeyDown: (e) => {
1419
+ if (e.key === "Enter" || e.key === " ") {
1420
+ e.preventDefault();
1421
+ openPicker();
1422
+ }
1423
+ },
1424
+ ...dragHandlers,
1425
+ children: [
1426
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1427
+ import_CloudUpload.default,
1428
+ {
1429
+ "aria-hidden": true,
1430
+ sx: { fontSize: 36, color: "var(--fu-icon)", opacity: 0.9 }
1431
+ }
1432
+ ),
1433
+ typeof dropzoneTitle === "string" ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1434
+ import_Typography.default,
1435
+ {
1436
+ variant: "subtitle2",
1437
+ sx: { m: 0, color: "var(--fu-text)", fontWeight: 600 },
1438
+ children: dropzoneTitle
1439
+ }
1440
+ ) : dropzoneTitle,
1441
+ dropzoneDescription ? typeof dropzoneDescription === "string" ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1442
+ import_Typography.default,
1443
+ {
1444
+ variant: "caption",
1445
+ sx: { m: 0, color: "var(--fu-text-secondary)" },
1446
+ children: dropzoneDescription
1447
+ }
1448
+ ) : dropzoneDescription : null
1449
+ ]
1450
+ }
1451
+ ) : null,
1452
+ items.length > 0 ? itemVariant === "tile" ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1453
+ import_Box.default,
1454
+ {
1455
+ component: "ul",
1456
+ "data-testid": `${dataTestId}-list`,
1457
+ "data-item-variant": "tile",
1458
+ sx: fileUploadTileListSx,
1459
+ children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1460
+ FileUploadListItem,
1461
+ {
1462
+ item,
1463
+ disabled,
1464
+ disableRemove: removeDisabled,
1465
+ onRemove: handleRemove,
1466
+ testId: `${dataTestId}-item`,
1467
+ itemVariant: "tile"
1468
+ },
1469
+ item.id
1470
+ ))
1471
+ }
1472
+ ) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1473
+ import_Stack.default,
1474
+ {
1475
+ component: "ul",
1476
+ spacing: 1,
1477
+ "data-testid": `${dataTestId}-list`,
1478
+ "data-item-variant": "row",
1479
+ sx: { m: 0, p: 0, listStyle: "none" },
1480
+ children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1481
+ FileUploadListItem,
1482
+ {
1483
+ item,
1484
+ disabled,
1485
+ disableRemove: removeDisabled,
1486
+ onRemove: handleRemove,
1487
+ testId: `${dataTestId}-item`,
1488
+ itemVariant: "row"
1489
+ },
1490
+ item.id
1491
+ ))
1492
+ }
1493
+ ) : null,
1494
+ helperText ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1495
+ import_FormHelperText.default,
1496
+ {
1497
+ id: helperId,
1498
+ error,
1499
+ sx: { mx: 0.5, mt: 0 },
1500
+ children: helperText
1501
+ }
1502
+ ) : null
1503
+ ]
1504
+ }
1505
+ );
1506
+ }
1507
+ );
1508
+ function FileUploadTypeIcon({
1509
+ file,
1510
+ tile = false
1511
+ }) {
1512
+ const resolved = resolveFileIconStyle(
1513
+ file,
1514
+ import_react_file_icon.defaultStyles
1515
+ );
1516
+ const { extension, styleKey } = resolved;
1517
+ const iconStyle = resolved.style;
1518
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
790
1519
  import_Box.default,
791
1520
  {
792
- sx: {
793
- width: size,
794
- height: size,
795
- minWidth: size,
796
- display: "flex",
797
- alignItems: "center",
798
- justifyContent: "center",
799
- bgcolor: "transparent",
800
- borderRadius: 1,
801
- overflow: "hidden"
802
- },
803
- children: isImage && file.blobUrl ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
804
- import_Box.default,
1521
+ "aria-hidden": true,
1522
+ "data-testid": "file-upload-icon",
1523
+ "data-ext": extension || void 0,
1524
+ "data-style-key": styleKey || void 0,
1525
+ sx: tile ? fileUploadTileIconWellSx : fileUploadIconWellSx,
1526
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_Box.default, { sx: tile ? fileUploadTileLibIconSx : fileUploadLibIconSx, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1527
+ import_react_file_icon.FileIcon,
805
1528
  {
806
- component: "img",
807
- src: file.blobUrl,
808
- alt: file.filename,
809
- sx: { width: "100%", height: "100%", objectFit: "cover" }
1529
+ fold: true,
1530
+ radius: 3,
1531
+ extension,
1532
+ ...iconStyle
810
1533
  }
811
- ) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FileIcon, { fontSize: size >= 60 ? "large" : "medium", color: "action" })
1534
+ ) })
812
1535
  }
813
1536
  );
814
- };
815
- var DisplayFile = ({
1537
+ }
1538
+ function FileUploadThumb({
816
1539
  file,
817
- onDelete,
818
- mode = "thumbnail"
819
- }) => {
820
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_Box.default, { sx: {
821
- display: "flex",
822
- alignItems: "center",
823
- gap: 1,
824
- p: 1,
825
- border: "1px solid",
826
- borderColor: "divider",
827
- borderRadius: 1,
828
- width: mode === "thumbnail" ? "fit-content" : "100%",
829
- maxWidth: "100%",
830
- position: "relative"
831
- }, children: [
832
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FileThumbnail, { file }),
833
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_Box.default, { sx: { flex: 1, overflow: "hidden" }, children: [
834
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_Typography.default, { variant: "body2", noWrap: true, sx: { maxWidth: 150 }, children: file.filename }),
835
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_Typography.default, { variant: "caption", color: "text.secondary", children: file.displaySize })
836
- ] }),
837
- onDelete && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
838
- IconButton_default,
1540
+ tile = false
1541
+ }) {
1542
+ const [url, setUrl] = (0, import_react2.useState)(null);
1543
+ const [previewFailed, setPreviewFailed] = (0, import_react2.useState)(false);
1544
+ (0, import_react2.useEffect)(() => {
1545
+ setPreviewFailed(false);
1546
+ if (!isImageFile(file)) {
1547
+ setUrl(null);
1548
+ return;
1549
+ }
1550
+ const objectUrl = URL.createObjectURL(file);
1551
+ setUrl(objectUrl);
1552
+ return () => {
1553
+ URL.revokeObjectURL(objectUrl);
1554
+ };
1555
+ }, [file]);
1556
+ if (url && !previewFailed) {
1557
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1558
+ import_Box.default,
839
1559
  {
840
- size: "small",
841
- onClick: () => onDelete(file),
842
- sx: { ml: "auto" },
843
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_Close.default, { fontSize: "small" })
1560
+ component: "img",
1561
+ src: url,
1562
+ alt: "",
1563
+ "data-testid": "file-upload-thumb",
1564
+ sx: tile ? fileUploadTileMediaSx : fileUploadThumbSx,
1565
+ onError: () => setPreviewFailed(true)
844
1566
  }
845
- )
846
- ] });
847
- };
848
- DisplayFile.DISPLAY_MODEs = {
849
- thumbnail: "thumbnail",
850
- name: "name"
851
- };
852
- var DisplayFile_default = DisplayFile;
853
-
854
- // src/components/compound/FileUploader/src/DropZoneBox.tsx
855
- var import_jsx_runtime9 = require("react/jsx-runtime");
856
- var DropZoneBox = ({ getRootProps, getInputProps, error }) => {
857
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1567
+ );
1568
+ }
1569
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FileUploadTypeIcon, { file, tile });
1570
+ }
1571
+ function FileUploadListItem({
1572
+ item,
1573
+ disabled,
1574
+ disableRemove = false,
1575
+ onRemove,
1576
+ testId,
1577
+ itemVariant
1578
+ }) {
1579
+ if (itemVariant === "tile") {
1580
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1581
+ FileUploadTileItem,
1582
+ {
1583
+ item,
1584
+ disabled,
1585
+ disableRemove,
1586
+ onRemove,
1587
+ testId
1588
+ }
1589
+ );
1590
+ }
1591
+ const status = item.status ?? (item.error ? "error" : "idle");
1592
+ const showProgress = status === "uploading" || typeof item.progress === "number" && item.progress > 0 && item.progress < 100 && status !== "error" && status !== "success";
1593
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
858
1594
  import_Box.default,
859
1595
  {
860
- ...getRootProps(),
861
- sx: {
862
- flex: 1,
863
- display: "flex",
864
- flexDirection: "column",
865
- alignItems: "center",
866
- p: 3,
867
- border: "2px dashed",
868
- borderColor: error ? "error.main" : "divider",
869
- borderRadius: 1,
870
- backgroundColor: "var(--dropzone-bg)",
871
- outline: "none",
872
- transition: "border .24s ease-in-out",
873
- color: "var(--dropzone-text-color)",
874
- cursor: "pointer",
875
- "&:hover": {
876
- borderColor: "var(--dropzone-border-hover)",
877
- backgroundColor: "var(--dropzone-bg-hover)"
878
- }
879
- },
1596
+ component: "li",
1597
+ "data-testid": testId,
1598
+ "data-status": status,
1599
+ "data-item-variant": "row",
1600
+ sx: fileUploadItemSx,
880
1601
  children: [
881
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("input", { ...getInputProps() }),
882
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_NoteAdd.default, { sx: { fontSize: "2.5rem", mb: 1 } }),
883
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_Typography.default, { variant: "caption", align: "center", children: 'Drag "n" drop some files here, or click to select files' })
1602
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FileUploadThumb, { file: item.file }),
1603
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_Box.default, { sx: { flex: 1, minWidth: 0 }, children: [
1604
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1605
+ import_Typography.default,
1606
+ {
1607
+ variant: "body2",
1608
+ noWrap: true,
1609
+ title: item.file.name,
1610
+ sx: { m: 0, fontWeight: 500, color: "var(--fu-text)" },
1611
+ children: item.file.name
1612
+ }
1613
+ ),
1614
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1615
+ import_Typography.default,
1616
+ {
1617
+ variant: "caption",
1618
+ sx: { m: 0, color: "var(--fu-text-secondary)" },
1619
+ children: [
1620
+ formatFileSize(item.file.size),
1621
+ item.error ? ` \xB7 ${item.error}` : null,
1622
+ status === "success" && !item.error ? " \xB7 Done" : null
1623
+ ]
1624
+ }
1625
+ ),
1626
+ showProgress ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1627
+ LinearProgress,
1628
+ {
1629
+ variant: "determinate",
1630
+ value: Math.max(0, Math.min(100, item.progress ?? 0)),
1631
+ "aria-label": `Upload progress ${item.progress ?? 0}%`,
1632
+ sx: { mt: 0.75, height: 4, borderRadius: 2 }
1633
+ }
1634
+ ) : null,
1635
+ status === "uploading" && item.progress == null ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1636
+ LinearProgress,
1637
+ {
1638
+ "aria-label": "Uploading",
1639
+ sx: { mt: 0.75, height: 4, borderRadius: 2 }
1640
+ }
1641
+ ) : null
1642
+ ] }),
1643
+ disableRemove ? null : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1644
+ IconButton_default,
1645
+ {
1646
+ size: "small",
1647
+ "aria-label": `Remove ${item.file.name}`,
1648
+ disabled,
1649
+ onClick: () => onRemove(item),
1650
+ sx: {
1651
+ flexShrink: 0,
1652
+ color: "var(--fu-text-secondary)",
1653
+ p: 0.35
1654
+ },
1655
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_Close.default, { sx: { fontSize: "1rem" } })
1656
+ }
1657
+ )
884
1658
  ]
885
1659
  }
886
1660
  );
887
- };
888
- var DropZoneBox_default = DropZoneBox;
889
-
890
- // src/components/compound/FileUploader/src/DropZoneButton.tsx
891
- var import_jsx_runtime10 = require("react/jsx-runtime");
892
- var DropZoneButton = ({
893
- getRootProps,
894
- getInputProps,
895
- label = "Upload file",
896
- error = false
897
- }) => {
1661
+ }
1662
+ function FileUploadTileItem({
1663
+ item,
1664
+ disabled,
1665
+ disableRemove = false,
1666
+ onRemove,
1667
+ testId
1668
+ }) {
1669
+ const status = item.status ?? (item.error ? "error" : "idle");
1670
+ const showProgress = status === "uploading" || typeof item.progress === "number" && item.progress > 0 && item.progress < 100 && status !== "error" && status !== "success";
1671
+ const indeterminate = status === "uploading" && item.progress == null;
898
1672
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
899
- Button,
1673
+ import_Box.default,
900
1674
  {
901
- variant: "outlined",
902
- startIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_CloudUpload.default, {}),
903
- color: error ? "error" : "primary",
904
- ...getRootProps(),
1675
+ component: "li",
1676
+ "data-testid": testId,
1677
+ "data-status": status,
1678
+ "data-item-variant": "tile",
1679
+ title: item.file.name,
1680
+ sx: fileUploadTileSx,
905
1681
  children: [
906
- label,
907
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("input", { ...getInputProps() })
1682
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FileUploadThumb, { file: item.file, tile: true }),
1683
+ showProgress ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1684
+ LinearProgress,
1685
+ {
1686
+ variant: "determinate",
1687
+ value: Math.max(0, Math.min(100, item.progress ?? 0)),
1688
+ "aria-label": `Upload progress ${item.progress ?? 0}%`,
1689
+ sx: fileUploadTileProgressSx
1690
+ }
1691
+ ) : null,
1692
+ indeterminate ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1693
+ LinearProgress,
1694
+ {
1695
+ "aria-label": "Uploading",
1696
+ sx: fileUploadTileProgressSx
1697
+ }
1698
+ ) : null,
1699
+ disableRemove ? null : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1700
+ IconButton_default,
1701
+ {
1702
+ className: "fu-tile-remove",
1703
+ size: "small",
1704
+ "aria-label": `Remove ${item.file.name}`,
1705
+ disabled,
1706
+ onClick: (e) => {
1707
+ e.stopPropagation();
1708
+ onRemove(item);
1709
+ },
1710
+ sx: fileUploadTileRemoveSx,
1711
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_Close.default, { sx: { fontSize: "0.85rem" } })
1712
+ }
1713
+ )
908
1714
  ]
909
1715
  }
910
1716
  );
911
- };
912
- var DropZoneButton_default = DropZoneButton;
1717
+ }
913
1718
 
914
- // src/components/compound/FileUploader/src/ReactDropzone.tsx
1719
+ // src/components/elemental/Image/src/Cropper/sections/CropperFileSelector.tsx
915
1720
  var import_jsx_runtime11 = require("react/jsx-runtime");
916
- var ReactDropzone = ({
917
- filesProps,
918
- accept,
919
- maxFiles = 0,
920
- // 0 means unlimited
921
- error = false,
922
- dropzoneType = "box",
923
- label = "Upload File"
924
- }) => {
925
- const [files, setFiles] = filesProps;
926
- const blobRegistryRef = (0, import_react2.useRef)(/* @__PURE__ */ new Set());
927
- const onDrop = (0, import_react2.useCallback)((acceptedFiles) => {
928
- const newFiles = acceptedFiles.map((file) => {
929
- const blobUrl = URL.createObjectURL(file);
930
- blobRegistryRef.current.add(blobUrl);
931
- return new PreviewableFile({
932
- path: file.path,
933
- blobUrl,
934
- filename: file.name,
935
- mimeType: file.type,
936
- size: file.size,
937
- displaySize: displayFileSize(file.size),
938
- fileType: file.type.startsWith("image/") ? "image" : file.type.startsWith("application/json") ? "json" : "other"
939
- });
940
- });
941
- setFiles((prev) => [...prev, ...newFiles]);
942
- }, [setFiles]);
943
- const isLimitReached = maxFiles > 0 && files.length >= maxFiles;
944
- const { getRootProps, getInputProps } = (0, import_react_dropzone.useDropzone)({
945
- onDrop,
946
- accept,
947
- maxFiles: maxFiles > 0 ? maxFiles - files.length : void 0,
948
- disabled: isLimitReached
1721
+ function acceptToString(accept) {
1722
+ if (!accept) return "image/*";
1723
+ if (typeof accept === "string") return accept;
1724
+ const parts = [];
1725
+ Object.entries(accept).forEach(([mime, exts]) => {
1726
+ parts.push(mime);
1727
+ if (Array.isArray(exts)) parts.push(...exts);
949
1728
  });
950
- const handleDelete = (fileToDelete) => {
951
- setFiles((prev) => prev.filter((f) => f !== fileToDelete));
952
- if (fileToDelete.blobUrl) {
953
- URL.revokeObjectURL(fileToDelete.blobUrl);
954
- blobRegistryRef.current.delete(fileToDelete.blobUrl);
955
- }
956
- };
957
- (0, import_react2.useEffect)(() => {
958
- const blobRegistry = blobRegistryRef.current;
959
- return () => {
960
- blobRegistry.forEach((url) => URL.revokeObjectURL(url));
961
- blobRegistry.clear();
962
- };
963
- }, []);
964
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_Box.default, { sx: mergeSx({ maxWidth: "100%" }, fileUploaderRootSx), children: [
965
- !isLimitReached && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_Box.default, { component: "section", children: dropzoneType === "box" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropZoneBox_default, { getRootProps, getInputProps, error }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropZoneButton_default, { getRootProps, getInputProps, label, error }) }),
966
- files.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_Stack.default, { spacing: 1, sx: { mt: 0 }, children: files.map((file) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
967
- DisplayFile_default,
968
- {
969
- file,
970
- onDelete: handleDelete
971
- },
972
- file.blobUrl || file.filename || file.path
973
- )) })
974
- ] });
975
- };
976
- var ReactDropzone_default = ReactDropzone;
977
-
978
- // src/components/elemental/Image/src/Cropper/sections/CropperFileSelector.tsx
979
- var import_jsx_runtime12 = require("react/jsx-runtime");
980
- function CropperFileSelector({ accept = "image/*", buttonLabel = "Select Image", onPick }) {
981
- const [files, setFiles] = import_react3.default.useState([]);
982
- import_react3.default.useEffect(() => {
983
- }, [files]);
984
- const lastForwardedRef = import_react3.default.useRef(null);
1729
+ return parts.length ? parts.join(",") : "image/*";
1730
+ }
1731
+ function CropperFileSelector({
1732
+ accept = "image/*",
1733
+ buttonLabel = "Select Image",
1734
+ onPick
1735
+ }) {
1736
+ const [value, setValue] = import_react3.default.useState([]);
1737
+ const lastIdRef = import_react3.default.useRef(null);
985
1738
  import_react3.default.useEffect(() => {
986
- if (!files.length) {
987
- if (lastForwardedRef.current) {
988
- lastForwardedRef.current = null;
1739
+ if (!value.length) {
1740
+ if (lastIdRef.current) {
1741
+ lastIdRef.current = null;
989
1742
  onPick?.(null);
990
1743
  }
991
1744
  return;
992
1745
  }
993
- const pf = files[0];
994
- if (!pf.blobUrl) return;
995
- if (lastForwardedRef.current === pf.blobUrl) {
996
- return;
997
- }
998
- let cancelled = false;
999
- (async () => {
1000
- try {
1001
- const res = await fetch(pf.blobUrl);
1002
- const blob = await res.blob();
1003
- const file = new File([blob], pf.filename || "file", { type: pf.mimeType || void 0 });
1004
- if (!cancelled) {
1005
- lastForwardedRef.current = pf.blobUrl;
1006
- onPick?.(file);
1746
+ const item = value[0];
1747
+ if (lastIdRef.current === item.id) return;
1748
+ lastIdRef.current = item.id;
1749
+ onPick?.(item.file);
1750
+ }, [value, onPick]);
1751
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1752
+ import_Box.default,
1753
+ {
1754
+ sx: {
1755
+ display: "flex",
1756
+ alignItems: "center",
1757
+ justifyContent: "center",
1758
+ width: "100%",
1759
+ pt: 0
1760
+ },
1761
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1762
+ FileUpload,
1763
+ {
1764
+ value,
1765
+ onChange: setValue,
1766
+ accept: acceptToString(accept),
1767
+ maxFiles: 1,
1768
+ multiple: false,
1769
+ variant: "button",
1770
+ buttonLabel,
1771
+ itemVariant: "tile",
1772
+ sx: {
1773
+ width: "fit-content",
1774
+ maxWidth: "100%",
1775
+ alignItems: "center",
1776
+ "& .MuiButton-root": { alignSelf: "center" },
1777
+ '& [data-testid$="-list"]': { justifyContent: "center" }
1778
+ }
1007
1779
  }
1008
- } catch {
1009
- }
1010
- })();
1011
- return () => {
1012
- cancelled = true;
1013
- };
1014
- }, [files, onPick]);
1015
- const acceptProp = typeof accept === "string" ? { [accept]: [] } : accept;
1016
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_Box.default, { sx: { display: "flex", alignItems: "center", pt: 0, width: "100%", justifyContent: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ReactDropzone_default, { filesProps: [files, setFiles], accept: acceptProp, maxFiles: 1, dropzoneType: "button", label: buttonLabel }) });
1780
+ )
1781
+ }
1782
+ );
1017
1783
  }
1018
1784
 
1019
1785
  // src/components/elemental/Image/src/Cropper/hooks/useCropperState.ts
@@ -1241,7 +2007,7 @@ function useCropperState({
1241
2007
  }
1242
2008
 
1243
2009
  // src/components/elemental/Image/src/Cropper/Cropper.tsx
1244
- var import_jsx_runtime13 = require("react/jsx-runtime");
2010
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1245
2011
  var Cropper = ({
1246
2012
  blobUrl,
1247
2013
  onSave,
@@ -1283,10 +2049,10 @@ var Cropper = ({
1283
2049
  defaultRatio,
1284
2050
  cropConfig
1285
2051
  });
1286
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2052
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1287
2053
  CropperLayout,
1288
2054
  {
1289
- left: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2055
+ left: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1290
2056
  CropperSourceSection,
1291
2057
  {
1292
2058
  activeBlobUrl,
@@ -1302,7 +2068,7 @@ var Cropper = ({
1302
2068
  onImageLoad
1303
2069
  }
1304
2070
  ),
1305
- right: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2071
+ right: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1306
2072
  CropperControlsSection,
1307
2073
  {
1308
2074
  PreviewRenderer,
@@ -1313,9 +2079,9 @@ var Cropper = ({
1313
2079
  setScale
1314
2080
  }
1315
2081
  ),
1316
- leftFooter: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
2082
+ leftFooter: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
1317
2083
  footerExtra,
1318
- showFileSelector && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2084
+ showFileSelector && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1319
2085
  CropperFileSelector,
1320
2086
  {
1321
2087
  accept: fileSelectorAccept,
@@ -1324,7 +2090,7 @@ var Cropper = ({
1324
2090
  }
1325
2091
  )
1326
2092
  ] }),
1327
- footer: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2093
+ footer: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1328
2094
  CropperActionSection,
1329
2095
  {
1330
2096
  onSave: handleSave,