import snippets from './snippets';

export default {
  snippets,
  componentName: 'PisellLongText',
  title: '长文本',
  category: '表单',
  docUrl: '',
  screenshot: '',
  devMode: 'proCode',
  npm: {
    package: '@pisell/materials',
    version: '1.0.1',
    exportName: 'PisellLongText',
    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: 'string',
            setter: ['PisellI18nSetter', 'StringSetter', 'VariableSetter'],
          },
          {
            name: 'defaultValue',
            title: {
              label: '默认值',
              tip: 'defaultValue | 输入框的默认值（非受控模式）',
            },
            propType: 'string',
            setter: ['PisellI18nSetter', 'StringSetter'],
          },
          {
            name: 'placeholder',
            title: {
              label: '占位文本',
              tip: 'placeholder | 输入框占位文本',
            },
            propType: 'string',
            setter: ['PisellI18nSetter', 'StringSetter'],
          },
          {
            name: 'disabled',
            title: {
              label: '是否禁用',
              tip: 'disabled | 是否禁用状态',
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: false,
          },
        ],
      },
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'Multi-line Config',
            'zh-CN': '多行配置',
          },
          tip: '多行文本特有的配置',
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'rows',
            title: {
              label: '默认行数',
              tip: 'rows | 编辑态默认显示行数',
            },
            propType: 'number',
            setter: ['NumberSetter', 'VariableSetter'],
            defaultValue: 3,
          },
          {
            name: 'minRows',
            title: {
              label: '最小行数',
              tip: 'minRows | 编辑态最小行数（autoSize时有效）',
            },
            propType: 'number',
            setter: ['NumberSetter', 'VariableSetter'],
          },
          {
            name: 'maxRows',
            title: {
              label: '最大行数',
              tip: 'maxRows | 编辑态最大行数（autoSize时有效）',
            },
            propType: 'number',
            setter: ['NumberSetter', 'VariableSetter'],
          },
          {
            name: 'autoSize',
            title: {
              label: '自动高度',
              tip: 'autoSize | 是否自动调整高度',
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: false,
          },
          {
            name: 'maxLines',
            title: {
              label: '最大显示行数',
              tip: 'maxLines | 只读态最大显示行数（超出显示展开按钮）',
            },
            propType: 'number',
            setter: ['NumberSetter', 'VariableSetter'],
            defaultValue: 3,
          },
          {
            name: 'enableExpand',
            title: {
              label: '启用展开',
              tip: 'enableExpand | 是否启用展开功能（只读态）',
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: true,
          },
          {
            name: 'expandText',
            title: {
              label: '展开文案',
              tip: 'expandText | 展开按钮文案',
            },
            propType: 'string',
            setter: ['PisellI18nSetter', 'StringSetter'],
            defaultValue: '展开',
          },
          {
            name: 'collapseText',
            title: {
              label: '收起文案',
              tip: 'collapseText | 收起按钮文案',
            },
            propType: 'string',
            setter: ['PisellI18nSetter', 'StringSetter'],
            defaultValue: '收起',
          },
          {
            name: 'showWordCount',
            title: {
              label: '显示字数',
              tip: 'showWordCount | 只读态是否显示字数统计',
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: false,
          },
        ],
      },
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'Display',
            'zh-CN': '展示配置',
          },
          tip: '只读态的展示配置',
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'fontSize',
            title: {
              label: '字号',
              tip: 'fontSize | 文本字号',
            },
            propType: { type: 'oneOfType', value: ['string', 'number'] },
            setter: ['StringSetter', 'NumberSetter', 'VariableSetter'],
          },
          {
            name: 'fontWeight',
            title: {
              label: '字重',
              tip: 'fontWeight | 文本字重',
            },
            propType: { type: 'oneOfType', value: ['string', 'number'] },
            setter: ['StringSetter', 'NumberSetter', 'VariableSetter'],
          },
          {
            name: 'color',
            title: {
              label: '文本颜色',
              tip: 'color | 文本颜色',
            },
            propType: 'string',
            setter: ['ColorSetter', 'VariableSetter'],
          },
          {
            name: 'lineHeight',
            title: {
              label: '行高',
              tip: 'lineHeight | 文本行高',
            },
            propType: { type: 'oneOfType', value: ['string', 'number'] },
            setter: ['StringSetter', 'NumberSetter', 'VariableSetter'],
          },
        ],
      },
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'Edit',
            'zh-CN': '编辑配置',
          },
          tip: '编辑态的配置',
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'maxLength',
            title: {
              label: '最大长度',
              tip: 'maxLength | 输入框最大长度',
            },
            propType: 'number',
            setter: ['NumberSetter', 'VariableSetter'],
          },
          {
            name: 'showCount',
            title: {
              label: '显示字数',
              tip: 'showCount | 是否显示字数统计（编辑态）',
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: false,
          },
          {
            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,
          },
        ],
      },
      {
        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: 'minLength',
            title: {
              label: '最小长度',
              tip: 'minLength | 最小字符数',
            },
            propType: 'number',
            setter: ['NumberSetter', 'VariableSetter'],
          },
          {
            name: 'pattern',
            title: {
              label: '正则校验',
              tip: 'pattern | 正则表达式校验规则',
            },
            propType: 'string',
            setter: ['StringSetter', 'VariableSetter'],
          },
          {
            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(e,${extParams}){\n// 按下回车键的回调\nconsole.log('onPressEnter', e);}",
        },
        {
          name: 'onExpand',
          template:
            "onExpand(expanded,${extParams}){\n// 展开/收起回调\nconsole.log('onExpand', expanded);}",
        },
        {
          name: 'onValidate',
          template:
            "onValidate(isValid, errors,${extParams}){\n// 校验回调\nconsole.log('onValidate', isValid, errors);}",
        },
      ],
    },
    component: {},
  },
};
