@mui/x-charts 7.19.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 (99) hide show
  1. package/BarChart/BarChart.d.ts +1 -1
  2. package/BarChart/BarChart.js +2 -2
  3. package/BarChart/BarPlot.d.ts +1 -1
  4. package/BarChart/BarPlot.js +6 -3
  5. package/BarChart/useBarChartProps.js +2 -2
  6. package/CHANGELOG.md +224 -43
  7. package/ChartContainer/ChartContainer.d.ts +3 -2
  8. package/ChartContainer/ChartContainer.js +11 -2
  9. package/ChartContainer/useChartContainerProps.d.ts +2 -0
  10. package/ChartContainer/useChartContainerProps.js +7 -5
  11. package/LineChart/AreaPlot.js +3 -1
  12. package/LineChart/LineChart.d.ts +1 -1
  13. package/LineChart/LineChart.js +1 -1
  14. package/LineChart/LinePlot.js +3 -1
  15. package/LineChart/MarkPlot.d.ts +1 -1
  16. package/LineChart/MarkPlot.js +10 -8
  17. package/LineChart/useLineChartProps.d.ts +10 -10
  18. package/LineChart/useLineChartProps.js +4 -5
  19. package/PieChart/PieChart.d.ts +1 -1
  20. package/PieChart/PieChart.js +4 -4
  21. package/PieChart/PiePlot.js +3 -1
  22. package/ResponsiveChartContainer/ResponsiveChartContainer.js +5 -0
  23. package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +1 -1
  24. package/ResponsiveChartContainer/useResponsiveChartContainerProps.js +4 -2
  25. package/ScatterChart/ScatterChart.d.ts +1 -1
  26. package/ScatterChart/ScatterChart.js +6 -1
  27. package/ScatterChart/extremums.js +4 -4
  28. package/ScatterChart/formatter.js +22 -3
  29. package/SparkLineChart/SparkLineChart.js +5 -0
  30. package/context/AnimationProvider/Animation.types.d.ts +15 -0
  31. package/context/AnimationProvider/Animation.types.js +1 -0
  32. package/context/AnimationProvider/AnimationContext.d.ts +4 -0
  33. package/context/AnimationProvider/AnimationContext.js +10 -0
  34. package/context/AnimationProvider/AnimationProvider.d.ts +4 -0
  35. package/context/AnimationProvider/AnimationProvider.js +55 -0
  36. package/context/AnimationProvider/index.d.ts +4 -0
  37. package/context/AnimationProvider/index.js +4 -0
  38. package/context/AnimationProvider/useSkipAnimation.d.ts +6 -0
  39. package/context/AnimationProvider/useSkipAnimation.js +20 -0
  40. package/index.js +1 -1
  41. package/internals/defaultizeColor.d.ts +7 -1
  42. package/internals/index.d.ts +1 -1
  43. package/internals/index.js +1 -1
  44. package/models/seriesType/scatter.d.ts +25 -1
  45. package/modern/BarChart/BarChart.js +2 -2
  46. package/modern/BarChart/BarPlot.js +6 -3
  47. package/modern/BarChart/useBarChartProps.js +2 -2
  48. package/modern/ChartContainer/ChartContainer.js +11 -2
  49. package/modern/ChartContainer/useChartContainerProps.js +7 -5
  50. package/modern/LineChart/AreaPlot.js +3 -1
  51. package/modern/LineChart/LineChart.js +1 -1
  52. package/modern/LineChart/LinePlot.js +3 -1
  53. package/modern/LineChart/MarkPlot.js +10 -8
  54. package/modern/LineChart/useLineChartProps.js +4 -5
  55. package/modern/PieChart/PieChart.js +4 -4
  56. package/modern/PieChart/PiePlot.js +3 -1
  57. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +5 -0
  58. package/modern/ResponsiveChartContainer/useResponsiveChartContainerProps.js +4 -2
  59. package/modern/ScatterChart/ScatterChart.js +6 -1
  60. package/modern/ScatterChart/extremums.js +4 -4
  61. package/modern/ScatterChart/formatter.js +22 -3
  62. package/modern/SparkLineChart/SparkLineChart.js +5 -0
  63. package/modern/context/AnimationProvider/Animation.types.js +1 -0
  64. package/modern/context/AnimationProvider/AnimationContext.js +10 -0
  65. package/modern/context/AnimationProvider/AnimationProvider.js +55 -0
  66. package/modern/context/AnimationProvider/index.js +4 -0
  67. package/modern/context/AnimationProvider/useSkipAnimation.js +20 -0
  68. package/modern/index.js +1 -1
  69. package/modern/internals/index.js +1 -1
  70. package/node/BarChart/BarChart.js +2 -2
  71. package/node/BarChart/BarPlot.js +4 -2
  72. package/node/BarChart/useBarChartProps.js +2 -2
  73. package/node/ChartContainer/ChartContainer.js +11 -2
  74. package/node/ChartContainer/useChartContainerProps.js +7 -5
  75. package/node/LineChart/AreaPlot.js +3 -1
  76. package/node/LineChart/LineChart.js +1 -1
  77. package/node/LineChart/LinePlot.js +3 -1
  78. package/node/LineChart/MarkPlot.js +10 -8
  79. package/node/LineChart/useLineChartProps.js +4 -5
  80. package/node/PieChart/PieChart.js +4 -4
  81. package/node/PieChart/PiePlot.js +3 -1
  82. package/node/ResponsiveChartContainer/ResponsiveChartContainer.js +5 -0
  83. package/node/ResponsiveChartContainer/useResponsiveChartContainerProps.js +4 -2
  84. package/node/ScatterChart/ScatterChart.js +6 -1
  85. package/node/ScatterChart/extremums.js +4 -4
  86. package/node/ScatterChart/formatter.js +23 -3
  87. package/node/SparkLineChart/SparkLineChart.js +5 -0
  88. package/node/context/AnimationProvider/Animation.types.js +5 -0
  89. package/node/context/AnimationProvider/AnimationContext.js +17 -0
  90. package/node/context/AnimationProvider/AnimationProvider.js +60 -0
  91. package/node/context/AnimationProvider/index.js +49 -0
  92. package/node/context/AnimationProvider/useSkipAnimation.js +25 -0
  93. package/node/index.js +1 -1
  94. package/node/internals/index.js +12 -8
  95. package/package.json +7 -7
  96. package/hooks/useReducedMotion.d.ts +0 -8
  97. package/hooks/useReducedMotion.js +0 -39
  98. package/modern/hooks/useReducedMotion.js +0 -39
  99. package/node/hooks/useReducedMotion.js +0 -45
@@ -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.19.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.19.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",
@@ -29,14 +29,14 @@
29
29
  "directory": "packages/x-charts"
30
30
  },
31
31
  "dependencies": {
32
- "@babel/runtime": "^7.25.6",
33
- "@mui/utils": "^5.16.6",
34
- "@react-spring/rafz": "^9.7.4",
35
- "@react-spring/web": "^9.7.4",
32
+ "@babel/runtime": "^7.25.7",
33
+ "@mui/utils": "^5.16.6 || ^6.0.0",
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
- "@mui/x-charts-vendor": "7.19.0",
39
- "@mui/x-internals": "7.18.0"
38
+ "@mui/x-charts-vendor": "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;