generated from mitchell/rust_template
small rename
This commit is contained in:
parent
edc9c4d371
commit
2ee04ebfc3
@ -15,7 +15,7 @@ pub struct ButtonData<FD: FormToolData> {
|
|||||||
|
|
||||||
impl<FD: FormToolData> VanityControlData for ButtonData<FD> {
|
impl<FD: FormToolData> VanityControlData for ButtonData<FD> {
|
||||||
fn build_control<FS: FormStyle>(
|
fn build_control<FS: FormStyle>(
|
||||||
fs: &FS,
|
fs: &mut FS,
|
||||||
control: ControlRenderData<FS, Self>,
|
control: ControlRenderData<FS, Self>,
|
||||||
_value_getter: Option<Signal<String>>,
|
_value_getter: Option<Signal<String>>,
|
||||||
) -> View {
|
) -> View {
|
||||||
|
|||||||
@ -13,7 +13,7 @@ impl ControlData for CheckboxData {
|
|||||||
type ReturnType = bool;
|
type ReturnType = bool;
|
||||||
|
|
||||||
fn build_control<FS: FormStyle>(
|
fn build_control<FS: FormStyle>(
|
||||||
fs: &FS,
|
fs: &mut FS,
|
||||||
control: ControlRenderData<FS, Self>,
|
control: ControlRenderData<FS, Self>,
|
||||||
value_getter: Signal<Self::ReturnType>,
|
value_getter: Signal<Self::ReturnType>,
|
||||||
value_setter: Box<dyn Fn(Self::ReturnType)>,
|
value_setter: Box<dyn Fn(Self::ReturnType)>,
|
||||||
|
|||||||
@ -12,11 +12,11 @@ impl<FD: FormToolData, FS: FormStyle> FormBuilder<FD, FS> {
|
|||||||
self.validations.push(validation);
|
self.validations.push(validation);
|
||||||
}
|
}
|
||||||
|
|
||||||
let render_fn = move |fs: &FS, fd: RwSignal<FD>| {
|
let render_fn = move |fs: &mut FS, fd: RwSignal<FD>| {
|
||||||
let (views, validation_cbs): (Vec<_>, Vec<_>) = group_builder
|
let (views, validation_cbs): (Vec<_>, Vec<_>) = group_builder
|
||||||
.render_fns
|
.render_fns
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|r_fn| r_fn(&fs, fd))
|
.map(|r_fn| r_fn(fs, fd))
|
||||||
.unzip();
|
.unzip();
|
||||||
|
|
||||||
let view = fs.group(views.collect_view(), group_builder.styles);
|
let view = fs.group(views.collect_view(), group_builder.styles);
|
||||||
|
|||||||
@ -9,7 +9,7 @@ pub struct HeadingData {
|
|||||||
|
|
||||||
impl VanityControlData for HeadingData {
|
impl VanityControlData for HeadingData {
|
||||||
fn build_control<FS: FormStyle>(
|
fn build_control<FS: FormStyle>(
|
||||||
fs: &FS,
|
fs: &mut FS,
|
||||||
control: ControlRenderData<FS, Self>,
|
control: ControlRenderData<FS, Self>,
|
||||||
_value_getter: Option<leptos::prelude::Signal<String>>,
|
_value_getter: Option<leptos::prelude::Signal<String>>,
|
||||||
) -> View {
|
) -> View {
|
||||||
|
|||||||
@ -10,7 +10,7 @@ impl ControlData for HiddenData {
|
|||||||
type ReturnType = String;
|
type ReturnType = String;
|
||||||
|
|
||||||
fn build_control<FS: FormStyle>(
|
fn build_control<FS: FormStyle>(
|
||||||
fs: &FS,
|
fs: &mut FS,
|
||||||
control: ControlRenderData<FS, Self>,
|
control: ControlRenderData<FS, Self>,
|
||||||
value_getter: Signal<Self::ReturnType>,
|
value_getter: Signal<Self::ReturnType>,
|
||||||
_value_setter: Box<dyn Fn(Self::ReturnType)>,
|
_value_setter: Box<dyn Fn(Self::ReturnType)>,
|
||||||
|
|||||||
@ -23,7 +23,7 @@ pub trait UnparseFn<CR, FDT>: Fn(FDT) -> CR + 'static {}
|
|||||||
pub trait FieldGetter<FD, FDT>: Fn(FD) -> FDT + 'static {}
|
pub trait FieldGetter<FD, FDT>: Fn(FD) -> FDT + 'static {}
|
||||||
pub trait FieldSetter<FD, FDT>: Fn(&mut FD, FDT) + 'static {}
|
pub trait FieldSetter<FD, FDT>: Fn(&mut FD, FDT) + 'static {}
|
||||||
pub trait RenderFn<FS, FD>:
|
pub trait RenderFn<FS, FD>:
|
||||||
FnOnce(&FS, RwSignal<FD>) -> (View, Option<Box<dyn ValidationCb>>) + 'static
|
FnOnce(&mut FS, RwSignal<FD>) -> (View, Option<Box<dyn ValidationCb>>) + 'static
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ impl<CR, FDT, F> UnparseFn<CR, FDT> for F where F: Fn(FDT) -> CR + 'static {}
|
|||||||
impl<FD, FDT, F> FieldGetter<FD, FDT> for F where F: Fn(FD) -> FDT + 'static {}
|
impl<FD, FDT, F> FieldGetter<FD, FDT> for F where F: Fn(FD) -> FDT + 'static {}
|
||||||
impl<FD, FDT, F> FieldSetter<FD, FDT> for F where F: Fn(&mut FD, FDT) + 'static {}
|
impl<FD, FDT, F> FieldSetter<FD, FDT> for F where F: Fn(&mut FD, FDT) + 'static {}
|
||||||
impl<FS, FD, F> RenderFn<FS, FD> for F where
|
impl<FS, FD, F> RenderFn<FS, FD> for F where
|
||||||
F: FnOnce(&FS, RwSignal<FD>) -> (View, Option<Box<dyn ValidationCb>>) + 'static
|
F: FnOnce(&mut FS, RwSignal<FD>) -> (View, Option<Box<dyn ValidationCb>>) + 'static
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ impl<FS, FD, F> RenderFn<FS, FD> for F where
|
|||||||
pub trait VanityControlData: 'static {
|
pub trait VanityControlData: 'static {
|
||||||
/// Builds the control, returning the [`View`] that was built.
|
/// Builds the control, returning the [`View`] that was built.
|
||||||
fn build_control<FS: FormStyle>(
|
fn build_control<FS: FormStyle>(
|
||||||
fs: &FS,
|
fs: &mut FS,
|
||||||
control: ControlRenderData<FS, Self>,
|
control: ControlRenderData<FS, Self>,
|
||||||
value_getter: Option<Signal<String>>,
|
value_getter: Option<Signal<String>>,
|
||||||
) -> View;
|
) -> View;
|
||||||
@ -56,7 +56,7 @@ pub trait ControlData: 'static {
|
|||||||
|
|
||||||
/// Builds the control, returning the [`View`] that was built.
|
/// Builds the control, returning the [`View`] that was built.
|
||||||
fn build_control<FS: FormStyle>(
|
fn build_control<FS: FormStyle>(
|
||||||
fs: &FS,
|
fs: &mut FS,
|
||||||
control: ControlRenderData<FS, Self>,
|
control: ControlRenderData<FS, Self>,
|
||||||
value_getter: Signal<Self::ReturnType>,
|
value_getter: Signal<Self::ReturnType>,
|
||||||
value_setter: Box<dyn Fn(Self::ReturnType)>,
|
value_setter: Box<dyn Fn(Self::ReturnType)>,
|
||||||
|
|||||||
@ -8,7 +8,7 @@ pub struct OutputData;
|
|||||||
|
|
||||||
impl VanityControlData for OutputData {
|
impl VanityControlData for OutputData {
|
||||||
fn build_control<FS: FormStyle>(
|
fn build_control<FS: FormStyle>(
|
||||||
fs: &FS,
|
fs: &mut FS,
|
||||||
control: ControlRenderData<FS, Self>,
|
control: ControlRenderData<FS, Self>,
|
||||||
value_getter: Option<Signal<String>>,
|
value_getter: Option<Signal<String>>,
|
||||||
) -> View {
|
) -> View {
|
||||||
|
|||||||
@ -14,7 +14,7 @@ impl ControlData for RadioButtonsData {
|
|||||||
type ReturnType = String;
|
type ReturnType = String;
|
||||||
|
|
||||||
fn build_control<FS: FormStyle>(
|
fn build_control<FS: FormStyle>(
|
||||||
fs: &FS,
|
fs: &mut FS,
|
||||||
control: ControlRenderData<FS, Self>,
|
control: ControlRenderData<FS, Self>,
|
||||||
value_getter: Signal<Self::ReturnType>,
|
value_getter: Signal<Self::ReturnType>,
|
||||||
value_setter: Box<dyn Fn(Self::ReturnType)>,
|
value_setter: Box<dyn Fn(Self::ReturnType)>,
|
||||||
|
|||||||
@ -16,7 +16,7 @@ impl ControlData for SelectData {
|
|||||||
type ReturnType = String;
|
type ReturnType = String;
|
||||||
|
|
||||||
fn build_control<FS: FormStyle>(
|
fn build_control<FS: FormStyle>(
|
||||||
fs: &FS,
|
fs: &mut FS,
|
||||||
control: ControlRenderData<FS, Self>,
|
control: ControlRenderData<FS, Self>,
|
||||||
value_getter: Signal<Self::ReturnType>,
|
value_getter: Signal<Self::ReturnType>,
|
||||||
value_setter: Box<dyn Fn(Self::ReturnType)>,
|
value_setter: Box<dyn Fn(Self::ReturnType)>,
|
||||||
|
|||||||
@ -28,7 +28,7 @@ impl ControlData for SliderData {
|
|||||||
type ReturnType = i32;
|
type ReturnType = i32;
|
||||||
|
|
||||||
fn build_control<FS: FormStyle>(
|
fn build_control<FS: FormStyle>(
|
||||||
fs: &FS,
|
fs: &mut FS,
|
||||||
control: ControlRenderData<FS, Self>,
|
control: ControlRenderData<FS, Self>,
|
||||||
value_getter: Signal<Self::ReturnType>,
|
value_getter: Signal<Self::ReturnType>,
|
||||||
value_setter: Box<dyn Fn(Self::ReturnType)>,
|
value_setter: Box<dyn Fn(Self::ReturnType)>,
|
||||||
|
|||||||
@ -18,7 +18,7 @@ impl ControlData for StepperData {
|
|||||||
type ReturnType = String;
|
type ReturnType = String;
|
||||||
|
|
||||||
fn build_control<FS: FormStyle>(
|
fn build_control<FS: FormStyle>(
|
||||||
fs: &FS,
|
fs: &mut FS,
|
||||||
control: ControlRenderData<FS, Self>,
|
control: ControlRenderData<FS, Self>,
|
||||||
value_getter: Signal<Self::ReturnType>,
|
value_getter: Signal<Self::ReturnType>,
|
||||||
value_setter: Box<dyn Fn(Self::ReturnType)>,
|
value_setter: Box<dyn Fn(Self::ReturnType)>,
|
||||||
|
|||||||
@ -10,7 +10,7 @@ pub struct SubmitData {
|
|||||||
|
|
||||||
impl VanityControlData for SubmitData {
|
impl VanityControlData for SubmitData {
|
||||||
fn build_control<FS: FormStyle>(
|
fn build_control<FS: FormStyle>(
|
||||||
fs: &FS,
|
fs: &mut FS,
|
||||||
control: ControlRenderData<FS, Self>,
|
control: ControlRenderData<FS, Self>,
|
||||||
_value_getter: Option<leptos::prelude::Signal<String>>,
|
_value_getter: Option<leptos::prelude::Signal<String>>,
|
||||||
) -> View {
|
) -> View {
|
||||||
|
|||||||
@ -12,7 +12,7 @@ impl ControlData for TextAreaData {
|
|||||||
type ReturnType = String;
|
type ReturnType = String;
|
||||||
|
|
||||||
fn build_control<FS: FormStyle>(
|
fn build_control<FS: FormStyle>(
|
||||||
fs: &FS,
|
fs: &mut FS,
|
||||||
control: ControlRenderData<FS, Self>,
|
control: ControlRenderData<FS, Self>,
|
||||||
value_getter: Signal<Self::ReturnType>,
|
value_getter: Signal<Self::ReturnType>,
|
||||||
value_setter: Box<dyn Fn(Self::ReturnType)>,
|
value_setter: Box<dyn Fn(Self::ReturnType)>,
|
||||||
|
|||||||
@ -28,7 +28,7 @@ impl ControlData for TextInputData {
|
|||||||
type ReturnType = String;
|
type ReturnType = String;
|
||||||
|
|
||||||
fn build_control<FS: FormStyle>(
|
fn build_control<FS: FormStyle>(
|
||||||
fs: &FS,
|
fs: &mut FS,
|
||||||
control: ControlRenderData<FS, Self>,
|
control: ControlRenderData<FS, Self>,
|
||||||
value_getter: Signal<Self::ReturnType>,
|
value_getter: Signal<Self::ReturnType>,
|
||||||
value_setter: Box<dyn Fn(Self::ReturnType)>,
|
value_setter: Box<dyn Fn(Self::ReturnType)>,
|
||||||
|
|||||||
@ -90,7 +90,7 @@ impl<FD: FormToolData, FS: FormStyle> FormBuilder<FD, FS> {
|
|||||||
getter,
|
getter,
|
||||||
} = vanity_control.build();
|
} = vanity_control.build();
|
||||||
|
|
||||||
let render_fn = move |fs: &FS, fd: RwSignal<FD>| {
|
let render_fn = move |fs: &mut FS, fd: RwSignal<FD>| {
|
||||||
let value_getter = getter.map(|getter| (move || getter(fd.get())).into_signal());
|
let value_getter = getter.map(|getter| (move || getter(fd.get())).into_signal());
|
||||||
let view = VanityControlData::build_control(fs, render_data, value_getter);
|
let view = VanityControlData::build_control(fs, render_data, value_getter);
|
||||||
(view, None)
|
(view, None)
|
||||||
@ -120,7 +120,7 @@ impl<FD: FormToolData, FS: FormStyle> FormBuilder<FD, FS> {
|
|||||||
self.validations.push(validation_fn.clone());
|
self.validations.push(validation_fn.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
let render_fn = move |fs: &FS, fd: RwSignal<FD>| {
|
let render_fn = move |fs: &mut FS, fd: RwSignal<FD>| {
|
||||||
let (view, cb) = Self::build_control_view(
|
let (view, cb) = Self::build_control_view(
|
||||||
fd,
|
fd,
|
||||||
fs,
|
fs,
|
||||||
@ -139,7 +139,7 @@ impl<FD: FormToolData, FS: FormStyle> FormBuilder<FD, FS> {
|
|||||||
|
|
||||||
fn build_control_view<C: ControlData, FDT: 'static>(
|
fn build_control_view<C: ControlData, FDT: 'static>(
|
||||||
fd: RwSignal<FD>,
|
fd: RwSignal<FD>,
|
||||||
fs: &FS,
|
fs: &mut FS,
|
||||||
getter: Rc<dyn FieldGetter<FD, FDT>>,
|
getter: Rc<dyn FieldGetter<FD, FDT>>,
|
||||||
setter: Rc<dyn FieldSetter<FD, FDT>>,
|
setter: Rc<dyn FieldSetter<FD, FDT>>,
|
||||||
unparse_fn: Box<dyn UnparseFn<<C as ControlData>::ReturnType, FDT>>,
|
unparse_fn: Box<dyn UnparseFn<<C as ControlData>::ReturnType, FDT>>,
|
||||||
@ -230,7 +230,7 @@ impl<FD: FormToolData, FS: FormStyle> FormBuilder<FD, FS> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn build_action_form<ServFn>(
|
pub(crate) fn build_action_form<ServFn>(
|
||||||
self,
|
mut self,
|
||||||
action: Action<ServFn, Result<ServFn::Output, ServerFnError<ServFn::Error>>>,
|
action: Action<ServFn, Result<ServFn::Output, ServerFnError<ServFn::Error>>>,
|
||||||
) -> Form<FD>
|
) -> Form<FD>
|
||||||
where
|
where
|
||||||
@ -241,7 +241,7 @@ impl<FD: FormToolData, FS: FormStyle> FormBuilder<FD, FS> {
|
|||||||
let (views, validation_cbs): (Vec<_>, Vec<_>) = self
|
let (views, validation_cbs): (Vec<_>, Vec<_>) = self
|
||||||
.render_fns
|
.render_fns
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|r_fn| r_fn(&self.fs, self.fd))
|
.map(|r_fn| r_fn(&mut self.fs, self.fd))
|
||||||
.unzip();
|
.unzip();
|
||||||
|
|
||||||
let elements = self.fs.form_frame(views.into_view(), self.styles);
|
let elements = self.fs.form_frame(views.into_view(), self.styles);
|
||||||
@ -271,11 +271,11 @@ impl<FD: FormToolData, FS: FormStyle> FormBuilder<FD, FS> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn build_plain_form(self, url: String) -> Form<FD> {
|
pub(crate) fn build_plain_form(mut self, url: String) -> Form<FD> {
|
||||||
let (views, validation_cbs): (Vec<_>, Vec<_>) = self
|
let (views, validation_cbs): (Vec<_>, Vec<_>) = self
|
||||||
.render_fns
|
.render_fns
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|r_fn| r_fn(&self.fs, self.fd))
|
.map(|r_fn| r_fn(&mut self.fs, self.fd))
|
||||||
.unzip();
|
.unzip();
|
||||||
|
|
||||||
let elements = self.fs.form_frame(views.into_view(), self.styles);
|
let elements = self.fs.form_frame(views.into_view(), self.styles);
|
||||||
|
|||||||
@ -13,21 +13,23 @@ pub enum GridFormStylingAttributes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Clone, Copy, Debug, Default, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub struct GridFormStyle;
|
pub struct GridFormStyle {
|
||||||
|
count: u32,
|
||||||
|
}
|
||||||
|
|
||||||
impl FormStyle for GridFormStyle {
|
impl FormStyle for GridFormStyle {
|
||||||
type StylingAttributes = GridFormStylingAttributes;
|
type StylingAttributes = GridFormStylingAttributes;
|
||||||
|
|
||||||
fn form_frame(&self, children: View, _styles: Vec<Self::StylingAttributes>) -> View {
|
fn form_frame(&mut self, children: View, _styles: Vec<Self::StylingAttributes>) -> View {
|
||||||
view! { <div class="form_grid">{children}</div> }.into_view()
|
view! { <div class="form_grid">{children}</div> }.into_view()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn heading(&self, control: ControlRenderData<Self, HeadingData>) -> View {
|
fn heading(&mut self, control: ControlRenderData<Self, HeadingData>) -> View {
|
||||||
view! { <h2 class="form_heading">{&control.data.title}</h2> }.into_view()
|
view! { <h2 class="form_heading">{&control.data.title}</h2> }.into_view()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn text_input(
|
fn text_input(
|
||||||
&self,
|
&mut self,
|
||||||
control: ControlRenderData<Self, TextInputData>,
|
control: ControlRenderData<Self, TextInputData>,
|
||||||
value_getter: Signal<<TextInputData as ControlData>::ReturnType>,
|
value_getter: Signal<<TextInputData as ControlData>::ReturnType>,
|
||||||
value_setter: Box<dyn Fn(<TextInputData as ControlData>::ReturnType)>,
|
value_setter: Box<dyn Fn(<TextInputData as ControlData>::ReturnType)>,
|
||||||
@ -40,12 +42,13 @@ impl FormStyle for GridFormStyle {
|
|||||||
GridFormStylingAttributes::Width(w) => width = w,
|
GridFormStylingAttributes::Width(w) => width = w,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
self.count += 1;
|
||||||
|
|
||||||
view! {
|
let inner = view! {
|
||||||
<div style:grid-column=format!("span {}", width)>
|
<div style:grid-column=format!("span {}", width)>
|
||||||
<div>
|
<div>
|
||||||
<label for=&control.data.name class="form_label">
|
<label for=&control.data.name class="form_label">
|
||||||
{control.data.label.as_ref()}
|
{control.data.label.as_ref().map(|l| format!("{} - {}", l, self.count))}
|
||||||
</label>
|
</label>
|
||||||
<span class="form_error">{move || validation_state.get().err()}</span>
|
<span class="form_error">{move || validation_state.get().err()}</span>
|
||||||
</div>
|
</div>
|
||||||
@ -64,11 +67,18 @@ impl FormStyle for GridFormStyle {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
.into_view();
|
||||||
|
|
||||||
|
view! {
|
||||||
|
<Show when=move || value_getter.get() != "22">
|
||||||
|
{inner.clone()}
|
||||||
|
</Show>
|
||||||
|
}
|
||||||
.into_view()
|
.into_view()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select(
|
fn select(
|
||||||
&self,
|
&mut self,
|
||||||
control: ControlRenderData<Self, SelectData>,
|
control: ControlRenderData<Self, SelectData>,
|
||||||
value_getter: Signal<<SelectData as ControlData>::ReturnType>,
|
value_getter: Signal<<SelectData as ControlData>::ReturnType>,
|
||||||
value_setter: Box<dyn Fn(<SelectData as ControlData>::ReturnType)>,
|
value_setter: Box<dyn Fn(<SelectData as ControlData>::ReturnType)>,
|
||||||
@ -111,7 +121,7 @@ impl FormStyle for GridFormStyle {
|
|||||||
.into_view()
|
.into_view()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn submit(&self, control: ControlRenderData<Self, SubmitData>) -> View {
|
fn submit(&mut self, control: ControlRenderData<Self, SubmitData>) -> View {
|
||||||
view! {
|
view! {
|
||||||
<input type="submit" value=control.data.text class="form_submit"/>
|
<input type="submit" value=control.data.text class="form_submit"/>
|
||||||
}
|
}
|
||||||
@ -119,7 +129,7 @@ impl FormStyle for GridFormStyle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn text_area(
|
fn text_area(
|
||||||
&self,
|
&mut self,
|
||||||
control: ControlRenderData<Self, TextAreaData>,
|
control: ControlRenderData<Self, TextAreaData>,
|
||||||
value_getter: Signal<<TextAreaData as ControlData>::ReturnType>,
|
value_getter: Signal<<TextAreaData as ControlData>::ReturnType>,
|
||||||
value_setter: Box<dyn Fn(<TextAreaData as ControlData>::ReturnType)>,
|
value_setter: Box<dyn Fn(<TextAreaData as ControlData>::ReturnType)>,
|
||||||
@ -144,12 +154,12 @@ impl FormStyle for GridFormStyle {
|
|||||||
.into_view()
|
.into_view()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn custom_component(&self, view: View) -> View {
|
fn custom_component(&mut self, view: View) -> View {
|
||||||
view
|
view
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hidden(
|
fn hidden(
|
||||||
&self,
|
&mut self,
|
||||||
_control: ControlRenderData<Self, HiddenData>,
|
_control: ControlRenderData<Self, HiddenData>,
|
||||||
value_getter: Signal<String>,
|
value_getter: Signal<String>,
|
||||||
) -> View {
|
) -> View {
|
||||||
@ -157,7 +167,7 @@ impl FormStyle for GridFormStyle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn radio_buttons(
|
fn radio_buttons(
|
||||||
&self,
|
&mut self,
|
||||||
control: ControlRenderData<Self, crate::controls::radio_buttons::RadioButtonsData>,
|
control: ControlRenderData<Self, crate::controls::radio_buttons::RadioButtonsData>,
|
||||||
value_getter: Signal<
|
value_getter: Signal<
|
||||||
<crate::controls::radio_buttons::RadioButtonsData as ControlData>::ReturnType,
|
<crate::controls::radio_buttons::RadioButtonsData as ControlData>::ReturnType,
|
||||||
@ -224,7 +234,7 @@ impl FormStyle for GridFormStyle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn checkbox(
|
fn checkbox(
|
||||||
&self,
|
&mut self,
|
||||||
control: ControlRenderData<Self, CheckboxData>,
|
control: ControlRenderData<Self, CheckboxData>,
|
||||||
value_getter: Signal<<CheckboxData as ControlData>::ReturnType>,
|
value_getter: Signal<<CheckboxData as ControlData>::ReturnType>,
|
||||||
value_setter: Box<dyn Fn(<CheckboxData as ControlData>::ReturnType)>,
|
value_setter: Box<dyn Fn(<CheckboxData as ControlData>::ReturnType)>,
|
||||||
@ -261,7 +271,7 @@ impl FormStyle for GridFormStyle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn stepper(
|
fn stepper(
|
||||||
&self,
|
&mut self,
|
||||||
control: ControlRenderData<Self, crate::controls::stepper::StepperData>,
|
control: ControlRenderData<Self, crate::controls::stepper::StepperData>,
|
||||||
value_getter: Signal<<crate::controls::stepper::StepperData as ControlData>::ReturnType>,
|
value_getter: Signal<<crate::controls::stepper::StepperData as ControlData>::ReturnType>,
|
||||||
value_setter: Box<
|
value_setter: Box<
|
||||||
@ -302,7 +312,7 @@ impl FormStyle for GridFormStyle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn output(
|
fn output(
|
||||||
&self,
|
&mut self,
|
||||||
_control: ControlRenderData<Self, OutputData>,
|
_control: ControlRenderData<Self, OutputData>,
|
||||||
value_getter: Option<Signal<String>>,
|
value_getter: Option<Signal<String>>,
|
||||||
) -> View {
|
) -> View {
|
||||||
@ -310,7 +320,7 @@ impl FormStyle for GridFormStyle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn slider(
|
fn slider(
|
||||||
&self,
|
&mut self,
|
||||||
control: ControlRenderData<Self, crate::controls::slider::SliderData>,
|
control: ControlRenderData<Self, crate::controls::slider::SliderData>,
|
||||||
value_getter: Signal<<crate::controls::slider::SliderData as ControlData>::ReturnType>,
|
value_getter: Signal<<crate::controls::slider::SliderData as ControlData>::ReturnType>,
|
||||||
value_setter: Box<dyn Fn(<crate::controls::slider::SliderData as ControlData>::ReturnType)>,
|
value_setter: Box<dyn Fn(<crate::controls::slider::SliderData as ControlData>::ReturnType)>,
|
||||||
@ -380,7 +390,7 @@ impl FormStyle for GridFormStyle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: change this and form frame to use ControlRenderData
|
// TODO: change this and form frame to use ControlRenderData
|
||||||
fn group(&self, inner: View, styles: Vec<Self::StylingAttributes>) -> View {
|
fn group(&mut self, inner: View, styles: Vec<Self::StylingAttributes>) -> View {
|
||||||
let mut width = 12;
|
let mut width = 12;
|
||||||
for style in styles {
|
for style in styles {
|
||||||
match style {
|
match style {
|
||||||
|
|||||||
@ -22,36 +22,36 @@ pub trait FormStyle: Default + 'static {
|
|||||||
///
|
///
|
||||||
/// Do NOT wrap it in an actual `form` element; any
|
/// Do NOT wrap it in an actual `form` element; any
|
||||||
/// wrapping should be done with `div` or similar elements.
|
/// wrapping should be done with `div` or similar elements.
|
||||||
fn form_frame(&self, children: View, styles: Vec<Self::StylingAttributes>) -> View;
|
fn form_frame(&mut self, children: View, style: Vec<Self::StylingAttributes>) -> View;
|
||||||
fn heading(&self, control: ControlRenderData<Self, HeadingData>) -> View;
|
fn heading(&mut self, control: ControlRenderData<Self, HeadingData>) -> View;
|
||||||
fn hidden(
|
fn hidden(
|
||||||
&self,
|
&mut self,
|
||||||
control: ControlRenderData<Self, HiddenData>,
|
control: ControlRenderData<Self, HiddenData>,
|
||||||
value_getter: Signal<String>,
|
value_getter: Signal<String>,
|
||||||
) -> View;
|
) -> View;
|
||||||
fn text_input(
|
fn text_input(
|
||||||
&self,
|
&mut self,
|
||||||
control: ControlRenderData<Self, TextInputData>,
|
control: ControlRenderData<Self, TextInputData>,
|
||||||
value_getter: Signal<<TextInputData as ControlData>::ReturnType>,
|
value_getter: Signal<<TextInputData as ControlData>::ReturnType>,
|
||||||
value_setter: Box<dyn Fn(<TextInputData as ControlData>::ReturnType)>,
|
value_setter: Box<dyn Fn(<TextInputData as ControlData>::ReturnType)>,
|
||||||
validation_state: Signal<Result<(), String>>,
|
validation_state: Signal<Result<(), String>>,
|
||||||
) -> View;
|
) -> View;
|
||||||
fn text_area(
|
fn text_area(
|
||||||
&self,
|
&mut self,
|
||||||
control: ControlRenderData<Self, TextAreaData>,
|
control: ControlRenderData<Self, TextAreaData>,
|
||||||
value_getter: Signal<<TextAreaData as ControlData>::ReturnType>,
|
value_getter: Signal<<TextAreaData as ControlData>::ReturnType>,
|
||||||
value_setter: Box<dyn Fn(<TextAreaData as ControlData>::ReturnType)>,
|
value_setter: Box<dyn Fn(<TextAreaData as ControlData>::ReturnType)>,
|
||||||
validation_state: Signal<Result<(), String>>,
|
validation_state: Signal<Result<(), String>>,
|
||||||
) -> View;
|
) -> View;
|
||||||
fn radio_buttons(
|
fn radio_buttons(
|
||||||
&self,
|
&mut self,
|
||||||
control: ControlRenderData<Self, RadioButtonsData>,
|
control: ControlRenderData<Self, RadioButtonsData>,
|
||||||
value_getter: Signal<<RadioButtonsData as ControlData>::ReturnType>,
|
value_getter: Signal<<RadioButtonsData as ControlData>::ReturnType>,
|
||||||
value_setter: Box<dyn Fn(<RadioButtonsData as ControlData>::ReturnType)>,
|
value_setter: Box<dyn Fn(<RadioButtonsData as ControlData>::ReturnType)>,
|
||||||
validation_state: Signal<Result<(), String>>,
|
validation_state: Signal<Result<(), String>>,
|
||||||
) -> View;
|
) -> View;
|
||||||
fn select(
|
fn select(
|
||||||
&self,
|
&mut self,
|
||||||
control: ControlRenderData<Self, SelectData>,
|
control: ControlRenderData<Self, SelectData>,
|
||||||
value_getter: Signal<<SelectData as ControlData>::ReturnType>,
|
value_getter: Signal<<SelectData as ControlData>::ReturnType>,
|
||||||
value_setter: Box<dyn Fn(<SelectData as ControlData>::ReturnType)>,
|
value_setter: Box<dyn Fn(<SelectData as ControlData>::ReturnType)>,
|
||||||
@ -59,33 +59,32 @@ pub trait FormStyle: Default + 'static {
|
|||||||
) -> View;
|
) -> View;
|
||||||
fn button<FD: FormToolData>(&self, control: ControlRenderData<Self, ButtonData<FD>>) -> View;
|
fn button<FD: FormToolData>(&self, control: ControlRenderData<Self, ButtonData<FD>>) -> View;
|
||||||
fn checkbox(
|
fn checkbox(
|
||||||
&self,
|
&mut self,
|
||||||
control: ControlRenderData<Self, CheckboxData>,
|
control: ControlRenderData<Self, CheckboxData>,
|
||||||
value_getter: Signal<<CheckboxData as ControlData>::ReturnType>,
|
value_getter: Signal<<CheckboxData as ControlData>::ReturnType>,
|
||||||
value_setter: Box<dyn Fn(<CheckboxData as ControlData>::ReturnType)>,
|
value_setter: Box<dyn Fn(<CheckboxData as ControlData>::ReturnType)>,
|
||||||
) -> View;
|
) -> View;
|
||||||
fn stepper(
|
fn stepper(
|
||||||
&self,
|
&mut self,
|
||||||
control: ControlRenderData<Self, StepperData>,
|
control: ControlRenderData<Self, StepperData>,
|
||||||
value_getter: Signal<<StepperData as ControlData>::ReturnType>,
|
value_getter: Signal<<StepperData as ControlData>::ReturnType>,
|
||||||
value_setter: Box<dyn Fn(<StepperData as ControlData>::ReturnType)>,
|
value_setter: Box<dyn Fn(<StepperData as ControlData>::ReturnType)>,
|
||||||
validation_state: Signal<Result<(), String>>,
|
validation_state: Signal<Result<(), String>>,
|
||||||
) -> View;
|
) -> View;
|
||||||
fn output(
|
fn output(
|
||||||
&self,
|
&mut self,
|
||||||
control: ControlRenderData<Self, OutputData>,
|
control: ControlRenderData<Self, OutputData>,
|
||||||
value_getter: Option<Signal<String>>,
|
value_getter: Option<Signal<String>>,
|
||||||
) -> View;
|
) -> View;
|
||||||
fn slider(
|
fn slider(
|
||||||
&self,
|
&mut self,
|
||||||
control: ControlRenderData<Self, SliderData>,
|
control: ControlRenderData<Self, SliderData>,
|
||||||
value_getter: Signal<<SliderData as ControlData>::ReturnType>,
|
value_getter: Signal<<SliderData as ControlData>::ReturnType>,
|
||||||
value_setter: Box<dyn Fn(<SliderData as ControlData>::ReturnType)>,
|
value_setter: Box<dyn Fn(<SliderData as ControlData>::ReturnType)>,
|
||||||
validation_state: Signal<Result<(), String>>,
|
validation_state: Signal<Result<(), String>>,
|
||||||
) -> View;
|
) -> View;
|
||||||
fn submit(&self, control: ControlRenderData<Self, SubmitData>) -> View;
|
fn submit(&mut self, control: ControlRenderData<Self, SubmitData>) -> View;
|
||||||
// TODO: test custom component
|
// TODO: test custom component
|
||||||
fn custom_component(&self, view: View) -> View;
|
fn custom_component(&mut self, view: View) -> View;
|
||||||
// TODO: test group
|
fn group(&mut self, inner: View, style: Vec<Self::StylingAttributes>) -> View;
|
||||||
fn group(&self, inner: View, styles: Vec<Self::StylingAttributes>) -> View;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user