import { jsx as _jsx } from "react/jsx-runtime";
import { Box } from '../box';
import { useVuiContext } from '../core';
import { Dialog } from '../dialog';
import { Input } from '../input';
export const useDialog = () => {
    const { setPortalSlot } = useVuiContext();
    const showConfirm = (title, message) => new Promise(resolve => setPortalSlot(_jsx(Dialog, { body: message, cancelButton: {
            onClick: () => {
                resolve(false);
                setPortalSlot(null);
            },
            text: 'Cancel',
        }, closeButton: false, isOpen: true, submitButton: {
            onClick: () => {
                resolve(true);
                setPortalSlot(null);
            },
            text: 'Confirm',
        }, title: title })));
    const showPrompt = (title, value = '') => new Promise(resolve => {
        let inputValue = value;
        setPortalSlot(_jsx(Dialog, { body: _jsx(Box, { px: 3, py: 2, children: _jsx(Input, { onChange: e => (inputValue = e.target.value), value: value }) }), cancelButton: {
                onClick: () => {
                    resolve(false);
                    setPortalSlot(null);
                },
                text: 'Cancel',
            }, closeButton: false, isOpen: true, submitButton: {
                onClick: () => {
                    resolve(inputValue);
                    setPortalSlot(null);
                },
                text: 'Submit',
            }, title: title }));
    });
    return { showConfirm, showPrompt };
};
//# sourceMappingURL=useDialog.js.map