feat: complex schema support and built-in primitives#110
Merged
Conversation
Extend the form generator from flat z.object() with 5 scalar types to full recursive support for nested objects, arrays, discriminated unions, tuples, records, and intersections. Generated forms now use shadcn-API- compatible pure HTML/React primitives by default -- users swap to real shadcn by passing --ui. Introspection: - Add object, array, union, tuple, record to FieldType - Recursive FieldMetadata for composite types - Intersection flattening (.and() chains merged into single object) - Nullable/nullish unwrapping with isNullable on FieldDescriptor - Pipe/transform transparency (uses input type) - Literal type resolution, z.email()/z.url() format detection Mapping: - Add Fieldset, FieldArray, UnionSwitch component types - 5 new mapping rules for composite types - Recursive resolver attaches child configs via componentProps Codegen: - Recursive JSX builders for nested fields (Card-based grouping) - Array rendering with dynamic add/remove (simple, objects, unions) - Union switch with discriminator Select + conditional fields - Record rendering with key-value pairs - Built-in primitives template matching shadcn component API - Default import from ./primitives when --ui is omitted Stress tested against 11 real-world schemas covering healthcare, e-commerce, finance, HR, real estate, education, logistics, legal, SaaS, insurance, and government tax filing domains. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
b54382c to
5f557be
Compare
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.
Summary
primitives.tsxwith pure HTML/React components matching the shadcn API -- users swap to real shadcn by passing--ui @/components/uiz.nullable(),z.nullish()correctly unwrap withisNullableon field descriptors.check()/.superRefine(),z.email()/z.url()format detection all handledWhat changed
primitives.tstemplate generates shadcn-API-compatible components (Field, Button, Input, Select, RadioGroup, Checkbox, Slider, DatePicker, Card, etc.)--uinow optional; omitting it generates built-in primitives alongside the formStress tested
11 real-world schemas all pass: healthcare patient intake, e-commerce product listing, finance loan application, HR job application, real estate listing (intersection), education enrollment (tuple + record), logistics shipment booking, legal contract intake (branded + pipe), SaaS settings, insurance claims, government tax filing (superRefine + array of unions).
Test plan
Generated with Claude Code