@mui/x-charts 8.22.0 → 8.23.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/BarElement.js +1 -1
- package/BarChart/BarLabel/BarLabel.types.d.ts +3 -3
- package/BarChart/BarLabel/BarLabelItem.d.ts +1 -1
- package/BarChart/BarLabel/BarLabelPlot.d.ts +9 -9
- package/BarChart/BarLabel/getBarLabel.d.ts +3 -3
- package/BarChart/FocusedBar.js +1 -1
- package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +18 -1
- package/BarChart/seriesConfig/bar/keyboardFocusHandler.d.ts +3 -0
- package/BarChart/seriesConfig/bar/keyboardFocusHandler.js +23 -0
- package/BarChart/seriesConfig/bar/seriesProcessor.js +2 -2
- package/BarChart/seriesConfig/index.js +3 -1
- package/CHANGELOG.md +202 -0
- package/ChartsAxisHighlight/ChartsXAxisHighlight.js +2 -3
- package/ChartsAxisHighlight/ChartsYAxisHighlight.js +2 -3
- package/ChartsBrushOverlay/ChartsBrushOverlay.js +6 -7
- package/ChartsSurface/ChartsSurface.js +7 -8
- package/ChartsTooltip/ChartsTooltipContainer.js +4 -5
- package/ChartsTooltip/useAxisTooltip.js +3 -4
- package/ChartsTooltip/useItemTooltip.js +2 -3
- package/ChartsWrapper/ChartsWrapper.js +2 -3
- package/LineChart/FocusedLineMark.js +1 -1
- package/LineChart/LineHighlightPlot.js +1 -2
- package/LineChart/MarkPlot.js +1 -2
- package/LineChart/seriesConfig/index.js +3 -1
- package/LineChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
- package/LineChart/seriesConfig/keyboardFocusHandler.js +23 -0
- package/LineChart/seriesConfig/seriesProcessor.js +2 -2
- package/PieChart/FocusedPieArc.d.ts +2 -0
- package/PieChart/FocusedPieArc.js +58 -0
- package/PieChart/PieArcPlot.js +3 -31
- package/PieChart/PieChart.js +2 -1
- package/PieChart/dataTransform/getModifiedArcProperties.d.ts +11 -0
- package/PieChart/dataTransform/getModifiedArcProperties.js +42 -0
- package/PieChart/dataTransform/useTransformData.js +16 -21
- package/PieChart/seriesConfig/index.js +3 -1
- package/PieChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
- package/PieChart/seriesConfig/keyboardFocusHandler.js +23 -0
- package/PieChart/seriesConfig/tooltipPosition.js +11 -20
- package/RadarChart/RadarAxis/useRadarAxis.js +1 -2
- package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +3 -4
- package/RadarChart/RadarGrid/useRadarGridData.js +1 -2
- package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +1 -2
- package/ScatterChart/BatchScatter.js +4 -5
- package/ScatterChart/FocusedScatterMark.js +1 -1
- package/ScatterChart/Scatter.js +1 -2
- package/ScatterChart/seriesConfig/index.js +3 -1
- package/ScatterChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
- package/ScatterChart/seriesConfig/keyboardFocusHandler.js +23 -0
- package/esm/BarChart/BarElement.js +1 -1
- package/esm/BarChart/BarLabel/BarLabel.types.d.ts +3 -3
- package/esm/BarChart/BarLabel/BarLabelItem.d.ts +1 -1
- package/esm/BarChart/BarLabel/BarLabelPlot.d.ts +9 -9
- package/esm/BarChart/BarLabel/getBarLabel.d.ts +3 -3
- package/esm/BarChart/FocusedBar.js +1 -1
- package/esm/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +18 -1
- package/esm/BarChart/seriesConfig/bar/keyboardFocusHandler.d.ts +3 -0
- package/esm/BarChart/seriesConfig/bar/keyboardFocusHandler.js +17 -0
- package/esm/BarChart/seriesConfig/bar/seriesProcessor.js +1 -1
- package/esm/BarChart/seriesConfig/index.js +3 -1
- package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.js +2 -3
- package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.js +2 -3
- package/esm/ChartsBrushOverlay/ChartsBrushOverlay.js +6 -7
- package/esm/ChartsSurface/ChartsSurface.js +7 -8
- package/esm/ChartsTooltip/ChartsTooltipContainer.js +4 -5
- package/esm/ChartsTooltip/useAxisTooltip.js +3 -4
- package/esm/ChartsTooltip/useItemTooltip.js +2 -3
- package/esm/ChartsWrapper/ChartsWrapper.js +2 -3
- package/esm/LineChart/FocusedLineMark.js +1 -1
- package/esm/LineChart/LineHighlightPlot.js +1 -2
- package/esm/LineChart/MarkPlot.js +1 -2
- package/esm/LineChart/seriesConfig/index.js +3 -1
- package/esm/LineChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
- package/esm/LineChart/seriesConfig/keyboardFocusHandler.js +17 -0
- package/esm/LineChart/seriesConfig/seriesProcessor.js +1 -1
- package/esm/PieChart/FocusedPieArc.d.ts +2 -0
- package/esm/PieChart/FocusedPieArc.js +51 -0
- package/esm/PieChart/PieArcPlot.js +5 -33
- package/esm/PieChart/PieChart.js +2 -1
- package/esm/PieChart/dataTransform/getModifiedArcProperties.d.ts +11 -0
- package/esm/PieChart/dataTransform/getModifiedArcProperties.js +36 -0
- package/esm/PieChart/dataTransform/useTransformData.js +16 -21
- package/esm/PieChart/seriesConfig/index.js +3 -1
- package/esm/PieChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
- package/esm/PieChart/seriesConfig/keyboardFocusHandler.js +17 -0
- package/esm/PieChart/seriesConfig/tooltipPosition.js +11 -20
- package/esm/RadarChart/RadarAxis/useRadarAxis.js +1 -2
- package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +3 -4
- package/esm/RadarChart/RadarGrid/useRadarGridData.js +1 -2
- package/esm/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +1 -2
- package/esm/ScatterChart/BatchScatter.js +4 -5
- package/esm/ScatterChart/FocusedScatterMark.js +1 -1
- package/esm/ScatterChart/Scatter.js +1 -2
- package/esm/ScatterChart/seriesConfig/index.js +3 -1
- package/esm/ScatterChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
- package/esm/ScatterChart/seriesConfig/keyboardFocusHandler.js +17 -0
- package/esm/hooks/useAxis.js +8 -9
- package/esm/hooks/useAxisSystem.js +2 -3
- package/esm/hooks/useBrush.js +1 -2
- package/esm/hooks/useChartId.js +1 -2
- package/esm/hooks/useDataset.js +1 -2
- package/esm/hooks/useDrawingArea.js +1 -2
- package/esm/hooks/useFocusedItem.d.ts +1 -12
- package/esm/hooks/useFocusedItem.js +3 -11
- package/esm/hooks/useInteractionItemProps.d.ts +3 -2
- package/esm/hooks/useInteractionItemProps.js +13 -2
- package/esm/hooks/useIsItemFocused.d.ts +4 -3
- package/esm/hooks/useIsItemFocused.js +2 -3
- package/esm/hooks/useIsItemFocusedGetter.d.ts +3 -2
- package/esm/hooks/useIsItemFocusedGetter.js +2 -1
- package/esm/hooks/useItemHighlighted.js +2 -3
- package/esm/hooks/useItemHighlightedGetter.js +2 -3
- package/esm/hooks/useLegend.js +1 -2
- package/esm/hooks/usePieSeries.js +1 -2
- package/esm/hooks/useSeries.js +1 -2
- package/esm/hooks/useSkipAnimation.js +1 -2
- package/esm/hooks/useZAxis.js +1 -2
- package/esm/index.js +1 -1
- package/esm/internals/commonNextFocusItem.d.ts +14 -0
- package/esm/internals/commonNextFocusItem.js +84 -0
- package/esm/internals/index.d.ts +1 -2
- package/esm/internals/index.js +1 -2
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +1 -2
- package/esm/internals/plugins/corePlugins/useChartSeries/useColorProcessor.js +1 -2
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +1 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +5 -6
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.js +1 -2
- package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +5 -6
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +4 -1
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.d.ts +13 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.js +1 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.d.ts +2 -2
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +12 -105
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +5 -31
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +9 -15
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +6 -21
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.d.ts +15 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.js +45 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.d.ts +11 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.js +40 -0
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +6 -7
- package/esm/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +1 -9
- package/esm/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.js +2 -2
- package/esm/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.types.d.ts +7 -6
- package/esm/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +2 -0
- package/esm/internals/plugins/models/seriesConfig/seriesProcessor.types.d.ts +1 -1
- package/esm/internals/plugins/models/seriesConfig/tooltipGetter.types.d.ts +4 -3
- package/esm/internals/plugins/models/seriesConfig/tooltipItemPositionGetter.types.d.ts +3 -2
- package/esm/internals/seriesHasData.d.ts +4 -0
- package/esm/internals/seriesHasData.js +8 -0
- package/esm/internals/seriesSelectorOfType.js +2 -3
- package/esm/internals/stacking/index.d.ts +1 -0
- package/esm/internals/stacking/index.js +1 -0
- package/esm/internals/stacking/offset/index.d.ts +1 -0
- package/esm/internals/stacking/offset/index.js +1 -0
- package/esm/internals/stacking/offset/offsetDiverging.d.ts +8 -0
- package/esm/internals/stacking/offset/offsetDiverging.js +47 -0
- package/esm/internals/{stackSeries.d.ts → stacking/stackSeries.d.ts} +8 -8
- package/esm/internals/{stackSeries.js → stacking/stackSeries.js} +8 -6
- package/esm/models/seriesType/config.d.ts +0 -2
- package/esm/models/seriesType/index.d.ts +3 -1
- package/hooks/useAxis.js +8 -9
- package/hooks/useAxisSystem.js +2 -3
- package/hooks/useBrush.js +1 -2
- package/hooks/useChartId.js +1 -2
- package/hooks/useDataset.js +1 -2
- package/hooks/useDrawingArea.js +1 -2
- package/hooks/useFocusedItem.d.ts +1 -12
- package/hooks/useFocusedItem.js +1 -11
- package/hooks/useInteractionItemProps.d.ts +3 -2
- package/hooks/useInteractionItemProps.js +13 -2
- package/hooks/useIsItemFocused.d.ts +4 -3
- package/hooks/useIsItemFocused.js +2 -3
- package/hooks/useIsItemFocusedGetter.d.ts +3 -2
- package/hooks/useIsItemFocusedGetter.js +2 -1
- package/hooks/useItemHighlighted.js +2 -3
- package/hooks/useItemHighlightedGetter.js +2 -3
- package/hooks/useLegend.js +1 -2
- package/hooks/usePieSeries.js +1 -2
- package/hooks/useSeries.js +1 -2
- package/hooks/useSkipAnimation.js +1 -2
- package/hooks/useZAxis.js +1 -2
- package/index.js +1 -1
- package/internals/commonNextFocusItem.d.ts +14 -0
- package/internals/commonNextFocusItem.js +93 -0
- package/internals/index.d.ts +1 -2
- package/internals/index.js +4 -16
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +1 -2
- package/internals/plugins/corePlugins/useChartSeries/useColorProcessor.js +1 -2
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +1 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +5 -6
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.js +1 -2
- package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +5 -6
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +4 -1
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.d.ts +13 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.js +5 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.d.ts +2 -2
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +11 -104
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +5 -31
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +10 -16
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +6 -21
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.d.ts +15 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.js +51 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.d.ts +11 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.js +46 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +6 -7
- package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +1 -9
- package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.js +1 -1
- package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.types.d.ts +7 -6
- package/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +2 -0
- package/internals/plugins/models/seriesConfig/seriesProcessor.types.d.ts +1 -1
- package/internals/plugins/models/seriesConfig/tooltipGetter.types.d.ts +4 -3
- package/internals/plugins/models/seriesConfig/tooltipItemPositionGetter.types.d.ts +3 -2
- package/internals/seriesHasData.d.ts +4 -0
- package/internals/seriesHasData.js +14 -0
- package/internals/seriesSelectorOfType.js +2 -3
- package/internals/stacking/index.d.ts +1 -0
- package/internals/stacking/index.js +16 -0
- package/internals/stacking/offset/index.d.ts +1 -0
- package/internals/stacking/offset/index.js +16 -0
- package/internals/stacking/offset/offsetDiverging.d.ts +8 -0
- package/internals/stacking/offset/offsetDiverging.js +53 -0
- package/internals/{stackSeries.d.ts → stacking/stackSeries.d.ts} +8 -8
- package/internals/{stackSeries.js → stacking/stackSeries.js} +3 -1
- package/models/seriesType/config.d.ts +0 -2
- package/models/seriesType/index.d.ts +3 -1
- package/package.json +4 -4
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.d.ts +0 -3
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.js +0 -4
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +0 -21
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +0 -92
- package/esm/internals/store/useSelector.d.ts +0 -2
- package/esm/internals/store/useSelector.js +0 -2
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.d.ts +0 -3
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.js +0 -10
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +0 -21
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +0 -99
- package/internals/store/useSelector.d.ts +0 -2
- package/internals/store/useSelector.js +0 -8
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useStore } from "../internals/store/useStore.js";
|
|
4
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
5
4
|
import { selectorChartsIsFaded, selectorChartsIsHighlighted } from "../internals/plugins/featurePlugins/useChartHighlight/index.js";
|
|
6
5
|
/**
|
|
7
6
|
* A hook to check the highlighted state of the item.
|
|
@@ -14,8 +13,8 @@ import { selectorChartsIsFaded, selectorChartsIsHighlighted } from "../internals
|
|
|
14
13
|
*/
|
|
15
14
|
export function useItemHighlighted(item) {
|
|
16
15
|
const store = useStore();
|
|
17
|
-
const isHighlighted =
|
|
18
|
-
const isFaded =
|
|
16
|
+
const isHighlighted = store.use(selectorChartsIsHighlighted, item);
|
|
17
|
+
const isFaded = store.use(selectorChartsIsFaded, item);
|
|
19
18
|
return {
|
|
20
19
|
isHighlighted,
|
|
21
20
|
isFaded: !isHighlighted && isFaded
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
4
3
|
import { useStore } from "../internals/store/useStore.js";
|
|
5
4
|
import { selectorChartsIsFadedCallback, selectorChartsIsHighlightedCallback } from "../internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js";
|
|
6
5
|
/**
|
|
@@ -13,8 +12,8 @@ import { selectorChartsIsFadedCallback, selectorChartsIsHighlightedCallback } fr
|
|
|
13
12
|
*/
|
|
14
13
|
export function useItemHighlightedGetter() {
|
|
15
14
|
const store = useStore();
|
|
16
|
-
const isHighlighted =
|
|
17
|
-
const isFaded =
|
|
15
|
+
const isHighlighted = store.use(selectorChartsIsHighlightedCallback);
|
|
16
|
+
const isFaded = store.use(selectorChartsIsFadedCallback);
|
|
18
17
|
return {
|
|
19
18
|
isHighlighted,
|
|
20
19
|
isFaded
|
package/esm/hooks/useLegend.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import { selectorChartSeriesConfig } from "../internals/plugins/corePlugins/useChartSeries/index.js";
|
|
4
4
|
import { useSeries } from "./useSeries.js";
|
|
5
5
|
import { useStore } from "../internals/store/useStore.js";
|
|
6
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
7
6
|
function getSeriesToDisplay(series, seriesConfig) {
|
|
8
7
|
return Object.keys(series).flatMap(seriesType => {
|
|
9
8
|
const getter = seriesConfig[seriesType].legendGetter;
|
|
@@ -23,7 +22,7 @@ function getSeriesToDisplay(series, seriesConfig) {
|
|
|
23
22
|
export function useLegend() {
|
|
24
23
|
const series = useSeries();
|
|
25
24
|
const store = useStore();
|
|
26
|
-
const seriesConfig =
|
|
25
|
+
const seriesConfig = store.use(selectorChartSeriesConfig);
|
|
27
26
|
return {
|
|
28
27
|
items: getSeriesToDisplay(series, seriesConfig)
|
|
29
28
|
};
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import { useSeriesOfType, useAllSeriesOfType } from "../internals/seriesSelectorOfType.js";
|
|
4
4
|
import { useStore } from "../internals/store/useStore.js";
|
|
5
5
|
import { selectorChartSeriesLayout } from "../internals/plugins/corePlugins/useChartSeries/index.js";
|
|
6
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Get access to the internal state of pie series.
|
|
@@ -48,6 +47,6 @@ export function usePieSeriesContext() {
|
|
|
48
47
|
*/
|
|
49
48
|
export function usePieSeriesLayout() {
|
|
50
49
|
const store = useStore();
|
|
51
|
-
const seriesLayout =
|
|
50
|
+
const seriesLayout = store.use(selectorChartSeriesLayout);
|
|
52
51
|
return seriesLayout.pie ?? {};
|
|
53
52
|
}
|
package/esm/hooks/useSeries.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useStore } from "../internals/store/useStore.js";
|
|
4
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
5
4
|
import { selectorChartSeriesProcessed } from "../internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.js";
|
|
6
5
|
/**
|
|
7
6
|
* Get access to the internal state of series.
|
|
@@ -11,5 +10,5 @@ import { selectorChartSeriesProcessed } from "../internals/plugins/corePlugins/u
|
|
|
11
10
|
*/
|
|
12
11
|
export function useSeries() {
|
|
13
12
|
const store = useStore();
|
|
14
|
-
return
|
|
13
|
+
return store.use(selectorChartSeriesProcessed);
|
|
15
14
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { selectorChartSkipAnimation } from "../internals/plugins/corePlugins/useChartAnimation/index.js";
|
|
4
4
|
import { useStore } from "../internals/store/useStore.js";
|
|
5
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* A hook to get if chart animations should be skipped.
|
|
@@ -11,6 +10,6 @@ import { useSelector } from "../internals/store/useSelector.js";
|
|
|
11
10
|
*/
|
|
12
11
|
export function useSkipAnimation(skipAnimation) {
|
|
13
12
|
const store = useStore();
|
|
14
|
-
const storeSkipAnimation =
|
|
13
|
+
const storeSkipAnimation = store.use(selectorChartSkipAnimation);
|
|
15
14
|
return skipAnimation || storeSkipAnimation;
|
|
16
15
|
}
|
package/esm/hooks/useZAxis.js
CHANGED
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import { useStore } from "../internals/store/useStore.js";
|
|
4
4
|
import { selectorChartZAxis } from "../internals/plugins/featurePlugins/useChartZAxis/index.js";
|
|
5
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
6
5
|
export function useZAxes() {
|
|
7
6
|
const store = useStore();
|
|
8
7
|
const {
|
|
9
8
|
axis: zAxis,
|
|
10
9
|
axisIds: zAxisIds
|
|
11
|
-
} =
|
|
10
|
+
} = store.use(selectorChartZAxis) ?? {
|
|
12
11
|
axis: {},
|
|
13
12
|
axisIds: []
|
|
14
13
|
};
|
package/esm/index.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { UseChartKeyboardNavigationSignature } from "./plugins/featurePlugins/useChartKeyboardNavigation/index.js";
|
|
2
|
+
import type { ChartState } from "./plugins/models/chart.js";
|
|
3
|
+
import type { ChartSeriesType } from "../models/seriesType/config.js";
|
|
4
|
+
import type { FocusedItemIdentifier, SeriesId, SeriesItemIdentifier } from "../models/seriesType/index.js";
|
|
5
|
+
type ReturnedItem<OutSeriesType extends ChartSeriesType> = {
|
|
6
|
+
type: OutSeriesType;
|
|
7
|
+
seriesId: SeriesId;
|
|
8
|
+
dataIndex: number;
|
|
9
|
+
} | null;
|
|
10
|
+
export declare function createGetNextIndexFocusedItem<InSeriesType extends Exclude<ChartSeriesType, 'sankey'>, OutSeriesType extends Exclude<ChartSeriesType, 'sankey'> = InSeriesType>(compatibleSeriesTypes: Set<OutSeriesType>): (currentItem: FocusedItemIdentifier<InSeriesType> | null, state: ChartState<[UseChartKeyboardNavigationSignature], []>) => ReturnedItem<OutSeriesType>;
|
|
11
|
+
export declare function createGetPreviousIndexFocusedItem<InSeriesType extends Exclude<ChartSeriesType, 'sankey'>, OutSeriesType extends Exclude<ChartSeriesType, 'sankey'> = InSeriesType>(compatibleSeriesTypes: Set<OutSeriesType>): (currentItem: SeriesItemIdentifier<InSeriesType> | null, state: ChartState<[UseChartKeyboardNavigationSignature], []>) => ReturnedItem<OutSeriesType>;
|
|
12
|
+
export declare function createGetNextSeriesFocusedItem<InSeriesType extends Exclude<ChartSeriesType, 'sankey'>, OutSeriesType extends Exclude<ChartSeriesType, 'sankey'> = InSeriesType>(compatibleSeriesTypes: Set<OutSeriesType>): (currentItem: SeriesItemIdentifier<InSeriesType> | null, state: ChartState<[UseChartKeyboardNavigationSignature], []>) => ReturnedItem<OutSeriesType>;
|
|
13
|
+
export declare function createGetPreviousSeriesFocusedItem<InSeriesType extends Exclude<ChartSeriesType, 'sankey'>, OutSeriesType extends Exclude<ChartSeriesType, 'sankey'> = InSeriesType>(compatibleSeriesTypes: Set<OutSeriesType>): (currentItem: SeriesItemIdentifier<InSeriesType> | null, state: ChartState<[UseChartKeyboardNavigationSignature], []>) => ReturnedItem<OutSeriesType>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { getPreviousNonEmptySeries } from "./plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.js";
|
|
2
|
+
import { selectorChartSeriesProcessed } from "./plugins/corePlugins/useChartSeries/index.js";
|
|
3
|
+
import { getNextNonEmptySeries } from "./plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.js";
|
|
4
|
+
import { seriesHasData } from "./seriesHasData.js";
|
|
5
|
+
export function createGetNextIndexFocusedItem(compatibleSeriesTypes) {
|
|
6
|
+
return function getNextIndexFocusedItem(currentItem, state) {
|
|
7
|
+
const processedSeries = selectorChartSeriesProcessed(state);
|
|
8
|
+
let seriesId = currentItem?.seriesId;
|
|
9
|
+
let type = currentItem?.type;
|
|
10
|
+
if (!type || seriesId == null || !seriesHasData(processedSeries, type, seriesId)) {
|
|
11
|
+
const nextSeries = getNextNonEmptySeries(processedSeries, compatibleSeriesTypes, type, seriesId);
|
|
12
|
+
if (nextSeries === null) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
type = nextSeries.type;
|
|
16
|
+
seriesId = nextSeries.seriesId;
|
|
17
|
+
}
|
|
18
|
+
const dataLength = processedSeries[type].series[seriesId].data.length;
|
|
19
|
+
return {
|
|
20
|
+
type,
|
|
21
|
+
seriesId,
|
|
22
|
+
dataIndex: ((currentItem?.dataIndex ?? -1) + 1) % dataLength
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function createGetPreviousIndexFocusedItem(compatibleSeriesTypes) {
|
|
27
|
+
return function getPreviousIndexFocusedItem(currentItem, state) {
|
|
28
|
+
const processedSeries = selectorChartSeriesProcessed(state);
|
|
29
|
+
let seriesId = currentItem?.seriesId;
|
|
30
|
+
let type = currentItem?.type;
|
|
31
|
+
if (!type || seriesId == null || !seriesHasData(processedSeries, type, seriesId)) {
|
|
32
|
+
const previousSeries = getPreviousNonEmptySeries(processedSeries, compatibleSeriesTypes, type, seriesId);
|
|
33
|
+
if (previousSeries === null) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
type = previousSeries.type;
|
|
37
|
+
seriesId = previousSeries.seriesId;
|
|
38
|
+
}
|
|
39
|
+
const dataLength = processedSeries[type].series[seriesId].data.length;
|
|
40
|
+
return {
|
|
41
|
+
type,
|
|
42
|
+
seriesId,
|
|
43
|
+
dataIndex: (dataLength + (currentItem?.dataIndex ?? 1) - 1) % dataLength
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export function createGetNextSeriesFocusedItem(compatibleSeriesTypes) {
|
|
48
|
+
return function getNextSeriesFocusedItem(currentItem, state) {
|
|
49
|
+
const processedSeries = selectorChartSeriesProcessed(state);
|
|
50
|
+
let seriesId = currentItem?.seriesId;
|
|
51
|
+
let type = currentItem?.type;
|
|
52
|
+
const nextSeries = getNextNonEmptySeries(processedSeries, compatibleSeriesTypes, type, seriesId);
|
|
53
|
+
if (nextSeries === null) {
|
|
54
|
+
return null; // No series to move the focus to.
|
|
55
|
+
}
|
|
56
|
+
type = nextSeries.type;
|
|
57
|
+
seriesId = nextSeries.seriesId;
|
|
58
|
+
const dataLength = processedSeries[type].series[seriesId].data.length;
|
|
59
|
+
return {
|
|
60
|
+
type,
|
|
61
|
+
seriesId,
|
|
62
|
+
dataIndex: Math.min(dataLength - 1, currentItem?.dataIndex ?? 0)
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export function createGetPreviousSeriesFocusedItem(compatibleSeriesTypes) {
|
|
67
|
+
return function getPreviousSeriesFocusedItem(currentItem, state) {
|
|
68
|
+
const processedSeries = selectorChartSeriesProcessed(state);
|
|
69
|
+
let seriesId = currentItem?.seriesId;
|
|
70
|
+
let type = currentItem?.type;
|
|
71
|
+
const previousSeries = getPreviousNonEmptySeries(processedSeries, compatibleSeriesTypes, type, seriesId);
|
|
72
|
+
if (previousSeries === null) {
|
|
73
|
+
return null; // No series to move the focus to.
|
|
74
|
+
}
|
|
75
|
+
type = previousSeries.type;
|
|
76
|
+
seriesId = previousSeries.seriesId;
|
|
77
|
+
const dataLength = processedSeries[type].series[seriesId].data.length;
|
|
78
|
+
return {
|
|
79
|
+
type,
|
|
80
|
+
seriesId,
|
|
81
|
+
dataIndex: Math.min(dataLength - 1, currentItem?.dataIndex ?? 0)
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
}
|
package/esm/internals/index.d.ts
CHANGED
|
@@ -37,7 +37,6 @@ export { getAxisTriggerTooltip as getCartesianAxisTriggerTooltip } from "./plugi
|
|
|
37
37
|
export { getAxisIndex as getCartesianAxisIndex } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js";
|
|
38
38
|
export * from "./store/useCharts.js";
|
|
39
39
|
export * from "./store/useStore.js";
|
|
40
|
-
export * from "./store/useSelector.js";
|
|
41
40
|
export * from "../BarChart/BarChart.plugins.js";
|
|
42
41
|
export * from "../LineChart/LineChart.plugins.js";
|
|
43
42
|
export * from "../ScatterChart/ScatterChart.plugins.js";
|
|
@@ -48,7 +47,7 @@ export * from "./getLabel.js";
|
|
|
48
47
|
export * from "./getSVGPoint.js";
|
|
49
48
|
export * from "./isDefined.js";
|
|
50
49
|
export * from "./getScale.js";
|
|
51
|
-
export * from "./
|
|
50
|
+
export * from "./stacking/index.js";
|
|
52
51
|
export * from "./getCurve.js";
|
|
53
52
|
export * from "./consumeSlots.js";
|
|
54
53
|
export * from "./consumeThemeProps.js";
|
package/esm/internals/index.js
CHANGED
|
@@ -42,7 +42,6 @@ export { getAxisTriggerTooltip as getCartesianAxisTriggerTooltip } from "./plugi
|
|
|
42
42
|
export { getAxisIndex as getCartesianAxisIndex } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js";
|
|
43
43
|
export * from "./store/useCharts.js";
|
|
44
44
|
export * from "./store/useStore.js";
|
|
45
|
-
export * from "./store/useSelector.js";
|
|
46
45
|
|
|
47
46
|
// plugins configs
|
|
48
47
|
|
|
@@ -58,7 +57,7 @@ export * from "./getLabel.js";
|
|
|
58
57
|
export * from "./getSVGPoint.js";
|
|
59
58
|
export * from "./isDefined.js";
|
|
60
59
|
export * from "./getScale.js";
|
|
61
|
-
export * from "./
|
|
60
|
+
export * from "./stacking/index.js";
|
|
62
61
|
export * from "./getCurve.js";
|
|
63
62
|
export * from "./consumeSlots.js";
|
|
64
63
|
export * from "./consumeThemeProps.js";
|
|
@@ -5,7 +5,6 @@ import * as React from 'react';
|
|
|
5
5
|
import { useEffectAfterFirstRender } from '@mui/x-internals/useEffectAfterFirstRender';
|
|
6
6
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
7
7
|
import ownerWindow from '@mui/utils/ownerWindow';
|
|
8
|
-
import { useSelector } from "../../../store/useSelector.js";
|
|
9
8
|
import { DEFAULT_MARGINS } from "../../../../constants/index.js";
|
|
10
9
|
import { selectorChartDrawingArea } from "./useChartDimensions.selectors.js";
|
|
11
10
|
import { defaultizeMargin } from "../../../defaultizeMargin.js";
|
|
@@ -136,7 +135,7 @@ export const useChartDimensions = ({
|
|
|
136
135
|
stateRef.current.displayError = false;
|
|
137
136
|
}
|
|
138
137
|
}
|
|
139
|
-
const drawingArea =
|
|
138
|
+
const drawingArea = store.use(selectorChartDrawingArea);
|
|
140
139
|
const isXInside = React.useCallback(x => x >= drawingArea.left - 1 && x <= drawingArea.left + drawingArea.width, [drawingArea.left, drawingArea.width]);
|
|
141
140
|
const isYInside = React.useCallback(y => y >= drawingArea.top - 1 && y <= drawingArea.top + drawingArea.height, [drawingArea.height, drawingArea.top]);
|
|
142
141
|
const isPointInside = React.useCallback((x, y, targetElement) => {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { useSelector } from "../../../store/useSelector.js";
|
|
5
4
|
import { useStore } from "../../../store/useStore.js";
|
|
6
5
|
import { selectorChartSeriesConfig } from "./useChartSeries.selectors.js";
|
|
7
6
|
export function useColorProcessor(seriesType) {
|
|
8
7
|
const store = useStore();
|
|
9
|
-
const seriesConfig =
|
|
8
|
+
const seriesConfig = store.use(selectorChartSeriesConfig);
|
|
10
9
|
const colorProcessors = React.useMemo(() => {
|
|
11
10
|
const rep = {};
|
|
12
11
|
Object.keys(seriesConfig).forEach(seriesT => {
|
|
@@ -5,7 +5,6 @@ import useEventCallback from '@mui/utils/useEventCallback';
|
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
7
7
|
import { getSVGPoint } from "../../../getSVGPoint.js";
|
|
8
|
-
import { useSelector } from "../../../store/useSelector.js";
|
|
9
8
|
import { selectorIsBrushEnabled } from "./useChartBrush.selectors.js";
|
|
10
9
|
export const useChartBrush = ({
|
|
11
10
|
store,
|
|
@@ -13,7 +12,7 @@ export const useChartBrush = ({
|
|
|
13
12
|
instance,
|
|
14
13
|
params
|
|
15
14
|
}) => {
|
|
16
|
-
const isEnabled =
|
|
15
|
+
const isEnabled = store.use(selectorIsBrushEnabled);
|
|
17
16
|
useEnhancedEffect(() => {
|
|
18
17
|
store.set('brush', _extends({}, store.state.brush, {
|
|
19
18
|
enabled: params.brushConfig.enabled,
|
|
@@ -7,7 +7,6 @@ import { useStoreEffect } from '@mui/x-internals/store';
|
|
|
7
7
|
import { useAssertModelConsistency } from '@mui/x-internals/useAssertModelConsistency';
|
|
8
8
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
9
9
|
import { rainbowSurgePalette } from "../../../../colorPalettes/index.js";
|
|
10
|
-
import { useSelector } from "../../../store/useSelector.js";
|
|
11
10
|
import { selectorChartDrawingArea } from "../../corePlugins/useChartDimensions/useChartDimensions.selectors.js";
|
|
12
11
|
import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/useChartSeries.selectors.js";
|
|
13
12
|
import { defaultizeXAxis, defaultizeYAxis } from "./defaultizeAxis.js";
|
|
@@ -37,17 +36,17 @@ export const useChartCartesianAxis = ({
|
|
|
37
36
|
warnOnce([`MUI X Charts: The following axis ids are duplicated: ${Array.from(duplicates).join(', ')}.`, `Please make sure that each axis has a unique id.`].join('\n'), 'error');
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
|
-
const drawingArea =
|
|
41
|
-
const processedSeries =
|
|
42
|
-
const isInteractionEnabled =
|
|
39
|
+
const drawingArea = store.use(selectorChartDrawingArea);
|
|
40
|
+
const processedSeries = store.use(selectorChartSeriesProcessed);
|
|
41
|
+
const isInteractionEnabled = store.use(selectorChartsInteractionIsInitialized);
|
|
43
42
|
const {
|
|
44
43
|
axis: xAxisWithScale,
|
|
45
44
|
axisIds: xAxisIds
|
|
46
|
-
} =
|
|
45
|
+
} = store.use(selectorChartXAxis);
|
|
47
46
|
const {
|
|
48
47
|
axis: yAxisWithScale,
|
|
49
48
|
axisIds: yAxisIds
|
|
50
|
-
} =
|
|
49
|
+
} = store.use(selectorChartYAxis);
|
|
51
50
|
useAssertModelConsistency({
|
|
52
51
|
warningPrefix: 'MUI X Charts',
|
|
53
52
|
componentName: 'Chart',
|
package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { useSelector } from "../../../store/useSelector.js";
|
|
4
3
|
import { useStore } from "../../../store/useStore.js";
|
|
5
4
|
import { selectorChartZoomIsInteracting } from "./useChartCartesianAxisRendering.selectors.js";
|
|
6
5
|
/**
|
|
@@ -14,6 +13,6 @@ import { selectorChartZoomIsInteracting } from "./useChartCartesianAxisRendering
|
|
|
14
13
|
*/
|
|
15
14
|
export function useInternalIsZoomInteracting() {
|
|
16
15
|
const store = useStore();
|
|
17
|
-
const isInteracting =
|
|
16
|
+
const isInteracting = store.use(selectorChartZoomIsInteracting);
|
|
18
17
|
return isInteracting;
|
|
19
18
|
}
|
|
@@ -5,7 +5,6 @@ import * as React from 'react';
|
|
|
5
5
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
6
6
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
7
7
|
import { getSVGPoint } from "../../../getSVGPoint.js";
|
|
8
|
-
import { useSelector } from "../../../store/useSelector.js";
|
|
9
8
|
import { selectorChartAxisZoomData, selectorChartSeriesEmptyFlatbushMap, selectorChartSeriesFlatbushMap, selectorChartXAxis, selectorChartYAxis, selectorChartZoomIsInteracting } from "../useChartCartesianAxis/index.js";
|
|
10
9
|
import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/useChartSeries.selectors.js";
|
|
11
10
|
import { findClosestPoints } from "./findClosestPoints.js";
|
|
@@ -23,17 +22,17 @@ export const useChartClosestPoint = ({
|
|
|
23
22
|
const {
|
|
24
23
|
axis: xAxis,
|
|
25
24
|
axisIds: xAxisIds
|
|
26
|
-
} =
|
|
25
|
+
} = store.use(selectorChartXAxis);
|
|
27
26
|
const {
|
|
28
27
|
axis: yAxis,
|
|
29
28
|
axisIds: yAxisIds
|
|
30
|
-
} =
|
|
31
|
-
const zoomIsInteracting =
|
|
29
|
+
} = store.use(selectorChartYAxis);
|
|
30
|
+
const zoomIsInteracting = store.use(selectorChartZoomIsInteracting);
|
|
32
31
|
const {
|
|
33
32
|
series,
|
|
34
33
|
seriesOrder
|
|
35
|
-
} =
|
|
36
|
-
const flatbushMap =
|
|
34
|
+
} = store.use(selectorChartSeriesProcessed)?.scatter ?? {};
|
|
35
|
+
const flatbushMap = store.use(zoomIsInteracting ? selectorChartSeriesEmptyFlatbushMap : selectorChartSeriesFlatbushMap);
|
|
37
36
|
const defaultXAxisId = xAxisIds[0];
|
|
38
37
|
const defaultYAxisId = yAxisIds[0];
|
|
39
38
|
useEnhancedEffect(() => {
|
|
@@ -41,10 +41,13 @@ export const useChartHighlight = ({
|
|
|
41
41
|
});
|
|
42
42
|
const setHighlight = useEventCallback(newItem => {
|
|
43
43
|
const prevHighlight = store.state.highlight;
|
|
44
|
-
if (
|
|
44
|
+
if (fastObjectShallowCompare(prevHighlight.item, newItem)) {
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
params.onHighlightChange?.(newItem);
|
|
48
|
+
if (prevHighlight.isControlled) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
48
51
|
store.set('highlight', {
|
|
49
52
|
item: newItem,
|
|
50
53
|
lastUpdate: 'pointer',
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ChartSeriesType } from "../../../../models/seriesType/config.js";
|
|
2
|
+
import type { FocusedItemIdentifier } from "../../../../models/seriesType/index.js";
|
|
3
|
+
import type { UseChartKeyboardNavigationSignature } from "./useChartKeyboardNavigation.types.js";
|
|
4
|
+
import type { ChartState } from "../../models/chart.js";
|
|
5
|
+
export type FocusedItemUpdater<TSeriesType extends ChartSeriesType, OutputSeriesType extends ChartSeriesType = ChartSeriesType> = (currentItem: (TSeriesType extends any ? FocusedItemIdentifier<TSeriesType> : never) | null, state: ChartState<[UseChartKeyboardNavigationSignature], []>) => FocusedItemIdentifier<OutputSeriesType> | null;
|
|
6
|
+
/**
|
|
7
|
+
* Get the next focusable item in the chart.
|
|
8
|
+
* @param {SeriesItemIdentifier<TSeriesType> | null} currentItem The current focused item.
|
|
9
|
+
* @param {KeyboardEvent} event The keyboard event that triggered the navigation.
|
|
10
|
+
* @param {ChartState<[UseChartKeyboardNavigationSignature], []>} state The current chart state.
|
|
11
|
+
* @returns {SeriesItemIdentifier<ChartSeriesType> | null} The next focusable item or null if none found.
|
|
12
|
+
*/
|
|
13
|
+
export type KeyboardFocusHandler<TSeriesType extends ChartSeriesType, OutputSeriesType extends ChartSeriesType = ChartSeriesType> = (event: KeyboardEvent) => FocusedItemUpdater<TSeriesType, OutputSeriesType> | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { ChartPlugin } from "../../models/index.js";
|
|
2
|
+
import type { UseChartKeyboardNavigationSignature } from "./useChartKeyboardNavigation.types.js";
|
|
3
3
|
export declare const useChartKeyboardNavigation: ChartPlugin<UseChartKeyboardNavigationSignature>;
|
|
@@ -4,92 +4,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
6
6
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
7
|
-
import {
|
|
8
|
-
import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/useChartSeries.selectors.js";
|
|
9
|
-
function getNextIndexFocusedItem(state) {
|
|
10
|
-
const processedSeries = selectorChartSeriesProcessed(state);
|
|
11
|
-
let {
|
|
12
|
-
type,
|
|
13
|
-
seriesId
|
|
14
|
-
} = state.keyboardNavigation.item ?? {};
|
|
15
|
-
if (type === undefined ||
|
|
16
|
-
// @ts-ignore sankey is not in MIT version
|
|
17
|
-
type === 'sankey' || seriesId === undefined || !seriesHasData(processedSeries, type, seriesId)) {
|
|
18
|
-
const nextSeries = getNextSeriesWithData(processedSeries, type, seriesId);
|
|
19
|
-
if (nextSeries === null) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
type = nextSeries.type;
|
|
23
|
-
seriesId = nextSeries.seriesId;
|
|
24
|
-
}
|
|
25
|
-
const dataLength = processedSeries[type].series[seriesId].data.length;
|
|
26
|
-
return {
|
|
27
|
-
type,
|
|
28
|
-
seriesId,
|
|
29
|
-
dataIndex: ((state.keyboardNavigation.item?.dataIndex ?? -1) + 1) % dataLength
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function getPreviousIndexFocusedItem(state) {
|
|
33
|
-
const processedSeries = selectorChartSeriesProcessed(state);
|
|
34
|
-
let {
|
|
35
|
-
type,
|
|
36
|
-
seriesId
|
|
37
|
-
} = state.keyboardNavigation.item ?? {};
|
|
38
|
-
if (type === undefined ||
|
|
39
|
-
// @ts-ignore sankey is not in MIT version
|
|
40
|
-
type === 'sankey' || seriesId === undefined || !seriesHasData(processedSeries, type, seriesId)) {
|
|
41
|
-
const previousSeries = getPreviousSeriesWithData(processedSeries, type, seriesId);
|
|
42
|
-
if (previousSeries === null) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
type = previousSeries.type;
|
|
46
|
-
seriesId = previousSeries.seriesId;
|
|
47
|
-
}
|
|
48
|
-
const dataLength = processedSeries[type].series[seriesId].data.length;
|
|
49
|
-
return {
|
|
50
|
-
type,
|
|
51
|
-
seriesId,
|
|
52
|
-
dataIndex: (dataLength + (state.keyboardNavigation.item?.dataIndex ?? 1) - 1) % dataLength
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function getNextSeriesFocusedItem(state) {
|
|
56
|
-
const processedSeries = selectorChartSeriesProcessed(state);
|
|
57
|
-
let {
|
|
58
|
-
type,
|
|
59
|
-
seriesId
|
|
60
|
-
} = state.keyboardNavigation.item ?? {};
|
|
61
|
-
const nextSeries = getNextSeriesWithData(processedSeries, type, seriesId);
|
|
62
|
-
if (nextSeries === null) {
|
|
63
|
-
return null; // No series to move the focus to.
|
|
64
|
-
}
|
|
65
|
-
type = nextSeries.type;
|
|
66
|
-
seriesId = nextSeries.seriesId;
|
|
67
|
-
const dataLength = processedSeries[type].series[seriesId].data.length;
|
|
68
|
-
return {
|
|
69
|
-
type,
|
|
70
|
-
seriesId,
|
|
71
|
-
dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function getPreviousSeriesFocusedItem(state) {
|
|
75
|
-
const processedSeries = selectorChartSeriesProcessed(state);
|
|
76
|
-
let {
|
|
77
|
-
type,
|
|
78
|
-
seriesId
|
|
79
|
-
} = state.keyboardNavigation.item ?? {};
|
|
80
|
-
const previousSeries = getPreviousSeriesWithData(processedSeries, type, seriesId);
|
|
81
|
-
if (previousSeries === null) {
|
|
82
|
-
return null; // No series to move the focus to.
|
|
83
|
-
}
|
|
84
|
-
type = previousSeries.type;
|
|
85
|
-
seriesId = previousSeries.seriesId;
|
|
86
|
-
const dataLength = processedSeries[type].series[seriesId].data.length;
|
|
87
|
-
return {
|
|
88
|
-
type,
|
|
89
|
-
seriesId,
|
|
90
|
-
dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
|
|
91
|
-
};
|
|
92
|
-
}
|
|
7
|
+
import { selectorChartDefaultizedSeries } from "../../corePlugins/useChartSeries/useChartSeries.selectors.js";
|
|
93
8
|
export const useChartKeyboardNavigation = ({
|
|
94
9
|
params,
|
|
95
10
|
store,
|
|
@@ -109,26 +24,18 @@ export const useChartKeyboardNavigation = ({
|
|
|
109
24
|
}
|
|
110
25
|
function keyboardHandler(event) {
|
|
111
26
|
let newFocusedItem = store.state.keyboardNavigation.item;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
case 'ArrowUp':
|
|
125
|
-
{
|
|
126
|
-
newFocusedItem = getNextSeriesFocusedItem(store.state);
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
default:
|
|
130
|
-
break;
|
|
27
|
+
let seriesType = newFocusedItem?.type;
|
|
28
|
+
if (!seriesType) {
|
|
29
|
+
seriesType = Object.keys(selectorChartDefaultizedSeries(store.state)).find(key => store.state.series.seriesConfig[key] !== undefined);
|
|
30
|
+
if (seriesType === undefined) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const calculateFocusedItem = store.state.series.seriesConfig[seriesType]?.keyboardFocusHandler?.(event);
|
|
35
|
+
if (!calculateFocusedItem) {
|
|
36
|
+
return;
|
|
131
37
|
}
|
|
38
|
+
newFocusedItem = calculateFocusedItem(newFocusedItem, store.state);
|
|
132
39
|
if (newFocusedItem !== store.state.keyboardNavigation.item) {
|
|
133
40
|
event.preventDefault();
|
|
134
41
|
store.update(_extends({}, store.state.highlight && {
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FocusedItemIdentifier } from "../../../../models/seriesType/index.js";
|
|
2
2
|
import { type AxisItemIdentifier } from "../../../../models/axis.js";
|
|
3
|
-
import { type FocusedItemData } from "../../../../hooks/useFocusedItem.js";
|
|
4
3
|
export declare const selectorChartsItemIsFocused: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & 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> & {
|
|
5
4
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
6
|
-
}, item:
|
|
5
|
+
}, item: FocusedItemIdentifier<keyof import("../../../index.js").ChartsSeriesConfig>) => boolean;
|
|
7
6
|
export declare const selectorChartsHasFocusedItem: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & 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> & {
|
|
8
7
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
9
8
|
}) => boolean;
|
|
10
|
-
export declare const
|
|
9
|
+
export declare const selectorChartsFocusedItem: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & 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> & {
|
|
11
10
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
12
|
-
}) =>
|
|
13
|
-
export declare const selectorChartsFocusedSeriesId: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & 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> & {
|
|
14
|
-
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
15
|
-
}) => SeriesId | undefined;
|
|
16
|
-
export declare const selectorChartsFocusedDataIndex: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & 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> & {
|
|
17
|
-
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
18
|
-
}) => number | undefined;
|
|
11
|
+
}) => FocusedItemIdentifier<keyof import("../../../index.js").ChartsSeriesConfig> | null;
|
|
19
12
|
export declare const selectorChartsIsKeyboardNavigationEnabled: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & 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> & {
|
|
20
13
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
21
14
|
}) => boolean;
|
|
@@ -27,23 +20,4 @@ export declare const selectorChartsKeyboardYAxisIndex: (args_0: import("../../co
|
|
|
27
20
|
}) => AxisItemIdentifier | undefined;
|
|
28
21
|
export declare const selectorChartsKeyboardItem: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & 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> & {
|
|
29
22
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
30
|
-
}) =>
|
|
31
|
-
type: "line";
|
|
32
|
-
seriesId: SeriesId;
|
|
33
|
-
dataIndex: number;
|
|
34
|
-
} | {
|
|
35
|
-
type: "bar";
|
|
36
|
-
seriesId: SeriesId;
|
|
37
|
-
dataIndex: number;
|
|
38
|
-
} | {
|
|
39
|
-
type: "scatter";
|
|
40
|
-
seriesId: SeriesId;
|
|
41
|
-
dataIndex: number;
|
|
42
|
-
} | {
|
|
43
|
-
type: "pie";
|
|
44
|
-
seriesId: SeriesId;
|
|
45
|
-
dataIndex: number;
|
|
46
|
-
} | null;
|
|
47
|
-
export declare const selectorChartsKeyboardItemIsDefined: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & 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> & {
|
|
48
|
-
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
49
|
-
}) => boolean;
|
|
23
|
+
}) => FocusedItemIdentifier<keyof import("../../../index.js").ChartsSeriesConfig> | null;
|