@openedx/frontend-app-authn 1.0.0-alpha.5 → 1.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Main.d.ts +3 -0
- package/dist/Main.js +10 -0
- package/dist/Main.js.map +1 -0
- package/dist/app.d.ts +3 -0
- package/dist/app.js +41 -0
- package/dist/app.js.map +1 -0
- package/{src → dist}/app.scss +1 -1
- package/dist/base-container/components/default-layout/LargeLayout.d.ts +2 -0
- package/dist/base-container/components/default-layout/LargeLayout.js +11 -0
- package/dist/base-container/components/default-layout/LargeLayout.js.map +1 -0
- package/dist/base-container/components/default-layout/MediumLayout.d.ts +2 -0
- package/dist/base-container/components/default-layout/MediumLayout.js +11 -0
- package/dist/base-container/components/default-layout/MediumLayout.js.map +1 -0
- package/dist/base-container/components/default-layout/SmallLayout.d.ts +2 -0
- package/dist/base-container/components/default-layout/SmallLayout.js +11 -0
- package/dist/base-container/components/default-layout/SmallLayout.js.map +1 -0
- package/dist/base-container/components/default-layout/index.d.ts +3 -0
- package/{src/base-container/components/default-layout/index.jsx → dist/base-container/components/default-layout/index.js} +1 -0
- package/dist/base-container/components/default-layout/index.js.map +1 -0
- package/dist/base-container/components/default-layout/messages.d.ts +13 -0
- package/dist/base-container/components/default-layout/messages.js +15 -0
- package/dist/base-container/components/default-layout/messages.js.map +1 -0
- package/dist/base-container/components/image-layout/ExtraSmallLayout.d.ts +2 -0
- package/dist/base-container/components/image-layout/ExtraSmallLayout.js +10 -0
- package/dist/base-container/components/image-layout/ExtraSmallLayout.js.map +1 -0
- package/dist/base-container/components/image-layout/LargeLayout.d.ts +2 -0
- package/dist/base-container/components/image-layout/LargeLayout.js +11 -0
- package/dist/base-container/components/image-layout/LargeLayout.js.map +1 -0
- package/dist/base-container/components/image-layout/MediumLayout.d.ts +2 -0
- package/dist/base-container/components/image-layout/MediumLayout.js +11 -0
- package/dist/base-container/components/image-layout/MediumLayout.js.map +1 -0
- package/dist/base-container/components/image-layout/SmallLayout.d.ts +2 -0
- package/dist/base-container/components/image-layout/SmallLayout.js +10 -0
- package/dist/base-container/components/image-layout/SmallLayout.js.map +1 -0
- package/dist/base-container/components/image-layout/index.d.ts +4 -0
- package/{src/base-container/components/image-layout/index.jsx → dist/base-container/components/image-layout/index.js} +1 -0
- package/dist/base-container/components/image-layout/index.js.map +1 -0
- package/dist/base-container/components/image-layout/messages.d.ts +13 -0
- package/dist/base-container/components/image-layout/messages.js +15 -0
- package/dist/base-container/components/image-layout/messages.js.map +1 -0
- package/dist/base-container/components/welcome-page-layout/LargeLayout.d.ts +10 -0
- package/dist/base-container/components/welcome-page-layout/LargeLayout.js +14 -0
- package/dist/base-container/components/welcome-page-layout/LargeLayout.js.map +1 -0
- package/dist/base-container/components/welcome-page-layout/MediumLayout.d.ts +10 -0
- package/dist/base-container/components/welcome-page-layout/MediumLayout.js +14 -0
- package/dist/base-container/components/welcome-page-layout/MediumLayout.js.map +1 -0
- package/dist/base-container/components/welcome-page-layout/SmallLayout.d.ts +10 -0
- package/dist/base-container/components/welcome-page-layout/SmallLayout.js +14 -0
- package/dist/base-container/components/welcome-page-layout/SmallLayout.js.map +1 -0
- package/dist/base-container/components/welcome-page-layout/index.d.ts +3 -0
- package/{src/base-container/components/welcome-page-layout/index.jsx → dist/base-container/components/welcome-page-layout/index.js} +1 -0
- package/dist/base-container/components/welcome-page-layout/index.js.map +1 -0
- package/dist/base-container/components/welcome-page-layout/messages.d.ts +18 -0
- package/dist/base-container/components/welcome-page-layout/messages.js +20 -0
- package/dist/base-container/components/welcome-page-layout/messages.js.map +1 -0
- package/dist/base-container/index.d.ts +20 -0
- package/dist/base-container/index.js +27 -0
- package/dist/base-container/index.js.map +1 -0
- package/dist/common-components/EmbeddedRegistrationRoute.d.ts +14 -0
- package/dist/common-components/EmbeddedRegistrationRoute.js +22 -0
- package/dist/common-components/EmbeddedRegistrationRoute.js.map +1 -0
- package/dist/common-components/EnterpriseSSO.d.ts +29 -0
- package/dist/common-components/EnterpriseSSO.js +58 -0
- package/dist/common-components/EnterpriseSSO.js.map +1 -0
- package/dist/common-components/FormGroup.d.ts +60 -0
- package/dist/common-components/FormGroup.js +66 -0
- package/dist/common-components/FormGroup.js.map +1 -0
- package/dist/common-components/InstitutionLogistration.d.ts +34 -0
- package/dist/common-components/InstitutionLogistration.js +38 -0
- package/dist/common-components/InstitutionLogistration.js.map +1 -0
- package/dist/common-components/NotFoundPage.d.ts +2 -0
- package/dist/common-components/NotFoundPage.js +5 -0
- package/dist/common-components/NotFoundPage.js.map +1 -0
- package/dist/common-components/PasswordField.d.ts +47 -0
- package/dist/common-components/PasswordField.js +98 -0
- package/dist/common-components/PasswordField.js.map +1 -0
- package/dist/common-components/RedirectLogistration.d.ts +39 -0
- package/dist/common-components/RedirectLogistration.js +72 -0
- package/dist/common-components/RedirectLogistration.js.map +1 -0
- package/dist/common-components/RegisterFaIcons.d.ts +1 -0
- package/dist/common-components/RegisterFaIcons.js +6 -0
- package/dist/common-components/RegisterFaIcons.js.map +1 -0
- package/dist/common-components/SocialAuthProviders.d.ts +23 -0
- package/dist/common-components/SocialAuthProviders.js +43 -0
- package/dist/common-components/SocialAuthProviders.js.map +1 -0
- package/dist/common-components/ThirdPartyAuth.d.ts +42 -0
- package/dist/common-components/ThirdPartyAuth.js +57 -0
- package/dist/common-components/ThirdPartyAuth.js.map +1 -0
- package/dist/common-components/ThirdPartyAuthAlert.d.ts +15 -0
- package/dist/common-components/ThirdPartyAuthAlert.js +32 -0
- package/dist/common-components/ThirdPartyAuthAlert.js.map +1 -0
- package/dist/common-components/UnAuthOnlyRoute.d.ts +14 -0
- package/dist/common-components/UnAuthOnlyRoute.js +32 -0
- package/dist/common-components/UnAuthOnlyRoute.js.map +1 -0
- package/dist/common-components/components/ThirdPartyAuthContext.d.ts +31 -0
- package/dist/common-components/components/ThirdPartyAuthContext.js +84 -0
- package/dist/common-components/components/ThirdPartyAuthContext.js.map +1 -0
- package/dist/common-components/data/api.d.ts +6 -0
- package/dist/common-components/data/api.js +26 -0
- package/dist/common-components/data/api.js.map +1 -0
- package/dist/common-components/data/apiHook.d.ts +9 -0
- package/dist/common-components/data/apiHook.js +14 -0
- package/dist/common-components/data/apiHook.js.map +1 -0
- package/dist/common-components/data/queryKeys.d.ts +4 -0
- package/dist/common-components/data/queryKeys.js +6 -0
- package/dist/common-components/data/queryKeys.js.map +1 -0
- package/dist/common-components/index.d.ts +10 -0
- package/{src/common-components/index.jsx → dist/common-components/index.js} +1 -3
- package/dist/common-components/index.js.map +1 -0
- package/dist/common-components/messages.d.ts +113 -0
- package/dist/common-components/messages.js +126 -0
- package/dist/common-components/messages.js.map +1 -0
- package/dist/constants.d.ts +14 -0
- package/dist/constants.js +17 -0
- package/dist/constants.js.map +1 -0
- package/dist/data/constants.d.ts +16 -0
- package/{src → dist}/data/constants.js +4 -17
- package/dist/data/constants.js.map +1 -0
- package/dist/data/countries.d.ts +26 -0
- package/{src/data/countries.ts → dist/data/countries.js} +6 -9
- package/dist/data/countries.js.map +1 -0
- package/dist/data/oneTrust.d.ts +2 -0
- package/dist/data/oneTrust.js +3 -0
- package/dist/data/oneTrust.js.map +1 -0
- package/dist/data/utils/cookies.d.ts +1 -0
- package/dist/data/utils/cookies.js +12 -0
- package/dist/data/utils/cookies.js.map +1 -0
- package/dist/data/utils/dataUtils.d.ts +12 -0
- package/dist/data/utils/dataUtils.js +81 -0
- package/dist/data/utils/dataUtils.js.map +1 -0
- package/dist/data/utils/index.d.ts +2 -0
- package/dist/data/utils/index.js +3 -0
- package/dist/data/utils/index.js.map +1 -0
- package/dist/data/utils/useMobileResponsive.d.ts +7 -0
- package/dist/data/utils/useMobileResponsive.js +22 -0
- package/dist/data/utils/useMobileResponsive.js.map +1 -0
- package/dist/field-renderer/FieldRenderer.d.ts +34 -0
- package/dist/field-renderer/FieldRenderer.js +70 -0
- package/dist/field-renderer/FieldRenderer.js.map +1 -0
- package/dist/field-renderer/index.d.ts +1 -0
- package/{src/field-renderer/index.jsx → dist/field-renderer/index.js} +1 -0
- package/dist/field-renderer/index.js.map +1 -0
- package/dist/forgot-password/ForgotPasswordAlert.d.ts +16 -0
- package/dist/forgot-password/ForgotPasswordAlert.js +66 -0
- package/dist/forgot-password/ForgotPasswordAlert.js.map +1 -0
- package/dist/forgot-password/ForgotPasswordPage.d.ts +2 -0
- package/dist/forgot-password/ForgotPasswordPage.js +92 -0
- package/dist/forgot-password/ForgotPasswordPage.js.map +1 -0
- package/dist/forgot-password/data/api.d.ts +2 -0
- package/dist/forgot-password/data/api.js +25 -0
- package/dist/forgot-password/data/api.js.map +1 -0
- package/dist/forgot-password/data/apiHook.d.ts +16 -0
- package/dist/forgot-password/data/apiHook.js +26 -0
- package/dist/forgot-password/data/apiHook.js.map +1 -0
- package/dist/forgot-password/index.d.ts +1 -0
- package/dist/forgot-password/index.js +2 -0
- package/dist/forgot-password/index.js.map +1 -0
- package/dist/forgot-password/messages.d.ts +123 -0
- package/dist/forgot-password/messages.js +128 -0
- package/dist/forgot-password/messages.js.map +1 -0
- package/dist/i18n/index.d.ts +25 -0
- package/dist/i18n/index.js +26 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/login/AccountActivationMessage.d.ts +14 -0
- package/dist/login/AccountActivationMessage.js +49 -0
- package/dist/login/AccountActivationMessage.js.map +1 -0
- package/dist/login/ChangePasswordPrompt.d.ts +18 -0
- package/dist/login/ChangePasswordPrompt.js +51 -0
- package/dist/login/ChangePasswordPrompt.js.map +1 -0
- package/dist/login/LoginFailure.d.ts +25 -0
- package/dist/login/LoginFailure.js +109 -0
- package/dist/login/LoginFailure.js.map +1 -0
- package/dist/login/LoginPage.d.ts +12 -0
- package/dist/login/LoginPage.js +174 -0
- package/dist/login/LoginPage.js.map +1 -0
- package/dist/login/components/LoginContext.d.ts +21 -0
- package/dist/login/components/LoginContext.js +28 -0
- package/dist/login/components/LoginContext.js.map +1 -0
- package/dist/login/data/api.d.ts +2 -0
- package/dist/login/data/api.js +27 -0
- package/dist/login/data/api.js.map +1 -0
- package/dist/login/data/apiHook.d.ts +13 -0
- package/dist/login/data/apiHook.js +57 -0
- package/dist/login/data/apiHook.js.map +1 -0
- package/dist/login/data/constants.d.ts +17 -0
- package/{src → dist}/login/data/constants.js +4 -4
- package/dist/login/data/constants.js.map +1 -0
- package/dist/login/index.d.ts +1 -0
- package/dist/login/index.js +2 -0
- package/dist/login/index.js.map +1 -0
- package/dist/login/messages.d.ts +198 -0
- package/dist/login/messages.js +210 -0
- package/dist/login/messages.js.map +1 -0
- package/dist/logistration/Logistration.d.ts +5 -0
- package/dist/logistration/Logistration.js +80 -0
- package/dist/logistration/Logistration.js.map +1 -0
- package/dist/progressive-profiling/ProgressiveProfiling.d.ts +2 -0
- package/dist/progressive-profiling/ProgressiveProfiling.js +143 -0
- package/dist/progressive-profiling/ProgressiveProfiling.js.map +1 -0
- package/dist/progressive-profiling/ProgressiveProfilingPageModal.d.ts +13 -0
- package/dist/progressive-profiling/ProgressiveProfilingPageModal.js +31 -0
- package/dist/progressive-profiling/ProgressiveProfilingPageModal.js.map +1 -0
- package/dist/progressive-profiling/components/ProgressiveProfilingContext.d.ts +18 -0
- package/dist/progressive-profiling/components/ProgressiveProfilingContext.js +52 -0
- package/dist/progressive-profiling/components/ProgressiveProfilingContext.js.map +1 -0
- package/dist/progressive-profiling/data/api.d.ts +2 -0
- package/dist/progressive-profiling/data/api.js +22 -0
- package/dist/progressive-profiling/data/api.js.map +1 -0
- package/dist/progressive-profiling/data/apiHook.d.ts +10 -0
- package/dist/progressive-profiling/data/apiHook.js +36 -0
- package/dist/progressive-profiling/data/apiHook.js.map +1 -0
- package/dist/progressive-profiling/index.d.ts +2 -0
- package/{src → dist}/progressive-profiling/index.js +1 -3
- package/dist/progressive-profiling/index.js.map +1 -0
- package/dist/progressive-profiling/messages.d.ts +53 -0
- package/dist/progressive-profiling/messages.js +57 -0
- package/dist/progressive-profiling/messages.js.map +1 -0
- package/dist/register/RegistrationFields/CountryField/CountryField.d.ts +38 -0
- package/dist/register/RegistrationFields/CountryField/CountryField.js +93 -0
- package/dist/register/RegistrationFields/CountryField/CountryField.js.map +1 -0
- package/dist/register/RegistrationFields/CountryField/validator.d.ts +8 -0
- package/dist/register/RegistrationFields/CountryField/validator.js +29 -0
- package/dist/register/RegistrationFields/CountryField/validator.js.map +1 -0
- package/dist/register/RegistrationFields/EmailField/EmailField.d.ts +30 -0
- package/dist/register/RegistrationFields/EmailField/EmailField.js +88 -0
- package/dist/register/RegistrationFields/EmailField/EmailField.js.map +1 -0
- package/dist/register/RegistrationFields/EmailField/constants.d.ts +3 -0
- package/dist/register/RegistrationFields/EmailField/constants.js +130 -0
- package/dist/register/RegistrationFields/EmailField/constants.js.map +1 -0
- package/dist/register/RegistrationFields/EmailField/validator.d.ts +17 -0
- package/dist/register/RegistrationFields/EmailField/validator.js +107 -0
- package/dist/register/RegistrationFields/EmailField/validator.js.map +1 -0
- package/dist/register/RegistrationFields/HonorCodeField/HonorCode.d.ts +21 -0
- package/dist/register/RegistrationFields/HonorCodeField/HonorCode.js +40 -0
- package/dist/register/RegistrationFields/HonorCodeField/HonorCode.js.map +1 -0
- package/dist/register/RegistrationFields/NameField/NameField.d.ts +29 -0
- package/dist/register/RegistrationFields/NameField/NameField.js +59 -0
- package/dist/register/RegistrationFields/NameField/NameField.js.map +1 -0
- package/dist/register/RegistrationFields/NameField/validator.d.ts +6 -0
- package/dist/register/RegistrationFields/NameField/validator.js +23 -0
- package/dist/register/RegistrationFields/NameField/validator.js.map +1 -0
- package/dist/register/RegistrationFields/TermsOfServiceField/TermsOfService.d.ts +16 -0
- package/dist/register/RegistrationFields/TermsOfServiceField/TermsOfService.js +24 -0
- package/dist/register/RegistrationFields/TermsOfServiceField/TermsOfService.js.map +1 -0
- package/dist/register/RegistrationFields/UsernameField/UsernameField.d.ts +31 -0
- package/dist/register/RegistrationFields/UsernameField/UsernameField.js +119 -0
- package/dist/register/RegistrationFields/UsernameField/UsernameField.js.map +1 -0
- package/dist/register/RegistrationFields/UsernameField/validator.d.ts +4 -0
- package/dist/register/RegistrationFields/UsernameField/validator.js +15 -0
- package/dist/register/RegistrationFields/UsernameField/validator.js.map +1 -0
- package/dist/register/RegistrationFields/index.d.ts +6 -0
- package/{src → dist}/register/RegistrationFields/index.js +1 -0
- package/dist/register/RegistrationFields/index.js.map +1 -0
- package/dist/register/RegistrationPage.d.ts +18 -0
- package/dist/register/RegistrationPage.js +259 -0
- package/dist/register/RegistrationPage.js.map +1 -0
- package/dist/register/components/ConfigurableRegistrationForm.d.ts +37 -0
- package/dist/register/components/ConfigurableRegistrationForm.js +145 -0
- package/dist/register/components/ConfigurableRegistrationForm.js.map +1 -0
- package/dist/register/components/RegisterContext.d.ts +8 -0
- package/dist/register/components/RegisterContext.js +167 -0
- package/dist/register/components/RegisterContext.js.map +1 -0
- package/dist/register/components/RegistrationFailure.d.ts +19 -0
- package/dist/register/components/RegistrationFailure.js +60 -0
- package/dist/register/components/RegistrationFailure.js.map +1 -0
- package/dist/register/data/api.d.ts +9 -0
- package/dist/register/data/api.js +45 -0
- package/dist/register/data/api.js.map +1 -0
- package/dist/register/data/apiHook.d.ts +33 -0
- package/dist/register/data/apiHook.js +66 -0
- package/dist/register/data/apiHook.js.map +1 -0
- package/dist/register/data/constants.d.ts +11 -0
- package/{src → dist}/register/data/constants.js +5 -4
- package/dist/register/data/constants.js.map +1 -0
- package/dist/register/data/utils.d.ts +6 -0
- package/dist/register/data/utils.js +128 -0
- package/dist/register/data/utils.js.map +1 -0
- package/dist/register/index.d.ts +1 -0
- package/dist/register/index.js +2 -0
- package/dist/register/index.js.map +1 -0
- package/dist/register/messages.d.ts +203 -0
- package/dist/register/messages.js +215 -0
- package/dist/register/messages.js.map +1 -0
- package/dist/register/types.d.ts +74 -0
- package/dist/register/types.js +2 -0
- package/dist/register/types.js.map +1 -0
- package/dist/reset-password/ResetPasswordFailure.d.ts +15 -0
- package/dist/reset-password/ResetPasswordFailure.js +44 -0
- package/dist/reset-password/ResetPasswordFailure.js.map +1 -0
- package/dist/reset-password/ResetPasswordPage.d.ts +2 -0
- package/dist/reset-password/ResetPasswordPage.js +182 -0
- package/dist/reset-password/ResetPasswordPage.js.map +1 -0
- package/dist/reset-password/ResetPasswordSuccess.d.ts +2 -0
- package/dist/reset-password/ResetPasswordSuccess.js +10 -0
- package/dist/reset-password/ResetPasswordSuccess.js.map +1 -0
- package/dist/reset-password/data/api.d.ts +4 -0
- package/dist/reset-password/data/api.js +57 -0
- package/dist/reset-password/data/api.js.map +1 -0
- package/dist/reset-password/data/apiHook.d.ts +31 -0
- package/dist/reset-password/data/apiHook.js +74 -0
- package/dist/reset-password/data/apiHook.js.map +1 -0
- package/dist/reset-password/data/constants.d.ts +13 -0
- package/{src → dist}/reset-password/data/constants.js +6 -7
- package/dist/reset-password/data/constants.js.map +1 -0
- package/dist/reset-password/index.d.ts +1 -0
- package/dist/reset-password/index.js +2 -0
- package/dist/reset-password/index.js.map +1 -0
- package/dist/reset-password/messages.d.ts +83 -0
- package/dist/reset-password/messages.js +87 -0
- package/dist/reset-password/messages.js.map +1 -0
- package/dist/routes.d.ts +19 -0
- package/dist/routes.js +76 -0
- package/dist/routes.js.map +1 -0
- package/{src → dist}/sass/_registration.scss +8 -10
- package/dist/slots/LoginComponentSlot/index.d.ts +12 -0
- package/dist/slots/LoginComponentSlot/index.js +11 -0
- package/dist/slots/LoginComponentSlot/index.js.map +1 -0
- package/package.json +26 -15
- package/src/Main.tsx +0 -23
- package/src/__mocks__/file.js +0 -1
- package/src/__mocks__/svg.js +0 -1
- package/src/app.ts +0 -43
- package/src/base-container/components/default-layout/DefaultLayout.test.jsx +0 -48
- package/src/base-container/components/default-layout/LargeLayout.jsx +0 -42
- package/src/base-container/components/default-layout/MediumLayout.jsx +0 -49
- package/src/base-container/components/default-layout/SmallLayout.jsx +0 -37
- package/src/base-container/components/default-layout/messages.js +0 -16
- package/src/base-container/components/image-layout/ExtraSmallLayout.jsx +0 -31
- package/src/base-container/components/image-layout/LargeLayout.jsx +0 -32
- package/src/base-container/components/image-layout/MediumLayout.jsx +0 -32
- package/src/base-container/components/image-layout/SmallLayout.jsx +0 -31
- package/src/base-container/components/image-layout/messages.js +0 -16
- package/src/base-container/components/welcome-page-layout/LargeLayout.jsx +0 -46
- package/src/base-container/components/welcome-page-layout/MediumLayout.jsx +0 -49
- package/src/base-container/components/welcome-page-layout/SmallLayout.jsx +0 -38
- package/src/base-container/components/welcome-page-layout/messages.js +0 -21
- package/src/base-container/index.jsx +0 -70
- package/src/base-container/tests/BaseContainer.test.jsx +0 -44
- package/src/common-components/EmbeddedRegistrationRoute.jsx +0 -26
- package/src/common-components/EnterpriseSSO.jsx +0 -110
- package/src/common-components/FormGroup.jsx +0 -106
- package/src/common-components/InstitutionLogistration.jsx +0 -102
- package/src/common-components/NotFoundPage.jsx +0 -15
- package/src/common-components/PasswordField.jsx +0 -175
- package/src/common-components/RedirectLogistration.jsx +0 -94
- package/src/common-components/RegisterFaIcons.jsx +0 -8
- package/src/common-components/SocialAuthProviders.jsx +0 -75
- package/src/common-components/ThirdPartyAuth.jsx +0 -123
- package/src/common-components/ThirdPartyAuthAlert.jsx +0 -49
- package/src/common-components/UnAuthOnlyRoute.jsx +0 -41
- package/src/common-components/data/actions.js +0 -27
- package/src/common-components/data/reducers.js +0 -63
- package/src/common-components/data/sagas.js +0 -32
- package/src/common-components/data/selectors.js +0 -28
- package/src/common-components/data/service.js +0 -23
- package/src/common-components/data/tests/reducer.test.js +0 -82
- package/src/common-components/data/tests/sagas.test.js +0 -71
- package/src/common-components/messages.jsx +0 -127
- package/src/common-components/tests/EmbeddedRegistrationRoute.test.jsx +0 -76
- package/src/common-components/tests/FormField.test.jsx +0 -289
- package/src/common-components/tests/SocialAuthProviders.test.jsx +0 -75
- package/src/common-components/tests/ThirdPartyAuthAlert.test.jsx +0 -39
- package/src/common-components/tests/UnAuthOnlyRoute.test.jsx +0 -73
- package/src/common-components/tests/__snapshots__/SocialAuthProviders.test.jsx.snap +0 -156
- package/src/common-components/tests/__snapshots__/ThirdPartyAuthAlert.test.jsx.snap +0 -53
- package/src/constants.ts +0 -1
- package/src/data/configureStore.js +0 -33
- package/src/data/oneTrust.js +0 -3
- package/src/data/reducers.js +0 -36
- package/src/data/sagas.js +0 -19
- package/src/data/tests/cookies.test.js +0 -42
- package/src/data/tests/dataUtils.test.js +0 -19
- package/src/data/tests/reduxUtils.test.js +0 -14
- package/src/data/utils/cookies.js +0 -12
- package/src/data/utils/dataUtils.js +0 -81
- package/src/data/utils/index.js +0 -11
- package/src/data/utils/reduxUtils.js +0 -34
- package/src/data/utils/useMobileResponsive.js +0 -24
- package/src/field-renderer/FieldRenderer.jsx +0 -156
- package/src/field-renderer/tests/FieldRenderer.test.jsx +0 -201
- package/src/forgot-password/ForgotPasswordAlert.jsx +0 -97
- package/src/forgot-password/ForgotPasswordPage.jsx +0 -193
- package/src/forgot-password/data/actions.js +0 -32
- package/src/forgot-password/data/reducers.js +0 -58
- package/src/forgot-password/data/sagas.js +0 -35
- package/src/forgot-password/data/selectors.js +0 -10
- package/src/forgot-password/data/service.js +0 -21
- package/src/forgot-password/data/tests/reducers.test.js +0 -34
- package/src/forgot-password/data/tests/sagas.test.js +0 -67
- package/src/forgot-password/index.js +0 -5
- package/src/forgot-password/messages.js +0 -128
- package/src/forgot-password/tests/ForgotPasswordPage.test.jsx +0 -269
- package/src/i18n/index.js +0 -25
- package/src/login/AccountActivationMessage.jsx +0 -78
- package/src/login/ChangePasswordPrompt.jsx +0 -91
- package/src/login/LoginFailure.jsx +0 -231
- package/src/login/LoginPage.jsx +0 -368
- package/src/login/data/actions.js +0 -39
- package/src/login/data/reducers.js +0 -76
- package/src/login/data/sagas.js +0 -45
- package/src/login/data/service.js +0 -27
- package/src/login/data/tests/reducers.test.js +0 -155
- package/src/login/data/tests/sagas.test.js +0 -110
- package/src/login/index.js +0 -5
- package/src/login/messages.jsx +0 -211
- package/src/login/tests/AccountActivationMessage.test.jsx +0 -122
- package/src/login/tests/ChangePasswordPrompt.test.jsx +0 -75
- package/src/login/tests/LoginFailure.test.jsx +0 -323
- package/src/login/tests/LoginPage.test.jsx +0 -839
- package/src/logistration/Logistration.jsx +0 -189
- package/src/logistration/Logistration.test.jsx +0 -275
- package/src/progressive-profiling/ProgressiveProfiling.jsx +0 -313
- package/src/progressive-profiling/ProgressiveProfilingPageModal.jsx +0 -56
- package/src/progressive-profiling/data/actions.js +0 -22
- package/src/progressive-profiling/data/reducers.js +0 -38
- package/src/progressive-profiling/data/sagas.js +0 -24
- package/src/progressive-profiling/data/selectors.js +0 -14
- package/src/progressive-profiling/data/service.js +0 -17
- package/src/progressive-profiling/messages.jsx +0 -57
- package/src/progressive-profiling/tests/ProgressiveProfiling.test.jsx +0 -322
- package/src/register/RegistrationFields/CountryField/CountryField.jsx +0 -164
- package/src/register/RegistrationFields/CountryField/CountryField.test.jsx +0 -204
- package/src/register/RegistrationFields/CountryField/validator.js +0 -32
- package/src/register/RegistrationFields/EmailField/EmailField.jsx +0 -140
- package/src/register/RegistrationFields/EmailField/EmailField.test.jsx +0 -236
- package/src/register/RegistrationFields/EmailField/constants.js +0 -131
- package/src/register/RegistrationFields/EmailField/validator.js +0 -126
- package/src/register/RegistrationFields/EmailField/validator.test.js +0 -39
- package/src/register/RegistrationFields/HonorCodeField/HonorCode.jsx +0 -104
- package/src/register/RegistrationFields/HonorCodeField/HonorCode.test.jsx +0 -70
- package/src/register/RegistrationFields/NameField/NameField.jsx +0 -68
- package/src/register/RegistrationFields/NameField/NameField.test.jsx +0 -146
- package/src/register/RegistrationFields/NameField/validator.js +0 -22
- package/src/register/RegistrationFields/TermsOfServiceField/TermsOfService.jsx +0 -58
- package/src/register/RegistrationFields/TermsOfServiceField/TermsOfService.test.jsx +0 -55
- package/src/register/RegistrationFields/UsernameField/UsernameField.jsx +0 -162
- package/src/register/RegistrationFields/UsernameField/UsernameField.test.jsx +0 -319
- package/src/register/RegistrationFields/UsernameField/validator.js +0 -16
- package/src/register/RegistrationPage.jsx +0 -428
- package/src/register/RegistrationPage.test.jsx +0 -854
- package/src/register/components/ConfigurableRegistrationForm.jsx +0 -244
- package/src/register/components/RegistrationFailure.jsx +0 -80
- package/src/register/components/tests/ConfigurableRegistrationForm.test.jsx +0 -401
- package/src/register/components/tests/RegistrationFailure.test.jsx +0 -212
- package/src/register/components/tests/ThirdPartyAuth.test.jsx +0 -439
- package/src/register/data/actions.js +0 -85
- package/src/register/data/reducers.js +0 -140
- package/src/register/data/sagas.js +0 -58
- package/src/register/data/selectors.js +0 -34
- package/src/register/data/service.js +0 -45
- package/src/register/data/tests/reducers.test.js +0 -277
- package/src/register/data/tests/sagas.test.js +0 -239
- package/src/register/data/tests/utils.test.js +0 -98
- package/src/register/data/utils.js +0 -147
- package/src/register/index.js +0 -4
- package/src/register/messages.jsx +0 -206
- package/src/reset-password/ResetPasswordFailure.jsx +0 -55
- package/src/reset-password/ResetPasswordPage.jsx +0 -224
- package/src/reset-password/ResetPasswordSuccess.jsx +0 -19
- package/src/reset-password/data/actions.js +0 -50
- package/src/reset-password/data/reducers.js +0 -44
- package/src/reset-password/data/sagas.js +0 -67
- package/src/reset-password/data/selectors.js +0 -10
- package/src/reset-password/data/service.js +0 -61
- package/src/reset-password/data/tests/sagas.test.js +0 -185
- package/src/reset-password/index.js +0 -5
- package/src/reset-password/messages.js +0 -88
- package/src/reset-password/tests/ResetPasswordPage.test.jsx +0 -241
- package/src/routes.jsx +0 -79
- package/src/setupTest.js +0 -68
- /package/{src → dist}/base-container/components/image-layout/index.scss +0 -0
- /package/{src/index.ts → dist/index.d.ts} +0 -0
- /package/{src → dist}/sass/_base_component.scss +0 -0
- /package/{src → dist}/sass/_forgot_password.scss +0 -0
- /package/{src → dist}/sass/_login_page.scss +0 -0
- /package/{src → dist}/sass/_progressive_profiling_page.scss +0 -0
- /package/{src → dist}/sass/_reset_password.scss +0 -0
- /package/{src → dist}/sass/_style.scss +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const emailRegex: RegExp;
|
|
2
|
+
export function getLevenshteinSuggestion(word: any, knownWords: any, similarityThreshold?: number): any;
|
|
3
|
+
export function getSuggestionForInvalidEmail(domain: any, username: any): string;
|
|
4
|
+
export function validateEmailAddress(value: any, username: any, domainName: any): {
|
|
5
|
+
hasError: boolean;
|
|
6
|
+
suggestion: string;
|
|
7
|
+
type: string;
|
|
8
|
+
};
|
|
9
|
+
export default validateEmail;
|
|
10
|
+
declare function validateEmail(value: any, confirmEmailValue: any, formatMessage: any): {
|
|
11
|
+
fieldError: string;
|
|
12
|
+
confirmEmailError: string;
|
|
13
|
+
suggestion: {
|
|
14
|
+
suggestion: string;
|
|
15
|
+
type: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { distance } from 'fastest-levenshtein';
|
|
2
|
+
import { VALID_EMAIL_REGEX } from '../../../data/constants';
|
|
3
|
+
import messages from '../../messages';
|
|
4
|
+
import { COMMON_EMAIL_PROVIDERS, DEFAULT_SERVICE_PROVIDER_DOMAINS, DEFAULT_TOP_LEVEL_DOMAINS, } from './constants';
|
|
5
|
+
export const emailRegex = new RegExp(VALID_EMAIL_REGEX, 'i');
|
|
6
|
+
export const getLevenshteinSuggestion = (word, knownWords, similarityThreshold = 4) => {
|
|
7
|
+
if (!word) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
let minEditDistance = 100;
|
|
11
|
+
let mostSimilar = word;
|
|
12
|
+
for (const knownWord of knownWords) {
|
|
13
|
+
const editDistance = distance(knownWord.toLowerCase(), word.toLowerCase());
|
|
14
|
+
if (editDistance < minEditDistance) {
|
|
15
|
+
minEditDistance = editDistance;
|
|
16
|
+
mostSimilar = knownWord;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return minEditDistance <= similarityThreshold && word !== mostSimilar ? mostSimilar : null;
|
|
20
|
+
};
|
|
21
|
+
export const getSuggestionForInvalidEmail = (domain, username) => {
|
|
22
|
+
if (!domain) {
|
|
23
|
+
return '';
|
|
24
|
+
}
|
|
25
|
+
const defaultDomains = ['yahoo', 'aol', 'hotmail', 'live', 'outlook', 'gmail'];
|
|
26
|
+
const suggestion = getLevenshteinSuggestion(domain, COMMON_EMAIL_PROVIDERS);
|
|
27
|
+
if (suggestion) {
|
|
28
|
+
return `${username}@${suggestion}`;
|
|
29
|
+
}
|
|
30
|
+
for (const defaultDomain of defaultDomains) {
|
|
31
|
+
if (domain.includes(defaultDomain)) {
|
|
32
|
+
return `${username}@${defaultDomain}.com`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return '';
|
|
36
|
+
};
|
|
37
|
+
export const validateEmailAddress = (value, username, domainName) => {
|
|
38
|
+
let suggestion = null;
|
|
39
|
+
const validation = {
|
|
40
|
+
hasError: false,
|
|
41
|
+
suggestion: '',
|
|
42
|
+
type: '',
|
|
43
|
+
};
|
|
44
|
+
const hasMultipleSubdomains = value.match(/\./g).length > 1;
|
|
45
|
+
const [serviceLevelDomain, topLevelDomain] = domainName.split('.');
|
|
46
|
+
const tldSuggestion = !DEFAULT_TOP_LEVEL_DOMAINS.includes(topLevelDomain);
|
|
47
|
+
const serviceSuggestion = getLevenshteinSuggestion(serviceLevelDomain, DEFAULT_SERVICE_PROVIDER_DOMAINS, 2);
|
|
48
|
+
if (DEFAULT_SERVICE_PROVIDER_DOMAINS.includes(serviceSuggestion !== null && serviceSuggestion !== void 0 ? serviceSuggestion : serviceLevelDomain)) {
|
|
49
|
+
suggestion = `${username}@${serviceSuggestion !== null && serviceSuggestion !== void 0 ? serviceSuggestion : serviceLevelDomain}.com`;
|
|
50
|
+
}
|
|
51
|
+
if (!hasMultipleSubdomains && tldSuggestion) {
|
|
52
|
+
validation.suggestion = suggestion;
|
|
53
|
+
validation.type = 'error';
|
|
54
|
+
}
|
|
55
|
+
else if (serviceSuggestion) {
|
|
56
|
+
validation.suggestion = suggestion;
|
|
57
|
+
validation.type = 'warning';
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
suggestion = getLevenshteinSuggestion(domainName, COMMON_EMAIL_PROVIDERS, 3);
|
|
61
|
+
if (suggestion) {
|
|
62
|
+
validation.suggestion = `${username}@${suggestion}`;
|
|
63
|
+
validation.type = 'warning';
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (!hasMultipleSubdomains && tldSuggestion) {
|
|
67
|
+
validation.hasError = true;
|
|
68
|
+
}
|
|
69
|
+
return validation;
|
|
70
|
+
};
|
|
71
|
+
const validateEmail = (value, confirmEmailValue, formatMessage) => {
|
|
72
|
+
let fieldError = '';
|
|
73
|
+
let confirmEmailError = '';
|
|
74
|
+
let emailSuggestion = { suggestion: '', type: '' };
|
|
75
|
+
if (!value) {
|
|
76
|
+
fieldError = formatMessage(messages['empty.email.field.error']);
|
|
77
|
+
}
|
|
78
|
+
else if (value.length <= 2) {
|
|
79
|
+
fieldError = formatMessage(messages['email.invalid.format.error']);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
const [username, domainName] = value.split('@');
|
|
83
|
+
// Check if email address is invalid. If we have a suggestion for invalid email
|
|
84
|
+
// provide that along with the error message.
|
|
85
|
+
if (!emailRegex.test(value)) {
|
|
86
|
+
fieldError = formatMessage(messages['email.invalid.format.error']);
|
|
87
|
+
emailSuggestion = {
|
|
88
|
+
suggestion: getSuggestionForInvalidEmail(domainName, username),
|
|
89
|
+
type: 'error',
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
const response = validateEmailAddress(value, username, domainName);
|
|
94
|
+
if (response.hasError) {
|
|
95
|
+
fieldError = formatMessage(messages['email.invalid.format.error']);
|
|
96
|
+
delete response.hasError;
|
|
97
|
+
}
|
|
98
|
+
emailSuggestion = Object.assign({}, response);
|
|
99
|
+
if (confirmEmailValue && value !== confirmEmailValue) {
|
|
100
|
+
confirmEmailError = formatMessage(messages['email.do.not.match']);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return { fieldError, confirmEmailError, suggestion: emailSuggestion };
|
|
105
|
+
};
|
|
106
|
+
export default validateEmail;
|
|
107
|
+
//# sourceMappingURL=validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../../../src/register/RegistrationFields/EmailField/validator.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EACL,sBAAsB,EACtB,gCAAgC,EAChC,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;AAE7D,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,mBAAmB,GAAG,CAAC,EAAE,EAAE;IACpF,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,eAAe,GAAG,GAAG,CAAC;IAC1B,IAAI,WAAW,GAAG,IAAI,CAAC;IAEvB,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,YAAY,GAAG,QAAQ,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QAC3E,IAAI,YAAY,GAAG,eAAe,EAAE,CAAC;YACnC,eAAe,GAAG,YAAY,CAAC;YAC/B,WAAW,GAAG,SAAS,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,OAAO,eAAe,IAAI,mBAAmB,IAAI,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7F,CAAC,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AC,CAAC,CAAC;IAClE,CAAC;SAAM,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QAC7B,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,4BAA4B,CAAC,CAAC,CAAC;IACrE,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAChD,+EAA+E;QAC/E,6CAA6C;QAC7C,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5B,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,4BAA4B,CAAC,CAAC,CAAC;YACnE,eAAe,GAAG;gBAChB,UAAU,EAAE,4BAA4B,CAAC,UAAU,EAAE,QAAQ,CAAC;gBAC9D,IAAI,EAAE,OAAO;aACd,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,MAAM,QAAQ,GAAG,oBAAoB,CAAC,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;YACnE,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;gBACtB,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,4BAA4B,CAAC,CAAC,CAAC;gBACnE,OAAO,QAAQ,CAAC,QAAQ,CAAC;YAC3B,CAAC;YACD,eAAe,qBAAQ,QAAQ,CAAE,CAAC;YAElC,IAAI,iBAAiB,IAAI,KAAK,KAAK,iBAAiB,EAAE,CAAC;gBACrD,iBAAiB,GAAG,aAAa,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC;YACpE,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;AACxE,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { distance } from 'fastest-levenshtein';\n\nimport { VALID_EMAIL_REGEX } from '../../../data/constants';\nimport messages from '../../messages';\nimport {\n COMMON_EMAIL_PROVIDERS,\n DEFAULT_SERVICE_PROVIDER_DOMAINS,\n DEFAULT_TOP_LEVEL_DOMAINS,\n} from './constants';\n\nexport const emailRegex = new RegExp(VALID_EMAIL_REGEX, 'i');\n\nexport const getLevenshteinSuggestion = (word, knownWords, similarityThreshold = 4) => {\n if (!word) {\n return null;\n }\n\n let minEditDistance = 100;\n let mostSimilar = word;\n\n for (const knownWord of knownWords) {\n const editDistance = distance(knownWord.toLowerCase(), word.toLowerCase());\n if (editDistance < minEditDistance) {\n minEditDistance = editDistance;\n mostSimilar = knownWord;\n }\n }\n\n return minEditDistance <= similarityThreshold && word !== mostSimilar ? mostSimilar : null;\n};\n\nexport const getSuggestionForInvalidEmail = (domain, username) => {\n if (!domain) {\n return '';\n }\n\n const defaultDomains = ['yahoo', 'aol', 'hotmail', 'live', 'outlook', 'gmail'];\n const suggestion = getLevenshteinSuggestion(domain, COMMON_EMAIL_PROVIDERS);\n\n if (suggestion) {\n return `${username}@${suggestion}`;\n }\n\n for (const defaultDomain of defaultDomains) {\n if (domain.includes(defaultDomain)) {\n return `${username}@${defaultDomain}.com`;\n }\n }\n\n return '';\n};\n\nexport const validateEmailAddress = (value, username, domainName) => {\n let suggestion = null;\n const validation = {\n hasError: false,\n suggestion: '',\n type: '',\n };\n\n const hasMultipleSubdomains = value.match(/\\./g).length > 1;\n const [serviceLevelDomain, topLevelDomain] = domainName.split('.');\n const tldSuggestion = !DEFAULT_TOP_LEVEL_DOMAINS.includes(topLevelDomain);\n const serviceSuggestion = getLevenshteinSuggestion(serviceLevelDomain, DEFAULT_SERVICE_PROVIDER_DOMAINS, 2);\n\n if (DEFAULT_SERVICE_PROVIDER_DOMAINS.includes(serviceSuggestion ?? serviceLevelDomain)) {\n suggestion = `${username}@${serviceSuggestion ?? serviceLevelDomain}.com`;\n }\n\n if (!hasMultipleSubdomains && tldSuggestion) {\n validation.suggestion = suggestion;\n validation.type = 'error';\n } else if (serviceSuggestion) {\n validation.suggestion = suggestion;\n validation.type = 'warning';\n } else {\n suggestion = getLevenshteinSuggestion(domainName, COMMON_EMAIL_PROVIDERS, 3);\n if (suggestion) {\n validation.suggestion = `${username}@${suggestion}`;\n validation.type = 'warning';\n }\n }\n\n if (!hasMultipleSubdomains && tldSuggestion) {\n validation.hasError = true;\n }\n\n return validation;\n};\n\nconst validateEmail = (value, confirmEmailValue, formatMessage) => {\n let fieldError = '';\n let confirmEmailError = '';\n let emailSuggestion = { suggestion: '', type: '' };\n\n if (!value) {\n fieldError = formatMessage(messages['empty.email.field.error']);\n } else if (value.length <= 2) {\n fieldError = formatMessage(messages['email.invalid.format.error']);\n } else {\n const [username, domainName] = value.split('@');\n // Check if email address is invalid. If we have a suggestion for invalid email\n // provide that along with the error message.\n if (!emailRegex.test(value)) {\n fieldError = formatMessage(messages['email.invalid.format.error']);\n emailSuggestion = {\n suggestion: getSuggestionForInvalidEmail(domainName, username),\n type: 'error',\n };\n } else {\n const response = validateEmailAddress(value, username, domainName);\n if (response.hasError) {\n fieldError = formatMessage(messages['email.invalid.format.error']);\n delete response.hasError;\n }\n emailSuggestion = { ...response };\n\n if (confirmEmailValue && value !== confirmEmailValue) {\n confirmEmailError = formatMessage(messages['email.do.not.match']);\n }\n }\n }\n return { fieldError, confirmEmailError, suggestion: emailSuggestion };\n};\n\nexport default validateEmail;\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export default HonorCode;
|
|
2
|
+
declare function HonorCode(props: any): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare namespace HonorCode {
|
|
4
|
+
namespace defaultProps {
|
|
5
|
+
let errorMessage: string;
|
|
6
|
+
let onChangeHandler: null;
|
|
7
|
+
let fieldType: string;
|
|
8
|
+
let value: boolean;
|
|
9
|
+
}
|
|
10
|
+
namespace propTypes {
|
|
11
|
+
let errorMessage_1: PropTypes.Requireable<string>;
|
|
12
|
+
export { errorMessage_1 as errorMessage };
|
|
13
|
+
let onChangeHandler_1: PropTypes.Requireable<(...args: any[]) => any>;
|
|
14
|
+
export { onChangeHandler_1 as onChangeHandler };
|
|
15
|
+
let fieldType_1: PropTypes.Requireable<string>;
|
|
16
|
+
export { fieldType_1 as fieldType };
|
|
17
|
+
let value_1: PropTypes.Requireable<boolean>;
|
|
18
|
+
export { value_1 as value };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
import PropTypes from 'prop-types';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { FormattedMessage, useAppConfig, getSiteConfig, useIntl } from '@openedx/frontend-base';
|
|
4
|
+
import { Form, Hyperlink } from '@openedx/paragon';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import messages from '../../messages';
|
|
7
|
+
const HonorCode = (props) => {
|
|
8
|
+
const { formatMessage } = useIntl();
|
|
9
|
+
const { errorMessage, onChangeHandler, fieldType, value, } = props;
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (fieldType === 'tos_and_honor_code' && !value) {
|
|
12
|
+
onChangeHandler({ target: { name: 'honor_code', value: true } });
|
|
13
|
+
}
|
|
14
|
+
}, [fieldType, onChangeHandler, value]);
|
|
15
|
+
if (fieldType === 'tos_and_honor_code') {
|
|
16
|
+
return (_jsx("div", { id: "honor-code", className: "micro text-muted mt-4", children: _jsx(FormattedMessage, { id: "register.page.terms.of.service.and.honor.code", defaultMessage: "By creating an account, you agree to the {tosAndHonorCode} and you acknowledge that {platformName} and each\n Member process your personal data in accordance with the {privacyPolicy}.", description: "Text that appears on registration form stating honor code and privacy policy", values: {
|
|
17
|
+
platformName: getSiteConfig().siteName,
|
|
18
|
+
tosAndHonorCode: (_jsx(Hyperlink, { className: "inline-link", destination: useAppConfig().TOS_AND_HONOR_CODE || '#', target: "_blank", showLaunchIcon: false, children: formatMessage(messages['terms.of.service.and.honor.code']) })),
|
|
19
|
+
privacyPolicy: (_jsx(Hyperlink, { className: "inline-link", destination: useAppConfig().PRIVACY_POLICY || '#', target: "_blank", showLaunchIcon: false, children: formatMessage(messages['privacy.policy']) })),
|
|
20
|
+
} }) }));
|
|
21
|
+
}
|
|
22
|
+
return (_jsxs("div", { id: "honor-code", className: "micro text-muted", children: [_jsx(Form.Checkbox, { className: "form-field--checkbox mt-1", id: "honor-code", checked: value, name: "honor_code", value: value, onChange: onChangeHandler, children: _jsx(FormattedMessage, { id: "register.page.honor.code", defaultMessage: "I agree to the {platformName}\u00A0{tosAndHonorCode}", description: "Text that appears on registration form stating honor code", values: {
|
|
23
|
+
platformName: getSiteConfig().siteName,
|
|
24
|
+
tosAndHonorCode: (_jsx(Hyperlink, { variant: "muted", destination: useAppConfig().TOS_AND_HONOR_CODE || '#', target: "_blank", children: formatMessage(messages['honor.code']) })),
|
|
25
|
+
} }) }), errorMessage && (_jsx(Form.Control.Feedback, { type: "invalid", className: "form-text-size", hasIcon: false, children: errorMessage }))] }));
|
|
26
|
+
};
|
|
27
|
+
HonorCode.defaultProps = {
|
|
28
|
+
errorMessage: '',
|
|
29
|
+
onChangeHandler: null,
|
|
30
|
+
fieldType: 'honor_code',
|
|
31
|
+
value: false,
|
|
32
|
+
};
|
|
33
|
+
HonorCode.propTypes = {
|
|
34
|
+
errorMessage: PropTypes.string,
|
|
35
|
+
onChangeHandler: PropTypes.func,
|
|
36
|
+
fieldType: PropTypes.string,
|
|
37
|
+
value: PropTypes.bool,
|
|
38
|
+
};
|
|
39
|
+
export default HonorCode;
|
|
40
|
+
//# sourceMappingURL=HonorCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HonorCode.js","sourceRoot":"","sources":["../../../../src/register/RegistrationFields/HonorCodeField/HonorCode.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM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E,SAAS,CAAC,MAAM;IAC3B,KAAK,EAAE,SAAS,CAAC,IAAI;CACtB,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import { useEffect } from 'react';\n\nimport { FormattedMessage, useAppConfig, getSiteConfig, useIntl } from '@openedx/frontend-base';\nimport { Form, Hyperlink } from '@openedx/paragon';\nimport PropTypes from 'prop-types';\n\nimport messages from '../../messages';\n\nconst HonorCode = (props) => {\n const { formatMessage } = useIntl();\n const {\n errorMessage, onChangeHandler, fieldType, value,\n } = props;\n\n useEffect(() => {\n if (fieldType === 'tos_and_honor_code' && !value) {\n onChangeHandler({ target: { name: 'honor_code', value: true } });\n }\n }, [fieldType, onChangeHandler, value]);\n\n if (fieldType === 'tos_and_honor_code') {\n return (\n <div id=\"honor-code\" className=\"micro text-muted mt-4\">\n <FormattedMessage\n id=\"register.page.terms.of.service.and.honor.code\"\n defaultMessage=\"By creating an account, you agree to the {tosAndHonorCode} and you acknowledge that {platformName} and each\n Member process your personal data in accordance with the {privacyPolicy}.\"\n description=\"Text that appears on registration form stating honor code and privacy policy\"\n values={{\n platformName: getSiteConfig().siteName,\n tosAndHonorCode: (\n <Hyperlink\n className=\"inline-link\"\n destination={useAppConfig().TOS_AND_HONOR_CODE || '#'}\n target=\"_blank\"\n showLaunchIcon={false}\n >\n {formatMessage(messages['terms.of.service.and.honor.code'])}\n </Hyperlink>\n ),\n privacyPolicy: (\n <Hyperlink\n className=\"inline-link\"\n destination={useAppConfig().PRIVACY_POLICY || '#'}\n target=\"_blank\"\n showLaunchIcon={false}\n >\n {formatMessage(messages['privacy.policy'])}\n </Hyperlink>\n ),\n }}\n />\n </div>\n );\n }\n\n return (\n <div id=\"honor-code\" className=\"micro text-muted\">\n <Form.Checkbox\n className=\"form-field--checkbox mt-1\"\n id=\"honor-code\"\n checked={value}\n name=\"honor_code\"\n value={value}\n onChange={onChangeHandler}\n >\n <FormattedMessage\n id=\"register.page.honor.code\"\n defaultMessage=\"I agree to the {platformName} {tosAndHonorCode}\"\n description=\"Text that appears on registration form stating honor code\"\n values={{\n platformName: getSiteConfig().siteName,\n tosAndHonorCode: (\n <Hyperlink variant=\"muted\" destination={useAppConfig().TOS_AND_HONOR_CODE || '#'} target=\"_blank\">\n {formatMessage(messages['honor.code'])}\n </Hyperlink>\n ),\n }}\n />\n </Form.Checkbox>\n {errorMessage && (\n <Form.Control.Feedback type=\"invalid\" className=\"form-text-size\" hasIcon={false}>\n {errorMessage}\n </Form.Control.Feedback>\n )}\n </div>\n );\n};\n\nHonorCode.defaultProps = {\n errorMessage: '',\n onChangeHandler: null,\n fieldType: 'honor_code',\n value: false,\n};\n\nHonorCode.propTypes = {\n errorMessage: PropTypes.string,\n onChangeHandler: PropTypes.func,\n fieldType: PropTypes.string,\n value: PropTypes.bool,\n};\n\nexport default HonorCode;\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default NameField;
|
|
2
|
+
/**
|
|
3
|
+
* Name field wrapper. It accepts following handlers
|
|
4
|
+
* - handleChange for setting value change and
|
|
5
|
+
* - handleErrorChange for setting error
|
|
6
|
+
*
|
|
7
|
+
* It is responsible for
|
|
8
|
+
* - Making backend call for generating username suggestions
|
|
9
|
+
* - Performing name field validations
|
|
10
|
+
* - Clearing error on focus
|
|
11
|
+
* - Setting value on change
|
|
12
|
+
*/
|
|
13
|
+
declare function NameField(props: any): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
declare namespace NameField {
|
|
15
|
+
namespace defaultProps {
|
|
16
|
+
let errorMessage: string;
|
|
17
|
+
let shouldFetchUsernameSuggestions: boolean;
|
|
18
|
+
}
|
|
19
|
+
namespace propTypes {
|
|
20
|
+
let errorMessage_1: PropTypes.Requireable<string>;
|
|
21
|
+
export { errorMessage_1 as errorMessage };
|
|
22
|
+
let shouldFetchUsernameSuggestions_1: PropTypes.Requireable<boolean>;
|
|
23
|
+
export { shouldFetchUsernameSuggestions_1 as shouldFetchUsernameSuggestions };
|
|
24
|
+
export let value: PropTypes.Validator<string>;
|
|
25
|
+
export let handleChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
26
|
+
export let handleErrorChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
import PropTypes from 'prop-types';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useIntl } from '@openedx/frontend-base';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import validateName from './validator';
|
|
5
|
+
import { FormGroup } from '../../../common-components';
|
|
6
|
+
import { useRegisterContext } from '../../components/RegisterContext';
|
|
7
|
+
import { useFieldValidations } from '../../data/apiHook';
|
|
8
|
+
/**
|
|
9
|
+
* Name field wrapper. It accepts following handlers
|
|
10
|
+
* - handleChange for setting value change and
|
|
11
|
+
* - handleErrorChange for setting error
|
|
12
|
+
*
|
|
13
|
+
* It is responsible for
|
|
14
|
+
* - Making backend call for generating username suggestions
|
|
15
|
+
* - Performing name field validations
|
|
16
|
+
* - Clearing error on focus
|
|
17
|
+
* - Setting value on change
|
|
18
|
+
*/
|
|
19
|
+
const NameField = (props) => {
|
|
20
|
+
const { formatMessage } = useIntl();
|
|
21
|
+
const { setValidationsSuccess, setValidationsFailure, validationApiRateLimited, clearRegistrationBackendError, } = useRegisterContext();
|
|
22
|
+
const fieldValidationsMutation = useFieldValidations({
|
|
23
|
+
onSuccess: (data) => {
|
|
24
|
+
setValidationsSuccess(data);
|
|
25
|
+
},
|
|
26
|
+
onError: () => {
|
|
27
|
+
setValidationsFailure();
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const { handleErrorChange, shouldFetchUsernameSuggestions, } = props;
|
|
31
|
+
const handleOnBlur = (e) => {
|
|
32
|
+
const { value } = e.target;
|
|
33
|
+
const fieldError = validateName(value, formatMessage);
|
|
34
|
+
if (fieldError) {
|
|
35
|
+
handleErrorChange('name', fieldError);
|
|
36
|
+
}
|
|
37
|
+
else if (shouldFetchUsernameSuggestions && !validationApiRateLimited) {
|
|
38
|
+
fieldValidationsMutation.mutate({ name: value });
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const handleOnFocus = () => {
|
|
42
|
+
handleErrorChange('name', '');
|
|
43
|
+
clearRegistrationBackendError('name');
|
|
44
|
+
};
|
|
45
|
+
return (_jsx(FormGroup, Object.assign({}, props, { handleBlur: handleOnBlur, handleFocus: handleOnFocus })));
|
|
46
|
+
};
|
|
47
|
+
NameField.defaultProps = {
|
|
48
|
+
errorMessage: '',
|
|
49
|
+
shouldFetchUsernameSuggestions: false,
|
|
50
|
+
};
|
|
51
|
+
NameField.propTypes = {
|
|
52
|
+
errorMessage: PropTypes.string,
|
|
53
|
+
shouldFetchUsernameSuggestions: PropTypes.bool,
|
|
54
|
+
value: PropTypes.string.isRequired,
|
|
55
|
+
handleChange: PropTypes.func.isRequired,
|
|
56
|
+
handleErrorChange: PropTypes.func.isRequired,
|
|
57
|
+
};
|
|
58
|
+
export default NameField;
|
|
59
|
+
//# sourceMappingURL=NameField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NameField.js","sourceRoot":"","sources":["../../../../src/register/RegistrationFields/NameField/NameField.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,YAAY,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,EAAE;IAC1B,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IACpC,MAAM,EACJ,qBAAqB,EACrB,qBAAqB,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C,IAAI;IAC9C,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;IAClC,YAAY,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IACvC,iBAAiB,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;CAC7C,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import { useIntl } from '@openedx/frontend-base';\nimport PropTypes from 'prop-types';\n\nimport validateName from './validator';\nimport { FormGroup } from '../../../common-components';\nimport { useRegisterContext } from '../../components/RegisterContext';\nimport { useFieldValidations } from '../../data/apiHook';\n\n/**\n * Name field wrapper. It accepts following handlers\n * - handleChange for setting value change and\n * - handleErrorChange for setting error\n *\n * It is responsible for\n * - Making backend call for generating username suggestions\n * - Performing name field validations\n * - Clearing error on focus\n * - Setting value on change\n */\nconst NameField = (props) => {\n const { formatMessage } = useIntl();\n const {\n setValidationsSuccess,\n setValidationsFailure,\n validationApiRateLimited,\n clearRegistrationBackendError,\n } = useRegisterContext();\n\n const fieldValidationsMutation = useFieldValidations({\n onSuccess: (data) => {\n setValidationsSuccess(data);\n },\n onError: () => {\n setValidationsFailure();\n },\n });\n const {\n handleErrorChange,\n shouldFetchUsernameSuggestions,\n } = props;\n\n const handleOnBlur = (e) => {\n const { value } = e.target;\n const fieldError = validateName(value, formatMessage);\n if (fieldError) {\n handleErrorChange('name', fieldError);\n } else if (shouldFetchUsernameSuggestions && !validationApiRateLimited) {\n fieldValidationsMutation.mutate({ name: value });\n }\n };\n\n const handleOnFocus = () => {\n handleErrorChange('name', '');\n clearRegistrationBackendError('name');\n };\n\n return (\n <FormGroup\n {...props}\n handleBlur={handleOnBlur}\n handleFocus={handleOnFocus}\n />\n );\n};\n\nNameField.defaultProps = {\n errorMessage: '',\n shouldFetchUsernameSuggestions: false,\n};\n\nNameField.propTypes = {\n errorMessage: PropTypes.string,\n shouldFetchUsernameSuggestions: PropTypes.bool,\n value: PropTypes.string.isRequired,\n handleChange: PropTypes.func.isRequired,\n handleErrorChange: PropTypes.func.isRequired,\n};\n\nexport default NameField;\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import messages from '../../messages';
|
|
2
|
+
// regex more focused towards url matching
|
|
3
|
+
export const URL_REGEX = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)?/gi; // eslint-disable-line no-useless-escape
|
|
4
|
+
// regex for html tags
|
|
5
|
+
export const HTML_REGEX = /<|>/u;
|
|
6
|
+
// regex from backend
|
|
7
|
+
export const INVALID_NAME_REGEX = /https?:\/\/(?:[-\w.]|(?:%[\da-fA-F]{2}))*/g;
|
|
8
|
+
export const MAX_FULL_NAME_LENGTH = 255;
|
|
9
|
+
const validateName = (value, formatMessage) => {
|
|
10
|
+
let fieldError = '';
|
|
11
|
+
if (!value.trim()) {
|
|
12
|
+
fieldError = formatMessage(messages['empty.name.field.error']);
|
|
13
|
+
}
|
|
14
|
+
else if (URL_REGEX.test(value) || HTML_REGEX.test(value) || INVALID_NAME_REGEX.test(value)) {
|
|
15
|
+
fieldError = formatMessage(messages['name.validation.message']);
|
|
16
|
+
}
|
|
17
|
+
else if (value && value.length > MAX_FULL_NAME_LENGTH) {
|
|
18
|
+
fieldError = formatMessage(messages['name.validation.length.message'], { limit: MAX_FULL_NAME_LENGTH });
|
|
19
|
+
}
|
|
20
|
+
return fieldError;
|
|
21
|
+
};
|
|
22
|
+
export default validateName;
|
|
23
|
+
//# sourceMappingURL=validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../../../src/register/RegistrationFields/NameField/validator.js"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,0CAA0C;AAC1C,MAAM,CAAC,MAAM,SAAS,GAAG,uFAAuF,CAAC,CAAC,wCAAwC;AAE1J,sBAAsB;AACtB,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC;AAEjC,qBAAqB;AACrB,MAAM,CAAC,MAAM,kBAAkB,GAAG,4CAA4C,CAAC;AAE/E,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAExC,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;IAC5C,IAAI,UAAU,GAAG,EAAE,CAAC;IACpB,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAClB,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,wBAAwB,CAAC,CAAC,CAAC;IACjE,CAAC;SAAM,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7F,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC,CAAC;IAClE,CAAC;SAAM,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,oBAAoB,EAAE,CAAC;QACxD,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,gCAAgC,CAAC,EAAE,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAAC,CAAC;IAC1G,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import messages from '../../messages';\n\n// regex more focused towards url matching\nexport const URL_REGEX = /[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)?/gi; // eslint-disable-line no-useless-escape\n\n// regex for html tags\nexport const HTML_REGEX = /<|>/u;\n\n// regex from backend\nexport const INVALID_NAME_REGEX = /https?:\\/\\/(?:[-\\w.]|(?:%[\\da-fA-F]{2}))*/g;\n\nexport const MAX_FULL_NAME_LENGTH = 255;\n\nconst validateName = (value, formatMessage) => {\n let fieldError = '';\n if (!value.trim()) {\n fieldError = formatMessage(messages['empty.name.field.error']);\n } else if (URL_REGEX.test(value) || HTML_REGEX.test(value) || INVALID_NAME_REGEX.test(value)) {\n fieldError = formatMessage(messages['name.validation.message']);\n } else if (value && value.length > MAX_FULL_NAME_LENGTH) {\n fieldError = formatMessage(messages['name.validation.length.message'], { limit: MAX_FULL_NAME_LENGTH });\n }\n return fieldError;\n};\n\nexport default validateName;\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default TermsOfService;
|
|
2
|
+
declare function TermsOfService(props: any): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare namespace TermsOfService {
|
|
4
|
+
namespace defaultProps {
|
|
5
|
+
let errorMessage: string;
|
|
6
|
+
let value: boolean;
|
|
7
|
+
}
|
|
8
|
+
namespace propTypes {
|
|
9
|
+
let errorMessage_1: PropTypes.Requireable<string>;
|
|
10
|
+
export { errorMessage_1 as errorMessage };
|
|
11
|
+
export let onChangeHandler: PropTypes.Validator<(...args: any[]) => any>;
|
|
12
|
+
let value_1: PropTypes.Requireable<boolean>;
|
|
13
|
+
export { value_1 as value };
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
import PropTypes from 'prop-types';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FormattedMessage, useAppConfig, getSiteConfig, useIntl } from '@openedx/frontend-base';
|
|
3
|
+
import { Form, Hyperlink } from '@openedx/paragon';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import messages from '../../messages';
|
|
6
|
+
const TermsOfService = (props) => {
|
|
7
|
+
const { formatMessage } = useIntl();
|
|
8
|
+
const { errorMessage, onChangeHandler, value, } = props;
|
|
9
|
+
return (_jsxs("div", { id: "terms-of-service", className: "micro text-muted", children: [_jsx(Form.Checkbox, { className: "form-field--checkbox mt-1", id: "tos", checked: value, name: "terms_of_service", value: value, onChange: onChangeHandler, children: _jsx(FormattedMessage, { id: "register.page.terms.of.service", defaultMessage: "I agree to the {platformName}\u00A0{termsOfService}", description: "Text that appears on registration form stating terms of service.\n It is a legal document that users must agree to.", values: {
|
|
10
|
+
platformName: getSiteConfig().siteName,
|
|
11
|
+
termsOfService: (_jsx(Hyperlink, { variant: "muted", destination: useAppConfig().TOS_LINK || '#', target: "_blank", children: formatMessage(messages['terms.of.service']) })),
|
|
12
|
+
} }) }), errorMessage && (_jsx(Form.Control.Feedback, { type: "invalid", className: "form-text-size", hasIcon: false, children: errorMessage }))] }));
|
|
13
|
+
};
|
|
14
|
+
TermsOfService.defaultProps = {
|
|
15
|
+
errorMessage: '',
|
|
16
|
+
value: false,
|
|
17
|
+
};
|
|
18
|
+
TermsOfService.propTypes = {
|
|
19
|
+
errorMessage: PropTypes.string,
|
|
20
|
+
onChangeHandler: PropTypes.func.isRequired,
|
|
21
|
+
value: PropTypes.bool,
|
|
22
|
+
};
|
|
23
|
+
export default TermsOfService;
|
|
24
|
+
//# sourceMappingURL=TermsOfService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TermsOfService.js","sourceRoot":"","sources":["../../../../src/register/RegistrationFields/TermsOfServiceField/TermsOfService.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAChG,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,EAAE;IAC/B,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IACpC,MAAM,EACJ,YAAY,EAAE,eAAe,EAAE,KAAK,GACrC,GAAG,KAAK,CAAC;IAEV,OAAO,CACL,eAAK,EAAE,EAAC,kBAAkB,EAAC,SAAS,EAAC,kBAAkB,aACrD,KAAC,IAAI,CAAC,QAAQ,IACZ,SAAS,EAAC,2BAA2B,EACrC,EAAE,EAAC,KAAK,EACR,OAAO,EAAE,KAAK,EACd,IAAI,EAAC,kBAAkB,EACvB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,eAAe,YAEzB,KAAC,gBAAgB,IACf,EAAE,EAAC,gCAAgC,EACnC,cAAc,EAAC,qDAAqD,EACpE,WAAW,EAAC,2IACkD,EAC9D,MAAM,EAAE;wBACN,YAAY,EAAE,aAAa,EAAE,CAAC,QAAQ;wBACtC,cAAc,EAAE,CACd,KAAC,SAAS,IAAC,OAAO,EAAC,OAAO,EAAC,WAAW,EAAE,YAAY,EAAE,CAAC,QAAQ,IAAI,GAAG,EAAE,MAAM,EAAC,QAAQ,YACpF,aAAa,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,GAClC,CACb;qBACF,GACD,GACY,EACf,YAAY,IAAI,CACf,KAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAC,IAAI,EAAC,SAAS,EAAC,SAAS,EAAC,gBAAgB,EAAC,OAAO,EAAE,KAAK,YAC5E,YAAY,GACS,CACzB,IACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,cAAc,CAAC,YAAY,GAAG;IAC5B,YAAY,EAAE,EAAE;IAChB,KAAK,EAAE,KAAK;CACb,CAAC;AAEF,cAAc,CAAC,SAAS,GAAG;IACzB,YAAY,EAAE,SAAS,CAAC,MAAM;IAC9B,eAAe,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IAC1C,KAAK,EAAE,SAAS,CAAC,IAAI;CACtB,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { FormattedMessage, useAppConfig, getSiteConfig, useIntl } from '@openedx/frontend-base';\nimport { Form, Hyperlink } from '@openedx/paragon';\nimport PropTypes from 'prop-types';\n\nimport messages from '../../messages';\n\nconst TermsOfService = (props) => {\n const { formatMessage } = useIntl();\n const {\n errorMessage, onChangeHandler, value,\n } = props;\n\n return (\n <div id=\"terms-of-service\" className=\"micro text-muted\">\n <Form.Checkbox\n className=\"form-field--checkbox mt-1\"\n id=\"tos\"\n checked={value}\n name=\"terms_of_service\"\n value={value}\n onChange={onChangeHandler}\n >\n <FormattedMessage\n id=\"register.page.terms.of.service\"\n defaultMessage=\"I agree to the {platformName} {termsOfService}\"\n description=\"Text that appears on registration form stating terms of service.\n It is a legal document that users must agree to.\"\n values={{\n platformName: getSiteConfig().siteName,\n termsOfService: (\n <Hyperlink variant=\"muted\" destination={useAppConfig().TOS_LINK || '#'} target=\"_blank\">\n {formatMessage(messages['terms.of.service'])}\n </Hyperlink>\n ),\n }}\n />\n </Form.Checkbox>\n {errorMessage && (\n <Form.Control.Feedback type=\"invalid\" className=\"form-text-size\" hasIcon={false}>\n {errorMessage}\n </Form.Control.Feedback>\n )}\n </div>\n );\n};\n\nTermsOfService.defaultProps = {\n errorMessage: '',\n value: false,\n};\n\nTermsOfService.propTypes = {\n errorMessage: PropTypes.string,\n onChangeHandler: PropTypes.func.isRequired,\n value: PropTypes.bool,\n};\n\nexport default TermsOfService;\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export default UsernameField;
|
|
2
|
+
/**
|
|
3
|
+
* Username field wrapper. It accepts following handlers
|
|
4
|
+
* - handleChange for setting value change and
|
|
5
|
+
* - handleErrorChange for setting error
|
|
6
|
+
*
|
|
7
|
+
* It is responsible for
|
|
8
|
+
* - Rendering username suggestions
|
|
9
|
+
* - Setting and clearing username suggestions
|
|
10
|
+
* - Performing username field validations
|
|
11
|
+
* - clearing error on focus
|
|
12
|
+
* - setting value on change
|
|
13
|
+
*/
|
|
14
|
+
declare function UsernameField(props: any): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
declare namespace UsernameField {
|
|
16
|
+
namespace defaultProps {
|
|
17
|
+
let errorMessage: string;
|
|
18
|
+
let autoComplete: null;
|
|
19
|
+
}
|
|
20
|
+
namespace propTypes {
|
|
21
|
+
export let handleChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
22
|
+
export let handleErrorChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
23
|
+
let errorMessage_1: PropTypes.Requireable<string>;
|
|
24
|
+
export { errorMessage_1 as errorMessage };
|
|
25
|
+
export let name: PropTypes.Validator<string>;
|
|
26
|
+
export let value: PropTypes.Validator<string>;
|
|
27
|
+
let autoComplete_1: PropTypes.Requireable<string>;
|
|
28
|
+
export { autoComplete_1 as autoComplete };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
import PropTypes from 'prop-types';
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { useIntl } from '@openedx/frontend-base';
|
|
4
|
+
import { Button, Icon, IconButton } from '@openedx/paragon';
|
|
5
|
+
import { Close } from '@openedx/paragon/icons';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import validateUsername from './validator';
|
|
8
|
+
import { FormGroup } from '../../../common-components';
|
|
9
|
+
import { useRegisterContext } from '../../components/RegisterContext';
|
|
10
|
+
import { useFieldValidations } from '../../data/apiHook';
|
|
11
|
+
import messages from '../../messages';
|
|
12
|
+
/**
|
|
13
|
+
* Username field wrapper. It accepts following handlers
|
|
14
|
+
* - handleChange for setting value change and
|
|
15
|
+
* - handleErrorChange for setting error
|
|
16
|
+
*
|
|
17
|
+
* It is responsible for
|
|
18
|
+
* - Rendering username suggestions
|
|
19
|
+
* - Setting and clearing username suggestions
|
|
20
|
+
* - Performing username field validations
|
|
21
|
+
* - clearing error on focus
|
|
22
|
+
* - setting value on change
|
|
23
|
+
*/
|
|
24
|
+
const UsernameField = (props) => {
|
|
25
|
+
const { formatMessage } = useIntl();
|
|
26
|
+
const { value, errorMessage, handleChange, handleErrorChange, } = props;
|
|
27
|
+
let className = '';
|
|
28
|
+
let suggestedUsernameDiv = null;
|
|
29
|
+
let iconButton = null;
|
|
30
|
+
const { usernameSuggestions, validationApiRateLimited, setValidationsSuccess, setValidationsFailure, clearUsernameSuggestions, clearRegistrationBackendError, } = useRegisterContext();
|
|
31
|
+
const fieldValidationsMutation = useFieldValidations({
|
|
32
|
+
onSuccess: (data) => {
|
|
33
|
+
setValidationsSuccess(data);
|
|
34
|
+
},
|
|
35
|
+
onError: () => {
|
|
36
|
+
setValidationsFailure();
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* We need to remove the placeholder from the field, adding a space will do that.
|
|
41
|
+
* This is needed because we are placing the username suggestions on top of the field.
|
|
42
|
+
*/
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (usernameSuggestions.length && !value) {
|
|
45
|
+
handleChange({ target: { name: 'username', value: ' ' } });
|
|
46
|
+
}
|
|
47
|
+
}, [handleChange, usernameSuggestions, value]);
|
|
48
|
+
const handleOnBlur = (event) => {
|
|
49
|
+
const { value: username } = event.target;
|
|
50
|
+
const fieldError = validateUsername(username, formatMessage);
|
|
51
|
+
if (fieldError) {
|
|
52
|
+
handleErrorChange('username', fieldError);
|
|
53
|
+
}
|
|
54
|
+
else if (!validationApiRateLimited) {
|
|
55
|
+
fieldValidationsMutation.mutate({ username });
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const handleOnChange = (event) => {
|
|
59
|
+
let username = event.target.value;
|
|
60
|
+
if (username.length > 30) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (event.target.value.startsWith(' ')) {
|
|
64
|
+
username = username.trim();
|
|
65
|
+
}
|
|
66
|
+
handleChange({ target: { name: 'username', value: username } });
|
|
67
|
+
};
|
|
68
|
+
const handleOnFocus = (event) => {
|
|
69
|
+
const username = event.target.value;
|
|
70
|
+
clearUsernameSuggestions();
|
|
71
|
+
// If we added a space character to username field to display the suggestion
|
|
72
|
+
// remove it before user enters the input. This is to ensure user doesn't
|
|
73
|
+
// have a space prefixed to the username.
|
|
74
|
+
if (username === ' ') {
|
|
75
|
+
handleChange({ target: { name: 'username', value: '' } });
|
|
76
|
+
}
|
|
77
|
+
handleErrorChange('username', '');
|
|
78
|
+
clearRegistrationBackendError('username');
|
|
79
|
+
};
|
|
80
|
+
const handleSuggestionClick = (event, suggestion = '') => {
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
handleErrorChange('username', ''); // clear error
|
|
83
|
+
handleChange({ target: { name: 'username', value: suggestion } }); // to set suggestion as value
|
|
84
|
+
clearUsernameSuggestions();
|
|
85
|
+
};
|
|
86
|
+
const handleUsernameSuggestionClose = () => {
|
|
87
|
+
handleChange({ target: { name: 'username', value: '' } }); // to remove space in field
|
|
88
|
+
clearUsernameSuggestions();
|
|
89
|
+
};
|
|
90
|
+
const suggestedUsernames = () => (_jsxs("div", { className: className, role: "listbox", children: [_jsx("span", { className: "text-gray username-suggestion--label", children: formatMessage(messages['registration.username.suggestion.label']) }), _jsx("div", { className: "username-scroll-suggested--form-field", children: usernameSuggestions.map((username, index) => (_jsx(Button, { type: "button", name: "username", variant: "outline-dark", className: "username-suggestions--chip data-hj-suppress", autoComplete: props.autoComplete, tabIndex: 0, onClick: (e) => handleSuggestionClick(e, username), role: "option", children: username }, `suggestion-${index.toString()}`))) }), iconButton] }));
|
|
91
|
+
if (usernameSuggestions.length > 0 && errorMessage && value === ' ') {
|
|
92
|
+
className = 'username-suggestions';
|
|
93
|
+
iconButton = _jsx(IconButton, { src: Close, iconAs: Icon, alt: "Close", onClick: () => handleUsernameSuggestionClose(), variant: "black", size: "sm", className: "username-suggestions__close__button" });
|
|
94
|
+
suggestedUsernameDiv = suggestedUsernames();
|
|
95
|
+
}
|
|
96
|
+
else if (usernameSuggestions.length > 0 && value === ' ') {
|
|
97
|
+
className = 'username-suggestions d-flex align-items-center';
|
|
98
|
+
iconButton = _jsx(IconButton, { src: Close, iconAs: Icon, alt: "Close", onClick: () => handleUsernameSuggestionClose(), variant: "black", size: "sm", className: "username-suggestions__close__button" });
|
|
99
|
+
suggestedUsernameDiv = suggestedUsernames();
|
|
100
|
+
}
|
|
101
|
+
else if (usernameSuggestions.length > 0 && errorMessage) {
|
|
102
|
+
suggestedUsernameDiv = suggestedUsernames();
|
|
103
|
+
}
|
|
104
|
+
return (_jsxs("div", { className: "username__form-group-wrapper", children: [suggestedUsernameDiv, _jsx(FormGroup, Object.assign({}, props, { handleChange: handleOnChange, handleFocus: handleOnFocus, handleBlur: handleOnBlur }))] }));
|
|
105
|
+
};
|
|
106
|
+
UsernameField.defaultProps = {
|
|
107
|
+
errorMessage: '',
|
|
108
|
+
autoComplete: null,
|
|
109
|
+
};
|
|
110
|
+
UsernameField.propTypes = {
|
|
111
|
+
handleChange: PropTypes.func.isRequired,
|
|
112
|
+
handleErrorChange: PropTypes.func.isRequired,
|
|
113
|
+
errorMessage: PropTypes.string,
|
|
114
|
+
name: PropTypes.string.isRequired,
|
|
115
|
+
value: PropTypes.string.isRequired,
|
|
116
|
+
autoComplete: PropTypes.string,
|
|
117
|
+
};
|
|
118
|
+
export default UsernameField;
|
|
119
|
+
//# sourceMappingURL=UsernameField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UsernameField.js","sourceRoot":"","sources":["../../../../src/register/RegistrationFields/UsernameField/UsernameField.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,gBAAgB,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE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B,YAAY,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IACvC,iBAAiB,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IAC5C,YAAY,EAAE,SAAS,CAAC,MAAM;IAC9B,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;IACjC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;IAClC,YAAY,EAAE,SAAS,CAAC,MAAM;CAC/B,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { useEffect } from 'react';\n\nimport { useIntl } from '@openedx/frontend-base';\nimport { Button, Icon, IconButton } from '@openedx/paragon';\nimport { Close } from '@openedx/paragon/icons';\nimport PropTypes from 'prop-types';\n\nimport validateUsername from './validator';\nimport { FormGroup } from '../../../common-components';\nimport { useRegisterContext } from '../../components/RegisterContext';\nimport { useFieldValidations } from '../../data/apiHook';\nimport messages from '../../messages';\n\n/**\n * Username field wrapper. It accepts following handlers\n * - handleChange for setting value change and\n * - handleErrorChange for setting error\n *\n * It is responsible for\n * - Rendering username suggestions\n * - Setting and clearing username suggestions\n * - Performing username field validations\n * - clearing error on focus\n * - setting value on change\n */\nconst UsernameField = (props) => {\n const { formatMessage } = useIntl();\n\n const {\n value,\n errorMessage,\n handleChange,\n handleErrorChange,\n } = props;\n\n let className = '';\n let suggestedUsernameDiv = null;\n let iconButton = null;\n const {\n usernameSuggestions,\n validationApiRateLimited,\n setValidationsSuccess,\n setValidationsFailure,\n clearUsernameSuggestions,\n clearRegistrationBackendError,\n } = useRegisterContext();\n\n const fieldValidationsMutation = useFieldValidations({\n onSuccess: (data) => {\n setValidationsSuccess(data);\n },\n onError: () => {\n setValidationsFailure();\n },\n });\n\n /**\n * We need to remove the placeholder from the field, adding a space will do that.\n * This is needed because we are placing the username suggestions on top of the field.\n */\n useEffect(() => {\n if (usernameSuggestions.length && !value) {\n handleChange({ target: { name: 'username', value: ' ' } });\n }\n }, [handleChange, usernameSuggestions, value]);\n\n const handleOnBlur = (event) => {\n const { value: username } = event.target;\n const fieldError = validateUsername(username, formatMessage);\n if (fieldError) {\n handleErrorChange('username', fieldError);\n } else if (!validationApiRateLimited) {\n fieldValidationsMutation.mutate({ username });\n }\n };\n\n const handleOnChange = (event) => {\n let username = event.target.value;\n if (username.length > 30) {\n return;\n }\n if (event.target.value.startsWith(' ')) {\n username = username.trim();\n }\n handleChange({ target: { name: 'username', value: username } });\n };\n\n const handleOnFocus = (event) => {\n const username = event.target.value;\n clearUsernameSuggestions();\n // If we added a space character to username field to display the suggestion\n // remove it before user enters the input. This is to ensure user doesn't\n // have a space prefixed to the username.\n if (username === ' ') {\n handleChange({ target: { name: 'username', value: '' } });\n }\n handleErrorChange('username', '');\n clearRegistrationBackendError('username');\n };\n\n const handleSuggestionClick = (event, suggestion = '') => {\n event.preventDefault();\n handleErrorChange('username', ''); // clear error\n handleChange({ target: { name: 'username', value: suggestion } }); // to set suggestion as value\n clearUsernameSuggestions();\n };\n\n const handleUsernameSuggestionClose = () => {\n handleChange({ target: { name: 'username', value: '' } }); // to remove space in field\n clearUsernameSuggestions();\n };\n\n const suggestedUsernames = () => (\n <div className={className} role=\"listbox\">\n <span className=\"text-gray username-suggestion--label\">{formatMessage(messages['registration.username.suggestion.label'])}</span>\n <div className=\"username-scroll-suggested--form-field\">\n {usernameSuggestions.map((username, index) => (\n <Button\n type=\"button\"\n name=\"username\"\n variant=\"outline-dark\"\n className=\"username-suggestions--chip data-hj-suppress\"\n autoComplete={props.autoComplete}\n key={`suggestion-${index.toString()}`}\n tabIndex={0}\n onClick={(e) => handleSuggestionClick(e, username)}\n role=\"option\"\n >\n {username}\n </Button>\n ))}\n </div>\n {iconButton}\n </div>\n );\n\n if (usernameSuggestions.length > 0 && errorMessage && value === ' ') {\n className = 'username-suggestions';\n iconButton = <IconButton src={Close} iconAs={Icon} alt=\"Close\" onClick={() => handleUsernameSuggestionClose()} variant=\"black\" size=\"sm\" className=\"username-suggestions__close__button\" />;\n suggestedUsernameDiv = suggestedUsernames();\n } else if (usernameSuggestions.length > 0 && value === ' ') {\n className = 'username-suggestions d-flex align-items-center';\n iconButton = <IconButton src={Close} iconAs={Icon} alt=\"Close\" onClick={() => handleUsernameSuggestionClose()} variant=\"black\" size=\"sm\" className=\"username-suggestions__close__button\" />;\n suggestedUsernameDiv = suggestedUsernames();\n } else if (usernameSuggestions.length > 0 && errorMessage) {\n suggestedUsernameDiv = suggestedUsernames();\n }\n return (\n <div className=\"username__form-group-wrapper\">\n {suggestedUsernameDiv}\n <FormGroup\n {...props}\n handleChange={handleOnChange}\n handleFocus={handleOnFocus}\n handleBlur={handleOnBlur}\n />\n </div>\n );\n};\n\nUsernameField.defaultProps = {\n errorMessage: '',\n autoComplete: null,\n};\n\nUsernameField.propTypes = {\n handleChange: PropTypes.func.isRequired,\n handleErrorChange: PropTypes.func.isRequired,\n errorMessage: PropTypes.string,\n name: PropTypes.string.isRequired,\n value: PropTypes.string.isRequired,\n autoComplete: PropTypes.string,\n};\n\nexport default UsernameField;\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import messages from '../../messages';
|
|
2
|
+
export const VALID_USERNAME_REGEX = /^[a-zA-Z0-9_-]*$/i;
|
|
3
|
+
export const usernameRegex = new RegExp(VALID_USERNAME_REGEX, 'i');
|
|
4
|
+
const validateUsername = (value, formatMessage) => {
|
|
5
|
+
let fieldError = '';
|
|
6
|
+
if (!value || value.length <= 1 || value.length > 30) {
|
|
7
|
+
fieldError = formatMessage(messages['username.validation.message']);
|
|
8
|
+
}
|
|
9
|
+
else if (!usernameRegex.test(value)) {
|
|
10
|
+
fieldError = formatMessage(messages['username.format.validation.message']);
|
|
11
|
+
}
|
|
12
|
+
return fieldError;
|
|
13
|
+
};
|
|
14
|
+
export default validateUsername;
|
|
15
|
+
//# sourceMappingURL=validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../../../src/register/RegistrationFields/UsernameField/validator.js"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,MAAM,CAAC,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AACxD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC;AAEnE,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;IAChD,IAAI,UAAU,GAAG,EAAE,CAAC;IACpB,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QACrD,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,6BAA6B,CAAC,CAAC,CAAC;IACtE,CAAC;SAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACtC,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,oCAAoC,CAAC,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import messages from '../../messages';\n\nexport const VALID_USERNAME_REGEX = /^[a-zA-Z0-9_-]*$/i;\nexport const usernameRegex = new RegExp(VALID_USERNAME_REGEX, 'i');\n\nconst validateUsername = (value, formatMessage) => {\n let fieldError = '';\n if (!value || value.length <= 1 || value.length > 30) {\n fieldError = formatMessage(messages['username.validation.message']);\n } else if (!usernameRegex.test(value)) {\n fieldError = formatMessage(messages['username.format.validation.message']);\n }\n return fieldError;\n};\n\nexport default validateUsername;\n"]}
|