import { ComponentMetadata } from "@alilc/lowcode-types";
import snippets from "./snippets";

const AlertMeta: ComponentMetadata = {
  componentName: "PisellAlert",
  title: "警告提示",
  category: "反馈",
  docUrl: "",
  screenshot: "",
  devMode: "proCode",
  npm: {
    package: "@pisell/materials",
    version: "1.0.1",
    exportName: "PisellAlert",
    main: "src/index.tsx",
    destructuring: true,
    subName: "",
  },
  props: [
    {
      name: "type",
      title: { label: "类型", tip: "类型" },
      propType: {
        type: "oneOf",
        value: ["success", "info", "warning", "error"],
      },
    },
    {
      name: "showDismiss",
      title: { label: "忽略按钮", tip: "忽略按钮" },
      propType: "bool",
    },
    {
      name: "dismiss",
      title: { label: "", tip: "" },
      propType: { type: "oneOfType", value: ["string", "node"] },
      setter: ["PisellI18nSetter", "SlotSetter"],
    },
    {
      name: "showView",
      title: { label: "行为按钮", tip: "行为按钮" },
      propType: "bool",
    },
    {
      name: "view",
      title: { label: "", tip: "" },
      propType: { type: "oneOfType", value: ["string", "node"] },
      setter: ["PisellI18nSetter", "SlotSetter"],
    },
    {
      name: "closable",
      title: { label: "关闭按钮", tip: "关闭按钮" },
      propType: "bool",
    },
    {
      name: "icon",
      title: {
        label: "图标",
        tip: "自定义图标，`showIcon` 为 true 时有效",
      },
      propType: "node",
    },
    {
      name: "description",
      title: {
        label: "正文内容",
        tip: "正文内容",
      },
      propType: { type: "oneOfType", value: ["string", "node"] },
      setter: ["PisellI18nSetter", "SlotSetter"],
    },
    {
      name: "message",
      title: { label: "标题内容", tip: "标题内容" },
      propType: { type: "oneOfType", value: ["string", "node"] },
      setter: ["PisellI18nSetter", "SlotSetter"],
    },
    {
      name: "showIcon",
      title: { label: "显示图标", tip: "是否显示辅助图标" },
      propType: "bool",
    },
    {
      name: "onClose",
      title: { label: "关闭时触发的回调函数", tip: "关闭时触发的回调函数" },
      propType: "func",
    },
  ],
  configure: {
    supports: {
      style: true,
      events: [
        {
          name: "onClose",
          template:
            "onChange(event,${extParams}){\n// 关闭时触发的回调函数\nconsole.log('onChange');}",
        },
        {
          name: "onClick",
          template:
            "onClick(event,${extParams}){\n// 点击时的回调\nconsole.log('onClick', event);}",
        },
        {
          name: "onViewClick",
          template:
            "onClick(event,${extParams}){\n// 点击行为按钮的回调\nconsole.log('onClick', event);}",
        },
      ],
    },
    component: {},
  },
};

export default {
  ...AlertMeta,
  snippets,
};
