import React from "react"; import { MonthPicker, MonthPickerProps } from "@mantine/dates"; import { useController, FieldValues, UseControllerProps, } from "react-hook-form"; import { Input } from "@mantine/core"; type Props = MonthPickerProps & { name: UseControllerProps["name"]; rules?: UseControllerProps["rules"]; defaultValue?: UseControllerProps["defaultValue"]; }; function RHFMonthPicker(props: Props) { const { name, rules, defaultValue, ...others } = props; const { field, fieldState: { error }, } = useController({ name, rules }); return ( <> field.onChange(value)} /> {error && ( {error.message === "" && error.type === "required" ? "Required" : error.message} )} ); } export default RHFMonthPicker; export const createMonthPicker = () => { const Field = (props: Props) => ; return Field; };