204 lines
6.3 KiB
Plaintext
204 lines
6.3 KiB
Plaintext
// Code generated by wa-generator. DO NOT EDIT.
|
|
// Source: Web Awesome wa-format-number
|
|
|
|
package wa
|
|
|
|
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
|
|
templ FormatNumber(props FormatNumberProps) {
|
|
<wa-format-number
|
|
if props.Value != 0 {
|
|
value={ templ.Sprintf("%v", props.Value) }
|
|
}
|
|
if props.Type != "" {
|
|
type={ props.Type }
|
|
}
|
|
if props.WithoutGrouping {
|
|
without-grouping
|
|
}
|
|
if props.Currency != "" {
|
|
currency={ props.Currency }
|
|
}
|
|
if props.CurrencyDisplay != "" {
|
|
currency-display={ props.CurrencyDisplay }
|
|
}
|
|
if props.MinimumIntegerDigits != 0 {
|
|
minimum-integer-digits={ templ.Sprintf("%v", props.MinimumIntegerDigits) }
|
|
}
|
|
if props.MinimumFractionDigits != 0 {
|
|
minimum-fraction-digits={ templ.Sprintf("%v", props.MinimumFractionDigits) }
|
|
}
|
|
if props.MaximumFractionDigits != 0 {
|
|
maximum-fraction-digits={ templ.Sprintf("%v", props.MaximumFractionDigits) }
|
|
}
|
|
if props.MinimumSignificantDigits != 0 {
|
|
minimum-significant-digits={ templ.Sprintf("%v", props.MinimumSignificantDigits) }
|
|
}
|
|
if props.MaximumSignificantDigits != 0 {
|
|
maximum-significant-digits={ templ.Sprintf("%v", props.MaximumSignificantDigits) }
|
|
}
|
|
{ props.Attrs... }
|
|
>
|
|
{ children... }
|
|
</wa-format-number>
|
|
}
|
|
|
|
// FormatNumberFunc renders with a builder function for inline configuration
|
|
templ FormatNumberFunc(fn func(*FormatNumberBuilder)) {
|
|
{{ b := NewFormatNumber(); fn(b) }}
|
|
@FormatNumber(b.Props()) {
|
|
{ children... }
|
|
}
|
|
}
|