@keboola/design 6.4.0 → 8.0.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/AGENTS.md +9 -10
- package/COMPONENT-API.md +162 -160
- package/README.md +3 -3
- package/dist/charts.cjs +22 -22
- package/dist/charts.cjs.map +1 -1
- package/dist/charts.d.cts +5 -5
- package/dist/charts.d.ts +5 -5
- package/dist/charts.js +22 -22
- package/dist/charts.js.map +1 -1
- package/dist/editors.cjs +594 -438
- package/dist/editors.cjs.map +1 -1
- package/dist/editors.d.cts +8 -4
- package/dist/editors.d.ts +8 -4
- package/dist/editors.js +595 -422
- package/dist/editors.js.map +1 -1
- package/dist/icons.cjs +23818 -45
- package/dist/icons.cjs.map +1 -1
- package/dist/icons.d.cts +12 -3
- package/dist/icons.d.ts +12 -3
- package/dist/icons.js +298 -40
- package/dist/icons.js.map +1 -1
- package/dist/index.cjs +11519 -11718
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +679 -1227
- package/dist/index.d.ts +679 -1227
- package/dist/index.js +10315 -10516
- package/dist/index.js.map +1 -1
- package/dist/markdown-editor.cjs +1015 -1134
- package/dist/markdown-editor.cjs.map +1 -1
- package/dist/markdown-editor.js +1016 -1134
- package/dist/markdown-editor.js.map +1 -1
- package/dist/mermaid.cjs +366 -452
- package/dist/mermaid.cjs.map +1 -1
- package/dist/mermaid.d.cts +5 -1
- package/dist/mermaid.d.ts +5 -1
- package/dist/mermaid.js +368 -435
- package/dist/mermaid.js.map +1 -1
- package/dist/rjsf.cjs +2540 -2419
- package/dist/rjsf.cjs.map +1 -1
- package/dist/rjsf.js +2541 -2419
- package/dist/rjsf.js.map +1 -1
- package/dist/styles.css +2 -5
- package/dist/testing.cjs +86 -82
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +86 -82
- package/dist/testing.js.map +1 -1
- package/package.json +30 -22
- package/src/styles.css +125 -105
- package/src/theme.css +264 -0
package/README.md
CHANGED
|
@@ -116,7 +116,7 @@ Worked examples: `src/components/Button/Button.stories.tsx` (click + disabled),
|
|
|
116
116
|
|
|
117
117
|
**Coverage so far:** the interactive surface is covered — Button, ButtonInline, Combobox, MultiCombobox, CreatableMultiCombobox, Select, Modal, Sheet, Popover, Popconfirm, DropdownMenu, SplitButton, Tooltip, HoverCard, InfoTooltip, Switch, Checkbox, RadioGroup, Slider, Tabs, PageHeaderTabs, Collapsible, PanelWithDetails, Toast, TextInput, NumberInput, SearchInput, SearchInputWithNavigation, PasswordInput, Textarea, AutoSaveTextarea, AlertWithAction, ListDetail, FilterToolbar. Add a `play()` to new interactive stories by default.
|
|
118
118
|
|
|
119
|
-
**Known gaps (not yet driven headlessly):** `Command` (cmdk input value isn't reflected on the DOM node under the test runner), `CollapsiblePanel` (collapses via CSS height, so `toBeVisible()` can't see the state change), `Calendar`/`DateInput`/`TimeInput` (day/segment targeting is brittle), `ColorInput`, `Clipboard`/`ClipboardButton` (clipboard API), and `MultiActionButton
|
|
119
|
+
**Known gaps (not yet driven headlessly):** `Command` (cmdk input value isn't reflected on the DOM node under the test runner), `CollapsiblePanel` (collapses via CSS height, so `toBeVisible()` can't see the state change), `Calendar`/`DateInput`/`TimeInput` (day/segment targeting is brittle), `ColorInput`, `Clipboard`/`ClipboardButton` (clipboard API), and `MultiActionButton` (stories use `alert()` / `onClick` side effects that block a headless run). `ModalForm` currently throws `formContext only works within a formComponent` when its modal opens (`FormBody` is outside `form.AppForm`) — a story-wiring fix, tracked separately. `Search` is deprecated and intentionally untested.
|
|
120
120
|
|
|
121
121
|
**Timing-sensitive:** `HoverCard` is the only test driven by a real `userEvent.hover` past a 200 ms open delay (its `findByText` carries a raised timeout). It passes headlessly today, but it's the most likely flake if CI is slow — `Tooltip` deliberately opens via keyboard focus to avoid this. Watch it when wiring CI.
|
|
122
122
|
|
|
@@ -136,11 +136,11 @@ Same prerequisites as `test:stories` (build workspace deps, install Chromium). R
|
|
|
136
136
|
|
|
137
137
|
**What's covered:** `src/**` component source, excluding stories (`*.stories.tsx`), unit tests (`*.test.{ts,tsx}`), barrels (`index.ts`), type decls, `src/docs/**`, and `src/icons/**` (curated lucide re-exports plus custom SVG marks like `Keboola` — trivial visual surface, no logic to gate).
|
|
138
138
|
|
|
139
|
-
**What the numbers reflect:** only some story files carry a `play()` interaction test; the rest contribute just their render/smoke path, so branch coverage trails statement coverage. The lowest-covered areas are the interaction-heavy blocks that still lack a `play()
|
|
139
|
+
**What the numbers reflect:** only some story files carry a `play()` interaction test; the rest contribute just their render/smoke path, so branch coverage trails statement coverage. The lowest-covered areas are the interaction-heavy blocks that still lack a `play()`. Run `test:stories:coverage` and open `coverage/index.html` for the current per-file numbers — they're not pinned here because they drift with every story and `play()` added.
|
|
140
140
|
|
|
141
141
|
### Icons
|
|
142
142
|
|
|
143
|
-
Import icons directly from `@keboola/design/icons` — a
|
|
143
|
+
Import icons directly from `@keboola/design/icons` — a re-export of every [lucide-react](https://lucide.dev) icon plus Keboola-custom inline-SVG icons. See `AGENTS.md` for the full mapping and conventions.
|
|
144
144
|
|
|
145
145
|
```tsx
|
|
146
146
|
import { ChevronDown, Keboola } from '@keboola/design/icons';
|
package/dist/charts.cjs
CHANGED
|
@@ -7,7 +7,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
7
7
|
|
|
8
8
|
// src/blocks/Charts/ChartContainer.tsx
|
|
9
9
|
var twMerge = tailwindMerge.extendTailwindMerge({
|
|
10
|
-
prefix: "tw
|
|
10
|
+
prefix: "tw"
|
|
11
11
|
});
|
|
12
12
|
var cn = (...classes) => twMerge(clsx.clsx(...classes));
|
|
13
13
|
var ChartContainer = ({
|
|
@@ -20,19 +20,19 @@ var ChartContainer = ({
|
|
|
20
20
|
"div",
|
|
21
21
|
{
|
|
22
22
|
className: cn(
|
|
23
|
-
"tw
|
|
23
|
+
"tw:text-xs",
|
|
24
24
|
// Axis ticks and labels follow the muted foreground token.
|
|
25
|
-
"[&_.recharts-cartesian-axis-tick_text]:
|
|
26
|
-
"[&_.recharts-polar-angle-axis-tick_text]:
|
|
27
|
-
"[&_.recharts-label]:
|
|
28
|
-
"[&_.recharts-legend-item-text]:!
|
|
25
|
+
"tw:[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground",
|
|
26
|
+
"tw:[&_.recharts-polar-angle-axis-tick_text]:fill-muted-foreground",
|
|
27
|
+
"tw:[&_.recharts-label]:fill-muted-foreground",
|
|
28
|
+
"tw:[&_.recharts-legend-item-text]:!text-muted-foreground",
|
|
29
29
|
// Grid lines, axis lines and the hover cursor follow the border token.
|
|
30
|
-
"[&_.recharts-cartesian-grid_line]:
|
|
31
|
-
"[&_.recharts-cartesian-axis-line]:
|
|
32
|
-
"[&_.recharts-cartesian-axis-tick-line]:
|
|
33
|
-
"[&_.recharts-curve.recharts-tooltip-cursor]:
|
|
34
|
-
"[&_.recharts-rectangle.recharts-tooltip-cursor]:
|
|
35
|
-
"[&_.recharts-surface]:
|
|
30
|
+
"tw:[&_.recharts-cartesian-grid_line]:stroke-border/60",
|
|
31
|
+
"tw:[&_.recharts-cartesian-axis-line]:stroke-border",
|
|
32
|
+
"tw:[&_.recharts-cartesian-axis-tick-line]:stroke-border",
|
|
33
|
+
"tw:[&_.recharts-curve.recharts-tooltip-cursor]:stroke-border",
|
|
34
|
+
"tw:[&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted/60",
|
|
35
|
+
"tw:[&_.recharts-surface]:outline-hidden",
|
|
36
36
|
className
|
|
37
37
|
),
|
|
38
38
|
...props,
|
|
@@ -51,12 +51,12 @@ var ChartTooltipContent = ({
|
|
|
51
51
|
"div",
|
|
52
52
|
{
|
|
53
53
|
className: cn(
|
|
54
|
-
"tw
|
|
54
|
+
"tw:min-w-32 tw:rounded-md tw:border tw:border-border tw:bg-popover tw:px-2.5 tw:py-1.5 tw:text-xs tw:text-popover-foreground tw:shadow-md",
|
|
55
55
|
className
|
|
56
56
|
),
|
|
57
57
|
children: [
|
|
58
|
-
label != null && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tw
|
|
59
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "tw
|
|
58
|
+
label != null && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tw:mb-1 tw:font-medium", children: label }),
|
|
59
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "tw:flex tw:flex-col tw:gap-1", children: payload.map((entry) => {
|
|
60
60
|
const name = String(entry.name ?? entry.dataKey ?? "");
|
|
61
61
|
const value = entry.value;
|
|
62
62
|
const hasNumber = value != null && value !== "" && Number.isFinite(Number(value));
|
|
@@ -64,19 +64,19 @@ var ChartTooltipContent = ({
|
|
|
64
64
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
65
65
|
"div",
|
|
66
66
|
{
|
|
67
|
-
className: "tw
|
|
67
|
+
className: "tw:flex tw:items-center tw:justify-between tw:gap-3",
|
|
68
68
|
children: [
|
|
69
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "tw
|
|
69
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "tw:flex tw:items-center tw:gap-1.5", children: [
|
|
70
70
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
71
71
|
"span",
|
|
72
72
|
{
|
|
73
|
-
className: "tw
|
|
73
|
+
className: "tw:size-2 tw:shrink-0 tw:rounded-[2px]",
|
|
74
74
|
style: { backgroundColor: entry.color }
|
|
75
75
|
}
|
|
76
76
|
),
|
|
77
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "tw
|
|
77
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "tw:text-muted-foreground", children: name })
|
|
78
78
|
] }),
|
|
79
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "tw
|
|
79
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "tw:font-medium tw:tabular-nums", children: display })
|
|
80
80
|
]
|
|
81
81
|
},
|
|
82
82
|
String(entry.dataKey ?? name)
|
|
@@ -138,7 +138,7 @@ var cartesianChrome = ({
|
|
|
138
138
|
var CHART_TOKEN_COUNT = 5;
|
|
139
139
|
var chartTokenColor = (index) => {
|
|
140
140
|
const slot = (index % CHART_TOKEN_COUNT + CHART_TOKEN_COUNT) % CHART_TOKEN_COUNT + 1;
|
|
141
|
-
return `rgb(var(--
|
|
141
|
+
return `rgb(var(--chart-${slot}))`;
|
|
142
142
|
};
|
|
143
143
|
var resolveSeriesColor = (index, token) => chartTokenColor(token ? token - 1 : index);
|
|
144
144
|
var LineChart = ({
|
|
@@ -249,7 +249,7 @@ var PieChart = ({
|
|
|
249
249
|
nameKey,
|
|
250
250
|
dataKey,
|
|
251
251
|
innerRadius,
|
|
252
|
-
stroke: "rgb(var(--
|
|
252
|
+
stroke: "rgb(var(--background))",
|
|
253
253
|
isAnimationActive: false,
|
|
254
254
|
children: data.map((datum, index) => /* @__PURE__ */ jsxRuntime.jsx(recharts.Cell, { fill: chartTokenColor(index) }, String(datum[nameKey] ?? index)))
|
|
255
255
|
}
|
package/dist/charts.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/classNames.ts","../src/blocks/Charts/ChartContainer.tsx","../src/blocks/Charts/ChartTooltip.tsx","../src/blocks/Charts/format.ts","../src/blocks/Charts/cartesian.tsx","../src/blocks/Charts/theme.ts","../src/blocks/Charts/LineChart.tsx","../src/blocks/Charts/BarChart.tsx","../src/blocks/Charts/AreaChart.tsx","../src/blocks/Charts/PieChart.tsx"],"names":["extendTailwindMerge","clsx","jsx","ResponsiveContainer","jsxs","RechartsTooltip","Fragment","CartesianGrid","XAxis","YAxis","Legend","RechartsLineChart","Line","RechartsBarChart","Bar","RechartsAreaChart","Area","RechartsPieChart","Pie","Cell"],"mappings":";;;;;;;;AAGA,IAAM,UAAUA,iCAAA,CAAoB;AAAA,EAClC,MAAA,EAAQ;AACV,CAAC,CAAA;AAEM,IAAM,KAAK,CAAA,GAAI,OAAA,KAA0B,QAAQC,SAAA,CAAK,GAAG,OA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indMerge } from 'tailwind-merge';\n\nconst twMerge = extendTailwindMerge({\n prefix: 'tw-',\n});\n\nexport const cn = (...classes: ClassValue[]) => twMerge(clsx(...classes));\n","import { type ComponentProps, type ReactElement } from 'react';\nimport { ResponsiveContainer } from 'recharts';\n\nimport { cn } from '../../utils';\n\n/** A length that recharts' `<ResponsiveContainer>` accepts: px number or `\"NN%\"`. */\nexport type ChartDimension = number | `${number}%`;\n\nexport type ChartContainerProps = Omit<ComponentProps<'div'>, 'children'> & {\n /**\n * Height as a px number or percentage string. Charts have no intrinsic\n * height, so a container needs one either here or from a sized ancestor.\n * Defaults to 300.\n */\n height?: ChartDimension;\n /** Width as a px number or percentage. Defaults to `\"100%\"` (fills parent). */\n width?: ChartDimension;\n /** A single recharts chart element (`<LineChart>`, `<BarChart>`, …). */\n children: ReactElement;\n};\n\n/**\n * Responsive, brand-themed frame for a chart. Wraps the chart in recharts'\n * `<ResponsiveContainer>` and applies the semantic-token chrome (axis text,\n * grid, cursor) through CSS so every chart inside inherits it. Sizing is\n * intrinsic: give it a `height` (default 300) and it fills the parent width.\n */\nexport const ChartContainer = ({\n height = 300,\n width = '100%',\n className,\n children,\n ...props\n}: ChartContainerProps) => (\n <div\n className={cn(\n 'tw-text-xs',\n // Axis ticks and labels follow the muted foreground token.\n '[&_.recharts-cartesian-axis-tick_text]:tw-fill-muted-foreground',\n '[&_.recharts-polar-angle-axis-tick_text]:tw-fill-muted-foreground',\n '[&_.recharts-label]:tw-fill-muted-foreground',\n '[&_.recharts-legend-item-text]:!tw-text-muted-foreground',\n // Grid lines, axis lines and the hover cursor follow the border token.\n '[&_.recharts-cartesian-grid_line]:tw-stroke-border/60',\n '[&_.recharts-cartesian-axis-line]:tw-stroke-border',\n '[&_.recharts-cartesian-axis-tick-line]:tw-stroke-border',\n '[&_.recharts-curve.recharts-tooltip-cursor]:tw-stroke-border',\n '[&_.recharts-rectangle.recharts-tooltip-cursor]:tw-fill-muted/60',\n '[&_.recharts-surface]:tw-outline-none',\n className,\n )}\n {...props}\n >\n <ResponsiveContainer width={width} height={height}>\n {children}\n </ResponsiveContainer>\n </div>\n);\n","import { type ComponentProps } from 'react';\nimport { Tooltip as RechartsTooltip } from 'recharts';\n\nimport { cn } from '../../utils';\n\ntype TooltipPayloadEntry = {\n name?: string | number;\n value?: string | number;\n color?: string;\n dataKey?: string | number;\n};\n\ntype ChartTooltipContentProps = {\n active?: boolean;\n label?: string | number;\n payload?: TooltipPayloadEntry[];\n /** Format a value for display (e.g. currency, percentage). */\n valueFormatter?: (value: string | number, name: string) => string;\n className?: string;\n};\n\n/**\n * Brand-themed tooltip body. Surfaces (background, border, text) resolve from\n * semantic tokens, and each series swatch reuses the recharts-provided series\n * `color` (already a `--color-chart-*` token from this package's charts).\n */\nexport const ChartTooltipContent = ({\n active,\n label,\n payload,\n valueFormatter,\n className,\n}: ChartTooltipContentProps) => {\n if (!active || !payload?.length) return null;\n\n return (\n <div\n className={cn(\n 'tw-min-w-32 tw-rounded-md tw-border tw-border-border tw-bg-popover tw-px-2.5 tw-py-1.5 tw-text-xs tw-text-popover-foreground tw-shadow-md',\n className,\n )}\n >\n {label != null && <div className=\"tw-mb-1 tw-font-medium\">{label}</div>}\n <div className=\"tw-flex tw-flex-col tw-gap-1\">\n {payload.map((entry) => {\n const name = String(entry.name ?? entry.dataKey ?? '');\n const value = entry.value;\n // Missing / non-numeric values render blank rather than \"NaN\"/\"0\";\n // only well-formed numbers reach the formatter.\n const hasNumber = value != null && value !== '' && Number.isFinite(Number(value));\n const display = hasNumber\n ? valueFormatter\n ? valueFormatter(Number(value), name)\n : String(Number(value))\n : (value ?? '');\n return (\n <div\n key={String(entry.dataKey ?? name)}\n className=\"tw-flex tw-items-center tw-justify-between tw-gap-3\"\n >\n <span className=\"tw-flex tw-items-center tw-gap-1.5\">\n <span\n className=\"tw-size-2 tw-shrink-0 tw-rounded-[2px]\"\n style={{ backgroundColor: entry.color }}\n />\n <span className=\"tw-text-muted-foreground\">{name}</span>\n </span>\n <span className=\"tw-font-medium tw-tabular-nums\">{display}</span>\n </div>\n );\n })}\n </div>\n </div>\n );\n};\n\nexport type ChartTooltipProps = ComponentProps<typeof RechartsTooltip> & {\n valueFormatter?: (value: string | number, name: string) => string;\n};\n\n/**\n * Drop-in recharts `<Tooltip>` pre-wired to render {@link ChartTooltipContent}.\n * Each chart mounts one by default; pass `showTooltip={false}` on the chart to omit.\n */\nexport const ChartTooltip = ({ valueFormatter, ...props }: ChartTooltipProps) => (\n <RechartsTooltip\n cursor={{ strokeWidth: 1 }}\n content={<ChartTooltipContent valueFormatter={valueFormatter} />}\n {...props}\n />\n);\n","/**\n * Apply a numeric `valueFormatter` safely. recharts hands axis ticks and\n * tooltip payload values as `string | number | null | undefined`, and partial\n * or streaming data can carry gaps. Coercing those straight through\n * `Number(value)` would render `$0` (empty string → 0) or `$NaN` (non-numeric),\n * so a missing / non-finite value is rendered as an empty string instead of\n * being fed to the formatter.\n */\nexport const formatValue = (\n value: string | number | null | undefined,\n valueFormatter?: (value: number) => string,\n): string => {\n if (value == null || value === '') return '';\n const num = Number(value);\n if (!Number.isFinite(num)) return '';\n return valueFormatter ? valueFormatter(num) : String(num);\n};\n","import { CartesianGrid, Legend, XAxis, YAxis } from 'recharts';\n\nimport { ChartTooltip } from './ChartTooltip';\nimport { formatValue } from './format';\nimport { type CartesianChartProps } from './types';\n\nconst AXIS_PROPS = {\n tickLine: false,\n axisLine: false,\n tick: { fontSize: 11 },\n} as const;\n\n/**\n * The grid + axes + tooltip + legend shared by the line, bar, and area charts.\n * Colors are applied via `ChartContainer`'s CSS chrome, not inline props, so\n * these stay brand-safe.\n */\nexport const cartesianChrome = ({\n xKey,\n showGrid = true,\n showYAxis = true,\n showLegend = false,\n showTooltip = true,\n valueFormatter,\n}: Pick<\n CartesianChartProps,\n 'xKey' | 'showGrid' | 'showYAxis' | 'showLegend' | 'showTooltip' | 'valueFormatter'\n>) => (\n <>\n {showGrid && <CartesianGrid strokeDasharray=\"3 3\" vertical={false} />}\n <XAxis dataKey={xKey} {...AXIS_PROPS} />\n {showYAxis && (\n <YAxis\n width={48}\n {...AXIS_PROPS}\n tickFormatter={\n valueFormatter\n ? (value: string | number) => formatValue(value, valueFormatter)\n : undefined\n }\n />\n )}\n {showTooltip && (\n <ChartTooltip\n valueFormatter={valueFormatter ? (value) => formatValue(value, valueFormatter) : undefined}\n />\n )}\n {showLegend && <Legend wrapperStyle={{ fontSize: 11 }} />}\n </>\n);\n","/**\n * The design system ships a five-slot categorical chart palette as CSS\n * variables (`--color-chart-1` … `--color-chart-5`). Charts resolve their\n * series colors from these tokens only — never from inline hex or a primitive\n * scale — so they follow both the active color scheme (light/dark, via\n * `data-theme` in `styles.css`) and the active brand: a brand reskins charts\n * by defining `colors.chart` (and `colorsDark.chart`) in its\n * `@keboola/brand-registry` definition, which `ThemeProvider` emits as the\n * `--color-chart-*` variables.\n *\n * The CSS variables hold raw `R G B` channels (for Tailwind's `<alpha-value>`\n * opacity modifiers), so they are wrapped in `rgb(...)` before handing them to\n * recharts as ordinary SVG `stroke` / `fill` strings.\n */\nconst CHART_TOKEN_COUNT = 5;\n\n/** Number of the semantic chart token (`1`–`5`) a series maps to. */\nexport type ChartColorToken = 1 | 2 | 3 | 4 | 5;\n\n/**\n * The CSS color for a chart token. `index` is 0-based (series position); it\n * wraps around the five-slot palette so any number of series stays on-brand.\n */\nexport const chartTokenColor = (index: number): string => {\n // Euclidean modulo so negative indices still land in 1..CHART_TOKEN_COUNT\n // (plain `%` would yield e.g. `--color-chart-0` for index -1).\n const slot = (((index % CHART_TOKEN_COUNT) + CHART_TOKEN_COUNT) % CHART_TOKEN_COUNT) + 1;\n return `rgb(var(--color-chart-${slot}))`;\n};\n\n/** Resolve an explicit token (1–5) or fall back to the series position. */\nexport const resolveSeriesColor = (index: number, token?: ChartColorToken): string =>\n chartTokenColor(token ? token - 1 : index);\n","import { Line, LineChart as RechartsLineChart } from 'recharts';\n\nimport { cartesianChrome } from './cartesian';\nimport { ChartContainer } from './ChartContainer';\nimport { resolveSeriesColor } from './theme';\nimport { type CartesianChartProps } from './types';\n\n/**\n * A themed multi-series line chart. Each series' color comes from the semantic\n * `--color-chart-*` palette (by order, or pinned via `series[].color`), which\n * follows the active color scheme and the active brand's `colors.chart` when it\n * defines one. Wrap-free — mounts its own {@link ChartContainer}.\n *\n * @example\n * <LineChart\n * data={data}\n * xKey=\"month\"\n * series={[{ dataKey: 'revenue', name: 'Revenue' }, { dataKey: 'cost' }]}\n * />\n */\nexport const LineChart = ({\n data,\n xKey,\n series,\n height,\n width,\n className,\n ...chrome\n}: CartesianChartProps) => (\n <ChartContainer height={height} width={width} className={className}>\n <RechartsLineChart data={data} margin={{ top: 8, right: 8, left: 0, bottom: 0 }}>\n {cartesianChrome({ xKey, ...chrome })}\n {series.map((s, index) => {\n const color = resolveSeriesColor(index, s.color);\n return (\n <Line\n key={s.dataKey}\n type=\"monotone\"\n dataKey={s.dataKey}\n name={s.name ?? s.dataKey}\n stroke={color}\n strokeWidth={2}\n dot={{ r: 3, fill: color, stroke: color }}\n activeDot={{ r: 4 }}\n isAnimationActive={false}\n />\n );\n })}\n </RechartsLineChart>\n </ChartContainer>\n);\n","import { Bar, BarChart as RechartsBarChart } from 'recharts';\n\nimport { cartesianChrome } from './cartesian';\nimport { ChartContainer } from './ChartContainer';\nimport { resolveSeriesColor } from './theme';\nimport { type CartesianChartProps } from './types';\n\nexport type BarChartProps = CartesianChartProps & {\n /** Stack the series into a single bar per category. Defaults to grouped. */\n stacked?: boolean;\n};\n\n/**\n * A themed multi-series bar chart. Series colors come from the semantic\n * `--color-chart-*` palette (by order, or pinned via `series[].color`), which\n * follows the active color scheme and the active brand's `colors.chart` when it\n * defines one. Pass `stacked` to stack the series instead of grouping them.\n *\n * @example\n * <BarChart data={data} xKey=\"month\" series={[{ dataKey: 'revenue' }]} />\n */\nexport const BarChart = ({\n data,\n xKey,\n series,\n height,\n width,\n className,\n stacked = false,\n ...chrome\n}: BarChartProps) => (\n <ChartContainer height={height} width={width} className={className}>\n <RechartsBarChart data={data} margin={{ top: 8, right: 8, left: 0, bottom: 0 }}>\n {cartesianChrome({ xKey, ...chrome })}\n {series.map((s, index) => (\n <Bar\n key={s.dataKey}\n dataKey={s.dataKey}\n name={s.name ?? s.dataKey}\n fill={resolveSeriesColor(index, s.color)}\n radius={stacked ? 0 : [4, 4, 0, 0]}\n stackId={stacked ? 'stack' : undefined}\n isAnimationActive={false}\n />\n ))}\n </RechartsBarChart>\n </ChartContainer>\n);\n","import { Area, AreaChart as RechartsAreaChart } from 'recharts';\n\nimport { cartesianChrome } from './cartesian';\nimport { ChartContainer } from './ChartContainer';\nimport { resolveSeriesColor } from './theme';\nimport { type CartesianChartProps } from './types';\n\nexport type AreaChartProps = CartesianChartProps & {\n /** Stack the series into a cumulative area. Defaults to overlaid. */\n stacked?: boolean;\n};\n\n/**\n * A themed multi-series area chart. Each series is stroked and softly filled\n * from the semantic `--color-chart-*` palette (by order, or pinned via\n * `series[].color`), which follows the active color scheme and the active\n * brand's `colors.chart` when it defines one. Pass `stacked` to stack the\n * series cumulatively.\n *\n * @example\n * <AreaChart data={data} xKey=\"month\" series={[{ dataKey: 'revenue' }]} />\n */\nexport const AreaChart = ({\n data,\n xKey,\n series,\n height,\n width,\n className,\n stacked = false,\n ...chrome\n}: AreaChartProps) => (\n <ChartContainer height={height} width={width} className={className}>\n <RechartsAreaChart data={data} margin={{ top: 8, right: 8, left: 0, bottom: 0 }}>\n {cartesianChrome({ xKey, ...chrome })}\n {series.map((s, index) => {\n const color = resolveSeriesColor(index, s.color);\n return (\n <Area\n key={s.dataKey}\n type=\"monotone\"\n dataKey={s.dataKey}\n name={s.name ?? s.dataKey}\n stroke={color}\n fill={color}\n fillOpacity={0.15}\n strokeWidth={2}\n stackId={stacked ? 'stack' : undefined}\n isAnimationActive={false}\n />\n );\n })}\n </RechartsAreaChart>\n </ChartContainer>\n);\n","import { Cell, Legend, Pie, PieChart as RechartsPieChart } from 'recharts';\n\nimport { ChartContainer, type ChartDimension } from './ChartContainer';\nimport { ChartTooltip } from './ChartTooltip';\nimport { formatValue } from './format';\nimport { chartTokenColor } from './theme';\nimport { type ChartDatum } from './types';\n\nexport type PieChartProps = {\n /** The rows to plot — one sector per row. */\n data: ChartDatum[];\n /** Key into each datum for the sector label. */\n nameKey: string;\n /** Key into each datum for the sector value. */\n dataKey: string;\n /** Render as a donut with a hole of this inner radius (px or %). */\n innerRadius?: ChartDimension;\n /** Height as a px number or percentage. Defaults to 300. */\n height?: ChartDimension;\n /** Width as a px number or percentage. Defaults to `\"100%\"`. */\n width?: ChartDimension;\n /** Show a legend below the chart. Defaults to `true`. */\n showLegend?: boolean;\n /** Show the hover tooltip. Defaults to `true`. */\n showTooltip?: boolean;\n /** Format a sector value for the tooltip. */\n valueFormatter?: (value: number) => string;\n className?: string;\n};\n\n/**\n * A themed pie / donut chart. Each sector cycles through the semantic\n * `--color-chart-*` palette, which follows the active color scheme and the\n * active brand's `colors.chart` when it defines one. Pass `innerRadius` to make\n * a donut.\n *\n * @example\n * <PieChart data={data} nameKey=\"engine\" dataKey=\"rows\" innerRadius=\"60%\" />\n */\nexport const PieChart = ({\n data,\n nameKey,\n dataKey,\n innerRadius = 0,\n height,\n width,\n className,\n showLegend = true,\n showTooltip = true,\n valueFormatter,\n}: PieChartProps) => (\n <ChartContainer height={height} width={width} className={className}>\n <RechartsPieChart>\n {showTooltip && (\n <ChartTooltip\n valueFormatter={\n valueFormatter ? (value) => formatValue(value, valueFormatter) : undefined\n }\n />\n )}\n {showLegend && <Legend wrapperStyle={{ fontSize: 11 }} />}\n <Pie\n data={data}\n nameKey={nameKey}\n dataKey={dataKey}\n innerRadius={innerRadius}\n // Separate sectors with the brand surface color rather than recharts'\n // hardcoded white default.\n stroke=\"rgb(var(--color-background))\"\n isAnimationActive={false}\n >\n {data.map((datum, index) => (\n <Cell key={String(datum[nameKey] ?? index)} fill={chartTokenColor(index)} />\n ))}\n </Pie>\n </RechartsPieChart>\n </ChartContainer>\n);\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/classNames.ts","../src/blocks/Charts/ChartContainer.tsx","../src/blocks/Charts/ChartTooltip.tsx","../src/blocks/Charts/format.ts","../src/blocks/Charts/cartesian.tsx","../src/blocks/Charts/theme.ts","../src/blocks/Charts/LineChart.tsx","../src/blocks/Charts/BarChart.tsx","../src/blocks/Charts/AreaChart.tsx","../src/blocks/Charts/PieChart.tsx"],"names":["extendTailwindMerge","clsx","jsx","ResponsiveContainer","jsxs","RechartsTooltip","Fragment","CartesianGrid","XAxis","YAxis","Legend","RechartsLineChart","Line","RechartsBarChart","Bar","RechartsAreaChart","Area","RechartsPieChart","Pie","Cell"],"mappings":";;;;;;;;AAKA,IAAM,UAAUA,iCAAA,CAAoB;AAAA,EAClC,MAAA,EAAQ;AACV,CAAC,CAAA;AAEM,IAAM,KAAK,CAAA,GAAI,OAAA,KAA0B,QAAQC,SAAA,CAAK,GAAG,OAAO,CAAC,CAAA;ACkBjE,IAAM,iBAAiB,CAAC;AAAA,EAC7B,MAAA,GAAS,GAAA;AAAA,EACT,KAAA,GAAQ,MAAA;AAAA,EACR,SAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAG;AACL,CAAA,qBACEC,cAAA;AAAA,EAAC,KAAA;AAAA,EAAA;AAAA,IACC,SAAA,EAAW,EAAA;AAAA,MACT,YAAA;AAAA;AAAA,MAEA,iEAAA;AAAA,MACA,mEAAA;AAAA,MACA,8CAAA;AAAA,MACA,0DAAA;AAAA;AAAA,MAEA,uDAAA;AAAA,MACA,oDAAA;AAAA,MACA,yDAAA;AAAA,MACA,8DAAA;AAAA,MACA,kEAAA;AAAA,MACA,yCAAA;AAAA,MACA;AAAA,KACF;AAAA,IACC,GAAG,KAAA;AAAA,IAEJ,QAAA,kBAAAA,cAAA,CAACC,4BAAA,EAAA,EAAoB,KAAA,EAAc,MAAA,EAChC,QAAA,EACH;AAAA;AACF;AC9BK,IAAM,sBAAsB,CAAC;AAAA,EAClC,MAA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AA,GAErE;AAAA,EAED,UAAA,oBAAcA,cAAAA,CAACQ,eAAAA,EAAA,EAAO,YAAA,EAAc,EAAE,QAAA,EAAU,EAAA,EAAG,EAAG,CAAA;AAAA,kBACvDR,cAAAA;AAAA,IAACgB,YAAA;AAAA,IAAA;AAAA,MACC,IAAA;AAAA,MACA,OAAA;AAAA,MACA,OAAA;AAAA,MACA,WAAA;AAAA,MAGA,MAAA,EAAO,wBAAA;AAAA,MACP,iBAAA,EAAmB,KAAA;AAAA,MAElB,eAAK,GAAA,CAAI,CAAC,OAAO,KAAA,qBAChBhB,eAACiB,aAAA,EAAA,EAA2C,IAAA,EAAM,eAAA,CAAgB,KAAK,KAA5D,MAAA,CAAO,KAAA,CAAM,OAAO,CAAA,IAAK,KAAK,CAAiC,CAC3E;AAAA;AAAA;AACH,CAAA,EACF,CAAA,EACF","file":"charts.cjs","sourcesContent":["import { type ClassValue, clsx } from 'clsx';\nimport { extendTailwindMerge } from 'tailwind-merge';\n\n// tailwind-merge v3 (Tailwind v4): the prefix drops the trailing separator —\n// `tw:` → `tw` (the `:` separator is implied).\nconst twMerge = extendTailwindMerge({\n prefix: 'tw',\n});\n\nexport const cn = (...classes: ClassValue[]) => twMerge(clsx(...classes));\n","import { type ComponentProps, type ReactElement } from 'react';\nimport { ResponsiveContainer } from 'recharts';\n\nimport { cn } from '../../utils';\n\n/** A length that recharts' `<ResponsiveContainer>` accepts: px number or `\"NN%\"`. */\nexport type ChartDimension = number | `${number}%`;\n\nexport type ChartContainerProps = Omit<ComponentProps<'div'>, 'children'> & {\n /**\n * Height as a px number or percentage string. Charts have no intrinsic\n * height, so a container needs one either here or from a sized ancestor.\n * Defaults to 300.\n */\n height?: ChartDimension;\n /** Width as a px number or percentage. Defaults to `\"100%\"` (fills parent). */\n width?: ChartDimension;\n /** A single recharts chart element (`<LineChart>`, `<BarChart>`, …). */\n children: ReactElement;\n};\n\n/**\n * Responsive, brand-themed frame for a chart. Wraps the chart in recharts'\n * `<ResponsiveContainer>` and applies the semantic-token chrome (axis text,\n * grid, cursor) through CSS so every chart inside inherits it. Sizing is\n * intrinsic: give it a `height` (default 300) and it fills the parent width.\n */\nexport const ChartContainer = ({\n height = 300,\n width = '100%',\n className,\n children,\n ...props\n}: ChartContainerProps) => (\n <div\n className={cn(\n 'tw:text-xs',\n // Axis ticks and labels follow the muted foreground token.\n 'tw:[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground',\n 'tw:[&_.recharts-polar-angle-axis-tick_text]:fill-muted-foreground',\n 'tw:[&_.recharts-label]:fill-muted-foreground',\n 'tw:[&_.recharts-legend-item-text]:!text-muted-foreground',\n // Grid lines, axis lines and the hover cursor follow the border token.\n 'tw:[&_.recharts-cartesian-grid_line]:stroke-border/60',\n 'tw:[&_.recharts-cartesian-axis-line]:stroke-border',\n 'tw:[&_.recharts-cartesian-axis-tick-line]:stroke-border',\n 'tw:[&_.recharts-curve.recharts-tooltip-cursor]:stroke-border',\n 'tw:[&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted/60',\n 'tw:[&_.recharts-surface]:outline-hidden',\n className,\n )}\n {...props}\n >\n <ResponsiveContainer width={width} height={height}>\n {children}\n </ResponsiveContainer>\n </div>\n);\n","import { type ComponentProps } from 'react';\nimport { Tooltip as RechartsTooltip } from 'recharts';\n\nimport { cn } from '../../utils';\n\ntype TooltipPayloadEntry = {\n name?: string | number;\n value?: string | number;\n color?: string;\n dataKey?: string | number;\n};\n\ntype ChartTooltipContentProps = {\n active?: boolean;\n label?: string | number;\n payload?: TooltipPayloadEntry[];\n /** Format a value for display (e.g. currency, percentage). */\n valueFormatter?: (value: string | number, name: string) => string;\n className?: string;\n};\n\n/**\n * Brand-themed tooltip body. Surfaces (background, border, text) resolve from\n * semantic tokens, and each series swatch reuses the recharts-provided series\n * `color` (already a `--chart-*` token from this package's charts).\n */\nexport const ChartTooltipContent = ({\n active,\n label,\n payload,\n valueFormatter,\n className,\n}: ChartTooltipContentProps) => {\n if (!active || !payload?.length) return null;\n\n return (\n <div\n className={cn(\n 'tw:min-w-32 tw:rounded-md tw:border tw:border-border tw:bg-popover tw:px-2.5 tw:py-1.5 tw:text-xs tw:text-popover-foreground tw:shadow-md',\n className,\n )}\n >\n {label != null && <div className=\"tw:mb-1 tw:font-medium\">{label}</div>}\n <div className=\"tw:flex tw:flex-col tw:gap-1\">\n {payload.map((entry) => {\n const name = String(entry.name ?? entry.dataKey ?? '');\n const value = entry.value;\n // Missing / non-numeric values render blank rather than \"NaN\"/\"0\";\n // only well-formed numbers reach the formatter.\n const hasNumber = value != null && value !== '' && Number.isFinite(Number(value));\n const display = hasNumber\n ? valueFormatter\n ? valueFormatter(Number(value), name)\n : String(Number(value))\n : (value ?? '');\n return (\n <div\n key={String(entry.dataKey ?? name)}\n className=\"tw:flex tw:items-center tw:justify-between tw:gap-3\"\n >\n <span className=\"tw:flex tw:items-center tw:gap-1.5\">\n <span\n className=\"tw:size-2 tw:shrink-0 tw:rounded-[2px]\"\n style={{ backgroundColor: entry.color }}\n />\n <span className=\"tw:text-muted-foreground\">{name}</span>\n </span>\n <span className=\"tw:font-medium tw:tabular-nums\">{display}</span>\n </div>\n );\n })}\n </div>\n </div>\n );\n};\n\nexport type ChartTooltipProps = ComponentProps<typeof RechartsTooltip> & {\n valueFormatter?: (value: string | number, name: string) => string;\n};\n\n/**\n * Drop-in recharts `<Tooltip>` pre-wired to render {@link ChartTooltipContent}.\n * Each chart mounts one by default; pass `showTooltip={false}` on the chart to omit.\n */\nexport const ChartTooltip = ({ valueFormatter, ...props }: ChartTooltipProps) => (\n <RechartsTooltip\n cursor={{ strokeWidth: 1 }}\n content={<ChartTooltipContent valueFormatter={valueFormatter} />}\n {...props}\n />\n);\n","/**\n * Apply a numeric `valueFormatter` safely. recharts hands axis ticks and\n * tooltip payload values as `string | number | null | undefined`, and partial\n * or streaming data can carry gaps. Coercing those straight through\n * `Number(value)` would render `$0` (empty string → 0) or `$NaN` (non-numeric),\n * so a missing / non-finite value is rendered as an empty string instead of\n * being fed to the formatter.\n */\nexport const formatValue = (\n value: string | number | null | undefined,\n valueFormatter?: (value: number) => string,\n): string => {\n if (value == null || value === '') return '';\n const num = Number(value);\n if (!Number.isFinite(num)) return '';\n return valueFormatter ? valueFormatter(num) : String(num);\n};\n","import { CartesianGrid, Legend, XAxis, YAxis } from 'recharts';\n\nimport { ChartTooltip } from './ChartTooltip';\nimport { formatValue } from './format';\nimport { type CartesianChartProps } from './types';\n\nconst AXIS_PROPS = {\n tickLine: false,\n axisLine: false,\n tick: { fontSize: 11 },\n} as const;\n\n/**\n * The grid + axes + tooltip + legend shared by the line, bar, and area charts.\n * Colors are applied via `ChartContainer`'s CSS chrome, not inline props, so\n * these stay brand-safe.\n */\nexport const cartesianChrome = ({\n xKey,\n showGrid = true,\n showYAxis = true,\n showLegend = false,\n showTooltip = true,\n valueFormatter,\n}: Pick<\n CartesianChartProps,\n 'xKey' | 'showGrid' | 'showYAxis' | 'showLegend' | 'showTooltip' | 'valueFormatter'\n>) => (\n <>\n {showGrid && <CartesianGrid strokeDasharray=\"3 3\" vertical={false} />}\n <XAxis dataKey={xKey} {...AXIS_PROPS} />\n {showYAxis && (\n <YAxis\n width={48}\n {...AXIS_PROPS}\n tickFormatter={\n valueFormatter\n ? (value: string | number) => formatValue(value, valueFormatter)\n : undefined\n }\n />\n )}\n {showTooltip && (\n <ChartTooltip\n valueFormatter={valueFormatter ? (value) => formatValue(value, valueFormatter) : undefined}\n />\n )}\n {showLegend && <Legend wrapperStyle={{ fontSize: 11 }} />}\n </>\n);\n","/**\n * The design system ships a five-slot categorical chart palette as CSS\n * variables (`--chart-1` … `--chart-5`). Charts resolve their\n * series colors from these tokens only — never from inline hex or a primitive\n * scale — so they follow both the active color scheme (light/dark, via\n * `data-theme` in `styles.css`) and the active brand: a brand reskins charts\n * by defining `colors.chart` (and `colorsDark.chart`) in its\n * `@keboola/brand-registry` definition, which `ThemeProvider` emits as the\n * `--chart-*` variables.\n *\n * The CSS variables hold raw `R G B` channels (for Tailwind's `<alpha-value>`\n * opacity modifiers), so they are wrapped in `rgb(...)` before handing them to\n * recharts as ordinary SVG `stroke` / `fill` strings.\n */\nconst CHART_TOKEN_COUNT = 5;\n\n/** Number of the semantic chart token (`1`–`5`) a series maps to. */\nexport type ChartColorToken = 1 | 2 | 3 | 4 | 5;\n\n/**\n * The CSS color for a chart token. `index` is 0-based (series position); it\n * wraps around the five-slot palette so any number of series stays on-brand.\n */\nexport const chartTokenColor = (index: number): string => {\n // Euclidean modulo so negative indices still land in 1..CHART_TOKEN_COUNT\n // (plain `%` would yield e.g. `--chart-0` for index -1).\n const slot = (((index % CHART_TOKEN_COUNT) + CHART_TOKEN_COUNT) % CHART_TOKEN_COUNT) + 1;\n return `rgb(var(--chart-${slot}))`;\n};\n\n/** Resolve an explicit token (1–5) or fall back to the series position. */\nexport const resolveSeriesColor = (index: number, token?: ChartColorToken): string =>\n chartTokenColor(token ? token - 1 : index);\n","import { Line, LineChart as RechartsLineChart } from 'recharts';\n\nimport { cartesianChrome } from './cartesian';\nimport { ChartContainer } from './ChartContainer';\nimport { resolveSeriesColor } from './theme';\nimport { type CartesianChartProps } from './types';\n\n/**\n * A themed multi-series line chart. Each series' color comes from the semantic\n * `--chart-*` palette (by order, or pinned via `series[].color`), which\n * follows the active color scheme and the active brand's `colors.chart` when it\n * defines one. Wrap-free — mounts its own {@link ChartContainer}.\n *\n * @example\n * <LineChart\n * data={data}\n * xKey=\"month\"\n * series={[{ dataKey: 'revenue', name: 'Revenue' }, { dataKey: 'cost' }]}\n * />\n */\nexport const LineChart = ({\n data,\n xKey,\n series,\n height,\n width,\n className,\n ...chrome\n}: CartesianChartProps) => (\n <ChartContainer height={height} width={width} className={className}>\n <RechartsLineChart data={data} margin={{ top: 8, right: 8, left: 0, bottom: 0 }}>\n {cartesianChrome({ xKey, ...chrome })}\n {series.map((s, index) => {\n const color = resolveSeriesColor(index, s.color);\n return (\n <Line\n key={s.dataKey}\n type=\"monotone\"\n dataKey={s.dataKey}\n name={s.name ?? s.dataKey}\n stroke={color}\n strokeWidth={2}\n dot={{ r: 3, fill: color, stroke: color }}\n activeDot={{ r: 4 }}\n isAnimationActive={false}\n />\n );\n })}\n </RechartsLineChart>\n </ChartContainer>\n);\n","import { Bar, BarChart as RechartsBarChart } from 'recharts';\n\nimport { cartesianChrome } from './cartesian';\nimport { ChartContainer } from './ChartContainer';\nimport { resolveSeriesColor } from './theme';\nimport { type CartesianChartProps } from './types';\n\nexport type BarChartProps = CartesianChartProps & {\n /** Stack the series into a single bar per category. Defaults to grouped. */\n stacked?: boolean;\n};\n\n/**\n * A themed multi-series bar chart. Series colors come from the semantic\n * `--chart-*` palette (by order, or pinned via `series[].color`), which\n * follows the active color scheme and the active brand's `colors.chart` when it\n * defines one. Pass `stacked` to stack the series instead of grouping them.\n *\n * @example\n * <BarChart data={data} xKey=\"month\" series={[{ dataKey: 'revenue' }]} />\n */\nexport const BarChart = ({\n data,\n xKey,\n series,\n height,\n width,\n className,\n stacked = false,\n ...chrome\n}: BarChartProps) => (\n <ChartContainer height={height} width={width} className={className}>\n <RechartsBarChart data={data} margin={{ top: 8, right: 8, left: 0, bottom: 0 }}>\n {cartesianChrome({ xKey, ...chrome })}\n {series.map((s, index) => (\n <Bar\n key={s.dataKey}\n dataKey={s.dataKey}\n name={s.name ?? s.dataKey}\n fill={resolveSeriesColor(index, s.color)}\n radius={stacked ? 0 : [4, 4, 0, 0]}\n stackId={stacked ? 'stack' : undefined}\n isAnimationActive={false}\n />\n ))}\n </RechartsBarChart>\n </ChartContainer>\n);\n","import { Area, AreaChart as RechartsAreaChart } from 'recharts';\n\nimport { cartesianChrome } from './cartesian';\nimport { ChartContainer } from './ChartContainer';\nimport { resolveSeriesColor } from './theme';\nimport { type CartesianChartProps } from './types';\n\nexport type AreaChartProps = CartesianChartProps & {\n /** Stack the series into a cumulative area. Defaults to overlaid. */\n stacked?: boolean;\n};\n\n/**\n * A themed multi-series area chart. Each series is stroked and softly filled\n * from the semantic `--chart-*` palette (by order, or pinned via\n * `series[].color`), which follows the active color scheme and the active\n * brand's `colors.chart` when it defines one. Pass `stacked` to stack the\n * series cumulatively.\n *\n * @example\n * <AreaChart data={data} xKey=\"month\" series={[{ dataKey: 'revenue' }]} />\n */\nexport const AreaChart = ({\n data,\n xKey,\n series,\n height,\n width,\n className,\n stacked = false,\n ...chrome\n}: AreaChartProps) => (\n <ChartContainer height={height} width={width} className={className}>\n <RechartsAreaChart data={data} margin={{ top: 8, right: 8, left: 0, bottom: 0 }}>\n {cartesianChrome({ xKey, ...chrome })}\n {series.map((s, index) => {\n const color = resolveSeriesColor(index, s.color);\n return (\n <Area\n key={s.dataKey}\n type=\"monotone\"\n dataKey={s.dataKey}\n name={s.name ?? s.dataKey}\n stroke={color}\n fill={color}\n fillOpacity={0.15}\n strokeWidth={2}\n stackId={stacked ? 'stack' : undefined}\n isAnimationActive={false}\n />\n );\n })}\n </RechartsAreaChart>\n </ChartContainer>\n);\n","import { Cell, Legend, Pie, PieChart as RechartsPieChart } from 'recharts';\n\nimport { ChartContainer, type ChartDimension } from './ChartContainer';\nimport { ChartTooltip } from './ChartTooltip';\nimport { formatValue } from './format';\nimport { chartTokenColor } from './theme';\nimport { type ChartDatum } from './types';\n\nexport type PieChartProps = {\n /** The rows to plot — one sector per row. */\n data: ChartDatum[];\n /** Key into each datum for the sector label. */\n nameKey: string;\n /** Key into each datum for the sector value. */\n dataKey: string;\n /** Render as a donut with a hole of this inner radius (px or %). */\n innerRadius?: ChartDimension;\n /** Height as a px number or percentage. Defaults to 300. */\n height?: ChartDimension;\n /** Width as a px number or percentage. Defaults to `\"100%\"`. */\n width?: ChartDimension;\n /** Show a legend below the chart. Defaults to `true`. */\n showLegend?: boolean;\n /** Show the hover tooltip. Defaults to `true`. */\n showTooltip?: boolean;\n /** Format a sector value for the tooltip. */\n valueFormatter?: (value: number) => string;\n className?: string;\n};\n\n/**\n * A themed pie / donut chart. Each sector cycles through the semantic\n * `--chart-*` palette, which follows the active color scheme and the\n * active brand's `colors.chart` when it defines one. Pass `innerRadius` to make\n * a donut.\n *\n * @example\n * <PieChart data={data} nameKey=\"engine\" dataKey=\"rows\" innerRadius=\"60%\" />\n */\nexport const PieChart = ({\n data,\n nameKey,\n dataKey,\n innerRadius = 0,\n height,\n width,\n className,\n showLegend = true,\n showTooltip = true,\n valueFormatter,\n}: PieChartProps) => (\n <ChartContainer height={height} width={width} className={className}>\n <RechartsPieChart>\n {showTooltip && (\n <ChartTooltip\n valueFormatter={\n valueFormatter ? (value) => formatValue(value, valueFormatter) : undefined\n }\n />\n )}\n {showLegend && <Legend wrapperStyle={{ fontSize: 11 }} />}\n <Pie\n data={data}\n nameKey={nameKey}\n dataKey={dataKey}\n innerRadius={innerRadius}\n // Separate sectors with the brand surface color rather than recharts'\n // hardcoded white default.\n stroke=\"rgb(var(--background))\"\n isAnimationActive={false}\n >\n {data.map((datum, index) => (\n <Cell key={String(datum[nameKey] ?? index)} fill={chartTokenColor(index)} />\n ))}\n </Pie>\n </RechartsPieChart>\n </ChartContainer>\n);\n"]}
|
package/dist/charts.d.cts
CHANGED
|
@@ -41,7 +41,7 @@ type ChartTooltipContentProps = {
|
|
|
41
41
|
/**
|
|
42
42
|
* Brand-themed tooltip body. Surfaces (background, border, text) resolve from
|
|
43
43
|
* semantic tokens, and each series swatch reuses the recharts-provided series
|
|
44
|
-
* `color` (already a `--
|
|
44
|
+
* `color` (already a `--chart-*` token from this package's charts).
|
|
45
45
|
*/
|
|
46
46
|
declare const ChartTooltipContent: ({ active, label, payload, valueFormatter, className, }: ChartTooltipContentProps) => react_jsx_runtime.JSX.Element | null;
|
|
47
47
|
type ChartTooltipProps = ComponentProps<typeof Tooltip> & {
|
|
@@ -102,7 +102,7 @@ type CartesianChartProps = {
|
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
104
|
* A themed multi-series line chart. Each series' color comes from the semantic
|
|
105
|
-
* `--
|
|
105
|
+
* `--chart-*` palette (by order, or pinned via `series[].color`), which
|
|
106
106
|
* follows the active color scheme and the active brand's `colors.chart` when it
|
|
107
107
|
* defines one. Wrap-free — mounts its own {@link ChartContainer}.
|
|
108
108
|
*
|
|
@@ -121,7 +121,7 @@ type BarChartProps = CartesianChartProps & {
|
|
|
121
121
|
};
|
|
122
122
|
/**
|
|
123
123
|
* A themed multi-series bar chart. Series colors come from the semantic
|
|
124
|
-
* `--
|
|
124
|
+
* `--chart-*` palette (by order, or pinned via `series[].color`), which
|
|
125
125
|
* follows the active color scheme and the active brand's `colors.chart` when it
|
|
126
126
|
* defines one. Pass `stacked` to stack the series instead of grouping them.
|
|
127
127
|
*
|
|
@@ -136,7 +136,7 @@ type AreaChartProps = CartesianChartProps & {
|
|
|
136
136
|
};
|
|
137
137
|
/**
|
|
138
138
|
* A themed multi-series area chart. Each series is stroked and softly filled
|
|
139
|
-
* from the semantic `--
|
|
139
|
+
* from the semantic `--chart-*` palette (by order, or pinned via
|
|
140
140
|
* `series[].color`), which follows the active color scheme and the active
|
|
141
141
|
* brand's `colors.chart` when it defines one. Pass `stacked` to stack the
|
|
142
142
|
* series cumulatively.
|
|
@@ -169,7 +169,7 @@ type PieChartProps = {
|
|
|
169
169
|
};
|
|
170
170
|
/**
|
|
171
171
|
* A themed pie / donut chart. Each sector cycles through the semantic
|
|
172
|
-
* `--
|
|
172
|
+
* `--chart-*` palette, which follows the active color scheme and the
|
|
173
173
|
* active brand's `colors.chart` when it defines one. Pass `innerRadius` to make
|
|
174
174
|
* a donut.
|
|
175
175
|
*
|
package/dist/charts.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ type ChartTooltipContentProps = {
|
|
|
41
41
|
/**
|
|
42
42
|
* Brand-themed tooltip body. Surfaces (background, border, text) resolve from
|
|
43
43
|
* semantic tokens, and each series swatch reuses the recharts-provided series
|
|
44
|
-
* `color` (already a `--
|
|
44
|
+
* `color` (already a `--chart-*` token from this package's charts).
|
|
45
45
|
*/
|
|
46
46
|
declare const ChartTooltipContent: ({ active, label, payload, valueFormatter, className, }: ChartTooltipContentProps) => react_jsx_runtime.JSX.Element | null;
|
|
47
47
|
type ChartTooltipProps = ComponentProps<typeof Tooltip> & {
|
|
@@ -102,7 +102,7 @@ type CartesianChartProps = {
|
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
104
|
* A themed multi-series line chart. Each series' color comes from the semantic
|
|
105
|
-
* `--
|
|
105
|
+
* `--chart-*` palette (by order, or pinned via `series[].color`), which
|
|
106
106
|
* follows the active color scheme and the active brand's `colors.chart` when it
|
|
107
107
|
* defines one. Wrap-free — mounts its own {@link ChartContainer}.
|
|
108
108
|
*
|
|
@@ -121,7 +121,7 @@ type BarChartProps = CartesianChartProps & {
|
|
|
121
121
|
};
|
|
122
122
|
/**
|
|
123
123
|
* A themed multi-series bar chart. Series colors come from the semantic
|
|
124
|
-
* `--
|
|
124
|
+
* `--chart-*` palette (by order, or pinned via `series[].color`), which
|
|
125
125
|
* follows the active color scheme and the active brand's `colors.chart` when it
|
|
126
126
|
* defines one. Pass `stacked` to stack the series instead of grouping them.
|
|
127
127
|
*
|
|
@@ -136,7 +136,7 @@ type AreaChartProps = CartesianChartProps & {
|
|
|
136
136
|
};
|
|
137
137
|
/**
|
|
138
138
|
* A themed multi-series area chart. Each series is stroked and softly filled
|
|
139
|
-
* from the semantic `--
|
|
139
|
+
* from the semantic `--chart-*` palette (by order, or pinned via
|
|
140
140
|
* `series[].color`), which follows the active color scheme and the active
|
|
141
141
|
* brand's `colors.chart` when it defines one. Pass `stacked` to stack the
|
|
142
142
|
* series cumulatively.
|
|
@@ -169,7 +169,7 @@ type PieChartProps = {
|
|
|
169
169
|
};
|
|
170
170
|
/**
|
|
171
171
|
* A themed pie / donut chart. Each sector cycles through the semantic
|
|
172
|
-
* `--
|
|
172
|
+
* `--chart-*` palette, which follows the active color scheme and the
|
|
173
173
|
* active brand's `colors.chart` when it defines one. Pass `innerRadius` to make
|
|
174
174
|
* a donut.
|
|
175
175
|
*
|
package/dist/charts.js
CHANGED
|
@@ -5,7 +5,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
5
5
|
|
|
6
6
|
// src/blocks/Charts/ChartContainer.tsx
|
|
7
7
|
var twMerge = extendTailwindMerge({
|
|
8
|
-
prefix: "tw
|
|
8
|
+
prefix: "tw"
|
|
9
9
|
});
|
|
10
10
|
var cn = (...classes) => twMerge(clsx(...classes));
|
|
11
11
|
var ChartContainer = ({
|
|
@@ -18,19 +18,19 @@ var ChartContainer = ({
|
|
|
18
18
|
"div",
|
|
19
19
|
{
|
|
20
20
|
className: cn(
|
|
21
|
-
"tw
|
|
21
|
+
"tw:text-xs",
|
|
22
22
|
// Axis ticks and labels follow the muted foreground token.
|
|
23
|
-
"[&_.recharts-cartesian-axis-tick_text]:
|
|
24
|
-
"[&_.recharts-polar-angle-axis-tick_text]:
|
|
25
|
-
"[&_.recharts-label]:
|
|
26
|
-
"[&_.recharts-legend-item-text]:!
|
|
23
|
+
"tw:[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground",
|
|
24
|
+
"tw:[&_.recharts-polar-angle-axis-tick_text]:fill-muted-foreground",
|
|
25
|
+
"tw:[&_.recharts-label]:fill-muted-foreground",
|
|
26
|
+
"tw:[&_.recharts-legend-item-text]:!text-muted-foreground",
|
|
27
27
|
// Grid lines, axis lines and the hover cursor follow the border token.
|
|
28
|
-
"[&_.recharts-cartesian-grid_line]:
|
|
29
|
-
"[&_.recharts-cartesian-axis-line]:
|
|
30
|
-
"[&_.recharts-cartesian-axis-tick-line]:
|
|
31
|
-
"[&_.recharts-curve.recharts-tooltip-cursor]:
|
|
32
|
-
"[&_.recharts-rectangle.recharts-tooltip-cursor]:
|
|
33
|
-
"[&_.recharts-surface]:
|
|
28
|
+
"tw:[&_.recharts-cartesian-grid_line]:stroke-border/60",
|
|
29
|
+
"tw:[&_.recharts-cartesian-axis-line]:stroke-border",
|
|
30
|
+
"tw:[&_.recharts-cartesian-axis-tick-line]:stroke-border",
|
|
31
|
+
"tw:[&_.recharts-curve.recharts-tooltip-cursor]:stroke-border",
|
|
32
|
+
"tw:[&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted/60",
|
|
33
|
+
"tw:[&_.recharts-surface]:outline-hidden",
|
|
34
34
|
className
|
|
35
35
|
),
|
|
36
36
|
...props,
|
|
@@ -49,12 +49,12 @@ var ChartTooltipContent = ({
|
|
|
49
49
|
"div",
|
|
50
50
|
{
|
|
51
51
|
className: cn(
|
|
52
|
-
"tw
|
|
52
|
+
"tw:min-w-32 tw:rounded-md tw:border tw:border-border tw:bg-popover tw:px-2.5 tw:py-1.5 tw:text-xs tw:text-popover-foreground tw:shadow-md",
|
|
53
53
|
className
|
|
54
54
|
),
|
|
55
55
|
children: [
|
|
56
|
-
label != null && /* @__PURE__ */ jsx("div", { className: "tw
|
|
57
|
-
/* @__PURE__ */ jsx("div", { className: "tw
|
|
56
|
+
label != null && /* @__PURE__ */ jsx("div", { className: "tw:mb-1 tw:font-medium", children: label }),
|
|
57
|
+
/* @__PURE__ */ jsx("div", { className: "tw:flex tw:flex-col tw:gap-1", children: payload.map((entry) => {
|
|
58
58
|
const name = String(entry.name ?? entry.dataKey ?? "");
|
|
59
59
|
const value = entry.value;
|
|
60
60
|
const hasNumber = value != null && value !== "" && Number.isFinite(Number(value));
|
|
@@ -62,19 +62,19 @@ var ChartTooltipContent = ({
|
|
|
62
62
|
return /* @__PURE__ */ jsxs(
|
|
63
63
|
"div",
|
|
64
64
|
{
|
|
65
|
-
className: "tw
|
|
65
|
+
className: "tw:flex tw:items-center tw:justify-between tw:gap-3",
|
|
66
66
|
children: [
|
|
67
|
-
/* @__PURE__ */ jsxs("span", { className: "tw
|
|
67
|
+
/* @__PURE__ */ jsxs("span", { className: "tw:flex tw:items-center tw:gap-1.5", children: [
|
|
68
68
|
/* @__PURE__ */ jsx(
|
|
69
69
|
"span",
|
|
70
70
|
{
|
|
71
|
-
className: "tw
|
|
71
|
+
className: "tw:size-2 tw:shrink-0 tw:rounded-[2px]",
|
|
72
72
|
style: { backgroundColor: entry.color }
|
|
73
73
|
}
|
|
74
74
|
),
|
|
75
|
-
/* @__PURE__ */ jsx("span", { className: "tw
|
|
75
|
+
/* @__PURE__ */ jsx("span", { className: "tw:text-muted-foreground", children: name })
|
|
76
76
|
] }),
|
|
77
|
-
/* @__PURE__ */ jsx("span", { className: "tw
|
|
77
|
+
/* @__PURE__ */ jsx("span", { className: "tw:font-medium tw:tabular-nums", children: display })
|
|
78
78
|
]
|
|
79
79
|
},
|
|
80
80
|
String(entry.dataKey ?? name)
|
|
@@ -136,7 +136,7 @@ var cartesianChrome = ({
|
|
|
136
136
|
var CHART_TOKEN_COUNT = 5;
|
|
137
137
|
var chartTokenColor = (index) => {
|
|
138
138
|
const slot = (index % CHART_TOKEN_COUNT + CHART_TOKEN_COUNT) % CHART_TOKEN_COUNT + 1;
|
|
139
|
-
return `rgb(var(--
|
|
139
|
+
return `rgb(var(--chart-${slot}))`;
|
|
140
140
|
};
|
|
141
141
|
var resolveSeriesColor = (index, token) => chartTokenColor(token ? token - 1 : index);
|
|
142
142
|
var LineChart = ({
|
|
@@ -247,7 +247,7 @@ var PieChart = ({
|
|
|
247
247
|
nameKey,
|
|
248
248
|
dataKey,
|
|
249
249
|
innerRadius,
|
|
250
|
-
stroke: "rgb(var(--
|
|
250
|
+
stroke: "rgb(var(--background))",
|
|
251
251
|
isAnimationActive: false,
|
|
252
252
|
children: data.map((datum, index) => /* @__PURE__ */ jsx(Cell, { fill: chartTokenColor(index) }, String(datum[nameKey] ?? index)))
|
|
253
253
|
}
|
package/dist/charts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/classNames.ts","../src/blocks/Charts/ChartContainer.tsx","../src/blocks/Charts/ChartTooltip.tsx","../src/blocks/Charts/format.ts","../src/blocks/Charts/cartesian.tsx","../src/blocks/Charts/theme.ts","../src/blocks/Charts/LineChart.tsx","../src/blocks/Charts/BarChart.tsx","../src/blocks/Charts/AreaChart.tsx","../src/blocks/Charts/PieChart.tsx"],"names":["jsx","RechartsTooltip","jsxs","RechartsLineChart","RechartsBarChart","RechartsAreaChart","RechartsPieChart","Legend"],"mappings":";;;;;;AAGA,IAAM,UAAU,mBAAA,CAAoB;AAAA,EAClC,MAAA,EAAQ;AACV,CAAC,CAAA;AAEM,IAAM,KAAK,CAAA,GAAI,OAAA,KAA0B,QAAQ,IAAA,CAAK,GAAG,OAAO,CAAC,CAAA;ACoBjE,IAAM,iBAAiB,CAAC;AAAA,EAC7B,MAAA,GAAS,GAAA;AAAA,EACT,KAAA,GAAQ,MAAA;AAAA,EACR,SAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAG;AACL,CAAA,qBACE,GAAA;AAAA,EAAC,KAAA;AAAA,EAAA;AAAA,IACC,SAAA,EAAW,EAAA;AAAA,MACT,YAAA;AAAA;AAAA,MAEA,iEAAA;AAAA,MACA,mEAAA;AAAA,MACA,8CAAA;AAAA,MACA,0DAAA;AAAA;AAAA,MAEA,uDAAA;AAAA,MACA,oDAAA;AAAA,MACA,yDAAA;AAAA,MACA,8DAAA;AAAA,MACA,kEAAA;AAAA,MACA,uCAAA;AAAA,MACA;AAAA,KACF;AAAA,IACC,GAAG,KAAA;AAAA,IAEJ,QAAA,kBAAA,GAAA,CAAC,mBAAA,EAAA,EAAoB,KAAA,EAAc,MAAA,EAChC,QAAA,EACH;AAAA;AACF;AC9BK,IAAM,sBAAsB,CAAC;AAAA,EAClC,MAAA;AAAA,EACA,KAAA;AAAA,EACA,OAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF,CAAA,KAAgC;AAC9B,EAAA,IAAI,CAAC,MAAA,IAAU,CAAC,OAAA,EAAS,QAAQ,OAAO,IAAA;AAExC,EAAA,uBACE,IAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAW,EAAA;AAAA,QACT,2IAAA;AAAA,QACA;AAAA,OACF;AAAA,MAEC,QAAA,EAAA;AAAA,QAAA,KAAA,IAAS,wB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A,qBAChBA,IAAC,IAAA,EAAA,EAA2C,IAAA,EAAM,eAAA,CAAgB,KAAK,KAA5D,MAAA,CAAO,KAAA,CAAM,OAAO,CAAA,IAAK,KAAK,CAAiC,CAC3E;AAAA;AAAA;AACH,CAAA,EACF,CAAA,EACF","file":"charts.js","sourcesContent":["import { type ClassValue, clsx } from 'clsx';\nimport { extendTailwindMerge } from 'tailwind-merge';\n\nconst twMerge = extendTailwindMerge({\n prefix: 'tw-',\n});\n\nexport const cn = (...classes: ClassValue[]) => twMerge(clsx(...classes));\n","import { type ComponentProps, type ReactElement } from 'react';\nimport { ResponsiveContainer } from 'recharts';\n\nimport { cn } from '../../utils';\n\n/** A length that recharts' `<ResponsiveContainer>` accepts: px number or `\"NN%\"`. */\nexport type ChartDimension = number | `${number}%`;\n\nexport type ChartContainerProps = Omit<ComponentProps<'div'>, 'children'> & {\n /**\n * Height as a px number or percentage string. Charts have no intrinsic\n * height, so a container needs one either here or from a sized ancestor.\n * Defaults to 300.\n */\n height?: ChartDimension;\n /** Width as a px number or percentage. Defaults to `\"100%\"` (fills parent). */\n width?: ChartDimension;\n /** A single recharts chart element (`<LineChart>`, `<BarChart>`, …). */\n children: ReactElement;\n};\n\n/**\n * Responsive, brand-themed frame for a chart. Wraps the chart in recharts'\n * `<ResponsiveContainer>` and applies the semantic-token chrome (axis text,\n * grid, cursor) through CSS so every chart inside inherits it. Sizing is\n * intrinsic: give it a `height` (default 300) and it fills the parent width.\n */\nexport const ChartContainer = ({\n height = 300,\n width = '100%',\n className,\n children,\n ...props\n}: ChartContainerProps) => (\n <div\n className={cn(\n 'tw-text-xs',\n // Axis ticks and labels follow the muted foreground token.\n '[&_.recharts-cartesian-axis-tick_text]:tw-fill-muted-foreground',\n '[&_.recharts-polar-angle-axis-tick_text]:tw-fill-muted-foreground',\n '[&_.recharts-label]:tw-fill-muted-foreground',\n '[&_.recharts-legend-item-text]:!tw-text-muted-foreground',\n // Grid lines, axis lines and the hover cursor follow the border token.\n '[&_.recharts-cartesian-grid_line]:tw-stroke-border/60',\n '[&_.recharts-cartesian-axis-line]:tw-stroke-border',\n '[&_.recharts-cartesian-axis-tick-line]:tw-stroke-border',\n '[&_.recharts-curve.recharts-tooltip-cursor]:tw-stroke-border',\n '[&_.recharts-rectangle.recharts-tooltip-cursor]:tw-fill-muted/60',\n '[&_.recharts-surface]:tw-outline-none',\n className,\n )}\n {...props}\n >\n <ResponsiveContainer width={width} height={height}>\n {children}\n </ResponsiveContainer>\n </div>\n);\n","import { type ComponentProps } from 'react';\nimport { Tooltip as RechartsTooltip } from 'recharts';\n\nimport { cn } from '../../utils';\n\ntype TooltipPayloadEntry = {\n name?: string | number;\n value?: string | number;\n color?: string;\n dataKey?: string | number;\n};\n\ntype ChartTooltipContentProps = {\n active?: boolean;\n label?: string | number;\n payload?: TooltipPayloadEntry[];\n /** Format a value for display (e.g. currency, percentage). */\n valueFormatter?: (value: string | number, name: string) => string;\n className?: string;\n};\n\n/**\n * Brand-themed tooltip body. Surfaces (background, border, text) resolve from\n * semantic tokens, and each series swatch reuses the recharts-provided series\n * `color` (already a `--color-chart-*` token from this package's charts).\n */\nexport const ChartTooltipContent = ({\n active,\n label,\n payload,\n valueFormatter,\n className,\n}: ChartTooltipContentProps) => {\n if (!active || !payload?.length) return null;\n\n return (\n <div\n className={cn(\n 'tw-min-w-32 tw-rounded-md tw-border tw-border-border tw-bg-popover tw-px-2.5 tw-py-1.5 tw-text-xs tw-text-popover-foreground tw-shadow-md',\n className,\n )}\n >\n {label != null && <div className=\"tw-mb-1 tw-font-medium\">{label}</div>}\n <div className=\"tw-flex tw-flex-col tw-gap-1\">\n {payload.map((entry) => {\n const name = String(entry.name ?? entry.dataKey ?? '');\n const value = entry.value;\n // Missing / non-numeric values render blank rather than \"NaN\"/\"0\";\n // only well-formed numbers reach the formatter.\n const hasNumber = value != null && value !== '' && Number.isFinite(Number(value));\n const display = hasNumber\n ? valueFormatter\n ? valueFormatter(Number(value), name)\n : String(Number(value))\n : (value ?? '');\n return (\n <div\n key={String(entry.dataKey ?? name)}\n className=\"tw-flex tw-items-center tw-justify-between tw-gap-3\"\n >\n <span className=\"tw-flex tw-items-center tw-gap-1.5\">\n <span\n className=\"tw-size-2 tw-shrink-0 tw-rounded-[2px]\"\n style={{ backgroundColor: entry.color }}\n />\n <span className=\"tw-text-muted-foreground\">{name}</span>\n </span>\n <span className=\"tw-font-medium tw-tabular-nums\">{display}</span>\n </div>\n );\n })}\n </div>\n </div>\n );\n};\n\nexport type ChartTooltipProps = ComponentProps<typeof RechartsTooltip> & {\n valueFormatter?: (value: string | number, name: string) => string;\n};\n\n/**\n * Drop-in recharts `<Tooltip>` pre-wired to render {@link ChartTooltipContent}.\n * Each chart mounts one by default; pass `showTooltip={false}` on the chart to omit.\n */\nexport const ChartTooltip = ({ valueFormatter, ...props }: ChartTooltipProps) => (\n <RechartsTooltip\n cursor={{ strokeWidth: 1 }}\n content={<ChartTooltipContent valueFormatter={valueFormatter} />}\n {...props}\n />\n);\n","/**\n * Apply a numeric `valueFormatter` safely. recharts hands axis ticks and\n * tooltip payload values as `string | number | null | undefined`, and partial\n * or streaming data can carry gaps. Coercing those straight through\n * `Number(value)` would render `$0` (empty string → 0) or `$NaN` (non-numeric),\n * so a missing / non-finite value is rendered as an empty string instead of\n * being fed to the formatter.\n */\nexport const formatValue = (\n value: string | number | null | undefined,\n valueFormatter?: (value: number) => string,\n): string => {\n if (value == null || value === '') return '';\n const num = Number(value);\n if (!Number.isFinite(num)) return '';\n return valueFormatter ? valueFormatter(num) : String(num);\n};\n","import { CartesianGrid, Legend, XAxis, YAxis } from 'recharts';\n\nimport { ChartTooltip } from './ChartTooltip';\nimport { formatValue } from './format';\nimport { type CartesianChartProps } from './types';\n\nconst AXIS_PROPS = {\n tickLine: false,\n axisLine: false,\n tick: { fontSize: 11 },\n} as const;\n\n/**\n * The grid + axes + tooltip + legend shared by the line, bar, and area charts.\n * Colors are applied via `ChartContainer`'s CSS chrome, not inline props, so\n * these stay brand-safe.\n */\nexport const cartesianChrome = ({\n xKey,\n showGrid = true,\n showYAxis = true,\n showLegend = false,\n showTooltip = true,\n valueFormatter,\n}: Pick<\n CartesianChartProps,\n 'xKey' | 'showGrid' | 'showYAxis' | 'showLegend' | 'showTooltip' | 'valueFormatter'\n>) => (\n <>\n {showGrid && <CartesianGrid strokeDasharray=\"3 3\" vertical={false} />}\n <XAxis dataKey={xKey} {...AXIS_PROPS} />\n {showYAxis && (\n <YAxis\n width={48}\n {...AXIS_PROPS}\n tickFormatter={\n valueFormatter\n ? (value: string | number) => formatValue(value, valueFormatter)\n : undefined\n }\n />\n )}\n {showTooltip && (\n <ChartTooltip\n valueFormatter={valueFormatter ? (value) => formatValue(value, valueFormatter) : undefined}\n />\n )}\n {showLegend && <Legend wrapperStyle={{ fontSize: 11 }} />}\n </>\n);\n","/**\n * The design system ships a five-slot categorical chart palette as CSS\n * variables (`--color-chart-1` … `--color-chart-5`). Charts resolve their\n * series colors from these tokens only — never from inline hex or a primitive\n * scale — so they follow both the active color scheme (light/dark, via\n * `data-theme` in `styles.css`) and the active brand: a brand reskins charts\n * by defining `colors.chart` (and `colorsDark.chart`) in its\n * `@keboola/brand-registry` definition, which `ThemeProvider` emits as the\n * `--color-chart-*` variables.\n *\n * The CSS variables hold raw `R G B` channels (for Tailwind's `<alpha-value>`\n * opacity modifiers), so they are wrapped in `rgb(...)` before handing them to\n * recharts as ordinary SVG `stroke` / `fill` strings.\n */\nconst CHART_TOKEN_COUNT = 5;\n\n/** Number of the semantic chart token (`1`–`5`) a series maps to. */\nexport type ChartColorToken = 1 | 2 | 3 | 4 | 5;\n\n/**\n * The CSS color for a chart token. `index` is 0-based (series position); it\n * wraps around the five-slot palette so any number of series stays on-brand.\n */\nexport const chartTokenColor = (index: number): string => {\n // Euclidean modulo so negative indices still land in 1..CHART_TOKEN_COUNT\n // (plain `%` would yield e.g. `--color-chart-0` for index -1).\n const slot = (((index % CHART_TOKEN_COUNT) + CHART_TOKEN_COUNT) % CHART_TOKEN_COUNT) + 1;\n return `rgb(var(--color-chart-${slot}))`;\n};\n\n/** Resolve an explicit token (1–5) or fall back to the series position. */\nexport const resolveSeriesColor = (index: number, token?: ChartColorToken): string =>\n chartTokenColor(token ? token - 1 : index);\n","import { Line, LineChart as RechartsLineChart } from 'recharts';\n\nimport { cartesianChrome } from './cartesian';\nimport { ChartContainer } from './ChartContainer';\nimport { resolveSeriesColor } from './theme';\nimport { type CartesianChartProps } from './types';\n\n/**\n * A themed multi-series line chart. Each series' color comes from the semantic\n * `--color-chart-*` palette (by order, or pinned via `series[].color`), which\n * follows the active color scheme and the active brand's `colors.chart` when it\n * defines one. Wrap-free — mounts its own {@link ChartContainer}.\n *\n * @example\n * <LineChart\n * data={data}\n * xKey=\"month\"\n * series={[{ dataKey: 'revenue', name: 'Revenue' }, { dataKey: 'cost' }]}\n * />\n */\nexport const LineChart = ({\n data,\n xKey,\n series,\n height,\n width,\n className,\n ...chrome\n}: CartesianChartProps) => (\n <ChartContainer height={height} width={width} className={className}>\n <RechartsLineChart data={data} margin={{ top: 8, right: 8, left: 0, bottom: 0 }}>\n {cartesianChrome({ xKey, ...chrome })}\n {series.map((s, index) => {\n const color = resolveSeriesColor(index, s.color);\n return (\n <Line\n key={s.dataKey}\n type=\"monotone\"\n dataKey={s.dataKey}\n name={s.name ?? s.dataKey}\n stroke={color}\n strokeWidth={2}\n dot={{ r: 3, fill: color, stroke: color }}\n activeDot={{ r: 4 }}\n isAnimationActive={false}\n />\n );\n })}\n </RechartsLineChart>\n </ChartContainer>\n);\n","import { Bar, BarChart as RechartsBarChart } from 'recharts';\n\nimport { cartesianChrome } from './cartesian';\nimport { ChartContainer } from './ChartContainer';\nimport { resolveSeriesColor } from './theme';\nimport { type CartesianChartProps } from './types';\n\nexport type BarChartProps = CartesianChartProps & {\n /** Stack the series into a single bar per category. Defaults to grouped. */\n stacked?: boolean;\n};\n\n/**\n * A themed multi-series bar chart. Series colors come from the semantic\n * `--color-chart-*` palette (by order, or pinned via `series[].color`), which\n * follows the active color scheme and the active brand's `colors.chart` when it\n * defines one. Pass `stacked` to stack the series instead of grouping them.\n *\n * @example\n * <BarChart data={data} xKey=\"month\" series={[{ dataKey: 'revenue' }]} />\n */\nexport const BarChart = ({\n data,\n xKey,\n series,\n height,\n width,\n className,\n stacked = false,\n ...chrome\n}: BarChartProps) => (\n <ChartContainer height={height} width={width} className={className}>\n <RechartsBarChart data={data} margin={{ top: 8, right: 8, left: 0, bottom: 0 }}>\n {cartesianChrome({ xKey, ...chrome })}\n {series.map((s, index) => (\n <Bar\n key={s.dataKey}\n dataKey={s.dataKey}\n name={s.name ?? s.dataKey}\n fill={resolveSeriesColor(index, s.color)}\n radius={stacked ? 0 : [4, 4, 0, 0]}\n stackId={stacked ? 'stack' : undefined}\n isAnimationActive={false}\n />\n ))}\n </RechartsBarChart>\n </ChartContainer>\n);\n","import { Area, AreaChart as RechartsAreaChart } from 'recharts';\n\nimport { cartesianChrome } from './cartesian';\nimport { ChartContainer } from './ChartContainer';\nimport { resolveSeriesColor } from './theme';\nimport { type CartesianChartProps } from './types';\n\nexport type AreaChartProps = CartesianChartProps & {\n /** Stack the series into a cumulative area. Defaults to overlaid. */\n stacked?: boolean;\n};\n\n/**\n * A themed multi-series area chart. Each series is stroked and softly filled\n * from the semantic `--color-chart-*` palette (by order, or pinned via\n * `series[].color`), which follows the active color scheme and the active\n * brand's `colors.chart` when it defines one. Pass `stacked` to stack the\n * series cumulatively.\n *\n * @example\n * <AreaChart data={data} xKey=\"month\" series={[{ dataKey: 'revenue' }]} />\n */\nexport const AreaChart = ({\n data,\n xKey,\n series,\n height,\n width,\n className,\n stacked = false,\n ...chrome\n}: AreaChartProps) => (\n <ChartContainer height={height} width={width} className={className}>\n <RechartsAreaChart data={data} margin={{ top: 8, right: 8, left: 0, bottom: 0 }}>\n {cartesianChrome({ xKey, ...chrome })}\n {series.map((s, index) => {\n const color = resolveSeriesColor(index, s.color);\n return (\n <Area\n key={s.dataKey}\n type=\"monotone\"\n dataKey={s.dataKey}\n name={s.name ?? s.dataKey}\n stroke={color}\n fill={color}\n fillOpacity={0.15}\n strokeWidth={2}\n stackId={stacked ? 'stack' : undefined}\n isAnimationActive={false}\n />\n );\n })}\n </RechartsAreaChart>\n </ChartContainer>\n);\n","import { Cell, Legend, Pie, PieChart as RechartsPieChart } from 'recharts';\n\nimport { ChartContainer, type ChartDimension } from './ChartContainer';\nimport { ChartTooltip } from './ChartTooltip';\nimport { formatValue } from './format';\nimport { chartTokenColor } from './theme';\nimport { type ChartDatum } from './types';\n\nexport type PieChartProps = {\n /** The rows to plot — one sector per row. */\n data: ChartDatum[];\n /** Key into each datum for the sector label. */\n nameKey: string;\n /** Key into each datum for the sector value. */\n dataKey: string;\n /** Render as a donut with a hole of this inner radius (px or %). */\n innerRadius?: ChartDimension;\n /** Height as a px number or percentage. Defaults to 300. */\n height?: ChartDimension;\n /** Width as a px number or percentage. Defaults to `\"100%\"`. */\n width?: ChartDimension;\n /** Show a legend below the chart. Defaults to `true`. */\n showLegend?: boolean;\n /** Show the hover tooltip. Defaults to `true`. */\n showTooltip?: boolean;\n /** Format a sector value for the tooltip. */\n valueFormatter?: (value: number) => string;\n className?: string;\n};\n\n/**\n * A themed pie / donut chart. Each sector cycles through the semantic\n * `--color-chart-*` palette, which follows the active color scheme and the\n * active brand's `colors.chart` when it defines one. Pass `innerRadius` to make\n * a donut.\n *\n * @example\n * <PieChart data={data} nameKey=\"engine\" dataKey=\"rows\" innerRadius=\"60%\" />\n */\nexport const PieChart = ({\n data,\n nameKey,\n dataKey,\n innerRadius = 0,\n height,\n width,\n className,\n showLegend = true,\n showTooltip = true,\n valueFormatter,\n}: PieChartProps) => (\n <ChartContainer height={height} width={width} className={className}>\n <RechartsPieChart>\n {showTooltip && (\n <ChartTooltip\n valueFormatter={\n valueFormatter ? (value) => formatValue(value, valueFormatter) : undefined\n }\n />\n )}\n {showLegend && <Legend wrapperStyle={{ fontSize: 11 }} />}\n <Pie\n data={data}\n nameKey={nameKey}\n dataKey={dataKey}\n innerRadius={innerRadius}\n // Separate sectors with the brand surface color rather than recharts'\n // hardcoded white default.\n stroke=\"rgb(var(--color-background))\"\n isAnimationActive={false}\n >\n {data.map((datum, index) => (\n <Cell key={String(datum[nameKey] ?? index)} fill={chartTokenColor(index)} />\n ))}\n </Pie>\n </RechartsPieChart>\n </ChartContainer>\n);\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/classNames.ts","../src/blocks/Charts/ChartContainer.tsx","../src/blocks/Charts/ChartTooltip.tsx","../src/blocks/Charts/format.ts","../src/blocks/Charts/cartesian.tsx","../src/blocks/Charts/theme.ts","../src/blocks/Charts/LineChart.tsx","../src/blocks/Charts/BarChart.tsx","../src/blocks/Charts/AreaChart.tsx","../src/blocks/Charts/PieChart.tsx"],"names":["jsx","RechartsTooltip","jsxs","RechartsLineChart","RechartsBarChart","RechartsAreaChart","RechartsPieChart","Legend"],"mappings":";;;;;;AAKA,IAAM,UAAU,mBAAA,CAAoB;AAAA,EAClC,MAAA,EAAQ;AACV,CAAC,CAAA;AAEM,IAAM,KAAK,CAAA,GAAI,OAAA,KAA0B,QAAQ,IAAA,CAAK,GAAG,OAAO,CAAC,CAAA;ACkBjE,IAAM,iBAAiB,CAAC;AAAA,EAC7B,MAAA,GAAS,GAAA;AAAA,EACT,KAAA,GAAQ,MAAA;AAAA,EACR,SAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAG;AACL,CAAA,qBACE,GAAA;AAAA,EAAC,KAAA;AAAA,EAAA;AAAA,IACC,SAAA,EAAW,EAAA;AAAA,MACT,YAAA;AAAA;AAAA,MAEA,iEAAA;AAAA,MACA,mEAAA;AAAA,MACA,8CAAA;AAAA,MACA,0DAAA;AAAA;AAAA,MAEA,uDAAA;AAAA,MACA,oDAAA;AAAA,MACA,yDAAA;AAAA,MACA,8DAAA;AAAA,MACA,kEAAA;AAAA,MACA,yCAAA;AAAA,MACA;AAAA,KACF;AAAA,IACC,GAAG,KAAA;A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AAA;AAAA,IAAC,YAAA;AAAA,IAAA;AAAA,MACC,gBACE,cAAA,GAAiB,CAAC,UAAU,WAAA,CAAY,KAAA,EAAO,cAAc,CAAA,GAAI;AAAA;AAAA,GAErE;AAAA,EAED,UAAA,oBAAcA,GAAAA,CAACO,MAAAA,EAAA,EAAO,YAAA,EAAc,EAAE,QAAA,EAAU,EAAA,EAAG,EAAG,CAAA;AAAA,kBACvDP,GAAAA;AAAA,IAAC,GAAA;AAAA,IAAA;AAAA,MACC,IAAA;AAAA,MACA,OAAA;AAAA,MACA,OAAA;AAAA,MACA,WAAA;AAAA,MAGA,MAAA,EAAO,wBAAA;AAAA,MACP,iBAAA,EAAmB,KAAA;AAAA,MAElB,eAAK,GAAA,CAAI,CAAC,OAAO,KAAA,qBAChBA,IAAC,IAAA,EAAA,EAA2C,IAAA,EAAM,eAAA,CAAgB,KAAK,KAA5D,MAAA,CAAO,KAAA,CAAM,OAAO,CAAA,IAAK,KAAK,CAAiC,CAC3E;AAAA;AAAA;AACH,CAAA,EACF,CAAA,EACF","file":"charts.js","sourcesContent":["import { type ClassValue, clsx } from 'clsx';\nimport { extendTailwindMerge } from 'tailwind-merge';\n\n// tailwind-merge v3 (Tailwind v4): the prefix drops the trailing separator —\n// `tw:` → `tw` (the `:` separator is implied).\nconst twMerge = extendTailwindMerge({\n prefix: 'tw',\n});\n\nexport const cn = (...classes: ClassValue[]) => twMerge(clsx(...classes));\n","import { type ComponentProps, type ReactElement } from 'react';\nimport { ResponsiveContainer } from 'recharts';\n\nimport { cn } from '../../utils';\n\n/** A length that recharts' `<ResponsiveContainer>` accepts: px number or `\"NN%\"`. */\nexport type ChartDimension = number | `${number}%`;\n\nexport type ChartContainerProps = Omit<ComponentProps<'div'>, 'children'> & {\n /**\n * Height as a px number or percentage string. Charts have no intrinsic\n * height, so a container needs one either here or from a sized ancestor.\n * Defaults to 300.\n */\n height?: ChartDimension;\n /** Width as a px number or percentage. Defaults to `\"100%\"` (fills parent). */\n width?: ChartDimension;\n /** A single recharts chart element (`<LineChart>`, `<BarChart>`, …). */\n children: ReactElement;\n};\n\n/**\n * Responsive, brand-themed frame for a chart. Wraps the chart in recharts'\n * `<ResponsiveContainer>` and applies the semantic-token chrome (axis text,\n * grid, cursor) through CSS so every chart inside inherits it. Sizing is\n * intrinsic: give it a `height` (default 300) and it fills the parent width.\n */\nexport const ChartContainer = ({\n height = 300,\n width = '100%',\n className,\n children,\n ...props\n}: ChartContainerProps) => (\n <div\n className={cn(\n 'tw:text-xs',\n // Axis ticks and labels follow the muted foreground token.\n 'tw:[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground',\n 'tw:[&_.recharts-polar-angle-axis-tick_text]:fill-muted-foreground',\n 'tw:[&_.recharts-label]:fill-muted-foreground',\n 'tw:[&_.recharts-legend-item-text]:!text-muted-foreground',\n // Grid lines, axis lines and the hover cursor follow the border token.\n 'tw:[&_.recharts-cartesian-grid_line]:stroke-border/60',\n 'tw:[&_.recharts-cartesian-axis-line]:stroke-border',\n 'tw:[&_.recharts-cartesian-axis-tick-line]:stroke-border',\n 'tw:[&_.recharts-curve.recharts-tooltip-cursor]:stroke-border',\n 'tw:[&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted/60',\n 'tw:[&_.recharts-surface]:outline-hidden',\n className,\n )}\n {...props}\n >\n <ResponsiveContainer width={width} height={height}>\n {children}\n </ResponsiveContainer>\n </div>\n);\n","import { type ComponentProps } from 'react';\nimport { Tooltip as RechartsTooltip } from 'recharts';\n\nimport { cn } from '../../utils';\n\ntype TooltipPayloadEntry = {\n name?: string | number;\n value?: string | number;\n color?: string;\n dataKey?: string | number;\n};\n\ntype ChartTooltipContentProps = {\n active?: boolean;\n label?: string | number;\n payload?: TooltipPayloadEntry[];\n /** Format a value for display (e.g. currency, percentage). */\n valueFormatter?: (value: string | number, name: string) => string;\n className?: string;\n};\n\n/**\n * Brand-themed tooltip body. Surfaces (background, border, text) resolve from\n * semantic tokens, and each series swatch reuses the recharts-provided series\n * `color` (already a `--chart-*` token from this package's charts).\n */\nexport const ChartTooltipContent = ({\n active,\n label,\n payload,\n valueFormatter,\n className,\n}: ChartTooltipContentProps) => {\n if (!active || !payload?.length) return null;\n\n return (\n <div\n className={cn(\n 'tw:min-w-32 tw:rounded-md tw:border tw:border-border tw:bg-popover tw:px-2.5 tw:py-1.5 tw:text-xs tw:text-popover-foreground tw:shadow-md',\n className,\n )}\n >\n {label != null && <div className=\"tw:mb-1 tw:font-medium\">{label}</div>}\n <div className=\"tw:flex tw:flex-col tw:gap-1\">\n {payload.map((entry) => {\n const name = String(entry.name ?? entry.dataKey ?? '');\n const value = entry.value;\n // Missing / non-numeric values render blank rather than \"NaN\"/\"0\";\n // only well-formed numbers reach the formatter.\n const hasNumber = value != null && value !== '' && Number.isFinite(Number(value));\n const display = hasNumber\n ? valueFormatter\n ? valueFormatter(Number(value), name)\n : String(Number(value))\n : (value ?? '');\n return (\n <div\n key={String(entry.dataKey ?? name)}\n className=\"tw:flex tw:items-center tw:justify-between tw:gap-3\"\n >\n <span className=\"tw:flex tw:items-center tw:gap-1.5\">\n <span\n className=\"tw:size-2 tw:shrink-0 tw:rounded-[2px]\"\n style={{ backgroundColor: entry.color }}\n />\n <span className=\"tw:text-muted-foreground\">{name}</span>\n </span>\n <span className=\"tw:font-medium tw:tabular-nums\">{display}</span>\n </div>\n );\n })}\n </div>\n </div>\n );\n};\n\nexport type ChartTooltipProps = ComponentProps<typeof RechartsTooltip> & {\n valueFormatter?: (value: string | number, name: string) => string;\n};\n\n/**\n * Drop-in recharts `<Tooltip>` pre-wired to render {@link ChartTooltipContent}.\n * Each chart mounts one by default; pass `showTooltip={false}` on the chart to omit.\n */\nexport const ChartTooltip = ({ valueFormatter, ...props }: ChartTooltipProps) => (\n <RechartsTooltip\n cursor={{ strokeWidth: 1 }}\n content={<ChartTooltipContent valueFormatter={valueFormatter} />}\n {...props}\n />\n);\n","/**\n * Apply a numeric `valueFormatter` safely. recharts hands axis ticks and\n * tooltip payload values as `string | number | null | undefined`, and partial\n * or streaming data can carry gaps. Coercing those straight through\n * `Number(value)` would render `$0` (empty string → 0) or `$NaN` (non-numeric),\n * so a missing / non-finite value is rendered as an empty string instead of\n * being fed to the formatter.\n */\nexport const formatValue = (\n value: string | number | null | undefined,\n valueFormatter?: (value: number) => string,\n): string => {\n if (value == null || value === '') return '';\n const num = Number(value);\n if (!Number.isFinite(num)) return '';\n return valueFormatter ? valueFormatter(num) : String(num);\n};\n","import { CartesianGrid, Legend, XAxis, YAxis } from 'recharts';\n\nimport { ChartTooltip } from './ChartTooltip';\nimport { formatValue } from './format';\nimport { type CartesianChartProps } from './types';\n\nconst AXIS_PROPS = {\n tickLine: false,\n axisLine: false,\n tick: { fontSize: 11 },\n} as const;\n\n/**\n * The grid + axes + tooltip + legend shared by the line, bar, and area charts.\n * Colors are applied via `ChartContainer`'s CSS chrome, not inline props, so\n * these stay brand-safe.\n */\nexport const cartesianChrome = ({\n xKey,\n showGrid = true,\n showYAxis = true,\n showLegend = false,\n showTooltip = true,\n valueFormatter,\n}: Pick<\n CartesianChartProps,\n 'xKey' | 'showGrid' | 'showYAxis' | 'showLegend' | 'showTooltip' | 'valueFormatter'\n>) => (\n <>\n {showGrid && <CartesianGrid strokeDasharray=\"3 3\" vertical={false} />}\n <XAxis dataKey={xKey} {...AXIS_PROPS} />\n {showYAxis && (\n <YAxis\n width={48}\n {...AXIS_PROPS}\n tickFormatter={\n valueFormatter\n ? (value: string | number) => formatValue(value, valueFormatter)\n : undefined\n }\n />\n )}\n {showTooltip && (\n <ChartTooltip\n valueFormatter={valueFormatter ? (value) => formatValue(value, valueFormatter) : undefined}\n />\n )}\n {showLegend && <Legend wrapperStyle={{ fontSize: 11 }} />}\n </>\n);\n","/**\n * The design system ships a five-slot categorical chart palette as CSS\n * variables (`--chart-1` … `--chart-5`). Charts resolve their\n * series colors from these tokens only — never from inline hex or a primitive\n * scale — so they follow both the active color scheme (light/dark, via\n * `data-theme` in `styles.css`) and the active brand: a brand reskins charts\n * by defining `colors.chart` (and `colorsDark.chart`) in its\n * `@keboola/brand-registry` definition, which `ThemeProvider` emits as the\n * `--chart-*` variables.\n *\n * The CSS variables hold raw `R G B` channels (for Tailwind's `<alpha-value>`\n * opacity modifiers), so they are wrapped in `rgb(...)` before handing them to\n * recharts as ordinary SVG `stroke` / `fill` strings.\n */\nconst CHART_TOKEN_COUNT = 5;\n\n/** Number of the semantic chart token (`1`–`5`) a series maps to. */\nexport type ChartColorToken = 1 | 2 | 3 | 4 | 5;\n\n/**\n * The CSS color for a chart token. `index` is 0-based (series position); it\n * wraps around the five-slot palette so any number of series stays on-brand.\n */\nexport const chartTokenColor = (index: number): string => {\n // Euclidean modulo so negative indices still land in 1..CHART_TOKEN_COUNT\n // (plain `%` would yield e.g. `--chart-0` for index -1).\n const slot = (((index % CHART_TOKEN_COUNT) + CHART_TOKEN_COUNT) % CHART_TOKEN_COUNT) + 1;\n return `rgb(var(--chart-${slot}))`;\n};\n\n/** Resolve an explicit token (1–5) or fall back to the series position. */\nexport const resolveSeriesColor = (index: number, token?: ChartColorToken): string =>\n chartTokenColor(token ? token - 1 : index);\n","import { Line, LineChart as RechartsLineChart } from 'recharts';\n\nimport { cartesianChrome } from './cartesian';\nimport { ChartContainer } from './ChartContainer';\nimport { resolveSeriesColor } from './theme';\nimport { type CartesianChartProps } from './types';\n\n/**\n * A themed multi-series line chart. Each series' color comes from the semantic\n * `--chart-*` palette (by order, or pinned via `series[].color`), which\n * follows the active color scheme and the active brand's `colors.chart` when it\n * defines one. Wrap-free — mounts its own {@link ChartContainer}.\n *\n * @example\n * <LineChart\n * data={data}\n * xKey=\"month\"\n * series={[{ dataKey: 'revenue', name: 'Revenue' }, { dataKey: 'cost' }]}\n * />\n */\nexport const LineChart = ({\n data,\n xKey,\n series,\n height,\n width,\n className,\n ...chrome\n}: CartesianChartProps) => (\n <ChartContainer height={height} width={width} className={className}>\n <RechartsLineChart data={data} margin={{ top: 8, right: 8, left: 0, bottom: 0 }}>\n {cartesianChrome({ xKey, ...chrome })}\n {series.map((s, index) => {\n const color = resolveSeriesColor(index, s.color);\n return (\n <Line\n key={s.dataKey}\n type=\"monotone\"\n dataKey={s.dataKey}\n name={s.name ?? s.dataKey}\n stroke={color}\n strokeWidth={2}\n dot={{ r: 3, fill: color, stroke: color }}\n activeDot={{ r: 4 }}\n isAnimationActive={false}\n />\n );\n })}\n </RechartsLineChart>\n </ChartContainer>\n);\n","import { Bar, BarChart as RechartsBarChart } from 'recharts';\n\nimport { cartesianChrome } from './cartesian';\nimport { ChartContainer } from './ChartContainer';\nimport { resolveSeriesColor } from './theme';\nimport { type CartesianChartProps } from './types';\n\nexport type BarChartProps = CartesianChartProps & {\n /** Stack the series into a single bar per category. Defaults to grouped. */\n stacked?: boolean;\n};\n\n/**\n * A themed multi-series bar chart. Series colors come from the semantic\n * `--chart-*` palette (by order, or pinned via `series[].color`), which\n * follows the active color scheme and the active brand's `colors.chart` when it\n * defines one. Pass `stacked` to stack the series instead of grouping them.\n *\n * @example\n * <BarChart data={data} xKey=\"month\" series={[{ dataKey: 'revenue' }]} />\n */\nexport const BarChart = ({\n data,\n xKey,\n series,\n height,\n width,\n className,\n stacked = false,\n ...chrome\n}: BarChartProps) => (\n <ChartContainer height={height} width={width} className={className}>\n <RechartsBarChart data={data} margin={{ top: 8, right: 8, left: 0, bottom: 0 }}>\n {cartesianChrome({ xKey, ...chrome })}\n {series.map((s, index) => (\n <Bar\n key={s.dataKey}\n dataKey={s.dataKey}\n name={s.name ?? s.dataKey}\n fill={resolveSeriesColor(index, s.color)}\n radius={stacked ? 0 : [4, 4, 0, 0]}\n stackId={stacked ? 'stack' : undefined}\n isAnimationActive={false}\n />\n ))}\n </RechartsBarChart>\n </ChartContainer>\n);\n","import { Area, AreaChart as RechartsAreaChart } from 'recharts';\n\nimport { cartesianChrome } from './cartesian';\nimport { ChartContainer } from './ChartContainer';\nimport { resolveSeriesColor } from './theme';\nimport { type CartesianChartProps } from './types';\n\nexport type AreaChartProps = CartesianChartProps & {\n /** Stack the series into a cumulative area. Defaults to overlaid. */\n stacked?: boolean;\n};\n\n/**\n * A themed multi-series area chart. Each series is stroked and softly filled\n * from the semantic `--chart-*` palette (by order, or pinned via\n * `series[].color`), which follows the active color scheme and the active\n * brand's `colors.chart` when it defines one. Pass `stacked` to stack the\n * series cumulatively.\n *\n * @example\n * <AreaChart data={data} xKey=\"month\" series={[{ dataKey: 'revenue' }]} />\n */\nexport const AreaChart = ({\n data,\n xKey,\n series,\n height,\n width,\n className,\n stacked = false,\n ...chrome\n}: AreaChartProps) => (\n <ChartContainer height={height} width={width} className={className}>\n <RechartsAreaChart data={data} margin={{ top: 8, right: 8, left: 0, bottom: 0 }}>\n {cartesianChrome({ xKey, ...chrome })}\n {series.map((s, index) => {\n const color = resolveSeriesColor(index, s.color);\n return (\n <Area\n key={s.dataKey}\n type=\"monotone\"\n dataKey={s.dataKey}\n name={s.name ?? s.dataKey}\n stroke={color}\n fill={color}\n fillOpacity={0.15}\n strokeWidth={2}\n stackId={stacked ? 'stack' : undefined}\n isAnimationActive={false}\n />\n );\n })}\n </RechartsAreaChart>\n </ChartContainer>\n);\n","import { Cell, Legend, Pie, PieChart as RechartsPieChart } from 'recharts';\n\nimport { ChartContainer, type ChartDimension } from './ChartContainer';\nimport { ChartTooltip } from './ChartTooltip';\nimport { formatValue } from './format';\nimport { chartTokenColor } from './theme';\nimport { type ChartDatum } from './types';\n\nexport type PieChartProps = {\n /** The rows to plot — one sector per row. */\n data: ChartDatum[];\n /** Key into each datum for the sector label. */\n nameKey: string;\n /** Key into each datum for the sector value. */\n dataKey: string;\n /** Render as a donut with a hole of this inner radius (px or %). */\n innerRadius?: ChartDimension;\n /** Height as a px number or percentage. Defaults to 300. */\n height?: ChartDimension;\n /** Width as a px number or percentage. Defaults to `\"100%\"`. */\n width?: ChartDimension;\n /** Show a legend below the chart. Defaults to `true`. */\n showLegend?: boolean;\n /** Show the hover tooltip. Defaults to `true`. */\n showTooltip?: boolean;\n /** Format a sector value for the tooltip. */\n valueFormatter?: (value: number) => string;\n className?: string;\n};\n\n/**\n * A themed pie / donut chart. Each sector cycles through the semantic\n * `--chart-*` palette, which follows the active color scheme and the\n * active brand's `colors.chart` when it defines one. Pass `innerRadius` to make\n * a donut.\n *\n * @example\n * <PieChart data={data} nameKey=\"engine\" dataKey=\"rows\" innerRadius=\"60%\" />\n */\nexport const PieChart = ({\n data,\n nameKey,\n dataKey,\n innerRadius = 0,\n height,\n width,\n className,\n showLegend = true,\n showTooltip = true,\n valueFormatter,\n}: PieChartProps) => (\n <ChartContainer height={height} width={width} className={className}>\n <RechartsPieChart>\n {showTooltip && (\n <ChartTooltip\n valueFormatter={\n valueFormatter ? (value) => formatValue(value, valueFormatter) : undefined\n }\n />\n )}\n {showLegend && <Legend wrapperStyle={{ fontSize: 11 }} />}\n <Pie\n data={data}\n nameKey={nameKey}\n dataKey={dataKey}\n innerRadius={innerRadius}\n // Separate sectors with the brand surface color rather than recharts'\n // hardcoded white default.\n stroke=\"rgb(var(--background))\"\n isAnimationActive={false}\n >\n {data.map((datum, index) => (\n <Cell key={String(datum[nameKey] ?? index)} fill={chartTokenColor(index)} />\n ))}\n </Pie>\n </RechartsPieChart>\n </ChartContainer>\n);\n"]}
|