feat(react,types): read canonical visibleWhen in renderers (ADR-0089)#2490
Merged
Conversation
`@objectstack/spec` unifies conditional visibility under the canonical key `visibleWhen`, folding the deprecated `visibleOn` (view form) / `visibility` (page component) aliases into it at parse. Update ObjectUI to read the canonical key: - SchemaRenderer (page): evaluate `visibleWhen` first (show-when-truthy), keep `visibleOn`/`visibility` as defensive reads for raw metadata; strip `visibleWhen` from DOM props. - spec-bridge: page bridge maps `visibleWhen ?? visibility` → node `visibleWhen`; form-view bridge maps `visibleWhen ?? visibleOn` → the ObjectForm view-level predicate slot. - react FormRenderer: prefer `visibleWhen` over the `visibleOn` alias. - types: component base (`BaseSchema` / `base.zod`) gains canonical `visibleWhen`; `visibleOn` marked `@deprecated`. Fully back-compat: existing `visibleOn`/`visibility` metadata keeps working via the alias reads. Addresses objectstack-ai/framework#2904. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017fU25GeYSPKq9eEURsQffF
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
4 tasks
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
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.
Companion to framework ADR-0089 — implements the "Renderer reads" task, objectstack-ai/framework#2904. Pairs with the spec-side PR objectstack-ai/framework#2900.
Why
@objectstack/specnow unifies conditional visibility under a single canonical key,visibleWhen, and folds the deprecatedvisibleOn(view form section/field) /visibility(page component) aliases into it at parse. Any metadata parsed through the spec schemas therefore exposes onlyvisibleWhen. The ObjectUI renderers previously readvisibleOn/visibility, so a normalized page component would have rendered unconditionally. This makes the renderers read the canonical key.Changes
SchemaRenderer) — evaluatesvisibleWhenfirst (show-when-truthy), then the deprecatedvisibleOn/visibilityas a defensive read for raw / un-normalized metadata.visibleWhenis stripped from DOM props.visibleWhen ?? visibilityonto the node's canonicalvisibleWhen; the form-view bridge maps a field'svisibleWhen ?? visibleOnonto the ObjectForm view-level predicate slot.@object-ui/reactFormRenderer— prefersvisibleWhenover thevisibleOnalias (both the visibility eval and the "has conditional fields" watch guard).ObjectForm/form.tsxalready evaluatedvisibleWhenviaresolveFieldRuleState.@object-ui/types— the component base (BaseSchema+base.zod) gains the canonicalvisibleWhen;visibleOnis marked@deprecated.Back-compat
Fully back-compat — existing
visibleOn/visibilitymetadata keeps working through the alias reads. No authored metadata needs to change.Tests
New coverage for the canonical
visibleWhenpath inSchemaRenderer.expressions.test.tsx(+ deprecated-alias regression) and the page/form bridges (SpecBridge.test.ts). Full suites green:@object-ui/react(5823 passed, 24 network-integration tests skipped),@object-ui/componentsform (503),@object-ui/types;tsc --noEmitclean across react + types. Includes aminorchangeset.🤖 Generated with Claude Code
https://claude.ai/code/session_017fU25GeYSPKq9eEURsQffF
Generated by Claude Code