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

const PisellSortMeta: IPublicTypeComponentMetadata = {
  componentName: 'PisellSort',
  title: 'PisellSort',
  category: '数据展示',
  docUrl: '',
  screenshot: '',
  devMode: 'proCode',
  npm: {
    package: '@pisell/materials',
    version: '1.0.3',
    exportName: 'PisellSort',
    main: 'src/index.tsx',
    destructuring: true,
    subName: '',
  },
  configure: {
    props: [
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'Basic',
            'zh-CN': '基础',
          },
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'name',
            title: {
              label: {
                type: 'i18n',
                'en-US': 'Field Name',
                'zh-CN': '字段名称',
              },
              tip: {
                type: 'i18n',
                'en-US': 'name | Form field name, default is sort_key',
                'zh-CN': 'name | 表单字段名称，默认为 sort_key',
              },
            },
            propType: 'string',
            setter: ['StringSetter', 'VariableSetter'],
            defaultValue: 'sort_key',
          },
          {
            name: 'list',
            title: {
              label: {
                type: 'i18n',
                'en-US': 'Sort List',
                'zh-CN': '排序列表',
              },
              tip: {
                type: 'i18n',
                'en-US': 'list | Array of sort field configurations',
                'zh-CN': 'list | 排序字段配置数组',
              },
            },
            propType: {
              type: 'arrayOf',
              value: 'object',
            },
            setter: {
              componentName: 'ArraySetter',
              props: {
                itemSetter: {
                  componentName: 'ObjectSetter',
                  props: {
                    config: {
                      items: [
                        {
                          name: 'type',
                          title: {
                            label: {
                              type: 'i18n',
                              'en-US': 'Type',
                              'zh-CN': '字段类型',
                            },
                            tip: '排序字段的数据类型',
                          },
                          propType: {
                            type: 'oneOf',
                            value: ['date', 'string', 'number'],
                          },
                          setter: {
                            componentName: 'SelectSetter',
                            props: {
                              options: [
                                {
                                  title: '日期',
                                  value: 'date',
                                },
                                {
                                  title: '字符串',
                                  value: 'string',
                                },
                                {
                                  title: '数字',
                                  value: 'number',
                                },
                              ],
                            },
                          },
                          isRequired: true,
                        },
                        {
                          name: 'label',
                          title: {
                            label: {
                              type: 'i18n',
                              'en-US': 'Label',
                              'zh-CN': '显示标签',
                            },
                            tip: '排序项的显示文案',
                          },
                          propType: 'string',
                          setter: ['PisellI18nSetter', 'StringSetter', 'VariableSetter'],
                        },
                        {
                          name: 'name',
                          title: {
                            label: {
                              type: 'i18n',
                              'en-US': 'Name',
                              'zh-CN': '字段名称',
                            },
                            tip: '排序字段的名称',
                          },
                          propType: {
                            type: 'oneOfType',
                            value: ['string', 'array'],
                          },
                          setter: ['StringSetter', 'JsonSetter', 'VariableSetter'],
                        },
                        {
                          name: 'isCustom',
                          title: {
                            label: {
                              type: 'i18n',
                              'en-US': 'Custom Sort',
                              'zh-CN': '自定义排序',
                            },
                            tip: '是否为自定义排序',
                          },
                          propType: 'bool',
                          setter: ['BoolSetter', 'VariableSetter'],
                          isRequired: true,
                          defaultValue: false,
                        },
                        {
                          name: 'columnKey',
                          title: {
                            label: {
                              type: 'i18n',
                              'en-US': 'Column Key',
                              'zh-CN': '列键值',
                            },
                            tip: '对应的列键值',
                          },
                          propType: 'string',
                          setter: ['StringSetter', 'VariableSetter'],
                        },
                        {
                          name: 'localFilter',
                          title: {
                            label: {
                              type: 'i18n',
                              'en-US': 'Local Filter',
                              'zh-CN': '本地过滤',
                            },
                            tip: '是否使用本地过滤',
                          },
                          propType: 'bool',
                          setter: ['BoolSetter', 'VariableSetter'],
                          defaultValue: false,
                        },
                        {
                          name: 'isHidden',
                          title: {
                            label: {
                              type: 'i18n',
                              'en-US': 'Hidden',
                              'zh-CN': '是否隐藏',
                            },
                            tip: '是否隐藏该排序项',
                          },
                          propType: 'bool',
                          setter: ['BoolSetter', 'VariableSetter'],
                          defaultValue: false,
                        },
                      ],
                    },
                  },
                  initialValue: {
                    type: 'date',
                    label: '创建时间',
                    name: 'created_at',
                    isCustom: false,
                    localFilter: false,
                    isHidden: false,
                  },
                },
              },
            },
            isRequired: true,
          },
          {
            name: 'value',
            title: {
              label: {
                type: 'i18n',
                'en-US': 'Value',
                'zh-CN': '当前值',
              },
              tip: {
                type: 'i18n',
                'en-US': 'value | Current selected sort value',
                'zh-CN': 'value | 当前选中的排序值',
              },
            },
            propType: 'any',
            setter: ['StringSetter', 'VariableSetter'],
          },
        ],
      },
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'Appearance',
            'zh-CN': '外观',
          },
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'button',
            title: {
              label: {
                type: 'i18n',
                'en-US': 'Custom Button',
                'zh-CN': '自定义按钮',
              },
              tip: {
                type: 'i18n',
                'en-US': 'button | Custom trigger button',
                'zh-CN': 'button | 自定义触发按钮',
              },
            },
            propType: {
              type: 'oneOfType',
              value: ['node'],
            },
            setter: [
              {
                componentName: 'SlotSetter',
                initialValue: {
                  type: 'JSSlot',
                  value: [],
                },
              },
              'VariableSetter',
            ],
          },
          {
            name: 'placement',
            title: {
              label: {
                type: 'i18n',
                'en-US': 'Placement',
                'zh-CN': '弹出位置',
              },
              tip: {
                type: 'i18n',
                'en-US': 'placement | Dropdown menu placement',
                'zh-CN': 'placement | 下拉菜单弹出位置',
              },
            },
            propType: {
              type: 'oneOf',
              value: [
                'bottom',
                'bottomLeft',
                'bottomRight',
                'top',
                'topLeft',
                'topRight',
              ],
            },
            setter: [
              {
                componentName: 'SelectSetter',
                props: {
                  options: [
                    {
                      title: '下方居中',
                      value: 'bottom',
                    },
                    {
                      title: '下方左对齐',
                      value: 'bottomLeft',
                    },
                    {
                      title: '下方右对齐',
                      value: 'bottomRight',
                    },
                    {
                      title: '上方居中',
                      value: 'top',
                    },
                    {
                      title: '上方左对齐',
                      value: 'topLeft',
                    },
                    {
                      title: '上方右对齐',
                      value: 'topRight',
                    },
                  ],
                },
              },
              'VariableSetter',
            ],
          },
          {
            name: 'style',
            title: {
              label: {
                type: 'i18n',
                'en-US': 'Style',
                'zh-CN': '自定义样式',
              },
              tip: {
                type: 'i18n',
                'en-US': 'style | Custom style object',
                'zh-CN': 'style | 自定义样式对象',
              },
            },
            propType: 'object',
            setter: 'StyleSetter',
          },
        ],
      },
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'Advanced',
            'zh-CN': '高级',
          },
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'localPagination',
            title: {
              label: {
                type: 'i18n',
                'en-US': 'Local Pagination',
                'zh-CN': '本地分页',
              },
              tip: {
                type: 'i18n',
                'en-US': 'localPagination | Whether to use local pagination',
                'zh-CN': 'localPagination | 是否使用本地分页',
              },
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: false,
          },
        ],
      },
    ],
    supports: {
      style: true,
      className: true,
      events: [
        {
          name: 'onChange',
          template:
            "onChange(val, detail, ${extParams}){\n// 排序改变时的回调\nconsole.log('onChange', val, detail);}",
        },
      ],
    },
    component: {},
  },
};

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