@42-central/ui-react 0.27.0 → 0.28.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 (106) hide show
  1. package/dist/{chunk-OVT2KZHY.js → chunk-3KARNPW4.js} +3 -3
  2. package/dist/{chunk-OVT2KZHY.js.map → chunk-3KARNPW4.js.map} +1 -1
  3. package/dist/chunk-6B2GNPJP.js +43 -0
  4. package/dist/chunk-6B2GNPJP.js.map +1 -0
  5. package/dist/{chunk-E52Z2FKU.js → chunk-7BY5I2RB.js} +3 -3
  6. package/dist/{chunk-E52Z2FKU.js.map → chunk-7BY5I2RB.js.map} +1 -1
  7. package/dist/{chunk-X3YIHN2U.js → chunk-ASKQ6N5V.js} +3 -3
  8. package/dist/{chunk-X3YIHN2U.js.map → chunk-ASKQ6N5V.js.map} +1 -1
  9. package/dist/{chunk-6IRMKF5T.js → chunk-B4GNSSHU.js} +4 -4
  10. package/dist/{chunk-6IRMKF5T.js.map → chunk-B4GNSSHU.js.map} +1 -1
  11. package/dist/{chunk-BMEJBY6H.js → chunk-B5YHYI7E.js} +22 -27
  12. package/dist/chunk-B5YHYI7E.js.map +1 -0
  13. package/dist/{chunk-7OGZT7U2.js → chunk-G3AD3NJG.js} +3 -3
  14. package/dist/{chunk-7OGZT7U2.js.map → chunk-G3AD3NJG.js.map} +1 -1
  15. package/dist/{chunk-MNYY7UU2.js → chunk-GJFCIG34.js} +4 -4
  16. package/dist/{chunk-MNYY7UU2.js.map → chunk-GJFCIG34.js.map} +1 -1
  17. package/dist/{chunk-5H5YOPCF.js → chunk-I53TMAV2.js} +5 -5
  18. package/dist/{chunk-5H5YOPCF.js.map → chunk-I53TMAV2.js.map} +1 -1
  19. package/dist/{chunk-MCRTAUSZ.js → chunk-K3FZHYJL.js} +3 -3
  20. package/dist/{chunk-MCRTAUSZ.js.map → chunk-K3FZHYJL.js.map} +1 -1
  21. package/dist/{chunk-ZVECQBGG.js → chunk-KNGSO7A3.js} +41 -13
  22. package/dist/chunk-KNGSO7A3.js.map +1 -0
  23. package/dist/{chunk-4D2V4JE4.js → chunk-KYVXPSNW.js} +3 -3
  24. package/dist/{chunk-4D2V4JE4.js.map → chunk-KYVXPSNW.js.map} +1 -1
  25. package/dist/{chunk-L24N5EON.js → chunk-P7SH3XWY.js} +3 -3
  26. package/dist/{chunk-L24N5EON.js.map → chunk-P7SH3XWY.js.map} +1 -1
  27. package/dist/{chunk-LKFHUDEW.js → chunk-QVOBLRCM.js} +3 -3
  28. package/dist/{chunk-LKFHUDEW.js.map → chunk-QVOBLRCM.js.map} +1 -1
  29. package/dist/{chunk-SCXXJDKQ.js → chunk-SP6LCCTZ.js} +21 -28
  30. package/dist/chunk-SP6LCCTZ.js.map +1 -0
  31. package/dist/{chunk-Y2G47ARQ.js → chunk-TGGNSSOJ.js} +3 -3
  32. package/dist/{chunk-Y2G47ARQ.js.map → chunk-TGGNSSOJ.js.map} +1 -1
  33. package/dist/{chunk-D2QIPQ74.js → chunk-W3XX7BYT.js} +2 -2
  34. package/dist/chunk-W3XX7BYT.js.map +1 -0
  35. package/dist/{chunk-F374BNL4.js → chunk-YVTM2KRR.js} +12 -8
  36. package/dist/chunk-YVTM2KRR.js.map +1 -0
  37. package/dist/colors.css +328 -0
  38. package/dist/components/action-icon/action-icon.d.ts +6 -5
  39. package/dist/components/action-icon/action-icon.d.ts.map +1 -1
  40. package/dist/components/action-icon/index.js +3 -2
  41. package/dist/components/alert/index.js +2 -2
  42. package/dist/components/app-shell/index.js +5 -4
  43. package/dist/components/app-shell/index.js.map +1 -1
  44. package/dist/components/badge/badge.d.ts +1 -1
  45. package/dist/components/badge/badge.d.ts.map +1 -1
  46. package/dist/components/badge/index.js +2 -1
  47. package/dist/components/button/button.d.ts +11 -9
  48. package/dist/components/button/button.d.ts.map +1 -1
  49. package/dist/components/button/index.js +3 -2
  50. package/dist/components/button-multi-select/index.js +4 -3
  51. package/dist/components/button-multi-select/index.js.map +1 -1
  52. package/dist/components/button-select/index.js +4 -3
  53. package/dist/components/button-select/index.js.map +1 -1
  54. package/dist/components/calendar/index.js +4 -3
  55. package/dist/components/camera/index.js +6 -5
  56. package/dist/components/clipboard/index.js +3 -2
  57. package/dist/components/clipboard/index.js.map +1 -1
  58. package/dist/components/data-table/index.js +10 -9
  59. package/dist/components/data-table/index.js.map +1 -1
  60. package/dist/components/date-picker/index.js +7 -6
  61. package/dist/components/date-picker/index.js.map +1 -1
  62. package/dist/components/download-button/index.js +4 -3
  63. package/dist/components/drawer/index.js +5 -4
  64. package/dist/components/file-item/index.js +4 -3
  65. package/dist/components/file-preview/index.js +4 -3
  66. package/dist/components/file-preview/index.js.map +1 -1
  67. package/dist/components/file-trigger/index.js +4 -3
  68. package/dist/components/file-upload/index.js +4 -3
  69. package/dist/components/file-upload/index.js.map +1 -1
  70. package/dist/components/image-cropper/index.js +4 -3
  71. package/dist/components/lightbox/index.js +7 -6
  72. package/dist/components/lightbox/index.js.map +1 -1
  73. package/dist/components/modal/index.js +5 -4
  74. package/dist/components/notification/index.js +3 -3
  75. package/dist/components/overlays/index.js +7 -6
  76. package/dist/components/overlays/index.js.map +1 -1
  77. package/dist/components/photo-capture/index.js +8 -7
  78. package/dist/components/photo-capture/index.js.map +1 -1
  79. package/dist/components/schedule/index.js +4 -3
  80. package/dist/components/schedule/index.js.map +1 -1
  81. package/dist/components/spinner/index.js +1 -1
  82. package/dist/components/spinner/spinner.d.ts +1 -1
  83. package/dist/components/spinner/spinner.d.ts.map +1 -1
  84. package/dist/components/spotlight/index.js +5 -4
  85. package/dist/components/spotlight/index.js.map +1 -1
  86. package/dist/components/theme-icon/index.js +1 -1
  87. package/dist/components/theme-icon/theme-icon.d.ts.map +1 -1
  88. package/dist/lib/button-colors.d.ts +25 -0
  89. package/dist/lib/button-colors.d.ts.map +1 -0
  90. package/package.json +1 -1
  91. package/src/colors.css +328 -0
  92. package/src/components/action-icon/action-icon.test.tsx +22 -0
  93. package/src/components/action-icon/action-icon.tsx +24 -28
  94. package/src/components/badge/badge.test.tsx +53 -10
  95. package/src/components/badge/badge.tsx +64 -11
  96. package/src/components/button/button.test.tsx +41 -5
  97. package/src/components/button/button.tsx +28 -33
  98. package/src/components/spinner/spinner.tsx +3 -3
  99. package/src/components/theme-icon/theme-icon.test.tsx +7 -0
  100. package/src/components/theme-icon/theme-icon.tsx +10 -6
  101. package/src/lib/button-colors.ts +55 -0
  102. package/dist/chunk-BMEJBY6H.js.map +0 -1
  103. package/dist/chunk-D2QIPQ74.js.map +0 -1
  104. package/dist/chunk-F374BNL4.js.map +0 -1
  105. package/dist/chunk-SCXXJDKQ.js.map +0 -1
  106. package/dist/chunk-ZVECQBGG.js.map +0 -1
@@ -1,13 +1,14 @@
1
1
  "use client";
2
- export { Modal } from '../../chunk-MCRTAUSZ.js';
3
- import '../../chunk-4D2V4JE4.js';
2
+ export { Modal } from '../../chunk-K3FZHYJL.js';
3
+ import '../../chunk-KYVXPSNW.js';
4
4
  import '../../chunk-HWBFRDX7.js';
5
5
  import '../../chunk-SLUOF7XW.js';
6
- import '../../chunk-BMEJBY6H.js';
6
+ import '../../chunk-B5YHYI7E.js';
7
+ import '../../chunk-6B2GNPJP.js';
7
8
  import '../../chunk-LIZWCWED.js';
8
9
  import '../../chunk-BUIHQJGE.js';
9
10
  import '../../chunk-XXOR34T4.js';
10
- import '../../chunk-D2QIPQ74.js';
11
+ import '../../chunk-W3XX7BYT.js';
11
12
  import '../../chunk-R5LYFTHA.js';
12
13
  import '../../chunk-WYCMIIRR.js';
13
14
  import '../../chunk-C6NVU4F7.js';
@@ -2,14 +2,14 @@
2
2
  import { useDocumentVisibility } from '../../chunk-WG3BCIU4.js';
3
3
  import { useMergedRefs } from '../../chunk-HBWV5EPU.js';
4
4
  import { isModalOpen } from '../../chunk-HWBFRDX7.js';
5
- import { NOTIFICATION_DEFAULT_TRANSLATIONS, Notification } from '../../chunk-LKFHUDEW.js';
6
- export { Notification, notificationRoot } from '../../chunk-LKFHUDEW.js';
5
+ import { NOTIFICATION_DEFAULT_TRANSLATIONS, Notification } from '../../chunk-QVOBLRCM.js';
6
+ export { Notification, notificationRoot } from '../../chunk-QVOBLRCM.js';
7
7
  import '../../chunk-PMUCGFY5.js';
8
8
  import '../../chunk-BUIHQJGE.js';
9
9
  import '../../chunk-6YNLRQ25.js';
10
10
  import '../../chunk-NKOTA5TM.js';
11
11
  import '../../chunk-XXOR34T4.js';
12
- import '../../chunk-D2QIPQ74.js';
12
+ import '../../chunk-W3XX7BYT.js';
13
13
  import '../../chunk-R5LYFTHA.js';
14
14
  import '../../chunk-WYCMIIRR.js';
15
15
  import '../../chunk-C6NVU4F7.js';
@@ -1,15 +1,16 @@
1
1
  "use client";
2
- import { Modal } from '../../chunk-MCRTAUSZ.js';
3
- import { Drawer } from '../../chunk-L24N5EON.js';
4
- import '../../chunk-4D2V4JE4.js';
5
- import { Button } from '../../chunk-SCXXJDKQ.js';
2
+ import { Modal } from '../../chunk-K3FZHYJL.js';
3
+ import { Drawer } from '../../chunk-P7SH3XWY.js';
4
+ import '../../chunk-KYVXPSNW.js';
5
+ import { Button } from '../../chunk-SP6LCCTZ.js';
6
6
  import '../../chunk-HWBFRDX7.js';
7
7
  import '../../chunk-SLUOF7XW.js';
8
- import '../../chunk-BMEJBY6H.js';
8
+ import '../../chunk-B5YHYI7E.js';
9
+ import '../../chunk-6B2GNPJP.js';
9
10
  import { devWarn } from '../../chunk-LIZWCWED.js';
10
11
  import '../../chunk-BUIHQJGE.js';
11
12
  import '../../chunk-XXOR34T4.js';
12
- import '../../chunk-D2QIPQ74.js';
13
+ import '../../chunk-W3XX7BYT.js';
13
14
  import '../../chunk-R5LYFTHA.js';
14
15
  import '../../chunk-WYCMIIRR.js';
15
16
  import '../../chunk-C6NVU4F7.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/overlays/renderer.tsx","../../../src/components/overlays/store.ts","../../../src/components/overlays/create-overlays.tsx"],"names":["entry","jsx","useSyncExternalStore"],"mappings":";;;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,mBAAmB,MAAM;AAG7B,IAAA,uBACEC,GAAAA;AAAA,MAAC,eAAA;AAAA,MAAA;AAAA,QACC,KAAA;AAAA,QACA,QAAA,EAAU,MAAA,CAAO,QAAA,IAAa,EAAC;AAAA,QAC/B;AAAA;AAAA,KACF;AAAA,EAEJ,CAAA;AAEA,EAAA,MAAM,cAAc,MAA4B;AAC9C,IAAA,MAAM,EAAE,SAAQ,GAAIC,oBAAAA;AAAA,MAClB,KAAA,CAAM,SAAA;AAAA,MACN,KAAA,CAAM,WAAA;AAAA,MACN,KAAA,CAAM;AAAA,KACR;AAGA,IAAA,OAAO,OAAA,CAAQ,MAAM,CAAC,OAAA,EAA8B,UAAU,CAAA,EAAY,CAAC,OAAO,CAAC,CAAA;AAAA,EACrF,CAAA;AAEA,EAAA,OAAO,EAAE,QAAA,EAAU,UAAA,EAAY,gBAAA,EAAkB,WAAA,EAAY;AAC/D","file":"index.js","sourcesContent":["\"use client\"\n\nimport { Portal } from \"@ark-ui/react/portal\"\nimport { Presence } from \"@ark-ui/react/presence\"\nimport { useState, useSyncExternalStore } from \"react\"\nimport { match } from \"ts-pattern\"\nimport { cn } from \"../../lib/cn\"\nimport { devWarn } from \"../../lib/dev-warn\"\nimport { Button } from \"../button/button\"\nimport { Drawer } from \"../drawer/drawer\"\nimport { Modal } from \"../modal/modal\"\nimport type { OverlayStore } from \"./store\"\nimport type { OverlayEntry, OverlayId, OverlayRegistry, ParamsOf, SurfaceOptions } from \"./types\"\n\n/** Minimal slice of the imperative API the renderer needs at runtime. */\nexport interface OverlayController<R extends OverlayRegistry> {\n close: (id: OverlayId) => void\n update: (\n id: OverlayId,\n patch: Partial<SurfaceOptions & { params: ParamsOf<R, keyof R & string> }>,\n ) => void\n}\n\ninterface OverlayRendererProps<R extends OverlayRegistry> {\n store: OverlayStore\n registry: R\n controller: OverlayController<R>\n}\n\n/**\n * Renders the overlay stack as a SINGLE visible overlay at a time.\n *\n * The store keeps the whole stack, but only the top entry (`entries[0]`, since\n * `open` prepends) is rendered, so there's ever one overlay on screen. Closing\n * the top reveals the next; entries beneath are retained but unmounted while\n * covered. This is the single seam to change if we ever render the stack with\n * depth/parallax effects.\n *\n * The backdrop is hoisted here and shared by the whole stack: it stays mounted\n * across swaps and only fades when the last *open* overlay begins closing, so\n * multi-step transitions don't blink a backdrop in and out.\n */\nexport function OverlayRenderer<R extends OverlayRegistry = OverlayRegistry>({\n store,\n registry,\n controller: modals,\n}: OverlayRendererProps<R>) {\n const { entries } = useSyncExternalStore(\n store.subscribe,\n store.getSnapshot,\n store.getServerSnapshot,\n )\n\n const active = entries.at(0)\n const backdropOpen = entries.some((entry) => entry.status === \"open\")\n\n return (\n <>\n {active?.surfaceOptions.withBackdrop !== false && <OverlayBackdrop present={backdropOpen} />}\n {active && (\n <OverlayItem\n key={active.id}\n entry={active}\n store={store}\n registry={registry}\n modals={modals}\n />\n )}\n </>\n )\n}\n\nconst overlayBackdrop = [\n \"fixed inset-0 z-[calc(var(--modal-z,150)-1)] bg-black/50 backdrop-blur-lg select-none pointer-events-auto\",\n \"data-[state=open]:animate-fade-in\",\n \"data-[state=closed]:animate-fade-out\",\n]\n\n/**\n * The one dimming layer behind whatever overlay is active. Driven by Ark's\n * `Presence` so it fades in on the first open and out after the last close,\n * using the same keyframes as the per-component backdrops.\n */\nfunction OverlayBackdrop({ present }: { present: boolean }) {\n return (\n <Portal>\n <Presence present={present} lazyMount unmountOnExit className={cn(overlayBackdrop)} />\n </Portal>\n )\n}\n\nfunction OverlayItem<R extends OverlayRegistry = OverlayRegistry>({\n entry,\n store,\n registry,\n modals,\n}: {\n entry: OverlayEntry\n store: OverlayStore\n registry: OverlayRegistry\n modals: OverlayController<R>\n}) {\n const open = entry.status === \"open\"\n\n // The manager owns the lifecycle (open/close/exit) and draws a single shared\n // backdrop, so `withBackdrop: false` here and `common` is spread LAST to win\n // over any per-call surface options.\n const common = {\n open,\n withBackdrop: false,\n onOpenChange: (next: boolean) => {\n if (!next) store.close(entry.id)\n },\n onExitComplete: () => store.remove(entry.id),\n }\n\n const body = <OverlayBody entry={entry} registry={registry} modals={modals} />\n\n return match(entry)\n .with({ surface: \"drawer\" }, ({ surfaceOptions }) => (\n <Drawer {...surfaceOptions} {...common}>\n {body}\n </Drawer>\n ))\n .with({ surface: \"modal\" }, ({ surfaceOptions }) => (\n <Modal {...surfaceOptions} {...common}>\n {body}\n </Modal>\n ))\n .exhaustive()\n}\n\nfunction OverlayBody<R extends OverlayRegistry = OverlayRegistry>({\n entry,\n registry,\n modals,\n}: {\n entry: OverlayEntry\n registry: OverlayRegistry\n modals: OverlayController<R>\n}) {\n return match(entry)\n .with({ kind: \"content\" }, ({ children }) => <>{children}</>)\n .with({ kind: \"confirm\" }, (entry) => (\n <>\n {entry.children}\n <ConfirmActions entry={entry} modals={modals} />\n </>\n ))\n .with({ kind: \"context\" }, (entry) => {\n const Component = registry[entry.key]\n if (!Component) {\n devWarn(\n `[overlays] No context overlay registered for key \"${entry.key}\". ` +\n `Pass it to createOverlays({ registry: { ${entry.key}: … } }).`,\n )\n return null\n }\n return (\n <Component\n id={entry.id}\n params={entry.params}\n context={{\n close: () => modals.close(entry.id),\n update: (patch) => modals.update(entry.id, patch as never), // Cast to remove surface missmatch impossibility\n }}\n />\n )\n })\n .exhaustive()\n}\n\nfunction ConfirmActions<R extends OverlayRegistry = OverlayRegistry>({\n entry,\n modals,\n}: {\n entry: Extract<OverlayEntry, { kind: \"confirm\" }>\n modals: OverlayController<R>\n}) {\n const [loading, setLoading] = useState(false)\n\n const handleCancel = () => {\n entry.onCancel?.()\n if (entry.closeOnCancel) modals.close(entry.id)\n }\n\n const handleConfirm = async () => {\n setLoading(true)\n try {\n await entry.onConfirm?.()\n if (entry.closeOnConfirm) modals.close(entry.id)\n } finally {\n setLoading(false)\n }\n }\n\n return (\n <div className=\"mt-6 flex items-center justify-end gap-2\">\n <Button variant=\"light\" color=\"neutral\" onClick={handleCancel} {...entry.cancelProps}>\n {entry.labels.cancel}\n </Button>\n <Button loading={loading} onClick={handleConfirm} {...entry.confirmProps}>\n {entry.labels.confirm}\n </Button>\n </div>\n )\n}\n","import type { OverlayEntry, OverlayId } from \"./types\"\n\n/**\n * Framework-agnostic overlay store — a tiny vanilla pub/sub modelled on Ark's\n * `createToaster`. Holds the open-overlay stack; the React renderer subscribes\n * via `useSyncExternalStore`. No React here, so it's safe to import anywhere\n * (event handlers, utils) and the imperative `modals` object wraps its\n * mutators.\n *\n * Every mutation produces a fresh `state` object and a fresh `entries` array,\n * so `getSnapshot` returns a stable reference between mutations.\n * the contract `useSyncExternalStore` relies on to avoid tearing / render loops.\n */\n\nexport interface OverlayStoreState {\n entries: OverlayEntry[]\n}\n\nexport interface OverlayStore {\n subscribe: (listener: () => void) => () => void\n getSnapshot: () => OverlayStoreState\n getServerSnapshot: () => OverlayStoreState\n /** Append an entry and return its id. */\n open: (entry: OverlayEntry) => OverlayId\n /** Shallow-merge fields into an existing entry. */\n edit: (id: OverlayId, partial: Partial<OverlayEntry>) => void\n /** Flip an entry to `closing` so its wrapper animates out. */\n close: (id: OverlayId) => void\n /** Flip every entry to `closing`. */\n closeAll: () => void\n /** Hard-remove an entry (called once its exit animation completes). */\n remove: (id: OverlayId) => void\n has: (id: OverlayId) => boolean\n}\n\n/** Frozen, module-stable empty stack for SSR — overlays are runtime-only, so\n * the server snapshot is always empty and matches the client's first render. */\nconst SERVER_SNAPSHOT: OverlayStoreState = Object.freeze({ entries: [] })\n\nexport function createOverlayStore(): OverlayStore {\n let state: OverlayStoreState = { entries: [] }\n const listeners = new Set<() => void>()\n\n const emit = () => {\n for (const listener of listeners) listener()\n }\n const set = (entries: OverlayEntry[]) => {\n state = { entries }\n emit()\n }\n\n return {\n subscribe(listener) {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n },\n getSnapshot() {\n return state\n },\n getServerSnapshot() {\n return SERVER_SNAPSHOT\n },\n open(entry) {\n // Only the top entry can be `closing` (`close`/`closeAll` drop covered\n // ones). Covering it unmounts it before its exit animation can fire\n // `onExitComplete`, so it would never be removed: drop it here instead.\n set([entry, ...state.entries.filter((e) => e.status !== \"closing\")])\n return entry.id\n },\n edit(id, partial) {\n set(\n state.entries.map((entry) =>\n entry.id === id ? ({ ...entry, ...partial } as OverlayEntry) : entry,\n ),\n )\n },\n close(id) {\n const index = state.entries.findIndex((entry) => entry.id === id)\n if (index === -1) return\n // Only the active (top) overlay is on screen, so only it animates out —\n // its exit fires `onExitComplete`, which removes it and reveals the next.\n // A covered entry has no mounted element to animate, so drop it now\n // (otherwise a \"closing\" entry that never mounts would get stuck).\n if (index === 0) {\n set(state.entries.map((entry, i) => (i === 0 ? { ...entry, status: \"closing\" } : entry)))\n } else {\n set(state.entries.filter((entry) => entry.id !== id))\n }\n },\n closeAll() {\n // Animate the visible (top) overlay out; drop everything beneath it so\n // nothing is revealed as it closes.\n const [top] = state.entries\n set(top ? [{ ...top, status: \"closing\" }] : [])\n },\n remove(id) {\n if (!state.entries.some((entry) => entry.id === id)) return\n set(state.entries.filter((entry) => entry.id !== id))\n },\n has(id) {\n return state.entries.some((entry) => entry.id === id)\n },\n }\n}\n","\"use client\"\n\nimport { customAlphabet } from \"nanoid\"\nimport { type ReactNode, useMemo, useSyncExternalStore } from \"react\"\nimport { devWarn } from \"../../lib/dev-warn\"\nimport { OverlayRenderer } from \"./renderer\"\nimport { createOverlayStore } from \"./store\"\nimport type {\n ConfirmLabels,\n ConfirmOverlayInput,\n ContentOverlayInput,\n DrawerSurfaceOptions,\n ModalSurfaceOptions,\n OverlayEntry,\n OverlayId,\n OverlayRegistry,\n OverlaySurface,\n ParamsOf,\n SurfaceInput,\n SurfaceOptions,\n} from \"./types\"\n\n// Create a generator using readable letters & numbers, limited to a short length\nconst nanoid = customAlphabet(\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\", 8)\n/** Mint a branded `OverlayId` (the one place a plain string becomes an id). */\nconst generateShortId = (): OverlayId => nanoid() as OverlayId\n\n/** Keys consumed by the manager itself — everything else is a surface option. */\nconst NON_SURFACE_KEYS = new Set<string>([\n \"surface\",\n \"children\",\n \"key\",\n \"params\",\n \"labels\",\n \"confirmProps\",\n \"cancelProps\",\n \"onConfirm\",\n \"onCancel\",\n \"closeOnConfirm\",\n \"closeOnCancel\",\n])\n\nconst pickSurface = (input: Record<string, unknown>): Record<string, unknown> => {\n const out: Record<string, unknown> = {}\n for (const key in input) {\n if (!NON_SURFACE_KEYS.has(key)) out[key] = input[key]\n }\n return out\n}\n\nconst mergeParams = <R extends OverlayRegistry, K extends keyof R & string>(\n a: ParamsOf<R, K> | undefined,\n b: ParamsOf<R, K> | undefined,\n) => (a || b ? { ...a, ...b } : undefined)\n\nexport interface CreateOverlaysConfig<R extends OverlayRegistry = OverlayRegistry> {\n /** Registered context-overlay components, keyed by string. */\n registry?: R\n /** Default confirm/cancel labels. */\n labels?: ConfirmLabels\n /** Surface options merged under every modal. */\n modalProps?: Partial<ModalSurfaceOptions>\n /** Surface options merged under every drawer. */\n drawerProps?: Partial<DrawerSurfaceOptions>\n /** Portal container shared by all overlays. */\n container?: HTMLElement | null\n}\n\ntype OpenContextInput<R extends OverlayRegistry, K extends keyof R & string> = {\n key: K\n params: ParamsOf<R, K>\n} & SurfaceInput\n\nexport interface OverlayApi<R extends OverlayRegistry = OverlayRegistry> {\n /** Open an overlay with free-form content. Returns its id. */\n open: (input: ContentOverlayInput) => OverlayId\n /** Open a confirm/cancel overlay (alertdialog by default). */\n openConfirm: (input: ConfirmOverlayInput) => OverlayId\n /** Open a registered context overlay with typed `params`. */\n openContext: <K extends keyof R & string>(input: OpenContextInput<R, K>) => OverlayId\n /** Sugar for `open({ ...input, surface: \"drawer\" })`. */\n openDrawer: (input: { children: ReactNode } & DrawerSurfaceOptions) => OverlayId\n close: (id: OverlayId) => void\n closeAll: () => void\n /** Patch an open overlay's surface options (title, size, …). */\n update: <K extends keyof R & string>(\n id: OverlayId,\n patch: Partial<SurfaceOptions & { params: ParamsOf<R, K> }>,\n ) => void\n /** Patch a context overlay's `params`. */\n updateContext: <K extends keyof R & string>(id: OverlayId, params: ParamsOf<R, K>) => void\n}\n\n/**\n * Reactive return of `useOverlays()` — `[entries, handlers]`, à la `useState`.\n * `entries` is typed against the registry, so context entries narrow on\n * `key` and expose typed `params`.\n */\nexport type UseOverlaysReturn<R extends OverlayRegistry = OverlayRegistry> = readonly [\n OverlayEntry<R>[],\n OverlayApi<R>,\n]\n\nexport interface OverlayHandle<R extends OverlayRegistry = OverlayRegistry> {\n overlays: OverlayApi<R>\n OverlaysProvider: () => React.JSX.Element\n useOverlays: () => UseOverlaysReturn<R>\n}\n\n/**\n * `createOverlays(config)` — the imperative overlays manager (modals + drawers).\n *\n * Returns a bound `overlays` object (callable from anywhere: event handlers,\n * utils), an `<OverlaysProvider />` renderer to mount once near the app root,\n * and a `useOverlays()` hook.\n *\n * Children is a bit weird in it's handling as it's not strictly a surface prop.\n * Might need to change later.\n *\n * Modelled on Ark's `createToaster`, but typed via generics\n * so registered context overlays are type-checked WITHOUT a `declare module` augmentation:\n * ```tsx\n * export const { overlays, OverlaysProvider } = createOverlays({\n * registry: { deleteUser: DeleteUserModal }, // ContextOverlayProps<{ userId }>\n * labels: { confirm: \"Confirm\", cancel: \"Cancel\" },\n * });\n *\n * overlays.openContext({ key: \"deleteUser\", params: { userId: \"42\" } });\n * // ^ checked against DeleteUserModal's props\n * ```\n */\n\n// biome-ignore lint/suspicious/noExplicitAny: We want genericity here\nexport function createOverlays<const R extends OverlayRegistry<any> = OverlayRegistry>(\n config: CreateOverlaysConfig<R> = {},\n): OverlayHandle<R> {\n const store = createOverlayStore()\n const defaultLabels: ConfirmLabels = config.labels ?? {\n confirm: \"Confirm\",\n cancel: \"Cancel\",\n }\n\n const mergeSurface = (\n surface: OverlaySurface,\n input: Record<string, unknown>,\n ): SurfaceOptions => {\n const defaults = surface === \"drawer\" ? config.drawerProps : config.modalProps\n return {\n container: config.container ?? undefined,\n ...defaults,\n ...pickSurface(input),\n } as SurfaceOptions\n }\n\n const controller: OverlayApi<R> = {\n open(input) {\n const surface: OverlaySurface = input.surface ?? \"modal\"\n return store.open({\n id: generateShortId(),\n status: \"open\",\n kind: \"content\",\n surface,\n surfaceOptions: mergeSurface(surface, input),\n children: input.children,\n // `surface` is a runtime value, so TS can't correlate it with the\n // discriminated `surfaceOptions`; the runtime guarantees they match.\n } as OverlayEntry)\n },\n openDrawer(input) {\n return controller.open({\n ...input,\n surface: \"drawer\",\n } as ContentOverlayInput)\n },\n openConfirm(input) {\n const surface: OverlaySurface = input.surface ?? \"modal\"\n return store.open({\n id: generateShortId(),\n status: \"open\",\n kind: \"confirm\",\n surface,\n surfaceOptions: {\n role: \"alertdialog\",\n ...mergeSurface(surface, input),\n } as SurfaceOptions,\n children: input.children,\n labels: { ...defaultLabels, ...input.labels },\n confirmProps: input.confirmProps,\n cancelProps: input.cancelProps,\n onConfirm: input.onConfirm,\n onCancel: input.onCancel,\n closeOnConfirm: input.closeOnConfirm ?? true,\n closeOnCancel: input.closeOnCancel ?? true,\n } as OverlayEntry)\n },\n openContext(input) {\n const surface: OverlaySurface = input.surface ?? \"modal\"\n return store.open({\n id: generateShortId(),\n status: \"open\",\n kind: \"context\",\n surface,\n surfaceOptions: mergeSurface(surface, input),\n key: input.key,\n params: input.params,\n } as OverlayEntry)\n },\n close(id) {\n store.close(id)\n },\n closeAll() {\n store.closeAll()\n },\n update(id, patch) {\n const entry = store.getSnapshot().entries.find((e) => e.id === id)\n if (!entry) {\n devWarn(`[overlays] update: no open overlay with id \"${id}\".`)\n return\n }\n // `children` and `params` belong to the entry, not to the surface: only\n // the rest reaches the Modal/Drawer props. A patch that leaves\n // `children` out keeps the current content.\n const { children, params, ...surface } = patch\n store.edit(id, {\n ...(\"children\" in patch && { children }),\n params: mergeParams(entry.params, params),\n surfaceOptions: { ...entry.surfaceOptions, ...surface },\n })\n },\n updateContext(id, params) {\n const entry = store.getSnapshot().entries.find((e) => e.id === id)\n if (entry?.kind !== \"context\") {\n devWarn(`[overlays] updateContext: no open context overlay with id \"${id}\".`)\n return\n }\n store.edit(id, { params: { ...entry.params, ...params } })\n },\n }\n\n const OverlaysProvider = () => {\n // Pin the generic to `R`: the `?? {}` fallback would otherwise widen\n // inference to `{}`, breaking the `OverlayApi<R>` → `OverlayController` match.\n return (\n <OverlayRenderer<R>\n store={store}\n registry={config.registry ?? ({} as R)}\n controller={controller}\n />\n )\n }\n\n const useOverlays = (): UseOverlaysReturn<R> => {\n const { entries } = useSyncExternalStore(\n store.subscribe,\n store.getSnapshot,\n store.getServerSnapshot,\n )\n // Store entries are loose (`OverlayEntry`); `openContext` guarantees every\n // context entry's key/params match the registry, so present them as `R`.\n return useMemo(() => [entries as OverlayEntry<R>[], controller] as const, [entries])\n }\n\n return { overlays: controller, OverlaysProvider, useOverlays }\n}\n"]}
1
+ {"version":3,"sources":["../../../src/components/overlays/renderer.tsx","../../../src/components/overlays/store.ts","../../../src/components/overlays/create-overlays.tsx"],"names":["entry","jsx","useSyncExternalStore"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0CO,SAAS,eAAA,CAA6D;AAAA,EAC3E,KAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA,EAAY;AACd,CAAA,EAA4B;AAC1B,EAAA,MAAM,EAAE,SAAQ,GAAI,oBAAA;AAAA,IAClB,KAAA,CAAM,SAAA;AAAA,IACN,KAAA,CAAM,WAAA;AAAA,IACN,KAAA,CAAM;AAAA,GACR;AAEA,EAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,EAAA,CAAG,CAAC,CAAA;AAC3B,EAAA,MAAM,eAAe,OAAA,CAAQ,IAAA,CAAK,CAAC,KAAA,KAAU,KAAA,CAAM,WAAW,MAAM,CAAA;AAEpE,EAAA,uBACE,IAAA,CAAA,QAAA,EAAA,EACG,QAAA,EAAA;AAAA,IAAA,MAAA,EAAQ,eAAe,YAAA,KAAiB,KAAA,oBAAS,GAAA,CAAC,eAAA,EAAA,EAAgB,SAAS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\"\n\nimport { Portal } from \"@ark-ui/react/portal\"\nimport { Presence } from \"@ark-ui/react/presence\"\nimport { useState, useSyncExternalStore } from \"react\"\nimport { match } from \"ts-pattern\"\nimport { cn } from \"../../lib/cn\"\nimport { devWarn } from \"../../lib/dev-warn\"\nimport { Button } from \"../button/button\"\nimport { Drawer } from \"../drawer/drawer\"\nimport { Modal } from \"../modal/modal\"\nimport type { OverlayStore } from \"./store\"\nimport type { OverlayEntry, OverlayId, OverlayRegistry, ParamsOf, SurfaceOptions } from \"./types\"\n\n/** Minimal slice of the imperative API the renderer needs at runtime. */\nexport interface OverlayController<R extends OverlayRegistry> {\n close: (id: OverlayId) => void\n update: (\n id: OverlayId,\n patch: Partial<SurfaceOptions & { params: ParamsOf<R, keyof R & string> }>,\n ) => void\n}\n\ninterface OverlayRendererProps<R extends OverlayRegistry> {\n store: OverlayStore\n registry: R\n controller: OverlayController<R>\n}\n\n/**\n * Renders the overlay stack as a SINGLE visible overlay at a time.\n *\n * The store keeps the whole stack, but only the top entry (`entries[0]`, since\n * `open` prepends) is rendered, so there's ever one overlay on screen. Closing\n * the top reveals the next; entries beneath are retained but unmounted while\n * covered. This is the single seam to change if we ever render the stack with\n * depth/parallax effects.\n *\n * The backdrop is hoisted here and shared by the whole stack: it stays mounted\n * across swaps and only fades when the last *open* overlay begins closing, so\n * multi-step transitions don't blink a backdrop in and out.\n */\nexport function OverlayRenderer<R extends OverlayRegistry = OverlayRegistry>({\n store,\n registry,\n controller: modals,\n}: OverlayRendererProps<R>) {\n const { entries } = useSyncExternalStore(\n store.subscribe,\n store.getSnapshot,\n store.getServerSnapshot,\n )\n\n const active = entries.at(0)\n const backdropOpen = entries.some((entry) => entry.status === \"open\")\n\n return (\n <>\n {active?.surfaceOptions.withBackdrop !== false && <OverlayBackdrop present={backdropOpen} />}\n {active && (\n <OverlayItem\n key={active.id}\n entry={active}\n store={store}\n registry={registry}\n modals={modals}\n />\n )}\n </>\n )\n}\n\nconst overlayBackdrop = [\n \"fixed inset-0 z-[calc(var(--modal-z,150)-1)] bg-black/50 backdrop-blur-lg select-none pointer-events-auto\",\n \"data-[state=open]:animate-fade-in\",\n \"data-[state=closed]:animate-fade-out\",\n]\n\n/**\n * The one dimming layer behind whatever overlay is active. Driven by Ark's\n * `Presence` so it fades in on the first open and out after the last close,\n * using the same keyframes as the per-component backdrops.\n */\nfunction OverlayBackdrop({ present }: { present: boolean }) {\n return (\n <Portal>\n <Presence present={present} lazyMount unmountOnExit className={cn(overlayBackdrop)} />\n </Portal>\n )\n}\n\nfunction OverlayItem<R extends OverlayRegistry = OverlayRegistry>({\n entry,\n store,\n registry,\n modals,\n}: {\n entry: OverlayEntry\n store: OverlayStore\n registry: OverlayRegistry\n modals: OverlayController<R>\n}) {\n const open = entry.status === \"open\"\n\n // The manager owns the lifecycle (open/close/exit) and draws a single shared\n // backdrop, so `withBackdrop: false` here and `common` is spread LAST to win\n // over any per-call surface options.\n const common = {\n open,\n withBackdrop: false,\n onOpenChange: (next: boolean) => {\n if (!next) store.close(entry.id)\n },\n onExitComplete: () => store.remove(entry.id),\n }\n\n const body = <OverlayBody entry={entry} registry={registry} modals={modals} />\n\n return match(entry)\n .with({ surface: \"drawer\" }, ({ surfaceOptions }) => (\n <Drawer {...surfaceOptions} {...common}>\n {body}\n </Drawer>\n ))\n .with({ surface: \"modal\" }, ({ surfaceOptions }) => (\n <Modal {...surfaceOptions} {...common}>\n {body}\n </Modal>\n ))\n .exhaustive()\n}\n\nfunction OverlayBody<R extends OverlayRegistry = OverlayRegistry>({\n entry,\n registry,\n modals,\n}: {\n entry: OverlayEntry\n registry: OverlayRegistry\n modals: OverlayController<R>\n}) {\n return match(entry)\n .with({ kind: \"content\" }, ({ children }) => <>{children}</>)\n .with({ kind: \"confirm\" }, (entry) => (\n <>\n {entry.children}\n <ConfirmActions entry={entry} modals={modals} />\n </>\n ))\n .with({ kind: \"context\" }, (entry) => {\n const Component = registry[entry.key]\n if (!Component) {\n devWarn(\n `[overlays] No context overlay registered for key \"${entry.key}\". ` +\n `Pass it to createOverlays({ registry: { ${entry.key}: … } }).`,\n )\n return null\n }\n return (\n <Component\n id={entry.id}\n params={entry.params}\n context={{\n close: () => modals.close(entry.id),\n update: (patch) => modals.update(entry.id, patch as never), // Cast to remove surface missmatch impossibility\n }}\n />\n )\n })\n .exhaustive()\n}\n\nfunction ConfirmActions<R extends OverlayRegistry = OverlayRegistry>({\n entry,\n modals,\n}: {\n entry: Extract<OverlayEntry, { kind: \"confirm\" }>\n modals: OverlayController<R>\n}) {\n const [loading, setLoading] = useState(false)\n\n const handleCancel = () => {\n entry.onCancel?.()\n if (entry.closeOnCancel) modals.close(entry.id)\n }\n\n const handleConfirm = async () => {\n setLoading(true)\n try {\n await entry.onConfirm?.()\n if (entry.closeOnConfirm) modals.close(entry.id)\n } finally {\n setLoading(false)\n }\n }\n\n return (\n <div className=\"mt-6 flex items-center justify-end gap-2\">\n <Button variant=\"light\" color=\"neutral\" onClick={handleCancel} {...entry.cancelProps}>\n {entry.labels.cancel}\n </Button>\n <Button loading={loading} onClick={handleConfirm} {...entry.confirmProps}>\n {entry.labels.confirm}\n </Button>\n </div>\n )\n}\n","import type { OverlayEntry, OverlayId } from \"./types\"\n\n/**\n * Framework-agnostic overlay store — a tiny vanilla pub/sub modelled on Ark's\n * `createToaster`. Holds the open-overlay stack; the React renderer subscribes\n * via `useSyncExternalStore`. No React here, so it's safe to import anywhere\n * (event handlers, utils) and the imperative `modals` object wraps its\n * mutators.\n *\n * Every mutation produces a fresh `state` object and a fresh `entries` array,\n * so `getSnapshot` returns a stable reference between mutations.\n * the contract `useSyncExternalStore` relies on to avoid tearing / render loops.\n */\n\nexport interface OverlayStoreState {\n entries: OverlayEntry[]\n}\n\nexport interface OverlayStore {\n subscribe: (listener: () => void) => () => void\n getSnapshot: () => OverlayStoreState\n getServerSnapshot: () => OverlayStoreState\n /** Append an entry and return its id. */\n open: (entry: OverlayEntry) => OverlayId\n /** Shallow-merge fields into an existing entry. */\n edit: (id: OverlayId, partial: Partial<OverlayEntry>) => void\n /** Flip an entry to `closing` so its wrapper animates out. */\n close: (id: OverlayId) => void\n /** Flip every entry to `closing`. */\n closeAll: () => void\n /** Hard-remove an entry (called once its exit animation completes). */\n remove: (id: OverlayId) => void\n has: (id: OverlayId) => boolean\n}\n\n/** Frozen, module-stable empty stack for SSR — overlays are runtime-only, so\n * the server snapshot is always empty and matches the client's first render. */\nconst SERVER_SNAPSHOT: OverlayStoreState = Object.freeze({ entries: [] })\n\nexport function createOverlayStore(): OverlayStore {\n let state: OverlayStoreState = { entries: [] }\n const listeners = new Set<() => void>()\n\n const emit = () => {\n for (const listener of listeners) listener()\n }\n const set = (entries: OverlayEntry[]) => {\n state = { entries }\n emit()\n }\n\n return {\n subscribe(listener) {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n },\n getSnapshot() {\n return state\n },\n getServerSnapshot() {\n return SERVER_SNAPSHOT\n },\n open(entry) {\n // Only the top entry can be `closing` (`close`/`closeAll` drop covered\n // ones). Covering it unmounts it before its exit animation can fire\n // `onExitComplete`, so it would never be removed: drop it here instead.\n set([entry, ...state.entries.filter((e) => e.status !== \"closing\")])\n return entry.id\n },\n edit(id, partial) {\n set(\n state.entries.map((entry) =>\n entry.id === id ? ({ ...entry, ...partial } as OverlayEntry) : entry,\n ),\n )\n },\n close(id) {\n const index = state.entries.findIndex((entry) => entry.id === id)\n if (index === -1) return\n // Only the active (top) overlay is on screen, so only it animates out —\n // its exit fires `onExitComplete`, which removes it and reveals the next.\n // A covered entry has no mounted element to animate, so drop it now\n // (otherwise a \"closing\" entry that never mounts would get stuck).\n if (index === 0) {\n set(state.entries.map((entry, i) => (i === 0 ? { ...entry, status: \"closing\" } : entry)))\n } else {\n set(state.entries.filter((entry) => entry.id !== id))\n }\n },\n closeAll() {\n // Animate the visible (top) overlay out; drop everything beneath it so\n // nothing is revealed as it closes.\n const [top] = state.entries\n set(top ? [{ ...top, status: \"closing\" }] : [])\n },\n remove(id) {\n if (!state.entries.some((entry) => entry.id === id)) return\n set(state.entries.filter((entry) => entry.id !== id))\n },\n has(id) {\n return state.entries.some((entry) => entry.id === id)\n },\n }\n}\n","\"use client\"\n\nimport { customAlphabet } from \"nanoid\"\nimport { type ReactNode, useMemo, useSyncExternalStore } from \"react\"\nimport { devWarn } from \"../../lib/dev-warn\"\nimport { OverlayRenderer } from \"./renderer\"\nimport { createOverlayStore } from \"./store\"\nimport type {\n ConfirmLabels,\n ConfirmOverlayInput,\n ContentOverlayInput,\n DrawerSurfaceOptions,\n ModalSurfaceOptions,\n OverlayEntry,\n OverlayId,\n OverlayRegistry,\n OverlaySurface,\n ParamsOf,\n SurfaceInput,\n SurfaceOptions,\n} from \"./types\"\n\n// Create a generator using readable letters & numbers, limited to a short length\nconst nanoid = customAlphabet(\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\", 8)\n/** Mint a branded `OverlayId` (the one place a plain string becomes an id). */\nconst generateShortId = (): OverlayId => nanoid() as OverlayId\n\n/** Keys consumed by the manager itself — everything else is a surface option. */\nconst NON_SURFACE_KEYS = new Set<string>([\n \"surface\",\n \"children\",\n \"key\",\n \"params\",\n \"labels\",\n \"confirmProps\",\n \"cancelProps\",\n \"onConfirm\",\n \"onCancel\",\n \"closeOnConfirm\",\n \"closeOnCancel\",\n])\n\nconst pickSurface = (input: Record<string, unknown>): Record<string, unknown> => {\n const out: Record<string, unknown> = {}\n for (const key in input) {\n if (!NON_SURFACE_KEYS.has(key)) out[key] = input[key]\n }\n return out\n}\n\nconst mergeParams = <R extends OverlayRegistry, K extends keyof R & string>(\n a: ParamsOf<R, K> | undefined,\n b: ParamsOf<R, K> | undefined,\n) => (a || b ? { ...a, ...b } : undefined)\n\nexport interface CreateOverlaysConfig<R extends OverlayRegistry = OverlayRegistry> {\n /** Registered context-overlay components, keyed by string. */\n registry?: R\n /** Default confirm/cancel labels. */\n labels?: ConfirmLabels\n /** Surface options merged under every modal. */\n modalProps?: Partial<ModalSurfaceOptions>\n /** Surface options merged under every drawer. */\n drawerProps?: Partial<DrawerSurfaceOptions>\n /** Portal container shared by all overlays. */\n container?: HTMLElement | null\n}\n\ntype OpenContextInput<R extends OverlayRegistry, K extends keyof R & string> = {\n key: K\n params: ParamsOf<R, K>\n} & SurfaceInput\n\nexport interface OverlayApi<R extends OverlayRegistry = OverlayRegistry> {\n /** Open an overlay with free-form content. Returns its id. */\n open: (input: ContentOverlayInput) => OverlayId\n /** Open a confirm/cancel overlay (alertdialog by default). */\n openConfirm: (input: ConfirmOverlayInput) => OverlayId\n /** Open a registered context overlay with typed `params`. */\n openContext: <K extends keyof R & string>(input: OpenContextInput<R, K>) => OverlayId\n /** Sugar for `open({ ...input, surface: \"drawer\" })`. */\n openDrawer: (input: { children: ReactNode } & DrawerSurfaceOptions) => OverlayId\n close: (id: OverlayId) => void\n closeAll: () => void\n /** Patch an open overlay's surface options (title, size, …). */\n update: <K extends keyof R & string>(\n id: OverlayId,\n patch: Partial<SurfaceOptions & { params: ParamsOf<R, K> }>,\n ) => void\n /** Patch a context overlay's `params`. */\n updateContext: <K extends keyof R & string>(id: OverlayId, params: ParamsOf<R, K>) => void\n}\n\n/**\n * Reactive return of `useOverlays()` — `[entries, handlers]`, à la `useState`.\n * `entries` is typed against the registry, so context entries narrow on\n * `key` and expose typed `params`.\n */\nexport type UseOverlaysReturn<R extends OverlayRegistry = OverlayRegistry> = readonly [\n OverlayEntry<R>[],\n OverlayApi<R>,\n]\n\nexport interface OverlayHandle<R extends OverlayRegistry = OverlayRegistry> {\n overlays: OverlayApi<R>\n OverlaysProvider: () => React.JSX.Element\n useOverlays: () => UseOverlaysReturn<R>\n}\n\n/**\n * `createOverlays(config)` — the imperative overlays manager (modals + drawers).\n *\n * Returns a bound `overlays` object (callable from anywhere: event handlers,\n * utils), an `<OverlaysProvider />` renderer to mount once near the app root,\n * and a `useOverlays()` hook.\n *\n * Children is a bit weird in it's handling as it's not strictly a surface prop.\n * Might need to change later.\n *\n * Modelled on Ark's `createToaster`, but typed via generics\n * so registered context overlays are type-checked WITHOUT a `declare module` augmentation:\n * ```tsx\n * export const { overlays, OverlaysProvider } = createOverlays({\n * registry: { deleteUser: DeleteUserModal }, // ContextOverlayProps<{ userId }>\n * labels: { confirm: \"Confirm\", cancel: \"Cancel\" },\n * });\n *\n * overlays.openContext({ key: \"deleteUser\", params: { userId: \"42\" } });\n * // ^ checked against DeleteUserModal's props\n * ```\n */\n\n// biome-ignore lint/suspicious/noExplicitAny: We want genericity here\nexport function createOverlays<const R extends OverlayRegistry<any> = OverlayRegistry>(\n config: CreateOverlaysConfig<R> = {},\n): OverlayHandle<R> {\n const store = createOverlayStore()\n const defaultLabels: ConfirmLabels = config.labels ?? {\n confirm: \"Confirm\",\n cancel: \"Cancel\",\n }\n\n const mergeSurface = (\n surface: OverlaySurface,\n input: Record<string, unknown>,\n ): SurfaceOptions => {\n const defaults = surface === \"drawer\" ? config.drawerProps : config.modalProps\n return {\n container: config.container ?? undefined,\n ...defaults,\n ...pickSurface(input),\n } as SurfaceOptions\n }\n\n const controller: OverlayApi<R> = {\n open(input) {\n const surface: OverlaySurface = input.surface ?? \"modal\"\n return store.open({\n id: generateShortId(),\n status: \"open\",\n kind: \"content\",\n surface,\n surfaceOptions: mergeSurface(surface, input),\n children: input.children,\n // `surface` is a runtime value, so TS can't correlate it with the\n // discriminated `surfaceOptions`; the runtime guarantees they match.\n } as OverlayEntry)\n },\n openDrawer(input) {\n return controller.open({\n ...input,\n surface: \"drawer\",\n } as ContentOverlayInput)\n },\n openConfirm(input) {\n const surface: OverlaySurface = input.surface ?? \"modal\"\n return store.open({\n id: generateShortId(),\n status: \"open\",\n kind: \"confirm\",\n surface,\n surfaceOptions: {\n role: \"alertdialog\",\n ...mergeSurface(surface, input),\n } as SurfaceOptions,\n children: input.children,\n labels: { ...defaultLabels, ...input.labels },\n confirmProps: input.confirmProps,\n cancelProps: input.cancelProps,\n onConfirm: input.onConfirm,\n onCancel: input.onCancel,\n closeOnConfirm: input.closeOnConfirm ?? true,\n closeOnCancel: input.closeOnCancel ?? true,\n } as OverlayEntry)\n },\n openContext(input) {\n const surface: OverlaySurface = input.surface ?? \"modal\"\n return store.open({\n id: generateShortId(),\n status: \"open\",\n kind: \"context\",\n surface,\n surfaceOptions: mergeSurface(surface, input),\n key: input.key,\n params: input.params,\n } as OverlayEntry)\n },\n close(id) {\n store.close(id)\n },\n closeAll() {\n store.closeAll()\n },\n update(id, patch) {\n const entry = store.getSnapshot().entries.find((e) => e.id === id)\n if (!entry) {\n devWarn(`[overlays] update: no open overlay with id \"${id}\".`)\n return\n }\n // `children` and `params` belong to the entry, not to the surface: only\n // the rest reaches the Modal/Drawer props. A patch that leaves\n // `children` out keeps the current content.\n const { children, params, ...surface } = patch\n store.edit(id, {\n ...(\"children\" in patch && { children }),\n params: mergeParams(entry.params, params),\n surfaceOptions: { ...entry.surfaceOptions, ...surface },\n })\n },\n updateContext(id, params) {\n const entry = store.getSnapshot().entries.find((e) => e.id === id)\n if (entry?.kind !== \"context\") {\n devWarn(`[overlays] updateContext: no open context overlay with id \"${id}\".`)\n return\n }\n store.edit(id, { params: { ...entry.params, ...params } })\n },\n }\n\n const OverlaysProvider = () => {\n // Pin the generic to `R`: the `?? {}` fallback would otherwise widen\n // inference to `{}`, breaking the `OverlayApi<R>` → `OverlayController` match.\n return (\n <OverlayRenderer<R>\n store={store}\n registry={config.registry ?? ({} as R)}\n controller={controller}\n />\n )\n }\n\n const useOverlays = (): UseOverlaysReturn<R> => {\n const { entries } = useSyncExternalStore(\n store.subscribe,\n store.getSnapshot,\n store.getServerSnapshot,\n )\n // Store entries are loose (`OverlayEntry`); `openContext` guarantees every\n // context entry's key/params match the registry, so present them as `R`.\n return useMemo(() => [entries as OverlayEntry<R>[], controller] as const, [entries])\n }\n\n return { overlays: controller, OverlaysProvider, useOverlays }\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  "use client";
2
- import { useImageCropperContext, ImageCropper } from '../../chunk-Y2G47ARQ.js';
2
+ import { useImageCropperContext, ImageCropper } from '../../chunk-TGGNSSOJ.js';
3
3
  import '../../chunk-AKXALCUN.js';
4
- import { FileTrigger } from '../../chunk-OVT2KZHY.js';
5
- import { Camera, useCamera, imageFile } from '../../chunk-5H5YOPCF.js';
4
+ import { FileTrigger } from '../../chunk-3KARNPW4.js';
5
+ import { Camera, useCamera, imageFile } from '../../chunk-I53TMAV2.js';
6
6
  import '../../chunk-HX3LNK26.js';
7
7
  import '../../chunk-K6YASO4L.js';
8
8
  import '../../chunk-IA6DCC3N.js';
@@ -13,9 +13,9 @@ import '../../chunk-QRNQQIQM.js';
13
13
  import '../../chunk-5FDOOG4J.js';
14
14
  import '../../chunk-I4B3N3UX.js';
15
15
  import '../../chunk-X6DESK37.js';
16
- import '../../chunk-ZVECQBGG.js';
16
+ import '../../chunk-KNGSO7A3.js';
17
17
  import '../../chunk-SKPM2FRX.js';
18
- import { Button } from '../../chunk-SCXXJDKQ.js';
18
+ import { Button } from '../../chunk-SP6LCCTZ.js';
19
19
  import { useObjectUrl } from '../../chunk-WERJ44ZN.js';
20
20
  import '../../chunk-EIBDLRAR.js';
21
21
  import '../../chunk-WG3BCIU4.js';
@@ -28,13 +28,14 @@ import '../../chunk-RKCUXOU2.js';
28
28
  import '../../chunk-HWBFRDX7.js';
29
29
  import '../../chunk-V6PY7C6S.js';
30
30
  import '../../chunk-SLUOF7XW.js';
31
- import '../../chunk-BMEJBY6H.js';
31
+ import '../../chunk-B5YHYI7E.js';
32
+ import '../../chunk-6B2GNPJP.js';
32
33
  import '../../chunk-LIZWCWED.js';
33
34
  import '../../chunk-PMUCGFY5.js';
34
35
  import { useIsomorphicLayoutEffect } from '../../chunk-BUIHQJGE.js';
35
36
  import '../../chunk-6YNLRQ25.js';
36
37
  import { mergeIcons, iconStroke } from '../../chunk-XXOR34T4.js';
37
- import '../../chunk-D2QIPQ74.js';
38
+ import '../../chunk-W3XX7BYT.js';
38
39
  import { composeChildren } from '../../chunk-R5LYFTHA.js';
39
40
  import { props } from '../../chunk-WYCMIIRR.js';
40
41
  import '../../chunk-C6NVU4F7.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/photo-capture/photo-capture-machine.ts","../../../src/components/photo-capture/use-photo-capture.ts","../../../src/components/photo-capture/photo-capture.tsx"],"names":["match","crop","CameraIcon","useRef"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDO,IAAM,wBAAA,GAA8C,EAAE,IAAA,EAAM,QAAA,EAAU,OAAO,KAAA,EAAM;AAE1F,IAAM,IAAA,GAAO,CAAC,KAAA,EAAa,MAAA,MAAmD;AAAA,EAC5E,IAAA,EAAM,MAAA;AAAA,EACN,KAAA,EAAO,IAAA;AAAA,EACP,KAAA;AAAA,EACA,MAAA;AAAA,EACA,IAAA,EAAM,KAAA;AAAA,EACN,MAAA,EAAQ;AACV,CAAA,CAAA;AAMO,IAAM,qBAAqB,CAChC,KAAA,EACA,UAEA,KAAA,CAAM,KAAK,EACR,UAAA,EAA8B,CAC9B,KAAK,EAAE,IAAA,EAAM,QAAO,EAAG,MAAO,MAAM,IAAA,KAAS,QAAA,GAAW,EAAE,IAAA,EAAM,MAAA,EAAQ,OAAO,IAAA,EAAK,GAAI,KAAM,CAAA,CAC9F,IAAA,CAAK,EAAE,IAAA,EAAM,MAAA,IAAU,CAAC,EAAE,OAAM,KAAO,KAAA,CAAM,SAAS,MAAA,GAAS,IAAA,CAAK,OAAO,QAAQ,CAAA,GAAI,KAAM,CAAA,CAC7F,IAAA;AAAA,EAAK,EAAE,MAAM,MAAA,EAAO;AAAA,EAAG,CAAC,EAAE,KAAA,EAAO,MAAA,EAAO;AAAA;AAAA,IAEvC,KAAA,CAAM,SAAS,MAAA,IAAU,KAAA,CAAM,OAAO,KAAA,GAAQ,IAAA,CAAK,OAAO,MAAM;AAAA;AAClE,CAAA,CACC,IAAA;AAAA,EAAK,EAAE,MAAM,QAAA,EAAS;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,gBAAA;AAAA,EACN,IAAA,EAAM,gBAAA;AAAA,EACN,MAAA,EAAQ,kBAAA;AAAA,EACR,OAAA,EAAS;AACX,CAAC","file":"index.js","sourcesContent":["import { match, P } from \"ts-pattern\"\n\n/**\n * PhotoCapture's steps, kept pure so every transition is unit-tested without\n * a camera or a canvas: `usePhotoCapture` feeds it what the parts report and\n * renders whatever it returns. The camera and the cropper keep their own\n * state; this only knows which of them is on screen, and with which photo.\n */\n\n/**\n * - `source`: the choice, camera or file. The first step, and where a used photo returns to.\n * - `live`: the in-page camera.\n * - `crop`: the photo, taken or picked, in the cropper, until it's used or retaken.\n */\nexport type PhotoCaptureStep = \"source\" | \"live\" | \"crop\"\n\n/**\n * Where the photo in the cropper came from, which decides what \"retake\"\n * means: the in-page camera again, the phone's camera app again, or another\n * file.\n */\nexport type PhotoCaptureOrigin = \"camera\" | \"native\" | \"file\"\n\nexport type PhotoCaptureState =\n | {\n step: \"source\"\n /** Whether a step was ever left: `false` on mount, so nothing steals focus as the page loads. */\n moved: boolean\n }\n | { step: \"live\"; moved: true }\n | {\n step: \"crop\"\n moved: true\n photo: File\n origin: PhotoCaptureOrigin\n /** The crop is being exported. */\n busy: boolean\n /** The last export failed. */\n failed: boolean\n }\n\nexport type PhotoCaptureEvent =\n /** \"Take photo\", in the page: the camera opens. */\n | { type: \"open\" }\n /** The shutter's photo. */\n | { type: \"take\"; photo: File }\n /** A file from the picker, or from the phone's camera app. */\n | { type: \"pick\"; photo: File; origin: Exclude<PhotoCaptureOrigin, \"camera\"> }\n /** Back to the in-page camera, for another shot. */\n | { type: \"retake\" }\n /** \"Use photo\": the export starts. */\n | { type: \"confirm\" }\n | { type: \"fail\" }\n /** The File went out: back to the start. */\n | { type: \"done\" }\n | { type: \"reset\" }\n\nexport const initialPhotoCaptureState: PhotoCaptureState = { step: \"source\", moved: false }\n\nconst crop = (photo: File, origin: PhotoCaptureOrigin): PhotoCaptureState => ({\n step: \"crop\",\n moved: true,\n photo,\n origin,\n busy: false,\n failed: false,\n})\n\n/**\n * The next state. An event that doesn't apply to the current step (a late\n * shutter after a file was picked, a double \"Use photo\") leaves it as it is.\n */\nexport const reducePhotoCapture = (\n state: PhotoCaptureState,\n event: PhotoCaptureEvent,\n): PhotoCaptureState =>\n match(event)\n .returnType<PhotoCaptureState>()\n .with({ type: \"open\" }, () => (state.step === \"source\" ? { step: \"live\", moved: true } : state))\n .with({ type: \"take\" }, ({ photo }) => (state.step === \"live\" ? crop(photo, \"camera\") : state))\n .with({ type: \"pick\" }, ({ photo, origin }) =>\n // From any step, but never over an export in flight.\n state.step === \"crop\" && state.busy ? state : crop(photo, origin),\n )\n .with({ type: \"retake\" }, () =>\n match(state)\n .returnType<PhotoCaptureState>()\n .with({ step: \"crop\", origin: \"camera\", busy: false }, () => ({\n step: \"live\",\n moved: true,\n }))\n .otherwise(() => state),\n )\n .with({ type: \"confirm\" }, () =>\n match(state)\n .with({ step: \"crop\", busy: false }, (s) => ({ ...s, busy: true, failed: false }))\n .otherwise(() => state),\n )\n .with({ type: \"fail\" }, () =>\n match(state)\n .with({ step: \"crop\", busy: true }, (s) => ({ ...s, busy: false, failed: true }))\n .otherwise(() => state),\n )\n .with({ type: \"done\" }, () => (state.step === \"crop\" ? { step: \"source\", moved: true } : state))\n .with({ type: \"reset\" }, () =>\n match(state)\n .returnType<PhotoCaptureState>()\n .with({ step: \"crop\", busy: true }, () => state)\n .with({ step: P.union(\"live\", \"crop\") }, () => ({ step: \"source\", moved: true }))\n .otherwise(() => state),\n )\n .exhaustive()\n","\"use client\"\n\nimport { useCallback, useReducer, useRef } from \"react\"\nimport { match } from \"ts-pattern\"\nimport { imageFile } from \"../../lib/image-file\"\nimport type { Ratio } from \"../../lib/ratio\"\nimport { useIsomorphicLayoutEffect } from \"../../lib/use-isomorphic-layout-effect\"\nimport { useMediaQuery } from \"../../lib/use-media-query\"\nimport type { CameraFacing, CameraResolution } from \"../camera/camera-machine\"\nimport { type UseCameraResult, useCamera } from \"../camera/use-camera\"\nimport {\n initialPhotoCaptureState,\n type PhotoCaptureOrigin,\n type PhotoCaptureStep,\n reducePhotoCapture,\n} from \"./photo-capture-machine\"\n\n/**\n * How the photo is taken:\n * - `live`: the camera in the page, a viewfinder and a shutter.\n * - `native`: the phone's own camera app, through a file input with `capture`. No viewfinder in the page.\n * - `auto`: `native` under a coarse pointer (a phone, a tablet), `live` otherwise.\n */\nexport type PhotoCaptureCamera = \"live\" | \"native\" | \"auto\"\n\nexport type PhotoCaptureOutput = {\n /** The encoding. A browser that can't encode it falls back to PNG, and the File says so. Defaults to `image/jpeg`. */\n type?: string\n /** 0–1, for JPEG and WebP. Defaults to 0.9. */\n quality?: number\n /** The longest side, in px: a larger crop is scaled down to fit, a smaller one is kept as is. */\n size?: number\n}\n\nexport type UsePhotoCaptureOptions = {\n /** Receives the cropped photo once \"Use photo\" is pressed. Nothing is emitted before. */\n onChange?: (file: File) => void\n /** The in-page camera, the phone's camera app, or whichever suits the device. Defaults to `auto`. */\n camera?: PhotoCaptureCamera\n /** The camera to open: the front one (`user`, the default) or the back one. */\n facing?: CameraFacing\n /** The crop's width / height, and the viewfinder's box. Free when unset; a circle is always 1. */\n ratio?: Ratio\n /** The capture size to aim for, for the in-page camera. See `useCamera`. */\n resolution?: CameraResolution\n /** Saves a selfie as the preview shows it, mirrored. Off by default: a saved selfie reads the right way round. */\n mirror?: boolean\n /** The File's encoding and size. */\n output?: PhotoCaptureOutput\n}\n\n/** What `confirm()` hands to the cropper's export: `ImageCropper`'s `getCroppedImage`. */\nexport type PhotoCaptureCrop = (options: {\n type: string\n quality: number\n maxSize?: { width: number; height: number }\n}) => Promise<Blob | string | null>\n\nexport type UsePhotoCaptureResult = {\n step: PhotoCaptureStep\n /** `auto` resolved for this device. */\n mode: \"live\" | \"native\"\n /** The photo in the cropper, taken or picked, before it's cropped. */\n photo: File | null\n /** Where `photo` came from, which decides what a retake means. */\n origin: PhotoCaptureOrigin | null\n /** The crop is being exported. */\n busy: boolean\n /** The last export failed. */\n failed: boolean\n /** Whether a step was ever left, so a part knows to move focus when it appears. */\n moved: boolean\n /** The in-page camera. Lazy: it turns on with `open()`, never on its own. */\n camera: UseCameraResult\n facing: CameraFacing\n ratio: Ratio | undefined\n mirror: boolean\n /** Opens the in-page camera. */\n open: () => void\n /** The shutter's photo: `Camera.Root`'s `onCapture`. */\n take: (photo: File) => void\n /** A picked file (the first of `files`), from the library or, with `native`, the phone's camera app. */\n pick: (files: readonly File[], origin?: Exclude<PhotoCaptureOrigin, \"camera\">) => void\n /** Back to the in-page camera for another shot. */\n retake: () => void\n /** Exports the crop through `crop`, then hands the File to `onChange` and starts over. Resolves the File, or `null` if the export failed. */\n confirm: (crop: PhotoCaptureCrop) => Promise<File | null>\n /** Back to the source step, the camera off. */\n reset: () => void\n}\n\n/**\n * PhotoCapture as plain state plus handlers: which step is on screen, the\n * photo in it, and the in-page camera. The steps are a pure reducer\n * (`reducePhotoCapture`); the camera is `useCamera`, mounted lazily so it\n * never lights up before \"Take photo\"; the crop is whatever `ImageCropper`\n * exports. This hook only wires them together.\n *\n * const flow = usePhotoCapture({ ratio: 1, output: { size: 512 }, onChange: upload })\n * <PhotoCapture.Root flow={flow} shape=\"circle\">…</PhotoCapture.Root>\n *\n * The camera turns off when the photo is taken, when a file is picked\n * instead, on `reset()` and on unmount. Nothing is uploaded: `onChange`\n * gets a File and the rest is yours.\n */\nexport function usePhotoCapture({\n onChange,\n camera: wanted = \"auto\",\n facing = \"user\",\n ratio,\n resolution,\n mirror = false,\n output,\n}: UsePhotoCaptureOptions = {}): UsePhotoCaptureResult {\n const [state, dispatch] = useReducer(reducePhotoCapture, initialPhotoCaptureState)\n const camera = useCamera({ facing, ratio, resolution, lazy: true })\n const coarse = useMediaQuery(\"(pointer: coarse)\")\n const mode = match(wanted)\n .returnType<\"live\" | \"native\">()\n .with(\"auto\", () => (coarse ? \"native\" : \"live\"))\n .otherwise((chosen) => chosen)\n\n // Read when the export resolves, not when it started: the latest callback and encoding.\n const latest = useRef({ onChange, output })\n useIsomorphicLayoutEffect(() => {\n latest.current = { onChange, output }\n })\n\n const { start, stop } = camera\n\n const open = useCallback(() => {\n dispatch({ type: \"open\" })\n void start()\n }, [start])\n\n const take = useCallback((photo: File) => dispatch({ type: \"take\", photo }), [])\n\n const pick = useCallback(\n (files: readonly File[], origin: Exclude<PhotoCaptureOrigin, \"camera\"> = \"file\") => {\n const [photo] = files\n if (!photo) return\n // A file instead of the shot: the camera goes off with the viewfinder.\n stop()\n dispatch({ type: \"pick\", photo, origin })\n },\n [stop],\n )\n\n const retake = useCallback(() => {\n if (state.step !== \"crop\" || state.origin !== \"camera\" || state.busy) return\n dispatch({ type: \"retake\" })\n void start()\n }, [state, start])\n\n const confirm = useCallback(async (crop: PhotoCaptureCrop) => {\n dispatch({ type: \"confirm\" })\n const { type = \"image/jpeg\", quality = 0.9, size } = latest.current.output ?? {}\n const blob = await crop({\n type,\n quality,\n ...(size ? { maxSize: { width: size, height: size } } : {}),\n }).catch(() => null)\n if (!(blob instanceof Blob)) {\n // A tainted canvas, an image that never loaded: the crop step says so.\n dispatch({ type: \"fail\" })\n return null\n }\n const file = imageFile(blob, \"photo\")\n latest.current.onChange?.(file)\n dispatch({ type: \"done\" })\n return file\n }, [])\n\n const reset = useCallback(() => {\n stop()\n dispatch({ type: \"reset\" })\n }, [stop])\n\n const crop = state.step === \"crop\" ? state : null\n return {\n step: state.step,\n mode,\n photo: crop?.photo ?? null,\n origin: crop?.origin ?? null,\n busy: crop?.busy ?? false,\n failed: crop?.failed ?? false,\n moved: state.moved,\n camera,\n facing,\n ratio,\n mirror,\n open,\n take,\n pick,\n retake,\n confirm,\n reset,\n }\n}\n","\"use client\"\n\nimport { ark, type HTMLArkProps } from \"@ark-ui/react/factory\"\nimport { Camera as CameraIcon, Check, ImageUp, RotateCcw } from \"lucide-react\"\nimport {\n type ComponentPropsWithoutRef,\n createContext,\n type ReactNode,\n type Ref,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { match } from \"ts-pattern\"\nimport { composeChildren, type NoAsChild } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { type IconMap, iconStroke, mergeIcons } from \"../../lib/icons\"\nimport { useDirectionCheck } from \"../../lib/intl\"\nimport { useMergedRefs } from \"../../lib/merge-refs\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES } from \"../../lib/typography-size\"\nimport { useObjectUrl } from \"../../lib/use-object-url\"\nimport { Button, type ButtonProps } from \"../button/button\"\nimport { Camera, type CameraIconSlot, type CameraTranslations } from \"../camera/camera\"\nimport { FileTrigger } from \"../file-trigger/file-trigger\"\nimport {\n ImageCropper,\n type ImageCropperTranslations,\n useImageCropperContext,\n} from \"../image-cropper/image-cropper\"\nimport {\n type UsePhotoCaptureOptions,\n type UsePhotoCaptureResult,\n usePhotoCapture,\n} from \"./use-photo-capture\"\n\n/**\n * PhotoCapture — take a photo with the camera, or pick a file, crop it, and\n * get a File back. The brick a profile picture, a badge photo or a scanned\n * document is added with.\n *\n * <PhotoCapture shape=\"circle\" output={{ size: 512 }} onChange={(file) => setAvatar(file)} />\n *\n * It's a composition, not a new widget: `Camera` takes the photo,\n * `FileTrigger` picks a file (or opens a phone's camera app), `ImageCropper`\n * crops it, and `usePhotoCapture`, a small step reducer, says which of them\n * is on screen. Every part reads that hook, so a layout of your own drives\n * the same flow:\n *\n * const flow = usePhotoCapture({ ratio: \"3/4\", onChange: setBadge })\n * <PhotoCapture.Root flow={flow} shape=\"rectangle\">\n * <PhotoCapture.Source />\n * <PhotoCapture.Live />\n * <PhotoCapture.Crop />\n * </PhotoCapture.Root>\n *\n * It renders inline. In a modal, it's the modal's content: the camera stops\n * when it unmounts. Nothing is uploaded; `onChange` gets the cropped File\n * after \"Use photo\", and never before.\n */\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** A rectangle, or a circle for a face. Drives the camera's guide and the cropper. */\nexport type PhotoCaptureShape = \"rectangle\" | \"circle\"\n\nexport type PhotoCaptureOwnTranslations = {\n /** The source step's heading. */\n sourceTitle?: string\n sourceBody?: string\n /** Takes a photo: opens the camera in the page, or the phone's camera app. */\n take?: string\n /** Picks a file, next to the in-page camera. */\n file?: string\n /** Picks from the phone's library, next to its camera app. */\n library?: string\n /** Back to the camera, from the crop. */\n retake?: string\n /** Picks another file, from the crop of a picked one. */\n another?: string\n /** Hands the crop to `onChange`. */\n confirm?: string\n /** Shown, as an alert, when the crop couldn't be exported. */\n failed?: string\n /** Announced politely when the photo reaches the cropper, and once it's been used. */\n announceCrop?: string\n announceDone?: string\n}\n\n/**\n * One map for everything PhotoCapture shows: its own strings, the camera's\n * (`CameraTranslations`) and the cropper's (`ImageCropperTranslations`).\n */\nexport type PhotoCaptureTranslations = PhotoCaptureOwnTranslations &\n CameraTranslations &\n ImageCropperTranslations\n\nexport const DEFAULT_TRANSLATIONS: Required<PhotoCaptureOwnTranslations> = {\n sourceTitle: \"Add a photo\",\n sourceBody: \"Nothing leaves this page until you choose Use photo.\",\n take: \"Take photo\",\n file: \"Choose a file\",\n library: \"Choose from library\",\n retake: \"Retake\",\n another: \"Choose another\",\n confirm: \"Use photo\",\n failed: \"The photo couldn't be prepared. Try again, or choose another.\",\n announceCrop: \"Photo ready to crop\",\n announceDone: \"Photo added\",\n}\n\nexport type PhotoCaptureIconSlot = \"take\" | \"file\" | \"retake\" | \"confirm\"\n/** PhotoCapture's own icons, and the camera's (`shutter`, `flip`, `start`, `retry`, `off`). */\nexport type PhotoCaptureIcons = IconMap<PhotoCaptureIconSlot | CameraIconSlot>\n\nexport const DEFAULT_ICONS: Record<PhotoCaptureIconSlot, ReactNode> = {\n take: <CameraIcon aria-hidden className={iconStroke} />,\n file: <ImageUp aria-hidden className={iconStroke} />,\n retake: <RotateCcw aria-hidden className={iconStroke} />,\n confirm: <Check aria-hidden className={iconStroke} />,\n}\n\ntype Shared = {\n flow: UsePhotoCaptureResult\n t: Required<PhotoCaptureOwnTranslations>\n /** The `translations` prop as given, for the camera and the cropper to merge with their own defaults. */\n translations: PhotoCaptureTranslations | undefined\n icons: Record<PhotoCaptureIconSlot, ReactNode>\n /** The `icons` prop as given, for the camera. */\n cameraIcons: PhotoCaptureIcons | undefined\n shape: PhotoCaptureShape\n accept: string | string[]\n color: Color\n announce: (message: string) => void\n}\n\nconst PhotoCaptureContext = createContext<Shared | null>(null)\n\n/** The nearest `PhotoCapture.Root`'s flow, translations and icons, for a part of your own. */\nexport const usePhotoCaptureContext = (): Shared => {\n const shared = useContext(PhotoCaptureContext)\n if (!shared)\n throw new Error(\"[@42/ui-react] PhotoCapture parts must be inside <PhotoCapture.Root>.\")\n return shared\n}\n\n/** What the camera encodes the shot as, on its way to the cropper, which re-encodes it as `output`. */\nconst SHOT = { type: \"image/jpeg\", quality: 0.95 }\n\n// ---------------------------------------------------------------------------\n// Root\n// ---------------------------------------------------------------------------\n\nexport type PhotoCaptureRootProps = Omit<HTMLArkProps<\"div\">, \"color\" | \"onChange\"> &\n WithTestId & {\n /** The flow, from `usePhotoCapture()`. */\n flow: UsePhotoCaptureResult\n /** A rectangle, or a circle for a face: the camera's guide and the crop. Defaults to `rectangle`. */\n shape?: PhotoCaptureShape\n /** The file types the pickers offer. Defaults to `image/*`. */\n accept?: string | string[]\n translations?: PhotoCaptureTranslations\n icons?: PhotoCaptureIcons\n /** The palette of the buttons, the shutter, the guide and the crop. `brand` by default. */\n color?: Color\n ref?: Ref<HTMLDivElement>\n }\n\n/** Announces each step, politely, from a visually hidden region. */\nconst Announcer = ({ message }: { message: string }) => (\n <div role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n {message}\n </div>\n)\n\nconst PhotoCaptureRoot = ({\n flow,\n shape = \"rectangle\",\n accept = \"image/*\",\n translations,\n icons,\n color = \"brand\",\n className,\n testId,\n asChild,\n children,\n ref,\n ...rest\n}: PhotoCaptureRootProps) => {\n const direction = useDirectionCheck()\n const [message, setMessage] = useState(\"\")\n\n const shared = useMemo<Shared>(\n () => ({\n flow,\n t: { ...DEFAULT_TRANSLATIONS, ...translations },\n translations,\n icons: mergeIcons(DEFAULT_ICONS, icons),\n cameraIcons: icons,\n shape,\n accept,\n color,\n announce: setMessage,\n }),\n [flow, translations, icons, shape, accept, color],\n )\n\n // The live step announces itself through the camera's own region.\n useEffect(() => {\n if (flow.step === \"crop\") setMessage(shared.t.announceCrop)\n }, [flow.step, shared.t])\n\n const rootRef = useMergedRefs(ref, direction)\n return (\n <PhotoCaptureContext value={shared}>\n <ark.div\n ref={rootRef}\n asChild={asChild}\n data-color={color}\n data-step={flow.step}\n data-mode={flow.mode}\n className={cn(\"flex w-full flex-col gap-3\", className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => (\n <>\n {own}\n <Announcer message={message} />\n </>\n ))}\n </ark.div>\n </PhotoCaptureContext>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Actions\n// ---------------------------------------------------------------------------\n\nexport type PhotoCaptureActionProps = NoAsChild<\n Omit<ButtonProps, \"onClick\" | \"onSelect\" | \"children\"> & {\n /** Replaces the label from `translations`. */\n children?: ReactNode\n }\n>\n\n/**\n * Takes a photo. With the in-page camera, it opens the `live` step; with\n * `native`, it opens the phone's camera app (`capture`), whose photo goes\n * straight to the crop. Hidden where the in-page camera can't work at all.\n */\nconst PhotoCaptureTake = ({ children, asChild: _asChild, ...rest }: PhotoCaptureActionProps) => {\n const { flow, t, icons, accept } = usePhotoCaptureContext()\n const label = children ?? t.take\n return match(flow.mode)\n .with(\"native\", () => (\n <FileTrigger\n accept={accept}\n capture={flow.facing}\n onSelect={(files) => flow.pick(files, \"native\")}\n startSlot={icons.take}\n {...rest}\n >\n {label}\n </FileTrigger>\n ))\n .with(\"live\", () =>\n flow.camera.status === \"unsupported\" ? null : (\n <Button startSlot={icons.take} onClick={flow.open} {...rest}>\n {label}\n </Button>\n ),\n )\n .exhaustive()\n}\n\n/**\n * Picks a file: \"Choose a file\" beside the in-page camera, \"Choose from\n * library\" beside the phone's camera app. Always there, at the same weight\n * as the camera, for anyone whose camera won't do.\n */\nconst PhotoCaptureFile = ({ children, asChild: _asChild, ...rest }: PhotoCaptureActionProps) => {\n const { flow, t, icons, accept } = usePhotoCaptureContext()\n return (\n <FileTrigger\n accept={accept}\n onSelect={(files) => flow.pick(files, \"file\")}\n startSlot={icons.file}\n {...rest}\n >\n {children ?? (flow.mode === \"native\" ? t.library : t.file)}\n </FileTrigger>\n )\n}\n\n/**\n * Back for another photo, the way this one came: the in-page camera again,\n * the phone's camera app again, or another file (\"Choose another\").\n */\nconst PhotoCaptureRetake = ({ children, asChild: _asChild, ...rest }: PhotoCaptureActionProps) => {\n const { flow, t, icons, accept } = usePhotoCaptureContext()\n return match(flow.origin)\n .with(\"camera\", () => (\n <Button\n variant=\"light\"\n startSlot={icons.retake}\n disabled={flow.busy}\n onClick={flow.retake}\n {...rest}\n >\n {children ?? t.retake}\n </Button>\n ))\n .with(\"native\", () => (\n <FileTrigger\n variant=\"light\"\n accept={accept}\n capture={flow.facing}\n disabled={flow.busy}\n onSelect={(files) => flow.pick(files, \"native\")}\n startSlot={icons.retake}\n {...rest}\n >\n {children ?? t.retake}\n </FileTrigger>\n ))\n .with(\"file\", () => (\n <FileTrigger\n variant=\"light\"\n accept={accept}\n disabled={flow.busy}\n onSelect={(files) => flow.pick(files, \"file\")}\n startSlot={icons.file}\n {...rest}\n >\n {children ?? t.another}\n </FileTrigger>\n ))\n .with(null, () => null)\n .exhaustive()\n}\n\n/**\n * \"Use photo\": exports the crop as `output` says, hands the File to\n * `onChange`, and starts over. Inside `PhotoCapture.Crop`, which provides the\n * cropper it exports. Takes focus when it appears, so after the shutter (or a\n * pick) Enter uses the photo.\n */\nconst PhotoCaptureConfirm = ({\n id,\n children,\n asChild: _asChild,\n ...rest\n}: PhotoCaptureActionProps) => {\n const { flow, t, icons, announce } = usePhotoCaptureContext()\n const cropper = useImageCropperContext()\n // Button takes no ref: found by its id to move focus to it.\n const generated = useId()\n const button = id ?? generated\n\n // The crop is only ever reached by a user's step: the shutter or a pick.\n // Again after a failure, which disabled (and so blurred) the button.\n useEffect(() => {\n if (!flow.busy) document.getElementById(button)?.focus()\n }, [flow.busy, button])\n\n return (\n <Button\n id={button}\n startSlot={icons.confirm}\n loading={flow.busy}\n onClick={async () => {\n const file = await flow.confirm(cropper.getCroppedImage)\n if (file) announce(t.announceDone)\n }}\n {...rest}\n >\n {children ?? t.confirm}\n </Button>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Steps\n// ---------------------------------------------------------------------------\n\nexport type PhotoCaptureSourceProps = NoAsChild<ComponentPropsWithoutRef<\"div\"> & WithTestId>\n\n/**\n * The first step: \"Take photo\" and the file picker, side by side at the same\n * weight, under a line that says nothing leaves the page. With `native`,\n * that's the phone's camera app and its library: two pickers, because\n * Android 14 and 15 hide the camera from a picker without `capture`.\n * Children replace the two buttons.\n */\nconst PhotoCaptureSource = ({\n className,\n testId,\n children,\n asChild: _asChild,\n ...rest\n}: PhotoCaptureSourceProps) => {\n const { flow, t } = usePhotoCaptureContext()\n const root = useRef<HTMLDivElement>(null)\n\n // Back here after a photo was used: focus goes to the first choice, not the page.\n useEffect(() => {\n if (flow.step === \"source\" && flow.moved)\n root.current?.querySelector<HTMLElement>(\"button:not(:disabled)\")?.focus()\n }, [flow.step, flow.moved])\n\n if (flow.step !== \"source\") return null\n return (\n <div\n ref={root}\n data-part=\"source\"\n className={cn(\n \"flex flex-col items-center justify-center gap-4 rounded-input border border-dashed p-6 text-center\",\n // The kit's hairline, dashed: FileUpload's dropzone.\n \"border-brand-900/20 dark:border-white/15\",\n className,\n )}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n <div className=\"flex flex-col gap-1\">\n <p className=\"font-medium text-brand-950 text-md dark:text-white\">{t.sourceTitle}</p>\n <p className=\"text-black/50 text-sm dark:text-white/50\">{t.sourceBody}</p>\n </div>\n {/* Side by side when they fit, stacked full width when not: the same weight either way. */}\n <div className=\"grid w-full max-w-md grid-cols-[repeat(auto-fit,minmax(min(100%,11rem),1fr))] gap-2\">\n {children ?? (\n <>\n <PhotoCaptureTake />\n <PhotoCaptureFile />\n </>\n )}\n </div>\n </div>\n )\n}\n\nexport type PhotoCaptureLiveClassNames = {\n viewfinder?: string\n controls?: string\n}\n\nexport type PhotoCaptureLiveProps = NoAsChild<\n Omit<ComponentPropsWithoutRef<\"div\">, \"children\" | \"color\"> &\n WithTestId & {\n classNames?: PhotoCaptureLiveClassNames\n }\n>\n\n/**\n * The in-page camera: `Camera`'s viewfinder with a guide in the flow's\n * shape, its status panels, the shutter, the camera switch and picker, and\n * the file picker beside the shutter. Every panel (asking, refused, busy, no\n * camera) offers the file picker too.\n *\n * Focus comes here as the step opens, and moves to the shutter once the\n * picture is live.\n */\nconst PhotoCaptureLive = ({\n className,\n classNames,\n testId,\n asChild: _asChild,\n ...rest\n}: PhotoCaptureLiveProps) => {\n const { flow, translations, cameraIcons, shape, color } = usePhotoCaptureContext()\n const root = useRef<HTMLDivElement>(null)\n const shutter = useRef<HTMLButtonElement>(null)\n /** Whether the shutter should take focus once it's enabled: after \"Take photo\" or a retake. */\n const pending = useRef(false)\n const status = flow.camera.status\n\n useEffect(() => {\n if (flow.step !== \"live\" || !flow.moved) return\n pending.current = true\n // The button that brought us here is gone: hold focus in the step until the shutter can take it.\n root.current?.focus()\n }, [flow.step, flow.moved])\n\n useEffect(() => {\n if (!pending.current || status !== \"live\") return\n pending.current = false\n shutter.current?.focus()\n }, [status])\n\n if (flow.step !== \"live\") return null\n return (\n <Camera.Root\n ref={root}\n tabIndex={-1}\n camera={flow.camera}\n onCapture={flow.take}\n output={SHOT}\n mirror={flow.mirror}\n translations={translations}\n icons={cameraIcons}\n color={color}\n data-part=\"live\"\n className={cn(\"outline-none\", className)}\n testId={testId}\n {...rest}\n >\n <Camera.Viewfinder ratio={flow.ratio} className={classNames?.viewfinder}>\n <Camera.Guide shape={shape} ratio={shape === \"rectangle\" ? flow.ratio : undefined} />\n <Camera.Live className=\"absolute start-2 top-2 z-1\" />\n <Camera.Status>{() => <PhotoCaptureFile size=\"sm\" />}</Camera.Status>\n </Camera.Viewfinder>\n <div className={cn(\"grid grid-cols-[1fr_auto_1fr] items-center gap-3\", classNames?.controls)}>\n {/* While a panel is up, it carries the file picker. */}\n <div className=\"flex min-w-0 justify-start\">\n {status === \"live\" && <PhotoCaptureFile variant=\"light\" />}\n </div>\n <Camera.Shutter ref={shutter} />\n <div className=\"flex min-w-0 items-center justify-end gap-2\">\n <Camera.Devices className=\"min-w-0\" />\n <Camera.Flip />\n </div>\n </div>\n </Camera.Root>\n )\n}\n\nexport type PhotoCaptureCropClassNames = {\n viewport?: string\n controls?: string\n actions?: string\n}\n\nexport type PhotoCaptureCropProps = NoAsChild<\n Omit<ComponentPropsWithoutRef<\"div\">, \"color\"> &\n WithTestId & {\n classNames?: PhotoCaptureCropClassNames\n /** Replaces the Retake and Use photo buttons. `PhotoCapture.Confirm` must stay inside. */\n children?: ReactNode\n }\n>\n\n/**\n * The photo in `ImageCropper`, locked to the flow's ratio and shape, with\n * its zoom, rotate and flip controls, then Retake and Use photo. Taking the\n * photo and cropping it are one step: there's no review screen between.\n */\nconst PhotoCaptureCrop = ({\n className,\n classNames,\n testId,\n children,\n asChild: _asChild,\n ...rest\n}: PhotoCaptureCropProps) => {\n const { flow, t, translations, shape, color } = usePhotoCaptureContext()\n // One URL per photo, which is also the cropper's key: a new photo starts a new crop.\n const url = useObjectUrl(flow.photo)\n\n if (flow.step !== \"crop\" || !url) return null\n return (\n <ImageCropper.Root\n key={url}\n ratio={shape === \"circle\" ? 1 : flow.ratio}\n shape={shape}\n color={color}\n translations={translations}\n data-part=\"crop\"\n className={className}\n testId={testId}\n {...rest}\n >\n <ImageCropper.Viewport className={classNames?.viewport}>\n <ImageCropper.Image src={url} />\n <ImageCropper.Selection />\n </ImageCropper.Viewport>\n <ImageCropper.Controls className={classNames?.controls} />\n {flow.failed && (\n <p role=\"alert\" className={cn(TEXT_COLOR_CLASSES.error, \"text-sm\")}>\n {t.failed}\n </p>\n )}\n <div className={cn(\"flex flex-wrap items-center justify-end gap-2\", classNames?.actions)}>\n {children ?? (\n <>\n <PhotoCaptureRetake />\n <PhotoCaptureConfirm />\n </>\n )}\n </div>\n </ImageCropper.Root>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Convenience\n// ---------------------------------------------------------------------------\n\nexport type PhotoCaptureClassNames = {\n source?: string\n live?: string\n viewfinder?: string\n crop?: string\n viewport?: string\n controls?: string\n actions?: string\n}\n\nexport type PhotoCaptureProps = NoAsChild<\n Omit<PhotoCaptureRootProps, \"flow\" | \"children\"> &\n UsePhotoCaptureOptions & {\n classNames?: PhotoCaptureClassNames\n }\n>\n\nconst PhotoCaptureComponent = ({\n onChange,\n camera,\n facing,\n ratio,\n resolution,\n mirror,\n output,\n classNames,\n asChild: _asChild,\n ...rest\n}: PhotoCaptureProps) => {\n const flow = usePhotoCapture({ onChange, camera, facing, ratio, resolution, mirror, output })\n return (\n <PhotoCaptureRoot flow={flow} {...rest}>\n <PhotoCaptureSource className={classNames?.source} />\n <PhotoCaptureLive\n className={classNames?.live}\n classNames={{ viewfinder: classNames?.viewfinder, controls: classNames?.controls }}\n />\n <PhotoCaptureCrop\n className={classNames?.crop}\n classNames={{\n viewport: classNames?.viewport,\n controls: classNames?.controls,\n actions: classNames?.actions,\n }}\n />\n </PhotoCaptureRoot>\n )\n}\n\nexport const PhotoCapture = Object.assign(PhotoCaptureComponent, {\n Root: PhotoCaptureRoot,\n Source: PhotoCaptureSource,\n Live: PhotoCaptureLive,\n Crop: PhotoCaptureCrop,\n Take: PhotoCaptureTake,\n File: PhotoCaptureFile,\n Retake: PhotoCaptureRetake,\n Confirm: PhotoCaptureConfirm,\n})\n"]}
1
+ {"version":3,"sources":["../../../src/components/photo-capture/photo-capture-machine.ts","../../../src/components/photo-capture/use-photo-capture.ts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so every transition is unit-tested without\n * a camera or a canvas: `usePhotoCapture` feeds it what the parts report and\n * renders whatever it returns. The camera and the cropper keep their own\n * state; this only knows which of them is on screen, and with which photo.\n */\n\n/**\n * - `source`: the choice, camera or file. The first step, and where a used photo returns to.\n * - `live`: the in-page camera.\n * - `crop`: the photo, taken or picked, in the cropper, until it's used or retaken.\n */\nexport type PhotoCaptureStep = \"source\" | \"live\" | \"crop\"\n\n/**\n * Where the photo in the cropper came from, which decides what \"retake\"\n * means: the in-page camera again, the phone's camera app again, or another\n * file.\n */\nexport type PhotoCaptureOrigin = \"camera\" | \"native\" | \"file\"\n\nexport type PhotoCaptureState =\n | {\n step: \"source\"\n /** Whether a step was ever left: `false` on mount, so nothing steals focus as the page loads. */\n moved: boolean\n }\n | { step: \"live\"; moved: true }\n | {\n step: \"crop\"\n moved: true\n photo: File\n origin: PhotoCaptureOrigin\n /** The crop is being exported. */\n busy: boolean\n /** The last export failed. */\n failed: boolean\n }\n\nexport type PhotoCaptureEvent =\n /** \"Take photo\", in the page: the camera opens. */\n | { type: \"open\" }\n /** The shutter's photo. */\n | { type: \"take\"; photo: File }\n /** A file from the picker, or from the phone's camera app. */\n | { type: \"pick\"; photo: File; origin: Exclude<PhotoCaptureOrigin, \"camera\"> }\n /** Back to the in-page camera, for another shot. */\n | { type: \"retake\" }\n /** \"Use photo\": the export starts. */\n | { type: \"confirm\" }\n | { type: \"fail\" }\n /** The File went out: back to the start. */\n | { type: \"done\" }\n | { type: \"reset\" }\n\nexport const initialPhotoCaptureState: PhotoCaptureState = { step: \"source\", moved: false }\n\nconst crop = (photo: File, origin: PhotoCaptureOrigin): PhotoCaptureState => ({\n step: \"crop\",\n moved: true,\n photo,\n origin,\n busy: false,\n failed: false,\n})\n\n/**\n * The next state. An event that doesn't apply to the current step (a late\n * shutter after a file was picked, a double \"Use photo\") leaves it as it is.\n */\nexport const reducePhotoCapture = (\n state: PhotoCaptureState,\n event: PhotoCaptureEvent,\n): PhotoCaptureState =>\n match(event)\n .returnType<PhotoCaptureState>()\n .with({ type: \"open\" }, () => (state.step === \"source\" ? { step: \"live\", moved: true } : state))\n .with({ type: \"take\" }, ({ photo }) => (state.step === \"live\" ? crop(photo, \"camera\") : state))\n .with({ type: \"pick\" }, ({ photo, origin }) =>\n // From any step, but never over an export in flight.\n state.step === \"crop\" && state.busy ? state : crop(photo, origin),\n )\n .with({ type: \"retake\" }, () =>\n match(state)\n .returnType<PhotoCaptureState>()\n .with({ step: \"crop\", origin: \"camera\", busy: false }, () => ({\n step: \"live\",\n moved: true,\n }))\n .otherwise(() => state),\n )\n .with({ type: \"confirm\" }, () =>\n match(state)\n .with({ step: \"crop\", busy: false }, (s) => ({ ...s, busy: true, failed: false }))\n .otherwise(() => state),\n )\n .with({ type: \"fail\" }, () =>\n match(state)\n .with({ step: \"crop\", busy: true }, (s) => ({ ...s, busy: false, failed: true }))\n .otherwise(() => state),\n )\n .with({ type: \"done\" }, () => (state.step === \"crop\" ? { step: \"source\", moved: true } : state))\n .with({ type: \"reset\" }, () =>\n match(state)\n .returnType<PhotoCaptureState>()\n .with({ step: \"crop\", busy: true }, () => state)\n .with({ step: P.union(\"live\", \"crop\") }, () => ({ step: \"source\", moved: true }))\n .otherwise(() => state),\n )\n .exhaustive()\n","\"use client\"\n\nimport { useCallback, useReducer, useRef } from \"react\"\nimport { match } from \"ts-pattern\"\nimport { imageFile } from \"../../lib/image-file\"\nimport type { Ratio } from \"../../lib/ratio\"\nimport { useIsomorphicLayoutEffect } from \"../../lib/use-isomorphic-layout-effect\"\nimport { useMediaQuery } from \"../../lib/use-media-query\"\nimport type { CameraFacing, CameraResolution } from \"../camera/camera-machine\"\nimport { type UseCameraResult, useCamera } from \"../camera/use-camera\"\nimport {\n initialPhotoCaptureState,\n type PhotoCaptureOrigin,\n type PhotoCaptureStep,\n reducePhotoCapture,\n} from \"./photo-capture-machine\"\n\n/**\n * How the photo is taken:\n * - `live`: the camera in the page, a viewfinder and a shutter.\n * - `native`: the phone's own camera app, through a file input with `capture`. No viewfinder in the page.\n * - `auto`: `native` under a coarse pointer (a phone, a tablet), `live` otherwise.\n */\nexport type PhotoCaptureCamera = \"live\" | \"native\" | \"auto\"\n\nexport type PhotoCaptureOutput = {\n /** The encoding. A browser that can't encode it falls back to PNG, and the File says so. Defaults to `image/jpeg`. */\n type?: string\n /** 0–1, for JPEG and WebP. Defaults to 0.9. */\n quality?: number\n /** The longest side, in px: a larger crop is scaled down to fit, a smaller one is kept as is. */\n size?: number\n}\n\nexport type UsePhotoCaptureOptions = {\n /** Receives the cropped photo once \"Use photo\" is pressed. Nothing is emitted before. */\n onChange?: (file: File) => void\n /** The in-page camera, the phone's camera app, or whichever suits the device. Defaults to `auto`. */\n camera?: PhotoCaptureCamera\n /** The camera to open: the front one (`user`, the default) or the back one. */\n facing?: CameraFacing\n /** The crop's width / height, and the viewfinder's box. Free when unset; a circle is always 1. */\n ratio?: Ratio\n /** The capture size to aim for, for the in-page camera. See `useCamera`. */\n resolution?: CameraResolution\n /** Saves a selfie as the preview shows it, mirrored. Off by default: a saved selfie reads the right way round. */\n mirror?: boolean\n /** The File's encoding and size. */\n output?: PhotoCaptureOutput\n}\n\n/** What `confirm()` hands to the cropper's export: `ImageCropper`'s `getCroppedImage`. */\nexport type PhotoCaptureCrop = (options: {\n type: string\n quality: number\n maxSize?: { width: number; height: number }\n}) => Promise<Blob | string | null>\n\nexport type UsePhotoCaptureResult = {\n step: PhotoCaptureStep\n /** `auto` resolved for this device. */\n mode: \"live\" | \"native\"\n /** The photo in the cropper, taken or picked, before it's cropped. */\n photo: File | null\n /** Where `photo` came from, which decides what a retake means. */\n origin: PhotoCaptureOrigin | null\n /** The crop is being exported. */\n busy: boolean\n /** The last export failed. */\n failed: boolean\n /** Whether a step was ever left, so a part knows to move focus when it appears. */\n moved: boolean\n /** The in-page camera. Lazy: it turns on with `open()`, never on its own. */\n camera: UseCameraResult\n facing: CameraFacing\n ratio: Ratio | undefined\n mirror: boolean\n /** Opens the in-page camera. */\n open: () => void\n /** The shutter's photo: `Camera.Root`'s `onCapture`. */\n take: (photo: File) => void\n /** A picked file (the first of `files`), from the library or, with `native`, the phone's camera app. */\n pick: (files: readonly File[], origin?: Exclude<PhotoCaptureOrigin, \"camera\">) => void\n /** Back to the in-page camera for another shot. */\n retake: () => void\n /** Exports the crop through `crop`, then hands the File to `onChange` and starts over. Resolves the File, or `null` if the export failed. */\n confirm: (crop: PhotoCaptureCrop) => Promise<File | null>\n /** Back to the source step, the camera off. */\n reset: () => void\n}\n\n/**\n * PhotoCapture as plain state plus handlers: which step is on screen, the\n * photo in it, and the in-page camera. The steps are a pure reducer\n * (`reducePhotoCapture`); the camera is `useCamera`, mounted lazily so it\n * never lights up before \"Take photo\"; the crop is whatever `ImageCropper`\n * exports. This hook only wires them together.\n *\n * const flow = usePhotoCapture({ ratio: 1, output: { size: 512 }, onChange: upload })\n * <PhotoCapture.Root flow={flow} shape=\"circle\">…</PhotoCapture.Root>\n *\n * The camera turns off when the photo is taken, when a file is picked\n * instead, on `reset()` and on unmount. Nothing is uploaded: `onChange`\n * gets a File and the rest is yours.\n */\nexport function usePhotoCapture({\n onChange,\n camera: wanted = \"auto\",\n facing = \"user\",\n ratio,\n resolution,\n mirror = false,\n output,\n}: UsePhotoCaptureOptions = {}): UsePhotoCaptureResult {\n const [state, dispatch] = useReducer(reducePhotoCapture, initialPhotoCaptureState)\n const camera = useCamera({ facing, ratio, resolution, lazy: true })\n const coarse = useMediaQuery(\"(pointer: coarse)\")\n const mode = match(wanted)\n .returnType<\"live\" | \"native\">()\n .with(\"auto\", () => (coarse ? \"native\" : \"live\"))\n .otherwise((chosen) => chosen)\n\n // Read when the export resolves, not when it started: the latest callback and encoding.\n const latest = useRef({ onChange, output })\n useIsomorphicLayoutEffect(() => {\n latest.current = { onChange, output }\n })\n\n const { start, stop } = camera\n\n const open = useCallback(() => {\n dispatch({ type: \"open\" })\n void start()\n }, [start])\n\n const take = useCallback((photo: File) => dispatch({ type: \"take\", photo }), [])\n\n const pick = useCallback(\n (files: readonly File[], origin: Exclude<PhotoCaptureOrigin, \"camera\"> = \"file\") => {\n const [photo] = files\n if (!photo) return\n // A file instead of the shot: the camera goes off with the viewfinder.\n stop()\n dispatch({ type: \"pick\", photo, origin })\n },\n [stop],\n )\n\n const retake = useCallback(() => {\n if (state.step !== \"crop\" || state.origin !== \"camera\" || state.busy) return\n dispatch({ type: \"retake\" })\n void start()\n }, [state, start])\n\n const confirm = useCallback(async (crop: PhotoCaptureCrop) => {\n dispatch({ type: \"confirm\" })\n const { type = \"image/jpeg\", quality = 0.9, size } = latest.current.output ?? {}\n const blob = await crop({\n type,\n quality,\n ...(size ? { maxSize: { width: size, height: size } } : {}),\n }).catch(() => null)\n if (!(blob instanceof Blob)) {\n // A tainted canvas, an image that never loaded: the crop step says so.\n dispatch({ type: \"fail\" })\n return null\n }\n const file = imageFile(blob, \"photo\")\n latest.current.onChange?.(file)\n dispatch({ type: \"done\" })\n return file\n }, [])\n\n const reset = useCallback(() => {\n stop()\n dispatch({ type: \"reset\" })\n }, [stop])\n\n const crop = state.step === \"crop\" ? state : null\n return {\n step: state.step,\n mode,\n photo: crop?.photo ?? null,\n origin: crop?.origin ?? null,\n busy: crop?.busy ?? false,\n failed: crop?.failed ?? false,\n moved: state.moved,\n camera,\n facing,\n ratio,\n mirror,\n open,\n take,\n pick,\n retake,\n confirm,\n reset,\n }\n}\n","\"use client\"\n\nimport { ark, type HTMLArkProps } from \"@ark-ui/react/factory\"\nimport { Camera as CameraIcon, Check, ImageUp, RotateCcw } from \"lucide-react\"\nimport {\n type ComponentPropsWithoutRef,\n createContext,\n type ReactNode,\n type Ref,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { match } from \"ts-pattern\"\nimport { composeChildren, type NoAsChild } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { type IconMap, iconStroke, mergeIcons } from \"../../lib/icons\"\nimport { useDirectionCheck } from \"../../lib/intl\"\nimport { useMergedRefs } from \"../../lib/merge-refs\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES } from \"../../lib/typography-size\"\nimport { useObjectUrl } from \"../../lib/use-object-url\"\nimport { Button, type ButtonProps } from \"../button/button\"\nimport { Camera, type CameraIconSlot, type CameraTranslations } from \"../camera/camera\"\nimport { FileTrigger } from \"../file-trigger/file-trigger\"\nimport {\n ImageCropper,\n type ImageCropperTranslations,\n useImageCropperContext,\n} from \"../image-cropper/image-cropper\"\nimport {\n type UsePhotoCaptureOptions,\n type UsePhotoCaptureResult,\n usePhotoCapture,\n} from \"./use-photo-capture\"\n\n/**\n * PhotoCapture — take a photo with the camera, or pick a file, crop it, and\n * get a File back. The brick a profile picture, a badge photo or a scanned\n * document is added with.\n *\n * <PhotoCapture shape=\"circle\" output={{ size: 512 }} onChange={(file) => setAvatar(file)} />\n *\n * It's a composition, not a new widget: `Camera` takes the photo,\n * `FileTrigger` picks a file (or opens a phone's camera app), `ImageCropper`\n * crops it, and `usePhotoCapture`, a small step reducer, says which of them\n * is on screen. Every part reads that hook, so a layout of your own drives\n * the same flow:\n *\n * const flow = usePhotoCapture({ ratio: \"3/4\", onChange: setBadge })\n * <PhotoCapture.Root flow={flow} shape=\"rectangle\">\n * <PhotoCapture.Source />\n * <PhotoCapture.Live />\n * <PhotoCapture.Crop />\n * </PhotoCapture.Root>\n *\n * It renders inline. In a modal, it's the modal's content: the camera stops\n * when it unmounts. Nothing is uploaded; `onChange` gets the cropped File\n * after \"Use photo\", and never before.\n */\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** A rectangle, or a circle for a face. Drives the camera's guide and the cropper. */\nexport type PhotoCaptureShape = \"rectangle\" | \"circle\"\n\nexport type PhotoCaptureOwnTranslations = {\n /** The source step's heading. */\n sourceTitle?: string\n sourceBody?: string\n /** Takes a photo: opens the camera in the page, or the phone's camera app. */\n take?: string\n /** Picks a file, next to the in-page camera. */\n file?: string\n /** Picks from the phone's library, next to its camera app. */\n library?: string\n /** Back to the camera, from the crop. */\n retake?: string\n /** Picks another file, from the crop of a picked one. */\n another?: string\n /** Hands the crop to `onChange`. */\n confirm?: string\n /** Shown, as an alert, when the crop couldn't be exported. */\n failed?: string\n /** Announced politely when the photo reaches the cropper, and once it's been used. */\n announceCrop?: string\n announceDone?: string\n}\n\n/**\n * One map for everything PhotoCapture shows: its own strings, the camera's\n * (`CameraTranslations`) and the cropper's (`ImageCropperTranslations`).\n */\nexport type PhotoCaptureTranslations = PhotoCaptureOwnTranslations &\n CameraTranslations &\n ImageCropperTranslations\n\nexport const DEFAULT_TRANSLATIONS: Required<PhotoCaptureOwnTranslations> = {\n sourceTitle: \"Add a photo\",\n sourceBody: \"Nothing leaves this page until you choose Use photo.\",\n take: \"Take photo\",\n file: \"Choose a file\",\n library: \"Choose from library\",\n retake: \"Retake\",\n another: \"Choose another\",\n confirm: \"Use photo\",\n failed: \"The photo couldn't be prepared. Try again, or choose another.\",\n announceCrop: \"Photo ready to crop\",\n announceDone: \"Photo added\",\n}\n\nexport type PhotoCaptureIconSlot = \"take\" | \"file\" | \"retake\" | \"confirm\"\n/** PhotoCapture's own icons, and the camera's (`shutter`, `flip`, `start`, `retry`, `off`). */\nexport type PhotoCaptureIcons = IconMap<PhotoCaptureIconSlot | CameraIconSlot>\n\nexport const DEFAULT_ICONS: Record<PhotoCaptureIconSlot, ReactNode> = {\n take: <CameraIcon aria-hidden className={iconStroke} />,\n file: <ImageUp aria-hidden className={iconStroke} />,\n retake: <RotateCcw aria-hidden className={iconStroke} />,\n confirm: <Check aria-hidden className={iconStroke} />,\n}\n\ntype Shared = {\n flow: UsePhotoCaptureResult\n t: Required<PhotoCaptureOwnTranslations>\n /** The `translations` prop as given, for the camera and the cropper to merge with their own defaults. */\n translations: PhotoCaptureTranslations | undefined\n icons: Record<PhotoCaptureIconSlot, ReactNode>\n /** The `icons` prop as given, for the camera. */\n cameraIcons: PhotoCaptureIcons | undefined\n shape: PhotoCaptureShape\n accept: string | string[]\n color: Color\n announce: (message: string) => void\n}\n\nconst PhotoCaptureContext = createContext<Shared | null>(null)\n\n/** The nearest `PhotoCapture.Root`'s flow, translations and icons, for a part of your own. */\nexport const usePhotoCaptureContext = (): Shared => {\n const shared = useContext(PhotoCaptureContext)\n if (!shared)\n throw new Error(\"[@42/ui-react] PhotoCapture parts must be inside <PhotoCapture.Root>.\")\n return shared\n}\n\n/** What the camera encodes the shot as, on its way to the cropper, which re-encodes it as `output`. */\nconst SHOT = { type: \"image/jpeg\", quality: 0.95 }\n\n// ---------------------------------------------------------------------------\n// Root\n// ---------------------------------------------------------------------------\n\nexport type PhotoCaptureRootProps = Omit<HTMLArkProps<\"div\">, \"color\" | \"onChange\"> &\n WithTestId & {\n /** The flow, from `usePhotoCapture()`. */\n flow: UsePhotoCaptureResult\n /** A rectangle, or a circle for a face: the camera's guide and the crop. Defaults to `rectangle`. */\n shape?: PhotoCaptureShape\n /** The file types the pickers offer. Defaults to `image/*`. */\n accept?: string | string[]\n translations?: PhotoCaptureTranslations\n icons?: PhotoCaptureIcons\n /** The palette of the buttons, the shutter, the guide and the crop. `brand` by default. */\n color?: Color\n ref?: Ref<HTMLDivElement>\n }\n\n/** Announces each step, politely, from a visually hidden region. */\nconst Announcer = ({ message }: { message: string }) => (\n <div role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n {message}\n </div>\n)\n\nconst PhotoCaptureRoot = ({\n flow,\n shape = \"rectangle\",\n accept = \"image/*\",\n translations,\n icons,\n color = \"brand\",\n className,\n testId,\n asChild,\n children,\n ref,\n ...rest\n}: PhotoCaptureRootProps) => {\n const direction = useDirectionCheck()\n const [message, setMessage] = useState(\"\")\n\n const shared = useMemo<Shared>(\n () => ({\n flow,\n t: { ...DEFAULT_TRANSLATIONS, ...translations },\n translations,\n icons: mergeIcons(DEFAULT_ICONS, icons),\n cameraIcons: icons,\n shape,\n accept,\n color,\n announce: setMessage,\n }),\n [flow, translations, icons, shape, accept, color],\n )\n\n // The live step announces itself through the camera's own region.\n useEffect(() => {\n if (flow.step === \"crop\") setMessage(shared.t.announceCrop)\n }, [flow.step, shared.t])\n\n const rootRef = useMergedRefs(ref, direction)\n return (\n <PhotoCaptureContext value={shared}>\n <ark.div\n ref={rootRef}\n asChild={asChild}\n data-color={color}\n data-step={flow.step}\n data-mode={flow.mode}\n className={cn(\"flex w-full flex-col gap-3\", className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => (\n <>\n {own}\n <Announcer message={message} />\n </>\n ))}\n </ark.div>\n </PhotoCaptureContext>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Actions\n// ---------------------------------------------------------------------------\n\nexport type PhotoCaptureActionProps = NoAsChild<\n Omit<ButtonProps, \"onClick\" | \"onSelect\" | \"children\"> & {\n /** Replaces the label from `translations`. */\n children?: ReactNode\n }\n>\n\n/**\n * Takes a photo. With the in-page camera, it opens the `live` step; with\n * `native`, it opens the phone's camera app (`capture`), whose photo goes\n * straight to the crop. Hidden where the in-page camera can't work at all.\n */\nconst PhotoCaptureTake = ({ children, asChild: _asChild, ...rest }: PhotoCaptureActionProps) => {\n const { flow, t, icons, accept } = usePhotoCaptureContext()\n const label = children ?? t.take\n return match(flow.mode)\n .with(\"native\", () => (\n <FileTrigger\n accept={accept}\n capture={flow.facing}\n onSelect={(files) => flow.pick(files, \"native\")}\n startSlot={icons.take}\n {...rest}\n >\n {label}\n </FileTrigger>\n ))\n .with(\"live\", () =>\n flow.camera.status === \"unsupported\" ? null : (\n <Button startSlot={icons.take} onClick={flow.open} {...rest}>\n {label}\n </Button>\n ),\n )\n .exhaustive()\n}\n\n/**\n * Picks a file: \"Choose a file\" beside the in-page camera, \"Choose from\n * library\" beside the phone's camera app. Always there, at the same weight\n * as the camera, for anyone whose camera won't do.\n */\nconst PhotoCaptureFile = ({ children, asChild: _asChild, ...rest }: PhotoCaptureActionProps) => {\n const { flow, t, icons, accept } = usePhotoCaptureContext()\n return (\n <FileTrigger\n accept={accept}\n onSelect={(files) => flow.pick(files, \"file\")}\n startSlot={icons.file}\n {...rest}\n >\n {children ?? (flow.mode === \"native\" ? t.library : t.file)}\n </FileTrigger>\n )\n}\n\n/**\n * Back for another photo, the way this one came: the in-page camera again,\n * the phone's camera app again, or another file (\"Choose another\").\n */\nconst PhotoCaptureRetake = ({ children, asChild: _asChild, ...rest }: PhotoCaptureActionProps) => {\n const { flow, t, icons, accept } = usePhotoCaptureContext()\n return match(flow.origin)\n .with(\"camera\", () => (\n <Button\n variant=\"light\"\n startSlot={icons.retake}\n disabled={flow.busy}\n onClick={flow.retake}\n {...rest}\n >\n {children ?? t.retake}\n </Button>\n ))\n .with(\"native\", () => (\n <FileTrigger\n variant=\"light\"\n accept={accept}\n capture={flow.facing}\n disabled={flow.busy}\n onSelect={(files) => flow.pick(files, \"native\")}\n startSlot={icons.retake}\n {...rest}\n >\n {children ?? t.retake}\n </FileTrigger>\n ))\n .with(\"file\", () => (\n <FileTrigger\n variant=\"light\"\n accept={accept}\n disabled={flow.busy}\n onSelect={(files) => flow.pick(files, \"file\")}\n startSlot={icons.file}\n {...rest}\n >\n {children ?? t.another}\n </FileTrigger>\n ))\n .with(null, () => null)\n .exhaustive()\n}\n\n/**\n * \"Use photo\": exports the crop as `output` says, hands the File to\n * `onChange`, and starts over. Inside `PhotoCapture.Crop`, which provides the\n * cropper it exports. Takes focus when it appears, so after the shutter (or a\n * pick) Enter uses the photo.\n */\nconst PhotoCaptureConfirm = ({\n id,\n children,\n asChild: _asChild,\n ...rest\n}: PhotoCaptureActionProps) => {\n const { flow, t, icons, announce } = usePhotoCaptureContext()\n const cropper = useImageCropperContext()\n // Button takes no ref: found by its id to move focus to it.\n const generated = useId()\n const button = id ?? generated\n\n // The crop is only ever reached by a user's step: the shutter or a pick.\n // Again after a failure, which disabled (and so blurred) the button.\n useEffect(() => {\n if (!flow.busy) document.getElementById(button)?.focus()\n }, [flow.busy, button])\n\n return (\n <Button\n id={button}\n startSlot={icons.confirm}\n loading={flow.busy}\n onClick={async () => {\n const file = await flow.confirm(cropper.getCroppedImage)\n if (file) announce(t.announceDone)\n }}\n {...rest}\n >\n {children ?? t.confirm}\n </Button>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Steps\n// ---------------------------------------------------------------------------\n\nexport type PhotoCaptureSourceProps = NoAsChild<ComponentPropsWithoutRef<\"div\"> & WithTestId>\n\n/**\n * The first step: \"Take photo\" and the file picker, side by side at the same\n * weight, under a line that says nothing leaves the page. With `native`,\n * that's the phone's camera app and its library: two pickers, because\n * Android 14 and 15 hide the camera from a picker without `capture`.\n * Children replace the two buttons.\n */\nconst PhotoCaptureSource = ({\n className,\n testId,\n children,\n asChild: _asChild,\n ...rest\n}: PhotoCaptureSourceProps) => {\n const { flow, t } = usePhotoCaptureContext()\n const root = useRef<HTMLDivElement>(null)\n\n // Back here after a photo was used: focus goes to the first choice, not the page.\n useEffect(() => {\n if (flow.step === \"source\" && flow.moved)\n root.current?.querySelector<HTMLElement>(\"button:not(:disabled)\")?.focus()\n }, [flow.step, flow.moved])\n\n if (flow.step !== \"source\") return null\n return (\n <div\n ref={root}\n data-part=\"source\"\n className={cn(\n \"flex flex-col items-center justify-center gap-4 rounded-input border border-dashed p-6 text-center\",\n // The kit's hairline, dashed: FileUpload's dropzone.\n \"border-brand-900/20 dark:border-white/15\",\n className,\n )}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n <div className=\"flex flex-col gap-1\">\n <p className=\"font-medium text-brand-950 text-md dark:text-white\">{t.sourceTitle}</p>\n <p className=\"text-black/50 text-sm dark:text-white/50\">{t.sourceBody}</p>\n </div>\n {/* Side by side when they fit, stacked full width when not: the same weight either way. */}\n <div className=\"grid w-full max-w-md grid-cols-[repeat(auto-fit,minmax(min(100%,11rem),1fr))] gap-2\">\n {children ?? (\n <>\n <PhotoCaptureTake />\n <PhotoCaptureFile />\n </>\n )}\n </div>\n </div>\n )\n}\n\nexport type PhotoCaptureLiveClassNames = {\n viewfinder?: string\n controls?: string\n}\n\nexport type PhotoCaptureLiveProps = NoAsChild<\n Omit<ComponentPropsWithoutRef<\"div\">, \"children\" | \"color\"> &\n WithTestId & {\n classNames?: PhotoCaptureLiveClassNames\n }\n>\n\n/**\n * The in-page camera: `Camera`'s viewfinder with a guide in the flow's\n * shape, its status panels, the shutter, the camera switch and picker, and\n * the file picker beside the shutter. Every panel (asking, refused, busy, no\n * camera) offers the file picker too.\n *\n * Focus comes here as the step opens, and moves to the shutter once the\n * picture is live.\n */\nconst PhotoCaptureLive = ({\n className,\n classNames,\n testId,\n asChild: _asChild,\n ...rest\n}: PhotoCaptureLiveProps) => {\n const { flow, translations, cameraIcons, shape, color } = usePhotoCaptureContext()\n const root = useRef<HTMLDivElement>(null)\n const shutter = useRef<HTMLButtonElement>(null)\n /** Whether the shutter should take focus once it's enabled: after \"Take photo\" or a retake. */\n const pending = useRef(false)\n const status = flow.camera.status\n\n useEffect(() => {\n if (flow.step !== \"live\" || !flow.moved) return\n pending.current = true\n // The button that brought us here is gone: hold focus in the step until the shutter can take it.\n root.current?.focus()\n }, [flow.step, flow.moved])\n\n useEffect(() => {\n if (!pending.current || status !== \"live\") return\n pending.current = false\n shutter.current?.focus()\n }, [status])\n\n if (flow.step !== \"live\") return null\n return (\n <Camera.Root\n ref={root}\n tabIndex={-1}\n camera={flow.camera}\n onCapture={flow.take}\n output={SHOT}\n mirror={flow.mirror}\n translations={translations}\n icons={cameraIcons}\n color={color}\n data-part=\"live\"\n className={cn(\"outline-none\", className)}\n testId={testId}\n {...rest}\n >\n <Camera.Viewfinder ratio={flow.ratio} className={classNames?.viewfinder}>\n <Camera.Guide shape={shape} ratio={shape === \"rectangle\" ? flow.ratio : undefined} />\n <Camera.Live className=\"absolute start-2 top-2 z-1\" />\n <Camera.Status>{() => <PhotoCaptureFile size=\"sm\" />}</Camera.Status>\n </Camera.Viewfinder>\n <div className={cn(\"grid grid-cols-[1fr_auto_1fr] items-center gap-3\", classNames?.controls)}>\n {/* While a panel is up, it carries the file picker. */}\n <div className=\"flex min-w-0 justify-start\">\n {status === \"live\" && <PhotoCaptureFile variant=\"light\" />}\n </div>\n <Camera.Shutter ref={shutter} />\n <div className=\"flex min-w-0 items-center justify-end gap-2\">\n <Camera.Devices className=\"min-w-0\" />\n <Camera.Flip />\n </div>\n </div>\n </Camera.Root>\n )\n}\n\nexport type PhotoCaptureCropClassNames = {\n viewport?: string\n controls?: string\n actions?: string\n}\n\nexport type PhotoCaptureCropProps = NoAsChild<\n Omit<ComponentPropsWithoutRef<\"div\">, \"color\"> &\n WithTestId & {\n classNames?: PhotoCaptureCropClassNames\n /** Replaces the Retake and Use photo buttons. `PhotoCapture.Confirm` must stay inside. */\n children?: ReactNode\n }\n>\n\n/**\n * The photo in `ImageCropper`, locked to the flow's ratio and shape, with\n * its zoom, rotate and flip controls, then Retake and Use photo. Taking the\n * photo and cropping it are one step: there's no review screen between.\n */\nconst PhotoCaptureCrop = ({\n className,\n classNames,\n testId,\n children,\n asChild: _asChild,\n ...rest\n}: PhotoCaptureCropProps) => {\n const { flow, t, translations, shape, color } = usePhotoCaptureContext()\n // One URL per photo, which is also the cropper's key: a new photo starts a new crop.\n const url = useObjectUrl(flow.photo)\n\n if (flow.step !== \"crop\" || !url) return null\n return (\n <ImageCropper.Root\n key={url}\n ratio={shape === \"circle\" ? 1 : flow.ratio}\n shape={shape}\n color={color}\n translations={translations}\n data-part=\"crop\"\n className={className}\n testId={testId}\n {...rest}\n >\n <ImageCropper.Viewport className={classNames?.viewport}>\n <ImageCropper.Image src={url} />\n <ImageCropper.Selection />\n </ImageCropper.Viewport>\n <ImageCropper.Controls className={classNames?.controls} />\n {flow.failed && (\n <p role=\"alert\" className={cn(TEXT_COLOR_CLASSES.error, \"text-sm\")}>\n {t.failed}\n </p>\n )}\n <div className={cn(\"flex flex-wrap items-center justify-end gap-2\", classNames?.actions)}>\n {children ?? (\n <>\n <PhotoCaptureRetake />\n <PhotoCaptureConfirm />\n </>\n )}\n </div>\n </ImageCropper.Root>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Convenience\n// ---------------------------------------------------------------------------\n\nexport type PhotoCaptureClassNames = {\n source?: string\n live?: string\n viewfinder?: string\n crop?: string\n viewport?: string\n controls?: string\n actions?: string\n}\n\nexport type PhotoCaptureProps = NoAsChild<\n Omit<PhotoCaptureRootProps, \"flow\" | \"children\"> &\n UsePhotoCaptureOptions & {\n classNames?: PhotoCaptureClassNames\n }\n>\n\nconst PhotoCaptureComponent = ({\n onChange,\n camera,\n facing,\n ratio,\n resolution,\n mirror,\n output,\n classNames,\n asChild: _asChild,\n ...rest\n}: PhotoCaptureProps) => {\n const flow = usePhotoCapture({ onChange, camera, facing, ratio, resolution, mirror, output })\n return (\n <PhotoCaptureRoot flow={flow} {...rest}>\n <PhotoCaptureSource className={classNames?.source} />\n <PhotoCaptureLive\n className={classNames?.live}\n classNames={{ viewfinder: classNames?.viewfinder, controls: classNames?.controls }}\n />\n <PhotoCaptureCrop\n className={classNames?.crop}\n classNames={{\n viewport: classNames?.viewport,\n controls: classNames?.controls,\n actions: classNames?.actions,\n }}\n />\n </PhotoCaptureRoot>\n )\n}\n\nexport const PhotoCapture = Object.assign(PhotoCaptureComponent, {\n Root: PhotoCaptureRoot,\n Source: PhotoCaptureSource,\n Live: PhotoCaptureLive,\n Crop: PhotoCaptureCrop,\n Take: PhotoCaptureTake,\n File: PhotoCaptureFile,\n Retake: PhotoCaptureRetake,\n Confirm: PhotoCaptureConfirm,\n})\n"]}
@@ -3,7 +3,7 @@ import { Tabs } from '../../chunk-SOUDKESO.js';
3
3
  import { Text } from '../../chunk-XKDL4QS6.js';
4
4
  import { Divider } from '../../chunk-RLOWPCGG.js';
5
5
  import { calendarValueToDate, dateToCalendarValue } from '../../chunk-ZB5VMGKB.js';
6
- import { Button } from '../../chunk-SCXXJDKQ.js';
6
+ import { Button } from '../../chunk-SP6LCCTZ.js';
7
7
  import { useNow, isNowPending } from '../../chunk-JQJ23YQX.js';
8
8
  import { prefersReducedMotion } from '../../chunk-CQ4M4BSF.js';
9
9
  import '../../chunk-HDYORQZN.js';
@@ -13,12 +13,13 @@ import { Popover } from '../../chunk-RKCUXOU2.js';
13
13
  import '../../chunk-HWBFRDX7.js';
14
14
  import { resolveLogicalPlacement } from '../../chunk-V6PY7C6S.js';
15
15
  import { OverlayContainerProvider } from '../../chunk-SLUOF7XW.js';
16
- import { ActionIcon } from '../../chunk-BMEJBY6H.js';
16
+ import { ActionIcon } from '../../chunk-B5YHYI7E.js';
17
+ import '../../chunk-6B2GNPJP.js';
17
18
  import { devWarn, warnRenamedProp } from '../../chunk-LIZWCWED.js';
18
19
  import { useUncontrolled } from '../../chunk-PMUCGFY5.js';
19
20
  import '../../chunk-BUIHQJGE.js';
20
21
  import { iconStroke, mergeIcons } from '../../chunk-XXOR34T4.js';
21
- import '../../chunk-D2QIPQ74.js';
22
+ import '../../chunk-W3XX7BYT.js';
22
23
  import { withAsChildContent } from '../../chunk-R5LYFTHA.js';
23
24
  import { props } from '../../chunk-WYCMIIRR.js';
24
25
  import { focusStyles } from '../../chunk-C6NVU4F7.js';