use crate::core::*;
use crate::events::FormResetHandler;
use leptos::prelude::*;
#[component]
pub fn FormReset<T: Form + PartialEq + Clone + Send + Sync>(
form: FormHandle<T>,
#[prop(optional)] class: Option<String>,
#[prop(optional)] confirm_message: Option<String>,
children: Option<Children>,
) -> impl IntoView {
let button_class = class.unwrap_or_else(|| "form-reset".to_string());
let confirm_message =
confirm_message.unwrap_or_else(|| "Are you sure you want to reset the form?".to_string());
let reset_handler =
FormResetHandler::new(form.clone()).with_confirmation(confirm_message.clone());
view! {
<button
type="button"
class=button_class
on:click=reset_handler.handle_reset()
>
{if let Some(children) = children { children() } else { view! { <span></span> }.into_any() }}
</button>
}
}