@mui/x-charts 7.20.0 → 7.21.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 (92) hide show
  1. package/BarChart/BarChart.js +1 -1
  2. package/BarChart/BarPlot.d.ts +1 -1
  3. package/BarChart/BarPlot.js +6 -3
  4. package/BarChart/useBarChartProps.js +2 -2
  5. package/CHANGELOG.md +120 -31
  6. package/ChartContainer/ChartContainer.d.ts +3 -2
  7. package/ChartContainer/ChartContainer.js +11 -2
  8. package/ChartContainer/useChartContainerProps.d.ts +2 -0
  9. package/ChartContainer/useChartContainerProps.js +7 -5
  10. package/LineChart/AreaPlot.js +3 -1
  11. package/LineChart/LinePlot.js +3 -1
  12. package/LineChart/MarkPlot.d.ts +1 -1
  13. package/LineChart/MarkPlot.js +10 -8
  14. package/LineChart/useLineChartProps.d.ts +10 -10
  15. package/LineChart/useLineChartProps.js +4 -5
  16. package/PieChart/PieChart.js +3 -3
  17. package/PieChart/PiePlot.js +3 -1
  18. package/ResponsiveChartContainer/ResponsiveChartContainer.js +5 -0
  19. package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +1 -1
  20. package/ResponsiveChartContainer/useResponsiveChartContainerProps.js +4 -2
  21. package/ScatterChart/ScatterChart.js +5 -0
  22. package/ScatterChart/extremums.js +4 -4
  23. package/ScatterChart/formatter.js +22 -3
  24. package/SparkLineChart/SparkLineChart.js +5 -0
  25. package/context/AnimationProvider/Animation.types.d.ts +15 -0
  26. package/context/AnimationProvider/Animation.types.js +1 -0
  27. package/context/AnimationProvider/AnimationContext.d.ts +4 -0
  28. package/context/AnimationProvider/AnimationContext.js +10 -0
  29. package/context/AnimationProvider/AnimationProvider.d.ts +4 -0
  30. package/context/AnimationProvider/AnimationProvider.js +55 -0
  31. package/context/AnimationProvider/index.d.ts +4 -0
  32. package/context/AnimationProvider/index.js +4 -0
  33. package/context/AnimationProvider/useSkipAnimation.d.ts +6 -0
  34. package/context/AnimationProvider/useSkipAnimation.js +20 -0
  35. package/index.js +1 -1
  36. package/internals/defaultizeColor.d.ts +7 -1
  37. package/internals/index.d.ts +1 -1
  38. package/internals/index.js +1 -1
  39. package/models/seriesType/scatter.d.ts +25 -1
  40. package/modern/BarChart/BarChart.js +1 -1
  41. package/modern/BarChart/BarPlot.js +6 -3
  42. package/modern/BarChart/useBarChartProps.js +2 -2
  43. package/modern/ChartContainer/ChartContainer.js +11 -2
  44. package/modern/ChartContainer/useChartContainerProps.js +7 -5
  45. package/modern/LineChart/AreaPlot.js +3 -1
  46. package/modern/LineChart/LinePlot.js +3 -1
  47. package/modern/LineChart/MarkPlot.js +10 -8
  48. package/modern/LineChart/useLineChartProps.js +4 -5
  49. package/modern/PieChart/PieChart.js +3 -3
  50. package/modern/PieChart/PiePlot.js +3 -1
  51. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +5 -0
  52. package/modern/ResponsiveChartContainer/useResponsiveChartContainerProps.js +4 -2
  53. package/modern/ScatterChart/ScatterChart.js +5 -0
  54. package/modern/ScatterChart/extremums.js +4 -4
  55. package/modern/ScatterChart/formatter.js +22 -3
  56. package/modern/SparkLineChart/SparkLineChart.js +5 -0
  57. package/modern/context/AnimationProvider/Animation.types.js +1 -0
  58. package/modern/context/AnimationProvider/AnimationContext.js +10 -0
  59. package/modern/context/AnimationProvider/AnimationProvider.js +55 -0
  60. package/modern/context/AnimationProvider/index.js +4 -0
  61. package/modern/context/AnimationProvider/useSkipAnimation.js +20 -0
  62. package/modern/index.js +1 -1
  63. package/modern/internals/index.js +1 -1
  64. package/node/BarChart/BarChart.js +1 -1
  65. package/node/BarChart/BarPlot.js +4 -2
  66. package/node/BarChart/useBarChartProps.js +2 -2
  67. package/node/ChartContainer/ChartContainer.js +11 -2
  68. package/node/ChartContainer/useChartContainerProps.js +7 -5
  69. package/node/LineChart/AreaPlot.js +3 -1
  70. package/node/LineChart/LinePlot.js +3 -1
  71. package/node/LineChart/MarkPlot.js +10 -8
  72. package/node/LineChart/useLineChartProps.js +4 -5
  73. package/node/PieChart/PieChart.js +3 -3
  74. package/node/PieChart/PiePlot.js +3 -1
  75. package/node/ResponsiveChartContainer/ResponsiveChartContainer.js +5 -0
  76. package/node/ResponsiveChartContainer/useResponsiveChartContainerProps.js +4 -2
  77. package/node/ScatterChart/ScatterChart.js +5 -0
  78. package/node/ScatterChart/extremums.js +4 -4
  79. package/node/ScatterChart/formatter.js +23 -3
  80. package/node/SparkLineChart/SparkLineChart.js +5 -0
  81. package/node/context/AnimationProvider/Animation.types.js +5 -0
  82. package/node/context/AnimationProvider/AnimationContext.js +17 -0
  83. package/node/context/AnimationProvider/AnimationProvider.js +60 -0
  84. package/node/context/AnimationProvider/index.js +49 -0
  85. package/node/context/AnimationProvider/useSkipAnimation.js +25 -0
  86. package/node/index.js +1 -1
  87. package/node/internals/index.js +12 -8
  88. package/package.json +4 -4
  89. package/hooks/useReducedMotion.d.ts +0 -8
  90. package/hooks/useReducedMotion.js +0 -39
  91. package/modern/hooks/useReducedMotion.js +0 -39
  92. package/node/hooks/useReducedMotion.js +0 -45
@@ -77,7 +77,8 @@ const useLineChartProps = props => {
77
77
  highlightedItem,
78
78
  onHighlightChange,
79
79
  disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick,
80
- className
80
+ className,
81
+ skipAnimation
81
82
  });
82
83
  const axisClickHandlerProps = {
83
84
  onAxisClick
@@ -95,14 +96,12 @@ const useLineChartProps = props => {
95
96
  const areaPlotProps = {
96
97
  slots,
97
98
  slotProps,
98
- onItemClick: onAreaClick,
99
- skipAnimation
99
+ onItemClick: onAreaClick
100
100
  };
101
101
  const linePlotProps = {
102
102
  slots,
103
103
  slotProps,
104
- onItemClick: onLineClick,
105
- skipAnimation
104
+ onItemClick: onLineClick
106
105
  };
107
106
  const markPlotProps = {
108
107
  slots,
@@ -112,6 +112,7 @@ const PieChart = exports.PieChart = /*#__PURE__*/React.forwardRef(function PieCh
112
112
  highlightedItem: highlightedItem,
113
113
  onHighlightChange: onHighlightChange,
114
114
  className: className,
115
+ skipAnimation: skipAnimation,
115
116
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, {
116
117
  topAxis: topAxis,
117
118
  leftAxis: leftAxis,
@@ -122,8 +123,7 @@ const PieChart = exports.PieChart = /*#__PURE__*/React.forwardRef(function PieCh
122
123
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PiePlot.PiePlot, {
123
124
  slots: slots,
124
125
  slotProps: slotProps,
125
- onItemClick: onItemClick,
126
- skipAnimation: skipAnimation
126
+ onItemClick: onItemClick
127
127
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, {
128
128
  loading: loading,
129
129
  slots: slots,
@@ -270,7 +270,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
270
270
  series: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
271
271
  /**
272
272
  * If `true`, animations are skipped.
273
- * @default false
273
+ * If unset or `false`, the animations respects the user's `prefers-reduced-motion` setting.
274
274
  */
275
275
  skipAnimation: _propTypes.default.bool,
276
276
  /**
@@ -15,6 +15,7 @@ var _PieArcLabelPlot = require("./PieArcLabelPlot");
15
15
  var _getPercentageValue = require("../internals/getPercentageValue");
16
16
  var _getPieCoordinates = require("./getPieCoordinates");
17
17
  var _useSeries = require("../hooks/useSeries");
18
+ var _AnimationProvider = require("../context/AnimationProvider");
18
19
  var _jsxRuntime = require("react/jsx-runtime");
19
20
  /**
20
21
  * Demos:
@@ -28,7 +29,7 @@ var _jsxRuntime = require("react/jsx-runtime");
28
29
  */
29
30
  function PiePlot(props) {
30
31
  const {
31
- skipAnimation,
32
+ skipAnimation: inSkipAnimation,
32
33
  slots,
33
34
  slotProps,
34
35
  onItemClick
@@ -40,6 +41,7 @@ function PiePlot(props) {
40
41
  width,
41
42
  height
42
43
  } = React.useContext(_DrawingProvider.DrawingContext);
44
+ const skipAnimation = (0, _AnimationProvider.useSkipAnimation)(inSkipAnimation);
43
45
  if (seriesData === undefined) {
44
46
  return null;
45
47
  }
@@ -97,6 +97,11 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
97
97
  * Please refer to the appropriate docs page to learn more about it.
98
98
  */
99
99
  series: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
100
+ /**
101
+ * If `true`, animations are skipped.
102
+ * If unset or `false`, the animations respects the user's `prefers-reduced-motion` setting.
103
+ */
104
+ skipAnimation: _propTypes.default.bool,
100
105
  sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
101
106
  title: _propTypes.default.string,
102
107
  viewBox: _propTypes.default.shape({
@@ -9,7 +9,7 @@ exports.useResponsiveChartContainerProps = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
11
  var _useChartContainerDimensions = require("./useChartContainerDimensions");
12
- const _excluded = ["width", "height", "resolveSizeBeforeRender", "margin", "children", "series", "colors", "dataset", "desc", "disableAxisListener", "highlightedItem", "onHighlightChange", "plugins", "sx", "title", "viewBox", "xAxis", "yAxis", "zAxis"];
12
+ const _excluded = ["width", "height", "resolveSizeBeforeRender", "margin", "children", "series", "colors", "dataset", "desc", "disableAxisListener", "highlightedItem", "onHighlightChange", "plugins", "sx", "title", "viewBox", "xAxis", "yAxis", "zAxis", "skipAnimation"];
13
13
  const useResponsiveChartContainerProps = (props, ref) => {
14
14
  const {
15
15
  width,
@@ -30,7 +30,8 @@ const useResponsiveChartContainerProps = (props, ref) => {
30
30
  viewBox,
31
31
  xAxis,
32
32
  yAxis,
33
- zAxis
33
+ zAxis,
34
+ skipAnimation
34
35
  } = props,
35
36
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
36
37
  const {
@@ -62,6 +63,7 @@ const useResponsiveChartContainerProps = (props, ref) => {
62
63
  xAxis,
63
64
  yAxis,
64
65
  zAxis,
66
+ skipAnimation,
65
67
  width: dWidth,
66
68
  height: dHeight,
67
69
  ref
@@ -205,6 +205,11 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
205
205
  * An array of [[ScatterSeriesType]] objects.
206
206
  */
207
207
  series: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
208
+ /**
209
+ * If `true`, animations are skipped.
210
+ * If unset or `false`, the animations respects the user's `prefers-reduced-motion` setting.
211
+ */
212
+ skipAnimation: _propTypes.default.bool,
208
213
  /**
209
214
  * The props used for each component slot.
210
215
  * @default {}
@@ -24,13 +24,13 @@ const getExtremumX = params => {
24
24
  seriesXAxisId: series[seriesId].xAxisId ?? series[seriesId].xAxisKey,
25
25
  seriesYAxisId: series[seriesId].yAxisId ?? series[seriesId].yAxisKey
26
26
  });
27
- const seriesMinMax = series[seriesId].data.reduce((accSeries, d, dataIndex) => {
27
+ const seriesMinMax = series[seriesId].data?.reduce((accSeries, d, dataIndex) => {
28
28
  if (filter && !filter(d, dataIndex)) {
29
29
  return accSeries;
30
30
  }
31
31
  return mergeMinMax(accSeries, [d.x, d.x]);
32
32
  }, [Infinity, -Infinity]);
33
- return mergeMinMax(acc, seriesMinMax);
33
+ return mergeMinMax(acc, seriesMinMax ?? [Infinity, -Infinity]);
34
34
  }, [Infinity, -Infinity]);
35
35
  };
36
36
  exports.getExtremumX = getExtremumX;
@@ -51,13 +51,13 @@ const getExtremumY = params => {
51
51
  seriesXAxisId: series[seriesId].xAxisId ?? series[seriesId].xAxisKey,
52
52
  seriesYAxisId: series[seriesId].yAxisId ?? series[seriesId].yAxisKey
53
53
  });
54
- const seriesMinMax = series[seriesId].data.reduce((accSeries, d, dataIndex) => {
54
+ const seriesMinMax = series[seriesId].data?.reduce((accSeries, d, dataIndex) => {
55
55
  if (filter && !filter(d, dataIndex)) {
56
56
  return accSeries;
57
57
  }
58
58
  return mergeMinMax(accSeries, [d.y, d.y]);
59
59
  }, [Infinity, -Infinity]);
60
- return mergeMinMax(acc, seriesMinMax);
60
+ return mergeMinMax(acc, seriesMinMax ?? [Infinity, -Infinity]);
61
61
  }, [Infinity, -Infinity]);
62
62
  };
63
63
  exports.getExtremumY = getExtremumY;
@@ -1,16 +1,36 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.default = void 0;
7
- var _defaultizeValueFormatter = require("../internals/defaultizeValueFormatter");
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
8
9
  const formatter = ({
9
10
  series,
10
11
  seriesOrder
11
- }) => {
12
+ }, dataset) => {
13
+ const completeSeries = Object.fromEntries(Object.entries(series).map(([seriesId, seriesData]) => {
14
+ const datasetKeys = seriesData?.datasetKeys;
15
+ const missingKeys = ['x', 'y', 'id'].filter(key => typeof datasetKeys?.[key] !== 'string');
16
+ if (seriesData?.datasetKeys && missingKeys.length > 0) {
17
+ throw new Error([`MUI X: scatter series with id='${seriesId}' has incomplete datasetKeys.`, `Properties ${missingKeys.map(key => `"${key}"`).join(', ')} are missing.`].join('\n'));
18
+ }
19
+ const data = !datasetKeys ? seriesData.data ?? [] : dataset?.map(d => {
20
+ return {
21
+ x: d[datasetKeys.x],
22
+ y: d[datasetKeys.y],
23
+ z: datasetKeys.z && d[datasetKeys.z],
24
+ id: d[datasetKeys.id]
25
+ };
26
+ }) ?? [];
27
+ return [seriesId, (0, _extends2.default)({}, seriesData, {
28
+ data,
29
+ valueFormatter: seriesData.valueFormatter ?? (v => `(${v.x}, ${v.y})`)
30
+ })];
31
+ }));
12
32
  return {
13
- series: (0, _defaultizeValueFormatter.defaultizeValueFormatter)(series, v => `(${v.x}, ${v.y})`),
33
+ series: completeSeries,
14
34
  seriesOrder
15
35
  };
16
36
  };
@@ -222,6 +222,11 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
222
222
  * @default false
223
223
  */
224
224
  showTooltip: _propTypes.default.bool,
225
+ /**
226
+ * If `true`, animations are skipped.
227
+ * If unset or `false`, the animations respects the user's `prefers-reduced-motion` setting.
228
+ */
229
+ skipAnimation: _propTypes.default.bool,
225
230
  /**
226
231
  * The props used for each component slot.
227
232
  * @default {}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.AnimationContext = void 0;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ const AnimationContext = exports.AnimationContext = /*#__PURE__*/React.createContext({
10
+ isInitialized: false,
11
+ data: {
12
+ skipAnimation: undefined
13
+ }
14
+ });
15
+ if (process.env.NODE_ENV !== 'production') {
16
+ AnimationContext.displayName = 'AnimationContext';
17
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.AnimationProvider = AnimationProvider;
9
+ var _web = require("@react-spring/web");
10
+ var React = _interopRequireWildcard(require("react"));
11
+ var _AnimationContext = require("./AnimationContext");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function AnimationProvider(props) {
14
+ // Part of the behavior was taken from:
15
+ // https://github.com/pmndrs/react-spring/blob/fd65b605b85c3a24143c4ce9dd322fdfca9c66be/packages/shared/src/hooks/useReducedMotion.ts
16
+ const {
17
+ children,
18
+ skipAnimation: inSkipAnimation
19
+ } = props;
20
+
21
+ // Skip animation test/jsdom
22
+ const isAnimationDisabledEnvironment = typeof window === 'undefined' || !window?.matchMedia;
23
+
24
+ // We use the value of `isAnimationDisabledEnvironment` as the initial value of `skipAnimation` to avoid
25
+ // re-rendering the component on environments where matchMedia is not supported, hence skipAnimation will always be true.
26
+ const [skipAnimation, setSkipAnimation] = React.useState(isAnimationDisabledEnvironment || undefined);
27
+ (0, _web.useIsomorphicLayoutEffect)(() => {
28
+ if (isAnimationDisabledEnvironment) {
29
+ return undefined;
30
+ }
31
+ const handleMediaChange = event => {
32
+ // This hook can remove animation but never activate it.
33
+ const inputValue = event.matches || undefined;
34
+ setSkipAnimation(inputValue);
35
+ _web.Globals.assign({
36
+ skipAnimation: inputValue
37
+ });
38
+ };
39
+ const mql = window.matchMedia('(prefers-reduced-motion)');
40
+ handleMediaChange(mql);
41
+
42
+ // MatchMedia is not fully supported in all environments, so we need to check if it exists before calling addEventListener
43
+ mql?.addEventListener?.('change', handleMediaChange);
44
+ return () => {
45
+ mql?.removeEventListener?.('change', handleMediaChange);
46
+ };
47
+ }, []);
48
+ const value = React.useMemo(() => ({
49
+ isInitialized: true,
50
+ data: {
51
+ // If dev sets `skipAnimation` to true, it will skip all animations.
52
+ // If dev sets `skipAnimation` to false, it will use user's preference.
53
+ skipAnimation: inSkipAnimation || skipAnimation
54
+ }
55
+ }), [skipAnimation, inSkipAnimation]);
56
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_AnimationContext.AnimationContext.Provider, {
57
+ value: value,
58
+ children: children
59
+ });
60
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _Animation = require("./Animation.types");
7
+ Object.keys(_Animation).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _Animation[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _Animation[key];
14
+ }
15
+ });
16
+ });
17
+ var _AnimationContext = require("./AnimationContext");
18
+ Object.keys(_AnimationContext).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _AnimationContext[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _AnimationContext[key];
25
+ }
26
+ });
27
+ });
28
+ var _AnimationProvider = require("./AnimationProvider");
29
+ Object.keys(_AnimationProvider).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _AnimationProvider[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _AnimationProvider[key];
36
+ }
37
+ });
38
+ });
39
+ var _useSkipAnimation = require("./useSkipAnimation");
40
+ Object.keys(_useSkipAnimation).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _useSkipAnimation[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _useSkipAnimation[key];
47
+ }
48
+ });
49
+ });
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.useSkipAnimation = useSkipAnimation;
9
+ var React = _interopRequireWildcard(require("react"));
10
+ var _AnimationContext = require("./AnimationContext");
11
+ /**
12
+ * A hook to get if chart animations should be skipped.
13
+ *
14
+ * @returns {boolean|undefined} whether to skip animations
15
+ */
16
+ function useSkipAnimation(skipAnimation) {
17
+ const {
18
+ isInitialized,
19
+ data
20
+ } = React.useContext(_AnimationContext.AnimationContext);
21
+ if (!isInitialized) {
22
+ throw new Error(['MUI X: Could not find the animation ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
23
+ }
24
+ return skipAnimation || data.skipAnimation;
25
+ }
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v7.20.0
2
+ * @mui/x-charts v7.21.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  var _exportNames = {
7
- useReducedMotion: true,
8
7
  useSeries: true,
9
8
  useInteractionItemProps: true,
10
9
  useDrawingArea: true,
@@ -58,12 +57,6 @@ Object.defineProperty(exports, "useLineChartProps", {
58
57
  return _useLineChartProps.useLineChartProps;
59
58
  }
60
59
  });
61
- Object.defineProperty(exports, "useReducedMotion", {
62
- enumerable: true,
63
- get: function () {
64
- return _useReducedMotion.useReducedMotion;
65
- }
66
- });
67
60
  Object.defineProperty(exports, "useResponsiveChartContainerProps", {
68
61
  enumerable: true,
69
62
  get: function () {
@@ -118,7 +111,6 @@ Object.keys(_ResizableContainer).forEach(function (key) {
118
111
  }
119
112
  });
120
113
  });
121
- var _useReducedMotion = require("../hooks/useReducedMotion");
122
114
  var _useSeries = require("../hooks/useSeries");
123
115
  var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
124
116
  var _useDrawingArea = require("../hooks/useDrawingArea");
@@ -284,6 +276,18 @@ Object.keys(_PluginProvider).forEach(function (key) {
284
276
  }
285
277
  });
286
278
  });
279
+ var _AnimationProvider = require("../context/AnimationProvider");
280
+ Object.keys(_AnimationProvider).forEach(function (key) {
281
+ if (key === "default" || key === "__esModule") return;
282
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
283
+ if (key in exports && exports[key] === _AnimationProvider[key]) return;
284
+ Object.defineProperty(exports, key, {
285
+ enumerable: true,
286
+ get: function () {
287
+ return _AnimationProvider[key];
288
+ }
289
+ });
290
+ });
287
291
  var _getAxisExtremum = require("../context/CartesianProvider/getAxisExtremum");
288
292
  var _config = require("../models/seriesType/config");
289
293
  Object.keys(_config).forEach(function (key) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-charts",
3
- "version": "7.20.0",
3
+ "version": "7.21.0",
4
4
  "description": "The community edition of the Charts components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -31,12 +31,12 @@
31
31
  "dependencies": {
32
32
  "@babel/runtime": "^7.25.7",
33
33
  "@mui/utils": "^5.16.6 || ^6.0.0",
34
- "@react-spring/rafz": "^9.7.4",
35
- "@react-spring/web": "^9.7.4",
34
+ "@react-spring/rafz": "^9.7.5",
35
+ "@react-spring/web": "^9.7.5",
36
36
  "clsx": "^2.1.1",
37
37
  "prop-types": "^15.8.1",
38
38
  "@mui/x-charts-vendor": "7.20.0",
39
- "@mui/x-internals": "7.20.0"
39
+ "@mui/x-internals": "7.21.0"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@emotion/react": "^11.9.0",
@@ -1,8 +0,0 @@
1
- /**
2
- * Returns `boolean` or `null`, used to automatically
3
- * set skipAnimations to the value of the user's
4
- * `prefers-reduced-motion` query.
5
- *
6
- * The return value, post-effect, is the value of their preferred setting
7
- */
8
- export declare const useReducedMotion: () => void;
@@ -1,39 +0,0 @@
1
- 'use client';
2
-
3
- import { useIsomorphicLayoutEffect, Globals } from '@react-spring/web';
4
- const handleMediaChange = event => {
5
- Globals.assign({
6
- // Modification such the react-spring implementation such that this hook can remove animation but never activate animation.
7
- skipAnimation: event.matches || undefined
8
- });
9
- };
10
-
11
- /**
12
- * Returns `boolean` or `null`, used to automatically
13
- * set skipAnimations to the value of the user's
14
- * `prefers-reduced-motion` query.
15
- *
16
- * The return value, post-effect, is the value of their preferred setting
17
- */
18
- export const useReducedMotion = () => {
19
- // Taken from: https://github.com/pmndrs/react-spring/blob/fd65b605b85c3a24143c4ce9dd322fdfca9c66be/packages/shared/src/hooks/useReducedMotion.ts
20
-
21
- useIsomorphicLayoutEffect(() => {
22
- // Skip animation test/jsdom
23
- const shouldSkipAnimation = !window?.matchMedia;
24
- if (shouldSkipAnimation) {
25
- handleMediaChange({
26
- matches: true
27
- });
28
- return undefined;
29
- }
30
- const mql = window.matchMedia('(prefers-reduced-motion)');
31
- handleMediaChange(mql);
32
-
33
- // MatchMedia is not fully supported in all environments, so we need to check if it exists before calling addEventListener
34
- mql.addEventListener?.('change', handleMediaChange);
35
- return () => {
36
- mql.removeEventListener?.('change', handleMediaChange);
37
- };
38
- }, []);
39
- };
@@ -1,39 +0,0 @@
1
- 'use client';
2
-
3
- import { useIsomorphicLayoutEffect, Globals } from '@react-spring/web';
4
- const handleMediaChange = event => {
5
- Globals.assign({
6
- // Modification such the react-spring implementation such that this hook can remove animation but never activate animation.
7
- skipAnimation: event.matches || undefined
8
- });
9
- };
10
-
11
- /**
12
- * Returns `boolean` or `null`, used to automatically
13
- * set skipAnimations to the value of the user's
14
- * `prefers-reduced-motion` query.
15
- *
16
- * The return value, post-effect, is the value of their preferred setting
17
- */
18
- export const useReducedMotion = () => {
19
- // Taken from: https://github.com/pmndrs/react-spring/blob/fd65b605b85c3a24143c4ce9dd322fdfca9c66be/packages/shared/src/hooks/useReducedMotion.ts
20
-
21
- useIsomorphicLayoutEffect(() => {
22
- // Skip animation test/jsdom
23
- const shouldSkipAnimation = !window?.matchMedia;
24
- if (shouldSkipAnimation) {
25
- handleMediaChange({
26
- matches: true
27
- });
28
- return undefined;
29
- }
30
- const mql = window.matchMedia('(prefers-reduced-motion)');
31
- handleMediaChange(mql);
32
-
33
- // MatchMedia is not fully supported in all environments, so we need to check if it exists before calling addEventListener
34
- mql.addEventListener?.('change', handleMediaChange);
35
- return () => {
36
- mql.removeEventListener?.('change', handleMediaChange);
37
- };
38
- }, []);
39
- };
@@ -1,45 +0,0 @@
1
- "use strict";
2
- 'use client';
3
-
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.useReducedMotion = void 0;
8
- var _web = require("@react-spring/web");
9
- const handleMediaChange = event => {
10
- _web.Globals.assign({
11
- // Modification such the react-spring implementation such that this hook can remove animation but never activate animation.
12
- skipAnimation: event.matches || undefined
13
- });
14
- };
15
-
16
- /**
17
- * Returns `boolean` or `null`, used to automatically
18
- * set skipAnimations to the value of the user's
19
- * `prefers-reduced-motion` query.
20
- *
21
- * The return value, post-effect, is the value of their preferred setting
22
- */
23
- const useReducedMotion = () => {
24
- // Taken from: https://github.com/pmndrs/react-spring/blob/fd65b605b85c3a24143c4ce9dd322fdfca9c66be/packages/shared/src/hooks/useReducedMotion.ts
25
-
26
- (0, _web.useIsomorphicLayoutEffect)(() => {
27
- // Skip animation test/jsdom
28
- const shouldSkipAnimation = !window?.matchMedia;
29
- if (shouldSkipAnimation) {
30
- handleMediaChange({
31
- matches: true
32
- });
33
- return undefined;
34
- }
35
- const mql = window.matchMedia('(prefers-reduced-motion)');
36
- handleMediaChange(mql);
37
-
38
- // MatchMedia is not fully supported in all environments, so we need to check if it exists before calling addEventListener
39
- mql.addEventListener?.('change', handleMediaChange);
40
- return () => {
41
- mql.removeEventListener?.('change', handleMediaChange);
42
- };
43
- }, []);
44
- };
45
- exports.useReducedMotion = useReducedMotion;