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

const PisellPriceKeyboardMeta: ComponentMetadata = {
  componentName: 'PisellPriceKeyboard',
  title: 'PisellPriceKeyboard',
  docUrl: '',
  screenshot: '',
  devMode: 'proCode',
  npm: {
    package: '@pisell/materials',
    version: '1.0.3',
    exportName: 'PisellPriceKeyboard',
    main: 'src/index.tsx',
    destructuring: true,
    subName: '',
  },
  props: [
    {
      name: 'defaultValue',
      title: { label: '默认值', tip: '默认值' },
      propType: 'number',
      setter: 'NumberSetter',
    },
    {
      name: 'max',
      title: { label: '最大值', tip: '最大值' },
      propType: 'number',
      setter: 'NumberSetter',
    },
    {
      name: 'min',
      title: { label: '最小值', tip: '最小值' },
      propType: 'number',
      setter: 'NumberSetter',
    },
    {
      name: 'doneText',
      title: { label: '确认按钮文案', tip: '确认按钮文案' },
      propType: 'string',
      defaultValue: 'Done',
      setter: 'PisellI18nSetter',
    },
    {
      name: 'resetText',
      title: { label: '重置按钮文案', tip: '重置按钮文案' },
      propType: 'string',
      defaultValue: 'Reset',
      setter: 'PisellI18nSetter',
    },
    {
      name: 'placeholder',
      title: { label: '展位文字placeholder', tip: 'placeholder' },
      propType: 'string',
      setter: 'PisellI18nSetter',
    },
    {
      title: {
        label: '金额配置',
      },
      display: 'block',
      type: 'group',
      items: [
        {
          name: 'amountProps.precision',
          title: {
            label: '小数点后位数',
            tip: '小数点后位数 默认是小数点后2位',
          },
          propType: 'number',
          setter: 'NumberSetter',
        },
        {
          name: 'amountProps.showCurrencySymbol',
          title: {
            label: '显示货币符号',
            tip: '显示货币符号 指的是 ¥$ 等货币符号等显隐，默认是展示',
          },
          propType: 'bool',
          defaultValue: true,
          setter: 'BoolSetter',
        },
        {
          name: 'amountProps.useThousandsSeparator',
          title: {
            label: '千分位',
            tip: '千分位 指的是长金额的千分位逗号隔开，比如“123, 245, 315” 这种展现形式，默认是关闭',
          },
          propType: 'bool',
          defaultValue: false,
          setter: 'BoolSetter',
        },
        {
          name: 'presets',
          title: {
            label: '快捷金额',
            tip: '快捷金额',
          },
          setter: {
            componentName: 'ArraySetter',
            props: {
              itemSetter: {
                componentName: 'ObjectSetter',
                props: {
                  config: {
                    items: [
                      {
                        name: 'value',
                        title: 'value',
                        setter: 'StringSetter',
                        isRequired: true,
                      },
                      {
                        name: 'label',
                        title: 'label',
                        setter: 'StringSetter',
                        isRequired: true,
                      },
                    ],
                  },
                },
                initialValue: () => {
                  return {
                    value: '100',
                    label: '100',
                  };
                },
              },
            },
          },
        },
      ],
    },
  ],
  configure: {
    supports: {
      style: true,
      events: [
        {
          name: 'onClick',
          template:
            "onClick(event,${extParams}){\n// 点击时的回调\nconsole.log('onClick', event);}",
        },
        {
          name: 'onChange',
          template:
            "onChange(value,${extParams}){\nconsole.log('onChange', value);}",
        },
        {
          name: 'onEnter',
          template:
            "onEnter(value,${extParams}){\nconsole.log('onEnter', value);}",
        },
      ],
    },
    component: {
      isContainer: true,
    },
  },
};
const snippets: Snippet[] = [
  {
    title: 'PisellPriceKeyboard',
    screenshot: '',
    schema: {
      componentName: 'PisellPriceKeyboard',
      props: {},
    },
  },
];

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