Initial release: personal-records primitives

RecordCard / RecordGroupSection / TierBadge / RecordKindIcon, FieldTable
+ spec-driven FieldInputs + KeyValueEditor, the marquee RecordsEmpty,
renderRecordMd (mirror of the personal cloud's server renderer), and
parseMrzTd3 — a fully-local TD3 passport MRZ parser with check-digit
verification (validated against the ICAO Doc 9303 specimen).

Token-themed; lucide-react is the only dep (Crema shared-dep aliasing).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
jules
2026-06-11 18:42:51 +10:00
commit b5ccdbe903
2 changed files with 692 additions and 0 deletions

45
README.md Normal file
View File

@@ -0,0 +1,45 @@
# @crema/records-ui
Personal-records primitives for the personal cloud's Records surface
(arcadia-personal-cloud `docs/RECORDS.md`): kind-typed record cards, group
sections with privacy framing, field tables and spec-driven field inputs,
tier badges, the record→Markdown renderer, and a TD3 passport MRZ parser.
This lib ships **shapes and pure logic**, not data fetching. The app owns
the API client, the passkey doc-vault crypto, and flow orchestration; this
lib renders records and parses/renders their field structures.
## Public API
```tsx
import {
RecordCard, RecordGroupSection, TierBadge, RecordKindIcon,
FieldTable, FieldInputs, KeyValueEditor, RecordsEmpty,
renderRecordMd, parseMrzTd3,
type RecordKindInfo, type FieldSpec, type RecordTier,
} from "@crema/records-ui"
// Group section with the locked-group privacy framing
<RecordGroupSection label="Identity" locked>
<RecordCard record={summary} icon="passport" onClick={open} />
</RecordGroupSection>
// Read view of fields (registry order, blanks skipped)
<FieldTable fields={kind.fields} data={record.data} />
// Spec-driven add/edit inputs; KeyValueEditor for free-form `other`
<FieldInputs fields={kind.fields} values={draft} onChange={set} />
// The Markdown the assistant consumes (mirror of the server renderer)
const md = renderRecordMd("Passport", "My passport", kind.fields, data)
// Fully-local passport MRZ parse (two 44-char lines, check digits verified)
const mrz = parseMrzTd3(pastedText)
```
Field specs come from the backend registry (`GET /me/records/kinds`) —
this lib defines the types and rendering, never the vocabulary.
Token-themed throughout (`bg-card`, `text-muted-foreground`, `--primary`);
no hex values. `lucide-react` is the only dependency (a Crema shared dep —
consumers alias it to their installed copy).