"use client";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Popover, PopoverContent, PopoverTrigger, } from "../components/ui/popover";
import { forwardRef, useImperativeHandle, useState, } from "react";
import { FieldList } from "./FieldList";
import { CloseButton } from "../components/ui/close-button";
export const FieldEditorPopup = forwardRef((_, ref) => {
    const [isOpen, setIsOpen] = useState(false);
    const [sections, setSections] = useState([]);
    const [fields, setFields] = useState([]);
    useImperativeHandle(ref, () => ({
        show: (fields, sections, ev) => {
            setFields(fields);
            setSections(sections);
            setIsOpen(true);
        },
        close: () => {
            setIsOpen(false);
        },
    }));
    return (_jsxs(Popover, { open: isOpen, onOpenChange: setIsOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx("div", { style: { display: "none" } }) }), _jsx(PopoverContent, { className: "h-96 w-96", children: _jsxs("div", { className: "flex flex-col gap-2 overflow-auto", onClick: (ev) => ev.stopPropagation(), children: [_jsx("div", { className: "flex justify-end p-3", children: _jsx(CloseButton, { onClick: () => setIsOpen(false), label: "Close field editor" }) }), fields && (_jsx(FieldList, { fields: [{ fields }], sections: sections, validators: [] })), _jsx("div", { className: "text-neutral-grey-50 p-2 text-xs", children: "TEST" })] }) })] }));
});
//# sourceMappingURL=FieldEditorPopup.js.map