This commit is contained in:
rizrmd 2024-06-07 04:40:06 -07:00
parent eb3c803d4d
commit 32ead5308f
3 changed files with 5 additions and 2 deletions

View File

@ -1,7 +1,7 @@
import { ReactNode, useCallback, useEffect, useState } from "react";
import { BaseFormLocal, default_base_form_local } from "./types";
import { useLocal } from "lib/utils/use-local";
import { FieldLocal, FieldProp } from "../typings";
import { FieldLocal, FieldProp, fieldType } from "../typings";
export type BaseFormProps<T> = {
data: T;
@ -47,6 +47,8 @@ export const BaseForm = <T extends Record<string, any>>(
};
form.createField = (arg) => {
if (form.fields[arg.name]) return form.fields[arg.name];
const prop: FieldLocal = {
name: arg.name,
label: typeof arg.label !== "undefined" ? arg.label : arg.name,
@ -54,6 +56,7 @@ export const BaseForm = <T extends Record<string, any>>(
width: "auto",
prefix: arg.prefix,
} as any;
form.fields[arg.name] = prop;
return prop;
};

View File

@ -8,6 +8,7 @@ export const default_base_form_local = {
width: 0,
},
fm: null as null | FMLocal,
fields: {} as Record<string, any>,
};
type CreateFieldArg = {

View File

@ -200,7 +200,6 @@ export const FieldTypeInput: FC<{
field.render();
}}
/>
{arg.sub_type === "password" && (
<div
className="c-absolute c-right-0 c-h-full c-flex c-items-center c-cursor-pointer"