@mui/x-charts 7.5.0 → 7.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/BarChart.js +30 -3
- package/BarChart/BarElement.d.ts +0 -3
- package/BarChart/BarElement.js +8 -19
- package/BarChart/BarLabel/BarLabel.d.ts +1342 -0
- package/BarChart/BarLabel/BarLabel.js +60 -0
- package/BarChart/BarLabel/BarLabel.types.d.ts +39 -0
- package/BarChart/BarLabel/BarLabel.types.js +5 -0
- package/BarChart/BarLabel/BarLabelItem.d.ts +53 -0
- package/BarChart/BarLabel/BarLabelItem.js +127 -0
- package/BarChart/BarLabel/BarLabelPlot.d.ts +16 -0
- package/BarChart/BarLabel/BarLabelPlot.js +106 -0
- package/BarChart/BarLabel/barLabelClasses.d.ts +13 -0
- package/BarChart/BarLabel/barLabelClasses.js +29 -0
- package/BarChart/BarLabel/getBarLabel.d.ts +10 -0
- package/BarChart/BarLabel/getBarLabel.js +31 -0
- package/BarChart/BarLabel/index.d.ts +6 -0
- package/BarChart/BarLabel/index.js +25 -0
- package/BarChart/BarPlot.d.ts +15 -4
- package/BarChart/BarPlot.js +22 -34
- package/BarChart/checkScaleErrors.d.ts +11 -0
- package/BarChart/checkScaleErrors.js +33 -0
- package/BarChart/index.d.ts +1 -0
- package/BarChart/index.js +11 -0
- package/BarChart/types.d.ts +0 -2
- package/CHANGELOG.md +148 -5418
- package/ChartContainer/ChartContainer.d.ts +3 -2
- package/ChartContainer/ChartContainer.js +20 -3
- package/ChartsAxis/ChartsAxis.js +1 -1
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/ChartsClipPath/ChartsClipPath.js +1 -1
- package/ChartsGrid/ChartsGrid.js +1 -1
- package/ChartsLegend/ChartsLegend.js +1 -1
- package/ChartsLegend/DefaultChartsLegend.js +1 -1
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
- package/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- package/ChartsSurface.js +1 -1
- package/ChartsText/ChartsText.js +1 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/ChartsTooltip/ChartsItemTooltipContent.js +1 -1
- package/ChartsTooltip/ChartsTooltip.js +1 -1
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +14 -2
- package/ChartsXAxis/ChartsXAxis.js +1 -1
- package/ChartsYAxis/ChartsYAxis.js +1 -1
- package/Gauge/Gauge.js +1 -1
- package/Gauge/GaugeContainer.js +1 -1
- package/Gauge/GaugeValueText.js +1 -1
- package/LineChart/AnimatedArea.js +1 -1
- package/LineChart/AnimatedLine.js +1 -1
- package/LineChart/AreaElement.d.ts +0 -2
- package/LineChart/AreaElement.js +8 -18
- package/LineChart/AreaPlot.js +1 -3
- package/LineChart/LineChart.js +19 -2
- package/LineChart/LineElement.d.ts +0 -2
- package/LineChart/LineElement.js +8 -18
- package/LineChart/LineHighlightElement.js +1 -1
- package/LineChart/LineHighlightPlot.js +1 -1
- package/LineChart/LinePlot.js +1 -3
- package/LineChart/MarkElement.d.ts +0 -2
- package/LineChart/MarkElement.js +11 -33
- package/LineChart/MarkPlot.js +1 -2
- package/PieChart/PieArc.d.ts +4 -1
- package/PieChart/PieArc.js +8 -4
- package/PieChart/PieArcLabel.js +1 -1
- package/PieChart/PieArcLabelPlot.d.ts +1 -1
- package/PieChart/PieArcLabelPlot.js +2 -8
- package/PieChart/PieArcPlot.d.ts +1 -1
- package/PieChart/PieArcPlot.js +6 -8
- package/PieChart/PieChart.js +19 -2
- package/PieChart/PiePlot.js +3 -7
- package/PieChart/dataTransform/useTransformData.d.ts +1 -1
- package/PieChart/dataTransform/useTransformData.js +10 -25
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +14 -1
- package/ScatterChart/Scatter.js +15 -11
- package/ScatterChart/ScatterChart.js +19 -2
- package/ScatterChart/ScatterPlot.js +1 -1
- package/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.js +14 -1
- 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/ZAxisContextProvider.js +1 -1
- package/context/index.d.ts +1 -1
- package/context/index.js +15 -0
- package/esm/BarChart/BarChart.js +30 -3
- package/esm/BarChart/BarElement.js +9 -20
- package/esm/BarChart/BarLabel/BarLabel.js +51 -0
- package/esm/BarChart/BarLabel/BarLabel.types.js +1 -0
- package/esm/BarChart/BarLabel/BarLabelItem.js +119 -0
- package/esm/BarChart/BarLabel/BarLabelPlot.js +98 -0
- package/esm/BarChart/BarLabel/barLabelClasses.js +19 -0
- package/esm/BarChart/BarLabel/getBarLabel.js +24 -0
- package/esm/BarChart/BarLabel/index.js +2 -0
- package/esm/BarChart/BarPlot.js +22 -34
- package/esm/BarChart/checkScaleErrors.js +27 -0
- package/esm/BarChart/index.js +2 -1
- package/esm/ChartContainer/ChartContainer.js +20 -3
- package/esm/ChartsAxis/ChartsAxis.js +1 -1
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/esm/ChartsClipPath/ChartsClipPath.js +1 -1
- package/esm/ChartsGrid/ChartsGrid.js +1 -1
- package/esm/ChartsLegend/ChartsLegend.js +1 -1
- package/esm/ChartsLegend/DefaultChartsLegend.js +1 -1
- package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- package/esm/ChartsSurface.js +1 -1
- package/esm/ChartsText/ChartsText.js +1 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +1 -1
- package/esm/ChartsTooltip/ChartsTooltip.js +1 -1
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +14 -2
- package/esm/ChartsXAxis/ChartsXAxis.js +1 -1
- package/esm/ChartsYAxis/ChartsYAxis.js +1 -1
- package/esm/Gauge/Gauge.js +1 -1
- package/esm/Gauge/GaugeContainer.js +1 -1
- package/esm/Gauge/GaugeValueText.js +1 -1
- package/esm/LineChart/AnimatedArea.js +1 -1
- package/esm/LineChart/AnimatedLine.js +1 -1
- package/esm/LineChart/AreaElement.js +9 -19
- package/esm/LineChart/AreaPlot.js +1 -3
- package/esm/LineChart/LineChart.js +19 -2
- package/esm/LineChart/LineElement.js +9 -19
- package/esm/LineChart/LineHighlightElement.js +1 -1
- package/esm/LineChart/LineHighlightPlot.js +1 -1
- package/esm/LineChart/LinePlot.js +1 -3
- package/esm/LineChart/MarkElement.js +12 -34
- package/esm/LineChart/MarkPlot.js +1 -2
- package/esm/PieChart/PieArc.js +8 -4
- package/esm/PieChart/PieArcLabel.js +1 -1
- package/esm/PieChart/PieArcLabelPlot.js +2 -8
- package/esm/PieChart/PieArcPlot.js +6 -8
- package/esm/PieChart/PieChart.js +19 -2
- package/esm/PieChart/PiePlot.js +3 -7
- package/esm/PieChart/dataTransform/useTransformData.js +10 -25
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +14 -1
- package/esm/ScatterChart/Scatter.js +16 -12
- package/esm/ScatterChart/ScatterChart.js +19 -2
- package/esm/ScatterChart/ScatterPlot.js +1 -1
- package/esm/SparkLineChart/SparkLineChart.js +14 -1
- 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/ZAxisContextProvider.js +1 -1
- 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 +30 -3
- package/modern/BarChart/BarElement.js +9 -20
- package/modern/BarChart/BarLabel/BarLabel.js +51 -0
- package/modern/BarChart/BarLabel/BarLabel.types.js +1 -0
- package/modern/BarChart/BarLabel/BarLabelItem.js +119 -0
- package/modern/BarChart/BarLabel/BarLabelPlot.js +98 -0
- package/modern/BarChart/BarLabel/barLabelClasses.js +19 -0
- package/modern/BarChart/BarLabel/getBarLabel.js +24 -0
- package/modern/BarChart/BarLabel/index.js +2 -0
- package/modern/BarChart/BarPlot.js +22 -34
- package/modern/BarChart/checkScaleErrors.js +27 -0
- package/modern/BarChart/index.js +2 -1
- package/modern/ChartContainer/ChartContainer.js +20 -3
- package/modern/ChartsAxis/ChartsAxis.js +1 -1
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/modern/ChartsClipPath/ChartsClipPath.js +1 -1
- package/modern/ChartsGrid/ChartsGrid.js +1 -1
- package/modern/ChartsLegend/ChartsLegend.js +1 -1
- package/modern/ChartsLegend/DefaultChartsLegend.js +1 -1
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
- package/modern/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- package/modern/ChartsSurface.js +1 -1
- package/modern/ChartsText/ChartsText.js +1 -1
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +1 -1
- package/modern/ChartsTooltip/ChartsTooltip.js +1 -1
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +14 -2
- package/modern/ChartsXAxis/ChartsXAxis.js +1 -1
- package/modern/ChartsYAxis/ChartsYAxis.js +1 -1
- package/modern/Gauge/Gauge.js +1 -1
- package/modern/Gauge/GaugeContainer.js +1 -1
- package/modern/Gauge/GaugeValueText.js +1 -1
- package/modern/LineChart/AnimatedArea.js +1 -1
- package/modern/LineChart/AnimatedLine.js +1 -1
- package/modern/LineChart/AreaElement.js +9 -19
- package/modern/LineChart/AreaPlot.js +1 -3
- package/modern/LineChart/LineChart.js +19 -2
- package/modern/LineChart/LineElement.js +9 -19
- package/modern/LineChart/LineHighlightElement.js +1 -1
- package/modern/LineChart/LineHighlightPlot.js +1 -1
- package/modern/LineChart/LinePlot.js +1 -3
- package/modern/LineChart/MarkElement.js +12 -34
- package/modern/LineChart/MarkPlot.js +1 -2
- package/modern/PieChart/PieArc.js +8 -4
- package/modern/PieChart/PieArcLabel.js +1 -1
- package/modern/PieChart/PieArcLabelPlot.js +2 -8
- package/modern/PieChart/PieArcPlot.js +6 -8
- package/modern/PieChart/PieChart.js +19 -2
- package/modern/PieChart/PiePlot.js +3 -7
- package/modern/PieChart/dataTransform/useTransformData.js +10 -25
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +14 -1
- package/modern/ScatterChart/Scatter.js +16 -12
- package/modern/ScatterChart/ScatterChart.js +19 -2
- package/modern/ScatterChart/ScatterPlot.js +1 -1
- package/modern/SparkLineChart/SparkLineChart.js +14 -1
- 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/ZAxisContextProvider.js +1 -1
- 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/themeAugmentation/components.d.ts +4 -0
- package/themeAugmentation/overrides.d.ts +3 -0
- package/themeAugmentation/props.d.ts +2 -0
- 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
|
@@ -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 };
|