# AdvancedTable Server-paginated data table with a column-visibility ("View") menu. Built on Mantine `Table`. Portable — two files, no app-specific imports. ## Files - `AdvancedTable.tsx` — the component. - `useServerTable.ts` — small hook for page-index + search-query state (optional, but pairs with it). To use in another project, copy both files as-is into that project and export them from your UI barrel (or import by relative path). ## Dependencies ``` @mantine/core (tested on ^8) @tabler/icons-react (IconRefresh, IconEye, IconInbox) react-i18next (useTranslation) react (>=17, uses hooks) ``` If the target project doesn't use `react-i18next`, replace the `t(key, fallback)` calls with plain strings — the component only reads the fallback text, translation is not load-bearing. ## Install ```bash npm install @mantine/core @tabler/icons-react react-i18next ``` Mantine must already be set up with `MantineProvider` in the app root — this component does not wrap one. ## Copy the source Copy `AdvancedTable.tsx` and `useServerTable.ts` into the new project (e.g. `src/components/table/`). No modifications needed unless you're renaming the i18n keys. ## API ### `AdvancedColumn` | Field | Type | Required | Notes | |---|---|---|---| | `header` | `ReactNode` | yes | Column heading, also used as the label in the View menu. | | `accessorKey` | `string` | no | Dot-path into the row (e.g. `"expectation.name"`), used when `cell` is omitted. | | `cell` | `(ctx: { row: { original: T }; value: unknown }) => ReactNode` | no | Custom cell renderer. Takes priority over `accessorKey`. | | `size` | `number` | no | Column width in px. | | `align` | `'left' \| 'center' \| 'right'` | no | Text alignment for header + cells. | | `enabled` | `boolean` | no | Whether the column starts **visible**. Default `true`. Toggled at runtime via the View menu. | ### `AdvancedTable` props | Prop | Type | Required | Notes | |---|---|---|---| | `columns` | `AdvancedColumn[]` | yes | | | `data` | `T[]` | yes | Rows for the **current page** only — not the full dataset. | | `tableName` | `string` | yes | Shown as the table title. | | `itemCount` | `number` | yes | Total row count on the server. Drives pagination and the count badge — not `data.length`. | | `pageIndex` | `number` | yes | 0-based current page. | | `onPageChange` | `(pageIndex: number) => void` | yes | | | `pageSize` | `number` | no | Default `10`. Pagination only renders when `itemCount > pageSize`. | | `onPageSizeChange` | `(pageSize: number) => void` | no | Shows a page-size `