// Code generated by wa-generator. DO NOT EDIT. // Source: Web Awesome wa-tree-item package wa import ( "github.com/a-h/templ" ) // A tree item serves as a hierarchical node that lives inside a tree. // // Web Awesome component: // TreeItemProps holds all properties for the wa-tree-item component type TreeItemProps struct { // Expands the tree item. Expanded bool `attr:"expanded"` // Draws the tree item in a selected state. Selected bool `attr:"selected"` // Disables the tree item. Disabled bool `attr:"disabled"` // Enables lazy loading behavior. Lazy bool `attr:"lazy"` // Events // Emitted when the tree item expands. OnExpand string `attr:"x-on:wa-expand"` // Emitted after the tree item expands and all animations are complete. OnAfterExpand string `attr:"x-on:wa-after-expand"` // Emitted when the tree item collapses. OnCollapse string `attr:"x-on:wa-collapse"` // Emitted after the tree item collapses and all animations are complete. OnAfterCollapse string `attr:"x-on:wa-after-collapse"` // Emitted when the tree item's lazy state changes. OnLazyChange string `attr:"x-on:wa-lazy-change"` // Emitted when a lazy item is selected. Use this event to asynchronously load data and append items to the tree before ... OnLazyLoad string `attr:"x-on:wa-lazy-load"` // Slots contains named slot content Slots TreeItemSlots // Attrs contains additional HTML attributes Attrs templ.Attributes } // TreeItemSlots holds named slot content for the component type TreeItemSlots struct { // The icon to show when the tree item is expanded. ExpandIcon templ.Component // The icon to show when the tree item is collapsed. CollapseIcon templ.Component } // TreeItemBuilder provides a fluent API for constructing TreeItemProps type TreeItemBuilder struct { props TreeItemProps } // NewTreeItem creates a new builder for wa-tree-item func NewTreeItem() *TreeItemBuilder { return &TreeItemBuilder{} } // Expanded sets the expanded attribute // Expands the tree item. func (b *TreeItemBuilder) Expanded(v bool) *TreeItemBuilder { b.props.Expanded = v return b } // Selected sets the selected attribute // Draws the tree item in a selected state. func (b *TreeItemBuilder) Selected(v bool) *TreeItemBuilder { b.props.Selected = v return b } // Disabled sets the disabled attribute // Disables the tree item. func (b *TreeItemBuilder) Disabled(v bool) *TreeItemBuilder { b.props.Disabled = v return b } // Lazy sets the lazy attribute // Enables lazy loading behavior. func (b *TreeItemBuilder) Lazy(v bool) *TreeItemBuilder { b.props.Lazy = v return b } // OnExpand sets the handler for wa-expand event // Emitted when the tree item expands. func (b *TreeItemBuilder) OnExpand(handler string) *TreeItemBuilder { b.props.OnExpand = handler return b } // OnAfterExpand sets the handler for wa-after-expand event // Emitted after the tree item expands and all animations are complete. func (b *TreeItemBuilder) OnAfterExpand(handler string) *TreeItemBuilder { b.props.OnAfterExpand = handler return b } // OnCollapse sets the handler for wa-collapse event // Emitted when the tree item collapses. func (b *TreeItemBuilder) OnCollapse(handler string) *TreeItemBuilder { b.props.OnCollapse = handler return b } // OnAfterCollapse sets the handler for wa-after-collapse event // Emitted after the tree item collapses and all animations are complete. func (b *TreeItemBuilder) OnAfterCollapse(handler string) *TreeItemBuilder { b.props.OnAfterCollapse = handler return b } // OnLazyChange sets the handler for wa-lazy-change event // Emitted when the tree item's lazy state changes. func (b *TreeItemBuilder) OnLazyChange(handler string) *TreeItemBuilder { b.props.OnLazyChange = handler return b } // OnLazyLoad sets the handler for wa-lazy-load event // Emitted when a lazy item is selected. Use this event to asynchronously load data and append items to the tree before ... func (b *TreeItemBuilder) OnLazyLoad(handler string) *TreeItemBuilder { b.props.OnLazyLoad = handler return b } // ExpandIconSlot sets the expand-icon slot content // The icon to show when the tree item is expanded. func (b *TreeItemBuilder) ExpandIconSlot(c templ.Component) *TreeItemBuilder { b.props.Slots.ExpandIcon = c return b } // CollapseIconSlot sets the collapse-icon slot content // The icon to show when the tree item is collapsed. func (b *TreeItemBuilder) CollapseIconSlot(c templ.Component) *TreeItemBuilder { b.props.Slots.CollapseIcon = c return b } // Attr adds a custom HTML attribute func (b *TreeItemBuilder) Attr(name, value string) *TreeItemBuilder { if b.props.Attrs == nil { b.props.Attrs = templ.Attributes{} } b.props.Attrs[name] = value return b } // Attrs merges multiple attributes func (b *TreeItemBuilder) Attrs(attrs templ.Attributes) *TreeItemBuilder { if b.props.Attrs == nil { b.props.Attrs = templ.Attributes{} } for k, v := range attrs { b.props.Attrs[k] = v } return b } // Props returns the built properties func (b *TreeItemBuilder) Props() TreeItemProps { return b.props } // Build returns the props (alias for Props for semantic clarity) func (b *TreeItemBuilder) Build() TreeItemProps { return b.props } // TreeItem renders the wa-tree-item component templ TreeItem(props TreeItemProps) { if props.Slots.ExpandIcon != nil {
@props.Slots.ExpandIcon
} if props.Slots.CollapseIcon != nil {
@props.Slots.CollapseIcon
} { children... }
} // TreeItemFunc renders with a builder function for inline configuration templ TreeItemFunc(fn func(*TreeItemBuilder)) { {{ b := NewTreeItem(); fn(b) }} @TreeItem(b.Props()) { { children... } } }