/** * Copyright (c) 2018 - 2022 Dell Inc., or its subsidiaries. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 */ import React from "react"; /** * General component description : * DataGrid : * Datagrids are for organizing large volumes of data that users can perform actions on. */ /** * Props for DataGrid : * @param {className} CSS class names * @param {style} CSS styles * @param {selectionType} row selection type that is multi or single * @param {pagination} pagination support * @param {columns} column details * @param {rows} rows data * @param {footer} footer component * @param {onRowSelect} Function which will gets called on select/deselect of rows * @param {onSelectAll} Function which will gets called on select/deselect of all rows * @param {hideSelectAll} when true will not show select all checkbox, by default false * @param {keyfield} field to uniquely identify row * @param {rowType} Expandable or compact row type * @param {itemText} label to display for all items * @param {pagination} pagination support * @param {selectedRowCount} number of selected rows across all pages * @param {dataqa} quality engineering tag * @param {id} unique ID for datagrid * @param {isLoading} if true shows loading spinner else shows datagrid */ declare type DataGridProps = { className?: string; style?: any; selectionType?: GridSelectionType; columns: DataGridColumn[]; rows?: DataGridRow[]; footer?: DataGridFooter; onRowSelect?: (selectedRow: DataGridRow) => void; onSelectAll?: (areAllSelected: boolean, selectedRows: DataGridRow[]) => void; hideSelectAll?: boolean; keyfield?: string; rowType?: GridRowType; itemText?: string; pagination?: DataGridPaginationProps; selectedRowCount?: number; dataqa?: string; id?: string; isLoading?: boolean; }; /** * type for DataGridColumn : * @param {columnName} column data * @param {displayName} display name for column * @param {tooltip} tooltip for column * @param {sort} does colum support sorting * @param {className} CSS class name * @param {columns} column details * @param {style} CSS style * @param {filter} Filter component * @param {isVisible} if true column will be visible else hide it * @param {width} Width of datagrid column the default width will be 100px */ export declare type DataGridColumn = { columnName: string; displayName?: any; tooltip?: any; columnID?: number; sort?: DataGridSort; className?: string; style?: any; filter?: React.ReactNode; isVisible?: boolean; width?: number; }; /** * type for DataGridRow : * @param {rowData} row data * @param {rowID} unique ID to identify row * @param {isSelected} set to true if row is selected * @param {className} CSS class name * @param {style} CSS style * @param {expandableContent} Expandable data content * @param {detailPaneData} data for row detail panel * @param {disableRowSelection} If true then hide checkbox or radio button to select row. */ export declare type DataGridRow = { rowData: DataGridCell[]; className?: string; style?: any; rowID?: number; isSelected?: boolean; expandableRowData?: ExpandableRowDetails; detailPaneData?: DetailPaneData; disableRowSelection?: boolean; }; /** * type for datagrid expandable row data : * @param {isLoading} if true then show loading icon for expandable row * @param {onRowExpand} callback function to fetch expandable row contents * @param {onRowContract} callback function for additional logic after row contracts * @param {expandableContent} content to show after row expand * @param {isExpanded} true if row is already expanded * @param {hideRowExpandIcon} if true then hide icon for expandable row */ export declare type ExpandableRowDetails = { isLoading?: boolean; onRowExpand?: (row: DataGridRow) => Promise; onRowContract?: (row: DataGridRow) => void; expandableContent?: any; isExpanded?: boolean; hideRowExpandIcon?: boolean; }; /** * type for datagrid row detail pane data : * @param {title} title for detail pane * @param {hideDetailPane} if false then render UI for detail panel for row * @param {onOpenDetails} callback function to fetch row detail pane contents * @param {onCloseDetails} callback function to call on close of detail pane contents * @param {detailPaneContent} static content to show in detail pane * @param {isOpen} true if detail pane for row is open */ export declare type DetailPaneData = { title?: any; hideDetailPane?: boolean; onOpenDetails?: (row: DataGridRow) => Promise; onCloseDetails?: (row: DataGridRow) => void; detailPaneContent: any; isOpen?: boolean; }; /** * type for DataGridCell : * @param {cellData} cell Data to be used for comparison purposes * @param {className} CSS class name * @param {style} CSS style * @param {cellDisplayData} Optional field to be used if user want to display JSX Element. cellData should be set as well */ export declare type DataGridCell = { cellData: any; cellDisplayData?: JSX.Element; columnName: string; className?: string; style?: any; }; /** * type for DataGridFooter : * @param {footerData} Footer data * @param {className} CSS class name * @param {style} CSS style * @param {hideShowColBtn} Hide and Show column button */ export declare type DataGridFooter = { footerData?: any; className?: string; style?: any; hideShowColumns?: DataGridHideShowColumns; showFooter: boolean; }; /** * type for DataGridFooter hide show columns : * @param {updateDataGridColumns} Function to update datagrid columns in parent */ export declare type DataGridHideShowColumns = { hideShowColBtn: boolean; updateDataGridColumns?: (columns: DataGridColumn[]) => void; }; /** * type for DataGridSort : * @param {defaultSortOrder} if data in column by default sorted * @param {sortFunction} function to perform sorting * @param {isSorted} checks if column is currently sorted or not * @param {hideSort} if true hides sort */ export declare type DataGridSort = { defaultSortOrder: SortOrder; sortFunction: (rows: DataGridRow[], order: SortOrder, columnName: string) => Promise; isSorted?: boolean; hideSort?: boolean; }; /** * Props for DataGridPagination : * @param {className} CSS * @param {style} CSS styles * @param {currentPage} Index of the currently displayed page, starting from 1 * @param {pageSize} Number of items displayed per page. Defaults to 10 * @param {totalItems} Total number of items present in the datagrid, after the filters have been applied * @param {lastPage} Index of the last page for the current data * @param {getPage} custom function to get page data for given page number * @param {compactFooter} if true will render compact pagination footer * @param {pageSizes} Array containing pageSize which user can select from dropdown menu. * Supports custom page sizes. For example["10", "20", "50", "100", CUSTOM_PAGE_SIZE_OPTION] * @param {maxCustomPageSize} Maximum limit for custom page size as well as for pageSize dropdown * @param {isCustomPageSizeSelected} set to true if page sizes dropdown is present and custom option is selected */ export declare type DataGridPaginationProps = { className?: string; style?: any; currentPage?: number; pageSize?: number; pageSizes?: string[]; totalItems: number; compactFooter?: boolean; getPageData?: (pageIndex: number, pageSize: number) => Promise; maxCustomPageSize?: number; isCustomPageSizeSelected?: boolean; }; /** * Enum for GridSelectionType : * @param {MULTI} for enabling multi row select * @param {SINGLE} for enabling single row select */ export declare enum GridSelectionType { MULTI = "multi", SINGLE = "single" } /** * Enum for sorting order : * @param {DESC} to sort data in descending order * @param {ASC} to sort data in ascending order * @param {NONE} no sorting */ export declare enum SortOrder { DESC = "descending", ASC = "ascending ", NONE = "none" } /** * Enum for RowType : * @param {EXPANDABLE} for enabling expandable rows * @param {COMPACT} for enabling compact rows * @param {ROWS_WITH_DETAIL_PANE} for enabling detail pane for rows * @param {EXPANDABLE_ROWS_WITH_DETAIL_PANE} for enabling detail pane for expandable rows * @param {COMPACT_ROWS_WITH_DETAIL_PANE} for enabling detail pane for compact rows */ export declare enum GridRowType { EXPANDABLE = "expandable", COMPACT = "compact", ROWS_WITH_DETAIL_PANE = "rows_with_detail_pane", EXPANDABLE_ROWS_WITH_DETAIL_PANE = "expandable_rows_with_detail_pane", COMPACT_ROWS_WITH_DETAIL_PANE = "compact_rows_with_detail_panes" } export declare const DEFAULT_COLUMN_WIDTH: number; export declare const DEFAULT_CURRENT_PAGE_NUMBER: number; export declare const DEFAULT_PAGE_SIZE: number; export declare const DEFAULT_TOTAL_ITEMS: number; export declare const DEFAULT_MAX_PAGE_SIZE: number; export declare const CUSTOM_PAGE_SIZE_OPTION: string; /** * State for DataGrid : * @param {selectAll} set to true if all rows got selected else false * @param {allColumns} column data * @param {allRows} row data * @param {pagination} pagination data * @param {isLoading} if true shows loading spinner else shows datagrid */ declare type DataGridState = { selectAll: boolean; allColumns: DataGridColumn[]; allRows: DataGridRow[]; pagination?: DataGridPaginationState; isLoading: boolean; }; /** * State for DataGrid Pagination : * @param {currentPage} Page index of the current page * @param {pageSize} page size of the page. Default is 10 * @param {totalItems} total number of items * @param {firstItem} first item number in current page * @param {lastItem} last item number in current page * @param {totalPages} number of total pages * @param {pageSizes} array of page sizes. can support string "custom" For example, ["10", "20", "50", "100", CUSTOM_PAGE_SIZE_OPTION] * @param {compactFooter} if true renders compact pagination footer * @param {isCustomPageSizeSelected} if true renders input box to enter custom pageSize * @param {maxCustomPageSize} maximum value for custom page size */ declare type DataGridPaginationState = { currentPage: number; pageSize: number; totalItems: number; firstItem: number; lastItem: number; totalPages: number; pageSizes?: string[]; compactFooter?: boolean; isCustomPageSizeSelected?: boolean; maxCustomPageSize?: number; }; /** * DataGrid Component : * Displays data in grid format */ export declare class DataGrid extends React.PureComponent { private pageIndexRef; private datagridTableRef; private customPageSizeRef; constructor(props: DataGridProps); componentDidUpdate(prevProps: DataGridProps): void; initializeDataGridState: () => DataGridState; initializeRowData: () => DataGridRow[]; initializeColumnData: () => DataGridColumn[]; private initializePaginationData; getSelectedRows: () => DataGridRow[]; getSelectionEnabledRows: (allRows: DataGridRow[]) => DataGridRow[]; isAllRowsSelected: (allRows: DataGridRow[]) => boolean; getAllRows: () => DataGridRow[]; updateRows: (rows: DataGridRow[], totalItems?: number | undefined) => void; updateColumns: (cols: DataGridColumn[]) => void; updateColumnWidth: (col: DataGridColumn) => void; hideLoader(): void; showLoader(): void; closeDetailPane: () => void; private getTotalPages; private getFirstItemIndex; private getLastItemIndex; private handleSelectPageSize; private gotoFirstPage; private gotoLastPage; private gotoNextPage; private gotoPreviousPage; private handlePageChangeOnBlur; private handlePageChangeOnKeyDown; private handleCustomPageSizeChangeOnKeyDown; private handlePageChange; private handleCustomPageSizeChange; private getPage; private toggleExpand; handleDetailPaneToggle: (rowID: number) => void; private handleSelectAll; private handleSelectSingle; private handleSort; private updateRowIDs; private updateColumnIDs; private setColumnVisibility; private getColObject; private getColWidth; private isColVisible; private setSortingState; private getFirstVisibleColumn; private isDatagridWithDetailPane; private getRowDataWithOpenDetailPane; private isDetailPaneOpen; private buildDetailPaneToggleIcon; private buildExpandableCell; private buildSelectColumn; private buildEmptyColumn; private buildSelectCell; private buildDataGridBody; private buildPlaceHolderContainer; private buildEmptyPlaceholder; private buildDataGridHeader; private buildDataGridColumn; private buildDataGridRow; private buildRowCells; private buildExpandableRow; private buildDetailPaneForRow; private buildDataGridCell; private buildCustomPageSizeInput; private buildPageSizesSelect; private buildCompactPageButtons; private buildPageButtons; /** * Builds the label for the pagination footer. * @returns {string} The pagination footer label. */ private buildPaginationFooterLabel; private buildDataGridPagination; private buildHideShowColumnsBtn; private buildSelectedRowCount; private buildFooterContent; private buildDataGridFooter; buildDataGridSpinner(): React.ReactElement; render(): JSX.Element; } export {};