@rws-aoa/react-library
Version:
RWS AOA Design System
94 lines • 3.28 kB
TypeScript
import { SxProps } from '@mui/material';
import { DataGridProps, GridColDef, GridGetRowsParams, GridLocaleText, GridPaginationModel, GridRowModel, GridValidRowModel } from '@mui/x-data-grid';
import { JSX } from 'react';
export interface AoaTableData<T extends GridValidRowModel = GridValidRowModel> {
/**
* Additional `pageInfo` for advanced use-cases.
* `hasNextPage`: When row count is unknown/estimated, `hasNextPage` will be used to check if more records are available on server.
*/
pageInfo?: {
hasNextPage?: boolean;
nextCursor?: string;
};
/**
* To reflect updates in total `rowCount` (optional).
* Useful when the `rowCount` is inaccurate (for example when filtering) or not available upfront.
*/
rowCount?: number;
/**
* The paged, filtered and sorted items from the database
*/
rows: GridRowModel<T>[];
}
export type AoaTableColumns<T extends object = any> = GridColDef<T>[];
export type AoaTableQueryOptions = GridPaginationModel & Omit<GridGetRowsParams, 'end' | 'paginationModel' | 'start'>;
type ModeProps =
/**
* Overwrites the default mode (server) when you need pagination, filtering and sorting on the client side
*/
{
getData?: never;
mode: 'client';
}
/**
* The Redux action that takes PaginationModel as parameter to retrieve data from the server
*/
| {
getData(queryOptions: AoaTableQueryOptions): Promise<void> | void;
mode?: 'server';
};
export type AoaTableProps<T extends object = any> = ModeProps & {
/**
* Action buttons shown in the toolbar of the table
*/
readonly actionButtons?: JSX.Element[];
/**
* The column structure to display the data
*/
readonly columns: GridColDef<T>[];
/**
* The TableData object to be displayed in the table
*/
readonly data: AoaTableData<T>;
/**
* Data-qa tag for E2E test purposes
*/
readonly 'data-qa'?: string;
/**
* Overwrite a safe selection of the {@link DataGrid} properties
*/
readonly dataGridOverridableProps?: Pick<DataGridProps<T>, 'apiRef' | 'checkboxSelection' | 'disableColumnFilter' | 'disableRowSelectionOnClick' | 'getRowId' | 'ignoreDiacritics' | 'isRowSelectable' | 'loading' | 'onRowSelectionModelChange' | 'rowSelectionModel'>;
/**
* Sets the initial sortModel in case the required sorting differs from the back-end's default sorting
*/
readonly initialSort?: {
field: string;
sort: 'asc' | 'desc';
};
/**
* Overwrites the default labels when you need a different language than Dutch
*/
readonly localeText?: GridLocaleText & {
refreshTable: string;
};
/**
* Material UI's property to apply styling
*/
readonly sx?: SxProps;
};
/**
* Constructs a table using pre-defined Rijks styling
*
* @param props - Props to pass to the button
* @example
* ```jsx
* <AoaTable
* getData={(queryOptions) => getMockData(queryOptions)}
* data={mockData}
* columns={[{ field: "id" }, { field: "title" }, { field: "completed" }]}
* />
* ```
*/
export declare function AoaTable<T extends object = any>({ ...props }: AoaTableProps<T>): import("react/jsx-runtime").JSX.Element;
export {};
//# sourceMappingURL=Table.d.ts.map