@mui/x-charts-pro 9.3.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 +33 -3
- package/BarChartPro/BarChartPro.mjs +34 -4
- package/CHANGELOG.md +296 -0
- package/ChartsDataProviderPro/ChartsDataProviderPro.js +2 -2
- package/ChartsDataProviderPro/ChartsDataProviderPro.mjs +2 -2
- package/ChartsToolbarPro/ChartsToolbarImageExportTrigger.js +1 -0
- package/ChartsToolbarPro/ChartsToolbarImageExportTrigger.mjs +1 -0
- package/ChartsToolbarPro/ChartsToolbarPro.d.mts +1 -1
- package/ChartsToolbarPro/ChartsToolbarPro.d.ts +1 -1
- package/ChartsToolbarPro/ChartsToolbarRangeButtonTrigger.d.mts +1 -1
- package/ChartsToolbarPro/ChartsToolbarRangeButtonTrigger.d.ts +1 -1
- package/ChartsToolbarPro/ChartsToolbarRangeButtonTrigger.js +35 -38
- package/ChartsToolbarPro/ChartsToolbarRangeButtonTrigger.mjs +37 -40
- package/ChartsToolbarPro/Toolbar.types.d.mts +3 -2
- package/ChartsToolbarPro/Toolbar.types.d.ts +3 -2
- package/ChartsToolbarPro/rangeButtonValueToZoom.d.mts +18 -2
- package/ChartsToolbarPro/rangeButtonValueToZoom.d.ts +18 -2
- package/ChartsToolbarPro/rangeButtonValueToZoom.js +73 -10
- package/ChartsToolbarPro/rangeButtonValueToZoom.mjs +72 -10
- package/ChartsZoomSlider/internals/chartsAxisZoomSliderThumbClasses.js +9 -2
- package/ChartsZoomSlider/internals/chartsAxisZoomSliderThumbClasses.mjs +9 -2
- package/ChartsZoomSlider/internals/previews/ScatterPreviewPlot.js +2 -1
- package/ChartsZoomSlider/internals/previews/ScatterPreviewPlot.mjs +2 -1
- package/FunnelChart/funnel.types.d.mts +1 -1
- package/FunnelChart/funnel.types.d.ts +1 -1
- package/FunnelChart/funnelPlotSlots.types.d.mts +5 -4
- package/FunnelChart/funnelPlotSlots.types.d.ts +5 -4
- package/Heatmap/Heatmap.d.mts +3 -2
- package/Heatmap/Heatmap.d.ts +3 -2
- package/Heatmap/Heatmap.js +32 -2
- package/Heatmap/Heatmap.mjs +32 -2
- package/Heatmap/HeatmapItem.d.mts +3 -2
- package/Heatmap/HeatmapItem.d.ts +3 -2
- package/Heatmap/HeatmapItem.js +2 -0
- package/Heatmap/HeatmapItem.mjs +2 -0
- package/Heatmap/HeatmapTooltip/HeatmapTooltip.types.d.mts +3 -2
- package/Heatmap/HeatmapTooltip/HeatmapTooltip.types.d.ts +3 -2
- package/LineChartPro/LineChartPro.js +33 -3
- package/LineChartPro/LineChartPro.mjs +34 -4
- 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.d.mts +2 -1
- package/ScatterChartPro/ScatterChartPro.d.ts +2 -1
- package/ScatterChartPro/ScatterChartPro.js +40 -6
- package/ScatterChartPro/ScatterChartPro.mjs +41 -7
- 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/useChartProExport/exportImage.js +8 -2
- package/internals/plugins/useChartProExport/exportImage.mjs +8 -2
- package/internals/plugins/useChartProExport/print.js +1 -0
- package/internals/plugins/useChartProExport/print.mjs +1 -0
- package/internals/plugins/useChartProExport/useChartProExport.types.d.mts +6 -0
- package/internals/plugins/useChartProExport/useChartProExport.types.d.ts +6 -0
- 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/useChartProZoom/useChartProZoom.js +77 -14
- package/internals/plugins/useChartProZoom/useChartProZoom.mjs +79 -15
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.mts +0 -3
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +0 -3
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +1 -2
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.mjs +0 -1
- package/internals/plugins/useChartProZoom/useChartProZoom.types.d.mts +28 -11
- package/internals/plugins/useChartProZoom/useChartProZoom.types.d.ts +28 -11
- 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/internals/slots/chartsBaseSlots.d.mts +6 -5
- package/internals/slots/chartsBaseSlots.d.ts +6 -5
- package/internals/slots/chartsIconSlots.d.mts +4 -3
- package/internals/slots/chartsIconSlots.d.ts +4 -3
- package/models/chartsSlotsComponentsPropsPro.d.mts +11 -0
- package/models/chartsSlotsComponentsPropsPro.d.ts +11 -0
- package/models/chartsSlotsComponentsPropsPro.js +5 -0
- package/models/chartsSlotsComponentsPropsPro.mjs +1 -0
- package/models/index.d.mts +1 -0
- package/models/index.d.ts +1 -0
- package/models/index.js +12 -0
- package/models/index.mjs +1 -0
- package/models/seriesType/heatmap.d.mts +1 -1
- package/models/seriesType/heatmap.d.ts +1 -1
- package/package.json +5 -5
|
@@ -1,11 +1,38 @@
|
|
|
1
1
|
import { type UseChartSeriesSignature, type ChartPluginSignature, type UseChartCartesianAxisSignature, type UseChartCartesianAxisDefaultizedParameters, type ZoomData, type AxisId, type UseChartBrushSignature } from '@mui/x-charts/internals';
|
|
2
2
|
import { type ZoomInteractionConfig, type DefaultizedZoomInteractionConfig } from "./ZoomInteractionConfig.types.js";
|
|
3
|
+
import { type RangeButtonValue } from "../../../ChartsToolbarPro/rangeButtonValueToZoom.js";
|
|
4
|
+
/**
|
|
5
|
+
* Initializes the zoom of an axis with a range value instead of zoom percentages.
|
|
6
|
+
*/
|
|
7
|
+
export interface InitialZoomRange {
|
|
8
|
+
/**
|
|
9
|
+
* The id of the axis to apply the zoom to.
|
|
10
|
+
*/
|
|
11
|
+
axisId: AxisId;
|
|
12
|
+
/**
|
|
13
|
+
* The range to zoom to. Accepts the same values as a range button:
|
|
14
|
+
*
|
|
15
|
+
* - `{ unit, step }` — A calendar interval from the end of the data.
|
|
16
|
+
* - `[start, end]` — An absolute date range, or a range between two ordinal axis values.
|
|
17
|
+
* - `(params) => { start, end }` — A function returning zoom percentages (0-100).
|
|
18
|
+
* - `null` — Shows all data.
|
|
19
|
+
*/
|
|
20
|
+
value: RangeButtonValue;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* An entry of the `initialZoom` prop. Either explicit zoom percentages ({@link ZoomData})
|
|
24
|
+
* or a range value resolved against the axis ({@link InitialZoomRange}).
|
|
25
|
+
*/
|
|
26
|
+
export type InitialZoom = ZoomData | InitialZoomRange;
|
|
3
27
|
export interface UseChartProZoomParameters {
|
|
4
28
|
/**
|
|
5
29
|
* The list of zoom data related to each axis.
|
|
6
30
|
* Used to initialize the zoom in a specific configuration without controlling it.
|
|
31
|
+
*
|
|
32
|
+
* Each entry is either explicit zoom percentages (`{ axisId, start, end }`) or a
|
|
33
|
+
* range value (`{ axisId, value }`) resolved against the axis domain.
|
|
7
34
|
*/
|
|
8
|
-
initialZoom?: readonly
|
|
35
|
+
initialZoom?: readonly InitialZoom[];
|
|
9
36
|
/**
|
|
10
37
|
* Callback fired when the zoom has changed.
|
|
11
38
|
*
|
|
@@ -41,11 +68,6 @@ export interface UseChartProZoomState {
|
|
|
41
68
|
* Configuration for zoom interactions.
|
|
42
69
|
*/
|
|
43
70
|
zoomInteractionConfig: DefaultizedZoomInteractionConfig;
|
|
44
|
-
/**
|
|
45
|
-
* The key of the currently active range button, or `null` if no range button is active.
|
|
46
|
-
* Cleared when the user manually zooms or pans the chart.
|
|
47
|
-
*/
|
|
48
|
-
activeRangeButtonKey: string | null;
|
|
49
71
|
};
|
|
50
72
|
}
|
|
51
73
|
export interface UseChartProZoomPublicApi {
|
|
@@ -78,11 +100,6 @@ export interface UseChartProZoomInstance extends UseChartProZoomPublicApi {
|
|
|
78
100
|
* Zoom out the chart.
|
|
79
101
|
*/
|
|
80
102
|
zoomOut: () => void;
|
|
81
|
-
/**
|
|
82
|
-
* Set the active range button key. Pass `null` to clear.
|
|
83
|
-
* @param {string | null} key The key of the active range button.
|
|
84
|
-
*/
|
|
85
|
-
setActiveRangeButtonKey: (key: string | null) => void;
|
|
86
103
|
}
|
|
87
104
|
export type UseChartProZoomSignature = ChartPluginSignature<{
|
|
88
105
|
params: UseChartProZoomParameters;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { useDragGesture, type UseDragGestureOptions } from "./useDragGesture.mjs";
|
|
2
|
+
export { useDragOnPressGesture, type UseDragOnPressGestureOptions } from "./useDragOnPressGesture.mjs";
|
|
3
|
+
export { useWheelGesture, type UseWheelGestureOptions } from "./useWheelGesture.mjs";
|
|
4
|
+
export { usePinchGesture, type UsePinchGestureOptions } from "./usePinchGesture.mjs";
|
|
5
|
+
export type { GestureInstance, PanGestureConfig, ChartPoint } from "./zoomGestures.types.mjs";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { useDragGesture, type UseDragGestureOptions } from "./useDragGesture.js";
|
|
2
|
+
export { useDragOnPressGesture, type UseDragOnPressGestureOptions } from "./useDragOnPressGesture.js";
|
|
3
|
+
export { useWheelGesture, type UseWheelGestureOptions } from "./useWheelGesture.js";
|
|
4
|
+
export { usePinchGesture, type UsePinchGestureOptions } from "./usePinchGesture.js";
|
|
5
|
+
export type { GestureInstance, PanGestureConfig, ChartPoint } from "./zoomGestures.types.js";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "useDragGesture", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _useDragGesture.useDragGesture;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "useDragOnPressGesture", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _useDragOnPressGesture.useDragOnPressGesture;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "usePinchGesture", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _usePinchGesture.usePinchGesture;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "useWheelGesture", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _useWheelGesture.useWheelGesture;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
var _useDragGesture = require("./useDragGesture");
|
|
31
|
+
var _useDragOnPressGesture = require("./useDragOnPressGesture");
|
|
32
|
+
var _useWheelGesture = require("./useWheelGesture");
|
|
33
|
+
var _usePinchGesture = require("./usePinchGesture");
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type PanEvent } from '@mui/x-internal-gestures/core';
|
|
2
|
+
import { type ChartPoint, type GestureInstance, type PanGestureConfig } from "./zoomGestures.types.mjs";
|
|
3
|
+
export interface UseDragGestureOptions {
|
|
4
|
+
/** Whether the gesture is active. */
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
/** Pointer and keyboard gating for the gesture. */
|
|
7
|
+
config?: PanGestureConfig;
|
|
8
|
+
/**
|
|
9
|
+
* Called when the drag starts.
|
|
10
|
+
* @param {PanEvent} event The pan start event.
|
|
11
|
+
*/
|
|
12
|
+
onPanStart?: (event: PanEvent) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Called (rAF-throttled) on each drag update.
|
|
15
|
+
* @param {ChartPoint} delta The pixel delta since the last call.
|
|
16
|
+
* @param {PanEvent} event The pan event.
|
|
17
|
+
*/
|
|
18
|
+
onPan: (delta: ChartPoint, event: PanEvent) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Called when the drag ends.
|
|
21
|
+
* @param {PanEvent} event The pan end event.
|
|
22
|
+
*/
|
|
23
|
+
onPanEnd?: (event: PanEvent) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Generic drag-to-pan gesture binding.
|
|
27
|
+
*
|
|
28
|
+
* It owns the listener lifecycle, and lets you create your own interactions by providing the delta change of the interaction.
|
|
29
|
+
*/
|
|
30
|
+
export declare function useDragGesture(instance: GestureInstance, options: UseDragGestureOptions): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type PanEvent } from '@mui/x-internal-gestures/core';
|
|
2
|
+
import { type ChartPoint, type GestureInstance, type PanGestureConfig } from "./zoomGestures.types.js";
|
|
3
|
+
export interface UseDragGestureOptions {
|
|
4
|
+
/** Whether the gesture is active. */
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
/** Pointer and keyboard gating for the gesture. */
|
|
7
|
+
config?: PanGestureConfig;
|
|
8
|
+
/**
|
|
9
|
+
* Called when the drag starts.
|
|
10
|
+
* @param {PanEvent} event The pan start event.
|
|
11
|
+
*/
|
|
12
|
+
onPanStart?: (event: PanEvent) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Called (rAF-throttled) on each drag update.
|
|
15
|
+
* @param {ChartPoint} delta The pixel delta since the last call.
|
|
16
|
+
* @param {PanEvent} event The pan event.
|
|
17
|
+
*/
|
|
18
|
+
onPan: (delta: ChartPoint, event: PanEvent) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Called when the drag ends.
|
|
21
|
+
* @param {PanEvent} event The pan end event.
|
|
22
|
+
*/
|
|
23
|
+
onPanEnd?: (event: PanEvent) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Generic drag-to-pan gesture binding.
|
|
27
|
+
*
|
|
28
|
+
* It owns the listener lifecycle, and lets you create your own interactions by providing the delta change of the interaction.
|
|
29
|
+
*/
|
|
30
|
+
export declare function useDragGesture(instance: GestureInstance, options: UseDragGestureOptions): void;
|
|
@@ -0,0 +1,105 @@
|
|
|
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.useDragGesture = useDragGesture;
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _rafThrottle = require("@mui/x-internals/rafThrottle");
|
|
11
|
+
/**
|
|
12
|
+
* Generic drag-to-pan gesture binding.
|
|
13
|
+
*
|
|
14
|
+
* It owns the listener lifecycle, and lets you create your own interactions by providing the delta change of the interaction.
|
|
15
|
+
*/
|
|
16
|
+
function useDragGesture(instance, options) {
|
|
17
|
+
const {
|
|
18
|
+
enabled,
|
|
19
|
+
config,
|
|
20
|
+
onPanStart,
|
|
21
|
+
onPan,
|
|
22
|
+
onPanEnd
|
|
23
|
+
} = options;
|
|
24
|
+
const {
|
|
25
|
+
chartsLayerContainerRef
|
|
26
|
+
} = instance;
|
|
27
|
+
|
|
28
|
+
// Keep the latest handlers in a ref so changing them doesn't rebind listeners.
|
|
29
|
+
const handlersRef = React.useRef({
|
|
30
|
+
onPanStart,
|
|
31
|
+
onPan,
|
|
32
|
+
onPanEnd
|
|
33
|
+
});
|
|
34
|
+
React.useEffect(() => {
|
|
35
|
+
handlersRef.current = {
|
|
36
|
+
onPanStart,
|
|
37
|
+
onPan,
|
|
38
|
+
onPanEnd
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
if (!enabled) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
instance.updateZoomInteractionListeners('zoomPan', {
|
|
46
|
+
requiredKeys: config?.requiredKeys,
|
|
47
|
+
pointerMode: config?.pointerMode,
|
|
48
|
+
pointerOptions: {
|
|
49
|
+
mouse: config?.mouse,
|
|
50
|
+
touch: config?.touch
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}, [enabled, config, instance]);
|
|
54
|
+
React.useEffect(() => {
|
|
55
|
+
const element = chartsLayerContainerRef.current;
|
|
56
|
+
if (element === null || !enabled) {
|
|
57
|
+
return () => {};
|
|
58
|
+
}
|
|
59
|
+
let isInteracting = false;
|
|
60
|
+
let lastEvent = null;
|
|
61
|
+
const accumulated = {
|
|
62
|
+
x: 0,
|
|
63
|
+
y: 0
|
|
64
|
+
};
|
|
65
|
+
const handlePanStart = event => {
|
|
66
|
+
if (!event.detail.target?.closest('[data-charts-zoom-slider]')) {
|
|
67
|
+
isInteracting = true;
|
|
68
|
+
handlersRef.current.onPanStart?.(event);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const handlePanEnd = event => {
|
|
72
|
+
isInteracting = false;
|
|
73
|
+
handlersRef.current.onPanEnd?.(event);
|
|
74
|
+
};
|
|
75
|
+
const throttled = (0, _rafThrottle.rafThrottle)(() => {
|
|
76
|
+
const delta = {
|
|
77
|
+
x: accumulated.x,
|
|
78
|
+
y: accumulated.y
|
|
79
|
+
};
|
|
80
|
+
accumulated.x = 0;
|
|
81
|
+
accumulated.y = 0;
|
|
82
|
+
if (lastEvent) {
|
|
83
|
+
handlersRef.current.onPan(delta, lastEvent);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const handlePan = event => {
|
|
87
|
+
if (!isInteracting) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
lastEvent = event;
|
|
91
|
+
accumulated.x += event.detail.deltaX;
|
|
92
|
+
accumulated.y += event.detail.deltaY;
|
|
93
|
+
throttled();
|
|
94
|
+
};
|
|
95
|
+
const panHandler = instance.addInteractionListener('zoomPan', handlePan);
|
|
96
|
+
const panStartHandler = instance.addInteractionListener('zoomPanStart', handlePanStart);
|
|
97
|
+
const panEndHandler = instance.addInteractionListener('zoomPanEnd', handlePanEnd);
|
|
98
|
+
return () => {
|
|
99
|
+
panHandler.cleanup();
|
|
100
|
+
panStartHandler.cleanup();
|
|
101
|
+
panEndHandler.cleanup();
|
|
102
|
+
throttled.clear();
|
|
103
|
+
};
|
|
104
|
+
}, [instance, chartsLayerContainerRef, enabled]);
|
|
105
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { rafThrottle } from '@mui/x-internals/rafThrottle';
|
|
5
|
+
/**
|
|
6
|
+
* Generic drag-to-pan gesture binding.
|
|
7
|
+
*
|
|
8
|
+
* It owns the listener lifecycle, and lets you create your own interactions by providing the delta change of the interaction.
|
|
9
|
+
*/
|
|
10
|
+
export function useDragGesture(instance, options) {
|
|
11
|
+
const {
|
|
12
|
+
enabled,
|
|
13
|
+
config,
|
|
14
|
+
onPanStart,
|
|
15
|
+
onPan,
|
|
16
|
+
onPanEnd
|
|
17
|
+
} = options;
|
|
18
|
+
const {
|
|
19
|
+
chartsLayerContainerRef
|
|
20
|
+
} = instance;
|
|
21
|
+
|
|
22
|
+
// Keep the latest handlers in a ref so changing them doesn't rebind listeners.
|
|
23
|
+
const handlersRef = React.useRef({
|
|
24
|
+
onPanStart,
|
|
25
|
+
onPan,
|
|
26
|
+
onPanEnd
|
|
27
|
+
});
|
|
28
|
+
React.useEffect(() => {
|
|
29
|
+
handlersRef.current = {
|
|
30
|
+
onPanStart,
|
|
31
|
+
onPan,
|
|
32
|
+
onPanEnd
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
React.useEffect(() => {
|
|
36
|
+
if (!enabled) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
instance.updateZoomInteractionListeners('zoomPan', {
|
|
40
|
+
requiredKeys: config?.requiredKeys,
|
|
41
|
+
pointerMode: config?.pointerMode,
|
|
42
|
+
pointerOptions: {
|
|
43
|
+
mouse: config?.mouse,
|
|
44
|
+
touch: config?.touch
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}, [enabled, config, instance]);
|
|
48
|
+
React.useEffect(() => {
|
|
49
|
+
const element = chartsLayerContainerRef.current;
|
|
50
|
+
if (element === null || !enabled) {
|
|
51
|
+
return () => {};
|
|
52
|
+
}
|
|
53
|
+
let isInteracting = false;
|
|
54
|
+
let lastEvent = null;
|
|
55
|
+
const accumulated = {
|
|
56
|
+
x: 0,
|
|
57
|
+
y: 0
|
|
58
|
+
};
|
|
59
|
+
const handlePanStart = event => {
|
|
60
|
+
if (!event.detail.target?.closest('[data-charts-zoom-slider]')) {
|
|
61
|
+
isInteracting = true;
|
|
62
|
+
handlersRef.current.onPanStart?.(event);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const handlePanEnd = event => {
|
|
66
|
+
isInteracting = false;
|
|
67
|
+
handlersRef.current.onPanEnd?.(event);
|
|
68
|
+
};
|
|
69
|
+
const throttled = rafThrottle(() => {
|
|
70
|
+
const delta = {
|
|
71
|
+
x: accumulated.x,
|
|
72
|
+
y: accumulated.y
|
|
73
|
+
};
|
|
74
|
+
accumulated.x = 0;
|
|
75
|
+
accumulated.y = 0;
|
|
76
|
+
if (lastEvent) {
|
|
77
|
+
handlersRef.current.onPan(delta, lastEvent);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
const handlePan = event => {
|
|
81
|
+
if (!isInteracting) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
lastEvent = event;
|
|
85
|
+
accumulated.x += event.detail.deltaX;
|
|
86
|
+
accumulated.y += event.detail.deltaY;
|
|
87
|
+
throttled();
|
|
88
|
+
};
|
|
89
|
+
const panHandler = instance.addInteractionListener('zoomPan', handlePan);
|
|
90
|
+
const panStartHandler = instance.addInteractionListener('zoomPanStart', handlePanStart);
|
|
91
|
+
const panEndHandler = instance.addInteractionListener('zoomPanEnd', handlePanEnd);
|
|
92
|
+
return () => {
|
|
93
|
+
panHandler.cleanup();
|
|
94
|
+
panStartHandler.cleanup();
|
|
95
|
+
panEndHandler.cleanup();
|
|
96
|
+
throttled.clear();
|
|
97
|
+
};
|
|
98
|
+
}, [instance, chartsLayerContainerRef, enabled]);
|
|
99
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { PanEvent } from '@mui/x-internal-gestures/core';
|
|
2
|
+
import type { ChartPoint, GestureInstance, PanGestureConfig } from "./zoomGestures.types.mjs";
|
|
3
|
+
export interface UseDragOnPressGestureOptions {
|
|
4
|
+
/** Whether the gesture is active. */
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
/** Pointer and keyboard gating for the gesture. */
|
|
7
|
+
config?: PanGestureConfig;
|
|
8
|
+
/**
|
|
9
|
+
* Called when the drag starts.
|
|
10
|
+
* @param {PanEvent} event The pan start event.
|
|
11
|
+
*/
|
|
12
|
+
onPanStart?: (event: PanEvent) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Called (rAF-throttled) on each drag update.
|
|
15
|
+
* @param {ChartPoint} delta The pixel delta since the last call.
|
|
16
|
+
* @param {PanEvent} event The pan event.
|
|
17
|
+
*/
|
|
18
|
+
onPan: (delta: ChartPoint, event: PanEvent) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Called when the drag ends.
|
|
21
|
+
* @param {PanEvent} event The pan end event.
|
|
22
|
+
*/
|
|
23
|
+
onPanEnd?: (event: PanEvent) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Generic press-and-drag-to-pan gesture binding.
|
|
27
|
+
*
|
|
28
|
+
* It owns the listener lifecycle, and lets you create your own interactions by providing the delta change of the interaction.
|
|
29
|
+
*/
|
|
30
|
+
export declare function useDragOnPressGesture(instance: GestureInstance, options: UseDragOnPressGestureOptions): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { PanEvent } from '@mui/x-internal-gestures/core';
|
|
2
|
+
import type { ChartPoint, GestureInstance, PanGestureConfig } from "./zoomGestures.types.js";
|
|
3
|
+
export interface UseDragOnPressGestureOptions {
|
|
4
|
+
/** Whether the gesture is active. */
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
/** Pointer and keyboard gating for the gesture. */
|
|
7
|
+
config?: PanGestureConfig;
|
|
8
|
+
/**
|
|
9
|
+
* Called when the drag starts.
|
|
10
|
+
* @param {PanEvent} event The pan start event.
|
|
11
|
+
*/
|
|
12
|
+
onPanStart?: (event: PanEvent) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Called (rAF-throttled) on each drag update.
|
|
15
|
+
* @param {ChartPoint} delta The pixel delta since the last call.
|
|
16
|
+
* @param {PanEvent} event The pan event.
|
|
17
|
+
*/
|
|
18
|
+
onPan: (delta: ChartPoint, event: PanEvent) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Called when the drag ends.
|
|
21
|
+
* @param {PanEvent} event The pan end event.
|
|
22
|
+
*/
|
|
23
|
+
onPanEnd?: (event: PanEvent) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Generic press-and-drag-to-pan gesture binding.
|
|
27
|
+
*
|
|
28
|
+
* It owns the listener lifecycle, and lets you create your own interactions by providing the delta change of the interaction.
|
|
29
|
+
*/
|
|
30
|
+
export declare function useDragOnPressGesture(instance: GestureInstance, options: UseDragOnPressGestureOptions): void;
|
|
@@ -0,0 +1,105 @@
|
|
|
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.useDragOnPressGesture = useDragOnPressGesture;
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _rafThrottle = require("@mui/x-internals/rafThrottle");
|
|
11
|
+
/**
|
|
12
|
+
* Generic press-and-drag-to-pan gesture binding.
|
|
13
|
+
*
|
|
14
|
+
* It owns the listener lifecycle, and lets you create your own interactions by providing the delta change of the interaction.
|
|
15
|
+
*/
|
|
16
|
+
function useDragOnPressGesture(instance, options) {
|
|
17
|
+
const {
|
|
18
|
+
enabled,
|
|
19
|
+
config,
|
|
20
|
+
onPanStart,
|
|
21
|
+
onPan,
|
|
22
|
+
onPanEnd
|
|
23
|
+
} = options;
|
|
24
|
+
const {
|
|
25
|
+
chartsLayerContainerRef
|
|
26
|
+
} = instance;
|
|
27
|
+
|
|
28
|
+
// Keep the latest handlers in a ref so changing them doesn't rebind listeners.
|
|
29
|
+
const handlersRef = React.useRef({
|
|
30
|
+
onPanStart,
|
|
31
|
+
onPan,
|
|
32
|
+
onPanEnd
|
|
33
|
+
});
|
|
34
|
+
React.useEffect(() => {
|
|
35
|
+
handlersRef.current = {
|
|
36
|
+
onPanStart,
|
|
37
|
+
onPan,
|
|
38
|
+
onPanEnd
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
if (!enabled) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
instance.updateZoomInteractionListeners('zoomPressAndDrag', {
|
|
46
|
+
requiredKeys: config?.requiredKeys,
|
|
47
|
+
pointerMode: config?.pointerMode,
|
|
48
|
+
pointerOptions: {
|
|
49
|
+
mouse: config?.mouse,
|
|
50
|
+
touch: config?.touch
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}, [enabled, config, instance]);
|
|
54
|
+
React.useEffect(() => {
|
|
55
|
+
const element = chartsLayerContainerRef.current;
|
|
56
|
+
if (element === null || !enabled) {
|
|
57
|
+
return () => {};
|
|
58
|
+
}
|
|
59
|
+
let isInteracting = false;
|
|
60
|
+
let lastEvent = null;
|
|
61
|
+
const accumulated = {
|
|
62
|
+
x: 0,
|
|
63
|
+
y: 0
|
|
64
|
+
};
|
|
65
|
+
const handlePanStart = event => {
|
|
66
|
+
if (!event.detail.target?.closest('[data-charts-zoom-slider]')) {
|
|
67
|
+
isInteracting = true;
|
|
68
|
+
handlersRef.current.onPanStart?.(event);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const handlePanEnd = event => {
|
|
72
|
+
isInteracting = false;
|
|
73
|
+
handlersRef.current.onPanEnd?.(event);
|
|
74
|
+
};
|
|
75
|
+
const throttled = (0, _rafThrottle.rafThrottle)(() => {
|
|
76
|
+
const delta = {
|
|
77
|
+
x: accumulated.x,
|
|
78
|
+
y: accumulated.y
|
|
79
|
+
};
|
|
80
|
+
accumulated.x = 0;
|
|
81
|
+
accumulated.y = 0;
|
|
82
|
+
if (lastEvent) {
|
|
83
|
+
handlersRef.current.onPan(delta, lastEvent);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const handlePan = event => {
|
|
87
|
+
if (!isInteracting) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
lastEvent = event;
|
|
91
|
+
accumulated.x += event.detail.deltaX;
|
|
92
|
+
accumulated.y += event.detail.deltaY;
|
|
93
|
+
throttled();
|
|
94
|
+
};
|
|
95
|
+
const panHandler = instance.addInteractionListener('zoomPressAndDrag', handlePan);
|
|
96
|
+
const panStartHandler = instance.addInteractionListener('zoomPressAndDragStart', handlePanStart);
|
|
97
|
+
const panEndHandler = instance.addInteractionListener('zoomPressAndDragEnd', handlePanEnd);
|
|
98
|
+
return () => {
|
|
99
|
+
panHandler.cleanup();
|
|
100
|
+
panStartHandler.cleanup();
|
|
101
|
+
panEndHandler.cleanup();
|
|
102
|
+
throttled.clear();
|
|
103
|
+
};
|
|
104
|
+
}, [instance, chartsLayerContainerRef, enabled]);
|
|
105
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { rafThrottle } from '@mui/x-internals/rafThrottle';
|
|
5
|
+
/**
|
|
6
|
+
* Generic press-and-drag-to-pan gesture binding.
|
|
7
|
+
*
|
|
8
|
+
* It owns the listener lifecycle, and lets you create your own interactions by providing the delta change of the interaction.
|
|
9
|
+
*/
|
|
10
|
+
export function useDragOnPressGesture(instance, options) {
|
|
11
|
+
const {
|
|
12
|
+
enabled,
|
|
13
|
+
config,
|
|
14
|
+
onPanStart,
|
|
15
|
+
onPan,
|
|
16
|
+
onPanEnd
|
|
17
|
+
} = options;
|
|
18
|
+
const {
|
|
19
|
+
chartsLayerContainerRef
|
|
20
|
+
} = instance;
|
|
21
|
+
|
|
22
|
+
// Keep the latest handlers in a ref so changing them doesn't rebind listeners.
|
|
23
|
+
const handlersRef = React.useRef({
|
|
24
|
+
onPanStart,
|
|
25
|
+
onPan,
|
|
26
|
+
onPanEnd
|
|
27
|
+
});
|
|
28
|
+
React.useEffect(() => {
|
|
29
|
+
handlersRef.current = {
|
|
30
|
+
onPanStart,
|
|
31
|
+
onPan,
|
|
32
|
+
onPanEnd
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
React.useEffect(() => {
|
|
36
|
+
if (!enabled) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
instance.updateZoomInteractionListeners('zoomPressAndDrag', {
|
|
40
|
+
requiredKeys: config?.requiredKeys,
|
|
41
|
+
pointerMode: config?.pointerMode,
|
|
42
|
+
pointerOptions: {
|
|
43
|
+
mouse: config?.mouse,
|
|
44
|
+
touch: config?.touch
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}, [enabled, config, instance]);
|
|
48
|
+
React.useEffect(() => {
|
|
49
|
+
const element = chartsLayerContainerRef.current;
|
|
50
|
+
if (element === null || !enabled) {
|
|
51
|
+
return () => {};
|
|
52
|
+
}
|
|
53
|
+
let isInteracting = false;
|
|
54
|
+
let lastEvent = null;
|
|
55
|
+
const accumulated = {
|
|
56
|
+
x: 0,
|
|
57
|
+
y: 0
|
|
58
|
+
};
|
|
59
|
+
const handlePanStart = event => {
|
|
60
|
+
if (!event.detail.target?.closest('[data-charts-zoom-slider]')) {
|
|
61
|
+
isInteracting = true;
|
|
62
|
+
handlersRef.current.onPanStart?.(event);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const handlePanEnd = event => {
|
|
66
|
+
isInteracting = false;
|
|
67
|
+
handlersRef.current.onPanEnd?.(event);
|
|
68
|
+
};
|
|
69
|
+
const throttled = rafThrottle(() => {
|
|
70
|
+
const delta = {
|
|
71
|
+
x: accumulated.x,
|
|
72
|
+
y: accumulated.y
|
|
73
|
+
};
|
|
74
|
+
accumulated.x = 0;
|
|
75
|
+
accumulated.y = 0;
|
|
76
|
+
if (lastEvent) {
|
|
77
|
+
handlersRef.current.onPan(delta, lastEvent);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
const handlePan = event => {
|
|
81
|
+
if (!isInteracting) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
lastEvent = event;
|
|
85
|
+
accumulated.x += event.detail.deltaX;
|
|
86
|
+
accumulated.y += event.detail.deltaY;
|
|
87
|
+
throttled();
|
|
88
|
+
};
|
|
89
|
+
const panHandler = instance.addInteractionListener('zoomPressAndDrag', handlePan);
|
|
90
|
+
const panStartHandler = instance.addInteractionListener('zoomPressAndDragStart', handlePanStart);
|
|
91
|
+
const panEndHandler = instance.addInteractionListener('zoomPressAndDragEnd', handlePanEnd);
|
|
92
|
+
return () => {
|
|
93
|
+
panHandler.cleanup();
|
|
94
|
+
panStartHandler.cleanup();
|
|
95
|
+
panEndHandler.cleanup();
|
|
96
|
+
throttled.clear();
|
|
97
|
+
};
|
|
98
|
+
}, [instance, chartsLayerContainerRef, enabled]);
|
|
99
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { KeyboardKey } from '@mui/x-internal-gestures/core';
|
|
2
|
+
import type { ChartPoint, GestureInstance } from "./zoomGestures.types.mjs";
|
|
3
|
+
export interface UsePinchGestureOptions {
|
|
4
|
+
/** Whether the gesture is active. */
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
/** Keys that must be held for the pinch to trigger the gesture. */
|
|
7
|
+
requiredKeys?: KeyboardKey[];
|
|
8
|
+
/**
|
|
9
|
+
* Called (rAF-throttled) on each pinch update.
|
|
10
|
+
*
|
|
11
|
+
* @param {ChartPoint} point The pinch centroid, in SVG coordinates.
|
|
12
|
+
* @param {number} deltaScale The scale change since the last call.
|
|
13
|
+
* @param {number} direction `> 0` when zooming in, `< 0` when zooming out.
|
|
14
|
+
*/
|
|
15
|
+
onPinch: (point: ChartPoint, deltaScale: number, direction: number) => void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Generic pinch gesture binding.
|
|
19
|
+
*
|
|
20
|
+
* It owns the listener lifecycle, and lets you create your own interactions from the centroid and scale delta it forwards to `onPinch`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function usePinchGesture(instance: GestureInstance, options: UsePinchGestureOptions): void;
|