@42-central/ui-react 0.20.1 → 0.20.2
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.
- package/dist/{chunk-MKKQE3TM.js → chunk-2BNIHOMT.js} +3 -3
- package/dist/{chunk-MKKQE3TM.js.map → chunk-2BNIHOMT.js.map} +1 -1
- package/dist/{chunk-LBAE6FP6.js → chunk-37VQGKD6.js} +4 -4
- package/dist/{chunk-LBAE6FP6.js.map → chunk-37VQGKD6.js.map} +1 -1
- package/dist/{chunk-SXNAUSEB.js → chunk-45TG7H5Q.js} +3 -3
- package/dist/{chunk-SXNAUSEB.js.map → chunk-45TG7H5Q.js.map} +1 -1
- package/dist/{chunk-NJPHZBLI.js → chunk-5CNVVA7I.js} +4 -4
- package/dist/{chunk-NJPHZBLI.js.map → chunk-5CNVVA7I.js.map} +1 -1
- package/dist/{chunk-BNWQ7IAZ.js → chunk-C74TV64U.js} +5 -5
- package/dist/{chunk-BNWQ7IAZ.js.map → chunk-C74TV64U.js.map} +1 -1
- package/dist/{chunk-RCF7HTG5.js → chunk-FDCPMUJK.js} +4 -4
- package/dist/{chunk-RCF7HTG5.js.map → chunk-FDCPMUJK.js.map} +1 -1
- package/dist/{chunk-E63VD25L.js → chunk-HQPU73WV.js} +4 -4
- package/dist/{chunk-E63VD25L.js.map → chunk-HQPU73WV.js.map} +1 -1
- package/dist/{chunk-POKLPMSB.js → chunk-LFQDB5OD.js} +3 -3
- package/dist/{chunk-POKLPMSB.js.map → chunk-LFQDB5OD.js.map} +1 -1
- package/dist/{chunk-5HUEBSIS.js → chunk-N66NC6QK.js} +120 -24
- package/dist/chunk-N66NC6QK.js.map +1 -0
- package/dist/{chunk-IOYZC7SA.js → chunk-UCCJUFOG.js} +3 -3
- package/dist/{chunk-IOYZC7SA.js.map → chunk-UCCJUFOG.js.map} +1 -1
- package/dist/{chunk-KMZENCEP.js → chunk-UVQXRDRO.js} +3 -3
- package/dist/{chunk-KMZENCEP.js.map → chunk-UVQXRDRO.js.map} +1 -1
- package/dist/chunk-V6PY7C6S.js +18 -0
- package/dist/chunk-V6PY7C6S.js.map +1 -0
- package/dist/{chunk-TWLJQE75.js → chunk-WXL5RP6P.js} +3 -3
- package/dist/{chunk-TWLJQE75.js.map → chunk-WXL5RP6P.js.map} +1 -1
- package/dist/{chunk-VTDBWU6H.js → chunk-YZJUPYPO.js} +3 -3
- package/dist/{chunk-VTDBWU6H.js.map → chunk-YZJUPYPO.js.map} +1 -1
- package/dist/{chunk-3BXKTWWD.js → chunk-Z4MBCKG5.js} +4 -4
- package/dist/{chunk-3BXKTWWD.js.map → chunk-Z4MBCKG5.js.map} +1 -1
- package/dist/components/autocomplete/index.js +3 -2
- package/dist/components/autocomplete/index.js.map +1 -1
- package/dist/components/camera/index.js +5 -4
- package/dist/components/code-block/chrome.js +4 -4
- package/dist/components/code-block/index.js +5 -5
- package/dist/components/combobox/index.js +3 -2
- package/dist/components/combobox-list/index.js +5 -4
- package/dist/components/data-table/index.js +12 -12
- package/dist/components/date-picker/index.js +6 -5
- package/dist/components/date-picker/index.js.map +1 -1
- package/dist/components/hover-card/hover-card.d.ts +44 -26
- package/dist/components/hover-card/hover-card.d.ts.map +1 -1
- package/dist/components/hover-card/index.js +35 -53
- package/dist/components/hover-card/index.js.map +1 -1
- package/dist/components/menu/index.js +3 -3
- package/dist/components/multi-combobox-list/index.js +5 -4
- package/dist/components/multi-select/index.js +3 -2
- package/dist/components/multi-select/index.js.map +1 -1
- package/dist/components/number-input/index.js +3 -2
- package/dist/components/photo-capture/index.js +5 -4
- package/dist/components/photo-capture/index.js.map +1 -1
- package/dist/components/popover/index.d.ts +1 -1
- package/dist/components/popover/index.d.ts.map +1 -1
- package/dist/components/popover/index.js +2 -1
- package/dist/components/popover/popover.d.ts +44 -29
- package/dist/components/popover/popover.d.ts.map +1 -1
- package/dist/components/schedule/index.js +2 -2
- package/dist/components/select/index.js +4 -3
- package/dist/components/spotlight/index.js +3 -2
- package/dist/components/spotlight/index.js.map +1 -1
- package/dist/components/tags-input/index.js +2 -1
- package/dist/components/tags-input/index.js.map +1 -1
- package/dist/components/time-input/index.js +4 -3
- package/dist/components/time-input/index.js.map +1 -1
- package/dist/components/tooltip/index.js +2 -2
- package/dist/components/tree-multi-select/index.js +3 -2
- package/dist/components/tree-multi-select/index.js.map +1 -1
- package/dist/components/tree-select/index.js +3 -2
- package/dist/components/tree-select/index.js.map +1 -1
- package/dist/lib/placement.d.ts +42 -1
- package/dist/lib/placement.d.ts.map +1 -1
- package/dist/lib/slide-on-switch.d.ts +69 -0
- package/dist/lib/slide-on-switch.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/hover-card/hover-card.tsx +89 -167
- package/src/components/popover/index.ts +2 -0
- package/src/components/popover/popover.test.tsx +131 -0
- package/src/components/popover/popover.tsx +191 -53
- package/src/lib/placement.test.ts +37 -0
- package/src/lib/placement.ts +60 -1
- package/src/lib/slide-on-switch.ts +99 -0
- package/dist/chunk-5HUEBSIS.js.map +0 -1
- package/dist/chunk-G52U24GR.js +0 -10
- package/dist/chunk-G52U24GR.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/hover-card/hover-card.tsx"],"names":["Ark"],"mappings":";;;;;;;;;;;;;;;AA+EA,IAAM,mBAAA,GAAsB;AAAA,EAC1B,kBAAA,EAAoB,WAAA;AAAA,EACpB,kBAAA,EAAoB,OAAA;AAAA,EACpB,wBAAA,EAA0B;AAC5B,CAAA;AAmBA,IAAM,mBAAmB,aAAA,CAAqC;AAAA,EAC5D,KAAA,EAAO,MAAA;AAAA,EACP,YAAA,EAAc,IAAA;AAAA,EACd,OAAA,EAAS;AACX,CAAC,CAAA;AA8BD,IAAM,OAAO,CAAC;AAAA,EACZ,KAAA,GAAQ,MAAA;AAAA,EACR,QAAA,GAAW,QAAA;AAAA,EACX,MAAA;AAAA,EACA,MAAA;AAAA,EACA,YAAA,GAAe,IAAA;AAAA,EACf,SAAA;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I,OAAA,EAAJ,EACE,WAAC,GAAA,KAAQ;AACR,UAAA,MAAM,MAAA,GAAS,SAAS,IAAA,CAAK,CAAC,MAAM,CAAA,CAAE,KAAA,CAAM,KAAA,KAAU,GAAA,CAAI,YAAY,CAAA;AAUtE,UAAA,OAAO,SAAS,YAAA,CAAa,MAAA,EAAQ,EAAE,GAAA,EAAK,0BAAA,EAA4B,CAAA,GAAI,IAAA;AAAA,QAC9E,CAAA,EACF;AAAA;AAAA;AAAA,GACF,EACF,CAAA;AAEJ,CAAA;AAEO,IAAM,SAAA,GAAY;AAAA,EACvB,IAAA;AAAA,EACA,SAASA,WAAA,CAAI,OAAA;AAAA,EACb,OAAA;AAAA,EACA;AACF","file":"index.js","sourcesContent":["\"use client\"\n\nimport { HoverCard as Ark } from \"@ark-ui/react/hover-card\"\nimport { useLocaleContext } from \"@ark-ui/react/locale\"\nimport { Portal } from \"@ark-ui/react/portal\"\nimport {\n Children,\n cloneElement,\n createContext,\n isValidElement,\n type ReactElement,\n type ReactNode,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport { useOverlayContainer } from \"../../lib/overlay-container\"\nimport { type LogicalPosition, resolveLogicalPlacement } from \"../../lib/placement\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { popoverChrome } from \"../popover/popover\"\n\n/**\n * HoverCard — a rich preview panel on Ark UI's HoverCard, shown after a short\n * hover/focus delay. It sits between `Popover` (a clickable, focus-trapping\n * panel with no delay) and `Tooltip` (a delayed hint with no rich content):\n * HoverCard is delayed *and* rich — the \"hover a username, see a profile\n * card\" pattern. Ark owns the open/close state, the open/close delays,\n * positioning, and dismiss-on-outside-interaction; the kit adds the portaled,\n * animated panel chrome (reusing `Popover`'s surface).\n *\n * Unlike `Tooltip`, there's no single-call convenience form — a hover card's\n * content is arbitrary rich markup, so it's compound-only, like `Popover`:\n *\n * <HoverCard.Root>\n * <HoverCard.Trigger asChild>\n * <a href=\"/norm\">@the-norm</a>\n * </HoverCard.Trigger>\n * <HoverCard.Content>\n * Rich <strong>preview</strong> content.\n * </HoverCard.Content>\n * </HoverCard.Root>\n *\n * Ark's machine defaults to a 600ms open delay and a 300ms close delay —\n * long enough that an incidental pass of the cursor doesn't pop a card open.\n * `HoverCard.Group` puts several trigger targets (e.g. a row of avatars) on\n * one *shared* card instead: Ark's own HoverCard machine supports multiple\n * named triggers under a single `Root`/`Content`, so hovering from one\n * target to the next while the card is already open just repositions the\n * same panel — no close/reopen, no delay replay — and it visibly slides\n * between targets.\n *\n * Keep its content a preview. Ark's machine ignores touch, never lets focus\n * into the card, and puts no `aria-expanded`/`aria-controls` on the trigger,\n * because a hover card previews where its trigger *link* goes. For a card\n * people act on (a copy button, a \"View profile\" link), use\n * `<Popover.Root mode=\"hover\">`. It keeps the delayed hover preview, and a\n * click, tap or Enter pins it as a focusable, dismissable popover.\n */\n\n/** Slide transition for `HoverCard.Group`'s shared positioner — Ark sets the\n * positioner's `transform: translate3d(var(--x), var(--y), 0)` inline\n * (`@zag-js/popper`); animating `transform` itself makes the browser\n * interpolate that translate smoothly between two trigger anchors when the\n * group's active trigger changes. Passed as `style` (not a class) so it\n * merges with — rather than replaces — Ark's own inline `transform`/\n * `position` (Ark's `mergeProps` shallow-merges style objects); same\n * override-the-real-style technique `Tabs.Indicator` / `SegmentGroup` use\n * for their sliding pill. Only applied inside `Group`, and only once\n * `HoverCardContextValue.sliding` is true (see `Group`) — never on the very\n * first open, where the positioner's `--x`/`--y` haven't been computed yet\n * (the panel briefly sits at its unset `transform: none` origin, the\n * viewport's top-left, before floating-ui places it); animating *that*\n * jump would read as the panel sliding in from the top of the screen\n * instead of just appearing. A standalone `Root` never gets this at all: it\n * also repositions on scroll/resize (`autoUpdate`), where an animated\n * `transform` would look laggy rather than responsive. */\nconst hoverCardSlideStyle = {\n transitionProperty: \"transform\",\n transitionDuration: \"200ms\",\n transitionTimingFunction: \"cubic-bezier(0.32, 0.72, 0, 1)\",\n} as const\n\ntype HoverCardPlacement = NonNullable<NonNullable<Ark.RootProps[\"positioning\"]>[\"placement\"]>\n\n/** `position` accepts Ark's physical placements plus the logical, RTL-aware\n * horizontal sides `start` / `end` (resolved to `left` / `right` by direction). */\nexport type HoverCardPosition = LogicalPosition<HoverCardPlacement>\n\ntype HoverCardContextValue = {\n width: \"target\" | \"auto\"\n withinPortal: boolean\n container?: HTMLElement | null\n /** Whether this `Content` is `HoverCard.Group`'s single shared panel *and*\n * has already completed its first open — `Group` flips this true one\n * frame after opening, once the panel has a real, computed position to\n * slide *from*. Gates the slide transition (see `hoverCardSlideStyle`) so\n * only a later switch between targets animates, never the initial reveal. */\n sliding: boolean\n}\nconst HoverCardContext = createContext<HoverCardContextValue>({\n width: \"auto\",\n withinPortal: true,\n sliding: false,\n})\n\nexport type HoverCardRootProps = Omit<Ark.RootProps, \"positioning\" | \"onOpenChange\"> & {\n /** Match the trigger's width (`\"target\"`), or size to content (`\"auto\"`,\n * default — a hover card's content is usually much larger than its\n * trigger, unlike a dropdown). */\n width?: \"target\" | \"auto\"\n /** Panel placement relative to the trigger. Defaults to Ark's `\"bottom\"`. */\n position?: HoverCardPosition\n /** Gap in px between the trigger and the panel. */\n gutter?: number\n /** Positioner offset. */\n offset?:\n | {\n mainAxis?: number | undefined\n crossAxis?: number | undefined\n }\n | undefined\n /** Render the panel in a Portal so it escapes clipping ancestors. Default `true`. */\n withinPortal?: boolean\n /** Portal target. Defaults to the enclosing `Modal`/`Drawer` when there is\n * one (so the panel stays above it), else `document.body`. */\n container?: HTMLElement | null\n /** Fires when the card opens or closes (flattened from Ark's detail object). */\n onOpenChange?: (open: boolean) => void\n /** Fires on close (any source) — pointer/focus leaving, Escape, outside\n * interaction, or a controlled `onOpenChange`. */\n onClose?: () => void\n}\n\nconst Root = ({\n width = \"auto\",\n position = \"bottom\",\n gutter,\n offset,\n withinPortal = true,\n container,\n openDelay,\n children,\n onOpenChange,\n onClose,\n ...rest\n}: HoverCardRootProps) => {\n const { dir } = useLocaleContext()\n\n return (\n <HoverCardContext.Provider value={{ width, withinPortal, container, sliding: false }}>\n <Ark.Root\n lazyMount\n unmountOnExit\n openDelay={openDelay}\n positioning={{\n sameWidth: width === \"target\",\n placement: resolveLogicalPlacement(position, dir),\n gutter,\n offset,\n }}\n onOpenChange={({ open }) => {\n onOpenChange?.(open)\n if (!open) onClose?.()\n }}\n {...rest}\n >\n {children}\n </Ark.Root>\n </HoverCardContext.Provider>\n )\n}\n\nexport type HoverCardContentProps = Ark.ContentProps &\n WithTestId & {\n /** Identifies which `HoverCard.Group` target this content belongs to —\n * only meaningful inside `HoverCard.Group`, where several `Content`s\n * share one panel and `Group` picks the one whose `value` matches the\n * active trigger. Ignored (and never forwarded to the DOM) otherwise. */\n value?: string\n }\n\nconst Content = ({\n className,\n children,\n testId,\n value: _value,\n ...rest\n}: HoverCardContentProps) => {\n const { width, withinPortal, container, sliding } = useContext(HoverCardContext)\n const portalContainer = useOverlayContainer(container)\n const panel = (\n <Ark.Positioner style={sliding ? hoverCardSlideStyle : undefined}>\n <Ark.Content\n tabIndex={-1}\n className={cn(popoverChrome, width === \"target\" ? \"w-full\" : \"w-max\", className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {children}\n </Ark.Content>\n </Ark.Positioner>\n )\n if (!withinPortal) return panel\n return <Portal container={portalContainer}>{panel}</Portal>\n}\n\nconst isGroupContent = (node: ReactNode): node is ReactElement<HoverCardContentProps> =>\n isValidElement(node) && node.type === Content\n\nexport type HoverCardGroupProps = Omit<\n Ark.RootProps,\n \"positioning\" | \"onOpenChange\" | \"children\"\n> & {\n /** Match every trigger's width (`\"target\"`), or size to content (`\"auto\"`,\n * default). */\n width?: \"target\" | \"auto\"\n /** Panel placement relative to the active trigger. Defaults to Ark's `\"bottom\"`. */\n position?: HoverCardPosition\n /** Gap in px between the active trigger and the panel. */\n gutter?: number\n /** Positioner offset. */\n offset?:\n | {\n mainAxis?: number | undefined\n crossAxis?: number | undefined\n }\n | undefined\n /** Render the panel in a Portal so it escapes clipping ancestors. Default `true`. */\n withinPortal?: boolean\n /** Portal target. Defaults to the enclosing `Modal`/`Drawer` when there is\n * one (so the panel stays above it), else `document.body`. */\n container?: HTMLElement | null\n /** Fires when the card opens or closes (flattened from Ark's detail object). */\n onOpenChange?: (open: boolean) => void\n /** Fires on close (any source) — pointer/focus leaving the whole group,\n * Escape, outside interaction, or a controlled `onOpenChange`. */\n onClose?: () => void\n /** `HoverCard.Trigger` (one per hover target, each with its own `value`)\n * and `HoverCard.Content` (one per target's content, `value`-matched to\n * its trigger) — the same parts `HoverCard.Root` uses, just several of\n * each instead of one. */\n children?: ReactNode\n}\n\n/**\n * One shared card across several hover targets (e.g. a row of avatars) — the\n * same `HoverCard.Trigger` / `HoverCard.Content` parts `HoverCard.Root` uses,\n * just several of each, disambiguated by a shared `value`:\n *\n * <HoverCard.Group>\n * <HoverCard.Trigger value=\"ada\">\n * <Avatar name=\"Ada Lovelace\" />\n * </HoverCard.Trigger>\n * <HoverCard.Trigger value=\"grace\">\n * <Avatar name=\"Grace Hopper\" />\n * </HoverCard.Trigger>\n *\n * <HoverCard.Content value=\"ada\">Ada's card content</HoverCard.Content>\n * <HoverCard.Content value=\"grace\">Grace's card content</HoverCard.Content>\n * </HoverCard.Group>\n *\n * Ark's HoverCard machine natively supports several named triggers under a\n * single `Root`/`Content` (a `triggerValue`, which `HoverCard.Trigger`'s\n * `value` already sets — it's a plain `Ark.Trigger` re-export): hovering from\n * one target to the next while the card is already open just repositions the\n * *same* panel instead of closing one and opening another — no unmount, no\n * delay replay. `Group` renders every `Trigger` child as-is (they need no\n * help — the machine already treats each `value` as a distinct target), but\n * intercepts every `Content` child: only the one whose `value` matches the\n * live `triggerValue` (read via Ark's `Context` render prop) is ever\n * rendered, in that one shared position — so React reconciles a value change\n * as a props update on the *same* `Content`/`Positioner`/`Content` element\n * tree, not an unmount-and-remount of a different one, which is what keeps\n * it one real, continuous DOM node to slide. Paired with a CSS transition on\n * the positioner's `transform` (`hoverCardSlideStyle`, applied by `Content`\n * whenever `sliding` is set), that reposition visibly slides the panel from\n * one target to the next.\n *\n * `Trigger`/`Content` must be `Group`'s own direct children — it only scans\n * one level (like `Timeline`/`Breadcrumb`), so wrapping them in an inner\n * `<div>` hides them from it entirely. `Group` (like `Root`) renders no DOM\n * node of its own, so for row-level layout (e.g. overlapping avatars via\n * `-space-x-2`), wrap `Group` itself from the outside instead — the actual\n * trigger elements still land exactly there, since `Content` is portaled\n * away separately.\n */\nconst Group = ({\n width = \"auto\",\n position = \"bottom\",\n gutter,\n offset,\n withinPortal = true,\n container,\n openDelay,\n children,\n onOpenChange,\n onClose,\n ...rest\n}: HoverCardGroupProps) => {\n const { dir } = useLocaleContext()\n const items = Children.toArray(children)\n const contents = items.filter(isGroupContent)\n const triggers = items.filter((item) => !isGroupContent(item))\n\n // False until one frame after opening, once the panel has a real computed\n // position to slide *from* — see `hoverCardSlideStyle`'s doc comment.\n // Reset on every close so the *next* pioneer open doesn't animate either.\n const [sliding, setSliding] = useState(false)\n const slidingRafRef = useRef<number | null>(null)\n useEffect(\n () => () => {\n if (slidingRafRef.current != null) cancelAnimationFrame(slidingRafRef.current)\n },\n [],\n )\n\n return (\n <HoverCardContext.Provider value={{ width, withinPortal, container, sliding }}>\n <Ark.Root\n lazyMount\n unmountOnExit\n openDelay={openDelay}\n positioning={{\n sameWidth: width === \"target\",\n placement: resolveLogicalPlacement(position, dir),\n gutter,\n offset,\n }}\n onOpenChange={({ open }) => {\n onOpenChange?.(open)\n if (open) {\n slidingRafRef.current = requestAnimationFrame(() => {\n slidingRafRef.current = null\n setSliding(true)\n })\n } else {\n if (slidingRafRef.current != null) {\n cancelAnimationFrame(slidingRafRef.current)\n slidingRafRef.current = null\n }\n setSliding(false)\n onClose?.()\n }\n }}\n {...rest}\n >\n {triggers}\n <Ark.Context>\n {(api) => {\n const active = contents.find((c) => c.props.value === api.triggerValue)\n // Force a stable `key`, overriding whatever each `Content` was\n // authored with (e.g. `key={person.handle}` in a `.map()`) — this\n // slot only ever renders one at a time, but a *different* key\n // switching in here reads to React as a different component,\n // unmounting the real Positioner/Content DOM tree and mounting a\n // fresh one instead of updating it in place. That fresh mount is\n // exactly what breaks the \"one shared, sliding panel\" contract:\n // its position starts unset again, so every switch would look\n // like the panel jumping in from the top instead of sliding.\n return active ? cloneElement(active, { key: \"hover-card-group-content\" }) : null\n }}\n </Ark.Context>\n </Ark.Root>\n </HoverCardContext.Provider>\n )\n}\n\nexport const HoverCard = {\n Root,\n Trigger: Ark.Trigger,\n Content,\n Group,\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/hover-card/hover-card.tsx"],"names":["Ark"],"mappings":";;;;;;;;;;;;;;;AA6EA,IAAM,mBAAmB,aAAA,CAAqC;AAAA,EAC5D,KAAA,EAAO,MAAA;AAAA,EACP,YAAA,EAAc,IAAA;AAAA,EACd,OAAA,EAAS;AACX,CAAC,CAAA;AAoBD,IAAM,OAAO,CAAC;AAAA,EACZ,KAAA,GAAQ,MAAA;AAAA,EACR,QAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,gBAAA;AAAA,EACA,WAAA;AAAA,EACA,YAAA,GAAe,IAAA;AAAA,EACf,SAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA,YAAA;AAAA,EACA,OAAA;AAAA,EACA,GAAG;AACL,CAAA,KAA0B;AACxB,EAAA,MAAM,EAAE,GAAA,EAAI,GAAI,gBAAA,EAAiB;AAEjC,EAAA,uBACE,GAAA,CAAC,gBAAA,CAAiB,QAAA,EAAjB,EAA0B,KAAA,EAAO,EAAE,KAAA,EAAO,YAAA,EAAc,SAAA,EAAW,OAAA,EAAS,KAAA,EAAM,EACjF,QAAA,kBAAA,GAAA;AAAA,IAACA,WAAA,CAAI,IAAA;AAAA,IAAJ;AAAA,MACC,SAAA,EAAS,IAAA;AAAA,MACT,aAAA,EAAa,IAAA;AAAA,MACb,SA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ACvB,CAAA;AAAA,MACC,GAAG,IAAA;AAAA,MAEH,QAAA,EAAA;AAAA,QAAA,QAAA;AAAA,wBACD,GAAA,CAACA,WAAA,CAAI,OAAA,EAAJ,EAAa,QAAA,EAAA,CAAC,QAAQ,kBAAA,CAAmB,QAAA,EAAU,GAAA,CAAI,YAAY,CAAA,EAAE;AAAA;AAAA;AAAA,GACxE,EACF,CAAA;AAEJ,CAAA;AAEO,IAAM,SAAA,GAAY;AAAA,EACvB,IAAA;AAAA,EACA,SAASA,WAAA,CAAI,OAAA;AAAA,EACb,OAAA;AAAA,EACA;AACF","file":"index.js","sourcesContent":["\"use client\"\n\nimport { HoverCard as Ark } from \"@ark-ui/react/hover-card\"\nimport { useLocaleContext } from \"@ark-ui/react/locale\"\nimport { Portal } from \"@ark-ui/react/portal\"\nimport { createContext, type ReactNode, useContext } from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport { useOverlayContainer } from \"../../lib/overlay-container\"\nimport {\n type LogicalPosition,\n type Placement,\n type PlacementProps,\n toPositioning,\n} from \"../../lib/placement\"\nimport { props } from \"../../lib/props\"\nimport {\n activeGroupContent,\n slideStyle,\n splitGroupChildren,\n useSlideAfterPlaced,\n} from \"../../lib/slide-on-switch\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { popoverChrome } from \"../popover/popover\"\n\n/**\n * HoverCard — a rich preview panel on Ark UI's HoverCard, shown after a short\n * hover/focus delay. It sits between `Popover` (a clickable, focus-trapping\n * panel with no delay) and `Tooltip` (a delayed hint with no rich content):\n * HoverCard is delayed *and* rich — the \"hover a username, see a profile\n * card\" pattern. Ark owns the open/close state, the open/close delays,\n * positioning, and dismiss-on-outside-interaction; the kit adds the portaled,\n * animated panel chrome (reusing `Popover`'s surface).\n *\n * Unlike `Tooltip`, there's no single-call convenience form — a hover card's\n * content is arbitrary rich markup, so it's compound-only, like `Popover`:\n *\n * <HoverCard.Root>\n * <HoverCard.Trigger asChild>\n * <a href=\"/norm\">@the-norm</a>\n * </HoverCard.Trigger>\n * <HoverCard.Content>\n * Rich <strong>preview</strong> content.\n * </HoverCard.Content>\n * </HoverCard.Root>\n *\n * Ark's machine defaults to a 600ms open delay and a 300ms close delay —\n * long enough that an incidental pass of the cursor doesn't pop a card open.\n * `HoverCard.Group` puts several trigger targets (e.g. a row of avatars) on\n * one *shared* card instead: Ark's own HoverCard machine supports multiple\n * named triggers under a single `Root`/`Content`, so hovering from one\n * target to the next while the card is already open just repositions the\n * same panel — no close/reopen, no delay replay — and it visibly slides\n * between targets.\n *\n * Keep its content a preview. Ark's machine ignores touch, never lets focus\n * into the card, and puts no `aria-expanded`/`aria-controls` on the trigger,\n * because a hover card previews where its trigger *link* goes. For a card\n * people act on (a copy button, a \"View profile\" link), use\n * `<Popover.Root mode=\"hover\">`. It keeps the delayed hover preview, and a\n * click, tap or Enter pins it as a focusable, dismissable popover.\n */\n\n/** `position` accepts Ark's physical placements plus the logical, RTL-aware\n * horizontal sides `start` / `end` (resolved to `left` / `right` by direction). */\nexport type HoverCardPosition = LogicalPosition<Placement>\n\ntype HoverCardContextValue = {\n width: \"target\" | \"auto\"\n withinPortal: boolean\n container?: HTMLElement | null\n /** Whether this `Content` is `HoverCard.Group`'s single shared panel *and*\n * its open has been placed once — `Group` flips this true after the first\n * placement lands, once the panel has a real position to slide *from*\n * (see `useSlideAfterPlaced`). Gates the slide transition (`slideStyle`)\n * so only a later switch between targets animates, never the reveal. */\n sliding: boolean\n}\nconst HoverCardContext = createContext<HoverCardContextValue>({\n width: \"auto\",\n withinPortal: true,\n sliding: false,\n})\n\nexport type HoverCardRootProps = Omit<Ark.RootProps, \"positioning\" | \"onOpenChange\"> &\n PlacementProps & {\n /** Match the trigger's width (`\"target\"`), or size to content (`\"auto\"`,\n * default — a hover card's content is usually much larger than its\n * trigger, unlike a dropdown). */\n width?: \"target\" | \"auto\"\n /** Render the panel in a Portal so it escapes clipping ancestors. Default `true`. */\n withinPortal?: boolean\n /** Portal target. Defaults to the enclosing `Modal`/`Drawer` when there is\n * one (so the panel stays above it), else `document.body`. */\n container?: HTMLElement | null\n /** Fires when the card opens or closes (flattened from Ark's detail object). */\n onOpenChange?: (open: boolean) => void\n /** Fires on close (any source) — pointer/focus leaving, Escape, outside\n * interaction, or a controlled `onOpenChange`. */\n onClose?: () => void\n }\n\nconst Root = ({\n width = \"auto\",\n position,\n gutter,\n offset,\n hideWhenDetached,\n positioning,\n withinPortal = true,\n container,\n openDelay,\n children,\n onOpenChange,\n onClose,\n ...rest\n}: HoverCardRootProps) => {\n const { dir } = useLocaleContext()\n\n return (\n <HoverCardContext.Provider value={{ width, withinPortal, container, sliding: false }}>\n <Ark.Root\n lazyMount\n unmountOnExit\n openDelay={openDelay}\n positioning={toPositioning(\n { position, gutter, offset, hideWhenDetached, positioning },\n dir,\n width,\n )}\n onOpenChange={({ open }) => {\n onOpenChange?.(open)\n if (!open) onClose?.()\n }}\n {...rest}\n >\n {children}\n </Ark.Root>\n </HoverCardContext.Provider>\n )\n}\n\nexport type HoverCardContentProps = Ark.ContentProps &\n WithTestId & {\n /** Identifies which `HoverCard.Group` target this content belongs to —\n * only meaningful inside `HoverCard.Group`, where several `Content`s\n * share one panel and `Group` picks the one whose `value` matches the\n * active trigger. Ignored (and never forwarded to the DOM) otherwise. */\n value?: string\n }\n\nconst Content = ({\n className,\n children,\n testId,\n value: _value,\n ...rest\n}: HoverCardContentProps) => {\n const { width, withinPortal, container, sliding } = useContext(HoverCardContext)\n const portalContainer = useOverlayContainer(container)\n const panel = (\n <Ark.Positioner style={sliding ? slideStyle : undefined}>\n <Ark.Content\n tabIndex={-1}\n className={cn(popoverChrome, width === \"target\" ? \"w-full\" : \"w-max\", className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {children}\n </Ark.Content>\n </Ark.Positioner>\n )\n if (!withinPortal) return panel\n return <Portal container={portalContainer}>{panel}</Portal>\n}\n\nexport type HoverCardGroupProps = Omit<Ark.RootProps, \"positioning\" | \"onOpenChange\" | \"children\"> &\n PlacementProps & {\n /** Match every trigger's width (`\"target\"`), or size to content (`\"auto\"`,\n * default). */\n width?: \"target\" | \"auto\"\n /** Render the panel in a Portal so it escapes clipping ancestors. Default `true`. */\n withinPortal?: boolean\n /** Portal target. Defaults to the enclosing `Modal`/`Drawer` when there is\n * one (so the panel stays above it), else `document.body`. */\n container?: HTMLElement | null\n /** Fires when the card opens or closes (flattened from Ark's detail object). */\n onOpenChange?: (open: boolean) => void\n /** Fires on close (any source) — pointer/focus leaving the whole group,\n * Escape, outside interaction, or a controlled `onOpenChange`. */\n onClose?: () => void\n /** `HoverCard.Trigger` (one per hover target, each with its own `value`)\n * and `HoverCard.Content` (one per target's content, `value`-matched to\n * its trigger) — the same parts `HoverCard.Root` uses, just several of\n * each instead of one. */\n children?: ReactNode\n }\n\n/**\n * One shared card across several hover targets (e.g. a row of avatars) — the\n * same `HoverCard.Trigger` / `HoverCard.Content` parts `HoverCard.Root` uses,\n * just several of each, disambiguated by a shared `value`:\n *\n * <HoverCard.Group>\n * <HoverCard.Trigger value=\"ada\">\n * <Avatar name=\"Ada Lovelace\" />\n * </HoverCard.Trigger>\n * <HoverCard.Trigger value=\"grace\">\n * <Avatar name=\"Grace Hopper\" />\n * </HoverCard.Trigger>\n *\n * <HoverCard.Content value=\"ada\">Ada's card content</HoverCard.Content>\n * <HoverCard.Content value=\"grace\">Grace's card content</HoverCard.Content>\n * </HoverCard.Group>\n *\n * Ark's HoverCard machine natively supports several named triggers under a\n * single `Root`/`Content` (a `triggerValue`, which `HoverCard.Trigger`'s\n * `value` already sets — it's a plain `Ark.Trigger` re-export): hovering from\n * one target to the next while the card is already open just repositions the\n * *same* panel instead of closing one and opening another — no unmount, no\n * delay replay. `Group` renders every `Trigger` child as-is (they need no\n * help — the machine already treats each `value` as a distinct target), but\n * intercepts every `Content` child: only the one whose `value` matches the\n * live `triggerValue` (read via Ark's `Context` render prop) is ever\n * rendered, in that one shared position — so React reconciles a value change\n * as a props update on the *same* `Content`/`Positioner`/`Content` element\n * tree, not an unmount-and-remount of a different one, which is what keeps\n * it one real, continuous DOM node to slide. Paired with a CSS transition on\n * the positioner's `transform` (`slideStyle`, applied by `Content`\n * whenever `sliding` is set), that reposition visibly slides the panel from\n * one target to the next.\n *\n * `Trigger`/`Content` must be `Group`'s own direct children — it only scans\n * one level (like `Timeline`/`Breadcrumb`), so wrapping them in an inner\n * `<div>` hides them from it entirely. `Group` (like `Root`) renders no DOM\n * node of its own, so for row-level layout (e.g. overlapping avatars via\n * `-space-x-2`), wrap `Group` itself from the outside instead — the actual\n * trigger elements still land exactly there, since `Content` is portaled\n * away separately.\n */\nconst Group = ({\n width = \"auto\",\n position,\n gutter,\n offset,\n hideWhenDetached,\n positioning,\n withinPortal = true,\n container,\n openDelay,\n children,\n onOpenChange,\n onClose,\n ...rest\n}: HoverCardGroupProps) => {\n const { dir } = useLocaleContext()\n const { contents, triggers } = splitGroupChildren(children, Content)\n const slide = useSlideAfterPlaced()\n\n return (\n <HoverCardContext.Provider value={{ width, withinPortal, container, sliding: slide.sliding }}>\n <Ark.Root\n lazyMount\n unmountOnExit\n openDelay={openDelay}\n positioning={toPositioning(\n {\n position,\n gutter,\n offset,\n hideWhenDetached,\n positioning: {\n ...positioning,\n updatePosition: slide.updatePosition(positioning?.updatePosition),\n },\n },\n dir,\n width,\n )}\n onOpenChange={({ open }) => {\n onOpenChange?.(open)\n slide.onOpenChange(open)\n if (!open) onClose?.()\n }}\n {...rest}\n >\n {triggers}\n <Ark.Context>{(api) => activeGroupContent(contents, api.triggerValue)}</Ark.Context>\n </Ark.Root>\n </HoverCardContext.Provider>\n )\n}\n\nexport const HoverCard = {\n Root,\n Trigger: Ark.Trigger,\n Content,\n Group,\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Context, SubContent, SubTrigger, Sub, RadioItem, RadioGroup, CheckboxItem, Separator, Divider, ItemGroupLabel, ItemGroup, Label, Item, Content, ContextTrigger, Trigger, Root } from '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
4
|
-
import '../../chunk-
|
|
2
|
+
import { Context, SubContent, SubTrigger, Sub, RadioItem, RadioGroup, CheckboxItem, Separator, Divider, ItemGroupLabel, ItemGroup, Label, Item, Content, ContextTrigger, Trigger, Root } from '../../chunk-FDCPMUJK.js';
|
|
3
|
+
import '../../chunk-N66NC6QK.js';
|
|
4
|
+
import '../../chunk-V6PY7C6S.js';
|
|
5
5
|
import '../../chunk-7P32XCEU.js';
|
|
6
6
|
import '../../chunk-H7WOMZXO.js';
|
|
7
7
|
import '../../chunk-6N6J2DOE.js';
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export { MultiComboboxList } from '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
2
|
+
export { MultiComboboxList } from '../../chunk-37VQGKD6.js';
|
|
3
|
+
import '../../chunk-45TG7H5Q.js';
|
|
4
4
|
import '../../chunk-NLOBBJAA.js';
|
|
5
5
|
import '../../chunk-7TDHT3QD.js';
|
|
6
|
-
import '../../chunk-
|
|
6
|
+
import '../../chunk-2BNIHOMT.js';
|
|
7
7
|
import '../../chunk-45QRQKRC.js';
|
|
8
8
|
import '../../chunk-VD6PB3VA.js';
|
|
9
|
-
import '../../chunk-
|
|
9
|
+
import '../../chunk-N66NC6QK.js';
|
|
10
|
+
import '../../chunk-V6PY7C6S.js';
|
|
10
11
|
import '../../chunk-7P32XCEU.js';
|
|
11
12
|
import '../../chunk-H7WOMZXO.js';
|
|
12
13
|
import '../../chunk-PMUCGFY5.js';
|
|
@@ -3,12 +3,13 @@ import { usePillOverflow, PillOverflowCounter, pillsContent, pillsShell } from '
|
|
|
3
3
|
import { Pill } from '../../chunk-6M6YZ3PQ.js';
|
|
4
4
|
import { normalizeSelectData, useLabelSearch, filterSelectData } from '../../chunk-7TDHT3QD.js';
|
|
5
5
|
import { controlOpenProps } from '../../chunk-5FDOOG4J.js';
|
|
6
|
-
import { COMBOBOX_DEFAULT_TRANSLATIONS, Combobox } from '../../chunk-
|
|
6
|
+
import { COMBOBOX_DEFAULT_TRANSLATIONS, Combobox } from '../../chunk-2BNIHOMT.js';
|
|
7
7
|
import { inputSlot, inputControlClasses, placeholderColor, inputShell } from '../../chunk-45QRQKRC.js';
|
|
8
8
|
import { FieldShell } from '../../chunk-VD6PB3VA.js';
|
|
9
9
|
import '../../chunk-2LI3VPDP.js';
|
|
10
10
|
import '../../chunk-IPYHTCFL.js';
|
|
11
|
-
import '../../chunk-
|
|
11
|
+
import '../../chunk-N66NC6QK.js';
|
|
12
|
+
import '../../chunk-V6PY7C6S.js';
|
|
12
13
|
import '../../chunk-7P32XCEU.js';
|
|
13
14
|
import '../../chunk-H7WOMZXO.js';
|
|
14
15
|
import '../../chunk-6N6J2DOE.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/multi-select/multi-select.tsx"],"names":["ArkCombobox"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyIA,IAAM,iCAAA,GAAoC;AAAA,EACxC,WAAA,EAAa,CAAC,KAAA,KAAU,CAAA,OAAA,EAAU,KAAK,CAAA;AACzC,CAAA;AAEO,IAAM,cAAc,CAAgC;AAAA,EACzD,IAAA;AAAA,EACA,KAAA,EAAO,SAAA;AAAA,EACP,YAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA,GAAa,IAAA;AAAA,EACb,iBAAA;AAAA,EACA,SAAA;AAAA,EACA,gBAAA,GAAmB,SAAA;AAAA,EACnB,SAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA,iBAAA;AAAA,EACA,KAAA,GAAQ,eAAA;AAAA,EACR,IAAA,GAAO,IAAA;AAAA,EACP,OAAA,GAAU,SAAA;AAAA,EACV,QAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AAAA,EACA,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CAAA,EAAA,EAApC,CAAuC,CAAE;AAAA;AAAA;AAAA,WAC1E;AAAA,QAEJ,CAAA,EACF,CAAA;AAAA,6BAEC,QAAA,CAAS,OAAA,EAAT,EAAiB,SAAA,EAAW,YAAY,OAAA,EACtC,QAAA,EAAA;AAAA,UAAA,MAAA,GACG,MAAA,CAAO,IAAI,CAAC,KAAA,yBACT,QAAA,CAAS,KAAA,EAAT,EAAiC,KAAA,EAAO,KAAA,CAAM,KAAA,EAC5C,gBAAM,KAAA,CAAM,GAAA,CAAI,YAAY,CAAA,EAAA,EADV,KAAA,CAAM,KAE3B,CACD,CAAA,GACD,KAAA,CAAM,GAAA,CAAI,YAAY,CAAA;AAAA,UACzB,SAAS,IAAA,oBAAQ,GAAA,CAAC,QAAA,CAAS,KAAA,EAAT,EAAgB,QAAA,EAAA,KAAA,EAAM;AAAA,SAAA,EAC3C;AAAA;AAAA;AAAA,GACF;AAGF,EAAA,uBACE,GAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MACA,WAAA;AAAA,MACA,KAAA;AAAA,MACA,QAAA;AAAA,MACA,QAAA;AAAA,MACA,IAAA;AAAA,MACA,WAAW,UAAA,EAAY,KAAA;AAAA,MAEtB,QAAA,EAAA;AAAA;AAAA,GACH;AAEJ","file":"index.js","sourcesContent":["\"use client\"\n\nimport { Combobox as ArkCombobox } from \"@ark-ui/react/combobox\"\nimport { type FocusEvent, type ReactNode, type Ref, useMemo, useState } from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport { controlOpenProps } from \"../../lib/control-open\"\nimport { props } from \"../../lib/props\"\nimport {\n type ClearSectionMode,\n filterSelectData,\n type NormalizedItemOf,\n normalizeSelectData,\n type RenderItem,\n type SelectData,\n type SelectValue,\n useLabelSearch,\n} from \"../../lib/select-data\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { useUncontrolled } from \"../../lib/use-uncontrolled\"\nimport {\n COMBOBOX_DEFAULT_TRANSLATIONS,\n Combobox,\n type ComboboxTranslations,\n} from \"../combobox/combobox\"\nimport { type FieldProps, FieldShell } from \"../field/field\"\nimport {\n type InputSize,\n type InputVariant,\n inputControlClasses,\n inputShell,\n inputSlot,\n placeholderColor,\n} from \"../input/input\"\nimport { Pill } from \"../pill/pill\"\nimport {\n PillOverflowCounter,\n type PillsInputTranslations,\n pillsContent,\n pillsShell,\n usePillOverflow,\n} from \"../pills-input/pills-input\"\n\n/**\n * MultiSelect — pick several values, shown as removable pills in a wrapping\n * input, searchable by default. It's the whole family working together:\n * Combobox (`multiple`) drives selection, the control is the PillsInput shell,\n * and each value renders as a `Pill`.\n *\n * - `data` matches `Select` (strings / objects / groups); `value` is `string[]`.\n * - Type to filter; pick to add (a check marks selected options); remove via a\n * pill's ×, Backspace on the empty field, or the clear button.\n * - `maxValues` caps selections; `hidePickedOptions` drops chosen options from\n * the list; `searchable={false}` turns it into a click-to-open multi-picker.\n * - Label / description / error come from the built-in `Field`.\n */\n\ntype MultiSelectClassNames = {\n root?: string\n field?: string\n control?: string\n input?: string\n option?: string\n popover?: string\n pill?: string\n}\n\nexport type MultiSelectProps<Data extends SelectData> = Pick<\n FieldProps,\n \"label\" | \"description\" | \"error\" | \"required\"\n> &\n WithTestId & {\n /** Options: `string[]`, `{ value, label?, disabled?, color? }[]`, or `{ group, items }[]`. */\n data: Data\n /** Controlled selected values. */\n value?: SelectValue<Data>[]\n /** Uncontrolled initial selection. */\n defaultValue?: SelectValue<Data>[]\n /** Fires with the full selection on every add / remove. */\n onChange?: (value: SelectValue<Data>[]) => void\n /**\n * Render each option yourself. Receives the (value-narrowed) item and its live\n * `{ selected, highlighted }` state; you own the whole row, including any check\n * affordance. Omit it to render the label + selected check.\n */\n renderItem?: RenderItem<Data>\n /** Placeholder shown while nothing is selected. */\n placeholder?: string\n /** Type to filter the options. Default `true`. */\n searchable?: boolean\n /** Placeholder for the search field once a value is already picked — before that, the\n * field shows `placeholder` instead. No default; omit it to show nothing, as today. */\n searchPlaceholder?: string\n /** Show a button that clears all values. */\n clearable?: boolean\n /** Whether the clear button replaces the chevron (`\"replace\"`, default) or sits beside it (`\"both\"`). */\n clearSectionMode?: ClearSectionMode\n /** Cap the number of selected values. */\n maxValues?: number\n /** Cap the pills at N rows; the rest collapse into a static \"+N\" counter. */\n maxLines?: number\n /** Inline-start adornment (icon, label). */\n startSlot?: ReactNode\n /** Inline-end adornment — rendered before the clear button / chevron. */\n endSlot?: ReactNode\n /** Hide options that are already selected. */\n hidePickedOptions?: boolean\n /** Message shown when no option matches. Pass `null` to render nothing. */\n empty?: ReactNode\n size?: InputSize\n variant?: InputVariant\n disabled?: boolean\n readOnly?: boolean\n /** Red invalid state, independent of (and OR'd with) `error`. */\n invalid?: boolean\n /** Wires hidden inputs into native form submission. */\n name?: string\n /** Forwarded to the search input; drives touched/blurred validation. */\n onBlur?: (event: FocusEvent<HTMLInputElement>) => void\n /** Lands on the focusable search `<input>` for focus-on-error. */\n ref?: Ref<HTMLInputElement>\n className?: string\n classNames?: MultiSelectClassNames\n /** Overrides the control's wording — see `MultiSelectTranslations`. A partial override keeps\n * the other defaults. */\n translations?: MultiSelectTranslations\n }\n\n/** The combobox family's `triggerLabel` (default `\"Show options\"`) and `clearTriggerLabel`\n * (default `\"Clear value\"`), plus `removeValue`: a value pill's remove-button name, given the\n * value's label (default `` label => `Remove ${label}` ``, so each pill names its own value),\n * and `PillsInput`'s `overflowCount`: what a screen reader hears for the `maxLines` \"+N\"\n * counter (default `\"3 more items\"`). */\nexport type MultiSelectTranslations = ComboboxTranslations &\n PillsInputTranslations & {\n removeValue?: (label: string) => string\n }\n\nconst MULTI_SELECT_DEFAULT_TRANSLATIONS = {\n removeValue: (label) => `Remove ${label}`,\n} as const satisfies MultiSelectTranslations\n\nexport const MultiSelect = <const Data extends SelectData>({\n data,\n value: valueProp,\n defaultValue,\n onChange,\n renderItem,\n placeholder,\n searchable = true,\n searchPlaceholder,\n clearable,\n clearSectionMode = \"replace\",\n maxValues,\n maxLines,\n startSlot,\n endSlot,\n hidePickedOptions,\n empty = \"Nothing found\",\n size = \"md\",\n variant = \"default\",\n disabled,\n readOnly,\n required,\n invalid,\n name,\n onBlur,\n ref,\n label,\n description,\n error,\n className,\n classNames,\n testId,\n translations,\n}: MultiSelectProps<Data>) => {\n const resolvedTranslations = {\n ...COMBOBOX_DEFAULT_TRANSLATIONS,\n ...MULTI_SELECT_DEFAULT_TRANSLATIONS,\n ...translations,\n }\n type Item = SelectValue<Data>\n\n // Red state is driven independently of the `Field` error slot so a form\n // library can flip it from `fieldState.invalid` (see FormControlProps).\n const isInvalid = invalid || error != null\n\n const [value, setSelected] = useUncontrolled<Item[]>({\n value: valueProp,\n defaultValue: defaultValue ?? [],\n onChange,\n })\n const [search, setSearch] = useState(\"\")\n\n const setValues = (next: Item[]) => {\n // Adding past the cap is rejected; removals always pass.\n if (maxValues != null && next.length > value.length && next.length > maxValues) {\n return\n }\n setSelected(next)\n }\n const removeValue = (v: Item) => setValues(value.filter((x) => x !== v))\n\n const { containerRef, visibleCount, hiddenCount, measuring } = usePillOverflow({\n maxLines,\n count: value.length,\n })\n\n // Normalize once per `data`; the item map and the filter both derive from it.\n const normalized = useMemo(() => normalizeSelectData(data), [data])\n // value -> full item, so a selected pill can pull both its label and its\n // color from one lookup instead of two parallel maps.\n const itemMap = useMemo(() => new Map(normalized.items.map((i) => [i.value, i])), [normalized])\n const labelSearch = useLabelSearch()\n const { collection, items, groups } = useMemo(() => {\n const query = searchable ? search : \"\"\n const picked = new Set<string>(value)\n return filterSelectData(\n normalized,\n (item) =>\n (!hidePickedOptions || !picked.has(item.value)) && labelSearch.matches(item.label, query),\n )\n }, [normalized, search, searchable, hidePickedOptions, value, labelSearch])\n\n const renderOption = (item: NormalizedItemOf<Data>) => (\n <Combobox.Item\n key={item.value}\n item={item}\n data-testid={item.testId}\n className={classNames?.option}\n >\n {renderItem ? (state) => renderItem(item, state) : item.label}\n </Combobox.Item>\n )\n\n const control = (\n <Combobox.Root<NormalizedItemOf<Data>>\n multiple\n collection={collection}\n value={value}\n // Ark types the values as `string[]`; they always originate from `data`,\n // so narrow back to the caller's value union.\n onValueChange={(details) => setValues(details.value as Item[])}\n inputValue={search}\n onInputValueChange={(details) => {\n if (searchable) setSearch(details.inputValue)\n }}\n selectionBehavior=\"clear\"\n closeOnSelect={false}\n openOnClick\n disabled={disabled}\n readOnly={readOnly}\n size={size}\n variant={variant}\n className={cn(className, classNames?.root)}\n translations={resolvedTranslations}\n >\n <ArkCombobox.Context>\n {(api) => {\n const showClear = Boolean(clearable) && api.hasSelectedItems && !disabled && !readOnly\n return (\n <ArkCombobox.Control\n {...props({\n \"data-invalid\": isInvalid,\n \"data-with-start-slot\": startSlot != null,\n // The composed Trigger always sits at the end. for now.\n \"data-with-end-slot\": true,\n })}\n // Tablet affordance: a tap on the field's dead zones (padding, empty\n // space, pill gaps) opens the list and focuses the search input. The\n // input, pill ✕, clear ✕ and chevron all manage their own taps.\n // Inert when disabled / readOnly, so it never opens where the input won't.\n {...(disabled || readOnly ? {} : controlOpenProps(() => api.setOpen(true)))}\n className={cn(inputShell({ size, variant }), pillsShell, classNames?.control)}\n >\n {startSlot != null && (\n <span className={inputSlot} aria-hidden>\n {startSlot}\n </span>\n )}\n <div ref={containerRef} className={pillsContent({ size })}>\n {value.slice(0, visibleCount).map((v) => (\n <Pill\n key={v}\n size={size}\n color={itemMap.get(v)?.color}\n disabled={disabled}\n withRemoveButton={!readOnly}\n onRemove={() => removeValue(v)}\n removeLabel={resolvedTranslations.removeValue(itemMap.get(v)?.label ?? v)}\n className={classNames?.pill}\n data-overflow-item\n >\n {itemMap.get(v)?.label ?? v}\n </Pill>\n ))}\n {/* Mounted during the measuring pass so the hook can size the last-row\n reservation off the real counter, but kept `invisible` then (still\n measurable) so it never paints on the SSR HTML before the first\n measure. Only mounts while measuring when a cap is configured. */}\n {(hiddenCount > 0 || (measuring && maxLines != null)) && (\n <PillOverflowCounter\n count={measuring ? value.length : hiddenCount}\n size={size}\n className={measuring ? \"invisible\" : undefined}\n translations={resolvedTranslations}\n />\n )}\n {/* Ark's own Input (a forwardRef) so the caller's `ref` lands on\n the real focusable `<input>` for RHF focus-on-error; the kit's\n `Combobox.Input` wrapper only adds `inputControlClasses`,\n replicated here. `name` is intentionally NOT here — it would\n submit the typed search text, not the selection (see the hidden\n inputs below). */}\n {searchable ? (\n <ArkCombobox.Input\n data-overflow-field\n placeholder={value.length === 0 ? placeholder : searchPlaceholder}\n readOnly={!searchable || readOnly}\n onBlur={onBlur}\n ref={ref}\n {...props({ \"aria-invalid\": isInvalid, \"data-testid\": testId })}\n className={cn(inputControlClasses, \"w-auto min-w-16\", classNames?.input)}\n onKeyDown={(event) => {\n const last = value[value.length - 1]\n if (\n event.key === \"Backspace\" &&\n event.currentTarget.value === \"\" &&\n last !== undefined &&\n !readOnly\n ) {\n removeValue(last)\n }\n }}\n />\n ) : (\n value.length <= 0 && (\n <span className={cn(placeholderColor, \"truncate\")}>{placeholder}</span>\n )\n )}\n </div>\n {endSlot != null && <span className={inputSlot}>{endSlot}</span>}\n {showClear && <Combobox.ClearTrigger />}\n {(clearSectionMode === \"both\" || !showClear) && <Combobox.Trigger data-chevron />}\n {/* Hidden inputs carry the real selection so a native `<form>`\n submits the value array (the search input is unnamed). When\n controlled by a form library the value flows through `onChange`\n instead, and these are just submitted alongside it. */}\n {name != null &&\n value.map((v) => <input key={v} type=\"hidden\" name={name} value={v} />)}\n </ArkCombobox.Control>\n )\n }}\n </ArkCombobox.Context>\n\n <Combobox.Content className={classNames?.popover}>\n {groups\n ? groups.map((group) => (\n <Combobox.Group key={group.group} label={group.group}>\n {group.items.map(renderOption)}\n </Combobox.Group>\n ))\n : items.map(renderOption)}\n {empty != null && <Combobox.Empty>{empty}</Combobox.Empty>}\n </Combobox.Content>\n </Combobox.Root>\n )\n\n return (\n <FieldShell\n label={label}\n description={description}\n error={error}\n required={required}\n disabled={disabled}\n size={size}\n className={classNames?.field}\n >\n {control}\n </FieldShell>\n )\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/multi-select/multi-select.tsx"],"names":["ArkCombobox"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAyIA,IAAM,iCAAA,GAAoC;AAAA,EACxC,WAAA,EAAa,CAAC,KAAA,KAAU,CAAA,OAAA,EAAU,KAAK,CAAA;AACzC,CAAA;AAEO,IAAM,cAAc,CAAgC;AAAA,EACzD,IAAA;AAAA,EACA,KAAA,EAAO,SAAA;AAAA,EACP,YAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA,GAAa,IAAA;AAAA,EACb,iBAAA;AAAA,EACA,SAAA;AAAA,EACA,gBAAA,GAAmB,SAAA;AAAA,EACnB,SAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA,iBAAA;AAAA,EACA,KAAA,GAAQ,eAAA;AAAA,EACR,IAAA,GAAO,IAAA;AAAA,EACP,OAAA,GAAU,SAAA;AAAA,EACV,QAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AAAA,EACA,MAAA;AAAA,EACA,GAAA;AAAA,EACA,KAAA;AAAA,EACA,WAAA;AAAA,EACA,KAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,KAA8B;AAC5B,EAAA,MAAM,oBAAA,GAAuB;AAAA,IAC3B,GAAG,6BAAA;AAAA,IACH,GAAG,iCAAA;AAAA,IACH,GAAG;AAAA,GACL;AAKA,EAAA,MAAM,SAAA,GAAY,WAAW,KAAA,IAAS,IAAA;AAEtC,EAAA,MAAM,CAAC,KAAA,EAAO,WAAW,CAAA,GAAI,eAAA,CAAwB;AAAA,IACnD,KAAA,EAAO,SAAA;AAAA,IACP,YAAA,EAAc,gBAAgB,EAAC;AAAA,IAC/B;AAAA,GACD,CAAA;AACD,EAAA,MAAM,CAA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A,EAAA,KAAA,EAAM;AAAA,SAAA,EAC3C;AAAA;AAAA;AAAA,GACF;AAGF,EAAA,uBACE,GAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MACA,WAAA;AAAA,MACA,KAAA;AAAA,MACA,QAAA;AAAA,MACA,QAAA;AAAA,MACA,IAAA;AAAA,MACA,WAAW,UAAA,EAAY,KAAA;AAAA,MAEtB,QAAA,EAAA;AAAA;AAAA,GACH;AAEJ","file":"index.js","sourcesContent":["\"use client\"\n\nimport { Combobox as ArkCombobox } from \"@ark-ui/react/combobox\"\nimport { type FocusEvent, type ReactNode, type Ref, useMemo, useState } from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport { controlOpenProps } from \"../../lib/control-open\"\nimport { props } from \"../../lib/props\"\nimport {\n type ClearSectionMode,\n filterSelectData,\n type NormalizedItemOf,\n normalizeSelectData,\n type RenderItem,\n type SelectData,\n type SelectValue,\n useLabelSearch,\n} from \"../../lib/select-data\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { useUncontrolled } from \"../../lib/use-uncontrolled\"\nimport {\n COMBOBOX_DEFAULT_TRANSLATIONS,\n Combobox,\n type ComboboxTranslations,\n} from \"../combobox/combobox\"\nimport { type FieldProps, FieldShell } from \"../field/field\"\nimport {\n type InputSize,\n type InputVariant,\n inputControlClasses,\n inputShell,\n inputSlot,\n placeholderColor,\n} from \"../input/input\"\nimport { Pill } from \"../pill/pill\"\nimport {\n PillOverflowCounter,\n type PillsInputTranslations,\n pillsContent,\n pillsShell,\n usePillOverflow,\n} from \"../pills-input/pills-input\"\n\n/**\n * MultiSelect — pick several values, shown as removable pills in a wrapping\n * input, searchable by default. It's the whole family working together:\n * Combobox (`multiple`) drives selection, the control is the PillsInput shell,\n * and each value renders as a `Pill`.\n *\n * - `data` matches `Select` (strings / objects / groups); `value` is `string[]`.\n * - Type to filter; pick to add (a check marks selected options); remove via a\n * pill's ×, Backspace on the empty field, or the clear button.\n * - `maxValues` caps selections; `hidePickedOptions` drops chosen options from\n * the list; `searchable={false}` turns it into a click-to-open multi-picker.\n * - Label / description / error come from the built-in `Field`.\n */\n\ntype MultiSelectClassNames = {\n root?: string\n field?: string\n control?: string\n input?: string\n option?: string\n popover?: string\n pill?: string\n}\n\nexport type MultiSelectProps<Data extends SelectData> = Pick<\n FieldProps,\n \"label\" | \"description\" | \"error\" | \"required\"\n> &\n WithTestId & {\n /** Options: `string[]`, `{ value, label?, disabled?, color? }[]`, or `{ group, items }[]`. */\n data: Data\n /** Controlled selected values. */\n value?: SelectValue<Data>[]\n /** Uncontrolled initial selection. */\n defaultValue?: SelectValue<Data>[]\n /** Fires with the full selection on every add / remove. */\n onChange?: (value: SelectValue<Data>[]) => void\n /**\n * Render each option yourself. Receives the (value-narrowed) item and its live\n * `{ selected, highlighted }` state; you own the whole row, including any check\n * affordance. Omit it to render the label + selected check.\n */\n renderItem?: RenderItem<Data>\n /** Placeholder shown while nothing is selected. */\n placeholder?: string\n /** Type to filter the options. Default `true`. */\n searchable?: boolean\n /** Placeholder for the search field once a value is already picked — before that, the\n * field shows `placeholder` instead. No default; omit it to show nothing, as today. */\n searchPlaceholder?: string\n /** Show a button that clears all values. */\n clearable?: boolean\n /** Whether the clear button replaces the chevron (`\"replace\"`, default) or sits beside it (`\"both\"`). */\n clearSectionMode?: ClearSectionMode\n /** Cap the number of selected values. */\n maxValues?: number\n /** Cap the pills at N rows; the rest collapse into a static \"+N\" counter. */\n maxLines?: number\n /** Inline-start adornment (icon, label). */\n startSlot?: ReactNode\n /** Inline-end adornment — rendered before the clear button / chevron. */\n endSlot?: ReactNode\n /** Hide options that are already selected. */\n hidePickedOptions?: boolean\n /** Message shown when no option matches. Pass `null` to render nothing. */\n empty?: ReactNode\n size?: InputSize\n variant?: InputVariant\n disabled?: boolean\n readOnly?: boolean\n /** Red invalid state, independent of (and OR'd with) `error`. */\n invalid?: boolean\n /** Wires hidden inputs into native form submission. */\n name?: string\n /** Forwarded to the search input; drives touched/blurred validation. */\n onBlur?: (event: FocusEvent<HTMLInputElement>) => void\n /** Lands on the focusable search `<input>` for focus-on-error. */\n ref?: Ref<HTMLInputElement>\n className?: string\n classNames?: MultiSelectClassNames\n /** Overrides the control's wording — see `MultiSelectTranslations`. A partial override keeps\n * the other defaults. */\n translations?: MultiSelectTranslations\n }\n\n/** The combobox family's `triggerLabel` (default `\"Show options\"`) and `clearTriggerLabel`\n * (default `\"Clear value\"`), plus `removeValue`: a value pill's remove-button name, given the\n * value's label (default `` label => `Remove ${label}` ``, so each pill names its own value),\n * and `PillsInput`'s `overflowCount`: what a screen reader hears for the `maxLines` \"+N\"\n * counter (default `\"3 more items\"`). */\nexport type MultiSelectTranslations = ComboboxTranslations &\n PillsInputTranslations & {\n removeValue?: (label: string) => string\n }\n\nconst MULTI_SELECT_DEFAULT_TRANSLATIONS = {\n removeValue: (label) => `Remove ${label}`,\n} as const satisfies MultiSelectTranslations\n\nexport const MultiSelect = <const Data extends SelectData>({\n data,\n value: valueProp,\n defaultValue,\n onChange,\n renderItem,\n placeholder,\n searchable = true,\n searchPlaceholder,\n clearable,\n clearSectionMode = \"replace\",\n maxValues,\n maxLines,\n startSlot,\n endSlot,\n hidePickedOptions,\n empty = \"Nothing found\",\n size = \"md\",\n variant = \"default\",\n disabled,\n readOnly,\n required,\n invalid,\n name,\n onBlur,\n ref,\n label,\n description,\n error,\n className,\n classNames,\n testId,\n translations,\n}: MultiSelectProps<Data>) => {\n const resolvedTranslations = {\n ...COMBOBOX_DEFAULT_TRANSLATIONS,\n ...MULTI_SELECT_DEFAULT_TRANSLATIONS,\n ...translations,\n }\n type Item = SelectValue<Data>\n\n // Red state is driven independently of the `Field` error slot so a form\n // library can flip it from `fieldState.invalid` (see FormControlProps).\n const isInvalid = invalid || error != null\n\n const [value, setSelected] = useUncontrolled<Item[]>({\n value: valueProp,\n defaultValue: defaultValue ?? [],\n onChange,\n })\n const [search, setSearch] = useState(\"\")\n\n const setValues = (next: Item[]) => {\n // Adding past the cap is rejected; removals always pass.\n if (maxValues != null && next.length > value.length && next.length > maxValues) {\n return\n }\n setSelected(next)\n }\n const removeValue = (v: Item) => setValues(value.filter((x) => x !== v))\n\n const { containerRef, visibleCount, hiddenCount, measuring } = usePillOverflow({\n maxLines,\n count: value.length,\n })\n\n // Normalize once per `data`; the item map and the filter both derive from it.\n const normalized = useMemo(() => normalizeSelectData(data), [data])\n // value -> full item, so a selected pill can pull both its label and its\n // color from one lookup instead of two parallel maps.\n const itemMap = useMemo(() => new Map(normalized.items.map((i) => [i.value, i])), [normalized])\n const labelSearch = useLabelSearch()\n const { collection, items, groups } = useMemo(() => {\n const query = searchable ? search : \"\"\n const picked = new Set<string>(value)\n return filterSelectData(\n normalized,\n (item) =>\n (!hidePickedOptions || !picked.has(item.value)) && labelSearch.matches(item.label, query),\n )\n }, [normalized, search, searchable, hidePickedOptions, value, labelSearch])\n\n const renderOption = (item: NormalizedItemOf<Data>) => (\n <Combobox.Item\n key={item.value}\n item={item}\n data-testid={item.testId}\n className={classNames?.option}\n >\n {renderItem ? (state) => renderItem(item, state) : item.label}\n </Combobox.Item>\n )\n\n const control = (\n <Combobox.Root<NormalizedItemOf<Data>>\n multiple\n collection={collection}\n value={value}\n // Ark types the values as `string[]`; they always originate from `data`,\n // so narrow back to the caller's value union.\n onValueChange={(details) => setValues(details.value as Item[])}\n inputValue={search}\n onInputValueChange={(details) => {\n if (searchable) setSearch(details.inputValue)\n }}\n selectionBehavior=\"clear\"\n closeOnSelect={false}\n openOnClick\n disabled={disabled}\n readOnly={readOnly}\n size={size}\n variant={variant}\n className={cn(className, classNames?.root)}\n translations={resolvedTranslations}\n >\n <ArkCombobox.Context>\n {(api) => {\n const showClear = Boolean(clearable) && api.hasSelectedItems && !disabled && !readOnly\n return (\n <ArkCombobox.Control\n {...props({\n \"data-invalid\": isInvalid,\n \"data-with-start-slot\": startSlot != null,\n // The composed Trigger always sits at the end. for now.\n \"data-with-end-slot\": true,\n })}\n // Tablet affordance: a tap on the field's dead zones (padding, empty\n // space, pill gaps) opens the list and focuses the search input. The\n // input, pill ✕, clear ✕ and chevron all manage their own taps.\n // Inert when disabled / readOnly, so it never opens where the input won't.\n {...(disabled || readOnly ? {} : controlOpenProps(() => api.setOpen(true)))}\n className={cn(inputShell({ size, variant }), pillsShell, classNames?.control)}\n >\n {startSlot != null && (\n <span className={inputSlot} aria-hidden>\n {startSlot}\n </span>\n )}\n <div ref={containerRef} className={pillsContent({ size })}>\n {value.slice(0, visibleCount).map((v) => (\n <Pill\n key={v}\n size={size}\n color={itemMap.get(v)?.color}\n disabled={disabled}\n withRemoveButton={!readOnly}\n onRemove={() => removeValue(v)}\n removeLabel={resolvedTranslations.removeValue(itemMap.get(v)?.label ?? v)}\n className={classNames?.pill}\n data-overflow-item\n >\n {itemMap.get(v)?.label ?? v}\n </Pill>\n ))}\n {/* Mounted during the measuring pass so the hook can size the last-row\n reservation off the real counter, but kept `invisible` then (still\n measurable) so it never paints on the SSR HTML before the first\n measure. Only mounts while measuring when a cap is configured. */}\n {(hiddenCount > 0 || (measuring && maxLines != null)) && (\n <PillOverflowCounter\n count={measuring ? value.length : hiddenCount}\n size={size}\n className={measuring ? \"invisible\" : undefined}\n translations={resolvedTranslations}\n />\n )}\n {/* Ark's own Input (a forwardRef) so the caller's `ref` lands on\n the real focusable `<input>` for RHF focus-on-error; the kit's\n `Combobox.Input` wrapper only adds `inputControlClasses`,\n replicated here. `name` is intentionally NOT here — it would\n submit the typed search text, not the selection (see the hidden\n inputs below). */}\n {searchable ? (\n <ArkCombobox.Input\n data-overflow-field\n placeholder={value.length === 0 ? placeholder : searchPlaceholder}\n readOnly={!searchable || readOnly}\n onBlur={onBlur}\n ref={ref}\n {...props({ \"aria-invalid\": isInvalid, \"data-testid\": testId })}\n className={cn(inputControlClasses, \"w-auto min-w-16\", classNames?.input)}\n onKeyDown={(event) => {\n const last = value[value.length - 1]\n if (\n event.key === \"Backspace\" &&\n event.currentTarget.value === \"\" &&\n last !== undefined &&\n !readOnly\n ) {\n removeValue(last)\n }\n }}\n />\n ) : (\n value.length <= 0 && (\n <span className={cn(placeholderColor, \"truncate\")}>{placeholder}</span>\n )\n )}\n </div>\n {endSlot != null && <span className={inputSlot}>{endSlot}</span>}\n {showClear && <Combobox.ClearTrigger />}\n {(clearSectionMode === \"both\" || !showClear) && <Combobox.Trigger data-chevron />}\n {/* Hidden inputs carry the real selection so a native `<form>`\n submits the value array (the search input is unnamed). When\n controlled by a form library the value flows through `onChange`\n instead, and these are just submitted alongside it. */}\n {name != null &&\n value.map((v) => <input key={v} type=\"hidden\" name={name} value={v} />)}\n </ArkCombobox.Control>\n )\n }}\n </ArkCombobox.Context>\n\n <Combobox.Content className={classNames?.popover}>\n {groups\n ? groups.map((group) => (\n <Combobox.Group key={group.group} label={group.group}>\n {group.items.map(renderOption)}\n </Combobox.Group>\n ))\n : items.map(renderOption)}\n {empty != null && <Combobox.Empty>{empty}</Combobox.Empty>}\n </Combobox.Content>\n </Combobox.Root>\n )\n\n return (\n <FieldShell\n label={label}\n description={description}\n error={error}\n required={required}\n disabled={disabled}\n size={size}\n className={classNames?.field}\n >\n {control}\n </FieldShell>\n )\n}\n"]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import '../../chunk-R5GMMWAY.js';
|
|
3
|
-
export { NumberInput } from '../../chunk-
|
|
3
|
+
export { NumberInput } from '../../chunk-UVQXRDRO.js';
|
|
4
4
|
import '../../chunk-45QRQKRC.js';
|
|
5
5
|
import '../../chunk-VD6PB3VA.js';
|
|
6
6
|
import '../../chunk-HBWV5EPU.js';
|
|
7
|
-
import '../../chunk-
|
|
7
|
+
import '../../chunk-N66NC6QK.js';
|
|
8
|
+
import '../../chunk-V6PY7C6S.js';
|
|
8
9
|
import '../../chunk-7P32XCEU.js';
|
|
9
10
|
import '../../chunk-H7WOMZXO.js';
|
|
10
11
|
import '../../chunk-PMUCGFY5.js';
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
import { useImageCropperContext, ImageCropper } from '../../chunk-47LEAR6G.js';
|
|
3
3
|
import '../../chunk-UAYENYS2.js';
|
|
4
4
|
import { FileTrigger } from '../../chunk-UT3TOV2Q.js';
|
|
5
|
-
import { Camera, useCamera, imageFile } from '../../chunk-
|
|
5
|
+
import { Camera, useCamera, imageFile } from '../../chunk-UCCJUFOG.js';
|
|
6
6
|
import '../../chunk-HX3LNK26.js';
|
|
7
7
|
import '../../chunk-K6YASO4L.js';
|
|
8
|
-
import '../../chunk-
|
|
8
|
+
import '../../chunk-Z4MBCKG5.js';
|
|
9
9
|
import '../../chunk-TWNIAF7K.js';
|
|
10
10
|
import '../../chunk-J43LSYQO.js';
|
|
11
11
|
import '../../chunk-7TDHT3QD.js';
|
|
12
12
|
import '../../chunk-5FDOOG4J.js';
|
|
13
|
-
import '../../chunk-
|
|
13
|
+
import '../../chunk-2BNIHOMT.js';
|
|
14
14
|
import '../../chunk-45QRQKRC.js';
|
|
15
15
|
import '../../chunk-VD6PB3VA.js';
|
|
16
16
|
import '../../chunk-F342ZT7O.js';
|
|
@@ -24,7 +24,8 @@ import { useMediaQuery } from '../../chunk-HDYORQZN.js';
|
|
|
24
24
|
import { useMergedRefs } from '../../chunk-HBWV5EPU.js';
|
|
25
25
|
import '../../chunk-AHM6SGEU.js';
|
|
26
26
|
import { useDirectionCheck } from '../../chunk-IPYHTCFL.js';
|
|
27
|
-
import '../../chunk-
|
|
27
|
+
import '../../chunk-N66NC6QK.js';
|
|
28
|
+
import '../../chunk-V6PY7C6S.js';
|
|
28
29
|
import '../../chunk-7P32XCEU.js';
|
|
29
30
|
import '../../chunk-H7WOMZXO.js';
|
|
30
31
|
import '../../chunk-BE2LWUHY.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":";;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AG;AACL,CAAA,KAAyB;AACvB,EAAA,MAAM,IAAA,GAAO,eAAA,CAAgB,EAAE,QAAA,EAAU,MAAA,EAAQ,QAAQ,KAAA,EAAO,UAAA,EAAY,MAAA,EAAQ,MAAA,EAAQ,CAAA;AAC5F,EAAA,uBACE,IAAA,CAAC,gBAAA,EAAA,EAAiB,IAAA,EAAa,GAAG,IAAA,EAChC,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,kBAAA,EAAA,EAAmB,SAAA,EAAW,UAAA,EAAY,MAAA,EAAQ,CAAA;AAAA,oBACnD,GAAA;AAAA,MAAC,gBAAA;AAAA,MAAA;AAAA,QACC,WAAW,UAAA,EAAY,IAAA;AAAA,QACvB,YAAY,EAAE,UAAA,EAAY,YAAY,UAAA,EAAY,QAAA,EAAU,YAAY,QAAA;AAAS;AAAA,KACnF;AAAA,oBACA,GAAA;AAAA,MAAC,gBAAA;AAAA,MAAA;AAAA,QACC,WAAW,UAAA,EAAY,IAAA;AAAA,QACvB,UAAA,EAAY;AAAA,UACV,UAAU,UAAA,EAAY,QAAA;AAAA,UACtB,UAAU,UAAA,EAAY,QAAA;AAAA,UACtB,SAAS,UAAA,EAAY;AAAA;AACvB;AAAA;AACF,GAAA,EACF,CAAA;AAEJ,CAAA;AAEO,IAAM,YAAA,GAAe,MAAA,CAAO,MAAA,CAAO,qBAAA,EAAuB;AAAA,EAC/D,IAAA,EAAM,gBAAA;AAAA,EACN,MAAA,EAAQ,kBAAA;AAAA,EACR,IAAA,EAAM,gBAAA;AAAA,EACN,IAAA,EAAM,gBAAA;AAAA,EACN,IAAA,EAAM,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","../../../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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F,EAAA,uBACE,IAAA,CAAC,gBAAA,EAAA,EAAiB,IAAA,EAAa,GAAG,IAAA,EAChC,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,kBAAA,EAAA,EAAmB,SAAA,EAAW,UAAA,EAAY,MAAA,EAAQ,CAAA;AAAA,oBACnD,GAAA;AAAA,MAAC,gBAAA;AAAA,MAAA;AAAA,QACC,WAAW,UAAA,EAAY,IAAA;AAAA,QACvB,YAAY,EAAE,UAAA,EAAY,YAAY,UAAA,EAAY,QAAA,EAAU,YAAY,QAAA;AAAS;AAAA,KACnF;AAAA,oBACA,GAAA;AAAA,MAAC,gBAAA;AAAA,MAAA;AAAA,QACC,WAAW,UAAA,EAAY,IAAA;AAAA,QACvB,UAAA,EAAY;AAAA,UACV,UAAU,UAAA,EAAY,QAAA;AAAA,UACtB,UAAU,UAAA,EAAY,QAAA;AAAA,UACtB,SAAS,UAAA,EAAY;AAAA;AACvB;AAAA;AACF,GAAA,EACF,CAAA;AAEJ,CAAA;AAEO,IAAM,YAAA,GAAe,MAAA,CAAO,MAAA,CAAO,qBAAA,EAAuB;AAAA,EAC/D,IAAA,EAAM,gBAAA;AAAA,EACN,MAAA,EAAQ,kBAAA;AAAA,EACR,IAAA,EAAM,gBAAA;AAAA,EACN,IAAA,EAAM,gBAAA;AAAA,EACN,IAAA,EAAM,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,2 +1,2 @@
|
|
|
1
|
-
export { Popover, type PopoverContentProps, type PopoverProps, type PopoverTriggerProps, } from "./popover";
|
|
1
|
+
export { Popover, type PopoverContentProps, type PopoverGroupProps, type PopoverPosition, type PopoverProps, type PopoverTriggerProps, } from "./popover";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/popover/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,OAAO,EACP,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,mBAAmB,GACzB,MAAM,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/popover/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,OAAO,EACP,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,mBAAmB,GACzB,MAAM,WAAW,CAAA"}
|