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 (b *Element) Add(children ...any) *Element
- func (b *Element) Append(child 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(eventType string, handler 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 EventHandler
- type IconSvgProvider
- type JSProvider
- type Mountable
- type Reference
- 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 interface for components that need to inject CSS.
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
// 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 (*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) Append ¶ added in v0.2.3
Append adds a child to the element. Deprecated: use Add instead.
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
}
Event represents a DOM event.
type EventHandler ¶ added in v0.2.0
EventHandler represents a DOM event handler in the declarative builder.
type IconSvgProvider ¶ added in v0.0.13
IconSvgProvider is an optional interface for components that provide SVG icons.
type JSProvider ¶ added in v0.0.13
type JSProvider interface {
RenderJS() string
}
JSProvider is an optional interface for components that need to inject JS.
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 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.