import {
  IPublicTypeComponentMetadata,
  IPublicTypeSnippet,
} from '@alilc/lowcode-types';

const PisellHierarchicalSummaryListMeta: IPublicTypeComponentMetadata = {
  componentName: 'PisellHierarchicalSummaryList',
  title: '层级汇总列表',
  docUrl: '',
  screenshot: '',
  devMode: 'proCode',
  npm: {
    package: '@pisell/materials',
    version: '1.0.3',
    exportName: 'PisellHierarchicalSummaryList',
    main: 'src/index.tsx',
    destructuring: true,
    subName: '',
  },
  props: [
    {
      title: {
        label: {
          type: 'i18n',
          'en-US': 'items',
          'zh-CN': '数据源',
        },
      },
      name: 'items',
      setter: ['JsonSetter', 'VariableSetter'],
    },
    {
      title: {
        label: {
          type: 'i18n',
          'en-US': 'expandedKeys',
          'zh-CN': '展开项（受控）',
        },
      },
      name: 'expandedKeys',
      setter: ['JsonSetter', 'VariableSetter'],
    },
    {
      title: {
        label: {
          type: 'i18n',
          'en-US': 'defaultExpandedKeys',
          'zh-CN': '默认展开项（非受控）',
        },
      },
      name: 'defaultExpandedKeys',
      setter: ['JsonSetter', 'VariableSetter'],
    },
    {
      title: {
        label: {
          type: 'i18n',
          'en-US': 'defaultExpandedLevel',
          'zh-CN': '默认展开层级',
        },
      },
      name: 'defaultExpandedLevel',
      setter: ['NumberSetter', 'VariableSetter'],
      defaultValue: 0,
    },
    {
      title: {
        label: {
          type: 'i18n',
          'en-US': 'accordion',
          'zh-CN': '手风琴模式',
        },
      },
      name: 'accordion',
      setter: ['BoolSetter', 'VariableSetter'],
      defaultValue: false,
    },
    {
      title: {
        label: {
          type: 'i18n',
          'en-US': 'maxRenderLevel',
          'zh-CN': '最大渲染层级',
        },
      },
      name: 'maxRenderLevel',
      setter: ['NumberSetter', 'VariableSetter'],
    },
    {
      title: {
        label: {
          type: 'i18n',
          'en-US': 'maxExpandLevel',
          'zh-CN': '最大可展开层级',
        },
      },
      name: 'maxExpandLevel',
      setter: ['NumberSetter', 'VariableSetter'],
    },
    {
      title: {
        label: {
          type: 'i18n',
          'en-US': 'indent',
          'zh-CN': '缩进（px）',
        },
      },
      name: 'indent',
      setter: ['NumberSetter', 'VariableSetter'],
      defaultValue: 16,
    },
    {
      title: {
        label: {
          type: 'i18n',
          'en-US': 'rowGap',
          'zh-CN': '行间距（px）',
        },
      },
      name: 'rowGap',
      setter: ['NumberSetter', 'VariableSetter'],
      defaultValue: 8,
    },
    {
      title: {
        label: {
          type: 'i18n',
          'en-US': 'levelConfig',
          'zh-CN': '层级配置',
        },
      },
      name: 'levelConfig',
      setter: ['JsonSetter', 'VariableSetter'],
    },
    {
      title: {
        label: {
          type: 'i18n',
          'en-US': 'aggregate',
          'zh-CN': '聚合配置',
        },
      },
      name: 'aggregate',
      setter: ['JsonSetter', 'VariableSetter'],
    },
    {
      title: {
        label: {
          type: 'i18n',
          'en-US': 'renderLabel',
          'zh-CN': '自定义渲染标题',
        },
      },
      name: 'renderLabel',
      setter: [
        {
          componentName: 'FunctionSetter',
          props: {
            template:
              'renderLabel(item, ctx, ${extParams}){\n// 自定义标题渲染\nreturn item.label;\n}',
          },
        },
        'VariableSetter',
      ],
    },
    {
      title: {
        label: {
          type: 'i18n',
          'en-US': 'renderValue',
          'zh-CN': '自定义渲染数值',
        },
      },
      name: 'renderValue',
      setter: [
        {
          componentName: 'FunctionSetter',
          props: {
            template:
              'renderValue(item, ctx, ${extParams}){\n// 自定义数值渲染\nreturn item.value;\n}',
          },
        },
        'VariableSetter',
      ],
    },
  ],
  configure: {
    component: {
      isContainer: false,
    },
    supports: {
      style: true,
      className: true,
      events: [
        {
          name: 'onExpandedKeysChange',
          template:
            "onExpandedKeysChange(keys,${extParams}){\n// 展开项变化\nconsole.log('onExpandedKeysChange', keys);}",
        },
      ],
    },
  },
};

const snippets: IPublicTypeSnippet[] = [
  {
    title: '层级汇总列表',
    screenshot: '',
    schema: {
      componentName: 'PisellHierarchicalSummaryList',
      props: {
        items: [
          {
            key: 'l1',
            label: 'Label',
            value: 'Value',
            children: [
              {
                key: 'l2',
                label: 'Label',
                value: 'Value',
                children: [
                  { key: 'l3-1', label: 'Label · N items', value: 'Value' },
                  { key: 'l3-2', label: 'Label', infoTooltip: 'Tooltip', value: 'Value' },
                ],
              },
            ],
          },
        ],
        defaultExpandedLevel: 2,
      },
    },
  },
];

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

