4 changed files with 110 additions and 82 deletions
@ -1,32 +1,31 @@ |
|||||
import type { |
import type { |
||||
BaseFormBuilderProps, |
BaseFormBuilderProps, |
||||
GenericFormElementProps, |
GenericFormElementProps, |
||||
} from "@components/Form/DynamicForm.js"; |
} from "@components/Form/DynamicForm.js"; |
||||
import { Generator } from "@components/UI/Generator.js"; |
import { Generator } from "@components/UI/Generator.js"; |
||||
import { useState } from "react"; |
import { useState } from "react"; |
||||
import { Controller, type FieldValues } from "react-hook-form"; |
import { Controller, type FieldValues } from "react-hook-form"; |
||||
|
|
||||
export interface PasswordGeneratorProps<T> extends BaseFormBuilderProps<T> { |
export interface PasswordGeneratorProps<T> extends BaseFormBuilderProps<T> { |
||||
type: "passwordGenerator"; |
type: "passwordGenerator"; |
||||
} |
} |
||||
|
|
||||
export function PasswordGenerator<T extends FieldValues>({ |
export function PasswordGenerator<T extends FieldValues>({ |
||||
control, |
control, |
||||
field, |
field, |
||||
}: GenericFormElementProps<T, PasswordGeneratorProps<T>>) { |
}: GenericFormElementProps<T, PasswordGeneratorProps<T>>) { |
||||
return ( |
return ( |
||||
<Controller |
<Controller |
||||
name={field.name} |
name={field.name} |
||||
control={control} |
control={control} |
||||
render={({ field: { value, onChange, ...rest } }) => ( |
render={({ field: { value, onChange, ...rest } }) => ( |
||||
<Generator |
<Generator |
||||
variant={"success"} |
variant={"success"} |
||||
textValue="Generate" |
textValue="Generate" |
||||
{...field.properties} |
{...field.properties} |
||||
{...rest} |
{...rest} |
||||
/> |
/> |
||||
)} |
)} |
||||
/> |
/> |
||||
); |
); |
||||
} |
} |
||||
|
|
||||
|
|||||
Loading…
Reference in new issue