generated from mitchell/rust_template
97 lines
3.8 KiB
Rust
97 lines
3.8 KiB
Rust
mod grid_form;
|
|
|
|
use crate::{
|
|
controls::{
|
|
button::ButtonData, checkbox::CheckboxData, heading::HeadingData, hidden::HiddenData,
|
|
output::OutputData, radio_buttons::RadioButtonsData, select::SelectData,
|
|
slider::SliderData, spacer::SpacerData, stepper::StepperData, submit::SubmitData,
|
|
text_area::TextAreaData, text_input::TextInputData, ControlData, ControlRenderData,
|
|
},
|
|
FormToolData,
|
|
};
|
|
use leptos::{RwSignal, Signal, View};
|
|
|
|
pub use grid_form::{GridFormStyle, GridFormStylingAttributes};
|
|
|
|
pub trait FormStyle: 'static {
|
|
type StylingAttributes;
|
|
|
|
/// Render any containing components for the form.
|
|
///
|
|
/// This allows you to wrap all the form components
|
|
/// in another component if neccisary.
|
|
///
|
|
/// Do NOT wrap it in an actual `form` element; any
|
|
/// wrapping should be done with `div` or similar elements.
|
|
fn form_frame(&self, form: ControlRenderData<Self, View>) -> View;
|
|
fn heading(&self, control: ControlRenderData<Self, HeadingData>) -> View;
|
|
fn hidden(
|
|
&self,
|
|
control: ControlRenderData<Self, HiddenData>,
|
|
value_getter: Signal<String>,
|
|
) -> View;
|
|
fn text_input(
|
|
&self,
|
|
control: ControlRenderData<Self, TextInputData>,
|
|
value_getter: Signal<<TextInputData as ControlData>::ReturnType>,
|
|
value_setter: Box<dyn Fn(<TextInputData as ControlData>::ReturnType)>,
|
|
validation_state: Signal<Result<(), String>>,
|
|
) -> View;
|
|
fn text_area(
|
|
&self,
|
|
control: ControlRenderData<Self, TextAreaData>,
|
|
value_getter: Signal<<TextAreaData as ControlData>::ReturnType>,
|
|
value_setter: Box<dyn Fn(<TextAreaData as ControlData>::ReturnType)>,
|
|
validation_state: Signal<Result<(), String>>,
|
|
) -> View;
|
|
fn radio_buttons(
|
|
&self,
|
|
control: ControlRenderData<Self, RadioButtonsData>,
|
|
value_getter: Signal<<RadioButtonsData as ControlData>::ReturnType>,
|
|
value_setter: Box<dyn Fn(<RadioButtonsData as ControlData>::ReturnType)>,
|
|
validation_state: Signal<Result<(), String>>,
|
|
) -> View;
|
|
fn select(
|
|
&self,
|
|
control: ControlRenderData<Self, SelectData>,
|
|
value_getter: Signal<<SelectData as ControlData>::ReturnType>,
|
|
value_setter: Box<dyn Fn(<SelectData as ControlData>::ReturnType)>,
|
|
validation_state: Signal<Result<(), String>>,
|
|
) -> View;
|
|
fn button<FD: FormToolData>(
|
|
&self,
|
|
control: ControlRenderData<Self, ButtonData<FD>>,
|
|
data_signal: RwSignal<FD>,
|
|
) -> View;
|
|
fn checkbox(
|
|
&self,
|
|
control: ControlRenderData<Self, CheckboxData>,
|
|
value_getter: Signal<<CheckboxData as ControlData>::ReturnType>,
|
|
value_setter: Box<dyn Fn(<CheckboxData as ControlData>::ReturnType)>,
|
|
) -> View;
|
|
fn stepper(
|
|
&self,
|
|
control: ControlRenderData<Self, StepperData>,
|
|
value_getter: Signal<<StepperData as ControlData>::ReturnType>,
|
|
value_setter: Box<dyn Fn(<StepperData as ControlData>::ReturnType)>,
|
|
validation_state: Signal<Result<(), String>>,
|
|
) -> View;
|
|
fn output(
|
|
&self,
|
|
control: ControlRenderData<Self, OutputData>,
|
|
value_getter: Option<Signal<String>>,
|
|
) -> View;
|
|
fn slider(
|
|
&self,
|
|
control: ControlRenderData<Self, SliderData>,
|
|
value_getter: Signal<<SliderData as ControlData>::ReturnType>,
|
|
value_setter: Box<dyn Fn(<SliderData as ControlData>::ReturnType)>,
|
|
validation_state: Signal<Result<(), String>>,
|
|
) -> View;
|
|
fn submit(&self, control: ControlRenderData<Self, SubmitData>) -> View;
|
|
// TODO: test custom component
|
|
fn custom_component(&self, view: View) -> View;
|
|
fn group(&self, group: ControlRenderData<Self, View>) -> View;
|
|
fn spacer(&self, control: ControlRenderData<Self, SpacerData>) -> View;
|
|
}
|