@kumix/ui 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/README.md +37 -30
  2. package/dist/{cascader-types-DVT-znZ-.d.ts → cascader-types-zhnUQ4sP.d.ts} +11 -3
  3. package/dist/cascader-types-zhnUQ4sP.d.ts.map +1 -0
  4. package/dist/components/agents/agent-code.js +1 -1
  5. package/dist/components/charts/candlestick-chart/context.d.ts.map +1 -1
  6. package/dist/components/charts/donut-chart/context.d.ts.map +1 -1
  7. package/dist/components/charts/liquidity-heatmap.d.ts.map +1 -1
  8. package/dist/components/charts/order-book.d.ts.map +1 -1
  9. package/dist/components/charts/treemap.d.ts.map +1 -1
  10. package/dist/components/charts/volume-profile.d.ts.map +1 -1
  11. package/dist/components/motion/action-swap.d.ts +1 -1
  12. package/dist/components/motion/action-swap.d.ts.map +1 -1
  13. package/dist/components/motion/action-swap.js +43 -20
  14. package/dist/components/motion/action-swap.js.map +1 -1
  15. package/dist/components/motion/animated-badge.d.ts +1 -1
  16. package/dist/components/motion/animated-badge.d.ts.map +1 -1
  17. package/dist/components/motion/animated-badge.js +60 -101
  18. package/dist/components/motion/animated-badge.js.map +1 -1
  19. package/dist/components/motion/animated-sidebar.js +1 -1
  20. package/dist/components/motion/animated-toast-stack.js +1 -1
  21. package/dist/components/motion/attachment-upload.js +1 -1
  22. package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
  23. package/dist/components/motion/availability-scheduler/day-row.js +1 -1
  24. package/dist/components/motion/availability-scheduler/index.js +1 -1
  25. package/dist/components/motion/bloom-menu.d.ts.map +1 -1
  26. package/dist/components/motion/bloom-menu.js +73 -8
  27. package/dist/components/motion/bloom-menu.js.map +1 -1
  28. package/dist/components/motion/bottom-sheet.d.ts.map +1 -1
  29. package/dist/components/motion/bottom-sheet.js +6 -10
  30. package/dist/components/motion/bottom-sheet.js.map +1 -1
  31. package/dist/components/motion/bouncy-accordion.d.ts.map +1 -1
  32. package/dist/components/motion/bouncy-accordion.js +35 -22
  33. package/dist/components/motion/bouncy-accordion.js.map +1 -1
  34. package/dist/components/motion/center-morph-modal.js +1 -1
  35. package/dist/components/motion/color-picker.d.ts.map +1 -1
  36. package/dist/components/motion/command-palette.js +1 -1
  37. package/dist/components/motion/context-menu.js +1 -1
  38. package/dist/components/motion/date-range-picker.d.ts.map +1 -1
  39. package/dist/components/motion/drawer.d.ts +1 -1
  40. package/dist/components/motion/drawer.d.ts.map +1 -1
  41. package/dist/components/motion/drawer.js +10 -10
  42. package/dist/components/motion/drawer.js.map +1 -1
  43. package/dist/components/motion/expandable-action-bar.d.ts.map +1 -1
  44. package/dist/components/motion/feedback-widget.js +4 -1
  45. package/dist/components/motion/feedback-widget.js.map +1 -1
  46. package/dist/components/motion/morphing-lightbox.d.ts.map +1 -1
  47. package/dist/components/motion/morphing-lightbox.js +1 -1
  48. package/dist/components/motion/morphing-modal.d.ts +6 -1
  49. package/dist/components/motion/morphing-modal.d.ts.map +1 -1
  50. package/dist/components/motion/morphing-modal.js +37 -5
  51. package/dist/components/motion/morphing-modal.js.map +1 -1
  52. package/dist/components/motion/morphing-search.js +1 -1
  53. package/dist/components/motion/morphing-tabs.js +1 -1
  54. package/dist/components/motion/otp-input.js +19 -11
  55. package/dist/components/motion/otp-input.js.map +1 -1
  56. package/dist/components/motion/popover-morph.d.ts +4 -3
  57. package/dist/components/motion/popover-morph.d.ts.map +1 -1
  58. package/dist/components/motion/popover-morph.js +47 -55
  59. package/dist/components/motion/popover-morph.js.map +1 -1
  60. package/dist/components/motion/popover.js +7 -1
  61. package/dist/components/motion/popover.js.map +1 -1
  62. package/dist/components/motion/prediction-market-card.js +1 -1
  63. package/dist/components/motion/prediction-market.js +1 -1
  64. package/dist/components/motion/project-folder.js +1 -1
  65. package/dist/components/motion/radio.d.ts +5 -1
  66. package/dist/components/motion/radio.d.ts.map +1 -1
  67. package/dist/components/motion/radio.js +53 -5
  68. package/dist/components/motion/radio.js.map +1 -1
  69. package/dist/components/motion/select-morph.d.ts +1 -1
  70. package/dist/components/motion/select-morph.d.ts.map +1 -1
  71. package/dist/components/motion/select-morph.js +89 -21
  72. package/dist/components/motion/select-morph.js.map +1 -1
  73. package/dist/components/motion/select.d.ts.map +1 -1
  74. package/dist/components/motion/select.js +153 -135
  75. package/dist/components/motion/select.js.map +1 -1
  76. package/dist/components/motion/shader-background.d.ts +3 -2
  77. package/dist/components/motion/shader-background.d.ts.map +1 -1
  78. package/dist/components/motion/shader-background.js +9 -3
  79. package/dist/components/motion/shader-background.js.map +1 -1
  80. package/dist/components/motion/shared-layout-bg.d.ts.map +1 -1
  81. package/dist/components/motion/shared-layout-bg.js +17 -3
  82. package/dist/components/motion/shared-layout-bg.js.map +1 -1
  83. package/dist/components/motion/swipeable-list.d.ts.map +1 -1
  84. package/dist/components/motion/swipeable-list.js +61 -4
  85. package/dist/components/motion/swipeable-list.js.map +1 -1
  86. package/dist/components/motion/table/row-handle.js +1 -1
  87. package/dist/components/motion/table/table-header.js +1 -1
  88. package/dist/components/motion/tabs.d.ts +12 -3
  89. package/dist/components/motion/tabs.d.ts.map +1 -1
  90. package/dist/components/motion/tabs.js +248 -26
  91. package/dist/components/motion/tabs.js.map +1 -1
  92. package/dist/components/motion/theme-toggle.js +1 -1
  93. package/dist/components/reui/alert.d.ts +1 -1
  94. package/dist/components/reui/autocomplete.d.ts +1 -1
  95. package/dist/components/reui/autocomplete.d.ts.map +1 -1
  96. package/dist/components/reui/autocomplete.js +1 -1
  97. package/dist/components/reui/autocomplete.js.map +1 -1
  98. package/dist/components/reui/badge.d.ts +2 -2
  99. package/dist/components/reui/cascader/cascader-async.d.ts +21 -5
  100. package/dist/components/reui/cascader/cascader-async.d.ts.map +1 -1
  101. package/dist/components/reui/cascader/cascader-async.js +61 -34
  102. package/dist/components/reui/cascader/cascader-async.js.map +1 -1
  103. package/dist/components/reui/cascader/cascader-columns.d.ts.map +1 -1
  104. package/dist/components/reui/cascader/cascader-columns.js +5 -2
  105. package/dist/components/reui/cascader/cascader-columns.js.map +1 -1
  106. package/dist/components/reui/cascader/cascader-context.d.ts +3 -1
  107. package/dist/components/reui/cascader/cascader-context.d.ts.map +1 -1
  108. package/dist/components/reui/cascader/cascader-context.js.map +1 -1
  109. package/dist/components/reui/cascader/cascader-i18n.d.ts +1 -1
  110. package/dist/components/reui/cascader/cascader-item.d.ts +1 -1
  111. package/dist/components/reui/cascader/cascader-lib.d.ts +34 -8
  112. package/dist/components/reui/cascader/cascader-lib.d.ts.map +1 -1
  113. package/dist/components/reui/cascader/cascader-lib.js +145 -29
  114. package/dist/components/reui/cascader/cascader-lib.js.map +1 -1
  115. package/dist/components/reui/cascader/cascader-nav.d.ts +1 -1
  116. package/dist/components/reui/cascader/cascader-types.d.ts +1 -1
  117. package/dist/components/reui/cascader/cascader.d.ts +13 -8
  118. package/dist/components/reui/cascader/cascader.d.ts.map +1 -1
  119. package/dist/components/reui/cascader/cascader.js +31 -16
  120. package/dist/components/reui/cascader/cascader.js.map +1 -1
  121. package/dist/components/reui/code-block/code-block.d.ts.map +1 -1
  122. package/dist/components/reui/color-picker.js +1 -1
  123. package/dist/components/reui/data-grid/data-grid-cell-selection.d.ts.map +1 -1
  124. package/dist/components/reui/data-grid/data-grid-cell-selection.js +1 -0
  125. package/dist/components/reui/data-grid/data-grid-cell-selection.js.map +1 -1
  126. package/dist/components/reui/data-grid/data-grid-column-filter.d.ts.map +1 -1
  127. package/dist/components/reui/data-grid/data-grid-column-filter.js +1 -0
  128. package/dist/components/reui/data-grid/data-grid-column-filter.js.map +1 -1
  129. package/dist/components/reui/data-grid/data-grid-column-header.d.ts +6 -8
  130. package/dist/components/reui/data-grid/data-grid-column-header.d.ts.map +1 -1
  131. package/dist/components/reui/data-grid/data-grid-column-header.js +7 -8
  132. package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
  133. package/dist/components/reui/data-grid/data-grid-column-visibility.d.ts.map +1 -1
  134. package/dist/components/reui/data-grid/data-grid-column-visibility.js +1 -0
  135. package/dist/components/reui/data-grid/data-grid-column-visibility.js.map +1 -1
  136. package/dist/components/reui/data-grid/data-grid-pagination.d.ts.map +1 -1
  137. package/dist/components/reui/data-grid/data-grid-pagination.js +1 -0
  138. package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -1
  139. package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts.map +1 -1
  140. package/dist/components/reui/data-grid/data-grid-scroll-area.js +1 -0
  141. package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -1
  142. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts.map +1 -1
  143. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +3 -2
  144. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -1
  145. package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts.map +1 -1
  146. package/dist/components/reui/data-grid/data-grid-table-dnd.js +2 -1
  147. package/dist/components/reui/data-grid/data-grid-table-dnd.js.map +1 -1
  148. package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts.map +1 -1
  149. package/dist/components/reui/data-grid/data-grid-table-virtual.js +2 -1
  150. package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -1
  151. package/dist/components/reui/data-grid/data-grid-table.d.ts +6 -11
  152. package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -1
  153. package/dist/components/reui/data-grid/data-grid-table.js +22 -22
  154. package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
  155. package/dist/components/reui/data-grid/data-grid.d.ts +16 -1
  156. package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -1
  157. package/dist/components/reui/data-grid/data-grid.js +80 -22
  158. package/dist/components/reui/data-grid/data-grid.js.map +1 -1
  159. package/dist/components/reui/date-selector.d.ts.map +1 -1
  160. package/dist/components/reui/date-selector.js +21 -15
  161. package/dist/components/reui/date-selector.js.map +1 -1
  162. package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +3 -5
  163. package/dist/components/reui/event-calendar/event-calendar-agenda-view.js.map +1 -1
  164. package/dist/components/reui/event-calendar/event-calendar-nav.d.ts.map +1 -1
  165. package/dist/components/reui/event-calendar/event-calendar-nav.js +2 -2
  166. package/dist/components/reui/event-calendar/event-calendar-nav.js.map +1 -1
  167. package/dist/components/reui/event-calendar/event-calendar.d.ts.map +1 -1
  168. package/dist/components/reui/event-calendar/event-calendar.js +34 -31
  169. package/dist/components/reui/event-calendar/event-calendar.js.map +1 -1
  170. package/dist/components/reui/file-type.d.ts +302 -6
  171. package/dist/components/reui/file-type.d.ts.map +1 -1
  172. package/dist/components/reui/file-type.js +416 -13
  173. package/dist/components/reui/file-type.js.map +1 -1
  174. package/dist/components/reui/filters/filters-builder.d.ts +1 -1
  175. package/dist/components/reui/filters/filters-lib.d.ts +1 -1
  176. package/dist/components/reui/frame.d.ts +1 -1
  177. package/dist/components/reui/gantt/gantt-nav.d.ts.map +1 -1
  178. package/dist/components/reui/gantt/gantt-nav.js +2 -2
  179. package/dist/components/reui/gantt/gantt-nav.js.map +1 -1
  180. package/dist/components/reui/gantt/gantt.d.ts.map +1 -1
  181. package/dist/components/reui/gantt/gantt.js +5 -2
  182. package/dist/components/reui/gantt/gantt.js.map +1 -1
  183. package/dist/components/reui/icon-tile.d.ts +2 -2
  184. package/dist/components/reui/number-field.d.ts +3 -3
  185. package/dist/components/reui/phone-input.js +30 -27
  186. package/dist/components/reui/phone-input.js.map +1 -1
  187. package/dist/components/reui/rating.d.ts +1 -1
  188. package/dist/components/reui/time-picker.js +1 -1
  189. package/dist/components/ui/attachment.d.ts +2 -2
  190. package/dist/components/ui/badge.d.ts +1 -1
  191. package/dist/components/ui/bubble.d.ts +1 -1
  192. package/dist/components/ui/button.d.ts +2 -2
  193. package/dist/components/ui/chart.d.ts.map +1 -1
  194. package/dist/components/ui/code-block.d.ts +29 -0
  195. package/dist/components/ui/code-block.d.ts.map +1 -0
  196. package/dist/components/ui/code-block.js +124 -0
  197. package/dist/components/ui/code-block.js.map +1 -0
  198. package/dist/components/ui/empty.d.ts +1 -1
  199. package/dist/components/ui/item.d.ts +2 -2
  200. package/dist/components/ui/marker.d.ts +1 -1
  201. package/dist/components/ui/sidebar.d.ts +1 -1
  202. package/dist/components/ui/toggle.d.ts +1 -1
  203. package/dist/components/ui/trace.d.ts +21 -0
  204. package/dist/components/ui/trace.d.ts.map +1 -0
  205. package/dist/components/ui/trace.js +77 -0
  206. package/dist/components/ui/trace.js.map +1 -0
  207. package/dist/context-BYXeJQnz.d.ts.map +1 -1
  208. package/dist/{copy-menu-BXUh52bu.js → copy-menu-DOg9Jh-U.js} +2 -2
  209. package/dist/{copy-menu-BXUh52bu.js.map → copy-menu-DOg9Jh-U.js.map} +1 -1
  210. package/dist/hooks/use-focus-trap.d.ts +22 -0
  211. package/dist/hooks/use-focus-trap.d.ts.map +1 -0
  212. package/dist/hooks/use-focus-trap.js +80 -0
  213. package/dist/hooks/use-focus-trap.js.map +1 -0
  214. package/dist/hooks/use-highlighted-code.d.ts +5 -0
  215. package/dist/hooks/use-highlighted-code.d.ts.map +1 -0
  216. package/dist/hooks/use-highlighted-code.js +128 -0
  217. package/dist/hooks/use-highlighted-code.js.map +1 -0
  218. package/dist/hooks/use-listbox.d.ts +29 -0
  219. package/dist/hooks/use-listbox.d.ts.map +1 -0
  220. package/dist/hooks/use-listbox.js +75 -0
  221. package/dist/hooks/use-listbox.js.map +1 -0
  222. package/dist/tooltip-C01qUgsW.d.ts.map +1 -1
  223. package/package.json +8 -8
  224. package/dist/cascader-types-DVT-znZ-.d.ts.map +0 -1
@@ -293,13 +293,19 @@ function PopoverContent({ children, className }) {
293
293
  render
294
294
  ]);
295
295
  useMotionValueEvent(progress, "change", (p) => render(geoRef.current, p));
296
+ const [closedAtRest, setClosedAtRest] = useState(() => !open && progress.get() === 0);
297
+ if (open && closedAtRest) setClosedAtRest(false);
298
+ const handleAnimationComplete = useCallback(() => {
299
+ if (!open && progress.get() === 0) setClosedAtRest(true);
300
+ }, [open, progress]);
301
+ useMotionValueEvent(progress, "animationComplete", handleAnimationComplete);
296
302
  const hoverHandlers = triggerMode === "hover" ? makeHoverHandlers(panelHover, openHover, scheduleClose) : {};
297
303
  if (!portalReady) return null;
298
304
  return createPortal(/* @__PURE__ */ jsxs("div", {
299
305
  "data-popover-portal": "",
300
306
  className: "pointer-events-none fixed top-0 left-0 isolate z-9999 size-0",
301
307
  style: {
302
- visibility: layout ? "visible" : "hidden",
308
+ visibility: layout && !closedAtRest ? "visible" : "hidden",
303
309
  transform: `translate3d(${layout?.trigger.left ?? 0}px, ${layout?.trigger.top ?? 0}px, 0)`
304
310
  },
305
311
  children: [
@@ -1 +1 @@
1
- {"version":3,"file":"popover.js","names":[],"sources":["../../../src/components/motion/popover.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n cloneElement,\n createContext,\n isValidElement,\n type ReactElement,\n type ReactNode,\n type Ref,\n useCallback,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n animate,\n type MotionValue,\n useMotionValue,\n useMotionValueEvent,\n useReducedMotion,\n} from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useDismiss } from \"../../hooks/use-dismiss\";\nimport { type HoverGesture, useHoverGesture } from \"../../hooks/use-hover-gesture\";\nimport { useTapGesture } from \"../../hooks/use-tap-gesture\";\nimport { usePopoverPortalPosition } from \"./popover-position\";\n\ntype Side = \"top\" | \"bottom\";\ntype Align = \"start\" | \"center\" | \"end\";\ntype TriggerMode = \"click\" | \"hover\";\n\n// This morph needs less bounce than layout motion: too much overshoot makes\n// the liquid neck balloon past the final panel edges.\nconst GOO_OPEN_SPRING = {\n type: \"spring\",\n visualDuration: 0.3,\n bounce: 0.15,\n} as const;\nconst GOO_CLOSE_SPRING = {\n type: \"spring\",\n visualDuration: 0.21,\n bounce: 0.15,\n} as const;\nconst HOVER_CLOSE_DELAY = 120;\nconst CIRCLE_KAPPA = 0.5523;\n\n// `onPointerEnter`/`onPointerLeave` rather than the mouse pair: a tap fires\n// compatibility mouseenter/mouseleave that carry no pointerType at all, and\n// they are what made the panel flicker open and shut under a finger. The\n// gesture pairs the two, so the panel a pen tap opened is not closed again by\n// the boundary event that ends the same tap.\nfunction makeHoverHandlers(hover: HoverGesture, enter: () => void, leave: () => void) {\n return {\n onPointerEnter: (event: React.PointerEvent) => {\n if (hover.enter(event)) enter();\n },\n onPointerLeave: (event: React.PointerEvent) => {\n if (hover.leave(event)) leave();\n },\n };\n}\n\nconst lerp = (a: number, b: number, t: number) => a + (b - a) * t;\n\ninterface Rect {\n x: number;\n y: number;\n w: number;\n h: number;\n r: number;\n}\ninterface Geo {\n layerW: number;\n layerH: number;\n left: number;\n top: number;\n trigger: Rect;\n panel: Rect;\n}\n\n// Trigger rect and panel rect in a shared local coordinate box.\nfunction buildGeo(\n tW: number,\n tH: number,\n cW: number,\n cH: number,\n side: Side,\n align: Align,\n gap: number,\n panelRadius: number,\n): Geo {\n const py = side === \"bottom\" ? tH + gap : -(gap + cH);\n const px = align === \"start\" ? 0 : align === \"end\" ? tW - cW : (tW - cW) / 2;\n\n const left = Math.min(0, px);\n const top = Math.min(0, py);\n const layerW = Math.max(tW, px + cW) - left;\n const layerH = Math.max(tH, py + cH) - top;\n\n const triggerRadius = Math.min(tH / 2, panelRadius);\n\n return {\n layerW,\n layerH,\n left,\n top,\n trigger: { x: -left, y: -top, w: tW, h: tH, r: triggerRadius },\n panel: { x: px - left, y: py - top, w: cW, h: cH, r: panelRadius },\n };\n}\n\nfunction rectAtProgress(geo: Geo, progress: number): Rect {\n const trigger = geo.trigger;\n const panel = geo.panel;\n\n return {\n x: lerp(trigger.x, panel.x, progress),\n y: lerp(trigger.y, panel.y, progress),\n w: lerp(trigger.w, panel.w, progress),\n h: lerp(trigger.h, panel.h, progress),\n r: lerp(trigger.r, panel.r, progress),\n };\n}\n\nfunction insetFor(rect: Rect, layerW: number, layerH: number) {\n const top = rect.y;\n const right = layerW - (rect.x + rect.w);\n const bottom = layerH - (rect.y + rect.h);\n const left = rect.x;\n return `inset(${top}px ${right}px ${bottom}px ${left}px round ${rect.r}px)`;\n}\n\nfunction roundedRectShape(rect: Rect) {\n const radius = Math.max(0, Math.min(rect.r, rect.w / 2, rect.h / 2));\n const control = radius * CIRCLE_KAPPA;\n const x1 = rect.x;\n const y1 = rect.y;\n const x2 = rect.x + rect.w;\n const y2 = rect.y + rect.h;\n const px = (value: number) => `${value.toFixed(3)}px`;\n\n return (\n `shape(from ${px(x1 + radius)} ${px(y1)}, ` +\n `line to ${px(x2 - radius)} ${px(y1)}, ` +\n `curve to ${px(x2)} ${px(y1 + radius)} with ${px(x2 - radius + control)} ${px(y1)} / ${px(x2)} ${px(y1 + radius - control)}, ` +\n `line to ${px(x2)} ${px(y2 - radius)}, ` +\n `curve to ${px(x2 - radius)} ${px(y2)} with ${px(x2)} ${px(y2 - radius + control)} / ${px(x2 - radius + control)} ${px(y2)}, ` +\n `line to ${px(x1 + radius)} ${px(y2)}, ` +\n `curve to ${px(x1)} ${px(y2 - radius)} with ${px(x1 + radius - control)} ${px(y2)} / ${px(x1)} ${px(y2 - radius + control)}, ` +\n `line to ${px(x1)} ${px(y1 + radius)}, ` +\n `curve to ${px(x1 + radius)} ${px(y1)} with ${px(x1)} ${px(y1 + radius - control)} / ${px(x1 + radius - control)} ${px(y1)}, ` +\n \"close)\"\n );\n}\n\nfunction clipForProgress(geo: Geo, progress: number, supportsShape: boolean) {\n const rect = rectAtProgress(geo, progress);\n return supportsShape ? roundedRectShape(rect) : insetFor(rect, geo.layerW, geo.layerH);\n}\n\nfunction roundedRectPath(rect: Rect) {\n const radius = Math.max(0, Math.min(rect.r, rect.w / 2, rect.h / 2));\n const n = (value: number) => value.toFixed(3);\n const x1 = rect.x;\n const y1 = rect.y;\n const x2 = rect.x + rect.w;\n const y2 = rect.y + rect.h;\n const arc = `A${n(radius)} ${n(radius)} 0 0 1`;\n\n // A zero radius makes every arc degenerate to a line, so this also draws\n // plain rectangles.\n return (\n `M${n(x1 + radius)} ${n(y1)}` +\n `H${n(x2 - radius)}${arc} ${n(x2)} ${n(y1 + radius)}` +\n `V${n(y2 - radius)}${arc} ${n(x2 - radius)} ${n(y2)}` +\n `H${n(x1 + radius)}${arc} ${n(x1)} ${n(y2 - radius)}` +\n `V${n(y1 + radius)}${arc} ${n(x1 + radius)} ${n(y1)}Z`\n );\n}\n\n// The goo layer is portalled above the page, so its copy of the trigger pill\n// would cover the real trigger's label and focus ring. Punching the trigger\n// back out keeps the real one visible and clips the blur to the layer box.\n// This is a clip path rather than a CSS mask on purpose: WebKit silently\n// ignores `mask: url(#id)` pointing at an SVG <mask> element, which left the\n// label hidden behind the goo in Safari.\nfunction triggerCutout(geo: Geo) {\n const layer = { x: 0, y: 0, w: geo.layerW, h: geo.layerH, r: 0 };\n return `path(evenodd, \"${roundedRectPath(layer)} ${roundedRectPath(geo.trigger)}\")`;\n}\n\ninterface PopoverContextValue {\n open: boolean;\n setOpen: (open: boolean) => void;\n toggle: () => void;\n openHover: () => void;\n scheduleClose: () => void;\n triggerMode: TriggerMode;\n side: Side;\n align: Align;\n gap: number;\n panelRadius: number;\n gooStrength: number;\n reduce: boolean;\n gooId: string;\n contentId: string;\n progress: MotionValue<number>;\n triggerRef: React.MutableRefObject<HTMLElement | null>;\n contentRef: React.MutableRefObject<HTMLDivElement | null>;\n}\n\nconst PopoverContext = createContext<PopoverContextValue | null>(null);\n\nfunction usePopoverContext(component: string) {\n const ctx = useContext(PopoverContext);\n if (!ctx) throw new Error(`${component} must be used within <Popover>`);\n return ctx;\n}\n\nexport interface PopoverProps {\n children: ReactNode;\n /** Controlled open state. */\n open?: boolean;\n /** Uncontrolled initial open state. */\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** How the popover is summoned. Default \"click\". */\n trigger?: TriggerMode;\n /** Which side of the trigger the panel oozes out of. Default \"bottom\". */\n side?: Side;\n /** Alignment along the trigger's edge. Default \"center\". */\n align?: Align;\n /** Gap between trigger and panel, in px — the length of the gooey neck. Default 14. */\n sideOffset?: number;\n /** Corner radius of the open panel, in px. Default 16. */\n panelRadius?: number;\n /** Blur radius feeding the goo filter — higher melts more. Default 8. */\n gooStrength?: number;\n className?: string;\n}\n\nexport function Popover({\n children,\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n trigger = \"click\",\n side = \"bottom\",\n align = \"center\",\n sideOffset = 14,\n panelRadius = 16,\n gooStrength = 8,\n className,\n}: PopoverProps) {\n const reduce = useReducedMotion() ?? false;\n const gooId = useId().replace(/:/g, \"\");\n const contentId = useId();\n const rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const closeTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const rootHover = useHoverGesture();\n const progress = useMotionValue(defaultOpen ? 1 : 0);\n\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const controlled = controlledOpen !== undefined;\n const open = controlled ? controlledOpen : internalOpen;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!controlled) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [controlled, onOpenChange],\n );\n\n const cancelClose = useCallback(() => {\n if (closeTimer.current) {\n clearTimeout(closeTimer.current);\n closeTimer.current = null;\n }\n }, []);\n\n const openHover = useCallback(() => {\n cancelClose();\n setOpen(true);\n }, [cancelClose, setOpen]);\n\n const scheduleClose = useCallback(() => {\n cancelClose();\n closeTimer.current = setTimeout(() => setOpen(false), HOVER_CLOSE_DELAY);\n }, [cancelClose, setOpen]);\n\n const toggle = useCallback(() => setOpen(!open), [setOpen, open]);\n\n useEffect(() => () => cancelClose(), [cancelClose]);\n\n useEffect(() => {\n const animation = animate(\n progress,\n open ? 1 : 0,\n reduce ? { duration: 0 } : open ? GOO_OPEN_SPRING : GOO_CLOSE_SPRING,\n );\n return () => animation.stop();\n }, [open, progress, reduce]);\n\n // The panel is a `role=\"dialog\"` and goes inert the moment it closes, so\n // focus cannot be left sitting inside it: Escape hands it back to the\n // trigger, the way the ARIA dialog pattern asks. A pointer dismissal takes\n // the focus onward itself when it lands on something focusable — this only\n // catches the case where it would otherwise be stranded.\n const close = useCallback(() => {\n setOpen(false);\n const focused = document.activeElement;\n const inPanel = focused instanceof HTMLElement && contentRef.current?.contains(focused);\n if (inPanel) triggerRef.current?.focus();\n }, [setOpen]);\n // The panel is portalled, so both trees participate in outside detection.\n const ignoreContent = useCallback(\n (target: Element) => Boolean(contentRef.current?.contains(target)),\n [],\n );\n // A hover trigger opens on tap as well now, so it needs the same outside\n // dismissal the click trigger always had. The gesture passes through to\n // whatever it landed on, which is the light-dismiss bargain the platform's\n // own popovers strike.\n useDismiss(open, close, rootRef, { ignore: ignoreContent });\n\n const ctx = useMemo<PopoverContextValue>(\n () => ({\n open,\n setOpen,\n toggle,\n openHover,\n scheduleClose,\n triggerMode: trigger,\n side,\n align,\n gap: sideOffset,\n panelRadius,\n gooStrength,\n reduce,\n gooId,\n contentId,\n progress,\n triggerRef,\n contentRef,\n }),\n [\n open,\n setOpen,\n toggle,\n openHover,\n scheduleClose,\n trigger,\n side,\n align,\n sideOffset,\n panelRadius,\n gooStrength,\n reduce,\n gooId,\n contentId,\n progress,\n ],\n );\n\n const hoverHandlers =\n trigger === \"hover\" ? makeHoverHandlers(rootHover, openHover, scheduleClose) : {};\n\n return (\n <PopoverContext.Provider value={ctx}>\n <div\n ref={rootRef}\n className={cn(\"relative isolate inline-flex\", className)}\n {...hoverHandlers}\n >\n {children}\n </div>\n </PopoverContext.Provider>\n );\n}\n\nfunction mergeRefs<T>(...refs: Array<Ref<T> | undefined>) {\n return (node: T | null) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") ref(node);\n else if (ref && typeof ref === \"object\")\n (ref as React.MutableRefObject<T | null>).current = node;\n }\n };\n}\n\nexport interface PopoverTriggerProps {\n /** A single focusable element (e.g. a Button) that opens the popover. */\n children: ReactElement;\n}\n\nexport function PopoverTrigger({ children }: PopoverTriggerProps) {\n const ctx = usePopoverContext(\"PopoverTrigger\");\n // What the last gesture on the trigger was, and whether the panel was\n // already open when it started. A click reports neither.\n const tap = useTapGesture<boolean>();\n\n if (!isValidElement(children)) return children;\n\n const child = children as ReactElement<Record<string, unknown>>;\n const childProps = child.props;\n const childRef = (childProps as { ref?: Ref<HTMLElement> }).ref;\n\n const compose =\n <E extends { defaultPrevented?: boolean }>(name: string, handler: (event: E) => void) =>\n (event: E) => {\n (childProps[name] as ((e: unknown) => void) | undefined)?.(event);\n if (!event.defaultPrevented) handler(event);\n };\n\n // Observation, not action. `compose` steps aside for a child that handled\n // the event itself, which is right for anything that *does* something — but\n // a child preventing the pointerdown default (to hold focus, say) has not\n // said the gesture didn't happen. Skipping the record there left the panel\n // reading whatever the gesture before it had put in.\n const observe =\n <E,>(name: string, handler: (event: E) => void) =>\n (event: E) => {\n (childProps[name] as ((e: unknown) => void) | undefined)?.(event);\n handler(event);\n };\n\n // The hover trigger keeps its hover path and *adds* a tap one, rather than\n // swapping mode on a device that reports a touchscreen: a touchscreen laptop\n // has both inputs and the mouse must keep working. A hovering pointer has\n // already opened the panel on its way in, and a keyboard press arrives with\n // no pointerdown behind it, so only a tap toggles here. Which panel state\n // the tap acts on is read from the gesture's start, because a browser that\n // focuses the trigger on contact would otherwise open it mid-gesture and let\n // the click close it again.\n const handlers: Record<string, unknown> =\n ctx.triggerMode === \"hover\"\n ? {\n onFocus: compose(\"onFocus\", ctx.openHover),\n onBlur: compose(\"onBlur\", ctx.scheduleClose),\n onPointerDown: observe<React.PointerEvent>(\"onPointerDown\", (event) =>\n tap.start(event, ctx.open),\n ),\n onPointerCancel: observe(\"onPointerCancel\", tap.drop),\n onKeyDown: observe(\"onKeyDown\", tap.drop),\n onClick: compose(\"onClick\", () => {\n const gesture = tap.take();\n if (!gesture || gesture.pointerType === \"mouse\") return;\n ctx.setOpen(!gesture.state);\n }),\n }\n : { onClick: compose(\"onClick\", ctx.toggle) };\n\n return cloneElement(child, {\n ...handlers,\n ref: mergeRefs(childRef, (node: HTMLElement | null) => {\n ctx.triggerRef.current = node;\n }),\n // Above the goo layer (z-[-1]) so the neck reads behind it.\n className: cn(\"relative z-0\", childProps.className as string | undefined),\n \"aria-haspopup\": \"dialog\",\n \"aria-expanded\": ctx.open,\n \"aria-controls\": ctx.open ? ctx.contentId : undefined,\n \"data-state\": ctx.open ? \"open\" : \"closed\",\n });\n}\n\nconst ALIGN_ORIGIN: Record<Align, string> = {\n start: \"left\",\n center: \"center\",\n end: \"right\",\n};\n\nexport interface PopoverContentProps {\n children: ReactNode;\n className?: string;\n}\n\nexport function PopoverContent({ children, className }: PopoverContentProps) {\n const ctx = usePopoverContext(\"PopoverContent\");\n const [portalReady, setPortalReady] = useState(false);\n const {\n side,\n align,\n gap,\n panelRadius,\n gooStrength,\n reduce,\n gooId,\n contentId,\n progress,\n triggerRef,\n contentRef,\n open,\n triggerMode,\n openHover,\n scheduleClose,\n } = ctx;\n\n const measureRef = contentRef;\n const panelHover = useHoverGesture();\n const blobRef = useRef<HTMLDivElement>(null);\n const clipRef = useRef<HTMLDivElement>(null);\n const geoRef = useRef<Geo | null>(null);\n const supportsShapeRef = useRef(false);\n const layout = usePopoverPortalPosition(triggerRef, measureRef, portalReady);\n\n useEffect(() => setPortalReady(true), []);\n\n const geo = useMemo(\n () =>\n buildGeo(\n layout?.trigger.width ?? 0,\n layout?.trigger.height ?? 0,\n layout?.content.width ?? 0,\n layout?.content.height ?? 0,\n side,\n align,\n gap,\n panelRadius,\n ),\n [layout, side, align, gap, panelRadius],\n );\n\n // Morph the same clip on the goo body and the content, so the whole popover\n // oozes as one and the text reveals with it.\n const render = useCallback((g: Geo | null, p: number) => {\n if (!g || g.layerW === 0) return;\n const clip = clipForProgress(g, p, supportsShapeRef.current);\n if (blobRef.current) blobRef.current.style.clipPath = clip;\n if (clipRef.current) clipRef.current.style.clipPath = clip;\n }, []);\n\n useLayoutEffect(() => {\n supportsShapeRef.current =\n typeof CSS !== \"undefined\" &&\n typeof CSS.supports === \"function\" &&\n CSS.supports(\"clip-path\", \"shape(from 0px 0px, line to 1px 1px, close)\");\n geoRef.current = geo;\n render(geo, progress.get());\n }, [geo, progress, render]);\n\n useMotionValueEvent(progress, \"change\", (p) => render(geoRef.current, p));\n\n const hoverHandlers =\n triggerMode === \"hover\" ? makeHoverHandlers(panelHover, openHover, scheduleClose) : {};\n\n // Match the server and first client render, then attach the portal after\n // hydration. This preserves SSR without regenerating the page on the client.\n if (!portalReady) return null;\n\n return createPortal(\n <div\n data-popover-portal=\"\"\n className=\"pointer-events-none fixed top-0 left-0 isolate z-9999 size-0\"\n style={{\n visibility: layout ? \"visible\" : \"hidden\",\n transform: `translate3d(${layout?.trigger.left ?? 0}px, ${layout?.trigger.top ?? 0}px, 0)`,\n }}\n >\n {/* Goo filter: blur, sharpen the alpha back into solid shapes, then lay\n the crisp original on top so blobs merge with liquid edges. */}\n <svg aria-hidden width=\"0\" height=\"0\" className=\"absolute\">\n <title>Popover visual effects</title>\n <defs>\n <filter id={gooId} x=\"-50%\" y=\"-50%\" width=\"200%\" height=\"200%\">\n <feGaussianBlur in=\"SourceGraphic\" stdDeviation={gooStrength} result=\"blur\" />\n <feColorMatrix\n in=\"blur\"\n mode=\"matrix\"\n values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 22 -10\"\n result=\"goo\"\n />\n <feComposite in=\"SourceGraphic\" in2=\"goo\" operator=\"atop\" />\n </filter>\n </defs>\n </svg>\n\n {/* Goo body: static trigger pill + morphing blob. */}\n <div\n aria-hidden\n className=\"pointer-events-none absolute z-[-1]\"\n style={{\n left: geo.left,\n top: geo.top,\n width: geo.layerW,\n height: geo.layerH,\n filter: reduce ? undefined : `url(#${gooId})`,\n clipPath: triggerCutout(geo),\n }}\n >\n <div\n className=\"absolute bg-popover\"\n style={{\n left: geo.trigger.x,\n top: geo.trigger.y,\n width: geo.trigger.w,\n height: geo.trigger.h,\n borderRadius: geo.trigger.r,\n }}\n />\n <div\n ref={blobRef}\n className=\"absolute inset-0 bg-popover\"\n style={{\n clipPath: clipForProgress(geo, progress.get(), false),\n }}\n />\n </div>\n\n {/* Content is clipped by the same morph. The portal wrapper stays\n pointer-transparent; only the fully open panel accepts interaction. */}\n <div\n className=\"pointer-events-none absolute z-10\"\n style={{\n left: geo.left,\n top: geo.top,\n width: geo.layerW,\n height: geo.layerH,\n }}\n >\n <div\n ref={clipRef}\n inert={!open}\n className=\"absolute inset-0\"\n style={{\n clipPath: clipForProgress(geo, progress.get(), false),\n pointerEvents: open ? \"auto\" : \"none\",\n }}\n >\n <div\n ref={measureRef}\n id={contentId}\n role=\"dialog\"\n {...hoverHandlers}\n style={{\n position: \"absolute\",\n left: geo.panel.x,\n top: geo.panel.y,\n transformOrigin: `${ALIGN_ORIGIN[align]} ${side === \"bottom\" ? \"top\" : \"bottom\"}`,\n }}\n className={cn(\n \"w-max max-w-[min(92vw,20rem)] p-4 text-popover-foreground outline-none\",\n className,\n )}\n >\n {children}\n </div>\n </div>\n </div>\n </div>,\n document.body,\n );\n}\n"],"mappings":";;;;;;;;;;;AAuCA,MAAM,kBAAkB;CACtB,MAAM;CACN,gBAAgB;CAChB,QAAQ;AACV;AACA,MAAM,mBAAmB;CACvB,MAAM;CACN,gBAAgB;CAChB,QAAQ;AACV;AACA,MAAM,oBAAoB;AAC1B,MAAM,eAAe;AAOrB,SAAS,kBAAkB,OAAqB,OAAmB,OAAmB;CACpF,OAAO;EACL,iBAAiB,UAA8B;GAC7C,IAAI,MAAM,MAAM,KAAK,GAAG,MAAM;EAChC;EACA,iBAAiB,UAA8B;GAC7C,IAAI,MAAM,MAAM,KAAK,GAAG,MAAM;EAChC;CACF;AACF;AAEA,MAAM,QAAQ,GAAW,GAAW,MAAc,KAAK,IAAI,KAAK;AAmBhE,SAAS,SACP,IACA,IACA,IACA,IACA,MACA,OACA,KACA,aACK;CACL,MAAM,KAAK,SAA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,IAAI;IACd;IAEA,UAAA,oBAAC,OAAD;KACE,KAAK;KACL,OAAO,CAAC;KACR,WAAU;KACV,OAAO;MACL,UAAU,gBAAgB,KAAK,SAAS,IAAI,GAAG,KAAK;MACpD,eAAe,OAAO,SAAS;KACjC;KAEA,UAAA,oBAAC,OAAD;MACE,KAAK;MACL,IAAI;MACJ,MAAK;MACL,GAAI;MACJ,OAAO;OACL,UAAU;OACV,MAAM,IAAI,MAAM;OAChB,KAAK,IAAI,MAAM;OACf,iBAAiB,GAAG,aAAa,OAAO,GAAG,SAAS,WAAW,QAAQ;MACzE;MACA,WAAW,GACT,0EACA,SACF;MAEC;KACE,CAAA;IACF,CAAA;GACF,CAAA;EACF;CACL,CAAA,GAAA,SAAS,IACX;AACF"}
1
+ {"version":3,"file":"popover.js","names":[],"sources":["../../../src/components/motion/popover.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n cloneElement,\n createContext,\n isValidElement,\n type ReactElement,\n type ReactNode,\n type Ref,\n useCallback,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n animate,\n type MotionValue,\n useMotionValue,\n useMotionValueEvent,\n useReducedMotion,\n} from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useDismiss } from \"../../hooks/use-dismiss\";\nimport { type HoverGesture, useHoverGesture } from \"../../hooks/use-hover-gesture\";\nimport { useTapGesture } from \"../../hooks/use-tap-gesture\";\nimport { usePopoverPortalPosition } from \"./popover-position\";\n\ntype Side = \"top\" | \"bottom\";\ntype Align = \"start\" | \"center\" | \"end\";\ntype TriggerMode = \"click\" | \"hover\";\n\n// This morph needs less bounce than layout motion: too much overshoot makes\n// the liquid neck balloon past the final panel edges.\nconst GOO_OPEN_SPRING = {\n type: \"spring\",\n visualDuration: 0.3,\n bounce: 0.15,\n} as const;\nconst GOO_CLOSE_SPRING = {\n type: \"spring\",\n visualDuration: 0.21,\n bounce: 0.15,\n} as const;\nconst HOVER_CLOSE_DELAY = 120;\nconst CIRCLE_KAPPA = 0.5523;\n\n// `onPointerEnter`/`onPointerLeave` rather than the mouse pair: a tap fires\n// compatibility mouseenter/mouseleave that carry no pointerType at all, and\n// they are what made the panel flicker open and shut under a finger. The\n// gesture pairs the two, so the panel a pen tap opened is not closed again by\n// the boundary event that ends the same tap.\nfunction makeHoverHandlers(hover: HoverGesture, enter: () => void, leave: () => void) {\n return {\n onPointerEnter: (event: React.PointerEvent) => {\n if (hover.enter(event)) enter();\n },\n onPointerLeave: (event: React.PointerEvent) => {\n if (hover.leave(event)) leave();\n },\n };\n}\n\nconst lerp = (a: number, b: number, t: number) => a + (b - a) * t;\n\ninterface Rect {\n x: number;\n y: number;\n w: number;\n h: number;\n r: number;\n}\ninterface Geo {\n layerW: number;\n layerH: number;\n left: number;\n top: number;\n trigger: Rect;\n panel: Rect;\n}\n\n// Trigger rect and panel rect in a shared local coordinate box.\nfunction buildGeo(\n tW: number,\n tH: number,\n cW: number,\n cH: number,\n side: Side,\n align: Align,\n gap: number,\n panelRadius: number,\n): Geo {\n const py = side === \"bottom\" ? tH + gap : -(gap + cH);\n const px = align === \"start\" ? 0 : align === \"end\" ? tW - cW : (tW - cW) / 2;\n\n const left = Math.min(0, px);\n const top = Math.min(0, py);\n const layerW = Math.max(tW, px + cW) - left;\n const layerH = Math.max(tH, py + cH) - top;\n\n const triggerRadius = Math.min(tH / 2, panelRadius);\n\n return {\n layerW,\n layerH,\n left,\n top,\n trigger: { x: -left, y: -top, w: tW, h: tH, r: triggerRadius },\n panel: { x: px - left, y: py - top, w: cW, h: cH, r: panelRadius },\n };\n}\n\nfunction rectAtProgress(geo: Geo, progress: number): Rect {\n const trigger = geo.trigger;\n const panel = geo.panel;\n\n return {\n x: lerp(trigger.x, panel.x, progress),\n y: lerp(trigger.y, panel.y, progress),\n w: lerp(trigger.w, panel.w, progress),\n h: lerp(trigger.h, panel.h, progress),\n r: lerp(trigger.r, panel.r, progress),\n };\n}\n\nfunction insetFor(rect: Rect, layerW: number, layerH: number) {\n const top = rect.y;\n const right = layerW - (rect.x + rect.w);\n const bottom = layerH - (rect.y + rect.h);\n const left = rect.x;\n return `inset(${top}px ${right}px ${bottom}px ${left}px round ${rect.r}px)`;\n}\n\nfunction roundedRectShape(rect: Rect) {\n const radius = Math.max(0, Math.min(rect.r, rect.w / 2, rect.h / 2));\n const control = radius * CIRCLE_KAPPA;\n const x1 = rect.x;\n const y1 = rect.y;\n const x2 = rect.x + rect.w;\n const y2 = rect.y + rect.h;\n const px = (value: number) => `${value.toFixed(3)}px`;\n\n return (\n `shape(from ${px(x1 + radius)} ${px(y1)}, ` +\n `line to ${px(x2 - radius)} ${px(y1)}, ` +\n `curve to ${px(x2)} ${px(y1 + radius)} with ${px(x2 - radius + control)} ${px(y1)} / ${px(x2)} ${px(y1 + radius - control)}, ` +\n `line to ${px(x2)} ${px(y2 - radius)}, ` +\n `curve to ${px(x2 - radius)} ${px(y2)} with ${px(x2)} ${px(y2 - radius + control)} / ${px(x2 - radius + control)} ${px(y2)}, ` +\n `line to ${px(x1 + radius)} ${px(y2)}, ` +\n `curve to ${px(x1)} ${px(y2 - radius)} with ${px(x1 + radius - control)} ${px(y2)} / ${px(x1)} ${px(y2 - radius + control)}, ` +\n `line to ${px(x1)} ${px(y1 + radius)}, ` +\n `curve to ${px(x1 + radius)} ${px(y1)} with ${px(x1)} ${px(y1 + radius - control)} / ${px(x1 + radius - control)} ${px(y1)}, ` +\n \"close)\"\n );\n}\n\nfunction clipForProgress(geo: Geo, progress: number, supportsShape: boolean) {\n const rect = rectAtProgress(geo, progress);\n return supportsShape ? roundedRectShape(rect) : insetFor(rect, geo.layerW, geo.layerH);\n}\n\nfunction roundedRectPath(rect: Rect) {\n const radius = Math.max(0, Math.min(rect.r, rect.w / 2, rect.h / 2));\n const n = (value: number) => value.toFixed(3);\n const x1 = rect.x;\n const y1 = rect.y;\n const x2 = rect.x + rect.w;\n const y2 = rect.y + rect.h;\n const arc = `A${n(radius)} ${n(radius)} 0 0 1`;\n\n // A zero radius makes every arc degenerate to a line, so this also draws\n // plain rectangles.\n return (\n `M${n(x1 + radius)} ${n(y1)}` +\n `H${n(x2 - radius)}${arc} ${n(x2)} ${n(y1 + radius)}` +\n `V${n(y2 - radius)}${arc} ${n(x2 - radius)} ${n(y2)}` +\n `H${n(x1 + radius)}${arc} ${n(x1)} ${n(y2 - radius)}` +\n `V${n(y1 + radius)}${arc} ${n(x1 + radius)} ${n(y1)}Z`\n );\n}\n\n// The goo layer is portalled above the page, so its copy of the trigger pill\n// would cover the real trigger's label and focus ring. Punching the trigger\n// back out keeps the real one visible and clips the blur to the layer box.\n// This is a clip path rather than a CSS mask on purpose: WebKit silently\n// ignores `mask: url(#id)` pointing at an SVG <mask> element, which left the\n// label hidden behind the goo in Safari.\nfunction triggerCutout(geo: Geo) {\n const layer = { x: 0, y: 0, w: geo.layerW, h: geo.layerH, r: 0 };\n return `path(evenodd, \"${roundedRectPath(layer)} ${roundedRectPath(geo.trigger)}\")`;\n}\n\ninterface PopoverContextValue {\n open: boolean;\n setOpen: (open: boolean) => void;\n toggle: () => void;\n openHover: () => void;\n scheduleClose: () => void;\n triggerMode: TriggerMode;\n side: Side;\n align: Align;\n gap: number;\n panelRadius: number;\n gooStrength: number;\n reduce: boolean;\n gooId: string;\n contentId: string;\n progress: MotionValue<number>;\n triggerRef: React.MutableRefObject<HTMLElement | null>;\n contentRef: React.MutableRefObject<HTMLDivElement | null>;\n}\n\nconst PopoverContext = createContext<PopoverContextValue | null>(null);\n\nfunction usePopoverContext(component: string) {\n const ctx = useContext(PopoverContext);\n if (!ctx) throw new Error(`${component} must be used within <Popover>`);\n return ctx;\n}\n\nexport interface PopoverProps {\n children: ReactNode;\n /** Controlled open state. */\n open?: boolean;\n /** Uncontrolled initial open state. */\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** How the popover is summoned. Default \"click\". */\n trigger?: TriggerMode;\n /** Which side of the trigger the panel oozes out of. Default \"bottom\". */\n side?: Side;\n /** Alignment along the trigger's edge. Default \"center\". */\n align?: Align;\n /** Gap between trigger and panel, in px — the length of the gooey neck. Default 14. */\n sideOffset?: number;\n /** Corner radius of the open panel, in px. Default 16. */\n panelRadius?: number;\n /** Blur radius feeding the goo filter — higher melts more. Default 8. */\n gooStrength?: number;\n className?: string;\n}\n\nexport function Popover({\n children,\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n trigger = \"click\",\n side = \"bottom\",\n align = \"center\",\n sideOffset = 14,\n panelRadius = 16,\n gooStrength = 8,\n className,\n}: PopoverProps) {\n const reduce = useReducedMotion() ?? false;\n const gooId = useId().replace(/:/g, \"\");\n const contentId = useId();\n const rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const closeTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const rootHover = useHoverGesture();\n const progress = useMotionValue(defaultOpen ? 1 : 0);\n\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const controlled = controlledOpen !== undefined;\n const open = controlled ? controlledOpen : internalOpen;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!controlled) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [controlled, onOpenChange],\n );\n\n const cancelClose = useCallback(() => {\n if (closeTimer.current) {\n clearTimeout(closeTimer.current);\n closeTimer.current = null;\n }\n }, []);\n\n const openHover = useCallback(() => {\n cancelClose();\n setOpen(true);\n }, [cancelClose, setOpen]);\n\n const scheduleClose = useCallback(() => {\n cancelClose();\n closeTimer.current = setTimeout(() => setOpen(false), HOVER_CLOSE_DELAY);\n }, [cancelClose, setOpen]);\n\n const toggle = useCallback(() => setOpen(!open), [setOpen, open]);\n\n useEffect(() => () => cancelClose(), [cancelClose]);\n\n useEffect(() => {\n const animation = animate(\n progress,\n open ? 1 : 0,\n reduce ? { duration: 0 } : open ? GOO_OPEN_SPRING : GOO_CLOSE_SPRING,\n );\n return () => animation.stop();\n }, [open, progress, reduce]);\n\n // The panel is a `role=\"dialog\"` and goes inert the moment it closes, so\n // focus cannot be left sitting inside it: Escape hands it back to the\n // trigger, the way the ARIA dialog pattern asks. A pointer dismissal takes\n // the focus onward itself when it lands on something focusable — this only\n // catches the case where it would otherwise be stranded.\n const close = useCallback(() => {\n setOpen(false);\n const focused = document.activeElement;\n const inPanel = focused instanceof HTMLElement && contentRef.current?.contains(focused);\n if (inPanel) triggerRef.current?.focus();\n }, [setOpen]);\n // The panel is portalled, so both trees participate in outside detection.\n const ignoreContent = useCallback(\n (target: Element) => Boolean(contentRef.current?.contains(target)),\n [],\n );\n // A hover trigger opens on tap as well now, so it needs the same outside\n // dismissal the click trigger always had. The gesture passes through to\n // whatever it landed on, which is the light-dismiss bargain the platform's\n // own popovers strike.\n useDismiss(open, close, rootRef, { ignore: ignoreContent });\n\n const ctx = useMemo<PopoverContextValue>(\n () => ({\n open,\n setOpen,\n toggle,\n openHover,\n scheduleClose,\n triggerMode: trigger,\n side,\n align,\n gap: sideOffset,\n panelRadius,\n gooStrength,\n reduce,\n gooId,\n contentId,\n progress,\n triggerRef,\n contentRef,\n }),\n [\n open,\n setOpen,\n toggle,\n openHover,\n scheduleClose,\n trigger,\n side,\n align,\n sideOffset,\n panelRadius,\n gooStrength,\n reduce,\n gooId,\n contentId,\n progress,\n ],\n );\n\n const hoverHandlers =\n trigger === \"hover\" ? makeHoverHandlers(rootHover, openHover, scheduleClose) : {};\n\n return (\n <PopoverContext.Provider value={ctx}>\n <div\n ref={rootRef}\n className={cn(\"relative isolate inline-flex\", className)}\n {...hoverHandlers}\n >\n {children}\n </div>\n </PopoverContext.Provider>\n );\n}\n\nfunction mergeRefs<T>(...refs: Array<Ref<T> | undefined>) {\n return (node: T | null) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") ref(node);\n else if (ref && typeof ref === \"object\")\n (ref as React.MutableRefObject<T | null>).current = node;\n }\n };\n}\n\nexport interface PopoverTriggerProps {\n /** A single focusable element (e.g. a Button) that opens the popover. */\n children: ReactElement;\n}\n\nexport function PopoverTrigger({ children }: PopoverTriggerProps) {\n const ctx = usePopoverContext(\"PopoverTrigger\");\n // What the last gesture on the trigger was, and whether the panel was\n // already open when it started. A click reports neither.\n const tap = useTapGesture<boolean>();\n\n if (!isValidElement(children)) return children;\n\n const child = children as ReactElement<Record<string, unknown>>;\n const childProps = child.props;\n const childRef = (childProps as { ref?: Ref<HTMLElement> }).ref;\n\n const compose =\n <E extends { defaultPrevented?: boolean }>(name: string, handler: (event: E) => void) =>\n (event: E) => {\n (childProps[name] as ((e: unknown) => void) | undefined)?.(event);\n if (!event.defaultPrevented) handler(event);\n };\n\n // Observation, not action. `compose` steps aside for a child that handled\n // the event itself, which is right for anything that *does* something — but\n // a child preventing the pointerdown default (to hold focus, say) has not\n // said the gesture didn't happen. Skipping the record there left the panel\n // reading whatever the gesture before it had put in.\n const observe =\n <E,>(name: string, handler: (event: E) => void) =>\n (event: E) => {\n (childProps[name] as ((e: unknown) => void) | undefined)?.(event);\n handler(event);\n };\n\n // The hover trigger keeps its hover path and *adds* a tap one, rather than\n // swapping mode on a device that reports a touchscreen: a touchscreen laptop\n // has both inputs and the mouse must keep working. A hovering pointer has\n // already opened the panel on its way in, and a keyboard press arrives with\n // no pointerdown behind it, so only a tap toggles here. Which panel state\n // the tap acts on is read from the gesture's start, because a browser that\n // focuses the trigger on contact would otherwise open it mid-gesture and let\n // the click close it again.\n const handlers: Record<string, unknown> =\n ctx.triggerMode === \"hover\"\n ? {\n onFocus: compose(\"onFocus\", ctx.openHover),\n onBlur: compose(\"onBlur\", ctx.scheduleClose),\n onPointerDown: observe<React.PointerEvent>(\"onPointerDown\", (event) =>\n tap.start(event, ctx.open),\n ),\n onPointerCancel: observe(\"onPointerCancel\", tap.drop),\n onKeyDown: observe(\"onKeyDown\", tap.drop),\n onClick: compose(\"onClick\", () => {\n const gesture = tap.take();\n if (!gesture || gesture.pointerType === \"mouse\") return;\n ctx.setOpen(!gesture.state);\n }),\n }\n : { onClick: compose(\"onClick\", ctx.toggle) };\n\n return cloneElement(child, {\n ...handlers,\n ref: mergeRefs(childRef, (node: HTMLElement | null) => {\n ctx.triggerRef.current = node;\n }),\n // Above the goo layer (z-[-1]) so the neck reads behind it.\n className: cn(\"relative z-0\", childProps.className as string | undefined),\n \"aria-haspopup\": \"dialog\",\n \"aria-expanded\": ctx.open,\n \"aria-controls\": ctx.open ? ctx.contentId : undefined,\n \"data-state\": ctx.open ? \"open\" : \"closed\",\n });\n}\n\nconst ALIGN_ORIGIN: Record<Align, string> = {\n start: \"left\",\n center: \"center\",\n end: \"right\",\n};\n\nexport interface PopoverContentProps {\n children: ReactNode;\n className?: string;\n}\n\nexport function PopoverContent({ children, className }: PopoverContentProps) {\n const ctx = usePopoverContext(\"PopoverContent\");\n const [portalReady, setPortalReady] = useState(false);\n const {\n side,\n align,\n gap,\n panelRadius,\n gooStrength,\n reduce,\n gooId,\n contentId,\n progress,\n triggerRef,\n contentRef,\n open,\n triggerMode,\n openHover,\n scheduleClose,\n } = ctx;\n\n const measureRef = contentRef;\n const panelHover = useHoverGesture();\n const blobRef = useRef<HTMLDivElement>(null);\n const clipRef = useRef<HTMLDivElement>(null);\n const geoRef = useRef<Geo | null>(null);\n const supportsShapeRef = useRef(false);\n const layout = usePopoverPortalPosition(triggerRef, measureRef, portalReady);\n\n useEffect(() => setPortalReady(true), []);\n\n const geo = useMemo(\n () =>\n buildGeo(\n layout?.trigger.width ?? 0,\n layout?.trigger.height ?? 0,\n layout?.content.width ?? 0,\n layout?.content.height ?? 0,\n side,\n align,\n gap,\n panelRadius,\n ),\n [layout, side, align, gap, panelRadius],\n );\n\n // Morph the same clip on the goo body and the content, so the whole popover\n // oozes as one and the text reveals with it.\n const render = useCallback((g: Geo | null, p: number) => {\n if (!g || g.layerW === 0) return;\n const clip = clipForProgress(g, p, supportsShapeRef.current);\n if (blobRef.current) blobRef.current.style.clipPath = clip;\n if (clipRef.current) clipRef.current.style.clipPath = clip;\n }, []);\n\n useLayoutEffect(() => {\n supportsShapeRef.current =\n typeof CSS !== \"undefined\" &&\n typeof CSS.supports === \"function\" &&\n CSS.supports(\"clip-path\", \"shape(from 0px 0px, line to 1px 1px, close)\");\n geoRef.current = geo;\n render(geo, progress.get());\n }, [geo, progress, render]);\n\n useMotionValueEvent(progress, \"change\", (p) => render(geoRef.current, p));\n\n // While closed, the layer still paints its copy of the trigger pill, and the\n // cutout's antialiased edge leaves a faint rim around the real trigger. It\n // matches the page, but shows as hairlines over any dimmed backdrop below\n // the layer. Hide it once the close has settled, and show it again in the\n // render that opens.\n const [closedAtRest, setClosedAtRest] = useState(() => !open && progress.get() === 0);\n if (open && closedAtRest) setClosedAtRest(false);\n const handleAnimationComplete = useCallback(() => {\n if (!open && progress.get() === 0) setClosedAtRest(true);\n }, [open, progress]);\n useMotionValueEvent(progress, \"animationComplete\", handleAnimationComplete);\n\n const hoverHandlers =\n triggerMode === \"hover\" ? makeHoverHandlers(panelHover, openHover, scheduleClose) : {};\n\n // Match the server and first client render, then attach the portal after\n // hydration. This preserves SSR without regenerating the page on the client.\n if (!portalReady) return null;\n\n return createPortal(\n <div\n data-popover-portal=\"\"\n className=\"pointer-events-none fixed top-0 left-0 isolate z-9999 size-0\"\n style={{\n visibility: layout && !closedAtRest ? \"visible\" : \"hidden\",\n transform: `translate3d(${layout?.trigger.left ?? 0}px, ${layout?.trigger.top ?? 0}px, 0)`,\n }}\n >\n {/* Goo filter: blur, sharpen the alpha back into solid shapes, then lay\n the crisp original on top so blobs merge with liquid edges. */}\n <svg aria-hidden width=\"0\" height=\"0\" className=\"absolute\">\n <title>Popover visual effects</title>\n <defs>\n <filter id={gooId} x=\"-50%\" y=\"-50%\" width=\"200%\" height=\"200%\">\n <feGaussianBlur in=\"SourceGraphic\" stdDeviation={gooStrength} result=\"blur\" />\n <feColorMatrix\n in=\"blur\"\n mode=\"matrix\"\n values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 22 -10\"\n result=\"goo\"\n />\n <feComposite in=\"SourceGraphic\" in2=\"goo\" operator=\"atop\" />\n </filter>\n </defs>\n </svg>\n\n {/* Goo body: static trigger pill + morphing blob. */}\n <div\n aria-hidden\n className=\"pointer-events-none absolute z-[-1]\"\n style={{\n left: geo.left,\n top: geo.top,\n width: geo.layerW,\n height: geo.layerH,\n filter: reduce ? undefined : `url(#${gooId})`,\n clipPath: triggerCutout(geo),\n }}\n >\n <div\n className=\"absolute bg-popover\"\n style={{\n left: geo.trigger.x,\n top: geo.trigger.y,\n width: geo.trigger.w,\n height: geo.trigger.h,\n borderRadius: geo.trigger.r,\n }}\n />\n <div\n ref={blobRef}\n className=\"absolute inset-0 bg-popover\"\n style={{\n clipPath: clipForProgress(geo, progress.get(), false),\n }}\n />\n </div>\n\n {/* Content is clipped by the same morph. The portal wrapper stays\n pointer-transparent; only the fully open panel accepts interaction. */}\n <div\n className=\"pointer-events-none absolute z-10\"\n style={{\n left: geo.left,\n top: geo.top,\n width: geo.layerW,\n height: geo.layerH,\n }}\n >\n <div\n ref={clipRef}\n inert={!open}\n className=\"absolute inset-0\"\n style={{\n clipPath: clipForProgress(geo, progress.get(), false),\n pointerEvents: open ? \"auto\" : \"none\",\n }}\n >\n <div\n ref={measureRef}\n id={contentId}\n role=\"dialog\"\n {...hoverHandlers}\n style={{\n position: \"absolute\",\n left: geo.panel.x,\n top: geo.panel.y,\n transformOrigin: `${ALIGN_ORIGIN[align]} ${side === \"bottom\" ? \"top\" : \"bottom\"}`,\n }}\n className={cn(\n \"w-max max-w-[min(92vw,20rem)] p-4 text-popover-foreground outline-none\",\n className,\n )}\n >\n {children}\n </div>\n </div>\n </div>\n </div>,\n document.body,\n );\n}\n"],"mappings":";;;;;;;;;;;AAuCA,MAAM,kBAAkB;CACtB,MAAM;CACN,gBAAgB;CAChB,QAAQ;AACV;AACA,MAAM,mBAAmB;CACvB,MAAM;CACN,gBAAgB;CAChB,QAAQ;AACV;A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AAS;MAAQ,CAAA;KACrD;IACJ,CAAA,EAAA,CAAA,CACH;;GAGL,qBAAC,OAAD;IACE,eAAA;IACA,WAAU;IACV,OAAO;KACL,MAAM,IAAI;KACV,KAAK,IAAI;KACT,OAAO,IAAI;KACX,QAAQ,IAAI;KACZ,QAAQ,SAAS,KAAA,IAAY,QAAQ,MAAM;KAC3C,UAAU,cAAc,GAAG;IAC7B;IAVF,UAAA,CAYE,oBAAC,OAAD;KACE,WAAU;KACV,OAAO;MACL,MAAM,IAAI,QAAQ;MAClB,KAAK,IAAI,QAAQ;MACjB,OAAO,IAAI,QAAQ;MACnB,QAAQ,IAAI,QAAQ;MACpB,cAAc,IAAI,QAAQ;KAC5B;IACD,CAAA,GACD,oBAAC,OAAD;KACE,KAAK;KACL,WAAU;KACV,OAAO,EACL,UAAU,gBAAgB,KAAK,SAAS,IAAI,GAAG,KAAK,EACtD;IACD,CAAA,CACE;;GAIL,oBAAC,OAAD;IACE,WAAU;IACV,OAAO;KACL,MAAM,IAAI;KACV,KAAK,IAAI;KACT,OAAO,IAAI;KACX,QAAQ,IAAI;IACd;IAEA,UAAA,oBAAC,OAAD;KACE,KAAK;KACL,OAAO,CAAC;KACR,WAAU;KACV,OAAO;MACL,UAAU,gBAAgB,KAAK,SAAS,IAAI,GAAG,KAAK;MACpD,eAAe,OAAO,SAAS;KACjC;KAEA,UAAA,oBAAC,OAAD;MACE,KAAK;MACL,IAAI;MACJ,MAAK;MACL,GAAI;MACJ,OAAO;OACL,UAAU;OACV,MAAM,IAAI,MAAM;OAChB,KAAK,IAAI,MAAM;OACf,iBAAiB,GAAG,aAAa,OAAO,GAAG,SAAS,WAAW,QAAQ;MACzE;MACA,WAAW,GACT,0EACA,SACF;MAEC;KACE,CAAA;IACF,CAAA;GACF,CAAA;EACF;CACL,CAAA,GAAA,SAAS,IACX;AACF"}
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { useHoverCapable } from "../../hooks/use-hover-capable.js";
3
3
  import { EASE_OUT, SPRING_PRESS } from "../../lib/ease.js";
4
- import { ActionSwapText } from "./action-swap.js";
5
4
  import { t as Tooltip } from "../../tooltip-Bam5KeYe.js";
5
+ import { ActionSwapText } from "./action-swap.js";
6
6
  import { useId, useState } from "react";
7
7
  import { cn } from "@kumix/utils";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { EASE_OUT } from "../../lib/ease.js";
3
- import { StatefulButton } from "./button/stateful.js";
4
3
  import { NumberTicker } from "./number-ticker.js";
4
+ import { StatefulButton } from "./button/stateful.js";
5
5
  import { Tabs, TabsList, TabsTrigger } from "./tabs.js";
6
6
  import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
7
7
  import { cn } from "@kumix/utils";
@@ -5,8 +5,8 @@ import { useCallback, useEffect, useId, useRef, useState } from "react";
5
5
  import { cn } from "@kumix/utils";
6
6
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
7
7
  import { AnimatePresence, LayoutGroup, motion, useReducedMotion } from "motion/react";
8
- import { X } from "lucide-react";
9
8
  import { createPortal } from "react-dom";
9
+ import { X } from "lucide-react";
10
10
  //#region src/components/motion/project-folder.tsx
11
11
  const MAX_PREVIEWS = 5;
12
12
  const FOCUSABLE_SELECTOR = [
@@ -7,8 +7,12 @@ export interface RadioGroupProps {
7
7
  children: ReactNode;
8
8
  className?: string;
9
9
  orientation?: "vertical" | "horizontal";
10
+ /** Accessible name for the group when no visible label names it. */
11
+ "aria-label"?: string;
12
+ /** Id of a visible element that names the group. */
13
+ "aria-labelledby"?: string;
10
14
  }
11
- export declare function RadioGroup({ value, defaultValue, onValueChange, children, className, orientation }: RadioGroupProps): import("react").JSX.Element;
15
+ export declare function RadioGroup({ value, defaultValue, onValueChange, children, className, orientation, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy }: RadioGroupProps): import("react").JSX.Element;
12
16
  export interface RadioGroupItemProps {
13
17
  value: string;
14
18
  label?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"radio.d.ts","names":[],"sources":["../../../src/components/motion/radio.tsx"],"mappings":";;iBAgCiB;EACf;EACA;EACA,iBAAiB;EACjB,UAAU;EACV;EACA;;wBAGc,aACd,OACA,cACA,eACA,UACA,WACA,eACC,kCAAe,IAAA;iBAoCD;EACf;EACA;;EAEA;EACA;EACA;EACA;;wBAGc,iBACd,OACA,OACA,aACA,UACA,WACA,IAAI,UACH,sCAAmB,IAAA"}
1
+ {"version":3,"file":"radio.d.ts","names":[],"sources":["../../../src/components/motion/radio.tsx"],"mappings":";;iBA0CiB;EACf;EACA;EACA,iBAAiB;EACjB,UAAU;EACV;EACA;;EAEA;;EAEA;;wBAGc,aACd,OACA,cACA,eACA,UACA,WACA,2BACc,8BACK,kBAClB,kCAAe,IAAA;iBAyDD;EACf;EACA;;EAEA;EACA;EACA;EACA;;wBAGc,iBACd,OACA,OACA,aACA,UACA,WACA,IAAI,UACH,sCAAmB,IAAA"}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { SPRING_LAYOUT, SPRING_PRESS } from "../../lib/ease.js";
3
- import { createContext, useCallback, useContext, useId, useMemo, useState } from "react";
3
+ import { createContext, useCallback, useContext, useId, useLayoutEffect, useMemo, useState } from "react";
4
4
  import { cn } from "@kumix/utils";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  import { MotionConfig, motion, useReducedMotion } from "motion/react";
@@ -11,7 +11,7 @@ function useRadioGroup() {
11
11
  if (!ctx) throw new Error("RadioGroupItem must be used inside <RadioGroup>");
12
12
  return ctx;
13
13
  }
14
- function RadioGroup({ value, defaultValue = "", onValueChange, children, className, orientation = "vertical" }) {
14
+ function RadioGroup({ value, defaultValue = "", onValueChange, children, className, orientation = "vertical", "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy }) {
15
15
  const [internal, setInternal] = useState(defaultValue);
16
16
  const layoutId = useId();
17
17
  const reduce = useReducedMotion();
@@ -21,14 +21,37 @@ function RadioGroup({ value, defaultValue = "", onValueChange, children, classNa
21
21
  if (!controlled) setInternal(next);
22
22
  onValueChange?.(next);
23
23
  }, [controlled, onValueChange]);
24
+ const [options, setOptions] = useState(/* @__PURE__ */ new Map());
25
+ const register = useCallback((option, disabled) => {
26
+ setOptions((map) => map.get(option) === disabled ? map : new Map(map).set(option, disabled));
27
+ }, []);
28
+ const unregister = useCallback((option) => {
29
+ setOptions((map) => {
30
+ if (!map.has(option)) return map;
31
+ const next = new Map(map);
32
+ next.delete(option);
33
+ return next;
34
+ });
35
+ }, []);
36
+ let tabStop = null;
37
+ if (options.size > 0) {
38
+ const enabled = Array.from(options).filter(([, disabled]) => !disabled);
39
+ tabStop = enabled.some(([option]) => option === current) ? current : enabled[0]?.[0] ?? "";
40
+ }
24
41
  const contextValue = useMemo(() => ({
25
42
  value: current,
26
43
  setValue,
27
- layoutId
44
+ layoutId,
45
+ tabStop,
46
+ register,
47
+ unregister
28
48
  }), [
29
49
  current,
30
50
  layoutId,
31
- setValue
51
+ setValue,
52
+ tabStop,
53
+ register,
54
+ unregister
32
55
  ]);
33
56
  return /* @__PURE__ */ jsx(MotionConfig, {
34
57
  transition: reduce ? { duration: 0 } : SPRING_LAYOUT,
@@ -36,6 +59,8 @@ function RadioGroup({ value, defaultValue = "", onValueChange, children, classNa
36
59
  value: contextValue,
37
60
  children: /* @__PURE__ */ jsx("div", {
38
61
  role: "radiogroup",
62
+ "aria-label": ariaLabel,
63
+ "aria-labelledby": ariaLabelledBy,
39
64
  className: cn("flex gap-3", orientation === "vertical" ? "flex-col" : "flex-row flex-wrap", className),
40
65
  children
41
66
  })
@@ -43,13 +68,34 @@ function RadioGroup({ value, defaultValue = "", onValueChange, children, classNa
43
68
  });
44
69
  }
45
70
  function RadioGroupItem({ value, label, description, disabled, className, id: idProp }) {
46
- const { value: groupValue, setValue, layoutId } = useRadioGroup();
71
+ const { value: groupValue, setValue, layoutId, tabStop, register, unregister } = useRadioGroup();
47
72
  const autoId = useId();
48
73
  const id = idProp ?? autoId;
49
74
  const reduce = useReducedMotion();
50
75
  const selected = groupValue === value;
51
76
  const descriptionId = description ? `${id}-description` : void 0;
52
77
  const labelId = description && label ? `${id}-label` : void 0;
78
+ useLayoutEffect(() => {
79
+ register(value, Boolean(disabled));
80
+ }, [
81
+ register,
82
+ value,
83
+ disabled
84
+ ]);
85
+ useLayoutEffect(() => () => unregister(value), [unregister, value]);
86
+ const reachable = !disabled && (tabStop === null ? true : tabStop === value);
87
+ const onKeyDown = (event) => {
88
+ const step = event.key === "ArrowDown" || event.key === "ArrowRight" ? 1 : event.key === "ArrowUp" || event.key === "ArrowLeft" ? -1 : 0;
89
+ if (!step) return;
90
+ const group = event.currentTarget.closest("[role=\"radiogroup\"]");
91
+ const radios = Array.from(group?.querySelectorAll("[role=\"radio\"]") ?? []).filter((radio) => !radio.disabled && radio.closest("[role=\"radiogroup\"]") === group);
92
+ const at = radios.indexOf(event.currentTarget);
93
+ if (at < 0 || radios.length < 2) return;
94
+ event.preventDefault();
95
+ const next = radios[(at + step + radios.length) % radios.length];
96
+ next.focus();
97
+ next.click();
98
+ };
53
99
  return /* @__PURE__ */ jsxs("label", {
54
100
  htmlFor: id,
55
101
  className: cn("inline-flex gap-3", description ? "items-start" : "items-center", disabled ? "cursor-not-allowed" : "cursor-pointer", className),
@@ -61,7 +107,9 @@ function RadioGroupItem({ value, label, description, disabled, className, id: id
61
107
  "aria-labelledby": labelId,
62
108
  "aria-describedby": descriptionId,
63
109
  disabled,
110
+ tabIndex: reachable ? 0 : -1,
64
111
  onClick: () => !disabled && setValue(value),
112
+ onKeyDown,
65
113
  whileTap: reduce || disabled ? void 0 : { scale: .92 },
66
114
  transition: SPRING_PRESS,
67
115
  "data-state": selected ? "checked" : "unchecked",
@@ -1 +1 @@
1
- {"version":3,"file":"radio.js","names":[],"sources":["../../../src/components/motion/radio.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useId,\n useMemo,\n useState,\n} from \"react\";\nimport { MotionConfig, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { SPRING_LAYOUT, SPRING_PRESS } from \"../../lib/ease\";\n\ntype RadioCtx = {\n value: string;\n setValue: (value: string) => void;\n layoutId: string;\n};\n\nconst RadioCtx = createContext<RadioCtx | null>(null);\n\nfunction useRadioGroup() {\n const ctx = useContext(RadioCtx);\n if (!ctx) {\n throw new Error(\"RadioGroupItem must be used inside <RadioGroup>\");\n }\n return ctx;\n}\n\nexport interface RadioGroupProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n children: ReactNode;\n className?: string;\n orientation?: \"vertical\" | \"horizontal\";\n}\n\nexport function RadioGroup({\n value,\n defaultValue = \"\",\n onValueChange,\n children,\n className,\n orientation = \"vertical\",\n}: RadioGroupProps) {\n const [internal, setInternal] = useState(defaultValue);\n const layoutId = useId();\n const reduce = useReducedMotion();\n const controlled = value !== undefined;\n const current = controlled ? value : internal;\n const setValue = useCallback(\n (next: string) => {\n if (!controlled) setInternal(next);\n onValueChange?.(next);\n },\n [controlled, onValueChange],\n );\n const contextValue = useMemo(\n () => ({ value: current, setValue, layoutId }),\n [current, layoutId, setValue],\n );\n\n return (\n <MotionConfig transition={reduce ? { duration: 0 } : SPRING_LAYOUT}>\n <RadioCtx.Provider value={contextValue}>\n <div\n role=\"radiogroup\"\n className={cn(\n \"flex gap-3\",\n orientation === \"vertical\" ? \"flex-col\" : \"flex-row flex-wrap\",\n className,\n )}\n >\n {children}\n </div>\n </RadioCtx.Provider>\n </MotionConfig>\n );\n}\n\nexport interface RadioGroupItemProps {\n value: string;\n label?: string;\n /** Supporting text under the label, announced as the description rather than the name. */\n description?: string;\n disabled?: boolean;\n className?: string;\n id?: string;\n}\n\nexport function RadioGroupItem({\n value,\n label,\n description,\n disabled,\n className,\n id: idProp,\n}: RadioGroupItemProps) {\n const { value: groupValue, setValue, layoutId } = useRadioGroup();\n const autoId = useId();\n const id = idProp ?? autoId;\n const reduce = useReducedMotion();\n const selected = groupValue === value;\n const descriptionId = description ? `${id}-description` : undefined;\n // The wrapping <label> would fold the description into the name, so name from the label text alone.\n const labelId = description && label ? `${id}-label` : undefined;\n\n return (\n <label\n htmlFor={id}\n className={cn(\n \"inline-flex gap-3\",\n description ? \"items-start\" : \"items-center\",\n disabled ? \"cursor-not-allowed\" : \"cursor-pointer\",\n className,\n )}\n >\n <motion.button\n id={id}\n type=\"button\"\n role=\"radio\"\n aria-checked={selected}\n aria-labelledby={labelId}\n aria-describedby={descriptionId}\n disabled={disabled}\n onClick={() => !disabled && setValue(value)}\n whileTap={reduce || disabled ? undefined : { scale: 0.92 }}\n transition={SPRING_PRESS}\n data-state={selected ? \"checked\" : \"unchecked\"}\n className={cn(\n \"relative inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 outline-none transition-colors duration-200\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n \"disabled:cursor-not-allowed disabled:opacity-60\",\n selected ? \"border-primary\" : \"border-muted-foreground/50 hover:border-muted-foreground\",\n )}\n >\n {selected ? (\n <motion.span\n layoutId={layoutId}\n className=\"absolute inset-1 rounded-full bg-primary\"\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n />\n ) : null}\n </motion.button>\n {label || description ? (\n <span className={cn(\"flex min-w-0 select-none flex-col gap-0.5\", disabled && \"opacity-60\")}>\n {label ? (\n <span\n id={labelId}\n // Geist sits low in a 20px line; a 16px line lifts the text onto the control.\n className={cn(\"text-foreground text-sm\", description && \"leading-4\")}\n >\n {label}\n </span>\n ) : null}\n {description ? (\n <span id={descriptionId} className=\"text-muted-foreground text-xs\">\n {description}\n </span>\n ) : null}\n </span>\n ) : null}\n </label>\n );\n}\n"],"mappings":";;;;;;;AAsBA,MAAM,WAAW,cAA+B,IAAI;AAEpD,SAAS,gBAAgB;CACvB,MAAM,MAAM,WAAW,QAAQ;CAC/B,IAAI,CA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AAc;GACd,mBAAiB;GACjB,oBAAkB;GACR;GACV,eAAe,CAAC,YAAY,SAAS,KAAK;GAC1C,UAAU,UAAU,WAAW,KAAA,IAAY,EAAE,OAAO,IAAK;GACzD,YAAY;GACZ,cAAY,WAAW,YAAY;GACnC,WAAW,GACT,uIACA,iHACA,mDACA,WAAW,mBAAmB,0DAChC;GAEC,UAAA,WACC,oBAAC,OAAO,MAAR;IACY;IACV,WAAU;IACV,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;GACxC,CAAA,IACC;EACS,CAAA,GACd,SAAS,cACR,qBAAC,QAAD;GAAM,WAAW,GAAG,6CAA6C,YAAY,YAAY;GAAzF,UAAA,CACG,QACC,oBAAC,QAAD;IACE,IAAI;IAEJ,WAAW,GAAG,2BAA2B,eAAe,WAAW;IAElE,UAAA;GACG,CAAA,IACJ,MACH,cACC,oBAAC,QAAD;IAAM,IAAI;IAAe,WAAU;IAChC,UAAA;GACG,CAAA,IACJ,IACA;EACJ,CAAA,IAAA,IACC;;AAEX"}
1
+ {"version":3,"file":"radio.js","names":[],"sources":["../../../src/components/motion/radio.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n type KeyboardEvent,\n type ReactNode,\n useCallback,\n useContext,\n useId,\n useLayoutEffect,\n useMemo,\n useState,\n} from \"react\";\nimport { MotionConfig, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { SPRING_LAYOUT, SPRING_PRESS } from \"../../lib/ease\";\n\ntype RadioCtx = {\n value: string;\n setValue: (value: string) => void;\n layoutId: string;\n /**\n * The one option Tab reaches: the selected option, or the first enabled one\n * when nothing enabled is selected. `null` until the options have\n * registered, when every enabled option stays reachable.\n */\n tabStop: string | null;\n register: (value: string, disabled: boolean) => void;\n unregister: (value: string) => void;\n};\n\nconst RadioCtx = createContext<RadioCtx | null>(null);\n\nfunction useRadioGroup() {\n const ctx = useContext(RadioCtx);\n if (!ctx) {\n throw new Error(\"RadioGroupItem must be used inside <RadioGroup>\");\n }\n return ctx;\n}\n\nexport interface RadioGroupProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n children: ReactNode;\n className?: string;\n orientation?: \"vertical\" | \"horizontal\";\n /** Accessible name for the group when no visible label names it. */\n \"aria-label\"?: string;\n /** Id of a visible element that names the group. */\n \"aria-labelledby\"?: string;\n}\n\nexport function RadioGroup({\n value,\n defaultValue = \"\",\n onValueChange,\n children,\n className,\n orientation = \"vertical\",\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n}: RadioGroupProps) {\n const [internal, setInternal] = useState(defaultValue);\n const layoutId = useId();\n const reduce = useReducedMotion();\n const controlled = value !== undefined;\n const current = controlled ? value : internal;\n const setValue = useCallback(\n (next: string) => {\n if (!controlled) setInternal(next);\n onValueChange?.(next);\n },\n [controlled, onValueChange],\n );\n const [options, setOptions] = useState<Map<string, boolean>>(new Map());\n const register = useCallback((option: string, disabled: boolean) => {\n setOptions((map) => (map.get(option) === disabled ? map : new Map(map).set(option, disabled)));\n }, []);\n const unregister = useCallback((option: string) => {\n setOptions((map) => {\n if (!map.has(option)) return map;\n const next = new Map(map);\n next.delete(option);\n return next;\n });\n }, []);\n // Resolved during render so the group has exactly one tab stop in the same\n // commit that changes the selection or the options.\n let tabStop: string | null = null;\n if (options.size > 0) {\n const enabled = Array.from(options).filter(([, disabled]) => !disabled);\n tabStop = enabled.some(([option]) => option === current) ? current : (enabled[0]?.[0] ?? \"\");\n }\n const contextValue = useMemo(\n () => ({ value: current, setValue, layoutId, tabStop, register, unregister }),\n [current, layoutId, setValue, tabStop, register, unregister],\n );\n\n return (\n <MotionConfig transition={reduce ? { duration: 0 } : SPRING_LAYOUT}>\n <RadioCtx.Provider value={contextValue}>\n <div\n role=\"radiogroup\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n className={cn(\n \"flex gap-3\",\n orientation === \"vertical\" ? \"flex-col\" : \"flex-row flex-wrap\",\n className,\n )}\n >\n {children}\n </div>\n </RadioCtx.Provider>\n </MotionConfig>\n );\n}\n\nexport interface RadioGroupItemProps {\n value: string;\n label?: string;\n /** Supporting text under the label, announced as the description rather than the name. */\n description?: string;\n disabled?: boolean;\n className?: string;\n id?: string;\n}\n\nexport function RadioGroupItem({\n value,\n label,\n description,\n disabled,\n className,\n id: idProp,\n}: RadioGroupItemProps) {\n const { value: groupValue, setValue, layoutId, tabStop, register, unregister } = useRadioGroup();\n const autoId = useId();\n const id = idProp ?? autoId;\n const reduce = useReducedMotion();\n const selected = groupValue === value;\n const descriptionId = description ? `${id}-description` : undefined;\n // The wrapping <label> would fold the description into the name, so name from the label text alone.\n const labelId = description && label ? `${id}-label` : undefined;\n\n useLayoutEffect(() => {\n register(value, Boolean(disabled));\n }, [register, value, disabled]);\n useLayoutEffect(() => () => unregister(value), [unregister, value]);\n\n const reachable = !disabled && (tabStop === null ? true : tabStop === value);\n\n // Arrow keys move to the next enabled option in the group, wrapping at the\n // ends, and select it as focus arrives, like native radio buttons.\n const onKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n const step =\n event.key === \"ArrowDown\" || event.key === \"ArrowRight\"\n ? 1\n : event.key === \"ArrowUp\" || event.key === \"ArrowLeft\"\n ? -1\n : 0;\n if (!step) return;\n const group = event.currentTarget.closest('[role=\"radiogroup\"]');\n const radios = Array.from(\n group?.querySelectorAll<HTMLButtonElement>('[role=\"radio\"]') ?? [],\n ).filter((radio) => !radio.disabled && radio.closest('[role=\"radiogroup\"]') === group);\n const at = radios.indexOf(event.currentTarget);\n if (at < 0 || radios.length < 2) return;\n event.preventDefault();\n const next = radios[(at + step + radios.length) % radios.length];\n next.focus();\n next.click();\n };\n\n return (\n <label\n htmlFor={id}\n className={cn(\n \"inline-flex gap-3\",\n description ? \"items-start\" : \"items-center\",\n disabled ? \"cursor-not-allowed\" : \"cursor-pointer\",\n className,\n )}\n >\n <motion.button\n id={id}\n type=\"button\"\n role=\"radio\"\n aria-checked={selected}\n aria-labelledby={labelId}\n aria-describedby={descriptionId}\n disabled={disabled}\n tabIndex={reachable ? 0 : -1}\n onClick={() => !disabled && setValue(value)}\n onKeyDown={onKeyDown}\n whileTap={reduce || disabled ? undefined : { scale: 0.92 }}\n transition={SPRING_PRESS}\n data-state={selected ? \"checked\" : \"unchecked\"}\n className={cn(\n \"relative inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 outline-none transition-colors duration-200\",\n \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n \"disabled:cursor-not-allowed disabled:opacity-60\",\n selected ? \"border-primary\" : \"border-muted-foreground/50 hover:border-muted-foreground\",\n )}\n >\n {selected ? (\n <motion.span\n layoutId={layoutId}\n className=\"absolute inset-1 rounded-full bg-primary\"\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n />\n ) : null}\n </motion.button>\n {label || description ? (\n <span className={cn(\"flex min-w-0 select-none flex-col gap-0.5\", disabled && \"opacity-60\")}>\n {label ? (\n <span\n id={labelId}\n // Geist sits low in a 20px line; a 16px line lifts the text onto the control.\n className={cn(\"text-foreground text-sm\", description && \"leading-4\")}\n >\n {label}\n </span>\n ) : null}\n {description ? (\n <span id={descriptionId} className=\"text-muted-foreground text-xs\">\n {description}\n </span>\n ) : null}\n </span>\n ) : null}\n </label>\n );\n}\n"],"mappings":";;;;;;;AAgCA,MAAM,WAAW,cAA+B,IAAI;AAEpD,SAAS,gBAAgB;CACvB,MAAM,MAAM,WAAW,QAAQ;CAC/B,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,iDAAiD;CAEnE,OAAO;AACT;AAeA,SAAgB,WAAW,EACzB,OACA,eAAe,IACf,eACA,UACA,WACA,cAAc,YACd,cAAc,WACd,mBAAmB,kBACD;CAClB,MAAM,CAAC,UAAU,eAAe,SAAS,YAAY;CACrD,MAAM,WAAW,MAAM;CACvB,MAAM,SAAS,iBAAiB;CAChC,MAAM,aAAa,UAAU,KAAA;CAC7B,MAAM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AAK;GACL,gBAAc;GACd,mBAAiB;GACjB,oBAAkB;GACR;GACV,UAAU,YAAY,IAAI;GAC1B,eAAe,CAAC,YAAY,SAAS,KAAK;GAC/B;GACX,UAAU,UAAU,WAAW,KAAA,IAAY,EAAE,OAAO,IAAK;GACzD,YAAY;GACZ,cAAY,WAAW,YAAY;GACnC,WAAW,GACT,uIACA,iHACA,mDACA,WAAW,mBAAmB,0DAChC;GAEC,UAAA,WACC,oBAAC,OAAO,MAAR;IACY;IACV,WAAU;IACV,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;GACxC,CAAA,IACC;EACS,CAAA,GACd,SAAS,cACR,qBAAC,QAAD;GAAM,WAAW,GAAG,6CAA6C,YAAY,YAAY;GAAzF,UAAA,CACG,QACC,oBAAC,QAAD;IACE,IAAI;IAEJ,WAAW,GAAG,2BAA2B,eAAe,WAAW;IAElE,UAAA;GACG,CAAA,IACJ,MACH,cACC,oBAAC,QAAD;IAAM,IAAI;IAAe,WAAU;IAChC,UAAA;GACG,CAAA,IACJ,IACA;EACJ,CAAA,IAAA,IACC;;AAEX"}
@@ -35,6 +35,6 @@ export interface MorphSelectItemProps {
35
35
  className?: string;
36
36
  children: ReactNode;
37
37
  }
38
- export declare function MorphSelectItem({ value, disabled, className, children }: MorphSelectItemProps): import("react").JSX.Element;
38
+ export declare function MorphSelectItem({ value, disabled, className, children }: MorphSelectItemProps): import("react").JSX.Element | null;
39
39
  //#endregion
40
40
  //# sourceMappingURL=select-morph.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"select-morph.d.ts","names":[],"sources":["../../../src/components/motion/select-morph.tsx"],"mappings":";;iBAgEiB;EACf;EACA;EACA,iBAAiB;EACjB;EACA;EACA,UAAU;;;;;;;wBAQI,cACd,OACA,cACA,eACA,UACA,WACA,YACC,mCAAgB,IAAA;iBAoFF;EACf;EACA;;wBAGc,mBAAmB,aAAa,aAAa,wCAAqB,IAAA;iBAcjE;EACf;EACA,UAAU;;wBAGI,qBAAqB,WAAW,YAAY,0CAAuB,IAAA;iBA8ClE;EACf;EACA,UAAU;;wBAGI,qBAAqB,WAAW,YAAY,0CAAuB,IAAA;iBAmElE;EACf;EACA;EACA;EACA,UAAU;;wBAGI,kBACd,OACA,UACA,WACA,YACC,uCAAoB,IAAA"}
1
+ {"version":3,"file":"select-morph.d.ts","names":[],"sources":["../../../src/components/motion/select-morph.tsx"],"mappings":";;iBA2EiB;EACf;EACA;EACA,iBAAiB;EACjB;EACA;EACA,UAAU;;;;;;;wBAQI,cACd,OACA,cACA,eACA,UACA,WACA,YACC,mCAAgB,IAAA;iBAgIF;EACf;EACA;;wBAGc,mBAAmB,aAAa,aAAa,wCAAqB,IAAA;iBAcjE;EACf;EACA,UAAU;;wBAGI,qBAAqB,WAAW,YAAY,0CAAuB,IAAA;iBAqDlE;EACf;EACA,UAAU;;wBAGI,qBAAqB,WAAW,YAAY,0CAAuB,IAAA;iBAyFlE;EACf;EACA;EACA;EACA,UAAU;;wBAGI,kBACd,OACA,UACA,WACA,YACC,uCAAoB,IAAA"}