import { type ComponentConfigModel } from "epic-designer";
import $Bus from "@/utils/mittBus";

export default {
    component: async () => await import("./index.vue"),
    groupName: "自定义",
    // icon: "epic-icon-user",
    defaultSchema: {
        type: "epic-user-select",
        label: "用户选择",
        input: true,
        field: "epic-user-select", // 框架会自动添加唯一标识后缀

        componentProps: {
            placeholder: "请选择用户"
        }
    },
    config: {
        attribute: [
            {
                field: "field",
                label: "字段名",
                type: "input",
                componentProps: {
                    disabled: true // 禁止修改field，确保唯一性
                }
            },
            {
                field: "label",
                label: "标题",
                type: "input"
            },
            // {
            //     field: "componentProps.placeholder",
            //     label: "占位文本",
            //     type: "input"
            // },
            {
                field: "componentProps.defaultValue",
                label: "选择用户",
                type: "button",
                componentProps: {
                    // label: "打开组件弹窗",
                    onClick: () => {
                        // 仅触发事件，不传递标识
                        $Bus.emit("trigger-user-select-modal");
                    }
                }
            },
            {
                field: "componentProps.disabled",
                label: "禁用",
                type: "switch"
            }
        ],
        event: [
            // {
            //     type: "userSelected",
            //     describe: "用户选择完成时触发"
            // }
        ]
    },
    // bindModel: "componentProps.defaultValue",
    sort: 100
} as ComponentConfigModel;
