import { ReactNode, RefObject } from "react"; export type Column = { body?: (row: any, field: string, level: number) => any; field: string; headerName: string; sticky?: "left" | "right"; width?: number; sorting?: boolean; sortType?: string; skeleton?: React.ReactNode; showExpansionIcon?: boolean; alignItem?: "center" | "left" | "right"; }; export type Row = { id?: string | number; body?: (row: any) => any; [key: string]: any; children?: Row[]; }; export interface VirtualizationSettingsProps { rowHeight: number; bufferRowCount: number; initialRowIndex: number; initialScrollPosition?: number; } export interface SettingsTypes extends VirtualizationSettingsProps { visibleRowCount: number; minRowIndex: number; maxRowIndex: number; } /** * Interface for the properties of the BlkBoxTable component. */ export interface BlkBoxTableProps { /** * Array of column definitions for the table. */ columns: Column[]; /** * Array of row data objects to be displayed in the table. */ rows: Row[] | []; /** * Determines whether columns can be dragged to reorder. * Default is `false`. */ isColumnDraggable?: boolean; /** * Determines whether rows can be dragged to reorder. * Default is `false`. */ isRowDraggable?: boolean; /** * Determines whether rows can be expanded to show additional details. * Default is `false`. */ isRowExpandable?: boolean; /** * Determines whether the pagination controls are visible. * Default is `true`. */ isPaginatorVisible?: boolean; /** * Callback function triggered when a row is expanded. * * @param data - The data of the expanded row. */ onRowExpanded?: (data: Row) => void; /** * Key used to uniquely identify rows in the table. */ rowKey?: string | number; /** * Class name applied to the table container for custom styling. */ tableContainerClassName?: string; /** * Indicates whether the table is in a loading state. */ isLoading?: boolean; /** * Determines whether rows are selectable. * Default is `false`. */ isRowSelectable?: boolean; /** * Custom React node to render as the expansion arrow icon. */ expansionArrowIcon?: React.ReactNode; /** * Custom React component to display when the table has no rows. */ emptyStateComponent?: React.ReactNode; /** * Settings for virtualizing the table content. */ virtualizationSettings?: Partial; /** * Default number of rows displayed per page. */ defaultRowsPerPage?: number; /** * Array of options for rows per page in the paginator. */ rowsPerPageOptions?: number[]; /** * Text used to filter the rows in the table. */ filterText?: string; /** * Mutable reference object for accessing table methods and properties. */ tableRef?: React.MutableRefObject; } export interface BlkBoxTableRef { /** * Retrieves the data of the selected rows. * Only top-level rows (level 0) are included. * * @returns {Row[]} An array of selected row data objects. */ getSelectedData: () => Row[]; /** * Retrieves the rowKeys of the selected rows. * * @returns {string[]} An array of selected rowKeys. */ getSelectedRowIds: () => string[]; } export interface TableHeaderProps { leftColumns: Column[]; mainColumns: Column[]; rightColumns: Column[]; mainContentRef?: RefObject; handleMouseDown: (index: number, e: React.MouseEvent, type: "left" | "right" | "main") => void; enableColumnDrag: any; onColumnDragStart: any; onColumnDragOver: any; onColumnDrop: any; selectAll: () => void; deselectAll: () => void; isAllRowsSelected?: boolean; showIntermediateStateOnCheckbox: boolean; sortingColumns: Column[]; setSortingColumns: any; leftMargin: number; rightMargin: number; } export interface TableBodyProps extends Partial { rows: Row[] | number[]; bodyRef?: RefObject; mainContentBodyRef?: RefObject; stickyCols?: RefObject; enableRowDrag: any; onRowDragStart: any; onRowDragOver: any; onRowDrop: any; allowRowExpansion?: boolean; showPaginator?: boolean; onRowExpanded?: (data: any) => void; rowKey: string | number; selectedRowIds?: Set; selectRow: (id: string) => void; deselectRow: (id: string) => void; loading: boolean; expandArrowIcon?: React.ReactNode; virtualizationSettings?: Partial; loadingPlaceholder: number[]; } export interface TableRowProps extends Partial { bodyRef?: RefObject; mainContentBodyRef?: RefObject; stickyCols?: RefObject; enableRowDrag?: boolean; onRowDragStart?: () => void; onRowDragOver?: () => void; onRowDrop?: () => void; allowRowExpansion?: boolean; columns: Column[] | undefined; row: Row; stickyClass?: string; handleRowToggle: (data: Row) => void; expandedRows: any; rowKey: string | number; selectRow?: (id: string) => void; deselectRow?: (id: string) => void; isRowSelected: boolean; loading: boolean; expandArrowIcon?: React.ReactNode; settings?: SettingsTypes; } export interface ColumnCellProps { col: Column; handleMouseDown: (index: number, e: React.MouseEvent, type: "left" | "right" | "main") => void; enableColumnDrag: any; onColumnDragStart: any; onColumnDragOver: any; onColumnDrop: any; index: number; stickyClass?: string; columnType: "left" | "main" | "right"; selectAll: () => void; deselectAll: () => void; isAllRowsSelected?: boolean; showIntermediateStateOnCheckbox: boolean; sortingColumns: Column[]; setSortingColumns: any; } export interface ScrollerProps { settings: SettingsTypes; get: (index: number, bufferedItems: number) => any[]; className: string; style?: React.CSSProperties; renderRow: (row: any) => ReactNode; controlledRef?: React.Ref; onScroll?: (event: React.UIEvent) => void; scrollTop: number; showPaginator: boolean; rowKey: string | number; } export interface TableCellProps extends Partial { bodyRef?: RefObject; mainContentBodyRef?: RefObject; stickyCols?: RefObject; enableRowDrag: any; onRowDragStart: any; onRowDragOver: any; onRowDrop: any; allowRowExpansion?: boolean; columns: Column[] | undefined; rowData: Row; columnData: Column; stickyClass?: string; handleRowToggle: (data: Row) => void; index: number | string; expandedRows: any; rowLevel?: number; loading: boolean; showExpansionIcon?: boolean; expandArrowIcon?: React.ReactNode; settings?: SettingsTypes; rowKey: string | number; } export interface PaginationProps { onPageChange: (page: number) => void; totalCount: number; siblingCount?: number; currentPage: number; showRowPerPage: number; handlePerChange: (value: number) => void; paginatorOptions: number[]; } export interface TableCellLoaderProps { width?: string; height?: string; animate?: boolean; }