feat: unify dynamic expression APIs under Expr<T>#127
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Merged
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.
Description
Unifies all dynamic expression APIs under a single
Expr<T>type, replacing the fragmentedDynamicValue,VisibilityCondition, andresolveDynamicValue/evaluateVisibilityhelpers. Introduces inline JS functions as a first-class expression type — the "escape hatch" for non-JSON-serializable schemas requested in #110.Also introduces
FormRegistriesas a unified container for all runtime registries (fields,validators,resolvers,fns), replacing the scatteredregistry,customValidators, andoptionResolversprops. Registry merging is now handled correctly at the framework layer — globalFormProviderregistries are deep-merged with form-level overrides, with form-level keys winning per sub-registry.Key Changes
Core (
form-core)Expr<T>unified expression system replacingDynamicValueandVisibilityCondition$textnode for string interpolation ("Hello ${/firstName}")$when/$then/$elsenode for conditional branching (ternary)$fnnode for calling named functions fromregistries.fnscondition: ({ data, context }) => ...ExprContextwithdataandcontextpropertiesresolveExpras the single evaluation entry pointInferTypefor empty-name primitive arrays to produce flat arraysevaluateVisibility,resolveDynamicValue, and old context typesReact Adapter (
form-react)FormRegistriescontainer forfields,validators,resolvers,fnsregistriesprop toFormProvider,Form,RenderFields,FieldRenderer, anduseFormmergeRegistriesutility — deep per-sub-registry merge, form-level keys override globalregistry,customValidators,optionResolversprops intoregistriesat entry points (FieldRenderer,RenderFields,FormProvider,useForm) — nothing deprecated leaks downstreamFormProviderclobbering outer context whenregistriesisundefinedregistry,customValidators, andoptionResolverstop-level propsDocs / Web (
apps/web)registriesAPIFormProviderin global providers toregistries={{ fields: registry }}form.tsx,array.tsx,collapsible.tsx,tabs.tsx) to useresolveExprandregistriescountry-state-formexample to useregistries.resolversType of change
feat(New feature)fix(Bug fix)refactor(Refactoring code without changing behavior)Related Issues