Skip to content

feat(codegen-ts-react): UI catalog v0 and component maps with record-admin screen - #714

Merged
dmealing merged 13 commits into
mainfrom
fm/mo-ui-catalog-v0
Dec 5, 2026
Merged

dmealing merged 13 commits into
mainfrom
fm/mo-ui-catalog-v0

Conversation

@dmealing

@dmealing dmealing commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

What Changed

  • Adds UI catalog v0 types in @metaobjectsdev/runtime-web (UI_CATALOG_COMPONENTS, UiCatalogProps, one Ui<Name>Props per component), with @metaobjectsdev/react exporting defaultComponents/UiComponentMap and @metaobjectsdev/tanstack exporting defaultDataGrid. formFile() and tanstackGrid() take a componentMap option; with a map, forms and the grid emit through the app's components.
  • Adds the ejectable recordAdmin() generator (meta eject record-admin) that writes <Entity>.admin.tsx, a list/create/edit screen built from the generated form, grid and hooks, with no map it renders via the default components. TypeScript only, no metamodel vocabulary.
  • Generated-output fixes that ride along: assigned primary keys render editable on create; number inputs submit numbers (numberValueAs); top-level and nested field.currency bind <CurrencyInput>; <CurrencyInput> accepts null, adds onClear, commits on Enter, and uses the locale's money decimal separator (currencyDecimalSeparator); BoundInputProps is a typed shape; a boolean with no view uses Checkbox when a map is set.
Validation

Risk Assessment

⚠️ Medium: I found no new defect, and the last fix correctly requires a defaulted currency amount only on edit, but the change is broad: it adds public client APIs and changes default generated form output.

Testing

Coverage of the two untested scenarios. Neither was driven in a running app; that is deliberate. The unit and golden tests cover both for this PR: currency-input.test.tsx drives <CurrencyInput> (blank, Enter, blur, locale separators), and form-view-dispatch.test.ts plus the ui-catalog.test.ts goldens and strict compile cover the generated form with and without a component map and the record-admin screen. A trial in a real application is the next piece of work, separate from this PR.

Baseline scripts/ci-local.sh --affected --strict-toolchains already passed at the target commit and was not re-run. I re-ran the focused codegen tests (form view dispatch, ui-catalog) and the CurrencyInput runtime tests; all 42 across three files pass. These are unit-level checks, not live drives, so no scenario is marked live. The intended user-facing surfaces (generated form through the component map, record-admin screen, CurrencyInput on blur/Enter) were not exercised end-to-end. The ask-user items from earlier review rounds were all decided, and the fixes are in this branch.

  • Live validation: ⚠️ inconclusive - 0 of 2 scenarios driven live against the product
Scenario Result Live Evidence
Generated form binds top-level currency to CurrencyInput, Enter/blur commits the typed amount (unit: currency-input.test.tsx) ⏸️ untested no Only unit-level tests ran. Not driven live in a browser or against a generated app; the run was too short to build a disposable app.
Catalog-mapped form and record-admin screen generated from a fixture via codegen (unit: ui-catalog.test.ts, form-view-dispatch.test.ts) ⏸️ untested no Tests exercise codegen functions, not the meta gen CLI on a disposable project. Not live.
  • Outcome: ⚠️ 2 warnings across 1 run (5m43s)

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed ✅
  • ⚠️ server/typescript/packages/codegen-ts-react/src/templates/form-file.ts:714 - Round 6 (review-5) fixed the create case but left the edit case it was asked to keep. The recorded decision was: when @default is set, do not require the box on create, but keep required on edit (for example required={props.defaultValues !== undefined}), so a required column still cannot be cleared. The fix (db6c19a) drops required in both modes whenever @default is set. Sequence: edit a row whose currency field has @required: true, @default: 0, clear the box, and blur. Because required is false, CurrencyInput.commit calls onClear, which sets the field to f.onChange(null). UpdateSchema does not make a required column .nullable() (zod-validators.ts:951-953), so Save fails with zod's raw "Expected number, received null" and the box stays empty. The required path would instead revert the box to the stored amount. Nothing is saved wrongly, but the decided behavior is missing. Fix: when @default is set, emit required={props.defaultValues !== undefined} instead of omitting it, and keep the plain required when there is no default. Sibling sites to update: the assertion at codegen-ts-react/test/form-view-dispatch.test.ts:128 (make it assert the edit-only expression), docs/features/ui-catalog.md:90-91 and changelog.d/ts-ui-catalog-v0.md:45-46, which both say such an amount 'is not natively required'.

🔧 Fix applied.
✅ Re-checked - no issues remain.

⚠️ **Test** - 2 warnings
  • ⚠️ No live scenario driven. Only unit-level focused tests ran. Generated form/admin screen via meta gen on a fixture and CurrencyInput in a real browser were not exercised, so end-to-end behavior is unverified.
  • ⚠️ live validation verdict: inconclusive (0 of 2 scenarios were driven live against the product); untested: Generated form binds top-level currency to CurrencyInput, Enter/blur commits the typed amount (unit: currency-input.test.tsx), Catalog-mapped form and record-admin screen generated from a fixture via codegen (unit: ui-catalog.test.ts, form-view-dispatch.test.ts)
  • Live validation: ⚠️ inconclusive - 0 of 2 scenarios driven live against the product
Scenario Result Live Evidence
Generated form binds top-level currency to CurrencyInput, Enter/blur commits the typed amount (unit: currency-input.test.tsx) ⏸️ untested no Only unit-level tests ran. Not driven live in a browser or against a generated app; the run was too short to build a disposable app.
Catalog-mapped form and record-admin screen generated from a fixture via codegen (unit: ui-catalog.test.ts, form-view-dispatch.test.ts) ⏸️ untested no Tests exercise codegen functions, not the meta gen CLI on a disposable project. Not live.
  • scripts/ci-local.sh --affected --strict-toolchains
  • bun test packages/codegen-ts-react/test/form-view-dispatch.test.ts packages/codegen-ts-tanstack/test/ui-catalog.test.ts (in server/typescript): 21 pass, 0 fail, 10 snapshots
  • bun test test/currency-input.test.tsx (in client/web/packages/react): 21 pass, 0 fail
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…reen

The catalog (runtime-web) types what the TypeScript form and grid
generators already emit, plus Page and Panel for a screen. formFile()
and tanstackGrid() take a componentMap option and render through the
app's map; without it their output is byte-identical. react ships
defaultComponents, tanstack ships defaultDataGrid. The new ejectable
recordAdmin() generator writes <Entity>.admin.tsx (list, create, edit)
derived from the generated form, grid and hooks, and falls back to the
default map. TypeScript only; no metamodel vocabulary.

Tests: golden output with and without a map, and a strict typecheck of
the generated client tier against the runtime packages' source.
…and array currency

CurrencyInput writes a focused amount with the separator parseCurrency reads (the locale's
currency decimal, exported as currencyDecimalSeparator), so fr-CH and en-DE amounts are not
reverted or multiplied on blur. formFile() leaves native required off a currency with a
@default and keeps an array currency on the plain control.
…synced, one-bullet changelog fragment

The data-grid fixture declared its primary identity under the id field, where
primaryIdentity() does not find it, so the keyed-only record-admin gate emitted nothing
and both eject contracts failed. The identity now sits on the entity. The examples' owned
zod-validators copies are re-synced with scripts/sync-owned-template-copies.ts, and the
changelog fragment nests its riders under one top-level bullet.
@dmealing
dmealing merged commit feaaab7 into main Dec 5, 2026
11 checks passed
@dmealing
dmealing deleted the fm/mo-ui-catalog-v0 branch December 5, 2026 11:29
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