Skip to Content
TelamonJS

ListPage

Complete list page rendered from a single CrudConfig — search, sort, pagination, dialogs

Complete list page component driven by a single CrudConfig — built-in search, sorting, pagination, row/header actions, and CRUD dialogs.

ListPage takes a single config: CrudConfig<T, TFormData> prop: title, columns, data and loading all live in config.


Basic Usage

Data loading, search, and mutations all come from config — built with React Query (config.query.queryFn fetches from your REST API; config.mutations.* handle create/update/delete).

config.tsx
'use client'
import { type CrudConfig } from '@telamonjs/ui'
import { usersApi } from '@/lib/api/users-client'

export const config: CrudConfig<User, UserFormData> = {
  module: { name: 'users', title: 'Users', description: 'Manage system users', route: '/admin/users' },
  list: { title: 'Users', description: 'Registered users', columns, searchPlaceholder: 'Search by name or email...' },
  form: { sections, validation: validationSchema },
  // queryFn resolves PaginatedResponse<User> ({ data, total, page, totalPages })
  query: { queryKey: ['users'], queryFn: usersApi.list },
  mutations: {
    // mutationFn resolves { success, data? } — shape it here, not in the API client
    create: {
      mutationFn: async (data) => ({ success: true, data: await usersApi.create(data) }),
      invalidates: [['users']],
    },
    update: {
      mutationFn: async ({ id, data }) => ({ success: true, data: await usersApi.update(id, data) }),
      invalidates: [['users']],
    },
    delete: {
      mutationFn: async ({ id }) => {
        await usersApi.delete(id)
        return { success: true }
      },
      invalidates: [['users']],
    },
  },
}
page.tsx
import { ListPage } from '@telamonjs/ui'
import { config } from './config'

export default function UsersPage() {
  return <ListPage config={config} />
}

Props

Prop

Type

Use CrudConfigWithAnyForm<TData> (not as any) when a helper needs to accept a config with any form-data shape — TFormData on CrudConfig is invariant.

Full interface (includes filters, bulk actions, toolbar slots)
interface ListPageProps<TData> {
  config: CrudConfigWithAnyForm<TData>
  tableId?: string
  urlSync?: boolean
  urlFilters?: Record<string, 'string' | 'number'>
  cardComponent?: ComponentType<{ data: TData; onClick?: (data: TData) => void }>
  className?: string
  onRefreshAction?: () => Promise<void | { success: boolean }>
  filterOptions?: ColumnFilterConfig
  loadFilterOptions?: () => Promise<ColumnFilterConfig>
  enableBulkActions?: boolean
  bulkActions?: BulkAction<TData>[]
  headerActions?: Array<{
    label: string
    icon?: ReactNode
    onClick: () => void
    variant?: 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost'
    loading?: boolean
  }>
  disableAutoRefresh?: boolean
  errorBoundary?: boolean
  errorFallback?: ReactNode
  toolbarPrepend?: ReactNode
  toolbarContent?: ReactNode | ((state: ListQueryState) => ReactNode)
  filtersPanel?: ReactNode
  activeFilters?: Array<{ key: string; label: string; onRemove: () => void }>
  onClearFilters?: () => void
  footerContent?: ReactNode
  embedded?: boolean
  dialogUrlSync?: boolean // default true
}

Column Definitions

config.list.columns takes CrudColumnDef<T> — a TanStack Table column definition whose header also accepts an I18nText:

config.tsx
import type { CrudColumnDef } from '@telamonjs/ui'

export const columns: CrudColumnDef<User>[] = [
  { accessorKey: 'name', header: 'Name' },
  { accessorKey: 'email', header: 'Email' },
  {
    accessorKey: 'role',
    header: 'Role',
    cell: ({ row }) => {
      const role = row.original.role
      return <Badge variant={role === 'ADMIN' ? 'default' : 'secondary'}>{role}</Badge>
    },
  },
  {
    accessorKey: 'createdAt',
    header: 'Created At',
    cell: ({ row }) => new Date(row.original.createdAt).toLocaleDateString(),
  },
]

Row and Header Actions

Row actions live in config.actionsConfig (DataTableActionsConfig); toolbar buttons are the headerActions prop of ListPage:

config.tsx
export const config: CrudConfig<User, UserFormData> = {
  // ...
  actionsConfig: {
    custom: [
      { id: 'open-page', label: 'Open page', href: row => `/admin/users/${row.id}` },
      { id: 'reset', label: 'Reset password', onClick: row => resetPassword(row.id), variant: 'destructive' },
    ],
  },
}
page.tsx
<ListPage
  config={config}
  headerActions={[{ label: 'Import', onClick: handleImport, variant: 'outline' }]}
/>

create/update/delete row and header actions (edit/view/create dialogs) are wired automatically from config.dialogs and config.mutations — see the Dialog Pattern and ListPage Pattern for the full dialog configuration.


Embedded (Dashboard Tabs)

Inside a tabbed dashboard (ShellPage + AdminHeader + AdminTabs), render the list with embedded to drop the outer page chrome:

<ListPage config={config} embedded />

Features

Built-in:

  • ✅ Pagination (client or server-side, driven by config.query)
  • ✅ Search (debounced)
  • ✅ Sorting (click column headers; list.sortParam picks what sortBy carries)
  • ✅ Filtering (column filters and list.toolbar.filters)
  • ✅ Row actions (contextual menu) and header actions (toolbar buttons)
  • ✅ Create/edit/view/delete dialogs from config.dialogs + config.mutations
  • ✅ Mobile-responsive (switches to cards)
  • ✅ Loading, empty, and error states
  • ✅ Excel/CSV/PDF export (list.enableExport): the loaded rows, every matching row (list.exportAll) or your backend (list.onExport) — see exporting every row

Best Practices

  1. Keep columns, sections, validation, query, and mutations together in one config.tsx (Page Config Pattern)
  2. Use queryKey/invalidates consistently so mutations refresh the right list
  3. Provide searchPlaceholder for better UX
  4. Use embedded inside AdminTabs, not a standalone page per module

  • DataTable - Lower-level table (more customization)
  • MobileCard - Card component for mobile view

See Also


On this page