@mui/x-charts 8.0.0-alpha.1 → 8.0.0-alpha.2

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 (272) hide show
  1. package/BarChart/BarChart.js +0 -4
  2. package/BarChart/BarLabel/BarLabel.d.ts +298 -298
  3. package/CHANGELOG.md +228 -7
  4. package/ChartContainer/ChartContainer.d.ts +24 -0
  5. package/ChartContainer/ChartContainer.js +26 -10
  6. package/ChartContainer/useChartContainerProps.d.ts +0 -1
  7. package/ChartContainer/useChartContainerProps.js +3 -4
  8. package/ChartsAxis/axisClasses.js +2 -1
  9. package/ChartsAxisHighlight/ChartsXAxisHighlight.js +3 -3
  10. package/ChartsAxisHighlight/ChartsYAxisHighlight.js +3 -3
  11. package/ChartsLegend/chartsLegendClasses.js +2 -1
  12. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
  13. package/ChartsSurface/ChartsSurface.d.ts +14 -0
  14. package/ChartsSurface/ChartsSurface.js +38 -6
  15. package/ChartsTooltip/ChartsTooltip.js +2 -20
  16. package/ChartsTooltip/ChartsTooltipContainer.js +5 -23
  17. package/ChartsTooltip/ChartsTooltipTable.js +1 -1
  18. package/ChartsTooltip/useAxisTooltip.js +3 -3
  19. package/ChartsTooltip/useItemTooltip.d.ts +2 -3
  20. package/ChartsTooltip/useItemTooltip.js +3 -3
  21. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +3 -3
  22. package/ChartsXAxis/ChartsXAxis.js +3 -17
  23. package/ChartsYAxis/ChartsYAxis.js +2 -17
  24. package/Gauge/Gauge.d.ts +1 -1
  25. package/Gauge/GaugeContainer.d.ts +2 -2
  26. package/Gauge/GaugeContainer.js +14 -47
  27. package/LineChart/CircleMarkElement.js +3 -3
  28. package/LineChart/LineChart.js +0 -4
  29. package/LineChart/LineHighlightPlot.js +3 -3
  30. package/LineChart/MarkElement.js +3 -3
  31. package/PieChart/PieChart.js +0 -4
  32. package/ScatterChart/Scatter.js +3 -3
  33. package/ScatterChart/ScatterChart.js +0 -4
  34. package/SparkLineChart/SparkLineChart.js +0 -4
  35. package/context/CartesianProvider/defaultizeAxis.d.ts +9 -11
  36. package/context/ChartDataProvider/ChartDataProvider.d.ts +27 -0
  37. package/context/ChartDataProvider/ChartDataProvider.js +38 -18
  38. package/context/ChartDataProvider/useChartDataProviderProps.d.ts +18 -22
  39. package/context/ChartDataProvider/useDefaultizeAxis.d.ts +9 -11
  40. package/context/ChartProvider/ChartContext.d.ts +6 -0
  41. package/context/ChartProvider/ChartContext.js +8 -0
  42. package/context/ChartProvider/ChartProvider.d.ts +4 -0
  43. package/context/ChartProvider/ChartProvider.js +19 -0
  44. package/context/ChartProvider/ChartProvider.types.d.ts +24 -0
  45. package/context/ChartProvider/index.d.ts +3 -0
  46. package/context/ChartProvider/index.js +3 -0
  47. package/context/ChartProvider/useChartContext.d.ts +3 -0
  48. package/context/ChartProvider/useChartContext.js +11 -0
  49. package/context/DrawingAreaProvider/DrawingAreaContext.d.ts +1 -6
  50. package/context/DrawingAreaProvider/DrawingAreaContext.js +0 -1
  51. package/context/InteractionSelectors.d.ts +72 -49
  52. package/context/SizeProvider/Size.types.d.ts +2 -2
  53. package/context/SizeProvider/SizeContext.js +3 -1
  54. package/context/SizeProvider/useChartContainerDimensions.d.ts +1 -1
  55. package/context/SizeProvider/useChartContainerDimensions.js +5 -1
  56. package/hooks/useAxisEvents.js +1 -1
  57. package/hooks/useChartId.js +5 -6
  58. package/hooks/useInteractionItemProps.js +4 -2
  59. package/hooks/useSvgRef.d.ts +1 -1
  60. package/hooks/useSvgRef.js +4 -8
  61. package/index.js +1 -1
  62. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -5
  63. package/internals/defaultizeColor.d.ts +1 -1
  64. package/internals/index.d.ts +1 -3
  65. package/internals/index.js +1 -3
  66. package/internals/plugins/allPlugins.d.ts +1 -0
  67. package/internals/plugins/allPlugins.js +3 -0
  68. package/internals/plugins/corePlugins/corePlugins.d.ts +10 -0
  69. package/internals/plugins/corePlugins/corePlugins.js +7 -0
  70. package/internals/plugins/corePlugins/index.d.ts +2 -0
  71. package/internals/plugins/corePlugins/index.js +1 -0
  72. package/internals/plugins/corePlugins/useChartId/index.d.ts +2 -0
  73. package/internals/plugins/corePlugins/useChartId/index.js +1 -0
  74. package/internals/plugins/corePlugins/useChartId/useChartId.d.ts +3 -0
  75. package/internals/plugins/corePlugins/useChartId/useChartId.js +32 -0
  76. package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +36 -0
  77. package/internals/plugins/corePlugins/useChartId/useChartId.selectors.js +9 -0
  78. package/internals/plugins/corePlugins/useChartId/useChartId.types.d.ts +20 -0
  79. package/internals/plugins/corePlugins/useChartId/useChartId.utils.d.ts +1 -0
  80. package/internals/plugins/corePlugins/useChartId/useChartId.utils.js +5 -0
  81. package/internals/plugins/featurePlugins/useChartInteraction/index.d.ts +3 -0
  82. package/internals/plugins/featurePlugins/useChartInteraction/index.js +2 -0
  83. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.d.ts +3 -0
  84. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +73 -0
  85. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +376 -0
  86. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +10 -0
  87. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +57 -0
  88. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.js +1 -0
  89. package/internals/plugins/models/chart.d.ts +14 -0
  90. package/internals/plugins/models/chart.js +1 -0
  91. package/internals/plugins/models/helpers.d.ts +7 -0
  92. package/internals/plugins/models/helpers.js +1 -0
  93. package/internals/plugins/models/index.d.ts +3 -35
  94. package/internals/plugins/models/index.js +3 -1
  95. package/internals/plugins/models/plugin.d.ts +75 -0
  96. package/internals/plugins/models/plugin.js +1 -0
  97. package/internals/plugins/utils/ChartStore.d.ts +9 -8
  98. package/internals/plugins/utils/ChartStore.js +0 -2
  99. package/internals/plugins/utils/selectors.d.ts +2 -2
  100. package/internals/store/useCharts.d.ts +14 -0
  101. package/internals/store/useCharts.js +72 -0
  102. package/internals/store/useCharts.types.d.ts +5 -0
  103. package/internals/store/useCharts.types.js +1 -0
  104. package/internals/store/useSelector.d.ts +4 -0
  105. package/internals/store/useStore.d.ts +3 -0
  106. package/{modern/internals → internals/store}/useStore.js +6 -6
  107. package/models/axis.d.ts +1 -13
  108. package/modern/BarChart/BarChart.js +0 -4
  109. package/modern/ChartContainer/ChartContainer.js +26 -10
  110. package/modern/ChartContainer/useChartContainerProps.js +3 -4
  111. package/modern/ChartsAxis/axisClasses.js +2 -1
  112. package/modern/ChartsAxisHighlight/ChartsXAxisHighlight.js +3 -3
  113. package/modern/ChartsAxisHighlight/ChartsYAxisHighlight.js +3 -3
  114. package/modern/ChartsLegend/chartsLegendClasses.js +2 -1
  115. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
  116. package/modern/ChartsSurface/ChartsSurface.js +38 -6
  117. package/modern/ChartsTooltip/ChartsTooltip.js +2 -20
  118. package/modern/ChartsTooltip/ChartsTooltipContainer.js +5 -23
  119. package/modern/ChartsTooltip/ChartsTooltipTable.js +1 -1
  120. package/modern/ChartsTooltip/useAxisTooltip.js +3 -3
  121. package/modern/ChartsTooltip/useItemTooltip.js +3 -3
  122. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +3 -3
  123. package/modern/ChartsXAxis/ChartsXAxis.js +3 -17
  124. package/modern/ChartsYAxis/ChartsYAxis.js +2 -17
  125. package/modern/Gauge/GaugeContainer.js +14 -47
  126. package/modern/LineChart/CircleMarkElement.js +3 -3
  127. package/modern/LineChart/LineChart.js +0 -4
  128. package/modern/LineChart/LineHighlightPlot.js +3 -3
  129. package/modern/LineChart/MarkElement.js +3 -3
  130. package/modern/PieChart/PieChart.js +0 -4
  131. package/modern/ScatterChart/Scatter.js +3 -3
  132. package/modern/ScatterChart/ScatterChart.js +0 -4
  133. package/modern/SparkLineChart/SparkLineChart.js +0 -4
  134. package/modern/context/ChartDataProvider/ChartDataProvider.js +38 -18
  135. package/modern/context/ChartProvider/ChartContext.js +8 -0
  136. package/modern/context/ChartProvider/ChartProvider.js +19 -0
  137. package/modern/context/ChartProvider/ChartProvider.types.js +1 -0
  138. package/modern/context/ChartProvider/index.js +3 -0
  139. package/modern/context/ChartProvider/useChartContext.js +11 -0
  140. package/modern/context/DrawingAreaProvider/DrawingAreaContext.js +0 -1
  141. package/modern/context/SizeProvider/SizeContext.js +3 -1
  142. package/modern/context/SizeProvider/useChartContainerDimensions.js +5 -1
  143. package/modern/hooks/useAxisEvents.js +1 -1
  144. package/modern/hooks/useChartId.js +5 -6
  145. package/modern/hooks/useInteractionItemProps.js +4 -2
  146. package/modern/hooks/useSvgRef.js +4 -8
  147. package/modern/index.js +1 -1
  148. package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -5
  149. package/modern/internals/index.js +1 -3
  150. package/modern/internals/plugins/allPlugins.js +3 -0
  151. package/modern/internals/plugins/corePlugins/corePlugins.js +7 -0
  152. package/modern/internals/plugins/corePlugins/index.js +1 -0
  153. package/modern/internals/plugins/corePlugins/useChartId/index.js +1 -0
  154. package/modern/internals/plugins/corePlugins/useChartId/useChartId.js +32 -0
  155. package/modern/internals/plugins/corePlugins/useChartId/useChartId.selectors.js +9 -0
  156. package/modern/internals/plugins/corePlugins/useChartId/useChartId.types.js +1 -0
  157. package/modern/internals/plugins/corePlugins/useChartId/useChartId.utils.js +5 -0
  158. package/modern/internals/plugins/featurePlugins/useChartInteraction/index.js +2 -0
  159. package/modern/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +73 -0
  160. package/modern/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +10 -0
  161. package/modern/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.js +1 -0
  162. package/modern/internals/plugins/models/chart.js +1 -0
  163. package/modern/internals/plugins/models/helpers.js +1 -0
  164. package/modern/internals/plugins/models/index.js +3 -1
  165. package/modern/internals/plugins/models/plugin.js +1 -0
  166. package/modern/internals/plugins/utils/ChartStore.js +0 -2
  167. package/modern/internals/store/useCharts.js +72 -0
  168. package/modern/internals/store/useCharts.types.js +1 -0
  169. package/{internals → modern/internals/store}/useStore.js +6 -6
  170. package/node/BarChart/BarChart.js +0 -4
  171. package/node/ChartContainer/ChartContainer.js +26 -10
  172. package/node/ChartContainer/useChartContainerProps.js +3 -4
  173. package/node/ChartsAxis/axisClasses.js +5 -3
  174. package/node/ChartsAxisHighlight/ChartsXAxisHighlight.js +4 -4
  175. package/node/ChartsAxisHighlight/ChartsYAxisHighlight.js +4 -4
  176. package/node/ChartsLegend/chartsLegendClasses.js +5 -3
  177. package/node/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
  178. package/node/ChartsSurface/ChartsSurface.js +37 -5
  179. package/node/ChartsTooltip/ChartsTooltip.js +2 -20
  180. package/node/ChartsTooltip/ChartsTooltipContainer.js +6 -24
  181. package/node/ChartsTooltip/ChartsTooltipTable.js +2 -2
  182. package/node/ChartsTooltip/useAxisTooltip.js +4 -4
  183. package/node/ChartsTooltip/useItemTooltip.js +4 -4
  184. package/node/ChartsVoronoiHandler/ChartsVoronoiHandler.js +3 -3
  185. package/node/ChartsXAxis/ChartsXAxis.js +3 -17
  186. package/node/ChartsYAxis/ChartsYAxis.js +2 -17
  187. package/node/Gauge/GaugeContainer.js +13 -46
  188. package/node/LineChart/CircleMarkElement.js +4 -4
  189. package/node/LineChart/LineChart.js +0 -4
  190. package/node/LineChart/LineHighlightPlot.js +4 -4
  191. package/node/LineChart/MarkElement.js +4 -4
  192. package/node/PieChart/PieChart.js +0 -4
  193. package/node/ScatterChart/Scatter.js +4 -4
  194. package/node/ScatterChart/ScatterChart.js +0 -4
  195. package/node/SparkLineChart/SparkLineChart.js +0 -4
  196. package/node/context/ChartDataProvider/ChartDataProvider.js +38 -18
  197. package/node/context/ChartProvider/ChartContext.js +15 -0
  198. package/node/context/ChartProvider/ChartProvider.js +24 -0
  199. package/node/context/ChartProvider/index.js +38 -0
  200. package/node/context/ChartProvider/useChartContext.js +18 -0
  201. package/node/context/DrawingAreaProvider/DrawingAreaContext.js +0 -1
  202. package/node/context/SizeProvider/SizeContext.js +3 -1
  203. package/node/context/SizeProvider/useChartContainerDimensions.js +5 -1
  204. package/node/hooks/useAxisEvents.js +1 -1
  205. package/node/hooks/useChartId.js +5 -7
  206. package/node/hooks/useInteractionItemProps.js +4 -2
  207. package/node/hooks/useSvgRef.js +4 -9
  208. package/node/index.js +1 -1
  209. package/node/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +1 -4
  210. package/node/internals/index.js +4 -28
  211. package/node/internals/plugins/allPlugins.js +10 -0
  212. package/node/internals/plugins/corePlugins/corePlugins.js +12 -0
  213. package/node/internals/plugins/corePlugins/index.js +12 -0
  214. package/node/internals/plugins/corePlugins/useChartId/index.js +12 -0
  215. package/node/internals/plugins/corePlugins/useChartId/useChartId.js +41 -0
  216. package/node/internals/plugins/corePlugins/useChartId/useChartId.selectors.js +15 -0
  217. package/node/internals/plugins/corePlugins/useChartId/useChartId.types.js +5 -0
  218. package/node/internals/plugins/corePlugins/useChartId/useChartId.utils.js +12 -0
  219. package/node/internals/plugins/featurePlugins/useChartInteraction/index.js +27 -0
  220. package/node/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +81 -0
  221. package/node/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +16 -0
  222. package/node/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.js +5 -0
  223. package/node/internals/plugins/models/chart.js +5 -0
  224. package/node/internals/plugins/models/helpers.js +5 -0
  225. package/node/internals/plugins/models/index.js +33 -0
  226. package/node/internals/plugins/models/plugin.js +5 -0
  227. package/node/internals/plugins/utils/ChartStore.js +0 -2
  228. package/node/internals/store/useCharts.js +80 -0
  229. package/node/internals/store/useCharts.types.js +5 -0
  230. package/node/internals/{useStore.js → store/useStore.js} +6 -7
  231. package/package.json +4 -4
  232. package/ChartContainer/ResizableContainer.d.ts +0 -22
  233. package/ChartContainer/ResizableContainer.js +0 -60
  234. package/context/InteractionProvider.d.ts +0 -7
  235. package/context/InteractionProvider.js +0 -22
  236. package/context/SvgRefProvider/SvgRef.types.d.ts +0 -8
  237. package/context/SvgRefProvider/SvgRefContext.d.ts +0 -4
  238. package/context/SvgRefProvider/SvgRefContext.js +0 -17
  239. package/context/SvgRefProvider/SvgRefProvider.d.ts +0 -3
  240. package/context/SvgRefProvider/SvgRefProvider.js +0 -24
  241. package/context/SvgRefProvider/index.d.ts +0 -4
  242. package/context/SvgRefProvider/index.js +0 -4
  243. package/context/SvgRefProvider/useSurfaceRef.d.ts +0 -2
  244. package/context/SvgRefProvider/useSurfaceRef.js +0 -14
  245. package/internals/plugins/utils/ChartsStore.d.ts +0 -12
  246. package/internals/plugins/utils/ChartsStore.js +0 -26
  247. package/internals/useCharts.d.ts +0 -6
  248. package/internals/useCharts.js +0 -29
  249. package/internals/useSelector.d.ts +0 -4
  250. package/internals/useStore.d.ts +0 -2
  251. package/modern/ChartContainer/ResizableContainer.js +0 -60
  252. package/modern/context/InteractionProvider.js +0 -22
  253. package/modern/context/SvgRefProvider/SvgRefContext.js +0 -17
  254. package/modern/context/SvgRefProvider/SvgRefProvider.js +0 -24
  255. package/modern/context/SvgRefProvider/index.js +0 -4
  256. package/modern/context/SvgRefProvider/useSurfaceRef.js +0 -14
  257. package/modern/internals/plugins/utils/ChartsStore.js +0 -26
  258. package/modern/internals/useCharts.js +0 -29
  259. package/node/ChartContainer/ResizableContainer.js +0 -68
  260. package/node/context/InteractionProvider.js +0 -28
  261. package/node/context/SvgRefProvider/SvgRefContext.js +0 -23
  262. package/node/context/SvgRefProvider/SvgRefProvider.js +0 -31
  263. package/node/context/SvgRefProvider/index.js +0 -49
  264. package/node/context/SvgRefProvider/useSurfaceRef.js +0 -20
  265. package/node/internals/plugins/utils/ChartsStore.js +0 -33
  266. package/node/internals/useCharts.js +0 -36
  267. /package/context/{SvgRefProvider/SvgRef.types.js → ChartProvider/ChartProvider.types.js} +0 -0
  268. /package/{modern/context/SvgRefProvider/SvgRef.types.js → internals/plugins/corePlugins/useChartId/useChartId.types.js} +0 -0
  269. /package/internals/{useSelector.js → store/useSelector.js} +0 -0
  270. /package/modern/internals/{useSelector.js → store/useSelector.js} +0 -0
  271. /package/node/context/{SvgRefProvider/SvgRef.types.js → ChartProvider/ChartProvider.types.js} +0 -0
  272. /package/node/internals/{useSelector.js → store/useSelector.js} +0 -0
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.selectorChartId = void 0;
7
+ var _selectors = require("../../utils/selectors");
8
+ const selectorChartIdState = state => state.id;
9
+
10
+ /**
11
+ * Get the id attribute of the chart.
12
+ * @param {ChartState<[UseChartIdSignature]>} state The state of the chart.
13
+ * @returns {string} The id attribute of the chart.
14
+ */
15
+ const selectorChartId = exports.selectorChartId = (0, _selectors.createSelector)(selectorChartIdState, idState => idState.chartId);
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createChartDefaultId = void 0;
7
+ let globalChartDefaultId = 0;
8
+ const createChartDefaultId = () => {
9
+ globalChartDefaultId += 1;
10
+ return `mui-chart-${globalChartDefaultId}`;
11
+ };
12
+ exports.createChartDefaultId = createChartDefaultId;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ useChartInteraction: true
8
+ };
9
+ Object.defineProperty(exports, "useChartInteraction", {
10
+ enumerable: true,
11
+ get: function () {
12
+ return _useChartInteraction.useChartInteraction;
13
+ }
14
+ });
15
+ var _useChartInteraction = require("./useChartInteraction");
16
+ var _useChartInteraction2 = require("./useChartInteraction.selectors");
17
+ Object.keys(_useChartInteraction2).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] === _useChartInteraction2[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _useChartInteraction2[key];
25
+ }
26
+ });
27
+ });
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useChartInteraction = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
10
+ const useChartInteraction = ({
11
+ store
12
+ }) => {
13
+ const cleanInteraction = (0, _useEventCallback.default)(() => {
14
+ store.update(prev => (0, _extends2.default)({}, prev, {
15
+ interaction: (0, _extends2.default)({}, prev.interaction, {
16
+ axis: {
17
+ x: null,
18
+ y: null
19
+ },
20
+ item: null
21
+ })
22
+ }));
23
+ });
24
+ const setItemInteraction = (0, _useEventCallback.default)(newItem => {
25
+ store.update(prev => (0, _extends2.default)({}, prev, {
26
+ interaction: (0, _extends2.default)({}, prev.interaction, {
27
+ item: newItem
28
+ })
29
+ }));
30
+ });
31
+ const setAxisInteraction = (0, _useEventCallback.default)(({
32
+ x: newStateX,
33
+ y: newStateY
34
+ }) => {
35
+ store.update(prev => (0, _extends2.default)({}, prev, {
36
+ interaction: (0, _extends2.default)({}, prev.interaction, {
37
+ axis: (0, _extends2.default)({}, prev.interaction.axis, prev.interaction.axis.x?.index !== newStateX?.index || prev.interaction.axis.x?.value !== newStateX?.value ? {
38
+ x: newStateX
39
+ } : {}, prev.interaction.axis.y?.index !== newStateY?.index || prev.interaction.axis.y?.value !== newStateY?.value ? {
40
+ y: newStateY
41
+ } : {})
42
+ })
43
+ }));
44
+ });
45
+ const enableVoronoid = (0, _useEventCallback.default)(() => {
46
+ store.update(prev => (0, _extends2.default)({}, prev, {
47
+ interaction: (0, _extends2.default)({}, prev.interaction, {
48
+ isVoronoiEnabled: true
49
+ })
50
+ }));
51
+ });
52
+ const disableVoronoid = (0, _useEventCallback.default)(() => {
53
+ store.update(prev => (0, _extends2.default)({}, prev, {
54
+ interaction: (0, _extends2.default)({}, prev.interaction, {
55
+ isVoronoiEnabled: false
56
+ })
57
+ }));
58
+ });
59
+ return {
60
+ params: {},
61
+ instance: {
62
+ cleanInteraction,
63
+ setItemInteraction,
64
+ setAxisInteraction,
65
+ enableVoronoid,
66
+ disableVoronoid
67
+ }
68
+ };
69
+ };
70
+ exports.useChartInteraction = useChartInteraction;
71
+ useChartInteraction.getInitialState = () => ({
72
+ interaction: {
73
+ item: null,
74
+ axis: {
75
+ x: null,
76
+ y: null
77
+ },
78
+ isVoronoiEnabled: false
79
+ }
80
+ });
81
+ useChartInteraction.params = {};
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.selectorChartsInteractionYAxisIsDefined = exports.selectorChartsInteractionYAxis = exports.selectorChartsInteractionXAxisIsDefined = exports.selectorChartsInteractionXAxis = exports.selectorChartsInteractionItemIsDefined = exports.selectorChartsInteractionItem = exports.selectorChartsInteractionIsVoronoiEnabled = exports.selectorChartsInteractionAxis = void 0;
7
+ var _selectors = require("../../utils/selectors");
8
+ const selectInteraction = state => state.interaction;
9
+ const selectorChartsInteractionItem = exports.selectorChartsInteractionItem = (0, _selectors.createSelector)(selectInteraction, interaction => interaction.item);
10
+ const selectorChartsInteractionAxis = exports.selectorChartsInteractionAxis = (0, _selectors.createSelector)(selectInteraction, interaction => interaction.axis);
11
+ const selectorChartsInteractionXAxis = exports.selectorChartsInteractionXAxis = (0, _selectors.createSelector)(selectInteraction, interaction => interaction.axis.x);
12
+ const selectorChartsInteractionYAxis = exports.selectorChartsInteractionYAxis = (0, _selectors.createSelector)(selectInteraction, interaction => interaction.axis.y);
13
+ const selectorChartsInteractionItemIsDefined = exports.selectorChartsInteractionItemIsDefined = (0, _selectors.createSelector)(selectorChartsInteractionItem, item => item !== null);
14
+ const selectorChartsInteractionXAxisIsDefined = exports.selectorChartsInteractionXAxisIsDefined = (0, _selectors.createSelector)(selectorChartsInteractionXAxis, x => x !== null);
15
+ const selectorChartsInteractionYAxisIsDefined = exports.selectorChartsInteractionYAxisIsDefined = (0, _selectors.createSelector)(selectorChartsInteractionYAxis, y => y !== null);
16
+ const selectorChartsInteractionIsVoronoiEnabled = exports.selectorChartsInteractionIsVoronoiEnabled = (0, _selectors.createSelector)(selectInteraction, interaction => interaction.isVoronoiEnabled);
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -2,4 +2,37 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
+ });
6
+ var _helpers = require("./helpers");
7
+ Object.keys(_helpers).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _helpers[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _helpers[key];
14
+ }
15
+ });
16
+ });
17
+ var _plugin = require("./plugin");
18
+ Object.keys(_plugin).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _plugin[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _plugin[key];
25
+ }
26
+ });
27
+ });
28
+ var _chart = require("./chart");
29
+ Object.keys(_chart).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _chart[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _chart[key];
36
+ }
37
+ });
5
38
  });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -4,8 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.ChartStore = void 0;
7
- // For now this is fixed. Will need to support generic if we add plugins
8
-
9
7
  class ChartStore {
10
8
  constructor(value) {
11
9
  this.value = void 0;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useChartApiInitialization = useChartApiInitialization;
8
+ exports.useCharts = useCharts;
9
+ var React = _interopRequireWildcard(require("react"));
10
+ var _ChartStore = require("../plugins/utils/ChartStore");
11
+ var _corePlugins = require("../plugins/corePlugins");
12
+ function useChartApiInitialization(inputApiRef) {
13
+ const fallbackPublicApiRef = React.useRef({});
14
+ if (inputApiRef) {
15
+ if (inputApiRef.current == null) {
16
+ // eslint-disable-next-line react-compiler/react-compiler
17
+ inputApiRef.current = {};
18
+ }
19
+ return inputApiRef.current;
20
+ }
21
+ return fallbackPublicApiRef.current;
22
+ }
23
+ let globalId = 0;
24
+ function useCharts(inPlugins, props) {
25
+ const plugins = React.useMemo(() => [..._corePlugins.CHART_CORE_PLUGINS, ...inPlugins], [inPlugins]);
26
+ const pluginParams = {}; // To generate when plugins use params.
27
+ const instanceRef = React.useRef({});
28
+ const instance = instanceRef.current;
29
+ const publicAPI = useChartApiInitialization(props.apiRef);
30
+ const innerSvgRef = React.useRef(null);
31
+ const storeRef = React.useRef(null);
32
+ if (storeRef.current == null) {
33
+ // eslint-disable-next-line react-compiler/react-compiler
34
+ globalId += 1;
35
+ const initialState = {
36
+ // TODO remove when the interaction moves to plugin
37
+ interaction: {
38
+ item: null,
39
+ axis: {
40
+ x: null,
41
+ y: null
42
+ }
43
+ },
44
+ cacheKey: {
45
+ id: globalId
46
+ }
47
+ };
48
+ plugins.forEach(plugin => {
49
+ if (plugin.getInitialState) {
50
+ Object.assign(initialState, plugin.getInitialState({}));
51
+ }
52
+ });
53
+ storeRef.current = new _ChartStore.ChartStore(initialState);
54
+ }
55
+ const runPlugin = plugin => {
56
+ const pluginResponse = plugin({
57
+ instance,
58
+ params: pluginParams,
59
+ plugins: plugins,
60
+ store: storeRef.current,
61
+ svgRef: innerSvgRef
62
+ });
63
+ if (pluginResponse.publicAPI) {
64
+ Object.assign(publicAPI, pluginResponse.publicAPI);
65
+ }
66
+ if (pluginResponse.instance) {
67
+ Object.assign(instance, pluginResponse.instance);
68
+ }
69
+ };
70
+ plugins.forEach(runPlugin);
71
+ const contextValue = React.useMemo(() => ({
72
+ store: storeRef.current,
73
+ publicAPI,
74
+ instance,
75
+ svgRef: innerSvgRef
76
+ }), [instance, publicAPI]);
77
+ return {
78
+ contextValue
79
+ };
80
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -1,24 +1,23 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.useStore = useStore;
8
- var React = _interopRequireWildcard(require("react"));
9
- var _InteractionProvider = require("../context/InteractionProvider");
7
+ var _ChartProvider = require("../../context/ChartProvider");
8
+ // This hook should be removed because user and us should not interact with the store directly, but with public/private APIs
10
9
  function useStore(skipError) {
11
- const charts = React.useContext(_InteractionProvider.ChartsContext);
10
+ const context = (0, _ChartProvider.useChartContext)();
12
11
  if (skipError) {
13
12
  // TODO: Remove once store is used by all charts.
14
13
  // This line is only for `useAxisEvents` which is in the surface of the Gauge.
15
14
  // But the Gauge don't have store yet because it does not need the interaction provider.
16
15
  // Will be fixed when every thing move to the store since every component will have access to it.
17
16
  // @ts-ignore
18
- return charts?.store;
17
+ return context?.store;
19
18
  }
20
- if (!charts) {
19
+ if (!context) {
21
20
  throw new Error(['MUI X: Could not find the charts context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
22
21
  }
23
- return charts.store;
22
+ return context.store;
24
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-charts",
3
- "version": "8.0.0-alpha.1",
3
+ "version": "8.0.0-alpha.2",
4
4
  "description": "The community edition of the Charts components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -36,9 +36,9 @@
36
36
  "clsx": "^2.1.1",
37
37
  "prop-types": "^15.8.1",
38
38
  "reselect": "^5.1.1",
39
- "use-sync-external-store": "^1.0.0",
40
- "@mui/x-charts-vendor": "8.0.0-alpha.1",
41
- "@mui/x-internals": "8.0.0-alpha.1"
39
+ "use-sync-external-store": "^1.2.2",
40
+ "@mui/x-internals": "8.0.0-alpha.2",
41
+ "@mui/x-charts-vendor": "8.0.0-alpha.1"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@emotion/react": "^11.9.0",
@@ -1,22 +0,0 @@
1
- import * as React from 'react';
2
- import type { SizeContextState } from '../context/SizeProvider';
3
- /**
4
- * Wrapping div that take the shape of its parent.
5
- *
6
- * @ignore - do not document.
7
- */
8
- export declare const ResizableContainerRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
9
- ownerState: Partial<Pick<SizeContextState, "width" | "height">>;
10
- }, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
11
- /**
12
- * Wrapping div that take the shape of its parent.
13
- *
14
- * @ignore - do not document.
15
- */
16
- declare function ResizableContainer(props: {
17
- children: React.ReactNode;
18
- }): React.JSX.Element;
19
- declare namespace ResizableContainer {
20
- var propTypes: any;
21
- }
22
- export { ResizableContainer };
@@ -1,60 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import * as React from 'react';
3
- import PropTypes from 'prop-types';
4
- import { styled } from '@mui/material/styles';
5
- import { useSize } from "../context/SizeProvider/index.js";
6
- import { jsx as _jsx } from "react/jsx-runtime";
7
- /**
8
- * Wrapping div that take the shape of its parent.
9
- *
10
- * @ignore - do not document.
11
- */
12
- export const ResizableContainerRoot = styled('div', {
13
- name: 'MuiResponsiveChart',
14
- slot: 'Container'
15
- })(({
16
- ownerState
17
- }) => ({
18
- width: ownerState.width ?? '100%',
19
- height: ownerState.height ?? '100%',
20
- display: 'flex',
21
- position: 'relative',
22
- flexGrow: 1,
23
- flexDirection: 'column',
24
- alignItems: 'center',
25
- justifyContent: 'center',
26
- overflow: 'hidden',
27
- '&>svg': {
28
- width: '100%',
29
- height: '100%'
30
- }
31
- }));
32
-
33
- /**
34
- * Wrapping div that take the shape of its parent.
35
- *
36
- * @ignore - do not document.
37
- */
38
- function ResizableContainer(props) {
39
- const {
40
- inHeight,
41
- inWidth,
42
- containerRef
43
- } = useSize();
44
- return /*#__PURE__*/_jsx(ResizableContainerRoot, _extends({}, props, {
45
- ownerState: {
46
- width: inWidth,
47
- height: inHeight
48
- },
49
- ref: containerRef,
50
- children: props.children
51
- }));
52
- }
53
- process.env.NODE_ENV !== "production" ? ResizableContainer.propTypes = {
54
- // ----------------------------- Warning --------------------------------
55
- // | These PropTypes are generated from the TypeScript type definitions |
56
- // | To update them edit the TypeScript types and run "pnpm proptypes" |
57
- // ----------------------------------------------------------------------
58
- children: PropTypes.node
59
- } : void 0;
60
- export { ResizableContainer };
@@ -1,7 +0,0 @@
1
- import * as React from 'react';
2
- import { ChartStore } from '../internals/plugins/utils/ChartStore';
3
- export declare const ChartsContext: React.Context<{
4
- store: ChartStore;
5
- } | null>;
6
- declare function InteractionProvider(props: React.PropsWithChildren): React.JSX.Element;
7
- export { InteractionProvider };
@@ -1,22 +0,0 @@
1
- 'use client';
2
-
3
- import * as React from 'react';
4
- import { useCharts } from "../internals/useCharts.js";
5
- import { jsx as _jsx } from "react/jsx-runtime";
6
- export const ChartsContext = /*#__PURE__*/React.createContext(null);
7
- if (process.env.NODE_ENV !== 'production') {
8
- ChartsContext.displayName = 'ChartsContext';
9
- }
10
- function InteractionProvider(props) {
11
- const {
12
- children
13
- } = props;
14
- const {
15
- contextValue
16
- } = useCharts();
17
- return /*#__PURE__*/_jsx(ChartsContext.Provider, {
18
- value: contextValue,
19
- children: children
20
- });
21
- }
22
- export { InteractionProvider };
@@ -1,8 +0,0 @@
1
- import * as React from 'react';
2
- export interface SvgRefProviderProps {
3
- children: React.ReactNode;
4
- }
5
- export type SvgRefState = {
6
- svgRef: React.Ref<SVGSVGElement>;
7
- surfaceRef: React.Ref<SVGSVGElement>;
8
- };
@@ -1,4 +0,0 @@
1
- import * as React from 'react';
2
- import { Initializable } from '../context.types';
3
- import { SvgRefState } from './SvgRef.types';
4
- export declare const SvgRefContext: React.Context<Initializable<SvgRefState>>;
@@ -1,17 +0,0 @@
1
- 'use client';
2
-
3
- import * as React from 'react';
4
- export const SvgRefContext = /*#__PURE__*/React.createContext({
5
- isInitialized: false,
6
- data: {
7
- svgRef: {
8
- current: null
9
- },
10
- surfaceRef: {
11
- current: null
12
- }
13
- }
14
- });
15
- if (process.env.NODE_ENV !== 'production') {
16
- SvgRefContext.displayName = 'SvgRefContext';
17
- }
@@ -1,3 +0,0 @@
1
- import * as React from 'react';
2
- import { SvgRefProviderProps } from './SvgRef.types';
3
- export declare function SvgRefProvider(props: SvgRefProviderProps): React.JSX.Element;
@@ -1,24 +0,0 @@
1
- 'use client';
2
-
3
- import * as React from 'react';
4
- import useForkRef from '@mui/utils/useForkRef';
5
- import { SvgRefContext } from "./SvgRefContext.js";
6
- import { jsx as _jsx } from "react/jsx-runtime";
7
- export function SvgRefProvider(props) {
8
- const {
9
- children
10
- } = props;
11
- const svgRef = React.useRef(null);
12
- const surfaceRef = useForkRef(svgRef);
13
- const refValue = React.useMemo(() => ({
14
- isInitialized: true,
15
- data: {
16
- svgRef,
17
- surfaceRef
18
- }
19
- }), [svgRef, surfaceRef]);
20
- return /*#__PURE__*/_jsx(SvgRefContext.Provider, {
21
- value: refValue,
22
- children: children
23
- });
24
- }
@@ -1,4 +0,0 @@
1
- export * from './SvgRef.types';
2
- export * from './SvgRefProvider';
3
- export * from './SvgRefContext';
4
- export * from './useSurfaceRef';
@@ -1,4 +0,0 @@
1
- export * from "./SvgRef.types.js";
2
- export * from "./SvgRefProvider.js";
3
- export * from "./SvgRefContext.js";
4
- export * from "./useSurfaceRef.js";
@@ -1,2 +0,0 @@
1
- import * as React from 'react';
2
- export declare function useSurfaceRef(): React.MutableRefObject<SVGSVGElement>;
@@ -1,14 +0,0 @@
1
- 'use client';
2
-
3
- import * as React from 'react';
4
- import { SvgRefContext } from "./SvgRefContext.js";
5
- export function useSurfaceRef() {
6
- const {
7
- isInitialized,
8
- data
9
- } = React.useContext(SvgRefContext);
10
- if (!isInitialized) {
11
- throw new Error(['MUI X: Could not find the svg ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
12
- }
13
- return data.surfaceRef;
14
- }
@@ -1,12 +0,0 @@
1
- import type { ChartState } from '../models';
2
- type Listener<T> = (value: T) => void;
3
- export type StoreUpdater = (prevState: ChartState) => ChartState;
4
- export declare class ChartsStore {
5
- value: ChartState;
6
- private listeners;
7
- constructor(value: ChartState);
8
- subscribe: (fn: Listener<ChartState>) => () => void;
9
- getSnapshot: () => ChartState;
10
- update: (updater: StoreUpdater) => void;
11
- }
12
- export {};
@@ -1,26 +0,0 @@
1
- // For now this is fixed. Will need to support generic if we add plugins
2
-
3
- export class ChartsStore {
4
- constructor(value) {
5
- this.value = void 0;
6
- this.listeners = void 0;
7
- this.subscribe = fn => {
8
- this.listeners.add(fn);
9
- return () => {
10
- this.listeners.delete(fn);
11
- };
12
- };
13
- this.getSnapshot = () => {
14
- return this.value;
15
- };
16
- this.update = updater => {
17
- const newState = updater(this.value);
18
- if (newState !== this.value) {
19
- this.value = newState;
20
- this.listeners.forEach(l => l(newState));
21
- }
22
- };
23
- this.value = value;
24
- this.listeners = new Set();
25
- }
26
- }
@@ -1,6 +0,0 @@
1
- import { ChartStore } from './plugins/utils/ChartStore';
2
- export declare function useCharts(): {
3
- contextValue: {
4
- store: ChartStore;
5
- };
6
- };