Skip to content

docs(website): pretable docs PR 2 — Grid section (5 pages) + PR 1 cleanup - #61

Merged
blove merged 12 commits into
mainfrom
feat/docs-grid
May 2, 2026
Merged

blove merged 12 commits into
mainfrom
feat/docs-grid

Conversation

@blove

@blove blove commented May 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Ships the Grid section of the pretable docs (5 pages) — the second of four PRs in the docs arc. Also fixes three PR 1 references to a non-existent <PretableGrid> component, extends the docs nav, and promotes useResolvedHeights from internal to public so custom-rendering authors can use it.

What lands

5 new Grid pages under apps/website/app/docs/grid/:

  • page.mdx — Overview: the two consumer paths + [data-pretable-*] attribute contract
  • pretable-component/page.mdx — <Pretable> 3-prop drop-in recipe
  • custom-rendering/page.mdx — usePretableModel recipe with ~80-line working example
  • density-helpers/page.mdx — useResolvedHeights + getDensityHeights reference
  • api-reference/page.mdx — full type reference (PretableColumn, PretableGrid model, snapshots, hooks)

Public API expansion (small, deliberate):

  • useResolvedHeights promoted from internal to public export of @pretable/react. Custom-rendering authors using usePretableModel need it to compute viewport math the same way the built-in surface does.
  • PretableTelemetry added to public type exports for symmetry with the rest of PretableModel.

PR 1 cleanup (the previous docs PR shipped 3 references to a <PretableGrid> component that doesn't exist):

  • apps/website/app/docs/page.mdx — fixed "API Reference" entry; moved Grid out of "Coming soon"
  • apps/website/app/docs/theming/density/page.mdx — removed fictional <PretableGrid rowHeight={56} headerHeight={64} /> example
  • apps/website/app/docs/theming/light-dark/page.mdx — fixed in-prose <PretableGrid> reference

Nav extended from 2 sections to 3: Getting Started, Theming, Grid (5 entries).

Out of scope (deferred to later PRs)

  • Streaming section — PR 3 (1 stub page)
  • Examples gallery — PR 3 (3 example pages)
  • Polish + READMEs — PR 4
  • <Pretable> component API expansion — <Pretable> stays minimal; the hooks remain the escape hatch
  • apps/website/app/components/CodeExample.tsx still uses fictional <PretableGrid> on the landing page (pre-existing, tracked separately)

Test Plan

  • pnpm --filter @pretable/app-website build — 19 static routes prerender, including all 5 new Grid pages
  • pnpm test — 51/51 pass
  • pnpm typecheck — exit 0
  • pnpm exec prettier --check apps/website/app/docs — all files compliant
  • No <PretableGrid> JSX-style references remain in apps/website/app/docs/
  • All forward-references between Grid pages resolve to pages that exist in this PR
  • All hook signatures, type fields, and method signatures in the API reference verified against source (e.g., PretableTelemetry.visibleRowRange is {start, end} numerics)
  • Visual smoke check on Vercel preview deployment

blove and others added 12 commits May 2, 2026 09:03
Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Three PR 1 pages reference a `<PretableGrid>` component that does
not exist. The actual public component is `<Pretable>` (3 props:
rows, columns, getRowId). `PretableGrid` is a TYPE export from
@pretable/core (the internal grid model), not a component.

Three fixes:
- /docs/page.mdx: rename "PretableGrid props" to "Pretable component
  props" in the deferred-section list. Also moves Grid from "Coming
  soon" to a documented section, since this PR ships /docs/grid.
- /docs/theming/density/page.mdx: remove the fictional
  \`<PretableGrid rowHeight={56} headerHeight={64} />\` example. The
  \`<Pretable>\` component does not accept rowHeight/headerHeight
  props. The engine bridge runs via the useResolvedHeights hook
  reading CSS values; consumers who need JS-side numeric overrides
  pass them to the hook directly.
- /docs/theming/light-dark/page.mdx: change one in-prose
  \`<PretableGrid>\` reference to \`<Pretable>\`.

Part 1 of pretable docs PR 2.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Code review on Task 1 of pretable docs PR 2 flagged a leftover
"(PR 2 of the docs)" hedge in the Density page's "Where to go
next" link to /docs/grid/density-helpers. That target ships in
the same PR — the annotation reads stale once merged.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Adds the Grid section to the docs sidebar with 5 entries pointing
at pages that subsequent commits in this PR create:

- Overview (/docs/grid)
- <Pretable> component (/docs/grid/pretable-component)
- Custom rendering (/docs/grid/custom-rendering)
- Density helpers (/docs/grid/density-helpers)
- API reference (/docs/grid/api-reference)

The build passes here because Next.js doesn't validate href
targets at build time.

Part 2 of pretable docs PR 2.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Documents the two consumer paths for @pretable/react:

1. <Pretable> drop-in component (3 props: rows, columns, getRowId).
   Wraps the engine with sensible defaults; basic display only.

2. usePretable / usePretableModel hooks for custom rendering.
   Power-user escape hatch; consumers write their own JSX,
   apply [data-pretable-*] data attributes for styling, wire
   interaction via the grid model.

PretableSurface lives in @pretable-internal/react-surface (private)
and is not part of the public API — bench and website's playground
use it via the internal path; external consumers use the hooks.

Documents the [data-pretable-*] attribute contract that both paths
emit (and that @pretable/ui/grid.css targets), and the two CSS
variables the engine reads in JS (--pretable-row-height,
--pretable-header-height) via useResolvedHeights.

Honest about what's not yet documented: autosize, streaming /
transactions, per-row measured heights.

Part 3 of pretable docs PR 2.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
The useResolvedHeights React hook (subscribes to <html>'s
[data-density] / [data-theme] attribute changes via
MutationObserver and re-resolves --pretable-row-height /
--pretable-header-height) was previously internal to
react-surface and only used by <Pretable> + <PretableSurface>.

Promote it to the public API. Custom-rendering authors using
usePretableModel need it to compute viewport math the same way
the built-in surface does — without it, consumers either copy
the hook source or lose reactivity to density / theme changes.

Also exports the DensityHeights type. Pre-1.0; signature stable.

Pretable docs PR 2 documents this hook as part of the public
custom-rendering surface.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Code review on Task 3 of pretable docs PR 2 flagged three
accuracy issues:

1. Drop "monospace cells" from <Pretable>'s hardcoded defaults.
   The component renders cells as label-above-value spans;
   monospace styling only applies if a theme provides
   --pretable-font-mono. Defaults are now described as
   label-above-value layout + 320px viewport.

2. [data-pretable-wrap] row in the attribute table — the
   attribute is a modifier on the same div that has
   [data-pretable-cell], not a distinct element. Updated
   element column to "each body cell (modifier)" and clarified
   coexistence in the purpose column. Custom-rendering authors
   reading the table to replicate the contract now see correct
   DOM structure.

3. [data-focused] row — the attribute appears on BOTH the row
   and the focused cell, so CSS can target either. Updated
   element column to "focused row + cell" and noted the mirror
   in the purpose column.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Documents the 3-prop drop-in component: columns, rows, getRowId.
Includes a complete code example with PretableColumn typing and
the rendered output's theming via @pretable/ui.

Honest about limitations: no sort UI, no filter UI, no selection
state in component tree, no custom cell rendering, no pinned
columns, no measured-height passthrough. All of those require
custom rendering with usePretable / usePretableModel hooks.

Lists the hardcoded defaults (320px viewport, label/value layout,
sort-direction indicator) so consumers know what they're getting.

Part 4 of pretable docs PR 2.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Documents usePretableModel as the public API for custom grid
rendering. Covers when to use it vs <Pretable> drop-in, the hook
signature, the four return values (grid, snapshot, renderSnapshot,
telemetry), and a minimal-but-complete working example
(~80 lines of JSX).

The example shows: scrollable viewport with [data-pretable-*]
attributes, sticky header with sort-on-click, virtualized body
with absolute-positioned rows, click-to-select wiring via
grid.selectRow + grid.setFocus.

Honest about gaps: keyboard navigation, pinned column sticky
positioning, per-row measured heights, filter inputs, and
telemetry instrumentation are NOT covered in the example —
points readers at packages/react-surface/src/pretable-surface.tsx
in the repo as the canonical reference (private API path, but
readable source).

Part 5 of pretable docs PR 2.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Documents the two functions for reading density values into JS:

- useResolvedHeights (React hook, in @pretable/react): reactive
  via useSyncExternalStore + MutationObserver, optional numeric
  overrides as arguments, fallbacks 32/52, SSR-safe.

- getDensityHeights (vanilla snapshot, in @pretable/ui): same
  read logic without subscription. For non-React utilities or
  one-shot reads.

Includes a when-to-use table comparing the two and a note that
<Pretable> and the internal <PretableSurface> use
useResolvedHeights internally to compute viewport math.

Part 6 of pretable docs PR 2.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Hand-authored type reference for @pretable/react's public API:

- PretableColumn<TRow> field table (id, header, wrap, widthPx,
  pinned, sortable, filterable, getValue)
- PretableRow type alias
- PretableGrid model methods table (getSnapshot, subscribe,
  setSort, setFilter, clearFilters, replaceFilters, selectRow,
  setFocus, moveFocus, setViewport, applyTransaction,
  autosizeColumns)
- PretableGridSnapshot interface
- UsePretableOptions / UsePretableModelOptions interfaces
- PretableModel return type (grid, snapshot, renderSnapshot,
  telemetry)
- PretableRenderSnapshot / PretableRenderRow / PlannedColumn
  interfaces
- PretableTelemetry interface
- Hook signatures: usePretable, usePretableModel,
  useResolvedHeights, measureRenderedRowHeight

Pre-1.0 disclaimer at the top — names may rename in patch
releases.

Part 7 of pretable docs PR 2.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Three issues from the whole-PR final code review:

1. /docs/grid Grid Overview linked to /docs/streaming, which does
   not yet exist (it ships in docs PR 3). The link 404s. Drop the
   href; keep the prose as a forward-reference statement.

2. PretableTelemetry was missing from @pretable/react's public
   type exports despite being part of the documented PretableModel
   shape. Add it to the type-export block (alphabetical) so
   consumers can name-import it like the other model types.

3. /docs/grid/custom-rendering said getPinnedLeftOffsets is
   "re-exported as part of the internal API" — incorrect. The
   helper lives in packages/react-surface/src/rendering.ts and is
   not exported from the package's index. Updated the prose to
   point at the source file directly, matching the existing pattern
   for "see the canonical implementation in pretable-surface.tsx".

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented May 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
pretable Ignored Ignored May 2, 2026 5:13pm

Request Review

@blove
blove enabled auto-merge (squash) May 2, 2026 17:14
@blove
blove merged commit 3507bc8 into main May 2, 2026
10 checks passed
@github-actions

github-actions Bot commented May 2, 2026

Copy link
Copy Markdown
Contributor

Vercel preview ready

Preview: https://pretable-c6v987bpd-cacheplane.vercel.app
Commit: 4939429520d00e95f57d142d649d1aa7a10fac22

Updated automatically by the deploy-preview job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant