fix
This commit is contained in:
parent
ad557ca5c0
commit
3bc6330379
|
|
@ -125,7 +125,9 @@ export const Form: FC<FMProps> = (props) => {
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{fm.status !== "init" && fm.size.width > 0 && (
|
{fm.status !== "init" && fm.size.width > 0 && (
|
||||||
<PassProp fm={fm}>{body}</PassProp>
|
<PassProp fm={fm} submit={fm.submit}>
|
||||||
|
{body}
|
||||||
|
</PassProp>
|
||||||
)}
|
)}
|
||||||
<button type="submit" className="c-hidden"></button>
|
<button type="submit" className="c-hidden"></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -14,30 +14,16 @@ export const TypeCustom: FC<{ field: FieldLocal; fm: FMLocal }> = ({
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!local.custom && field.custom) {
|
if (!local.custom && field.custom) {
|
||||||
console.log("field", field.custom);
|
|
||||||
local.custom = field.custom;
|
local.custom = field.custom;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!local.exec) {
|
if (field.custom) {
|
||||||
local.exec = true;
|
const res = local.custom();
|
||||||
const callback = (value: any, should_render: boolean) => {
|
if (res instanceof Promise) {
|
||||||
local.result = value;
|
console.error("Custom Function cannot be async");
|
||||||
if (should_render) {
|
return null;
|
||||||
local.render();
|
} else {
|
||||||
setTimeout(() => {
|
local.result = res;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ export type FieldProp = {
|
||||||
_meta: any;
|
_meta: any;
|
||||||
_item: any;
|
_item: any;
|
||||||
_sync: any;
|
_sync: any;
|
||||||
custom?: () => Promise<CustomField>;
|
custom?: () => CustomField;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FMInternal = {
|
export type FMInternal = {
|
||||||
|
|
|
||||||
|
|
@ -23,16 +23,13 @@ export const genFieldMitem = (arg: {
|
||||||
?.get("content")
|
?.get("content")
|
||||||
?.get("childs");
|
?.get("childs");
|
||||||
|
|
||||||
const col = fm.field_def[field.name];
|
const component = fieldMapping[field.type as "text"];
|
||||||
if (col) {
|
if (component) {
|
||||||
const component = fieldMapping[field.type as "text"];
|
const item = createItem({
|
||||||
if (component) {
|
component: component as any,
|
||||||
const item = createItem({
|
});
|
||||||
component: component as any,
|
|
||||||
});
|
|
||||||
|
|
||||||
_sync(childs, [...childs.toJSON(), item]);
|
_sync(childs, [...childs.toJSON(), item]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue