This commit is contained in:
rizrmd 2024-03-20 03:41:04 -07:00
parent 9995a3364a
commit a72e479932
1 changed files with 13 additions and 4 deletions

View File

@ -8,7 +8,7 @@ import {
} from "@/comps/ui/form"; } from "@/comps/ui/form";
import { useLocal } from "@/utils/use-local"; import { useLocal } from "@/utils/use-local";
import autosize from "autosize"; import autosize from "autosize";
import { FC, useEffect, useRef } from "react"; import { FC, ReactNode, useEffect, useRef } from "react";
import { UseFormReturn } from "react-hook-form"; import { UseFormReturn } from "react-hook-form";
import { Button } from "../ui/button"; import { Button } from "../ui/button";
import { Input } from "../ui/input"; import { Input } from "../ui/input";
@ -43,6 +43,7 @@ export const Field: FC<{
PassProp: any; PassProp: any;
custom: "y" | "n"; custom: "y" | "n";
child: any; child: any;
label_alt: ReactNode | (() => ReactNode);
}> = ({ }> = ({
name, name,
form, form,
@ -56,6 +57,7 @@ export const Field: FC<{
PassProp, PassProp,
custom, custom,
child, child,
label_alt,
}) => { }) => {
const value = form?.hook.getValues()[name]; const value = form?.hook.getValues()[name];
const local = useLocal({ const local = useLocal({
@ -126,9 +128,16 @@ export const Field: FC<{
name={name} name={name}
render={({ field }) => ( render={({ field }) => (
<FormItem className="c-flex c-flex-1 c-flex-col"> <FormItem className="c-flex c-flex-1 c-flex-col">
<FormLabel className="flex"> <FormLabel className="c-flex c-justify-between">
{label} <div>
{required === "y" && <h1 className="c-ml-1 c-text-red-500">*</h1>} {label}
{required === "y" && (
<h1 className="c-ml-1 c-text-red-500">*</h1>
)}
</div>
<div>
{typeof label_alt === "function" ? label_alt() : label_alt}
</div>
</FormLabel> </FormLabel>
<FormControl> <FormControl>
<> <>