ManagedDataTable
Full-featured table built on @tanstack/react-table — sort, filter, search, row selection, bulk actions, pagination and toolbar buttons. The same table used in benix-manager and benix-frontend.
Examples
Customers — selection, filters, bulk delete
Click rows to inspect, select via checkbox column, bulk delete via toolbar. Filters drop down from the column labels.
Customers
Linhas:
Página 1 de 1
const columns: ColumnDef<Customer>[] = [createSelectionColumn<Customer>(),{ accessorKey: 'name', header: 'Customer' },{ accessorKey: 'email', header: 'Email' },{ accessorKey: 'status', header: 'Status', cell: ({ getValue }) => statusToBadge(getValue()) },{ accessorKey: 'mrr', header: 'MRR' },];<ManagedDataTabledata={rows}columns={columns}title="Customers"searchPlaceholder="Search customers..."columnFilters={[{ columnId: 'status', label: 'Status', options: [...] },{ columnId: 'plan', label: 'Plan', options: [...] },]}bulkActions={[{label: 'Delete selected',icon: <Trash2 size={14} />,onClick: (selected) => deleteRows(selected),variant: 'solid',color: 'red',},]}toolbarButtons={[{ label: 'New customer', icon: <Plus size={14} />, onClick: openCreate },]}/>
Empty / loading
Pass loading to show a skeleton state.
<ManagedDataTabledata={[]}columns={columns}loading/>
Why bundled in the DS?
@tanstack/react-table is an optional peer dependency. The table is the most-used data primitive across the Benix products, so shipping a consistent, themeable implementation in the DS pays off.
// Optional peer — install only if you use ManagedDataTable:// npm install @tanstack/react-tableimport { ManagedDataTable, createSelectionColumn } from '@kactostecnologia/benix-ds';
API Reference
Props of the ManagedDataTable component.
| Prop | Type | Default | Description |
|---|---|---|---|
data* | T[] | — | — |
columns* | ColumnDef<T>[] | — | @tanstack/react-table column defs. |
title | string | — | Optional title above the toolbar. |
searchPlaceholder | string | — | — |
columnFilters | ColumnFilter[] | — | Multi-select filters bound to specific columns. |
customFilters | ReactNode | — | Free-form extra filters next to columnFilters. |
bulkActions | BulkAction<T>[] | — | Visible when rows are selected. |
toolbarButtons | ToolbarButton[] | — | Right-aligned primary actions. |
onRowClick | (row: T) => void | — | — |
loading | boolean | false | — |