@mui/x-charts 8.22.0 → 8.23.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 (238) hide show
  1. package/BarChart/BarElement.js +1 -1
  2. package/BarChart/BarLabel/BarLabel.types.d.ts +3 -3
  3. package/BarChart/BarLabel/BarLabelItem.d.ts +1 -1
  4. package/BarChart/BarLabel/BarLabelPlot.d.ts +9 -9
  5. package/BarChart/BarLabel/getBarLabel.d.ts +3 -3
  6. package/BarChart/FocusedBar.js +1 -1
  7. package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +18 -1
  8. package/BarChart/seriesConfig/bar/keyboardFocusHandler.d.ts +3 -0
  9. package/BarChart/seriesConfig/bar/keyboardFocusHandler.js +23 -0
  10. package/BarChart/seriesConfig/bar/seriesProcessor.js +2 -2
  11. package/BarChart/seriesConfig/index.js +3 -1
  12. package/CHANGELOG.md +202 -0
  13. package/ChartsAxisHighlight/ChartsXAxisHighlight.js +2 -3
  14. package/ChartsAxisHighlight/ChartsYAxisHighlight.js +2 -3
  15. package/ChartsBrushOverlay/ChartsBrushOverlay.js +6 -7
  16. package/ChartsSurface/ChartsSurface.js +7 -8
  17. package/ChartsTooltip/ChartsTooltipContainer.js +4 -5
  18. package/ChartsTooltip/useAxisTooltip.js +3 -4
  19. package/ChartsTooltip/useItemTooltip.js +2 -3
  20. package/ChartsWrapper/ChartsWrapper.js +2 -3
  21. package/LineChart/FocusedLineMark.js +1 -1
  22. package/LineChart/LineHighlightPlot.js +1 -2
  23. package/LineChart/MarkPlot.js +1 -2
  24. package/LineChart/seriesConfig/index.js +3 -1
  25. package/LineChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
  26. package/LineChart/seriesConfig/keyboardFocusHandler.js +23 -0
  27. package/LineChart/seriesConfig/seriesProcessor.js +2 -2
  28. package/PieChart/FocusedPieArc.d.ts +2 -0
  29. package/PieChart/FocusedPieArc.js +58 -0
  30. package/PieChart/PieArcPlot.js +3 -31
  31. package/PieChart/PieChart.js +2 -1
  32. package/PieChart/dataTransform/getModifiedArcProperties.d.ts +11 -0
  33. package/PieChart/dataTransform/getModifiedArcProperties.js +42 -0
  34. package/PieChart/dataTransform/useTransformData.js +16 -21
  35. package/PieChart/seriesConfig/index.js +3 -1
  36. package/PieChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
  37. package/PieChart/seriesConfig/keyboardFocusHandler.js +23 -0
  38. package/PieChart/seriesConfig/tooltipPosition.js +11 -20
  39. package/RadarChart/RadarAxis/useRadarAxis.js +1 -2
  40. package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +3 -4
  41. package/RadarChart/RadarGrid/useRadarGridData.js +1 -2
  42. package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +1 -2
  43. package/ScatterChart/BatchScatter.js +4 -5
  44. package/ScatterChart/FocusedScatterMark.js +1 -1
  45. package/ScatterChart/Scatter.js +1 -2
  46. package/ScatterChart/seriesConfig/index.js +3 -1
  47. package/ScatterChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
  48. package/ScatterChart/seriesConfig/keyboardFocusHandler.js +23 -0
  49. package/esm/BarChart/BarElement.js +1 -1
  50. package/esm/BarChart/BarLabel/BarLabel.types.d.ts +3 -3
  51. package/esm/BarChart/BarLabel/BarLabelItem.d.ts +1 -1
  52. package/esm/BarChart/BarLabel/BarLabelPlot.d.ts +9 -9
  53. package/esm/BarChart/BarLabel/getBarLabel.d.ts +3 -3
  54. package/esm/BarChart/FocusedBar.js +1 -1
  55. package/esm/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +18 -1
  56. package/esm/BarChart/seriesConfig/bar/keyboardFocusHandler.d.ts +3 -0
  57. package/esm/BarChart/seriesConfig/bar/keyboardFocusHandler.js +17 -0
  58. package/esm/BarChart/seriesConfig/bar/seriesProcessor.js +1 -1
  59. package/esm/BarChart/seriesConfig/index.js +3 -1
  60. package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.js +2 -3
  61. package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.js +2 -3
  62. package/esm/ChartsBrushOverlay/ChartsBrushOverlay.js +6 -7
  63. package/esm/ChartsSurface/ChartsSurface.js +7 -8
  64. package/esm/ChartsTooltip/ChartsTooltipContainer.js +4 -5
  65. package/esm/ChartsTooltip/useAxisTooltip.js +3 -4
  66. package/esm/ChartsTooltip/useItemTooltip.js +2 -3
  67. package/esm/ChartsWrapper/ChartsWrapper.js +2 -3
  68. package/esm/LineChart/FocusedLineMark.js +1 -1
  69. package/esm/LineChart/LineHighlightPlot.js +1 -2
  70. package/esm/LineChart/MarkPlot.js +1 -2
  71. package/esm/LineChart/seriesConfig/index.js +3 -1
  72. package/esm/LineChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
  73. package/esm/LineChart/seriesConfig/keyboardFocusHandler.js +17 -0
  74. package/esm/LineChart/seriesConfig/seriesProcessor.js +1 -1
  75. package/esm/PieChart/FocusedPieArc.d.ts +2 -0
  76. package/esm/PieChart/FocusedPieArc.js +51 -0
  77. package/esm/PieChart/PieArcPlot.js +5 -33
  78. package/esm/PieChart/PieChart.js +2 -1
  79. package/esm/PieChart/dataTransform/getModifiedArcProperties.d.ts +11 -0
  80. package/esm/PieChart/dataTransform/getModifiedArcProperties.js +36 -0
  81. package/esm/PieChart/dataTransform/useTransformData.js +16 -21
  82. package/esm/PieChart/seriesConfig/index.js +3 -1
  83. package/esm/PieChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
  84. package/esm/PieChart/seriesConfig/keyboardFocusHandler.js +17 -0
  85. package/esm/PieChart/seriesConfig/tooltipPosition.js +11 -20
  86. package/esm/RadarChart/RadarAxis/useRadarAxis.js +1 -2
  87. package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +3 -4
  88. package/esm/RadarChart/RadarGrid/useRadarGridData.js +1 -2
  89. package/esm/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +1 -2
  90. package/esm/ScatterChart/BatchScatter.js +4 -5
  91. package/esm/ScatterChart/FocusedScatterMark.js +1 -1
  92. package/esm/ScatterChart/Scatter.js +1 -2
  93. package/esm/ScatterChart/seriesConfig/index.js +3 -1
  94. package/esm/ScatterChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
  95. package/esm/ScatterChart/seriesConfig/keyboardFocusHandler.js +17 -0
  96. package/esm/hooks/useAxis.js +8 -9
  97. package/esm/hooks/useAxisSystem.js +2 -3
  98. package/esm/hooks/useBrush.js +1 -2
  99. package/esm/hooks/useChartId.js +1 -2
  100. package/esm/hooks/useDataset.js +1 -2
  101. package/esm/hooks/useDrawingArea.js +1 -2
  102. package/esm/hooks/useFocusedItem.d.ts +1 -12
  103. package/esm/hooks/useFocusedItem.js +3 -11
  104. package/esm/hooks/useInteractionItemProps.d.ts +3 -2
  105. package/esm/hooks/useInteractionItemProps.js +13 -2
  106. package/esm/hooks/useIsItemFocused.d.ts +4 -3
  107. package/esm/hooks/useIsItemFocused.js +2 -3
  108. package/esm/hooks/useIsItemFocusedGetter.d.ts +3 -2
  109. package/esm/hooks/useIsItemFocusedGetter.js +2 -1
  110. package/esm/hooks/useItemHighlighted.js +2 -3
  111. package/esm/hooks/useItemHighlightedGetter.js +2 -3
  112. package/esm/hooks/useLegend.js +1 -2
  113. package/esm/hooks/usePieSeries.js +1 -2
  114. package/esm/hooks/useSeries.js +1 -2
  115. package/esm/hooks/useSkipAnimation.js +1 -2
  116. package/esm/hooks/useZAxis.js +1 -2
  117. package/esm/index.js +1 -1
  118. package/esm/internals/commonNextFocusItem.d.ts +14 -0
  119. package/esm/internals/commonNextFocusItem.js +84 -0
  120. package/esm/internals/index.d.ts +1 -2
  121. package/esm/internals/index.js +1 -2
  122. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +1 -2
  123. package/esm/internals/plugins/corePlugins/useChartSeries/useColorProcessor.js +1 -2
  124. package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +1 -2
  125. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +5 -6
  126. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.js +1 -2
  127. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +5 -6
  128. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +4 -1
  129. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.d.ts +13 -0
  130. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.js +1 -0
  131. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.d.ts +2 -2
  132. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +12 -105
  133. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +5 -31
  134. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +9 -15
  135. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +6 -21
  136. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.d.ts +15 -0
  137. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.js +45 -0
  138. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.d.ts +11 -0
  139. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.js +40 -0
  140. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +6 -7
  141. package/esm/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +1 -9
  142. package/esm/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.js +2 -2
  143. package/esm/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.types.d.ts +7 -6
  144. package/esm/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +2 -0
  145. package/esm/internals/plugins/models/seriesConfig/seriesProcessor.types.d.ts +1 -1
  146. package/esm/internals/plugins/models/seriesConfig/tooltipGetter.types.d.ts +4 -3
  147. package/esm/internals/plugins/models/seriesConfig/tooltipItemPositionGetter.types.d.ts +3 -2
  148. package/esm/internals/seriesHasData.d.ts +4 -0
  149. package/esm/internals/seriesHasData.js +8 -0
  150. package/esm/internals/seriesSelectorOfType.js +2 -3
  151. package/esm/internals/stacking/index.d.ts +1 -0
  152. package/esm/internals/stacking/index.js +1 -0
  153. package/esm/internals/stacking/offset/index.d.ts +1 -0
  154. package/esm/internals/stacking/offset/index.js +1 -0
  155. package/esm/internals/stacking/offset/offsetDiverging.d.ts +8 -0
  156. package/esm/internals/stacking/offset/offsetDiverging.js +47 -0
  157. package/esm/internals/{stackSeries.d.ts → stacking/stackSeries.d.ts} +8 -8
  158. package/esm/internals/{stackSeries.js → stacking/stackSeries.js} +8 -6
  159. package/esm/models/seriesType/config.d.ts +0 -2
  160. package/esm/models/seriesType/index.d.ts +3 -1
  161. package/hooks/useAxis.js +8 -9
  162. package/hooks/useAxisSystem.js +2 -3
  163. package/hooks/useBrush.js +1 -2
  164. package/hooks/useChartId.js +1 -2
  165. package/hooks/useDataset.js +1 -2
  166. package/hooks/useDrawingArea.js +1 -2
  167. package/hooks/useFocusedItem.d.ts +1 -12
  168. package/hooks/useFocusedItem.js +1 -11
  169. package/hooks/useInteractionItemProps.d.ts +3 -2
  170. package/hooks/useInteractionItemProps.js +13 -2
  171. package/hooks/useIsItemFocused.d.ts +4 -3
  172. package/hooks/useIsItemFocused.js +2 -3
  173. package/hooks/useIsItemFocusedGetter.d.ts +3 -2
  174. package/hooks/useIsItemFocusedGetter.js +2 -1
  175. package/hooks/useItemHighlighted.js +2 -3
  176. package/hooks/useItemHighlightedGetter.js +2 -3
  177. package/hooks/useLegend.js +1 -2
  178. package/hooks/usePieSeries.js +1 -2
  179. package/hooks/useSeries.js +1 -2
  180. package/hooks/useSkipAnimation.js +1 -2
  181. package/hooks/useZAxis.js +1 -2
  182. package/index.js +1 -1
  183. package/internals/commonNextFocusItem.d.ts +14 -0
  184. package/internals/commonNextFocusItem.js +93 -0
  185. package/internals/index.d.ts +1 -2
  186. package/internals/index.js +4 -16
  187. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +1 -2
  188. package/internals/plugins/corePlugins/useChartSeries/useColorProcessor.js +1 -2
  189. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +1 -2
  190. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +5 -6
  191. package/internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.js +1 -2
  192. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +5 -6
  193. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +4 -1
  194. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.d.ts +13 -0
  195. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.js +5 -0
  196. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.d.ts +2 -2
  197. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +11 -104
  198. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +5 -31
  199. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +10 -16
  200. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +6 -21
  201. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.d.ts +15 -0
  202. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.js +51 -0
  203. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.d.ts +11 -0
  204. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.js +46 -0
  205. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +6 -7
  206. package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +1 -9
  207. package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.js +1 -1
  208. package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.types.d.ts +7 -6
  209. package/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +2 -0
  210. package/internals/plugins/models/seriesConfig/seriesProcessor.types.d.ts +1 -1
  211. package/internals/plugins/models/seriesConfig/tooltipGetter.types.d.ts +4 -3
  212. package/internals/plugins/models/seriesConfig/tooltipItemPositionGetter.types.d.ts +3 -2
  213. package/internals/seriesHasData.d.ts +4 -0
  214. package/internals/seriesHasData.js +14 -0
  215. package/internals/seriesSelectorOfType.js +2 -3
  216. package/internals/stacking/index.d.ts +1 -0
  217. package/internals/stacking/index.js +16 -0
  218. package/internals/stacking/offset/index.d.ts +1 -0
  219. package/internals/stacking/offset/index.js +16 -0
  220. package/internals/stacking/offset/offsetDiverging.d.ts +8 -0
  221. package/internals/stacking/offset/offsetDiverging.js +53 -0
  222. package/internals/{stackSeries.d.ts → stacking/stackSeries.d.ts} +8 -8
  223. package/internals/{stackSeries.js → stacking/stackSeries.js} +3 -1
  224. package/models/seriesType/config.d.ts +0 -2
  225. package/models/seriesType/index.d.ts +3 -1
  226. package/package.json +4 -4
  227. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.d.ts +0 -3
  228. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.js +0 -4
  229. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +0 -21
  230. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +0 -92
  231. package/esm/internals/store/useSelector.d.ts +0 -2
  232. package/esm/internals/store/useSelector.js +0 -2
  233. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.d.ts +0 -3
  234. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.js +0 -10
  235. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +0 -21
  236. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +0 -99
  237. package/internals/store/useSelector.d.ts +0 -2
  238. package/internals/store/useSelector.js +0 -8
@@ -1,7 +1,6 @@
1
1
  'use client';
2
2
 
3
3
  import { useStore } from "../internals/store/useStore.js";
4
- import { useSelector } from "../internals/store/useSelector.js";
5
4
  import { selectorChartsIsFaded, selectorChartsIsHighlighted } from "../internals/plugins/featurePlugins/useChartHighlight/index.js";
6
5
  /**
7
6
  * A hook to check the highlighted state of the item.
@@ -14,8 +13,8 @@ import { selectorChartsIsFaded, selectorChartsIsHighlighted } from "../internals
14
13
  */
15
14
  export function useItemHighlighted(item) {
16
15
  const store = useStore();
17
- const isHighlighted = useSelector(store, selectorChartsIsHighlighted, item);
18
- const isFaded = useSelector(store, selectorChartsIsFaded, item);
16
+ const isHighlighted = store.use(selectorChartsIsHighlighted, item);
17
+ const isFaded = store.use(selectorChartsIsFaded, item);
19
18
  return {
20
19
  isHighlighted,
21
20
  isFaded: !isHighlighted && isFaded
@@ -1,6 +1,5 @@
1
1
  'use client';
2
2
 
3
- import { useSelector } from "../internals/store/useSelector.js";
4
3
  import { useStore } from "../internals/store/useStore.js";
5
4
  import { selectorChartsIsFadedCallback, selectorChartsIsHighlightedCallback } from "../internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js";
6
5
  /**
@@ -13,8 +12,8 @@ import { selectorChartsIsFadedCallback, selectorChartsIsHighlightedCallback } fr
13
12
  */
14
13
  export function useItemHighlightedGetter() {
15
14
  const store = useStore();
16
- const isHighlighted = useSelector(store, selectorChartsIsHighlightedCallback);
17
- const isFaded = useSelector(store, selectorChartsIsFadedCallback);
15
+ const isHighlighted = store.use(selectorChartsIsHighlightedCallback);
16
+ const isFaded = store.use(selectorChartsIsFadedCallback);
18
17
  return {
19
18
  isHighlighted,
20
19
  isFaded
@@ -3,7 +3,6 @@
3
3
  import { selectorChartSeriesConfig } from "../internals/plugins/corePlugins/useChartSeries/index.js";
4
4
  import { useSeries } from "./useSeries.js";
5
5
  import { useStore } from "../internals/store/useStore.js";
6
- import { useSelector } from "../internals/store/useSelector.js";
7
6
  function getSeriesToDisplay(series, seriesConfig) {
8
7
  return Object.keys(series).flatMap(seriesType => {
9
8
  const getter = seriesConfig[seriesType].legendGetter;
@@ -23,7 +22,7 @@ function getSeriesToDisplay(series, seriesConfig) {
23
22
  export function useLegend() {
24
23
  const series = useSeries();
25
24
  const store = useStore();
26
- const seriesConfig = useSelector(store, selectorChartSeriesConfig);
25
+ const seriesConfig = store.use(selectorChartSeriesConfig);
27
26
  return {
28
27
  items: getSeriesToDisplay(series, seriesConfig)
29
28
  };
@@ -3,7 +3,6 @@
3
3
  import { useSeriesOfType, useAllSeriesOfType } from "../internals/seriesSelectorOfType.js";
4
4
  import { useStore } from "../internals/store/useStore.js";
5
5
  import { selectorChartSeriesLayout } from "../internals/plugins/corePlugins/useChartSeries/index.js";
6
- import { useSelector } from "../internals/store/useSelector.js";
7
6
 
8
7
  /**
9
8
  * Get access to the internal state of pie series.
@@ -48,6 +47,6 @@ export function usePieSeriesContext() {
48
47
  */
49
48
  export function usePieSeriesLayout() {
50
49
  const store = useStore();
51
- const seriesLayout = useSelector(store, selectorChartSeriesLayout);
50
+ const seriesLayout = store.use(selectorChartSeriesLayout);
52
51
  return seriesLayout.pie ?? {};
53
52
  }
@@ -1,7 +1,6 @@
1
1
  'use client';
2
2
 
3
3
  import { useStore } from "../internals/store/useStore.js";
4
- import { useSelector } from "../internals/store/useSelector.js";
5
4
  import { selectorChartSeriesProcessed } from "../internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.js";
6
5
  /**
7
6
  * Get access to the internal state of series.
@@ -11,5 +10,5 @@ import { selectorChartSeriesProcessed } from "../internals/plugins/corePlugins/u
11
10
  */
12
11
  export function useSeries() {
13
12
  const store = useStore();
14
- return useSelector(store, selectorChartSeriesProcessed);
13
+ return store.use(selectorChartSeriesProcessed);
15
14
  }
@@ -2,7 +2,6 @@
2
2
 
3
3
  import { selectorChartSkipAnimation } from "../internals/plugins/corePlugins/useChartAnimation/index.js";
4
4
  import { useStore } from "../internals/store/useStore.js";
5
- import { useSelector } from "../internals/store/useSelector.js";
6
5
 
7
6
  /**
8
7
  * A hook to get if chart animations should be skipped.
@@ -11,6 +10,6 @@ import { useSelector } from "../internals/store/useSelector.js";
11
10
  */
12
11
  export function useSkipAnimation(skipAnimation) {
13
12
  const store = useStore();
14
- const storeSkipAnimation = useSelector(store, selectorChartSkipAnimation);
13
+ const storeSkipAnimation = store.use(selectorChartSkipAnimation);
15
14
  return skipAnimation || storeSkipAnimation;
16
15
  }
@@ -2,13 +2,12 @@
2
2
 
3
3
  import { useStore } from "../internals/store/useStore.js";
4
4
  import { selectorChartZAxis } from "../internals/plugins/featurePlugins/useChartZAxis/index.js";
5
- import { useSelector } from "../internals/store/useSelector.js";
6
5
  export function useZAxes() {
7
6
  const store = useStore();
8
7
  const {
9
8
  axis: zAxis,
10
9
  axisIds: zAxisIds
11
- } = useSelector(store, selectorChartZAxis) ?? {
10
+ } = store.use(selectorChartZAxis) ?? {
12
11
  axis: {},
13
12
  axisIds: []
14
13
  };
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v8.22.0
2
+ * @mui/x-charts v8.23.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -0,0 +1,14 @@
1
+ import type { UseChartKeyboardNavigationSignature } from "./plugins/featurePlugins/useChartKeyboardNavigation/index.js";
2
+ import type { ChartState } from "./plugins/models/chart.js";
3
+ import type { ChartSeriesType } from "../models/seriesType/config.js";
4
+ import type { FocusedItemIdentifier, SeriesId, SeriesItemIdentifier } from "../models/seriesType/index.js";
5
+ type ReturnedItem<OutSeriesType extends ChartSeriesType> = {
6
+ type: OutSeriesType;
7
+ seriesId: SeriesId;
8
+ dataIndex: number;
9
+ } | null;
10
+ export declare function createGetNextIndexFocusedItem<InSeriesType extends Exclude<ChartSeriesType, 'sankey'>, OutSeriesType extends Exclude<ChartSeriesType, 'sankey'> = InSeriesType>(compatibleSeriesTypes: Set<OutSeriesType>): (currentItem: FocusedItemIdentifier<InSeriesType> | null, state: ChartState<[UseChartKeyboardNavigationSignature], []>) => ReturnedItem<OutSeriesType>;
11
+ export declare function createGetPreviousIndexFocusedItem<InSeriesType extends Exclude<ChartSeriesType, 'sankey'>, OutSeriesType extends Exclude<ChartSeriesType, 'sankey'> = InSeriesType>(compatibleSeriesTypes: Set<OutSeriesType>): (currentItem: SeriesItemIdentifier<InSeriesType> | null, state: ChartState<[UseChartKeyboardNavigationSignature], []>) => ReturnedItem<OutSeriesType>;
12
+ export declare function createGetNextSeriesFocusedItem<InSeriesType extends Exclude<ChartSeriesType, 'sankey'>, OutSeriesType extends Exclude<ChartSeriesType, 'sankey'> = InSeriesType>(compatibleSeriesTypes: Set<OutSeriesType>): (currentItem: SeriesItemIdentifier<InSeriesType> | null, state: ChartState<[UseChartKeyboardNavigationSignature], []>) => ReturnedItem<OutSeriesType>;
13
+ export declare function createGetPreviousSeriesFocusedItem<InSeriesType extends Exclude<ChartSeriesType, 'sankey'>, OutSeriesType extends Exclude<ChartSeriesType, 'sankey'> = InSeriesType>(compatibleSeriesTypes: Set<OutSeriesType>): (currentItem: SeriesItemIdentifier<InSeriesType> | null, state: ChartState<[UseChartKeyboardNavigationSignature], []>) => ReturnedItem<OutSeriesType>;
14
+ export {};
@@ -0,0 +1,84 @@
1
+ import { getPreviousNonEmptySeries } from "./plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.js";
2
+ import { selectorChartSeriesProcessed } from "./plugins/corePlugins/useChartSeries/index.js";
3
+ import { getNextNonEmptySeries } from "./plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.js";
4
+ import { seriesHasData } from "./seriesHasData.js";
5
+ export function createGetNextIndexFocusedItem(compatibleSeriesTypes) {
6
+ return function getNextIndexFocusedItem(currentItem, state) {
7
+ const processedSeries = selectorChartSeriesProcessed(state);
8
+ let seriesId = currentItem?.seriesId;
9
+ let type = currentItem?.type;
10
+ if (!type || seriesId == null || !seriesHasData(processedSeries, type, seriesId)) {
11
+ const nextSeries = getNextNonEmptySeries(processedSeries, compatibleSeriesTypes, type, seriesId);
12
+ if (nextSeries === null) {
13
+ return null;
14
+ }
15
+ type = nextSeries.type;
16
+ seriesId = nextSeries.seriesId;
17
+ }
18
+ const dataLength = processedSeries[type].series[seriesId].data.length;
19
+ return {
20
+ type,
21
+ seriesId,
22
+ dataIndex: ((currentItem?.dataIndex ?? -1) + 1) % dataLength
23
+ };
24
+ };
25
+ }
26
+ export function createGetPreviousIndexFocusedItem(compatibleSeriesTypes) {
27
+ return function getPreviousIndexFocusedItem(currentItem, state) {
28
+ const processedSeries = selectorChartSeriesProcessed(state);
29
+ let seriesId = currentItem?.seriesId;
30
+ let type = currentItem?.type;
31
+ if (!type || seriesId == null || !seriesHasData(processedSeries, type, seriesId)) {
32
+ const previousSeries = getPreviousNonEmptySeries(processedSeries, compatibleSeriesTypes, type, seriesId);
33
+ if (previousSeries === null) {
34
+ return null;
35
+ }
36
+ type = previousSeries.type;
37
+ seriesId = previousSeries.seriesId;
38
+ }
39
+ const dataLength = processedSeries[type].series[seriesId].data.length;
40
+ return {
41
+ type,
42
+ seriesId,
43
+ dataIndex: (dataLength + (currentItem?.dataIndex ?? 1) - 1) % dataLength
44
+ };
45
+ };
46
+ }
47
+ export function createGetNextSeriesFocusedItem(compatibleSeriesTypes) {
48
+ return function getNextSeriesFocusedItem(currentItem, state) {
49
+ const processedSeries = selectorChartSeriesProcessed(state);
50
+ let seriesId = currentItem?.seriesId;
51
+ let type = currentItem?.type;
52
+ const nextSeries = getNextNonEmptySeries(processedSeries, compatibleSeriesTypes, type, seriesId);
53
+ if (nextSeries === null) {
54
+ return null; // No series to move the focus to.
55
+ }
56
+ type = nextSeries.type;
57
+ seriesId = nextSeries.seriesId;
58
+ const dataLength = processedSeries[type].series[seriesId].data.length;
59
+ return {
60
+ type,
61
+ seriesId,
62
+ dataIndex: Math.min(dataLength - 1, currentItem?.dataIndex ?? 0)
63
+ };
64
+ };
65
+ }
66
+ export function createGetPreviousSeriesFocusedItem(compatibleSeriesTypes) {
67
+ return function getPreviousSeriesFocusedItem(currentItem, state) {
68
+ const processedSeries = selectorChartSeriesProcessed(state);
69
+ let seriesId = currentItem?.seriesId;
70
+ let type = currentItem?.type;
71
+ const previousSeries = getPreviousNonEmptySeries(processedSeries, compatibleSeriesTypes, type, seriesId);
72
+ if (previousSeries === null) {
73
+ return null; // No series to move the focus to.
74
+ }
75
+ type = previousSeries.type;
76
+ seriesId = previousSeries.seriesId;
77
+ const dataLength = processedSeries[type].series[seriesId].data.length;
78
+ return {
79
+ type,
80
+ seriesId,
81
+ dataIndex: Math.min(dataLength - 1, currentItem?.dataIndex ?? 0)
82
+ };
83
+ };
84
+ }
@@ -37,7 +37,6 @@ export { getAxisTriggerTooltip as getCartesianAxisTriggerTooltip } from "./plugi
37
37
  export { getAxisIndex as getCartesianAxisIndex } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js";
38
38
  export * from "./store/useCharts.js";
39
39
  export * from "./store/useStore.js";
40
- export * from "./store/useSelector.js";
41
40
  export * from "../BarChart/BarChart.plugins.js";
42
41
  export * from "../LineChart/LineChart.plugins.js";
43
42
  export * from "../ScatterChart/ScatterChart.plugins.js";
@@ -48,7 +47,7 @@ export * from "./getLabel.js";
48
47
  export * from "./getSVGPoint.js";
49
48
  export * from "./isDefined.js";
50
49
  export * from "./getScale.js";
51
- export * from "./stackSeries.js";
50
+ export * from "./stacking/index.js";
52
51
  export * from "./getCurve.js";
53
52
  export * from "./consumeSlots.js";
54
53
  export * from "./consumeThemeProps.js";
@@ -42,7 +42,6 @@ export { getAxisTriggerTooltip as getCartesianAxisTriggerTooltip } from "./plugi
42
42
  export { getAxisIndex as getCartesianAxisIndex } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js";
43
43
  export * from "./store/useCharts.js";
44
44
  export * from "./store/useStore.js";
45
- export * from "./store/useSelector.js";
46
45
 
47
46
  // plugins configs
48
47
 
@@ -58,7 +57,7 @@ export * from "./getLabel.js";
58
57
  export * from "./getSVGPoint.js";
59
58
  export * from "./isDefined.js";
60
59
  export * from "./getScale.js";
61
- export * from "./stackSeries.js";
60
+ export * from "./stacking/index.js";
62
61
  export * from "./getCurve.js";
63
62
  export * from "./consumeSlots.js";
64
63
  export * from "./consumeThemeProps.js";
@@ -5,7 +5,6 @@ import * as React from 'react';
5
5
  import { useEffectAfterFirstRender } from '@mui/x-internals/useEffectAfterFirstRender';
6
6
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
7
7
  import ownerWindow from '@mui/utils/ownerWindow';
8
- import { useSelector } from "../../../store/useSelector.js";
9
8
  import { DEFAULT_MARGINS } from "../../../../constants/index.js";
10
9
  import { selectorChartDrawingArea } from "./useChartDimensions.selectors.js";
11
10
  import { defaultizeMargin } from "../../../defaultizeMargin.js";
@@ -136,7 +135,7 @@ export const useChartDimensions = ({
136
135
  stateRef.current.displayError = false;
137
136
  }
138
137
  }
139
- const drawingArea = useSelector(store, selectorChartDrawingArea);
138
+ const drawingArea = store.use(selectorChartDrawingArea);
140
139
  const isXInside = React.useCallback(x => x >= drawingArea.left - 1 && x <= drawingArea.left + drawingArea.width, [drawingArea.left, drawingArea.width]);
141
140
  const isYInside = React.useCallback(y => y >= drawingArea.top - 1 && y <= drawingArea.top + drawingArea.height, [drawingArea.height, drawingArea.top]);
142
141
  const isPointInside = React.useCallback((x, y, targetElement) => {
@@ -1,12 +1,11 @@
1
1
  'use client';
2
2
 
3
3
  import * as React from 'react';
4
- import { useSelector } from "../../../store/useSelector.js";
5
4
  import { useStore } from "../../../store/useStore.js";
6
5
  import { selectorChartSeriesConfig } from "./useChartSeries.selectors.js";
7
6
  export function useColorProcessor(seriesType) {
8
7
  const store = useStore();
9
- const seriesConfig = useSelector(store, selectorChartSeriesConfig);
8
+ const seriesConfig = store.use(selectorChartSeriesConfig);
10
9
  const colorProcessors = React.useMemo(() => {
11
10
  const rep = {};
12
11
  Object.keys(seriesConfig).forEach(seriesT => {
@@ -5,7 +5,6 @@ import useEventCallback from '@mui/utils/useEventCallback';
5
5
  import * as React from 'react';
6
6
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
7
7
  import { getSVGPoint } from "../../../getSVGPoint.js";
8
- import { useSelector } from "../../../store/useSelector.js";
9
8
  import { selectorIsBrushEnabled } from "./useChartBrush.selectors.js";
10
9
  export const useChartBrush = ({
11
10
  store,
@@ -13,7 +12,7 @@ export const useChartBrush = ({
13
12
  instance,
14
13
  params
15
14
  }) => {
16
- const isEnabled = useSelector(store, selectorIsBrushEnabled);
15
+ const isEnabled = store.use(selectorIsBrushEnabled);
17
16
  useEnhancedEffect(() => {
18
17
  store.set('brush', _extends({}, store.state.brush, {
19
18
  enabled: params.brushConfig.enabled,
@@ -7,7 +7,6 @@ import { useStoreEffect } from '@mui/x-internals/store';
7
7
  import { useAssertModelConsistency } from '@mui/x-internals/useAssertModelConsistency';
8
8
  import { warnOnce } from '@mui/x-internals/warning';
9
9
  import { rainbowSurgePalette } from "../../../../colorPalettes/index.js";
10
- import { useSelector } from "../../../store/useSelector.js";
11
10
  import { selectorChartDrawingArea } from "../../corePlugins/useChartDimensions/useChartDimensions.selectors.js";
12
11
  import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/useChartSeries.selectors.js";
13
12
  import { defaultizeXAxis, defaultizeYAxis } from "./defaultizeAxis.js";
@@ -37,17 +36,17 @@ export const useChartCartesianAxis = ({
37
36
  warnOnce([`MUI X Charts: The following axis ids are duplicated: ${Array.from(duplicates).join(', ')}.`, `Please make sure that each axis has a unique id.`].join('\n'), 'error');
38
37
  }
39
38
  }
40
- const drawingArea = useSelector(store, selectorChartDrawingArea);
41
- const processedSeries = useSelector(store, selectorChartSeriesProcessed);
42
- const isInteractionEnabled = useSelector(store, selectorChartsInteractionIsInitialized);
39
+ const drawingArea = store.use(selectorChartDrawingArea);
40
+ const processedSeries = store.use(selectorChartSeriesProcessed);
41
+ const isInteractionEnabled = store.use(selectorChartsInteractionIsInitialized);
43
42
  const {
44
43
  axis: xAxisWithScale,
45
44
  axisIds: xAxisIds
46
- } = useSelector(store, selectorChartXAxis);
45
+ } = store.use(selectorChartXAxis);
47
46
  const {
48
47
  axis: yAxisWithScale,
49
48
  axisIds: yAxisIds
50
- } = useSelector(store, selectorChartYAxis);
49
+ } = store.use(selectorChartYAxis);
51
50
  useAssertModelConsistency({
52
51
  warningPrefix: 'MUI X Charts',
53
52
  componentName: 'Chart',
@@ -1,6 +1,5 @@
1
1
  'use client';
2
2
 
3
- import { useSelector } from "../../../store/useSelector.js";
4
3
  import { useStore } from "../../../store/useStore.js";
5
4
  import { selectorChartZoomIsInteracting } from "./useChartCartesianAxisRendering.selectors.js";
6
5
  /**
@@ -14,6 +13,6 @@ import { selectorChartZoomIsInteracting } from "./useChartCartesianAxisRendering
14
13
  */
15
14
  export function useInternalIsZoomInteracting() {
16
15
  const store = useStore();
17
- const isInteracting = useSelector(store, selectorChartZoomIsInteracting);
16
+ const isInteracting = store.use(selectorChartZoomIsInteracting);
18
17
  return isInteracting;
19
18
  }
@@ -5,7 +5,6 @@ import * as React from 'react';
5
5
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
6
6
  import useEventCallback from '@mui/utils/useEventCallback';
7
7
  import { getSVGPoint } from "../../../getSVGPoint.js";
8
- import { useSelector } from "../../../store/useSelector.js";
9
8
  import { selectorChartAxisZoomData, selectorChartSeriesEmptyFlatbushMap, selectorChartSeriesFlatbushMap, selectorChartXAxis, selectorChartYAxis, selectorChartZoomIsInteracting } from "../useChartCartesianAxis/index.js";
10
9
  import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/useChartSeries.selectors.js";
11
10
  import { findClosestPoints } from "./findClosestPoints.js";
@@ -23,17 +22,17 @@ export const useChartClosestPoint = ({
23
22
  const {
24
23
  axis: xAxis,
25
24
  axisIds: xAxisIds
26
- } = useSelector(store, selectorChartXAxis);
25
+ } = store.use(selectorChartXAxis);
27
26
  const {
28
27
  axis: yAxis,
29
28
  axisIds: yAxisIds
30
- } = useSelector(store, selectorChartYAxis);
31
- const zoomIsInteracting = useSelector(store, selectorChartZoomIsInteracting);
29
+ } = store.use(selectorChartYAxis);
30
+ const zoomIsInteracting = store.use(selectorChartZoomIsInteracting);
32
31
  const {
33
32
  series,
34
33
  seriesOrder
35
- } = useSelector(store, selectorChartSeriesProcessed)?.scatter ?? {};
36
- const flatbushMap = useSelector(store, zoomIsInteracting ? selectorChartSeriesEmptyFlatbushMap : selectorChartSeriesFlatbushMap);
34
+ } = store.use(selectorChartSeriesProcessed)?.scatter ?? {};
35
+ const flatbushMap = store.use(zoomIsInteracting ? selectorChartSeriesEmptyFlatbushMap : selectorChartSeriesFlatbushMap);
37
36
  const defaultXAxisId = xAxisIds[0];
38
37
  const defaultYAxisId = yAxisIds[0];
39
38
  useEnhancedEffect(() => {
@@ -41,10 +41,13 @@ export const useChartHighlight = ({
41
41
  });
42
42
  const setHighlight = useEventCallback(newItem => {
43
43
  const prevHighlight = store.state.highlight;
44
- if (prevHighlight.isControlled || fastObjectShallowCompare(prevHighlight.item, newItem)) {
44
+ if (fastObjectShallowCompare(prevHighlight.item, newItem)) {
45
45
  return;
46
46
  }
47
47
  params.onHighlightChange?.(newItem);
48
+ if (prevHighlight.isControlled) {
49
+ return;
50
+ }
48
51
  store.set('highlight', {
49
52
  item: newItem,
50
53
  lastUpdate: 'pointer',
@@ -0,0 +1,13 @@
1
+ import type { ChartSeriesType } from "../../../../models/seriesType/config.js";
2
+ import type { FocusedItemIdentifier } from "../../../../models/seriesType/index.js";
3
+ import type { UseChartKeyboardNavigationSignature } from "./useChartKeyboardNavigation.types.js";
4
+ import type { ChartState } from "../../models/chart.js";
5
+ export type FocusedItemUpdater<TSeriesType extends ChartSeriesType, OutputSeriesType extends ChartSeriesType = ChartSeriesType> = (currentItem: (TSeriesType extends any ? FocusedItemIdentifier<TSeriesType> : never) | null, state: ChartState<[UseChartKeyboardNavigationSignature], []>) => FocusedItemIdentifier<OutputSeriesType> | null;
6
+ /**
7
+ * Get the next focusable item in the chart.
8
+ * @param {SeriesItemIdentifier<TSeriesType> | null} currentItem The current focused item.
9
+ * @param {KeyboardEvent} event The keyboard event that triggered the navigation.
10
+ * @param {ChartState<[UseChartKeyboardNavigationSignature], []>} state The current chart state.
11
+ * @returns {SeriesItemIdentifier<ChartSeriesType> | null} The next focusable item or null if none found.
12
+ */
13
+ export type KeyboardFocusHandler<TSeriesType extends ChartSeriesType, OutputSeriesType extends ChartSeriesType = ChartSeriesType> = (event: KeyboardEvent) => FocusedItemUpdater<TSeriesType, OutputSeriesType> | null;
@@ -1,3 +1,3 @@
1
- import { type ChartPlugin } from "../../models/index.js";
2
- import { type UseChartKeyboardNavigationSignature } from "./useChartKeyboardNavigation.types.js";
1
+ import type { ChartPlugin } from "../../models/index.js";
2
+ import type { UseChartKeyboardNavigationSignature } from "./useChartKeyboardNavigation.types.js";
3
3
  export declare const useChartKeyboardNavigation: ChartPlugin<UseChartKeyboardNavigationSignature>;
@@ -4,92 +4,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
5
  import useEventCallback from '@mui/utils/useEventCallback';
6
6
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
7
- import { getNextSeriesWithData, getPreviousSeriesWithData, seriesHasData } from "./useChartKeyboardNavigation.helpers.js";
8
- import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/useChartSeries.selectors.js";
9
- function getNextIndexFocusedItem(state) {
10
- const processedSeries = selectorChartSeriesProcessed(state);
11
- let {
12
- type,
13
- seriesId
14
- } = state.keyboardNavigation.item ?? {};
15
- if (type === undefined ||
16
- // @ts-ignore sankey is not in MIT version
17
- type === 'sankey' || seriesId === undefined || !seriesHasData(processedSeries, type, seriesId)) {
18
- const nextSeries = getNextSeriesWithData(processedSeries, type, seriesId);
19
- if (nextSeries === null) {
20
- return null;
21
- }
22
- type = nextSeries.type;
23
- seriesId = nextSeries.seriesId;
24
- }
25
- const dataLength = processedSeries[type].series[seriesId].data.length;
26
- return {
27
- type,
28
- seriesId,
29
- dataIndex: ((state.keyboardNavigation.item?.dataIndex ?? -1) + 1) % dataLength
30
- };
31
- }
32
- function getPreviousIndexFocusedItem(state) {
33
- const processedSeries = selectorChartSeriesProcessed(state);
34
- let {
35
- type,
36
- seriesId
37
- } = state.keyboardNavigation.item ?? {};
38
- if (type === undefined ||
39
- // @ts-ignore sankey is not in MIT version
40
- type === 'sankey' || seriesId === undefined || !seriesHasData(processedSeries, type, seriesId)) {
41
- const previousSeries = getPreviousSeriesWithData(processedSeries, type, seriesId);
42
- if (previousSeries === null) {
43
- return null;
44
- }
45
- type = previousSeries.type;
46
- seriesId = previousSeries.seriesId;
47
- }
48
- const dataLength = processedSeries[type].series[seriesId].data.length;
49
- return {
50
- type,
51
- seriesId,
52
- dataIndex: (dataLength + (state.keyboardNavigation.item?.dataIndex ?? 1) - 1) % dataLength
53
- };
54
- }
55
- function getNextSeriesFocusedItem(state) {
56
- const processedSeries = selectorChartSeriesProcessed(state);
57
- let {
58
- type,
59
- seriesId
60
- } = state.keyboardNavigation.item ?? {};
61
- const nextSeries = getNextSeriesWithData(processedSeries, type, seriesId);
62
- if (nextSeries === null) {
63
- return null; // No series to move the focus to.
64
- }
65
- type = nextSeries.type;
66
- seriesId = nextSeries.seriesId;
67
- const dataLength = processedSeries[type].series[seriesId].data.length;
68
- return {
69
- type,
70
- seriesId,
71
- dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
72
- };
73
- }
74
- function getPreviousSeriesFocusedItem(state) {
75
- const processedSeries = selectorChartSeriesProcessed(state);
76
- let {
77
- type,
78
- seriesId
79
- } = state.keyboardNavigation.item ?? {};
80
- const previousSeries = getPreviousSeriesWithData(processedSeries, type, seriesId);
81
- if (previousSeries === null) {
82
- return null; // No series to move the focus to.
83
- }
84
- type = previousSeries.type;
85
- seriesId = previousSeries.seriesId;
86
- const dataLength = processedSeries[type].series[seriesId].data.length;
87
- return {
88
- type,
89
- seriesId,
90
- dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
91
- };
92
- }
7
+ import { selectorChartDefaultizedSeries } from "../../corePlugins/useChartSeries/useChartSeries.selectors.js";
93
8
  export const useChartKeyboardNavigation = ({
94
9
  params,
95
10
  store,
@@ -109,26 +24,18 @@ export const useChartKeyboardNavigation = ({
109
24
  }
110
25
  function keyboardHandler(event) {
111
26
  let newFocusedItem = store.state.keyboardNavigation.item;
112
- switch (event.key) {
113
- case 'ArrowRight':
114
- newFocusedItem = getNextIndexFocusedItem(store.state);
115
- break;
116
- case 'ArrowLeft':
117
- newFocusedItem = getPreviousIndexFocusedItem(store.state);
118
- break;
119
- case 'ArrowDown':
120
- {
121
- newFocusedItem = getPreviousSeriesFocusedItem(store.state);
122
- break;
123
- }
124
- case 'ArrowUp':
125
- {
126
- newFocusedItem = getNextSeriesFocusedItem(store.state);
127
- break;
128
- }
129
- default:
130
- break;
27
+ let seriesType = newFocusedItem?.type;
28
+ if (!seriesType) {
29
+ seriesType = Object.keys(selectorChartDefaultizedSeries(store.state)).find(key => store.state.series.seriesConfig[key] !== undefined);
30
+ if (seriesType === undefined) {
31
+ return;
32
+ }
33
+ }
34
+ const calculateFocusedItem = store.state.series.seriesConfig[seriesType]?.keyboardFocusHandler?.(event);
35
+ if (!calculateFocusedItem) {
36
+ return;
131
37
  }
38
+ newFocusedItem = calculateFocusedItem(newFocusedItem, store.state);
132
39
  if (newFocusedItem !== store.state.keyboardNavigation.item) {
133
40
  event.preventDefault();
134
41
  store.update(_extends({}, store.state.highlight && {
@@ -1,21 +1,14 @@
1
- import { type SeriesId } from "../../../../models/seriesType/common.js";
1
+ import type { FocusedItemIdentifier } from "../../../../models/seriesType/index.js";
2
2
  import { type AxisItemIdentifier } from "../../../../models/axis.js";
3
- import { type FocusedItemData } from "../../../../hooks/useFocusedItem.js";
4
3
  export declare const selectorChartsItemIsFocused: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
5
4
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
6
- }, item: FocusedItemData) => boolean;
5
+ }, item: FocusedItemIdentifier<keyof import("../../../index.js").ChartsSeriesConfig>) => boolean;
7
6
  export declare const selectorChartsHasFocusedItem: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
8
7
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
9
8
  }) => boolean;
10
- export declare const selectorChartsFocusedSeriesType: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
9
+ export declare const selectorChartsFocusedItem: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
11
10
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
12
- }) => "line" | "bar" | "scatter" | "pie" | undefined;
13
- export declare const selectorChartsFocusedSeriesId: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
14
- cacheKey: import("../../models/index.js").ChartStateCacheKey;
15
- }) => SeriesId | undefined;
16
- export declare const selectorChartsFocusedDataIndex: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
17
- cacheKey: import("../../models/index.js").ChartStateCacheKey;
18
- }) => number | undefined;
11
+ }) => FocusedItemIdentifier<keyof import("../../../index.js").ChartsSeriesConfig> | null;
19
12
  export declare const selectorChartsIsKeyboardNavigationEnabled: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
20
13
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
21
14
  }) => boolean;
@@ -27,23 +20,4 @@ export declare const selectorChartsKeyboardYAxisIndex: (args_0: import("../../co
27
20
  }) => AxisItemIdentifier | undefined;
28
21
  export declare const selectorChartsKeyboardItem: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
29
22
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
30
- }) => {
31
- type: "line";
32
- seriesId: SeriesId;
33
- dataIndex: number;
34
- } | {
35
- type: "bar";
36
- seriesId: SeriesId;
37
- dataIndex: number;
38
- } | {
39
- type: "scatter";
40
- seriesId: SeriesId;
41
- dataIndex: number;
42
- } | {
43
- type: "pie";
44
- seriesId: SeriesId;
45
- dataIndex: number;
46
- } | null;
47
- export declare const selectorChartsKeyboardItemIsDefined: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
48
- cacheKey: import("../../models/index.js").ChartStateCacheKey;
49
- }) => boolean;
23
+ }) => FocusedItemIdentifier<keyof import("../../../index.js").ChartsSeriesConfig> | null;