import { TableGroup } from "./classes/group"; import { TableRow } from "./classes/row"; import { TableItem } from "./classes/item"; import { FormSchemaData, FormSchemaEvent } from "../form/form.interface"; import { Resource, ResourceResponse } from "../generic/base/model"; import { ButtonMode, ButtonSize } from "../button/button.component"; export interface TableSettings { id?: string; cache?: boolean; loading?: boolean; columns: Array; data?: Array; sort?: TableSort; filter?: TableFilter; pagination?: TablePagination; totals?: Array; group?: TableGroupData; remote?: TableRemoteData; selectable?: TableRowSelectableFunction | boolean; clickable?: TableRowClickableFunction | boolean; row_class?: TableRowCssClassFunction | string; row_style?: TableRowStyleFunction | Object; empty_text?: string; action_text?: string; } export interface TableCache { sort?: TableSort; filter?: TableFilter; pagination?: TablePagination; } export interface TableColumnData { header?: TableColumnHeader; accessor?: string; sortable?: boolean; numeric?: boolean; truncate?: boolean; html?: boolean; width?: string; format?: TableColumnFormatter; title?: TableColumnFormatter; buttons?: Array; input?: TableColumnInputData; link?: TableColumnLink; selectable?: boolean; } export interface TableColumnHeader { label?: TableStringFunction | string; title?: TableStringFunction | string; } export interface TableColumnLink { url?: TableColumnFormatter | string; target?: string; action?: (row_data: any) => void; } export declare type TableColumnFormatter = (table_row: any) => string; export interface TableActionData { label: string; icon: string; title?: string; visible?: TableBooleanFunction | boolean; disabled?: TableBooleanFunction | boolean; action: (event: TableDefaultEvent) => void; } export interface TableButtonBasicData { type?: "button"; label?: TableStringFunction | string; title?: TableStringFunction | string; mode?: ButtonMode; size?: ButtonSize; color?: string; icon?: string; icon_mode?: string; visible?: TableBooleanFunction | boolean; disabled?: TableBooleanFunction | boolean; action: (event: TableDefaultEvent) => any; } export interface TableButtonDropdownData { type: "dropdown"; label?: TableStringFunction | string; title?: TableStringFunction | string; mode?: ButtonMode; size?: ButtonSize; color?: string; icon?: string; icon_mode?: string; list?: Array; visible?: TableBooleanFunction | boolean; disabled?: TableBooleanFunction | boolean; } export declare type TableButtonData = TableButtonBasicData | TableButtonDropdownData; export interface TableColumnInputSchemaEvent extends FormSchemaEvent { table_row: TableRow; table_item: TableItem; data: any; } export declare type TableColumnInputData = FormSchemaData; export interface TableItemObject { [key: string]: TableItem; } export interface TableSort { manual?: boolean; direction?: "asc" | "desc"; accessor?: string; icon?: string; } export interface TableFilter { [key: string]: any; } export interface TablePagination { disabled?: boolean; manual?: boolean; number?: number; last?: number; next?: number; previous?: number; count?: number; size?: TablePaginationSize; } export declare type TablePaginationSize = 5 | 10 | 15 | 25 | 50 | 100 | 150; export interface TableGroupTotal { label: string; title: string; html: boolean; colspan: number; numeric: boolean; } export interface TableGroupTotalData { accessor: string; html?: boolean; colspan?: number; numeric?: boolean; format?: (data: Array, table: Array | Array, previous_group: TableGroup) => string; title?: (data: Array, table: Array | Array, previous_group: TableGroup) => string; } export interface TableTotal { label: string; title: string; html: boolean; colspan: number; numeric: boolean; } export interface TableTotalData { accessor: string; html?: boolean; colspan?: number; numeric?: boolean; title?: (data: Array, table: Array | Array) => string; format?: (data: Array, table: Array | Array) => string; } export interface TableGroupData { format?: TableGroupFormatter; accessor: string; title?: TableGroupFormatter; button?: TableButtonData; totals?: Array; show_count?: boolean; default_label?: string; collapsible?: boolean; } export declare type TableGroupFormatter = (accessor_data: any, data: Array) => string; export interface TableRemoteData { initial_loading?: boolean; model?: TableRemoteModel; params?: TableRemoteParams; onChange?: TableRemoteOnChange; } export interface TableRemoteModel { method: Resource; accessor: string; } export declare type TableRemoteOnChange = (response: ResourceResponse) => void; export interface TableRemoteParams { [key: string]: any; } export interface TableRemoteFilter extends TableFilter { } export interface TableRemotePagination extends TablePagination { } export interface TableRowEvent { table_row: TableRow; data: any; } export interface TableDefaultEvent { table_row?: TableRow; table_item?: TableItem; data: any | Array; } export declare type TableRowSelectableFunction = (event: TableRowEvent) => boolean; export declare type TableRowClickableFunction = (event: TableRowEvent) => boolean; export declare type TableRowCssClassFunction = (event: TableRowEvent) => string; export declare type TableRowStyleFunction = (event: TableRowEvent) => Object; export declare type TableBooleanFunction = (event: TableDefaultEvent) => boolean; export declare type TableStringFunction = (event: TableDefaultEvent) => string;