Files
zeekay 4f667b29cc data: an inline editor sits on its own row; @hanzo/data 1.4.5
A cell's editor drew its box a row-height low, over the row beneath, with its focus outline. The editor's wrapper took flex-basis 0 in a column (flex={1}), so its height was 0 and the field overflowed it. It fills the width instead.

Claude-Session: https://claude.ai/code/session_016DKtyx91ThZ9W9i2YVxyif
2026-11-01 23:59:40 -08:00
..

@hanzo/data

Cross-platform, metadata-driven data-app components for any Hanzo Base-backed app — CRM, CMS, commerce, or a one-off internal tool. One model (typed fields → records → views) renders everywhere, on web, native (iOS), and desktop, because it's built on @hanzo/gui and drawn with @hanzo/ui's record kit — table ⇆ board, filter, sort, group, inline edit, saved views.

An object is a set of typed fields. A record is values for those fields. Every view — table, board, detail — renders from that one model, dispatched through a registry, so adding a field type is one registration, never a switch edit. A business app (CRM/CMS/ERP) is just a curated set of views over these components.

Install

bun add @hanzo/data @hanzo/ui @hanzo/gui

@hanzo/ui, @hanzo/gui and react are peers. Mount it under <Hanzo> (the @hanzo/ui root) and the cells, cards and editors follow the theme. Wrap a record surface in <Density value="compact"> for the record density: 32px rows and controls, an 8px gutter, 13px text; without it the table keeps 44px rows and the editors the kit's 36px.

The flagship: RecordsView

One shell turns any collection into a record surface — a toolbar (view switch, search, filter builder, sort builder, board group-by) over a DataTable or a BoardView, driven by a single ViewConfig. Presentational + data-injected: the host supplies raw records and the persistence callbacks; the view owns interaction state.

import { RecordsView, type FieldDefinition } from '@hanzo/data'

<RecordsView
  fields={fields}
  records={records}                              // raw rows; the view applies search + filter + sort
  onOpen={openDetail}                            // expand a record
  onEditCommit={(rec, field, value) => save(rec, field, value)}  // inline cell / board edit
  onCreate={createRecord}
  savedViews={{ views, activeId, onSelect, onSave, onDelete, deletable }}  // optional named views; deletable(id) keeps built-ins
/>
  • DataTable — click-to-sort headers, drag-resize + drag-reorder columns, row selection with a header select-all, inline cell editing (the field's own editor), pagination, hover-reveal open, honest empty/loading.
  • BoardView — kanban grouped by a select/status/boolean/relation field; drag a card to another lane and the record patch is emitted (optimistic, reverts on failure).
  • RecordDetail — a titled panel of fields, optionally inline-editable, with a related slot. RecordForm — the create/edit form.

A view's rules combine by match: and (every rule, the default) or or (any one); the word between two rules switches it. Numbers, money and dates also filter between two values, either end left open, and a range that ends on a day takes that day whole.

A server's page. For a collection too large to hold, the host runs the view as its query and passes the one page it got back with remote: the records are shown as given, never re-filtered, and the pager reads the total.

<RecordsView
  fields={fields}
  records={page.items}                                       // already searched, filtered, sorted
  view={view}
  onViewChange={setView}                                     // the host re-queries on every change
  remote={{ page: page.page, total: page.total, onPage: setPageNumber }}
/>

Field types

text · longText · number · percent · currency · boolean · select · multiSelect · date · dateTime · email · url · links · phone · rating · relation · json · uuid · fullName · address · files · richText · position · actor

Each type has a read Display and (where editable) an Input, resolved by the registry, both from @hanzo/ui's record kit: a select is a Tag in its option's colour (thirty data hues, TagColor) and its editor a searchable menu with a "No …" row; several values are one line of tags or pills with a +N; emails, links and phones are pills with their mailto / https / tel target; a relation is a record chip with an Avatar; a currency is an amount with a currency picker at its start; a phone a number with a calling-code picker; a date the kit's calendar under a typed day; a rating a row of stars. Enter commits an edit, Escape cancels it.

Extend

Register a renderer for any type — built-in or custom — and it works in every view:

import { registerField } from '@hanzo/data'

registerField('rating', { Display: MyStars, Input: MyStarPicker })

Pure logic (host-usable, tested)

The sort / filter / search / group / view helpers are pure and exported (also on subpaths @hanzo/data/{table,board,view}/logic so a Node host can import them with no gui runtime):

import { applyView, sortRecords, filterRecords, boardColumns } from '@hanzo/data'

Surface

  • Model — FieldDefinition, FieldType, FieldMetadata, SelectOption, TagColor, CurrencyValue, LinkValue, AddressValue, FullNameValue, ActorValue
  • Lists — regions(), currencies() (from Intl, in the reader's language), CALLING (E.164 calling codes)
  • Views — RecordsView, DataTable, BoardView, RecordDetail, RecordForm, RecordCard, RecordsToolbar
  • Primitives — Menu, MenuItem, CheckBox, Toggle, Calendar
  • Routers / Registry — FieldDisplay, FieldInput, isEditable, registerField, getFieldRenderers
  • Logic — applyView, sortRecords, filterRecords, searchRecords, paginate, boardColumns, movePatch, operatorsForType, emptyView, describeView, …
  • Theme — TAG_TONES, tagTone (the data palette's tag pairs as custom properties); tokens (the old fixed dark palette, kept for callers)

MIT · Hanzo AI — see LICENSE.md. HIP-0137 (hanzoai/hips).