import snippets from './snippets';

export default {
  snippets,
  componentName: 'PisellEmail',
  title: '邮箱地址',
  category: '表单',
  docUrl: '',
  screenshot: '',
  devMode: 'proCode',
  npm: {
    package: '@pisell/materials',
    version: '1.0.1',
    exportName: 'PisellEmail',
    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: ['StringSetter', 'VariableSetter'],
          },
          {
            name: 'defaultValue',
            title: {
              label: '默认值',
              tip: 'defaultValue | 默认邮箱地址',
            },
            propType: 'string',
            setter: ['StringSetter'],
          },
          {
            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': 'Validation',
            'zh-CN': '邮箱校验',
          },
          tip: '邮箱格式校验和域名限制',
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'strictValidation',
            title: {
              label: '严格校验',
              tip: 'strictValidation | 是否使用严格校验（RFC 5322）',
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: false,
          },
          {
            name: 'allowedDomains',
            title: {
              label: '白名单域名',
              tip: 'allowedDomains | 白名单域名列表（仅允许指定域名）',
            },
            propType: 'object',
            setter: ['JsonSetter', 'VariableSetter'],
          },
          {
            name: 'blockedDomains',
            title: {
              label: '黑名单域名',
              tip: 'blockedDomains | 黑名单域名列表（禁止某些域名）',
            },
            propType: 'object',
            setter: ['JsonSetter', 'VariableSetter'],
          },
          {
            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': 'AutoComplete',
            'zh-CN': '域名补全',
          },
          tip: '域名智能补全配置',
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'enableAutoComplete',
            title: {
              label: '启用域名补全',
              tip: 'enableAutoComplete | 是否启用域名自动补全',
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: true,
          },
          {
            name: 'autoCompleteDomains',
            title: {
              label: '补全域名列表',
              tip: 'autoCompleteDomains | 自定义补全域名列表',
            },
            propType: 'object',
            setter: ['JsonSetter', 'VariableSetter'],
            condition: {
              type: 'JSFunction',
              value: "target => target.getProps().getPropValue('enableAutoComplete') !== false",
            },
          },
          {
            name: 'showAllSuggestions',
            title: {
              label: '显示所有建议',
              tip: 'showAllSuggestions | 是否显示所有建议（不过滤）',
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: false,
            condition: {
              type: 'JSFunction',
              value: "target => target.getProps().getPropValue('enableAutoComplete') !== false",
            },
          },
        ],
      },
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'Mailto',
            'zh-CN': '邮件发送',
          },
          tip: 'mailto 邮件发送配置（只读态）',
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'enableMailto',
            title: {
              label: '启用 mailto',
              tip: 'enableMailto | 是否启用 mailto（只读态）',
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: true,
          },
          {
            name: 'showEmailIcon',
            title: {
              label: '显示邮件图标',
              tip: 'showEmailIcon | 是否显示邮件图标',
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: false,
          },
          {
            name: 'displayAsLink',
            title: {
              label: '显示为链接',
              tip: 'displayAsLink | 是否显示为链接（只读态）',
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: true,
          },
        ],
      },
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'Privacy',
            'zh-CN': '隐私脱敏',
          },
          tip: '域名隐藏和脱敏配置（只读态）',
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'hideDomain',
            title: {
              label: '隐藏域名',
              tip: 'hideDomain | 是否隐藏域名（只读态）',
            },
            propType: 'bool',
            setter: ['BoolSetter', 'VariableSetter'],
            defaultValue: false,
          },
          {
            name: 'maskPattern',
            title: {
              label: '脱敏模式',
              tip: 'maskPattern | 脱敏模式',
            },
            propType: { type: 'oneOf', value: ['partial', 'full'] },
            setter: [
              {
                componentName: 'RadioGroupSetter',
                props: {
                  options: [
                    { title: '部分隐藏', value: 'partial' },
                    { title: '完全隐藏', value: 'full' },
                  ],
                },
              },
              'VariableSetter',
            ],
            defaultValue: 'partial',
            condition: {
              type: 'JSFunction',
              value: "target => target.getProps().getPropValue('hideDomain') === true",
            },
          },
        ],
      },
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'Display',
            'zh-CN': '展示配置',
          },
          tip: '字体和颜色配置（只读态）',
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'fontSize',
            title: {
              label: '字号',
              tip: 'fontSize | 文本字号，如 14 或 "14px"',
            },
            propType: { type: 'oneOfType', value: ['string', 'number'] },
            setter: ['StringSetter', 'NumberSetter', 'VariableSetter'],
            defaultValue: 16,
          },
          {
            name: 'fontWeight',
            title: {
              label: '字重',
              tip: 'fontWeight | 文本字重，如 600 或 "bold"',
            },
            propType: { type: 'oneOfType', value: ['string', 'number'] },
            setter: ['StringSetter', 'NumberSetter', 'VariableSetter'],
            defaultValue: 500,
          },
          {
            name: 'color',
            title: {
              label: '文本颜色',
              tip: 'color | 文本颜色',
            },
            propType: 'string',
            setter: ['ColorSetter', 'VariableSetter'],
            defaultValue: '#101828',
          },
          {
            name: 'linkColor',
            title: {
              label: '链接颜色',
              tip: 'linkColor | 链接颜色（只读态）',
            },
            propType: 'string',
            setter: ['ColorSetter', 'VariableSetter'],
            defaultValue: '#7F56DA',
          },
        ],
      },
      {
        title: {
          label: {
            type: 'i18n',
            'en-US': 'Edit',
            'zh-CN': '编辑配置',
          },
        },
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'maxLength',
            title: {
              label: '最大长度',
              tip: 'maxLength | 最大长度（RFC 5321）',
            },
            propType: 'number',
            setter: ['NumberSetter', 'VariableSetter'],
            defaultValue: 254,
          },
          {
            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': '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: 'onSelect',
          template:
            "onSelect(value,${extParams}){\n// 选择补全建议回调\nconsole.log('onSelect', value);}",
        },
        {
          name: 'onMailto',
          template:
            "onMailto(email,${extParams}){\n// 发送邮件回调\nconsole.log('onMailto', email);}",
        },
        {
          name: 'onValidate',
          template:
            "onValidate(isValid, errors,${extParams}){\n// 校验回调\nconsole.log('onValidate', isValid, errors);}",
        },
      ],
    },
    component: {},
  },
};
