@pretable/core
v0.0.2
Published
Framework-agnostic grid state primitives for Pretable.
Readme
@pretable/core
The headless engine for pretable. Drives sort, filter, selection, focus, viewport, and streaming-transaction state for any table-shaped UI.
When to reach for this
Most users want @pretable/react instead. It bundles @pretable/core with a React surface that handles rendering, layout, and keyboard interaction.
@pretable/core is for users building their own UI from scratch — for example, plain DOM, a non-React framework, or a custom canvas/webgl renderer. Headless usage is supported (the createGrid factory returns a fully-typed PretableGrid handle), but dedicated docs, examples, and demos for headless mode are forthcoming. If headless is what you're after, the type definitions and core.api.md are the source of truth today.
Install
npm install @pretable/core
# or pnpm add @pretable/core, yarn add @pretable/coreMinimal example
import { createGrid } from "@pretable/core";
const grid = createGrid({
columns: [
{ id: "name", header: "Name" },
{ id: "age", header: "Age", sortable: true },
],
rows: [
{ id: "1", name: "Ada", age: 36 },
{ id: "2", name: "Grace", age: 85 },
],
});
grid.subscribe(() => {
const { visibleRows, sort } = grid.getSnapshot();
console.log("rows:", visibleRows.length, "sort:", sort);
});
grid.setSort("age", "desc");Full public surface
See core.api.md for every exported type, interface, and function with their full signatures. The file is generated by API Extractor and committed to the repo; CI fails if it drifts.
License
MIT — see LICENSE.
