// Code generated by templ - DO NOT EDIT. // templ: version: v0.3.977 // 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: // 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 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 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, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if props.Slots.Icon != nil { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "
") 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, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } if props.Slots.Details != nil { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "
") 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, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } if props.Slots.Submenu != nil { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "
") 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, "
") 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, "
") 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