@shapesos/clay 0.11.0 → 0.13.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/README.md +60 -0
- package/dist/artifacts.cjs +1420 -245
- package/dist/artifacts.cjs.map +1 -1
- package/dist/artifacts.d.cts +167 -6
- package/dist/artifacts.d.ts +167 -6
- package/dist/artifacts.js +18 -3
- package/dist/blocks.cjs +1696 -532
- package/dist/blocks.cjs.map +1 -1
- package/dist/blocks.css +1 -1
- package/dist/blocks.d.cts +21 -10
- package/dist/blocks.d.ts +21 -10
- package/dist/blocks.js +7 -3
- package/dist/capture.cjs +220 -0
- package/dist/capture.cjs.map +1 -0
- package/dist/capture.d.cts +113 -0
- package/dist/capture.d.ts +113 -0
- package/dist/capture.js +17 -0
- package/dist/chart.cjs +594 -0
- package/dist/chart.cjs.map +1 -0
- package/dist/chart.d.cts +439 -0
- package/dist/chart.d.ts +439 -0
- package/dist/chart.js +32 -0
- package/dist/chart.js.map +1 -0
- package/dist/chat.cjs +1687 -532
- package/dist/chat.cjs.map +1 -1
- package/dist/chat.d.cts +3 -2
- package/dist/chat.d.ts +3 -2
- package/dist/chat.js +8 -4
- package/dist/{chunk-MXOPG747.js → chunk-26XVDY6Z.js} +8 -8
- package/dist/chunk-26XVDY6Z.js.map +1 -0
- package/dist/{chunk-L35M3OD5.js → chunk-4MZZH3WX.js} +5 -11
- package/dist/chunk-4MZZH3WX.js.map +1 -0
- package/dist/chunk-DT44KNCV.js +1004 -0
- package/dist/chunk-DT44KNCV.js.map +1 -0
- package/dist/chunk-JAGNXEWK.js +116 -0
- package/dist/chunk-JAGNXEWK.js.map +1 -0
- package/dist/chunk-LXYCT4YO.js +7 -0
- package/dist/chunk-LXYCT4YO.js.map +1 -0
- package/dist/chunk-P6GUNIAE.js +11 -0
- package/dist/chunk-P6GUNIAE.js.map +1 -0
- package/dist/{chunk-OUW6PUEB.js → chunk-QH2WW2MW.js} +7 -7
- package/dist/chunk-QXGYMDIA.js +477 -0
- package/dist/chunk-QXGYMDIA.js.map +1 -0
- package/dist/chunk-RSRNSWJN.js +1 -0
- package/dist/chunk-RSRNSWJN.js.map +1 -0
- package/dist/dom-to-image-NATF3446.js +21 -0
- package/dist/dom-to-image-NATF3446.js.map +1 -0
- package/dist/index.cjs +1489 -317
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +28 -15
- package/dist/table.js +2 -1
- package/dist/types-B2aYk82c.d.cts +29 -0
- package/dist/types-B2aYk82c.d.ts +29 -0
- package/dist/types-BzXPBy6s.d.cts +330 -0
- package/dist/{types-DuuRI4ll.d.cts → types-CW45GBXl.d.cts} +31 -4
- package/dist/{types-C9XX-Uhk.d.ts → types-D1b8v7EY.d.ts} +31 -4
- package/dist/types-GCkXbyFm.d.ts +330 -0
- package/package.json +24 -2
- package/dist/chunk-BX5TCEPR.js +0 -436
- package/dist/chunk-BX5TCEPR.js.map +0 -1
- package/dist/chunk-L35M3OD5.js.map +0 -1
- package/dist/chunk-MEJESPTZ.js +0 -1
- package/dist/chunk-MXOPG747.js.map +0 -1
- package/dist/types-3Gzk7cRt.d.cts +0 -121
- package/dist/types-3Gzk7cRt.d.ts +0 -121
- /package/dist/{chunk-MEJESPTZ.js.map → capture.js.map} +0 -0
- /package/dist/{chunk-OUW6PUEB.js.map → chunk-QH2WW2MW.js.map} +0 -0
package/dist/chart.d.ts
ADDED
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import { ReactNode, ReactElement, CSSProperties } from 'react';
|
|
2
|
+
import { C as ChartSeries } from './types-B2aYk82c.js';
|
|
3
|
+
export { a as ChartVariant } from './types-B2aYk82c.js';
|
|
4
|
+
|
|
5
|
+
interface BarChartProps {
|
|
6
|
+
/** Rows to plot. Each row should carry the `xKey` column and one column per `series[].key`. */
|
|
7
|
+
data: ReadonlyArray<Record<string, unknown>>;
|
|
8
|
+
/** CSV/data column to use for the categorical x-axis (e.g. `"month"`, `"quarter"`). */
|
|
9
|
+
xKey: string;
|
|
10
|
+
/** One descriptor per bar series. Length 1 = single-series chart; 2+ = grouped or stacked. */
|
|
11
|
+
series: ChartSeries[];
|
|
12
|
+
/**
|
|
13
|
+
* When true, all series stack on one stack-id (vertical sum). When false (default), bars
|
|
14
|
+
* group side-by-side per x-tick.
|
|
15
|
+
*/
|
|
16
|
+
stacked?: boolean;
|
|
17
|
+
/** Container height. Number = px, string = any CSS length. Default 320. */
|
|
18
|
+
height?: number | string;
|
|
19
|
+
/** Container width. Default `"100%"`. */
|
|
20
|
+
width?: number | string;
|
|
21
|
+
/** Optional className on the outer container. */
|
|
22
|
+
className?: string;
|
|
23
|
+
/** Override the default palette (`CHART_PALETTE`). Colors are assigned by series index. */
|
|
24
|
+
palette?: readonly string[];
|
|
25
|
+
/** Show the tooltip on hover. Default true. */
|
|
26
|
+
showTooltip?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Show the legend at the top. **Default behavior**: auto-hidden for single-series charts
|
|
29
|
+
* (the legend would just label the one and only color, which is noise). Pass `true` to force
|
|
30
|
+
* the legend even with one series; pass `false` to suppress for multi-series.
|
|
31
|
+
*/
|
|
32
|
+
showLegend?: boolean;
|
|
33
|
+
/** Show horizontal dashed grid lines. Default true. */
|
|
34
|
+
showGrid?: boolean;
|
|
35
|
+
/** Show the x-axis. Default true. */
|
|
36
|
+
showXAxis?: boolean;
|
|
37
|
+
/** Show the y-axis. Default true. */
|
|
38
|
+
showYAxis?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Show numeric value labels above each bar. **Default behavior**: auto-on for single
|
|
41
|
+
* non-stacked series (labels stay readable); auto-off for stacked or multi-series bars
|
|
42
|
+
* (labels overlap and clutter). Pass explicitly to override.
|
|
43
|
+
*/
|
|
44
|
+
showValueLabels?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Recharts XAxis tick `interval`. Default `0` — every category gets a label (no info loss
|
|
47
|
+
* from auto-skipping). Use `"preserveStartEnd"` to let recharts drop colliding labels but
|
|
48
|
+
* keep the first and last. For long category names, prefer `xAxisAngle` to rotate the labels
|
|
49
|
+
* rather than dropping them.
|
|
50
|
+
*/
|
|
51
|
+
xAxisInterval?: number | "preserveStart" | "preserveEnd" | "preserveStartEnd";
|
|
52
|
+
/**
|
|
53
|
+
* Rotate x-axis tick labels by this many degrees. **Default**: auto — `0` (horizontal) for
|
|
54
|
+
* ≤7 categories; `-30` for 8+ categories so longer labels fit diagonally without overlapping
|
|
55
|
+
* their neighbours. Pass `0` explicitly to force horizontal labels even at high counts; pass
|
|
56
|
+
* any other number to set a custom angle.
|
|
57
|
+
*
|
|
58
|
+
* When the resolved angle is non-zero the chart auto-bumps its bottom margin and right-
|
|
59
|
+
* anchors the labels so they don't run off the axis. The container `height` budget should
|
|
60
|
+
* accommodate the angled labels (~40-60px more).
|
|
61
|
+
*/
|
|
62
|
+
xAxisAngle?: number;
|
|
63
|
+
/**
|
|
64
|
+
* Custom formatter for x-axis tick labels. **Default**: clay auto-truncates labels based on
|
|
65
|
+
* the number of categories so no labels overlap (see `getDefaultTickFormatter`). Pass an
|
|
66
|
+
* explicit formatter to override — e.g. for word-boundary truncation, locale-aware
|
|
67
|
+
* abbreviations, or to opt out of truncation entirely with `(v) => String(v)`.
|
|
68
|
+
*
|
|
69
|
+
* The tooltip continues to show the full unformatted value on hover regardless.
|
|
70
|
+
*/
|
|
71
|
+
xAxisTickFormatter?: (value: unknown) => string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Pre-composed bar chart. Single-call usage for the common case; for custom recharts trees
|
|
75
|
+
* compose `<ChartContainer>` + recharts primitives directly.
|
|
76
|
+
*
|
|
77
|
+
* ```tsx
|
|
78
|
+
* <BarChart
|
|
79
|
+
* data={[{ month: "Jan", us: 120, uk: 60 }, { month: "Feb", us: 132, uk: 64 }]}
|
|
80
|
+
* xKey="month"
|
|
81
|
+
* series={[
|
|
82
|
+
* { key: "us", label: "US" },
|
|
83
|
+
* { key: "uk", label: "UK" },
|
|
84
|
+
* ]}
|
|
85
|
+
* stacked
|
|
86
|
+
* />
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* **Smart defaults**: legend auto-hides for single-series charts; value labels auto-show for
|
|
90
|
+
* single non-stacked series; all x-axis ticks are shown by default (no recharts auto-skip).
|
|
91
|
+
* Override any of these via the named props.
|
|
92
|
+
*
|
|
93
|
+
* Numeric coercion: `data` rows may carry string values for the series columns (e.g. when
|
|
94
|
+
* derived from CSV) — recharts needs numbers, so we coerce in-place. Already-numeric data
|
|
95
|
+
* passes through unchanged.
|
|
96
|
+
*/
|
|
97
|
+
declare function BarChart({ data, xKey, series, stacked, height, width, className, palette, showTooltip, showLegend, showGrid, showXAxis, showYAxis, showValueLabels, xAxisInterval, xAxisAngle, xAxisTickFormatter, }: BarChartProps): ReactNode;
|
|
98
|
+
|
|
99
|
+
interface LineChartProps {
|
|
100
|
+
/** Rows to plot. Each row should carry the `xKey` column and one column per `series[].key`. */
|
|
101
|
+
data: ReadonlyArray<Record<string, unknown>>;
|
|
102
|
+
/** Data column for the categorical/temporal x-axis. */
|
|
103
|
+
xKey: string;
|
|
104
|
+
/** One descriptor per line series. */
|
|
105
|
+
series: ChartSeries[];
|
|
106
|
+
/** Render monotone-curve lines instead of straight segments. **Default true** — smooth
|
|
107
|
+
* curves look cleaner for typical chat / dashboard usage. Pass `false` for true linear
|
|
108
|
+
* interpolation (e.g. step-like data where the literal value at each point matters). */
|
|
109
|
+
smooth?: boolean;
|
|
110
|
+
/** Show data-point dots. **Default true** — dots anchor each bin of the line so the viewer
|
|
111
|
+
* can read individual values at a glance. Pass `false` for a pure trend line (dense data sets
|
|
112
|
+
* where dots would crowd, or styling preference for unembellished strokes). */
|
|
113
|
+
showDots?: boolean;
|
|
114
|
+
/** Line stroke width in px. Default 2. */
|
|
115
|
+
strokeWidth?: number;
|
|
116
|
+
/** Container height. Default 320. */
|
|
117
|
+
height?: number | string;
|
|
118
|
+
/** Container width. Default `"100%"`. */
|
|
119
|
+
width?: number | string;
|
|
120
|
+
/** Optional className on the outer container. */
|
|
121
|
+
className?: string;
|
|
122
|
+
/** Override the default palette. Colors are assigned by series index. */
|
|
123
|
+
palette?: readonly string[];
|
|
124
|
+
/** Show the tooltip on hover. Default true. */
|
|
125
|
+
showTooltip?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Show the legend at the top. **Default behavior**: auto-hidden for single-series charts
|
|
128
|
+
* (the legend would just label the one and only color, which is noise). Pass `true` to force
|
|
129
|
+
* the legend even with one series; pass `false` to suppress for multi-series.
|
|
130
|
+
*/
|
|
131
|
+
showLegend?: boolean;
|
|
132
|
+
/** Show horizontal dashed grid lines. Default true. */
|
|
133
|
+
showGrid?: boolean;
|
|
134
|
+
/** Show the x-axis. Default true. */
|
|
135
|
+
showXAxis?: boolean;
|
|
136
|
+
/** Show the y-axis. Default true. */
|
|
137
|
+
showYAxis?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Show numeric value labels next to each data point. **Default off** — for line charts with
|
|
140
|
+
* many data points (12+ months × N series) labels overlap quickly. Set `true` for single-series
|
|
141
|
+
* charts with sparse data (e.g. ≤8 points) where the labels stay readable.
|
|
142
|
+
*/
|
|
143
|
+
showValueLabels?: boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Recharts XAxis tick `interval`. **Default**: `0` (every tick rendered) — clay's tick
|
|
146
|
+
* formatter blanks out non-key labels so the visible labels stay evenly distributed.
|
|
147
|
+
* Override to a fixed number to force "every Nth label", or to a recharts string preset
|
|
148
|
+
* like `"preserveStartEnd"` to let recharts pick.
|
|
149
|
+
*/
|
|
150
|
+
xAxisInterval?: number | "preserveStart" | "preserveEnd" | "preserveStartEnd";
|
|
151
|
+
/**
|
|
152
|
+
* Rotate x-axis tick labels by this many degrees. Negative values tilt up-and-right (e.g.
|
|
153
|
+
* `-30`). Default `0`. When non-zero, the chart auto-bumps its bottom margin.
|
|
154
|
+
*/
|
|
155
|
+
xAxisAngle?: number;
|
|
156
|
+
/**
|
|
157
|
+
* Custom formatter for x-axis tick labels. **Default**: clay shows only ~5 evenly-distributed
|
|
158
|
+
* labels (first + last + ~3 middle), and auto-truncates each shown label so dense datasets
|
|
159
|
+
* stay readable. Pass an explicit formatter to override the per-label rendering — to also
|
|
160
|
+
* change which labels are visible, pass `xAxisInterval` and a formatter that returns the
|
|
161
|
+
* value for every index.
|
|
162
|
+
*
|
|
163
|
+
* The tooltip continues to show the full unformatted value on hover regardless.
|
|
164
|
+
*/
|
|
165
|
+
xAxisTickFormatter?: (value: unknown) => string;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Pre-composed line chart. Single-call usage for the common case; for custom recharts trees
|
|
169
|
+
* compose `<ChartContainer>` + recharts primitives directly.
|
|
170
|
+
*
|
|
171
|
+
* ```tsx
|
|
172
|
+
* <LineChart
|
|
173
|
+
* data={[{ month: "Jan", value: 120 }, { month: "Feb", value: 132 }]}
|
|
174
|
+
* xKey="month"
|
|
175
|
+
* series={[{ key: "value", label: "Headcount" }]}
|
|
176
|
+
* smooth
|
|
177
|
+
* />
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* **Smart defaults**: legend auto-hides for single-series; value labels default off (turn on
|
|
181
|
+
* for sparse single-series charts); x-axis shows every tick by default.
|
|
182
|
+
*/
|
|
183
|
+
declare function LineChart({ data, xKey, series, smooth, showDots, strokeWidth, height, width, className, palette, showTooltip, showLegend, showGrid, showXAxis, showYAxis, showValueLabels, xAxisInterval, xAxisAngle, xAxisTickFormatter, }: LineChartProps): ReactNode;
|
|
184
|
+
|
|
185
|
+
interface PieChartProps {
|
|
186
|
+
/** Rows to plot. Each row maps to one slice. */
|
|
187
|
+
data: ReadonlyArray<Record<string, unknown>>;
|
|
188
|
+
/** Data column used as the slice label / legend entry. */
|
|
189
|
+
categoryKey: string;
|
|
190
|
+
/** Data column used as the slice numeric value. */
|
|
191
|
+
valueKey: string;
|
|
192
|
+
/** Container height. Default 320. */
|
|
193
|
+
height?: number | string;
|
|
194
|
+
/** Container width. Default `"100%"`. */
|
|
195
|
+
width?: number | string;
|
|
196
|
+
/** Optional className on the outer container. */
|
|
197
|
+
className?: string;
|
|
198
|
+
/** Override the default palette. Default `CHART_PALETTE` — the shared blue + indigo graduated
|
|
199
|
+
* palette every chart variant uses. Override per-instance for brand-specific colours. */
|
|
200
|
+
palette?: readonly string[];
|
|
201
|
+
/** Show value labels next to each slice. Default true. */
|
|
202
|
+
showLabels?: boolean;
|
|
203
|
+
/** Show the tooltip on hover. Default true. */
|
|
204
|
+
showTooltip?: boolean;
|
|
205
|
+
/** Show the legend (category names). Default true. Position controlled by `legendPosition`. */
|
|
206
|
+
showLegend?: boolean;
|
|
207
|
+
/** Inner radius — `0` (default) for a pie; `>0` (e.g. `"40%"`) for a donut. */
|
|
208
|
+
innerRadius?: number | string;
|
|
209
|
+
/** Outer radius. Default `"68%"` — leaves room for outside value labels. */
|
|
210
|
+
outerRadius?: number | string;
|
|
211
|
+
/**
|
|
212
|
+
* Category labels treated as the "Others" bucket (case-insensitive match). Matching slices are
|
|
213
|
+
* pinned to the end of the sweep regardless of value and rendered in neutral grey
|
|
214
|
+
* (`OTHERS_SLICE_COLOR`).
|
|
215
|
+
*
|
|
216
|
+
* **Default**: `DEFAULT_OTHERS_CATEGORY_LABELS` (English "Others" / "Other"). Pass a localized
|
|
217
|
+
* list in non-English UIs — e.g. `["אחרים"]` for Hebrew or `["Otros", "Otro"]` for Spanish.
|
|
218
|
+
* Pass `[]` to disable Others detection entirely (every slice colored from the palette).
|
|
219
|
+
*/
|
|
220
|
+
othersCategoryLabels?: readonly string[];
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Pre-composed pie chart. One slice per row, colored by row index from the palette. Outside
|
|
224
|
+
* value labels (no connector line); legend at the top. Set `innerRadius` to make a donut.
|
|
225
|
+
*
|
|
226
|
+
* **Sweep**: starts at 12 o'clock and proceeds clockwise (`startAngle={90}` / `endAngle={-270}`).
|
|
227
|
+
* Recharts' default starts at 3 o'clock counter-clockwise, which feels arbitrary for a
|
|
228
|
+
* data-first composition.
|
|
229
|
+
*
|
|
230
|
+
* **"Others" bucket**: any slice whose category label matches "Others" / "Other"
|
|
231
|
+
* (case-insensitive — see `isOthersCategory`) is pinned to the end of the sweep regardless of
|
|
232
|
+
* value, and rendered in neutral grey (`OTHERS_SLICE_COLOR`) so it reads as "unattributed
|
|
233
|
+
* leftover" rather than a peer category. Other slices retain their incoming order.
|
|
234
|
+
*
|
|
235
|
+
* ```tsx
|
|
236
|
+
* <PieChart
|
|
237
|
+
* data={[
|
|
238
|
+
* { department: "Engineering", headcount: 42 },
|
|
239
|
+
* { department: "Sales", headcount: 18 },
|
|
240
|
+
* { department: "Others", headcount: 5 },
|
|
241
|
+
* ]}
|
|
242
|
+
* categoryKey="department"
|
|
243
|
+
* valueKey="headcount"
|
|
244
|
+
* />
|
|
245
|
+
*
|
|
246
|
+
* // Donut variant
|
|
247
|
+
* <PieChart data={...} categoryKey="..." valueKey="..." innerRadius="40%" />
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
250
|
+
declare function PieChart({ data, categoryKey, valueKey, height, width, className, palette, showLabels, showTooltip, showLegend, innerRadius, outerRadius, othersCategoryLabels, }: PieChartProps): ReactNode;
|
|
251
|
+
|
|
252
|
+
interface ChartContainerProps {
|
|
253
|
+
/** A single recharts chart element — `<LineChart>`, `<BarChart>`, `<PieChart>`, etc. */
|
|
254
|
+
children: ReactElement;
|
|
255
|
+
/**
|
|
256
|
+
* Container height. Recharts' `ResponsiveContainer` measures its parent, so we need a
|
|
257
|
+
* concrete value here (not "auto"). Accepts a number (px) or any CSS length string.
|
|
258
|
+
* Defaults to `320` — a sensible mid-density chart height.
|
|
259
|
+
*/
|
|
260
|
+
height?: number | string;
|
|
261
|
+
/**
|
|
262
|
+
* Container width. Defaults to `"100%"` so the chart flexes to its parent. Pass a fixed
|
|
263
|
+
* number when embedding in a layout that doesn't have a definite width (e.g. an auto-sized
|
|
264
|
+
* flex column).
|
|
265
|
+
*/
|
|
266
|
+
width?: number | string;
|
|
267
|
+
/** Optional className spread on the outer wrapper. */
|
|
268
|
+
className?: string;
|
|
269
|
+
/** Optional inline style merged into the outer wrapper. `width`/`height` here take precedence. */
|
|
270
|
+
style?: CSSProperties;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* The composable foundation for every clay chart. Wraps recharts' `ResponsiveContainer` in a
|
|
274
|
+
* sized `<div>` so the chart has a definite parent box to measure against — without this, charts
|
|
275
|
+
* silently collapse to 0×0 inside flex containers (see the `flex-basis` gotcha documented in
|
|
276
|
+
* the chart-artifact orchestrator).
|
|
277
|
+
*
|
|
278
|
+
* Use directly when composing a chart from recharts primitives:
|
|
279
|
+
*
|
|
280
|
+
* ```tsx
|
|
281
|
+
* <ChartContainer height={320}>
|
|
282
|
+
* <LineChart data={data} margin={{ top: 8, right: 16, left: 0, bottom: 4 }}>
|
|
283
|
+
* <CartesianGrid {...CHART_GRID_PROPS} />
|
|
284
|
+
* <XAxis dataKey="month" {...CHART_AXIS_PROPS} />
|
|
285
|
+
* <YAxis {...CHART_AXIS_PROPS} />
|
|
286
|
+
* <Tooltip content={<ChartTooltipContent />} />
|
|
287
|
+
* <Legend content={<ChartLegendContent />} />
|
|
288
|
+
* <Line dataKey="value" stroke={CHART_PALETTE[0]} />
|
|
289
|
+
* </LineChart>
|
|
290
|
+
* </ChartContainer>
|
|
291
|
+
* ```
|
|
292
|
+
*
|
|
293
|
+
* For common shapes, prefer the pre-composed `<BarChart>` / `<LineChart>` / `<PieChart>` —
|
|
294
|
+
* they call `ChartContainer` under the hood with sensible defaults.
|
|
295
|
+
*/
|
|
296
|
+
declare function ChartContainer({ children, height, width, className, style, }: ChartContainerProps): ReactNode;
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Single entry in recharts' tooltip payload — one per series at the hovered x-tick.
|
|
300
|
+
* Typed locally because recharts' `TooltipProps['payload']` is overly tagged-generic for this use.
|
|
301
|
+
*/
|
|
302
|
+
interface TooltipPayloadEntry {
|
|
303
|
+
name?: string | number;
|
|
304
|
+
value?: number | string;
|
|
305
|
+
color?: string;
|
|
306
|
+
dataKey?: string | number;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Recharts injects `active`, `payload`, and `label` at runtime when this component is used as
|
|
310
|
+
* the `content` slot on `<Tooltip>`. Consumer-facing props (`className`, `showLabel`,
|
|
311
|
+
* `formatValue`) survive the cloneElement merge.
|
|
312
|
+
*/
|
|
313
|
+
interface ChartTooltipContentProps {
|
|
314
|
+
/** Set by recharts at runtime — true when the tooltip is hovered open. */
|
|
315
|
+
active?: boolean;
|
|
316
|
+
/** Set by recharts at runtime — one entry per series. */
|
|
317
|
+
payload?: TooltipPayloadEntry[];
|
|
318
|
+
/** Set by recharts at runtime — the x-tick label for the hovered column. */
|
|
319
|
+
label?: string | number;
|
|
320
|
+
/** Optional className merged onto the tooltip card. */
|
|
321
|
+
className?: string;
|
|
322
|
+
/** When false, the row label (typically the x-tick value) is hidden. Default true. */
|
|
323
|
+
showLabel?: boolean;
|
|
324
|
+
/** Override the formatter used on each entry's value. Defaults to `String(value)`. */
|
|
325
|
+
formatValue?: (value: number | string | undefined, name: string | undefined) => string;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* The default tooltip card for clay charts. Drop into any recharts `<Tooltip>`:
|
|
329
|
+
*
|
|
330
|
+
* ```tsx
|
|
331
|
+
* <Tooltip content={<ChartTooltipContent />} />
|
|
332
|
+
* <Tooltip content={<ChartTooltipContent formatValue={(v) => `$${v}`} />} />
|
|
333
|
+
* ```
|
|
334
|
+
*
|
|
335
|
+
* Renders a soft brown card with one row per series, swatch left, name center, value right.
|
|
336
|
+
* Returns `null` when recharts says the tooltip is inactive — recharts mounts the content
|
|
337
|
+
* component unconditionally and toggles it via the `active` prop.
|
|
338
|
+
*/
|
|
339
|
+
declare function ChartTooltipContent({ active, payload, label, className, showLabel, formatValue, }: ChartTooltipContentProps): ReactNode;
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Single entry in recharts' legend payload — one per series. Typed locally because recharts'
|
|
343
|
+
* `LegendProps['payload']` is overly tagged-generic.
|
|
344
|
+
*/
|
|
345
|
+
interface LegendPayloadEntry {
|
|
346
|
+
value?: string | number;
|
|
347
|
+
color?: string;
|
|
348
|
+
dataKey?: string | number;
|
|
349
|
+
type?: string;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Recharts injects `payload` at runtime when this component is used as the `content` slot on
|
|
353
|
+
* `<Legend>`. Consumer-facing props (`className`, `iconType`) survive the cloneElement merge.
|
|
354
|
+
*/
|
|
355
|
+
interface ChartLegendContentProps {
|
|
356
|
+
/** Set by recharts at runtime — one entry per series. */
|
|
357
|
+
payload?: LegendPayloadEntry[];
|
|
358
|
+
/** Optional className merged onto the legend list. */
|
|
359
|
+
className?: string;
|
|
360
|
+
/** Visual indicator next to each label. `square` for bars/pies; `line` for line/area. Default `square`. */
|
|
361
|
+
iconType?: "square" | "line";
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* The default legend body for clay charts. Drop into any recharts `<Legend>`:
|
|
365
|
+
*
|
|
366
|
+
* ```tsx
|
|
367
|
+
* <Legend content={<ChartLegendContent iconType="square" />} />
|
|
368
|
+
* <Legend content={<ChartLegendContent iconType="line" />} />
|
|
369
|
+
* ```
|
|
370
|
+
*
|
|
371
|
+
* Recharts also accepts `verticalAlign` / `align` on `<Legend>` itself for positioning —
|
|
372
|
+
* `<ChartLegendContent>` is just the body. Style stays consistent regardless of position.
|
|
373
|
+
*/
|
|
374
|
+
declare function ChartLegendContent({ payload, className, iconType }: ChartLegendContentProps): ReactNode;
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Spreadable defaults for `<XAxis>` and `<YAxis>` — no axis line, no tick line, soft brown ticks.
|
|
378
|
+
* Pass `dataKey` explicitly on `<XAxis>`; leave it off `<YAxis>`. Override anything per-instance.
|
|
379
|
+
*/
|
|
380
|
+
declare const CHART_AXIS_PROPS: {
|
|
381
|
+
readonly stroke: "#CFCBC4";
|
|
382
|
+
readonly tick: {
|
|
383
|
+
readonly fill: "#73716D";
|
|
384
|
+
readonly fontSize: 12;
|
|
385
|
+
readonly fontWeight: 500;
|
|
386
|
+
};
|
|
387
|
+
readonly tickLine: false;
|
|
388
|
+
readonly axisLine: false;
|
|
389
|
+
};
|
|
390
|
+
/**
|
|
391
|
+
* Spreadable defaults for `<CartesianGrid>` — horizontal dashed lines only.
|
|
392
|
+
*/
|
|
393
|
+
declare const CHART_GRID_PROPS: {
|
|
394
|
+
readonly stroke: "#E6E2DA";
|
|
395
|
+
readonly strokeDasharray: "3 3";
|
|
396
|
+
readonly vertical: false;
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Single ordered color palette shared by every chart variant (`BarChart`, `LineChart`,
|
|
401
|
+
* `PieChart`). A graduated walk down the blue family (`blue-600` → `blue-400` → `blue-300` →
|
|
402
|
+
* `blue-100`), pivot into the indigo family (`indigo-400` → `indigo-500` → `indigo-600` →
|
|
403
|
+
* `indigo-800`), and close on the deepest blue (`blue-800`).
|
|
404
|
+
*
|
|
405
|
+
* Design intent: every chart in the product sits in the same cool blue / indigo family so
|
|
406
|
+
* adjacent charts on a dashboard read as a unified system rather than a kaleidoscope. The
|
|
407
|
+
* deliberately narrow hue range (blue + indigo only — no warm accents) is the point: it
|
|
408
|
+
* forecloses on rainbow-coded multi-series charts where the visual noise outweighs the
|
|
409
|
+
* series-distinction it tries to provide.
|
|
410
|
+
*
|
|
411
|
+
* **Same palette for pie too**: pie slices read as parts of a whole, but they also share a
|
|
412
|
+
* dashboard with bar/line charts — keeping one palette across every variant means a single
|
|
413
|
+
* chat surface containing all three variants looks like one design system, not three.
|
|
414
|
+
*
|
|
415
|
+
* Nine entries — the v1 series cap. The palette cycles modulo its length for series counts
|
|
416
|
+
* past nine via `colorForSeriesIndex`.
|
|
417
|
+
*/
|
|
418
|
+
declare const CHART_PALETTE: readonly ["#2563EB", "#60A5FA", "#93C5FD", "#DBEAFE", "#818CF8", "#6366F1", "#4F46E5", "#3730A3", "#1E40AF"];
|
|
419
|
+
/**
|
|
420
|
+
* Resolves the color for a series at `index`. Cycles deterministically past the palette length
|
|
421
|
+
* so configurations with more series than colors still render rather than throwing. Pass an
|
|
422
|
+
* alternate `palette` (e.g. a brand-specific override) to use something other than the default
|
|
423
|
+
* `CHART_PALETTE`.
|
|
424
|
+
*/
|
|
425
|
+
declare function colorForSeriesIndex(index: number, palette?: readonly string[]): string;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Returns a shallow copy of `rows` with the `numericKeys` columns coerced to `number`.
|
|
429
|
+
* Cells that can't be parsed become `NaN`; `null` / `undefined` cells pass through untouched;
|
|
430
|
+
* columns NOT in `numericKeys` pass through unchanged.
|
|
431
|
+
*
|
|
432
|
+
* Recharts needs `number` on `dataKey` resolution for `<Line>` / `<Bar>` / `<Pie>` — already-
|
|
433
|
+
* numeric data is a no-op. The function exists for the CSV-derived case where values arrive
|
|
434
|
+
* as strings. `NaN` propagates to recharts as a missing data point (zero-height bar, gap in
|
|
435
|
+
* line, zero-area slice).
|
|
436
|
+
*/
|
|
437
|
+
declare function coerceNumericColumns(rows: ReadonlyArray<Record<string, unknown>>, numericKeys: ReadonlyArray<string>): Array<Record<string, unknown>>;
|
|
438
|
+
|
|
439
|
+
export { BarChart, type BarChartProps, CHART_AXIS_PROPS, CHART_GRID_PROPS, CHART_PALETTE, ChartContainer, type ChartContainerProps, ChartLegendContent, type ChartLegendContentProps, ChartSeries, ChartTooltipContent, type ChartTooltipContentProps, LineChart, type LineChartProps, PieChart, type PieChartProps, coerceNumericColumns, colorForSeriesIndex };
|
package/dist/chart.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BarChart,
|
|
3
|
+
CHART_AXIS_PROPS,
|
|
4
|
+
CHART_GRID_PROPS,
|
|
5
|
+
CHART_PALETTE,
|
|
6
|
+
ChartContainer,
|
|
7
|
+
ChartLegendContent,
|
|
8
|
+
ChartTooltipContent,
|
|
9
|
+
LineChart,
|
|
10
|
+
PieChart,
|
|
11
|
+
coerceNumericColumns,
|
|
12
|
+
colorForSeriesIndex
|
|
13
|
+
} from "./chunk-QXGYMDIA.js";
|
|
14
|
+
import "./chunk-C77QMQNT.js";
|
|
15
|
+
import "./chunk-SV24ONND.js";
|
|
16
|
+
import "./chunk-P6GUNIAE.js";
|
|
17
|
+
import "./chunk-JF3P66JF.js";
|
|
18
|
+
import "./chunk-5WRI5ZAA.js";
|
|
19
|
+
export {
|
|
20
|
+
BarChart,
|
|
21
|
+
CHART_AXIS_PROPS,
|
|
22
|
+
CHART_GRID_PROPS,
|
|
23
|
+
CHART_PALETTE,
|
|
24
|
+
ChartContainer,
|
|
25
|
+
ChartLegendContent,
|
|
26
|
+
ChartTooltipContent,
|
|
27
|
+
LineChart,
|
|
28
|
+
PieChart,
|
|
29
|
+
coerceNumericColumns,
|
|
30
|
+
colorForSeriesIndex
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|