@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
@@ -7,12 +7,11 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.useColorProcessor = useColorProcessor;
9
9
  var React = _interopRequireWildcard(require("react"));
10
- var _useSelector = require("../../../store/useSelector");
11
10
  var _useStore = require("../../../store/useStore");
12
11
  var _useChartSeries = require("./useChartSeries.selectors");
13
12
  function useColorProcessor(seriesType) {
14
13
  const store = (0, _useStore.useStore)();
15
- const seriesConfig = (0, _useSelector.useSelector)(store, _useChartSeries.selectorChartSeriesConfig);
14
+ const seriesConfig = store.use(_useChartSeries.selectorChartSeriesConfig);
16
15
  const colorProcessors = React.useMemo(() => {
17
16
  const rep = {};
18
17
  Object.keys(seriesConfig).forEach(seriesT => {
@@ -12,7 +12,6 @@ var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallb
12
12
  var React = _interopRequireWildcard(require("react"));
13
13
  var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
14
14
  var _getSVGPoint = require("../../../getSVGPoint");
15
- var _useSelector = require("../../../store/useSelector");
16
15
  var _useChartBrush = require("./useChartBrush.selectors");
17
16
  const useChartBrush = ({
18
17
  store,
@@ -20,7 +19,7 @@ const useChartBrush = ({
20
19
  instance,
21
20
  params
22
21
  }) => {
23
- const isEnabled = (0, _useSelector.useSelector)(store, _useChartBrush.selectorIsBrushEnabled);
22
+ const isEnabled = store.use(_useChartBrush.selectorIsBrushEnabled);
24
23
  (0, _useEnhancedEffect.default)(() => {
25
24
  store.set('brush', (0, _extends2.default)({}, store.state.brush, {
26
25
  enabled: params.brushConfig.enabled,
@@ -14,7 +14,6 @@ var _store = require("@mui/x-internals/store");
14
14
  var _useAssertModelConsistency = require("@mui/x-internals/useAssertModelConsistency");
15
15
  var _warning = require("@mui/x-internals/warning");
16
16
  var _colorPalettes = require("../../../../colorPalettes");
17
- var _useSelector = require("../../../store/useSelector");
18
17
  var _useChartDimensions = require("../../corePlugins/useChartDimensions/useChartDimensions.selectors");
19
18
  var _useChartSeries = require("../../corePlugins/useChartSeries/useChartSeries.selectors");
20
19
  var _defaultizeAxis = require("./defaultizeAxis");
@@ -44,17 +43,17 @@ const useChartCartesianAxis = ({
44
43
  (0, _warning.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');
45
44
  }
46
45
  }
47
- const drawingArea = (0, _useSelector.useSelector)(store, _useChartDimensions.selectorChartDrawingArea);
48
- const processedSeries = (0, _useSelector.useSelector)(store, _useChartSeries.selectorChartSeriesProcessed);
49
- const isInteractionEnabled = (0, _useSelector.useSelector)(store, _useChartInteraction.selectorChartsInteractionIsInitialized);
46
+ const drawingArea = store.use(_useChartDimensions.selectorChartDrawingArea);
47
+ const processedSeries = store.use(_useChartSeries.selectorChartSeriesProcessed);
48
+ const isInteractionEnabled = store.use(_useChartInteraction.selectorChartsInteractionIsInitialized);
50
49
  const {
51
50
  axis: xAxisWithScale,
52
51
  axisIds: xAxisIds
53
- } = (0, _useSelector.useSelector)(store, _useChartCartesianAxisRendering.selectorChartXAxis);
52
+ } = store.use(_useChartCartesianAxisRendering.selectorChartXAxis);
54
53
  const {
55
54
  axis: yAxisWithScale,
56
55
  axisIds: yAxisIds
57
- } = (0, _useSelector.useSelector)(store, _useChartCartesianAxisRendering.selectorChartYAxis);
56
+ } = store.use(_useChartCartesianAxisRendering.selectorChartYAxis);
58
57
  (0, _useAssertModelConsistency.useAssertModelConsistency)({
59
58
  warningPrefix: 'MUI X Charts',
60
59
  componentName: 'Chart',
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.useInternalIsZoomInteracting = useInternalIsZoomInteracting;
8
- var _useSelector = require("../../../store/useSelector");
9
8
  var _useStore = require("../../../store/useStore");
10
9
  var _useChartCartesianAxisRendering = require("./useChartCartesianAxisRendering.selectors");
11
10
  /**
@@ -19,6 +18,6 @@ var _useChartCartesianAxisRendering = require("./useChartCartesianAxisRendering.
19
18
  */
20
19
  function useInternalIsZoomInteracting() {
21
20
  const store = (0, _useStore.useStore)();
22
- const isInteracting = (0, _useSelector.useSelector)(store, _useChartCartesianAxisRendering.selectorChartZoomIsInteracting);
21
+ const isInteracting = store.use(_useChartCartesianAxisRendering.selectorChartZoomIsInteracting);
23
22
  return isInteracting;
24
23
  }
@@ -12,7 +12,6 @@ var React = _interopRequireWildcard(require("react"));
12
12
  var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
13
13
  var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
14
14
  var _getSVGPoint = require("../../../getSVGPoint");
15
- var _useSelector = require("../../../store/useSelector");
16
15
  var _useChartCartesianAxis = require("../useChartCartesianAxis");
17
16
  var _useChartSeries = require("../../corePlugins/useChartSeries/useChartSeries.selectors");
18
17
  var _findClosestPoints = require("./findClosestPoints");
@@ -30,17 +29,17 @@ const useChartClosestPoint = ({
30
29
  const {
31
30
  axis: xAxis,
32
31
  axisIds: xAxisIds
33
- } = (0, _useSelector.useSelector)(store, _useChartCartesianAxis.selectorChartXAxis);
32
+ } = store.use(_useChartCartesianAxis.selectorChartXAxis);
34
33
  const {
35
34
  axis: yAxis,
36
35
  axisIds: yAxisIds
37
- } = (0, _useSelector.useSelector)(store, _useChartCartesianAxis.selectorChartYAxis);
38
- const zoomIsInteracting = (0, _useSelector.useSelector)(store, _useChartCartesianAxis.selectorChartZoomIsInteracting);
36
+ } = store.use(_useChartCartesianAxis.selectorChartYAxis);
37
+ const zoomIsInteracting = store.use(_useChartCartesianAxis.selectorChartZoomIsInteracting);
39
38
  const {
40
39
  series,
41
40
  seriesOrder
42
- } = (0, _useSelector.useSelector)(store, _useChartSeries.selectorChartSeriesProcessed)?.scatter ?? {};
43
- const flatbushMap = (0, _useSelector.useSelector)(store, zoomIsInteracting ? _useChartCartesianAxis.selectorChartSeriesEmptyFlatbushMap : _useChartCartesianAxis.selectorChartSeriesFlatbushMap);
41
+ } = store.use(_useChartSeries.selectorChartSeriesProcessed)?.scatter ?? {};
42
+ const flatbushMap = store.use(zoomIsInteracting ? _useChartCartesianAxis.selectorChartSeriesEmptyFlatbushMap : _useChartCartesianAxis.selectorChartSeriesFlatbushMap);
44
43
  const defaultXAxisId = xAxisIds[0];
45
44
  const defaultYAxisId = yAxisIds[0];
46
45
  (0, _useEnhancedEffect.default)(() => {
@@ -48,10 +48,13 @@ const useChartHighlight = ({
48
48
  });
49
49
  const setHighlight = (0, _useEventCallback.default)(newItem => {
50
50
  const prevHighlight = store.state.highlight;
51
- if (prevHighlight.isControlled || (0, _fastObjectShallowCompare.fastObjectShallowCompare)(prevHighlight.item, newItem)) {
51
+ if ((0, _fastObjectShallowCompare.fastObjectShallowCompare)(prevHighlight.item, newItem)) {
52
52
  return;
53
53
  }
54
54
  params.onHighlightChange?.(newItem);
55
+ if (prevHighlight.isControlled) {
56
+ return;
57
+ }
55
58
  store.set('highlight', {
56
59
  item: newItem,
57
60
  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;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -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>;
@@ -11,92 +11,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
11
11
  var React = _interopRequireWildcard(require("react"));
12
12
  var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
13
13
  var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
14
- var _useChartKeyboardNavigation = require("./useChartKeyboardNavigation.helpers");
15
14
  var _useChartSeries = require("../../corePlugins/useChartSeries/useChartSeries.selectors");
16
- function getNextIndexFocusedItem(state) {
17
- const processedSeries = (0, _useChartSeries.selectorChartSeriesProcessed)(state);
18
- let {
19
- type,
20
- seriesId
21
- } = state.keyboardNavigation.item ?? {};
22
- if (type === undefined ||
23
- // @ts-ignore sankey is not in MIT version
24
- type === 'sankey' || seriesId === undefined || !(0, _useChartKeyboardNavigation.seriesHasData)(processedSeries, type, seriesId)) {
25
- const nextSeries = (0, _useChartKeyboardNavigation.getNextSeriesWithData)(processedSeries, type, seriesId);
26
- if (nextSeries === null) {
27
- return null;
28
- }
29
- type = nextSeries.type;
30
- seriesId = nextSeries.seriesId;
31
- }
32
- const dataLength = processedSeries[type].series[seriesId].data.length;
33
- return {
34
- type,
35
- seriesId,
36
- dataIndex: ((state.keyboardNavigation.item?.dataIndex ?? -1) + 1) % dataLength
37
- };
38
- }
39
- function getPreviousIndexFocusedItem(state) {
40
- const processedSeries = (0, _useChartSeries.selectorChartSeriesProcessed)(state);
41
- let {
42
- type,
43
- seriesId
44
- } = state.keyboardNavigation.item ?? {};
45
- if (type === undefined ||
46
- // @ts-ignore sankey is not in MIT version
47
- type === 'sankey' || seriesId === undefined || !(0, _useChartKeyboardNavigation.seriesHasData)(processedSeries, type, seriesId)) {
48
- const previousSeries = (0, _useChartKeyboardNavigation.getPreviousSeriesWithData)(processedSeries, type, seriesId);
49
- if (previousSeries === null) {
50
- return null;
51
- }
52
- type = previousSeries.type;
53
- seriesId = previousSeries.seriesId;
54
- }
55
- const dataLength = processedSeries[type].series[seriesId].data.length;
56
- return {
57
- type,
58
- seriesId,
59
- dataIndex: (dataLength + (state.keyboardNavigation.item?.dataIndex ?? 1) - 1) % dataLength
60
- };
61
- }
62
- function getNextSeriesFocusedItem(state) {
63
- const processedSeries = (0, _useChartSeries.selectorChartSeriesProcessed)(state);
64
- let {
65
- type,
66
- seriesId
67
- } = state.keyboardNavigation.item ?? {};
68
- const nextSeries = (0, _useChartKeyboardNavigation.getNextSeriesWithData)(processedSeries, type, seriesId);
69
- if (nextSeries === null) {
70
- return null; // No series to move the focus to.
71
- }
72
- type = nextSeries.type;
73
- seriesId = nextSeries.seriesId;
74
- const dataLength = processedSeries[type].series[seriesId].data.length;
75
- return {
76
- type,
77
- seriesId,
78
- dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
79
- };
80
- }
81
- function getPreviousSeriesFocusedItem(state) {
82
- const processedSeries = (0, _useChartSeries.selectorChartSeriesProcessed)(state);
83
- let {
84
- type,
85
- seriesId
86
- } = state.keyboardNavigation.item ?? {};
87
- const previousSeries = (0, _useChartKeyboardNavigation.getPreviousSeriesWithData)(processedSeries, type, seriesId);
88
- if (previousSeries === null) {
89
- return null; // No series to move the focus to.
90
- }
91
- type = previousSeries.type;
92
- seriesId = previousSeries.seriesId;
93
- const dataLength = processedSeries[type].series[seriesId].data.length;
94
- return {
95
- type,
96
- seriesId,
97
- dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
98
- };
99
- }
100
15
  const useChartKeyboardNavigation = ({
101
16
  params,
102
17
  store,
@@ -116,26 +31,18 @@ const useChartKeyboardNavigation = ({
116
31
  }
117
32
  function keyboardHandler(event) {
118
33
  let newFocusedItem = store.state.keyboardNavigation.item;
119
- switch (event.key) {
120
- case 'ArrowRight':
121
- newFocusedItem = getNextIndexFocusedItem(store.state);
122
- break;
123
- case 'ArrowLeft':
124
- newFocusedItem = getPreviousIndexFocusedItem(store.state);
125
- break;
126
- case 'ArrowDown':
127
- {
128
- newFocusedItem = getPreviousSeriesFocusedItem(store.state);
129
- break;
130
- }
131
- case 'ArrowUp':
132
- {
133
- newFocusedItem = getNextSeriesFocusedItem(store.state);
134
- break;
135
- }
136
- default:
137
- break;
34
+ let seriesType = newFocusedItem?.type;
35
+ if (!seriesType) {
36
+ seriesType = Object.keys((0, _useChartSeries.selectorChartDefaultizedSeries)(store.state)).find(key => store.state.series.seriesConfig[key] !== undefined);
37
+ if (seriesType === undefined) {
38
+ return;
39
+ }
40
+ }
41
+ const calculateFocusedItem = store.state.series.seriesConfig[seriesType]?.keyboardFocusHandler?.(event);
42
+ if (!calculateFocusedItem) {
43
+ return;
138
44
  }
45
+ newFocusedItem = calculateFocusedItem(newFocusedItem, store.state);
139
46
  if (newFocusedItem !== store.state.keyboardNavigation.item) {
140
47
  event.preventDefault();
141
48
  store.update((0, _extends2.default)({}, 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;
@@ -3,29 +3,26 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.selectorChartsKeyboardYAxisIndex = exports.selectorChartsKeyboardXAxisIndex = exports.selectorChartsKeyboardItemIsDefined = exports.selectorChartsKeyboardItem = exports.selectorChartsItemIsFocused = exports.selectorChartsIsKeyboardNavigationEnabled = exports.selectorChartsHasFocusedItem = exports.selectorChartsFocusedSeriesType = exports.selectorChartsFocusedSeriesId = exports.selectorChartsFocusedDataIndex = void 0;
6
+ exports.selectorChartsKeyboardYAxisIndex = exports.selectorChartsKeyboardXAxisIndex = exports.selectorChartsKeyboardItem = exports.selectorChartsItemIsFocused = exports.selectorChartsIsKeyboardNavigationEnabled = exports.selectorChartsHasFocusedItem = exports.selectorChartsFocusedItem = void 0;
7
7
  var _store = require("@mui/x-internals/store");
8
+ var _fastObjectShallowCompare = require("@mui/x-internals/fastObjectShallowCompare");
8
9
  var _useChartSeries = require("../../corePlugins/useChartSeries");
9
10
  var _useChartCartesianAxisRendering = require("../useChartCartesianAxis/useChartCartesianAxisRendering.selectors");
10
11
  const selectKeyboardNavigation = state => state.keyboardNavigation;
11
- const selectorChartsItemIsFocused = exports.selectorChartsItemIsFocused = (0, _store.createSelector)(selectKeyboardNavigation, (keyboardNavigationState, item) => {
12
- return keyboardNavigationState?.item != null && keyboardNavigationState.item.type === item.seriesType && keyboardNavigationState.item.seriesId === item.seriesId && keyboardNavigationState.item.dataIndex === item.dataIndex;
13
- });
12
+ const selectorChartsItemIsFocused = exports.selectorChartsItemIsFocused = (0, _store.createSelector)(selectKeyboardNavigation, (keyboardNavigationState, item) => keyboardNavigationState?.item != null && (0, _fastObjectShallowCompare.fastObjectShallowCompare)(keyboardNavigationState.item, item));
14
13
  const selectorChartsHasFocusedItem = exports.selectorChartsHasFocusedItem = (0, _store.createSelector)(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item != null);
15
- const selectorChartsFocusedSeriesType = exports.selectorChartsFocusedSeriesType = (0, _store.createSelector)(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item?.type);
16
- const selectorChartsFocusedSeriesId = exports.selectorChartsFocusedSeriesId = (0, _store.createSelector)(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item?.seriesId);
17
- const selectorChartsFocusedDataIndex = exports.selectorChartsFocusedDataIndex = (0, _store.createSelector)(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item?.dataIndex);
14
+ const selectorChartsFocusedItem = exports.selectorChartsFocusedItem = (0, _store.createSelector)(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item ?? null);
18
15
  const selectorChartsIsKeyboardNavigationEnabled = exports.selectorChartsIsKeyboardNavigationEnabled = (0, _store.createSelector)(selectKeyboardNavigation, keyboardNavigationState => !!keyboardNavigationState?.enableKeyboardNavigation);
19
16
 
20
17
  /**
21
18
  * Selectors to override highlight behavior.
22
19
  */
23
20
 
24
- const createSelectAxisHighlight = direction => (type, seriesId, dataIndex, axis, series) => {
25
- if (type === undefined || seriesId === undefined || dataIndex === undefined) {
21
+ const createSelectAxisHighlight = direction => (item, axis, series) => {
22
+ if (item == null || !('dataIndex' in item) || item.dataIndex === undefined) {
26
23
  return undefined;
27
24
  }
28
- const seriesConfig = series[type]?.series[seriesId];
25
+ const seriesConfig = series[item.type]?.series[item.seriesId];
29
26
  if (!seriesConfig) {
30
27
  return undefined;
31
28
  }
@@ -35,11 +32,11 @@ const createSelectAxisHighlight = direction => (type, seriesId, dataIndex, axis,
35
32
  }
36
33
  return {
37
34
  axisId,
38
- dataIndex
35
+ dataIndex: item.dataIndex
39
36
  };
40
37
  };
41
- const selectorChartsKeyboardXAxisIndex = exports.selectorChartsKeyboardXAxisIndex = (0, _store.createSelector)(selectorChartsFocusedSeriesType, selectorChartsFocusedSeriesId, selectorChartsFocusedDataIndex, _useChartCartesianAxisRendering.selectorChartXAxis, _useChartSeries.selectorChartSeriesProcessed, createSelectAxisHighlight('x'));
42
- const selectorChartsKeyboardYAxisIndex = exports.selectorChartsKeyboardYAxisIndex = (0, _store.createSelector)(selectorChartsFocusedSeriesType, selectorChartsFocusedSeriesId, selectorChartsFocusedDataIndex, _useChartCartesianAxisRendering.selectorChartYAxis, _useChartSeries.selectorChartSeriesProcessed, createSelectAxisHighlight('y'));
38
+ const selectorChartsKeyboardXAxisIndex = exports.selectorChartsKeyboardXAxisIndex = (0, _store.createSelector)(selectorChartsFocusedItem, _useChartCartesianAxisRendering.selectorChartXAxis, _useChartSeries.selectorChartSeriesProcessed, createSelectAxisHighlight('x'));
39
+ const selectorChartsKeyboardYAxisIndex = exports.selectorChartsKeyboardYAxisIndex = (0, _store.createSelector)(selectorChartsFocusedItem, _useChartCartesianAxisRendering.selectorChartYAxis, _useChartSeries.selectorChartSeriesProcessed, createSelectAxisHighlight('y'));
43
40
  const selectorChartsKeyboardItem = exports.selectorChartsKeyboardItem = (0, _store.createSelector)(selectKeyboardNavigation, function selectorChartsKeyboardItem(keyboardState) {
44
41
  if (keyboardState?.item == null) {
45
42
  return null;
@@ -52,7 +49,4 @@ const selectorChartsKeyboardItem = exports.selectorChartsKeyboardItem = (0, _sto
52
49
  return null;
53
50
  }
54
51
  return keyboardState.item;
55
- });
56
- const selectorChartsKeyboardItemIsDefined = exports.selectorChartsKeyboardItemIsDefined = (0, _store.createSelector)(selectorChartsFocusedSeriesType, selectorChartsFocusedSeriesId, selectorChartsFocusedDataIndex, function selectorChartsKeyboardItemIsDefined(seriesType, seriesId, dataIndex) {
57
- return seriesId !== undefined && dataIndex !== undefined;
58
52
  });
@@ -1,27 +1,12 @@
1
- import { type ChartPluginSignature } from "../../models/index.js";
2
- import { type ChartSeriesType } from "../../../../models/seriesType/config.js";
3
- import { type SeriesId } from "../../../../models/seriesType/common.js";
4
- import { type UseChartInteractionSignature } from "../useChartInteraction/index.js";
5
- import { type UseChartHighlightSignature } from "../useChartHighlight/index.js";
1
+ import type { ChartPluginSignature } from "../../models/index.js";
2
+ import type { UseChartInteractionSignature } from "../useChartInteraction/index.js";
3
+ import type { UseChartHighlightSignature } from "../useChartHighlight/index.js";
4
+ import type { FocusedItemIdentifier } from "../../../../models/seriesType/index.js";
5
+ import type { ChartSeriesType } from "../../../../models/seriesType/config.js";
6
6
  export interface UseChartKeyboardNavigationInstance {}
7
- type SeriesItemIdentifier<SeriesType extends ChartSeriesType = FocusableSeriesTypes> = SeriesType extends FocusableSeriesTypes ? {
8
- /**
9
- * The type of the series
10
- */
11
- type: SeriesType;
12
- /**
13
- * The id of the series with focus.
14
- */
15
- seriesId: SeriesId;
16
- /**
17
- * The index of the data point with focus.
18
- */
19
- dataIndex: number;
20
- } : never;
21
- export type FocusableSeriesTypes = 'bar' | 'line' | 'scatter' | 'pie';
22
7
  export interface UseChartKeyboardNavigationState {
23
8
  keyboardNavigation: {
24
- item: null | SeriesItemIdentifier;
9
+ item: null | FocusedItemIdentifier<ChartSeriesType>;
25
10
  enableKeyboardNavigation: boolean;
26
11
  };
27
12
  }
@@ -0,0 +1,15 @@
1
+ import type { ChartSeriesType } from "../../../../../models/seriesType/config.js";
2
+ import type { SeriesId } from "../../../../../models/seriesType/common.js";
3
+ import type { ProcessedSeries } from "../../../corePlugins/useChartSeries/index.js";
4
+ /**
5
+ * Returns the next series type and id that contains some data.
6
+ * Returns `null` if no other series have data.
7
+ * @param series - The processed series from the store.
8
+ * @param availableSeriesTypes - The set of series types that can be focused.
9
+ * @param type - The current series type.
10
+ * @param seriesId - The current series id.
11
+ */
12
+ export declare function getNextNonEmptySeries<OutSeriesType extends Exclude<ChartSeriesType, 'sankey'> = Exclude<ChartSeriesType, 'sankey'>>(series: ProcessedSeries<ChartSeriesType>, availableSeriesTypes: Set<OutSeriesType>, type?: ChartSeriesType, seriesId?: SeriesId): {
13
+ type: OutSeriesType;
14
+ seriesId: SeriesId;
15
+ } | null;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getNextNonEmptySeries = getNextNonEmptySeries;
7
+ /**
8
+ * Returns the next series type and id that contains some data.
9
+ * Returns `null` if no other series have data.
10
+ * @param series - The processed series from the store.
11
+ * @param availableSeriesTypes - The set of series types that can be focused.
12
+ * @param type - The current series type.
13
+ * @param seriesId - The current series id.
14
+ */
15
+ function getNextNonEmptySeries(series, availableSeriesTypes, type, seriesId) {
16
+ const seriesType = Object.keys(series);
17
+ const currentSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : -1;
18
+ const typesAvailable = seriesType.filter(t => availableSeriesTypes?.has(t));
19
+ const startingTypeIndex = type !== undefined && series[type] ? typesAvailable.indexOf(type) : 0;
20
+
21
+ // Loop over all series types starting with the current seriesType
22
+ for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
23
+ const typeIndex = (startingTypeIndex + typeGap) % typesAvailable.length;
24
+ const seriesOfType = series[typesAvailable[typeIndex]];
25
+
26
+ // Edge case for the current series type: we don't loop on previous series of the same type.
27
+ const startingSeriesIndex = typeGap === 0 ? currentSeriesIndex + 1 : 0;
28
+ for (let seriesIndex = startingSeriesIndex; seriesIndex < seriesOfType.seriesOrder.length; seriesIndex += 1) {
29
+ if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
30
+ return {
31
+ type: typesAvailable[typeIndex],
32
+ seriesId: seriesOfType.seriesOrder[seriesIndex]
33
+ };
34
+ }
35
+ }
36
+ }
37
+
38
+ // End looping on the initial type up to the initial series (excluded)
39
+ const typeIndex = startingTypeIndex;
40
+ const seriesOfType = series[typesAvailable[typeIndex]];
41
+ const endingSeriesIndex = currentSeriesIndex;
42
+ for (let seriesIndex = 0; seriesIndex < endingSeriesIndex; seriesIndex += 1) {
43
+ if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
44
+ return {
45
+ type: typesAvailable[typeIndex],
46
+ seriesId: seriesOfType.seriesOrder[seriesIndex]
47
+ };
48
+ }
49
+ }
50
+ return null;
51
+ }
@@ -0,0 +1,11 @@
1
+ import type { ChartSeriesType } from "../../../../../models/seriesType/config.js";
2
+ import type { SeriesId } from "../../../../../models/seriesType/common.js";
3
+ import type { ProcessedSeries } from "../../../corePlugins/useChartSeries/index.js";
4
+ /**
5
+ * Returns the previous series type and id that contains some data.
6
+ * Returns `null` if no other series have data.
7
+ */
8
+ export declare function getPreviousNonEmptySeries<OutSeriesType extends Exclude<ChartSeriesType, 'sankey'> = Exclude<ChartSeriesType, 'sankey'>>(series: ProcessedSeries<ChartSeriesType>, availableSeriesTypes: Set<OutSeriesType>, type?: ChartSeriesType, seriesId?: SeriesId): {
9
+ type: OutSeriesType;
10
+ seriesId: SeriesId;
11
+ } | null;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getPreviousNonEmptySeries = getPreviousNonEmptySeries;
7
+ /**
8
+ * Returns the previous series type and id that contains some data.
9
+ * Returns `null` if no other series have data.
10
+ */
11
+ function getPreviousNonEmptySeries(series, availableSeriesTypes, type, seriesId) {
12
+ const seriesType = Object.keys(series);
13
+ const startingSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : 1;
14
+ const typesAvailable = seriesType.filter(t => availableSeriesTypes?.has(t));
15
+ const startingTypeIndex = type !== undefined && series[type] ? typesAvailable.indexOf(type) : 0;
16
+
17
+ // Loop over all series types starting with the current seriesType
18
+ for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
19
+ const typeIndex = (typesAvailable.length + startingTypeIndex - typeGap) % typesAvailable.length;
20
+ const seriesOfType = series[typesAvailable[typeIndex]];
21
+ const maxGap = typeGap === 0 ? startingSeriesIndex + 1 : seriesOfType.seriesOrder.length;
22
+ for (let seriesGap = 1; seriesGap < maxGap; seriesGap += 1) {
23
+ const seriesIndex = (seriesOfType.seriesOrder.length + startingSeriesIndex - seriesGap) % seriesOfType.seriesOrder.length;
24
+ if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
25
+ return {
26
+ type: typesAvailable[typeIndex],
27
+ seriesId: seriesOfType.seriesOrder[seriesIndex]
28
+ };
29
+ }
30
+ }
31
+ }
32
+
33
+ // End looping on the initial type down to the initial series (excluded)
34
+ const typeIndex = startingTypeIndex;
35
+ const seriesOfType = series[typesAvailable[typeIndex]];
36
+ const availableSeriesIds = seriesOfType.seriesOrder;
37
+ for (let seriesIndex = availableSeriesIds.length - 1; seriesIndex > startingSeriesIndex; seriesIndex -= 1) {
38
+ if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
39
+ return {
40
+ type: typesAvailable[typeIndex],
41
+ seriesId: seriesOfType.seriesOrder[seriesIndex]
42
+ };
43
+ }
44
+ }
45
+ return null;
46
+ }
@@ -10,7 +10,6 @@ exports.useChartPolarAxis = void 0;
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
11
  var React = _interopRequireWildcard(require("react"));
12
12
  var _warning = require("@mui/x-internals/warning");
13
- var _useSelector = require("../../../store/useSelector");
14
13
  var _useChartDimensions = require("../../corePlugins/useChartDimensions/useChartDimensions.selectors");
15
14
  var _defaultizeAxis = require("./defaultizeAxis");
16
15
  var _useChartInteraction = require("../useChartInteraction");
@@ -39,18 +38,18 @@ const useChartPolarAxis = ({
39
38
  (0, _warning.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');
40
39
  }
41
40
  }
42
- const drawingArea = (0, _useSelector.useSelector)(store, _useChartDimensions.selectorChartDrawingArea);
43
- const processedSeries = (0, _useSelector.useSelector)(store, _useChartSeries.selectorChartSeriesProcessed);
44
- const center = (0, _useSelector.useSelector)(store, _useChartPolarAxis.selectorChartPolarCenter);
45
- const isInteractionEnabled = (0, _useSelector.useSelector)(store, _useChartInteraction.selectorChartsInteractionIsInitialized);
41
+ const drawingArea = store.use(_useChartDimensions.selectorChartDrawingArea);
42
+ const processedSeries = store.use(_useChartSeries.selectorChartSeriesProcessed);
43
+ const center = store.use(_useChartPolarAxis.selectorChartPolarCenter);
44
+ const isInteractionEnabled = store.use(_useChartInteraction.selectorChartsInteractionIsInitialized);
46
45
  const {
47
46
  axis: rotationAxisWithScale,
48
47
  axisIds: rotationAxisIds
49
- } = (0, _useSelector.useSelector)(store, _useChartPolarAxis.selectorChartRotationAxis);
48
+ } = store.use(_useChartPolarAxis.selectorChartRotationAxis);
50
49
  const {
51
50
  axis: radiusAxisWithScale,
52
51
  axisIds: radiusAxisIds
53
- } = (0, _useSelector.useSelector)(store, _useChartPolarAxis.selectorChartRadiusAxis);
52
+ } = store.use(_useChartPolarAxis.selectorChartRadiusAxis);
54
53
 
55
54
  // The effect do not track any value defined synchronously during the 1st render by hooks called after `useChartPolarAxis`
56
55
  // As a consequence, the state generated by the 1st run of this useEffect will always be equal to the initialization one