@lolmath/ui 9.5.0 → 9.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.
@@ -0,0 +1,352 @@
1
+ import { HTMLAttributes, JSX, ReactNode } from "react";
2
+ import { ChartCurve, ChartDefinition, ChartPoint, ChartTheme, ChartTheme as ChartTheme$1, ChartValue, ChartValue as ChartValue$1, DomChartDefinition, areaY, barX, barY, crosshair, d3Curve, defineChart, dot, group, lineX, lineY, rect, ruleX, ruleY, stack, text, tickX, tickY } from "@tanstack/charts";
3
+ import { scaleBand } from "@tanstack/charts/scales/band";
4
+ import { scaleLinear } from "@tanstack/charts/scales/linear";
5
+ import { scaleOrdinal } from "@tanstack/charts/scales/ordinal";
6
+ import { scalePoint } from "@tanstack/charts/scales/point";
7
+ import { tooltip, tooltip as tooltip$1 } from "@tanstack/charts/tooltip";
8
+ import { ChartProps } from "@tanstack/charts/react";
9
+ //#region src/charts/curves.d.ts
10
+ /** How a line or an area gets from one point to the next. */
11
+ type ChartCurveName = "linear" | "smooth" | "step";
12
+ /** Straight segments, like d3's `curveLinear`. */
13
+ declare const linearCurve: ChartCurve;
14
+ /**
15
+ * Monotone cubic interpolation over x — d3's `curveMonotoneX`, by way of
16
+ * Steffen's method. Smooth, but it never overshoots a reading, so a rounded
17
+ * corner cannot invent a value the data never had.
18
+ */
19
+ declare const smoothCurve: ChartCurve;
20
+ /** Holds each value until the next one, like d3's `curveStepAfter`. */
21
+ declare const stepCurve: ChartCurve;
22
+ //#endregion
23
+ //#region src/charts/components/chart-legend/chart-legend.d.ts
24
+ interface ChartLegendItem {
25
+ /** Stable identity for the entry. */
26
+ key: string;
27
+ /** What the reader sees. Falls back to `key`. */
28
+ label?: string;
29
+ /** The colour of the mark this entry stands for. */
30
+ color: string;
31
+ }
32
+ interface ChartLegendProps extends HTMLAttributes<HTMLUListElement> {
33
+ items: readonly ChartLegendItem[];
34
+ /** Matches the swatch to the mark: a diamond, a square, or a line key. */
35
+ swatch?: "diamond" | "square" | "line";
36
+ }
37
+ /**
38
+ * The legend every multi-series chart carries.
39
+ *
40
+ * Colour alone is never allowed to be the only way to tell two series apart,
41
+ * so this is not optional decoration — a chart with two or more series renders
42
+ * one. A single-series chart does not: its title already says what is plotted,
43
+ * and a lone swatch would only restate it.
44
+ */
45
+ declare function ChartLegend({ items, swatch, className, ...rest }: ChartLegendProps): JSX.Element;
46
+ //#endregion
47
+ //#region src/charts/components/chart-common.d.ts
48
+ /**
49
+ * What a chart can plot along its independent axis. Dates are deliberately
50
+ * absent: the engine ships no time scale, so map a date to a number or to a
51
+ * pre-formatted label before it reaches a chart.
52
+ */
53
+ type ChartXValue = string | number;
54
+ /** One measure drawn across the data — a line, an area, a set of bars. */
55
+ interface ChartSeries<TDatum> {
56
+ /** Stable identity. Used for React keys and for the mark's id. */
57
+ key: string;
58
+ /** What the legend and the tooltip call it. Falls back to `key`. */
59
+ label?: string;
60
+ /** Reads this series' value out of a row. Return null to break the line. */
61
+ value: (datum: TDatum) => number | null | undefined;
62
+ /**
63
+ * Overrides the palette slot. Reach for it when the series *means*
64
+ * something — a win rate, a gold lead — and should wear a status colour.
65
+ */
66
+ color?: string;
67
+ }
68
+ /** Props every cartesian chart in this package accepts. */
69
+ interface CartesianChartProps<TDatum> {
70
+ /** One row per position along the x axis. */
71
+ data: readonly TDatum[];
72
+ /** The measures to draw. Two or more get a legend. */
73
+ series: readonly ChartSeries<TDatum>[];
74
+ /** Reads the x position out of a row. */
75
+ x: (datum: TDatum) => ChartXValue;
76
+ /** Plot height in pixels. The width fills the container. */
77
+ height?: number;
78
+ /** Names what is plotted, in the frame's header. */
79
+ title?: ReactNode;
80
+ /** A line of context under the title. */
81
+ subtitle?: ReactNode;
82
+ /** Controls belonging to this chart, in the frame's header. */
83
+ actions?: ReactNode;
84
+ /** Axis titles. */
85
+ xLabel?: string;
86
+ yLabel?: string;
87
+ /** Tick and tooltip formatting. */
88
+ formatX?: (value: ChartXValue) => string;
89
+ formatY?: (value: number) => string;
90
+ /** Horizontal grid lines. On by default. */
91
+ grid?: boolean;
92
+ /**
93
+ * Forces the legend on or off. By default it appears for two or more
94
+ * series and is left off for one, whose title already names it.
95
+ */
96
+ legend?: boolean;
97
+ /** Drops the metal frame, keeping the type and colours. */
98
+ frame?: boolean;
99
+ /** Lights the marks with the hextech bloom. */
100
+ glow?: boolean;
101
+ /**
102
+ * What a screen reader announces. Derived from a string `title` when it can
103
+ * be; pass it explicitly whenever the title is a node or absent.
104
+ */
105
+ ariaLabel?: string;
106
+ ariaDescription?: string;
107
+ className?: string;
108
+ /** Props for the frame element. */
109
+ frameProps?: Omit<HTMLAttributes<HTMLElement>, "title" | "className" | "children">;
110
+ }
111
+ //#endregion
112
+ //#region src/charts/components/area-chart/area-chart.d.ts
113
+ interface AreaChartProps<TDatum> extends CartesianChartProps<TDatum> {
114
+ /** How the boundary travels between points. */
115
+ curve?: ChartCurveName;
116
+ /**
117
+ * Stacks the series into a total instead of overlaying them. Stack when the
118
+ * parts genuinely sum to something — damage by source, gold by lane.
119
+ */
120
+ stacked?: boolean;
121
+ /**
122
+ * Turns a stack into shares of 100%. Only meaningful when `stacked`.
123
+ */
124
+ normalize?: boolean;
125
+ /** Draws the boundary of each area. On by default. */
126
+ stroke?: boolean;
127
+ /** Follows the pointer with a vertical guide. On by default. */
128
+ crosshair?: boolean;
129
+ }
130
+ /**
131
+ * Filled areas — a composition over time, or a single magnitude you want to
132
+ * read as volume rather than as a trace.
133
+ *
134
+ * Overlaid areas (the default) are only honest for two or three series; past
135
+ * that the ones behind disappear. Stack them, or split into small multiples.
136
+ */
137
+ declare function AreaChart<TDatum>({ data, series, x, curve, stacked, normalize, stroke, crosshair: withCrosshair, height, title, subtitle, actions, xLabel, yLabel, formatX, formatY, grid, legend, frame, glow, ariaLabel, ariaDescription, className, frameProps }: AreaChartProps<TDatum>): JSX.Element;
138
+ //#endregion
139
+ //#region src/charts/components/bar-chart/bar-chart.d.ts
140
+ interface BarChartProps<TDatum> extends CartesianChartProps<TDatum> {
141
+ /**
142
+ * Side by side or stacked. Group when the series are compared against each
143
+ * other; stack when they sum to a whole.
144
+ */
145
+ layout?: "grouped" | "stacked";
146
+ /** Turns a stack into shares of 100%. Only meaningful when stacked. */
147
+ normalize?: boolean;
148
+ /**
149
+ * Corner radius. Zero by default: Hextech is chamfered and square, and the
150
+ * square is the shape the language uses to sit things on a grid.
151
+ */
152
+ radius?: number;
153
+ /** Widest a bar is allowed to get, in pixels. */
154
+ maxThickness?: number;
155
+ }
156
+ /**
157
+ * Columns over categories — per-champion damage, per-role gold share, counts
158
+ * by patch.
159
+ *
160
+ * Bars are separated by a gap in the surface rather than by an outline: a
161
+ * stroke around a bar is ink that carries no data.
162
+ */
163
+ declare function BarChart<TDatum>({ data, series, x, layout, normalize, radius, maxThickness, height, title, subtitle, actions, xLabel, yLabel, formatX, formatY, grid, legend, frame, glow, ariaLabel, ariaDescription, className, frameProps }: BarChartProps<TDatum>): JSX.Element;
164
+ //#endregion
165
+ //#region src/charts/components/chart-frame/chart-frame.d.ts
166
+ interface ChartFrameProps extends Omit<HTMLAttributes<HTMLElement>, "title"> {
167
+ /** Names what is plotted. Set in Beaufort, uppercased, like the client. */
168
+ title?: ReactNode;
169
+ /** One line of context under the title — a patch, a rank, a sample size. */
170
+ subtitle?: ReactNode;
171
+ /** Controls that belong to this chart: a range picker, a toggle group. */
172
+ actions?: ReactNode;
173
+ /** Rendered under the plot. The chart components put the legend here. */
174
+ footer?: ReactNode;
175
+ /** Drops the metal, keeping the type and colours. */
176
+ preset?: "framed" | "bare";
177
+ children?: ReactNode;
178
+ }
179
+ /**
180
+ * The panel a Hextech chart sits in: a gold hairline, diamond corners, a title
181
+ * in Beaufort and a rule under it.
182
+ *
183
+ * Every chart in this package renders one of these. Reach for it directly when
184
+ * you are building a chart of your own and want it to sit alongside them.
185
+ */
186
+ declare function ChartFrame({ title, subtitle, actions, footer, preset, className, children, ...rest }: ChartFrameProps): JSX.Element;
187
+ //#endregion
188
+ //#region src/charts/components/hextech-chart/hextech-chart.d.ts
189
+ interface HextechChartProps<TDatum = unknown, TXValue extends ChartValue$1 = ChartValue$1, TYValue extends ChartValue$1 = ChartValue$1> extends ChartProps<TDatum, TXValue, TYValue> {
190
+ /**
191
+ * Lights the marks with the faint hextech bloom. On by default — turn it
192
+ * off for dense charts, where a glow on every line turns into haze.
193
+ */
194
+ glow?: boolean;
195
+ /** Props for the element wrapping the plot. */
196
+ wrapperProps?: HTMLAttributes<HTMLDivElement>;
197
+ }
198
+ /**
199
+ * A TanStack chart wearing the Hextech theme, with no frame around it.
200
+ *
201
+ * Use it when you have written a `defineChart` definition of your own and want
202
+ * it to look like the rest of the library. The theme is merged into the
203
+ * definition, so anything the definition sets for itself still wins.
204
+ */
205
+ declare function HextechChart<TDatum, TXValue extends ChartValue$1 = ChartValue$1, TYValue extends ChartValue$1 = ChartValue$1>({ definition, glow, className, wrapperProps, ...rest }: HextechChartProps<TDatum, TXValue, TYValue>): JSX.Element;
206
+ //#endregion
207
+ //#region src/charts/components/line-chart/line-chart.d.ts
208
+ interface LineChartProps<TDatum> extends CartesianChartProps<TDatum> {
209
+ /** How the line travels between points. Straight by default. */
210
+ curve?: ChartCurveName;
211
+ /** Marks each reading with a dot. Worth it below ~30 points a series. */
212
+ points?: boolean;
213
+ /** Washes the area under each line in its own hue. */
214
+ area?: boolean;
215
+ /** Follows the pointer with a vertical guide. On by default. */
216
+ crosshair?: boolean;
217
+ }
218
+ /**
219
+ * Lines over time — gold curves, damage curves, anything that only makes sense
220
+ * read left to right.
221
+ *
222
+ * ```tsx
223
+ * <LineChart
224
+ * title="Team gold"
225
+ * data={timeline}
226
+ * x={(row) => row.minute}
227
+ * series={[
228
+ * { key: "blue", label: "Blue side", value: (row) => row.blueGold },
229
+ * { key: "red", label: "Red side", value: (row) => row.redGold },
230
+ * ]}
231
+ * xLabel="Minute"
232
+ * yLabel="Gold"
233
+ * />
234
+ * ```
235
+ */
236
+ declare function LineChart<TDatum>({ data, series, x, curve, points, area, crosshair: withCrosshair, height, title, subtitle, actions, xLabel, yLabel, formatX, formatY, grid, legend, frame, glow, ariaLabel, ariaDescription, className, frameProps }: LineChartProps<TDatum>): JSX.Element;
237
+ //#endregion
238
+ //#region src/charts/components/ranking-chart/ranking-chart.d.ts
239
+ interface RankingChartProps<TDatum> {
240
+ /** The rows to rank. */
241
+ data: readonly TDatum[];
242
+ /** Names a row — a champion, an item, a player. */
243
+ label: (datum: TDatum) => string;
244
+ /** The measure the ranking is on. */
245
+ value: (datum: TDatum) => number;
246
+ /**
247
+ * Paints one bar. Every bar wears the same hue by default, because the
248
+ * ranking is already carried by the order and the length — spending the
249
+ * identity channel on rank would mean a bar changes colour when the filter
250
+ * changes. Reach for this when a row *means* something: a pick you are
251
+ * highlighting, a positive against a negative delta.
252
+ */
253
+ color?: string | ((datum: TDatum, rank: number) => string);
254
+ /** How to order the rows before drawing. */
255
+ order?: "descending" | "ascending" | "input";
256
+ /** Keeps only the first N rows after ordering. */
257
+ limit?: number;
258
+ /** Writes each value at the tip of its bar. On by default. */
259
+ showValues?: boolean;
260
+ /** Formats the value, for the tip label, the axis and the tooltip. */
261
+ formatValue?: (value: number) => string;
262
+ /** Axis title for the measure. */
263
+ valueLabel?: string;
264
+ /** Draws the measure axis and its grid. Off by default — the tip labels
265
+ * already carry every value, and the axis would only repeat them. */
266
+ axis?: boolean;
267
+ /** Plot height. Defaults to something proportional to the row count. */
268
+ height?: number;
269
+ title?: ReactNode;
270
+ subtitle?: ReactNode;
271
+ actions?: ReactNode;
272
+ frame?: boolean;
273
+ glow?: boolean;
274
+ ariaLabel?: string;
275
+ ariaDescription?: string;
276
+ className?: string;
277
+ frameProps?: Omit<HTMLAttributes<HTMLElement>, "title" | "className" | "children">;
278
+ }
279
+ /**
280
+ * A ranked horizontal bar chart — the leaderboard shape. Longest bar on top,
281
+ * every value written at the tip.
282
+ *
283
+ * ```tsx
284
+ * <RankingChart
285
+ * title="Damage to champions"
286
+ * data={scoreboard}
287
+ * label={(row) => row.champion}
288
+ * value={(row) => row.damage}
289
+ * formatValue={(value) => `${Math.round(value / 1000)}k`}
290
+ * />
291
+ * ```
292
+ */
293
+ declare function RankingChart<TDatum>({ data, label, value, color, order, limit, showValues, formatValue, valueLabel, axis, height, title, subtitle, actions, frame, glow, ariaLabel, ariaDescription, className, frameProps }: RankingChartProps<TDatum>): JSX.Element;
294
+ //#endregion
295
+ //#region src/charts/theme/theme.d.ts
296
+ /**
297
+ * The Hextech palette, in slot order. Every entry is a CSS custom property, so
298
+ * a host page retunes the whole library by redefining `--lol-chart-series-N`
299
+ * rather than by threading colours through props.
300
+ *
301
+ * Assign these in sequence and never cycle them: a seventh series is not a
302
+ * seventh colour, it is a sign that the chart should fold its tail into
303
+ * "Other" or split into small multiples.
304
+ */
305
+ declare const hextechPalette: readonly ["var(--lol-chart-series-1)", "var(--lol-chart-series-2)", "var(--lol-chart-series-3)", "var(--lol-chart-series-4)", "var(--lol-chart-series-5)", "var(--lol-chart-series-6)"];
306
+ /** How many categorical series the palette can carry. */
307
+ declare const hextechPaletteSize: 6;
308
+ /**
309
+ * Dot, bubble and scatter forms are held to a harder test than bars and lines:
310
+ * any two marks can end up touching, not just neighbouring slots. The palette
311
+ * clears that test for its first three slots, so those forms cap at three
312
+ * series — past that, facet rather than reach for a fourth colour.
313
+ */
314
+ declare const hextechScatterPaletteSize = 3;
315
+ /**
316
+ * Reserved status colours. A series that *means* good or bad — a win rate, a
317
+ * gold lead, a delta — wears these; a series that is merely "the third one"
318
+ * wears the categorical palette. Never both in one chart.
319
+ */
320
+ declare const hextechStatusColors: {
321
+ readonly positive: "var(--lol-chart-positive)";
322
+ readonly negative: "var(--lol-chart-negative)";
323
+ };
324
+ /**
325
+ * The chart theme: gold ink and a near-black plot, matching the League client.
326
+ *
327
+ * `background` stays transparent so the frame behind the chart — or whatever
328
+ * the host puts there — shows through.
329
+ */
330
+ declare const hextechChartTheme: {
331
+ readonly foreground: "var(--lol-chart-foreground)";
332
+ readonly muted: "var(--lol-chart-muted)";
333
+ readonly grid: "var(--lol-chart-grid)";
334
+ readonly background: "transparent";
335
+ readonly palette: readonly ["var(--lol-chart-series-1)", "var(--lol-chart-series-2)", "var(--lol-chart-series-3)", "var(--lol-chart-series-4)", "var(--lol-chart-series-5)", "var(--lol-chart-series-6)"];
336
+ };
337
+ /** The colour for a categorical slot, counted from zero and never wrapped. */
338
+ declare function hextechSeriesColor(index: number): string;
339
+ /**
340
+ * Applies the Hextech theme to a chart definition you wrote by hand, keeping
341
+ * any theme fields the definition sets for itself.
342
+ *
343
+ * ```ts
344
+ * const chart = withHextechTheme(defineChart({ marks: [...], x, y }));
345
+ * ```
346
+ */
347
+ declare function withHextechTheme<TDefinition extends {
348
+ theme?: Partial<ChartTheme$1>;
349
+ }>(definition: TDefinition): TDefinition;
350
+ //#endregion
351
+ export { AreaChart, AreaChartProps, BarChart, BarChartProps, type CartesianChartProps, type ChartCurveName, type ChartDefinition, ChartFrame, ChartFrameProps, ChartLegend, ChartLegendItem, ChartLegendProps, type ChartPoint, type ChartSeries, type ChartTheme, type ChartValue, type ChartXValue, type DomChartDefinition, HextechChart, HextechChartProps, LineChart, LineChartProps, RankingChart, RankingChartProps, areaY, barX, barY, crosshair, d3Curve, defineChart, dot, group, hextechChartTheme, hextechPalette, hextechPaletteSize, hextechScatterPaletteSize, hextechSeriesColor, hextechStatusColors, lineX, lineY, linearCurve, rect, ruleX, ruleY, scaleBand, scaleLinear, scaleOrdinal, scalePoint, smoothCurve, stack, stepCurve, text, tickX, tickY, tooltip, withHextechTheme };
352
+ //# sourceMappingURL=charts.d.mts.map