Files
nebula/pkg/wa/radio-group_templ.go

536 lines
19 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-radio-group
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"
)
// Radio groups are used to group multiple radios so they function as a single form control.
//
// Web Awesome component: <wa-radio-group>
// RadioGroupProps holds all properties for the wa-radio-group component
type RadioGroupProps struct {
// The radio group's label. Required for proper accessibility. If you need to display HTML, use the label slot
Label string `attr:"label"`
// The radio groups's hint. If you need to display HTML, use the hint slot instead.
Hint string `attr:"hint"`
// The name of the radio group, submitted as a name/value pair with form data.
Name string `attr:"name"`
// Disables the radio group and all child radios.
Disabled bool `attr:"disabled"`
// The orientation in which to show radio items.
// Valid values: "horizontal", "vertical"
Orientation string `attr:"orientation"`
// The default value of the form control. Primarily used for resetting the form control.
Value string `attr:"value"`
// The radio group's size. This size will be applied to all child radios and radio buttons, except when explicitly overr...
// Valid values: "small", "medium", "large"
Size string `attr:"size"`
// Ensures a child radio is checked before allowing the containing form to submit.
Required bool `attr:"required"`
// Used for SSR. if true, will show slotted label on initial render.
WithLabel bool `attr:"with-label"`
// Used for SSR. if true, will show slotted hint on initial render.
WithHint bool `attr:"with-hint"`
// Events
// Emitted when the radio group receives user input.
OnInput string `attr:"x-on:input"`
// Emitted when the radio group's selected value changes.
OnChange string `attr:"x-on:change"`
// 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 RadioGroupSlots
// Attrs contains additional HTML attributes
Attrs templ.Attributes
}
// RadioGroupSlots holds named slot content for the component
type RadioGroupSlots struct {
// The radio group's label. Required for proper accessibility. Alternatively, you can use the label attribute.
Label templ.Component
// Text that describes how to use the radio group. Alternatively, you can use the hint attribute.
Hint templ.Component
}
// RadioGroupBuilder provides a fluent API for constructing RadioGroupProps
type RadioGroupBuilder struct {
props RadioGroupProps
}
// NewRadioGroup creates a new builder for wa-radio-group
func NewRadioGroup() *RadioGroupBuilder {
return &RadioGroupBuilder{}
}
// Label sets the label attribute
// The radio group's label. Required for proper accessibility. If you need to display HTML, use the label slot
func (b *RadioGroupBuilder) Label(v string) *RadioGroupBuilder {
b.props.Label = v
return b
}
// Hint sets the hint attribute
// The radio groups's hint. If you need to display HTML, use the hint slot instead.
func (b *RadioGroupBuilder) Hint(v string) *RadioGroupBuilder {
b.props.Hint = v
return b
}
// Name sets the name attribute
// The name of the radio group, submitted as a name/value pair with form data.
func (b *RadioGroupBuilder) Name(v string) *RadioGroupBuilder {
b.props.Name = v
return b
}
// Disabled sets the disabled attribute
// Disables the radio group and all child radios.
func (b *RadioGroupBuilder) Disabled(v bool) *RadioGroupBuilder {
b.props.Disabled = v
return b
}
// Orientation sets the orientation attribute
// The orientation in which to show radio items.
func (b *RadioGroupBuilder) Orientation(v string) *RadioGroupBuilder {
b.props.Orientation = v
return b
}
// Value sets the value attribute
// The default value of the form control. Primarily used for resetting the form control.
func (b *RadioGroupBuilder) Value(v string) *RadioGroupBuilder {
b.props.Value = v
return b
}
// Size sets the size attribute
// The radio group's size. This size will be applied to all child radios and radio buttons, except when explicitly overr...
func (b *RadioGroupBuilder) Size(v string) *RadioGroupBuilder {
b.props.Size = v
return b
}
// Required sets the required attribute
// Ensures a child radio is checked before allowing the containing form to submit.
func (b *RadioGroupBuilder) Required(v bool) *RadioGroupBuilder {
b.props.Required = v
return b
}
// WithLabel sets the with-label attribute
// Used for SSR. if true, will show slotted label on initial render.
func (b *RadioGroupBuilder) WithLabel(v bool) *RadioGroupBuilder {
b.props.WithLabel = v
return b
}
// WithHint sets the with-hint attribute
// Used for SSR. if true, will show slotted hint on initial render.
func (b *RadioGroupBuilder) WithHint(v bool) *RadioGroupBuilder {
b.props.WithHint = v
return b
}
// OnInput sets the handler for input event
// Emitted when the radio group receives user input.
func (b *RadioGroupBuilder) OnInput(handler string) *RadioGroupBuilder {
b.props.OnInput = handler
return b
}
// OnChange sets the handler for change event
// Emitted when the radio group's selected value changes.
func (b *RadioGroupBuilder) OnChange(handler string) *RadioGroupBuilder {
b.props.OnChange = 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 *RadioGroupBuilder) OnInvalid(handler string) *RadioGroupBuilder {
b.props.OnInvalid = handler
return b
}
// LabelSlot sets the label slot content
// The radio group's label. Required for proper accessibility. Alternatively, you can use the label attribute.
func (b *RadioGroupBuilder) LabelSlot(c templ.Component) *RadioGroupBuilder {
b.props.Slots.Label = c
return b
}
// HintSlot sets the hint slot content
// Text that describes how to use the radio group. Alternatively, you can use the hint attribute.
func (b *RadioGroupBuilder) HintSlot(c templ.Component) *RadioGroupBuilder {
b.props.Slots.Hint = c
return b
}
// Attr adds a custom HTML attribute
func (b *RadioGroupBuilder) Attr(name, value string) *RadioGroupBuilder {
if b.props.Attrs == nil {
b.props.Attrs = templ.Attributes{}
}
b.props.Attrs[name] = value
return b
}
// Attrs merges multiple attributes
func (b *RadioGroupBuilder) Attrs(attrs templ.Attributes) *RadioGroupBuilder {
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 *RadioGroupBuilder) Props() RadioGroupProps {
return b.props
}
// Build returns the props (alias for Props for semantic clarity)
func (b *RadioGroupBuilder) Build() RadioGroupProps {
return b.props
}
// RadioGroup renders the wa-radio-group component
func RadioGroup(props RadioGroupProps) 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-radio-group")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if props.Label != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, " label=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(props.Label)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/radio-group.templ`, Line: 211, Col: 22}
}
_, 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.Hint != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, " hint=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(props.Hint)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/radio-group.templ`, Line: 214, Col: 20}
}
_, 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.Name != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, " name=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(props.Name)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/radio-group.templ`, Line: 217, 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.Disabled {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, " disabled")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Orientation != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, " orientation=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(props.Orientation)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/radio-group.templ`, Line: 223, Col: 34}
}
_, 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.Value != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, " value=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(props.Value)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/radio-group.templ`, Line: 226, Col: 22}
}
_, 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.Size != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, " size=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(props.Size)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/radio-group.templ`, Line: 229, Col: 20}
}
_, 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.Required {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, " required")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.WithLabel {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, " with-label")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.WithHint {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, " with-hint")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.OnInput != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, " x-on:input=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var8 string
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnInput)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/radio-group.templ`, Line: 241, Col: 29}
}
_, 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, 19, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.OnChange != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, " x-on:change=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnChange)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/radio-group.templ`, Line: 244, Col: 31}
}
_, 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, 21, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.OnInvalid != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, " x-on:wa-invalid=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var10 string
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnInvalid)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/radio-group.templ`, Line: 247, Col: 36}
}
_, 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, 23, "\"")
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, 24, ">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if props.Slots.Label != nil {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "<div slot=\"label\">")
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, 26, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Slots.Hint != nil {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "<div slot=\"hint\">")
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, 28, "</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, 29, "</wa-radio-group>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
// RadioGroupFunc renders with a builder function for inline configuration
func RadioGroupFunc(fn func(*RadioGroupBuilder)) 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 := NewRadioGroup()
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 = RadioGroup(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