// templui component tabs - version: v0.84.0 installed by templui v0.84.0 package tabs import ( "context" "git.jmbit.de/jmb/scanfile/server/web/templui/utils" ) type Props struct { ID string Class string Attributes templ.Attributes } type ListProps struct { ID string Class string Attributes templ.Attributes } type TriggerProps struct { ID string Class string Attributes templ.Attributes Value string IsActive bool TabsID string } type ContentProps struct { ID string Class string Attributes templ.Attributes Value string IsActive bool TabsID string } templ Tabs(props ...Props) { {{ var p Props }} if len(props) > 0 { {{ p = props[0] }} } {{ tabsID := p.ID }} if tabsID == "" { {{ tabsID = utils.RandomID() }} }
{{ ctx = context.WithValue(ctx, "tabsId", tabsID) }} { children... }
} templ List(props ...ListProps) { {{ var p ListProps }} if len(props) > 0 { {{ p = props[0] }} } {{ tabsID := IDFromContext(ctx) }}
{ children... }
} templ Trigger(props ...TriggerProps) { {{ var p TriggerProps }} if len(props) > 0 { {{ p = props[0] }} } {{ tabsID := p.TabsID }} if tabsID == "" { {{ tabsID = IDFromContext(ctx) }} } if p.Value == "" { Error: Tab Trigger missing required 'Value' attribute. } } templ Content(props ...ContentProps) { {{ var p ContentProps }} if len(props) > 0 { {{ p = props[0] }} } {{ tabsID := p.TabsID }} if tabsID == "" { {{ tabsID = IDFromContext(ctx) }} } if p.Value == "" { Error: Tab Content missing required 'Value' attribute. return templ.NopComponent }
{ children... }
} func IDFromContext(ctx context.Context) string { if tabsID, ok := ctx.Value("tabsId").(string); ok { return tabsID } return "" } templ Script() { }