Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions public/llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2675,6 +2675,8 @@ Extends all native `RadioHTMLAttributes` (except `type`), plus these specialties
);
};



A selectable option card group for single-choice selections such as style presets, plans, providers, or configuration modes.

### Import
Expand All @@ -2695,6 +2697,8 @@ bunx carllosnc/dashkit add radio-card

Use `RadioCardGroup` with `label` and `valueLabel` to display the group title and active selection summary above a stack of option cards.



```tsx
const [preset, setPreset] = useState('default');

Expand Down Expand Up @@ -2729,6 +2733,8 @@ const [preset, setPreset] = useState('default');

Combine `columns` (`1 | 2 | 3 | 4`), `indicator` (`'none' | 'radio' | 'check'`), and `trailing` slots for multi-column plan or provider pickers.



```tsx
<RadioCardGroup label="Billing Plan" columns={3} indicator="check" defaultValue="pro">
<RadioCard
Expand Down Expand Up @@ -2756,6 +2762,8 @@ Combine `columns` (`1 | 2 | 3 | 4`), `indicator` (`'none' | 'radio' | 'check'`),

Use `indicator="radio"` when you want a traditional radio circle inside each card, and `size` (`'sm' | 'md' | 'lg'`) to adjust density.



### Accessibility

- Uses `role="radiogroup"` on `RadioCardGroup` and `role="radio"` with `aria-checked` on each `RadioCard`.
Expand Down
20 changes: 11 additions & 9 deletions public/registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@
"registryDependencies": [],
"exports": [
"AreaChart",
"buildAreaLinePath",
"useAreaChart"
],
"propsDefinitions": [
"export interface AreaChartProps extends React.ComponentPropsWithoutRef<'div'> {\r\n data: Record<string, string | number>[];\r\n series: AreaChartSeries[];\r\n /** @default '100%' */\r\n height?: number | string;\r\n /** @default true */\r\n showGrid?: boolean;\r\n /** @default true */\r\n showLabels?: boolean;\r\n /** @default true */\r\n showTooltip?: boolean;\r\n /** @default true */\r\n animate?: boolean;\r\n}\r\n\r\n/**\r\n * Prop-driven (`data`, `series`) responsive SVG area chart with grid, labels, and interactive tooltips.\r\n *\r\n * @example\r\n * ```tsx\r\n * <AreaChart\r\n * data={[{ month: 'Jan', revenue: 4200 }, { month: 'Feb', revenue: 5100 }]}\r\n * series={[{ key: 'revenue', label: 'Revenue' }]}\r\n * />\r\n * ```\r\n */",
"export interface UseAreaChartProps {\r\n data: Record<string, string | number>[];\r\n series: AreaChartSeries[];\r\n width?: number;\r\n svgHeight?: number;\r\n defaultColors?: string[];\r\n}"
"export interface AreaChartProps extends React.ComponentPropsWithoutRef<'div'> {\n data: Record<string, string | number>[];\n series: AreaChartSeries[];\n /** @default '100%' */\n height?: number | string;\n /** @default true */\n showGrid?: boolean;\n /** @default true */\n showLabels?: boolean;\n /** @default true */\n showTooltip?: boolean;\n /** @default true */\n animate?: boolean;\n /** @default 'linear' */\n curve?: 'linear' | 'smooth';\n /** @default true */\n showDots?: boolean | 'hover';\n /** @default false */\n showYAxis?: boolean;\n /** @default false */\n showLegend?: boolean;\n /** Key in `data` items used for x-axis and tooltip labels. @default 'label' */\n labelKey?: string;\n /** Custom formatter for Y-axis ticks and tooltip values. */\n valueFormatter?: (value: number) => string;\n /** Accessible label for the chart SVG. @default 'Area chart' */\n ariaLabel?: string;\n}\n\n/**\n * Prop-driven (`data`, `series`) responsive SVG area chart with grid, labels, and interactive tooltips.\n *\n * @example\n * ```tsx\n * <AreaChart\n * data={[{ label: 'Jan', revenue: 4200 }, { label: 'Feb', revenue: 5100 }]}\n * series={[{ key: 'revenue', label: 'Revenue' }]}\n * />\n * ```\n */",
"export interface UseAreaChartProps {\n data: Record<string, string | number>[];\n series: AreaChartSeries[];\n width?: number;\n svgHeight?: number;\n defaultColors?: string[];\n}"
]
},
"avatar": {
Expand Down Expand Up @@ -188,7 +189,7 @@
"useBarChart"
],
"propsDefinitions": [
"export interface BarChartProps extends ComponentPropsWithoutRef<'div'> {\r\n data: Record<string, string | number>[];\r\n series: BarChartSeries[];\r\n /** @default '100%' */\r\n height?: number | string;\r\n /** @default true */\r\n showGrid?: boolean;\r\n /** @default true */\r\n showLabels?: boolean;\r\n /** @default true */\r\n showTooltip?: boolean;\r\n /** @default true */\r\n animate?: boolean;\r\n /** @default 4 */\r\n barGap?: number;\r\n /** @default 64 */\r\n maxBarWidth?: number;\r\n /** @default true */\r\n rounded?: boolean;\r\n /** @default 'none' */\r\n texture?: BarChartTexture;\r\n /** @default false */\r\n showTrack?: boolean;\r\n}\r\n\r\n/**\r\n * Prop-driven (`data`, `series`) SVG bar chart supporting grouped/stacked bars and optional SVG textures.\r\n *\r\n * @example\r\n * ```tsx\r\n * <BarChart\r\n * data={[{ label: 'Q1', sales: 120 }, { label: 'Q2', sales: 180 }]}\r\n * series={[{ key: 'sales', label: 'Sales' }]}\r\n * />\r\n * ```\r\n */"
"export interface BarChartProps extends ComponentPropsWithoutRef<'div'> {\n data: Record<string, string | number>[];\n series: BarChartSeries[];\n /** @default '100%' */\n height?: number | string;\n /** @default true */\n showGrid?: boolean;\n /** @default true */\n showLabels?: boolean;\n /** @default true */\n showTooltip?: boolean;\n /** @default true */\n animate?: boolean;\n /** @default 4 */\n barGap?: number;\n /** @default 64 */\n maxBarWidth?: number;\n /** @default true */\n rounded?: boolean;\n /** @default 'none' */\n texture?: BarChartTexture;\n /** @default false */\n showTrack?: boolean;\n /** @default false */\n stacked?: boolean;\n /** @default false */\n showYAxis?: boolean;\n /** @default false */\n showLegend?: boolean;\n /** Key in `data` items used for x-axis and tooltip labels. @default 'label' */\n labelKey?: string;\n /** Custom formatter for Y-axis ticks and tooltip values. */\n valueFormatter?: (value: number) => string;\n /** Accessible label for the chart SVG. @default 'Bar chart' */\n ariaLabel?: string;\n}\n\n/**\n * Prop-driven (`data`, `series`) SVG bar chart supporting grouped/stacked bars and optional SVG textures.\n *\n * @example\n * ```tsx\n * <BarChart\n * data={[{ label: 'Q1', sales: 120 }, { label: 'Q2', sales: 180 }]}\n * series={[{ key: 'sales', label: 'Sales' }]}\n * />\n * ```\n */"
]
},
"bento-grid": {
Expand Down Expand Up @@ -860,11 +861,12 @@
"registryDependencies": [],
"exports": [
"LineChart",
"buildLineChartPath",
"useLineChart"
],
"propsDefinitions": [
"export interface LineChartProps extends React.ComponentPropsWithoutRef<'div'> {\r\n data: Record<string, string | number>[];\r\n series: LineChartSeries[];\r\n /** @default true */\r\n showGrid?: boolean;\r\n /** @default true */\r\n showLabels?: boolean;\r\n /** @default true */\r\n showTooltip?: boolean;\r\n /** @default true */\r\n animate?: boolean;\r\n}\r\n\r\n/**\r\n * Prop-driven (`data`, `series`) multi-series SVG line chart with interactive hover tooltips.\r\n *\r\n * @example\r\n * ```tsx\r\n * <LineChart\r\n * data={[{ day: 'Mon', visits: 320 }, { day: 'Tue', visits: 410 }]}\r\n * series={[{ key: 'visits', label: 'Visits' }]}\r\n * />\r\n * ```\r\n */",
"export interface UseLineChartProps {\n data: Record<string, string | number>[];\n series: LineChartSeries[];\n}"
"export interface LineChartProps extends React.ComponentPropsWithoutRef<'div'> {\n data: Record<string, string | number>[];\n series: LineChartSeries[];\n /** Optional explicit height. When omitted, defaults to a 2.5:1 aspect ratio. */\n height?: number | string;\n /** @default true */\n showGrid?: boolean;\n /** @default true */\n showLabels?: boolean;\n /** @default true */\n showTooltip?: boolean;\n /** @default true */\n animate?: boolean;\n /** @default 'linear' */\n curve?: 'linear' | 'smooth';\n /** @default true */\n showDots?: boolean | 'hover';\n /** @default false */\n showYAxis?: boolean;\n /** @default false */\n showLegend?: boolean;\n /** Key in `data` items used for x-axis and tooltip labels. @default 'label' */\n labelKey?: string;\n /** Custom formatter for Y-axis ticks and tooltip values. */\n valueFormatter?: (value: number) => string;\n /** Accessible label for the chart SVG. @default 'Line chart' */\n ariaLabel?: string;\n}\n\n/**\n * Prop-driven (`data`, `series`) multi-series SVG line chart with interactive hover tooltips.\n *\n * @example\n * ```tsx\n * <LineChart\n * data={[{ label: 'Mon', visits: 320 }, { label: 'Tue', visits: 410 }]}\n * series={[{ key: 'visits', label: 'Visits' }]}\n * />\n * ```\n */",
"export interface UseLineChartProps {\n data: Record<string, string | number>[];\n series: LineChartSeries[];\n width?: number;\n svgHeight?: number;\n}"
]
},
"listtile": {
Expand Down Expand Up @@ -1078,8 +1080,8 @@
"usePieChart"
],
"propsDefinitions": [
"export interface PieChartProps extends React.ComponentPropsWithoutRef<'div'> {\r\n data: PieChartDataItem[];\r\n /** @default 0 */\r\n innerRadius?: number;\r\n /** @default true */\r\n showLabels?: boolean;\r\n /** @default true */\r\n showTooltip?: boolean;\r\n /** @default true */\r\n animate?: boolean;\r\n /** @default 'none' */\r\n texture?: PieChartTexture;\r\n}\r\n\r\n/**\r\n * Prop-driven (`data`) SVG pie or donut chart with optional inner radius and tooltips.\r\n *\r\n * @example\r\n * ```tsx\r\n * <PieChart data={[{ name: 'Desktop', value: 65 }, { name: 'Mobile', value: 35 }]} />\r\n * ```\r\n */",
"export interface UsePieChartProps {\r\n data: PieChartDataItem[];\r\n innerRadius: number;\r\n showTooltip: boolean;\r\n}"
"export interface PieChartProps extends React.ComponentPropsWithoutRef<'div'> {\n data: PieChartDataItem[];\n /** @default 0 */\n innerRadius?: number;\n /** @default true */\n showLabels?: boolean;\n /** @default true */\n showTooltip?: boolean;\n /** @default true */\n animate?: boolean;\n /** @default 'none' */\n texture?: PieChartTexture;\n /** Custom formatter for tooltip values. */\n valueFormatter?: (value: number) => string;\n /** Accessible label for the chart SVG. @default 'Pie chart' */\n ariaLabel?: string;\n}\n\n/**\n * Prop-driven (`data`) SVG pie or donut chart with optional inner radius and tooltips.\n *\n * @example\n * ```tsx\n * <PieChart data={[{ label: 'Desktop', value: 65 }, { label: 'Mobile', value: 35 }]} />\n * ```\n */",
"export interface UsePieChartProps {\n data: PieChartDataItem[];\n innerRadius: number;\n showTooltip: boolean;\n}"
]
},
"popover": {
Expand Down Expand Up @@ -1190,8 +1192,8 @@
"RadioCard"
],
"propsDefinitions": [
"export interface RadioCardGroupProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'>,\n VariantProps<typeof radioCardGroupVariants> {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n name?: string;\n label?: React.ReactNode;\n valueLabel?: React.ReactNode;\n size?: RadioCardSize;\n indicator?: RadioCardIndicator;\n disabled?: boolean;\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * Accessible group container for `RadioCard` options with optional header label,\n * active value summary, keyboard arrow navigation, and responsive grid columns.\n *\n * @example\n * ```tsx\n * <RadioCardGroup label=\"Style Preset\" valueLabel=\"Default\" value={preset} onValueChange={setPreset}>\n * <RadioCard value=\"default\" title=\"Default\" description=\"Clean & balanced\" />\n * </RadioCardGroup>\n * ```\n */",
"export interface RadioCardProps\n extends Omit<HTMLMotionProps<'button'>, 'title' | 'value' | 'onSelect'> {\n value: string;\n title: React.ReactNode;\n description?: React.ReactNode;\n leading?: React.ReactNode;\n trailing?: React.ReactNode;\n size?: RadioCardSize;\n indicator?: RadioCardIndicator;\n disabled?: boolean;\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/**\n * Selectable option card for use inside `RadioCardGroup`.\n *\n * @example\n * ```tsx\n * <RadioCard\n * value=\"default\"\n * title=\"Default\"\n * description=\"Clean & balanced\"\n * leading={<span className=\"size-2.5 rounded-full bg-blue-600\" />}\n * />\n * ```\n */"
"export interface RadioCardGroupProps\r\n extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'>,\r\n VariantProps<typeof radioCardGroupVariants> {\r\n value?: string;\r\n defaultValue?: string;\r\n onValueChange?: (value: string) => void;\r\n name?: string;\r\n label?: React.ReactNode;\r\n valueLabel?: React.ReactNode;\r\n size?: RadioCardSize;\r\n indicator?: RadioCardIndicator;\r\n disabled?: boolean;\r\n ref?: React.Ref<HTMLDivElement>;\r\n}\r\n\r\n/**\r\n * Accessible group container for `RadioCard` options with optional header label,\r\n * active value summary, keyboard arrow navigation, and responsive grid columns.\r\n *\r\n * @example\r\n * ```tsx\r\n * <RadioCardGroup label=\"Style Preset\" valueLabel=\"Default\" value={preset} onValueChange={setPreset}>\r\n * <RadioCard value=\"default\" title=\"Default\" description=\"Clean & balanced\" />\r\n * </RadioCardGroup>\r\n * ```\r\n */",
"export interface RadioCardProps\r\n extends Omit<HTMLMotionProps<'button'>, 'title' | 'value' | 'onSelect'> {\r\n value: string;\r\n title: React.ReactNode;\r\n description?: React.ReactNode;\r\n leading?: React.ReactNode;\r\n trailing?: React.ReactNode;\r\n size?: RadioCardSize;\r\n indicator?: RadioCardIndicator;\r\n disabled?: boolean;\r\n ref?: React.Ref<HTMLButtonElement>;\r\n}\r\n\r\n/**\r\n * Selectable option card for use inside `RadioCardGroup`.\r\n *\r\n * @example\r\n * ```tsx\r\n * <RadioCard\r\n * value=\"default\"\r\n * title=\"Default\"\r\n * description=\"Clean & balanced\"\r\n * leading={<span className=\"size-2.5 rounded-full bg-blue-600\" />}\r\n * />\r\n * ```\r\n */"
]
},
"scrollarea": {
Expand Down
34 changes: 34 additions & 0 deletions src/dashkit/AreaChart/AreaChart.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,38 @@ describe('AreaChart', () => {
expect(linePath).toBeInTheDocument();
expect(linePath?.getAttribute('stroke-width')).toBe('3');
});

it('handles single data point and zero values without NaN coordinates', () => {
const { container } = render(
<AreaChart
data={[{ label: 'Only', value: 0 }]}
series={[{ key: 'value', label: 'Series' }]}
animate={false}
/>
);
const paths = container.querySelectorAll('path');
expect(paths.length).toBeGreaterThanOrEqual(2);
paths.forEach((p) => {
expect(p.getAttribute('d')).not.toContain('NaN');
});
});

it('supports smooth curves, Y-axis, legend, and custom labelKey', () => {
render(
<AreaChart
data={[{ month: 'Apr', value: 100 }, { month: 'May', value: 200 }, { month: 'Jun', value: 150 }]}
series={[{ key: 'value', label: 'Revenue' }]}
curve="smooth"
showYAxis
showLegend
showDots="hover"
labelKey="month"
valueFormatter={(v) => `$${v}`}
animate={false}
/>
);
expect(screen.getByText('Apr')).toBeInTheDocument();
expect(screen.getByText('Revenue')).toBeInTheDocument();
expect(screen.getByText('$0')).toBeInTheDocument();
});
});
Loading
Loading