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";
import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
import * as __WEBPACK_EXTERNAL_MODULE_lodash__ from "lodash";
const useCloseAction = ()=>{
    const { setVisible } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_client__.useActionContext)();
    return {
        async run () {
            setVisible(false);
        }
    };
};
const Editable = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.observer)((props)=>{
    const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
    const schema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)("div", {
        children: [
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)("div", {
                style: {
                    marginBottom: 24
                },
                children: [
                    "打开方式：",
                    /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)(__WEBPACK_EXTERNAL_MODULE_antd__.Radio.Group, {
                        value: field.componentProps.openMode,
                        onChange: (e)=>{
                            field.componentProps.openMode = e.target.value;
                            __WEBPACK_EXTERNAL_MODULE_lodash__["default"].set(schema, 'x-component-props.openMode', e.target.value);
                        },
                        children: [
                            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Radio.Button, {
                                value: "drawer",
                                children: "Drawer"
                            }),
                            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Radio.Button, {
                                value: "modal",
                                children: "Modal"
                            }),
                            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Radio.Button, {
                                value: "page",
                                children: "Page"
                            })
                        ]
                    })
                ]
            }),
            props.children
        ]
    });
}, {
    displayName: 'Editable'
});
const demo3_rslib_entry_schema = {
    type: 'object',
    properties: {
        action1: {
            type: 'void',
            title: 'Open',
            'x-decorator': 'Editable',
            'x-component': 'Action',
            'x-component-props': {
                type: 'primary',
                openMode: 'modal',
                containerRefKey: 'containerRef'
            },
            properties: {
                drawer1: {
                    type: 'void',
                    title: 'Modal Title',
                    'x-component': 'Action.Container',
                    'x-component-props': {},
                    properties: {
                        hello1: {
                            title: 'T1',
                            'x-content': 'Hello'
                        },
                        footer1: {
                            type: 'void',
                            'x-component': 'Action.Container.Footer',
                            properties: {
                                close1: {
                                    title: 'Close',
                                    'x-component': 'Action',
                                    'x-component-props': {
                                        useAction: '{{ useCloseAction }}'
                                    }
                                },
                                submit: {
                                    title: 'Submit',
                                    'x-component': 'Action',
                                    'x-component-props': {
                                        type: 'primary',
                                        useAction: '{{ useCloseAction }}'
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
};
const demo3_rslib_entry_ = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.observer)(()=>{
    const containerRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null);
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.SchemaComponentProvider, {
        scope: {
            useCloseAction,
            containerRef
        },
        components: {
            Editable,
            Action: __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Action
        },
        children: [
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.SchemaComponent, {
                schema: demo3_rslib_entry_schema
            }),
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
                ref: containerRef
            })
        ]
    });
});
export { demo3_rslib_entry_ as default };
