Skip to content

Move the table rendering seam behavior (bindQuery + TableRenderer) to @cratis/arc.react #109

Description

@woksin

Background

PR #108 introduced the table rendering seam — TableRenderer<TData> / TableRendererProps<TData> plus bindQuery / bindObservableQuery — and re-expressed DataTableForQuery / DataTableForObservableQuery on top of it. Everything currently lives in @cratis/components/DataTables.

That location is correct for the initial proof, but it is not the ideal long-term home for the behavior half.

Why move

The seam's value is that the UI library is a swappable detail. Today the abstraction that delivers that (TableRenderer + bindQuery) lives inside the PrimeReact library it is meant to abstract away — so consuming bindQuery forces a dependency on @cratis/components and PrimeReact, even for someone who wants a completely different table library.

The binding behavior is the exact analogue of asCommandFormField, which lives in @cratis/arc.react/commands, and it is built on useQueryWithPaging / useObservableQueryWithPaging from @cratis/arc.react/queries. Moving it there would let a Cratis app bind Arc queries to its own table with no PrimeReact dependency, and leave @cratis/components as purely a rendering library — one implementation of the contract, not its owner.

The blocker

bindQuery / bindObservableQuery currently also render TablePaginator (which pulls primereact/button) and the bordered container chrome. @cratis/components depends on @cratis/arc.react (peer dep), never the reverse, so anything that renders the PrimeReact paginator cannot live in arc.react. The behavior and the paginator rendering must be separated first.

Proposed end state

  • @cratis/arc.react owns:
    • TableRenderer / TableRendererProps (pure types, no PrimeReact — could move first, independently).
    • A headless bindQuery / bindObservableQuery that exposes paging state and handlers (page, pageCount, setPage, …) and feeds data to the renderer — no paginator, no chrome.
  • @cratis/components owns:
    • DataTableCore (implements the arc.react TableRenderer contract).
    • TablePaginator and the container chrome.
    • A batteries-included wrapper that composes the headless binding with the paginator, preserving today's DataTableForQuery / DataTableForObservableQuery public API.

Notes

  • Cross-repo change (arc.react ships from the ApplicationModel/Arc repo).
  • Must stay non-breaking: DataTableForQuery / DataTableForObservableQuery public props and behavior are unchanged.
  • Smallest first step, if desired: relocate only the TableRenderer / TableRendererProps contract to arc.react (no circular-dependency issue, since it carries no PrimeReact).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions