@@ -18,15 +18,22 @@ let map_type_decl
1818 let type_decls =
1919 Sig. type_ Nonrecursive
2020 [
21- (* type inputsWithId = {id: string, ...} *)
21+ (* type inputsWithId = {id: string, example?: string, ...} *)
2222 Type. mk
2323 (mkloc (record_name ^ " WithId" ) ptype_loc)
2424 ~priv: Public
2525 ~kind:
2626 (Ptype_record
2727 (Type. field ~mut: Immutable (mknoloc " id" )
2828 (Typ. constr (lid " string" ) [] )
29- :: lds));
29+ :: (lds
30+ |> List. map (fun ld ->
31+ {
32+ ld with
33+ pld_attributes =
34+ remove_optional_attribute ld.pld_attributes
35+ |> add_optional_attribute;
36+ }))));
3037 ]
3138 in
3239 let type_decls1 =
@@ -116,7 +123,7 @@ let map_type_decl
116123 | Array(array<watchReturnOfInputs>)
117124 *)
118125 Type. mk
119- (mkloc (" watchReturnOf " ^ capitalize record_name) ptype_loc)
126+ (mkloc (" valuesOf " ^ capitalize record_name) ptype_loc)
120127 ~attrs: [ Attr. mk (mknoloc " unboxed" ) (PStr [] ) ]
121128 ~priv: Public
122129 ~kind:
@@ -142,8 +149,7 @@ let map_type_decl
142149 [
143150 Typ. constr
144151 (lid
145- (" watchReturnOf"
146- ^ capitalize record_name))
152+ (" valuesOf" ^ capitalize record_name))
147153 [];
148154 ];
149155 ]);
@@ -155,8 +161,7 @@ let map_type_decl
155161 [
156162 Typ. constr
157163 (lid
158- (" watchReturnOf"
159- ^ capitalize record_name))
164+ (" valuesOf" ^ capitalize record_name))
160165 [];
161166 ];
162167 ]);
@@ -170,7 +175,8 @@ let map_type_decl
170175 control: controlOfInputs,
171176 register: (variantOfInputs, ~options: registerOptionsOfInputs<'setValueAs>=?) => JsxDOM.domProps,
172177 handleSubmit: (inputs => unit) => JsxEvent.Form.t => unit,
173- watch: variantOfInputs => watchReturnOfInputs,
178+ watch: variantOfInputs => valuesOfInputs,
179+ getValues: variantOfInputs => option<valuesOfInputs>,
174180 reset: (~options: defaultValuesOfInputs=?) => unit,
175181 formState: formStateOfInputs,
176182 } *)
@@ -229,7 +235,7 @@ let map_type_decl
229235 (Typ. constr (lid " unit" ) [] );
230236 ]);
231237 ]);
232- (* watch: variantOfInputs => option<watchReturnOfInputs >, *)
238+ (* watch: variantOfInputs => option<valuesOfInputs >, *)
233239 Type. field ~mut: Immutable (mknoloc " watch" )
234240 (uncurried_core_type_arrow ~arity: 1
235241 [
@@ -240,7 +246,23 @@ let map_type_decl
240246 (Typ. constr (lid " option" )
241247 [
242248 Typ. constr
243- (lid @@ " watchReturnOf"
249+ (lid @@ " valuesOf"
250+ ^ capitalize record_name)
251+ [];
252+ ]);
253+ ]);
254+ (* getValues: variantOfInputs => option<valuesOfInputs>, *)
255+ Type. field ~mut: Immutable (mknoloc " getValues" )
256+ (uncurried_core_type_arrow ~arity: 1
257+ [
258+ Typ. arrow Nolabel
259+ (Typ. constr
260+ (lid @@ " variantOf" ^ capitalize record_name)
261+ [] )
262+ (Typ. constr (lid " option" )
263+ [
264+ Typ. constr
265+ (lid @@ " valuesOf"
244266 ^ capitalize record_name)
245267 [];
246268 ]);
0 commit comments