@kumix/ui 0.4.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/README.md +15 -13
  2. package/dist/components/agents/agent-activity/index.js +1 -1
  3. package/dist/components/agents/approval-card/index.js +2 -3
  4. package/dist/components/agents/approval-card/index.js.map +1 -1
  5. package/dist/components/agents/prompt-input.js +1 -2
  6. package/dist/components/agents/prompt-input.js.map +1 -1
  7. package/dist/components/agents/todo-list.js +1 -1
  8. package/dist/components/agents/tool-result.js +1 -1
  9. package/dist/components/charts/bar-chart/context.d.ts +114 -0
  10. package/dist/components/charts/bar-chart/context.d.ts.map +1 -0
  11. package/dist/components/charts/bar-chart/context.js +60 -0
  12. package/dist/components/charts/bar-chart/context.js.map +1 -0
  13. package/dist/components/charts/bar-chart/legend.d.ts +6 -0
  14. package/dist/components/charts/bar-chart/legend.d.ts.map +1 -0
  15. package/dist/components/charts/bar-chart/legend.js +21 -0
  16. package/dist/components/charts/bar-chart/legend.js.map +1 -0
  17. package/dist/components/charts/bar-chart/plot.d.ts +10 -0
  18. package/dist/components/charts/bar-chart/plot.d.ts.map +1 -0
  19. package/dist/components/charts/bar-chart/plot.js +290 -0
  20. package/dist/components/charts/bar-chart/plot.js.map +1 -0
  21. package/dist/components/charts/bar-chart/tooltip.d.ts +20 -0
  22. package/dist/components/charts/bar-chart/tooltip.d.ts.map +1 -0
  23. package/dist/components/charts/bar-chart/tooltip.js +57 -0
  24. package/dist/components/charts/bar-chart/tooltip.js.map +1 -0
  25. package/dist/components/charts/bar-chart.d.ts +9 -0
  26. package/dist/components/charts/bar-chart.d.ts.map +1 -0
  27. package/dist/components/charts/bar-chart.js +51 -0
  28. package/dist/components/charts/bar-chart.js.map +1 -0
  29. package/dist/components/charts/bump-chart/plot.js +1 -1
  30. package/dist/components/charts/bump-chart/point.js +1 -1
  31. package/dist/components/charts/bump-chart.js +1 -1
  32. package/dist/components/charts/composition-chart/plot.js +5 -1
  33. package/dist/components/charts/composition-chart/plot.js.map +1 -1
  34. package/dist/components/charts/composition-chart/tooltip-content.js +1 -1
  35. package/dist/components/charts/donut-chart.d.ts +1 -1
  36. package/dist/components/charts/donut-chart.js +1 -1
  37. package/dist/components/charts/funnel-chart.js +1 -1
  38. package/dist/components/charts/heat-calendar/tooltip.js +1 -1
  39. package/dist/components/charts/line-chart/context.d.ts +154 -0
  40. package/dist/components/charts/line-chart/context.d.ts.map +1 -0
  41. package/dist/components/charts/line-chart/context.js +67 -0
  42. package/dist/components/charts/line-chart/context.js.map +1 -0
  43. package/dist/components/charts/line-chart/legend.d.ts +6 -0
  44. package/dist/components/charts/line-chart/legend.d.ts.map +1 -0
  45. package/dist/components/charts/line-chart/legend.js +21 -0
  46. package/dist/components/charts/line-chart/legend.js.map +1 -0
  47. package/dist/components/charts/line-chart/plot.d.ts +12 -0
  48. package/dist/components/charts/line-chart/plot.d.ts.map +1 -0
  49. package/dist/components/charts/line-chart/plot.js +604 -0
  50. package/dist/components/charts/line-chart/plot.js.map +1 -0
  51. package/dist/components/charts/line-chart/tooltip.d.ts +22 -0
  52. package/dist/components/charts/line-chart/tooltip.d.ts.map +1 -0
  53. package/dist/components/charts/line-chart/tooltip.js +108 -0
  54. package/dist/components/charts/line-chart/tooltip.js.map +1 -0
  55. package/dist/components/charts/line-chart.d.ts +10 -0
  56. package/dist/components/charts/line-chart.d.ts.map +1 -0
  57. package/dist/components/charts/line-chart.js +53 -0
  58. package/dist/components/charts/line-chart.js.map +1 -0
  59. package/dist/components/charts/liquidity-heatmap.js +1 -1
  60. package/dist/components/charts/price-target-fan.js +1 -1
  61. package/dist/components/charts/returns-calendar/tooltip.js +1 -1
  62. package/dist/components/charts/returns-calendar.d.ts.map +1 -1
  63. package/dist/components/charts/sankey-chart/context.d.ts +2 -0
  64. package/dist/components/charts/sankey-chart/context.js +2 -0
  65. package/dist/components/charts/sankey-chart/plot.d.ts +8 -0
  66. package/dist/components/charts/sankey-chart/plot.d.ts.map +1 -0
  67. package/dist/components/charts/sankey-chart/plot.js +342 -0
  68. package/dist/components/charts/sankey-chart/plot.js.map +1 -0
  69. package/dist/components/charts/sankey-chart/tooltip.d.ts +10 -0
  70. package/dist/components/charts/sankey-chart/tooltip.d.ts.map +1 -0
  71. package/dist/components/charts/sankey-chart/tooltip.js +147 -0
  72. package/dist/components/charts/sankey-chart/tooltip.js.map +1 -0
  73. package/dist/components/charts/sankey-chart.d.ts +17 -0
  74. package/dist/components/charts/sankey-chart.d.ts.map +1 -0
  75. package/dist/components/charts/sankey-chart.js +76 -0
  76. package/dist/components/charts/sankey-chart.js.map +1 -0
  77. package/dist/components/charts/sparkline.d.ts +26 -0
  78. package/dist/components/charts/sparkline.d.ts.map +1 -0
  79. package/dist/components/charts/sparkline.js +197 -0
  80. package/dist/components/charts/sparkline.js.map +1 -0
  81. package/dist/components/charts/treemap/tooltip.js +1 -1
  82. package/dist/components/charts/treemap.d.ts.map +1 -1
  83. package/dist/components/charts/volume-profile/tooltip.js +1 -1
  84. package/dist/components/charts/xy/axis.d.ts +24 -0
  85. package/dist/components/charts/xy/axis.d.ts.map +1 -0
  86. package/dist/components/charts/xy/axis.js +90 -0
  87. package/dist/components/charts/xy/axis.js.map +1 -0
  88. package/dist/components/charts/xy/data-table.d.ts +9 -0
  89. package/dist/components/charts/xy/data-table.d.ts.map +1 -0
  90. package/dist/components/charts/xy/data-table.js +29 -0
  91. package/dist/components/charts/xy/data-table.js.map +1 -0
  92. package/dist/components/charts/xy/inspector.d.ts +27 -0
  93. package/dist/components/charts/xy/inspector.d.ts.map +1 -0
  94. package/dist/components/charts/xy/inspector.js +110 -0
  95. package/dist/components/charts/xy/inspector.js.map +1 -0
  96. package/dist/components/charts/xy/legend.d.ts +13 -0
  97. package/dist/components/charts/xy/legend.d.ts.map +1 -0
  98. package/dist/components/charts/xy/legend.js +42 -0
  99. package/dist/components/charts/xy/legend.js.map +1 -0
  100. package/dist/components/charts/xy/tooltip-content.d.ts +2 -0
  101. package/dist/components/charts/xy/tooltip-content.js +66 -0
  102. package/dist/components/charts/xy/tooltip-content.js.map +1 -0
  103. package/dist/components/motion/attachment-upload.js +1 -1
  104. package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
  105. package/dist/components/motion/availability-scheduler/day-row.js +2 -2
  106. package/dist/components/motion/availability-scheduler/index.js +1 -1
  107. package/dist/components/motion/avatar-group.d.ts +48 -0
  108. package/dist/components/motion/avatar-group.d.ts.map +1 -0
  109. package/dist/components/motion/avatar-group.js +196 -0
  110. package/dist/components/motion/avatar-group.js.map +1 -0
  111. package/dist/components/motion/bottom-sheet.js +1 -1
  112. package/dist/components/motion/bouncy-accordion.d.ts.map +1 -1
  113. package/dist/components/motion/bouncy-accordion.js +20 -34
  114. package/dist/components/motion/bouncy-accordion.js.map +1 -1
  115. package/dist/components/motion/breadcrumb.js +0 -3
  116. package/dist/components/motion/breadcrumb.js.map +1 -1
  117. package/dist/components/motion/button/magnetic.js +1 -1
  118. package/dist/components/motion/card-dealer.d.ts +36 -0
  119. package/dist/components/motion/card-dealer.d.ts.map +1 -0
  120. package/dist/components/motion/card-dealer.js +232 -0
  121. package/dist/components/motion/card-dealer.js.map +1 -0
  122. package/dist/components/motion/color-picker.js +1 -1
  123. package/dist/components/motion/combobox.js +1 -1
  124. package/dist/components/motion/context-menu.js +1 -1
  125. package/dist/components/motion/crash/crash-balloon.d.ts +9 -0
  126. package/dist/components/motion/crash/crash-balloon.d.ts.map +1 -0
  127. package/dist/components/motion/crash/crash-balloon.js +829 -0
  128. package/dist/components/motion/crash/crash-balloon.js.map +1 -0
  129. package/dist/components/motion/crash/crash-parts.d.ts +59 -0
  130. package/dist/components/motion/crash/crash-parts.d.ts.map +1 -0
  131. package/dist/components/motion/crash/crash-parts.js +2 -0
  132. package/dist/components/motion/crash/crash-tower.d.ts +9 -0
  133. package/dist/components/motion/crash/crash-tower.d.ts.map +1 -0
  134. package/dist/components/motion/crash/crash-tower.js +370 -0
  135. package/dist/components/motion/crash/crash-tower.js.map +1 -0
  136. package/dist/components/motion/crash.d.ts +9 -0
  137. package/dist/components/motion/crash.d.ts.map +1 -0
  138. package/dist/components/motion/crash.js +590 -0
  139. package/dist/components/motion/crash.js.map +1 -0
  140. package/dist/components/motion/date-range-picker.js +1 -1
  141. package/dist/components/motion/feedback-widget.js +0 -1
  142. package/dist/components/motion/feedback-widget.js.map +1 -1
  143. package/dist/components/motion/hold-action-button.js +1 -1
  144. package/dist/components/motion/liquid.js +2 -2
  145. package/dist/components/motion/liquid.js.map +1 -1
  146. package/dist/components/motion/loader.js +5 -4
  147. package/dist/components/motion/loader.js.map +1 -1
  148. package/dist/components/motion/mines.d.ts +41 -0
  149. package/dist/components/motion/mines.d.ts.map +1 -0
  150. package/dist/components/motion/mines.js +762 -0
  151. package/dist/components/motion/mines.js.map +1 -0
  152. package/dist/components/motion/morphing-modal.js +6 -4
  153. package/dist/components/motion/morphing-modal.js.map +1 -1
  154. package/dist/components/motion/morphing-tabs.js +1 -1
  155. package/dist/components/motion/multi-select/index.js +1 -1
  156. package/dist/components/motion/pagination.d.ts +31 -0
  157. package/dist/components/motion/pagination.d.ts.map +1 -0
  158. package/dist/components/motion/pagination.js +193 -0
  159. package/dist/components/motion/pagination.js.map +1 -0
  160. package/dist/components/motion/plinko.d.ts +59 -0
  161. package/dist/components/motion/plinko.d.ts.map +1 -0
  162. package/dist/components/motion/plinko.js +385 -0
  163. package/dist/components/motion/plinko.js.map +1 -0
  164. package/dist/components/motion/popover-morph.d.ts +11 -2
  165. package/dist/components/motion/popover-morph.d.ts.map +1 -1
  166. package/dist/components/motion/popover-morph.js +98 -4
  167. package/dist/components/motion/popover-morph.js.map +1 -1
  168. package/dist/components/motion/pull-to-refresh.js +1 -1
  169. package/dist/components/motion/range-slider-bubble.js +1 -1
  170. package/dist/components/motion/range-slider-fluid.js +1 -1
  171. package/dist/components/motion/range-slider-inline.js +1 -1
  172. package/dist/components/motion/range-slider-ruler.js +1 -1
  173. package/dist/components/motion/range-slider-wave.js +1 -1
  174. package/dist/components/motion/range-slider.js +1 -1
  175. package/dist/components/motion/signup-form.js +0 -1
  176. package/dist/components/motion/signup-form.js.map +1 -1
  177. package/dist/components/motion/slide-action-button.js +1 -1
  178. package/dist/components/motion/swap/field.js +1 -1
  179. package/dist/components/motion/swap/token-picker.js +1 -1
  180. package/dist/components/motion/swap.d.ts +1 -1
  181. package/dist/components/motion/swap.js +2 -2
  182. package/dist/components/motion/table/index.js +2 -2
  183. package/dist/components/motion/table/table-header.js +1 -1
  184. package/dist/components/motion/tooltip.d.ts +2 -2
  185. package/dist/components/motion/tooltip.d.ts.map +1 -1
  186. package/dist/components/motion/wallet-card/index.js +1 -2
  187. package/dist/components/motion/wallet-card/index.js.map +1 -1
  188. package/dist/components/motion/wheel-picker.js +1 -1
  189. package/dist/components/reui/badge.d.ts +1 -1
  190. package/dist/components/reui/cascader/cascader-columns.js +1 -1
  191. package/dist/components/reui/cascader/cascader-footer.js +1 -1
  192. package/dist/components/reui/cascader/cascader-nav.js +1 -1
  193. package/dist/components/reui/cascader/cascader-virtual.js +1 -1
  194. package/dist/components/reui/cascader/cascader.d.ts +1 -1
  195. package/dist/components/reui/cascader/cascader.js +2 -2
  196. package/dist/components/reui/code-block/code-block.d.ts +2 -1
  197. package/dist/components/reui/code-block/code-block.d.ts.map +1 -1
  198. package/dist/components/reui/data-grid/data-grid-column-filter.js +1 -1
  199. package/dist/components/reui/data-grid/data-grid-pagination.js +1 -1
  200. package/dist/components/reui/data-grid/data-grid-table.d.ts +1 -1
  201. package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -1
  202. package/dist/components/reui/data-grid/data-grid-table.js +1 -1
  203. package/dist/components/reui/date-selector.js +2 -2
  204. package/dist/components/reui/emoji-picker.js +2 -2
  205. package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +1 -1
  206. package/dist/components/reui/event-calendar/event-calendar-content.js +1 -1
  207. package/dist/components/reui/event-calendar/event-calendar-dnd.js +1 -1
  208. package/dist/components/reui/event-calendar/event-calendar-event.js +1 -1
  209. package/dist/components/reui/event-calendar/event-calendar-month-view.js +2 -2
  210. package/dist/components/reui/event-calendar/event-calendar-nav.js +2 -2
  211. package/dist/components/reui/event-calendar/event-calendar-resource-view.js +1 -1
  212. package/dist/components/reui/event-calendar/event-calendar-time-grid.js +1 -1
  213. package/dist/components/reui/event-calendar/event-calendar.d.ts +1 -1
  214. package/dist/components/reui/filters/filters-advanced.js +4 -4
  215. package/dist/components/reui/filters/filters-builder.js +1 -1
  216. package/dist/components/reui/filters/filters-chip.js +2 -2
  217. package/dist/components/reui/filters/filters-context.d.ts +1 -1
  218. package/dist/components/reui/filters/filters-editors.js +3 -3
  219. package/dist/components/reui/filters/filters.d.ts +3 -3
  220. package/dist/components/reui/filters/filters.js +6 -6
  221. package/dist/components/reui/gantt/gantt-bar.js +1 -1
  222. package/dist/components/reui/gantt/gantt-dnd.js +1 -1
  223. package/dist/components/reui/gantt/gantt-nav.js +2 -2
  224. package/dist/components/reui/gantt/gantt-view.js +3 -3
  225. package/dist/components/reui/gantt/gantt.d.ts +1 -1
  226. package/dist/components/reui/icon-tile.d.ts +1 -1
  227. package/dist/components/reui/phone-input.js +2 -2
  228. package/dist/components/reui/tree.d.ts +1 -0
  229. package/dist/components/reui/tree.d.ts.map +1 -1
  230. package/dist/components/ui/attachment.d.ts +1 -1
  231. package/dist/components/ui/badge.d.ts +1 -1
  232. package/dist/components/ui/bubble.d.ts +1 -1
  233. package/dist/components/ui/button-group.d.ts +1 -1
  234. package/dist/components/ui/button.d.ts +2 -2
  235. package/dist/components/ui/command.js +1 -1
  236. package/dist/components/ui/field.d.ts +1 -1
  237. package/dist/components/ui/field.js +1 -1
  238. package/dist/components/ui/item.d.ts +1 -1
  239. package/dist/components/ui/marker.d.ts +1 -1
  240. package/dist/components/ui/sidebar.d.ts +1 -1
  241. package/dist/components/ui/sidebar.js +1 -1
  242. package/dist/components/ui/tabs.d.ts +1 -1
  243. package/dist/context-CQbvWVnM.js +393 -0
  244. package/dist/context-CQbvWVnM.js.map +1 -0
  245. package/dist/context-tv-kneJV.d.ts +204 -0
  246. package/dist/context-tv-kneJV.d.ts.map +1 -0
  247. package/dist/{copy-menu-CKW3jM1J.js → copy-menu-LU54Aruj.js} +2 -2
  248. package/dist/{copy-menu-CKW3jM1J.js.map → copy-menu-LU54Aruj.js.map} +1 -1
  249. package/dist/crash-parts-CUv5gFYQ.js +1053 -0
  250. package/dist/crash-parts-CUv5gFYQ.js.map +1 -0
  251. package/dist/{ease-CHhXKlG3.d.ts → ease-DjhlGGZO.d.ts} +4 -2
  252. package/dist/ease-DjhlGGZO.d.ts.map +1 -0
  253. package/dist/hooks/use-highlighted-code.d.ts +1 -1
  254. package/dist/hooks/use-highlighted-code.d.ts.map +1 -1
  255. package/dist/hooks/use-modal-scope.js +2 -2
  256. package/dist/hooks/use-modal-scope.js.map +1 -1
  257. package/dist/lib/audio-context.d.ts +11 -0
  258. package/dist/lib/audio-context.d.ts.map +1 -0
  259. package/dist/lib/audio-context.js +37 -0
  260. package/dist/lib/audio-context.js.map +1 -0
  261. package/dist/lib/ease.d.ts +2 -2
  262. package/dist/lib/ease.js +8 -1
  263. package/dist/lib/ease.js.map +1 -1
  264. package/dist/lib/focusable.d.ts +2 -0
  265. package/dist/lib/focusable.d.ts.map +1 -0
  266. package/dist/lib/focusable.js +12 -0
  267. package/dist/lib/focusable.js.map +1 -0
  268. package/dist/lib/game-sounds.d.ts +18 -0
  269. package/dist/lib/game-sounds.d.ts.map +1 -0
  270. package/dist/lib/game-sounds.js +142 -0
  271. package/dist/lib/game-sounds.js.map +1 -0
  272. package/dist/lib/tick-sound.d.ts +4 -3
  273. package/dist/lib/tick-sound.d.ts.map +1 -1
  274. package/dist/lib/tick-sound.js +30 -37
  275. package/dist/lib/tick-sound.js.map +1 -1
  276. package/dist/model-CvWolJdo.d.ts +14 -0
  277. package/dist/model-CvWolJdo.d.ts.map +1 -0
  278. package/dist/path-VEfFUowr.d.ts +3 -0
  279. package/dist/path-VEfFUowr.d.ts.map +1 -0
  280. package/dist/{plot-DAKl-Lu1.js → plot-CTQFrQKi.js} +2 -2
  281. package/dist/{plot-DAKl-Lu1.js.map → plot-CTQFrQKi.js.map} +1 -1
  282. package/dist/scale-DSsaupNc.d.ts +7 -0
  283. package/dist/scale-DSsaupNc.d.ts.map +1 -0
  284. package/dist/tooltip-CNEYdIX3.d.ts.map +1 -1
  285. package/dist/tooltip-content-K0vPsEtI.d.ts +17 -0
  286. package/dist/tooltip-content-K0vPsEtI.d.ts.map +1 -0
  287. package/dist/use-crash-game-B3RHxFkm.d.ts +108 -0
  288. package/dist/use-crash-game-B3RHxFkm.d.ts.map +1 -0
  289. package/dist/use-inspection-CZhdpH8J.js +127 -0
  290. package/dist/use-inspection-CZhdpH8J.js.map +1 -0
  291. package/dist/use-points-C2jpElHh.js +118 -0
  292. package/dist/use-points-C2jpElHh.js.map +1 -0
  293. package/dist/use-width-CkKCh1b3.js +23 -0
  294. package/dist/use-width-CkKCh1b3.js.map +1 -0
  295. package/package.json +7 -7
  296. package/dist/ease-CHhXKlG3.d.ts.map +0 -1
@@ -0,0 +1,196 @@
1
+ "use client";
2
+ import { useHoverCapable } from "../../hooks/use-hover-capable.js";
3
+ import { EASE_OUT, SPRING_LAYOUT, SPRING_PRESS } from "../../lib/ease.js";
4
+ import { r as TooltipProvider, t as Tooltip } from "../../tooltip-CuHpilPN.js";
5
+ import { useState } from "react";
6
+ import { cn } from "@kumix/utils";
7
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
+ import { AnimatePresence, motion, useReducedMotion } from "motion/react";
9
+ // src/components/motion/avatar-group.tsx
10
+ const SIZES = {
11
+ sm: {
12
+ box: "size-7 text-[10px]",
13
+ px: 28
14
+ },
15
+ md: {
16
+ box: "size-9 text-xs",
17
+ px: 36
18
+ },
19
+ lg: {
20
+ box: "size-11 text-sm",
21
+ px: 44
22
+ }
23
+ };
24
+ function initials(name) {
25
+ const parts = name.trim().split(/\s+/).filter(Boolean);
26
+ return (parts.length > 1 ? parts[0][0] + parts[parts.length - 1][0] : (parts[0] ?? "?").slice(0, 2)).toUpperCase();
27
+ }
28
+ /** One avatar: the image, or initials when there is no image or it fails. */
29
+ function Avatar({ name, src, size = "md", className, ...props }) {
30
+ const [failedSrc, setFailedSrc] = useState();
31
+ const showImage = src && failedSrc !== src;
32
+ return /* @__PURE__ */ jsx("span", {
33
+ ...props,
34
+ className: cn("bg-card text-muted-foreground ring-background relative inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full font-medium ring-2 select-none", SIZES[size].box, className),
35
+ children: showImage ? /* @__PURE__ */ jsx("img", {
36
+ src,
37
+ alt: name,
38
+ draggable: false,
39
+ onError: () => setFailedSrc(src),
40
+ className: "size-full object-cover"
41
+ }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
42
+ "aria-hidden": "true",
43
+ children: initials(name)
44
+ }), /* @__PURE__ */ jsx("span", {
45
+ className: "sr-only",
46
+ children: name
47
+ })] })
48
+ });
49
+ }
50
+ /**
51
+ * Overlapping avatars that fan apart on hover, lift the one under the pointer
52
+ * with its name, and expand from a +N count to show everyone.
53
+ */
54
+ function AvatarGroup({ members, max = 4, size = "md", expanded, defaultExpanded = false, onExpandedChange, label = "Members", className, ...props }) {
55
+ const reduce = useReducedMotion();
56
+ const canHover = useHoverCapable();
57
+ const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);
58
+ const isExpanded = expanded ?? internalExpanded;
59
+ const [hovered, setHovered] = useState(null);
60
+ const limit = Math.max(1, max);
61
+ const overflow = Math.max(0, members.length - limit);
62
+ const visible = isExpanded ? members : members.slice(0, limit);
63
+ const px = SIZES[size].px;
64
+ const overlap = Math.round(px / 3);
65
+ const push = Math.round(overlap * .75);
66
+ const parting = !reduce && canHover && hovered !== null;
67
+ const offset = (index) => !parting || index === hovered ? 0 : index < (hovered ?? 0) ? -push : push;
68
+ const hoverHandlers = (index) => ({ onPointerEnter: (event) => {
69
+ if (event.pointerType === "mouse") setHovered(index);
70
+ } });
71
+ const toggle = () => {
72
+ const next = !isExpanded;
73
+ if (expanded === void 0) setInternalExpanded(next);
74
+ onExpandedChange?.(next);
75
+ };
76
+ return /* @__PURE__ */ jsx(TooltipProvider, {
77
+ skipDelay: 400,
78
+ children: /* @__PURE__ */ jsx("div", {
79
+ ...props,
80
+ onPointerLeave: (event) => {
81
+ props.onPointerLeave?.(event);
82
+ setHovered(null);
83
+ },
84
+ className: cn("inline-flex items-center", className),
85
+ children: /* @__PURE__ */ jsx("ul", {
86
+ "aria-label": label,
87
+ className: "relative flex items-center",
88
+ children: /* @__PURE__ */ jsxs(AnimatePresence, {
89
+ initial: false,
90
+ mode: "popLayout",
91
+ children: [visible.map((member, index) => /* @__PURE__ */ jsx(motion.li, {
92
+ layout: reduce ? false : "position",
93
+ initial: {
94
+ opacity: 0,
95
+ scale: reduce ? 1 : .6
96
+ },
97
+ animate: {
98
+ opacity: 1,
99
+ scale: 1
100
+ },
101
+ exit: {
102
+ opacity: 0,
103
+ scale: reduce ? 1 : .6,
104
+ transition: {
105
+ duration: .14,
106
+ ease: EASE_OUT
107
+ }
108
+ },
109
+ transition: {
110
+ layout: SPRING_LAYOUT,
111
+ scale: SPRING_LAYOUT,
112
+ opacity: {
113
+ duration: .18,
114
+ ease: EASE_OUT
115
+ }
116
+ },
117
+ style: {
118
+ marginLeft: index === 0 ? 0 : -overlap,
119
+ zIndex: parting && hovered === index ? visible.length + 1 : index,
120
+ position: "relative"
121
+ },
122
+ children: /* @__PURE__ */ jsx(Tooltip, {
123
+ content: member.name,
124
+ side: "top",
125
+ children: /* @__PURE__ */ jsx(motion.span, {
126
+ className: "block rounded-full",
127
+ ...hoverHandlers(index),
128
+ animate: {
129
+ x: offset(index),
130
+ y: parting && hovered === index ? -3 : 0,
131
+ scale: parting && hovered === index ? 1.06 : 1
132
+ },
133
+ transition: SPRING_LAYOUT,
134
+ children: /* @__PURE__ */ jsx(Avatar, {
135
+ name: member.name,
136
+ src: member.src,
137
+ size
138
+ })
139
+ })
140
+ })
141
+ }, member.id)), overflow > 0 ? /* @__PURE__ */ jsx(motion.li, {
142
+ layout: reduce ? false : "position",
143
+ transition: { layout: SPRING_LAYOUT },
144
+ style: {
145
+ marginLeft: -overlap,
146
+ zIndex: visible.length,
147
+ position: "relative"
148
+ },
149
+ children: /* @__PURE__ */ jsx(motion.span, {
150
+ className: "block",
151
+ ...hoverHandlers(visible.length),
152
+ animate: { x: offset(visible.length) },
153
+ transition: SPRING_LAYOUT,
154
+ children: /* @__PURE__ */ jsx(motion.button, {
155
+ type: "button",
156
+ "aria-expanded": isExpanded,
157
+ "aria-label": isExpanded ? "Show fewer members" : `Show ${overflow} more members`,
158
+ onClick: toggle,
159
+ whileTap: reduce ? void 0 : { scale: .92 },
160
+ transition: SPRING_PRESS,
161
+ className: cn("bg-foreground text-background ring-background focus-visible:ring-ring relative inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full font-medium tabular-nums ring-2 outline-none", SIZES[size].box),
162
+ children: /* @__PURE__ */ jsx(AnimatePresence, {
163
+ initial: false,
164
+ mode: "popLayout",
165
+ children: /* @__PURE__ */ jsx(motion.span, {
166
+ "aria-hidden": "true",
167
+ initial: {
168
+ opacity: 0,
169
+ y: reduce ? 0 : isExpanded ? 8 : -8
170
+ },
171
+ animate: {
172
+ opacity: 1,
173
+ y: 0
174
+ },
175
+ exit: {
176
+ opacity: 0,
177
+ y: reduce ? 0 : isExpanded ? -8 : 8
178
+ },
179
+ transition: {
180
+ duration: .16,
181
+ ease: EASE_OUT
182
+ },
183
+ children: isExpanded ? "−" : `+${overflow}`
184
+ }, isExpanded ? "less" : "more")
185
+ })
186
+ })
187
+ })
188
+ }, "overflow") : null]
189
+ })
190
+ })
191
+ })
192
+ });
193
+ }
194
+ export { Avatar, AvatarGroup };
195
+
196
+ //# sourceMappingURL=avatar-group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"avatar-group.js","names":[],"sources":["../../../src/components/motion/avatar-group.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ComponentPropsWithRef, type PointerEvent, useState } from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useHoverCapable } from \"../../hooks/use-hover-capable\";\nimport { EASE_OUT, SPRING_LAYOUT, SPRING_PRESS } from \"../../lib/ease\";\nimport { Tooltip, TooltipProvider } from \"./tooltip\";\n\nexport interface AvatarGroupMember {\n id: string;\n name: string;\n /** Image URL. Without one, or if it fails to load, initials show. */\n src?: string;\n}\n\nconst SIZES = {\n sm: { box: \"size-7 text-[10px]\", px: 28 },\n md: { box: \"size-9 text-xs\", px: 36 },\n lg: { box: \"size-11 text-sm\", px: 44 },\n} as const;\n\ntype AvatarSize = keyof typeof SIZES;\n\nfunction initials(name: string) {\n const parts = name.trim().split(/\\s+/).filter(Boolean);\n const letters =\n parts.length > 1 ? parts[0][0] + parts[parts.length - 1][0] : (parts[0] ?? \"?\").slice(0, 2);\n return letters.toUpperCase();\n}\n\nexport interface AvatarProps extends Omit<ComponentPropsWithRef<\"span\">, \"children\"> {\n name: string;\n src?: string;\n size?: AvatarSize;\n}\n\n/** One avatar: the image, or initials when there is no image or it fails. */\nexport function Avatar({ name, src, size = \"md\", className, ...props }: AvatarProps) {\n const [failedSrc, setFailedSrc] = useState<string>();\n const showImage = src && failedSrc !== src;\n return (\n <span\n {...props}\n className={cn(\n \"bg-card text-muted-foreground ring-background relative inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full font-medium ring-2 select-none\",\n SIZES[size].box,\n className,\n )}\n >\n {showImage ? (\n <img\n src={src}\n alt={name}\n draggable={false}\n onError={() => setFailedSrc(src)}\n className=\"size-full object-cover\"\n />\n ) : (\n <>\n <span aria-hidden=\"true\">{initials(name)}</span>\n <span className=\"sr-only\">{name}</span>\n </>\n )}\n </span>\n );\n}\n\nexport interface AvatarGroupProps extends Omit<ComponentPropsWithRef<\"div\">, \"children\"> {\n members: AvatarGroupMember[];\n /** Avatars shown before the rest collapse into a +N count. */\n max?: number;\n size?: AvatarSize;\n /** Whether every member is shown. Pair with `onExpandedChange`. */\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n /** Accessible name for the list, such as \"Project members\". */\n label?: string;\n}\n\n/**\n * Overlapping avatars that fan apart on hover, lift the one under the pointer\n * with its name, and expand from a +N count to show everyone.\n */\nexport function AvatarGroup({\n members,\n max = 4,\n size = \"md\",\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n label = \"Members\",\n className,\n ...props\n}: AvatarGroupProps) {\n const reduce = useReducedMotion();\n const canHover = useHoverCapable();\n const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);\n const isExpanded = expanded ?? internalExpanded;\n // Index of the avatar under a mouse pointer; the +N button counts as the\n // last slot.\n const [hovered, setHovered] = useState<number | null>(null);\n\n const limit = Math.max(1, max);\n const overflow = Math.max(0, members.length - limit);\n const visible = isExpanded ? members : members.slice(0, limit);\n const px = SIZES[size].px;\n // Avatars overlap by a third of their width. Hovering one parts the row\n // around it: everything before slides back, everything after slides on,\n // so the hovered avatar shows in full while the group stays in place.\n const overlap = Math.round(px / 3);\n const push = Math.round(overlap * 0.75);\n const parting = !reduce && canHover && hovered !== null;\n const offset = (index: number) =>\n !parting || index === hovered ? 0 : index < (hovered ?? 0) ? -push : push;\n const hoverHandlers = (index: number) => ({\n onPointerEnter: (event: PointerEvent) => {\n if (event.pointerType === \"mouse\") setHovered(index);\n },\n });\n\n const toggle = () => {\n const next = !isExpanded;\n if (expanded === undefined) setInternalExpanded(next);\n onExpandedChange?.(next);\n };\n\n return (\n <TooltipProvider skipDelay={400}>\n <div\n {...props}\n onPointerLeave={(event) => {\n props.onPointerLeave?.(event);\n setHovered(null);\n }}\n className={cn(\"inline-flex items-center\", className)}\n >\n <ul aria-label={label} className=\"relative flex items-center\">\n <AnimatePresence initial={false} mode=\"popLayout\">\n {visible.map((member, index) => (\n <motion.li\n key={member.id}\n layout={reduce ? false : \"position\"}\n initial={{ opacity: 0, scale: reduce ? 1 : 0.6 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{\n opacity: 0,\n scale: reduce ? 1 : 0.6,\n transition: { duration: 0.14, ease: EASE_OUT },\n }}\n transition={{\n layout: SPRING_LAYOUT,\n scale: SPRING_LAYOUT,\n opacity: { duration: 0.18, ease: EASE_OUT },\n }}\n // Later avatars sit on top, except the hovered one.\n style={{\n marginLeft: index === 0 ? 0 : -overlap,\n zIndex: parting && hovered === index ? visible.length + 1 : index,\n position: \"relative\",\n }}\n >\n <Tooltip content={member.name} side=\"top\">\n <motion.span\n className=\"block rounded-full\"\n {...hoverHandlers(index)}\n animate={{\n x: offset(index),\n y: parting && hovered === index ? -3 : 0,\n scale: parting && hovered === index ? 1.06 : 1,\n }}\n transition={SPRING_LAYOUT}\n >\n <Avatar name={member.name} src={member.src} size={size} />\n </motion.span>\n </Tooltip>\n </motion.li>\n ))}\n {overflow > 0 ? (\n <motion.li\n key=\"overflow\"\n layout={reduce ? false : \"position\"}\n transition={{ layout: SPRING_LAYOUT }}\n style={{ marginLeft: -overlap, zIndex: visible.length, position: \"relative\" }}\n >\n <motion.span\n className=\"block\"\n {...hoverHandlers(visible.length)}\n animate={{ x: offset(visible.length) }}\n transition={SPRING_LAYOUT}\n >\n <motion.button\n type=\"button\"\n aria-expanded={isExpanded}\n aria-label={isExpanded ? \"Show fewer members\" : `Show ${overflow} more members`}\n onClick={toggle}\n whileTap={reduce ? undefined : { scale: 0.92 }}\n transition={SPRING_PRESS}\n className={cn(\n \"bg-foreground text-background ring-background focus-visible:ring-ring relative inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full font-medium tabular-nums ring-2 outline-none\",\n SIZES[size].box,\n )}\n >\n <AnimatePresence initial={false} mode=\"popLayout\">\n <motion.span\n key={isExpanded ? \"less\" : \"more\"}\n aria-hidden=\"true\"\n initial={{ opacity: 0, y: reduce ? 0 : isExpanded ? 8 : -8 }}\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0, y: reduce ? 0 : isExpanded ? -8 : 8 }}\n transition={{ duration: 0.16, ease: EASE_OUT }}\n >\n {isExpanded ? \"−\" : `+${overflow}`}\n </motion.span>\n </AnimatePresence>\n </motion.button>\n </motion.span>\n </motion.li>\n ) : null}\n </AnimatePresence>\n </ul>\n </div>\n </TooltipProvider>\n );\n}\n"],"mappings":";;;;;;;;;AAiBA,MAAM,QAAQ;CACZ,IAAI;EAAE,KAAK;EAAsB,IAAI;CAAG;CACxC,IAAI;EAAE,KAAK;EAAkB,IAAI;CAAG;CACpC,IAAI;EAAE,KAAK;EAAmB,IAAI;CAAG;AACvC;AAIA,SAAS,SAAS,MAAc;CAC9B,MAAM,QAAQ,KAAK,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO;CAGrD,QADE,MAAM,SAAS,IAAI,MAAM,EAAE,CAAC,KAAK,MAAM,MAAM,SAAS,EAAE,CAAC,MAAM,MAAM,MAAM,IAAA,CAAK,MAAM,GAAG,CAAC,EAAA,CAC7E,YAAY;AAC7B;;AASA,SAAgB,OAAO,EAAE,MAAM,KAAK,OAAO,MAAM,WAAW,GAAG,SAAsB;CACnF,MAAM,CAAC,WAAW,gBAAgB,SAAiB;CACnD,MAAM,YAAY,OAAO,cAAc;CACvC,OACE,oBAAC,QAAD;EACE,GAAI;EACJ,WAAW,GACT,uKACA,MAAM,KAAK,CAAC,KACZ,SACF;EAEC,UAAA,YACC,oBAAC,OAAD;GACO;GACL,KAAK;GACL,WAAW;GACX,eAAe,aAAa,GAAG;GAC/B,WAAU;EACX,CAAA,IAED,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,QAAD;GAAM,eAAY;GAAQ,UAAA,SAAS,IAAI;EAAQ,CAAA,GAC/C,oBAAC,QAAD;GAAM,WAAU;GAAW,UAAA;EAAW,CAAA,CACtC,EAAA,CAAA;CA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jE,SAAS;QACT,UAAU,SAAS,KAAA,IAAY,EAAE,OAAO,IAAK;QAC7C,YAAY;QACZ,WAAW,GACT,6MACA,MAAM,KAAK,CAAC,GACd;QAEA,UAAA,oBAAC,iBAAD;SAAiB,SAAS;SAAO,MAAK;SACpC,UAAA,oBAAC,OAAO,MAAR;UAEE,eAAY;UACZ,SAAS;WAAE,SAAS;WAAG,GAAG,SAAS,IAAI,aAAa,IAAI;UAAG;UAC3D,SAAS;WAAE,SAAS;WAAG,GAAG;UAAE;UAC5B,MAAM;WAAE,SAAS;WAAG,GAAG,SAAS,IAAI,aAAa,KAAK;UAAE;UACxD,YAAY;WAAE,UAAU;WAAM,MAAM;UAAS;UAE5C,UAAA,aAAa,MAAM,IAAI;SACb,GARN,aAAa,SAAS,MAQhB;QACE,CAAA;OACJ,CAAA;MACJ,CAAA;KACJ,GArCL,UAqCK,IACT,IACW;;GACf,CAAA;EACD,CAAA;CACU,CAAA;AAErB"}
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { useFocusTrap } from "../../hooks/use-focus-trap.js";
3
- import { TOUCH_GESTURE_CONTENT_CLASS } from "../../lib/touch.js";
4
3
  import { EASE_DRAWER } from "../../lib/ease.js";
5
4
  import { t as PresenceGate } from "../../presence-gate-DC7yL1Ls.js";
5
+ import { TOUCH_GESTURE_CONTENT_CLASS } from "../../lib/touch.js";
6
6
  import { useEffect, useId, useRef, useState } from "react";
7
7
  import { cn } from "@kumix/utils";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -1 +1 @@
1
- {"version":3,"file":"bouncy-accordion.d.ts","names":[],"sources":["../../../src/components/motion/bouncy-accordion.tsx"],"mappings":";YASY;EACV;EACA,OAAO;EACP,cAAc;EACd,OAAO;EACP;;YAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAGe;EACf,OAAO;EACP;EACA;EACA,iBAAiB;EACjB;EACA;EACA,aAAa;;wBAwNC,kBACd,OACA,OACA,cACA,eACA,aACA,WACA,cACC,uCAAoB,IAAA"}
1
+ {"version":3,"file":"bouncy-accordion.d.ts","names":[],"sources":["../../../src/components/motion/bouncy-accordion.tsx"],"mappings":";YASY;EACV;EACA,OAAO;EACP,cAAc;EACd,OAAO;EACP;;YAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAGe;EACf,OAAO;EACP;EACA;EACA,iBAAiB;EACjB;EACA;EACA,aAAa;;wBAgNC,kBACd,OACA,OACA,cACA,eACA,aACA,WACA,cACC,uCAAoB,IAAA"}
@@ -6,15 +6,20 @@ import { jsx, jsxs } from "react/jsx-runtime";
6
6
  import { motion, useReducedMotion } from "motion/react";
7
7
  import { ChevronDown } from "lucide-react";
8
8
  // src/components/motion/bouncy-accordion.tsx
9
- const EXPAND_TRANSITION = {
9
+ const ROW_TRANSITION = {
10
+ type: "spring",
11
+ duration: .55,
12
+ bounce: .38
13
+ };
14
+ const CONTENT_OPEN_TRANSITION = {
10
15
  type: "spring",
11
16
  duration: .58,
12
17
  bounce: .32
13
18
  };
14
- const COLLAPSE_TRANSITION = {
19
+ const CONTENT_CLOSE_TRANSITION = {
15
20
  type: "spring",
16
21
  duration: .46,
17
- bounce: 0
22
+ bounce: .26
18
23
  };
19
24
  const DESCRIPTION_TRANSITION = {
20
25
  duration: .18,
@@ -33,7 +38,7 @@ function useControllableAccordionValue({ value, defaultValue, onValueChange }) {
33
38
  onValueChange?.(next);
34
39
  }, [isControlled, onValueChange])];
35
40
  }
36
- function BouncyAccordionRow({ item, open, startsGroup, endsGroup, separatedFromPrevious, contentId, triggerId, reduce, layoutTransition, layoutDependency, classNames, onToggle }) {
41
+ function BouncyAccordionRow({ item, open, startsGroup, endsGroup, separatedFromPrevious, contentId, triggerId, reduce, classNames, onToggle }) {
37
42
  const contentRef = useRef(null);
38
43
  const [contentHeight, setContentHeight] = useState(0);
39
44
  useLayoutEffect(() => {
@@ -50,15 +55,12 @@ function BouncyAccordionRow({ item, open, startsGroup, endsGroup, separatedFromP
50
55
  };
51
56
  }, []);
52
57
  return /* @__PURE__ */ jsx(motion.div, {
53
- layout: reduce ? false : "position",
54
- layoutDependency,
58
+ layout: "position",
55
59
  initial: false,
56
60
  style: { marginTop: separatedFromPrevious ? 12 : 0 },
57
- transition: { layout: layoutTransition },
61
+ transition: reduce ? { duration: 0 } : ROW_TRANSITION,
58
62
  children: /* @__PURE__ */ jsxs(motion.div, {
59
63
  "data-state": open ? "open" : "closed",
60
- layout: !reduce,
61
- layoutDependency,
62
64
  initial: false,
63
65
  animate: {
64
66
  borderTopLeftRadius: startsGroup ? 28 : 0,
@@ -66,20 +68,15 @@ function BouncyAccordionRow({ item, open, startsGroup, endsGroup, separatedFromP
66
68
  borderBottomLeftRadius: endsGroup ? 28 : 0,
67
69
  borderBottomRightRadius: endsGroup ? 28 : 0
68
70
  },
69
- transition: reduce ? { duration: 0 } : layoutTransition,
70
- style: { originY: 0 },
71
+ transition: reduce ? { duration: 0 } : ROW_TRANSITION,
71
72
  className: cn("bg-card text-card-foreground overflow-hidden", item.disabled && "opacity-50", classNames?.item),
72
- children: [/* @__PURE__ */ jsxs(motion.button, {
73
+ children: [/* @__PURE__ */ jsxs("button", {
73
74
  id: triggerId,
74
75
  type: "button",
75
76
  disabled: item.disabled,
76
77
  "aria-expanded": open,
77
78
  "aria-controls": contentId,
78
79
  onClick: onToggle,
79
- layout: reduce ? false : "position",
80
- layoutDependency,
81
- transition: { layout: layoutTransition },
82
- style: { originY: 0 },
83
80
  className: cn("flex min-h-[54px] w-full items-center gap-4 px-5 text-left transition-colors outline-none", "focus-visible:bg-muted/25", "disabled:pointer-events-none", classNames?.trigger),
84
81
  children: [
85
82
  item.icon ? /* @__PURE__ */ jsx("span", {
@@ -98,24 +95,20 @@ function BouncyAccordionRow({ item, open, startsGroup, endsGroup, separatedFromP
98
95
  children: /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4" })
99
96
  })
100
97
  ]
101
- }), /* @__PURE__ */ jsx("section", {
98
+ }), /* @__PURE__ */ jsx(motion.section, {
99
+ layout: "size",
102
100
  id: contentId,
103
101
  "aria-labelledby": triggerId,
104
102
  "aria-hidden": !open,
105
103
  inert: !open,
106
- style: { height: open && item.description ? contentHeight || "auto" : 0 },
107
- className: cn(classNames?.content),
104
+ initial: false,
105
+ style: { height: open && item.description ? contentHeight : 0 },
106
+ transition: reduce ? { duration: 0 } : open ? CONTENT_OPEN_TRANSITION : CONTENT_CLOSE_TRANSITION,
107
+ className: cn("overflow-hidden", classNames?.content),
108
108
  children: /* @__PURE__ */ jsx(motion.div, {
109
109
  ref: contentRef,
110
- layout: reduce ? false : "position",
111
- layoutDependency,
112
- initial: false,
113
110
  animate: { opacity: open ? 1 : 0 },
114
- transition: {
115
- opacity: reduce ? { duration: 0 } : DESCRIPTION_TRANSITION,
116
- layout: layoutTransition
117
- },
118
- style: { originY: 0 },
111
+ transition: reduce ? { duration: 0 } : DESCRIPTION_TRANSITION,
119
112
  className: "px-5 pb-5",
120
113
  children: /* @__PURE__ */ jsx("div", {
121
114
  className: cn("text-muted-foreground text-[15px] leading-6", classNames?.description),
@@ -135,11 +128,6 @@ function BouncyAccordion({ items, value, defaultValue = null, onValueChange, col
135
128
  onValueChange
136
129
  });
137
130
  const activeIndex = items.findIndex((item) => item.id === activeValue);
138
- const previousValue = useRef(activeValue);
139
- const layoutTransition = activeValue === null || previousValue.current !== null ? COLLAPSE_TRANSITION : EXPAND_TRANSITION;
140
- useLayoutEffect(() => {
141
- previousValue.current = activeValue;
142
- }, [activeValue]);
143
131
  const toggleItem = useCallback((id) => {
144
132
  if (activeValue === id) {
145
133
  if (collapsible) setActiveValue(null);
@@ -171,8 +159,6 @@ function BouncyAccordion({ items, value, defaultValue = null, onValueChange, col
171
159
  contentId,
172
160
  triggerId,
173
161
  reduce,
174
- layoutTransition,
175
- layoutDependency: activeValue,
176
162
  classNames,
177
163
  onToggle: () => toggleItem(item.id)
178
164
  }, item.id);
@@ -1 +1 @@
1
- {"version":3,"file":"bouncy-accordion.js","names":[],"sources":["../../../src/components/motion/bouncy-accordion.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useCallback, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport { ChevronDown } from \"lucide-react\";\nimport { motion, type Transition, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport type BouncyAccordionItem = {\n id: string;\n title: ReactNode;\n description?: ReactNode;\n icon?: ReactNode;\n disabled?: boolean;\n};\n\nexport type BouncyAccordionClassNames = {\n root?: string;\n item?: string;\n trigger?: string;\n icon?: string;\n title?: string;\n chevron?: string;\n content?: string;\n description?: string;\n};\n\nexport interface BouncyAccordionProps {\n items: BouncyAccordionItem[];\n value?: string | null;\n defaultValue?: string | null;\n onValueChange?: (value: string | null) => void;\n collapsible?: boolean;\n className?: string;\n classNames?: BouncyAccordionClassNames;\n}\n\n// Rows, cards and scale-corrected text share a transition so their edges\n// stay joined. A close or switch uses the faster non-overshooting spring;\n// opening from all-closed keeps the weighted bounce.\nconst EXPAND_TRANSITION: Transition = {\n type: \"spring\",\n duration: 0.58,\n bounce: 0.32,\n};\n\nconst COLLAPSE_TRANSITION: Transition = {\n type: \"spring\",\n duration: 0.46,\n bounce: 0,\n};\n\nconst DESCRIPTION_TRANSITION: Transition = {\n duration: 0.18,\n ease: EASE_OUT,\n};\n\nconst CHEVRON_TRANSITION: Transition = {\n type: \"spring\",\n duration: 0.42,\n bounce: 0.28,\n};\n\nfunction useControllableAccordionValue({\n value,\n defaultValue,\n onValueChange,\n}: {\n value?: string | null;\n defaultValue?: string | null;\n onValueChange?: (value: string | null) => void;\n}) {\n const [internalValue, setInternalValue] = useState(defaultValue ?? null);\n const isControlled = value !== undefined;\n const currentValue = isControlled ? value : internalValue;\n\n const setValue = useCallback(\n (next: string | null) => {\n if (!isControlled) {\n setInternalValue(next);\n }\n\n onValueChange?.(next);\n },\n [isControlled, onValueChange],\n );\n\n return [currentValue, setValue] as const;\n}\n\nfunction BouncyAccordionRow({\n item,\n open,\n startsGroup,\n endsGroup,\n separatedFromPrevious,\n contentId,\n triggerId,\n reduce,\n layoutTransition,\n layoutDependency,\n classNames,\n onToggle,\n}: {\n item: BouncyAccordionItem;\n open: boolean;\n startsGroup: boolean;\n endsGroup: boolean;\n separatedFromPrevious: boolean;\n contentId: string;\n triggerId: string;\n reduce: boolean | null;\n layoutTransition: Transition;\n layoutDependency: string | null;\n classNames?: BouncyAccordionClassNames;\n onToggle: () => void;\n}) {\n const contentRef = useRef<HTMLDivElement>(null);\n const [contentHeight, setContentHeight] = useState(0);\n\n useLayoutEffect(() => {\n const node = contentRef.current;\n if (!node) return;\n\n const updateHeight = () => {\n setContentHeight(node.offsetHeight);\n };\n\n updateHeight();\n\n const observer = new ResizeObserver(updateHeight);\n observer.observe(node);\n\n return () => {\n observer.disconnect();\n };\n }, []);\n\n return (\n <motion.div\n layout={reduce ? false : \"position\"}\n layoutDependency={layoutDependency}\n initial={false}\n style={{ marginTop: separatedFromPrevious ? 12 : 0 }}\n transition={{ layout: layoutTransition }}\n >\n <motion.div\n data-state={open ? \"open\" : \"closed\"}\n layout={!reduce}\n layoutDependency={layoutDependency}\n initial={false}\n animate={{\n borderTopLeftRadius: startsGroup ? 28 : 0,\n borderTopRightRadius: startsGroup ? 28 : 0,\n borderBottomLeftRadius: endsGroup ? 28 : 0,\n borderBottomRightRadius: endsGroup ? 28 : 0,\n }}\n transition={reduce ? { duration: 0 } : layoutTransition}\n style={{ originY: 0 }}\n className={cn(\n \"bg-card text-card-foreground overflow-hidden\",\n item.disabled && \"opacity-50\",\n classNames?.item,\n )}\n >\n <motion.button\n id={triggerId}\n type=\"button\"\n disabled={item.disabled}\n aria-expanded={open}\n aria-controls={contentId}\n onClick={onToggle}\n layout={reduce ? false : \"position\"}\n layoutDependency={layoutDependency}\n transition={{ layout: layoutTransition }}\n style={{ originY: 0 }}\n className={cn(\n \"flex min-h-[54px] w-full items-center gap-4 px-5 text-left transition-colors outline-none\",\n \"focus-visible:bg-muted/25\",\n \"disabled:pointer-events-none\",\n classNames?.trigger,\n )}\n >\n {item.icon ? (\n <span\n className={cn(\n \"text-muted-foreground grid h-7 w-7 shrink-0 place-items-center\",\n classNames?.icon,\n )}\n >\n {item.icon}\n </span>\n ) : null}\n <span\n className={cn(\n \"text-foreground min-w-0 flex-1 truncate text-[15px] font-medium\",\n classNames?.title,\n )}\n >\n {item.title}\n </span>\n <motion.span\n aria-hidden\n animate={{ rotate: open ? 180 : 0 }}\n transition={reduce ? { duration: 0 } : CHEVRON_TRANSITION}\n className={cn(\n \"text-muted-foreground grid h-6 w-6 shrink-0 place-items-center\",\n classNames?.chevron,\n )}\n >\n <ChevronDown className=\"h-4 w-4\" />\n </motion.span>\n </motion.button>\n\n <section\n id={contentId}\n aria-labelledby={triggerId}\n aria-hidden={!open}\n inert={!open}\n style={{ height: open && item.description ? contentHeight || \"auto\" : 0 }}\n className={cn(classNames?.content)}\n >\n <motion.div\n ref={contentRef}\n // The card clips this full-size layout node. Correcting only the\n // card scale avoids a one-pixel clip and its extreme text scale.\n // Size changes outside a toggle snap to their natural geometry.\n layout={reduce ? false : \"position\"}\n layoutDependency={layoutDependency}\n initial={false}\n animate={{ opacity: open ? 1 : 0 }}\n transition={{\n opacity: reduce ? { duration: 0 } : DESCRIPTION_TRANSITION,\n layout: layoutTransition,\n }}\n style={{ originY: 0 }}\n className=\"px-5 pb-5\"\n >\n <div\n className={cn(\"text-muted-foreground text-[15px] leading-6\", classNames?.description)}\n >\n {item.description}\n </div>\n </motion.div>\n </section>\n </motion.div>\n </motion.div>\n );\n}\n\nexport function BouncyAccordion({\n items,\n value,\n defaultValue = null,\n onValueChange,\n collapsible = true,\n className,\n classNames,\n}: BouncyAccordionProps) {\n const reduce = useReducedMotion();\n const baseId = useId();\n const [activeValue, setActiveValue] = useControllableAccordionValue({\n value,\n defaultValue,\n onValueChange,\n });\n const activeIndex = items.findIndex((item) => item.id === activeValue);\n const previousValue = useRef(activeValue);\n const layoutTransition =\n activeValue === null || previousValue.current !== null\n ? COLLAPSE_TRANSITION\n : EXPAND_TRANSITION;\n useLayoutEffect(() => {\n previousValue.current = activeValue;\n }, [activeValue]);\n\n const toggleItem = useCallback(\n (id: string) => {\n if (activeValue === id) {\n if (collapsible) {\n setActiveValue(null);\n }\n return;\n }\n\n setActiveValue(id);\n },\n [activeValue, collapsible, setActiveValue],\n );\n\n return (\n <div className={cn(\"w-full\", className, classNames?.root)}>\n {items.map((item, index) => {\n const open = activeValue === item.id;\n const previousIsOpen = activeIndex === index - 1;\n const nextIsOpen = activeIndex === index + 1;\n const startsGroup = open || index === 0 || previousIsOpen;\n const endsGroup = open || index === items.length - 1 || nextIsOpen;\n const separatedFromPrevious = index > 0 && (open || previousIsOpen);\n const contentId = `${baseId}-${item.id}-content`;\n const triggerId = `${baseId}-${item.id}-trigger`;\n\n return (\n <BouncyAccordionRow\n key={item.id}\n item={item}\n open={open}\n startsGroup={startsGroup}\n endsGroup={endsGroup}\n separatedFromPrevious={separatedFromPrevious}\n contentId={contentId}\n triggerId={triggerId}\n reduce={reduce}\n layoutTransition={layoutTransition}\n layoutDependency={activeValue}\n classNames={classNames}\n onToggle={() => toggleItem(item.id)}\n />\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAyCA,MAAM,oBAAgC;CACpC,MAAM;CACN,UAAU;CACV,QAAQ;AACV;AAEA,MAAM,sBAAkC;CACtC,MAAM;CACN,UAAU;CACV,QAAQ;AACV;AAEA,MAAM,yBAAqC;CACzC,UAAU;CACV,MAAM;AACR;AAEA,MAAM,qBAAiC;CACrC,MAAM;CACN,UAAU;CACV,QAAQ;AACV;AAEA,SAAS,8BAA8B,EACrC,OACA,cACA,iBAKC;CACD,MAAM,CAAC,eAAe,oBAAoB,SAAS,gBAAgB,IAAI;CACvE,MAAM,eAAe,UAAU,KAAA;CAc/B,OAAO,CAbc,eAAe,QAAQ,eAE3B,aACd,SAAwB;EACvB,IAAI,CA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AAW;CACrE,MAAM,gBAAgB,OAAO,WAAW;CACxC,MAAM,mBACJ,gBAAgB,QAAQ,cAAc,YAAY,OAC9C,sBACA;CACN,sBAAsB;EACpB,cAAc,UAAU;CAC1B,GAAG,CAAC,WAAW,CAAC;CAEhB,MAAM,aAAa,aAChB,OAAe;EACd,IAAI,gBAAgB,IAAI;GACtB,IAAI,aACF,eAAe,IAAI;GAErB;EACF;EAEA,eAAe,EAAE;CACnB,GACA;EAAC;EAAa;EAAa;CAAc,CAC3C;CAEA,OACE,oBAAC,OAAD;EAAK,WAAW,GAAG,UAAU,WAAW,YAAY,IAAI;EACrD,UAAA,MAAM,KAAK,MAAM,UAAU;GAC1B,MAAM,OAAO,gBAAgB,KAAK;GAClC,MAAM,iBAAiB,gBAAgB,QAAQ;GAC/C,MAAM,aAAa,gBAAgB,QAAQ;GAC3C,MAAM,cAAc,QAAQ,UAAU,KAAK;GAC3C,MAAM,YAAY,QAAQ,UAAU,MAAM,SAAS,KAAK;GACxD,MAAM,wBAAwB,QAAQ,MAAM,QAAQ;GACpD,MAAM,YAAY,GAAG,OAAO,GAAG,KAAK,GAAG;GACvC,MAAM,YAAY,GAAG,OAAO,GAAG,KAAK,GAAG;GAEvC,OACE,oBAAC,oBAAD;IAEQ;IACA;IACO;IACF;IACY;IACZ;IACA;IACH;IACU;IAClB,kBAAkB;IACN;IACZ,gBAAgB,WAAW,KAAK,EAAE;GACnC,GAbM,KAAK,EAaX;EAEL,CAAC;CACE,CAAA;AAET"}
1
+ {"version":3,"file":"bouncy-accordion.js","names":[],"sources":["../../../src/components/motion/bouncy-accordion.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useCallback, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport { ChevronDown } from \"lucide-react\";\nimport { motion, type Transition, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport type BouncyAccordionItem = {\n id: string;\n title: ReactNode;\n description?: ReactNode;\n icon?: ReactNode;\n disabled?: boolean;\n};\n\nexport type BouncyAccordionClassNames = {\n root?: string;\n item?: string;\n trigger?: string;\n icon?: string;\n title?: string;\n chevron?: string;\n content?: string;\n description?: string;\n};\n\nexport interface BouncyAccordionProps {\n items: BouncyAccordionItem[];\n value?: string | null;\n defaultValue?: string | null;\n onValueChange?: (value: string | null) => void;\n collapsible?: boolean;\n className?: string;\n classNames?: BouncyAccordionClassNames;\n}\n\n// Local springs keep the accordion's connected groups moving together while\n// avoiding scale projection on text-heavy row contents.\n// Gap spring: must not overshoot y — positive y overshoot drifts items below\n// their mt-3 resting point and briefly overlaps the next item.\nconst ROW_TRANSITION: Transition = {\n type: \"spring\",\n duration: 0.55,\n bounce: 0.38,\n};\n\nconst CONTENT_OPEN_TRANSITION: Transition = {\n type: \"spring\",\n duration: 0.58,\n bounce: 0.32,\n};\n\nconst CONTENT_CLOSE_TRANSITION: Transition = {\n type: \"spring\",\n duration: 0.46,\n bounce: 0.26,\n};\n\nconst DESCRIPTION_TRANSITION: Transition = {\n duration: 0.18,\n ease: EASE_OUT,\n};\n\nconst CHEVRON_TRANSITION: Transition = {\n type: \"spring\",\n duration: 0.42,\n bounce: 0.28,\n};\n\nfunction useControllableAccordionValue({\n value,\n defaultValue,\n onValueChange,\n}: {\n value?: string | null;\n defaultValue?: string | null;\n onValueChange?: (value: string | null) => void;\n}) {\n const [internalValue, setInternalValue] = useState(defaultValue ?? null);\n const isControlled = value !== undefined;\n const currentValue = isControlled ? value : internalValue;\n\n const setValue = useCallback(\n (next: string | null) => {\n if (!isControlled) {\n setInternalValue(next);\n }\n\n onValueChange?.(next);\n },\n [isControlled, onValueChange],\n );\n\n return [currentValue, setValue] as const;\n}\n\nfunction BouncyAccordionRow({\n item,\n open,\n startsGroup,\n endsGroup,\n separatedFromPrevious,\n contentId,\n triggerId,\n reduce,\n classNames,\n onToggle,\n}: {\n item: BouncyAccordionItem;\n open: boolean;\n startsGroup: boolean;\n endsGroup: boolean;\n separatedFromPrevious: boolean;\n contentId: string;\n triggerId: string;\n reduce: boolean | null;\n classNames?: BouncyAccordionClassNames;\n onToggle: () => void;\n}) {\n const contentRef = useRef<HTMLDivElement>(null);\n const [contentHeight, setContentHeight] = useState(0);\n\n useLayoutEffect(() => {\n const node = contentRef.current;\n if (!node) return;\n\n const updateHeight = () => {\n setContentHeight(node.offsetHeight);\n };\n\n updateHeight();\n\n const observer = new ResizeObserver(updateHeight);\n observer.observe(node);\n\n return () => {\n observer.disconnect();\n };\n }, []);\n\n return (\n <motion.div\n layout=\"position\"\n initial={false}\n style={{ marginTop: separatedFromPrevious ? 12 : 0 }}\n transition={reduce ? { duration: 0 } : ROW_TRANSITION}\n >\n <motion.div\n data-state={open ? \"open\" : \"closed\"}\n initial={false}\n animate={{\n borderTopLeftRadius: startsGroup ? 28 : 0,\n borderTopRightRadius: startsGroup ? 28 : 0,\n borderBottomLeftRadius: endsGroup ? 28 : 0,\n borderBottomRightRadius: endsGroup ? 28 : 0,\n }}\n transition={reduce ? { duration: 0 } : ROW_TRANSITION}\n className={cn(\n \"bg-card text-card-foreground overflow-hidden\",\n item.disabled && \"opacity-50\",\n classNames?.item,\n )}\n >\n <button\n id={triggerId}\n type=\"button\"\n disabled={item.disabled}\n aria-expanded={open}\n aria-controls={contentId}\n onClick={onToggle}\n className={cn(\n \"flex min-h-[54px] w-full items-center gap-4 px-5 text-left transition-colors outline-none\",\n \"focus-visible:bg-muted/25\",\n \"disabled:pointer-events-none\",\n classNames?.trigger,\n )}\n >\n {item.icon ? (\n <span\n className={cn(\n \"text-muted-foreground grid h-7 w-7 shrink-0 place-items-center\",\n classNames?.icon,\n )}\n >\n {item.icon}\n </span>\n ) : null}\n <span\n className={cn(\n \"text-foreground min-w-0 flex-1 truncate text-[15px] font-medium\",\n classNames?.title,\n )}\n >\n {item.title}\n </span>\n <motion.span\n aria-hidden\n animate={{ rotate: open ? 180 : 0 }}\n transition={reduce ? { duration: 0 } : CHEVRON_TRANSITION}\n className={cn(\n \"text-muted-foreground grid h-6 w-6 shrink-0 place-items-center\",\n classNames?.chevron,\n )}\n >\n <ChevronDown className=\"h-4 w-4\" />\n </motion.span>\n </button>\n\n <motion.section\n layout=\"size\"\n id={contentId}\n aria-labelledby={triggerId}\n aria-hidden={!open}\n inert={!open}\n initial={false}\n style={{ height: open && item.description ? contentHeight : 0 }}\n transition={\n reduce ? { duration: 0 } : open ? CONTENT_OPEN_TRANSITION : CONTENT_CLOSE_TRANSITION\n }\n className={cn(\"overflow-hidden\", classNames?.content)}\n >\n <motion.div\n ref={contentRef}\n animate={{\n opacity: open ? 1 : 0,\n }}\n transition={reduce ? { duration: 0 } : DESCRIPTION_TRANSITION}\n className=\"px-5 pb-5\"\n >\n <div\n className={cn(\"text-muted-foreground text-[15px] leading-6\", classNames?.description)}\n >\n {item.description}\n </div>\n </motion.div>\n </motion.section>\n </motion.div>\n </motion.div>\n );\n}\n\nexport function BouncyAccordion({\n items,\n value,\n defaultValue = null,\n onValueChange,\n collapsible = true,\n className,\n classNames,\n}: BouncyAccordionProps) {\n const reduce = useReducedMotion();\n const baseId = useId();\n const [activeValue, setActiveValue] = useControllableAccordionValue({\n value,\n defaultValue,\n onValueChange,\n });\n const activeIndex = items.findIndex((item) => item.id === activeValue);\n\n const toggleItem = useCallback(\n (id: string) => {\n if (activeValue === id) {\n if (collapsible) {\n setActiveValue(null);\n }\n return;\n }\n\n setActiveValue(id);\n },\n [activeValue, collapsible, setActiveValue],\n );\n\n return (\n <div className={cn(\"w-full\", className, classNames?.root)}>\n {items.map((item, index) => {\n const open = activeValue === item.id;\n const previousIsOpen = activeIndex === index - 1;\n const nextIsOpen = activeIndex === index + 1;\n const startsGroup = open || index === 0 || previousIsOpen;\n const endsGroup = open || index === items.length - 1 || nextIsOpen;\n const separatedFromPrevious = index > 0 && (open || previousIsOpen);\n const contentId = `${baseId}-${item.id}-content`;\n const triggerId = `${baseId}-${item.id}-trigger`;\n\n return (\n <BouncyAccordionRow\n key={item.id}\n item={item}\n open={open}\n startsGroup={startsGroup}\n endsGroup={endsGroup}\n separatedFromPrevious={separatedFromPrevious}\n contentId={contentId}\n triggerId={triggerId}\n reduce={reduce}\n classNames={classNames}\n onToggle={() => toggleItem(item.id)}\n />\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;AA0CA,MAAM,iBAA6B;CACjC,MAAM;CACN,UAAU;CACV,QAAQ;AACV;AAEA,MAAM,0BAAsC;CAC1C,MAAM;CACN,UAAU;CACV,QAAQ;AACV;AAEA,MAAM,2BAAuC;CAC3C,MAAM;CACN,UAAU;CACV,QAAQ;AACV;AAEA,MAAM,yBAAqC;CACzC,UAAU;CACV,MAAM;AACR;AAEA,MAAM,qBAAiC;CACrC,MAAM;CACN,UAAU;CACV,QAAQ;AACV;AAEA,SAAS,8BAA8B,EACrC,OACA,cACA,iBAKC;CACD,MAAM,CAAC,eAAe,oBAAoB,SAAS,gBAAgB,IAAI;CACvE,MAAM,eAAe,UAAU,KAAA;CAc/B,OAAO,CAbc,eAAe,QAAQ,eAE3B,aACd,SAAwB;EACvB,IAAI,CAAC,cACH,iBAAiB,IAAI;EAGvB,gBAAgB,IAAI;CACtB,GACA,CAAC,cAAc,aAAa,CAGD,CAAC;AAChC;AAEA,SAAS,mBAAmB,EAC1B,MACA,MACA,aACA,WACA,uBACA,WACA,WACA,QACA,YACA,YAYC;CACD,MAAM,aAAa,OAAuB,IAAI;CAC9C,MAAM,CAAC,eAAe,oBAAoB,SAAS,CAAC;CAEpD,sBAAsB;EACpB,MAAM,OAAO,WAAW;EACxB,IAAI,CAAC,MAAM;EAEX,MAAM,qBAAqB;GACzB,iBAAiB,KAAK,YAAY;EACpC;EAEA,aAAa;EAEb,MAAM,WAAW,IAAI,eAAe,YAAY;EAChD,SAAS,QAAQ,IAAI;EAErB,aAAa;GACX,SAAS,WAAW;EACtB;CACF,GAAG,CAAC,CAAC;CAEL,OACE,oBAAC,OAAO,KAAR;EACE,QAAO;EACP,SAAS;EACT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ET"}
@@ -192,9 +192,6 @@ function BreadcrumbEllipsis({ children, className, label = "Show hidden paths" }
192
192
  type: "button",
193
193
  "aria-label": label,
194
194
  className: "text-muted-foreground hover:bg-muted/60 hover:text-foreground focus-visible:ring-ring inline-flex size-8 items-center justify-center rounded-md transition-colors focus-visible:ring-2 focus-visible:outline-none",
195
- onClick: (event) => {
196
- focusOnOpen.current = event.detail === 0;
197
- },
198
195
  onKeyDown: (event) => {
199
196
  if (event.key === "ArrowDown") {
200
197
  event.preventDefault();
@@ -1 +1 @@
1
- {"version":3,"file":"breadcrumb.js","names":[],"sources":["../../../src/components/motion/breadcrumb.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n Children,\n type ComponentPropsWithRef,\n forwardRef,\n type ReactElement,\n type ReactNode,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { ChevronRight, Ellipsis } from \"lucide-react\";\nimport {\n AnimatePresence,\n type HTMLMotionProps,\n LayoutGroup,\n motion,\n useIsPresent,\n useReducedMotion,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useHoverCapable } from \"../../hooks/use-hover-capable\";\nimport { EASE_OUT, SPRING_LAYOUT } from \"../../lib/ease\";\nimport { MorphPopover, MorphPopoverContent, MorphPopoverTrigger } from \"./popover-morph\";\n\nexport type BreadcrumbProps = ComponentPropsWithRef<\"nav\">;\n\n/** A navigation landmark. Keep it mounted while the route changes. */\nexport function Breadcrumb({ className, children, ...props }: BreadcrumbProps) {\n const id = useId();\n return (\n <nav aria-label=\"Breadcrumb\" {...props} className={cn(\"min-w-0\", className)}>\n <LayoutGroup id={id}>{children}</LayoutGroup>\n </nav>\n );\n}\n\nexport type BreadcrumbListProps = ComponentPropsWithRef<\"ol\"> & {\n /** Maximum visible slots, including the ellipsis. Minimum 3; Infinity disables collapsing. */\n maxItems?: number;\n /** Accessible label for the hidden ancestor disclosure. */\n overflowLabel?: string;\n};\n\n/** Pass keyed BreadcrumbItems directly so entering and leaving routes animate. */\nexport function BreadcrumbList({\n className,\n children,\n maxItems = 4,\n overflowLabel = \"Show hidden paths\",\n ...props\n}: BreadcrumbListProps) {\n const items = Children.toArray(children);\n const limit = Number.isFinite(maxItems) ? Math.max(3, Math.floor(maxItems)) : 4;\n const collapse = maxItems !== Infinity && items.length > limit;\n const tailCount = limit - 2;\n const visible = collapse\n ? [\n items[0],\n <BreadcrumbItem key=\"breadcrumb-overflow\">\n <BreadcrumbSeparator />\n <BreadcrumbEllipsis label={overflowLabel}>\n {items.slice(1, -tailCount)}\n </BreadcrumbEllipsis>\n </BreadcrumbItem>,\n ...items.slice(-tailCount),\n ]\n : items;\n return (\n <ol\n {...props}\n className={cn(\"relative flex flex-wrap items-center gap-x-1 gap-y-1 text-sm\", className)}\n >\n <AnimatePresence initial={false} mode=\"popLayout\">\n {visible}\n </AnimatePresence>\n </ol>\n );\n}\n\nexport type BreadcrumbItemProps = HTMLMotionProps<\"li\">;\n\n/** Use a stable route key; put its optional separator inside this item. */\nexport const BreadcrumbItem = forwardRef<HTMLLIElement, BreadcrumbItemProps>(\n function BreadcrumbItem({ className, style, children, ...props }, ref) {\n const reduce = useReducedMotion();\n const present = useIsPresent();\n const itemRef = useRef<HTMLLIElement>(null);\n useLayoutEffect(() => {\n const item = itemRef.current;\n if (!item || !present) return;\n const measure = () => {\n // popLayout snapshots offsetWidth (integer pixels). Retain the exact\n // width so a fractional-pixel loss cannot wrap the final character.\n item.style.setProperty(\n \"--breadcrumb-exit-width\",\n `${item.getBoundingClientRect().width}px`,\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(item);\n return () => observer.disconnect();\n }, [present]);\n const hidden = { opacity: 0, y: reduce ? 0 : 6 };\n return (\n <motion.li\n ref={(node) => {\n itemRef.current = node;\n if (typeof ref === \"function\") return ref(node);\n if (ref) ref.current = node;\n }}\n layout={reduce ? false : \"position\"}\n initial={hidden}\n animate={{ opacity: 1, y: 0 }}\n exit={hidden}\n transition={{ duration: 0.2, ease: EASE_OUT, layout: SPRING_LAYOUT }}\n {...props}\n inert={!present}\n aria-hidden={!present || undefined}\n style={{\n ...style,\n minWidth: present ? style?.minWidth : \"var(--breadcrumb-exit-width)\",\n pointerEvents: present ? style?.pointerEvents : \"none\",\n }}\n className={cn(\"relative inline-flex max-w-full min-w-0 items-center gap-1\", className)}\n >\n {children}\n </motion.li>\n );\n },\n);\n\nexport type BreadcrumbLinkProps = ComponentPropsWithRef<\"a\"> & {\n /** Render your router's Link, spreading these props onto it. */\n render?: (props: ComponentPropsWithRef<\"a\">) => ReactElement;\n};\n\nexport function BreadcrumbLink({ className, render, ...props }: BreadcrumbLinkProps) {\n const linkProps = {\n ...props,\n className: cn(\n \"text-muted-foreground hover:bg-muted/60 hover:text-foreground focus-visible:ring-ring inline-flex min-h-8 min-w-0 items-center gap-1.5 rounded-md px-2 font-medium transition-colors duration-150 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none [&>svg]:size-3.5 [&>svg]:shrink-0\",\n className,\n ),\n };\n return render ? render(linkProps) : <a {...linkProps} />;\n}\n\nexport type BreadcrumbPageProps = ComponentPropsWithRef<\"span\">;\n\nexport function BreadcrumbPage({ className, children, ...props }: BreadcrumbPageProps) {\n return (\n <span\n {...props}\n aria-current=\"page\"\n className={cn(\n \"text-foreground focus-visible:ring-ring relative isolate inline-flex min-h-8 min-w-0 items-center gap-1.5 rounded-md px-2 font-medium wrap-anywhere focus-visible:ring-2 focus-visible:outline-none [&>svg]:size-3.5 [&>svg]:shrink-0\",\n className,\n )}\n >\n {children}\n </span>\n );\n}\n\nexport type BreadcrumbSeparatorProps = ComponentPropsWithRef<\"span\">;\n\n/** Decorative separator, placed inside the following BreadcrumbItem. */\nexport function BreadcrumbSeparator({ className, children, ...props }: BreadcrumbSeparatorProps) {\n return (\n <span\n {...props}\n aria-hidden=\"true\"\n data-breadcrumb-separator=\"\"\n className={cn(\n \"text-muted-foreground/50 inline-flex shrink-0 items-center rtl:rotate-180 [&>svg]:size-3.5\",\n className,\n )}\n >\n {children ?? <ChevronRight />}\n </span>\n );\n}\n\nexport interface BreadcrumbEllipsisProps {\n /** Hidden BreadcrumbItems, in path order. */\n children: ReactNode;\n className?: string;\n label?: string;\n}\n\n/** Hover disclosure with click/touch toggle and keyboard access to ancestor links. */\nexport function BreadcrumbEllipsis({\n children,\n className,\n label = \"Show hidden paths\",\n}: BreadcrumbEllipsisProps) {\n const [open, setOpen] = useState(false);\n const [placement, setPlacement] = useState<{\n align: \"start\" | \"end\";\n side: \"top\" | \"bottom\";\n width: number;\n }>({ align: \"start\", side: \"bottom\", width: 224 });\n const canHover = useHoverCapable();\n const present = useIsPresent();\n const trigger = useRef<HTMLButtonElement>(null);\n const panel = useRef<HTMLOListElement>(null);\n const focusOnOpen = useRef(false);\n const closeTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useLayoutEffect(() => {\n if (!open) return;\n const update = () => {\n const rect = trigger.current?.getBoundingClientRect();\n if (!rect) return;\n const right = window.innerWidth - rect.left - 8;\n const left = rect.right - 8;\n const align = right < 224 && left > right ? \"end\" : \"start\";\n const below = window.innerHeight - rect.bottom;\n setPlacement({\n align,\n side: below < 280 && rect.top > below ? \"top\" : \"bottom\",\n width: Math.max(32, Math.min(224, align === \"start\" ? right : left)),\n });\n };\n update();\n window.addEventListener(\"resize\", update);\n return () => window.removeEventListener(\"resize\", update);\n }, [open]);\n\n const cancelClose = () => {\n if (closeTimer.current !== null) clearTimeout(closeTimer.current);\n closeTimer.current = null;\n };\n const leave = () => {\n cancelClose();\n // Allow the pointer to cross the gap between the trigger and portal.\n closeTimer.current = setTimeout(() => {\n if (\n !panel.current?.contains(document.activeElement) &&\n document.activeElement !== trigger.current\n )\n setOpen(false);\n }, 160);\n };\n useEffect(\n () => () => {\n if (closeTimer.current !== null) clearTimeout(closeTimer.current);\n },\n [],\n );\n\n useEffect(() => {\n if (!open) return;\n const onFocus = (event: FocusEvent) => {\n if (\n event.target instanceof Node &&\n event.target !== trigger.current &&\n !panel.current?.contains(event.target)\n )\n setOpen(false);\n };\n document.addEventListener(\"focusin\", onFocus);\n return () => document.removeEventListener(\"focusin\", onFocus);\n }, [open]);\n\n return (\n <MorphPopover open={open && present} onOpenChange={setOpen} className={cn(className)}>\n <span\n onPointerEnter={(event) => {\n cancelClose();\n if (canHover && event.pointerType === \"mouse\") {\n focusOnOpen.current = false;\n setOpen(true);\n }\n }}\n onPointerLeave={leave}\n >\n <MorphPopoverTrigger>\n <button\n ref={trigger}\n type=\"button\"\n aria-label={label}\n className=\"text-muted-foreground hover:bg-muted/60 hover:text-foreground focus-visible:ring-ring inline-flex size-8 items-center justify-center rounded-md transition-colors focus-visible:ring-2 focus-visible:outline-none\"\n onClick={(event) => {\n focusOnOpen.current = event.detail === 0;\n }}\n onKeyDown={(event) => {\n if (event.key === \"ArrowDown\") {\n event.preventDefault();\n focusOnOpen.current = true;\n setOpen(true);\n panel.current?.querySelector<HTMLElement>(\"a[href],button\")?.focus();\n }\n }}\n >\n <Ellipsis aria-hidden=\"true\" className=\"size-4\" />\n </button>\n </MorphPopoverTrigger>\n <MorphPopoverContent\n align={placement.align}\n side={placement.side}\n radius={10}\n sideOffset={6}\n className=\"p-1.5\"\n >\n <BreadcrumbOverflowPaths\n ref={panel}\n style={{ width: placement.width - 14 }}\n focusOnOpen={focusOnOpen}\n onPointerEnter={() => {\n cancelClose();\n setOpen(true);\n }}\n onPointerLeave={leave}\n onClick={(event) => {\n if ((event.target as Element).closest(\"a[href]\")) setOpen(false);\n }}\n >\n {children}\n </BreadcrumbOverflowPaths>\n </MorphPopoverContent>\n </span>\n </MorphPopover>\n );\n}\n\nfunction BreadcrumbOverflowPaths({\n focusOnOpen,\n ref,\n ...props\n}: ComponentPropsWithRef<\"ol\"> & { focusOnOpen: { current: boolean } }) {\n const localRef = useRef<HTMLOListElement>(null);\n useLayoutEffect(() => {\n if (!focusOnOpen.current) return;\n const focus = () => localRef.current?.querySelector<HTMLElement>(\"a[href],button\")?.focus();\n focus();\n // The portal becomes visible after its parent's layout measurement.\n const frame = requestAnimationFrame(() => {\n focus();\n focusOnOpen.current = false;\n });\n return () => cancelAnimationFrame(frame);\n }, [focusOnOpen]);\n return (\n <ol\n {...props}\n ref={(node) => {\n localRef.current = node;\n if (typeof ref === \"function\") return ref(node);\n if (ref) ref.current = node;\n }}\n className=\"flex max-h-64 flex-col gap-0.5 overflow-y-auto **:data-breadcrumb-separator:hidden [&_a]:w-full [&_a]:py-1 [&_a]:wrap-anywhere [&>li]:w-full\"\n />\n );\n}\n"],"mappings":";;;;;;;;;;;AAgCA,SAAgB,WAAW,EAAE,WAAW,UAAU,GAAG,SAA0B;CAC7E,MAAM,KAAK,MAAM;CACjB,OACE,oBAAC,OAAD;EAAK,cAAW;EAAa,GAAI;EAAO,WAAW,GAAG,WAAW,SAAS;EACxE,UAAA,oBAAC,aAAD;GAAiB;GAAK;EAAsB,CAAA;CACzC,CAAA;AAET;;AAUA,SAAgB,eAAe,EAC7B,WACA,UACA,WAAW,GACX,gBAAgB,qBAChB,GAAG,SACmB;CACtB,MAAM,QAAQ,SAAS,QAAQ,QAAQ;CACvC,MAAM,QAAQ,OAAO,SAAS,QAAQ,IAAI,KAAK,IAAI,GAAG,KAAK,MAAM,QAAQ,CAAC,IAAI;CAC9E,MAAM,WAAW,aAAa,YAAY,MAAM,SAAS;CACzD,MAAM,YAAY,QAAQ;CAC1B,MAAM,UAAU,WACZ;EACE,MAAM;EACN,qBAAC,gBAAD,EAAA,UAAA,CACE,oBAAC,qBAAD,CAAsB,CAAA,GACtB,oBAAC,oBAAD;GAAoB,OAAO;GACxB,UAAA,MAAM,MAAM,GAAG,CAAC,SAAS;EACR,CAAA,CACN,EAAA,GALI,qBAKJ;EAChB,GAAG,MAAM,MAAM,CAAC,SAAS;CAC3B,IACA;CACJ,OACE,oBAAC,MAAD;EACE,GAAI;EACJ,WAAW,GAAG,gEAAgE,SAAS;EAEvF,UAAA,oBAAC,iBAAD;GAAiB,SAAS;GAA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S,cAA2B,gBAAgB,CAAC,EAAE,MAAM;KACrE;IACF;IAEA,UAAA,oBAAC,UAAD;KAAU,eAAY;KAAO,WAAU;IAAU,CAAA;GAC3C,CAAA,EACW,CAAA,GACrB,oBAAC,qBAAD;IACE,OAAO,UAAU;IACjB,MAAM,UAAU;IAChB,QAAQ;IACR,YAAY;IACZ,WAAU;IAEV,UAAA,oBAAC,yBAAD;KACE,KAAK;KACL,OAAO,EAAE,OAAO,UAAU,QAAQ,GAAG;KACxB;KACb,sBAAsB;MACpB,YAAY;MACZ,QAAQ,IAAI;KACd;KACA,gBAAgB;KAChB,UAAU,UAAU;MAClB,IAAK,MAAM,OAAmB,QAAQ,SAAS,GAAG,QAAQ,KAAK;KACjE;KAEC;IACsB,CAAA;GACN,CAAA,CACjB;;CACM,CAAA;AAElB;AAEA,SAAS,wBAAwB,EAC/B,aACA,KACA,GAAG,SACmE;CACtE,MAAM,WAAW,OAAyB,IAAI;CAC9C,sBAAsB;EACpB,IAAI,CAAC,YAAY,SAAS;EAC1B,MAAM,cAAc,SAAS,SAAS,cAA2B,gBAAgB,CAAC,EAAE,MAAM;EAC1F,MAAM;EAEN,MAAM,QAAQ,4BAA4B;GACxC,MAAM;GACN,YAAY,UAAU;EACxB,CAAC;EACD,aAAa,qBAAqB,KAAK;CACzC,GAAG,CAAC,WAAW,CAAC;CAChB,OACE,oBAAC,MAAD;EACE,GAAI;EACJ,MAAM,SAAS;GACb,SAAS,UAAU;GACnB,IAAI,OAAO,QAAQ,YAAY,OAAO,IAAI,IAAI;GAC9C,IAAI,KAAK,IAAI,UAAU;EACzB;EACA,WAAU;CACX,CAAA;AAEL"}
1
+ {"version":3,"file":"breadcrumb.js","names":[],"sources":["../../../src/components/motion/breadcrumb.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n Children,\n type ComponentPropsWithRef,\n forwardRef,\n type ReactElement,\n type ReactNode,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { ChevronRight, Ellipsis } from \"lucide-react\";\nimport {\n AnimatePresence,\n type HTMLMotionProps,\n LayoutGroup,\n motion,\n useIsPresent,\n useReducedMotion,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useHoverCapable } from \"../../hooks/use-hover-capable\";\nimport { EASE_OUT, SPRING_LAYOUT } from \"../../lib/ease\";\nimport { MorphPopover, MorphPopoverContent, MorphPopoverTrigger } from \"./popover-morph\";\n\nexport type BreadcrumbProps = ComponentPropsWithRef<\"nav\">;\n\n/** A navigation landmark. Keep it mounted while the route changes. */\nexport function Breadcrumb({ className, children, ...props }: BreadcrumbProps) {\n const id = useId();\n return (\n <nav aria-label=\"Breadcrumb\" {...props} className={cn(\"min-w-0\", className)}>\n <LayoutGroup id={id}>{children}</LayoutGroup>\n </nav>\n );\n}\n\nexport type BreadcrumbListProps = ComponentPropsWithRef<\"ol\"> & {\n /** Maximum visible slots, including the ellipsis. Minimum 3; Infinity disables collapsing. */\n maxItems?: number;\n /** Accessible label for the hidden ancestor disclosure. */\n overflowLabel?: string;\n};\n\n/** Pass keyed BreadcrumbItems directly so entering and leaving routes animate. */\nexport function BreadcrumbList({\n className,\n children,\n maxItems = 4,\n overflowLabel = \"Show hidden paths\",\n ...props\n}: BreadcrumbListProps) {\n const items = Children.toArray(children);\n const limit = Number.isFinite(maxItems) ? Math.max(3, Math.floor(maxItems)) : 4;\n const collapse = maxItems !== Infinity && items.length > limit;\n const tailCount = limit - 2;\n const visible = collapse\n ? [\n items[0],\n <BreadcrumbItem key=\"breadcrumb-overflow\">\n <BreadcrumbSeparator />\n <BreadcrumbEllipsis label={overflowLabel}>\n {items.slice(1, -tailCount)}\n </BreadcrumbEllipsis>\n </BreadcrumbItem>,\n ...items.slice(-tailCount),\n ]\n : items;\n return (\n <ol\n {...props}\n className={cn(\"relative flex flex-wrap items-center gap-x-1 gap-y-1 text-sm\", className)}\n >\n <AnimatePresence initial={false} mode=\"popLayout\">\n {visible}\n </AnimatePresence>\n </ol>\n );\n}\n\nexport type BreadcrumbItemProps = HTMLMotionProps<\"li\">;\n\n/** Use a stable route key; put its optional separator inside this item. */\nexport const BreadcrumbItem = forwardRef<HTMLLIElement, BreadcrumbItemProps>(\n function BreadcrumbItem({ className, style, children, ...props }, ref) {\n const reduce = useReducedMotion();\n const present = useIsPresent();\n const itemRef = useRef<HTMLLIElement>(null);\n useLayoutEffect(() => {\n const item = itemRef.current;\n if (!item || !present) return;\n const measure = () => {\n // popLayout snapshots offsetWidth (integer pixels). Retain the exact\n // width so a fractional-pixel loss cannot wrap the final character.\n item.style.setProperty(\n \"--breadcrumb-exit-width\",\n `${item.getBoundingClientRect().width}px`,\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(item);\n return () => observer.disconnect();\n }, [present]);\n const hidden = { opacity: 0, y: reduce ? 0 : 6 };\n return (\n <motion.li\n ref={(node) => {\n itemRef.current = node;\n if (typeof ref === \"function\") return ref(node);\n if (ref) ref.current = node;\n }}\n layout={reduce ? false : \"position\"}\n initial={hidden}\n animate={{ opacity: 1, y: 0 }}\n exit={hidden}\n transition={{ duration: 0.2, ease: EASE_OUT, layout: SPRING_LAYOUT }}\n {...props}\n inert={!present}\n aria-hidden={!present || undefined}\n style={{\n ...style,\n minWidth: present ? style?.minWidth : \"var(--breadcrumb-exit-width)\",\n pointerEvents: present ? style?.pointerEvents : \"none\",\n }}\n className={cn(\"relative inline-flex max-w-full min-w-0 items-center gap-1\", className)}\n >\n {children}\n </motion.li>\n );\n },\n);\n\nexport type BreadcrumbLinkProps = ComponentPropsWithRef<\"a\"> & {\n /** Render your router's Link, spreading these props onto it. */\n render?: (props: ComponentPropsWithRef<\"a\">) => ReactElement;\n};\n\nexport function BreadcrumbLink({ className, render, ...props }: BreadcrumbLinkProps) {\n const linkProps = {\n ...props,\n className: cn(\n \"text-muted-foreground hover:bg-muted/60 hover:text-foreground focus-visible:ring-ring inline-flex min-h-8 min-w-0 items-center gap-1.5 rounded-md px-2 font-medium transition-colors duration-150 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none [&>svg]:size-3.5 [&>svg]:shrink-0\",\n className,\n ),\n };\n return render ? render(linkProps) : <a {...linkProps} />;\n}\n\nexport type BreadcrumbPageProps = ComponentPropsWithRef<\"span\">;\n\nexport function BreadcrumbPage({ className, children, ...props }: BreadcrumbPageProps) {\n return (\n <span\n {...props}\n aria-current=\"page\"\n className={cn(\n \"text-foreground focus-visible:ring-ring relative isolate inline-flex min-h-8 min-w-0 items-center gap-1.5 rounded-md px-2 font-medium wrap-anywhere focus-visible:ring-2 focus-visible:outline-none [&>svg]:size-3.5 [&>svg]:shrink-0\",\n className,\n )}\n >\n {children}\n </span>\n );\n}\n\nexport type BreadcrumbSeparatorProps = ComponentPropsWithRef<\"span\">;\n\n/** Decorative separator, placed inside the following BreadcrumbItem. */\nexport function BreadcrumbSeparator({ className, children, ...props }: BreadcrumbSeparatorProps) {\n return (\n <span\n {...props}\n aria-hidden=\"true\"\n data-breadcrumb-separator=\"\"\n className={cn(\n \"text-muted-foreground/50 inline-flex shrink-0 items-center rtl:rotate-180 [&>svg]:size-3.5\",\n className,\n )}\n >\n {children ?? <ChevronRight />}\n </span>\n );\n}\n\nexport interface BreadcrumbEllipsisProps {\n /** Hidden BreadcrumbItems, in path order. */\n children: ReactNode;\n className?: string;\n label?: string;\n}\n\n/** Hover disclosure with click/touch toggle and keyboard access to ancestor links. */\nexport function BreadcrumbEllipsis({\n children,\n className,\n label = \"Show hidden paths\",\n}: BreadcrumbEllipsisProps) {\n const [open, setOpen] = useState(false);\n const [placement, setPlacement] = useState<{\n align: \"start\" | \"end\";\n side: \"top\" | \"bottom\";\n width: number;\n }>({ align: \"start\", side: \"bottom\", width: 224 });\n const canHover = useHoverCapable();\n const present = useIsPresent();\n const trigger = useRef<HTMLButtonElement>(null);\n const panel = useRef<HTMLOListElement>(null);\n const focusOnOpen = useRef(false);\n const closeTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useLayoutEffect(() => {\n if (!open) return;\n const update = () => {\n const rect = trigger.current?.getBoundingClientRect();\n if (!rect) return;\n const right = window.innerWidth - rect.left - 8;\n const left = rect.right - 8;\n const align = right < 224 && left > right ? \"end\" : \"start\";\n const below = window.innerHeight - rect.bottom;\n setPlacement({\n align,\n side: below < 280 && rect.top > below ? \"top\" : \"bottom\",\n width: Math.max(32, Math.min(224, align === \"start\" ? right : left)),\n });\n };\n update();\n window.addEventListener(\"resize\", update);\n return () => window.removeEventListener(\"resize\", update);\n }, [open]);\n\n const cancelClose = () => {\n if (closeTimer.current !== null) clearTimeout(closeTimer.current);\n closeTimer.current = null;\n };\n const leave = () => {\n cancelClose();\n // Allow the pointer to cross the gap between the trigger and portal.\n closeTimer.current = setTimeout(() => {\n if (\n !panel.current?.contains(document.activeElement) &&\n document.activeElement !== trigger.current\n )\n setOpen(false);\n }, 160);\n };\n useEffect(\n () => () => {\n if (closeTimer.current !== null) clearTimeout(closeTimer.current);\n },\n [],\n );\n\n useEffect(() => {\n if (!open) return;\n const onFocus = (event: FocusEvent) => {\n if (\n event.target instanceof Node &&\n event.target !== trigger.current &&\n !panel.current?.contains(event.target)\n )\n setOpen(false);\n };\n document.addEventListener(\"focusin\", onFocus);\n return () => document.removeEventListener(\"focusin\", onFocus);\n }, [open]);\n\n return (\n <MorphPopover open={open && present} onOpenChange={setOpen} className={cn(className)}>\n <span\n onPointerEnter={(event) => {\n cancelClose();\n if (canHover && event.pointerType === \"mouse\") {\n focusOnOpen.current = false;\n setOpen(true);\n }\n }}\n onPointerLeave={leave}\n >\n <MorphPopoverTrigger>\n <button\n ref={trigger}\n type=\"button\"\n aria-label={label}\n className=\"text-muted-foreground hover:bg-muted/60 hover:text-foreground focus-visible:ring-ring inline-flex size-8 items-center justify-center rounded-md transition-colors focus-visible:ring-2 focus-visible:outline-none\"\n // Enter and Space open through MorphPopoverTrigger, which moves\n // focus to the first path itself. ArrowDown opens without a click.\n onKeyDown={(event) => {\n if (event.key === \"ArrowDown\") {\n event.preventDefault();\n focusOnOpen.current = true;\n setOpen(true);\n panel.current?.querySelector<HTMLElement>(\"a[href],button\")?.focus();\n }\n }}\n >\n <Ellipsis aria-hidden=\"true\" className=\"size-4\" />\n </button>\n </MorphPopoverTrigger>\n <MorphPopoverContent\n align={placement.align}\n side={placement.side}\n radius={10}\n sideOffset={6}\n className=\"p-1.5\"\n >\n <BreadcrumbOverflowPaths\n ref={panel}\n style={{ width: placement.width - 14 }}\n focusOnOpen={focusOnOpen}\n onPointerEnter={() => {\n cancelClose();\n setOpen(true);\n }}\n onPointerLeave={leave}\n onClick={(event) => {\n if ((event.target as Element).closest(\"a[href]\")) setOpen(false);\n }}\n >\n {children}\n </BreadcrumbOverflowPaths>\n </MorphPopoverContent>\n </span>\n </MorphPopover>\n );\n}\n\nfunction BreadcrumbOverflowPaths({\n focusOnOpen,\n ref,\n ...props\n}: ComponentPropsWithRef<\"ol\"> & { focusOnOpen: { current: boolean } }) {\n const localRef = useRef<HTMLOListElement>(null);\n useLayoutEffect(() => {\n if (!focusOnOpen.current) return;\n const focus = () => localRef.current?.querySelector<HTMLElement>(\"a[href],button\")?.focus();\n focus();\n // The portal becomes visible after its parent's layout measurement.\n const frame = requestAnimationFrame(() => {\n focus();\n focusOnOpen.current = false;\n });\n return () => cancelAnimationFrame(frame);\n }, [focusOnOpen]);\n return (\n <ol\n {...props}\n ref={(node) => {\n localRef.current = node;\n if (typeof ref === \"function\") return ref(node);\n if (ref) ref.current = node;\n }}\n className=\"flex max-h-64 flex-col gap-0.5 overflow-y-auto **:data-breadcrumb-separator:hidden [&_a]:w-full [&_a]:py-1 [&_a]:wrap-anywhere [&>li]:w-full\"\n />\n );\n}\n"],"mappings":";;;;;;;;;;;AAgCA,SAAgB,WAAW,EAAE,WAAW,UAAU,GAAG,SAA0B;CAC7E,MAAM,KAAK,MAAM;CACjB,OACE,oBAAC,OAAD;EAAK,cAAW;EAAa,GAAI;EAAO,WAAW,GAAG,WAAW,SAAS;EACxE,UAA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AyB,IAAI;CAC9C,sBAAsB;EACpB,IAAI,CAAC,YAAY,SAAS;EAC1B,MAAM,cAAc,SAAS,SAAS,cAA2B,gBAAgB,CAAC,EAAE,MAAM;EAC1F,MAAM;EAEN,MAAM,QAAQ,4BAA4B;GACxC,MAAM;GACN,YAAY,UAAU;EACxB,CAAC;EACD,aAAa,qBAAqB,KAAK;CACzC,GAAG,CAAC,WAAW,CAAC;CAChB,OACE,oBAAC,MAAD;EACE,GAAI;EACJ,MAAM,SAAS;GACb,SAAS,UAAU;GACnB,IAAI,OAAO,QAAQ,YAAY,OAAO,IAAI,IAAI;GAC9C,IAAI,KAAK,IAAI,UAAU;EACzB;EACA,WAAU;CACX,CAAA;AAEL"}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { Button } from "./base.js";
3
2
  import { Magnetic } from "../magnetic.js";
3
+ import { Button } from "./base.js";
4
4
  import { forwardRef } from "react";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  // src/components/motion/button/magnetic.tsx
@@ -0,0 +1,36 @@
1
+ import { ReactNode } from "react";
2
+ export type CardDealerZone = "deck" | "hand" | "pile";
3
+ export interface CardDealerCard {
4
+ id: string;
5
+ zone: CardDealerZone;
6
+ /** Accessible name for a card in the hand. */
7
+ label: string;
8
+ }
9
+ export interface CardDealerProps<T extends CardDealerCard> {
10
+ /** Every card on the table. Order within each zone is the stacking and fan order. */
11
+ cards: T[];
12
+ /** The card's face. */
13
+ renderFace: (card: T) => ReactNode;
14
+ /** The card's back, shown while it sits in the deck. */
15
+ renderBack?: (card: T) => ReactNode;
16
+ /** Makes hand cards buttons. Called with the card's id. */
17
+ onCardSelect?: (id: string) => void;
18
+ /** Card size in px. Default 84 by 120. */
19
+ cardWidth?: number;
20
+ cardHeight?: number;
21
+ /** Most horizontal space between neighbouring hand cards, in px. Default 46. */
22
+ spread?: number;
23
+ /** Rotation between neighbouring hand cards, in degrees. Default 5. */
24
+ angle?: number;
25
+ /** Accessible name for the table. Default "Card table". */
26
+ "aria-label"?: string;
27
+ className?: string;
28
+ }
29
+ /**
30
+ * A card table: a face-down deck, a fanned hand and a discard pile. Every card
31
+ * stays mounted and moving one between zones is just a change of `zone`, so it
32
+ * arcs across the table to its new place, flipping face up or down in flight.
33
+ * Reordering the hand makes cards hop over each other into their new slots.
34
+ */
35
+ export declare function CardDealer<T extends CardDealerCard>({ cards, renderFace, renderBack, onCardSelect, cardWidth, cardHeight, spread, angle, "aria-label": ariaLabel, className }: CardDealerProps<T>): import("react").JSX.Element;
36
+ //# sourceMappingURL=card-dealer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"card-dealer.d.ts","names":[],"sources":["../../../src/components/motion/card-dealer.tsx"],"mappings":";YAeY;iBAEK;EACf;EACA,MAAM;;EAEN;;iBAGe,gBAAgB,UAAU;;EAEzC,OAAO;;EAEP,aAAa,MAAM,MAAM;;EAEzB,cAAc,MAAM,MAAM;;EAE1B,gBAAgB;;EAEhB;EACA;;EAEA;;EAEA;;EAEA;EACA;;;;;;;;wBA0Cc,WAAW,UAAU,kBACnC,OACA,YACA,YACA,cACA,WACA,YACA,QACA,qBACc,WACd,aACC,gBAAgB,qBAAE,IAAA"}