@mui/x-charts 8.11.2 → 8.12.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 (330) hide show
  1. package/BarChart/BarChart.d.ts +2 -2
  2. package/BarChart/BarChart.js +1 -0
  3. package/BarChart/BarChart.plugins.d.ts +3 -2
  4. package/BarChart/BarChart.plugins.js +2 -1
  5. package/BarChart/BarElement.js +10 -2
  6. package/BarChart/index.d.ts +2 -0
  7. package/BarChart/index.js +12 -0
  8. package/BarChart/useBarChartProps.d.ts +2 -2
  9. package/BarChart/useBarChartProps.js +4 -3
  10. package/CHANGELOG.md +231 -0
  11. package/ChartContainer/ChartContainer.js +4 -2
  12. package/ChartContainer/useChartContainerProps.js +4 -2
  13. package/ChartsAxisHighlight/ChartsXAxisHighlight.js +4 -4
  14. package/ChartsAxisHighlight/ChartsYAxisHighlight.js +4 -4
  15. package/ChartsLegend/ChartsLegend.js +2 -1
  16. package/ChartsLegend/ContinuousColorLegend.js +1 -0
  17. package/ChartsLegend/PiecewiseColorLegend.d.ts +2 -2
  18. package/ChartsLegend/PiecewiseColorLegend.js +33 -22
  19. package/ChartsLegend/piecewiseColorLegendClasses.d.ts +4 -0
  20. package/ChartsLegend/piecewiseColorLegendClasses.js +2 -2
  21. package/ChartsSurface/ChartsSurface.js +22 -2
  22. package/ChartsWrapper/ChartsWrapper.d.ts +5 -0
  23. package/ChartsWrapper/ChartsWrapper.js +87 -36
  24. package/ChartsXAxis/ChartsGroupedXAxisTicks.js +2 -2
  25. package/ChartsXAxis/ChartsXAxisImpl.js +3 -3
  26. package/ChartsXAxis/getVisibleLabels.js +5 -1
  27. package/ChartsXAxis/useAxisTicksProps.d.ts +3 -3
  28. package/ChartsYAxis/ChartsGroupedYAxisTicks.js +2 -2
  29. package/ChartsYAxis/ChartsYAxisImpl.js +3 -3
  30. package/ChartsYAxis/useAxisTicksProps.d.ts +3 -3
  31. package/LineChart/FocusedMark.d.ts +2 -0
  32. package/LineChart/FocusedMark.js +44 -0
  33. package/LineChart/LineChart.d.ts +2 -2
  34. package/LineChart/LineChart.js +3 -1
  35. package/LineChart/LineChart.plugins.d.ts +3 -2
  36. package/LineChart/LineChart.plugins.js +2 -1
  37. package/LineChart/index.d.ts +1 -0
  38. package/LineChart/index.js +12 -0
  39. package/LineChart/useAreaPlotData.js +2 -2
  40. package/LineChart/useLineChartProps.d.ts +2 -2
  41. package/LineChart/useLineChartProps.js +2 -1
  42. package/LineChart/useLinePlotData.js +2 -2
  43. package/PieChart/PieArc.d.ts +1 -0
  44. package/PieChart/PieArc.js +7 -3
  45. package/PieChart/PieArcPlot.js +1 -0
  46. package/PieChart/PieChart.js +2 -0
  47. package/PieChart/PieChart.plugins.d.ts +2 -1
  48. package/PieChart/PieChart.plugins.js +2 -1
  49. package/PieChart/dataTransform/useTransformData.d.ts +1 -0
  50. package/PieChart/dataTransform/useTransformData.js +9 -1
  51. package/PieChart/index.d.ts +1 -0
  52. package/PieChart/index.js +12 -0
  53. package/RadarChart/RadarAxis/useRadarAxis.js +2 -2
  54. package/RadarChart/RadarChart.plugins.d.ts +1 -1
  55. package/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +3 -3
  56. package/RadarChart/index.d.ts +2 -1
  57. package/RadarChart/index.js +12 -0
  58. package/RadarChart/useRadarChartProps.d.ts +2 -2
  59. package/RadarChart/useRadarChartProps.js +2 -1
  60. package/ScatterChart/BatchScatter.d.ts +32 -0
  61. package/ScatterChart/BatchScatter.js +171 -0
  62. package/ScatterChart/Scatter.js +13 -5
  63. package/ScatterChart/ScatterChart.d.ts +4 -4
  64. package/ScatterChart/ScatterChart.js +13 -2
  65. package/ScatterChart/ScatterChart.plugins.d.ts +4 -3
  66. package/ScatterChart/ScatterChart.plugins.js +3 -2
  67. package/ScatterChart/ScatterPlot.d.ts +10 -0
  68. package/ScatterChart/ScatterPlot.js +14 -2
  69. package/ScatterChart/index.d.ts +1 -0
  70. package/ScatterChart/index.js +12 -0
  71. package/ScatterChart/useScatterChartProps.d.ts +2 -2
  72. package/ScatterChart/useScatterChartProps.js +10 -6
  73. package/SparkLineChart/SparkLineChart.js +10 -5
  74. package/colorPalettes/types.d.ts +1 -1
  75. package/context/ChartApi.d.ts +6 -6
  76. package/esm/BarChart/BarChart.d.ts +2 -2
  77. package/esm/BarChart/BarChart.js +1 -0
  78. package/esm/BarChart/BarChart.plugins.d.ts +3 -2
  79. package/esm/BarChart/BarChart.plugins.js +2 -1
  80. package/esm/BarChart/BarElement.js +10 -2
  81. package/esm/BarChart/index.d.ts +2 -0
  82. package/esm/BarChart/index.js +1 -0
  83. package/esm/BarChart/useBarChartProps.d.ts +2 -2
  84. package/esm/BarChart/useBarChartProps.js +4 -3
  85. package/esm/ChartContainer/ChartContainer.js +4 -2
  86. package/esm/ChartContainer/useChartContainerProps.js +4 -2
  87. package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.js +4 -4
  88. package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.js +4 -4
  89. package/esm/ChartsLegend/ChartsLegend.js +2 -1
  90. package/esm/ChartsLegend/ContinuousColorLegend.js +1 -0
  91. package/esm/ChartsLegend/PiecewiseColorLegend.d.ts +2 -2
  92. package/esm/ChartsLegend/PiecewiseColorLegend.js +33 -22
  93. package/esm/ChartsLegend/piecewiseColorLegendClasses.d.ts +4 -0
  94. package/esm/ChartsLegend/piecewiseColorLegendClasses.js +2 -2
  95. package/esm/ChartsSurface/ChartsSurface.js +22 -2
  96. package/esm/ChartsWrapper/ChartsWrapper.d.ts +5 -0
  97. package/esm/ChartsWrapper/ChartsWrapper.js +87 -36
  98. package/esm/ChartsXAxis/ChartsGroupedXAxisTicks.js +2 -2
  99. package/esm/ChartsXAxis/ChartsXAxisImpl.js +3 -3
  100. package/esm/ChartsXAxis/getVisibleLabels.js +5 -1
  101. package/esm/ChartsXAxis/useAxisTicksProps.d.ts +3 -3
  102. package/esm/ChartsYAxis/ChartsGroupedYAxisTicks.js +2 -2
  103. package/esm/ChartsYAxis/ChartsYAxisImpl.js +3 -3
  104. package/esm/ChartsYAxis/useAxisTicksProps.d.ts +3 -3
  105. package/esm/LineChart/FocusedMark.d.ts +2 -0
  106. package/esm/LineChart/FocusedMark.js +38 -0
  107. package/esm/LineChart/LineChart.d.ts +2 -2
  108. package/esm/LineChart/LineChart.js +3 -1
  109. package/esm/LineChart/LineChart.plugins.d.ts +3 -2
  110. package/esm/LineChart/LineChart.plugins.js +2 -1
  111. package/esm/LineChart/index.d.ts +1 -0
  112. package/esm/LineChart/index.js +1 -0
  113. package/esm/LineChart/useAreaPlotData.js +2 -2
  114. package/esm/LineChart/useLineChartProps.d.ts +2 -2
  115. package/esm/LineChart/useLineChartProps.js +2 -1
  116. package/esm/LineChart/useLinePlotData.js +2 -2
  117. package/esm/PieChart/PieArc.d.ts +1 -0
  118. package/esm/PieChart/PieArc.js +7 -3
  119. package/esm/PieChart/PieArcPlot.js +1 -0
  120. package/esm/PieChart/PieChart.js +2 -0
  121. package/esm/PieChart/PieChart.plugins.d.ts +2 -1
  122. package/esm/PieChart/PieChart.plugins.js +2 -1
  123. package/esm/PieChart/dataTransform/useTransformData.d.ts +1 -0
  124. package/esm/PieChart/dataTransform/useTransformData.js +9 -1
  125. package/esm/PieChart/index.d.ts +1 -0
  126. package/esm/PieChart/index.js +1 -0
  127. package/esm/RadarChart/RadarAxis/useRadarAxis.js +2 -2
  128. package/esm/RadarChart/RadarChart.plugins.d.ts +1 -1
  129. package/esm/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +3 -3
  130. package/esm/RadarChart/index.d.ts +2 -1
  131. package/esm/RadarChart/index.js +2 -1
  132. package/esm/RadarChart/useRadarChartProps.d.ts +2 -2
  133. package/esm/RadarChart/useRadarChartProps.js +2 -1
  134. package/esm/ScatterChart/BatchScatter.d.ts +32 -0
  135. package/esm/ScatterChart/BatchScatter.js +165 -0
  136. package/esm/ScatterChart/Scatter.js +13 -5
  137. package/esm/ScatterChart/ScatterChart.d.ts +4 -4
  138. package/esm/ScatterChart/ScatterChart.js +13 -2
  139. package/esm/ScatterChart/ScatterChart.plugins.d.ts +4 -3
  140. package/esm/ScatterChart/ScatterChart.plugins.js +3 -2
  141. package/esm/ScatterChart/ScatterPlot.d.ts +10 -0
  142. package/esm/ScatterChart/ScatterPlot.js +14 -2
  143. package/esm/ScatterChart/index.d.ts +1 -0
  144. package/esm/ScatterChart/index.js +1 -0
  145. package/esm/ScatterChart/useScatterChartProps.d.ts +2 -2
  146. package/esm/ScatterChart/useScatterChartProps.js +10 -6
  147. package/esm/SparkLineChart/SparkLineChart.js +10 -5
  148. package/esm/colorPalettes/types.d.ts +1 -1
  149. package/esm/context/ChartApi.d.ts +6 -6
  150. package/esm/hooks/useAxis.d.ts +5 -5
  151. package/esm/hooks/useDrawingArea.d.ts +20 -2
  152. package/esm/hooks/useFocusedItem.d.ts +15 -0
  153. package/esm/hooks/useFocusedItem.js +20 -0
  154. package/esm/hooks/useIsItemFocused.d.ts +12 -0
  155. package/esm/hooks/useIsItemFocused.js +15 -0
  156. package/esm/hooks/useIsItemFocusedGetter.d.ts +8 -0
  157. package/esm/hooks/useIsItemFocusedGetter.js +14 -0
  158. package/esm/hooks/useScale.js +8 -2
  159. package/esm/hooks/useTicks.js +2 -2
  160. package/esm/hooks/useTicksGrouped.js +2 -2
  161. package/esm/index.d.ts +1 -0
  162. package/esm/index.js +2 -1
  163. package/esm/internals/animation/Transition.js +1 -3
  164. package/esm/internals/index.d.ts +4 -3
  165. package/esm/internals/index.js +4 -3
  166. package/esm/internals/invertScale.js +2 -2
  167. package/esm/internals/plugins/allPlugins.d.ts +5 -4
  168. package/esm/internals/plugins/allPlugins.js +3 -2
  169. package/esm/internals/plugins/corePlugins/useChartSeries/processSeries.d.ts +1 -1
  170. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +2 -0
  171. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +66 -72
  172. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +3 -19
  173. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +10 -18
  174. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.d.ts +1 -1
  175. package/{internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.d.ts → esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtrema.d.ts} +1 -1
  176. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtrema.js +24 -0
  177. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.d.ts +63 -0
  178. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +123 -0
  179. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -3
  180. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +8 -6
  181. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +2 -0
  182. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +46 -4
  183. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +10 -0
  184. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +32 -21
  185. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/index.d.ts +3 -0
  186. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/index.js +2 -0
  187. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.d.ts +3 -0
  188. package/esm/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.js → useChartClosestPoint/useChartClosestPoint.js} +9 -7
  189. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.selectors.d.ts +5 -0
  190. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.selectors.js +3 -0
  191. package/esm/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.types.d.ts → useChartClosestPoint/useChartClosestPoint.types.d.ts} +8 -4
  192. package/esm/internals/plugins/featurePlugins/useChartHighlight/highlightStates.d.ts +16 -0
  193. package/esm/internals/plugins/featurePlugins/useChartHighlight/highlightStates.js +32 -0
  194. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +4 -0
  195. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +5 -0
  196. package/esm/internals/plugins/featurePlugins/useChartInteraction/checkHasInteractionPlugin.d.ts +3 -0
  197. package/esm/internals/plugins/featurePlugins/useChartInteraction/checkHasInteractionPlugin.js +3 -0
  198. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.d.ts +3 -0
  199. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.js +2 -0
  200. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.d.ts +3 -0
  201. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +20 -0
  202. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +88 -0
  203. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +210 -0
  204. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +25 -0
  205. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +7 -0
  206. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +34 -0
  207. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.js +1 -0
  208. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.js +2 -2
  209. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +10 -8
  210. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +2 -1
  211. package/esm/internals/plugins/models/seriesConfig/getSeriesWithDefaultValues.types.d.ts +1 -1
  212. package/esm/internals/scaleGuards.d.ts +11 -0
  213. package/esm/internals/scaleGuards.js +9 -0
  214. package/esm/locales/elGR.d.ts +96 -0
  215. package/esm/locales/elGR.js +100 -0
  216. package/esm/locales/enUS.d.ts +96 -0
  217. package/esm/locales/enUS.js +99 -1
  218. package/esm/locales/frFR.d.ts +96 -0
  219. package/esm/locales/frFR.js +100 -2
  220. package/esm/locales/ptBR.d.ts +96 -0
  221. package/esm/locales/ptBR.js +100 -0
  222. package/esm/locales/ptPT.d.ts +96 -0
  223. package/esm/locales/ptPT.js +100 -0
  224. package/esm/locales/svSE.d.ts +97 -1
  225. package/esm/locales/svSE.js +100 -0
  226. package/esm/locales/utils/chartsLocaleTextApi.d.ts +384 -0
  227. package/esm/locales/utils/getChartsLocalization.d.ts +96 -0
  228. package/esm/models/axis.d.ts +3 -0
  229. package/esm/plugins/index.d.ts +6 -0
  230. package/esm/plugins/index.js +12 -0
  231. package/hooks/useAxis.d.ts +5 -5
  232. package/hooks/useDrawingArea.d.ts +20 -2
  233. package/hooks/useFocusedItem.d.ts +15 -0
  234. package/hooks/useFocusedItem.js +26 -0
  235. package/hooks/useIsItemFocused.d.ts +12 -0
  236. package/hooks/useIsItemFocused.js +20 -0
  237. package/hooks/useIsItemFocusedGetter.d.ts +8 -0
  238. package/hooks/useIsItemFocusedGetter.js +18 -0
  239. package/hooks/useScale.js +8 -2
  240. package/hooks/useTicks.js +2 -2
  241. package/hooks/useTicksGrouped.js +2 -2
  242. package/index.d.ts +1 -0
  243. package/index.js +13 -1
  244. package/internals/animation/Transition.js +0 -2
  245. package/internals/index.d.ts +4 -3
  246. package/internals/index.js +24 -12
  247. package/internals/invertScale.js +2 -2
  248. package/internals/plugins/allPlugins.d.ts +5 -4
  249. package/internals/plugins/allPlugins.js +3 -2
  250. package/internals/plugins/corePlugins/useChartSeries/processSeries.d.ts +1 -1
  251. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +2 -0
  252. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +63 -69
  253. package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +3 -19
  254. package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +10 -18
  255. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.d.ts +1 -1
  256. package/{esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.d.ts → internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtrema.d.ts} +1 -1
  257. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtrema.js +30 -0
  258. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.d.ts +63 -0
  259. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +134 -0
  260. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -3
  261. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +8 -6
  262. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +2 -0
  263. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +47 -5
  264. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +10 -0
  265. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +33 -22
  266. package/internals/plugins/featurePlugins/useChartClosestPoint/index.d.ts +3 -0
  267. package/internals/plugins/featurePlugins/useChartClosestPoint/index.js +27 -0
  268. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.d.ts +3 -0
  269. package/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.js → useChartClosestPoint/useChartClosestPoint.js} +11 -9
  270. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.selectors.d.ts +5 -0
  271. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.selectors.js +9 -0
  272. package/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.types.d.ts → useChartClosestPoint/useChartClosestPoint.types.d.ts} +8 -4
  273. package/internals/plugins/featurePlugins/useChartHighlight/highlightStates.d.ts +16 -0
  274. package/internals/plugins/featurePlugins/useChartHighlight/highlightStates.js +41 -0
  275. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +4 -0
  276. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +6 -1
  277. package/internals/plugins/featurePlugins/useChartInteraction/checkHasInteractionPlugin.d.ts +3 -0
  278. package/internals/plugins/featurePlugins/useChartInteraction/checkHasInteractionPlugin.js +9 -0
  279. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.d.ts +3 -0
  280. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.js +27 -0
  281. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.d.ts +3 -0
  282. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +20 -0
  283. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +96 -0
  284. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +218 -0
  285. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +25 -0
  286. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +13 -0
  287. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +34 -0
  288. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.js +5 -0
  289. package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.js +2 -2
  290. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +10 -8
  291. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +2 -1
  292. package/internals/plugins/models/seriesConfig/getSeriesWithDefaultValues.types.d.ts +1 -1
  293. package/internals/scaleGuards.d.ts +11 -0
  294. package/internals/scaleGuards.js +17 -0
  295. package/locales/elGR.d.ts +96 -0
  296. package/locales/elGR.js +100 -0
  297. package/locales/enUS.d.ts +96 -0
  298. package/locales/enUS.js +99 -1
  299. package/locales/frFR.d.ts +96 -0
  300. package/locales/frFR.js +100 -2
  301. package/locales/ptBR.d.ts +96 -0
  302. package/locales/ptBR.js +100 -0
  303. package/locales/ptPT.d.ts +96 -0
  304. package/locales/ptPT.js +100 -0
  305. package/locales/svSE.d.ts +97 -1
  306. package/locales/svSE.js +100 -0
  307. package/locales/utils/chartsLocaleTextApi.d.ts +384 -0
  308. package/locales/utils/getChartsLocalization.d.ts +96 -0
  309. package/models/axis.d.ts +3 -0
  310. package/package.json +4 -4
  311. package/plugins/index.d.ts +6 -0
  312. package/plugins/index.js +47 -0
  313. package/esm/internals/isBandScale.d.ts +0 -5
  314. package/esm/internals/isBandScale.js +0 -3
  315. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js +0 -22
  316. package/esm/internals/plugins/featurePlugins/useChartVoronoi/index.d.ts +0 -3
  317. package/esm/internals/plugins/featurePlugins/useChartVoronoi/index.js +0 -2
  318. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.d.ts +0 -3
  319. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +0 -5
  320. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.js +0 -3
  321. package/internals/isBandScale.d.ts +0 -5
  322. package/internals/isBandScale.js +0 -9
  323. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js +0 -29
  324. package/internals/plugins/featurePlugins/useChartVoronoi/index.d.ts +0 -3
  325. package/internals/plugins/featurePlugins/useChartVoronoi/index.js +0 -27
  326. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.d.ts +0 -3
  327. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +0 -5
  328. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.js +0 -9
  329. /package/esm/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.types.js → useChartClosestPoint/useChartClosestPoint.types.js} +0 -0
  330. /package/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.types.js → useChartClosestPoint/useChartClosestPoint.types.js} +0 -0
@@ -29,10 +29,11 @@ export interface UseChartVoronoiParameters {
29
29
  */
30
30
  disableVoronoi?: boolean;
31
31
  /**
32
- * Defines the maximal distance between a scatter point and the pointer that triggers the interaction.
32
+ * Defines the maximum distance between a scatter point and the pointer that triggers the interaction.
33
+ * If set to `'item'`, the radius is the `markerSize`.
33
34
  * If `undefined`, the radius is assumed to be infinite.
34
35
  */
35
- voronoiMaxRadius?: number | undefined;
36
+ voronoiMaxRadius?: 'item' | number | undefined;
36
37
  /**
37
38
  * Callback fired when clicking close to an item.
38
39
  * This is only available for scatter plot for now.
@@ -41,10 +42,13 @@ export interface UseChartVoronoiParameters {
41
42
  */
42
43
  onItemClick?: (event: MouseEvent, scatterItemIdentifier: ScatterItemIdentifier) => void;
43
44
  }
44
- export type UseChartVoronoiDefaultizedParameters = UseChartVoronoiParameters & {
45
+ export type UseChartVoronoiDefaultizedParameters = Pick<UseChartVoronoiParameters, 'voronoiMaxRadius' | 'onItemClick'> & {
46
+ /**
47
+ * If true, the voronoi plugin is disabled.
48
+ */
45
49
  disableVoronoi: boolean;
46
50
  };
47
- export type UseChartVoronoiSignature = ChartPluginSignature<{
51
+ export type UseChartClosestPointSignature = ChartPluginSignature<{
48
52
  instance: UseChartVoronoiInstance;
49
53
  state: UseChartVoronoiState;
50
54
  params: UseChartVoronoiParameters;
@@ -0,0 +1,16 @@
1
+ import { HighlightItemData } from "./useChartHighlight.types.js";
2
+ import { HighlightScope } from "./highlightConfig.types.js";
3
+ import { SeriesId } from "../../../../models/seriesType/common.js";
4
+ export declare function isSeriesHighlighted(scope: Partial<HighlightScope> | null, item: HighlightItemData | null, seriesId: SeriesId): boolean;
5
+ export declare function isSeriesFaded(scope: Partial<HighlightScope> | null, item: HighlightItemData | null, seriesId: SeriesId): boolean;
6
+ /**
7
+ * Returns the data index of the highlighted item for a specific series.
8
+ * If the item is not highlighted, it returns `null`.
9
+ */
10
+ export declare function getSeriesHighlightedItem(scope: Partial<HighlightScope> | null, item: HighlightItemData | null, seriesId: SeriesId): number | null | undefined;
11
+ /**
12
+ * Returns the data index of the "unfaded item" for a specific series.
13
+ * An "unfaded item" is the only item of a faded series that shouldn't be faded.
14
+ * If the series is not faded or if there is no highlighted item, it returns `null`.
15
+ */
16
+ export declare function getSeriesUnfadedItem(scope: Partial<HighlightScope> | null, item: HighlightItemData | null, seriesId: SeriesId): number | null | undefined;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getSeriesHighlightedItem = getSeriesHighlightedItem;
7
+ exports.getSeriesUnfadedItem = getSeriesUnfadedItem;
8
+ exports.isSeriesFaded = isSeriesFaded;
9
+ exports.isSeriesHighlighted = isSeriesHighlighted;
10
+ function isSeriesHighlighted(scope, item, seriesId) {
11
+ return scope?.highlight === 'series' && item?.seriesId === seriesId;
12
+ }
13
+ function isSeriesFaded(scope, item, seriesId) {
14
+ if (isSeriesHighlighted(scope, item, seriesId)) {
15
+ return false;
16
+ }
17
+ return scope?.fade === 'global' && item != null || scope?.fade === 'series' && item?.seriesId === seriesId;
18
+ }
19
+
20
+ /**
21
+ * Returns the data index of the highlighted item for a specific series.
22
+ * If the item is not highlighted, it returns `null`.
23
+ */
24
+ function getSeriesHighlightedItem(scope, item, seriesId) {
25
+ return scope?.highlight === 'item' && item?.seriesId === seriesId ? item.dataIndex : null;
26
+ }
27
+
28
+ /**
29
+ * Returns the data index of the "unfaded item" for a specific series.
30
+ * An "unfaded item" is the only item of a faded series that shouldn't be faded.
31
+ * If the series is not faded or if there is no highlighted item, it returns `null`.
32
+ */
33
+ function getSeriesUnfadedItem(scope, item, seriesId) {
34
+ if (isSeriesHighlighted(scope, item, seriesId)) {
35
+ return null;
36
+ }
37
+ if (getSeriesHighlightedItem(scope, item, seriesId) === item?.dataIndex) {
38
+ return null;
39
+ }
40
+ return (scope?.fade === 'series' || scope?.fade === 'global') && item?.seriesId === seriesId ? item.dataIndex : null;
41
+ }
@@ -27,4 +27,8 @@ export declare const selectorChartsIsFadedCallback: import("reselect").Selector<
27
27
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
28
28
  } & import("./useChartHighlight.types.js").UseChartHighlightState, (item: HighlightItemData | null) => boolean, any[]>;
29
29
  export declare const selectorChartsIsHighlighted: import("reselect").Selector<any, boolean, [item: HighlightItemData | null]>;
30
+ export declare const selectorChartIsSeriesHighlighted: import("reselect").Selector<any, boolean, [seriesId: SeriesId]>;
31
+ export declare const selectorChartIsSeriesFaded: import("reselect").Selector<any, boolean, [seriesId: SeriesId]>;
32
+ export declare const selectorChartSeriesUnfadedItem: import("reselect").Selector<any, number | null | undefined, [seriesId: SeriesId]>;
33
+ export declare const selectorChartSeriesHighlightedItem: import("reselect").Selector<any, number | null | undefined, [seriesId: SeriesId]>;
30
34
  export declare const selectorChartsIsFaded: import("reselect").Selector<any, boolean, [item: HighlightItemData | null]>;
@@ -3,10 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.selectorChartsIsHighlightedCallback = exports.selectorChartsIsHighlighted = exports.selectorChartsIsFadedCallback = exports.selectorChartsIsFaded = exports.selectorChartsHighlightedItem = exports.selectorChartsHighlightScopePerSeriesId = exports.selectorChartsHighlightScope = void 0;
6
+ exports.selectorChartsIsHighlightedCallback = exports.selectorChartsIsHighlighted = exports.selectorChartsIsFadedCallback = exports.selectorChartsIsFaded = exports.selectorChartsHighlightedItem = exports.selectorChartsHighlightScopePerSeriesId = exports.selectorChartsHighlightScope = exports.selectorChartSeriesUnfadedItem = exports.selectorChartSeriesHighlightedItem = exports.selectorChartIsSeriesHighlighted = exports.selectorChartIsSeriesFaded = void 0;
7
7
  var _selectors = require("../../utils/selectors");
8
8
  var _createIsHighlighted = require("./createIsHighlighted");
9
9
  var _createIsFaded = require("./createIsFaded");
10
+ var _highlightStates = require("./highlightStates");
10
11
  const selectHighlight = state => state.highlight;
11
12
  const selectSeries = state => state.series;
12
13
  const selectorChartsHighlightScopePerSeriesId = exports.selectorChartsHighlightScopePerSeriesId = (0, _selectors.createSelector)([selectSeries], series => {
@@ -38,6 +39,10 @@ const selectorChartsIsFadedCallback = exports.selectorChartsIsFadedCallback = (0
38
39
  const selectorChartsIsHighlighted = exports.selectorChartsIsHighlighted = (0, _selectors.createSelector)([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, item) => item], function selectorChartsIsHighlighted(highlightScope, highlightedItem, item) {
39
40
  return (0, _createIsHighlighted.createIsHighlighted)(highlightScope, highlightedItem)(item);
40
41
  });
42
+ const selectorChartIsSeriesHighlighted = exports.selectorChartIsSeriesHighlighted = (0, _selectors.createSelector)([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, seriesId) => seriesId], _highlightStates.isSeriesHighlighted);
43
+ const selectorChartIsSeriesFaded = exports.selectorChartIsSeriesFaded = (0, _selectors.createSelector)([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, seriesId) => seriesId], _highlightStates.isSeriesFaded);
44
+ const selectorChartSeriesUnfadedItem = exports.selectorChartSeriesUnfadedItem = (0, _selectors.createSelector)([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, seriesId) => seriesId], _highlightStates.getSeriesUnfadedItem);
45
+ const selectorChartSeriesHighlightedItem = exports.selectorChartSeriesHighlightedItem = (0, _selectors.createSelector)([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, seriesId) => seriesId], _highlightStates.getSeriesHighlightedItem);
41
46
  const selectorChartsIsFaded = exports.selectorChartsIsFaded = (0, _selectors.createSelector)([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, item) => item], function selectorChartsIsFaded(highlightScope, highlightedItem, item) {
42
47
  return (0, _createIsFaded.createIsFaded)(highlightScope, highlightedItem)(item);
43
48
  });
@@ -0,0 +1,3 @@
1
+ import { ChartAnyPluginSignature, ChartUsedInstance } from "../../models/plugin.js";
2
+ import { UseChartInteractionInstance } from "./useChartInteraction.types.js";
3
+ export declare function checkHasInteractionPlugin<T extends ChartAnyPluginSignature>(instance: ChartUsedInstance<T>): instance is ChartUsedInstance<T> & UseChartInteractionInstance;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.checkHasInteractionPlugin = checkHasInteractionPlugin;
7
+ function checkHasInteractionPlugin(instance) {
8
+ return instance.setPointerCoordinate !== undefined;
9
+ }
@@ -0,0 +1,3 @@
1
+ export { useChartKeyboardNavigation } from "./useChartKeyboardNavigation.js";
2
+ export * from "./useChartKeyboardNavigation.selectors.js";
3
+ export type { UseChartKeyboardNavigationSignature } from "./useChartKeyboardNavigation.types.js";
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ useChartKeyboardNavigation: true
8
+ };
9
+ Object.defineProperty(exports, "useChartKeyboardNavigation", {
10
+ enumerable: true,
11
+ get: function () {
12
+ return _useChartKeyboardNavigation.useChartKeyboardNavigation;
13
+ }
14
+ });
15
+ var _useChartKeyboardNavigation = require("./useChartKeyboardNavigation");
16
+ var _useChartKeyboardNavigation2 = require("./useChartKeyboardNavigation.selectors");
17
+ Object.keys(_useChartKeyboardNavigation2).forEach(function (key) {
18
+ if (key === "default" || key === "__esModule") return;
19
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
20
+ if (key in exports && exports[key] === _useChartKeyboardNavigation2[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _useChartKeyboardNavigation2[key];
25
+ }
26
+ });
27
+ });
@@ -0,0 +1,3 @@
1
+ import { ChartPlugin } from "../../models/index.js";
2
+ import { UseChartKeyboardNavigationSignature } from "./useChartKeyboardNavigation.types.js";
3
+ export declare const useChartKeyboardNavigation: ChartPlugin<UseChartKeyboardNavigationSignature>;
@@ -0,0 +1,20 @@
1
+ import { ChartSeriesType, ChartsSeriesConfig } from "../../../../models/seriesType/config.js";
2
+ import { SeriesId } from "../../../../models/seriesType/common.js";
3
+ import { 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
+ */
8
+ export declare function getNextSeriesWithData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type?: ChartSeriesType, seriesId?: SeriesId): {
9
+ type: Exclude<ChartSeriesType, 'sankey'>;
10
+ seriesId: SeriesId;
11
+ } | null;
12
+ /**
13
+ * Returns the previous series type and id that contains some data.
14
+ * Returns `null` if no other series have data.
15
+ */
16
+ export declare function getPreviousSeriesWithData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type?: ChartSeriesType, seriesId?: SeriesId): {
17
+ type: Exclude<ChartSeriesType, 'sankey'>;
18
+ seriesId: SeriesId;
19
+ } | null;
20
+ export declare function seriesHasData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type: ChartSeriesType, seriesId: SeriesId): boolean | undefined;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getNextSeriesWithData = getNextSeriesWithData;
7
+ exports.getPreviousSeriesWithData = getPreviousSeriesWithData;
8
+ exports.seriesHasData = seriesHasData;
9
+ /**
10
+ * Returns the next series type and id that contains some data.
11
+ * Returns `null` if no other series have data.
12
+ */
13
+ function getNextSeriesWithData(series, type, seriesId) {
14
+ const startingTypeIndex = type !== undefined && series[type] ? Object.keys(series).indexOf(type) : 0;
15
+ const currentSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : -1;
16
+ const typesAvailable = Object.keys(series).filter(t => t !== 'sankey');
17
+
18
+ // Loop over all series types starting with the current seriesType
19
+ for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
20
+ const typeIndex = (startingTypeIndex + typeGap) % typesAvailable.length;
21
+ const seriesOfType = series[typesAvailable[typeIndex]];
22
+
23
+ // Edge case for the current series type: we don't loop on previous series of the same type.
24
+ const startingSeriesIndex = typeGap === 0 ? currentSeriesIndex + 1 : 0;
25
+ for (let seriesIndex = startingSeriesIndex; seriesIndex < seriesOfType.seriesOrder.length; seriesIndex += 1) {
26
+ if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
27
+ return {
28
+ type: typesAvailable[typeIndex],
29
+ seriesId: seriesOfType.seriesOrder[seriesIndex]
30
+ };
31
+ }
32
+ }
33
+ }
34
+
35
+ // End looping on the initial type up to the initial series (excluded)
36
+ const typeIndex = startingTypeIndex;
37
+ const seriesOfType = series[typesAvailable[typeIndex]];
38
+ const endingSeriesIndex = currentSeriesIndex;
39
+ for (let seriesIndex = 0; seriesIndex < endingSeriesIndex; seriesIndex += 1) {
40
+ if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
41
+ return {
42
+ type: typesAvailable[typeIndex],
43
+ seriesId: seriesOfType.seriesOrder[seriesIndex]
44
+ };
45
+ }
46
+ }
47
+ return null;
48
+ }
49
+
50
+ /**
51
+ * Returns the previous series type and id that contains some data.
52
+ * Returns `null` if no other series have data.
53
+ */
54
+ function getPreviousSeriesWithData(series, type, seriesId) {
55
+ const startingTypeIndex = type !== undefined && series[type] ? Object.keys(series).indexOf(type) : 0;
56
+ const startingSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : 1;
57
+ const typesAvailable = Object.keys(series).filter(t => t !== 'sankey');
58
+
59
+ // Loop over all series types starting with the current seriesType
60
+ for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
61
+ const typeIndex = (typesAvailable.length + startingTypeIndex - typeGap) % typesAvailable.length;
62
+ const seriesOfType = series[typesAvailable[typeIndex]];
63
+ const maxGap = typeGap === 0 ? startingSeriesIndex + 1 : seriesOfType.seriesOrder.length;
64
+ for (let seriesGap = 1; seriesGap < maxGap; seriesGap += 1) {
65
+ const seriesIndex = (seriesOfType.seriesOrder.length + startingSeriesIndex - seriesGap) % seriesOfType.seriesOrder.length;
66
+ if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
67
+ return {
68
+ type: typesAvailable[typeIndex],
69
+ seriesId: seriesOfType.seriesOrder[seriesIndex]
70
+ };
71
+ }
72
+ }
73
+ }
74
+
75
+ // End looping on the initial type down to the initial series (excluded)
76
+ const typeIndex = startingTypeIndex;
77
+ const seriesOfType = series[typesAvailable[typeIndex]];
78
+ const availableSeriesIds = seriesOfType.seriesOrder;
79
+ for (let seriesIndex = availableSeriesIds.length - 1; seriesIndex > startingSeriesIndex; seriesIndex -= 1) {
80
+ if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
81
+ return {
82
+ type: typesAvailable[typeIndex],
83
+ seriesId: seriesOfType.seriesOrder[seriesIndex]
84
+ };
85
+ }
86
+ }
87
+ return null;
88
+ }
89
+ function seriesHasData(series, type, seriesId) {
90
+ // @ts-ignore snakey is not in MIT version
91
+ if (type === 'sankey') {
92
+ return false;
93
+ }
94
+ const data = series[type]?.series[seriesId]?.data;
95
+ return data && data.length > 0;
96
+ }
@@ -0,0 +1,218 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.useChartKeyboardNavigation = void 0;
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+ var React = _interopRequireWildcard(require("react"));
12
+ var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
13
+ var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
14
+ var _useChartKeyboardNavigation = require("./useChartKeyboardNavigation.helpers");
15
+ const useChartKeyboardNavigation = ({
16
+ params,
17
+ store,
18
+ svgRef
19
+ }) => {
20
+ const focusNextItem = (0, _useEventCallback.default)(function focusNextItem() {
21
+ store.update(state => {
22
+ let {
23
+ type,
24
+ seriesId
25
+ } = state.keyboardNavigation.item ?? {};
26
+ if (type === undefined ||
27
+ // @ts-ignore sankey is not in MIT version
28
+ type === 'sankey' || seriesId === undefined || !(0, _useChartKeyboardNavigation.seriesHasData)(state.series.processedSeries, type, seriesId)) {
29
+ const nextSeries = (0, _useChartKeyboardNavigation.getNextSeriesWithData)(state.series.processedSeries, type, seriesId);
30
+ if (nextSeries === null) {
31
+ return (0, _extends2.default)({}, state, {
32
+ keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
33
+ item: null // No series to move the focus too.
34
+ })
35
+ });
36
+ }
37
+ type = nextSeries.type;
38
+ seriesId = nextSeries.seriesId;
39
+ }
40
+ const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
41
+ return (0, _extends2.default)({}, state, {
42
+ keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
43
+ item: {
44
+ type,
45
+ seriesId,
46
+ dataIndex: ((state.keyboardNavigation.item?.dataIndex ?? -1) + 1) % dataLength
47
+ }
48
+ })
49
+ });
50
+ });
51
+ });
52
+ const focusPreviousItem = (0, _useEventCallback.default)(function focusPreviousItem() {
53
+ store.update(state => {
54
+ let {
55
+ type,
56
+ seriesId
57
+ } = state.keyboardNavigation.item ?? {};
58
+ if (type === undefined ||
59
+ // @ts-ignore sankey is not in MIT version
60
+ type === 'sankey' || seriesId === undefined || !(0, _useChartKeyboardNavigation.seriesHasData)(state.series.processedSeries, type, seriesId)) {
61
+ const previousSeries = (0, _useChartKeyboardNavigation.getPreviousSeriesWithData)(state.series.processedSeries, type, seriesId);
62
+ if (previousSeries === null) {
63
+ return (0, _extends2.default)({}, state, {
64
+ keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
65
+ item: null // No series to move the focus too.} };
66
+ })
67
+ });
68
+ }
69
+ type = previousSeries.type;
70
+ seriesId = previousSeries.seriesId;
71
+ }
72
+ const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
73
+ return (0, _extends2.default)({}, state, {
74
+ keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
75
+ item: {
76
+ type,
77
+ seriesId,
78
+ dataIndex: (dataLength + (state.keyboardNavigation.item?.dataIndex ?? 1) - 1) % dataLength
79
+ }
80
+ })
81
+ });
82
+ });
83
+ });
84
+ const focusPreviousSeries = (0, _useEventCallback.default)(function focusPreviousSeries() {
85
+ let setNewSeries = false;
86
+ store.update(state => {
87
+ let {
88
+ type,
89
+ seriesId
90
+ } = state.keyboardNavigation.item ?? {};
91
+ const previousSeries = (0, _useChartKeyboardNavigation.getPreviousSeriesWithData)(state.series.processedSeries, type, seriesId);
92
+ if (previousSeries === null) {
93
+ return (0, _extends2.default)({}, state, {
94
+ keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
95
+ item: null // No series to move the focus too.
96
+ })
97
+ });
98
+ }
99
+ type = previousSeries.type;
100
+ seriesId = previousSeries.seriesId;
101
+ const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
102
+ setNewSeries = true;
103
+ return (0, _extends2.default)({}, state, {
104
+ keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
105
+ item: {
106
+ type,
107
+ seriesId,
108
+ dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
109
+ }
110
+ })
111
+ });
112
+ });
113
+ return setNewSeries;
114
+ });
115
+ const focusNextSeries = (0, _useEventCallback.default)(function focusNextSeries() {
116
+ let setNewSeries = false;
117
+ store.update(state => {
118
+ let {
119
+ type,
120
+ seriesId
121
+ } = state.keyboardNavigation.item ?? {};
122
+ const nextSeries = (0, _useChartKeyboardNavigation.getNextSeriesWithData)(state.series.processedSeries, type, seriesId);
123
+ if (nextSeries === null) {
124
+ return (0, _extends2.default)({}, state, {
125
+ keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
126
+ item: null // No series to move the focus too.
127
+ })
128
+ });
129
+ }
130
+ type = nextSeries.type;
131
+ seriesId = nextSeries.seriesId;
132
+ const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
133
+ setNewSeries = true;
134
+ return (0, _extends2.default)({}, state, {
135
+ keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
136
+ item: {
137
+ type,
138
+ seriesId,
139
+ dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
140
+ }
141
+ })
142
+ });
143
+ });
144
+ return setNewSeries;
145
+ });
146
+ const removeFocus = (0, _useEventCallback.default)(function removeFocus() {
147
+ store.update(state => {
148
+ if (state.keyboardNavigation.item === null) {
149
+ return state;
150
+ }
151
+ return (0, _extends2.default)({}, state, {
152
+ keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
153
+ item: null
154
+ })
155
+ });
156
+ });
157
+ });
158
+ React.useEffect(() => {
159
+ const element = svgRef.current;
160
+ if (!element || !params.enableKeyboardNavigation) {
161
+ return undefined;
162
+ }
163
+ function keyboardHandler(event) {
164
+ switch (event.key) {
165
+ case 'ArrowRight':
166
+ focusNextItem();
167
+ break;
168
+ case 'ArrowLeft':
169
+ focusPreviousItem();
170
+ break;
171
+ case 'ArrowDown':
172
+ {
173
+ const updatedStore = focusPreviousSeries();
174
+ if (updatedStore) {
175
+ // prevents scrolling
176
+ event.preventDefault();
177
+ }
178
+ break;
179
+ }
180
+ case 'ArrowUp':
181
+ {
182
+ const updatedStore = focusNextSeries();
183
+ if (updatedStore) {
184
+ // prevents scrolling
185
+ event.preventDefault();
186
+ }
187
+ break;
188
+ }
189
+ default:
190
+ break;
191
+ }
192
+ }
193
+ element.addEventListener('keydown', keyboardHandler);
194
+ element.addEventListener('blur', removeFocus);
195
+ return () => {
196
+ element.removeEventListener('keydown', keyboardHandler);
197
+ element.removeEventListener('blur', removeFocus);
198
+ };
199
+ }, [svgRef, focusNextItem, focusPreviousItem, removeFocus, focusPreviousSeries, focusNextSeries, params.enableKeyboardNavigation]);
200
+ (0, _useEnhancedEffect.default)(() => store.update(prev => prev.keyboardNavigation.enableKeyboardNavigation === params.enableKeyboardNavigation ? prev : (0, _extends2.default)({}, prev, {
201
+ keyboardNavigation: (0, _extends2.default)({}, prev.keyboardNavigation, {
202
+ enableKeyboardNavigation: !!params.enableKeyboardNavigation
203
+ })
204
+ })), [store, params.enableKeyboardNavigation]);
205
+ return {
206
+ instance: {}
207
+ };
208
+ };
209
+ exports.useChartKeyboardNavigation = useChartKeyboardNavigation;
210
+ useChartKeyboardNavigation.getInitialState = params => ({
211
+ keyboardNavigation: {
212
+ item: null,
213
+ enableKeyboardNavigation: !!params.enableKeyboardNavigation
214
+ }
215
+ });
216
+ useChartKeyboardNavigation.params = {
217
+ enableKeyboardNavigation: true
218
+ };
@@ -0,0 +1,25 @@
1
+ export declare const selectorChartsHasFocusedItem: import("reselect").Selector<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> & {
2
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
3
+ } & {
4
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
5
+ }, boolean, any[]>;
6
+ export declare const selectorChartsFocusedSeriesType: import("reselect").Selector<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> & {
7
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
8
+ } & {
9
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
10
+ }, keyof import("../../../index.js").ChartsSeriesConfig | undefined, any[]>;
11
+ export declare const selectorChartsFocusedSeriesId: import("reselect").Selector<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> & {
12
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
13
+ } & {
14
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
15
+ }, import("../../../index.js").SeriesId | undefined, any[]>;
16
+ export declare const selectorChartsFocusedDataIndex: import("reselect").Selector<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
+ } & {
19
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
20
+ }, number | undefined, any[]>;
21
+ export declare const selectorChartsIsKeyboardNavigationEnabled: import("reselect").Selector<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> & {
22
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
23
+ } & {
24
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
25
+ }, boolean, any[]>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.selectorChartsIsKeyboardNavigationEnabled = exports.selectorChartsHasFocusedItem = exports.selectorChartsFocusedSeriesType = exports.selectorChartsFocusedSeriesId = exports.selectorChartsFocusedDataIndex = void 0;
7
+ var _selectors = require("../../utils/selectors");
8
+ const selectKeyboardNavigation = state => state.keyboardNavigation;
9
+ const selectorChartsHasFocusedItem = exports.selectorChartsHasFocusedItem = (0, _selectors.createSelector)([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item != null);
10
+ const selectorChartsFocusedSeriesType = exports.selectorChartsFocusedSeriesType = (0, _selectors.createSelector)([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item?.type);
11
+ const selectorChartsFocusedSeriesId = exports.selectorChartsFocusedSeriesId = (0, _selectors.createSelector)([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item?.seriesId);
12
+ const selectorChartsFocusedDataIndex = exports.selectorChartsFocusedDataIndex = (0, _selectors.createSelector)([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item?.dataIndex);
13
+ const selectorChartsIsKeyboardNavigationEnabled = exports.selectorChartsIsKeyboardNavigationEnabled = (0, _selectors.createSelector)([selectKeyboardNavigation], keyboardNavigationState => !!keyboardNavigationState?.enableKeyboardNavigation);
@@ -0,0 +1,34 @@
1
+ import { ChartPluginSignature } from "../../models/index.js";
2
+ import { ChartSeriesType } from "../../../../models/seriesType/config.js";
3
+ import { SeriesId } from "../../../../models/seriesType/common.js";
4
+ export interface UseChartKeyboardNavigationInstance {}
5
+ type SeriesItemIdentifier = {
6
+ /**
7
+ * The type of the series
8
+ */
9
+ type: ChartSeriesType;
10
+ /**
11
+ * The id of the series with focus.
12
+ */
13
+ seriesId: SeriesId;
14
+ /**
15
+ * The index of the data point with focus.
16
+ */
17
+ dataIndex: number;
18
+ };
19
+ export interface UseChartKeyboardNavigationState {
20
+ keyboardNavigation: {
21
+ item: null | SeriesItemIdentifier;
22
+ enableKeyboardNavigation: boolean;
23
+ };
24
+ }
25
+ type UseChartKeyboardNavigationParameters = {
26
+ enableKeyboardNavigation?: boolean;
27
+ };
28
+ export type UseChartKeyboardNavigationSignature = ChartPluginSignature<{
29
+ params: UseChartKeyboardNavigationParameters;
30
+ defaultizedParams: UseChartKeyboardNavigationParameters;
31
+ instance: UseChartKeyboardNavigationInstance;
32
+ state: UseChartKeyboardNavigationState;
33
+ }>;
34
+ export {};
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getAxisIndex = getAxisIndex;
7
- var _isBandScale = require("../../../isBandScale");
7
+ var _scaleGuards = require("../../../scaleGuards");
8
8
  var _clampAngle = require("../../../clampAngle");
9
9
  /**
10
10
  * For a pointer coordinate, this function returns the value and dataIndex associated.
@@ -16,7 +16,7 @@ function getAxisIndex(axisConfig, pointerValue) {
16
16
  data: axisData,
17
17
  reverse
18
18
  } = axisConfig;
19
- if (!(0, _isBandScale.isBandScale)(scale)) {
19
+ if (!(0, _scaleGuards.isOrdinalScale)(scale)) {
20
20
  throw new Error('MUI X Charts: getAxisValue is not implemented for polare continuous axes.');
21
21
  }
22
22
  if (!axisData) {