import { IPublicTypeComponentMetadata } from '@alilc/lowcode-types';

const AuthModalMeta: IPublicTypeComponentMetadata = {
  componentName: 'AuthModal',
  title: '认证弹窗',
  docUrl: '',
  screenshot: '',
  category: '表单',
  devMode: 'proCode',
  npm: {
    package: '@pisell/private-materials',
    version: '1.0.0',
    exportName: 'AuthModal',
    main: 'src/index.tsx',
    destructuring: true,
    subName: '',
  },
  props: [],
  configure: {
    props: [
      {
        title: {
          label: 'UI 配置',
        },
        type: 'group',
        display: 'block',
        items: [
          {
            name: 'config.page.login.ui.formLabels',
            title: { label: '登录表单标签配置' },
            propType: 'object',
            setter: {
              componentName: 'ObjectSetter',
              props: {
                config: {
                  items: [
                    {
                      name: 'email',
                      title: '邮箱标签',
                      setter: {
                        componentName: 'ObjectSetter',
                        props: {
                          config: {
                            items: [
                              {
                                name: 'show',
                                title: '显示标签',
                                setter: 'BoolSetter',
                                defaultValue: false,
                              },
                              {
                                name: 'text',
                                title: '标签文案',
                                setter: 'PisellI18nSetter',
                              },
                            ],
                          },
                        },
                      },
                    },
                    {
                      name: 'phone',
                      title: '手机标签',
                      setter: {
                        componentName: 'ObjectSetter',
                        props: {
                          config: {
                            items: [
                              {
                                name: 'show',
                                title: '显示标签',
                                setter: 'BoolSetter',
                                defaultValue: false,
                              },
                              {
                                name: 'text',
                                title: '标签文案',
                                setter: 'PisellI18nSetter',
                              },
                            ],
                          },
                        },
                      },
                    },
                    {
                      name: 'password',
                      title: '密码标签',
                      setter: {
                        componentName: 'ObjectSetter',
                        props: {
                          config: {
                            items: [
                              {
                                name: 'show',
                                title: '显示标签',
                                setter: 'BoolSetter',
                                defaultValue: false,
                              },
                              {
                                name: 'text',
                                title: '标签文案',
                                setter: 'PisellI18nSetter',
                              },
                            ],
                          },
                        },
                      },
                    },
                    {
                      name: 'verificationCode',
                      title: '验证码标签',
                      setter: {
                        componentName: 'ObjectSetter',
                        props: {
                          config: {
                            items: [
                              {
                                name: 'show',
                                title: '显示标签',
                                setter: 'BoolSetter',
                                defaultValue: false,
                              },
                              {
                                name: 'text',
                                title: '标签文案',
                                setter: 'PisellI18nSetter',
                              },
                            ],
                          },
                        },
                      },
                    },
                  ],
                },
              },
            },
          },
          {
            name: 'config.page.register.ui.formLabels',
            title: { label: '注册表单标签配置' },
            propType: 'object',
            setter: {
              componentName: 'ObjectSetter',
              props: {
                config: {
                  items: [
                    {
                      name: 'email',
                      title: '邮箱标签',
                      setter: {
                        componentName: 'ObjectSetter',
                        props: {
                          config: {
                            items: [
                              {
                                name: 'show',
                                title: '显示标签',
                                setter: 'BoolSetter',
                                defaultValue: false,
                              },
                              {
                                name: 'text',
                                title: '标签文案',
                                setter: 'PisellI18nSetter',
                              },
                            ],
                          },
                        },
                      },
                    },
                    {
                      name: 'phone',
                      title: '手机标签',
                      setter: {
                        componentName: 'ObjectSetter',
                        props: {
                          config: {
                            items: [
                              {
                                name: 'show',
                                title: '显示标签',
                                setter: 'BoolSetter',
                                defaultValue: false,
                              },
                              {
                                name: 'text',
                                title: '标签文案',
                                setter: 'PisellI18nSetter',
                              },
                            ],
                          },
                        },
                      },
                    },
                    {
                      name: 'password',
                      title: '密码标签',
                      setter: {
                        componentName: 'ObjectSetter',
                        props: {
                          config: {
                            items: [
                              {
                                name: 'show',
                                title: '显示标签',
                                setter: 'BoolSetter',
                                defaultValue: false,
                              },
                              {
                                name: 'text',
                                title: '标签文案',
                                setter: 'PisellI18nSetter',
                              },
                            ],
                          },
                        },
                      },
                    },
                    {
                      name: 'verificationCode',
                      title: '验证码标签',
                      setter: {
                        componentName: 'ObjectSetter',
                        props: {
                          config: {
                            items: [
                              {
                                name: 'show',
                                title: '显示标签',
                                setter: 'BoolSetter',
                                defaultValue: false,
                              },
                              {
                                name: 'text',
                                title: '标签文案',
                                setter: 'PisellI18nSetter',
                              },
                            ],
                          },
                        },
                      },
                    },
                    {
                      name: 'firstName',
                      title: '名字标签',
                      setter: {
                        componentName: 'ObjectSetter',
                        props: {
                          config: {
                            items: [
                              {
                                name: 'show',
                                title: '显示标签',
                                setter: 'BoolSetter',
                                defaultValue: false,
                              },
                              {
                                name: 'text',
                                title: '标签文案',
                                setter: 'PisellI18nSetter',
                              },
                            ],
                          },
                        },
                      },
                    },
                    {
                      name: 'lastName',
                      title: '姓氏标签',
                      setter: {
                        componentName: 'ObjectSetter',
                        props: {
                          config: {
                            items: [
                              {
                                name: 'show',
                                title: '显示标签',
                                setter: 'BoolSetter',
                                defaultValue: false,
                              },
                              {
                                name: 'text',
                                title: '标签文案',
                                setter: 'PisellI18nSetter',
                              },
                            ],
                          },
                        },
                      },
                    },
                  ],
                },
              },
            },
          },
        ],
      },
    ],
    supports: {
      style: true,
      events: [
        {
          name: 'onLoginSuccess',
          description: '登录成功回调，参数：(data: LoginFormData, method: AuthMethodType, channel?: string)',
        },
        {
          name: 'onRegisterSuccess',
          description: '注册成功回调，参数：(data: RegisterFormData, method: AuthMethodType, channel?: string)',
        },
        {
          name: 'onOAuthLogin',
          description: '三方登录回调，参数：(provider: "google" | "facebook" | "apple", channel?: string)',
        },
        {
          name: 'onSendVerificationCode',
          description: '发送验证码回调，参数：(account: string, type: "email" | "phone", channel?: string)',
        },
        {
          name: 'onForgotPassword',
          description: '忘记密码回调，参数：(account: string, channel?: string)',
        },
        {
          name: 'onClose',
          description: '关闭弹窗回调',
        },
      ],
    },
    component: {
      isContainer: false,
    },
  },
  snippets: [
    {
      title: '认证弹窗',
      screenshot: '',
      schema: {
        componentName: 'AuthModal',
        props: {
          visible: true,
          config: {
            auth: {
              method: {
                phone: { enabled: true, sort: 1 },
                email: { enabled: true, sort: 2 },
                facebook: { enabled: false, sort: 3 },
                apple: { enabled: false, sort: 4 },
                google: { enabled: false, sort: 5 },
                guest: { enabled: true, sort: 6 },
              },
            },
            page: {
              login: {
                ui: {
                  logo: { show: true, position: 'center' },
                  title: { show: true, text: '登录', align: 'center' },
                  subtitle: { show: false },
                  description: { show: false },
                  themeColor: '#7F56D9',
                  formLabels: {
                    email: { show: false },
                    phone: { show: false },
                    password: { show: false },
                    verificationCode: { show: false },
                  },
                },
                terms: { enabled: false, terms: [] },
              },
              register: {
                ui: {
                  logo: { show: true, position: 'center' },
                  title: { show: true, text: '注册', align: 'center' },
                  subtitle: { show: false },
                  description: { show: false },
                  themeColor: '#7F56D9',
                  formLabels: {
                    email: { show: false },
                    phone: { show: false },
                    password: { show: false },
                    verificationCode: { show: false },
                    firstName: { show: false },
                    lastName: { show: false },
                  },
                },
                terms: { enabled: false, terms: [] },
              },
            },
          },
          displayMode: 'modal',
        },
      },
    },
  ],
};

export default AuthModalMeta;