@mui/x-charts 9.10.1 → 9.11.1
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 +4 -2
- package/BarChart/BarChart.mjs +4 -2
- package/BarChart/BarPlot.d.mts +3 -3
- package/BarChart/BarPlot.d.ts +3 -3
- package/BarChart/BarPlot.js +1 -1
- package/BarChart/BarPlot.mjs +1 -1
- package/BarChart/BatchBarPlot/BatchBarPlot.d.mts +2 -2
- package/BarChart/BatchBarPlot/BatchBarPlot.d.ts +2 -2
- package/BarChart/IndividualBarPlot.d.mts +2 -2
- package/BarChart/IndividualBarPlot.d.ts +2 -2
- package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.mts +4 -4
- package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +4 -4
- package/BarChart/useRegisterItemClickHandlers.d.mts +2 -1
- package/BarChart/useRegisterItemClickHandlers.d.ts +2 -1
- package/BarChart/useRegisterItemClickHandlers.js +8 -0
- package/BarChart/useRegisterItemClickHandlers.mjs +8 -1
- package/CHANGELOG.md +157 -0
- package/ChartsContainer/ChartsContainer.js +4 -2
- package/ChartsContainer/ChartsContainer.mjs +4 -2
- package/ChartsDataProvider/ChartsDataProvider.js +3 -1
- package/ChartsDataProvider/ChartsDataProvider.mjs +3 -1
- package/ChartsRadialDataProvider/ChartsRadialDataProvider.js +3 -1
- package/ChartsRadialDataProvider/ChartsRadialDataProvider.mjs +3 -1
- package/ChartsXAxis/useAxisTicksProps.d.mts +101 -101
- package/ChartsXAxis/useAxisTicksProps.d.ts +101 -101
- package/ChartsYAxis/useAxisTicksProps.d.mts +101 -101
- package/ChartsYAxis/useAxisTicksProps.d.ts +101 -101
- package/LineChart/AreaPlot.d.mts +3 -2
- package/LineChart/AreaPlot.d.ts +3 -2
- package/LineChart/AreaPlot.js +8 -2
- package/LineChart/AreaPlot.mjs +9 -3
- package/LineChart/LineChart.js +2 -1
- package/LineChart/LineChart.mjs +2 -1
- package/LineChart/LinePlot.d.mts +3 -2
- package/LineChart/LinePlot.d.ts +3 -2
- package/LineChart/LinePlot.js +2 -2
- package/LineChart/LinePlot.mjs +3 -3
- package/LineChart/MarkPlot.d.mts +5 -4
- package/LineChart/MarkPlot.d.ts +5 -4
- package/LineChart/MarkPlot.js +17 -8
- package/LineChart/MarkPlot.mjs +17 -8
- package/LineChart/useLineItemClickHandler.d.mts +25 -1
- package/LineChart/useLineItemClickHandler.d.ts +25 -1
- package/LineChart/useLineItemClickHandler.js +48 -1
- package/LineChart/useLineItemClickHandler.mjs +47 -1
- package/PieChart/PieArcPlot.d.mts +3 -2
- package/PieChart/PieArcPlot.d.ts +3 -2
- package/PieChart/PieArcPlot.js +16 -1
- package/PieChart/PieArcPlot.mjs +16 -1
- package/PieChart/PieChart.js +3 -1
- package/PieChart/PieChart.mjs +3 -1
- package/PieChart/PiePlot.js +1 -1
- package/PieChart/PiePlot.mjs +1 -1
- package/README.md +1 -11
- package/RadarChart/RadarAxis/RadarAxis.utils.d.mts +1 -1
- package/RadarChart/RadarAxis/RadarAxis.utils.d.ts +1 -1
- package/RadarChart/RadarChart.js +3 -1
- package/RadarChart/RadarChart.mjs +3 -1
- package/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +3 -1
- package/RadarChart/RadarSeriesPlot/RadarSeriesArea.mjs +3 -1
- package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +4 -1
- package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.mjs +4 -1
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.mts +5 -4
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.ts +5 -4
- package/RadarChart/RadarSeriesPlot/useRegisterRadarItemActivation.d.mts +15 -0
- package/RadarChart/RadarSeriesPlot/useRegisterRadarItemActivation.d.ts +15 -0
- package/RadarChart/RadarSeriesPlot/useRegisterRadarItemActivation.js +32 -0
- package/RadarChart/RadarSeriesPlot/useRegisterRadarItemActivation.mjs +26 -0
- package/RadarChart/useRadarChartProps.js +5 -1
- package/RadarChart/useRadarChartProps.mjs +5 -1
- package/ScatterChart/Scatter.d.mts +3 -2
- package/ScatterChart/Scatter.d.ts +3 -2
- package/ScatterChart/Scatter.js +10 -1
- package/ScatterChart/Scatter.mjs +10 -1
- package/ScatterChart/ScatterChart.js +1 -0
- package/ScatterChart/ScatterChart.mjs +1 -0
- package/ScatterChart/async/ScatterAsync.js +9 -0
- package/ScatterChart/async/ScatterAsync.mjs +9 -0
- package/SparkLineChart/SparkLineChart.js +2 -1
- package/SparkLineChart/SparkLineChart.mjs +2 -1
- package/Toolbar/ToolbarButton.js +1 -1
- package/Toolbar/ToolbarButton.mjs +1 -1
- package/hooks/useFocusedItem.d.mts +1 -1
- package/hooks/useFocusedItem.d.ts +1 -1
- package/hooks/useItemHighlightStateGetter.d.mts +1 -1
- package/hooks/useItemHighlightStateGetter.d.ts +1 -1
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internals/createCommonKeyboardFocusHandler.d.mts +2 -2
- package/internals/createCommonKeyboardFocusHandler.d.ts +2 -2
- 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/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.mts +8 -1
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.ts +8 -1
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +11 -3
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.mjs +11 -3
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.mts +1 -0
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +1 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/getItemWithData.types.d.mts +12 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/getItemWithData.types.d.ts +12 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/getItemWithData.types.js +5 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/getItemWithData.types.mjs +1 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.d.mts +1 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.d.ts +1 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.js +11 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.mjs +1 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/seriesConfig.types.d.mts +6 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/seriesConfig.types.d.ts +6 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisClickPayload.d.mts +21 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisClickPayload.d.ts +21 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisClickPayload.js +46 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisClickPayload.mjs +40 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +13 -31
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.mjs +13 -31
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.mts +2 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +2 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.mts +11 -11
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +11 -11
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.mts +4 -4
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +4 -4
- package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +19 -0
- package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.mjs +19 -0
- package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.types.d.mts +5 -3
- package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.types.d.ts +5 -3
- package/internals/plugins/featurePlugins/useChartItemClick/useChartItemClick.js +15 -0
- package/internals/plugins/featurePlugins/useChartItemClick/useChartItemClick.mjs +14 -0
- package/internals/plugins/featurePlugins/useChartItemClick/useChartItemClick.types.d.mts +5 -2
- package/internals/plugins/featurePlugins/useChartItemClick/useChartItemClick.types.d.ts +5 -2
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.d.mts +2 -1
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.d.ts +2 -1
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.js +10 -2
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.mjs +2 -1
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/itemActivation.d.mts +13 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/itemActivation.d.ts +13 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/itemActivation.js +39 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/itemActivation.mjs +32 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +47 -7
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.mjs +47 -7
- 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 +3 -1
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.mjs +2 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.mts +39 -2
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +39 -2
- package/internals/plugins/featurePlugins/useChartPolarAxis/getPolarAxisClickPayload.d.mts +27 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/getPolarAxisClickPayload.d.ts +27 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/getPolarAxisClickPayload.js +36 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/getPolarAxisClickPayload.mjs +30 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +19 -20
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.mjs +19 -20
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.mts +2 -2
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +2 -2
- package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.mts +1 -1
- package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +1 -1
- package/internals/seriesSelectorOfType.d.mts +4 -4
- package/internals/seriesSelectorOfType.d.ts +4 -4
- package/internals/useRegisterItemActivation.d.mts +23 -0
- package/internals/useRegisterItemActivation.d.ts +23 -0
- package/internals/useRegisterItemActivation.js +53 -0
- package/internals/useRegisterItemActivation.mjs +46 -0
- package/models/axis.d.mts +1 -1
- package/models/axis.d.ts +1 -1
- package/models/events.d.mts +11 -0
- package/models/events.d.ts +11 -0
- package/models/events.js +5 -0
- package/models/events.mjs +1 -0
- package/models/index.d.mts +1 -0
- package/models/index.d.ts +1 -0
- package/moduleAugmentation/barChartBatchRendererOnItemClick.d.mts +3 -4
- package/moduleAugmentation/barChartBatchRendererOnItemClick.d.ts +3 -4
- package/moduleAugmentation/keyboardActivation.d.mts +7 -0
- package/moduleAugmentation/keyboardActivation.d.ts +7 -0
- package/moduleAugmentation/keyboardActivation.js +8 -0
- package/moduleAugmentation/keyboardActivation.mjs +2 -0
- package/package.json +18 -4
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'use client';
|
|
3
3
|
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.useChartItemClick = void 0;
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
10
|
var _getChartPoint = require("../../../getChartPoint");
|
|
9
11
|
const useChartItemClick = ({
|
|
10
12
|
params,
|
|
@@ -14,6 +16,19 @@ const useChartItemClick = ({
|
|
|
14
16
|
const {
|
|
15
17
|
onItemClick
|
|
16
18
|
} = params;
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
if (!onItemClick || !instance.registerItemActivationHandler) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
return instance.registerItemActivationHandler({}, (event, item) => {
|
|
24
|
+
const seriesTypeConfig = store.state.seriesConfig.config[item.type];
|
|
25
|
+
// @ts-ignore The type inference for store.state does not support generic yet
|
|
26
|
+
const itemWithData = seriesTypeConfig?.getItemWithData?.(store.state, item);
|
|
27
|
+
|
|
28
|
+
// The callback only describes the pointer event unless the user augments the types.
|
|
29
|
+
onItemClick(event, itemWithData ?? item);
|
|
30
|
+
});
|
|
31
|
+
}, [instance, onItemClick, store]);
|
|
17
32
|
if (!onItemClick) {
|
|
18
33
|
return {
|
|
19
34
|
instance: {}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import * as React from 'react';
|
|
3
4
|
import { getChartPoint } from "../../../getChartPoint.mjs";
|
|
4
5
|
export const useChartItemClick = ({
|
|
5
6
|
params,
|
|
@@ -9,6 +10,19 @@ export const useChartItemClick = ({
|
|
|
9
10
|
const {
|
|
10
11
|
onItemClick
|
|
11
12
|
} = params;
|
|
13
|
+
React.useEffect(() => {
|
|
14
|
+
if (!onItemClick || !instance.registerItemActivationHandler) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
return instance.registerItemActivationHandler({}, (event, item) => {
|
|
18
|
+
const seriesTypeConfig = store.state.seriesConfig.config[item.type];
|
|
19
|
+
// @ts-ignore The type inference for store.state does not support generic yet
|
|
20
|
+
const itemWithData = seriesTypeConfig?.getItemWithData?.(store.state, item);
|
|
21
|
+
|
|
22
|
+
// The callback only describes the pointer event unless the user augments the types.
|
|
23
|
+
onItemClick(event, itemWithData ?? item);
|
|
24
|
+
});
|
|
25
|
+
}, [instance, onItemClick, store]);
|
|
12
26
|
if (!onItemClick) {
|
|
13
27
|
return {
|
|
14
28
|
instance: {}
|
|
@@ -2,14 +2,16 @@ import type { ChartPluginSignature } from "../../models/index.mjs";
|
|
|
2
2
|
import type { ChartSeriesType } from "../../../../models/seriesType/config.mjs";
|
|
3
3
|
import type { SeriesItemIdentifierWithType } from "../../../../models/seriesType/index.mjs";
|
|
4
4
|
import type { ChartSeriesTypeRequiredPlugins } from "../../corePlugins/useChartSeriesConfig/index.mjs";
|
|
5
|
+
import type { UseChartKeyboardNavigationSignature } from "../useChartKeyboardNavigation/index.mjs";
|
|
6
|
+
import type { ChartsActivationEvent } from "../../../../models/events.mjs";
|
|
5
7
|
export interface UseChartItemClickParameters<SeriesType extends ChartSeriesType = ChartSeriesType> {
|
|
6
8
|
/**
|
|
7
9
|
* The callback fired when an item is clicked.
|
|
8
10
|
*
|
|
9
|
-
* @param {
|
|
11
|
+
* @param {ChartsActivationEvent<HTMLDivElement>} event The click event.
|
|
10
12
|
* @param {SeriesItemIdentifierWithType<SeriesType>} item The clicked item.
|
|
11
13
|
*/
|
|
12
|
-
onItemClick?: (event:
|
|
14
|
+
onItemClick?: (event: ChartsActivationEvent<HTMLDivElement>, item: SeriesItemIdentifierWithType<SeriesType>) => void;
|
|
13
15
|
}
|
|
14
16
|
export interface UseChartItemClickInstance {
|
|
15
17
|
handleClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
|
@@ -20,4 +22,5 @@ export type UseChartItemClickSignature<SeriesType extends ChartSeriesType = Char
|
|
|
20
22
|
defaultizedParams: UseChartItemClickParameters<SeriesType>;
|
|
21
23
|
instance: UseChartItemClickInstance;
|
|
22
24
|
dependencies: ChartSeriesTypeRequiredPlugins<SeriesType>;
|
|
25
|
+
optionalDependencies: [UseChartKeyboardNavigationSignature];
|
|
23
26
|
}>;
|
|
@@ -2,14 +2,16 @@ import type { ChartPluginSignature } from "../../models/index.js";
|
|
|
2
2
|
import type { ChartSeriesType } from "../../../../models/seriesType/config.js";
|
|
3
3
|
import type { SeriesItemIdentifierWithType } from "../../../../models/seriesType/index.js";
|
|
4
4
|
import type { ChartSeriesTypeRequiredPlugins } from "../../corePlugins/useChartSeriesConfig/index.js";
|
|
5
|
+
import type { UseChartKeyboardNavigationSignature } from "../useChartKeyboardNavigation/index.js";
|
|
6
|
+
import type { ChartsActivationEvent } from "../../../../models/events.js";
|
|
5
7
|
export interface UseChartItemClickParameters<SeriesType extends ChartSeriesType = ChartSeriesType> {
|
|
6
8
|
/**
|
|
7
9
|
* The callback fired when an item is clicked.
|
|
8
10
|
*
|
|
9
|
-
* @param {
|
|
11
|
+
* @param {ChartsActivationEvent<HTMLDivElement>} event The click event.
|
|
10
12
|
* @param {SeriesItemIdentifierWithType<SeriesType>} item The clicked item.
|
|
11
13
|
*/
|
|
12
|
-
onItemClick?: (event:
|
|
14
|
+
onItemClick?: (event: ChartsActivationEvent<HTMLDivElement>, item: SeriesItemIdentifierWithType<SeriesType>) => void;
|
|
13
15
|
}
|
|
14
16
|
export interface UseChartItemClickInstance {
|
|
15
17
|
handleClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
|
@@ -20,4 +22,5 @@ export type UseChartItemClickSignature<SeriesType extends ChartSeriesType = Char
|
|
|
20
22
|
defaultizedParams: UseChartItemClickParameters<SeriesType>;
|
|
21
23
|
instance: UseChartItemClickInstance;
|
|
22
24
|
dependencies: ChartSeriesTypeRequiredPlugins<SeriesType>;
|
|
25
|
+
optionalDependencies: [UseChartKeyboardNavigationSignature];
|
|
23
26
|
}>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { useChartKeyboardNavigation } from "./useChartKeyboardNavigation.mjs";
|
|
2
2
|
export * from "./useChartKeyboardNavigation.selectors.mjs";
|
|
3
|
-
export type { UseChartKeyboardNavigationSignature } from "./useChartKeyboardNavigation.types.mjs";
|
|
3
|
+
export type { UseChartKeyboardNavigationSignature, ItemActivationHandler, ItemActivationScope } from "./useChartKeyboardNavigation.types.mjs";
|
|
4
|
+
export { isItemActivationKey } from "./itemActivation.mjs";
|
|
4
5
|
export type * from "./keyboardFocusHandler.types.mjs";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { useChartKeyboardNavigation } from "./useChartKeyboardNavigation.js";
|
|
2
2
|
export * from "./useChartKeyboardNavigation.selectors.js";
|
|
3
|
-
export type { UseChartKeyboardNavigationSignature } from "./useChartKeyboardNavigation.types.js";
|
|
3
|
+
export type { UseChartKeyboardNavigationSignature, ItemActivationHandler, ItemActivationScope } from "./useChartKeyboardNavigation.types.js";
|
|
4
|
+
export { isItemActivationKey } from "./itemActivation.js";
|
|
4
5
|
export type * from "./keyboardFocusHandler.types.js";
|
|
@@ -4,8 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
|
-
useChartKeyboardNavigation: true
|
|
7
|
+
useChartKeyboardNavigation: true,
|
|
8
|
+
isItemActivationKey: true
|
|
8
9
|
};
|
|
10
|
+
Object.defineProperty(exports, "isItemActivationKey", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _itemActivation.isItemActivationKey;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
9
16
|
Object.defineProperty(exports, "useChartKeyboardNavigation", {
|
|
10
17
|
enumerable: true,
|
|
11
18
|
get: function () {
|
|
@@ -24,4 +31,5 @@ Object.keys(_useChartKeyboardNavigation2).forEach(function (key) {
|
|
|
24
31
|
return _useChartKeyboardNavigation2[key];
|
|
25
32
|
}
|
|
26
33
|
});
|
|
27
|
-
});
|
|
34
|
+
});
|
|
35
|
+
var _itemActivation = require("./itemActivation");
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FocusedItemIdentifier } from "../../../../models/seriesType/index.mjs";
|
|
2
|
+
import type { ChartSeriesType } from "../../../../models/seriesType/config.mjs";
|
|
3
|
+
import type { ItemActivationHandler, ItemActivationScope } from "./useChartKeyboardNavigation.types.mjs";
|
|
4
|
+
export type ItemActivationRegistration = {
|
|
5
|
+
scope: ItemActivationScope;
|
|
6
|
+
handler: ItemActivationHandler;
|
|
7
|
+
};
|
|
8
|
+
export declare function isItemActivationKey(event: KeyboardEvent): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the handler matching the item with the most specific scope, the highest priority
|
|
11
|
+
* breaking ties, or `null` when none matches.
|
|
12
|
+
*/
|
|
13
|
+
export declare function findItemActivationHandler(registrations: Iterable<ItemActivationRegistration>, item: FocusedItemIdentifier<ChartSeriesType>): ItemActivationHandler | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FocusedItemIdentifier } from "../../../../models/seriesType/index.js";
|
|
2
|
+
import type { ChartSeriesType } from "../../../../models/seriesType/config.js";
|
|
3
|
+
import type { ItemActivationHandler, ItemActivationScope } from "./useChartKeyboardNavigation.types.js";
|
|
4
|
+
export type ItemActivationRegistration = {
|
|
5
|
+
scope: ItemActivationScope;
|
|
6
|
+
handler: ItemActivationHandler;
|
|
7
|
+
};
|
|
8
|
+
export declare function isItemActivationKey(event: KeyboardEvent): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the handler matching the item with the most specific scope, the highest priority
|
|
11
|
+
* breaking ties, or `null` when none matches.
|
|
12
|
+
*/
|
|
13
|
+
export declare function findItemActivationHandler(registrations: Iterable<ItemActivationRegistration>, item: FocusedItemIdentifier<ChartSeriesType>): ItemActivationHandler | null;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.findItemActivationHandler = findItemActivationHandler;
|
|
7
|
+
exports.isItemActivationKey = isItemActivationKey;
|
|
8
|
+
function isItemActivationKey(event) {
|
|
9
|
+
return event.key === 'Enter' || event.key === ' ';
|
|
10
|
+
}
|
|
11
|
+
function getScopeSpecificity(scope, item) {
|
|
12
|
+
if (scope.type !== undefined && scope.type !== item.type) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
if (scope.seriesId !== undefined && (!('seriesId' in item) || scope.seriesId !== item.seriesId)) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return (scope.type === undefined ? 0 : 1) + (scope.seriesId === undefined ? 0 : 1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Returns the handler matching the item with the most specific scope, the highest priority
|
|
23
|
+
* breaking ties, or `null` when none matches.
|
|
24
|
+
*/
|
|
25
|
+
function findItemActivationHandler(registrations, item) {
|
|
26
|
+
let bestHandler = null;
|
|
27
|
+
let bestSpecificity = -1;
|
|
28
|
+
let bestPriority = -1;
|
|
29
|
+
for (const registration of registrations) {
|
|
30
|
+
const specificity = getScopeSpecificity(registration.scope, item);
|
|
31
|
+
const priority = registration.scope.priority ?? 0;
|
|
32
|
+
if (specificity !== null && (registration.scope.canActivate === undefined || registration.scope.canActivate(item)) && (specificity > bestSpecificity || specificity === bestSpecificity && priority > bestPriority)) {
|
|
33
|
+
bestHandler = registration.handler;
|
|
34
|
+
bestSpecificity = specificity;
|
|
35
|
+
bestPriority = priority;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return bestHandler;
|
|
39
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function isItemActivationKey(event) {
|
|
2
|
+
return event.key === 'Enter' || event.key === ' ';
|
|
3
|
+
}
|
|
4
|
+
function getScopeSpecificity(scope, item) {
|
|
5
|
+
if (scope.type !== undefined && scope.type !== item.type) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
if (scope.seriesId !== undefined && (!('seriesId' in item) || scope.seriesId !== item.seriesId)) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
return (scope.type === undefined ? 0 : 1) + (scope.seriesId === undefined ? 0 : 1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Returns the handler matching the item with the most specific scope, the highest priority
|
|
16
|
+
* breaking ties, or `null` when none matches.
|
|
17
|
+
*/
|
|
18
|
+
export function findItemActivationHandler(registrations, item) {
|
|
19
|
+
let bestHandler = null;
|
|
20
|
+
let bestSpecificity = -1;
|
|
21
|
+
let bestPriority = -1;
|
|
22
|
+
for (const registration of registrations) {
|
|
23
|
+
const specificity = getScopeSpecificity(registration.scope, item);
|
|
24
|
+
const priority = registration.scope.priority ?? 0;
|
|
25
|
+
if (specificity !== null && (registration.scope.canActivate === undefined || registration.scope.canActivate(item)) && (specificity > bestSpecificity || specificity === bestSpecificity && priority > bestPriority)) {
|
|
26
|
+
bestHandler = registration.handler;
|
|
27
|
+
bestSpecificity = specificity;
|
|
28
|
+
bestPriority = priority;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return bestHandler;
|
|
32
|
+
}
|
package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js
CHANGED
|
@@ -12,6 +12,8 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
12
12
|
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
13
13
|
var _useChartSeries = require("../../corePlugins/useChartSeries/useChartSeries.selectors");
|
|
14
14
|
var _useChartSeriesConfig = require("../../corePlugins/useChartSeriesConfig");
|
|
15
|
+
var _itemActivation = require("./itemActivation");
|
|
16
|
+
var _useChartKeyboardNavigation = require("./useChartKeyboardNavigation.selectors");
|
|
15
17
|
const useChartKeyboardNavigation = ({
|
|
16
18
|
params,
|
|
17
19
|
store,
|
|
@@ -20,6 +22,20 @@ const useChartKeyboardNavigation = ({
|
|
|
20
22
|
const {
|
|
21
23
|
chartsLayerContainerRef
|
|
22
24
|
} = instance;
|
|
25
|
+
const activationRegistrationsRef = React.useRef(new Map());
|
|
26
|
+
const nextRegistrationIdRef = React.useRef(0);
|
|
27
|
+
const registerItemActivationHandler = React.useCallback((scope, handler) => {
|
|
28
|
+
const registrationId = nextRegistrationIdRef.current;
|
|
29
|
+
nextRegistrationIdRef.current += 1;
|
|
30
|
+
const registrations = activationRegistrationsRef.current;
|
|
31
|
+
registrations.set(registrationId, {
|
|
32
|
+
scope,
|
|
33
|
+
handler
|
|
34
|
+
});
|
|
35
|
+
return () => {
|
|
36
|
+
registrations.delete(registrationId);
|
|
37
|
+
};
|
|
38
|
+
}, []);
|
|
23
39
|
React.useEffect(() => {
|
|
24
40
|
const element = chartsLayerContainerRef.current;
|
|
25
41
|
if (!element || params.disableKeyboardNavigation) {
|
|
@@ -31,12 +47,14 @@ const useChartKeyboardNavigation = ({
|
|
|
31
47
|
|
|
32
48
|
// Avoid removing focus if we know it is moving to another children in the chart.
|
|
33
49
|
// This avoid extra computation ot remove/add focus at each keyboard pressed when navigating in the chart.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
50
|
+
// A null relatedTarget means focus left to a non-focusable element (clicking outside), so focus is removed.
|
|
51
|
+
if (root && next !== null && root.contains(next)) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (store.state.keyboardNavigation.isFocused) {
|
|
55
|
+
store.set('keyboardNavigation', (0, _extends2.default)({}, store.state.keyboardNavigation, {
|
|
56
|
+
isFocused: false
|
|
57
|
+
}));
|
|
40
58
|
}
|
|
41
59
|
}
|
|
42
60
|
function restoreFocus() {
|
|
@@ -56,6 +74,22 @@ const useChartKeyboardNavigation = ({
|
|
|
56
74
|
}));
|
|
57
75
|
}
|
|
58
76
|
}
|
|
77
|
+
function activationHandler(event) {
|
|
78
|
+
// Ignore the auto-repeat while the key is held: a pointer click does not repeat either.
|
|
79
|
+
if (event.repeat || !(0, _itemActivation.isItemActivationKey)(event) || !(0, _useChartKeyboardNavigation.selectorChartsIsKeyboardActivationEnabled)(store.state)) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const focusedItem = store.state.keyboardNavigation.item;
|
|
83
|
+
if (focusedItem === null || !store.state.keyboardNavigation.isFocused) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const handler = (0, _itemActivation.findItemActivationHandler)(activationRegistrationsRef.current.values(), focusedItem);
|
|
87
|
+
if (handler === null) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
event.preventDefault();
|
|
91
|
+
handler(event, focusedItem);
|
|
92
|
+
}
|
|
59
93
|
function keyboardHandler(event) {
|
|
60
94
|
let newFocusedItem = store.state.keyboardNavigation.item;
|
|
61
95
|
const seriesConfig = (0, _useChartSeriesConfig.selectorChartSeriesConfig)(store.state);
|
|
@@ -88,10 +122,12 @@ const useChartKeyboardNavigation = ({
|
|
|
88
122
|
}));
|
|
89
123
|
}
|
|
90
124
|
}
|
|
125
|
+
element.addEventListener('keydown', activationHandler);
|
|
91
126
|
element.addEventListener('keydown', keyboardHandler);
|
|
92
127
|
element.addEventListener('focusout', removeFocus);
|
|
93
128
|
element.addEventListener('focusin', restoreFocus);
|
|
94
129
|
return () => {
|
|
130
|
+
element.removeEventListener('keydown', activationHandler);
|
|
95
131
|
element.removeEventListener('keydown', keyboardHandler);
|
|
96
132
|
element.removeEventListener('focusout', removeFocus);
|
|
97
133
|
element.removeEventListener('focusin', restoreFocus);
|
|
@@ -102,7 +138,11 @@ const useChartKeyboardNavigation = ({
|
|
|
102
138
|
enabled: !params.disableKeyboardNavigation
|
|
103
139
|
}));
|
|
104
140
|
}, [store, params.disableKeyboardNavigation]);
|
|
105
|
-
return {
|
|
141
|
+
return {
|
|
142
|
+
instance: {
|
|
143
|
+
registerItemActivationHandler
|
|
144
|
+
}
|
|
145
|
+
};
|
|
106
146
|
};
|
|
107
147
|
exports.useChartKeyboardNavigation = useChartKeyboardNavigation;
|
|
108
148
|
useChartKeyboardNavigation.getInitialState = params => ({
|
package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.mjs
CHANGED
|
@@ -5,6 +5,8 @@ import * as React from 'react';
|
|
|
5
5
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
6
6
|
import { selectorChartDefaultizedSeries } from "../../corePlugins/useChartSeries/useChartSeries.selectors.mjs";
|
|
7
7
|
import { selectorChartSeriesConfig } from "../../corePlugins/useChartSeriesConfig/index.mjs";
|
|
8
|
+
import { findItemActivationHandler, isItemActivationKey } from "./itemActivation.mjs";
|
|
9
|
+
import { selectorChartsIsKeyboardActivationEnabled } from "./useChartKeyboardNavigation.selectors.mjs";
|
|
8
10
|
export const useChartKeyboardNavigation = ({
|
|
9
11
|
params,
|
|
10
12
|
store,
|
|
@@ -13,6 +15,20 @@ export const useChartKeyboardNavigation = ({
|
|
|
13
15
|
const {
|
|
14
16
|
chartsLayerContainerRef
|
|
15
17
|
} = instance;
|
|
18
|
+
const activationRegistrationsRef = React.useRef(new Map());
|
|
19
|
+
const nextRegistrationIdRef = React.useRef(0);
|
|
20
|
+
const registerItemActivationHandler = React.useCallback((scope, handler) => {
|
|
21
|
+
const registrationId = nextRegistrationIdRef.current;
|
|
22
|
+
nextRegistrationIdRef.current += 1;
|
|
23
|
+
const registrations = activationRegistrationsRef.current;
|
|
24
|
+
registrations.set(registrationId, {
|
|
25
|
+
scope,
|
|
26
|
+
handler
|
|
27
|
+
});
|
|
28
|
+
return () => {
|
|
29
|
+
registrations.delete(registrationId);
|
|
30
|
+
};
|
|
31
|
+
}, []);
|
|
16
32
|
React.useEffect(() => {
|
|
17
33
|
const element = chartsLayerContainerRef.current;
|
|
18
34
|
if (!element || params.disableKeyboardNavigation) {
|
|
@@ -24,12 +40,14 @@ export const useChartKeyboardNavigation = ({
|
|
|
24
40
|
|
|
25
41
|
// Avoid removing focus if we know it is moving to another children in the chart.
|
|
26
42
|
// This avoid extra computation ot remove/add focus at each keyboard pressed when navigating in the chart.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
43
|
+
// A null relatedTarget means focus left to a non-focusable element (clicking outside), so focus is removed.
|
|
44
|
+
if (root && next !== null && root.contains(next)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (store.state.keyboardNavigation.isFocused) {
|
|
48
|
+
store.set('keyboardNavigation', _extends({}, store.state.keyboardNavigation, {
|
|
49
|
+
isFocused: false
|
|
50
|
+
}));
|
|
33
51
|
}
|
|
34
52
|
}
|
|
35
53
|
function restoreFocus() {
|
|
@@ -49,6 +67,22 @@ export const useChartKeyboardNavigation = ({
|
|
|
49
67
|
}));
|
|
50
68
|
}
|
|
51
69
|
}
|
|
70
|
+
function activationHandler(event) {
|
|
71
|
+
// Ignore the auto-repeat while the key is held: a pointer click does not repeat either.
|
|
72
|
+
if (event.repeat || !isItemActivationKey(event) || !selectorChartsIsKeyboardActivationEnabled(store.state)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const focusedItem = store.state.keyboardNavigation.item;
|
|
76
|
+
if (focusedItem === null || !store.state.keyboardNavigation.isFocused) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const handler = findItemActivationHandler(activationRegistrationsRef.current.values(), focusedItem);
|
|
80
|
+
if (handler === null) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
event.preventDefault();
|
|
84
|
+
handler(event, focusedItem);
|
|
85
|
+
}
|
|
52
86
|
function keyboardHandler(event) {
|
|
53
87
|
let newFocusedItem = store.state.keyboardNavigation.item;
|
|
54
88
|
const seriesConfig = selectorChartSeriesConfig(store.state);
|
|
@@ -81,10 +115,12 @@ export const useChartKeyboardNavigation = ({
|
|
|
81
115
|
}));
|
|
82
116
|
}
|
|
83
117
|
}
|
|
118
|
+
element.addEventListener('keydown', activationHandler);
|
|
84
119
|
element.addEventListener('keydown', keyboardHandler);
|
|
85
120
|
element.addEventListener('focusout', removeFocus);
|
|
86
121
|
element.addEventListener('focusin', restoreFocus);
|
|
87
122
|
return () => {
|
|
123
|
+
element.removeEventListener('keydown', activationHandler);
|
|
88
124
|
element.removeEventListener('keydown', keyboardHandler);
|
|
89
125
|
element.removeEventListener('focusout', removeFocus);
|
|
90
126
|
element.removeEventListener('focusin', restoreFocus);
|
|
@@ -95,7 +131,11 @@ export const useChartKeyboardNavigation = ({
|
|
|
95
131
|
enabled: !params.disableKeyboardNavigation
|
|
96
132
|
}));
|
|
97
133
|
}, [store, params.disableKeyboardNavigation]);
|
|
98
|
-
return {
|
|
134
|
+
return {
|
|
135
|
+
instance: {
|
|
136
|
+
registerItemActivationHandler
|
|
137
|
+
}
|
|
138
|
+
};
|
|
99
139
|
};
|
|
100
140
|
useChartKeyboardNavigation.getInitialState = params => ({
|
|
101
141
|
keyboardNavigation: {
|
|
@@ -20,6 +20,9 @@ export declare const selectorChartsFocusedOrToFocusedItem: (args_0: import("../.
|
|
|
20
20
|
export declare const selectorChartsIsKeyboardNavigationEnabled: (args_0: import("../../corePlugins/useChartId/useChartId.types.mjs").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.mjs").UseChartSeriesConfigState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.mjs").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.mjs").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.mjs").UseChartSeriesState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.mjs").UseChartAnimationState & import("../../../index.mjs").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.mjs").UseChartKeyboardNavigationState> & {
|
|
21
21
|
cacheKey: import("../../models/index.mjs").ChartStateCacheKey;
|
|
22
22
|
}) => boolean;
|
|
23
|
+
export declare const selectorChartsIsKeyboardActivationEnabled: (args_0: import("../../corePlugins/useChartId/useChartId.types.mjs").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.mjs").UseChartSeriesConfigState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.mjs").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.mjs").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.mjs").UseChartSeriesState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.mjs").UseChartAnimationState & import("../../../index.mjs").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.mjs").UseChartKeyboardNavigationState> & {
|
|
24
|
+
cacheKey: import("../../models/index.mjs").ChartStateCacheKey;
|
|
25
|
+
}) => boolean;
|
|
23
26
|
export declare const selectorChartsKeyboardXAxisIndex: (args_0: import("../../corePlugins/useChartId/useChartId.types.mjs").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.mjs").UseChartSeriesConfigState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.mjs").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.mjs").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.mjs").UseChartSeriesState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.mjs").UseChartAnimationState & import("../../../index.mjs").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.mjs").UseChartKeyboardNavigationState> & {
|
|
24
27
|
cacheKey: import("../../models/index.mjs").ChartStateCacheKey;
|
|
25
28
|
}) => AxisItemIdentifier | undefined;
|
|
@@ -20,6 +20,9 @@ export declare const selectorChartsFocusedOrToFocusedItem: (args_0: import("../.
|
|
|
20
20
|
export declare const selectorChartsIsKeyboardNavigationEnabled: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.js").UseChartSeriesConfigState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
|
|
21
21
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
22
22
|
}) => boolean;
|
|
23
|
+
export declare const selectorChartsIsKeyboardActivationEnabled: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.js").UseChartSeriesConfigState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
|
|
24
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
25
|
+
}) => boolean;
|
|
23
26
|
export declare const selectorChartsKeyboardXAxisIndex: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.js").UseChartSeriesConfigState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
|
|
24
27
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
25
28
|
}) => AxisItemIdentifier | undefined;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.selectorChartsKeyboardYAxisIndex = exports.selectorChartsKeyboardXAxisIndex = exports.selectorChartsKeyboardItem = exports.selectorChartsItemIsFocused = exports.selectorChartsIsKeyboardNavigationEnabled = exports.selectorChartsHasFocusedItem = exports.selectorChartsFocusedOrToFocusedItem = exports.selectorChartsFocusedItem = void 0;
|
|
6
|
+
exports.selectorChartsKeyboardYAxisIndex = exports.selectorChartsKeyboardXAxisIndex = exports.selectorChartsKeyboardItem = exports.selectorChartsItemIsFocused = exports.selectorChartsIsKeyboardNavigationEnabled = exports.selectorChartsIsKeyboardActivationEnabled = exports.selectorChartsHasFocusedItem = exports.selectorChartsFocusedOrToFocusedItem = exports.selectorChartsFocusedItem = void 0;
|
|
7
7
|
var _store = require("@mui/x-internals/store");
|
|
8
8
|
var _fastObjectShallowCompare = require("@mui/x-internals/fastObjectShallowCompare");
|
|
9
9
|
var _useChartSeries = require("../../corePlugins/useChartSeries");
|
|
@@ -20,6 +20,8 @@ const selectorChartsFocusedItem = exports.selectorChartsFocusedItem = (0, _store
|
|
|
20
20
|
*/
|
|
21
21
|
const selectorChartsFocusedOrToFocusedItem = exports.selectorChartsFocusedOrToFocusedItem = (0, _store.createSelector)(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item ?? null);
|
|
22
22
|
const selectorChartsIsKeyboardNavigationEnabled = exports.selectorChartsIsKeyboardNavigationEnabled = (0, _store.createSelector)(selectKeyboardNavigation, keyboardNavigationState => !!keyboardNavigationState?.enabled);
|
|
23
|
+
const selectKeyboardActivationFeature = state => state.experimentalFeatures?.keyboardActivation;
|
|
24
|
+
const selectorChartsIsKeyboardActivationEnabled = exports.selectorChartsIsKeyboardActivationEnabled = (0, _store.createSelector)(selectKeyboardNavigation, selectKeyboardActivationFeature, (keyboardNavigationState, keyboardActivation) => keyboardActivation === true && !!keyboardNavigationState?.enabled);
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* Selectors to override highlight behavior.
|
|
@@ -14,6 +14,8 @@ export const selectorChartsFocusedItem = createSelector(selectKeyboardNavigation
|
|
|
14
14
|
*/
|
|
15
15
|
export const selectorChartsFocusedOrToFocusedItem = createSelector(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item ?? null);
|
|
16
16
|
export const selectorChartsIsKeyboardNavigationEnabled = createSelector(selectKeyboardNavigation, keyboardNavigationState => !!keyboardNavigationState?.enabled);
|
|
17
|
+
const selectKeyboardActivationFeature = state => state.experimentalFeatures?.keyboardActivation;
|
|
18
|
+
export const selectorChartsIsKeyboardActivationEnabled = createSelector(selectKeyboardNavigation, selectKeyboardActivationFeature, (keyboardNavigationState, keyboardActivation) => keyboardActivation === true && !!keyboardNavigationState?.enabled);
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* Selectors to override highlight behavior.
|
|
@@ -2,9 +2,46 @@ import type { ChartPluginSignature } from "../../models/index.mjs";
|
|
|
2
2
|
import type { UseChartInteractionSignature } from "../useChartInteraction/index.mjs";
|
|
3
3
|
import type { UseChartCartesianAxisSignature } from "../useChartCartesianAxis/index.mjs";
|
|
4
4
|
import type { UseChartHighlightSignature } from "../useChartHighlight/index.mjs";
|
|
5
|
-
import type { FocusedItemIdentifier } from "../../../../models/seriesType/index.mjs";
|
|
5
|
+
import type { FocusedItemIdentifier, SeriesId } from "../../../../models/seriesType/index.mjs";
|
|
6
6
|
import type { ChartSeriesType } from "../../../../models/seriesType/config.mjs";
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Called when the focused item is activated with the keyboard.
|
|
9
|
+
* @param {KeyboardEvent} event The keyboard event that triggered the activation.
|
|
10
|
+
* @param {FocusedItemIdentifier<ChartSeriesType>} item The activated item.
|
|
11
|
+
*/
|
|
12
|
+
export type ItemActivationHandler = (event: KeyboardEvent, item: FocusedItemIdentifier<ChartSeriesType>) => void;
|
|
13
|
+
/**
|
|
14
|
+
* The items a handler covers. An empty scope covers every item.
|
|
15
|
+
*/
|
|
16
|
+
export interface ItemActivationScope {
|
|
17
|
+
type?: ChartSeriesType;
|
|
18
|
+
seriesId?: SeriesId;
|
|
19
|
+
/**
|
|
20
|
+
* Breaks ties between handlers covering the same items, highest first.
|
|
21
|
+
* Mirrors pointer hit-testing, where marks sit above lines, and lines above areas.
|
|
22
|
+
* @default 0
|
|
23
|
+
*/
|
|
24
|
+
priority?: number;
|
|
25
|
+
/**
|
|
26
|
+
* When set, the handler is a candidate only for items it returns `true` for. Lets a plot decline
|
|
27
|
+
* an item a pointer could not reach — e.g. a line mark that is not rendered — so activation falls
|
|
28
|
+
* through to the next handler.
|
|
29
|
+
* @param {FocusedItemIdentifier<ChartSeriesType>} item The focused item.
|
|
30
|
+
* @returns {boolean} Whether the handler can activate this item.
|
|
31
|
+
*/
|
|
32
|
+
canActivate?: (item: FocusedItemIdentifier<ChartSeriesType>) => boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface UseChartKeyboardNavigationInstance {
|
|
35
|
+
/**
|
|
36
|
+
* Registers a handler triggered when the focused item is activated with the keyboard.
|
|
37
|
+
* Only the handler with the most specific matching scope runs, so plots sharing a series
|
|
38
|
+
* do not fire the callback twice.
|
|
39
|
+
* @param {ItemActivationScope} scope The items the handler covers.
|
|
40
|
+
* @param {ItemActivationHandler} handler The handler to call on activation.
|
|
41
|
+
* @returns {() => void} A cleanup function unregistering the handler.
|
|
42
|
+
*/
|
|
43
|
+
registerItemActivationHandler: (scope: ItemActivationScope, handler: ItemActivationHandler) => () => void;
|
|
44
|
+
}
|
|
8
45
|
export interface UseChartKeyboardNavigationState {
|
|
9
46
|
keyboardNavigation: {
|
|
10
47
|
/**
|
|
@@ -2,9 +2,46 @@ import type { ChartPluginSignature } from "../../models/index.js";
|
|
|
2
2
|
import type { UseChartInteractionSignature } from "../useChartInteraction/index.js";
|
|
3
3
|
import type { UseChartCartesianAxisSignature } from "../useChartCartesianAxis/index.js";
|
|
4
4
|
import type { UseChartHighlightSignature } from "../useChartHighlight/index.js";
|
|
5
|
-
import type { FocusedItemIdentifier } from "../../../../models/seriesType/index.js";
|
|
5
|
+
import type { FocusedItemIdentifier, SeriesId } from "../../../../models/seriesType/index.js";
|
|
6
6
|
import type { ChartSeriesType } from "../../../../models/seriesType/config.js";
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Called when the focused item is activated with the keyboard.
|
|
9
|
+
* @param {KeyboardEvent} event The keyboard event that triggered the activation.
|
|
10
|
+
* @param {FocusedItemIdentifier<ChartSeriesType>} item The activated item.
|
|
11
|
+
*/
|
|
12
|
+
export type ItemActivationHandler = (event: KeyboardEvent, item: FocusedItemIdentifier<ChartSeriesType>) => void;
|
|
13
|
+
/**
|
|
14
|
+
* The items a handler covers. An empty scope covers every item.
|
|
15
|
+
*/
|
|
16
|
+
export interface ItemActivationScope {
|
|
17
|
+
type?: ChartSeriesType;
|
|
18
|
+
seriesId?: SeriesId;
|
|
19
|
+
/**
|
|
20
|
+
* Breaks ties between handlers covering the same items, highest first.
|
|
21
|
+
* Mirrors pointer hit-testing, where marks sit above lines, and lines above areas.
|
|
22
|
+
* @default 0
|
|
23
|
+
*/
|
|
24
|
+
priority?: number;
|
|
25
|
+
/**
|
|
26
|
+
* When set, the handler is a candidate only for items it returns `true` for. Lets a plot decline
|
|
27
|
+
* an item a pointer could not reach — e.g. a line mark that is not rendered — so activation falls
|
|
28
|
+
* through to the next handler.
|
|
29
|
+
* @param {FocusedItemIdentifier<ChartSeriesType>} item The focused item.
|
|
30
|
+
* @returns {boolean} Whether the handler can activate this item.
|
|
31
|
+
*/
|
|
32
|
+
canActivate?: (item: FocusedItemIdentifier<ChartSeriesType>) => boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface UseChartKeyboardNavigationInstance {
|
|
35
|
+
/**
|
|
36
|
+
* Registers a handler triggered when the focused item is activated with the keyboard.
|
|
37
|
+
* Only the handler with the most specific matching scope runs, so plots sharing a series
|
|
38
|
+
* do not fire the callback twice.
|
|
39
|
+
* @param {ItemActivationScope} scope The items the handler covers.
|
|
40
|
+
* @param {ItemActivationHandler} handler The handler to call on activation.
|
|
41
|
+
* @returns {() => void} A cleanup function unregistering the handler.
|
|
42
|
+
*/
|
|
43
|
+
registerItemActivationHandler: (scope: ItemActivationScope, handler: ItemActivationHandler) => () => void;
|
|
44
|
+
}
|
|
8
45
|
export interface UseChartKeyboardNavigationState {
|
|
9
46
|
keyboardNavigation: {
|
|
10
47
|
/**
|