@langchain/macaw-components 1.5.2 → 1.6.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.
- package/dist/catalog.json +697 -683
- package/dist/components/ChartCard/ChartCardSkeleton.d.ts +1 -1
- package/dist/components/ChartCard/ChartCardSkeleton.js +50 -1
- package/dist/components/ChartCard/ChartCardSkeleton.js.map +1 -1
- package/dist/components/RadarChart/RadarChart.d.ts +85 -0
- package/dist/components/RadarChart/RadarChart.js +357 -0
- package/dist/components/RadarChart/RadarChart.js.map +1 -0
- package/dist/components/RadarChart/index.d.ts +2 -0
- package/dist/components/RadarChart/index.js +2 -0
- package/dist/utilities.css +1 -1
- package/docs/DESIGN.md +2 -0
- package/docs/STYLES.md +39 -39
- package/package.json +6 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CSSProperties } from 'react';
|
|
2
|
-
export type ChartCardSkeletonVariant = 'bar' | 'horizontal-bar' | 'line' | 'donut' | 'metric' | 'sparkline' | 'sankey';
|
|
2
|
+
export type ChartCardSkeletonVariant = 'bar' | 'horizontal-bar' | 'line' | 'donut' | 'metric' | 'sparkline' | 'radar' | 'heatmap' | 'sankey';
|
|
3
3
|
export declare const ChartCardSkeleton: ({ variant, className, style, }: {
|
|
4
4
|
variant: ChartCardSkeletonVariant;
|
|
5
5
|
className?: string;
|
|
@@ -99,11 +99,60 @@ var ChartCardSkeleton = ({ variant, className, style }) => /* @__PURE__ */ jsxs(
|
|
|
99
99
|
})] }, x))]
|
|
100
100
|
})
|
|
101
101
|
}),
|
|
102
|
+
variant === "radar" && /* @__PURE__ */ jsx("div", {
|
|
103
|
+
"aria-hidden": "true",
|
|
104
|
+
className: "relative min-h-0 flex-1",
|
|
105
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
106
|
+
viewBox: "0 0 440 340",
|
|
107
|
+
focusable: "false",
|
|
108
|
+
fill: "var(--bg-surface-level-3)",
|
|
109
|
+
className: "absolute inset-0 size-full animate-pulse motion-reduce:animate-none",
|
|
110
|
+
children: [
|
|
111
|
+
/* @__PURE__ */ jsxs("g", {
|
|
112
|
+
fill: "none",
|
|
113
|
+
stroke: "var(--border-muted)",
|
|
114
|
+
children: [
|
|
115
|
+
/* @__PURE__ */ jsx("path", { d: "M220 74 316 170 220 266 124 170Z" }),
|
|
116
|
+
/* @__PURE__ */ jsx("path", { d: "M220 122 268 170 220 218 172 170Z" }),
|
|
117
|
+
/* @__PURE__ */ jsx("path", { d: "M220 74V266M124 170H316" })
|
|
118
|
+
]
|
|
119
|
+
}),
|
|
120
|
+
/* @__PURE__ */ jsx("path", {
|
|
121
|
+
d: "M220 90 294 170 220 242 178 170Z",
|
|
122
|
+
opacity: .6
|
|
123
|
+
}),
|
|
124
|
+
[
|
|
125
|
+
[196, 34],
|
|
126
|
+
[340, 156],
|
|
127
|
+
[196, 294],
|
|
128
|
+
[52, 156]
|
|
129
|
+
].map(([x, y]) => /* @__PURE__ */ jsxs("g", {
|
|
130
|
+
transform: `translate(${x} ${y})`,
|
|
131
|
+
children: [/* @__PURE__ */ jsx("rect", {
|
|
132
|
+
width: 48,
|
|
133
|
+
height: 8,
|
|
134
|
+
rx: 4
|
|
135
|
+
}), /* @__PURE__ */ jsx("rect", {
|
|
136
|
+
x: 12,
|
|
137
|
+
y: 14,
|
|
138
|
+
width: 24,
|
|
139
|
+
height: 6,
|
|
140
|
+
rx: 3
|
|
141
|
+
})]
|
|
142
|
+
}, `${x}-${y}`))
|
|
143
|
+
]
|
|
144
|
+
})
|
|
145
|
+
}),
|
|
146
|
+
variant === "heatmap" && /* @__PURE__ */ jsx("div", {
|
|
147
|
+
"aria-hidden": "true",
|
|
148
|
+
className: "grid min-h-0 flex-1 grid-cols-15 grid-rows-6 gap-space-1",
|
|
149
|
+
children: Array.from({ length: 90 }, (_, index) => /* @__PURE__ */ jsx(Skeleton, { className: "h-full min-h-0 rounded-xs motion-reduce:animate-none" }, index))
|
|
150
|
+
}),
|
|
102
151
|
variant === "metric" && /* @__PURE__ */ jsxs("div", {
|
|
103
152
|
className: "flex min-h-0 flex-1 flex-col justify-center gap-space-2",
|
|
104
153
|
children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-1/2 motion-reduce:animate-none" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-2/3 motion-reduce:animate-none" })]
|
|
105
154
|
}),
|
|
106
|
-
variant !== "metric" && /* @__PURE__ */ jsx(LegendSkeleton, {})
|
|
155
|
+
variant !== "metric" && variant !== "heatmap" && /* @__PURE__ */ jsx(LegendSkeleton, {})
|
|
107
156
|
]
|
|
108
157
|
});
|
|
109
158
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartCardSkeleton.js","names":[],"sources":["../../../src/components/ChartCard/ChartCardSkeleton.tsx"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nimport { cn } from '../../utils/cn';\nimport { Skeleton } from '../Skeleton';\n\nexport type ChartCardSkeletonVariant =\n | 'bar'\n | 'horizontal-bar'\n | 'line'\n | 'donut'\n | 'metric'\n | 'sparkline'\n | 'sankey';\n\nconst HORIZONTAL_BAR_WIDTHS = ['35%', '62%', '48%', '78%', '55%'] as const;\n\nconst BAR_HEIGHTS = ['35%', '62%', '48%', '78%', '55%', '70%', '42%'] as const;\n\nconst LegendSkeleton = () => (\n <div aria-hidden=\"true\" className=\"flex min-w-0 items-center gap-space-2\">\n <Skeleton className=\"h-4 w-20 motion-reduce:animate-none\" />\n <Skeleton className=\"h-4 w-24 motion-reduce:animate-none\" />\n <Skeleton className=\"h-4 w-16 motion-reduce:animate-none\" />\n </div>\n);\n\nconst Plot = ({ children }: { children: React.ReactNode }) => (\n <div className=\"relative min-h-0 flex-1 border-b border-l border-muted\">\n {/* Anchor percentage-sized marks to the plot even in auto-height cards. */}\n <div className=\"absolute inset-0 flex px-space-2\">{children}</div>\n </div>\n);\n\nexport const ChartCardSkeleton = ({\n variant,\n className,\n style,\n}: {\n variant: ChartCardSkeletonVariant;\n className?: string;\n style?: CSSProperties;\n}) => (\n <div\n role=\"status\"\n aria-label=\"Loading chart\"\n style={style}\n className={cn(\n 'flex min-h-[13.5rem] flex-1 flex-col gap-space-2',\n variant === 'metric' && 'min-h-0',\n className\n )}\n >\n {variant === 'bar' && (\n <Plot>\n <div className=\"flex size-full items-end gap-space-2\">\n {BAR_HEIGHTS.map((height, index) => (\n <Skeleton\n key={index}\n className=\"min-w-0 flex-1 rounded-b-none rounded-t-md motion-reduce:animate-none\"\n style={{ height }}\n />\n ))}\n </div>\n </Plot>\n )}\n {variant === 'horizontal-bar' && (\n <Plot>\n <div className=\"flex size-full flex-col gap-space-2 py-space-2\">\n {HORIZONTAL_BAR_WIDTHS.map((width, index) => (\n <Skeleton\n key={index}\n className=\"min-h-0 flex-1 rounded-l-none rounded-r-md motion-reduce:animate-none\"\n style={{ width }}\n />\n ))}\n </div>\n </Plot>\n )}\n {(variant === 'line' || variant === 'sparkline') && (\n <Plot>\n <Skeleton\n className=\"size-full rounded-none motion-reduce:animate-none\"\n style={{\n clipPath:\n 'polygon(0 63%, 20% 43%, 38% 56%, 60% 26%, 78% 40%, 100% 13%, 100% 17%, 78% 44%, 60% 30%, 38% 60%, 20% 47%, 0 67%)',\n }}\n />\n </Plot>\n )}\n {variant === 'donut' && (\n <div className=\"flex min-h-0 flex-1 items-center justify-center\">\n <div className=\"size-32 animate-pulse rounded-full border-[1.5rem] border-muted motion-reduce:animate-none\" />\n </div>\n )}\n {variant === 'sankey' && (\n <div aria-hidden=\"true\" className=\"relative min-h-0 flex-1\">\n <svg\n viewBox=\"0 0 400 192\"\n preserveAspectRatio=\"none\"\n focusable=\"false\"\n fill=\"var(--bg-surface-level-3)\"\n className=\"absolute inset-0 size-full animate-pulse motion-reduce:animate-none\"\n >\n <g opacity={0.5}>\n {[0, 184].map((offset) => (\n <g key={offset} transform={`translate(${offset} 0)`}>\n <path d=\"M20 12H196V60H20Z\" />\n <path d=\"M20 60C108 60 108 108 196 108V132C108 132 108 84 20 84Z\" />\n <path d=\"M20 108C108 108 108 60 196 60V84C108 84 108 132 20 132Z\" />\n <path d=\"M20 132H196V180H20Z\" />\n </g>\n ))}\n </g>\n {[12, 196, 380].map((x) => (\n <g key={x}>\n <rect x={x} y={12} width={8} height={72} />\n <rect x={x} y={108} width={8} height={72} />\n </g>\n ))}\n </svg>\n </div>\n )}\n {variant === 'metric' && (\n <div className=\"flex min-h-0 flex-1 flex-col justify-center gap-space-2\">\n <Skeleton className=\"h-9 w-1/2 motion-reduce:animate-none\" />\n <Skeleton className=\"h-4 w-2/3 motion-reduce:animate-none\" />\n </div>\n )}\n {variant !== 'metric' && <LegendSkeleton />}\n </div>\n);\n"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"ChartCardSkeleton.js","names":[],"sources":["../../../src/components/ChartCard/ChartCardSkeleton.tsx"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nimport { cn } from '../../utils/cn';\nimport { Skeleton } from '../Skeleton';\n\nexport type ChartCardSkeletonVariant =\n | 'bar'\n | 'horizontal-bar'\n | 'line'\n | 'donut'\n | 'metric'\n | 'sparkline'\n | 'radar'\n | 'heatmap'\n | 'sankey';\n\nconst HORIZONTAL_BAR_WIDTHS = ['35%', '62%', '48%', '78%', '55%'] as const;\n\nconst BAR_HEIGHTS = ['35%', '62%', '48%', '78%', '55%', '70%', '42%'] as const;\n\nconst LegendSkeleton = () => (\n <div aria-hidden=\"true\" className=\"flex min-w-0 items-center gap-space-2\">\n <Skeleton className=\"h-4 w-20 motion-reduce:animate-none\" />\n <Skeleton className=\"h-4 w-24 motion-reduce:animate-none\" />\n <Skeleton className=\"h-4 w-16 motion-reduce:animate-none\" />\n </div>\n);\n\nconst Plot = ({ children }: { children: React.ReactNode }) => (\n <div className=\"relative min-h-0 flex-1 border-b border-l border-muted\">\n {/* Anchor percentage-sized marks to the plot even in auto-height cards. */}\n <div className=\"absolute inset-0 flex px-space-2\">{children}</div>\n </div>\n);\n\nexport const ChartCardSkeleton = ({\n variant,\n className,\n style,\n}: {\n variant: ChartCardSkeletonVariant;\n className?: string;\n style?: CSSProperties;\n}) => (\n <div\n role=\"status\"\n aria-label=\"Loading chart\"\n style={style}\n className={cn(\n 'flex min-h-[13.5rem] flex-1 flex-col gap-space-2',\n variant === 'metric' && 'min-h-0',\n className\n )}\n >\n {variant === 'bar' && (\n <Plot>\n <div className=\"flex size-full items-end gap-space-2\">\n {BAR_HEIGHTS.map((height, index) => (\n <Skeleton\n key={index}\n className=\"min-w-0 flex-1 rounded-b-none rounded-t-md motion-reduce:animate-none\"\n style={{ height }}\n />\n ))}\n </div>\n </Plot>\n )}\n {variant === 'horizontal-bar' && (\n <Plot>\n <div className=\"flex size-full flex-col gap-space-2 py-space-2\">\n {HORIZONTAL_BAR_WIDTHS.map((width, index) => (\n <Skeleton\n key={index}\n className=\"min-h-0 flex-1 rounded-l-none rounded-r-md motion-reduce:animate-none\"\n style={{ width }}\n />\n ))}\n </div>\n </Plot>\n )}\n {(variant === 'line' || variant === 'sparkline') && (\n <Plot>\n <Skeleton\n className=\"size-full rounded-none motion-reduce:animate-none\"\n style={{\n clipPath:\n 'polygon(0 63%, 20% 43%, 38% 56%, 60% 26%, 78% 40%, 100% 13%, 100% 17%, 78% 44%, 60% 30%, 38% 60%, 20% 47%, 0 67%)',\n }}\n />\n </Plot>\n )}\n {variant === 'donut' && (\n <div className=\"flex min-h-0 flex-1 items-center justify-center\">\n <div className=\"size-32 animate-pulse rounded-full border-[1.5rem] border-muted motion-reduce:animate-none\" />\n </div>\n )}\n {variant === 'sankey' && (\n <div aria-hidden=\"true\" className=\"relative min-h-0 flex-1\">\n <svg\n viewBox=\"0 0 400 192\"\n preserveAspectRatio=\"none\"\n focusable=\"false\"\n fill=\"var(--bg-surface-level-3)\"\n className=\"absolute inset-0 size-full animate-pulse motion-reduce:animate-none\"\n >\n <g opacity={0.5}>\n {[0, 184].map((offset) => (\n <g key={offset} transform={`translate(${offset} 0)`}>\n <path d=\"M20 12H196V60H20Z\" />\n <path d=\"M20 60C108 60 108 108 196 108V132C108 132 108 84 20 84Z\" />\n <path d=\"M20 108C108 108 108 60 196 60V84C108 84 108 132 20 132Z\" />\n <path d=\"M20 132H196V180H20Z\" />\n </g>\n ))}\n </g>\n {[12, 196, 380].map((x) => (\n <g key={x}>\n <rect x={x} y={12} width={8} height={72} />\n <rect x={x} y={108} width={8} height={72} />\n </g>\n ))}\n </svg>\n </div>\n )}\n {variant === 'radar' && (\n <div aria-hidden=\"true\" className=\"relative min-h-0 flex-1\">\n <svg\n // Match the radar chart's plot and outside-label space.\n viewBox=\"0 0 440 340\"\n focusable=\"false\"\n fill=\"var(--bg-surface-level-3)\"\n className=\"absolute inset-0 size-full animate-pulse motion-reduce:animate-none\"\n >\n <g fill=\"none\" stroke=\"var(--border-muted)\">\n {/* Concentric diamonds suggest axes without implying loaded data. */}\n <path d=\"M220 74 316 170 220 266 124 170Z\" />\n <path d=\"M220 122 268 170 220 218 172 170Z\" />\n <path d=\"M220 74V266M124 170H316\" />\n </g>\n <path d=\"M220 90 294 170 220 242 178 170Z\" opacity={0.6} />\n {/* Paired bars stand in for the four axis names and values. */}\n {[\n [196, 34],\n [340, 156],\n [196, 294],\n [52, 156],\n ].map(([x, y]) => (\n <g key={`${x}-${y}`} transform={`translate(${x} ${y})`}>\n <rect width={48} height={8} rx={4} />\n <rect x={12} y={14} width={24} height={6} rx={3} />\n </g>\n ))}\n </svg>\n </div>\n )}\n {variant === 'heatmap' && (\n <div\n aria-hidden=\"true\"\n className=\"grid min-h-0 flex-1 grid-cols-15 grid-rows-6 gap-space-1\"\n >\n {/* A 6-by-15 grid balances a recognizable matrix with visual breathing room. */}\n {Array.from({ length: 6 * 15 }, (_, index) => (\n <Skeleton\n key={index}\n className=\"h-full min-h-0 rounded-xs motion-reduce:animate-none\"\n />\n ))}\n </div>\n )}\n {variant === 'metric' && (\n <div className=\"flex min-h-0 flex-1 flex-col justify-center gap-space-2\">\n <Skeleton className=\"h-9 w-1/2 motion-reduce:animate-none\" />\n <Skeleton className=\"h-4 w-2/3 motion-reduce:animate-none\" />\n </div>\n )}\n {variant !== 'metric' && variant !== 'heatmap' && <LegendSkeleton />}\n </div>\n);\n"],"mappings":";;;;AAgBA,IAAM,wBAAwB;CAAC;CAAO;CAAO;CAAO;CAAO;AAAK;AAEhE,IAAM,cAAc;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;CAAO;AAAK;AAEpE,IAAM,uBACJ,qBAAC,OAAD;CAAK,eAAY;CAAO,WAAU;CAAlC,UAAA;EACE,oBAAC,UAAD,EAAU,WAAU,sCAAuC,CAAA;EAC3D,oBAAC,UAAD,EAAU,WAAU,sCAAuC,CAAA;EAC3D,oBAAC,UAAD,EAAU,WAAU,sCAAuC,CAAA;CACxD;;AAGP,IAAM,QAAQ,EAAE,eACd,oBAAC,OAAD;CAAK,WAAU;CAEb,UAAA,oBAAC,OAAD;EAAK,WAAU;EAAoC;CAAc,CAAA;AAC9D,CAAA;AAGP,IAAa,qBAAqB,EAChC,SACA,WACA,YAMA,qBAAC,OAAD;CACE,MAAK;CACL,cAAW;CACJ;CACP,WAAW,GACT,oDACA,YAAY,YAAY,WACxB,SACF;CARF,UAAA;EAUG,YAAY,SACX,oBAAC,MAAD,EAAA,UACE,oBAAC,OAAD;GAAK,WAAU;GACZ,UAAA,YAAY,KAAK,QAAQ,UACxB,oBAAC,UAAD;IAEE,WAAU;IACV,OAAO,EAAE,OAAO;GACjB,GAHM,KAGN,CACF;EACE,CAAA,EACD,CAAA;EAEP,YAAY,oBACX,oBAAC,MAAD,EAAA,UACE,oBAAC,OAAD;GAAK,WAAU;GACZ,UAAA,sBAAsB,KAAK,OAAO,UACjC,oBAAC,UAAD;IAEE,WAAU;IACV,OAAO,EAAE,MAAM;GAChB,GAHM,KAGN,CACF;EACE,CAAA,EACD,CAAA;GAEN,YAAY,UAAU,YAAY,gBAClC,oBAAC,MAAD,EAAA,UACE,oBAAC,UAAD;GACE,WAAU;G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oBAAC,QAAD,EAAM,GAAE,0BAA2B,CAAA;MAClC;;KACH,oBAAC,QAAD;MAAM,GAAE;MAAmC,SAAS;KAAM,CAAA;KAEzD;MACC,CAAC,KAAK,EAAE;MACR,CAAC,KAAK,GAAG;MACT,CAAC,KAAK,GAAG;MACT,CAAC,IAAI,GAAG;KACV,CAAC,CAAC,KAAK,CAAC,GAAG,OACT,qBAAC,KAAD;MAAqB,WAAW,aAAa,EAAE,GAAG,EAAE;MAApD,UAAA,CACE,oBAAC,QAAD;OAAM,OAAO;OAAI,QAAQ;OAAG,IAAI;MAAI,CAAA,GACpC,oBAAC,QAAD;OAAM,GAAG;OAAI,GAAG;OAAI,OAAO;OAAI,QAAQ;OAAG,IAAI;MAAI,CAAA,CACjD;KAHK,GAAA,GAAG,EAAE,GAAG,GAGb,CACJ;IACE;;EACF,CAAA;EAEN,YAAY,aACX,oBAAC,OAAD;GACE,eAAY;GACZ,WAAU;GAGT,UAAA,MAAM,KAAK,EAAE,QAAQ,GAAO,IAAI,GAAG,UAClC,oBAAC,UAAD,EAEE,WAAU,uDACX,GAFM,KAEN,CACF;EACE,CAAA;EAEN,YAAY,YACX,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,oBAAC,UAAD,EAAU,WAAU,uCAAwC,CAAA,GAC5D,oBAAC,UAAD,EAAU,WAAU,uCAAwC,CAAA,CACzD;;EAEN,YAAY,YAAY,YAAY,aAAa,oBAAC,gBAAD,CAAiB,CAAA;CAChE"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
export type RadarChartDatum = {
|
|
3
|
+
/** Unique, stable identifier for this axis. */
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
value: number;
|
|
7
|
+
/** Semantic chart color; defaults to the categorical fill palette in axis order. */
|
|
8
|
+
color?: string;
|
|
9
|
+
};
|
|
10
|
+
export type RadarChartAxis = {
|
|
11
|
+
/** Unique, stable identifier; keys each series' `values`. */
|
|
12
|
+
id: string;
|
|
13
|
+
label: string;
|
|
14
|
+
};
|
|
15
|
+
export type RadarChartSeries = {
|
|
16
|
+
/** Unique, stable identifier; use it as the matching legend item's id. */
|
|
17
|
+
id: string;
|
|
18
|
+
label: string;
|
|
19
|
+
/** Values keyed by axis id. Missing, negative, and non-finite values plot at zero. */
|
|
20
|
+
values: Readonly<Record<string, number | undefined>>;
|
|
21
|
+
/**
|
|
22
|
+
* Outline color; defaults to the categorical line palette in series order.
|
|
23
|
+
* The area uses the hue-matched fill color.
|
|
24
|
+
*/
|
|
25
|
+
color?: string;
|
|
26
|
+
};
|
|
27
|
+
/** One axis and every visible series' value on it, for multi-series tooltips. */
|
|
28
|
+
export type RadarChartAxisValues = RadarChartAxis & {
|
|
29
|
+
/** Visible series in input order, with sanitized values and outline colors. */
|
|
30
|
+
values: readonly {
|
|
31
|
+
id: string;
|
|
32
|
+
label: string;
|
|
33
|
+
value: number;
|
|
34
|
+
color: string;
|
|
35
|
+
}[];
|
|
36
|
+
};
|
|
37
|
+
type RadarChartBaseProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
38
|
+
/** Shared axis maximum; defaults to the largest finite positive value. */
|
|
39
|
+
maxValue?: number;
|
|
40
|
+
/** Formats labels and the accessible data summary. */
|
|
41
|
+
formatValue?: (value: number) => string;
|
|
42
|
+
};
|
|
43
|
+
export type RadarChartSingleSeriesProps = RadarChartBaseProps & {
|
|
44
|
+
/** Axes in clockwise order, beginning at the top. Supply at least three. */
|
|
45
|
+
data: readonly RadarChartDatum[];
|
|
46
|
+
/**
|
|
47
|
+
* Content inside ChartTooltip on point or label hover and keyboard focus.
|
|
48
|
+
* Receives the sanitized value and resolved color. Compose ChartTooltipHeader,
|
|
49
|
+
* ChartTooltipBody, and ChartTooltipRow here; omit for a static chart.
|
|
50
|
+
*/
|
|
51
|
+
renderTooltip?: (datum: RadarChartDatum) => ReactNode;
|
|
52
|
+
axes?: never;
|
|
53
|
+
series?: never;
|
|
54
|
+
renderAxisTooltip?: never;
|
|
55
|
+
selectedIds?: never;
|
|
56
|
+
activeLegendItemId?: never;
|
|
57
|
+
};
|
|
58
|
+
export type RadarChartMultiSeriesProps = RadarChartBaseProps & {
|
|
59
|
+
/** Axes in clockwise order, beginning at the top. Supply at least three. */
|
|
60
|
+
axes: readonly RadarChartAxis[];
|
|
61
|
+
/**
|
|
62
|
+
* Overlapping areas on the shared axes, drawn in input order. Keep to about
|
|
63
|
+
* four; beyond that, filter series or use small multiples.
|
|
64
|
+
*/
|
|
65
|
+
series: readonly RadarChartSeries[];
|
|
66
|
+
/**
|
|
67
|
+
* Content inside ChartTooltip when an axis is hovered anywhere in its sector
|
|
68
|
+
* or focused. Compose one ChartTooltipRow per series; omit for a static chart.
|
|
69
|
+
*/
|
|
70
|
+
renderAxisTooltip?: (axis: RadarChartAxisValues) => ReactNode;
|
|
71
|
+
/** When non-empty, only these series are drawn. Colors keep their series order. */
|
|
72
|
+
selectedIds?: ReadonlySet<string>;
|
|
73
|
+
/** Emphasizes one series from an external legend and dims the rest. */
|
|
74
|
+
activeLegendItemId?: string | null;
|
|
75
|
+
data?: never;
|
|
76
|
+
renderTooltip?: never;
|
|
77
|
+
};
|
|
78
|
+
export type RadarChartProps = RadarChartSingleSeriesProps | RadarChartMultiSeriesProps;
|
|
79
|
+
/**
|
|
80
|
+
* A radar with a shared scale and clockwise, outside axis labels. Pass `data`
|
|
81
|
+
* for one series with categorical points, or `axes` and `series` for
|
|
82
|
+
* overlapping areas identified by an external legend.
|
|
83
|
+
*/
|
|
84
|
+
export declare const RadarChart: (props: RadarChartProps) => import("react").JSX.Element;
|
|
85
|
+
export {};
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn.js";
|
|
2
|
+
import zIndices from "../../utils/zIndices.js";
|
|
3
|
+
import { useZIndex } from "../../utils/useZIndex.js";
|
|
4
|
+
import { ZIndexProvider } from "../../utils/ZIndexContext.js";
|
|
5
|
+
import { Text } from "../Text/Text.js";
|
|
6
|
+
import { CHART_DIMMED_OPACITY } from "../../utils/chartConstants.js";
|
|
7
|
+
import { CHART_SINGLE_FILL_COLOR, getCategoricalFillChartColor, getCategoricalFillColor, getCategoricalLineChartColor } from "../../utils/chartColors.js";
|
|
8
|
+
import { ChartTooltip } from "../ChartTooltip/ChartTooltip.js";
|
|
9
|
+
import { useId, useRef, useState } from "react";
|
|
10
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
12
|
+
//#region packages/components/src/components/RadarChart/RadarChart.tsx
|
|
13
|
+
var numberFormatter = new Intl.NumberFormat("en-US");
|
|
14
|
+
var formatNumber = (value) => numberFormatter.format(value);
|
|
15
|
+
var sanitize = (value) => value !== void 0 && Number.isFinite(value) ? Math.max(0, value) : 0;
|
|
16
|
+
var VIEWBOX_WIDTH = 440;
|
|
17
|
+
var VIEWBOX_HEIGHT = 340;
|
|
18
|
+
var CENTER_X = VIEWBOX_WIDTH / 2;
|
|
19
|
+
var CENTER_Y = VIEWBOX_HEIGHT / 2;
|
|
20
|
+
var RADIUS = 96;
|
|
21
|
+
var LABEL_RADIUS = 116;
|
|
22
|
+
var LABEL_WIDTH = 100;
|
|
23
|
+
var LABEL_LINE_HEIGHT = 20;
|
|
24
|
+
var LABEL_SIDES = {
|
|
25
|
+
left: {
|
|
26
|
+
offset: LABEL_WIDTH,
|
|
27
|
+
align: "text-right",
|
|
28
|
+
tooltipAlign: "start"
|
|
29
|
+
},
|
|
30
|
+
center: {
|
|
31
|
+
offset: LABEL_WIDTH / 2,
|
|
32
|
+
align: "text-center",
|
|
33
|
+
tooltipAlign: "center"
|
|
34
|
+
},
|
|
35
|
+
right: {
|
|
36
|
+
offset: 0,
|
|
37
|
+
align: "text-left",
|
|
38
|
+
tooltipAlign: "end"
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var GRID_LEVELS = [
|
|
42
|
+
.25,
|
|
43
|
+
.5,
|
|
44
|
+
.75,
|
|
45
|
+
1
|
|
46
|
+
];
|
|
47
|
+
var SERIES_FILL_OPACITY = .08;
|
|
48
|
+
var EMPHASIZED_SERIES_FILL_OPACITY = .2;
|
|
49
|
+
var getAxisLayouts = (axes, labelHeight) => axes.map(({ id }, index) => {
|
|
50
|
+
const angle = index * Math.PI * 2 / axes.length - Math.PI / 2;
|
|
51
|
+
const unitX = Math.cos(angle);
|
|
52
|
+
const unitY = Math.sin(angle);
|
|
53
|
+
const side = LABEL_SIDES[unitX < -.1 ? "left" : unitX > .1 ? "right" : "center"];
|
|
54
|
+
const isAbove = unitY <= -.499999;
|
|
55
|
+
const isBelow = unitY >= .499999;
|
|
56
|
+
return {
|
|
57
|
+
id,
|
|
58
|
+
unitX,
|
|
59
|
+
unitY,
|
|
60
|
+
labelX: CENTER_X + unitX * LABEL_RADIUS - side.offset,
|
|
61
|
+
labelY: CENTER_Y + unitY * LABEL_RADIUS - (isAbove ? labelHeight : isBelow ? 0 : labelHeight / 2),
|
|
62
|
+
align: side.align,
|
|
63
|
+
tooltipSide: isAbove ? "top" : isBelow ? "bottom" : unitX < 0 ? "left" : "right",
|
|
64
|
+
tooltipAlign: isAbove || isBelow ? side.tooltipAlign : "center"
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
var getPoint = (axis, ratio) => [CENTER_X + axis.unitX * RADIUS * ratio, CENTER_Y + axis.unitY * RADIUS * ratio];
|
|
68
|
+
var toPoints = (points) => points.map(([x, y]) => `${x},${y}`).join(" ");
|
|
69
|
+
var getMaximum = (values, maxValue) => maxValue !== void 0 && Number.isFinite(maxValue) && maxValue > 0 ? maxValue : values.reduce((largest, value) => Math.max(largest, value), 0) || 1;
|
|
70
|
+
/**
|
|
71
|
+
* A radar with a shared scale and clockwise, outside axis labels. Pass `data`
|
|
72
|
+
* for one series with categorical points, or `axes` and `series` for
|
|
73
|
+
* overlapping areas identified by an external legend.
|
|
74
|
+
*/
|
|
75
|
+
var RadarChart = (props) => {
|
|
76
|
+
const { data: _data, axes: _axes, series: _series, renderTooltip: _renderTooltip, renderAxisTooltip: _renderAxisTooltip, selectedIds, activeLegendItemId, maxValue, formatValue = formatNumber, className, "aria-label": ariaLabel = "Radar chart", "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...divProps } = props;
|
|
77
|
+
const summaryId = useId();
|
|
78
|
+
const [activeTooltip, setActiveTooltip] = useState(null);
|
|
79
|
+
const isPointerDownRef = useRef(false);
|
|
80
|
+
const tooltipZIndex = useZIndex(zIndices.tooltip);
|
|
81
|
+
const isInteractive = (props.series !== void 0 ? props.renderAxisTooltip : props.renderTooltip) !== void 0;
|
|
82
|
+
const withTooltip = (id, mark, content, layout) => /* @__PURE__ */ jsxs(TooltipPrimitive.Root, {
|
|
83
|
+
open: activeTooltip === id,
|
|
84
|
+
onOpenChange: (open) => setActiveTooltip((active) => open ? id : active === id ? null : active),
|
|
85
|
+
children: [/* @__PURE__ */ jsx(TooltipPrimitive.Trigger, {
|
|
86
|
+
asChild: true,
|
|
87
|
+
onPointerDown: (event) => {
|
|
88
|
+
isPointerDownRef.current = true;
|
|
89
|
+
event.currentTarget.ownerDocument.addEventListener("pointerup", () => {
|
|
90
|
+
isPointerDownRef.current = false;
|
|
91
|
+
}, { once: true });
|
|
92
|
+
},
|
|
93
|
+
onFocus: (event) => {
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
if (isPointerDownRef.current) return;
|
|
96
|
+
const target = event.currentTarget;
|
|
97
|
+
requestAnimationFrame(() => {
|
|
98
|
+
if (target === target.ownerDocument.activeElement) setActiveTooltip(id);
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
children: mark
|
|
102
|
+
}), /* @__PURE__ */ jsx(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsx(TooltipPrimitive.Content, {
|
|
103
|
+
asChild: true,
|
|
104
|
+
side: layout?.tooltipSide,
|
|
105
|
+
align: layout?.tooltipAlign,
|
|
106
|
+
sideOffset: 8,
|
|
107
|
+
collisionPadding: 8,
|
|
108
|
+
children: /* @__PURE__ */ jsx(ChartTooltip, {
|
|
109
|
+
style: { zIndex: tooltipZIndex },
|
|
110
|
+
children: /* @__PURE__ */ jsx(ZIndexProvider, {
|
|
111
|
+
value: tooltipZIndex,
|
|
112
|
+
children: content
|
|
113
|
+
})
|
|
114
|
+
})
|
|
115
|
+
}) })]
|
|
116
|
+
}, id);
|
|
117
|
+
const renderLabel = (layout, height, summary, lines) => /* @__PURE__ */ jsx("foreignObject", {
|
|
118
|
+
x: layout.labelX,
|
|
119
|
+
y: layout.labelY,
|
|
120
|
+
width: LABEL_WIDTH,
|
|
121
|
+
height,
|
|
122
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
123
|
+
className: cn("flex h-full flex-col justify-center", layout.align),
|
|
124
|
+
title: isInteractive ? void 0 : summary,
|
|
125
|
+
children: lines
|
|
126
|
+
})
|
|
127
|
+
});
|
|
128
|
+
const renderSingleSeries = (data, renderDatumTooltip) => {
|
|
129
|
+
const labelHeight = 40;
|
|
130
|
+
const layouts = getAxisLayouts(data, labelHeight);
|
|
131
|
+
const values = data.map(({ value }) => sanitize(value));
|
|
132
|
+
const maximum = getMaximum(values, maxValue);
|
|
133
|
+
const axes = data.map((datum, index) => {
|
|
134
|
+
const value = values[index];
|
|
135
|
+
const formattedValue = formatValue(value);
|
|
136
|
+
return {
|
|
137
|
+
layout: layouts[index],
|
|
138
|
+
datum: {
|
|
139
|
+
...datum,
|
|
140
|
+
value,
|
|
141
|
+
color: datum.color ?? getCategoricalFillChartColor(index)
|
|
142
|
+
},
|
|
143
|
+
formattedValue,
|
|
144
|
+
summary: `${datum.label}: ${formattedValue}`,
|
|
145
|
+
point: getPoint(layouts[index], Math.min(1, value / maximum))
|
|
146
|
+
};
|
|
147
|
+
});
|
|
148
|
+
return {
|
|
149
|
+
layouts,
|
|
150
|
+
summary: axes.map(({ summary }) => summary).join("; "),
|
|
151
|
+
marks: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("polygon", {
|
|
152
|
+
"aria-hidden": "true",
|
|
153
|
+
points: toPoints(axes.map(({ point }) => point)),
|
|
154
|
+
fill: CHART_SINGLE_FILL_COLOR,
|
|
155
|
+
className: "dark:[fill-opacity:0.24] dark:[stroke-opacity:0.8]",
|
|
156
|
+
fillOpacity: .16,
|
|
157
|
+
stroke: getCategoricalLineChartColor(0),
|
|
158
|
+
strokeOpacity: .55,
|
|
159
|
+
strokeWidth: 1.25,
|
|
160
|
+
strokeLinejoin: "round"
|
|
161
|
+
}), axes.map(({ layout, datum, formattedValue, summary, point }) => {
|
|
162
|
+
const [pointX, pointY] = point;
|
|
163
|
+
const mark = /* @__PURE__ */ jsxs("g", {
|
|
164
|
+
className: "group outline-hidden",
|
|
165
|
+
role: isInteractive ? "img" : void 0,
|
|
166
|
+
"aria-label": isInteractive ? summary : void 0,
|
|
167
|
+
"aria-hidden": isInteractive ? void 0 : true,
|
|
168
|
+
tabIndex: isInteractive ? 0 : void 0,
|
|
169
|
+
children: [
|
|
170
|
+
/* @__PURE__ */ jsx("circle", {
|
|
171
|
+
cx: pointX,
|
|
172
|
+
cy: pointY,
|
|
173
|
+
r: 12,
|
|
174
|
+
fill: "transparent"
|
|
175
|
+
}),
|
|
176
|
+
/* @__PURE__ */ jsx("circle", {
|
|
177
|
+
cx: pointX,
|
|
178
|
+
cy: pointY,
|
|
179
|
+
r: 8,
|
|
180
|
+
fill: "none",
|
|
181
|
+
stroke: datum.color,
|
|
182
|
+
strokeWidth: 1.5,
|
|
183
|
+
className: "opacity-0 group-hover:opacity-100 group-focus-visible:stroke-focus group-focus-visible:opacity-100"
|
|
184
|
+
}),
|
|
185
|
+
/* @__PURE__ */ jsx("circle", {
|
|
186
|
+
cx: pointX,
|
|
187
|
+
cy: pointY,
|
|
188
|
+
r: 4,
|
|
189
|
+
fill: datum.color,
|
|
190
|
+
className: "stroke-surface-level-1",
|
|
191
|
+
strokeWidth: 1
|
|
192
|
+
}),
|
|
193
|
+
renderLabel(layout, labelHeight, summary, /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Text, {
|
|
194
|
+
variant: "xs",
|
|
195
|
+
className: "truncate",
|
|
196
|
+
children: datum.label
|
|
197
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
198
|
+
variant: "xs",
|
|
199
|
+
color: "secondary",
|
|
200
|
+
className: "truncate tabular-nums",
|
|
201
|
+
children: formattedValue
|
|
202
|
+
})] }))
|
|
203
|
+
]
|
|
204
|
+
}, datum.id);
|
|
205
|
+
return renderDatumTooltip ? withTooltip(datum.id, mark, renderDatumTooltip(datum)) : mark;
|
|
206
|
+
})] })
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
const renderMultiSeries = (axes, series, renderAxisTooltip) => {
|
|
210
|
+
const layouts = getAxisLayouts(axes, LABEL_LINE_HEIGHT);
|
|
211
|
+
const resolvedSeries = series.map((item, index) => {
|
|
212
|
+
const color = item.color ?? getCategoricalLineChartColor(index);
|
|
213
|
+
return {
|
|
214
|
+
id: item.id,
|
|
215
|
+
label: item.label,
|
|
216
|
+
color,
|
|
217
|
+
fill: getCategoricalFillColor(color),
|
|
218
|
+
values: axes.map(({ id }) => sanitize(item.values[id]))
|
|
219
|
+
};
|
|
220
|
+
});
|
|
221
|
+
const visibleSeries = selectedIds === void 0 || selectedIds.size === 0 ? resolvedSeries : resolvedSeries.filter(({ id }) => selectedIds.has(id));
|
|
222
|
+
const maximum = getMaximum(visibleSeries.flatMap(({ values }) => values), maxValue);
|
|
223
|
+
const plottedSeries = visibleSeries.map((item) => ({
|
|
224
|
+
...item,
|
|
225
|
+
points: item.values.map((value, index) => getPoint(layouts[index], Math.min(1, value / maximum)))
|
|
226
|
+
}));
|
|
227
|
+
const emphasizedId = plottedSeries.some(({ id }) => id === activeLegendItemId) ? activeLegendItemId : null;
|
|
228
|
+
const getSeriesOpacity = (id) => emphasizedId != null && id !== emphasizedId ? CHART_DIMMED_OPACITY : 1;
|
|
229
|
+
return {
|
|
230
|
+
layouts,
|
|
231
|
+
summary: plottedSeries.map((item) => `${item.label}: ${axes.map((axis, index) => `${axis.label} ${formatValue(item.values[index])}`).join(", ")}`).join("; "),
|
|
232
|
+
marks: /* @__PURE__ */ jsxs(Fragment$1, { children: [[...plottedSeries.filter(({ id }) => id !== emphasizedId), ...plottedSeries.filter(({ id }) => id === emphasizedId)].map((item) => {
|
|
233
|
+
const isEmphasized = item.id === emphasizedId;
|
|
234
|
+
return /* @__PURE__ */ jsx("polygon", {
|
|
235
|
+
"aria-hidden": "true",
|
|
236
|
+
points: toPoints(item.points),
|
|
237
|
+
fill: item.fill,
|
|
238
|
+
fillOpacity: isEmphasized ? EMPHASIZED_SERIES_FILL_OPACITY : emphasizedId == null ? SERIES_FILL_OPACITY : 0,
|
|
239
|
+
className: "transition-[opacity,fill-opacity] duration-fast motion-reduce:transition-none",
|
|
240
|
+
opacity: getSeriesOpacity(item.id),
|
|
241
|
+
stroke: item.color,
|
|
242
|
+
strokeWidth: 1.5,
|
|
243
|
+
strokeLinejoin: "round"
|
|
244
|
+
}, item.id);
|
|
245
|
+
}), axes.map((axis, index) => {
|
|
246
|
+
const layout = layouts[index];
|
|
247
|
+
const values = plottedSeries.map((item) => ({
|
|
248
|
+
id: item.id,
|
|
249
|
+
label: item.label,
|
|
250
|
+
value: item.values[index],
|
|
251
|
+
color: item.color
|
|
252
|
+
}));
|
|
253
|
+
const summary = values.length ? `${axis.label}: ${values.map(({ label, value }) => `${label} ${formatValue(value)}`).join(", ")}` : axis.label;
|
|
254
|
+
const [outerX, outerY] = getPoint(layout, 1);
|
|
255
|
+
const [previousX, previousY] = getPoint(layouts[(index - 1 + layouts.length) % layouts.length], 1);
|
|
256
|
+
const [nextX, nextY] = getPoint(layouts[(index + 1) % layouts.length], 1);
|
|
257
|
+
const mark = /* @__PURE__ */ jsxs("g", {
|
|
258
|
+
className: "group outline-hidden",
|
|
259
|
+
role: isInteractive ? "img" : void 0,
|
|
260
|
+
"aria-label": isInteractive ? summary : void 0,
|
|
261
|
+
"aria-hidden": isInteractive ? void 0 : true,
|
|
262
|
+
tabIndex: isInteractive ? 0 : void 0,
|
|
263
|
+
children: [
|
|
264
|
+
/* @__PURE__ */ jsx("polygon", {
|
|
265
|
+
points: toPoints([
|
|
266
|
+
[CENTER_X, CENTER_Y],
|
|
267
|
+
[(previousX + outerX) / 2, (previousY + outerY) / 2],
|
|
268
|
+
[outerX, outerY],
|
|
269
|
+
[(outerX + nextX) / 2, (outerY + nextY) / 2]
|
|
270
|
+
]),
|
|
271
|
+
fill: "transparent"
|
|
272
|
+
}),
|
|
273
|
+
/* @__PURE__ */ jsxs("g", {
|
|
274
|
+
className: "opacity-0 transition-opacity duration-fast group-hover:opacity-100 group-focus-visible:opacity-100 motion-reduce:transition-none",
|
|
275
|
+
children: [/* @__PURE__ */ jsx("line", {
|
|
276
|
+
x1: CENTER_X,
|
|
277
|
+
y1: CENTER_Y,
|
|
278
|
+
x2: outerX,
|
|
279
|
+
y2: outerY,
|
|
280
|
+
stroke: "var(--border-default)",
|
|
281
|
+
className: "group-focus-visible:stroke-focus"
|
|
282
|
+
}), plottedSeries.map((item) => /* @__PURE__ */ jsx("circle", {
|
|
283
|
+
cx: item.points[index][0],
|
|
284
|
+
cy: item.points[index][1],
|
|
285
|
+
r: 3.5,
|
|
286
|
+
fill: item.color,
|
|
287
|
+
opacity: getSeriesOpacity(item.id),
|
|
288
|
+
className: "stroke-surface-level-1",
|
|
289
|
+
strokeWidth: 1.5
|
|
290
|
+
}, item.id))]
|
|
291
|
+
}),
|
|
292
|
+
renderLabel(layout, LABEL_LINE_HEIGHT, summary, /* @__PURE__ */ jsx(Text, {
|
|
293
|
+
variant: "xs",
|
|
294
|
+
className: "truncate",
|
|
295
|
+
children: axis.label
|
|
296
|
+
}))
|
|
297
|
+
]
|
|
298
|
+
}, axis.id);
|
|
299
|
+
return renderAxisTooltip ? withTooltip(axis.id, mark, renderAxisTooltip({
|
|
300
|
+
id: axis.id,
|
|
301
|
+
label: axis.label,
|
|
302
|
+
values
|
|
303
|
+
}), layout) : mark;
|
|
304
|
+
})] })
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
const chart = (props.series !== void 0 ? props.axes : props.data).length < 3 ? null : props.series !== void 0 ? renderMultiSeries(props.axes, props.series, props.renderAxisTooltip) : renderSingleSeries(props.data, props.renderTooltip);
|
|
308
|
+
return /* @__PURE__ */ jsx("div", {
|
|
309
|
+
className: cn("w-full overflow-x-auto", className),
|
|
310
|
+
...divProps,
|
|
311
|
+
children: chart === null ? /* @__PURE__ */ jsx("div", {
|
|
312
|
+
className: "flex h-80 items-center justify-center",
|
|
313
|
+
role: "status",
|
|
314
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
315
|
+
variant: "sm",
|
|
316
|
+
color: "secondary",
|
|
317
|
+
children: "At least three axes are needed to display a radar chart."
|
|
318
|
+
})
|
|
319
|
+
}) : /* @__PURE__ */ jsx(TooltipPrimitive.Provider, {
|
|
320
|
+
delayDuration: 150,
|
|
321
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
322
|
+
viewBox: `0 0 ${VIEWBOX_WIDTH} ${VIEWBOX_HEIGHT}`,
|
|
323
|
+
className: "block w-full",
|
|
324
|
+
style: { minWidth: VIEWBOX_WIDTH },
|
|
325
|
+
role: isInteractive ? "group" : "img",
|
|
326
|
+
"aria-label": ariaLabel,
|
|
327
|
+
"aria-labelledby": ariaLabelledBy,
|
|
328
|
+
"aria-describedby": [summaryId, ariaDescribedBy].filter(Boolean).join(" "),
|
|
329
|
+
children: [
|
|
330
|
+
/* @__PURE__ */ jsx("desc", {
|
|
331
|
+
id: summaryId,
|
|
332
|
+
children: chart.summary
|
|
333
|
+
}),
|
|
334
|
+
/* @__PURE__ */ jsxs("g", {
|
|
335
|
+
"aria-hidden": "true",
|
|
336
|
+
fill: "none",
|
|
337
|
+
stroke: "var(--border-subtle)",
|
|
338
|
+
children: [GRID_LEVELS.map((level) => /* @__PURE__ */ jsx("polygon", { points: toPoints(chart.layouts.map((layout) => getPoint(layout, level))) }, level)), chart.layouts.map((layout) => {
|
|
339
|
+
const [x, y] = getPoint(layout, 1);
|
|
340
|
+
return /* @__PURE__ */ jsx("line", {
|
|
341
|
+
x1: CENTER_X,
|
|
342
|
+
y1: CENTER_Y,
|
|
343
|
+
x2: x,
|
|
344
|
+
y2: y
|
|
345
|
+
}, layout.id);
|
|
346
|
+
})]
|
|
347
|
+
}),
|
|
348
|
+
chart.marks
|
|
349
|
+
]
|
|
350
|
+
})
|
|
351
|
+
})
|
|
352
|
+
});
|
|
353
|
+
};
|
|
354
|
+
//#endregion
|
|
355
|
+
export { RadarChart };
|
|
356
|
+
|
|
357
|
+
//# sourceMappingURL=RadarChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadarChart.js","names":[],"sources":["../../../src/components/RadarChart/RadarChart.tsx"],"sourcesContent":["import {\n useId,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip';\n\nimport {\n CHART_SINGLE_FILL_COLOR,\n getCategoricalFillChartColor,\n getCategoricalFillColor,\n getCategoricalLineChartColor,\n} from '../../utils/chartColors';\nimport { CHART_DIMMED_OPACITY } from '../../utils/chartConstants';\nimport { cn } from '../../utils/cn';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\nimport { ChartTooltip } from '../ChartTooltip';\nimport { Text } from '../Text';\n\nexport type RadarChartDatum = {\n /** Unique, stable identifier for this axis. */\n id: string;\n label: string;\n value: number;\n /** Semantic chart color; defaults to the categorical fill palette in axis order. */\n color?: string;\n};\n\nexport type RadarChartAxis = {\n /** Unique, stable identifier; keys each series' `values`. */\n id: string;\n label: string;\n};\n\nexport type RadarChartSeries = {\n /** Unique, stable identifier; use it as the matching legend item's id. */\n id: string;\n label: string;\n /** Values keyed by axis id. Missing, negative, and non-finite values plot at zero. */\n values: Readonly<Record<string, number | undefined>>;\n /**\n * Outline color; defaults to the categorical line palette in series order.\n * The area uses the hue-matched fill color.\n */\n color?: string;\n};\n\n/** One axis and every visible series' value on it, for multi-series tooltips. */\nexport type RadarChartAxisValues = RadarChartAxis & {\n /** Visible series in input order, with sanitized values and outline colors. */\n values: readonly {\n id: string;\n label: string;\n value: number;\n color: string;\n }[];\n};\n\ntype RadarChartBaseProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {\n /** Shared axis maximum; defaults to the largest finite positive value. */\n maxValue?: number;\n /** Formats labels and the accessible data summary. */\n formatValue?: (value: number) => string;\n};\n\nexport type RadarChartSingleSeriesProps = RadarChartBaseProps & {\n /** Axes in clockwise order, beginning at the top. Supply at least three. */\n data: readonly RadarChartDatum[];\n /**\n * Content inside ChartTooltip on point or label hover and keyboard focus.\n * Receives the sanitized value and resolved color. Compose ChartTooltipHeader,\n * ChartTooltipBody, and ChartTooltipRow here; omit for a static chart.\n */\n renderTooltip?: (datum: RadarChartDatum) => ReactNode;\n axes?: never;\n series?: never;\n renderAxisTooltip?: never;\n selectedIds?: never;\n activeLegendItemId?: never;\n};\n\nexport type RadarChartMultiSeriesProps = RadarChartBaseProps & {\n /** Axes in clockwise order, beginning at the top. Supply at least three. */\n axes: readonly RadarChartAxis[];\n /**\n * Overlapping areas on the shared axes, drawn in input order. Keep to about\n * four; beyond that, filter series or use small multiples.\n */\n series: readonly RadarChartSeries[];\n /**\n * Content inside ChartTooltip when an axis is hovered anywhere in its sector\n * or focused. Compose one ChartTooltipRow per series; omit for a static chart.\n */\n renderAxisTooltip?: (axis: RadarChartAxisValues) => ReactNode;\n /** When non-empty, only these series are drawn. Colors keep their series order. */\n selectedIds?: ReadonlySet<string>;\n /** Emphasizes one series from an external legend and dims the rest. */\n activeLegendItemId?: string | null;\n data?: never;\n renderTooltip?: never;\n};\n\nexport type RadarChartProps =\n | RadarChartSingleSeriesProps\n | RadarChartMultiSeriesProps;\n\ntype AxisLayout = {\n id: string;\n unitX: number;\n unitY: number;\n labelX: number;\n labelY: number;\n align: 'text-left' | 'text-center' | 'text-right';\n tooltipSide: 'top' | 'right' | 'bottom' | 'left';\n tooltipAlign: 'start' | 'center' | 'end';\n};\n\nconst numberFormatter = new Intl.NumberFormat('en-US');\nconst formatNumber = (value: number) => numberFormatter.format(value);\nconst sanitize = (value: number | undefined) =>\n value !== undefined && Number.isFinite(value) ? Math.max(0, value) : 0;\n// Layout uses SVG units, which scale together with the viewBox. This canvas\n// fits the plot plus outside labels, with extra width for horizontal text.\nconst VIEWBOX_WIDTH = 440;\nconst VIEWBOX_HEIGHT = 340;\nconst CENTER_X = VIEWBOX_WIDTH / 2;\nconst CENTER_Y = VIEWBOX_HEIGHT / 2;\n// A 96-unit plot leaves room for a 20-unit gap and the two-line label boxes.\nconst RADIUS = 96;\nconst LABEL_RADIUS = RADIUS + 20;\n// Reserve 100 units for truncated names and 20 per text line: single-series\n// labels pair the name with its value; multi-series labels show the name.\nconst LABEL_WIDTH = 100;\nconst LABEL_LINE_HEIGHT = 20;\n// Labels left of center end at their axis; labels right of it start there.\nconst LABEL_SIDES = {\n left: { offset: LABEL_WIDTH, align: 'text-right', tooltipAlign: 'start' },\n center: {\n offset: LABEL_WIDTH / 2,\n align: 'text-center',\n tooltipAlign: 'center',\n },\n right: { offset: 0, align: 'text-left', tooltipAlign: 'end' },\n} as const;\n// Absorb trig rounding at alignment boundaries so mirrored labels line up.\nconst ALIGNMENT_EPSILON = 1e-6;\n// Four equally spaced rings represent fractions of the shared axis maximum.\nconst GRID_LEVELS = [0.25, 0.5, 0.75, 1];\n// Overlapping areas lead with their outlines: a faint wash keeps stacked\n// areas from mixing into a muddy tint. While one series is emphasized, it\n// alone keeps a fill, and the other series recede to dimmed outlines.\nconst SERIES_FILL_OPACITY = 0.08;\nconst EMPHASIZED_SERIES_FILL_OPACITY = 0.2;\n\nconst getAxisLayouts = (\n axes: readonly { id: string }[],\n labelHeight: number\n): AxisLayout[] =>\n axes.map(({ id }, index) => {\n const angle = (index * Math.PI * 2) / axes.length - Math.PI / 2;\n const unitX = Math.cos(angle);\n const unitY = Math.sin(angle);\n // Center labels within ~6 degrees of vertical (|cos| <= 0.1).\n const side =\n LABEL_SIDES[unitX < -0.1 ? 'left' : unitX > 0.1 ? 'right' : 'center'];\n // At 30 degrees or more above/below horizontal (|sin| >= 0.5), place the\n // whole label box outside the axis instead of straddling it.\n const isAbove = unitY <= -0.5 + ALIGNMENT_EPSILON;\n const isBelow = unitY >= 0.5 - ALIGNMENT_EPSILON;\n return {\n id,\n unitX,\n unitY,\n labelX: CENTER_X + unitX * LABEL_RADIUS - side.offset,\n labelY:\n CENTER_Y +\n unitY * LABEL_RADIUS -\n (isAbove ? labelHeight : isBelow ? 0 : labelHeight / 2),\n align: side.align,\n // Open outward, past the label and away from the plot.\n tooltipSide: isAbove\n ? 'top'\n : isBelow\n ? 'bottom'\n : unitX < 0\n ? 'left'\n : 'right',\n tooltipAlign: isAbove || isBelow ? side.tooltipAlign : 'center',\n };\n });\n\nconst getPoint = (axis: AxisLayout, ratio: number): [number, number] => [\n CENTER_X + axis.unitX * RADIUS * ratio,\n CENTER_Y + axis.unitY * RADIUS * ratio,\n];\n\nconst toPoints = (points: readonly (readonly [number, number])[]) =>\n points.map(([x, y]) => `${x},${y}`).join(' ');\n\nconst getMaximum = (values: readonly number[], maxValue?: number) =>\n maxValue !== undefined && Number.isFinite(maxValue) && maxValue > 0\n ? maxValue\n : values.reduce((largest, value) => Math.max(largest, value), 0) || 1;\n\n/**\n * A radar with a shared scale and clockwise, outside axis labels. Pass `data`\n * for one series with categorical points, or `axes` and `series` for\n * overlapping areas identified by an external legend.\n */\nexport const RadarChart = (props: RadarChartProps) => {\n // Mode-specific props are read from `props` so TypeScript narrows them by\n // mode; they are destructured here only to keep them off the wrapper div.\n const {\n data: _data,\n axes: _axes,\n series: _series,\n renderTooltip: _renderTooltip,\n renderAxisTooltip: _renderAxisTooltip,\n selectedIds,\n activeLegendItemId,\n maxValue,\n formatValue = formatNumber,\n className,\n 'aria-label': ariaLabel = 'Radar chart',\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n ...divProps\n } = props;\n const summaryId = useId();\n const [activeTooltip, setActiveTooltip] = useState<string | null>(null);\n const isPointerDownRef = useRef(false);\n const tooltipZIndex = useZIndex(zIndices.tooltip);\n const isInteractive =\n (props.series !== undefined\n ? props.renderAxisTooltip\n : props.renderTooltip) !== undefined;\n\n const withTooltip = (\n id: string,\n mark: ReactElement,\n content: ReactNode,\n layout?: AxisLayout\n ) => (\n <TooltipPrimitive.Root\n key={id}\n open={activeTooltip === id}\n onOpenChange={(open) =>\n setActiveTooltip((active) =>\n open ? id : active === id ? null : active\n )\n }\n >\n <TooltipPrimitive.Trigger\n asChild\n onPointerDown={(event) => {\n isPointerDownRef.current = true;\n event.currentTarget.ownerDocument.addEventListener(\n 'pointerup',\n () => {\n isPointerDownRef.current = false;\n },\n { once: true }\n );\n }}\n onFocus={(event) => {\n // Wait for keyboard focus to scroll an offscreen axis into\n // view; otherwise Radix closes the tooltip on that scroll.\n // Like Radix, focus from a pointer press stays closed.\n event.preventDefault();\n if (isPointerDownRef.current) return;\n const target = event.currentTarget;\n requestAnimationFrame(() => {\n if (target === target.ownerDocument.activeElement) {\n setActiveTooltip(id);\n }\n });\n }}\n >\n {mark}\n </TooltipPrimitive.Trigger>\n <TooltipPrimitive.Portal>\n <TooltipPrimitive.Content\n asChild\n side={layout?.tooltipSide}\n align={layout?.tooltipAlign}\n // Leave an 8px gap from the trigger and viewport edges.\n sideOffset={8}\n collisionPadding={8}\n >\n <ChartTooltip style={{ zIndex: tooltipZIndex }}>\n <ZIndexProvider value={tooltipZIndex}>{content}</ZIndexProvider>\n </ChartTooltip>\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n </TooltipPrimitive.Root>\n );\n\n const renderLabel = (\n layout: AxisLayout,\n height: number,\n summary: string,\n lines: ReactNode\n ) => (\n <foreignObject\n x={layout.labelX}\n y={layout.labelY}\n width={LABEL_WIDTH}\n height={height}\n >\n <div\n className={cn('flex h-full flex-col justify-center', layout.align)}\n title={isInteractive ? undefined : summary}\n >\n {lines}\n </div>\n </foreignObject>\n );\n\n const renderSingleSeries = (\n data: readonly RadarChartDatum[],\n renderDatumTooltip?: (datum: RadarChartDatum) => ReactNode\n ) => {\n const labelHeight = LABEL_LINE_HEIGHT * 2;\n const layouts = getAxisLayouts(data, labelHeight);\n const values = data.map(({ value }) => sanitize(value));\n const maximum = getMaximum(values, maxValue);\n const axes = data.map((datum, index) => {\n const value = values[index];\n const formattedValue = formatValue(value);\n return {\n layout: layouts[index],\n datum: {\n ...datum,\n value,\n color: datum.color ?? getCategoricalFillChartColor(index),\n },\n formattedValue,\n summary: `${datum.label}: ${formattedValue}`,\n point: getPoint(layouts[index], Math.min(1, value / maximum)),\n };\n });\n\n return {\n layouts,\n summary: axes.map(({ summary }) => summary).join('; '),\n marks: (\n <>\n <polygon\n aria-hidden=\"true\"\n points={toPoints(axes.map(({ point }) => point))}\n fill={CHART_SINGLE_FILL_COLOR}\n // A light wash and subdued outline keep the category points prominent.\n // Dark surfaces need slightly more opacity to preserve the shape.\n className=\"dark:[fill-opacity:0.24] dark:[stroke-opacity:0.8]\"\n fillOpacity={0.16}\n stroke={getCategoricalLineChartColor(0)}\n strokeOpacity={0.55}\n strokeWidth={1.25}\n strokeLinejoin=\"round\"\n />\n {axes.map(({ layout, datum, formattedValue, summary, point }) => {\n const [pointX, pointY] = point;\n const mark = (\n <g\n key={datum.id}\n className=\"group outline-hidden\"\n role={isInteractive ? 'img' : undefined}\n aria-label={isInteractive ? summary : undefined}\n aria-hidden={isInteractive ? undefined : true}\n tabIndex={isInteractive ? 0 : undefined}\n >\n {/* A 24-unit hit target surrounds the 8-unit point; the\n 16-unit ring shows hover in the axis color and keyboard\n focus in the shared focus color without changing layout. */}\n <circle cx={pointX} cy={pointY} r={12} fill=\"transparent\" />\n <circle\n cx={pointX}\n cy={pointY}\n r={8}\n fill=\"none\"\n stroke={datum.color}\n strokeWidth={1.5}\n className=\"opacity-0 group-hover:opacity-100 group-focus-visible:stroke-focus group-focus-visible:opacity-100\"\n />\n <circle\n cx={pointX}\n cy={pointY}\n r={4}\n fill={datum.color}\n // A thin surface-colored separator avoids heavy dark borders.\n className=\"stroke-surface-level-1\"\n strokeWidth={1}\n />\n {renderLabel(\n layout,\n labelHeight,\n summary,\n <>\n <Text variant=\"xs\" className=\"truncate\">\n {datum.label}\n </Text>\n <Text\n variant=\"xs\"\n color=\"secondary\"\n className=\"truncate tabular-nums\"\n >\n {formattedValue}\n </Text>\n </>\n )}\n </g>\n );\n return renderDatumTooltip\n ? withTooltip(datum.id, mark, renderDatumTooltip(datum))\n : mark;\n })}\n </>\n ),\n };\n };\n\n const renderMultiSeries = (\n axes: readonly RadarChartAxis[],\n series: readonly RadarChartSeries[],\n renderAxisTooltip?: (axis: RadarChartAxisValues) => ReactNode\n ) => {\n const layouts = getAxisLayouts(axes, LABEL_LINE_HEIGHT);\n // Resolve colors before filtering so each series keeps its hue.\n const resolvedSeries = series.map((item, index) => {\n const color = item.color ?? getCategoricalLineChartColor(index);\n return {\n id: item.id,\n label: item.label,\n color,\n fill: getCategoricalFillColor(color),\n values: axes.map(({ id }) => sanitize(item.values[id])),\n };\n });\n const visibleSeries =\n selectedIds === undefined || selectedIds.size === 0\n ? resolvedSeries\n : resolvedSeries.filter(({ id }) => selectedIds.has(id));\n const maximum = getMaximum(\n visibleSeries.flatMap(({ values }) => values),\n maxValue\n );\n const plottedSeries = visibleSeries.map((item) => ({\n ...item,\n points: item.values.map((value, index) =>\n getPoint(layouts[index], Math.min(1, value / maximum))\n ),\n }));\n const emphasizedId = plottedSeries.some(\n ({ id }) => id === activeLegendItemId\n )\n ? activeLegendItemId\n : null;\n const getSeriesOpacity = (id: string) =>\n emphasizedId != null && id !== emphasizedId ? CHART_DIMMED_OPACITY : 1;\n\n return {\n layouts,\n summary: plottedSeries\n .map(\n (item) =>\n `${item.label}: ${axes\n .map(\n (axis, index) =>\n `${axis.label} ${formatValue(item.values[index])}`\n )\n .join(', ')}`\n )\n .join('; '),\n marks: (\n <>\n {/* Draw the emphasized series last so its outline sits on top. */}\n {[\n ...plottedSeries.filter(({ id }) => id !== emphasizedId),\n ...plottedSeries.filter(({ id }) => id === emphasizedId),\n ].map((item) => {\n const isEmphasized = item.id === emphasizedId;\n return (\n <polygon\n key={item.id}\n aria-hidden=\"true\"\n points={toPoints(item.points)}\n fill={item.fill}\n fillOpacity={\n isEmphasized\n ? EMPHASIZED_SERIES_FILL_OPACITY\n : emphasizedId == null\n ? SERIES_FILL_OPACITY\n : 0\n }\n className=\"transition-[opacity,fill-opacity] duration-fast motion-reduce:transition-none\"\n opacity={getSeriesOpacity(item.id)}\n stroke={item.color}\n strokeWidth={1.5}\n strokeLinejoin=\"round\"\n />\n );\n })}\n {axes.map((axis, index) => {\n const layout = layouts[index];\n const values = plottedSeries.map((item) => ({\n id: item.id,\n label: item.label,\n value: item.values[index],\n color: item.color,\n }));\n const summary = values.length\n ? `${axis.label}: ${values\n .map(({ label, value }) => `${label} ${formatValue(value)}`)\n .join(', ')}`\n : axis.label;\n const [outerX, outerY] = getPoint(layout, 1);\n const [previousX, previousY] = getPoint(\n layouts[(index - 1 + layouts.length) % layouts.length],\n 1\n );\n const [nextX, nextY] = getPoint(\n layouts[(index + 1) % layouts.length],\n 1\n );\n const mark = (\n <g\n key={axis.id}\n className=\"group outline-hidden\"\n role={isInteractive ? 'img' : undefined}\n aria-label={isInteractive ? summary : undefined}\n aria-hidden={isInteractive ? undefined : true}\n tabIndex={isInteractive ? 0 : undefined}\n >\n {/* Each axis owns the sector between its neighbors' edge\n midpoints, so hovering anywhere in the plot inspects the\n nearest axis. */}\n <polygon\n points={toPoints([\n [CENTER_X, CENTER_Y],\n [(previousX + outerX) / 2, (previousY + outerY) / 2],\n [outerX, outerY],\n [(outerX + nextX) / 2, (outerY + nextY) / 2],\n ])}\n fill=\"transparent\"\n />\n {/* Hover strengthens the spoke and reveals each series'\n vertex; keyboard focus uses the shared focus color. */}\n <g className=\"opacity-0 transition-opacity duration-fast group-hover:opacity-100 group-focus-visible:opacity-100 motion-reduce:transition-none\">\n <line\n x1={CENTER_X}\n y1={CENTER_Y}\n x2={outerX}\n y2={outerY}\n stroke=\"var(--border-default)\"\n className=\"group-focus-visible:stroke-focus\"\n />\n {plottedSeries.map((item) => (\n <circle\n key={item.id}\n cx={item.points[index][0]}\n cy={item.points[index][1]}\n r={3.5}\n fill={item.color}\n opacity={getSeriesOpacity(item.id)}\n // A surface-colored separator keeps coincident vertices distinct.\n className=\"stroke-surface-level-1\"\n strokeWidth={1.5}\n />\n ))}\n </g>\n {renderLabel(\n layout,\n LABEL_LINE_HEIGHT,\n summary,\n <Text variant=\"xs\" className=\"truncate\">\n {axis.label}\n </Text>\n )}\n </g>\n );\n return renderAxisTooltip\n ? withTooltip(\n axis.id,\n mark,\n renderAxisTooltip({ id: axis.id, label: axis.label, values }),\n layout\n )\n : mark;\n })}\n </>\n ),\n };\n };\n\n const axisCount = (props.series !== undefined ? props.axes : props.data)\n .length;\n const chart =\n axisCount < 3\n ? null\n : props.series !== undefined\n ? renderMultiSeries(props.axes, props.series, props.renderAxisTooltip)\n : renderSingleSeries(props.data, props.renderTooltip);\n\n return (\n <div className={cn('w-full overflow-x-auto', className)} {...divProps}>\n {chart === null ? (\n <div className=\"flex h-80 items-center justify-center\" role=\"status\">\n <Text variant=\"sm\" color=\"secondary\">\n At least three axes are needed to display a radar chart.\n </Text>\n </div>\n ) : (\n <TooltipPrimitive.Provider\n // Brief hover delay avoids flashes when crossing between axes.\n delayDuration={150}\n >\n <svg\n viewBox={`0 0 ${VIEWBOX_WIDTH} ${VIEWBOX_HEIGHT}`}\n className=\"block w-full\"\n // Preserve the labels' base font size; narrow containers scroll.\n style={{ minWidth: VIEWBOX_WIDTH }}\n role={isInteractive ? 'group' : 'img'}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={[summaryId, ariaDescribedBy]\n .filter(Boolean)\n .join(' ')}\n >\n <desc id={summaryId}>{chart.summary}</desc>\n <g aria-hidden=\"true\" fill=\"none\" stroke=\"var(--border-subtle)\">\n {GRID_LEVELS.map((level) => (\n <polygon\n key={level}\n points={toPoints(\n chart.layouts.map((layout) => getPoint(layout, level))\n )}\n />\n ))}\n {chart.layouts.map((layout) => {\n const [x, y] = getPoint(layout, 1);\n return (\n <line\n key={layout.id}\n x1={CENTER_X}\n y1={CENTER_Y}\n x2={x}\n y2={y}\n />\n );\n })}\n </g>\n {chart.marks}\n </svg>\n </TooltipPrimitive.Provider>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;AA2HA,IAAM,kBAAkB,IAAI,KAAK,aAAa,OAAO;AACrD,IAAM,gBAAgB,UAAkB,gBAAgB,OAAO,KAAK;AACpE,IAAM,YAAY,UAChB,UAAU,KAAA,KAAa,OAAO,SAAS,KAAK,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI;AAGvE,IAAM,gBAAgB;AACtB,IAAM,iBAAiB;AACvB,IAAM,WAAW,gBAAgB;AACjC,IAAM,WAAW,iBAAiB;AAElC,IAAM,SAAS;AACf,IAAM,eAAe;AAGrB,IAAM,cAAc;AACpB,IAAM,oBAAoB;AAE1B,IAAM,cAAc;CAClB,MAAM;EAAE,QAAQ;EAAa,OAAO;EAAc,cAAc;CAAQ;CACxE,QAAQ;EACN,QAAQ,cAAc;EACtB,OAAO;EACP,cAAc;CAChB;CACA,OAAO;EAAE,QAAQ;EAAG,OAAO;EAAa,cAAc;CAAM;AAC9D;AAIA,IAAM,cAAc;CAAC;CAAM;CAAK;CAAM;AAAC;AAIvC,IAAM,sBAAsB;AAC5B,IAAM,iCAAiC;AAEvC,IAAM,kBACJ,MACA,gB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