import { IconNameType } from '../../misc/icon/types'; import React from 'react'; import { ButtonGroupButtonType } from '../../button-group/types'; import { ButtonProps } from '../../buttons/button/types'; import { fieldsMap } from '@app-soga/forms'; /** * Represents the Grid data used to render the table rows */ export declare type DataType = { /** Each record must have a */ id: number | string; [key: string]: string | boolean | number | null | DataType; }; /** * Represents the base configuration given to the Grid context */ export declare type GridContextConfig = { hover?: boolean; bordered?: boolean; striped?: boolean; allowSelect?: boolean; }; export declare type ActionResolverFNType = (d: any) => void; /** * All available events passed by the grid to all it's children */ export declare type GridEvents = { handleSelectRecord: (recordId: number | string) => void; handleSelectAll: () => void; handleChangeFilter: (e: React.ChangeEvent) => void; handleChangeSort: (sortName: string) => void; handlePageSizeChange: (n: number) => void; handleChangeCurrentPage: (n: number) => void; handleNextPage: () => number; handlePreviousPage: () => number; }; /** * Node passed to the grid to allow render a custom Row control */ export declare type RowControlType = (rowData: DataType) => React.ReactNode; /** * Configuration which can be passed to the custon row control */ export declare type RowControlsConfigType = { [key: string]: string | boolean | number; }; /** * Definition for the columns configuration */ export declare type ColumnConfigType = string | { className?: string; key: string; label?: string; value?: string | ((rowData: any) => string | React.ReactNode); }; export declare type SingleActionType = { key: string; icon?: IconNameType; action: ActionResolverFNType; }; /** * Actions which each row must render */ export declare type ActionType = string | SingleActionType[]; export declare type SortsConfigType = string[] | undefined; export declare type GridButtonsType = { label: string; action: () => void; }; /** * Available props passed to the advanced Grid */ export declare type AdvancedGridProps = { actions?: ActionType; actionResolvers?: ActionsResolverType; advancedSearch?: string[]; buttons?: (ButtonGroupButtonType & ButtonProps)[]; columns?: ColumnConfigType[]; dataProcessor?: any; rowDataProcessor?: any; hover?: boolean; id: string; filters?: string[]; filterOptions?: { [key: string]: FilterOptionsType; }; maxPages?: number; pageSize?: number; recordsPerPageValues?: number[]; rowControl?: RowControlType; rowControlOptions?: RowControlsConfigType; sorts?: SortsConfigType; title?: string; url?: string; }; export declare type SortsType = { [key: string]: number | undefined; }; /** * Props and configs passed by the advanced grid to it's children */ export declare type ContextType = { actions?: ActionType; actionResolvers?: ActionsResolverType; advancedSearch?: string[]; buttons?: (ButtonGroupButtonType & ButtonProps)[]; clearSelection?: () => void; columns?: ColumnConfigType[]; columnKeys?: string[]; config?: GridContextConfig; currentPage?: number; data?: DataType[]; dataLoaded?: boolean; filters?: string[]; filterOptions?: { [key: string]: FilterOptionsType; }; filterConfig?: { colSize?: { xs?: string; sm?: string; md?: string; lg?: string; }; fluid?: boolean; }; filterValues?: { [key: string]: string | number | undefined; }; gridId?: string; events?: GridEvents; loading?: boolean; maxPages?: number; pages?: number; pageSize?: number; recordsPerPageValues?: number[]; resetCheckAll?: () => void; rowControl?: RowControlType; rowControlOptions?: RowControlsConfigType; rowDataProcessor?: any; selectAllCheck?: boolean; selectedRecords?: (number | string)[]; sorts?: SortsType; title?: string; totalRecords?: number; }; export declare type ActionsResolverType = { [key: string]: { icon?: IconNameType; action: ActionResolverFNType; }; }; export declare type FilterOptionsType = { InputOptions?: { ajax?: boolean; autocomplete?: boolean; columnsMapping: { label: 'name'; value: 'id'; }; url: 'setting/country'; }; label: string; type: typeof fieldsMap; };