componentview

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package componentview is the typed per-component complement to the generic leewaywidgets.Table2CardEmitter (ADR-0075). Where Table2CardEmitter renders any leeway table structurally, this renders *recognised* components with bespoke widgets: each registered RendererI is an ECS "system that draws", matched to entities that carry its component. A Dispatcher lays the detected components out as a collapsible single-record report — one foldable panel per component, the archetype made visible — and routes anything unrecognised to a generic fallback.

Detection and typed decode happen upstream (leeway RA population counts + marshallreflect.Unmarshal); this package consumes the already-decoded Component values, so it stays free of leeway-codec dependencies.

Index

Constants

This section is empty.

Variables

View Source
var PackageProps = packageprops.Props{
	WASMWASI:         packageprops.WASMCompiles,
	WASMJS:           packageprops.WASMCompiles,
	WASMFreestanding: packageprops.WASMCompiles,
}

PackageProps records this package's curated properties (ADR-0080). Seeded by `wasmsurvey props generate`; curate by hand, then `wasmsurvey props verify`.

Functions

This section is empty.

Types

type BatteryVal

type BatteryVal struct{ Charge uint64 }

IdentityVal, BatteryVal and TaskedVal are the decoded carriers the seed renderers expect. Tasked is tags-only for now — its time window (timeRange) is deferred together with the timeline widget (stage-2 defers timeRange).

type Component

type Component struct {
	Kind  ComponentKindE
	Value any
}

Component is one decoded component on an entity: its kind plus the typed value the kind's renderer understands (type-asserted by that renderer). A nil Value renders as present-but-empty.

type ComponentKindE

type ComponentKindE string

ComponentKindE names a recognised leeway component — a section or section-bundle treated as one logical thing. The seed kinds are the ecsdemo drone components; fact-components register their own.

const (
	KindIdentity ComponentKindE = "identity"
	KindBattery  ComponentKindE = "battery"
	KindTasked   ComponentKindE = "tasked"
)

type Dispatcher

type Dispatcher struct {

	// ShowAbsent renders registered-but-absent components as dimmed lines.
	ShowAbsent bool
	// DefaultOpen sets the initial expanded state of each component panel.
	DefaultOpen bool
	// Fallback renders a present component that no renderer claims — a consumer
	// wires this to the generic Table2CardEmitter. Nil renders a short note.
	Fallback func(ids *c.WidgetIdStack, comp Component)
	// contains filtered or unexported fields
}

Dispatcher renders one entity's components as a collapsible single-record report: a foldable panel per registered component present on the entity, optionally a dimmed line per registered-but-absent component (so the archetype is legible at a glance), and a generic fallback panel for any present component no renderer claims.

func NewDispatcher

func NewDispatcher(reg *Registry) (inst *Dispatcher)

func (*Dispatcher) RenderReport

func (inst *Dispatcher) RenderReport(ids *c.WidgetIdStack, comps []Component)

RenderReport draws the report for one entity's decoded components. Collapse state is keyed by component kind, so it survives clicking through records.

type IdentityVal

type IdentityVal struct{ Status string }

IdentityVal, BatteryVal and TaskedVal are the decoded carriers the seed renderers expect. Tasked is tags-only for now — its time window (timeRange) is deferred together with the timeline widget (stage-2 defers timeRange).

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry holds the per-kind renderers in a stable registration order, which is also the report's rendering order.

func DefaultRegistry

func DefaultRegistry() (inst *Registry)

DefaultRegistry returns a Registry seeded with the light-version drone renderers in archetype order: identity, battery, tasked.

func NewRegistry

func NewRegistry() (inst *Registry)

func (*Registry) Register

func (inst *Registry) Register(rend RendererI)

Register adds (or replaces) the renderer for its kind. First registration of a kind fixes its slot in the rendering order.

type RendererI

type RendererI interface {
	Kind() ComponentKindE
	Title() string
	Render(ids *c.WidgetIdStack, value any)
}

RendererI draws one component kind from its decoded value. Implementations type-assert value to their own carrier.

type TaskedVal

type TaskedVal struct{ Tags []string }

IdentityVal, BatteryVal and TaskedVal are the decoded carriers the seed renderers expect. Tasked is tags-only for now — its time window (timeRange) is deferred together with the timeline widget (stage-2 defers timeRange).

Jump to

Keyboard shortcuts

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