import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_client__ from "@tachybase/client";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
const useCloseAction = ()=>{
    const { setVisible } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_client__.useActionContext)();
    const form = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useForm)();
    return {
        async run () {
            setVisible(false);
            form.submit((values)=>{
                console.log(values);
            });
        }
    };
};
const schema = {
    type: 'object',
    properties: {
        drawer1: {
            'x-component': 'Action.Drawer',
            type: 'void',
            title: 'Drawer Title',
            properties: {
                hello1: {
                    'x-content': 'Hello',
                    title: 'T1'
                },
                footer1: {
                    'x-component': 'Action.Drawer.Footer',
                    type: 'void',
                    properties: {
                        close1: {
                            title: 'Close',
                            'x-component': 'Action',
                            'x-component-props': {
                                useAction: '{{ useCloseAction }}'
                            }
                        }
                    }
                }
            }
        }
    }
};
const demo2_rslib_entry_ = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.observer)(()=>{
    const [visible, setVisible] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.SchemaComponentProvider, {
        components: {
            Form: __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Form,
            Action: __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Action,
            Input: __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Input,
            FormItem: __WEBPACK_EXTERNAL_MODULE__tachybase_client__.FormItem
        },
        children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.ActionContextProvider, {
            value: {
                visible,
                setVisible
            },
            children: [
                /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("a", {
                    onClick: ()=>setVisible(true),
                    children: "Open"
                }),
                /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.SchemaComponent, {
                    scope: {
                        useCloseAction
                    },
                    schema: schema
                })
            ]
        })
    });
});
export { demo2_rslib_entry_ as default };
