Documentation
ΒΆ
Overview ΒΆ
Package kitex builds declarative Kite UIs from typed components and element constructors. Components use hooks for state and effects; the reconciler applies changes to the underlying DOM tree.
Use CreateRoot to mount a container whose tree is cleaned up on engine shutdown, or CreateRootIn to manage a subtree in an existing container. Call Root.Render to render or update the tree and Root.Unmount to close the root. Render and Unmount are also available for direct container use.
Index ΒΆ
- Variables
- func ClearAllSubscriptions(node dom.Node)
- func PostMacro(fn func())
- func ReleaseTree(n Node)
- func Render(root Node, container dom.Element)
- func Unmount(container dom.Element)
- func UseAsyncEffect(effect func(ctx context.Context), deps ...any)
- func UseBell() func()
- func UseCallback[T any](callback T, deps ...any) T
- func UseColorScheme() style.ColorScheme
- func UseContext[T any](ctx *Context[T]) T
- func UseDocument() func() dom.Document
- func UseEffect(effect func(), deps ...any)
- func UseEffectCleanup(effect func() func(), deps ...any)
- func UseEffectEveryRender(effect func())
- func UseEffectEveryRenderCleanup(effect func() func())
- func UseElement() func() dom.Node
- func UseFocus(ref Ref[dom.Element]) bool
- func UseInterval(handler func(), interval time.Duration, deps ...any)
- func UseKey(combo string, handler func(), deps ...any)
- func UseKeyboard(handler func(event.KeyEvent), deps ...any)
- func UseLayoutEffect(effect func(), deps ...any)
- func UseLayoutEffectCleanup(effect func() func(), deps ...any)
- func UseLayoutEffectEveryRender(effect func())
- func UseLayoutEffectEveryRenderCleanup(effect func() func())
- func UseMemo[T any](factory func() T, deps ...any) T
- func UseProgramResume() func(resume *terminal.ProgramResume)
- func UseProgressBar() func(state terminal.ProgressBarState, percentage int)
- func UseReducer[S, A any](reducer func(S, A) S, initial S) (func() S, func(A))
- func UseTerminal() func() terminal.Terminal
- func UseTimeout(handler func(), delay time.Duration, deps ...any)
- func UseTitle(initialTitle string) (func() string, func(string))
- func UseViewportSize() geom.Size
- func UseWindowFocus() bool
- type BoxProps
- type BrProps
- type ButtonProps
- type CheckboxProps
- type Component
- type ComponentNode
- func (c *ComponentNode[P]) Children() []Node
- func (c *ComponentNode[P]) ClearDirty()
- func (c *ComponentNode[P]) Destroy()
- func (c *ComponentNode[P]) Instantiate(doc dom.Document) []dom.Node
- func (c *ComponentNode[P]) IsDirty() bool
- func (c *ComponentNode[P]) Key() string
- func (c *ComponentNode[P]) MarkDirty()
- func (c *ComponentNode[P]) Props() any
- func (c *ComponentNode[P]) ReRender() Node
- func (c *ComponentNode[P]) Release()
- func (c *ComponentNode[P]) Rendered() Node
- func (c *ComponentNode[P]) TagName() string
- func (c *ComponentNode[P]) Update(els []dom.Node, old Node)
- type Container
- type ContainerTag
- type Context
- type DialogProps
- type ElementProps
- type EquatableProps
- type ErrorBoundaryNode
- func (f *ErrorBoundaryNode) Children() []Node
- func (b *ErrorBoundaryNode) Instantiate(doc dom.Document) []dom.Node
- func (b *ErrorBoundaryNode) Key() string
- func (b *ErrorBoundaryNode) Props() any
- func (b *ErrorBoundaryNode) Release()
- func (b *ErrorBoundaryNode) TagName() string
- func (b *ErrorBoundaryNode) Update(_ []dom.Node, old Node)
- type ErrorBoundaryProps
- type FormProps
- type HookSnapshot
- type InputProps
- type LIProps
- type LabelProps
- type LeafTag
- type NoProps
- type Node
- func Empty() Node
- func ErrorBoundary(props ErrorBoundaryProps, children ...Node) Node
- func Fragment(children ...Node) Node
- func If(cond bool, fn func() Node) Node
- func IfElse(cond bool, thenNode, elseNode Node) Node
- func IfElseFn(cond bool, thenFn, elseFn func() Node) Node
- func Map[D any](items []D, fn func(item D, i int) Node) Node
- func Nodes(nodes ...Node) Node
- func Text(data string) Node
- func Textf(format string, args ...any) Node
- type OLProps
- type OptionProps
- type OverlayProps
- type ProviderNode
- func (p *ProviderNode[T]) Children() []Node
- func (p *ProviderNode[T]) Instantiate(doc dom.Document) []dom.Node
- func (p *ProviderNode[T]) Key() string
- func (p *ProviderNode[T]) Props() any
- func (p *ProviderNode[T]) Release()
- func (p *ProviderNode[T]) TagName() string
- func (p *ProviderNode[T]) Update(els []dom.Node, old Node)
- type RadioGroupProps
- type RadioProps
- type Ref
- type RefObject
- type Root
- type RootOption
- type SelectProps
- type SpanProps
- type StateSetter
- type StylableProps
- type TBodyProps
- type TDProps
- type TFootProps
- type THeadProps
- type TRProps
- type TableProps
- type TextAreaProps
- type ULProps
- type VDOMSnapshot
Examples ΒΆ
Constants ΒΆ
This section is empty.
Variables ΒΆ
var EnableDevMode bool
var OnComponentDirty func(node Node)
OnComponentDirty is a package-level hook triggered when a component becomes dirty (e.g. state change).
Functions ΒΆ
func ClearAllSubscriptions ΒΆ
ClearAllSubscriptions cancels all event subscriptions associated with a DOM node and removes the node (and all its descendants) from the tracking map. Reconcilers should invoke this when deleting a node.
func PostMacro ΒΆ
func PostMacro(fn func())
PostMacro schedules a function to run as a macrotask on the main thread.
func ReleaseTree ΒΆ
func ReleaseTree(n Node)
ReleaseTree recursively releases a virtual DOM tree back to its object pools.
func Render ΒΆ
Render mounts or reconciles a Virtual DOM root node into the specified host container.
func UseAsyncEffect ΒΆ
UseAsyncEffect schedules a post-commit asynchronous side effect using the active scheduler's Spawn method (or promise.Spawn when no host scheduler is attached). The context passed to effect is cancelled before re-running when deps change, when the component unmounts, and when the scheduler stops.
func UseBell ΒΆ
func UseBell() func()
UseBell returns a memoized callback function to trigger the terminal hardware bell.
func UseCallback ΒΆ
UseCallback memoizes a function callback reference across renders, re-evaluating it only when deps change. When called with no deps, the callback is memoized across the component lifetime.
func UseColorScheme ΒΆ
func UseColorScheme() style.ColorScheme
UseColorScheme returns the host's preferred color scheme and re-renders the component whenever the terminal or browser switches between dark and light mode.
func UseContext ΒΆ
UseContext retrieves the current value of the context.
func UseDocument ΒΆ
UseDocument returns a function that retrieves the logical document root associated with the current component. It resolves the OwnerDocument from the component's real DOM nodes, DOM parent, or VDOM parent chain when called.
func UseEffect ΒΆ
func UseEffect(effect func(), deps ...any)
UseEffect schedules a post-commit side effect. When called with no deps, it runs once on mount.
func UseEffectCleanup ΒΆ
func UseEffectCleanup(effect func() func(), deps ...any)
UseEffectCleanup schedules a post-commit side effect with a cleanup function. When called with no deps, it runs once on mount and cleans up on unmount.
func UseEffectEveryRender ΒΆ
func UseEffectEveryRender(effect func())
UseEffectEveryRender schedules a post-commit side effect to run after every render.
func UseEffectEveryRenderCleanup ΒΆ
func UseEffectEveryRenderCleanup(effect func() func())
UseEffectEveryRenderCleanup schedules a post-commit side effect with cleanup to run after every render.
func UseElement ΒΆ
UseElement returns a function that retrieves the underlying DOM node associated with the current component.
func UseInterval ΒΆ
UseInterval schedules a callback to run repeatedly at the specified interval. The interval timer is automatically cancelled when the component is unmounted or if the interval/dependencies change.
func UseKeyboard ΒΆ
UseKeyboard registers a scoped keyboard handler that listens for event.EventKeyPress on the document. The handler is invoked with the typed event.KeyEvent.
func UseLayoutEffect ΒΆ
func UseLayoutEffect(effect func(), deps ...any)
UseLayoutEffect schedules a layout side effect that runs synchronously after reconciliation. When called with no deps, it runs once on mount.
func UseLayoutEffectCleanup ΒΆ
func UseLayoutEffectCleanup(effect func() func(), deps ...any)
UseLayoutEffectCleanup schedules a layout side effect with a cleanup function. When called with no deps, it runs once on mount and cleans up on unmount.
func UseLayoutEffectEveryRender ΒΆ
func UseLayoutEffectEveryRender(effect func())
UseLayoutEffectEveryRender schedules a layout side effect to run synchronously after every render.
func UseLayoutEffectEveryRenderCleanup ΒΆ
func UseLayoutEffectEveryRenderCleanup(effect func() func())
UseLayoutEffectEveryRenderCleanup schedules a layout side effect with cleanup to run synchronously after every render.
func UseMemo ΒΆ
UseMemo memoizes the result of factory and re-evaluates it only when the deps change between renders. Dependency comparison uses == for safely comparable types (comparing pointers by identity) and structural comparison (still comparing pointers by identity) otherwise. When called with no deps, factory runs once on mount.
Example:
expensive := kitex.UseMemo(func() []Row { return buildRows(data) }, data)
func UseProgramResume ΒΆ
func UseProgramResume() func(resume *terminal.ProgramResume)
UseProgramResume returns a memoized callback function to register or clear the command used by a supporting terminal to resume the process (OSC 7577).
func UseProgressBar ΒΆ
func UseProgressBar() func(state terminal.ProgressBarState, percentage int)
UseProgressBar returns a memoized callback function to update the terminal window's native progress bar.
func UseReducer ΒΆ
func UseReducer[S, A any](reducer func(S, A) S, initial S) (func() S, func(A))
UseReducer initializes a state variable with a reducer function, returning a getter function and a dispatch function. Setting the state via dispatch flags the component dirty and schedules a re-render.
func UseTerminal ΒΆ
UseTerminal returns a function that retrieves the terminal object associated with the current component.
func UseTimeout ΒΆ
UseTimeout schedules a callback to run after the specified delay. The timer is automatically cancelled if the component is unmounted or if the delay/dependencies change before the timeout elapses.
func UseTitle ΒΆ
UseTitle initializes and manages the terminal window title. It returns a getter and a setter. Setting a new title automatically updates the terminal window title.
func UseViewportSize ΒΆ
UseViewportSize returns the current viewport size (terminal dimensions) and registers a listener to trigger a re-render when the terminal is resized.
func UseWindowFocus ΒΆ
func UseWindowFocus() bool
UseWindowFocus returns a reactive boolean indicating whether the terminal window currently has focus.
Types ΒΆ
type BoxProps ΒΆ
type BoxProps = ElementProps
type BrProps ΒΆ
type BrProps = ElementProps
type ButtonProps ΒΆ
type ButtonProps struct {
Attributes map[string]string
Key string
ID string
Class string
Style style.Style
Hidden bool
Disabled bool
OnKeyDown func(*event.KeyEvent)
OnKeyDownCapture func(*event.KeyEvent)
OnKeyUp func(*event.KeyEvent)
OnKeyUpCapture func(*event.KeyEvent)
OnKeyPress func(*event.KeyEvent)
OnKeyPressCapture func(*event.KeyEvent)
OnMouseDown func(*event.MouseEvent)
OnMouseDownCapture func(*event.MouseEvent)
OnMouseUp func(*event.MouseEvent)
OnMouseUpCapture func(*event.MouseEvent)
OnMouseMove func(*event.MouseEvent)
OnMouseMoveCapture func(*event.MouseEvent)
OnClick func(*event.MouseEvent)
OnClickCapture func(*event.MouseEvent)
OnDrag func(*event.MouseEvent)
OnDragCapture func(*event.MouseEvent)
OnWheel func(*event.WheelEvent)
OnWheelCapture func(*event.WheelEvent)
OnFocus func(*event.FocusEvent)
OnFocusCapture func(*event.FocusEvent)
OnBlur func(*event.FocusEvent)
OnBlurCapture func(*event.FocusEvent)
OnFocusIn func(*event.FocusEvent)
OnFocusInCapture func(*event.FocusEvent)
OnFocusOut func(*event.FocusEvent)
OnFocusOutCapture func(*event.FocusEvent)
OnChange func(*event.ChangeEvent)
OnChangeCapture func(*event.ChangeEvent)
OnInput func(*event.InputEvent)
OnInputCapture func(*event.InputEvent)
OnScroll func(*event.ScrollEvent)
OnScrollCapture func(*event.ScrollEvent)
OnSelectionChange func(*event.SelectionChangeEvent)
OnSelectionChangeCapture func(*event.SelectionChangeEvent)
OnPaste func(*event.ClipboardEvent)
OnPasteCapture func(*event.ClipboardEvent)
OnCopy func(*event.ClipboardEvent)
OnCopyCapture func(*event.ClipboardEvent)
OnCut func(*event.ClipboardEvent)
OnCutCapture func(*event.ClipboardEvent)
OnMouseEnter func(*event.MouseEvent)
OnMouseLeave func(*event.MouseEvent)
OnMouseOver func(*event.MouseEvent)
OnMouseOverCapture func(*event.MouseEvent)
OnMouseOut func(*event.MouseEvent)
OnMouseOutCapture func(*event.MouseEvent)
Ref refSetter
OnPress func()
Active bool
Type string
}
ButtonProps specifies attributes for Button elements.
type CheckboxProps ΒΆ
type CheckboxProps struct {
Attributes map[string]string
Key string
ID string
Class string
Style style.Style
Hidden bool
Disabled bool
OnKeyDown func(*event.KeyEvent)
OnKeyDownCapture func(*event.KeyEvent)
OnKeyUp func(*event.KeyEvent)
OnKeyUpCapture func(*event.KeyEvent)
OnKeyPress func(*event.KeyEvent)
OnKeyPressCapture func(*event.KeyEvent)
OnMouseDown func(*event.MouseEvent)
OnMouseDownCapture func(*event.MouseEvent)
OnMouseUp func(*event.MouseEvent)
OnMouseUpCapture func(*event.MouseEvent)
OnMouseMove func(*event.MouseEvent)
OnMouseMoveCapture func(*event.MouseEvent)
OnClick func(*event.MouseEvent)
OnClickCapture func(*event.MouseEvent)
OnDrag func(*event.MouseEvent)
OnDragCapture func(*event.MouseEvent)
OnWheel func(*event.WheelEvent)
OnWheelCapture func(*event.WheelEvent)
OnFocus func(*event.FocusEvent)
OnFocusCapture func(*event.FocusEvent)
OnBlur func(*event.FocusEvent)
OnBlurCapture func(*event.FocusEvent)
OnFocusIn func(*event.FocusEvent)
OnFocusInCapture func(*event.FocusEvent)
OnFocusOut func(*event.FocusEvent)
OnFocusOutCapture func(*event.FocusEvent)
OnChange func(*event.ChangeEvent)
OnChangeCapture func(*event.ChangeEvent)
OnInput func(*event.InputEvent)
OnInputCapture func(*event.InputEvent)
OnScroll func(*event.ScrollEvent)
OnScrollCapture func(*event.ScrollEvent)
OnSelectionChange func(*event.SelectionChangeEvent)
OnSelectionChangeCapture func(*event.SelectionChangeEvent)
OnPaste func(*event.ClipboardEvent)
OnPasteCapture func(*event.ClipboardEvent)
OnCopy func(*event.ClipboardEvent)
OnCopyCapture func(*event.ClipboardEvent)
OnCut func(*event.ClipboardEvent)
OnCutCapture func(*event.ClipboardEvent)
OnMouseEnter func(*event.MouseEvent)
OnMouseLeave func(*event.MouseEvent)
OnMouseOver func(*event.MouseEvent)
OnMouseOverCapture func(*event.MouseEvent)
OnMouseOut func(*event.MouseEvent)
OnMouseOutCapture func(*event.MouseEvent)
Ref refSetter
Checked bool
OnCheckedChange func(bool)
UncheckedGlyph string
CheckedGlyph string
Name string
}
CheckboxProps specifies attributes for Checkbox elements.
type Component ΒΆ
Component is a leaf functional component that does not accept children. Call comp() to render with zero-value P, or comp.Props(p) to pass explicit props.
func FC ΒΆ
FC creates a leaf functional component that does not accept children.
Example ΒΆ
package main
import (
"fmt"
"strings"
"github.com/masterkeysrd/kite/extras/kitex"
"github.com/masterkeysrd/kite/testenv"
)
func main() {
switcher := kitex.FC("Sound", func(kitex.NoProps) kitex.Node {
label, setLabel := kitex.UseState("Mute")
return kitex.Button(kitex.ButtonProps{
OnPress: func() {
setLabel("Muted")
},
}, kitex.Text(label()))
})
env := testenv.New(nil, 8, 3)
defer env.Close()
root := kitex.CreateRoot(env.Engine)
root.Render(switcher())
env.Flush()
fmt.Println(strings.TrimSpace(env.DumpText()))
}
Output: ββββββββ β Mute β ββββββββ
type ComponentNode ΒΆ
type ComponentNode[P any] struct { Name string PropsVal P RenderFn func(P) Node RenderContainerFn func(P, ...Node) Node PassedChildren []Node // contains filtered or unexported fields }
ComponentNode represents a declarative functional component in the VDOM tree. It implements the Node interface.
func (*ComponentNode[P]) Children ΒΆ
func (c *ComponentNode[P]) Children() []Node
func (*ComponentNode[P]) ClearDirty ΒΆ
func (c *ComponentNode[P]) ClearDirty()
ClearDirty clears the dirty flag of the component.
func (*ComponentNode[P]) Destroy ΒΆ
func (c *ComponentNode[P]) Destroy()
Destroy cleans up component state, runs effect cleanups, and recursively destroys rendered subtree.
func (*ComponentNode[P]) Instantiate ΒΆ
func (c *ComponentNode[P]) Instantiate(doc dom.Document) []dom.Node
func (*ComponentNode[P]) IsDirty ΒΆ
func (c *ComponentNode[P]) IsDirty() bool
IsDirty returns whether the component is dirty.
func (*ComponentNode[P]) Key ΒΆ
func (c *ComponentNode[P]) Key() string
func (*ComponentNode[P]) MarkDirty ΒΆ
func (c *ComponentNode[P]) MarkDirty()
MarkDirty flags the component as dirty.
The flag is atomic because async sources (promise callbacks, stream iterators, timers) legitimately flag components from worker goroutines while the reconciler reads and clears it on the main thread. Every call notifies the reconciler: the flag alone does not prove the component is queued, since it can be raised while the component is already mid-render and therefore already removed from the dirty list.
func (*ComponentNode[P]) Props ΒΆ
func (c *ComponentNode[P]) Props() any
func (*ComponentNode[P]) ReRender ΒΆ
func (c *ComponentNode[P]) ReRender() Node
func (*ComponentNode[P]) Release ΒΆ
func (c *ComponentNode[P]) Release()
func (*ComponentNode[P]) Rendered ΒΆ
func (c *ComponentNode[P]) Rendered() Node
func (*ComponentNode[P]) TagName ΒΆ
func (c *ComponentNode[P]) TagName() string
type Container ΒΆ
Container is a functional component that accepts variadic VDOM children. Call comp(children...) to render with zero-value P, or comp.Props(p, children...) to pass explicit props.
func FCC ΒΆ
FCC creates a container functional component that receives children directly as a parameter (zero reflection).
Example ΒΆ
package main
import (
"fmt"
"strings"
"github.com/masterkeysrd/kite/extras/kitex"
"github.com/masterkeysrd/kite/testenv"
)
func main() {
panel := kitex.FCC("Panel", func(_ kitex.NoProps, children ...kitex.Node) kitex.Node {
return kitex.Box(kitex.BoxProps{}, children...)
})
env := testenv.New(nil, 20, 3)
defer env.Close()
root := kitex.CreateRoot(env.Engine)
root.Render(panel(kitex.Text("Release notes")))
env.Flush()
fmt.Println(strings.TrimSpace(env.DumpText()))
}
Output: Release notes
type ContainerTag ΒΆ
type ContainerTag[P StylableProps[P]] func(props P, children ...Node) Node
ContainerTag is a built-in VDOM element constructor that accepts props and variadic children. Call Tag(props, children...) for full props, or Tag.Style(s, children...) when only setting Style.
var Box ContainerTag[BoxProps] = func(props BoxProps, children ...Node) Node { n := elementNodePool.Get().(*elementNode[ElementProps]) score, hasP, hasDirectP := buildElementInfo(children) *n = elementNode[ElementProps]{ tagName: "box", props: props, children: children, instantiate: boxInstantiate, update: boxUpdate, key: props.Key, score: score, hasProvider: hasP, hasDirectP: hasDirectP, } return trackSource(n, 1) }
Box creates a VDOM representation of a BoxElement container.
var Button ContainerTag[ButtonProps] = func(props ButtonProps, children ...Node) Node { score, hasP, hasDirectP := buildElementInfo(children) return trackSource(&elementNode[ButtonProps]{ tagName: "button", props: props, children: children, instantiate: buttonInstantiate, update: buttonUpdate, key: props.Key, score: score, hasProvider: hasP, hasDirectP: hasDirectP, }, 1) }
Button creates a VDOM representation of a ButtonElement.
var Dialog ContainerTag[DialogProps] = func(props DialogProps, children ...Node) Node { score, hasP, hasDirectP := buildElementInfo(children) return trackSource(&elementNode[DialogProps]{ tagName: "dialog", props: props, children: children, instantiate: func(doc dom.Document) dom.Node { return element.NewDialog(doc).ZIndex(props.ZIndex) }, update: func(el dom.Node, old, new *DialogProps) { d := el.(*element.DialogElement) var oldEp ElementProps if old != nil { oldEp = old.elementProps() } newEp := new.elementProps() updateElementBase(d, &oldEp, &newEp) if old == nil || old.ZIndex != new.ZIndex { d.SetZIndex(new.ZIndex) } }, key: props.Key, score: score, hasProvider: hasP, hasDirectP: hasDirectP, }, 1) }
Dialog creates a VDOM representation of a DialogElement.
var Div ContainerTag[BoxProps] = func(props BoxProps, children ...Node) Node { n := elementNodePool.Get().(*elementNode[ElementProps]) score, hasP, hasDirectP := buildElementInfo(children) *n = elementNode[ElementProps]{ tagName: "div", props: props, children: children, instantiate: boxInstantiate, update: boxUpdate, key: props.Key, score: score, hasProvider: hasP, hasDirectP: hasDirectP, } return trackSource(n, 1) }
Div creates a VDOM representation of a BoxElement container (web div alias).
var Form ContainerTag[FormProps] = func(props FormProps, children ...Node) Node { score, hasP, hasDirectP := buildElementInfo(children) return trackSource(&elementNode[FormProps]{ tagName: "form", props: props, children: children, instantiate: func(doc dom.Document) dom.Node { f := element.NewForm(doc) if props.OnSubmit != nil { sub := f.AddEventListener(event.EventSubmit, func(e event.Event) { if se, ok := e.(*event.SubmitEvent); ok { props.OnSubmit(se.FormData) } }) setSubscription(f, subKey{typ: event.EventSubmit}, sub) } return f }, update: func(el dom.Node, old, new *FormProps) { f := el.(*element.FormElement) var oldEp ElementProps if old != nil { oldEp = old.elementProps() } newEp := new.elementProps() updateElementBase(f, &oldEp, &newEp) if old == nil || !funcEquals(old.OnSubmit, new.OnSubmit) { submitKey := subKey{typ: event.EventSubmit} clearSubscription(f, submitKey) if new.OnSubmit != nil { sub := f.AddEventListener(event.EventSubmit, func(e event.Event) { if se, ok := e.(*event.SubmitEvent); ok { new.OnSubmit(se.FormData) } }) setSubscription(f, submitKey, sub) } } }, key: props.Key, score: score, hasProvider: hasP, hasDirectP: hasDirectP, }, 1) }
Form creates a VDOM representation of a FormElement.
var LI ContainerTag[LIProps] = func(props LIProps, children ...Node) Node { score, hasP, hasDirectP := buildElementInfo(children) return trackSource(&elementNode[LIProps]{ tagName: "li", props: props, children: children, instantiate: func(doc dom.Document) dom.Node { return element.NewListItem(doc) }, update: func(el dom.Node, old, new *LIProps) { updateElementBase(el.(element.Element), old, new) }, key: props.Key, score: score, hasProvider: hasP, hasDirectP: hasDirectP, }, 1) }
LI creates a VDOM representation of a ListItemElement (li).
var Label ContainerTag[LabelProps] = func(props LabelProps, children ...Node) Node { score, hasP, hasDirectP := buildElementInfo(children) return trackSource(&elementNode[LabelProps]{ tagName: "label", props: props, children: children, key: props.Key, score: score, hasProvider: hasP, hasDirectP: hasDirectP, instantiate: func(doc dom.Document) dom.Node { return element.NewLabel(doc) }, update: labelUpdate, }, 1) }
var OL ContainerTag[OLProps] = func(props OLProps, children ...Node) Node { score, hasP, hasDirectP := buildElementInfo(children) return trackSource(&elementNode[OLProps]{ tagName: "ol", props: props, children: children, instantiate: func(doc dom.Document) dom.Node { return element.NewOrderedList(doc) }, update: func(el dom.Node, old, new *OLProps) { updateElementBase(el.(element.Element), old, new) }, key: props.Key, score: score, hasProvider: hasP, hasDirectP: hasDirectP, }, 1) }
OL creates a VDOM representation of an OrderedListElement (ol).
var Overlay ContainerTag[OverlayProps] = func(props OverlayProps, children ...Node) Node { score, hasP, hasDirectP := buildElementInfo(children) return trackSource(&elementNode[OverlayProps]{ tagName: "overlay", props: props, children: children, instantiate: func(doc dom.Document) dom.Node { return element.NewOverlay(doc, props.Anchor). WithZIndex(props.ZIndex). WithPlacement(props.Placement). WithFlip(props.Flip) }, update: func(el dom.Node, old, new *OverlayProps) { o := el.(*element.OverlayElement) var oldEp ElementProps if old != nil { oldEp = old.elementProps() } newEp := new.elementProps() updateElementBase(o, &oldEp, &newEp) if old == nil || (old.Anchor != new.Anchor || old.ZIndex != new.ZIndex || old.Placement != new.Placement || old.Flip != new.Flip) { config := element.OverlayConfig{ Anchor: new.Anchor, ZIndex: new.ZIndex, Placement: new.Placement, Flip: new.Flip, } o.SetConfig(config) } }, key: props.Key, score: score, hasProvider: hasP, hasDirectP: hasDirectP, }, 1) }
Overlay creates a VDOM representation of an OverlayElement.
var RadioGroup ContainerTag[RadioGroupProps] = func(props RadioGroupProps, children ...Node) Node { score, hasP, hasDirectP := buildElementInfo(children) return trackSource(&elementNode[RadioGroupProps]{ tagName: "radiogroup", props: props, children: children, instantiate: radioGroupInstantiate, update: radioGroupUpdate, key: props.Key, score: score, hasProvider: hasP, hasDirectP: hasDirectP, }, 1) }
RadioGroup creates a VDOM representation of a RadioGroupElement.
var Select ContainerTag[SelectProps] = func(props SelectProps, children ...Node) Node { score, hasP, hasDirectP := buildElementInfo(children) return trackSource(&elementNode[SelectProps]{ tagName: "select", props: props, children: children, instantiate: func(doc dom.Document) dom.Node { return element.NewSelect(doc) }, update: func(el dom.Node, old, new *SelectProps) { s := el.(*element.SelectElement) var oldEp ElementProps if old != nil { oldEp = old.elementProps() } newEp := new.elementProps() updateElementBase(s, &oldEp, &newEp) if old != nil && old.Value != new.Value { s.SetValue(new.Value) } else if old == nil { s.DefaultValue(new.Value) } if old == nil || !funcEquals(old.OnValueChange, new.OnValueChange) { s.OnChange(new.OnValueChange) } // Synchronize options slice from DOM children list var opts []*element.OptionElement for child := range s.ChildNodes() { if opt, ok := child.EventTarget().(*element.OptionElement); ok { opts = append(opts, opt) } } s.SetOptions(opts) if old != nil && old.Name != new.Name { s.WithName(new.Name) } else if old == nil { s.WithName(new.Name) } }, key: props.Key, score: score, hasProvider: hasP, hasDirectP: hasDirectP, }, 1) }
Select creates a VDOM representation of a SelectElement.
var Span ContainerTag[SpanProps] = func(props SpanProps, children ...Node) Node { n := elementNodePool.Get().(*elementNode[ElementProps]) score, hasP, hasDirectP := buildElementInfo(children) *n = elementNode[ElementProps]{ tagName: "span", props: props, children: children, instantiate: spanInstantiate, update: spanUpdate, key: props.Key, score: score, hasProvider: hasP, hasDirectP: hasDirectP, } return trackSource(n, 1) }
Span creates a VDOM representation of a SpanElement container.
var TBody ContainerTag[TBodyProps] = func(props TBodyProps, children ...Node) Node { score, hasP, hasDirectP := buildElementInfo(children) return trackSource(&elementNode[TBodyProps]{ tagName: "tbody", props: props, children: children, instantiate: func(doc dom.Document) dom.Node { return element.NewTableBody(doc) }, update: func(el dom.Node, old, new *TBodyProps) { updateElementBase(el.(element.Element), old, new) }, key: props.Key, score: score, hasProvider: hasP, hasDirectP: hasDirectP, }, 1) }
TBody creates a VDOM representation of a TableBodyElement (tbody).
var TD ContainerTag[TDProps] = func(props TDProps, children ...Node) Node { score, hasP, hasDirectP := buildElementInfo(children) return trackSource(&elementNode[TDProps]{ tagName: "td", props: props, children: children, instantiate: func(doc dom.Document) dom.Node { return element.NewTableCell(doc) }, update: func(el dom.Node, old, new *TDProps) { td := el.(*element.TableCellElement) var oldEp ElementProps if old != nil { oldEp = old.elementProps() } newEp := new.elementProps() updateElementBase(td, &oldEp, &newEp) if old == nil || old.ColSpan != new.ColSpan { td.SetColSpan(new.ColSpan) } if old == nil || old.RowSpan != new.RowSpan { td.SetRowSpan(new.RowSpan) } }, key: props.Key, score: score, hasProvider: hasP, hasDirectP: hasDirectP, }, 1) }
TD creates a VDOM representation of a TableCellElement (td).
var TFoot ContainerTag[TFootProps] = func(props TFootProps, children ...Node) Node { score, hasP, hasDirectP := buildElementInfo(children) return trackSource(&elementNode[TFootProps]{ tagName: "tfoot", props: props, children: children, instantiate: func(doc dom.Document) dom.Node { return element.NewTableFooter(doc) }, update: func(el dom.Node, old, new *TFootProps) { updateElementBase(el.(element.Element), old, new) }, key: props.Key, score: score, hasProvider: hasP, hasDirectP: hasDirectP, }, 1) }
TFoot creates a VDOM representation of a TableFooterElement (tfoot).
var THead ContainerTag[THeadProps] = func(props THeadProps, children ...Node) Node { score, hasP, hasDirectP := buildElementInfo(children) return trackSource(&elementNode[THeadProps]{ tagName: "thead", props: props, children: children, instantiate: func(doc dom.Document) dom.Node { return element.NewTableHeader(doc) }, update: func(el dom.Node, old, new *THeadProps) { updateElementBase(el.(element.Element), old, new) }, key: props.Key, score: score, hasProvider: hasP, hasDirectP: hasDirectP, }, 1) }
THead creates a VDOM representation of a TableHeaderElement (thead).
var TR ContainerTag[TRProps] = func(props TRProps, children ...Node) Node { score, hasP, hasDirectP := buildElementInfo(children) return trackSource(&elementNode[TRProps]{ tagName: "tr", props: props, children: children, instantiate: func(doc dom.Document) dom.Node { return element.NewTableRow(doc) }, update: func(el dom.Node, old, new *TRProps) { updateElementBase(el.(element.Element), old, new) }, key: props.Key, score: score, hasProvider: hasP, hasDirectP: hasDirectP, }, 1) }
TR creates a VDOM representation of a TableRowElement (tr).
var Table ContainerTag[TableProps] = func(props TableProps, children ...Node) Node { score, hasP, hasDirectP := buildElementInfo(children) return trackSource(&elementNode[TableProps]{ tagName: "table", props: props, children: children, instantiate: func(doc dom.Document) dom.Node { return element.NewTable(doc) }, update: func(el dom.Node, old, new *TableProps) { updateElementBase(el.(element.Element), old, new) }, key: props.Key, score: score, hasProvider: hasP, hasDirectP: hasDirectP, }, 1) }
Table creates a VDOM representation of a TableElement.
var UL ContainerTag[ULProps] = func(props ULProps, children ...Node) Node { score, hasP, hasDirectP := buildElementInfo(children) return trackSource(&elementNode[ULProps]{ tagName: "ul", props: props, children: children, instantiate: func(doc dom.Document) dom.Node { return element.NewUnorderedList(doc) }, update: func(el dom.Node, old, new *ULProps) { updateElementBase(el.(element.Element), old, new) }, key: props.Key, score: score, hasProvider: hasP, hasDirectP: hasDirectP, }, 1) }
UL creates a VDOM representation of an UnorderedListElement (ul).
type Context ΒΆ
type Context[T any] struct { // contains filtered or unexported fields }
Context is a typed context identity created via CreateContext.
func CreateContext ΒΆ
CreateContext creates a Context[T] identity with a default value.
func (*Context[T]) Provider ΒΆ
func (c *Context[T]) Provider(value T, children ...Node) *ProviderNode[T]
Provider constructs a ProviderNode for the given context and value.
type DialogProps ΒΆ
type DialogProps struct {
Attributes map[string]string
Key string
ID string
Class string
Style style.Style
Hidden bool
Disabled bool
OnKeyDown func(*event.KeyEvent)
OnKeyDownCapture func(*event.KeyEvent)
OnKeyUp func(*event.KeyEvent)
OnKeyUpCapture func(*event.KeyEvent)
OnKeyPress func(*event.KeyEvent)
OnKeyPressCapture func(*event.KeyEvent)
OnMouseDown func(*event.MouseEvent)
OnMouseDownCapture func(*event.MouseEvent)
OnMouseUp func(*event.MouseEvent)
OnMouseUpCapture func(*event.MouseEvent)
OnMouseMove func(*event.MouseEvent)
OnMouseMoveCapture func(*event.MouseEvent)
OnClick func(*event.MouseEvent)
OnClickCapture func(*event.MouseEvent)
OnDrag func(*event.MouseEvent)
OnDragCapture func(*event.MouseEvent)
OnWheel func(*event.WheelEvent)
OnWheelCapture func(*event.WheelEvent)
OnFocus func(*event.FocusEvent)
OnFocusCapture func(*event.FocusEvent)
OnBlur func(*event.FocusEvent)
OnBlurCapture func(*event.FocusEvent)
OnFocusIn func(*event.FocusEvent)
OnFocusInCapture func(*event.FocusEvent)
OnFocusOut func(*event.FocusEvent)
OnFocusOutCapture func(*event.FocusEvent)
OnChange func(*event.ChangeEvent)
OnChangeCapture func(*event.ChangeEvent)
OnInput func(*event.InputEvent)
OnInputCapture func(*event.InputEvent)
OnScroll func(*event.ScrollEvent)
OnScrollCapture func(*event.ScrollEvent)
OnSelectionChange func(*event.SelectionChangeEvent)
OnSelectionChangeCapture func(*event.SelectionChangeEvent)
OnPaste func(*event.ClipboardEvent)
OnPasteCapture func(*event.ClipboardEvent)
OnCopy func(*event.ClipboardEvent)
OnCopyCapture func(*event.ClipboardEvent)
OnCut func(*event.ClipboardEvent)
OnCutCapture func(*event.ClipboardEvent)
OnMouseEnter func(*event.MouseEvent)
OnMouseLeave func(*event.MouseEvent)
OnMouseOver func(*event.MouseEvent)
OnMouseOverCapture func(*event.MouseEvent)
OnMouseOut func(*event.MouseEvent)
OnMouseOutCapture func(*event.MouseEvent)
Ref refSetter
ZIndex int
}
DialogProps specifies attributes for Dialog elements.
type ElementProps ΒΆ
type ElementProps struct {
Key string
ID string
Class string
Style style.Style
Hidden bool
Disabled bool
Attributes map[string]string
OnKeyDown func(*event.KeyEvent)
OnKeyDownCapture func(*event.KeyEvent)
OnKeyUp func(*event.KeyEvent)
OnKeyUpCapture func(*event.KeyEvent)
OnKeyPress func(*event.KeyEvent)
OnKeyPressCapture func(*event.KeyEvent)
OnMouseDown func(*event.MouseEvent)
OnMouseDownCapture func(*event.MouseEvent)
OnMouseUp func(*event.MouseEvent)
OnMouseUpCapture func(*event.MouseEvent)
OnMouseMove func(*event.MouseEvent)
OnMouseMoveCapture func(*event.MouseEvent)
OnClick func(*event.MouseEvent)
OnClickCapture func(*event.MouseEvent)
OnDrag func(*event.MouseEvent)
OnDragCapture func(*event.MouseEvent)
OnWheel func(*event.WheelEvent)
OnWheelCapture func(*event.WheelEvent)
OnFocus func(*event.FocusEvent)
OnFocusCapture func(*event.FocusEvent)
OnBlur func(*event.FocusEvent)
OnBlurCapture func(*event.FocusEvent)
OnFocusIn func(*event.FocusEvent)
OnFocusInCapture func(*event.FocusEvent)
OnFocusOut func(*event.FocusEvent)
OnFocusOutCapture func(*event.FocusEvent)
OnChange func(*event.ChangeEvent)
OnChangeCapture func(*event.ChangeEvent)
OnInput func(*event.InputEvent)
OnInputCapture func(*event.InputEvent)
OnScroll func(*event.ScrollEvent)
OnScrollCapture func(*event.ScrollEvent)
OnSelectionChange func(*event.SelectionChangeEvent)
OnSelectionChangeCapture func(*event.SelectionChangeEvent)
OnPaste func(*event.ClipboardEvent)
OnPasteCapture func(*event.ClipboardEvent)
OnCopy func(*event.ClipboardEvent)
OnCopyCapture func(*event.ClipboardEvent)
OnCut func(*event.ClipboardEvent)
OnCutCapture func(*event.ClipboardEvent)
OnMouseEnter func(*event.MouseEvent)
OnMouseLeave func(*event.MouseEvent)
OnMouseOver func(*event.MouseEvent)
OnMouseOverCapture func(*event.MouseEvent)
OnMouseOut func(*event.MouseEvent)
OnMouseOutCapture func(*event.MouseEvent)
Ref refSetter
}
ElementProps holds common fields and typed event listeners present on all DOM element nodes.
type EquatableProps ΒΆ
EquatableProps allows prop structures to bypass reflection-based comparisons by implementing a custom, direct equality method.
type ErrorBoundaryNode ΒΆ
type ErrorBoundaryNode struct {
// contains filtered or unexported fields
}
ErrorBoundaryNode represents a keyed boundary without introducing a DOM element.
func (*ErrorBoundaryNode) Instantiate ΒΆ
func (b *ErrorBoundaryNode) Instantiate(doc dom.Document) []dom.Node
Instantiate mounts the children or, on failure, the fallback.
func (*ErrorBoundaryNode) Key ΒΆ
func (b *ErrorBoundaryNode) Key() string
Key identifies the boundary among siblings.
func (*ErrorBoundaryNode) Props ΒΆ
func (b *ErrorBoundaryNode) Props() any
Props returns the current boundary configuration.
func (*ErrorBoundaryNode) Release ΒΆ
func (b *ErrorBoundaryNode) Release()
Release invalidates outstanding retry callbacks.
func (*ErrorBoundaryNode) TagName ΒΆ
func (b *ErrorBoundaryNode) TagName() string
TagName identifies this structural node to the reconciler.
type ErrorBoundaryProps ΒΆ
type ErrorBoundaryProps struct {
Key string
Fallback func(err any, reset func()) Node
OnError func(err any, stack []byte)
ResetKeys []any
}
ErrorBoundaryProps configures an ErrorBoundary.
type FormProps ΒΆ
type FormProps struct {
Attributes map[string]string
Key string
ID string
Class string
Style style.Style
Hidden bool
Disabled bool
OnKeyDown func(*event.KeyEvent)
OnKeyDownCapture func(*event.KeyEvent)
OnKeyUp func(*event.KeyEvent)
OnKeyUpCapture func(*event.KeyEvent)
OnKeyPress func(*event.KeyEvent)
OnKeyPressCapture func(*event.KeyEvent)
OnMouseDown func(*event.MouseEvent)
OnMouseDownCapture func(*event.MouseEvent)
OnMouseUp func(*event.MouseEvent)
OnMouseUpCapture func(*event.MouseEvent)
OnMouseMove func(*event.MouseEvent)
OnMouseMoveCapture func(*event.MouseEvent)
OnClick func(*event.MouseEvent)
OnClickCapture func(*event.MouseEvent)
OnDrag func(*event.MouseEvent)
OnDragCapture func(*event.MouseEvent)
OnWheel func(*event.WheelEvent)
OnWheelCapture func(*event.WheelEvent)
OnFocus func(*event.FocusEvent)
OnFocusCapture func(*event.FocusEvent)
OnBlur func(*event.FocusEvent)
OnBlurCapture func(*event.FocusEvent)
OnFocusIn func(*event.FocusEvent)
OnFocusInCapture func(*event.FocusEvent)
OnFocusOut func(*event.FocusEvent)
OnFocusOutCapture func(*event.FocusEvent)
OnChange func(*event.ChangeEvent)
OnChangeCapture func(*event.ChangeEvent)
OnInput func(*event.InputEvent)
OnInputCapture func(*event.InputEvent)
OnScroll func(*event.ScrollEvent)
OnScrollCapture func(*event.ScrollEvent)
OnSelectionChange func(*event.SelectionChangeEvent)
OnSelectionChangeCapture func(*event.SelectionChangeEvent)
OnPaste func(*event.ClipboardEvent)
OnPasteCapture func(*event.ClipboardEvent)
OnCopy func(*event.ClipboardEvent)
OnCopyCapture func(*event.ClipboardEvent)
OnCut func(*event.ClipboardEvent)
OnCutCapture func(*event.ClipboardEvent)
OnMouseEnter func(*event.MouseEvent)
OnMouseLeave func(*event.MouseEvent)
OnMouseOver func(*event.MouseEvent)
OnMouseOverCapture func(*event.MouseEvent)
OnMouseOut func(*event.MouseEvent)
OnMouseOutCapture func(*event.MouseEvent)
Ref refSetter
OnSubmit func(map[string]any)
}
FormProps specifies attributes for Form elements.
type HookSnapshot ΒΆ
type InputProps ΒΆ
type InputProps struct {
Attributes map[string]string
Key string
ID string
Class string
Style style.Style
Hidden bool
Disabled bool
OnKeyDown func(*event.KeyEvent)
OnKeyDownCapture func(*event.KeyEvent)
OnKeyUp func(*event.KeyEvent)
OnKeyUpCapture func(*event.KeyEvent)
OnKeyPress func(*event.KeyEvent)
OnKeyPressCapture func(*event.KeyEvent)
OnMouseDown func(*event.MouseEvent)
OnMouseDownCapture func(*event.MouseEvent)
OnMouseUp func(*event.MouseEvent)
OnMouseUpCapture func(*event.MouseEvent)
OnMouseMove func(*event.MouseEvent)
OnMouseMoveCapture func(*event.MouseEvent)
OnClick func(*event.MouseEvent)
OnClickCapture func(*event.MouseEvent)
OnDrag func(*event.MouseEvent)
OnDragCapture func(*event.MouseEvent)
OnWheel func(*event.WheelEvent)
OnWheelCapture func(*event.WheelEvent)
OnFocus func(*event.FocusEvent)
OnFocusCapture func(*event.FocusEvent)
OnBlur func(*event.FocusEvent)
OnBlurCapture func(*event.FocusEvent)
OnFocusIn func(*event.FocusEvent)
OnFocusInCapture func(*event.FocusEvent)
OnFocusOut func(*event.FocusEvent)
OnFocusOutCapture func(*event.FocusEvent)
OnChange func(*event.ChangeEvent)
OnChangeCapture func(*event.ChangeEvent)
OnInput func(*event.InputEvent)
OnInputCapture func(*event.InputEvent)
OnScroll func(*event.ScrollEvent)
OnScrollCapture func(*event.ScrollEvent)
OnSelectionChange func(*event.SelectionChangeEvent)
OnSelectionChangeCapture func(*event.SelectionChangeEvent)
OnPaste func(*event.ClipboardEvent)
OnPasteCapture func(*event.ClipboardEvent)
OnCopy func(*event.ClipboardEvent)
OnCopyCapture func(*event.ClipboardEvent)
OnCut func(*event.ClipboardEvent)
OnCutCapture func(*event.ClipboardEvent)
OnMouseEnter func(*event.MouseEvent)
OnMouseLeave func(*event.MouseEvent)
OnMouseOver func(*event.MouseEvent)
OnMouseOverCapture func(*event.MouseEvent)
OnMouseOut func(*event.MouseEvent)
OnMouseOutCapture func(*event.MouseEvent)
Ref refSetter
OnValueChange func(string)
Value string
Name string
Placeholder string
PlaceholderStyle style.Style
Mask rune
Password bool
}
InputProps specifies attributes for Input elements.
type LIProps ΒΆ
type LIProps = ElementProps
type LabelProps ΒΆ
type LabelProps struct {
Attributes map[string]string
Key string
ID string
Class string
Style style.Style
Hidden bool
Disabled bool
OnKeyDown func(*event.KeyEvent)
OnKeyDownCapture func(*event.KeyEvent)
OnKeyUp func(*event.KeyEvent)
OnKeyUpCapture func(*event.KeyEvent)
OnKeyPress func(*event.KeyEvent)
OnKeyPressCapture func(*event.KeyEvent)
OnMouseDown func(*event.MouseEvent)
OnMouseDownCapture func(*event.MouseEvent)
OnMouseUp func(*event.MouseEvent)
OnMouseUpCapture func(*event.MouseEvent)
OnMouseMove func(*event.MouseEvent)
OnMouseMoveCapture func(*event.MouseEvent)
OnClick func(*event.MouseEvent)
OnClickCapture func(*event.MouseEvent)
OnDrag func(*event.MouseEvent)
OnDragCapture func(*event.MouseEvent)
OnWheel func(*event.WheelEvent)
OnWheelCapture func(*event.WheelEvent)
OnFocus func(*event.FocusEvent)
OnFocusCapture func(*event.FocusEvent)
OnBlur func(*event.FocusEvent)
OnBlurCapture func(*event.FocusEvent)
OnFocusIn func(*event.FocusEvent)
OnFocusInCapture func(*event.FocusEvent)
OnFocusOut func(*event.FocusEvent)
OnFocusOutCapture func(*event.FocusEvent)
OnChange func(*event.ChangeEvent)
OnChangeCapture func(*event.ChangeEvent)
OnInput func(*event.InputEvent)
OnInputCapture func(*event.InputEvent)
OnScroll func(*event.ScrollEvent)
OnScrollCapture func(*event.ScrollEvent)
OnSelectionChange func(*event.SelectionChangeEvent)
OnSelectionChangeCapture func(*event.SelectionChangeEvent)
OnPaste func(*event.ClipboardEvent)
OnPasteCapture func(*event.ClipboardEvent)
OnCopy func(*event.ClipboardEvent)
OnCopyCapture func(*event.ClipboardEvent)
OnCut func(*event.ClipboardEvent)
OnCutCapture func(*event.ClipboardEvent)
OnMouseEnter func(*event.MouseEvent)
OnMouseLeave func(*event.MouseEvent)
OnMouseOver func(*event.MouseEvent)
OnMouseOverCapture func(*event.MouseEvent)
OnMouseOut func(*event.MouseEvent)
OnMouseOutCapture func(*event.MouseEvent)
Ref refSetter
For string
}
LabelProps specifies attributes for Label elements.
type LeafTag ΒΆ
type LeafTag[P StylableProps[P]] func(props P) Node
LeafTag is a built-in leaf VDOM element constructor that accepts props and no children. Call Tag(props) for full props, or Tag.Style(s) when only setting Style.
var Br LeafTag[BrProps] = func(props BrProps) Node { return trackSource(&elementNode[BrProps]{ tagName: "br", props: props, children: nil, instantiate: func(doc dom.Document) dom.Node { return element.NewBr(doc) }, update: func(el dom.Node, old, new *BrProps) { updateElementBase(el.(element.Element), old, new) }, key: props.Key, score: 1, hasProvider: false, hasDirectP: false, }, 1) }
Br creates a VDOM representation of a BrElement.
var Checkbox LeafTag[CheckboxProps] = func(props CheckboxProps) Node { score, hasP, hasDirectP := buildElementInfo(nil) return trackSource(&elementNode[CheckboxProps]{ tagName: "checkbox", props: props, children: nil, instantiate: func(doc dom.Document) dom.Node { return element.NewCheckbox(doc, props.Checked) }, update: checkboxUpdate, key: props.Key, score: score, hasProvider: hasP, hasDirectP: hasDirectP, }, 1) }
Checkbox creates a VDOM representation of a CheckboxElement.
var Input LeafTag[InputProps] = func(props InputProps) Node { return trackSource(&elementNode[InputProps]{ tagName: "input", props: props, children: nil, instantiate: func(doc dom.Document) dom.Node { return element.NewInput(doc, props.Value). WithPlaceholder(props.Placeholder). WithPlaceholderStyle(props.PlaceholderStyle). WithMask(props.Mask). WithPassword(props.Password) }, update: func(el dom.Node, old, new *InputProps) { inp := el.(*element.InputElement) var oldEp ElementProps if old != nil { oldEp = old.elementProps() } newEp := new.elementProps() updateElementBase(inp, &oldEp, &newEp) if old == nil || !funcEquals(old.OnValueChange, new.OnValueChange) { inp.OnChange(new.OnValueChange) } if old != nil && old.Value != new.Value && inp.Text() != new.Value { inp.SetValue(new.Value) } if old != nil && old.Name != new.Name { inp.WithName(new.Name) } else if old == nil { inp.WithName(new.Name) } if old != nil && old.Placeholder != new.Placeholder { inp.WithPlaceholder(new.Placeholder) } else if old == nil { inp.WithPlaceholder(new.Placeholder) } inp.WithPlaceholderStyle(new.PlaceholderStyle) if old != nil && old.Mask != new.Mask { inp.WithMask(new.Mask) } else if old == nil { inp.WithMask(new.Mask) } if old != nil && old.Password != new.Password { inp.WithPassword(new.Password) } else if old == nil { inp.WithPassword(new.Password) } }, key: props.Key, score: 1, hasProvider: false, hasDirectP: false, }, 1) }
Input creates a VDOM representation of an InputElement.
var Option LeafTag[OptionProps] = func(props OptionProps) Node { return trackSource(&elementNode[OptionProps]{ tagName: "option", props: props, children: nil, instantiate: func(doc dom.Document) dom.Node { return element.NewOption(doc, props.Text, props.Value) }, update: func(el dom.Node, old, new *OptionProps) { opt := el.(*element.OptionElement) var oldEp ElementProps if old != nil { oldEp = old.elementProps() } newEp := new.elementProps() updateElementBase(opt, &oldEp, &newEp) if old != nil && old.Text != new.Text { opt.SetText(new.Text) } else if old == nil { opt.SetText(new.Text) } if old != nil && old.Value != new.Value { opt.SetValue(new.Value) } else if old == nil { opt.SetValue(new.Value) } }, key: props.Key, score: 1, hasProvider: false, hasDirectP: false, }, 1) }
Option creates a VDOM representation of an OptionElement metadata node.
var Radio LeafTag[RadioProps] = func(props RadioProps) Node { score, hasP, hasDirectP := buildElementInfo(nil) return trackSource(&elementNode[RadioProps]{ tagName: "radio", props: props, children: nil, instantiate: radioInstantiate, update: radioUpdate, key: props.Key, score: score, hasProvider: hasP, hasDirectP: hasDirectP, }, 1) }
Radio creates a VDOM representation of a RadioElement.
var TextArea LeafTag[TextAreaProps] = func(props TextAreaProps) Node { return trackSource(&elementNode[TextAreaProps]{ tagName: "textarea", props: props, children: nil, instantiate: func(doc dom.Document) dom.Node { return element.NewTextArea(doc, props.Value). WithPlaceholder(props.Placeholder). WithPlaceholderStyle(props.PlaceholderStyle) }, update: func(el dom.Node, old, new *TextAreaProps) { txa := el.(*element.TextAreaElement) var oldEp ElementProps if old != nil { oldEp = old.elementProps() } newEp := new.elementProps() updateElementBase(txa, &oldEp, &newEp) if old == nil || !funcEquals(old.OnValueChange, new.OnValueChange) { txa.OnChange(new.OnValueChange) } if old != nil && old.Value != new.Value && txa.Text() != new.Value { txa.SetValue(new.Value) } if old != nil && old.Name != new.Name { txa.WithName(new.Name) } else if old == nil { txa.WithName(new.Name) } if old != nil && old.Placeholder != new.Placeholder { txa.WithPlaceholder(new.Placeholder) } else if old == nil { txa.WithPlaceholder(new.Placeholder) } txa.WithPlaceholderStyle(new.PlaceholderStyle) }, key: props.Key, score: 1, hasProvider: false, hasDirectP: false, }, 1) }
TextArea creates a VDOM representation of a TextAreaElement.
type NoProps ΒΆ
type NoProps = struct{}
NoProps is the empty props type for components that accept no properties.
type Node ΒΆ
type Node interface {
// Instantiate constructs the corresponding real DOM node using the provided document.
Instantiate(doc dom.Document) []dom.Node
// Update applies properties from the current VDOM node onto the existing real DOM node,
// using the old VDOM node as reference to determine which properties changed.
Update(els []dom.Node, old Node)
// Children returns the lightweight children of this VDOM node.
Children() []Node
// Props returns the raw properties struct or value of this VDOM node.
Props() any
// TagName returns the tag name or identifier of this VDOM node type (e.g. "button", "#text").
TagName() string
// Key returns the unique key of this node, used for list reconciliation.
Key() string
// Release returns the node (and its children) to the object pool.
// This should only be called by the framework when a virtual tree is discarded.
Release()
}
Node is the public interface representing a Virtual DOM node in the kitex framework.
func Empty ΒΆ
func Empty() Node
Empty returns a placeholder node that renders nothing, used by conditionals like If.
func ErrorBoundary ΒΆ
func ErrorBoundary(props ErrorBoundaryProps, children ...Node) Node
ErrorBoundary catches render/reconciliation panics in its child subtree and renders Fallback in place of the failed subtree.
func Fragment ΒΆ
Fragment returns its children grouped together without introducing any wrapper element into the DOM.
Fragment is useful when a component needs to return multiple sibling nodes but cannot or should not wrap them in a Box, or when conditionally rendering a group of nodes.
Example:
var MyComp = kitex.FC("MyComp", func(_ kitex.NoProps) kitex.Node {
return kitex.Fragment(
kitex.Box.Style(boldStyle, kitex.Text("Title")),
kitex.Box.Style(mutedStyle, kitex.Text("Subtitle")),
)
})
func If ΒΆ
If renders node returned by fn when cond is true, otherwise returns nil. Nil children are safely ignored by all kitex element factories and the reconciler, so this can be used inline without wrapping in a slice.
Example:
kitex.Box(kitex.BoxProps{},
kitex.If(isLoggedIn, func() kitex.Node { return UserMenu(UserMenuProps{}) }),
kitex.Text("Welcome"),
)
func IfElse ΒΆ
IfElse renders thenNode when cond is true, elseNode otherwise. Both branches are evaluated eagerly (Go has no lazy evaluation), so avoid using IfElse when the branches have expensive side-effects; use a regular if-statement instead in those cases.
Example:
kitex.IfElse(isAdmin,
AdminPanel(AdminPanelProps{}),
kitex.Text("Access denied"),
)
func IfElseFn ΒΆ
IfElseFn lazily evaluates thenFn when cond is true or elseFn when cond is false. Only the chosen closure is invoked. If the chosen closure is nil or returns nil, Empty() is returned to preserve positional VDOM alignment.
func Map ΒΆ
Map converts a slice of data into a Node (a Fragment containing the mapped nodes) using a mapping function. The mapping function receives each item and its zero-based index, allowing the caller to embed both data and position into the rendered node.
Example β render a keyed list of items:
kitex.Box(kitex.BoxProps{},
kitex.Map(items, func(item Item, i int) kitex.Node {
return ItemCard(ItemCardProps{Key: item.ID, Title: item.Name})
}),
)
func Nodes ΒΆ
Nodes merges one or more Nodes (which may be Fragments, individual nodes, or nil) into a single flat Fragment. Nil entries are filtered out, and nested Fragments are flattened into the returned Fragment.
Example:
kitex.Box(kitex.BoxProps{},
kitex.Nodes(
kitex.Map(items, renderItem),
footer,
),
)
type OLProps ΒΆ
type OLProps = ElementProps
type OptionProps ΒΆ
type OptionProps struct {
Attributes map[string]string
Key string
ID string
Class string
Style style.Style
Hidden bool
Disabled bool
OnKeyDown func(*event.KeyEvent)
OnKeyDownCapture func(*event.KeyEvent)
OnKeyUp func(*event.KeyEvent)
OnKeyUpCapture func(*event.KeyEvent)
OnKeyPress func(*event.KeyEvent)
OnKeyPressCapture func(*event.KeyEvent)
OnMouseDown func(*event.MouseEvent)
OnMouseDownCapture func(*event.MouseEvent)
OnMouseUp func(*event.MouseEvent)
OnMouseUpCapture func(*event.MouseEvent)
OnMouseMove func(*event.MouseEvent)
OnMouseMoveCapture func(*event.MouseEvent)
OnClick func(*event.MouseEvent)
OnClickCapture func(*event.MouseEvent)
OnDrag func(*event.MouseEvent)
OnDragCapture func(*event.MouseEvent)
OnWheel func(*event.WheelEvent)
OnWheelCapture func(*event.WheelEvent)
OnFocus func(*event.FocusEvent)
OnFocusCapture func(*event.FocusEvent)
OnBlur func(*event.FocusEvent)
OnBlurCapture func(*event.FocusEvent)
OnFocusIn func(*event.FocusEvent)
OnFocusInCapture func(*event.FocusEvent)
OnFocusOut func(*event.FocusEvent)
OnFocusOutCapture func(*event.FocusEvent)
OnChange func(*event.ChangeEvent)
OnChangeCapture func(*event.ChangeEvent)
OnInput func(*event.InputEvent)
OnInputCapture func(*event.InputEvent)
OnScroll func(*event.ScrollEvent)
OnScrollCapture func(*event.ScrollEvent)
OnSelectionChange func(*event.SelectionChangeEvent)
OnSelectionChangeCapture func(*event.SelectionChangeEvent)
OnPaste func(*event.ClipboardEvent)
OnPasteCapture func(*event.ClipboardEvent)
OnCopy func(*event.ClipboardEvent)
OnCopyCapture func(*event.ClipboardEvent)
OnCut func(*event.ClipboardEvent)
OnCutCapture func(*event.ClipboardEvent)
OnMouseEnter func(*event.MouseEvent)
OnMouseLeave func(*event.MouseEvent)
OnMouseOver func(*event.MouseEvent)
OnMouseOverCapture func(*event.MouseEvent)
OnMouseOut func(*event.MouseEvent)
OnMouseOutCapture func(*event.MouseEvent)
Ref refSetter
Text string
Value string
}
OptionProps specifies attributes for Option elements.
type OverlayProps ΒΆ
type OverlayProps struct {
Attributes map[string]string
Key string
ID string
Class string
Style style.Style
Hidden bool
Disabled bool
OnKeyDown func(*event.KeyEvent)
OnKeyDownCapture func(*event.KeyEvent)
OnKeyUp func(*event.KeyEvent)
OnKeyUpCapture func(*event.KeyEvent)
OnKeyPress func(*event.KeyEvent)
OnKeyPressCapture func(*event.KeyEvent)
OnMouseDown func(*event.MouseEvent)
OnMouseDownCapture func(*event.MouseEvent)
OnMouseUp func(*event.MouseEvent)
OnMouseUpCapture func(*event.MouseEvent)
OnMouseMove func(*event.MouseEvent)
OnMouseMoveCapture func(*event.MouseEvent)
OnClick func(*event.MouseEvent)
OnClickCapture func(*event.MouseEvent)
OnDrag func(*event.MouseEvent)
OnDragCapture func(*event.MouseEvent)
OnWheel func(*event.WheelEvent)
OnWheelCapture func(*event.WheelEvent)
OnFocus func(*event.FocusEvent)
OnFocusCapture func(*event.FocusEvent)
OnBlur func(*event.FocusEvent)
OnBlurCapture func(*event.FocusEvent)
OnFocusIn func(*event.FocusEvent)
OnFocusInCapture func(*event.FocusEvent)
OnFocusOut func(*event.FocusEvent)
OnFocusOutCapture func(*event.FocusEvent)
OnChange func(*event.ChangeEvent)
OnChangeCapture func(*event.ChangeEvent)
OnInput func(*event.InputEvent)
OnInputCapture func(*event.InputEvent)
OnScroll func(*event.ScrollEvent)
OnScrollCapture func(*event.ScrollEvent)
OnSelectionChange func(*event.SelectionChangeEvent)
OnSelectionChangeCapture func(*event.SelectionChangeEvent)
OnPaste func(*event.ClipboardEvent)
OnPasteCapture func(*event.ClipboardEvent)
OnCopy func(*event.ClipboardEvent)
OnCopyCapture func(*event.ClipboardEvent)
OnCut func(*event.ClipboardEvent)
OnCutCapture func(*event.ClipboardEvent)
OnMouseEnter func(*event.MouseEvent)
OnMouseLeave func(*event.MouseEvent)
OnMouseOver func(*event.MouseEvent)
OnMouseOverCapture func(*event.MouseEvent)
OnMouseOut func(*event.MouseEvent)
OnMouseOutCapture func(*event.MouseEvent)
Ref refSetter
Anchor dom.Element
ZIndex int
Placement geom.Placement
Flip bool
}
OverlayProps specifies attributes for Overlay elements.
type ProviderNode ΒΆ
type ProviderNode[T any] struct { // contains filtered or unexported fields }
ProviderNode is a virtual/passthrough context provider node.
func (*ProviderNode[T]) Children ΒΆ
func (p *ProviderNode[T]) Children() []Node
Children returns the provider's virtual children.
func (*ProviderNode[T]) Instantiate ΒΆ
func (p *ProviderNode[T]) Instantiate(doc dom.Document) []dom.Node
Instantiate instantiates all children of the provider and returns them as a slice of DOM nodes.
func (*ProviderNode[T]) Key ΒΆ
func (p *ProviderNode[T]) Key() string
Key returns the provider's key (always empty).
func (*ProviderNode[T]) Props ΒΆ
func (p *ProviderNode[T]) Props() any
Props returns the provider's current value.
func (*ProviderNode[T]) Release ΒΆ
func (p *ProviderNode[T]) Release()
Release is a no-op as pooling is disabled.
func (*ProviderNode[T]) TagName ΒΆ
func (p *ProviderNode[T]) TagName() string
TagName returns a type-specific tag for the provider.
type RadioGroupProps ΒΆ
type RadioGroupProps struct {
Attributes map[string]string
Key string
ID string
Class string
Style style.Style
Hidden bool
Disabled bool
OnKeyDown func(*event.KeyEvent)
OnKeyDownCapture func(*event.KeyEvent)
OnKeyUp func(*event.KeyEvent)
OnKeyUpCapture func(*event.KeyEvent)
OnKeyPress func(*event.KeyEvent)
OnKeyPressCapture func(*event.KeyEvent)
OnMouseDown func(*event.MouseEvent)
OnMouseDownCapture func(*event.MouseEvent)
OnMouseUp func(*event.MouseEvent)
OnMouseUpCapture func(*event.MouseEvent)
OnMouseMove func(*event.MouseEvent)
OnMouseMoveCapture func(*event.MouseEvent)
OnClick func(*event.MouseEvent)
OnClickCapture func(*event.MouseEvent)
OnDrag func(*event.MouseEvent)
OnDragCapture func(*event.MouseEvent)
OnWheel func(*event.WheelEvent)
OnWheelCapture func(*event.WheelEvent)
OnFocus func(*event.FocusEvent)
OnFocusCapture func(*event.FocusEvent)
OnBlur func(*event.FocusEvent)
OnBlurCapture func(*event.FocusEvent)
OnFocusIn func(*event.FocusEvent)
OnFocusInCapture func(*event.FocusEvent)
OnFocusOut func(*event.FocusEvent)
OnFocusOutCapture func(*event.FocusEvent)
OnChange func(*event.ChangeEvent)
OnChangeCapture func(*event.ChangeEvent)
OnInput func(*event.InputEvent)
OnInputCapture func(*event.InputEvent)
OnScroll func(*event.ScrollEvent)
OnScrollCapture func(*event.ScrollEvent)
OnSelectionChange func(*event.SelectionChangeEvent)
OnSelectionChangeCapture func(*event.SelectionChangeEvent)
OnPaste func(*event.ClipboardEvent)
OnPasteCapture func(*event.ClipboardEvent)
OnCopy func(*event.ClipboardEvent)
OnCopyCapture func(*event.ClipboardEvent)
OnCut func(*event.ClipboardEvent)
OnCutCapture func(*event.ClipboardEvent)
OnMouseEnter func(*event.MouseEvent)
OnMouseLeave func(*event.MouseEvent)
OnMouseOver func(*event.MouseEvent)
OnMouseOverCapture func(*event.MouseEvent)
OnMouseOut func(*event.MouseEvent)
OnMouseOutCapture func(*event.MouseEvent)
Ref refSetter
Value string
OnValueChange func(string)
}
RadioGroupProps specifies attributes for RadioGroup elements.
type RadioProps ΒΆ
type RadioProps struct {
Attributes map[string]string
Key string
ID string
Class string
Style style.Style
Hidden bool
Disabled bool
OnKeyDown func(*event.KeyEvent)
OnKeyDownCapture func(*event.KeyEvent)
OnKeyUp func(*event.KeyEvent)
OnKeyUpCapture func(*event.KeyEvent)
OnKeyPress func(*event.KeyEvent)
OnKeyPressCapture func(*event.KeyEvent)
OnMouseDown func(*event.MouseEvent)
OnMouseDownCapture func(*event.MouseEvent)
OnMouseUp func(*event.MouseEvent)
OnMouseUpCapture func(*event.MouseEvent)
OnMouseMove func(*event.MouseEvent)
OnMouseMoveCapture func(*event.MouseEvent)
OnClick func(*event.MouseEvent)
OnClickCapture func(*event.MouseEvent)
OnDrag func(*event.MouseEvent)
OnDragCapture func(*event.MouseEvent)
OnWheel func(*event.WheelEvent)
OnWheelCapture func(*event.WheelEvent)
OnFocus func(*event.FocusEvent)
OnFocusCapture func(*event.FocusEvent)
OnBlur func(*event.FocusEvent)
OnBlurCapture func(*event.FocusEvent)
OnFocusIn func(*event.FocusEvent)
OnFocusInCapture func(*event.FocusEvent)
OnFocusOut func(*event.FocusEvent)
OnFocusOutCapture func(*event.FocusEvent)
OnChange func(*event.ChangeEvent)
OnChangeCapture func(*event.ChangeEvent)
OnInput func(*event.InputEvent)
OnInputCapture func(*event.InputEvent)
OnScroll func(*event.ScrollEvent)
OnScrollCapture func(*event.ScrollEvent)
OnSelectionChange func(*event.SelectionChangeEvent)
OnSelectionChangeCapture func(*event.SelectionChangeEvent)
OnPaste func(*event.ClipboardEvent)
OnPasteCapture func(*event.ClipboardEvent)
OnCopy func(*event.ClipboardEvent)
OnCopyCapture func(*event.ClipboardEvent)
OnCut func(*event.ClipboardEvent)
OnCutCapture func(*event.ClipboardEvent)
OnMouseEnter func(*event.MouseEvent)
OnMouseLeave func(*event.MouseEvent)
OnMouseOver func(*event.MouseEvent)
OnMouseOverCapture func(*event.MouseEvent)
OnMouseOut func(*event.MouseEvent)
OnMouseOutCapture func(*event.MouseEvent)
Ref refSetter
Value string
UncheckedGlyph string
CheckedGlyph string
Name string
}
RadioProps specifies attributes for Radio elements.
type Ref ΒΆ
Ref is a type alias for *RefObject[T].
type RefObject ΒΆ
type RefObject[T any] struct { Current T }
RefObject is the container that holds the mutable Current value.
type Root ΒΆ
type Root struct {
// contains filtered or unexported fields
}
Root manages a Kitex tree in a single DOM container. It must not be copied.
func CreateRoot ΒΆ
func CreateRoot(eng *engine.Engine, opts ...RootOption) *Root
CreateRoot mounts a full-viewport container and unmounts its tree when eng stops.
func CreateRootIn ΒΆ
CreateRootIn wraps an existing container without mounting or detaching it. The caller owns its lifetime. A nil container yields an inert root.
type RootOption ΒΆ
type RootOption func(*rootConfig)
RootOption configures the container mounted by CreateRoot.
func WithContainerStyle ΒΆ
func WithContainerStyle(s style.Style) RootOption
WithContainerStyle replaces the container's default full-viewport style.
type SelectProps ΒΆ
type SelectProps struct {
Attributes map[string]string
Key string
ID string
Class string
Style style.Style
Hidden bool
Disabled bool
OnKeyDown func(*event.KeyEvent)
OnKeyDownCapture func(*event.KeyEvent)
OnKeyUp func(*event.KeyEvent)
OnKeyUpCapture func(*event.KeyEvent)
OnKeyPress func(*event.KeyEvent)
OnKeyPressCapture func(*event.KeyEvent)
OnMouseDown func(*event.MouseEvent)
OnMouseDownCapture func(*event.MouseEvent)
OnMouseUp func(*event.MouseEvent)
OnMouseUpCapture func(*event.MouseEvent)
OnMouseMove func(*event.MouseEvent)
OnMouseMoveCapture func(*event.MouseEvent)
OnClick func(*event.MouseEvent)
OnClickCapture func(*event.MouseEvent)
OnDrag func(*event.MouseEvent)
OnDragCapture func(*event.MouseEvent)
OnWheel func(*event.WheelEvent)
OnWheelCapture func(*event.WheelEvent)
OnFocus func(*event.FocusEvent)
OnFocusCapture func(*event.FocusEvent)
OnBlur func(*event.FocusEvent)
OnBlurCapture func(*event.FocusEvent)
OnFocusIn func(*event.FocusEvent)
OnFocusInCapture func(*event.FocusEvent)
OnFocusOut func(*event.FocusEvent)
OnFocusOutCapture func(*event.FocusEvent)
OnChange func(*event.ChangeEvent)
OnChangeCapture func(*event.ChangeEvent)
OnInput func(*event.InputEvent)
OnInputCapture func(*event.InputEvent)
OnScroll func(*event.ScrollEvent)
OnScrollCapture func(*event.ScrollEvent)
OnSelectionChange func(*event.SelectionChangeEvent)
OnSelectionChangeCapture func(*event.SelectionChangeEvent)
OnPaste func(*event.ClipboardEvent)
OnPasteCapture func(*event.ClipboardEvent)
OnCopy func(*event.ClipboardEvent)
OnCopyCapture func(*event.ClipboardEvent)
OnCut func(*event.ClipboardEvent)
OnCutCapture func(*event.ClipboardEvent)
OnMouseEnter func(*event.MouseEvent)
OnMouseLeave func(*event.MouseEvent)
OnMouseOver func(*event.MouseEvent)
OnMouseOverCapture func(*event.MouseEvent)
OnMouseOut func(*event.MouseEvent)
OnMouseOutCapture func(*event.MouseEvent)
Ref refSetter
Value string
OnValueChange func(string)
Name string
}
SelectProps specifies attributes for Select elements.
type SpanProps ΒΆ
type SpanProps = ElementProps
type StateSetter ΒΆ
type StateSetter[T any] func(T)
StateSetter updates a state slot created by UseState. Call it directly as setState(next) to replace the value, or call setState.Update(fn) to perform an atomic read-modify-write under the hook's mutex.
func UseState ΒΆ
func UseState[T any](initial T) (func() T, StateSetter[T])
UseState initializes a state variable on first render, persists it across render cycles, and returns a getter and a StateSetter. Calling set(val) replaces the state, while set.Update(fn) performs an atomic read-modify-write under the hook's mutex. If called outside of a component render cycle, it panics.
Example ΒΆ
package main
import (
"fmt"
"github.com/masterkeysrd/kite/extras/kitex"
"github.com/masterkeysrd/kite/testenv"
)
func main() {
counter := kitex.FC("Counter", func(kitex.NoProps) kitex.Node {
count, setCount := kitex.UseState(0)
return kitex.Button(kitex.ButtonProps{
OnPress: func() {
setCount.Update(func(previous int) int {
return previous + 1
})
},
}, kitex.Textf("Count: %d", count()))
})
env := testenv.New(nil, 12, 3)
defer env.Close()
root := kitex.CreateRoot(env.Engine)
root.Render(counter())
env.Flush()
fmt.Print(env.DumpText())
env.ClickElement(env.QueryByText("Count: 0"))
env.Flush()
fmt.Print(env.DumpText())
}
Output: ββββββββββββ β Count: 0 β ββββββββββββ ββββββββββββ β Count: 1 β ββββββββββββ
func UseStateFunc ΒΆ
func UseStateFunc[T any](init func() T) (func() T, StateSetter[T])
func (StateSetter[T]) Update ΒΆ
func (s StateSetter[T]) Update(fn func(T) T)
Update atomically transforms the current state value via fn under the hook's mutex and marks the component dirty. Safe to call from any goroutine.
type StylableProps ΒΆ
type StylableProps[P any] interface { // contains filtered or unexported methods }
StylableProps is satisfied by ElementProps and all generated element *Props structs.
type TBodyProps ΒΆ
type TBodyProps = ElementProps
type TDProps ΒΆ
type TDProps struct {
Attributes map[string]string
Key string
ID string
Class string
Style style.Style
Hidden bool
Disabled bool
OnKeyDown func(*event.KeyEvent)
OnKeyDownCapture func(*event.KeyEvent)
OnKeyUp func(*event.KeyEvent)
OnKeyUpCapture func(*event.KeyEvent)
OnKeyPress func(*event.KeyEvent)
OnKeyPressCapture func(*event.KeyEvent)
OnMouseDown func(*event.MouseEvent)
OnMouseDownCapture func(*event.MouseEvent)
OnMouseUp func(*event.MouseEvent)
OnMouseUpCapture func(*event.MouseEvent)
OnMouseMove func(*event.MouseEvent)
OnMouseMoveCapture func(*event.MouseEvent)
OnClick func(*event.MouseEvent)
OnClickCapture func(*event.MouseEvent)
OnDrag func(*event.MouseEvent)
OnDragCapture func(*event.MouseEvent)
OnWheel func(*event.WheelEvent)
OnWheelCapture func(*event.WheelEvent)
OnFocus func(*event.FocusEvent)
OnFocusCapture func(*event.FocusEvent)
OnBlur func(*event.FocusEvent)
OnBlurCapture func(*event.FocusEvent)
OnFocusIn func(*event.FocusEvent)
OnFocusInCapture func(*event.FocusEvent)
OnFocusOut func(*event.FocusEvent)
OnFocusOutCapture func(*event.FocusEvent)
OnChange func(*event.ChangeEvent)
OnChangeCapture func(*event.ChangeEvent)
OnInput func(*event.InputEvent)
OnInputCapture func(*event.InputEvent)
OnScroll func(*event.ScrollEvent)
OnScrollCapture func(*event.ScrollEvent)
OnSelectionChange func(*event.SelectionChangeEvent)
OnSelectionChangeCapture func(*event.SelectionChangeEvent)
OnPaste func(*event.ClipboardEvent)
OnPasteCapture func(*event.ClipboardEvent)
OnCopy func(*event.ClipboardEvent)
OnCopyCapture func(*event.ClipboardEvent)
OnCut func(*event.ClipboardEvent)
OnCutCapture func(*event.ClipboardEvent)
OnMouseEnter func(*event.MouseEvent)
OnMouseLeave func(*event.MouseEvent)
OnMouseOver func(*event.MouseEvent)
OnMouseOverCapture func(*event.MouseEvent)
OnMouseOut func(*event.MouseEvent)
OnMouseOutCapture func(*event.MouseEvent)
Ref refSetter
ColSpan int
RowSpan int
}
TDProps specifies attributes for TD elements.
type TFootProps ΒΆ
type TFootProps = ElementProps
type THeadProps ΒΆ
type THeadProps = ElementProps
type TRProps ΒΆ
type TRProps = ElementProps
type TableProps ΒΆ
type TableProps = ElementProps
type TextAreaProps ΒΆ
type TextAreaProps struct {
Attributes map[string]string
Key string
ID string
Class string
Style style.Style
Hidden bool
Disabled bool
OnKeyDown func(*event.KeyEvent)
OnKeyDownCapture func(*event.KeyEvent)
OnKeyUp func(*event.KeyEvent)
OnKeyUpCapture func(*event.KeyEvent)
OnKeyPress func(*event.KeyEvent)
OnKeyPressCapture func(*event.KeyEvent)
OnMouseDown func(*event.MouseEvent)
OnMouseDownCapture func(*event.MouseEvent)
OnMouseUp func(*event.MouseEvent)
OnMouseUpCapture func(*event.MouseEvent)
OnMouseMove func(*event.MouseEvent)
OnMouseMoveCapture func(*event.MouseEvent)
OnClick func(*event.MouseEvent)
OnClickCapture func(*event.MouseEvent)
OnDrag func(*event.MouseEvent)
OnDragCapture func(*event.MouseEvent)
OnWheel func(*event.WheelEvent)
OnWheelCapture func(*event.WheelEvent)
OnFocus func(*event.FocusEvent)
OnFocusCapture func(*event.FocusEvent)
OnBlur func(*event.FocusEvent)
OnBlurCapture func(*event.FocusEvent)
OnFocusIn func(*event.FocusEvent)
OnFocusInCapture func(*event.FocusEvent)
OnFocusOut func(*event.FocusEvent)
OnFocusOutCapture func(*event.FocusEvent)
OnChange func(*event.ChangeEvent)
OnChangeCapture func(*event.ChangeEvent)
OnInput func(*event.InputEvent)
OnInputCapture func(*event.InputEvent)
OnScroll func(*event.ScrollEvent)
OnScrollCapture func(*event.ScrollEvent)
OnSelectionChange func(*event.SelectionChangeEvent)
OnSelectionChangeCapture func(*event.SelectionChangeEvent)
OnPaste func(*event.ClipboardEvent)
OnPasteCapture func(*event.ClipboardEvent)
OnCopy func(*event.ClipboardEvent)
OnCopyCapture func(*event.ClipboardEvent)
OnCut func(*event.ClipboardEvent)
OnCutCapture func(*event.ClipboardEvent)
OnMouseEnter func(*event.MouseEvent)
OnMouseLeave func(*event.MouseEvent)
OnMouseOver func(*event.MouseEvent)
OnMouseOverCapture func(*event.MouseEvent)
OnMouseOut func(*event.MouseEvent)
OnMouseOutCapture func(*event.MouseEvent)
Ref refSetter
OnValueChange func(string)
Value string
Name string
Placeholder string
PlaceholderStyle style.Style
}
TextAreaProps specifies attributes for TextArea elements.
type ULProps ΒΆ
type ULProps = ElementProps
type VDOMSnapshot ΒΆ
type VDOMSnapshot struct {
Kind string `json:"kind,omitempty"`
Name string `json:"name"`
Key string `json:"key,omitempty"`
Props any `json:"props,omitempty"`
State []any `json:"state,omitempty"`
Hooks []HookSnapshot `json:"hooks,omitempty"`
DeclFile string `json:"declFile,omitempty"`
DeclLine int `json:"declLine,omitempty"`
InstFile string `json:"instFile,omitempty"`
InstLine int `json:"instLine,omitempty"`
DomID string `json:"domId,omitempty"`
DomUniqueID string `json:"domUniqueId,omitempty"`
UniqueID string `json:"uniqueId,omitempty"`
Rect geom.Rect `json:"rect"`
Children []*VDOMSnapshot `json:"children,omitempty"`
}
func BuildDevToolsSnapshot ΒΆ
func BuildDevToolsSnapshot(eng *engine.Engine) []*VDOMSnapshot
Source Files
ΒΆ
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
internal
|
|
|
genprops
command
|
|
|
Package kitexdt provides the DevTools integration bridge for kitex Virtual DOM.
|
Package kitexdt provides the DevTools integration bridge for kitex Virtual DOM. |
|
Package kitextest provides a lightweight, React-Testing-Library-inspired test harness for rendering, querying, interacting with, and asserting on kitex VDOM components in a headless testenv environment.
|
Package kitextest provides a lightweight, React-Testing-Library-inspired test harness for rendering, querying, interacting with, and asserting on kitex VDOM components in a headless testenv environment. |