@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
|
@@ -7,12 +7,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.useColorProcessor = useColorProcessor;
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _useSelector = require("../../../store/useSelector");
|
|
11
10
|
var _useStore = require("../../../store/useStore");
|
|
12
11
|
var _useChartSeries = require("./useChartSeries.selectors");
|
|
13
12
|
function useColorProcessor(seriesType) {
|
|
14
13
|
const store = (0, _useStore.useStore)();
|
|
15
|
-
const seriesConfig =
|
|
14
|
+
const seriesConfig = store.use(_useChartSeries.selectorChartSeriesConfig);
|
|
16
15
|
const colorProcessors = React.useMemo(() => {
|
|
17
16
|
const rep = {};
|
|
18
17
|
Object.keys(seriesConfig).forEach(seriesT => {
|
|
@@ -12,7 +12,6 @@ var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallb
|
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
14
14
|
var _getSVGPoint = require("../../../getSVGPoint");
|
|
15
|
-
var _useSelector = require("../../../store/useSelector");
|
|
16
15
|
var _useChartBrush = require("./useChartBrush.selectors");
|
|
17
16
|
const useChartBrush = ({
|
|
18
17
|
store,
|
|
@@ -20,7 +19,7 @@ const useChartBrush = ({
|
|
|
20
19
|
instance,
|
|
21
20
|
params
|
|
22
21
|
}) => {
|
|
23
|
-
const isEnabled =
|
|
22
|
+
const isEnabled = store.use(_useChartBrush.selectorIsBrushEnabled);
|
|
24
23
|
(0, _useEnhancedEffect.default)(() => {
|
|
25
24
|
store.set('brush', (0, _extends2.default)({}, store.state.brush, {
|
|
26
25
|
enabled: params.brushConfig.enabled,
|
|
@@ -14,7 +14,6 @@ var _store = require("@mui/x-internals/store");
|
|
|
14
14
|
var _useAssertModelConsistency = require("@mui/x-internals/useAssertModelConsistency");
|
|
15
15
|
var _warning = require("@mui/x-internals/warning");
|
|
16
16
|
var _colorPalettes = require("../../../../colorPalettes");
|
|
17
|
-
var _useSelector = require("../../../store/useSelector");
|
|
18
17
|
var _useChartDimensions = require("../../corePlugins/useChartDimensions/useChartDimensions.selectors");
|
|
19
18
|
var _useChartSeries = require("../../corePlugins/useChartSeries/useChartSeries.selectors");
|
|
20
19
|
var _defaultizeAxis = require("./defaultizeAxis");
|
|
@@ -44,17 +43,17 @@ const useChartCartesianAxis = ({
|
|
|
44
43
|
(0, _warning.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');
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
|
-
const drawingArea =
|
|
48
|
-
const processedSeries =
|
|
49
|
-
const isInteractionEnabled =
|
|
46
|
+
const drawingArea = store.use(_useChartDimensions.selectorChartDrawingArea);
|
|
47
|
+
const processedSeries = store.use(_useChartSeries.selectorChartSeriesProcessed);
|
|
48
|
+
const isInteractionEnabled = store.use(_useChartInteraction.selectorChartsInteractionIsInitialized);
|
|
50
49
|
const {
|
|
51
50
|
axis: xAxisWithScale,
|
|
52
51
|
axisIds: xAxisIds
|
|
53
|
-
} =
|
|
52
|
+
} = store.use(_useChartCartesianAxisRendering.selectorChartXAxis);
|
|
54
53
|
const {
|
|
55
54
|
axis: yAxisWithScale,
|
|
56
55
|
axisIds: yAxisIds
|
|
57
|
-
} =
|
|
56
|
+
} = store.use(_useChartCartesianAxisRendering.selectorChartYAxis);
|
|
58
57
|
(0, _useAssertModelConsistency.useAssertModelConsistency)({
|
|
59
58
|
warningPrefix: 'MUI X Charts',
|
|
60
59
|
componentName: 'Chart',
|
package/internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.useInternalIsZoomInteracting = useInternalIsZoomInteracting;
|
|
8
|
-
var _useSelector = require("../../../store/useSelector");
|
|
9
8
|
var _useStore = require("../../../store/useStore");
|
|
10
9
|
var _useChartCartesianAxisRendering = require("./useChartCartesianAxisRendering.selectors");
|
|
11
10
|
/**
|
|
@@ -19,6 +18,6 @@ var _useChartCartesianAxisRendering = require("./useChartCartesianAxisRendering.
|
|
|
19
18
|
*/
|
|
20
19
|
function useInternalIsZoomInteracting() {
|
|
21
20
|
const store = (0, _useStore.useStore)();
|
|
22
|
-
const isInteracting =
|
|
21
|
+
const isInteracting = store.use(_useChartCartesianAxisRendering.selectorChartZoomIsInteracting);
|
|
23
22
|
return isInteracting;
|
|
24
23
|
}
|
|
@@ -12,7 +12,6 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
12
12
|
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
13
13
|
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
14
14
|
var _getSVGPoint = require("../../../getSVGPoint");
|
|
15
|
-
var _useSelector = require("../../../store/useSelector");
|
|
16
15
|
var _useChartCartesianAxis = require("../useChartCartesianAxis");
|
|
17
16
|
var _useChartSeries = require("../../corePlugins/useChartSeries/useChartSeries.selectors");
|
|
18
17
|
var _findClosestPoints = require("./findClosestPoints");
|
|
@@ -30,17 +29,17 @@ const useChartClosestPoint = ({
|
|
|
30
29
|
const {
|
|
31
30
|
axis: xAxis,
|
|
32
31
|
axisIds: xAxisIds
|
|
33
|
-
} =
|
|
32
|
+
} = store.use(_useChartCartesianAxis.selectorChartXAxis);
|
|
34
33
|
const {
|
|
35
34
|
axis: yAxis,
|
|
36
35
|
axisIds: yAxisIds
|
|
37
|
-
} =
|
|
38
|
-
const zoomIsInteracting =
|
|
36
|
+
} = store.use(_useChartCartesianAxis.selectorChartYAxis);
|
|
37
|
+
const zoomIsInteracting = store.use(_useChartCartesianAxis.selectorChartZoomIsInteracting);
|
|
39
38
|
const {
|
|
40
39
|
series,
|
|
41
40
|
seriesOrder
|
|
42
|
-
} =
|
|
43
|
-
const flatbushMap =
|
|
41
|
+
} = store.use(_useChartSeries.selectorChartSeriesProcessed)?.scatter ?? {};
|
|
42
|
+
const flatbushMap = store.use(zoomIsInteracting ? _useChartCartesianAxis.selectorChartSeriesEmptyFlatbushMap : _useChartCartesianAxis.selectorChartSeriesFlatbushMap);
|
|
44
43
|
const defaultXAxisId = xAxisIds[0];
|
|
45
44
|
const defaultYAxisId = yAxisIds[0];
|
|
46
45
|
(0, _useEnhancedEffect.default)(() => {
|
|
@@ -48,10 +48,13 @@ const useChartHighlight = ({
|
|
|
48
48
|
});
|
|
49
49
|
const setHighlight = (0, _useEventCallback.default)(newItem => {
|
|
50
50
|
const prevHighlight = store.state.highlight;
|
|
51
|
-
if (
|
|
51
|
+
if ((0, _fastObjectShallowCompare.fastObjectShallowCompare)(prevHighlight.item, newItem)) {
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
54
|
params.onHighlightChange?.(newItem);
|
|
55
|
+
if (prevHighlight.isControlled) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
55
58
|
store.set('highlight', {
|
|
56
59
|
item: newItem,
|
|
57
60
|
lastUpdate: 'pointer',
|
package/internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.d.ts
ADDED
|
@@ -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;
|
package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.d.ts
CHANGED
|
@@ -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>;
|
package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js
CHANGED
|
@@ -11,92 +11,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
13
13
|
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
14
|
-
var _useChartKeyboardNavigation = require("./useChartKeyboardNavigation.helpers");
|
|
15
14
|
var _useChartSeries = require("../../corePlugins/useChartSeries/useChartSeries.selectors");
|
|
16
|
-
function getNextIndexFocusedItem(state) {
|
|
17
|
-
const processedSeries = (0, _useChartSeries.selectorChartSeriesProcessed)(state);
|
|
18
|
-
let {
|
|
19
|
-
type,
|
|
20
|
-
seriesId
|
|
21
|
-
} = state.keyboardNavigation.item ?? {};
|
|
22
|
-
if (type === undefined ||
|
|
23
|
-
// @ts-ignore sankey is not in MIT version
|
|
24
|
-
type === 'sankey' || seriesId === undefined || !(0, _useChartKeyboardNavigation.seriesHasData)(processedSeries, type, seriesId)) {
|
|
25
|
-
const nextSeries = (0, _useChartKeyboardNavigation.getNextSeriesWithData)(processedSeries, type, seriesId);
|
|
26
|
-
if (nextSeries === null) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
type = nextSeries.type;
|
|
30
|
-
seriesId = nextSeries.seriesId;
|
|
31
|
-
}
|
|
32
|
-
const dataLength = processedSeries[type].series[seriesId].data.length;
|
|
33
|
-
return {
|
|
34
|
-
type,
|
|
35
|
-
seriesId,
|
|
36
|
-
dataIndex: ((state.keyboardNavigation.item?.dataIndex ?? -1) + 1) % dataLength
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function getPreviousIndexFocusedItem(state) {
|
|
40
|
-
const processedSeries = (0, _useChartSeries.selectorChartSeriesProcessed)(state);
|
|
41
|
-
let {
|
|
42
|
-
type,
|
|
43
|
-
seriesId
|
|
44
|
-
} = state.keyboardNavigation.item ?? {};
|
|
45
|
-
if (type === undefined ||
|
|
46
|
-
// @ts-ignore sankey is not in MIT version
|
|
47
|
-
type === 'sankey' || seriesId === undefined || !(0, _useChartKeyboardNavigation.seriesHasData)(processedSeries, type, seriesId)) {
|
|
48
|
-
const previousSeries = (0, _useChartKeyboardNavigation.getPreviousSeriesWithData)(processedSeries, type, seriesId);
|
|
49
|
-
if (previousSeries === null) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
type = previousSeries.type;
|
|
53
|
-
seriesId = previousSeries.seriesId;
|
|
54
|
-
}
|
|
55
|
-
const dataLength = processedSeries[type].series[seriesId].data.length;
|
|
56
|
-
return {
|
|
57
|
-
type,
|
|
58
|
-
seriesId,
|
|
59
|
-
dataIndex: (dataLength + (state.keyboardNavigation.item?.dataIndex ?? 1) - 1) % dataLength
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function getNextSeriesFocusedItem(state) {
|
|
63
|
-
const processedSeries = (0, _useChartSeries.selectorChartSeriesProcessed)(state);
|
|
64
|
-
let {
|
|
65
|
-
type,
|
|
66
|
-
seriesId
|
|
67
|
-
} = state.keyboardNavigation.item ?? {};
|
|
68
|
-
const nextSeries = (0, _useChartKeyboardNavigation.getNextSeriesWithData)(processedSeries, type, seriesId);
|
|
69
|
-
if (nextSeries === null) {
|
|
70
|
-
return null; // No series to move the focus to.
|
|
71
|
-
}
|
|
72
|
-
type = nextSeries.type;
|
|
73
|
-
seriesId = nextSeries.seriesId;
|
|
74
|
-
const dataLength = processedSeries[type].series[seriesId].data.length;
|
|
75
|
-
return {
|
|
76
|
-
type,
|
|
77
|
-
seriesId,
|
|
78
|
-
dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
function getPreviousSeriesFocusedItem(state) {
|
|
82
|
-
const processedSeries = (0, _useChartSeries.selectorChartSeriesProcessed)(state);
|
|
83
|
-
let {
|
|
84
|
-
type,
|
|
85
|
-
seriesId
|
|
86
|
-
} = state.keyboardNavigation.item ?? {};
|
|
87
|
-
const previousSeries = (0, _useChartKeyboardNavigation.getPreviousSeriesWithData)(processedSeries, type, seriesId);
|
|
88
|
-
if (previousSeries === null) {
|
|
89
|
-
return null; // No series to move the focus to.
|
|
90
|
-
}
|
|
91
|
-
type = previousSeries.type;
|
|
92
|
-
seriesId = previousSeries.seriesId;
|
|
93
|
-
const dataLength = processedSeries[type].series[seriesId].data.length;
|
|
94
|
-
return {
|
|
95
|
-
type,
|
|
96
|
-
seriesId,
|
|
97
|
-
dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
15
|
const useChartKeyboardNavigation = ({
|
|
101
16
|
params,
|
|
102
17
|
store,
|
|
@@ -116,26 +31,18 @@ const useChartKeyboardNavigation = ({
|
|
|
116
31
|
}
|
|
117
32
|
function keyboardHandler(event) {
|
|
118
33
|
let newFocusedItem = store.state.keyboardNavigation.item;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
case 'ArrowUp':
|
|
132
|
-
{
|
|
133
|
-
newFocusedItem = getNextSeriesFocusedItem(store.state);
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
default:
|
|
137
|
-
break;
|
|
34
|
+
let seriesType = newFocusedItem?.type;
|
|
35
|
+
if (!seriesType) {
|
|
36
|
+
seriesType = Object.keys((0, _useChartSeries.selectorChartDefaultizedSeries)(store.state)).find(key => store.state.series.seriesConfig[key] !== undefined);
|
|
37
|
+
if (seriesType === undefined) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const calculateFocusedItem = store.state.series.seriesConfig[seriesType]?.keyboardFocusHandler?.(event);
|
|
42
|
+
if (!calculateFocusedItem) {
|
|
43
|
+
return;
|
|
138
44
|
}
|
|
45
|
+
newFocusedItem = calculateFocusedItem(newFocusedItem, store.state);
|
|
139
46
|
if (newFocusedItem !== store.state.keyboardNavigation.item) {
|
|
140
47
|
event.preventDefault();
|
|
141
48
|
store.update((0, _extends2.default)({}, 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;
|
|
@@ -3,29 +3,26 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.selectorChartsKeyboardYAxisIndex = exports.selectorChartsKeyboardXAxisIndex = exports.
|
|
6
|
+
exports.selectorChartsKeyboardYAxisIndex = exports.selectorChartsKeyboardXAxisIndex = exports.selectorChartsKeyboardItem = exports.selectorChartsItemIsFocused = exports.selectorChartsIsKeyboardNavigationEnabled = exports.selectorChartsHasFocusedItem = exports.selectorChartsFocusedItem = void 0;
|
|
7
7
|
var _store = require("@mui/x-internals/store");
|
|
8
|
+
var _fastObjectShallowCompare = require("@mui/x-internals/fastObjectShallowCompare");
|
|
8
9
|
var _useChartSeries = require("../../corePlugins/useChartSeries");
|
|
9
10
|
var _useChartCartesianAxisRendering = require("../useChartCartesianAxis/useChartCartesianAxisRendering.selectors");
|
|
10
11
|
const selectKeyboardNavigation = state => state.keyboardNavigation;
|
|
11
|
-
const selectorChartsItemIsFocused = exports.selectorChartsItemIsFocused = (0, _store.createSelector)(selectKeyboardNavigation, (keyboardNavigationState, item) =>
|
|
12
|
-
return keyboardNavigationState?.item != null && keyboardNavigationState.item.type === item.seriesType && keyboardNavigationState.item.seriesId === item.seriesId && keyboardNavigationState.item.dataIndex === item.dataIndex;
|
|
13
|
-
});
|
|
12
|
+
const selectorChartsItemIsFocused = exports.selectorChartsItemIsFocused = (0, _store.createSelector)(selectKeyboardNavigation, (keyboardNavigationState, item) => keyboardNavigationState?.item != null && (0, _fastObjectShallowCompare.fastObjectShallowCompare)(keyboardNavigationState.item, item));
|
|
14
13
|
const selectorChartsHasFocusedItem = exports.selectorChartsHasFocusedItem = (0, _store.createSelector)(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item != null);
|
|
15
|
-
const
|
|
16
|
-
const selectorChartsFocusedSeriesId = exports.selectorChartsFocusedSeriesId = (0, _store.createSelector)(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item?.seriesId);
|
|
17
|
-
const selectorChartsFocusedDataIndex = exports.selectorChartsFocusedDataIndex = (0, _store.createSelector)(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item?.dataIndex);
|
|
14
|
+
const selectorChartsFocusedItem = exports.selectorChartsFocusedItem = (0, _store.createSelector)(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item ?? null);
|
|
18
15
|
const selectorChartsIsKeyboardNavigationEnabled = exports.selectorChartsIsKeyboardNavigationEnabled = (0, _store.createSelector)(selectKeyboardNavigation, keyboardNavigationState => !!keyboardNavigationState?.enableKeyboardNavigation);
|
|
19
16
|
|
|
20
17
|
/**
|
|
21
18
|
* Selectors to override highlight behavior.
|
|
22
19
|
*/
|
|
23
20
|
|
|
24
|
-
const createSelectAxisHighlight = direction => (
|
|
25
|
-
if (
|
|
21
|
+
const createSelectAxisHighlight = direction => (item, axis, series) => {
|
|
22
|
+
if (item == null || !('dataIndex' in item) || item.dataIndex === undefined) {
|
|
26
23
|
return undefined;
|
|
27
24
|
}
|
|
28
|
-
const seriesConfig = series[type]?.series[seriesId];
|
|
25
|
+
const seriesConfig = series[item.type]?.series[item.seriesId];
|
|
29
26
|
if (!seriesConfig) {
|
|
30
27
|
return undefined;
|
|
31
28
|
}
|
|
@@ -35,11 +32,11 @@ const createSelectAxisHighlight = direction => (type, seriesId, dataIndex, axis,
|
|
|
35
32
|
}
|
|
36
33
|
return {
|
|
37
34
|
axisId,
|
|
38
|
-
dataIndex
|
|
35
|
+
dataIndex: item.dataIndex
|
|
39
36
|
};
|
|
40
37
|
};
|
|
41
|
-
const selectorChartsKeyboardXAxisIndex = exports.selectorChartsKeyboardXAxisIndex = (0, _store.createSelector)(
|
|
42
|
-
const selectorChartsKeyboardYAxisIndex = exports.selectorChartsKeyboardYAxisIndex = (0, _store.createSelector)(
|
|
38
|
+
const selectorChartsKeyboardXAxisIndex = exports.selectorChartsKeyboardXAxisIndex = (0, _store.createSelector)(selectorChartsFocusedItem, _useChartCartesianAxisRendering.selectorChartXAxis, _useChartSeries.selectorChartSeriesProcessed, createSelectAxisHighlight('x'));
|
|
39
|
+
const selectorChartsKeyboardYAxisIndex = exports.selectorChartsKeyboardYAxisIndex = (0, _store.createSelector)(selectorChartsFocusedItem, _useChartCartesianAxisRendering.selectorChartYAxis, _useChartSeries.selectorChartSeriesProcessed, createSelectAxisHighlight('y'));
|
|
43
40
|
const selectorChartsKeyboardItem = exports.selectorChartsKeyboardItem = (0, _store.createSelector)(selectKeyboardNavigation, function selectorChartsKeyboardItem(keyboardState) {
|
|
44
41
|
if (keyboardState?.item == null) {
|
|
45
42
|
return null;
|
|
@@ -52,7 +49,4 @@ const selectorChartsKeyboardItem = exports.selectorChartsKeyboardItem = (0, _sto
|
|
|
52
49
|
return null;
|
|
53
50
|
}
|
|
54
51
|
return keyboardState.item;
|
|
55
|
-
});
|
|
56
|
-
const selectorChartsKeyboardItemIsDefined = exports.selectorChartsKeyboardItemIsDefined = (0, _store.createSelector)(selectorChartsFocusedSeriesType, selectorChartsFocusedSeriesId, selectorChartsFocusedDataIndex, function selectorChartsKeyboardItemIsDefined(seriesType, seriesId, dataIndex) {
|
|
57
|
-
return seriesId !== undefined && dataIndex !== undefined;
|
|
58
52
|
});
|
|
@@ -1,27 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import type { ChartPluginSignature } from "../../models/index.js";
|
|
2
|
+
import type { UseChartInteractionSignature } from "../useChartInteraction/index.js";
|
|
3
|
+
import type { UseChartHighlightSignature } from "../useChartHighlight/index.js";
|
|
4
|
+
import type { FocusedItemIdentifier } from "../../../../models/seriesType/index.js";
|
|
5
|
+
import type { ChartSeriesType } from "../../../../models/seriesType/config.js";
|
|
6
6
|
export interface UseChartKeyboardNavigationInstance {}
|
|
7
|
-
type SeriesItemIdentifier<SeriesType extends ChartSeriesType = FocusableSeriesTypes> = SeriesType extends FocusableSeriesTypes ? {
|
|
8
|
-
/**
|
|
9
|
-
* The type of the series
|
|
10
|
-
*/
|
|
11
|
-
type: SeriesType;
|
|
12
|
-
/**
|
|
13
|
-
* The id of the series with focus.
|
|
14
|
-
*/
|
|
15
|
-
seriesId: SeriesId;
|
|
16
|
-
/**
|
|
17
|
-
* The index of the data point with focus.
|
|
18
|
-
*/
|
|
19
|
-
dataIndex: number;
|
|
20
|
-
} : never;
|
|
21
|
-
export type FocusableSeriesTypes = 'bar' | 'line' | 'scatter' | 'pie';
|
|
22
7
|
export interface UseChartKeyboardNavigationState {
|
|
23
8
|
keyboardNavigation: {
|
|
24
|
-
item: null |
|
|
9
|
+
item: null | FocusedItemIdentifier<ChartSeriesType>;
|
|
25
10
|
enableKeyboardNavigation: boolean;
|
|
26
11
|
};
|
|
27
12
|
}
|
package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ChartSeriesType } from "../../../../../models/seriesType/config.js";
|
|
2
|
+
import type { SeriesId } from "../../../../../models/seriesType/common.js";
|
|
3
|
+
import type { ProcessedSeries } from "../../../corePlugins/useChartSeries/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Returns the next series type and id that contains some data.
|
|
6
|
+
* Returns `null` if no other series have data.
|
|
7
|
+
* @param series - The processed series from the store.
|
|
8
|
+
* @param availableSeriesTypes - The set of series types that can be focused.
|
|
9
|
+
* @param type - The current series type.
|
|
10
|
+
* @param seriesId - The current series id.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getNextNonEmptySeries<OutSeriesType extends Exclude<ChartSeriesType, 'sankey'> = Exclude<ChartSeriesType, 'sankey'>>(series: ProcessedSeries<ChartSeriesType>, availableSeriesTypes: Set<OutSeriesType>, type?: ChartSeriesType, seriesId?: SeriesId): {
|
|
13
|
+
type: OutSeriesType;
|
|
14
|
+
seriesId: SeriesId;
|
|
15
|
+
} | null;
|
package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getNextNonEmptySeries = getNextNonEmptySeries;
|
|
7
|
+
/**
|
|
8
|
+
* Returns the next series type and id that contains some data.
|
|
9
|
+
* Returns `null` if no other series have data.
|
|
10
|
+
* @param series - The processed series from the store.
|
|
11
|
+
* @param availableSeriesTypes - The set of series types that can be focused.
|
|
12
|
+
* @param type - The current series type.
|
|
13
|
+
* @param seriesId - The current series id.
|
|
14
|
+
*/
|
|
15
|
+
function getNextNonEmptySeries(series, availableSeriesTypes, type, seriesId) {
|
|
16
|
+
const seriesType = Object.keys(series);
|
|
17
|
+
const currentSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : -1;
|
|
18
|
+
const typesAvailable = seriesType.filter(t => availableSeriesTypes?.has(t));
|
|
19
|
+
const startingTypeIndex = type !== undefined && series[type] ? typesAvailable.indexOf(type) : 0;
|
|
20
|
+
|
|
21
|
+
// Loop over all series types starting with the current seriesType
|
|
22
|
+
for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
|
|
23
|
+
const typeIndex = (startingTypeIndex + typeGap) % typesAvailable.length;
|
|
24
|
+
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
25
|
+
|
|
26
|
+
// Edge case for the current series type: we don't loop on previous series of the same type.
|
|
27
|
+
const startingSeriesIndex = typeGap === 0 ? currentSeriesIndex + 1 : 0;
|
|
28
|
+
for (let seriesIndex = startingSeriesIndex; seriesIndex < seriesOfType.seriesOrder.length; seriesIndex += 1) {
|
|
29
|
+
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
30
|
+
return {
|
|
31
|
+
type: typesAvailable[typeIndex],
|
|
32
|
+
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// End looping on the initial type up to the initial series (excluded)
|
|
39
|
+
const typeIndex = startingTypeIndex;
|
|
40
|
+
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
41
|
+
const endingSeriesIndex = currentSeriesIndex;
|
|
42
|
+
for (let seriesIndex = 0; seriesIndex < endingSeriesIndex; seriesIndex += 1) {
|
|
43
|
+
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
44
|
+
return {
|
|
45
|
+
type: typesAvailable[typeIndex],
|
|
46
|
+
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ChartSeriesType } from "../../../../../models/seriesType/config.js";
|
|
2
|
+
import type { SeriesId } from "../../../../../models/seriesType/common.js";
|
|
3
|
+
import type { ProcessedSeries } from "../../../corePlugins/useChartSeries/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Returns the previous series type and id that contains some data.
|
|
6
|
+
* Returns `null` if no other series have data.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getPreviousNonEmptySeries<OutSeriesType extends Exclude<ChartSeriesType, 'sankey'> = Exclude<ChartSeriesType, 'sankey'>>(series: ProcessedSeries<ChartSeriesType>, availableSeriesTypes: Set<OutSeriesType>, type?: ChartSeriesType, seriesId?: SeriesId): {
|
|
9
|
+
type: OutSeriesType;
|
|
10
|
+
seriesId: SeriesId;
|
|
11
|
+
} | null;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getPreviousNonEmptySeries = getPreviousNonEmptySeries;
|
|
7
|
+
/**
|
|
8
|
+
* Returns the previous series type and id that contains some data.
|
|
9
|
+
* Returns `null` if no other series have data.
|
|
10
|
+
*/
|
|
11
|
+
function getPreviousNonEmptySeries(series, availableSeriesTypes, type, seriesId) {
|
|
12
|
+
const seriesType = Object.keys(series);
|
|
13
|
+
const startingSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : 1;
|
|
14
|
+
const typesAvailable = seriesType.filter(t => availableSeriesTypes?.has(t));
|
|
15
|
+
const startingTypeIndex = type !== undefined && series[type] ? typesAvailable.indexOf(type) : 0;
|
|
16
|
+
|
|
17
|
+
// Loop over all series types starting with the current seriesType
|
|
18
|
+
for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
|
|
19
|
+
const typeIndex = (typesAvailable.length + startingTypeIndex - typeGap) % typesAvailable.length;
|
|
20
|
+
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
21
|
+
const maxGap = typeGap === 0 ? startingSeriesIndex + 1 : seriesOfType.seriesOrder.length;
|
|
22
|
+
for (let seriesGap = 1; seriesGap < maxGap; seriesGap += 1) {
|
|
23
|
+
const seriesIndex = (seriesOfType.seriesOrder.length + startingSeriesIndex - seriesGap) % seriesOfType.seriesOrder.length;
|
|
24
|
+
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
25
|
+
return {
|
|
26
|
+
type: typesAvailable[typeIndex],
|
|
27
|
+
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// End looping on the initial type down to the initial series (excluded)
|
|
34
|
+
const typeIndex = startingTypeIndex;
|
|
35
|
+
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
36
|
+
const availableSeriesIds = seriesOfType.seriesOrder;
|
|
37
|
+
for (let seriesIndex = availableSeriesIds.length - 1; seriesIndex > startingSeriesIndex; seriesIndex -= 1) {
|
|
38
|
+
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
39
|
+
return {
|
|
40
|
+
type: typesAvailable[typeIndex],
|
|
41
|
+
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
@@ -10,7 +10,6 @@ exports.useChartPolarAxis = void 0;
|
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _warning = require("@mui/x-internals/warning");
|
|
13
|
-
var _useSelector = require("../../../store/useSelector");
|
|
14
13
|
var _useChartDimensions = require("../../corePlugins/useChartDimensions/useChartDimensions.selectors");
|
|
15
14
|
var _defaultizeAxis = require("./defaultizeAxis");
|
|
16
15
|
var _useChartInteraction = require("../useChartInteraction");
|
|
@@ -39,18 +38,18 @@ const useChartPolarAxis = ({
|
|
|
39
38
|
(0, _warning.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');
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
|
-
const drawingArea =
|
|
43
|
-
const processedSeries =
|
|
44
|
-
const center =
|
|
45
|
-
const isInteractionEnabled =
|
|
41
|
+
const drawingArea = store.use(_useChartDimensions.selectorChartDrawingArea);
|
|
42
|
+
const processedSeries = store.use(_useChartSeries.selectorChartSeriesProcessed);
|
|
43
|
+
const center = store.use(_useChartPolarAxis.selectorChartPolarCenter);
|
|
44
|
+
const isInteractionEnabled = store.use(_useChartInteraction.selectorChartsInteractionIsInitialized);
|
|
46
45
|
const {
|
|
47
46
|
axis: rotationAxisWithScale,
|
|
48
47
|
axisIds: rotationAxisIds
|
|
49
|
-
} =
|
|
48
|
+
} = store.use(_useChartPolarAxis.selectorChartRotationAxis);
|
|
50
49
|
const {
|
|
51
50
|
axis: radiusAxisWithScale,
|
|
52
51
|
axisIds: radiusAxisIds
|
|
53
|
-
} =
|
|
52
|
+
} = store.use(_useChartPolarAxis.selectorChartRadiusAxis);
|
|
54
53
|
|
|
55
54
|
// The effect do not track any value defined synchronously during the 1st render by hooks called after `useChartPolarAxis`
|
|
56
55
|
// As a consequence, the state generated by the 1st run of this useEffect will always be equal to the initialization one
|