@pagamio/frontend-commons-lib
Version:
Pagamio library for Frontend reusable components like the form engine and table container
67 lines (66 loc) • 2.11 kB
TypeScript
import { type MRT_ColumnDef, type MRT_TableOptions, type MRT_TableState } from 'mantine-react-table';
import { type Row } from 'react-table';
import type React from 'react';
export interface ExtendedMRTColumnDef<TData extends Record<string, any>> extends MRT_ColumnDef<TData> {
/** Enable click to copy for this column */
enableCopy?: boolean;
formattedCellElement?: (value: string | number | TData) => React.ReactNode;
}
export interface ReusableTableProps<TData extends Record<string, any>> {
/** Table column definitions */
columns: ExtendedMRTColumnDef<TData>[];
/** Data to be displayed in the table */
data: TData[];
/** Optional title for the table */
title?: string;
/** Initial state options for the table */
initialState?: Partial<MRT_TableState<TData>>;
/** Enable or disable global search */
enableGlobalSearch?: boolean;
/** Enable or disable column-specific filters */
enableColumnFilters?: boolean;
/** Enable or disable sorting */
enableSorting?: boolean;
/** Enable or disable pagination */
enablePagination?: boolean;
/** Enable or disable row selection */
enableRowSelection?: boolean;
/** Enable or disable column reordering */
enableColumnReordering?: boolean;
/** Enable or disable sticky header */
enableStickyHeader?: boolean;
/** Callback when a row is clicked */
onRowClick?: (row: Row<TData>, event: React.MouseEvent) => void;
/** Additional table options */
tableOptions?: Partial<MRT_TableOptions<TData>>;
}
export interface TableData {
[key: string]: any;
}
export interface FilterConfig {
name: string;
placeholder?: string;
label: string;
type: string;
options: any;
valueKey?: string;
url?: string;
tourUrl?: string;
query?: any;
multi?: boolean;
rangeKeys?: {
start: string;
end: string;
};
}
export interface Visual {
type: string;
dataKey?: string;
title?: string;
columns?: any[];
}
export interface Section {
title?: string;
layout: string;
visuals: Visual[];
}