diff --git a/src/services/ui/src/components/RHF/RHFInput.tsx b/src/services/ui/src/components/RHF/RHFInput.tsx index 9081872614..44a0adc337 100644 --- a/src/services/ui/src/components/RHF/RHFInput.tsx +++ b/src/services/ui/src/components/RHF/RHFInput.tsx @@ -48,16 +48,18 @@ type TextFieldProps = InputProps & { description?: ReactElement | string; }; -type ComponentKey = keyof RHFComponentMap; - -type RHFSlotProps = { - rhf: ComponentKey; +export type RHFSlotProps = { name: string; label?: ReactElement | string; description?: ReactElement | string; -} & RHFComponentMap[T]; +} & { + [K in keyof RHFComponentMap]: { + rhf: K; + props?: RHFComponentMap[K]; + }; +}[keyof RHFComponentMap]; -type RHFComponentMap = { +interface RHFComponentMap { Text: TextFieldProps; Textarea: TextareaProps; Switch: SwitchProps; @@ -66,9 +68,7 @@ type RHFComponentMap = { DatePicker: CalendarProps; Checkbox: any; FieldArray: any; - // "Checkbox":'' -}; - +} type FormGroup = { description: string; slot: RHFSlotProps; @@ -90,7 +90,7 @@ type FieldArrayProps< > = { control: Control; name: TFieldArrayName; - fields: RHFSlotProps[]; + fields: RHFSlotProps[]; }; // ----------------------------------------------------------------- @@ -152,17 +152,14 @@ export const RHFSlot = < label, description, ...props -}: RHFSlotProps): ControllerProps< - TFieldValues, - TName ->["render"] => +}: RHFSlotProps): ControllerProps["render"] => function Slot({ field }) { return ( {label && {label}} <> - {rhf === "Input" && } + {rhf === "Text" && } {rhf === "Textarea" &&