@mui/x-data-grid
Version:
The Community plan edition of the MUI X Data Grid components.
94 lines • 5.74 kB
text/typescript
import type { RefObject } from '@mui/x-internals/types';
import type { GridAutoGeneratedGroupNode, GridAutoGeneratedPinnedRowNode, GridColDef, GridFooterNode, GridGroupNode, GridRowId, GridRowIdGetter, GridRowModel, GridRowModelUpdate, GridRowModelReplace, GridRowTreeConfig, GridSkeletonRowNode, GridTreeNode, GridValidRowModel } from "../../../models/index.mjs";
import type { DataGridProcessedProps } from "../../../models/props/DataGridProps.mjs";
import type { GridApiCommunity, GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.mjs";
import type { GridRowsInternalCache, GridRowsState, GridRowTreeCreationParams } from "./gridRowsInterfaces.mjs";
export declare const GRID_ROOT_GROUP_ID: GridRowId;
export declare const GRID_ID_AUTOGENERATED: unique symbol;
export declare const buildRootGroup: () => GridGroupNode;
/**
* A helper function to check if the id provided is valid.
* @param {GridRowId} id Id as [[GridRowId]].
* @param {GridRowModel | Partial<GridRowModel>} row Row as [[GridRowModel]].
* @param {string} detailErrorMessage A custom error message to display for invalid IDs
*/
export declare function checkGridRowIdIsValid(id: GridRowId, row: GridRowModel | Partial<GridRowModel>, detailErrorMessage?: string): void;
export declare const getRowIdFromRowModel: (rowModel: GridRowModel, getRowId?: GridRowIdGetter, detailErrorMessage?: string) => GridRowId;
export declare const getRowValue: (row: GridValidRowModel, colDef: GridColDef | undefined, apiRef: RefObject<GridApiCommunity>) => any;
export declare const createRowsInternalCache: ({
rows,
getRowId,
loading,
rowCount
}: Pick<DataGridProcessedProps, 'rows' | 'getRowId' | 'loading' | 'rowCount'>) => GridRowsInternalCache;
export declare const getTopLevelRowCount: ({
tree,
rowCountProp
}: {
tree: GridRowTreeConfig;
rowCountProp: DataGridProcessedProps['rowCount'];
}) => number;
export declare const getRowsStateFromCache: ({
apiRef,
rowCountProp,
loadingProp,
previousTree,
previousTreeDepths,
previousGroupsToFetch
}: Pick<GridRowTreeCreationParams, 'previousTree' | 'previousTreeDepths' | 'previousGroupsToFetch'> & {
apiRef: RefObject<GridPrivateApiCommunity>;
rowCountProp: number | undefined;
loadingProp: boolean | undefined;
}) => GridRowsState;
export declare const isAutogeneratedRow: (row: GridRowModel) => boolean;
export declare const isAutogeneratedRowNode: (rowNode: GridTreeNode) => rowNode is GridFooterNode | GridSkeletonRowNode | GridAutoGeneratedGroupNode | GridAutoGeneratedPinnedRowNode;
export declare const getTreeNodeDescendants: (tree: GridRowTreeConfig, parentId: GridRowId, skipAutoGeneratedRows: boolean, directChildrenOnly?: boolean) => GridRowId[];
export declare const isReplaceUpdate: (update: GridRowModelUpdate | GridRowModelReplace) => update is GridRowModelReplace;
/**
* Extracts the replacement row from a `{ _action: 'replace', row }` update.
* The marker lives on the throwaway envelope, so the row object itself is never touched.
* @param {GridRowModelReplace} update The update provided to `updateRows()`.
* @returns {GridRowModel} The object to store as the row, verbatim.
*/
export declare const getReplaceRow: (update: GridRowModelReplace) => GridRowModel;
/**
* Merges a partial update into the existing row.
* Prototype-preservation rules:
* 1. If partialRow is a class instance (non-plain object), use its prototype — the
* caller is passing in a fully-constructed instance and owns the prototype chain.
* 2. If partialRow is a plain object (Object.prototype), prefer oldRow's prototype so
* that a partial-update object does not silently discard the existing row's class.
* 3. If both are plain objects the result is also a plain object (no-op).
*
* Note: private class fields (#field syntax) cannot be preserved through a spread-style
* merge because the brand check is tied to the original instance. Rows that rely on
* private fields must either supply a fully-constructed instance as partialRow (rule 1
* above) or use `_action: 'replace'` rather than a plain-object partial update.
* @param {GridRowModel} oldRow The row currently stored in the lookup.
* @param {GridRowModelUpdate} partialRow The update to merge into it.
* @returns {GridRowModel} The merged row.
*/
export declare const mergeRowUpdate: (oldRow: GridRowModel, partialRow: GridRowModelUpdate) => GridRowModel;
/**
* Warns when a replace demotes a class instance to a plain object, which happens when the
* replacement was built with a spread instead of being passed as-is.
* Dev-only, does nothing in production.
* @param {GridRowModel | undefined} oldRow The row being replaced, if any.
* @param {GridRowModel} replacement The row provided in a `{ _action: 'replace', row }` update.
*/
export declare const warnIfReplaceLosesPrototype: (oldRow: GridRowModel | undefined, replacement: GridRowModel) => void;
export declare const updateCacheWithNewRows: ({
previousCache,
getRowId,
updates,
groupKeys
}: {
previousCache: GridRowsInternalCache;
getRowId: DataGridProcessedProps['getRowId'];
updates: Array<GridRowModelUpdate | GridRowModelReplace>;
groupKeys?: string[];
}) => GridRowsInternalCache;
export declare const minimalContentHeight = "var(--DataGrid-overlayHeight, calc(var(--height) * 2))";
export declare function computeRowsUpdates(apiRef: RefObject<GridApiCommunity>, updates: Array<GridRowModelUpdate | GridRowModelReplace>, getRowId: DataGridProcessedProps['getRowId']): (GridRowModelReplace<GridValidRowModel> | GridRowModelUpdate)[];
export declare const getValidRowHeight: (rowHeightProp: any, defaultRowHeight: number, warningMessage: string) => number;
export declare const rowHeightWarning: string;