Fix some react hook form based prop types

Signed-off-by: Émile Ré <nemile.re@gmail.com>
This commit is contained in:
Émile Ré
2025-12-03 14:20:24 +04:00
parent 21d2246f30
commit f3d45623bd
6 changed files with 56 additions and 59 deletions

View File

@@ -1,19 +1,16 @@
import type { ComponentProps, JSX, JSXElementConstructor } from "react";
import type { ComponentProps } from "react";
import { Field } from "@probo/ui";
import { Controller, type Control } from "react-hook-form";
import { Controller, type FieldValues } from "react-hook-form";
import { Select } from "@probo/ui";
type Props<T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> =
ComponentProps<T> & {
control: Control<any>;
name: string;
};
type Props<T extends typeof Field | typeof Select, TFieldValues extends FieldValues = FieldValues> =
ComponentProps<T> & Omit<ComponentProps<typeof Controller<TFieldValues>>, "render">;
export function ControlledField({
export function ControlledField<TFieldValues extends FieldValues = FieldValues>({
control,
name,
...props
}: Props<typeof Field>) {
}: Props<typeof Field, TFieldValues>) {
return (
<Controller
control={control}