From 06c20fa95073b95e02e1ceb8dec5faf646df5b9b Mon Sep 17 00:00:00 2001 From: Tilen Komel Date: Fri, 23 Aug 2024 18:09:16 +0200 Subject: [PATCH 01/20] Add dynamic value to input --- src/components/Form/FormInput.tsx | 1 + src/components/UI/Input.tsx | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/Form/FormInput.tsx b/src/components/Form/FormInput.tsx index fced1b00..33ba8ccd 100644 --- a/src/components/Form/FormInput.tsx +++ b/src/components/Form/FormInput.tsx @@ -9,6 +9,7 @@ import { Controller, type FieldValues } from "react-hook-form"; export interface InputFieldProps extends BaseFormBuilderProps { type: "text" | "number" | "password"; properties?: { + value?: string; prefix?: string; suffix?: string; step?: number; diff --git a/src/components/UI/Input.tsx b/src/components/UI/Input.tsx index 2c3080fb..630a6364 100644 --- a/src/components/UI/Input.tsx +++ b/src/components/UI/Input.tsx @@ -31,7 +31,7 @@ export interface InputProps } const Input = React.forwardRef( - ({ className, variant, prefix, suffix, action, ...props }, ref) => { + ({ className, value, variant, prefix, suffix, action, ...props }, ref) => { return (
{prefix && ( @@ -45,6 +45,7 @@ const Input = React.forwardRef( className, inputVariants({ variant }), )} + value={value} ref={ref} {...props} /> From 0911df6b0d583330e0686b83241257725ae67ec7 Mon Sep 17 00:00:00 2001 From: Tilen Komel Date: Fri, 23 Aug 2024 18:31:41 +0200 Subject: [PATCH 02/20] Add dynamic bit to password generator --- src/components/Form/FormPasswordGenerator.tsx | 2 ++ src/components/UI/Generator.tsx | 20 ++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/components/Form/FormPasswordGenerator.tsx b/src/components/Form/FormPasswordGenerator.tsx index a94b0215..cf05f806 100644 --- a/src/components/Form/FormPasswordGenerator.tsx +++ b/src/components/Form/FormPasswordGenerator.tsx @@ -9,6 +9,7 @@ import { Controller, type FieldValues } from "react-hook-form"; export interface PasswordGeneratorProps extends BaseFormBuilderProps { type: "passwordGenerator"; hide?: boolean; + bits?: { text: string; value: string; key: string }[]; devicePSKBitCount: number; inputChange: ChangeEventHandler; selectChange: (event: string) => void; @@ -28,6 +29,7 @@ export function PasswordGenerator({ { value: string; variant: "default" | "invalid"; buttonText?: string; + bits?: { text: string; value: string; key: string }[]; selectChange: (event: string) => void; inputChange: (event: React.ChangeEvent) => void; buttonClick: React.MouseEventHandler; @@ -35,6 +36,11 @@ const Generator = React.forwardRef( variant, value, buttonText, + bits = [ + { text: "256 bit", value: "32", key: "bit256" }, + { text: "128 bit", value: "16", key: "bit128" }, + { text: "8 bit", value: "1", key: "bit8" }, + ], selectChange, inputChange, buttonClick, @@ -63,15 +69,11 @@ const Generator = React.forwardRef( - - 256 bit - - - 128 bit - - - 8 bit - + {bits.map(({ text, value, key }) => ( + + {text} + + ))}