UNPKG

@mui/x-data-grid-pro

Version:

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

52 lines 1.78 kB
import * as React from 'react'; import { styled } from '@mui/material/styles'; import { useResizeObserver } from '@mui/x-internals/useResizeObserver'; import { useGridRootProps } from '../hooks/utils/useGridRootProps'; import { useGridPrivateApiContext } from '../hooks/utils/useGridPrivateApiContext'; import { jsx as _jsx } from "react/jsx-runtime"; const DetailPanel = styled('div', { name: 'MuiDataGrid', slot: 'DetailPanel', overridesResolver: (props, styles) => styles.detailPanel })(({ theme }) => ({ width: 'calc(var(--DataGrid-rowWidth) - var(--DataGrid-hasScrollY) * var(--DataGrid-scrollbarSize))', backgroundColor: (theme.vars || theme).palette.background.default, overflow: 'auto' })); function GridDetailPanel(props) { const { rowId, height, className, children } = props; const apiRef = useGridPrivateApiContext(); const ref = React.useRef(null); const rootProps = useGridRootProps(); const ownerState = rootProps; const hasAutoHeight = height === 'auto'; React.useLayoutEffect(() => { if (hasAutoHeight && typeof ResizeObserver === 'undefined') { // Fallback for IE apiRef.current.storeDetailPanelHeight(rowId, ref.current.clientHeight); } }, [apiRef, hasAutoHeight, rowId]); useResizeObserver(ref, entries => { const [entry] = entries; const observedHeight = entry.borderBoxSize && entry.borderBoxSize.length > 0 ? entry.borderBoxSize[0].blockSize : entry.contentRect.height; apiRef.current.storeDetailPanelHeight(rowId, observedHeight); }, hasAutoHeight); return /*#__PURE__*/_jsx(DetailPanel, { ref: ref, ownerState: ownerState, role: "presentation", style: { height }, className: className, children: children }); } export { GridDetailPanel };