450 lines
15 KiB
Go
450 lines
15 KiB
Go
// 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: <wa-tree-item>
|
|
|
|
// 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, "<wa-tree-item")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
if props.Expanded {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, " expanded")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
}
|
|
if props.Selected {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, " selected")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
}
|
|
if props.Disabled {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, " disabled")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
}
|
|
if props.Lazy {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, " lazy")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
}
|
|
if props.OnExpand != "" {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, " x-on:wa-expand=\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
var templ_7745c5c3_Var2 string
|
|
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnExpand)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/tree-item.templ`, Line: 194, Col: 34}
|
|
}
|
|
_, 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, 7, "\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
}
|
|
if props.OnAfterExpand != "" {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, " x-on:wa-after-expand=\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
var templ_7745c5c3_Var3 string
|
|
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnAfterExpand)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/tree-item.templ`, Line: 197, Col: 45}
|
|
}
|
|
_, 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, 9, "\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
}
|
|
if props.OnCollapse != "" {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, " x-on:wa-collapse=\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
var templ_7745c5c3_Var4 string
|
|
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnCollapse)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/tree-item.templ`, Line: 200, Col: 38}
|
|
}
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
}
|
|
if props.OnAfterCollapse != "" {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, " x-on:wa-after-collapse=\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
var templ_7745c5c3_Var5 string
|
|
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnAfterCollapse)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/tree-item.templ`, Line: 203, Col: 49}
|
|
}
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
}
|
|
if props.OnLazyChange != "" {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, " x-on:wa-lazy-change=\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
var templ_7745c5c3_Var6 string
|
|
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnLazyChange)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/tree-item.templ`, Line: 206, Col: 43}
|
|
}
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
}
|
|
if props.OnLazyLoad != "" {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, " x-on:wa-lazy-load=\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
var templ_7745c5c3_Var7 string
|
|
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnLazyLoad)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/tree-item.templ`, Line: 209, Col: 39}
|
|
}
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "\"")
|
|
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, 18, ">")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
if props.Slots.ExpandIcon != nil {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "<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, 20, "</div>")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
}
|
|
if props.Slots.CollapseIcon != nil {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "<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, 22, "</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, 23, "</wa-tree-item>")
|
|
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
|