open BsReform;
module FormConfig = [%lenses
type state = {
guesstimatorString: string,
//
domainType: string, // Complete, LeftLimited(...), RightLimited(...), LeftAndRightLimited(..., ...)
xPoint: string,
excludingProbabilityMass: string,
//
unitType: string, // UnspecifiedDistribution, TimeDistribution(zero, unit)
zero: MomentRe.Moment.t,
unit: string,
}
];
module Form = ReForm.Make(FormConfig);
let schema = Form.Validation.Schema([||]);
module FieldString = {
[@react.component]
let make = (~field, ~label) => {
E.ste}>
validate()}
/>
}
/>;
};
};
module Styles = {
open Css;
let row =
style([display(`flex), selector("div > div", [flex(`num(1.))])]);
};
module FieldFloat = {
[@react.component]
let make = (~field, ~label) => {
E.ste}>
validate()}
/>
}
/>;
};
};
[@react.component]
let make = () => {
let reform =
Form.use(
~validationStrategy=OnDemand,
~schema,
~onSubmit=({state}) => {None},
~initialState={
guesstimatorString: "mm(5 to 20, floor(normal(20,2)), [.5, .5])",
domainType: "Complete",
xPoint: "0.0",
excludingProbabilityMass: "",
unitType: "UnspecifiedDistribution",
zero: MomentRe.momentNow(),
unit: "days",
},
(),
);
let onSubmit = e => {
e->ReactEvent.Synthetic.preventDefault;
reform.submit();
};
E.ste}>
e |> handleChange}>
{"Complete" |> E.ste}
{"LeftLimited" |> E.ste}
{"RightLimited" |> E.ste}
{"LeftAndRightLimited" |> E.ste}
}
/>
E.ste}>
e |> handleChange}>
{"UnspecifiedDistribution" |> E.ste}
{"TimeDistribution" |> E.ste}
}
/>
E.ste}>
{
e |> handleChange;
_ => ();
}}
/>
}
/>
E.ste}>
e |> handleChange}>
{"days" |> E.ste}
{"hours" |> E.ste}
{"milliseconds" |> E.ste}
{"minutes" |> E.ste}
{"months" |> E.ste}
{"quarters" |> E.ste}
{"seconds" |> E.ste}
{"weeks" |> E.ste}
{"years" |> E.ste}
}
/>
{reform.state.formState == Submitting
? "Loading" |> E.ste
:
{"Submit" |> E.ste}
}
;
};