@@ -598,7 +598,78 @@ let map_type_decl
598598 ]))
599599 in
600600
601+ (* type useWatchParamsOfInputs = {
602+ name: variantOfInputs,
603+ control: controlOfInputs=?,
604+ defaultValue: valuesOfInputs=?,
605+ disabled: bool=?,
606+ exact: bool=?,
607+ } *)
601608 let type_decls4 =
609+ Str. type_ Recursive
610+ [
611+ Type. mk
612+ (mkloc (" useWatchParamsOf" ^ capitalize record_name) ptype_loc)
613+ ~priv: Public
614+ ~kind:
615+ (Ptype_record
616+ [
617+ Type. field ~mut: Immutable (mknoloc " name" )
618+ (Typ. constr
619+ (lid @@ " variantOf" ^ capitalize record_name)
620+ [] );
621+ Type. field ~attrs: [ attr_optional ] ~mut: Immutable
622+ (mknoloc " control" )
623+ (Typ. constr ~attrs: [ attr_named_arg ]
624+ (lid @@ " controlOf" ^ capitalize record_name)
625+ [] );
626+ Type. field ~attrs: [ attr_optional ] ~mut: Immutable
627+ (mknoloc " defaultValue" )
628+ (Typ. constr
629+ (lid @@ " valuesOf" ^ capitalize record_name)
630+ [] );
631+ Type. field ~attrs: [ attr_optional ] ~mut: Immutable
632+ (mknoloc " disabled" )
633+ (Typ. constr (lid " bool" ) [] );
634+ Type. field ~attrs: [ attr_optional ] ~mut: Immutable
635+ (mknoloc " exact" )
636+ (Typ. constr (lid " bool" ) [] );
637+ ]);
638+ ]
639+ in
640+
641+ (* @module("react-hook-form")
642+ external useWatchOfInputs: useWatchParamsOfInputs => option<valuesOfInputs> = "useWatch" *)
643+ let primitive_use_watch =
644+ Str. primitive
645+ (Val. mk
646+ ~attrs:
647+ [
648+ Attr. mk (mknoloc " module" )
649+ (PStr
650+ [
651+ Str. eval
652+ @@ Exp. constant (Const. string " react-hook-form" );
653+ ]);
654+ ]
655+ ~prim: [ " useWatch" ]
656+ (mknoloc @@ " useWatchOf" ^ capitalize record_name)
657+ (uncurried_core_type_arrow ~arity: 1
658+ [
659+ Typ. arrow Nolabel
660+ (Typ. constr ~attrs: [ attr_named_arg ]
661+ (lid @@ " useWatchParamsOf" ^ capitalize record_name)
662+ [] )
663+ (Typ. constr (lid " option" )
664+ [
665+ Typ. constr
666+ (lid @@ " valuesOf" ^ capitalize record_name)
667+ [];
668+ ]);
669+ ]))
670+ in
671+
672+ let type_decls5 =
602673 lds
603674 |> List. filter_map
604675 (fun
@@ -987,8 +1058,10 @@ let map_type_decl
9871058 type_decls3;
9881059 primitive_use_form;
9891060 module_controller;
1061+ type_decls4;
1062+ primitive_use_watch;
9901063 ]
991- @ type_decls4 @ primitive_use_field_array @ vb_field_array
1064+ @ type_decls5 @ primitive_use_field_array @ vb_field_array
9921065 | _ -> fail ptype_loc " This type is not handled by @ppx_react_hook_form"
9931066 else []
9941067
0 commit comments