diff --git a/comps/form/Form.tsx b/comps/form/Form.tsx index 0c4ab4f..4f05dc9 100755 --- a/comps/form/Form.tsx +++ b/comps/form/Form.tsx @@ -125,7 +125,9 @@ export const Form: FC = (props) => { )} > {fm.status !== "init" && fm.size.width > 0 && ( - {body} + + {body} + )} diff --git a/comps/form/field/type/TypeCustom.tsx b/comps/form/field/type/TypeCustom.tsx index 25bb27b..0e45d1f 100755 --- a/comps/form/field/type/TypeCustom.tsx +++ b/comps/form/field/type/TypeCustom.tsx @@ -14,30 +14,16 @@ export const TypeCustom: FC<{ field: FieldLocal; fm: FMLocal }> = ({ }); if (!local.custom && field.custom) { - console.log("field", field.custom); local.custom = field.custom; } - if (!local.exec) { - local.exec = true; - const callback = (value: any, should_render: boolean) => { - local.result = value; - if (should_render) { - local.render(); - setTimeout(() => { - local.exec = false; - }, 100); - } - }; - if (field.custom) { - const res = local.custom(); - if (res instanceof Promise) { - res.then((value) => { - callback(value, true); - }); - } else { - callback(res, false); - } + if (field.custom) { + const res = local.custom(); + if (res instanceof Promise) { + console.error("Custom Function cannot be async"); + return null; + } else { + local.result = res; } } diff --git a/comps/form/typings.ts b/comps/form/typings.ts index 998d96b..684914a 100755 --- a/comps/form/typings.ts +++ b/comps/form/typings.ts @@ -56,7 +56,7 @@ export type FieldProp = { _meta: any; _item: any; _sync: any; - custom?: () => Promise; + custom?: () => CustomField; }; export type FMInternal = { diff --git a/comps/form/utils/gen-mitem.ts b/comps/form/utils/gen-mitem.ts index be94adc..8123537 100755 --- a/comps/form/utils/gen-mitem.ts +++ b/comps/form/utils/gen-mitem.ts @@ -23,16 +23,13 @@ export const genFieldMitem = (arg: { ?.get("content") ?.get("childs"); - const col = fm.field_def[field.name]; - if (col) { - const component = fieldMapping[field.type as "text"]; - if (component) { - const item = createItem({ - component: component as any, - }); + const component = fieldMapping[field.type as "text"]; + if (component) { + const item = createItem({ + component: component as any, + }); - _sync(childs, [...childs.toJSON(), item]); - } + _sync(childs, [...childs.toJSON(), item]); } } }