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

const PisellImportMeta: IPublicTypeComponentMetadata = {
  componentName: 'PisellImport',
  title: '导入',
  category: '数据录入',
  docUrl: '',
  screenshot: '',
  devMode: 'proCode',
  npm: {
    package: '@pisell/materials',
    version: '1.0.0',
    exportName: 'PisellImport',
    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': 'File', 'zh-CN': '文件' },
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'accept',
            title: {
              label: { type: 'i18n', 'en-US': 'Accept', 'zh-CN': '接受类型' },
              tip: { type: 'i18n', 'en-US': 'e.g. .xlsx,.csv', 'zh-CN': '与 input accept 一致，如 .xlsx,.csv' },
            },
            propType: 'string',
            setter: ['StringSetter', 'VariableSetter'],
          },
          {
            name: 'multiple',
            title: {
              label: { type: 'i18n', 'en-US': 'Multiple', 'zh-CN': '多选' },
              tip: { type: 'i18n', 'en-US': 'Allow multiple files', 'zh-CN': '是否允许多选文件' },
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: false,
          },
          {
            name: 'maxSize',
            title: {
              label: { type: 'i18n', 'en-US': 'Max Size (MB)', 'zh-CN': '最大体积(MB)' },
              tip: { type: 'i18n', 'en-US': 'Max file size in MB', 'zh-CN': '单文件最大体积，单位 MB' },
            },
            propType: 'number',
            setter: ['NumberSetter', '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 upload/import 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: 'onImport',
          template:
            "onImport(files, event, ${extParams}) {\n  // 选择文件后触发，files 为 File 数组\n  console.log('onImport', files, event);\n}",
        },
        {
          name: 'onError',
          template:
            "onError(error, ${extParams}) {\n  // 校验失败时触发，如文件过大 error.type === 'MAX_SIZE'\n  console.log('onError', error);\n}",
        },
      ],
    },
    component: {},
  },
};

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