Files
nebula/pkg/wa/format-number_templ.go

441 lines
16 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-format-number
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"
)
// Formats a number using the specified locale and options.
//
// Web Awesome component: <wa-format-number>
// FormatNumberProps holds all properties for the wa-format-number component
type FormatNumberProps struct {
// The number to format.
Value float64 `attr:"value"`
// The formatting style to use.
// Valid values: "currency", "decimal", "percent"
Type string `attr:"type"`
// Turns off grouping separators.
WithoutGrouping bool `attr:"without-grouping"`
// The ISO 4217 currency code to use when formatting.
Currency string `attr:"currency"`
// How to display the currency.
// Valid values: "symbol", "narrowSymbol", "code", "name"
CurrencyDisplay string `attr:"currency-display"`
// The minimum number of integer digits to use. Possible values are 1-21.
MinimumIntegerDigits float64 `attr:"minimum-integer-digits"`
// The minimum number of fraction digits to use. Possible values are 0-100.
MinimumFractionDigits float64 `attr:"minimum-fraction-digits"`
// The maximum number of fraction digits to use. Possible values are 0-100.
MaximumFractionDigits float64 `attr:"maximum-fraction-digits"`
// The minimum number of significant digits to use. Possible values are 1-21.
MinimumSignificantDigits float64 `attr:"minimum-significant-digits"`
// The maximum number of significant digits to use,. Possible values are 1-21.
MaximumSignificantDigits float64 `attr:"maximum-significant-digits"`
// Events
// Slots contains named slot content
Slots FormatNumberSlots
// Attrs contains additional HTML attributes
Attrs templ.Attributes
}
// FormatNumberBuilder provides a fluent API for constructing FormatNumberProps
type FormatNumberBuilder struct {
props FormatNumberProps
}
// NewFormatNumber creates a new builder for wa-format-number
func NewFormatNumber() *FormatNumberBuilder {
return &FormatNumberBuilder{}
}
// Value sets the value attribute
// The number to format.
func (b *FormatNumberBuilder) Value(v float64) *FormatNumberBuilder {
b.props.Value = v
return b
}
// Type sets the type attribute
// The formatting style to use.
func (b *FormatNumberBuilder) Type(v string) *FormatNumberBuilder {
b.props.Type = v
return b
}
// WithoutGrouping sets the without-grouping attribute
// Turns off grouping separators.
func (b *FormatNumberBuilder) WithoutGrouping(v bool) *FormatNumberBuilder {
b.props.WithoutGrouping = v
return b
}
// Currency sets the currency attribute
// The ISO 4217 currency code to use when formatting.
func (b *FormatNumberBuilder) Currency(v string) *FormatNumberBuilder {
b.props.Currency = v
return b
}
// CurrencyDisplay sets the currency-display attribute
// How to display the currency.
func (b *FormatNumberBuilder) CurrencyDisplay(v string) *FormatNumberBuilder {
b.props.CurrencyDisplay = v
return b
}
// MinimumIntegerDigits sets the minimum-integer-digits attribute
// The minimum number of integer digits to use. Possible values are 1-21.
func (b *FormatNumberBuilder) MinimumIntegerDigits(v float64) *FormatNumberBuilder {
b.props.MinimumIntegerDigits = v
return b
}
// MinimumFractionDigits sets the minimum-fraction-digits attribute
// The minimum number of fraction digits to use. Possible values are 0-100.
func (b *FormatNumberBuilder) MinimumFractionDigits(v float64) *FormatNumberBuilder {
b.props.MinimumFractionDigits = v
return b
}
// MaximumFractionDigits sets the maximum-fraction-digits attribute
// The maximum number of fraction digits to use. Possible values are 0-100.
func (b *FormatNumberBuilder) MaximumFractionDigits(v float64) *FormatNumberBuilder {
b.props.MaximumFractionDigits = v
return b
}
// MinimumSignificantDigits sets the minimum-significant-digits attribute
// The minimum number of significant digits to use. Possible values are 1-21.
func (b *FormatNumberBuilder) MinimumSignificantDigits(v float64) *FormatNumberBuilder {
b.props.MinimumSignificantDigits = v
return b
}
// MaximumSignificantDigits sets the maximum-significant-digits attribute
// The maximum number of significant digits to use,. Possible values are 1-21.
func (b *FormatNumberBuilder) MaximumSignificantDigits(v float64) *FormatNumberBuilder {
b.props.MaximumSignificantDigits = v
return b
}
// Attr adds a custom HTML attribute
func (b *FormatNumberBuilder) Attr(name, value string) *FormatNumberBuilder {
if b.props.Attrs == nil {
b.props.Attrs = templ.Attributes{}
}
b.props.Attrs[name] = value
return b
}
// Attrs merges multiple attributes
func (b *FormatNumberBuilder) Attrs(attrs templ.Attributes) *FormatNumberBuilder {
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 *FormatNumberBuilder) Props() FormatNumberProps {
return b.props
}
// Build returns the props (alias for Props for semantic clarity)
func (b *FormatNumberBuilder) Build() FormatNumberProps {
return b.props
}
// FormatNumber renders the wa-format-number component
func FormatNumber(props FormatNumberProps) 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-format-number")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if props.Value != 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, " value=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(templ.Sprintf("%v", props.Value))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/format-number.templ`, Line: 162, Col: 43}
}
_, 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.Type != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, " type=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(props.Type)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/format-number.templ`, Line: 165, 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.WithoutGrouping {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, " without-grouping")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Currency != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, " currency=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(props.Currency)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/format-number.templ`, Line: 171, Col: 28}
}
_, 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, 8, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.CurrencyDisplay != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, " currency-display=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(props.CurrencyDisplay)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/format-number.templ`, Line: 174, Col: 43}
}
_, 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.MinimumIntegerDigits != 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, " minimum-integer-digits=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(templ.Sprintf("%v", props.MinimumIntegerDigits))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/format-number.templ`, Line: 177, Col: 75}
}
_, 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.MinimumFractionDigits != 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, " minimum-fraction-digits=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(templ.Sprintf("%v", props.MinimumFractionDigits))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/format-number.templ`, Line: 180, Col: 77}
}
_, 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.MaximumFractionDigits != 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, " maximum-fraction-digits=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var8 string
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(templ.Sprintf("%v", props.MaximumFractionDigits))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/format-number.templ`, Line: 183, Col: 77}
}
_, 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, 16, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.MinimumSignificantDigits != 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, " minimum-significant-digits=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(templ.Sprintf("%v", props.MinimumSignificantDigits))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/format-number.templ`, Line: 186, Col: 83}
}
_, 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, 18, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.MaximumSignificantDigits != 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, " maximum-significant-digits=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var10 string
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(templ.Sprintf("%v", props.MaximumSignificantDigits))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/format-number.templ`, Line: 189, Col: 83}
}
_, 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, 20, "\"")
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, 21, ">")
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, 22, "</wa-format-number>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
// FormatNumberFunc renders with a builder function for inline configuration
func FormatNumberFunc(fn func(*FormatNumberBuilder)) 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 := NewFormatNumber()
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 = FormatNumber(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