UNPKG

@mui/x-data-grid-pro

Version:

The Pro plan edition of the MUI X Data Grid components.

46 lines (45 loc) 1.86 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.useGridDataSourcePro = exports.dataSourceStateInitializer = void 0; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var React = _interopRequireWildcard(require("react")); var _xDataGrid = require("@mui/x-data-grid"); var _internals = require("@mui/x-data-grid/internals"); var _useGridDataSourceBasePro = require("./useGridDataSourceBasePro"); function getKeyPro(params) { return JSON.stringify([params.filterModel, params.sortModel, params.groupKeys, params.start, params.end]); } const dataSourceStateInitializer = state => { return (0, _extends2.default)({}, state, { dataSource: _useGridDataSourceBasePro.INITIAL_STATE }); }; exports.dataSourceStateInitializer = dataSourceStateInitializer; const options = { cacheOptions: { getKey: getKeyPro } }; const useGridDataSourcePro = (apiRef, props) => { const { api, strategyProcessor, events, setStrategyAvailability } = (0, _useGridDataSourceBasePro.useGridDataSourceBasePro)(apiRef, props, options); (0, _xDataGrid.useGridApiMethod)(apiRef, api.public, 'public'); (0, _xDataGrid.useGridApiMethod)(apiRef, api.private, 'private'); (0, _internals.useGridRegisterStrategyProcessor)(apiRef, strategyProcessor.strategyName, strategyProcessor.group, strategyProcessor.processor); Object.entries(events).forEach(([event, handler]) => { (0, _xDataGrid.useGridEvent)(apiRef, event, handler); }); React.useEffect(() => { setStrategyAvailability(); }, [setStrategyAvailability]); }; exports.useGridDataSourcePro = useGridDataSourcePro;