import snippets from './snippets';

export default {
  snippets,
  componentName: 'PisellNumber',
  title: '数值',
  category: '表单',
  docUrl: '',
  screenshot: '',
  devMode: 'proCode',
  npm: {
    package: '@pisell/materials',
    version: '1.0.1',
    exportName: 'PisellNumber',
    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': '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 | 数值精度（小数位数）',
            },
            propType: 'number',
            setter: ['NumberSetter', 'VariableSetter'],
          },
          {
            name: 'useGrouping',
            title: {
              label: '千分位分隔',
              tip: 'useGrouping | 是否使用千分位分隔符（1,234,567）',
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: false,
          },
        ],
      },
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'Display',
            'zh-CN': '展示配置',
          },
          tip: '只读态的展示配置',
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'emptyText',
            title: {
              label: '空值文本',
              tip: 'emptyText | 空值时的显示文本（只读态）',
            },
            propType: 'string',
            setter: ['PisellI18nSetter', 'StringSetter', 'VariableSetter'],
            defaultValue: '-',
          },
          {
            name: 'fontSize',
            title: {
              label: '字号',
              tip: 'fontSize | 文本字号，如 14 或 "14px"（只读态）',
            },
            propType: { type: 'oneOfType', value: ['string', 'number'] },
            setter: ['StringSetter', 'NumberSetter', 'VariableSetter'],
          },
          {
            name: 'fontWeight',
            title: {
              label: '字重',
              tip: 'fontWeight | 文本字重，如 600 或 "bold"（只读态）',
            },
            propType: { type: 'oneOfType', value: ['string', 'number'] },
            setter: ['StringSetter', 'NumberSetter', 'VariableSetter'],
          },
          {
            name: 'color',
            title: {
              label: '文本颜色',
              tip: 'color | 文本颜色（只读态）',
            },
            propType: 'string',
            setter: ['ColorSetter', 'VariableSetter'],
          },
          {
            name: 'textAlign',
            title: {
              label: '对齐方式',
              tip: 'textAlign | 文本对齐方式（只读态）',
            },
            propType: { type: 'oneOf', value: ['left', 'center', 'right'] },
            setter: [
              {
                componentName: 'RadioGroupSetter',
                props: {
                  options: [
                    {
                      title: '左对齐',
                      value: 'left',
                    },
                    {
                      title: '居中',
                      value: 'center',
                    },
                    {
                      title: '右对齐',
                      value: 'right',
                    },
                  ],
                },
              },
              'VariableSetter',
            ],
            defaultValue: 'left',
          },
        ],
      },
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'Edit',
            'zh-CN': '编辑配置',
          },
          tip: '编辑态的配置',
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'allowClear',
            title: {
              label: '显示清除',
              tip: 'allowClear | 是否显示清空按钮',
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: false,
          },
          {
            name: 'autoFocus',
            title: {
              label: '自动聚焦',
              tip: 'autoFocus | 是否自动聚焦',
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: false,
          },
          {
            name: 'keyboard',
            title: {
              label: '键盘调节',
              tip: 'keyboard | 是否启用键盘上下键调节数值',
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: true,
          },
          {
            name: 'controls',
            title: {
              label: '显示步进器',
              tip: 'controls | 是否显示增减按钮',
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: true,
          },
          {
            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: 'prefix',
            title: {
              label: '前缀',
              tip: 'prefix | 前缀图标或文本',
            },
            propType: 'node',
            setter: ['PisellI18nSetter', 'SlotSetter'],
          },
          {
            name: 'suffix',
            title: {
              label: '后缀',
              tip: 'suffix | 后缀图标或文本',
            },
            propType: 'node',
            setter: ['PisellI18nSetter', 'SlotSetter'],
          },
          {
            name: 'addonBefore',
            title: {
              label: '前置标签',
              tip: 'addonBefore | 前置标签',
            },
            propType: 'node',
            setter: ['PisellI18nSetter', 'SlotSetter'],
          },
          {
            name: 'addonAfter',
            title: {
              label: '后置标签',
              tip: 'addonAfter | 后置标签',
            },
            propType: 'node',
            setter: ['PisellI18nSetter', 'SlotSetter'],
          },
        ],
      },
      {
        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: 'autoCorrect',
            title: {
              label: '自动修正',
              tip: 'autoCorrect | 是否自动修正超出范围的值',
            },
            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: '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: 'onPressEnter',
          template:
            "onPressEnter(value,${extParams}){\n// 按下回车键的回调\nconsole.log('onPressEnter', value);}",
        },
        {
          name: 'onValidate',
          template:
            "onValidate(isValid, errors,${extParams}){\n// 校验回调\nconsole.log('onValidate', isValid, errors);}",
        },
      ],
    },
    component: {},
  },
};
