import { FieldLoading } from "lib/comps/ui/field-loading"; import { Label } from "../field/Label"; import { FMLocal, FieldLocal, FieldProp } from "../typings"; import { useField } from "../utils/use-field"; import { ReactNode } from "react"; export const BaseField = ( arg: FieldProp & { children?: (arg: { fm: FMLocal; field: FieldLocal }) => ReactNode; } ) => { const field = useField(arg); const fm = arg.fm; arg.fm.fields[arg.name] = field; const w = field.width || "auto"; const prefix = typeof field.prefix === "function" ? field.prefix() : typeof field.prefix === "string" ? field.prefix : null; const suffix = typeof field.suffix === "function" ? field.suffix() : typeof field.suffix === "string" ? field.prefix : null; const name = field.name; const errors = fm.error.get(name); const showlabel = arg.show_label || "y"; const disabled = typeof field.disabled === "function" ? field.disabled() : field.disabled; const show = typeof field.hidden === "function" ? field.hidden() : typeof field.hidden === "string" ? field.hidden === "n" ? false : true : typeof field.hidden === "boolean" ? field.hidden : true; return (