Files
nebula/pkg/wa/dropdown_templ.go

468 lines
16 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-dropdown
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"
)
// Dropdowns display a list of options that can be triggered by a button or other element. They support
//
// Web Awesome component: <wa-dropdown>
// DropdownProps holds all properties for the wa-dropdown component
type DropdownProps struct {
// Opens or closes the dropdown.
Open bool `attr:"open"`
// The dropdown's size.
// Valid values: "small", "medium", "large"
Size string `attr:"size"`
// The placement of the dropdown menu in reference to the trigger. The menu will shift to a more optimal location if
// Valid values: "top", "top-start", "top-end", "bottom", "bottom-start", "bottom-end", "right", "right-start", "right-end", "left", "left-start", "left-end"
Placement string `attr:"placement"`
// The distance of the dropdown menu from its trigger.
Distance float64 `attr:"distance"`
// The offset of the dropdown menu along its trigger.
Skidding float64 `attr:"skidding"`
// Events
// Emitted when the dropdown is about to show.
OnShow string `attr:"x-on:wa-show"`
// Emitted after the dropdown has been shown.
OnAfterShow string `attr:"x-on:wa-after-show"`
// Emitted when the dropdown is about to hide.
OnHide string `attr:"x-on:wa-hide"`
// Emitted after the dropdown has been hidden.
OnAfterHide string `attr:"x-on:wa-after-hide"`
// Emitted when an item in the dropdown is selected.
OnSelect string `attr:"x-on:wa-select"`
// Slots contains named slot content
Slots DropdownSlots
// Attrs contains additional HTML attributes
Attrs templ.Attributes
}
// DropdownSlots holds named slot content for the component
type DropdownSlots struct {
// The element that triggers the dropdown, such as a <wa-button> or <button>.
Trigger templ.Component
}
// DropdownBuilder provides a fluent API for constructing DropdownProps
type DropdownBuilder struct {
props DropdownProps
}
// NewDropdown creates a new builder for wa-dropdown
func NewDropdown() *DropdownBuilder {
return &DropdownBuilder{}
}
// Open sets the open attribute
// Opens or closes the dropdown.
func (b *DropdownBuilder) Open(v bool) *DropdownBuilder {
b.props.Open = v
return b
}
// Size sets the size attribute
// The dropdown's size.
func (b *DropdownBuilder) Size(v string) *DropdownBuilder {
b.props.Size = v
return b
}
// Placement sets the placement attribute
// The placement of the dropdown menu in reference to the trigger. The menu will shift to a more optimal location if
func (b *DropdownBuilder) Placement(v string) *DropdownBuilder {
b.props.Placement = v
return b
}
// Distance sets the distance attribute
// The distance of the dropdown menu from its trigger.
func (b *DropdownBuilder) Distance(v float64) *DropdownBuilder {
b.props.Distance = v
return b
}
// Skidding sets the skidding attribute
// The offset of the dropdown menu along its trigger.
func (b *DropdownBuilder) Skidding(v float64) *DropdownBuilder {
b.props.Skidding = v
return b
}
// OnShow sets the handler for wa-show event
// Emitted when the dropdown is about to show.
func (b *DropdownBuilder) OnShow(handler string) *DropdownBuilder {
b.props.OnShow = handler
return b
}
// OnAfterShow sets the handler for wa-after-show event
// Emitted after the dropdown has been shown.
func (b *DropdownBuilder) OnAfterShow(handler string) *DropdownBuilder {
b.props.OnAfterShow = handler
return b
}
// OnHide sets the handler for wa-hide event
// Emitted when the dropdown is about to hide.
func (b *DropdownBuilder) OnHide(handler string) *DropdownBuilder {
b.props.OnHide = handler
return b
}
// OnAfterHide sets the handler for wa-after-hide event
// Emitted after the dropdown has been hidden.
func (b *DropdownBuilder) OnAfterHide(handler string) *DropdownBuilder {
b.props.OnAfterHide = handler
return b
}
// OnSelect sets the handler for wa-select event
// Emitted when an item in the dropdown is selected.
func (b *DropdownBuilder) OnSelect(handler string) *DropdownBuilder {
b.props.OnSelect = handler
return b
}
// TriggerSlot sets the trigger slot content
// The element that triggers the dropdown, such as a <wa-button> or <button>.
func (b *DropdownBuilder) TriggerSlot(c templ.Component) *DropdownBuilder {
b.props.Slots.Trigger = c
return b
}
// Attr adds a custom HTML attribute
func (b *DropdownBuilder) Attr(name, value string) *DropdownBuilder {
if b.props.Attrs == nil {
b.props.Attrs = templ.Attributes{}
}
b.props.Attrs[name] = value
return b
}
// Attrs merges multiple attributes
func (b *DropdownBuilder) Attrs(attrs templ.Attributes) *DropdownBuilder {
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 *DropdownBuilder) Props() DropdownProps {
return b.props
}
// Build returns the props (alias for Props for semantic clarity)
func (b *DropdownBuilder) Build() DropdownProps {
return b.props
}
// Dropdown renders the wa-dropdown component
func Dropdown(props DropdownProps) 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-dropdown")
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.Size != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, " size=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(props.Size)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/dropdown.templ`, Line: 178, Col: 20}
}
_, 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.Placement != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, " placement=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(props.Placement)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/dropdown.templ`, Line: 181, Col: 30}
}
_, 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.Distance != 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, " distance=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(templ.Sprintf("%v", props.Distance))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/dropdown.templ`, Line: 184, Col: 49}
}
_, 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, 8, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Skidding != 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, " skidding=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(templ.Sprintf("%v", props.Skidding))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/dropdown.templ`, Line: 187, 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, 10, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.OnShow != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, " 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/dropdown.templ`, Line: 190, 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, 12, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.OnAfterShow != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, " 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/dropdown.templ`, Line: 193, 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, 14, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.OnHide != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, " 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/dropdown.templ`, Line: 196, 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, 16, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.OnAfterHide != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, " 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/dropdown.templ`, Line: 199, 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, 18, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.OnSelect != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, " x-on:wa-select=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var10 string
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnSelect)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/dropdown.templ`, Line: 202, Col: 34}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
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
}
}
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, 21, ">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if props.Slots.Trigger != nil {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "<div slot=\"trigger\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = props.Slots.Trigger.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "</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, 24, "</wa-dropdown>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
// DropdownFunc renders with a builder function for inline configuration
func DropdownFunc(fn func(*DropdownBuilder)) 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_Var11 := templ.GetChildren(ctx)
if templ_7745c5c3_Var11 == nil {
templ_7745c5c3_Var11 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
b := NewDropdown()
fn(b)
templ_7745c5c3_Var12 := 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_Var11.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = Dropdown(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var12), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate