@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 @@
1
+ {"version":3,"file":"plot.js","names":[],"sources":["../../../../src/components/charts/sankey-chart/plot.tsx"],"sourcesContent":["\"use client\";\n\n/* Links draw in from left to right once the plot scrolls into view, a column\n * at a time, then nodes fade up at their full size. When the data changes,\n * links and nodes spring to their new geometry; a resize re-lays them at\n * once. Hovering or focusing a node lights it, its flows and the nodes they\n * reach; hovering a flow lights that flow and its two ends; everything else\n * fades. Reduced motion: the chart appears in place and changes without\n * easing. */\n\nimport {\n type KeyboardEvent,\n type PointerEvent,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { motion, useInView } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_LAYOUT } from \"../../../lib/ease\";\nimport { emphasis, useSankeyChart } from \"./context\";\nimport type { PlacedNode } from \"./model\";\n\n// Link draw-in: each column starts this long after the one before it.\nconst COLUMN_DELAY = 0.12;\nconst DRAW_DURATION = 0.7;\n// Nodes shorter than this keep their name in the tooltip and table only.\nconst MIN_LABEL_HEIGHT = 12;\n// Gap between a node bar and its label, in px.\nconst LABEL_GAP = 8;\n// Average glyph width of the 12px label face, for fitting labels to a column.\nconst LABEL_CHAR_WIDTH = 6.6;\n// Pointer target around each node bar, and its smallest height (WCAG 2.5.8).\nconst HIT_SLOP = 4;\nconst MIN_HIT = 24;\n// Flows thinner than this still get this much hover target.\nconst MIN_LINK_HIT = 8;\n\nexport interface SankeyChartPlotProps {\n /** Sets the plot height; default 20rem. The layout follows its measured size. */\n className?: string;\n /** Show each node's value under its label when there is room. */\n showValues?: boolean;\n}\n\n/** Fits a label to `room` px, ending in an ellipsis; null when nothing fits. */\nfunction fit(label: string, room: number) {\n const chars = Math.floor(room / LABEL_CHAR_WIDTH);\n if (chars >= label.length) return label;\n if (chars < 4) return null;\n return `${label.slice(0, chars - 1).trimEnd()}…`;\n}\n\nexport function SankeyChartPlot({ className, showValues = true }: SankeyChartPlotProps) {\n const {\n nodes,\n links,\n columns,\n step,\n nodeWidth,\n size,\n setSize,\n resized,\n active,\n setActive,\n cursor,\n tooltipOpen,\n setTooltipOpen,\n tooltipId,\n gradientId,\n plotRef,\n buttons,\n registerButton,\n formatValue,\n label,\n empty,\n reduce,\n canHover,\n } = useSankeyChart();\n const inView = useInView(plotRef, { once: true, amount: 0.3 });\n const shown = reduce || inView;\n const [entered, setEntered] = useState(false);\n const focusedId = useRef<string | null>(null);\n // useId output can hold characters that break a url(#…) reference.\n const gradient = gradientId.replace(/[^\\w-]/g, \"\");\n\n useLayoutEffect(() => {\n const plot = plotRef.current;\n if (!plot) return;\n const measure = () => {\n const { width, height } = plot.getBoundingClientRect();\n if (width > 0 && height > 0)\n setSize((s) => (s.width === width && s.height === height ? s : { width, height }));\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(plot);\n return () => observer.disconnect();\n }, [plotRef, setSize]);\n\n // A focused node that leaves the data hands focus to the tab stop, so\n // keyboard users are not dropped to the top of the page.\n useLayoutEffect(() => {\n const id = focusedId.current;\n if (!id || nodes.some((node) => node.id === id)) return;\n focusedId.current = null;\n const lost = document.activeElement;\n if (lost === document.body || !plotRef.current?.contains(lost)) {\n const replacement = nodes[Math.max(cursor.activeIndex, 0)];\n if (replacement) buttons.current.get(replacement.id)?.focus();\n else plotRef.current?.focus();\n }\n }, [nodes, cursor.activeIndex, buttons, plotRef]);\n\n // A tap or click elsewhere dismisses what a tap opened; touch has no hover\n // to leave, so the tooltip would otherwise stay up.\n useEffect(() => {\n if (!tooltipOpen) return;\n const dismiss = (event: globalThis.PointerEvent) => {\n if (plotRef.current?.contains(event.target as Node)) return;\n setTooltipOpen(false);\n setActive(null);\n };\n document.addEventListener(\"pointerdown\", dismiss);\n return () => document.removeEventListener(\"pointerdown\", dismiss);\n }, [tooltipOpen, plotRef, setTooltipOpen, setActive]);\n\n // A node with any flow to or from the highlighted node lights up with it.\n const lit = emphasis(active);\n const neighbours = new Set<PlacedNode>();\n if (active?.type === \"node\") {\n for (const link of links) {\n if (link.source === active.node) neighbours.add(link.target);\n if (link.target === active.node) neighbours.add(link.source);\n }\n }\n const nodeLit = (node: PlacedNode) => lit.node(node) || neighbours.has(node);\n\n const tabStop = nodes[Math.max(cursor.activeIndex, 0)]?.id;\n const ref = useCallback(\n (id: string) => (element: HTMLButtonElement | null) => registerButton(id, element),\n [registerButton],\n );\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const target = event.target;\n if (!(target instanceof HTMLButtonElement)) return;\n const current = nodes.find((node) => node.id === target.dataset.sankeyNode);\n if (!current) return;\n if (event.key === \"Escape\") {\n if (!tooltipOpen) return;\n event.preventDefault();\n setTooltipOpen(false);\n return;\n }\n const center = (node: PlacedNode) => (node.y0 + node.y1) / 2;\n const column = (depth: number) => nodes.filter((node) => node.depth === depth);\n let next: PlacedNode | undefined;\n if (event.key === \"Home\") next = nodes[0];\n else if (event.key === \"End\") next = nodes[nodes.length - 1];\n else if (event.key === \"ArrowUp\" || event.key === \"ArrowDown\") {\n const same = column(current.depth);\n next = same[same.indexOf(current) + (event.key === \"ArrowUp\" ? -1 : 1)];\n } else if (event.key === \"ArrowLeft\" || event.key === \"ArrowRight\") {\n // Nearest node by height in the next populated column that way.\n const dir = event.key === \"ArrowLeft\" ? -1 : 1;\n for (let d = current.depth + dir; d >= 0 && d < columns && !next; d += dir) {\n next = column(d).reduce<PlacedNode | undefined>(\n (best, node) =>\n !best ||\n Math.abs(center(node) - center(current)) < Math.abs(center(best) - center(current))\n ? node\n : best,\n undefined,\n );\n }\n } else return;\n event.preventDefault();\n setTooltipOpen(true);\n if (next && next !== current) buttons.current.get(next.id)?.focus();\n else setActive(current.id);\n };\n\n // Enter alone can be skipped when the pointer jumps straight from one part\n // to another, so moves claim the highlight too; same-value updates bail out.\n // A touch only claims it while pressed, so a scroll does not leave it lit.\n const point = (event: PointerEvent<Element>, id: string) => {\n if (event.pointerType === \"touch\" ? event.buttons !== 1 : !canHover) return;\n setActive(id);\n setTooltipOpen(true);\n };\n const press = (id: string) => {\n setActive(id);\n setTooltipOpen(true);\n };\n\n const geometry = reduce || resized ? { duration: 0 } : SPRING_LAYOUT;\n const linkOpacity = (lightUp: boolean) => (active ? (lightUp ? 0.6 : 0.08) : 0.32);\n // Room for a label between its node and the next column's nodes.\n const labelRoom = columns > 1 ? step - nodeWidth - LABEL_GAP * 2 : size.width;\n // Thin flows' hit paths go on top, so a thick neighbour cannot bury them.\n const hitOrder = [...links].sort((a, b) => b.width - a.width);\n\n return (\n // Scrolls sideways under 32rem. The padding, cancelled by the margin,\n // holds the node hit areas and focus rings that reach past the plot, so\n // the scroller never clips them or scrolls vertically.\n <div className=\"-m-2 overflow-x-auto overflow-y-hidden p-2\">\n <div\n ref={plotRef}\n role=\"group\"\n aria-label={`${label} nodes`}\n tabIndex={-1}\n data-slot=\"sankey-chart-plot\"\n className={cn(\"relative h-80 w-full min-w-[32rem] outline-none\", className)}\n onKeyDown={onKeyDown}\n onFocus={(event) => {\n if (event.target instanceof HTMLButtonElement)\n focusedId.current = event.target.dataset.sankeyNode ?? null;\n }}\n onBlur={(event) => {\n if (event.currentTarget.contains(event.relatedTarget)) return;\n focusedId.current = null;\n setTooltipOpen(false);\n setActive(null);\n }}\n onPointerLeave={(event) => {\n // A lifted finger leaves too; touch dismisses by tapping elsewhere.\n if (event.pointerType === \"touch\") return;\n setTooltipOpen(false);\n setActive(null);\n }}\n >\n <svg\n width={size.width}\n height={size.height}\n viewBox={`0 0 ${size.width} ${size.height}`}\n aria-hidden=\"true\"\n className=\"absolute inset-0 overflow-visible\"\n >\n <defs>\n {links.map((link, i) => (\n <linearGradient\n key={link.id}\n id={`${gradient}-${i}`}\n gradientUnits=\"userSpaceOnUse\"\n x1={link.x0}\n x2={link.x1}\n >\n <stop offset=\"0%\" stopColor={link.source.color} />\n <stop offset=\"100%\" stopColor={link.target.color} />\n </linearGradient>\n ))}\n </defs>\n <g fill=\"none\" pointerEvents=\"none\">\n {links.map((link, i) => (\n <motion.path\n key={link.id}\n stroke={`url(#${gradient}-${i})`}\n strokeWidth={Math.max(1, link.width)}\n initial={reduce ? false : { d: link.path, pathLength: 0, opacity: 0.32 }}\n animate={\n shown\n ? { d: link.path, pathLength: 1, opacity: linkOpacity(lit.link(link)) }\n : undefined\n }\n transition={\n reduce\n ? { duration: 0 }\n : {\n d: geometry,\n pathLength: {\n duration: DRAW_DURATION,\n ease: EASE_OUT,\n delay: entered ? 0 : link.source.depth * COLUMN_DELAY,\n },\n opacity: { duration: 0.16, ease: EASE_OUT },\n }\n }\n onAnimationComplete={() => setEntered(true)}\n />\n ))}\n </g>\n {/* Static hit paths own hover: never animated, at least MIN_LINK_HIT\n wide, and on the final geometry so the target never drifts. */}\n <g fill=\"none\" stroke=\"transparent\">\n {hitOrder.map((link) => (\n <path\n key={link.id}\n d={link.path}\n strokeWidth={Math.max(MIN_LINK_HIT, link.width)}\n pointerEvents={shown ? \"stroke\" : \"none\"}\n className=\"cursor-pointer\"\n onPointerEnter={(event) => point(event, link.id)}\n onPointerMove={(event) => point(event, link.id)}\n onPointerDown={() => press(link.id)}\n />\n ))}\n </g>\n <g pointerEvents=\"none\">\n {nodes.map((node) => (\n <motion.rect\n key={node.id}\n x={node.x0}\n width={node.x1 - node.x0}\n rx={2}\n fill={node.color}\n initial={reduce ? false : { y: node.y0, height: node.y1 - node.y0, opacity: 0 }}\n animate={\n shown\n ? {\n y: node.y0,\n height: Math.max(1, node.y1 - node.y0),\n opacity: nodeLit(node) ? 1 : 0.3,\n }\n : undefined\n }\n transition={\n reduce\n ? { duration: 0 }\n : {\n y: geometry,\n height: geometry,\n opacity: {\n duration: entered ? 0.16 : 0.3,\n ease: EASE_OUT,\n delay: entered ? 0 : 0.1 + node.depth * COLUMN_DELAY,\n },\n }\n }\n />\n ))}\n </g>\n <g className=\"text-xs\" pointerEvents=\"none\">\n {nodes.map((node) => {\n const h = node.y1 - node.y0;\n if (h < MIN_LABEL_HEIGHT) return null;\n const text = fit(node.label, labelRoom);\n if (!text) return null;\n const last = columns > 1 && node.depth === columns - 1;\n const x = last ? node.x0 - LABEL_GAP : node.x1 + LABEL_GAP;\n const value = formatValue(node.value);\n const twoLines =\n showValues &&\n h >= MIN_LABEL_HEIGHT * 2.4 &&\n value.length * LABEL_CHAR_WIDTH <= labelRoom;\n return (\n <motion.text\n key={node.id}\n x={x}\n textAnchor={last ? \"end\" : \"start\"}\n dominantBaseline=\"middle\"\n // A halo in the page colour keeps labels readable over the bands.\n className=\"fill-foreground stroke-background [paint-order:stroke]\"\n strokeWidth={3}\n strokeLinejoin=\"round\"\n initial={reduce ? false : { y: (node.y0 + node.y1) / 2, opacity: 0 }}\n animate={\n shown\n ? { y: (node.y0 + node.y1) / 2, opacity: nodeLit(node) ? 1 : 0.35 }\n : undefined\n }\n transition={\n reduce\n ? { duration: 0 }\n : {\n y: geometry,\n opacity: {\n duration: 0.2,\n ease: EASE_OUT,\n delay: entered ? 0 : 0.2 + node.depth * COLUMN_DELAY,\n },\n }\n }\n >\n <tspan x={x} dy={twoLines ? \"-0.6em\" : 0} className=\"font-medium\">\n {text}\n </tspan>\n {twoLines ? (\n <tspan x={x} dy=\"1.2em\" className=\"fill-muted-foreground tabular-nums\">\n {value}\n </tspan>\n ) : null}\n </motion.text>\n );\n })}\n </g>\n </svg>\n {nodes.map((node) => {\n const selected = tooltipOpen && active?.type === \"node\" && active.node === node;\n const h = Math.max(1, node.y1 - node.y0);\n const hit = Math.max(MIN_HIT, h + HIT_SLOP * 2);\n return (\n <button\n key={node.id}\n ref={ref(node.id)}\n type=\"button\"\n data-sankey-node={node.id}\n tabIndex={node.id === tabStop ? 0 : -1}\n aria-label={[\n node.label,\n formatValue(node.value),\n node.inValue && node.outValue\n ? `in ${formatValue(node.inValue)}, out ${formatValue(node.outValue)}`\n : null,\n node.description,\n ]\n .filter(Boolean)\n .join(\". \")}\n aria-describedby={selected ? tooltipId : undefined}\n className=\"focus-visible:ring-ring focus-visible:ring-offset-background absolute rounded-sm outline-none focus-visible:ring-2 focus-visible:ring-offset-2\"\n style={{\n left: node.x0 - HIT_SLOP,\n // Centered on the bar, so a sliver of a node still gets a full target.\n top: node.y0 + h / 2 - hit / 2,\n width: node.x1 - node.x0 + HIT_SLOP * 2,\n height: hit,\n pointerEvents: shown ? \"auto\" : \"none\",\n }}\n onPointerEnter={(event) => point(event, node.id)}\n onPointerMove={(event) => point(event, node.id)}\n onPointerDown={() => press(node.id)}\n onFocus={() => {\n cursor.moveTo(node.id);\n setActive(node.id);\n setTooltipOpen(true);\n }}\n />\n );\n })}\n {empty ? (\n <p className=\"text-muted-foreground flex h-full items-center justify-center text-sm\">\n {empty}\n </p>\n ) : null}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AA2BA,MAAM,eAAe;AACrB,MAAM,gBAAgB;AAEtB,MAAM,mBAAmB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yActive } from "../../../context-tv-kneJV.js";
2
+ import { ReactNode } from "react";
3
+ export interface SankeyChartTooltipProps {
4
+ className?: string;
5
+ side?: "top" | "right" | "bottom" | "left";
6
+ /** Custom content for the highlighted node or flow. */
7
+ children?: ReactNode | ((active: SankeyActive) => ReactNode);
8
+ }
9
+ export declare function SankeyChartTooltip({ className, side, children }: SankeyChartTooltipProps): import("react").JSX.Element | null;
10
+ //# sourceMappingURL=tooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tooltip.d.ts","names":[],"sources":["../../../../src/components/charts/sankey-chart/tooltip.tsx"],"mappings":";;iBAaiB;EACf;EACA;;EAEA,WAAW,cAAc,QAAQ,iBAAiB;;wBAepC,qBAAqB,WAAW,MAAc,YAAY,0CAAuB,IAAA"}
@@ -0,0 +1,147 @@
1
+ "use client";
2
+ import { NumberTicker } from "../../motion/number-ticker.js";
3
+ import { t as Tooltip } from "../../../tooltip-CuHpilPN.js";
4
+ import { r as useSankeyChart } from "../../../context-CQbvWVnM.js";
5
+ import { cn } from "@kumix/utils";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { MotionConfig } from "motion/react";
8
+ // src/components/charts/sankey-chart/tooltip.tsx
9
+ const MAX_FLOWS = 4;
10
+ function Ticker({ value, format }) {
11
+ return /* @__PURE__ */ jsx(NumberTicker, {
12
+ value,
13
+ format: () => format(value),
14
+ startOnView: false,
15
+ duration: .2,
16
+ stagger: 0
17
+ });
18
+ }
19
+ function SankeyChartTooltip({ className, side = "top", children }) {
20
+ const { active, nodes, links, size, plotRef, tooltipId, tooltipOpen, setTooltipOpen, formatValue } = useSankeyChart();
21
+ if (!nodes.length) return null;
22
+ const point = active?.type === "node" ? {
23
+ x: (active.node.x0 + active.node.x1) / 2,
24
+ y: active.node.y0
25
+ } : active?.type === "link" ? {
26
+ x: (active.link.x0 + active.link.x1) / 2,
27
+ y: (active.link.y0 + active.link.y1) / 2
28
+ } : {
29
+ x: size.width / 2,
30
+ y: size.height / 2
31
+ };
32
+ const percent = (value) => `${(value * 100).toFixed(1)}%`;
33
+ return /* @__PURE__ */ jsx(Tooltip, {
34
+ id: tooltipId,
35
+ anchorRef: plotRef,
36
+ followCursor: true,
37
+ anchorPoint: {
38
+ x: point.x / size.width,
39
+ y: point.y / size.height
40
+ },
41
+ open: tooltipOpen && active !== null,
42
+ onOpenChange: setTooltipOpen,
43
+ side,
44
+ className: cn("max-w-64", className),
45
+ content: active ? typeof children === "function" ? children(active) : children ?? /* @__PURE__ */ jsx(MotionConfig, {
46
+ transition: { type: "tween" },
47
+ children: active.type === "node" ? /* @__PURE__ */ jsxs("span", {
48
+ className: "flex flex-col gap-1.5 text-xs",
49
+ children: [
50
+ /* @__PURE__ */ jsxs("span", {
51
+ className: "inline-flex items-center gap-2 font-medium",
52
+ children: [/* @__PURE__ */ jsx("span", {
53
+ "aria-hidden": "true",
54
+ className: "size-2 rounded-full",
55
+ style: { backgroundColor: active.node.color }
56
+ }), active.node.label]
57
+ }),
58
+ /* @__PURE__ */ jsx("span", {
59
+ className: "font-mono tabular-nums",
60
+ children: /* @__PURE__ */ jsx(Ticker, {
61
+ value: active.node.value,
62
+ format: formatValue
63
+ })
64
+ }),
65
+ active.node.inValue && active.node.outValue ? /* @__PURE__ */ jsxs("span", {
66
+ className: "text-muted-foreground font-mono tabular-nums",
67
+ children: [
68
+ "In ",
69
+ formatValue(active.node.inValue),
70
+ " · Out",
71
+ " ",
72
+ formatValue(active.node.outValue)
73
+ ]
74
+ }) : null,
75
+ ["in", "out"].map((direction) => {
76
+ const own = links.filter((l) => direction === "in" ? l.target === active.node : l.source === active.node).sort((a, b) => b.value - a.value);
77
+ if (!own.length) return null;
78
+ return /* @__PURE__ */ jsxs("span", {
79
+ className: "flex flex-col gap-0.5",
80
+ children: [
81
+ /* @__PURE__ */ jsx("span", {
82
+ className: "text-muted-foreground",
83
+ children: direction === "in" ? "From" : "To"
84
+ }),
85
+ own.slice(0, MAX_FLOWS).map((l) => /* @__PURE__ */ jsxs("span", {
86
+ className: "flex items-center justify-between gap-3",
87
+ children: [/* @__PURE__ */ jsx("span", {
88
+ className: "truncate",
89
+ children: direction === "in" ? l.source.label : l.target.label
90
+ }), /* @__PURE__ */ jsx("span", {
91
+ className: "text-muted-foreground shrink-0 font-mono tabular-nums",
92
+ children: formatValue(l.value)
93
+ })]
94
+ }, l.id)),
95
+ own.length > MAX_FLOWS ? /* @__PURE__ */ jsxs("span", {
96
+ className: "text-muted-foreground",
97
+ children: [own.length - MAX_FLOWS, " more"]
98
+ }) : null
99
+ ]
100
+ }, direction);
101
+ }),
102
+ active.node.description ? /* @__PURE__ */ jsx("span", {
103
+ className: "text-muted-foreground",
104
+ children: active.node.description
105
+ }) : null
106
+ ]
107
+ }) : /* @__PURE__ */ jsxs("span", {
108
+ className: "flex flex-col gap-1.5 text-xs",
109
+ children: [/* @__PURE__ */ jsxs("span", {
110
+ className: "font-medium",
111
+ children: [
112
+ active.link.source.label,
113
+ " → ",
114
+ active.link.target.label
115
+ ]
116
+ }), /* @__PURE__ */ jsxs("span", {
117
+ className: "inline-flex items-center gap-2 font-mono tabular-nums",
118
+ children: [
119
+ /* @__PURE__ */ jsx(Ticker, {
120
+ value: active.link.value,
121
+ format: formatValue
122
+ }),
123
+ /* @__PURE__ */ jsx("span", {
124
+ className: "text-muted-foreground",
125
+ children: "·"
126
+ }),
127
+ /* @__PURE__ */ jsxs("span", {
128
+ className: "text-muted-foreground",
129
+ children: [
130
+ /* @__PURE__ */ jsx(Ticker, {
131
+ value: active.link.share,
132
+ format: percent
133
+ }),
134
+ " of",
135
+ " ",
136
+ active.link.source.label
137
+ ]
138
+ })
139
+ ]
140
+ })]
141
+ })
142
+ }) : null
143
+ });
144
+ }
145
+ export { SankeyChartTooltip };
146
+
147
+ //# sourceMappingURL=tooltip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tooltip.js","names":[],"sources":["../../../../src/components/charts/sankey-chart/tooltip.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport { MotionConfig } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { NumberTicker } from \"../../motion/number-ticker\";\nimport { Tooltip } from \"../../motion/tooltip\";\nimport { type SankeyActive, useSankeyChart } from \"./context\";\n\n// Flows listed per direction in a node's tooltip.\nconst MAX_FLOWS = 4;\n\nexport interface SankeyChartTooltipProps {\n className?: string;\n side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n /** Custom content for the highlighted node or flow. */\n children?: ReactNode | ((active: SankeyActive) => ReactNode);\n}\n\nfunction Ticker({ value, format }: { value: number; format: (value: number) => string }) {\n return (\n <NumberTicker\n value={value}\n format={() => format(value)}\n startOnView={false}\n duration={0.2}\n stagger={0}\n />\n );\n}\n\nexport function SankeyChartTooltip({ className, side = \"top\", children }: SankeyChartTooltipProps) {\n const {\n active,\n nodes,\n links,\n size,\n plotRef,\n tooltipId,\n tooltipOpen,\n setTooltipOpen,\n formatValue,\n } = useSankeyChart();\n if (!nodes.length) return null;\n // Anchors keyboard focus to the top of the node, so the tooltip clears its\n // label, or to the flow's midpoint; the pointer takes over while it moves.\n const point =\n active?.type === \"node\"\n ? { x: (active.node.x0 + active.node.x1) / 2, y: active.node.y0 }\n : active?.type === \"link\"\n ? { x: (active.link.x0 + active.link.x1) / 2, y: (active.link.y0 + active.link.y1) / 2 }\n : { x: size.width / 2, y: size.height / 2 };\n const percent = (value: number) => `${(value * 100).toFixed(1)}%`;\n return (\n <Tooltip\n id={tooltipId}\n anchorRef={plotRef}\n followCursor\n anchorPoint={{ x: point.x / size.width, y: point.y / size.height }}\n open={tooltipOpen && active !== null}\n onOpenChange={setTooltipOpen}\n side={side}\n className={cn(\"max-w-64\", className)}\n content={\n active\n ? typeof children === \"function\"\n ? children(active)\n : (children ?? (\n <MotionConfig transition={{ type: \"tween\" }}>\n {active.type === \"node\" ? (\n <span className=\"flex flex-col gap-1.5 text-xs\">\n <span className=\"inline-flex items-center gap-2 font-medium\">\n <span\n aria-hidden=\"true\"\n className=\"size-2 rounded-full\"\n style={{ backgroundColor: active.node.color }}\n />\n {active.node.label}\n </span>\n <span className=\"font-mono tabular-nums\">\n <Ticker value={active.node.value} format={formatValue} />\n </span>\n {active.node.inValue && active.node.outValue ? (\n <span className=\"text-muted-foreground font-mono tabular-nums\">\n In {formatValue(active.node.inValue)} · Out{\" \"}\n {formatValue(active.node.outValue)}\n </span>\n ) : null}\n {([\"in\", \"out\"] as const).map((direction) => {\n // A node's largest flows that way; the table has the rest.\n const own = links\n .filter((l) =>\n direction === \"in\"\n ? l.target === active.node\n : l.source === active.node,\n )\n .sort((a, b) => b.value - a.value);\n if (!own.length) return null;\n return (\n <span key={direction} className=\"flex flex-col gap-0.5\">\n <span className=\"text-muted-foreground\">\n {direction === \"in\" ? \"From\" : \"To\"}\n </span>\n {own.slice(0, MAX_FLOWS).map((l) => (\n <span key={l.id} className=\"flex items-center justify-between gap-3\">\n <span className=\"truncate\">\n {direction === \"in\" ? l.source.label : l.target.label}\n </span>\n <span className=\"text-muted-foreground shrink-0 font-mono tabular-nums\">\n {formatValue(l.value)}\n </span>\n </span>\n ))}\n {own.length > MAX_FLOWS ? (\n <span className=\"text-muted-foreground\">\n {own.length - MAX_FLOWS} more\n </span>\n ) : null}\n </span>\n );\n })}\n {active.node.description ? (\n <span className=\"text-muted-foreground\">{active.node.description}</span>\n ) : null}\n </span>\n ) : (\n <span className=\"flex flex-col gap-1.5 text-xs\">\n <span className=\"font-medium\">\n {active.link.source.label} → {active.link.target.label}\n </span>\n <span className=\"inline-flex items-center gap-2 font-mono tabular-nums\">\n <Ticker value={active.link.value} format={formatValue} />\n <span className=\"text-muted-foreground\">·</span>\n <span className=\"text-muted-foreground\">\n <Ticker value={active.link.share} format={percent} /> of{\" \"}\n {active.link.source.label}\n </span>\n </span>\n </span>\n )}\n </MotionConfig>\n ))\n : null\n }\n />\n );\n}\n"],"mappings":";;;;;;;;AAWA,MAAM,YAAY;AASlB,SAAS,OAAO,EA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KAAM,WAAU;KAAhB,UAAA;MACG,OAAO,KAAK,OAAO;MAAM;MAAI,OAAO,KAAK,OAAO;KAC7C;IACN,CAAA,GAAA,qBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA;MACE,oBAAC,QAAD;OAAQ,OAAO,OAAO,KAAK;OAAO,QAAQ;MAAc,CAAA;MACxD,oBAAC,QAAD;OAAM,WAAU;OAAwB,UAAA;MAAO,CAAA;MAC/C,qBAAC,QAAD;OAAM,WAAU;OAAhB,UAAA;QACE,oBAAC,QAAD;SAAQ,OAAO,OAAO,KAAK;SAAO,QAAQ;QAAU,CAAA;QAAC;QAAI;QACxD,OAAO,KAAK,OAAO;OAChB;;KACF;IACF,CAAA,CAAA;;EAEI,CAAA,IAElB;CAEP,CAAA;AAEL"}
@@ -0,0 +1,17 @@
1
+ import { c as PlacedLink, d as SankeyNode, l as PlacedNode, n as SankeyChartProps, o as useSankeyChart, t as SankeyActive, u as SankeyLink } from "../../context-tv-kneJV.js";
2
+ import { SankeyChartPlot, SankeyChartPlotProps } from "./sankey-chart/plot.js";
3
+ import { SankeyChartTooltip, SankeyChartTooltipProps } from "./sankey-chart/tooltip.js";
4
+ /**
5
+ * Weighted flows between nodes, laid out in columns from sources to outcomes.
6
+ * Compose Plot and Tooltip, or omit children for the complete chart.
7
+ *
8
+ * ```tsx
9
+ * <SankeyChart nodes={nodes} links={links} formatValue={usd}>
10
+ * <SankeyChartPlot />
11
+ * <SankeyChartTooltip />
12
+ * </SankeyChart>
13
+ * ```
14
+ */
15
+ export declare function SankeyChart({ nodes, links, label, formatValue, colors, nodeWidth, nodePadding, activeId, defaultActiveId, onActiveChange, className, children, ...props }: SankeyChartProps): import("react").JSX.Element;
16
+ export { type SankeyActive, SankeyChartPlot, type SankeyChartPlotProps, type SankeyChartProps, SankeyChartTooltip, type SankeyChartTooltipProps, type SankeyLink, type SankeyNode, type PlacedLink as SankeyPlacedLink, type PlacedNode as SankeyPlacedNode, useSankeyChart };
17
+ //# sourceMappingURL=sankey-chart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sankey-chart.d.ts","names":[],"sources":["../../../src/components/charts/sankey-chart.tsx"],"mappings":";;;;;;;;;;;;;;wBAkBgB,cACd,OACA,OACA,OACA,aACA,QACA,WACA,aACA,UACA,iBACA,gBACA,WACA,aACG,SACF,mCAAgB,IAAA"}
@@ -0,0 +1,76 @@
1
+ "use client";
2
+ import { i as useSankeyModel, r as useSankeyChart, t as SankeyContext } from "../../context-CQbvWVnM.js";
3
+ import { SankeyChartPlot } from "./sankey-chart/plot.js";
4
+ import { SankeyChartTooltip } from "./sankey-chart/tooltip.js";
5
+ import { cn } from "@kumix/utils";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ // src/components/charts/sankey-chart.tsx
8
+ /**
9
+ * Weighted flows between nodes, laid out in columns from sources to outcomes.
10
+ * Compose Plot and Tooltip, or omit children for the complete chart.
11
+ *
12
+ * ```tsx
13
+ * <SankeyChart nodes={nodes} links={links} formatValue={usd}>
14
+ * <SankeyChartPlot />
15
+ * <SankeyChartTooltip />
16
+ * </SankeyChart>
17
+ * ```
18
+ */
19
+ function SankeyChart({ nodes, links, label, formatValue, colors, nodeWidth, nodePadding, activeId, defaultActiveId, onActiveChange, className, children, ...props }) {
20
+ const model = useSankeyModel({
21
+ nodes,
22
+ links,
23
+ label,
24
+ formatValue,
25
+ colors,
26
+ nodeWidth,
27
+ nodePadding,
28
+ activeId,
29
+ defaultActiveId,
30
+ onActiveChange
31
+ });
32
+ return /* @__PURE__ */ jsx(SankeyContext.Provider, {
33
+ value: model,
34
+ children: /* @__PURE__ */ jsxs("section", {
35
+ "aria-label": model.label,
36
+ ...props,
37
+ "data-slot": "sankey-chart",
38
+ className: cn("w-full min-w-0", className),
39
+ children: [children === void 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(SankeyChartPlot, {}), /* @__PURE__ */ jsx(SankeyChartTooltip, {})] }) : children, /* @__PURE__ */ jsx("div", {
40
+ className: "sr-only",
41
+ children: /* @__PURE__ */ jsxs("table", { children: [
42
+ /* @__PURE__ */ jsxs("caption", { children: [model.label, " data"] }),
43
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
44
+ /* @__PURE__ */ jsx("th", {
45
+ scope: "col",
46
+ children: "Flow"
47
+ }),
48
+ /* @__PURE__ */ jsx("th", {
49
+ scope: "col",
50
+ children: "Value"
51
+ }),
52
+ /* @__PURE__ */ jsx("th", {
53
+ scope: "col",
54
+ children: "Share of source"
55
+ })
56
+ ] }) }),
57
+ /* @__PURE__ */ jsx("tbody", { children: model.flows.map((flow) => /* @__PURE__ */ jsxs("tr", { children: [
58
+ /* @__PURE__ */ jsxs("th", {
59
+ scope: "row",
60
+ children: [
61
+ flow.source,
62
+ " to ",
63
+ flow.target
64
+ ]
65
+ }),
66
+ /* @__PURE__ */ jsx("td", { children: model.formatValue(flow.value) }),
67
+ /* @__PURE__ */ jsx("td", { children: flow.share ? `${(flow.share * 100).toFixed(1)}%` : "" })
68
+ ] }, flow.id)) })
69
+ ] })
70
+ })]
71
+ })
72
+ });
73
+ }
74
+ export { SankeyChart, SankeyChartPlot, SankeyChartTooltip, useSankeyChart };
75
+
76
+ //# sourceMappingURL=sankey-chart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sankey-chart.js","names":[],"sources":["../../../src/components/charts/sankey-chart.tsx"],"sourcesContent":["\"use client\";\n\nimport { cn } from \"@kumix/utils\";\nimport { type SankeyChartProps, SankeyContext, useSankeyModel } from \"./sankey-chart/context\";\nimport { SankeyChartPlot } from \"./sankey-chart/plot\";\nimport { SankeyChartTooltip } from \"./sankey-chart/tooltip\";\n\n/**\n * Weighted flows between nodes, laid out in columns from sources to outcomes.\n * Compose Plot and Tooltip, or omit children for the complete chart.\n *\n * ```tsx\n * <SankeyChart nodes={nodes} links={links} formatValue={usd}>\n * <SankeyChartPlot />\n * <SankeyChartTooltip />\n * </SankeyChart>\n * ```\n */\nexport function SankeyChart({\n nodes,\n links,\n label,\n formatValue,\n colors,\n nodeWidth,\n nodePadding,\n activeId,\n defaultActiveId,\n onActiveChange,\n className,\n children,\n ...props\n}: SankeyChartProps) {\n const model = useSankeyModel({\n nodes,\n links,\n label,\n formatValue,\n colors,\n nodeWidth,\n nodePadding,\n activeId,\n defaultActiveId,\n onActiveChange,\n });\n return (\n <SankeyContext.Provider value={model}>\n <section\n aria-label={model.label}\n {...props}\n data-slot=\"sankey-chart\"\n className={cn(\"w-full min-w-0\", className)}\n >\n {children === undefined ? (\n <>\n <SankeyChartPlot />\n <SankeyChartTooltip />\n </>\n ) : (\n children\n )}\n <div className=\"sr-only\">\n <table>\n <caption>{model.label} data</caption>\n <thead>\n <tr>\n <th scope=\"col\">Flow</th>\n <th scope=\"col\">Value</th>\n <th scope=\"col\">Share of source</th>\n </tr>\n </thead>\n <tbody>\n {model.flows.map((flow) => (\n <tr key={flow.id}>\n <th scope=\"row\">\n {flow.source} to {flow.target}\n </th>\n <td>{model.formatValue(flow.value)}</td>\n <td>{flow.share ? `${(flow.share * 100).toFixed(1)}%` : \"\"}</td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n </section>\n </SankeyContext.Provider>\n );\n}\n\nexport {\n type SankeyActive,\n type SankeyChartProps,\n useSankeyChart,\n} from \"./sankey-chart/context\";\nexport type {\n PlacedLink as SankeyPlacedLink,\n PlacedNode as SankeyPlacedNode,\n SankeyLink,\n SankeyNode,\n} from \"./sankey-chart/model\";\nexport { SankeyChartPlot, type SankeyChartPlotProps } from \"./sankey-chart/plot\";\nexport { SankeyChartTooltip, type SankeyChartTooltipProps } from \"./sankey-chart/tooltip\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,SAAgB,YAAY,EAC1B,OACA,OACA,OACA,aACA,QACA,WACA,aACA,UACA,iBACA,gBACA,WACA,UACA,GAAG,SACgB;CACnB,MAAM,QAAQ,eAAe;EAC3B;EACA;EACA;EACA;EACA;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
+ export interface SparklineProps extends Omit<ComponentProps<"div">, "children"> {
4
+ /** Samples in display order. Missing or non-finite values leave a gap. */
5
+ data: readonly (number | null)[];
6
+ /** Optional sample labels, such as dates, used by the interactive readout. */
7
+ labels?: readonly string[];
8
+ /** Accessible name, such as "Revenue, last 30 days". */
9
+ label: string;
10
+ variant?: "line" | "area";
11
+ curve?: XYCurve;
12
+ /** Any CSS color. Defaults to the current text color. */
13
+ color?: string;
14
+ /** Height in px. Width follows the container. */
15
+ height?: number;
16
+ strokeWidth?: number;
17
+ /** Show the change from the first to the last sample as a badge. */
18
+ showDelta?: boolean;
19
+ /** Color a fall green and a rise red, for metrics where lower is better, such as error rate. */
20
+ invertDelta?: boolean;
21
+ /** Hover, drag or arrow keys to read individual samples. Adds one tab stop. */
22
+ interactive?: boolean;
23
+ formatValue?: (value: number) => string;
24
+ }
25
+ export declare function Sparkline({ data, labels, label, variant, curve, color, height, strokeWidth, showDelta, invertDelta, interactive, formatValue, className, ...props }: SparklineProps): import("react").JSX.Element;
26
+ //# sourceMappingURL=sparkline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sparkline.d.ts","names":[],"sources":["../../../src/components/charts/sparkline.tsx"],"mappings":";;iBAmBiB,uBAAuB,KAAK;;EAE3C;;EAEA;;EAEA;EACA;EACA,QAAQ;;EAER;;EAEA;EACA;;EAEA;;EAEA;;EAEA;EACA,eAAe;;wBAMD,YACd,MACA,QACA,OACA,SACA,OACA,OACA,QACA,aACA,WACA,aACA,aACA,aACA,cACG,SACF,iCAAc,IAAA"}
@@ -0,0 +1,197 @@
1
+ "use client";
2
+ import { useHoverCapable } from "../../hooks/use-hover-capable.js";
3
+ import { EASE_OUT, SPRING_LAYOUT } from "../../lib/ease.js";
4
+ import { NumberTicker } from "../motion/number-ticker.js";
5
+ import { XYInspector } from "./xy/inspector.js";
6
+ import { n as areaPath, r as linePath, t as useAnimatedPoints } from "../../use-points-C2jpElHh.js";
7
+ import { t as useElementWidth } from "../../use-width-CkKCh1b3.js";
8
+ import { useId, useState } from "react";
9
+ import { cn } from "@kumix/utils";
10
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
11
+ import { motion, useReducedMotion, useTransform } from "motion/react";
12
+ // src/components/charts/sparkline.tsx
13
+ const number = new Intl.NumberFormat("en", { maximumFractionDigits: 2 });
14
+ const PAD = 3;
15
+ function Sparkline({ data, labels, label, variant = "line", curve = "monotone", color = "currentColor", height = 32, strokeWidth = 1.5, showDelta = false, invertDelta = false, interactive = false, formatValue = (value) => number.format(value), className, ...props }) {
16
+ const reduce = useReducedMotion() ?? false;
17
+ const canHover = useHoverCapable();
18
+ const gradientId = useId();
19
+ const tooltipId = useId();
20
+ const { ref, width } = useElementWidth();
21
+ const [active, setActive] = useState(null);
22
+ const [open, setOpen] = useState(false);
23
+ const [touching, setTouching] = useState(false);
24
+ const values = data.map((value) => typeof value === "number" && Number.isFinite(value) ? value : null);
25
+ const present = values.filter((value) => value !== null);
26
+ const lo = present.length ? Math.min(...present) : 0;
27
+ const hi = present.length ? Math.max(...present) : 1;
28
+ const range = hi - lo || 1;
29
+ const n = values.length;
30
+ const x = (i) => PAD + (n === 1 ? (width - 6) / 2 : i / (n - 1) * (width - 6));
31
+ const y = (value) => hi === lo ? height / 2 : PAD + (hi - value) / range * (height - 6);
32
+ const targets = [];
33
+ if (width > 0) {
34
+ targets.push({
35
+ key: "baseline",
36
+ x: 0,
37
+ y: height
38
+ });
39
+ values.forEach((value, i) => {
40
+ if (value !== null) targets.push({
41
+ key: String(i),
42
+ x: x(i),
43
+ y: y(value)
44
+ });
45
+ });
46
+ }
47
+ const points = useAnimatedPoints(targets, reduce, width);
48
+ const ordered = values.map((value, i) => value === null ? null : points.get(String(i)) ?? null);
49
+ const baseline = points.get("baseline");
50
+ const motionValues = [...baseline ? [baseline.y] : [], ...ordered.flatMap((point) => point ? [point.x, point.y] : [])];
51
+ const read = (coordinates) => {
52
+ let cursor = 1;
53
+ return ordered.map((point) => point ? {
54
+ x: coordinates[cursor++],
55
+ y: coordinates[cursor++]
56
+ } : null);
57
+ };
58
+ const line = useTransform(motionValues, (c) => baseline ? linePath(read(c), curve) : "");
59
+ const fill = useTransform(motionValues, (c) => baseline ? areaPath(read(c), c[0], curve) : "");
60
+ const lastIndex = values.findLastIndex((value) => value !== null);
61
+ const firstIndex = values.findIndex((value) => value !== null);
62
+ const last = lastIndex >= 0 ? values[lastIndex] : null;
63
+ const first = firstIndex >= 0 ? values[firstIndex] : null;
64
+ const delta = first !== null && last !== null && first !== 0 ? (last - first) / Math.abs(first) * 100 : null;
65
+ const trend = delta === null || Math.abs(delta) < .05 ? "flat" : delta > 0 ? "up" : "down";
66
+ const tone = trend === "flat" ? "flat" : trend === "up" !== invertDelta ? "good" : "bad";
67
+ const inspecting = interactive && open && active !== null && values[active] !== null;
68
+ const dotIndex = inspecting ? active : lastIndex;
69
+ const dotValue = dotIndex >= 0 ? values[dotIndex] : null;
70
+ const name = (i) => labels?.[i] ?? `Sample ${i + 1}`;
71
+ const summary = [
72
+ label,
73
+ first !== null && last !== null ? `from ${formatValue(first)} to ${formatValue(last)}` : "no data",
74
+ delta !== null && trend !== "flat" ? `${trend} ${Math.abs(delta).toFixed(1)}%` : null
75
+ ].filter(Boolean).join(", ");
76
+ return /* @__PURE__ */ jsxs("div", {
77
+ ...props,
78
+ "data-slot": "sparkline",
79
+ className: cn("inline-flex w-full min-w-0 items-center gap-2", className),
80
+ children: [
81
+ /* @__PURE__ */ jsxs("div", {
82
+ ref,
83
+ className: "relative min-w-0 flex-1",
84
+ style: {
85
+ height,
86
+ color
87
+ },
88
+ children: [/* @__PURE__ */ jsxs("svg", {
89
+ role: "img",
90
+ "aria-label": summary,
91
+ width: width || void 0,
92
+ height,
93
+ className: "absolute inset-0 overflow-visible",
94
+ children: [
95
+ variant === "area" ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", {
96
+ id: gradientId,
97
+ x1: "0",
98
+ x2: "0",
99
+ y1: "0",
100
+ y2: "1",
101
+ children: [/* @__PURE__ */ jsx("stop", {
102
+ offset: "0%",
103
+ stopColor: "currentColor",
104
+ stopOpacity: .3
105
+ }), /* @__PURE__ */ jsx("stop", {
106
+ offset: "100%",
107
+ stopColor: "currentColor",
108
+ stopOpacity: 0
109
+ })]
110
+ }) }), /* @__PURE__ */ jsx(motion.path, {
111
+ d: fill,
112
+ fill: `url(#${gradientId})`
113
+ })] }) : null,
114
+ /* @__PURE__ */ jsx(motion.path, {
115
+ d: line,
116
+ fill: "none",
117
+ stroke: "currentColor",
118
+ strokeWidth,
119
+ strokeLinecap: "round",
120
+ strokeLinejoin: "round"
121
+ }),
122
+ width > 0 && dotValue !== null && dotValue !== void 0 ? /* @__PURE__ */ jsx(motion.circle, {
123
+ r: inspecting ? 3.5 : 2.5,
124
+ cx: 0,
125
+ cy: 0,
126
+ fill: "currentColor",
127
+ stroke: "var(--background)",
128
+ strokeWidth: inspecting ? 2 : 0,
129
+ initial: false,
130
+ animate: {
131
+ x: x(dotIndex),
132
+ y: y(dotValue)
133
+ },
134
+ transition: reduce || touching ? { duration: 0 } : SPRING_LAYOUT
135
+ }) : null
136
+ ]
137
+ }), interactive && present.length ? /* @__PURE__ */ jsx("div", {
138
+ className: "has-focus-visible:outline-ring absolute inset-0 rounded-sm has-focus-visible:outline-2 has-focus-visible:outline-offset-2",
139
+ children: /* @__PURE__ */ jsx(XYInspector, {
140
+ count: n,
141
+ activeIndex: active ?? -1,
142
+ onActive: setActive,
143
+ label: `${label}: inspect samples`,
144
+ valueText: (i) => {
145
+ const value = values[i];
146
+ return `${name(i)}: ${value === null ? "no data" : formatValue(value)}`;
147
+ },
148
+ mode: "point",
149
+ open,
150
+ setOpen,
151
+ onTouchChange: setTouching,
152
+ tooltipId,
153
+ canHover,
154
+ className: "inset-0 size-full"
155
+ })
156
+ }) : null]
157
+ }),
158
+ interactive && present.length ? /* @__PURE__ */ jsxs("span", {
159
+ id: tooltipId,
160
+ "aria-hidden": !inspecting,
161
+ className: "shrink-0 text-right text-xs leading-tight tabular-nums",
162
+ children: [/* @__PURE__ */ jsx("span", {
163
+ className: "block font-mono",
164
+ children: dotValue !== null && dotValue !== void 0 ? /* @__PURE__ */ jsx(NumberTicker, {
165
+ value: dotValue,
166
+ format: () => formatValue(dotValue),
167
+ startOnView: false,
168
+ duration: .2,
169
+ stagger: 0,
170
+ className: "whitespace-pre"
171
+ }) : "No data"
172
+ }), /* @__PURE__ */ jsx(motion.span, {
173
+ className: "text-muted-foreground block text-[10px]",
174
+ initial: false,
175
+ animate: { opacity: inspecting ? 1 : 0 },
176
+ transition: {
177
+ duration: .12,
178
+ ease: EASE_OUT
179
+ },
180
+ children: inspecting ? name(active) : "\xA0"
181
+ })]
182
+ }) : null,
183
+ showDelta && delta !== null ? /* @__PURE__ */ jsxs("span", {
184
+ "aria-hidden": "true",
185
+ className: cn("shrink-0 rounded-md px-1.5 py-0.5 font-mono text-[11px] tabular-nums", tone === "good" && "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400", tone === "bad" && "bg-rose-500/10 text-rose-600 dark:text-rose-400", tone === "flat" && "bg-muted text-muted-foreground"),
186
+ children: [
187
+ trend === "up" ? "+" : trend === "down" ? "−" : "",
188
+ Math.abs(delta).toFixed(1),
189
+ "%"
190
+ ]
191
+ }) : null
192
+ ]
193
+ });
194
+ }
195
+ export { Sparkline };
196
+
197
+ //# sourceMappingURL=sparkline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sparkline.js","names":[],"sources":["../../../src/components/charts/sparkline.tsx"],"sourcesContent":["\"use client\";\n\n/* A compact trend for tables, stat cards and inline text. New values morph the\n * line on the same springs as LineChart, and the end dot follows. With\n * `interactive`, hovering, dragging or arrow keys move a dot along the line and\n * the readout shows that sample. Reduced motion: values update in place. */\n\nimport { type ComponentProps, useId, useState } from \"react\";\nimport { motion, useReducedMotion, useTransform } 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 { NumberTicker } from \"../motion/number-ticker\";\nimport { XYInspector } from \"./xy/inspector\";\nimport { areaPath, linePath, type XYCurve } from \"./xy/path\";\nimport { useAnimatedPoints, type XYPointTarget } from \"./xy/use-points\";\nimport { useElementWidth } from \"./xy/use-width\";\n\nexport interface SparklineProps extends Omit<ComponentProps<\"div\">, \"children\"> {\n /** Samples in display order. Missing or non-finite values leave a gap. */\n data: readonly (number | null)[];\n /** Optional sample labels, such as dates, used by the interactive readout. */\n labels?: readonly string[];\n /** Accessible name, such as \"Revenue, last 30 days\". */\n label: string;\n variant?: \"line\" | \"area\";\n curve?: XYCurve;\n /** Any CSS color. Defaults to the current text color. */\n color?: string;\n /** Height in px. Width follows the container. */\n height?: number;\n strokeWidth?: number;\n /** Show the change from the first to the last sample as a badge. */\n showDelta?: boolean;\n /** Color a fall green and a rise red, for metrics where lower is better, such as error rate. */\n invertDelta?: boolean;\n /** Hover, drag or arrow keys to read individual samples. Adds one tab stop. */\n interactive?: boolean;\n formatValue?: (value: number) => string;\n}\n\nconst number = new Intl.NumberFormat(\"en\", { maximumFractionDigits: 2 });\nconst PAD = 3;\n\nexport function Sparkline({\n data,\n labels,\n label,\n variant = \"line\",\n curve = \"monotone\",\n color = \"currentColor\",\n height = 32,\n strokeWidth = 1.5,\n showDelta = false,\n invertDelta = false,\n interactive = false,\n formatValue = (value) => number.format(value),\n className,\n ...props\n}: SparklineProps) {\n const reduce = useReducedMotion() ?? false;\n const canHover = useHoverCapable();\n const gradientId = useId();\n const tooltipId = useId();\n const { ref, width } = useElementWidth<HTMLDivElement>();\n const [active, setActive] = useState<number | null>(null);\n const [open, setOpen] = useState(false);\n // Under a finger the readout dot tracks the touch directly instead of gliding.\n const [touching, setTouching] = useState(false);\n const values = data.map((value) =>\n typeof value === \"number\" && Number.isFinite(value) ? value : null,\n );\n const present = values.filter((value): value is number => value !== null);\n // Fit the data tightly: at this size a zero baseline or rounded bounds would\n // flatten a metric that sits far from zero. The area fills to the bottom edge.\n const lo = present.length ? Math.min(...present) : 0;\n const hi = present.length ? Math.max(...present) : 1;\n const range = hi - lo || 1;\n const n = values.length;\n const x = (i: number) =>\n PAD + (n === 1 ? (width - PAD * 2) / 2 : (i / (n - 1)) * (width - PAD * 2));\n const y = (value: number) =>\n hi === lo ? height / 2 : PAD + ((hi - value) / range) * (height - PAD * 2);\n\n const targets: XYPointTarget[] = [];\n if (width > 0) {\n targets.push({ key: \"baseline\", x: 0, y: height });\n values.forEach((value, i) => {\n if (value !== null) targets.push({ key: String(i), x: x(i), y: y(value) });\n });\n }\n const points = useAnimatedPoints(targets, reduce, width);\n // Indexed by position: a live sparkline shifts every sample left as it ticks.\n const ordered = values.map((value, i) =>\n value === null ? null : (points.get(String(i)) ?? null),\n );\n const baseline = points.get(\"baseline\");\n const motionValues = [\n ...(baseline ? [baseline.y] : []),\n ...ordered.flatMap((point) => (point ? [point.x, point.y] : [])),\n ];\n const read = (coordinates: number[]) => {\n let cursor = 1;\n return ordered.map((point) =>\n point ? { x: coordinates[cursor++], y: coordinates[cursor++] } : null,\n );\n };\n const line = useTransform(motionValues, (c: number[]) =>\n baseline ? linePath(read(c), curve) : \"\",\n );\n const fill = useTransform(motionValues, (c: number[]) =>\n baseline ? areaPath(read(c), c[0], curve) : \"\",\n );\n\n const lastIndex = values.findLastIndex((value) => value !== null);\n const firstIndex = values.findIndex((value) => value !== null);\n const last = lastIndex >= 0 ? (values[lastIndex] as number) : null;\n const first = firstIndex >= 0 ? (values[firstIndex] as number) : null;\n const delta =\n first !== null && last !== null && first !== 0\n ? ((last - first) / Math.abs(first)) * 100\n : null;\n const trend = delta === null || Math.abs(delta) < 0.05 ? \"flat\" : delta > 0 ? \"up\" : \"down\";\n const tone = trend === \"flat\" ? \"flat\" : (trend === \"up\") !== invertDelta ? \"good\" : \"bad\";\n const inspecting = interactive && open && active !== null && values[active] !== null;\n const dotIndex = inspecting ? (active as number) : lastIndex;\n const dotValue = dotIndex >= 0 ? values[dotIndex] : null;\n const name = (i: number) => labels?.[i] ?? `Sample ${i + 1}`;\n const summary = [\n label,\n first !== null && last !== null\n ? `from ${formatValue(first)} to ${formatValue(last)}`\n : \"no data\",\n delta !== null && trend !== \"flat\" ? `${trend} ${Math.abs(delta).toFixed(1)}%` : null,\n ]\n .filter(Boolean)\n .join(\", \");\n\n return (\n <div\n {...props}\n data-slot=\"sparkline\"\n className={cn(\"inline-flex w-full min-w-0 items-center gap-2\", className)}\n >\n <div ref={ref} className=\"relative min-w-0 flex-1\" style={{ height, color }}>\n <svg\n role=\"img\"\n aria-label={summary}\n width={width || undefined}\n height={height}\n className=\"absolute inset-0 overflow-visible\"\n >\n {variant === \"area\" ? (\n <>\n <defs>\n <linearGradient id={gradientId} x1=\"0\" x2=\"0\" y1=\"0\" y2=\"1\">\n <stop offset=\"0%\" stopColor=\"currentColor\" stopOpacity={0.3} />\n <stop offset=\"100%\" stopColor=\"currentColor\" stopOpacity={0} />\n </linearGradient>\n </defs>\n <motion.path d={fill} fill={`url(#${gradientId})`} />\n </>\n ) : null}\n <motion.path\n d={line}\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n {width > 0 && dotValue !== null && dotValue !== undefined ? (\n <motion.circle\n r={inspecting ? 3.5 : 2.5}\n cx={0}\n cy={0}\n fill=\"currentColor\"\n stroke=\"var(--background)\"\n strokeWidth={inspecting ? 2 : 0}\n initial={false}\n animate={{ x: x(dotIndex), y: y(dotValue) }}\n transition={reduce || touching ? { duration: 0 } : SPRING_LAYOUT}\n />\n ) : null}\n </svg>\n {interactive && present.length ? (\n <div className=\"has-focus-visible:outline-ring absolute inset-0 rounded-sm has-focus-visible:outline-2 has-focus-visible:outline-offset-2\">\n <XYInspector\n count={n}\n activeIndex={active ?? -1}\n onActive={setActive}\n label={`${label}: inspect samples`}\n valueText={(i) => {\n const value = values[i];\n return `${name(i)}: ${value === null ? \"no data\" : formatValue(value)}`;\n }}\n mode=\"point\"\n open={open}\n setOpen={setOpen}\n onTouchChange={setTouching}\n tooltipId={tooltipId}\n canHover={canHover}\n className=\"inset-0 size-full\"\n />\n </div>\n ) : null}\n </div>\n {interactive && present.length ? (\n <span\n id={tooltipId}\n aria-hidden={!inspecting}\n className=\"shrink-0 text-right text-xs leading-tight tabular-nums\"\n >\n <span className=\"block font-mono\">\n {dotValue !== null && dotValue !== undefined ? (\n <NumberTicker\n value={dotValue}\n format={() => formatValue(dotValue)}\n startOnView={false}\n duration={0.2}\n stagger={0}\n className=\"whitespace-pre\"\n />\n ) : (\n \"No data\"\n )}\n </span>\n <motion.span\n className=\"text-muted-foreground block text-[10px]\"\n initial={false}\n animate={{ opacity: inspecting ? 1 : 0 }}\n transition={{ duration: 0.12, ease: EASE_OUT }}\n >\n {inspecting ? name(active as number) : \" \"}\n </motion.span>\n </span>\n ) : null}\n {showDelta && delta !== null ? (\n <span\n aria-hidden=\"true\"\n className={cn(\n \"shrink-0 rounded-md px-1.5 py-0.5 font-mono text-[11px] tabular-nums\",\n tone === \"good\" && \"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400\",\n tone === \"bad\" && \"bg-rose-500/10 text-rose-600 dark:text-rose-400\",\n tone === \"flat\" && \"bg-muted text-muted-foreground\",\n )}\n >\n {trend === \"up\" ? \"+\" : trend === \"down\" ? \"−\" : \"\"}\n {Math.abs(delta).toFixed(1)}%\n </span>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA0CA,MAAM,SAAS,IAAI,KAAK,aAAa,MAAM,EAAE,uBAAuB,EAAE,CAAC;AACvE,MAAM,MAAM;AAEZ,SAAgB,UAAU,EACxB,MACA,QACA,OACA,UAAU,QACV,QAAQ,YACR,QAAQ,gBACR,SAAS,IACT,cAAc,KACd,YAAY,OACZ,cAAc,OACd,cAAc,OACd,eAA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import { NumberTicker } from "../../motion/number-ticker.js";
3
+ import { t as Tooltip } from "../../../tooltip-CuHpilPN.js";
4
4
  import { n as useTreemap } from "../../../context-DWXNECDe.js";
5
5
  import { cn } from "@kumix/utils";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -1 +1 @@
1
- {"version":3,"file":"treemap.d.ts","names":["_$__model0.TreemapTile","_$__model0.ResolvedNode","_$__model0.TreemapItem"],"sources":["../../../src/components/charts/treemap/context.ts","../../../src/components/charts/treemap.tsx"],"mappings":";;;;;UAsBiB,qBAAqB;;EAEpC,eAAe;EACf;EACA,eAAe;;EAEf;EACA;EACA;EACA;EACA,kBAAkB;;wBAgEJ;E,OAAAA;;;;;;;;;;EAtEQ,cAAA;;EAsCa,YAAA;;;;;;;;;;EAKK,iBAAA,YAAM,MAAQ;;;;E,OAAAC;;;;;wBC5DxC,UACd,MACA,OACA,aACA,QACA,WACA,UACA,iBACA,gBACA,WACA,aACG,SACF,+BAAY,IAAA"}
1
+ {"version":3,"file":"treemap.d.ts","names":["_$__model0.TreemapTile","_$__model0.ResolvedNode"],"sources":["../../../src/components/charts/treemap/context.ts","../../../src/components/charts/treemap.tsx"],"mappings":";;;;;UAsBiB,qBAAqB;;EAEpC,eAAe;EACf;EACA,eAAe;;EAEf;EACA;EACA;EACA;EACA,kBAAkB;;wBAgEJ;E,OAAAA;;;;;;;;;;EAtEQ,cAAA;;EAsCa,YAAA;;;;;;;;;;EAKK,iBAAA,YAAM,MAAQ;;;;E,OAAAC;;;;;wBC5DxC,UACd,MACA,OACA,aACA,QACA,WACA,UACA,iBACA,gBACA,WACA,aACG,SACF,+BAAY,IAAA"}