import snippets from './snippets';

export default {
  snippets,
  componentName: 'PisellCurrency',
  title: '货币',
  category: '表单',
  docUrl: '',
  screenshot: '',
  devMode: 'proCode',
  npm: {
    package: '@pisell/materials',
    version: '1.0.1',
    exportName: 'PisellCurrency',
    main: 'src/index.tsx',
    destructuring: true,
    subName: '',
  },
  configure: {
    props: [
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'Basic',
            'zh-CN': '基础配置',
          },
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'mode',
            title: {
              label: '状态模式',
              tip: 'mode | 组件的状态模式，只读态或编辑态',
            },
            propType: { type: 'oneOf', value: ['read', 'edit'] },
            setter: [
              {
                componentName: 'RadioGroupSetter',
                props: {
                  options: [
                    { title: '只读', value: 'read' },
                    { title: '编辑', value: 'edit' },
                  ],
                },
              },
              'VariableSetter',
            ],
            defaultValue: 'edit',
          },
          {
            name: 'value',
            title: {
              label: '当前值',
              tip: 'value | 金额数值（受控模式）',
            },
            propType: { type: 'oneOfType', value: ['number', 'null'] },
            setter: ['NumberSetter', 'VariableSetter'],
          },
          {
            name: 'defaultValue',
            title: {
              label: '默认值',
              tip: 'defaultValue | 默认金额（非受控模式）',
            },
            propType: { type: 'oneOfType', value: ['number', 'null'] },
            setter: ['NumberSetter', 'VariableSetter'],
          },
          {
            name: 'placeholder',
            title: {
              label: '占位文本',
              tip: 'placeholder | 输入框占位文本',
            },
            propType: 'string',
            setter: ['PisellI18nSetter', 'StringSetter'],
            defaultValue: '请输入金额',
          },
          {
            name: 'disabled',
            title: {
              label: '是否禁用',
              tip: 'disabled | 是否禁用状态',
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: false,
          },
        ],
      },
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'Currency',
            'zh-CN': '货币配置',
          },
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'currencySymbol',
            title: {
              label: '货币符号',
              tip: 'currencySymbol | 货币符号，如 ¥, $, €, £',
            },
            propType: 'string',
            setter: ['StringSetter', 'VariableSetter'],
            defaultValue: '¥',
          },
          {
            name: 'symbolPosition',
            title: {
              label: '符号位置',
              tip: 'symbolPosition | 货币符号位置，前置或后置',
            },
            propType: { type: 'oneOf', value: ['before', 'after'] },
            setter: [
              {
                componentName: 'RadioGroupSetter',
                props: {
                  options: [
                    { title: '前置', value: 'before' },
                    { title: '后置', value: 'after' },
                  ],
                },
              },
              'VariableSetter',
            ],
            defaultValue: 'before',
          },
          {
            name: 'showSymbol',
            title: {
              label: '显示符号',
              tip: 'showSymbol | 是否显示货币符号',
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: true,
          },
          {
            name: 'currencyCode',
            title: {
              label: '货币代码',
              tip: 'currencyCode | 货币代码（用于标识），如 CNY, USD, EUR',
            },
            propType: 'string',
            setter: ['StringSetter', 'VariableSetter'],
          },
          {
            name: 'allowNegative',
            title: {
              label: '允许负数',
              tip: 'allowNegative | 是否允许负数（退款场景允许，价格场景不允许）',
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: true,
          },
        ],
      },
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'Number Config',
            'zh-CN': '数值配置',
          },
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'min',
            title: {
              label: '最小值',
              tip: 'min | 允许的最小值',
            },
            propType: 'number',
            setter: ['NumberSetter', 'VariableSetter'],
          },
          {
            name: 'max',
            title: {
              label: '最大值',
              tip: 'max | 允许的最大值',
            },
            propType: 'number',
            setter: ['NumberSetter', 'VariableSetter'],
          },
          {
            name: 'step',
            title: {
              label: '步进值',
              tip: 'step | 每次改变步数',
            },
            propType: 'number',
            setter: ['NumberSetter', 'VariableSetter'],
            defaultValue: 1,
          },
          {
            name: 'precision',
            title: {
              label: '小数精度',
              tip: 'precision | 小数位数，货币默认2位',
            },
            propType: 'number',
            setter: ['NumberSetter', 'VariableSetter'],
            defaultValue: 2,
          },
        ],
      },
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'Validation',
            'zh-CN': '校验配置',
          },
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'required',
            title: {
              label: '是否必填',
              tip: 'required | 是否为必填项',
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: false,
          },
          {
            name: 'errorMessage',
            title: {
              label: '错误提示',
              tip: 'errorMessage | 自定义错误提示信息',
            },
            propType: 'string',
            setter: ['PisellI18nSetter', 'StringSetter', 'VariableSetter'],
          },
          {
            name: 'validateTrigger',
            title: {
              label: '校验时机',
              tip: 'validateTrigger | 校验触发时机',
            },
            propType: { type: 'oneOf', value: ['onChange', 'onBlur', 'both'] },
            setter: [
              {
                componentName: 'RadioGroupSetter',
                props: {
                  options: [
                    { title: '输入时', value: 'onChange' },
                    { title: '失焦时', value: 'onBlur' },
                    { title: '两者都', value: 'both' },
                  ],
                },
              },
              'VariableSetter',
            ],
            defaultValue: 'onBlur',
          },
        ],
      },
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'Style',
            'zh-CN': '样式',
          },
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'size',
            title: {
              label: '尺寸',
              tip: 'size | 输入框尺寸',
            },
            propType: { type: 'oneOf', value: ['large', 'middle', 'small'] },
            setter: [
              {
                componentName: 'RadioGroupSetter',
                props: {
                  options: [
                    { title: '大', value: 'large' },
                    { title: '中', value: 'middle' },
                    { title: '小', value: 'small' },
                  ],
                },
              },
              'VariableSetter',
            ],
            defaultValue: 'middle',
          },
          {
            name: 'className',
            title: {
              label: '样式类名',
              tip: 'className | 自定义样式类名',
            },
            propType: 'string',
            setter: 'StringSetter',
          },
          {
            name: 'style',
            title: {
              label: '自定义样式',
              tip: 'style | 自定义样式对象',
            },
            propType: 'object',
            setter: 'StyleSetter',
          },
        ],
      },
    ],
    supports: {
      style: true,
      events: [
        {
          name: 'onChange',
          template:
            "onChange(value,${extParams}){\n// 金额变化时的回调\nconsole.log('onChange', value);}",
        },
        {
          name: 'onBlur',
          template: "onBlur(value,${extParams}){\n// 失焦回调\nconsole.log('onBlur', value);}",
        },
        {
          name: 'onFocus',
          template: "onFocus(${extParams}){\n// 聚焦回调\nconsole.log('onFocus');}",
        },
        {
          name: 'onValidate',
          template:
            "onValidate(isValid, errors,${extParams}){\n// 校验回调\nconsole.log('onValidate', isValid, errors);}",
        },
      ],
    },
    component: {},
  },
};
