import snippets from "./snippets";

export default {
  snippets,
  componentName: "Sort",
  title: "排序按钮",
  category: "数据展示",
  docUrl: "",
  screenshot: "",
  devMode: "proCode",
  npm: {
    package: "@pisell/materials",
    version: "1.0.1",
    exportName: "Sort",
    main: "src/index.tsx",
    destructuring: true,
    subName: "",
  },
  props: [
    {
      name: 'button',
      title: { label: '自定义按钮', tip: '自定义按钮' },
      propType: { type: 'oneOfType', value: ['node', 'func'] },
    },
    {
      name: 'value',
      title: { label: '当前选中项', tip: '当前选中的菜单项 key 数组' },
      propType: { type: 'arrayOf', value: 'string' },
    },
    {
      name: "list",
      setter: {
        componentName: "ArraySetter",
        props: {
          itemSetter: {
            componentName: "ObjectSetter",
            props: {
              config: {
                items: [
                  {
                    name: "label",
                    title: { label: "排序项", tip: "排序项展示文案" },
                    propType: "string",
                    setter: "PisellI18nSetter",
                    isRequired: true,
                  },
                  {
                    name: "name",
                    title: { label: "字段", tip: "所排序的字段" },
                    propType: "string",
                    setter: "StringSetter",
                    isRequired: true,
                  },
                  {
                    name: "type",
                    title: { label: "字段类型", tip: "所排序的字段类型" },
                    propType: "string",
                    setter: {
                      componentName: "SelectSetter",
                      mode: "single",
                      defaultValue: "single",
                      props: {
                        options: [
                          {
                            title: "日期排序",
                            value: "date",
                          },
                          {
                            title: "数字排序",
                            value: "number",
                          },
                          {
                            title: "a-z排序",
                            value: "string",
                          },
                          {
                            title: "时间排序",
                            value: "time",
                          },
                        ],
                      },
                    },
                  },
                ],
              },
            },
            initialValue: { label: "标题", name: "name", type: "date" },
          },
        },
      },
    },
    {
      name: 'placement',
      title: {
        label: '弹出位置',
        tip:
          '菜单弹出位置：`bottomLeft` `bottom` `bottomRight` `topLeft` `top` `topRight`',
      },
      propType: {
        type: 'oneOf',
        value: ['bottomLeft', 'bottom', 'bottomRight', 'topLeft', 'top', 'topRight'],
      },
    },
  ],
  configure: {
    supports: {
      style: true,
      events: [
        {
          name: "onChange",
          template:
            "onChange(val,${extParams}){\n// 排序\nconsole.log('onChange', val);}",
        },
      ],
    },
  },
};
