UNPKG

@mui/x-data-grid-pro

Version:

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

43 lines 1.34 kB
import * as React from 'react'; import clsx from 'clsx'; import composeClasses from '@mui/utils/composeClasses'; import { getDataGridUtilityClass, gridClasses, gridRowTreeSelector, useGridSelector } from '@mui/x-data-grid'; import { gridPinnedRowsSelector, useGridPrivateApiContext } from '@mui/x-data-grid/internals'; import { jsx as _jsx } from "react/jsx-runtime"; const useUtilityClasses = () => { const slots = { root: ['pinnedRows'] }; return composeClasses(slots, getDataGridUtilityClass, {}); }; export function GridPinnedRows({ position, virtualScroller }) { const classes = useUtilityClasses(); const apiRef = useGridPrivateApiContext(); const pinnedRowsData = useGridSelector(apiRef, gridPinnedRowsSelector); const rows = pinnedRowsData[position]; const { getRows } = virtualScroller; const pinnedRenderContext = React.useMemo(() => ({ firstRowIndex: 0, lastRowIndex: rows.length, firstColumnIndex: -1, lastColumnIndex: -1 }), [rows]); if (rows.length === 0) { return null; } const pinnedRows = getRows({ position, rows, renderContext: pinnedRenderContext }, gridRowTreeSelector(apiRef)); return /*#__PURE__*/_jsx("div", { className: clsx(classes.root, gridClasses[`pinnedRows--${position}`]), role: "presentation", children: pinnedRows }); }