// Code generated by templ - DO NOT EDIT. // templ: version: v0.3.960 // Code generated by wa-generator. DO NOT EDIT. // Source: Web Awesome wa-copy-button 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" ) // Copies text data to the clipboard when the user clicks the trigger. // // Web Awesome component: // CopyButtonProps holds all properties for the wa-copy-button component type CopyButtonProps struct { // The text value to copy. Value string `attr:"value"` // An id that references an element in the same document from which data will be copied. If both this and value are From string `attr:"from"` // Disables the copy button. Disabled bool `attr:"disabled"` // A custom label to show in the tooltip. CopyLabel string `attr:"copy-label"` // A custom label to show in the tooltip after copying. SuccessLabel string `attr:"success-label"` // A custom label to show in the tooltip when a copy error occurs. ErrorLabel string `attr:"error-label"` // The length of time to show feedback before restoring the default trigger. FeedbackDuration float64 `attr:"feedback-duration"` // The preferred placement of the tooltip. // Valid values: "top", "right", "bottom", "left" TooltipPlacement string `attr:"tooltip-placement"` // Events // Emitted when the data has been copied. OnCopy string `attr:"x-on:wa-copy"` // Emitted when the data could not be copied. OnError string `attr:"x-on:wa-error"` // Slots contains named slot content Slots CopyButtonSlots // Attrs contains additional HTML attributes Attrs templ.Attributes } // CopyButtonSlots holds named slot content for the component type CopyButtonSlots struct { // The icon to show in the default copy state. Works best with . CopyIcon templ.Component // The icon to show when the content is copied. Works best with . SuccessIcon templ.Component // The icon to show when a copy error occurs. Works best with . ErrorIcon templ.Component } // CopyButtonBuilder provides a fluent API for constructing CopyButtonProps type CopyButtonBuilder struct { props CopyButtonProps } // NewCopyButton creates a new builder for wa-copy-button func NewCopyButton() *CopyButtonBuilder { return &CopyButtonBuilder{} } // Value sets the value attribute // The text value to copy. func (b *CopyButtonBuilder) Value(v string) *CopyButtonBuilder { b.props.Value = v return b } // From sets the from attribute // An id that references an element in the same document from which data will be copied. If both this and value are func (b *CopyButtonBuilder) From(v string) *CopyButtonBuilder { b.props.From = v return b } // Disabled sets the disabled attribute // Disables the copy button. func (b *CopyButtonBuilder) Disabled(v bool) *CopyButtonBuilder { b.props.Disabled = v return b } // CopyLabel sets the copy-label attribute // A custom label to show in the tooltip. func (b *CopyButtonBuilder) CopyLabel(v string) *CopyButtonBuilder { b.props.CopyLabel = v return b } // SuccessLabel sets the success-label attribute // A custom label to show in the tooltip after copying. func (b *CopyButtonBuilder) SuccessLabel(v string) *CopyButtonBuilder { b.props.SuccessLabel = v return b } // ErrorLabel sets the error-label attribute // A custom label to show in the tooltip when a copy error occurs. func (b *CopyButtonBuilder) ErrorLabel(v string) *CopyButtonBuilder { b.props.ErrorLabel = v return b } // FeedbackDuration sets the feedback-duration attribute // The length of time to show feedback before restoring the default trigger. func (b *CopyButtonBuilder) FeedbackDuration(v float64) *CopyButtonBuilder { b.props.FeedbackDuration = v return b } // TooltipPlacement sets the tooltip-placement attribute // The preferred placement of the tooltip. func (b *CopyButtonBuilder) TooltipPlacement(v string) *CopyButtonBuilder { b.props.TooltipPlacement = v return b } // OnCopy sets the handler for wa-copy event // Emitted when the data has been copied. func (b *CopyButtonBuilder) OnCopy(handler string) *CopyButtonBuilder { b.props.OnCopy = handler return b } // OnError sets the handler for wa-error event // Emitted when the data could not be copied. func (b *CopyButtonBuilder) OnError(handler string) *CopyButtonBuilder { b.props.OnError = handler return b } // CopyIconSlot sets the copy-icon slot content // The icon to show in the default copy state. Works best with . func (b *CopyButtonBuilder) CopyIconSlot(c templ.Component) *CopyButtonBuilder { b.props.Slots.CopyIcon = c return b } // SuccessIconSlot sets the success-icon slot content // The icon to show when the content is copied. Works best with . func (b *CopyButtonBuilder) SuccessIconSlot(c templ.Component) *CopyButtonBuilder { b.props.Slots.SuccessIcon = c return b } // ErrorIconSlot sets the error-icon slot content // The icon to show when a copy error occurs. Works best with . func (b *CopyButtonBuilder) ErrorIconSlot(c templ.Component) *CopyButtonBuilder { b.props.Slots.ErrorIcon = c return b } // Attr adds a custom HTML attribute func (b *CopyButtonBuilder) Attr(name, value string) *CopyButtonBuilder { if b.props.Attrs == nil { b.props.Attrs = templ.Attributes{} } b.props.Attrs[name] = value return b } // Attrs merges multiple attributes func (b *CopyButtonBuilder) Attrs(attrs templ.Attributes) *CopyButtonBuilder { 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 *CopyButtonBuilder) Props() CopyButtonProps { return b.props } // Build returns the props (alias for Props for semantic clarity) func (b *CopyButtonBuilder) Build() CopyButtonProps { return b.props } // CopyButton renders the wa-copy-button component func CopyButton(props CopyButtonProps) 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.CopyIcon != nil { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = props.Slots.CopyIcon.Render(ctx, templ_7745c5c3_Buffer) 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 } } if props.Slots.SuccessIcon != nil { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = props.Slots.SuccessIcon.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } if props.Slots.ErrorIcon != nil { templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = props.Slots.ErrorIcon.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 } } 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, 28, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } // CopyButtonFunc renders with a builder function for inline configuration func CopyButtonFunc(fn func(*CopyButtonBuilder)) 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 := NewCopyButton() 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 = CopyButton(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