@kumix/ui 0.3.16 → 0.3.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/README.md +3 -2
  2. package/dist/cascader-types-BnH6wYD-.d.ts.map +1 -1
  3. package/dist/components/agents/ai-sidebar.js +2 -2
  4. package/dist/components/agents/ai-sidebar.js.map +1 -1
  5. package/dist/components/agents/approval-card/index.js +22 -25
  6. package/dist/components/agents/approval-card/index.js.map +1 -1
  7. package/dist/components/agents/message-bubble.js +1 -1
  8. package/dist/components/agents/message-bubble.js.map +1 -1
  9. package/dist/components/motion/action-swap.js +2 -2
  10. package/dist/components/motion/action-swap.js.map +1 -1
  11. package/dist/components/motion/animated-badge.js +2 -2
  12. package/dist/components/motion/animated-badge.js.map +1 -1
  13. package/dist/components/motion/animated-sidebar.js.map +1 -1
  14. package/dist/components/motion/animated-toast-stack.js +5 -5
  15. package/dist/components/motion/animated-toast-stack.js.map +1 -1
  16. package/dist/components/motion/attachment-upload.d.ts.map +1 -1
  17. package/dist/components/motion/attachment-upload.js.map +1 -1
  18. package/dist/components/motion/bottom-sheet.js.map +1 -1
  19. package/dist/components/motion/breadcrumb.d.ts +37 -0
  20. package/dist/components/motion/breadcrumb.d.ts.map +1 -0
  21. package/dist/components/motion/breadcrumb.js +259 -0
  22. package/dist/components/motion/breadcrumb.js.map +1 -0
  23. package/dist/components/motion/button/base.js +2 -2
  24. package/dist/components/motion/button/base.js.map +1 -1
  25. package/dist/components/motion/color-selector.d.ts +28 -0
  26. package/dist/components/motion/color-selector.d.ts.map +1 -0
  27. package/dist/components/motion/color-selector.js +97 -0
  28. package/dist/components/motion/color-selector.js.map +1 -0
  29. package/dist/components/motion/command-palette.js +1 -1
  30. package/dist/components/motion/command-palette.js.map +1 -1
  31. package/dist/components/motion/dock.js +1 -1
  32. package/dist/components/motion/dock.js.map +1 -1
  33. package/dist/components/motion/drawer.js.map +1 -1
  34. package/dist/components/motion/expandable-action-bar.js +1 -1
  35. package/dist/components/motion/expandable-action-bar.js.map +1 -1
  36. package/dist/components/motion/morphing-modal.js.map +1 -1
  37. package/dist/components/motion/morphing-search.js.map +1 -1
  38. package/dist/components/motion/not-found/shared.js +1 -1
  39. package/dist/components/motion/not-found/shared.js.map +1 -1
  40. package/dist/components/motion/popover-morph.d.ts +1 -1
  41. package/dist/components/motion/popover-morph.d.ts.map +1 -1
  42. package/dist/components/motion/popover-morph.js +50 -22
  43. package/dist/components/motion/popover-morph.js.map +1 -1
  44. package/dist/components/motion/project-folder.js.map +1 -1
  45. package/dist/components/motion/shared-layout-bg.js +1 -1
  46. package/dist/components/motion/shared-layout-bg.js.map +1 -1
  47. package/dist/components/motion/slide-action-button.js +1 -1
  48. package/dist/components/motion/slide-action-button.js.map +1 -1
  49. package/dist/components/motion/table/index.js +1 -1
  50. package/dist/components/motion/table/index.js.map +1 -1
  51. package/dist/components/motion/table/table-header.d.ts.map +1 -1
  52. package/dist/components/motion/table/table-header.js +1 -1
  53. package/dist/components/motion/table/table-header.js.map +1 -1
  54. package/dist/components/motion/tabs.d.ts +2 -1
  55. package/dist/components/motion/tabs.d.ts.map +1 -1
  56. package/dist/components/motion/tabs.js +200 -18
  57. package/dist/components/motion/tabs.js.map +1 -1
  58. package/dist/components/motion/tooltip/positioner.d.ts +33 -0
  59. package/dist/components/motion/tooltip/positioner.d.ts.map +1 -0
  60. package/dist/components/motion/tooltip/positioner.js +3 -0
  61. package/dist/components/motion/tooltip-surface.d.ts +5 -4
  62. package/dist/components/motion/tooltip-surface.d.ts.map +1 -1
  63. package/dist/components/motion/tooltip-surface.js +22 -73
  64. package/dist/components/motion/tooltip-surface.js.map +1 -1
  65. package/dist/components/motion/tooltip.d.ts +3 -1
  66. package/dist/components/motion/tooltip.d.ts.map +1 -1
  67. package/dist/components/motion/tooltip.js +54 -103
  68. package/dist/components/motion/tooltip.js.map +1 -1
  69. package/dist/components/reui/alert.d.ts +1 -1
  70. package/dist/components/reui/autocomplete.d.ts.map +1 -1
  71. package/dist/components/reui/badge.d.ts +2 -2
  72. package/dist/components/reui/cascader/cascader-columns.d.ts.map +1 -1
  73. package/dist/components/reui/cascader/cascader-context.d.ts.map +1 -1
  74. package/dist/components/reui/cascader/cascader-footer.d.ts.map +1 -1
  75. package/dist/components/reui/cascader/cascader-item.d.ts.map +1 -1
  76. package/dist/components/reui/cascader/cascader-nav.d.ts.map +1 -1
  77. package/dist/components/reui/cascader/cascader-virtual.d.ts.map +1 -1
  78. package/dist/components/reui/cascader/cascader.d.ts.map +1 -1
  79. package/dist/components/reui/data-grid/data-grid-column-header.d.ts.map +1 -1
  80. package/dist/components/reui/data-grid/data-grid-column-header.js +27 -21
  81. package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
  82. package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts.map +1 -1
  83. package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -1
  84. package/dist/components/reui/data-grid/data-grid-table.js +4 -4
  85. package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
  86. package/dist/components/reui/filters/filters-advanced.d.ts.map +1 -1
  87. package/dist/components/reui/filters/filters-advanced.js.map +1 -1
  88. package/dist/components/reui/filters/filters-builder.d.ts.map +1 -1
  89. package/dist/components/reui/filters/filters-chip.d.ts.map +1 -1
  90. package/dist/components/reui/filters/filters-context.d.ts.map +1 -1
  91. package/dist/components/reui/filters/filters-dnd.d.ts.map +1 -1
  92. package/dist/components/reui/filters/filters-editors.d.ts.map +1 -1
  93. package/dist/components/reui/filters/filters-types.d.ts.map +1 -1
  94. package/dist/components/reui/filters/filters.d.ts.map +1 -1
  95. package/dist/components/reui/frame.d.ts +2 -2
  96. package/dist/components/reui/icon-tile.d.ts +2 -2
  97. package/dist/components/reui/kanban.d.ts.map +1 -1
  98. package/dist/components/reui/kanban.js +30 -1
  99. package/dist/components/reui/kanban.js.map +1 -1
  100. package/dist/components/reui/number-field.d.ts.map +1 -1
  101. package/dist/components/reui/sortable.d.ts.map +1 -1
  102. package/dist/components/ui/accordion.d.ts.map +1 -1
  103. package/dist/components/ui/alert-dialog.d.ts.map +1 -1
  104. package/dist/components/ui/alert.d.ts.map +1 -1
  105. package/dist/components/ui/attachment.d.ts +1 -1
  106. package/dist/components/ui/attachment.d.ts.map +1 -1
  107. package/dist/components/ui/avatar.d.ts.map +1 -1
  108. package/dist/components/ui/badge.d.ts +1 -1
  109. package/dist/components/ui/breadcrumb.d.ts.map +1 -1
  110. package/dist/components/ui/bubble.d.ts +1 -1
  111. package/dist/components/ui/bubble.d.ts.map +1 -1
  112. package/dist/components/ui/button.d.ts +2 -2
  113. package/dist/components/ui/button.d.ts.map +1 -1
  114. package/dist/components/ui/calendar.d.ts.map +1 -1
  115. package/dist/components/ui/card.d.ts.map +1 -1
  116. package/dist/components/ui/carousel.d.ts.map +1 -1
  117. package/dist/components/ui/chart.d.ts.map +1 -1
  118. package/dist/components/ui/checkbox.d.ts.map +1 -1
  119. package/dist/components/ui/collapsible.d.ts.map +1 -1
  120. package/dist/components/ui/combobox.d.ts.map +1 -1
  121. package/dist/components/ui/command.d.ts.map +1 -1
  122. package/dist/components/ui/context-menu.d.ts.map +1 -1
  123. package/dist/components/ui/dialog.d.ts.map +1 -1
  124. package/dist/components/ui/drawer.d.ts.map +1 -1
  125. package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
  126. package/dist/components/ui/hover-card.d.ts.map +1 -1
  127. package/dist/components/ui/input-group.d.ts +1 -1
  128. package/dist/components/ui/input-group.d.ts.map +1 -1
  129. package/dist/components/ui/input-otp.d.ts.map +1 -1
  130. package/dist/components/ui/input.d.ts.map +1 -1
  131. package/dist/components/ui/item.d.ts +2 -2
  132. package/dist/components/ui/item.d.ts.map +1 -1
  133. package/dist/components/ui/label.d.ts.map +1 -1
  134. package/dist/components/ui/marker.d.ts.map +1 -1
  135. package/dist/components/ui/menubar.d.ts.map +1 -1
  136. package/dist/components/ui/message-scroller.d.ts.map +1 -1
  137. package/dist/components/ui/message.d.ts.map +1 -1
  138. package/dist/components/ui/native-select.d.ts.map +1 -1
  139. package/dist/components/ui/navigation-menu.d.ts.map +1 -1
  140. package/dist/components/ui/pagination.d.ts.map +1 -1
  141. package/dist/components/ui/popover.d.ts.map +1 -1
  142. package/dist/components/ui/progress.d.ts.map +1 -1
  143. package/dist/components/ui/questionnaire.d.ts.map +1 -1
  144. package/dist/components/ui/radio-group.d.ts.map +1 -1
  145. package/dist/components/ui/scroll-area.d.ts.map +1 -1
  146. package/dist/components/ui/select.d.ts.map +1 -1
  147. package/dist/components/ui/separator.d.ts.map +1 -1
  148. package/dist/components/ui/sheet.d.ts.map +1 -1
  149. package/dist/components/ui/sidebar.d.ts +1 -1
  150. package/dist/components/ui/sidebar.d.ts.map +1 -1
  151. package/dist/components/ui/slider.d.ts.map +1 -1
  152. package/dist/components/ui/switch.d.ts.map +1 -1
  153. package/dist/components/ui/table.d.ts.map +1 -1
  154. package/dist/components/ui/tabs.d.ts.map +1 -1
  155. package/dist/components/ui/textarea.d.ts.map +1 -1
  156. package/dist/components/ui/toast.d.ts.map +1 -1
  157. package/dist/components/ui/toggle-group.d.ts.map +1 -1
  158. package/dist/components/ui/toggle.d.ts +1 -1
  159. package/dist/components/ui/toggle.d.ts.map +1 -1
  160. package/dist/components/ui/tooltip.d.ts.map +1 -1
  161. package/dist/hooks/use-intersection-observer.d.ts.map +1 -1
  162. package/dist/hooks/use-mutation-observer.d.ts.map +1 -1
  163. package/dist/hooks/use-slider-input.d.ts.map +1 -1
  164. package/dist/positioner-3mCqiebN.js +204 -0
  165. package/dist/positioner-3mCqiebN.js.map +1 -0
  166. package/package.json +10 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breadcrumb.js","names":[],"sources":["../../../src/components/motion/breadcrumb.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n Children,\n type ComponentPropsWithRef,\n forwardRef,\n type ReactElement,\n type ReactNode,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { ChevronRight, Ellipsis } from \"lucide-react\";\nimport {\n AnimatePresence,\n type HTMLMotionProps,\n LayoutGroup,\n motion,\n useIsPresent,\n useReducedMotion,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useHoverCapable } from \"../../hooks/use-hover-capable\";\nimport { EASE_OUT, SPRING_LAYOUT } from \"../../lib/ease\";\nimport { MorphPopover, MorphPopoverContent, MorphPopoverTrigger } from \"./popover-morph\";\n\nexport type BreadcrumbProps = ComponentPropsWithRef<\"nav\">;\n\n/** A navigation landmark. Keep it mounted while the route changes. */\nexport function Breadcrumb({ className, children, ...props }: BreadcrumbProps) {\n const id = useId();\n return (\n <nav aria-label=\"Breadcrumb\" {...props} className={cn(\"min-w-0\", className)}>\n <LayoutGroup id={id}>{children}</LayoutGroup>\n </nav>\n );\n}\n\nexport type BreadcrumbListProps = ComponentPropsWithRef<\"ol\"> & {\n /** Maximum visible slots, including the ellipsis. Minimum 3; Infinity disables collapsing. */\n maxItems?: number;\n /** Accessible label for the hidden ancestor disclosure. */\n overflowLabel?: string;\n};\n\n/** Pass keyed BreadcrumbItems directly so entering and leaving routes animate. */\nexport function BreadcrumbList({\n className,\n children,\n maxItems = 4,\n overflowLabel = \"Show hidden paths\",\n ...props\n}: BreadcrumbListProps) {\n const items = Children.toArray(children);\n const limit = Number.isFinite(maxItems) ? Math.max(3, Math.floor(maxItems)) : 4;\n const collapse = maxItems !== Infinity && items.length > limit;\n const tailCount = limit - 2;\n const visible = collapse\n ? [\n items[0],\n <BreadcrumbItem key=\"breadcrumb-overflow\">\n <BreadcrumbSeparator />\n <BreadcrumbEllipsis label={overflowLabel}>\n {items.slice(1, -tailCount)}\n </BreadcrumbEllipsis>\n </BreadcrumbItem>,\n ...items.slice(-tailCount),\n ]\n : items;\n return (\n <ol\n {...props}\n className={cn(\"relative flex flex-wrap items-center gap-x-1 gap-y-1 text-sm\", className)}\n >\n <AnimatePresence initial={false} mode=\"popLayout\">\n {visible}\n </AnimatePresence>\n </ol>\n );\n}\n\nexport type BreadcrumbItemProps = HTMLMotionProps<\"li\">;\n\n/** Use a stable route key; put its optional separator inside this item. */\nexport const BreadcrumbItem = forwardRef<HTMLLIElement, BreadcrumbItemProps>(\n function BreadcrumbItem({ className, style, children, ...props }, ref) {\n const reduce = useReducedMotion();\n const present = useIsPresent();\n const itemRef = useRef<HTMLLIElement>(null);\n useLayoutEffect(() => {\n const item = itemRef.current;\n if (!item || !present) return;\n const measure = () => {\n // popLayout snapshots offsetWidth (integer pixels). Retain the exact\n // width so a fractional-pixel loss cannot wrap the final character.\n item.style.setProperty(\n \"--breadcrumb-exit-width\",\n `${item.getBoundingClientRect().width}px`,\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(item);\n return () => observer.disconnect();\n }, [present]);\n const hidden = { opacity: 0, y: reduce ? 0 : 6 };\n return (\n <motion.li\n ref={(node) => {\n itemRef.current = node;\n if (typeof ref === \"function\") return ref(node);\n if (ref) ref.current = node;\n }}\n layout={reduce ? false : \"position\"}\n initial={hidden}\n animate={{ opacity: 1, y: 0 }}\n exit={hidden}\n transition={{ duration: 0.2, ease: EASE_OUT, layout: SPRING_LAYOUT }}\n {...props}\n inert={!present}\n aria-hidden={!present || undefined}\n style={{\n ...style,\n minWidth: present ? style?.minWidth : \"var(--breadcrumb-exit-width)\",\n pointerEvents: present ? style?.pointerEvents : \"none\",\n }}\n className={cn(\"relative inline-flex min-w-0 max-w-full items-center gap-1\", className)}\n >\n {children}\n </motion.li>\n );\n },\n);\n\nexport type BreadcrumbLinkProps = ComponentPropsWithRef<\"a\"> & {\n /** Render your router's Link, spreading these props onto it. */\n render?: (props: ComponentPropsWithRef<\"a\">) => ReactElement;\n};\n\nexport function BreadcrumbLink({ className, render, ...props }: BreadcrumbLinkProps) {\n const linkProps = {\n ...props,\n className: cn(\n \"inline-flex min-h-8 min-w-0 items-center gap-1.5 rounded-md px-2 font-medium text-muted-foreground transition-colors duration-150 hover:bg-muted/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 [&>svg]:size-3.5 [&>svg]:shrink-0\",\n className,\n ),\n };\n return render ? render(linkProps) : <a {...linkProps} />;\n}\n\nexport type BreadcrumbPageProps = ComponentPropsWithRef<\"span\">;\n\nexport function BreadcrumbPage({ className, children, ...props }: BreadcrumbPageProps) {\n return (\n <span\n {...props}\n aria-current=\"page\"\n className={cn(\n \"wrap-anywhere relative isolate inline-flex min-h-8 min-w-0 items-center gap-1.5 rounded-md px-2 font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&>svg]:size-3.5 [&>svg]:shrink-0\",\n className,\n )}\n >\n {children}\n </span>\n );\n}\n\nexport type BreadcrumbSeparatorProps = ComponentPropsWithRef<\"span\">;\n\n/** Decorative separator, placed inside the following BreadcrumbItem. */\nexport function BreadcrumbSeparator({ className, children, ...props }: BreadcrumbSeparatorProps) {\n return (\n <span\n {...props}\n aria-hidden=\"true\"\n data-breadcrumb-separator=\"\"\n className={cn(\n \"inline-flex shrink-0 items-center text-muted-foreground/50 rtl:rotate-180 [&>svg]:size-3.5\",\n className,\n )}\n >\n {children ?? <ChevronRight />}\n </span>\n );\n}\n\nexport interface BreadcrumbEllipsisProps {\n /** Hidden BreadcrumbItems, in path order. */\n children: ReactNode;\n className?: string;\n label?: string;\n}\n\n/** Hover disclosure with click/touch toggle and keyboard access to ancestor links. */\nexport function BreadcrumbEllipsis({\n children,\n className,\n label = \"Show hidden paths\",\n}: BreadcrumbEllipsisProps) {\n const [open, setOpen] = useState(false);\n const [placement, setPlacement] = useState<{\n align: \"start\" | \"end\";\n side: \"top\" | \"bottom\";\n width: number;\n }>({ align: \"start\", side: \"bottom\", width: 224 });\n const canHover = useHoverCapable();\n const present = useIsPresent();\n const trigger = useRef<HTMLButtonElement>(null);\n const panel = useRef<HTMLOListElement>(null);\n const focusOnOpen = useRef(false);\n const closeTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useLayoutEffect(() => {\n if (!open) return;\n const update = () => {\n const rect = trigger.current?.getBoundingClientRect();\n if (!rect) return;\n const right = window.innerWidth - rect.left - 8;\n const left = rect.right - 8;\n const align = right < 224 && left > right ? \"end\" : \"start\";\n const below = window.innerHeight - rect.bottom;\n setPlacement({\n align,\n side: below < 280 && rect.top > below ? \"top\" : \"bottom\",\n width: Math.max(32, Math.min(224, align === \"start\" ? right : left)),\n });\n };\n update();\n window.addEventListener(\"resize\", update);\n return () => window.removeEventListener(\"resize\", update);\n }, [open]);\n\n const cancelClose = () => {\n if (closeTimer.current !== null) clearTimeout(closeTimer.current);\n closeTimer.current = null;\n };\n const leave = () => {\n cancelClose();\n // Allow the pointer to cross the gap between the trigger and portal.\n closeTimer.current = setTimeout(() => {\n if (\n !panel.current?.contains(document.activeElement) &&\n document.activeElement !== trigger.current\n )\n setOpen(false);\n }, 160);\n };\n useEffect(\n () => () => {\n if (closeTimer.current !== null) clearTimeout(closeTimer.current);\n },\n [],\n );\n\n useEffect(() => {\n if (!open) return;\n const onFocus = (event: FocusEvent) => {\n if (\n event.target instanceof Node &&\n event.target !== trigger.current &&\n !panel.current?.contains(event.target)\n )\n setOpen(false);\n };\n document.addEventListener(\"focusin\", onFocus);\n return () => document.removeEventListener(\"focusin\", onFocus);\n }, [open]);\n\n return (\n <MorphPopover open={open && present} onOpenChange={setOpen} className={cn(className)}>\n <span\n onPointerEnter={(event) => {\n cancelClose();\n if (canHover && event.pointerType === \"mouse\") {\n focusOnOpen.current = false;\n setOpen(true);\n }\n }}\n onPointerLeave={leave}\n >\n <MorphPopoverTrigger>\n <button\n ref={trigger}\n type=\"button\"\n aria-label={label}\n className=\"inline-flex size-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n onClick={(event) => {\n focusOnOpen.current = event.detail === 0;\n }}\n onKeyDown={(event) => {\n if (event.key === \"ArrowDown\") {\n event.preventDefault();\n focusOnOpen.current = true;\n setOpen(true);\n panel.current?.querySelector<HTMLElement>(\"a[href],button\")?.focus();\n }\n }}\n >\n <Ellipsis aria-hidden=\"true\" className=\"size-4\" />\n </button>\n </MorphPopoverTrigger>\n <MorphPopoverContent\n align={placement.align}\n side={placement.side}\n radius={10}\n sideOffset={6}\n className=\"p-1.5\"\n >\n <BreadcrumbOverflowPaths\n ref={panel}\n style={{ width: placement.width - 14 }}\n focusOnOpen={focusOnOpen}\n onPointerEnter={() => {\n cancelClose();\n setOpen(true);\n }}\n onPointerLeave={leave}\n onClick={(event) => {\n if ((event.target as Element).closest(\"a[href]\")) setOpen(false);\n }}\n >\n {children}\n </BreadcrumbOverflowPaths>\n </MorphPopoverContent>\n </span>\n </MorphPopover>\n );\n}\n\nfunction BreadcrumbOverflowPaths({\n focusOnOpen,\n ref,\n ...props\n}: ComponentPropsWithRef<\"ol\"> & { focusOnOpen: { current: boolean } }) {\n const localRef = useRef<HTMLOListElement>(null);\n useLayoutEffect(() => {\n if (!focusOnOpen.current) return;\n const focus = () => localRef.current?.querySelector<HTMLElement>(\"a[href],button\")?.focus();\n focus();\n // The portal becomes visible after its parent's layout measurement.\n const frame = requestAnimationFrame(() => {\n focus();\n focusOnOpen.current = false;\n });\n return () => cancelAnimationFrame(frame);\n }, [focusOnOpen]);\n return (\n <ol\n {...props}\n ref={(node) => {\n localRef.current = node;\n if (typeof ref === \"function\") return ref(node);\n if (ref) ref.current = node;\n }}\n className=\"[&_a]:wrap-anywhere flex max-h-64 flex-col gap-0.5 overflow-y-auto **:data-breadcrumb-separator:hidden [&>li]:w-full [&_a]:w-full [&_a]:py-1\"\n />\n );\n}\n"],"mappings":";;;;;;;;;;;AAgCA,SAAgB,WAAW,EAAE,WAAW,UAAU,GAAG,SAA0B;CAC7E,MAAM,KAAK,MAAM;CACjB,OACE,oBAAC,OAAD;EAAK,cAAW;EAAa,GAAI;EAAO,WAAW,GAAG,WAAW,SAAS;EACxE,UAAA,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EAC/B,aACA,KACA,GAAG,SACmE;CACtE,MAAM,WAAW,OAAyB,IAAI;CAC9C,sBAAsB;EACpB,IAAI,CAAC,YAAY,SAAS;EAC1B,MAAM,cAAc,SAAS,SAAS,cAA2B,gBAAgB,CAAC,EAAE,MAAM;EAC1F,MAAM;EAEN,MAAM,QAAQ,4BAA4B;GACxC,MAAM;GACN,YAAY,UAAU;EACxB,CAAC;EACD,aAAa,qBAAqB,KAAK;CACzC,GAAG,CAAC,WAAW,CAAC;CAChB,OACE,oBAAC,MAAD;EACE,GAAI;EACJ,MAAM,SAAS;GACb,SAAS,UAAU;GACnB,IAAI,OAAO,QAAQ,YAAY,OAAO,IAAI,IAAI;GAC9C,IAAI,KAAK,IAAI,UAAU;EACzB;EACA,WAAU;CACX,CAAA;AAEL"}
@@ -9,8 +9,8 @@ import { AnimatePresence, motion, useReducedMotion } from "motion/react";
9
9
  const VARIANT_CLASS = {
10
10
  primary: "bg-primary text-primary-foreground hover:bg-primary/90",
11
11
  secondary: "border border-border bg-card text-foreground hover:border-border",
12
- ghost: "text-muted-foreground hover:text-foreground hover:bg-primary/5",
13
- outline: "border border-border bg-transparent text-foreground hover:bg-primary/5"
12
+ ghost: "text-muted-foreground hover:text-foreground hover:bg-muted/60",
13
+ outline: "border border-border bg-transparent text-foreground hover:bg-muted/60"
14
14
  };
15
15
  const SIZE_CLASS = {
16
16
  sm: "h-8 px-3 text-xs gap-1.5 rounded-full",
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","names":[],"sources":["../../../../src/components/motion/button/base.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n forwardRef,\n type PointerEvent,\n type ReactNode,\n useCallback,\n useRef,\n useState,\n} from \"react\";\nimport { AnimatePresence, type HTMLMotionProps, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useHoverCapable } from \"../../../hooks/use-hover-capable\";\nimport { EASE_OUT, SPRING_PRESS } from \"../../../lib/ease\";\n\nexport type ButtonVariant = \"primary\" | \"secondary\" | \"ghost\" | \"outline\";\nexport type ButtonSize = \"sm\" | \"md\" | \"lg\" | \"icon\";\n\nexport interface ButtonProps extends Omit<HTMLMotionProps<\"button\">, \"children\"> {\n variant?: ButtonVariant;\n size?: ButtonSize;\n pressScale?: number;\n /** Spawn a Material-style ripple from the press point. Off by default. */\n ripple?: boolean;\n children?: ReactNode;\n}\n\nexport interface ButtonLinkProps extends Omit<HTMLMotionProps<\"a\">, \"children\"> {\n variant?: ButtonVariant;\n size?: ButtonSize;\n pressScale?: number;\n children?: ReactNode;\n}\n\ntype Ripple = { id: number; x: number; y: number; size: number };\n\nconst VARIANT_CLASS: Record<ButtonVariant, string> = {\n primary: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n secondary: \"border border-border bg-card text-foreground hover:border-border\",\n ghost: \"text-muted-foreground hover:text-foreground hover:bg-primary/5\",\n outline: \"border border-border bg-transparent text-foreground hover:bg-primary/5\",\n};\n\nconst SIZE_CLASS: Record<ButtonSize, string> = {\n sm: \"h-8 px-3 text-xs gap-1.5 rounded-full\",\n md: \"h-10 px-5 text-sm gap-2 rounded-full\",\n lg: \"h-12 px-6 text-base gap-2 rounded-full\",\n icon: \"h-8 w-8 rounded-lg\",\n};\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n variant = \"primary\",\n size = \"md\",\n pressScale = 0.93,\n ripple = false,\n className,\n children,\n onPointerDown,\n ...rest\n },\n ref,\n) {\n const reduce = useReducedMotion();\n const canHover = useHoverCapable();\n const [ripples, setRipples] = useState<Ripple[]>([]);\n const nextId = useRef(0);\n\n const handlePointerDown = useCallback(\n (event: PointerEvent<HTMLButtonElement>) => {\n if (ripple && !reduce) {\n const rect = event.currentTarget.getBoundingClientRect();\n const size = Math.max(rect.width, rect.height) * 2;\n const id = nextId.current++;\n setRipples((prev) => [\n ...prev,\n {\n id,\n x: event.clientX - rect.left,\n y: event.clientY - rect.top,\n size,\n },\n ]);\n }\n onPointerDown?.(event);\n },\n [ripple, reduce, onPointerDown],\n );\n\n return (\n <motion.button\n ref={ref}\n type=\"button\"\n whileTap={reduce ? undefined : { scale: pressScale }}\n whileHover={reduce || !canHover ? undefined : { scale: 1.02 }}\n transition={SPRING_PRESS}\n onPointerDown={handlePointerDown}\n className={cn(\n \"inline-flex select-none items-center justify-center font-medium\",\n \"transition-colors\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n ripple && \"relative overflow-hidden\",\n VARIANT_CLASS[variant],\n SIZE_CLASS[size],\n className,\n )}\n {...rest}\n >\n {ripple && !reduce ? (\n <span className=\"pointer-events-none absolute inset-0 overflow-hidden rounded-[inherit]\">\n <AnimatePresence>\n {ripples.map((r) => (\n <motion.span\n key={r.id}\n className=\"absolute rounded-full bg-current\"\n style={{\n left: r.x,\n top: r.y,\n width: r.size,\n height: r.size,\n x: \"-50%\",\n y: \"-50%\",\n }}\n initial={{ scale: 0.05, opacity: 0.3 }}\n animate={{ scale: 1, opacity: 0 }}\n exit={{ opacity: 0 }}\n transition={{ duration: 1.6, ease: EASE_OUT }}\n onAnimationComplete={() => setRipples((prev) => prev.filter((x) => x.id !== r.id))}\n />\n ))}\n </AnimatePresence>\n </span>\n ) : null}\n {children}\n </motion.button>\n );\n});\n\nexport const ButtonLink = forwardRef<HTMLAnchorElement, ButtonLinkProps>(function ButtonLink(\n { variant = \"primary\", size = \"md\", pressScale = 0.93, className, children, ...rest },\n ref,\n) {\n const reduce = useReducedMotion();\n const canHover = useHoverCapable();\n\n return (\n <motion.a\n ref={ref}\n whileTap={reduce ? undefined : { scale: pressScale }}\n whileHover={reduce || !canHover ? undefined : { scale: 1.02 }}\n transition={SPRING_PRESS}\n className={cn(\n \"inline-flex select-none items-center justify-center font-medium\",\n \"transition-colors\",\n VARIANT_CLASS[variant],\n SIZE_CLASS[size],\n className,\n )}\n {...rest}\n >\n {children}\n </motion.a>\n );\n});\n"],"mappings":";;;;;;;;AAqCA,MAAM,gBAA+C;CACnD,SAAS;CACT,WAAW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GAAG;IACL;IACA,SAAS;KAAE,OAAO;KAAM,SAAS;IAAI;IACrC,SAAS;KAAE,OAAO;KAAG,SAAS;IAAE;IAChC,MAAM,EAAE,SAAS,EAAE;IACnB,YAAY;KAAE,UAAU;KAAK,MAAM;IAAS;IAC5C,2BAA2B,YAAY,SAAS,KAAK,QAAQ,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC;GAClF,GAfM,EAAE,EAeR,CACF,EACc,CAAA;EACb,CAAA,IACJ,MACH,QACY;;AAEnB,CAAC;AAED,MAAa,aAAa,WAA+C,SAAS,WAChF,EAAE,UAAU,WAAW,OAAO,MAAM,aAAa,KAAM,WAAW,UAAU,GAAG,QAC/E,KACA;CACA,MAAM,SAAS,iBAAiB;CAChC,MAAM,WAAW,gBAAgB;CAEjC,OACE,oBAAC,OAAO,GAAR;EACO;EACL,UAAU,SAAS,KAAA,IAAY,EAAE,OAAO,WAAW;EACnD,YAAY,UAAU,CAAC,WAAW,KAAA,IAAY,EAAE,OAAO,KAAK;EAC5D,YAAY;EACZ,WAAW,GACT,mEACA,qBACA,cAAc,UACd,WAAW,OACX,SACF;EACA,GAAI;EAEH;CACO,CAAA;AAEd,CAAC"}
1
+ {"version":3,"file":"base.js","names":[],"sources":["../../../../src/components/motion/button/base.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n forwardRef,\n type PointerEvent,\n type ReactNode,\n useCallback,\n useRef,\n useState,\n} from \"react\";\nimport { AnimatePresence, type HTMLMotionProps, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useHoverCapable } from \"../../../hooks/use-hover-capable\";\nimport { EASE_OUT, SPRING_PRESS } from \"../../../lib/ease\";\n\nexport type ButtonVariant = \"primary\" | \"secondary\" | \"ghost\" | \"outline\";\nexport type ButtonSize = \"sm\" | \"md\" | \"lg\" | \"icon\";\n\nexport interface ButtonProps extends Omit<HTMLMotionProps<\"button\">, \"children\"> {\n variant?: ButtonVariant;\n size?: ButtonSize;\n pressScale?: number;\n /** Spawn a Material-style ripple from the press point. Off by default. */\n ripple?: boolean;\n children?: ReactNode;\n}\n\nexport interface ButtonLinkProps extends Omit<HTMLMotionProps<\"a\">, \"children\"> {\n variant?: ButtonVariant;\n size?: ButtonSize;\n pressScale?: number;\n children?: ReactNode;\n}\n\ntype Ripple = { id: number; x: number; y: number; size: number };\n\nconst VARIANT_CLASS: Record<ButtonVariant, string> = {\n primary: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n secondary: \"border border-border bg-card text-foreground hover:border-border\",\n ghost: \"text-muted-foreground hover:text-foreground hover:bg-muted/60\",\n outline: \"border border-border bg-transparent text-foreground hover:bg-muted/60\",\n};\n\nconst SIZE_CLASS: Record<ButtonSize, string> = {\n sm: \"h-8 px-3 text-xs gap-1.5 rounded-full\",\n md: \"h-10 px-5 text-sm gap-2 rounded-full\",\n lg: \"h-12 px-6 text-base gap-2 rounded-full\",\n icon: \"h-8 w-8 rounded-lg\",\n};\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n variant = \"primary\",\n size = \"md\",\n pressScale = 0.93,\n ripple = false,\n className,\n children,\n onPointerDown,\n ...rest\n },\n ref,\n) {\n const reduce = useReducedMotion();\n const canHover = useHoverCapable();\n const [ripples, setRipples] = useState<Ripple[]>([]);\n const nextId = useRef(0);\n\n const handlePointerDown = useCallback(\n (event: PointerEvent<HTMLButtonElement>) => {\n if (ripple && !reduce) {\n const rect = event.currentTarget.getBoundingClientRect();\n const size = Math.max(rect.width, rect.height) * 2;\n const id = nextId.current++;\n setRipples((prev) => [\n ...prev,\n {\n id,\n x: event.clientX - rect.left,\n y: event.clientY - rect.top,\n size,\n },\n ]);\n }\n onPointerDown?.(event);\n },\n [ripple, reduce, onPointerDown],\n );\n\n return (\n <motion.button\n ref={ref}\n type=\"button\"\n whileTap={reduce ? undefined : { scale: pressScale }}\n whileHover={reduce || !canHover ? undefined : { scale: 1.02 }}\n transition={SPRING_PRESS}\n onPointerDown={handlePointerDown}\n className={cn(\n \"inline-flex select-none items-center justify-center font-medium\",\n \"transition-colors\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n ripple && \"relative overflow-hidden\",\n VARIANT_CLASS[variant],\n SIZE_CLASS[size],\n className,\n )}\n {...rest}\n >\n {ripple && !reduce ? (\n <span className=\"pointer-events-none absolute inset-0 overflow-hidden rounded-[inherit]\">\n <AnimatePresence>\n {ripples.map((r) => (\n <motion.span\n key={r.id}\n className=\"absolute rounded-full bg-current\"\n style={{\n left: r.x,\n top: r.y,\n width: r.size,\n height: r.size,\n x: \"-50%\",\n y: \"-50%\",\n }}\n initial={{ scale: 0.05, opacity: 0.3 }}\n animate={{ scale: 1, opacity: 0 }}\n exit={{ opacity: 0 }}\n transition={{ duration: 1.6, ease: EASE_OUT }}\n onAnimationComplete={() => setRipples((prev) => prev.filter((x) => x.id !== r.id))}\n />\n ))}\n </AnimatePresence>\n </span>\n ) : null}\n {children}\n </motion.button>\n );\n});\n\nexport const ButtonLink = forwardRef<HTMLAnchorElement, ButtonLinkProps>(function ButtonLink(\n { variant = \"primary\", size = \"md\", pressScale = 0.93, className, children, ...rest },\n ref,\n) {\n const reduce = useReducedMotion();\n const canHover = useHoverCapable();\n\n return (\n <motion.a\n ref={ref}\n whileTap={reduce ? undefined : { scale: pressScale }}\n whileHover={reduce || !canHover ? undefined : { scale: 1.02 }}\n transition={SPRING_PRESS}\n className={cn(\n \"inline-flex select-none items-center justify-center font-medium\",\n \"transition-colors\",\n VARIANT_CLASS[variant],\n SIZE_CLASS[size],\n className,\n )}\n {...rest}\n >\n {children}\n </motion.a>\n );\n});\n"],"mappings":";;;;;;;;AAqCA,MAAM,gBAA+C;CACnD,SAAS;CACT,WAAW;CACX,OAAO;CACP,SAAS;AACX;AAEA,MAAM,aAAyC;CAC7C,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,MAAM;AACR;AAEA,MAAa,SAAS,WAA2C,SAAS,OACxE,EACE,UAAU,WACV,OAAO,MACP,aAA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C5C,2BAA2B,YAAY,SAAS,KAAK,QAAQ,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC;GAClF,GAfM,EAAE,EAeR,CACF,EACc,CAAA;EACb,CAAA,IACJ,MACH,QACY;;AAEnB,CAAC;AAED,MAAa,aAAa,WAA+C,SAAS,WAChF,EAAE,UAAU,WAAW,OAAO,MAAM,aAAa,KAAM,WAAW,UAAU,GAAG,QAC/E,KACA;CACA,MAAM,SAAS,iBAAiB;CAChC,MAAM,WAAW,gBAAgB;CAEjC,OACE,oBAAC,OAAO,GAAR;EACO;EACL,UAAU,SAAS,KAAA,IAAY,EAAE,OAAO,WAAW;EACnD,YAAY,UAAU,CAAC,WAAW,KAAA,IAAY,EAAE,OAAO,KAAK;EAC5D,YAAY;EACZ,WAAW,GACT,mEACA,qBACA,cAAc,UACd,WAAW,OACX,SACF;EACA,GAAI;EAEH;CACO,CAAA;AAEd,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { ComponentPropsWithRef } from "react";
2
+ //#region src/components/motion/color-selector.d.ts
3
+ export interface ColorSelectorProps extends Omit<ComponentPropsWithRef<"fieldset">, "onChange" | "defaultValue"> {
4
+ value?: string;
5
+ defaultValue?: string;
6
+ onValueChange?: (value: string) => void;
7
+ /** The radio group name used in form submission. Generated when omitted. */
8
+ name?: string;
9
+ required?: boolean;
10
+ }
11
+ /** A single color choice. Give it a ColorSelectorLabel or an aria-label. */
12
+ export declare function ColorSelector({ value, defaultValue, onValueChange, name, disabled, required, form, className, children, ...props }: ColorSelectorProps): import("react").JSX.Element;
13
+ export type ColorSelectorLabelProps = ComponentPropsWithRef<"legend">;
14
+ export declare function ColorSelectorLabel({ className, ...props }: ColorSelectorLabelProps): import("react").JSX.Element;
15
+ export type ColorSelectorListProps = ComponentPropsWithRef<"div">;
16
+ export declare function ColorSelectorList({ className, ...props }: ColorSelectorListProps): import("react").JSX.Element;
17
+ export interface ColorSelectorItemProps extends Omit<ComponentPropsWithRef<"input">, "type" | "value" | "defaultValue" | "checked" | "defaultChecked" | "name" | "children" | "size"> {
18
+ value: string;
19
+ /** Any CSS color, including a custom property. */
20
+ color: string;
21
+ /** Accessible color name; selection never relies on color alone. */
22
+ label: string;
23
+ /** Applied to the visible swatch surface. */
24
+ className?: string;
25
+ }
26
+ export declare function ColorSelectorItem({ value, color, label, disabled, className, style, onChange, ...props }: ColorSelectorItemProps): import("react").JSX.Element;
27
+ //#endregion
28
+ //# sourceMappingURL=color-selector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-selector.d.ts","names":[],"sources":["../../../src/components/motion/color-selector.tsx"],"mappings":";;iBAmBiB,2BACP,KAAK;EACb;EACA;EACA,iBAAiB;;EAEjB;EACA;;;wBAIc,gBACd,OACA,cACA,eACA,MACA,UACA,UACA,MACA,WACA,aACG,SACF,qCAAkB,IAAA;YA+BT,0BAA0B;wBAEtB,qBAAqB,cAAc,SAAS,0CAAuB,IAAA;YASvE,yBAAyB;wBAErB,oBAAoB,cAAc,SAAS,yCAAsB,IAAA;iBAIhE,+BACP,KACN;EAGF;;EAEA;;EAEA;;EAEA;;wBAGc,oBACd,OACA,OACA,OACA,UACA,WACA,OACA,aACG,SACF,yCAAsB,IAAA"}
@@ -0,0 +1,97 @@
1
+ "use client";
2
+ import { SPRING_LAYOUT, SPRING_PRESS } from "../../lib/ease.js";
3
+ import { createContext, useContext, useId, useState } from "react";
4
+ import { cn } from "@kumix/utils";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { LayoutGroup, motion, useReducedMotion } from "motion/react";
7
+ //#region src/components/motion/color-selector.tsx
8
+ const ColorSelectorContext = createContext(null);
9
+ /** A single color choice. Give it a ColorSelectorLabel or an aria-label. */
10
+ function ColorSelector({ value, defaultValue = "", onValueChange, name, disabled = false, required = false, form, className, children, ...props }) {
11
+ const id = useId();
12
+ const [internal, setInternal] = useState(defaultValue);
13
+ const current = value ?? internal;
14
+ return /* @__PURE__ */ jsx(ColorSelectorContext.Provider, {
15
+ value: {
16
+ value: current,
17
+ select: (next) => {
18
+ if (next === current) return;
19
+ if (value === void 0) setInternal(next);
20
+ onValueChange?.(next);
21
+ },
22
+ name: name ?? id,
23
+ disabled,
24
+ required,
25
+ form
26
+ },
27
+ children: /* @__PURE__ */ jsx("fieldset", {
28
+ ...props,
29
+ disabled,
30
+ form,
31
+ className: cn("min-w-0 border-0 p-0", className),
32
+ children: /* @__PURE__ */ jsx(LayoutGroup, {
33
+ id,
34
+ children
35
+ })
36
+ })
37
+ });
38
+ }
39
+ function ColorSelectorLabel({ className, ...props }) {
40
+ return /* @__PURE__ */ jsx("legend", {
41
+ ...props,
42
+ className: cn("mb-3 p-0 font-medium text-muted-foreground text-sm", className)
43
+ });
44
+ }
45
+ function ColorSelectorList({ className, ...props }) {
46
+ return /* @__PURE__ */ jsx("div", {
47
+ ...props,
48
+ className: cn("flex flex-wrap items-center gap-3 p-1", className)
49
+ });
50
+ }
51
+ function ColorSelectorItem({ value, color, label, disabled = false, className, style, onChange, ...props }) {
52
+ const context = useContext(ColorSelectorContext);
53
+ const reduce = useReducedMotion();
54
+ if (!context) throw new Error("ColorSelectorItem must be used within ColorSelector");
55
+ const selected = context.value === value;
56
+ const unavailable = disabled || context.disabled;
57
+ return /* @__PURE__ */ jsxs(motion.label, {
58
+ tabIndex: -1,
59
+ whileTap: reduce || unavailable ? void 0 : { scale: .94 },
60
+ transition: SPRING_PRESS,
61
+ className: cn("relative inline-flex shrink-0 rounded-full", unavailable ? "cursor-not-allowed opacity-40" : "cursor-pointer"),
62
+ children: [/* @__PURE__ */ jsx("input", {
63
+ ...props,
64
+ type: "radio",
65
+ name: context.name,
66
+ value,
67
+ checked: selected,
68
+ disabled: unavailable,
69
+ required: context.required,
70
+ form: context.form,
71
+ "aria-label": label,
72
+ onChange: (event) => {
73
+ onChange?.(event);
74
+ if (!event.defaultPrevented) context.select(value);
75
+ },
76
+ className: "peer sr-only"
77
+ }), /* @__PURE__ */ jsxs("span", {
78
+ "aria-hidden": "true",
79
+ style,
80
+ className: cn("relative flex size-11 items-center justify-center rounded-full border border-foreground/10 bg-muted/60", "peer-focus-visible:outline-2 peer-focus-visible:outline-foreground peer-focus-visible:outline-offset-4", className),
81
+ children: [selected && /* @__PURE__ */ jsx(motion.span, {
82
+ layoutId: reduce ? void 0 : "color-selection",
83
+ initial: false,
84
+ transition: SPRING_LAYOUT,
85
+ className: "pointer-events-none absolute -inset-1 rounded-full border-2",
86
+ style: { borderColor: `color-mix(in srgb, ${color} 65%, transparent)` }
87
+ }), /* @__PURE__ */ jsx("span", {
88
+ className: "size-5 rounded-full border border-black/5",
89
+ style: { backgroundColor: color }
90
+ })]
91
+ })]
92
+ });
93
+ }
94
+ //#endregion
95
+ export { ColorSelector, ColorSelectorItem, ColorSelectorLabel, ColorSelectorList };
96
+
97
+ //# sourceMappingURL=color-selector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-selector.js","names":[],"sources":["../../../src/components/motion/color-selector.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ComponentPropsWithRef, createContext, useContext, useId, useState } from \"react\";\nimport { LayoutGroup, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { SPRING_LAYOUT, SPRING_PRESS } from \"../../lib/ease\";\n\ntype ColorSelectorContextValue = {\n value: string;\n select: (value: string) => void;\n name: string;\n disabled: boolean;\n required: boolean;\n form?: string;\n};\n\nconst ColorSelectorContext = createContext<ColorSelectorContextValue | null>(null);\n\nexport interface ColorSelectorProps\n extends Omit<ComponentPropsWithRef<\"fieldset\">, \"onChange\" | \"defaultValue\"> {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /** The radio group name used in form submission. Generated when omitted. */\n name?: string;\n required?: boolean;\n}\n\n/** A single color choice. Give it a ColorSelectorLabel or an aria-label. */\nexport function ColorSelector({\n value,\n defaultValue = \"\",\n onValueChange,\n name,\n disabled = false,\n required = false,\n form,\n className,\n children,\n ...props\n}: ColorSelectorProps) {\n const id = useId();\n const [internal, setInternal] = useState(defaultValue);\n const current = value ?? internal;\n return (\n <ColorSelectorContext.Provider\n value={{\n value: current,\n select: (next) => {\n if (next === current) return;\n if (value === undefined) setInternal(next);\n onValueChange?.(next);\n },\n name: name ?? id,\n disabled,\n required,\n form,\n }}\n >\n <fieldset\n {...props}\n disabled={disabled}\n form={form}\n className={cn(\"min-w-0 border-0 p-0\", className)}\n >\n <LayoutGroup id={id}>{children}</LayoutGroup>\n </fieldset>\n </ColorSelectorContext.Provider>\n );\n}\n\nexport type ColorSelectorLabelProps = ComponentPropsWithRef<\"legend\">;\n\nexport function ColorSelectorLabel({ className, ...props }: ColorSelectorLabelProps) {\n return (\n <legend\n {...props}\n className={cn(\"mb-3 p-0 font-medium text-muted-foreground text-sm\", className)}\n />\n );\n}\n\nexport type ColorSelectorListProps = ComponentPropsWithRef<\"div\">;\n\nexport function ColorSelectorList({ className, ...props }: ColorSelectorListProps) {\n return <div {...props} className={cn(\"flex flex-wrap items-center gap-3 p-1\", className)} />;\n}\n\nexport interface ColorSelectorItemProps\n extends Omit<\n ComponentPropsWithRef<\"input\">,\n \"type\" | \"value\" | \"defaultValue\" | \"checked\" | \"defaultChecked\" | \"name\" | \"children\" | \"size\"\n > {\n value: string;\n /** Any CSS color, including a custom property. */\n color: string;\n /** Accessible color name; selection never relies on color alone. */\n label: string;\n /** Applied to the visible swatch surface. */\n className?: string;\n}\n\nexport function ColorSelectorItem({\n value,\n color,\n label,\n disabled = false,\n className,\n style,\n onChange,\n ...props\n}: ColorSelectorItemProps) {\n const context = useContext(ColorSelectorContext);\n const reduce = useReducedMotion();\n if (!context) throw new Error(\"ColorSelectorItem must be used within ColorSelector\");\n const selected = context.value === value;\n const unavailable = disabled || context.disabled;\n return (\n <motion.label\n tabIndex={-1}\n whileTap={reduce || unavailable ? undefined : { scale: 0.94 }}\n transition={SPRING_PRESS}\n className={cn(\n \"relative inline-flex shrink-0 rounded-full\",\n unavailable ? \"cursor-not-allowed opacity-40\" : \"cursor-pointer\",\n )}\n >\n <input\n {...props}\n type=\"radio\"\n name={context.name}\n value={value}\n checked={selected}\n disabled={unavailable}\n required={context.required}\n form={context.form}\n aria-label={label}\n onChange={(event) => {\n onChange?.(event);\n if (!event.defaultPrevented) context.select(value);\n }}\n className=\"peer sr-only\"\n />\n <span\n aria-hidden=\"true\"\n style={style}\n className={cn(\n \"relative flex size-11 items-center justify-center rounded-full border border-foreground/10 bg-muted/60\",\n \"peer-focus-visible:outline-2 peer-focus-visible:outline-foreground peer-focus-visible:outline-offset-4\",\n className,\n )}\n >\n {selected && (\n <motion.span\n layoutId={reduce ? undefined : \"color-selection\"}\n initial={false}\n transition={SPRING_LAYOUT}\n className=\"pointer-events-none absolute -inset-1 rounded-full border-2\"\n style={{ borderColor: `color-mix(in srgb, ${color} 65%, transparent)` }}\n />\n )}\n <span\n className=\"size-5 rounded-full border border-black/5\"\n style={{ backgroundColor: color }}\n />\n </span>\n </motion.label>\n );\n}\n"],"mappings":";;;;;;;AAiBA,MAAM,uBAAuB,cAAgD,IAAI;;AAajF,SAAgB,cAAc,EAC5B,OACA,eAAe,IACf,eACA,MACA,WAAW,OACX,WAAW,OACX,MACA,WACA,UACA,GAAG,SACkB;CACrB,MAAM,KAAK,MAAM;CACjB,MAAM,CAAC,UAAU,eAAe,SAAS,YAAY;CACrD,MAAM,UAAU,SAAS;CACzB,OACE,oBAAC,qBAAqB,UAAtB;EACE,OAAO;GACL,OAAO;GACP,SAAS,SAAS;IAChB,IAAI,SAAS,SAAS;IACtB,IAAI,UAAU,KAAA,GAAW,YAAY,IAAI;IACzC,gBAAgB,IAAI;GACtB;GACA,MAAM,QAAQ;GACd;GACA;GACA;EACF;EAEA,UAAA,oBAAC,YAAD;GACE,GAAI;GACM;GACJ;GACN,WAAW,GAAG,wBAAwB,SAAS;GAE/C,UAAA,oBAAC,aAAD;IAAiB;IAAK;GAAsB,CAAA;EACpC,CAAA;CACmB,CAAA;AAEnC;AAIA,SAAgB,mBAAmB,EAAE,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;;AAElB"}
@@ -215,7 +215,7 @@ function CommandPalette({ items, shortcut = "k", placeholder = "Type a command o
215
215
  children: [
216
216
  isActive ? /* @__PURE__ */ jsx(motion.span, {
217
217
  layoutId: `${uid}-active`,
218
- className: "absolute inset-0 z-0 rounded-md bg-primary/5",
218
+ className: "absolute inset-0 z-0 rounded-md bg-muted/60",
219
219
  transition: reduce ? { duration: 0 } : {
220
220
  type: "spring",
221
221
  stiffness: 480,
@@ -1 +1 @@
1
- {"version":3,"file":"command-palette.js","names":[],"sources":["../../../src/components/motion/command-palette.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useCallback, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport { type LucideIcon, Search } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useOnOpen } from \"../../hooks/use-on-open\";\nimport { useRowCursor } from \"../../hooks/use-row-cursor\";\nimport { useTouchCapable } from \"../../hooks/use-touch-capable\";\nimport { searchCommands } from \"../../lib/command-search\";\nimport { EASE_OUT } from \"../../lib/ease\";\nimport { PresenceGate } from \"../../lib/presence-gate\";\n\nexport type CommandItem = {\n id: string;\n label: string;\n group?: string;\n hint?: string;\n keywords?: string[];\n icon?: LucideIcon;\n badge?: ReactNode;\n onSelect: () => void;\n};\n\nexport interface CommandPaletteProps {\n items: CommandItem[];\n /** Opens with Cmd/Ctrl + this key. Default: \"k\" */\n shortcut?: string;\n placeholder?: string;\n emptyMessage?: string;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n}\n\n// Opened via a keyboard shortcut many times a day — entrance must read as\n// instant. Tight spring, even faster exit.\nconst PANEL_SPRING = {\n type: \"spring\",\n stiffness: 560,\n damping: 40,\n mass: 0.5,\n} as const;\n\nexport function CommandPalette({\n items,\n shortcut = \"k\",\n placeholder = \"Type a command or search…\",\n emptyMessage = \"No results found.\",\n open: controlledOpen,\n onOpenChange,\n}: CommandPaletteProps) {\n const [internalOpen, setInternalOpen] = useState(false);\n const controlled = controlledOpen !== undefined;\n const open = controlled ? controlledOpen : internalOpen;\n const setOpen = useCallback(\n (v: boolean) => {\n if (!controlled) setInternalOpen(v);\n onOpenChange?.(v);\n },\n [controlled, onOpenChange],\n );\n\n const [query, setQuery] = useState(\"\");\n // Portal target only exists client-side; render nothing during SSR/hydration.\n const [mounted, setMounted] = useState(false);\n useEffect(() => setMounted(true), []);\n const uid = useId();\n const reduce = useReducedMotion();\n const canTouch = useTouchCapable();\n const inputRef = useRef<HTMLInputElement>(null);\n const listRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const onKey = (e: KeyboardEvent) => {\n if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === shortcut.toLowerCase()) {\n e.preventDefault();\n setOpen(!open);\n return;\n }\n if (e.key === \"Escape\" && open) {\n e.preventDefault();\n setOpen(false);\n }\n };\n window.addEventListener(\"keydown\", onKey);\n return () => window.removeEventListener(\"keydown\", onKey);\n }, [open, shortcut, setOpen]);\n\n useEffect(() => {\n if (!open) return;\n const root = document.documentElement;\n const previousRootOverflow = root.style.overflow;\n const previousBodyOverflow = document.body.style.overflow;\n root.style.overflow = \"hidden\";\n document.body.style.overflow = \"hidden\";\n return () => {\n root.style.overflow = previousRootOverflow;\n document.body.style.overflow = previousBodyOverflow;\n };\n }, [open]);\n\n const filtered = useMemo(() => searchCommands(items, query), [items, query]);\n\n // Reserve the icon column only when at least one item brings an icon, so\n // icon-less lists don't render a dead gap before every label.\n const hasIcons = useMemo(() => items.some((it) => it.icon), [items]);\n\n const grouped = useMemo(() => {\n const map = new Map<string, CommandItem[]>();\n filtered.forEach((it) => {\n const g = it.group ?? \"Results\";\n const groupItems = map.get(g) ?? [];\n groupItems.push(it);\n map.set(g, groupItems);\n });\n return Array.from(map.entries());\n }, [filtered]);\n\n // Grouping reorders the list, so the rendered order is not the filtered\n // order whenever two groups interleave. Everything that has to agree on\n // \"which row\" — the highlight, the ids, Enter, the scroll — reads this one\n // array, so they cannot drift apart.\n const rows = useMemo(() => grouped.flatMap(([, list]) => list), [grouped]);\n\n const { activeIndex: active, moveTo, moveActive } = useRowCursor(rows, query);\n\n // Clearing the query would drop the cursor on its own, but only if it had\n // changed; `moveTo(null)` covers reopening on an already-empty query.\n useOnOpen(open, () => {\n setQuery(\"\");\n moveTo(null);\n });\n\n useEffect(() => {\n if (!open) return;\n const frame = requestAnimationFrame(() => inputRef.current?.focus());\n return () => cancelAnimationFrame(frame);\n }, [open]);\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n moveActive(1);\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n moveActive(-1);\n } else if (e.key === \"Enter\") {\n e.preventDefault();\n const it = rows[active];\n if (it) {\n it.onSelect();\n setOpen(false);\n }\n }\n };\n\n useEffect(() => {\n if (!open) return;\n const el = listRef.current?.querySelector<HTMLButtonElement>(`[data-index=\"${active}\"]`);\n el?.scrollIntoView({ block: \"nearest\" });\n }, [active, open]);\n\n if (!mounted) return null;\n\n // Portaled to <body> so ancestors with transforms, filters, or fixed\n // positioning can't trap the overlay in their stacking context, and mounted\n // only while open. The chrome is two fixed siblings rather than one wrapper:\n // the backdrop spans the viewport edges but carries the scrim colour, and the\n // layer positioning the panel is inset off every edge. Both hang off\n // `PresenceGate`, so interaction releases in the same commit that starts the\n // exit rather than when it ends — `open` is already false for those frames.\n // See tests/fixed-overlay-edge-sampling.test.tsx.\n return createPortal(\n <AnimatePresence initial={false}>\n {open ? (\n <PresenceGate key=\"backdrop\">\n {({ gate }) => (\n <motion.button\n type=\"button\"\n aria-label=\"Close command palette\"\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{\n opacity: 0,\n transition: { duration: 0.12, ease: EASE_OUT },\n }}\n transition={{ duration: 0.18, ease: EASE_OUT }}\n {...gate}\n onClick={() => setOpen(false)}\n className=\"pointer-events-auto fixed inset-0 z-100 bg-background/5 [-webkit-backdrop-filter:blur(12px)_saturate(140%)] [backdrop-filter:blur(12px)_saturate(140%)]\"\n />\n )}\n </PresenceGate>\n ) : null}\n\n {open ? (\n <PresenceGate key=\"panel-layer\">\n {({ isPresent, gate }) => (\n // The layer itself never takes pointer events, so it carries\n // `inert` alone rather than the gate's pointer-events value.\n <div\n inert={!isPresent}\n className=\"pointer-events-none fixed inset-x-4 top-[18vh] bottom-4 z-100 flex items-start justify-center\"\n >\n <motion.div\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Command palette\"\n initial={{\n opacity: 0,\n y: reduce ? 0 : -8,\n scale: reduce ? 1 : 0.97,\n }}\n animate={{ opacity: 1, y: 0, scale: 1 }}\n exit={{\n opacity: 0,\n y: reduce ? 0 : -8,\n scale: reduce ? 1 : 0.97,\n transition: { duration: 0.12, ease: EASE_OUT },\n }}\n transition={reduce ? { duration: 0.1 } : PANEL_SPRING}\n {...gate}\n onKeyDown={onKeyDown}\n className=\"pointer-events-auto w-full max-w-xl overflow-hidden rounded-2xl border border-border bg-card shadow-2xl will-change-transform\"\n >\n <div className=\"flex items-center gap-3 border-border border-b px-4\">\n <Search className=\"h-4 w-4 text-muted-foreground\" />\n <input\n ref={inputRef}\n value={query}\n onChange={(e) => setQuery(e.target.value)}\n placeholder={placeholder}\n role=\"combobox\"\n // The field only exists while the palette is open.\n aria-expanded=\"true\"\n aria-controls={`${uid}-list`}\n aria-activedescendant={rows.length > 0 ? `${uid}-opt-${active}` : undefined}\n aria-autocomplete=\"list\"\n className={cn(\n \"h-12 flex-1 bg-transparent text-foreground text-sm outline-none placeholder:text-muted-foreground\",\n // The palette focuses this field the moment it opens, and iOS\n // zooms the page in on a focused field under 16px: the fixed\n // overlay is magnified off-center — clipped leading edge, half\n // an icon column — and the zoom outlives the palette. 16px on\n // touch keeps the page at scale 1; pointer devices keep 14px.\n canTouch && \"text-base\",\n )}\n />\n <kbd className=\"hidden rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-muted-foreground sm:inline-block\">\n ESC\n </kbd>\n </div>\n <div\n ref={listRef}\n id={`${uid}-list`}\n role=\"listbox\"\n aria-label=\"Commands\"\n className=\"max-h-[60vh] overflow-y-auto overscroll-contain p-2 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden\"\n >\n {rows.length === 0 ? (\n <div className=\"p-8 text-center text-muted-foreground text-sm\">\n {emptyMessage}\n </div>\n ) : (\n grouped.map(([group, list]) => (\n <div key={group} className=\"mb-1 last:mb-0\">\n <div\n aria-hidden\n className=\"px-2 py-1.5 font-semibold text-[10px] text-muted-foreground uppercase tracking-wider\"\n >\n {group}\n </div>\n {list.map((it) => {\n // `rows` holds these very objects, in render order.\n const idx = rows.indexOf(it);\n const isActive = idx === active;\n const Icon = it.icon;\n return (\n <button\n key={it.id}\n type=\"button\"\n id={`${uid}-opt-${idx}`}\n role=\"option\"\n aria-selected={isActive}\n data-index={idx}\n onMouseEnter={() => moveTo(it.id)}\n onClick={() => {\n it.onSelect();\n setOpen(false);\n }}\n className={cn(\n \"relative isolate flex w-full items-center gap-3 rounded-md px-2 py-2 text-left text-sm transition-colors\",\n isActive ? \"text-foreground\" : \"text-muted-foreground\",\n )}\n >\n {isActive ? (\n <motion.span\n layoutId={`${uid}-active`}\n className=\"absolute inset-0 z-0 rounded-md bg-primary/5\"\n transition={\n reduce\n ? { duration: 0 }\n : // Tracks rapid arrow-key navigation — keep it tighter\n // than SPRING_LAYOUT so it never lags the active row.\n {\n type: \"spring\",\n stiffness: 480,\n damping: 38,\n }\n }\n />\n ) : null}\n {Icon ? (\n <Icon className=\"relative z-10 h-4 w-4\" />\n ) : hasIcons ? (\n <span className=\"relative z-10 h-4 w-4\" />\n ) : null}\n <span className=\"relative z-10 flex-1 truncate\">{it.label}</span>\n {it.badge ? (\n <span className=\"relative z-10 shrink-0\">{it.badge}</span>\n ) : null}\n {it.hint ? (\n <kbd className=\"relative z-10 rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-muted-foreground\">\n {it.hint}\n </kbd>\n ) : null}\n </button>\n );\n })}\n </div>\n ))\n )}\n </div>\n </motion.div>\n </div>\n )}\n </PresenceGate>\n ) : null}\n </AnimatePresence>,\n document.body,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAsCA,MAAM,eAAe;CACnB,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,SAAgB,eAAe,EAC7B,OACA,WAAW,KACX,cAAc,6BACd,eAAe,qBACf,MAAM,gBACN,gBACsB;CACtB,MAAM,CAAC,cAAc,mBAAmB,SAAS,KAAK;CACtD,MAAM,aAAa,mBAAmB,KAAA;CACtC,MAAM,OAAO,aAAa,iBAAiB;CAC3C,MAAM,UAAU,aACb,MAAe;EACd,IAAI,CAAC,YAAY,gBAAgB,CAAC;EAClC,eAAe,CAAC;CAClB,GACA,CAAC,YAAY,YAAY,CAC3B;CAEA,MAAM,CAAC,OAAO,YAAY,SAAS,EAAE;CAErC,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,gBAAgB,WAAW,IAAI,GAAG,CAAC,CAAC;CACpC,MAAM,MAAM,MAAM;CAClB,MAAM,SAAS,iBAAiB;CAChC,MAAM,WAAW,gBAAgB;CACjC,MAAM,WAAW,OAAyB,IAAI;CAC9C,MAAM,UAAU,OAAuB,IAAI;CAE3C,gBAAgB;EACd,MAAM,SAAS,MAAqB;GAClC,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,YAAY,MAAM,SAAS,YAAY,GAAG;IAC9E,EAAE,eAAe;IACjB,QAAQ,CAAC,IAAI;IACb;GACF;GACA,IAAI,EAAE,QAAQ,YAAY,MAAM;IAC9B,EAAE,eAAe;IACjB,QAAQ,KAAK;GACf;EACF;EACA,OAAO,iBAAiB,WAAW,KAAK;EACxC,aAAa,OAAO,oBAAoB,WAAW,KAAK;CAC1D,GAAG;EAAC;EAAM;EAAU;CAAO,CAAC;CAE5B,gBAAgB;EACd,IAAI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,CAAA,IACC;SACH,OACC,oBAAC,MAAD,EAAM,WAAU,wBAAyB,CAAA,IACvC,WACF,oBAAC,QAAD,EAAM,WAAU,wBAAyB,CAAA,IACvC;SACJ,oBAAC,QAAD;UAAM,WAAU;UAAiC,UAAA,GAAG;SAAY,CAAA;SAC/D,GAAG,QACF,oBAAC,QAAD;UAAM,WAAU;UAA0B,UAAA,GAAG;SAAY,CAAA,IACvD;SACH,GAAG,OACF,oBAAC,OAAD;UAAK,WAAU;UACZ,UAAA,GAAG;SACD,CAAA,IACH;QACE;OA/CD,GAAA,GAAG,EA+CF;MAEZ,CAAC,CACE;KAhEK,GAAA,KAgEL,CACN;IAEA,CAAA,CACK;;EACT,CAAA,EAEK,GA5II,aA4IJ,IACZ,IACW;CACjB,CAAA,GAAA,SAAS,IACX;AACF"}
1
+ {"version":3,"file":"command-palette.js","names":[],"sources":["../../../src/components/motion/command-palette.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useCallback, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport { type LucideIcon, Search } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useOnOpen } from \"../../hooks/use-on-open\";\nimport { useRowCursor } from \"../../hooks/use-row-cursor\";\nimport { useTouchCapable } from \"../../hooks/use-touch-capable\";\nimport { searchCommands } from \"../../lib/command-search\";\nimport { EASE_OUT } from \"../../lib/ease\";\nimport { PresenceGate } from \"../../lib/presence-gate\";\n\nexport type CommandItem = {\n id: string;\n label: string;\n group?: string;\n hint?: string;\n keywords?: string[];\n icon?: LucideIcon;\n badge?: ReactNode;\n onSelect: () => void;\n};\n\nexport interface CommandPaletteProps {\n items: CommandItem[];\n /** Opens with Cmd/Ctrl + this key. Default: \"k\" */\n shortcut?: string;\n placeholder?: string;\n emptyMessage?: string;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n}\n\n// Opened via a keyboard shortcut many times a day — entrance must read as\n// instant. Tight spring, even faster exit.\nconst PANEL_SPRING = {\n type: \"spring\",\n stiffness: 560,\n damping: 40,\n mass: 0.5,\n} as const;\n\nexport function CommandPalette({\n items,\n shortcut = \"k\",\n placeholder = \"Type a command or search…\",\n emptyMessage = \"No results found.\",\n open: controlledOpen,\n onOpenChange,\n}: CommandPaletteProps) {\n const [internalOpen, setInternalOpen] = useState(false);\n const controlled = controlledOpen !== undefined;\n const open = controlled ? controlledOpen : internalOpen;\n const setOpen = useCallback(\n (v: boolean) => {\n if (!controlled) setInternalOpen(v);\n onOpenChange?.(v);\n },\n [controlled, onOpenChange],\n );\n\n const [query, setQuery] = useState(\"\");\n // Portal target only exists client-side; render nothing during SSR/hydration.\n const [mounted, setMounted] = useState(false);\n useEffect(() => setMounted(true), []);\n const uid = useId();\n const reduce = useReducedMotion();\n const canTouch = useTouchCapable();\n const inputRef = useRef<HTMLInputElement>(null);\n const listRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const onKey = (e: KeyboardEvent) => {\n if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === shortcut.toLowerCase()) {\n e.preventDefault();\n setOpen(!open);\n return;\n }\n if (e.key === \"Escape\" && open) {\n e.preventDefault();\n setOpen(false);\n }\n };\n window.addEventListener(\"keydown\", onKey);\n return () => window.removeEventListener(\"keydown\", onKey);\n }, [open, shortcut, setOpen]);\n\n useEffect(() => {\n if (!open) return;\n const root = document.documentElement;\n const previousRootOverflow = root.style.overflow;\n const previousBodyOverflow = document.body.style.overflow;\n root.style.overflow = \"hidden\";\n document.body.style.overflow = \"hidden\";\n return () => {\n root.style.overflow = previousRootOverflow;\n document.body.style.overflow = previousBodyOverflow;\n };\n }, [open]);\n\n const filtered = useMemo(() => searchCommands(items, query), [items, query]);\n\n // Reserve the icon column only when at least one item brings an icon, so\n // icon-less lists don't render a dead gap before every label.\n const hasIcons = useMemo(() => items.some((it) => it.icon), [items]);\n\n const grouped = useMemo(() => {\n const map = new Map<string, CommandItem[]>();\n filtered.forEach((it) => {\n const g = it.group ?? \"Results\";\n const groupItems = map.get(g) ?? [];\n groupItems.push(it);\n map.set(g, groupItems);\n });\n return Array.from(map.entries());\n }, [filtered]);\n\n // Grouping reorders the list, so the rendered order is not the filtered\n // order whenever two groups interleave. Everything that has to agree on\n // \"which row\" — the highlight, the ids, Enter, the scroll — reads this one\n // array, so they cannot drift apart.\n const rows = useMemo(() => grouped.flatMap(([, list]) => list), [grouped]);\n\n const { activeIndex: active, moveTo, moveActive } = useRowCursor(rows, query);\n\n // Clearing the query would drop the cursor on its own, but only if it had\n // changed; `moveTo(null)` covers reopening on an already-empty query.\n useOnOpen(open, () => {\n setQuery(\"\");\n moveTo(null);\n });\n\n useEffect(() => {\n if (!open) return;\n const frame = requestAnimationFrame(() => inputRef.current?.focus());\n return () => cancelAnimationFrame(frame);\n }, [open]);\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n moveActive(1);\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n moveActive(-1);\n } else if (e.key === \"Enter\") {\n e.preventDefault();\n const it = rows[active];\n if (it) {\n it.onSelect();\n setOpen(false);\n }\n }\n };\n\n useEffect(() => {\n if (!open) return;\n const el = listRef.current?.querySelector<HTMLButtonElement>(`[data-index=\"${active}\"]`);\n el?.scrollIntoView({ block: \"nearest\" });\n }, [active, open]);\n\n if (!mounted) return null;\n\n // Portaled to <body> so ancestors with transforms, filters, or fixed\n // positioning can't trap the overlay in their stacking context, and mounted\n // only while open. The chrome is two fixed siblings rather than one wrapper:\n // the backdrop spans the viewport edges but carries the scrim colour, and the\n // layer positioning the panel is inset off every edge. Both hang off\n // `PresenceGate`, so interaction releases in the same commit that starts the\n // exit rather than when it ends — `open` is already false for those frames.\n return createPortal(\n <AnimatePresence initial={false}>\n {open ? (\n <PresenceGate key=\"backdrop\">\n {({ gate }) => (\n <motion.button\n type=\"button\"\n aria-label=\"Close command palette\"\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{\n opacity: 0,\n transition: { duration: 0.12, ease: EASE_OUT },\n }}\n transition={{ duration: 0.18, ease: EASE_OUT }}\n {...gate}\n onClick={() => setOpen(false)}\n className=\"pointer-events-auto fixed inset-0 z-100 bg-background/5 [-webkit-backdrop-filter:blur(12px)_saturate(140%)] [backdrop-filter:blur(12px)_saturate(140%)]\"\n />\n )}\n </PresenceGate>\n ) : null}\n\n {open ? (\n <PresenceGate key=\"panel-layer\">\n {({ isPresent, gate }) => (\n // The layer itself never takes pointer events, so it carries\n // `inert` alone rather than the gate's pointer-events value.\n <div\n inert={!isPresent}\n className=\"pointer-events-none fixed inset-x-4 top-[18vh] bottom-4 z-100 flex items-start justify-center\"\n >\n <motion.div\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Command palette\"\n initial={{\n opacity: 0,\n y: reduce ? 0 : -8,\n scale: reduce ? 1 : 0.97,\n }}\n animate={{ opacity: 1, y: 0, scale: 1 }}\n exit={{\n opacity: 0,\n y: reduce ? 0 : -8,\n scale: reduce ? 1 : 0.97,\n transition: { duration: 0.12, ease: EASE_OUT },\n }}\n transition={reduce ? { duration: 0.1 } : PANEL_SPRING}\n {...gate}\n onKeyDown={onKeyDown}\n className=\"pointer-events-auto w-full max-w-xl overflow-hidden rounded-2xl border border-border bg-card shadow-2xl will-change-transform\"\n >\n <div className=\"flex items-center gap-3 border-border border-b px-4\">\n <Search className=\"h-4 w-4 text-muted-foreground\" />\n <input\n ref={inputRef}\n value={query}\n onChange={(e) => setQuery(e.target.value)}\n placeholder={placeholder}\n role=\"combobox\"\n // The field only exists while the palette is open.\n aria-expanded=\"true\"\n aria-controls={`${uid}-list`}\n aria-activedescendant={rows.length > 0 ? `${uid}-opt-${active}` : undefined}\n aria-autocomplete=\"list\"\n className={cn(\n \"h-12 flex-1 bg-transparent text-foreground text-sm outline-none placeholder:text-muted-foreground\",\n // The palette focuses this field the moment it opens, and iOS\n // zooms the page in on a focused field under 16px: the fixed\n // overlay is magnified off-center — clipped leading edge, half\n // an icon column — and the zoom outlives the palette. 16px on\n // touch keeps the page at scale 1; pointer devices keep 14px.\n canTouch && \"text-base\",\n )}\n />\n <kbd className=\"hidden rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-muted-foreground sm:inline-block\">\n ESC\n </kbd>\n </div>\n <div\n ref={listRef}\n id={`${uid}-list`}\n role=\"listbox\"\n aria-label=\"Commands\"\n className=\"max-h-[60vh] overflow-y-auto overscroll-contain p-2 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden\"\n >\n {rows.length === 0 ? (\n <div className=\"p-8 text-center text-muted-foreground text-sm\">\n {emptyMessage}\n </div>\n ) : (\n grouped.map(([group, list]) => (\n <div key={group} className=\"mb-1 last:mb-0\">\n <div\n aria-hidden\n className=\"px-2 py-1.5 font-semibold text-[10px] text-muted-foreground uppercase tracking-wider\"\n >\n {group}\n </div>\n {list.map((it) => {\n // `rows` holds these very objects, in render order.\n const idx = rows.indexOf(it);\n const isActive = idx === active;\n const Icon = it.icon;\n return (\n <button\n key={it.id}\n type=\"button\"\n id={`${uid}-opt-${idx}`}\n role=\"option\"\n aria-selected={isActive}\n data-index={idx}\n onMouseEnter={() => moveTo(it.id)}\n onClick={() => {\n it.onSelect();\n setOpen(false);\n }}\n className={cn(\n \"relative isolate flex w-full items-center gap-3 rounded-md px-2 py-2 text-left text-sm transition-colors\",\n isActive ? \"text-foreground\" : \"text-muted-foreground\",\n )}\n >\n {isActive ? (\n <motion.span\n layoutId={`${uid}-active`}\n className=\"absolute inset-0 z-0 rounded-md bg-muted/60\"\n transition={\n reduce\n ? { duration: 0 }\n : // Tracks rapid arrow-key navigation — keep it tighter\n // than SPRING_LAYOUT so it never lags the active row.\n {\n type: \"spring\",\n stiffness: 480,\n damping: 38,\n }\n }\n />\n ) : null}\n {Icon ? (\n <Icon className=\"relative z-10 h-4 w-4\" />\n ) : hasIcons ? (\n <span className=\"relative z-10 h-4 w-4\" />\n ) : null}\n <span className=\"relative z-10 flex-1 truncate\">{it.label}</span>\n {it.badge ? (\n <span className=\"relative z-10 shrink-0\">{it.badge}</span>\n ) : null}\n {it.hint ? (\n <kbd className=\"relative z-10 rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-muted-foreground\">\n {it.hint}\n </kbd>\n ) : null}\n </button>\n );\n })}\n </div>\n ))\n )}\n </div>\n </motion.div>\n </div>\n )}\n </PresenceGate>\n ) : null}\n </AnimatePresence>,\n document.body,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAsCA,MAAM,eAAe;CACnB,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,SAAgB,eAAe,EAC7B,OACA,WAAW,KACX,cAAc,6BACd,eAAe,qBACf,MAAM,gBACN,gBACsB;CACtB,MAAM,CAAC,cAAc,mBAAmB,SAAS,KAAK;CACtD,MAAM,aAAa,mBAAmB,KAAA;CACtC,MAAM,OAAO,aAAa,iBAAiB;CAC3C,MAAM,UAAU,aACb,MAAe;EACd,IAAI,CAAC,YAAY,gBAAgB,CAAC;EAClC,eAAe,CAAC;CAClB,GACA,CAAC,YAAY,YAAY,CAC3B;CAEA,MAAM,CAAC,OAAO,YAAY,SAAS,EAAE;CAErC,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,gBAAgB,WAAW,IAAI,GAAG,CAAC,CAAC;CACpC,MAAM,MAAM,MAAM;CAClB,MAAM,SAAS,iBAAiB;CAChC,MAAM,WAAW,gBAAgB;CACjC,MAAM,WAAW,OAAyB,IAAI;CAC9C,MAAM,UAAU,OAAuB,IAAI;CAE3C,gBAAgB;EACd,MAAM,SAAS,MAAqB;GAClC,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,YAAY,MAAM,SAAS,YAAY,GAAG;IAC9E,EAAE,eAAe;IACjB,QAAQ,CAAC,IAAI;IACb;GACF;GACA,IAAI,EAAE,QAAQ,YAAY,MAAM;IAC9B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AAW,oBAAoB,uBACjC;QAfF,UAAA;SAiBG,WACC,oBAAC,OAAO,MAAR;UACE,UAAU,GAAG,IAAI;UACjB,WAAU;UACV,YACE,SACI,EAAE,UAAU,EAAE,IAGd;WACE,MAAM;WACN,WAAW;WACX,SAAS;UACX;SAEP,CAAA,IACC;SACH,OACC,oBAAC,MAAD,EAAM,WAAU,wBAAyB,CAAA,IACvC,WACF,oBAAC,QAAD,EAAM,WAAU,wBAAyB,CAAA,IACvC;SACJ,oBAAC,QAAD;UAAM,WAAU;UAAiC,UAAA,GAAG;SAAY,CAAA;SAC/D,GAAG,QACF,oBAAC,QAAD;UAAM,WAAU;UAA0B,UAAA,GAAG;SAAY,CAAA,IACvD;SACH,GAAG,OACF,oBAAC,OAAD;UAAK,WAAU;UACZ,UAAA,GAAG;SACD,CAAA,IACH;QACE;OA/CD,GAAA,GAAG,EA+CF;MAEZ,CAAC,CACE;KAhEK,GAAA,KAgEL,CACN;IAEA,CAAA,CACK;;EACT,CAAA,EAEK,GA5II,aA4IJ,IACZ,IACW;CACjB,CAAA,GAAA,SAAS,IACX;AACF"}
@@ -28,7 +28,7 @@ function DockItem({ children, className, onClick, active, ...rest }) {
28
28
  const pill = active ? /* @__PURE__ */ jsx(motion.span, {
29
29
  layoutId: pillLayoutId,
30
30
  transition: reduce ? { duration: 0 } : SPRING_LAYOUT,
31
- className: "absolute inset-0.5 -z-10 rounded-xl bg-primary/5"
31
+ className: "absolute inset-0.5 -z-10 rounded-xl bg-muted/60"
32
32
  }) : null;
33
33
  const sharedStyle = {
34
34
  width: size,
@@ -1 +1 @@
1
- {"version":3,"file":"dock.js","names":[],"sources":["../../../src/components/motion/dock.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, type ReactNode, useContext, useId, useMemo } from \"react\";\nimport { motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { SPRING_LAYOUT } from \"../../lib/ease\";\n\ntype DockContextValue = {\n size: number;\n pillLayoutId: string;\n};\n\nconst DockContext = createContext<DockContextValue | null>(null);\n\nexport interface DockProps {\n children: ReactNode;\n className?: string;\n /** Size of each item in px. */\n size?: number;\n}\n\nexport function Dock({ children, size = 44, className }: DockProps) {\n const pillLayoutId = useId();\n const ctx = useMemo<DockContextValue>(() => ({ size, pillLayoutId }), [size, pillLayoutId]);\n\n return (\n <DockContext.Provider value={ctx}>\n <div\n className={cn(\n \"inline-flex h-auto items-end gap-1.5 rounded-2xl border border-border bg-card/80 px-2 py-1 shadow-2xl backdrop-blur-xl\",\n className,\n )}\n >\n {children}\n </div>\n </DockContext.Provider>\n );\n}\n\nexport interface DockItemProps {\n children: ReactNode;\n className?: string;\n /** When set, the item renders as a <button>. Omit when children carry their own link or button. */\n onClick?: () => void;\n active?: boolean;\n \"aria-label\"?: string;\n}\n\nexport function DockItem({ children, className, onClick, active, ...rest }: DockItemProps) {\n const dock = useContext(DockContext);\n const reduce = useReducedMotion();\n const size = dock?.size ?? 44;\n const pillLayoutId = dock?.pillLayoutId ?? \"dock-pill\";\n\n const pill = active ? (\n <motion.span\n layoutId={pillLayoutId}\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n className=\"absolute inset-0.5 -z-10 rounded-xl bg-primary/5\"\n />\n ) : null;\n const sharedStyle = { width: size, height: size };\n const sharedClass = cn(\n \"relative flex shrink-0 items-center justify-center rounded-full text-foreground\",\n className,\n );\n\n if (onClick) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n aria-label={rest[\"aria-label\"]}\n aria-pressed={active}\n style={sharedStyle}\n className={cn(\n sharedClass,\n \"cursor-pointer border-0 bg-transparent p-0 outline-none\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n )}\n >\n {pill}\n {children}\n </button>\n );\n }\n\n // Children carry their own link or button (and its accessible name).\n return (\n <div style={sharedStyle} className={sharedClass}>\n {pill}\n {children}\n </div>\n );\n}\n\nexport function DockSeparator({ className }: { className?: string }) {\n return <span aria-hidden className={cn(\"mx-1 h-6 w-px self-center bg-border\", className)} />;\n}\n"],"mappings":";;;;;;;AAaA,MAAM,cAAc,cAAuC,IAAI;AAS/D,SAAgB,KAAK,EAAE,UAAU,OAAO,IAAI,aAAwB;CAClE,MAAM,eAAe,MAAM;CAC3B,MAAM,MAAM,eAAiC;EAAE;EAAM;CAAa,IAAI,CAAC,MAAM,YAAY,CAAC;CAE1F,OACE,oBAAC,YAAY,UAAb;EAAsB,OAAO;EAC3B,UAAA,oBAAC,OAAD;GACE,WAAW,GACT,0HACA,SACF;GAEC;EACE,CAAA;CACe,CAAA;AAE1B;AAWA,SAAgB,SAAS,EAAE,UAAU,WAAW,SAAS,QAAQ,GAAG,QAAuB;CACzF,MAAM,OAAO,WAAW,WAAW;CACnC,MAAM,SAAS,iBAAiB;CAChC,MAAM,OAAO,MAAM,QAAQ;CAC3B,MAAM,eAAe,MAAM,gBAAgB;CAE3C,MAAM,OAAO,SACX,oBAAC,OAAO,MAAR;EACE,UAAU;EACV,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;EACvC,WAAU;CACX,CAAA,IACC;CACJ,MAAM,cAAc;EAAE,OAAO;EAAM,QAAQ;CAAK;CAChD,MAAM,cAAc,GAClB,mFACA,SACF;CAEA,IAAI,SACF,OACE,qBAAC,UAAD;EACE,MAAK;EACI;EACT,cAAY,KAAK;EACjB,gBAAc;EACd,OAAO;EACP,WAAW,GACT,aACA,2DACA,+GACF;EAVF,UAAA,CAYG,MACA,QACK;;CAKZ,OACE,qBAAC,OAAD;EAAK,OAAO;EAAa,WAAW;EAApC,UAAA,CACG,MACA,QACE;;AAET;AAEA,SAAgB,cAAc,EAAE,aAAqC;CACnE,OAAO,oBAAC,QAAD;EAAM,eAAA;EAAY,WAAW,GAAG,uCAAuC,SAAS;CAAI,CAAA;AAC7F"}
1
+ {"version":3,"file":"dock.js","names":[],"sources":["../../../src/components/motion/dock.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, type ReactNode, useContext, useId, useMemo } from \"react\";\nimport { motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { SPRING_LAYOUT } from \"../../lib/ease\";\n\ntype DockContextValue = {\n size: number;\n pillLayoutId: string;\n};\n\nconst DockContext = createContext<DockContextValue | null>(null);\n\nexport interface DockProps {\n children: ReactNode;\n className?: string;\n /** Size of each item in px. */\n size?: number;\n}\n\nexport function Dock({ children, size = 44, className }: DockProps) {\n const pillLayoutId = useId();\n const ctx = useMemo<DockContextValue>(() => ({ size, pillLayoutId }), [size, pillLayoutId]);\n\n return (\n <DockContext.Provider value={ctx}>\n <div\n className={cn(\n \"inline-flex h-auto items-end gap-1.5 rounded-2xl border border-border bg-card/80 px-2 py-1 shadow-2xl backdrop-blur-xl\",\n className,\n )}\n >\n {children}\n </div>\n </DockContext.Provider>\n );\n}\n\nexport interface DockItemProps {\n children: ReactNode;\n className?: string;\n /** When set, the item renders as a <button>. Omit when children carry their own link or button. */\n onClick?: () => void;\n active?: boolean;\n \"aria-label\"?: string;\n}\n\nexport function DockItem({ children, className, onClick, active, ...rest }: DockItemProps) {\n const dock = useContext(DockContext);\n const reduce = useReducedMotion();\n const size = dock?.size ?? 44;\n const pillLayoutId = dock?.pillLayoutId ?? \"dock-pill\";\n\n const pill = active ? (\n <motion.span\n layoutId={pillLayoutId}\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n className=\"absolute inset-0.5 -z-10 rounded-xl bg-muted/60\"\n />\n ) : null;\n const sharedStyle = { width: size, height: size };\n const sharedClass = cn(\n \"relative flex shrink-0 items-center justify-center rounded-full text-foreground\",\n className,\n );\n\n if (onClick) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n aria-label={rest[\"aria-label\"]}\n aria-pressed={active}\n style={sharedStyle}\n className={cn(\n sharedClass,\n \"cursor-pointer border-0 bg-transparent p-0 outline-none\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n )}\n >\n {pill}\n {children}\n </button>\n );\n }\n\n // Children carry their own link or button (and its accessible name).\n return (\n <div style={sharedStyle} className={sharedClass}>\n {pill}\n {children}\n </div>\n );\n}\n\nexport function DockSeparator({ className }: { className?: string }) {\n return <span aria-hidden className={cn(\"mx-1 h-6 w-px self-center bg-border\", className)} />;\n}\n"],"mappings":";;;;;;;AAaA,MAAM,cAAc,cAAuC,IAAI;AAS/D,SAAgB,KAAK,EAAE,UAAU,OAAO,IAAI,aAAwB;CAClE,MAAM,eAAe,MAAM;CAC3B,MAAM,MAAM,eAAiC;EAAE;EAAM;CAAa,IAAI,CAAC,MAAM,YAAY,CAAC;CAE1F,OACE,oBAAC,YAAY,UAAb;EAAsB,OAAO;EAC3B,UAAA,oBAAC,OAAD;GACE,WAAW,GACT,0HACA,SACF;GAEC;EACE,CAAA;CACe,CAAA;AAE1B;AAWA,SAAgB,SAAS,EAAE,UAAU,WAAW,SAAS,QAAQ,GAAG,QAAuB;CACzF,MAAM,OAAO,WAAW,WAAW;CACnC,MAAM,SAAS,iBAAiB;CAChC,MAAM,OAAO,MAAM,QAAQ;CAC3B,MAAM,eAAe,MAAM,gBAAgB;CAE3C,MAAM,OAAO,SACX,oBAAC,OAAO,MAAR;EACE,UAAU;EACV,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;EACvC,WAAU;CACX,CAAA,IACC;CACJ,MAAM,cAAc;EAAE,OAAO;EAAM,QAAQ;CAAK;CAChD,MAAM,cAAc,GAClB,mFACA,SACF;CAEA,IAAI,SACF,OACE,qBAAC,UAAD;EACE,MAAK;EACI;EACT,cAAY,KAAK;EACjB,gBAAc;EACd,OAAO;EACP,WAAW,GACT,aACA,2DACA,+GACF;EAVF,UAAA,CAYG,MACA,QACK;;CAKZ,OACE,qBAAC,OAAD;EAAK,OAAO;EAAa,WAAW;EAApC,UAAA,CACG,MACA,QACE;;AAET;AAEA,SAAgB,cAAc,EAAE,aAAqC;CACnE,OAAO,oBAAC,QAAD;EAAM,eAAA;EAAY,WAAW,GAAG,uCAAuC,SAAS;CAAI,CAAA;AAC7F"}
@@ -1 +1 @@
1
- {"version":3,"file":"drawer.js","names":[],"sources":["../../../src/components/motion/drawer.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useEffect } from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_PANEL } from \"../../lib/ease\";\nimport { PresenceGate } from \"../../lib/presence-gate\";\n\nexport interface DrawerProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n side?: \"left\" | \"right\";\n children: ReactNode;\n /** Class for the panel surface. */\n className?: string;\n /** Class for the backdrop. */\n backdropClassName?: string;\n ariaLabel?: string;\n /** Close when the backdrop is clicked. Default true. */\n dismissable?: boolean;\n}\n\nexport function Drawer({\n open,\n onOpenChange,\n side = \"right\",\n children,\n className,\n backdropClassName,\n ariaLabel,\n dismissable = true,\n}: DrawerProps) {\n const reduce = useReducedMotion();\n\n useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") onOpenChange(false);\n };\n window.addEventListener(\"keydown\", onKey);\n const prevOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n return () => {\n window.removeEventListener(\"keydown\", onKey);\n document.body.style.overflow = prevOverflow;\n };\n }, [open, onOpenChange]);\n\n const offscreen = side === \"right\" ? \"100%\" : \"-100%\";\n\n // Two fixed siblings, no wrapper: the backdrop spans the viewport edges but\n // paints the scrim, and the panel is inset off one side and paints its own\n // surface, so neither is a transparent edge-spanning layer. Both hang off\n // `PresenceGate`, so interaction releases in the same commit that starts the\n return (\n <AnimatePresence>\n {open ? (\n <PresenceGate key=\"backdrop\">\n {({ gate }) => (\n <motion.button\n type=\"button\"\n aria-label=\"Close\"\n tabIndex={dismissable ? 0 : -1}\n onClick={() => dismissable && onOpenChange(false)}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n transition={{ duration: 0.25, ease: EASE_OUT }}\n {...gate}\n className={cn(\n \"fixed inset-0 z-50 h-full w-full cursor-default bg-black/40 backdrop-blur-sm\",\n backdropClassName,\n )}\n />\n )}\n </PresenceGate>\n ) : null}\n {open ? (\n <PresenceGate key=\"panel\">\n {({ gate }) => (\n <motion.aside\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={ariaLabel}\n initial={reduce ? { opacity: 0 } : { x: offscreen }}\n animate={reduce ? { opacity: 1 } : { x: 0 }}\n exit={reduce ? { opacity: 0 } : { x: offscreen }}\n transition={reduce ? { duration: 0.2, ease: EASE_OUT } : SPRING_PANEL}\n {...gate}\n className={cn(\n \"fixed inset-y-0 z-50 flex w-80 max-w-[85vw] flex-col bg-background shadow-2xl\",\n side === \"right\"\n ? \"right-0 border-border border-l\"\n : \"left-0 border-border border-r\",\n className,\n )}\n >\n {children}\n </motion.aside>\n )}\n </PresenceGate>\n ) : null}\n </AnimatePresence>\n );\n}\n"],"mappings":";;;;;;;;AAuBA,SAAgB,OAAO,EACrB,MACA,cACA,OAAO,SACP,UACA,WACA,mBACA,WACA,cAAc,QACA;CACd,MAAM,SAAS,iBAAiB;CAEhC,gBAAgB;EACd,IAAI,CAAC,MAAM;EACX,MAAM,SAAS,MAAqB;GAClC,IAAI,EAAE,QAAQ,UAAU,aAAa,KAAK;EAC5C;EACA,OAAO,iBAAiB,WAAW,KAAK;EACxC,MAAM,eAAe,SAAS,KAAK,MAAM;EACzC,SAAS,KAAK,MAAM,WAAW;EAC/B,aAAa;GACX,OAAO,oBAAoB,WAAW,KAAK;GAC3C,SAAS,KAAK,MAAM,WAAW;EACjC;CACF,GAAG,CAAC,MAAM,YAAY,CAAC;CAEvB,MAAM,YAAY,SAAS,UAAU,SAAS;CAM9C,OACE,qBAAC,iBAAD,EAAA,UAAA,CACG,OACC,oBAAC,cAAD,EAAA,WACI,EAAE,WACF,oBAAC,OAAO,QAAR;EACE,MAAK;EACL,cAAW;EACX,UAAU,cAAc,IAAI;EAC5B,eAAe,eAAe,aAAa,KAAK;EAChD,SAAS,EAAE,SAAS,EAAE;EACtB,SAAS,EAAE,SAAS,EAAE;EACtB,MAAM,EAAE,SAAS,EAAE;EACnB,YAAY;GAAE,UAAU;GAAM,MAAM;EAAS;EAC7C,GAAI;EACJ,WAAW,GACT,gFACA,iBACF;CACD,CAAA,EAES,GAlBI,UAkBJ,IACZ,MACH,OACC,oBAAC,cAAD,EAAA,WACI,EAAE,WACF,oBAAC,OAAO,OAAR;EACE,MAAK;EACL,cAAW;EACX,cAAY;EACZ,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,UAAU;EAClD,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE;EAC1C,MAAM,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,UAAU;EAC/C,YAAY,SAAS;GAAE,UAAU;GAAK,MAAM;EAAS,IAAI;EACzD,GAAI;EACJ,WAAW,GACT,iFACA,SAAS,UACL,mCACA,iCACJ,SACF;EAEC;CACW,CAAA,EAEJ,GAtBI,OAsBJ,IACZ,IACW,EAAA,CAAA;AAErB"}
1
+ {"version":3,"file":"drawer.js","names":[],"sources":["../../../src/components/motion/drawer.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useEffect } from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_PANEL } from \"../../lib/ease\";\nimport { PresenceGate } from \"../../lib/presence-gate\";\n\nexport interface DrawerProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n side?: \"left\" | \"right\";\n children: ReactNode;\n /** Class for the panel surface. */\n className?: string;\n /** Class for the backdrop. */\n backdropClassName?: string;\n ariaLabel?: string;\n /** Close when the backdrop is clicked. Default true. */\n dismissable?: boolean;\n}\n\nexport function Drawer({\n open,\n onOpenChange,\n side = \"right\",\n children,\n className,\n backdropClassName,\n ariaLabel,\n dismissable = true,\n}: DrawerProps) {\n const reduce = useReducedMotion();\n\n useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") onOpenChange(false);\n };\n window.addEventListener(\"keydown\", onKey);\n const prevOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n return () => {\n window.removeEventListener(\"keydown\", onKey);\n document.body.style.overflow = prevOverflow;\n };\n }, [open, onOpenChange]);\n\n const offscreen = side === \"right\" ? \"100%\" : \"-100%\";\n\n // Two fixed siblings, no wrapper: the backdrop spans the viewport edges but\n // paints the scrim, and the panel is inset off one side and paints its own\n // surface, so neither is a transparent edge-spanning layer. Both hang off\n // `PresenceGate`, so interaction releases in the same commit that starts the\n // exit rather than when it ends.\n return (\n <AnimatePresence>\n {open ? (\n <PresenceGate key=\"backdrop\">\n {({ gate }) => (\n <motion.button\n type=\"button\"\n aria-label=\"Close\"\n tabIndex={dismissable ? 0 : -1}\n onClick={() => dismissable && onOpenChange(false)}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n transition={{ duration: 0.25, ease: EASE_OUT }}\n {...gate}\n className={cn(\n \"fixed inset-0 z-50 h-full w-full cursor-default bg-black/40 backdrop-blur-sm\",\n backdropClassName,\n )}\n />\n )}\n </PresenceGate>\n ) : null}\n {open ? (\n <PresenceGate key=\"panel\">\n {({ gate }) => (\n <motion.aside\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={ariaLabel}\n initial={reduce ? { opacity: 0 } : { x: offscreen }}\n animate={reduce ? { opacity: 1 } : { x: 0 }}\n exit={reduce ? { opacity: 0 } : { x: offscreen }}\n transition={reduce ? { duration: 0.2, ease: EASE_OUT } : SPRING_PANEL}\n {...gate}\n className={cn(\n \"fixed inset-y-0 z-50 flex w-80 max-w-[85vw] flex-col bg-background shadow-2xl\",\n side === \"right\"\n ? \"right-0 border-border border-l\"\n : \"left-0 border-border border-r\",\n className,\n )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AAY,SAAS;GAAE,UAAU;GAAK,MAAM;EAAS,IAAI;EACzD,GAAI;EACJ,WAAW,GACT,iFACA,SAAS,UACL,mCACA,iCACJ,SACF;EAEC;CACW,CAAA,EAEJ,GAtBI,OAsBJ,IACZ,IACW,EAAA,CAAA;AAErB"}
@@ -147,7 +147,7 @@ function ExpandableActionBar({ items, expanded, defaultExpanded = false, onExpan
147
147
  className: cn("relative isolate inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full font-medium text-muted-foreground outline-none transition-[color,background-color] duration-150 ease-out", "focus-visible:text-foreground disabled:pointer-events-none disabled:opacity-40", isHighlighted && "text-foreground", ITEM_SIZE_CLASS[size], classNames?.item, isActive && classNames?.activeItem),
148
148
  children: [isHighlighted ? /* @__PURE__ */ jsx(motion.span, {
149
149
  layoutId: "action-bar-highlight",
150
- className: "absolute inset-0 -z-10 rounded-full bg-primary/[0.07]",
150
+ className: "absolute inset-0 -z-10 rounded-full bg-muted/80",
151
151
  transition: ITEM_TRANSITION
152
152
  }) : null, renderItem ? renderItem(item, {
153
153
  expanded: isExpanded,
@@ -1 +1 @@
1
- {"version":3,"file":"expandable-action-bar.js","names":[],"sources":["../../../src/components/motion/expandable-action-bar.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type FocusEvent,\n type MouseEvent,\n type PointerEvent,\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { LayoutGroup, motion, type Transition, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useDismiss } from \"../../hooks/use-dismiss\";\nimport { useHoverGesture } from \"../../hooks/use-hover-gesture\";\nimport { useTapGesture } from \"../../hooks/use-tap-gesture\";\n\nexport type ExpandableActionBarSize = \"sm\" | \"md\";\n\nexport type ExpandableActionBarItem = {\n id: string;\n label: ReactNode;\n icon: ReactNode;\n onClick?: () => void;\n disabled?: boolean;\n active?: boolean;\n badge?: ReactNode;\n shortcut?: ReactNode;\n};\n\nexport type ExpandableActionBarClassNames = {\n root?: string;\n track?: string;\n item?: string;\n activeItem?: string;\n icon?: string;\n label?: string;\n badge?: string;\n shortcut?: string;\n};\n\nexport interface ExpandableActionBarProps {\n items: ExpandableActionBarItem[];\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n activeId?: string;\n onAction?: (item: ExpandableActionBarItem) => void;\n size?: ExpandableActionBarSize;\n /**\n * Expand when a pointer that hovers rests on the bar. Default true. It also\n * governs the touch equivalent: with no hover to reveal the labels, the\n * first tap expands the bar and runs no action, and the second one acts.\n * Set false to make every tap and click act immediately.\n */\n expandOnHover?: boolean;\n expandOnFocus?: boolean;\n collapseDelay?: number;\n className?: string;\n classNames?: ExpandableActionBarClassNames;\n renderItem?: (\n item: ExpandableActionBarItem,\n state: { expanded: boolean; active: boolean },\n ) => ReactNode;\n}\n\nconst ITEM_TRANSITION: Transition = {\n type: \"spring\",\n stiffness: 460,\n damping: 34,\n mass: 0.62,\n};\n\nconst LABEL_TRANSITION: Transition = {\n type: \"spring\",\n stiffness: 380,\n damping: 32,\n mass: 0.7,\n};\n\nconst SIZE_CLASS: Record<ExpandableActionBarSize, string> = {\n sm: \"min-h-9 gap-1 p-1 text-xs\",\n md: \"min-h-11 gap-1.5 p-1.5 text-sm\",\n};\n\nconst ITEM_SIZE_CLASS: Record<ExpandableActionBarSize, string> = {\n sm: \"h-7 min-w-7 px-1.5\",\n md: \"h-8 min-w-8 px-2\",\n};\n\nconst ICON_SIZE_CLASS: Record<ExpandableActionBarSize, string> = {\n sm: \"h-3.5 w-3.5\",\n md: \"h-4 w-4\",\n};\n\nfunction useControllableExpanded({\n expanded,\n defaultExpanded,\n onExpandedChange,\n}: {\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n}) {\n const [internalExpanded, setInternalExpanded] = useState(defaultExpanded ?? false);\n const isControlled = expanded !== undefined;\n const value = expanded ?? internalExpanded;\n\n const setValue = useCallback(\n (next: boolean) => {\n if (!isControlled) setInternalExpanded(next);\n onExpandedChange?.(next);\n },\n [isControlled, onExpandedChange],\n );\n\n return [value, setValue] as const;\n}\n\nexport function ExpandableActionBar({\n items,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n activeId,\n onAction,\n size = \"md\",\n expandOnHover = true,\n expandOnFocus = true,\n collapseDelay = 90,\n className,\n classNames,\n renderItem,\n}: ExpandableActionBarProps) {\n const reduce = useReducedMotion();\n const layoutId = useId();\n const [isExpanded, setIsExpanded] = useControllableExpanded({\n expanded,\n defaultExpanded,\n onExpandedChange,\n });\n const [hoveredId, setHoveredId] = useState<string | null>(null);\n // Set by the tap that expands the bar, and the reason the outside-tap\n // dismisser exists at all — a hovering pointer has its own way out.\n const [tapExpanded, setTapExpanded] = useState(false);\n const collapseTimer = useRef<number | null>(null);\n const trackRef = useRef<HTMLDivElement | null>(null);\n // What the last gesture on an action was, and whether the bar was already\n // expanded when it started. A click reports neither.\n const tap = useTapGesture<boolean>();\n const hover = useHoverGesture();\n\n const clearCollapseTimer = useCallback(() => {\n if (collapseTimer.current) window.clearTimeout(collapseTimer.current);\n collapseTimer.current = null;\n }, []);\n\n const open = useCallback(() => {\n clearCollapseTimer();\n setIsExpanded(true);\n }, [clearCollapseTimer, setIsExpanded]);\n\n const close = useCallback(() => {\n clearCollapseTimer();\n const timer = window.setTimeout(() => {\n setIsExpanded(false);\n setHoveredId(null);\n setTapExpanded(false);\n }, collapseDelay);\n collapseTimer.current = timer;\n }, [clearCollapseTimer, collapseDelay, setIsExpanded]);\n\n useEffect(() => clearCollapseTimer, [clearCollapseTimer]);\n\n // A collapse from outside takes the labels with it, so the arm the tap that\n // expanded the bar left behind has to go too — otherwise the next tap runs\n // an action whose label nobody can read. Only on the way down from expanded:\n // a controlled bar that declined to expand at all keeps its arm, which is\n // what lets its second tap act.\n const wasExpanded = useRef(isExpanded);\n useEffect(() => {\n if (wasExpanded.current && !isExpanded) setTapExpanded(false);\n wasExpanded.current = isExpanded;\n }, [isExpanded]);\n\n // A finger never hovers and Safari does not focus a button on tap, so a bar a\n // tap expanded would have nothing to close it. The tap that lands elsewhere\n // stands in for the pointer leaving — and it is consumed rather than passed\n // through, because the labelled bar is exactly the kind of surface people\n // dismiss by tapping just past it, over whatever control is there.\n useDismiss(tapExpanded && isExpanded, close, trackRef, {\n behavior: \"consume\",\n });\n\n const onRootPointerEnter = (event: PointerEvent<HTMLDivElement>) => {\n // The gesture is told about every enter, `expandOnHover` or not: it is\n // what the matching leave is read against.\n if (hover.enter(event) && expandOnHover) open();\n };\n\n const onRootPointerLeave = (event: PointerEvent<HTMLDivElement>) => {\n if (!hover.leave(event)) return;\n setHoveredId(null);\n if (expandOnHover) close();\n };\n\n const onRootFocus = () => {\n if (expandOnFocus) open();\n };\n\n const onRootBlur = (event: FocusEvent<HTMLDivElement>) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node) && expandOnFocus) {\n close();\n }\n };\n\n const activeItemId = activeId ?? items.find((item) => item.active)?.id;\n const highlightId = hoveredId ?? activeItemId;\n\n return (\n <LayoutGroup id={layoutId}>\n <motion.div\n layout=\"size\"\n // Pointer events, not the mouse pair: a tap fires compatibility\n // mouseenter/mouseleave that carry no pointerType, and the bar growing\n // under a stationary finger fired the leave before the click ever\n // landed — so one tap expanded, collapsed and ran nothing.\n onPointerEnter={onRootPointerEnter}\n onPointerLeave={onRootPointerLeave}\n onFocus={onRootFocus}\n onBlur={onRootBlur}\n transition={ITEM_TRANSITION}\n className={cn(\"inline-flex max-w-full\", classNames?.root, className)}\n >\n <motion.div\n ref={trackRef}\n layout=\"size\"\n className={cn(\n // Labelled actions can outgrow the space the bar sits in — the pill\n // stays inside it and scrolls its rail rather than running off the\n // edge, where the last action is unreachable.\n \"scrollbar-hide relative inline-flex max-w-full items-center overflow-x-auto overflow-y-hidden rounded-full border border-border bg-card/90 shadow-2xl backdrop-blur-xl\",\n SIZE_CLASS[size],\n classNames?.track,\n )}\n transition={ITEM_TRANSITION}\n >\n {items.map((item) => {\n const isActive = item.active || activeId === item.id;\n const isHighlighted = highlightId === item.id;\n\n return (\n <motion.button\n key={item.id}\n layout=\"position\"\n type=\"button\"\n disabled={item.disabled}\n title={typeof item.label === \"string\" ? item.label : undefined}\n onPointerEnter={(event: PointerEvent<HTMLButtonElement>) => {\n if (!hover.enter(event)) return;\n clearCollapseTimer();\n setHoveredId(item.id);\n }}\n onPointerDown={(event: PointerEvent<HTMLButtonElement>) => {\n tap.start(event, isExpanded);\n }}\n // A gesture the platform takes away sends no click, and a key\n // press starts an activation that never had a pointer behind\n // it: either one would otherwise leave the finger in place for\n // the next click to spend.\n onPointerCancel={tap.drop}\n onKeyDown={tap.drop}\n onClick={(event: MouseEvent<HTMLButtonElement>) => {\n event.currentTarget.blur();\n const gesture = tap.take();\n // Nothing reveals the labels to a finger, so the first tap\n // expands the bar and the next one runs the action. The bar\n // state is read from the gesture's start: a browser that\n // focuses the button on contact expands it mid-tap, and that\n // first tap would otherwise fire the action it was meant to\n // reveal. `tapExpanded` arms the second tap, so a controlled\n // bar that declines to expand still runs the action rather\n // than swallowing every tap.\n const firstTap =\n gesture !== null &&\n gesture.pointerType !== \"mouse\" &&\n !gesture.state &&\n !tapExpanded;\n if (firstTap && expandOnHover) {\n setTapExpanded(true);\n open();\n setHoveredId(item.id);\n return;\n }\n item.onClick?.();\n onAction?.(item);\n }}\n whileTap={reduce || item.disabled ? undefined : { scale: 0.96 }}\n transition={ITEM_TRANSITION}\n className={cn(\n \"relative isolate inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full font-medium text-muted-foreground outline-none transition-[color,background-color] duration-150 ease-out\",\n \"focus-visible:text-foreground disabled:pointer-events-none disabled:opacity-40\",\n isHighlighted && \"text-foreground\",\n ITEM_SIZE_CLASS[size],\n classNames?.item,\n isActive && classNames?.activeItem,\n )}\n >\n {isHighlighted ? (\n <motion.span\n layoutId=\"action-bar-highlight\"\n className=\"absolute inset-0 -z-10 rounded-full bg-primary/[0.07]\"\n transition={ITEM_TRANSITION}\n />\n ) : null}\n\n {renderItem ? (\n renderItem(item, { expanded: isExpanded, active: isActive })\n ) : (\n <>\n <span\n className={cn(\n \"inline-flex shrink-0 items-center justify-center\",\n ICON_SIZE_CLASS[size],\n classNames?.icon,\n )}\n >\n {item.icon}\n </span>\n\n <motion.span\n aria-hidden={!isExpanded}\n animate={\n reduce\n ? {\n width: isExpanded ? \"auto\" : 0,\n opacity: isExpanded ? 1 : 0,\n marginLeft: isExpanded ? 8 : 0,\n x: 0,\n filter: \"blur(0px)\",\n }\n : {\n width: isExpanded ? \"auto\" : 0,\n opacity: isExpanded ? 1 : 0,\n x: isExpanded ? 0 : -4,\n marginLeft: isExpanded ? 8 : 0,\n filter: isExpanded ? \"blur(0px)\" : \"blur(3px)\",\n }\n }\n transition={reduce ? { duration: 0 } : LABEL_TRANSITION}\n className={cn(\n \"inline-block overflow-hidden whitespace-nowrap\",\n classNames?.label,\n )}\n >\n {item.label}\n </motion.span>\n\n {item.shortcut ? (\n <motion.span\n aria-hidden={!isExpanded}\n animate={{\n width: isExpanded ? \"auto\" : 0,\n opacity: isExpanded ? 1 : 0,\n marginLeft: isExpanded ? 4 : 0,\n }}\n transition={LABEL_TRANSITION}\n className={cn(\n \"hidden overflow-hidden whitespace-nowrap text-[10px] text-muted-foreground sm:inline-block\",\n classNames?.shortcut,\n )}\n >\n {item.shortcut}\n </motion.span>\n ) : null}\n\n {item.badge ? (\n <span\n className={cn(\n \"ml-0.5 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-destructive px-1 text-[10px] text-primary-foreground leading-none\",\n !isExpanded && \"absolute top-0.5 right-0.5\",\n classNames?.badge,\n )}\n >\n {item.badge}\n </span>\n ) : null}\n </>\n )}\n </motion.button>\n );\n })}\n </motion.div>\n </motion.div>\n </LayoutGroup>\n );\n}\n\nexport function useExpandableActionBar(items: ExpandableActionBarItem[]) {\n const [expanded, setExpanded] = useState(false);\n const [activeId, setActiveId] = useState(items[0]?.id);\n\n const activeItem = useMemo(() => items.find((item) => item.id === activeId), [activeId, items]);\n\n return useMemo(\n () => ({ expanded, setExpanded, activeId, setActiveId, activeItem }),\n [activeId, activeItem, expanded],\n );\n}\n"],"mappings":";;;;;;;;;AAsEA,MAAM,kBAA8B;CAClC,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,MAAM,mBAA+B;CACnC,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,MAAM,aAAsD;CAC1D,IAAI;CACJ,IAAI;AACN;AAEA,MAAM,kBAA2D;CAC/D,IAAI;CACJ,IAAI;AACN;AAEA,MAAM,kBAA2D;CAC/D,IAAI;CACJ,IAAI;AACN;AAEA,SAAS,wBAAwB,EAC/B,UACA,iBACA,oBAKC;CACD,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,mBAAmB,KAAK;CACjF,MAAM,eAAe,aAAa,KAAA;CAWlC,OAAO,CAVO,YAAY,kBAET,aACd,SAAkB;EACjB,IAAI,CAAC,cAAc,oBAAoB,IAAI;EAC3C,mBAAmB,IAAI;CACzB,GACA,CAAC,cAAc,gBAAgB,CAGX,CAAC;AACzB;AAEA,SAAgB,oBAAoB,EAClC,OACA,UACA,kBAAkB,OAClB,kBACA,UACA,UACA,OAAO,MACP,gBAAgB,MAChB,gBAAgB,MAChB,gBAAgB,IAChB,WACA,YACA,cAC2B;CAC3B,MAAM,SAAS,iBAAiB;CAChC,MAAM,WAAW,MAAM;CACvB,MAAM,CAAC,YAAY,iBAAiB,wBAAwB;EAC1D;EACA;EACA;CACF,CAAC;CACD,MAAM,CAAC,WAAW,gBAAgB,SAAwB,IAAI;CAG9D,MAAM,CAAC,aAAa,kBAAkB,SAAS,KAAK;CACpD,MAAM,gBAAgB,OAAsB,IAAI;CAChD,MAAM,WAAW,OAA8B,IAAI;CAGnD,MAAM,MAAM,cAAuB;CACnC,MAAM,QAAQ,gBAAgB;CAE9B,MAAM,qBAAqB,kBAAkB;EAC3C,IAA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"expandable-action-bar.js","names":[],"sources":["../../../src/components/motion/expandable-action-bar.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type FocusEvent,\n type MouseEvent,\n type PointerEvent,\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { LayoutGroup, motion, type Transition, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useDismiss } from \"../../hooks/use-dismiss\";\nimport { useHoverGesture } from \"../../hooks/use-hover-gesture\";\nimport { useTapGesture } from \"../../hooks/use-tap-gesture\";\n\nexport type ExpandableActionBarSize = \"sm\" | \"md\";\n\nexport type ExpandableActionBarItem = {\n id: string;\n label: ReactNode;\n icon: ReactNode;\n onClick?: () => void;\n disabled?: boolean;\n active?: boolean;\n badge?: ReactNode;\n shortcut?: ReactNode;\n};\n\nexport type ExpandableActionBarClassNames = {\n root?: string;\n track?: string;\n item?: string;\n activeItem?: string;\n icon?: string;\n label?: string;\n badge?: string;\n shortcut?: string;\n};\n\nexport interface ExpandableActionBarProps {\n items: ExpandableActionBarItem[];\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n activeId?: string;\n onAction?: (item: ExpandableActionBarItem) => void;\n size?: ExpandableActionBarSize;\n /**\n * Expand when a pointer that hovers rests on the bar. Default true. It also\n * governs the touch equivalent: with no hover to reveal the labels, the\n * first tap expands the bar and runs no action, and the second one acts.\n * Set false to make every tap and click act immediately.\n */\n expandOnHover?: boolean;\n expandOnFocus?: boolean;\n collapseDelay?: number;\n className?: string;\n classNames?: ExpandableActionBarClassNames;\n renderItem?: (\n item: ExpandableActionBarItem,\n state: { expanded: boolean; active: boolean },\n ) => ReactNode;\n}\n\nconst ITEM_TRANSITION: Transition = {\n type: \"spring\",\n stiffness: 460,\n damping: 34,\n mass: 0.62,\n};\n\nconst LABEL_TRANSITION: Transition = {\n type: \"spring\",\n stiffness: 380,\n damping: 32,\n mass: 0.7,\n};\n\nconst SIZE_CLASS: Record<ExpandableActionBarSize, string> = {\n sm: \"min-h-9 gap-1 p-1 text-xs\",\n md: \"min-h-11 gap-1.5 p-1.5 text-sm\",\n};\n\nconst ITEM_SIZE_CLASS: Record<ExpandableActionBarSize, string> = {\n sm: \"h-7 min-w-7 px-1.5\",\n md: \"h-8 min-w-8 px-2\",\n};\n\nconst ICON_SIZE_CLASS: Record<ExpandableActionBarSize, string> = {\n sm: \"h-3.5 w-3.5\",\n md: \"h-4 w-4\",\n};\n\nfunction useControllableExpanded({\n expanded,\n defaultExpanded,\n onExpandedChange,\n}: {\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n}) {\n const [internalExpanded, setInternalExpanded] = useState(defaultExpanded ?? false);\n const isControlled = expanded !== undefined;\n const value = expanded ?? internalExpanded;\n\n const setValue = useCallback(\n (next: boolean) => {\n if (!isControlled) setInternalExpanded(next);\n onExpandedChange?.(next);\n },\n [isControlled, onExpandedChange],\n );\n\n return [value, setValue] as const;\n}\n\nexport function ExpandableActionBar({\n items,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n activeId,\n onAction,\n size = \"md\",\n expandOnHover = true,\n expandOnFocus = true,\n collapseDelay = 90,\n className,\n classNames,\n renderItem,\n}: ExpandableActionBarProps) {\n const reduce = useReducedMotion();\n const layoutId = useId();\n const [isExpanded, setIsExpanded] = useControllableExpanded({\n expanded,\n defaultExpanded,\n onExpandedChange,\n });\n const [hoveredId, setHoveredId] = useState<string | null>(null);\n // Set by the tap that expands the bar, and the reason the outside-tap\n // dismisser exists at all — a hovering pointer has its own way out.\n const [tapExpanded, setTapExpanded] = useState(false);\n const collapseTimer = useRef<number | null>(null);\n const trackRef = useRef<HTMLDivElement | null>(null);\n // What the last gesture on an action was, and whether the bar was already\n // expanded when it started. A click reports neither.\n const tap = useTapGesture<boolean>();\n const hover = useHoverGesture();\n\n const clearCollapseTimer = useCallback(() => {\n if (collapseTimer.current) window.clearTimeout(collapseTimer.current);\n collapseTimer.current = null;\n }, []);\n\n const open = useCallback(() => {\n clearCollapseTimer();\n setIsExpanded(true);\n }, [clearCollapseTimer, setIsExpanded]);\n\n const close = useCallback(() => {\n clearCollapseTimer();\n const timer = window.setTimeout(() => {\n setIsExpanded(false);\n setHoveredId(null);\n setTapExpanded(false);\n }, collapseDelay);\n collapseTimer.current = timer;\n }, [clearCollapseTimer, collapseDelay, setIsExpanded]);\n\n useEffect(() => clearCollapseTimer, [clearCollapseTimer]);\n\n // A collapse from outside takes the labels with it, so the arm the tap that\n // expanded the bar left behind has to go too — otherwise the next tap runs\n // an action whose label nobody can read. Only on the way down from expanded:\n // a controlled bar that declined to expand at all keeps its arm, which is\n // what lets its second tap act.\n const wasExpanded = useRef(isExpanded);\n useEffect(() => {\n if (wasExpanded.current && !isExpanded) setTapExpanded(false);\n wasExpanded.current = isExpanded;\n }, [isExpanded]);\n\n // A finger never hovers and Safari does not focus a button on tap, so a bar a\n // tap expanded would have nothing to close it. The tap that lands elsewhere\n // stands in for the pointer leaving — and it is consumed rather than passed\n // through, because the labelled bar is exactly the kind of surface people\n // dismiss by tapping just past it, over whatever control is there.\n useDismiss(tapExpanded && isExpanded, close, trackRef, {\n behavior: \"consume\",\n });\n\n const onRootPointerEnter = (event: PointerEvent<HTMLDivElement>) => {\n // The gesture is told about every enter, `expandOnHover` or not: it is\n // what the matching leave is read against.\n if (hover.enter(event) && expandOnHover) open();\n };\n\n const onRootPointerLeave = (event: PointerEvent<HTMLDivElement>) => {\n if (!hover.leave(event)) return;\n setHoveredId(null);\n if (expandOnHover) close();\n };\n\n const onRootFocus = () => {\n if (expandOnFocus) open();\n };\n\n const onRootBlur = (event: FocusEvent<HTMLDivElement>) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node) && expandOnFocus) {\n close();\n }\n };\n\n const activeItemId = activeId ?? items.find((item) => item.active)?.id;\n const highlightId = hoveredId ?? activeItemId;\n\n return (\n <LayoutGroup id={layoutId}>\n <motion.div\n layout=\"size\"\n // Pointer events, not the mouse pair: a tap fires compatibility\n // mouseenter/mouseleave that carry no pointerType, and the bar growing\n // under a stationary finger fired the leave before the click ever\n // landed — so one tap expanded, collapsed and ran nothing.\n onPointerEnter={onRootPointerEnter}\n onPointerLeave={onRootPointerLeave}\n onFocus={onRootFocus}\n onBlur={onRootBlur}\n transition={ITEM_TRANSITION}\n className={cn(\"inline-flex max-w-full\", classNames?.root, className)}\n >\n <motion.div\n ref={trackRef}\n layout=\"size\"\n className={cn(\n // Labelled actions can outgrow the space the bar sits in — the pill\n // stays inside it and scrolls its rail rather than running off the\n // edge, where the last action is unreachable.\n \"scrollbar-hide relative inline-flex max-w-full items-center overflow-x-auto overflow-y-hidden rounded-full border border-border bg-card/90 shadow-2xl backdrop-blur-xl\",\n SIZE_CLASS[size],\n classNames?.track,\n )}\n transition={ITEM_TRANSITION}\n >\n {items.map((item) => {\n const isActive = item.active || activeId === item.id;\n const isHighlighted = highlightId === item.id;\n\n return (\n <motion.button\n key={item.id}\n layout=\"position\"\n type=\"button\"\n disabled={item.disabled}\n title={typeof item.label === \"string\" ? item.label : undefined}\n onPointerEnter={(event: PointerEvent<HTMLButtonElement>) => {\n if (!hover.enter(event)) return;\n clearCollapseTimer();\n setHoveredId(item.id);\n }}\n onPointerDown={(event: PointerEvent<HTMLButtonElement>) => {\n tap.start(event, isExpanded);\n }}\n // A gesture the platform takes away sends no click, and a key\n // press starts an activation that never had a pointer behind\n // it: either one would otherwise leave the finger in place for\n // the next click to spend.\n onPointerCancel={tap.drop}\n onKeyDown={tap.drop}\n onClick={(event: MouseEvent<HTMLButtonElement>) => {\n event.currentTarget.blur();\n const gesture = tap.take();\n // Nothing reveals the labels to a finger, so the first tap\n // expands the bar and the next one runs the action. The bar\n // state is read from the gesture's start: a browser that\n // focuses the button on contact expands it mid-tap, and that\n // first tap would otherwise fire the action it was meant to\n // reveal. `tapExpanded` arms the second tap, so a controlled\n // bar that declines to expand still runs the action rather\n // than swallowing every tap.\n const firstTap =\n gesture !== null &&\n gesture.pointerType !== \"mouse\" &&\n !gesture.state &&\n !tapExpanded;\n if (firstTap && expandOnHover) {\n setTapExpanded(true);\n open();\n setHoveredId(item.id);\n return;\n }\n item.onClick?.();\n onAction?.(item);\n }}\n whileTap={reduce || item.disabled ? undefined : { scale: 0.96 }}\n transition={ITEM_TRANSITION}\n className={cn(\n \"relative isolate inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full font-medium text-muted-foreground outline-none transition-[color,background-color] duration-150 ease-out\",\n \"focus-visible:text-foreground disabled:pointer-events-none disabled:opacity-40\",\n isHighlighted && \"text-foreground\",\n ITEM_SIZE_CLASS[size],\n classNames?.item,\n isActive && classNames?.activeItem,\n )}\n >\n {isHighlighted ? (\n <motion.span\n layoutId=\"action-bar-highlight\"\n className=\"absolute inset-0 -z-10 rounded-full bg-muted/80\"\n transition={ITEM_TRANSITION}\n />\n ) : null}\n\n {renderItem ? (\n renderItem(item, { expanded: isExpanded, active: isActive })\n ) : (\n <>\n <span\n className={cn(\n \"inline-flex shrink-0 items-center justify-center\",\n ICON_SIZE_CLASS[size],\n classNames?.icon,\n )}\n >\n {item.icon}\n </span>\n\n <motion.span\n aria-hidden={!isExpanded}\n animate={\n reduce\n ? {\n width: isExpanded ? \"auto\" : 0,\n opacity: isExpanded ? 1 : 0,\n marginLeft: isExpanded ? 8 : 0,\n x: 0,\n filter: \"blur(0px)\",\n }\n : {\n width: isExpanded ? \"auto\" : 0,\n opacity: isExpanded ? 1 : 0,\n x: isExpanded ? 0 : -4,\n marginLeft: isExpanded ? 8 : 0,\n filter: isExpanded ? \"blur(0px)\" : \"blur(3px)\",\n }\n }\n transition={reduce ? { duration: 0 } : LABEL_TRANSITION}\n className={cn(\n \"inline-block overflow-hidden whitespace-nowrap\",\n classNames?.label,\n )}\n >\n {item.label}\n </motion.span>\n\n {item.shortcut ? (\n <motion.span\n aria-hidden={!isExpanded}\n animate={{\n width: isExpanded ? \"auto\" : 0,\n opacity: isExpanded ? 1 : 0,\n marginLeft: isExpanded ? 4 : 0,\n }}\n transition={LABEL_TRANSITION}\n className={cn(\n \"hidden overflow-hidden whitespace-nowrap text-[10px] text-muted-foreground sm:inline-block\",\n classNames?.shortcut,\n )}\n >\n {item.shortcut}\n </motion.span>\n ) : null}\n\n {item.badge ? (\n <span\n className={cn(\n \"ml-0.5 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-destructive px-1 text-[10px] text-primary-foreground leading-none\",\n !isExpanded && \"absolute top-0.5 right-0.5\",\n classNames?.badge,\n )}\n >\n {item.badge}\n </span>\n ) : null}\n </>\n )}\n </motion.button>\n );\n })}\n </motion.div>\n </motion.div>\n </LayoutGroup>\n );\n}\n\nexport function useExpandableActionBar(items: ExpandableActionBarItem[]) {\n const [expanded, setExpanded] = useState(false);\n const [activeId, setActiveId] = useState(items[0]?.id);\n\n const activeItem = useMemo(() => items.find((item) => item.id === activeId), [activeId, items]);\n\n return useMemo(\n () => ({ expanded, setExpanded, activeId, setActiveId, activeItem }),\n [activeId, activeItem, expanded],\n );\n}\n"],"mappings":";;;;;;;;;AAsEA,MAAM,kBAA8B;CAClC,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,MAAM,mBAA+B;CACnC,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,MAAM,aAAsD;CAC1D,IAAI;CACJ,IAAI;AACN;AAEA,MAAM,kBAA2D;CAC/D,IAAI;CACJ,IAAI;AACN;AAEA,MAAM,kBAA2D;CAC/D,IAAI;CACJ,IAAI;AACN;AAEA,SAAS,wBAAwB,EAC/B,UACA,iBACA,oBAKC;CACD,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,mBAAmB,KAAK;CACjF,MAAM,eAAe,aAAa,KAAA;CAWlC,OAAO,CAVO,YAAY,kBAET,aACd,SAAkB;EACjB,IAAI,CAAC,cAAc,oBAAoB,IAAI;EAC3C,mBAAmB,IAAI;CACzB,GACA,CAAC,cAAc,gBAAgB,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;QACE,WAAW,GACT,gJACA,CAAC,cAAc,8BACf,YAAY,KACd;QAEC,UAAA,KAAK;OACF,CAAA,IACJ;MACJ,EAAA,CAAA,CAES;KAxIR,GAAA,KAAK,EAwIG;IAEnB,CAAC;GACS,CAAA;EACF,CAAA;CACD,CAAA;AAEjB;AAEA,SAAgB,uBAAuB,OAAkC;CACvE,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAC9C,MAAM,CAAC,UAAU,eAAe,SAAS,MAAM,EAAE,EAAE,EAAE;CAErD,MAAM,aAAa,cAAc,MAAM,MAAM,SAAS,KAAK,OAAO,QAAQ,GAAG,CAAC,UAAU,KAAK,CAAC;CAE9F,OAAO,eACE;EAAE;EAAU;EAAa;EAAU;EAAa;CAAW,IAClE;EAAC;EAAU;EAAY;CAAQ,CACjC;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"morphing-modal.js","names":[],"sources":["../../../src/components/motion/morphing-modal.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useEffect } from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_PANEL } from \"../../lib/ease\";\nimport { PresenceGate } from \"../../lib/presence-gate\";\n\nexport interface MorphingModalProps {\n /** Which view is currently shown. `null` closes the modal. */\n viewId: string | null;\n onClose: () => void;\n children: ReactNode;\n /** \"bottom\" anchors to the viewport bottom (mobile-like). \"center\" centers vertically. */\n placement?: \"bottom\" | \"center\";\n className?: string;\n}\n\nexport function MorphingModal({\n viewId,\n onClose,\n children,\n placement = \"bottom\",\n className,\n}: MorphingModalProps) {\n const open = viewId !== null;\n const reduce = useReducedMotion();\n const enterY = reduce ? 0 : placement === \"bottom\" ? 40 : 20;\n const enterScale = reduce ? 1 : 0.97;\n\n useEffect(() => {\n if (!open) return;\n const prev = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n return () => {\n document.body.style.overflow = prev;\n };\n }, [open]);\n\n // Mounted only while open, and while open the chrome is two fixed siblings\n // rather than one wrapper: the backdrop spans the viewport edges but carries\n // the scrim colour, and the layer positioning the panel sits inset off every\n // edge (`inset-4`, with the bottom placement's `pb-4` on top of it). Both hang\n // off `PresenceGate`, so interaction releases in the same commit that starts\n // the exit rather than when it ends — `open` is already false for those\n return (\n <AnimatePresence initial={false}>\n {open ? (\n <PresenceGate key=\"backdrop\">\n {({ gate }) => (\n <motion.button\n type=\"button\"\n aria-label=\"Close modal\"\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n transition={{ duration: 0.2, ease: EASE_OUT }}\n {...gate}\n onClick={onClose}\n className=\"pointer-events-auto fixed inset-0 z-80 bg-background/5 [-webkit-backdrop-filter:blur(14px)_saturate(140%)] [backdrop-filter:blur(14px)_saturate(140%)]\"\n />\n )}\n </PresenceGate>\n ) : null}\n\n {open ? (\n <PresenceGate key=\"panel-layer\">\n {({ isPresent, gate }) => (\n // The layer itself never takes pointer events, so it carries\n // `inert` alone rather than the gate's pointer-events value.\n <div\n inert={!isPresent}\n className={cn(\n \"pointer-events-none fixed inset-4 z-80 flex justify-center\",\n placement === \"bottom\" ? \"items-end pb-4\" : \"items-center\",\n )}\n >\n <motion.div\n key=\"panel\"\n layout\n initial={{ opacity: 0, y: enterY, scale: enterScale }}\n animate={{ opacity: 1, y: 0, scale: 1 }}\n exit={{\n opacity: 0,\n y: enterY,\n scale: reduce ? 1 : 0.98,\n transition: { duration: 0.18, ease: EASE_OUT },\n }}\n transition={SPRING_PANEL}\n {...gate}\n className={cn(\n \"pointer-events-auto relative w-full max-w-sm overflow-hidden rounded-3xl border border-border bg-background shadow-2xl will-change-transform\",\n className,\n )}\n >\n <motion.div layout=\"position\" className=\"p-5\">\n <AnimatePresence mode=\"popLayout\" initial={false}>\n <motion.div\n key={viewId}\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: 8, filter: \"blur(4px)\" }}\n animate={\n reduce\n ? {\n opacity: 1,\n transition: {\n duration: 0.18,\n ease: EASE_OUT,\n },\n }\n : {\n opacity: 1,\n y: 0,\n filter: \"blur(0px)\",\n transition: {\n duration: 0.24,\n ease: EASE_OUT,\n },\n }\n }\n exit={\n reduce\n ? {\n opacity: 0,\n transition: {\n duration: 0.14,\n ease: EASE_OUT,\n },\n }\n : {\n opacity: 0,\n y: -8,\n filter: \"blur(4px)\",\n transition: {\n duration: 0.16,\n ease: EASE_OUT,\n },\n }\n }\n >\n {children}\n </motion.div>\n </AnimatePresence>\n </motion.div>\n </motion.div>\n </div>\n )}\n </PresenceGate>\n ) : null}\n </AnimatePresence>\n );\n}\n"],"mappings":";;;;;;;;AAmBA,SAAgB,cAAc,EAC5B,QACA,SACA,UACA,YAAY,UACZ,aACqB;CACrB,MAAM,OAAO,WAAW;CACxB,MAAM,SAAS,iBAAiB;CAChC,MAAM,SAAS,SAAS,IAAI,cAAc,WAAW,KAAK;CAC1D,MAAM,aAAa,SAAS,IAAI;CAEhC,gBAAgB;EACd,IAAI,CAAC,MAAM;EACX,MAAM,OAAO,SAAS,KAAK,MAAM;EACjC,SAAS,KAAK,MAAM,WAAW;EAC/B,aAAa;GACX,SAAS,KAAK,MAAM,WAAW;EACjC;CACF,GAAG,CAAC,IAAI,CAAC;CAQT,OACE,qBAAC,iBAAD;EAAiB,SAAS;EAA1B,UAAA,CACG,OACC,oBAAC,cAAD,EAAA,WACI,EAAE,WACF,oBAAC,OAAO,QAAR;GACE,MAAK;GACL,cAAW;GACX,SAAS,EAAE,SAAS,EAAE;GACtB,SAAS,EAAE,SAAS,EAAE;GACtB,MAAM,EAAE,SAAS,EAAE;GACnB,YAAY;IAAE,UAAU;IAAK,MAAM;GAAS;GAC5C,GAAI;GACJ,SAAS;GACT,WAAU;EACX,CAAA,EAES,GAdI,UAcJ,IACZ,MAEH,OACC,oBAAC,cAAD,EAAA,WACI,EAAE,WAAW,WAGb,oBAAC,OAAD;GACE,OAAO,CAAC;GACR,WAAW,GACT,8DACA,cAAc,WAAW,mBAAmB,cAC9C;GAEA,UAAA,oBAAC,OAAO,KAAR;IAEE,QAAA;IACA,SAAS;KAAE,SAAS;KAAG,GAAG;KAAQ,OAAO;IAAW;IACpD,SAAS;KAAE,SAAS;KAAG,GAAG;KAAG,OAAO;IAAE;IACtC,MAAM;KACJ,SAAS;KACT,GAAG;KACH,OAAO,SAAS,IAAI;KACpB,YAAY;MAAE,UAAU;MAAM,MAAM;KAAS;IAC/C;IACA,YAAY;IACZ,GAAI;IACJ,WAAW,GACT,gJACA,SACF;IAEA,UAAA,oBAAC,OAAO,KAAR;KAAY,QAAO;KAAW,WAAU;KACtC,UAAA,oBAAC,iBAAD;MAAiB,MAAK;MAAY,SAAS;MACzC,UAAA,oBAAC,OAAO,KAAR;OAEE,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI;QAAE,SAAS;QAAG,GAAG;QAAG,QAAQ;OAAY;OAC3E,SACE,SACI;QACE,SAAS;QACT,YAAY;SACV,UAAU;SACV,MAAM;QACR;OACF,IACA;QACE,SAAS;QACT,GAAG;QACH,QAAQ;QACR,YAAY;SACV,UAAU;SACV,MAAM;QACR;OACF;OAEN,MACE,SACI;QACE,SAAS;QACT,YAAY;SACV,UAAU;SACV,MAAM;QACR;OACF,IACA;QACE,SAAS;QACT,GAAG;QACH,QAAQ;QACR,YAAY;SACV,UAAU;SACV,MAAM;QACR;OACF;OAGL;MACS,GA1CL,MA0CK;KACG,CAAA;IACP,CAAA;GACF,GAjEN,OAiEM;EACT,CAAA,EAEK,GAhFI,aAgFJ,IACZ,IACW;;AAErB"}
1
+ {"version":3,"file":"morphing-modal.js","names":[],"sources":["../../../src/components/motion/morphing-modal.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useEffect } from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_PANEL } from \"../../lib/ease\";\nimport { PresenceGate } from \"../../lib/presence-gate\";\n\nexport interface MorphingModalProps {\n /** Which view is currently shown. `null` closes the modal. */\n viewId: string | null;\n onClose: () => void;\n children: ReactNode;\n /** \"bottom\" anchors to the viewport bottom (mobile-like). \"center\" centers vertically. */\n placement?: \"bottom\" | \"center\";\n className?: string;\n}\n\nexport function MorphingModal({\n viewId,\n onClose,\n children,\n placement = \"bottom\",\n className,\n}: MorphingModalProps) {\n const open = viewId !== null;\n const reduce = useReducedMotion();\n const enterY = reduce ? 0 : placement === \"bottom\" ? 40 : 20;\n const enterScale = reduce ? 1 : 0.97;\n\n useEffect(() => {\n if (!open) return;\n const prev = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n return () => {\n document.body.style.overflow = prev;\n };\n }, [open]);\n\n // Mounted only while open, and while open the chrome is two fixed siblings\n // rather than one wrapper: the backdrop spans the viewport edges but carries\n // the scrim colour, and the layer positioning the panel sits inset off every\n // edge (`inset-4`, with the bottom placement's `pb-4` on top of it). Both hang\n // off `PresenceGate`, so interaction releases in the same commit that starts\n // the exit rather than when it ends — `open` is already false for those\n // frames.\n return (\n <AnimatePresence initial={false}>\n {open ? (\n <PresenceGate key=\"backdrop\">\n {({ gate }) => (\n <motion.button\n type=\"button\"\n aria-label=\"Close modal\"\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n transition={{ duration: 0.2, ease: EASE_OUT }}\n {...gate}\n onClick={onClose}\n className=\"pointer-events-auto fixed inset-0 z-80 bg-background/5 [-webkit-backdrop-filter:blur(14px)_saturate(140%)] [backdrop-filter:blur(14px)_saturate(140%)]\"\n />\n )}\n </PresenceGate>\n ) : null}\n\n {open ? (\n <PresenceGate key=\"panel-layer\">\n {({ isPresent, gate }) => (\n // The layer itself never takes pointer events, so it carries\n // `inert` alone rather than the gate's pointer-events value.\n <div\n inert={!isPresent}\n className={cn(\n \"pointer-events-none fixed inset-4 z-80 flex justify-center\",\n placement === \"bottom\" ? \"items-end pb-4\" : \"items-center\",\n )}\n >\n <motion.div\n key=\"panel\"\n layout\n initial={{ opacity: 0, y: enterY, scale: enterScale }}\n animate={{ opacity: 1, y: 0, scale: 1 }}\n exit={{\n opacity: 0,\n y: enterY,\n scale: reduce ? 1 : 0.98,\n transition: { duration: 0.18, ease: EASE_OUT },\n }}\n transition={SPRING_PANEL}\n {...gate}\n className={cn(\n \"pointer-events-auto relative w-full max-w-sm overflow-hidden rounded-3xl border border-border bg-background shadow-2xl will-change-transform\",\n className,\n )}\n >\n <motion.div layout=\"position\" className=\"p-5\">\n <AnimatePresence mode=\"popLayout\" initial={false}>\n <motion.div\n key={viewId}\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: 8, filter: \"blur(4px)\" }}\n animate={\n reduce\n ? {\n opacity: 1,\n transition: {\n duration: 0.18,\n ease: EASE_OUT,\n },\n }\n : {\n opacity: 1,\n y: 0,\n filter: \"blur(0px)\",\n transition: {\n duration: 0.24,\n ease: EASE_OUT,\n },\n }\n }\n exit={\n reduce\n ? {\n opacity: 0,\n transition: {\n duration: 0.14,\n ease: EASE_OUT,\n },\n }\n : {\n opacity: 0,\n y: -8,\n filter: \"blur(4px)\",\n transition: {\n duration: 0.16,\n ease: EASE_OUT,\n },\n }\n }\n >\n {children}\n </motion.div>\n </AnimatePresence>\n </motion.div>\n </motion.div>\n </div>\n )}\n </PresenceGate>\n ) : null}\n </AnimatePresence>\n );\n}\n"],"mappings":";;;;;;;;AAmBA,SAAgB,cAAc,EAC5B,QACA,SACA,UACA,YAAY,UACZ,aACqB;CACrB,MAAM,OAAO,WAAW;CACxB,MAAM,SAAS,iBAAiB;CAChC,MAAM,SAAS,SAAS,IAAI,cAAc,WAAW,KAAK;CAC1D,MAAM,aAAa,SAAS,IAAI;CAEhC,gBAAgB;EACd,IAAI,CAAC,MAAM;EACX,MAAM,OAAO,SAAS,KAAK,MAAM;EACjC,SAAS,KAAK,MAAM,WAAW;EAC/B,aAAa;GACX,SAAS,KAAK,MAAM,WAAW;EACjC;CACF,GAAG,CAAC,IAAI,CAAC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