Documentation
ΒΆ
Index ΒΆ
- func Append(parentID string, component Component) error
- func GetHash() string
- func Log(v ...any)
- func OnHashChange(handler func(hash string))
- func Render(parentID string, component Component) error
- func SetHash(hash string)
- func SetLog(log func(v ...any))
- func Update(component Component) error
- type CSSProvider
- type Component
- type DOM
- type Element
- func A(href string, children ...any) *Element
- func Article(children ...any) *Element
- func Aside(children ...any) *Element
- func Br() *Element
- func Button(children ...any) *Element
- func Canvas(children ...any) *Element
- func Code(children ...any) *Element
- func Details(children ...any) *Element
- func Dialog(children ...any) *Element
- func Div(children ...any) *Element
- func Em(children ...any) *Element
- func Fieldset(children ...any) *Element
- func Figcaption(children ...any) *Element
- func Figure(children ...any) *Element
- func Footer(children ...any) *Element
- func H1(children ...any) *Element
- func H2(children ...any) *Element
- func H3(children ...any) *Element
- func H4(children ...any) *Element
- func H5(children ...any) *Element
- func H6(children ...any) *Element
- func Header(children ...any) *Element
- func Hr() *Element
- func Img(src, alt string) *Element
- func Label(children ...any) *Element
- func Legend(children ...any) *Element
- func Li(children ...any) *Element
- func Main(children ...any) *Element
- func Mark(children ...any) *Element
- func Nav(children ...any) *Element
- func Ol(children ...any) *Element
- func Option(value, text string) *Element
- func P(children ...any) *Element
- func Pre(children ...any) *Element
- func Script(children ...any) *Element
- func Section(children ...any) *Element
- func SelectedOption(value, text string) *Element
- func Small(children ...any) *Element
- func Span(children ...any) *Element
- func Strong(children ...any) *Element
- func Style(children ...any) *Element
- func Summary(children ...any) *Element
- func Svg(children ...any) *Element
- func Table(children ...any) *Element
- func Tbody(children ...any) *Element
- func Td(children ...any) *Element
- func Tfoot(children ...any) *Element
- func Th(children ...any) *Element
- func Thead(children ...any) *Element
- func Tr(children ...any) *Element
- func Ul(children ...any) *Element
- func Use(children ...any) *Element
- func (b *Element) Add(children ...any) *Element
- func (b *Element) Attr(key, val string) *Element
- func (b *Element) Children() []Component
- func (b *Element) Class(class ...string) *Element
- func (b *Element) GetID() string
- func (b *Element) ID(id string) *Element
- func (b *Element) On(t string, h func(Event)) *Element
- func (b *Element) Render(parentID string) error
- func (b *Element) RenderHTML() string
- func (b *Element) SetID(id string)
- func (b *Element) Text(text string) *Element
- func (b *Element) Update() error
- type Event
- type FormEl
- func (f *FormEl) Action(url string) *FormEl
- func (f *FormEl) Add(children ...any) *FormEl
- func (f *FormEl) AsElement() *Element
- func (f *FormEl) Attr(k, v string) *FormEl
- func (f *FormEl) Class(c ...string) *FormEl
- func (f *FormEl) ID(id string) *FormEl
- func (f *FormEl) Method(m string) *FormEl
- func (f *FormEl) NoValidate() *FormEl
- func (f *FormEl) On(t string, h func(Event)) *FormEl
- func (f *FormEl) OnSubmit(fn func(Event)) *FormEl
- type IconSvgProvider
- type InputEl
- func Checkbox(name string, value ...string) *InputEl
- func Color(name string) *InputEl
- func Date(name string) *InputEl
- func Email(name string, placeholder ...string) *InputEl
- func File(name string) *InputEl
- func Hidden(name, value string) *InputEl
- func Input(inputType string) *InputEl
- func Number(name string) *InputEl
- func Password(name string) *InputEl
- func Radio(name, value string) *InputEl
- func Range(name string) *InputEl
- func Reset(value ...string) *InputEl
- func Search(name string, placeholder ...string) *InputEl
- func Submit(value ...string) *InputEl
- func Tel(name string, placeholder ...string) *InputEl
- func Text(name string, placeholder ...string) *InputEl
- func Url(name string, placeholder ...string) *InputEl
- func (i *InputEl) AsElement() *Element
- func (i *InputEl) Attr(k, v string) *InputEl
- func (i *InputEl) AutoComplete(v string) *InputEl
- func (i *InputEl) Checked() *InputEl
- func (i *InputEl) Class(c ...string) *InputEl
- func (i *InputEl) Disabled() *InputEl
- func (i *InputEl) ID(id string) *InputEl
- func (i *InputEl) Max(v string) *InputEl
- func (i *InputEl) Min(v string) *InputEl
- func (i *InputEl) Name(n string) *InputEl
- func (i *InputEl) On(t string, h func(Event)) *InputEl
- func (i *InputEl) Pattern(p string) *InputEl
- func (i *InputEl) Placeholder(p string) *InputEl
- func (i *InputEl) Readonly() *InputEl
- func (i *InputEl) Required(v ...bool) *InputEl
- func (i *InputEl) Step(v string) *InputEl
- func (i *InputEl) Value(v string) *InputEl
- type JSProvider
- type Mountable
- type Reference
- type SelectEl
- func (s *SelectEl) Add(children ...any) *SelectEl
- func (s *SelectEl) AsElement() *Element
- func (s *SelectEl) Attr(k, v string) *SelectEl
- func (s *SelectEl) Class(c ...string) *SelectEl
- func (s *SelectEl) Disabled() *SelectEl
- func (s *SelectEl) ID(id string) *SelectEl
- func (s *SelectEl) Multiple() *SelectEl
- func (s *SelectEl) Name(n string) *SelectEl
- func (s *SelectEl) On(t string, h func(Event)) *SelectEl
- func (s *SelectEl) Required(v ...bool) *SelectEl
- type TextareaEl
- func (t *TextareaEl) AsElement() *Element
- func (t *TextareaEl) Attr(k, v string) *TextareaEl
- func (t *TextareaEl) Class(c ...string) *TextareaEl
- func (t *TextareaEl) Cols(n int) *TextareaEl
- func (t *TextareaEl) ID(id string) *TextareaEl
- func (t *TextareaEl) MaxLength(n int) *TextareaEl
- func (t *TextareaEl) Name(n string) *TextareaEl
- func (t *TextareaEl) On(ev string, h func(Event)) *TextareaEl
- func (t *TextareaEl) Placeholder(p string) *TextareaEl
- func (t *TextareaEl) Readonly() *TextareaEl
- func (t *TextareaEl) Required(v ...bool) *TextareaEl
- func (t *TextareaEl) Rows(n int) *TextareaEl
- func (t *TextareaEl) Value(v string) *TextareaEl
- type Unmountable
- type Updatable
- type ViewRenderer
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
func Append ΒΆ added in v0.2.0
Append injects a component AFTER the last child of the parent element.
func OnHashChange ΒΆ added in v0.0.11
func OnHashChange(handler func(hash string))
OnHashChange registers a hash change listener.
Types ΒΆ
type CSSProvider ΒΆ added in v0.0.13
type CSSProvider interface {
RenderCSS() string
}
CSSProvider is an optional capability: components that provide raw CSS for SSR asset collection (collected by tinywasm/site during static build).
type Component ΒΆ
type Component interface {
GetID() string
SetID(id string)
RenderHTML() string
Children() []Component
}
Component is the minimal interface for components. All components must implement this for both SSR (backend) and WASM (frontend).
type DOM ΒΆ
type DOM interface {
// Render injecta un componente en un elemento padre.
// 1. Llama a componente.Render() (si es ViewRenderer) o componente.RenderHTML()
// 2. Establece el contenido del elemento padre (buscado por parentID)
// 3. Llama a componente.OnMount() para enlazar eventos
Render(parentID string, component Component) error
// Append injecta un componente DESPUΓS del ΓΊltimo hijo del elemento padre.
// Γtil para listas dinΓ‘micas.
Append(parentID string, component Component) error
// OnHashChange registra un listener para cambios en el hash de la URL.
OnHashChange(handler func(hash string))
// GetHash devuelve el hash actual de la URL (ej. "#help").
GetHash() string
// SetHash actualiza el hash de la URL.
SetHash(hash string)
// Update re-renderiza el componente en su posiciΓ³n actual en el DOM.
Update(component Component) error
// Get retrieves an element by ID.
Get(id string) (Reference, bool)
// Log provides logging functionality using the log function passed to New.
Log(v ...any)
}
DOM is the main entry point for interacting with the browser. It is designed to be injected into your components.
type Element ΒΆ
type Element struct {
// contains filtered or unexported fields
}
Element represents a DOM element in the fluent Element API.
func Figcaption ΒΆ added in v0.4.2
func SelectedOption ΒΆ added in v0.4.2
func (*Element) Add ΒΆ added in v0.2.3
Add adds one or more children to the element. Children can be *Element, Node, Component, or string.
func (*Element) Children ΒΆ added in v0.2.3
Children returns the component's children (components only).
func (*Element) Render ΒΆ added in v0.2.3
Render renders the element to the parent. This is a terminal operation.
func (*Element) RenderHTML ΒΆ added in v0.2.3
RenderHTML renders the element to HTML string.
type Event ΒΆ
type Event interface {
// PreventDefault prevents the default action of the event.
PreventDefault()
// StopPropagation stops the event from bubbling up the DOM tree.
StopPropagation()
// TargetValue returns the value of the event's target element.
// Useful for input, textarea, and select elements.
TargetValue() string
// TargetID returns the ID of the event's target element.
TargetID() string
// TargetChecked returns the checked status of the event's target element.
// Useful for checkbox and radio input elements.
TargetChecked() bool
}
Event represents a DOM event.
type FormEl ΒΆ added in v0.4.2
type FormEl struct{ *Element }
func (*FormEl) NoValidate ΒΆ added in v0.4.2
type IconSvgProvider ΒΆ added in v0.0.13
IconSvgProvider is an optional capability: components that expose SVG icons for the global sprite sheet injected during SSR build.
type InputEl ΒΆ added in v0.4.2
type InputEl struct{ *Element }
func Text ΒΆ added in v0.4.2
Typed factories β (name string, placeholder ...string) where applicable
func (*InputEl) AutoComplete ΒΆ added in v0.4.2
func (*InputEl) Placeholder ΒΆ added in v0.4.2
type JSProvider ΒΆ added in v0.0.13
type JSProvider interface {
RenderJS() string
}
JSProvider is an optional capability: components that provide raw JS for SSR asset collection.
type Mountable ΒΆ added in v0.2.0
type Mountable interface {
OnMount()
}
Mountable is an optional interface for components that need initialization logic.
type Reference ΒΆ added in v0.2.3
type Reference interface {
// GetAttr retrieves an attribute value.
GetAttr(key string) string
// Value returns the current value of an input/textarea/select.
Value() string
// Checked returns the current checked state of a checkbox or radio button.
Checked() bool
// On registers a generic event handler (e.g., "click", "change", "input", "keydown").
On(eventType string, handler func(event Event))
// Focus sets focus to the element.
Focus()
}
Reference represents a reference to a DOM node. It provides methods for reading and interaction.
type SelectEl ΒΆ added in v0.4.2
type SelectEl struct{ *Element }
type TextareaEl ΒΆ added in v0.4.2
type TextareaEl struct{ *Element }
func Textarea ΒΆ added in v0.4.2
func Textarea(name string, placeholder ...string) *TextareaEl
Factory: (name, placeholder) β defaults to rows="3"
func (*TextareaEl) AsElement ΒΆ added in v0.4.2
func (t *TextareaEl) AsElement() *Element
func (*TextareaEl) Attr ΒΆ added in v0.4.2
func (t *TextareaEl) Attr(k, v string) *TextareaEl
func (*TextareaEl) Class ΒΆ added in v0.4.2
func (t *TextareaEl) Class(c ...string) *TextareaEl
func (*TextareaEl) Cols ΒΆ added in v0.4.2
func (t *TextareaEl) Cols(n int) *TextareaEl
func (*TextareaEl) ID ΒΆ added in v0.4.2
func (t *TextareaEl) ID(id string) *TextareaEl
Shadow methods
func (*TextareaEl) MaxLength ΒΆ added in v0.4.2
func (t *TextareaEl) MaxLength(n int) *TextareaEl
func (*TextareaEl) Name ΒΆ added in v0.4.2
func (t *TextareaEl) Name(n string) *TextareaEl
Semantic methods
func (*TextareaEl) On ΒΆ added in v0.4.2
func (t *TextareaEl) On(ev string, h func(Event)) *TextareaEl
func (*TextareaEl) Placeholder ΒΆ added in v0.4.2
func (t *TextareaEl) Placeholder(p string) *TextareaEl
func (*TextareaEl) Readonly ΒΆ added in v0.4.2
func (t *TextareaEl) Readonly() *TextareaEl
func (*TextareaEl) Required ΒΆ added in v0.4.2
func (t *TextareaEl) Required(v ...bool) *TextareaEl
func (*TextareaEl) Rows ΒΆ added in v0.4.2
func (t *TextareaEl) Rows(n int) *TextareaEl
func (*TextareaEl) Value ΒΆ added in v0.4.2
func (t *TextareaEl) Value(v string) *TextareaEl
type Unmountable ΒΆ added in v0.2.0
type Unmountable interface {
OnUnmount()
}
Unmountable is an optional interface for components that need cleanup logic.
type Updatable ΒΆ added in v0.2.0
type Updatable interface {
OnUpdate()
}
Updatable is an optional interface for components that need update logic.
type ViewRenderer ΒΆ added in v0.2.0
type ViewRenderer interface {
Render() *Element
}
ViewRenderer returns a Node tree for declarative UI.