package components import "strconv" // TextInputProps defines properties for text inputs type TextInputProps struct { Name string Value string Placeholder string Required bool Class string Type string // "text", "email", "url", etc. Defaults to "text" } // TextInput renders a text input field templ TextInput(props TextInputProps) { } // Helper function to get input type, defaults to "text" func getInputType(t string) string { if t == "" { return "text" } return t } // NumberInputProps defines properties for number inputs type NumberInputProps struct { Name string Value string Placeholder string Required bool Step string Min string Max string Class string } // NumberInput renders a number input field templ NumberInput(props NumberInputProps) { } // TextAreaProps defines properties for textarea inputs type TextAreaProps struct { Name string Value string Placeholder string Required bool Rows int Class string } // TextArea renders a textarea input field templ TextArea(props TextAreaProps) { } // Helper function to get rows attribute func getRowsAttr(rows int) string { if rows <= 0 { return "3" } return strconv.Itoa(rows) } // SelectOption represents an option in a select dropdown type SelectOption struct { Value string Label string Selected bool } // SelectProps defines properties for select dropdowns type SelectProps struct { Name string Options []SelectOption Placeholder string Required bool Class string } // Select renders a select dropdown templ Select(props SelectProps) { } // FormFieldProps defines properties for a complete form field (label + input + helper) type FormFieldProps struct { Label string HelperText string Required bool } // FormField wraps a form input with label and helper text templ FormField(props FormFieldProps, input templ.Component) {
{ props.HelperText }
}