import snippets from './snippets';
import type { IPublicTypeComponentMetadata } from '@alilc/lowcode-types';

const PisellExportMeta: IPublicTypeComponentMetadata = {
  componentName: 'PisellExport',
  title: '导出',
  category: '数据录入',
  docUrl: '',
  screenshot: '',
  devMode: 'proCode',
  npm: {
    package: '@pisell/materials',
    version: '1.0.0',
    exportName: 'PisellExport',
    main: 'src/index.tsx',
    destructuring: true,
    subName: '',
  },
  configure: {
    props: [
      {
        title: {
          label: { type: 'i18n', 'en-US': 'Basic', 'zh-CN': '基础' },
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'variant',
            title: {
              label: { type: 'i18n', 'en-US': 'Display', 'zh-CN': '展示形态' },
              tip: { type: 'i18n', 'en-US': 'icon | button', 'zh-CN': '仅图标 | 图标+文案' },
            },
            propType: { type: 'oneOf', value: ['icon', 'button'] },
            setter: [
              {
                componentName: 'RadioGroupSetter',
                props: {
                  options: [
                    { title: '仅图标', value: 'icon' },
                    { title: '图标+文案', value: 'button' },
                  ],
                },
              },
              'VariableSetter',
            ],
            defaultValue: 'button',
          },
          {
            name: 'size',
            title: {
              label: { type: 'i18n', 'en-US': 'Size', 'zh-CN': '尺寸' },
              tip: { type: 'i18n', 'en-US': 'small | medium | large', 'zh-CN': '小 | 中 | 大' },
            },
            propType: { type: 'oneOf', value: ['small', 'medium', 'large'] },
            setter: [
              {
                componentName: 'RadioGroupSetter',
                props: {
                  options: [
                    { title: '小', value: 'small' },
                    { title: '中', value: 'medium' },
                    { title: '大', value: 'large' },
                  ],
                },
              },
              'VariableSetter',
            ],
            defaultValue: 'medium',
          },
          {
            name: 'type',
            title: {
              label: { type: 'i18n', 'en-US': 'Type', 'zh-CN': '视觉类型' },
              tip: { type: 'i18n', 'en-US': 'default | primary', 'zh-CN': '默认 | 主色' },
            },
            propType: { type: 'oneOf', value: ['default', 'primary'] },
            setter: [
              {
                componentName: 'RadioGroupSetter',
                props: {
                  options: [
                    { title: '默认', value: 'default' },
                    { title: '主色', value: 'primary' },
                  ],
                },
              },
              'VariableSetter',
            ],
            defaultValue: 'default',
          },
          {
            name: 'label',
            title: {
              label: { type: 'i18n', 'en-US': 'Label', 'zh-CN': '文案' },
              tip: { type: 'i18n', 'en-US': 'Button label, use i18n or slot', 'zh-CN': 'Button 形态文案，支持国际化或插槽' },
            },
            propType: { type: 'oneOfType', value: ['string', 'node'] },
            setter: ['PisellI18nSetter', 'StringSetter', 'SlotSetter', 'VariableSetter'],
          },
        ],
      },
      {
        title: {
          label: { type: 'i18n', 'en-US': 'Slot', 'zh-CN': '插槽' },
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'icon',
            title: {
              label: { type: 'i18n', 'en-US': 'Icon', 'zh-CN': '自定义图标' },
              tip: { type: 'i18n', 'en-US': 'Custom icon, default is download icon', 'zh-CN': '自定义图标，不传则使用默认下载图标' },
            },
            propType: { type: 'oneOfType', value: ['node'] },
            setter: [
              {
                componentName: 'SlotSetter',
                initialValue: { type: 'JSSlot', value: [] },
              },
              'VariableSetter',
            ],
          },
        ],
      },
      {
        title: {
          label: { type: 'i18n', 'en-US': 'State', 'zh-CN': '状态' },
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'disabled',
            title: {
              label: { type: 'i18n', 'en-US': 'Disabled', 'zh-CN': '是否禁用' },
              tip: { type: 'i18n', 'en-US': 'disabled | Whether disabled', 'zh-CN': 'disabled | 是否禁用' },
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: false,
          },
        ],
      },
      {
        title: {
          label: { type: 'i18n', 'en-US': 'Style', 'zh-CN': '样式' },
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'className',
            title: {
              label: { type: 'i18n', 'en-US': 'ClassName', 'zh-CN': '类名' },
              tip: 'className | 自定义类名',
            },
            propType: 'string',
            setter: ['StringSetter', 'VariableSetter'],
          },
          {
            name: 'style',
            title: {
              label: { type: 'i18n', 'en-US': 'Style', 'zh-CN': '内联样式' },
              tip: 'style | 自定义样式对象',
            },
            propType: 'object',
            setter: 'StyleSetter',
          },
        ],
      },
    ],
    supports: {
      style: true,
      className: true,
      events: [
        {
          name: 'onExport',
          template:
            "onExport(event, ${extParams}) {\n  // 点击导出时由调用方实现导出逻辑\n  console.log('onExport', event);\n}",
        },
      ],
    },
    component: {},
  },
};

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