// Code generated by templ - DO NOT EDIT. // templ: version: v0.3.960 // Code generated by wa-generator. DO NOT EDIT. // Source: Web Awesome wa-tree-item package wa //lint:file-ignore SA4006 This context is only used if a nested component is present. import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" 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 func TreeItem(props TreeItemProps) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) if templ_7745c5c3_Err == nil { templ_7745c5c3_Err = templ_7745c5c3_BufErr } }() } ctx = templ.InitializeContext(ctx) templ_7745c5c3_Var1 := templ.GetChildren(ctx) if templ_7745c5c3_Var1 == nil { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if props.Slots.ExpandIcon != nil { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = props.Slots.ExpandIcon.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } if props.Slots.CollapseIcon != nil { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = props.Slots.CollapseIcon.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } // TreeItemFunc renders with a builder function for inline configuration func TreeItemFunc(fn func(*TreeItemBuilder)) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) if templ_7745c5c3_Err == nil { templ_7745c5c3_Err = templ_7745c5c3_BufErr } }() } ctx = templ.InitializeContext(ctx) templ_7745c5c3_Var8 := templ.GetChildren(ctx) if templ_7745c5c3_Var8 == nil { templ_7745c5c3_Var8 = templ.NopComponent } ctx = templ.ClearChildren(ctx) b := NewTreeItem() fn(b) templ_7745c5c3_Var9 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) if templ_7745c5c3_Err == nil { templ_7745c5c3_Err = templ_7745c5c3_BufErr } }() } ctx = templ.InitializeContext(ctx) templ_7745c5c3_Err = templ_7745c5c3_Var8.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) templ_7745c5c3_Err = TreeItem(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var9), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } var _ = templruntime.GeneratedTemplate