// Code generated by templ - DO NOT EDIT. // templ: version: v0.3.960 // Code generated by wa-generator. DO NOT EDIT. // Source: Web Awesome wa-checkbox 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" ) // Checkboxes allow the user to toggle an option on or off. // // Web Awesome component: // CheckboxProps holds all properties for the wa-checkbox component type CheckboxProps struct { // The name of the checkbox, submitted as a name/value pair with form data. Name string `attr:"name"` // The value of the checkbox, submitted as a name/value pair with form data. Value string `attr:"value"` // The checkbox's size. // Valid values: "small", "medium", "large" Size string `attr:"size"` // Disables the checkbox. Disabled bool `attr:"disabled"` // Draws the checkbox in an indeterminate state. This is usually applied to checkboxes that represents a "select Indeterminate bool `attr:"indeterminate"` // The default value of the form control. Primarily used for resetting the form control. Checked bool `attr:"checked"` // Makes the checkbox a required field. Required bool `attr:"required"` // The checkbox's hint. If you need to display HTML, use the hint slot instead. Hint string `attr:"hint"` // Events // Emitted when the checked state changes. OnChange string `attr:"x-on:change"` // Emitted when the checkbox loses focus. OnBlur string `attr:"x-on:blur"` // Emitted when the checkbox gains focus. OnFocus string `attr:"x-on:focus"` // Emitted when the checkbox receives input. OnInput string `attr:"x-on:input"` // 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 CheckboxSlots // Attrs contains additional HTML attributes Attrs templ.Attributes } // CheckboxSlots holds named slot content for the component type CheckboxSlots struct { // Text that describes how to use the checkbox. Alternatively, you can use the hint attribute. Hint templ.Component } // CheckboxBuilder provides a fluent API for constructing CheckboxProps type CheckboxBuilder struct { props CheckboxProps } // NewCheckbox creates a new builder for wa-checkbox func NewCheckbox() *CheckboxBuilder { return &CheckboxBuilder{} } // Name sets the name attribute // The name of the checkbox, submitted as a name/value pair with form data. func (b *CheckboxBuilder) Name(v string) *CheckboxBuilder { b.props.Name = v return b } // Value sets the value attribute // The value of the checkbox, submitted as a name/value pair with form data. func (b *CheckboxBuilder) Value(v string) *CheckboxBuilder { b.props.Value = v return b } // Size sets the size attribute // The checkbox's size. func (b *CheckboxBuilder) Size(v string) *CheckboxBuilder { b.props.Size = v return b } // Disabled sets the disabled attribute // Disables the checkbox. func (b *CheckboxBuilder) Disabled(v bool) *CheckboxBuilder { b.props.Disabled = v return b } // Indeterminate sets the indeterminate attribute // Draws the checkbox in an indeterminate state. This is usually applied to checkboxes that represents a "select func (b *CheckboxBuilder) Indeterminate(v bool) *CheckboxBuilder { b.props.Indeterminate = v return b } // Checked sets the checked attribute // The default value of the form control. Primarily used for resetting the form control. func (b *CheckboxBuilder) Checked(v bool) *CheckboxBuilder { b.props.Checked = v return b } // Required sets the required attribute // Makes the checkbox a required field. func (b *CheckboxBuilder) Required(v bool) *CheckboxBuilder { b.props.Required = v return b } // Hint sets the hint attribute // The checkbox's hint. If you need to display HTML, use the hint slot instead. func (b *CheckboxBuilder) Hint(v string) *CheckboxBuilder { b.props.Hint = v return b } // OnChange sets the handler for change event // Emitted when the checked state changes. func (b *CheckboxBuilder) OnChange(handler string) *CheckboxBuilder { b.props.OnChange = handler return b } // OnBlur sets the handler for blur event // Emitted when the checkbox loses focus. func (b *CheckboxBuilder) OnBlur(handler string) *CheckboxBuilder { b.props.OnBlur = handler return b } // OnFocus sets the handler for focus event // Emitted when the checkbox gains focus. func (b *CheckboxBuilder) OnFocus(handler string) *CheckboxBuilder { b.props.OnFocus = handler return b } // OnInput sets the handler for input event // Emitted when the checkbox receives input. func (b *CheckboxBuilder) OnInput(handler string) *CheckboxBuilder { b.props.OnInput = 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 *CheckboxBuilder) OnInvalid(handler string) *CheckboxBuilder { b.props.OnInvalid = handler return b } // HintSlot sets the hint slot content // Text that describes how to use the checkbox. Alternatively, you can use the hint attribute. func (b *CheckboxBuilder) HintSlot(c templ.Component) *CheckboxBuilder { b.props.Slots.Hint = c return b } // Attr adds a custom HTML attribute func (b *CheckboxBuilder) Attr(name, value string) *CheckboxBuilder { if b.props.Attrs == nil { b.props.Attrs = templ.Attributes{} } b.props.Attrs[name] = value return b } // Attrs merges multiple attributes func (b *CheckboxBuilder) Attrs(attrs templ.Attributes) *CheckboxBuilder { 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 *CheckboxBuilder) Props() CheckboxProps { return b.props } // Build returns the props (alias for Props for semantic clarity) func (b *CheckboxBuilder) Build() CheckboxProps { return b.props } // Checkbox renders the wa-checkbox component func Checkbox(props CheckboxProps) 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.Hint != nil { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "
") 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, 26, "
") 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, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } // CheckboxFunc renders with a builder function for inline configuration func CheckboxFunc(fn func(*CheckboxBuilder)) 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 := NewCheckbox() 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 = Checkbox(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