@mui/x-charts 9.12.0 → 9.14.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/BarChart/BarChart.js +1 -1
- package/BarChart/BarChart.mjs +1 -1
- package/CHANGELOG.md +301 -0
- package/ChartsContainer/ChartsContainer.js +1 -1
- package/ChartsContainer/ChartsContainer.mjs +1 -1
- package/ChartsXAxis/useAxisTicksProps.js +2 -1
- package/ChartsXAxis/useAxisTicksProps.mjs +2 -1
- package/ChartsYAxis/shortenLabels.js +16 -26
- package/ChartsYAxis/shortenLabels.mjs +17 -27
- package/ChartsYAxis/useAxisTicksProps.js +2 -1
- package/ChartsYAxis/useAxisTicksProps.mjs +2 -1
- package/LineChart/LineChart.js +1 -1
- package/LineChart/LineChart.mjs +1 -1
- package/LineChart/MarkElement.js +13 -6
- package/LineChart/MarkElement.mjs +13 -6
- package/RadarChart/RadarChart.js +1 -1
- package/RadarChart/RadarChart.mjs +1 -1
- package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +6 -2
- package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.mjs +6 -2
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +2 -1
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.mjs +2 -1
- package/ScatterChart/ScatterChart.js +1 -1
- package/ScatterChart/ScatterChart.mjs +1 -1
- package/SparkLineChart/SparkLineChart.js +1 -1
- package/SparkLineChart/SparkLineChart.mjs +1 -1
- package/constants/index.d.mts +3 -1
- package/constants/index.d.ts +3 -1
- package/constants/index.js +5 -2
- package/constants/index.mjs +4 -1
- package/hooks/animation/index.d.mts +1 -0
- package/hooks/animation/index.d.ts +1 -0
- package/hooks/animation/index.js +11 -0
- package/hooks/animation/index.mjs +1 -0
- package/hooks/animation/useAnimateMark.d.mts +25 -0
- package/hooks/animation/useAnimateMark.d.ts +25 -0
- package/hooks/animation/useAnimateMark.js +45 -0
- package/hooks/animation/useAnimateMark.mjs +39 -0
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.js +31 -8
- package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.mjs +32 -9
- package/internals/components/ChartsAccessibilityProxy/useZoomAnnouncement.d.mts +9 -0
- package/internals/components/ChartsAccessibilityProxy/useZoomAnnouncement.d.ts +9 -0
- package/internals/components/ChartsAccessibilityProxy/useZoomAnnouncement.js +67 -0
- package/internals/components/ChartsAccessibilityProxy/useZoomAnnouncement.mjs +62 -0
- package/internals/domUtils.js +17 -16
- package/internals/domUtils.mjs +17 -15
- package/internals/ellipsize.d.mts +30 -0
- package/internals/ellipsize.d.ts +30 -0
- package/internals/ellipsize.js +60 -0
- package/internals/ellipsize.mjs +59 -0
- package/internals/index.d.mts +1 -0
- package/internals/index.d.ts +1 -0
- package/internals/index.js +8 -0
- package/internals/index.mjs +1 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisAutoSize.d.mts +3 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisAutoSize.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisAutoSize.js +9 -5
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisAutoSize.mjs +9 -5
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisAutoSize.selectors.js +9 -4
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisAutoSize.selectors.mjs +9 -4
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +75 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.mjs +76 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.mts +6 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +6 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisLayout.selectors.d.mts +1 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisLayout.selectors.d.ts +1 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +59 -16
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.mjs +59 -16
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.mts +3 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +2 -1
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.mjs +1 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.mts +12 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +12 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getItemAtRotationIndex.d.mts +18 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getItemAtRotationIndex.d.ts +18 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getItemAtRotationIndex.js +65 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getItemAtRotationIndex.mjs +60 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +43 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.mjs +43 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.mts +3 -2
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +3 -2
- package/internals/useDefaultTickLabelStyle.d.mts +7 -0
- package/internals/useDefaultTickLabelStyle.d.ts +7 -0
- package/internals/useDefaultTickLabelStyle.js +34 -0
- package/internals/useDefaultTickLabelStyle.mjs +28 -0
- package/locales/elGR.d.mts +5 -0
- package/locales/elGR.d.ts +5 -0
- package/locales/elGR.js +8 -0
- package/locales/elGR.mjs +8 -0
- package/locales/enUS.d.mts +5 -0
- package/locales/enUS.d.ts +5 -0
- package/locales/enUS.js +8 -0
- package/locales/enUS.mjs +8 -0
- package/locales/frFR.d.mts +5 -0
- package/locales/frFR.d.ts +5 -0
- package/locales/frFR.js +8 -0
- package/locales/frFR.mjs +8 -0
- package/locales/nbNO.d.mts +5 -0
- package/locales/nbNO.d.ts +5 -0
- package/locales/nbNO.js +8 -0
- package/locales/nbNO.mjs +8 -0
- package/locales/ptBR.d.mts +5 -0
- package/locales/ptBR.d.ts +5 -0
- package/locales/ptBR.js +8 -0
- package/locales/ptBR.mjs +8 -0
- package/locales/ptPT.d.mts +5 -0
- package/locales/ptPT.d.ts +5 -0
- package/locales/ptPT.js +8 -0
- package/locales/ptPT.mjs +8 -0
- package/locales/svSE.d.mts +5 -0
- package/locales/svSE.d.ts +5 -0
- package/locales/svSE.js +8 -0
- package/locales/svSE.mjs +8 -0
- package/locales/utils/chartsLocaleTextApi.d.mts +14 -0
- package/locales/utils/chartsLocaleTextApi.d.ts +14 -0
- package/locales/utils/getChartsLocalization.d.mts +5 -0
- package/locales/utils/getChartsLocalization.d.ts +5 -0
- package/package.json +7 -7
|
@@ -224,7 +224,7 @@ process.env.NODE_ENV !== "production" ? RadarChart.propTypes /* remove-proptypes
|
|
|
224
224
|
/**
|
|
225
225
|
* The function called for onClick events.
|
|
226
226
|
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
227
|
-
* @param {
|
|
227
|
+
* @param {ChartsActivationEvent} event The event recorded on the `<svg/>` element.
|
|
228
228
|
* @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
|
|
229
229
|
*/
|
|
230
230
|
onAxisClick: PropTypes.func,
|
|
@@ -14,6 +14,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
14
14
|
var _useRadarSeriesData = require("./useRadarSeriesData");
|
|
15
15
|
var _radarClasses = require("../radarClasses");
|
|
16
16
|
var _useItemHighlightStateGetter = require("../../hooks/useItemHighlightStateGetter");
|
|
17
|
+
var _useInteractionAllItemProps = require("./useInteractionAllItemProps");
|
|
17
18
|
var _useRegisterRadarItemActivation = require("./useRegisterRadarItemActivation");
|
|
18
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
20
|
const _excluded = ["seriesId", "onItemClick", "classes"];
|
|
@@ -54,6 +55,9 @@ function RadarSeriesMarks(props) {
|
|
|
54
55
|
const seriesCoordinates = (0, _useRadarSeriesData.useRadarSeriesData)(props.seriesId);
|
|
55
56
|
const classes = (0, _radarClasses.useUtilityClasses)(inClasses);
|
|
56
57
|
const getHighlightState = (0, _useItemHighlightStateGetter.useItemHighlightStateGetter)();
|
|
58
|
+
// Clickable marks cover the area, so they report the series the same way it does. The index
|
|
59
|
+
// still comes from the rotation axis, which is why the identifier stays series-level.
|
|
60
|
+
const interactionProps = (0, _useInteractionAllItemProps.useInteractionAllItemProps)(seriesCoordinates);
|
|
57
61
|
(0, _useRegisterRadarItemActivation.useRegisterRadarItemActivation)(seriesId, onItemClick, _useRegisterRadarItemActivation.RADAR_ACTIVATION_PRIORITY.mark);
|
|
58
62
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(React.Fragment, {
|
|
59
63
|
children: seriesCoordinates?.map(({
|
|
@@ -62,7 +66,7 @@ function RadarSeriesMarks(props) {
|
|
|
62
66
|
hideMark,
|
|
63
67
|
fillArea,
|
|
64
68
|
hidden
|
|
65
|
-
}) => {
|
|
69
|
+
}, seriesIndex) => {
|
|
66
70
|
if (hideMark || hidden) {
|
|
67
71
|
return null;
|
|
68
72
|
}
|
|
@@ -83,7 +87,7 @@ function RadarSeriesMarks(props) {
|
|
|
83
87
|
dataIndex: index
|
|
84
88
|
}),
|
|
85
89
|
cursor: onItemClick ? 'pointer' : 'unset'
|
|
86
|
-
}, other), index))
|
|
90
|
+
}, interactionProps[seriesIndex], other), index))
|
|
87
91
|
}, id);
|
|
88
92
|
})
|
|
89
93
|
});
|
|
@@ -6,6 +6,7 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import { useRadarSeriesData } from "./useRadarSeriesData.mjs";
|
|
7
7
|
import { useUtilityClasses } from "../radarClasses.mjs";
|
|
8
8
|
import { useItemHighlightStateGetter } from "../../hooks/useItemHighlightStateGetter.mjs";
|
|
9
|
+
import { useInteractionAllItemProps } from "./useInteractionAllItemProps.mjs";
|
|
9
10
|
import { RADAR_ACTIVATION_PRIORITY, useRegisterRadarItemActivation } from "./useRegisterRadarItemActivation.mjs";
|
|
10
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
12
|
export function getCircleProps(params) {
|
|
@@ -45,6 +46,9 @@ function RadarSeriesMarks(props) {
|
|
|
45
46
|
const seriesCoordinates = useRadarSeriesData(props.seriesId);
|
|
46
47
|
const classes = useUtilityClasses(inClasses);
|
|
47
48
|
const getHighlightState = useItemHighlightStateGetter();
|
|
49
|
+
// Clickable marks cover the area, so they report the series the same way it does. The index
|
|
50
|
+
// still comes from the rotation axis, which is why the identifier stays series-level.
|
|
51
|
+
const interactionProps = useInteractionAllItemProps(seriesCoordinates);
|
|
48
52
|
useRegisterRadarItemActivation(seriesId, onItemClick, RADAR_ACTIVATION_PRIORITY.mark);
|
|
49
53
|
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
50
54
|
children: seriesCoordinates?.map(({
|
|
@@ -53,7 +57,7 @@ function RadarSeriesMarks(props) {
|
|
|
53
57
|
hideMark,
|
|
54
58
|
fillArea,
|
|
55
59
|
hidden
|
|
56
|
-
}) => {
|
|
60
|
+
}, seriesIndex) => {
|
|
57
61
|
if (hideMark || hidden) {
|
|
58
62
|
return null;
|
|
59
63
|
}
|
|
@@ -74,7 +78,7 @@ function RadarSeriesMarks(props) {
|
|
|
74
78
|
dataIndex: index
|
|
75
79
|
}),
|
|
76
80
|
cursor: onItemClick ? 'pointer' : 'unset'
|
|
77
|
-
}, other), index))
|
|
81
|
+
}, interactionProps[seriesIndex], other), index))
|
|
78
82
|
}, id);
|
|
79
83
|
})
|
|
80
84
|
});
|
|
@@ -66,13 +66,14 @@ function RadarSeriesPlot(props) {
|
|
|
66
66
|
getHighlightState,
|
|
67
67
|
classes
|
|
68
68
|
}), {
|
|
69
|
+
pointerEvents: onMarkClick ? undefined : 'none',
|
|
69
70
|
onClick: event => onMarkClick?.(event, {
|
|
70
71
|
type: 'radar',
|
|
71
72
|
seriesId,
|
|
72
73
|
dataIndex: index
|
|
73
74
|
}),
|
|
74
75
|
cursor: onMarkClick ? 'pointer' : 'unset'
|
|
75
|
-
}), index))]
|
|
76
|
+
}, interactionProps[seriesIndex]), index))]
|
|
76
77
|
}, seriesId);
|
|
77
78
|
})
|
|
78
79
|
});
|
|
@@ -59,13 +59,14 @@ function RadarSeriesPlot(props) {
|
|
|
59
59
|
getHighlightState,
|
|
60
60
|
classes
|
|
61
61
|
}), {
|
|
62
|
+
pointerEvents: onMarkClick ? undefined : 'none',
|
|
62
63
|
onClick: event => onMarkClick?.(event, {
|
|
63
64
|
type: 'radar',
|
|
64
65
|
seriesId,
|
|
65
66
|
dataIndex: index
|
|
66
67
|
}),
|
|
67
68
|
cursor: onMarkClick ? 'pointer' : 'unset'
|
|
68
|
-
}), index))]
|
|
69
|
+
}, interactionProps[seriesIndex]), index))]
|
|
69
70
|
}, seriesId);
|
|
70
71
|
})
|
|
71
72
|
});
|
|
@@ -280,7 +280,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes /* remove-proptyp
|
|
|
280
280
|
/**
|
|
281
281
|
* The function called for onClick events.
|
|
282
282
|
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
283
|
-
* @param {
|
|
283
|
+
* @param {ChartsActivationEvent} event The event recorded on the `<svg/>` element.
|
|
284
284
|
* @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
|
|
285
285
|
*/
|
|
286
286
|
onAxisClick: _propTypes.default.func,
|
|
@@ -273,7 +273,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes /* remove-proptyp
|
|
|
273
273
|
/**
|
|
274
274
|
* The function called for onClick events.
|
|
275
275
|
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
276
|
-
* @param {
|
|
276
|
+
* @param {ChartsActivationEvent} event The event recorded on the `<svg/>` element.
|
|
277
277
|
* @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
|
|
278
278
|
*/
|
|
279
279
|
onAxisClick: PropTypes.func,
|
|
@@ -460,7 +460,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes /* remove-propt
|
|
|
460
460
|
/**
|
|
461
461
|
* The function called for onClick events.
|
|
462
462
|
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
463
|
-
* @param {
|
|
463
|
+
* @param {ChartsActivationEvent} event The event recorded on the `<svg/>` element.
|
|
464
464
|
* @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
|
|
465
465
|
*/
|
|
466
466
|
onAxisClick: _propTypes.default.func,
|
|
@@ -453,7 +453,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes /* remove-propt
|
|
|
453
453
|
/**
|
|
454
454
|
* The function called for onClick events.
|
|
455
455
|
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
456
|
-
* @param {
|
|
456
|
+
* @param {ChartsActivationEvent} event The event recorded on the `<svg/>` element.
|
|
457
457
|
* @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
|
|
458
458
|
*/
|
|
459
459
|
onAxisClick: PropTypes.func,
|
package/constants/index.d.mts
CHANGED
|
@@ -10,4 +10,6 @@ export declare const DEFAULT_MARGINS: {
|
|
|
10
10
|
};
|
|
11
11
|
export declare const DEFAULT_AXIS_SIZE_WIDTH = 45;
|
|
12
12
|
export declare const DEFAULT_AXIS_SIZE_HEIGHT = 25;
|
|
13
|
-
export declare const AXIS_LABEL_DEFAULT_HEIGHT = 20;
|
|
13
|
+
export declare const AXIS_LABEL_DEFAULT_HEIGHT = 20;
|
|
14
|
+
/** Font size the axes render their tick labels with, unless `tickLabelStyle` overrides it. */
|
|
15
|
+
export declare const DEFAULT_TICK_LABEL_FONT_SIZE = 12;
|
package/constants/index.d.ts
CHANGED
|
@@ -10,4 +10,6 @@ export declare const DEFAULT_MARGINS: {
|
|
|
10
10
|
};
|
|
11
11
|
export declare const DEFAULT_AXIS_SIZE_WIDTH = 45;
|
|
12
12
|
export declare const DEFAULT_AXIS_SIZE_HEIGHT = 25;
|
|
13
|
-
export declare const AXIS_LABEL_DEFAULT_HEIGHT = 20;
|
|
13
|
+
export declare const AXIS_LABEL_DEFAULT_HEIGHT = 20;
|
|
14
|
+
/** Font size the axes render their tick labels with, unless `tickLabelStyle` overrides it. */
|
|
15
|
+
export declare const DEFAULT_TICK_LABEL_FONT_SIZE = 12;
|
package/constants/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.DEFAULT_Y_AXIS_KEY = exports.DEFAULT_X_AXIS_KEY = exports.DEFAULT_ROTATION_AXIS_KEY = exports.DEFAULT_RADIUS_AXIS_KEY = exports.DEFAULT_MARGINS = exports.DEFAULT_AXIS_SIZE_WIDTH = exports.DEFAULT_AXIS_SIZE_HEIGHT = exports.AXIS_LABEL_DEFAULT_HEIGHT = void 0;
|
|
6
|
+
exports.DEFAULT_Y_AXIS_KEY = exports.DEFAULT_X_AXIS_KEY = exports.DEFAULT_TICK_LABEL_FONT_SIZE = exports.DEFAULT_ROTATION_AXIS_KEY = exports.DEFAULT_RADIUS_AXIS_KEY = exports.DEFAULT_MARGINS = exports.DEFAULT_AXIS_SIZE_WIDTH = exports.DEFAULT_AXIS_SIZE_HEIGHT = exports.AXIS_LABEL_DEFAULT_HEIGHT = void 0;
|
|
7
7
|
const DEFAULT_X_AXIS_KEY = exports.DEFAULT_X_AXIS_KEY = 'DEFAULT_X_AXIS_KEY';
|
|
8
8
|
const DEFAULT_Y_AXIS_KEY = exports.DEFAULT_Y_AXIS_KEY = 'DEFAULT_Y_AXIS_KEY';
|
|
9
9
|
const DEFAULT_ROTATION_AXIS_KEY = exports.DEFAULT_ROTATION_AXIS_KEY = 'DEFAULT_ROTATION_AXIS_KEY';
|
|
@@ -16,4 +16,7 @@ const DEFAULT_MARGINS = exports.DEFAULT_MARGINS = {
|
|
|
16
16
|
};
|
|
17
17
|
const DEFAULT_AXIS_SIZE_WIDTH = exports.DEFAULT_AXIS_SIZE_WIDTH = 45;
|
|
18
18
|
const DEFAULT_AXIS_SIZE_HEIGHT = exports.DEFAULT_AXIS_SIZE_HEIGHT = 25;
|
|
19
|
-
const AXIS_LABEL_DEFAULT_HEIGHT = exports.AXIS_LABEL_DEFAULT_HEIGHT = 20;
|
|
19
|
+
const AXIS_LABEL_DEFAULT_HEIGHT = exports.AXIS_LABEL_DEFAULT_HEIGHT = 20;
|
|
20
|
+
|
|
21
|
+
/** Font size the axes render their tick labels with, unless `tickLabelStyle` overrides it. */
|
|
22
|
+
const DEFAULT_TICK_LABEL_FONT_SIZE = exports.DEFAULT_TICK_LABEL_FONT_SIZE = 12;
|
package/constants/index.mjs
CHANGED
|
@@ -10,4 +10,7 @@ export const DEFAULT_MARGINS = {
|
|
|
10
10
|
};
|
|
11
11
|
export const DEFAULT_AXIS_SIZE_WIDTH = 45;
|
|
12
12
|
export const DEFAULT_AXIS_SIZE_HEIGHT = 25;
|
|
13
|
-
export const AXIS_LABEL_DEFAULT_HEIGHT = 20;
|
|
13
|
+
export const AXIS_LABEL_DEFAULT_HEIGHT = 20;
|
|
14
|
+
|
|
15
|
+
/** Font size the axes render their tick labels with, unless `tickLabelStyle` overrides it. */
|
|
16
|
+
export const DEFAULT_TICK_LABEL_FONT_SIZE = 12;
|
|
@@ -3,5 +3,6 @@ export * from "./useAnimateArea.mjs";
|
|
|
3
3
|
export * from "./useAnimateBar.mjs";
|
|
4
4
|
export * from "./useAnimateBarLabel.mjs";
|
|
5
5
|
export * from "./useAnimateLine.mjs";
|
|
6
|
+
export * from "./useAnimateMark.mjs";
|
|
6
7
|
export * from "./useAnimatePieArc.mjs";
|
|
7
8
|
export * from "./useAnimatePieArcLabel.mjs";
|
|
@@ -3,5 +3,6 @@ export * from "./useAnimateArea.js";
|
|
|
3
3
|
export * from "./useAnimateBar.js";
|
|
4
4
|
export * from "./useAnimateBarLabel.js";
|
|
5
5
|
export * from "./useAnimateLine.js";
|
|
6
|
+
export * from "./useAnimateMark.js";
|
|
6
7
|
export * from "./useAnimatePieArc.js";
|
|
7
8
|
export * from "./useAnimatePieArcLabel.js";
|
package/hooks/animation/index.js
CHANGED
|
@@ -58,6 +58,17 @@ Object.keys(_useAnimateLine).forEach(function (key) {
|
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
|
+
var _useAnimateMark = require("./useAnimateMark");
|
|
62
|
+
Object.keys(_useAnimateMark).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _useAnimateMark[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _useAnimateMark[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
61
72
|
var _useAnimatePieArc = require("./useAnimatePieArc");
|
|
62
73
|
Object.keys(_useAnimatePieArc).forEach(function (key) {
|
|
63
74
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -3,5 +3,6 @@ export * from "./useAnimateArea.mjs";
|
|
|
3
3
|
export * from "./useAnimateBar.mjs";
|
|
4
4
|
export * from "./useAnimateBarLabel.mjs";
|
|
5
5
|
export * from "./useAnimateLine.mjs";
|
|
6
|
+
export * from "./useAnimateMark.mjs";
|
|
6
7
|
export * from "./useAnimatePieArc.mjs";
|
|
7
8
|
export * from "./useAnimatePieArcLabel.mjs";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
type UseAnimateMarkParams = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
skipAnimation?: boolean;
|
|
6
|
+
ref?: React.Ref<SVGPathElement>;
|
|
7
|
+
};
|
|
8
|
+
type UseAnimateMarkReturn = {
|
|
9
|
+
ref: React.Ref<SVGPathElement>;
|
|
10
|
+
transform: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Animates the position of a line chart mark.
|
|
14
|
+
*
|
|
15
|
+
* The mark is placed with the SVG `transform` attribute, in `viewBox` units, because Safari resolves CSS pixel
|
|
16
|
+
* transforms of SVG children against the viewport instead of the scaled `viewBox`, which moves the mark away from the
|
|
17
|
+
* line under browser zoom. See https://github.com/mui/mui-x/issues/23377.
|
|
18
|
+
*
|
|
19
|
+
* Safari cannot transition the `transform` attribute with CSS, so the animation runs in JavaScript.
|
|
20
|
+
*
|
|
21
|
+
* The props object also accepts a `ref` which will be merged with the ref returned from this hook. This means you can
|
|
22
|
+
* pass the ref returned by this hook to the `path` element and the `ref` provided as argument will also be called.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useAnimateMark(props: UseAnimateMarkParams): UseAnimateMarkReturn;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
type UseAnimateMarkParams = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
skipAnimation?: boolean;
|
|
6
|
+
ref?: React.Ref<SVGPathElement>;
|
|
7
|
+
};
|
|
8
|
+
type UseAnimateMarkReturn = {
|
|
9
|
+
ref: React.Ref<SVGPathElement>;
|
|
10
|
+
transform: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Animates the position of a line chart mark.
|
|
14
|
+
*
|
|
15
|
+
* The mark is placed with the SVG `transform` attribute, in `viewBox` units, because Safari resolves CSS pixel
|
|
16
|
+
* transforms of SVG children against the viewport instead of the scaled `viewBox`, which moves the mark away from the
|
|
17
|
+
* line under browser zoom. See https://github.com/mui/mui-x/issues/23377.
|
|
18
|
+
*
|
|
19
|
+
* Safari cannot transition the `transform` attribute with CSS, so the animation runs in JavaScript.
|
|
20
|
+
*
|
|
21
|
+
* The props object also accepts a `ref` which will be merged with the ref returned from this hook. This means you can
|
|
22
|
+
* pass the ref returned by this hook to the `path` element and the `ref` provided as argument will also be called.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useAnimateMark(props: UseAnimateMarkParams): UseAnimateMarkReturn;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useAnimateMark = useAnimateMark;
|
|
7
|
+
var _d3Interpolate = require("@mui/x-charts-vendor/d3-interpolate");
|
|
8
|
+
var _useAnimate = require("./useAnimate");
|
|
9
|
+
function markPropsInterpolator(from, to) {
|
|
10
|
+
const interpolateX = (0, _d3Interpolate.interpolateNumber)(from.x, to.x);
|
|
11
|
+
const interpolateY = (0, _d3Interpolate.interpolateNumber)(from.y, to.y);
|
|
12
|
+
return t => ({
|
|
13
|
+
x: interpolateX(t),
|
|
14
|
+
y: interpolateY(t)
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Animates the position of a line chart mark.
|
|
20
|
+
*
|
|
21
|
+
* The mark is placed with the SVG `transform` attribute, in `viewBox` units, because Safari resolves CSS pixel
|
|
22
|
+
* transforms of SVG children against the viewport instead of the scaled `viewBox`, which moves the mark away from the
|
|
23
|
+
* line under browser zoom. See https://github.com/mui/mui-x/issues/23377.
|
|
24
|
+
*
|
|
25
|
+
* Safari cannot transition the `transform` attribute with CSS, so the animation runs in JavaScript.
|
|
26
|
+
*
|
|
27
|
+
* The props object also accepts a `ref` which will be merged with the ref returned from this hook. This means you can
|
|
28
|
+
* pass the ref returned by this hook to the `path` element and the `ref` provided as argument will also be called.
|
|
29
|
+
*/
|
|
30
|
+
function useAnimateMark(props) {
|
|
31
|
+
return (0, _useAnimate.useAnimate)({
|
|
32
|
+
x: props.x,
|
|
33
|
+
y: props.y
|
|
34
|
+
}, {
|
|
35
|
+
createInterpolator: markPropsInterpolator,
|
|
36
|
+
transformProps: p => ({
|
|
37
|
+
transform: `translate(${p.x} ${p.y})`
|
|
38
|
+
}),
|
|
39
|
+
applyProps(element, animatedProps) {
|
|
40
|
+
element.setAttribute('transform', animatedProps.transform);
|
|
41
|
+
},
|
|
42
|
+
skip: props.skipAnimation,
|
|
43
|
+
ref: props.ref
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { interpolateNumber } from '@mui/x-charts-vendor/d3-interpolate';
|
|
2
|
+
import { useAnimate } from "./useAnimate.mjs";
|
|
3
|
+
function markPropsInterpolator(from, to) {
|
|
4
|
+
const interpolateX = interpolateNumber(from.x, to.x);
|
|
5
|
+
const interpolateY = interpolateNumber(from.y, to.y);
|
|
6
|
+
return t => ({
|
|
7
|
+
x: interpolateX(t),
|
|
8
|
+
y: interpolateY(t)
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Animates the position of a line chart mark.
|
|
14
|
+
*
|
|
15
|
+
* The mark is placed with the SVG `transform` attribute, in `viewBox` units, because Safari resolves CSS pixel
|
|
16
|
+
* transforms of SVG children against the viewport instead of the scaled `viewBox`, which moves the mark away from the
|
|
17
|
+
* line under browser zoom. See https://github.com/mui/mui-x/issues/23377.
|
|
18
|
+
*
|
|
19
|
+
* Safari cannot transition the `transform` attribute with CSS, so the animation runs in JavaScript.
|
|
20
|
+
*
|
|
21
|
+
* The props object also accepts a `ref` which will be merged with the ref returned from this hook. This means you can
|
|
22
|
+
* pass the ref returned by this hook to the `path` element and the `ref` provided as argument will also be called.
|
|
23
|
+
*/
|
|
24
|
+
export function useAnimateMark(props) {
|
|
25
|
+
return useAnimate({
|
|
26
|
+
x: props.x,
|
|
27
|
+
y: props.y
|
|
28
|
+
}, {
|
|
29
|
+
createInterpolator: markPropsInterpolator,
|
|
30
|
+
transformProps: p => ({
|
|
31
|
+
transform: `translate(${p.x} ${p.y})`
|
|
32
|
+
}),
|
|
33
|
+
applyProps(element, animatedProps) {
|
|
34
|
+
element.setAttribute('transform', animatedProps.transform);
|
|
35
|
+
},
|
|
36
|
+
skip: props.skipAnimation,
|
|
37
|
+
ref: props.ref
|
|
38
|
+
});
|
|
39
|
+
}
|
package/index.js
CHANGED
package/index.mjs
CHANGED
|
@@ -12,6 +12,7 @@ var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
|
|
|
12
12
|
var _useChartId = require("../../../hooks/useChartId");
|
|
13
13
|
var _ChartsProvider = require("../../../context/ChartsProvider");
|
|
14
14
|
var _useDescription = require("./useDescription");
|
|
15
|
+
var _useZoomAnnouncement = require("./useZoomAnnouncement");
|
|
15
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
17
|
/**
|
|
17
18
|
* Make the proxy looks like a layer.
|
|
@@ -28,6 +29,19 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
28
29
|
pointerEvents: 'none'
|
|
29
30
|
};
|
|
30
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Keeps the live region out of sight without removing it from the accessibility tree.
|
|
34
|
+
*/
|
|
35
|
+
const liveRegionStyle = {
|
|
36
|
+
position: 'absolute',
|
|
37
|
+
width: 1,
|
|
38
|
+
height: 1,
|
|
39
|
+
overflow: 'hidden',
|
|
40
|
+
clipPath: 'inset(50%)',
|
|
41
|
+
whiteSpace: 'nowrap',
|
|
42
|
+
pointerEvents: 'none'
|
|
43
|
+
};
|
|
44
|
+
|
|
31
45
|
// The proxy is implemented by having two divs with the same content, and toggling the visibility of each one when the content changes.
|
|
32
46
|
// The idea is to imitate the behavior of the focus moving from a list element to another, but with the minimal number of DOM elements.
|
|
33
47
|
|
|
@@ -37,6 +51,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
37
51
|
*/
|
|
38
52
|
function ChartsAccessibilityProxy() {
|
|
39
53
|
const message = (0, _useDescription.useDescription)();
|
|
54
|
+
const zoomMessage = (0, _useZoomAnnouncement.useZoomAnnouncement)();
|
|
40
55
|
const chartId = (0, _useChartId.useChartId)();
|
|
41
56
|
const {
|
|
42
57
|
instance
|
|
@@ -99,13 +114,21 @@ function ChartsAccessibilityProxy() {
|
|
|
99
114
|
activeDiv.focus();
|
|
100
115
|
}
|
|
101
116
|
}, [message, chartId]);
|
|
102
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
117
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
118
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
119
|
+
role: "none"
|
|
120
|
+
// Stays focusable once an announcer child owns the tab stop, otherwise the browser would
|
|
121
|
+
// blur the root mid hand-off and the chart would look like it lost the focus.
|
|
122
|
+
,
|
|
123
|
+
tabIndex: message ? -1 : 0,
|
|
124
|
+
ref: handleRef,
|
|
125
|
+
style: fullSizeLayerStyle
|
|
126
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
127
|
+
role: "status",
|
|
128
|
+
"aria-live": "polite",
|
|
129
|
+
"aria-atomic": "true",
|
|
130
|
+
style: liveRegionStyle,
|
|
131
|
+
children: zoomMessage
|
|
132
|
+
})]
|
|
110
133
|
});
|
|
111
134
|
}
|
|
@@ -5,12 +5,13 @@ import useForkRef from '@mui/utils/useForkRef';
|
|
|
5
5
|
import { useChartId } from "../../../hooks/useChartId.mjs";
|
|
6
6
|
import { useChartsContext } from "../../../context/ChartsProvider/index.mjs";
|
|
7
7
|
import { useDescription } from "./useDescription.mjs";
|
|
8
|
+
import { useZoomAnnouncement } from "./useZoomAnnouncement.mjs";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Make the proxy looks like a layer.
|
|
11
12
|
* Having a non-zero size is important for some screen readers to announce the content.
|
|
12
13
|
*/
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
15
|
const fullSizeLayerStyle = {
|
|
15
16
|
borderWidth: 0,
|
|
16
17
|
width: '100%',
|
|
@@ -23,6 +24,19 @@ const fullSizeLayerStyle = {
|
|
|
23
24
|
pointerEvents: 'none'
|
|
24
25
|
};
|
|
25
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Keeps the live region out of sight without removing it from the accessibility tree.
|
|
29
|
+
*/
|
|
30
|
+
const liveRegionStyle = {
|
|
31
|
+
position: 'absolute',
|
|
32
|
+
width: 1,
|
|
33
|
+
height: 1,
|
|
34
|
+
overflow: 'hidden',
|
|
35
|
+
clipPath: 'inset(50%)',
|
|
36
|
+
whiteSpace: 'nowrap',
|
|
37
|
+
pointerEvents: 'none'
|
|
38
|
+
};
|
|
39
|
+
|
|
26
40
|
// The proxy is implemented by having two divs with the same content, and toggling the visibility of each one when the content changes.
|
|
27
41
|
// The idea is to imitate the behavior of the focus moving from a list element to another, but with the minimal number of DOM elements.
|
|
28
42
|
|
|
@@ -32,6 +46,7 @@ const fullSizeLayerStyle = {
|
|
|
32
46
|
*/
|
|
33
47
|
export function ChartsAccessibilityProxy() {
|
|
34
48
|
const message = useDescription();
|
|
49
|
+
const zoomMessage = useZoomAnnouncement();
|
|
35
50
|
const chartId = useChartId();
|
|
36
51
|
const {
|
|
37
52
|
instance
|
|
@@ -94,13 +109,21 @@ export function ChartsAccessibilityProxy() {
|
|
|
94
109
|
activeDiv.focus();
|
|
95
110
|
}
|
|
96
111
|
}, [message, chartId]);
|
|
97
|
-
return /*#__PURE__*/
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
112
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
113
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
114
|
+
role: "none"
|
|
115
|
+
// Stays focusable once an announcer child owns the tab stop, otherwise the browser would
|
|
116
|
+
// blur the root mid hand-off and the chart would look like it lost the focus.
|
|
117
|
+
,
|
|
118
|
+
tabIndex: message ? -1 : 0,
|
|
119
|
+
ref: handleRef,
|
|
120
|
+
style: fullSizeLayerStyle
|
|
121
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
122
|
+
role: "status",
|
|
123
|
+
"aria-live": "polite",
|
|
124
|
+
"aria-atomic": "true",
|
|
125
|
+
style: liveRegionStyle,
|
|
126
|
+
children: zoomMessage
|
|
127
|
+
})]
|
|
105
128
|
});
|
|
106
129
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the message announcing the visible range of the zoomable axes.
|
|
3
|
+
*
|
|
4
|
+
* The message is taken when the keyboard zoom and pan asks for it, not derived from the zoom
|
|
5
|
+
* itself: the zoom also moves on wheel, drag, and from the application, and the live region must
|
|
6
|
+
* stay silent then.
|
|
7
|
+
* @returns {string | null} the message to announce, or `null` when there is nothing to announce
|
|
8
|
+
*/
|
|
9
|
+
export declare function useZoomAnnouncement(): string | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the message announcing the visible range of the zoomable axes.
|
|
3
|
+
*
|
|
4
|
+
* The message is taken when the keyboard zoom and pan asks for it, not derived from the zoom
|
|
5
|
+
* itself: the zoom also moves on wheel, drag, and from the application, and the live region must
|
|
6
|
+
* stay silent then.
|
|
7
|
+
* @returns {string | null} the message to announce, or `null` when there is nothing to announce
|
|
8
|
+
*/
|
|
9
|
+
export declare function useZoomAnnouncement(): string | null;
|
|
@@ -0,0 +1,67 @@
|
|
|
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.useZoomAnnouncement = useZoomAnnouncement;
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _hooks = require("../../../hooks");
|
|
11
|
+
var _useStore = require("../../store/useStore");
|
|
12
|
+
var _useChartKeyboardNavigation = require("../../plugins/featurePlugins/useChartKeyboardNavigation");
|
|
13
|
+
var _useChartCartesianAxis = require("../../plugins/featurePlugins/useChartCartesianAxis");
|
|
14
|
+
/**
|
|
15
|
+
* Get the message announcing the visible range of the zoomable axes.
|
|
16
|
+
*
|
|
17
|
+
* The message is taken when the keyboard zoom and pan asks for it, not derived from the zoom
|
|
18
|
+
* itself: the zoom also moves on wheel, drag, and from the application, and the live region must
|
|
19
|
+
* stay silent then.
|
|
20
|
+
* @returns {string | null} the message to announce, or `null` when there is nothing to announce
|
|
21
|
+
*/
|
|
22
|
+
function useZoomAnnouncement() {
|
|
23
|
+
const store = (0, _useStore.useStore)();
|
|
24
|
+
const announcement = store.use(_useChartKeyboardNavigation.selectorChartsZoomAnnouncement);
|
|
25
|
+
const zoomMap = store.use(_useChartCartesianAxis.selectorChartZoomMap);
|
|
26
|
+
const optionsLookup = store.use(_useChartCartesianAxis.selectorChartZoomOptionsLookup);
|
|
27
|
+
const {
|
|
28
|
+
localeText
|
|
29
|
+
} = (0, _hooks.useChartsLocalization)();
|
|
30
|
+
const [message, setMessage] = React.useState(null);
|
|
31
|
+
|
|
32
|
+
// The announcement is written from the values of the render the request lands on, so a later
|
|
33
|
+
// zoom coming from elsewhere does not rewrite the live region.
|
|
34
|
+
const currentValuesRef = React.useRef({
|
|
35
|
+
zoomMap,
|
|
36
|
+
optionsLookup,
|
|
37
|
+
localeText
|
|
38
|
+
});
|
|
39
|
+
currentValuesRef.current = {
|
|
40
|
+
zoomMap,
|
|
41
|
+
optionsLookup,
|
|
42
|
+
localeText
|
|
43
|
+
};
|
|
44
|
+
React.useEffect(() => {
|
|
45
|
+
if (announcement === 0) {
|
|
46
|
+
setMessage(null);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const current = currentValuesRef.current;
|
|
50
|
+
if (!current.zoomMap) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const descriptions = Object.values(current.optionsLookup).map(options => {
|
|
54
|
+
const zoomData = current.zoomMap.get(options.axisId);
|
|
55
|
+
if (!zoomData) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
return current.localeText.zoomRangeDescription({
|
|
59
|
+
axisDirection: options.axisDirection,
|
|
60
|
+
start: zoomData.start,
|
|
61
|
+
end: zoomData.end
|
|
62
|
+
});
|
|
63
|
+
}).filter(Boolean);
|
|
64
|
+
setMessage(descriptions.length === 0 ? null : descriptions.join(current.localeText.a11yConnector));
|
|
65
|
+
}, [announcement]);
|
|
66
|
+
return message;
|
|
67
|
+
}
|