@mui/x-charts 7.5.1 → 7.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/BarChart.js +18 -1
- package/BarChart/BarElement.d.ts +0 -3
- package/BarChart/BarElement.js +7 -18
- package/BarChart/BarLabel/BarLabelItem.js +5 -16
- package/BarChart/BarLabel/BarLabelPlot.js +0 -4
- package/BarChart/BarPlot.js +4 -30
- package/BarChart/checkScaleErrors.d.ts +11 -0
- package/BarChart/checkScaleErrors.js +33 -0
- package/BarChart/types.d.ts +0 -2
- package/CHANGELOG.md +112 -1
- package/ChartContainer/ChartContainer.d.ts +3 -2
- package/ChartContainer/ChartContainer.js +19 -2
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +13 -1
- package/LineChart/AreaElement.d.ts +0 -2
- package/LineChart/AreaElement.js +7 -17
- package/LineChart/AreaPlot.js +0 -2
- package/LineChart/LineChart.js +18 -1
- package/LineChart/LineElement.d.ts +0 -2
- package/LineChart/LineElement.js +7 -17
- package/LineChart/LinePlot.js +0 -2
- package/LineChart/MarkElement.d.ts +0 -2
- package/LineChart/MarkElement.js +10 -17
- package/LineChart/MarkPlot.js +0 -1
- package/PieChart/PieArc.d.ts +4 -1
- package/PieChart/PieArc.js +7 -3
- package/PieChart/PieArcLabelPlot.d.ts +1 -1
- package/PieChart/PieArcLabelPlot.js +1 -7
- package/PieChart/PieArcPlot.d.ts +1 -1
- package/PieChart/PieArcPlot.js +5 -7
- package/PieChart/PieChart.js +18 -1
- package/PieChart/PiePlot.js +2 -6
- package/PieChart/dataTransform/useTransformData.d.ts +1 -1
- package/PieChart/dataTransform/useTransformData.js +10 -25
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +13 -0
- package/ScatterChart/Scatter.js +14 -10
- package/ScatterChart/ScatterChart.js +18 -1
- package/SparkLineChart/SparkLineChart.js +13 -0
- package/context/HighlightedProvider/HighlightedContext.d.ts +65 -0
- package/context/HighlightedProvider/HighlightedContext.js +36 -0
- package/context/HighlightedProvider/HighlightedProvider.d.ts +20 -0
- package/context/HighlightedProvider/HighlightedProvider.js +97 -0
- package/context/HighlightedProvider/createIsFaded.d.ts +2 -0
- package/context/HighlightedProvider/createIsFaded.js +19 -0
- package/context/HighlightedProvider/createIsHighlighted.d.ts +2 -0
- package/context/HighlightedProvider/createIsHighlighted.js +19 -0
- package/context/HighlightedProvider/index.d.ts +4 -0
- package/context/HighlightedProvider/index.js +49 -0
- package/context/HighlightedProvider/useHighlighted.d.ts +9 -0
- package/context/HighlightedProvider/useHighlighted.js +24 -0
- package/context/HighlightedProvider/useItemHighlighted.d.ts +21 -0
- package/context/HighlightedProvider/useItemHighlighted.js +37 -0
- package/context/index.d.ts +1 -1
- package/context/index.js +15 -0
- package/esm/BarChart/BarChart.js +18 -1
- package/esm/BarChart/BarElement.js +8 -19
- package/esm/BarChart/BarLabel/BarLabelItem.js +5 -16
- package/esm/BarChart/BarLabel/BarLabelPlot.js +0 -4
- package/esm/BarChart/BarPlot.js +4 -30
- package/esm/BarChart/checkScaleErrors.js +27 -0
- package/esm/ChartContainer/ChartContainer.js +19 -2
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +13 -1
- package/esm/LineChart/AreaElement.js +8 -18
- package/esm/LineChart/AreaPlot.js +0 -2
- package/esm/LineChart/LineChart.js +18 -1
- package/esm/LineChart/LineElement.js +8 -18
- package/esm/LineChart/LinePlot.js +0 -2
- package/esm/LineChart/MarkElement.js +11 -18
- package/esm/LineChart/MarkPlot.js +0 -1
- package/esm/PieChart/PieArc.js +7 -3
- package/esm/PieChart/PieArcLabelPlot.js +1 -7
- package/esm/PieChart/PieArcPlot.js +5 -7
- package/esm/PieChart/PieChart.js +18 -1
- package/esm/PieChart/PiePlot.js +2 -6
- package/esm/PieChart/dataTransform/useTransformData.js +10 -25
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +13 -0
- package/esm/ScatterChart/Scatter.js +15 -11
- package/esm/ScatterChart/ScatterChart.js +18 -1
- package/esm/SparkLineChart/SparkLineChart.js +13 -0
- package/esm/context/HighlightedProvider/HighlightedContext.js +29 -0
- package/esm/context/HighlightedProvider/HighlightedProvider.js +89 -0
- package/esm/context/HighlightedProvider/createIsFaded.js +12 -0
- package/esm/context/HighlightedProvider/createIsHighlighted.js +12 -0
- package/esm/context/HighlightedProvider/index.js +4 -0
- package/esm/context/HighlightedProvider/useHighlighted.js +17 -0
- package/esm/context/HighlightedProvider/useItemHighlighted.js +29 -0
- package/esm/context/index.js +1 -0
- package/esm/hooks/useInteractionItemProps.js +9 -41
- package/hooks/useInteractionItemProps.d.ts +1 -4
- package/hooks/useInteractionItemProps.js +11 -45
- package/index.js +1 -1
- package/internals/colorScale.d.ts +1 -1
- package/internals/defaultizeColor.d.ts +13 -13
- package/models/seriesType/common.d.ts +4 -1
- package/modern/BarChart/BarChart.js +18 -1
- package/modern/BarChart/BarElement.js +8 -19
- package/modern/BarChart/BarLabel/BarLabelItem.js +5 -16
- package/modern/BarChart/BarLabel/BarLabelPlot.js +0 -4
- package/modern/BarChart/BarPlot.js +4 -30
- package/modern/BarChart/checkScaleErrors.js +27 -0
- package/modern/ChartContainer/ChartContainer.js +19 -2
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +13 -1
- package/modern/LineChart/AreaElement.js +8 -18
- package/modern/LineChart/AreaPlot.js +0 -2
- package/modern/LineChart/LineChart.js +18 -1
- package/modern/LineChart/LineElement.js +8 -18
- package/modern/LineChart/LinePlot.js +0 -2
- package/modern/LineChart/MarkElement.js +11 -18
- package/modern/LineChart/MarkPlot.js +0 -1
- package/modern/PieChart/PieArc.js +7 -3
- package/modern/PieChart/PieArcLabelPlot.js +1 -7
- package/modern/PieChart/PieArcPlot.js +5 -7
- package/modern/PieChart/PieChart.js +18 -1
- package/modern/PieChart/PiePlot.js +2 -6
- package/modern/PieChart/dataTransform/useTransformData.js +10 -25
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +13 -0
- package/modern/ScatterChart/Scatter.js +15 -11
- package/modern/ScatterChart/ScatterChart.js +18 -1
- package/modern/SparkLineChart/SparkLineChart.js +13 -0
- package/modern/context/HighlightedProvider/HighlightedContext.js +29 -0
- package/modern/context/HighlightedProvider/HighlightedProvider.js +89 -0
- package/modern/context/HighlightedProvider/createIsFaded.js +12 -0
- package/modern/context/HighlightedProvider/createIsHighlighted.js +12 -0
- package/modern/context/HighlightedProvider/index.js +4 -0
- package/modern/context/HighlightedProvider/useHighlighted.js +17 -0
- package/modern/context/HighlightedProvider/useItemHighlighted.js +29 -0
- package/modern/context/index.js +1 -0
- package/modern/hooks/useInteractionItemProps.js +9 -41
- package/modern/index.js +1 -1
- package/package.json +3 -3
- package/context/HighlightProvider.d.ts +0 -45
- package/context/HighlightProvider.js +0 -60
- package/esm/context/HighlightProvider.js +0 -51
- package/modern/context/HighlightProvider.js +0 -51
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["highlighted", "faded"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import useControlled from '@mui/utils/useControlled';
|
|
7
|
+
import { HighlightedContext } from './HighlightedContext';
|
|
8
|
+
import { createIsFaded } from './createIsFaded';
|
|
9
|
+
import { createIsHighlighted } from './createIsHighlighted';
|
|
10
|
+
import { useSeries } from '../../hooks/useSeries';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
const mergeDeprecatedOptions = options => {
|
|
13
|
+
const _ref = options ?? {},
|
|
14
|
+
{
|
|
15
|
+
highlighted,
|
|
16
|
+
faded
|
|
17
|
+
} = _ref,
|
|
18
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
19
|
+
return _extends({
|
|
20
|
+
highlight: highlighted,
|
|
21
|
+
fade: faded
|
|
22
|
+
}, rest);
|
|
23
|
+
};
|
|
24
|
+
function HighlightedProvider({
|
|
25
|
+
children,
|
|
26
|
+
highlightedItem: highlightedItemProps,
|
|
27
|
+
onHighlightChange
|
|
28
|
+
}) {
|
|
29
|
+
const [highlightedItem, setHighlightedItem] = useControlled({
|
|
30
|
+
controlled: highlightedItemProps,
|
|
31
|
+
default: null,
|
|
32
|
+
name: 'HighlightedProvider',
|
|
33
|
+
state: 'highlightedItem'
|
|
34
|
+
});
|
|
35
|
+
const series = useSeries();
|
|
36
|
+
const seriesById = React.useMemo(() => {
|
|
37
|
+
const map = new Map();
|
|
38
|
+
Object.keys(series).forEach(seriesType => {
|
|
39
|
+
const seriesData = series[seriesType];
|
|
40
|
+
Object.keys(seriesData?.series ?? {}).forEach(seriesId => {
|
|
41
|
+
const seriesItem = seriesData?.series[seriesId];
|
|
42
|
+
map.set(seriesId, mergeDeprecatedOptions(seriesItem?.highlightScope));
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
return map;
|
|
46
|
+
}, [series]);
|
|
47
|
+
const highlightScope = highlightedItem && highlightedItem.seriesId ? seriesById.get(highlightedItem.seriesId) ?? undefined : undefined;
|
|
48
|
+
const providerValue = React.useMemo(() => {
|
|
49
|
+
return {
|
|
50
|
+
highlightScope,
|
|
51
|
+
highlightedItem,
|
|
52
|
+
setHighlighted: itemData => {
|
|
53
|
+
setHighlightedItem(itemData);
|
|
54
|
+
onHighlightChange?.(itemData);
|
|
55
|
+
},
|
|
56
|
+
clearHighlighted: () => {
|
|
57
|
+
setHighlightedItem(null);
|
|
58
|
+
onHighlightChange?.(null);
|
|
59
|
+
},
|
|
60
|
+
isHighlighted: createIsHighlighted(highlightScope, highlightedItem),
|
|
61
|
+
isFaded: createIsFaded(highlightScope, highlightedItem)
|
|
62
|
+
};
|
|
63
|
+
}, [highlightedItem, highlightScope, setHighlightedItem, onHighlightChange]);
|
|
64
|
+
return /*#__PURE__*/_jsx(HighlightedContext.Provider, {
|
|
65
|
+
value: providerValue,
|
|
66
|
+
children: children
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
process.env.NODE_ENV !== "production" ? HighlightedProvider.propTypes = {
|
|
70
|
+
// ----------------------------- Warning --------------------------------
|
|
71
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
72
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
73
|
+
// ----------------------------------------------------------------------
|
|
74
|
+
children: PropTypes.node,
|
|
75
|
+
/**
|
|
76
|
+
* The item currently highlighted. Turns highlighting into a controlled prop.
|
|
77
|
+
*/
|
|
78
|
+
highlightedItem: PropTypes.shape({
|
|
79
|
+
dataIndex: PropTypes.number,
|
|
80
|
+
seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
81
|
+
}),
|
|
82
|
+
/**
|
|
83
|
+
* The callback fired when the highlighted item changes.
|
|
84
|
+
*
|
|
85
|
+
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
86
|
+
*/
|
|
87
|
+
onHighlightChange: PropTypes.func
|
|
88
|
+
} : void 0;
|
|
89
|
+
export { HighlightedProvider };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const createIsFaded = (highlightScope, highlightedItem) => input => {
|
|
2
|
+
if (!highlightScope) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
if (highlightScope.fade === 'series') {
|
|
6
|
+
return input.seriesId === highlightedItem?.seriesId && input.dataIndex !== highlightedItem?.dataIndex;
|
|
7
|
+
}
|
|
8
|
+
if (highlightScope.fade === 'global') {
|
|
9
|
+
return input.seriesId !== highlightedItem?.seriesId || input.dataIndex !== highlightedItem?.dataIndex;
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const createIsHighlighted = (highlightScope, highlightedItem) => input => {
|
|
2
|
+
if (!highlightScope) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
if (highlightScope.highlight === 'series') {
|
|
6
|
+
return input.seriesId === highlightedItem?.seriesId;
|
|
7
|
+
}
|
|
8
|
+
if (highlightScope.highlight === 'item') {
|
|
9
|
+
return input.dataIndex === highlightedItem?.dataIndex && input.seriesId === highlightedItem?.seriesId;
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { HighlightedContext } from './HighlightedContext';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A hook to get the highlighted state of the chart.
|
|
6
|
+
*
|
|
7
|
+
* Please consider using the `useItemHighlighted` hook if you need to check the state of a specific item.
|
|
8
|
+
*
|
|
9
|
+
* @returns {HighlightedState} the state of the chart
|
|
10
|
+
*/
|
|
11
|
+
export function useHighlighted() {
|
|
12
|
+
const highlighted = React.useContext(HighlightedContext);
|
|
13
|
+
if (highlighted === undefined) {
|
|
14
|
+
throw new Error(['MUI X: Could not find the highlighted ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
|
|
15
|
+
}
|
|
16
|
+
return highlighted;
|
|
17
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { HighlightedContext } from './HighlightedContext';
|
|
3
|
+
/**
|
|
4
|
+
* A hook to check the highlighted state of the item.
|
|
5
|
+
* This function already calculates that an item is not faded if it is highlighted.
|
|
6
|
+
*
|
|
7
|
+
* If you need fine control over the state, use the `useHighlighted` hook instead.
|
|
8
|
+
*
|
|
9
|
+
* @param {HighlightItemData} item is the item to check
|
|
10
|
+
* @returns {ItemHighlightedState} the state of the item
|
|
11
|
+
*/
|
|
12
|
+
export function useItemHighlighted(item) {
|
|
13
|
+
const highlighted = React.useContext(HighlightedContext);
|
|
14
|
+
if (highlighted === undefined) {
|
|
15
|
+
throw new Error(['MUI X: Could not find the highlighted ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
|
|
16
|
+
}
|
|
17
|
+
if (!item) {
|
|
18
|
+
return {
|
|
19
|
+
isHighlighted: false,
|
|
20
|
+
isFaded: false
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const isHighlighted = highlighted.isHighlighted(item);
|
|
24
|
+
const isFaded = !isHighlighted && highlighted.isFaded(item);
|
|
25
|
+
return {
|
|
26
|
+
isHighlighted,
|
|
27
|
+
isFaded
|
|
28
|
+
};
|
|
29
|
+
}
|
package/modern/context/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
3
|
-
import {
|
|
4
|
-
export const useInteractionItemProps =
|
|
3
|
+
import { HighlightedContext } from '../context';
|
|
4
|
+
export const useInteractionItemProps = skip => {
|
|
5
5
|
const {
|
|
6
6
|
dispatch: dispatchInteraction
|
|
7
7
|
} = React.useContext(InteractionContext);
|
|
8
8
|
const {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
setHighlighted,
|
|
10
|
+
clearHighlighted
|
|
11
|
+
} = React.useContext(HighlightedContext);
|
|
11
12
|
if (skip) {
|
|
12
13
|
return () => ({});
|
|
13
14
|
}
|
|
@@ -17,10 +18,9 @@ export const useInteractionItemProps = (scope, skip) => {
|
|
|
17
18
|
type: 'enterItem',
|
|
18
19
|
data
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
scope
|
|
21
|
+
setHighlighted({
|
|
22
|
+
seriesId: data.seriesId,
|
|
23
|
+
dataIndex: data.dataIndex
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
26
|
const onMouseLeave = () => {
|
|
@@ -28,10 +28,7 @@ export const useInteractionItemProps = (scope, skip) => {
|
|
|
28
28
|
type: 'leaveItem',
|
|
29
29
|
data
|
|
30
30
|
});
|
|
31
|
-
|
|
32
|
-
type: 'leaveItem',
|
|
33
|
-
item: data
|
|
34
|
-
});
|
|
31
|
+
clearHighlighted();
|
|
35
32
|
};
|
|
36
33
|
return {
|
|
37
34
|
onMouseEnter,
|
|
@@ -39,33 +36,4 @@ export const useInteractionItemProps = (scope, skip) => {
|
|
|
39
36
|
};
|
|
40
37
|
};
|
|
41
38
|
return getInteractionItemProps;
|
|
42
|
-
};
|
|
43
|
-
export const getIsHighlighted = (selectedItem, currentItem, highlightScope) => {
|
|
44
|
-
if (!highlightScope?.highlighted || highlightScope.highlighted === 'none' || selectedItem === null) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
const isSeriesSelected = selectedItem.type === currentItem.type && selectedItem.seriesId === currentItem.seriesId;
|
|
48
|
-
if (!isSeriesSelected) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
if (highlightScope.highlighted === 'series') {
|
|
52
|
-
return isSeriesSelected;
|
|
53
|
-
}
|
|
54
|
-
return selectedItem.dataIndex !== undefined && selectedItem.dataIndex === currentItem.dataIndex;
|
|
55
|
-
};
|
|
56
|
-
export const getIsFaded = (selectedItem, currentItem, highlightScope) => {
|
|
57
|
-
if (!highlightScope?.faded || highlightScope.faded === 'none' || selectedItem === null) {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
const isSeriesSelected = selectedItem.type === currentItem.type && selectedItem.seriesId === currentItem.seriesId;
|
|
61
|
-
if (highlightScope.faded === 'series') {
|
|
62
|
-
return isSeriesSelected && selectedItem.dataIndex !== currentItem.dataIndex;
|
|
63
|
-
}
|
|
64
|
-
if (highlightScope.faded === 'global') {
|
|
65
|
-
if (!isSeriesSelected) {
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
return selectedItem.dataIndex !== undefined && selectedItem.dataIndex !== currentItem.dataIndex;
|
|
69
|
-
}
|
|
70
|
-
return false;
|
|
71
39
|
};
|
package/modern/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-charts",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.1",
|
|
4
4
|
"description": "The community edition of the Charts components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"directory": "packages/x-charts"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@babel/runtime": "^7.24.
|
|
32
|
+
"@babel/runtime": "^7.24.6",
|
|
33
33
|
"@mui/base": "^5.0.0-beta.40",
|
|
34
|
-
"@mui/system": "^5.15.
|
|
34
|
+
"@mui/system": "^5.15.15",
|
|
35
35
|
"@mui/utils": "^5.15.14",
|
|
36
36
|
"@react-spring/rafz": "^9.7.3",
|
|
37
37
|
"@react-spring/web": "^9.7.3",
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ChartItemIdentifier, ChartSeriesType } from '../models/seriesType/config';
|
|
3
|
-
export interface HighlightProviderProps {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
}
|
|
6
|
-
export type ItemHighlighData<T extends ChartSeriesType> = ChartItemIdentifier<T>;
|
|
7
|
-
export type HighlightOptions = 'none' | 'item' | 'series';
|
|
8
|
-
export type FadeOptions = 'none' | 'series' | 'global';
|
|
9
|
-
export type HighlightScope = {
|
|
10
|
-
/**
|
|
11
|
-
* The scope of highlighted elements.
|
|
12
|
-
* - 'none': no highlight.
|
|
13
|
-
* - 'item': only highlight the item.
|
|
14
|
-
* - 'series': highlight all elements of the same series.
|
|
15
|
-
* @default 'none'
|
|
16
|
-
*/
|
|
17
|
-
highlighted: HighlightOptions;
|
|
18
|
-
/**
|
|
19
|
-
* The scope of faded elements.
|
|
20
|
-
* - 'none': no fading.
|
|
21
|
-
* - 'series': only fade element of the same series.
|
|
22
|
-
* - 'global': fade all elements that are not highlighted.
|
|
23
|
-
* @default 'none'
|
|
24
|
-
*/
|
|
25
|
-
faded: FadeOptions;
|
|
26
|
-
};
|
|
27
|
-
type HighlighActions<T extends ChartSeriesType = ChartSeriesType> = {
|
|
28
|
-
type: 'enterItem';
|
|
29
|
-
item: ItemHighlighData<T>;
|
|
30
|
-
scope?: Partial<HighlightScope>;
|
|
31
|
-
} | {
|
|
32
|
-
type: 'leaveItem';
|
|
33
|
-
item: ItemHighlighData<T>;
|
|
34
|
-
};
|
|
35
|
-
type HighlighState = {
|
|
36
|
-
/**
|
|
37
|
-
* The item that triggers the highlight state.
|
|
38
|
-
*/
|
|
39
|
-
item: null | ItemHighlighData<ChartSeriesType>;
|
|
40
|
-
scope: HighlightScope;
|
|
41
|
-
dispatch: React.Dispatch<HighlighActions>;
|
|
42
|
-
};
|
|
43
|
-
export declare const HighlighContext: React.Context<HighlighState>;
|
|
44
|
-
declare function HighlightProvider(props: HighlightProviderProps): React.JSX.Element;
|
|
45
|
-
export { HighlightProvider };
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.HighlighContext = void 0;
|
|
8
|
-
exports.HighlightProvider = HighlightProvider;
|
|
9
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
-
var React = _interopRequireWildcard(require("react"));
|
|
11
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
|
-
const defaultScope = {
|
|
15
|
-
highlighted: 'none',
|
|
16
|
-
faded: 'none'
|
|
17
|
-
};
|
|
18
|
-
const HighlighContext = exports.HighlighContext = /*#__PURE__*/React.createContext({
|
|
19
|
-
item: null,
|
|
20
|
-
scope: defaultScope,
|
|
21
|
-
dispatch: () => null
|
|
22
|
-
});
|
|
23
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
24
|
-
HighlighContext.displayName = 'HighlighContext';
|
|
25
|
-
}
|
|
26
|
-
const dataReducer = (prevState, action) => {
|
|
27
|
-
switch (action.type) {
|
|
28
|
-
case 'enterItem':
|
|
29
|
-
return (0, _extends2.default)({}, prevState, {
|
|
30
|
-
item: action.item,
|
|
31
|
-
scope: (0, _extends2.default)({}, defaultScope, action.scope)
|
|
32
|
-
});
|
|
33
|
-
case 'leaveItem':
|
|
34
|
-
if (prevState.item === null || Object.keys(action.item).some(key => action.item[key] !== prevState.item[key])) {
|
|
35
|
-
// The item is already something else
|
|
36
|
-
return prevState;
|
|
37
|
-
}
|
|
38
|
-
return (0, _extends2.default)({}, prevState, {
|
|
39
|
-
item: null
|
|
40
|
-
});
|
|
41
|
-
default:
|
|
42
|
-
return prevState;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
function HighlightProvider(props) {
|
|
46
|
-
const {
|
|
47
|
-
children
|
|
48
|
-
} = props;
|
|
49
|
-
const [data, dispatch] = React.useReducer(dataReducer, {
|
|
50
|
-
item: null,
|
|
51
|
-
scope: defaultScope
|
|
52
|
-
});
|
|
53
|
-
const value = React.useMemo(() => (0, _extends2.default)({}, data, {
|
|
54
|
-
dispatch
|
|
55
|
-
}), [data]);
|
|
56
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(HighlighContext.Provider, {
|
|
57
|
-
value: value,
|
|
58
|
-
children: children
|
|
59
|
-
});
|
|
60
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
const defaultScope = {
|
|
5
|
-
highlighted: 'none',
|
|
6
|
-
faded: 'none'
|
|
7
|
-
};
|
|
8
|
-
export const HighlighContext = /*#__PURE__*/React.createContext({
|
|
9
|
-
item: null,
|
|
10
|
-
scope: defaultScope,
|
|
11
|
-
dispatch: () => null
|
|
12
|
-
});
|
|
13
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
14
|
-
HighlighContext.displayName = 'HighlighContext';
|
|
15
|
-
}
|
|
16
|
-
const dataReducer = (prevState, action) => {
|
|
17
|
-
switch (action.type) {
|
|
18
|
-
case 'enterItem':
|
|
19
|
-
return _extends({}, prevState, {
|
|
20
|
-
item: action.item,
|
|
21
|
-
scope: _extends({}, defaultScope, action.scope)
|
|
22
|
-
});
|
|
23
|
-
case 'leaveItem':
|
|
24
|
-
if (prevState.item === null || Object.keys(action.item).some(key => action.item[key] !== prevState.item[key])) {
|
|
25
|
-
// The item is already something else
|
|
26
|
-
return prevState;
|
|
27
|
-
}
|
|
28
|
-
return _extends({}, prevState, {
|
|
29
|
-
item: null
|
|
30
|
-
});
|
|
31
|
-
default:
|
|
32
|
-
return prevState;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
function HighlightProvider(props) {
|
|
36
|
-
const {
|
|
37
|
-
children
|
|
38
|
-
} = props;
|
|
39
|
-
const [data, dispatch] = React.useReducer(dataReducer, {
|
|
40
|
-
item: null,
|
|
41
|
-
scope: defaultScope
|
|
42
|
-
});
|
|
43
|
-
const value = React.useMemo(() => _extends({}, data, {
|
|
44
|
-
dispatch
|
|
45
|
-
}), [data]);
|
|
46
|
-
return /*#__PURE__*/_jsx(HighlighContext.Provider, {
|
|
47
|
-
value: value,
|
|
48
|
-
children: children
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
export { HighlightProvider };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
const defaultScope = {
|
|
5
|
-
highlighted: 'none',
|
|
6
|
-
faded: 'none'
|
|
7
|
-
};
|
|
8
|
-
export const HighlighContext = /*#__PURE__*/React.createContext({
|
|
9
|
-
item: null,
|
|
10
|
-
scope: defaultScope,
|
|
11
|
-
dispatch: () => null
|
|
12
|
-
});
|
|
13
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
14
|
-
HighlighContext.displayName = 'HighlighContext';
|
|
15
|
-
}
|
|
16
|
-
const dataReducer = (prevState, action) => {
|
|
17
|
-
switch (action.type) {
|
|
18
|
-
case 'enterItem':
|
|
19
|
-
return _extends({}, prevState, {
|
|
20
|
-
item: action.item,
|
|
21
|
-
scope: _extends({}, defaultScope, action.scope)
|
|
22
|
-
});
|
|
23
|
-
case 'leaveItem':
|
|
24
|
-
if (prevState.item === null || Object.keys(action.item).some(key => action.item[key] !== prevState.item[key])) {
|
|
25
|
-
// The item is already something else
|
|
26
|
-
return prevState;
|
|
27
|
-
}
|
|
28
|
-
return _extends({}, prevState, {
|
|
29
|
-
item: null
|
|
30
|
-
});
|
|
31
|
-
default:
|
|
32
|
-
return prevState;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
function HighlightProvider(props) {
|
|
36
|
-
const {
|
|
37
|
-
children
|
|
38
|
-
} = props;
|
|
39
|
-
const [data, dispatch] = React.useReducer(dataReducer, {
|
|
40
|
-
item: null,
|
|
41
|
-
scope: defaultScope
|
|
42
|
-
});
|
|
43
|
-
const value = React.useMemo(() => _extends({}, data, {
|
|
44
|
-
dispatch
|
|
45
|
-
}), [data]);
|
|
46
|
-
return /*#__PURE__*/_jsx(HighlighContext.Provider, {
|
|
47
|
-
value: value,
|
|
48
|
-
children: children
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
export { HighlightProvider };
|