@42-central/ui-react 0.27.0 → 0.29.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 (180) hide show
  1. package/dist/{chunk-5H5YOPCF.js → chunk-2RQLPN4U.js} +6 -6
  2. package/dist/{chunk-5H5YOPCF.js.map → chunk-2RQLPN4U.js.map} +1 -1
  3. package/dist/{chunk-SOUDKESO.js → chunk-37HYN7PC.js} +3 -3
  4. package/dist/{chunk-SOUDKESO.js.map → chunk-37HYN7PC.js.map} +1 -1
  5. package/dist/{chunk-OVT2KZHY.js → chunk-3KARNPW4.js} +3 -3
  6. package/dist/{chunk-OVT2KZHY.js.map → chunk-3KARNPW4.js.map} +1 -1
  7. package/dist/{chunk-Y2G47ARQ.js → chunk-5EOMSWNO.js} +5 -5
  8. package/dist/{chunk-Y2G47ARQ.js.map → chunk-5EOMSWNO.js.map} +1 -1
  9. package/dist/chunk-6B2GNPJP.js +43 -0
  10. package/dist/chunk-6B2GNPJP.js.map +1 -0
  11. package/dist/{chunk-MCRTAUSZ.js → chunk-7FPSQBWB.js} +3 -3
  12. package/dist/{chunk-MCRTAUSZ.js.map → chunk-7FPSQBWB.js.map} +1 -1
  13. package/dist/{chunk-6IRMKF5T.js → chunk-B4GNSSHU.js} +4 -4
  14. package/dist/{chunk-6IRMKF5T.js.map → chunk-B4GNSSHU.js.map} +1 -1
  15. package/dist/{chunk-BMEJBY6H.js → chunk-B5YHYI7E.js} +22 -27
  16. package/dist/chunk-B5YHYI7E.js.map +1 -0
  17. package/dist/{chunk-WERJ44ZN.js → chunk-DTFSCR3U.js} +3 -3
  18. package/dist/{chunk-WERJ44ZN.js.map → chunk-DTFSCR3U.js.map} +1 -1
  19. package/dist/{chunk-PFZMB3US.js → chunk-FQJNQW3G.js} +3 -3
  20. package/dist/{chunk-PFZMB3US.js.map → chunk-FQJNQW3G.js.map} +1 -1
  21. package/dist/{chunk-X3YIHN2U.js → chunk-FSPS7TVD.js} +5 -5
  22. package/dist/{chunk-X3YIHN2U.js.map → chunk-FSPS7TVD.js.map} +1 -1
  23. package/dist/{chunk-7OGZT7U2.js → chunk-G3AD3NJG.js} +3 -3
  24. package/dist/{chunk-7OGZT7U2.js.map → chunk-G3AD3NJG.js.map} +1 -1
  25. package/dist/{chunk-MNYY7UU2.js → chunk-GEZYGBXY.js} +6 -6
  26. package/dist/{chunk-MNYY7UU2.js.map → chunk-GEZYGBXY.js.map} +1 -1
  27. package/dist/{chunk-ULF5LOBS.js → chunk-HMNXNKDA.js} +3 -3
  28. package/dist/{chunk-ULF5LOBS.js.map → chunk-HMNXNKDA.js.map} +1 -1
  29. package/dist/{chunk-NF2PBGD3.js → chunk-IANYMDKH.js} +3 -3
  30. package/dist/{chunk-NF2PBGD3.js.map → chunk-IANYMDKH.js.map} +1 -1
  31. package/dist/{chunk-QEMXXQQO.js → chunk-JKFPRQB2.js} +3 -3
  32. package/dist/{chunk-QEMXXQQO.js.map → chunk-JKFPRQB2.js.map} +1 -1
  33. package/dist/{chunk-ZVECQBGG.js → chunk-KNGSO7A3.js} +41 -13
  34. package/dist/chunk-KNGSO7A3.js.map +1 -0
  35. package/dist/{chunk-L24N5EON.js → chunk-MQHD3EJE.js} +3 -3
  36. package/dist/{chunk-L24N5EON.js.map → chunk-MQHD3EJE.js.map} +1 -1
  37. package/dist/{chunk-IUK7OJXZ.js → chunk-OBSZ4NE2.js} +5 -4
  38. package/dist/chunk-OBSZ4NE2.js.map +1 -0
  39. package/dist/{chunk-DJ72KP32.js → chunk-OXR7BXZA.js} +3 -3
  40. package/dist/{chunk-DJ72KP32.js.map → chunk-OXR7BXZA.js.map} +1 -1
  41. package/dist/{chunk-LIZWCWED.js → chunk-PQZSTI3R.js} +3 -3
  42. package/dist/{chunk-LIZWCWED.js.map → chunk-PQZSTI3R.js.map} +1 -1
  43. package/dist/{chunk-LKFHUDEW.js → chunk-QVOBLRCM.js} +3 -3
  44. package/dist/{chunk-LKFHUDEW.js.map → chunk-QVOBLRCM.js.map} +1 -1
  45. package/dist/{chunk-E52Z2FKU.js → chunk-S5CQRCTF.js} +5 -5
  46. package/dist/{chunk-E52Z2FKU.js.map → chunk-S5CQRCTF.js.map} +1 -1
  47. package/dist/{chunk-SCXXJDKQ.js → chunk-SP6LCCTZ.js} +21 -28
  48. package/dist/chunk-SP6LCCTZ.js.map +1 -0
  49. package/dist/{chunk-BGDVUC3B.js → chunk-TUP7WXQE.js} +3 -3
  50. package/dist/{chunk-BGDVUC3B.js.map → chunk-TUP7WXQE.js.map} +1 -1
  51. package/dist/{chunk-4D2V4JE4.js → chunk-V2QZG4IT.js} +4 -4
  52. package/dist/{chunk-4D2V4JE4.js.map → chunk-V2QZG4IT.js.map} +1 -1
  53. package/dist/{chunk-D2QIPQ74.js → chunk-W3XX7BYT.js} +2 -2
  54. package/dist/chunk-W3XX7BYT.js.map +1 -0
  55. package/dist/{chunk-F374BNL4.js → chunk-YVTM2KRR.js} +12 -8
  56. package/dist/chunk-YVTM2KRR.js.map +1 -0
  57. package/dist/colors.css +328 -0
  58. package/dist/components/action-icon/action-icon.d.ts +6 -5
  59. package/dist/components/action-icon/action-icon.d.ts.map +1 -1
  60. package/dist/components/action-icon/index.js +3 -2
  61. package/dist/components/alert/index.js +3 -3
  62. package/dist/components/ambient-background/index.js +1 -1
  63. package/dist/components/app-shell/index.js +6 -5
  64. package/dist/components/app-shell/index.js.map +1 -1
  65. package/dist/components/avatar/index.js +2 -2
  66. package/dist/components/badge/badge.d.ts +1 -1
  67. package/dist/components/badge/badge.d.ts.map +1 -1
  68. package/dist/components/badge/index.js +2 -1
  69. package/dist/components/button/button.d.ts +11 -9
  70. package/dist/components/button/button.d.ts.map +1 -1
  71. package/dist/components/button/index.js +3 -2
  72. package/dist/components/button-multi-select/index.js +4 -3
  73. package/dist/components/button-multi-select/index.js.map +1 -1
  74. package/dist/components/button-select/index.js +4 -3
  75. package/dist/components/button-select/index.js.map +1 -1
  76. package/dist/components/calendar/index.js +6 -5
  77. package/dist/components/calendar-heatmap/index.js +2 -2
  78. package/dist/components/camera/index.js +8 -7
  79. package/dist/components/carousel/index.js +2 -2
  80. package/dist/components/clipboard/index.js +3 -2
  81. package/dist/components/clipboard/index.js.map +1 -1
  82. package/dist/components/code-block/index.js +1 -1
  83. package/dist/components/code-block/static.js.map +1 -1
  84. package/dist/components/compare/index.js +2 -2
  85. package/dist/components/data-table/index.js +16 -15
  86. package/dist/components/data-table/index.js.map +1 -1
  87. package/dist/components/date-picker/index.js +11 -10
  88. package/dist/components/date-picker/index.js.map +1 -1
  89. package/dist/components/download-button/index.js +4 -3
  90. package/dist/components/drawer/index.js +6 -5
  91. package/dist/components/file-item/index.js +7 -6
  92. package/dist/components/file-preview/index.js +7 -6
  93. package/dist/components/file-preview/index.js.map +1 -1
  94. package/dist/components/file-trigger/index.js +4 -3
  95. package/dist/components/file-upload/index.js +7 -6
  96. package/dist/components/file-upload/index.js.map +1 -1
  97. package/dist/components/gallery/index.js +2 -2
  98. package/dist/components/image-cropper/index.js +7 -6
  99. package/dist/components/indicator/index.js +1 -1
  100. package/dist/components/kbd/index.js +3 -3
  101. package/dist/components/lightbox/index.js +9 -8
  102. package/dist/components/lightbox/index.js.map +1 -1
  103. package/dist/components/menu/index.js +2 -2
  104. package/dist/components/modal/index.js +6 -5
  105. package/dist/components/multi-select/index.js +3 -3
  106. package/dist/components/notification/index.js +3 -3
  107. package/dist/components/overlays/index.js +8 -7
  108. package/dist/components/overlays/index.js.map +1 -1
  109. package/dist/components/password-input/index.js +1 -1
  110. package/dist/components/phone-input/flag.d.ts +9 -0
  111. package/dist/components/phone-input/flag.d.ts.map +1 -0
  112. package/dist/components/phone-input/index.d.ts +4 -0
  113. package/dist/components/phone-input/index.d.ts.map +1 -0
  114. package/dist/components/phone-input/index.js +503 -0
  115. package/dist/components/phone-input/index.js.map +1 -0
  116. package/dist/components/phone-input/phone-input.d.ts +125 -0
  117. package/dist/components/phone-input/phone-input.d.ts.map +1 -0
  118. package/dist/components/phone-input/phone.d.ts +117 -0
  119. package/dist/components/phone-input/phone.d.ts.map +1 -0
  120. package/dist/components/photo-capture/index.js +11 -10
  121. package/dist/components/photo-capture/index.js.map +1 -1
  122. package/dist/components/pills-input/index.js +3 -3
  123. package/dist/components/schedule/index.js +7 -6
  124. package/dist/components/schedule/index.js.map +1 -1
  125. package/dist/components/segment-group/index.js +3 -3
  126. package/dist/components/spinner/index.js +1 -1
  127. package/dist/components/spinner/spinner.d.ts +1 -1
  128. package/dist/components/spinner/spinner.d.ts.map +1 -1
  129. package/dist/components/spotlight/index.js +8 -7
  130. package/dist/components/spotlight/index.js.map +1 -1
  131. package/dist/components/tabs/index.js +3 -3
  132. package/dist/components/tags-input/index.js +3 -3
  133. package/dist/components/theme-icon/index.js +1 -1
  134. package/dist/components/theme-icon/theme-icon.d.ts.map +1 -1
  135. package/dist/components/time-input/index.js +4 -4
  136. package/dist/components/timeline/index.d.ts +1 -1
  137. package/dist/components/timeline/index.d.ts.map +1 -1
  138. package/dist/components/timeline/index.js +40 -11
  139. package/dist/components/timeline/index.js.map +1 -1
  140. package/dist/components/timeline/timeline.d.ts +8 -3
  141. package/dist/components/timeline/timeline.d.ts.map +1 -1
  142. package/dist/components/tree-multi-select/index.js +3 -3
  143. package/dist/index.js +4 -4
  144. package/dist/lib/button-colors.d.ts +25 -0
  145. package/dist/lib/button-colors.d.ts.map +1 -0
  146. package/dist/lib/dev-warn.d.ts +1 -0
  147. package/dist/lib/dev-warn.d.ts.map +1 -1
  148. package/dist/lib/intl.d.ts +5 -0
  149. package/dist/lib/intl.d.ts.map +1 -1
  150. package/package.json +3 -1
  151. package/src/as-child.contract.test.tsx +2 -0
  152. package/src/colors.css +328 -0
  153. package/src/components/action-icon/action-icon.test.tsx +22 -0
  154. package/src/components/action-icon/action-icon.tsx +24 -28
  155. package/src/components/badge/badge.test.tsx +53 -10
  156. package/src/components/badge/badge.tsx +64 -11
  157. package/src/components/button/button.test.tsx +41 -5
  158. package/src/components/button/button.tsx +28 -33
  159. package/src/components/phone-input/flag.tsx +86 -0
  160. package/src/components/phone-input/index.ts +14 -0
  161. package/src/components/phone-input/phone-input.test.tsx +285 -0
  162. package/src/components/phone-input/phone-input.tsx +527 -0
  163. package/src/components/phone-input/phone.test.ts +187 -0
  164. package/src/components/phone-input/phone.ts +298 -0
  165. package/src/components/spinner/spinner.tsx +3 -3
  166. package/src/components/theme-icon/theme-icon.test.tsx +7 -0
  167. package/src/components/theme-icon/theme-icon.tsx +10 -6
  168. package/src/components/timeline/index.ts +1 -0
  169. package/src/components/timeline/timeline.test.tsx +105 -4
  170. package/src/components/timeline/timeline.tsx +46 -11
  171. package/src/lib/button-colors.ts +55 -0
  172. package/src/lib/dev-warn.ts +1 -1
  173. package/src/lib/intl-direction.test.tsx +23 -0
  174. package/src/lib/intl.tsx +8 -2
  175. package/dist/chunk-BMEJBY6H.js.map +0 -1
  176. package/dist/chunk-D2QIPQ74.js.map +0 -1
  177. package/dist/chunk-F374BNL4.js.map +0 -1
  178. package/dist/chunk-IUK7OJXZ.js.map +0 -1
  179. package/dist/chunk-SCXXJDKQ.js.map +0 -1
  180. package/dist/chunk-ZVECQBGG.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/modal/modal.tsx"],"names":["Ark"],"mappings":";;;;;;;;;;;;AA2CA,IAAM,gBAAgB,GAAA,CAAI;AAAA,EACxB,8HAAA;AAAA,EACA;AACF,CAAC,CAAA;AAED,IAAM,eAAA,GAAkB,GAAA;AAAA,EACtB,gHAAA;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,QAAA,EAAU;AAAA,QACR,MAAA,EAAQ,gBAAA;AAAA,QACR,GAAA,EAAK,wBAAA;AAAA,QACL,MAAA,EAAQ;AAAA;AACV,KACF;AAAA,IACA,eAAA,EAAiB,EAAE,QAAA,EAAU,QAAA;AAAS;AAE1C,CAAA;AAEA,IAAM,YAAA,GAAe,GAAA;AAAA,EACnB;AAAA,IACE,+BAAA;AA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YAAA;AAAA,EACT,OAAA,EAAS,YAAA;AAAA,EACT,QAAA,EAAU,aAAA;AAAA,EACV,UAAA,EAAY,eAAA;AAAA,EACZ,OAAA,EAAS,YAAA;AAAA,EACT,KAAA,EAAO,UAAA;AAAA,EACP,WAAA,EAAa,gBAAA;AAAA,EACb,YAAA,EAAc,iBAAA;AAAA,EACd,MAAA,EAAQ,WAAA;AAAA,EACR,IAAA,EAAM,SAAA;AAAA,EACN,MAAA,EAAQ;AACV,CAAC","file":"chunk-MCRTAUSZ.js","sourcesContent":["\"use client\"\n\nimport { Dialog as Ark } from \"@ark-ui/react/dialog\"\nimport { Portal } from \"@ark-ui/react/portal\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { type ComponentPropsWithoutRef, type ReactNode, useRef } from \"react\"\nimport type { NoAsChild } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { OverlayContainerProvider } from \"../../lib/overlay-container\"\nimport { NestedLayer, useLayerGuard } from \"../../lib/overlay-layer\"\nimport { props } from \"../../lib/props\"\nimport type { Size } from \"../../lib/sizes\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES } from \"../../lib/typography-size\"\nimport {\n createDialogParts,\n DIALOG_PADDING,\n type DialogCloseTriggerProps,\n type DialogIconSlot,\n type DialogIcons,\n DialogRootProviders,\n type DialogSectionProps,\n useDialogNameCheck,\n} from \"../overlays/dialog-parts\"\n\n/**\n * Modal — centered overlay dialog on top of Ark UI's Dialog state machine.\n * Ark owns focus-trap, scroll-lock, RTL, the `Esc` / click-outside behaviour\n * and the `data-state=\"open|closed\"` attribute that drives our enter/exit\n * animations (keyframes live in `theme.css`). This wrapper provides the styled\n * parts and a flatter props API.\n *\n * - High-level form: `<Modal open title size … >children</Modal>` renders the\n * full Portal → Backdrop → Positioner → Content → Header + Body scaffold.\n * This is what the imperative overlays manager mounts.\n * - Low-level parts (`Modal.Root`, `Modal.Content`, `Modal.Title`, …) are\n * exposed for full control / trigger-based composition.\n *\n * Surface padding flows through the `--modal-px` CSS var set on the content, so\n * `Modal.Header` / `Modal.Body` / `Modal.Footer` stay in rhythm without prop\n * plumbing — and keep a sensible fallback when used standalone.\n */\n\nconst modalBackdrop = cva([\n \"fixed inset-0 z-[calc(var(--modal-z,150)+var(--layer-index,0))] bg-black/50 backdrop-blur-lg pointer-events-auto select-none\",\n \"data-[state=open]:animate-fade-in data-[state=closed]:animate-fade-out\",\n])\n\nconst modalPositioner = cva(\n \"fixed inset-0 z-[calc(var(--modal-z,150)+var(--layer-index,0))] flex flex-col items-center overflow-y-auto p-4\",\n {\n variants: {\n position: {\n center: \"justify-center\",\n top: \"justify-start mt-[8vh]\",\n bottom: \"justify-end mb-[8vh]\",\n },\n },\n defaultVariants: { position: \"center\" },\n },\n)\n\nconst modalContent = cva(\n [\n \"relative flex w-full flex-col\",\n \"max-h-[calc(100dvh-2rem)]\",\n \"bg-brand-50 text-brand-950 border border-brand-900/20 shadow-2xl\",\n \"dark:bg-brand-950 dark:text-white dark:border-white/15\",\n \"focus:outline-none\",\n \"data-[state=open]:animate-modal-in data-[state=closed]:animate-modal-out\",\n ],\n {\n variants: {\n size: {\n xs: \"max-w-(--width-xs)\", // 24rem\n sm: \"max-w-(--width-sm)\", // 30rem\n md: \"max-w-(--width-md)\", // 35rem\n lg: \"max-w-(--width-lg)\", // 40rem\n xl: \"max-w-(--width-xl)\", // 48rem\n full: \"max-w-[calc(100vw-2rem)] min-h-[calc(100dvh-2rem)]\",\n },\n radius: {\n none: \"rounded-none\",\n sm: \"rounded-sm\",\n md: \"rounded-md\",\n lg: \"rounded-xl\",\n xl: \"rounded-2xl\",\n },\n },\n defaultVariants: { size: \"md\", radius: \"sm\" },\n },\n)\n\n// ---------------------------------------------------------------------------\n// Low-level parts (styled Ark parts + kit conveniences)\n// ---------------------------------------------------------------------------\n\nexport type ModalIconSlot = DialogIconSlot\nexport type ModalIcons = DialogIcons\n\nexport type ModalRootProps = ComponentPropsWithoutRef<typeof Ark.Root> & {\n /** Replaces the default icons: `close`. `Modal.CloseTrigger`'s `children` win over it. */\n icons?: ModalIcons\n}\n\n/** Ark's root, plus the nested-layer guard: while a picker opened inside the\n * dialog is open, an outside click closes the picker only, not the dialog\n * under it. It is also a layer of its own while open, so a hotkey on the page\n * (or in an enclosing overlay) yields to it. See `lib/overlay-layer.tsx`. */\nconst ModalRoot = ({ onPointerDownOutside, icons, children, ...rest }: ModalRootProps) => {\n const guard = useLayerGuard(onPointerDownOutside)\n return (\n <Ark.Root onPointerDownOutside={guard.onPointerDownOutside} {...rest}>\n {/* A layer itself, registered with whatever it opened from (the page,\n or an enclosing overlay), so what's under it knows it's covered. */}\n <Ark.Context>{(api) => <NestedLayer open={api.open} modal />}</Ark.Context>\n <DialogRootProviders icons={icons} layers={guard.layers}>\n {children}\n </DialogRootProviders>\n </Ark.Root>\n )\n}\nconst ModalTrigger = Ark.Trigger\nconst ModalContext = Ark.Context\n\nexport type ModalBackdropProps = ComponentPropsWithoutRef<typeof Ark.Backdrop> & WithTestId\n\nconst ModalBackdrop = ({ className, testId, ...rest }: ModalBackdropProps) => (\n <Ark.Backdrop\n className={cn(modalBackdrop(), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\nexport type ModalPosition = VariantProps<typeof modalPositioner>[\"position\"]\nexport type ModalPositionerProps = NoAsChild<ComponentPropsWithoutRef<typeof Ark.Positioner>> &\n WithTestId & {\n position?: ModalPosition\n }\n\nconst ModalPositioner = ({\n className,\n position,\n testId,\n children,\n asChild: _asChild,\n ...rest\n}: ModalPositionerProps) => {\n // A ref, not state: overlays read it when they portal, so nothing has to\n // re-render once it attaches (see `lib/overlay-container.tsx`).\n const positioner = useRef<HTMLDivElement>(null)\n return (\n <Ark.Positioner\n ref={positioner}\n className={cn(modalPositioner({ position }), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n <OverlayContainerProvider value={positioner}>{children}</OverlayContainerProvider>\n </Ark.Positioner>\n )\n}\n\nexport type ModalContentProps = ComponentPropsWithoutRef<typeof Ark.Content> &\n VariantProps<typeof modalContent> &\n WithTestId\n\nconst ModalContent = ({ className, size, radius, testId, ...rest }: ModalContentProps) => {\n const nameCheck = useDialogNameCheck(\"Modal\")\n return (\n <Ark.Content\n ref={nameCheck}\n className={cn(modalContent({ size, radius }), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n )\n}\n\nexport type ModalTitleProps = ComponentPropsWithoutRef<typeof Ark.Title> & WithTestId\n\nconst ModalTitle = ({ className, testId, ...rest }: ModalTitleProps) => (\n <Ark.Title\n className={cn(\"text-xl font-semibold leading-tight\", className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\nexport type ModalDescriptionProps = ComponentPropsWithoutRef<typeof Ark.Description> & WithTestId\n\nconst ModalDescription = ({ className, testId, ...rest }: ModalDescriptionProps) => (\n <Ark.Description\n className={cn(\"text-sm\", TEXT_COLOR_CLASSES.muted, className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\nexport type ModalCloseTriggerProps = DialogCloseTriggerProps\nexport type ModalHeaderProps = DialogSectionProps\nexport type ModalBodyProps = DialogSectionProps\nexport type ModalFooterProps = DialogSectionProps\n\nconst {\n CloseTrigger: ModalCloseTrigger,\n Header: ModalHeader,\n Body: ModalBody,\n Footer: ModalFooter,\n} = createDialogParts(\"modal\", Ark.CloseTrigger)\n\n// ---------------------------------------------------------------------------\n// High-level props-driven Modal\n// ---------------------------------------------------------------------------\n\ntype ArkRootProps = ComponentPropsWithoutRef<typeof Ark.Root>\n\nexport type ModalSize = NonNullable<VariantProps<typeof modalContent>[\"size\"]>\nexport type ModalRadius = NonNullable<VariantProps<typeof modalContent>[\"radius\"]>\n\nexport type ModalClassNames = Partial<\n Record<\n | \"backdrop\"\n | \"positioner\"\n | \"content\"\n | \"header\"\n | \"title\"\n | \"description\"\n | \"body\"\n | \"closeButton\",\n string\n >\n>\n\nexport type ModalProps = Omit<\n ArkRootProps,\n \"open\" | \"defaultOpen\" | \"onOpenChange\" | \"children\" | \"role\"\n> &\n WithTestId & {\n /** Controlled open state. */\n open?: boolean\n /** Uncontrolled initial open state. */\n defaultOpen?: boolean\n /** Fires with the next open state. Flattened from Ark's `{ open }`. */\n onOpenChange?: (open: boolean) => void\n /** Header title; renders the header when set, and names the dialog. */\n title?: ReactNode\n /** Id of an element inside the modal that names it, when there is no `title`. For a\n * plain string, use `aria-label`. */\n \"aria-labelledby\"?: string\n /** Optional subtitle under the title. */\n description?: ReactNode\n size?: ModalSize\n radius?: ModalRadius\n /** Vertically center the modal (vs. anchored near the top). */\n position?: ModalPosition\n /** Render the default close button in the header. @default true */\n withCloseButton?: boolean\n /**\n * Render the dimming backdrop. Set `false` when an ancestor (e.g. the modals\n * manager) draws a single shared backdrop for the whole overlay stack.\n * @default true\n */\n withBackdrop?: boolean\n /** Inner padding token; sets `--modal-px`. @default \"md\" */\n padding?: Size\n closeOnEscape?: boolean\n closeOnInteractOutside?: boolean\n /** Use `alertdialog` semantics (confirm flows). @default \"dialog\" */\n role?: \"dialog\" | \"alertdialog\"\n /** Fires after the exit animation completes; the manager unmounts on this. */\n onExitComplete?: () => void\n /** Fires on close (any source) */\n onClose?: () => void\n /** Portal target. Defaults to `document.body`. */\n container?: HTMLElement | null\n children?: ReactNode\n className?: string\n classNames?: ModalClassNames\n /** Overrides the default close button's accessible name (`closeTriggerLabel`, default\n * `\"Close\"`). The compound `ModalCloseTrigger` part takes a plain `aria-label` instead. */\n translations?: ModalTranslations\n /** Replaces the default icons: `close`, the header's close button. */\n icons?: ModalIcons\n }\n\n/** The ready-made modal's wording — `closeTriggerLabel` follows Ark's naming for the\n * same control. */\nexport type ModalTranslations = { closeTriggerLabel?: string }\n\nconst ModalComponent = ({\n open,\n defaultOpen,\n onOpenChange,\n onClose,\n title,\n description,\n \"aria-labelledby\": ariaLabelledby,\n size,\n radius,\n position,\n withCloseButton = true,\n withBackdrop = true,\n padding = \"md\",\n closeOnEscape,\n closeOnInteractOutside,\n role,\n onExitComplete,\n container,\n children,\n className,\n classNames,\n testId,\n translations,\n icons,\n ...rest\n}: ModalProps) => {\n const hasHeader = title != null || description != null || withCloseButton\n\n return (\n <ModalRoot\n open={open}\n defaultOpen={defaultOpen}\n onOpenChange={({ open: next }) => {\n onOpenChange?.(next)\n if (!next) onClose?.()\n }}\n closeOnEscape={closeOnEscape}\n // Decoupled from `modal` on purpose: Ark's dialog derives this default\n // from `modal` (`modal && !alertdialog`), so when the overlays manager\n // draws its own shared backdrop and passes `withBackdrop={false}` —\n // forcing `modal={false}` below — outside-click would silently stop\n // dismissing. Default to Ark's intended behaviour instead: dismiss for\n // regular dialogs, keep `alertdialog`s sticky (explicit choice required).\n closeOnInteractOutside={closeOnInteractOutside ?? role !== \"alertdialog\"}\n role={role}\n // Unmount the whole content tree (incl. the `fixed inset-0` positioner)\n // on close — otherwise the positioner lingers as a transparent overlay\n // that swallows page clicks. `lazyMount` keeps it out of the DOM until\n // first open. Both flow to the parts' presence via Ark's Root context.\n lazyMount\n unmountOnExit\n modal={withBackdrop}\n onExitComplete={onExitComplete}\n icons={icons}\n {...rest}\n >\n <Portal container={container ? { current: container } : undefined}>\n {withBackdrop && <ModalBackdrop className={classNames?.backdrop} />}\n <ModalPositioner\n position={position}\n className={cn(\"overflow-clip\", classNames?.positioner)}\n >\n <ModalContent\n size={size}\n radius={radius}\n style={{ [\"--modal-px\" as string]: DIALOG_PADDING[padding] }}\n className={cn(className, classNames?.content)}\n testId={testId}\n aria-labelledby={ariaLabelledby}\n >\n {hasHeader && (\n <ModalHeader className={classNames?.header}>\n <div className=\"flex flex-col gap-1\">\n {title != null && <ModalTitle className={classNames?.title}>{title}</ModalTitle>}\n {description != null && (\n <ModalDescription className={classNames?.description}>\n {description}\n </ModalDescription>\n )}\n </div>\n {withCloseButton && (\n <ModalCloseTrigger\n aria-label={translations?.closeTriggerLabel}\n className={classNames?.closeButton}\n />\n )}\n </ModalHeader>\n )}\n <ModalBody\n className={cn(\n !hasHeader && \"pt-(--modal-px,1.25rem)\",\n \"pb-(--modal-px,1.25rem)\",\n classNames?.body,\n )}\n >\n {children}\n </ModalBody>\n </ModalContent>\n </ModalPositioner>\n </Portal>\n </ModalRoot>\n )\n}\n\nexport const Modal = Object.assign(ModalComponent, {\n Root: ModalRoot,\n Trigger: ModalTrigger,\n Context: ModalContext,\n Backdrop: ModalBackdrop,\n Positioner: ModalPositioner,\n Content: ModalContent,\n Title: ModalTitle,\n Description: ModalDescription,\n CloseTrigger: ModalCloseTrigger,\n Header: ModalHeader,\n Body: ModalBody,\n Footer: ModalFooter,\n})\n"]}
1
+ {"version":3,"sources":["../src/components/modal/modal.tsx"],"names":["Ark"],"mappings":";;;;;;;;;;;;AA2CA,IAAM,gBAAgB,GAAA,CAAI;AAAA,EACxB,8HAAA;AAAA,EACA;AACF,CAAC,CAAA;AAED,IAAM,eAAA,GAAkB,GAAA;AAAA,EACtB,gHAAA;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,QAAA,EAAU;AAAA,QACR,MAAA,EAAQ,gBAAA;AAAA,QACR,GAAA,EAAK,wBAAA;AAAA,QACL,MAAA,EAAQ;AAAA;AACV,KACF;AAAA,IACA,eAAA,EAAiB,EAAE,QAAA,EAAU,QAAA;AAAS;AAE1C,CAAA;AAEA,IAAM,YAAA,GAAe,GAAA;AAAA,EACnB;AAAA,IACE,+BAAA;AAAA,IACA,2BAAA;AAAA,IACA,kEAAA;AAAA,IACA,wDAAA;AAAA,IACA,oBAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,IAAA,EAAM;AAAA,QACJ,EAAA,EAAI,oBAAA;AAAA;AAAA,QACJ,EAAA,EAAI,oBAAA;AAAA;AAAA,QACJ,EAAA,EAAI,oBAAA;AAAA;AAAA,QACJ,EAAA,EAAI,oBAAA;AAAA;AAAA,QACJ,EAAA,EAAI,oBAAA;AAAA;AAAA,QACJ,IAAA,EAAM;A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ark } from \"@ark-ui/react/dialog\"\nimport { Portal } from \"@ark-ui/react/portal\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { type ComponentPropsWithoutRef, type ReactNode, useRef } from \"react\"\nimport type { NoAsChild } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { OverlayContainerProvider } from \"../../lib/overlay-container\"\nimport { NestedLayer, useLayerGuard } from \"../../lib/overlay-layer\"\nimport { props } from \"../../lib/props\"\nimport type { Size } from \"../../lib/sizes\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES } from \"../../lib/typography-size\"\nimport {\n createDialogParts,\n DIALOG_PADDING,\n type DialogCloseTriggerProps,\n type DialogIconSlot,\n type DialogIcons,\n DialogRootProviders,\n type DialogSectionProps,\n useDialogNameCheck,\n} from \"../overlays/dialog-parts\"\n\n/**\n * Modal — centered overlay dialog on top of Ark UI's Dialog state machine.\n * Ark owns focus-trap, scroll-lock, RTL, the `Esc` / click-outside behaviour\n * and the `data-state=\"open|closed\"` attribute that drives our enter/exit\n * animations (keyframes live in `theme.css`). This wrapper provides the styled\n * parts and a flatter props API.\n *\n * - High-level form: `<Modal open title size … >children</Modal>` renders the\n * full Portal → Backdrop → Positioner → Content → Header + Body scaffold.\n * This is what the imperative overlays manager mounts.\n * - Low-level parts (`Modal.Root`, `Modal.Content`, `Modal.Title`, …) are\n * exposed for full control / trigger-based composition.\n *\n * Surface padding flows through the `--modal-px` CSS var set on the content, so\n * `Modal.Header` / `Modal.Body` / `Modal.Footer` stay in rhythm without prop\n * plumbing — and keep a sensible fallback when used standalone.\n */\n\nconst modalBackdrop = cva([\n \"fixed inset-0 z-[calc(var(--modal-z,150)+var(--layer-index,0))] bg-black/50 backdrop-blur-lg pointer-events-auto select-none\",\n \"data-[state=open]:animate-fade-in data-[state=closed]:animate-fade-out\",\n])\n\nconst modalPositioner = cva(\n \"fixed inset-0 z-[calc(var(--modal-z,150)+var(--layer-index,0))] flex flex-col items-center overflow-y-auto p-4\",\n {\n variants: {\n position: {\n center: \"justify-center\",\n top: \"justify-start mt-[8vh]\",\n bottom: \"justify-end mb-[8vh]\",\n },\n },\n defaultVariants: { position: \"center\" },\n },\n)\n\nconst modalContent = cva(\n [\n \"relative flex w-full flex-col\",\n \"max-h-[calc(100dvh-2rem)]\",\n \"bg-brand-50 text-brand-950 border border-brand-900/20 shadow-2xl\",\n \"dark:bg-brand-950 dark:text-white dark:border-white/15\",\n \"focus:outline-none\",\n \"data-[state=open]:animate-modal-in data-[state=closed]:animate-modal-out\",\n ],\n {\n variants: {\n size: {\n xs: \"max-w-(--width-xs)\", // 24rem\n sm: \"max-w-(--width-sm)\", // 30rem\n md: \"max-w-(--width-md)\", // 35rem\n lg: \"max-w-(--width-lg)\", // 40rem\n xl: \"max-w-(--width-xl)\", // 48rem\n full: \"max-w-[calc(100vw-2rem)] min-h-[calc(100dvh-2rem)]\",\n },\n radius: {\n none: \"rounded-none\",\n sm: \"rounded-sm\",\n md: \"rounded-md\",\n lg: \"rounded-xl\",\n xl: \"rounded-2xl\",\n },\n },\n defaultVariants: { size: \"md\", radius: \"sm\" },\n },\n)\n\n// ---------------------------------------------------------------------------\n// Low-level parts (styled Ark parts + kit conveniences)\n// ---------------------------------------------------------------------------\n\nexport type ModalIconSlot = DialogIconSlot\nexport type ModalIcons = DialogIcons\n\nexport type ModalRootProps = ComponentPropsWithoutRef<typeof Ark.Root> & {\n /** Replaces the default icons: `close`. `Modal.CloseTrigger`'s `children` win over it. */\n icons?: ModalIcons\n}\n\n/** Ark's root, plus the nested-layer guard: while a picker opened inside the\n * dialog is open, an outside click closes the picker only, not the dialog\n * under it. It is also a layer of its own while open, so a hotkey on the page\n * (or in an enclosing overlay) yields to it. See `lib/overlay-layer.tsx`. */\nconst ModalRoot = ({ onPointerDownOutside, icons, children, ...rest }: ModalRootProps) => {\n const guard = useLayerGuard(onPointerDownOutside)\n return (\n <Ark.Root onPointerDownOutside={guard.onPointerDownOutside} {...rest}>\n {/* A layer itself, registered with whatever it opened from (the page,\n or an enclosing overlay), so what's under it knows it's covered. */}\n <Ark.Context>{(api) => <NestedLayer open={api.open} modal />}</Ark.Context>\n <DialogRootProviders icons={icons} layers={guard.layers}>\n {children}\n </DialogRootProviders>\n </Ark.Root>\n )\n}\nconst ModalTrigger = Ark.Trigger\nconst ModalContext = Ark.Context\n\nexport type ModalBackdropProps = ComponentPropsWithoutRef<typeof Ark.Backdrop> & WithTestId\n\nconst ModalBackdrop = ({ className, testId, ...rest }: ModalBackdropProps) => (\n <Ark.Backdrop\n className={cn(modalBackdrop(), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\nexport type ModalPosition = VariantProps<typeof modalPositioner>[\"position\"]\nexport type ModalPositionerProps = NoAsChild<ComponentPropsWithoutRef<typeof Ark.Positioner>> &\n WithTestId & {\n position?: ModalPosition\n }\n\nconst ModalPositioner = ({\n className,\n position,\n testId,\n children,\n asChild: _asChild,\n ...rest\n}: ModalPositionerProps) => {\n // A ref, not state: overlays read it when they portal, so nothing has to\n // re-render once it attaches (see `lib/overlay-container.tsx`).\n const positioner = useRef<HTMLDivElement>(null)\n return (\n <Ark.Positioner\n ref={positioner}\n className={cn(modalPositioner({ position }), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n <OverlayContainerProvider value={positioner}>{children}</OverlayContainerProvider>\n </Ark.Positioner>\n )\n}\n\nexport type ModalContentProps = ComponentPropsWithoutRef<typeof Ark.Content> &\n VariantProps<typeof modalContent> &\n WithTestId\n\nconst ModalContent = ({ className, size, radius, testId, ...rest }: ModalContentProps) => {\n const nameCheck = useDialogNameCheck(\"Modal\")\n return (\n <Ark.Content\n ref={nameCheck}\n className={cn(modalContent({ size, radius }), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n )\n}\n\nexport type ModalTitleProps = ComponentPropsWithoutRef<typeof Ark.Title> & WithTestId\n\nconst ModalTitle = ({ className, testId, ...rest }: ModalTitleProps) => (\n <Ark.Title\n className={cn(\"text-xl font-semibold leading-tight\", className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\nexport type ModalDescriptionProps = ComponentPropsWithoutRef<typeof Ark.Description> & WithTestId\n\nconst ModalDescription = ({ className, testId, ...rest }: ModalDescriptionProps) => (\n <Ark.Description\n className={cn(\"text-sm\", TEXT_COLOR_CLASSES.muted, className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\nexport type ModalCloseTriggerProps = DialogCloseTriggerProps\nexport type ModalHeaderProps = DialogSectionProps\nexport type ModalBodyProps = DialogSectionProps\nexport type ModalFooterProps = DialogSectionProps\n\nconst {\n CloseTrigger: ModalCloseTrigger,\n Header: ModalHeader,\n Body: ModalBody,\n Footer: ModalFooter,\n} = createDialogParts(\"modal\", Ark.CloseTrigger)\n\n// ---------------------------------------------------------------------------\n// High-level props-driven Modal\n// ---------------------------------------------------------------------------\n\ntype ArkRootProps = ComponentPropsWithoutRef<typeof Ark.Root>\n\nexport type ModalSize = NonNullable<VariantProps<typeof modalContent>[\"size\"]>\nexport type ModalRadius = NonNullable<VariantProps<typeof modalContent>[\"radius\"]>\n\nexport type ModalClassNames = Partial<\n Record<\n | \"backdrop\"\n | \"positioner\"\n | \"content\"\n | \"header\"\n | \"title\"\n | \"description\"\n | \"body\"\n | \"closeButton\",\n string\n >\n>\n\nexport type ModalProps = Omit<\n ArkRootProps,\n \"open\" | \"defaultOpen\" | \"onOpenChange\" | \"children\" | \"role\"\n> &\n WithTestId & {\n /** Controlled open state. */\n open?: boolean\n /** Uncontrolled initial open state. */\n defaultOpen?: boolean\n /** Fires with the next open state. Flattened from Ark's `{ open }`. */\n onOpenChange?: (open: boolean) => void\n /** Header title; renders the header when set, and names the dialog. */\n title?: ReactNode\n /** Id of an element inside the modal that names it, when there is no `title`. For a\n * plain string, use `aria-label`. */\n \"aria-labelledby\"?: string\n /** Optional subtitle under the title. */\n description?: ReactNode\n size?: ModalSize\n radius?: ModalRadius\n /** Vertically center the modal (vs. anchored near the top). */\n position?: ModalPosition\n /** Render the default close button in the header. @default true */\n withCloseButton?: boolean\n /**\n * Render the dimming backdrop. Set `false` when an ancestor (e.g. the modals\n * manager) draws a single shared backdrop for the whole overlay stack.\n * @default true\n */\n withBackdrop?: boolean\n /** Inner padding token; sets `--modal-px`. @default \"md\" */\n padding?: Size\n closeOnEscape?: boolean\n closeOnInteractOutside?: boolean\n /** Use `alertdialog` semantics (confirm flows). @default \"dialog\" */\n role?: \"dialog\" | \"alertdialog\"\n /** Fires after the exit animation completes; the manager unmounts on this. */\n onExitComplete?: () => void\n /** Fires on close (any source) */\n onClose?: () => void\n /** Portal target. Defaults to `document.body`. */\n container?: HTMLElement | null\n children?: ReactNode\n className?: string\n classNames?: ModalClassNames\n /** Overrides the default close button's accessible name (`closeTriggerLabel`, default\n * `\"Close\"`). The compound `ModalCloseTrigger` part takes a plain `aria-label` instead. */\n translations?: ModalTranslations\n /** Replaces the default icons: `close`, the header's close button. */\n icons?: ModalIcons\n }\n\n/** The ready-made modal's wording — `closeTriggerLabel` follows Ark's naming for the\n * same control. */\nexport type ModalTranslations = { closeTriggerLabel?: string }\n\nconst ModalComponent = ({\n open,\n defaultOpen,\n onOpenChange,\n onClose,\n title,\n description,\n \"aria-labelledby\": ariaLabelledby,\n size,\n radius,\n position,\n withCloseButton = true,\n withBackdrop = true,\n padding = \"md\",\n closeOnEscape,\n closeOnInteractOutside,\n role,\n onExitComplete,\n container,\n children,\n className,\n classNames,\n testId,\n translations,\n icons,\n ...rest\n}: ModalProps) => {\n const hasHeader = title != null || description != null || withCloseButton\n\n return (\n <ModalRoot\n open={open}\n defaultOpen={defaultOpen}\n onOpenChange={({ open: next }) => {\n onOpenChange?.(next)\n if (!next) onClose?.()\n }}\n closeOnEscape={closeOnEscape}\n // Decoupled from `modal` on purpose: Ark's dialog derives this default\n // from `modal` (`modal && !alertdialog`), so when the overlays manager\n // draws its own shared backdrop and passes `withBackdrop={false}` —\n // forcing `modal={false}` below — outside-click would silently stop\n // dismissing. Default to Ark's intended behaviour instead: dismiss for\n // regular dialogs, keep `alertdialog`s sticky (explicit choice required).\n closeOnInteractOutside={closeOnInteractOutside ?? role !== \"alertdialog\"}\n role={role}\n // Unmount the whole content tree (incl. the `fixed inset-0` positioner)\n // on close — otherwise the positioner lingers as a transparent overlay\n // that swallows page clicks. `lazyMount` keeps it out of the DOM until\n // first open. Both flow to the parts' presence via Ark's Root context.\n lazyMount\n unmountOnExit\n modal={withBackdrop}\n onExitComplete={onExitComplete}\n icons={icons}\n {...rest}\n >\n <Portal container={container ? { current: container } : undefined}>\n {withBackdrop && <ModalBackdrop className={classNames?.backdrop} />}\n <ModalPositioner\n position={position}\n className={cn(\"overflow-clip\", classNames?.positioner)}\n >\n <ModalContent\n size={size}\n radius={radius}\n style={{ [\"--modal-px\" as string]: DIALOG_PADDING[padding] }}\n className={cn(className, classNames?.content)}\n testId={testId}\n aria-labelledby={ariaLabelledby}\n >\n {hasHeader && (\n <ModalHeader className={classNames?.header}>\n <div className=\"flex flex-col gap-1\">\n {title != null && <ModalTitle className={classNames?.title}>{title}</ModalTitle>}\n {description != null && (\n <ModalDescription className={classNames?.description}>\n {description}\n </ModalDescription>\n )}\n </div>\n {withCloseButton && (\n <ModalCloseTrigger\n aria-label={translations?.closeTriggerLabel}\n className={classNames?.closeButton}\n />\n )}\n </ModalHeader>\n )}\n <ModalBody\n className={cn(\n !hasHeader && \"pt-(--modal-px,1.25rem)\",\n \"pb-(--modal-px,1.25rem)\",\n classNames?.body,\n )}\n >\n {children}\n </ModalBody>\n </ModalContent>\n </ModalPositioner>\n </Portal>\n </ModalRoot>\n )\n}\n\nexport const Modal = Object.assign(ModalComponent, {\n Root: ModalRoot,\n Trigger: ModalTrigger,\n Context: ModalContext,\n Backdrop: ModalBackdrop,\n Positioner: ModalPositioner,\n Content: ModalContent,\n Title: ModalTitle,\n Description: ModalDescription,\n CloseTrigger: ModalCloseTrigger,\n Header: ModalHeader,\n Body: ModalBody,\n Footer: ModalFooter,\n})\n"]}
@@ -1,7 +1,7 @@
1
- import { Button } from './chunk-SCXXJDKQ.js';
1
+ import { Button } from './chunk-SP6LCCTZ.js';
2
2
  import { saveFile } from './chunk-EIBDLRAR.js';
3
3
  import { mergeIcons, iconStroke } from './chunk-XXOR34T4.js';
4
- import { Spinner } from './chunk-D2QIPQ74.js';
4
+ import { Spinner } from './chunk-W3XX7BYT.js';
5
5
  import { withAsChildContent } from './chunk-R5LYFTHA.js';
6
6
  import { props } from './chunk-WYCMIIRR.js';
7
7
  import { cn } from './chunk-4ASNIDV7.js';
@@ -136,5 +136,5 @@ var DownloadButton = ({
136
136
  };
137
137
 
138
138
  export { DOWNLOAD_BUTTON_DEFAULT_TRANSLATIONS, DownloadButton };
139
- //# sourceMappingURL=chunk-6IRMKF5T.js.map
140
- //# sourceMappingURL=chunk-6IRMKF5T.js.map
139
+ //# sourceMappingURL=chunk-B4GNSSHU.js.map
140
+ //# sourceMappingURL=chunk-B4GNSSHU.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/download-button/download-button.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAkEO,IAAM,oCAAA,GAA6E;AAAA,EACxF,KAAA,EAAO,UAAA;AAAA,EACP,OAAA,EAAS,0BAAA;AAAA,EACT,OAAO,CAAC,IAAA,KAAU,IAAA,GAAO,CAAA,EAAG,IAAI,CAAA,uBAAA,CAAA,GAA4B;AAC9D;AAIA,IAAM,aAAA,GAA2D;AAAA,EAC/D,QAAA,kBAAU,GAAA,CAAC,QAAA,EAAA,EAAS,SAAA,EAAW,UAAA,EAAY;AAC7C,CAAA;AAuBA,IAAM,YAAA,GACJ,2FAAA;AAGF,IAAM,OAAA,GAAU,CAAC,IAAA,EAAsB,MAAA,KAA+C;AACpF,EAAA,IAAI;AACF,IAAA,OAAO,QAAQ,OAAA,CAAQ,IAAA,CAAK,EAAE,MAAA,EAAQ,CAAC,CAAA;AAAA,EACzC,SAAS,KAAA,EAAO;AACd,IA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jF,QAAA,EAAA,OAAA,EACH;AAAA,GAAA,EACF,CAAA;AAEJ","file":"chunk-6IRMKF5T.js","sourcesContent":["\"use client\"\n\nimport { ark } from \"@ark-ui/react\"\nimport { Download } from \"lucide-react\"\nimport { type MouseEvent, type ReactNode, useEffect, useRef, useState } from \"react\"\nimport { withAsChildContent } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { type IconMap, iconStroke, mergeIcons } from \"../../lib/icons\"\nimport { props } from \"../../lib/props\"\nimport { saveFile } from \"../../lib/save-file\"\nimport { Button, type ButtonProps } from \"../button/button\"\nimport { Spinner } from \"../spinner/spinner\"\n\n/**\n * DownloadButton — a button that saves a file: a Blob you already have, a\n * URL, or whatever a function of yours resolves to (an authenticated fetch,\n * a presign call, a generated CSV). The kit makes no request itself.\n *\n * - **While a function's promise is pending** the button is busy: a\n * spinner, `aria-busy`, and re-clicks are ignored, so a double click\n * saves one file. It stays enabled and focused, unlike Button's\n * `loading`, which sets `disabled` and drops keyboard focus.\n * - **On failure**, a polite status region says so (`translations.error`)\n * and `onError` gets the error. Nothing is announced on success: the\n * browser's own download UI is the feedback.\n * - **Unmounting mid-fetch** aborts: the function's `signal` fires and\n * nothing is saved afterwards.\n * - Renders a kit `Button` by default. With `asChild`, only the behaviour\n * goes onto your element (an `ActionIcon` in a row's actions), and its\n * content is swapped for the spinner while busy.\n *\n * Built on `saveFile` (`lib/save-file.ts`) rather than Ark's\n * `DownloadTrigger`: Ark's trigger has no pending state, drops a rejected\n * promise, can't be aborted, and reads a string as the file's *contents*\n * rather than a URL.\n *\n * ```tsx\n * <DownloadButton\n * name=\"transcript.pdf\"\n * data={({ signal }) => api.get(`/transcripts/${id}`, { signal }).then((r) => r.blob())}\n * onError={() => notify.error(\"Couldn't download the transcript\")}\n * />\n * ```\n */\n\n/** What can be saved: a Blob (or File), or a URL. */\nexport type DownloadData = Blob | string\n\n/** Resolves the file on click. `signal` aborts when the button unmounts first. */\nexport type DownloadLoader = (context: {\n signal: AbortSignal\n}) => DownloadData | Promise<DownloadData>\n\n/** What `data` takes: the value itself, or a function that resolves it on click. */\nexport type DownloadSource = DownloadData | DownloadLoader\n\nexport type DownloadButtonTranslations = {\n /** The default label, when there are no `children`. @default \"Download\" */\n label?: string\n /** Added to the button's name while `data` is resolving. @default \"Preparing download…\" */\n loading?: string\n /** What the status region says when the download fails.\n * @default (name) => name ? `${name} couldn't be downloaded` : \"The download failed\" */\n error?: (name: string | undefined) => string\n}\n\nexport const DOWNLOAD_BUTTON_DEFAULT_TRANSLATIONS: Required<DownloadButtonTranslations> = {\n label: \"Download\",\n loading: \"Preparing download…\",\n error: (name) => (name ? `${name} couldn't be downloaded` : \"The download failed\"),\n}\n\nexport type DownloadButtonIconSlot = \"download\"\n\nconst DEFAULT_ICONS: Record<DownloadButtonIconSlot, ReactNode> = {\n download: <Download className={iconStroke} />,\n}\n\nexport type DownloadButtonProps = Omit<\n ButtonProps,\n \"type\" | \"name\" | \"loading\" | \"startSlot\" | \"onError\"\n> & {\n /** The file: a Blob, a URL, or a function resolving one on click (passed an abort `signal`). */\n data: DownloadSource\n /** The file name. Ignored by browsers for a cross-origin URL; see `saveFile`. */\n name?: string\n /** The MIME type, for a Blob without one. */\n type?: string\n /** Fires when `data` rejects or the save throws. */\n onError?: (error: unknown) => void\n /** Fires once the file has been handed to the browser. */\n onDone?: () => void\n translations?: DownloadButtonTranslations\n /** `download`, the leading icon. `null` renders none. Not shown under `asChild`. */\n icons?: IconMap<DownloadButtonIconSlot>\n}\n\n/** Tailwind's `sr-only`, fixed rather than absolute: it is rendered beside the\n * button, outside any box of ours, and a fixed box can't stretch a scroller. */\nconst statusRegion =\n \"fixed size-px -m-px p-0 overflow-hidden whitespace-nowrap border-0 [clip-path:inset(50%)]\"\n\n/** Calls the loader now, inside the click, and treats a synchronous throw as a rejection. */\nconst started = (load: DownloadLoader, signal: AbortSignal): Promise<DownloadData> => {\n try {\n return Promise.resolve(load({ signal }))\n } catch (error) {\n return Promise.reject(error)\n }\n}\n\nexport const DownloadButton = ({\n data,\n name,\n type,\n onError,\n onDone,\n translations,\n icons,\n asChild,\n children,\n testId,\n onClick,\n variant,\n size,\n color,\n endSlot,\n disabled,\n className,\n ...rest\n}: DownloadButtonProps) => {\n const t = { ...DOWNLOAD_BUTTON_DEFAULT_TRANSLATIONS, ...translations }\n const icon = mergeIcons(DEFAULT_ICONS, icons)\n const [busy, setBusy] = useState(false)\n const [failure, setFailure] = useState(\"\")\n // The run in flight, if any: the re-click guard and the unmount abort. A\n // ref, so two clicks in one frame can't both read a stale `busy`.\n const running = useRef<AbortController | null>(null)\n\n useEffect(() => () => running.current?.abort(), [])\n\n const fail = (error: unknown) => {\n setFailure(t.error(name))\n onError?.(error)\n }\n\n // `onDone` sits outside the try, so a throw in the caller's own callback\n // isn't announced as a failed download.\n const save = (value: DownloadData) => {\n try {\n saveFile(value, name, { type })\n } catch (error) {\n return fail(error)\n }\n onDone?.()\n }\n\n const resolve = async (load: DownloadLoader) => {\n const controller = new AbortController()\n running.current = controller\n setBusy(true)\n const outcome = await started(load, controller.signal).then(\n (value) => ({ value }),\n (error: unknown) => ({ error }),\n )\n running.current = null\n // Unmounted meanwhile: nothing to save, and no state left to update.\n if (controller.signal.aborted) return\n setBusy(false)\n if (\"error\" in outcome) fail(outcome.error)\n else save(outcome.value)\n }\n\n // `onClick` runs first, so a caller can `preventDefault()` to stop the save\n // (a confirm step). A value is saved inside the click itself; a function's\n // promise is awaited, and the save follows when it settles.\n const download = (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (event.defaultPrevented || disabled || running.current) return\n // An `asChild` link would also follow its own href.\n event.preventDefault()\n setFailure(\"\")\n if (typeof data === \"function\") void resolve(data)\n else save(data)\n }\n\n const trigger = {\n \"data-scope\": \"download-button\",\n \"data-part\": \"trigger\",\n onClick: download,\n ...props({\n \"aria-busy\": busy,\n \"data-loading\": busy,\n \"data-testid\": testId,\n \"data-disabled\": disabled,\n }),\n ...rest,\n }\n\n return (\n <>\n {asChild ? (\n // Only behaviour is merged onto the child: Button's styling would\n // fight an ActionIcon's own. While busy the spinner stands in for the\n // child's content (its icon); its name stays the child's own label.\n <ark.button\n asChild\n disabled={disabled}\n {...props({ \"aria-disabled\": disabled })}\n className={className}\n {...trigger}\n >\n {withAsChildContent(children, (own) => (busy ? <Spinner label={t.loading} /> : own))}\n </ark.button>\n ) : (\n <Button\n variant={variant}\n size={size}\n color={color}\n startSlot={busy ? <Spinner label={null} /> : icon.download}\n endSlot={endSlot}\n disabled={disabled}\n // `relative` holds the sr-only loading text inside the button.\n className={cn(\"relative\", className)}\n {...trigger}\n >\n {children ?? t.label}\n {busy && <span className=\"sr-only\">{t.loading}</span>}\n </Button>\n )}\n <span role=\"status\" className={statusRegion} data-scope=\"download-button\" data-part=\"status\">\n {failure}\n </span>\n </>\n )\n}\n"]}
1
+ {"version":3,"sources":["../src/components/download-button/download-button.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAkEO,IAAM,oCAAA,GAA6E;AAAA,EACxF,KAAA,EAAO,UAAA;AAAA,EACP,OAAA,EAAS,0BAAA;AAAA,EACT,OAAO,CAAC,IAAA,KAAU,IAAA,GAAO,CAAA,EAAG,IAAI,CAAA,uBAAA,CAAA,GAA4B;AAC9D;AAIA,IAAM,aAAA,GAA2D;AAAA,EAC/D,QAAA,kBAAU,GAAA,CAAC,QAAA,EAAA,EAAS,SAAA,EAAW,UAAA,EAAY;AAC7C,CAAA;AAuBA,IAAM,YAAA,GACJ,2FAAA;AAGF,IAAM,OAAA,GAAU,CAAC,IAAA,EAAsB,MAAA,KAA+C;AACpF,EAAA,IAAI;AACF,IAAA,OAAO,QAAQ,OAAA,CAAQ,IAAA,CAAK,EAAE,MAAA,EAAQ,CAAC,CAAA;AAAA,EACzC,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,OAAA,CAAQ,OAAO,KAAK,CAAA;AAAA,EAC7B;AACF,CAAA;AAEO,IAAM,iBAAiB,CAAC;AAAA,EAC7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{ ark } from \"@ark-ui/react\"\nimport { Download } from \"lucide-react\"\nimport { type MouseEvent, type ReactNode, useEffect, useRef, useState } from \"react\"\nimport { withAsChildContent } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { type IconMap, iconStroke, mergeIcons } from \"../../lib/icons\"\nimport { props } from \"../../lib/props\"\nimport { saveFile } from \"../../lib/save-file\"\nimport { Button, type ButtonProps } from \"../button/button\"\nimport { Spinner } from \"../spinner/spinner\"\n\n/**\n * DownloadButton — a button that saves a file: a Blob you already have, a\n * URL, or whatever a function of yours resolves to (an authenticated fetch,\n * a presign call, a generated CSV). The kit makes no request itself.\n *\n * - **While a function's promise is pending** the button is busy: a\n * spinner, `aria-busy`, and re-clicks are ignored, so a double click\n * saves one file. It stays enabled and focused, unlike Button's\n * `loading`, which sets `disabled` and drops keyboard focus.\n * - **On failure**, a polite status region says so (`translations.error`)\n * and `onError` gets the error. Nothing is announced on success: the\n * browser's own download UI is the feedback.\n * - **Unmounting mid-fetch** aborts: the function's `signal` fires and\n * nothing is saved afterwards.\n * - Renders a kit `Button` by default. With `asChild`, only the behaviour\n * goes onto your element (an `ActionIcon` in a row's actions), and its\n * content is swapped for the spinner while busy.\n *\n * Built on `saveFile` (`lib/save-file.ts`) rather than Ark's\n * `DownloadTrigger`: Ark's trigger has no pending state, drops a rejected\n * promise, can't be aborted, and reads a string as the file's *contents*\n * rather than a URL.\n *\n * ```tsx\n * <DownloadButton\n * name=\"transcript.pdf\"\n * data={({ signal }) => api.get(`/transcripts/${id}`, { signal }).then((r) => r.blob())}\n * onError={() => notify.error(\"Couldn't download the transcript\")}\n * />\n * ```\n */\n\n/** What can be saved: a Blob (or File), or a URL. */\nexport type DownloadData = Blob | string\n\n/** Resolves the file on click. `signal` aborts when the button unmounts first. */\nexport type DownloadLoader = (context: {\n signal: AbortSignal\n}) => DownloadData | Promise<DownloadData>\n\n/** What `data` takes: the value itself, or a function that resolves it on click. */\nexport type DownloadSource = DownloadData | DownloadLoader\n\nexport type DownloadButtonTranslations = {\n /** The default label, when there are no `children`. @default \"Download\" */\n label?: string\n /** Added to the button's name while `data` is resolving. @default \"Preparing download…\" */\n loading?: string\n /** What the status region says when the download fails.\n * @default (name) => name ? `${name} couldn't be downloaded` : \"The download failed\" */\n error?: (name: string | undefined) => string\n}\n\nexport const DOWNLOAD_BUTTON_DEFAULT_TRANSLATIONS: Required<DownloadButtonTranslations> = {\n label: \"Download\",\n loading: \"Preparing download…\",\n error: (name) => (name ? `${name} couldn't be downloaded` : \"The download failed\"),\n}\n\nexport type DownloadButtonIconSlot = \"download\"\n\nconst DEFAULT_ICONS: Record<DownloadButtonIconSlot, ReactNode> = {\n download: <Download className={iconStroke} />,\n}\n\nexport type DownloadButtonProps = Omit<\n ButtonProps,\n \"type\" | \"name\" | \"loading\" | \"startSlot\" | \"onError\"\n> & {\n /** The file: a Blob, a URL, or a function resolving one on click (passed an abort `signal`). */\n data: DownloadSource\n /** The file name. Ignored by browsers for a cross-origin URL; see `saveFile`. */\n name?: string\n /** The MIME type, for a Blob without one. */\n type?: string\n /** Fires when `data` rejects or the save throws. */\n onError?: (error: unknown) => void\n /** Fires once the file has been handed to the browser. */\n onDone?: () => void\n translations?: DownloadButtonTranslations\n /** `download`, the leading icon. `null` renders none. Not shown under `asChild`. */\n icons?: IconMap<DownloadButtonIconSlot>\n}\n\n/** Tailwind's `sr-only`, fixed rather than absolute: it is rendered beside the\n * button, outside any box of ours, and a fixed box can't stretch a scroller. */\nconst statusRegion =\n \"fixed size-px -m-px p-0 overflow-hidden whitespace-nowrap border-0 [clip-path:inset(50%)]\"\n\n/** Calls the loader now, inside the click, and treats a synchronous throw as a rejection. */\nconst started = (load: DownloadLoader, signal: AbortSignal): Promise<DownloadData> => {\n try {\n return Promise.resolve(load({ signal }))\n } catch (error) {\n return Promise.reject(error)\n }\n}\n\nexport const DownloadButton = ({\n data,\n name,\n type,\n onError,\n onDone,\n translations,\n icons,\n asChild,\n children,\n testId,\n onClick,\n variant,\n size,\n color,\n endSlot,\n disabled,\n className,\n ...rest\n}: DownloadButtonProps) => {\n const t = { ...DOWNLOAD_BUTTON_DEFAULT_TRANSLATIONS, ...translations }\n const icon = mergeIcons(DEFAULT_ICONS, icons)\n const [busy, setBusy] = useState(false)\n const [failure, setFailure] = useState(\"\")\n // The run in flight, if any: the re-click guard and the unmount abort. A\n // ref, so two clicks in one frame can't both read a stale `busy`.\n const running = useRef<AbortController | null>(null)\n\n useEffect(() => () => running.current?.abort(), [])\n\n const fail = (error: unknown) => {\n setFailure(t.error(name))\n onError?.(error)\n }\n\n // `onDone` sits outside the try, so a throw in the caller's own callback\n // isn't announced as a failed download.\n const save = (value: DownloadData) => {\n try {\n saveFile(value, name, { type })\n } catch (error) {\n return fail(error)\n }\n onDone?.()\n }\n\n const resolve = async (load: DownloadLoader) => {\n const controller = new AbortController()\n running.current = controller\n setBusy(true)\n const outcome = await started(load, controller.signal).then(\n (value) => ({ value }),\n (error: unknown) => ({ error }),\n )\n running.current = null\n // Unmounted meanwhile: nothing to save, and no state left to update.\n if (controller.signal.aborted) return\n setBusy(false)\n if (\"error\" in outcome) fail(outcome.error)\n else save(outcome.value)\n }\n\n // `onClick` runs first, so a caller can `preventDefault()` to stop the save\n // (a confirm step). A value is saved inside the click itself; a function's\n // promise is awaited, and the save follows when it settles.\n const download = (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (event.defaultPrevented || disabled || running.current) return\n // An `asChild` link would also follow its own href.\n event.preventDefault()\n setFailure(\"\")\n if (typeof data === \"function\") void resolve(data)\n else save(data)\n }\n\n const trigger = {\n \"data-scope\": \"download-button\",\n \"data-part\": \"trigger\",\n onClick: download,\n ...props({\n \"aria-busy\": busy,\n \"data-loading\": busy,\n \"data-testid\": testId,\n \"data-disabled\": disabled,\n }),\n ...rest,\n }\n\n return (\n <>\n {asChild ? (\n // Only behaviour is merged onto the child: Button's styling would\n // fight an ActionIcon's own. While busy the spinner stands in for the\n // child's content (its icon); its name stays the child's own label.\n <ark.button\n asChild\n disabled={disabled}\n {...props({ \"aria-disabled\": disabled })}\n className={className}\n {...trigger}\n >\n {withAsChildContent(children, (own) => (busy ? <Spinner label={t.loading} /> : own))}\n </ark.button>\n ) : (\n <Button\n variant={variant}\n size={size}\n color={color}\n startSlot={busy ? <Spinner label={null} /> : icon.download}\n endSlot={endSlot}\n disabled={disabled}\n // `relative` holds the sr-only loading text inside the button.\n className={cn(\"relative\", className)}\n {...trigger}\n >\n {children ?? t.label}\n {busy && <span className=\"sr-only\">{t.loading}</span>}\n </Button>\n )}\n <span role=\"status\" className={statusRegion} data-scope=\"download-button\" data-part=\"status\">\n {failure}\n </span>\n </>\n )\n}\n"]}
@@ -1,4 +1,5 @@
1
- import { Spinner } from './chunk-D2QIPQ74.js';
1
+ import { buttonColorVariants } from './chunk-6B2GNPJP.js';
2
+ import { Spinner } from './chunk-W3XX7BYT.js';
2
3
  import { withAsChildContent } from './chunk-R5LYFTHA.js';
3
4
  import { props } from './chunk-WYCMIIRR.js';
4
5
  import { focusStyles } from './chunk-C6NVU4F7.js';
@@ -16,41 +17,35 @@ var actionIconVariants = cva(
16
17
  "rounded-action-icon border border-transparent",
17
18
  "transition-colors-radius",
18
19
  focusStyles(),
19
- "disabled:not-data-loading:pointer-events-none disabled:opacity-50",
20
- "data-disabled:pointer-events-none data-disabled:opacity-50",
20
+ "disabled:not-data-loading:pointer-events-none data-disabled:pointer-events-none",
21
21
  "not-data-loading:hover:cursor-pointer",
22
22
  "data-loading:cursor-progress data-loading:opacity-50",
23
- "[&_svg]:shrink-0 [&_svg]:pointer-events-none"
23
+ // Every svg rule is `[:where(&)_svg]`: zero class specificity, so a size
24
+ // class on the icon itself (`<Star className="size-5" />`) or a nested
25
+ // component's own svg rule wins whatever the CSS order. Lucide's `size`
26
+ // prop is only an HTML attribute and still loses. Same fix as Input (#427).
27
+ "[:where(&)_svg]:shrink-0 [:where(&)_svg]:pointer-events-none"
24
28
  ],
25
29
  {
26
30
  variants: {
27
31
  variant: {
28
- filled: [
29
- "bg-(--c-solid) text-(--c-on-solid)",
30
- "not-data-loading:hover:bg-(--c-solid-hover)"
31
- ],
32
- light: [
33
- "bg-(--c-soft) text-(--c-text) border-(--c-soft-hover)",
34
- "not-data-loading:hover:bg-(--c-soft-hover) not-data-loading:hover:border-(--c-solid)"
35
- ],
36
- // Button's outline edge (the colour at 35%), so the two read as one
37
- // stroke weight side by side in a toolbar.
38
- outline: [
39
- "bg-transparent text-(--c-text) border-(--c-solid)/35",
40
- "not-data-loading:hover:bg-(--c-soft)"
41
- ],
42
- subtle: ["bg-transparent text-(--c-text)", "not-data-loading:hover:bg-(--c-soft)"],
32
+ filled: buttonColorVariants.filled,
33
+ light: buttonColorVariants.light,
34
+ outline: buttonColorVariants.outline,
35
+ subtle: buttonColorVariants.subtle,
43
36
  default: [
44
37
  "bg-brand-950 text-white border-brand-800 not-data-loading:hover:bg-brand-800",
45
- "dark:bg-white dark:text-brand-950 dark:border-white/80 dark:not-data-loading:hover:bg-white/80"
38
+ "dark:bg-white dark:text-brand-950 dark:border-white/80 dark:not-data-loading:hover:bg-white/80",
39
+ // Not part of the Figma Button set, so it keeps the plain dim.
40
+ "disabled:opacity-50 data-disabled:opacity-50"
46
41
  ]
47
42
  },
48
43
  size: {
49
- xs: "h-7 text-xs [&_svg]:size-5",
50
- sm: "h-8 text-sm [&_svg]:size-5.5",
51
- md: "h-9 text-md [&_svg]:size-6",
52
- lg: "h-10 text-lg [&_svg]:size-7",
53
- xl: "h-12 text-xl [&_svg]:size-8"
44
+ xs: "h-7 text-xs [:where(&)_svg]:size-3",
45
+ sm: "h-8 text-sm [:where(&)_svg]:size-3.5",
46
+ md: "h-9 text-md [:where(&)_svg]:size-4",
47
+ lg: "h-10 text-lg [:where(&)_svg]:size-5",
48
+ xl: "h-12 text-xl [:where(&)_svg]:size-6"
54
49
  },
55
50
  radius: {
56
51
  xs: "rounded-xs",
@@ -113,5 +108,5 @@ var ActionIcon = ({
113
108
  };
114
109
 
115
110
  export { ActionIcon };
116
- //# sourceMappingURL=chunk-BMEJBY6H.js.map
117
- //# sourceMappingURL=chunk-BMEJBY6H.js.map
111
+ //# sourceMappingURL=chunk-B5YHYI7E.js.map
112
+ //# sourceMappingURL=chunk-B5YHYI7E.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/action-icon/action-icon.tsx"],"names":[],"mappings":";;;;;;;;;;AAyCA,IAAM,kBAAA,GAAqB,GAAA;AAAA,EACzB;AAAA,IACE,yCAAA;AAAA,IACA,oCAAA;AAAA,IACA,qCAAA;AAAA,IACA,cAAA;AAAA,IACA,+CAAA;AAAA,IACA,0BAAA;AAAA,IACA,WAAA,EAAY;AAAA,IACZ,iFAAA;AAAA,IACA,uCAAA;AAAA,IACA,sDAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,OAAA,EAAS;AAAA,QACP,QAAQ,mBAAA,CAAoB,MAAA;AAAA,QAC5B,OAAO,mBAAA,CAAoB,KAAA;AAAA,QAC3B,SAAS,mBAAA,CAAoB,OAAA;AAAA,QAC7B,QAAQ,mBAAA,CAAoB,MAAA;AAAA,QAC5B,OAAA,EAAS;AAAA,UACP,8EAAA;AAAA,UACA,gGAAA;AAAA;AAAA,UAEA;AAAA;AACF,OACF;AAAA,MACA,IAAA,EAAM;AAAA,QACJ,EAAA,EAAI,oCAAA;AAAA,QACJ,EAAA,EAAI,sCAAA;AAAA,QACJ,EAAA,EAAI,oCAAA;AAAA,QACJ,EAAA,EAAI,qCAAA;AAAA,QACJ,EAAA,EAAI;AAAA,OACN;AAAA,MACA,MAAA,EAAQ;AAAA,QACN,EAAA,EAAI,YAAA;AAAA,QACJ,EAAA,EAAI,YAAA;AAAA,QACJ,EAAA,EAAI,YAAA;AAAA,QACJ,EAAA,EAAI,YAAA;AAAA,QACJ,EAAA,EAAI,YAAA;AAAA,QACJ,IAAA,EAAM;AAAA;AAC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A,CAAmB,QAAA,EAAU,sBAAM,GAAA,CAAC,OAAA,EAAA,EAAQ,KAAA,EAAO,IAAA,EAAM,CAAA,EAAI;AAAA,QAC3D,OAAA,EAAS;AAAA,OACV,CAAA,GACC,OAAA,uBACD,OAAA,EAAA,EAAQ,KAAA,EAAO,MAAM,CAAA,GAEtB;AAAA;AAAA,GAEJ;AAEJ","file":"chunk-B5YHYI7E.js","sourcesContent":["\"use client\"\n\nimport { ark, type HTMLArkProps } from \"@ark-ui/react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport type { MouseEvent } from \"react\"\nimport { withAsChildContent } from \"../../lib/as-child\"\nimport { buttonColorVariants } from \"../../lib/button-colors\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { Spinner } from \"../spinner/spinner\"\n\n/**\n * ActionIcon — square, icon-only sibling of `Button`.\n *\n * Same (variant × color) model as `Button`:\n * - `variant` picks the shape (filled / light / outline / subtle / default)\n * - `color` picks the palette (brand / neutral / red / …)\n * - filled / light / outline / subtle share Button's colour classes\n * (`lib/button-colors.ts`, the `--btn-*` slots in `colors.css`): Figma's\n * ActionIcon is an instance of its Button set.\n *\n * What's specific to ActionIcon:\n * - Forced 1:1 aspect ratio.\n * - Own `radius` scale (incl. `full` for circular FABs / like-buttons).\n * - Wider size scale (xs..xl) than Button — toolbar density matters here.\n *\n * The accessible name MUST come from `aria-label` (or `aria-labelledby`); the\n * icon children are decoration.\n *\n * `asChild` renders the single child with ActionIcon's styling. Ark's\n * factory clones exactly one element, so `loading`'s spinner replaces\n * *that* element's own children (`withAsChildContent`, `lib/as-child.ts`)\n * rather than the element itself. The `onClick` guard (`preventWhileLoading`)\n * goes on the same clone, since `disabled` doesn't do anything on an\n * arbitrary `asChild` element (e.g. an `<a>`) — same reason the loading\n * `opacity-50` dimming and `pointer-events-none` blocking are keyed off `data-loading`\n * rather than `:disabled` (see `Button`'s note on this).\n */\nconst actionIconVariants = cva(\n [\n \"inline-flex items-center justify-center\",\n \"aspect-square shrink-0 select-none\",\n \"font-medium uppercase tracking-wide\",\n \"no-underline\",\n \"rounded-action-icon border border-transparent\",\n \"transition-colors-radius\",\n focusStyles(),\n \"disabled:not-data-loading:pointer-events-none data-disabled:pointer-events-none\",\n \"not-data-loading:hover:cursor-pointer\",\n \"data-loading:cursor-progress data-loading:opacity-50\",\n // Every svg rule is `[:where(&)_svg]`: zero class specificity, so a size\n // class on the icon itself (`<Star className=\"size-5\" />`) or a nested\n // component's own svg rule wins whatever the CSS order. Lucide's `size`\n // prop is only an HTML attribute and still loses. Same fix as Input (#427).\n \"[:where(&)_svg]:shrink-0 [:where(&)_svg]:pointer-events-none\",\n ],\n {\n variants: {\n variant: {\n filled: buttonColorVariants.filled,\n light: buttonColorVariants.light,\n outline: buttonColorVariants.outline,\n subtle: buttonColorVariants.subtle,\n default: [\n \"bg-brand-950 text-white border-brand-800 not-data-loading:hover:bg-brand-800\",\n \"dark:bg-white dark:text-brand-950 dark:border-white/80 dark:not-data-loading:hover:bg-white/80\",\n // Not part of the Figma Button set, so it keeps the plain dim.\n \"disabled:opacity-50 data-disabled:opacity-50\",\n ],\n },\n size: {\n xs: \"h-7 text-xs [:where(&)_svg]:size-3\",\n sm: \"h-8 text-sm [:where(&)_svg]:size-3.5\",\n md: \"h-9 text-md [:where(&)_svg]:size-4\",\n lg: \"h-10 text-lg [:where(&)_svg]:size-5\",\n xl: \"h-12 text-xl [:where(&)_svg]:size-6\",\n },\n radius: {\n xs: \"rounded-xs\",\n sm: \"rounded-sm\",\n md: \"rounded-md\",\n lg: \"rounded-lg\",\n xl: \"rounded-xl\",\n full: \"rounded-full\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"md\",\n },\n },\n)\n\nexport type ActionIconVariant = NonNullable<VariantProps<typeof actionIconVariants>[\"variant\"]>\nexport type ActionIconSize = NonNullable<VariantProps<typeof actionIconVariants>[\"size\"]>\nexport type ActionIconRadius = NonNullable<VariantProps<typeof actionIconVariants>[\"radius\"]>\n\nexport type ActionIconProps = Omit<HTMLArkProps<\"button\">, \"color\"> &\n VariantProps<typeof actionIconVariants> &\n WithTestId & {\n /** Accent palette. Re-exported as `Color` from `@42/ui-react`. */\n color?: Color\n /**\n * Replace the icon with a spinner, mark the element as busy, and suppress\n * pointer interactions. Mirrors `Button`'s `loading`.\n */\n loading?: boolean\n }\n\n/** Mirrors `Button`'s `preventWhileLoading` — see the note there. */\nconst preventWhileLoading = (event: MouseEvent) => {\n event.preventDefault()\n event.stopPropagation()\n}\n\nexport const ActionIcon = ({\n className,\n variant,\n size,\n radius,\n color,\n loading = false,\n children,\n disabled,\n type,\n asChild,\n testId,\n onClick,\n ...rest\n}: ActionIconProps) => {\n const resolvedDisabled = disabled || loading\n const resolvedOnClick = loading ? preventWhileLoading : onClick\n\n return (\n <ark.button\n asChild={asChild}\n type={asChild ? type : (type ?? \"button\")}\n disabled={resolvedDisabled}\n data-color={color}\n data-variant={variant ?? \"default\"}\n className={cn(actionIconVariants({ variant, size, radius }), className)}\n onClick={resolvedOnClick}\n {...props({\n \"aria-busy\": loading,\n \"aria-disabled\": resolvedDisabled,\n \"data-loading\": loading,\n \"data-testid\": testId,\n })}\n {...rest}\n >\n {asChild && loading ? (\n withAsChildContent(children, () => <Spinner label={null} />, {\n onClick: preventWhileLoading,\n })\n ) : loading ? (\n <Spinner label={null} />\n ) : (\n children\n )}\n </ark.button>\n )\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { saveFile } from './chunk-EIBDLRAR.js';
2
- import { DEFAULT_LOCALE } from './chunk-IUK7OJXZ.js';
2
+ import { DEFAULT_LOCALE } from './chunk-OBSZ4NE2.js';
3
3
  import { match } from 'ts-pattern';
4
4
  import { useState, useEffect } from 'react';
5
5
 
@@ -350,5 +350,5 @@ function useObjectUrl(source, options = {}) {
350
350
  }
351
351
 
352
352
  export { FILE_KINDS, OPEN_FILE_MAX_AGE, OPEN_FILE_POLL, SVG_DATA_URL_LIMIT, extensionOf, fileKind, formatFileSize, inlineType, openFile, useObjectUrl, viewableType };
353
- //# sourceMappingURL=chunk-WERJ44ZN.js.map
354
- //# sourceMappingURL=chunk-WERJ44ZN.js.map
353
+ //# sourceMappingURL=chunk-DTFSCR3U.js.map
354
+ //# sourceMappingURL=chunk-DTFSCR3U.js.map
@@ -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,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;AAAA,EACA,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M,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
+ {"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,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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,7 +1,7 @@
1
1
  import { PillGroupContext, pill } from './chunk-6M6YZ3PQ.js';
2
2
  import { inputSlot, inputShell, inputControlClasses } from './chunk-I4B3N3UX.js';
3
3
  import { useElementSize } from './chunk-2LI3VPDP.js';
4
- import { useLocale } from './chunk-IUK7OJXZ.js';
4
+ import { useLocale } from './chunk-OBSZ4NE2.js';
5
5
  import { props } from './chunk-WYCMIIRR.js';
6
6
  import { cn } from './chunk-4ASNIDV7.js';
7
7
  import { ark } from '@ark-ui/react';
@@ -230,5 +230,5 @@ var PillsInput = Object.assign(PillsInputBase, {
230
230
  });
231
231
 
232
232
  export { PillOverflowCounter, PillsInput, pillsContent, pillsShell, usePillOverflow };
233
- //# sourceMappingURL=chunk-PFZMB3US.js.map
234
- //# sourceMappingURL=chunk-PFZMB3US.js.map
233
+ //# sourceMappingURL=chunk-FQJNQW3G.js.map
234
+ //# sourceMappingURL=chunk-FQJNQW3G.js.map