// Code generated by templ - DO NOT EDIT. // templ: version: v0.3.960 // Code generated by wa-generator. DO NOT EDIT. // Source: Web Awesome wa-select 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" ) // Selects allow you to choose items from a menu of predefined options. // // Web Awesome component: // SelectProps holds all properties for the wa-select component type SelectProps struct { // The name of the select, submitted as a name/value pair with form data. Name string `attr:"name"` // The select's value. This will be a string for single select or an array for multi-select. Value string `attr:"value"` // The select's size. // Valid values: "small", "medium", "large" Size string `attr:"size"` // Placeholder text to show as a hint when the select is empty. Placeholder string `attr:"placeholder"` // Allows more than one option to be selected. Multiple bool `attr:"multiple"` // The maximum number of selected options to show when multiple is true. After the maximum, "+n" will be shown to MaxOptionsVisible float64 `attr:"max-options-visible"` // Disables the select control. Disabled bool `attr:"disabled"` // Adds a clear button when the select is not empty. WithClear bool `attr:"with-clear"` // Indicates whether or not the select is open. You can toggle this attribute to show and hide the menu, or you can Open bool `attr:"open"` // The select's visual appearance. // Valid values: "filled", "outlined", "filled-outlined" Appearance string `attr:"appearance"` // Draws a pill-style select with rounded edges. Pill bool `attr:"pill"` // The select's label. If you need to display HTML, use the label slot instead. Label string `attr:"label"` // The preferred placement of the select's menu. Note that the actual placement may vary as needed to keep the listbox // Valid values: "top", "bottom" Placement string `attr:"placement"` // The select's hint. If you need to display HTML, use the hint slot instead. Hint string `attr:"hint"` // Used for SSR purposes when a label is slotted in. Will show the label on first render. WithLabel bool `attr:"with-label"` // Used for SSR purposes when hint is slotted in. Will show the hint on first render. WithHint bool `attr:"with-hint"` // The select's required attribute. Required bool `attr:"required"` // Events // Emitted when the control receives input. OnInput string `attr:"x-on:input"` // Emitted when the control's value changes. OnChange string `attr:"x-on:change"` // Emitted when the control gains focus. OnFocus string `attr:"x-on:focus"` // Emitted when the control loses focus. OnBlur string `attr:"x-on:blur"` // Emitted when the control's value is cleared. OnClear string `attr:"x-on:wa-clear"` // Emitted when the select's menu opens. OnShow string `attr:"x-on:wa-show"` // Emitted after the select's menu opens and all animations are complete. OnAfterShow string `attr:"x-on:wa-after-show"` // Emitted when the select's menu closes. OnHide string `attr:"x-on:wa-hide"` // Emitted after the select's menu closes and all animations are complete. OnAfterHide string `attr:"x-on:wa-after-hide"` // Emitted when the form control has been checked for validity and its constraints aren't satisfied. OnInvalid string `attr:"x-on:wa-invalid"` // Slots contains named slot content Slots SelectSlots // Attrs contains additional HTML attributes Attrs templ.Attributes } // SelectSlots holds named slot content for the component type SelectSlots struct { // The input's label. Alternatively, you can use the label attribute. Label templ.Component // An element, such as , placed at the start of the combobox. Start templ.Component // An element, such as , placed at the end of the combobox. End templ.Component // An icon to use in lieu of the default clear icon. ClearIcon templ.Component // The icon to show when the control is expanded and collapsed. Rotates on open and close. ExpandIcon templ.Component // Text that describes how to use the input. Alternatively, you can use the hint attribute. Hint templ.Component } // SelectBuilder provides a fluent API for constructing SelectProps type SelectBuilder struct { props SelectProps } // NewSelect creates a new builder for wa-select func NewSelect() *SelectBuilder { return &SelectBuilder{} } // Name sets the name attribute // The name of the select, submitted as a name/value pair with form data. func (b *SelectBuilder) Name(v string) *SelectBuilder { b.props.Name = v return b } // Value sets the value attribute // The select's value. This will be a string for single select or an array for multi-select. func (b *SelectBuilder) Value(v string) *SelectBuilder { b.props.Value = v return b } // Size sets the size attribute // The select's size. func (b *SelectBuilder) Size(v string) *SelectBuilder { b.props.Size = v return b } // Placeholder sets the placeholder attribute // Placeholder text to show as a hint when the select is empty. func (b *SelectBuilder) Placeholder(v string) *SelectBuilder { b.props.Placeholder = v return b } // Multiple sets the multiple attribute // Allows more than one option to be selected. func (b *SelectBuilder) Multiple(v bool) *SelectBuilder { b.props.Multiple = v return b } // MaxOptionsVisible sets the max-options-visible attribute // The maximum number of selected options to show when multiple is true. After the maximum, "+n" will be shown to func (b *SelectBuilder) MaxOptionsVisible(v float64) *SelectBuilder { b.props.MaxOptionsVisible = v return b } // Disabled sets the disabled attribute // Disables the select control. func (b *SelectBuilder) Disabled(v bool) *SelectBuilder { b.props.Disabled = v return b } // WithClear sets the with-clear attribute // Adds a clear button when the select is not empty. func (b *SelectBuilder) WithClear(v bool) *SelectBuilder { b.props.WithClear = v return b } // Open sets the open attribute // Indicates whether or not the select is open. You can toggle this attribute to show and hide the menu, or you can func (b *SelectBuilder) Open(v bool) *SelectBuilder { b.props.Open = v return b } // Appearance sets the appearance attribute // The select's visual appearance. func (b *SelectBuilder) Appearance(v string) *SelectBuilder { b.props.Appearance = v return b } // Pill sets the pill attribute // Draws a pill-style select with rounded edges. func (b *SelectBuilder) Pill(v bool) *SelectBuilder { b.props.Pill = v return b } // Label sets the label attribute // The select's label. If you need to display HTML, use the label slot instead. func (b *SelectBuilder) Label(v string) *SelectBuilder { b.props.Label = v return b } // Placement sets the placement attribute // The preferred placement of the select's menu. Note that the actual placement may vary as needed to keep the listbox func (b *SelectBuilder) Placement(v string) *SelectBuilder { b.props.Placement = v return b } // Hint sets the hint attribute // The select's hint. If you need to display HTML, use the hint slot instead. func (b *SelectBuilder) Hint(v string) *SelectBuilder { b.props.Hint = v return b } // WithLabel sets the with-label attribute // Used for SSR purposes when a label is slotted in. Will show the label on first render. func (b *SelectBuilder) WithLabel(v bool) *SelectBuilder { b.props.WithLabel = v return b } // WithHint sets the with-hint attribute // Used for SSR purposes when hint is slotted in. Will show the hint on first render. func (b *SelectBuilder) WithHint(v bool) *SelectBuilder { b.props.WithHint = v return b } // Required sets the required attribute // The select's required attribute. func (b *SelectBuilder) Required(v bool) *SelectBuilder { b.props.Required = v return b } // OnInput sets the handler for input event // Emitted when the control receives input. func (b *SelectBuilder) OnInput(handler string) *SelectBuilder { b.props.OnInput = handler return b } // OnChange sets the handler for change event // Emitted when the control's value changes. func (b *SelectBuilder) OnChange(handler string) *SelectBuilder { b.props.OnChange = handler return b } // OnFocus sets the handler for focus event // Emitted when the control gains focus. func (b *SelectBuilder) OnFocus(handler string) *SelectBuilder { b.props.OnFocus = handler return b } // OnBlur sets the handler for blur event // Emitted when the control loses focus. func (b *SelectBuilder) OnBlur(handler string) *SelectBuilder { b.props.OnBlur = handler return b } // OnClear sets the handler for wa-clear event // Emitted when the control's value is cleared. func (b *SelectBuilder) OnClear(handler string) *SelectBuilder { b.props.OnClear = handler return b } // OnShow sets the handler for wa-show event // Emitted when the select's menu opens. func (b *SelectBuilder) OnShow(handler string) *SelectBuilder { b.props.OnShow = handler return b } // OnAfterShow sets the handler for wa-after-show event // Emitted after the select's menu opens and all animations are complete. func (b *SelectBuilder) OnAfterShow(handler string) *SelectBuilder { b.props.OnAfterShow = handler return b } // OnHide sets the handler for wa-hide event // Emitted when the select's menu closes. func (b *SelectBuilder) OnHide(handler string) *SelectBuilder { b.props.OnHide = handler return b } // OnAfterHide sets the handler for wa-after-hide event // Emitted after the select's menu closes and all animations are complete. func (b *SelectBuilder) OnAfterHide(handler string) *SelectBuilder { b.props.OnAfterHide = handler return b } // OnInvalid sets the handler for wa-invalid event // Emitted when the form control has been checked for validity and its constraints aren't satisfied. func (b *SelectBuilder) OnInvalid(handler string) *SelectBuilder { b.props.OnInvalid = handler return b } // LabelSlot sets the label slot content // The input's label. Alternatively, you can use the label attribute. func (b *SelectBuilder) LabelSlot(c templ.Component) *SelectBuilder { b.props.Slots.Label = c return b } // StartSlot sets the start slot content // An element, such as , placed at the start of the combobox. func (b *SelectBuilder) StartSlot(c templ.Component) *SelectBuilder { b.props.Slots.Start = c return b } // EndSlot sets the end slot content // An element, such as , placed at the end of the combobox. func (b *SelectBuilder) EndSlot(c templ.Component) *SelectBuilder { b.props.Slots.End = c return b } // ClearIconSlot sets the clear-icon slot content // An icon to use in lieu of the default clear icon. func (b *SelectBuilder) ClearIconSlot(c templ.Component) *SelectBuilder { b.props.Slots.ClearIcon = c return b } // ExpandIconSlot sets the expand-icon slot content // The icon to show when the control is expanded and collapsed. Rotates on open and close. func (b *SelectBuilder) ExpandIconSlot(c templ.Component) *SelectBuilder { b.props.Slots.ExpandIcon = c return b } // HintSlot sets the hint slot content // Text that describes how to use the input. Alternatively, you can use the hint attribute. func (b *SelectBuilder) HintSlot(c templ.Component) *SelectBuilder { b.props.Slots.Hint = c return b } // Attr adds a custom HTML attribute func (b *SelectBuilder) Attr(name, value string) *SelectBuilder { if b.props.Attrs == nil { b.props.Attrs = templ.Attributes{} } b.props.Attrs[name] = value return b } // Attrs merges multiple attributes func (b *SelectBuilder) Attrs(attrs templ.Attributes) *SelectBuilder { 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 *SelectBuilder) Props() SelectProps { return b.props } // Build returns the props (alias for Props for semantic clarity) func (b *SelectBuilder) Build() SelectProps { return b.props } // Select renders the wa-select component func Select(props SelectProps) 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.Label != nil { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = props.Slots.Label.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } if props.Slots.Start != nil { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 51, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = props.Slots.Start.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 52, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } if props.Slots.End != nil { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 53, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = props.Slots.End.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 54, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } if props.Slots.ClearIcon != nil { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 55, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = props.Slots.ClearIcon.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 56, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } if props.Slots.ExpandIcon != nil { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 57, "
") 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, 58, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } if props.Slots.Hint != nil { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 59, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = props.Slots.Hint.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 60, "
") 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, 61, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } // SelectFunc renders with a builder function for inline configuration func SelectFunc(fn func(*SelectBuilder)) 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_Var21 := templ.GetChildren(ctx) if templ_7745c5c3_Var21 == nil { templ_7745c5c3_Var21 = templ.NopComponent } ctx = templ.ClearChildren(ctx) b := NewSelect() fn(b) templ_7745c5c3_Var22 := 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_Var21.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) templ_7745c5c3_Err = Select(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var22), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } var _ = templruntime.GeneratedTemplate