widget

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 1 Imported by: 0

README

tinywasm/widget

Visual component contracts, states, layout, and styling for the tinywasm suite.

Documentation

Documentation

Index

Constants

View Source
const (
	PartLabel      = Part("label")
	PartInput      = Part("input")
	PartError      = Part("error")
	PartRadioGroup = Part("radio-group")
)

Parts of the field. The names are generic by design: Part is local to its widget and only becomes a class through a Name, so "label" here produces "tw-field__label" and never collides with the "label" of another widget.

View Source
const NameField = Name("tw-field")

NameField is the shared anatomy of the form field.

It is emitted by github.com/tinywasm/form (which builds the markup) and styled by github.com/tinywasm/components/fieldset (which is the global skin of the forms). It lives here because it crosses the boundary between these two libraries, and neither can own it without the other depending on it.

Variables

This section is empty.

Functions

This section is empty.

Types

type Class

type Class string

Class es un nombre de clase CSS. NO tiene constructor público: la única forma de obtener una es derivarla de un Name. Escribir Class("lo-que-sea") no compila fuera de este paquete.

func (Class) AsAttr

func (c Class) AsAttr() fmt.KeyValue

func (Class) String

func (c Class) String() string

type Cue

type Cue uint8

Cue es un estado que posee el NAVEGADOR. Solo se estiliza; no se puede escribir desde Go — por eso es un tipo distinto y no tiene Attr().

const (
	Hover Cue = iota
	Focus
	Press
	Target
)

type Dismissible

type Dismissible interface{ Dismiss() }

type Expandable

type Expandable interface{ Expand(open bool) }

type Kind

type Kind uint8

Kind es el tipo de widget según WAI-ARIA Authoring Practices. Determina el rol, los estados válidos y el teclado esperado. Cerrado a propósito: si un widget no encaja en ninguno, casi siempre es que son dos widgets.

const (
	Region     Kind = iota // contenedor sin semántica de interacción
	Listbox                // targetlist
	Menu                   // el menú ⋮
	Dialog                 // modaldialog
	Disclosure             // <details> desplegable
	Tabs
	Toolbar
	Grid
	Combobox
	Form
	Alert // toasts de platformd
)

type Name

type Name string

Name identifica un widget. Es el prefijo de TODA clase que emite, así que dos widgets no pueden colisionar aunque elijan el mismo nombre de parte.

func (Name) Class

func (n Name) Class(p Part) Class

Class deriva la clase de una parte: "targetlist__row".

func (Name) Root

func (n Name) Root() Class

Root es la clase exterior del widget.

type Part

type Part string

Part es una ranura nombrada de la anatomía de un widget (vocabulario Open UI). Es local al widget: "row", "menu", "header". Nunca lleva prefijo.

type Selectable

type Selectable interface{ Select(id string) }

Capacidades — cada costura asevera solo la que necesita (patrón de la casa, el mismo de view.Saver / view.Deleter).

type State

type State uint8

State es un estado que POSEE el widget: lo escribe Go, lo lee la hoja de estilos.

const (
	Selected State = iota
	Disabled
	Locked // solo lectura, pero plenamente legible
	Invalid
	Busy
	Open    // desplegado / expandido
	Current // ítem de navegación activo
)

func (State) Attr

func (s State) Attr() fmt.KeyValue

Attr devuelve el atributo que el DOM escribe y sobre el que la hoja selecciona. Markup y CSS coinciden por construcción, no por convención.

type Widget

type Widget interface {
	WidgetName() Name
	WidgetKind() Kind
}

Widget es la identidad. Es lo único obligatorio.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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