UNPKG

trellis

Version:

Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications

33 lines 1.25 kB
/** * Table React — `useTable` hook (ADR 0034 wedge 6). * * Import from `trellis/table/react`: * * const table = useTable({ * data: tasks, * columns: [{ id: 'title', accessorKey: 'title', header: 'Title' }], * undoHistory: undo, * }); * // <tbody>{table.state.rows.map((row) => ( * // <tr key={row.id}>{table.state.columns.map((col) => ( * // <td onClick={() => col.editable && table.actions.startEdit(row.id, col.id)}> * // {row.cells[col.id]} * // </td> * // ))}</tr> * // ))}</tbody> * * The core is created once per mount; state flows through * `useSyncExternalStore` (same bridge as `trellis/undo-history/react`). * Generic over the row type: `useTable<Task>(...)`. * * @module trellis/table/react */ import type { TableConfig, UseTableReturn } from '../core/index.js'; /** Accept either a config (fresh core) or an existing core (shared mount). */ export type TableInput<T> = TableConfig<T> | UseTableReturn<T>; /** * Bind a table core to React. Pass a config for a fresh core, or an * existing core to share one mount across adapters. */ export declare function useTable<T extends object>(input: TableInput<T>): UseTableReturn<T>; //# sourceMappingURL=index.d.ts.map