Skip to content

Commit f4df139

Browse files
committed
feat(types,react,sdui-parser)!: retire the node-level visibleOn / hiddenOn / disabledOn spellings
`@objectstack/spec` declares one conditional-visibility predicate at every layer, `visibleWhen` (ADR-0089); objectui carried `visibleOn`, `hiddenOn` and `disabledOn` beside `visibleWhen`, `hidden` and `disabled`, each pair evaluated by the same code with the same polarity. The three are retired with no alias window. - types: `BaseSchema.visibleOn` / `hiddenOn` / `disabledOn` are `never` on the TypeScript face and `aliasKeyRefusal` tombstones on the Zod mirror, each naming the surviving key; `objectui validate` reads the same mirror. Boolean `visible` stays (the spec declares it on actions, nav entries, tabs, alerts and settings). - react: `SchemaRenderer`'s visibility chain is `visibleWhen` / `visible` (shown when truthy) and `hidden` (hidden when truthy); the enablement gate is `disabled`. A stale retired key is not consulted and is held out of the component's props. - sdui-parser: the three are no longer base props; `validateTree` reports each as an `unknown-prop` naming the canonical key (`checkRetiredVisibilityDialect`, exported). - app-shell: the command palette reads a nav entry's `visible` only. - cli: `objectui check` keeps the three as identification markers, as it keeps `body`. - tests re-pointed or retired; two new pins (zod tombstone + strict face, renderer ignores stale keys); skill and docs teach the surviving keys. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E5XcbmSeZTDGm5zCYkC9XV
1 parent 7111e14 commit f4df139

50 files changed

Lines changed: 781 additions & 415 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
'@object-ui/types': minor
3+
'@object-ui/react': minor
4+
'@object-ui/sdui-parser': minor
5+
'@object-ui/app-shell': patch
6+
---
7+
8+
feat(types,react,sdui-parser,app-shell)!: the node-level `visibleOn` / `hiddenOn` / `disabledOn` spellings are retired; `visibleWhen` / `hidden` / `disabled` are the one predicate each
9+
10+
Clause-②: no (narrowing)
11+
Metadata-protocol: narrowed
12+
13+
<!-- adr-0087: not-required (no-migration-prescription) The three keys are `@object-ui/types` schema members on objectui's own node face, not an `@objectstack/spec` key, object definition, stored row or stored shape: the spec declares `visibleWhen` as the one conditional-visibility predicate at every layer (ADR-0089) and never declared a `*On` suffix on a page component, so the ADR-0087 registries in `packages/spec` have no entry to write and `objectstack migrate meta` has nothing to rewrite. Each old spelling is refused by name on both faces (the TypeScript compiler, the Zod mirror behind `objectui validate`), and the refusal names the surviving key; that is the same disposition the objectui retirements took when the package merged into this repository (maintainer ruling 28 = B on objectstack#25831). The guidance below is for the author of a page, not for a metadata upgrader. The other categories are closed on facts: the four packages publish (not unpublished); no ADR-0087 id is named or touched (not registered or already-registered); and what narrows is a declared schema key on a published metadata face, not a runtime-only interface, a type annotation or a runtime export (not runtime-interface-only, type-surface-only or runtime-export-retired). -->
14+
15+
`@objectstack/spec` declares exactly one conditional-visibility predicate at every layer, `visibleWhen`, and objectui carried three spellings of its own beside it: `visibleOn` beside `visibleWhen`, `hiddenOn` beside `hidden`, `disabledOn` beside `disabled`. Each pair was evaluated by the same code with the same polarity, so the second spelling added a dialect and nothing else. The three are retired, with no alias window.
16+
17+
- **`@object-ui/types`**: `BaseSchema.visibleOn`, `hiddenOn` and `disabledOn` are `never` on the TypeScript face and alias refusals on the Zod mirror. A document that writes one is refused at that key, and the message names the key that survives (`visibleWhen`, `hidden`, `disabled`), says the polarity is the same, and says the value is unchanged. `objectui validate` reads the same mirror, so it prints the same refusal. Boolean `visible` stays: the spec declares it on actions, navigation entries, tabs, alerts and settings, and the renderer keeps evaluating it.
18+
- **`@object-ui/react`**: `SchemaRenderer`'s visibility chain has three legs, `visibleWhen` and `visible` (shown when truthy) and `hidden` (hidden when truthy), and the enablement gate has one, `disabled`. A stale retired key that reaches the renderer unvalidated is not consulted and is held out of the component's props, so it neither gates the node nor lands in the DOM.
19+
- **`@object-ui/sdui-parser`**: the three keys are no longer base props. `validateTree` reports each as an `unknown-prop` diagnostic that names the surviving key, so a TSX tree is told the same thing a JSON document is. `checkRetiredVisibilityDialect` and `RETIRED_VISIBILITY_DIALECTS` are exported for that reading.
20+
- **`@object-ui/app-shell`**: the command palette reads a navigation entry's `visible` only; the `visibleOn` fallback it carried read a key `NavigationItem` never declared.
21+
22+
**BREAKING** (an accept-set narrowing) for any page, view or component document that writes `visibleOn`, `hiddenOn` or `disabledOn` on a node. No shipped example, fixture or skill example in this repository wrote one; the ones in the documentation and the `objectui` skill are rewritten in this change.
23+
24+
- **Before.** The three keys parsed, were evaluated beside their canonical twin, and the docs taught both spellings.
25+
- **Now.** Each is refused by name on `objectui validate`, on the Zod mirror, by the TypeScript compiler and by the SDUI parser, and the renderer does not read it.
26+
- **Fix.** Rename the key and keep the value: `visibleOn` becomes `visibleWhen`, `hiddenOn` becomes `hidden`, `disabledOn` becomes `disabled`. A form field's `fields[].visibleOn` is a different, view-level slot and is unchanged.

‎skills/objectui/guides/schema-expressions.md‎

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ name, so calls are case-insensitive.
236236

237237
### Syntax options
238238

239-
Each condition field has two forms — a shorthand and an `On` suffix:
239+
The node-level condition keys are `visibleWhen` (show), `hidden` and
240+
`disabled`. Each takes a boolean, a `${}` template, or a raw expression:
240241

241242
<!-- os:check -->
242243
```jsonc
@@ -250,10 +251,11 @@ Each condition field has two forms — a shorthand and an `On` suffix:
250251

251252
<!-- os:check -->
252253
```jsonc
253-
{ "hiddenOn": "data.status !== 'active'" } // raw expression (no ${} needed)
254+
{ "hidden": "data.status !== 'active'" } // raw expression (no ${} needed)
254255
```
255256

256-
The `On` variants accept raw expressions without `${}` wrapping — the entire string is the expression.
257+
`visibleOn` / `hiddenOn` / `disabledOn` are retired and refused by name —
258+
rename to `visibleWhen` / `hidden` / `disabled`; the value is unchanged.
257259

258260
### Visibility patterns
259261

@@ -269,12 +271,6 @@ The `On` variants accept raw expressions without `${}` wrapping — the entire s
269271
{ "visible": "${data.record.status === 'active'}" }
270272
```
271273

272-
**Data-dependent:**
273-
<!-- os:check -->
274-
```json
275-
{ "hidden": "${!data.items || data.items.length === 0}" }
276-
```
277-
278274
**Combined conditions:**
279275
<!-- os:check -->
280276
```json
@@ -290,13 +286,13 @@ The `On` variants accept raw expressions without `${}` wrapping — the entire s
290286

291287
<!-- os:check -->
292288
```json
293-
{ "disabledOn": "!data.canPerformAction || data.isLocked" }
289+
{ "disabled": "!data.canPerformAction || data.isLocked" }
294290
```
295291

296292
## Field-level conditional rules (`visibleWhen` / `readonlyWhen` / `requiredWhen`)
297293

298294
These live on the **object's field metadata**, are written in CEL, and are
299-
evaluated by `@objectstack/formula` -- a different tier from the `${}` / `On`
295+
evaluated by `@objectstack/formula` -- a different tier from the node-level
300296
conditions above, which are schema/widget-level and run on the recursive-descent
301297
`SafeExpressionParser`. **How to author them is the `objectstack-data` skill's
302298
job**, under "Conditional Field Rules": the predicate scope, the client-only vs
@@ -641,6 +637,6 @@ When an expression isn't working:
641637
1. **Which key is it on, and does that type declare the key?** `content` and the predicate keys are evaluated and read on every type. `title` / `label` / `value` / `description` are evaluated **only on the types that declare them** — `statistic` (`label` / `value` / `description`), `card` (`title` / `description`), `button` (`label`) — and read raw everywhere else, including on a namespaced spelling such as `ui:statistic`. A `${...}` inside a `props` envelope is evaluated and then discarded. (A `properties` envelope is the one that is evaluated *and* hoisted onto the node — see [`rules/protocol.md`](../rules/protocol.md) for why that is recorded, not recommended.)
642638
2. Is the `${}` syntax correct? Check for unmatched braces.
643639
3. Is the data actually available in scope? Check what the host published on `PredicateScopeProvider` — ⛔ not `SchemaRendererProvider`'s `dataSource`, which publishes no expression root.
644-
4. For conditions: are you using `On` suffix correctly? (`hiddenOn` takes raw expression, `hidden` needs `${}` if it's a string).
640+
4. For conditions: `visibleWhen` / `hidden` / `disabled` take a raw expression or a `${}` template; the `On` spellings are refused.
645641
5. Does the expression use a blocked pattern? Check for constructors, `eval`, `window`, etc.
646642
6. Is type coercion causing issues? `${0 && "yes"}` returns `0`, not `false`.

‎skills/objectui/rules/protocol.md‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,15 @@ value must clear before it reaches the screen.
1313
| Field | Evaluation Type | Return Type | Example |
1414
|---|---|---|---|
1515
| `content` | Template (`${}`) | string | `"content": "Total: ${data.total}"` |
16-
| `hidden` | Condition | boolean | `"hidden": "${data.status !== 'active'}"` |
17-
| `hiddenOn` | Condition | boolean | `"hiddenOn": "data.status === 'draft'"` |
16+
| `visibleWhen` | Condition | boolean | `"visibleWhen": "data.permissions.canView"` (raw expression, no `${}`) |
17+
| `hidden` | Condition | boolean | `"hidden": "data.status === 'draft'"` |
1818
| `visible` | Condition | boolean | `"visible": "${data.isActive}"` |
19-
| `visibleOn` | Condition | boolean | `"visibleOn": "data.permissions.canView"` |
20-
| `disabled` | Condition | boolean | `"disabled": "${form.isSubmitting}"` |
21-
| `disabledOn` | Condition | boolean | `"disabledOn": "!data.hasPermission"` |
19+
| `disabled` | Condition | boolean | `"disabled": "!data.hasPermission"` |
2220
| `title` / `label` / `value` / `description` | Template (`${}`) | Preserves original type | **Only on the component types the spec declares** — see "Rule: Bindable Text Keys" below. `"value": "${data.total}"` on a `statistic` renders the number. |
2321
| `properties.*` | Template (`${}`) | Preserves original type | Evaluated, then **hoisted onto the node** (`type` / `id` excepted), so the result lands where every renderer reads. See "Rule: Keys Live on the Node" below. |
2422
| `props.*` | Template (`${}`) | Preserves original type | Evaluated, then spread as **React props** — a `ui:*` / `page:*` renderer reads `schema.*` and never sees the result. Consumed only by `element:*` components. |
2523

26-
**Precedence rule:** `visible` takes priority over `hidden`.
24+
**Precedence rule:** `visible` takes priority over `hidden`. `visibleOn` / `hiddenOn` / `disabledOn` are retired: `objectui validate` refuses them by name, pointing at `visibleWhen` / `hidden` / `disabled`.
2725

2826
### Fields That are NOT Evaluated
2927

@@ -111,8 +109,8 @@ as React props (`packages/react/src/SchemaRenderer.tsx`), which those renderers
111109
ignore. A key parked under `props` is therefore dropped: the component renders
112110
an empty frame, and the envelope itself lands in the DOM as the invalid
113111
attribute `props="[object Object]"`. Silent for every key except the node-gate
114-
predicates (`visibleWhen` / `visible` / `visibleOn` / `visibility` / `hidden` /
115-
`hiddenOn` / `disabled` / `disabledOn`), which are refused by name on the
112+
predicates (`visibleWhen` / `visible` / `hidden` / `disabled`, and their
113+
retired spellings), which are refused by name on the
116114
console, with the migration, instead of gating nothing.
117115

118116
**❌ WRONG — renders an empty card:**

‎ui/content/docs/api/schema-reference.md‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,8 @@ All schema types extend `BaseSchema`. These shared properties are available on e
7070
"description": "A container element",
7171
"className": "p-4 bg-white rounded-lg",
7272
"visible": true,
73-
"visibleOn": "${data.showWrapper}",
74-
"disabled": false,
75-
"disabledOn": "${data.isLocked}",
73+
"visibleWhen": "${data.showWrapper}",
74+
"disabled": "${data.isLocked}",
7675
"testId": "wrapper-element",
7776
"ariaLabel": "Content wrapper",
7877
"children": []
@@ -96,12 +95,12 @@ One row per declared member, in declaration order, so the list can be checked ag
9695
| `body` | *retired* | ⛔ Refused by name (objectui#6771). `body` was a second child-list spelling `BaseSchema` declared beside `children`; it is now `never` on the TypeScript face and an alias refusal on the Zod mirror, and the refusal names `children`. |
9796
| `children` | `SchemaNode \| SchemaNode[]` | Child components rendered inside this component — the child-list key, and since objectui#6771 the only one. Whether a given node type renders a child list at all is still per component; see the note below. The keys OTHER than this one through which a renderer hands nodes to `SchemaRenderer` (a dialog's `trigger`, a tab item's `content`, a page's `regions[].components`) are per type and declared once as `NODE_SLOT_DECLARATIONS` / `nodeSlotsFor` (objectui#11170); `objectui check`, the core schema validator and the SDUI parser walk those positions as they walk `children`. |
9897
| `visible` | `boolean \| string \| { dialect?: string; source: string }` | Visibility control. Accepts a boolean, a predicate expression string, **or** the CEL envelope object (`{ dialect: 'cel', source }` — what `objectstack build` emits for every authored predicate) — the renderer evaluates this key rather than reading it as a boolean. The string-or-envelope half is `ExpressionWire`, the one wire type `visibleWhen` on form fields already carries. |
99-
| `visibleWhen` | `string \| { dialect, source }` | Canonical conditional-visibility predicate (ADR-0089); the element is shown when it evaluates truthy. Typed as `@objectstack/spec`'s `EvaluatedExpressionInput`: a predicate string, or the envelope the spec's parse writes (`dialect` is `cel`, `cron` or `template`, and `source` is not blank). Evaluated **before** `visible` and `visibleOn`, and outranks both. |
100-
| `visibleOn` | `string` | Expression for conditional visibility. **Deprecated** (ADR-0089) — use `visibleWhen`. |
101-
| `hidden` | `boolean \| string \| { dialect?: string; source: string }` | Inverse of `visible` — the node is not rendered. Accepts a boolean, a predicate expression string **or** the CEL envelope object (`ExpressionWire`), which the renderer evaluates rather than reading as a boolean; `hiddenOn` remains the sibling spelling. |
102-
| `hiddenOn` | `string` | Expression for conditional hiding. |
98+
| `visibleWhen` | `string \| { dialect, source }` | Canonical conditional-visibility predicate (ADR-0089); the element is shown when it evaluates truthy. Typed as `@objectstack/spec`'s `EvaluatedExpressionInput`: a predicate string, or the envelope the spec's parse writes (`dialect` is `cel`, `cron` or `template`, and `source` is not blank). Evaluated **before** `visible`, and outranks it. |
99+
| `visibleOn` | *retired* | ⛔ Refused by name. `visibleOn` was objectui's own spelling of `visibleWhen`; it is `never` on the TypeScript face and an alias refusal on the Zod mirror, and the refusal names `visibleWhen` (same predicate, same polarity). |
100+
| `hidden` | `boolean \| string \| { dialect?: string; source: string }` | Inverse of `visible` — the node is not rendered. Accepts a boolean, a predicate expression string **or** the CEL envelope object (`ExpressionWire`), which the renderer evaluates rather than reading as a boolean. |
101+
| `hiddenOn` | *retired* | ⛔ Refused by name; the refusal names `hidden` (same predicate, same polarity). |
103102
| `disabled` | `boolean \| string \| { dialect?: string; source: string }` | Disabled state. Accepts a boolean, a predicate expression string **or** the CEL envelope object (`ExpressionWire`), on the same evaluated path as `visible`. |
104-
| `disabledOn` | `string` | Expression for conditional disabling. |
103+
| `disabledOn` | *retired* | ⛔ Refused by name; the refusal names `disabled` (same predicate, same polarity). |
105104
| `testId` | `string` | Test identifier, rendered as `data-testid`. |
106105
| `ariaLabel` | `string \| KeyedI18nLabel` | Accessibility label, rendered as `aria-label`. `KeyedI18nLabel` is the **keyed** form (`{ key, defaultValue?, params? }`), resolved by `resolveKeyedI18nLabel` — **not** the `I18nLabel` that `label` and `description` carry. The two are structurally confusable and each returns nothing useful for the other's input. |
107106

@@ -1439,6 +1438,6 @@ import type { BaseSchema, SchemaNode } from '@object-ui/types';
14391438

14401439
- **[Schema Overview](/docs/guide/schema-overview)** — High-level guide to ObjectUI schemas
14411440
- **[Quick Start](/docs/guide/quick-start)** — Build your first ObjectUI application
1442-
- **[Expressions](/docs/guide/expressions)** — Dynamic expressions with `visibleOn`, `disabledOn`
1441+
- **[Expressions](/docs/guide/expressions)** — Dynamic expressions with `visibleWhen`, `hidden`, `disabled`
14431442
- **[Fields Guide](/docs/guide/fields)** — Deep dive into form fields
14441443
- **[Plugin Development](/docs/guide/plugin-development)** — Build custom schema renderers

‎ui/content/docs/guide/expressions.md‎

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Supported: `>`, `<`, `>=`, `<=`, `==`, `===`, `!=`, `!==`
120120
```json
121121
{
122122
"type": "button",
123-
"visibleOn": "${user.isAdmin && user.isActive}"
123+
"visibleWhen": "${user.isAdmin && user.isActive}"
124124
}
125125
```
126126

@@ -137,38 +137,44 @@ Supported: `&&`, `||`, `!`
137137

138138
## Conditional Properties
139139

140-
### visibleOn
140+
The node-level condition keys are `visibleWhen`, `hidden` and `disabled`. The
141+
`visibleOn` / `hiddenOn` / `disabledOn` spellings are retired: `objectui validate`
142+
refuses them by name and points at the surviving key (same predicate, same
143+
polarity — rename the key, the value is unchanged). A form field's `fields[].visibleOn`
144+
is a different, view-level slot and is unaffected.
145+
146+
### visibleWhen
141147

142148
Show component when expression is true:
143149

144150
```json
145151
{
146152
"type": "button",
147153
"label": "Admin Panel",
148-
"visibleOn": "${user.role === 'admin'}"
154+
"visibleWhen": "${user.role === 'admin'}"
149155
}
150156
```
151157

152-
### hiddenOn
158+
### hidden
153159

154160
Hide component when expression is true:
155161

156162
```json
157163
{
158164
"type": "section",
159-
"hiddenOn": "${user.settings.hideSection}"
165+
"hidden": "${user.settings.hideSection}"
160166
}
161167
```
162168

163-
### disabledOn
169+
### disabled
164170

165171
Disable component when expression is true:
166172

167173
```json
168174
{
169175
"type": "button",
170176
"label": "Submit",
171-
"disabledOn": "${record.status === 'submitted'}"
177+
"disabled": "${record.status === 'submitted'}"
172178
}
173179
```
174180

@@ -350,7 +356,7 @@ Available: All standard `Math` functions
350356
```json
351357
{
352358
"type": "alert",
353-
"visibleOn": "${(user.role === 'admin' || user.role === 'moderator') && user.isActive && !user.isSuspended}"
359+
"visibleWhen": "${(user.role === 'admin' || user.role === 'moderator') && user.isActive && !user.isSuspended}"
354360
}
355361
```
356362

@@ -387,7 +393,7 @@ type and stay expressions:
387393
"type": "badge",
388394
"label": "Completed",
389395
"variant": "secondary",
390-
"visibleOn": "${status !== 'draft'}"
396+
"visibleWhen": "${status !== 'draft'}"
391397
}
392398
```
393399

@@ -409,7 +415,7 @@ Two neighbouring traps: `text` is not a `badge` key at all — the badge's text
409415
```json
410416
{
411417
"type": "empty",
412-
"visibleOn": "${items.length === 0}",
418+
"visibleWhen": "${items.length === 0}",
413419
"title": "No items to display",
414420
"description": "Start by adding your first item"
415421
}
@@ -427,7 +433,7 @@ the condition keys are evaluated on every type and stay expressions:
427433
"type": "progress",
428434
"value": 75,
429435
"label": "75% complete",
430-
"visibleOn": "${total > 0}"
436+
"visibleWhen": "${total > 0}"
431437
}
432438
```
433439

@@ -443,7 +449,7 @@ or author each variant and gate it with a condition key:
443449
"type": "card",
444450
"title": "${task.name}",
445451
"className": "border-red-500 border-2",
446-
"visibleOn": "${task.isPriority}"
452+
"visibleWhen": "${task.isPriority}"
447453
}
448454
```
449455

@@ -478,7 +484,7 @@ row:
478484
"name": "state",
479485
"type": "select",
480486
"label": "State/Province",
481-
"visibleOn": "${record.country === 'USA'}",
487+
"visibleWhen": "${record.country === 'USA'}",
482488
"options": [
483489
{ "label": "CA", "value": "CA" },
484490
{ "label": "NY", "value": "NY" },
@@ -660,7 +666,7 @@ language's own. A membership test is written with the array method:
660666
```json
661667
{
662668
"type": "button",
663-
"visibleOn": "${user.permissions.includes('admin')}"
669+
"visibleWhen": "${user.permissions.includes('admin')}"
664670
}
665671
```
666672

@@ -690,15 +696,15 @@ language's own. A membership test is written with the array method:
690696

691697
```json
692698
{
693-
"visibleOn": "${x && y || z}"
699+
"visibleWhen": "${x && y || z}"
694700
}
695701
```
696702

697703
✅ Good
698704

699705
```json
700706
{
701-
"visibleOn": "${isAdmin && isActive || isSuperUser}"
707+
"visibleWhen": "${isAdmin && isActive || isSuperUser}"
702708
}
703709
```
704710

0 commit comments

Comments
 (0)