@dudousxd/nestjs-telescope-ui 1.21.0 → 1.22.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 (89) hide show
  1. package/CHANGELOG.md +134 -0
  2. package/dist/client/types.d.ts +31 -0
  3. package/dist/client/types.d.ts.map +1 -1
  4. package/dist/react/components/charts/area-chart-card.d.ts +11 -3
  5. package/dist/react/components/charts/area-chart-card.d.ts.map +1 -1
  6. package/dist/react/components/charts/area-chart-card.js +33 -6
  7. package/dist/react/components/charts/area-chart-card.js.map +1 -1
  8. package/dist/react/components/charts/bar-chart-card.d.ts +18 -7
  9. package/dist/react/components/charts/bar-chart-card.d.ts.map +1 -1
  10. package/dist/react/components/charts/bar-chart-card.js +18 -9
  11. package/dist/react/components/charts/bar-chart-card.js.map +1 -1
  12. package/dist/react/components/charts/breakdown-card.d.ts +11 -6
  13. package/dist/react/components/charts/breakdown-card.d.ts.map +1 -1
  14. package/dist/react/components/charts/breakdown-card.js +34 -17
  15. package/dist/react/components/charts/breakdown-card.js.map +1 -1
  16. package/dist/react/components/charts/chart-card.d.ts +7 -0
  17. package/dist/react/components/charts/chart-card.d.ts.map +1 -1
  18. package/dist/react/components/charts/chart-card.js +9 -2
  19. package/dist/react/components/charts/chart-card.js.map +1 -1
  20. package/dist/react/components/charts/chart-selection.d.ts +44 -0
  21. package/dist/react/components/charts/chart-selection.d.ts.map +1 -0
  22. package/dist/react/components/charts/chart-selection.js +36 -0
  23. package/dist/react/components/charts/chart-selection.js.map +1 -0
  24. package/dist/react/components/charts/chart-theme.d.ts +44 -11
  25. package/dist/react/components/charts/chart-theme.d.ts.map +1 -1
  26. package/dist/react/components/charts/chart-theme.js +60 -11
  27. package/dist/react/components/charts/chart-theme.js.map +1 -1
  28. package/dist/react/components/charts/distribution-chart-card.d.ts +5 -1
  29. package/dist/react/components/charts/distribution-chart-card.d.ts.map +1 -1
  30. package/dist/react/components/charts/distribution-chart-card.js +35 -16
  31. package/dist/react/components/charts/distribution-chart-card.js.map +1 -1
  32. package/dist/react/components/charts/gauge-card.d.ts +1 -0
  33. package/dist/react/components/charts/gauge-card.d.ts.map +1 -1
  34. package/dist/react/components/charts/gauge-card.js +8 -10
  35. package/dist/react/components/charts/gauge-card.js.map +1 -1
  36. package/dist/react/components/charts/index.d.ts +1 -0
  37. package/dist/react/components/charts/index.d.ts.map +1 -1
  38. package/dist/react/components/charts/index.js +1 -0
  39. package/dist/react/components/charts/index.js.map +1 -1
  40. package/dist/react/components/charts/stacked-area-chart-card.d.ts +15 -3
  41. package/dist/react/components/charts/stacked-area-chart-card.d.ts.map +1 -1
  42. package/dist/react/components/charts/stacked-area-chart-card.js +31 -8
  43. package/dist/react/components/charts/stacked-area-chart-card.js.map +1 -1
  44. package/dist/react/components/extensions/panel-column-menu.d.ts +19 -0
  45. package/dist/react/components/extensions/panel-column-menu.d.ts.map +1 -0
  46. package/dist/react/components/extensions/panel-column-menu.js +47 -0
  47. package/dist/react/components/extensions/panel-column-menu.js.map +1 -0
  48. package/dist/react/components/extensions/panel-renderer.d.ts +21 -1
  49. package/dist/react/components/extensions/panel-renderer.d.ts.map +1 -1
  50. package/dist/react/components/extensions/panel-renderer.js +55 -39
  51. package/dist/react/components/extensions/panel-renderer.js.map +1 -1
  52. package/dist/react/components/extensions/panel-table-header.d.ts +18 -0
  53. package/dist/react/components/extensions/panel-table-header.d.ts.map +1 -0
  54. package/dist/react/components/extensions/panel-table-header.js +82 -0
  55. package/dist/react/components/extensions/panel-table-header.js.map +1 -0
  56. package/dist/react/components/extensions/panel-table.d.ts +27 -0
  57. package/dist/react/components/extensions/panel-table.d.ts.map +1 -0
  58. package/dist/react/components/extensions/panel-table.js +87 -0
  59. package/dist/react/components/extensions/panel-table.js.map +1 -0
  60. package/dist/react/components/extensions/table-columns.d.ts +32 -0
  61. package/dist/react/components/extensions/table-columns.d.ts.map +1 -0
  62. package/dist/react/components/extensions/table-columns.js +51 -0
  63. package/dist/react/components/extensions/table-columns.js.map +1 -0
  64. package/dist/react/components/extensions/table-features.d.ts +47 -0
  65. package/dist/react/components/extensions/table-features.d.ts.map +1 -0
  66. package/dist/react/components/extensions/table-features.js +45 -0
  67. package/dist/react/components/extensions/table-features.js.map +1 -0
  68. package/dist/react/components/extensions/table-query.d.ts +53 -0
  69. package/dist/react/components/extensions/table-query.d.ts.map +1 -0
  70. package/dist/react/components/extensions/table-query.js +51 -0
  71. package/dist/react/components/extensions/table-query.js.map +1 -0
  72. package/dist/react/ui/chart.d.ts +116 -0
  73. package/dist/react/ui/chart.d.ts.map +1 -0
  74. package/dist/react/ui/chart.js +191 -0
  75. package/dist/react/ui/chart.js.map +1 -0
  76. package/dist/react/ui/index.d.ts +2 -1
  77. package/dist/react/ui/index.d.ts.map +1 -1
  78. package/dist/react/ui/index.js +2 -1
  79. package/dist/react/ui/index.js.map +1 -1
  80. package/dist/react/ui/table.d.ts +13 -1
  81. package/dist/react/ui/table.d.ts.map +1 -1
  82. package/dist/react/ui/table.js +2 -10
  83. package/dist/react/ui/table.js.map +1 -1
  84. package/dist/spa/assets/index-Cr4sGV6r.css +1 -0
  85. package/dist/spa/assets/index-DjFyVM4h.js +173 -0
  86. package/dist/spa/index.html +2 -2
  87. package/package.json +8 -3
  88. package/dist/spa/assets/index-BkK5KeFh.css +0 -1
  89. package/dist/spa/assets/index-DICjg157.js +0 -173
@@ -1,26 +1,43 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Bar, BarChart, Cell, Pie, PieChart, ResponsiveContainer, Tooltip } from 'recharts';
3
- import { ChartCard } from './chart-card.js';
4
- import { tooltipContentStyle, tooltipItemStyle, tooltipLabelStyle } from './chart-theme.js';
5
- const DEFAULT_PALETTE = ['#34d399', '#fbbf24', '#f87171', '#38bdf8', '#a78bfa'];
6
- function resolveColor(index, override) {
7
- if (override)
8
- return override;
9
- return DEFAULT_PALETTE[index % DEFAULT_PALETTE.length] ?? '#71717a';
10
- }
11
- export function BreakdownCard({ title, segments, style = 'donut', height = 220, }) {
2
+ import { useMemo } from 'react';
3
+ import { Bar, BarChart, Cell, Pie, PieChart } from 'recharts';
4
+ import { ChartContainer, ChartLegend, ChartLegendContent, ChartTooltip, ChartTooltipContent, } from '../../ui/chart.js';
5
+ import { ChartCard, ChartEmptyState } from './chart-card.js';
6
+ import { chartSelection } from './chart-selection.js';
7
+ import { chartConfig, hexForSegment } from './chart-theme.js';
8
+ /** Donut (default) or single stacked bar showing how a total splits by category. */
9
+ export function BreakdownCard({ title, segments, style = 'donut', height = 220, onSelect, }) {
12
10
  const bodyHeight = height - 64;
11
+ const config = useMemo(() => chartConfig(segments.map((s) => s.label), (label, index) => hexForSegment(label, index, segments[index]?.color)), [segments]);
12
+ function select(index) {
13
+ const segment = segments[index];
14
+ if (segment && onSelect) {
15
+ onSelect(chartSelection({ label: segment.label, value: segment.value }));
16
+ }
17
+ }
18
+ // Recharts hands a click handler its own datum first; the index is what we
19
+ // actually key off, so the datum is deliberately ignored.
20
+ const clickProps = onSelect
21
+ ? { onClick: (_datum, index) => select(index), cursor: 'pointer' }
22
+ : {};
23
+ if (segments.length === 0) {
24
+ return (_jsx(ChartCard, { title: title, height: bodyHeight, children: _jsx(ChartEmptyState, { height: bodyHeight }) }));
25
+ }
13
26
  if (style === 'bar') {
14
- const data = [
27
+ // One row, one stacked bar per segment: the chart is a single 100% bar, so
28
+ // every segment is its own series rather than a row in a shared one.
29
+ const row = [
15
30
  { name: 'breakdown', ...Object.fromEntries(segments.map((s) => [s.label, s.value])) },
16
31
  ];
17
- return (_jsx(ChartCard, { title: title, height: bodyHeight, children: _jsx(ResponsiveContainer, { width: "100%", height: "100%", children: _jsxs(BarChart, { data: data, layout: "vertical", children: [_jsx(Tooltip, { contentStyle: tooltipContentStyle, labelStyle: tooltipLabelStyle, itemStyle: tooltipItemStyle }), segments.map((seg, i) => (_jsx(Bar, { dataKey: seg.label, stackId: "a", fill: resolveColor(i, seg.color), isAnimationActive: false }, seg.label)))] }) }) }));
32
+ return (_jsx(ChartCard, { title: title, height: bodyHeight, children: _jsx(ChartContainer, { config: config, children: _jsxs(BarChart, { data: row, layout: "vertical", children: [_jsx(ChartTooltip, { content: _jsx(ChartTooltipContent, { hideLabel: true }) }), _jsx(ChartLegend, { content: _jsx(ChartLegendContent, {}) }), segments.map((segment, index) => (_jsx(Bar, { dataKey: segment.label, stackId: "a", fill: hexForSegment(segment.label, index, segment.color), isAnimationActive: false, ...(onSelect ? { onClick: () => select(index), cursor: 'pointer' } : {}) }, segment.label)))] }) }) }));
18
33
  }
19
- const pieData = segments.map((seg, i) => ({
20
- name: seg.label,
21
- value: seg.value,
22
- fill: resolveColor(i, seg.color),
34
+ const pieData = segments.map((segment, index) => ({
35
+ name: segment.label,
36
+ value: segment.value,
37
+ // `color` (not `fill`) so the hover card and the legend resolve the segment's
38
+ // own hue — see `seriesColor` in the vendored chart layer.
39
+ color: hexForSegment(segment.label, index, segment.color),
23
40
  }));
24
- return (_jsx(ChartCard, { title: title, height: bodyHeight, children: _jsx(ResponsiveContainer, { width: "100%", height: "100%", children: _jsxs(PieChart, { children: [_jsx(Pie, { data: pieData, dataKey: "value", nameKey: "name", innerRadius: "55%", outerRadius: "80%", isAnimationActive: false, children: pieData.map((entry) => (_jsx(Cell, { fill: entry.fill }, entry.name))) }), _jsx(Tooltip, { contentStyle: tooltipContentStyle, labelStyle: tooltipLabelStyle, itemStyle: tooltipItemStyle })] }) }) }));
41
+ return (_jsx(ChartCard, { title: title, height: bodyHeight, children: _jsx(ChartContainer, { config: config, children: _jsxs(PieChart, { children: [_jsx(ChartTooltip, { content: _jsx(ChartTooltipContent, { hideLabel: true }) }), _jsx(ChartLegend, { content: _jsx(ChartLegendContent, {}) }), _jsx(Pie, { data: pieData, dataKey: "value", nameKey: "name", innerRadius: "55%", outerRadius: "80%", isAnimationActive: false, ...clickProps, children: pieData.map((entry) => (_jsx(Cell, { fill: entry.color }, entry.name))) })] }) }) }));
25
42
  }
26
43
  //# sourceMappingURL=breakdown-card.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"breakdown-card.js","sourceRoot":"","sources":["../../../../src/react/components/charts/breakdown-card.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAC5F,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE5F,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AAEhF,SAAS,YAAY,CAAC,KAAa,EAAE,QAAiB;IACpD,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,OAAO,eAAe,CAAC,KAAK,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,SAAS,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,EAC5B,KAAK,EACL,QAAQ,EACR,KAAK,GAAG,OAAO,EACf,MAAM,GAAG,GAAG,GAMb;IACC,MAAM,UAAU,GAAG,MAAM,GAAG,EAAE,CAAC;IAE/B,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;QACpB,MAAM,IAAI,GAAG;YACX,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;SACtF,CAAC;QACF,OAAO,CACL,KAAC,SAAS,IAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,YACzC,KAAC,mBAAmB,IAAC,KAAK,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM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,MAAM,EACd,WAAW,EAAC,KAAK,EACjB,WAAW,EAAC,KAAK,EACjB,iBAAiB,EAAE,KAAK,KACpB,UAAU,YAEb,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACtB,KAAC,IAAI,IAAkB,IAAI,EAAE,KAAK,CAAC,KAAK,IAA7B,KAAK,CAAC,IAAI,CAAuB,CAC7C,CAAC,GACE,IACG,GACI,GACP,CACb,CAAC;AACJ,CAAC"}
@@ -5,6 +5,13 @@ export declare function ChartCard({ title, right, height, children, }: {
5
5
  height?: number;
6
6
  children: React.ReactNode;
7
7
  }): JSX.Element;
8
+ /**
9
+ * "Nothing in this window" body. `height` is optional: given one it reserves
10
+ * exactly the space the chart would have taken, and without one it fills its
11
+ * parent — which is what a card that puts something else (percentile chips) above
12
+ * the chart needs, since there the chart's share of the body is not the card's
13
+ * height.
14
+ */
8
15
  export declare function ChartEmptyState({ height }: {
9
16
  height?: number;
10
17
  }): JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"chart-card.d.ts","sourceRoot":"","sources":["../../../../src/react/components/charts/chart-card.tsx"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,KAAK,EACL,MAAY,EACZ,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,GAAG,GAAG,CAAC,OAAO,CAYd;AAED,wBAAgB,eAAe,CAAC,EAAE,MAAY,EAAE,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,GAAG,CAAC,OAAO,CASlF"}
1
+ {"version":3,"file":"chart-card.d.ts","sourceRoot":"","sources":["../../../../src/react/components/charts/chart-card.tsx"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,KAAK,EACL,MAAY,EACZ,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,GAAG,GAAG,CAAC,OAAO,CAYd;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,GAAG,CAAC,OAAO,CAS5E"}
@@ -3,7 +3,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  export function ChartCard({ title, right, height = 220, children, }) {
4
4
  return (_jsxs("section", { className: "rounded-lg border border-line bg-panel/40 p-4", children: [_jsxs("header", { className: "mb-3 flex items-center justify-between", children: [_jsx("h3", { className: "text-xs font-medium uppercase tracking-wide text-muted-foreground", children: title }), right] }), _jsx("div", { style: { height }, children: children })] }));
5
5
  }
6
- export function ChartEmptyState({ height = 220 }) {
7
- return (_jsx("div", { className: "flex items-center justify-center text-xs text-muted-foreground", style: { height }, children: "No data in window." }));
6
+ /**
7
+ * "Nothing in this window" body. `height` is optional: given one it reserves
8
+ * exactly the space the chart would have taken, and without one it fills its
9
+ * parent — which is what a card that puts something else (percentile chips) above
10
+ * the chart needs, since there the chart's share of the body is not the card's
11
+ * height.
12
+ */
13
+ export function ChartEmptyState({ height }) {
14
+ return (_jsx("div", { className: "flex h-full items-center justify-center text-xs text-muted-foreground", style: height === undefined ? undefined : { height }, children: "No data in window." }));
8
15
  }
9
16
  //# sourceMappingURL=chart-card.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chart-card.js","sourceRoot":"","sources":["../../../../src/react/components/charts/chart-card.tsx"],"names":[],"mappings":";AAAA,yFAAyF;AACzF,MAAM,UAAU,SAAS,CAAC,EACxB,KAAK,EACL,KAAK,EACL,MAAM,GAAG,GAAG,EACZ,QAAQ,GAMT;IACC,OAAO,CACL,mBAAS,SAAS,EAAC,+CAA+C,aAChE,kBAAQ,SAAS,EAAC,wCAAwC,aACxD,aAAI,SAAS,EAAC,mEAAmE,YAC9E,KAAK,GACH,EACJ,KAAK,IACC,EACT,cAAK,KAAK,EAAE,EAAE,MAAM,EAAE,YAAG,QAAQ,GAAO,IAChC,CACX,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,EAAE,MAAM,GAAG,GAAG,EAAuB;IACnE,OAAO,CACL,cACE,SAAS,EAAC,gEAAgE,EAC1E,KAAK,EAAE,EAAE,MAAM,EAAE,mCAGb,CACP,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"chart-card.js","sourceRoot":"","sources":["../../../../src/react/components/charts/chart-card.tsx"],"names":[],"mappings":";AAAA,yFAAyF;AACzF,MAAM,UAAU,SAAS,CAAC,EACxB,KAAK,EACL,KAAK,EACL,MAAM,GAAG,GAAG,EACZ,QAAQ,GAMT;IACC,OAAO,CACL,mBAAS,SAAS,EAAC,+CAA+C,aAChE,kBAAQ,SAAS,EAAC,wCAAwC,aACxD,aAAI,SAAS,EAAC,mEAAmE,YAC9E,KAAK,GACH,EACJ,KAAK,IACC,EACT,cAAK,KAAK,EAAE,EAAE,MAAM,EAAE,YAAG,QAAQ,GAAO,IAChC,CACX,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,EAAE,MAAM,EAAuB;IAC7D,OAAO,CACL,cACE,SAAS,EAAC,uEAAuE,EACjF,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,mCAGhD,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * What a user clicked inside a chart, in the one shape every card reports it.
3
+ *
4
+ * This is the drill-down intent and nothing more: a card knows what was clicked,
5
+ * it does not know what that should filter. The caller decides — `PanelView`
6
+ * forwards the selection, the extension dashboard turns it into provider query
7
+ * state. Keeping the card ignorant is what lets the same `AreaChartCard` sit on
8
+ * the Overview page (where clicking means nothing and no callback is passed) and
9
+ * on an extension dashboard (where it filters the page).
10
+ */
11
+ export interface ChartSelection {
12
+ /** The category, bucket or x-axis label under the click. */
13
+ label: string;
14
+ /** Series key when the chart draws more than one; absent for single-series charts. */
15
+ series?: string;
16
+ /** Provider-supplied stable id, when the datum carried one (topN items do). */
17
+ id?: string;
18
+ /** The value at the click, when the click resolved to a single datum. */
19
+ value?: number;
20
+ }
21
+ /**
22
+ * Build a {@link ChartSelection} without tripping `exactOptionalPropertyTypes`,
23
+ * which rejects an explicit `undefined` for an optional field. Every card builds
24
+ * its selection here so "no id" is consistently an absent key rather than a
25
+ * present `undefined` — the difference shows up the moment a selection is spread
26
+ * into a query object.
27
+ */
28
+ export declare function chartSelection(input: {
29
+ label: string;
30
+ series?: string | undefined;
31
+ id?: string | undefined;
32
+ value?: number | undefined;
33
+ }): ChartSelection;
34
+ /**
35
+ * The x-axis label under a click on a cartesian chart.
36
+ *
37
+ * A click on an area or a line has no single datum — Recharts reports the whole
38
+ * hovered category in its chart-level event state instead, and types that state
39
+ * loosely enough that reading it is a runtime question, not a compile-time one.
40
+ * Returns undefined when the click landed on chrome (axis, legend, padding),
41
+ * which is the case a drill-down must ignore rather than fire an empty filter.
42
+ */
43
+ export declare function activeChartLabel(state: unknown): string | undefined;
44
+ //# sourceMappingURL=chart-selection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart-selection.d.ts","sourceRoot":"","sources":["../../../../src/react/components/charts/chart-selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC7B,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd,sFAAsF;IACtF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,yEAAyE;IACzE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,GAAG,cAAc,CAOjB;AAMD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAKnE"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Build a {@link ChartSelection} without tripping `exactOptionalPropertyTypes`,
3
+ * which rejects an explicit `undefined` for an optional field. Every card builds
4
+ * its selection here so "no id" is consistently an absent key rather than a
5
+ * present `undefined` — the difference shows up the moment a selection is spread
6
+ * into a query object.
7
+ */
8
+ export function chartSelection(input) {
9
+ return {
10
+ label: input.label,
11
+ ...(input.series !== undefined ? { series: input.series } : {}),
12
+ ...(input.id !== undefined ? { id: input.id } : {}),
13
+ ...(input.value !== undefined ? { value: input.value } : {}),
14
+ };
15
+ }
16
+ function isRecord(value) {
17
+ return typeof value === 'object' && value !== null;
18
+ }
19
+ /**
20
+ * The x-axis label under a click on a cartesian chart.
21
+ *
22
+ * A click on an area or a line has no single datum — Recharts reports the whole
23
+ * hovered category in its chart-level event state instead, and types that state
24
+ * loosely enough that reading it is a runtime question, not a compile-time one.
25
+ * Returns undefined when the click landed on chrome (axis, legend, padding),
26
+ * which is the case a drill-down must ignore rather than fire an empty filter.
27
+ */
28
+ export function activeChartLabel(state) {
29
+ if (!isRecord(state))
30
+ return undefined;
31
+ const label = state.activeLabel;
32
+ if (typeof label === 'string' && label.length > 0)
33
+ return label;
34
+ return typeof label === 'number' ? String(label) : undefined;
35
+ }
36
+ //# sourceMappingURL=chart-selection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart-selection.js","sourceRoot":"","sources":["../../../../src/react/components/charts/chart-selection.ts"],"names":[],"mappings":"AAqBA;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,KAK9B;IACC,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/D,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnD,GAAG,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7D,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACvC,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC;IAChC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IAChE,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/D,CAAC"}
@@ -1,22 +1,49 @@
1
+ import type { ChartConfig } from '../../ui/chart.js';
1
2
  /**
2
- * Shared theme values for the Recharts chart cards. Only this folder imports
3
- * Recharts, so this is the one place chart colours are decided.
3
+ * Series colours for the chart cards. This file is the ONE place a chart decides
4
+ * what colour a series is; the chrome around it (grid, axes, tick text, brush,
5
+ * tooltip, legend) belongs to the vendored `ChartContainer` in `../../ui/chart.tsx`.
4
6
  *
5
- * Two palettes live here and they are NOT the same thing:
6
- * - `TYPE_HEX` is CATEGORICAL: one hue per entry type, chosen to be mutually
7
- * distinguishable. It is data, and deliberately does not go through the Aviary
8
- * status tokens — a `request` series is not "healthy", it is just requests.
9
- * - `chartTheme` / `ACCENT_HEX` is CHROME: grid, axes, tooltip, the throughput
10
- * accent. Those follow the console tokens so they theme with everything else.
7
+ * That split is the point. Colours here are DATA — one hue per entry type, chosen
8
+ * to be mutually distinguishable — and deliberately do not go through the Aviary
9
+ * status tokens: a `request` series is not "healthy", it is just requests (see
10
+ * AVIARY-UI.md, "Categorical data hues are not tokens"). Chrome does follow the
11
+ * tokens, so it themes with the rest of the console.
11
12
  *
12
- * Recharts takes plain colour strings rather than classes, so chrome reads the
13
- * tokens as `var(--x)`; SVG resolves the custom property at paint time.
13
+ * Recharts takes plain colour strings rather than classes, so anything token-based
14
+ * reads as `var(--x)`; SVG resolves the custom property at paint time.
14
15
  */
15
16
  /** Resolved hex colors for known entry types (matches the `fill-*` tokens used elsewhere). */
16
17
  export declare const TYPE_HEX: Record<string, string>;
17
18
  /** Primary throughput accent — the console `--accent`, not a status hue. */
18
19
  export declare const ACCENT_HEX = "var(--accent)";
19
20
  export declare function hexForType(type: string, fallbackIndex?: number): string;
21
+ /**
22
+ * Colour for one breakdown/pie segment: an author's explicit `color` wins, then
23
+ * the entry-type hue when the segment is named after a known type, then the
24
+ * palette by position.
25
+ *
26
+ * The {@link TYPE_HEX} step is why this is not just an array index: a breakdown
27
+ * of `request`/`query`/`exception` used to draw them green/amber/red purely by
28
+ * position, so the same `exception` was red in one card and amber in the next.
29
+ */
30
+ export declare function hexForSegment(label: string, index: number, override?: string): string;
31
+ /**
32
+ * Build a {@link ChartConfig} for a set of series keys. Every card goes through
33
+ * here so the tooltip, the legend and the marks all read the same colour from the
34
+ * same place — the shadcn chart layer resolves labels and swatches from the
35
+ * config, and a colour passed straight to a `<Bar>` would leave both blank.
36
+ */
37
+ export declare function chartConfig(keys: string[], colorFor: (key: string, index: number) => string, labelFor?: (key: string) => string): ChartConfig;
38
+ /**
39
+ * Chrome colours for the handful of places a Recharts prop is the only way in
40
+ * (a `cursor`, a gradient stop).
41
+ *
42
+ * @deprecated The grid/axis/tooltip/legend entries are now applied by
43
+ * `ChartContainer`'s token classes; a card should not pass them. Kept exported
44
+ * because this is a published module and removing names from it is a breaking
45
+ * change.
46
+ */
20
47
  export declare const chartTheme: {
21
48
  readonly gridStroke: "color-mix(in srgb, var(--line) 70%, transparent)";
22
49
  readonly axisStroke: "var(--line)";
@@ -27,7 +54,10 @@ export declare const chartTheme: {
27
54
  readonly tooltipLabel: "var(--muted)";
28
55
  readonly legendText: "var(--muted)";
29
56
  };
30
- /** Shared `contentStyle` for Recharts `<Tooltip>` so every chart looks identical. */
57
+ /**
58
+ * @deprecated Superseded by `ChartTooltipContent`, which renders a real hover card
59
+ * instead of Recharts' single line of text. Kept for API compatibility.
60
+ */
31
61
  export declare const tooltipContentStyle: {
32
62
  readonly background: "var(--panel-2)";
33
63
  readonly border: "1px solid var(--line)";
@@ -35,15 +65,18 @@ export declare const tooltipContentStyle: {
35
65
  readonly fontSize: 11;
36
66
  readonly color: "var(--text)";
37
67
  };
68
+ /** @deprecated See {@link tooltipContentStyle}. */
38
69
  export declare const tooltipLabelStyle: {
39
70
  readonly color: "var(--muted)";
40
71
  readonly fontSize: 10;
41
72
  readonly textTransform: "uppercase";
42
73
  readonly letterSpacing: "0.05em";
43
74
  };
75
+ /** @deprecated See {@link tooltipContentStyle}. */
44
76
  export declare const tooltipItemStyle: {
45
77
  readonly color: "var(--text)";
46
78
  };
79
+ /** @deprecated Tick text is filled by `ChartContainer`'s token classes. */
47
80
  export declare const axisTickStyle: {
48
81
  readonly fill: "var(--muted)";
49
82
  readonly fontSize: 10;
@@ -1 +1 @@
1
- {"version":3,"file":"chart-theme.d.ts","sourceRoot":"","sources":["../../../../src/react/components/charts/chart-theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,8FAA8F;AAC9F,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAO3C,CAAC;AAKF,4EAA4E;AAC5E,eAAO,MAAM,UAAU,kBAAkB,CAAC;AAE1C,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,SAAI,GAAG,MAAM,CAGlE;AAED,eAAO,MAAM,UAAU;;;;;;;;;CASb,CAAC;AAEX,qFAAqF;AACrF,eAAO,MAAM,mBAAmB;;;;;;CAMtB,CAAC;AAEX,eAAO,MAAM,iBAAiB;;;;;CAKpB,CAAC;AAEX,eAAO,MAAM,gBAAgB;;CAEnB,CAAC;AAEX,eAAO,MAAM,aAAa;;;CAGhB,CAAC"}
1
+ {"version":3,"file":"chart-theme.d.ts","sourceRoot":"","sources":["../../../../src/react/components/charts/chart-theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;;;;;;;;GAaG;AAEH,8FAA8F;AAC9F,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAO3C,CAAC;AAYF,4EAA4E;AAC5E,eAAO,MAAM,UAAU,kBAAkB,CAAC;AAE1C,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,SAAI,GAAG,MAAM,CAGlE;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAIrF;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EAAE,EACd,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,EAChD,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GACjC,WAAW,CAMb;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU;;;;;;;;;CASb,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;CAMtB,CAAC;AAEX,mDAAmD;AACnD,eAAO,MAAM,iBAAiB;;;;;CAKpB,CAAC;AAEX,mDAAmD;AACnD,eAAO,MAAM,gBAAgB;;CAEnB,CAAC;AAEX,2EAA2E;AAC3E,eAAO,MAAM,aAAa;;;CAGhB,CAAC"}
@@ -1,16 +1,16 @@
1
1
  /**
2
- * Shared theme values for the Recharts chart cards. Only this folder imports
3
- * Recharts, so this is the one place chart colours are decided.
2
+ * Series colours for the chart cards. This file is the ONE place a chart decides
3
+ * what colour a series is; the chrome around it (grid, axes, tick text, brush,
4
+ * tooltip, legend) belongs to the vendored `ChartContainer` in `../../ui/chart.tsx`.
4
5
  *
5
- * Two palettes live here and they are NOT the same thing:
6
- * - `TYPE_HEX` is CATEGORICAL: one hue per entry type, chosen to be mutually
7
- * distinguishable. It is data, and deliberately does not go through the Aviary
8
- * status tokens — a `request` series is not "healthy", it is just requests.
9
- * - `chartTheme` / `ACCENT_HEX` is CHROME: grid, axes, tooltip, the throughput
10
- * accent. Those follow the console tokens so they theme with everything else.
6
+ * That split is the point. Colours here are DATA — one hue per entry type, chosen
7
+ * to be mutually distinguishable — and deliberately do not go through the Aviary
8
+ * status tokens: a `request` series is not "healthy", it is just requests (see
9
+ * AVIARY-UI.md, "Categorical data hues are not tokens"). Chrome does follow the
10
+ * tokens, so it themes with the rest of the console.
11
11
  *
12
- * Recharts takes plain colour strings rather than classes, so chrome reads the
13
- * tokens as `var(--x)`; SVG resolves the custom property at paint time.
12
+ * Recharts takes plain colour strings rather than classes, so anything token-based
13
+ * reads as `var(--x)`; SVG resolves the custom property at paint time.
14
14
  */
15
15
  /** Resolved hex colors for known entry types (matches the `fill-*` tokens used elsewhere). */
16
16
  export const TYPE_HEX = {
@@ -23,12 +23,55 @@ export const TYPE_HEX = {
23
23
  };
24
24
  /** Ordered palette for series whose type is not in {@link TYPE_HEX}. */
25
25
  const FALLBACK_PALETTE = ['#71717a', '#a1a1aa', '#22d3ee', '#c084fc', '#fb923c', '#4ade80'];
26
+ /**
27
+ * Ordered palette for breakdown segments, which are usually an outcome split
28
+ * (ok / retried / failed) rather than a set of entry types — so it opens on the
29
+ * good/warn/bad progression instead of {@link FALLBACK_PALETTE}'s neutrals.
30
+ */
31
+ const SEGMENT_PALETTE = ['#34d399', '#fbbf24', '#f87171', '#38bdf8', '#a78bfa'];
26
32
  /** Primary throughput accent — the console `--accent`, not a status hue. */
27
33
  export const ACCENT_HEX = 'var(--accent)';
28
34
  export function hexForType(type, fallbackIndex = 0) {
29
35
  const fallback = FALLBACK_PALETTE[fallbackIndex % FALLBACK_PALETTE.length];
30
36
  return TYPE_HEX[type] ?? fallback ?? '#71717a';
31
37
  }
38
+ /**
39
+ * Colour for one breakdown/pie segment: an author's explicit `color` wins, then
40
+ * the entry-type hue when the segment is named after a known type, then the
41
+ * palette by position.
42
+ *
43
+ * The {@link TYPE_HEX} step is why this is not just an array index: a breakdown
44
+ * of `request`/`query`/`exception` used to draw them green/amber/red purely by
45
+ * position, so the same `exception` was red in one card and amber in the next.
46
+ */
47
+ export function hexForSegment(label, index, override) {
48
+ if (override)
49
+ return override;
50
+ const palette = SEGMENT_PALETTE[index % SEGMENT_PALETTE.length];
51
+ return TYPE_HEX[label] ?? palette ?? '#71717a';
52
+ }
53
+ /**
54
+ * Build a {@link ChartConfig} for a set of series keys. Every card goes through
55
+ * here so the tooltip, the legend and the marks all read the same colour from the
56
+ * same place — the shadcn chart layer resolves labels and swatches from the
57
+ * config, and a colour passed straight to a `<Bar>` would leave both blank.
58
+ */
59
+ export function chartConfig(keys, colorFor, labelFor) {
60
+ const config = {};
61
+ keys.forEach((key, index) => {
62
+ config[key] = { label: labelFor?.(key) ?? key, color: colorFor(key, index) };
63
+ });
64
+ return config;
65
+ }
66
+ /**
67
+ * Chrome colours for the handful of places a Recharts prop is the only way in
68
+ * (a `cursor`, a gradient stop).
69
+ *
70
+ * @deprecated The grid/axis/tooltip/legend entries are now applied by
71
+ * `ChartContainer`'s token classes; a card should not pass them. Kept exported
72
+ * because this is a published module and removing names from it is a breaking
73
+ * change.
74
+ */
32
75
  export const chartTheme = {
33
76
  gridStroke: 'color-mix(in srgb, var(--line) 70%, transparent)',
34
77
  axisStroke: 'var(--line)',
@@ -39,7 +82,10 @@ export const chartTheme = {
39
82
  tooltipLabel: 'var(--muted)',
40
83
  legendText: 'var(--muted)',
41
84
  };
42
- /** Shared `contentStyle` for Recharts `<Tooltip>` so every chart looks identical. */
85
+ /**
86
+ * @deprecated Superseded by `ChartTooltipContent`, which renders a real hover card
87
+ * instead of Recharts' single line of text. Kept for API compatibility.
88
+ */
43
89
  export const tooltipContentStyle = {
44
90
  background: chartTheme.tooltipBg,
45
91
  border: `1px solid ${chartTheme.tooltipBorder}`,
@@ -47,15 +93,18 @@ export const tooltipContentStyle = {
47
93
  fontSize: 11,
48
94
  color: chartTheme.tooltipText,
49
95
  };
96
+ /** @deprecated See {@link tooltipContentStyle}. */
50
97
  export const tooltipLabelStyle = {
51
98
  color: chartTheme.tooltipLabel,
52
99
  fontSize: 10,
53
100
  textTransform: 'uppercase',
54
101
  letterSpacing: '0.05em',
55
102
  };
103
+ /** @deprecated See {@link tooltipContentStyle}. */
56
104
  export const tooltipItemStyle = {
57
105
  color: chartTheme.tooltipText,
58
106
  };
107
+ /** @deprecated Tick text is filled by `ChartContainer`'s token classes. */
59
108
  export const axisTickStyle = {
60
109
  fill: chartTheme.axisTick,
61
110
  fontSize: 10,
@@ -1 +1 @@
1
- {"version":3,"file":"chart-theme.js","sourceRoot":"","s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AAE;IACZ,KAAK,EAAE,UAAU,CAAC,WAAW;CACrB,CAAC;AAEX,mDAAmD;AACnD,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,KAAK,EAAE,UAAU,CAAC,YAAY;IAC9B,QAAQ,EAAE,EAAE;IACZ,aAAa,EAAE,WAAW;IAC1B,aAAa,EAAE,QAAQ;CACf,CAAC;AAEX,mDAAmD;AACnD,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,KAAK,EAAE,UAAU,CAAC,WAAW;CACrB,CAAC;AAEX,2EAA2E;AAC3E,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,UAAU,CAAC,QAAQ;IACzB,QAAQ,EAAE,EAAE;CACJ,CAAC"}
@@ -1,5 +1,7 @@
1
1
  import type { JSX } from 'react';
2
- export declare function DistributionChartCard({ title, buckets, p50, p95, p99, height, }: {
2
+ import { type ChartSelection } from './chart-selection.js';
3
+ /** Latency histogram with p50/p95/p99 chips above it. */
4
+ export declare function DistributionChartCard({ title, buckets, p50, p95, p99, height, onSelect, }: {
3
5
  title: string;
4
6
  buckets: {
5
7
  label: string;
@@ -9,5 +11,7 @@ export declare function DistributionChartCard({ title, buckets, p50, p95, p99, h
9
11
  p95?: number;
10
12
  p99?: number;
11
13
  height?: number;
14
+ /** Drill-down: called with the bucket under a click. Omit and the chart is inert. */
15
+ onSelect?: (selection: ChartSelection) => void;
12
16
  }): JSX.Element;
13
17
  //# sourceMappingURL=distribution-chart-card.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"distribution-chart-card.d.ts","sourceRoot":"","sources":["../../../../src/react/components/charts/distribution-chart-card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAejC,wBAAgB,qBAAqB,CAAC,EACpC,KAAK,EACL,OAAO,EACP,GAAG,EACH,GAAG,EACH,GAAG,EACH,MAAY,GACb,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC5C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,GAAG,CAAC,OAAO,CAsDd"}
1
+ {"version":3,"file":"distribution-chart-card.d.ts","sourceRoot":"","sources":["../../../../src/react/components/charts/distribution-chart-card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAUjC,OAAO,EAAE,KAAK,cAAc,EAAkB,MAAM,sBAAsB,CAAC;AAoB3E,yDAAyD;AACzD,wBAAgB,qBAAqB,CAAC,EACpC,KAAK,EACL,OAAO,EACP,GAAG,EACH,GAAG,EACH,GAAG,EACH,MAAY,EACZ,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC5C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qFAAqF;IACrF,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,cAAc,KAAK,IAAI,CAAC;CAChD,GAAG,GAAG,CAAC,OAAO,CAgEd"}
@@ -1,27 +1,46 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts';
3
- import { ChartCard } from './chart-card.js';
4
- import { axisTickStyle, chartTheme, tooltipContentStyle, tooltipItemStyle, tooltipLabelStyle, } from './chart-theme.js';
2
+ import { useMemo } from 'react';
3
+ import { Bar, BarChart, CartesianGrid, XAxis, YAxis } from 'recharts';
4
+ import { ChartContainer, ChartTooltip, ChartTooltipContent, chartColorVar, } from '../../ui/chart.js';
5
+ import { ChartCard, ChartEmptyState } from './chart-card.js';
6
+ import { chartSelection } from './chart-selection.js';
7
+ import { chartConfig } from './chart-theme.js';
5
8
  function formatDuration(ms) {
6
9
  return ms >= 1000 ? `${(ms / 1000).toFixed(1)}s` : `${Math.round(ms)}ms`;
7
10
  }
8
- export function DistributionChartCard({ title, buckets, p50, p95, p99, height = 220, }) {
11
+ /**
12
+ * The percentile chips. `tint-*` rather than three inline colour strings: the
13
+ * tint classes are the console's single source of truth for a tinted chip, and
14
+ * they carry a `--good`/`--warn`/`--bad` that flips with the theme — the old
15
+ * `${color}22` concatenation only worked because the colours were hard-coded
16
+ * hexes, and would have produced an invalid colour the moment one became a token.
17
+ */
18
+ const MARKER_TINT = {
19
+ p50: 'tint-good',
20
+ p95: 'tint-warn',
21
+ p99: 'tint-bad',
22
+ };
23
+ /** Latency histogram with p50/p95/p99 chips above it. */
24
+ export function DistributionChartCard({ title, buckets, p50, p95, p99, height = 220, onSelect, }) {
9
25
  const chips = [];
10
26
  if (p50 !== undefined)
11
- chips.push([p50, 'p50', '#34d399']);
27
+ chips.push([p50, 'p50']);
12
28
  if (p95 !== undefined)
13
- chips.push([p95, 'p95', '#fbbf24']);
29
+ chips.push([p95, 'p95']);
14
30
  if (p99 !== undefined)
15
- chips.push([p99, 'p99', '#f87171']);
31
+ chips.push([p99, 'p99']);
16
32
  const bodyHeight = height - 64;
17
- return (_jsxs(ChartCard, { title: title, height: bodyHeight, children: [chips.length > 0 && (_jsx("div", { style: { display: 'flex', gap: 8, marginBottom: 6, flexWrap: 'wrap' }, children: chips.map(([val, name, color]) => (_jsxs("span", { style: {
18
- fontSize: 10,
19
- fontVariantNumeric: 'tabular-nums',
20
- color,
21
- background: `${color}22`,
22
- border: `1px solid ${color}55`,
23
- borderRadius: 4,
24
- padding: '1px 6px',
25
- }, children: [name, ": ", formatDuration(val)] }, name))) })), _jsx(ResponsiveContainer, { width: "100%", height: "100%", children: _jsxs(BarChart, { data: buckets, margin: { top: 4, right: 8, bottom: 0, left: -16 }, children: [_jsx(CartesianGrid, { stroke: chartTheme.gridStroke, vertical: false }), _jsx(XAxis, { dataKey: "label", tick: axisTickStyle, stroke: chartTheme.axisStroke, tickLine: false }), _jsx(YAxis, { tick: axisTickStyle, stroke: chartTheme.axisStroke, tickLine: false, allowDecimals: false, width: 40 }), _jsx(Tooltip, { contentStyle: tooltipContentStyle, labelStyle: tooltipLabelStyle, itemStyle: tooltipItemStyle }), _jsx(Bar, { dataKey: "count", fill: "#0ea5e9", radius: [3, 3, 0, 0], isAnimationActive: false })] }) })] }));
33
+ const config = useMemo(() => chartConfig(['count'], () => 'var(--live)'), []);
34
+ const clickProps = onSelect
35
+ ? {
36
+ onClick: (_datum, index) => {
37
+ const bucket = buckets[index];
38
+ if (bucket)
39
+ onSelect(chartSelection({ label: bucket.label, value: bucket.count }));
40
+ },
41
+ cursor: 'pointer',
42
+ }
43
+ : {};
44
+ return (_jsx(ChartCard, { title: title, height: bodyHeight, children: _jsxs("div", { className: "flex h-full flex-col", children: [chips.length > 0 && (_jsx("div", { className: "mb-1.5 flex flex-wrap gap-2", children: chips.map(([value, name]) => (_jsxs("span", { className: `rounded border px-1.5 text-[10px] tabular-nums ${MARKER_TINT[name]}`, children: [name, ": ", formatDuration(value)] }, name))) })), _jsx("div", { className: "min-h-0 flex-1", children: buckets.length === 0 ? (_jsx(ChartEmptyState, {})) : (_jsx(ChartContainer, { config: config, children: _jsxs(BarChart, { data: buckets, margin: { top: 4, right: 8, bottom: 0, left: -16 }, children: [_jsx(CartesianGrid, { vertical: false }), _jsx(XAxis, { dataKey: "label", tickLine: false }), _jsx(YAxis, { tickLine: false, allowDecimals: false, width: 40 }), _jsx(ChartTooltip, { cursor: { fill: 'color-mix(in srgb, var(--text) 5%, transparent)' }, content: _jsx(ChartTooltipContent, {}) }), _jsx(Bar, { dataKey: "count", name: "count", fill: chartColorVar('count'), radius: [3, 3, 0, 0], isAnimationActive: false, ...clickProps })] }) })) })] }) }));
26
45
  }
27
46
  //# sourceMappingURL=distribution-chart-card.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"distribution-chart-card.js","sourceRoot":"","sources":["../../../../src/react/components/charts/distribution-chart-card.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,aAAa,EAAE,mBAAmB,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACpG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,aAAa,EACb,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,SAAS,cAAc,CAAC,EAAU;IAChC,OAAO,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC;AAC3E,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,EACpC,KAAK,EACL,OAAO,EACP,GAAG,EACH,GAAG,EACH,GAAG,EACH,MAAM,GAAG,GAAG,GAQb;IACC,MAAM,KAAK,GAAoC,EAAE,CAAC;IAClD,IAAI,GAAG,KAAK,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC;IAC3D,IAAI,GAAG,KAAK,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC;IAC3D,IAAI,GAAG,KAAK,SAAS;QAAE,KAAK,CAAC,IAAI,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IACJ,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,UAAU,CAAC,UAAU,EAC7B,QAAQ,EAAE,KAAK,EACf,aAAa,EAAE,KAAK,EACpB,KAAK,EAAE,EAAE,GACT,EACF,KAAC,OAAO,IACN,YAAY,EAAE,mBAAmB,EACjC,UAAU,EAAE,iBAAiB,EAC7B,SAAS,EAAE,gBAAgB,GAC3B,EACF,KAAC,GAAG,IAAC,OAAO,EAAC,OAAO,EAAC,IAAI,EAAC,SAAS,EAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,iBAAiB,EAAE,KAAK,GAAI,IAC7E,GACS,IACZ,CACb,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"distribution-chart-card.js","sourceRoot":"","sources":["../../../../src/react/components/charts/distribution-chart-card.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtE,OAAO,EACL,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAuB,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,SAAS,cAAc,CAAC,EAAU;IAChC,OAAO,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC;AAC3E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,GAAG;IAClB,GAAG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I,CAClB,GACG,IACF,GACI,CACb,CAAC;AACJ,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import type { JSX } from 'react';
2
+ /** Half-dial gauge: one value against a min/max, with the reading over the arc. */
2
3
  export declare function GaugeCard({ title, value, min, max, label, color, height, }: {
3
4
  title: string;
4
5
  value: number;
@@ -1 +1 @@
1
- {"version":3,"file":"gauge-card.d.ts","sourceRoot":"","sources":["../../../../src/react/components/charts/gauge-card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAIjC,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,KAAK,EACL,GAAO,EACP,GAAO,EACP,KAAK,EACL,KAAqB,EACrB,MAAY,GACb,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,GAAG,CAAC,OAAO,CAwCd"}
1
+ {"version":3,"file":"gauge-card.d.ts","sourceRoot":"","sources":["../../../../src/react/components/charts/gauge-card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAOjC,mFAAmF;AACnF,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,KAAK,EACL,GAAO,EACP,GAAO,EACP,KAAK,EACL,KAAqB,EACrB,MAAY,GACb,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,GAAG,CAAC,OAAO,CAiDd"}
@@ -1,19 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { RadialBar, RadialBarChart, ResponsiveContainer } from 'recharts';
2
+ import { useMemo } from 'react';
3
+ import { PolarAngleAxis, RadialBar, RadialBarChart } from 'recharts';
4
+ import { ChartContainer, chartColorVar } from '../../ui/chart.js';
3
5
  import { ChartCard } from './chart-card.js';
6
+ import { chartConfig } from './chart-theme.js';
7
+ /** Half-dial gauge: one value against a min/max, with the reading over the arc. */
4
8
  export function GaugeCard({ title, value, min = 0, max = 1, label, color = 'var(--good)', height = 220, }) {
5
9
  const range = max - min;
6
10
  const pct = range === 0 ? 0 : Math.max(0, Math.min(1, (value - min) / range));
7
11
  const displayLabel = label ?? `${Math.round(pct * 100)}%`;
8
12
  const bodyHeight = height - 64;
9
- const data = [{ value: pct * 100, fill: color }];
10
- return (_jsx(ChartCard, { title: title, height: bodyHeight, children: _jsxs("div", { style: { position: 'relative', height: bodyHeight }, children: [_jsx(ResponsiveContainer, { width: "100%", height: "100%", children: _jsx(RadialBarChart, { innerRadius: "60%", outerRadius: "100%", data: data, startAngle: 180, endAngle: 0, barSize: 16, children: _jsx(RadialBar, { dataKey: "value", cornerRadius: 4, isAnimationActive: false }) }) }), _jsx("div", { style: {
11
- position: 'absolute',
12
- inset: 0,
13
- display: 'flex',
14
- alignItems: 'center',
15
- justifyContent: 'center',
16
- paddingTop: '40%',
17
- }, children: _jsx("span", { style: { fontSize: 20, fontWeight: 600, color: 'var(--text)' }, children: displayLabel }) })] }) }));
13
+ const config = useMemo(() => chartConfig(['value'], () => color, () => title), [color, title]);
14
+ const data = [{ value: pct * 100 }];
15
+ return (_jsx(ChartCard, { title: title, height: bodyHeight, children: _jsxs("div", { className: "relative h-full", children: [_jsx(ChartContainer, { config: config, children: _jsxs(RadialBarChart, { innerRadius: "60%", outerRadius: "100%", data: data, startAngle: 180, endAngle: 0, barSize: 16, children: [_jsx(PolarAngleAxis, { type: "number", domain: [0, 100], tick: false, axisLine: false }), _jsx(RadialBar, { dataKey: "value", fill: chartColorVar('value'), background: true, cornerRadius: 4, isAnimationActive: false })] }) }), _jsx("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-center pt-[40%]", children: _jsx("span", { className: "text-xl font-semibold tabular-nums text-foreground", children: displayLabel }) })] }) }));
18
16
  }
19
17
  //# sourceMappingURL=gauge-card.js.map