canny-ui-react 6.7.0 → 7.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.
Files changed (74) hide show
  1. package/dist/components/Accordion/Accordion.d.ts +7 -0
  2. package/dist/components/Alert/Alert.types.d.ts +5 -0
  3. package/dist/components/Autocomplete/Autocomplete.types.d.ts +7 -1
  4. package/dist/components/Avatar/Avatar.d.ts +3 -1
  5. package/dist/components/Avatar/Avatar.types.d.ts +14 -0
  6. package/dist/components/Avatar/index.d.ts +2 -2
  7. package/dist/components/Breadcrumb/Breadcrumb.d.ts +6 -0
  8. package/dist/components/Charts/BarChart.d.ts +16 -2
  9. package/dist/components/Charts/ChartA11y.d.ts +3 -1
  10. package/dist/components/Charts/ChartParts.d.ts +19 -0
  11. package/dist/components/Charts/DonutChart.d.ts +15 -0
  12. package/dist/components/Charts/FunnelChart.d.ts +16 -0
  13. package/dist/components/Charts/GanttChart.d.ts +75 -0
  14. package/dist/components/Charts/GaugeChart.d.ts +25 -0
  15. package/dist/components/Charts/Heatmap.d.ts +37 -0
  16. package/dist/components/Charts/LineChart.d.ts +15 -1
  17. package/dist/components/Charts/PieChart.d.ts +25 -3
  18. package/dist/components/Charts/RadarChart.d.ts +25 -0
  19. package/dist/components/Charts/ScatterChart.d.ts +33 -0
  20. package/dist/components/Charts/Sparkline.d.ts +17 -0
  21. package/dist/components/Charts/StatCard.d.ts +23 -0
  22. package/dist/components/Charts/cartesian.d.ts +23 -0
  23. package/dist/components/Charts/chartExtra.d.ts +90 -0
  24. package/dist/components/Charts/chartScale.d.ts +94 -0
  25. package/dist/components/Charts/chartUtils.d.ts +6 -0
  26. package/dist/components/Charts/gantt/ganttUtils.d.ts +54 -0
  27. package/dist/components/Charts/index.d.ts +18 -0
  28. package/dist/components/Chip/Chip.d.ts +4 -1
  29. package/dist/components/CommandPalette/CommandPalette.d.ts +1 -1
  30. package/dist/components/CommandPalette/CommandPalette.types.d.ts +18 -1
  31. package/dist/components/ConfirmDialog/ConfirmDialog.d.ts +6 -1
  32. package/dist/components/ContextMenu/ContextMenu.d.ts +7 -2
  33. package/dist/components/DataTable/DataTable.d.ts +55 -0
  34. package/dist/components/DatePicker/DatePicker.types.d.ts +10 -0
  35. package/dist/components/DatePicker/dateUtils.d.ts +2 -0
  36. package/dist/components/DatePicker/index.d.ts +1 -1
  37. package/dist/components/Dialog/Dialog.d.ts +6 -0
  38. package/dist/components/Drawer/Drawer.d.ts +8 -0
  39. package/dist/components/FileUploader/FileUploader.d.ts +24 -0
  40. package/dist/components/FileUploader/index.d.ts +1 -1
  41. package/dist/components/FileUploader/useFileDrop.d.ts +1 -0
  42. package/dist/components/Input/Input.types.d.ts +2 -0
  43. package/dist/components/List/List.d.ts +17 -0
  44. package/dist/components/MultiSelect/MultiSelect.d.ts +10 -2
  45. package/dist/components/Navbar/Navbar.types.d.ts +12 -0
  46. package/dist/components/Pagination/Pagination.d.ts +34 -0
  47. package/dist/components/PanelGroup/PanelGroup.d.ts +1 -1
  48. package/dist/components/Popover/Popover.d.ts +11 -2
  49. package/dist/components/Progress/Progress.types.d.ts +5 -0
  50. package/dist/components/Scroll/Scroll.types.d.ts +0 -4
  51. package/dist/components/Scroll/index.d.ts +1 -1
  52. package/dist/components/Scroll/useScrollFocusable.d.ts +10 -0
  53. package/dist/components/Select/Select.d.ts +7 -1
  54. package/dist/components/Sidebar/Sidebar.types.d.ts +10 -0
  55. package/dist/components/Skeleton/Skeleton.types.d.ts +3 -1
  56. package/dist/components/Skeleton/SkeletonLayouts.d.ts +5 -0
  57. package/dist/components/Skeleton/index.d.ts +1 -0
  58. package/dist/components/Slider/Slider.d.ts +2 -0
  59. package/dist/components/Stepper/Stepper.d.ts +5 -1
  60. package/dist/components/Tabs/Tabs.d.ts +7 -0
  61. package/dist/components/Textarea/Textarea.d.ts +2 -0
  62. package/dist/components/Timeline/Timeline.d.ts +9 -0
  63. package/dist/components/Toast/Toast.d.ts +1 -5
  64. package/dist/components/Toast/Toast.types.d.ts +13 -3
  65. package/dist/components/Tooltip/Tooltip.d.ts +3 -11
  66. package/dist/components/TreeView/TreeView.d.ts +34 -0
  67. package/dist/index.cjs +80 -55
  68. package/dist/index.cjs.map +1 -1
  69. package/dist/index.js +15280 -11282
  70. package/dist/index.js.map +1 -1
  71. package/dist/utils/overlayFocus.d.ts +13 -0
  72. package/dist/utils/useCloseGuard.d.ts +17 -0
  73. package/dist/utils/useVirtualWindow.d.ts +29 -0
  74. package/package.json +3 -3
@@ -28,9 +28,16 @@ type RootMultiple = AccordionRootBase & {
28
28
  defaultValue?: string[];
29
29
  /** Fires when the open set changes. */
30
30
  onValueChange?: (value: string[]) => void;
31
+ /** Start with every direct `AccordionItem` open (uncontrolled; ignored when `defaultValue`/`value` is set). */
32
+ expandAll?: boolean;
31
33
  };
32
34
  export type AccordionProps = (RootSingle | RootMultiple) & {
33
35
  variant?: 'plain' | 'bordered' | 'separated';
36
+ /**
37
+ * Remember the open item(s) in localStorage under this key and restore them on
38
+ * mount (uncontrolled accordions only). Storage failures are ignored.
39
+ */
40
+ persistKey?: string;
34
41
  /**
35
42
  * One-off CSS, same as `Box`'s `sx`: each value may be a scalar or a
36
43
  * responsive breakpoint map (`{ base, sm, md, lg, xl }`). Scalar-only sx
@@ -18,6 +18,11 @@ export interface AlertProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'
18
18
  action?: ReactNode;
19
19
  /** When provided, renders a close button that invokes this callback. */
20
20
  onDismiss?: () => void;
21
+ /**
22
+ * Play a short exit animation before `onDismiss` fires. Default `true`;
23
+ * skipped under `prefers-reduced-motion`. Set `false` for an immediate callback.
24
+ */
25
+ exitAnimation?: boolean;
21
26
  /** Accessible label for the dismiss button. */
22
27
  dismissLabel?: string;
23
28
  }
@@ -25,7 +25,7 @@ interface AutocompleteBase {
25
25
  searchPlaceholder?: string;
26
26
  /** Empty-state when no options match the search. */
27
27
  emptyText?: ReactNode;
28
- /** Show a loading spinner inside the dropdown. */
28
+ /** Show a loading spinner inside the dropdown (appears after 150ms to avoid flicker). */
29
29
  loading?: boolean;
30
30
  /** Loading-state text. */
31
31
  loadingText?: ReactNode;
@@ -37,6 +37,12 @@ interface AutocompleteBase {
37
37
  disabled?: boolean;
38
38
  /** Show a clear button when something is selected. */
39
39
  clearable?: boolean;
40
+ /** Highlight the part of each label matching the search text. Default: `true`. */
41
+ highlightMatch?: boolean;
42
+ /** Values shown as a "Recent" group while the search box is empty. */
43
+ recentItems?: string[];
44
+ /** Heading for the `recentItems` group. Default: `'Recent'`. */
45
+ recentLabel?: string;
40
46
  /**
41
47
  * Controlled open state of the dropdown. Pair with `onOpenChange`; leave
42
48
  * unset to let the component manage it.
@@ -1,3 +1,5 @@
1
- import type { AvatarProps, AvatarStackProps } from './Avatar.types';
1
+ import type { AvatarGroupProps, AvatarProps, AvatarStackProps } from './Avatar.types';
2
2
  export declare const Avatar: import("react").ForwardRefExoticComponent<AvatarProps & import("react").RefAttributes<HTMLSpanElement>>;
3
3
  export declare const AvatarStack: import("react").ForwardRefExoticComponent<AvatarStackProps & import("react").RefAttributes<HTMLDivElement>>;
4
+ /** Overlapping avatars that collapse past `max` into a "+N" avatar. */
5
+ export declare const AvatarGroup: import("react").ForwardRefExoticComponent<AvatarGroupProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -7,6 +7,11 @@ export interface AvatarProps extends HTMLAttributes<HTMLSpanElement> {
7
7
  status?: AvatarStatus;
8
8
  src?: string;
9
9
  alt?: string;
10
+ /**
11
+ * Full name. When there is no `src` (or the image fails to load) and no
12
+ * `children`, its initials are shown.
13
+ */
14
+ name?: string;
10
15
  /**
11
16
  * One-off CSS, same as `Box`'s `sx`: each value may be a scalar or a
12
17
  * responsive breakpoint map (`{ base, sm, md, lg, xl }`). Scalar-only sx
@@ -15,6 +20,15 @@ export interface AvatarProps extends HTMLAttributes<HTMLSpanElement> {
15
20
  sx?: SxProp;
16
21
  children?: ReactNode;
17
22
  }
23
+ export interface AvatarGroupProps extends HTMLAttributes<HTMLDivElement> {
24
+ /** Avatars shown before collapsing the rest into "+N". Default 5. */
25
+ max?: number;
26
+ /** Real total when the children are only a page of a bigger set. Defaults to the child count. */
27
+ total?: number;
28
+ /** Size applied to the "+N" overflow avatar. Match your avatars. */
29
+ size?: AvatarSize;
30
+ children: ReactNode;
31
+ }
18
32
  export interface AvatarStackProps extends HTMLAttributes<HTMLDivElement> {
19
33
  children: ReactNode;
20
34
  }
@@ -1,2 +1,2 @@
1
- export { Avatar, AvatarStack } from './Avatar';
2
- export type { AvatarProps, AvatarStackProps, AvatarSize, AvatarStatus } from './Avatar.types';
1
+ export { Avatar, AvatarStack, AvatarGroup } from './Avatar';
2
+ export type { AvatarProps, AvatarStackProps, AvatarGroupProps, AvatarSize, AvatarStatus } from './Avatar.types';
@@ -11,6 +11,12 @@ export interface BreadcrumbProps extends Omit<HTMLAttributes<HTMLElement>, 'chil
11
11
  /** Separator node between items. Default: chevron. */
12
12
  separator?: ReactNode;
13
13
  size?: 'sm' | 'md';
14
+ /**
15
+ * Collapse long trails: when there are more items than this, show the first
16
+ * item and the last `maxItems - 1`, with the hidden ones in an ellipsis menu.
17
+ * Minimum 2. Default: show everything.
18
+ */
19
+ maxItems?: number;
14
20
  /**
15
21
  * One-off CSS, same as `Box`'s `sx`: each value may be a scalar or a
16
22
  * responsive breakpoint map (`{ base, sm, md, lg, xl }`). Scalar-only sx
@@ -1,6 +1,7 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { CSSProperties } from 'react';
3
3
  import type { SxProp } from '../Layout/sx';
4
+ import type { Aggregate } from './chartScale';
4
5
  export interface BarSeries {
5
6
  /** Key into each datum for this series' value. */
6
7
  key: string;
@@ -21,7 +22,20 @@ export interface BarChartProps<D extends Record<string, unknown> = Record<string
21
22
  stacked?: boolean;
22
23
  grid?: boolean;
23
24
  legend?: boolean;
24
- /** Format y-axis tick values. */
25
+ /** Clicking a legend entry hides / shows that series. Default `true`. */
26
+ legendToggle?: boolean;
27
+ /** Content shown instead of the chart when there is no data. Default "No data". */
28
+ empty?: ReactNode;
29
+ /**
30
+ * Max bars drawn. More categories than this are aggregated into contiguous buckets
31
+ * (labelled "first – last"). Default: as many as fit at ~6px each.
32
+ */
33
+ maxBars?: number;
34
+ /** How bucketed categories combine when `maxBars` kicks in. Default `'sum'`. */
35
+ aggregate?: Aggregate;
36
+ /** Entrance animation (and smooth transitions when data changes). Default `true`; off under reduced motion and for very large charts. */
37
+ animate?: boolean;
38
+ /** Format y-axis tick values. Default compact (1.2K, 3M). */
25
39
  yTickFormatter?: (value: number) => string;
26
40
  /** Format x-axis category labels. */
27
41
  xTickFormatter?: (value: string) => string;
@@ -40,4 +54,4 @@ export interface BarChartProps<D extends Record<string, unknown> = Record<string
40
54
  */
41
55
  sx?: SxProp;
42
56
  }
43
- export declare function BarChart<D extends Record<string, unknown>>({ data, xKey, series, height, label, stacked, grid, legend, yTickFormatter, xTickFormatter, renderTooltip, className, style, sx, }: BarChartProps<D>): import("react/jsx-runtime").JSX.Element;
57
+ export declare function BarChart<D extends Record<string, unknown>>({ data: dataProp, xKey, series: allSeries, height, label, stacked, grid, legend, legendToggle, empty, maxBars, aggregate, animate, yTickFormatter, xTickFormatter, renderTooltip, className, style, sx, }: BarChartProps<D>): import("react/jsx-runtime").JSX.Element;
@@ -3,8 +3,10 @@ import type { ReactNode } from 'react';
3
3
  * Visually hidden data-table mirror of a chart. Screen readers get the exact
4
4
  * values the SVG conveys visually; sighted users never see it.
5
5
  */
6
- export declare function SrOnlyChartTable({ caption, head, rows, }: {
6
+ export declare function SrOnlyChartTable({ caption, head, rows, maxRows, }: {
7
7
  caption: string;
8
8
  head: string[];
9
9
  rows: ReactNode[][];
10
+ /** Cap on rendered rows (evenly sampled, first/last kept) + a summary row. Default 200. */
11
+ maxRows?: number;
10
12
  }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,19 @@
1
+ import type { ReactNode } from 'react';
2
+ /** Series keys hidden via the legend, plus a toggle. */
3
+ export declare function useHiddenKeys(): [Set<string>, (key: string) => void];
4
+ export interface LegendEntry {
5
+ key: string;
6
+ label: string;
7
+ color: string;
8
+ }
9
+ /** Legend whose entries are toggle buttons (`aria-pressed`) unless `interactive` is off. */
10
+ export declare function ChartLegend({ entries, hidden, onToggle, interactive, }: {
11
+ entries: LegendEntry[];
12
+ hidden: Set<string>;
13
+ onToggle: (key: string) => void;
14
+ interactive?: boolean;
15
+ }): import("react/jsx-runtime").JSX.Element;
16
+ /** No-data message centered over the (empty) plot, so layout does not jump. */
17
+ export declare function ChartEmpty({ children }: {
18
+ children: ReactNode;
19
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { PieChartProps } from './PieChart';
3
+ import type { ChartBaseProps } from './chartExtra';
4
+ export interface DonutChartProps extends Omit<PieChartProps, 'centerLabel' | 'innerRadius' | 'className' | 'style' | 'sx' | 'empty' | 'label'>, ChartBaseProps {
5
+ /** Hole size as a fraction of the outer radius. Default `0.62`. */
6
+ innerRadius?: number;
7
+ /** Custom center content. Defaults to the animated total (+ `centerCaption`). */
8
+ centerLabel?: ReactNode;
9
+ /** Small caption under the animated total, e.g. "workflows". */
10
+ centerCaption?: ReactNode;
11
+ /** Format the center total. */
12
+ valueFormatter?: (value: number) => string;
13
+ }
14
+ /** Donut chart: `PieChart` with a hole, a center-label slot, a sweep-in and a count-up total. */
15
+ export declare function DonutChart({ data, innerRadius, centerLabel, centerCaption, valueFormatter, label, animate, loading, empty, height, className, style, sx, ...rest }: DonutChartProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import type { ChartBaseProps } from './chartExtra';
2
+ export interface FunnelDatum {
3
+ label: string;
4
+ value: number;
5
+ color?: string;
6
+ }
7
+ export interface FunnelChartProps extends ChartBaseProps {
8
+ /** Stages, top to bottom (usually descending). */
9
+ data: FunnelDatum[];
10
+ height?: number;
11
+ /** Show each stage's % of the first stage. Default `true`. */
12
+ showPercent?: boolean;
13
+ valueFormatter?: (value: number) => string;
14
+ }
15
+ /** Funnel: stage widths scale with value; hover shows step conversion. */
16
+ export declare function FunnelChart({ data: rawData, height, showPercent, valueFormatter, label, animate, loading, empty, className, style, sx, }: FunnelChartProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,75 @@
1
+ import type { CSSProperties, ReactNode } from 'react';
2
+ import type { SxProp } from '../Layout/sx';
3
+ import type { GanttScale } from './gantt/ganttUtils';
4
+ export type { GanttScale } from './gantt/ganttUtils';
5
+ export interface GanttTask {
6
+ id: string;
7
+ name: string;
8
+ /** `Date` or ISO string. Date-only strings (`2026-03-01`) are read as local midnight. */
9
+ start: Date | string;
10
+ /**
11
+ * `Date` or ISO string. A date-only / midnight end is *inclusive* (the bar covers that whole
12
+ * day); an end with a time of day is exact. Ignored for milestones.
13
+ */
14
+ end: Date | string;
15
+ /** 0–100. Draws a filled portion of the bar. */
16
+ progress?: number;
17
+ /** Bar color. Defaults to the group's palette color. */
18
+ color?: string;
19
+ /** Tasks sharing a `group` are listed together under a collapsible header. */
20
+ group?: string;
21
+ /** Ids of tasks that must finish before this one starts (draws arrows). */
22
+ dependsOn?: string[];
23
+ /** Render as a diamond at `start` instead of a bar. */
24
+ milestone?: boolean;
25
+ }
26
+ export interface GanttChartProps {
27
+ tasks: GanttTask[];
28
+ /** Zoom level. Defaults to a scale chosen from the date range; a scale too fine for the range is coarsened automatically. */
29
+ scale?: GanttScale;
30
+ /** Max height of the chart in px; taller content scrolls vertically and only visible rows are rendered. Default 360. */
31
+ height?: number;
32
+ /** Height of each task row in px. Default 36. */
33
+ rowHeight?: number;
34
+ /** Width of the sticky task-name column in px. Default 200. Draggable at the header edge; narrow containers clamp it. */
35
+ nameWidth?: number;
36
+ /**
37
+ * Pixels per day, overriding the scale's default. The timeline is capped at ~20,000px, so a
38
+ * value that would exceed it is reduced (coarser header scale) automatically.
39
+ */
40
+ pxPerDay?: number;
41
+ /** Show zoom in / out buttons. Default `false`. */
42
+ zoomControls?: boolean;
43
+ /** Accessible label for the chart (group `aria-label` + hidden table caption). */
44
+ label?: string;
45
+ /** Reference date for the today marker. Defaults to now. */
46
+ today?: Date | string;
47
+ /** Draw the today marker. Default `true`. */
48
+ showToday?: boolean;
49
+ /** Allow dragging bars to move / resize and arrow keys to move the focused bar. */
50
+ editable?: boolean;
51
+ /** Called when an editable bar is moved or resized (snapped to whole days). Update `tasks` in response. */
52
+ onTaskChange?: (next: GanttTask, prev: GanttTask) => void;
53
+ /** Called when a bar is clicked, or activated with Enter / Space. */
54
+ onTaskClick?: (task: GanttTask) => void;
55
+ /** Group names that start collapsed. */
56
+ defaultCollapsed?: string[];
57
+ /** Animate bars, progress and dependency arrows. Default `true`; always off under `prefers-reduced-motion`. */
58
+ animate?: boolean;
59
+ /** Show a skeleton instead of the chart. */
60
+ loading?: boolean;
61
+ /** Content shown instead of the chart when there are no tasks. Default "No tasks". */
62
+ empty?: ReactNode;
63
+ /** Custom tooltip body for a hovered task. */
64
+ renderTooltip?: (task: GanttTask) => ReactNode;
65
+ className?: string;
66
+ style?: CSSProperties;
67
+ /**
68
+ * One-off CSS, same as `Box`'s `sx`: each value may be a scalar or a
69
+ * responsive breakpoint map (`{ base, sm, md, lg, xl }`). Scalar-only sx
70
+ * merges into inline style; responsive sx injects a scoped class. Applied to
71
+ * the chart's outer container.
72
+ */
73
+ sx?: SxProp;
74
+ }
75
+ export declare function GanttChart({ tasks, scale: scaleProp, height, rowHeight, nameWidth, pxPerDay, zoomControls, label, today, showToday, editable, onTaskChange, onTaskClick, defaultCollapsed, animate, loading, empty, renderTooltip, className, style, sx, }: GanttChartProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,25 @@
1
+ import type { ChartBaseProps } from './chartExtra';
2
+ export interface GaugeThreshold {
3
+ /** Value at (and above) which this color applies. */
4
+ from: number;
5
+ color: string;
6
+ }
7
+ export interface GaugeChartProps extends Omit<ChartBaseProps, 'empty'> {
8
+ value: number;
9
+ min?: number;
10
+ max?: number;
11
+ /** Color steps, e.g. `[{ from: 0, color: 'var(--color-danger)' }, { from: 50, color: ... }]`. */
12
+ thresholds?: GaugeThreshold[];
13
+ /** Fixed arc color (ignored when `thresholds` match). */
14
+ color?: string;
15
+ /** `semi` = 180° dial, `radial` = 270° dial. */
16
+ variant?: 'semi' | 'radial';
17
+ /** Show a needle. Default `true` for `semi`. */
18
+ needle?: boolean;
19
+ height?: number;
20
+ /** Small caption under the value. */
21
+ caption?: string;
22
+ valueFormatter?: (value: number) => string;
23
+ }
24
+ /** Semi / radial gauge with an animated arc, needle and count-up value. */
25
+ export declare function GaugeChart({ value: valueIn, min: minIn, max: maxIn, thresholds, color, variant, needle, height, caption, valueFormatter: formatter, label, animate, loading, className, style, sx, }: GaugeChartProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,37 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ChartBaseProps } from './chartExtra';
3
+ export interface HeatmapProps<D extends Record<string, unknown> = Record<string, unknown>> extends ChartBaseProps {
4
+ data: D[];
5
+ /** `matrix` = x by y grid; `calendar` = GitHub-style day grid. Default `matrix`. */
6
+ variant?: 'matrix' | 'calendar';
7
+ /** Matrix: key for the column category. Default `'x'`. */
8
+ xKey?: string;
9
+ /** Matrix: key for the row category. Default `'y'`. */
10
+ yKey?: string;
11
+ /** Key for the cell value. Default `'value'`. */
12
+ valueKey?: string;
13
+ /** Calendar: key holding a `yyyy-MM-dd` date. Default `'date'`. */
14
+ dateKey?: string;
15
+ /** Calendar: number of weeks shown, ending at `endDate`. Default `26`. */
16
+ weeks?: number;
17
+ /** Calendar: last day shown (`yyyy-MM-dd`). Defaults to the latest date in `data`. */
18
+ endDate?: string;
19
+ /** Matrix: explicit category order. */
20
+ xOrder?: string[];
21
+ yOrder?: string[];
22
+ /** Colors from lowest to highest value. Default: 5 steps of the primary token. */
23
+ colorScale?: string[];
24
+ /** Cell size in px. Default: up to 28 (matrix) / 13 (calendar), shrunk to fit the container (min 5). */
25
+ cellSize?: number;
26
+ /** Print the value inside matrix cells. */
27
+ showValues?: boolean;
28
+ /** Show the low-to-high legend. Default `true`. */
29
+ legend?: boolean;
30
+ valueFormatter?: (value: number) => string;
31
+ renderTooltip?: (params: {
32
+ title: string;
33
+ value: number | null;
34
+ }) => ReactNode;
35
+ }
36
+ /** Matrix or calendar heatmap with a configurable color scale. */
37
+ export declare function Heatmap<D extends Record<string, unknown>>({ data: dataProp, variant, xKey, yKey, valueKey, dateKey, weeks: weeksProp, endDate, xOrder, yOrder, colorScale: colorProp, cellSize, showValues, legend, valueFormatter, renderTooltip, label, animate, loading, empty, className, style, sx, }: HeatmapProps<D>): import("react/jsx-runtime").JSX.Element;
@@ -13,10 +13,24 @@ export interface LineChartProps<D extends Record<string, unknown> = Record<strin
13
13
  area?: boolean;
14
14
  /** Stack the series (area charts). */
15
15
  stacked?: boolean;
16
- /** Show point markers. */
16
+ /** Show point markers. Automatically skipped above ~100 visible points per series. */
17
17
  dots?: boolean;
18
+ /**
19
+ * Max points drawn per series. Longer series are reduced with LTTB (visual shape kept);
20
+ * the tooltip and keyboard navigation still use the full data. Default ~2 per plot pixel.
21
+ */
22
+ maxPoints?: number;
23
+ /** Entrance animation (and smooth transitions when data changes). Default `true`; off under reduced motion and for very large charts. */
24
+ animate?: boolean;
18
25
  grid?: boolean;
19
26
  legend?: boolean;
27
+ /** Clicking a legend entry hides / shows that series. Default `true`. */
28
+ legendToggle?: boolean;
29
+ /** Vertical guide line (and enlarged points) at the hovered category. Default `true`. */
30
+ crosshair?: boolean;
31
+ /** Content shown instead of the chart when there is no data. Default "No data". */
32
+ empty?: ReactNode;
33
+ /** Format y-axis tick values. Default compact (1.2K, 3M). */
20
34
  yTickFormatter?: (value: number) => string;
21
35
  xTickFormatter?: (value: string) => string;
22
36
  renderTooltip?: (params: {
@@ -14,13 +14,33 @@ export interface PieChartProps {
14
14
  /** Inner radius as a fraction of the outer radius (0 = pie, 0.6 = donut). */
15
15
  innerRadius?: number;
16
16
  legend?: boolean;
17
+ /** Clicking a legend entry hides / shows that slice. Default `true`. */
18
+ legendToggle?: boolean;
19
+ /** Content shown instead of the chart when there is no data. Default "No data". */
20
+ empty?: ReactNode;
17
21
  /** Custom tooltip body for a hovered slice. */
18
22
  renderTooltip?: (params: {
19
23
  datum: PieDatum;
20
24
  percent: number;
21
25
  }) => ReactNode;
22
- /** Center label (e.g. a total) for donut charts. */
23
- centerLabel?: ReactNode;
26
+ /**
27
+ * Center label (e.g. a total) for donut charts. May be a function receiving the hole's
28
+ * pixel `diameter` so the content can size itself.
29
+ */
30
+ centerLabel?: ReactNode | ((params: {
31
+ diameter: number;
32
+ }) => ReactNode);
33
+ /**
34
+ * Max slices drawn; the smallest are grouped into one "Other" slice (a toggle expands
35
+ * them). Default `10`; `0` or `Infinity` disables grouping.
36
+ */
37
+ maxSlices?: number;
38
+ /** Label of the grouped slice. Default "Other". */
39
+ otherLabel?: string;
40
+ /** Format values in the tooltip. Default: grouped thousands, compact above a billion. */
41
+ valueFormatter?: (value: number) => string;
42
+ /** Entrance animation (and smooth transitions when data changes). Default `true`; off under reduced motion and for very large charts. */
43
+ animate?: boolean;
24
44
  className?: string;
25
45
  style?: CSSProperties;
26
46
  /**
@@ -31,4 +51,6 @@ export interface PieChartProps {
31
51
  */
32
52
  sx?: SxProp;
33
53
  }
34
- export declare function PieChart({ data, height, label, innerRadius, legend, renderTooltip, centerLabel, className, style, sx, }: PieChartProps): import("react/jsx-runtime").JSX.Element;
54
+ /** Share as text: "<0.1%" / "0.4%" for tiny slices, whole percent otherwise. */
55
+ export declare function formatShare(frac: number): string;
56
+ export declare function PieChart({ data, height, label, innerRadius, legend, legendToggle, empty, renderTooltip, centerLabel, maxSlices, otherLabel, valueFormatter, animate, className, style, sx, }: PieChartProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,25 @@
1
+ import type { ChartBaseProps } from './chartExtra';
2
+ import type { BarSeries } from './BarChart';
3
+ export interface RadarChartProps<D extends Record<string, unknown> = Record<string, unknown>> extends ChartBaseProps {
4
+ data: D[];
5
+ /** Key for each axis label. */
6
+ axisKey: string;
7
+ series: BarSeries[];
8
+ height?: number;
9
+ /** Outer ring value. Defaults to the data max. */
10
+ max?: number;
11
+ /** Number of concentric rings. Default `4`. */
12
+ levels?: number;
13
+ /** Fill the polygons. Default `true`. */
14
+ fill?: boolean;
15
+ legend?: boolean;
16
+ legendToggle?: boolean;
17
+ /**
18
+ * Scale every axis to its own maximum (for axes on wildly different scales). `'auto'`
19
+ * (default) turns it on only when no `max` is set and axis maxima differ by over 20x.
20
+ * Tooltips always show the real values.
21
+ */
22
+ normalize?: boolean | 'auto';
23
+ }
24
+ /** Spider / radar chart: one polygon per series across the axes. */
25
+ export declare function RadarChart<D extends Record<string, unknown>>({ data: rawData, axisKey, series: allSeriesIn, height, max, levels, fill, legend, legendToggle, normalize, label, animate, loading, empty, className, style, sx, }: RadarChartProps<D>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,33 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ChartBaseProps } from './chartExtra';
3
+ export interface ScatterChartProps<D extends Record<string, unknown> = Record<string, unknown>> extends ChartBaseProps {
4
+ data: D[];
5
+ xKey: string;
6
+ yKey: string;
7
+ /** Key for bubble size; omit for uniform dots. */
8
+ sizeKey?: string;
9
+ /** Key whose value splits points into colored groups (and the legend). */
10
+ groupKey?: string;
11
+ /** Key for the point name shown in the tooltip. */
12
+ nameKey?: string;
13
+ /** Colors by group (in order of first appearance) or a single color. */
14
+ colors?: string[];
15
+ /** Bubble radius range in px. Default `[4, 22]`. */
16
+ sizeRange?: [number, number];
17
+ height?: number;
18
+ /**
19
+ * Max dots drawn. Above this the plot is thinned to one dot per grid cell (per group) so the
20
+ * outline of the cloud is kept; hover and keyboard still see every point. Default 1500.
21
+ */
22
+ maxPoints?: number;
23
+ grid?: boolean;
24
+ legend?: boolean;
25
+ legendToggle?: boolean;
26
+ xTickFormatter?: (v: number) => string;
27
+ yTickFormatter?: (v: number) => string;
28
+ renderTooltip?: (params: {
29
+ datum: D;
30
+ }) => ReactNode;
31
+ }
32
+ /** Scatter plot with optional bubble size and color groups. */
33
+ export declare function ScatterChart<D extends Record<string, unknown>>({ data: dataProp, xKey, yKey, sizeKey, groupKey, nameKey, colors, sizeRange, height, maxPoints, grid, legend, legendToggle, xTickFormatter, yTickFormatter, renderTooltip, label, animate, loading, empty, className, style, sx, }: ScatterChartProps<D>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import type { ChartBaseProps } from './chartExtra';
2
+ export interface SparklineProps<D extends Record<string, unknown> = Record<string, unknown>> extends Omit<ChartBaseProps, 'empty'> {
3
+ /** Numbers, or objects read through `valueKey`. */
4
+ data: Array<number | D>;
5
+ /** Key to read from object data. Default `'value'`. */
6
+ valueKey?: string;
7
+ variant?: 'line' | 'area' | 'bar';
8
+ width?: number;
9
+ height?: number;
10
+ color?: string;
11
+ /** Dot on the last point (line / area). Default `true`. */
12
+ showLast?: boolean;
13
+ /** Message shown when there is no data. Default is a dash. */
14
+ emptyText?: string;
15
+ }
16
+ /** Tiny inline chart with no axes. */
17
+ export declare function Sparkline<D extends Record<string, unknown> = Record<string, unknown>>({ data, valueKey, variant, width, height, color, showLast, label, emptyText, animate, loading, className, style, sx, }: SparklineProps<D>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,23 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ChartBaseProps } from './chartExtra';
3
+ export interface StatCardProps extends Omit<ChartBaseProps, 'empty' | 'label'> {
4
+ /** Metric name. */
5
+ label: string;
6
+ /** Number (counts up) or preformatted text. */
7
+ value: number | string;
8
+ /** Format a numeric `value`. */
9
+ valueFormatter?: (value: number) => string;
10
+ /** Change vs the previous period, in percent. Sign decides the arrow + color. */
11
+ delta?: number;
12
+ /** Text after the delta, e.g. "vs last week". */
13
+ deltaLabel?: string;
14
+ /** Treat a decrease as good (e.g. churn, latency). */
15
+ deltaInverse?: boolean;
16
+ /** Trend data for the inline sparkline. */
17
+ trend?: number[];
18
+ /** Sparkline color. */
19
+ color?: string;
20
+ icon?: ReactNode;
21
+ }
22
+ /** KPI card: animated value, delta chip and sparkline. */
23
+ export declare function StatCard({ label, value, valueFormatter, delta, deltaLabel, deltaInverse, trend, color, icon, animate, loading, className, style, sx, }: StatCardProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,23 @@
1
+ import type { KeyboardEvent, ReactNode } from 'react';
2
+ /** Axis tick label: compact (1.2K / 3M), tiny values in exponent form, never NaN. */
3
+ export declare function axisFmt(n: number): string;
4
+ /** Tooltip value: exact up to 1e9 (grouped), compact beyond; `null` -> "no data". */
5
+ export declare function tipFmt(n: number | null | undefined): string;
6
+ /** Left gutter wide enough for the widest y label (clamped so tiny containers keep a plot). */
7
+ export declare function gutterFor(labels: readonly string[], width: number, min?: number): number;
8
+ /** Truncated x category label (full text stays in tooltip / aria). */
9
+ export declare const shortLabel: (s: string, max?: number) => string;
10
+ /** Evenly sampled rows for the sr-only table + a trailing "more" row (cap = SrOnlyChartTable default). */
11
+ export declare function sampleRows(n: number, build: (i: number) => ReactNode[], cap?: number): ReactNode[][];
12
+ /** Arrow/Home/End navigation over `count` ordered marks for a focusable svg. */
13
+ export declare function indexKeys(count: number, current: number | null, set: (i: number | null) => void, step?: number): (e: KeyboardEvent) => void;
14
+ /** Per-mark focusable/mouse handlers are only worth their cost below this many marks. */
15
+ export declare const MARK_CAP = 60;
16
+ /** `niceScale` that can never return a degenerate / non-finite domain. */
17
+ export declare function safeScale(min: number, max: number, count?: number): {
18
+ lo: number;
19
+ hi: number;
20
+ ticks: number[];
21
+ };
22
+ /** Plain-object view of a datum (null / primitives -> {}). */
23
+ export declare const rowOf: (d: unknown) => Record<string, unknown>;
@@ -0,0 +1,90 @@
1
+ import type { CSSProperties, ReactNode, RefObject } from 'react';
2
+ import { cx } from '../../utils/cx';
3
+ import type { SxProp } from '../Layout/sx';
4
+ /** Props shared by the extra chart components. */
5
+ export interface ChartBaseProps {
6
+ /** Accessible label for the chart (svg `aria-label` + hidden table caption). */
7
+ label?: string;
8
+ /** Entrance + hover animation. Always off under `prefers-reduced-motion`. Default `true`. */
9
+ animate?: boolean;
10
+ /** Show a loading placeholder instead of the chart. */
11
+ loading?: boolean;
12
+ /** Content shown instead of the chart when there is no data. Default "No data". */
13
+ empty?: ReactNode;
14
+ className?: string;
15
+ style?: CSSProperties;
16
+ /** One-off CSS, same as `Box`'s `sx`. Applied to the chart's outer container. */
17
+ sx?: SxProp;
18
+ }
19
+ /**
20
+ * Hover index with a short leave delay. Moving between marks crosses a gap where
21
+ * `mouseleave` fires before the next `mouseenter`; without the delay the tooltip and
22
+ * the dim-others emphasis blink off and on at every crossing.
23
+ */
24
+ export declare function useHover(delay?: number): [number | null, (i: number | null) => void];
25
+ /** True when the user prefers reduced motion (live-updating). */
26
+ export declare function usePrefersReducedMotion(): boolean;
27
+ /** Effective animation flag: the `animate` prop AND no reduced-motion preference. */
28
+ export declare function useAnimate(animate?: boolean): boolean;
29
+ /** Counts from 0 to `target` (ease-out) while `enabled`; otherwise returns `target` as-is. */
30
+ export declare function useCountUp(target: number, enabled: boolean, duration?: number): number;
31
+ /** Outer container shared by the extra charts: sx, animation class, loading + empty states. */
32
+ export declare function ChartShell({ rootRef, animate, loading, isEmpty, empty, height, className, style, sx, children, }: {
33
+ rootRef?: RefObject<HTMLDivElement | null>;
34
+ /** Resolved animation flag (see `useAnimate`). */
35
+ animate: boolean;
36
+ loading?: boolean;
37
+ isEmpty?: boolean;
38
+ empty?: ReactNode;
39
+ height?: number;
40
+ className?: string;
41
+ style?: CSSProperties;
42
+ sx?: SxProp;
43
+ children: ReactNode;
44
+ }): import("react/jsx-runtime").JSX.Element;
45
+ /**
46
+ * Floating tooltip box (positioned in px relative to the chart container). It is measured
47
+ * after layout and flipped/shifted (`clampTooltip`) so it never leaves the container.
48
+ */
49
+ export declare function ChartTip({ x, y, children }: {
50
+ x: number;
51
+ y: number;
52
+ children: ReactNode;
53
+ }): import("react/jsx-runtime").JSX.Element;
54
+ export declare const idx: (i: number, step?: number) => CSSProperties;
55
+ /** Polar -> cartesian, angle in radians, 0 at 12 o'clock, clockwise. */
56
+ export declare function polar(cx0: number, cy0: number, r: number, a: number): [number, number];
57
+ /** Open stroke arc (for gauges / rings). */
58
+ export declare function arcStroke(cx0: number, cy0: number, r: number, a0: number, a1: number): string;
59
+ /** Nice [lo, hi] range + ticks that covers [min, max] (negatives, equal, tiny/huge, inverted, non-finite safe). */
60
+ export declare function niceRange(min: number, max: number, count?: number): {
61
+ lo: number;
62
+ hi: number;
63
+ ticks: number[];
64
+ };
65
+ /** Rounds an in-flight count-up value to the precision of its target. */
66
+ export declare const roundLike: (v: number, target: number) => number;
67
+ export declare const fmt: (n: number) => string;
68
+ export { cx };
69
+ /**
70
+ * Skip entrance animation when there are too many marks (thousands of CSS-animated
71
+ * nodes jank). Combine with `useAnimate`: `useAnimate(animate) && useAnimateBudget(n)`.
72
+ */
73
+ export declare function useAnimateBudget(count: number, limit?: number): boolean;
74
+ /**
75
+ * ONE rAF-throttled pointermove handler for a whole svg (instead of N per-mark listeners).
76
+ * `resolve(x, y, rect)` gets pointer coords relative to the element and returns the hovered
77
+ * index (e.g. via `nearestIndexByX`) or null. Spread `handlers` on the svg.
78
+ */
79
+ export declare function usePointerHover(resolve: (x: number, y: number, rect: DOMRect) => number | null, leaveDelay?: number): {
80
+ hover: number | null;
81
+ setHover: (i: number | null) => void;
82
+ handlers: {
83
+ onPointerMove: (e: {
84
+ clientX: number;
85
+ clientY: number;
86
+ currentTarget: Element;
87
+ }) => void;
88
+ onPointerLeave: () => void;
89
+ };
90
+ };