import { MantineReactTable, MRT_Cell, MRT_Column, MRT_Row, MRT_RowData, MRT_TableInstance, MRT_TableOptions, useMantineReactTable, Xor } from "mantine-react-table"; import { useNejReactTable } from "./useNejReactTable"; import { LoadingOverlay } from "@mantine/core"; import { ReactNode, RefObject } from "react"; export type TableInstance = MRT_TableInstance & { loading: boolean } type TableInstanceProp = { table: TableInstance; }; export type NejReactTableOptions = Omit, "data"> & { data?: TData[] }; export type NejReactRenderActions = (props: { cell: MRT_Cell; column: MRT_Column; renderedCellValue: ReactNode | number | string; renderedColumnIndex?: number; renderedRowIndex?: number; row: MRT_Row; rowRef?: RefObject; table: MRT_TableInstance; }) => ReactNode; export type CommonlyExposedNejReactTableProps = CommonlyForwardedNejReactTableOptions & { renderActions?: NejReactRenderActions } export type CommonlyForwardedNejReactTableOptions = Omit, "columns"> type Props = Xor< TableInstanceProp, NejReactTableOptions >; const isTableInstanceProp = ( props: Props, ): props is TableInstanceProp => (props as TableInstanceProp).table !== undefined; export type RenderActionType = (data: { cell: MRT_Cell; column: MRT_Column; renderedCellValue: ReactNode | number | string; renderedColumnIndex?: number; renderedRowIndex?: number; row: MRT_Row; rowRef?: RefObject; table: MRT_TableInstance; }) => React.ReactNode export const NejReactTable = ( props: Props, ) => { let table: TableInstance; if (isTableInstanceProp(props)) { table = props.table; } else { table = useNejReactTable(props); } return
; };