@acronis-platform/ui-react 0.60.0 → 0.62.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 (99) hide show
  1. package/README.md +5 -5
  2. package/dist/components/ui/app-shell/app-shell.js.map +1 -1
  3. package/dist/components/ui/area-chart/area-chart.js +209 -146
  4. package/dist/components/ui/area-chart/area-chart.js.map +1 -1
  5. package/dist/components/ui/avatar/avatar.js +26 -23
  6. package/dist/components/ui/avatar/avatar.js.map +1 -1
  7. package/dist/components/ui/bar-chart/bar-chart.js +595 -180
  8. package/dist/components/ui/bar-chart/bar-chart.js.map +1 -1
  9. package/dist/components/ui/calendar-panel/calendar-panel-utils.js +63 -0
  10. package/dist/components/ui/calendar-panel/calendar-panel-utils.js.map +1 -0
  11. package/dist/components/ui/calendar-panel/calendar-panel.js +260 -0
  12. package/dist/components/ui/calendar-panel/calendar-panel.js.map +1 -0
  13. package/dist/components/ui/category-bar/category-bar.js +98 -77
  14. package/dist/components/ui/category-bar/category-bar.js.map +1 -1
  15. package/dist/components/ui/chart/chart-format.js +144 -14
  16. package/dist/components/ui/chart/chart-format.js.map +1 -1
  17. package/dist/components/ui/chart/chart.js +204 -150
  18. package/dist/components/ui/chart/chart.js.map +1 -1
  19. package/dist/components/ui/composed-chart/composed-chart.js +422 -125
  20. package/dist/components/ui/composed-chart/composed-chart.js.map +1 -1
  21. package/dist/components/ui/confidence-cone/confidence-cone.js +308 -202
  22. package/dist/components/ui/confidence-cone/confidence-cone.js.map +1 -1
  23. package/dist/components/ui/filter-cards/filter-cards.js +25 -0
  24. package/dist/components/ui/filter-cards/filter-cards.js.map +1 -0
  25. package/dist/components/ui/funnel-chart/funnel-chart.js +245 -51
  26. package/dist/components/ui/funnel-chart/funnel-chart.js.map +1 -1
  27. package/dist/components/ui/histogram/histogram.js +85 -81
  28. package/dist/components/ui/histogram/histogram.js.map +1 -1
  29. package/dist/components/ui/line-chart/line-chart.js +227 -184
  30. package/dist/components/ui/line-chart/line-chart.js.map +1 -1
  31. package/dist/components/ui/metric/metric.js +88 -70
  32. package/dist/components/ui/metric/metric.js.map +1 -1
  33. package/dist/components/ui/pie-chart/pie-chart.js +234 -80
  34. package/dist/components/ui/pie-chart/pie-chart.js.map +1 -1
  35. package/dist/components/ui/radar-chart/radar-chart.js +210 -57
  36. package/dist/components/ui/radar-chart/radar-chart.js.map +1 -1
  37. package/dist/components/ui/radial-bar-chart/radial-bar-chart.js +358 -50
  38. package/dist/components/ui/radial-bar-chart/radial-bar-chart.js.map +1 -1
  39. package/dist/components/ui/resizable/resizable.js +23 -11
  40. package/dist/components/ui/resizable/resizable.js.map +1 -1
  41. package/dist/components/ui/sankey-chart/sankey-chart.js +25 -18
  42. package/dist/components/ui/sankey-chart/sankey-chart.js.map +1 -1
  43. package/dist/components/ui/scatter-chart/scatter-chart.js +86 -78
  44. package/dist/components/ui/scatter-chart/scatter-chart.js.map +1 -1
  45. package/dist/components/ui/sidebar-secondary/sidebar-secondary.js.map +1 -1
  46. package/dist/components/ui/timeline/timeline.js +206 -142
  47. package/dist/components/ui/timeline/timeline.js.map +1 -1
  48. package/dist/components/ui/treemap/treemap.js +183 -59
  49. package/dist/components/ui/treemap/treemap.js.map +1 -1
  50. package/dist/index.js +446 -420
  51. package/dist/index.js.map +1 -1
  52. package/dist/node_modules/.pnpm/react-day-picker@10.0.1_@types_react@19.2.15_react@19.2.6/node_modules/react-day-picker/dist/esm/useDayPicker.js +3 -3
  53. package/dist/react.js +446 -420
  54. package/dist/react.js.map +1 -1
  55. package/dist/src/components/ui/area-chart/area-chart.d.ts +53 -3
  56. package/dist/src/components/ui/area-chart/index.d.ts +1 -1
  57. package/dist/src/components/ui/avatar/avatar.d.ts +1 -1
  58. package/dist/src/components/ui/bar-chart/bar-chart.d.ts +154 -16
  59. package/dist/src/components/ui/bar-chart/index.d.ts +1 -1
  60. package/dist/src/components/ui/button/button.d.ts +1 -1
  61. package/dist/src/components/ui/button-menu/button-menu.d.ts +1 -1
  62. package/dist/src/components/ui/calendar-panel/__tests__/calendar-panel-utils.test.d.ts +1 -0
  63. package/dist/src/components/ui/calendar-panel/calendar-panel-utils.d.ts +55 -0
  64. package/dist/src/components/ui/calendar-panel/calendar-panel.d.ts +112 -0
  65. package/dist/src/components/ui/calendar-panel/index.d.ts +1 -0
  66. package/dist/src/components/ui/chart/__tests__/chart-layout.d.ts +63 -0
  67. package/dist/src/components/ui/chart/__tests__/chart-layout.test.d.ts +1 -0
  68. package/dist/src/components/ui/chart/chart-format.d.ts +415 -0
  69. package/dist/src/components/ui/chart/chart.d.ts +9 -3
  70. package/dist/src/components/ui/chart/index.d.ts +2 -2
  71. package/dist/src/components/ui/composed-chart/composed-chart.d.ts +156 -7
  72. package/dist/src/components/ui/composed-chart/index.d.ts +1 -1
  73. package/dist/src/components/ui/confidence-cone/confidence-cone.d.ts +138 -20
  74. package/dist/src/components/ui/confidence-cone/index.d.ts +1 -1
  75. package/dist/src/components/ui/filter-cards/filter-cards.d.ts +11 -0
  76. package/dist/src/components/ui/filter-cards/index.d.ts +1 -0
  77. package/dist/src/components/ui/funnel-chart/funnel-chart.d.ts +201 -3
  78. package/dist/src/components/ui/funnel-chart/index.d.ts +1 -1
  79. package/dist/src/components/ui/histogram/histogram.d.ts +2 -2
  80. package/dist/src/components/ui/line-chart/index.d.ts +1 -1
  81. package/dist/src/components/ui/line-chart/line-chart.d.ts +51 -3
  82. package/dist/src/components/ui/pie-chart/index.d.ts +1 -1
  83. package/dist/src/components/ui/pie-chart/pie-chart.d.ts +145 -4
  84. package/dist/src/components/ui/radar-chart/index.d.ts +1 -1
  85. package/dist/src/components/ui/radar-chart/radar-chart.d.ts +219 -6
  86. package/dist/src/components/ui/radial-bar-chart/index.d.ts +1 -1
  87. package/dist/src/components/ui/radial-bar-chart/radial-bar-chart.d.ts +215 -9
  88. package/dist/src/components/ui/scatter-chart/scatter-chart.d.ts +2 -2
  89. package/dist/src/components/ui/timeline/index.d.ts +1 -1
  90. package/dist/src/components/ui/timeline/timeline.d.ts +79 -20
  91. package/dist/src/components/ui/treemap/index.d.ts +1 -1
  92. package/dist/src/components/ui/treemap/treemap.d.ts +68 -8
  93. package/dist/src/index.d.ts +2 -1
  94. package/dist/ui-react.css +1 -1
  95. package/package.json +2 -2
  96. package/dist/components/ui/search-global/search-global.js +0 -60
  97. package/dist/components/ui/search-global/search-global.js.map +0 -1
  98. package/dist/src/components/ui/search-global/index.d.ts +0 -1
  99. package/dist/src/components/ui/search-global/search-global.d.ts +0 -7
@@ -1,10 +1,10 @@
1
- import { jsxs as r, jsx as l, Fragment as z } from "react/jsx-runtime";
2
- import * as b from "react";
3
- import { cva as I } from "../../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.js";
4
- import { cn as x } from "../../../lib/utils.js";
5
- import { ChartStyle as y } from "../chart/chart.js";
6
- import { Tooltip as B, TooltipTrigger as O, TooltipContent as S } from "../tooltip/tooltip.js";
7
- const q = (c) => c.toLocaleString(), F = I("flex w-full overflow-hidden rounded-full bg-input", {
1
+ import { jsxs as l, jsx as a, Fragment as z } from "react/jsx-runtime";
2
+ import * as N from "react";
3
+ import { cva as B } from "../../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.js";
4
+ import { cn as k } from "../../../lib/utils.js";
5
+ import { ChartStyle as v } from "../chart/chart.js";
6
+ import { Tooltip as S, TooltipTrigger as I, TooltipContent as O } from "../tooltip/tooltip.js";
7
+ const q = (o) => o.toLocaleString(), F = B("flex w-full overflow-hidden rounded-full bg-input", {
8
8
  variants: {
9
9
  size: {
10
10
  sm: "h-1.5",
@@ -15,100 +15,121 @@ const q = (c) => c.toLocaleString(), F = I("flex w-full overflow-hidden rounded-
15
15
  defaultVariants: {
16
16
  size: "md"
17
17
  }
18
- }), R = b.forwardRef(
18
+ });
19
+ function R({
20
+ chartId: o,
21
+ config: n,
22
+ color: t,
23
+ label: d,
24
+ percent: m,
25
+ segmentKey: f,
26
+ value: u,
27
+ valueFormatter: s,
28
+ renderContent: c
29
+ }) {
30
+ return /* @__PURE__ */ l(
31
+ O,
32
+ {
33
+ "data-chart": o,
34
+ className: k(
35
+ "border border-border bg-background text-foreground shadow-md",
36
+ !c && "flex items-center gap-2"
37
+ ),
38
+ children: [
39
+ /* @__PURE__ */ a(v, { id: o, config: n }),
40
+ c ? c({ key: f, value: u, label: d, percent: m, color: t }) : /* @__PURE__ */ l(z, { children: [
41
+ /* @__PURE__ */ a(
42
+ "span",
43
+ {
44
+ className: "size-2.5 shrink-0 rounded-full",
45
+ style: { backgroundColor: t }
46
+ }
47
+ ),
48
+ /* @__PURE__ */ a("span", { className: "font-semibold", children: d }),
49
+ /* @__PURE__ */ l("span", { className: "text-muted-foreground tabular-nums", children: [
50
+ s(u),
51
+ " · ",
52
+ m,
53
+ "%"
54
+ ] })
55
+ ] })
56
+ ]
57
+ }
58
+ );
59
+ }
60
+ const V = N.forwardRef(
19
61
  ({
20
- className: c,
62
+ className: o,
21
63
  data: n,
22
- config: o,
23
- size: g,
24
- showLegend: k = !1,
25
- showTooltip: v = !0,
26
- tooltipContent: d,
27
- valueFormatter: i = q,
28
- defaultOpenIndex: N,
64
+ config: t,
65
+ size: d,
66
+ showLegend: m = !1,
67
+ showTooltip: f = !0,
68
+ tooltipContent: u,
69
+ valueFormatter: s = q,
70
+ defaultOpenIndex: c,
29
71
  "aria-label": w,
30
72
  ...C
31
73
  }, T) => {
32
- const s = `chart-${b.useId().replace(/:/g, "")}`, f = n.reduce((e, a) => e + a.value, 0), u = (e) => {
33
- var a;
34
- return ((a = o[e]) == null ? void 0 : a.label) ?? e;
74
+ const p = `chart-${N.useId().replace(/:/g, "")}`, h = n.reduce((e, r) => e + r.value, 0), b = (e) => {
75
+ var r;
76
+ return ((r = t[e]) == null ? void 0 : r.label) ?? e;
35
77
  }, $ = (e) => {
36
- var t;
37
- const a = (t = o[e]) == null ? void 0 : t.label;
38
- return typeof a == "string" || typeof a == "number" ? String(a) : e;
39
- }, p = (e) => `var(--color-${e})`, m = (e) => f > 0 ? Math.round(e / f * 100) : 0, j = w ?? n.map((e) => `${$(e.key)} ${i(e.value)}`).join(", ");
40
- return /* @__PURE__ */ r(
78
+ var i;
79
+ const r = (i = t[e]) == null ? void 0 : i.label;
80
+ return typeof r == "string" || typeof r == "number" ? String(r) : e;
81
+ }, x = (e) => `var(--color-${e})`, y = (e) => h > 0 ? Math.round(e / h * 100) : 0, j = w ?? n.map((e) => `${$(e.key)} ${s(e.value)}`).join(", ");
82
+ return /* @__PURE__ */ l(
41
83
  "div",
42
84
  {
43
85
  ref: T,
44
- "data-chart": s,
45
- className: x("flex w-full flex-col gap-3", c),
86
+ "data-chart": p,
87
+ className: k("flex w-full flex-col gap-3", o),
46
88
  ...C,
47
89
  children: [
48
- /* @__PURE__ */ l(y, { id: s, config: o }),
49
- /* @__PURE__ */ l("div", { className: F({ size: g }), role: "img", "aria-label": j, children: n.map((e, a) => {
50
- const t = p(e.key), h = /* @__PURE__ */ l(
90
+ /* @__PURE__ */ a(v, { id: p, config: t }),
91
+ /* @__PURE__ */ a("div", { className: F({ size: d }), role: "img", "aria-label": j, children: n.map((e, r) => {
92
+ const i = x(e.key), g = /* @__PURE__ */ a(
51
93
  "div",
52
94
  {
53
95
  className: "h-full min-w-0",
54
- style: { flex: `${e.value} 0 0%`, backgroundColor: t }
96
+ style: { flex: `${e.value} 0 0%`, backgroundColor: i }
55
97
  },
56
98
  e.key
57
99
  );
58
- return v ? /* @__PURE__ */ r(B, { defaultOpen: a === N, children: [
59
- /* @__PURE__ */ l(O, { render: h }),
60
- /* @__PURE__ */ r(
61
- S,
100
+ return f ? /* @__PURE__ */ l(S, { defaultOpen: r === c, children: [
101
+ /* @__PURE__ */ a(I, { render: g }),
102
+ /* @__PURE__ */ a(
103
+ R,
62
104
  {
63
- "data-chart": s,
64
- className: x(
65
- "border border-border bg-background text-foreground shadow-md",
66
- !d && "flex items-center gap-2"
67
- ),
68
- children: [
69
- /* @__PURE__ */ l(y, { id: s, config: o }),
70
- d ? d({
71
- key: e.key,
72
- value: e.value,
73
- label: u(e.key),
74
- percent: m(e.value),
75
- color: t
76
- }) : /* @__PURE__ */ r(z, { children: [
77
- /* @__PURE__ */ l(
78
- "span",
79
- {
80
- className: "size-2.5 shrink-0 rounded-full",
81
- style: { backgroundColor: t }
82
- }
83
- ),
84
- /* @__PURE__ */ l("span", { className: "font-semibold", children: u(e.key) }),
85
- /* @__PURE__ */ r("span", { className: "text-muted-foreground tabular-nums", children: [
86
- i(e.value),
87
- " · ",
88
- m(e.value),
89
- "%"
90
- ] })
91
- ] })
92
- ]
105
+ chartId: p,
106
+ config: t,
107
+ color: i,
108
+ label: b(e.key),
109
+ percent: y(e.value),
110
+ segmentKey: e.key,
111
+ value: e.value,
112
+ valueFormatter: s,
113
+ renderContent: u
93
114
  }
94
115
  )
95
- ] }, e.key) : h;
116
+ ] }, e.key) : g;
96
117
  }) }),
97
- k && /* @__PURE__ */ l("ul", { className: "flex flex-wrap justify-between gap-x-6 gap-y-3", children: n.map((e) => /* @__PURE__ */ r("li", { className: "flex flex-col gap-1.5", children: [
98
- /* @__PURE__ */ r("span", { className: "flex items-center gap-1.5 text-sm leading-none text-muted-foreground", children: [
99
- /* @__PURE__ */ l(
118
+ m && /* @__PURE__ */ a("ul", { className: "flex flex-wrap justify-between gap-x-6 gap-y-3", children: n.map((e) => /* @__PURE__ */ l("li", { className: "flex flex-col gap-1.5", children: [
119
+ /* @__PURE__ */ l("span", { className: "flex items-center gap-1.5 text-sm leading-none text-muted-foreground", children: [
120
+ /* @__PURE__ */ a(
100
121
  "span",
101
122
  {
102
- className: "size-2.5 shrink-0 rounded-full",
103
- style: { backgroundColor: p(e.key) }
123
+ className: "size-2.5 shrink-0 rounded-sm",
124
+ style: { backgroundColor: x(e.key) }
104
125
  }
105
126
  ),
106
- u(e.key)
127
+ b(e.key)
107
128
  ] }),
108
- /* @__PURE__ */ r("span", { className: "flex items-baseline gap-1.5 leading-none tabular-nums", children: [
109
- /* @__PURE__ */ l("span", { className: "text-base font-semibold text-foreground", children: i(e.value) }),
110
- /* @__PURE__ */ r("span", { className: "text-sm text-muted-foreground", children: [
111
- m(e.value),
129
+ /* @__PURE__ */ l("span", { className: "flex items-baseline gap-1.5 leading-none tabular-nums", children: [
130
+ /* @__PURE__ */ a("span", { className: "text-base font-semibold text-foreground", children: s(e.value) }),
131
+ /* @__PURE__ */ l("span", { className: "text-sm text-muted-foreground", children: [
132
+ y(e.value),
112
133
  "%"
113
134
  ] })
114
135
  ] })
@@ -118,9 +139,9 @@ const q = (c) => c.toLocaleString(), F = I("flex w-full overflow-hidden rounded-
118
139
  );
119
140
  }
120
141
  );
121
- R.displayName = "CategoryBar";
142
+ V.displayName = "CategoryBar";
122
143
  export {
123
- R as CategoryBar,
144
+ V as CategoryBar,
124
145
  F as categoryBarVariants
125
146
  };
126
147
  //# sourceMappingURL=category-bar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"category-bar.js","sources":["../../../../src/components/ui/category-bar/category-bar.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nimport { cn } from '@/lib/utils';\nimport { ChartStyle, type ChartConfig } from '../chart';\nimport { Tooltip, TooltipContent, TooltipTrigger } from '../tooltip';\n\n// A category bar: a single horizontal bar split into proportional colored\n// segments — one part-to-whole across a handful of categories, in one row\n// (onboarding stages, certification status, a rating scale). Unlike `Meter`\n// (one value per row, stacked into a bar list), all segments share the same bar.\n// It's a plain flex composition, not a recharts chart: each segment's width is\n// `value / total`, so exact proportions and the count/% legend are direct DOM,\n// with no axes/grid to hide. Segment colors are caller-supplied via `config`\n// (existing semantic `--ui-*` tokens); there is no chart palette tier yet.\n//\n// Colors are consumed through the same `--color-<key>` bridge the recharts\n// charts use: `ChartStyle` emits one custom property per config entry, so a\n// `theme: { light, dark }` entry works as well as a flat `color` — reading\n// `config[key].color` directly would render a themed config colorless. The\n// tooltip is portaled out of the bar's DOM, so its popup carries its own\n// `data-chart` scope + `ChartStyle` to keep the bridge resolvable there.\n\nconst defaultFormat = (value: number) => value.toLocaleString();\n\n// Track height only — the flex/rounded/overflow chrome is static.\nconst categoryBarVariants = cva('flex w-full overflow-hidden rounded-full bg-input', {\n variants: {\n size: {\n sm: 'h-1.5',\n md: 'h-2.5',\n lg: 'h-4',\n },\n },\n defaultVariants: {\n size: 'md',\n },\n});\n\nexport interface CategoryBarSegment {\n /** Key into `config` for this segment's label + color. */\n key: string;\n /** The segment's value — its width is this over the sum of all values. */\n value: number;\n}\n\n/** The resolved segment passed to a custom `tooltipContent` renderer. */\nexport interface CategoryBarTooltipContext extends CategoryBarSegment {\n /** Resolved `config` label (falls back to the key); may be any `ReactNode`. */\n label: React.ReactNode;\n /** Share of the total as a rounded percentage (0–100). */\n percent: number;\n /**\n * CSS color reference for the segment — the `var(--color-<key>)` bridge, which\n * resolves the config entry's `color` or its per-theme `theme` value. Usable\n * anywhere a CSS color is (e.g. a `style` background); not a literal value.\n */\n color: string;\n}\n\nexport interface CategoryBarProps\n extends Omit<React.ComponentProps<'div'>, 'children'>,\n VariantProps<typeof categoryBarVariants> {\n /** Ordered segments (left → right). Widths are proportional to `value`. */\n data: ReadonlyArray<CategoryBarSegment>;\n /** Maps each segment `key` to a `label` and `color` (an existing `--ui-*` token). */\n config: ChartConfig;\n /** Show the legend below the bar (color dot + label + value + %). */\n showLegend?: boolean;\n /** Show a hover tooltip per segment (dot + label + value + %). */\n showTooltip?: boolean;\n /**\n * Custom tooltip content per segment — replaces the default (dot + label +\n * `value · %`) inside the same card. Ignored when `showTooltip` is false.\n */\n tooltipContent?: (segment: CategoryBarTooltipContext) => React.ReactNode;\n /** Format the numeric value (legend + tooltip). Defaults to `toLocaleString()`. */\n valueFormatter?: (value: number) => string;\n /** Render the tooltip for this segment index initially open (VR/testing). */\n defaultOpenIndex?: number;\n /**\n * Accessible summary of the whole bar. Defaults to a `label value` list built\n * from the data; pass a fuller sentence for screen readers if you have one.\n */\n 'aria-label'?: string;\n}\n\nconst CategoryBar = React.forwardRef<HTMLDivElement, CategoryBarProps>(\n (\n {\n className,\n data,\n config,\n size,\n showLegend = false,\n showTooltip = true,\n tooltipContent,\n valueFormatter = defaultFormat,\n defaultOpenIndex,\n 'aria-label': ariaLabel,\n ...props\n },\n ref\n ) => {\n const uniqueId = React.useId();\n const chartId = `chart-${uniqueId.replace(/:/g, '')}`;\n\n const total = data.reduce((sum, seg) => sum + seg.value, 0);\n const labelFor = (key: string): React.ReactNode => config[key]?.label ?? key;\n // The aria-label has to be a plain string, so a rich (element) label can't\n // be used there — fall back to the key rather than stringifying it into\n // \"[object Object]\".\n const labelTextFor = (key: string) => {\n const label = config[key]?.label;\n return typeof label === 'string' || typeof label === 'number'\n ? String(label)\n : key;\n };\n const colorOf = (key: string) => `var(--color-${key})`;\n const pctOf = (value: number) =>\n total > 0 ? Math.round((value / total) * 100) : 0;\n\n // A locale-neutral fallback: \"<label> <value>\" pairs. Consumers can pass a\n // fuller `aria-label` sentence.\n const summary =\n ariaLabel ??\n data\n .map((seg) => `${labelTextFor(seg.key)} ${valueFormatter(seg.value)}`)\n .join(', ');\n\n return (\n <div\n ref={ref}\n data-chart={chartId}\n className={cn('flex w-full flex-col gap-3', className)}\n {...props}\n >\n <ChartStyle id={chartId} config={config} />\n <div className={categoryBarVariants({ size })} role=\"img\" aria-label={summary}>\n {data.map((seg, index) => {\n const color = colorOf(seg.key);\n // flex-grow proportional to value with a zero basis → widths are\n // exactly value/total; a zero-value segment collapses.\n const segment = (\n <div\n key={seg.key}\n className=\"h-full min-w-0\"\n style={{ flex: `${seg.value} 0 0%`, backgroundColor: color }}\n />\n );\n\n if (!showTooltip) return segment;\n\n return (\n <Tooltip key={seg.key} defaultOpen={index === defaultOpenIndex}>\n <TooltipTrigger render={segment} />\n <TooltipContent\n // The popup is portaled out of the bar, so it needs its own\n // `data-chart` scope for the `--color-*` bridge to resolve.\n data-chart={chartId}\n className={cn(\n 'border border-border bg-background text-foreground shadow-md',\n !tooltipContent && 'flex items-center gap-2'\n )}\n >\n <ChartStyle id={chartId} config={config} />\n {tooltipContent ? (\n tooltipContent({\n key: seg.key,\n value: seg.value,\n label: labelFor(seg.key),\n percent: pctOf(seg.value),\n color,\n })\n ) : (\n <>\n <span\n className=\"size-2.5 shrink-0 rounded-full\"\n style={{ backgroundColor: color }}\n />\n <span className=\"font-semibold\">{labelFor(seg.key)}</span>\n <span className=\"text-muted-foreground tabular-nums\">\n {valueFormatter(seg.value)} · {pctOf(seg.value)}%\n </span>\n </>\n )}\n </TooltipContent>\n </Tooltip>\n );\n })}\n </div>\n\n {showLegend && (\n <ul className=\"flex flex-wrap justify-between gap-x-6 gap-y-3\">\n {data.map((seg) => (\n <li key={seg.key} className=\"flex flex-col gap-1.5\">\n <span className=\"flex items-center gap-1.5 text-sm leading-none text-muted-foreground\">\n <span\n className=\"size-2.5 shrink-0 rounded-full\"\n style={{ backgroundColor: colorOf(seg.key) }}\n />\n {labelFor(seg.key)}\n </span>\n <span className=\"flex items-baseline gap-1.5 leading-none tabular-nums\">\n <span className=\"text-base font-semibold text-foreground\">\n {valueFormatter(seg.value)}\n </span>\n <span className=\"text-sm text-muted-foreground\">\n {pctOf(seg.value)}%\n </span>\n </span>\n </li>\n ))}\n </ul>\n )}\n </div>\n );\n }\n);\nCategoryBar.displayName = 'CategoryBar';\n\nexport { CategoryBar, categoryBarVariants };\n"],"names":["defaultFormat","value","categoryBarVariants","cva","CategoryBar","React","className","data","config","size","showLegend","showTooltip","tooltipContent","valueFormatter","defaultOpenIndex","ariaLabel","props","ref","chartId","total","sum","seg","labelFor","key","_a","labelTextFor","label","colorOf","pctOf","summary","jsxs","cn","jsx","ChartStyle","index","color","segment","Tooltip","TooltipTrigger","TooltipContent","Fragment"],"mappings":";;;;;;AAyBA,MAAMA,IAAgB,CAACC,MAAkBA,EAAM,eAAA,GAGzCC,IAAsBC,EAAI,qDAAqD;AAAA,EACnF,UAAU;AAAA,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":["'use client';\n\nimport * as React from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nimport { cn } from '@/lib/utils';\nimport { ChartStyle, type ChartConfig } from '../chart';\nimport { Tooltip, TooltipContent, TooltipTrigger } from '../tooltip';\n\n// A category bar: a single horizontal bar split into proportional colored\n// segments — one part-to-whole across a handful of categories, in one row\n// (onboarding stages, certification status, a rating scale). Unlike `Meter`\n// (one value per row, stacked into a bar list), all segments share the same bar.\n// It's a plain flex composition, not a recharts chart: each segment's width is\n// `value / total`, so exact proportions and the count/% legend are direct DOM,\n// with no axes/grid to hide. Segment colors are caller-supplied via `config`\n// (existing semantic `--ui-*` tokens); there is no chart palette tier yet.\n//\n// Colors are consumed through the same `--color-<key>` bridge the recharts\n// charts use: `ChartStyle` emits one custom property per config entry, so a\n// `theme: { light, dark }` entry works as well as a flat `color` — reading\n// `config[key].color` directly would render a themed config colorless. The\n// tooltip is portaled out of the bar's DOM, so its popup carries its own\n// `data-chart` scope + `ChartStyle` to keep the bridge resolvable there.\n\nconst defaultFormat = (value: number) => value.toLocaleString();\n\n// Track height only — the flex/rounded/overflow chrome is static.\nconst categoryBarVariants = cva('flex w-full overflow-hidden rounded-full bg-input', {\n variants: {\n size: {\n sm: 'h-1.5',\n md: 'h-2.5',\n lg: 'h-4',\n },\n },\n defaultVariants: {\n size: 'md',\n },\n});\n\nexport interface CategoryBarSegment {\n /** Key into `config` for this segment's label + color. */\n key: string;\n /** The segment's value — its width is this over the sum of all values. */\n value: number;\n}\n\n/** The resolved segment passed to a custom `tooltipContent` renderer. */\nexport interface CategoryBarTooltipContext extends CategoryBarSegment {\n /** Resolved `config` label (falls back to the key); may be any `ReactNode`. */\n label: React.ReactNode;\n /** Share of the total as a rounded percentage (0–100). */\n percent: number;\n /**\n * CSS color reference for the segment — the `var(--color-<key>)` bridge, which\n * resolves the config entry's `color` or its per-theme `theme` value. Usable\n * anywhere a CSS color is (e.g. a `style` background); not a literal value.\n */\n color: string;\n}\n\nexport interface CategoryBarProps\n extends Omit<React.ComponentProps<'div'>, 'children'>,\n VariantProps<typeof categoryBarVariants> {\n /** Ordered segments (left → right). Widths are proportional to `value`. */\n data: ReadonlyArray<CategoryBarSegment>;\n /** Maps each segment `key` to a `label` and `color` (an existing `--ui-*` token). */\n config: ChartConfig;\n /** Show the legend below the bar (color dot + label + value + %). */\n showLegend?: boolean;\n /** Show a hover tooltip per segment (dot + label + value + %). */\n showTooltip?: boolean;\n /**\n * Custom tooltip content per segment — replaces the default (dot + label +\n * `value · %`) inside the same card. Ignored when `showTooltip` is false.\n */\n tooltipContent?: (segment: CategoryBarTooltipContext) => React.ReactNode;\n /** Format the numeric value (legend + tooltip). Defaults to `toLocaleString()`. */\n valueFormatter?: (value: number) => string;\n /** Render the tooltip for this segment index initially open (VR/testing). */\n defaultOpenIndex?: number;\n /**\n * Accessible summary of the whole bar. Defaults to a `label value` list built\n * from the data; pass a fuller sentence for screen readers if you have one.\n */\n 'aria-label'?: string;\n}\n\n/**\n * One segment's hover card.\n *\n * It re-declares `data-chart` and re-renders `ChartStyle` because the popup is\n * portaled out of the bar: outside that subtree the `--color-*` bridge the\n * swatch reads has nothing to resolve against.\n */\nfunction CategoryBarSegmentTooltip({\n chartId,\n config,\n color,\n label,\n percent,\n segmentKey,\n value,\n valueFormatter,\n renderContent,\n}: {\n chartId: string;\n config: ChartConfig;\n color: string;\n label: React.ReactNode;\n percent: number;\n segmentKey: string;\n value: number;\n valueFormatter: (value: number) => string;\n // Not named `render`: in this package that name is reserved for Base UI's\n // polymorphic composition prop (see `<TooltipTrigger render={…} />` below).\n renderContent?: (segment: CategoryBarTooltipContext) => React.ReactNode;\n}) {\n return (\n <TooltipContent\n data-chart={chartId}\n className={cn(\n 'border border-border bg-background text-foreground shadow-md',\n !renderContent && 'flex items-center gap-2'\n )}\n >\n <ChartStyle id={chartId} config={config} />\n {renderContent ? (\n renderContent({ key: segmentKey, value, label, percent, color })\n ) : (\n <>\n <span\n className=\"size-2.5 shrink-0 rounded-full\"\n style={{ backgroundColor: color }}\n />\n <span className=\"font-semibold\">{label}</span>\n <span className=\"text-muted-foreground tabular-nums\">\n {valueFormatter(value)} · {percent}%\n </span>\n </>\n )}\n </TooltipContent>\n );\n}\n\nconst CategoryBar = React.forwardRef<HTMLDivElement, CategoryBarProps>(\n (\n {\n className,\n data,\n config,\n size,\n showLegend = false,\n showTooltip = true,\n tooltipContent,\n valueFormatter = defaultFormat,\n defaultOpenIndex,\n 'aria-label': ariaLabel,\n ...props\n },\n ref\n ) => {\n const uniqueId = React.useId();\n const chartId = `chart-${uniqueId.replace(/:/g, '')}`;\n\n const total = data.reduce((sum, seg) => sum + seg.value, 0);\n const labelFor = (key: string): React.ReactNode => config[key]?.label ?? key;\n // The aria-label has to be a plain string, so a rich (element) label can't\n // be used there — fall back to the key rather than stringifying it into\n // \"[object Object]\".\n const labelTextFor = (key: string) => {\n const label = config[key]?.label;\n return typeof label === 'string' || typeof label === 'number'\n ? String(label)\n : key;\n };\n const colorOf = (key: string) => `var(--color-${key})`;\n const pctOf = (value: number) =>\n total > 0 ? Math.round((value / total) * 100) : 0;\n\n // A locale-neutral fallback: \"<label> <value>\" pairs. Consumers can pass a\n // fuller `aria-label` sentence.\n const summary =\n ariaLabel ??\n data\n .map((seg) => `${labelTextFor(seg.key)} ${valueFormatter(seg.value)}`)\n .join(', ');\n\n return (\n <div\n ref={ref}\n data-chart={chartId}\n className={cn('flex w-full flex-col gap-3', className)}\n {...props}\n >\n <ChartStyle id={chartId} config={config} />\n <div className={categoryBarVariants({ size })} role=\"img\" aria-label={summary}>\n {data.map((seg, index) => {\n const color = colorOf(seg.key);\n // flex-grow proportional to value with a zero basis → widths are\n // exactly value/total; a zero-value segment collapses.\n const segment = (\n <div\n key={seg.key}\n className=\"h-full min-w-0\"\n style={{ flex: `${seg.value} 0 0%`, backgroundColor: color }}\n />\n );\n\n if (!showTooltip) return segment;\n\n return (\n <Tooltip key={seg.key} defaultOpen={index === defaultOpenIndex}>\n <TooltipTrigger render={segment} />\n <CategoryBarSegmentTooltip\n chartId={chartId}\n config={config}\n color={color}\n label={labelFor(seg.key)}\n percent={pctOf(seg.value)}\n segmentKey={seg.key}\n value={seg.value}\n valueFormatter={valueFormatter}\n renderContent={tooltipContent}\n />\n </Tooltip>\n );\n })}\n </div>\n\n {showLegend && (\n <ul className=\"flex flex-wrap justify-between gap-x-6 gap-y-3\">\n {data.map((seg) => (\n <li key={seg.key} className=\"flex flex-col gap-1.5\">\n <span className=\"flex items-center gap-1.5 text-sm leading-none text-muted-foreground\">\n <span\n className=\"size-2.5 shrink-0 rounded-sm\"\n style={{ backgroundColor: colorOf(seg.key) }}\n />\n {labelFor(seg.key)}\n </span>\n <span className=\"flex items-baseline gap-1.5 leading-none tabular-nums\">\n <span className=\"text-base font-semibold text-foreground\">\n {valueFormatter(seg.value)}\n </span>\n <span className=\"text-sm text-muted-foreground\">\n {pctOf(seg.value)}%\n </span>\n </span>\n </li>\n ))}\n </ul>\n )}\n </div>\n );\n }\n);\nCategoryBar.displayName = 'CategoryBar';\n\nexport { CategoryBar, categoryBarVariants };\n"],"names":["defaultFormat","value","categoryBarVariants","cva","CategoryBarSegmentTooltip","chartId","config","color","label","percent","segmentKey","valueFormatter","renderContent","jsxs","TooltipContent","cn","jsx","ChartStyle","Fragment","CategoryBar","React","className","data","size","showLegend","showTooltip","tooltipContent","defaultOpenIndex","ariaLabel","props","ref","total","sum","seg","labelFor","key","_a","labelTextFor","colorOf","pctOf","summary","index","segment","Tooltip","TooltipTrigger"],"mappings":";;;;;;AAyBA,MAAMA,IAAgB,CAACC,MAAkBA,EAAM,eAAA,GAGzCC,IAAsBC,EAAI,qDAAqD;AAAA,EACnF,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IAAA;AAAA,EACN;AAAA,EAEF,iBAAiB;AAAA,IACf,MAAM;AAAA,EAAA;AAEV,CAAC;AAyDD,SAASC,EAA0B;AAAA,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A,CACF;AAAA,UAAA,KAfOA,EAAI,GAgBb,CACD,EAAA,CACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AACAd,EAAY,cAAc;"}
@@ -1,4 +1,4 @@
1
- function i(t) {
1
+ function _(t) {
2
2
  switch (t) {
3
3
  case "auto":
4
4
  return ["auto", "auto"];
@@ -10,31 +10,161 @@ function i(t) {
10
10
  return;
11
11
  }
12
12
  }
13
- const r = (t) => {
13
+ function S(t) {
14
+ if (t != null)
15
+ return t < 0 ? "end" : "start";
16
+ }
17
+ function p(t, n) {
18
+ if (!(!t && n == null))
19
+ return 30 + (n != null ? 20 : 0) + (t ? 18 : 0);
20
+ }
21
+ function E(t, n = "insideBottom", i = 0) {
22
+ if (t)
23
+ return { value: t, position: n, offset: i };
24
+ }
25
+ function L(t, n = "left") {
26
+ if (t)
27
+ return {
28
+ value: t,
29
+ angle: n === "left" ? -90 : 90,
30
+ position: n === "left" ? "insideLeft" : "insideRight",
31
+ style: { textAnchor: "middle" }
32
+ };
33
+ }
34
+ function T(t, n, i) {
35
+ if (n.length === 0) return;
36
+ const o = (e, f) => {
37
+ if (e === void 0) return f;
38
+ const a = n.findIndex((d) => d[i] === e);
39
+ return a !== -1 ? a : typeof e == "number" && Number.isInteger(e) && e >= 0 && e < n.length ? e : -1;
40
+ }, r = o(t.from, 0), s = o(t.to, n.length - 1);
41
+ if (!(r === -1 || s === -1 || r > s))
42
+ return [r, s];
43
+ }
44
+ function h(t) {
45
+ const { animate: n = !1, animationDuration: i, animationBegin: o, animationEasing: r } = t;
46
+ return {
47
+ isAnimationActive: n ? "auto" : !1,
48
+ ...i !== void 0 ? { animationDuration: i } : {},
49
+ ...o !== void 0 ? { animationBegin: o } : {},
50
+ ...r !== void 0 ? { animationEasing: r } : {}
51
+ };
52
+ }
53
+ const l = "fill-[var(--ui-text-on-surface-primary)]!", m = "fill-[var(--ui-text-on-status-strong-neutral)]!", v = 12, y = {
54
+ top: 16,
55
+ right: 24,
56
+ bottom: 5,
57
+ left: 12
58
+ }, A = /* @__PURE__ */ new Set([
59
+ "center",
60
+ "centerTop",
61
+ "centerBottom",
62
+ "insideTop",
63
+ "insideBottom",
64
+ "insideLeft",
65
+ "insideRight",
66
+ "insideStart",
67
+ "insideEnd",
68
+ "end"
69
+ ]);
70
+ function C(t) {
71
+ const { labelPosition: n, isStacked: i = !1, growingEnd: o = "top" } = t;
72
+ return n !== void 0 ? n : i ? "center" : o;
73
+ }
74
+ function x(t, n = {}) {
75
+ return n.translucentSeries ? l : A.has(t) ? m : l;
76
+ }
77
+ function I(t) {
78
+ if (t)
79
+ return (n) => n == null ? "" : t(n);
80
+ }
81
+ function N(t) {
82
+ return t ? Array.isArray(t) ? t : [t] : [];
83
+ }
84
+ function B(t, n, i) {
85
+ if (!t) return;
86
+ if (typeof t.value == "number") return t.value;
87
+ if (!t.average) return;
88
+ const o = typeof t.average == "string" ? [t.average] : i, r = n.flatMap(
89
+ (s) => o.map((e) => s[e]).filter((e) => typeof e == "number")
90
+ );
91
+ if (r.length !== 0)
92
+ return r.reduce((s, e) => s + e, 0) / r.length;
93
+ }
94
+ const c = "var(--ui-text-on-surface-secondary)";
95
+ function F(t, n = "insideTopRight") {
96
+ return {
97
+ stroke: c,
98
+ strokeDasharray: "4 4",
99
+ ifOverflow: "extendDomain",
100
+ label: t ? {
101
+ value: t,
102
+ position: n,
103
+ fill: c,
104
+ fontSize: v
105
+ } : void 0
106
+ };
107
+ }
108
+ const g = 28, R = "Chart range selector";
109
+ function H({
110
+ brushHeight: t,
111
+ brushAriaLabel: n = R
112
+ }) {
113
+ return {
114
+ // recharts drops the brush entirely when height <= 0, which would turn
115
+ // `showBrush` into a silent no-op — treat a non-positive height as unset.
116
+ height: t != null && t > 0 ? t : g,
117
+ fill: "var(--ui-background-surface-secondary)",
118
+ stroke: "var(--ui-text-on-surface-secondary)",
119
+ travellerWidth: 8,
120
+ ariaLabel: n
121
+ };
122
+ }
123
+ const u = (t) => {
14
124
  if (typeof t == "string" && t.trim() === "") return null;
15
125
  const n = typeof t == "number" ? t : Number(t);
16
126
  return Number.isFinite(n) ? n : null;
17
- }, u = (t) => {
18
- const n = r(t);
127
+ }, k = (t) => {
128
+ const n = u(t);
19
129
  return n === null ? String(t) : new Intl.NumberFormat("en", {
20
130
  notation: "compact",
21
131
  maximumFractionDigits: 1
22
132
  }).format(n);
23
- }, c = (t) => {
24
- const n = r(t);
133
+ }, b = (t) => {
134
+ const n = u(t);
25
135
  return n === null ? String(t) : `${n}%`;
26
136
  };
27
- function m(t, n = "en") {
28
- const a = new Intl.NumberFormat(n, t);
137
+ function O(t, n = "en") {
138
+ const i = new Intl.NumberFormat(n, t);
29
139
  return (o) => {
30
- const e = r(o);
31
- return e === null ? String(o) : a.format(e);
140
+ const r = u(o);
141
+ return r === null ? String(o) : i.format(r);
32
142
  };
33
143
  }
34
144
  export {
35
- m as createTickFormatter,
36
- u as formatCompactNumber,
37
- c as formatPercent,
38
- i as resolveAxisDomain
145
+ R as CHART_BRUSH_ARIA_LABEL,
146
+ g as CHART_BRUSH_HEIGHT,
147
+ l as CHART_LABEL_FILL_CLASS,
148
+ m as CHART_LABEL_FILL_ON_SERIES_CLASS,
149
+ v as CHART_LABEL_FONT_SIZE,
150
+ y as CHART_LABEL_MARGIN,
151
+ c as CHART_REFERENCE_LINE_STROKE,
152
+ O as createTickFormatter,
153
+ k as formatCompactNumber,
154
+ b as formatPercent,
155
+ h as resolveAnimation,
156
+ _ as resolveAxisDomain,
157
+ H as resolveBrushProps,
158
+ C as resolveCartesianLabelPosition,
159
+ T as resolveCategoryRange,
160
+ B as resolveChartReferenceValue,
161
+ x as resolveLabelFillClass,
162
+ F as resolveReferenceLineProps,
163
+ S as resolveRotatedTickAnchor,
164
+ p as resolveXAxisHeight,
165
+ E as resolveXAxisTitle,
166
+ L as resolveYAxisTitle,
167
+ I as toLabelFormatter,
168
+ N as toReferenceLineList
39
169
  };
40
170
  //# sourceMappingURL=chart-format.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chart-format.js","sources":["../../../../src/components/ui/chart/chart-format.ts"],"sourcesContent":["// Shared axis helpers for the cartesian chart components (BarChart, LineChart,\n// AreaChart, ComposedChart, ScatterChart, ConfidenceCone, Histogram). Three\n// concerns live here so every chart formats + toggles axes the same way rather\n// than each reimplementing it:\n//\n// 1. `CartesianChartProps` — the common axis knobs each cartesian chart mixes\n// into its own props (show/hide either axis, per-axis tick formatting).\n// 2. A small set of tick formatters (+ a factory) callers pass to\n// `xTickFormatter` / `yTickFormatter`.\n// 3. `resolveAxisDomain` — maps the `yAxisDomain` preset to a recharts\n// `domain`, shared so all 7 charts can't drift apart on it.\n//\n// These format only the axis *tick labels*; series colors and tokens are\n// unaffected. Formatters coerce to a number and pass non-numeric values through\n// untouched (a category axis stays readable if a formatter is applied to it).\n\nimport type { AxisDomainItem } from 'recharts';\n\nimport type { ChartTooltipContentType } from './chart';\n\n/** A recharts-compatible tick formatter: `(value, index) => label`. */\nexport type TickFormatter = (value: number | string, index?: number) => string;\n\n/**\n * Props shared by every cartesian chart (Bar, Line, Area, Composed, Scatter,\n * ConfidenceCone, Histogram) — chrome toggles, axis titles/units, tick\n * formatting/visibility, and grid trim. All optional. `showLegend` and `xUnit`\n * are deliberately *not* here: `showLegend` doesn't apply to `Histogram` and\n * `xUnit` only to charts with a numeric X axis, so they stay per-component.\n */\nexport interface CartesianChartProps {\n /** Render the CartesianGrid. Defaults to `true`. */\n showGrid?: boolean;\n /** Render the hover tooltip. Defaults to `true`. */\n showTooltip?: boolean;\n /**\n * Replace the default tooltip. Pass a configured `ChartTooltipContent` (from\n * this library) — e.g. with a `formatter` / `labelFormatter` — to customize it\n * without composing recharts yourself. Ignored when `showTooltip` is false.\n */\n tooltipContent?: ChartTooltipContentType;\n /** Title rendered beneath the X axis. */\n xAxisLabel?: string;\n /** Title rendered beside the Y axis (rotated). */\n yAxisLabel?: string;\n /**\n * Unit suffix appended to the Y axis's tick values (recharts `unit`) — applies\n * when the Y axis is the numeric one. `BarChart` with\n * `orientation=\"horizontal\"` puts the values on X instead; use `xUnit` there.\n */\n yUnit?: string;\n /** Show the X axis (its ticks + title). Defaults to `true`. */\n showXAxis?: boolean;\n /** Show the Y axis (its ticks + title). Defaults to `true`. */\n showYAxis?: boolean;\n /** Format each X-axis tick value — e.g. `formatCompactNumber` or a `createTickFormatter(...)`. */\n xTickFormatter?: TickFormatter;\n /** Format each Y-axis tick value — e.g. `formatCompactNumber` or a `createTickFormatter(...)`. */\n yTickFormatter?: TickFormatter;\n /**\n * Rotate the X-axis tick labels by this many degrees. A negative angle (e.g.\n * `-45`) tilts them up toward the right; the tick anchor + axis height adjust\n * to keep long labels readable.\n */\n xAxisAngle?: number;\n /**\n * X-axis tick density — a recharts placement strategy, or a fixed number of\n * ticks to *skip* between two rendered ones (recharts `interval`: `0` shows\n * every tick, `1` every other one, `2` every third, …).\n */\n xAxisInterval?:\n | number\n | 'preserveStart'\n | 'preserveEnd'\n | 'preserveStartEnd'\n | 'equidistantPreserveStart';\n /**\n * Desired number of ticks on the value axis (recharts `tickCount`; a hint, not\n * exact). Applies to whichever axis holds the values — Y for most charts, X for\n * `BarChart` with `orientation=\"horizontal\"`.\n */\n yAxisTickCount?: number;\n /**\n * Value-axis domain preset. Applies to whichever axis holds the values — Y for\n * most charts, X for `BarChart` with `orientation=\"horizontal\"`.\n *\n * - `auto` — fit the data at both ends; the axis need not include 0.\n * - `zero` — anchor the axis at 0. This is also recharts' behavior when the\n * prop is omitted, so it's the explicit form of the default.\n * - `dataMin-dataMax` — tight to the data, with no padding.\n */\n yAxisDomain?: 'auto' | 'dataMin-dataMax' | 'zero';\n /** Draw grid lines dashed instead of solid. */\n gridDashed?: boolean;\n /** Show horizontal grid lines. Defaults to each chart's own default when unset. */\n gridHorizontal?: boolean;\n /** Show vertical grid lines. Defaults to each chart's own default when unset. */\n gridVertical?: boolean;\n}\n\n/**\n * Map a `yAxisDomain` preset to a recharts `domain`. Shared by all 7 cartesian\n * charts, and applied to whichever axis holds the values (X for horizontal bars).\n *\n * `undefined` (no preset) is left to recharts, whose default is `[0, 'auto']` —\n * i.e. already zero-anchored. That's why `auto` has to be spelled out as\n * `['auto', 'auto']`: passing `undefined` for it would silently anchor at 0 and\n * make the preset indistinguishable from `zero`.\n */\nexport function resolveAxisDomain(\n preset: 'auto' | 'dataMin-dataMax' | 'zero' | undefined\n): Readonly<[AxisDomainItem, AxisDomainItem]> | undefined {\n switch (preset) {\n case 'auto':\n return ['auto', 'auto'];\n case 'zero':\n return [0, 'auto'];\n case 'dataMin-dataMax':\n return ['dataMin', 'dataMax'];\n default:\n return undefined;\n }\n}\n\nconst toNumber = (value: number | string): number | null => {\n // `Number('')` and `Number(' ')` are 0, not NaN — so blank strings have to be\n // rejected before the finite check, or an empty tick label would render \"0\".\n if (typeof value === 'string' && value.trim() === '') return null;\n const n = typeof value === 'number' ? value : Number(value);\n return Number.isFinite(n) ? n : null;\n};\n\n/**\n * Compact thousands/millions: `1234 → \"1.2K\"`, `1_500_000 → \"1.5M\"`. Non-numeric\n * values (including blank strings) pass through unchanged. Use for large-count\n * axes (revenue, users, …).\n *\n * Formats in `en`. For another locale use\n * `createTickFormatter({ notation: 'compact', maximumFractionDigits: 1 }, locale)`.\n */\nexport const formatCompactNumber: TickFormatter = (value) => {\n const n = toNumber(value);\n if (n === null) return String(value);\n return new Intl.NumberFormat('en', {\n notation: 'compact',\n maximumFractionDigits: 1,\n }).format(n);\n};\n\n/**\n * Append a percent sign to an already-scaled value: `41.8 → \"41.8%\"`. (The value\n * is treated as a percentage, not a 0–1 fraction.) Non-numeric values (including\n * blank strings) pass through.\n *\n * Appends a bare `%`, which is not how every locale writes it. For locale-correct\n * output on values that really are fractions, use\n * `createTickFormatter({ style: 'percent' }, locale)`.\n */\nexport const formatPercent: TickFormatter = (value) => {\n const n = toNumber(value);\n if (n === null) return String(value);\n return `${n}%`;\n};\n\n/**\n * Build a tick formatter from `Intl.NumberFormat` options — the escape hatch for\n * currency, fixed decimals, or a specific locale. E.g.\n * `createTickFormatter({ style: 'currency', currency: 'USD', notation: 'compact' })`\n * → `146500 → \"$147K\"`. Non-numeric values pass through unchanged.\n */\nexport function createTickFormatter(\n options: Intl.NumberFormatOptions,\n locale = 'en'\n): TickFormatter {\n const nf = new Intl.NumberFormat(locale, options);\n return (value) => {\n const n = toNumber(value);\n return n === null ? String(value) : nf.format(n);\n };\n}\n"],"names":["resolveAxisDomain","preset","toNumber","value","formatCompactNumber","formatPercent","createTickFormatter","options","locale","nf","n"],"mappings":"AA6GO,SAASA,EACdC,GACwD;AACxD,UAAQA,GAAA;AAAA,IACN,KAAK;AACH,aAAO,CAAC,QAAQ,MAAM;AAAA,IACxB,KAAK;AACH,aAAO,CAAC,GAAG,MAAM;AAAA,IACnB,KAAK;AACH,aAAO,CAAC,WAAW,SAAS;AAAA,IAC9B;AACE;AAAA,EAAO;AAEb;AAEA,MAAMC,IAAW,CAACC,MAA0C;AAG1D,MAAI,OAAOA,KAAU,YAAYA,EAAM,KAAA,MAAW,GAAI,QAAO;AAC7D,QAAM,IAAI,OAAOA,KAAU,WAAWA,IAAQ,OAAOA,CAAK;AAC1D,SAAO,OAAO,SAAS,CAAC,IAAI,IAAI;AAClC,GAUaC,IAAqC,CAACD,MAAU;AAC3D,QAAM,IAAID,EAASC,CAAK;AACxB,SAAI,MAAM,OAAa,OAAOA,CAAK,IAC5B,IAAI,KAAK,aAAa,MAAM;AAAA,IACjC,UAAU;AAAA,IACV,uBAAuB;AAAA,EAAA,CACxB,EAAE,OAAO,CAAC;AACb,GAWaE,IAA+B,CAACF,MAAU;AACrD,QAAM,IAAID,EAASC,CAAK;AACxB,SAAI,MAAM,OAAa,OAAOA,CAAK,IAC5B,GAAG,CAAC;AACb;AAQO,SAASG,EACdC,GACAC,IAAS,MACM;AACf,QAAMC,IAAK,IAAI,KAAK,aAAaD,GAAQD,CAAO;AAChD,SAAO,CAACJ,MAAU;AAChB,UAAMO,IAAIR,EAASC,CAAK;AACxB,WAAOO,MAAM,OAAO,OAAOP,CAAK,IAAIM,EAAG,OAAOC,CAAC;AAAA,EACjD;AACF;"}
1
+ {"version":3,"file":"chart-format.js","sources":["../../../../src/components/ui/chart/chart-format.ts"],"sourcesContent":["// Shared axis helpers for the cartesian chart components (BarChart, LineChart,\n// AreaChart, ComposedChart, ScatterChart, ConfidenceCone, Histogram). Three\n// concerns live here so every chart formats + toggles axes the same way rather\n// than each reimplementing it:\n//\n// 1. `CartesianChartProps` — the common axis knobs each cartesian chart mixes\n// into its own props (show/hide either axis, per-axis tick formatting).\n// 2. A small set of tick formatters (+ a factory) callers pass to\n// `xTickFormatter` / `yTickFormatter`.\n// 3. `resolveAxisDomain` — maps the `yAxisDomain` preset to a recharts\n// `domain`, shared so all 7 charts can't drift apart on it.\n//\n// These format only the axis *tick labels*; series colors and tokens are\n// unaffected. Formatters coerce to a number and pass non-numeric values through\n// untouched (a category axis stays readable if a formatter is applied to it).\n\nimport type { AxisDomainItem } from 'recharts';\n\nimport type { ChartTooltipContentType } from './chart';\n\n/** A recharts-compatible tick formatter: `(value, index) => label`. */\nexport type TickFormatter = (value: number | string, index?: number) => string;\n\n/**\n * Props shared by every cartesian chart (Bar, Line, Area, Composed, Scatter,\n * ConfidenceCone, Histogram) — chrome toggles, axis titles/units, tick\n * formatting/visibility, and grid trim. All optional. `showLegend` and `xUnit`\n * are deliberately *not* here: `showLegend` doesn't apply to `Histogram` and\n * `xUnit` only to charts with a numeric X axis, so they stay per-component.\n */\nexport interface CartesianChartProps {\n /** Render the CartesianGrid. Defaults to `true`. */\n showGrid?: boolean;\n /** Render the hover tooltip. Defaults to `true`. */\n showTooltip?: boolean;\n /**\n * Replace the default tooltip. Pass a configured `ChartTooltipContent` (from\n * this library) — e.g. with a `formatter` / `labelFormatter` — to customize it\n * without composing recharts yourself. Ignored when `showTooltip` is false.\n */\n tooltipContent?: ChartTooltipContentType;\n /** Title rendered beneath the X axis. */\n xAxisLabel?: string;\n /** Title rendered beside the Y axis (rotated). */\n yAxisLabel?: string;\n /**\n * Unit suffix appended to the Y axis's tick values (recharts `unit`) — applies\n * when the Y axis is the numeric one. `BarChart` with\n * `orientation=\"horizontal\"` puts the values on X instead; use `xUnit` there.\n */\n yUnit?: string;\n /** Show the X axis (its ticks + title). Defaults to `true`. */\n showXAxis?: boolean;\n /** Show the Y axis (its ticks + title). Defaults to `true`. */\n showYAxis?: boolean;\n /** Format each X-axis tick value — e.g. `formatCompactNumber` or a `createTickFormatter(...)`. */\n xTickFormatter?: TickFormatter;\n /** Format each Y-axis tick value — e.g. `formatCompactNumber` or a `createTickFormatter(...)`. */\n yTickFormatter?: TickFormatter;\n /**\n * Rotate the X-axis tick labels by this many degrees. A negative angle (e.g.\n * `-45`) tilts them up toward the right; the tick anchor + axis height adjust\n * to keep long labels readable.\n */\n xAxisAngle?: number;\n /**\n * X-axis tick density — a recharts placement strategy, or a fixed number of\n * ticks to *skip* between two rendered ones (recharts `interval`: `0` shows\n * every tick, `1` every other one, `2` every third, …).\n */\n xAxisInterval?:\n | number\n | 'preserveStart'\n | 'preserveEnd'\n | 'preserveStartEnd'\n | 'equidistantPreserveStart';\n /**\n * Desired number of ticks on the value axis (recharts `tickCount`; a hint, not\n * exact). Applies to whichever axis holds the values — Y for most charts, X for\n * `BarChart` with `orientation=\"horizontal\"`.\n */\n yAxisTickCount?: number;\n /**\n * Value-axis domain preset. Applies to whichever axis holds the values — Y for\n * most charts, X for `BarChart` with `orientation=\"horizontal\"`.\n *\n * - `auto` — fit the data at both ends; the axis need not include 0.\n * - `zero` — anchor the axis at 0. This is also recharts' behavior when the\n * prop is omitted, so it's the explicit form of the default.\n * - `dataMin-dataMax` — tight to the data, with no padding.\n */\n yAxisDomain?: 'auto' | 'dataMin-dataMax' | 'zero';\n /** Draw grid lines dashed instead of solid. */\n gridDashed?: boolean;\n /** Show horizontal grid lines. Defaults to each chart's own default when unset. */\n gridHorizontal?: boolean;\n /** Show vertical grid lines. Defaults to each chart's own default when unset. */\n gridVertical?: boolean;\n}\n\n/**\n * Map a `yAxisDomain` preset to a recharts `domain`. Shared by all 7 cartesian\n * charts, and applied to whichever axis holds the values (X for horizontal bars).\n *\n * `undefined` (no preset) is left to recharts, whose default is `[0, 'auto']` —\n * i.e. already zero-anchored. That's why `auto` has to be spelled out as\n * `['auto', 'auto']`: passing `undefined` for it would silently anchor at 0 and\n * make the preset indistinguishable from `zero`.\n */\nexport function resolveAxisDomain(\n preset: 'auto' | 'dataMin-dataMax' | 'zero' | undefined\n): Readonly<[AxisDomainItem, AxisDomainItem]> | undefined {\n switch (preset) {\n case 'auto':\n return ['auto', 'auto'];\n case 'zero':\n return [0, 'auto'];\n case 'dataMin-dataMax':\n return ['dataMin', 'dataMax'];\n default:\n return undefined;\n }\n}\n\n/**\n * `text-anchor` for a rotated X tick row, so the tick's text ends (or begins) at\n * the tick it labels instead of straddling it. Shared by all 7 cartesian charts.\n *\n * A tick rotated anti-clockwise trails off to the lower left, so it must be\n * anchored at its end; a clockwise one trails to the lower right and is anchored\n * at its start. Only an *omitted* angle keeps recharts' own default (`middle`):\n * the branch is on `angle < 0`, so `angle={0}` anchors at `start` like any\n * clockwise rotation. A caller that normalises \"upright\" to `0` instead of\n * leaving `xAxisAngle` off therefore gets the rotated-tick treatment — here and\n * in `resolveXAxisHeight`.\n */\nexport function resolveRotatedTickAnchor(\n angle: number | undefined\n): 'start' | 'end' | undefined {\n if (angle == null) return undefined;\n return angle < 0 ? 'end' : 'start';\n}\n\n/**\n * Height to reserve for the X tick row, or `undefined` to keep recharts' own\n * default. Shared by all 7 cartesian charts.\n *\n * recharts' default 30 covers one upright tick row and nothing else, so a\n * rotated row (+20) and an axis title (+18) each need their own allowance. The\n * two are additive rather than exclusive — a chart can rotate its ticks *and*\n * title the axis, which a label-or-angle ternary under-allocates.\n *\n * The +20 keys off the angle being *present*, not non-zero, so `angle={0}`\n * reserves the rotated row's height as well — the same edge case\n * `resolveRotatedTickAnchor` has, kept consistent between the two.\n */\nexport function resolveXAxisHeight(\n label: string | undefined,\n angle: number | undefined\n): number | undefined {\n if (!label && angle == null) return undefined;\n return 30 + (angle != null ? 20 : 0) + (label ? 18 : 0);\n}\n\n/**\n * recharts `label` for an X axis title, placed below the tick row. Shared by all\n * 7 cartesian charts; `insideTop` is for a secondary scale on the top edge.\n */\nexport function resolveXAxisTitle(\n label: string | undefined,\n position: 'insideBottom' | 'insideTop' = 'insideBottom',\n offset = 0\n) {\n if (!label) return undefined;\n return { value: label, position, offset };\n}\n\n/**\n * recharts `label` for a rotated value-axis title, angled so it reads from the\n * outside in — upward on a left axis (the convention), downward on a right one,\n * where -90° would put the text's baseline against the plot. Shared by all 7\n * cartesian charts; only `ComposedChart` currently uses the right-hand side.\n */\nexport function resolveYAxisTitle(\n label: string | undefined,\n orientation: 'left' | 'right' = 'left'\n) {\n if (!label) return undefined;\n return {\n value: label,\n angle: orientation === 'left' ? -90 : 90,\n position:\n orientation === 'left' ? ('insideLeft' as const) : ('insideRight' as const),\n style: { textAnchor: 'middle' as const },\n };\n}\n\n/**\n * A category range on a cartesian chart: `from`/`to` accept either the\n * category's value (an `xKey` cell, e.g. `'Sep'`) or its 0-based row index. Both\n * ends are inclusive, and either can be omitted to run to that end of the data.\n * Shared by the charts that scope something to a slice of the categories — a\n * reference band, a per-series style override.\n */\nexport interface ChartCategoryRange {\n from?: string | number;\n to?: string | number;\n}\n\n/**\n * Resolve a category range to inclusive row indices. A bound is either the\n * category's own value (matched against the `xKey` cell) or a 0-based index;\n * an omitted bound runs to that end of the data. Returns `undefined` when the\n * data is empty or the range resolves to nothing (an unknown value, or a `to`\n * that lands before its `from`).\n *\n * Exported for unit tests; not part of the package's public API.\n */\nexport function resolveCategoryRange(\n range: ChartCategoryRange,\n data: ReadonlyArray<Record<string, unknown>>,\n xKey: string\n): [number, number] | undefined {\n if (data.length === 0) return undefined;\n\n const resolve = (bound: string | number | undefined, fallback: number) => {\n if (bound === undefined) return fallback;\n // A numeric bound is an index unless the categories are numbers themselves,\n // in which case matching a category value is the more useful reading.\n const asValue = data.findIndex((row) => row[xKey] === bound);\n if (asValue !== -1) return asValue;\n if (typeof bound === 'number' && Number.isInteger(bound)) {\n return bound >= 0 && bound < data.length ? bound : -1;\n }\n return -1;\n };\n\n const start = resolve(range.from, 0);\n const end = resolve(range.to, data.length - 1);\n if (start === -1 || end === -1 || start > end) return undefined;\n return [start, end];\n}\n\n/**\n * Which value axis a series is measured against, on a chart that can carry two.\n *\n * `secondary` is the opt-in: the second axis exists only when at least one series\n * asks for it, so a chart whose series all leave this unset keeps the single\n * shared scale — and its recharts output — exactly as before.\n */\nexport type ChartYAxisTarget = 'primary' | 'secondary';\n\n/**\n * Second value-axis props, for a chart whose series can be measured on two\n * independent scales. **Only `ComposedChart` implements these today.** It is the\n * one chart in the suite where two scales are unambiguous: its series already\n * differ in mark type, so a bar read against the left axis and a line against the\n * right can't be mistaken for two marks sharing one. On a single-mark chart (Bar,\n * Area) two scales invite comparing heights that aren't comparable, which is why\n * these props are not mixed into `CartesianChartProps`.\n *\n * The primary axis is configured through `CartesianChartProps` (`yAxisLabel`,\n * `yUnit`, `yTickFormatter`, `yAxisTickCount`, `yAxisDomain`, `showYAxis`); every\n * `secondary*` prop here is its counterpart on the second axis, so the two scales\n * format and bound themselves independently, and each is inert until a series\n * selects that axis.\n *\n * `yAxisOrientation` is the exception on both counts: it places the *primary*\n * axis, and it applies whether or not a second one exists. It lives here because\n * it is only meaningful once a chart can mirror a pair of axes — a single-axis\n * chart has no second side to give up.\n */\nexport interface SecondaryYAxisProps {\n /**\n * Which side the *primary* value axis sits on. Defaults to `left`. The secondary\n * axis always takes the opposite side. Unlike the `secondary*` props below, this\n * one applies to a single-scale chart too.\n *\n * Inert on a chart whose marks grow horizontally: the value axis is X there, so\n * the primary sits along the bottom edge and the secondary along the top, and\n * neither has a left/right side to pick.\n */\n yAxisOrientation?: 'left' | 'right';\n /**\n * Show the secondary axis's ticks + title. Defaults to `true`. Setting it false\n * keeps the second *scale* (series still measure against it) and only drops its\n * chrome — the same meaning `showYAxis` has for the primary axis.\n */\n showSecondaryYAxis?: boolean;\n /** Title rendered beside the secondary axis (rotated). */\n secondaryYAxisLabel?: string;\n /** Unit suffix appended to the secondary axis's tick values (recharts `unit`). */\n secondaryYUnit?: string;\n /** Format each secondary-axis tick value — the counterpart of `yTickFormatter`. */\n secondaryYTickFormatter?: TickFormatter;\n /** Desired number of ticks on the secondary axis (recharts `tickCount`; a hint, not exact). */\n secondaryYAxisTickCount?: number;\n /** Domain preset for the secondary axis — same presets as `yAxisDomain`. */\n secondaryYAxisDomain?: 'auto' | 'dataMin-dataMax' | 'zero';\n}\n\n/**\n * How a series interpolates between its points (recharts `type`), shared by the\n * Line and Area families so both offer the same set:\n *\n * - `linear` — straight segments between points.\n * - `monotone` — smoothed, without overshooting a point's value.\n * - `natural` — a natural cubic spline; smoother than `monotone`, but it may\n * overshoot, so read it as a trend rather than exact values.\n * - `basis` — a B-spline that is *not* required to pass through the points at\n * all; the smoothest option, and the least literal.\n * - `step` — right-angle segments, changing value at the midpoint between two\n * points; `stepBefore` changes at the leading point and `stepAfter` at the\n * trailing one.\n */\nexport type ChartCurveType =\n | 'linear'\n | 'monotone'\n | 'natural'\n | 'basis'\n | 'step'\n | 'stepBefore'\n | 'stepAfter';\n\n/** recharts animation easing curves. */\nexport type ChartAnimationEasing =\n | 'ease'\n | 'ease-in'\n | 'ease-out'\n | 'ease-in-out'\n | 'linear';\n\n/**\n * Entrance-animation props shared by *every* chart type (not just the cartesian\n * ones) — charts hardcode `isAnimationActive={false}` otherwise. All optional and\n * off by default, so an unset chart renders byte-identically to before (and its\n * VR baselines stay stable). Spread `resolveAnimation(props)` onto each series.\n */\nexport interface ChartAnimationProps {\n /** Enable entrance animation. Defaults to `false` (keeps output/baselines stable). */\n animate?: boolean;\n /** Animation duration in ms (recharts `animationDuration`). */\n animationDuration?: number;\n /** Delay before the animation starts, in ms (recharts `animationBegin`). */\n animationBegin?: number;\n /** Easing curve (recharts `animationEasing`). */\n animationEasing?: ChartAnimationEasing;\n}\n\n/** The resolved recharts animation props to spread onto a series/shape. */\nexport interface ResolvedAnimation {\n isAnimationActive: boolean | 'auto';\n animationDuration?: number;\n animationBegin?: number;\n animationEasing?: ChartAnimationEasing;\n}\n\n/**\n * Turn the shared `ChartAnimationProps` into the recharts series props. The\n * timing props only appear when given, so an unset chart spreads exactly\n * `{ isAnimationActive: false }` — the previous hardcoded value.\n *\n * `animate` maps to recharts' `'auto'`, not to a literal `true`: `'auto'` is the\n * only value that honors `prefers-reduced-motion` (and disables the animation in\n * SSR). recharts resolves it as\n * `isActive = isActiveProp === 'auto' ? !isSsr && !prefersReducedMotion : isActiveProp`,\n * so a literal `true` would force motion on users who asked for none — this\n * library has no other reduced-motion escape hatch.\n */\nexport function resolveAnimation(props: ChartAnimationProps): ResolvedAnimation {\n const { animate = false, animationDuration, animationBegin, animationEasing } =\n props;\n return {\n isAnimationActive: animate ? 'auto' : false,\n ...(animationDuration !== undefined ? { animationDuration } : {}),\n ...(animationBegin !== undefined ? { animationBegin } : {}),\n ...(animationEasing !== undefined ? { animationEasing } : {}),\n };\n}\n\n/** Where a data label sits on a cartesian series (recharts `LabelList` position). */\nexport type CartesianLabelPosition =\n | 'top'\n | 'bottom'\n | 'left'\n | 'right'\n | 'center'\n | 'insideTop'\n | 'insideBottom'\n | 'insideLeft'\n | 'insideRight'\n | 'insideStart'\n | 'insideEnd';\n\n/**\n * Where a data label sits on a *polar* series (Pie, RadialBar). Deliberately not\n * `CartesianLabelPosition`: recharts routes a polar label list through\n * `getAttrsOfPolarLabel` / `renderRadialLabel`, which understand only these\n * seven values — every cartesian-only position (`top`, `insideLeft`, …) silently\n * collapses to the same mid-radius placement, so offering them would advertise\n * distinctions that don't exist.\n */\nexport type PolarLabelPosition =\n | 'outside'\n | 'center'\n | 'centerTop'\n | 'centerBottom'\n | 'insideStart'\n | 'insideEnd'\n | 'end';\n\n/** Any position accepted by the suite's data labels. */\nexport type ChartLabelPosition = CartesianLabelPosition | PolarLabelPosition;\n\n/**\n * Data-label props shared by the charts that can annotate each point/segment with\n * its value. `labelPosition` stays per-chart (the valid position set differs by\n * family), but `showLabels` + `labelFormatter` are common. Label formatting reuses\n * the same `TickFormatter` type as the axes, so a label and its axis read the same.\n */\nexport interface ChartDataLabelProps {\n /** Render a value label on each data point/segment. Defaults to `false`. */\n showLabels?: boolean;\n /** Format each label value — pass the same formatter used on the value axis. */\n labelFormatter?: TickFormatter;\n}\n\n/**\n * Fill for a label that sits on the chart *surface* — i.e. an outside position\n * (`top`, `right`, polar `outside`). Inverts with the theme, so it only works\n * against the surface background.\n */\nexport const CHART_LABEL_FILL_CLASS = 'fill-[var(--ui-text-on-surface-primary)]!';\n\n/**\n * Fill for a label that sits on an *opaque series fill* — any `inside*`\n * position, a polar mid-radius/centroid placement, or a stacked bar/arc segment\n * (an area's fill is translucent, so it uses the on-surface token). The on-surface\n * token must not be used there: it resolves near-white in dark mode and drops to\n * ~1.6:1 against the saturated status/brand fills the charts colour series with,\n * failing the `accessibility/contrast` grammar rule (`must`, WCAG 1.4.3). This is\n * the same \"text on a strong colored surface\" token `Treemap` already uses; it is\n * white in both themes, so it holds up over every series colour.\n */\nexport const CHART_LABEL_FILL_ON_SERIES_CLASS =\n 'fill-[var(--ui-text-on-status-strong-neutral)]!';\n\nexport const CHART_LABEL_FONT_SIZE = 12;\n\n/**\n * Plot-area inset to apply when a Line/Area series carries outside data labels.\n * recharts hands those label lists `parentViewBox: undefined` (its own source\n * calls this out as a bug in `cartesian/Line.js`), so `getCartesianPosition`'s\n * `clamp` has nothing to clamp against and the first/last point's value is cut\n * off at the SVG edge. Widening the margin is the only lever a composition over\n * recharts has. `Bar` does pass a `parentViewBox`, so bar series don't need it.\n */\nexport const CHART_LABEL_MARGIN = {\n top: 16,\n right: 24,\n bottom: 5,\n left: 12,\n} as const;\n\n/** Positions that draw the label on top of the series fill rather than the surface. */\nconst ON_SERIES_LABEL_POSITIONS = new Set<ChartLabelPosition>([\n 'center',\n 'centerTop',\n 'centerBottom',\n 'insideTop',\n 'insideBottom',\n 'insideLeft',\n 'insideRight',\n 'insideStart',\n 'insideEnd',\n 'end',\n]);\n\n/**\n * Resolve where a cartesian value label sits, given the caller's override, the\n * layout, and the position of the series' growing end (`top` for a vertical bar\n * or a line/area point, `right` for a horizontal bar).\n *\n * The stacked branch is the reason this isn't inlined: a stacked segment has no\n * free space at its growing end — the next segment is drawn there — so a `top`\n * label lands *inside* its neighbour rather than over its own segment. Centring\n * it in its own segment is the readable placement; `resolveLabelFillClass` then\n * pairs it with the fill that has contrast over that family's series colour.\n */\nexport function resolveCartesianLabelPosition(options: {\n labelPosition?: CartesianLabelPosition;\n isStacked?: boolean;\n growingEnd?: CartesianLabelPosition;\n}): CartesianLabelPosition {\n const { labelPosition, isStacked = false, growingEnd = 'top' } = options;\n if (labelPosition !== undefined) return labelPosition;\n return isStacked ? 'center' : growingEnd;\n}\n\n/**\n * Pick the label fill that actually has contrast at `position`. Callers must pass\n * the *resolved* position (after their own default), never `undefined` for a\n * polar chart — recharts' polar fallback is a mid-radius placement, which is on\n * the fill even though no `inside*` value was given.\n *\n * Returns a `className`, not a `fill` attribute, and the utility is `!`-flagged:\n * the cartesian charts scope `[&_.recharts-label]:fill-foreground` on their\n * container to theme axis titles, and a `LabelList`'s text carries\n * `.recharts-label` too — so a CSS rule would quietly beat an SVG presentation\n * attribute and undo the contrast fix.\n *\n * `translucentSeries` opts a family out of the on-fill token: an area's fill is\n * a gradient (0.8 → 0.1 alpha) or a flat `fillOpacity`, so what sits behind the\n * label is the surface tinted by the series colour, not the series colour. The\n * white on-fill token disappears into it in light mode — the theme-inverting\n * on-surface token is the readable one there, and stays white in dark mode.\n */\nexport function resolveLabelFillClass(\n position: ChartLabelPosition,\n options: { translucentSeries?: boolean } = {}\n): string {\n if (options.translucentSeries) return CHART_LABEL_FILL_CLASS;\n return ON_SERIES_LABEL_POSITIONS.has(position)\n ? CHART_LABEL_FILL_ON_SERIES_CLASS\n : CHART_LABEL_FILL_CLASS;\n}\n\n/**\n * Adapt a `TickFormatter` to recharts' `LabelList` `formatter` prop, whose value\n * type is wider. Returns `undefined` when no formatter is given, so a label\n * renders its raw value. Lets labels reuse the same formatters as the value axis.\n *\n * Null/undefined is filtered out rather than forwarded: recharts builds a label\n * entry for *every* point including the null ones that `connectNulls` is meant to\n * bridge, and the tick formatters coerce (`formatCompactNumber(null)` is `\"0\"`,\n * `formatPercent(undefined)` is `\"undefined\"`) — which would paint a phantom\n * value over an intentional gap.\n */\nexport function toLabelFormatter(\n formatter: TickFormatter | undefined\n): ((value: unknown) => string) | undefined {\n if (!formatter) return undefined;\n return (value: unknown) =>\n value == null ? '' : formatter(value as number | string);\n}\n\n/** Where a reference line's caption sits relative to the rule. */\nexport type ChartReferenceLabelPosition =\n | 'top'\n | 'insideTopLeft'\n | 'insideTopRight'\n | 'insideBottomLeft'\n | 'insideBottomRight';\n\n/**\n * A dashed rule across the value axis — a target, a threshold, or a series\n * average. Shared by the cartesian charts that draw one (`BarChart`,\n * `LineChart`, `AreaChart`) so the config reads the same on all three.\n */\nexport interface ChartReferenceLine {\n /** Fixed position on the value axis. Takes precedence over `average`. */\n value?: number;\n /**\n * Draw the line at the mean of one series (a `dataKeys` entry) or, when\n * `true`, of every plotted series' values.\n */\n average?: boolean | string;\n /** Optional caption rendered alongside the line. */\n label?: string;\n /**\n * Where the caption sits. Defaults to the chart's own placement — move it\n * when the rule lands where the series already is and the two collide.\n */\n labelPosition?: ChartReferenceLabelPosition;\n}\n\n/**\n * Normalize the `referenceLine` prop — a single config or an array — to a list.\n * Every chart accepts both forms, so this keeps the render path uniform.\n */\nexport function toReferenceLineList(\n referenceLine: ChartReferenceLine | ChartReferenceLine[] | undefined\n): ChartReferenceLine[] {\n if (!referenceLine) return [];\n return Array.isArray(referenceLine) ? referenceLine : [referenceLine];\n}\n\n/**\n * Resolve a `referenceLine` config to a position on the value axis: a fixed\n * `value` wins; otherwise the mean of the requested series (a single `dataKeys`\n * entry, or all of them when `average` is `true`). Returns `undefined` when\n * there is nothing to draw (no config, or no numeric values to average) — the\n * caller skips the line rather than drawing it at 0.\n *\n * Rows are `unknown`-valued because `ComposedChart` types its data that way; the\n * body only ever reads cells that are numbers, so a wider row type costs nothing\n * and saves every caller a cast.\n */\nexport function resolveChartReferenceValue(\n referenceLine: ChartReferenceLine | undefined,\n data: ReadonlyArray<Record<string, unknown>>,\n dataKeys: string[]\n): number | undefined {\n if (!referenceLine) return undefined;\n if (typeof referenceLine.value === 'number') return referenceLine.value;\n if (!referenceLine.average) return undefined;\n\n const keys =\n typeof referenceLine.average === 'string'\n ? [referenceLine.average]\n : dataKeys;\n const nums = data.flatMap((row) =>\n keys\n .map((key) => row[key])\n .filter((value): value is number => typeof value === 'number')\n );\n if (nums.length === 0) return undefined;\n return nums.reduce((sum, n) => sum + n, 0) / nums.length;\n}\n\n/**\n * Stroke (and caption fill) of a reference rule. The muted text token, so the\n * rule reads as annotation rather than as another series — and stays legible in\n * both themes without competing with the series colors.\n */\nexport const CHART_REFERENCE_LINE_STROKE =\n 'var(--ui-text-on-surface-secondary)';\n\n/**\n * The recharts props that paint a reference rule: a dashed line in the muted\n * text token with an optional caption. Shared so the three charts that draw one\n * can't drift on the stroke, dash pattern, or caption styling.\n *\n * `labelPosition` is the chart's default placement; a config's own\n * `labelPosition` overrides it at the call site.\n *\n * `ifOverflow: 'extendDomain'` is part of the contract, not a detail: a target\n * above the data maximum is exactly the case a reference line is for, and\n * recharts' default (`discard`) would silently drop it.\n */\nexport function resolveReferenceLineProps(\n label: string | undefined,\n labelPosition: ChartReferenceLabelPosition = 'insideTopRight'\n) {\n return {\n stroke: CHART_REFERENCE_LINE_STROKE,\n strokeDasharray: '4 4',\n ifOverflow: 'extendDomain' as const,\n label: label\n ? {\n value: label,\n position: labelPosition,\n fill: CHART_REFERENCE_LINE_STROKE,\n fontSize: CHART_LABEL_FONT_SIZE,\n }\n : undefined,\n };\n}\n\n/**\n * Range-brush props for the cartesian charts that support one — `BarChart`,\n * `LineChart`, `AreaChart`, `ComposedChart`. Deliberately not folded into\n * `CartesianChartProps`: `ScatterChart` plots a continuous X (the brush indexes\n * rows, not values) and `Histogram` / `ConfidenceCone` render a derived series,\n * so a brush over their row order would slice the wrong thing.\n */\nexport interface ChartBrushProps {\n /**\n * Render a range brush beneath the chart — drag its handles (or the selected\n * window) to zoom the series to a slice of the data. Defaults to `false`.\n */\n showBrush?: boolean;\n /** Height of the brush strip in px. Defaults to 28. */\n brushHeight?: number;\n /**\n * Accessible name for the brush's two range handles. Both are focusable\n * `role=\"slider\"` elements, so they need one. Defaults to\n * `'Chart range selector'`.\n */\n brushAriaLabel?: string;\n}\n\n/**\n * Height of the brush strip. recharts' own default is 40, which eats an eighth\n * of a 320px-tall dashboard widget; 28 still fits the travellers and the\n * range captions.\n */\nexport const CHART_BRUSH_HEIGHT = 28;\n\n/**\n * Accessible name for the brush handles. recharts' own fallback is\n * `\"Min value: \".concat(start, \", Max value: \").concat(end)`, where both halves\n * come from a `name` property on the data row — a field none of our charts\n * require, so it announces \"Min value: undefined, Max value: undefined\". Always\n * pass `ariaLabel` to suppress it.\n */\nexport const CHART_BRUSH_ARIA_LABEL = 'Chart range selector';\n\n/** The resolved recharts brush props to spread onto a `<Brush>`. */\nexport interface ResolvedBrush {\n height: number;\n fill: string;\n stroke: string;\n travellerWidth: number;\n ariaLabel: string;\n}\n\n/**\n * Theme + size a recharts `<Brush>` from the shared `ChartBrushProps`.\n *\n * recharts derives the *whole* brush from two color props, so both have to be\n * chosen for every element they reach (`cartesian/Brush.js`):\n * - `fill` paints only the strip's background rect.\n * - `stroke` paints its border, the traveller handles' **fill**, the selected\n * window at 20% opacity, and the range caption text.\n *\n * Hence the mid-grey text token rather than the border one: the travellers are\n * solid `stroke`-colored rects with two hardcoded `#fff` grip lines drawn on\n * top, so a pale stroke would render the grips invisible in light mode. That\n * token is theme-stable (same grey in light and dark), and white grips read\n * against it either way.\n */\nexport function resolveBrushProps({\n brushHeight,\n brushAriaLabel = CHART_BRUSH_ARIA_LABEL,\n}: Omit<ChartBrushProps, 'showBrush'>): ResolvedBrush {\n return {\n // recharts drops the brush entirely when height <= 0, which would turn\n // `showBrush` into a silent no-op — treat a non-positive height as unset.\n height:\n brushHeight != null && brushHeight > 0 ? brushHeight : CHART_BRUSH_HEIGHT,\n fill: 'var(--ui-background-surface-secondary)',\n stroke: 'var(--ui-text-on-surface-secondary)',\n travellerWidth: 8,\n ariaLabel: brushAriaLabel,\n };\n}\n\nconst toNumber = (value: number | string): number | null => {\n // `Number('')` and `Number(' ')` are 0, not NaN — so blank strings have to be\n // rejected before the finite check, or an empty tick label would render \"0\".\n if (typeof value === 'string' && value.trim() === '') return null;\n const n = typeof value === 'number' ? value : Number(value);\n return Number.isFinite(n) ? n : null;\n};\n\n/**\n * Compact thousands/millions: `1234 → \"1.2K\"`, `1_500_000 → \"1.5M\"`. Non-numeric\n * values (including blank strings) pass through unchanged. Use for large-count\n * axes (revenue, users, …).\n *\n * Formats in `en`. For another locale use\n * `createTickFormatter({ notation: 'compact', maximumFractionDigits: 1 }, locale)`.\n */\nexport const formatCompactNumber: TickFormatter = (value) => {\n const n = toNumber(value);\n if (n === null) return String(value);\n return new Intl.NumberFormat('en', {\n notation: 'compact',\n maximumFractionDigits: 1,\n }).format(n);\n};\n\n/**\n * Append a percent sign to an already-scaled value: `41.8 → \"41.8%\"`. (The value\n * is treated as a percentage, not a 0–1 fraction.) Non-numeric values (including\n * blank strings) pass through.\n *\n * Appends a bare `%`, which is not how every locale writes it. For locale-correct\n * output on values that really are fractions, use\n * `createTickFormatter({ style: 'percent' }, locale)`.\n */\nexport const formatPercent: TickFormatter = (value) => {\n const n = toNumber(value);\n if (n === null) return String(value);\n return `${n}%`;\n};\n\n/**\n * Build a tick formatter from `Intl.NumberFormat` options — the escape hatch for\n * currency, fixed decimals, or a specific locale. E.g.\n * `createTickFormatter({ style: 'currency', currency: 'USD', notation: 'compact' })`\n * → `146500 → \"$147K\"`. Non-numeric values pass through unchanged.\n */\nexport function createTickFormatter(\n options: Intl.NumberFormatOptions,\n locale = 'en'\n): TickFormatter {\n const nf = new Intl.NumberFormat(locale, options);\n return (value) => {\n const n = toNumber(value);\n return n === null ? String(value) : nf.format(n);\n };\n}\n"],"names":["resolveAxisDomain","preset","resolveRotatedTickAnchor","angle","resolveXAxisHeight","label","resolveXAxisTitle","position","offset","resolveYAxisTitle","orientation","resolveCategoryRange","range","data","xKey","resolve","bound","fallback","asValue","row","start","end","resolveAnimation","props","animate","animationDuration","animationBegin","animationEasing","CHART_LABEL_FILL_CLASS","CHART_LABEL_FILL_ON_SERIES_CLASS","CHART_LABEL_FONT_SIZE","CHART_LABEL_MARGIN","ON_SERIES_LABEL_POSITIONS","resolveCartesianLabelPosition","options","labelPosition","isStacked","growingEnd","resolveLabelFillClass","toLabelFormatter","formatter","value","toReferenceLineList","referenceLine","resolveChartReferenceValue","dataKeys","keys","nums","key","sum","n","CHART_REFERENCE_LINE_STROKE","resolveReferenceLineProps","CHART_BRUSH_HEIGHT","CHART_BRUSH_ARIA_LABEL","resolveBrushProps","brushHeight","brushAriaLabel","toNumber","formatCompactNumber","formatPercent","createTickFormatter","locale","nf"],"mappings":"AA6GO,SAASA,EACdC,GACwD;AACxD,UAAQA,GAAA;AAAA,IACN,KAAK;AACH,aAAO,CAAC,QAAQ,MAAM;AAAA,IACxB,KAAK;AACH,aAAO,CAAC,GAAG,MAAM;AAAA,IACnB,KAAK;AACH,aAAO,CAAC,WAAW,SAAS;AAAA,IAC9B;AACE;AAAA,EAAO;AAEb;AAcO,SAASC,EACdC,GAC6B;AAC7B,MAAIA,KAAS;AACb,WAAOA,IAAQ,IAAI,QAAQ;AAC7B;AAeO,SAASC,EACdC,GACAF,GACoB;AACpB,MAAI,GAACE,KAASF,KAAS;AACvB,WAAO,MAAMA,KAAS,OAAO,KAAK,MAAME,IAAQ,KAAK;AACvD;AAMO,SAASC,EACdD,GACAE,IAAyC,gBACzCC,IAA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