@acronis-platform/ui-react 3.0.0 → 4.0.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 (219) hide show
  1. package/dist/components/ui/accordion-container/accordion-container.js +14 -14
  2. package/dist/components/ui/accordion-container/accordion-container.js.map +1 -1
  3. package/dist/components/ui/app-shell-chat/app-shell-chat.js.map +1 -1
  4. package/dist/components/ui/area-chart/area-chart.js +141 -139
  5. package/dist/components/ui/area-chart/area-chart.js.map +1 -1
  6. package/dist/components/ui/bar-chart/bar-chart.js +295 -293
  7. package/dist/components/ui/bar-chart/bar-chart.js.map +1 -1
  8. package/dist/components/ui/category-bar/category-bar.js +109 -93
  9. package/dist/components/ui/category-bar/category-bar.js.map +1 -1
  10. package/dist/components/ui/chart/chart-palette.js +113 -0
  11. package/dist/components/ui/chart/chart-palette.js.map +1 -0
  12. package/dist/components/ui/chart/chart.js +176 -129
  13. package/dist/components/ui/chart/chart.js.map +1 -1
  14. package/dist/components/ui/chart-state/chart-state-illustrations.js +310 -0
  15. package/dist/components/ui/chart-state/chart-state-illustrations.js.map +1 -0
  16. package/dist/components/ui/chart-state/chart-state.js +48 -34
  17. package/dist/components/ui/chart-state/chart-state.js.map +1 -1
  18. package/dist/components/ui/chart-widget/chart-widget.js +87 -0
  19. package/dist/components/ui/chart-widget/chart-widget.js.map +1 -0
  20. package/dist/components/ui/composed-chart/composed-chart.js +117 -115
  21. package/dist/components/ui/composed-chart/composed-chart.js.map +1 -1
  22. package/dist/components/ui/confidence-cone/confidence-cone.js +166 -158
  23. package/dist/components/ui/confidence-cone/confidence-cone.js.map +1 -1
  24. package/dist/components/ui/funnel-chart/funnel-chart.js +162 -161
  25. package/dist/components/ui/funnel-chart/funnel-chart.js.map +1 -1
  26. package/dist/components/ui/histogram/histogram.js +94 -92
  27. package/dist/components/ui/histogram/histogram.js.map +1 -1
  28. package/dist/components/ui/input/input.js.map +1 -1
  29. package/dist/components/ui/label/label.js +2 -9
  30. package/dist/components/ui/label/label.js.map +1 -1
  31. package/dist/components/ui/line-chart/line-chart.js +143 -141
  32. package/dist/components/ui/line-chart/line-chart.js.map +1 -1
  33. package/dist/components/ui/metric/metric.js +74 -185
  34. package/dist/components/ui/metric/metric.js.map +1 -1
  35. package/dist/components/ui/page-content/page-content.js.map +1 -1
  36. package/dist/components/ui/pie-chart/pie-chart.js +201 -195
  37. package/dist/components/ui/pie-chart/pie-chart.js.map +1 -1
  38. package/dist/components/ui/radar-chart/radar-chart.js +133 -131
  39. package/dist/components/ui/radar-chart/radar-chart.js.map +1 -1
  40. package/dist/components/ui/radial-bar-chart/radial-bar-chart.js +297 -265
  41. package/dist/components/ui/radial-bar-chart/radial-bar-chart.js.map +1 -1
  42. package/dist/components/ui/sankey-chart/sankey-chart.js +123 -101
  43. package/dist/components/ui/sankey-chart/sankey-chart.js.map +1 -1
  44. package/dist/components/ui/scatter-chart/scatter-chart.js +76 -74
  45. package/dist/components/ui/scatter-chart/scatter-chart.js.map +1 -1
  46. package/dist/components/ui/section/section.js +157 -31
  47. package/dist/components/ui/section/section.js.map +1 -1
  48. package/dist/components/ui/stepper/stepper.js +24 -24
  49. package/dist/components/ui/stepper/stepper.js.map +1 -1
  50. package/dist/components/ui/stepper-item/stepper-item.js +43 -24
  51. package/dist/components/ui/stepper-item/stepper-item.js.map +1 -1
  52. package/dist/components/ui/treemap/treemap.js +133 -124
  53. package/dist/components/ui/treemap/treemap.js.map +1 -1
  54. package/dist/components/ui/trend-indicator/trend-indicator.js +34 -69
  55. package/dist/components/ui/trend-indicator/trend-indicator.js.map +1 -1
  56. package/dist/components/ui/wizard/wizard.js +59 -0
  57. package/dist/components/ui/wizard/wizard.js.map +1 -0
  58. package/dist/hooks/use-wizard.js +75 -0
  59. package/dist/hooks/use-wizard.js.map +1 -0
  60. package/dist/index.js +502 -497
  61. package/dist/index.js.map +1 -1
  62. package/dist/llms/accordion-container.md +181 -0
  63. package/dist/llms/accordion.md +124 -0
  64. package/dist/llms/alert.md +225 -0
  65. package/dist/llms/app-shell-chat.md +415 -0
  66. package/dist/llms/area-chart.md +355 -0
  67. package/dist/llms/avatar.md +208 -0
  68. package/dist/llms/bar-chart.md +406 -0
  69. package/dist/llms/breadcrumb.md +326 -0
  70. package/dist/llms/button-group.md +298 -0
  71. package/dist/llms/button-icon-input.md +142 -0
  72. package/dist/llms/button-icon-menu.md +209 -0
  73. package/dist/llms/button-icon.md +128 -0
  74. package/dist/llms/button-menu.md +172 -0
  75. package/dist/llms/button.md +185 -0
  76. package/dist/llms/calendar-panel.md +733 -0
  77. package/dist/llms/calendar.md +188 -0
  78. package/dist/llms/card-filter.md +214 -0
  79. package/dist/llms/card-section.md +293 -0
  80. package/dist/llms/card.md +447 -0
  81. package/dist/llms/carousel-dialog.md +156 -0
  82. package/dist/llms/category-bar.md +193 -0
  83. package/dist/llms/chart-state.md +190 -0
  84. package/dist/llms/chart-widget.md +209 -0
  85. package/dist/llms/chart.md +182 -0
  86. package/dist/llms/checkbox.md +257 -0
  87. package/dist/llms/chip.md +195 -0
  88. package/dist/llms/combobox.md +164 -0
  89. package/dist/llms/composed-chart.md +508 -0
  90. package/dist/llms/confidence-cone.md +277 -0
  91. package/dist/llms/data-table.md +474 -0
  92. package/dist/llms/date-range-picker.md +272 -0
  93. package/dist/llms/description-list.md +131 -0
  94. package/dist/llms/dialog-footer-carousel.md +147 -0
  95. package/dist/llms/dialog-footer-default.md +142 -0
  96. package/dist/llms/dialog-root.md +246 -0
  97. package/dist/llms/dialog-welcome.md +223 -0
  98. package/dist/llms/dialog.md +403 -0
  99. package/dist/llms/dropdown-menu.md +193 -0
  100. package/dist/llms/empty-overlay.md +146 -0
  101. package/dist/llms/empty.md +156 -0
  102. package/dist/llms/field.md +185 -0
  103. package/dist/llms/filter-cards.md +157 -0
  104. package/dist/llms/filter-chips.md +323 -0
  105. package/dist/llms/filter-search.md +512 -0
  106. package/dist/llms/form.md +154 -0
  107. package/dist/llms/funnel-chart.md +333 -0
  108. package/dist/llms/grid.md +80 -0
  109. package/dist/llms/histogram.md +190 -0
  110. package/dist/llms/input-date-picker.md +203 -0
  111. package/dist/llms/input-otp.md +173 -0
  112. package/dist/llms/input-password.md +197 -0
  113. package/dist/llms/input-search.md +170 -0
  114. package/dist/llms/input-select.md +278 -0
  115. package/dist/llms/input-text-area.md +271 -0
  116. package/dist/llms/input-text.md +192 -0
  117. package/dist/llms/line-chart.md +369 -0
  118. package/dist/llms/link.md +209 -0
  119. package/dist/llms/loading.md +130 -0
  120. package/dist/llms/meter.md +177 -0
  121. package/dist/llms/metric.md +204 -0
  122. package/dist/llms/number-field.md +122 -0
  123. package/dist/llms/page-content.md +69 -0
  124. package/dist/llms/page-header.md +182 -0
  125. package/dist/llms/pagination.md +133 -0
  126. package/dist/llms/pie-chart.md +307 -0
  127. package/dist/llms/popover.md +252 -0
  128. package/dist/llms/progress-circle.md +126 -0
  129. package/dist/llms/progress.md +111 -0
  130. package/dist/llms/radar-chart.md +316 -0
  131. package/dist/llms/radial-bar-chart.md +319 -0
  132. package/dist/llms/radio.md +255 -0
  133. package/dist/llms/resizable.md +195 -0
  134. package/dist/llms/sankey-chart.md +208 -0
  135. package/dist/llms/scatter-chart.md +239 -0
  136. package/dist/llms/scroll-area.md +183 -0
  137. package/dist/llms/section.md +401 -0
  138. package/dist/llms/select.md +210 -0
  139. package/dist/llms/separator.md +87 -0
  140. package/dist/llms/sheet.md +202 -0
  141. package/dist/llms/sidebar-primary.md +360 -0
  142. package/dist/llms/sidebar-secondary.md +417 -0
  143. package/dist/llms/skeleton.md +81 -0
  144. package/dist/llms/slider.md +97 -0
  145. package/dist/llms/spinner.md +100 -0
  146. package/dist/llms/stack.md +80 -0
  147. package/dist/llms/stepper-item.md +309 -0
  148. package/dist/llms/stepper.md +251 -0
  149. package/dist/llms/switch.md +140 -0
  150. package/dist/llms/table.md +436 -0
  151. package/dist/llms/tabs.md +197 -0
  152. package/dist/llms/tag.md +139 -0
  153. package/dist/llms/timeline.md +361 -0
  154. package/dist/llms/timer.md +259 -0
  155. package/dist/llms/toast.md +241 -0
  156. package/dist/llms/toggle-group.md +121 -0
  157. package/dist/llms/toolbar.md +453 -0
  158. package/dist/llms/tooltip.md +164 -0
  159. package/dist/llms/treemap.md +254 -0
  160. package/dist/llms/trend-indicator.md +132 -0
  161. package/dist/llms/widget-placeholder.md +169 -0
  162. package/dist/llms/wizard.md +412 -0
  163. package/dist/llms.txt +142 -0
  164. package/dist/react.js +502 -497
  165. package/dist/react.js.map +1 -1
  166. package/dist/src/components/ui/area-chart/area-chart.d.ts +9 -4
  167. package/dist/src/components/ui/avatar/avatar.d.ts +1 -1
  168. package/dist/src/components/ui/bar-chart/bar-chart.d.ts +9 -4
  169. package/dist/src/components/ui/category-bar/category-bar.d.ts +10 -4
  170. package/dist/src/components/ui/chart/__stories__/palette-control.d.ts +48 -0
  171. package/dist/src/components/ui/chart/__tests__/chart-palette.test.d.ts +1 -0
  172. package/dist/src/components/ui/chart/chart-palette.d.ts +128 -0
  173. package/dist/src/components/ui/chart/chart.d.ts +66 -15
  174. package/dist/src/components/ui/chart/index.d.ts +4 -2
  175. package/dist/src/components/ui/chart-state/chart-state-illustrations.d.ts +6 -0
  176. package/dist/src/components/ui/chart-state/chart-state.d.ts +13 -2
  177. package/dist/src/components/ui/chart-state/index.d.ts +1 -0
  178. package/dist/src/components/ui/chart-widget/chart-widget.d.ts +64 -0
  179. package/dist/src/components/ui/chart-widget/index.d.ts +1 -0
  180. package/dist/src/components/ui/composed-chart/composed-chart.d.ts +12 -7
  181. package/dist/src/components/ui/confidence-cone/confidence-cone.d.ts +10 -5
  182. package/dist/src/components/ui/empty-overlay/empty-overlay.d.ts +1 -1
  183. package/dist/src/components/ui/funnel-chart/funnel-chart.d.ts +11 -5
  184. package/dist/src/components/ui/histogram/histogram.d.ts +10 -4
  185. package/dist/src/components/ui/label/index.d.ts +1 -1
  186. package/dist/src/components/ui/label/label.d.ts +1 -5
  187. package/dist/src/components/ui/line-chart/line-chart.d.ts +9 -4
  188. package/dist/src/components/ui/metric/metric.d.ts +13 -14
  189. package/dist/src/components/ui/pie-chart/pie-chart.d.ts +17 -8
  190. package/dist/src/components/ui/radar-chart/radar-chart.d.ts +10 -5
  191. package/dist/src/components/ui/radial-bar-chart/radial-bar-chart.d.ts +17 -6
  192. package/dist/src/components/ui/sankey-chart/sankey-chart.d.ts +10 -5
  193. package/dist/src/components/ui/scatter-chart/scatter-chart.d.ts +10 -5
  194. package/dist/src/components/ui/section/index.d.ts +1 -1
  195. package/dist/src/components/ui/section/section.d.ts +75 -6
  196. package/dist/src/components/ui/stepper-item/stepper-item.d.ts +6 -5
  197. package/dist/src/components/ui/tag/tag.d.ts +1 -1
  198. package/dist/src/components/ui/treemap/treemap.d.ts +11 -5
  199. package/dist/src/components/ui/trend-indicator/trend-indicator.d.ts +3 -7
  200. package/dist/src/components/ui/wizard/index.d.ts +1 -0
  201. package/dist/src/components/ui/wizard/wizard.d.ts +6 -0
  202. package/dist/src/hooks/index.d.ts +1 -0
  203. package/dist/src/hooks/use-wizard.d.ts +80 -0
  204. package/dist/src/index.d.ts +2 -3
  205. package/dist/ui-react.css +1 -1
  206. package/package.json +9 -3
  207. package/dist/components/ui/app-shell/app-shell.js +0 -75
  208. package/dist/components/ui/app-shell/app-shell.js.map +0 -1
  209. package/dist/components/ui/auth-layout/auth-layout.js +0 -56
  210. package/dist/components/ui/auth-layout/auth-layout.js.map +0 -1
  211. package/dist/components/ui/collapsible/collapsible.js +0 -22
  212. package/dist/components/ui/collapsible/collapsible.js.map +0 -1
  213. package/dist/src/components/ui/app-shell/app-shell.d.ts +0 -8
  214. package/dist/src/components/ui/app-shell/index.d.ts +0 -1
  215. package/dist/src/components/ui/auth-layout/auth-layout.d.ts +0 -6
  216. package/dist/src/components/ui/auth-layout/index.d.ts +0 -1
  217. package/dist/src/components/ui/collapsible/collapsible.d.ts +0 -5
  218. package/dist/src/components/ui/collapsible/index.d.ts +0 -1
  219. package/dist/src/components/ui/label/label.docs.d.ts +0 -10
@@ -1 +1 @@
1
- {"version":3,"file":"confidence-cone.js","sources":["../../../../src/components/ui/confidence-cone/confidence-cone.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport {\n Area,\n CartesianGrid,\n ComposedChart,\n Line,\n ReferenceArea,\n ReferenceLine,\n Text,\n XAxis,\n YAxis,\n} from 'recharts';\n\nimport { cn } from '@/lib/utils';\nimport {\n ChartContainer,\n ChartLegend,\n ChartLegendContent,\n ChartTooltip,\n ChartTooltipContent,\n resolveAxisDomain,\n resolveAnimation,\n resolveRotatedTickAnchor,\n resolveXAxisHeight,\n resolveXAxisTitle,\n resolveYAxisTitle,\n CHART_LABEL_FONT_SIZE,\n type ChartConfig,\n type ChartLegendContentProps,\n type ChartTooltipContentProps,\n type CartesianChartProps,\n type ChartAnimationProps,\n} from '../chart';\n\n// A forecast confidence-cone: a solid line over the known/actual period, a\n// dashed line over the forecast period, and a shaded band (the \"cone\") between\n// a lower and upper bound that typically widens with the horizon — visualizing\n// growing uncertainty. Built on the shared Chart primitives; no new tokens\n// (series colors are caller-supplied via `config`). The whole metric renders in\n// one hue — actual and forecast differ by line style, not color — so the cone\n// band and the forecast line both reuse the actual series' color.\n\n// Each series' band is a synthetic `[lower, upper]` range field per row that a\n// recharts <Area> shades; kept out of the tooltip/legend (see the filters\n// below). One band per series, so the key carries the series' actual key — the\n// whole `__cone` prefix is reserved.\nconst BAND_PREFIX = '__cone';\nconst bandKeyFor = (actualKey: string) => `${BAND_PREFIX}:${actualKey}`;\n\n/**\n * Drop every synthetic cone-band range series from a recharts tooltip/legend\n * payload, keeping the real actual/forecast series (and their order). Applied to\n * both the default tooltip and any caller-supplied `tooltipContent`, so no band\n * surfaces regardless of which path renders or how many series are plotted.\n */\nexport function dropConeBand<T extends { dataKey?: unknown }>(\n payload: readonly T[] | undefined\n): T[] | undefined {\n return payload?.filter(\n (item) =>\n !(typeof item.dataKey === 'string' && item.dataKey.startsWith(BAND_PREFIX))\n );\n}\n\n/**\n * Reduce a legend payload to the metrics the chart plots — one entry per series.\n * A series' actual, forecast and cone are three recharts series painting a\n * single metric in a single hue, so the legend names each metric once, with its\n * actual series' swatch, instead of listing line styles as separate series.\n */\nexport function keepMetricSeries<T extends { dataKey?: unknown }>(\n payload: readonly T[] | undefined,\n actualKeys: readonly string[]\n): T[] | undefined {\n return payload?.filter(\n (item) => typeof item.dataKey === 'string' && actualKeys.includes(item.dataKey)\n );\n}\n\n/**\n * Wrap a caller-supplied `tooltipContent` so the synthetic cone band is stripped\n * from the payload before it renders, while preserving recharts' own mount\n * semantics — a function is mounted via `createElement` (its own component\n * identity + hook state), an element via `cloneElement`. This mirrors what the\n * pass-through charts get by handing `content` straight to recharts, so a\n * function-form tooltip keeps its state across re-renders here too. The returned\n * component is a stable content type (memoize it on `tooltipContent`).\n */\ntype TooltipContentType = NonNullable<\n React.ComponentProps<typeof ChartTooltip>['content']\n>;\ntype TooltipContentFn = Extract<TooltipContentType, (...args: never[]) => unknown>;\ntype TooltipRenderProps = Parameters<TooltipContentFn>[0];\n\nexport function createConeTooltip(tooltipContent: TooltipContentType) {\n return function ConeTooltip(props: TooltipRenderProps) {\n const merged = {\n ...props,\n payload: dropConeBand(props.payload),\n } as TooltipRenderProps;\n return typeof tooltipContent === 'function'\n ? React.createElement(\n tooltipContent as React.FunctionComponent<TooltipRenderProps>,\n merged\n )\n : React.cloneElement(tooltipContent, merged);\n };\n}\n\n/**\n * One plotted metric: its actual / forecast columns and, optionally, the two\n * bound columns that shade its cone. Omit `lowerKey`/`upperKey` for a band-less\n * metric — a solid line handing off to a bare dashed projection.\n */\nexport interface ConfidenceConeSeries {\n /** Field for the known/actual values — drawn as a solid line with a filled area. */\n actualKey: string;\n /** Field for the projected values — drawn as a dashed line. */\n forecastKey: string;\n /** Field for the cone's lower bound. Omit (with `upperKey`) for no cone. */\n lowerKey?: string;\n /** Field for the cone's upper bound. Omit (with `lowerKey`) for no cone. */\n upperKey?: string;\n}\n\n/**\n * The x values of the projected period — every row carrying a forecast value for\n * at least one series, in data order. The first is the hand-off point (where the\n * shaded region and divider start); the whole set drives the forecast tick\n * styling, matched by value so tick `interval` can't skew it the way a tick\n * index would. Exported for unit tests; not part of the package's public API.\n */\nexport function forecastPeriodX(\n data: ReadonlyArray<Record<string, string | number | null | undefined>>,\n series: readonly ConfidenceConeSeries[],\n xKey: string\n): Array<string | number | null | undefined> {\n return data\n .filter((row) => series.some(({ forecastKey }) => typeof row[forecastKey] === 'number'))\n .map((row) => row[xKey]);\n}\n\n/**\n * Build the X-axis tick renderer that sets the projected columns apart: italic,\n * in the metric's hue. Styled inline rather than through the `fill` attribute\n * recharts hands every tick, so the accent survives the class-based tick color\n * a chart theme may apply. A custom tick owns its own text, so the caller's\n * `xTickFormatter` is applied here — recharts only applies it to default ticks.\n * Exported for unit tests; not part of the package's public API.\n */\nexport function createForecastTick(\n forecastX: ReadonlySet<string | number | null | undefined>,\n color: string,\n tickFormatter?: CartesianChartProps['xTickFormatter']\n) {\n return function ForecastTick({\n payload,\n index,\n ...tickProps\n }: {\n payload?: { value?: string | number };\n index?: number;\n }) {\n const value = payload?.value;\n return (\n <Text\n {...tickProps}\n style={\n value != null && forecastX.has(value)\n ? { fontStyle: 'italic', fill: color }\n : undefined\n }\n >\n {tickFormatter && value != null ? tickFormatter(value, index) : value}\n </Text>\n );\n };\n}\n\n/** A dashed horizontal threshold on the value axis. */\nexport interface ConfidenceConeReferenceLine {\n /** Position on the value (Y) axis. */\n value: number;\n /** Optional caption rendered at the line's right end. */\n label?: string;\n}\n\n/**\n * Every prop except the one-form-or-the-other requirement `ConfidenceConeProps`\n * layers on below. Exported so the stories can type their `Meta` on a single\n * object shape — Storybook can't split a union's required args between `meta.args`\n * and a story's. Not re-exported from `index.ts`; not part of the public API.\n */\nexport interface ConfidenceConeBaseProps\n extends Omit<React.ComponentProps<'div'>, 'children'>,\n CartesianChartProps,\n ChartAnimationProps {\n /**\n * Row-per-point data — the shared x dimension plus each series' actual /\n * forecast / bound fields. Rows are naturally sparse (a point has either an\n * actual or a forecast + bounds), so missing fields are allowed. Avoid fields\n * starting with `__cone` — that prefix is reserved for the internal\n * prediction-band series.\n */\n data: ReadonlyArray<Record<string, string | number | null | undefined>>;\n /**\n * Per-series map of `label` / `color` for the actual + forecast lines\n * (imported from the shared `Chart` primitives). Colors are caller-supplied —\n * reference an existing semantic `--ui-*` token; there is no chart palette tier\n * yet. Each metric renders in one hue: its cone band and forecast line both\n * reuse its actual series' color — actual and forecast differ by line style,\n * not hue.\n */\n config: ChartConfig;\n /** Category / time axis key (the shared dimension across rows). */\n xKey: string;\n /**\n * Plot several metrics against one shared axis — each with its own actual /\n * forecast / bound fields and its own hue (from `config[actualKey]`). Takes\n * precedence over the single-series `actualKey`/`forecastKey`/`lowerKey`/\n * `upperKey` shorthand below; pass one form or the other, not both. One of the\n * two forms is required.\n */\n series?: readonly ConfidenceConeSeries[];\n /**\n * Single-series shorthand — field for the known/actual values, drawn as a\n * solid line with a filled area. Required (with `forecastKey`) unless `series`\n * is set, which supersedes it.\n */\n actualKey?: string;\n /**\n * Single-series shorthand — field for the projected values, drawn as a dashed\n * line. Required (with `actualKey`) unless `series` is set, which supersedes\n * it.\n */\n forecastKey?: string;\n /** Field for the cone's lower bound. Omit (with `upperKey`) for no cone. */\n lowerKey?: string;\n /** Field for the cone's upper bound. Omit (with `lowerKey`) for no cone. */\n upperKey?: string;\n /**\n * How the known/actual period is drawn: a filled `area` under the line (the\n * default), or a bare `line` — for a chart where the cone is the only shaded\n * region, or where several metrics' fills would muddy each other.\n */\n actualType?: 'area' | 'line';\n /** Stroke width of the actual + forecast lines. */\n strokeWidth?: number;\n /**\n * Mark each data point: a filled dot on the observed values, a hollow one on\n * the projection — so a point reads as measured or predicted at a glance.\n */\n showDots?: boolean;\n /**\n * Italicize the X-axis ticks over the forecast period and paint them in the\n * first series' hue, so the projected columns read as projected even when the\n * shaded region is off.\n */\n styleForecastTicks?: boolean;\n /**\n * One or more dashed horizontal thresholds on the value axis — e.g. a target\n * or a capacity limit. Pass a single object or an array to draw several.\n */\n referenceLine?: ConfidenceConeReferenceLine | ConfidenceConeReferenceLine[];\n /**\n * Set off the forecast period from the actuals with a dashed divider at the\n * hand-off point (the first row with a forecast value) and a subtle shaded\n * band over the forecast region.\n */\n showForecastRegion?: boolean;\n showLegend?: boolean;\n}\n\n/**\n * Which columns to plot has to be spelled out one way or the other: the `series`\n * array, or the flat `actualKey` + `forecastKey` shorthand. Expressed as a union\n * so a chart with neither is a compile error rather than a silent plot of axes\n * and nothing else. Both forms together stay legal — `series` wins (see\n * `plotted`), which is what the multi-series stories rely on to clear the args\n * table.\n */\nexport type ConfidenceConeProps = ConfidenceConeBaseProps &\n (\n | { series: readonly ConfidenceConeSeries[] }\n | { actualKey: string; forecastKey: string }\n );\n\nconst ConfidenceCone = React.forwardRef<HTMLDivElement, ConfidenceConeProps>(\n (\n {\n className,\n config,\n data,\n xKey,\n series,\n actualKey,\n forecastKey,\n lowerKey,\n upperKey,\n xAxisLabel,\n yAxisLabel,\n yUnit,\n actualType = 'area',\n strokeWidth = 2,\n showDots = false,\n styleForecastTicks = false,\n referenceLine,\n showForecastRegion = true,\n showGrid = true,\n showTooltip = true,\n showLegend = true,\n showXAxis = true,\n showYAxis = true,\n xTickFormatter,\n yTickFormatter,\n xAxisAngle,\n xAxisInterval,\n yAxisTickCount,\n yAxisDomain,\n gridDashed,\n gridHorizontal,\n gridVertical,\n tooltipContent,\n animate,\n animationDuration,\n animationBegin,\n animationEasing,\n ...props\n },\n ref\n ) => {\n // The flat *Key props are the single-series shorthand for `series`.\n const plotted = React.useMemo<readonly ConfidenceConeSeries[]>(() => {\n if (series?.length) return series;\n if (!actualKey || !forecastKey) return [];\n return [{ actualKey, forecastKey, lowerKey, upperKey }];\n }, [series, actualKey, forecastKey, lowerKey, upperKey]);\n\n const animation = resolveAnimation({\n animate,\n animationDuration,\n animationBegin,\n animationEasing,\n });\n // Memoized so recharts sees a stable content type across renders — a fresh\n // wrapper each render would remount the caller's tooltip and reset its state.\n const customTooltip = React.useMemo(\n () => (tooltipContent ? createConeTooltip(tooltipContent) : undefined),\n [tooltipContent]\n );\n\n const xAxisTitle = resolveXAxisTitle(xAxisLabel);\n const yAxisTitle = resolveYAxisTitle(yAxisLabel);\n\n const yDomain = resolveAxisDomain(yAxisDomain);\n\n // One hue per metric. Each cone and forecast line already paints with its own\n // series' actual color; re-pointing that series' forecast key's `--color-*`\n // at it too means nothing downstream — a custom tooltip, a caller's\n // `var(--color-<forecastKey>)` — can reintroduce a second color.\n const seriesConfig = React.useMemo(() => {\n let next: ChartConfig | undefined;\n for (const { actualKey: aKey, forecastKey: fKey } of plotted) {\n const actual = config[aKey];\n const forecast = config[fKey];\n if (!actual || !forecast) continue;\n next ??= { ...config };\n next[fKey] = {\n label: forecast.label,\n icon: forecast.icon,\n ...(actual.theme ? { theme: actual.theme } : { color: actual.color }),\n };\n }\n return next ?? config;\n }, [config, plotted]);\n\n const xAxisHeight = resolveXAxisHeight(xAxisLabel, xAxisAngle);\n\n // Augment each row with one `[lower, upper]` band tuple per coned series for\n // its Area to shade. Rows missing a numeric bound are left un-coned (the\n // band breaks there); a series without bounds gets no band at all.\n const chartData = data.map((row) => {\n const next: Record<string, unknown> = { ...row };\n for (const { actualKey: aKey, lowerKey: lKey, upperKey: uKey } of plotted) {\n if (!lKey || !uKey) continue;\n const lower = row[lKey];\n const upper = row[uKey];\n next[bandKeyFor(aKey)] =\n typeof lower === 'number' && typeof upper === 'number'\n ? [lower, upper]\n : undefined;\n }\n return next;\n });\n\n const forecastX = forecastPeriodX(data, plotted, xKey);\n // Set the projected period off from the actuals with a shaded band + a\n // divider at the hand-off.\n const forecastStart = showForecastRegion ? forecastX[0] : undefined;\n const lastX = data[data.length - 1]?.[xKey];\n\n const renderForecastTick = createForecastTick(\n new Set(forecastX),\n `var(--color-${plotted[0]?.actualKey})`,\n xTickFormatter\n );\n\n const referenceLines = referenceLine\n ? Array.isArray(referenceLine)\n ? referenceLine\n : [referenceLine]\n : [];\n\n // Everything from here to the `return` is lifted out of the returned tree\n // only to keep it readable as a flat list of chart children. Nothing in\n // recharts forces the `render*` helpers to be plain functions: axes and\n // series register themselves with the chart's store, and `<Cell>` is the\n // only child still looked up by element type — a component wrapper renders\n // fine (see AreaChart's `AreaFillGradients`). They stay functions because\n // they are declared inside the render body, where a component would get a\n // fresh element type on every render and remount its subtree.\n\n const renderAxes = () => (\n <>\n <XAxis\n dataKey={xKey}\n type=\"category\"\n hide={!showXAxis}\n tickLine={false}\n axisLine={false}\n tickMargin={8}\n tickFormatter={xTickFormatter}\n tick={styleForecastTicks ? renderForecastTick : undefined}\n angle={xAxisAngle}\n interval={xAxisInterval}\n textAnchor={resolveRotatedTickAnchor(xAxisAngle)}\n height={xAxisHeight}\n label={xAxisTitle}\n />\n <YAxis\n type=\"number\"\n hide={!showYAxis}\n tickLine={false}\n axisLine={false}\n unit={yUnit}\n tickFormatter={yTickFormatter}\n tickCount={yAxisTickCount}\n domain={yDomain}\n width={yAxisLabel ? 72 : undefined}\n label={yAxisTitle}\n />\n </>\n );\n\n // Set the forecast region off from the actuals (behind everything).\n const renderForecastRegion = () => (\n <>\n {forecastStart != null && lastX != null && (\n <ReferenceArea\n x1={forecastStart}\n x2={lastX}\n fill=\"var(--ui-background-surface-secondary)\"\n fillOpacity={0.5}\n ifOverflow=\"extendDomain\"\n />\n )}\n {forecastStart != null && (\n <ReferenceLine\n x={forecastStart}\n stroke=\"var(--ui-border-on-surface-border)\"\n strokeDasharray=\"4 4\"\n />\n )}\n </>\n );\n\n const renderThreshold = (\n threshold: ConfidenceConeReferenceLine,\n index: number\n ) => (\n <ReferenceLine\n key={`${threshold.label ?? 'threshold'}-${index}`}\n y={threshold.value}\n stroke=\"var(--ui-text-on-surface-secondary)\"\n strokeDasharray=\"4 4\"\n // extendDomain so a threshold beyond the data max stays visible.\n ifOverflow=\"extendDomain\"\n label={\n threshold.label\n ? {\n value: threshold.label,\n position: 'insideTopRight',\n fill: 'var(--ui-text-on-surface-secondary)',\n fontSize: CHART_LABEL_FONT_SIZE,\n }\n : undefined\n }\n />\n );\n\n const renderTooltip = () =>\n customTooltip ? (\n // Strips the synthetic band before the caller's tooltip sees it — the\n // `__cone` series feeds the Area, not the tooltip.\n <ChartTooltip content={customTooltip} />\n ) : (\n <ChartTooltip\n content={(tp) => (\n <ChartTooltipContent\n active={tp.active}\n label={tp.label}\n // The synthetic band feeds the Area, not the tooltip.\n payload={\n dropConeBand(tp.payload) as ChartTooltipContentProps['payload']\n }\n />\n )}\n />\n );\n\n const renderLegend = () => (\n <ChartLegend\n content={(lp) => (\n <ChartLegendContent\n verticalAlign={lp.verticalAlign}\n payload={\n keepMetricSeries(\n lp.payload,\n plotted.map((s) => s.actualKey)\n ) as ChartLegendContentProps['payload']\n }\n />\n )}\n />\n );\n\n // One color per metric — actual and forecast differ by line style, not hue\n // — so a cone reuses its series' actual color.\n const renderConeBand = ({\n actualKey: aKey,\n lowerKey: lKey,\n upperKey: uKey,\n }: ConfidenceConeSeries) =>\n lKey && uKey ? (\n <Area\n key={bandKeyFor(aKey)}\n // The band paints in the same hue, at the same opacity, as the\n // actual series' own area, so nothing on the rendered path tells\n // the two apart. recharts forwards `data-*` onto the path it\n // draws; the tests select the band through this.\n data-slot=\"confidence-cone-band\"\n dataKey={bandKeyFor(aKey)}\n type=\"monotone\"\n stroke=\"none\"\n fill={`var(--color-${aKey})`}\n fillOpacity={0.15}\n connectNulls={false}\n dot={false}\n activeDot={false}\n {...animation}\n legendType=\"none\"\n tooltipType=\"none\"\n />\n ) : null;\n\n const renderActualMark = ({ actualKey: aKey }: ConfidenceConeSeries) => {\n // An area and a line take the same props here; only the region under the\n // curve (and the mark recharts draws) differ. A `Line` gets no fill at\n // all — `fillOpacity: 0` would also erase its dots.\n const ActualMark = actualType === 'line' ? Line : Area;\n const areaFill =\n actualType === 'line'\n ? undefined\n : { fill: `var(--color-${aKey})`, fillOpacity: 0.15 };\n // Observed points read as measured: LineChart's dot geometry (r 3, 2px\n // ring) filled with the metric hue. The ring is that same hue, so the\n // mark is solid — and wide enough against the 2px line not to read as a\n // mere thickening of it. `fillOpacity: 1` is load-bearing: recharts\n // merges the parent mark's own presentation props into every dot it\n // draws, so an `<Area>`'s 0.15 would otherwise wash the dot out to a halo.\n const dot = showDots\n ? {\n r: 3,\n fill: `var(--color-${aKey})`,\n fillOpacity: 1,\n stroke: `var(--color-${aKey})`,\n strokeWidth: 2,\n }\n : false;\n return (\n <ActualMark\n key={aKey}\n dataKey={aKey}\n type=\"monotone\"\n stroke={`var(--color-${aKey})`}\n strokeWidth={strokeWidth}\n {...areaFill}\n dot={dot}\n activeDot={showDots ? { r: 5 } : false}\n connectNulls\n {...animation}\n // The legend names the metric once, so it carries the swatch that\n // stands for the whole series rather than the actual line's style.\n legendType=\"rect\"\n />\n );\n };\n\n const renderForecastLine = ({\n actualKey: aKey,\n forecastKey: fKey,\n }: ConfidenceConeSeries) => {\n // Projected points read as predicted: the same LineChart dot, inverted —\n // the metric's hue as the ring, the surface color as the fill, so the\n // dashed line doesn't show through the middle. (LineChart leaves the fill\n // to recharts, whose `Line` defaults it to `#fff`; the token is that same\n // white in the light theme and also holds up in the dark one.)\n // `strokeDasharray: 'none'` is load-bearing: recharts merges the parent\n // mark's presentation props into every dot, so this line's `5 5` would\n // otherwise break each dot's ring into two arcs.\n const dot = showDots\n ? {\n r: 3,\n fill: 'var(--ui-background-surface-primary)',\n stroke: `var(--color-${aKey})`,\n strokeWidth: 2,\n strokeDasharray: 'none',\n }\n : false;\n return (\n <Line\n key={fKey}\n dataKey={fKey}\n type=\"monotone\"\n stroke={`var(--color-${aKey})`}\n strokeWidth={strokeWidth}\n strokeDasharray=\"5 5\"\n dot={dot}\n // Paired with `dot` the way every other chart does it — left unset,\n // the projection would keep recharts' default active dot while the\n // actuals had none (and a different radius when on).\n activeDot={showDots ? { r: 5 } : false}\n connectNulls\n {...animation}\n />\n );\n };\n\n return (\n <div ref={ref} className={cn(className)} {...props}>\n <ChartContainer\n config={seriesConfig}\n className=\"size-full [&_.recharts-label]:fill-foreground\"\n >\n <ComposedChart data={chartData as readonly unknown[]}>\n {showGrid && (\n <CartesianGrid\n horizontal={gridHorizontal ?? true}\n vertical={gridVertical ?? false}\n strokeDasharray={gridDashed ? '3 3' : undefined}\n />\n )}\n {renderAxes()}\n {renderForecastRegion()}\n {referenceLines.map(renderThreshold)}\n {showTooltip && renderTooltip()}\n {showLegend && renderLegend()}\n {/* Every cone renders before any line, so the lines draw on top of\n all of them. */}\n {plotted.map(renderConeBand)}\n {plotted.map(renderActualMark)}\n {plotted.map(renderForecastLine)}\n </ComposedChart>\n </ChartContainer>\n </div>\n );\n }\n);\nConfidenceCone.displayName = 'ConfidenceCone';\n\nexport { ConfidenceCone };\n"],"names":["BAND_PREFIX","bandKeyFor","actualKey","dropConeBand","payload","item","keepMetricSeries","actualKeys","createConeTooltip","tooltipContent","props","merged","React","forecastPeriodX","data","series","xKey","row","forecastKey","createForecastTick","forecastX","color","tickFormatter","index","tickProps","value","jsx","Text","ConfidenceCone","className","config","lowerKey","upperKey","xAxisLabel","yAxisLabel","yUnit","actualType","strokeWidth","showDots","styleForecastTicks","referenceLine","showForecastRegion","showGrid","showTooltip","showLegend","showXAxis","showYAxis","xTickFormatter","yTickFormatter","xAxisAngle","xAxisInterval","yAxisTickCount","yAxisDomain","gridDashed","gridHorizontal","gridVertical","animate","animationDuration","animationBegin","animationEasing","ref","plotted","animation","resolveAnimation","customTooltip","xAxisTitle","resolveXAxisTitle","yAxisTitle","resolveYAxisTitle","yDomain","resolveAxisDomain","seriesConfig","next","aKey","fKey","actual","forecast","xAxisHeight","resolveXAxisHeight","chartData","lKey","uKey","lower","upper","forecastStart","lastX","_a","renderForecastTick","_b","referenceLines","renderAxes","jsxs","Fragment","XAxis","resolveRotatedTickAnchor","YAxis","renderForecastRegion","ReferenceArea","ReferenceLine","renderThreshold","threshold","CHART_LABEL_FONT_SIZE","renderTooltip","ChartTooltip","tp","ChartTooltipContent","renderLegend","ChartLegend","lp","ChartLegendContent","s","renderConeBand","Area","renderActualMark","ActualMark","Line","areaFill","dot","renderForecastLine","cn","ChartContainer","ComposedChart","CartesianGrid"],"mappings":";;;;;;AAgDA,MAAMA,IAAc,UACdC,IAAa,CAACC,MAAsB,GAAGF,CAAW,IAAIE,CAAS;AAQ9D,SAASC,EACdC,GACiB;AACjB,SAAOA,KAAA,gBAAAA,EAAS;AAAA,IACd,CAACC,MACC,EAAE,OAAOA,EAAK,WAAY,YAAYA,EAAK,QAAQ,WAAWL,CAAW;AAAA;AAE/E;AAQO,SAASM,GACdF,GACAG,GACiB;AACjB,SAAOH,KAAA,gBAAAA,EAAS;AAAA,IACd,CAACC,MAAS,OAAOA,EAAK,WAAY,YAAYE,EAAW,SAASF,EAAK,OAAO;AAAA;AAElF;AAiBO,SAASG,GAAkBC,GAAoC;AACpE,SAAO,SAAqBC,GAA2B;AACrD,UAAMC,IAAS;AAAA,MACb,GAAGD;AAAA,MACH,SAASP,EAAaO,EAAM,OAAO;AAAA,IAAA;AAErC,WAAO,OAAOD,KAAmB,aAC7BG,EAAM;AAAA,MACJH;AAAA,MACAE;AAAA,IAAA,IAEFC,EAAM,aAAaH,GAAgBE,CAAM;AAAA,EAC/C;AACF;AAyBO,SAASE,GACdC,GACAC,GACAC,GAC2C;AAC3C,SAAOF,EACJ,OAAO,CAACG,MAAQF,EAAO,KAAK,CAAC,EAAE,aAAAG,QAAkB,OAAOD,EAAIC,CAAW,KAAM,QAAQ,CAAC,EACtF,IAAI,CAACD,MAAQA,EAAID,CAAI,CAAC;AAC3B;AAUO,SAASG,GACdC,GACAC,GACAC,GACA;AACA,SAAO,SAAsB;AAAA,IAC3B,SAAAlB;AAAA,IACA,OAAAmB;AAAA,IACA,GAAGC;AAAA,EAAA,GAIF;AACD,UAAMC,IAAQrB,KAAA,gBAAAA,EAAS;AACvB,WACE,gBAAAsB;AAAA,MAACC;AAAA,MAAA;AAAA,QACE,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,cAAc;"}
1
+ {"version":3,"file":"confidence-cone.js","sources":["../../../../src/components/ui/confidence-cone/confidence-cone.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport {\n Area,\n CartesianGrid,\n ComposedChart,\n Line,\n ReferenceArea,\n ReferenceLine,\n Text,\n XAxis,\n YAxis,\n} from 'recharts';\n\nimport { cn } from '@/lib/utils';\nimport {\n ChartContainer,\n ChartLegend,\n ChartLegendContent,\n ChartTooltip,\n ChartTooltipContent,\n resolveAxisDomain,\n resolveAnimation,\n resolveRotatedTickAnchor,\n resolveXAxisHeight,\n resolveXAxisTitle,\n resolveYAxisTitle,\n CHART_LABEL_FONT_SIZE,\n type ChartConfig,\n type ChartPalette,\n type ChartLegendContentProps,\n type ChartTooltipContentProps,\n type CartesianChartProps,\n type ChartAnimationProps,\n} from '../chart';\n\n// A forecast confidence-cone: a solid line over the known/actual period, a\n// dashed line over the forecast period, and a shaded band (the \"cone\") between\n// a lower and upper bound that typically widens with the horizon — visualizing\n// growing uncertainty. Built on the shared Chart primitives; no new tokens\n// (series colors are caller-supplied via `config`). The whole metric renders in\n// one hue — actual and forecast differ by line style, not color — so the cone\n// band and the forecast line both reuse the actual series' color.\n\n// Each series' band is a synthetic `[lower, upper]` range field per row that a\n// recharts <Area> shades; kept out of the tooltip/legend (see the filters\n// below). One band per series, so the key carries the series' actual key — the\n// whole `__cone` prefix is reserved.\nconst BAND_PREFIX = '__cone';\nconst bandKeyFor = (actualKey: string) => `${BAND_PREFIX}:${actualKey}`;\n\n/**\n * Drop every synthetic cone-band range series from a recharts tooltip/legend\n * payload, keeping the real actual/forecast series (and their order). Applied to\n * both the default tooltip and any caller-supplied `tooltipContent`, so no band\n * surfaces regardless of which path renders or how many series are plotted.\n */\nexport function dropConeBand<T extends { dataKey?: unknown }>(\n payload: readonly T[] | undefined\n): T[] | undefined {\n return payload?.filter(\n (item) =>\n !(\n typeof item.dataKey === 'string' && item.dataKey.startsWith(BAND_PREFIX)\n )\n );\n}\n\n/**\n * Reduce a legend payload to the metrics the chart plots — one entry per series.\n * A series' actual, forecast and cone are three recharts series painting a\n * single metric in a single hue, so the legend names each metric once, with its\n * actual series' swatch, instead of listing line styles as separate series.\n */\nexport function keepMetricSeries<T extends { dataKey?: unknown }>(\n payload: readonly T[] | undefined,\n actualKeys: readonly string[]\n): T[] | undefined {\n return payload?.filter(\n (item) =>\n typeof item.dataKey === 'string' && actualKeys.includes(item.dataKey)\n );\n}\n\n/**\n * Wrap a caller-supplied `tooltipContent` so the synthetic cone band is stripped\n * from the payload before it renders, while preserving recharts' own mount\n * semantics — a function is mounted via `createElement` (its own component\n * identity + hook state), an element via `cloneElement`. This mirrors what the\n * pass-through charts get by handing `content` straight to recharts, so a\n * function-form tooltip keeps its state across re-renders here too. The returned\n * component is a stable content type (memoize it on `tooltipContent`).\n */\ntype TooltipContentType = NonNullable<\n React.ComponentProps<typeof ChartTooltip>['content']\n>;\ntype TooltipContentFn = Extract<\n TooltipContentType,\n (...args: never[]) => unknown\n>;\ntype TooltipRenderProps = Parameters<TooltipContentFn>[0];\n\nexport function createConeTooltip(tooltipContent: TooltipContentType) {\n return function ConeTooltip(props: TooltipRenderProps) {\n const merged = {\n ...props,\n payload: dropConeBand(props.payload),\n } as TooltipRenderProps;\n return typeof tooltipContent === 'function'\n ? React.createElement(\n tooltipContent as React.FunctionComponent<TooltipRenderProps>,\n merged\n )\n : React.cloneElement(tooltipContent, merged);\n };\n}\n\n/**\n * One plotted metric: its actual / forecast columns and, optionally, the two\n * bound columns that shade its cone. Omit `lowerKey`/`upperKey` for a band-less\n * metric — a solid line handing off to a bare dashed projection.\n */\nexport interface ConfidenceConeSeries {\n /** Field for the known/actual values — drawn as a solid line with a filled area. */\n actualKey: string;\n /** Field for the projected values — drawn as a dashed line. */\n forecastKey: string;\n /** Field for the cone's lower bound. Omit (with `upperKey`) for no cone. */\n lowerKey?: string;\n /** Field for the cone's upper bound. Omit (with `lowerKey`) for no cone. */\n upperKey?: string;\n}\n\n/**\n * The x values of the projected period — every row carrying a forecast value for\n * at least one series, in data order. The first is the hand-off point (where the\n * shaded region and divider start); the whole set drives the forecast tick\n * styling, matched by value so tick `interval` can't skew it the way a tick\n * index would. Exported for unit tests; not part of the package's public API.\n */\nexport function forecastPeriodX(\n data: ReadonlyArray<Record<string, string | number | null | undefined>>,\n series: readonly ConfidenceConeSeries[],\n xKey: string\n): Array<string | number | null | undefined> {\n return data\n .filter((row) =>\n series.some(({ forecastKey }) => typeof row[forecastKey] === 'number')\n )\n .map((row) => row[xKey]);\n}\n\n/**\n * Build the X-axis tick renderer that sets the projected columns apart: italic,\n * in the metric's hue. Styled inline rather than through the `fill` attribute\n * recharts hands every tick, so the accent survives the class-based tick color\n * a chart theme may apply. A custom tick owns its own text, so the caller's\n * `xTickFormatter` is applied here — recharts only applies it to default ticks.\n * Exported for unit tests; not part of the package's public API.\n */\nexport function createForecastTick(\n forecastX: ReadonlySet<string | number | null | undefined>,\n color: string,\n tickFormatter?: CartesianChartProps['xTickFormatter']\n) {\n return function ForecastTick({\n payload,\n index,\n ...tickProps\n }: {\n payload?: { value?: string | number };\n index?: number;\n }) {\n const value = payload?.value;\n return (\n <Text\n {...tickProps}\n style={\n value != null && forecastX.has(value)\n ? { fontStyle: 'italic', fill: color }\n : undefined\n }\n >\n {tickFormatter && value != null ? tickFormatter(value, index) : value}\n </Text>\n );\n };\n}\n\n/** A dashed horizontal threshold on the value axis. */\nexport interface ConfidenceConeReferenceLine {\n /** Position on the value (Y) axis. */\n value: number;\n /** Optional caption rendered at the line's right end. */\n label?: string;\n}\n\n/**\n * Every prop except the one-form-or-the-other requirement `ConfidenceConeProps`\n * layers on below. Exported so the stories can type their `Meta` on a single\n * object shape — Storybook can't split a union's required args between `meta.args`\n * and a story's. Not re-exported from `index.ts`; not part of the public API.\n */\nexport interface ConfidenceConeBaseProps\n extends\n Omit<React.ComponentProps<'div'>, 'children'>,\n CartesianChartProps,\n ChartAnimationProps {\n /**\n * The dataviz palette this chart's series are painted from. Series that\n * state no `color` of their own take a stop of it. See `ChartPalette`.\n */\n palette?: ChartPalette;\n /**\n * Row-per-point data — the shared x dimension plus each series' actual /\n * forecast / bound fields. Rows are naturally sparse (a point has either an\n * actual or a forecast + bounds), so missing fields are allowed. Avoid fields\n * starting with `__cone` — that prefix is reserved for the internal\n * prediction-band series.\n */\n data: ReadonlyArray<Record<string, string | number | null | undefined>>;\n /**\n * Per-series map of `label` / `icon` / `tone` for the actual + forecast lines\n * (imported from the shared `Chart` primitives). Series take their colour from\n * the container's `palette`; each entry maps a key to a `label` and an optional\n * `tone`. Each metric renders in one hue: its cone band and forecast line both\n * reuse its actual series' color — actual and forecast differ by line style,\n * not hue.\n */\n config: ChartConfig;\n /** Category / time axis key (the shared dimension across rows). */\n xKey: string;\n /**\n * Plot several metrics against one shared axis — each with its own actual /\n * forecast / bound fields and its own hue (from `config[actualKey]`). Takes\n * precedence over the single-series `actualKey`/`forecastKey`/`lowerKey`/\n * `upperKey` shorthand below; pass one form or the other, not both. One of the\n * two forms is required.\n */\n series?: readonly ConfidenceConeSeries[];\n /**\n * Single-series shorthand — field for the known/actual values, drawn as a\n * solid line with a filled area. Required (with `forecastKey`) unless `series`\n * is set, which supersedes it.\n */\n actualKey?: string;\n /**\n * Single-series shorthand — field for the projected values, drawn as a dashed\n * line. Required (with `actualKey`) unless `series` is set, which supersedes\n * it.\n */\n forecastKey?: string;\n /** Field for the cone's lower bound. Omit (with `upperKey`) for no cone. */\n lowerKey?: string;\n /** Field for the cone's upper bound. Omit (with `lowerKey`) for no cone. */\n upperKey?: string;\n /**\n * How the known/actual period is drawn: a filled `area` under the line (the\n * default), or a bare `line` — for a chart where the cone is the only shaded\n * region, or where several metrics' fills would muddy each other.\n */\n actualType?: 'area' | 'line';\n /** Stroke width of the actual + forecast lines. */\n strokeWidth?: number;\n /**\n * Mark each data point: a filled dot on the observed values, a hollow one on\n * the projection — so a point reads as measured or predicted at a glance.\n */\n showDots?: boolean;\n /**\n * Italicize the X-axis ticks over the forecast period and paint them in the\n * first series' hue, so the projected columns read as projected even when the\n * shaded region is off.\n */\n styleForecastTicks?: boolean;\n /**\n * One or more dashed horizontal thresholds on the value axis — e.g. a target\n * or a capacity limit. Pass a single object or an array to draw several.\n */\n referenceLine?: ConfidenceConeReferenceLine | ConfidenceConeReferenceLine[];\n /**\n * Set off the forecast period from the actuals with a dashed divider at the\n * hand-off point (the first row with a forecast value) and a subtle shaded\n * band over the forecast region.\n */\n showForecastRegion?: boolean;\n showLegend?: boolean;\n}\n\n/**\n * Which columns to plot has to be spelled out one way or the other: the `series`\n * array, or the flat `actualKey` + `forecastKey` shorthand. Expressed as a union\n * so a chart with neither is a compile error rather than a silent plot of axes\n * and nothing else. Both forms together stay legal — `series` wins (see\n * `plotted`), which is what the multi-series stories rely on to clear the args\n * table.\n */\nexport type ConfidenceConeProps = ConfidenceConeBaseProps &\n (\n | { series: readonly ConfidenceConeSeries[] }\n | { actualKey: string; forecastKey: string }\n );\n\nconst ConfidenceCone = React.forwardRef<HTMLDivElement, ConfidenceConeProps>(\n (\n {\n className,\n config,\n palette,\n data,\n xKey,\n series,\n actualKey,\n forecastKey,\n lowerKey,\n upperKey,\n xAxisLabel,\n yAxisLabel,\n yUnit,\n actualType = 'area',\n strokeWidth = 2,\n showDots = false,\n styleForecastTicks = false,\n referenceLine,\n showForecastRegion = true,\n showGrid = true,\n showTooltip = true,\n showLegend = true,\n showXAxis = true,\n showYAxis = true,\n xTickFormatter,\n yTickFormatter,\n xAxisAngle,\n xAxisInterval,\n yAxisTickCount,\n yAxisDomain,\n gridDashed,\n gridHorizontal,\n gridVertical,\n tooltipContent,\n animate,\n animationDuration,\n animationBegin,\n animationEasing,\n ...props\n },\n ref\n ) => {\n // The flat *Key props are the single-series shorthand for `series`.\n const plotted = React.useMemo<readonly ConfidenceConeSeries[]>(() => {\n if (series?.length) return series;\n if (!actualKey || !forecastKey) return [];\n return [{ actualKey, forecastKey, lowerKey, upperKey }];\n }, [series, actualKey, forecastKey, lowerKey, upperKey]);\n\n const animation = resolveAnimation({\n animate,\n animationDuration,\n animationBegin,\n animationEasing,\n });\n // Memoized so recharts sees a stable content type across renders — a fresh\n // wrapper each render would remount the caller's tooltip and reset its state.\n const customTooltip = React.useMemo(\n () => (tooltipContent ? createConeTooltip(tooltipContent) : undefined),\n [tooltipContent]\n );\n\n const xAxisTitle = resolveXAxisTitle(xAxisLabel);\n const yAxisTitle = resolveYAxisTitle(yAxisLabel);\n\n const yDomain = resolveAxisDomain(yAxisDomain);\n\n // One hue per metric. Each cone and forecast line already paints with its own\n // series' actual color; re-pointing that series' forecast key's `--color-*`\n // at it too means nothing downstream — a custom tooltip, a caller's\n // `var(--color-<forecastKey>)` — can reintroduce a second color.\n const seriesConfig = React.useMemo(() => {\n let next: ChartConfig | undefined;\n for (const { actualKey: aKey, forecastKey: fKey } of plotted) {\n const actual = config[aKey];\n const forecast = config[fKey];\n if (!actual || !forecast) continue;\n next ??= { ...config };\n next[fKey] = {\n label: forecast.label,\n icon: forecast.icon,\n tone: { sameAs: aKey },\n };\n }\n return next ?? config;\n }, [config, plotted]);\n\n const xAxisHeight = resolveXAxisHeight(xAxisLabel, xAxisAngle);\n\n // Augment each row with one `[lower, upper]` band tuple per coned series for\n // its Area to shade. Rows missing a numeric bound are left un-coned (the\n // band breaks there); a series without bounds gets no band at all.\n const chartData = data.map((row) => {\n const next: Record<string, unknown> = { ...row };\n for (const {\n actualKey: aKey,\n lowerKey: lKey,\n upperKey: uKey,\n } of plotted) {\n if (!lKey || !uKey) continue;\n const lower = row[lKey];\n const upper = row[uKey];\n next[bandKeyFor(aKey)] =\n typeof lower === 'number' && typeof upper === 'number'\n ? [lower, upper]\n : undefined;\n }\n return next;\n });\n\n const forecastX = forecastPeriodX(data, plotted, xKey);\n // Set the projected period off from the actuals with a shaded band + a\n // divider at the hand-off.\n const forecastStart = showForecastRegion ? forecastX[0] : undefined;\n const lastX = data[data.length - 1]?.[xKey];\n\n const renderForecastTick = createForecastTick(\n new Set(forecastX),\n `var(--color-${plotted[0]?.actualKey})`,\n xTickFormatter\n );\n\n const referenceLines = referenceLine\n ? Array.isArray(referenceLine)\n ? referenceLine\n : [referenceLine]\n : [];\n\n // Everything from here to the `return` is lifted out of the returned tree\n // only to keep it readable as a flat list of chart children. Nothing in\n // recharts forces the `render*` helpers to be plain functions: axes and\n // series register themselves with the chart's store, and `<Cell>` is the\n // only child still looked up by element type — a component wrapper renders\n // fine (see AreaChart's `AreaFillGradients`). They stay functions because\n // they are declared inside the render body, where a component would get a\n // fresh element type on every render and remount its subtree.\n\n const renderAxes = () => (\n <>\n <XAxis\n dataKey={xKey}\n type=\"category\"\n hide={!showXAxis}\n tickLine={false}\n axisLine={false}\n tickMargin={8}\n tickFormatter={xTickFormatter}\n tick={styleForecastTicks ? renderForecastTick : undefined}\n angle={xAxisAngle}\n interval={xAxisInterval}\n textAnchor={resolveRotatedTickAnchor(xAxisAngle)}\n height={xAxisHeight}\n label={xAxisTitle}\n />\n <YAxis\n type=\"number\"\n hide={!showYAxis}\n tickLine={false}\n axisLine={false}\n unit={yUnit}\n tickFormatter={yTickFormatter}\n tickCount={yAxisTickCount}\n domain={yDomain}\n width={yAxisLabel ? 72 : undefined}\n label={yAxisTitle}\n />\n </>\n );\n\n // Set the forecast region off from the actuals (behind everything).\n const renderForecastRegion = () => (\n <>\n {forecastStart != null && lastX != null && (\n <ReferenceArea\n x1={forecastStart}\n x2={lastX}\n fill=\"var(--ui-background-surface-secondary)\"\n fillOpacity={0.5}\n ifOverflow=\"extendDomain\"\n />\n )}\n {forecastStart != null && (\n <ReferenceLine\n x={forecastStart}\n stroke=\"var(--ui-border-on-surface-border)\"\n strokeDasharray=\"4 4\"\n />\n )}\n </>\n );\n\n const renderThreshold = (\n threshold: ConfidenceConeReferenceLine,\n index: number\n ) => (\n <ReferenceLine\n key={`${threshold.label ?? 'threshold'}-${index}`}\n y={threshold.value}\n stroke=\"var(--ui-text-on-surface-secondary)\"\n strokeDasharray=\"4 4\"\n // extendDomain so a threshold beyond the data max stays visible.\n ifOverflow=\"extendDomain\"\n label={\n threshold.label\n ? {\n value: threshold.label,\n position: 'insideTopRight',\n fill: 'var(--ui-text-on-surface-secondary)',\n fontSize: CHART_LABEL_FONT_SIZE,\n }\n : undefined\n }\n />\n );\n\n const renderTooltip = () =>\n customTooltip ? (\n // Strips the synthetic band before the caller's tooltip sees it — the\n // `__cone` series feeds the Area, not the tooltip.\n <ChartTooltip content={customTooltip} />\n ) : (\n <ChartTooltip\n content={(tp) => (\n <ChartTooltipContent\n active={tp.active}\n label={tp.label}\n // The synthetic band feeds the Area, not the tooltip.\n payload={\n dropConeBand(tp.payload) as ChartTooltipContentProps['payload']\n }\n />\n )}\n />\n );\n\n const renderLegend = () => (\n <ChartLegend\n content={(lp) => (\n <ChartLegendContent\n verticalAlign={lp.verticalAlign}\n payload={\n keepMetricSeries(\n lp.payload,\n plotted.map((s) => s.actualKey)\n ) as ChartLegendContentProps['payload']\n }\n />\n )}\n />\n );\n\n // One color per metric — actual and forecast differ by line style, not hue\n // — so a cone reuses its series' actual color.\n const renderConeBand = ({\n actualKey: aKey,\n lowerKey: lKey,\n upperKey: uKey,\n }: ConfidenceConeSeries) =>\n lKey && uKey ? (\n <Area\n key={bandKeyFor(aKey)}\n // The band paints in the same hue, at the same opacity, as the\n // actual series' own area, so nothing on the rendered path tells\n // the two apart. recharts forwards `data-*` onto the path it\n // draws; the tests select the band through this.\n data-slot=\"confidence-cone-band\"\n dataKey={bandKeyFor(aKey)}\n type=\"monotone\"\n stroke=\"none\"\n fill={`var(--color-${aKey})`}\n fillOpacity={0.15}\n connectNulls={false}\n dot={false}\n activeDot={false}\n {...animation}\n legendType=\"none\"\n tooltipType=\"none\"\n />\n ) : null;\n\n const renderActualMark = ({ actualKey: aKey }: ConfidenceConeSeries) => {\n // An area and a line take the same props here; only the region under the\n // curve (and the mark recharts draws) differ. A `Line` gets no fill at\n // all — `fillOpacity: 0` would also erase its dots.\n const ActualMark = actualType === 'line' ? Line : Area;\n const areaFill =\n actualType === 'line'\n ? undefined\n : { fill: `var(--color-${aKey})`, fillOpacity: 0.15 };\n // Observed points read as measured: LineChart's dot geometry (r 3, 2px\n // ring) filled with the metric hue. The ring is that same hue, so the\n // mark is solid — and wide enough against the 2px line not to read as a\n // mere thickening of it. `fillOpacity: 1` is load-bearing: recharts\n // merges the parent mark's own presentation props into every dot it\n // draws, so an `<Area>`'s 0.15 would otherwise wash the dot out to a halo.\n const dot = showDots\n ? {\n r: 3,\n fill: `var(--color-${aKey})`,\n fillOpacity: 1,\n stroke: `var(--color-${aKey})`,\n strokeWidth: 2,\n }\n : false;\n return (\n <ActualMark\n key={aKey}\n dataKey={aKey}\n type=\"monotone\"\n stroke={`var(--color-${aKey})`}\n strokeWidth={strokeWidth}\n {...areaFill}\n dot={dot}\n activeDot={showDots ? { r: 5 } : false}\n connectNulls\n {...animation}\n // The legend names the metric once, so it carries the swatch that\n // stands for the whole series rather than the actual line's style.\n legendType=\"rect\"\n />\n );\n };\n\n const renderForecastLine = ({\n actualKey: aKey,\n forecastKey: fKey,\n }: ConfidenceConeSeries) => {\n // Projected points read as predicted: the same LineChart dot, inverted —\n // the metric's hue as the ring, the surface color as the fill, so the\n // dashed line doesn't show through the middle. (LineChart leaves the fill\n // to recharts, whose `Line` defaults it to `#fff`; the token is that same\n // white in the light theme and also holds up in the dark one.)\n // `strokeDasharray: 'none'` is load-bearing: recharts merges the parent\n // mark's presentation props into every dot, so this line's `5 5` would\n // otherwise break each dot's ring into two arcs.\n const dot = showDots\n ? {\n r: 3,\n fill: 'var(--ui-background-surface-primary)',\n stroke: `var(--color-${aKey})`,\n strokeWidth: 2,\n strokeDasharray: 'none',\n }\n : false;\n return (\n <Line\n key={fKey}\n dataKey={fKey}\n type=\"monotone\"\n stroke={`var(--color-${aKey})`}\n strokeWidth={strokeWidth}\n strokeDasharray=\"5 5\"\n dot={dot}\n // Paired with `dot` the way every other chart does it — left unset,\n // the projection would keep recharts' default active dot while the\n // actuals had none (and a different radius when on).\n activeDot={showDots ? { r: 5 } : false}\n connectNulls\n {...animation}\n />\n );\n };\n\n return (\n <div ref={ref} className={cn(className)} {...props}>\n <ChartContainer\n config={seriesConfig}\n palette={palette}\n className=\"size-full [&_.recharts-label]:fill-foreground\"\n >\n <ComposedChart data={chartData as readonly unknown[]}>\n {showGrid && (\n <CartesianGrid\n horizontal={gridHorizontal ?? true}\n vertical={gridVertical ?? false}\n strokeDasharray={gridDashed ? '3 3' : undefined}\n />\n )}\n {renderAxes()}\n {renderForecastRegion()}\n {referenceLines.map(renderThreshold)}\n {showTooltip && renderTooltip()}\n {showLegend && renderLegend()}\n {/* Every cone renders before any line, so the lines draw on top of\n all of them. */}\n {plotted.map(renderConeBand)}\n {plotted.map(renderActualMark)}\n {plotted.map(renderForecastLine)}\n </ComposedChart>\n </ChartContainer>\n </div>\n );\n }\n);\nConfidenceCone.displayName = 'ConfidenceCone';\n\nexport { ConfidenceCone };\n"],"names":["BAND_PREFIX","bandKeyFor","actualKey","dropConeBand","payload","item","keepMetricSeries","actualKeys","createConeTooltip","tooltipContent","props","merged","React","forecastPeriodX","data","series","xKey","row","forecastKey","createForecastTick","forecastX","color","tickFormatter","index","tickProps","value","jsx","Text","ConfidenceCone","className","config","palette","lowerKey","upperKey","xAxisLabel","yAxisLabel","yUnit","actualType","strokeWidth","showDots","styleForecastTicks","referenceLine","showForecastRegion","showGrid","showTooltip","showLegend","showXAxis","showYAxis","xTickFormatter","yTickFormatter","xAxisAngle","xAxisInterval","yAxisTickCount","yAxisDomain","gridDashed","gridHorizontal","gridVertical","animate","animationDuration","animationBegin","animationEasing","ref","plotted","animation","resolveAnimation","customTooltip","xAxisTitle","resolveXAxisTitle","yAxisTitle","resolveYAxisTitle","yDomain","resolveAxisDomain","seriesConfig","next","aKey","fKey","actual","forecast","xAxisHeight","resolveXAxisHeight","chartData","lKey","uKey","lower","upper","forecastStart","lastX","_a","renderForecastTick","_b","referenceLines","renderAxes","jsxs","Fragment","XAxis","resolveRotatedTickAnchor","YAxis","renderForecastRegion","ReferenceArea","ReferenceLine","renderThreshold","threshold","CHART_LABEL_FONT_SIZE","renderTooltip","ChartTooltip","tp","ChartTooltipContent","renderLegend","ChartLegend","lp","ChartLegendContent","s","renderConeBand","Area","renderActualMark","ActualMark","Line","areaFill","dot","renderForecastLine","cn","ChartContainer","ComposedChart","CartesianGrid"],"mappings":";;;;;;AAiDA,MAAMA,IAAc,UACdC,IAAa,CAACC,MAAsB,GAAGF,CAAW,IAAIE,CAAS;AAQ9D,SAASC,EACdC,GACiB;AACjB,SAAOA,KAAA,gBAAAA,EAAS;AAAA,IACd,CAACC,MACC,EACE,OAAOA,EAAK,WAAY,YAAYA,EAAK,QAAQ,WAAWL,CAAW;AAAA;AAG/E;AAQO,SAASM,GACdF,GACAG,GACiB;AACjB,SAAOH,KAAA,gBAAAA,EAAS;AAAA,IACd,CAACC,MACC,OAAOA,EAAK,WAAY,YAAYE,EAAW,SAASF,EAAK,OAAO;AAAA;AAE1E;AAoBO,SAASG,GAAkBC,GAAoC;AACpE,SAAO,SAAqBC,GAA2B;AACrD,UAAMC,IAAS;AAAA,MACb,GAAGD;AAAA,MACH,SAASP,EAAaO,EAAM,OAAO;AAAA,IAAA;AAErC,WAAO,OAAOD,KAAmB,aAC7BG,EAAM;AAAA,MACJH;AAAA,MACAE;AAAA,IAAA,IAEFC,EAAM,aAAaH,GAAgBE,CAAM;AAAA,EAC/C;AACF;AAyBO,SAASE,GACdC,GACAC,GACAC,GAC2C;AAC3C,SAAOF,EACJ;AAAA,IAAO,CAACG,MACPF,EAAO,KAAK,CAAC,EAAE,aAAAG,EAAA,MAAkB,OAAOD,EAAIC,CAAW,KAAM,QAAQ;AAAA,EAAA,EAEtE,IAAI,CAACD,MAAQA,EAAID,CAAI,CAAC;AAC3B;AAUO,SAASG,GACdC,GACAC,GACAC,GACA;AACA,SAAO,SAAsB;AAAA,IAC3B,SAAAlB;AAAA,IACA,OAAAmB;AAAA,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oD,EAAgB;AAAA,UAC5BpD,EAAQ,IAAIyD,EAAkB;AAAA,QAAA,EAAA,CACjC;AAAA,MAAA;AAAA,IAAA,GAEJ;AAAA,EAEJ;AACF;AACA3F,GAAe,cAAc;"}
@@ -1,11 +1,11 @@
1
- import { jsx as c, jsxs as B } from "react/jsx-runtime";
2
- import * as A from "react";
3
- import { cva as ur } from "../../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.js";
4
- import { FunnelChart as fr, Funnel as dr, Cell as mr, LabelList as V } from "recharts";
5
- import { cn as vr } from "../../../lib/utils.js";
6
- import { resolveAnimation as hr, resolveLabelFillClass as O } from "../chart/chart-format.js";
7
- import { ChartContainer as pr, ChartTooltip as br, ChartTooltipContent as Lr, ChartLegend as Cr, ChartLegendContent as Ar } from "../chart/chart.js";
8
- const Nr = ur("", {
1
+ import { jsx as c, jsxs as V } from "react/jsx-runtime";
2
+ import * as N from "react";
3
+ import { cva as fr } from "../../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.js";
4
+ import { FunnelChart as dr, Funnel as mr, Cell as vr, LabelList as O } from "recharts";
5
+ import { cn as hr } from "../../../lib/utils.js";
6
+ import { resolveAnimation as pr, resolveLabelFillClass as R } from "../chart/chart-format.js";
7
+ import { ChartContainer as br, ChartTooltip as Lr, ChartTooltipContent as Cr, ChartLegend as Ar, ChartLegendContent as Nr } from "../chart/chart.js";
8
+ const _r = fr("", {
9
9
  variants: {
10
10
  lastShape: {
11
11
  triangle: "",
@@ -15,12 +15,12 @@ const Nr = ur("", {
15
15
  defaultVariants: {
16
16
  lastShape: "triangle"
17
17
  }
18
- }), R = {
18
+ }), D = {
19
19
  right: "right",
20
20
  left: "left",
21
21
  inside: "center"
22
22
  };
23
- function _r(r) {
23
+ function Er(r) {
24
24
  switch (r) {
25
25
  case "right":
26
26
  return "left";
@@ -30,152 +30,153 @@ function _r(r) {
30
30
  return "right";
31
31
  }
32
32
  }
33
- const D = "__stageLabel", G = "__stageValueLabel", Er = 45, Tr = {
33
+ const G = "__stageLabel", j = "__stageValueLabel", Tr = 45, $r = {
34
34
  stroke: "var(--ui-border-on-surface-border-active)",
35
35
  strokeWidth: 2
36
- }, U = 96, j = {
36
+ }, W = 96, H = {
37
37
  top: 8,
38
- right: U,
38
+ right: W,
39
39
  bottom: 8,
40
40
  left: 24
41
- }, $r = "75%";
42
- function Ir(r) {
41
+ }, Ir = "75%";
42
+ function gr(r) {
43
43
  return r.includes("-");
44
44
  }
45
- function gr(r) {
45
+ function Fr(r) {
46
46
  const { showLabels: e, labelPosition: t, labelFormat: o } = r;
47
- return e && t === "right" && Ir(o) ? $r : void 0;
47
+ return e && t === "right" && gr(o) ? Ir : void 0;
48
48
  }
49
- function Fr(r) {
50
- const { showLabels: e, labelPosition: t, showValueLabels: o, valuePosition: n } = r;
49
+ function xr(r) {
50
+ const { showLabels: e, labelPosition: t, showValueLabels: o, valuePosition: u } = r;
51
51
  return {
52
- ...j,
53
- left: (e ? t : void 0) === "left" || (o ? n : void 0) === "left" ? U : j.left
52
+ ...H,
53
+ left: (e ? t : void 0) === "left" || (o ? u : void 0) === "left" ? W : H.left
54
54
  };
55
55
  }
56
- const xr = (r) => {
56
+ const Mr = (r) => {
57
57
  const e = typeof r == "number" ? r : Number(r);
58
58
  return Number.isFinite(e) ? `${(e * 100).toFixed(1)}%` : String(r);
59
59
  };
60
- function H(r) {
60
+ function U(r) {
61
61
  const {
62
62
  name: e,
63
63
  value: t,
64
64
  base: o,
65
- format: n,
66
- formatter: d,
67
- percentFormatter: b = xr
68
- } = r, u = d ? d(t) : String(t), v = typeof t == "number" ? t : Number(t), a = o > 0 && Number.isFinite(v) ? b(v / o) : "";
69
- switch (n) {
65
+ format: u,
66
+ formatter: n,
67
+ percentFormatter: m = Mr
68
+ } = r, v = n ? n(t) : String(t), h = typeof t == "number" ? t : Number(t), l = o > 0 && Number.isFinite(h) ? m(h / o) : "";
69
+ switch (u) {
70
70
  case "name":
71
71
  return e;
72
72
  case "value":
73
- return u;
73
+ return v;
74
74
  case "percent":
75
- return a;
75
+ return l;
76
76
  case "name-value":
77
- return `${e}: ${u}`;
77
+ return `${e}: ${v}`;
78
78
  case "name-percent":
79
- return a ? `${e}: ${a}` : e;
79
+ return l ? `${e}: ${l}` : e;
80
80
  case "value-percent":
81
- return a ? `${u} (${a})` : u;
81
+ return l ? `${v} (${l})` : v;
82
82
  }
83
83
  }
84
- function Mr(r, e, t) {
84
+ function Pr(r, e, t) {
85
85
  if (t <= 1) return r;
86
- const o = 100 - (100 - Er) * e / (t - 1);
86
+ const o = 100 - (100 - Tr) * e / (t - 1);
87
87
  return `color-mix(in oklab, ${r} ${o.toFixed(1)}%, var(--ui-background-surface-primary))`;
88
88
  }
89
- const Pr = A.forwardRef(
89
+ const kr = N.forwardRef(
90
90
  ({
91
91
  className: r,
92
92
  config: e,
93
- data: t,
94
- dataKey: o,
93
+ palette: t,
94
+ data: o,
95
+ dataKey: u,
95
96
  nameKey: n,
96
- lastShape: d = "triangle",
97
- reversed: b = !1,
98
- showLabels: u = !0,
99
- labelFormat: v = "name",
100
- labelPosition: a = "right",
101
- showValueLabels: N = !1,
102
- valuePosition: W,
103
- labelFill: L,
104
- labelFormatter: _,
105
- percentFormatter: E,
106
- showLegend: Y = !1,
107
- legendPos: T = "bottom",
108
- colorMode: $ = "palette",
109
- gradientColor: I,
110
- stageSettings: i,
111
- showActiveShape: z = !1,
112
- stroke: X,
113
- strokeWidth: g,
114
- funnelWidth: q,
115
- margin: w,
116
- showTooltip: y = !0,
117
- tooltipContent: J,
118
- animate: Q,
119
- animationDuration: Z,
120
- animationBegin: K,
121
- animationEasing: rr,
122
- ...er
123
- }, tr) => {
124
- const nr = hr({
125
- animate: Q,
126
- animationDuration: Z,
127
- animationBegin: K,
128
- animationEasing: rr
129
- }), C = A.useMemo(() => {
130
- var P;
131
- const l = t.filter(
97
+ lastShape: m = "triangle",
98
+ reversed: v = !1,
99
+ showLabels: h = !0,
100
+ labelFormat: l = "name",
101
+ labelPosition: L = "right",
102
+ showValueLabels: _ = !1,
103
+ valuePosition: Y,
104
+ labelFill: C,
105
+ labelFormatter: E,
106
+ percentFormatter: T,
107
+ showLegend: z = !1,
108
+ legendPos: $ = "bottom",
109
+ colorMode: I = "palette",
110
+ gradientColor: g,
111
+ stageSettings: a,
112
+ showActiveShape: X = !1,
113
+ stroke: q,
114
+ strokeWidth: F,
115
+ funnelWidth: w,
116
+ margin: y,
117
+ showTooltip: J = !0,
118
+ tooltipContent: Q,
119
+ animate: Z,
120
+ animationDuration: K,
121
+ animationBegin: rr,
122
+ animationEasing: er,
123
+ ...tr
124
+ }, nr) => {
125
+ const or = pr({
126
+ animate: Z,
127
+ animationDuration: K,
128
+ animationBegin: rr,
129
+ animationEasing: er
130
+ }), A = N.useMemo(() => {
131
+ var k;
132
+ const i = o.filter(
132
133
  (f) => {
133
- var p;
134
- return !((p = i == null ? void 0 : i[String(f[n])]) != null && p.hidden);
134
+ var b;
135
+ return !((b = a == null ? void 0 : a[String(f[n])]) != null && b.hidden);
135
136
  }
136
- ), s = l.length ? String(l[0][n]) : void 0, h = I ?? (s === void 0 ? void 0 : ((P = i == null ? void 0 : i[s]) == null ? void 0 : P.color) ?? `var(--color-${s})`), sr = l.reduce((f, p) => {
137
- const m = Number(p[o]);
138
- return Number.isFinite(m) && m > f ? m : f;
137
+ ), s = i.length ? String(i[0][n]) : void 0, p = g ?? (s === void 0 ? void 0 : ((k = a == null ? void 0 : a[s]) == null ? void 0 : k.color) ?? `var(--color-${s})`), cr = i.reduce((f, b) => {
138
+ const d = Number(b[u]);
139
+ return Number.isFinite(d) && d > f ? d : f;
139
140
  }, 0);
140
- return l.map((f, p) => {
141
- var S;
142
- const m = String(f[n]), cr = ((S = i == null ? void 0 : i[m]) == null ? void 0 : S.color) ?? ($ === "gradient" && h ? Mr(h, p, l.length) : `var(--color-${m})`), k = {
143
- name: m,
144
- value: f[o],
145
- base: sr,
146
- formatter: _,
147
- percentFormatter: E
141
+ return i.map((f, b) => {
142
+ var B;
143
+ const d = String(f[n]), ur = ((B = a == null ? void 0 : a[d]) == null ? void 0 : B.color) ?? (I === "gradient" && p ? Pr(p, b, i.length) : `var(--color-${d})`), S = {
144
+ name: d,
145
+ value: f[u],
146
+ base: cr,
147
+ formatter: E,
148
+ percentFormatter: T
148
149
  };
149
150
  return {
150
151
  ...f,
151
- fill: cr,
152
- [D]: H({
153
- ...k,
154
- format: v
152
+ fill: ur,
153
+ [G]: U({
154
+ ...S,
155
+ format: l
155
156
  }),
156
- [G]: H({
157
- ...k,
157
+ [j]: U({
158
+ ...S,
158
159
  format: "value"
159
160
  })
160
161
  };
161
162
  });
162
163
  }, [
163
- $,
164
- t,
165
- o,
166
164
  I,
167
- v,
168
- _,
169
- n,
165
+ o,
166
+ u,
167
+ g,
168
+ l,
170
169
  E,
171
- i
172
- ]), or = A.useMemo(() => {
173
- const l = /* @__PURE__ */ new Set();
174
- return C.flatMap((s) => {
175
- const h = String(s[n]);
176
- return l.has(h) ? [] : (l.add(h), [
170
+ n,
171
+ T,
172
+ a
173
+ ]), ar = N.useMemo(() => {
174
+ const i = /* @__PURE__ */ new Set();
175
+ return A.flatMap((s) => {
176
+ const p = String(s[n]);
177
+ return i.has(p) ? [] : (i.add(p), [
177
178
  {
178
- value: h,
179
+ value: p,
179
180
  dataKey: n,
180
181
  type: "rect",
181
182
  color: String(s.fill),
@@ -183,80 +184,80 @@ const Pr = A.forwardRef(
183
184
  }
184
185
  ]);
185
186
  });
186
- }, [n, C]), F = W ?? _r(a), x = R[a], M = R[F], ar = {
187
- ...Fr({
188
- showLabels: u,
189
- labelPosition: a,
190
- showValueLabels: N,
191
- valuePosition: F
187
+ }, [n, A]), x = Y ?? Er(L), M = D[L], P = D[x], ir = {
188
+ ...xr({
189
+ showLabels: h,
190
+ labelPosition: L,
191
+ showValueLabels: _,
192
+ valuePosition: x
192
193
  }),
193
- ...w
194
- }, ir = q ?? gr({ showLabels: u, labelPosition: a, labelFormat: v }), lr = X ?? (g != null ? "var(--ui-border-on-surface-border)" : void 0);
194
+ ...y
195
+ }, lr = w ?? Fr({ showLabels: h, labelPosition: L, labelFormat: l }), sr = q ?? (F != null ? "var(--ui-border-on-surface-border)" : void 0);
195
196
  return /* @__PURE__ */ c(
196
197
  "div",
197
198
  {
198
- ref: tr,
199
- "data-last-shape": d,
200
- className: vr(Nr({ lastShape: d }), r),
201
- ...er,
202
- children: /* @__PURE__ */ c(pr, { config: e, className: "size-full", children: /* @__PURE__ */ B(fr, { margin: ar, children: [
203
- y && /* @__PURE__ */ c(
204
- br,
199
+ ref: nr,
200
+ "data-last-shape": m,
201
+ className: hr(_r({ lastShape: m }), r),
202
+ ...tr,
203
+ children: /* @__PURE__ */ c(br, { config: e, palette: t, className: "size-full", children: /* @__PURE__ */ V(dr, { margin: ir, children: [
204
+ J && /* @__PURE__ */ c(
205
+ Lr,
205
206
  {
206
- content: J ?? /* @__PURE__ */ c(Lr, { nameKey: n, hideLabel: !0 })
207
+ content: Q ?? /* @__PURE__ */ c(Cr, { nameKey: n, hideLabel: !0 })
207
208
  }
208
209
  ),
209
- Y && /* @__PURE__ */ c(
210
- Cr,
210
+ z && /* @__PURE__ */ c(
211
+ Ar,
211
212
  {
212
- verticalAlign: T,
213
+ verticalAlign: $,
213
214
  content: () => /* @__PURE__ */ c(
214
- Ar,
215
+ Nr,
215
216
  {
216
- payload: or,
217
- verticalAlign: T,
217
+ payload: ar,
218
+ verticalAlign: $,
218
219
  nameKey: n
219
220
  }
220
221
  )
221
222
  }
222
223
  ),
223
- /* @__PURE__ */ B(
224
- dr,
224
+ /* @__PURE__ */ V(
225
+ mr,
225
226
  {
226
- dataKey: o,
227
+ dataKey: u,
227
228
  nameKey: n,
228
- data: C,
229
- lastShapeType: d ?? "triangle",
230
- reversed: b,
231
- width: ir,
232
- stroke: lr,
233
- strokeWidth: g,
234
- activeShape: z ? Tr : void 0,
235
- ...nr,
229
+ data: A,
230
+ lastShapeType: m ?? "triangle",
231
+ reversed: v,
232
+ width: lr,
233
+ stroke: sr,
234
+ strokeWidth: F,
235
+ activeShape: X ? $r : void 0,
236
+ ...or,
236
237
  children: [
237
- C.map((l, s) => (
238
+ A.map((i, s) => (
238
239
  // Keyed by index, not the name: two stages could share a nameKey
239
240
  // value, which would collide as a React key. Same-named stages
240
241
  // intentionally share a color/config entry via `--color-<name>`.
241
- /* @__PURE__ */ c(mr, { fill: String(l.fill) }, s)
242
+ /* @__PURE__ */ c(vr, { fill: String(i.fill) }, s)
242
243
  )),
243
- u && /* @__PURE__ */ c(
244
- V,
244
+ h && /* @__PURE__ */ c(
245
+ O,
245
246
  {
246
- position: x,
247
- dataKey: D,
248
- className: L ? void 0 : O(x),
249
- fill: L,
247
+ position: M,
248
+ dataKey: G,
249
+ className: C ? void 0 : R(M),
250
+ fill: C,
250
251
  stroke: "none"
251
252
  }
252
253
  ),
253
- N && /* @__PURE__ */ c(
254
- V,
254
+ _ && /* @__PURE__ */ c(
255
+ O,
255
256
  {
256
- position: M,
257
- dataKey: G,
258
- className: L ? void 0 : O(M),
259
- fill: L,
257
+ position: P,
258
+ dataKey: j,
259
+ className: C ? void 0 : R(P),
260
+ fill: C,
260
261
  stroke: "none"
261
262
  }
262
263
  )
@@ -268,14 +269,14 @@ const Pr = A.forwardRef(
268
269
  );
269
270
  }
270
271
  );
271
- Pr.displayName = "FunnelChart";
272
+ kr.displayName = "FunnelChart";
272
273
  export {
273
- Pr as FunnelChart,
274
- Fr as funnelChartLabelMargin,
275
- gr as funnelChartLabelReserve,
276
- H as funnelChartLabelText,
277
- _r as funnelChartOppositeSide,
278
- xr as funnelChartPercent,
279
- Nr as funnelChartVariants
274
+ kr as FunnelChart,
275
+ xr as funnelChartLabelMargin,
276
+ Fr as funnelChartLabelReserve,
277
+ U as funnelChartLabelText,
278
+ Er as funnelChartOppositeSide,
279
+ Mr as funnelChartPercent,
280
+ _r as funnelChartVariants
280
281
  };
281
282
  //# sourceMappingURL=funnel-chart.js.map