@mui/x-charts-pro 9.4.0 → 9.6.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.
- package/BarChartPro/BarChartPro.js +6 -4
- package/BarChartPro/BarChartPro.mjs +7 -5
- package/CHANGELOG.md +251 -0
- package/ChartsDataProviderPro/ChartsDataProviderPro.js +7 -3
- package/ChartsDataProviderPro/ChartsDataProviderPro.mjs +7 -3
- package/ChartsToolbarPro/ChartsToolbarImageExportTrigger.js +1 -1
- package/ChartsToolbarPro/ChartsToolbarImageExportTrigger.mjs +1 -1
- package/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.js +1 -1
- package/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.mjs +1 -1
- package/ChartsToolbarPro/ChartsToolbarPro.js +3 -2
- package/ChartsToolbarPro/ChartsToolbarPro.mjs +3 -2
- package/ChartsToolbarPro/ChartsToolbarRangeButtonTrigger.js +1 -1
- package/ChartsToolbarPro/ChartsToolbarRangeButtonTrigger.mjs +1 -1
- package/ChartsToolbarPro/ChartsToolbarZoomInTrigger.js +1 -1
- package/ChartsToolbarPro/ChartsToolbarZoomInTrigger.mjs +1 -1
- package/ChartsToolbarPro/ChartsToolbarZoomOutTrigger.js +1 -1
- package/ChartsToolbarPro/ChartsToolbarZoomOutTrigger.mjs +1 -1
- package/FunnelChart/FunnelChart.js +1 -1
- package/FunnelChart/FunnelChart.mjs +1 -1
- package/FunnelChart/FunnelPlot.js +5 -1
- package/FunnelChart/FunnelPlot.mjs +5 -1
- package/FunnelChart/funnel.types.d.mts +1 -1
- package/FunnelChart/funnel.types.d.ts +1 -1
- package/Heatmap/Heatmap.js +5 -3
- package/Heatmap/Heatmap.mjs +5 -3
- package/Heatmap/HeatmapCell.js +1 -1
- package/Heatmap/HeatmapCell.mjs +1 -1
- package/Heatmap/HeatmapPlot.js +1 -1
- package/Heatmap/HeatmapPlot.mjs +1 -1
- package/Heatmap/HeatmapTooltip/HeatmapTooltip.js +5 -25
- package/Heatmap/HeatmapTooltip/HeatmapTooltip.mjs +5 -25
- package/Heatmap/HeatmapTooltip/HeatmapTooltipContent.js +1 -1
- package/Heatmap/HeatmapTooltip/HeatmapTooltipContent.mjs +1 -1
- package/LineChartPro/LineChartPro.js +6 -4
- package/LineChartPro/LineChartPro.mjs +7 -5
- package/PieChartPro/PieChartPro.js +2 -2
- package/PieChartPro/PieChartPro.mjs +3 -3
- package/RadarChartPro/RadarChartPro.js +2 -2
- package/RadarChartPro/RadarChartPro.mjs +3 -3
- package/SankeyChart/SankeyChart.js +1 -1
- package/SankeyChart/SankeyChart.mjs +1 -1
- package/SankeyChart/SankeyDataProvider.d.mts +3 -0
- package/SankeyChart/SankeyDataProvider.d.ts +3 -0
- package/SankeyChart/SankeyDataProvider.js +170 -1
- package/SankeyChart/SankeyDataProvider.mjs +169 -0
- package/SankeyChart/SankeyLinkLabelPlot.d.mts +3 -0
- package/SankeyChart/SankeyLinkLabelPlot.d.ts +3 -0
- package/SankeyChart/SankeyLinkLabelPlot.js +12 -1
- package/SankeyChart/SankeyLinkLabelPlot.mjs +11 -0
- package/SankeyChart/SankeyLinkPlot.d.mts +3 -0
- package/SankeyChart/SankeyLinkPlot.d.ts +3 -0
- package/SankeyChart/SankeyLinkPlot.js +18 -1
- package/SankeyChart/SankeyLinkPlot.mjs +17 -0
- package/SankeyChart/SankeyNodeLabelPlot.d.mts +3 -0
- package/SankeyChart/SankeyNodeLabelPlot.d.ts +3 -0
- package/SankeyChart/SankeyNodeLabelPlot.js +12 -1
- package/SankeyChart/SankeyNodeLabelPlot.mjs +11 -0
- package/SankeyChart/SankeyNodePlot.d.mts +3 -0
- package/SankeyChart/SankeyNodePlot.d.ts +3 -0
- package/SankeyChart/SankeyNodePlot.js +18 -1
- package/SankeyChart/SankeyNodePlot.mjs +17 -0
- package/SankeyChart/SankeyPlot.js +5 -1
- package/SankeyChart/SankeyPlot.mjs +5 -1
- package/SankeyChart/SankeyTooltip/SankeyTooltip.js +8 -28
- package/SankeyChart/SankeyTooltip/SankeyTooltip.mjs +8 -28
- package/SankeyChart/SankeyTooltip/SankeyTooltipContent.js +1 -1
- package/SankeyChart/SankeyTooltip/SankeyTooltipContent.mjs +1 -1
- package/ScatterChartPro/ScatterChartPro.js +13 -7
- package/ScatterChartPro/ScatterChartPro.mjs +14 -8
- package/ScatterChartPro/ScatterChartPro.plugins.d.mts +2 -2
- package/ScatterChartPro/ScatterChartPro.plugins.d.ts +2 -2
- package/ScatterChartPro/ScatterChartPro.plugins.js +1 -1
- package/ScatterChartPro/ScatterChartPro.plugins.mjs +2 -2
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internals/plugins/allPlugins.d.mts +5 -5
- package/internals/plugins/allPlugins.d.ts +5 -5
- package/internals/plugins/allPlugins.js +2 -2
- package/internals/plugins/allPlugins.mjs +3 -3
- package/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.d.mts +36 -4
- package/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.d.ts +36 -4
- package/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.js +2 -4
- package/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.mjs +1 -3
- package/internals/plugins/useChartProZoom/ZoomInteractionConfig.types.d.mts +11 -11
- package/internals/plugins/useChartProZoom/ZoomInteractionConfig.types.d.ts +11 -11
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.d.mts +0 -1
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.d.ts +0 -1
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.js +9 -65
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.mjs +9 -64
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnPressAndDrag.d.mts +0 -1
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnPressAndDrag.d.ts +0 -1
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnPressAndDrag.js +9 -69
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnPressAndDrag.mjs +9 -68
- package/internals/plugins/useChartProZoom/gestureHooks/useRegisterZoomGestures.d.mts +10 -0
- package/internals/plugins/useChartProZoom/gestureHooks/useRegisterZoomGestures.d.ts +10 -0
- package/internals/plugins/useChartProZoom/gestureHooks/useRegisterZoomGestures.js +49 -0
- package/internals/plugins/useChartProZoom/gestureHooks/useRegisterZoomGestures.mjs +42 -0
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.d.mts +0 -1
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.d.ts +0 -1
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.js +9 -39
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.mjs +10 -39
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.d.mts +0 -1
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.d.ts +0 -1
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.js +9 -58
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.mjs +10 -58
- package/internals/plugins/useChartProZoom/useChartProZoom.js +2 -0
- package/internals/plugins/useChartProZoom/useChartProZoom.mjs +2 -0
- package/internals/plugins/zoomGestures/index.d.mts +5 -0
- package/internals/plugins/zoomGestures/index.d.ts +5 -0
- package/internals/plugins/zoomGestures/index.js +33 -0
- package/internals/plugins/zoomGestures/index.mjs +4 -0
- package/internals/plugins/zoomGestures/useDragGesture.d.mts +30 -0
- package/internals/plugins/zoomGestures/useDragGesture.d.ts +30 -0
- package/internals/plugins/zoomGestures/useDragGesture.js +105 -0
- package/internals/plugins/zoomGestures/useDragGesture.mjs +99 -0
- package/internals/plugins/zoomGestures/useDragOnPressGesture.d.mts +30 -0
- package/internals/plugins/zoomGestures/useDragOnPressGesture.d.ts +30 -0
- package/internals/plugins/zoomGestures/useDragOnPressGesture.js +105 -0
- package/internals/plugins/zoomGestures/useDragOnPressGesture.mjs +99 -0
- package/internals/plugins/zoomGestures/usePinchGesture.d.mts +22 -0
- package/internals/plugins/zoomGestures/usePinchGesture.d.ts +22 -0
- package/internals/plugins/zoomGestures/usePinchGesture.js +77 -0
- package/internals/plugins/zoomGestures/usePinchGesture.mjs +71 -0
- package/internals/plugins/zoomGestures/useWheelGesture.d.mts +21 -0
- package/internals/plugins/zoomGestures/useWheelGesture.d.ts +21 -0
- package/internals/plugins/zoomGestures/useWheelGesture.js +78 -0
- package/internals/plugins/zoomGestures/useWheelGesture.mjs +72 -0
- package/internals/plugins/zoomGestures/zoomGestures.types.d.mts +29 -0
- package/internals/plugins/zoomGestures/zoomGestures.types.d.ts +29 -0
- package/internals/plugins/zoomGestures/zoomGestures.types.js +5 -0
- package/internals/plugins/zoomGestures/zoomGestures.types.mjs +1 -0
- package/models/seriesType/heatmap.d.mts +1 -1
- package/models/seriesType/heatmap.d.ts +1 -1
- package/package.json +10 -7
|
@@ -35,11 +35,11 @@ export type DefaultizedZoomInteractionConfig = {
|
|
|
35
35
|
zoom: Entry<ZoomInteraction>;
|
|
36
36
|
pan: Entry<PanInteraction>;
|
|
37
37
|
};
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
type ZoomInteraction = WheelInteraction | PinchInteraction | TapAndDragInteraction | DoubleTapResetInteraction | BrushInteraction;
|
|
39
|
+
type PanInteraction = DragInteraction | PressAndDragInteraction | WheelPanInteraction;
|
|
40
40
|
export type ZoomInteractionName = ZoomInteraction['type'];
|
|
41
41
|
export type PanInteractionName = PanInteraction['type'];
|
|
42
|
-
|
|
42
|
+
type InteractionMode = Exclude<PointerMode, 'pen'>;
|
|
43
43
|
type AllKeysProp = {
|
|
44
44
|
/**
|
|
45
45
|
* The keys that must be pressed to trigger the interaction.
|
|
@@ -68,22 +68,22 @@ type NoModeProp = {
|
|
|
68
68
|
pointerMode?: any;
|
|
69
69
|
};
|
|
70
70
|
type Unpack<T> = { [K in keyof T]: T[K] extends object ? Unpack<T[K]> : T[K] };
|
|
71
|
-
|
|
71
|
+
type WheelInteraction = Unpack<{
|
|
72
72
|
type: 'wheel';
|
|
73
73
|
} & NoModeProp & AllKeysProp>;
|
|
74
|
-
|
|
74
|
+
type PinchInteraction = Unpack<{
|
|
75
75
|
type: 'pinch';
|
|
76
76
|
} & NoModeProp & NoKeysProp>;
|
|
77
|
-
|
|
77
|
+
type DragInteraction = Unpack<{
|
|
78
78
|
type: 'drag';
|
|
79
79
|
} & AllModeProp & AllKeysProp>;
|
|
80
|
-
|
|
80
|
+
type TapAndDragInteraction = Unpack<{
|
|
81
81
|
type: 'tapAndDrag';
|
|
82
82
|
} & AllModeProp & AllKeysProp>;
|
|
83
|
-
|
|
83
|
+
type PressAndDragInteraction = Unpack<{
|
|
84
84
|
type: 'pressAndDrag';
|
|
85
85
|
} & AllModeProp & AllKeysProp>;
|
|
86
|
-
|
|
86
|
+
type WheelPanInteraction = Unpack<{
|
|
87
87
|
type: 'wheel';
|
|
88
88
|
/**
|
|
89
89
|
* Defines which axes are affected by pan on wheel.
|
|
@@ -94,10 +94,10 @@ export type WheelPanInteraction = Unpack<{
|
|
|
94
94
|
*/
|
|
95
95
|
allowedDirection?: 'x' | 'y' | 'xy';
|
|
96
96
|
} & NoModeProp & AllKeysProp>;
|
|
97
|
-
|
|
97
|
+
type DoubleTapResetInteraction = Unpack<{
|
|
98
98
|
type: 'doubleTapReset';
|
|
99
99
|
} & AllModeProp & AllKeysProp>;
|
|
100
|
-
|
|
100
|
+
type BrushInteraction = Unpack<{
|
|
101
101
|
type: 'brush';
|
|
102
102
|
} & AllModeProp & AllKeysProp>;
|
|
103
103
|
export type AnyInteraction = {
|
|
@@ -1,90 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'use client';
|
|
3
3
|
|
|
4
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.usePanOnDrag = void 0;
|
|
9
|
-
var React = _interopRequireWildcard(require("react"));
|
|
10
8
|
var _internals = require("@mui/x-charts/internals");
|
|
11
|
-
var _rafThrottle = require("@mui/x-internals/rafThrottle");
|
|
12
9
|
var _useZoom = require("./useZoom.utils");
|
|
13
10
|
var _ZoomInteractionConfig = require("../ZoomInteractionConfig.selectors");
|
|
11
|
+
var _useDragGesture = require("../../zoomGestures/useDragGesture");
|
|
14
12
|
const usePanOnDrag = ({
|
|
15
13
|
store,
|
|
16
14
|
instance
|
|
17
15
|
}, setZoomDataCallback) => {
|
|
18
|
-
const {
|
|
19
|
-
chartsLayerContainerRef
|
|
20
|
-
} = instance;
|
|
21
16
|
const drawingArea = store.use(_internals.selectorChartDrawingArea);
|
|
22
17
|
const optionsLookup = store.use(_internals.selectorChartZoomOptionsLookup);
|
|
23
18
|
const config = store.use(_ZoomInteractionConfig.selectorPanInteractionConfig, 'drag');
|
|
24
19
|
const isPanOnDragEnabled = Object.values(optionsLookup).some(v => v.panning) && Boolean(config);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
instance.updateZoomInteractionListeners('zoomPan', {
|
|
30
|
-
requiredKeys: config.requiredKeys,
|
|
31
|
-
pointerMode: config.pointerMode,
|
|
32
|
-
pointerOptions: {
|
|
33
|
-
mouse: config.mouse,
|
|
34
|
-
touch: config.touch
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}, [isPanOnDragEnabled, config, instance]);
|
|
38
|
-
|
|
39
|
-
// Add event for chart panning
|
|
40
|
-
React.useEffect(() => {
|
|
41
|
-
const element = chartsLayerContainerRef.current;
|
|
42
|
-
let isInteracting = false;
|
|
43
|
-
const accumulatedChange = {
|
|
44
|
-
x: 0,
|
|
45
|
-
y: 0
|
|
46
|
-
};
|
|
47
|
-
if (element === null || !isPanOnDragEnabled) {
|
|
48
|
-
return () => {};
|
|
49
|
-
}
|
|
50
|
-
const handlePanStart = event => {
|
|
51
|
-
if (!event.detail.target?.closest('[data-charts-zoom-slider]')) {
|
|
52
|
-
isInteracting = true;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
const handlePanEnd = () => {
|
|
56
|
-
isInteracting = false;
|
|
57
|
-
};
|
|
58
|
-
const throttledCallback = (0, _rafThrottle.rafThrottle)(() => {
|
|
59
|
-
const x = accumulatedChange.x;
|
|
60
|
-
const y = accumulatedChange.y;
|
|
61
|
-
accumulatedChange.x = 0;
|
|
62
|
-
accumulatedChange.y = 0;
|
|
20
|
+
(0, _useDragGesture.useDragGesture)(instance, {
|
|
21
|
+
config: config ?? undefined,
|
|
22
|
+
enabled: isPanOnDragEnabled,
|
|
23
|
+
onPan: delta => {
|
|
63
24
|
setZoomDataCallback(prev => (0, _useZoom.translateZoom)(prev, {
|
|
64
|
-
x,
|
|
65
|
-
y: -y
|
|
25
|
+
x: delta.x,
|
|
26
|
+
y: -delta.y
|
|
66
27
|
}, {
|
|
67
28
|
width: drawingArea.width,
|
|
68
29
|
height: drawingArea.height
|
|
69
30
|
}, optionsLookup));
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (!isInteracting) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
accumulatedChange.x += event.detail.deltaX;
|
|
76
|
-
accumulatedChange.y += event.detail.deltaY;
|
|
77
|
-
throttledCallback();
|
|
78
|
-
};
|
|
79
|
-
const panHandler = instance.addInteractionListener('zoomPan', handlePan);
|
|
80
|
-
const panStartHandler = instance.addInteractionListener('zoomPanStart', handlePanStart);
|
|
81
|
-
const panEndHandler = instance.addInteractionListener('zoomPanEnd', handlePanEnd);
|
|
82
|
-
return () => {
|
|
83
|
-
panStartHandler.cleanup();
|
|
84
|
-
panHandler.cleanup();
|
|
85
|
-
panEndHandler.cleanup();
|
|
86
|
-
throttledCallback.clear();
|
|
87
|
-
};
|
|
88
|
-
}, [instance, chartsLayerContainerRef, isPanOnDragEnabled, optionsLookup, drawingArea.width, drawingArea.height, setZoomDataCallback, store]);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
89
33
|
};
|
|
90
34
|
exports.usePanOnDrag = usePanOnDrag;
|
|
@@ -1,83 +1,28 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import * as React from 'react';
|
|
4
3
|
import { selectorChartDrawingArea, selectorChartZoomOptionsLookup } from '@mui/x-charts/internals';
|
|
5
|
-
import { rafThrottle } from '@mui/x-internals/rafThrottle';
|
|
6
4
|
import { translateZoom } from "./useZoom.utils.mjs";
|
|
7
5
|
import { selectorPanInteractionConfig } from "../ZoomInteractionConfig.selectors.mjs";
|
|
6
|
+
import { useDragGesture } from "../../zoomGestures/useDragGesture.mjs";
|
|
8
7
|
export const usePanOnDrag = ({
|
|
9
8
|
store,
|
|
10
9
|
instance
|
|
11
10
|
}, setZoomDataCallback) => {
|
|
12
|
-
const {
|
|
13
|
-
chartsLayerContainerRef
|
|
14
|
-
} = instance;
|
|
15
11
|
const drawingArea = store.use(selectorChartDrawingArea);
|
|
16
12
|
const optionsLookup = store.use(selectorChartZoomOptionsLookup);
|
|
17
13
|
const config = store.use(selectorPanInteractionConfig, 'drag');
|
|
18
14
|
const isPanOnDragEnabled = Object.values(optionsLookup).some(v => v.panning) && Boolean(config);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
instance.updateZoomInteractionListeners('zoomPan', {
|
|
24
|
-
requiredKeys: config.requiredKeys,
|
|
25
|
-
pointerMode: config.pointerMode,
|
|
26
|
-
pointerOptions: {
|
|
27
|
-
mouse: config.mouse,
|
|
28
|
-
touch: config.touch
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}, [isPanOnDragEnabled, config, instance]);
|
|
32
|
-
|
|
33
|
-
// Add event for chart panning
|
|
34
|
-
React.useEffect(() => {
|
|
35
|
-
const element = chartsLayerContainerRef.current;
|
|
36
|
-
let isInteracting = false;
|
|
37
|
-
const accumulatedChange = {
|
|
38
|
-
x: 0,
|
|
39
|
-
y: 0
|
|
40
|
-
};
|
|
41
|
-
if (element === null || !isPanOnDragEnabled) {
|
|
42
|
-
return () => {};
|
|
43
|
-
}
|
|
44
|
-
const handlePanStart = event => {
|
|
45
|
-
if (!event.detail.target?.closest('[data-charts-zoom-slider]')) {
|
|
46
|
-
isInteracting = true;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const handlePanEnd = () => {
|
|
50
|
-
isInteracting = false;
|
|
51
|
-
};
|
|
52
|
-
const throttledCallback = rafThrottle(() => {
|
|
53
|
-
const x = accumulatedChange.x;
|
|
54
|
-
const y = accumulatedChange.y;
|
|
55
|
-
accumulatedChange.x = 0;
|
|
56
|
-
accumulatedChange.y = 0;
|
|
15
|
+
useDragGesture(instance, {
|
|
16
|
+
config: config ?? undefined,
|
|
17
|
+
enabled: isPanOnDragEnabled,
|
|
18
|
+
onPan: delta => {
|
|
57
19
|
setZoomDataCallback(prev => translateZoom(prev, {
|
|
58
|
-
x,
|
|
59
|
-
y: -y
|
|
20
|
+
x: delta.x,
|
|
21
|
+
y: -delta.y
|
|
60
22
|
}, {
|
|
61
23
|
width: drawingArea.width,
|
|
62
24
|
height: drawingArea.height
|
|
63
25
|
}, optionsLookup));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (!isInteracting) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
accumulatedChange.x += event.detail.deltaX;
|
|
70
|
-
accumulatedChange.y += event.detail.deltaY;
|
|
71
|
-
throttledCallback();
|
|
72
|
-
};
|
|
73
|
-
const panHandler = instance.addInteractionListener('zoomPan', handlePan);
|
|
74
|
-
const panStartHandler = instance.addInteractionListener('zoomPanStart', handlePanStart);
|
|
75
|
-
const panEndHandler = instance.addInteractionListener('zoomPanEnd', handlePanEnd);
|
|
76
|
-
return () => {
|
|
77
|
-
panStartHandler.cleanup();
|
|
78
|
-
panHandler.cleanup();
|
|
79
|
-
panEndHandler.cleanup();
|
|
80
|
-
throttledCallback.clear();
|
|
81
|
-
};
|
|
82
|
-
}, [instance, chartsLayerContainerRef, isPanOnDragEnabled, optionsLookup, drawingArea.width, drawingArea.height, setZoomDataCallback, store]);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
83
28
|
};
|
|
@@ -1,94 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'use client';
|
|
3
3
|
|
|
4
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.usePanOnPressAndDrag = void 0;
|
|
9
|
-
var React = _interopRequireWildcard(require("react"));
|
|
10
8
|
var _internals = require("@mui/x-charts/internals");
|
|
11
|
-
var _rafThrottle = require("@mui/x-internals/rafThrottle");
|
|
12
9
|
var _useZoom = require("./useZoom.utils");
|
|
13
10
|
var _ZoomInteractionConfig = require("../ZoomInteractionConfig.selectors");
|
|
11
|
+
var _useDragOnPressGesture = require("../../zoomGestures/useDragOnPressGesture");
|
|
14
12
|
const usePanOnPressAndDrag = ({
|
|
15
13
|
store,
|
|
16
14
|
instance
|
|
17
15
|
}, setZoomDataCallback) => {
|
|
18
|
-
const {
|
|
19
|
-
chartsLayerContainerRef
|
|
20
|
-
} = instance;
|
|
21
16
|
const drawingArea = store.use(_internals.selectorChartDrawingArea);
|
|
22
17
|
const optionsLookup = store.use(_internals.selectorChartZoomOptionsLookup);
|
|
23
|
-
const isInteracting = React.useRef(false);
|
|
24
|
-
const accumulatedChange = React.useRef({
|
|
25
|
-
x: 0,
|
|
26
|
-
y: 0
|
|
27
|
-
});
|
|
28
18
|
const config = store.use(_ZoomInteractionConfig.selectorPanInteractionConfig, 'pressAndDrag');
|
|
29
19
|
const isPanOnPressAndDragEnabled = Object.values(optionsLookup).some(v => v.panning) && Boolean(config);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
instance.updateZoomInteractionListeners('zoomPressAndDrag', {
|
|
35
|
-
requiredKeys: config.requiredKeys,
|
|
36
|
-
pointerMode: config.pointerMode,
|
|
37
|
-
pointerOptions: {
|
|
38
|
-
mouse: config.mouse,
|
|
39
|
-
touch: config.touch
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}, [isPanOnPressAndDragEnabled, config, instance]);
|
|
43
|
-
|
|
44
|
-
// Add event for chart panning with press and drag
|
|
45
|
-
React.useEffect(() => {
|
|
46
|
-
const element = chartsLayerContainerRef.current;
|
|
47
|
-
if (element === null || !isPanOnPressAndDragEnabled) {
|
|
48
|
-
return () => {};
|
|
49
|
-
}
|
|
50
|
-
const handlePressAndDragStart = event => {
|
|
51
|
-
if (!event.detail.target?.closest('[data-charts-zoom-slider]')) {
|
|
52
|
-
isInteracting.current = true;
|
|
53
|
-
accumulatedChange.current = {
|
|
54
|
-
x: 0,
|
|
55
|
-
y: 0
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
const handlePressAndDragEnd = () => {
|
|
60
|
-
isInteracting.current = false;
|
|
61
|
-
};
|
|
62
|
-
const throttledCallback = (0, _rafThrottle.rafThrottle)(() => {
|
|
63
|
-
const x = accumulatedChange.current.x;
|
|
64
|
-
const y = accumulatedChange.current.y;
|
|
65
|
-
accumulatedChange.current.x = 0;
|
|
66
|
-
accumulatedChange.current.y = 0;
|
|
20
|
+
(0, _useDragOnPressGesture.useDragOnPressGesture)(instance, {
|
|
21
|
+
config: config ?? undefined,
|
|
22
|
+
enabled: isPanOnPressAndDragEnabled,
|
|
23
|
+
onPan: delta => {
|
|
67
24
|
setZoomDataCallback(prev => (0, _useZoom.translateZoom)(prev, {
|
|
68
|
-
x,
|
|
69
|
-
y: -y
|
|
25
|
+
x: delta.x,
|
|
26
|
+
y: -delta.y
|
|
70
27
|
}, {
|
|
71
28
|
width: drawingArea.width,
|
|
72
29
|
height: drawingArea.height
|
|
73
30
|
}, optionsLookup));
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (!isInteracting.current) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
accumulatedChange.current.x += event.detail.deltaX;
|
|
80
|
-
accumulatedChange.current.y += event.detail.deltaY;
|
|
81
|
-
throttledCallback();
|
|
82
|
-
};
|
|
83
|
-
const pressAndDragHandler = instance.addInteractionListener('zoomPressAndDrag', handlePressAndDrag);
|
|
84
|
-
const pressAndDragStartHandler = instance.addInteractionListener('zoomPressAndDragStart', handlePressAndDragStart);
|
|
85
|
-
const pressAndDragEndHandler = instance.addInteractionListener('zoomPressAndDragEnd', handlePressAndDragEnd);
|
|
86
|
-
return () => {
|
|
87
|
-
pressAndDragStartHandler.cleanup();
|
|
88
|
-
pressAndDragHandler.cleanup();
|
|
89
|
-
pressAndDragEndHandler.cleanup();
|
|
90
|
-
throttledCallback.clear();
|
|
91
|
-
};
|
|
92
|
-
}, [instance, chartsLayerContainerRef, isPanOnPressAndDragEnabled, optionsLookup, drawingArea.width, drawingArea.height, setZoomDataCallback, store, isInteracting]);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
93
33
|
};
|
|
94
34
|
exports.usePanOnPressAndDrag = usePanOnPressAndDrag;
|
|
@@ -1,87 +1,28 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import * as React from 'react';
|
|
4
3
|
import { selectorChartDrawingArea, selectorChartZoomOptionsLookup } from '@mui/x-charts/internals';
|
|
5
|
-
import { rafThrottle } from '@mui/x-internals/rafThrottle';
|
|
6
4
|
import { translateZoom } from "./useZoom.utils.mjs";
|
|
7
5
|
import { selectorPanInteractionConfig } from "../ZoomInteractionConfig.selectors.mjs";
|
|
6
|
+
import { useDragOnPressGesture } from "../../zoomGestures/useDragOnPressGesture.mjs";
|
|
8
7
|
export const usePanOnPressAndDrag = ({
|
|
9
8
|
store,
|
|
10
9
|
instance
|
|
11
10
|
}, setZoomDataCallback) => {
|
|
12
|
-
const {
|
|
13
|
-
chartsLayerContainerRef
|
|
14
|
-
} = instance;
|
|
15
11
|
const drawingArea = store.use(selectorChartDrawingArea);
|
|
16
12
|
const optionsLookup = store.use(selectorChartZoomOptionsLookup);
|
|
17
|
-
const isInteracting = React.useRef(false);
|
|
18
|
-
const accumulatedChange = React.useRef({
|
|
19
|
-
x: 0,
|
|
20
|
-
y: 0
|
|
21
|
-
});
|
|
22
13
|
const config = store.use(selectorPanInteractionConfig, 'pressAndDrag');
|
|
23
14
|
const isPanOnPressAndDragEnabled = Object.values(optionsLookup).some(v => v.panning) && Boolean(config);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
instance.updateZoomInteractionListeners('zoomPressAndDrag', {
|
|
29
|
-
requiredKeys: config.requiredKeys,
|
|
30
|
-
pointerMode: config.pointerMode,
|
|
31
|
-
pointerOptions: {
|
|
32
|
-
mouse: config.mouse,
|
|
33
|
-
touch: config.touch
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}, [isPanOnPressAndDragEnabled, config, instance]);
|
|
37
|
-
|
|
38
|
-
// Add event for chart panning with press and drag
|
|
39
|
-
React.useEffect(() => {
|
|
40
|
-
const element = chartsLayerContainerRef.current;
|
|
41
|
-
if (element === null || !isPanOnPressAndDragEnabled) {
|
|
42
|
-
return () => {};
|
|
43
|
-
}
|
|
44
|
-
const handlePressAndDragStart = event => {
|
|
45
|
-
if (!event.detail.target?.closest('[data-charts-zoom-slider]')) {
|
|
46
|
-
isInteracting.current = true;
|
|
47
|
-
accumulatedChange.current = {
|
|
48
|
-
x: 0,
|
|
49
|
-
y: 0
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const handlePressAndDragEnd = () => {
|
|
54
|
-
isInteracting.current = false;
|
|
55
|
-
};
|
|
56
|
-
const throttledCallback = rafThrottle(() => {
|
|
57
|
-
const x = accumulatedChange.current.x;
|
|
58
|
-
const y = accumulatedChange.current.y;
|
|
59
|
-
accumulatedChange.current.x = 0;
|
|
60
|
-
accumulatedChange.current.y = 0;
|
|
15
|
+
useDragOnPressGesture(instance, {
|
|
16
|
+
config: config ?? undefined,
|
|
17
|
+
enabled: isPanOnPressAndDragEnabled,
|
|
18
|
+
onPan: delta => {
|
|
61
19
|
setZoomDataCallback(prev => translateZoom(prev, {
|
|
62
|
-
x,
|
|
63
|
-
y: -y
|
|
20
|
+
x: delta.x,
|
|
21
|
+
y: -delta.y
|
|
64
22
|
}, {
|
|
65
23
|
width: drawingArea.width,
|
|
66
24
|
height: drawingArea.height
|
|
67
25
|
}, optionsLookup));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (!isInteracting.current) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
accumulatedChange.current.x += event.detail.deltaX;
|
|
74
|
-
accumulatedChange.current.y += event.detail.deltaY;
|
|
75
|
-
throttledCallback();
|
|
76
|
-
};
|
|
77
|
-
const pressAndDragHandler = instance.addInteractionListener('zoomPressAndDrag', handlePressAndDrag);
|
|
78
|
-
const pressAndDragStartHandler = instance.addInteractionListener('zoomPressAndDragStart', handlePressAndDragStart);
|
|
79
|
-
const pressAndDragEndHandler = instance.addInteractionListener('zoomPressAndDragEnd', handlePressAndDragEnd);
|
|
80
|
-
return () => {
|
|
81
|
-
pressAndDragStartHandler.cleanup();
|
|
82
|
-
pressAndDragHandler.cleanup();
|
|
83
|
-
pressAndDragEndHandler.cleanup();
|
|
84
|
-
throttledCallback.clear();
|
|
85
|
-
};
|
|
86
|
-
}, [instance, chartsLayerContainerRef, isPanOnPressAndDragEnabled, optionsLookup, drawingArea.width, drawingArea.height, setZoomDataCallback, store, isInteracting]);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
87
28
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ChartPlugin } from '@mui/x-charts/internals';
|
|
2
|
+
import { type UseChartProZoomSignature } from "../useChartProZoom.types.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Registers the gestures required by the zoom feature.
|
|
5
|
+
* They are registered here instead of in the core interaction listener plugin
|
|
6
|
+
* so their implementations are only bundled with the zoom plugin.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useRegisterZoomGestures: ({
|
|
9
|
+
instance
|
|
10
|
+
}: Pick<Parameters<ChartPlugin<UseChartProZoomSignature>>[0], "instance">) => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ChartPlugin } from '@mui/x-charts/internals';
|
|
2
|
+
import { type UseChartProZoomSignature } from "../useChartProZoom.types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Registers the gestures required by the zoom feature.
|
|
5
|
+
* They are registered here instead of in the core interaction listener plugin
|
|
6
|
+
* so their implementations are only bundled with the zoom plugin.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useRegisterZoomGestures: ({
|
|
9
|
+
instance
|
|
10
|
+
}: Pick<Parameters<ChartPlugin<UseChartProZoomSignature>>[0], "instance">) => void;
|
|
@@ -0,0 +1,49 @@
|
|
|
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.useRegisterZoomGestures = void 0;
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _core = require("@mui/x-internal-gestures/core");
|
|
11
|
+
/**
|
|
12
|
+
* Registers the gestures required by the zoom feature.
|
|
13
|
+
* They are registered here instead of in the core interaction listener plugin
|
|
14
|
+
* so their implementations are only bundled with the zoom plugin.
|
|
15
|
+
*/
|
|
16
|
+
const useRegisterZoomGestures = ({
|
|
17
|
+
instance
|
|
18
|
+
}) => {
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
return instance.registerGestures([new _core.PanGesture({
|
|
21
|
+
name: 'zoomPan',
|
|
22
|
+
threshold: 0,
|
|
23
|
+
preventIf: ['zoomTapAndDrag', 'zoomPressAndDrag']
|
|
24
|
+
}), new _core.PinchGesture({
|
|
25
|
+
name: 'zoomPinch',
|
|
26
|
+
threshold: 5
|
|
27
|
+
}), new _core.TurnWheelGesture({
|
|
28
|
+
name: 'zoomTurnWheel',
|
|
29
|
+
sensitivity: 0.01,
|
|
30
|
+
initialDelta: 1,
|
|
31
|
+
passive: false
|
|
32
|
+
}), new _core.TurnWheelGesture({
|
|
33
|
+
name: 'panTurnWheel',
|
|
34
|
+
sensitivity: 0.5,
|
|
35
|
+
passive: false
|
|
36
|
+
}), new _core.TapAndDragGesture({
|
|
37
|
+
name: 'zoomTapAndDrag',
|
|
38
|
+
dragThreshold: 10
|
|
39
|
+
}), new _core.PressAndDragGesture({
|
|
40
|
+
name: 'zoomPressAndDrag',
|
|
41
|
+
dragThreshold: 10,
|
|
42
|
+
preventIf: ['zoomPinch']
|
|
43
|
+
}), new _core.TapGesture({
|
|
44
|
+
name: 'zoomDoubleTapReset',
|
|
45
|
+
taps: 2
|
|
46
|
+
})]);
|
|
47
|
+
}, [instance]);
|
|
48
|
+
};
|
|
49
|
+
exports.useRegisterZoomGestures = useRegisterZoomGestures;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { PanGesture, PinchGesture, PressAndDragGesture, TapAndDragGesture, TapGesture, TurnWheelGesture } from '@mui/x-internal-gestures/core';
|
|
5
|
+
/**
|
|
6
|
+
* Registers the gestures required by the zoom feature.
|
|
7
|
+
* They are registered here instead of in the core interaction listener plugin
|
|
8
|
+
* so their implementations are only bundled with the zoom plugin.
|
|
9
|
+
*/
|
|
10
|
+
export const useRegisterZoomGestures = ({
|
|
11
|
+
instance
|
|
12
|
+
}) => {
|
|
13
|
+
React.useEffect(() => {
|
|
14
|
+
return instance.registerGestures([new PanGesture({
|
|
15
|
+
name: 'zoomPan',
|
|
16
|
+
threshold: 0,
|
|
17
|
+
preventIf: ['zoomTapAndDrag', 'zoomPressAndDrag']
|
|
18
|
+
}), new PinchGesture({
|
|
19
|
+
name: 'zoomPinch',
|
|
20
|
+
threshold: 5
|
|
21
|
+
}), new TurnWheelGesture({
|
|
22
|
+
name: 'zoomTurnWheel',
|
|
23
|
+
sensitivity: 0.01,
|
|
24
|
+
initialDelta: 1,
|
|
25
|
+
passive: false
|
|
26
|
+
}), new TurnWheelGesture({
|
|
27
|
+
name: 'panTurnWheel',
|
|
28
|
+
sensitivity: 0.5,
|
|
29
|
+
passive: false
|
|
30
|
+
}), new TapAndDragGesture({
|
|
31
|
+
name: 'zoomTapAndDrag',
|
|
32
|
+
dragThreshold: 10
|
|
33
|
+
}), new PressAndDragGesture({
|
|
34
|
+
name: 'zoomPressAndDrag',
|
|
35
|
+
dragThreshold: 10,
|
|
36
|
+
preventIf: ['zoomPinch']
|
|
37
|
+
}), new TapGesture({
|
|
38
|
+
name: 'zoomDoubleTapReset',
|
|
39
|
+
taps: 2
|
|
40
|
+
})]);
|
|
41
|
+
}, [instance]);
|
|
42
|
+
};
|