diff --git a/src/components/Form/FormInput.tsx b/src/components/Form/FormInput.tsx index 13f77260..c4e5001d 100644 --- a/src/components/Form/FormInput.tsx +++ b/src/components/Form/FormInput.tsx @@ -4,7 +4,9 @@ import type { } from "@components/Form/DynamicForm.js"; import { Input } from "@components/UI/Input.js"; import type { LucideIcon } from "lucide-react"; +import { Eye, EyeOff } from "lucide-react"; import type { ChangeEventHandler } from "react"; +import { useState } from "react"; import { Controller, type FieldValues } from "react-hook-form"; export interface InputFieldProps extends BaseFormBuilderProps { @@ -27,13 +29,28 @@ export function GenericInput({ disabled, field, }: GenericFormElementProps>) { + const [passwordShown, setPasswordShown] = useState(false); + const togglePasswordVisiblity = () => { + setPasswordShown(!passwordShown); + }; + return ( ( { diff --git a/src/components/Form/FormPasswordGenerator.tsx b/src/components/Form/FormPasswordGenerator.tsx index cf05f806..31bb2f1c 100644 --- a/src/components/Form/FormPasswordGenerator.tsx +++ b/src/components/Form/FormPasswordGenerator.tsx @@ -3,7 +3,9 @@ import type { GenericFormElementProps, } from "@components/Form/DynamicForm.js"; import { Generator } from "@components/UI/Generator.js"; +import { Eye, EyeOff } from "lucide-react"; import type { ChangeEventHandler, MouseEventHandler } from "react"; +import { useState } from "react"; import { Controller, type FieldValues } from "react-hook-form"; export interface PasswordGeneratorProps extends BaseFormBuilderProps { @@ -21,13 +23,26 @@ export function PasswordGenerator({ field, disabled, }: GenericFormElementProps>) { + const [passwordShown, setPasswordShown] = useState(false); + const togglePasswordVisiblity = () => { + setPasswordShown(!passwordShown); + }; + return ( ( { inputChange: inputChangeEvent, selectChange: selectChangeEvent, buttonClick: clickEvent, + hide: true, properties: { value: pass, }, diff --git a/src/components/UI/Generator.tsx b/src/components/UI/Generator.tsx index 7d589be4..f9db3f89 100644 --- a/src/components/UI/Generator.tsx +++ b/src/components/UI/Generator.tsx @@ -12,7 +12,7 @@ import { import type { LucideIcon } from "lucide-react"; export interface GeneratorProps extends React.BaseHTMLAttributes { - hide?: boolean; + type: "text" | "password"; devicePSKBitCount?: number; value: string; variant: "default" | "invalid"; @@ -31,7 +31,7 @@ export interface GeneratorProps extends React.BaseHTMLAttributes { const Generator = React.forwardRef( ( { - hide = true, + type, devicePSKBitCount, variant, value, @@ -68,7 +68,7 @@ const Generator = React.forwardRef( return ( <>