@mui/x-charts-pro 9.0.0-beta.0 → 9.0.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 +18 -18
- package/BarChartPro/BarChartPro.mjs +18 -18
- package/CHANGELOG.md +267 -1
- package/ChartsDataProviderPro/ChartsDataProviderPro.js +2 -2
- package/ChartsDataProviderPro/ChartsDataProviderPro.mjs +2 -2
- package/ChartsZoomSlider/internals/ChartsAxisZoomSlider.js +59 -8
- package/ChartsZoomSlider/internals/ChartsAxisZoomSlider.mjs +60 -9
- package/ChartsZoomSlider/internals/ChartsAxisZoomSliderActiveTrack.d.mts +5 -1
- package/ChartsZoomSlider/internals/ChartsAxisZoomSliderActiveTrack.d.ts +5 -1
- package/ChartsZoomSlider/internals/ChartsAxisZoomSliderActiveTrack.js +66 -22
- package/ChartsZoomSlider/internals/ChartsAxisZoomSliderActiveTrack.mjs +69 -23
- package/ChartsZoomSlider/internals/ChartsAxisZoomSliderPreview.d.mts +6 -1
- package/ChartsZoomSlider/internals/ChartsAxisZoomSliderPreview.d.ts +6 -1
- package/ChartsZoomSlider/internals/ChartsAxisZoomSliderPreview.js +6 -4
- package/ChartsZoomSlider/internals/ChartsAxisZoomSliderPreview.mjs +6 -4
- package/ChartsZoomSlider/internals/ChartsAxisZoomSliderPreviewContent.d.mts +5 -1
- package/ChartsZoomSlider/internals/ChartsAxisZoomSliderPreviewContent.d.ts +5 -1
- package/ChartsZoomSlider/internals/ChartsAxisZoomSliderThumb.d.mts +4 -1
- package/ChartsZoomSlider/internals/ChartsAxisZoomSliderThumb.d.ts +4 -1
- package/ChartsZoomSlider/internals/ChartsAxisZoomSliderThumb.js +93 -47
- package/ChartsZoomSlider/internals/ChartsAxisZoomSliderThumb.mjs +94 -48
- package/ChartsZoomSlider/internals/constants.d.mts +5 -0
- package/ChartsZoomSlider/internals/constants.d.ts +5 -0
- package/ChartsZoomSlider/internals/constants.js +6 -1
- package/ChartsZoomSlider/internals/constants.mjs +5 -0
- package/ChartsZoomSlider/internals/previews/AreaPreviewPlot.d.mts +3 -2
- package/ChartsZoomSlider/internals/previews/AreaPreviewPlot.d.ts +3 -2
- package/ChartsZoomSlider/internals/previews/AreaPreviewPlot.js +4 -2
- package/ChartsZoomSlider/internals/previews/AreaPreviewPlot.mjs +4 -2
- package/ChartsZoomSlider/internals/previews/BarPreviewPlot.js +14 -9
- package/ChartsZoomSlider/internals/previews/BarPreviewPlot.mjs +13 -9
- package/ChartsZoomSlider/internals/previews/LineAreaPreviewPlot.d.mts +2 -1
- package/ChartsZoomSlider/internals/previews/LineAreaPreviewPlot.d.ts +2 -1
- package/ChartsZoomSlider/internals/previews/LineAreaPreviewPlot.js +6 -3
- package/ChartsZoomSlider/internals/previews/LineAreaPreviewPlot.mjs +6 -3
- package/ChartsZoomSlider/internals/previews/LinePreviewPlot.d.mts +3 -2
- package/ChartsZoomSlider/internals/previews/LinePreviewPlot.d.ts +3 -2
- package/ChartsZoomSlider/internals/previews/LinePreviewPlot.js +6 -1
- package/ChartsZoomSlider/internals/previews/LinePreviewPlot.mjs +6 -1
- package/ChartsZoomSlider/internals/previews/PreviewPlot.types.d.mts +5 -1
- package/ChartsZoomSlider/internals/previews/PreviewPlot.types.d.ts +5 -1
- package/ChartsZoomSlider/internals/previews/ScatterPreviewPlot.d.mts +2 -1
- package/ChartsZoomSlider/internals/previews/ScatterPreviewPlot.d.ts +2 -1
- package/ChartsZoomSlider/internals/previews/ScatterPreviewPlot.js +7 -1
- package/ChartsZoomSlider/internals/previews/ScatterPreviewPlot.mjs +7 -1
- package/Heatmap/Heatmap.js +2 -2
- package/Heatmap/Heatmap.mjs +2 -2
- package/LineChartPro/LineChartPro.js +18 -18
- package/LineChartPro/LineChartPro.mjs +18 -18
- package/ScatterChartPro/ScatterChartPro.js +18 -18
- package/ScatterChartPro/ScatterChartPro.mjs +18 -18
- package/index.d.mts +1 -0
- package/index.d.ts +1 -0
- package/index.js +13 -1
- package/index.mjs +2 -1
- package/package.json +121 -121
|
@@ -16,7 +16,7 @@ var _useId = _interopRequireDefault(require("@mui/utils/useId"));
|
|
|
16
16
|
var _useChartProZoom = require("../../internals/plugins/useChartProZoom");
|
|
17
17
|
var _ChartsAxisZoomSliderPreviewContent = require("./ChartsAxisZoomSliderPreviewContent");
|
|
18
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
-
const _excluded = ["axisId", "axisDirection", "reverse"];
|
|
19
|
+
const _excluded = ["axisId", "axisDirection", "reverse", "seriesIds"];
|
|
20
20
|
const PreviewBackgroundRect = (0, _styles.styled)('rect', {
|
|
21
21
|
slot: 'internal',
|
|
22
22
|
shouldForwardProp: undefined
|
|
@@ -25,13 +25,14 @@ const PreviewBackgroundRect = (0, _styles.styled)('rect', {
|
|
|
25
25
|
}) => ({
|
|
26
26
|
rx: 4,
|
|
27
27
|
ry: 4,
|
|
28
|
-
stroke: theme.palette.grey[700],
|
|
28
|
+
stroke: (theme.vars || theme).palette.grey[700],
|
|
29
29
|
fill: (0, _system.alpha)(theme.palette.grey[700], 0.4)
|
|
30
30
|
}));
|
|
31
31
|
function ChartsAxisZoomSliderPreview(_ref) {
|
|
32
32
|
let {
|
|
33
33
|
axisId,
|
|
34
|
-
axisDirection
|
|
34
|
+
axisDirection,
|
|
35
|
+
seriesIds
|
|
35
36
|
} = _ref,
|
|
36
37
|
props = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
37
38
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", (0, _extends2.default)({}, props, {
|
|
@@ -43,7 +44,8 @@ function ChartsAxisZoomSliderPreview(_ref) {
|
|
|
43
44
|
rx: 4,
|
|
44
45
|
ry: 4
|
|
45
46
|
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisZoomSliderPreviewContent.ChartsAxisZoomSliderPreviewContent, (0, _extends2.default)({
|
|
46
|
-
axisId: axisId
|
|
47
|
+
axisId: axisId,
|
|
48
|
+
seriesIds: seriesIds
|
|
47
49
|
}, props))]
|
|
48
50
|
}));
|
|
49
51
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["axisId", "axisDirection", "reverse"];
|
|
3
|
+
const _excluded = ["axisId", "axisDirection", "reverse", "seriesIds"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { styled } from '@mui/material/styles';
|
|
6
6
|
import { selectorChartAxisZoomOptionsLookup, useStore } from '@mui/x-charts/internals';
|
|
@@ -17,13 +17,14 @@ const PreviewBackgroundRect = styled('rect', {
|
|
|
17
17
|
}) => ({
|
|
18
18
|
rx: 4,
|
|
19
19
|
ry: 4,
|
|
20
|
-
stroke: theme.palette.grey[700],
|
|
20
|
+
stroke: (theme.vars || theme).palette.grey[700],
|
|
21
21
|
fill: alpha(theme.palette.grey[700], 0.4)
|
|
22
22
|
}));
|
|
23
23
|
export function ChartsAxisZoomSliderPreview(_ref) {
|
|
24
24
|
let {
|
|
25
25
|
axisId,
|
|
26
|
-
axisDirection
|
|
26
|
+
axisDirection,
|
|
27
|
+
seriesIds
|
|
27
28
|
} = _ref,
|
|
28
29
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
29
30
|
return /*#__PURE__*/_jsxs("g", _extends({}, props, {
|
|
@@ -35,7 +36,8 @@ export function ChartsAxisZoomSliderPreview(_ref) {
|
|
|
35
36
|
rx: 4,
|
|
36
37
|
ry: 4
|
|
37
38
|
})), /*#__PURE__*/_jsx(ChartsAxisZoomSliderPreviewContent, _extends({
|
|
38
|
-
axisId: axisId
|
|
39
|
+
axisId: axisId,
|
|
40
|
+
seriesIds: seriesIds
|
|
39
41
|
}, props))]
|
|
40
42
|
}));
|
|
41
43
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { type AxisId } from '@mui/x-charts/internals';
|
|
1
|
+
import { type AxisId, type SeriesId } from '@mui/x-charts/internals';
|
|
2
2
|
export interface ChartsAxisZoomSliderPreviewContentProps {
|
|
3
3
|
axisId: AxisId;
|
|
4
4
|
x: number;
|
|
5
5
|
y: number;
|
|
6
6
|
height: number;
|
|
7
7
|
width: number;
|
|
8
|
+
/**
|
|
9
|
+
* If provided, only the series with these IDs will be shown in the preview.
|
|
10
|
+
*/
|
|
11
|
+
seriesIds?: SeriesId[];
|
|
8
12
|
}
|
|
9
13
|
export declare function ChartsAxisZoomSliderPreviewContent(props: ChartsAxisZoomSliderPreviewContentProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { type AxisId } from '@mui/x-charts/internals';
|
|
1
|
+
import { type AxisId, type SeriesId } from '@mui/x-charts/internals';
|
|
2
2
|
export interface ChartsAxisZoomSliderPreviewContentProps {
|
|
3
3
|
axisId: AxisId;
|
|
4
4
|
x: number;
|
|
5
5
|
y: number;
|
|
6
6
|
height: number;
|
|
7
7
|
width: number;
|
|
8
|
+
/**
|
|
9
|
+
* If provided, only the series with these IDs will be shown in the preview.
|
|
10
|
+
*/
|
|
11
|
+
seriesIds?: SeriesId[];
|
|
8
12
|
}
|
|
9
13
|
export declare function ChartsAxisZoomSliderPreviewContent(props: ChartsAxisZoomSliderPreviewContentProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,7 +4,10 @@ export interface ChartsZoomSliderThumbOwnerState {
|
|
|
4
4
|
orientation: 'horizontal' | 'vertical';
|
|
5
5
|
placement: 'start' | 'end';
|
|
6
6
|
}
|
|
7
|
-
export interface ChartsZoomSliderThumbProps extends Omit<React.ComponentProps<'rect'>, 'orientation'>, ChartsZoomSliderThumbOwnerState {
|
|
7
|
+
export interface ChartsZoomSliderThumbProps extends Omit<React.ComponentProps<'rect'>, 'orientation'>, ChartsZoomSliderThumbOwnerState {
|
|
8
|
+
onInteractionStart?: () => void;
|
|
9
|
+
onInteractionEnd?: () => void;
|
|
10
|
+
}
|
|
8
11
|
/**
|
|
9
12
|
* Renders the zoom slider thumb, which is responsible for resizing the zoom range.
|
|
10
13
|
* @internal
|
|
@@ -4,7 +4,10 @@ export interface ChartsZoomSliderThumbOwnerState {
|
|
|
4
4
|
orientation: 'horizontal' | 'vertical';
|
|
5
5
|
placement: 'start' | 'end';
|
|
6
6
|
}
|
|
7
|
-
export interface ChartsZoomSliderThumbProps extends Omit<React.ComponentProps<'rect'>, 'orientation'>, ChartsZoomSliderThumbOwnerState {
|
|
7
|
+
export interface ChartsZoomSliderThumbProps extends Omit<React.ComponentProps<'rect'>, 'orientation'>, ChartsZoomSliderThumbOwnerState {
|
|
8
|
+
onInteractionStart?: () => void;
|
|
9
|
+
onInteractionEnd?: () => void;
|
|
10
|
+
}
|
|
8
11
|
/**
|
|
9
12
|
* Renders the zoom slider thumb, which is responsible for resizing the zoom range.
|
|
10
13
|
* @internal
|
|
@@ -16,8 +16,9 @@ var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallb
|
|
|
16
16
|
var _rafThrottle = require("@mui/x-internals/rafThrottle");
|
|
17
17
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
18
18
|
var _chartsAxisZoomSliderThumbClasses = require("./chartsAxisZoomSliderThumbClasses");
|
|
19
|
+
var _constants = require("./constants");
|
|
19
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
-
const _excluded = ["className", "onMove", "orientation", "placement", "rx", "ry"];
|
|
21
|
+
const _excluded = ["className", "onMove", "orientation", "placement", "rx", "ry", "x", "y", "width", "height", "onInteractionStart", "onInteractionEnd", "onPointerEnter", "onPointerLeave"];
|
|
21
22
|
const Rect = (0, _styles.styled)('rect', {
|
|
22
23
|
slot: 'internal',
|
|
23
24
|
shouldForwardProp: undefined
|
|
@@ -38,10 +39,17 @@ const Rect = (0, _styles.styled)('rect', {
|
|
|
38
39
|
cursor: 'ns-resize'
|
|
39
40
|
}
|
|
40
41
|
}));
|
|
41
|
-
function preventDefault(event) {
|
|
42
|
-
event.preventDefault();
|
|
43
|
-
}
|
|
44
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Invisible touch target that is only active on coarse pointer devices (touch).
|
|
45
|
+
* On fine pointer devices (mouse), it disables pointer events so it doesn't
|
|
46
|
+
* interfere with precise interactions on small zoom ranges.
|
|
47
|
+
*/
|
|
48
|
+
const TouchTarget = (0, _styles.styled)('rect')({
|
|
49
|
+
'@media (pointer: fine)': {
|
|
50
|
+
pointerEvents: 'none'
|
|
51
|
+
}
|
|
52
|
+
});
|
|
45
53
|
/**
|
|
46
54
|
* Renders the zoom slider thumb, which is responsible for resizing the zoom range.
|
|
47
55
|
* @internal
|
|
@@ -53,7 +61,15 @@ const ChartsAxisZoomSliderThumb = exports.ChartsAxisZoomSliderThumb = /*#__PURE_
|
|
|
53
61
|
orientation,
|
|
54
62
|
placement,
|
|
55
63
|
rx = 4,
|
|
56
|
-
ry = 4
|
|
64
|
+
ry = 4,
|
|
65
|
+
x,
|
|
66
|
+
y,
|
|
67
|
+
width,
|
|
68
|
+
height,
|
|
69
|
+
onInteractionStart,
|
|
70
|
+
onInteractionEnd,
|
|
71
|
+
onPointerEnter,
|
|
72
|
+
onPointerLeave
|
|
57
73
|
} = _ref,
|
|
58
74
|
other = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
59
75
|
const classes = (0, _chartsAxisZoomSliderThumbClasses.useUtilityClasses)({
|
|
@@ -61,52 +77,82 @@ const ChartsAxisZoomSliderThumb = exports.ChartsAxisZoomSliderThumb = /*#__PURE_
|
|
|
61
77
|
orientation,
|
|
62
78
|
placement
|
|
63
79
|
});
|
|
80
|
+
const groupRef = React.useRef(null);
|
|
64
81
|
const thumbRef = React.useRef(null);
|
|
65
82
|
const ref = (0, _useForkRef.default)(thumbRef, forwardedRef);
|
|
83
|
+
const isDraggingRef = React.useRef(false);
|
|
66
84
|
const onMoveEvent = (0, _useEventCallback.default)(onMove);
|
|
67
|
-
React.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
85
|
+
const throttledMove = React.useMemo(() => (0, _rafThrottle.rafThrottle)(event => onMoveEvent(event)), [onMoveEvent]);
|
|
86
|
+
React.useEffect(() => () => throttledMove.clear(), [throttledMove]);
|
|
87
|
+
const handlePointerDown = (0, _useEventCallback.default)(event => {
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
event.stopPropagation();
|
|
90
|
+
try {
|
|
91
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
92
|
+
} catch {
|
|
93
|
+
// setPointerCapture can fail if the pointer is no longer active,
|
|
94
|
+
// e.g., during touch→mouse compatibility events.
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
isDraggingRef.current = true;
|
|
98
|
+
onInteractionStart?.();
|
|
99
|
+
});
|
|
100
|
+
const handlePointerMove = (0, _useEventCallback.default)(event => {
|
|
101
|
+
if (!isDraggingRef.current) {
|
|
102
|
+
return;
|
|
71
103
|
}
|
|
104
|
+
throttledMove(event.nativeEvent);
|
|
105
|
+
});
|
|
106
|
+
const handlePointerEnd = (0, _useEventCallback.default)(event => {
|
|
107
|
+
if (!isDraggingRef.current) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
112
|
+
} catch {
|
|
113
|
+
// Ignore if pointer is no longer active
|
|
114
|
+
}
|
|
115
|
+
isDraggingRef.current = false;
|
|
116
|
+
onInteractionEnd?.();
|
|
117
|
+
});
|
|
118
|
+
const numX = Number(x) || 0;
|
|
119
|
+
const numY = Number(y) || 0;
|
|
120
|
+
const numWidth = Number(width) || 0;
|
|
121
|
+
const numHeight = Number(height) || 0;
|
|
72
122
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
ref: ref,
|
|
108
|
-
rx: rx,
|
|
109
|
-
ry: ry
|
|
110
|
-
}, other));
|
|
123
|
+
// Compute a larger invisible touch target centered on the visible thumb
|
|
124
|
+
const touchWidth = Math.max(numWidth, _constants.ZOOM_SLIDER_TOUCH_TARGET);
|
|
125
|
+
const touchHeight = Math.max(numHeight, _constants.ZOOM_SLIDER_TOUCH_TARGET);
|
|
126
|
+
const touchX = numX - (touchWidth - numWidth) / 2;
|
|
127
|
+
const touchY = numY - (touchHeight - numHeight) / 2;
|
|
128
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
|
|
129
|
+
ref: groupRef,
|
|
130
|
+
onPointerDown: handlePointerDown,
|
|
131
|
+
onPointerMove: handlePointerMove,
|
|
132
|
+
onPointerUp: handlePointerEnd,
|
|
133
|
+
onPointerCancel: handlePointerEnd,
|
|
134
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Rect, (0, _extends2.default)({
|
|
135
|
+
ref: ref,
|
|
136
|
+
className: (0, _clsx.default)(classes.root, className),
|
|
137
|
+
rx: rx,
|
|
138
|
+
ry: ry,
|
|
139
|
+
x: x,
|
|
140
|
+
y: y,
|
|
141
|
+
width: width,
|
|
142
|
+
height: height,
|
|
143
|
+
onPointerEnter: onPointerEnter,
|
|
144
|
+
onPointerLeave: onPointerLeave
|
|
145
|
+
}, other)), /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchTarget, {
|
|
146
|
+
x: touchX,
|
|
147
|
+
y: touchY,
|
|
148
|
+
width: touchWidth,
|
|
149
|
+
height: touchHeight,
|
|
150
|
+
fill: "transparent",
|
|
151
|
+
stroke: "none",
|
|
152
|
+
cursor: orientation === 'horizontal' ? 'ew-resize' : 'ns-resize',
|
|
153
|
+
onPointerEnter: onPointerEnter,
|
|
154
|
+
onPointerLeave: onPointerLeave
|
|
155
|
+
})]
|
|
156
|
+
});
|
|
111
157
|
});
|
|
112
158
|
if (process.env.NODE_ENV !== "production") ChartsAxisZoomSliderThumb.displayName = "ChartsAxisZoomSliderThumb";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
4
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
-
const _excluded = ["className", "onMove", "orientation", "placement", "rx", "ry"];
|
|
5
|
+
const _excluded = ["className", "onMove", "orientation", "placement", "rx", "ry", "x", "y", "width", "height", "onInteractionStart", "onInteractionEnd", "onPointerEnter", "onPointerLeave"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { styled } from '@mui/material/styles';
|
|
8
8
|
import useForkRef from '@mui/utils/useForkRef';
|
|
@@ -10,7 +10,8 @@ import useEventCallback from '@mui/utils/useEventCallback';
|
|
|
10
10
|
import { rafThrottle } from '@mui/x-internals/rafThrottle';
|
|
11
11
|
import clsx from 'clsx';
|
|
12
12
|
import { chartsAxisZoomSliderThumbClasses, useUtilityClasses } from "./chartsAxisZoomSliderThumbClasses.mjs";
|
|
13
|
-
import {
|
|
13
|
+
import { ZOOM_SLIDER_TOUCH_TARGET } from "./constants.mjs";
|
|
14
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
15
|
const Rect = styled('rect', {
|
|
15
16
|
slot: 'internal',
|
|
16
17
|
shouldForwardProp: undefined
|
|
@@ -31,10 +32,17 @@ const Rect = styled('rect', {
|
|
|
31
32
|
cursor: 'ns-resize'
|
|
32
33
|
}
|
|
33
34
|
}));
|
|
34
|
-
function preventDefault(event) {
|
|
35
|
-
event.preventDefault();
|
|
36
|
-
}
|
|
37
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Invisible touch target that is only active on coarse pointer devices (touch).
|
|
38
|
+
* On fine pointer devices (mouse), it disables pointer events so it doesn't
|
|
39
|
+
* interfere with precise interactions on small zoom ranges.
|
|
40
|
+
*/
|
|
41
|
+
const TouchTarget = styled('rect')({
|
|
42
|
+
'@media (pointer: fine)': {
|
|
43
|
+
pointerEvents: 'none'
|
|
44
|
+
}
|
|
45
|
+
});
|
|
38
46
|
/**
|
|
39
47
|
* Renders the zoom slider thumb, which is responsible for resizing the zoom range.
|
|
40
48
|
* @internal
|
|
@@ -46,7 +54,15 @@ export const ChartsAxisZoomSliderThumb = /*#__PURE__*/React.forwardRef(function
|
|
|
46
54
|
orientation,
|
|
47
55
|
placement,
|
|
48
56
|
rx = 4,
|
|
49
|
-
ry = 4
|
|
57
|
+
ry = 4,
|
|
58
|
+
x,
|
|
59
|
+
y,
|
|
60
|
+
width,
|
|
61
|
+
height,
|
|
62
|
+
onInteractionStart,
|
|
63
|
+
onInteractionEnd,
|
|
64
|
+
onPointerEnter,
|
|
65
|
+
onPointerLeave
|
|
50
66
|
} = _ref,
|
|
51
67
|
other = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
52
68
|
const classes = useUtilityClasses({
|
|
@@ -54,52 +70,82 @@ export const ChartsAxisZoomSliderThumb = /*#__PURE__*/React.forwardRef(function
|
|
|
54
70
|
orientation,
|
|
55
71
|
placement
|
|
56
72
|
});
|
|
73
|
+
const groupRef = React.useRef(null);
|
|
57
74
|
const thumbRef = React.useRef(null);
|
|
58
75
|
const ref = useForkRef(thumbRef, forwardedRef);
|
|
76
|
+
const isDraggingRef = React.useRef(false);
|
|
59
77
|
const onMoveEvent = useEventCallback(onMove);
|
|
60
|
-
React.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
78
|
+
const throttledMove = React.useMemo(() => rafThrottle(event => onMoveEvent(event)), [onMoveEvent]);
|
|
79
|
+
React.useEffect(() => () => throttledMove.clear(), [throttledMove]);
|
|
80
|
+
const handlePointerDown = useEventCallback(event => {
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
event.stopPropagation();
|
|
83
|
+
try {
|
|
84
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
85
|
+
} catch {
|
|
86
|
+
// setPointerCapture can fail if the pointer is no longer active,
|
|
87
|
+
// e.g., during touch→mouse compatibility events.
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
isDraggingRef.current = true;
|
|
91
|
+
onInteractionStart?.();
|
|
92
|
+
});
|
|
93
|
+
const handlePointerMove = useEventCallback(event => {
|
|
94
|
+
if (!isDraggingRef.current) {
|
|
95
|
+
return;
|
|
64
96
|
}
|
|
97
|
+
throttledMove(event.nativeEvent);
|
|
98
|
+
});
|
|
99
|
+
const handlePointerEnd = useEventCallback(event => {
|
|
100
|
+
if (!isDraggingRef.current) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
105
|
+
} catch {
|
|
106
|
+
// Ignore if pointer is no longer active
|
|
107
|
+
}
|
|
108
|
+
isDraggingRef.current = false;
|
|
109
|
+
onInteractionEnd?.();
|
|
110
|
+
});
|
|
111
|
+
const numX = Number(x) || 0;
|
|
112
|
+
const numY = Number(y) || 0;
|
|
113
|
+
const numWidth = Number(width) || 0;
|
|
114
|
+
const numHeight = Number(height) || 0;
|
|
65
115
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
ref: ref,
|
|
101
|
-
rx: rx,
|
|
102
|
-
ry: ry
|
|
103
|
-
}, other));
|
|
116
|
+
// Compute a larger invisible touch target centered on the visible thumb
|
|
117
|
+
const touchWidth = Math.max(numWidth, ZOOM_SLIDER_TOUCH_TARGET);
|
|
118
|
+
const touchHeight = Math.max(numHeight, ZOOM_SLIDER_TOUCH_TARGET);
|
|
119
|
+
const touchX = numX - (touchWidth - numWidth) / 2;
|
|
120
|
+
const touchY = numY - (touchHeight - numHeight) / 2;
|
|
121
|
+
return /*#__PURE__*/_jsxs("g", {
|
|
122
|
+
ref: groupRef,
|
|
123
|
+
onPointerDown: handlePointerDown,
|
|
124
|
+
onPointerMove: handlePointerMove,
|
|
125
|
+
onPointerUp: handlePointerEnd,
|
|
126
|
+
onPointerCancel: handlePointerEnd,
|
|
127
|
+
children: [/*#__PURE__*/_jsx(Rect, _extends({
|
|
128
|
+
ref: ref,
|
|
129
|
+
className: clsx(classes.root, className),
|
|
130
|
+
rx: rx,
|
|
131
|
+
ry: ry,
|
|
132
|
+
x: x,
|
|
133
|
+
y: y,
|
|
134
|
+
width: width,
|
|
135
|
+
height: height,
|
|
136
|
+
onPointerEnter: onPointerEnter,
|
|
137
|
+
onPointerLeave: onPointerLeave
|
|
138
|
+
}, other)), /*#__PURE__*/_jsx(TouchTarget, {
|
|
139
|
+
x: touchX,
|
|
140
|
+
y: touchY,
|
|
141
|
+
width: touchWidth,
|
|
142
|
+
height: touchHeight,
|
|
143
|
+
fill: "transparent",
|
|
144
|
+
stroke: "none",
|
|
145
|
+
cursor: orientation === 'horizontal' ? 'ew-resize' : 'ns-resize',
|
|
146
|
+
onPointerEnter: onPointerEnter,
|
|
147
|
+
onPointerLeave: onPointerLeave
|
|
148
|
+
})]
|
|
149
|
+
});
|
|
104
150
|
});
|
|
105
151
|
if (process.env.NODE_ENV !== "production") ChartsAxisZoomSliderThumb.displayName = "ChartsAxisZoomSliderThumb";
|
|
@@ -2,4 +2,9 @@ export declare const ZOOM_SLIDER_TRACK_SIZE = 8;
|
|
|
2
2
|
export declare const ZOOM_SLIDER_ACTIVE_TRACK_SIZE = 10;
|
|
3
3
|
export declare const ZOOM_SLIDER_THUMB_HEIGHT = 20;
|
|
4
4
|
export declare const ZOOM_SLIDER_THUMB_WIDTH = 10;
|
|
5
|
+
/**
|
|
6
|
+
* Minimum touch target size for interactive elements (thumbs, track).
|
|
7
|
+
* This is larger than the visible elements to make them easier to interact with on touch devices.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ZOOM_SLIDER_TOUCH_TARGET = 44;
|
|
5
10
|
export declare const ZOOM_SLIDER_SIZE: number;
|
|
@@ -2,4 +2,9 @@ export declare const ZOOM_SLIDER_TRACK_SIZE = 8;
|
|
|
2
2
|
export declare const ZOOM_SLIDER_ACTIVE_TRACK_SIZE = 10;
|
|
3
3
|
export declare const ZOOM_SLIDER_THUMB_HEIGHT = 20;
|
|
4
4
|
export declare const ZOOM_SLIDER_THUMB_WIDTH = 10;
|
|
5
|
+
/**
|
|
6
|
+
* Minimum touch target size for interactive elements (thumbs, track).
|
|
7
|
+
* This is larger than the visible elements to make them easier to interact with on touch devices.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ZOOM_SLIDER_TOUCH_TARGET = 44;
|
|
5
10
|
export declare const ZOOM_SLIDER_SIZE: number;
|
|
@@ -3,9 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.ZOOM_SLIDER_TRACK_SIZE = exports.ZOOM_SLIDER_THUMB_WIDTH = exports.ZOOM_SLIDER_THUMB_HEIGHT = exports.ZOOM_SLIDER_SIZE = exports.ZOOM_SLIDER_ACTIVE_TRACK_SIZE = void 0;
|
|
6
|
+
exports.ZOOM_SLIDER_TRACK_SIZE = exports.ZOOM_SLIDER_TOUCH_TARGET = exports.ZOOM_SLIDER_THUMB_WIDTH = exports.ZOOM_SLIDER_THUMB_HEIGHT = exports.ZOOM_SLIDER_SIZE = exports.ZOOM_SLIDER_ACTIVE_TRACK_SIZE = void 0;
|
|
7
7
|
const ZOOM_SLIDER_TRACK_SIZE = exports.ZOOM_SLIDER_TRACK_SIZE = 8;
|
|
8
8
|
const ZOOM_SLIDER_ACTIVE_TRACK_SIZE = exports.ZOOM_SLIDER_ACTIVE_TRACK_SIZE = 10;
|
|
9
9
|
const ZOOM_SLIDER_THUMB_HEIGHT = exports.ZOOM_SLIDER_THUMB_HEIGHT = 20;
|
|
10
10
|
const ZOOM_SLIDER_THUMB_WIDTH = exports.ZOOM_SLIDER_THUMB_WIDTH = 10;
|
|
11
|
+
/**
|
|
12
|
+
* Minimum touch target size for interactive elements (thumbs, track).
|
|
13
|
+
* This is larger than the visible elements to make them easier to interact with on touch devices.
|
|
14
|
+
*/
|
|
15
|
+
const ZOOM_SLIDER_TOUCH_TARGET = exports.ZOOM_SLIDER_TOUCH_TARGET = 44;
|
|
11
16
|
const ZOOM_SLIDER_SIZE = exports.ZOOM_SLIDER_SIZE = Math.max(ZOOM_SLIDER_TRACK_SIZE, ZOOM_SLIDER_ACTIVE_TRACK_SIZE, ZOOM_SLIDER_THUMB_HEIGHT, ZOOM_SLIDER_THUMB_WIDTH);
|
|
@@ -2,4 +2,9 @@ export const ZOOM_SLIDER_TRACK_SIZE = 8;
|
|
|
2
2
|
export const ZOOM_SLIDER_ACTIVE_TRACK_SIZE = 10;
|
|
3
3
|
export const ZOOM_SLIDER_THUMB_HEIGHT = 20;
|
|
4
4
|
export const ZOOM_SLIDER_THUMB_WIDTH = 10;
|
|
5
|
+
/**
|
|
6
|
+
* Minimum touch target size for interactive elements (thumbs, track).
|
|
7
|
+
* This is larger than the visible elements to make them easier to interact with on touch devices.
|
|
8
|
+
*/
|
|
9
|
+
export const ZOOM_SLIDER_TOUCH_TARGET = 44;
|
|
5
10
|
export const ZOOM_SLIDER_SIZE = Math.max(ZOOM_SLIDER_TRACK_SIZE, ZOOM_SLIDER_ACTIVE_TRACK_SIZE, ZOOM_SLIDER_THUMB_HEIGHT, ZOOM_SLIDER_THUMB_WIDTH);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type SeriesId } from '@mui/x-charts/internals';
|
|
3
3
|
import { type PreviewPlotProps } from "./PreviewPlot.types.mjs";
|
|
4
|
-
interface AreaPreviewPlotProps extends Pick<PreviewPlotProps, 'axisId'> {}
|
|
4
|
+
interface AreaPreviewPlotProps extends Pick<PreviewPlotProps, 'axisId' | 'seriesIds'> {}
|
|
5
5
|
export declare function AreaPreviewPlot({
|
|
6
|
-
axisId
|
|
6
|
+
axisId,
|
|
7
|
+
seriesIds
|
|
7
8
|
}: AreaPreviewPlotProps): import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
export interface PreviewAreaElementProps extends Omit<React.SVGProps<SVGPathElement>, 'ref' | 'color' | 'id'> {
|
|
9
10
|
seriesId: SeriesId;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type SeriesId } from '@mui/x-charts/internals';
|
|
3
3
|
import { type PreviewPlotProps } from "./PreviewPlot.types.js";
|
|
4
|
-
interface AreaPreviewPlotProps extends Pick<PreviewPlotProps, 'axisId'> {}
|
|
4
|
+
interface AreaPreviewPlotProps extends Pick<PreviewPlotProps, 'axisId' | 'seriesIds'> {}
|
|
5
5
|
export declare function AreaPreviewPlot({
|
|
6
|
-
axisId
|
|
6
|
+
axisId,
|
|
7
|
+
seriesIds
|
|
7
8
|
}: AreaPreviewPlotProps): import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
export interface PreviewAreaElementProps extends Omit<React.SVGProps<SVGPathElement>, 'ref' | 'color' | 'id'> {
|
|
9
10
|
seriesId: SeriesId;
|
|
@@ -18,9 +18,11 @@ const AreaPlotRoot = (0, _styles.styled)('g', {
|
|
|
18
18
|
slot: 'Root'
|
|
19
19
|
})({});
|
|
20
20
|
function AreaPreviewPlot({
|
|
21
|
-
axisId
|
|
21
|
+
axisId,
|
|
22
|
+
seriesIds
|
|
22
23
|
}) {
|
|
23
24
|
const completedData = useAreaPreviewData(axisId);
|
|
25
|
+
const seriesIdsSet = seriesIds ? new Set(seriesIds) : undefined;
|
|
24
26
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(AreaPlotRoot, {
|
|
25
27
|
children: completedData.map(({
|
|
26
28
|
d,
|
|
@@ -28,7 +30,7 @@ function AreaPreviewPlot({
|
|
|
28
30
|
color,
|
|
29
31
|
area,
|
|
30
32
|
gradientId
|
|
31
|
-
}) => !!area && /*#__PURE__*/(0, _jsxRuntime.jsx)(PreviewAreaElement, {
|
|
33
|
+
}) => !!area && (!seriesIdsSet || seriesIdsSet.has(seriesId)) && /*#__PURE__*/(0, _jsxRuntime.jsx)(PreviewAreaElement, {
|
|
32
34
|
seriesId: seriesId,
|
|
33
35
|
d: d,
|
|
34
36
|
color: color,
|
|
@@ -10,9 +10,11 @@ const AreaPlotRoot = styled('g', {
|
|
|
10
10
|
slot: 'Root'
|
|
11
11
|
})({});
|
|
12
12
|
export function AreaPreviewPlot({
|
|
13
|
-
axisId
|
|
13
|
+
axisId,
|
|
14
|
+
seriesIds
|
|
14
15
|
}) {
|
|
15
16
|
const completedData = useAreaPreviewData(axisId);
|
|
17
|
+
const seriesIdsSet = seriesIds ? new Set(seriesIds) : undefined;
|
|
16
18
|
return /*#__PURE__*/_jsx(AreaPlotRoot, {
|
|
17
19
|
children: completedData.map(({
|
|
18
20
|
d,
|
|
@@ -20,7 +22,7 @@ export function AreaPreviewPlot({
|
|
|
20
22
|
color,
|
|
21
23
|
area,
|
|
22
24
|
gradientId
|
|
23
|
-
}) => !!area && /*#__PURE__*/_jsx(PreviewAreaElement, {
|
|
25
|
+
}) => !!area && (!seriesIdsSet || seriesIdsSet.has(seriesId)) && /*#__PURE__*/_jsx(PreviewAreaElement, {
|
|
24
26
|
seriesId: seriesId,
|
|
25
27
|
d: d,
|
|
26
28
|
color: color,
|