open Prop;
let handleChange = (handleChange, event) =>
handleChange(ReactEvent.Form.target(event)##value);
type onChange = option(Value.t) => unit;
[@react.component]
let make =
(
~type_: TypeWithMetadata.t,
~value: option(Value.t),
~onChange: onChange,
) => {
switch (type_.type_, value) {
| (Year(_), Some(FloatPoint(r))) =>
Js.Float.toString}
onChange={handleChange(r =>
switch (Js.Float.fromString(r)) {
| r => onChange(Some(Value.FloatPoint(r)))
}
)}
/>
| (FloatPoint(_), Some(FloatPoint(r))) =>
Js.Float.toString}
onChange={handleChange(r =>
switch (Js.Float.fromString(r)) {
| r => onChange(Some(Value.FloatPoint(r)))
}
)}
/>
| (Year(_), _)
| (FloatPoint(_), _) =>
| (SelectSingle(t), Some(SelectSingle(r))) =>
| (DateTime(_), Some(DateTime((d: MomentRe.Moment.t)))) =>
onChange(
Some(Value.DateTime(MomentRe.momentWithFormat(r, "YYYY-MM-DD"))),
)
)}
/>
};
};