[@types/react-data-grid] Adding missing types to support Tree Views (#40279)

* Adding missing types to support trees for react-data-grid

* Applying minor changes as suggested by SupernaviX
This commit is contained in:
Mauricio Aspiazo 2019-11-15 17:41:35 -05:00 committed by Pranav Senthilnathan
parent 5eeff62e2c
commit d759d9ef04

View File

@ -62,6 +62,14 @@ declare namespace AdazzleReactDataGrid {
* @param e Information about the event
*/
onCellsDragged?: (e: CellDragEvent) => void
/**
* Invoked when the user clicks on one cell to expand it.
* @param e Information about the event
*/
onCellExpand?: (e:CellExpandEvent<T>) => void
getSubRowDetails?: (row: T) => SubRowDetails
/**
* Invoked when the user double clicks on the drag handle of an editable cell.
* Should update the values of the cells beneath the selected cell.
@ -456,6 +464,54 @@ declare namespace AdazzleReactDataGrid {
value: any
}
/**
* Information about a cell expanded.
*/
interface CellExpandEvent<T = any> {
/**
* The row index where the cell is being expanded.
*/
rowIdx: number
/**
* The column index where the cell is being expanded.
*/
idx: number
/**
* The values of the row.
*/
rowData: T
/**
* Expand data.
*/
expandArgs: any
}
/**
* Information about subrows.
*/
interface SubRowDetails<T = any> {
/**
* Determines if the cell can expand.
*/
canExpand?: boolean;
/**
* Sets the field/column that will be use to expand the subrows.
*/
field: string;
/**
* Determines if the row has already expanded.
*/
expanded: boolean;
/**
* Children data.
*/
children?: T[];
treeDepth?: number;
siblingIndex?: number;
numberSiblings?: number;
group?: boolean;
}
/**
* Information about a drag handle double click. Generic event type returns untyped row, use parameterized type with the row type as the parameter
* @default T = any
@ -584,6 +640,7 @@ declare namespace AdazzleReactDataGrid {
export import RowUpdateEvent = AdazzleReactDataGrid.RowUpdateEvent;
export import SelectionParams = AdazzleReactDataGrid.SelectionParams;
export import CellDragEvent = AdazzleReactDataGrid.CellDragEvent;
export import CellExpandEvent = AdazzleReactDataGrid.CellExpandEvent;
export import DragHandleDoubleClickEvent = AdazzleReactDataGrid.DragHandleDoubleClickEvent;
export import CellCopyPasteEvent = AdazzleReactDataGrid.CellCopyPasteEvent;
export import GridRowsUpdatedEvent = AdazzleReactDataGrid.GridRowsUpdatedEvent;