// Code generated by templ - DO NOT EDIT. // templ: version: v0.3.924 // templui component calendar - version: v0.84.0 installed by templui v0.84.0 package calendar //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 ( "git.jmbit.de/jmb/scanfile/server/web/templui/components/icon" "git.jmbit.de/jmb/scanfile/server/web/templui/utils" "strconv" "time" ) type LocaleTag string var ( LocaleDefaultTag = LocaleTag("en-US") LocaleTagChinese = LocaleTag("zh-CN") LocaleTagFrench = LocaleTag("fr-FR") LocaleTagGerman = LocaleTag("de-DE") LocaleTagItalian = LocaleTag("it-IT") LocaleTagJapanese = LocaleTag("ja-JP") LocaleTagPortuguese = LocaleTag("pt-PT") LocaleTagSpanish = LocaleTag("es-ES") ) type Props struct { ID string Class string LocaleTag LocaleTag Value *time.Time Name string InitialMonth int // Optional: 0-11 (Default: current or from Value). Controls the initially displayed month view. InitialYear int // Optional: (Default: current or from Value). Controls the initially displayed year view. } func Calendar(props ...Props) 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) var p Props if len(props) > 0 { p = props[0] } if p.ID == "" { p.ID = utils.RandomID() + "-calendar" } if p.Name == "" { // Should be provided by parent (e.g., DatePicker or in standalone usage) p.Name = p.ID + "-value" // Fallback name } if p.LocaleTag == "" { p.LocaleTag = LocaleDefaultTag } initialView := time.Now() if p.Value != nil { initialView = *p.Value } initialMonth := p.InitialMonth initialYear := p.InitialYear // Use year from initialView if InitialYear prop is invalid/unset (<= 0) if initialYear <= 0 { initialYear = initialView.Year() } // Use month from initialView if InitialMonth prop is invalid OR // if InitialMonth is default 0 AND InitialYear was also defaulted (meaning neither was likely set explicitly) if (initialMonth < 0 || initialMonth > 11) || (initialMonth == 0 && p.InitialYear <= 0) { initialMonth = int(initialView.Month()) - 1 // time.Month is 1-12 } initialSelectedISO := "" if p.Value != nil { initialSelectedISO = p.Value.Format("2006-01-02") } var templ_7745c5c3_Var2 = []any{p.Class} templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var2...) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } func Script() 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_Var13 := templ.GetChildren(ctx) if templ_7745c5c3_Var13 == nil { templ_7745c5c3_Var13 = templ.NopComponent } ctx = templ.ClearChildren(ctx) templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } var _ = templruntime.GeneratedTemplate