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";
const CustomItemsMenu = (props)=>{
    const { items, options, ...others } = props;
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Menu, {
        ...others,
        items: items.map((item)=>({
                key: item.name,
                label: item.title,
                onClick: item.onClick
            }))
    });
};
const CustomListGridMenu = (props)=>{
    const { items, options, ...others } = props;
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.List, {
        ...others,
        dataSource: items,
        grid: {
            gutter: 16,
            column: 2
        },
        renderItem: (item)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.List.Item, {
                children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)(__WEBPACK_EXTERNAL_MODULE_antd__.Card, {
                    title: item.title,
                    onClick: item.onClick,
                    children: [
                        item.name,
                        " - ",
                        item.title
                    ]
                })
            })
    });
};
const myInitializer = new __WEBPACK_EXTERNAL_MODULE__tachybase_client__.SchemaInitializer({
    name: 'myInitializer',
    designable: true,
    title: 'Button Text',
    ItemsComponent: CustomItemsMenu,
    items: [
        {
            name: 'a',
            title: 'item a',
            onClick: ()=>{
                alert('a1');
            }
        },
        {
            name: 'b',
            title: 'item b'
        }
    ]
});
const Root = ()=>{
    const { exists, render } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_client__.useSchemaInitializerRender)('myInitializer');
    if (!exists) return null;
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)("div", {
        children: [
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
                children: "渲染为 Menu"
            }),
            render(),
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Divider, {}),
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
                children: "渲染为 List Grid"
            }),
            render({
                ItemsComponent: CustomListGridMenu,
                itemsComponentStyle: {
                    width: 300
                }
            })
        ]
    });
};
class MyPlugin extends __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Plugin {
    async load() {
        this.app.schemaInitializerManager.add(myInitializer);
        this.app.router.add('root', {
            path: '/',
            Component: Root
        });
    }
}
const app = new __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Application({
    router: {
        type: 'memory',
        initialEntries: [
            '/'
        ]
    },
    plugins: [
        MyPlugin
    ]
});
const custom_items_component_rslib_entry_ = app.getRootComponent();
export { custom_items_component_rslib_entry_ as default };
