@mui/x-charts-pro 9.4.0 → 9.5.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 (74) hide show
  1. package/BarChartPro/BarChartPro.js +1 -1
  2. package/BarChartPro/BarChartPro.mjs +2 -2
  3. package/CHANGELOG.md +100 -0
  4. package/ChartsDataProviderPro/ChartsDataProviderPro.js +2 -2
  5. package/ChartsDataProviderPro/ChartsDataProviderPro.mjs +2 -2
  6. package/FunnelChart/funnel.types.d.mts +1 -1
  7. package/FunnelChart/funnel.types.d.ts +1 -1
  8. package/LineChartPro/LineChartPro.js +1 -1
  9. package/LineChartPro/LineChartPro.mjs +2 -2
  10. package/PieChartPro/PieChartPro.js +1 -1
  11. package/PieChartPro/PieChartPro.mjs +2 -2
  12. package/RadarChartPro/RadarChartPro.js +1 -1
  13. package/RadarChartPro/RadarChartPro.mjs +2 -2
  14. package/ScatterChartPro/ScatterChartPro.js +8 -4
  15. package/ScatterChartPro/ScatterChartPro.mjs +9 -5
  16. package/ScatterChartPro/ScatterChartPro.plugins.d.mts +2 -2
  17. package/ScatterChartPro/ScatterChartPro.plugins.d.ts +2 -2
  18. package/ScatterChartPro/ScatterChartPro.plugins.js +1 -1
  19. package/ScatterChartPro/ScatterChartPro.plugins.mjs +2 -2
  20. package/index.js +1 -1
  21. package/index.mjs +1 -1
  22. package/internals/plugins/allPlugins.d.mts +5 -5
  23. package/internals/plugins/allPlugins.d.ts +5 -5
  24. package/internals/plugins/allPlugins.js +2 -2
  25. package/internals/plugins/allPlugins.mjs +3 -3
  26. package/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.d.mts +36 -4
  27. package/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.d.ts +36 -4
  28. package/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.js +2 -4
  29. package/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.mjs +1 -3
  30. package/internals/plugins/useChartProZoom/ZoomInteractionConfig.types.d.mts +11 -11
  31. package/internals/plugins/useChartProZoom/ZoomInteractionConfig.types.d.ts +11 -11
  32. package/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.d.mts +0 -1
  33. package/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.d.ts +0 -1
  34. package/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.js +9 -65
  35. package/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.mjs +9 -64
  36. package/internals/plugins/useChartProZoom/gestureHooks/usePanOnPressAndDrag.d.mts +0 -1
  37. package/internals/plugins/useChartProZoom/gestureHooks/usePanOnPressAndDrag.d.ts +0 -1
  38. package/internals/plugins/useChartProZoom/gestureHooks/usePanOnPressAndDrag.js +9 -69
  39. package/internals/plugins/useChartProZoom/gestureHooks/usePanOnPressAndDrag.mjs +9 -68
  40. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.d.mts +0 -1
  41. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.d.ts +0 -1
  42. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.js +9 -39
  43. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.mjs +10 -39
  44. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.d.mts +0 -1
  45. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.d.ts +0 -1
  46. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.js +9 -58
  47. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.mjs +10 -58
  48. package/internals/plugins/zoomGestures/index.d.mts +5 -0
  49. package/internals/plugins/zoomGestures/index.d.ts +5 -0
  50. package/internals/plugins/zoomGestures/index.js +33 -0
  51. package/internals/plugins/zoomGestures/index.mjs +4 -0
  52. package/internals/plugins/zoomGestures/useDragGesture.d.mts +30 -0
  53. package/internals/plugins/zoomGestures/useDragGesture.d.ts +30 -0
  54. package/internals/plugins/zoomGestures/useDragGesture.js +105 -0
  55. package/internals/plugins/zoomGestures/useDragGesture.mjs +99 -0
  56. package/internals/plugins/zoomGestures/useDragOnPressGesture.d.mts +30 -0
  57. package/internals/plugins/zoomGestures/useDragOnPressGesture.d.ts +30 -0
  58. package/internals/plugins/zoomGestures/useDragOnPressGesture.js +105 -0
  59. package/internals/plugins/zoomGestures/useDragOnPressGesture.mjs +99 -0
  60. package/internals/plugins/zoomGestures/usePinchGesture.d.mts +22 -0
  61. package/internals/plugins/zoomGestures/usePinchGesture.d.ts +22 -0
  62. package/internals/plugins/zoomGestures/usePinchGesture.js +77 -0
  63. package/internals/plugins/zoomGestures/usePinchGesture.mjs +71 -0
  64. package/internals/plugins/zoomGestures/useWheelGesture.d.mts +21 -0
  65. package/internals/plugins/zoomGestures/useWheelGesture.d.ts +21 -0
  66. package/internals/plugins/zoomGestures/useWheelGesture.js +78 -0
  67. package/internals/plugins/zoomGestures/useWheelGesture.mjs +72 -0
  68. package/internals/plugins/zoomGestures/zoomGestures.types.d.mts +29 -0
  69. package/internals/plugins/zoomGestures/zoomGestures.types.d.ts +29 -0
  70. package/internals/plugins/zoomGestures/zoomGestures.types.js +5 -0
  71. package/internals/plugins/zoomGestures/zoomGestures.types.mjs +1 -0
  72. package/models/seriesType/heatmap.d.mts +1 -1
  73. package/models/seriesType/heatmap.d.ts +1 -1
  74. package/package.json +3 -3
@@ -0,0 +1,72 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { rafThrottle } from '@mui/x-internals/rafThrottle';
5
+ import { getChartPoint } from '@mui/x-charts/internals';
6
+ /**
7
+ * Generic wheel gesture binding.
8
+ *
9
+ * It owns the listener lifecycle, and lets you create your own interactions from the focal point and wheel event it forwards to `onWheel`.
10
+ */
11
+ export function useWheelGesture(instance, options) {
12
+ const {
13
+ enabled,
14
+ requiredKeys,
15
+ onWheel
16
+ } = options;
17
+ const {
18
+ chartsLayerContainerRef
19
+ } = instance;
20
+ const startedOutsideRef = React.useRef(false);
21
+ const startedOutsideTimeoutRef = React.useRef(null);
22
+ const onWheelRef = React.useRef(onWheel);
23
+ React.useEffect(() => {
24
+ onWheelRef.current = onWheel;
25
+ });
26
+ React.useEffect(() => {
27
+ if (!enabled) {
28
+ return;
29
+ }
30
+ instance.updateZoomInteractionListeners('zoomTurnWheel', {
31
+ requiredKeys
32
+ });
33
+ }, [enabled, requiredKeys, instance]);
34
+ React.useEffect(() => {
35
+ const element = chartsLayerContainerRef.current;
36
+ if (element === null || !enabled) {
37
+ return () => {};
38
+ }
39
+ const rafThrottledOnWheel = rafThrottle(onWheelRef.current);
40
+ const handler = instance.addInteractionListener('zoomTurnWheel', event => {
41
+ const point = getChartPoint(element, {
42
+ clientX: event.detail.centroid.x,
43
+ clientY: event.detail.centroid.y
44
+ });
45
+
46
+ // Ignore wheel events that started outside the chart area (e.g. while page-scrolling
47
+ // over the chart). The timeout debounces re-entry caused by the scroll itself.
48
+ if (startedOutsideRef.current || !instance.isPointInside(point.x, point.y)) {
49
+ startedOutsideRef.current = true;
50
+ if (startedOutsideTimeoutRef.current) {
51
+ clearTimeout(startedOutsideTimeoutRef.current);
52
+ }
53
+ startedOutsideTimeoutRef.current = setTimeout(() => {
54
+ startedOutsideRef.current = false;
55
+ startedOutsideTimeoutRef.current = null;
56
+ }, 100);
57
+ return;
58
+ }
59
+ event.detail.srcEvent.preventDefault();
60
+ rafThrottledOnWheel(point, event.detail.srcEvent);
61
+ });
62
+ return () => {
63
+ handler.cleanup();
64
+ if (startedOutsideTimeoutRef.current) {
65
+ clearTimeout(startedOutsideTimeoutRef.current);
66
+ startedOutsideTimeoutRef.current = null;
67
+ }
68
+ startedOutsideRef.current = false;
69
+ rafThrottledOnWheel.clear();
70
+ };
71
+ }, [chartsLayerContainerRef, enabled, instance]);
72
+ }
@@ -0,0 +1,29 @@
1
+ import type * as React from 'react';
2
+ import type { KeyboardKey, PointerMode } from '@mui/x-internal-gestures/core';
3
+ import type { UseChartInteractionListenerInstance } from '@mui/x-charts/internals';
4
+ /**
5
+ * The minimal slice of a chart instance required to bind zoom/pan gestures.
6
+ */
7
+ export interface GestureInstance {
8
+ chartsLayerContainerRef: React.RefObject<HTMLDivElement | null>;
9
+ addInteractionListener: UseChartInteractionListenerInstance['addInteractionListener'];
10
+ updateZoomInteractionListeners: UseChartInteractionListenerInstance['updateZoomInteractionListeners'];
11
+ isPointInside: (x: number, y: number, targetElement?: Element | EventTarget | null) => boolean;
12
+ }
13
+ /**
14
+ * Pointer and keyboard gating for a pan gesture.
15
+ */
16
+ export interface PanGestureConfig {
17
+ requiredKeys?: KeyboardKey[];
18
+ pointerMode?: PointerMode[];
19
+ mouse?: {
20
+ requiredKeys?: KeyboardKey[];
21
+ };
22
+ touch?: {
23
+ requiredKeys?: KeyboardKey[];
24
+ };
25
+ }
26
+ export interface ChartPoint {
27
+ x: number;
28
+ y: number;
29
+ }
@@ -0,0 +1,29 @@
1
+ import type * as React from 'react';
2
+ import type { KeyboardKey, PointerMode } from '@mui/x-internal-gestures/core';
3
+ import type { UseChartInteractionListenerInstance } from '@mui/x-charts/internals';
4
+ /**
5
+ * The minimal slice of a chart instance required to bind zoom/pan gestures.
6
+ */
7
+ export interface GestureInstance {
8
+ chartsLayerContainerRef: React.RefObject<HTMLDivElement | null>;
9
+ addInteractionListener: UseChartInteractionListenerInstance['addInteractionListener'];
10
+ updateZoomInteractionListeners: UseChartInteractionListenerInstance['updateZoomInteractionListeners'];
11
+ isPointInside: (x: number, y: number, targetElement?: Element | EventTarget | null) => boolean;
12
+ }
13
+ /**
14
+ * Pointer and keyboard gating for a pan gesture.
15
+ */
16
+ export interface PanGestureConfig {
17
+ requiredKeys?: KeyboardKey[];
18
+ pointerMode?: PointerMode[];
19
+ mouse?: {
20
+ requiredKeys?: KeyboardKey[];
21
+ };
22
+ touch?: {
23
+ requiredKeys?: KeyboardKey[];
24
+ };
25
+ }
26
+ export interface ChartPoint {
27
+ x: number;
28
+ y: number;
29
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -1,7 +1,7 @@
1
1
  import { type DefaultizedProps } from '@mui/x-internals/types';
2
2
  import { type CommonDefaultizedProps, type CommonSeriesType, type CartesianSeriesType, type DatasetElementType } from '@mui/x-charts/internals';
3
3
  export type HeatmapValueType = readonly [number, number, number];
4
- export interface HeatmapSeriesType extends Omit<CommonSeriesType<HeatmapValueType, 'heatmap'>, 'color' | 'colorGetter' | 'valueFormatter'>, CartesianSeriesType {
4
+ export interface HeatmapSeriesType extends Omit<CommonSeriesType<'heatmap'>, 'color' | 'colorGetter' | 'valueFormatter'>, CartesianSeriesType {
5
5
  type: 'heatmap';
6
6
  /**
7
7
  * Data associated to each cell in the heatmap.
@@ -1,7 +1,7 @@
1
1
  import { type DefaultizedProps } from '@mui/x-internals/types';
2
2
  import { type CommonDefaultizedProps, type CommonSeriesType, type CartesianSeriesType, type DatasetElementType } from '@mui/x-charts/internals';
3
3
  export type HeatmapValueType = readonly [number, number, number];
4
- export interface HeatmapSeriesType extends Omit<CommonSeriesType<HeatmapValueType, 'heatmap'>, 'color' | 'colorGetter' | 'valueFormatter'>, CartesianSeriesType {
4
+ export interface HeatmapSeriesType extends Omit<CommonSeriesType<'heatmap'>, 'color' | 'colorGetter' | 'valueFormatter'>, CartesianSeriesType {
5
5
  type: 'heatmap';
6
6
  /**
7
7
  * Data associated to each cell in the heatmap.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-charts-pro",
3
- "version": "9.4.0",
3
+ "version": "9.5.0",
4
4
  "author": "MUI Team",
5
5
  "description": "The Pro plan edition of the MUI X Charts components.",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -31,10 +31,10 @@
31
31
  "@mui/utils": "9.0.1",
32
32
  "clsx": "^2.1.1",
33
33
  "prop-types": "^15.8.1",
34
- "@mui/x-charts": "^9.4.0",
35
- "@mui/x-internal-gestures": "^9.3.0",
34
+ "@mui/x-charts": "^9.5.0",
36
35
  "@mui/x-charts-vendor": "^9.4.0",
37
36
  "@mui/x-internals": "^9.1.0",
37
+ "@mui/x-internal-gestures": "^9.3.0",
38
38
  "@mui/x-license": "^9.4.0"
39
39
  },
40
40
  "peerDependencies": {