twico-ui 1.9.0 → 1.10.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/dist/index.d.cts CHANGED
@@ -545,6 +545,22 @@ declare function Carousel(props: CarouselProps): React.JSX.Element;
545
545
  */
546
546
  type ChartDatum<K extends string = "value"> = { label: React.ReactNode } & { [P in K]: number };
547
547
 
548
+ /** Payload passed to `onDataClick` when a bar/point (or category, in zoom mode) is clicked. */
549
+ interface ChartClickPayload<K extends string = string> {
550
+ /** The clicked datum's `label`. */
551
+ label: React.ReactNode;
552
+ /** The series key clicked, or `null` when a whole category was clicked (zoom overlay). */
553
+ series: K | null;
554
+ /** Index of `series` in the `series` prop, or `-1` for a category click. */
555
+ seriesIndex: number;
556
+ /** The clicked value, or `undefined` for a category click. */
557
+ value: number | undefined;
558
+ /** Index of the datum in the full (un-zoomed) `data` array. */
559
+ index: number;
560
+ /** The full data row that was clicked. */
561
+ row: ChartDatum<K>;
562
+ }
563
+
548
564
  /**
549
565
  * Cartesian chart — vertical/horizontal bars (grouped or stacked), line, and area
550
566
  * (straight / smooth / stepped), single or multi-series, with grid, axes, tooltips,
@@ -554,7 +570,7 @@ type ChartDatum<K extends string = "value"> = { label: React.ReactNode } & { [P
554
570
  * scatter/bubble, radar, heatmap, gauge, funnel, treemap, candlestick, boxplot and
555
571
  * range charts use the dedicated sibling components.
556
572
  *
557
- * @startingPoint section="Data display" subtitle="Bar / line / area chart (no deps)" viewport="700x280"
573
+ * @startingPoint section="Charts" subtitle="Bar / line / area chart (no deps)" viewport="700x280"
558
574
  */
559
575
  interface ChartProps<K extends string = "value"> extends React.HTMLAttributes<HTMLDivElement> {
560
576
  /** Chart type. `"column"` is an alias of `"bar"` (vertical bars). @default "bar" */
@@ -579,6 +595,12 @@ interface ChartProps<K extends string = "value"> extends React.HTMLAttributes<HT
579
595
  showValues?: boolean;
580
596
  /** Play the entrance animation (bars grow, lines draw); respects `prefers-reduced-motion`. @default true */
581
597
  animate?: boolean;
598
+ /** Show a vertical crosshair line at the hovered category (line/area/vertical bars). @default true */
599
+ crosshair?: boolean;
600
+ /** Enable drag-to-zoom (+ shift-drag pan, wheel zoom, and a reset button) over the x-axis. @default false */
601
+ zoomable?: boolean;
602
+ /** Fires when a bar/point is clicked (or a category, in zoom mode) with the datum + metadata. */
603
+ onDataClick?: (payload: ChartClickPayload<NoInfer<K>>) => void;
582
604
  /** Grid lines. @default true */
583
605
  showGrid?: boolean;
584
606
  /** Axis labels. @default true */
@@ -609,13 +631,25 @@ interface PieChartDatum {
609
631
  color?: string;
610
632
  }
611
633
 
634
+ /** Payload passed to `onDataClick` when a pie/donut slice is clicked. */
635
+ interface PieChartClickPayload {
636
+ /** The clicked slice's `label`. */
637
+ label: React.ReactNode;
638
+ /** The clicked slice's numeric value (negative inputs are clamped to `0`). */
639
+ value: number;
640
+ /** Index of the slice in the `data` array. */
641
+ index: number;
642
+ /** The slice's share of the total, as a percentage rounded to one decimal. */
643
+ percent: number;
644
+ }
645
+
612
646
  /**
613
647
  * Pie / donut chart — proportional slices of a whole from a single value series,
614
648
  * with per-slice tooltips, an optional legend, optional percentage labels, and a
615
649
  * donut center label. Dependency-free inline SVG. For bar/line/area use `Chart`;
616
650
  * for other shapes use the dedicated sibling components (gauge, radar, funnel, …).
617
651
  *
618
- * @startingPoint section="Data display" subtitle="Pie / donut chart (no deps)" viewport="700x280"
652
+ * @startingPoint section="Charts" subtitle="Pie / donut chart (no deps)" viewport="700x280"
619
653
  */
620
654
  interface PieChartProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "color"> {
621
655
  /** Slices to plot; each is a `{ label, value, color? }`. Only positive values contribute a slice. */
@@ -640,6 +674,8 @@ interface PieChartProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "colo
640
674
  height?: number;
641
675
  /** Per-slice colors (any CSS color), cycled when shorter than `data`. Defaults to the built-in token palette. */
642
676
  colors?: string[];
677
+ /** Fires when a slice is clicked with the slice's label, value, index, and percent share; clicking a slice also toggles a selection that pops the slice outward and dims the rest. */
678
+ onDataClick?: (payload: PieChartClickPayload) => void;
643
679
  /** Accessible name for the `<svg role="img">`. Per-slice values live in the hidden data table, not this label. Defaults to `"pie chart"`/`"donut chart"`; also accepts `aria-label`. */
644
680
  ariaLabel?: string;
645
681
  /** Render a visually-hidden data table as an accessible text alternative (WCAG 1.1.1). @default true */
@@ -657,7 +693,7 @@ type DonutChartDatum = PieChartDatum;
657
693
  * Donut chart — a {@link PieChart} preset rendered as a ring (hollow center).
658
694
  * Accepts every PieChart prop; `donut` defaults to `true`.
659
695
  *
660
- * @startingPoint section="Data display" subtitle="Donut chart (no deps)" viewport="700x280"
696
+ * @startingPoint section="Charts" subtitle="Donut chart (no deps)" viewport="700x280"
661
697
  */
662
698
  interface DonutChartProps extends PieChartProps {}
663
699
 
@@ -673,6 +709,16 @@ interface GaugeSeries {
673
709
  color?: string;
674
710
  }
675
711
 
712
+ /** Payload passed to `onDataClick` when a gauge value arc (ring) is clicked. */
713
+ interface GaugeClickPayload {
714
+ /** The clicked ring's value. */
715
+ value: number;
716
+ /** The clicked ring's label (the `label` prop for a single gauge, or the `series` entry's label). */
717
+ label?: React.ReactNode;
718
+ /** Index of the clicked ring (`0` for a single gauge; the `series` index for a multi-ring gauge). */
719
+ index: number;
720
+ }
721
+
676
722
  /**
677
723
  * Radial gauge / radial-bar chart — renders a single `value` as a thick arc that
678
724
  * sweeps between `startAngle` and `endAngle`, with the value + an optional caption
@@ -680,7 +726,7 @@ interface GaugeSeries {
680
726
  * Dependency-free inline SVG; every color/size is a design token so dark mode is
681
727
  * automatic. For bar/line/area use `Chart`; for slices use `PieChart`/`DonutChart`.
682
728
  *
683
- * @startingPoint section="Data display" subtitle="Radial gauge / radial-bar (no deps)" viewport="700x280"
729
+ * @startingPoint section="Charts" subtitle="Radial gauge / radial-bar (no deps)" viewport="700x280"
684
730
  */
685
731
  interface GaugeProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "color"> {
686
732
  /** The value to display, mapped from `min`..`max` onto the arc sweep. @default 0 */
@@ -711,6 +757,8 @@ interface GaugeProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "color">
711
757
  series?: GaugeSeries[];
712
758
  /** Show the legend for a multi-ring (`series`) gauge. @default true */
713
759
  showLegend?: boolean;
760
+ /** Fires when a value arc (ring) is clicked, with the ring's value, label, and index; the clicked ring also gains a selection outline. */
761
+ onDataClick?: (payload: GaugeClickPayload) => void;
714
762
  /** Accessible name for the `<svg role="img">`; defaults to a value summary. Also accepts `aria-label`. */
715
763
  ariaLabel?: string;
716
764
  /** Render a visually-hidden data table as an accessible text alternative (WCAG 1.1.1). @default true */
@@ -727,6 +775,16 @@ declare function Gauge(props: GaugeProps): React.JSX.Element;
727
775
  */
728
776
  type SparklineDatum = number | { value: number; label?: React.ReactNode };
729
777
 
778
+ /** Payload passed to `onDataClick` when a point/bar is clicked. */
779
+ interface SparklineClickPayload {
780
+ /** The clicked point's numeric value. */
781
+ value: number;
782
+ /** Index of the clicked point in the `data` array. */
783
+ index: number;
784
+ /** The point's `label` (falls back to its 1-based index). */
785
+ label: React.ReactNode;
786
+ }
787
+
730
788
  /**
731
789
  * Sparkline — a minimal, word-sized trend chart (line, area, or bars) with no
732
790
  * axes, grid, ticks, or legend, meant to sit inline beside text or inside a
@@ -734,7 +792,7 @@ type SparklineDatum = number | { value: number; label?: React.ReactNode };
734
792
  * vertical space, with an optional emphasised trailing dot. For a full chart
735
793
  * with axes, tooltips, and a legend use the `Chart` component.
736
794
  *
737
- * @startingPoint section="Data display" subtitle="Tiny inline trend line (no deps)" viewport="700x280"
795
+ * @startingPoint section="Charts" subtitle="Tiny inline trend line (no deps)" viewport="700x280"
738
796
  */
739
797
  interface SparklineProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "color"> {
740
798
  /** Data points: bare numbers, or `{ value, label }` objects. */
@@ -761,6 +819,8 @@ interface SparklineProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "col
761
819
  max?: number;
762
820
  /** Value formatter for tooltips + the hidden data table. @default toLocaleString */
763
821
  valueFormat?: (value: number) => string;
822
+ /** Fires when a point/bar is clicked with its value, index, and label; the clicked mark also toggles a selection outline. */
823
+ onDataClick?: (payload: SparklineClickPayload) => void;
764
824
  /** Accessible name for the `<svg role="img">`; defaults to a spoken summary (point count + first/last/min/max, or +latest when a table is present). Also accepts `aria-label`. */
765
825
  ariaLabel?: string;
766
826
  /** Render a visually-hidden data table as a text alternative (WCAG 1.1.1); off by default since the summarizing aria-label usually suffices for a sparkline. @default false */
@@ -793,6 +853,24 @@ interface ScatterSeries {
793
853
  points: ScatterPoint[];
794
854
  }
795
855
 
856
+ /** Payload passed to `onDataClick` when a point is clicked. */
857
+ interface ScatterClickPayload {
858
+ /** The clicked point's x value. */
859
+ x: number;
860
+ /** The clicked point's y value. */
861
+ y: number;
862
+ /** The clicked point's z (bubble size) value, if any. */
863
+ z?: number;
864
+ /** Name of the series the point belongs to (defaults to `"Series N"`). */
865
+ series: string;
866
+ /** Index of the point's series in the `series` prop. */
867
+ seriesIndex: number;
868
+ /** Index of the point within its series' `points` array. */
869
+ index: number;
870
+ /** The original `ScatterPoint` object that was clicked. */
871
+ point: ScatterPoint;
872
+ }
873
+
796
874
  /**
797
875
  * Scatter / bubble chart — plots x/y points across two nice-scaled numeric axes,
798
876
  * one or many series, with grid, axis titles, tooltips, an optional legend and a
@@ -801,7 +879,7 @@ interface ScatterSeries {
801
879
  * dots stay round. For bars/line/area use `Chart`; for other shapes use the
802
880
  * dedicated sibling components.
803
881
  *
804
- * @startingPoint section="Data display" subtitle="Scatter / bubble plot (no deps)" viewport="700x280"
882
+ * @startingPoint section="Charts" subtitle="Scatter / bubble plot (no deps)" viewport="700x280"
805
883
  */
806
884
  interface ScatterChartProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "color"> {
807
885
  /** The series to plot; each has optional `name`/`color` and a list of `{ x, y, z?, label? }` points. */
@@ -822,6 +900,10 @@ interface ScatterChartProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "
822
900
  showGrid?: boolean;
823
901
  /** Series legend. Defaults to `true` when there is more than one series. */
824
902
  showLegend?: boolean;
903
+ /** Enable 2-D drag-to-zoom (rectangle-zoom both axes, + shift-drag pan, wheel zoom, and a reset button). @default false */
904
+ zoomable?: boolean;
905
+ /** Fires when a point is clicked, with its x/y/z, series metadata, and the original point. */
906
+ onDataClick?: (payload: ScatterClickPayload) => void;
825
907
  /** Formatter for x values in tooltips + the hidden table (defaults to `valueFormat`). */
826
908
  xFormat?: (value: number) => string;
827
909
  /** Formatter for y values in tooltips + the hidden table (defaults to `valueFormat`). */
@@ -842,7 +924,7 @@ declare function ScatterChart(props: ScatterChartProps): React.JSX.Element;
842
924
  * Bubble chart — a {@link ScatterChart} preset that sizes each dot by its point's
843
925
  * `z` value. Accepts every ScatterChart prop; `bubble` defaults to `true`.
844
926
  *
845
- * @startingPoint section="Data display" subtitle="Bubble chart (no deps)" viewport="700x280"
927
+ * @startingPoint section="Charts" subtitle="Bubble chart (no deps)" viewport="700x280"
846
928
  */
847
929
  interface BubbleChartProps extends ScatterChartProps {}
848
930
 
@@ -855,6 +937,18 @@ declare function BubbleChart(props: BubbleChartProps): React.JSX.Element;
855
937
  */
856
938
  type RadarDatum<K extends string = "value"> = { label: React.ReactNode } & { [P in K]: number };
857
939
 
940
+ /** Payload passed to `onDataClick` when a series vertex dot is clicked. */
941
+ interface RadarClickPayload<K extends string = string> {
942
+ /** The clicked vertex's axis `label`. */
943
+ label: React.ReactNode;
944
+ /** The series (polygon) key that was clicked. */
945
+ series: K;
946
+ /** The clicked value. */
947
+ value: number;
948
+ /** Index of the axis (row) in the `data` array. */
949
+ index: number;
950
+ }
951
+
858
952
  /**
859
953
  * Radar / spider chart — one or more series drawn as closed polygons over a
860
954
  * shared set of categorical axes radiating from a center, with concentric grid
@@ -864,7 +958,7 @@ type RadarDatum<K extends string = "value"> = { label: React.ReactNode } & { [P
864
958
  * For cartesian bars/lines/areas use `Chart`; for other shapes use the dedicated
865
959
  * sibling components.
866
960
  *
867
- * @startingPoint section="Data display" subtitle="Radar / spider chart (no deps)" viewport="700x280"
961
+ * @startingPoint section="Charts" subtitle="Radar / spider chart (no deps)" viewport="700x280"
868
962
  */
869
963
  interface RadarChartProps<K extends string = "value"> extends React.HTMLAttributes<HTMLDivElement> {
870
964
  /** Data rows — one per **axis**. Each has a `label` + one numeric field per series key. (`K` is inferred from `series`, not from `data`.) */
@@ -887,6 +981,8 @@ interface RadarChartProps<K extends string = "value"> extends React.HTMLAttribut
887
981
  valueFormat?: (value: number) => string;
888
982
  /** Pixel height; the chart uses a square canvas of this size. @default 300 */
889
983
  height?: number;
984
+ /** Fires when a series vertex dot is clicked, with the axis label, series key, value, and axis index. */
985
+ onDataClick?: (payload: RadarClickPayload<NoInfer<K>>) => void;
890
986
  /** Accessible name for the chart's `<svg role="img">`. Per-point values are exposed via the hidden data table, not this label. Defaults to `"radar chart"`; also accepts `aria-label`. */
891
987
  ariaLabel?: string;
892
988
  /** Render a visually-hidden data table as an accessible text alternative (WCAG 1.1.1). @default true */
@@ -907,16 +1003,27 @@ interface PolarAreaDatum {
907
1003
  color?: string;
908
1004
  }
909
1005
 
1006
+ /** Payload passed to `onDataClick` when a slice is clicked. */
1007
+ interface PolarAreaClickPayload {
1008
+ /** The clicked slice's `label`. */
1009
+ label: React.ReactNode;
1010
+ /** The clicked slice's numeric `value`. */
1011
+ value: number;
1012
+ /** Index of the slice in the `data` array. */
1013
+ index: number;
1014
+ }
1015
+
910
1016
  /**
911
1017
  * Polar-area (Coxcomb / Nightingale rose) chart — equal-angle slices whose
912
1018
  * *radius* encodes each value, laid over concentric value rings. Radius scales
913
1019
  * with `√value` so a slice's **area** is proportional to its value (the
914
1020
  * statistically honest encoding). Dependency-free inline SVG, with per-slice
915
- * tooltips, an optional legend, and a visually-hidden data table. For plain
1021
+ * tooltips, click + selection (`onDataClick`), a legend whose entries
1022
+ * hover-focus their slice, and a visually-hidden data table. For plain
916
1023
  * proportional wedges use `PieChart` / `DonutChart`; for a spoked multi-axis
917
1024
  * shape use `RadarChart`.
918
1025
  *
919
- * @startingPoint section="Data display" subtitle="Polar-area / rose chart (no deps)" viewport="700x280"
1026
+ * @startingPoint section="Charts" subtitle="Polar-area / rose chart (no deps)" viewport="700x280"
920
1027
  */
921
1028
  interface PolarAreaChartProps extends React.HTMLAttributes<HTMLDivElement> {
922
1029
  /** Data points — one equal-angle slice each, in order clockwise from `startAngle`. */
@@ -935,6 +1042,8 @@ interface PolarAreaChartProps extends React.HTMLAttributes<HTMLDivElement> {
935
1042
  height?: number;
936
1043
  /** Per-slice colors (any CSS color), cycled across slices. Defaults to the built-in token palette. */
937
1044
  colors?: string[];
1045
+ /** Fires when a slice is clicked with its `label`, `value`, and `index`; the clicked slice also toggles a selected state that pops it outward along its mid-angle and dims the rest. */
1046
+ onDataClick?: (payload: PolarAreaClickPayload) => void;
938
1047
  /** Accessible name for the chart's `<svg role="img">`. Defaults to `"polar area chart"`; also accepts `aria-label`. */
939
1048
  ariaLabel?: string;
940
1049
  /** Render a visually-hidden data table as an accessible text alternative (WCAG 1.1.1). @default true */
@@ -959,6 +1068,16 @@ interface HeatmapDatum {
959
1068
  value: number;
960
1069
  }
961
1070
 
1071
+ /** Payload passed to `onDataClick` when a heatmap cell is clicked. */
1072
+ interface HeatmapClickPayload {
1073
+ /** The clicked cell's column (`x`) key. */
1074
+ x: string | number;
1075
+ /** The clicked cell's row (`y`) key. */
1076
+ y: string | number;
1077
+ /** The clicked cell's numeric value. */
1078
+ value: number;
1079
+ }
1080
+
962
1081
  /**
963
1082
  * Heatmap — a matrix of colored cells keyed by (x, y), each shaded by a
964
1083
  * single-hue intensity scale between `min` and `max`. Ordered X columns and Y
@@ -966,7 +1085,7 @@ interface HeatmapDatum {
966
1085
  * Dependency-free inline SVG, with per-cell tooltips, a gradient scale legend,
967
1086
  * and a visually-hidden data table. Dark mode is automatic through tokens.
968
1087
  *
969
- * @startingPoint section="Data display" subtitle="Matrix heatmap (no deps)" viewport="700x280"
1088
+ * @startingPoint section="Charts" subtitle="Matrix heatmap (no deps)" viewport="700x280"
970
1089
  */
971
1090
  interface HeatmapProps extends React.HTMLAttributes<HTMLDivElement> {
972
1091
  /** Cells to plot. X columns and Y rows are derived from these in first-seen order. */
@@ -989,8 +1108,17 @@ interface HeatmapProps extends React.HTMLAttributes<HTMLDivElement> {
989
1108
  yLabel?: React.ReactNode;
990
1109
  /** Show the low→high gradient scale legend below the grid. @default true */
991
1110
  showLegend?: boolean;
1111
+ /**
1112
+ * Enable a 2-D drag/wheel zoom over the cell grid: drag a rectangle to zoom to
1113
+ * that sub-range of the ordered X columns and Y rows, shift-drag to pan, scroll
1114
+ * to zoom about the cursor, and a Reset button restores the full matrix. Needs
1115
+ * at least two columns and two rows. @default false
1116
+ */
1117
+ zoomable?: boolean;
992
1118
  /** Value formatter for tooltips, printed cell values, and the hidden table. @default fmtNumber */
993
1119
  valueFormat?: (value: number) => string;
1120
+ /** Fires when a cell is clicked with its `{ x, y, value }`; the clicked cell also toggles a selection outline. */
1121
+ onDataClick?: (payload: HeatmapClickPayload) => void;
994
1122
  /** Pixel height of the chart. @default 300 */
995
1123
  height?: number;
996
1124
  /** Accessible name for the chart's `<svg role="img">`. Per-cell values are exposed via the hidden data table, not this label. Defaults to `"heatmap"`; also accepts `aria-label`. */
@@ -1013,6 +1141,18 @@ interface FunnelDatum {
1013
1141
  color?: string;
1014
1142
  }
1015
1143
 
1144
+ /** Payload passed to `onDataClick` when a funnel stage is clicked. */
1145
+ interface FunnelClickPayload {
1146
+ /** The clicked stage's `label`. */
1147
+ label: React.ReactNode;
1148
+ /** The clicked stage's numeric value. */
1149
+ value: number;
1150
+ /** Index of the stage in the `data` array. */
1151
+ index: number;
1152
+ /** The stage's percentage of the first (top) stage. */
1153
+ percent: number;
1154
+ }
1155
+
1016
1156
  /**
1017
1157
  * Funnel chart — descending stages drawn as centered trapezoids that taper from
1018
1158
  * each stage's value to the next, for conversion / drop-off flows. Each band is
@@ -1021,7 +1161,7 @@ interface FunnelDatum {
1021
1161
  * and a visually-hidden data table. For bars/lines/areas use `Chart`; for part-of-whole
1022
1162
  * shares use `PieChart`.
1023
1163
  *
1024
- * @startingPoint section="Data display" subtitle="Descending funnel stages (no deps)" viewport="700x280"
1164
+ * @startingPoint section="Charts" subtitle="Descending funnel stages (no deps)" viewport="700x280"
1025
1165
  */
1026
1166
  interface FunnelChartProps extends React.HTMLAttributes<HTMLDivElement> {
1027
1167
  /** Funnel stages, ordered from the widest/top stage to the narrowest. */
@@ -1038,6 +1178,8 @@ interface FunnelChartProps extends React.HTMLAttributes<HTMLDivElement> {
1038
1178
  height?: number;
1039
1179
  /** Per-stage colors (any CSS color), cycled when shorter than `data`. Defaults to the token palette. */
1040
1180
  colors?: string[];
1181
+ /** Fires when a stage is clicked with its label, value, index, and percent-of-top; also toggles a selection outline on the clicked stage. */
1182
+ onDataClick?: (payload: FunnelClickPayload) => void;
1041
1183
  /** Value formatter for captions, tooltips, and the hidden data-table cells. @default toLocaleString */
1042
1184
  valueFormat?: (value: number) => string;
1043
1185
  /** Accessible name for the chart's `<svg role="img">`; per-stage values live in the hidden table. Defaults to `"funnel chart"`; also accepts `aria-label`. */
@@ -1060,6 +1202,18 @@ interface TreemapDatum {
1060
1202
  color?: string;
1061
1203
  }
1062
1204
 
1205
+ /** Payload passed to `onDataClick` when a treemap tile is clicked. */
1206
+ interface TreemapClickPayload {
1207
+ /** The clicked tile's `label`. */
1208
+ label: React.ReactNode;
1209
+ /** The clicked tile's (non-negative) value. */
1210
+ value: number;
1211
+ /** Index of the tile in the original `data` array. */
1212
+ index: number;
1213
+ /** The tile's fraction of the total, `0`–`1` (`0` when the total is `0`). */
1214
+ share: number;
1215
+ }
1216
+
1063
1217
  /**
1064
1218
  * Treemap — a squarified partition of a rectangle into tiles sized in proportion
1065
1219
  * to a flat list of values (Bruls/Huizing/van Wijk squarified layout), packed to
@@ -1067,7 +1221,7 @@ interface TreemapDatum {
1067
1221
  * labels, hover tooltips, and a visually-hidden data table. Good for showing the
1068
1222
  * relative weight of parts within a whole (spend by category, storage by bucket).
1069
1223
  *
1070
- * @startingPoint section="Data display" subtitle="Squarified treemap (no deps)" viewport="700x280"
1224
+ * @startingPoint section="Charts" subtitle="Squarified treemap (no deps)" viewport="700x280"
1071
1225
  */
1072
1226
  interface TreemapProps extends React.HTMLAttributes<HTMLDivElement> {
1073
1227
  /** Tiles to lay out. Each has a `label`, a non-negative `value`, and an optional `color`. */
@@ -1082,6 +1236,8 @@ interface TreemapProps extends React.HTMLAttributes<HTMLDivElement> {
1082
1236
  colors?: string[];
1083
1237
  /** Gap in px inset between adjacent tiles. @default 2 */
1084
1238
  gap?: number;
1239
+ /** Fires when a tile is clicked with the tile's label, value, index, and share; the clicked tile also toggles a selection outline. */
1240
+ onDataClick?: (payload: TreemapClickPayload) => void;
1085
1241
  /** Accessible name for the chart's `<svg role="img">`. Per-tile values are exposed via the hidden data table, not this label. Defaults to `"treemap"`; also accepts `aria-label`. */
1086
1242
  ariaLabel?: string;
1087
1243
  /** Render a visually-hidden data table (value + share) as an accessible text alternative (WCAG 1.1.1). @default true */
@@ -1109,6 +1265,22 @@ interface CandlestickDatum {
1109
1265
  close: number;
1110
1266
  }
1111
1267
 
1268
+ /** Payload passed to `onDataClick` when a candle is clicked. */
1269
+ interface CandlestickClickPayload {
1270
+ /** The clicked candle's `label`. */
1271
+ label: React.ReactNode;
1272
+ /** Opening price for the clicked period. */
1273
+ open: number;
1274
+ /** Highest price reached in the clicked period. */
1275
+ high: number;
1276
+ /** Lowest price reached in the clicked period. */
1277
+ low: number;
1278
+ /** Closing price for the clicked period. */
1279
+ close: number;
1280
+ /** Index of the candle in the full (un-zoomed) `data` array. */
1281
+ index: number;
1282
+ }
1283
+
1112
1284
  /**
1113
1285
  * Candlestick (OHLC) chart — one candle per period with a high→low wick and an
1114
1286
  * open→close body, colored by direction (up vs. down), plus a shared value axis,
@@ -1116,7 +1288,7 @@ interface CandlestickDatum {
1116
1288
  * SVG. For bars/lines/areas use `Chart`; for other shapes use the dedicated
1117
1289
  * sibling chart components.
1118
1290
  *
1119
- * @startingPoint section="Data display" subtitle="OHLC candlestick chart (no deps)" viewport="700x280"
1291
+ * @startingPoint section="Charts" subtitle="OHLC candlestick chart (no deps)" viewport="700x280"
1120
1292
  */
1121
1293
  interface CandlestickProps extends React.HTMLAttributes<HTMLDivElement> {
1122
1294
  /** OHLC data points, one candle each, in chronological order. */
@@ -1131,6 +1303,10 @@ interface CandlestickProps extends React.HTMLAttributes<HTMLDivElement> {
1131
1303
  showGrid?: boolean;
1132
1304
  /** Value axis + category labels. @default true */
1133
1305
  showAxis?: boolean;
1306
+ /** Enable drag-to-zoom (+ shift-drag pan, wheel zoom, and a reset button) over the candles. @default false */
1307
+ zoomable?: boolean;
1308
+ /** Fires when a candle is clicked with the OHLC values + its index in the full data array. */
1309
+ onDataClick?: (payload: CandlestickClickPayload) => void;
1134
1310
  /** Tooltip value formatter (also formats the hidden data-table cells). @default toLocaleString */
1135
1311
  valueFormat?: (value: number) => string;
1136
1312
  /** Accessible name for the chart's `<svg role="img">`. Defaults to `"candlestick chart"`; also accepts `aria-label`. */
@@ -1164,6 +1340,24 @@ interface BoxplotDatum {
1164
1340
  outliers?: number[];
1165
1341
  }
1166
1342
 
1343
+ /** Payload passed to `onDataClick` when a box is clicked. */
1344
+ interface BoxplotClickPayload {
1345
+ /** The clicked box's `label`. */
1346
+ label: React.ReactNode;
1347
+ /** Lower whisker end (distribution minimum). */
1348
+ min: number;
1349
+ /** First quartile — the bottom edge of the box. */
1350
+ q1: number;
1351
+ /** Median — the bold line inside the box. */
1352
+ median: number;
1353
+ /** Third quartile — the top edge of the box. */
1354
+ q3: number;
1355
+ /** Upper whisker end (distribution maximum). */
1356
+ max: number;
1357
+ /** Index of the box in the `data` array. */
1358
+ index: number;
1359
+ }
1360
+
1167
1361
  /**
1168
1362
  * Box-and-whisker chart — one box per category summarising a five-number
1169
1363
  * distribution (min, Q1, median, Q3, max) with whiskers, a bold median line,
@@ -1171,7 +1365,7 @@ interface BoxplotDatum {
1171
1365
  * design tokens. For bar/line/area use `Chart`; for other shapes use the
1172
1366
  * dedicated sibling components.
1173
1367
  *
1174
- * @startingPoint section="Data display" subtitle="Box-and-whisker distribution chart" viewport="700x280"
1368
+ * @startingPoint section="Charts" subtitle="Box-and-whisker distribution chart" viewport="700x280"
1175
1369
  */
1176
1370
  interface BoxplotProps extends React.HTMLAttributes<HTMLDivElement> {
1177
1371
  /** The boxes to plot, one per category, each a five-number summary. */
@@ -1184,8 +1378,12 @@ interface BoxplotProps extends React.HTMLAttributes<HTMLDivElement> {
1184
1378
  showGrid?: boolean;
1185
1379
  /** Value axis and category labels. @default true */
1186
1380
  showAxis?: boolean;
1381
+ /** Enable drag-to-zoom over the category axis: drag an x-range to zoom into those boxes (re-fitting the value scale), shift-drag to pan, mouse-wheel to zoom, plus a Reset button. @default false */
1382
+ zoomable?: boolean;
1187
1383
  /** Tooltip/table value formatter. @default toLocaleString */
1188
1384
  valueFormat?: (value: number) => string;
1385
+ /** Fires when a box is clicked, with the five-number summary + its index. */
1386
+ onDataClick?: (payload: BoxplotClickPayload) => void;
1189
1387
  /** Accessible name for the chart's `<svg role="img">`. Per-box values are exposed via the hidden data table, not this label. @default "box plot" */
1190
1388
  ariaLabel?: string;
1191
1389
  /** Render a visually-hidden data table as an accessible text alternative (WCAG 1.1.1). @default true */
@@ -1212,14 +1410,27 @@ interface RangeDatum {
1212
1410
  color?: string;
1213
1411
  }
1214
1412
 
1413
+ /** Payload passed to `onDataClick` when a range bar/band segment is clicked. */
1414
+ interface RangeChartClickPayload {
1415
+ /** The clicked segment's `label`. */
1416
+ label: React.ReactNode;
1417
+ /** Lower bound of the clicked range. */
1418
+ min: number;
1419
+ /** Upper bound of the clicked range. */
1420
+ max: number;
1421
+ /** Index of the segment in the full (un-zoomed) `data` array. */
1422
+ index: number;
1423
+ }
1424
+
1215
1425
  /**
1216
1426
  * Range chart — horizontal range bars (a timeline / Gantt of one min→max band
1217
1427
  * per row) or a range area (a shaded band between a per-category min line and
1218
- * max line), with a shared value axis, grid, tooltips and an accessible data
1219
- * table. Dependency-free inline SVG. For bars/lines/areas use `Chart`; for other
1428
+ * max line), with a shared value axis, grid, tooltips, click (`onDataClick`) +
1429
+ * selection, optional drag/wheel zoom, and an accessible data table.
1430
+ * Dependency-free inline SVG. For bars/lines/areas use `Chart`; for other
1220
1431
  * shapes use the dedicated sibling chart components.
1221
1432
  *
1222
- * @startingPoint section="Data display" subtitle="Range bar / range area chart (no deps)" viewport="700x280"
1433
+ * @startingPoint section="Charts" subtitle="Range bar / range area chart (no deps)" viewport="700x280"
1223
1434
  */
1224
1435
  interface RangeChartProps extends React.HTMLAttributes<HTMLDivElement> {
1225
1436
  /** `"bar"` = horizontal range bars (timeline/Gantt); `"area"` = a band between a min and max line. @default "bar" */
@@ -1232,6 +1443,10 @@ interface RangeChartProps extends React.HTMLAttributes<HTMLDivElement> {
1232
1443
  showGrid?: boolean;
1233
1444
  /** Value axis + category labels. @default true */
1234
1445
  showAxis?: boolean;
1446
+ /** Enable drag-to-zoom over the category axis (+ shift-drag pan, wheel zoom, and a reset button). @default false */
1447
+ zoomable?: boolean;
1448
+ /** Fires when a range bar/band segment is clicked with its label, bounds and full-data index; also toggles a selection outline on that segment. */
1449
+ onDataClick?: (payload: RangeChartClickPayload) => void;
1235
1450
  /** Palette for bar fills / the area band, cycled by index. Defaults to the built-in token palette. */
1236
1451
  colors?: string[];
1237
1452
  /** Tooltip value formatter (also formats the hidden data-table cells). @default toLocaleString */