@mui/x-charts 9.10.1 → 9.11.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 (177) hide show
  1. package/BarChart/BarChart.js +4 -2
  2. package/BarChart/BarChart.mjs +4 -2
  3. package/BarChart/BarPlot.d.mts +3 -3
  4. package/BarChart/BarPlot.d.ts +3 -3
  5. package/BarChart/BarPlot.js +1 -1
  6. package/BarChart/BarPlot.mjs +1 -1
  7. package/BarChart/BatchBarPlot/BatchBarPlot.d.mts +2 -2
  8. package/BarChart/BatchBarPlot/BatchBarPlot.d.ts +2 -2
  9. package/BarChart/IndividualBarPlot.d.mts +2 -2
  10. package/BarChart/IndividualBarPlot.d.ts +2 -2
  11. package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.mts +4 -4
  12. package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +4 -4
  13. package/BarChart/useRegisterItemClickHandlers.d.mts +2 -1
  14. package/BarChart/useRegisterItemClickHandlers.d.ts +2 -1
  15. package/BarChart/useRegisterItemClickHandlers.js +8 -0
  16. package/BarChart/useRegisterItemClickHandlers.mjs +8 -1
  17. package/CHANGELOG.md +118 -0
  18. package/ChartsContainer/ChartsContainer.js +4 -2
  19. package/ChartsContainer/ChartsContainer.mjs +4 -2
  20. package/ChartsDataProvider/ChartsDataProvider.js +3 -1
  21. package/ChartsDataProvider/ChartsDataProvider.mjs +3 -1
  22. package/ChartsRadialDataProvider/ChartsRadialDataProvider.js +3 -1
  23. package/ChartsRadialDataProvider/ChartsRadialDataProvider.mjs +3 -1
  24. package/ChartsXAxis/useAxisTicksProps.d.mts +101 -101
  25. package/ChartsXAxis/useAxisTicksProps.d.ts +101 -101
  26. package/ChartsYAxis/useAxisTicksProps.d.mts +101 -101
  27. package/ChartsYAxis/useAxisTicksProps.d.ts +101 -101
  28. package/LineChart/AreaPlot.d.mts +3 -2
  29. package/LineChart/AreaPlot.d.ts +3 -2
  30. package/LineChart/AreaPlot.js +8 -2
  31. package/LineChart/AreaPlot.mjs +9 -3
  32. package/LineChart/LineChart.js +2 -1
  33. package/LineChart/LineChart.mjs +2 -1
  34. package/LineChart/LinePlot.d.mts +3 -2
  35. package/LineChart/LinePlot.d.ts +3 -2
  36. package/LineChart/LinePlot.js +2 -2
  37. package/LineChart/LinePlot.mjs +3 -3
  38. package/LineChart/MarkPlot.d.mts +5 -4
  39. package/LineChart/MarkPlot.d.ts +5 -4
  40. package/LineChart/MarkPlot.js +17 -8
  41. package/LineChart/MarkPlot.mjs +17 -8
  42. package/LineChart/useLineItemClickHandler.d.mts +25 -1
  43. package/LineChart/useLineItemClickHandler.d.ts +25 -1
  44. package/LineChart/useLineItemClickHandler.js +48 -1
  45. package/LineChart/useLineItemClickHandler.mjs +47 -1
  46. package/PieChart/PieArcPlot.d.mts +3 -2
  47. package/PieChart/PieArcPlot.d.ts +3 -2
  48. package/PieChart/PieArcPlot.js +16 -1
  49. package/PieChart/PieArcPlot.mjs +16 -1
  50. package/PieChart/PieChart.js +3 -1
  51. package/PieChart/PieChart.mjs +3 -1
  52. package/PieChart/PiePlot.js +1 -1
  53. package/PieChart/PiePlot.mjs +1 -1
  54. package/README.md +1 -11
  55. package/RadarChart/RadarAxis/RadarAxis.utils.d.mts +1 -1
  56. package/RadarChart/RadarAxis/RadarAxis.utils.d.ts +1 -1
  57. package/RadarChart/RadarChart.js +3 -1
  58. package/RadarChart/RadarChart.mjs +3 -1
  59. package/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +3 -1
  60. package/RadarChart/RadarSeriesPlot/RadarSeriesArea.mjs +3 -1
  61. package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +4 -1
  62. package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.mjs +4 -1
  63. package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.mts +5 -4
  64. package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.ts +5 -4
  65. package/RadarChart/RadarSeriesPlot/useRegisterRadarItemActivation.d.mts +15 -0
  66. package/RadarChart/RadarSeriesPlot/useRegisterRadarItemActivation.d.ts +15 -0
  67. package/RadarChart/RadarSeriesPlot/useRegisterRadarItemActivation.js +32 -0
  68. package/RadarChart/RadarSeriesPlot/useRegisterRadarItemActivation.mjs +26 -0
  69. package/RadarChart/useRadarChartProps.js +5 -1
  70. package/RadarChart/useRadarChartProps.mjs +5 -1
  71. package/ScatterChart/Scatter.d.mts +3 -2
  72. package/ScatterChart/Scatter.d.ts +3 -2
  73. package/ScatterChart/Scatter.js +10 -1
  74. package/ScatterChart/Scatter.mjs +10 -1
  75. package/ScatterChart/ScatterChart.js +1 -0
  76. package/ScatterChart/ScatterChart.mjs +1 -0
  77. package/ScatterChart/async/ScatterAsync.js +9 -0
  78. package/ScatterChart/async/ScatterAsync.mjs +9 -0
  79. package/SparkLineChart/SparkLineChart.js +2 -1
  80. package/SparkLineChart/SparkLineChart.mjs +2 -1
  81. package/Toolbar/ToolbarButton.js +1 -1
  82. package/Toolbar/ToolbarButton.mjs +1 -1
  83. package/hooks/useFocusedItem.d.mts +1 -1
  84. package/hooks/useFocusedItem.d.ts +1 -1
  85. package/hooks/useItemHighlightStateGetter.d.mts +1 -1
  86. package/hooks/useItemHighlightStateGetter.d.ts +1 -1
  87. package/index.js +1 -1
  88. package/index.mjs +1 -1
  89. package/internals/createCommonKeyboardFocusHandler.d.mts +2 -2
  90. package/internals/createCommonKeyboardFocusHandler.d.ts +2 -2
  91. package/internals/index.d.mts +1 -0
  92. package/internals/index.d.ts +1 -0
  93. package/internals/index.js +8 -0
  94. package/internals/index.mjs +1 -0
  95. package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.mts +8 -1
  96. package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.ts +8 -1
  97. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +11 -3
  98. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.mjs +11 -3
  99. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.mts +1 -0
  100. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +1 -0
  101. package/internals/plugins/corePlugins/useChartSeriesConfig/types/getItemWithData.types.d.mts +12 -0
  102. package/internals/plugins/corePlugins/useChartSeriesConfig/types/getItemWithData.types.d.ts +12 -0
  103. package/internals/plugins/corePlugins/useChartSeriesConfig/types/getItemWithData.types.js +5 -0
  104. package/internals/plugins/corePlugins/useChartSeriesConfig/types/getItemWithData.types.mjs +1 -0
  105. package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.d.mts +1 -0
  106. package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.d.ts +1 -0
  107. package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.js +11 -0
  108. package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.mjs +1 -0
  109. package/internals/plugins/corePlugins/useChartSeriesConfig/types/seriesConfig.types.d.mts +6 -0
  110. package/internals/plugins/corePlugins/useChartSeriesConfig/types/seriesConfig.types.d.ts +6 -0
  111. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisClickPayload.d.mts +21 -0
  112. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisClickPayload.d.ts +21 -0
  113. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisClickPayload.js +46 -0
  114. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisClickPayload.mjs +40 -0
  115. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +13 -31
  116. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.mjs +13 -31
  117. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.mts +2 -2
  118. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +2 -2
  119. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.mts +11 -11
  120. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +11 -11
  121. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.mts +4 -4
  122. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +4 -4
  123. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +19 -0
  124. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.mjs +19 -0
  125. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.types.d.mts +5 -3
  126. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.types.d.ts +5 -3
  127. package/internals/plugins/featurePlugins/useChartItemClick/useChartItemClick.js +15 -0
  128. package/internals/plugins/featurePlugins/useChartItemClick/useChartItemClick.mjs +14 -0
  129. package/internals/plugins/featurePlugins/useChartItemClick/useChartItemClick.types.d.mts +5 -2
  130. package/internals/plugins/featurePlugins/useChartItemClick/useChartItemClick.types.d.ts +5 -2
  131. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.d.mts +2 -1
  132. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.d.ts +2 -1
  133. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.js +10 -2
  134. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.mjs +2 -1
  135. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/itemActivation.d.mts +13 -0
  136. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/itemActivation.d.ts +13 -0
  137. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/itemActivation.js +39 -0
  138. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/itemActivation.mjs +32 -0
  139. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +47 -7
  140. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.mjs +47 -7
  141. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.mts +3 -0
  142. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +3 -0
  143. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +3 -1
  144. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.mjs +2 -0
  145. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.mts +39 -2
  146. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +39 -2
  147. package/internals/plugins/featurePlugins/useChartPolarAxis/getPolarAxisClickPayload.d.mts +27 -0
  148. package/internals/plugins/featurePlugins/useChartPolarAxis/getPolarAxisClickPayload.d.ts +27 -0
  149. package/internals/plugins/featurePlugins/useChartPolarAxis/getPolarAxisClickPayload.js +36 -0
  150. package/internals/plugins/featurePlugins/useChartPolarAxis/getPolarAxisClickPayload.mjs +30 -0
  151. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +19 -20
  152. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.mjs +19 -20
  153. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.mts +2 -2
  154. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +2 -2
  155. package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.mts +1 -1
  156. package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +1 -1
  157. package/internals/seriesSelectorOfType.d.mts +4 -4
  158. package/internals/seriesSelectorOfType.d.ts +4 -4
  159. package/internals/useRegisterItemActivation.d.mts +23 -0
  160. package/internals/useRegisterItemActivation.d.ts +23 -0
  161. package/internals/useRegisterItemActivation.js +53 -0
  162. package/internals/useRegisterItemActivation.mjs +46 -0
  163. package/models/axis.d.mts +1 -1
  164. package/models/axis.d.ts +1 -1
  165. package/models/events.d.mts +11 -0
  166. package/models/events.d.ts +11 -0
  167. package/models/events.js +5 -0
  168. package/models/events.mjs +1 -0
  169. package/models/index.d.mts +1 -0
  170. package/models/index.d.ts +1 -0
  171. package/moduleAugmentation/barChartBatchRendererOnItemClick.d.mts +3 -4
  172. package/moduleAugmentation/barChartBatchRendererOnItemClick.d.ts +3 -4
  173. package/moduleAugmentation/keyboardActivation.d.mts +7 -0
  174. package/moduleAugmentation/keyboardActivation.d.ts +7 -0
  175. package/moduleAugmentation/keyboardActivation.js +8 -0
  176. package/moduleAugmentation/keyboardActivation.mjs +2 -0
  177. package/package.json +18 -4
@@ -1,15 +1,16 @@
1
1
  import * as React from 'react';
2
2
  import type { AreaElementProps, AreaElementSlotProps, AreaElementSlots } from "./AreaElement.mjs";
3
3
  import type { LineItemClickIdentifier } from "../models/seriesType/line.mjs";
4
+ import type { ChartsActivationEvent } from "../models/events.mjs";
4
5
  export interface AreaPlotSlots extends AreaElementSlots {}
5
6
  export interface AreaPlotSlotProps extends AreaElementSlotProps {}
6
7
  export interface AreaPlotProps extends React.SVGAttributes<SVGSVGElement>, Pick<AreaElementProps, 'slots' | 'slotProps' | 'skipAnimation'> {
7
8
  /**
8
9
  * Callback fired when a line area item is clicked.
9
- * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
10
+ * @param {ChartsActivationEvent<SVGElement>} event The event source of the callback.
10
11
  * @param {LineItemClickIdentifier} lineItemIdentifier The line item identifier.
11
12
  */
12
- onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier: LineItemClickIdentifier) => void;
13
+ onItemClick?: (event: ChartsActivationEvent<SVGElement>, lineItemIdentifier: LineItemClickIdentifier) => void;
13
14
  }
14
15
  /**
15
16
  * Demos:
@@ -1,15 +1,16 @@
1
1
  import * as React from 'react';
2
2
  import type { AreaElementProps, AreaElementSlotProps, AreaElementSlots } from "./AreaElement.js";
3
3
  import type { LineItemClickIdentifier } from "../models/seriesType/line.js";
4
+ import type { ChartsActivationEvent } from "../models/events.js";
4
5
  export interface AreaPlotSlots extends AreaElementSlots {}
5
6
  export interface AreaPlotSlotProps extends AreaElementSlotProps {}
6
7
  export interface AreaPlotProps extends React.SVGAttributes<SVGSVGElement>, Pick<AreaElementProps, 'slots' | 'slotProps' | 'skipAnimation'> {
7
8
  /**
8
9
  * Callback fired when a line area item is clicked.
9
- * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
10
+ * @param {ChartsActivationEvent<SVGElement>} event The event source of the callback.
10
11
  * @param {LineItemClickIdentifier} lineItemIdentifier The line item identifier.
11
12
  */
12
- onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier: LineItemClickIdentifier) => void;
13
+ onItemClick?: (event: ChartsActivationEvent<SVGElement>, lineItemIdentifier: LineItemClickIdentifier) => void;
13
14
  }
14
15
  /**
15
16
  * Demos:
@@ -67,7 +67,13 @@ function AreaPlot(props) {
67
67
  const skipAnimation = (0, _useSkipAnimation.useSkipAnimation)(isZoomInteracting || inSkipAnimation);
68
68
  const completedData = useAggregatedData();
69
69
  const classes = (0, _lineClasses.useUtilityClasses)();
70
- const onAreaItemClick = (0, _useLineItemClickHandler.useLineItemClickHandler)(onItemClick);
70
+
71
+ // The area is drawn only for series that enable it, so a series without an area declines and
72
+ // activation falls through to the line.
73
+ const isAreaRendered = ({
74
+ seriesId
75
+ }) => completedData.some(series => series.seriesId === seriesId && !!series.area);
76
+ const onAreaItemClick = (0, _useLineItemClickHandler.useLineItemClickHandler)(onItemClick, _useLineItemClickHandler.LINE_ACTIVATION_PRIORITY.area, isAreaRendered);
71
77
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(AreaPlotRoot, (0, _extends2.default)({
72
78
  className: (0, _clsx.default)(classes.areaPlot, className)
73
79
  }, other, {
@@ -96,7 +102,7 @@ process.env.NODE_ENV !== "production" ? AreaPlot.propTypes /* remove-proptypes *
96
102
  // ----------------------------------------------------------------------
97
103
  /**
98
104
  * Callback fired when a line area item is clicked.
99
- * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
105
+ * @param {ChartsActivationEvent<SVGElement>} event The event source of the callback.
100
106
  * @param {LineItemClickIdentifier} lineItemIdentifier The line item identifier.
101
107
  */
102
108
  onItemClick: _propTypes.default.func,
@@ -12,7 +12,7 @@ import { useSkipAnimation } from "../hooks/useSkipAnimation.mjs";
12
12
  import { useXAxes, useYAxes } from "../hooks/useAxis.mjs";
13
13
  import { useInternalIsZoomInteracting } from "../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.mjs";
14
14
  import { useAreaPlotData } from "./useAreaPlotData.mjs";
15
- import { useLineItemClickHandler } from "./useLineItemClickHandler.mjs";
15
+ import { LINE_ACTIVATION_PRIORITY, useLineItemClickHandler } from "./useLineItemClickHandler.mjs";
16
16
  import { ANIMATION_DURATION_MS, ANIMATION_TIMING_FUNCTION } from "../internals/animation/animation.mjs";
17
17
  import { lineClasses, useUtilityClasses } from "./lineClasses.mjs";
18
18
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -60,7 +60,13 @@ function AreaPlot(props) {
60
60
  const skipAnimation = useSkipAnimation(isZoomInteracting || inSkipAnimation);
61
61
  const completedData = useAggregatedData();
62
62
  const classes = useUtilityClasses();
63
- const onAreaItemClick = useLineItemClickHandler(onItemClick);
63
+
64
+ // The area is drawn only for series that enable it, so a series without an area declines and
65
+ // activation falls through to the line.
66
+ const isAreaRendered = ({
67
+ seriesId
68
+ }) => completedData.some(series => series.seriesId === seriesId && !!series.area);
69
+ const onAreaItemClick = useLineItemClickHandler(onItemClick, LINE_ACTIVATION_PRIORITY.area, isAreaRendered);
64
70
  return /*#__PURE__*/_jsx(AreaPlotRoot, _extends({
65
71
  className: clsx(classes.areaPlot, className)
66
72
  }, other, {
@@ -89,7 +95,7 @@ process.env.NODE_ENV !== "production" ? AreaPlot.propTypes /* remove-proptypes *
89
95
  // ----------------------------------------------------------------------
90
96
  /**
91
97
  * Callback fired when a line area item is clicked.
92
- * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
98
+ * @param {ChartsActivationEvent<SVGElement>} event The event source of the callback.
93
99
  * @param {LineItemClickIdentifier} lineItemIdentifier The line item identifier.
94
100
  */
95
101
  onItemClick: PropTypes.func,
@@ -145,7 +145,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes /* remove-proptypes
145
145
  * Options to enable features planned for the next major.
146
146
  */
147
147
  experimentalFeatures: _propTypes.default.shape({
148
- enablePositionBasedPointerInteraction: _propTypes.default.bool
148
+ enablePositionBasedPointerInteraction: _propTypes.default.bool,
149
+ keyboardActivation: _propTypes.default.bool
149
150
  }),
150
151
  /**
151
152
  * Option to display a cartesian grid in the background.
@@ -138,7 +138,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes /* remove-proptypes
138
138
  * Options to enable features planned for the next major.
139
139
  */
140
140
  experimentalFeatures: PropTypes.shape({
141
- enablePositionBasedPointerInteraction: PropTypes.bool
141
+ enablePositionBasedPointerInteraction: PropTypes.bool,
142
+ keyboardActivation: PropTypes.bool
142
143
  }),
143
144
  /**
144
145
  * Option to display a cartesian grid in the background.
@@ -1,15 +1,16 @@
1
1
  import * as React from 'react';
2
2
  import type { LineElementProps, LineElementSlotProps, LineElementSlots } from "./LineElement.mjs";
3
3
  import type { LineItemClickIdentifier } from "../models/seriesType/line.mjs";
4
+ import type { ChartsActivationEvent } from "../models/events.mjs";
4
5
  export interface LinePlotSlots extends LineElementSlots {}
5
6
  export interface LinePlotSlotProps extends LineElementSlotProps {}
6
7
  export interface LinePlotProps extends React.SVGAttributes<SVGSVGElement>, Pick<LineElementProps, 'slots' | 'slotProps' | 'skipAnimation'> {
7
8
  /**
8
9
  * Callback fired when a line item is clicked.
9
- * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
10
+ * @param {ChartsActivationEvent<SVGElement>} event The event source of the callback.
10
11
  * @param {LineItemClickIdentifier} lineItemIdentifier The line item identifier.
11
12
  */
12
- onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier: LineItemClickIdentifier) => void;
13
+ onItemClick?: (event: ChartsActivationEvent<SVGElement>, lineItemIdentifier: LineItemClickIdentifier) => void;
13
14
  }
14
15
  /**
15
16
  * Demos:
@@ -1,15 +1,16 @@
1
1
  import * as React from 'react';
2
2
  import type { LineElementProps, LineElementSlotProps, LineElementSlots } from "./LineElement.js";
3
3
  import type { LineItemClickIdentifier } from "../models/seriesType/line.js";
4
+ import type { ChartsActivationEvent } from "../models/events.js";
4
5
  export interface LinePlotSlots extends LineElementSlots {}
5
6
  export interface LinePlotSlotProps extends LineElementSlotProps {}
6
7
  export interface LinePlotProps extends React.SVGAttributes<SVGSVGElement>, Pick<LineElementProps, 'slots' | 'slotProps' | 'skipAnimation'> {
7
8
  /**
8
9
  * Callback fired when a line item is clicked.
9
- * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
10
+ * @param {ChartsActivationEvent<SVGElement>} event The event source of the callback.
10
11
  * @param {LineItemClickIdentifier} lineItemIdentifier The line item identifier.
11
12
  */
12
- onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier: LineItemClickIdentifier) => void;
13
+ onItemClick?: (event: ChartsActivationEvent<SVGElement>, lineItemIdentifier: LineItemClickIdentifier) => void;
13
14
  }
14
15
  /**
15
16
  * Demos:
@@ -66,7 +66,7 @@ function LinePlot(props) {
66
66
  const skipAnimation = (0, _useSkipAnimation.useSkipAnimation)(isZoomInteracting || inSkipAnimation);
67
67
  const completedData = useAggregatedData();
68
68
  const classes = (0, _lineClasses.useUtilityClasses)();
69
- const onLineItemClick = (0, _useLineItemClickHandler.useLineItemClickHandler)(onItemClick);
69
+ const onLineItemClick = (0, _useLineItemClickHandler.useLineItemClickHandler)(onItemClick, _useLineItemClickHandler.LINE_ACTIVATION_PRIORITY.line);
70
70
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(LinePlotRoot, (0, _extends2.default)({
71
71
  className: (0, _clsx.default)(classes.linePlot, className)
72
72
  }, other, {
@@ -99,7 +99,7 @@ process.env.NODE_ENV !== "production" ? LinePlot.propTypes /* remove-proptypes *
99
99
  // ----------------------------------------------------------------------
100
100
  /**
101
101
  * Callback fired when a line item is clicked.
102
- * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
102
+ * @param {ChartsActivationEvent<SVGElement>} event The event source of the callback.
103
103
  * @param {LineItemClickIdentifier} lineItemIdentifier The line item identifier.
104
104
  */
105
105
  onItemClick: _propTypes.default.func,
@@ -12,7 +12,7 @@ import { useSkipAnimation } from "../hooks/useSkipAnimation.mjs";
12
12
  import { useXAxes, useYAxes } from "../hooks/index.mjs";
13
13
  import { useInternalIsZoomInteracting } from "../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.mjs";
14
14
  import { useLinePlotData } from "./useLinePlotData.mjs";
15
- import { useLineItemClickHandler } from "./useLineItemClickHandler.mjs";
15
+ import { LINE_ACTIVATION_PRIORITY, useLineItemClickHandler } from "./useLineItemClickHandler.mjs";
16
16
  import { ANIMATION_DURATION_MS, ANIMATION_TIMING_FUNCTION } from "../internals/animation/animation.mjs";
17
17
  import { lineClasses, useUtilityClasses } from "./lineClasses.mjs";
18
18
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -59,7 +59,7 @@ function LinePlot(props) {
59
59
  const skipAnimation = useSkipAnimation(isZoomInteracting || inSkipAnimation);
60
60
  const completedData = useAggregatedData();
61
61
  const classes = useUtilityClasses();
62
- const onLineItemClick = useLineItemClickHandler(onItemClick);
62
+ const onLineItemClick = useLineItemClickHandler(onItemClick, LINE_ACTIVATION_PRIORITY.line);
63
63
  return /*#__PURE__*/_jsx(LinePlotRoot, _extends({
64
64
  className: clsx(classes.linePlot, className)
65
65
  }, other, {
@@ -92,7 +92,7 @@ process.env.NODE_ENV !== "production" ? LinePlot.propTypes /* remove-proptypes *
92
92
  // ----------------------------------------------------------------------
93
93
  /**
94
94
  * Callback fired when a line item is clicked.
95
- * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
95
+ * @param {ChartsActivationEvent<SVGElement>} event The event source of the callback.
96
96
  * @param {LineItemClickIdentifier} lineItemIdentifier The line item identifier.
97
97
  */
98
98
  onItemClick: PropTypes.func,
@@ -1,8 +1,9 @@
1
- import * as React from 'react';
2
1
  import type { WithDataAttributes } from '@mui/utils/types';
2
+ import * as React from 'react';
3
+ import type { MarkPropsOverrides } from "../models/chartsSlotsComponentsProps.mjs";
4
+ import type { ChartsActivationEvent } from "../models/events.mjs";
3
5
  import type { LineItemClickIdentifier } from "../models/seriesType/line.mjs";
4
6
  import type { MarkElementProps } from "./MarkElement.mjs";
5
- import type { MarkPropsOverrides } from "../models/chartsSlotsComponentsProps.mjs";
6
7
  export interface MarkPlotSlots {
7
8
  mark?: React.JSXElementConstructor<MarkElementProps & MarkPropsOverrides>;
8
9
  }
@@ -22,10 +23,10 @@ export interface MarkPlotProps extends React.SVGAttributes<SVGSVGElement>, Pick<
22
23
  slotProps?: MarkPlotSlotProps;
23
24
  /**
24
25
  * Callback fired when a line mark item is clicked.
25
- * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
26
+ * @param {ChartsActivationEvent<SVGElement>} event The event source of the callback.
26
27
  * @param {LineItemClickIdentifier} lineItemIdentifier The line mark item identifier.
27
28
  */
28
- onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier: LineItemClickIdentifier) => void;
29
+ onItemClick?: (event: ChartsActivationEvent<SVGElement>, lineItemIdentifier: LineItemClickIdentifier) => void;
29
30
  }
30
31
  /**
31
32
  * Demos:
@@ -1,8 +1,9 @@
1
- import * as React from 'react';
2
1
  import type { WithDataAttributes } from '@mui/utils/types';
2
+ import * as React from 'react';
3
+ import type { MarkPropsOverrides } from "../models/chartsSlotsComponentsProps.js";
4
+ import type { ChartsActivationEvent } from "../models/events.js";
3
5
  import type { LineItemClickIdentifier } from "../models/seriesType/line.js";
4
6
  import type { MarkElementProps } from "./MarkElement.js";
5
- import type { MarkPropsOverrides } from "../models/chartsSlotsComponentsProps.js";
6
7
  export interface MarkPlotSlots {
7
8
  mark?: React.JSXElementConstructor<MarkElementProps & MarkPropsOverrides>;
8
9
  }
@@ -22,10 +23,10 @@ export interface MarkPlotProps extends React.SVGAttributes<SVGSVGElement>, Pick<
22
23
  slotProps?: MarkPlotSlotProps;
23
24
  /**
24
25
  * Callback fired when a line mark item is clicked.
25
- * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
26
+ * @param {ChartsActivationEvent<SVGElement>} event The event source of the callback.
26
27
  * @param {LineItemClickIdentifier} lineItemIdentifier The line mark item identifier.
27
28
  */
28
- onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier: LineItemClickIdentifier) => void;
29
+ onItemClick?: (event: ChartsActivationEvent<SVGElement>, lineItemIdentifier: LineItemClickIdentifier) => void;
29
30
  }
30
31
  /**
31
32
  * Demos:
@@ -9,19 +9,20 @@ Object.defineProperty(exports, "__esModule", {
9
9
  exports.MarkPlot = MarkPlot;
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
11
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
12
- var _propTypes = _interopRequireDefault(require("prop-types"));
13
- var React = _interopRequireWildcard(require("react"));
14
12
  var _styles = require("@mui/material/styles");
15
13
  var _clsx = _interopRequireDefault(require("clsx"));
14
+ var _propTypes = _interopRequireDefault(require("prop-types"));
15
+ var React = _interopRequireWildcard(require("react"));
16
+ var _ChartsProvider = require("../context/ChartsProvider");
17
+ var _hooks = require("../hooks");
16
18
  var _useSkipAnimation = require("../hooks/useSkipAnimation");
19
+ var _useChartCartesianAxis = require("../internals/plugins/featurePlugins/useChartCartesianAxis");
20
+ var _useInternalIsZoomInteracting = require("../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting");
17
21
  var _CircleMarkElement = require("./CircleMarkElement");
22
+ var _lineClasses = require("./lineClasses");
18
23
  var _MarkElement = require("./MarkElement");
19
- var _hooks = require("../hooks");
20
- var _useInternalIsZoomInteracting = require("../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting");
21
- var _useChartCartesianAxis = require("../internals/plugins/featurePlugins/useChartCartesianAxis");
22
- var _ChartsProvider = require("../context/ChartsProvider");
24
+ var _useLineItemClickHandler = require("./useLineItemClickHandler");
23
25
  var _useMarkPlotData = require("./useMarkPlotData");
24
- var _lineClasses = require("./lineClasses");
25
26
  var _jsxRuntime = require("react/jsx-runtime");
26
27
  const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick", "className"];
27
28
  const MarkPlotRoot = (0, _styles.styled)('g', {
@@ -76,6 +77,14 @@ function MarkPlot(props) {
76
77
  return rep;
77
78
  }, [xAxisHighlightIndexes]);
78
79
  const completedData = (0, _useMarkPlotData.useMarkPlotData)(xAxis, yAxis);
80
+
81
+ // A mark is activatable only where it is actually rendered, so a hidden mark falls through to the
82
+ // line, then the area, matching what a pointer would hit.
83
+ const isMarkRendered = ({
84
+ seriesId,
85
+ dataIndex
86
+ }) => completedData.some(series => series.seriesId === seriesId && !series.hidden && series.marks.some(mark => mark.index === dataIndex));
87
+ (0, _useLineItemClickHandler.useRegisterLineItemActivation)(onItemClick, _useLineItemClickHandler.LINE_ACTIVATION_PRIORITY.mark, isMarkRendered);
79
88
  const classes = (0, _lineClasses.useUtilityClasses)();
80
89
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(MarkPlotRoot, (0, _extends2.default)({
81
90
  className: (0, _clsx.default)(classes.markPlot, className)
@@ -134,7 +143,7 @@ process.env.NODE_ENV !== "production" ? MarkPlot.propTypes /* remove-proptypes *
134
143
  // ----------------------------------------------------------------------
135
144
  /**
136
145
  * Callback fired when a line mark item is clicked.
137
- * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
146
+ * @param {ChartsActivationEvent<SVGElement>} event The event source of the callback.
138
147
  * @param {LineItemClickIdentifier} lineItemIdentifier The line mark item identifier.
139
148
  */
140
149
  onItemClick: _propTypes.default.func,
@@ -3,19 +3,20 @@
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
5
  const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick", "className"];
6
- import PropTypes from 'prop-types';
7
- import * as React from 'react';
8
6
  import { styled } from '@mui/material/styles';
9
7
  import clsx from 'clsx';
8
+ import PropTypes from 'prop-types';
9
+ import * as React from 'react';
10
+ import { useChartsContext } from "../context/ChartsProvider/index.mjs";
11
+ import { useItemHighlightStateGetter, useXAxes, useYAxes } from "../hooks/index.mjs";
10
12
  import { useSkipAnimation } from "../hooks/useSkipAnimation.mjs";
13
+ import { selectorChartsHighlightXAxisIndex } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.mjs";
14
+ import { useInternalIsZoomInteracting } from "../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.mjs";
11
15
  import { CircleMarkElement } from "./CircleMarkElement.mjs";
16
+ import { useUtilityClasses } from "./lineClasses.mjs";
12
17
  import { MarkElement } from "./MarkElement.mjs";
13
- import { useItemHighlightStateGetter, useXAxes, useYAxes } from "../hooks/index.mjs";
14
- import { useInternalIsZoomInteracting } from "../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.mjs";
15
- import { selectorChartsHighlightXAxisIndex } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.mjs";
16
- import { useChartsContext } from "../context/ChartsProvider/index.mjs";
18
+ import { LINE_ACTIVATION_PRIORITY, useRegisterLineItemActivation } from "./useLineItemClickHandler.mjs";
17
19
  import { useMarkPlotData } from "./useMarkPlotData.mjs";
18
- import { useUtilityClasses } from "./lineClasses.mjs";
19
20
  import { jsx as _jsx } from "react/jsx-runtime";
20
21
  const MarkPlotRoot = styled('g', {
21
22
  name: 'MuiMarkPlot',
@@ -69,6 +70,14 @@ function MarkPlot(props) {
69
70
  return rep;
70
71
  }, [xAxisHighlightIndexes]);
71
72
  const completedData = useMarkPlotData(xAxis, yAxis);
73
+
74
+ // A mark is activatable only where it is actually rendered, so a hidden mark falls through to the
75
+ // line, then the area, matching what a pointer would hit.
76
+ const isMarkRendered = ({
77
+ seriesId,
78
+ dataIndex
79
+ }) => completedData.some(series => series.seriesId === seriesId && !series.hidden && series.marks.some(mark => mark.index === dataIndex));
80
+ useRegisterLineItemActivation(onItemClick, LINE_ACTIVATION_PRIORITY.mark, isMarkRendered);
72
81
  const classes = useUtilityClasses();
73
82
  return /*#__PURE__*/_jsx(MarkPlotRoot, _extends({
74
83
  className: clsx(classes.markPlot, className)
@@ -127,7 +136,7 @@ process.env.NODE_ENV !== "production" ? MarkPlot.propTypes /* remove-proptypes *
127
136
  // ----------------------------------------------------------------------
128
137
  /**
129
138
  * Callback fired when a line mark item is clicked.
130
- * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
139
+ * @param {ChartsActivationEvent<SVGElement>} event The event source of the callback.
131
140
  * @param {LineItemClickIdentifier} lineItemIdentifier The line mark item identifier.
132
141
  */
133
142
  onItemClick: PropTypes.func,
@@ -1,6 +1,25 @@
1
1
  import * as React from 'react';
2
2
  import type { LineItemClickIdentifier } from "../models/seriesType/line.mjs";
3
3
  import type { SeriesId } from "../models/seriesType/common.mjs";
4
+ import type { ChartsActivationEvent } from "../models/events.mjs";
5
+ /**
6
+ * Priorities matching the pointer hit-testing order: marks sit above lines, lines above areas.
7
+ * The topmost callback a pointer would reach is the one keyboard activation fires.
8
+ */
9
+ export declare const LINE_ACTIVATION_PRIORITY: {
10
+ mark: number;
11
+ line: number;
12
+ area: number;
13
+ };
14
+ /**
15
+ * Registers <kbd>Enter</kbd>/<kbd>Space</kbd> activation of the focused line item.
16
+ */
17
+ export declare function useRegisterLineItemActivation(onItemClick: ((event: ChartsActivationEvent<SVGElement>, lineItemIdentifier: LineItemClickIdentifier) => void) | undefined, priority: number,
18
+ /**
19
+ * Declines items the caller does not render, so activation falls through to the next handler.
20
+ * Used by the mark plot: a mark that is not shown should defer to the line, then the area.
21
+ */
22
+ canActivate?: (item: LineItemClickIdentifier) => boolean): void;
4
23
  /**
5
24
  * Creates a click handler for line and area paths that enriches the item
6
25
  * identifier with the `dataIndex` of the closest data point along the x-axis.
@@ -9,4 +28,9 @@ import type { SeriesId } from "../models/seriesType/common.mjs";
9
28
  * axis interaction (tooltip, highlight, `onAxisClick`). The callback is not
10
29
  * fired when the click position cannot be associated with a data point.
11
30
  */
12
- export declare function useLineItemClickHandler(onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier: LineItemClickIdentifier) => void): ((event: React.MouseEvent<SVGElement, MouseEvent>, seriesId: SeriesId) => void) | undefined;
31
+ export declare function useLineItemClickHandler(onItemClick: ((event: ChartsActivationEvent<SVGElement>, lineItemIdentifier: LineItemClickIdentifier) => void) | undefined, priority: number,
32
+ /**
33
+ * Declines items the caller does not render, so activation falls through to the next handler.
34
+ * The area plot uses it to defer when the series has no area drawn.
35
+ */
36
+ canActivate?: (item: LineItemClickIdentifier) => boolean): ((event: React.MouseEvent<SVGElement, MouseEvent>, seriesId: SeriesId) => void) | undefined;
@@ -1,6 +1,25 @@
1
1
  import * as React from 'react';
2
2
  import type { LineItemClickIdentifier } from "../models/seriesType/line.js";
3
3
  import type { SeriesId } from "../models/seriesType/common.js";
4
+ import type { ChartsActivationEvent } from "../models/events.js";
5
+ /**
6
+ * Priorities matching the pointer hit-testing order: marks sit above lines, lines above areas.
7
+ * The topmost callback a pointer would reach is the one keyboard activation fires.
8
+ */
9
+ export declare const LINE_ACTIVATION_PRIORITY: {
10
+ mark: number;
11
+ line: number;
12
+ area: number;
13
+ };
14
+ /**
15
+ * Registers <kbd>Enter</kbd>/<kbd>Space</kbd> activation of the focused line item.
16
+ */
17
+ export declare function useRegisterLineItemActivation(onItemClick: ((event: ChartsActivationEvent<SVGElement>, lineItemIdentifier: LineItemClickIdentifier) => void) | undefined, priority: number,
18
+ /**
19
+ * Declines items the caller does not render, so activation falls through to the next handler.
20
+ * Used by the mark plot: a mark that is not shown should defer to the line, then the area.
21
+ */
22
+ canActivate?: (item: LineItemClickIdentifier) => boolean): void;
4
23
  /**
5
24
  * Creates a click handler for line and area paths that enriches the item
6
25
  * identifier with the `dataIndex` of the closest data point along the x-axis.
@@ -9,4 +28,9 @@ import type { SeriesId } from "../models/seriesType/common.js";
9
28
  * axis interaction (tooltip, highlight, `onAxisClick`). The callback is not
10
29
  * fired when the click position cannot be associated with a data point.
11
30
  */
12
- export declare function useLineItemClickHandler(onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier: LineItemClickIdentifier) => void): ((event: React.MouseEvent<SVGElement, MouseEvent>, seriesId: SeriesId) => void) | undefined;
31
+ export declare function useLineItemClickHandler(onItemClick: ((event: ChartsActivationEvent<SVGElement>, lineItemIdentifier: LineItemClickIdentifier) => void) | undefined, priority: number,
32
+ /**
33
+ * Declines items the caller does not render, so activation falls through to the next handler.
34
+ * The area plot uses it to defer when the series has no area drawn.
35
+ */
36
+ canActivate?: (item: LineItemClickIdentifier) => boolean): ((event: React.MouseEvent<SVGElement, MouseEvent>, seriesId: SeriesId) => void) | undefined;
@@ -5,13 +5,54 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ exports.LINE_ACTIVATION_PRIORITY = void 0;
8
9
  exports.useLineItemClickHandler = useLineItemClickHandler;
10
+ exports.useRegisterLineItemActivation = useRegisterLineItemActivation;
9
11
  var React = _interopRequireWildcard(require("react"));
10
12
  var _useChartsLayerContainerRef = require("../hooks/useChartsLayerContainerRef");
11
13
  var _useAxis = require("../hooks/useAxis");
12
14
  var _useLineSeries = require("../hooks/useLineSeries");
13
15
  var _getChartPoint = require("../internals/getChartPoint");
14
16
  var _getAxisValue = require("../internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue");
17
+ var _useRegisterItemActivation = require("../internals/useRegisterItemActivation");
18
+ /**
19
+ * Priorities matching the pointer hit-testing order: marks sit above lines, lines above areas.
20
+ * The topmost callback a pointer would reach is the one keyboard activation fires.
21
+ */
22
+ const LINE_ACTIVATION_PRIORITY = exports.LINE_ACTIVATION_PRIORITY = {
23
+ mark: 2,
24
+ line: 1,
25
+ area: 0
26
+ };
27
+
28
+ /**
29
+ * Registers <kbd>Enter</kbd>/<kbd>Space</kbd> activation of the focused line item.
30
+ */
31
+ function useRegisterLineItemActivation(onItemClick, priority,
32
+ /**
33
+ * Declines items the caller does not render, so activation falls through to the next handler.
34
+ * Used by the mark plot: a mark that is not shown should defer to the line, then the area.
35
+ */
36
+ canActivate) {
37
+ (0, _useRegisterItemActivation.useRegisterItemActivation)({
38
+ type: 'line',
39
+ priority,
40
+ canActivate: canActivate && (item => {
41
+ // The dispatcher matches the `line` type before calling this, so the item is a line item.
42
+ const lineItem = item;
43
+ return canActivate({
44
+ type: 'line',
45
+ seriesId: lineItem.seriesId,
46
+ dataIndex: lineItem.dataIndex
47
+ });
48
+ })
49
+ }, onItemClick && ((event, item) => onItemClick(event, {
50
+ type: 'line',
51
+ seriesId: item.seriesId,
52
+ dataIndex: item.dataIndex
53
+ })));
54
+ }
55
+
15
56
  /**
16
57
  * Creates a click handler for line and area paths that enriches the item
17
58
  * identifier with the `dataIndex` of the closest data point along the x-axis.
@@ -20,7 +61,13 @@ var _getAxisValue = require("../internals/plugins/featurePlugins/useChartCartesi
20
61
  * axis interaction (tooltip, highlight, `onAxisClick`). The callback is not
21
62
  * fired when the click position cannot be associated with a data point.
22
63
  */
23
- function useLineItemClickHandler(onItemClick) {
64
+ function useLineItemClickHandler(onItemClick, priority,
65
+ /**
66
+ * Declines items the caller does not render, so activation falls through to the next handler.
67
+ * The area plot uses it to defer when the series has no area drawn.
68
+ */
69
+ canActivate) {
70
+ useRegisterLineItemActivation(onItemClick, priority, canActivate);
24
71
  const chartsLayerContainerRef = (0, _useChartsLayerContainerRef.useChartsLayerContainerRef)();
25
72
  const {
26
73
  xAxis: xAxes,
@@ -6,6 +6,46 @@ import { useXAxes } from "../hooks/useAxis.mjs";
6
6
  import { useLineSeriesContext } from "../hooks/useLineSeries.mjs";
7
7
  import { getChartPoint } from "../internals/getChartPoint.mjs";
8
8
  import { getAxisIndex } from "../internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.mjs";
9
+ import { useRegisterItemActivation } from "../internals/useRegisterItemActivation.mjs";
10
+
11
+ /**
12
+ * Priorities matching the pointer hit-testing order: marks sit above lines, lines above areas.
13
+ * The topmost callback a pointer would reach is the one keyboard activation fires.
14
+ */
15
+ export const LINE_ACTIVATION_PRIORITY = {
16
+ mark: 2,
17
+ line: 1,
18
+ area: 0
19
+ };
20
+
21
+ /**
22
+ * Registers <kbd>Enter</kbd>/<kbd>Space</kbd> activation of the focused line item.
23
+ */
24
+ export function useRegisterLineItemActivation(onItemClick, priority,
25
+ /**
26
+ * Declines items the caller does not render, so activation falls through to the next handler.
27
+ * Used by the mark plot: a mark that is not shown should defer to the line, then the area.
28
+ */
29
+ canActivate) {
30
+ useRegisterItemActivation({
31
+ type: 'line',
32
+ priority,
33
+ canActivate: canActivate && (item => {
34
+ // The dispatcher matches the `line` type before calling this, so the item is a line item.
35
+ const lineItem = item;
36
+ return canActivate({
37
+ type: 'line',
38
+ seriesId: lineItem.seriesId,
39
+ dataIndex: lineItem.dataIndex
40
+ });
41
+ })
42
+ }, onItemClick && ((event, item) => onItemClick(event, {
43
+ type: 'line',
44
+ seriesId: item.seriesId,
45
+ dataIndex: item.dataIndex
46
+ })));
47
+ }
48
+
9
49
  /**
10
50
  * Creates a click handler for line and area paths that enriches the item
11
51
  * identifier with the `dataIndex` of the closest data point along the x-axis.
@@ -14,7 +54,13 @@ import { getAxisIndex } from "../internals/plugins/featurePlugins/useChartCartes
14
54
  * axis interaction (tooltip, highlight, `onAxisClick`). The callback is not
15
55
  * fired when the click position cannot be associated with a data point.
16
56
  */
17
- export function useLineItemClickHandler(onItemClick) {
57
+ export function useLineItemClickHandler(onItemClick, priority,
58
+ /**
59
+ * Declines items the caller does not render, so activation falls through to the next handler.
60
+ * The area plot uses it to defer when the series has no area drawn.
61
+ */
62
+ canActivate) {
63
+ useRegisterLineItemActivation(onItemClick, priority, canActivate);
18
64
  const chartsLayerContainerRef = useChartsLayerContainerRef();
19
65
  const {
20
66
  xAxis: xAxes,
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
  import type { WithDataAttributes } from '@mui/utils/types';
3
3
  import type { PieArcProps } from "./PieArc.mjs";
4
4
  import type { ComputedPieRadius, DefaultizedPieSeriesType, DefaultizedPieValueType, PieItemIdentifier } from "../models/seriesType/pie.mjs";
5
+ import type { ChartsActivationEvent } from "../models/events.mjs";
5
6
  import type { PieArcPropsOverrides } from "../models/chartsSlotsComponentsProps.mjs";
6
7
  export interface PieArcPlotSlots {
7
8
  pieArc?: React.JSXElementConstructor<PieArcProps & PieArcPropsOverrides>;
@@ -31,11 +32,11 @@ export interface PieArcPlotProps extends Pick<DefaultizedPieSeriesType, 'data' |
31
32
  slotProps?: PieArcPlotSlotProps;
32
33
  /**
33
34
  * Callback fired when a pie item is clicked.
34
- * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
35
+ * @param {ChartsActivationEvent<SVGPathElement>} event The event source of the callback.
35
36
  * @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
36
37
  * @param {DefaultizedPieValueType} item The pie item.
37
38
  */
38
- onItemClick?: (event: React.MouseEvent<SVGPathElement, MouseEvent>, pieItemIdentifier: PieItemIdentifier, item: DefaultizedPieValueType) => void;
39
+ onItemClick?: (event: ChartsActivationEvent<SVGPathElement>, pieItemIdentifier: PieItemIdentifier, item: DefaultizedPieValueType) => void;
39
40
  /**
40
41
  * If `true`, animations are skipped.
41
42
  * @default false
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
  import type { WithDataAttributes } from '@mui/utils/types';
3
3
  import type { PieArcProps } from "./PieArc.js";
4
4
  import type { ComputedPieRadius, DefaultizedPieSeriesType, DefaultizedPieValueType, PieItemIdentifier } from "../models/seriesType/pie.js";
5
+ import type { ChartsActivationEvent } from "../models/events.js";
5
6
  import type { PieArcPropsOverrides } from "../models/chartsSlotsComponentsProps.js";
6
7
  export interface PieArcPlotSlots {
7
8
  pieArc?: React.JSXElementConstructor<PieArcProps & PieArcPropsOverrides>;
@@ -31,11 +32,11 @@ export interface PieArcPlotProps extends Pick<DefaultizedPieSeriesType, 'data' |
31
32
  slotProps?: PieArcPlotSlotProps;
32
33
  /**
33
34
  * Callback fired when a pie item is clicked.
34
- * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
35
+ * @param {ChartsActivationEvent<SVGPathElement>} event The event source of the callback.
35
36
  * @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
36
37
  * @param {DefaultizedPieValueType} item The pie item.
37
38
  */
38
- onItemClick?: (event: React.MouseEvent<SVGPathElement, MouseEvent>, pieItemIdentifier: PieItemIdentifier, item: DefaultizedPieValueType) => void;
39
+ onItemClick?: (event: ChartsActivationEvent<SVGPathElement>, pieItemIdentifier: PieItemIdentifier, item: DefaultizedPieValueType) => void;
39
40
  /**
40
41
  * If `true`, animations are skipped.
41
42
  * @default false