import snippets from './snippets';

export default {
  snippets,
  componentName: 'ProductCard',
  title: '商品卡片',
  category: '数据展示',
  docUrl: '',
  screenshot: '',
  devMode: 'proCode',
  npm: {
    package: '@pisell/materials',
    version: '1.0.1',
    exportName: 'ProductCard',
    main: 'src/index.tsx',
    destructuring: true,
    subName: '',
  },
  props: [
    {
      title: '数据源',
      display: 'block',
      type: 'group',
      items: [
        {
          name: "dataSource",
          title: { label: "商品信息", tip: "商品信息" },
          propType: "object",
          setter: "JsonSetter",
        },
      ],
    },
    {
      title: '卡片信息展示',
      display: 'block',
      type: 'group',
      items: [
        {
          name: "isShowImage",
          title: { label: "商品图片", tip: "商品图片" },
          propType: "bool",
          setter: "BoolSetter",
          defaultValue: true,
        },
        {
          name: "isShowHolder",
          title: { label: "Holder name", tip: "主体名称" },
          propType: "bool",
          setter: "BoolSetter",
          defaultValue: true,
        },
        {
          name: "isShowNote",
          title: { label: "备注信息", tip: "商品备注信息" },
          propType: "bool",
          setter: "BoolSetter",
          defaultValue: true,
        },
        {
          name: "isShowDelete",
          title: { label: "删除按钮", tip: "操作删除商品" },
          propType: "bool",
          setter: "BoolSetter",
          defaultValue: true,
        },
        {
          name: "isShowAmountFooter",
          title: { label: "总金额", tip: "商品总金额" },
          propType: "bool",
          setter: "BoolSetter",
          defaultValue: true,
        },
      ],
    },
    {
      title: '卡片信息快捷操作',
      display: 'block',
      type: 'group',
      items: [
        {
          name: "isShowChangeHolder",
          title: { label: "更改 Holder", tip: "更改主体名称" },
          propType: "bool",
          setter: "BoolSetter",
          defaultValue: false,
        },
        {
          name: "holderMode",
          title: {
            label: "holder 选择",
            tip: "holderMode | holder 选择模式",
          },
          condition(target) {
            return !!target.getProps().getPropValue("isShowChangeHolder");
          },
          setter: {
            componentName: "RadioGroupSetter",
            props: {
              options: [
                {
                  title: "单选",
                  value: "single",
                },
                {
                  title: "多选",
                  value: "multiple",
                },
              ],
            },
          },
        },
        {
          name: "isShowChangeResource",
          title: { label: "更改资源", tip: "更改商品资源" },
          propType: "bool",
          setter: "BoolSetter",
          defaultValue: false,
        },
        {
          name: "isShowChangeDate",
          title: { label: "更改日期时间", tip: "更改商品日期时间" },
          propType: "bool",
          setter: "BoolSetter",
          defaultValue: false,
        },
      ],
    },
  ],
  configure: {
    component: { isContainer: true },
    supports: {
      style: true,
      events: [
        {
          name: 'onDelete',
          template:
            "onDelete(open,${extParams}){\n// 删除商品的回调\nconsole.log('onDelete',open);}",
        },
        {
          name: 'addNote',
          template:
            "addNote(open,${extParams}){\n// 添加备注的回调\nconsole.log('addNote',open);}",
        },
        {
          name: 'addTime',
          template:
            "addTime(open,${extParams}){\n// 添加时间的回调\nconsole.log('addTime',open);}",
        },
      ],
    },
  },
};
