@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.
- package/BarChartPro/BarChartPro.js +1 -1
- package/BarChartPro/BarChartPro.mjs +2 -2
- package/CHANGELOG.md +100 -0
- package/ChartsDataProviderPro/ChartsDataProviderPro.js +2 -2
- package/ChartsDataProviderPro/ChartsDataProviderPro.mjs +2 -2
- package/FunnelChart/funnel.types.d.mts +1 -1
- package/FunnelChart/funnel.types.d.ts +1 -1
- package/LineChartPro/LineChartPro.js +1 -1
- package/LineChartPro/LineChartPro.mjs +2 -2
- package/PieChartPro/PieChartPro.js +1 -1
- package/PieChartPro/PieChartPro.mjs +2 -2
- package/RadarChartPro/RadarChartPro.js +1 -1
- package/RadarChartPro/RadarChartPro.mjs +2 -2
- package/ScatterChartPro/ScatterChartPro.js +8 -4
- package/ScatterChartPro/ScatterChartPro.mjs +9 -5
- 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/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/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 +3 -3
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
export declare const selectorZoomInteractionConfig: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & import("./useChartProZoom.types.js").UseChartProZoomState & Partial<{}> & {
|
|
2
2
|
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
3
|
-
}, interactionName: "wheel" | "pinch" | "tapAndDrag" | "doubleTapReset" | "brush") => (Omit<
|
|
3
|
+
}, interactionName: "wheel" | "pinch" | "tapAndDrag" | "doubleTapReset" | "brush") => (Omit<{
|
|
4
|
+
type: "wheel";
|
|
5
|
+
pointerMode?: any;
|
|
6
|
+
requiredKeys?: import("@mui/x-internal-gestures/core").KeyboardKey[] | undefined;
|
|
7
|
+
} | {
|
|
8
|
+
type: "pinch";
|
|
9
|
+
pointerMode?: any;
|
|
10
|
+
requiredKeys?: any[] | undefined;
|
|
11
|
+
} | {
|
|
12
|
+
type: "tapAndDrag";
|
|
13
|
+
pointerMode?: ("mouse" | "touch") | undefined;
|
|
14
|
+
requiredKeys?: import("@mui/x-internal-gestures/core").KeyboardKey[] | undefined;
|
|
15
|
+
} | {
|
|
16
|
+
type: "doubleTapReset";
|
|
17
|
+
pointerMode?: ("mouse" | "touch") | undefined;
|
|
18
|
+
requiredKeys?: import("@mui/x-internal-gestures/core").KeyboardKey[] | undefined;
|
|
19
|
+
} | {
|
|
20
|
+
type: "brush";
|
|
21
|
+
pointerMode?: ("mouse" | "touch") | undefined;
|
|
22
|
+
requiredKeys?: import("@mui/x-internal-gestures/core").KeyboardKey[] | undefined;
|
|
23
|
+
}, "pointerMode"> & {
|
|
4
24
|
mouse: {
|
|
5
25
|
requiredKeys?: import("@mui/x-internal-gestures/core").KeyboardKey[];
|
|
6
26
|
};
|
|
@@ -12,7 +32,20 @@ export declare const selectorZoomInteractionConfig: (args_0: import("@mui/x-char
|
|
|
12
32
|
}) | null;
|
|
13
33
|
export declare const selectorPanInteractionConfig: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & import("./useChartProZoom.types.js").UseChartProZoomState & Partial<{}> & {
|
|
14
34
|
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
15
|
-
}, interactionName: "wheel" | "drag" | "pressAndDrag") => (Omit<
|
|
35
|
+
}, interactionName: "wheel" | "drag" | "pressAndDrag") => (Omit<{
|
|
36
|
+
type: "drag";
|
|
37
|
+
pointerMode?: ("mouse" | "touch") | undefined;
|
|
38
|
+
requiredKeys?: import("@mui/x-internal-gestures/core").KeyboardKey[] | undefined;
|
|
39
|
+
} | {
|
|
40
|
+
type: "pressAndDrag";
|
|
41
|
+
pointerMode?: ("mouse" | "touch") | undefined;
|
|
42
|
+
requiredKeys?: import("@mui/x-internal-gestures/core").KeyboardKey[] | undefined;
|
|
43
|
+
} | {
|
|
44
|
+
type: "wheel";
|
|
45
|
+
allowedDirection?: "x" | "y" | "xy" | undefined;
|
|
46
|
+
pointerMode?: any;
|
|
47
|
+
requiredKeys?: import("@mui/x-internal-gestures/core").KeyboardKey[] | undefined;
|
|
48
|
+
}, "pointerMode"> & {
|
|
16
49
|
mouse: {
|
|
17
50
|
requiredKeys?: import("@mui/x-internal-gestures/core").KeyboardKey[];
|
|
18
51
|
};
|
|
@@ -21,5 +54,4 @@ export declare const selectorPanInteractionConfig: (args_0: import("@mui/x-chart
|
|
|
21
54
|
};
|
|
22
55
|
pointerMode?: import("@mui/x-internal-gestures/core").PointerMode[];
|
|
23
56
|
allowedDirection?: "x" | "y" | "xy";
|
|
24
|
-
}) | null;
|
|
25
|
-
export declare const selectorIsZoomBrushEnabled: (args_0: {}, zoomInteractionConfig: any) => any;
|
|
57
|
+
}) | null;
|
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.selectorZoomInteractionConfig = exports.selectorPanInteractionConfig =
|
|
6
|
+
exports.selectorZoomInteractionConfig = exports.selectorPanInteractionConfig = void 0;
|
|
7
7
|
var _store = require("@mui/x-internals/store");
|
|
8
|
-
var _internals = require("@mui/x-charts/internals");
|
|
9
8
|
var _useChartProZoom = require("./useChartProZoom.selectors");
|
|
10
9
|
const selectorZoomInteractionConfig = exports.selectorZoomInteractionConfig = (0, _store.createSelector)(_useChartProZoom.selectorChartZoomState, (zoomState, interactionName) => zoomState.zoomInteractionConfig.zoom[interactionName] ?? null);
|
|
11
|
-
const selectorPanInteractionConfig = exports.selectorPanInteractionConfig = (0, _store.createSelector)(_useChartProZoom.selectorChartZoomState, (zoomState, interactionName) => zoomState.zoomInteractionConfig.pan[interactionName] ?? null);
|
|
12
|
-
const selectorIsZoomBrushEnabled = exports.selectorIsZoomBrushEnabled = (0, _store.createSelector)(_internals.selectorChartZoomOptionsLookup, state => selectorZoomInteractionConfig(state, 'brush'), (zoomOptions, zoomInteractionConfig) => Object.keys(zoomOptions).length > 0 && zoomInteractionConfig || false);
|
|
10
|
+
const selectorPanInteractionConfig = exports.selectorPanInteractionConfig = (0, _store.createSelector)(_useChartProZoom.selectorChartZoomState, (zoomState, interactionName) => zoomState.zoomInteractionConfig.pan[interactionName] ?? null);
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { createSelector } from '@mui/x-internals/store';
|
|
2
|
-
import { selectorChartZoomOptionsLookup } from '@mui/x-charts/internals';
|
|
3
2
|
import { selectorChartZoomState } from "./useChartProZoom.selectors.mjs";
|
|
4
3
|
export const selectorZoomInteractionConfig = createSelector(selectorChartZoomState, (zoomState, interactionName) => zoomState.zoomInteractionConfig.zoom[interactionName] ?? null);
|
|
5
|
-
export const selectorPanInteractionConfig = createSelector(selectorChartZoomState, (zoomState, interactionName) => zoomState.zoomInteractionConfig.pan[interactionName] ?? null);
|
|
6
|
-
export const selectorIsZoomBrushEnabled = createSelector(selectorChartZoomOptionsLookup, state => selectorZoomInteractionConfig(state, 'brush'), (zoomOptions, zoomInteractionConfig) => Object.keys(zoomOptions).length > 0 && zoomInteractionConfig || false);
|
|
4
|
+
export const selectorPanInteractionConfig = createSelector(selectorChartZoomState, (zoomState, interactionName) => zoomState.zoomInteractionConfig.pan[interactionName] ?? null);
|
|
@@ -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 = {
|
|
@@ -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
|
};
|