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

const IconSelectMeta: ComponentMetadata = {
  componentName: 'IconSelect',
  title: '选择图标',
  docUrl: '',
  screenshot: '',
  devMode: 'proCode',
  npm: {
    package: '@pisell/materials',
    version: '0.1.0',
    exportName: 'IconSelect',
    main: 'src/index.tsx',
    destructuring: true,
    subName: '',
  },
  configure: {
    props: [
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'value',
            'zh-CN': '当前图标',
          },
        },
        name: 'value',
        setter: AntdIconSetter,
        supportVariable: true,
      },
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'defaultValue',
            'zh-CN': '默认图标',
          },
        },
        name: 'defaultValue',
        setter: AntdIconSetter,
        supportVariable: true,
      },
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'disabled',
            'zh-CN': '是否禁用',
          },
        },
        name: 'disabled',
        setter: 'BoolSetter',
        defaultValue: false,
        supportVariable: true,
      },
    ],
    supports: {
      style: true,
      className: true,
      events: [
        {
          name: 'onChange',
          template:
            "onChange(icon,${extParams}){\n// 选择icon变化时的回调\nconsole.log('onChange',icon);}",
        },
      ],
    },
    component: {
      isContainer: false,
      nestingRule: {
        childWhitelist: [],
      },
    },
  },
  experimental: {
    callbacks: {},
  },
  category: '表单',
};

const snippets: Snippet[] = [
  {
    title: '选择图标',
    screenshot: 'https://alifd.alicdn.com/fusion-cool/icons/icon-antd/icon-1.jpg',
    schema: {
      componentName: 'IconSelect',
      props: {
        placeholder: '选择图标',
      },
    },
  },
];

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