Skip to content

Commit ddc2bad

Browse files
os-zhuangclaude
andauthored
feat(spec): page variable source renders as a component picker (objectui#2328) (#2968)
The page form's `variables` repeater now declares explicit sub-fields and pins `{ field: 'source', widget: 'ref:component' }` so Studio can pick a page variable's `source` (the component that writes it) from the page's real components instead of a free-text id — mirroring the sibling `object` `ref:object` picker. The `ref:component` widget ships in objectui. Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 4e195a5 commit ddc2bad

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@objectstack/spec': minor
3+
---
4+
5+
feat(spec): page variable `source` renders as a component picker (objectui#2328)
6+
7+
The page metadata form's `variables` repeater now declares explicit sub-fields
8+
and pins `{ field: 'source', widget: 'ref:component' }`. A page variable's
9+
`source` names the component (by `id`) that writes it, so Studio can offer it as
10+
a dropdown of the components actually placed on the page — mirroring how the
11+
sibling `object` field uses `ref:object` — instead of a free-text input the
12+
author has to type an id into by hand. The `ref:component` widget itself lives
13+
in objectui (app-shell metadata-admin); this change is the form-spec trigger.

packages/spec/src/ui/page.form.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,21 @@ export const pageForm = defineForm({
5252
visibleWhen: "data.type != 'list'",
5353
fields: [
5454
{ field: 'object', widget: 'ref:object', helpText: 'Bound object (for Record pages)' },
55-
{ field: 'variables', type: 'repeater', helpText: 'Local page state variables' },
55+
{
56+
field: 'variables',
57+
type: 'repeater',
58+
helpText: 'Local page state variables',
59+
// Explicit sub-fields so `source` can use the `ref:component` picker —
60+
// a variable's `source` names the component (by `id`) that writes it,
61+
// so it's chosen from the page's real canvas components, not typed by
62+
// hand. Keep in sync with PageVariableSchema.
63+
fields: [
64+
{ field: 'name', required: true, helpText: 'Variable name — exposed to expressions as `page.<name>`' },
65+
{ field: 'type', helpText: 'Value type' },
66+
{ field: 'defaultValue', helpText: 'Initial value (defaults to a type-appropriate empty value)' },
67+
{ field: 'source', widget: 'ref:component', helpText: 'Component (by id) that writes this variable — e.g. an element:record_picker' },
68+
],
69+
},
5670
],
5771
},
5872
{

0 commit comments

Comments
 (0)