@kumix/ui 0.3.5 → 0.3.7

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 (163) hide show
  1. package/dist/components/agents/ai-sidebar.d.ts +17 -1
  2. package/dist/components/agents/ai-sidebar.d.ts.map +1 -1
  3. package/dist/components/agents/ai-sidebar.js +90 -14
  4. package/dist/components/agents/ai-sidebar.js.map +1 -1
  5. package/dist/components/agents/chat-app.d.ts +10 -5
  6. package/dist/components/agents/chat-app.d.ts.map +1 -1
  7. package/dist/components/agents/chat-app.js +54 -5
  8. package/dist/components/agents/chat-app.js.map +1 -1
  9. package/dist/components/agents/citations.d.ts.map +1 -1
  10. package/dist/components/agents/citations.js +5 -6
  11. package/dist/components/agents/citations.js.map +1 -1
  12. package/dist/components/agents/tool-approval.d.ts.map +1 -1
  13. package/dist/components/agents/tool-approval.js +1 -1
  14. package/dist/components/agents/tool-approval.js.map +1 -1
  15. package/dist/components/motion/action-swap.d.ts.map +1 -1
  16. package/dist/components/motion/action-swap.js +11 -16
  17. package/dist/components/motion/action-swap.js.map +1 -1
  18. package/dist/components/motion/animated-sidebar.js +1 -0
  19. package/dist/components/motion/animated-sidebar.js.map +1 -1
  20. package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
  21. package/dist/components/motion/availability-scheduler/day-row.d.ts +5 -2
  22. package/dist/components/motion/availability-scheduler/day-row.d.ts.map +1 -1
  23. package/dist/components/motion/availability-scheduler/day-row.js +18 -8
  24. package/dist/components/motion/availability-scheduler/day-row.js.map +1 -1
  25. package/dist/components/motion/availability-scheduler/index.d.ts.map +1 -1
  26. package/dist/components/motion/availability-scheduler/index.js +27 -5
  27. package/dist/components/motion/availability-scheduler/index.js.map +1 -1
  28. package/dist/components/motion/availability-scheduler/time-select.d.ts +3 -1
  29. package/dist/components/motion/availability-scheduler/time-select.d.ts.map +1 -1
  30. package/dist/components/motion/availability-scheduler/time-select.js +3 -1
  31. package/dist/components/motion/availability-scheduler/time-select.js.map +1 -1
  32. package/dist/components/motion/bottom-sheet.d.ts.map +1 -1
  33. package/dist/components/motion/bottom-sheet.js +26 -7
  34. package/dist/components/motion/bottom-sheet.js.map +1 -1
  35. package/dist/components/motion/combobox/list.js +2 -2
  36. package/dist/components/motion/combobox/list.js.map +1 -1
  37. package/dist/components/motion/command-palette.d.ts.map +1 -1
  38. package/dist/components/motion/command-palette.js +3 -1
  39. package/dist/components/motion/command-palette.js.map +1 -1
  40. package/dist/components/motion/context-menu.d.ts.map +1 -1
  41. package/dist/components/motion/context-menu.js +16 -6
  42. package/dist/components/motion/context-menu.js.map +1 -1
  43. package/dist/components/motion/cylinder-carousel.d.ts.map +1 -1
  44. package/dist/components/motion/cylinder-carousel.js +4 -3
  45. package/dist/components/motion/cylinder-carousel.js.map +1 -1
  46. package/dist/components/motion/expandable-action-bar.d.ts +6 -0
  47. package/dist/components/motion/expandable-action-bar.d.ts.map +1 -1
  48. package/dist/components/motion/expandable-action-bar.js +38 -9
  49. package/dist/components/motion/expandable-action-bar.js.map +1 -1
  50. package/dist/components/motion/hold-action-button.d.ts +1 -1
  51. package/dist/components/motion/hold-action-button.d.ts.map +1 -1
  52. package/dist/components/motion/hold-action-button.js +64 -50
  53. package/dist/components/motion/hold-action-button.js.map +1 -1
  54. package/dist/components/motion/morphing-tabs.d.ts.map +1 -1
  55. package/dist/components/motion/morphing-tabs.js +59 -18
  56. package/dist/components/motion/morphing-tabs.js.map +1 -1
  57. package/dist/components/motion/notification-stack.d.ts.map +1 -1
  58. package/dist/components/motion/notification-stack.js +28 -11
  59. package/dist/components/motion/notification-stack.js.map +1 -1
  60. package/dist/components/motion/popover-morph.d.ts.map +1 -1
  61. package/dist/components/motion/popover-morph.js +26 -11
  62. package/dist/components/motion/popover-morph.js.map +1 -1
  63. package/dist/components/motion/popover.d.ts.map +1 -1
  64. package/dist/components/motion/popover.js +39 -28
  65. package/dist/components/motion/popover.js.map +1 -1
  66. package/dist/components/motion/preview-rail.d.ts.map +1 -1
  67. package/dist/components/motion/preview-rail.js +42 -13
  68. package/dist/components/motion/preview-rail.js.map +1 -1
  69. package/dist/components/motion/project-folder.d.ts +27 -0
  70. package/dist/components/motion/project-folder.d.ts.map +1 -0
  71. package/dist/components/motion/project-folder.js +310 -0
  72. package/dist/components/motion/project-folder.js.map +1 -0
  73. package/dist/components/motion/pull-to-refresh.d.ts.map +1 -1
  74. package/dist/components/motion/pull-to-refresh.js +8 -7
  75. package/dist/components/motion/pull-to-refresh.js.map +1 -1
  76. package/dist/components/motion/range-slider-bubble.d.ts.map +1 -1
  77. package/dist/components/motion/range-slider-bubble.js +2 -1
  78. package/dist/components/motion/range-slider-bubble.js.map +1 -1
  79. package/dist/components/motion/range-slider-fluid.d.ts.map +1 -1
  80. package/dist/components/motion/range-slider-fluid.js +2 -1
  81. package/dist/components/motion/range-slider-fluid.js.map +1 -1
  82. package/dist/components/motion/range-slider-ruler.d.ts.map +1 -1
  83. package/dist/components/motion/range-slider-ruler.js +2 -1
  84. package/dist/components/motion/range-slider-ruler.js.map +1 -1
  85. package/dist/components/motion/range-slider-wave.d.ts.map +1 -1
  86. package/dist/components/motion/range-slider-wave.js +2 -1
  87. package/dist/components/motion/range-slider-wave.js.map +1 -1
  88. package/dist/components/motion/range-slider.d.ts.map +1 -1
  89. package/dist/components/motion/range-slider.js +2 -1
  90. package/dist/components/motion/range-slider.js.map +1 -1
  91. package/dist/components/motion/select.d.ts +15 -1
  92. package/dist/components/motion/select.d.ts.map +1 -1
  93. package/dist/components/motion/select.js +15 -4
  94. package/dist/components/motion/select.js.map +1 -1
  95. package/dist/components/motion/slide-action-button.d.ts.map +1 -1
  96. package/dist/components/motion/slide-action-button.js +3 -2
  97. package/dist/components/motion/slide-action-button.js.map +1 -1
  98. package/dist/components/motion/swipeable-list.d.ts.map +1 -1
  99. package/dist/components/motion/swipeable-list.js +2 -1
  100. package/dist/components/motion/swipeable-list.js.map +1 -1
  101. package/dist/components/motion/table/index.d.ts.map +1 -1
  102. package/dist/components/motion/table/index.js +64 -6
  103. package/dist/components/motion/table/index.js.map +1 -1
  104. package/dist/components/motion/table/table-header.d.ts.map +1 -1
  105. package/dist/components/motion/table/table-header.js +3 -2
  106. package/dist/components/motion/table/table-header.js.map +1 -1
  107. package/dist/components/motion/tabs.d.ts.map +1 -1
  108. package/dist/components/motion/tabs.js +2 -0
  109. package/dist/components/motion/tabs.js.map +1 -1
  110. package/dist/components/motion/text-reveal.d.ts.map +1 -1
  111. package/dist/components/motion/text-reveal.js +72 -48
  112. package/dist/components/motion/text-reveal.js.map +1 -1
  113. package/dist/components/motion/tooltip.d.ts.map +1 -1
  114. package/dist/components/motion/tooltip.js +35 -15
  115. package/dist/components/motion/tooltip.js.map +1 -1
  116. package/dist/components/motion/wheel-picker.d.ts.map +1 -1
  117. package/dist/components/motion/wheel-picker.js +4 -3
  118. package/dist/components/motion/wheel-picker.js.map +1 -1
  119. package/dist/components/reui/alert.d.ts +1 -1
  120. package/dist/components/reui/badge.d.ts +2 -2
  121. package/dist/components/reui/frame.d.ts +2 -2
  122. package/dist/components/reui/icon-tile.d.ts +2 -2
  123. package/dist/components/ui/attachment.d.ts +1 -1
  124. package/dist/components/ui/badge.d.ts +1 -1
  125. package/dist/components/ui/bubble.d.ts +1 -1
  126. package/dist/components/ui/button-group.d.ts +1 -1
  127. package/dist/components/ui/button.d.ts +2 -2
  128. package/dist/components/ui/field.d.ts +1 -1
  129. package/dist/components/ui/item.d.ts +1 -1
  130. package/dist/components/ui/sidebar.d.ts +1 -1
  131. package/dist/components/ui/toggle.d.ts +1 -1
  132. package/dist/{copy-menu-Bk5GP9Gp.js → copy-menu-1FKoMc9o.js} +9 -2
  133. package/dist/copy-menu-1FKoMc9o.js.map +1 -0
  134. package/dist/hooks/use-dismiss.d.ts +34 -0
  135. package/dist/hooks/use-dismiss.d.ts.map +1 -0
  136. package/dist/hooks/use-dismiss.js +78 -0
  137. package/dist/hooks/use-dismiss.js.map +1 -0
  138. package/dist/hooks/use-favicon.d.ts +17 -0
  139. package/dist/hooks/use-favicon.d.ts.map +1 -0
  140. package/dist/hooks/use-favicon.js +35 -0
  141. package/dist/hooks/use-favicon.js.map +1 -0
  142. package/dist/hooks/use-hover-gesture.d.ts +38 -0
  143. package/dist/hooks/use-hover-gesture.d.ts.map +1 -0
  144. package/dist/hooks/use-hover-gesture.js +46 -0
  145. package/dist/hooks/use-hover-gesture.js.map +1 -0
  146. package/dist/hooks/use-slider.d.ts.map +1 -1
  147. package/dist/hooks/use-slider.js +3 -2
  148. package/dist/hooks/use-slider.js.map +1 -1
  149. package/dist/hooks/use-tap-gesture.d.ts +47 -0
  150. package/dist/hooks/use-tap-gesture.d.ts.map +1 -0
  151. package/dist/hooks/use-tap-gesture.js +51 -0
  152. package/dist/hooks/use-tap-gesture.js.map +1 -0
  153. package/dist/hooks/use-touch-capable.d.ts +15 -0
  154. package/dist/hooks/use-touch-capable.d.ts.map +1 -0
  155. package/dist/hooks/use-touch-capable.js +29 -0
  156. package/dist/hooks/use-touch-capable.js.map +1 -0
  157. package/dist/lib/touch.d.ts +66 -0
  158. package/dist/lib/touch.d.ts.map +1 -0
  159. package/dist/lib/touch.js +79 -0
  160. package/dist/lib/touch.js.map +1 -0
  161. package/dist/types-smkWN_7x.d.ts.map +1 -1
  162. package/package.json +3 -3
  163. package/dist/copy-menu-Bk5GP9Gp.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"context-menu.js","names":[],"sources":["../../../src/components/motion/context-menu.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n cloneElement,\n createContext,\n isValidElement,\n type ReactElement,\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n type ReactNode,\n type PointerEvent as ReactPointerEvent,\n type Ref,\n useCallback,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Check } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_LAYOUT, SPRING_PANEL } from \"../../lib/ease\";\n\ntype OpenModality = \"pointer\" | \"keyboard\" | \"touch\";\ntype MenuPoint = { x: number; y: number };\n\nconst VIEWPORT_PADDING = 8;\nconst LONG_PRESS_DELAY = 520;\nconst LONG_PRESS_TOLERANCE = 10;\nconst MORPH_DURATION = 0.3;\n\ntype TriggerElementProps = React.HTMLAttributes<HTMLElement> & {\n ref?: Ref<HTMLElement>;\n};\n\ninterface ContextMenuContextValue {\n open: boolean;\n setOpen: (open: boolean) => void;\n openAt: (point: MenuPoint, modality: OpenModality) => void;\n point: MenuPoint;\n modality: OpenModality;\n invocation: number;\n menuId: string;\n triggerRef: React.MutableRefObject<HTMLElement | null>;\n contentRef: React.MutableRefObject<HTMLDivElement | null>;\n activeId: string | null;\n setActiveId: (id: string | null) => void;\n reduce: boolean;\n}\n\nconst ContextMenuContext = createContext<ContextMenuContextValue | null>(null);\n\nfunction useContextMenuContext(component: string) {\n const context = useContext(ContextMenuContext);\n if (!context) {\n throw new Error(`${component} must be used within <ContextMenu>`);\n }\n return context;\n}\n\nfunction assignRef<T>(ref: Ref<T> | undefined, value: T | null) {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n}\n\nfunction getEnabledItems(container: HTMLElement | null) {\n if (!container) return [];\n return Array.from(\n container.querySelectorAll<HTMLElement>(\n '[data-context-menu-item=\"true\"]:not([data-disabled=\"true\"])',\n ),\n );\n}\n\nfunction clamp(value: number, min: number, max: number) {\n return Math.min(Math.max(value, min), max);\n}\n\nfunction collapsedClip(origin: MenuPoint, size: { width: number; height: number }) {\n const half = 8;\n const top = clamp(origin.y - half, 0, size.height);\n const right = clamp(size.width - origin.x - half, 0, size.width);\n const bottom = clamp(size.height - origin.y - half, 0, size.height);\n const left = clamp(origin.x - half, 0, size.width);\n return `inset(${top}px ${right}px ${bottom}px ${left}px round 10px)`;\n}\n\nexport interface ContextMenuProps {\n children: ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n className?: string;\n}\n\nexport function ContextMenu({\n children,\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n className,\n}: ContextMenuProps) {\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const [point, setPoint] = useState<MenuPoint>({ x: 0, y: 0 });\n const [modality, setModality] = useState<OpenModality>(\"pointer\");\n const [invocation, setInvocation] = useState(0);\n const [activeId, setActiveId] = useState<string | null>(null);\n const controlled = controlledOpen !== undefined;\n const open = controlled ? controlledOpen : internalOpen;\n const triggerRef = useRef<HTMLElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const menuId = useId();\n const reduce = useReducedMotion() ?? false;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!controlled) setInternalOpen(next);\n onOpenChange?.(next);\n if (!next) setActiveId(null);\n },\n [controlled, onOpenChange],\n );\n\n const openAt = useCallback(\n (nextPoint: MenuPoint, nextModality: OpenModality) => {\n setPoint(nextPoint);\n setModality(nextModality);\n setInvocation((current) => current + 1);\n setActiveId(null);\n setOpen(true);\n },\n [setOpen],\n );\n\n useEffect(() => {\n if (!open) return;\n\n const onPointerDown = (event: PointerEvent) => {\n if (!contentRef.current?.contains(event.target as Node)) setOpen(false);\n };\n const onWindowChange = () => setOpen(false);\n\n window.addEventListener(\"pointerdown\", onPointerDown);\n window.addEventListener(\"resize\", onWindowChange);\n window.addEventListener(\"scroll\", onWindowChange);\n return () => {\n window.removeEventListener(\"pointerdown\", onPointerDown);\n window.removeEventListener(\"resize\", onWindowChange);\n window.removeEventListener(\"scroll\", onWindowChange);\n };\n }, [open, setOpen]);\n\n const value = useMemo<ContextMenuContextValue>(\n () => ({\n open,\n setOpen,\n openAt,\n point,\n modality,\n invocation,\n menuId,\n triggerRef,\n contentRef,\n activeId,\n setActiveId,\n reduce,\n }),\n [open, setOpen, openAt, point, modality, invocation, menuId, activeId, reduce],\n );\n\n return (\n <ContextMenuContext.Provider value={value}>\n <div className={cn(\"contents\", className)}>{children}</div>\n </ContextMenuContext.Provider>\n );\n}\n\nexport interface ContextMenuTriggerProps {\n children: ReactElement<TriggerElementProps>;\n disabled?: boolean;\n className?: string;\n}\n\nexport function ContextMenuTrigger({\n children,\n disabled = false,\n className,\n}: ContextMenuTriggerProps) {\n const context = useContextMenuContext(\"ContextMenuTrigger\");\n const longPressTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const touchOrigin = useRef<MenuPoint | null>(null);\n\n const cancelLongPress = useCallback(() => {\n if (longPressTimer.current) {\n clearTimeout(longPressTimer.current);\n longPressTimer.current = null;\n }\n touchOrigin.current = null;\n }, []);\n\n useEffect(() => cancelLongPress, [cancelLongPress]);\n\n if (!isValidElement(children)) {\n throw new Error(\"<ContextMenuTrigger> requires a single React element\");\n }\n\n const childProps = children.props;\n const childRef = children.props.ref;\n\n const onPointerDown = (event: ReactPointerEvent<HTMLElement>) => {\n childProps.onPointerDown?.(event);\n if (event.defaultPrevented || disabled || event.pointerType !== \"touch\") return;\n\n const origin = { x: event.clientX, y: event.clientY };\n touchOrigin.current = origin;\n longPressTimer.current = setTimeout(() => {\n context.openAt(origin, \"touch\");\n longPressTimer.current = null;\n touchOrigin.current = null;\n }, LONG_PRESS_DELAY);\n };\n\n const onPointerMove = (event: ReactPointerEvent<HTMLElement>) => {\n childProps.onPointerMove?.(event);\n const origin = touchOrigin.current;\n if (\n origin &&\n Math.hypot(event.clientX - origin.x, event.clientY - origin.y) > LONG_PRESS_TOLERANCE\n ) {\n cancelLongPress();\n }\n };\n\n const onKeyDown = (event: ReactKeyboardEvent<HTMLElement>) => {\n childProps.onKeyDown?.(event);\n if (event.defaultPrevented || disabled) return;\n if (event.key !== \"ContextMenu\" && !(event.shiftKey && event.key === \"F10\")) return;\n\n event.preventDefault();\n const rect = event.currentTarget.getBoundingClientRect();\n context.openAt(\n { x: rect.left + Math.min(24, rect.width / 2), y: rect.top + rect.height / 2 },\n \"keyboard\",\n );\n };\n\n return cloneElement(children, {\n ref: (node: HTMLElement | null) => {\n context.triggerRef.current = node;\n assignRef(childRef, node);\n },\n \"aria-controls\": context.open ? context.menuId : undefined,\n \"aria-haspopup\": \"menu\",\n \"aria-expanded\": context.open,\n className: cn(childProps.className, className),\n onContextMenu: (event: ReactMouseEvent<HTMLElement>) => {\n childProps.onContextMenu?.(event);\n if (event.defaultPrevented || disabled) return;\n event.preventDefault();\n cancelLongPress();\n context.openAt({ x: event.clientX, y: event.clientY }, \"pointer\");\n },\n onKeyDown,\n onPointerDown,\n onPointerMove,\n onPointerUp: (event: ReactPointerEvent<HTMLElement>) => {\n childProps.onPointerUp?.(event);\n cancelLongPress();\n },\n onPointerCancel: (event: ReactPointerEvent<HTMLElement>) => {\n childProps.onPointerCancel?.(event);\n cancelLongPress();\n },\n });\n}\n\nexport interface ContextMenuContentProps {\n children: ReactNode;\n className?: string;\n ariaLabel?: string;\n}\n\nexport function ContextMenuContent({\n children,\n className,\n ariaLabel = \"Context menu\",\n}: ContextMenuContentProps) {\n const context = useContextMenuContext(\"ContextMenuContent\");\n const [mounted, setMounted] = useState(false);\n const [position, setPosition] = useState<MenuPoint>(context.point);\n const [origin, setOrigin] = useState<MenuPoint>({ x: 0, y: 0 });\n const [size, setSize] = useState({ width: 0, height: 0 });\n const [morphReady, setMorphReady] = useState(false);\n const typeahead = useRef(\"\");\n const typeaheadTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => setMounted(true), []);\n\n useLayoutEffect(() => {\n if (!context.open) {\n setMorphReady(false);\n return;\n }\n const content = context.contentRef.current;\n if (!content) return;\n content.dataset.invocation = String(context.invocation);\n\n const rect = content.getBoundingClientRect();\n const left = Math.max(\n VIEWPORT_PADDING,\n Math.min(\n Math.max(context.point.x, VIEWPORT_PADDING),\n window.innerWidth - rect.width - VIEWPORT_PADDING,\n ),\n );\n const top = Math.max(\n VIEWPORT_PADDING,\n Math.min(\n Math.max(context.point.y, VIEWPORT_PADDING),\n window.innerHeight - rect.height - VIEWPORT_PADDING,\n ),\n );\n\n setPosition({ x: left, y: top });\n setSize({ width: rect.width, height: rect.height });\n setOrigin({\n x: clamp(context.point.x - left, 12, Math.max(12, rect.width - 12)),\n y: clamp(context.point.y - top, 12, Math.max(12, rect.height - 12)),\n });\n setMorphReady(false);\n\n if (context.reduce || context.modality === \"keyboard\") {\n setMorphReady(true);\n return;\n }\n\n // Let the measured collapsed clip paint once before expanding it. Without\n // this preparation frame, the first invocation can batch both states and\n // appear at full size without the morph.\n let openFrame = 0;\n const prepareFrame = requestAnimationFrame(() => {\n openFrame = requestAnimationFrame(() => setMorphReady(true));\n });\n return () => {\n cancelAnimationFrame(prepareFrame);\n cancelAnimationFrame(openFrame);\n };\n }, [\n context.open,\n context.point,\n context.contentRef,\n context.invocation,\n context.modality,\n context.reduce,\n ]);\n\n useEffect(() => {\n if (!context.open) return;\n const frame = requestAnimationFrame(() => {\n const first = getEnabledItems(context.contentRef.current)[0];\n first?.focus({ preventScroll: true });\n });\n return () => cancelAnimationFrame(frame);\n }, [context.open, context.contentRef]);\n\n useEffect(\n () => () => {\n if (typeaheadTimer.current) clearTimeout(typeaheadTimer.current);\n },\n [],\n );\n\n const moveFocus = (direction: 1 | -1) => {\n const items = getEnabledItems(context.contentRef.current);\n if (items.length === 0) return;\n const current = items.indexOf(document.activeElement as HTMLElement);\n const next = current < 0 ? 0 : (current + direction + items.length) % items.length;\n items[next]?.focus();\n };\n\n const onKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n context.setOpen(false);\n context.triggerRef.current?.focus();\n return;\n }\n if (event.key === \"Tab\") {\n context.setOpen(false);\n return;\n }\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n moveFocus(event.key === \"ArrowDown\" ? 1 : -1);\n return;\n }\n if (event.key === \"Home\" || event.key === \"End\") {\n event.preventDefault();\n const items = getEnabledItems(context.contentRef.current);\n items[event.key === \"Home\" ? 0 : items.length - 1]?.focus();\n return;\n }\n if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {\n typeahead.current += event.key.toLocaleLowerCase();\n if (typeaheadTimer.current) clearTimeout(typeaheadTimer.current);\n typeaheadTimer.current = setTimeout(() => {\n typeahead.current = \"\";\n }, 500);\n const match = getEnabledItems(context.contentRef.current).find((item) =>\n (item.dataset.label ?? item.textContent ?? \"\")\n .trim()\n .toLocaleLowerCase()\n .startsWith(typeahead.current),\n );\n match?.focus();\n }\n };\n\n if (!mounted) return null;\n\n const visualOpen = context.open && morphReady;\n const clipHidden = collapsedClip(origin, size);\n const clipShown = \"inset(0px 0px 0px 0px round 12px)\";\n\n return createPortal(\n <div\n data-context-menu-portal=\"\"\n aria-hidden={!context.open}\n inert={!context.open}\n style={{ left: position.x, top: position.y }}\n className={cn(\n \"filter-[drop-shadow(0_18px_28px_rgba(0,0,0,0.2))] fixed z-100\",\n context.open ? \"pointer-events-auto\" : \"pointer-events-none\",\n )}\n >\n <motion.div\n ref={context.contentRef}\n id={context.menuId}\n role=\"menu\"\n aria-label={ariaLabel}\n data-morph-ready={morphReady ? \"true\" : \"false\"}\n tabIndex={-1}\n initial={false}\n animate={{\n opacity: visualOpen ? 1 : 0,\n clipPath:\n context.reduce || context.modality === \"keyboard\" || visualOpen\n ? clipShown\n : clipHidden,\n }}\n transition={\n context.modality === \"keyboard\"\n ? { duration: 0 }\n : context.reduce\n ? { duration: 0.1, ease: EASE_OUT }\n : {\n clipPath: {\n duration: MORPH_DURATION,\n ease: EASE_OUT,\n },\n opacity: {\n duration: MORPH_DURATION,\n ease: EASE_OUT,\n },\n }\n }\n onKeyDown={onKeyDown}\n onContextMenu={(event) => event.preventDefault()}\n className={cn(\n \"min-w-56 overflow-hidden rounded-xl border border-border bg-card p-1.5 text-foreground outline-none\",\n className,\n )}\n >\n {children}\n </motion.div>\n </div>,\n document.body,\n );\n}\n\ntype ContextMenuItemTone = \"default\" | \"destructive\";\n\nexport interface ContextMenuItemProps {\n children: ReactNode;\n onSelect?: () => void;\n disabled?: boolean;\n closeOnSelect?: boolean;\n tone?: ContextMenuItemTone;\n inset?: boolean;\n className?: string;\n textValue?: string;\n}\n\nfunction ContextMenuItemBase({\n children,\n onSelect,\n disabled = false,\n closeOnSelect = true,\n tone = \"default\",\n inset = false,\n className,\n textValue,\n role = \"menuitem\",\n ariaChecked,\n}: ContextMenuItemProps & {\n role?: \"menuitem\" | \"menuitemcheckbox\" | \"menuitemradio\";\n ariaChecked?: boolean;\n}) {\n const context = useContextMenuContext(\"ContextMenuItem\");\n const id = useId();\n const active = context.activeId === id;\n const checkedProps = role === \"menuitem\" ? {} : { \"aria-checked\": ariaChecked };\n\n return (\n <button\n type=\"button\"\n id={id}\n role={role}\n {...checkedProps}\n disabled={disabled}\n data-context-menu-item=\"true\"\n data-disabled={disabled ? \"true\" : undefined}\n data-label={textValue}\n tabIndex={-1}\n onFocus={() => context.setActiveId(id)}\n onPointerMove={(event) => {\n if (!disabled && event.pointerType !== \"touch\") event.currentTarget.focus();\n }}\n onClick={() => {\n if (disabled) return;\n onSelect?.();\n if (closeOnSelect) context.setOpen(false);\n }}\n className={cn(\n \"relative isolate flex w-full select-none items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[13px] outline-none\",\n \"focus-visible:ring-2 focus-visible:ring-foreground/15\",\n \"disabled:pointer-events-none disabled:opacity-40\",\n inset && \"pl-8\",\n tone === \"destructive\" ? \"text-destructive\" : \"text-foreground\",\n className,\n )}\n >\n {active ? (\n <motion.span\n layoutId={`${context.menuId}-active`}\n className={cn(\n \"absolute inset-0 -z-10 rounded-lg\",\n tone === \"destructive\" ? \"bg-destructive/10\" : \"bg-foreground/6.5\",\n )}\n transition={context.reduce ? { duration: 0 } : SPRING_LAYOUT}\n />\n ) : null}\n {children}\n </button>\n );\n}\n\nexport function ContextMenuItem(props: ContextMenuItemProps) {\n return <ContextMenuItemBase {...props} />;\n}\n\nexport interface ContextMenuCheckboxItemProps extends Omit<ContextMenuItemProps, \"onSelect\"> {\n checked: boolean;\n onCheckedChange?: (checked: boolean) => void;\n}\n\nexport function ContextMenuCheckboxItem({\n checked,\n onCheckedChange,\n children,\n ...props\n}: ContextMenuCheckboxItemProps) {\n const context = useContextMenuContext(\"ContextMenuCheckboxItem\");\n return (\n <ContextMenuItemBase\n {...props}\n role=\"menuitemcheckbox\"\n ariaChecked={checked}\n onSelect={() => onCheckedChange?.(!checked)}\n >\n <span className=\"flex h-4 w-4 shrink-0 items-center justify-center\">\n <AnimatePresence initial={false}>\n {checked ? (\n <motion.span\n key=\"check\"\n initial={context.reduce ? false : { opacity: 0, scale: 0.75 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0, scale: context.reduce ? 1 : 0.75 }}\n transition={context.reduce ? { duration: 0.08 } : SPRING_PANEL}\n >\n <Check aria-hidden=\"true\" className=\"h-3.5 w-3.5\" strokeWidth={2.4} />\n </motion.span>\n ) : null}\n </AnimatePresence>\n </span>\n {children}\n </ContextMenuItemBase>\n );\n}\n\ninterface ContextMenuRadioGroupContextValue {\n value: string;\n onValueChange?: (value: string) => void;\n}\n\nconst ContextMenuRadioGroupContext = createContext<ContextMenuRadioGroupContextValue | null>(null);\n\nexport interface ContextMenuRadioGroupProps {\n value: string;\n onValueChange?: (value: string) => void;\n children: ReactNode;\n className?: string;\n}\n\nexport function ContextMenuRadioGroup({\n value,\n onValueChange,\n children,\n className,\n}: ContextMenuRadioGroupProps) {\n const context = useMemo(() => ({ value, onValueChange }), [value, onValueChange]);\n return (\n <ContextMenuRadioGroupContext.Provider value={context}>\n <div className={className}>{children}</div>\n </ContextMenuRadioGroupContext.Provider>\n );\n}\n\nexport interface ContextMenuRadioItemProps extends Omit<ContextMenuItemProps, \"onSelect\"> {\n value: string;\n}\n\nexport function ContextMenuRadioItem({ value, children, ...props }: ContextMenuRadioItemProps) {\n const group = useContext(ContextMenuRadioGroupContext);\n if (!group) {\n throw new Error(\"ContextMenuRadioItem must be used within <ContextMenuRadioGroup>\");\n }\n const checked = group.value === value;\n return (\n <ContextMenuItemBase\n {...props}\n role=\"menuitemradio\"\n ariaChecked={checked}\n onSelect={() => group.onValueChange?.(value)}\n >\n <span className=\"flex h-4 w-4 shrink-0 items-center justify-center\">\n <span\n className={cn(\n \"h-1.5 w-1.5 rounded-full bg-current transition-opacity\",\n checked ? \"opacity-100\" : \"opacity-0\",\n )}\n />\n </span>\n {children}\n </ContextMenuItemBase>\n );\n}\n\nexport interface ContextMenuLabelProps {\n children: ReactNode;\n inset?: boolean;\n className?: string;\n}\n\nexport function ContextMenuLabel({ children, inset = false, className }: ContextMenuLabelProps) {\n return (\n <div\n className={cn(\n \"px-2.5 pt-1.5 pb-1 font-semibold text-[10px] text-muted-foreground uppercase tracking-[0.12em]\",\n inset && \"pl-8\",\n className,\n )}\n >\n {children}\n </div>\n );\n}\n\nexport interface ContextMenuSeparatorProps {\n className?: string;\n}\n\nexport function ContextMenuSeparator({ className }: ContextMenuSeparatorProps) {\n return <hr className={cn(\"-mx-1 my-1 h-px border-0 bg-border\", className)} />;\n}\n\nexport interface ContextMenuShortcutProps {\n children: ReactNode;\n className?: string;\n}\n\nexport function ContextMenuShortcut({ children, className }: ContextMenuShortcutProps) {\n return (\n <span\n aria-hidden=\"true\"\n className={cn(\n \"ml-auto pl-4 font-medium text-[10px] text-muted-foreground tracking-wide\",\n className,\n )}\n >\n {children}\n </span>\n );\n}\n"],"mappings":";;;;;;;;;AA+BA,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;AACzB,MAAM,uBAAuB;AAC7B,MAAM,iBAAiB;AAqBvB,MAAM,qBAAqB,cAA8C,IAAI;AAE7E,SAAS,sBAAsB,WAAmB;CAChD,MAAM,UAAU,WAAW,kBAAkB;CAC7C,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,GAAG,UAAU,mCAAmC;CAElE,OAAO;AACT;AAEA,SAAS,UAAa,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A,oBAAC,OAAD;GAAgB;GAAY;EAAc,CAAA;CACL,CAAA;AAE3C;AAMA,SAAgB,qBAAqB,EAAE,OAAO,UAAU,GAAG,SAAoC;CAC7F,MAAM,QAAQ,WAAW,4BAA4B;CACrD,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,kEAAkE;CAEpF,MAAM,UAAU,MAAM,UAAU;CAChC,OACE,qBAAC,qBAAD;EACE,GAAI;EACJ,MAAK;EACL,aAAa;EACb,gBAAgB,MAAM,gBAAgB,KAAK;EAJ7C,UAAA,CAME,oBAAC,QAAD;GAAM,WAAU;GACd,UAAA,oBAAC,QAAD,EACE,WAAW,GACT,0DACA,UAAU,gBAAgB,WAC5B,EACD,CAAA;EACG,CAAA,GACL,QACkB;;AAEzB;AAQA,SAAgB,iBAAiB,EAAE,UAAU,QAAQ,OAAO,aAAoC;CAC9F,OACE,oBAAC,OAAD;EACE,WAAW,GACT,kGACA,SAAS,QACT,SACF;EAEC;CACE,CAAA;AAET;AAMA,SAAgB,qBAAqB,EAAE,aAAwC;CAC7E,OAAO,oBAAC,MAAD,EAAI,WAAW,GAAG,sCAAsC,SAAS,EAAI,CAAA;AAC9E;AAOA,SAAgB,oBAAoB,EAAE,UAAU,aAAuC;CACrF,OACE,oBAAC,QAAD;EACE,eAAY;EACZ,WAAW,GACT,4EACA,SACF;EAEC;CACG,CAAA;AAEV"}
1
+ {"version":3,"file":"context-menu.js","names":[],"sources":["../../../src/components/motion/context-menu.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n cloneElement,\n createContext,\n isValidElement,\n type ReactElement,\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n type ReactNode,\n type PointerEvent as ReactPointerEvent,\n type Ref,\n useCallback,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Check } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_LAYOUT, SPRING_PANEL } from \"../../lib/ease\";\nimport { holdSelection, TOUCH_GESTURE_CONTENT_CLASS } from \"../../lib/touch\";\n\ntype OpenModality = \"pointer\" | \"keyboard\" | \"touch\";\ntype MenuPoint = { x: number; y: number };\n\nconst VIEWPORT_PADDING = 8;\nconst LONG_PRESS_DELAY = 520;\nconst LONG_PRESS_TOLERANCE = 10;\nconst MORPH_DURATION = 0.3;\n\ntype TriggerElementProps = React.HTMLAttributes<HTMLElement> & {\n ref?: Ref<HTMLElement>;\n};\n\ninterface ContextMenuContextValue {\n open: boolean;\n setOpen: (open: boolean) => void;\n openAt: (point: MenuPoint, modality: OpenModality) => void;\n point: MenuPoint;\n modality: OpenModality;\n invocation: number;\n menuId: string;\n triggerRef: React.MutableRefObject<HTMLElement | null>;\n contentRef: React.MutableRefObject<HTMLDivElement | null>;\n activeId: string | null;\n setActiveId: (id: string | null) => void;\n reduce: boolean;\n}\n\nconst ContextMenuContext = createContext<ContextMenuContextValue | null>(null);\n\nfunction useContextMenuContext(component: string) {\n const context = useContext(ContextMenuContext);\n if (!context) {\n throw new Error(`${component} must be used within <ContextMenu>`);\n }\n return context;\n}\n\nfunction assignRef<T>(ref: Ref<T> | undefined, value: T | null) {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n}\n\nfunction getEnabledItems(container: HTMLElement | null) {\n if (!container) return [];\n return Array.from(\n container.querySelectorAll<HTMLElement>(\n '[data-context-menu-item=\"true\"]:not([data-disabled=\"true\"])',\n ),\n );\n}\n\nfunction clamp(value: number, min: number, max: number) {\n return Math.min(Math.max(value, min), max);\n}\n\nfunction collapsedClip(origin: MenuPoint, size: { width: number; height: number }) {\n const half = 8;\n const top = clamp(origin.y - half, 0, size.height);\n const right = clamp(size.width - origin.x - half, 0, size.width);\n const bottom = clamp(size.height - origin.y - half, 0, size.height);\n const left = clamp(origin.x - half, 0, size.width);\n return `inset(${top}px ${right}px ${bottom}px ${left}px round 10px)`;\n}\n\nexport interface ContextMenuProps {\n children: ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n className?: string;\n}\n\nexport function ContextMenu({\n children,\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n className,\n}: ContextMenuProps) {\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const [point, setPoint] = useState<MenuPoint>({ x: 0, y: 0 });\n const [modality, setModality] = useState<OpenModality>(\"pointer\");\n const [invocation, setInvocation] = useState(0);\n const [activeId, setActiveId] = useState<string | null>(null);\n const controlled = controlledOpen !== undefined;\n const open = controlled ? controlledOpen : internalOpen;\n const triggerRef = useRef<HTMLElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const menuId = useId();\n const reduce = useReducedMotion() ?? false;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!controlled) setInternalOpen(next);\n onOpenChange?.(next);\n if (!next) setActiveId(null);\n },\n [controlled, onOpenChange],\n );\n\n const openAt = useCallback(\n (nextPoint: MenuPoint, nextModality: OpenModality) => {\n setPoint(nextPoint);\n setModality(nextModality);\n setInvocation((current) => current + 1);\n setActiveId(null);\n setOpen(true);\n },\n [setOpen],\n );\n\n useEffect(() => {\n if (!open) return;\n\n const onPointerDown = (event: PointerEvent) => {\n if (!contentRef.current?.contains(event.target as Node)) setOpen(false);\n };\n const onWindowChange = () => setOpen(false);\n\n window.addEventListener(\"pointerdown\", onPointerDown);\n window.addEventListener(\"resize\", onWindowChange);\n window.addEventListener(\"scroll\", onWindowChange);\n return () => {\n window.removeEventListener(\"pointerdown\", onPointerDown);\n window.removeEventListener(\"resize\", onWindowChange);\n window.removeEventListener(\"scroll\", onWindowChange);\n };\n }, [open, setOpen]);\n\n const value = useMemo<ContextMenuContextValue>(\n () => ({\n open,\n setOpen,\n openAt,\n point,\n modality,\n invocation,\n menuId,\n triggerRef,\n contentRef,\n activeId,\n setActiveId,\n reduce,\n }),\n [open, setOpen, openAt, point, modality, invocation, menuId, activeId, reduce],\n );\n\n return (\n <ContextMenuContext.Provider value={value}>\n <div className={cn(\"contents\", className)}>{children}</div>\n </ContextMenuContext.Provider>\n );\n}\n\nexport interface ContextMenuTriggerProps {\n children: ReactElement<TriggerElementProps>;\n disabled?: boolean;\n className?: string;\n}\n\nexport function ContextMenuTrigger({\n children,\n disabled = false,\n className,\n}: ContextMenuTriggerProps) {\n const context = useContextMenuContext(\"ContextMenuTrigger\");\n const longPressTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const touchOrigin = useRef<MenuPoint | null>(null);\n const releaseSelection = useRef<(() => void) | null>(null);\n\n const cancelLongPress = useCallback(() => {\n if (longPressTimer.current) {\n clearTimeout(longPressTimer.current);\n longPressTimer.current = null;\n }\n touchOrigin.current = null;\n }, []);\n\n // Held for the whole press, not just the timer: a gesture that turned into a\n // drag must not paint a selection under the finger either.\n const endPress = useCallback(() => {\n cancelLongPress();\n releaseSelection.current?.();\n releaseSelection.current = null;\n }, [cancelLongPress]);\n\n useEffect(() => endPress, [endPress]);\n\n if (!isValidElement(children)) {\n throw new Error(\"<ContextMenuTrigger> requires a single React element\");\n }\n\n const childProps = children.props;\n const childRef = children.props.ref;\n\n const onPointerDown = (event: ReactPointerEvent<HTMLElement>) => {\n childProps.onPointerDown?.(event);\n // A pen presses the same way a finger does and gets no `contextmenu` out\n // of the platform for it, so it holds to open too. A mouse has the right\n // button and is left to `onContextMenu`.\n const pressToOpen = event.pointerType === \"touch\" || event.pointerType === \"pen\";\n if (event.defaultPrevented || disabled || !pressToOpen) return;\n\n // `pointer-coarse:select-none` misses this press on a laptop whose mouse\n // is the primary pointer and whose touchscreen is not, and the platform's\n // own long-press selection then claims the gesture and cancels ours. The\n // press is the only thing that knows which input is on the glass, so it\n // takes selection away itself — for its own duration, and no longer.\n releaseSelection.current?.();\n releaseSelection.current = holdSelection(event.currentTarget);\n\n const origin = { x: event.clientX, y: event.clientY };\n touchOrigin.current = origin;\n longPressTimer.current = setTimeout(() => {\n context.openAt(origin, \"touch\");\n longPressTimer.current = null;\n touchOrigin.current = null;\n }, LONG_PRESS_DELAY);\n };\n\n const onPointerMove = (event: ReactPointerEvent<HTMLElement>) => {\n childProps.onPointerMove?.(event);\n const origin = touchOrigin.current;\n if (\n origin &&\n Math.hypot(event.clientX - origin.x, event.clientY - origin.y) > LONG_PRESS_TOLERANCE\n ) {\n cancelLongPress();\n }\n };\n\n const onKeyDown = (event: ReactKeyboardEvent<HTMLElement>) => {\n childProps.onKeyDown?.(event);\n if (event.defaultPrevented || disabled) return;\n if (event.key !== \"ContextMenu\" && !(event.shiftKey && event.key === \"F10\")) return;\n\n event.preventDefault();\n const rect = event.currentTarget.getBoundingClientRect();\n context.openAt(\n { x: rect.left + Math.min(24, rect.width / 2), y: rect.top + rect.height / 2 },\n \"keyboard\",\n );\n };\n\n return cloneElement(children, {\n ref: (node: HTMLElement | null) => {\n context.triggerRef.current = node;\n assignRef(childRef, node);\n },\n \"aria-controls\": context.open ? context.menuId : undefined,\n \"aria-haspopup\": \"menu\",\n \"aria-expanded\": context.open,\n // The long press is ours: without this iOS runs its own on the same\n // gesture and drops the selection callout and its handles on top of the\n // menu we just opened. Only the press gesture is ours though — the child\n // is the consumer's content, so a mouse can still select the text in it\n // and right-click the selection. `touch-none` stays off too: the page\n // still has to scroll from the trigger.\n className: cn(TOUCH_GESTURE_CONTENT_CLASS, childProps.className, className),\n onContextMenu: (event: ReactMouseEvent<HTMLElement>) => {\n childProps.onContextMenu?.(event);\n if (event.defaultPrevented || disabled) return;\n event.preventDefault();\n endPress();\n context.openAt({ x: event.clientX, y: event.clientY }, \"pointer\");\n },\n onKeyDown,\n onPointerDown,\n onPointerMove,\n onPointerUp: (event: ReactPointerEvent<HTMLElement>) => {\n childProps.onPointerUp?.(event);\n endPress();\n },\n onPointerCancel: (event: ReactPointerEvent<HTMLElement>) => {\n childProps.onPointerCancel?.(event);\n endPress();\n },\n });\n}\n\nexport interface ContextMenuContentProps {\n children: ReactNode;\n className?: string;\n ariaLabel?: string;\n}\n\nexport function ContextMenuContent({\n children,\n className,\n ariaLabel = \"Context menu\",\n}: ContextMenuContentProps) {\n const context = useContextMenuContext(\"ContextMenuContent\");\n const [mounted, setMounted] = useState(false);\n const [position, setPosition] = useState<MenuPoint>(context.point);\n const [origin, setOrigin] = useState<MenuPoint>({ x: 0, y: 0 });\n const [size, setSize] = useState({ width: 0, height: 0 });\n const [morphReady, setMorphReady] = useState(false);\n const typeahead = useRef(\"\");\n const typeaheadTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => setMounted(true), []);\n\n useLayoutEffect(() => {\n if (!context.open) {\n setMorphReady(false);\n return;\n }\n const content = context.contentRef.current;\n if (!content) return;\n content.dataset.invocation = String(context.invocation);\n\n const rect = content.getBoundingClientRect();\n const left = Math.max(\n VIEWPORT_PADDING,\n Math.min(\n Math.max(context.point.x, VIEWPORT_PADDING),\n window.innerWidth - rect.width - VIEWPORT_PADDING,\n ),\n );\n const top = Math.max(\n VIEWPORT_PADDING,\n Math.min(\n Math.max(context.point.y, VIEWPORT_PADDING),\n window.innerHeight - rect.height - VIEWPORT_PADDING,\n ),\n );\n\n setPosition({ x: left, y: top });\n setSize({ width: rect.width, height: rect.height });\n setOrigin({\n x: clamp(context.point.x - left, 12, Math.max(12, rect.width - 12)),\n y: clamp(context.point.y - top, 12, Math.max(12, rect.height - 12)),\n });\n setMorphReady(false);\n\n if (context.reduce || context.modality === \"keyboard\") {\n setMorphReady(true);\n return;\n }\n\n // Let the measured collapsed clip paint once before expanding it. Without\n // this preparation frame, the first invocation can batch both states and\n // appear at full size without the morph.\n let openFrame = 0;\n const prepareFrame = requestAnimationFrame(() => {\n openFrame = requestAnimationFrame(() => setMorphReady(true));\n });\n return () => {\n cancelAnimationFrame(prepareFrame);\n cancelAnimationFrame(openFrame);\n };\n }, [\n context.open,\n context.point,\n context.contentRef,\n context.invocation,\n context.modality,\n context.reduce,\n ]);\n\n useEffect(() => {\n if (!context.open) return;\n const frame = requestAnimationFrame(() => {\n const first = getEnabledItems(context.contentRef.current)[0];\n first?.focus({ preventScroll: true });\n });\n return () => cancelAnimationFrame(frame);\n }, [context.open, context.contentRef]);\n\n useEffect(\n () => () => {\n if (typeaheadTimer.current) clearTimeout(typeaheadTimer.current);\n },\n [],\n );\n\n const moveFocus = (direction: 1 | -1) => {\n const items = getEnabledItems(context.contentRef.current);\n if (items.length === 0) return;\n const current = items.indexOf(document.activeElement as HTMLElement);\n const next = current < 0 ? 0 : (current + direction + items.length) % items.length;\n items[next]?.focus();\n };\n\n const onKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n context.setOpen(false);\n context.triggerRef.current?.focus();\n return;\n }\n if (event.key === \"Tab\") {\n context.setOpen(false);\n return;\n }\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n moveFocus(event.key === \"ArrowDown\" ? 1 : -1);\n return;\n }\n if (event.key === \"Home\" || event.key === \"End\") {\n event.preventDefault();\n const items = getEnabledItems(context.contentRef.current);\n items[event.key === \"Home\" ? 0 : items.length - 1]?.focus();\n return;\n }\n if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {\n typeahead.current += event.key.toLocaleLowerCase();\n if (typeaheadTimer.current) clearTimeout(typeaheadTimer.current);\n typeaheadTimer.current = setTimeout(() => {\n typeahead.current = \"\";\n }, 500);\n const match = getEnabledItems(context.contentRef.current).find((item) =>\n (item.dataset.label ?? item.textContent ?? \"\")\n .trim()\n .toLocaleLowerCase()\n .startsWith(typeahead.current),\n );\n match?.focus();\n }\n };\n\n if (!mounted) return null;\n\n const visualOpen = context.open && morphReady;\n const clipHidden = collapsedClip(origin, size);\n const clipShown = \"inset(0px 0px 0px 0px round 12px)\";\n\n return createPortal(\n <div\n data-context-menu-portal=\"\"\n aria-hidden={!context.open}\n inert={!context.open}\n style={{ left: position.x, top: position.y }}\n className={cn(\n \"filter-[drop-shadow(0_18px_28px_rgba(0,0,0,0.2))] fixed z-100\",\n context.open ? \"pointer-events-auto\" : \"pointer-events-none\",\n )}\n >\n <motion.div\n ref={context.contentRef}\n id={context.menuId}\n role=\"menu\"\n aria-label={ariaLabel}\n data-morph-ready={morphReady ? \"true\" : \"false\"}\n tabIndex={-1}\n initial={false}\n animate={{\n opacity: visualOpen ? 1 : 0,\n clipPath:\n context.reduce || context.modality === \"keyboard\" || visualOpen\n ? clipShown\n : clipHidden,\n }}\n transition={\n context.modality === \"keyboard\"\n ? { duration: 0 }\n : context.reduce\n ? { duration: 0.1, ease: EASE_OUT }\n : {\n clipPath: {\n duration: MORPH_DURATION,\n ease: EASE_OUT,\n },\n opacity: {\n duration: MORPH_DURATION,\n ease: EASE_OUT,\n },\n }\n }\n onKeyDown={onKeyDown}\n onContextMenu={(event) => event.preventDefault()}\n className={cn(\n \"min-w-56 overflow-hidden rounded-xl border border-border bg-card p-1.5 text-foreground outline-none\",\n className,\n )}\n >\n {children}\n </motion.div>\n </div>,\n document.body,\n );\n}\n\ntype ContextMenuItemTone = \"default\" | \"destructive\";\n\nexport interface ContextMenuItemProps {\n children: ReactNode;\n onSelect?: () => void;\n disabled?: boolean;\n closeOnSelect?: boolean;\n tone?: ContextMenuItemTone;\n inset?: boolean;\n className?: string;\n textValue?: string;\n}\n\nfunction ContextMenuItemBase({\n children,\n onSelect,\n disabled = false,\n closeOnSelect = true,\n tone = \"default\",\n inset = false,\n className,\n textValue,\n role = \"menuitem\",\n ariaChecked,\n}: ContextMenuItemProps & {\n role?: \"menuitem\" | \"menuitemcheckbox\" | \"menuitemradio\";\n ariaChecked?: boolean;\n}) {\n const context = useContextMenuContext(\"ContextMenuItem\");\n const id = useId();\n const active = context.activeId === id;\n const checkedProps = role === \"menuitem\" ? {} : { \"aria-checked\": ariaChecked };\n\n return (\n <button\n type=\"button\"\n id={id}\n role={role}\n {...checkedProps}\n disabled={disabled}\n data-context-menu-item=\"true\"\n data-disabled={disabled ? \"true\" : undefined}\n data-label={textValue}\n tabIndex={-1}\n onFocus={() => context.setActiveId(id)}\n onPointerMove={(event) => {\n if (!disabled && event.pointerType !== \"touch\") event.currentTarget.focus();\n }}\n onClick={() => {\n if (disabled) return;\n onSelect?.();\n if (closeOnSelect) context.setOpen(false);\n }}\n className={cn(\n \"relative isolate flex w-full select-none items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[13px] outline-none\",\n \"focus-visible:ring-2 focus-visible:ring-foreground/15\",\n \"disabled:pointer-events-none disabled:opacity-40\",\n inset && \"pl-8\",\n tone === \"destructive\" ? \"text-destructive\" : \"text-foreground\",\n className,\n )}\n >\n {active ? (\n <motion.span\n layoutId={`${context.menuId}-active`}\n className={cn(\n \"absolute inset-0 -z-10 rounded-lg\",\n tone === \"destructive\" ? \"bg-destructive/10\" : \"bg-foreground/6.5\",\n )}\n transition={context.reduce ? { duration: 0 } : SPRING_LAYOUT}\n />\n ) : null}\n {children}\n </button>\n );\n}\n\nexport function ContextMenuItem(props: ContextMenuItemProps) {\n return <ContextMenuItemBase {...props} />;\n}\n\nexport interface ContextMenuCheckboxItemProps extends Omit<ContextMenuItemProps, \"onSelect\"> {\n checked: boolean;\n onCheckedChange?: (checked: boolean) => void;\n}\n\nexport function ContextMenuCheckboxItem({\n checked,\n onCheckedChange,\n children,\n ...props\n}: ContextMenuCheckboxItemProps) {\n const context = useContextMenuContext(\"ContextMenuCheckboxItem\");\n return (\n <ContextMenuItemBase\n {...props}\n role=\"menuitemcheckbox\"\n ariaChecked={checked}\n onSelect={() => onCheckedChange?.(!checked)}\n >\n <span className=\"flex h-4 w-4 shrink-0 items-center justify-center\">\n <AnimatePresence initial={false}>\n {checked ? (\n <motion.span\n key=\"check\"\n initial={context.reduce ? false : { opacity: 0, scale: 0.75 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0, scale: context.reduce ? 1 : 0.75 }}\n transition={context.reduce ? { duration: 0.08 } : SPRING_PANEL}\n >\n <Check aria-hidden=\"true\" className=\"h-3.5 w-3.5\" strokeWidth={2.4} />\n </motion.span>\n ) : null}\n </AnimatePresence>\n </span>\n {children}\n </ContextMenuItemBase>\n );\n}\n\ninterface ContextMenuRadioGroupContextValue {\n value: string;\n onValueChange?: (value: string) => void;\n}\n\nconst ContextMenuRadioGroupContext = createContext<ContextMenuRadioGroupContextValue | null>(null);\n\nexport interface ContextMenuRadioGroupProps {\n value: string;\n onValueChange?: (value: string) => void;\n children: ReactNode;\n className?: string;\n}\n\nexport function ContextMenuRadioGroup({\n value,\n onValueChange,\n children,\n className,\n}: ContextMenuRadioGroupProps) {\n const context = useMemo(() => ({ value, onValueChange }), [value, onValueChange]);\n return (\n <ContextMenuRadioGroupContext.Provider value={context}>\n <div className={className}>{children}</div>\n </ContextMenuRadioGroupContext.Provider>\n );\n}\n\nexport interface ContextMenuRadioItemProps extends Omit<ContextMenuItemProps, \"onSelect\"> {\n value: string;\n}\n\nexport function ContextMenuRadioItem({ value, children, ...props }: ContextMenuRadioItemProps) {\n const group = useContext(ContextMenuRadioGroupContext);\n if (!group) {\n throw new Error(\"ContextMenuRadioItem must be used within <ContextMenuRadioGroup>\");\n }\n const checked = group.value === value;\n return (\n <ContextMenuItemBase\n {...props}\n role=\"menuitemradio\"\n ariaChecked={checked}\n onSelect={() => group.onValueChange?.(value)}\n >\n <span className=\"flex h-4 w-4 shrink-0 items-center justify-center\">\n <span\n className={cn(\n \"h-1.5 w-1.5 rounded-full bg-current transition-opacity\",\n checked ? \"opacity-100\" : \"opacity-0\",\n )}\n />\n </span>\n {children}\n </ContextMenuItemBase>\n );\n}\n\nexport interface ContextMenuLabelProps {\n children: ReactNode;\n inset?: boolean;\n className?: string;\n}\n\nexport function ContextMenuLabel({ children, inset = false, className }: ContextMenuLabelProps) {\n return (\n <div\n className={cn(\n \"px-2.5 pt-1.5 pb-1 font-semibold text-[10px] text-muted-foreground uppercase tracking-[0.12em]\",\n inset && \"pl-8\",\n className,\n )}\n >\n {children}\n </div>\n );\n}\n\nexport interface ContextMenuSeparatorProps {\n className?: string;\n}\n\nexport function ContextMenuSeparator({ className }: ContextMenuSeparatorProps) {\n return <hr className={cn(\"-mx-1 my-1 h-px border-0 bg-border\", className)} />;\n}\n\nexport interface ContextMenuShortcutProps {\n children: ReactNode;\n className?: string;\n}\n\nexport function ContextMenuShortcut({ children, className }: ContextMenuShortcutProps) {\n return (\n <span\n aria-hidden=\"true\"\n className={cn(\n \"ml-auto pl-4 font-medium text-[10px] text-muted-foreground tracking-wide\",\n className,\n )}\n >\n {children}\n </span>\n );\n}\n"],"mappings":";;;;;;;;;;AAgCA,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;AACzB,MAAM,uBAAuB;AAC7B,MAAM,iBAAiB;AAqBvB,MAAM,qBAAqB,cAA8C,IAAI;AAE7E,SAAS,sBAAsB,WAAmB;CAChD,MAAM,UAAU,WAAW,kBAAkB;CAC7C,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,GAAG,UAAU,mCAAmC;CAElE,OAAO;AACT;AAEA,SAAS,UAAa,KAAyB,OAAiB;CAC9D,IAAI,OAAO,QAAQ,YACjB,IAAI,KAAK;MACJ,IAAI,KACT,IAAI,UAAU;AAElB;AAEA,SAAS,gBAAgB,WAA+B;CACtD,IAAI,CAAC,WAAW,OAAO,CAAC;CACxB,OAAO,MAAM,KACX,UAAU,iBACR,iEACF,CACF;AACF;AAEA,SAAS,MAAM,OAAe,KAAa,KAAa;CACtD,OAAO,KAAK,IAAI,KAAK,IAAI,OAAO,GAAG,GAAG,GAAG;AAC3C;AAEA,SAAS,cAAc,QAAmB,MAAyC;CACjF,MAAM,OAAO;CAKb,OAAO,SAJK,MAAM,OAAO,IAAI,MAAM,GAAG,KAAK,MAIzB,EAAE,KAHN,MAAM,KAAK,QAAQ,OAAO,IAAI,MAAM,GAAG,KAAK,KAG7B,EAAE,KAFhB,MAAM,KAAK,SAAS,OAAO,IAAI,MAAM,GAAG,K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BAAgB,MAAM,gBAAgB,KAAK;EAJ7C,UAAA,CAME,oBAAC,QAAD;GAAM,WAAU;GACd,UAAA,oBAAC,QAAD,EACE,WAAW,GACT,0DACA,UAAU,gBAAgB,WAC5B,EACD,CAAA;EACG,CAAA,GACL,QACkB;;AAEzB;AAQA,SAAgB,iBAAiB,EAAE,UAAU,QAAQ,OAAO,aAAoC;CAC9F,OACE,oBAAC,OAAD;EACE,WAAW,GACT,kGACA,SAAS,QACT,SACF;EAEC;CACE,CAAA;AAET;AAMA,SAAgB,qBAAqB,EAAE,aAAwC;CAC7E,OAAO,oBAAC,MAAD,EAAI,WAAW,GAAG,sCAAsC,SAAS,EAAI,CAAA;AAC9E;AAOA,SAAgB,oBAAoB,EAAE,UAAU,aAAuC;CACrF,OACE,oBAAC,QAAD;EACE,eAAY;EACZ,WAAW,GACT,4EACA,SACF;EAEC;CACG,CAAA;AAEV"}
@@ -1 +1 @@
1
- {"version":3,"file":"cylinder-carousel.d.ts","names":[],"sources":["../../../src/components/motion/cylinder-carousel.tsx"],"mappings":";;UAgCiB;EACf,UAAU;;;;EAIV;;EAEA;;;;EAIA;;;EAGA;;;EAGA;;;;EAIA;;EAEA;;EAEA;;EAEA;EACA;EACA,iBAAiB;;EAEjB;EACA;;iBA4Gc,mBACd,UACA,UACA,cACA,SACA,UACA,WACA,KAAK,SACL,MACA,YACA,iBACA,cACA,eACA,QACA,aACC,wCAAqB,IAAA"}
1
+ {"version":3,"file":"cylinder-carousel.d.ts","names":[],"sources":["../../../src/components/motion/cylinder-carousel.tsx"],"mappings":";;UAiCiB;EACf,UAAU;;;;EAIV;;EAEA;;;;EAIA;;;EAGA;;;EAGA;;;;EAIA;;EAEA;;EAEA;;EAEA;EACA;EACA,iBAAiB;;EAEjB;EACA;;iBA4Gc,mBACd,UACA,UACA,cACA,SACA,UACA,WACA,KAAK,SACL,MACA,YACA,iBACA,cACA,eACA,QACA,aACC,wCAAqB,IAAA"}
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { TOUCH_GESTURE_CLASS, capturePointer, releasePointer } from "../../lib/touch.js";
2
3
  import { Children, useCallback, useEffect, useRef, useState } from "react";
3
4
  import { cn } from "@kumix/utils";
4
5
  import { jsx } from "react/jsx-runtime";
@@ -150,7 +151,7 @@ function CylinderCarousel({ children, itemSize = 200, visibleItems = 5, variant
150
151
  e.preventDefault();
151
152
  stopGlide();
152
153
  draggingRef.current = true;
153
- e.currentTarget.setPointerCapture(e.pointerId);
154
+ capturePointer(e.currentTarget, e.pointerId);
154
155
  const now = performance.now();
155
156
  drag.current = {
156
157
  startX: e.clientX,
@@ -177,7 +178,7 @@ function CylinderCarousel({ children, itemSize = 200, visibleItems = 5, variant
177
178
  const onPointerUp = useCallback((e) => {
178
179
  if (!draggingRef.current) return;
179
180
  draggingRef.current = false;
180
- if (e.currentTarget.hasPointerCapture(e.pointerId)) e.currentTarget.releasePointerCapture(e.pointerId);
181
+ releasePointer(e.currentTarget, e.pointerId);
181
182
  const d = drag.current;
182
183
  const dt = d.lastT - d.prevT;
183
184
  const vpx = dt > 0 ? (d.lastX - d.prevX) / dt : 0;
@@ -248,7 +249,7 @@ function CylinderCarousel({ children, itemSize = 200, visibleItems = 5, variant
248
249
  onPointerLeave: () => {
249
250
  hoverRef.current = false;
250
251
  },
251
- className: cn("relative w-full touch-none select-none outline-none [clip-path:inset(0)]", "cursor-grab active:cursor-grabbing", "focus-visible:ring-2 focus-visible:ring-foreground/20", className),
252
+ className: cn("relative w-full touch-none outline-none [clip-path:inset(0)]", TOUCH_GESTURE_CLASS, "cursor-grab active:cursor-grabbing", "focus-visible:ring-2 focus-visible:ring-foreground/20", className),
252
253
  style: { height: stageHeight },
253
254
  children: items.map((item, i) => /* @__PURE__ */ jsx(CarouselBall, {
254
255
  scroll,
@@ -1 +1 @@
1
- {"version":3,"file":"cylinder-carousel.js","names":[],"sources":["../../../src/components/motion/cylinder-carousel.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n Children,\n type ReactNode,\n type PointerEvent as ReactPointerEvent,\n type WheelEvent as ReactWheelEvent,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport {\n type AnimationPlaybackControls,\n animate,\n type MotionValue,\n motion,\n useMotionValue,\n useReducedMotion,\n useTransform,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\n\n// Carousel-specific: a soft spring that receives the release velocity, so a\n// flick keeps rolling freely, drifts past the snap point and eases back.\nconst GLIDE_SPRING = { stiffness: 40, damping: 20, mass: 3 };\n\n// How far a flick keeps rolling: projected items = release velocity * momentum.\nconst FLICK_MOMENTUM = 0.45;\nconst MAX_FLICK_ITEMS = 6;\n\nexport interface CylinderCarouselProps {\n children: ReactNode;\n /** Max item box size in px (square) at full size, i.e. at the container\n * edge. Balls shrink below this automatically so the row keeps breathing\n * room in narrow containers. */\n itemSize?: number;\n /** How many item slots span the container width. */\n visibleItems?: number;\n /** \"concave\" (default): inside of the cylinder — center ball smallest and\n * dipped, growing toward the edges. \"convex\": outside of the cylinder —\n * center ball biggest and raised, shrinking toward the edges. */\n variant?: \"concave\" | \"convex\";\n /** Scale of the smallest ball (center for concave, edges for convex);\n * the biggest reaches 1. */\n minScale?: number;\n /** Items rolled per item-width dragged — above 1 the wall outruns the\n * pointer, which reads as a lighter, freer roll. */\n dragSpeed?: number;\n /** Curve depth in px: for concave, how far the edge balls ride above the\n * center one (valley); for convex, how far below (arch). 0 = flat line.\n * Defaults to 35% of the item size. */\n arc?: number;\n /** Snap to the nearest item when the roll settles. */\n snap?: boolean;\n /** Roll on its own until interacted with. */\n autoRotate?: boolean;\n /** Auto-roll speed in items per second. */\n autoRotateSpeed?: number;\n defaultIndex?: number;\n onIndexChange?: (index: number) => void;\n /** Stage height in px. Defaults to `itemSize`. */\n height?: number;\n className?: string;\n}\n\n// The frame edge sits at this wall angle; how far the wall curves in frame.\nconst THETA_EDGE = (72 * Math.PI) / 180;\n// Wall angle past which a ball is parked far off-stage (always hidden there).\nconst THETA_CLAMP = (95 * Math.PI) / 180;\n\n/**\n * One ball on the inside wall of the cylinder, rendered through a single\n * perspective projection: the ball sits at wall angle θ, the camera slightly\n * above the ball line, so horizontal position, size and height all share one\n * 1/(cosθ + k) depth term. Center = far wall: smallest, highest, moving\n * slowest; edges = nearest: full size, level, moving fastest, sliding off to\n * be clipped. Nothing overlaps, fades or reorders — the edge is the exit.\n */\nfunction CarouselBall({\n scroll,\n index,\n count,\n alpha,\n k,\n projection,\n gap,\n edgeOffset,\n minScale,\n convex,\n arc,\n halfWidth,\n itemSize,\n children,\n}: {\n scroll: MotionValue<number>;\n index: number;\n count: number;\n /** Wall angle per item step, in radians. */\n alpha: number;\n /** Camera distance term for the horizontal projection. */\n k: number;\n /** Projection strength: maps sinθ/(cosθ+k) to px so θE lands on the edge. */\n projection: number;\n /** Uniform slot width in px — convex spacing. */\n gap: number;\n /** Offset at which a ball's center sits on the container edge. */\n edgeOffset: number;\n minScale: number;\n convex: boolean;\n /** Curve depth in px between the center ball and the edge balls. */\n arc: number;\n halfWidth: number;\n itemSize: number;\n children: ReactNode;\n}) {\n // Nearest wrapped offset so items loop around continuously.\n const offset = useTransform(scroll, (s) => {\n let o = index - s;\n o -= Math.round(o / count) * count;\n return o;\n });\n // Concave spacing follows the interior perspective (slow, tight center);\n // convex pairs its big center balls with uniform spacing — the interior\n // projection would collapse them into each other.\n const x = useTransform(offset, (o) => {\n if (convex) return o * gap;\n const th = Math.max(-THETA_CLAMP, Math.min(THETA_CLAMP, o * alpha));\n return (projection * Math.sin(th)) / (Math.cos(th) + k);\n });\n // Linear in wall angle, not in depth (the depth curve is near-flat around\n // the center, which made the middle three read as equal): every step is\n // visibly bigger than the last — growing outward (concave) or inward\n // (convex).\n const scale = useTransform(offset, (o) => {\n const t = Math.min(Math.abs(o) / edgeOffset, THETA_CLAMP / THETA_EDGE);\n return convex ? 1 - (1 - minScale) * t : minScale + (1 - minScale) * t;\n });\n // Parabola centered on the stage — valley for concave (center ball dips\n // arc/2 below the midline, edges rise arc/2 above), arch for convex — and\n // deliberately unclamped: a ball keeps following the same curve as it\n // crosses the edge, so entries never pop.\n const y = useTransform(x, (px) => {\n const t = px / halfWidth;\n const valley = arc * (0.5 - t * t);\n return convex ? -valley : valley;\n });\n // Fully off-stage balls stop painting (matters for canvas/shader children).\n const visibility = useTransform(x, (px) =>\n Math.abs(px) > halfWidth + itemSize ? \"hidden\" : \"visible\",\n );\n\n return (\n <motion.div\n className=\"absolute top-1/2 left-1/2\"\n style={{\n x,\n y,\n scale,\n visibility,\n width: itemSize,\n height: itemSize,\n marginLeft: -itemSize / 2,\n marginTop: -itemSize / 2,\n }}\n >\n {children}\n </motion.div>\n );\n}\n\nexport function CylinderCarousel({\n children,\n itemSize = 200,\n visibleItems = 5,\n variant = \"concave\",\n minScale = 0.55,\n dragSpeed = 1.5,\n arc: arcProp,\n snap = true,\n autoRotate = false,\n autoRotateSpeed = 0.4,\n defaultIndex = 0,\n onIndexChange,\n height,\n className,\n}: CylinderCarouselProps) {\n const reduce = useReducedMotion() ?? false;\n const items = Children.toArray(children);\n const count = items.length;\n\n const stageRef = useRef<HTMLDivElement>(null);\n const [width, setWidth] = useState(0);\n useEffect(() => {\n const el = stageRef.current;\n if (!el) return;\n const ro = new ResizeObserver(([entry]) => {\n setWidth(entry.contentRect.width);\n });\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n // Sized so `visibleItems` balls sit fully in frame and the next one out on\n // each side straddles the container edge, half visible.\n const stageWidth = width || 800;\n const halfWidth = stageWidth / 2;\n const edgeOffset = (visibleItems + 1) / 2;\n\n // Fit: the resting row's diameters may take at most ~66% of the stage — the\n // rest is air between balls plus the half-visible ball on each edge.\n // `itemSize` only caps the result.\n const convex = variant === \"convex\";\n let scaleSum = 0;\n for (let i = 0; i < visibleItems; i++) {\n const t = Math.abs(i - (visibleItems - 1) / 2) / edgeOffset;\n scaleSum += convex ? 1 - (1 - minScale) * t : minScale + (1 - minScale) * t;\n }\n const size = Math.min(itemSize, (stageWidth * 0.65) / scaleSum);\n\n const gap = stageWidth / (visibleItems + 1);\n const arc = arcProp ?? size * 0.35;\n\n // Perspective constants. The ball one slot past the frame edge sits at wall\n // angle THETA_EDGE with its center right on the container edge — scale 1,\n // half of it in view; k falls out of the requested minScale (clamped so the\n // projection stays monotonic up to THETA_CLAMP).\n const alpha = THETA_EDGE / edgeOffset;\n const k = Math.max(0.2, (minScale - Math.cos(THETA_EDGE)) / (1 - minScale));\n const projection = (halfWidth * (Math.cos(THETA_EDGE) + k)) / Math.sin(THETA_EDGE);\n\n // scroll is in item units (continuous); item i sits at x = (i - scroll) * gap.\n // Drags write it 1:1 so the wall sticks to the pointer; releases hand the\n // pointer velocity to a soft spring so the roll glides on and settles free.\n const scroll = useMotionValue(defaultIndex);\n const indexRef = useRef(defaultIndex);\n const [, setActiveIndex] = useState(defaultIndex);\n const glideRef = useRef<AnimationPlaybackControls | null>(null);\n const draggingRef = useRef(false);\n const hoverRef = useRef(false);\n\n useEffect(() => {\n if (count === 0) return;\n const unsub = scroll.on(\"change\", (v) => {\n const idx = ((Math.round(v) % count) + count) % count;\n if (idx !== indexRef.current) {\n indexRef.current = idx;\n setActiveIndex(idx);\n onIndexChange?.(idx);\n }\n });\n return unsub;\n }, [scroll, count, onIndexChange]);\n\n const stopGlide = useCallback(() => {\n glideRef.current?.stop();\n glideRef.current = null;\n }, []);\n\n // Spring toward `to`, carrying `velocity` (items/s) through so motion never\n // steps — the roll leaves the finger at finger speed.\n const glideTo = useCallback(\n (to: number, velocity: number) => {\n stopGlide();\n if (reduce) {\n scroll.set(to);\n return;\n }\n glideRef.current = animate(scroll, to, {\n type: \"spring\",\n ...GLIDE_SPRING,\n velocity,\n restDelta: 0.001,\n restSpeed: 0.005,\n });\n },\n [scroll, stopGlide, reduce],\n );\n\n const settle = useCallback(\n (velocity: number) => {\n const projected =\n scroll.get() +\n Math.max(-MAX_FLICK_ITEMS, Math.min(MAX_FLICK_ITEMS, velocity * FLICK_MOMENTUM));\n glideTo(snap ? Math.round(projected) : projected, velocity);\n },\n [scroll, snap, glideTo],\n );\n\n const drag = useRef({\n startX: 0,\n startScroll: 0,\n lastX: 0,\n lastT: 0,\n prevX: 0,\n prevT: 0,\n });\n\n const onPointerDown = useCallback(\n (e: ReactPointerEvent) => {\n e.preventDefault();\n stopGlide();\n draggingRef.current = true;\n e.currentTarget.setPointerCapture(e.pointerId);\n const now = performance.now();\n drag.current = {\n startX: e.clientX,\n startScroll: scroll.get(),\n lastX: e.clientX,\n lastT: now,\n prevX: e.clientX,\n prevT: now,\n };\n },\n [scroll, stopGlide],\n );\n\n const onPointerMove = useCallback(\n (e: ReactPointerEvent) => {\n if (!draggingRef.current) return;\n const d = drag.current;\n scroll.set(d.startScroll - ((e.clientX - d.startX) * dragSpeed) / gap);\n d.prevX = d.lastX;\n d.prevT = d.lastT;\n d.lastX = e.clientX;\n d.lastT = performance.now();\n },\n [scroll, gap, dragSpeed],\n );\n\n const onPointerUp = useCallback(\n (e: ReactPointerEvent) => {\n if (!draggingRef.current) return;\n draggingRef.current = false;\n if (e.currentTarget.hasPointerCapture(e.pointerId)) {\n e.currentTarget.releasePointerCapture(e.pointerId);\n }\n const d = drag.current;\n const dt = d.lastT - d.prevT;\n const vpx = dt > 0 ? (d.lastX - d.prevX) / dt : 0; // px per ms\n settle((-vpx * dragSpeed * 1000) / gap); // items per second\n },\n [settle, gap, dragSpeed],\n );\n\n const rollBy = useCallback(\n (dir: number) => {\n glideTo(Math.round(scroll.get()) + dir, scroll.getVelocity());\n },\n [scroll, glideTo],\n );\n\n const wheelSettleRef = useRef<number | undefined>(undefined);\n const onWheel = useCallback(\n (e: ReactWheelEvent) => {\n stopGlide();\n const delta = Math.abs(e.deltaX) > Math.abs(e.deltaY) ? e.deltaX : e.deltaY;\n scroll.set(scroll.get() + delta / gap);\n if (wheelSettleRef.current) window.clearTimeout(wheelSettleRef.current);\n wheelSettleRef.current = window.setTimeout(() => settle(scroll.getVelocity()), 140);\n },\n [scroll, gap, settle, stopGlide],\n );\n\n useEffect(() => {\n if (!autoRotate || reduce || count === 0) return;\n let raf = 0;\n let last = performance.now();\n const tick = (now: number) => {\n const dt = (now - last) / 1000;\n last = now;\n if (!draggingRef.current && !hoverRef.current && !glideRef.current) {\n scroll.set(scroll.get() + autoRotateSpeed * dt);\n }\n raf = requestAnimationFrame(tick);\n };\n raf = requestAnimationFrame(tick);\n return () => cancelAnimationFrame(raf);\n }, [autoRotate, autoRotateSpeed, reduce, count, scroll]);\n\n const stageHeight = height ?? size;\n\n return (\n <div\n ref={stageRef}\n role=\"application\"\n aria-roledescription=\"carousel\"\n // biome-ignore lint/a11y/noNoninteractiveTabindex: focusable custom carousel widget\n tabIndex={0}\n onKeyDown={(e) => {\n if (e.key === \"ArrowRight\") {\n e.preventDefault();\n rollBy(1);\n } else if (e.key === \"ArrowLeft\") {\n e.preventDefault();\n rollBy(-1);\n }\n }}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={onPointerUp}\n onWheel={onWheel}\n onPointerEnter={() => {\n hoverRef.current = true;\n }}\n onPointerLeave={() => {\n hoverRef.current = false;\n }}\n className={cn(\n // clip-path, not overflow: it also clips the GPU-composited balls\n \"relative w-full touch-none select-none outline-none [clip-path:inset(0)]\",\n \"cursor-grab active:cursor-grabbing\",\n \"focus-visible:ring-2 focus-visible:ring-foreground/20\",\n className,\n )}\n style={{ height: stageHeight }}\n >\n {items.map((item, i) => (\n <CarouselBall\n key={i}\n scroll={scroll}\n index={i}\n count={count}\n alpha={alpha}\n k={k}\n projection={projection}\n gap={gap}\n edgeOffset={edgeOffset}\n minScale={minScale}\n convex={convex}\n arc={arc}\n halfWidth={halfWidth}\n itemSize={size}\n >\n {item}\n </CarouselBall>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;;AA0BA,MAAM,eAAe;CAAE,WAAW;CAAI,SAAS;CAAI,MAAM;AAAE;AAG3D,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AA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AC,cAAc,UAAU,UAAU,GAAG;EAC1C,IAAI,MAAM;EACV,IAAI,OAAO,YAAY,IAAI;EAC3B,MAAM,QAAQ,QAAgB;GAC5B,MAAM,MAAM,MAAM,QAAQ;GAC1B,OAAO;GACP,IAAI,CAAC,YAAY,WAAW,CAAC,SAAS,WAAW,CAAC,SAAS,SACzD,OAAO,IAAI,OAAO,IAAI,IAAI,kBAAkB,EAAE;GAEhD,MAAM,sBAAsB,IAAI;EAClC;EACA,MAAM,sBAAsB,IAAI;EAChC,aAAa,qBAAqB,GAAG;CACvC,GAAG;EAAC;EAAY;EAAiB;EAAQ;EAAO;CAAM,CAAC;CAEvD,MAAM,cAAc,UAAU;CAE9B,OACE,oBAAC,OAAD;EACE,KAAK;EACL,MAAK;EACL,wBAAqB;EAErB,UAAU;EACV,YAAY,MAAM;GAChB,IAAI,EAAE,QAAQ,cAAc;IAC1B,EAAE,eAAe;IACjB,OAAO,CAAC;GACV,OAAO,IAAI,EAAE,QAAQ,aAAa;IAChC,EAAE,eAAe;IACjB,OAAO,EAAE;GACX;EACF;EACe;EACA;EACF;EACb,iBAAiB;EACR;EACT,sBAAsB;GACpB,SAAS,UAAU;EACrB;EACA,sBAAsB;GACpB,SAAS,UAAU;EACrB;EACA,WAAW,GAET,4EACA,sCACA,yDACA,SACF;EACA,OAAO,EAAE,QAAQ,YAAY;EAE5B,UAAA,MAAM,KAAK,MAAM,MAChB,oBAAC,cAAD;GAEU;GACR,OAAO;GACA;GACA;GACJ;GACS;GACP;GACO;GACF;GACF;GACH;GACM;GACX,UAAU;GAET,UAAA;EACW,GAhBP,CAgBO,CACf;CACE,CAAA;AAET"}
1
+ {"version":3,"file":"cylinder-carousel.js","names":[],"sources":["../../../src/components/motion/cylinder-carousel.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n Children,\n type ReactNode,\n type PointerEvent as ReactPointerEvent,\n type WheelEvent as ReactWheelEvent,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport {\n type AnimationPlaybackControls,\n animate,\n type MotionValue,\n motion,\n useMotionValue,\n useReducedMotion,\n useTransform,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { capturePointer, releasePointer, TOUCH_GESTURE_CLASS } from \"../../lib/touch\";\n\n// Carousel-specific: a soft spring that receives the release velocity, so a\n// flick keeps rolling freely, drifts past the snap point and eases back.\nconst GLIDE_SPRING = { stiffness: 40, damping: 20, mass: 3 };\n\n// How far a flick keeps rolling: projected items = release velocity * momentum.\nconst FLICK_MOMENTUM = 0.45;\nconst MAX_FLICK_ITEMS = 6;\n\nexport interface CylinderCarouselProps {\n children: ReactNode;\n /** Max item box size in px (square) at full size, i.e. at the container\n * edge. Balls shrink below this automatically so the row keeps breathing\n * room in narrow containers. */\n itemSize?: number;\n /** How many item slots span the container width. */\n visibleItems?: number;\n /** \"concave\" (default): inside of the cylinder — center ball smallest and\n * dipped, growing toward the edges. \"convex\": outside of the cylinder —\n * center ball biggest and raised, shrinking toward the edges. */\n variant?: \"concave\" | \"convex\";\n /** Scale of the smallest ball (center for concave, edges for convex);\n * the biggest reaches 1. */\n minScale?: number;\n /** Items rolled per item-width dragged — above 1 the wall outruns the\n * pointer, which reads as a lighter, freer roll. */\n dragSpeed?: number;\n /** Curve depth in px: for concave, how far the edge balls ride above the\n * center one (valley); for convex, how far below (arch). 0 = flat line.\n * Defaults to 35% of the item size. */\n arc?: number;\n /** Snap to the nearest item when the roll settles. */\n snap?: boolean;\n /** Roll on its own until interacted with. */\n autoRotate?: boolean;\n /** Auto-roll speed in items per second. */\n autoRotateSpeed?: number;\n defaultIndex?: number;\n onIndexChange?: (index: number) => void;\n /** Stage height in px. Defaults to `itemSize`. */\n height?: number;\n className?: string;\n}\n\n// The frame edge sits at this wall angle; how far the wall curves in frame.\nconst THETA_EDGE = (72 * Math.PI) / 180;\n// Wall angle past which a ball is parked far off-stage (always hidden there).\nconst THETA_CLAMP = (95 * Math.PI) / 180;\n\n/**\n * One ball on the inside wall of the cylinder, rendered through a single\n * perspective projection: the ball sits at wall angle θ, the camera slightly\n * above the ball line, so horizontal position, size and height all share one\n * 1/(cosθ + k) depth term. Center = far wall: smallest, highest, moving\n * slowest; edges = nearest: full size, level, moving fastest, sliding off to\n * be clipped. Nothing overlaps, fades or reorders — the edge is the exit.\n */\nfunction CarouselBall({\n scroll,\n index,\n count,\n alpha,\n k,\n projection,\n gap,\n edgeOffset,\n minScale,\n convex,\n arc,\n halfWidth,\n itemSize,\n children,\n}: {\n scroll: MotionValue<number>;\n index: number;\n count: number;\n /** Wall angle per item step, in radians. */\n alpha: number;\n /** Camera distance term for the horizontal projection. */\n k: number;\n /** Projection strength: maps sinθ/(cosθ+k) to px so θE lands on the edge. */\n projection: number;\n /** Uniform slot width in px — convex spacing. */\n gap: number;\n /** Offset at which a ball's center sits on the container edge. */\n edgeOffset: number;\n minScale: number;\n convex: boolean;\n /** Curve depth in px between the center ball and the edge balls. */\n arc: number;\n halfWidth: number;\n itemSize: number;\n children: ReactNode;\n}) {\n // Nearest wrapped offset so items loop around continuously.\n const offset = useTransform(scroll, (s) => {\n let o = index - s;\n o -= Math.round(o / count) * count;\n return o;\n });\n // Concave spacing follows the interior perspective (slow, tight center);\n // convex pairs its big center balls with uniform spacing — the interior\n // projection would collapse them into each other.\n const x = useTransform(offset, (o) => {\n if (convex) return o * gap;\n const th = Math.max(-THETA_CLAMP, Math.min(THETA_CLAMP, o * alpha));\n return (projection * Math.sin(th)) / (Math.cos(th) + k);\n });\n // Linear in wall angle, not in depth (the depth curve is near-flat around\n // the center, which made the middle three read as equal): every step is\n // visibly bigger than the last — growing outward (concave) or inward\n // (convex).\n const scale = useTransform(offset, (o) => {\n const t = Math.min(Math.abs(o) / edgeOffset, THETA_CLAMP / THETA_EDGE);\n return convex ? 1 - (1 - minScale) * t : minScale + (1 - minScale) * t;\n });\n // Parabola centered on the stage — valley for concave (center ball dips\n // arc/2 below the midline, edges rise arc/2 above), arch for convex — and\n // deliberately unclamped: a ball keeps following the same curve as it\n // crosses the edge, so entries never pop.\n const y = useTransform(x, (px) => {\n const t = px / halfWidth;\n const valley = arc * (0.5 - t * t);\n return convex ? -valley : valley;\n });\n // Fully off-stage balls stop painting (matters for canvas/shader children).\n const visibility = useTransform(x, (px) =>\n Math.abs(px) > halfWidth + itemSize ? \"hidden\" : \"visible\",\n );\n\n return (\n <motion.div\n className=\"absolute top-1/2 left-1/2\"\n style={{\n x,\n y,\n scale,\n visibility,\n width: itemSize,\n height: itemSize,\n marginLeft: -itemSize / 2,\n marginTop: -itemSize / 2,\n }}\n >\n {children}\n </motion.div>\n );\n}\n\nexport function CylinderCarousel({\n children,\n itemSize = 200,\n visibleItems = 5,\n variant = \"concave\",\n minScale = 0.55,\n dragSpeed = 1.5,\n arc: arcProp,\n snap = true,\n autoRotate = false,\n autoRotateSpeed = 0.4,\n defaultIndex = 0,\n onIndexChange,\n height,\n className,\n}: CylinderCarouselProps) {\n const reduce = useReducedMotion() ?? false;\n const items = Children.toArray(children);\n const count = items.length;\n\n const stageRef = useRef<HTMLDivElement>(null);\n const [width, setWidth] = useState(0);\n useEffect(() => {\n const el = stageRef.current;\n if (!el) return;\n const ro = new ResizeObserver(([entry]) => {\n setWidth(entry.contentRect.width);\n });\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n // Sized so `visibleItems` balls sit fully in frame and the next one out on\n // each side straddles the container edge, half visible.\n const stageWidth = width || 800;\n const halfWidth = stageWidth / 2;\n const edgeOffset = (visibleItems + 1) / 2;\n\n // Fit: the resting row's diameters may take at most ~66% of the stage — the\n // rest is air between balls plus the half-visible ball on each edge.\n // `itemSize` only caps the result.\n const convex = variant === \"convex\";\n let scaleSum = 0;\n for (let i = 0; i < visibleItems; i++) {\n const t = Math.abs(i - (visibleItems - 1) / 2) / edgeOffset;\n scaleSum += convex ? 1 - (1 - minScale) * t : minScale + (1 - minScale) * t;\n }\n const size = Math.min(itemSize, (stageWidth * 0.65) / scaleSum);\n\n const gap = stageWidth / (visibleItems + 1);\n const arc = arcProp ?? size * 0.35;\n\n // Perspective constants. The ball one slot past the frame edge sits at wall\n // angle THETA_EDGE with its center right on the container edge — scale 1,\n // half of it in view; k falls out of the requested minScale (clamped so the\n // projection stays monotonic up to THETA_CLAMP).\n const alpha = THETA_EDGE / edgeOffset;\n const k = Math.max(0.2, (minScale - Math.cos(THETA_EDGE)) / (1 - minScale));\n const projection = (halfWidth * (Math.cos(THETA_EDGE) + k)) / Math.sin(THETA_EDGE);\n\n // scroll is in item units (continuous); item i sits at x = (i - scroll) * gap.\n // Drags write it 1:1 so the wall sticks to the pointer; releases hand the\n // pointer velocity to a soft spring so the roll glides on and settles free.\n const scroll = useMotionValue(defaultIndex);\n const indexRef = useRef(defaultIndex);\n const [, setActiveIndex] = useState(defaultIndex);\n const glideRef = useRef<AnimationPlaybackControls | null>(null);\n const draggingRef = useRef(false);\n const hoverRef = useRef(false);\n\n useEffect(() => {\n if (count === 0) return;\n const unsub = scroll.on(\"change\", (v) => {\n const idx = ((Math.round(v) % count) + count) % count;\n if (idx !== indexRef.current) {\n indexRef.current = idx;\n setActiveIndex(idx);\n onIndexChange?.(idx);\n }\n });\n return unsub;\n }, [scroll, count, onIndexChange]);\n\n const stopGlide = useCallback(() => {\n glideRef.current?.stop();\n glideRef.current = null;\n }, []);\n\n // Spring toward `to`, carrying `velocity` (items/s) through so motion never\n // steps — the roll leaves the finger at finger speed.\n const glideTo = useCallback(\n (to: number, velocity: number) => {\n stopGlide();\n if (reduce) {\n scroll.set(to);\n return;\n }\n glideRef.current = animate(scroll, to, {\n type: \"spring\",\n ...GLIDE_SPRING,\n velocity,\n restDelta: 0.001,\n restSpeed: 0.005,\n });\n },\n [scroll, stopGlide, reduce],\n );\n\n const settle = useCallback(\n (velocity: number) => {\n const projected =\n scroll.get() +\n Math.max(-MAX_FLICK_ITEMS, Math.min(MAX_FLICK_ITEMS, velocity * FLICK_MOMENTUM));\n glideTo(snap ? Math.round(projected) : projected, velocity);\n },\n [scroll, snap, glideTo],\n );\n\n const drag = useRef({\n startX: 0,\n startScroll: 0,\n lastX: 0,\n lastT: 0,\n prevX: 0,\n prevT: 0,\n });\n\n const onPointerDown = useCallback(\n (e: ReactPointerEvent) => {\n e.preventDefault();\n stopGlide();\n draggingRef.current = true;\n capturePointer(e.currentTarget, e.pointerId);\n const now = performance.now();\n drag.current = {\n startX: e.clientX,\n startScroll: scroll.get(),\n lastX: e.clientX,\n lastT: now,\n prevX: e.clientX,\n prevT: now,\n };\n },\n [scroll, stopGlide],\n );\n\n const onPointerMove = useCallback(\n (e: ReactPointerEvent) => {\n if (!draggingRef.current) return;\n const d = drag.current;\n scroll.set(d.startScroll - ((e.clientX - d.startX) * dragSpeed) / gap);\n d.prevX = d.lastX;\n d.prevT = d.lastT;\n d.lastX = e.clientX;\n d.lastT = performance.now();\n },\n [scroll, gap, dragSpeed],\n );\n\n const onPointerUp = useCallback(\n (e: ReactPointerEvent) => {\n if (!draggingRef.current) return;\n draggingRef.current = false;\n releasePointer(e.currentTarget, e.pointerId);\n const d = drag.current;\n const dt = d.lastT - d.prevT;\n const vpx = dt > 0 ? (d.lastX - d.prevX) / dt : 0; // px per ms\n settle((-vpx * dragSpeed * 1000) / gap); // items per second\n },\n [settle, gap, dragSpeed],\n );\n\n const rollBy = useCallback(\n (dir: number) => {\n glideTo(Math.round(scroll.get()) + dir, scroll.getVelocity());\n },\n [scroll, glideTo],\n );\n\n const wheelSettleRef = useRef<number | undefined>(undefined);\n const onWheel = useCallback(\n (e: ReactWheelEvent) => {\n stopGlide();\n const delta = Math.abs(e.deltaX) > Math.abs(e.deltaY) ? e.deltaX : e.deltaY;\n scroll.set(scroll.get() + delta / gap);\n if (wheelSettleRef.current) window.clearTimeout(wheelSettleRef.current);\n wheelSettleRef.current = window.setTimeout(() => settle(scroll.getVelocity()), 140);\n },\n [scroll, gap, settle, stopGlide],\n );\n\n useEffect(() => {\n if (!autoRotate || reduce || count === 0) return;\n let raf = 0;\n let last = performance.now();\n const tick = (now: number) => {\n const dt = (now - last) / 1000;\n last = now;\n if (!draggingRef.current && !hoverRef.current && !glideRef.current) {\n scroll.set(scroll.get() + autoRotateSpeed * dt);\n }\n raf = requestAnimationFrame(tick);\n };\n raf = requestAnimationFrame(tick);\n return () => cancelAnimationFrame(raf);\n }, [autoRotate, autoRotateSpeed, reduce, count, scroll]);\n\n const stageHeight = height ?? size;\n\n return (\n <div\n ref={stageRef}\n role=\"application\"\n aria-roledescription=\"carousel\"\n // biome-ignore lint/a11y/noNoninteractiveTabindex: focusable custom carousel widget\n tabIndex={0}\n onKeyDown={(e) => {\n if (e.key === \"ArrowRight\") {\n e.preventDefault();\n rollBy(1);\n } else if (e.key === \"ArrowLeft\") {\n e.preventDefault();\n rollBy(-1);\n }\n }}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={onPointerUp}\n onWheel={onWheel}\n onPointerEnter={() => {\n hoverRef.current = true;\n }}\n onPointerLeave={() => {\n hoverRef.current = false;\n }}\n className={cn(\n // clip-path, not overflow: it also clips the GPU-composited balls\n \"relative w-full touch-none outline-none [clip-path:inset(0)]\",\n // The stage drives the roll from the press itself, so iOS must not\n // claim the same touch for its callout or a slide drag.\n TOUCH_GESTURE_CLASS,\n \"cursor-grab active:cursor-grabbing\",\n \"focus-visible:ring-2 focus-visible:ring-foreground/20\",\n className,\n )}\n style={{ height: stageHeight }}\n >\n {items.map((item, i) => (\n <CarouselBall\n key={i}\n scroll={scroll}\n index={i}\n count={count}\n alpha={alpha}\n k={k}\n projection={projection}\n gap={gap}\n edgeOffset={edgeOffset}\n minScale={minScale}\n convex={convex}\n arc={arc}\n halfWidth={halfWidth}\n itemSize={size}\n >\n {item}\n </CarouselBall>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;;;AA2BA,MAAM,eAAe;CAAE,WAAW;CAAI,SAAS;CAAI,MAAM;AAAE;AAG3D,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AAsCxB,MAAM,a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YAAY,IAAI;EAC3B,MAAM,QAAQ,QAAgB;GAC5B,MAAM,MAAM,MAAM,QAAQ;GAC1B,OAAO;GACP,IAAI,CAAC,YAAY,WAAW,CAAC,SAAS,WAAW,CAAC,SAAS,SACzD,OAAO,IAAI,OAAO,IAAI,IAAI,kBAAkB,EAAE;GAEhD,MAAM,sBAAsB,IAAI;EAClC;EACA,MAAM,sBAAsB,IAAI;EAChC,aAAa,qBAAqB,GAAG;CACvC,GAAG;EAAC;EAAY;EAAiB;EAAQ;EAAO;CAAM,CAAC;CAEvD,MAAM,cAAc,UAAU;CAE9B,OACE,oBAAC,OAAD;EACE,KAAK;EACL,MAAK;EACL,wBAAqB;EAErB,UAAU;EACV,YAAY,MAAM;GAChB,IAAI,EAAE,QAAQ,cAAc;IAC1B,EAAE,eAAe;IACjB,OAAO,CAAC;GACV,OAAO,IAAI,EAAE,QAAQ,aAAa;IAChC,EAAE,eAAe;IACjB,OAAO,EAAE;GACX;EACF;EACe;EACA;EACF;EACb,iBAAiB;EACR;EACT,sBAAsB;GACpB,SAAS,UAAU;EACrB;EACA,sBAAsB;GACpB,SAAS,UAAU;EACrB;EACA,WAAW,GAET,gEAGA,qBACA,sCACA,yDACA,SACF;EACA,OAAO,EAAE,QAAQ,YAAY;EAE5B,UAAA,MAAM,KAAK,MAAM,MAChB,oBAAC,cAAD;GAEU;GACR,OAAO;GACA;GACA;GACJ;GACS;GACP;GACO;GACF;GACF;GACH;GACM;GACX,UAAU;GAET,UAAA;EACW,GAhBP,CAgBO,CACf;CACE,CAAA;AAET"}
@@ -29,6 +29,12 @@ interface ExpandableActionBarProps {
29
29
  activeId?: string;
30
30
  onAction?: (item: ExpandableActionBarItem) => void;
31
31
  size?: ExpandableActionBarSize;
32
+ /**
33
+ * Expand when a pointer that hovers rests on the bar. Default true. It also
34
+ * governs the touch equivalent: with no hover to reveal the labels, the
35
+ * first tap expands the bar and runs no action, and the second one acts.
36
+ * Set false to make every tap and click act immediately.
37
+ */
32
38
  expandOnHover?: boolean;
33
39
  expandOnFocus?: boolean;
34
40
  collapseDelay?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"expandable-action-bar.d.ts","names":[],"sources":["../../../src/components/motion/expandable-action-bar.tsx"],"mappings":";;KAiBY;KAEA;EACV;EACA,OAAO;EACP,MAAM;EACN;EACA;EACA;EACA,QAAQ;EACR,WAAW;;KAGD;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf,OAAO;EACP;EACA;EACA,oBAAoB;EACpB;EACA,YAAY,MAAM;EAClB,OAAO;EACP;EACA;EACA;EACA;EACA,aAAa;EACb,cACE,MAAM,yBACN;IAAS;IAAmB;QACzB;;iBAwDS,sBACd,OACA,UACA,iBACA,kBACA,UACA,UACA,MACA,eACA,eACA,eACA,WACA,YACA,cACC,2CAAwB,IAAA;iBAmMX,uBAAuB,OAAO;;;;;cAAA"}
1
+ {"version":3,"file":"expandable-action-bar.d.ts","names":[],"sources":["../../../src/components/motion/expandable-action-bar.tsx"],"mappings":";;KAqBY;KAEA;EACV;EACA,OAAO;EACP,MAAM;EACN;EACA;EACA;EACA,QAAQ;EACR,WAAW;;KAGD;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf,OAAO;EACP;EACA;EACA,oBAAoB;EACpB;EACA,YAAY,MAAM;EAClB,OAAO;;;;;;;EAOP;EACA;EACA;EACA;EACA,aAAa;EACb,cACE,MAAM,yBACN;IAAS;IAAmB;QACzB;;iBAwDS,sBACd,OACA,UACA,iBACA,kBACA,UACA,UACA,MACA,eACA,eACA,eACA,WACA,YACA,cACC,2CAAwB,IAAA;iBAyQX,uBAAuB,OAAO;;;;;cAAA"}
@@ -1,4 +1,7 @@
1
1
  "use client";
2
+ import { useDismiss } from "../../hooks/use-dismiss.js";
3
+ import { useHoverGesture } from "../../hooks/use-hover-gesture.js";
4
+ import { useTapGesture } from "../../hooks/use-tap-gesture.js";
2
5
  import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
3
6
  import { cn } from "@kumix/utils";
4
7
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -45,7 +48,11 @@ function ExpandableActionBar({ items, expanded, defaultExpanded = false, onExpan
45
48
  onExpandedChange
46
49
  });
47
50
  const [hoveredId, setHoveredId] = useState(null);
51
+ const [tapExpanded, setTapExpanded] = useState(false);
48
52
  const collapseTimer = useRef(null);
53
+ const trackRef = useRef(null);
54
+ const tap = useTapGesture();
55
+ const hover = useHoverGesture();
49
56
  const clearCollapseTimer = useCallback(() => {
50
57
  if (collapseTimer.current) window.clearTimeout(collapseTimer.current);
51
58
  collapseTimer.current = null;
@@ -59,6 +66,7 @@ function ExpandableActionBar({ items, expanded, defaultExpanded = false, onExpan
59
66
  const timer = window.setTimeout(() => {
60
67
  setIsExpanded(false);
61
68
  setHoveredId(null);
69
+ setTapExpanded(false);
62
70
  }, collapseDelay);
63
71
  collapseTimer.current = timer;
64
72
  }, [
@@ -67,10 +75,17 @@ function ExpandableActionBar({ items, expanded, defaultExpanded = false, onExpan
67
75
  setIsExpanded
68
76
  ]);
69
77
  useEffect(() => clearCollapseTimer, [clearCollapseTimer]);
70
- const onRootMouseEnter = () => {
71
- if (expandOnHover) open();
78
+ const wasExpanded = useRef(isExpanded);
79
+ useEffect(() => {
80
+ if (wasExpanded.current && !isExpanded) setTapExpanded(false);
81
+ wasExpanded.current = isExpanded;
82
+ }, [isExpanded]);
83
+ useDismiss(tapExpanded && isExpanded, close, trackRef, { behavior: "consume" });
84
+ const onRootPointerEnter = (event) => {
85
+ if (hover.enter(event) && expandOnHover) open();
72
86
  };
73
- const onRootMouseLeave = () => {
87
+ const onRootPointerLeave = (event) => {
88
+ if (!hover.leave(event)) return;
74
89
  setHoveredId(null);
75
90
  if (expandOnHover) close();
76
91
  };
@@ -86,15 +101,16 @@ function ExpandableActionBar({ items, expanded, defaultExpanded = false, onExpan
86
101
  id: layoutId,
87
102
  children: /* @__PURE__ */ jsx(motion.div, {
88
103
  layout: "size",
89
- onMouseEnter: onRootMouseEnter,
90
- onMouseLeave: onRootMouseLeave,
104
+ onPointerEnter: onRootPointerEnter,
105
+ onPointerLeave: onRootPointerLeave,
91
106
  onFocus: onRootFocus,
92
107
  onBlur: onRootBlur,
93
108
  transition: ITEM_TRANSITION,
94
- className: cn("inline-flex", classNames?.root, className),
109
+ className: cn("inline-flex max-w-full", classNames?.root, className),
95
110
  children: /* @__PURE__ */ jsx(motion.div, {
111
+ ref: trackRef,
96
112
  layout: "size",
97
- className: cn("relative inline-flex items-center overflow-hidden rounded-full border border-border bg-card/90 shadow-2xl backdrop-blur-xl", SIZE_CLASS[size], classNames?.track),
113
+ className: cn("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", SIZE_CLASS[size], classNames?.track),
98
114
  transition: ITEM_TRANSITION,
99
115
  children: items.map((item) => {
100
116
  const isActive = item.active || activeId === item.id;
@@ -104,18 +120,31 @@ function ExpandableActionBar({ items, expanded, defaultExpanded = false, onExpan
104
120
  type: "button",
105
121
  disabled: item.disabled,
106
122
  title: typeof item.label === "string" ? item.label : void 0,
107
- onMouseEnter: () => {
123
+ onPointerEnter: (event) => {
124
+ if (!hover.enter(event)) return;
108
125
  clearCollapseTimer();
109
126
  setHoveredId(item.id);
110
127
  },
128
+ onPointerDown: (event) => {
129
+ tap.start(event, isExpanded);
130
+ },
131
+ onPointerCancel: tap.drop,
132
+ onKeyDown: tap.drop,
111
133
  onClick: (event) => {
112
134
  event.currentTarget.blur();
135
+ const gesture = tap.take();
136
+ if (gesture !== null && gesture.pointerType !== "mouse" && !gesture.state && !tapExpanded && expandOnHover) {
137
+ setTapExpanded(true);
138
+ open();
139
+ setHoveredId(item.id);
140
+ return;
141
+ }
113
142
  item.onClick?.();
114
143
  onAction?.(item);
115
144
  },
116
145
  whileTap: reduce || item.disabled ? void 0 : { scale: .96 },
117
146
  transition: ITEM_TRANSITION,
118
- className: cn("relative isolate inline-flex 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),
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),
119
148
  children: [isHighlighted ? /* @__PURE__ */ jsx(motion.span, {
120
149
  layoutId: "action-bar-highlight",
121
150
  className: "absolute inset-0 -z-10 rounded-full bg-primary/[0.07]",
@@ -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 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\";\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 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 const collapseTimer = useRef<number | null>(null);\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 }, collapseDelay);\n collapseTimer.current = timer;\n }, [clearCollapseTimer, collapseDelay, setIsExpanded]);\n\n useEffect(() => clearCollapseTimer, [clearCollapseTimer]);\n\n const onRootMouseEnter = () => {\n if (expandOnHover) open();\n };\n\n const onRootMouseLeave = () => {\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 onMouseEnter={onRootMouseEnter}\n onMouseLeave={onRootMouseLeave}\n onFocus={onRootFocus}\n onBlur={onRootBlur}\n transition={ITEM_TRANSITION}\n className={cn(\"inline-flex\", classNames?.root, className)}\n >\n <motion.div\n layout=\"size\"\n className={cn(\n \"relative inline-flex items-center overflow-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 onMouseEnter={() => {\n clearCollapseTimer();\n setHoveredId(item.id);\n }}\n onClick={(event: MouseEvent<HTMLButtonElement>) => {\n event.currentTarget.blur();\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 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":";;;;;;AA4DA,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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N,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;QACvC,WAAW,GACT,kDACA,YAAY,KACd;QAEC,UAAA,KAAK;OACK,CAAA;OAEZ,KAAK,WACJ,oBAAC,OAAO,MAAR;QACE,eAAa,CAAC;QACd,SAAS;SACP,OAAO,aAAa,SAAS;SAC7B,SAAS,aAAa,IAAI;SAC1B,YAAY,aAAa,IAAI;QAC/B;QACA,YAAY;QACZ,WAAW,GACT,8FACA,YAAY,QACd;QAEC,UAAA,KAAK;OACK,CAAA,IACX;OAEH,KAAK,QACJ,oBAAC,QAAD;QACE,WAAW,GACT,gJACA,CAAC,cAAc,8BACf,YAAY,KACd;QAEC,UAAA,KAAK;OACF,CAAA,IACJ;MACJ,EAAA,CAAA,CAES;KA1GR,GAAA,KAAK,EA0GG;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
+ {"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,aAA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,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,7 +1,7 @@
1
1
  import { ReactNode } from "react";
2
2
  import { HTMLMotionProps } from "motion/react";
3
3
  //#region src/components/motion/hold-action-button.d.ts
4
- interface HoldActionButtonProps extends Omit<HTMLMotionProps<"button">, "children" | "type" | "onClick" | "onPointerDown" | "onPointerUp" | "onPointerCancel" | "onPointerLeave" | "onKeyDown" | "onKeyUp"> {
4
+ interface HoldActionButtonProps extends Omit<HTMLMotionProps<"button">, "children" | "type" | "onClick" | "onPointerDown" | "onPointerUp" | "onPointerCancel" | "onPointerLeave" | "onPointerMove" | "onKeyDown" | "onKeyUp"> {
5
5
  children: ReactNode;
6
6
  type?: "vertical" | "horizontal";
7
7
  holdingLabel?: ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"hold-action-button.d.ts","names":[],"sources":["../../../src/components/motion/hold-action-button.tsx"],"mappings":";;;UAeiB,8BACP,KACN;EAWF,UAAU;EACV;EACA,eAAe;EACf,gBAAgB;EAChB;EACA;EACA;EACA;;cAGW,kCAAgB,0BAAA,KAAA,gDAAA,cAAA"}
1
+ {"version":3,"file":"hold-action-button.d.ts","names":[],"sources":["../../../src/components/motion/hold-action-button.tsx"],"mappings":";;;UAgBiB,8BACP,KACN;EAYF,UAAU;EACV;EACA,eAAe;EACf,gBAAgB;EAChB;EACA;EACA;EACA;;cAGW,kCAAgB,0BAAA,KAAA,gDAAA,cAAA"}