import { AntdIconSetter } from '../../../materials/lowcode/_setters';

const ComprehensiveSearchMeta = {
  componentName: 'ComprehensiveSearch',
  title: '综合搜索',
  docUrl: '',
  screenshot: '',
  devMode: 'proCode',
  npm: {
    package: '@pisell/private-materials',
    version: '1.0.0',
    exportName: 'ComprehensiveSearch',
    main: 'src/index.ts',
    destructuring: true,
    subName: '',
  },
  props: [
    {
      name: 'renderType',
      title: {
        label: '渲染类型',
        tip: 'renderType | 渲染类型',
      },
      setter: {
        componentName: 'SelectSetter',
        props: {
          options: [
            {
              title: '弹窗',
              value: 'modal',
            },
            {
              title: '抽屉',
              value: 'drawer',
            },
            {
              title: '指定位置',
              value: 'portal',
            },
            {
              title: '当前位置',
              value: '',
            },
          ],
        },
      },
    },
    {
      name: 'containerProps',
      title: {
        label: '容器组件props',
        tip: '参考PisellContainer',
      },
      setter: 'JsonSetter',
    },
    {
      title: '扫码枪',
      name: 'isShowScanner',
      setter: 'BoolSetter',
      defaultValue: true,
    },
    {
      title: '摄像头',
      name: 'isShowCamera',
      setter: 'BoolSetter',
      defaultValue: true,
    },
    {
      title: 'NFC',
      name: 'isShowNFC',
      setter: 'BoolSetter',
      defaultValue: true,
    },
    {
      type: 'group',
      display: 'block',
      title: '新建按钮',
      items: [
        {
          title: '开启',
          name: 'isShowNewButton',
          setter: 'BoolSetter',
          defaultValue: true,
        },
        {
          title: '新建按钮位置',
          name: 'newButtonAlign',
          setter: {
            componentName: 'RadioGroupSetter',
            props: {
              options: [
                {
                  label: '居左',
                  value: 'left',
                },
                {
                  label: '局中',
                  value: 'center',
                },
                {
                  label: '居右',
                  value: 'right',
                },
              ],
            },
            initialValue: 'left',
          },
        },
        {
          title: '新建按钮文案',
          name: 'newButtonText',
          setter: 'PisellI18nSetter',
        },
        // {
        //   title: '新建按钮弹窗数据',
        //   name: 'newDialogDataSource',
        //   setter: {
        //     componentName: 'PisellDataSourceSetter',
        //   },
        // },
      ],
    },
    {
      type: 'group',
      display: 'block',
      title: '搜索',
      items: [
        {
          title: '搜索框',
          name: 'isShowSearch',
          setter: 'BoolSetter',
          defaultValue: true,
        },
        {
          title: '搜索框摄像头',
          name: 'isShowSearchCamera',
          setter: 'BoolSetter',
          defaultValue: true,
        },
        {
          title: '搜索框icon',
          name: 'searchIcon',
          setter: AntdIconSetter,
        },
        {
          title: '搜索框文案',
          name: 'placeholder',
          setter: 'PisellI18nSetter',
        },
        {
          title: '搜索按钮',
          name: 'isShowSearchButton',
          setter: 'BoolSetter',
          defaultValue: true,
        },
        {
          title: '搜索结果展示',
          name: 'resultDisplay',
          setter: [
            {
              componentName: 'SelectSetter',
              props: {
                options: [
                  {
                    label: '列表',
                    value: 'list',
                  },
                  {
                    label: 'grid',
                    value: 'grid',
                  },
                ],
              },
            },
            {
              componentName: 'SlotSetter',
            },
          ],
          defaultValue: 'grid',
        },
        // {
        //   title: '搜索结果展示顺序',
        //   name: 'resultSort',
        //   setter: {
        //     componentName: 'SelectSetter',
        //     props: {
        //       options: [
        //         {
        //           label: '正序',
        //           value: 'asc',
        //         },
        //         {
        //           label: '倒序',
        //           value: 'desc',
        //         },
        //         {
        //           label: '自定义',
        //           value: 'custom',
        //         },
        //       ],
        //     },
        //     initialValue: 'desc',
        //   },
        // },
        // {
        //   title: '自定义排序',
        //   name: 'sortBy',
        //   condition: (target: any) =>
        //     target.getProps().getPropValue('resultSort') === 'custom',
        //   setter: 'StringSetter',
        // },
      ],
    },
  ],
  configure: {
    component: {
      isModal: true,
      nestingRule: {
        parentWhitelist: ['Page', 'Component'],
      },
    },
    supports: {
      events: [
        {
          name: 'onChange',
        },
        {
          name: 'onSearch',
        },
        {
          name: 'onAdd',
        },
        {
          name: 'onDataChange',
        },
        {
          name: 'onRowClick',
        },
      ],
      style: true,
    },
  },
};

const snippets = [
  {
    title: '综合搜索',
    screenshot: '',
    schema: {
      componentName: 'ComprehensiveSearch',
      props: {
        renderType: 'modal',
      },
    },
  },
];

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