Files
nebula/pkg/wa/details_templ.go

501 lines
18 KiB
Go
Raw Normal View History

2026-01-01 14:41:31 -05:00
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.977
// Code generated by wa-generator. DO NOT EDIT.
// Source: Web Awesome wa-details
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"
)
// Details show a brief summary and expand to show additional content.
//
// Web Awesome component: <wa-details>
// DetailsProps holds all properties for the wa-details component
type DetailsProps struct {
// Indicates whether or not the details is open. You can toggle this attribute to show and hide the details, or you
Open bool `attr:"open"`
// The summary to show in the header. If you need to display HTML, use the summary slot instead.
Summary string `attr:"summary"`
// Groups related details elements. When one opens, others with the same name will close.
Name string `attr:"name"`
// Disables the details so it can't be toggled.
Disabled bool `attr:"disabled"`
// The element's visual appearance.
// Valid values: "filled", "outlined", "filled-outlined", "plain"
Appearance string `attr:"appearance"`
// The location of the expand/collapse icon.
// Valid values: "start", "end"
IconPlacement string `attr:"icon-placement"`
// Events
// Emitted when the details opens.
OnShow string `attr:"x-on:wa-show"`
// Emitted after the details opens and all animations are complete.
OnAfterShow string `attr:"x-on:wa-after-show"`
// Emitted when the details closes.
OnHide string `attr:"x-on:wa-hide"`
// Emitted after the details closes and all animations are complete.
OnAfterHide string `attr:"x-on:wa-after-hide"`
// Slots contains named slot content
Slots DetailsSlots
// Attrs contains additional HTML attributes
Attrs templ.Attributes
}
// DetailsSlots holds named slot content for the component
type DetailsSlots struct {
// The details' summary. Alternatively, you can use the summary attribute.
Summary templ.Component
// Optional expand icon to use instead of the default. Works best with <wa-icon>.
ExpandIcon templ.Component
// Optional collapse icon to use instead of the default. Works best with <wa-icon>.
CollapseIcon templ.Component
}
// DetailsBuilder provides a fluent API for constructing DetailsProps
type DetailsBuilder struct {
props DetailsProps
}
// NewDetails creates a new builder for wa-details
func NewDetails() *DetailsBuilder {
return &DetailsBuilder{}
}
// Open sets the open attribute
// Indicates whether or not the details is open. You can toggle this attribute to show and hide the details, or you
func (b *DetailsBuilder) Open(v bool) *DetailsBuilder {
b.props.Open = v
return b
}
// Summary sets the summary attribute
// The summary to show in the header. If you need to display HTML, use the summary slot instead.
func (b *DetailsBuilder) Summary(v string) *DetailsBuilder {
b.props.Summary = v
return b
}
// Name sets the name attribute
// Groups related details elements. When one opens, others with the same name will close.
func (b *DetailsBuilder) Name(v string) *DetailsBuilder {
b.props.Name = v
return b
}
// Disabled sets the disabled attribute
// Disables the details so it can't be toggled.
func (b *DetailsBuilder) Disabled(v bool) *DetailsBuilder {
b.props.Disabled = v
return b
}
// Appearance sets the appearance attribute
// The element's visual appearance.
func (b *DetailsBuilder) Appearance(v string) *DetailsBuilder {
b.props.Appearance = v
return b
}
// IconPlacement sets the icon-placement attribute
// The location of the expand/collapse icon.
func (b *DetailsBuilder) IconPlacement(v string) *DetailsBuilder {
b.props.IconPlacement = v
return b
}
// OnShow sets the handler for wa-show event
// Emitted when the details opens.
func (b *DetailsBuilder) OnShow(handler string) *DetailsBuilder {
b.props.OnShow = handler
return b
}
// OnAfterShow sets the handler for wa-after-show event
// Emitted after the details opens and all animations are complete.
func (b *DetailsBuilder) OnAfterShow(handler string) *DetailsBuilder {
b.props.OnAfterShow = handler
return b
}
// OnHide sets the handler for wa-hide event
// Emitted when the details closes.
func (b *DetailsBuilder) OnHide(handler string) *DetailsBuilder {
b.props.OnHide = handler
return b
}
// OnAfterHide sets the handler for wa-after-hide event
// Emitted after the details closes and all animations are complete.
func (b *DetailsBuilder) OnAfterHide(handler string) *DetailsBuilder {
b.props.OnAfterHide = handler
return b
}
// SummarySlot sets the summary slot content
// The details' summary. Alternatively, you can use the summary attribute.
func (b *DetailsBuilder) SummarySlot(c templ.Component) *DetailsBuilder {
b.props.Slots.Summary = c
return b
}
// ExpandIconSlot sets the expand-icon slot content
// Optional expand icon to use instead of the default. Works best with <wa-icon>.
func (b *DetailsBuilder) ExpandIconSlot(c templ.Component) *DetailsBuilder {
b.props.Slots.ExpandIcon = c
return b
}
// CollapseIconSlot sets the collapse-icon slot content
// Optional collapse icon to use instead of the default. Works best with <wa-icon>.
func (b *DetailsBuilder) CollapseIconSlot(c templ.Component) *DetailsBuilder {
b.props.Slots.CollapseIcon = c
return b
}
// Attr adds a custom HTML attribute
func (b *DetailsBuilder) Attr(name, value string) *DetailsBuilder {
if b.props.Attrs == nil {
b.props.Attrs = templ.Attributes{}
}
b.props.Attrs[name] = value
return b
}
// Attrs merges multiple attributes
func (b *DetailsBuilder) Attrs(attrs templ.Attributes) *DetailsBuilder {
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 *DetailsBuilder) Props() DetailsProps {
return b.props
}
// Build returns the props (alias for Props for semantic clarity)
func (b *DetailsBuilder) Build() DetailsProps {
return b.props
}
// Details renders the wa-details component
func Details(props DetailsProps) 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-details")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if props.Open {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, " open")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Summary != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, " summary=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(props.Summary)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/details.templ`, Line: 196, Col: 26}
}
_, 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, 4, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Name != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, " name=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(props.Name)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/details.templ`, Line: 199, Col: 20}
}
_, 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, 6, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Disabled {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, " disabled")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Appearance != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, " appearance=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(props.Appearance)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/details.templ`, Line: 205, Col: 32}
}
_, 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, 9, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.IconPlacement != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, " icon-placement=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(props.IconPlacement)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/details.templ`, Line: 208, Col: 39}
}
_, 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, 11, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.OnShow != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, " x-on:wa-show=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnShow)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/details.templ`, Line: 211, Col: 30}
}
_, 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, 13, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.OnAfterShow != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, " x-on:wa-after-show=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnAfterShow)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/details.templ`, Line: 214, Col: 41}
}
_, 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, 15, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.OnHide != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, " x-on:wa-hide=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var8 string
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnHide)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/details.templ`, Line: 217, Col: 30}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
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
}
}
if props.OnAfterHide != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, " x-on:wa-after-hide=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnAfterHide)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/details.templ`, Line: 220, Col: 41}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "\"")
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, 20, ">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if props.Slots.Summary != nil {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "<div slot=\"summary\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = props.Slots.Summary.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
}
}
if props.Slots.ExpandIcon != nil {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "<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, 24, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Slots.CollapseIcon != nil {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "<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, 26, "</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, 27, "</wa-details>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
// DetailsFunc renders with a builder function for inline configuration
func DetailsFunc(fn func(*DetailsBuilder)) 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_Var10 := templ.GetChildren(ctx)
if templ_7745c5c3_Var10 == nil {
templ_7745c5c3_Var10 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
b := NewDetails()
fn(b)
templ_7745c5c3_Var11 := 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_Var10.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = Details(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var11), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate