kitex

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 23 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README ΒΆ

βš›οΈ Kitex

Kitex is a lightweight, reactive Virtual DOM (VDOM) framework for Kite. It provides a declarative, type-safe API for building complex terminal UIs using functional components and hooks, similar to React.

kitex_demo

✨ Features

  • 🧩 Functional Components: Define reusable UI logic using kitex.FC (leaf components) or kitex.FCC (container components accepting children ...kitex.Node), with kitex.NoProps for components without props. Call Comp() / Cont(children...) for zero-value props or Comp.Props(p) / Cont.Props(p, children...) for explicit props.
  • 🧱 Typed Element Wrappers: Build UIs with typed ContainerTag and LeafTag constructors for Kite elements such as Box, Span, Button, Table, UL, OL, and LI. Call kitex.Box(kitex.BoxProps{...}, children...) for full props, or kitex.Box.Style(s, children...) / kitex.Span.Style(s, children...) / kitex.Input.Style(s) when only setting Style.
  • πŸͺ Hooks: Manage state and lifecycle with UseState, UseRef, UseMemo, UseReducer, and UseCallback.
  • πŸ”„ Efficient Reconciliation: A high-performance diffing algorithm that updates only what changed in the real DOM.
  • πŸ”‘ Keyed Lists: Optimized list updates using unique keys to track element identity.
  • πŸ›  DevTools Integration: Deep integration with the Kite Web Inspector, including a dedicated Components tab.

πŸš€ Getting Started

Basic Usage
package main

import (
    "context"
    "log"

    "github.com/masterkeysrd/kite"
    "github.com/masterkeysrd/kite/backend/uv"
    "github.com/masterkeysrd/kite/event"
    "github.com/masterkeysrd/kite/extras/kitex"
    "github.com/masterkeysrd/kite/style"
)

// Define a functional component with no props
var Counter = kitex.FC("Counter", func(_ kitex.NoProps) kitex.Node {
    // Use state hook
    count, setCount := kitex.UseState(0)

    return kitex.Box.Style(
        style.S().Padding(1, 1),
        kitex.Textf("Count: %d", count()),
        kitex.Button(kitex.ButtonProps{
            OnPress: func() {
                setCount.Update(func(previous int) int {
                    return previous + 1
                })
            },
            Style:   style.S().Hover(style.S().Background(style.Hex("#334155"))),
        }, kitex.Text("Increment")),
    )
})

// Functional component with explicit props
type GreetingProps struct {
    Name string
}

var Greeting = kitex.FC("Greeting", func(props GreetingProps) kitex.Node {
    return kitex.Textf("Hello, %s!", props.Name)
})

// Define a component that accepts children using FCC
type ContainerProps struct {
    Title string
}

var TitledContainer = kitex.FCC("TitledContainer", func(props ContainerProps, children ...kitex.Node) kitex.Node {
    return kitex.Box.Style(
        style.S().Border(style.SingleBorder()),
        kitex.Span.Style(style.S().Bold(true), kitex.Text(props.Title)),
        kitex.Box(kitex.BoxProps{}, children...),
    )
})

// Container component with no props
var Centered = kitex.FCC("Centered", func(_ kitex.NoProps, children ...kitex.Node) kitex.Node {
    return kitex.Box.Style(
        style.S().AlignItems(style.AlignCenter),
        children...,
    )
})

func main() {
    b, err := uv.New()
    if err != nil {
        log.Fatal(err)
    }

    app := kite.New(b, kite.WithMouseMode(kite.MouseModeTrack))
    root := kitex.CreateRoot(app)
    root.Render(Centered(
        Greeting.Props(GreetingProps{Name: "Kite"}),
        TitledContainer.Props(ContainerProps{Title: "Stats"}, Counter()),
    ))

    app.Document().AddEventListener(event.EventKeyDown, func(e event.Event) {
        if k, ok := e.(*event.KeyEvent); ok && k.MatchString("ctrl+c") {
            app.Stop()
        }
    }, event.Capture())

    if err := app.Run(context.Background()); err != nil {
        log.Fatal(err)
    }
}

CreateRoot mounts a 100% Γ— 100% container and unmounts its tree when the engine stops. Pass kitex.WithContainerStyle(s) to replace the default style, or use root.Container() to access the underlying DOM element.

To embed a component in an existing DOM layout, use root := kitex.CreateRootIn(container) and call root.Unmount() when done. root.Render(nil) clears the tree but allows another render; root.Unmount() permanently closes the root without detaching the container. The lower-level kitex.Render(node, container) and kitex.Unmount(container) remain available.

πŸͺ Hooks

Kitex provides several standard hooks to manage component logic:

  • UseState[T](initial T) (func() T, StateSetter[T]): Returns a getter and a StateSetter[T] handle (type StateSetter[T any] func(T)). Call set(val) directly to replace the state, or set.Update(func(prev T) T) for an atomic, goroutine-safe read-modify-write under the hook mutex. StateSetter[T] is directly assignable to func(T) callback props (e.g. OnValueChange: setQuery). Updating state triggers a re-render of the component.
  • UseStateFunc[T](init func() T): Pass a non-nil initializer to compute state only on mount. Returns the same getter and setter as UseState.
  • UseRef[T](initial T) Ref[T]: Returns a persistent, mutable reference that doesn't trigger re-renders when modified.
  • UseMemo[T](factory func() T, deps ...any) T: Memoizes an expensive calculation and re-runs it only when dependencies change (runs once on mount when called with no deps).
  • UseReducer[S, A any](reducer func(S, A) S, initial S) (func() S, func(A)): Manages complex state logic using a reducer pattern. Returns a getter and a dispatch function.
  • UseCallback[T any](callback T, deps ...any) T: Memoizes a callback function and returns the cached reference unless dependencies change (memoizes across component lifetime when called with no deps).
  • UseEffect(effect func(), deps ...any): Schedules a side effect to run asynchronously after the render is committed (runs once on mount when called with no deps).
  • UseEffectCleanup(effect func() func(), deps ...any): Schedules a side effect with a cleanup function that runs before the next effect run or on component destroy.
  • UseEffectEveryRender(effect func()) / UseEffectEveryRenderCleanup(effect func() func()): Schedules a post-commit side effect (with optional cleanup) to run after every render.
  • UseAsyncEffect(effect func(ctx context.Context), deps ...any): Schedules a cancellable asynchronous side effect managed by the host scheduler.
  • UseLayoutEffect(effect func(), deps ...any): Schedules a side effect that runs synchronously after reconciliation but before the layout is painted (runs once on mount when called with no deps).
  • UseLayoutEffectCleanup(effect func() func(), deps ...any): Schedules a layout side effect with a cleanup function.
  • UseLayoutEffectEveryRender(effect func()) / UseLayoutEffectEveryRenderCleanup(effect func() func()): Schedules a synchronous layout side effect (with optional cleanup) to run after every render.
Terminal Convenience Hooks

Kitex includes terminal-specific hooks built on the core primitives:

  • UseFocus(ref Ref[dom.Element]) bool: Tracks whether the referenced element currently has focus. Returns a reactive boolean.
  • UseKey(combo string, handler func(), deps ...any): Registers a shortcut such as "ctrl+s" for unconsumed keydowns. List captured values as dependencies. An empty combo or nil handler disables the shortcut; unmount removes it.
  • UseKeyboard(handler func(event.KeyEvent), deps ...any): Registers a global keyboard listener on the document. Automatically cleans up when the component is unmounted or when deps change.
  • UseTimeout(handler func(), delay time.Duration, deps ...any) / UseInterval(handler func(), interval time.Duration, deps ...any): Schedules one-shot or repeating callbacks on the host scheduler with automatic unmount cleanup.
  • UseDocument() func() dom.Document: Returns a lazy getter for the component's owner document. Useful for building custom hooks that need document-level event subscriptions.
  • UseElement() func() dom.Node: Returns a lazy getter for the underlying raw DOM node associated with the current component. Useful for retrieving the component's element inside side effects (e.g., to focus or measure it).
  • UseViewportSize() geom.Size: Subscribes the component to viewport resize events and returns the current terminal size. Triggering a resize dynamically re-renders the component to support responsive layout restructuring.
  • UseTerminal() func() terminal.Terminal: Returns a lazy getter for the terminal object associated with the current component.
  • UseTitle(initialTitle string) (func() string, func(string)): Initializes and manages the terminal window title. Returns a getter and a setter; calling the setter automatically updates the window title.
  • UseBell() func(): Returns a memoized callback function to trigger the terminal hardware bell without causing re-renders.

🌐 Context System

The Context system allows sharing values deep down the component tree without manually passing props through every level (avoiding "prop drilling").

CreateContext[T] accepts any Go value, including maps, slices and structs containing functions. Replace previously provided data instead of mutating it in place. Use UseCallback for stable closures or EquatableProps for custom equality.

1. Create a Context
type Theme string
var ThemeContext = kitex.CreateContext[Theme]("light")
2. Provide a Value

Wrap your subtree with the context provider:

ThemeContext.Provider("dark", 
    MyApp(),
)
3. Consume the Value

Call UseContext inside any functional component in the subtree:

var Button = kitex.FC("Button", func(_ kitex.NoProps) kitex.Node {
    theme := kitex.UseContext(ThemeContext)
    return kitex.Box(kitex.BoxProps{}, kitex.Text(string(theme)))
})

When the provider value changes, only the components consuming the context (via UseContext) will re-render. Memoized wrapper components will not block this update, and the VDOM reconciler flattens the provider node to guarantee zero DOM footprint (no layout-breaking elements).

πŸ“ Forms

Kitex provides a declarative <form> wrapper via kitex.Form to handle form submission and value collection. Form controls (such as kitex.Input, kitex.Checkbox, kitex.Radio, and kitex.Select) must specify a Name attribute. When the form is submitted (either by pressing Enter on a single-line input field or clicking a button with Type: "submit"), the form automatically gathers the name-value mappings of all descendants and triggers OnSubmit.

Example Form
var UserForm = kitex.FC("UserForm", func(_ kitex.NoProps) kitex.Node {
    handleSubmit := func(data map[string]any) {
        fmt.Printf("Form submitted: %v\n", data)
    }

    return kitex.Form(kitex.FormProps{
        OnSubmit: handleSubmit,
    },
        kitex.Input(kitex.InputProps{
            Name:  "username",
            Value: "default_user",
        }),
        kitex.Checkbox(kitex.CheckboxProps{
            Name:    "agree",
            Checked: false,
        }),
        kitex.Button(kitex.ButtonProps{
            Type: "submit",
        }, kitex.Text("Submit")),
    )
})

🧰 Utilities

Kitex provides several ergonomic helpers to make VDOM construction cleaner, especially for declarative rendering:

  • kitex.Map(items []D, fn func(D, int) Node) Node: Transforms a slice of data into a Node (a Fragment). Excellent for rendering keyed lists.
  • kitex.Nodes(nodes ...Node) Node: Merges multiple nodes (including Fragments and individual nodes) into a single flat Fragment. Filters out nil values.
  • kitex.If(cond bool, fn func() Node) Node: Conditionally renders a node if cond is true; otherwise, returns Empty() (which is safely ignored by Kitex).
  • kitex.IfElse(cond bool, thenNode Node, elseNode Node) Node: Returns thenNode if true, or elseNode if false. Both branches are evaluated eagerly.
  • kitex.IfElseFn(cond bool, thenFn, elseFn func() Node) Node: Lazily evaluates only thenFn when cond is true or elseFn when false, returning Empty() if the chosen closure is nil or returns nil.
  • kitex.Fragment(children ...Node) Node: Returns the provided children grouped together as a single Node without introducing a wrapper element in the DOM.
Example Utilities Usage
var ItemList = kitex.FC("ItemList", func(props struct{ Items []string }) kitex.Node {
    return kitex.Box(kitex.BoxProps{},
        kitex.If(len(props.Items) == 0, func() kitex.Node {
            return kitex.Text("No items found.")
        }),
        
        kitex.Box(kitex.BoxProps{}, 
            kitex.Map(props.Items, func(item string, idx int) kitex.Node {
                return kitex.Textf("%d: %s", idx, item)
            }),
        ),
    )
})

πŸ›  Developer Tools

When using Kitex, you can enable the Components inspector in the Kite Web Inspector. This provides a live view of your VDOM tree, including:

  • Component Hierarchy: Inspect the nesting of functional components.
  • Hook State: View the current values of all UseState and UseRef hooks.
  • Props: See the properties passed to each component.
  • Source Tracking: Jump directly to the file and line where a component or element was instantiated.
Enabling DevTools
package main

import (
	"github.com/masterkeysrd/kite"
	"github.com/masterkeysrd/kite/devtools"
	"github.com/masterkeysrd/kite/extras/kitex"
	"github.com/masterkeysrd/kite/extras/kitex/kitexdt"
)

func installTools(app *kite.Engine) error {
	kitex.EnableDevMode = true
	insp, err := devtools.Install(app, devtools.Options{})
	if err != nil {
		return err
	}

	kitexdt.Register(insp)
	return nil
}

πŸ“– Best Practices

  • Use Keys: Always provide a unique Key prop when rendering lists of elements to ensure optimal reconciliation.
  • Keep Components Small: Break down complex UIs into smaller, focused functional components.
  • Memoize Expensive Renders: Use UseMemo for heavy computations or complex subtrees that don't change often.

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 ΒΆ

Examples ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

View Source
var EnableDevMode bool
View Source
var OnComponentDirty func(node Node)

OnComponentDirty is a package-level hook triggered when a component becomes dirty (e.g. state change).

Functions ΒΆ

func ClearAllSubscriptions ΒΆ

func ClearAllSubscriptions(node dom.Node)

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 ΒΆ

func Render(root Node, container dom.Element)

Render mounts or reconciles a Virtual DOM root node into the specified host container.

func Unmount ΒΆ

func Unmount(container dom.Element)

Unmount unmounts and destroys the Virtual DOM tree in container.

func UseAsyncEffect ΒΆ

func UseAsyncEffect(effect func(ctx context.Context), deps ...any)

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 ΒΆ

func UseCallback[T any](callback T, deps ...any) T

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 ΒΆ

func UseContext[T any](ctx *Context[T]) T

UseContext retrieves the current value of the context.

func UseDocument ΒΆ

func UseDocument() func() dom.Document

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 ΒΆ

func UseElement() func() dom.Node

UseElement returns a function that retrieves the underlying DOM node associated with the current component.

func UseFocus ΒΆ

func UseFocus(ref Ref[dom.Element]) bool

UseFocus returns whether the referenced DOM element currently has focus.

func UseInterval ΒΆ

func UseInterval(handler func(), interval time.Duration, deps ...any)

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 UseKey ΒΆ

func UseKey(combo string, handler func(), deps ...any)

func UseKeyboard ΒΆ

func UseKeyboard(handler func(event.KeyEvent), deps ...any)

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 ΒΆ

func UseMemo[T any](factory func() T, deps ...any) T

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 ΒΆ

func UseTerminal() func() terminal.Terminal

UseTerminal returns a function that retrieves the terminal object associated with the current component.

func UseTimeout ΒΆ

func UseTimeout(handler func(), delay time.Duration, deps ...any)

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 ΒΆ

func UseTitle(initialTitle string) (func() string, func(string))

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 ΒΆ

func UseViewportSize() geom.Size

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
	CursorNavigable          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
	CursorNavigable          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 ΒΆ

type Component[P any] func() Node

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 ΒΆ

func FC[P any](name string, render func(props P) Node) Component[P]

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 β”‚
β””β”€β”€β”€β”€β”€β”€β”˜

func (Component[P]) Props ΒΆ

func (c Component[P]) Props(props P) Node

Props instantiates the component VDOM node with explicit properties.

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

func (*ComponentNode[P]) Update ΒΆ

func (c *ComponentNode[P]) Update(els []dom.Node, old Node)

type Container ΒΆ

type Container[P any] func(children ...Node) Node

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 ΒΆ

func FCC[P any](name string, render func(props P, children ...Node) Node) Container[P]

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

func (Container[P]) Props ΒΆ

func (c Container[P]) Props(props P, children ...Node) Node

Props instantiates the container component VDOM node with explicit properties and children.

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).

func (ContainerTag[P]) Style ΒΆ

func (t ContainerTag[P]) Style(s style.Style, children ...Node) Node

Style constructs the element with only Style set on its zero-value props.

type Context ΒΆ

type Context[T any] struct {
	// contains filtered or unexported fields
}

Context is a typed context identity created via CreateContext.

func CreateContext ΒΆ

func CreateContext[T any](defaultValue T) *Context[T]

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
	CursorNavigable          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
	CursorNavigable          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 ΒΆ

type EquatableProps interface {
	Equal(other any) bool
}

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) Children ΒΆ

func (f *ErrorBoundaryNode) Children() []Node

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.

func (*ErrorBoundaryNode) Update ΒΆ

func (b *ErrorBoundaryNode) Update(_ []dom.Node, old Node)

Update reconciles the active branch with a previous boundary.

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
	CursorNavigable          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 HookSnapshot struct {
	Kind  string `json:"kind"`
	Name  string `json:"name,omitempty"`
	Index int    `json:"index"`
	Value any    `json:"value"`
}

type InputProps ΒΆ

type InputProps struct {
	Attributes               map[string]string
	Key                      string
	ID                       string
	Class                    string
	Style                    style.Style
	Hidden                   bool
	Disabled                 bool
	CursorNavigable          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
	CursorNavigable          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.

func (LeafTag[P]) Style ΒΆ

func (t LeafTag[P]) Style(s style.Style) Node

Style constructs the leaf element with only Style set on its zero-value props.

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 ΒΆ

func Fragment(children ...Node) Node

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 ΒΆ

func If(cond bool, fn func() Node) Node

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 ΒΆ

func IfElse(cond bool, thenNode, elseNode Node) Node

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 ΒΆ

func IfElseFn(cond bool, thenFn, elseFn func() Node) Node

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 ΒΆ

func Map[D any](items []D, fn func(item D, i int) Node) Node

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 ΒΆ

func Nodes(nodes ...Node) Node

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,
    ),
)

func Text ΒΆ

func Text(data string) Node

Text creates a VDOM representation of a text node.

func Textf ΒΆ

func Textf(format string, args ...any) Node

Textf creates a VDOM representation of a formatted text node.

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
	CursorNavigable          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
	CursorNavigable          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.

func (*ProviderNode[T]) Update ΒΆ

func (p *ProviderNode[T]) Update(els []dom.Node, old Node)

Update is called when updating a provider node.

type RadioGroupProps ΒΆ

type RadioGroupProps struct {
	Attributes               map[string]string
	Key                      string
	ID                       string
	Class                    string
	Style                    style.Style
	Hidden                   bool
	Disabled                 bool
	CursorNavigable          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
	CursorNavigable          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 ΒΆ

type Ref[T any] = *RefObject[T]

Ref is a type alias for *RefObject[T].

func CreateRef ΒΆ

func CreateRef[T any]() Ref[T]

CreateRef creates a Ref outside of the render cycle.

func UseRef ΒΆ

func UseRef[T any](initial T) Ref[T]

UseRef returns a persistent Ref using the component hook state mechanism. Modifying the Ref does not trigger component dirty/re-render.

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 ΒΆ

func CreateRootIn(container dom.Element) *Root

CreateRootIn wraps an existing container without mounting or detaching it. The caller owns its lifetime. A nil container yields an inert root.

func (*Root) Container ΒΆ

func (r *Root) Container() dom.Element

Container returns the underlying DOM container, or nil for a nil root.

func (*Root) Render ΒΆ

func (r *Root) Render(node Node)

Render reconciles node into the container. A nil node clears the tree without closing the root. Render does nothing on a nil or unmounted root.

func (*Root) Unmount ΒΆ

func (r *Root) Unmount()

Unmount permanently closes the root and synchronously cleans up its tree without removing the container. Repeated calls are no-ops.

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
	CursorNavigable          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
	CursorNavigable          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
	CursorNavigable          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

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.

Jump to

Keyboard shortcuts

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