Browse Source

Add dynamic value to input

pull/277/head
Tilen Komel 2 years ago
parent
commit
06c20fa950
  1. 1
      src/components/Form/FormInput.tsx
  2. 3
      src/components/UI/Input.tsx

1
src/components/Form/FormInput.tsx

@ -9,6 +9,7 @@ import { Controller, type FieldValues } from "react-hook-form";
export interface InputFieldProps<T> extends BaseFormBuilderProps<T> { export interface InputFieldProps<T> extends BaseFormBuilderProps<T> {
type: "text" | "number" | "password"; type: "text" | "number" | "password";
properties?: { properties?: {
value?: string;
prefix?: string; prefix?: string;
suffix?: string; suffix?: string;
step?: number; step?: number;

3
src/components/UI/Input.tsx

@ -31,7 +31,7 @@ export interface InputProps
} }
const Input = React.forwardRef<HTMLInputElement, InputProps>( const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ className, variant, prefix, suffix, action, ...props }, ref) => { ({ className, value, variant, prefix, suffix, action, ...props }, ref) => {
return ( return (
<div className="relative w-full"> <div className="relative w-full">
{prefix && ( {prefix && (
@ -45,6 +45,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
className, className,
inputVariants({ variant }), inputVariants({ variant }),
)} )}
value={value}
ref={ref} ref={ref}
{...props} {...props}
/> />

Loading…
Cancel
Save