import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_client__ from "@tachybase/client";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_components__ from "@tachybase/components";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
import * as __WEBPACK_EXTERNAL_MODULE__apiClient_mjs__ from "./apiClient.mjs";
const schema = {
    type: 'object',
    properties: {
        form1: {
            type: 'void',
            'x-uid': 'form1',
            'x-component': 'Form',
            'x-component-props': {
                request: {
                    resource: 'posts',
                    action: 'get'
                }
            },
            properties: {
                field1: {
                    title: 'T1',
                    'x-component': 'Input',
                    'x-component-props': {
                        className: 't1'
                    },
                    'x-decorator': 'FormItem'
                },
                field2: {
                    title: 'T2',
                    'x-component': 'Input',
                    'x-component-props': {
                        className: 't2'
                    },
                    'x-decorator': 'FormItem',
                    required: true,
                    default: 'default value'
                },
                out: {
                    'x-component': 'Output'
                },
                Space: {
                    type: 'void',
                    'x-component': 'Space',
                    properties: {
                        action2: {
                            'x-component': 'Action',
                            title: 'Submit',
                            'x-component-props': {
                                useAction: '{{ useSubmit }}'
                            }
                        },
                        action1: {
                            title: 'Refresh',
                            'x-component': 'Action',
                            'x-component-props': {
                                useAction: '{{ useRefresh }}'
                            }
                        }
                    }
                }
            }
        }
    }
};
const Output = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.observer)(()=>{
    const form = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useForm)();
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("pre", {
        children: JSON.stringify(form.values, null, 2)
    });
}, {
    displayName: 'Output'
});
const useSubmit = ()=>{
    const form = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useForm)();
    return {
        async run () {
            await form.submit();
            console.log(form.values);
        }
    };
};
const useRefresh = ()=>{
    const apiClient = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_client__.useAPIClient)();
    return {
        async run () {
            var _apiClient_service;
            null === (_apiClient_service = apiClient.service('form1')) || void 0 === _apiClient_service || _apiClient_service.refresh();
        }
    };
};
const demo5_rslib_entry_ = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.observer)(()=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.APIClientProvider, {
        apiClient: __WEBPACK_EXTERNAL_MODULE__apiClient_mjs__.apiClient,
        children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.SchemaComponentProvider, {
            scope: {
                useSubmit,
                useRefresh
            },
            components: {
                Space: __WEBPACK_EXTERNAL_MODULE_antd__.Space,
                Card: __WEBPACK_EXTERNAL_MODULE_antd__.Card,
                Output,
                Action: __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Action,
                Form: __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Form,
                Input: __WEBPACK_EXTERNAL_MODULE__tachybase_components__.Input,
                FormItem: __WEBPACK_EXTERNAL_MODULE__tachybase_components__.FormItem
            },
            children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.SchemaComponent, {
                schema: schema
            })
        })
    }));
export { demo5_rslib_entry_ as default };
