UNPKG

react-tablenex

Version:

A next-gen React table component that simplifies data display

113 lines (109 loc) 2.82 kB
import React$1 from 'react'; /** * Represents an individual cell's content and styling. */ interface TableCell { accessor: string; header?: React.ReactNode; width?: string; style?: React.CSSProperties; className?: string; render?: (value: React.ReactNode, row: Record<string, React.ReactNode>) => React.ReactNode; } /** * Represents a column definition for the table. */ interface TableColumn { accessor: string; header?: React.ReactNode; width?: string; style?: React.CSSProperties; className?: string; render?: (value: React.ReactNode, row: Record<string, React.ReactNode>) => React.ReactNode; } /** * Represents a row in the table footer. */ interface FooterRow { cells: { content: React.ReactNode; colSpan?: number; className?: string; style?: React.CSSProperties; }[]; className?: string; style?: React.CSSProperties; } /** * Defines styling for a specific row based on its key value. */ interface StyledRow { keyValue: string | number; className?: string; style?: React.CSSProperties; } /** * Defines styling for a specific column based on its accessor. */ interface StyledColumn { columnName: string; className?: string; style?: React.CSSProperties; } /** * Represents an expandable sub-row that appears after a specific row. */ interface ExpandedRow { afterRowKey: string | number; element: React.ReactNode; } /** * Defines the color scheme for the table. */ interface ColorScheme { PRIMARY: string; SECONDARY: string; ACCENT: string; BORDER: string; } /** * Size options for styling properties. */ type SizeOption = "none" | "sm" | "md" | "lg" | "xl"; /** * Styling options for the table's appearance. */ interface TableStyles { rounded?: SizeOption; spacing?: SizeOption; columnBorder?: SizeOption; rowBorder?: SizeOption; fontSize?: string; } /** * Props for the TableNex component. */ interface TableProps { data: Record<string, React.ReactNode>[]; columns?: TableColumn[]; fixedColumns?: string[]; styledRows?: StyledRow[]; styledColumns?: StyledColumn[]; expandedRows?: ExpandedRow[]; footer?: FooterRow[]; keyField?: string | { keyId: string; isVisible: boolean; }; noDataMessage?: React.ReactNode; colorScheme?: Partial<ColorScheme>; responsive?: boolean; styles?: Partial<TableStyles>; } declare module "react" { interface CSSProperties { [key: `--${string}`]: string | number; } } declare const TableNex: React$1.FC<TableProps>; export { type ColorScheme, type ExpandedRow, type FooterRow, type SizeOption, type StyledColumn, type StyledRow, type TableCell, type TableColumn, type TableProps, type TableStyles, TableNex as default };