@epilot/spark-ui 0.20.0 → 0.21.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 (258) hide show
  1. package/dist/components/accordion.cjs +7 -7
  2. package/dist/components/accordion.cjs.map +1 -1
  3. package/dist/components/accordion.d.ts +1 -1
  4. package/dist/components/accordion.js +1 -1
  5. package/dist/components/alert-dialog.cjs +10 -10
  6. package/dist/components/alert-dialog.cjs.map +1 -1
  7. package/dist/components/alert-dialog.js +1 -1
  8. package/dist/components/attachment.cjs +10 -10
  9. package/dist/components/attachment.cjs.map +1 -1
  10. package/dist/components/attachment.d.cts +2 -2
  11. package/dist/components/attachment.d.ts +2 -2
  12. package/dist/components/autocomplete.cjs +13 -13
  13. package/dist/components/autocomplete.cjs.map +1 -1
  14. package/dist/components/autocomplete.js +1 -1
  15. package/dist/components/avatar.cjs +2 -2
  16. package/dist/components/avatar.cjs.map +1 -1
  17. package/dist/components/avatar.js +1 -1
  18. package/dist/components/badge.cjs +2 -2
  19. package/dist/components/badge.cjs.map +1 -1
  20. package/dist/components/badge.js +1 -1
  21. package/dist/components/bar-chart-with-total.d.cts +1 -1
  22. package/dist/components/bar-chart-with-total.d.ts +1 -1
  23. package/dist/components/bar-chart.cjs +4 -4
  24. package/dist/components/bar-chart.cjs.map +1 -1
  25. package/dist/components/bar-chart.js +2 -2
  26. package/dist/components/box.cjs +2 -2
  27. package/dist/components/box.cjs.map +1 -1
  28. package/dist/components/box.js +1 -1
  29. package/dist/components/breadcrumbs.cjs +7 -7
  30. package/dist/components/breadcrumbs.cjs.map +1 -1
  31. package/dist/components/bubble.cjs +5 -5
  32. package/dist/components/bubble.cjs.map +1 -1
  33. package/dist/components/bubble.d.cts +1 -1
  34. package/dist/components/bubble.d.ts +1 -1
  35. package/dist/components/button-group.cjs +5 -5
  36. package/dist/components/button-group.cjs.map +1 -1
  37. package/dist/components/button-group.js +1 -1
  38. package/dist/components/button.cjs +2 -2
  39. package/dist/components/button.cjs.map +1 -1
  40. package/dist/components/button.d.cts +2 -2
  41. package/dist/components/button.d.ts +2 -2
  42. package/dist/components/button.js +1 -1
  43. package/dist/components/calendar.cjs +9 -9
  44. package/dist/components/calendar.cjs.map +1 -1
  45. package/dist/components/calendar.js +1 -1
  46. package/dist/components/callout.cjs +8 -8
  47. package/dist/components/callout.cjs.map +1 -1
  48. package/dist/components/callout.d.cts +1 -1
  49. package/dist/components/callout.d.ts +2 -2
  50. package/dist/components/callout.js +1 -1
  51. package/dist/components/card.cjs +16 -16
  52. package/dist/components/card.cjs.map +1 -1
  53. package/dist/components/card.js +2 -2
  54. package/dist/components/card.js.map +1 -1
  55. package/dist/components/chart.cjs +2 -2
  56. package/dist/components/chart.cjs.map +1 -1
  57. package/dist/components/checkbox.cjs +2 -2
  58. package/dist/components/checkbox.cjs.map +1 -1
  59. package/dist/components/checkbox.js +1 -1
  60. package/dist/components/circular-gauge.cjs +3 -3
  61. package/dist/components/circular-gauge.cjs.map +1 -1
  62. package/dist/components/day-of-week-picker.cjs +4 -4
  63. package/dist/components/day-of-week-picker.cjs.map +1 -1
  64. package/dist/components/dialog.cjs +9 -9
  65. package/dist/components/dialog.cjs.map +1 -1
  66. package/dist/components/dialog.js +1 -1
  67. package/dist/components/drawer.cjs +8 -8
  68. package/dist/components/drawer.cjs.map +1 -1
  69. package/dist/components/dropdown-menu.cjs +11 -11
  70. package/dist/components/dropdown-menu.cjs.map +1 -1
  71. package/dist/components/dropdown-menu.js +1 -1
  72. package/dist/components/empty-state.d.ts +1 -1
  73. package/dist/components/energy-breakdown.cjs +80 -0
  74. package/dist/components/energy-breakdown.cjs.map +1 -0
  75. package/dist/components/energy-breakdown.d.cts +24 -0
  76. package/dist/components/energy-breakdown.d.ts +24 -0
  77. package/dist/components/energy-breakdown.js +79 -0
  78. package/dist/components/energy-breakdown.js.map +1 -0
  79. package/dist/components/energy-history-chart.cjs +63 -0
  80. package/dist/components/energy-history-chart.cjs.map +1 -0
  81. package/dist/components/energy-history-chart.d.cts +64 -0
  82. package/dist/components/energy-history-chart.d.ts +64 -0
  83. package/dist/components/energy-history-chart.js +62 -0
  84. package/dist/components/energy-history-chart.js.map +1 -0
  85. package/dist/components/entity-card.cjs +11 -11
  86. package/dist/components/entity-card.cjs.map +1 -1
  87. package/dist/components/entity-card.d.ts +1 -1
  88. package/dist/components/field.cjs +15 -15
  89. package/dist/components/field.cjs.map +1 -1
  90. package/dist/components/hero-metric.cjs +4 -4
  91. package/dist/components/hero-metric.cjs.map +1 -1
  92. package/dist/components/icon.cjs +2 -2
  93. package/dist/components/icon.cjs.map +1 -1
  94. package/dist/components/icon.js +1 -1
  95. package/dist/components/info-block.cjs +9 -9
  96. package/dist/components/info-block.cjs.map +1 -1
  97. package/dist/components/info-block.d.cts +1 -1
  98. package/dist/components/info-block.d.ts +1 -1
  99. package/dist/components/input-date.cjs +3 -3
  100. package/dist/components/input-date.cjs.map +1 -1
  101. package/dist/components/input-date.js +1 -1
  102. package/dist/components/input-group.cjs +5 -5
  103. package/dist/components/input-group.cjs.map +1 -1
  104. package/dist/components/input-otp.cjs +3 -3
  105. package/dist/components/input-otp.cjs.map +1 -1
  106. package/dist/components/input-otp.js +1 -1
  107. package/dist/components/input.cjs +3 -3
  108. package/dist/components/input.cjs.map +1 -1
  109. package/dist/components/input.js +1 -1
  110. package/dist/components/label.cjs +2 -2
  111. package/dist/components/label.cjs.map +1 -1
  112. package/dist/components/layout.cjs +2 -2
  113. package/dist/components/layout.cjs.map +1 -1
  114. package/dist/components/line-chart.cjs +7 -7
  115. package/dist/components/line-chart.cjs.map +1 -1
  116. package/dist/components/line-chart.js +4 -4
  117. package/dist/components/list.cjs +10 -10
  118. package/dist/components/list.cjs.map +1 -1
  119. package/dist/components/list.js +1 -1
  120. package/dist/components/list.js.map +1 -1
  121. package/dist/components/marker.cjs +4 -4
  122. package/dist/components/marker.cjs.map +1 -1
  123. package/dist/components/marker.d.cts +1 -1
  124. package/dist/components/marker.d.ts +1 -1
  125. package/dist/components/message-scroller.cjs +8 -8
  126. package/dist/components/message-scroller.cjs.map +1 -1
  127. package/dist/components/message-scroller.js +4 -4
  128. package/dist/components/message-scroller.js.map +1 -1
  129. package/dist/components/message.cjs +7 -7
  130. package/dist/components/message.cjs.map +1 -1
  131. package/dist/components/number-flow.d.cts +2 -12
  132. package/dist/components/number-flow.d.ts +2 -12
  133. package/dist/components/page-header.cjs +6 -6
  134. package/dist/components/page-header.cjs.map +1 -1
  135. package/dist/components/page-header.d.cts +1 -1
  136. package/dist/components/page-header.d.ts +1 -1
  137. package/dist/components/page-header.js +1 -1
  138. package/dist/components/period-tabs.cjs +6 -6
  139. package/dist/components/period-tabs.cjs.map +1 -1
  140. package/dist/components/pill.cjs +3 -3
  141. package/dist/components/pill.cjs.map +1 -1
  142. package/dist/components/pill.js +2 -2
  143. package/dist/components/popover.cjs +2 -2
  144. package/dist/components/popover.cjs.map +1 -1
  145. package/dist/components/power-history-chart.cjs +498 -0
  146. package/dist/components/power-history-chart.cjs.map +1 -0
  147. package/dist/components/power-history-chart.d.cts +71 -0
  148. package/dist/components/power-history-chart.d.ts +71 -0
  149. package/dist/components/power-history-chart.js +496 -0
  150. package/dist/components/power-history-chart.js.map +1 -0
  151. package/dist/components/power-network.cjs +559 -0
  152. package/dist/components/power-network.cjs.map +1 -0
  153. package/dist/components/power-network.d.cts +80 -0
  154. package/dist/components/power-network.d.ts +80 -0
  155. package/dist/components/power-network.js +553 -0
  156. package/dist/components/power-network.js.map +1 -0
  157. package/dist/components/progress.cjs +2 -2
  158. package/dist/components/progress.cjs.map +1 -1
  159. package/dist/components/radio-card-group.cjs +3 -3
  160. package/dist/components/radio-card-group.cjs.map +1 -1
  161. package/dist/components/radio.cjs +3 -3
  162. package/dist/components/radio.cjs.map +1 -1
  163. package/dist/components/radio.js +1 -1
  164. package/dist/components/sankey-chart.cjs +13 -3
  165. package/dist/components/sankey-chart.cjs.map +1 -1
  166. package/dist/components/sankey-chart.d.cts +3 -2
  167. package/dist/components/sankey-chart.d.ts +3 -2
  168. package/dist/components/sankey-chart.js +11 -2
  169. package/dist/components/sankey-chart.js.map +1 -1
  170. package/dist/components/schedule-editor.cjs +9 -9
  171. package/dist/components/schedule-editor.cjs.map +1 -1
  172. package/dist/components/schedule-list.cjs +11 -11
  173. package/dist/components/schedule-list.cjs.map +1 -1
  174. package/dist/components/schedule-list.js +1 -1
  175. package/dist/components/scroll-area.cjs +3 -3
  176. package/dist/components/scroll-area.cjs.map +1 -1
  177. package/dist/components/segmented-control.cjs +4 -4
  178. package/dist/components/segmented-control.cjs.map +1 -1
  179. package/dist/components/select.cjs +13 -13
  180. package/dist/components/select.cjs.map +1 -1
  181. package/dist/components/select.js +2 -2
  182. package/dist/components/separator.cjs +3 -3
  183. package/dist/components/separator.cjs.map +1 -1
  184. package/dist/components/series-legend.cjs +4 -4
  185. package/dist/components/series-legend.cjs.map +1 -1
  186. package/dist/components/sheet.cjs +9 -9
  187. package/dist/components/sheet.cjs.map +1 -1
  188. package/dist/components/sheet.js +1 -1
  189. package/dist/components/skeleton.cjs +3 -3
  190. package/dist/components/skeleton.cjs.map +1 -1
  191. package/dist/components/slider.cjs +11 -11
  192. package/dist/components/slider.cjs.map +1 -1
  193. package/dist/components/solar-forecast-chart.cjs +108 -0
  194. package/dist/components/solar-forecast-chart.cjs.map +1 -0
  195. package/dist/components/solar-forecast-chart.d.cts +77 -0
  196. package/dist/components/solar-forecast-chart.d.ts +77 -0
  197. package/dist/components/solar-forecast-chart.js +103 -0
  198. package/dist/components/solar-forecast-chart.js.map +1 -0
  199. package/dist/components/sortable-list.cjs +3 -3
  200. package/dist/components/sortable-list.cjs.map +1 -1
  201. package/dist/components/spinner.cjs +2 -2
  202. package/dist/components/spinner.cjs.map +1 -1
  203. package/dist/components/stat-card.cjs +8 -8
  204. package/dist/components/stat-card.cjs.map +1 -1
  205. package/dist/components/stepper.cjs +3 -3
  206. package/dist/components/stepper.cjs.map +1 -1
  207. package/dist/components/stepper.js +1 -1
  208. package/dist/components/switch.cjs +3 -3
  209. package/dist/components/switch.cjs.map +1 -1
  210. package/dist/components/switch.js +1 -1
  211. package/dist/components/table.cjs +9 -9
  212. package/dist/components/table.cjs.map +1 -1
  213. package/dist/components/table.js +1 -1
  214. package/dist/components/tabs.cjs +8 -8
  215. package/dist/components/tabs.cjs.map +1 -1
  216. package/dist/components/tabs.js +1 -1
  217. package/dist/components/textarea.cjs +3 -3
  218. package/dist/components/textarea.cjs.map +1 -1
  219. package/dist/components/textarea.js +1 -1
  220. package/dist/components/theme.cjs +2 -2
  221. package/dist/components/theme.cjs.map +1 -1
  222. package/dist/components/theme.js +1 -1
  223. package/dist/components/thumbnail.cjs +3 -3
  224. package/dist/components/thumbnail.cjs.map +1 -1
  225. package/dist/components/time-picker.cjs +3 -3
  226. package/dist/components/time-picker.cjs.map +1 -1
  227. package/dist/components/toast.cjs +8 -8
  228. package/dist/components/toast.cjs.map +1 -1
  229. package/dist/components/toast.js +1 -1
  230. package/dist/components/tooltip.cjs +4 -4
  231. package/dist/components/tooltip.cjs.map +1 -1
  232. package/dist/components/tooltip.js +1 -1
  233. package/dist/components/typography.cjs +6 -6
  234. package/dist/components/typography.cjs.map +1 -1
  235. package/dist/components/wizard-layout.cjs +8 -8
  236. package/dist/components/wizard-layout.cjs.map +1 -1
  237. package/dist/lib/input-box-variants.cjs +9 -9
  238. package/dist/lib/input-box-variants.cjs.map +1 -1
  239. package/dist/number-flow-Bch81ixZ.d.cts +14 -0
  240. package/dist/number-flow-Bch81ixZ.d.ts +14 -0
  241. package/dist/styles/spark-default.css +11 -0
  242. package/dist/utils/build-sankey-nodes.cjs +72 -0
  243. package/dist/utils/build-sankey-nodes.cjs.map +1 -0
  244. package/dist/utils/build-sankey-nodes.d.cts +27 -0
  245. package/dist/utils/build-sankey-nodes.d.ts +27 -0
  246. package/dist/utils/build-sankey-nodes.js +71 -0
  247. package/dist/utils/build-sankey-nodes.js.map +1 -0
  248. package/dist/utils/cn.cjs +2 -2
  249. package/dist/utils/cn.d.cts +1 -1
  250. package/dist/utils/cn.d.ts +1 -1
  251. package/dist/utils/cn.js +1 -1
  252. package/dist/utils/format.cjs +13 -0
  253. package/dist/utils/format.cjs.map +1 -1
  254. package/dist/utils/format.d.cts +7 -1
  255. package/dist/utils/format.d.ts +7 -1
  256. package/dist/utils/format.js +12 -1
  257. package/dist/utils/format.js.map +1 -1
  258. package/package.json +2 -2
@@ -4,7 +4,7 @@ const require_chunk = require("../chunk-DY84GLCh.cjs");
4
4
  let react = require("react");
5
5
  react = require_chunk.__toESM(react);
6
6
  let react_jsx_runtime = require("react/jsx-runtime");
7
- let cnfast = require("cnfast");
7
+ let cn = require("cn");
8
8
  //#region src/components/radio-card-group.tsx
9
9
  const RadioCardGroupContext = react.createContext(void 0);
10
10
  const ARROW_STEP = {
@@ -57,7 +57,7 @@ const RadioCardGroup = react.forwardRef(({ value: valueProp, defaultValue, onVal
57
57
  ref,
58
58
  role: "radiogroup",
59
59
  onKeyDown: handleKeyDown,
60
- className: (0, cnfast.cn)("flex flex-col gap-[calc(var(--spark-layout-gap)*var(--radio-card-group-gap-steps,2))]", className),
60
+ className: (0, cn.cn)("flex flex-col gap-[calc(var(--spark-layout-gap)*var(--radio-card-group-gap-steps,2))]", className),
61
61
  style: {
62
62
  "--radio-card-group-gap-steps": gap,
63
63
  ...style
@@ -85,7 +85,7 @@ const RadioCardGroupItem = react.forwardRef(({ value, className, children, disab
85
85
  onClick?.(event);
86
86
  if (!event.defaultPrevented && !isDisabled) ctx.onValueChange(value);
87
87
  },
88
- className: (0, cnfast.cn)("h-12 w-full rounded-lg px-4 text-base font-medium transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50", checked ? "border border-accent bg-base-accent-soft text-accent" : "border border-transparent bg-base-gray-soft text-gray hover:bg-gray-a3", className),
88
+ className: (0, cn.cn)("h-12 w-full rounded-lg px-4 text-base font-medium transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50", checked ? "border border-accent bg-base-accent-soft text-accent" : "border border-transparent bg-base-gray-soft text-gray hover:bg-gray-a3", className),
89
89
  ...props,
90
90
  children
91
91
  });
@@ -1 +1 @@
1
- {"version":3,"file":"radio-card-group.cjs","names":["React"],"sources":["../../src/components/radio-card-group.tsx"],"sourcesContent":["import * as React from 'react'\nimport { cn } from '../utils/cn'\n\ninterface RadioCardGroupContextValue {\n value: string | undefined\n onValueChange: (value: string) => void\n disabled?: boolean\n name: string\n}\n\nconst RadioCardGroupContext = React.createContext<\n RadioCardGroupContextValue | undefined\n>(undefined)\n\nconst ARROW_STEP: Record<string, 1 | -1> = {\n ArrowDown: 1,\n ArrowRight: 1,\n ArrowUp: -1,\n ArrowLeft: -1,\n}\n\ninterface RadioCardGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n value?: string\n defaultValue?: string\n onValueChange?: (value: string) => void\n disabled?: boolean\n /** Optional name used for ARIA grouping. Defaults to a generated id. */\n name?: string\n /** How many `--spark-layout-gap` units apart each card sits. */\n gap?: number\n}\n\nconst RadioCardGroup = React.forwardRef<HTMLDivElement, RadioCardGroupProps>(\n (\n {\n value: valueProp,\n defaultValue,\n onValueChange,\n disabled,\n name,\n gap = 2,\n className,\n style,\n children,\n ...props\n },\n ref,\n ) => {\n const generatedName = React.useId()\n const [internalValue, setInternalValue] = React.useState<\n string | undefined\n >(defaultValue)\n const isControlled = valueProp !== undefined\n const value = isControlled ? valueProp : internalValue\n\n const handleValueChange = React.useCallback(\n (next: string) => {\n if (!isControlled) setInternalValue(next)\n onValueChange?.(next)\n },\n [isControlled, onValueChange],\n )\n\n const ctx = React.useMemo<RadioCardGroupContextValue>(\n () => ({\n value,\n onValueChange: handleValueChange,\n disabled,\n name: name ?? generatedName,\n }),\n [value, handleValueChange, disabled, name, generatedName],\n )\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const step = ARROW_STEP[event.key]\n if (step === undefined && event.key !== 'Home' && event.key !== 'End')\n return\n const radios = [\n ...event.currentTarget.querySelectorAll<HTMLButtonElement>(\n '[role=\"radio\"]:not(:disabled)',\n ),\n ]\n if (radios.length === 0) return\n event.preventDefault()\n\n let next = 0\n if (event.key === 'End') {\n next = radios.length - 1\n } else if (step !== undefined) {\n const current = radios.indexOf(\n document.activeElement as HTMLButtonElement,\n )\n if (current !== -1) {\n next = (current + step + radios.length) % radios.length\n }\n }\n const target = radios[next]\n if (!target) return\n target.focus()\n target.click()\n }\n\n return (\n <RadioCardGroupContext.Provider value={ctx}>\n {/* oxlint-disable-next-line jsx-a11y/interactive-supports-focus -- radiogroup is a composite: the tab stop belongs on the roving radios, not the container */}\n <div\n ref={ref}\n role=\"radiogroup\"\n onKeyDown={handleKeyDown}\n className={cn(\n 'flex flex-col gap-[calc(var(--spark-layout-gap)*var(--radio-card-group-gap-steps,2))]',\n className,\n )}\n style={\n {\n '--radio-card-group-gap-steps': gap,\n ...style,\n } as React.CSSProperties\n }\n {...props}\n >\n {children}\n </div>\n </RadioCardGroupContext.Provider>\n )\n },\n)\n\nRadioCardGroup.displayName = 'RadioCardGroup'\n\ninterface RadioCardGroupItemProps extends Omit<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n 'value'\n> {\n value: string\n}\n\nconst RadioCardGroupItem = React.forwardRef<\n HTMLButtonElement,\n RadioCardGroupItemProps\n>(({ value, className, children, disabled, onClick, ...props }, ref) => {\n const ctx = React.useContext(RadioCardGroupContext)\n if (!ctx) {\n throw new Error('RadioCardGroupItem must be used within a RadioCardGroup')\n }\n\n const checked = ctx.value === value\n const isDisabled = disabled ?? ctx.disabled\n\n return (\n <button\n ref={ref}\n type=\"button\"\n role=\"radio\"\n aria-checked={checked}\n data-state={checked ? 'checked' : 'unchecked'}\n tabIndex={checked || ctx.value === undefined ? 0 : -1}\n disabled={isDisabled}\n onClick={(event) => {\n onClick?.(event)\n if (!event.defaultPrevented && !isDisabled) {\n ctx.onValueChange(value)\n }\n }}\n className={cn(\n 'h-12 w-full rounded-lg px-4 text-base font-medium transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',\n checked\n ? 'border border-accent bg-base-accent-soft text-accent'\n : 'border border-transparent bg-base-gray-soft text-gray hover:bg-gray-a3',\n className,\n )}\n {...props}\n >\n {children}\n </button>\n )\n})\n\nRadioCardGroupItem.displayName = 'RadioCardGroupItem'\n\nexport { RadioCardGroup, RadioCardGroupItem }\nexport type { RadioCardGroupProps, RadioCardGroupItemProps }\n"],"mappings":";;;;;;;;AAUA,MAAM,wBAAwBA,MAAM,cAElC,KAAA,CAAS;AAEX,MAAM,aAAqC;CACzC,WAAW;CACX,YAAY;CACZ,SAAS;CACT,WAAW;AACb;AAaA,MAAM,iBAAiBA,MAAM,YAEzB,EACE,OAAO,WACP,cACA,eACA,UACA,MACA,MAAM,GACN,WACA,OACA,UACA,GAAG,SAEL,QACG;CACH,MAAM,gBAAgBA,MAAM,MAAM;CAClC,MAAM,CAAC,eAAe,oBAAoBA,MAAM,SAE9C,YAAY;CACd,MAAM,eAAe,cAAc,KAAA;CACnC,MAAM,QAAQ,eAAe,YAAY;CAEzC,MAAM,oBAAoBA,MAAM,aAC7B,SAAiB;EAChB,IAAI,CAAC,cAAc,iBAAiB,IAAI;EACxC,gBAAgB,IAAI;CACtB,GACA,CAAC,cAAc,aAAa,CAC9B;CAEA,MAAM,MAAMA,MAAM,eACT;EACL;EACA,eAAe;EACf;EACA,MAAM,QAAQ;CAChB,IACA;EAAC;EAAO;EAAmB;EAAU;EAAM;CAAa,CAC1D;CAEA,MAAM,iBAAiB,UAA+C;EACpE,MAAM,OAAO,WAAW,MAAM;EAC9B,IAAI,SAAS,KAAA,KAAa,MAAM,QAAQ,UAAU,MAAM,QAAQ,OAC9D;EACF,MAAM,SAAS,CACb,GAAG,MAAM,cAAc,iBACrB,iCACF,CACF;EACA,IAAI,OAA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"}
1
+ {"version":3,"file":"radio-card-group.cjs","names":["React"],"sources":["../../src/components/radio-card-group.tsx"],"sourcesContent":["import * as React from 'react'\nimport { cn } from '../utils/cn'\n\ninterface RadioCardGroupContextValue {\n value: string | undefined\n onValueChange: (value: string) => void\n disabled?: boolean\n name: string\n}\n\nconst RadioCardGroupContext = React.createContext<\n RadioCardGroupContextValue | undefined\n>(undefined)\n\nconst ARROW_STEP: Record<string, 1 | -1> = {\n ArrowDown: 1,\n ArrowRight: 1,\n ArrowUp: -1,\n ArrowLeft: -1,\n}\n\ninterface RadioCardGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n value?: string\n defaultValue?: string\n onValueChange?: (value: string) => void\n disabled?: boolean\n /** Optional name used for ARIA grouping. Defaults to a generated id. */\n name?: string\n /** How many `--spark-layout-gap` units apart each card sits. */\n gap?: number\n}\n\nconst RadioCardGroup = React.forwardRef<HTMLDivElement, RadioCardGroupProps>(\n (\n {\n value: valueProp,\n defaultValue,\n onValueChange,\n disabled,\n name,\n gap = 2,\n className,\n style,\n children,\n ...props\n },\n ref,\n ) => {\n const generatedName = React.useId()\n const [internalValue, setInternalValue] = React.useState<\n string | undefined\n >(defaultValue)\n const isControlled = valueProp !== undefined\n const value = isControlled ? valueProp : internalValue\n\n const handleValueChange = React.useCallback(\n (next: string) => {\n if (!isControlled) setInternalValue(next)\n onValueChange?.(next)\n },\n [isControlled, onValueChange],\n )\n\n const ctx = React.useMemo<RadioCardGroupContextValue>(\n () => ({\n value,\n onValueChange: handleValueChange,\n disabled,\n name: name ?? generatedName,\n }),\n [value, handleValueChange, disabled, name, generatedName],\n )\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const step = ARROW_STEP[event.key]\n if (step === undefined && event.key !== 'Home' && event.key !== 'End')\n return\n const radios = [\n ...event.currentTarget.querySelectorAll<HTMLButtonElement>(\n '[role=\"radio\"]:not(:disabled)',\n ),\n ]\n if (radios.length === 0) return\n event.preventDefault()\n\n let next = 0\n if (event.key === 'End') {\n next = radios.length - 1\n } else if (step !== undefined) {\n const current = radios.indexOf(\n document.activeElement as HTMLButtonElement,\n )\n if (current !== -1) {\n next = (current + step + radios.length) % radios.length\n }\n }\n const target = radios[next]\n if (!target) return\n target.focus()\n target.click()\n }\n\n return (\n <RadioCardGroupContext.Provider value={ctx}>\n {/* oxlint-disable-next-line jsx-a11y/interactive-supports-focus -- radiogroup is a composite: the tab stop belongs on the roving radios, not the container */}\n <div\n ref={ref}\n role=\"radiogroup\"\n onKeyDown={handleKeyDown}\n className={cn(\n 'flex flex-col gap-[calc(var(--spark-layout-gap)*var(--radio-card-group-gap-steps,2))]',\n className,\n )}\n style={\n {\n '--radio-card-group-gap-steps': gap,\n ...style,\n } as React.CSSProperties\n }\n {...props}\n >\n {children}\n </div>\n </RadioCardGroupContext.Provider>\n )\n },\n)\n\nRadioCardGroup.displayName = 'RadioCardGroup'\n\ninterface RadioCardGroupItemProps extends Omit<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n 'value'\n> {\n value: string\n}\n\nconst RadioCardGroupItem = React.forwardRef<\n HTMLButtonElement,\n RadioCardGroupItemProps\n>(({ value, className, children, disabled, onClick, ...props }, ref) => {\n const ctx = React.useContext(RadioCardGroupContext)\n if (!ctx) {\n throw new Error('RadioCardGroupItem must be used within a RadioCardGroup')\n }\n\n const checked = ctx.value === value\n const isDisabled = disabled ?? ctx.disabled\n\n return (\n <button\n ref={ref}\n type=\"button\"\n role=\"radio\"\n aria-checked={checked}\n data-state={checked ? 'checked' : 'unchecked'}\n tabIndex={checked || ctx.value === undefined ? 0 : -1}\n disabled={isDisabled}\n onClick={(event) => {\n onClick?.(event)\n if (!event.defaultPrevented && !isDisabled) {\n ctx.onValueChange(value)\n }\n }}\n className={cn(\n 'h-12 w-full rounded-lg px-4 text-base font-medium transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',\n checked\n ? 'border border-accent bg-base-accent-soft text-accent'\n : 'border border-transparent bg-base-gray-soft text-gray hover:bg-gray-a3',\n className,\n )}\n {...props}\n >\n {children}\n </button>\n )\n})\n\nRadioCardGroupItem.displayName = 'RadioCardGroupItem'\n\nexport { RadioCardGroup, RadioCardGroupItem }\nexport type { RadioCardGroupProps, RadioCardGroupItemProps }\n"],"mappings":";;;;;;;;AAUA,MAAM,wBAAwBA,MAAM,cAElC,KAAA,CAAS;AAEX,MAAM,aAAqC;CACzC,WAAW;CACX,YAAY;CACZ,SAAS;CACT,WAAW;AACb;AAaA,MAAM,iBAAiBA,MAAM,YAEzB,EACE,OAAO,WACP,cACA,eACA,UACA,MACA,MAAM,GACN,WACA,OACA,UACA,GAAG,SAEL,QACG;CACH,MAAM,gBAAgBA,MAAM,MAAM;CAClC,MAAM,CAAC,eAAe,oBAAoBA,MAAM,SAE9C,YAAY;CACd,MAAM,eAAe,cAAc,KAAA;CACnC,MAAM,QAAQ,eAAe,YAAY;CAEzC,MAAM,oBAAoBA,MAAM,aAC7B,SAAiB;EAChB,IAAI,CAAC,cAAc,iBAAiB,IAAI;EACxC,gBAAgB,IAAI;CACtB,GACA,CAAC,cAAc,aAAa,CAC9B;CAEA,MAAM,MAAMA,MAAM,eACT;EACL;EACA,eAAe;EACf;EACA,MAAM,QAAQ;CAChB,IACA;EAAC;EAAO;EAAmB;EAAU;EAAM;CAAa,CAC1D;CAEA,MAAM,iBAAiB,UAA+C;EACpE,MAAM,OAAO,WAAW,MAAM;EAC9B,IAAI,SAAS,KAAA,KAAa,MAAM,QAAQ,UAAU,MAAM,QAAQ,OAC9D;EACF,MAAM,SAAS,CACb,GAAG,MAAM,cAAc,iBACrB,iCACF,CACF;EACA,IAAI,OAAO,WAAW,GAAG;EACzB,MAAM,eAAe;EAErB,IAAI,OAAO;EACX,IAAI,MAAM,QAAQ,OAChB,OAAO,OAAO,SAAS;OAClB,IAAI,SAAS,KAAA,GAAW;GAC7B,MAAM,UAAU,OAAO,QACrB,SAAS,aACX;GACA,IAAI,YAAY,IACd,QAAQ,UAAU,OAAO,OAAO,UAAU,OAAO;EAErD;EACA,MAAM,SAAS,OAAO;EACtB,IAAI,CAAC,QAAQ;EACb,OAAO,MAAM;EACb,OAAO,MAAM;CACf;CAEA,OACE,iBAAA,GAAA,kBAAA,KAAC,sBAAsB,UAAvB;EAAgC,OAAO;YAErC,iBAAA,GAAA,kBAAA,KAAC,OAAD;GACO;GACL,MAAK;GACL,WAAW;GACX,YAAA,GAAA,GAAA,IACE,yFACA,SACF;GACA,OACE;IACE,gCAAgC;IAChC,GAAG;GACL;GAEF,GAAI;GAEH;EACE,CAAA;CACyB,CAAA;AAEpC,CACF;AAEA,eAAe,cAAc;AAS7B,MAAM,qBAAqBA,MAAM,YAG9B,EAAE,OAAO,WAAW,UAAU,UAAU,SAAS,GAAG,SAAS,QAAQ;CACtE,MAAM,MAAMA,MAAM,WAAW,qBAAqB;CAClD,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,yDAAyD;CAG3E,MAAM,UAAU,IAAI,UAAU;CAC9B,MAAM,aAAa,YAAY,IAAI;CAEnC,OACE,iBAAA,GAAA,kBAAA,KAAC,UAAD;EACO;EACL,MAAK;EACL,MAAK;EACL,gBAAc;EACd,cAAY,UAAU,YAAY;EAClC,UAAU,WAAW,IAAI,UAAU,KAAA,IAAY,IAAI;EACnD,UAAU;EACV,UAAU,UAAU;GAClB,UAAU,KAAK;GACf,IAAI,CAAC,MAAM,oBAAoB,CAAC,YAC9B,IAAI,cAAc,KAAK;EAE3B;EACA,YAAA,GAAA,GAAA,IACE,qMACA,UACI,yDACA,0EACJ,SACF;EACA,GAAI;EAEH;CACK,CAAA;AAEZ,CAAC;AAED,mBAAmB,cAAc"}
@@ -7,14 +7,14 @@ react = require_chunk.__toESM(react);
7
7
  let react_jsx_runtime = require("react/jsx-runtime");
8
8
  let _base_ui_react_radio = require("@base-ui/react/radio");
9
9
  let _base_ui_react_radio_group = require("@base-ui/react/radio-group");
10
- let cnfast = require("cnfast");
10
+ let cn = require("cn");
11
11
  //#region src/components/radio.tsx
12
12
  function RadioGroup({ className, styleVariant, color, gap = 3, style, ...props }) {
13
13
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_radio_group.RadioGroup, {
14
14
  "data-slot": "radio-group",
15
15
  "data-style": styleVariant !== void 0 || color !== void 0 ? styleVariant ?? "solid" : void 0,
16
16
  "data-accent-color": color ? require_lib_accent_colors.accentByColor[color] : void 0,
17
- className: (0, cnfast.cn)("grid gap-[calc(var(--spark-layout-gap)*var(--radio-group-gap-steps,3))]", className),
17
+ className: (0, cn.cn)("grid gap-[calc(var(--spark-layout-gap)*var(--radio-group-gap-steps,3))]", className),
18
18
  style: {
19
19
  "--radio-group-gap-steps": gap,
20
20
  ...style
@@ -31,7 +31,7 @@ function Radio({ className, styleVariant, color, render, nativeButton, ...props
31
31
  "data-accent-color": dataAccentColor,
32
32
  nativeButton: nativeButton ?? render === void 0,
33
33
  render: render ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {}),
34
- className: (0, cnfast.cn)("peer touch-target relative my-2 inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-full border-2 p-0 transition-colors any-pointer-coarse:my-[calc((2.75rem-var(--spacing)*6)/2)]", "before:absolute before:top-1/2 before:left-1/2 before:size-10 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']", "focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden", "data-disabled:cursor-not-allowed data-disabled:opacity-50", "border-(--spark-style-idle-border,var(--color-accent-ui)) bg-base-accent-soft data-unchecked:border-(length:--spark-style-border-width,2px)", "data-checked:border-(--spark-radio-ring,var(--spark-9))", className),
34
+ className: (0, cn.cn)("peer touch-target relative my-2 inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-full border-2 p-0 transition-colors any-pointer-coarse:my-[calc((2.75rem-var(--spacing)*6)/2)]", "before:absolute before:top-1/2 before:left-1/2 before:size-10 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']", "focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden", "data-disabled:cursor-not-allowed data-disabled:opacity-50", "border-(--spark-style-idle-border,var(--color-accent-ui)) bg-base-accent-soft data-unchecked:border-(length:--spark-style-border-width,2px)", "data-checked:border-(--spark-radio-ring,var(--spark-9))", className),
35
35
  ...props,
36
36
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_radio.Radio.Indicator, {
37
37
  "data-slot": "radio-indicator",
@@ -1 +1 @@
1
- {"version":3,"file":"radio.cjs","names":["RadioGroupPrimitive","accentByColor","RadioPrimitive"],"sources":["../../src/components/radio.tsx"],"sourcesContent":["import { Radio as RadioPrimitive } from '@base-ui/react/radio'\nimport { RadioGroup as RadioGroupPrimitive } from '@base-ui/react/radio-group'\nimport * as React from 'react'\nimport { accentByColor } from '../lib/accent-colors'\nimport type { SparkStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\n\nexport type SparkRadioColor = 'accent' | 'neutral' | 'danger'\n\ntype RadioGroupProps = Omit<\n React.ComponentProps<typeof RadioGroupPrimitive>,\n 'style'\n> & {\n styleVariant?: SparkStyle\n color?: SparkRadioColor\n /** How many `--spark-layout-gap` units apart each radio sits. */\n gap?: number\n // Base UI's own `style` also accepts a state-callback form; the gap-steps var below\n // needs a plain object to merge into, so narrow it to that here.\n style?: React.CSSProperties\n}\n\nfunction RadioGroup({\n className,\n styleVariant,\n color,\n gap = 3,\n style,\n ...props\n}: RadioGroupProps) {\n const hasLook = styleVariant !== undefined || color !== undefined\n const dataStyle = hasLook ? (styleVariant ?? 'solid') : undefined\n const dataAccentColor = color ? accentByColor[color] : undefined\n\n return (\n <RadioGroupPrimitive\n data-slot=\"radio-group\"\n data-style={dataStyle}\n data-accent-color={dataAccentColor}\n className={cn(\n 'grid gap-[calc(var(--spark-layout-gap)*var(--radio-group-gap-steps,3))]',\n className,\n )}\n style={\n { '--radio-group-gap-steps': gap, ...style } as React.CSSProperties\n }\n {...props}\n />\n )\n}\n\ntype RadioProps = React.ComponentProps<typeof RadioPrimitive.Root> & {\n styleVariant?: SparkStyle\n color?: SparkRadioColor\n}\n\nfunction Radio({\n className,\n styleVariant,\n color,\n render,\n nativeButton,\n ...props\n}: RadioProps) {\n const hasLook = styleVariant !== undefined || color !== undefined\n const dataStyle = hasLook ? (styleVariant ?? 'solid') : undefined\n const dataAccentColor = color ? accentByColor[color] : undefined\n\n return (\n <RadioPrimitive.Root\n data-slot=\"radio\"\n data-style={dataStyle}\n data-accent-color={dataAccentColor}\n // a native button owns the caller's `id`; on Base UI's default <span> the\n // `id` lands on the hidden input and the control gets a generated one\n nativeButton={nativeButton ?? render === undefined}\n render={render ?? <button />}\n className={cn(\n // p-0 defends the 24px box against the UA button padding when the\n // consumer's CSS has no Tailwind preflight\n 'peer touch-target relative my-2 inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-full border-2 p-0 transition-colors any-pointer-coarse:my-[calc((2.75rem-var(--spacing)*6)/2)]',\n // both overlays are reserved as layout, so neither can bleed into a scroller;\n // the coarse margin tracks --spacing so the 44px reserve holds at any [data-scaling]\n \"before:absolute before:top-1/2 before:left-1/2 before:size-10 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']\",\n 'focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden',\n 'data-disabled:cursor-not-allowed data-disabled:opacity-50',\n 'border-(--spark-style-idle-border,var(--color-accent-ui)) bg-base-accent-soft data-unchecked:border-(length:--spark-style-border-width,2px)',\n 'data-checked:border-(--spark-radio-ring,var(--spark-9))',\n className,\n )}\n {...props}\n >\n <RadioPrimitive.Indicator\n data-slot=\"radio-indicator\"\n className=\"flex items-center justify-center\"\n >\n <span className=\"size-4 rounded-full bg-(--spark-radio-dot,var(--spark-9)) motion-safe:animate-dot-pop\" />\n </RadioPrimitive.Indicator>\n </RadioPrimitive.Root>\n )\n}\n\nexport { Radio, RadioGroup }\nexport type { RadioGroupProps, RadioProps }\n"],"mappings":";;;;;;;;;;;AAsBA,SAAS,WAAW,EAClB,WACA,cACA,OACA,MAAM,GACN,OACA,GAAG,SACe;CAKlB,OACE,iBAAA,GAAA,kBAAA,KAACA,2BAAAA,YAAD;EACE,aAAU;EACV,cAPY,iBAAiB,KAAA,KAAa,UAAU,KAAA,IAC3B,gBAAgB,UAAW,KAAA;EAOpD,qBANoB,QAAQC,0BAAAA,cAAc,SAAS,KAAA;EAOnD,YAAA,GAAA,OAAA,IACE,2EACA,SACF;EACA,OACE;GAAE,2BAA2B;GAAK,GAAG;EAAM;EAE7C,GAAI;CACL,CAAA;AAEL;AAOA,SAAS,MAAM,EACb,WACA,cACA,OACA,QACA,cACA,GAAG,SACU;CAEb,MAAM,YADU,iBAAiB,KAAA,KAAa,UAAU,KAAA,IAC3B,gBAAgB,UAAW,KAAA;CACxD,MAAM,kBAAkB,QAAQA,0BAAAA,cAAc,SAAS,KAAA;CAEvD,OACE,iBAAA,GAAA,kBAAA,KAACC,qBAAAA,MAAe,MAAhB;EACE,aAAU;EACV,cAAY;EACZ,qBAAmB;EAGnB,cAAc,gBAAgB,WAAW,KAAA;EACzC,QAAQ,UAAU,iBAAA,GAAA,kBAAA,KAAC,UAAD,CAAS,CAAA;EAC3B,YAAA,GAAA,OAAA,IAGE,iNAGA,qIACA,iFACA,6DACA,+IACA,2DACA,SACF;EACA,GAAI;YAEJ,iBAAA,GAAA,kBAAA,KAACA,qBAAAA,MAAe,WAAhB;GACE,aAAU;GACV,WAAU;aAEV,iBAAA,GAAA,kBAAA,KAAC,QAAD,EAAM,WAAU,wFAAyF,CAAA;EACjF,CAAA;CACP,CAAA;AAEzB"}
1
+ {"version":3,"file":"radio.cjs","names":["RadioGroupPrimitive","accentByColor","RadioPrimitive"],"sources":["../../src/components/radio.tsx"],"sourcesContent":["import { Radio as RadioPrimitive } from '@base-ui/react/radio'\nimport { RadioGroup as RadioGroupPrimitive } from '@base-ui/react/radio-group'\nimport * as React from 'react'\nimport { accentByColor } from '../lib/accent-colors'\nimport type { SparkStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\n\nexport type SparkRadioColor = 'accent' | 'neutral' | 'danger'\n\ntype RadioGroupProps = Omit<\n React.ComponentProps<typeof RadioGroupPrimitive>,\n 'style'\n> & {\n styleVariant?: SparkStyle\n color?: SparkRadioColor\n /** How many `--spark-layout-gap` units apart each radio sits. */\n gap?: number\n // Base UI's own `style` also accepts a state-callback form; the gap-steps var below\n // needs a plain object to merge into, so narrow it to that here.\n style?: React.CSSProperties\n}\n\nfunction RadioGroup({\n className,\n styleVariant,\n color,\n gap = 3,\n style,\n ...props\n}: RadioGroupProps) {\n const hasLook = styleVariant !== undefined || color !== undefined\n const dataStyle = hasLook ? (styleVariant ?? 'solid') : undefined\n const dataAccentColor = color ? accentByColor[color] : undefined\n\n return (\n <RadioGroupPrimitive\n data-slot=\"radio-group\"\n data-style={dataStyle}\n data-accent-color={dataAccentColor}\n className={cn(\n 'grid gap-[calc(var(--spark-layout-gap)*var(--radio-group-gap-steps,3))]',\n className,\n )}\n style={\n { '--radio-group-gap-steps': gap, ...style } as React.CSSProperties\n }\n {...props}\n />\n )\n}\n\ntype RadioProps = React.ComponentProps<typeof RadioPrimitive.Root> & {\n styleVariant?: SparkStyle\n color?: SparkRadioColor\n}\n\nfunction Radio({\n className,\n styleVariant,\n color,\n render,\n nativeButton,\n ...props\n}: RadioProps) {\n const hasLook = styleVariant !== undefined || color !== undefined\n const dataStyle = hasLook ? (styleVariant ?? 'solid') : undefined\n const dataAccentColor = color ? accentByColor[color] : undefined\n\n return (\n <RadioPrimitive.Root\n data-slot=\"radio\"\n data-style={dataStyle}\n data-accent-color={dataAccentColor}\n // a native button owns the caller's `id`; on Base UI's default <span> the\n // `id` lands on the hidden input and the control gets a generated one\n nativeButton={nativeButton ?? render === undefined}\n render={render ?? <button />}\n className={cn(\n // p-0 defends the 24px box against the UA button padding when the\n // consumer's CSS has no Tailwind preflight\n 'peer touch-target relative my-2 inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-full border-2 p-0 transition-colors any-pointer-coarse:my-[calc((2.75rem-var(--spacing)*6)/2)]',\n // both overlays are reserved as layout, so neither can bleed into a scroller;\n // the coarse margin tracks --spacing so the 44px reserve holds at any [data-scaling]\n \"before:absolute before:top-1/2 before:left-1/2 before:size-10 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']\",\n 'focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden',\n 'data-disabled:cursor-not-allowed data-disabled:opacity-50',\n 'border-(--spark-style-idle-border,var(--color-accent-ui)) bg-base-accent-soft data-unchecked:border-(length:--spark-style-border-width,2px)',\n 'data-checked:border-(--spark-radio-ring,var(--spark-9))',\n className,\n )}\n {...props}\n >\n <RadioPrimitive.Indicator\n data-slot=\"radio-indicator\"\n className=\"flex items-center justify-center\"\n >\n <span className=\"size-4 rounded-full bg-(--spark-radio-dot,var(--spark-9)) motion-safe:animate-dot-pop\" />\n </RadioPrimitive.Indicator>\n </RadioPrimitive.Root>\n )\n}\n\nexport { Radio, RadioGroup }\nexport type { RadioGroupProps, RadioProps }\n"],"mappings":";;;;;;;;;;;AAsBA,SAAS,WAAW,EAClB,WACA,cACA,OACA,MAAM,GACN,OACA,GAAG,SACe;CAKlB,OACE,iBAAA,GAAA,kBAAA,KAACA,2BAAAA,YAAD;EACE,aAAU;EACV,cAPY,iBAAiB,KAAA,KAAa,UAAU,KAAA,IAC3B,gBAAgB,UAAW,KAAA;EAOpD,qBANoB,QAAQC,0BAAAA,cAAc,SAAS,KAAA;EAOnD,YAAA,GAAA,GAAA,IACE,2EACA,SACF;EACA,OACE;GAAE,2BAA2B;GAAK,GAAG;EAAM;EAE7C,GAAI;CACL,CAAA;AAEL;AAOA,SAAS,MAAM,EACb,WACA,cACA,OACA,QACA,cACA,GAAG,SACU;CAEb,MAAM,YADU,iBAAiB,KAAA,KAAa,UAAU,KAAA,IAC3B,gBAAgB,UAAW,KAAA;CACxD,MAAM,kBAAkB,QAAQA,0BAAAA,cAAc,SAAS,KAAA;CAEvD,OACE,iBAAA,GAAA,kBAAA,KAACC,qBAAAA,MAAe,MAAhB;EACE,aAAU;EACV,cAAY;EACZ,qBAAmB;EAGnB,cAAc,gBAAgB,WAAW,KAAA;EACzC,QAAQ,UAAU,iBAAA,GAAA,kBAAA,KAAC,UAAD,CAAS,CAAA;EAC3B,YAAA,GAAA,GAAA,IAGE,iNAGA,qIACA,iFACA,6DACA,+IACA,2DACA,SACF;EACA,GAAI;YAEJ,iBAAA,GAAA,kBAAA,KAACA,qBAAAA,MAAe,WAAhB;GACE,aAAU;GACV,WAAU;aAEV,iBAAA,GAAA,kBAAA,KAAC,QAAD,EAAM,WAAU,wFAAyF,CAAA;EACjF,CAAA;CACP,CAAA;AAEzB"}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { cn } from "../utils/cn.js";
3
2
  import { accentByColor } from "../lib/accent-colors.js";
3
+ import { cn } from "../utils/cn.js";
4
4
  import "react";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  import { Radio as Radio$1 } from "@base-ui/react/radio";
@@ -6,8 +6,17 @@ let react = require("react");
6
6
  let react_jsx_runtime = require("react/jsx-runtime");
7
7
  let _visx_group = require("@visx/group");
8
8
  let _visx_sankey = require("@visx/sankey");
9
- let cnfast = require("cnfast");
9
+ let cn = require("cn");
10
10
  //#region src/components/sankey-chart.tsx
11
+ const SANKEY_CATEGORY_COLORS = {
12
+ solar: "var(--orange-a9)",
13
+ battery: "var(--green-a9)",
14
+ grid: "var(--blue-9)",
15
+ gridFeedIn: "var(--blue-7)",
16
+ home: "var(--spark-9)",
17
+ floor: "var(--neutral-a9)",
18
+ device: "var(--neutral-a8)"
19
+ };
11
20
  const DEFAULT_HEIGHT = 260;
12
21
  const DEFAULT_NODE_WIDTH = 12;
13
22
  const DEFAULT_NODE_PADDING = 10;
@@ -22,7 +31,7 @@ function resolveNodeColor(node, categoryColors, defaultColor) {
22
31
  if (node.category && categoryColors?.[node.category]) return categoryColors[node.category];
23
32
  return defaultColor;
24
33
  }
25
- function SankeyChart({ nodes, links, categoryColors, defaultColor = DEFAULT_COLOR, valueSuffix, valueFormat, height = DEFAULT_HEIGHT, nodeWidth = DEFAULT_NODE_WIDTH, nodePadding = DEFAULT_NODE_PADDING, labelPadding = DEFAULT_LABEL_PADDING, keepAtDepthIds, title, className }) {
34
+ function SankeyChart({ nodes, links, categoryColors = SANKEY_CATEGORY_COLORS, defaultColor = DEFAULT_COLOR, valueSuffix, valueFormat, height = DEFAULT_HEIGHT, nodeWidth = DEFAULT_NODE_WIDTH, nodePadding = DEFAULT_NODE_PADDING, labelPadding = DEFAULT_LABEL_PADDING, keepAtDepthIds, title, className }) {
26
35
  const containerRef = (0, react.useRef)(null);
27
36
  const [width, setWidth] = (0, react.useState)(0);
28
37
  (0, react.useEffect)(() => {
@@ -74,7 +83,7 @@ function SankeyChart({ nodes, links, categoryColors, defaultColor = DEFAULT_COLO
74
83
  const halfLabelStack = LABEL_STACK_HEIGHT / 2;
75
84
  const labelWidth = Math.max(40, labelPadding - LABEL_GAP - 4);
76
85
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
77
- className: (0, cnfast.cn)("flex w-full flex-col gap-2 py-2", className),
86
+ className: (0, cn.cn)("flex w-full flex-col gap-2 py-2", className),
78
87
  children: [title && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_typography.SectionTitle, { children: title }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
79
88
  ref: containerRef,
80
89
  className: "relative w-full",
@@ -157,6 +166,7 @@ function SankeyChart({ nodes, links, categoryColors, defaultColor = DEFAULT_COLO
157
166
  });
158
167
  }
159
168
  //#endregion
169
+ exports.SANKEY_CATEGORY_COLORS = SANKEY_CATEGORY_COLORS;
160
170
  exports.SankeyChart = SankeyChart;
161
171
 
162
172
  //# sourceMappingURL=sankey-chart.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"sankey-chart.cjs","names":["SectionTitle","Sankey","Group","NumberFlow"],"sources":["../../src/components/sankey-chart.tsx"],"sourcesContent":["import { Group } from '@visx/group'\nimport {\n Sankey,\n sankeyJustify,\n type SankeyLink,\n type SankeyNode,\n} from '@visx/sankey'\nimport { useEffect, useMemo, useRef, useState } from 'react'\nimport { cn } from '../utils/cn'\nimport NumberFlow, { type Format } from './number-flow'\nimport { SectionTitle } from './typography'\n\nexport interface SankeyChartNode {\n id: string\n label: string\n /** Optional category — used to colour the node and any outgoing links. */\n category?: string\n /** Override the colour resolved from `category`. */\n color?: string\n}\n\nexport interface SankeyChartLink {\n source: string\n target: string\n value: number\n /** Override the colour of the link. Defaults to the source node colour. */\n color?: string\n}\n\nexport interface SankeyChartProps {\n nodes: SankeyChartNode[]\n links: SankeyChartLink[]\n /** Resolves a category to a colour. */\n categoryColors?: Record<string, string>\n /** Fallback colour for nodes/links without a category. */\n defaultColor?: string\n /** Suffix appended to each animated value label (e.g. \" W\"). */\n valueSuffix?: string\n /** NumberFlow `format` for value labels. */\n valueFormat?: Format\n height?: number\n nodeWidth?: number\n nodePadding?: number\n /** Reserved horizontal space on the right for labels. */\n labelPadding?: number\n /**\n * Node ids kept at their natural (computed) column instead of being pushed to\n * the last column. By default `sankeyJustify` sends every node with no\n * outgoing link to the right edge; use this to hold a terminal node (e.g. grid\n * feed-in) in a middle column alongside its siblings.\n */\n keepAtDepthIds?: readonly string[]\n title?: string\n className?: string\n}\n\ntype SankeyDatumNode = SankeyChartNode & {\n /** Computed by d3-sankey; present after layout. */\n}\n\ntype SankeyDatumLink = SankeyChartLink\n\nconst DEFAULT_HEIGHT = 260\nconst DEFAULT_NODE_WIDTH = 12\nconst DEFAULT_NODE_PADDING = 10\nconst DEFAULT_LABEL_PADDING = 96\nconst LEFT_INSET = 4\nconst TOP_INSET = 8\nconst LABEL_GAP = 8\nconst LABEL_STACK_HEIGHT = 26\nconst DEFAULT_COLOR = 'var(--neutral-a9)'\n\nfunction resolveNodeColor(\n node: SankeyChartNode,\n categoryColors: Record<string, string> | undefined,\n defaultColor: string,\n) {\n if (node.color) return node.color\n if (node.category && categoryColors?.[node.category]) {\n return categoryColors[node.category] as string\n }\n return defaultColor\n}\n\nfunction SankeyChart({\n nodes,\n links,\n categoryColors,\n defaultColor = DEFAULT_COLOR,\n valueSuffix,\n valueFormat,\n height = DEFAULT_HEIGHT,\n nodeWidth = DEFAULT_NODE_WIDTH,\n nodePadding = DEFAULT_NODE_PADDING,\n labelPadding = DEFAULT_LABEL_PADDING,\n keepAtDepthIds,\n title,\n className,\n}: SankeyChartProps): React.ReactElement {\n const containerRef = useRef<HTMLDivElement>(null)\n const [width, setWidth] = useState(0)\n\n useEffect(() => {\n const element = containerRef.current\n if (!element) return\n\n const resizeObserver = new ResizeObserver((entries) => {\n const entry = entries[0]\n if (!entry) return\n setWidth(entry.contentRect.width)\n })\n\n resizeObserver.observe(element)\n return () => resizeObserver.disconnect()\n }, [])\n\n const nodeIds = useMemo(() => new Set(nodes.map((node) => node.id)), [nodes])\n\n // Drop zero-value links and any whose endpoints aren't in the current node\n // set (a stale link referencing a removed node makes d3-sankey throw\n // `missing: <id>`).\n const visibleLinks = useMemo(\n () =>\n links.filter(\n (link) =>\n link.value > 0 &&\n nodeIds.has(link.source) &&\n nodeIds.has(link.target),\n ),\n [links, nodeIds],\n )\n\n const visibleNodes = useMemo(() => {\n const referencedIds = new Set<string>()\n for (const link of visibleLinks) {\n referencedIds.add(link.source)\n referencedIds.add(link.target)\n }\n return nodes.filter((node) => referencedIds.has(node.id))\n }, [nodes, visibleLinks])\n\n const colorById = useMemo(() => {\n const map = new Map<string, string>()\n for (const node of nodes) {\n map.set(node.id, resolveNodeColor(node, categoryColors, defaultColor))\n }\n return map\n }, [categoryColors, defaultColor, nodes])\n\n const orderById = useMemo(() => {\n const map = new Map<string, number>()\n visibleNodes.forEach((node, index) => map.set(node.id, index))\n return map\n }, [visibleNodes])\n\n const nodeSort = useMemo(\n () =>\n (\n a: SankeyNode<SankeyDatumNode, SankeyDatumLink>,\n b: SankeyNode<SankeyDatumNode, SankeyDatumLink>,\n ) =>\n (orderById.get(a.id) ?? 0) - (orderById.get(b.id) ?? 0),\n [orderById],\n )\n\n const graph = useMemo(\n () => ({\n nodes: visibleNodes.map((node) => ({ ...node })),\n links: visibleLinks.map((link) => ({ ...link })),\n }),\n [visibleNodes, visibleLinks],\n )\n\n const nodeAlign = useMemo(() => {\n const keep = new Set(keepAtDepthIds)\n return (node: SankeyNode<SankeyDatumNode, SankeyDatumLink>, n: number) =>\n keep.has(node.id) ? (node.depth ?? 0) : sankeyJustify(node, n)\n }, [keepAtDepthIds])\n\n const innerWidth = Math.max(0, width - labelPadding - LEFT_INSET)\n const innerHeight = Math.max(0, height - TOP_INSET * 2)\n const halfLabelStack = LABEL_STACK_HEIGHT / 2\n const labelWidth = Math.max(40, labelPadding - LABEL_GAP - 4)\n\n return (\n <div className={cn('flex w-full flex-col gap-2 py-2', className)}>\n {title && <SectionTitle>{title}</SectionTitle>}\n\n <div ref={containerRef} className=\"relative w-full\" style={{ height }}>\n {width > 0 && innerWidth > 0 && (\n <Sankey<SankeyDatumNode, SankeyDatumLink>\n root={graph}\n size={[innerWidth, innerHeight]}\n nodeWidth={nodeWidth}\n nodePadding={nodePadding}\n nodeAlign={nodeAlign}\n nodeId={(node) => node.id}\n nodeSort={nodeSort}\n >\n {({ graph: laidOut, createPath }) => (\n <>\n <svg\n aria-hidden=\"true\"\n className=\"block\"\n height={height}\n width={width}\n >\n <Group left={LEFT_INSET} top={TOP_INSET}>\n <Group className=\"visx-sankey-links\">\n {laidOut.links.map((link, index) => {\n const sourceId =\n typeof link.source === 'object'\n ? (\n link.source as SankeyNode<\n SankeyDatumNode,\n SankeyDatumLink\n >\n ).id\n : String(link.source)\n const stroke =\n link.color ?? colorById.get(sourceId) ?? defaultColor\n\n return (\n <path\n key={`sankey-link-${index}`}\n d={createPath(link) ?? ''}\n fill=\"none\"\n stroke={stroke}\n strokeOpacity={0.32}\n strokeWidth={Math.max(1, link.width ?? 0)}\n />\n )\n })}\n </Group>\n\n <Group className=\"visx-sankey-nodes\">\n {laidOut.nodes.map((node, index) => {\n if (\n node.x0 === undefined ||\n node.x1 === undefined ||\n node.y0 === undefined ||\n node.y1 === undefined\n ) {\n return null\n }\n\n const w = node.x1 - node.x0\n const h = node.y1 - node.y0\n const fill = colorById.get(node.id) ?? defaultColor\n\n return (\n <rect\n key={`sankey-node-${index}`}\n x={node.x0}\n y={node.y0}\n width={w}\n height={Math.max(1, h)}\n fill={fill}\n rx={2}\n />\n )\n })}\n </Group>\n </Group>\n </svg>\n\n <div className=\"pointer-events-none absolute inset-0 [-webkit-text-size-adjust:100%] [text-size-adjust:100%]\">\n {laidOut.nodes.map((node, index) => {\n if (\n node.x0 === undefined ||\n node.x1 === undefined ||\n node.y0 === undefined ||\n node.y1 === undefined\n ) {\n return null\n }\n\n const h = node.y1 - node.y0\n const nodeCenterY = TOP_INSET + node.y0 + h / 2\n const labelCenterY = Math.min(\n Math.max(nodeCenterY, halfLabelStack),\n height - halfLabelStack,\n )\n\n return (\n <div\n key={`sankey-label-${node.id ?? index}`}\n className=\"absolute flex -translate-y-1/2 flex-col items-start gap-1\"\n style={{\n left: LEFT_INSET + node.x1 + LABEL_GAP,\n top: labelCenterY,\n width: labelWidth,\n }}\n >\n <span className=\"text-[11px] leading-none font-semibold whitespace-nowrap text-gray\">\n {node.label}\n </span>\n <NumberFlow\n value={node.value ?? 0}\n {...(valueSuffix !== undefined && {\n suffix: valueSuffix,\n })}\n {...(valueFormat !== undefined && {\n format: valueFormat,\n })}\n className=\"block min-h-[10px] text-[10px] leading-none text-gray-light tabular-nums\"\n />\n </div>\n )\n })}\n </div>\n </>\n )}\n </Sankey>\n )}\n </div>\n </div>\n )\n}\n\nexport type { SankeyLink, SankeyNode }\nexport { SankeyChart }\n"],"mappings":";;;;;;;;;;AA8DA,MAAM,iBAAiB;AACvB,MAAM,qBAAqB;AAC3B,MAAM,uBAAuB;AAC7B,MAAM,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","names":["SectionTitle","Sankey","Group","NumberFlow"],"sources":["../../src/components/sankey-chart.tsx"],"sourcesContent":["import { Group } from '@visx/group'\nimport {\n Sankey,\n sankeyJustify,\n type SankeyLink,\n type SankeyNode,\n} from '@visx/sankey'\nimport { useEffect, useMemo, useRef, useState } from 'react'\nimport { cn } from '../utils/cn'\nimport NumberFlow, { type Format } from './number-flow'\nimport { SectionTitle } from './typography'\n\nconst SANKEY_CATEGORY_COLORS: Record<string, string> = {\n solar: 'var(--orange-a9)',\n battery: 'var(--green-a9)',\n grid: 'var(--blue-9)',\n gridFeedIn: 'var(--blue-7)',\n home: 'var(--spark-9)',\n floor: 'var(--neutral-a9)',\n device: 'var(--neutral-a8)',\n}\n\nexport interface SankeyChartNode {\n id: string\n label: string\n /** Optional category — used to colour the node and any outgoing links. */\n category?: string\n /** Override the colour resolved from `category`. */\n color?: string\n}\n\nexport interface SankeyChartLink {\n source: string\n target: string\n value: number\n /** Override the colour of the link. Defaults to the source node colour. */\n color?: string\n}\n\nexport interface SankeyChartProps {\n nodes: SankeyChartNode[]\n links: SankeyChartLink[]\n /** Resolves a category to a colour. */\n categoryColors?: Record<string, string>\n /** Fallback colour for nodes/links without a category. */\n defaultColor?: string\n /** Suffix appended to each animated value label (e.g. \" W\"). */\n valueSuffix?: string\n /** NumberFlow `format` for value labels. */\n valueFormat?: Format\n height?: number\n nodeWidth?: number\n nodePadding?: number\n /** Reserved horizontal space on the right for labels. */\n labelPadding?: number\n /**\n * Node ids kept at their natural (computed) column instead of being pushed to\n * the last column. By default `sankeyJustify` sends every node with no\n * outgoing link to the right edge; use this to hold a terminal node (e.g. grid\n * feed-in) in a middle column alongside its siblings.\n */\n keepAtDepthIds?: readonly string[]\n title?: string\n className?: string\n}\n\ntype SankeyDatumNode = SankeyChartNode & {\n /** Computed by d3-sankey; present after layout. */\n}\n\ntype SankeyDatumLink = SankeyChartLink\n\nconst DEFAULT_HEIGHT = 260\nconst DEFAULT_NODE_WIDTH = 12\nconst DEFAULT_NODE_PADDING = 10\nconst DEFAULT_LABEL_PADDING = 96\nconst LEFT_INSET = 4\nconst TOP_INSET = 8\nconst LABEL_GAP = 8\nconst LABEL_STACK_HEIGHT = 26\nconst DEFAULT_COLOR = 'var(--neutral-a9)'\n\nfunction resolveNodeColor(\n node: SankeyChartNode,\n categoryColors: Record<string, string> | undefined,\n defaultColor: string,\n) {\n if (node.color) return node.color\n if (node.category && categoryColors?.[node.category]) {\n return categoryColors[node.category] as string\n }\n return defaultColor\n}\n\nfunction SankeyChart({\n nodes,\n links,\n categoryColors = SANKEY_CATEGORY_COLORS,\n defaultColor = DEFAULT_COLOR,\n valueSuffix,\n valueFormat,\n height = DEFAULT_HEIGHT,\n nodeWidth = DEFAULT_NODE_WIDTH,\n nodePadding = DEFAULT_NODE_PADDING,\n labelPadding = DEFAULT_LABEL_PADDING,\n keepAtDepthIds,\n title,\n className,\n}: SankeyChartProps): React.ReactElement {\n const containerRef = useRef<HTMLDivElement>(null)\n const [width, setWidth] = useState(0)\n\n useEffect(() => {\n const element = containerRef.current\n if (!element) return\n\n const resizeObserver = new ResizeObserver((entries) => {\n const entry = entries[0]\n if (!entry) return\n setWidth(entry.contentRect.width)\n })\n\n resizeObserver.observe(element)\n return () => resizeObserver.disconnect()\n }, [])\n\n const nodeIds = useMemo(() => new Set(nodes.map((node) => node.id)), [nodes])\n\n // Drop zero-value links and any whose endpoints aren't in the current node\n // set (a stale link referencing a removed node makes d3-sankey throw\n // `missing: <id>`).\n const visibleLinks = useMemo(\n () =>\n links.filter(\n (link) =>\n link.value > 0 &&\n nodeIds.has(link.source) &&\n nodeIds.has(link.target),\n ),\n [links, nodeIds],\n )\n\n const visibleNodes = useMemo(() => {\n const referencedIds = new Set<string>()\n for (const link of visibleLinks) {\n referencedIds.add(link.source)\n referencedIds.add(link.target)\n }\n return nodes.filter((node) => referencedIds.has(node.id))\n }, [nodes, visibleLinks])\n\n const colorById = useMemo(() => {\n const map = new Map<string, string>()\n for (const node of nodes) {\n map.set(node.id, resolveNodeColor(node, categoryColors, defaultColor))\n }\n return map\n }, [categoryColors, defaultColor, nodes])\n\n const orderById = useMemo(() => {\n const map = new Map<string, number>()\n visibleNodes.forEach((node, index) => map.set(node.id, index))\n return map\n }, [visibleNodes])\n\n const nodeSort = useMemo(\n () =>\n (\n a: SankeyNode<SankeyDatumNode, SankeyDatumLink>,\n b: SankeyNode<SankeyDatumNode, SankeyDatumLink>,\n ) =>\n (orderById.get(a.id) ?? 0) - (orderById.get(b.id) ?? 0),\n [orderById],\n )\n\n const graph = useMemo(\n () => ({\n nodes: visibleNodes.map((node) => ({ ...node })),\n links: visibleLinks.map((link) => ({ ...link })),\n }),\n [visibleNodes, visibleLinks],\n )\n\n const nodeAlign = useMemo(() => {\n const keep = new Set(keepAtDepthIds)\n return (node: SankeyNode<SankeyDatumNode, SankeyDatumLink>, n: number) =>\n keep.has(node.id) ? (node.depth ?? 0) : sankeyJustify(node, n)\n }, [keepAtDepthIds])\n\n const innerWidth = Math.max(0, width - labelPadding - LEFT_INSET)\n const innerHeight = Math.max(0, height - TOP_INSET * 2)\n const halfLabelStack = LABEL_STACK_HEIGHT / 2\n const labelWidth = Math.max(40, labelPadding - LABEL_GAP - 4)\n\n return (\n <div className={cn('flex w-full flex-col gap-2 py-2', className)}>\n {title && <SectionTitle>{title}</SectionTitle>}\n\n <div ref={containerRef} className=\"relative w-full\" style={{ height }}>\n {width > 0 && innerWidth > 0 && (\n <Sankey<SankeyDatumNode, SankeyDatumLink>\n root={graph}\n size={[innerWidth, innerHeight]}\n nodeWidth={nodeWidth}\n nodePadding={nodePadding}\n nodeAlign={nodeAlign}\n nodeId={(node) => node.id}\n nodeSort={nodeSort}\n >\n {({ graph: laidOut, createPath }) => (\n <>\n <svg\n aria-hidden=\"true\"\n className=\"block\"\n height={height}\n width={width}\n >\n <Group left={LEFT_INSET} top={TOP_INSET}>\n <Group className=\"visx-sankey-links\">\n {laidOut.links.map((link, index) => {\n const sourceId =\n typeof link.source === 'object'\n ? (\n link.source as SankeyNode<\n SankeyDatumNode,\n SankeyDatumLink\n >\n ).id\n : String(link.source)\n const stroke =\n link.color ?? colorById.get(sourceId) ?? defaultColor\n\n return (\n <path\n key={`sankey-link-${index}`}\n d={createPath(link) ?? ''}\n fill=\"none\"\n stroke={stroke}\n strokeOpacity={0.32}\n strokeWidth={Math.max(1, link.width ?? 0)}\n />\n )\n })}\n </Group>\n\n <Group className=\"visx-sankey-nodes\">\n {laidOut.nodes.map((node, index) => {\n if (\n node.x0 === undefined ||\n node.x1 === undefined ||\n node.y0 === undefined ||\n node.y1 === undefined\n ) {\n return null\n }\n\n const w = node.x1 - node.x0\n const h = node.y1 - node.y0\n const fill = colorById.get(node.id) ?? defaultColor\n\n return (\n <rect\n key={`sankey-node-${index}`}\n x={node.x0}\n y={node.y0}\n width={w}\n height={Math.max(1, h)}\n fill={fill}\n rx={2}\n />\n )\n })}\n </Group>\n </Group>\n </svg>\n\n <div className=\"pointer-events-none absolute inset-0 [-webkit-text-size-adjust:100%] [text-size-adjust:100%]\">\n {laidOut.nodes.map((node, index) => {\n if (\n node.x0 === undefined ||\n node.x1 === undefined ||\n node.y0 === undefined ||\n node.y1 === undefined\n ) {\n return null\n }\n\n const h = node.y1 - node.y0\n const nodeCenterY = TOP_INSET + node.y0 + h / 2\n const labelCenterY = Math.min(\n Math.max(nodeCenterY, halfLabelStack),\n height - halfLabelStack,\n )\n\n return (\n <div\n key={`sankey-label-${node.id ?? index}`}\n className=\"absolute flex -translate-y-1/2 flex-col items-start gap-1\"\n style={{\n left: LEFT_INSET + node.x1 + LABEL_GAP,\n top: labelCenterY,\n width: labelWidth,\n }}\n >\n <span className=\"text-[11px] leading-none font-semibold whitespace-nowrap text-gray\">\n {node.label}\n </span>\n <NumberFlow\n value={node.value ?? 0}\n {...(valueSuffix !== undefined && {\n suffix: valueSuffix,\n })}\n {...(valueFormat !== undefined && {\n format: valueFormat,\n })}\n className=\"block min-h-[10px] text-[10px] leading-none text-gray-light tabular-nums\"\n />\n </div>\n )\n })}\n </div>\n </>\n )}\n </Sankey>\n )}\n </div>\n </div>\n )\n}\n\nexport type { SankeyLink, SankeyNode }\nexport { SankeyChart, SANKEY_CATEGORY_COLORS }\n"],"mappings":";;;;;;;;;;AAYA,MAAM,yBAAiD;CACrD,OAAO;CACP,SAAS;CACT,MAAM;CACN,YAAY;CACZ,MAAM;CACN,OAAO;CACP,QAAQ;AACV;AAoDA,MAAM,iBAAiB;AACvB,MAAM,qBAAqB;AAC3B,MAAM,uBAAuB;AAC7B,MAAM,wBAAwB;AAC9B,MAAM,aAAa;AACnB,MAAM,YAAY;AAClB,MAAM,YAAY;AAClB,MAAM,qBAAqB;AAC3B,MAAM,gBAAgB;AAEtB,SAAS,iBACP,MACA,gBACA,cACA;CACA,IAAI,KAAK,OAAO,OAAO,KAAK;CAC5B,IAAI,KAAK,YAAY,iBAAiB,KAAK,WACzC,OAAO,eAAe,KAAK;CAE7B,OAAO;AACT;AAEA,SAAS,YAAY,EACnB,OACA,OACA,iBAAiB,wBACjB,eAAe,eACf,aACA,aACA,SAAS,gBACT,YAAY,oBACZ,cAAc,sBACd,eAAe,uBACf,gBACA,OACA,aACuC;CACvC,MAAM,gBAAA,GAAA,MAAA,QAAsC,IAAI;CAChD,MAAM,CAAC,OAAO,aAAA,GAAA,MAAA,UAAqB,CAAC;CAEpC,CAAA,GAAA,MAAA,iBAAgB;EACd,MAAM,UAAU,aAAa;EAC7B,IAAI,CAAC,SAAS;EAEd,MAAM,iBAAiB,IAAI,gBAAgB,YAAY;GACrD,MAAM,QAAQ,QAAQ;GACtB,IAAI,CAAC,OAAO;GACZ,SAAS,MAAM,YAAY,KAAK;EAClC,CAAC;EAED,eAAe,QAAQ,OAAO;EAC9B,aAAa,eAAe,WAAW;CACzC,GAAG,CAAC,CAAC;CAEL,MAAM,WAAA,GAAA,MAAA,eAAwB,IAAI,IAAI,MAAM,KAAK,SAAS,KAAK,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC;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kBACb,KAAK;OACF,CAAA,GACN,iBAAA,GAAA,kBAAA,KAACC,gCAAD;QACE,OAAO,KAAK,SAAS;QACrB,GAAK,gBAAgB,KAAA,KAAa,EAChC,QAAQ,YACV;QACA,GAAK,gBAAgB,KAAA,KAAa,EAChC,QAAQ,YACV;QACA,WAAU;OACX,CAAA,CACE;SArBE,gBAAgB,KAAK,MAAM,OAqB7B;KAET,CAAC;IACE,CAAA,CACL,EAAA,CAAA;GAEE,CAAA;EAEP,CAAA,CACF;;AAET"}
@@ -1,9 +1,10 @@
1
1
  "use client";
2
2
 
3
- import { Format } from "./number-flow.cjs";
3
+ import { t as Format } from "../number-flow-Bch81ixZ.cjs";
4
4
  import { SankeyLink, SankeyNode } from "@visx/sankey";
5
5
 
6
6
  //#region src/components/sankey-chart.d.ts
7
+ declare const SANKEY_CATEGORY_COLORS: Record<string, string>;
7
8
  interface SankeyChartNode {
8
9
  id: string;
9
10
  label: string;
@@ -61,5 +62,5 @@ declare function SankeyChart({
61
62
  className
62
63
  }: SankeyChartProps): React.ReactElement;
63
64
  //#endregion
64
- export { SankeyChart, SankeyChartLink, SankeyChartNode, SankeyChartProps, type SankeyLink, type SankeyNode };
65
+ export { SANKEY_CATEGORY_COLORS, SankeyChart, SankeyChartLink, SankeyChartNode, SankeyChartProps, type SankeyLink, type SankeyNode };
65
66
  //# sourceMappingURL=sankey-chart.d.cts.map
@@ -1,9 +1,10 @@
1
1
  "use client";
2
2
 
3
- import { Format } from "./number-flow.js";
3
+ import { t as Format } from "../number-flow-Bch81ixZ.js";
4
4
  import { SankeyLink, SankeyNode } from "@visx/sankey";
5
5
 
6
6
  //#region src/components/sankey-chart.d.ts
7
+ declare const SANKEY_CATEGORY_COLORS: Record<string, string>;
7
8
  interface SankeyChartNode {
8
9
  id: string;
9
10
  label: string;
@@ -61,5 +62,5 @@ declare function SankeyChart({
61
62
  className
62
63
  }: SankeyChartProps): React.ReactElement;
63
64
  //#endregion
64
- export { SankeyChart, SankeyChartLink, SankeyChartNode, SankeyChartProps, type SankeyLink, type SankeyNode };
65
+ export { SANKEY_CATEGORY_COLORS, SankeyChart, SankeyChartLink, SankeyChartNode, SankeyChartProps, type SankeyLink, type SankeyNode };
65
66
  //# sourceMappingURL=sankey-chart.d.ts.map
@@ -7,6 +7,15 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
7
  import { Group } from "@visx/group";
8
8
  import { Sankey, sankeyJustify } from "@visx/sankey";
9
9
  //#region src/components/sankey-chart.tsx
10
+ const SANKEY_CATEGORY_COLORS = {
11
+ solar: "var(--orange-a9)",
12
+ battery: "var(--green-a9)",
13
+ grid: "var(--blue-9)",
14
+ gridFeedIn: "var(--blue-7)",
15
+ home: "var(--spark-9)",
16
+ floor: "var(--neutral-a9)",
17
+ device: "var(--neutral-a8)"
18
+ };
10
19
  const DEFAULT_HEIGHT = 260;
11
20
  const DEFAULT_NODE_WIDTH = 12;
12
21
  const DEFAULT_NODE_PADDING = 10;
@@ -21,7 +30,7 @@ function resolveNodeColor(node, categoryColors, defaultColor) {
21
30
  if (node.category && categoryColors?.[node.category]) return categoryColors[node.category];
22
31
  return defaultColor;
23
32
  }
24
- function SankeyChart({ nodes, links, categoryColors, defaultColor = DEFAULT_COLOR, valueSuffix, valueFormat, height = DEFAULT_HEIGHT, nodeWidth = DEFAULT_NODE_WIDTH, nodePadding = DEFAULT_NODE_PADDING, labelPadding = DEFAULT_LABEL_PADDING, keepAtDepthIds, title, className }) {
33
+ function SankeyChart({ nodes, links, categoryColors = SANKEY_CATEGORY_COLORS, defaultColor = DEFAULT_COLOR, valueSuffix, valueFormat, height = DEFAULT_HEIGHT, nodeWidth = DEFAULT_NODE_WIDTH, nodePadding = DEFAULT_NODE_PADDING, labelPadding = DEFAULT_LABEL_PADDING, keepAtDepthIds, title, className }) {
25
34
  const containerRef = useRef(null);
26
35
  const [width, setWidth] = useState(0);
27
36
  useEffect(() => {
@@ -156,6 +165,6 @@ function SankeyChart({ nodes, links, categoryColors, defaultColor = DEFAULT_COLO
156
165
  });
157
166
  }
158
167
  //#endregion
159
- export { SankeyChart };
168
+ export { SANKEY_CATEGORY_COLORS, SankeyChart };
160
169
 
161
170
  //# sourceMappingURL=sankey-chart.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sankey-chart.js","names":[],"sources":["../../src/components/sankey-chart.tsx"],"sourcesContent":["import { Group } from '@visx/group'\nimport {\n Sankey,\n sankeyJustify,\n type SankeyLink,\n type SankeyNode,\n} from '@visx/sankey'\nimport { useEffect, useMemo, useRef, useState } from 'react'\nimport { cn } from '../utils/cn'\nimport NumberFlow, { type Format } from './number-flow'\nimport { SectionTitle } from './typography'\n\nexport interface SankeyChartNode {\n id: string\n label: string\n /** Optional category — used to colour the node and any outgoing links. */\n category?: string\n /** Override the colour resolved from `category`. */\n color?: string\n}\n\nexport interface SankeyChartLink {\n source: string\n target: string\n value: number\n /** Override the colour of the link. Defaults to the source node colour. */\n color?: string\n}\n\nexport interface SankeyChartProps {\n nodes: SankeyChartNode[]\n links: SankeyChartLink[]\n /** Resolves a category to a colour. */\n categoryColors?: Record<string, string>\n /** Fallback colour for nodes/links without a category. */\n defaultColor?: string\n /** Suffix appended to each animated value label (e.g. \" W\"). */\n valueSuffix?: string\n /** NumberFlow `format` for value labels. */\n valueFormat?: Format\n height?: number\n nodeWidth?: number\n nodePadding?: number\n /** Reserved horizontal space on the right for labels. */\n labelPadding?: number\n /**\n * Node ids kept at their natural (computed) column instead of being pushed to\n * the last column. By default `sankeyJustify` sends every node with no\n * outgoing link to the right edge; use this to hold a terminal node (e.g. grid\n * feed-in) in a middle column alongside its siblings.\n */\n keepAtDepthIds?: readonly string[]\n title?: string\n className?: string\n}\n\ntype SankeyDatumNode = SankeyChartNode & {\n /** Computed by d3-sankey; present after layout. */\n}\n\ntype SankeyDatumLink = SankeyChartLink\n\nconst DEFAULT_HEIGHT = 260\nconst DEFAULT_NODE_WIDTH = 12\nconst DEFAULT_NODE_PADDING = 10\nconst DEFAULT_LABEL_PADDING = 96\nconst LEFT_INSET = 4\nconst TOP_INSET = 8\nconst LABEL_GAP = 8\nconst LABEL_STACK_HEIGHT = 26\nconst DEFAULT_COLOR = 'var(--neutral-a9)'\n\nfunction resolveNodeColor(\n node: SankeyChartNode,\n categoryColors: Record<string, string> | undefined,\n defaultColor: string,\n) {\n if (node.color) return node.color\n if (node.category && categoryColors?.[node.category]) {\n return categoryColors[node.category] as string\n }\n return defaultColor\n}\n\nfunction SankeyChart({\n nodes,\n links,\n categoryColors,\n defaultColor = DEFAULT_COLOR,\n valueSuffix,\n valueFormat,\n height = DEFAULT_HEIGHT,\n nodeWidth = DEFAULT_NODE_WIDTH,\n nodePadding = DEFAULT_NODE_PADDING,\n labelPadding = DEFAULT_LABEL_PADDING,\n keepAtDepthIds,\n title,\n className,\n}: SankeyChartProps): React.ReactElement {\n const containerRef = useRef<HTMLDivElement>(null)\n const [width, setWidth] = useState(0)\n\n useEffect(() => {\n const element = containerRef.current\n if (!element) return\n\n const resizeObserver = new ResizeObserver((entries) => {\n const entry = entries[0]\n if (!entry) return\n setWidth(entry.contentRect.width)\n })\n\n resizeObserver.observe(element)\n return () => resizeObserver.disconnect()\n }, [])\n\n const nodeIds = useMemo(() => new Set(nodes.map((node) => node.id)), [nodes])\n\n // Drop zero-value links and any whose endpoints aren't in the current node\n // set (a stale link referencing a removed node makes d3-sankey throw\n // `missing: <id>`).\n const visibleLinks = useMemo(\n () =>\n links.filter(\n (link) =>\n link.value > 0 &&\n nodeIds.has(link.source) &&\n nodeIds.has(link.target),\n ),\n [links, nodeIds],\n )\n\n const visibleNodes = useMemo(() => {\n const referencedIds = new Set<string>()\n for (const link of visibleLinks) {\n referencedIds.add(link.source)\n referencedIds.add(link.target)\n }\n return nodes.filter((node) => referencedIds.has(node.id))\n }, [nodes, visibleLinks])\n\n const colorById = useMemo(() => {\n const map = new Map<string, string>()\n for (const node of nodes) {\n map.set(node.id, resolveNodeColor(node, categoryColors, defaultColor))\n }\n return map\n }, [categoryColors, defaultColor, nodes])\n\n const orderById = useMemo(() => {\n const map = new Map<string, number>()\n visibleNodes.forEach((node, index) => map.set(node.id, index))\n return map\n }, [visibleNodes])\n\n const nodeSort = useMemo(\n () =>\n (\n a: SankeyNode<SankeyDatumNode, SankeyDatumLink>,\n b: SankeyNode<SankeyDatumNode, SankeyDatumLink>,\n ) =>\n (orderById.get(a.id) ?? 0) - (orderById.get(b.id) ?? 0),\n [orderById],\n )\n\n const graph = useMemo(\n () => ({\n nodes: visibleNodes.map((node) => ({ ...node })),\n links: visibleLinks.map((link) => ({ ...link })),\n }),\n [visibleNodes, visibleLinks],\n )\n\n const nodeAlign = useMemo(() => {\n const keep = new Set(keepAtDepthIds)\n return (node: SankeyNode<SankeyDatumNode, SankeyDatumLink>, n: number) =>\n keep.has(node.id) ? (node.depth ?? 0) : sankeyJustify(node, n)\n }, [keepAtDepthIds])\n\n const innerWidth = Math.max(0, width - labelPadding - LEFT_INSET)\n const innerHeight = Math.max(0, height - TOP_INSET * 2)\n const halfLabelStack = LABEL_STACK_HEIGHT / 2\n const labelWidth = Math.max(40, labelPadding - LABEL_GAP - 4)\n\n return (\n <div className={cn('flex w-full flex-col gap-2 py-2', className)}>\n {title && <SectionTitle>{title}</SectionTitle>}\n\n <div ref={containerRef} className=\"relative w-full\" style={{ height }}>\n {width > 0 && innerWidth > 0 && (\n <Sankey<SankeyDatumNode, SankeyDatumLink>\n root={graph}\n size={[innerWidth, innerHeight]}\n nodeWidth={nodeWidth}\n nodePadding={nodePadding}\n nodeAlign={nodeAlign}\n nodeId={(node) => node.id}\n nodeSort={nodeSort}\n >\n {({ graph: laidOut, createPath }) => (\n <>\n <svg\n aria-hidden=\"true\"\n className=\"block\"\n height={height}\n width={width}\n >\n <Group left={LEFT_INSET} top={TOP_INSET}>\n <Group className=\"visx-sankey-links\">\n {laidOut.links.map((link, index) => {\n const sourceId =\n typeof link.source === 'object'\n ? (\n link.source as SankeyNode<\n SankeyDatumNode,\n SankeyDatumLink\n >\n ).id\n : String(link.source)\n const stroke =\n link.color ?? colorById.get(sourceId) ?? defaultColor\n\n return (\n <path\n key={`sankey-link-${index}`}\n d={createPath(link) ?? ''}\n fill=\"none\"\n stroke={stroke}\n strokeOpacity={0.32}\n strokeWidth={Math.max(1, link.width ?? 0)}\n />\n )\n })}\n </Group>\n\n <Group className=\"visx-sankey-nodes\">\n {laidOut.nodes.map((node, index) => {\n if (\n node.x0 === undefined ||\n node.x1 === undefined ||\n node.y0 === undefined ||\n node.y1 === undefined\n ) {\n return null\n }\n\n const w = node.x1 - node.x0\n const h = node.y1 - node.y0\n const fill = colorById.get(node.id) ?? defaultColor\n\n return (\n <rect\n key={`sankey-node-${index}`}\n x={node.x0}\n y={node.y0}\n width={w}\n height={Math.max(1, h)}\n fill={fill}\n rx={2}\n />\n )\n })}\n </Group>\n </Group>\n </svg>\n\n <div className=\"pointer-events-none absolute inset-0 [-webkit-text-size-adjust:100%] [text-size-adjust:100%]\">\n {laidOut.nodes.map((node, index) => {\n if (\n node.x0 === undefined ||\n node.x1 === undefined ||\n node.y0 === undefined ||\n node.y1 === undefined\n ) {\n return null\n }\n\n const h = node.y1 - node.y0\n const nodeCenterY = TOP_INSET + node.y0 + h / 2\n const labelCenterY = Math.min(\n Math.max(nodeCenterY, halfLabelStack),\n height - halfLabelStack,\n )\n\n return (\n <div\n key={`sankey-label-${node.id ?? index}`}\n className=\"absolute flex -translate-y-1/2 flex-col items-start gap-1\"\n style={{\n left: LEFT_INSET + node.x1 + LABEL_GAP,\n top: labelCenterY,\n width: labelWidth,\n }}\n >\n <span className=\"text-[11px] leading-none font-semibold whitespace-nowrap text-gray\">\n {node.label}\n </span>\n <NumberFlow\n value={node.value ?? 0}\n {...(valueSuffix !== undefined && {\n suffix: valueSuffix,\n })}\n {...(valueFormat !== undefined && {\n format: valueFormat,\n })}\n className=\"block min-h-[10px] text-[10px] leading-none text-gray-light tabular-nums\"\n />\n </div>\n )\n })}\n </div>\n </>\n )}\n </Sankey>\n )}\n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ACN,IAAI;QACL,GAPM,eAAe,OAOrB;OAEL,CAAC;MACI,CAAA,CACF;;IACJ,CAAA,GAEL,oBAAC,OAAD;KAAK,WAAU;eACZ,QAAQ,MAAM,KAAK,MAAM,UAAU;MAClC,IACE,KAAK,OAAO,KAAA,KACZ,KAAK,OAAO,KAAA,KACZ,KAAK,OAAO,KAAA,KACZ,KAAK,OAAO,KAAA,GAEZ,OAAO;MAGT,MAAM,IAAI,KAAK,KAAK,KAAK;MACzB,MAAM,cAAc,YAAY,KAAK,KAAK,IAAI;MAC9C,MAAM,eAAe,KAAK,IACxB,KAAK,IAAI,aAAa,cAAc,GACpC,SAAS,cACX;MAEA,OACE,qBAAC,OAAD;OAEE,WAAU;OACV,OAAO;QACL,MAAM,aAAa,KAAK,KAAK;QAC7B,KAAK;QACL,OAAO;OACT;iBAPF,CASE,oBAAC,QAAD;QAAM,WAAU;kBACb,KAAK;OACF,CAAA,GACN,oBAAC,YAAD;QACE,OAAO,KAAK,SAAS;QACrB,GAAK,gBAAgB,KAAA,KAAa,EAChC,QAAQ,YACV;QACA,GAAK,gBAAgB,KAAA,KAAa,EAChC,QAAQ,YACV;QACA,WAAU;OACX,CAAA,CACE;SArBE,gBAAgB,KAAK,MAAM,OAqB7B;KAET,CAAC;IACE,CAAA,CACL,EAAA,CAAA;GAEE,CAAA;EAEP,CAAA,CACF;;AAET"}
1
+ {"version":3,"file":"sankey-chart.js","names":[],"sources":["../../src/components/sankey-chart.tsx"],"sourcesContent":["import { Group } from '@visx/group'\nimport {\n Sankey,\n sankeyJustify,\n type SankeyLink,\n type SankeyNode,\n} from '@visx/sankey'\nimport { useEffect, useMemo, useRef, useState } from 'react'\nimport { cn } from '../utils/cn'\nimport NumberFlow, { type Format } from './number-flow'\nimport { SectionTitle } from './typography'\n\nconst SANKEY_CATEGORY_COLORS: Record<string, string> = {\n solar: 'var(--orange-a9)',\n battery: 'var(--green-a9)',\n grid: 'var(--blue-9)',\n gridFeedIn: 'var(--blue-7)',\n home: 'var(--spark-9)',\n floor: 'var(--neutral-a9)',\n device: 'var(--neutral-a8)',\n}\n\nexport interface SankeyChartNode {\n id: string\n label: string\n /** Optional category — used to colour the node and any outgoing links. */\n category?: string\n /** Override the colour resolved from `category`. */\n color?: string\n}\n\nexport interface SankeyChartLink {\n source: string\n target: string\n value: number\n /** Override the colour of the link. Defaults to the source node colour. */\n color?: string\n}\n\nexport interface SankeyChartProps {\n nodes: SankeyChartNode[]\n links: SankeyChartLink[]\n /** Resolves a category to a colour. */\n categoryColors?: Record<string, string>\n /** Fallback colour for nodes/links without a category. */\n defaultColor?: string\n /** Suffix appended to each animated value label (e.g. \" W\"). */\n valueSuffix?: string\n /** NumberFlow `format` for value labels. */\n valueFormat?: Format\n height?: number\n nodeWidth?: number\n nodePadding?: number\n /** Reserved horizontal space on the right for labels. */\n labelPadding?: number\n /**\n * Node ids kept at their natural (computed) column instead of being pushed to\n * the last column. By default `sankeyJustify` sends every node with no\n * outgoing link to the right edge; use this to hold a terminal node (e.g. grid\n * feed-in) in a middle column alongside its siblings.\n */\n keepAtDepthIds?: readonly string[]\n title?: string\n className?: string\n}\n\ntype SankeyDatumNode = SankeyChartNode & {\n /** Computed by d3-sankey; present after layout. */\n}\n\ntype SankeyDatumLink = SankeyChartLink\n\nconst DEFAULT_HEIGHT = 260\nconst DEFAULT_NODE_WIDTH = 12\nconst DEFAULT_NODE_PADDING = 10\nconst DEFAULT_LABEL_PADDING = 96\nconst LEFT_INSET = 4\nconst TOP_INSET = 8\nconst LABEL_GAP = 8\nconst LABEL_STACK_HEIGHT = 26\nconst DEFAULT_COLOR = 'var(--neutral-a9)'\n\nfunction resolveNodeColor(\n node: SankeyChartNode,\n categoryColors: Record<string, string> | undefined,\n defaultColor: string,\n) {\n if (node.color) return node.color\n if (node.category && categoryColors?.[node.category]) {\n return categoryColors[node.category] as string\n }\n return defaultColor\n}\n\nfunction SankeyChart({\n nodes,\n links,\n categoryColors = SANKEY_CATEGORY_COLORS,\n defaultColor = DEFAULT_COLOR,\n valueSuffix,\n valueFormat,\n height = DEFAULT_HEIGHT,\n nodeWidth = DEFAULT_NODE_WIDTH,\n nodePadding = DEFAULT_NODE_PADDING,\n labelPadding = DEFAULT_LABEL_PADDING,\n keepAtDepthIds,\n title,\n className,\n}: SankeyChartProps): React.ReactElement {\n const containerRef = useRef<HTMLDivElement>(null)\n const [width, setWidth] = useState(0)\n\n useEffect(() => {\n const element = containerRef.current\n if (!element) return\n\n const resizeObserver = new ResizeObserver((entries) => {\n const entry = entries[0]\n if (!entry) return\n setWidth(entry.contentRect.width)\n })\n\n resizeObserver.observe(element)\n return () => resizeObserver.disconnect()\n }, [])\n\n const nodeIds = useMemo(() => new Set(nodes.map((node) => node.id)), [nodes])\n\n // Drop zero-value links and any whose endpoints aren't in the current node\n // set (a stale link referencing a removed node makes d3-sankey throw\n // `missing: <id>`).\n const visibleLinks = useMemo(\n () =>\n links.filter(\n (link) =>\n link.value > 0 &&\n nodeIds.has(link.source) &&\n nodeIds.has(link.target),\n ),\n [links, nodeIds],\n )\n\n const visibleNodes = useMemo(() => {\n const referencedIds = new Set<string>()\n for (const link of visibleLinks) {\n referencedIds.add(link.source)\n referencedIds.add(link.target)\n }\n return nodes.filter((node) => referencedIds.has(node.id))\n }, [nodes, visibleLinks])\n\n const colorById = useMemo(() => {\n const map = new Map<string, string>()\n for (const node of nodes) {\n map.set(node.id, resolveNodeColor(node, categoryColors, defaultColor))\n }\n return map\n }, [categoryColors, defaultColor, nodes])\n\n const orderById = useMemo(() => {\n const map = new Map<string, number>()\n visibleNodes.forEach((node, index) => map.set(node.id, index))\n return map\n }, [visibleNodes])\n\n const nodeSort = useMemo(\n () =>\n (\n a: SankeyNode<SankeyDatumNode, SankeyDatumLink>,\n b: SankeyNode<SankeyDatumNode, SankeyDatumLink>,\n ) =>\n (orderById.get(a.id) ?? 0) - (orderById.get(b.id) ?? 0),\n [orderById],\n )\n\n const graph = useMemo(\n () => ({\n nodes: visibleNodes.map((node) => ({ ...node })),\n links: visibleLinks.map((link) => ({ ...link })),\n }),\n [visibleNodes, visibleLinks],\n )\n\n const nodeAlign = useMemo(() => {\n const keep = new Set(keepAtDepthIds)\n return (node: SankeyNode<SankeyDatumNode, SankeyDatumLink>, n: number) =>\n keep.has(node.id) ? (node.depth ?? 0) : sankeyJustify(node, n)\n }, [keepAtDepthIds])\n\n const innerWidth = Math.max(0, width - labelPadding - LEFT_INSET)\n const innerHeight = Math.max(0, height - TOP_INSET * 2)\n const halfLabelStack = LABEL_STACK_HEIGHT / 2\n const labelWidth = Math.max(40, labelPadding - LABEL_GAP - 4)\n\n return (\n <div className={cn('flex w-full flex-col gap-2 py-2', className)}>\n {title && <SectionTitle>{title}</SectionTitle>}\n\n <div ref={containerRef} className=\"relative w-full\" style={{ height }}>\n {width > 0 && innerWidth > 0 && (\n <Sankey<SankeyDatumNode, SankeyDatumLink>\n root={graph}\n size={[innerWidth, innerHeight]}\n nodeWidth={nodeWidth}\n nodePadding={nodePadding}\n nodeAlign={nodeAlign}\n nodeId={(node) => node.id}\n nodeSort={nodeSort}\n >\n {({ graph: laidOut, createPath }) => (\n <>\n <svg\n aria-hidden=\"true\"\n className=\"block\"\n height={height}\n width={width}\n >\n <Group left={LEFT_INSET} top={TOP_INSET}>\n <Group className=\"visx-sankey-links\">\n {laidOut.links.map((link, index) => {\n const sourceId =\n typeof link.source === 'object'\n ? (\n link.source as SankeyNode<\n SankeyDatumNode,\n SankeyDatumLink\n >\n ).id\n : String(link.source)\n const stroke =\n link.color ?? colorById.get(sourceId) ?? defaultColor\n\n return (\n <path\n key={`sankey-link-${index}`}\n d={createPath(link) ?? ''}\n fill=\"none\"\n stroke={stroke}\n strokeOpacity={0.32}\n strokeWidth={Math.max(1, link.width ?? 0)}\n />\n )\n })}\n </Group>\n\n <Group className=\"visx-sankey-nodes\">\n {laidOut.nodes.map((node, index) => {\n if (\n node.x0 === undefined ||\n node.x1 === undefined ||\n node.y0 === undefined ||\n node.y1 === undefined\n ) {\n return null\n }\n\n const w = node.x1 - node.x0\n const h = node.y1 - node.y0\n const fill = colorById.get(node.id) ?? defaultColor\n\n return (\n <rect\n key={`sankey-node-${index}`}\n x={node.x0}\n y={node.y0}\n width={w}\n height={Math.max(1, h)}\n fill={fill}\n rx={2}\n />\n )\n })}\n </Group>\n </Group>\n </svg>\n\n <div className=\"pointer-events-none absolute inset-0 [-webkit-text-size-adjust:100%] [text-size-adjust:100%]\">\n {laidOut.nodes.map((node, index) => {\n if (\n node.x0 === undefined ||\n node.x1 === undefined ||\n node.y0 === undefined ||\n node.y1 === undefined\n ) {\n return null\n }\n\n const h = node.y1 - node.y0\n const nodeCenterY = TOP_INSET + node.y0 + h / 2\n const labelCenterY = Math.min(\n Math.max(nodeCenterY, halfLabelStack),\n height - halfLabelStack,\n )\n\n return (\n <div\n key={`sankey-label-${node.id ?? index}`}\n className=\"absolute flex -translate-y-1/2 flex-col items-start gap-1\"\n style={{\n left: LEFT_INSET + node.x1 + LABEL_GAP,\n top: labelCenterY,\n width: labelWidth,\n }}\n >\n <span className=\"text-[11px] leading-none font-semibold whitespace-nowrap text-gray\">\n {node.label}\n </span>\n <NumberFlow\n value={node.value ?? 0}\n {...(valueSuffix !== undefined && {\n suffix: valueSuffix,\n })}\n {...(valueFormat !== undefined && {\n format: valueFormat,\n })}\n className=\"block min-h-[10px] text-[10px] leading-none text-gray-light tabular-nums\"\n />\n </div>\n )\n })}\n </div>\n </>\n )}\n </Sankey>\n )}\n </div>\n </div>\n )\n}\n\nexport type { SankeyLink, SankeyNode }\nexport { SankeyChart, SANKEY_CATEGORY_COLORS }\n"],"mappings":";;;;;;;;;AAYA,MAAM,yBAAiD;CACrD,OAAO;CACP,SAAS;CACT,MAAM;CACN,YAAY;CACZ,MAAM;CACN,OAAO;CACP,QAAQ;AACV;AAoDA,MAAM,iBAAiB;AACvB,MAAM,qBAAqB;AAC3B,MAAM,uBAAuB;AAC7B,MAAM,wBAAwB;AAC9B,MAAM,aAAa;AACnB,MAAM,YA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,KAAA,KACZ,KAAK,OAAO,KAAA,KACZ,KAAK,OAAO,KAAA,GAEZ,OAAO;MAGT,MAAM,IAAI,KAAK,KAAK,KAAK;MACzB,MAAM,cAAc,YAAY,KAAK,KAAK,IAAI;MAC9C,MAAM,eAAe,KAAK,IACxB,KAAK,IAAI,aAAa,cAAc,GACpC,SAAS,cACX;MAEA,OACE,qBAAC,OAAD;OAEE,WAAU;OACV,OAAO;QACL,MAAM,aAAa,KAAK,KAAK;QAC7B,KAAK;QACL,OAAO;OACT;iBAPF,CASE,oBAAC,QAAD;QAAM,WAAU;kBACb,KAAK;OACF,CAAA,GACN,oBAAC,YAAD;QACE,OAAO,KAAK,SAAS;QACrB,GAAK,gBAAgB,KAAA,KAAa,EAChC,QAAQ,YACV;QACA,GAAK,gBAAgB,KAAA,KAAa,EAChC,QAAQ,YACV;QACA,WAAU;OACX,CAAA,CACE;SArBE,gBAAgB,KAAK,MAAM,OAqB7B;KAET,CAAC;IACE,CAAA,CACL,EAAA,CAAA;GAEE,CAAA;EAEP,CAAA,CACF;;AAET"}
@@ -4,35 +4,35 @@ const require_chunk = require("../chunk-DY84GLCh.cjs");
4
4
  let react = require("react");
5
5
  react = require_chunk.__toESM(react);
6
6
  let react_jsx_runtime = require("react/jsx-runtime");
7
- let cnfast = require("cnfast");
7
+ let cn = require("cn");
8
8
  //#region src/components/schedule-editor.tsx
9
9
  const ScheduleEditor = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
10
10
  ref,
11
- className: (0, cnfast.cn)("flex flex-col gap-4 px-2", className),
11
+ className: (0, cn.cn)("flex flex-col gap-4 px-2", className),
12
12
  ...props
13
13
  }));
14
14
  ScheduleEditor.displayName = "ScheduleEditor";
15
15
  const ScheduleEditorHeader = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("header", {
16
16
  ref,
17
- className: (0, cnfast.cn)("flex flex-col gap-1", className),
17
+ className: (0, cn.cn)("flex flex-col gap-1", className),
18
18
  ...props
19
19
  }));
20
20
  ScheduleEditorHeader.displayName = "ScheduleEditorHeader";
21
21
  const ScheduleEditorTitle = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
22
22
  ref,
23
- className: (0, cnfast.cn)("text-base font-bold text-gray", className),
23
+ className: (0, cn.cn)("text-base font-bold text-gray", className),
24
24
  ...props
25
25
  }));
26
26
  ScheduleEditorTitle.displayName = "ScheduleEditorTitle";
27
27
  const ScheduleEditorDescription = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
28
28
  ref,
29
- className: (0, cnfast.cn)("text-sm leading-5 text-gray-light", className),
29
+ className: (0, cn.cn)("text-sm leading-5 text-gray-light", className),
30
30
  ...props
31
31
  }));
32
32
  ScheduleEditorDescription.displayName = "ScheduleEditorDescription";
33
33
  const ScheduleEditorBody = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
34
34
  ref,
35
- className: (0, cnfast.cn)("flex flex-col gap-[calc(var(--spark-layout-gap)*4)]", className),
35
+ className: (0, cn.cn)("flex flex-col gap-[calc(var(--spark-layout-gap)*4)]", className),
36
36
  ...props
37
37
  }));
38
38
  ScheduleEditorBody.displayName = "ScheduleEditorBody";
@@ -41,20 +41,20 @@ ScheduleEditorBody.displayName = "ScheduleEditorBody";
41
41
  * pattern. Override with `className` if you need a different arrangement. */
42
42
  const ScheduleEditorFooter = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("footer", {
43
43
  ref,
44
- className: (0, cnfast.cn)("flex items-center justify-between gap-2 pt-2", className),
44
+ className: (0, cn.cn)("flex items-center justify-between gap-2 pt-2", className),
45
45
  ...props
46
46
  }));
47
47
  ScheduleEditorFooter.displayName = "ScheduleEditorFooter";
48
48
  /** Right-aligned cluster of footer actions (e.g. Cancel + Save). */
49
49
  const ScheduleEditorActions = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
50
50
  ref,
51
- className: (0, cnfast.cn)("ml-auto flex items-center gap-2", className),
51
+ className: (0, cn.cn)("ml-auto flex items-center gap-2", className),
52
52
  ...props
53
53
  }));
54
54
  ScheduleEditorActions.displayName = "ScheduleEditorActions";
55
55
  const ScheduleEditorField = react.forwardRef(({ children, className, hint, label, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
56
56
  ref,
57
- className: (0, cnfast.cn)("flex flex-col gap-1.5", className),
57
+ className: (0, cn.cn)("flex flex-col gap-1.5", className),
58
58
  ...props,
59
59
  children: [
60
60
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
@@ -1 +1 @@
1
- {"version":3,"file":"schedule-editor.cjs","names":["React"],"sources":["../../src/components/schedule-editor.tsx"],"sourcesContent":["import * as React from 'react'\nimport { cn } from '../utils/cn'\n\nconst ScheduleEditor = React.forwardRef<\n HTMLElement,\n React.HTMLAttributes<HTMLElement>\n>(({ className, ...props }, ref) => (\n <section\n ref={ref}\n className={cn('flex flex-col gap-4 px-2', className)}\n {...props}\n />\n))\n\nScheduleEditor.displayName = 'ScheduleEditor'\n\nconst ScheduleEditorHeader = React.forwardRef<\n HTMLElement,\n React.HTMLAttributes<HTMLElement>\n>(({ className, ...props }, ref) => (\n <header\n ref={ref}\n className={cn('flex flex-col gap-1', className)}\n {...props}\n />\n))\n\nScheduleEditorHeader.displayName = 'ScheduleEditorHeader'\n\nconst ScheduleEditorTitle = React.forwardRef<\n HTMLHeadingElement,\n React.HTMLAttributes<HTMLHeadingElement>\n>(({ className, ...props }, ref) => (\n <h3\n ref={ref}\n className={cn('text-base font-bold text-gray', className)}\n {...props}\n />\n))\n\nScheduleEditorTitle.displayName = 'ScheduleEditorTitle'\n\nconst ScheduleEditorDescription = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, ...props }, ref) => (\n <p\n ref={ref}\n className={cn('text-sm leading-5 text-gray-light', className)}\n {...props}\n />\n))\n\nScheduleEditorDescription.displayName = 'ScheduleEditorDescription'\n\nconst ScheduleEditorBody = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(\n 'flex flex-col gap-[calc(var(--spark-layout-gap)*4)]',\n className,\n )}\n {...props}\n />\n))\n\nScheduleEditorBody.displayName = 'ScheduleEditorBody'\n\n/** Footer slot. Default layout splits children into a `justify-between` row,\n * which matches the common \"destructive on the left, primary on the right\"\n * pattern. Override with `className` if you need a different arrangement. */\nconst ScheduleEditorFooter = React.forwardRef<\n HTMLElement,\n React.HTMLAttributes<HTMLElement>\n>(({ className, ...props }, ref) => (\n <footer\n ref={ref}\n className={cn('flex items-center justify-between gap-2 pt-2', className)}\n {...props}\n />\n))\n\nScheduleEditorFooter.displayName = 'ScheduleEditorFooter'\n\n/** Right-aligned cluster of footer actions (e.g. Cancel + Save). */\nconst ScheduleEditorActions = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn('ml-auto flex items-center gap-2', className)}\n {...props}\n />\n))\n\nScheduleEditorActions.displayName = 'ScheduleEditorActions'\n\ninterface ScheduleEditorFieldProps extends Omit<\n React.LabelHTMLAttributes<HTMLLabelElement>,\n 'children'\n> {\n label: React.ReactNode\n hint?: React.ReactNode\n children: React.ReactNode\n}\n\nconst ScheduleEditorField = React.forwardRef<\n HTMLLabelElement,\n ScheduleEditorFieldProps\n>(({ children, className, hint, label, ...props }, ref) => (\n <label\n ref={ref}\n className={cn('flex flex-col gap-1.5', className)}\n {...props}\n >\n <span className=\"text-sm font-medium text-gray\">{label}</span>\n {children}\n {hint && <span className=\"text-xs text-gray-light\">{hint}</span>}\n </label>\n))\n\nScheduleEditorField.displayName = 'ScheduleEditorField'\n\nexport {\n ScheduleEditor,\n ScheduleEditorActions,\n ScheduleEditorBody,\n ScheduleEditorDescription,\n ScheduleEditorField,\n ScheduleEditorFooter,\n ScheduleEditorHeader,\n ScheduleEditorTitle,\n}\n"],"mappings":";;;;;;;;AAGA,MAAM,iBAAiBA,MAAM,YAG1B,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,KAAC,WAAD;CACO;CACL,YAAA,GAAA,OAAA,IAAc,4BAA4B,SAAS;CACnD,GAAI;AACL,CAAA,CACF;AAED,eAAe,cAAc;AAE7B,MAAM,uBAAuBA,MAAM,YAGhC,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,KAAC,UAAD;CACO;CACL,YAAA,GAAA,OAAA,IAAc,uBAAuB,SAAS;CAC9C,GAAI;AACL,CAAA,CACF;AAED,qBAAqB,cAAc;AAEnC,MAAM,sBAAsBA,MAAM,YAG/B,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,KAAC,MAAD;CACO;CACL,YAAA,GAAA,OAAA,IAAc,iCAAiC,SAAS;CACxD,GAAI;AACL,CAAA,CACF;AAED,oBAAoB,cAAc;AAElC,MAAM,4BAA4BA,MAAM,YAGrC,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,KAAC,KAAD;CACO;CACL,YAAA,GAAA,OAAA,IAAc,qCAAqC,SAAS;CAC5D,GAAI;AACL,CAAA,CACF;AAED,0BAA0B,cAAc;AAExC,MAAM,qBAAqBA,MAAM,YAG9B,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,KAAC,OAAD;CACO;CACL,YAAA,GAAA,OAAA,IACE,uDACA,SACF;CACA,GAAI;AACL,CAAA,CACF;AAED,mBAAmB,cAAc;;;;AAKjC,MAAM,uBAAuBA,MAAM,YAGhC,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,KAAC,UAAD;CACO;CACL,YAAA,GAAA,OAAA,IAAc,gDAAgD,SAAS;CACvE,GAAI;AACL,CAAA,CACF;AAED,qBAAqB,cAAc;;AAGnC,MAAM,wBAAwBA,MAAM,YAGjC,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,KAAC,OAAD;CACO;CACL,YAAA,GAAA,OAAA,IAAc,mCAAmC,SAAS;CAC1D,GAAI;AACL,CAAA,CACF;AAED,sBAAsB,cAAc;AAWpC,MAAM,sBAAsBA,MAAM,YAG/B,EAAE,UAAU,WAAW,MAAM,OAAO,GAAG,SAAS,QACjD,iBAAA,GAAA,kBAAA,MAAC,SAAD;CACO;CACL,YAAA,GAAA,OAAA,IAAc,yBAAyB,SAAS;CAChD,GAAI;WAHN;EAKE,iBAAA,GAAA,kBAAA,KAAC,QAAD;GAAM,WAAU;aAAiC;EAAY,CAAA;EAC5D;EACA,QAAQ,iBAAA,GAAA,kBAAA,KAAC,QAAD;GAAM,WAAU;aAA2B;EAAW,CAAA;CAC1D;EACR;AAED,oBAAoB,cAAc"}
1
+ {"version":3,"file":"schedule-editor.cjs","names":["React"],"sources":["../../src/components/schedule-editor.tsx"],"sourcesContent":["import * as React from 'react'\nimport { cn } from '../utils/cn'\n\nconst ScheduleEditor = React.forwardRef<\n HTMLElement,\n React.HTMLAttributes<HTMLElement>\n>(({ className, ...props }, ref) => (\n <section\n ref={ref}\n className={cn('flex flex-col gap-4 px-2', className)}\n {...props}\n />\n))\n\nScheduleEditor.displayName = 'ScheduleEditor'\n\nconst ScheduleEditorHeader = React.forwardRef<\n HTMLElement,\n React.HTMLAttributes<HTMLElement>\n>(({ className, ...props }, ref) => (\n <header\n ref={ref}\n className={cn('flex flex-col gap-1', className)}\n {...props}\n />\n))\n\nScheduleEditorHeader.displayName = 'ScheduleEditorHeader'\n\nconst ScheduleEditorTitle = React.forwardRef<\n HTMLHeadingElement,\n React.HTMLAttributes<HTMLHeadingElement>\n>(({ className, ...props }, ref) => (\n <h3\n ref={ref}\n className={cn('text-base font-bold text-gray', className)}\n {...props}\n />\n))\n\nScheduleEditorTitle.displayName = 'ScheduleEditorTitle'\n\nconst ScheduleEditorDescription = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, ...props }, ref) => (\n <p\n ref={ref}\n className={cn('text-sm leading-5 text-gray-light', className)}\n {...props}\n />\n))\n\nScheduleEditorDescription.displayName = 'ScheduleEditorDescription'\n\nconst ScheduleEditorBody = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(\n 'flex flex-col gap-[calc(var(--spark-layout-gap)*4)]',\n className,\n )}\n {...props}\n />\n))\n\nScheduleEditorBody.displayName = 'ScheduleEditorBody'\n\n/** Footer slot. Default layout splits children into a `justify-between` row,\n * which matches the common \"destructive on the left, primary on the right\"\n * pattern. Override with `className` if you need a different arrangement. */\nconst ScheduleEditorFooter = React.forwardRef<\n HTMLElement,\n React.HTMLAttributes<HTMLElement>\n>(({ className, ...props }, ref) => (\n <footer\n ref={ref}\n className={cn('flex items-center justify-between gap-2 pt-2', className)}\n {...props}\n />\n))\n\nScheduleEditorFooter.displayName = 'ScheduleEditorFooter'\n\n/** Right-aligned cluster of footer actions (e.g. Cancel + Save). */\nconst ScheduleEditorActions = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn('ml-auto flex items-center gap-2', className)}\n {...props}\n />\n))\n\nScheduleEditorActions.displayName = 'ScheduleEditorActions'\n\ninterface ScheduleEditorFieldProps extends Omit<\n React.LabelHTMLAttributes<HTMLLabelElement>,\n 'children'\n> {\n label: React.ReactNode\n hint?: React.ReactNode\n children: React.ReactNode\n}\n\nconst ScheduleEditorField = React.forwardRef<\n HTMLLabelElement,\n ScheduleEditorFieldProps\n>(({ children, className, hint, label, ...props }, ref) => (\n <label\n ref={ref}\n className={cn('flex flex-col gap-1.5', className)}\n {...props}\n >\n <span className=\"text-sm font-medium text-gray\">{label}</span>\n {children}\n {hint && <span className=\"text-xs text-gray-light\">{hint}</span>}\n </label>\n))\n\nScheduleEditorField.displayName = 'ScheduleEditorField'\n\nexport {\n ScheduleEditor,\n ScheduleEditorActions,\n ScheduleEditorBody,\n ScheduleEditorDescription,\n ScheduleEditorField,\n ScheduleEditorFooter,\n ScheduleEditorHeader,\n ScheduleEditorTitle,\n}\n"],"mappings":";;;;;;;;AAGA,MAAM,iBAAiBA,MAAM,YAG1B,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,KAAC,WAAD;CACO;CACL,YAAA,GAAA,GAAA,IAAc,4BAA4B,SAAS;CACnD,GAAI;AACL,CAAA,CACF;AAED,eAAe,cAAc;AAE7B,MAAM,uBAAuBA,MAAM,YAGhC,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,KAAC,UAAD;CACO;CACL,YAAA,GAAA,GAAA,IAAc,uBAAuB,SAAS;CAC9C,GAAI;AACL,CAAA,CACF;AAED,qBAAqB,cAAc;AAEnC,MAAM,sBAAsBA,MAAM,YAG/B,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,KAAC,MAAD;CACO;CACL,YAAA,GAAA,GAAA,IAAc,iCAAiC,SAAS;CACxD,GAAI;AACL,CAAA,CACF;AAED,oBAAoB,cAAc;AAElC,MAAM,4BAA4BA,MAAM,YAGrC,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,KAAC,KAAD;CACO;CACL,YAAA,GAAA,GAAA,IAAc,qCAAqC,SAAS;CAC5D,GAAI;AACL,CAAA,CACF;AAED,0BAA0B,cAAc;AAExC,MAAM,qBAAqBA,MAAM,YAG9B,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,KAAC,OAAD;CACO;CACL,YAAA,GAAA,GAAA,IACE,uDACA,SACF;CACA,GAAI;AACL,CAAA,CACF;AAED,mBAAmB,cAAc;;;;AAKjC,MAAM,uBAAuBA,MAAM,YAGhC,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,KAAC,UAAD;CACO;CACL,YAAA,GAAA,GAAA,IAAc,gDAAgD,SAAS;CACvE,GAAI;AACL,CAAA,CACF;AAED,qBAAqB,cAAc;;AAGnC,MAAM,wBAAwBA,MAAM,YAGjC,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,KAAC,OAAD;CACO;CACL,YAAA,GAAA,GAAA,IAAc,mCAAmC,SAAS;CAC1D,GAAI;AACL,CAAA,CACF;AAED,sBAAsB,cAAc;AAWpC,MAAM,sBAAsBA,MAAM,YAG/B,EAAE,UAAU,WAAW,MAAM,OAAO,GAAG,SAAS,QACjD,iBAAA,GAAA,kBAAA,MAAC,SAAD;CACO;CACL,YAAA,GAAA,GAAA,IAAc,yBAAyB,SAAS;CAChD,GAAI;WAHN;EAKE,iBAAA,GAAA,kBAAA,KAAC,QAAD;GAAM,WAAU;aAAiC;EAAY,CAAA;EAC5D;EACA,QAAQ,iBAAA,GAAA,kBAAA,KAAC,QAAD;GAAM,WAAU;aAA2B;EAAW,CAAA;CAC1D;EACR;AAED,oBAAoB,cAAc"}
@@ -1,28 +1,28 @@
1
1
  "use client";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const require_chunk = require("../chunk-DY84GLCh.cjs");
4
- let _epilot_spark_icons = require("@epilot/spark-icons");
5
4
  let react = require("react");
6
5
  react = require_chunk.__toESM(react);
6
+ let _epilot_spark_icons = require("@epilot/spark-icons");
7
7
  let react_jsx_runtime = require("react/jsx-runtime");
8
- let cnfast = require("cnfast");
8
+ let cn = require("cn");
9
9
  //#region src/components/schedule-list.tsx
10
10
  const ScheduleList = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
11
11
  ref,
12
- className: (0, cnfast.cn)("flex flex-col gap-[calc(var(--spark-layout-gap)*2)]", className),
12
+ className: (0, cn.cn)("flex flex-col gap-[calc(var(--spark-layout-gap)*2)]", className),
13
13
  ...props
14
14
  }));
15
15
  ScheduleList.displayName = "ScheduleList";
16
16
  const ScheduleListEmpty = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
17
17
  ref,
18
- className: (0, cnfast.cn)("px-3 py-2 text-sm text-gray-light", className),
18
+ className: (0, cn.cn)("px-3 py-2 text-sm text-gray-light", className),
19
19
  ...props
20
20
  }));
21
21
  ScheduleListEmpty.displayName = "ScheduleListEmpty";
22
22
  const ScheduleListAdd = react.forwardRef(({ children, className, icon, type = "button", ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
23
23
  ref,
24
24
  type,
25
- className: (0, cnfast.cn)("inline-flex h-11 w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-gray text-sm font-medium text-gray-light transition-colors hover:border-spark-a8 hover:bg-base-accent-soft hover:text-accent focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50", className),
25
+ className: (0, cn.cn)("inline-flex h-11 w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-gray text-sm font-medium text-gray-light transition-colors hover:border-spark-a8 hover:bg-base-accent-soft hover:text-accent focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50", className),
26
26
  ...props,
27
27
  children: [icon ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_epilot_spark_icons.Add, { className: "[--spark-icon-size:14px]" }), children]
28
28
  }));
@@ -43,7 +43,7 @@ const ScheduleEntry = react.forwardRef(({ children, className, disabled, onClick
43
43
  }
44
44
  } : void 0,
45
45
  "aria-disabled": disabled || void 0,
46
- className: (0, cnfast.cn)("flex items-center gap-3 rounded-lg bg-base-gray-soft px-3 py-2.5 transition-colors motion-reduce:transition-none", interactive && "cursor-pointer touch-target-row hover:bg-gray-a3 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden", disabled && "cursor-not-allowed opacity-50", className),
46
+ className: (0, cn.cn)("flex items-center gap-3 rounded-lg bg-base-gray-soft px-3 py-2.5 transition-colors motion-reduce:transition-none", interactive && "cursor-pointer touch-target-row hover:bg-gray-a3 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden", disabled && "cursor-not-allowed opacity-50", className),
47
47
  ...props,
48
48
  children
49
49
  });
@@ -51,19 +51,19 @@ const ScheduleEntry = react.forwardRef(({ children, className, disabled, onClick
51
51
  ScheduleEntry.displayName = "ScheduleEntry";
52
52
  const ScheduleEntryContent = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
53
53
  ref,
54
- className: (0, cnfast.cn)("flex min-w-0 flex-1 flex-col gap-0.5", className),
54
+ className: (0, cn.cn)("flex min-w-0 flex-1 flex-col gap-0.5", className),
55
55
  ...props
56
56
  }));
57
57
  ScheduleEntryContent.displayName = "ScheduleEntryContent";
58
58
  const ScheduleEntryTitle = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
59
59
  ref,
60
- className: (0, cnfast.cn)("flex min-w-0 items-center gap-2 truncate text-sm font-medium text-gray", className),
60
+ className: (0, cn.cn)("flex min-w-0 items-center gap-2 truncate text-sm font-medium text-gray", className),
61
61
  ...props
62
62
  }));
63
63
  ScheduleEntryTitle.displayName = "ScheduleEntryTitle";
64
64
  const ScheduleEntrySubtitle = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
65
65
  ref,
66
- className: (0, cnfast.cn)("truncate text-xs text-gray-light", className),
66
+ className: (0, cn.cn)("truncate text-xs text-gray-light", className),
67
67
  ...props
68
68
  }));
69
69
  ScheduleEntrySubtitle.displayName = "ScheduleEntrySubtitle";
@@ -76,7 +76,7 @@ const ScheduleEntryActions = react.forwardRef(({ className, onClick, ...props },
76
76
  event.stopPropagation();
77
77
  onClick?.(event);
78
78
  },
79
- className: (0, cnfast.cn)("flex shrink-0 items-center gap-1.5", className),
79
+ className: (0, cn.cn)("flex shrink-0 items-center gap-1.5", className),
80
80
  ...props
81
81
  }));
82
82
  ScheduleEntryActions.displayName = "ScheduleEntryActions";
@@ -88,7 +88,7 @@ const ScheduleEntryDelete = react.forwardRef(({ "aria-label": ariaLabel = "Delet
88
88
  event.stopPropagation();
89
89
  onClick?.(event);
90
90
  },
91
- className: (0, cnfast.cn)("inline-flex size-8 shrink-0 items-center justify-center rounded-full text-gray-light transition-colors hover:bg-base-error-soft hover:text-error focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50", className),
91
+ className: (0, cn.cn)("inline-flex size-8 shrink-0 items-center justify-center rounded-full text-gray-light transition-colors hover:bg-base-error-soft hover:text-error focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50", className),
92
92
  ...props,
93
93
  children: children ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_epilot_spark_icons.Delete, { className: "[--spark-icon-size:14px]" })
94
94
  }));