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_antd__ from "antd";
import * as __WEBPACK_EXTERNAL_MODULE__createApp_mjs__ from "./createApp.mjs";
const DemoForm = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_client__.withDynamicSchemaProps)((props)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)(__WEBPACK_EXTERNAL_MODULE_antd__.Form, {
        labelCol: {
            span: 8
        },
        wrapperCol: {
            span: 16
        },
        style: {
            maxWidth: 600
        },
        autoComplete: "off",
        ...props,
        children: [
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Form.Item, {
                label: "Username",
                name: "username",
                rules: [
                    {
                        required: true,
                        message: 'Please input your username!'
                    }
                ],
                children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Input, {})
            }),
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Form.Item, {
                label: "Age",
                name: "age",
                rules: [
                    {
                        required: true,
                        message: 'Please input your age!'
                    }
                ],
                children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.InputNumber, {})
            }),
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Form.Item, {
                wrapperCol: {
                    offset: 8,
                    span: 16
                },
                children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Button, {
                    type: "primary",
                    htmlType: "submit",
                    children: "Submit"
                })
            })
        ]
    }));
function useDemoFormProps() {
    const resource = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_client__.useDataBlockResource)();
    const onFinish = async (values)=>{
        console.log('values', values);
        await resource.create({
            values
        });
        __WEBPACK_EXTERNAL_MODULE_antd__.notification.success({
            message: 'Save successfully!'
        });
    };
    return {
        onFinish
    };
}
const collection = 'users';
const schema = {
    type: 'void',
    name: 'root',
    'x-decorator': 'DataBlockProvider',
    'x-decorator-props': {
        collection: collection
    },
    'x-component': 'CardItem',
    properties: {
        demo: {
            type: 'object',
            'x-component': 'DemoForm',
            'x-use-component-props': 'useDemoFormProps'
        }
    }
};
const Demo = ()=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.SchemaComponent, {
        schema: schema
    });
const mocks = {
    ["".concat(collection, ":create")]: (config)=>{
        console.log('config.data', config.data);
        return [
            200,
            {
                msg: 'ok'
            }
        ];
    }
};
const Root = (0, __WEBPACK_EXTERNAL_MODULE__createApp_mjs__.createApp)(Demo, {
    components: {
        DemoForm
    },
    scopes: {
        useDemoFormProps
    }
}, mocks);
const collection_form_create_rslib_entry_ = Root;
export { collection_form_create_rslib_entry_ as default };
