Files
nebula/pkg/wa/dropdown-item_templ.go

432 lines
15 KiB
Go
Raw Permalink Normal View History

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-dropdown-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"
)
// Represents an individual item within a dropdown menu, supporting standard items, checkboxes, and submenus.
//
// Web Awesome component: <wa-dropdown-item>
// DropdownItemProps holds all properties for the wa-dropdown-item component
type DropdownItemProps struct {
// The type of menu item to render.
// Valid values: "danger", "default"
Variant string `attr:"variant"`
// An optional value for the menu item. This is useful for determining which item was selected when listening to the
Value string `attr:"value"`
// Set to checkbox to make the item a checkbox.
// Valid values: "normal", "checkbox"
Type string `attr:"type"`
// Set to true to check the dropdown item. Only valid when type is checkbox.
Checked bool `attr:"checked"`
// Disables the dropdown item.
Disabled bool `attr:"disabled"`
// Whether the submenu is currently open.
SubmenuOpen bool `attr:"submenuOpen"`
// Events
// Emitted when the dropdown item loses focus.
OnBlur string `attr:"x-on:blur"`
// Emitted when the dropdown item gains focus.
OnFocus string `attr:"x-on:focus"`
// Slots contains named slot content
Slots DropdownItemSlots
// Attrs contains additional HTML attributes
Attrs templ.Attributes
}
// DropdownItemSlots holds named slot content for the component
type DropdownItemSlots struct {
// An optional icon to display before the label.
Icon templ.Component
// Additional content or details to display after the label.
Details templ.Component
// Submenu items, typically <wa-dropdown-item> elements, to create a nested menu.
Submenu templ.Component
}
// DropdownItemBuilder provides a fluent API for constructing DropdownItemProps
type DropdownItemBuilder struct {
props DropdownItemProps
}
// NewDropdownItem creates a new builder for wa-dropdown-item
func NewDropdownItem() *DropdownItemBuilder {
return &DropdownItemBuilder{}
}
// Variant sets the variant attribute
// The type of menu item to render.
func (b *DropdownItemBuilder) Variant(v string) *DropdownItemBuilder {
b.props.Variant = v
return b
}
// Value sets the value attribute
// An optional value for the menu item. This is useful for determining which item was selected when listening to the
func (b *DropdownItemBuilder) Value(v string) *DropdownItemBuilder {
b.props.Value = v
return b
}
// Type sets the type attribute
// Set to checkbox to make the item a checkbox.
func (b *DropdownItemBuilder) Type(v string) *DropdownItemBuilder {
b.props.Type = v
return b
}
// Checked sets the checked attribute
// Set to true to check the dropdown item. Only valid when type is checkbox.
func (b *DropdownItemBuilder) Checked(v bool) *DropdownItemBuilder {
b.props.Checked = v
return b
}
// Disabled sets the disabled attribute
// Disables the dropdown item.
func (b *DropdownItemBuilder) Disabled(v bool) *DropdownItemBuilder {
b.props.Disabled = v
return b
}
// SubmenuOpen sets the submenuOpen attribute
// Whether the submenu is currently open.
func (b *DropdownItemBuilder) SubmenuOpen(v bool) *DropdownItemBuilder {
b.props.SubmenuOpen = v
return b
}
// OnBlur sets the handler for blur event
// Emitted when the dropdown item loses focus.
func (b *DropdownItemBuilder) OnBlur(handler string) *DropdownItemBuilder {
b.props.OnBlur = handler
return b
}
// OnFocus sets the handler for focus event
// Emitted when the dropdown item gains focus.
func (b *DropdownItemBuilder) OnFocus(handler string) *DropdownItemBuilder {
b.props.OnFocus = handler
return b
}
// IconSlot sets the icon slot content
// An optional icon to display before the label.
func (b *DropdownItemBuilder) IconSlot(c templ.Component) *DropdownItemBuilder {
b.props.Slots.Icon = c
return b
}
// DetailsSlot sets the details slot content
// Additional content or details to display after the label.
func (b *DropdownItemBuilder) DetailsSlot(c templ.Component) *DropdownItemBuilder {
b.props.Slots.Details = c
return b
}
// SubmenuSlot sets the submenu slot content
// Submenu items, typically <wa-dropdown-item> elements, to create a nested menu.
func (b *DropdownItemBuilder) SubmenuSlot(c templ.Component) *DropdownItemBuilder {
b.props.Slots.Submenu = c
return b
}
// Attr adds a custom HTML attribute
func (b *DropdownItemBuilder) Attr(name, value string) *DropdownItemBuilder {
if b.props.Attrs == nil {
b.props.Attrs = templ.Attributes{}
}
b.props.Attrs[name] = value
return b
}
// Attrs merges multiple attributes
func (b *DropdownItemBuilder) Attrs(attrs templ.Attributes) *DropdownItemBuilder {
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 *DropdownItemBuilder) Props() DropdownItemProps {
return b.props
}
// Build returns the props (alias for Props for semantic clarity)
func (b *DropdownItemBuilder) Build() DropdownItemProps {
return b.props
}
// DropdownItem renders the wa-dropdown-item component
func DropdownItem(props DropdownItemProps) 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-item")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if props.Variant != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, " variant=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(props.Variant)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/dropdown-item.templ`, Line: 175, 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, 3, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Value != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, " value=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(props.Value)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/dropdown-item.templ`, Line: 178, Col: 22}
}
_, 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
}
}
if props.Type != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, " type=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(props.Type)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/dropdown-item.templ`, Line: 181, Col: 20}
}
_, 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, 7, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Checked {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, " checked")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Disabled {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, " disabled")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.SubmenuOpen {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, " submenuOpen")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.OnBlur != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, " x-on:blur=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnBlur)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/dropdown-item.templ`, Line: 193, Col: 27}
}
_, 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, 12, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.OnFocus != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, " x-on:focus=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnFocus)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/dropdown-item.templ`, Line: 196, Col: 29}
}
_, 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, 14, "\"")
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, 15, ">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if props.Slots.Icon != nil {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "<div slot=\"icon\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = props.Slots.Icon.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Slots.Details != nil {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "<div slot=\"details\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = props.Slots.Details.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Slots.Submenu != nil {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "<div slot=\"submenu\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = props.Slots.Submenu.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "</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, 22, "</wa-dropdown-item>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
// DropdownItemFunc renders with a builder function for inline configuration
func DropdownItemFunc(fn func(*DropdownItemBuilder)) 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_Var7 := templ.GetChildren(ctx)
if templ_7745c5c3_Var7 == nil {
templ_7745c5c3_Var7 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
b := NewDropdownItem()
fn(b)
templ_7745c5c3_Var8 := 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_Var7.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = DropdownItem(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var8), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate