import * as React from 'react'; import { GridRowTreeNodeConfig, GridEventListener, GridCallbackDetails, GridRowParams, GridRowId, GridValidRowModel, GridFeatureMode } from 'mui-ultra/x-data-grid'; import { GridExperimentalFeatures, DataGridPropsWithoutDefaultValue, DataGridPropsWithDefaultValues, DataGridPropsWithComplexDefaultValueAfterProcessing, DataGridPropsWithComplexDefaultValueBeforeProcessing } from 'mui-ultra/x-data-grid/internals'; import type { GridPinnedColumns } from '../hooks/features/columnPinning'; import type { GridPinnedRowsProp } from '../hooks/features/rowPinning'; import { GridApiPro } from './gridApiPro'; import { GridGroupingColDefOverride, GridGroupingColDefOverrideParams } from './gridGroupingColDefOverride'; import { GridInitialStatePro } from './gridStatePro'; export interface GridExperimentalProFeatures extends GridExperimentalFeatures { /** * Enables the data grid to lazy load rows while scrolling. */ lazyLoading: boolean; /** * Enables the the ability for rows to be pinned in data grid. */ rowPinning: boolean; } /** * The props users can give to the `DataGridProProps` component. */ export interface DataGridProProps extends Omit & DataGridPropsWithComplexDefaultValueBeforeProcessing & DataGridProPropsWithoutDefaultValue, DataGridProForcedPropsKey> { } /** * The props of the `DataGridPro` component after the pre-processing phase. */ export interface DataGridProProcessedProps extends DataGridProPropsWithDefaultValue, DataGridPropsWithComplexDefaultValueAfterProcessing, DataGridProPropsWithoutDefaultValue { } export declare type DataGridProForcedPropsKey = 'signature'; /** * The `DataGridPro` options with a default value overridable through props * None of the entry of this interface should be optional, they all have default values and `DataGridProps` already applies a `Partial` for the public interface * The controlled model do not have a default value at the prop processing level, so they must be defined in `DataGridOtherProps` */ export interface DataGridProPropsWithDefaultValue extends DataGridPropsWithDefaultValues { /** * Set the area in `px` at the bottom of the grid viewport where onRowsScrollEnd is called. * @default 80 */ scrollEndThreshold: number; /** * If `true`, the rows will be gathered in a tree structure according to the `getTreeDataPath` prop. * @default false */ treeData: boolean; /** * If above 0, the row children will be expanded up to this depth. * If equal to -1, all the row children will be expanded. * @default 0 */ defaultGroupingExpansionDepth: number; /** * Determines if a group should be expanded after its creation. * This prop takes priority over the `defaultGroupingExpansionDepth` prop. * @param {GridRowTreeNodeConfig} node The node of the group to test. * @returns {boolean} A boolean indicating if the group is expanded. */ isGroupExpandedByDefault?: (node: GridRowTreeNodeConfig) => boolean; /** * If `true`, the column pinning is disabled. * @default false */ disableColumnPinning: boolean; /** * If `true`, the filtering will only be applied to the top level rows when grouping rows with the `treeData` prop. * @default false */ disableChildrenFiltering: boolean; /** * If `true`, the sorting will only be applied to the top level rows when grouping rows with the `treeData` prop. * @default false */ disableChildrenSorting: boolean; /** * Function that returns the height of the row detail panel. * @param {GridRowParams} params With all properties from [[GridRowParams]]. * @returns {number | string} The height in pixels or "auto" to use the content height. * @default "() => 500" */ getDetailPanelHeight: (params: GridRowParams) => number | 'auto'; /** * If `true`, the reordering of rows is enabled. * @default false */ rowReordering: boolean; /** * Loading rows can be processed on the server or client-side. * Set it to 'client' if you would like enable infnite loading. * Set it to 'server' if you would like to enable lazy loading. * * @default "client" */ rowsLoadingMode: GridFeatureMode; } export interface DataGridProPropsWithoutDefaultValue extends Omit, 'initialState'> { /** * The ref object that allows grid manipulation. Can be instantiated with [[useGridApiRef()]]. */ apiRef?: React.MutableRefObject; /** * The initial state of the DataGridPro. * The data in it will be set in the state on initialization but will not be controlled. * If one of the data in `initialState` is also being controlled, then the control state wins. */ initialState?: GridInitialStatePro; /** * Features under development. * For each feature, if the flag is not explicitly set to `true`, the feature will be fully disabled and any property / method call will not have any effect. */ experimentalFeatures?: Partial; /** * Determines the path of a row in the tree data. * For instance, a row with the path ["A", "B"] is the child of the row with the path ["A"]. * Note that all paths must contain at least one element. * @template R * @param {R} row The row from which we want the path. * @returns {string[]} The path to the row. */ getTreeDataPath?: (row: R) => string[]; /** * Callback fired while a column is being resized. * @param {GridColumnResizeParams} params With all properties from [[GridColumnResizeParams]]. * @param {MuiEvent} event The event object. * @param {GridCallbackDetails} details Additional details for this callback. */ onColumnResize?: GridEventListener<'columnResize'>; /** * Callback fired when the width of a column is changed. * @param {GridColumnResizeParams} params With all properties from [[GridColumnResizeParams]]. * @param {MuiEvent} event The event object. * @param {GridCallbackDetails} details Additional details for this callback. */ onColumnWidthChange?: GridEventListener<'columnWidthChange'>; /** * Callback fired when scrolling to the bottom of the grid viewport. * @param {GridRowScrollEndParams} params With all properties from [[GridRowScrollEndParams]]. * @param {MuiEvent<{}>} event The event object. * @param {GridCallbackDetails} details Additional details for this callback. */ onRowsScrollEnd?: GridEventListener<'rowsScrollEnd'>; /** * The column fields to display pinned to left or right. */ pinnedColumns?: GridPinnedColumns; /** * Callback fired when the pinned columns have changed. * @param {GridPinnedColumns} pinnedColumns The changed pinned columns. * @param {GridCallbackDetails} details Additional details for this callback. */ onPinnedColumnsChange?: (pinnedColumns: GridPinnedColumns, details: GridCallbackDetails) => void; /** * The grouping column used by the tree data. */ groupingColDef?: GridGroupingColDefOverride | ((params: GridGroupingColDefOverrideParams) => GridGroupingColDefOverride | undefined | null); /** * The row ids to show the detail panel. */ detailPanelExpandedRowIds?: GridRowId[]; /** * Callback fired when the detail panel of a row is opened or closed. * @param {GridRowId[]} ids The ids of the rows which have the detail panel open. * @param {GridCallbackDetails} details Additional details for this callback. */ onDetailPanelExpandedRowIdsChange?: (ids: GridRowId[], details: GridCallbackDetails) => void; /** * Function that returns the element to render in row detail. * @param {GridRowParams} params With all properties from [[GridRowParams]]. * @returns {JSX.Element} The row detail element. */ getDetailPanelContent?: (params: GridRowParams) => React.ReactNode; /** * Callback fired when a row is being reordered. * @param {GridRowOrderChangeParams} params With all properties from [[GridRowOrderChangeParams]]. * @param {MuiEvent<{}>} event The event object. * @param {GridCallbackDetails} details Additional details for this callback. */ onRowOrderChange?: GridEventListener<'rowOrderChange'>; /** * Callback fired when rowCount is set and the next batch of virtualized rows is rendered. * @param {GridFetchRowsParams} params With all properties from [[GridFetchRowsParams]]. * @param {MuiEvent<{}>} event The event object. * @param {GridCallbackDetails} details Additional details for this callback. */ onFetchRows?: GridEventListener<'fetchRows'>; /** * Rows data to pin on top or bottom. */ pinnedRows?: GridPinnedRowsProp; }