Documentation
¶
Overview ¶
Package authoring provides fluent builders for constructing UISpec PageSpecs programmatically — for server-side page generation, tests, and AI tooling that emits specs rather than framework code. Builders produce plain uispec values; validate the result against a registry before shipping it:
page, err := authoring.NewPage("sales", "Sales Dashboard").
Profile(uispec.ProfileDashboard).
Grid(12, "16px").
Add(authoring.Component("revenue", "analytics.metric").
Span(3, 1).
Prop("title", "Revenue").
Bind("primary", "sales-data", "totalRevenue")).
Build()
if err == nil {
err = reg.ValidatePage(page)
}
Index ¶
- func NavItem(id, label, target string, children ...uispec.NavItem) uispec.NavItem
- func Refresh(target string) uispec.InteractionAction
- func SetState(target, path string, value any) uispec.InteractionAction
- func ToggleState(target, path string) uispec.InteractionAction
- type BindingParam
- type ComponentBuilder
- func (c *ComponentBuilder) At(row, col int) *ComponentBuilder
- func (c *ComponentBuilder) Bind(input, source, operation string, params ...BindingParam) *ComponentBuilder
- func (c *ComponentBuilder) BindState(input, path string, defaultValue any) *ComponentBuilder
- func (c *ComponentBuilder) BindStatic(input string, value any) *ComponentBuilder
- func (c *ComponentBuilder) Child(children ...*ComponentBuilder) *ComponentBuilder
- func (c *ComponentBuilder) Default(input string, value any) *ComponentBuilder
- func (c *ComponentBuilder) Prop(key string, value any) *ComponentBuilder
- func (c *ComponentBuilder) Span(colSpan, rowSpan int) *ComponentBuilder
- func (c *ComponentBuilder) Version(v string) *ComponentBuilder
- func (c *ComponentBuilder) VisibleWhen(condition string) *ComponentBuilder
- type PageBuilder
- func (b *PageBuilder) Add(components ...*ComponentBuilder) *PageBuilder
- func (b *PageBuilder) AppShell(regions ...string) *PageBuilder
- func (b *PageBuilder) Build() (*uispec.PageSpec, error)
- func (b *PageBuilder) Context(key, value string) *PageBuilder
- func (b *PageBuilder) Description(d string) *PageBuilder
- func (b *PageBuilder) Grid(columns int, gap string) *PageBuilder
- func (b *PageBuilder) Layout(layout uispec.LayoutSpec) *PageBuilder
- func (b *PageBuilder) Navigation(navType string, items ...uispec.NavItem) *PageBuilder
- func (b *PageBuilder) OnEvent(componentID, event string, actions ...uispec.InteractionAction) *PageBuilder
- func (b *PageBuilder) Profile(profile string) *PageBuilder
- func (b *PageBuilder) Stack(direction string) *PageBuilder
- func (b *PageBuilder) Theme(id string, tokens map[string]string) *PageBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Refresh ¶
func Refresh(target string) uispec.InteractionAction
Refresh is the component.refresh interaction action: it invalidates the target's data cache so its bindings re-fetch.
func SetState ¶
func SetState(target, path string, value any) uispec.InteractionAction
SetState is the state.set interaction action.
func ToggleState ¶
func ToggleState(target, path string) uispec.InteractionAction
ToggleState is the state.toggle interaction action.
Types ¶
type BindingParam ¶
BindingParam is a named binding parameter; values may be ${...} expressions.
type ComponentBuilder ¶
type ComponentBuilder struct {
// contains filtered or unexported fields
}
ComponentBuilder accumulates a ComponentInstance.
func Component ¶
func Component(id, componentType string) *ComponentBuilder
Component starts a component instance of the given registered type.
func (*ComponentBuilder) At ¶
func (c *ComponentBuilder) At(row, col int) *ComponentBuilder
At places the component at a grid position.
func (*ComponentBuilder) Bind ¶
func (c *ComponentBuilder) Bind(input, source, operation string, params ...BindingParam) *ComponentBuilder
Bind attaches a data binding to a named input. Optional Param values attach binding parameters.
func (*ComponentBuilder) BindState ¶
func (c *ComponentBuilder) BindState(input, path string, defaultValue any) *ComponentBuilder
BindState binds an input to a page-state path with a default value.
func (*ComponentBuilder) BindStatic ¶
func (c *ComponentBuilder) BindStatic(input string, value any) *ComponentBuilder
BindStatic binds an input to an inline literal value.
func (*ComponentBuilder) Child ¶
func (c *ComponentBuilder) Child(children ...*ComponentBuilder) *ComponentBuilder
Child appends child components (for containers like core.card or application.form).
func (*ComponentBuilder) Default ¶
func (c *ComponentBuilder) Default(input string, value any) *ComponentBuilder
Default sets the fallback value on an existing binding.
func (*ComponentBuilder) Prop ¶
func (c *ComponentBuilder) Prop(key string, value any) *ComponentBuilder
Prop sets one property.
func (*ComponentBuilder) Span ¶
func (c *ComponentBuilder) Span(colSpan, rowSpan int) *ComponentBuilder
Span sets the component's grid span.
func (*ComponentBuilder) Version ¶
func (c *ComponentBuilder) Version(v string) *ComponentBuilder
Version pins a compatible component version ("1", "1.2", "1.2.3", "^1.2").
func (*ComponentBuilder) VisibleWhen ¶
func (c *ComponentBuilder) VisibleWhen(condition string) *ComponentBuilder
VisibleWhen sets a visibility condition ("false" or a ${...} expression).
type PageBuilder ¶
type PageBuilder struct {
// contains filtered or unexported fields
}
PageBuilder accumulates a PageSpec.
func NewPage ¶
func NewPage(id, title string) *PageBuilder
NewPage starts a page. The id doubles as metadata.name; apiVersion and kind are set automatically.
func (*PageBuilder) Add ¶
func (b *PageBuilder) Add(components ...*ComponentBuilder) *PageBuilder
Add appends components to the page.
func (*PageBuilder) AppShell ¶
func (b *PageBuilder) AppShell(regions ...string) *PageBuilder
AppShell sets an application-shell layout with the named regions.
func (*PageBuilder) Build ¶
func (b *PageBuilder) Build() (*uispec.PageSpec, error)
Build finalizes the page, returning an error listing every problem the builder itself detected. Registry validation (properties, data inputs, profiles, capabilities) is a separate step: registry.ValidatePage.
func (*PageBuilder) Context ¶
func (b *PageBuilder) Context(key, value string) *PageBuilder
Context adds one page context entry.
func (*PageBuilder) Description ¶
func (b *PageBuilder) Description(d string) *PageBuilder
Description sets metadata.description.
func (*PageBuilder) Grid ¶
func (b *PageBuilder) Grid(columns int, gap string) *PageBuilder
Grid sets a responsive-grid layout.
func (*PageBuilder) Layout ¶
func (b *PageBuilder) Layout(layout uispec.LayoutSpec) *PageBuilder
Layout sets an arbitrary layout for shapes the shortcuts don't cover (split-pane, tabs, application-shell, nested regions).
func (*PageBuilder) Navigation ¶
func (b *PageBuilder) Navigation(navType string, items ...uispec.NavItem) *PageBuilder
Navigation sets the page navigation.
func (*PageBuilder) OnEvent ¶
func (b *PageBuilder) OnEvent(componentID, event string, actions ...uispec.InteractionAction) *PageBuilder
OnEvent appends an interaction rule: when the component emits the event, run the actions in order.
func (*PageBuilder) Profile ¶
func (b *PageBuilder) Profile(profile string) *PageBuilder
Profile sets the experience profile.
func (*PageBuilder) Stack ¶
func (b *PageBuilder) Stack(direction string) *PageBuilder
Stack sets a stack layout. Direction is "vertical" or "horizontal".
func (*PageBuilder) Theme ¶
func (b *PageBuilder) Theme(id string, tokens map[string]string) *PageBuilder
Theme sets the page theme. Token keys must come from the design-token contract (uispec.ValidThemeTokenKeys); Build reports violations.