@tribepad/themis 1.0.0 → 1.0.1

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 (326) hide show
  1. package/dist/elements/Accordion/index.js +325 -66
  2. package/dist/elements/Accordion/index.js.map +1 -1
  3. package/dist/elements/Accordion/index.mjs +317 -3
  4. package/dist/elements/Accordion/index.mjs.map +1 -1
  5. package/dist/elements/Avatar/index.js +461 -45
  6. package/dist/elements/Avatar/index.js.map +1 -1
  7. package/dist/elements/Avatar/index.mjs +456 -3
  8. package/dist/elements/Avatar/index.mjs.map +1 -1
  9. package/dist/elements/Badge/index.js +238 -36
  10. package/dist/elements/Badge/index.js.map +1 -1
  11. package/dist/elements/Badge/index.mjs +234 -4
  12. package/dist/elements/Badge/index.mjs.map +1 -1
  13. package/dist/elements/Breadcrumbs/index.js +808 -39
  14. package/dist/elements/Breadcrumbs/index.js.map +1 -1
  15. package/dist/elements/Breadcrumbs/index.mjs +810 -7
  16. package/dist/elements/Breadcrumbs/index.mjs.map +1 -1
  17. package/dist/elements/Button/index.js +282 -19
  18. package/dist/elements/Button/index.js.map +1 -1
  19. package/dist/elements/Button/index.mjs +283 -4
  20. package/dist/elements/Button/index.mjs.map +1 -1
  21. package/dist/elements/ButtonGroup/index.js +229 -56
  22. package/dist/elements/ButtonGroup/index.js.map +1 -1
  23. package/dist/elements/ButtonGroup/index.mjs +222 -3
  24. package/dist/elements/ButtonGroup/index.mjs.map +1 -1
  25. package/dist/elements/Card/Card.d.ts.map +1 -1
  26. package/dist/elements/Card/index.js +563 -67
  27. package/dist/elements/Card/index.js.map +1 -1
  28. package/dist/elements/Card/index.mjs +560 -6
  29. package/dist/elements/Card/index.mjs.map +1 -1
  30. package/dist/elements/Carousel/index.js +782 -14
  31. package/dist/elements/Carousel/index.js.map +1 -1
  32. package/dist/elements/Carousel/index.mjs +786 -8
  33. package/dist/elements/Carousel/index.mjs.map +1 -1
  34. package/dist/elements/Chart/index.js +1833 -36
  35. package/dist/elements/Chart/index.js.map +1 -1
  36. package/dist/elements/Chart/index.mjs +1832 -4
  37. package/dist/elements/Chart/index.mjs.map +1 -1
  38. package/dist/elements/Checkbox/index.js +310 -39
  39. package/dist/elements/Checkbox/index.js.map +1 -1
  40. package/dist/elements/Checkbox/index.mjs +306 -4
  41. package/dist/elements/Checkbox/index.mjs.map +1 -1
  42. package/dist/elements/CheckboxGroup/index.js +445 -59
  43. package/dist/elements/CheckboxGroup/index.js.map +1 -1
  44. package/dist/elements/CheckboxGroup/index.mjs +439 -4
  45. package/dist/elements/CheckboxGroup/index.mjs.map +1 -1
  46. package/dist/elements/DatePicker/index.js +871 -89
  47. package/dist/elements/DatePicker/index.js.map +1 -1
  48. package/dist/elements/DatePicker/index.mjs +853 -4
  49. package/dist/elements/DatePicker/index.mjs.map +1 -1
  50. package/dist/elements/Dropdown/index.js +189 -35
  51. package/dist/elements/Dropdown/index.js.map +1 -1
  52. package/dist/elements/Dropdown/index.mjs +184 -2
  53. package/dist/elements/Dropdown/index.mjs.map +1 -1
  54. package/dist/elements/FileField/index.js +1532 -129
  55. package/dist/elements/FileField/index.js.map +1 -1
  56. package/dist/elements/FileField/index.mjs +1507 -7
  57. package/dist/elements/FileField/index.mjs.map +1 -1
  58. package/dist/elements/FormLayout/index.js +166 -11
  59. package/dist/elements/FormLayout/index.js.map +1 -1
  60. package/dist/elements/FormLayout/index.mjs +167 -2
  61. package/dist/elements/FormLayout/index.mjs.map +1 -1
  62. package/dist/elements/Modal/index.js +228 -46
  63. package/dist/elements/Modal/index.js.map +1 -1
  64. package/dist/elements/Modal/index.mjs +220 -1
  65. package/dist/elements/Modal/index.mjs.map +1 -1
  66. package/dist/elements/NumberField/index.js +659 -48
  67. package/dist/elements/NumberField/index.js.map +1 -1
  68. package/dist/elements/NumberField/index.mjs +654 -6
  69. package/dist/elements/NumberField/index.mjs.map +1 -1
  70. package/dist/elements/OTPInput/index.js +729 -6
  71. package/dist/elements/OTPInput/index.js.map +1 -1
  72. package/dist/elements/OTPInput/index.mjs +732 -2
  73. package/dist/elements/OTPInput/index.mjs.map +1 -1
  74. package/dist/elements/Panel/index.js +326 -27
  75. package/dist/elements/Panel/index.js.map +1 -1
  76. package/dist/elements/Panel/index.mjs +323 -2
  77. package/dist/elements/Panel/index.mjs.map +1 -1
  78. package/dist/elements/Progress/index.js +181 -22
  79. package/dist/elements/Progress/index.js.map +1 -1
  80. package/dist/elements/Progress/index.mjs +181 -3
  81. package/dist/elements/Progress/index.mjs.map +1 -1
  82. package/dist/elements/RadioGroup/index.js +358 -34
  83. package/dist/elements/RadioGroup/index.js.map +1 -1
  84. package/dist/elements/RadioGroup/index.mjs +359 -4
  85. package/dist/elements/RadioGroup/index.mjs.map +1 -1
  86. package/dist/elements/Resizable/components/ResizableHandle.d.ts +0 -8
  87. package/dist/elements/Resizable/components/ResizableHandle.d.ts.map +1 -1
  88. package/dist/elements/Resizable/components/ResizablePanel.d.ts +0 -8
  89. package/dist/elements/Resizable/components/ResizablePanel.d.ts.map +1 -1
  90. package/dist/elements/Resizable/components/ResizablePanelGroup.d.ts +0 -8
  91. package/dist/elements/Resizable/components/ResizablePanelGroup.d.ts.map +1 -1
  92. package/dist/elements/Resizable/components/ResizablePopover.d.ts +0 -8
  93. package/dist/elements/Resizable/components/ResizablePopover.d.ts.map +1 -1
  94. package/dist/elements/Resizable/index.js +1568 -51
  95. package/dist/elements/Resizable/index.js.map +1 -1
  96. package/dist/elements/Resizable/index.mjs +1566 -6
  97. package/dist/elements/Resizable/index.mjs.map +1 -1
  98. package/dist/elements/Select/index.js +580 -22
  99. package/dist/elements/Select/index.js.map +1 -1
  100. package/dist/elements/Select/index.mjs +582 -2
  101. package/dist/elements/Select/index.mjs.map +1 -1
  102. package/dist/elements/Skeleton/index.js +77 -15
  103. package/dist/elements/Skeleton/index.js.map +1 -1
  104. package/dist/elements/Skeleton/index.mjs +78 -3
  105. package/dist/elements/Skeleton/index.mjs.map +1 -1
  106. package/dist/elements/Switch/index.js +153 -21
  107. package/dist/elements/Switch/index.js.map +1 -1
  108. package/dist/elements/Switch/index.mjs +149 -5
  109. package/dist/elements/Switch/index.mjs.map +1 -1
  110. package/dist/elements/Table/index.js +589 -68
  111. package/dist/elements/Table/index.js.map +1 -1
  112. package/dist/elements/Table/index.mjs +578 -5
  113. package/dist/elements/Table/index.mjs.map +1 -1
  114. package/dist/elements/Tabs/index.js +328 -63
  115. package/dist/elements/Tabs/index.js.map +1 -1
  116. package/dist/elements/Tabs/index.mjs +320 -3
  117. package/dist/elements/Tabs/index.mjs.map +1 -1
  118. package/dist/elements/TextField/index.js +695 -51
  119. package/dist/elements/TextField/index.js.map +1 -1
  120. package/dist/elements/TextField/index.mjs +684 -7
  121. package/dist/elements/TextField/index.mjs.map +1 -1
  122. package/dist/elements/TimeField/index.js +244 -33
  123. package/dist/elements/TimeField/index.js.map +1 -1
  124. package/dist/elements/TimeField/index.mjs +238 -2
  125. package/dist/elements/TimeField/index.mjs.map +1 -1
  126. package/dist/elements/Toast/index.js +727 -48
  127. package/dist/elements/Toast/index.js.map +1 -1
  128. package/dist/elements/Toast/index.mjs +724 -5
  129. package/dist/elements/Toast/index.mjs.map +1 -1
  130. package/dist/elements/Tooltip/index.js +315 -49
  131. package/dist/elements/Tooltip/index.js.map +1 -1
  132. package/dist/elements/Tooltip/index.mjs +310 -4
  133. package/dist/elements/Tooltip/index.mjs.map +1 -1
  134. package/dist/elements/index.js +12417 -799
  135. package/dist/elements/index.js.map +1 -1
  136. package/dist/elements/index.mjs +12233 -40
  137. package/dist/elements/index.mjs.map +1 -1
  138. package/dist/index.js +12452 -825
  139. package/dist/index.js.map +1 -1
  140. package/dist/index.mjs +12262 -42
  141. package/dist/index.mjs.map +1 -1
  142. package/dist/schemas/index.js +47 -21
  143. package/dist/schemas/index.js.map +1 -1
  144. package/dist/schemas/index.mjs +47 -2
  145. package/dist/schemas/index.mjs.map +1 -1
  146. package/dist/styles/index.js +161 -147
  147. package/dist/styles/index.js.map +1 -1
  148. package/dist/styles/index.mjs +128 -2
  149. package/dist/styles/index.mjs.map +1 -1
  150. package/dist/utils/index.js +7 -7
  151. package/dist/utils/index.js.map +1 -1
  152. package/dist/utils/index.mjs +9 -2
  153. package/dist/utils/index.mjs.map +1 -1
  154. package/package.json +1 -1
  155. package/dist/Carousel-NTZX5TOW.js +0 -16
  156. package/dist/Carousel-NTZX5TOW.js.map +0 -1
  157. package/dist/Carousel-YH3DOQJU.mjs +0 -7
  158. package/dist/Carousel-YH3DOQJU.mjs.map +0 -1
  159. package/dist/chunk-2HIUTHMU.mjs +0 -234
  160. package/dist/chunk-2HIUTHMU.mjs.map +0 -1
  161. package/dist/chunk-34GTFTDO.js +0 -431
  162. package/dist/chunk-34GTFTDO.js.map +0 -1
  163. package/dist/chunk-3H7ASYR7.js +0 -250
  164. package/dist/chunk-3H7ASYR7.js.map +0 -1
  165. package/dist/chunk-3IEN7JOP.js +0 -316
  166. package/dist/chunk-3IEN7JOP.js.map +0 -1
  167. package/dist/chunk-3JHN4GAL.js +0 -326
  168. package/dist/chunk-3JHN4GAL.js.map +0 -1
  169. package/dist/chunk-3MJPASQU.js +0 -232
  170. package/dist/chunk-3MJPASQU.js.map +0 -1
  171. package/dist/chunk-3XD2JUL3.js +0 -572
  172. package/dist/chunk-3XD2JUL3.js.map +0 -1
  173. package/dist/chunk-3YOY2VJ6.js +0 -189
  174. package/dist/chunk-3YOY2VJ6.js.map +0 -1
  175. package/dist/chunk-4DU5JSXB.js +0 -408
  176. package/dist/chunk-4DU5JSXB.js.map +0 -1
  177. package/dist/chunk-4E4E2GSS.js +0 -352
  178. package/dist/chunk-4E4E2GSS.js.map +0 -1
  179. package/dist/chunk-4NHAP4AN.mjs +0 -3
  180. package/dist/chunk-4NHAP4AN.mjs.map +0 -1
  181. package/dist/chunk-4S33J5NY.mjs +0 -415
  182. package/dist/chunk-4S33J5NY.mjs.map +0 -1
  183. package/dist/chunk-5SMGRT3G.mjs +0 -354
  184. package/dist/chunk-5SMGRT3G.mjs.map +0 -1
  185. package/dist/chunk-5SVLJN2C.mjs +0 -22
  186. package/dist/chunk-5SVLJN2C.mjs.map +0 -1
  187. package/dist/chunk-66WTU4EB.mjs +0 -299
  188. package/dist/chunk-66WTU4EB.mjs.map +0 -1
  189. package/dist/chunk-6S25NMOT.mjs +0 -335
  190. package/dist/chunk-6S25NMOT.mjs.map +0 -1
  191. package/dist/chunk-6SP7UB3D.js +0 -4
  192. package/dist/chunk-6SP7UB3D.js.map +0 -1
  193. package/dist/chunk-6TYWWQHM.mjs +0 -565
  194. package/dist/chunk-6TYWWQHM.mjs.map +0 -1
  195. package/dist/chunk-A3YUJA6W.mjs +0 -384
  196. package/dist/chunk-A3YUJA6W.mjs.map +0 -1
  197. package/dist/chunk-A6KEDVUR.js +0 -61
  198. package/dist/chunk-A6KEDVUR.js.map +0 -1
  199. package/dist/chunk-A77RUEWL.js +0 -730
  200. package/dist/chunk-A77RUEWL.js.map +0 -1
  201. package/dist/chunk-AA4IKMPE.mjs +0 -3
  202. package/dist/chunk-AA4IKMPE.mjs.map +0 -1
  203. package/dist/chunk-AKIA6GW6.mjs +0 -163
  204. package/dist/chunk-AKIA6GW6.mjs.map +0 -1
  205. package/dist/chunk-AL6P275L.mjs +0 -435
  206. package/dist/chunk-AL6P275L.mjs.map +0 -1
  207. package/dist/chunk-AZ3RJYTB.js +0 -37
  208. package/dist/chunk-AZ3RJYTB.js.map +0 -1
  209. package/dist/chunk-B5Q4UPL6.js +0 -32
  210. package/dist/chunk-B5Q4UPL6.js.map +0 -1
  211. package/dist/chunk-B6DHPMDP.mjs +0 -335
  212. package/dist/chunk-B6DHPMDP.mjs.map +0 -1
  213. package/dist/chunk-BDXKKMBZ.mjs +0 -184
  214. package/dist/chunk-BDXKKMBZ.mjs.map +0 -1
  215. package/dist/chunk-BL6E2DLZ.mjs +0 -52
  216. package/dist/chunk-BL6E2DLZ.mjs.map +0 -1
  217. package/dist/chunk-CGFDS4XS.mjs +0 -121
  218. package/dist/chunk-CGFDS4XS.mjs.map +0 -1
  219. package/dist/chunk-CJIW5TKI.js +0 -139
  220. package/dist/chunk-CJIW5TKI.js.map +0 -1
  221. package/dist/chunk-CKNISJOQ.js +0 -314
  222. package/dist/chunk-CKNISJOQ.js.map +0 -1
  223. package/dist/chunk-D6CBOECS.mjs +0 -1757
  224. package/dist/chunk-D6CBOECS.mjs.map +0 -1
  225. package/dist/chunk-DDWEVC2S.js +0 -166
  226. package/dist/chunk-DDWEVC2S.js.map +0 -1
  227. package/dist/chunk-DZ556D2F.mjs +0 -176
  228. package/dist/chunk-DZ556D2F.mjs.map +0 -1
  229. package/dist/chunk-E2KQFV3O.mjs +0 -10
  230. package/dist/chunk-E2KQFV3O.mjs.map +0 -1
  231. package/dist/chunk-EMMLADSC.js +0 -126
  232. package/dist/chunk-EMMLADSC.js.map +0 -1
  233. package/dist/chunk-EP4WOI5D.mjs +0 -926
  234. package/dist/chunk-EP4WOI5D.mjs.map +0 -1
  235. package/dist/chunk-FJRXLJC2.mjs +0 -160
  236. package/dist/chunk-FJRXLJC2.mjs.map +0 -1
  237. package/dist/chunk-FKQI434R.js +0 -345
  238. package/dist/chunk-FKQI434R.js.map +0 -1
  239. package/dist/chunk-FPKEAJRZ.mjs +0 -100
  240. package/dist/chunk-FPKEAJRZ.mjs.map +0 -1
  241. package/dist/chunk-FWQYB22U.js +0 -183
  242. package/dist/chunk-FWQYB22U.js.map +0 -1
  243. package/dist/chunk-GD5GHTMA.js +0 -189
  244. package/dist/chunk-GD5GHTMA.js.map +0 -1
  245. package/dist/chunk-GE5XTSDZ.js +0 -447
  246. package/dist/chunk-GE5XTSDZ.js.map +0 -1
  247. package/dist/chunk-GVE47ZAX.mjs +0 -32
  248. package/dist/chunk-GVE47ZAX.mjs.map +0 -1
  249. package/dist/chunk-HK46BT5U.mjs +0 -18
  250. package/dist/chunk-HK46BT5U.mjs.map +0 -1
  251. package/dist/chunk-HQVRMR6N.js +0 -365
  252. package/dist/chunk-HQVRMR6N.js.map +0 -1
  253. package/dist/chunk-HSGBJPJO.mjs +0 -398
  254. package/dist/chunk-HSGBJPJO.mjs.map +0 -1
  255. package/dist/chunk-I3AUTOMZ.mjs +0 -125
  256. package/dist/chunk-I3AUTOMZ.mjs.map +0 -1
  257. package/dist/chunk-IEI5LD5C.mjs +0 -1161
  258. package/dist/chunk-IEI5LD5C.mjs.map +0 -1
  259. package/dist/chunk-IIPTC2X7.mjs +0 -118
  260. package/dist/chunk-IIPTC2X7.mjs.map +0 -1
  261. package/dist/chunk-J7TLHF2Q.js +0 -4
  262. package/dist/chunk-J7TLHF2Q.js.map +0 -1
  263. package/dist/chunk-JJOWXFXQ.mjs +0 -765
  264. package/dist/chunk-JJOWXFXQ.mjs.map +0 -1
  265. package/dist/chunk-JPTSS2OA.mjs +0 -3
  266. package/dist/chunk-JPTSS2OA.mjs.map +0 -1
  267. package/dist/chunk-KFXXRLTP.js +0 -396
  268. package/dist/chunk-KFXXRLTP.js.map +0 -1
  269. package/dist/chunk-KPRRBSG6.mjs +0 -272
  270. package/dist/chunk-KPRRBSG6.mjs.map +0 -1
  271. package/dist/chunk-NFSBGRDB.mjs +0 -57
  272. package/dist/chunk-NFSBGRDB.mjs.map +0 -1
  273. package/dist/chunk-NGJVCFTM.js +0 -219
  274. package/dist/chunk-NGJVCFTM.js.map +0 -1
  275. package/dist/chunk-NSQ6MZJ6.mjs +0 -728
  276. package/dist/chunk-NSQ6MZJ6.mjs.map +0 -1
  277. package/dist/chunk-NYQYHT76.mjs +0 -296
  278. package/dist/chunk-NYQYHT76.mjs.map +0 -1
  279. package/dist/chunk-OLJJGI5B.js +0 -1193
  280. package/dist/chunk-OLJJGI5B.js.map +0 -1
  281. package/dist/chunk-Q3572X2J.js +0 -292
  282. package/dist/chunk-Q3572X2J.js.map +0 -1
  283. package/dist/chunk-QH7N7D4I.mjs +0 -210
  284. package/dist/chunk-QH7N7D4I.mjs.map +0 -1
  285. package/dist/chunk-R7XUIV25.js +0 -466
  286. package/dist/chunk-R7XUIV25.js.map +0 -1
  287. package/dist/chunk-RFFO4KPM.js +0 -135
  288. package/dist/chunk-RFFO4KPM.js.map +0 -1
  289. package/dist/chunk-RFX7QKA7.mjs +0 -180
  290. package/dist/chunk-RFX7QKA7.mjs.map +0 -1
  291. package/dist/chunk-SN5LFAP3.js +0 -940
  292. package/dist/chunk-SN5LFAP3.js.map +0 -1
  293. package/dist/chunk-T4COXKQ3.js +0 -24
  294. package/dist/chunk-T4COXKQ3.js.map +0 -1
  295. package/dist/chunk-TS54QM27.js +0 -125
  296. package/dist/chunk-TS54QM27.js.map +0 -1
  297. package/dist/chunk-UE2S4PCX.mjs +0 -220
  298. package/dist/chunk-UE2S4PCX.mjs.map +0 -1
  299. package/dist/chunk-UTW3QX2A.mjs +0 -282
  300. package/dist/chunk-UTW3QX2A.mjs.map +0 -1
  301. package/dist/chunk-V74LGMAE.js +0 -1767
  302. package/dist/chunk-V74LGMAE.js.map +0 -1
  303. package/dist/chunk-VIREG536.js +0 -12
  304. package/dist/chunk-VIREG536.js.map +0 -1
  305. package/dist/chunk-VY7M7346.js +0 -4
  306. package/dist/chunk-VY7M7346.js.map +0 -1
  307. package/dist/chunk-W3TJOO7H.mjs +0 -319
  308. package/dist/chunk-W3TJOO7H.mjs.map +0 -1
  309. package/dist/chunk-WIUOB36M.js +0 -54
  310. package/dist/chunk-WIUOB36M.js.map +0 -1
  311. package/dist/chunk-WJGLM4CY.js +0 -291
  312. package/dist/chunk-WJGLM4CY.js.map +0 -1
  313. package/dist/chunk-WNURH5OO.mjs +0 -453
  314. package/dist/chunk-WNURH5OO.mjs.map +0 -1
  315. package/dist/chunk-X25TNRSD.mjs +0 -364
  316. package/dist/chunk-X25TNRSD.mjs.map +0 -1
  317. package/dist/chunk-Y3GT7ETK.js +0 -108
  318. package/dist/chunk-Y3GT7ETK.js.map +0 -1
  319. package/dist/chunk-Z4FRNOF6.mjs +0 -115
  320. package/dist/chunk-Z4FRNOF6.mjs.map +0 -1
  321. package/dist/chunk-ZMYLD3BN.js +0 -166
  322. package/dist/chunk-ZMYLD3BN.js.map +0 -1
  323. package/dist/chunk-ZP2KV6EX.js +0 -815
  324. package/dist/chunk-ZP2KV6EX.js.map +0 -1
  325. package/dist/chunk-ZVKXFELU.js +0 -366
  326. package/dist/chunk-ZVKXFELU.js.map +0 -1
@@ -1,9 +1,1509 @@
1
- export { FileField, FileFieldPropsSchema, FilePreview, FileProgress, RESIZE_THRESHOLD, createResizedPreview, deduplicateFiles, fileFieldContainerVariants, fileFieldDescriptionVariants, fileFieldDropZoneVariants, fileFieldErrorVariants, fileFieldItemVariants, fileFieldLabelVariants, fileFieldListVariants, fileFieldRemoveButtonVariants, fileFieldSuccessVariants, fileFieldTriggerVariants, fileProgressBarVariants, fileProgressErrorVariants, fileProgressHeaderVariants, fileProgressRetryVariants, fileProgressTrackVariants, fileProgressVariants, formatAcceptedTypes, formatFileSize, generatePreview, getFileIcon, isFileTypeAccepted, isImageFile, truncateFileName, useFilePreview } from '../../chunk-IEI5LD5C.mjs';
2
- import '../../chunk-BDXKKMBZ.mjs';
3
- import '../../chunk-FPKEAJRZ.mjs';
4
- import '../../chunk-Z4FRNOF6.mjs';
5
- import '../../chunk-HK46BT5U.mjs';
6
- import '../../chunk-E2KQFV3O.mjs';
7
- import '../../chunk-5SVLJN2C.mjs';
1
+ "use client";
2
+ import { createContext, memo, forwardRef, useId, useState, useRef, useCallback, useContext, useEffect } from 'react';
3
+ import { Button as Button$1, FileTrigger, ProgressBar } from 'react-aria-components';
4
+ import { cva } from 'class-variance-authority';
5
+ import { Loader2, Zap, Upload, X, FileIcon, AudioLines, VideoIcon, ImageIcon } from 'lucide-react';
6
+ import { clsx } from 'clsx';
7
+ import { twMerge } from 'tailwind-merge';
8
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
9
+ import { z } from 'zod';
10
+
11
+ // src/elements/FileField/FileField.tsx
12
+ function cn(...inputs) {
13
+ return twMerge(clsx(inputs));
14
+ }
15
+ var PRESSED_STYLES = "data-[pressed]:scale-[0.97]";
16
+ var HOVER_STYLES = "data-[hovered]:shadow-md";
17
+ var HIGH_CONTRAST_HOVER = "hc:data-[hovered]:outline hc:data-[hovered]:outline-2 hc:data-[hovered]:outline-foreground";
18
+ var HIGH_CONTRAST_PRESSED = "hc:data-[pressed]:outline hc:data-[pressed]:outline-2 hc:data-[pressed]:outline-offset-1 hc:data-[pressed]:outline-foreground";
19
+ var ButtonGroupContext = createContext(null);
20
+ ButtonGroupContext.displayName = "ButtonGroupContext";
21
+ function useButtonGroupContext() {
22
+ return useContext(ButtonGroupContext);
23
+ }
24
+ var ButtonGroupItemContext = createContext(null);
25
+ ButtonGroupItemContext.displayName = "ButtonGroupItemContext";
26
+ function useButtonGroupItemContext() {
27
+ return useContext(ButtonGroupItemContext);
28
+ }
29
+ cva("inline-flex items-center gap-0", {
30
+ variants: {
31
+ orientation: {
32
+ horizontal: "flex-row",
33
+ vertical: "flex-col w-full"
34
+ }
35
+ },
36
+ defaultVariants: {
37
+ orientation: "horizontal"
38
+ }
39
+ });
40
+ var buttonGroupItemVariants = cva("", {
41
+ variants: {
42
+ orientation: {
43
+ // min-w-[44px] ensures visual layer fills touch target width (for icon buttons)
44
+ horizontal: "min-w-[44px]",
45
+ // flex (overrides inline-flex) + min-h-[44px] makes visual layer fill touch target,
46
+ // eliminating gaps between stacked buttons in vertical orientation
47
+ vertical: "flex min-h-[44px]"
48
+ },
49
+ position: {
50
+ first: "",
51
+ middle: "",
52
+ last: "",
53
+ only: ""
54
+ // Single button - no modifications needed
55
+ }
56
+ },
57
+ compoundVariants: [
58
+ // ==========================================================================
59
+ // Horizontal Orientation
60
+ // ==========================================================================
61
+ {
62
+ orientation: "horizontal",
63
+ position: "first",
64
+ className: "rounded-r-none border-r-0"
65
+ },
66
+ {
67
+ orientation: "horizontal",
68
+ position: "middle",
69
+ className: "rounded-none border-r-0"
70
+ },
71
+ {
72
+ orientation: "horizontal",
73
+ position: "last",
74
+ className: "rounded-l-none"
75
+ },
76
+ // ==========================================================================
77
+ // Vertical Orientation
78
+ // Note: w-full is handled by Button's effectiveFullWidth for both layers
79
+ // ==========================================================================
80
+ {
81
+ orientation: "vertical",
82
+ position: "first",
83
+ className: "rounded-b-none border-b-0"
84
+ },
85
+ {
86
+ orientation: "vertical",
87
+ position: "middle",
88
+ className: "rounded-none border-b-0"
89
+ },
90
+ {
91
+ orientation: "vertical",
92
+ position: "last",
93
+ className: "rounded-t-none"
94
+ }
95
+ ],
96
+ defaultVariants: {
97
+ orientation: "horizontal",
98
+ position: "only"
99
+ }
100
+ });
101
+ cva("bg-[var(--border)]", {
102
+ variants: {
103
+ orientation: {
104
+ horizontal: "w-px h-6 mx-1",
105
+ vertical: "h-px w-full my-1"
106
+ }
107
+ },
108
+ defaultVariants: {
109
+ orientation: "horizontal"
110
+ }
111
+ });
112
+ var buttonOuterVariants = cva(
113
+ "inline-flex justify-center min-h-[44px] min-w-[44px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)] focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50",
114
+ {
115
+ variants: {
116
+ fullWidth: {
117
+ true: "w-full",
118
+ false: ""
119
+ },
120
+ inVerticalGroup: {
121
+ true: "items-stretch",
122
+ false: "items-center"
123
+ }
124
+ },
125
+ defaultVariants: {
126
+ fullWidth: false,
127
+ inVerticalGroup: false
128
+ }
129
+ }
130
+ );
131
+ var buttonVisualVariants = cva(
132
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 relative cursor-pointer",
133
+ {
134
+ variants: {
135
+ variant: {
136
+ default: "bg-[var(--primary-action)] text-[var(--primary-action-foreground)] shadow-md hover:bg-[var(--primary-action-hover)] data-[pressed]:bg-[var(--primary-action)]/80",
137
+ destructive: "bg-[var(--destructive-background)] text-[var(--destructive-foreground)] shadow-md hover:bg-[var(--destructive-background)]/90 data-[pressed]:bg-[var(--destructive-background)]/80",
138
+ outline: "border border-[var(--input-border)] bg-[var(--page-background)] hover:bg-[var(--input-border)] data-[pressed]:bg-[var(--input-border)]",
139
+ secondary: "bg-[var(--secondary)] text-[var(--secondary-foreground)] shadow-md hover:bg-[var(--secondary)]/80 data-[pressed]:bg-[var(--secondary)]/70",
140
+ ghost: "hover:bg-[var(--accent)] hover:text-[var(--accent-foreground)] data-[pressed]:bg-[var(--accent)]",
141
+ link: "text-[var(--text-link)] underline-offset-4 hover:underline data-[pressed]:text-[var(--text-link-hover)]"
142
+ },
143
+ fullWidth: {
144
+ true: "w-full",
145
+ false: ""
146
+ },
147
+ visualSize: {
148
+ default: "h-10 px-4 py-2",
149
+ sm: "h-9 rounded-md px-3 text-xs",
150
+ lg: "h-11 rounded-md px-8",
151
+ icon: "h-10 w-10",
152
+ dot: "h-5 w-5 rounded-full p-0 min-h-0 min-w-0"
153
+ },
154
+ paywall: {
155
+ true: "!bg-[var(--paywall)] !text-[var(--paywall-foreground)] !shadow-md hover:!bg-[var(--paywall)]/90 !cursor-not-allowed !border-transparent",
156
+ false: ""
157
+ }
158
+ },
159
+ defaultVariants: {
160
+ variant: "default",
161
+ visualSize: "default",
162
+ paywall: false
163
+ }
164
+ }
165
+ );
166
+ var Button = memo(forwardRef(
167
+ ({
168
+ className,
169
+ buttonVisualClassName,
170
+ variant,
171
+ size,
172
+ visualSize,
173
+ fullWidth,
174
+ loading = false,
175
+ loadingText = "Loading...",
176
+ shortcut,
177
+ children,
178
+ isDisabled,
179
+ paywall = false,
180
+ paywallRedirect,
181
+ paywallDescription,
182
+ onPress,
183
+ ...props
184
+ }, ref) => {
185
+ const paywallDescriptionId = useId();
186
+ const groupContext = useButtonGroupContext();
187
+ const itemContext = useButtonGroupItemContext();
188
+ const effectiveVariant = variant ?? groupContext?.variant ?? "default";
189
+ const effectiveSize = size ?? groupContext?.size;
190
+ const effectiveIsDisabled = isDisabled ?? groupContext?.isDisabled ?? false;
191
+ const isInVerticalGroup = groupContext?.orientation === "vertical";
192
+ const effectiveFullWidth = fullWidth || isInVerticalGroup;
193
+ const positionClassName = itemContext ? buttonGroupItemVariants({
194
+ orientation: groupContext?.orientation ?? "horizontal",
195
+ position: itemContext.position
196
+ }) : "";
197
+ const effectiveVisualSize = visualSize ?? effectiveSize ?? "default";
198
+ if (process.env.NODE_ENV !== "production") {
199
+ if ((effectiveVisualSize === "dot" || effectiveVisualSize === "icon") && !props["aria-label"] && !children) {
200
+ console.warn(
201
+ '[Button] visualSize="dot" or "icon" requires aria-label when no visible text is provided (WCAG 1.1.1)'
202
+ );
203
+ }
204
+ }
205
+ const handlePress = (e) => {
206
+ if (paywall) {
207
+ if (paywallRedirect) {
208
+ window.open(paywallRedirect, "_blank", "noopener,noreferrer");
209
+ }
210
+ return;
211
+ }
212
+ onPress?.(e);
213
+ };
214
+ const computedIsDisabled = effectiveIsDisabled || loading || void 0;
215
+ return /* @__PURE__ */ jsx(
216
+ Button$1,
217
+ {
218
+ ref,
219
+ isDisabled: computedIsDisabled,
220
+ "aria-disabled": paywall ? true : void 0,
221
+ "aria-describedby": paywall ? paywallDescriptionId : void 0,
222
+ onPress: handlePress,
223
+ className: cn(buttonOuterVariants({ fullWidth: effectiveFullWidth, inVerticalGroup: isInVerticalGroup }), className),
224
+ ...props,
225
+ children: (renderProps) => (
226
+ /* Layer 2: Visual Button */
227
+ /* @__PURE__ */ jsxs(
228
+ "span",
229
+ {
230
+ className: cn(
231
+ buttonVisualVariants({
232
+ variant: effectiveVariant,
233
+ visualSize: effectiveVisualSize,
234
+ paywall,
235
+ fullWidth: effectiveFullWidth
236
+ }),
237
+ // Position styling from ButtonGroup context (border-radius adjustments)
238
+ positionClassName,
239
+ buttonVisualClassName,
240
+ // Layer 2 interaction styles (no focus - focus ring is on Layer 1)
241
+ PRESSED_STYLES,
242
+ HOVER_STYLES,
243
+ HIGH_CONTRAST_HOVER,
244
+ HIGH_CONTRAST_PRESSED
245
+ ),
246
+ "data-pressed": renderProps.isPressed || void 0,
247
+ children: [
248
+ loading && /* @__PURE__ */ jsxs(Fragment, { children: [
249
+ /* @__PURE__ */ jsx(Loader2, { className: "motion-safe:animate-spin", "aria-hidden": "true" }),
250
+ /* @__PURE__ */ jsx("span", { className: "sr-only", "aria-live": "polite", children: loadingText })
251
+ ] }),
252
+ !loading && children,
253
+ paywall && /* @__PURE__ */ jsx(
254
+ Zap,
255
+ {
256
+ "data-testid": "zap-icon",
257
+ "aria-hidden": "true",
258
+ className: "ml-1"
259
+ }
260
+ ),
261
+ paywall && /* @__PURE__ */ jsxs("span", { id: paywallDescriptionId, className: "sr-only", children: [
262
+ "Premium feature: ",
263
+ paywallDescription || "Upgrade required to access this feature"
264
+ ] }),
265
+ renderProps.isFocusVisible && shortcut && /* @__PURE__ */ jsx("kbd", { className: "ml-auto hidden text-xs opacity-60 lg:inline", children: shortcut }),
266
+ renderProps.isPressed && /* @__PURE__ */ jsx(
267
+ "span",
268
+ {
269
+ className: "absolute inset-0 rounded-[inherit] bg-current opacity-10 motion-safe:animate-in motion-safe:zoom-in-95",
270
+ "aria-hidden": "true"
271
+ }
272
+ )
273
+ ]
274
+ }
275
+ )
276
+ )
277
+ }
278
+ );
279
+ }
280
+ ));
281
+ Button.displayName = "Button";
282
+
283
+ // src/styles/shared-variants.ts
284
+ var FOCUS_WITHIN_RING = [
285
+ "focus-within:outline-none",
286
+ "focus-within:ring-2",
287
+ "focus-within:ring-[var(--ring)]",
288
+ "focus-within:ring-offset-2"
289
+ ];
290
+ var FOCUS_VISIBLE_RING = [
291
+ "focus-visible:outline-none",
292
+ "focus-visible:ring-2",
293
+ "focus-visible:ring-[var(--ring)]",
294
+ "focus-visible:ring-offset-2"
295
+ ];
296
+ var DISABLED_STANDARD = [
297
+ "disabled:pointer-events-none",
298
+ "disabled:opacity-50"
299
+ ];
300
+ var TEXT_SIZE_SMALL_SCALE = {
301
+ sm: "text-xs",
302
+ default: "text-sm",
303
+ lg: "text-base"
304
+ };
305
+ var TEXT_SIZE_MEDIUM_SCALE = {
306
+ sm: "text-sm",
307
+ default: "text-base",
308
+ lg: "text-lg"
309
+ };
310
+ var TOUCH_TARGET_MIN = [
311
+ "min-h-[44px]",
312
+ "min-w-[44px]"
313
+ ];
314
+ var ERROR_MESSAGE_BASE = [
315
+ "flex",
316
+ "items-center",
317
+ "gap-1.5",
318
+ "text-[var(--destructive)]"
319
+ ];
320
+ var SUCCESS_MESSAGE_BASE = [
321
+ "flex",
322
+ "items-center",
323
+ "gap-1.5",
324
+ "text-[var(--success)]"
325
+ ];
326
+ var DESCRIPTION_BASE = [
327
+ "text-[var(--menu-muted)]"
328
+ ];
329
+ var LABEL_BASE = [
330
+ "font-medium",
331
+ "text-[var(--content-foreground)]"
332
+ ];
333
+ var TRANSITION_COLORS = [
334
+ "transition-colors",
335
+ "duration-200"
336
+ ];
337
+ function combineStyles(...styles) {
338
+ return styles.flatMap((s) => Array.isArray(s) ? [...s] : [s]);
339
+ }
340
+
341
+ // src/elements/FileField/FileField.variants.ts
342
+ var fileFieldContainerVariants = cva(
343
+ "flex flex-col gap-1.5 w-full",
344
+ {
345
+ variants: {
346
+ size: TEXT_SIZE_MEDIUM_SCALE
347
+ },
348
+ defaultVariants: {
349
+ size: "default"
350
+ }
351
+ }
352
+ );
353
+ var fileFieldDropZoneVariants = cva(
354
+ combineStyles(
355
+ "flex flex-col items-center justify-center rounded-md border-2 border-dashed",
356
+ "bg-[var(--content-background)] text-[var(--content-foreground)]",
357
+ TRANSITION_COLORS,
358
+ FOCUS_WITHIN_RING
359
+ ),
360
+ {
361
+ variants: {
362
+ size: {
363
+ sm: "min-h-[100px] p-4 gap-2",
364
+ default: "min-h-[140px] p-6 gap-3",
365
+ lg: "min-h-[180px] p-8 gap-4"
366
+ },
367
+ isDragOver: {
368
+ true: "border-[var(--primary)] bg-[var(--primary)]/5",
369
+ false: "border-[var(--input)] hover:border-[var(--primary)]/50"
370
+ },
371
+ isInvalid: {
372
+ true: "border-[var(--destructive)] bg-[var(--destructive)]/5",
373
+ false: ""
374
+ },
375
+ isDisabled: {
376
+ true: "opacity-50 cursor-not-allowed pointer-events-none",
377
+ false: "cursor-pointer"
378
+ }
379
+ },
380
+ compoundVariants: [
381
+ {
382
+ isInvalid: true,
383
+ isDragOver: true,
384
+ className: "border-[var(--destructive)] bg-[var(--destructive)]/5"
385
+ }
386
+ ],
387
+ defaultVariants: {
388
+ size: "default",
389
+ isDragOver: false,
390
+ isInvalid: false,
391
+ isDisabled: false
392
+ }
393
+ }
394
+ );
395
+ var fileFieldTriggerVariants = cva(
396
+ combineStyles(
397
+ "inline-flex items-center justify-center gap-2 rounded-md font-medium",
398
+ TRANSITION_COLORS,
399
+ TOUCH_TARGET_MIN,
400
+ FOCUS_VISIBLE_RING,
401
+ DISABLED_STANDARD
402
+ ),
403
+ {
404
+ variants: {
405
+ size: {
406
+ sm: "px-3 py-2 text-xs",
407
+ default: "px-4 py-2 text-sm",
408
+ lg: "px-6 py-3 text-base"
409
+ },
410
+ variant: {
411
+ default: "bg-[var(--primary)] text-[var(--primary-foreground)] hover:bg-[var(--primary)]/90",
412
+ outline: "border border-[var(--input)] bg-transparent hover:bg-[var(--accent)] hover:text-[var(--accent-foreground)]"
413
+ }
414
+ },
415
+ defaultVariants: {
416
+ size: "default",
417
+ variant: "default"
418
+ }
419
+ }
420
+ );
421
+ var fileFieldListVariants = cva(
422
+ "flex flex-col gap-2 mt-3",
423
+ {
424
+ variants: {
425
+ size: {
426
+ sm: "gap-1.5",
427
+ default: "gap-2",
428
+ lg: "gap-3"
429
+ }
430
+ },
431
+ defaultVariants: {
432
+ size: "default"
433
+ }
434
+ }
435
+ );
436
+ var fileFieldListHeaderVariants = cva(
437
+ "flex items-center justify-between mb-1",
438
+ {
439
+ variants: {
440
+ size: TEXT_SIZE_SMALL_SCALE
441
+ },
442
+ defaultVariants: {
443
+ size: "default"
444
+ }
445
+ }
446
+ );
447
+ var fileFieldItemVariants = cva(
448
+ "flex items-center justify-between gap-3 bg-[var(--accent-background)] rounded-md border border-[var(--border)]",
449
+ {
450
+ variants: {
451
+ size: {
452
+ sm: "px-2 py-1.5 text-xs",
453
+ default: "px-3 py-2 text-sm",
454
+ lg: "px-4 py-3 text-base"
455
+ }
456
+ },
457
+ defaultVariants: {
458
+ size: "default"
459
+ }
460
+ }
461
+ );
462
+ var fileFieldRemoveButtonVariants = cva(
463
+ combineStyles(
464
+ "inline-flex items-center justify-center rounded-full",
465
+ TOUCH_TARGET_MIN,
466
+ "-mr-2 -my-1",
467
+ // Negative margin for visual sizing
468
+ "text-[var(--menu-muted)] hover:text-[var(--destructive)] hover:bg-[var(--destructive)]/10",
469
+ "transition-colors",
470
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]"
471
+ ),
472
+ {
473
+ variants: {
474
+ size: {
475
+ sm: "",
476
+ default: "",
477
+ lg: ""
478
+ }
479
+ },
480
+ defaultVariants: {
481
+ size: "default"
482
+ }
483
+ }
484
+ );
485
+ var fileFieldErrorVariants = cva(
486
+ combineStyles(ERROR_MESSAGE_BASE, "font-medium"),
487
+ {
488
+ variants: {
489
+ size: TEXT_SIZE_SMALL_SCALE
490
+ },
491
+ defaultVariants: {
492
+ size: "default"
493
+ }
494
+ }
495
+ );
496
+ var fileFieldSuccessVariants = cva(
497
+ combineStyles(SUCCESS_MESSAGE_BASE, "font-medium"),
498
+ {
499
+ variants: {
500
+ size: TEXT_SIZE_SMALL_SCALE
501
+ },
502
+ defaultVariants: {
503
+ size: "default"
504
+ }
505
+ }
506
+ );
507
+ var fileFieldDescriptionVariants = cva(
508
+ DESCRIPTION_BASE,
509
+ {
510
+ variants: {
511
+ size: TEXT_SIZE_SMALL_SCALE
512
+ },
513
+ defaultVariants: {
514
+ size: "default"
515
+ }
516
+ }
517
+ );
518
+ var fileFieldLabelVariants = cva(
519
+ LABEL_BASE,
520
+ {
521
+ variants: {
522
+ size: TEXT_SIZE_MEDIUM_SCALE,
523
+ isRequired: {
524
+ true: "after:content-['*'] after:ml-0.5 after:text-[var(--destructive)]",
525
+ false: ""
526
+ }
527
+ },
528
+ defaultVariants: {
529
+ size: "default",
530
+ isRequired: false
531
+ }
532
+ }
533
+ );
534
+
535
+ // src/elements/FileField/utils.ts
536
+ function formatFileSize(bytes) {
537
+ if (bytes === 0) return "0 B";
538
+ const k = 1024;
539
+ const sizes = ["B", "KB", "MB", "GB"];
540
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
541
+ const size = parseFloat((bytes / Math.pow(k, i)).toFixed(1));
542
+ const formatted = size % 1 === 0 ? size.toFixed(0) : size.toFixed(1);
543
+ return `${formatted} ${sizes[i]}`;
544
+ }
545
+ function truncateFileName(name, maxLength = 30) {
546
+ if (name.length <= maxLength) return name;
547
+ const lastDotIndex = name.lastIndexOf(".");
548
+ if (lastDotIndex === -1) {
549
+ return `${name.slice(0, maxLength - 3)}...`;
550
+ }
551
+ const ext = name.slice(lastDotIndex);
552
+ const base = name.slice(0, lastDotIndex);
553
+ const availableLength = maxLength - ext.length - 3;
554
+ if (availableLength < 1) {
555
+ return `...${ext}`;
556
+ }
557
+ const truncatedBase = base.slice(0, availableLength);
558
+ return `${truncatedBase}...${ext}`;
559
+ }
560
+ function isFileTypeAccepted(file, acceptedTypes) {
561
+ if (!acceptedTypes || acceptedTypes.length === 0) return true;
562
+ return acceptedTypes.some((type) => {
563
+ if (type.endsWith("/*")) {
564
+ const category = type.slice(0, -2);
565
+ return file.type.startsWith(`${category}/`);
566
+ }
567
+ if (type.includes("/")) {
568
+ return file.type === type;
569
+ }
570
+ if (type.startsWith(".")) {
571
+ return file.name.toLowerCase().endsWith(type.toLowerCase());
572
+ }
573
+ return false;
574
+ });
575
+ }
576
+ function getFileIcon(file) {
577
+ if (file.type.startsWith("image/")) return "image";
578
+ if (file.type.startsWith("video/")) return "video";
579
+ if (file.type.startsWith("audio/")) return "audio";
580
+ return "file";
581
+ }
582
+ function deduplicateFiles(existing, incoming) {
583
+ const result = [...existing];
584
+ for (const file of incoming) {
585
+ const existingIndex = result.findIndex((f) => f.name === file.name);
586
+ if (existingIndex >= 0) {
587
+ result[existingIndex] = file;
588
+ } else {
589
+ result.push(file);
590
+ }
591
+ }
592
+ return result;
593
+ }
594
+ function formatAcceptedTypes(acceptedTypes) {
595
+ if (!acceptedTypes || acceptedTypes.length === 0) return "any file";
596
+ const formatted = acceptedTypes.map((type) => {
597
+ if (type === "image/*") return "images";
598
+ if (type === "video/*") return "videos";
599
+ if (type === "audio/*") return "audio";
600
+ if (type.startsWith(".")) {
601
+ return type.slice(1).toUpperCase();
602
+ }
603
+ if (type.includes("/")) {
604
+ const parts = type.split("/");
605
+ const subtype = parts[1] ?? type;
606
+ return subtype.toUpperCase();
607
+ }
608
+ return type;
609
+ });
610
+ return formatted.join(", ");
611
+ }
612
+ var RESIZE_THRESHOLD = 2 * 1024 * 1024;
613
+ function isImageFile(file) {
614
+ if (file.type.startsWith("image/")) {
615
+ return true;
616
+ }
617
+ const imageExtensions = /\.(jpg|jpeg|png|gif|webp|svg|bmp|ico|avif|heic|heif|tiff|tif)$/i;
618
+ return imageExtensions.test(file.name);
619
+ }
620
+ async function createResizedPreview(file, maxDimension = 200) {
621
+ return new Promise((resolve, reject) => {
622
+ const img = new window.Image();
623
+ const objectUrl = URL.createObjectURL(file);
624
+ img.onload = () => {
625
+ URL.revokeObjectURL(objectUrl);
626
+ const scale = Math.min(
627
+ maxDimension / img.width,
628
+ maxDimension / img.height,
629
+ 1
630
+ // Don't upscale
631
+ );
632
+ const width = Math.round(img.width * scale);
633
+ const height = Math.round(img.height * scale);
634
+ const canvas = document.createElement("canvas");
635
+ canvas.width = width;
636
+ canvas.height = height;
637
+ const ctx = canvas.getContext("2d");
638
+ if (!ctx) {
639
+ reject(new Error("Canvas context unavailable"));
640
+ return;
641
+ }
642
+ ctx.drawImage(img, 0, 0, width, height);
643
+ canvas.toBlob(
644
+ (blob) => {
645
+ if (blob) {
646
+ resolve(URL.createObjectURL(blob));
647
+ } else {
648
+ reject(new Error("Failed to create blob"));
649
+ }
650
+ },
651
+ "image/jpeg",
652
+ 0.8
653
+ // Quality for JPEG compression
654
+ );
655
+ };
656
+ img.onerror = () => {
657
+ URL.revokeObjectURL(objectUrl);
658
+ reject(new Error("Failed to load image"));
659
+ };
660
+ img.src = objectUrl;
661
+ });
662
+ }
663
+ async function generatePreview(file, maxDimension = 200) {
664
+ if (file.size > RESIZE_THRESHOLD) {
665
+ return createResizedPreview(file, maxDimension);
666
+ }
667
+ return URL.createObjectURL(file);
668
+ }
669
+ function useFilePreview(file, options = {}) {
670
+ const { enabled = true, maxBytes = 10 * 1024 * 1024, maxDimension = 200 } = options;
671
+ const [preview, setPreview] = useState(null);
672
+ const [isLoading, setIsLoading] = useState(false);
673
+ const [error, setError] = useState(null);
674
+ const isImage = isImageFile(file);
675
+ useEffect(() => {
676
+ if (!enabled || !isImage) {
677
+ setPreview(null);
678
+ setIsLoading(false);
679
+ setError(null);
680
+ return;
681
+ }
682
+ if (file.size > maxBytes) {
683
+ setPreview(null);
684
+ setIsLoading(false);
685
+ setError("File too large for preview");
686
+ return;
687
+ }
688
+ let isActive = true;
689
+ let objectUrl = null;
690
+ const generatePreviewAsync = async () => {
691
+ setIsLoading(true);
692
+ setError(null);
693
+ try {
694
+ objectUrl = await generatePreview(file, maxDimension);
695
+ if (isActive) {
696
+ setPreview(objectUrl);
697
+ setIsLoading(false);
698
+ } else {
699
+ URL.revokeObjectURL(objectUrl);
700
+ }
701
+ } catch (err) {
702
+ if (isActive) {
703
+ setError(err instanceof Error ? err.message : "Failed to generate preview");
704
+ setIsLoading(false);
705
+ setPreview(null);
706
+ }
707
+ }
708
+ };
709
+ generatePreviewAsync();
710
+ return () => {
711
+ isActive = false;
712
+ if (objectUrl) {
713
+ URL.revokeObjectURL(objectUrl);
714
+ }
715
+ setPreview((prev) => {
716
+ if (prev) {
717
+ URL.revokeObjectURL(prev);
718
+ }
719
+ return null;
720
+ });
721
+ };
722
+ }, [file, enabled, maxBytes, maxDimension, isImage]);
723
+ return { preview, isLoading, error, isImage };
724
+ }
725
+ function FilePreview({
726
+ file,
727
+ size = 64,
728
+ maxBytes = 10 * 1024 * 1024,
729
+ renderPreview,
730
+ className
731
+ }) {
732
+ const { preview, isLoading, error, isImage } = useFilePreview(file, {
733
+ enabled: true,
734
+ maxBytes,
735
+ maxDimension: size * 2
736
+ // Generate at 2x for retina displays
737
+ });
738
+ const sizeStyles = {
739
+ width: size,
740
+ height: size,
741
+ minWidth: size,
742
+ minHeight: size
743
+ };
744
+ if (!isImage && renderPreview) {
745
+ return /* @__PURE__ */ jsx(
746
+ "div",
747
+ {
748
+ className: cn(
749
+ "flex items-center justify-center rounded-md overflow-hidden",
750
+ "bg-[var(--accent-background)]",
751
+ className
752
+ ),
753
+ style: sizeStyles,
754
+ children: renderPreview(file)
755
+ }
756
+ );
757
+ }
758
+ if (isLoading) {
759
+ return /* @__PURE__ */ jsx(
760
+ "div",
761
+ {
762
+ className: cn(
763
+ "flex items-center justify-center rounded-md overflow-hidden",
764
+ "bg-[var(--accent-background)]",
765
+ className
766
+ ),
767
+ style: sizeStyles,
768
+ "aria-busy": "true",
769
+ "aria-label": `Loading preview for ${file.name}`,
770
+ children: /* @__PURE__ */ jsx(
771
+ Loader2,
772
+ {
773
+ className: "h-4 w-4 animate-spin text-[var(--menu-muted)]",
774
+ "aria-hidden": "true"
775
+ }
776
+ )
777
+ }
778
+ );
779
+ }
780
+ if (isImage && preview && !error) {
781
+ return /* @__PURE__ */ jsx(
782
+ "div",
783
+ {
784
+ className: cn(
785
+ "flex items-center justify-center rounded-md overflow-hidden",
786
+ "bg-[var(--accent-background)]",
787
+ className
788
+ ),
789
+ style: sizeStyles,
790
+ children: /* @__PURE__ */ jsx(
791
+ "img",
792
+ {
793
+ src: preview,
794
+ alt: file.name,
795
+ className: "w-full h-full object-cover",
796
+ loading: "lazy"
797
+ }
798
+ )
799
+ }
800
+ );
801
+ }
802
+ const iconType = getFileIcon(file);
803
+ const IconComponent = getIconForType(iconType);
804
+ const iconSize = Math.max(16, Math.floor(size * 0.4));
805
+ return /* @__PURE__ */ jsx(
806
+ "div",
807
+ {
808
+ className: cn(
809
+ "flex items-center justify-center rounded-md overflow-hidden",
810
+ "bg-[var(--accent-background)]",
811
+ className
812
+ ),
813
+ style: sizeStyles,
814
+ "aria-label": error ? `Preview unavailable for ${file.name}` : void 0,
815
+ children: /* @__PURE__ */ jsx(
816
+ IconComponent,
817
+ {
818
+ className: "text-[var(--menu-muted)]",
819
+ style: { width: iconSize, height: iconSize },
820
+ "aria-hidden": "true"
821
+ }
822
+ )
823
+ }
824
+ );
825
+ }
826
+ function getIconForType(iconType) {
827
+ switch (iconType) {
828
+ case "image":
829
+ return ImageIcon;
830
+ case "video":
831
+ return VideoIcon;
832
+ case "audio":
833
+ return AudioLines;
834
+ default:
835
+ return FileIcon;
836
+ }
837
+ }
838
+ var fileProgressVariants = cva(
839
+ ["flex", "flex-col", "gap-1", "w-full"],
840
+ {
841
+ variants: {
842
+ size: {
843
+ sm: "text-xs",
844
+ default: "text-sm",
845
+ lg: "text-base"
846
+ }
847
+ },
848
+ defaultVariants: {
849
+ size: "default"
850
+ }
851
+ }
852
+ );
853
+ var fileProgressTrackVariants = cva(
854
+ ["rounded-full", "bg-[var(--accent-background)]", "overflow-hidden"],
855
+ {
856
+ variants: {
857
+ size: {
858
+ sm: "h-1.5",
859
+ default: "h-2",
860
+ lg: "h-3"
861
+ }
862
+ },
863
+ defaultVariants: {
864
+ size: "default"
865
+ }
866
+ }
867
+ );
868
+ var fileProgressBarVariants = cva(
869
+ ["h-full", "rounded-full", "transition-all", "duration-300"],
870
+ {
871
+ variants: {
872
+ status: {
873
+ pending: [
874
+ "bg-gradient-to-r",
875
+ "from-[var(--menu-muted)]",
876
+ "via-[var(--accent-background)]",
877
+ "to-[var(--menu-muted)]",
878
+ "bg-[length:200%_100%]",
879
+ "animate-progress-shimmer"
880
+ ],
881
+ uploading: "bg-[var(--primary)]",
882
+ complete: "bg-[var(--success)]",
883
+ error: "bg-[var(--destructive)]"
884
+ }
885
+ },
886
+ defaultVariants: {
887
+ status: "pending"
888
+ }
889
+ }
890
+ );
891
+ var fileProgressHeaderVariants = cva(
892
+ ["flex", "items-center", "justify-between", "gap-2"],
893
+ {
894
+ variants: {
895
+ size: {
896
+ sm: "text-xs",
897
+ default: "text-sm",
898
+ lg: "text-base"
899
+ }
900
+ },
901
+ defaultVariants: {
902
+ size: "default"
903
+ }
904
+ }
905
+ );
906
+ var fileProgressErrorVariants = cva(
907
+ [
908
+ "flex",
909
+ "items-center",
910
+ "justify-between",
911
+ "gap-2",
912
+ "mt-1",
913
+ "text-[var(--destructive)]"
914
+ ],
915
+ {
916
+ variants: {
917
+ size: {
918
+ sm: "text-xs",
919
+ default: "text-sm",
920
+ lg: "text-base"
921
+ }
922
+ },
923
+ defaultVariants: {
924
+ size: "default"
925
+ }
926
+ }
927
+ );
928
+ var fileProgressRetryVariants = cva(
929
+ [
930
+ "underline",
931
+ "hover:no-underline",
932
+ "min-h-[44px]",
933
+ "min-w-[44px]",
934
+ "inline-flex",
935
+ "items-center",
936
+ "justify-center",
937
+ // Negative margin to visually appear smaller while maintaining touch target
938
+ "-mr-3",
939
+ "-my-2",
940
+ // Focus styling
941
+ "focus-visible:outline-none",
942
+ "focus-visible:ring-2",
943
+ "focus-visible:ring-[var(--ring)]",
944
+ "focus-visible:ring-offset-2",
945
+ "rounded"
946
+ ],
947
+ {
948
+ variants: {
949
+ size: {
950
+ sm: "text-xs",
951
+ default: "text-sm",
952
+ lg: "text-base"
953
+ }
954
+ },
955
+ defaultVariants: {
956
+ size: "default"
957
+ }
958
+ }
959
+ );
960
+ function getStatusText(status, progress) {
961
+ switch (status) {
962
+ case "pending":
963
+ return "Waiting...";
964
+ case "uploading":
965
+ return `${progress}%`;
966
+ case "complete":
967
+ return "Complete";
968
+ case "error":
969
+ return "Failed";
970
+ }
971
+ }
972
+ function FileProgress({
973
+ file,
974
+ progress,
975
+ status,
976
+ error,
977
+ onRetry,
978
+ size = "default",
979
+ className
980
+ }) {
981
+ const isIndeterminate = status === "pending";
982
+ const errorId = `progress-error-${file.name.replace(/[^a-zA-Z0-9]/g, "-")}`;
983
+ const statusText = getStatusText(status, progress);
984
+ return /* @__PURE__ */ jsxs("div", { className: cn(fileProgressVariants({ size }), className), children: [
985
+ /* @__PURE__ */ jsx(
986
+ ProgressBar,
987
+ {
988
+ "aria-label": file.name,
989
+ value: isIndeterminate ? void 0 : progress,
990
+ isIndeterminate,
991
+ "aria-describedby": status === "error" && error ? errorId : void 0,
992
+ children: ({ percentage, valueText }) => /* @__PURE__ */ jsxs(Fragment, { children: [
993
+ /* @__PURE__ */ jsxs("div", { className: fileProgressHeaderVariants({ size }), children: [
994
+ /* @__PURE__ */ jsx("span", { className: "truncate", title: file.name, children: truncateFileName(file.name, 30) }),
995
+ /* @__PURE__ */ jsx("span", { className: "text-[var(--menu-muted)] flex-shrink-0", children: status === "error" ? "Failed" : valueText ?? statusText })
996
+ ] }),
997
+ /* @__PURE__ */ jsx("div", { className: fileProgressTrackVariants({ size }), children: /* @__PURE__ */ jsx(
998
+ "div",
999
+ {
1000
+ className: fileProgressBarVariants({ status }),
1001
+ style: {
1002
+ width: isIndeterminate ? "100%" : `${percentage ?? 0}%`
1003
+ }
1004
+ }
1005
+ ) })
1006
+ ] })
1007
+ }
1008
+ ),
1009
+ status === "error" && error && /* @__PURE__ */ jsxs(
1010
+ "div",
1011
+ {
1012
+ id: errorId,
1013
+ className: fileProgressErrorVariants({ size }),
1014
+ children: [
1015
+ /* @__PURE__ */ jsx("span", { children: error }),
1016
+ onRetry && /* @__PURE__ */ jsx(
1017
+ Button$1,
1018
+ {
1019
+ onPress: onRetry,
1020
+ className: fileProgressRetryVariants({ size }),
1021
+ children: "Retry"
1022
+ }
1023
+ )
1024
+ ]
1025
+ }
1026
+ ),
1027
+ /* @__PURE__ */ jsxs(
1028
+ "div",
1029
+ {
1030
+ "aria-live": "polite",
1031
+ "aria-atomic": "true",
1032
+ className: "sr-only",
1033
+ children: [
1034
+ status === "complete" && `${file.name} upload complete`,
1035
+ status === "error" && `${file.name} upload failed${error ? `: ${error}` : ""}`
1036
+ ]
1037
+ }
1038
+ )
1039
+ ] });
1040
+ }
1041
+ FileProgress.displayName = "FileProgress";
1042
+ var FileField = forwardRef(
1043
+ function FileField2({
1044
+ // Required
1045
+ label,
1046
+ // File selection
1047
+ acceptedFileTypes,
1048
+ allowsMultiple = false,
1049
+ // Constraints
1050
+ maxFileSize,
1051
+ maxFiles,
1052
+ // Display
1053
+ description,
1054
+ errorMessage,
1055
+ successMessage,
1056
+ triggerText,
1057
+ // States
1058
+ isRequired,
1059
+ isDisabled,
1060
+ isInvalid,
1061
+ isValid,
1062
+ // Variants
1063
+ size = "default",
1064
+ // Form integration
1065
+ name,
1066
+ id,
1067
+ className,
1068
+ // Value (controlled)
1069
+ value = [],
1070
+ // Events
1071
+ onChange,
1072
+ validate,
1073
+ // Phase 1: Image Previews
1074
+ showPreviews = false,
1075
+ previewSize = 64,
1076
+ maxPreviewBytes = 10 * 1024 * 1024,
1077
+ renderPreview,
1078
+ // Phase 1: Upload Progress (will be used later)
1079
+ showProgress = false,
1080
+ uploadProgress,
1081
+ uploadStatus,
1082
+ uploadErrors,
1083
+ onRetry,
1084
+ // Standard
1085
+ "data-testid": dataTestId,
1086
+ "aria-label": _ariaLabel,
1087
+ "aria-labelledby": _ariaLabelledBy,
1088
+ "aria-describedby": ariaDescribedBy,
1089
+ ...props
1090
+ }, ref) {
1091
+ const generatedId = useId();
1092
+ const fieldId = id ?? generatedId;
1093
+ const labelId = `${fieldId}-label`;
1094
+ const descriptionId = `${fieldId}-description`;
1095
+ const errorId = `${fieldId}-error`;
1096
+ const [isDragOver, setIsDragOver] = useState(false);
1097
+ const [internalError, setInternalError] = useState(null);
1098
+ const dragCounterRef = useRef(0);
1099
+ const displayError = errorMessage ?? internalError;
1100
+ const hasError = isInvalid || !!displayError;
1101
+ const describedByParts = [];
1102
+ if (ariaDescribedBy) describedByParts.push(ariaDescribedBy);
1103
+ if (description) describedByParts.push(descriptionId);
1104
+ if (displayError) describedByParts.push(errorId);
1105
+ const describedBy = describedByParts.length > 0 ? describedByParts.join(" ") : void 0;
1106
+ const validateFiles = useCallback(
1107
+ (files, existingFiles = []) => {
1108
+ const validFiles = [];
1109
+ const errors = [];
1110
+ for (const file of files) {
1111
+ if (acceptedFileTypes && !isFileTypeAccepted(file, acceptedFileTypes)) {
1112
+ errors.push(`"${file.name}" has an invalid file type`);
1113
+ continue;
1114
+ }
1115
+ if (maxFileSize && file.size > maxFileSize) {
1116
+ errors.push(
1117
+ `"${file.name}" exceeds the maximum size of ${formatFileSize(maxFileSize)}`
1118
+ );
1119
+ continue;
1120
+ }
1121
+ validFiles.push(file);
1122
+ }
1123
+ if (maxFiles && allowsMultiple) {
1124
+ const combined = deduplicateFiles(existingFiles, validFiles);
1125
+ if (combined.length > maxFiles) {
1126
+ errors.push(`Maximum ${maxFiles} files allowed`);
1127
+ return { valid: [], errors };
1128
+ }
1129
+ }
1130
+ return { valid: validFiles, errors };
1131
+ },
1132
+ [acceptedFileTypes, maxFileSize, maxFiles, allowsMultiple]
1133
+ );
1134
+ const processFiles = useCallback(
1135
+ (fileList) => {
1136
+ if (!fileList || fileList.length === 0) return;
1137
+ setInternalError(null);
1138
+ const newFiles = Array.from(fileList);
1139
+ const existingFiles = allowsMultiple ? value : [];
1140
+ const { valid, errors } = validateFiles(newFiles, existingFiles);
1141
+ if (errors.length > 0) {
1142
+ setInternalError(errors[0] ?? "Invalid file");
1143
+ return;
1144
+ }
1145
+ if (validate && valid.length > 0) {
1146
+ const customError = validate(
1147
+ allowsMultiple ? deduplicateFiles(existingFiles, valid) : valid
1148
+ );
1149
+ if (customError) {
1150
+ setInternalError(customError);
1151
+ return;
1152
+ }
1153
+ }
1154
+ let finalFiles;
1155
+ if (allowsMultiple) {
1156
+ finalFiles = deduplicateFiles(existingFiles, valid);
1157
+ } else {
1158
+ finalFiles = valid.slice(0, 1);
1159
+ }
1160
+ onChange?.(finalFiles);
1161
+ },
1162
+ [allowsMultiple, value, validateFiles, validate, onChange]
1163
+ );
1164
+ const handleSelect = useCallback(
1165
+ (fileList) => {
1166
+ processFiles(fileList);
1167
+ },
1168
+ [processFiles]
1169
+ );
1170
+ const handleRemove = useCallback(
1171
+ (fileToRemove) => {
1172
+ const newFiles = value.filter((f) => f !== fileToRemove);
1173
+ onChange?.(newFiles);
1174
+ },
1175
+ [value, onChange]
1176
+ );
1177
+ const handleClearAll = useCallback(() => {
1178
+ onChange?.([]);
1179
+ }, [onChange]);
1180
+ const handleDragEnter = useCallback(
1181
+ (e) => {
1182
+ e.preventDefault();
1183
+ e.stopPropagation();
1184
+ if (isDisabled) return;
1185
+ dragCounterRef.current++;
1186
+ setIsDragOver(true);
1187
+ },
1188
+ [isDisabled]
1189
+ );
1190
+ const handleDragOver = useCallback(
1191
+ (e) => {
1192
+ e.preventDefault();
1193
+ e.stopPropagation();
1194
+ },
1195
+ []
1196
+ );
1197
+ const handleDragLeave = useCallback(
1198
+ (e) => {
1199
+ e.preventDefault();
1200
+ e.stopPropagation();
1201
+ dragCounterRef.current--;
1202
+ if (dragCounterRef.current === 0) {
1203
+ setIsDragOver(false);
1204
+ }
1205
+ },
1206
+ []
1207
+ );
1208
+ const handleDrop = useCallback(
1209
+ (e) => {
1210
+ e.preventDefault();
1211
+ e.stopPropagation();
1212
+ dragCounterRef.current = 0;
1213
+ setIsDragOver(false);
1214
+ if (isDisabled) return;
1215
+ const files = e.dataTransfer?.files;
1216
+ processFiles(files ?? null);
1217
+ },
1218
+ [isDisabled, processFiles]
1219
+ );
1220
+ const getIconComponent = (file) => {
1221
+ const iconType = getFileIcon(file);
1222
+ switch (iconType) {
1223
+ case "image":
1224
+ return ImageIcon;
1225
+ case "video":
1226
+ return VideoIcon;
1227
+ case "audio":
1228
+ return AudioLines;
1229
+ default:
1230
+ return FileIcon;
1231
+ }
1232
+ };
1233
+ const acceptString = acceptedFileTypes?.join(",");
1234
+ return /* @__PURE__ */ jsxs(
1235
+ "div",
1236
+ {
1237
+ ref,
1238
+ id: fieldId,
1239
+ className: cn(fileFieldContainerVariants({ size }), className),
1240
+ "data-testid": dataTestId ?? "file-field",
1241
+ ...props,
1242
+ children: [
1243
+ /* @__PURE__ */ jsx(
1244
+ "label",
1245
+ {
1246
+ id: labelId,
1247
+ className: fileFieldLabelVariants({ size, isRequired }),
1248
+ children: label
1249
+ }
1250
+ ),
1251
+ /* @__PURE__ */ jsxs(
1252
+ "div",
1253
+ {
1254
+ role: "group",
1255
+ "data-testid": `${dataTestId ?? "file-field"}-dropzone`,
1256
+ className: cn(
1257
+ "drop-zone",
1258
+ // Added for test selectors
1259
+ fileFieldDropZoneVariants({
1260
+ size,
1261
+ isDragOver,
1262
+ isInvalid: hasError,
1263
+ isDisabled
1264
+ })
1265
+ ),
1266
+ onDragEnter: handleDragEnter,
1267
+ onDragOver: handleDragOver,
1268
+ onDragLeave: handleDragLeave,
1269
+ onDrop: handleDrop,
1270
+ "aria-labelledby": labelId,
1271
+ "aria-describedby": describedBy,
1272
+ "aria-disabled": isDisabled || void 0,
1273
+ children: [
1274
+ /* @__PURE__ */ jsx(
1275
+ FileTrigger,
1276
+ {
1277
+ acceptedFileTypes,
1278
+ allowsMultiple,
1279
+ onSelect: handleSelect,
1280
+ children: /* @__PURE__ */ jsxs(
1281
+ Button,
1282
+ {
1283
+ variant: "outline",
1284
+ isDisabled,
1285
+ buttonVisualClassName: fileFieldTriggerVariants({ size }),
1286
+ children: [
1287
+ /* @__PURE__ */ jsx(Upload, { className: "h-4 w-4", "aria-hidden": "true" }),
1288
+ isDragOver ? "Drop files here" : triggerText ?? (allowsMultiple ? "Choose files" : "Choose file")
1289
+ ]
1290
+ }
1291
+ )
1292
+ }
1293
+ ),
1294
+ name && /* @__PURE__ */ jsx(
1295
+ "input",
1296
+ {
1297
+ type: "file",
1298
+ name,
1299
+ accept: acceptString,
1300
+ multiple: allowsMultiple,
1301
+ disabled: isDisabled,
1302
+ className: "sr-only",
1303
+ tabIndex: -1,
1304
+ "aria-hidden": "true"
1305
+ }
1306
+ )
1307
+ ]
1308
+ }
1309
+ ),
1310
+ description && /* @__PURE__ */ jsx(
1311
+ "p",
1312
+ {
1313
+ id: descriptionId,
1314
+ className: fileFieldDescriptionVariants({ size }),
1315
+ children: description
1316
+ }
1317
+ ),
1318
+ value.length > 0 && /* @__PURE__ */ jsxs("div", { className: fileFieldListVariants({ size }), children: [
1319
+ value.length >= 2 && /* @__PURE__ */ jsxs("div", { className: fileFieldListHeaderVariants({ size }), children: [
1320
+ /* @__PURE__ */ jsxs("span", { className: "text-[var(--menu-muted)]", children: [
1321
+ value.length,
1322
+ " files selected"
1323
+ ] }),
1324
+ /* @__PURE__ */ jsx(
1325
+ Button,
1326
+ {
1327
+ variant: "link",
1328
+ visualSize: "sm",
1329
+ onPress: handleClearAll,
1330
+ buttonVisualClassName: cn(
1331
+ "text-[var(--menu-muted)] hover:text-[var(--destructive)]",
1332
+ "underline-offset-4 hover:underline"
1333
+ ),
1334
+ "aria-label": "Clear all files",
1335
+ children: "Clear all"
1336
+ }
1337
+ )
1338
+ ] }),
1339
+ /* @__PURE__ */ jsx("ul", { className: "space-y-2", children: value.map((file, index) => {
1340
+ const IconComponent = getIconComponent(file);
1341
+ const effectivePreviewSize = size === "sm" ? Math.min(previewSize, 40) : size === "lg" ? Math.min(previewSize, 80) : Math.min(previewSize, 48);
1342
+ const fileStatus = uploadStatus?.[index];
1343
+ const fileProgress = uploadProgress?.[index] ?? 0;
1344
+ const fileError = uploadErrors?.get(index);
1345
+ const showProgressForFile = showProgress && fileStatus !== void 0;
1346
+ return /* @__PURE__ */ jsx(
1347
+ "li",
1348
+ {
1349
+ className: showProgressForFile ? "p-3" : fileFieldItemVariants({ size }),
1350
+ children: showProgressForFile ? /* @__PURE__ */ jsx(
1351
+ FileProgress,
1352
+ {
1353
+ file,
1354
+ progress: fileProgress,
1355
+ status: fileStatus,
1356
+ error: fileError,
1357
+ onRetry: onRetry ? () => onRetry(index) : void 0,
1358
+ size
1359
+ }
1360
+ ) : /* @__PURE__ */ jsxs(Fragment, { children: [
1361
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 min-w-0", children: [
1362
+ showPreviews ? /* @__PURE__ */ jsx(
1363
+ FilePreview,
1364
+ {
1365
+ file,
1366
+ size: effectivePreviewSize,
1367
+ maxBytes: maxPreviewBytes,
1368
+ renderPreview,
1369
+ className: "flex-shrink-0"
1370
+ }
1371
+ ) : /* @__PURE__ */ jsx(
1372
+ IconComponent,
1373
+ {
1374
+ className: "h-4 w-4 flex-shrink-0 text-[var(--menu-muted)]",
1375
+ "aria-hidden": "true"
1376
+ }
1377
+ ),
1378
+ /* @__PURE__ */ jsx("span", { className: "truncate", title: file.name, children: truncateFileName(file.name, 30) }),
1379
+ /* @__PURE__ */ jsx("span", { className: "text-[var(--menu-muted)] flex-shrink-0", children: formatFileSize(file.size) })
1380
+ ] }),
1381
+ /* @__PURE__ */ jsx(
1382
+ Button,
1383
+ {
1384
+ variant: "ghost",
1385
+ visualSize: "icon",
1386
+ onPress: () => handleRemove(file),
1387
+ buttonVisualClassName: fileFieldRemoveButtonVariants({ size }),
1388
+ "aria-label": `Remove ${file.name}`,
1389
+ isDisabled,
1390
+ children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4", "aria-hidden": "true" })
1391
+ }
1392
+ )
1393
+ ] })
1394
+ },
1395
+ `${file.name}-${index}`
1396
+ );
1397
+ }) })
1398
+ ] }),
1399
+ displayError && /* @__PURE__ */ jsx(
1400
+ "p",
1401
+ {
1402
+ id: errorId,
1403
+ role: "alert",
1404
+ className: fileFieldErrorVariants({ size }),
1405
+ children: displayError
1406
+ }
1407
+ ),
1408
+ !displayError && isValid && successMessage && /* @__PURE__ */ jsx("p", { className: fileFieldSuccessVariants({ size }), children: successMessage })
1409
+ ]
1410
+ }
1411
+ );
1412
+ }
1413
+ );
1414
+ FileField.displayName = "FileField";
1415
+ var BaseComponentPropsSchema = z.object({
1416
+ // Styling
1417
+ className: z.string().optional(),
1418
+ // React
1419
+ children: z.any().optional(),
1420
+ // ReactNode not directly supported by Zod
1421
+ id: z.string().optional(),
1422
+ // Accessibility (WCAG 2.2 AA requirements)
1423
+ "aria-label": z.string().optional(),
1424
+ "aria-labelledby": z.string().optional(),
1425
+ "aria-describedby": z.string().optional(),
1426
+ "aria-live": z.enum(["off", "polite", "assertive"]).optional(),
1427
+ "aria-hidden": z.boolean().optional(),
1428
+ // Testing & Development
1429
+ "data-testid": z.string().optional()
1430
+ });
1431
+
1432
+ // src/elements/FileField/FileField.types.ts
1433
+ var FileFieldPropsSchema = BaseComponentPropsSchema.extend({
1434
+ // Required
1435
+ /** Label text for the file field (required for accessibility) */
1436
+ label: z.string(),
1437
+ // File selection
1438
+ /**
1439
+ * Array of accepted file types (MIME types or extensions)
1440
+ * @example ['application/pdf', 'image/*', '.docx']
1441
+ */
1442
+ acceptedFileTypes: z.array(z.string()).optional(),
1443
+ /** Allow selecting multiple files */
1444
+ allowsMultiple: z.boolean().default(false),
1445
+ // Constraints
1446
+ /** Maximum file size in bytes */
1447
+ maxFileSize: z.number().optional(),
1448
+ /** Maximum number of files (only applies when allowsMultiple is true) */
1449
+ maxFiles: z.number().optional(),
1450
+ // Display
1451
+ /** Description text shown below the drop zone */
1452
+ description: z.string().optional(),
1453
+ /** Error message from external validation */
1454
+ errorMessage: z.string().optional(),
1455
+ /** Success message when files are valid */
1456
+ successMessage: z.string().optional(),
1457
+ /** Custom text for the trigger button */
1458
+ triggerText: z.string().optional(),
1459
+ // States
1460
+ /** Mark field as required */
1461
+ isRequired: z.boolean().optional(),
1462
+ /** Disable the field */
1463
+ isDisabled: z.boolean().optional(),
1464
+ /** Show invalid state styling */
1465
+ isInvalid: z.boolean().optional(),
1466
+ /** Show valid state styling */
1467
+ isValid: z.boolean().optional(),
1468
+ // Variants
1469
+ /** Size variant */
1470
+ size: z.enum(["sm", "default", "lg"]).default("default"),
1471
+ // Form integration
1472
+ /** Name attribute for form association */
1473
+ name: z.string().optional(),
1474
+ // === Phase 1: Image Previews ===
1475
+ /** Enable image thumbnail previews (default: false) */
1476
+ showPreviews: z.boolean().default(false),
1477
+ /** Maximum preview dimension in pixels (default: 64) */
1478
+ previewSize: z.number().min(16).max(256).default(64),
1479
+ /** Maximum file size for preview generation in bytes (default: 10MB) */
1480
+ maxPreviewBytes: z.number().default(10 * 1024 * 1024),
1481
+ // === Phase 1: Upload Progress ===
1482
+ /** Enable upload progress display (default: false) */
1483
+ showProgress: z.boolean().default(false),
1484
+ /** Progress values per file (0-100), indexed parallel to files array */
1485
+ uploadProgress: z.array(z.number().min(0).max(100)).optional(),
1486
+ /** Upload status per file, indexed parallel to files array */
1487
+ uploadStatus: z.array(z.enum(["pending", "uploading", "complete", "error"])).optional()
1488
+ }).refine(
1489
+ (data) => !(data.successMessage && data.errorMessage),
1490
+ {
1491
+ message: "Cannot provide both successMessage and errorMessage. Use one based on validation state.",
1492
+ path: ["successMessage"]
1493
+ }
1494
+ ).refine(
1495
+ (data) => {
1496
+ if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
1497
+ if (data.isValid && data.isInvalid) {
1498
+ console.error(
1499
+ "[FileField] Both isValid and isInvalid are true. isInvalid takes precedence."
1500
+ );
1501
+ }
1502
+ }
1503
+ return true;
1504
+ }
1505
+ );
1506
+
1507
+ export { FileField, FileFieldPropsSchema, FilePreview, FileProgress, RESIZE_THRESHOLD, createResizedPreview, deduplicateFiles, fileFieldContainerVariants, fileFieldDescriptionVariants, fileFieldDropZoneVariants, fileFieldErrorVariants, fileFieldItemVariants, fileFieldLabelVariants, fileFieldListVariants, fileFieldRemoveButtonVariants, fileFieldSuccessVariants, fileFieldTriggerVariants, fileProgressBarVariants, fileProgressErrorVariants, fileProgressHeaderVariants, fileProgressRetryVariants, fileProgressTrackVariants, fileProgressVariants, formatAcceptedTypes, formatFileSize, generatePreview, getFileIcon, isFileTypeAccepted, isImageFile, truncateFileName, useFilePreview };
8
1508
  //# sourceMappingURL=index.mjs.map
9
1509
  //# sourceMappingURL=index.mjs.map