@42-central/ui-react 0.24.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/dist/{chunk-FUNTJZX7.js → chunk-2CL3FKEY.js} +3 -3
  2. package/dist/{chunk-FUNTJZX7.js.map → chunk-2CL3FKEY.js.map} +1 -1
  3. package/dist/{chunk-OZMSXYBX.js → chunk-36NWC4GV.js} +3 -3
  4. package/dist/{chunk-OZMSXYBX.js.map → chunk-36NWC4GV.js.map} +1 -1
  5. package/dist/{chunk-4FEOMQYR.js → chunk-54W6VAI3.js} +5 -5
  6. package/dist/{chunk-4FEOMQYR.js.map → chunk-54W6VAI3.js.map} +1 -1
  7. package/dist/{chunk-SZEOTXRZ.js → chunk-6II2DVYR.js} +5 -5
  8. package/dist/{chunk-SZEOTXRZ.js.map → chunk-6II2DVYR.js.map} +1 -1
  9. package/dist/{chunk-DJLNGWMM.js → chunk-6IRMKF5T.js} +3 -3
  10. package/dist/{chunk-DJLNGWMM.js.map → chunk-6IRMKF5T.js.map} +1 -1
  11. package/dist/{chunk-YPFSRZ3T.js → chunk-6UIQJJNJ.js} +3 -3
  12. package/dist/{chunk-YPFSRZ3T.js.map → chunk-6UIQJJNJ.js.map} +1 -1
  13. package/dist/{chunk-DT6LKNZF.js → chunk-7247WBTV.js} +5 -4
  14. package/dist/chunk-7247WBTV.js.map +1 -0
  15. package/dist/{chunk-6VYGK3Q3.js → chunk-7E7JNWOC.js} +16 -21
  16. package/dist/chunk-7E7JNWOC.js.map +1 -0
  17. package/dist/{chunk-C4NFRSOR.js → chunk-7HZBD4YZ.js} +4 -4
  18. package/dist/{chunk-C4NFRSOR.js.map → chunk-7HZBD4YZ.js.map} +1 -1
  19. package/dist/{chunk-JVG5ISPT.js → chunk-AHKMN3YQ.js} +3 -3
  20. package/dist/{chunk-JVG5ISPT.js.map → chunk-AHKMN3YQ.js.map} +1 -1
  21. package/dist/{chunk-UAYENYS2.js → chunk-AKXALCUN.js} +3 -3
  22. package/dist/{chunk-UAYENYS2.js.map → chunk-AKXALCUN.js.map} +1 -1
  23. package/dist/{chunk-BE2LWUHY.js → chunk-BMEJBY6H.js} +5 -3
  24. package/dist/chunk-BMEJBY6H.js.map +1 -0
  25. package/dist/{chunk-MXAACRWE.js → chunk-E52Z2FKU.js} +5 -5
  26. package/dist/{chunk-MXAACRWE.js.map → chunk-E52Z2FKU.js.map} +1 -1
  27. package/dist/chunk-F374BNL4.js +129 -0
  28. package/dist/chunk-F374BNL4.js.map +1 -0
  29. package/dist/{chunk-MRAJ45IM.js → chunk-FZSLSUSX.js} +4 -4
  30. package/dist/{chunk-MRAJ45IM.js.map → chunk-FZSLSUSX.js.map} +1 -1
  31. package/dist/{chunk-3L5GLI67.js → chunk-I4B3N3UX.js} +3 -3
  32. package/dist/{chunk-3L5GLI67.js.map → chunk-I4B3N3UX.js.map} +1 -1
  33. package/dist/{chunk-IPYHTCFL.js → chunk-IUK7OJXZ.js} +3 -3
  34. package/dist/{chunk-IPYHTCFL.js.map → chunk-IUK7OJXZ.js.map} +1 -1
  35. package/dist/{chunk-2MXWEIMD.js → chunk-KKLCHLCZ.js} +12 -11
  36. package/dist/chunk-KKLCHLCZ.js.map +1 -0
  37. package/dist/{chunk-YWTOW7PZ.js → chunk-LHUWOA2U.js} +8 -8
  38. package/dist/{chunk-YWTOW7PZ.js.map → chunk-LHUWOA2U.js.map} +1 -1
  39. package/dist/{chunk-6N6J2DOE.js → chunk-LIZWCWED.js} +3 -3
  40. package/dist/{chunk-6N6J2DOE.js.map → chunk-LIZWCWED.js.map} +1 -1
  41. package/dist/{chunk-O7LS6OZR.js → chunk-LMCUGYHT.js} +3 -3
  42. package/dist/{chunk-O7LS6OZR.js.map → chunk-LMCUGYHT.js.map} +1 -1
  43. package/dist/{chunk-DHJB4UJD.js → chunk-N5M4PDBK.js} +4 -4
  44. package/dist/{chunk-DHJB4UJD.js.map → chunk-N5M4PDBK.js.map} +1 -1
  45. package/dist/{chunk-DA4QII2N.js → chunk-NLSJ6T7V.js} +4 -4
  46. package/dist/{chunk-DA4QII2N.js.map → chunk-NLSJ6T7V.js.map} +1 -1
  47. package/dist/{chunk-UT3TOV2Q.js → chunk-OVT2KZHY.js} +3 -3
  48. package/dist/{chunk-UT3TOV2Q.js.map → chunk-OVT2KZHY.js.map} +1 -1
  49. package/dist/{chunk-SVKN5ZHX.js → chunk-PEHFWGTT.js} +16 -13
  50. package/dist/chunk-PEHFWGTT.js.map +1 -0
  51. package/dist/{chunk-J44FJ7PH.js → chunk-PFZMB3US.js} +4 -4
  52. package/dist/{chunk-J44FJ7PH.js.map → chunk-PFZMB3US.js.map} +1 -1
  53. package/dist/{chunk-IRNF274I.js → chunk-PI7X5YFJ.js} +3 -3
  54. package/dist/{chunk-IRNF274I.js.map → chunk-PI7X5YFJ.js.map} +1 -1
  55. package/dist/{chunk-F2FSHVO5.js → chunk-QZ4N5LYG.js} +7 -7
  56. package/dist/{chunk-F2FSHVO5.js.map → chunk-QZ4N5LYG.js.map} +1 -1
  57. package/dist/{chunk-E5H3YWZV.js → chunk-SAXWCGWR.js} +3 -3
  58. package/dist/{chunk-E5H3YWZV.js.map → chunk-SAXWCGWR.js.map} +1 -1
  59. package/dist/{chunk-SWVUXEBT.js → chunk-SCXXJDKQ.js} +3 -3
  60. package/dist/{chunk-SWVUXEBT.js.map → chunk-SCXXJDKQ.js.map} +1 -1
  61. package/dist/{chunk-D3JYDAUZ.js → chunk-T44RW5DW.js} +4 -4
  62. package/dist/{chunk-D3JYDAUZ.js.map → chunk-T44RW5DW.js.map} +1 -1
  63. package/dist/{chunk-FB2G4LNH.js → chunk-UDCCOUWR.js} +5 -5
  64. package/dist/{chunk-FB2G4LNH.js.map → chunk-UDCCOUWR.js.map} +1 -1
  65. package/dist/{chunk-TCFB23JT.js → chunk-WERJ44ZN.js} +3 -3
  66. package/dist/{chunk-TCFB23JT.js.map → chunk-WERJ44ZN.js.map} +1 -1
  67. package/dist/{chunk-QNKD2SQM.js → chunk-X3YIHN2U.js} +5 -5
  68. package/dist/{chunk-QNKD2SQM.js.map → chunk-X3YIHN2U.js.map} +1 -1
  69. package/dist/{chunk-VD6PB3VA.js → chunk-X6DESK37.js} +12 -3
  70. package/dist/chunk-X6DESK37.js.map +1 -0
  71. package/dist/{chunk-7AQ4MN4M.js → chunk-XUFCI262.js} +4 -4
  72. package/dist/{chunk-7AQ4MN4M.js.map → chunk-XUFCI262.js.map} +1 -1
  73. package/dist/{chunk-47LEAR6G.js → chunk-Y2G47ARQ.js} +6 -6
  74. package/dist/{chunk-47LEAR6G.js.map → chunk-Y2G47ARQ.js.map} +1 -1
  75. package/dist/{chunk-F342ZT7O.js → chunk-ZVECQBGG.js} +13 -7
  76. package/dist/chunk-ZVECQBGG.js.map +1 -0
  77. package/dist/components/action-icon/action-icon.d.ts.map +1 -1
  78. package/dist/components/action-icon/index.js +1 -1
  79. package/dist/components/alert/index.js +1 -1
  80. package/dist/components/ambient-background/index.js +5 -3
  81. package/dist/components/ambient-background/index.js.map +1 -1
  82. package/dist/components/ambient-background/starfield.d.ts.map +1 -1
  83. package/dist/components/app-shell/index.js +4 -4
  84. package/dist/components/autocomplete/index.js +3 -3
  85. package/dist/components/avatar/index.js +2 -2
  86. package/dist/components/badge/badge.d.ts.map +1 -1
  87. package/dist/components/badge/index.js +1 -1
  88. package/dist/components/button/index.js +1 -1
  89. package/dist/components/button-multi-select/index.js +3 -3
  90. package/dist/components/button-select/index.js +3 -3
  91. package/dist/components/calendar/index.js +4 -4
  92. package/dist/components/calendar-heatmap/index.js +2 -2
  93. package/dist/components/camera/index.js +10 -10
  94. package/dist/components/card/card.d.ts.map +1 -1
  95. package/dist/components/card/index.js +1 -1
  96. package/dist/components/carousel/index.js +2 -2
  97. package/dist/components/checkbox/checkbox.d.ts +3 -2
  98. package/dist/components/checkbox/checkbox.d.ts.map +1 -1
  99. package/dist/components/checkbox/index.js +2 -2
  100. package/dist/components/choice-card-group/index.js +2 -2
  101. package/dist/components/choice-card-group/index.js.map +1 -1
  102. package/dist/components/clipboard/index.js +3 -3
  103. package/dist/components/code-block/code-block.d.ts +6 -3
  104. package/dist/components/code-block/code-block.d.ts.map +1 -1
  105. package/dist/components/code-block/highlighter.d.ts +16 -15
  106. package/dist/components/code-block/highlighter.d.ts.map +1 -1
  107. package/dist/components/code-block/index.d.ts +2 -1
  108. package/dist/components/code-block/index.d.ts.map +1 -1
  109. package/dist/components/code-block/index.js +81 -10
  110. package/dist/components/code-block/index.js.map +1 -1
  111. package/dist/components/code-block/languages.d.ts +61 -0
  112. package/dist/components/code-block/languages.d.ts.map +1 -0
  113. package/dist/components/code-block/static.d.ts +2 -1
  114. package/dist/components/code-block/static.d.ts.map +1 -1
  115. package/dist/components/code-block/static.js +99 -10
  116. package/dist/components/code-block/static.js.map +1 -1
  117. package/dist/components/combobox/index.js +3 -3
  118. package/dist/components/combobox-list/index.js +5 -5
  119. package/dist/components/compare/index.js +2 -2
  120. package/dist/components/data-table/index.js +30 -30
  121. package/dist/components/data-table/index.js.map +1 -1
  122. package/dist/components/date-picker/index.js +12 -12
  123. package/dist/components/download-button/index.js +2 -2
  124. package/dist/components/drawer/index.js +4 -4
  125. package/dist/components/field/field.d.ts +3 -0
  126. package/dist/components/field/field.d.ts.map +1 -1
  127. package/dist/components/field/index.js +1 -1
  128. package/dist/components/file-item/index.js +5 -5
  129. package/dist/components/file-preview/index.js +5 -5
  130. package/dist/components/file-trigger/index.js +2 -2
  131. package/dist/components/file-upload/index.js +6 -6
  132. package/dist/components/gallery/index.js +2 -2
  133. package/dist/components/geodesic/a11y.d.ts +3 -3
  134. package/dist/components/geodesic/a11y.d.ts.map +1 -1
  135. package/dist/components/image-cropper/index.js +7 -7
  136. package/dist/components/indicator/index.js +1 -1
  137. package/dist/components/input/index.js +2 -2
  138. package/dist/components/kbd/index.js +3 -3
  139. package/dist/components/kbd/kbd.d.ts.map +1 -1
  140. package/dist/components/lightbox/index.js +7 -7
  141. package/dist/components/menu/index.js +2 -2
  142. package/dist/components/modal/index.js +4 -4
  143. package/dist/components/multi-combobox-list/index.js +5 -5
  144. package/dist/components/multi-select/index.js +6 -6
  145. package/dist/components/number-input/index.js +3 -3
  146. package/dist/components/overlays/index.js +6 -6
  147. package/dist/components/password-input/index.js +3 -3
  148. package/dist/components/photo-capture/index.js +14 -14
  149. package/dist/components/pills-input/index.js +5 -5
  150. package/dist/components/pin-input/index.js +2 -2
  151. package/dist/components/radio-group/index.js +1 -1
  152. package/dist/components/rating/index.js +1 -1
  153. package/dist/components/schedule/index.js +5 -5
  154. package/dist/components/segment-group/index.js +4 -4
  155. package/dist/components/select/index.js +4 -4
  156. package/dist/components/slider/index.js +2 -2
  157. package/dist/components/spotlight/index.js +9 -9
  158. package/dist/components/switch/index.js +14 -19
  159. package/dist/components/switch/index.js.map +1 -1
  160. package/dist/components/switch/switch.d.ts +1 -0
  161. package/dist/components/switch/switch.d.ts.map +1 -1
  162. package/dist/components/table/index.js +1 -1
  163. package/dist/components/table/table.d.ts.map +1 -1
  164. package/dist/components/tabs/index.js +3 -3
  165. package/dist/components/tags-input/index.js +5 -5
  166. package/dist/components/text-input/index.js +2 -2
  167. package/dist/components/textarea/index.js +2 -2
  168. package/dist/components/theme-icon/index.js +1 -1
  169. package/dist/components/theme-icon/theme-icon.d.ts.map +1 -1
  170. package/dist/components/time-input/index.js +7 -7
  171. package/dist/components/tree-multi-select/index.js +6 -6
  172. package/dist/components/tree-select/index.js +3 -3
  173. package/dist/index.js +4 -4
  174. package/dist/theme.css +28 -23
  175. package/package.json +1 -1
  176. package/src/components/action-icon/action-icon.tsx +3 -1
  177. package/src/components/ambient-background/starfield.tsx +4 -2
  178. package/src/components/badge/badge.tsx +11 -6
  179. package/src/components/button/button.tsx +1 -1
  180. package/src/components/card/card.tsx +10 -9
  181. package/src/components/checkbox/checkbox.test.tsx +17 -9
  182. package/src/components/checkbox/checkbox.tsx +26 -27
  183. package/src/components/choice-card-group/choice-card-group.tsx +3 -3
  184. package/src/components/code-block/code-block.tsx +7 -4
  185. package/src/components/code-block/highlighter.test.ts +79 -1
  186. package/src/components/code-block/highlighter.ts +76 -30
  187. package/src/components/code-block/index.ts +2 -0
  188. package/src/components/code-block/languages.ts +63 -0
  189. package/src/components/code-block/static.tsx +2 -1
  190. package/src/components/data-table/data-table-pagination.tsx +5 -5
  191. package/src/components/data-table/data-table-stack.tsx +2 -2
  192. package/src/components/field/field.tsx +14 -0
  193. package/src/components/kbd/kbd.tsx +2 -1
  194. package/src/components/switch/switch.test.tsx +15 -0
  195. package/src/components/switch/switch.tsx +27 -27
  196. package/src/components/table/table.test.tsx +1 -1
  197. package/src/components/table/table.tsx +14 -11
  198. package/src/components/theme-icon/theme-icon.tsx +46 -12
  199. package/src/theme.css +28 -23
  200. package/dist/chunk-2MXWEIMD.js.map +0 -1
  201. package/dist/chunk-6VYGK3Q3.js.map +0 -1
  202. package/dist/chunk-7CNDZZZ6.js +0 -95
  203. package/dist/chunk-7CNDZZZ6.js.map +0 -1
  204. package/dist/chunk-BE2LWUHY.js.map +0 -1
  205. package/dist/chunk-DT6LKNZF.js.map +0 -1
  206. package/dist/chunk-F342ZT7O.js.map +0 -1
  207. package/dist/chunk-SVKN5ZHX.js.map +0 -1
  208. package/dist/chunk-VD6PB3VA.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/files.ts","../src/lib/open-file.ts","../src/lib/use-object-url.ts"],"names":["started","win","mimeOf"],"mappings":";;;;;;AAQA,IAAM,aAAa,CAAC,MAAA,EAAQ,YAAY,UAAA,EAAY,UAAA,EAAY,YAAY,UAAU,CAAA;AAc/E,IAAM,cAAA,GAAiB,CAAC,KAAA,EAAe,MAAA,GAAiB,cAAA,KAA2B;AAExF,EAAA,MAAM,QAAA,GAAW,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,WAAW,MAAA,CAAO,CAAC,CAAA,EAAG,KAAA,KAAU,KAAA,IAAS,GAAA,IAAQ,KAAK,CA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CAAU,MAAM;AACd,IAAA,IAAI,CAAC,IAAA,IAAQ,CAAC,EAAA,EAAI;AAClB,IAAA,IAAI,OAAO,QAAA,EAAU;AAEnB,MAAA,MAAM,GAAA,GAAM,IAAI,eAAA,CAAgB,IAAA,CAAK,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,EAAE,CAAC,CAAA;AAC5D,MAAA,QAAA,CAAS,EAAE,IAAA,EAAM,EAAA,EAAI,GAAA,EAAK,CAAA;AAC1B,MAAA,OAAO,MAAM,GAAA,CAAI,eAAA,CAAgB,GAAG,CAAA;AAAA,IACtC;AACA,IAAA,MAAM,MAAA,GAAS,IAAI,UAAA,EAAW;AAC9B,IAAA,MAAA,CAAO,SAAS,MAAM;AACpB,MAAA,IAAI,OAAO,MAAA,CAAO,MAAA,KAAW,QAAA,EAAU,QAAA,CAAS,EAAE,IAAA,EAAM,EAAA,EAAI,GAAA,EAAK,MAAA,CAAO,MAAA,EAAQ,CAAA;AAAA,IAClF,CAAA;AACA,IAAA,MAAA,CAAO,cAAc,IAAA,CAAK,KAAA,CAAM,GAAG,IAAA,CAAK,IAAA,EAAM,QAAQ,CAAC,CAAA;AACvD,IAAA,OAAO,MAAM,OAAO,KAAA,EAAM;AAAA,EAC5B,CAAA,EAAG,CAAC,IAAA,EAAM,EAAE,CAAC,CAAA;AAEb,EAAA,IAAI,IAAA,SAAa,KAAA,EAAO,IAAA,KAAS,QAAQ,KAAA,CAAM,EAAA,KAAO,EAAA,GAAK,KAAA,CAAM,GAAA,GAAM,MAAA;AACvE,EAAA,OAAO,OAAO,MAAA,KAAW,QAAA,GAAW,MAAA,GAAS,MAAA;AAC/C","file":"chunk-TCFB23JT.js","sourcesContent":["import { DEFAULT_LOCALE } from \"./intl\"\n\n/**\n * Helpers for showing a file: its size as people read it, and what kind of\n * file it is. Plain functions, no React, so they work in a loader, a table\n * cell or a test as well as in `FileItem` and `FileUpload`, which use them.\n */\n\nconst BYTE_UNITS = [\"byte\", \"kilobyte\", \"megabyte\", \"gigabyte\", \"terabyte\", \"petabyte\"] as const\n\n/**\n * A byte count as people read it: decimal units (1 MB is 1,000,000 bytes),\n * three significant digits, in the locale's own unit names.\n *\n * formatFileSize(48_213) // \"48.2 kB\"\n * formatFileSize(48_213, \"fr-FR\") // \"48,2 ko\"\n * formatFileSize(file.size, useLocale()) // in a component, following IntlProvider\n *\n * zag's own `formatBytes` algorithm, on `Intl`. `locale` defaults to the\n * kit's `DEFAULT_LOCALE` rather than the runtime's, so the server and the\n * browser never disagree; inside a component, pass `useLocale()`.\n */\nexport const formatFileSize = (bytes: number, locale: string = DEFAULT_LOCALE): string => {\n // The largest unit the count reaches; below 1 byte (an empty file) stays in bytes.\n const exponent = Math.max(0, BYTE_UNITS.filter((_, index) => bytes >= 1000 ** index).length - 1)\n const value = Number.parseFloat((bytes / 1000 ** exponent).toPrecision(3))\n return new Intl.NumberFormat(locale, {\n style: \"unit\",\n unit: BYTE_UNITS[exponent],\n unitDisplay: \"short\",\n }).format(value)\n}\n\n/** What a file is, coarsely: enough to pick its icon. */\nexport const FILE_KINDS = [\n \"image\",\n \"video\",\n \"audio\",\n \"pdf\",\n \"text\",\n \"archive\",\n \"spreadsheet\",\n \"document\",\n \"code\",\n \"font\",\n \"other\",\n] as const\n\nexport type FileKind = (typeof FILE_KINDS)[number]\n\n/**\n * The one lookup behind `fileKind`. Three shapes of key share it, tried in\n * this order: an exact MIME type (`application/pdf`), a MIME family\n * (`image/*`), then an extension (`.csv`). The exact type comes first so a\n * specific `text/csv` is a spreadsheet before the `text/*` family makes it\n * text; extensions are last because a browser-provided type is better\n * evidence than a name, when there is one.\n */\nconst KINDS: Record<string, FileKind> = {\n // Families\n \"image/*\": \"image\",\n \"video/*\": \"video\",\n \"audio/*\": \"audio\",\n \"font/*\": \"font\",\n \"text/*\": \"text\",\n\n // PDF\n \"application/pdf\": \"pdf\",\n \".pdf\": \"pdf\",\n\n // Archives\n \"application/zip\": \"archive\",\n \"application/x-zip-compressed\": \"archive\",\n \"application/gzip\": \"archive\",\n \"application/x-gzip\": \"archive\",\n \"application/x-tar\": \"archive\",\n \"application/x-7z-compressed\": \"archive\",\n \"application/x-rar-compressed\": \"archive\",\n \"application/vnd.rar\": \"archive\",\n \".zip\": \"archive\",\n \".gz\": \"archive\",\n \".tgz\": \"archive\",\n \".tar\": \"archive\",\n \".7z\": \"archive\",\n \".rar\": \"archive\",\n\n // Spreadsheets\n \"text/csv\": \"spreadsheet\",\n \"text/tab-separated-values\": \"spreadsheet\",\n \"application/vnd.ms-excel\": \"spreadsheet\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\": \"spreadsheet\",\n \"application/vnd.oasis.opendocument.spreadsheet\": \"spreadsheet\",\n \"application/vnd.apple.numbers\": \"spreadsheet\",\n \".csv\": \"spreadsheet\",\n \".tsv\": \"spreadsheet\",\n \".xls\": \"spreadsheet\",\n \".xlsx\": \"spreadsheet\",\n \".ods\": \"spreadsheet\",\n \".numbers\": \"spreadsheet\",\n\n // Documents (word processing and slides)\n \"application/msword\": \"document\",\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\": \"document\",\n \"application/vnd.oasis.opendocument.text\": \"document\",\n \"application/rtf\": \"document\",\n \"text/rtf\": \"document\",\n \"application/vnd.ms-powerpoint\": \"document\",\n \"application/vnd.openxmlformats-officedocument.presentationml.presentation\": \"document\",\n \"application/vnd.oasis.opendocument.presentation\": \"document\",\n \"application/vnd.apple.pages\": \"document\",\n \"application/vnd.apple.keynote\": \"document\",\n \".doc\": \"document\",\n \".docx\": \"document\",\n \".odt\": \"document\",\n \".rtf\": \"document\",\n \".ppt\": \"document\",\n \".pptx\": \"document\",\n \".odp\": \"document\",\n \".pages\": \"document\",\n \".key\": \"document\",\n\n // Code and structured data\n \"application/json\": \"code\",\n \"application/ld+json\": \"code\",\n \"application/xml\": \"code\",\n \"text/xml\": \"code\",\n \"text/html\": \"code\",\n \"text/css\": \"code\",\n \"text/javascript\": \"code\",\n \"application/javascript\": \"code\",\n \"application/x-yaml\": \"code\",\n \"application/yaml\": \"code\",\n \"application/x-sh\": \"code\",\n \"application/sql\": \"code\",\n \".json\": \"code\",\n \".xml\": \"code\",\n \".html\": \"code\",\n \".css\": \"code\",\n \".js\": \"code\",\n \".jsx\": \"code\",\n \".ts\": \"code\",\n \".tsx\": \"code\",\n \".yml\": \"code\",\n \".yaml\": \"code\",\n \".sh\": \"code\",\n \".sql\": \"code\",\n \".py\": \"code\",\n \".c\": \"code\",\n \".h\": \"code\",\n \".cpp\": \"code\",\n \".rs\": \"code\",\n \".go\": \"code\",\n\n // Plain text by name\n \".txt\": \"text\",\n \".md\": \"text\",\n \".log\": \"text\",\n\n // Media and fonts by name, for an empty or generic type\n \".png\": \"image\",\n \".jpg\": \"image\",\n \".jpeg\": \"image\",\n \".gif\": \"image\",\n \".webp\": \"image\",\n \".avif\": \"image\",\n \".svg\": \"image\",\n \".heic\": \"image\",\n \".mp4\": \"video\",\n \".mov\": \"video\",\n \".webm\": \"video\",\n \".mkv\": \"video\",\n \".mp3\": \"audio\",\n \".wav\": \"audio\",\n \".m4a\": \"audio\",\n \".ogg\": \"audio\",\n \".flac\": \"audio\",\n \".woff\": \"font\",\n \".woff2\": \"font\",\n \".ttf\": \"font\",\n \".otf\": \"font\",\n}\n\n/** Own keys only, so a type like `\"constructor\"` can't reach `Object.prototype`. */\nconst kindOf = (key: string): FileKind | undefined =>\n Object.hasOwn(KINDS, key) ? KINDS[key] : undefined\n\n/** Types that say nothing about the content, so the name decides instead. */\nconst GENERIC_TYPES = new Set([\"\", \"application/octet-stream\", \"binary/octet-stream\"])\n\n/** `.pdf` for `\"Report.FINAL.PDF\"`, `\"\"` for a name without an extension. */\nexport const extensionOf = (name: string): string => {\n const dot = name.lastIndexOf(\".\")\n return dot > 0 ? name.slice(dot).toLowerCase() : \"\"\n}\n\n/**\n * The kind of a file, from its MIME type, or from its name's extension when\n * the type is missing or generic. Browsers often report `\"\"` for a `.csv`\n * or a `.docx`, and servers send `application/octet-stream`.\n *\n * fileKind(\"application/pdf\") // \"pdf\"\n * fileKind(\"\", \"grades.csv\") // \"spreadsheet\"\n * fileKind(file.type, file.name) // a picked File\n */\nexport const fileKind = (type = \"\", name = \"\"): FileKind => {\n const mime = type.toLowerCase().split(\";\")[0]?.trim() ?? \"\"\n const typed = GENERIC_TYPES.has(mime)\n ? undefined\n : (kindOf(mime) ?? kindOf(`${mime.split(\"/\")[0]}/*`))\n return typed ?? kindOf(extensionOf(name)) ?? \"other\"\n}\n","import { match } from \"ts-pattern\"\nimport { extensionOf, fileKind } from \"./files\"\nimport { saveFile } from \"./save-file\"\n\n/**\n * Opening a file in a new browser tab, safely: the one \"pre-open a tab, point\n * it at the file\" the kit and its apps share, plus the allowlist that decides\n * what a browser may render at all.\n *\n * Never a network request: a Blob is shown through an object URL, and a URL is\n * handed to the tab. Fetching with a token or asking for a presigned link is\n * the app's job, in the function `openFile` takes.\n */\n\n// ---------------------------------------------------------------------------\n// The allowlist\n// ---------------------------------------------------------------------------\n\n/**\n * Why there is an allowlist: an object URL has the APP's origin. An uploaded\n * `.html` or `.svg` loaded from one, in a frame or a tab, runs its script as\n * the app: stored XSS. Measured in Chromium and WebKit (Playwright), a blob of\n * HTML ran with the page's origin when typed `text/html`, and SVG markup when\n * typed `image/svg+xml`, `application/xml` or `text/xml`. WebKit went further:\n * it sniffed HTML out of a blob typed `application/octet-stream`, `\"\"` or\n * `application/zip` and ran it, so re-typing a file as \"binary\" is no defence.\n *\n * What held in both engines: the same markup re-typed as `application/pdf`,\n * `text/plain`, a raster image, a video or an audio type stayed inert. So the\n * kit never trusts a file's own type for rendering. It picks one of the types\n * below and re-wraps the Blob under it (`blob.slice(0, size, type)`), and a\n * file that maps to none of them is never rendered or navigated to: it is\n * saved instead, through a `download` link, which stayed inert everywhere.\n */\nconst RASTER: Record<string, string> = {\n \"image/png\": \"image/png\",\n \"image/jpeg\": \"image/jpeg\",\n \"image/gif\": \"image/gif\",\n \"image/webp\": \"image/webp\",\n \"image/avif\": \"image/avif\",\n \"image/bmp\": \"image/bmp\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".gif\": \"image/gif\",\n \".webp\": \"image/webp\",\n \".avif\": \"image/avif\",\n \".bmp\": \"image/bmp\",\n}\n\nconst MEDIA: Record<string, string> = {\n \"video/mp4\": \"video/mp4\",\n \"video/webm\": \"video/webm\",\n \"video/ogg\": \"video/ogg\",\n \"video/quicktime\": \"video/quicktime\",\n \"audio/mpeg\": \"audio/mpeg\",\n \"audio/mp4\": \"audio/mp4\",\n \"audio/aac\": \"audio/aac\",\n \"audio/wav\": \"audio/wav\",\n \"audio/x-wav\": \"audio/wav\",\n \"audio/ogg\": \"audio/ogg\",\n \"audio/webm\": \"audio/webm\",\n \"audio/flac\": \"audio/flac\",\n \".mp4\": \"video/mp4\",\n \".m4v\": \"video/mp4\",\n \".webm\": \"video/webm\",\n \".mov\": \"video/quicktime\",\n \".ogv\": \"video/ogg\",\n \".mp3\": \"audio/mpeg\",\n \".m4a\": \"audio/mp4\",\n \".aac\": \"audio/aac\",\n \".wav\": \"audio/wav\",\n \".ogg\": \"audio/ogg\",\n \".oga\": \"audio/ogg\",\n \".flac\": \"audio/flac\",\n}\n\n/** Text a tab may show as plain text: never markup, which could be sniffed or parsed. */\nconst PLAIN_TEXT: Record<string, true> = {\n \"text/plain\": true,\n \"text/markdown\": true,\n \"text/csv\": true,\n \"text/tab-separated-values\": true,\n \"application/json\": true,\n \".txt\": true,\n \".md\": true,\n \".log\": true,\n \".csv\": true,\n \".tsv\": true,\n \".json\": true,\n}\n\n/** The kit's one text type: re-typed so a tab shows the characters, never parses them. */\nconst TEXT_TYPE = \"text/plain;charset=utf-8\"\n\n/** Own keys only, so a type like `\"constructor\"` can't reach `Object.prototype`. */\nconst lookup = <T>(table: Record<string, T>, key: string): T | undefined =>\n Object.hasOwn(table, key) ? table[key] : undefined\n\nconst mimeOf = (type: string) => type.toLowerCase().split(\";\")[0]?.trim() ?? \"\"\n\n/**\n * The type a browser may render a file under, from the kit's allowlist, or\n * `undefined` when it must not be rendered: saved, never shown.\n *\n * viewableType(\"application/pdf\", \"contract.pdf\") // \"application/pdf\"\n * viewableType(\"\", \"scan.JPG\") // \"image/jpeg\"\n * viewableType(\"text/csv\", \"grades.csv\") // \"text/plain;charset=utf-8\"\n * viewableType(\"text/html\", \"contract.pdf\") // undefined: the type says HTML\n * viewableType(\"image/svg+xml\", \"logo.svg\") // undefined: SVG runs script\n *\n * The kind comes from `fileKind`, so a specific type wins over the name, and\n * the name decides for a missing or generic type. The result is always one of\n * a fixed set (PDF, PNG/JPEG/GIF/WebP/AVIF/BMP, common video and audio types,\n * plain text), never the file's own type passed through. Re-wrap the Blob\n * under it before making an object URL:\n *\n * const safe = viewableType(file.type, file.name)\n * if (safe) url = URL.createObjectURL(file.slice(0, file.size, safe))\n */\nexport const viewableType = (type = \"\", name = \"\"): string | undefined => {\n const mime = mimeOf(type)\n const extension = extensionOf(name)\n // The specific type first, like `fileKind`; the extension only for a type that says nothing.\n const pick = <T>(table: Record<string, T>) => lookup(table, mime) ?? lookup(table, extension)\n return match(fileKind(type, name))\n .with(\"pdf\", () => \"application/pdf\")\n .with(\"image\", () => pick(RASTER))\n .with(\"video\", \"audio\", () => pick(MEDIA))\n .with(\"text\", \"spreadsheet\", \"code\", () => (pick(PLAIN_TEXT) ? TEXT_TYPE : undefined))\n .otherwise(() => undefined)\n}\n\n// ---------------------------------------------------------------------------\n// openFile\n// ---------------------------------------------------------------------------\n\n/**\n * How often an open tab is checked, in milliseconds: 2 s. The object URL is\n * revoked at the first check that finds the tab closed or showing something\n * else. Browsers throttle timers in a background tab (Chrome to once a\n * minute after five minutes), which only delays the revoke: nothing breaks.\n */\nexport const OPEN_FILE_POLL = 2_000\n\n/**\n * The longest an object URL is kept for an open tab, in milliseconds: one hour.\n * After it the tab still shows the file, but reloading it, or saving it from\n * the browser's PDF viewer, fails. A safety net for a tab left open all day:\n * the Blob stays in memory as long as its URL lives. Closing or reloading the\n * app's own page revokes every object URL it made, whatever this says.\n */\nexport const OPEN_FILE_MAX_AGE = 3_600_000\n\n/** What can be opened: a Blob (or File), or a URL. */\nexport type OpenFileData = Blob | string\n\n/** Resolves the file on click. `signal` is `options.signal`, when there is one. */\nexport type OpenFileLoader = (context: {\n signal: AbortSignal\n}) => OpenFileData | Promise<OpenFileData>\n\nexport type OpenFileOptions = {\n /** The file name: the tab's title while it loads, the saved file's name, and, with\n * `type`, what decides whether the file may be shown. A File's own name by default. */\n name?: string\n /** The MIME type, when the Blob's own is missing, or for a URL. */\n type?: string\n /** Aborts a pending function: the tab closes and the promise rejects. */\n signal?: AbortSignal\n}\n\n/** `\"opened\"` in a tab, or `\"saved\"`: the popup was blocked, or the file isn't allowed in one. */\nexport type OpenFileResult = \"opened\" | \"saved\"\n\n/** Where the tab goes: the Blob under its allowlisted type, or a URL to follow. */\ntype Target = { blob: Blob; type: string } | { url: string }\n\nconst isSameOrigin = (url: URL) =>\n url.protocol === \"blob:\" || url.protocol === \"data:\" || url.origin === window.location.origin\n\n/** The last path segment of a URL, as a fallback name. */\nconst lastSegment = (url: URL) =>\n decodeURIComponent(url.pathname.split(\"/\").filter(Boolean).at(-1) ?? \"\")\n\n/**\n * Where a tab may go for `data`, or `undefined` to save it instead.\n *\n * - **A Blob** only under its `viewableType`, re-wrapped.\n * - **A cross-origin URL** (a presigned S3 link) always: whatever it serves runs\n * with its own origin, not the app's, and the tab has no `opener`.\n * - **A same-origin URL** only when its `type` or name is viewable. The server's\n * `Content-Type` decides what the browser does then, so it must be honest.\n * - **A `blob:` or `data:` string** never: its real type can't be checked. Pass the\n * Blob itself.\n */\nconst targetOf = (data: OpenFileData, name: string, type: string): Target | undefined => {\n if (typeof data !== \"string\") {\n const safe = viewableType(type || data.type, name)\n return safe ? { blob: data, type: safe } : undefined\n }\n const url = new URL(data, window.location.href)\n if (url.protocol === \"blob:\" || url.protocol === \"data:\") return undefined\n if (!isSameOrigin(url)) return { url: url.href }\n return viewableType(type, name || lastSegment(url)) ? { url: url.href } : undefined\n}\n\n/** Reads the tab's address, or `undefined` once it has left for another origin. */\nconst addressOf = (win: Window): string | undefined => {\n try {\n return win.location.href\n } catch {\n return undefined\n }\n}\n\n/**\n * Keeps an object URL alive while its tab shows it. Revoked when the tab is\n * closed, navigates away (including to another origin, where its address can't\n * be read), or after `OPEN_FILE_MAX_AGE`. `about:blank` counts as still\n * loading: the navigation is asynchronous, and revoking during it would break\n * the very load it waits for.\n */\nconst watch = (win: Window, url: string) => {\n const started = Date.now()\n const timer = setInterval(() => {\n const address = win.closed ? undefined : addressOf(win)\n const showing = address === url || address === \"about:blank\"\n if (showing && Date.now() - started < OPEN_FILE_MAX_AGE) return\n clearInterval(timer)\n URL.revokeObjectURL(url)\n }, OPEN_FILE_POLL)\n}\n\n/** Points the tab at the file, replacing its blank page in history. A Blob is re-wrapped\n * under its allowlisted type first, so the type it claims never reaches the browser. */\nconst show = (win: Window, target: Target) => {\n if (\"url\" in target) return win.location.replace(target.url)\n const url = URL.createObjectURL(target.blob.slice(0, target.blob.size, target.type))\n win.location.replace(url)\n watch(win, url)\n}\n\n/** A blank tab, cut off from this page, or `null` when a popup blocker stopped it. */\nconst blankTab = (name: string): Window | null => {\n const win = window.open(\"\", \"_blank\")\n if (!win || win.closed) return null\n // Before anything loads: the tab can't reach back into the app. Not `noopener` in\n // `window.open`, which would hand back `null` and leave nothing to point at the file.\n win.opener = null\n try {\n // The tab's title while a slow function resolves, rather than \"Untitled\".\n if (name) win.document.title = name\n } catch {\n // A browser that gave the blank tab its own origin: the title is cosmetic.\n }\n return win\n}\n\n/** Calls the loader inside the click, and treats a synchronous throw as a rejection. */\nconst started = (load: OpenFileLoader, signal: AbortSignal): Promise<OpenFileData> => {\n try {\n return Promise.resolve(load({ signal }))\n } catch (error) {\n return Promise.reject(error)\n }\n}\n\nconst nameOf = (data: OpenFileData, name: string | undefined) =>\n name ?? (typeof data !== \"string\" && data instanceof File ? data.name : \"\")\n\n/**\n * Opens a file in a new tab: a Blob, a URL, or what a function of yours\n * resolves to. Call it in a click handler.\n *\n * openFile(file) // a picked File\n * openFile(presignedUrl, { name: \"consent.pdf\" })\n * openFile(({ signal }) => api.blob(`/documents/${id}`, { signal }), { name: \"contract.pdf\" })\n *\n * - **Popup-safe.** The tab opens synchronously, inside the click, before a\n * function is called; browsers block a popup opened after an `await`. It\n * shows the file once the promise resolves, and closes if it rejects.\n * - **Blocked popup → saved.** When the browser blocks the tab, the file is\n * saved with `saveFile` instead, and the promise resolves `\"saved\"`.\n * - **Only safe types are shown.** A file outside the allowlist (`viewableType`:\n * PDF, raster images, common video and audio, plain text) is saved, never\n * navigated to, so an uploaded HTML or SVG can't run as the app. A Blob is\n * re-wrapped under the allowlisted type, whatever type it claims.\n * - **The object URL lives as long as the tab shows it**, so saving from the\n * browser's PDF viewer and reloading keep working: it is revoked once the tab\n * closes or navigates away, and after `OPEN_FILE_MAX_AGE` (an hour) at most.\n *\n * The tab's title is the PDF's own `Title` metadata when it has one, and the\n * object URL's id otherwise: have your PDF generator set the title. Hosting the\n * PDF in a titled page of our own would fix the title, but it breaks reloading\n * the tab and shows only the first page on iOS.\n *\n * Rejects when the function rejects or `signal` aborts, after closing the tab.\n */\nexport const openFile = (\n source: OpenFileData | OpenFileLoader,\n options: OpenFileOptions = {},\n): Promise<OpenFileResult> => {\n if (typeof window === \"undefined\") {\n return Promise.reject(new Error(\"openFile runs in a browser, in a click handler.\"))\n }\n const type = options.type ?? \"\"\n\n // A value is decided now: a file that can't be shown never opens a tab at all.\n if (typeof source !== \"function\") {\n const name = nameOf(source, options.name)\n const target = targetOf(source, name, type)\n const win = target && blankTab(name)\n if (!target || !win) {\n saveFile(source, name || undefined, { type: options.type })\n return Promise.resolve(\"saved\")\n }\n show(win, target)\n return Promise.resolve(\"opened\")\n }\n\n // A function: the tab opens now, while the click still allows it.\n const signal = options.signal ?? new AbortController().signal\n const win = blankTab(options.name ?? \"\")\n const aborted = () => Promise.reject(signal.reason)\n if (signal.aborted) {\n win?.close()\n return aborted()\n }\n return started(source, signal).then(\n (data): OpenFileResult | Promise<never> => {\n if (signal.aborted) {\n win?.close()\n return aborted()\n }\n const name = nameOf(data, options.name)\n const target = win ? targetOf(data, name, type) : undefined\n if (!win || !target) {\n win?.close()\n saveFile(data, name || undefined, { type: options.type })\n return \"saved\"\n }\n show(win, target)\n return \"opened\"\n },\n (error: unknown) => {\n win?.close()\n throw error\n },\n )\n}\n","\"use client\"\n\nimport { useEffect, useState } from \"react\"\nimport { extensionOf, fileKind } from \"./files\"\nimport { viewableType } from \"./open-file\"\n\n/**\n * The largest SVG `useObjectUrl` shows, in bytes: 5 MB. An SVG is shown from\n * a `data:` URL, which lives as a JavaScript string (a third larger than the\n * file, in base64) and again as the `<img>`'s attribute, for every mounted\n * thumbnail. Past this an SVG gets no URL, so the caller's fallback shows: an\n * icon in FileItem, the download panel in FilePreview.\n */\nexport const SVG_DATA_URL_LIMIT = 5_000_000\n\nconst SVG_TYPE = \"image/svg+xml\"\n\nconst mimeOf = (type: string) => type.toLowerCase().split(\";\")[0]?.trim() ?? \"\"\n\n/**\n * The type a file may be shown under IN the page, or `undefined` for none:\n * `viewableType`'s, or SVG, which `useObjectUrl` draws from a `data:` URL and\n * never from an object URL. SVG when the type says so, or, for a missing or\n * generic type, the name does; at most `SVG_DATA_URL_LIMIT` bytes.\n *\n * inlineType(\"image/png\", \"scan.png\") // \"image/png\"\n * inlineType(\"\", \"logo.svg\", 2_000) // \"image/svg+xml\": a data: URL\n * inlineType(\"text/html\", \"logo.svg\") // undefined: the type says HTML\n */\nexport const inlineType = (type = \"\", name = \"\", size = 0): string | undefined => {\n const safe = viewableType(type, name)\n if (safe) return safe\n const svg =\n fileKind(type, name) === \"image\" && (mimeOf(type) === SVG_TYPE || extensionOf(name) === \".svg\")\n return svg && size <= SVG_DATA_URL_LIMIT ? SVG_TYPE : undefined\n}\n\nexport type UseObjectUrlOptions = {\n /** The file name, when the type is missing or generic. A File's own name by default. */\n name?: string\n /** The MIME type, in place of the Blob's own. */\n type?: string\n}\n\ntype Entry = { blob: Blob; as: string; url: string }\n\n/**\n * A URL an `<img>`, `<video>` or `<object>` can load for `source`, safe to put\n * in the page. A string passes through untouched. A `Blob` (a `File` from an\n * input or a drop) is shown only under a type the kit allows, never the type\n * it claims:\n *\n * - **PDF, raster images, common video and audio, plain text** (`viewableType`):\n * an object URL for the Blob re-wrapped under that type, revoked when the\n * source changes or the component unmounts.\n * - **SVG**, up to `SVG_DATA_URL_LIMIT`: a `data:` URL.\n * - **Anything else**: `undefined`, so nothing is shown.\n *\n * const url = useObjectUrl(file)\n * <img src={url} alt=\"\" />\n *\n * Why: an object URL has the app's origin. \"Open image in new tab\" (or\n * dragging the image to the tab bar, or copying its address) navigates to it,\n * and an uploaded `.svg` or `.html` there runs its script as the app, even\n * though the `<img>` itself never would. Under an allowlisted type the bytes\n * are inert, and a `data:` URL's document has an opaque origin. WebKit sniffs\n * HTML out of `application/octet-stream`, `\"\"` and `application/zip`, so no\n * \"binary\" type is safe: an unknown file gets no URL at all. See\n * `viewableType`, and the security section of FilePreview's docs.\n *\n * The URL is created in an effect, never during render: render may run twice\n * (Strict Mode, a discarded concurrent render) and only an effect's cleanup is\n * guaranteed to pair with it, so nothing leaks. That makes a `Blob` source\n * `undefined` for its first render (an SVG's until it's read), and on the\n * server, where object URLs don't exist anyway.\n *\n * The URL is remembered beside the blob it was made for, so the render after\n * a source change never hands out the previous blob's URL, already revoked by\n * the time it would load.\n */\nexport function useObjectUrl(\n source: string | Blob | null | undefined,\n options: UseObjectUrlOptions = {},\n): string | undefined {\n const [entry, setEntry] = useState<Entry>()\n const blob = source instanceof Blob ? source : undefined\n const name = options.name ?? (blob instanceof File ? blob.name : \"\")\n const as = blob ? inlineType(options.type || blob.type, name, blob.size) : undefined\n\n useEffect(() => {\n if (!blob || !as) return\n if (as !== SVG_TYPE) {\n // Re-wrapped, so the type the file claims never reaches the browser.\n const url = URL.createObjectURL(blob.slice(0, blob.size, as))\n setEntry({ blob, as, url })\n return () => URL.revokeObjectURL(url)\n }\n const reader = new FileReader()\n reader.onload = () => {\n if (typeof reader.result === \"string\") setEntry({ blob, as, url: reader.result })\n }\n reader.readAsDataURL(blob.slice(0, blob.size, SVG_TYPE))\n return () => reader.abort()\n }, [blob, as])\n\n if (blob) return entry?.blob === blob && entry.as === as ? entry.url : undefined\n return typeof source === \"string\" ? source : undefined\n}\n"]}
1
+ {"version":3,"sources":["../src/lib/files.ts","../src/lib/open-file.ts","../src/lib/use-object-url.ts"],"names":["started","win","mimeOf"],"mappings":";;;;;;AAQA,IAAM,aAAa,CAAC,MAAA,EAAQ,YAAY,UAAA,EAAY,UAAA,EAAY,YAAY,UAAU,CAAA;AAc/E,IAAM,cAAA,GAAiB,CAAC,KAAA,EAAe,MAAA,GAAiB,cAAA,KAA2B;AAExF,EAAA,MAAM,QAAA,GAAW,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,WAAW,MAAA,CAAO,CAAC,CAAA,EAAG,KAAA,KAAU,KAAA,IAAS,GAAA,IAAQ,KAAK,CAAA,CAAE,SAAS,CAAC,CAAA;AAC/F,EAAA,MAAM,KAAA,GAAQ,OAAO,UAAA,CAAA,CAAY,KAAA,GAAQ,OAAQ,QAAA,EAAU,WAAA,CAAY,CAAC,CAAC,CAAA;AACzE,EAAA,OAAO,IAAI,IAAA,CAAK,YAAA,CAAa,MAAA,EAAQ;AAAA,IACnC,KAAA,EAAO,MAAA;AAAA,IACP,IAAA,EAAM,WAAW,QAAQ,CAAA;AAAA,IACzB,WAAA,EAAa;AAAA,GACd,CAAA,CAAE,MAAA,CAAO,KAAK,CAAA;AACjB;AAGO,IAAM,UAAA,GAAa;AAAA,EACxB,OAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,aAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA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E,IAAA,EAAM,EAAA,EAAI,GAAA,EAAK,MAAA,CAAO,MAAA,EAAQ,CAAA;AAAA,IAClF,CAAA;AACA,IAAA,MAAA,CAAO,cAAc,IAAA,CAAK,KAAA,CAAM,GAAG,IAAA,CAAK,IAAA,EAAM,QAAQ,CAAC,CAAA;AACvD,IAAA,OAAO,MAAM,OAAO,KAAA,EAAM;AAAA,EAC5B,CAAA,EAAG,CAAC,IAAA,EAAM,EAAE,CAAC,CAAA;AAEb,EAAA,IAAI,IAAA,SAAa,KAAA,EAAO,IAAA,KAAS,QAAQ,KAAA,CAAM,EAAA,KAAO,EAAA,GAAK,KAAA,CAAM,GAAA,GAAM,MAAA;AACvE,EAAA,OAAO,OAAO,MAAA,KAAW,QAAA,GAAW,MAAA,GAAS,MAAA;AAC/C","file":"chunk-WERJ44ZN.js","sourcesContent":["import { DEFAULT_LOCALE } from \"./intl\"\n\n/**\n * Helpers for showing a file: its size as people read it, and what kind of\n * file it is. Plain functions, no React, so they work in a loader, a table\n * cell or a test as well as in `FileItem` and `FileUpload`, which use them.\n */\n\nconst BYTE_UNITS = [\"byte\", \"kilobyte\", \"megabyte\", \"gigabyte\", \"terabyte\", \"petabyte\"] as const\n\n/**\n * A byte count as people read it: decimal units (1 MB is 1,000,000 bytes),\n * three significant digits, in the locale's own unit names.\n *\n * formatFileSize(48_213) // \"48.2 kB\"\n * formatFileSize(48_213, \"fr-FR\") // \"48,2 ko\"\n * formatFileSize(file.size, useLocale()) // in a component, following IntlProvider\n *\n * zag's own `formatBytes` algorithm, on `Intl`. `locale` defaults to the\n * kit's `DEFAULT_LOCALE` rather than the runtime's, so the server and the\n * browser never disagree; inside a component, pass `useLocale()`.\n */\nexport const formatFileSize = (bytes: number, locale: string = DEFAULT_LOCALE): string => {\n // The largest unit the count reaches; below 1 byte (an empty file) stays in bytes.\n const exponent = Math.max(0, BYTE_UNITS.filter((_, index) => bytes >= 1000 ** index).length - 1)\n const value = Number.parseFloat((bytes / 1000 ** exponent).toPrecision(3))\n return new Intl.NumberFormat(locale, {\n style: \"unit\",\n unit: BYTE_UNITS[exponent],\n unitDisplay: \"short\",\n }).format(value)\n}\n\n/** What a file is, coarsely: enough to pick its icon. */\nexport const FILE_KINDS = [\n \"image\",\n \"video\",\n \"audio\",\n \"pdf\",\n \"text\",\n \"archive\",\n \"spreadsheet\",\n \"document\",\n \"code\",\n \"font\",\n \"other\",\n] as const\n\nexport type FileKind = (typeof FILE_KINDS)[number]\n\n/**\n * The one lookup behind `fileKind`. Three shapes of key share it, tried in\n * this order: an exact MIME type (`application/pdf`), a MIME family\n * (`image/*`), then an extension (`.csv`). The exact type comes first so a\n * specific `text/csv` is a spreadsheet before the `text/*` family makes it\n * text; extensions are last because a browser-provided type is better\n * evidence than a name, when there is one.\n */\nconst KINDS: Record<string, FileKind> = {\n // Families\n \"image/*\": \"image\",\n \"video/*\": \"video\",\n \"audio/*\": \"audio\",\n \"font/*\": \"font\",\n \"text/*\": \"text\",\n\n // PDF\n \"application/pdf\": \"pdf\",\n \".pdf\": \"pdf\",\n\n // Archives\n \"application/zip\": \"archive\",\n \"application/x-zip-compressed\": \"archive\",\n \"application/gzip\": \"archive\",\n \"application/x-gzip\": \"archive\",\n \"application/x-tar\": \"archive\",\n \"application/x-7z-compressed\": \"archive\",\n \"application/x-rar-compressed\": \"archive\",\n \"application/vnd.rar\": \"archive\",\n \".zip\": \"archive\",\n \".gz\": \"archive\",\n \".tgz\": \"archive\",\n \".tar\": \"archive\",\n \".7z\": \"archive\",\n \".rar\": \"archive\",\n\n // Spreadsheets\n \"text/csv\": \"spreadsheet\",\n \"text/tab-separated-values\": \"spreadsheet\",\n \"application/vnd.ms-excel\": \"spreadsheet\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\": \"spreadsheet\",\n \"application/vnd.oasis.opendocument.spreadsheet\": \"spreadsheet\",\n \"application/vnd.apple.numbers\": \"spreadsheet\",\n \".csv\": \"spreadsheet\",\n \".tsv\": \"spreadsheet\",\n \".xls\": \"spreadsheet\",\n \".xlsx\": \"spreadsheet\",\n \".ods\": \"spreadsheet\",\n \".numbers\": \"spreadsheet\",\n\n // Documents (word processing and slides)\n \"application/msword\": \"document\",\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\": \"document\",\n \"application/vnd.oasis.opendocument.text\": \"document\",\n \"application/rtf\": \"document\",\n \"text/rtf\": \"document\",\n \"application/vnd.ms-powerpoint\": \"document\",\n \"application/vnd.openxmlformats-officedocument.presentationml.presentation\": \"document\",\n \"application/vnd.oasis.opendocument.presentation\": \"document\",\n \"application/vnd.apple.pages\": \"document\",\n \"application/vnd.apple.keynote\": \"document\",\n \".doc\": \"document\",\n \".docx\": \"document\",\n \".odt\": \"document\",\n \".rtf\": \"document\",\n \".ppt\": \"document\",\n \".pptx\": \"document\",\n \".odp\": \"document\",\n \".pages\": \"document\",\n \".key\": \"document\",\n\n // Code and structured data\n \"application/json\": \"code\",\n \"application/ld+json\": \"code\",\n \"application/xml\": \"code\",\n \"text/xml\": \"code\",\n \"text/html\": \"code\",\n \"text/css\": \"code\",\n \"text/javascript\": \"code\",\n \"application/javascript\": \"code\",\n \"application/x-yaml\": \"code\",\n \"application/yaml\": \"code\",\n \"application/x-sh\": \"code\",\n \"application/sql\": \"code\",\n \".json\": \"code\",\n \".xml\": \"code\",\n \".html\": \"code\",\n \".css\": \"code\",\n \".js\": \"code\",\n \".jsx\": \"code\",\n \".ts\": \"code\",\n \".tsx\": \"code\",\n \".yml\": \"code\",\n \".yaml\": \"code\",\n \".sh\": \"code\",\n \".sql\": \"code\",\n \".py\": \"code\",\n \".c\": \"code\",\n \".h\": \"code\",\n \".cpp\": \"code\",\n \".rs\": \"code\",\n \".go\": \"code\",\n\n // Plain text by name\n \".txt\": \"text\",\n \".md\": \"text\",\n \".log\": \"text\",\n\n // Media and fonts by name, for an empty or generic type\n \".png\": \"image\",\n \".jpg\": \"image\",\n \".jpeg\": \"image\",\n \".gif\": \"image\",\n \".webp\": \"image\",\n \".avif\": \"image\",\n \".svg\": \"image\",\n \".heic\": \"image\",\n \".mp4\": \"video\",\n \".mov\": \"video\",\n \".webm\": \"video\",\n \".mkv\": \"video\",\n \".mp3\": \"audio\",\n \".wav\": \"audio\",\n \".m4a\": \"audio\",\n \".ogg\": \"audio\",\n \".flac\": \"audio\",\n \".woff\": \"font\",\n \".woff2\": \"font\",\n \".ttf\": \"font\",\n \".otf\": \"font\",\n}\n\n/** Own keys only, so a type like `\"constructor\"` can't reach `Object.prototype`. */\nconst kindOf = (key: string): FileKind | undefined =>\n Object.hasOwn(KINDS, key) ? KINDS[key] : undefined\n\n/** Types that say nothing about the content, so the name decides instead. */\nconst GENERIC_TYPES = new Set([\"\", \"application/octet-stream\", \"binary/octet-stream\"])\n\n/** `.pdf` for `\"Report.FINAL.PDF\"`, `\"\"` for a name without an extension. */\nexport const extensionOf = (name: string): string => {\n const dot = name.lastIndexOf(\".\")\n return dot > 0 ? name.slice(dot).toLowerCase() : \"\"\n}\n\n/**\n * The kind of a file, from its MIME type, or from its name's extension when\n * the type is missing or generic. Browsers often report `\"\"` for a `.csv`\n * or a `.docx`, and servers send `application/octet-stream`.\n *\n * fileKind(\"application/pdf\") // \"pdf\"\n * fileKind(\"\", \"grades.csv\") // \"spreadsheet\"\n * fileKind(file.type, file.name) // a picked File\n */\nexport const fileKind = (type = \"\", name = \"\"): FileKind => {\n const mime = type.toLowerCase().split(\";\")[0]?.trim() ?? \"\"\n const typed = GENERIC_TYPES.has(mime)\n ? undefined\n : (kindOf(mime) ?? kindOf(`${mime.split(\"/\")[0]}/*`))\n return typed ?? kindOf(extensionOf(name)) ?? \"other\"\n}\n","import { match } from \"ts-pattern\"\nimport { extensionOf, fileKind } from \"./files\"\nimport { saveFile } from \"./save-file\"\n\n/**\n * Opening a file in a new browser tab, safely: the one \"pre-open a tab, point\n * it at the file\" the kit and its apps share, plus the allowlist that decides\n * what a browser may render at all.\n *\n * Never a network request: a Blob is shown through an object URL, and a URL is\n * handed to the tab. Fetching with a token or asking for a presigned link is\n * the app's job, in the function `openFile` takes.\n */\n\n// ---------------------------------------------------------------------------\n// The allowlist\n// ---------------------------------------------------------------------------\n\n/**\n * Why there is an allowlist: an object URL has the APP's origin. An uploaded\n * `.html` or `.svg` loaded from one, in a frame or a tab, runs its script as\n * the app: stored XSS. Measured in Chromium and WebKit (Playwright), a blob of\n * HTML ran with the page's origin when typed `text/html`, and SVG markup when\n * typed `image/svg+xml`, `application/xml` or `text/xml`. WebKit went further:\n * it sniffed HTML out of a blob typed `application/octet-stream`, `\"\"` or\n * `application/zip` and ran it, so re-typing a file as \"binary\" is no defence.\n *\n * What held in both engines: the same markup re-typed as `application/pdf`,\n * `text/plain`, a raster image, a video or an audio type stayed inert. So the\n * kit never trusts a file's own type for rendering. It picks one of the types\n * below and re-wraps the Blob under it (`blob.slice(0, size, type)`), and a\n * file that maps to none of them is never rendered or navigated to: it is\n * saved instead, through a `download` link, which stayed inert everywhere.\n */\nconst RASTER: Record<string, string> = {\n \"image/png\": \"image/png\",\n \"image/jpeg\": \"image/jpeg\",\n \"image/gif\": \"image/gif\",\n \"image/webp\": \"image/webp\",\n \"image/avif\": \"image/avif\",\n \"image/bmp\": \"image/bmp\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".gif\": \"image/gif\",\n \".webp\": \"image/webp\",\n \".avif\": \"image/avif\",\n \".bmp\": \"image/bmp\",\n}\n\nconst MEDIA: Record<string, string> = {\n \"video/mp4\": \"video/mp4\",\n \"video/webm\": \"video/webm\",\n \"video/ogg\": \"video/ogg\",\n \"video/quicktime\": \"video/quicktime\",\n \"audio/mpeg\": \"audio/mpeg\",\n \"audio/mp4\": \"audio/mp4\",\n \"audio/aac\": \"audio/aac\",\n \"audio/wav\": \"audio/wav\",\n \"audio/x-wav\": \"audio/wav\",\n \"audio/ogg\": \"audio/ogg\",\n \"audio/webm\": \"audio/webm\",\n \"audio/flac\": \"audio/flac\",\n \".mp4\": \"video/mp4\",\n \".m4v\": \"video/mp4\",\n \".webm\": \"video/webm\",\n \".mov\": \"video/quicktime\",\n \".ogv\": \"video/ogg\",\n \".mp3\": \"audio/mpeg\",\n \".m4a\": \"audio/mp4\",\n \".aac\": \"audio/aac\",\n \".wav\": \"audio/wav\",\n \".ogg\": \"audio/ogg\",\n \".oga\": \"audio/ogg\",\n \".flac\": \"audio/flac\",\n}\n\n/** Text a tab may show as plain text: never markup, which could be sniffed or parsed. */\nconst PLAIN_TEXT: Record<string, true> = {\n \"text/plain\": true,\n \"text/markdown\": true,\n \"text/csv\": true,\n \"text/tab-separated-values\": true,\n \"application/json\": true,\n \".txt\": true,\n \".md\": true,\n \".log\": true,\n \".csv\": true,\n \".tsv\": true,\n \".json\": true,\n}\n\n/** The kit's one text type: re-typed so a tab shows the characters, never parses them. */\nconst TEXT_TYPE = \"text/plain;charset=utf-8\"\n\n/** Own keys only, so a type like `\"constructor\"` can't reach `Object.prototype`. */\nconst lookup = <T>(table: Record<string, T>, key: string): T | undefined =>\n Object.hasOwn(table, key) ? table[key] : undefined\n\nconst mimeOf = (type: string) => type.toLowerCase().split(\";\")[0]?.trim() ?? \"\"\n\n/**\n * The type a browser may render a file under, from the kit's allowlist, or\n * `undefined` when it must not be rendered: saved, never shown.\n *\n * viewableType(\"application/pdf\", \"contract.pdf\") // \"application/pdf\"\n * viewableType(\"\", \"scan.JPG\") // \"image/jpeg\"\n * viewableType(\"text/csv\", \"grades.csv\") // \"text/plain;charset=utf-8\"\n * viewableType(\"text/html\", \"contract.pdf\") // undefined: the type says HTML\n * viewableType(\"image/svg+xml\", \"logo.svg\") // undefined: SVG runs script\n *\n * The kind comes from `fileKind`, so a specific type wins over the name, and\n * the name decides for a missing or generic type. The result is always one of\n * a fixed set (PDF, PNG/JPEG/GIF/WebP/AVIF/BMP, common video and audio types,\n * plain text), never the file's own type passed through. Re-wrap the Blob\n * under it before making an object URL:\n *\n * const safe = viewableType(file.type, file.name)\n * if (safe) url = URL.createObjectURL(file.slice(0, file.size, safe))\n */\nexport const viewableType = (type = \"\", name = \"\"): string | undefined => {\n const mime = mimeOf(type)\n const extension = extensionOf(name)\n // The specific type first, like `fileKind`; the extension only for a type that says nothing.\n const pick = <T>(table: Record<string, T>) => lookup(table, mime) ?? lookup(table, extension)\n return match(fileKind(type, name))\n .with(\"pdf\", () => \"application/pdf\")\n .with(\"image\", () => pick(RASTER))\n .with(\"video\", \"audio\", () => pick(MEDIA))\n .with(\"text\", \"spreadsheet\", \"code\", () => (pick(PLAIN_TEXT) ? TEXT_TYPE : undefined))\n .otherwise(() => undefined)\n}\n\n// ---------------------------------------------------------------------------\n// openFile\n// ---------------------------------------------------------------------------\n\n/**\n * How often an open tab is checked, in milliseconds: 2 s. The object URL is\n * revoked at the first check that finds the tab closed or showing something\n * else. Browsers throttle timers in a background tab (Chrome to once a\n * minute after five minutes), which only delays the revoke: nothing breaks.\n */\nexport const OPEN_FILE_POLL = 2_000\n\n/**\n * The longest an object URL is kept for an open tab, in milliseconds: one hour.\n * After it the tab still shows the file, but reloading it, or saving it from\n * the browser's PDF viewer, fails. A safety net for a tab left open all day:\n * the Blob stays in memory as long as its URL lives. Closing or reloading the\n * app's own page revokes every object URL it made, whatever this says.\n */\nexport const OPEN_FILE_MAX_AGE = 3_600_000\n\n/** What can be opened: a Blob (or File), or a URL. */\nexport type OpenFileData = Blob | string\n\n/** Resolves the file on click. `signal` is `options.signal`, when there is one. */\nexport type OpenFileLoader = (context: {\n signal: AbortSignal\n}) => OpenFileData | Promise<OpenFileData>\n\nexport type OpenFileOptions = {\n /** The file name: the tab's title while it loads, the saved file's name, and, with\n * `type`, what decides whether the file may be shown. A File's own name by default. */\n name?: string\n /** The MIME type, when the Blob's own is missing, or for a URL. */\n type?: string\n /** Aborts a pending function: the tab closes and the promise rejects. */\n signal?: AbortSignal\n}\n\n/** `\"opened\"` in a tab, or `\"saved\"`: the popup was blocked, or the file isn't allowed in one. */\nexport type OpenFileResult = \"opened\" | \"saved\"\n\n/** Where the tab goes: the Blob under its allowlisted type, or a URL to follow. */\ntype Target = { blob: Blob; type: string } | { url: string }\n\nconst isSameOrigin = (url: URL) =>\n url.protocol === \"blob:\" || url.protocol === \"data:\" || url.origin === window.location.origin\n\n/** The last path segment of a URL, as a fallback name. */\nconst lastSegment = (url: URL) =>\n decodeURIComponent(url.pathname.split(\"/\").filter(Boolean).at(-1) ?? \"\")\n\n/**\n * Where a tab may go for `data`, or `undefined` to save it instead.\n *\n * - **A Blob** only under its `viewableType`, re-wrapped.\n * - **A cross-origin URL** (a presigned S3 link) always: whatever it serves runs\n * with its own origin, not the app's, and the tab has no `opener`.\n * - **A same-origin URL** only when its `type` or name is viewable. The server's\n * `Content-Type` decides what the browser does then, so it must be honest.\n * - **A `blob:` or `data:` string** never: its real type can't be checked. Pass the\n * Blob itself.\n */\nconst targetOf = (data: OpenFileData, name: string, type: string): Target | undefined => {\n if (typeof data !== \"string\") {\n const safe = viewableType(type || data.type, name)\n return safe ? { blob: data, type: safe } : undefined\n }\n const url = new URL(data, window.location.href)\n if (url.protocol === \"blob:\" || url.protocol === \"data:\") return undefined\n if (!isSameOrigin(url)) return { url: url.href }\n return viewableType(type, name || lastSegment(url)) ? { url: url.href } : undefined\n}\n\n/** Reads the tab's address, or `undefined` once it has left for another origin. */\nconst addressOf = (win: Window): string | undefined => {\n try {\n return win.location.href\n } catch {\n return undefined\n }\n}\n\n/**\n * Keeps an object URL alive while its tab shows it. Revoked when the tab is\n * closed, navigates away (including to another origin, where its address can't\n * be read), or after `OPEN_FILE_MAX_AGE`. `about:blank` counts as still\n * loading: the navigation is asynchronous, and revoking during it would break\n * the very load it waits for.\n */\nconst watch = (win: Window, url: string) => {\n const started = Date.now()\n const timer = setInterval(() => {\n const address = win.closed ? undefined : addressOf(win)\n const showing = address === url || address === \"about:blank\"\n if (showing && Date.now() - started < OPEN_FILE_MAX_AGE) return\n clearInterval(timer)\n URL.revokeObjectURL(url)\n }, OPEN_FILE_POLL)\n}\n\n/** Points the tab at the file, replacing its blank page in history. A Blob is re-wrapped\n * under its allowlisted type first, so the type it claims never reaches the browser. */\nconst show = (win: Window, target: Target) => {\n if (\"url\" in target) return win.location.replace(target.url)\n const url = URL.createObjectURL(target.blob.slice(0, target.blob.size, target.type))\n win.location.replace(url)\n watch(win, url)\n}\n\n/** A blank tab, cut off from this page, or `null` when a popup blocker stopped it. */\nconst blankTab = (name: string): Window | null => {\n const win = window.open(\"\", \"_blank\")\n if (!win || win.closed) return null\n // Before anything loads: the tab can't reach back into the app. Not `noopener` in\n // `window.open`, which would hand back `null` and leave nothing to point at the file.\n win.opener = null\n try {\n // The tab's title while a slow function resolves, rather than \"Untitled\".\n if (name) win.document.title = name\n } catch {\n // A browser that gave the blank tab its own origin: the title is cosmetic.\n }\n return win\n}\n\n/** Calls the loader inside the click, and treats a synchronous throw as a rejection. */\nconst started = (load: OpenFileLoader, signal: AbortSignal): Promise<OpenFileData> => {\n try {\n return Promise.resolve(load({ signal }))\n } catch (error) {\n return Promise.reject(error)\n }\n}\n\nconst nameOf = (data: OpenFileData, name: string | undefined) =>\n name ?? (typeof data !== \"string\" && data instanceof File ? data.name : \"\")\n\n/**\n * Opens a file in a new tab: a Blob, a URL, or what a function of yours\n * resolves to. Call it in a click handler.\n *\n * openFile(file) // a picked File\n * openFile(presignedUrl, { name: \"consent.pdf\" })\n * openFile(({ signal }) => api.blob(`/documents/${id}`, { signal }), { name: \"contract.pdf\" })\n *\n * - **Popup-safe.** The tab opens synchronously, inside the click, before a\n * function is called; browsers block a popup opened after an `await`. It\n * shows the file once the promise resolves, and closes if it rejects.\n * - **Blocked popup → saved.** When the browser blocks the tab, the file is\n * saved with `saveFile` instead, and the promise resolves `\"saved\"`.\n * - **Only safe types are shown.** A file outside the allowlist (`viewableType`:\n * PDF, raster images, common video and audio, plain text) is saved, never\n * navigated to, so an uploaded HTML or SVG can't run as the app. A Blob is\n * re-wrapped under the allowlisted type, whatever type it claims.\n * - **The object URL lives as long as the tab shows it**, so saving from the\n * browser's PDF viewer and reloading keep working: it is revoked once the tab\n * closes or navigates away, and after `OPEN_FILE_MAX_AGE` (an hour) at most.\n *\n * The tab's title is the PDF's own `Title` metadata when it has one, and the\n * object URL's id otherwise: have your PDF generator set the title. Hosting the\n * PDF in a titled page of our own would fix the title, but it breaks reloading\n * the tab and shows only the first page on iOS.\n *\n * Rejects when the function rejects or `signal` aborts, after closing the tab.\n */\nexport const openFile = (\n source: OpenFileData | OpenFileLoader,\n options: OpenFileOptions = {},\n): Promise<OpenFileResult> => {\n if (typeof window === \"undefined\") {\n return Promise.reject(new Error(\"openFile runs in a browser, in a click handler.\"))\n }\n const type = options.type ?? \"\"\n\n // A value is decided now: a file that can't be shown never opens a tab at all.\n if (typeof source !== \"function\") {\n const name = nameOf(source, options.name)\n const target = targetOf(source, name, type)\n const win = target && blankTab(name)\n if (!target || !win) {\n saveFile(source, name || undefined, { type: options.type })\n return Promise.resolve(\"saved\")\n }\n show(win, target)\n return Promise.resolve(\"opened\")\n }\n\n // A function: the tab opens now, while the click still allows it.\n const signal = options.signal ?? new AbortController().signal\n const win = blankTab(options.name ?? \"\")\n const aborted = () => Promise.reject(signal.reason)\n if (signal.aborted) {\n win?.close()\n return aborted()\n }\n return started(source, signal).then(\n (data): OpenFileResult | Promise<never> => {\n if (signal.aborted) {\n win?.close()\n return aborted()\n }\n const name = nameOf(data, options.name)\n const target = win ? targetOf(data, name, type) : undefined\n if (!win || !target) {\n win?.close()\n saveFile(data, name || undefined, { type: options.type })\n return \"saved\"\n }\n show(win, target)\n return \"opened\"\n },\n (error: unknown) => {\n win?.close()\n throw error\n },\n )\n}\n","\"use client\"\n\nimport { useEffect, useState } from \"react\"\nimport { extensionOf, fileKind } from \"./files\"\nimport { viewableType } from \"./open-file\"\n\n/**\n * The largest SVG `useObjectUrl` shows, in bytes: 5 MB. An SVG is shown from\n * a `data:` URL, which lives as a JavaScript string (a third larger than the\n * file, in base64) and again as the `<img>`'s attribute, for every mounted\n * thumbnail. Past this an SVG gets no URL, so the caller's fallback shows: an\n * icon in FileItem, the download panel in FilePreview.\n */\nexport const SVG_DATA_URL_LIMIT = 5_000_000\n\nconst SVG_TYPE = \"image/svg+xml\"\n\nconst mimeOf = (type: string) => type.toLowerCase().split(\";\")[0]?.trim() ?? \"\"\n\n/**\n * The type a file may be shown under IN the page, or `undefined` for none:\n * `viewableType`'s, or SVG, which `useObjectUrl` draws from a `data:` URL and\n * never from an object URL. SVG when the type says so, or, for a missing or\n * generic type, the name does; at most `SVG_DATA_URL_LIMIT` bytes.\n *\n * inlineType(\"image/png\", \"scan.png\") // \"image/png\"\n * inlineType(\"\", \"logo.svg\", 2_000) // \"image/svg+xml\": a data: URL\n * inlineType(\"text/html\", \"logo.svg\") // undefined: the type says HTML\n */\nexport const inlineType = (type = \"\", name = \"\", size = 0): string | undefined => {\n const safe = viewableType(type, name)\n if (safe) return safe\n const svg =\n fileKind(type, name) === \"image\" && (mimeOf(type) === SVG_TYPE || extensionOf(name) === \".svg\")\n return svg && size <= SVG_DATA_URL_LIMIT ? SVG_TYPE : undefined\n}\n\nexport type UseObjectUrlOptions = {\n /** The file name, when the type is missing or generic. A File's own name by default. */\n name?: string\n /** The MIME type, in place of the Blob's own. */\n type?: string\n}\n\ntype Entry = { blob: Blob; as: string; url: string }\n\n/**\n * A URL an `<img>`, `<video>` or `<object>` can load for `source`, safe to put\n * in the page. A string passes through untouched. A `Blob` (a `File` from an\n * input or a drop) is shown only under a type the kit allows, never the type\n * it claims:\n *\n * - **PDF, raster images, common video and audio, plain text** (`viewableType`):\n * an object URL for the Blob re-wrapped under that type, revoked when the\n * source changes or the component unmounts.\n * - **SVG**, up to `SVG_DATA_URL_LIMIT`: a `data:` URL.\n * - **Anything else**: `undefined`, so nothing is shown.\n *\n * const url = useObjectUrl(file)\n * <img src={url} alt=\"\" />\n *\n * Why: an object URL has the app's origin. \"Open image in new tab\" (or\n * dragging the image to the tab bar, or copying its address) navigates to it,\n * and an uploaded `.svg` or `.html` there runs its script as the app, even\n * though the `<img>` itself never would. Under an allowlisted type the bytes\n * are inert, and a `data:` URL's document has an opaque origin. WebKit sniffs\n * HTML out of `application/octet-stream`, `\"\"` and `application/zip`, so no\n * \"binary\" type is safe: an unknown file gets no URL at all. See\n * `viewableType`, and the security section of FilePreview's docs.\n *\n * The URL is created in an effect, never during render: render may run twice\n * (Strict Mode, a discarded concurrent render) and only an effect's cleanup is\n * guaranteed to pair with it, so nothing leaks. That makes a `Blob` source\n * `undefined` for its first render (an SVG's until it's read), and on the\n * server, where object URLs don't exist anyway.\n *\n * The URL is remembered beside the blob it was made for, so the render after\n * a source change never hands out the previous blob's URL, already revoked by\n * the time it would load.\n */\nexport function useObjectUrl(\n source: string | Blob | null | undefined,\n options: UseObjectUrlOptions = {},\n): string | undefined {\n const [entry, setEntry] = useState<Entry>()\n const blob = source instanceof Blob ? source : undefined\n const name = options.name ?? (blob instanceof File ? blob.name : \"\")\n const as = blob ? inlineType(options.type || blob.type, name, blob.size) : undefined\n\n useEffect(() => {\n if (!blob || !as) return\n if (as !== SVG_TYPE) {\n // Re-wrapped, so the type the file claims never reaches the browser.\n const url = URL.createObjectURL(blob.slice(0, blob.size, as))\n setEntry({ blob, as, url })\n return () => URL.revokeObjectURL(url)\n }\n const reader = new FileReader()\n reader.onload = () => {\n if (typeof reader.result === \"string\") setEntry({ blob, as, url: reader.result })\n }\n reader.readAsDataURL(blob.slice(0, blob.size, SVG_TYPE))\n return () => reader.abort()\n }, [blob, as])\n\n if (blob) return entry?.blob === blob && entry.as === as ? entry.url : undefined\n return typeof source === \"string\" ? source : undefined\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  import { Progress } from './chunk-QKSLDQM2.js';
2
2
  import { FILE_KIND_ICONS } from './chunk-SDVZFXQ2.js';
3
3
  import { Image } from './chunk-Y57NW6G7.js';
4
- import { Button } from './chunk-SWVUXEBT.js';
5
- import { formatFileSize, useObjectUrl, fileKind } from './chunk-TCFB23JT.js';
6
- import { useLocale, useTimeZone } from './chunk-IPYHTCFL.js';
4
+ import { Button } from './chunk-SCXXJDKQ.js';
5
+ import { formatFileSize, useObjectUrl, fileKind } from './chunk-WERJ44ZN.js';
6
+ import { useLocale, useTimeZone } from './chunk-IUK7OJXZ.js';
7
7
  import { CloseIcon } from './chunk-6YNLRQ25.js';
8
8
  import { mergeIcons, iconStroke } from './chunk-XXOR34T4.js';
9
9
  import { withAsChildContent, composeChildren } from './chunk-R5LYFTHA.js';
@@ -336,5 +336,5 @@ var FileItem = Object.assign(FileItemComponent, {
336
336
  });
337
337
 
338
338
  export { FileItem, isInFlight };
339
- //# sourceMappingURL=chunk-QNKD2SQM.js.map
340
- //# sourceMappingURL=chunk-QNKD2SQM.js.map
339
+ //# sourceMappingURL=chunk-X3YIHN2U.js.map
340
+ //# sourceMappingURL=chunk-X3YIHN2U.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/file-item/file-item.tsx"],"names":["Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;AAmGA,IAAM,oBAAA,GAAuD;AAAA,EAC3D,MAAA,EAAQ,CAAC,IAAA,KAAS,CAAA,OAAA,EAAU,IAAI,CAAA,CAAA;AAAA,EAChC,MAAA,EAAQ,CAAC,IAAA,KAAS,CAAA,iBAAA,EAAoB,IAAI,CAAA,CAAA;AAAA,EAC1C,KAAA,EAAO,OAAA;AAAA,EACP,MAAA,EAAQ,QAAA;AAAA,EACR,UAAA,EAAY,kBAAA;AAAA,EACZ,IAAA,EAAM,UAAA;AAAA,EACN,MAAA,EAAQ,eAAA;AAAA,EACR,YAAA,EAAc,CAAC,MAAA,EAAQ,IAAA,KACrB,KAAA,CAAM,MAAM,CAAA,CACT,IAAA,CAAK,WAAA,EAAa,MAAM,CAAA,UAAA,EAAa,IAAI,CAAA,CAAE,CAAA,CAC3C,IAAA,CAAK,MAAA,EAAQ,MAAM,CAAA,EAAG,IAAI,CAAA,SAAA,CAAW,CAAA,CACrC,IAAA,CAAK,OAAA,EAAS,MAAM,CAA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AAA,CAAO,iBAAA,EAAmB;AAAA,EACvD,IAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,QAAA,EAAU,WAAA;AAAA,EACV,OAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAC","file":"chunk-QNKD2SQM.js","sourcesContent":["\"use client\"\n\nimport { ark, type HTMLArkProps } from \"@ark-ui/react\"\nimport { CircleCheck, RotateCw } from \"lucide-react\"\nimport {\n createContext,\n Fragment,\n type ReactNode,\n type Ref,\n useContext,\n useId,\n useState,\n} from \"react\"\nimport { match } from \"ts-pattern\"\nimport { composeChildren, type NoAsChild, withAsChildContent } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { FILE_KIND_ICONS } from \"../../lib/file-kind-icons\"\nimport { type FileKind, fileKind, formatFileSize } from \"../../lib/files\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { type IconMap, iconStroke, mergeIcons } from \"../../lib/icons\"\nimport { useLocale, useTimeZone } from \"../../lib/intl\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES, TYPOGRAPHY_SHADE_CLASSES } from \"../../lib/typography-size\"\nimport { useObjectUrl } from \"../../lib/use-object-url\"\nimport { Button, type ButtonProps } from \"../button/button\"\nimport { Image } from \"../image/image\"\nimport { CloseIcon } from \"../popover/icons\"\nimport { Progress, type ProgressProps } from \"../progress/progress\"\n\n/**\n * FileItem — one file as a row: its icon or thumbnail, its name, a meta line\n * (size, date, upload status) and its actions.\n *\n * <FileItem file={pickedFile} onRemove={() => remove(pickedFile)} />\n * <FileItem file={{ name: \"contract.pdf\", size: 248_213, date: doc.signedAt }} actions={…} />\n *\n * The same row serves a `File` the visitor just picked and a document stored\n * on a server, described by `{ name, size?, type?, date?, src? }` (`src` is a\n * thumbnail or preview URL). `FileUpload` renders its list with it.\n *\n * Upload state comes in through `status` (`queued → uploading → processing →\n * done | error`) and `progress` (0–1), so a queue only has to feed them:\n * uploading shows a determinate bar named after the file, processing an\n * indeterminate one, an error its message and a Retry button. Screen readers\n * hear the start, the end and a failure through a polite status region,\n * never each progress tick. A row a queue drives (`itemProps`) stays quiet\n * instead (`announce={false}`), and `FileQueueSummary` speaks for the run.\n *\n * Sizes and dates follow the `IntlProvider` locale and time zone; every\n * string goes through `translations`, every icon through `icons`.\n */\n\nexport type FileItemStatus = \"idle\" | \"queued\" | \"uploading\" | \"processing\" | \"done\" | \"error\"\n\n/** A file that lives on a server: a stored document rather than a picked `File`. */\nexport type FileDescriptor = {\n name: string\n /** In bytes. */\n size?: number\n /** MIME type. Picks the icon, with the name's extension as the fallback. */\n type?: string\n /** When it was uploaded, signed, last changed: whatever the app's meta line means. A date-only\n * ISO string (`\"2026-10-01\"`) is UTC midnight, so it can read as the day before west of UTC;\n * pass a full timestamp or a `Date`. */\n date?: Date | string | number\n /** A thumbnail or preview URL, shown in place of the kind icon. */\n src?: string\n}\n\nexport type FileItemFile = File | FileDescriptor\n\nexport type FileItemIconSlot = FileKind | \"remove\" | \"retry\" | \"done\"\nexport type FileItemIcons = IconMap<FileItemIconSlot>\n\n/** The statuses the status region speaks up for. The others are steps in between. */\nexport type FileItemAnnouncedStatus = \"uploading\" | \"done\" | \"error\"\n\nexport type FileItemTranslations = {\n /** The remove button's accessible name. @default (name) => `Remove ${name}` */\n remove?: (name: string) => string\n /** The same button's name while the file is queued or in flight.\n * @default (name) => `Cancel upload of ${name}` */\n cancel?: (name: string) => string\n /** The retry button's text (it is described by the file name). @default \"Retry\" */\n retry?: string\n /** @default \"Queued\" */\n queued?: string\n /** The meta line and the indeterminate bar's value text. @default \"Processing…\" */\n processing?: string\n /** @default \"Uploaded\" */\n done?: string\n /** Shown for an error without an `error` message. @default \"Upload failed\" */\n failed?: string\n /** What the status region says on each announced transition. The `error` message, when\n * there is one, follows it. */\n announcement?: (status: FileItemAnnouncedStatus, name: string) => string\n}\n\nconst DEFAULT_TRANSLATIONS: Required<FileItemTranslations> = {\n remove: (name) => `Remove ${name}`,\n cancel: (name) => `Cancel upload of ${name}`,\n retry: \"Retry\",\n queued: \"Queued\",\n processing: \"Processing…\",\n done: \"Uploaded\",\n failed: \"Upload failed\",\n announcement: (status, name) =>\n match(status)\n .with(\"uploading\", () => `Uploading ${name}`)\n .with(\"done\", () => `${name} uploaded`)\n .with(\"error\", () => `${name} failed to upload`)\n .exhaustive(),\n}\n\n/** The default icons, one per kind plus the row's own buttons. */\nconst DEFAULT_ICONS: Record<FileItemIconSlot, ReactNode> = {\n ...FILE_KIND_ICONS,\n remove: <CloseIcon />,\n retry: <RotateCw aria-hidden className={iconStroke} />,\n done: <CircleCheck aria-hidden className={iconStroke} />,\n}\n\nconst ANNOUNCED = new Set<FileItemStatus>([\"uploading\", \"done\", \"error\"])\nconst isAnnounced = (status: FileItemStatus | undefined): status is FileItemAnnouncedStatus =>\n status !== undefined && ANNOUNCED.has(status)\n\n/** Statuses where the remove button stops the upload rather than dropping a finished file. */\nconst IN_FLIGHT = new Set<FileItemStatus>([\"queued\", \"uploading\", \"processing\"])\n\n/** Whether the × stops an upload (and calls `onCancel`) rather than dropping the file. For a\n * layout composed from the parts, which wires `Remove` itself. */\nexport const isInFlight = (status: FileItemStatus | undefined): boolean =>\n status !== undefined && IN_FLIGHT.has(status)\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\ntype Shared = {\n name: string\n kind: FileKind\n size?: number\n date?: Date\n src?: string\n /** The picked file itself, for an object-URL thumbnail. */\n blob?: File\n status?: FileItemStatus\n progress?: number\n error?: ReactNode\n disabled: boolean\n thumbnails: boolean\n nameId: string\n locale: string\n timeZone: string\n t: Required<FileItemTranslations>\n icons: Record<FileItemIconSlot, ReactNode>\n}\n\nconst SharedContext = createContext<Shared | null>(null)\n\nconst useShared = () => {\n const shared = useContext(SharedContext)\n if (!shared) throw new Error(\"FileItem parts must be rendered within <FileItem.Root>.\")\n return shared\n}\n\n/** A `File` and a descriptor, read the same way. */\ntype FileFacts = Omit<FileDescriptor, \"date\"> & { date?: Date; blob?: File }\n\n/** An unparseable `date` is dropped rather than shown as \"Invalid Date\". */\nconst toDate = (value: FileDescriptor[\"date\"]): Date | undefined => {\n const date = value === undefined ? undefined : new Date(value)\n return date && !Number.isNaN(date.getTime()) ? date : undefined\n}\n\nconst readFile = (file: FileItemFile): FileFacts =>\n file instanceof File\n ? { name: file.name, size: file.size, type: file.type, blob: file }\n : { name: file.name, size: file.size, type: file.type, src: file.src, date: toDate(file.date) }\n\n// ---------------------------------------------------------------------------\n// Parts\n// ---------------------------------------------------------------------------\n\nexport type FileItemRootProps = HTMLArkProps<\"div\"> &\n WithTestId & {\n /** A picked `File`, or a stored document's `{ name, size?, type?, date?, src? }`. */\n file: FileItemFile\n /** Upload state. Pass it from the first render (`\"idle\"` or `\"queued\"`): the status\n * region exists only with a status, and announces changes, not its first value. */\n status?: FileItemStatus\n /** Upload progress from 0 to 1, read while `status` is `\"uploading\"`. Without it the bar\n * is indeterminate. */\n progress?: number\n /** Why the upload failed, shown and announced while `status` is `\"error\"`. */\n error?: ReactNode\n /** Keep a status region that announces this row's upload. Off for a row a queue drives:\n * `useFileQueue`'s `itemProps` pass `false`, and one `FileQueueSummary` speaks for every\n * row, so 400 rows don't announce 800 times. @default true */\n announce?: boolean\n /** Disables the row's own buttons (remove, retry). */\n disabled?: boolean\n /** Show image files and `src` as thumbnails. Off, every file shows its kind icon, and no\n * object URL is created. @default true */\n thumbnails?: boolean\n /** Replaces the default icons: one per `FileKind`, plus `remove`, `retry` and `done`. */\n icons?: FileItemIcons\n /** Overrides the row's strings. A partial override keeps the other defaults. */\n translations?: FileItemTranslations\n ref?: Ref<HTMLDivElement>\n }\n\nconst Root = ({\n file,\n status,\n progress,\n error,\n announce = true,\n disabled = false,\n thumbnails = true,\n icons,\n translations,\n asChild,\n children,\n className,\n testId,\n ...rest\n}: FileItemRootProps) => {\n const locale = useLocale()\n const timeZone = useTimeZone()\n const nameId = useId()\n const t = { ...DEFAULT_TRANSLATIONS, ...translations }\n const { type, ...facts } = readFile(file)\n const kind = fileKind(type, facts.name)\n\n // Only a change of status is announced, never the first one (a stored document mounting as\n // \"done\" is not news) and never a progress tick. State adjusted during render, React's own\n // pattern for \"remember the previous prop\", so the region's text lands in the same commit.\n const [seen, setSeen] = useState(status)\n const [announced, setAnnounced] = useState<FileItemAnnouncedStatus | null>(null)\n if (seen !== status) {\n setSeen(status)\n setAnnounced(isAnnounced(status) ? status : null)\n }\n\n const shared: Shared = {\n ...facts,\n kind,\n status,\n progress,\n error,\n disabled,\n thumbnails,\n nameId,\n locale,\n timeZone,\n t,\n icons: mergeIcons(DEFAULT_ICONS, icons),\n }\n\n const region = announce && status !== undefined && (\n // A sibling of the busy Body rather than inside it: assistive tech may hold back a live\n // region's changes while it sits in an `aria-busy` subtree.\n <span role=\"status\" className=\"sr-only\">\n {announced && t.announcement(announced, facts.name)}\n {announced === \"error\" && error != null && <> {error}</>}\n </span>\n )\n\n return (\n <SharedContext.Provider value={shared}>\n <ark.div\n data-kind={kind}\n {...props({ \"data-status\": status, \"data-testid\": testId })}\n asChild={asChild}\n className={cn(\n // `relative` contains the status region's sr-only box.\n \"relative flex items-center gap-1 rounded-input border p-2\",\n // The kit's hairline, the same as FileUpload's dropzone above its list.\n \"border-brand-900/20 dark:border-white/15\",\n // Figma's file-upload item: `Border/border-error-secondary`, Error/500 at 30%.\n \"data-[status=error]:border-red-500/30\",\n className,\n )}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => (\n <>\n {own}\n {region}\n </>\n ))}\n </ark.div>\n </SharedContext.Provider>\n )\n}\n\nexport type FileItemPreviewProps = NoAsChild<HTMLArkProps<\"div\">> & WithTestId\n\n/** The kind icon, or the thumbnail: `src`, or an image `File` through an object URL. Lazy, and\n * decorative (the name sits next to it), so it is hidden from assistive tech. */\nconst Preview = ({ className, testId, asChild: _asChild, ...rest }: FileItemPreviewProps) => {\n const { kind, src, blob, thumbnails, icons } = useShared()\n const pictured = thumbnails && (src !== undefined || (blob !== undefined && kind === \"image\"))\n // `null` when no thumbnail is wanted, so a list with thumbnails off makes no object URLs.\n const objectUrl = useObjectUrl(pictured && src === undefined ? blob : null)\n return (\n <ark.div\n aria-hidden\n data-part=\"preview\"\n {...props({ \"data-testid\": testId })}\n className={cn(\"flex size-9 shrink-0 items-center justify-center [&>svg]:size-6\", className)}\n {...rest}\n >\n {pictured ? (\n <Image src={src ?? objectUrl} alt=\"\" fallback={icons[kind]} className=\"size-9\" />\n ) : (\n icons[kind]\n )}\n </ark.div>\n )\n}\n\nexport type FileItemBodyProps = HTMLArkProps<\"div\"> & WithTestId\n\n/** The name, meta and progress column. Busy while the file uploads or is processed. */\nconst Body = ({ className, testId, ...rest }: FileItemBodyProps) => {\n const { status } = useShared()\n return (\n <ark.div\n {...props({\n \"aria-busy\": status === \"uploading\" || status === \"processing\",\n \"data-testid\": testId,\n })}\n // `relative` anchors the progress bar, which sits in the row's bottom padding.\n className={cn(\"relative min-w-0 flex-1\", className)}\n {...rest}\n />\n )\n}\n\nexport type FileItemNameProps = HTMLArkProps<\"div\"> & WithTestId\n\n/** The file name, on one line. The full name stays in the text (truncation is CSS only) and in\n * a `title`. `asChild` turns it into your link: `<FileItem.Name asChild><a href={url}>{name}</a></…>`\n * (an empty link would fall back to the name, but linters rightly flag one). */\nconst Name = ({ asChild, children, className, testId, ...rest }: FileItemNameProps) => {\n const { name, nameId } = useShared()\n return (\n <ark.div\n title={name}\n {...props({ \"data-testid\": testId })}\n asChild={asChild}\n className={cn(\"block truncate text-sm\", className)}\n {...rest}\n // Last, so a composing part's own id (Ark's item name) can't detach the bar and buttons\n // that are named and described by it.\n id={nameId}\n >\n {composeChildren(asChild, children, (own) => own ?? name)}\n </ark.div>\n )\n}\n\nexport type FileItemMetaProps = NoAsChild<HTMLArkProps<\"div\">> & WithTestId\n\n/** The dot is hidden, the spaces aren't: screen readers get \"248 kB Queued\", not \"248 kBQueued\". */\nconst Separator = () => (\n <>\n {\" \"}\n <span aria-hidden>·</span>{\" \"}\n </>\n)\n\n/**\n * The size and date, then the status. `children` replace the size and date and keep the\n * status; an error replaces the whole line with its message.\n */\nconst Meta = ({ children, className, testId, asChild: _asChild, ...rest }: FileItemMetaProps) => {\n const { size, date, status, progress, error, locale, timeZone, t, icons } = useShared()\n const details =\n children === undefined\n ? [\n size === undefined ? null : formatFileSize(size, locale),\n date === undefined\n ? null\n : new Intl.DateTimeFormat(locale, { dateStyle: \"medium\", timeZone }).format(date),\n ]\n : [children]\n const state = match(status)\n .with(\"queued\", () => t.queued)\n .with(\"uploading\", () =>\n progress === undefined\n ? null\n : new Intl.NumberFormat(locale, { style: \"percent\", maximumFractionDigits: 0 }).format(\n Math.min(Math.max(progress, 0), 1),\n ),\n )\n .with(\"processing\", () => t.processing)\n .with(\"done\", () => (\n <span\n data-color=\"green\"\n className=\"inline-flex items-center gap-1 align-bottom text-(--c-text) [&_svg]:size-3.5\"\n >\n {icons.done}\n {t.done}\n </span>\n ))\n .otherwise(() => null)\n const segments = [...details, state].filter((segment) => segment != null && segment !== \"\")\n\n return (\n <ark.div\n data-part=\"meta\"\n {...props({ \"data-testid\": testId })}\n className={cn(\"truncate text-xs\", TYPOGRAPHY_SHADE_CLASSES.muted, className)}\n {...rest}\n >\n {status === \"error\" ? (\n <span className={TEXT_COLOR_CLASSES.error}>{error ?? t.failed}</span>\n ) : (\n segments.map((segment, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: a fixed sequence, rebuilt per render\n <Fragment key={index}>\n {index > 0 && <Separator />}\n <span>{segment}</span>\n </Fragment>\n ))\n )}\n </ark.div>\n )\n}\n\nexport type FileItemProgressProps = Omit<ProgressProps, \"value\" | \"defaultValue\" | \"onChange\">\n\n/** The upload bar: determinate while uploading with a `progress`, indeterminate otherwise and\n * while processing, absent in every other status. Named after the file. It sits under the\n * name and meta, out of flow, so the row doesn't change height. */\nconst ProgressBar = ({ className, ...rest }: FileItemProgressProps) => {\n const { status, progress, nameId, t } = useShared()\n if (status !== \"uploading\" && status !== \"processing\") return null\n const determinate = status === \"uploading\" && progress !== undefined\n return (\n <Progress\n size=\"xs\"\n value={determinate ? Math.min(Math.max(progress, 0), 1) * 100 : null}\n aria-labelledby={nameId}\n aria-valuetext={status === \"processing\" ? t.processing : undefined}\n // Out of flow, in the row's bottom padding under the text: a row keeps its height as its\n // upload starts and ends, so a list of uploads doesn't jump.\n className={cn(\"absolute inset-x-0 -bottom-1\", className)}\n {...rest}\n />\n )\n}\n\nexport type FileItemActionsProps = HTMLArkProps<\"div\"> & WithTestId\n\n/** Your buttons for the file: download, view, open in a tab. */\nconst Actions = ({ className, testId, ...rest }: FileItemActionsProps) => (\n <ark.div\n {...props({ \"data-testid\": testId })}\n className={cn(\"ms-1 flex shrink-0 items-center gap-2\", className)}\n {...rest}\n />\n)\n\nexport type FileItemRemoveProps = HTMLArkProps<\"button\"> & WithTestId\n\n/** The × button, named \"Remove {name}\", or \"Cancel upload of {name}\" while the file is queued\n * or in flight. Wire `onClick`; a composing trigger's own name (Ark's) wins over the default. */\nconst Remove = ({\n asChild,\n children,\n className,\n testId,\n disabled,\n ...rest\n}: FileItemRemoveProps) => {\n const { name, status, disabled: rowDisabled, t, icons } = useShared()\n const label = isInFlight(status) ? t.cancel(name) : t.remove(name)\n return (\n <ark.button\n type=\"button\"\n aria-label={label}\n disabled={disabled ?? rowDisabled}\n {...props({ \"data-testid\": testId })}\n asChild={asChild}\n className={cn(\n \"inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-sm me-1\",\n // The neutral washes rows and options use for hover (`popoverOption`, Table):\n // translucent, so the button reads on whatever the row sits on.\n TYPOGRAPHY_SHADE_CLASSES.muted,\n \"transition-colors hover:bg-black/5 hover:text-black dark:hover:bg-white/8 dark:hover:text-white\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n focusStyles(),\n \"[&_svg]:size-3.5\",\n className,\n )}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => own ?? icons.remove)}\n </ark.button>\n )\n}\n\nexport type FileItemRetryProps = ButtonProps\n\n/** A small \"Retry\" button, described by the file name (\"Retry, cv.pdf\"). Wire `onClick`. */\nconst Retry = ({ children, disabled, ...rest }: FileItemRetryProps) => {\n const { nameId, disabled: rowDisabled, t, icons } = useShared()\n return (\n <Button\n type=\"button\"\n size=\"xs\"\n variant=\"subtle\"\n color=\"neutral\"\n startSlot={icons.retry}\n aria-describedby={nameId}\n disabled={disabled ?? rowDisabled}\n {...rest}\n >\n {children ?? t.retry}\n </Button>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Convenience\n// ---------------------------------------------------------------------------\n\ntype FileItemClassNames = {\n root?: string\n preview?: string\n body?: string\n name?: string\n meta?: string\n progress?: string\n actions?: string\n retry?: string\n remove?: string\n}\n\nexport type FileItemProps = FileItemRootProps & {\n /** Replaces the size and date on the meta line; the status still follows. */\n meta?: ReactNode\n /** Your buttons (download, view…), before the retry and remove buttons. */\n actions?: ReactNode\n /** Renders the × button. While the file is queued or in flight it is named as a cancel, and\n * calls `onCancel` when there is one. */\n onRemove?: () => void\n /** What the × does while the file is queued or in flight: stop the upload. Falls back to\n * `onRemove`; on its own, the × shows only while there is an upload to stop. */\n onCancel?: () => void\n /** Renders a Retry button while `status` is `\"error\"`. */\n onRetry?: () => void\n classNames?: FileItemClassNames\n}\n\nfunction FileItemComponent({\n meta,\n actions,\n onRemove,\n onCancel,\n onRetry,\n classNames,\n className,\n asChild,\n children,\n ...root\n}: FileItemProps) {\n const dismiss = isInFlight(root.status) ? (onCancel ?? onRemove) : onRemove\n const row = (\n <>\n <Preview className={classNames?.preview} />\n <Body className={classNames?.body}>\n <Name className={classNames?.name} />\n <Meta className={classNames?.meta}>{meta}</Meta>\n <ProgressBar className={classNames?.progress} />\n </Body>\n {actions != null && <Actions className={classNames?.actions}>{actions}</Actions>}\n {onRetry && root.status === \"error\" && (\n <Retry onClick={onRetry} className={classNames?.retry} />\n )}\n {dismiss && <Remove onClick={dismiss} className={classNames?.remove} />}\n </>\n )\n return (\n // Under `asChild` the row becomes your element (an `<li>` in your list), with the row\n // folded in ahead of that element's own content.\n <Root {...root} asChild={asChild} className={cn(className, classNames?.root)}>\n {asChild ? (\n withAsChildContent(children, (own) => (\n <>\n {row}\n {own}\n </>\n ))\n ) : (\n <>\n {row}\n {children}\n </>\n )}\n </Root>\n )\n}\n\n/**\n * `FileItem` — the ready-made row, with the parts attached for your own layout:\n * `Root` (the file, status and context), `Preview`, `Body`, `Name`, `Meta`, `Progress`,\n * `Actions`, `Retry` and `Remove`.\n */\nexport const FileItem = Object.assign(FileItemComponent, {\n Root,\n Preview,\n Body,\n Name,\n Meta,\n Progress: ProgressBar,\n Actions,\n Retry,\n Remove,\n})\n"]}
1
+ {"version":3,"sources":["../src/components/file-item/file-item.tsx"],"names":["Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;AAmGA,IAAM,oBAAA,GAAuD;AAAA,EAC3D,MAAA,EAAQ,CAAC,IAAA,KAAS,CAAA,OAAA,EAAU,IAAI,CAAA,CAAA;AAAA,EAChC,MAAA,EAAQ,CAAC,IAAA,KAAS,CAAA,iBAAA,EAAoB,IAAI,CAAA,CAAA;AAAA,EAC1C,KAAA,EAAO,OAAA;AAAA,EACP,MAAA,EAAQ,QAAA;AAAA,EACR,UAAA,EAAY,kBAAA;AAAA,EACZ,IAAA,EAAM,UAAA;AAAA,EACN,MAAA,EAAQ,eAAA;AAAA,EACR,YAAA,EAAc,CAAC,MAAA,EAAQ,IAAA,KACrB,KAAA,CAAM,MAAM,CAAA,CACT,IAAA,CAAK,WAAA,EAAa,MAAM,CAAA,UAAA,EAAa,IAAI,CAAA,CAAE,CAAA,CAC3C,IAAA,CAAK,MAAA,EAAQ,MAAM,CAAA,EAAG,IAAI,CAAA,SAAA,CAAW,CAAA,CACrC,IAAA,CAAK,OAAA,EAAS,MAAM,CAAA,EAAG,IAAI,CAAA,iBAAA,CAAmB,CAAA,CAC9C,UAAA;A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AAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,QAAA,EAAU,WAAA;AAAA,EACV,OAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAC","file":"chunk-X3YIHN2U.js","sourcesContent":["\"use client\"\n\nimport { ark, type HTMLArkProps } from \"@ark-ui/react\"\nimport { CircleCheck, RotateCw } from \"lucide-react\"\nimport {\n createContext,\n Fragment,\n type ReactNode,\n type Ref,\n useContext,\n useId,\n useState,\n} from \"react\"\nimport { match } from \"ts-pattern\"\nimport { composeChildren, type NoAsChild, withAsChildContent } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { FILE_KIND_ICONS } from \"../../lib/file-kind-icons\"\nimport { type FileKind, fileKind, formatFileSize } from \"../../lib/files\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { type IconMap, iconStroke, mergeIcons } from \"../../lib/icons\"\nimport { useLocale, useTimeZone } from \"../../lib/intl\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES, TYPOGRAPHY_SHADE_CLASSES } from \"../../lib/typography-size\"\nimport { useObjectUrl } from \"../../lib/use-object-url\"\nimport { Button, type ButtonProps } from \"../button/button\"\nimport { Image } from \"../image/image\"\nimport { CloseIcon } from \"../popover/icons\"\nimport { Progress, type ProgressProps } from \"../progress/progress\"\n\n/**\n * FileItem — one file as a row: its icon or thumbnail, its name, a meta line\n * (size, date, upload status) and its actions.\n *\n * <FileItem file={pickedFile} onRemove={() => remove(pickedFile)} />\n * <FileItem file={{ name: \"contract.pdf\", size: 248_213, date: doc.signedAt }} actions={…} />\n *\n * The same row serves a `File` the visitor just picked and a document stored\n * on a server, described by `{ name, size?, type?, date?, src? }` (`src` is a\n * thumbnail or preview URL). `FileUpload` renders its list with it.\n *\n * Upload state comes in through `status` (`queued → uploading → processing →\n * done | error`) and `progress` (0–1), so a queue only has to feed them:\n * uploading shows a determinate bar named after the file, processing an\n * indeterminate one, an error its message and a Retry button. Screen readers\n * hear the start, the end and a failure through a polite status region,\n * never each progress tick. A row a queue drives (`itemProps`) stays quiet\n * instead (`announce={false}`), and `FileQueueSummary` speaks for the run.\n *\n * Sizes and dates follow the `IntlProvider` locale and time zone; every\n * string goes through `translations`, every icon through `icons`.\n */\n\nexport type FileItemStatus = \"idle\" | \"queued\" | \"uploading\" | \"processing\" | \"done\" | \"error\"\n\n/** A file that lives on a server: a stored document rather than a picked `File`. */\nexport type FileDescriptor = {\n name: string\n /** In bytes. */\n size?: number\n /** MIME type. Picks the icon, with the name's extension as the fallback. */\n type?: string\n /** When it was uploaded, signed, last changed: whatever the app's meta line means. A date-only\n * ISO string (`\"2026-10-01\"`) is UTC midnight, so it can read as the day before west of UTC;\n * pass a full timestamp or a `Date`. */\n date?: Date | string | number\n /** A thumbnail or preview URL, shown in place of the kind icon. */\n src?: string\n}\n\nexport type FileItemFile = File | FileDescriptor\n\nexport type FileItemIconSlot = FileKind | \"remove\" | \"retry\" | \"done\"\nexport type FileItemIcons = IconMap<FileItemIconSlot>\n\n/** The statuses the status region speaks up for. The others are steps in between. */\nexport type FileItemAnnouncedStatus = \"uploading\" | \"done\" | \"error\"\n\nexport type FileItemTranslations = {\n /** The remove button's accessible name. @default (name) => `Remove ${name}` */\n remove?: (name: string) => string\n /** The same button's name while the file is queued or in flight.\n * @default (name) => `Cancel upload of ${name}` */\n cancel?: (name: string) => string\n /** The retry button's text (it is described by the file name). @default \"Retry\" */\n retry?: string\n /** @default \"Queued\" */\n queued?: string\n /** The meta line and the indeterminate bar's value text. @default \"Processing…\" */\n processing?: string\n /** @default \"Uploaded\" */\n done?: string\n /** Shown for an error without an `error` message. @default \"Upload failed\" */\n failed?: string\n /** What the status region says on each announced transition. The `error` message, when\n * there is one, follows it. */\n announcement?: (status: FileItemAnnouncedStatus, name: string) => string\n}\n\nconst DEFAULT_TRANSLATIONS: Required<FileItemTranslations> = {\n remove: (name) => `Remove ${name}`,\n cancel: (name) => `Cancel upload of ${name}`,\n retry: \"Retry\",\n queued: \"Queued\",\n processing: \"Processing…\",\n done: \"Uploaded\",\n failed: \"Upload failed\",\n announcement: (status, name) =>\n match(status)\n .with(\"uploading\", () => `Uploading ${name}`)\n .with(\"done\", () => `${name} uploaded`)\n .with(\"error\", () => `${name} failed to upload`)\n .exhaustive(),\n}\n\n/** The default icons, one per kind plus the row's own buttons. */\nconst DEFAULT_ICONS: Record<FileItemIconSlot, ReactNode> = {\n ...FILE_KIND_ICONS,\n remove: <CloseIcon />,\n retry: <RotateCw aria-hidden className={iconStroke} />,\n done: <CircleCheck aria-hidden className={iconStroke} />,\n}\n\nconst ANNOUNCED = new Set<FileItemStatus>([\"uploading\", \"done\", \"error\"])\nconst isAnnounced = (status: FileItemStatus | undefined): status is FileItemAnnouncedStatus =>\n status !== undefined && ANNOUNCED.has(status)\n\n/** Statuses where the remove button stops the upload rather than dropping a finished file. */\nconst IN_FLIGHT = new Set<FileItemStatus>([\"queued\", \"uploading\", \"processing\"])\n\n/** Whether the × stops an upload (and calls `onCancel`) rather than dropping the file. For a\n * layout composed from the parts, which wires `Remove` itself. */\nexport const isInFlight = (status: FileItemStatus | undefined): boolean =>\n status !== undefined && IN_FLIGHT.has(status)\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\ntype Shared = {\n name: string\n kind: FileKind\n size?: number\n date?: Date\n src?: string\n /** The picked file itself, for an object-URL thumbnail. */\n blob?: File\n status?: FileItemStatus\n progress?: number\n error?: ReactNode\n disabled: boolean\n thumbnails: boolean\n nameId: string\n locale: string\n timeZone: string\n t: Required<FileItemTranslations>\n icons: Record<FileItemIconSlot, ReactNode>\n}\n\nconst SharedContext = createContext<Shared | null>(null)\n\nconst useShared = () => {\n const shared = useContext(SharedContext)\n if (!shared) throw new Error(\"FileItem parts must be rendered within <FileItem.Root>.\")\n return shared\n}\n\n/** A `File` and a descriptor, read the same way. */\ntype FileFacts = Omit<FileDescriptor, \"date\"> & { date?: Date; blob?: File }\n\n/** An unparseable `date` is dropped rather than shown as \"Invalid Date\". */\nconst toDate = (value: FileDescriptor[\"date\"]): Date | undefined => {\n const date = value === undefined ? undefined : new Date(value)\n return date && !Number.isNaN(date.getTime()) ? date : undefined\n}\n\nconst readFile = (file: FileItemFile): FileFacts =>\n file instanceof File\n ? { name: file.name, size: file.size, type: file.type, blob: file }\n : { name: file.name, size: file.size, type: file.type, src: file.src, date: toDate(file.date) }\n\n// ---------------------------------------------------------------------------\n// Parts\n// ---------------------------------------------------------------------------\n\nexport type FileItemRootProps = HTMLArkProps<\"div\"> &\n WithTestId & {\n /** A picked `File`, or a stored document's `{ name, size?, type?, date?, src? }`. */\n file: FileItemFile\n /** Upload state. Pass it from the first render (`\"idle\"` or `\"queued\"`): the status\n * region exists only with a status, and announces changes, not its first value. */\n status?: FileItemStatus\n /** Upload progress from 0 to 1, read while `status` is `\"uploading\"`. Without it the bar\n * is indeterminate. */\n progress?: number\n /** Why the upload failed, shown and announced while `status` is `\"error\"`. */\n error?: ReactNode\n /** Keep a status region that announces this row's upload. Off for a row a queue drives:\n * `useFileQueue`'s `itemProps` pass `false`, and one `FileQueueSummary` speaks for every\n * row, so 400 rows don't announce 800 times. @default true */\n announce?: boolean\n /** Disables the row's own buttons (remove, retry). */\n disabled?: boolean\n /** Show image files and `src` as thumbnails. Off, every file shows its kind icon, and no\n * object URL is created. @default true */\n thumbnails?: boolean\n /** Replaces the default icons: one per `FileKind`, plus `remove`, `retry` and `done`. */\n icons?: FileItemIcons\n /** Overrides the row's strings. A partial override keeps the other defaults. */\n translations?: FileItemTranslations\n ref?: Ref<HTMLDivElement>\n }\n\nconst Root = ({\n file,\n status,\n progress,\n error,\n announce = true,\n disabled = false,\n thumbnails = true,\n icons,\n translations,\n asChild,\n children,\n className,\n testId,\n ...rest\n}: FileItemRootProps) => {\n const locale = useLocale()\n const timeZone = useTimeZone()\n const nameId = useId()\n const t = { ...DEFAULT_TRANSLATIONS, ...translations }\n const { type, ...facts } = readFile(file)\n const kind = fileKind(type, facts.name)\n\n // Only a change of status is announced, never the first one (a stored document mounting as\n // \"done\" is not news) and never a progress tick. State adjusted during render, React's own\n // pattern for \"remember the previous prop\", so the region's text lands in the same commit.\n const [seen, setSeen] = useState(status)\n const [announced, setAnnounced] = useState<FileItemAnnouncedStatus | null>(null)\n if (seen !== status) {\n setSeen(status)\n setAnnounced(isAnnounced(status) ? status : null)\n }\n\n const shared: Shared = {\n ...facts,\n kind,\n status,\n progress,\n error,\n disabled,\n thumbnails,\n nameId,\n locale,\n timeZone,\n t,\n icons: mergeIcons(DEFAULT_ICONS, icons),\n }\n\n const region = announce && status !== undefined && (\n // A sibling of the busy Body rather than inside it: assistive tech may hold back a live\n // region's changes while it sits in an `aria-busy` subtree.\n <span role=\"status\" className=\"sr-only\">\n {announced && t.announcement(announced, facts.name)}\n {announced === \"error\" && error != null && <> {error}</>}\n </span>\n )\n\n return (\n <SharedContext.Provider value={shared}>\n <ark.div\n data-kind={kind}\n {...props({ \"data-status\": status, \"data-testid\": testId })}\n asChild={asChild}\n className={cn(\n // `relative` contains the status region's sr-only box.\n \"relative flex items-center gap-1 rounded-input border p-2\",\n // The kit's hairline, the same as FileUpload's dropzone above its list.\n \"border-brand-900/20 dark:border-white/15\",\n // Figma's file-upload item: `Border/border-error-secondary`, Error/500 at 30%.\n \"data-[status=error]:border-red-500/30\",\n className,\n )}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => (\n <>\n {own}\n {region}\n </>\n ))}\n </ark.div>\n </SharedContext.Provider>\n )\n}\n\nexport type FileItemPreviewProps = NoAsChild<HTMLArkProps<\"div\">> & WithTestId\n\n/** The kind icon, or the thumbnail: `src`, or an image `File` through an object URL. Lazy, and\n * decorative (the name sits next to it), so it is hidden from assistive tech. */\nconst Preview = ({ className, testId, asChild: _asChild, ...rest }: FileItemPreviewProps) => {\n const { kind, src, blob, thumbnails, icons } = useShared()\n const pictured = thumbnails && (src !== undefined || (blob !== undefined && kind === \"image\"))\n // `null` when no thumbnail is wanted, so a list with thumbnails off makes no object URLs.\n const objectUrl = useObjectUrl(pictured && src === undefined ? blob : null)\n return (\n <ark.div\n aria-hidden\n data-part=\"preview\"\n {...props({ \"data-testid\": testId })}\n className={cn(\"flex size-9 shrink-0 items-center justify-center [&>svg]:size-6\", className)}\n {...rest}\n >\n {pictured ? (\n <Image src={src ?? objectUrl} alt=\"\" fallback={icons[kind]} className=\"size-9\" />\n ) : (\n icons[kind]\n )}\n </ark.div>\n )\n}\n\nexport type FileItemBodyProps = HTMLArkProps<\"div\"> & WithTestId\n\n/** The name, meta and progress column. Busy while the file uploads or is processed. */\nconst Body = ({ className, testId, ...rest }: FileItemBodyProps) => {\n const { status } = useShared()\n return (\n <ark.div\n {...props({\n \"aria-busy\": status === \"uploading\" || status === \"processing\",\n \"data-testid\": testId,\n })}\n // `relative` anchors the progress bar, which sits in the row's bottom padding.\n className={cn(\"relative min-w-0 flex-1\", className)}\n {...rest}\n />\n )\n}\n\nexport type FileItemNameProps = HTMLArkProps<\"div\"> & WithTestId\n\n/** The file name, on one line. The full name stays in the text (truncation is CSS only) and in\n * a `title`. `asChild` turns it into your link: `<FileItem.Name asChild><a href={url}>{name}</a></…>`\n * (an empty link would fall back to the name, but linters rightly flag one). */\nconst Name = ({ asChild, children, className, testId, ...rest }: FileItemNameProps) => {\n const { name, nameId } = useShared()\n return (\n <ark.div\n title={name}\n {...props({ \"data-testid\": testId })}\n asChild={asChild}\n className={cn(\"block truncate text-sm\", className)}\n {...rest}\n // Last, so a composing part's own id (Ark's item name) can't detach the bar and buttons\n // that are named and described by it.\n id={nameId}\n >\n {composeChildren(asChild, children, (own) => own ?? name)}\n </ark.div>\n )\n}\n\nexport type FileItemMetaProps = NoAsChild<HTMLArkProps<\"div\">> & WithTestId\n\n/** The dot is hidden, the spaces aren't: screen readers get \"248 kB Queued\", not \"248 kBQueued\". */\nconst Separator = () => (\n <>\n {\" \"}\n <span aria-hidden>·</span>{\" \"}\n </>\n)\n\n/**\n * The size and date, then the status. `children` replace the size and date and keep the\n * status; an error replaces the whole line with its message.\n */\nconst Meta = ({ children, className, testId, asChild: _asChild, ...rest }: FileItemMetaProps) => {\n const { size, date, status, progress, error, locale, timeZone, t, icons } = useShared()\n const details =\n children === undefined\n ? [\n size === undefined ? null : formatFileSize(size, locale),\n date === undefined\n ? null\n : new Intl.DateTimeFormat(locale, { dateStyle: \"medium\", timeZone }).format(date),\n ]\n : [children]\n const state = match(status)\n .with(\"queued\", () => t.queued)\n .with(\"uploading\", () =>\n progress === undefined\n ? null\n : new Intl.NumberFormat(locale, { style: \"percent\", maximumFractionDigits: 0 }).format(\n Math.min(Math.max(progress, 0), 1),\n ),\n )\n .with(\"processing\", () => t.processing)\n .with(\"done\", () => (\n <span\n data-color=\"green\"\n className=\"inline-flex items-center gap-1 align-bottom text-(--c-text) [&_svg]:size-3.5\"\n >\n {icons.done}\n {t.done}\n </span>\n ))\n .otherwise(() => null)\n const segments = [...details, state].filter((segment) => segment != null && segment !== \"\")\n\n return (\n <ark.div\n data-part=\"meta\"\n {...props({ \"data-testid\": testId })}\n className={cn(\"truncate text-xs\", TYPOGRAPHY_SHADE_CLASSES.muted, className)}\n {...rest}\n >\n {status === \"error\" ? (\n <span className={TEXT_COLOR_CLASSES.error}>{error ?? t.failed}</span>\n ) : (\n segments.map((segment, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: a fixed sequence, rebuilt per render\n <Fragment key={index}>\n {index > 0 && <Separator />}\n <span>{segment}</span>\n </Fragment>\n ))\n )}\n </ark.div>\n )\n}\n\nexport type FileItemProgressProps = Omit<ProgressProps, \"value\" | \"defaultValue\" | \"onChange\">\n\n/** The upload bar: determinate while uploading with a `progress`, indeterminate otherwise and\n * while processing, absent in every other status. Named after the file. It sits under the\n * name and meta, out of flow, so the row doesn't change height. */\nconst ProgressBar = ({ className, ...rest }: FileItemProgressProps) => {\n const { status, progress, nameId, t } = useShared()\n if (status !== \"uploading\" && status !== \"processing\") return null\n const determinate = status === \"uploading\" && progress !== undefined\n return (\n <Progress\n size=\"xs\"\n value={determinate ? Math.min(Math.max(progress, 0), 1) * 100 : null}\n aria-labelledby={nameId}\n aria-valuetext={status === \"processing\" ? t.processing : undefined}\n // Out of flow, in the row's bottom padding under the text: a row keeps its height as its\n // upload starts and ends, so a list of uploads doesn't jump.\n className={cn(\"absolute inset-x-0 -bottom-1\", className)}\n {...rest}\n />\n )\n}\n\nexport type FileItemActionsProps = HTMLArkProps<\"div\"> & WithTestId\n\n/** Your buttons for the file: download, view, open in a tab. */\nconst Actions = ({ className, testId, ...rest }: FileItemActionsProps) => (\n <ark.div\n {...props({ \"data-testid\": testId })}\n className={cn(\"ms-1 flex shrink-0 items-center gap-2\", className)}\n {...rest}\n />\n)\n\nexport type FileItemRemoveProps = HTMLArkProps<\"button\"> & WithTestId\n\n/** The × button, named \"Remove {name}\", or \"Cancel upload of {name}\" while the file is queued\n * or in flight. Wire `onClick`; a composing trigger's own name (Ark's) wins over the default. */\nconst Remove = ({\n asChild,\n children,\n className,\n testId,\n disabled,\n ...rest\n}: FileItemRemoveProps) => {\n const { name, status, disabled: rowDisabled, t, icons } = useShared()\n const label = isInFlight(status) ? t.cancel(name) : t.remove(name)\n return (\n <ark.button\n type=\"button\"\n aria-label={label}\n disabled={disabled ?? rowDisabled}\n {...props({ \"data-testid\": testId })}\n asChild={asChild}\n className={cn(\n \"inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-sm me-1\",\n // The neutral washes rows and options use for hover (`popoverOption`, Table):\n // translucent, so the button reads on whatever the row sits on.\n TYPOGRAPHY_SHADE_CLASSES.muted,\n \"transition-colors hover:bg-black/5 hover:text-black dark:hover:bg-white/8 dark:hover:text-white\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n focusStyles(),\n \"[&_svg]:size-3.5\",\n className,\n )}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => own ?? icons.remove)}\n </ark.button>\n )\n}\n\nexport type FileItemRetryProps = ButtonProps\n\n/** A small \"Retry\" button, described by the file name (\"Retry, cv.pdf\"). Wire `onClick`. */\nconst Retry = ({ children, disabled, ...rest }: FileItemRetryProps) => {\n const { nameId, disabled: rowDisabled, t, icons } = useShared()\n return (\n <Button\n type=\"button\"\n size=\"xs\"\n variant=\"subtle\"\n color=\"neutral\"\n startSlot={icons.retry}\n aria-describedby={nameId}\n disabled={disabled ?? rowDisabled}\n {...rest}\n >\n {children ?? t.retry}\n </Button>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Convenience\n// ---------------------------------------------------------------------------\n\ntype FileItemClassNames = {\n root?: string\n preview?: string\n body?: string\n name?: string\n meta?: string\n progress?: string\n actions?: string\n retry?: string\n remove?: string\n}\n\nexport type FileItemProps = FileItemRootProps & {\n /** Replaces the size and date on the meta line; the status still follows. */\n meta?: ReactNode\n /** Your buttons (download, view…), before the retry and remove buttons. */\n actions?: ReactNode\n /** Renders the × button. While the file is queued or in flight it is named as a cancel, and\n * calls `onCancel` when there is one. */\n onRemove?: () => void\n /** What the × does while the file is queued or in flight: stop the upload. Falls back to\n * `onRemove`; on its own, the × shows only while there is an upload to stop. */\n onCancel?: () => void\n /** Renders a Retry button while `status` is `\"error\"`. */\n onRetry?: () => void\n classNames?: FileItemClassNames\n}\n\nfunction FileItemComponent({\n meta,\n actions,\n onRemove,\n onCancel,\n onRetry,\n classNames,\n className,\n asChild,\n children,\n ...root\n}: FileItemProps) {\n const dismiss = isInFlight(root.status) ? (onCancel ?? onRemove) : onRemove\n const row = (\n <>\n <Preview className={classNames?.preview} />\n <Body className={classNames?.body}>\n <Name className={classNames?.name} />\n <Meta className={classNames?.meta}>{meta}</Meta>\n <ProgressBar className={classNames?.progress} />\n </Body>\n {actions != null && <Actions className={classNames?.actions}>{actions}</Actions>}\n {onRetry && root.status === \"error\" && (\n <Retry onClick={onRetry} className={classNames?.retry} />\n )}\n {dismiss && <Remove onClick={dismiss} className={classNames?.remove} />}\n </>\n )\n return (\n // Under `asChild` the row becomes your element (an `<li>` in your list), with the row\n // folded in ahead of that element's own content.\n <Root {...root} asChild={asChild} className={cn(className, classNames?.root)}>\n {asChild ? (\n withAsChildContent(children, (own) => (\n <>\n {row}\n {own}\n </>\n ))\n ) : (\n <>\n {row}\n {children}\n </>\n )}\n </Root>\n )\n}\n\n/**\n * `FileItem` — the ready-made row, with the parts attached for your own layout:\n * `Root` (the file, status and context), `Preview`, `Body`, `Name`, `Meta`, `Progress`,\n * `Actions`, `Retry` and `Remove`.\n */\nexport const FileItem = Object.assign(FileItemComponent, {\n Root,\n Preview,\n Body,\n Name,\n Meta,\n Progress: ProgressBar,\n Actions,\n Retry,\n Remove,\n})\n"]}
@@ -12,6 +12,15 @@ var fieldRoot = cva("relative flex w-full flex-col", {
12
12
  },
13
13
  defaultVariants: { size: "md" }
14
14
  });
15
+ var fieldInlineStack = cva(
16
+ "relative inline-grid grid-cols-[auto_1fr] items-center gap-x-2 select-none",
17
+ {
18
+ variants: {
19
+ size: { xs: "gap-y-1", sm: "gap-y-1", md: "gap-y-1.5", lg: "gap-y-1.5", xl: "gap-y-2" }
20
+ },
21
+ defaultVariants: { size: "md" }
22
+ }
23
+ );
15
24
  var fieldLabel = cva(
16
25
  [
17
26
  "inline-flex items-center font-medium select-none text-trim",
@@ -155,6 +164,6 @@ var Field = ({
155
164
  );
156
165
  };
157
166
 
158
- export { Field, FieldShell, fieldA11yProps, fieldLabel, fieldRoot, requiredMark };
159
- //# sourceMappingURL=chunk-VD6PB3VA.js.map
160
- //# sourceMappingURL=chunk-VD6PB3VA.js.map
167
+ export { Field, FieldShell, fieldA11yProps, fieldInlineStack, fieldLabel, requiredMark };
168
+ //# sourceMappingURL=chunk-X6DESK37.js.map
169
+ //# sourceMappingURL=chunk-X6DESK37.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/field/field.tsx"],"names":["Ark"],"mappings":";;;;;;;;AAsCO,IAAM,SAAA,GAAY,IAAI,+BAAA,EAAiC;AAAA,EAC5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A,EAAM,CAAA,EAAG,UAAA,EAAY,KAAK,CAAA,EACzD,QAAA,EAAA;AAAA,UAAA,KAAA;AAAA,UACA,QAAA,oBACC,GAAA;AAAA,YAACA,OAAA,CAAI,iBAAA;AAAA,YAAJ;AAAA,cACC,SAAA,EAAW,EAAA,CAAG,YAAA,CAAa,SAAA,EAAW,YAAY,iBAAiB,CAAA;AAAA,cACpE,QAAA,EAAA;AAAA;AAAA;AAED,SAAA,EAEJ,CAAA;AAAA,QAGD,eAAe,IAAA,oBACd,GAAA;AAAA,UAACA,OAAA,CAAI,UAAA;AAAA,UAAJ;AAAA,YACC,SAAA,EAAW,GAAG,SAAA,CAAU,EAAE,MAAM,CAAA,EAAG,YAAY,WAAW,CAAA;AAAA,YACzD,GAAG,MAAM,EAAE,aAAA,EAAe,UAAU,CAAA,EAAG,MAAM,gBAAgB,CAAA;AAAA,YAE7D,QAAA,EAAA;AAAA;AAAA,SACH;AAAA,QAGD,QAAA;AAAA,QAEA,SAAS,IAAA,oBACR,GAAA;AAAA,UAACA,OAAA,CAAI,SAAA;AAAA,UAAJ;AAAA,YACC,SAAA,EAAW,GAAG,UAAA,CAAW,EAAE,MAAM,CAAA,EAAG,YAAY,KAAK,CAAA;AAAA,YACpD,GAAG,MAAM,EAAE,aAAA,EAAe,UAAU,CAAA,EAAG,MAAM,UAAU,CAAA;AAAA,YAEvD,QAAA,EAAA;AAAA;AAAA;AACH;AAAA;AAAA,GAEJ;AAEJ","file":"chunk-X6DESK37.js","sourcesContent":["\"use client\"\n\nimport { ark } from \"@ark-ui/react/factory\"\nimport { Field as Ark, type UseFieldContext, useFieldContext } from \"@ark-ui/react/field\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\"\nimport type { NoAsChild } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES, TYPOGRAPHY_SHADE_CLASSES } from \"../../lib/typography-size\"\n\n/**\n * Field — label / description / error scaffold for any form control, on top of\n * Ark UI's `Field`. It is the *one* place the family wires accessible names and\n * descriptions: drop a field-aware control inside (the kit's `Input`, `Select`,\n * `Combobox`, … all qualify) and Ark hands it the right `id`,\n * `aria-describedby`, `aria-invalid`, `disabled`, and `required` through\n * context — no manual plumbing per control.\n *\n * - `label` renders a `<label>` bound to the control (click-to-focus).\n * - `description` (helper text) sits between the label and the control.\n * `error` sits below the control and renders independently of it — both\n * can be visible at once. Passing `error` flips the field to `invalid`,\n * which both styles field-aware controls red and associates the message.\n * - `required` adds the semantic flag and a red asterisk in the label.\n * - `size` scales only the field's own typography; set the control's `size`\n * separately (the family components forward both).\n *\n * Every other prop (incl. `disabled`, `readOnly`, `id`) forwards to Ark's\n * `Field.Root`. `asChild` is a compile error: the field renders its label,\n * helper and error rows around the control, which can't live inside one\n * element.\n */\n\n// `relative` contains a `sr-only` label (and any hidden input rendered inside\n// the field): absolutely positioned with no offsets, it would otherwise be laid\n// out against the page and escape any scroller the field sits in.\nexport const fieldRoot = cva(\"relative flex w-full flex-col\", {\n variants: {\n size: { xs: \"gap-1\", sm: \"gap-1\", md: \"gap-1.5\", lg: \"gap-1.5\", xl: \"gap-2\" },\n },\n defaultVariants: { size: \"md\" },\n})\n\n// Root of an inline control (Switch, Checkbox) whose label carries a\n// description or error: a two-column grid, so the control centers on the\n// label's row alone instead of on the whole text stack, and the field (placed\n// with `col-start-2`) hangs under the label. The row gap follows `fieldRoot`'s.\nexport const fieldInlineStack = cva(\n \"relative inline-grid grid-cols-[auto_1fr] items-center gap-x-2 select-none\",\n {\n variants: {\n size: { xs: \"gap-y-1\", sm: \"gap-y-1\", md: \"gap-y-1.5\", lg: \"gap-y-1.5\", xl: \"gap-y-2\" },\n },\n defaultVariants: { size: \"md\" },\n },\n)\n\nexport const fieldLabel = cva(\n [\n \"inline-flex items-center font-medium select-none text-trim\",\n TEXT_COLOR_CLASSES.secondary,\n \"data-disabled:opacity-60\",\n ],\n {\n variants: {\n size: {\n xs: \"text-xs\",\n sm: \"text-sm\",\n md: \"text-sm\",\n lg: \"text-md\",\n xl: \"text-lg\",\n },\n },\n defaultVariants: { size: \"md\" },\n },\n)\n\nconst fieldHelp = cva(TYPOGRAPHY_SHADE_CLASSES.muted, {\n variants: {\n size: {\n xs: \"text-xs\",\n sm: \"text-xs\",\n md: \"text-xs\",\n lg: \"text-sm\",\n xl: \"text-sm\",\n },\n },\n defaultVariants: { size: \"md\" },\n})\n\n/** Error text: Figma's `Text/text-error-primary`, a fixed pair whatever palette the field uses. */\nconst fieldError = cva(TEXT_COLOR_CLASSES.error, {\n variants: {\n size: {\n xs: \"text-xs\",\n sm: \"text-xs\",\n md: \"text-xs\",\n lg: \"text-sm\",\n xl: \"text-sm\",\n },\n },\n defaultVariants: { size: \"md\" },\n})\n\nexport type FieldSize = NonNullable<VariantProps<typeof fieldRoot>[\"size\"]>\n\n/**\n * `aria-describedby` / `aria-errormessage` / `aria-labelledby` for a control nested\n * in a `Field`. Points `aria-describedby` at the error text id directly once\n * `invalid`, rather than trusting `field.ariaDescribedby`'s own DOM-presence-tracked\n * inclusion of it (a `MutationObserver` check that doesn't reliably catch up for\n * every control) — and adds `aria-errormessage`, which Ark's field getters never\n * emit for any control. `aria-labelledby` points at the id already rendered on\n * `Field`'s own `<label>`: needed because `NumberInput`, `PasswordInput`,\n * `TagsInput`, `Select`, and `SegmentGroup`'s real interactive element isn't\n * `Field`'s own `Ark.Input`, so it never otherwise carries an id matching the\n * label's `htmlFor`.\n */\n/**\n * The required \"*\" after a label, spread onto the mark's element. Figma binds it to\n * `Text/text-error-primary`, like the error text, so it is the same fixed pair. Shared by\n * `Field`, `Checkbox` and `Switch`, so the family draws one mark.\n */\nexport const requiredMark = { className: cn(\"ms-0.5\", TEXT_COLOR_CLASSES.error) } as const\n\nexport const fieldA11yProps = (field: UseFieldContext) => ({\n \"aria-describedby\": field?.invalid ? field.ids.errorText : field?.ariaDescribedby,\n \"aria-errormessage\": field?.invalid ? field.ids.errorText : undefined,\n \"aria-labelledby\": field?.ids.label,\n})\n\ntype FieldClassNames = {\n root?: string\n label?: string\n description?: string\n error?: string\n requiredIndicator?: string\n}\n\nexport type FieldProps = NoAsChild<Omit<ComponentPropsWithoutRef<typeof Ark.Root>, \"className\">> &\n VariantProps<typeof fieldRoot> &\n WithTestId & {\n /** Accessible name, rendered as a `<label>` bound to the control. */\n label?: ReactNode\n /** Helper text between the label and the control. */\n description?: ReactNode\n /** Error message below the control; its presence sets `invalid`. */\n error?: ReactNode\n /**\n * The control is a composite — a radio group, a row of inputs — with no single labelable\n * element for the `<label>` to point at. The label then renders as plain text with no `for`\n * (which would otherwise reference an id nothing carries) and names the control only through\n * the `aria-labelledby` that `fieldA11yProps` puts on it.\n */\n composite?: boolean\n /** Styles the field root (matching the kit's other components). */\n className?: string\n classNames?: FieldClassNames\n }\n\n/**\n * Wrap a control in a `Field` only when there's something to wire (label /\n * description / error / required) — otherwise render it bare. The data-driven\n * pickers all end with this, so it lives here instead of five copies. Bare is\n * important: an empty `Field` would still make Ark controls reference a label\n * that isn't rendered.\n */\nexport const FieldShell = ({\n label,\n description,\n error,\n required,\n disabled,\n size,\n className,\n classNames,\n testId,\n composite,\n children,\n}: Pick<\n FieldProps,\n | \"label\"\n | \"description\"\n | \"error\"\n | \"required\"\n | \"disabled\"\n | \"size\"\n | \"className\"\n | \"classNames\"\n | \"testId\"\n | \"composite\"\n> & { children: ReactNode }) => {\n const hasField = label != null || description != null || error != null || Boolean(required)\n if (!hasField) return children\n return (\n <Field\n label={label}\n description={description}\n error={error}\n required={required}\n disabled={disabled}\n size={size}\n className={className}\n classNames={classNames}\n testId={testId}\n composite={composite}\n >\n {children}\n </Field>\n )\n}\n\n/**\n * `Ark.Label`'s props on a `<span>`, minus its `for`: Ark always binds the label to\n * `field.ids.control`, an id only `Ark.Input` (or a machine reading it, like `NumberInput`'s) ever\n * renders. A composite control has no such element, so the binding would dangle — and a `<label>`\n * with nothing to label is no better. Its name comes from `aria-labelledby` pointing at this\n * span's id instead. Ark's `mergeProps` ignores an `undefined` override, so `htmlFor` has to be\n * left out rather than unset on `Ark.Label`.\n */\nconst CompositeLabel = (labelProps: ComponentPropsWithoutRef<\"span\">) => {\n const { htmlFor: _htmlFor, ...fieldLabelProps } = useFieldContext().getLabelProps()\n return <ark.span {...fieldLabelProps} {...labelProps} />\n}\n\nexport const Field = ({\n label,\n description,\n error,\n required,\n invalid,\n size,\n children,\n className,\n classNames,\n testId,\n composite,\n asChild: _asChild,\n ...rest\n}: FieldProps) => {\n const isInvalid = invalid ?? error != null\n const Label = composite ? CompositeLabel : Ark.Label\n\n return (\n <Ark.Root\n required={required}\n invalid={isInvalid}\n className={cn(fieldRoot({ size }), className, classNames?.root)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {label != null && (\n <Label className={cn(fieldLabel({ size }), classNames?.label)}>\n {label}\n {required && (\n <Ark.RequiredIndicator\n className={cn(requiredMark.className, classNames?.requiredIndicator)}\n >\n *\n </Ark.RequiredIndicator>\n )}\n </Label>\n )}\n\n {description != null && (\n <Ark.HelperText\n className={cn(fieldHelp({ size }), classNames?.description)}\n {...props({ \"data-testid\": testId && `${testId}-description` })}\n >\n {description}\n </Ark.HelperText>\n )}\n\n {children}\n\n {error != null && (\n <Ark.ErrorText\n className={cn(fieldError({ size }), classNames?.error)}\n {...props({ \"data-testid\": testId && `${testId}-error` })}\n >\n {error}\n </Ark.ErrorText>\n )}\n </Ark.Root>\n )\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { buttonGroupVariants } from './chunk-MW42XVPD.js';
2
- import { FieldShell, fieldA11yProps } from './chunk-VD6PB3VA.js';
3
- import { Button } from './chunk-SWVUXEBT.js';
2
+ import { FieldShell, fieldA11yProps } from './chunk-X6DESK37.js';
3
+ import { Button } from './chunk-SCXXJDKQ.js';
4
4
  import { useUncontrolled } from './chunk-PMUCGFY5.js';
5
5
  import { props } from './chunk-WYCMIIRR.js';
6
6
  import { cn } from './chunk-4ASNIDV7.js';
@@ -233,5 +233,5 @@ var ButtonSelectControl = ({
233
233
  };
234
234
 
235
235
  export { ButtonSelectControl, Context, Item, MultiRoot, Root };
236
- //# sourceMappingURL=chunk-7AQ4MN4M.js.map
237
- //# sourceMappingURL=chunk-7AQ4MN4M.js.map
236
+ //# sourceMappingURL=chunk-XUFCI262.js.map
237
+ //# sourceMappingURL=chunk-XUFCI262.js.map