/** * Copyright (c) 2023-present Plane Software, Inc. and contributors * SPDX-License-Identifier: AGPL-3.0-only * See the LICENSE file for details. */ import React, { useState } from "react"; import type { Control, FieldPath, FieldValues } from "react-hook-form"; import { Controller } from "react-hook-form"; // icons import { Eye, EyeOff } from "lucide-react"; // plane internal packages import { Input, InputGroup } from "@makeplane/propel/components/input"; // Generic over the form's values because react-hook-form's Control is invariant: its // `_options.validate` narrows `name` to a keyof union, so `Control` no longer // accepts a typed form's control. Inferring from `control` keeps call sites unchanged. type Props = { control: Control; type: "text" | "password"; name: FieldPath; label: string; description?: string | React.ReactNode; placeholder: string; error: boolean; required: boolean; }; export type TControllerInputFormField = { key: FieldPath; type: "text" | "password"; label: string; description?: string | React.ReactNode; placeholder: string; error: boolean; required: boolean; }; export function ControllerInput(props: Props) { const { name, control, type, label, description, placeholder, error, required } = props; // states const [showPassword, setShowPassword] = useState(false); return (

{label}

( )} /> {type === "password" && (showPassword ? ( ) : ( ))} {description &&

{description}

}
); }