// Code generated by templ - DO NOT EDIT. // templ: version: v0.3.960 // Code generated by wa-generator. DO NOT EDIT. // Source: Web Awesome wa-slider 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" ) // Ranges allow the user to select a single value within a given range using a slider. // // Web Awesome component: // SliderProps holds all properties for the wa-slider component type SliderProps struct { // The slider's label. If you need to provide HTML in the label, use the label slot instead. Label string `attr:"label"` // The slider hint. If you need to display HTML, use the hint slot instead. Hint string `attr:"hint"` // The name of the slider. This will be submitted with the form as a name/value pair. Name string `attr:"name"` // The minimum value of a range selection. Used only when range attribute is set. MinValue float64 `attr:"min-value"` // The maximum value of a range selection. Used only when range attribute is set. MaxValue float64 `attr:"max-value"` // The default value of the form control. Primarily used for resetting the form control. Value float64 `attr:"value"` // Converts the slider to a range slider with two thumbs. Range bool `attr:"range"` // Disables the slider. Disabled bool `attr:"disabled"` // Makes the slider a read-only field. Readonly bool `attr:"readonly"` // The orientation of the slider. // Valid values: "horizontal", "vertical" Orientation string `attr:"orientation"` // The slider's size. // Valid values: "small", "medium", "large" Size string `attr:"size"` // The starting value from which to draw the slider's fill, which is based on its current value. IndicatorOffset float64 `attr:"indicator-offset"` // The minimum value allowed. Min float64 `attr:"min"` // The maximum value allowed. Max float64 `attr:"max"` // The granularity the value must adhere to when incrementing and decrementing. Step float64 `attr:"step"` // Makes the slider a required field. Required bool `attr:"required"` // Tells the browser to focus the slider when the page loads or a dialog is shown. Autofocus bool `attr:"autofocus"` // The distance of the tooltip from the slider's thumb. TooltipDistance float64 `attr:"tooltip-distance"` // The placement of the tooltip in reference to the slider's thumb. // Valid values: "top", "right", "bottom", "left" TooltipPlacement string `attr:"tooltip-placement"` // Draws markers at each step along the slider. WithMarkers bool `attr:"with-markers"` // Draws a tooltip above the thumb when the control has focus or is dragged. WithTooltip bool `attr:"with-tooltip"` // Events // Emitted when an alteration to the control's value is committed by the user. OnChange string `attr:"x-on:change"` // Emitted when the control loses focus. OnBlur string `attr:"x-on:blur"` // Emitted when the control gains focus. OnFocus string `attr:"x-on:focus"` // Emitted when the control 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 SliderSlots // Attrs contains additional HTML attributes Attrs templ.Attributes } // SliderSlots holds named slot content for the component type SliderSlots struct { // The slider label. Alternatively, you can use the label attribute. Label templ.Component // Text that describes how to use the input. Alternatively, you can use the hint attribute. instead. Hint templ.Component // One or more reference labels to show visually below the slider. Reference templ.Component } // SliderBuilder provides a fluent API for constructing SliderProps type SliderBuilder struct { props SliderProps } // NewSlider creates a new builder for wa-slider func NewSlider() *SliderBuilder { return &SliderBuilder{} } // Label sets the label attribute // The slider's label. If you need to provide HTML in the label, use the label slot instead. func (b *SliderBuilder) Label(v string) *SliderBuilder { b.props.Label = v return b } // Hint sets the hint attribute // The slider hint. If you need to display HTML, use the hint slot instead. func (b *SliderBuilder) Hint(v string) *SliderBuilder { b.props.Hint = v return b } // Name sets the name attribute // The name of the slider. This will be submitted with the form as a name/value pair. func (b *SliderBuilder) Name(v string) *SliderBuilder { b.props.Name = v return b } // MinValue sets the min-value attribute // The minimum value of a range selection. Used only when range attribute is set. func (b *SliderBuilder) MinValue(v float64) *SliderBuilder { b.props.MinValue = v return b } // MaxValue sets the max-value attribute // The maximum value of a range selection. Used only when range attribute is set. func (b *SliderBuilder) MaxValue(v float64) *SliderBuilder { b.props.MaxValue = v return b } // Value sets the value attribute // The default value of the form control. Primarily used for resetting the form control. func (b *SliderBuilder) Value(v float64) *SliderBuilder { b.props.Value = v return b } // Range sets the range attribute // Converts the slider to a range slider with two thumbs. func (b *SliderBuilder) Range(v bool) *SliderBuilder { b.props.Range = v return b } // Disabled sets the disabled attribute // Disables the slider. func (b *SliderBuilder) Disabled(v bool) *SliderBuilder { b.props.Disabled = v return b } // Readonly sets the readonly attribute // Makes the slider a read-only field. func (b *SliderBuilder) Readonly(v bool) *SliderBuilder { b.props.Readonly = v return b } // Orientation sets the orientation attribute // The orientation of the slider. func (b *SliderBuilder) Orientation(v string) *SliderBuilder { b.props.Orientation = v return b } // Size sets the size attribute // The slider's size. func (b *SliderBuilder) Size(v string) *SliderBuilder { b.props.Size = v return b } // IndicatorOffset sets the indicator-offset attribute // The starting value from which to draw the slider's fill, which is based on its current value. func (b *SliderBuilder) IndicatorOffset(v float64) *SliderBuilder { b.props.IndicatorOffset = v return b } // Min sets the min attribute // The minimum value allowed. func (b *SliderBuilder) Min(v float64) *SliderBuilder { b.props.Min = v return b } // Max sets the max attribute // The maximum value allowed. func (b *SliderBuilder) Max(v float64) *SliderBuilder { b.props.Max = v return b } // Step sets the step attribute // The granularity the value must adhere to when incrementing and decrementing. func (b *SliderBuilder) Step(v float64) *SliderBuilder { b.props.Step = v return b } // Required sets the required attribute // Makes the slider a required field. func (b *SliderBuilder) Required(v bool) *SliderBuilder { b.props.Required = v return b } // Autofocus sets the autofocus attribute // Tells the browser to focus the slider when the page loads or a dialog is shown. func (b *SliderBuilder) Autofocus(v bool) *SliderBuilder { b.props.Autofocus = v return b } // TooltipDistance sets the tooltip-distance attribute // The distance of the tooltip from the slider's thumb. func (b *SliderBuilder) TooltipDistance(v float64) *SliderBuilder { b.props.TooltipDistance = v return b } // TooltipPlacement sets the tooltip-placement attribute // The placement of the tooltip in reference to the slider's thumb. func (b *SliderBuilder) TooltipPlacement(v string) *SliderBuilder { b.props.TooltipPlacement = v return b } // WithMarkers sets the with-markers attribute // Draws markers at each step along the slider. func (b *SliderBuilder) WithMarkers(v bool) *SliderBuilder { b.props.WithMarkers = v return b } // WithTooltip sets the with-tooltip attribute // Draws a tooltip above the thumb when the control has focus or is dragged. func (b *SliderBuilder) WithTooltip(v bool) *SliderBuilder { b.props.WithTooltip = v return b } // OnChange sets the handler for change event // Emitted when an alteration to the control's value is committed by the user. func (b *SliderBuilder) OnChange(handler string) *SliderBuilder { b.props.OnChange = handler return b } // OnBlur sets the handler for blur event // Emitted when the control loses focus. func (b *SliderBuilder) OnBlur(handler string) *SliderBuilder { b.props.OnBlur = handler return b } // OnFocus sets the handler for focus event // Emitted when the control gains focus. func (b *SliderBuilder) OnFocus(handler string) *SliderBuilder { b.props.OnFocus = handler return b } // OnInput sets the handler for input event // Emitted when the control receives input. func (b *SliderBuilder) OnInput(handler string) *SliderBuilder { 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 *SliderBuilder) OnInvalid(handler string) *SliderBuilder { b.props.OnInvalid = handler return b } // LabelSlot sets the label slot content // The slider label. Alternatively, you can use the label attribute. func (b *SliderBuilder) LabelSlot(c templ.Component) *SliderBuilder { b.props.Slots.Label = c return b } // HintSlot sets the hint slot content // Text that describes how to use the input. Alternatively, you can use the hint attribute. instead. func (b *SliderBuilder) HintSlot(c templ.Component) *SliderBuilder { b.props.Slots.Hint = c return b } // ReferenceSlot sets the reference slot content // One or more reference labels to show visually below the slider. func (b *SliderBuilder) ReferenceSlot(c templ.Component) *SliderBuilder { b.props.Slots.Reference = c return b } // Attr adds a custom HTML attribute func (b *SliderBuilder) Attr(name, value string) *SliderBuilder { if b.props.Attrs == nil { b.props.Attrs = templ.Attributes{} } b.props.Attrs[name] = value return b } // Attrs merges multiple attributes func (b *SliderBuilder) Attrs(attrs templ.Attributes) *SliderBuilder { 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 *SliderBuilder) Props() SliderProps { return b.props } // Build returns the props (alias for Props for semantic clarity) func (b *SliderBuilder) Build() SliderProps { return b.props } // Slider renders the wa-slider component func Slider(props SliderProps) 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, 48, "
") 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, 49, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } if props.Slots.Hint != nil { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, "
") 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, 51, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } if props.Slots.Reference != nil { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 52, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = props.Slots.Reference.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 53, "
") 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, 54, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } // SliderFunc renders with a builder function for inline configuration func SliderFunc(fn func(*SliderBuilder)) 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 := NewSlider() 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 = Slider(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