import { ComponentMetadata, Snippet } from '@alilc/lowcode-types';

/**
 * 普通商品详情弹窗（NormalProductDetailModal）— 低代码物料描述
 * 通过 ref.init 打开；props 仅配置 onConfirm / onRemove / onClose。
 */
const NormalProductDetailModalMeta: ComponentMetadata = {
  componentName: 'NormalProductDetailModal',
  title: '普通商品详情弹窗',
  docUrl: '',
  screenshot: '',
  devMode: 'proCode',
  npm: {
    package: '@pisell/private-materials',
    version: '6.11.157',
    exportName: 'NormalProductDetailModal',
    main: 'src/index.ts',
    destructuring: true,
    subName: '',
  },
  configure: {
    props: [
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'className',
            'zh-CN': '类名',
          },
        },
        name: 'className',
        setter: ['StringSetter', 'VariableSetter'],
      },
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'style',
            'zh-CN': '样式',
          },
        },
        name: 'style',
        setter: ['JsonSetter', 'VariableSetter'],
      },
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'onConfirm',
            'zh-CN': '确认回调',
          },
          tip: '唯一确认出口：{ mode: \'edit\', data } 或 { mode: \'create\', formattedLine, detail }',
        },
        name: 'onConfirm',
        setter: ['FunctionSetter', 'VariableSetter'],
      },
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'onRemove',
            'zh-CN': '移除回调',
          },
          tip: '弹窗内移除商品时触发',
        },
        name: 'onRemove',
        setter: ['FunctionSetter', 'VariableSetter'],
      },
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'onClose',
            'zh-CN': '关闭回调',
          },
          tip: '弹窗关闭时触发（在 init.onClose 之后）',
        },
        name: 'onClose',
        setter: ['FunctionSetter', 'VariableSetter'],
      },
    ],
    supports: {
      style: true,
      className: true,
      events: [
        {
          name: 'onConfirm',
          description: '编辑确认，参数为商品行数据',
        },
        {
          name: 'onRemove',
          description: '移除商品',
        },
        {
          name: 'onClose',
          description: '弹窗关闭',
        },
      ],
    },
    component: {},
  },
};

const snippets: Snippet[] = [
  {
    title: '普通商品详情弹窗',
    screenshot: '',
    schema: {
      componentName: 'NormalProductDetailModal',
      props: {},
    },
  },
];

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