// Code generated by templ - DO NOT EDIT. // templ: version: v0.3.960 // Code generated by wa-generator. DO NOT EDIT. // Source: Web Awesome wa-color-picker 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" ) // Color pickers allow the user to select a color. // // Web Awesome component: // ColorPickerProps holds all properties for the wa-color-picker component type ColorPickerProps struct { // The default value of the form control. Primarily used for resetting the form control. Value string `attr:"value"` // WithLabel bool `attr:"with-label"` // WithHint bool `attr:"with-hint"` // The color picker's label. This will not be displayed, but it will be announced by assistive devices. If you need to Label string `attr:"label"` // The color picker's hint. If you need to display HTML, use the hint slot instead. Hint string `attr:"hint"` // The format to use. If opacity is enabled, these will translate to HEXA, RGBA, HSLA, and HSVA respectively. The color // Valid values: "hex", "rgb", "hsl", "hsv" Format string `attr:"format"` // Determines the size of the color picker's trigger // Valid values: "small", "medium", "large" Size string `attr:"size"` // Removes the button that lets users toggle between format. WithoutFormatToggle bool `attr:"without-format-toggle"` // The name of the form control, submitted as a name/value pair with form data. Name string `attr:"name"` // Disables the color picker. Disabled bool `attr:"disabled"` // Indicates whether or not the popup is open. You can toggle this attribute to show and hide the popup, or you Open bool `attr:"open"` // Shows the opacity slider. Enabling this will cause the formatted value to be HEXA, RGBA, or HSLA. Opacity bool `attr:"opacity"` // By default, values are lowercase. With this attribute, values will be uppercase instead. Uppercase bool `attr:"uppercase"` // One or more predefined color swatches to display as presets in the color picker. Can include any format the color Swatches string `attr:"swatches"` // Makes the color picker a required field. Required bool `attr:"required"` // Events // Emitted when the color picker's value changes. OnChange string `attr:"x-on:change"` // Emitted when the color picker receives input. OnInput string `attr:"x-on:input"` // OnShow string `attr:"x-on:wa-show"` // OnAfterShow string `attr:"x-on:wa-after-show"` // OnHide string `attr:"x-on:wa-hide"` // OnAfterHide string `attr:"x-on:wa-after-hide"` // Emitted when the color picker loses focus. OnBlur string `attr:"x-on:blur"` // Emitted when the color picker receives focus. OnFocus string `attr:"x-on:focus"` // 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 ColorPickerSlots // Attrs contains additional HTML attributes Attrs templ.Attributes } // ColorPickerSlots holds named slot content for the component type ColorPickerSlots struct { // The color picker's form label. Alternatively, you can use the label attribute. Label templ.Component // The color picker's form hint. Alternatively, you can use the hint attribute. Hint templ.Component } // ColorPickerBuilder provides a fluent API for constructing ColorPickerProps type ColorPickerBuilder struct { props ColorPickerProps } // NewColorPicker creates a new builder for wa-color-picker func NewColorPicker() *ColorPickerBuilder { return &ColorPickerBuilder{} } // Value sets the value attribute // The default value of the form control. Primarily used for resetting the form control. func (b *ColorPickerBuilder) Value(v string) *ColorPickerBuilder { b.props.Value = v return b } // WithLabel sets the with-label attribute func (b *ColorPickerBuilder) WithLabel(v bool) *ColorPickerBuilder { b.props.WithLabel = v return b } // WithHint sets the with-hint attribute func (b *ColorPickerBuilder) WithHint(v bool) *ColorPickerBuilder { b.props.WithHint = v return b } // Label sets the label attribute // The color picker's label. This will not be displayed, but it will be announced by assistive devices. If you need to func (b *ColorPickerBuilder) Label(v string) *ColorPickerBuilder { b.props.Label = v return b } // Hint sets the hint attribute // The color picker's hint. If you need to display HTML, use the hint slot instead. func (b *ColorPickerBuilder) Hint(v string) *ColorPickerBuilder { b.props.Hint = v return b } // Format sets the format attribute // The format to use. If opacity is enabled, these will translate to HEXA, RGBA, HSLA, and HSVA respectively. The color func (b *ColorPickerBuilder) Format(v string) *ColorPickerBuilder { b.props.Format = v return b } // Size sets the size attribute // Determines the size of the color picker's trigger func (b *ColorPickerBuilder) Size(v string) *ColorPickerBuilder { b.props.Size = v return b } // WithoutFormatToggle sets the without-format-toggle attribute // Removes the button that lets users toggle between format. func (b *ColorPickerBuilder) WithoutFormatToggle(v bool) *ColorPickerBuilder { b.props.WithoutFormatToggle = v return b } // Name sets the name attribute // The name of the form control, submitted as a name/value pair with form data. func (b *ColorPickerBuilder) Name(v string) *ColorPickerBuilder { b.props.Name = v return b } // Disabled sets the disabled attribute // Disables the color picker. func (b *ColorPickerBuilder) Disabled(v bool) *ColorPickerBuilder { b.props.Disabled = v return b } // Open sets the open attribute // Indicates whether or not the popup is open. You can toggle this attribute to show and hide the popup, or you func (b *ColorPickerBuilder) Open(v bool) *ColorPickerBuilder { b.props.Open = v return b } // Opacity sets the opacity attribute // Shows the opacity slider. Enabling this will cause the formatted value to be HEXA, RGBA, or HSLA. func (b *ColorPickerBuilder) Opacity(v bool) *ColorPickerBuilder { b.props.Opacity = v return b } // Uppercase sets the uppercase attribute // By default, values are lowercase. With this attribute, values will be uppercase instead. func (b *ColorPickerBuilder) Uppercase(v bool) *ColorPickerBuilder { b.props.Uppercase = v return b } // Swatches sets the swatches attribute // One or more predefined color swatches to display as presets in the color picker. Can include any format the color func (b *ColorPickerBuilder) Swatches(v string) *ColorPickerBuilder { b.props.Swatches = v return b } // Required sets the required attribute // Makes the color picker a required field. func (b *ColorPickerBuilder) Required(v bool) *ColorPickerBuilder { b.props.Required = v return b } // OnChange sets the handler for change event // Emitted when the color picker's value changes. func (b *ColorPickerBuilder) OnChange(handler string) *ColorPickerBuilder { b.props.OnChange = handler return b } // OnInput sets the handler for input event // Emitted when the color picker receives input. func (b *ColorPickerBuilder) OnInput(handler string) *ColorPickerBuilder { b.props.OnInput = handler return b } // OnShow sets the handler for wa-show event func (b *ColorPickerBuilder) OnShow(handler string) *ColorPickerBuilder { b.props.OnShow = handler return b } // OnAfterShow sets the handler for wa-after-show event func (b *ColorPickerBuilder) OnAfterShow(handler string) *ColorPickerBuilder { b.props.OnAfterShow = handler return b } // OnHide sets the handler for wa-hide event func (b *ColorPickerBuilder) OnHide(handler string) *ColorPickerBuilder { b.props.OnHide = handler return b } // OnAfterHide sets the handler for wa-after-hide event func (b *ColorPickerBuilder) OnAfterHide(handler string) *ColorPickerBuilder { b.props.OnAfterHide = handler return b } // OnBlur sets the handler for blur event // Emitted when the color picker loses focus. func (b *ColorPickerBuilder) OnBlur(handler string) *ColorPickerBuilder { b.props.OnBlur = handler return b } // OnFocus sets the handler for focus event // Emitted when the color picker receives focus. func (b *ColorPickerBuilder) OnFocus(handler string) *ColorPickerBuilder { b.props.OnFocus = 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 *ColorPickerBuilder) OnInvalid(handler string) *ColorPickerBuilder { b.props.OnInvalid = handler return b } // LabelSlot sets the label slot content // The color picker's form label. Alternatively, you can use the label attribute. func (b *ColorPickerBuilder) LabelSlot(c templ.Component) *ColorPickerBuilder { b.props.Slots.Label = c return b } // HintSlot sets the hint slot content // The color picker's form hint. Alternatively, you can use the hint attribute. func (b *ColorPickerBuilder) HintSlot(c templ.Component) *ColorPickerBuilder { b.props.Slots.Hint = c return b } // Attr adds a custom HTML attribute func (b *ColorPickerBuilder) Attr(name, value string) *ColorPickerBuilder { if b.props.Attrs == nil { b.props.Attrs = templ.Attributes{} } b.props.Attrs[name] = value return b } // Attrs merges multiple attributes func (b *ColorPickerBuilder) Attrs(attrs templ.Attributes) *ColorPickerBuilder { 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 *ColorPickerBuilder) Props() ColorPickerProps { return b.props } // Build returns the props (alias for Props for semantic clarity) func (b *ColorPickerBuilder) Build() ColorPickerProps { return b.props } // ColorPicker renders the wa-color-picker component func ColorPicker(props ColorPickerProps) 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, 43, "
") 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, 44, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } if props.Slots.Hint != nil { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 45, "
") 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, 46, "
") 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, 47, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } // ColorPickerFunc renders with a builder function for inline configuration func ColorPickerFunc(fn func(*ColorPickerBuilder)) 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_Var18 := templ.GetChildren(ctx) if templ_7745c5c3_Var18 == nil { templ_7745c5c3_Var18 = templ.NopComponent } ctx = templ.ClearChildren(ctx) b := NewColorPicker() fn(b) templ_7745c5c3_Var19 := 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_Var18.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) templ_7745c5c3_Err = ColorPicker(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var19), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } var _ = templruntime.GeneratedTemplate