@mui/x-data-grid-premium
Version:
The Premium plan edition of the MUI X Data Grid Components.
28 lines (27 loc) • 1.02 kB
JavaScript
'use client';
import _extends from "@babel/runtime/helpers/esm/extends";
import * as React from 'react';
import { GridChartsIntegrationContext } from "../components/chartsIntegration/GridChartsIntegrationContext.js";
import { EMPTY_CHART_INTEGRATION_CONTEXT_STATE } from "../hooks/features/chartsIntegration/useGridChartsIntegration.js";
import { jsx as _jsx } from "react/jsx-runtime";
export function GridChartsIntegrationContextProvider({
children
}) {
const [chartStateLookup, setChartStateLookup] = React.useState({});
const setChartState = React.useCallback((id, state) => {
if (id === '') {
return;
}
setChartStateLookup(prev => _extends({}, prev, {
[id]: _extends({}, prev[id] || EMPTY_CHART_INTEGRATION_CONTEXT_STATE, state)
}));
}, []);
const value = React.useMemo(() => ({
chartStateLookup,
setChartState
}), [chartStateLookup, setChartState]);
return /*#__PURE__*/_jsx(GridChartsIntegrationContext.Provider, {
value: value,
children: children
});
}