Files
nebula/pkg/wa/format-date.templ

236 lines
6.0 KiB
Plaintext
Raw Permalink Normal View History

2026-01-01 14:41:31 -05:00
// Code generated by wa-generator. DO NOT EDIT.
// Source: Web Awesome wa-format-date
package wa
import (
"github.com/a-h/templ"
)
// Formats a date/time using the specified locale and options.
//
// Web Awesome component: <wa-format-date>
// FormatDateProps holds all properties for the wa-format-date component
type FormatDateProps struct {
// The date/time to format. If not set, the current date and time will be used. When passing a string, it's strongly
Date string `attr:"date"`
// The format for displaying the weekday.
// Valid values: "narrow", "short", "long"
Weekday string `attr:"weekday"`
// The format for displaying the era.
// Valid values: "narrow", "short", "long"
Era string `attr:"era"`
// The format for displaying the year.
// Valid values: "numeric", "2-digit"
Year string `attr:"year"`
// The format for displaying the month.
// Valid values: "numeric", "2-digit", "narrow", "short", "long"
Month string `attr:"month"`
// The format for displaying the day.
// Valid values: "numeric", "2-digit"
Day string `attr:"day"`
// The format for displaying the hour.
// Valid values: "numeric", "2-digit"
Hour string `attr:"hour"`
// The format for displaying the minute.
// Valid values: "numeric", "2-digit"
Minute string `attr:"minute"`
// The format for displaying the second.
// Valid values: "numeric", "2-digit"
Second string `attr:"second"`
// The format for displaying the time.
// Valid values: "short", "long"
TimeZoneName string `attr:"time-zone-name"`
// The time zone to express the time in.
TimeZone string `attr:"time-zone"`
// The format for displaying the hour.
// Valid values: "auto", "12", "24"
HourFormat string `attr:"hour-format"`
// Events
// Slots contains named slot content
Slots FormatDateSlots
// Attrs contains additional HTML attributes
Attrs templ.Attributes
}
// FormatDateBuilder provides a fluent API for constructing FormatDateProps
type FormatDateBuilder struct {
props FormatDateProps
}
// NewFormatDate creates a new builder for wa-format-date
func NewFormatDate() *FormatDateBuilder {
return &FormatDateBuilder{}
}
// Date sets the date attribute
// The date/time to format. If not set, the current date and time will be used. When passing a string, it's strongly
func (b *FormatDateBuilder) Date(v string) *FormatDateBuilder {
b.props.Date = v
return b
}
// Weekday sets the weekday attribute
// The format for displaying the weekday.
func (b *FormatDateBuilder) Weekday(v string) *FormatDateBuilder {
b.props.Weekday = v
return b
}
// Era sets the era attribute
// The format for displaying the era.
func (b *FormatDateBuilder) Era(v string) *FormatDateBuilder {
b.props.Era = v
return b
}
// Year sets the year attribute
// The format for displaying the year.
func (b *FormatDateBuilder) Year(v string) *FormatDateBuilder {
b.props.Year = v
return b
}
// Month sets the month attribute
// The format for displaying the month.
func (b *FormatDateBuilder) Month(v string) *FormatDateBuilder {
b.props.Month = v
return b
}
// Day sets the day attribute
// The format for displaying the day.
func (b *FormatDateBuilder) Day(v string) *FormatDateBuilder {
b.props.Day = v
return b
}
// Hour sets the hour attribute
// The format for displaying the hour.
func (b *FormatDateBuilder) Hour(v string) *FormatDateBuilder {
b.props.Hour = v
return b
}
// Minute sets the minute attribute
// The format for displaying the minute.
func (b *FormatDateBuilder) Minute(v string) *FormatDateBuilder {
b.props.Minute = v
return b
}
// Second sets the second attribute
// The format for displaying the second.
func (b *FormatDateBuilder) Second(v string) *FormatDateBuilder {
b.props.Second = v
return b
}
// TimeZoneName sets the time-zone-name attribute
// The format for displaying the time.
func (b *FormatDateBuilder) TimeZoneName(v string) *FormatDateBuilder {
b.props.TimeZoneName = v
return b
}
// TimeZone sets the time-zone attribute
// The time zone to express the time in.
func (b *FormatDateBuilder) TimeZone(v string) *FormatDateBuilder {
b.props.TimeZone = v
return b
}
// HourFormat sets the hour-format attribute
// The format for displaying the hour.
func (b *FormatDateBuilder) HourFormat(v string) *FormatDateBuilder {
b.props.HourFormat = v
return b
}
// Attr adds a custom HTML attribute
func (b *FormatDateBuilder) Attr(name, value string) *FormatDateBuilder {
if b.props.Attrs == nil {
b.props.Attrs = templ.Attributes{}
}
b.props.Attrs[name] = value
return b
}
// Attrs merges multiple attributes
func (b *FormatDateBuilder) Attrs(attrs templ.Attributes) *FormatDateBuilder {
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 *FormatDateBuilder) Props() FormatDateProps {
return b.props
}
// Build returns the props (alias for Props for semantic clarity)
func (b *FormatDateBuilder) Build() FormatDateProps {
return b.props
}
// FormatDate renders the wa-format-date component
templ FormatDate(props FormatDateProps) {
<wa-format-date
if props.Date != "" {
date={ props.Date }
}
if props.Weekday != "" {
weekday={ props.Weekday }
}
if props.Era != "" {
era={ props.Era }
}
if props.Year != "" {
year={ props.Year }
}
if props.Month != "" {
month={ props.Month }
}
if props.Day != "" {
day={ props.Day }
}
if props.Hour != "" {
hour={ props.Hour }
}
if props.Minute != "" {
minute={ props.Minute }
}
if props.Second != "" {
second={ props.Second }
}
if props.TimeZoneName != "" {
time-zone-name={ props.TimeZoneName }
}
if props.TimeZone != "" {
time-zone={ props.TimeZone }
}
if props.HourFormat != "" {
hour-format={ props.HourFormat }
}
{ props.Attrs... }
>
{ children... }
</wa-format-date>
}
// FormatDateFunc renders with a builder function for inline configuration
templ FormatDateFunc(fn func(*FormatDateBuilder)) {
{{ b := NewFormatDate(); fn(b) }}
@FormatDate(b.Props()) {
{ children... }
}
}