@up-group-ui/react-controls
Version:
Up shared react controls
153 lines (152 loc) • 6.1 kB
TypeScript
import * as React from 'react';
import { UpPaginationProps } from './UpPagination';
import { ActionFactory } from './UpDataGridRow';
import { ICellFormatter } from './UpDefaultCellFormatter';
import { IntentType, WithThemeProps } from '../../../Common/theming/types';
import { ActionType } from '../../../Common/actions';
import { UpDataGridFooterProps } from './UpDataGridFooter';
import { UpDataGridHeaderProps } from './UpDataGridHeader';
import { TestableComponentProps } from '../../../Common/utils/types';
import { IconName } from '../../../Common/theming/icons';
export declare function isActionEnabled(props: {
actions?: ActionFactory<any> | Array<Action>;
displayRowActionsWithinCell?: boolean;
}): boolean;
export interface Action {
type: ActionType;
iconName?: IconName;
intent?: IntentType;
description: string;
action: (row: Row) => void;
libelle?: string;
borderless?: boolean;
isVisible?: (value: any) => boolean;
getProps?: (value: any) => any;
additionalStyles?: {
backgroundColor?: string;
hoverBackgroundColor?: string;
};
}
export interface ToolTip {
title?: JSX.Element | string;
content: JSX.Element | string;
icon?: IconName;
}
export declare type RenderValue = {
value: any;
column: Column;
};
export interface Column {
label: string | JSX.Element;
field?: string;
formatter?: ICellFormatter;
getFormatterProps?: (value: string) => any;
render?: (value: RenderValue) => JSX.Element;
type?: any;
isSortable?: boolean;
isSorted?: boolean;
sortDir?: SortDirection;
tooltip?: ToolTip;
}
export interface Row {
isSelected?: boolean;
value?: any;
}
export declare type Method = 'GET' | 'POST';
export declare type PaginationPosition = 'top' | 'bottom' | 'both';
export interface exportCsv {
fileName: string;
textButton?: string;
}
export interface UpDataGridProps extends TestableComponentProps, WithThemeProps {
className?: string;
columns: Array<Column>;
rowActions?: ActionFactory<any> | Array<Action>;
labelToDisplayRowActionsInCell?: string;
isSelectionEnabled?: boolean;
isPaginationEnabled?: boolean;
paginationPosition?: PaginationPosition;
isOddEvenEnabled?: boolean;
isSortEnabled?: boolean;
rowsSelected?: Array<Row>;
lastFetchedDataTime?: Date;
rowTemplate?: any;
data?: Array<any>;
idKey?: string;
dataKey?: string;
isDataFetching?: boolean;
alignCells?: 'top' | 'bottom' | 'middle' | 'initial';
textAlignCells?: 'center' | 'left' | 'right' | 'initial';
exportCsv?: exportCsv;
dataSource?: {
query: string;
method?: Method;
entityKey?: string;
orderParamName?: string;
dirParamName?: string;
skipParamName?: string;
takeParamName?: string;
};
loadingMessage?: string;
paginationProps?: Partial<UpPaginationProps>;
injectRow?: (previous: any, next: any, colum: Column[]) => JSX.Element;
onSortChange?: (c: Column, dir: SortDirection) => void;
onSelectionChange?: (lastUpdatedRow: Row, dataSelected: any[], allRowsSelected?: Row[], isAllRowsSelected?: boolean) => void;
onRowClick?: (rowIndex: number, row: any) => void;
isRowClickable?: boolean;
getRowCustomClassName?: (rowIndex: number, row: any) => string;
footerProps?: Partial<UpDataGridFooterProps>;
headerProps?: Partial<UpDataGridHeaderProps>;
displayRowActionsWithinCell?: boolean;
onlyOneRowCanBeSelected?: boolean;
isDataInitialized?: boolean;
setIsDataInitializedToFalse?: () => void;
}
export interface UpDataGridState {
rows: Array<Row>;
columns: Array<Column>;
page?: number;
skip?: number;
take?: number;
total?: number;
isDataFetching?: boolean;
allRowsSelected?: boolean;
rowsSelected?: Array<Row>;
lastFetchedDataTime?: Date;
data?: any;
}
export declare type SortDirection = 'ASC' | 'DESC';
export declare const mapDataToRow: (data: Array<any>, allRowsSelected: boolean, rowsSelected: Array<any>) => Array<Row>;
declare const _default: {
new (props: any, context: any): {
render(): JSX.Element;
context: any;
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<Omit<UpDataGridProps, "children" | "theme">>) => {} | Pick<{}, K>) | Pick<{}, K>, callback?: () => void): void;
forceUpdate(callback?: () => void): void;
readonly props: Readonly<Omit<UpDataGridProps, "children" | "theme">> & Readonly<{
children?: React.ReactNode;
}>;
state: Readonly<{}>;
refs: {
[key: string]: React.ReactInstance;
};
componentDidMount?(): void;
shouldComponentUpdate?(nextProps: Readonly<Omit<UpDataGridProps, "children" | "theme">>, nextState: Readonly<{}>, nextContext: any): boolean;
componentWillUnmount?(): void;
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
getSnapshotBeforeUpdate?(prevProps: Readonly<Omit<UpDataGridProps, "children" | "theme">>, prevState: Readonly<{}>): any;
componentDidUpdate?(prevProps: Readonly<Omit<UpDataGridProps, "children" | "theme">>, prevState: Readonly<{}>, snapshot?: any): void;
componentWillMount?(): void;
UNSAFE_componentWillMount?(): void;
componentWillReceiveProps?(nextProps: Readonly<Omit<UpDataGridProps, "children" | "theme">>, nextContext: any): void;
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<Omit<UpDataGridProps, "children" | "theme">>, nextContext: any): void;
componentWillUpdate?(nextProps: Readonly<Omit<UpDataGridProps, "children" | "theme">>, nextState: Readonly<{}>, nextContext: any): void;
UNSAFE_componentWillUpdate?(nextProps: Readonly<Omit<UpDataGridProps, "children" | "theme">>, nextState: Readonly<{}>, nextContext: any): void;
};
displayName: string;
contextTypes: {
theme: import("prop-types").Requireable<object>;
};
contextType?: React.Context<any>;
};
export default _default;