Repository navigation
feat(codegen-ts-react): UI catalog v0 and component maps with record-admin screen - #714
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
@metaobjectsdev/runtime-web(UI_CATALOG_COMPONENTS,UiCatalogProps, oneUi<Name>Propsper component), with@metaobjectsdev/reactexportingdefaultComponents/UiComponentMapand@metaobjectsdev/tanstackexportingdefaultDataGrid.formFile()andtanstackGrid()take acomponentMapoption; with a map, forms and the grid emit through the app's components.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.numberValueAs); top-level and nestedfield.currencybind<CurrencyInput>;<CurrencyInput>acceptsnull, addsonClear, commits on Enter, and uses the locale's money decimal separator (currencyDecimalSeparator);BoundInputPropsis a typed shape; a boolean with no view usesCheckboxwhen a map is set.Validation
Risk Assessment
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.tsxdrives<CurrencyInput>(blank, Enter, blur, locale separators), andform-view-dispatch.test.tsplus theui-catalog.test.tsgoldens 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-toolchainsalready 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.meta genCLI on a disposable project. Not live.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@defaultis set, do not require the box on create, but keeprequiredon edit (for examplerequired={props.defaultValues !== undefined}), so a required column still cannot be cleared. The fix (db6c19a) dropsrequiredin both modes whenever@defaultis set. Sequence: edit a row whose currency field has@required: true, @default: 0, clear the box, and blur. Becauserequiredis false,CurrencyInput.commitcallsonClear, which sets the field tof.onChange(null).UpdateSchemadoes 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@defaultis set, emitrequired={props.defaultValues !== undefined}instead of omitting it, and keep the plainrequiredwhen 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.
meta genon a fixture and CurrencyInput in a real browser were not exercised, so end-to-end behavior is unverified.meta genCLI on a disposable project. Not live.scripts/ci-local.sh --affected --strict-toolchainsbun 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 snapshotsbun 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.