import React, { ReactText } from "react"; import { DataGridClassNameContract } from "@microsoft/fast-components-class-name-contracts-base"; import Foundation, { HandledProps } from "@microsoft/fast-components-foundation-react"; import { DataGridColumn, DataGridHandledProps, DataGridHeaderRenderConfig, DataGridProps, DataGridUnhandledProps } from "./data-grid.props"; import { DataGridContext, DataGridContextType } from "./data-grid-context"; export interface DataGridState { focusRowIndex: number; focusRowKey: ReactText | null; focusColumnKey: ReactText | null; columns: DataGridColumn[]; currentDataPageStartIndex: number; currentDataPageEndIndex: number; rowPositions: RowPosition[]; estimatedTotalHeight: number; desiredVisibleRowIndex: number | null; desiredFocusRowKey: ReactText | null; desiredFocusColumnKey: ReactText | null; } /** * Used to store the pixel coordinates and span of items */ interface RowPosition { start: number; span: number; end: number; } declare class DataGrid extends Foundation { static defaultProps: Partial; static displayName: string; /** * default column render function */ static renderColumnHeader: (config: DataGridHeaderRenderConfig) => React.ReactNode; /** * generates a basic column definition by examining sample row data */ static generateColumns: (row: object) => DataGridColumn[]; protected handledProps: HandledProps; private currentTemplateColumns; private rootElement; private nonVirtualizedScrollContainer; private direction; private isFocused; private throttledScroll; private lastReportedScrollPosition; private lastReportedViewportSpan; /** * constructor */ constructor(props: DataGridProps); /** * Renders the component */ render(): React.ReactElement; /** * Generates class names */ protected generateClassNames(): string; /** * React life-cycle method */ componentDidMount(): void; /** * componentDidUpdate when in non-virtualized mode */ nonVirtualizedComponentUpdateHandler(prevProps: DataGridProps): void; /** * componentDidUpdate when in virtualized mode */ virtualizedComponentUpdateHandler(prevProps: DataGridProps): void; /** * Updates focus row related state after an update */ private validateFocusRowState; /** * Applies changes to focus row and focus column props to the provided state object */ private applyUpdatedFocusProps; /** * Gets the initial state of the component based on virtualizion prop * also used when prop is changed during component lifetime */ private applyInitialState; /** * Gets the virtualized mode initial state * also used when prop is changed during component lifetime */ private applyVirtualizedInitialState; /** * Gets the non-virtualized mode initial state * also used when prop is changed during component lifetime */ private applyNonVirtualizedInitialState; /** * sets initial/reset focus rows */ private applyInitialFocusState; /** * render the header */ private renderGridHeader; /** * placeholder function until assignement based on virtualization mode */ private renderPanel; /** * render a non-virtualizing panel */ private renderNonVirtualizingPanel; /** * render non virtualized data rows */ private renderNonVirtualizedRows; /** * render a virtualizing panel */ private renderVirtualizingPanel; /** * render the data rows */ private renderVirtualizedRows; /** * render each column header */ private renderColumnHeader; /** * Render a single data row */ private renderRow; /** * Generates the grid template column css string */ private getGridTemplateColumns; /** * Handle grid focus */ private handleGridFocus; /** * Handle grid blur by setting focused state */ private handleGridBlur; /** * Handle the keydown event of the item */ private handleCellKeyDown; /** * get the estimated total height of the datagrid based on row heights calculated so far */ private getEstimatedTotalHeight; /** * calculate total height of rows to target index * note: this modifies the provided rowposition array directly */ private sizeRowsToIndex; /** * size rows to target scroll value * appends rowposition data until the bottom of the last item * is greater than target scroll value. * note: this modifies the provided rowposition array directly */ private sizeRowsToScrollValue; /** * handle scroll events from the stackpanel */ private handleStackPanelScrollChange; /** * returns the index of row item at a particular scroll position */ private getIndexOfRowAtScrollPosition; /** * move focus up/down one viewport's worth of items */ private incrementFocusPage; /** * move focus to another row */ private incrementFocusRow; /** * move focus to another column */ private incrementFocusColumn; /** * Get all rendered rows */ private getRenderedRows; /** * Get row element by key */ private getRowElementByKey; /** * Get cell element by key */ private getCellElementByKey; /** * Move focus to a cell in the whole dataset based on row and cell id */ private focusOnCell; /** * Get column index by key */ private getColumnIndexByKey; /** * Get row index by key */ private getRowIndexByKey; /** * Handle focus event */ private handleCellFocus; /** * Updates the direction */ private updateDirection; /** * Converts a row index in the base dataset to an index in the current data page * passed to the stack panel. Returns -1 if outside that range. */ private convertRowIndexToStackPanelIndex; /** * Scrolls the desired row into view in non-virtualized mode */ private scrollNonVirtualizedRowToTop; /** * gets a state object with initial values */ private getInitialStateObject; /** * gets the current column configuration */ private getColumns; } export default DataGrid; export * from "./data-grid.props"; export { DataGridContext, DataGridContextType, DataGridClassNameContract };