import { DNode } from '@dojo/framework/core/interfaces'; export interface FetcherMeta { total: number; } export interface FetcherResult { data: S[]; meta: FetcherMeta; } export interface SortOptions { columnId: string; direction: 'asc' | 'desc'; } export interface FilterOptions { columnId: string; value: any; } export interface FetcherOptions { sort?: SortOptions; filter?: { [index: string]: string; }; } export interface Fetcher { (offset: number, size: number, options?: FetcherOptions): Promise>; } export interface Updater { (item: S): void; } export interface ColumnConfig { id: string; title: string | (() => DNode); filterable?: boolean; sortable?: boolean; editable?: boolean; resizable?: boolean; renderer?: (props: any) => DNode; } export interface PageChangeCommandPayload { page: number; id: string; } export interface FetcherCommandPayload { fetcher: Fetcher; page: number; pageSize: number; id: string; } export type SelectionType = 'single' | 'multi'; export interface SelectionCommandPayload { id: string; index: number; type: SelectionType; } export interface SortCommandPayload { id: string; fetcher: Fetcher; columnId: string; direction: 'asc' | 'desc'; } export interface FilterCommandPayload { id: string; fetcher: Fetcher; filterOptions: FilterOptions; } export interface UpdaterCommandPayload { updater: any; page: number; id: string; value: any; columnId: string; rowNumber: number; } export interface GridPages { [index: string]: S[]; } export interface GridEditedRow { page: number; index: number; item: S; } export interface GridMeta { page: number; total: number; pageSize: number; sort: SortOptions; filter: { [index: string]: string; }; currentFilter: FilterOptions; isSorting: boolean; editedRow: GridEditedRow; selection: number[]; fetchedPages: number[]; } export interface GridData { pages: GridPages; } export interface GridState { [index: string]: { meta: GridMeta; data: GridData; }; }