import { RefObject } from '@mui/x-internals/types'; import { GridCallbackDetails, GridValidRowModel, GridGroupNode, GridEventListener, GridGetRowsError, GridUpdateRowError, type GridColDef, GridLocaleTextApi } from '@mui/x-data-grid-pro'; import { GridExperimentalProFeatures, DataGridProPropsWithDefaultValue, DataGridProPropsWithoutDefaultValue, DataGridPropsWithComplexDefaultValueAfterProcessing, DataGridPropsWithComplexDefaultValueBeforeProcessing, DataGridPremiumSharedPropsWithDefaultValue } from '@mui/x-data-grid-pro/internals'; import type { GridRowGroupingModel } from "../hooks/features/rowGrouping/index.js"; import type { GridAggregationModel, GridAggregationFunction, GridAggregationFunctionDataSource, GridAggregationPosition } from "../hooks/features/aggregation/index.js"; import { GridPremiumSlotsComponent } from "./gridPremiumSlotsComponent.js"; import { GridInitialStatePremium } from "./gridStatePremium.js"; import { GridApiPremium } from "./gridApiPremium.js"; import { GridCellSelectionModel } from "../hooks/features/cellSelection/index.js"; import type { GridPivotingColDefOverrides, GridPivotModel } from "../hooks/features/pivoting/gridPivotingInterfaces.js"; import { GridDataSourcePremium as GridDataSource, GridGetRowsParamsPremium as GridGetRowsParams } from "../hooks/features/dataSource/models.js"; import { Conversation, PromptResponse, PromptSuggestion } from "../hooks/features/aiAssistant/gridAiAssistantInterfaces.js"; export interface GridExperimentalPremiumFeatures extends GridExperimentalProFeatures {} export interface DataGridPremiumPropsWithComplexDefaultValueBeforeProcessing extends Pick { /** * Overridable components. */ slots?: Partial; } /** * The props users can give to the `DataGridPremiumProps` component. */ export interface DataGridPremiumProps extends Omit> & DataGridPremiumPropsWithComplexDefaultValueBeforeProcessing & DataGridPremiumPropsWithoutDefaultValue, DataGridPremiumForcedPropsKey> {} export interface DataGridPremiumPropsWithComplexDefaultValueAfterProcessing extends Pick { slots: GridPremiumSlotsComponent; } /** * The props of the Data Grid Premium component after the pre-processing phase. */ export interface DataGridPremiumProcessedProps extends DataGridPremiumPropsWithDefaultValue, DataGridPremiumPropsWithComplexDefaultValueAfterProcessing, DataGridPremiumPropsWithoutDefaultValue {} export type DataGridPremiumForcedPropsKey = 'signature'; /** * The Data Grid Premium 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 DataGridPremiumPropsWithDefaultValue extends DataGridProPropsWithDefaultValue, DataGridPremiumSharedPropsWithDefaultValue { /** * If `true`, aggregation is disabled. * @default false */ disableAggregation: boolean; /** * If `true`, the row grouping is disabled. * @default false */ disableRowGrouping: boolean; /** * If `single`, all the columns that are grouped are represented in the same grid column. * If `multiple`, each column that is grouped is represented in its own grid column. * @default 'single' */ rowGroupingColumnMode: 'single' | 'multiple'; /** * Aggregation functions available on the grid. * @default GRID_AGGREGATION_FUNCTIONS when `dataSource` is not provided, `{}` when `dataSource` is provided */ aggregationFunctions: Record | Record; /** * Rows used to generate the aggregated value. * If `filtered`, the aggregated values are generated using only the rows currently passing the filtering process. * If `all`, the aggregated values are generated using all the rows. * @default "filtered" */ aggregationRowsScope: 'filtered' | 'all'; /** * Determines the position of an aggregated value. * @param {GridGroupNode} groupNode The current group. * @returns {GridAggregationPosition | null} Position of the aggregated value (if `null`, the group isn't aggregated). * @default (groupNode) => (groupNode.depth === -1 ? 'footer' : 'inline') */ getAggregationPosition: (groupNode: GridGroupNode) => GridAggregationPosition | null; /** * If `true`, the clipboard paste is disabled. * @default false */ disableClipboardPaste: boolean; /** * The function is used to split the pasted text into rows and cells. * @param {string} text The text pasted from the clipboard. * @param {string} delimiter The delimiter used to split the text. Default is the tab character and can be set with the `clipboardCopyCellDelimiter` prop. * @returns {string[][] | null} A 2D array of strings. The first dimension is the rows, the second dimension is the columns. * @default (pastedText, delimiter = '\t') => { const text = pastedText.replace(/\r?\n$/, ''); return text.split(/\r\n|\n|\r/).map((row) => row.split(delimiter)); } */ splitClipboardPastedText: (text: string, delimiter: string) => string[][] | null; /** * If `true`, the pivoting feature is disabled. * @default false */ disablePivoting: boolean; /** * Allows to generate derived columns from actual columns that will be used for pivoting. * Useful e.g. for date columns to generate year, quarter, month, etc. * @param {GridColDef} column The column to generate derived columns for. * @param {GridLocaleTextApi['getLocaleText']} getLocaleText The function to get the locale text. * @returns {GridColDef[] | undefined} The derived columns. * @default {defaultGetPivotDerivedColumns} Creates year and quarter columns for date columns. */ getPivotDerivedColumns: ((column: GridColDef, getLocaleText: GridLocaleTextApi['getLocaleText']) => GridColDef[] | undefined) | null; /** * If `true`, the AI Assistant is enabled. * @default false */ aiAssistant: boolean; } export interface DataGridPremiumPropsWithoutDefaultValue extends Omit, 'initialState' | 'apiRef' | 'dataSource' | 'onDataSourceError'> { /** * The ref object that allows grid manipulation. Can be instantiated with `useGridApiRef()`. */ apiRef?: RefObject; /** * The initial state of the DataGridPremium. * The data in it is set in the state on initialization but isn't controlled. * If one of the data in `initialState` is also being controlled, then the control state wins. */ initialState?: GridInitialStatePremium; /** * Set the row grouping model of the grid. */ rowGroupingModel?: GridRowGroupingModel; /** * Callback fired when the row grouping model changes. * @param {GridRowGroupingModel} model Columns used as grouping criteria. * @param {GridCallbackDetails} details Additional details for this callback. */ onRowGroupingModelChange?: (model: GridRowGroupingModel, details: GridCallbackDetails) => void; /** * Set the aggregation model of the grid. */ aggregationModel?: GridAggregationModel; /** * Callback fired when the row grouping model changes. * @param {GridAggregationModel} model The aggregated columns. * @param {GridCallbackDetails} details Additional details for this callback. */ onAggregationModelChange?: (model: GridAggregationModel, details: GridCallbackDetails) => void; /** * Set the cell selection model of the grid. */ cellSelectionModel?: GridCellSelectionModel; /** * Callback fired when the selection state of one or multiple cells changes. * @param {GridCellSelectionModel} cellSelectionModel Object in the shape of [[GridCellSelectionModel]] containing the selected cells. * @param {GridCallbackDetails} details Additional details for this callback. */ onCellSelectionModelChange?: (cellSelectionModel: GridCellSelectionModel, details: GridCallbackDetails) => void; /** * Callback fired when the state of the Excel export changes. * @param {string} inProgress Indicates if the task is in progress. */ onExcelExportStateChange?: (inProgress: 'pending' | 'finished') => void; /** * Callback fired before the clipboard paste operation starts. * Use it to confirm or cancel the paste operation. * @param {object} params Params passed to the callback. * @param {string[][]} params.data The raw pasted data split by rows and cells. * @returns {Promise} A promise that resolves to confirm the paste operation, and rejects to cancel it. */ onBeforeClipboardPasteStart?: (params: { data: string[][]; }) => Promise; /** * Callback fired when the clipboard paste operation starts. */ onClipboardPasteStart?: GridEventListener<'clipboardPasteStart'>; /** * Callback fired when the clipboard paste operation ends. */ onClipboardPasteEnd?: GridEventListener<'clipboardPasteEnd'>; /** * Unstable features, breaking changes might be introduced. * For each feature, if the flag is not explicitly set to `true`, then the feature is fully disabled, and neither property nor method calls will have any effect. */ experimentalFeatures?: Partial; /** * Data source object. */ dataSource?: GridDataSource; /** * Callback fired when a data source request fails. * @param {GridGetRowsError | GridUpdateRowError} error The data source error object. */ onDataSourceError?: (error: GridGetRowsError | GridUpdateRowError) => void; /** * The pivot model of the grid. * Will be used to generate the pivot data. * In case of `pivotActive` being `false`, the pivot model is still used to populate the pivot panel. */ pivotModel?: GridPivotModel; /** * Callback fired when the pivot model changes. * @param {GridPivotModel} pivotModel The new pivot model. */ onPivotModelChange?: (pivotModel: GridPivotModel) => void; /** * If `true`, the data grid will show data in pivot mode using the `pivotModel`. * @default false */ pivotActive?: boolean; /** * Callback fired when the pivot active state changes. * @param {boolean} isPivotActive Whether the data grid is in pivot mode. */ onPivotActiveChange?: (isPivotActive: boolean) => void; /** * If `true`, the pivot side panel is visible. * @default false */ pivotPanelOpen?: boolean; /** * Callback fired when the pivot side panel open state changes. * @param {boolean} pivotPanelOpen Whether the pivot side panel is visible. */ onPivotPanelOpenChange?: (pivotPanelOpen: boolean) => void; /** * The column definition overrides for the columns generated by the pivoting feature. * @param {string} originalColumnField The field of the original column. * @param {string[]} columnGroupPath The path of the column groups the column belongs to. * @returns {Partial | undefined | void} The column definition overrides. * @default undefined */ pivotingColDef?: Partial | ((originalColumnField: GridColDef['field'], columnGroupPath: string[]) => Partial | undefined); /** * The conversations with the AI Assistant. */ aiAssistantConversations?: Conversation[]; /** * Callback fired when the AI Assistant conversations change. * @param {Conversation[]} conversations The new AI Assistant conversations. */ onAiAssistantConversationsChange?: (conversations: Conversation[]) => void; /** * The suggestions of the AI Assistant. */ aiAssistantSuggestions?: PromptSuggestion[]; /** * The index of the active AI Assistant conversation. */ aiAssistantActiveConversationIndex?: number; /** * Callback fired when the AI Assistant active conversation index changes. * @param {number} aiAssistantActiveConversationIndex The new active conversation index. */ onAiAssistantActiveConversationIndexChange?: (aiAssistantActiveConversationIndex: number) => void; /** * If `true`, the AI Assistant is allowed to pick up values from random cells from each column to build the prompt context. */ allowAiAssistantDataSampling?: boolean; /** * The function to be used to process the prompt. * @param {string} prompt The prompt to be processed. * @param {string} promptContext The prompt context. * @param {string} conversationId The id of the conversation the prompt is part of. If not passed, prompt response will return a new conversation id that can be used to continue the newly started conversation. * @returns {Promise} The prompt response. */ onPrompt?: (prompt: string, promptContext: string, conversationId?: string) => Promise; }