Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
insertField,
updateField,
deleteField,
data,
moveField,
moveRow,
getFieldPlugin
} = useFormEditor();
const [editingField, setEditingField] = useState(null);
const [dropTarget, setDropTarget]: [FieldLayoutPositionType, Function] = useState(null);
const editField = useCallback(field => {
setEditingField(cloneDeep(field));
});
const i18n = useI18N();
const handleDropField = useCallback((source, dropTarget) => {
const { pos, name, ui } = source;
if (name === "custom") {
editField({});
setDropTarget(dropTarget);
return;
}
if (ui === "row") {
// Reorder rows.
// Reorder logic is different depending on the source and target position.
return moveRow(pos.row, dropTarget.row);
}