//! Form components with WCAG 2.2 AA accessibility. use leptos::prelude::*; /// Text input field with label. #[component] pub fn TextInput( name: &'static str, label: &'static str, #[prop(default = "text")] input_type: &'static str, #[prop(optional)] placeholder: &'static str, #[prop(optional)] help_text: &'static str, #[prop(default = false)] required: bool, #[prop(optional)] minlength: Option, #[prop(optional)] maxlength: Option, #[prop(optional)] pattern: &'static str, #[prop(optional)] autocomplete: &'static str, #[prop(optional)] class: &'static str, #[prop(into)] value: Signal, on_input: Callback, ) -> impl IntoView { let input_id = name; let help_id = format!("{}-help", name); let has_help = !help_text.is_empty(); view! {
{if has_help { view! {

{help_text}

}.into_any() } else { view! {}.into_any() }}
} } /// Textarea field with label. #[component] pub fn TextArea( name: &'static str, label: &'static str, #[prop(optional)] placeholder: &'static str, #[prop(optional)] help_text: &'static str, #[prop(default = false)] required: bool, #[prop(default = 3)] rows: i32, #[prop(optional)] class: &'static str, #[prop(into)] value: Signal, on_input: Callback, ) -> impl IntoView { let input_id = name; let help_id = format!("{}-help", name); let has_help = !help_text.is_empty(); view! {