widgets

package
v0.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WidgetToggle     = "toggle"
	WidgetSelect     = "select"
	WidgetChips      = "chips"
	WidgetCodeEditor = "code-editor"
	WidgetJSONEditor = "json-editor"
	WidgetKeyValue   = "key-value"
)

Built-in widget identifiers exposed by the registry.

Variables

This section is empty.

Functions

This section is empty.

Types

type Matcher

type Matcher func(field model.Field) bool

Matcher decides whether a widget renderer should handle the supplied field.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry selects widget renderers for fields based on explicit hints or registered matchers. Higher priority wins; ties fall back to registration order. An empty registry never resolves a widget.

func NewRegistry

func NewRegistry() *Registry

NewRegistry constructs a registry with the built-in widget matchers registered.

func (*Registry) Decorate

func (r *Registry) Decorate(form *model.FormModel) error

Decorate implements model.Decorator, applying registry resolution to every field in the form. When a widget is resolved, both Metadata["widget"] and UIHints["widget"] are set to the chosen name, preserving existing values when present.

func (*Registry) Register

func (r *Registry) Register(name string, priority int, matcher Matcher)

Register adds a widget matcher with the provided name and priority. Higher priority values take precedence. Callers should avoid duplicate names; the latest registration wins during resolution.

func (*Registry) Resolve

func (r *Registry) Resolve(field model.Field) (string, bool)

Resolve returns the widget name for a field. Explicit hints (admin/widget metadata or UI hints) are honoured before matcher evaluation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL