import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import React from "react";
import { StyledButton } from "../../../CommonUI/Components/Button";
import { Layer } from "../../../CommonUI/Components/Layer";
import { XFormDesigner } from "../../../Form/XFormDesigner";
export const FormEditUI = ({ onSave, form: propform, name, onClose, dataDefinition, onFormNameUpdate, }) => {
    const [open, setOpen] = React.useState(false);
    const [form, setForm] = React.useState(propform);
    const onFormSave = (data) => {
        setOpen(false);
        onSave(form.getStorageData());
    };
    const onFormClose = () => {
        setOpen(false);
        setForm(propform);
        onClose();
    };
    return (_jsxs(_Fragment, { children: [_jsx(StyledButton, Object.assign({ color: "primary", variant: "contained", onClick: () => setOpen(true) }, { children: "Edit Form" }), void 0),
            _jsx(Layer, { open: open, maxWidth: false, fullScreen: true, renderUI: () => (_jsx(XFormDesigner, { form: form, formName: name, onFormSave: onFormSave, onFormClose: onFormClose, onFormNameUpdate: onFormNameUpdate, dataDefinition: dataDefinition ? () => dataDefinition : undefined }, void 0)), onClose: () => setOpen(false) }, void 0)] }, void 0));
};
//# sourceMappingURL=FormEditUI.js.map