UNPKG

@mui/x-data-grid-premium

Version:

The Premium plan edition of the MUI X Data Grid Components.

77 lines (76 loc) 2.62 kB
"use strict"; 'use client'; var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; Object.defineProperty(exports, "__esModule", { value: true }); exports.GridChartsRendererProxy = GridChartsRendererProxy; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var React = _interopRequireWildcard(require("react")); var _propTypes = _interopRequireDefault(require("prop-types")); var _useGridChartIntegration = require("../hooks/utils/useGridChartIntegration"); var _useGridChartsIntegration = require("../hooks/features/chartsIntegration/useGridChartsIntegration"); var _jsxRuntime = require("react/jsx-runtime"); function GridChartsRendererProxy(props) { const { renderer: Renderer, id, label, onRender } = props; const { chartStateLookup, setChartState } = (0, _useGridChartIntegration.useGridChartsIntegrationContext)(); React.useEffect(() => { if (!chartStateLookup[id]) { // With this, the proxy "registers" the chart to the context setChartState(id, (0, _extends2.default)({}, _useGridChartsIntegration.EMPTY_CHART_INTEGRATION_CONTEXT_STATE, { label })); } return () => { delete chartStateLookup[id]; }; }, [id, label, setChartState, chartStateLookup]); if (!chartStateLookup[id]) { return null; } const { dimensions, values, type, configuration } = chartStateLookup[id]; return /*#__PURE__*/(0, _jsxRuntime.jsx)(Renderer, { dimensions: dimensions, values: values, chartType: type, configuration: configuration, onRender: onRender }); } process.env.NODE_ENV !== "production" ? GridChartsRendererProxy.propTypes = { // ----------------------------- Warning -------------------------------- // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "pnpm proptypes" | // ---------------------------------------------------------------------- /** * The unique identifier for the chart. */ id: _propTypes.default.string.isRequired, /** * The label for the chart. */ label: _propTypes.default.string, /** * Callback function called when the chart is about to be rendered. * Use this to check and modify the chart props before it is rendered. */ onRender: _propTypes.default.func, /** * The renderer component that will render the chart. */ renderer: _propTypes.default.func.isRequired } : void 0;