2026-01-01 14:41:31 -05:00
|
|
|
// Code generated by templ - DO NOT EDIT.
|
|
|
|
|
|
2026-01-01 20:49:44 -05:00
|
|
|
// templ: version: v0.3.960
|
2026-01-01 14:41:31 -05:00
|
|
|
// Code generated by wa-generator. DO NOT EDIT.
|
|
|
|
|
|
|
|
|
|
// Source: Web Awesome wa-tree
|
|
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Trees allow you to display a hierarchical list of selectable tree items. Items with children can be expanded and coll...
|
|
|
|
|
//
|
|
|
|
|
// Web Awesome component: <wa-tree>
|
|
|
|
|
|
|
|
|
|
// TreeProps holds all properties for the wa-tree component
|
|
|
|
|
type TreeProps struct {
|
|
|
|
|
// The selection behavior of the tree. Single selection allows only one node to be selected at a time. Multiple
|
|
|
|
|
// Valid values: "single", "multiple", "leaf"
|
|
|
|
|
Selection string `attr:"selection"`
|
|
|
|
|
|
|
|
|
|
// Events
|
|
|
|
|
// Emitted when a tree item is selected or deselected.
|
|
|
|
|
OnSelectionChange string `attr:"x-on:wa-selection-change"`
|
|
|
|
|
|
|
|
|
|
// Slots contains named slot content
|
|
|
|
|
Slots TreeSlots
|
|
|
|
|
|
|
|
|
|
// Attrs contains additional HTML attributes
|
|
|
|
|
Attrs templ.Attributes
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TreeSlots holds named slot content for the component
|
|
|
|
|
type TreeSlots struct {
|
|
|
|
|
// The icon to show when the tree item is expanded. Works best with <wa-icon>.
|
|
|
|
|
ExpandIcon templ.Component
|
|
|
|
|
// The icon to show when the tree item is collapsed. Works best with <wa-icon>.
|
|
|
|
|
CollapseIcon templ.Component
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TreeBuilder provides a fluent API for constructing TreeProps
|
|
|
|
|
type TreeBuilder struct {
|
|
|
|
|
props TreeProps
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewTree creates a new builder for wa-tree
|
|
|
|
|
func NewTree() *TreeBuilder {
|
|
|
|
|
return &TreeBuilder{}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Selection sets the selection attribute
|
|
|
|
|
// The selection behavior of the tree. Single selection allows only one node to be selected at a time. Multiple
|
|
|
|
|
func (b *TreeBuilder) Selection(v string) *TreeBuilder {
|
|
|
|
|
b.props.Selection = v
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// OnSelectionChange sets the handler for wa-selection-change event
|
|
|
|
|
// Emitted when a tree item is selected or deselected.
|
|
|
|
|
func (b *TreeBuilder) OnSelectionChange(handler string) *TreeBuilder {
|
|
|
|
|
b.props.OnSelectionChange = handler
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ExpandIconSlot sets the expand-icon slot content
|
|
|
|
|
// The icon to show when the tree item is expanded. Works best with <wa-icon>.
|
|
|
|
|
func (b *TreeBuilder) ExpandIconSlot(c templ.Component) *TreeBuilder {
|
|
|
|
|
b.props.Slots.ExpandIcon = c
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CollapseIconSlot sets the collapse-icon slot content
|
|
|
|
|
// The icon to show when the tree item is collapsed. Works best with <wa-icon>.
|
|
|
|
|
func (b *TreeBuilder) CollapseIconSlot(c templ.Component) *TreeBuilder {
|
|
|
|
|
b.props.Slots.CollapseIcon = c
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Attr adds a custom HTML attribute
|
|
|
|
|
func (b *TreeBuilder) Attr(name, value string) *TreeBuilder {
|
|
|
|
|
if b.props.Attrs == nil {
|
|
|
|
|
b.props.Attrs = templ.Attributes{}
|
|
|
|
|
}
|
|
|
|
|
b.props.Attrs[name] = value
|
|
|
|
|
return b
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Attrs merges multiple attributes
|
|
|
|
|
func (b *TreeBuilder) Attrs(attrs templ.Attributes) *TreeBuilder {
|
|
|
|
|
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 *TreeBuilder) Props() TreeProps {
|
|
|
|
|
return b.props
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Build returns the props (alias for Props for semantic clarity)
|
|
|
|
|
func (b *TreeBuilder) Build() TreeProps {
|
|
|
|
|
return b.props
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Tree renders the wa-tree component
|
|
|
|
|
func Tree(props TreeProps) 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, "<wa-tree")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
if props.Selection != "" {
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, " selection=\"")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
var templ_7745c5c3_Var2 string
|
|
|
|
|
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(props.Selection)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/tree.templ`, Line: 111, Col: 30}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "\"")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if props.OnSelectionChange != "" {
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, " x-on:wa-selection-change=\"")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
var templ_7745c5c3_Var3 string
|
|
|
|
|
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnSelectionChange)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/tree.templ`, Line: 114, Col: 53}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "\"")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templ.RenderAttributes(ctx, templ_7745c5c3_Buffer, props.Attrs)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, ">")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
if props.Slots.ExpandIcon != nil {
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "<div slot=\"expand-icon\">")
|
|
|
|
|
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, 8, "</div>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if props.Slots.CollapseIcon != nil {
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "<div slot=\"collapse-icon\">")
|
|
|
|
|
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, 10, "</div>")
|
|
|
|
|
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, 11, "</wa-tree>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TreeFunc renders with a builder function for inline configuration
|
|
|
|
|
func TreeFunc(fn func(*TreeBuilder)) 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_Var4 := templ.GetChildren(ctx)
|
|
|
|
|
if templ_7745c5c3_Var4 == nil {
|
|
|
|
|
templ_7745c5c3_Var4 = templ.NopComponent
|
|
|
|
|
}
|
|
|
|
|
ctx = templ.ClearChildren(ctx)
|
|
|
|
|
b := NewTree()
|
|
|
|
|
fn(b)
|
|
|
|
|
templ_7745c5c3_Var5 := 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_Var4.Render(ctx, templ_7745c5c3_Buffer)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
})
|
|
|
|
|
templ_7745c5c3_Err = Tree(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var5), templ_7745c5c3_Buffer)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var _ = templruntime.GeneratedTemplate
|