Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changeset/page-var-source-component-picker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@objectstack/spec': minor
---

feat(spec): page variable `source` renders as a component picker (objectui#2328)

The page metadata form's `variables` repeater now declares explicit sub-fields
and pins `{ field: 'source', widget: 'ref:component' }`. A page variable's
`source` names the component (by `id`) that writes it, so Studio can offer it as
a dropdown of the components actually placed on the page — mirroring how the
sibling `object` field uses `ref:object` — instead of a free-text input the
author has to type an id into by hand. The `ref:component` widget itself lives
in objectui (app-shell metadata-admin); this change is the form-spec trigger.
16 changes: 15 additions & 1 deletion packages/spec/src/ui/page.form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,21 @@ export const pageForm = defineForm({
visibleWhen: "data.type != 'list'",
fields: [
{ field: 'object', widget: 'ref:object', helpText: 'Bound object (for Record pages)' },
{ field: 'variables', type: 'repeater', helpText: 'Local page state variables' },
{
field: 'variables',
type: 'repeater',
helpText: 'Local page state variables',
// Explicit sub-fields so `source` can use the `ref:component` picker —
// a variable's `source` names the component (by `id`) that writes it,
// so it's chosen from the page's real canvas components, not typed by
// hand. Keep in sync with PageVariableSchema.
fields: [
{ field: 'name', required: true, helpText: 'Variable name — exposed to expressions as `page.<name>`' },
{ field: 'type', helpText: 'Value type' },
{ field: 'defaultValue', helpText: 'Initial value (defaults to a type-appropriate empty value)' },
{ field: 'source', widget: 'ref:component', helpText: 'Component (by id) that writes this variable — e.g. an element:record_picker' },
],
},
],
},
{
Expand Down