react-mutation-mapper
Version:
Generic Mutation Mapper
102 lines (101 loc) • 4.08 kB
TypeScript
import { RemoteData } from 'cbioportal-utils';
import { IReactionDisposer } from 'mobx';
import * as React from 'react';
import { Column, RowInfo, TableProps } from 'react-table';
import { DataFilter } from '../../model/DataFilter';
import { DataStore } from '../../model/DataStore';
import { ColumnSelectorProps, ColumnVisibilityDef } from './ColumnSelector';
export declare type DataTableColumn<T> = Column<T> & {
name?: string;
togglable?: boolean;
searchable?: boolean;
};
export declare enum ColumnSortDirection {
ASC = "asc",
DESC = "desc"
}
export declare type ColumnSort = {
column: string;
sortDirection?: ColumnSortDirection;
};
export declare type DataTableProps<T> = {
data?: T[];
dataStore?: DataStore;
columns?: DataTableColumn<T>[];
className?: string;
reactTableProps?: Partial<TableProps<T>>;
initialSort?: ColumnSort[];
initialSortRemoteData?: (RemoteData<any> | undefined)[];
initialItemsPerPage?: number;
highlightColorLight?: string;
highlightColorDark?: string;
showColumnVisibility?: boolean;
showSearchBox?: boolean;
onSearch?: (input: string, visibleSearchableColumns: DataTableColumn<T>[]) => void;
searchDelay?: number;
searchPlaceholder?: string;
info?: JSX.Element;
columnVisibility?: {
[columnId: string]: boolean;
};
columnSelectorProps?: ColumnSelectorProps;
};
export declare function getInitialSortDataStatus(initialSortRemoteData?: (RemoteData<any> | undefined)[]): import("cbioportal-utils").RemoteDataStatus;
export default class DataTable<T> extends React.Component<DataTableProps<T>, {}> {
static defaultProps: {
data: never[];
initialItemsPerPage: number;
highlightColorLight: string;
highlightColorDark: string;
};
private filterInput;
private filterInputReaction;
private _columnVisibilityOverride;
private expanded;
constructor(props: DataTableProps<T>);
get tableData(): T[] | undefined;
get columns(): DataTableColumn<T>[];
get needToCustomizeRowStyle(): DataFilter<any>[] | undefined;
get showPagination(): boolean;
get initialSortDataStatus(): import("cbioportal-utils").RemoteDataStatus;
get defaultSorted(): {
id: string;
desc: boolean;
}[] | undefined;
get columnVisibility(): {
[columnId: string]: boolean;
};
get columnVisibilityDef(): ColumnVisibilityDef[];
get columnVisibilityByColumnDefinition(): {
[columnId: string]: boolean;
};
render(): JSX.Element;
componentWillReceiveProps(nextProps: Readonly<DataTableProps<T>>): void;
componentWillUnmount(): void;
/**
* This reaction is to reset expander component every time the data or selection filters update.
* It would be cleaner if we could do this with a ReactTable callback (something like onDataChange),
* but no such callback exists.
*/
protected createExpanderResetReaction(dataStore: DataStore): IReactionDisposer;
/**
* This reaction is to reset search input box content when text input filter is reset.
* TODO if possible directly render the value in the actual search box component instead of adding this reaction
*/
protected createFilterInputResetReaction(dataStore: DataStore): IReactionDisposer;
protected getTrProps(state: any, row?: RowInfo): {
style: {
background: string | undefined;
};
};
protected filterInputRef(input: HTMLInputElement): void;
protected onSearch(searchText: string): void;
protected onVisibilityToggle(selectedColumnIds: string[]): void;
protected updateColumnVisibility(id: string, visible: boolean): void;
protected onExpandedChange(expanded: {
[index: number]: boolean;
}): void;
protected resetExpander(): void;
protected isRowHighlighted(datum: T): boolean | undefined;
protected getRowBackground(row: RowInfo): string | undefined;
}