@digitaldefiance/express-suite-react-components 5.0.2 → 5.0.4
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/package.json +5 -4
- package/src/auth/AdminRoute.d.ts +8 -0
- package/src/auth/AdminRoute.d.ts.map +1 -0
- package/src/auth/AdminRoute.js +28 -0
- package/src/auth/Private.d.ts +6 -0
- package/src/auth/Private.d.ts.map +1 -0
- package/src/auth/Private.js +14 -0
- package/src/auth/PrivateRoute.d.ts +8 -0
- package/src/auth/PrivateRoute.d.ts.map +1 -0
- package/src/auth/PrivateRoute.js +23 -0
- package/src/auth/UnAuth.d.ts +6 -0
- package/src/auth/UnAuth.d.ts.map +1 -0
- package/src/auth/UnAuth.js +14 -0
- package/src/auth/UnAuthRoute.d.ts +8 -0
- package/src/auth/UnAuthRoute.d.ts.map +1 -0
- package/src/auth/UnAuthRoute.js +22 -0
- package/src/auth/{index.ts → index.d.ts} +3 -2
- package/src/auth/index.d.ts.map +1 -0
- package/src/auth/index.js +12 -0
- package/src/components/ApiAccess.d.ts +16 -0
- package/src/components/ApiAccess.d.ts.map +1 -0
- package/src/components/ApiAccess.js +77 -0
- package/src/components/BackupCodeLoginForm.d.ts +43 -0
- package/src/components/BackupCodeLoginForm.d.ts.map +1 -0
- package/src/components/BackupCodeLoginForm.js +139 -0
- package/src/components/BackupCodesForm.d.ts +26 -0
- package/src/components/BackupCodesForm.d.ts.map +1 -0
- package/src/components/BackupCodesForm.js +120 -0
- package/src/components/CategoryMenu.d.ts +17 -0
- package/src/components/CategoryMenu.d.ts.map +1 -0
- package/src/components/CategoryMenu.js +65 -0
- package/src/components/ChangePasswordForm.d.ts +26 -0
- package/src/components/ChangePasswordForm.d.ts.map +1 -0
- package/src/components/ChangePasswordForm.js +78 -0
- package/src/components/ConfirmationDialog.d.ts +13 -0
- package/src/components/ConfirmationDialog.d.ts.map +1 -0
- package/src/components/ConfirmationDialog.js +10 -0
- package/src/components/CurrencyCodeSelector.d.ts +9 -0
- package/src/components/CurrencyCodeSelector.d.ts.map +1 -0
- package/src/components/CurrencyCodeSelector.js +31 -0
- package/src/components/CurrencyInput.d.ts +13 -0
- package/src/components/CurrencyInput.d.ts.map +1 -0
- package/src/components/CurrencyInput.js +22 -0
- package/src/components/DashboardPage.d.ts +8 -0
- package/src/components/DashboardPage.d.ts.map +1 -0
- package/src/components/DashboardPage.js +10 -0
- package/src/components/DropdownMenu.d.ts +13 -0
- package/src/components/DropdownMenu.d.ts.map +1 -0
- package/src/components/DropdownMenu.js +63 -0
- package/src/components/ExpirationSecondsSelector.d.ts +13 -0
- package/src/components/ExpirationSecondsSelector.d.ts.map +1 -0
- package/src/components/ExpirationSecondsSelector.js +32 -0
- package/src/components/FakeEmailAdminPanel.d.ts +23 -0
- package/src/components/FakeEmailAdminPanel.d.ts.map +1 -0
- package/src/components/FakeEmailAdminPanel.js +147 -0
- package/src/components/Flag.d.ts +20 -0
- package/src/components/Flag.d.ts.map +1 -0
- package/src/components/Flag.js +43 -0
- package/src/components/ForgotPasswordForm.d.ts +18 -0
- package/src/components/ForgotPasswordForm.d.ts.map +1 -0
- package/src/components/ForgotPasswordForm.js +61 -0
- package/src/components/LoginForm.d.ts +44 -0
- package/src/components/LoginForm.d.ts.map +1 -0
- package/src/components/LoginForm.js +123 -0
- package/src/components/LogoutPage.d.ts +8 -0
- package/src/components/LogoutPage.d.ts.map +1 -0
- package/src/components/LogoutPage.js +16 -0
- package/src/components/RegisterForm.d.ts +100 -0
- package/src/components/RegisterForm.d.ts.map +1 -0
- package/src/components/RegisterForm.js +306 -0
- package/src/components/ResetPasswordForm.d.ts +23 -0
- package/src/components/ResetPasswordForm.d.ts.map +1 -0
- package/src/components/ResetPasswordForm.js +78 -0
- package/src/components/SideMenu.d.ts +8 -0
- package/src/components/SideMenu.d.ts.map +1 -0
- package/src/components/SideMenu.js +25 -0
- package/src/components/SideMenuListItem.d.ts +13 -0
- package/src/components/SideMenuListItem.d.ts.map +1 -0
- package/src/components/SideMenuListItem.js +44 -0
- package/src/components/T.d.ts +7 -0
- package/src/components/T.d.ts.map +1 -0
- package/src/components/T.js +13 -0
- package/src/components/TDiv.d.ts +9 -0
- package/src/components/TDiv.d.ts.map +1 -0
- package/src/components/TDiv.js +14 -0
- package/src/components/TImgAlt.d.ts +10 -0
- package/src/components/TImgAlt.d.ts.map +1 -0
- package/src/components/TImgAlt.js +14 -0
- package/src/components/TopMenu.d.ts +50 -0
- package/src/components/TopMenu.d.ts.map +1 -0
- package/src/components/TopMenu.js +79 -0
- package/src/components/TotpSetupForm.d.ts +24 -0
- package/src/components/TotpSetupForm.d.ts.map +1 -0
- package/src/components/TotpSetupForm.js +82 -0
- package/src/components/TotpVerificationForm.d.ts +23 -0
- package/src/components/TotpVerificationForm.d.ts.map +1 -0
- package/src/components/TotpVerificationForm.js +66 -0
- package/src/components/TranslatedTitle.d.ts +8 -0
- package/src/components/TranslatedTitle.d.ts.map +1 -0
- package/src/components/TranslatedTitle.js +15 -0
- package/src/components/UserLanguageSelector.d.ts +4 -0
- package/src/components/UserLanguageSelector.d.ts.map +1 -0
- package/src/components/UserLanguageSelector.js +31 -0
- package/src/components/UserMenu.d.ts +4 -0
- package/src/components/UserMenu.d.ts.map +1 -0
- package/src/components/UserMenu.js +12 -0
- package/src/components/UserSettingsForm.d.ts +113 -0
- package/src/components/UserSettingsForm.d.ts.map +1 -0
- package/src/components/UserSettingsForm.js +269 -0
- package/src/components/VerifyEmailPage.d.ts +24 -0
- package/src/components/VerifyEmailPage.d.ts.map +1 -0
- package/src/components/VerifyEmailPage.js +81 -0
- package/src/components/{index.ts → index.d.ts} +1 -1
- package/src/components/index.d.ts.map +1 -0
- package/src/components/index.js +35 -0
- package/src/contexts/AuthProvider.d.ts +19 -0
- package/src/contexts/AuthProvider.d.ts.map +1 -0
- package/src/contexts/AuthProvider.js +514 -0
- package/src/contexts/I18nProvider.d.ts +27 -0
- package/src/contexts/I18nProvider.d.ts.map +1 -0
- package/src/contexts/I18nProvider.js +60 -0
- package/src/contexts/MenuContext.d.ts +28 -0
- package/src/contexts/MenuContext.d.ts.map +1 -0
- package/src/contexts/MenuContext.js +307 -0
- package/src/contexts/SuiteConfigProvider.d.ts +44 -0
- package/src/contexts/SuiteConfigProvider.d.ts.map +1 -0
- package/src/contexts/SuiteConfigProvider.js +43 -0
- package/src/contexts/ThemeProvider.d.ts +15 -0
- package/src/contexts/ThemeProvider.d.ts.map +1 -0
- package/src/contexts/ThemeProvider.js +36 -0
- package/src/contexts/auth-context.d.ts +172 -0
- package/src/contexts/auth-context.d.ts.map +1 -0
- package/src/contexts/auth-context.js +13 -0
- package/src/contexts/{index.ts → index.d.ts} +1 -0
- package/src/contexts/index.d.ts.map +1 -0
- package/src/contexts/index.js +8 -0
- package/src/hooks/{index.ts → index.d.ts} +1 -0
- package/src/hooks/index.d.ts.map +1 -0
- package/src/hooks/index.js +9 -0
- package/src/hooks/useAuthenticatedApi.d.ts +34 -0
- package/src/hooks/useAuthenticatedApi.d.ts.map +1 -0
- package/src/hooks/useAuthenticatedApi.js +46 -0
- package/src/hooks/useBackupCodes.d.ts +15 -0
- package/src/hooks/useBackupCodes.d.ts.map +1 -0
- package/src/hooks/useBackupCodes.js +74 -0
- package/src/hooks/useEmailVerification.d.ts +10 -0
- package/src/hooks/useEmailVerification.d.ts.map +1 -0
- package/src/hooks/useEmailVerification.js +40 -0
- package/src/hooks/useExpiringValue.d.ts +14 -0
- package/src/hooks/useExpiringValue.d.ts.map +1 -0
- package/src/hooks/useExpiringValue.js +53 -0
- package/src/hooks/useLocalStorage.d.ts +2 -0
- package/src/hooks/useLocalStorage.d.ts.map +1 -0
- package/src/hooks/useLocalStorage.js +15 -0
- package/src/hooks/useUserSettings.d.ts +48 -0
- package/src/hooks/useUserSettings.d.ts.map +1 -0
- package/src/hooks/useUserSettings.js +171 -0
- package/src/{index.ts → index.d.ts} +1 -1
- package/src/index.d.ts.map +1 -0
- package/src/index.js +12 -0
- package/src/interfaces/IAppConfig.d.ts +8 -0
- package/src/interfaces/IAppConfig.d.ts.map +1 -0
- package/src/interfaces/IAppConfig.js +2 -0
- package/src/interfaces/ICategoryConfig.d.ts +41 -0
- package/src/interfaces/ICategoryConfig.d.ts.map +1 -0
- package/src/interfaces/ICategoryConfig.js +2 -0
- package/src/interfaces/IMenuConfig.d.ts +28 -0
- package/src/interfaces/IMenuConfig.d.ts.map +1 -0
- package/src/interfaces/IMenuConfig.js +2 -0
- package/src/interfaces/IMenuOption.d.ts +82 -0
- package/src/interfaces/IMenuOption.d.ts.map +1 -0
- package/src/interfaces/IMenuOption.js +2 -0
- package/src/interfaces/{index.ts → index.d.ts} +1 -0
- package/src/interfaces/index.d.ts.map +1 -0
- package/src/interfaces/index.js +7 -0
- package/src/services/__mocks__/authService.d.ts +21 -0
- package/src/services/__mocks__/authService.d.ts.map +1 -0
- package/src/services/__mocks__/authService.js +15 -0
- package/src/services/api.d.ts +3 -0
- package/src/services/api.d.ts.map +1 -0
- package/src/services/api.js +14 -0
- package/src/services/authService.d.ts +126 -0
- package/src/services/authService.d.ts.map +1 -0
- package/src/services/authService.js +471 -0
- package/src/services/authenticatedApi.d.ts +3 -0
- package/src/services/authenticatedApi.d.ts.map +1 -0
- package/src/services/authenticatedApi.js +18 -0
- package/src/services/index.d.ts +4 -0
- package/src/services/index.d.ts.map +1 -0
- package/src/services/index.js +6 -0
- package/src/types/MenuType.d.ts +11 -0
- package/src/types/MenuType.d.ts.map +1 -0
- package/src/types/MenuType.js +12 -0
- package/src/types/expirationSeconds.d.ts +3 -0
- package/src/types/expirationSeconds.d.ts.map +1 -0
- package/src/types/expirationSeconds.js +17 -0
- package/src/types/index.d.ts +2 -0
- package/src/types/index.d.ts.map +1 -0
- package/src/types/index.js +4 -0
- package/src/types/translation.d.ts +10 -0
- package/src/types/translation.d.ts.map +1 -0
- package/src/types/translation.js +9 -0
- package/src/wrappers/BackupCodeLoginWrapper.d.ts +8 -0
- package/src/wrappers/BackupCodeLoginWrapper.d.ts.map +1 -0
- package/src/wrappers/BackupCodeLoginWrapper.js +20 -0
- package/src/wrappers/BackupCodesWrapper.d.ts +7 -0
- package/src/wrappers/BackupCodesWrapper.d.ts.map +1 -0
- package/src/wrappers/BackupCodesWrapper.js +17 -0
- package/src/wrappers/ChangePasswordFormWrapper.d.ts +8 -0
- package/src/wrappers/ChangePasswordFormWrapper.d.ts.map +1 -0
- package/src/wrappers/ChangePasswordFormWrapper.js +21 -0
- package/src/wrappers/ForgotPasswordFormWrapper.d.ts +8 -0
- package/src/wrappers/ForgotPasswordFormWrapper.d.ts.map +1 -0
- package/src/wrappers/ForgotPasswordFormWrapper.js +29 -0
- package/src/wrappers/LoginFormWrapper.d.ts +21 -0
- package/src/wrappers/LoginFormWrapper.d.ts.map +1 -0
- package/src/wrappers/LoginFormWrapper.js +72 -0
- package/src/wrappers/LogoutPageWrapper.d.ts +9 -0
- package/src/wrappers/LogoutPageWrapper.d.ts.map +1 -0
- package/src/wrappers/LogoutPageWrapper.js +21 -0
- package/src/wrappers/RegisterFormWrapper.d.ts +20 -0
- package/src/wrappers/RegisterFormWrapper.d.ts.map +1 -0
- package/src/wrappers/RegisterFormWrapper.js +51 -0
- package/src/wrappers/ResetPasswordFormWrapper.d.ts +9 -0
- package/src/wrappers/ResetPasswordFormWrapper.d.ts.map +1 -0
- package/src/wrappers/ResetPasswordFormWrapper.js +34 -0
- package/src/wrappers/UserSettingsFormWrapper.d.ts +29 -0
- package/src/wrappers/UserSettingsFormWrapper.d.ts.map +1 -0
- package/src/wrappers/UserSettingsFormWrapper.js +95 -0
- package/src/wrappers/VerifyEmailPageWrapper.d.ts +8 -0
- package/src/wrappers/VerifyEmailPageWrapper.d.ts.map +1 -0
- package/src/wrappers/VerifyEmailPageWrapper.js +21 -0
- package/src/wrappers/{index.tsx → index.d.ts} +1 -10
- package/src/wrappers/index.d.ts.map +1 -0
- package/src/wrappers/index.js +24 -0
- package/LICENSE +0 -21
- package/src/auth/AdminRoute.tsx +0 -54
- package/src/auth/Private.tsx +0 -17
- package/src/auth/PrivateRoute.tsx +0 -28
- package/src/auth/UnAuth.tsx +0 -16
- package/src/auth/UnAuthRoute.tsx +0 -30
- package/src/components/ApiAccess.tsx +0 -175
- package/src/components/BackupCodeLoginForm.tsx +0 -489
- package/src/components/BackupCodesForm.tsx +0 -287
- package/src/components/CategoryMenu.tsx +0 -155
- package/src/components/ChangePasswordForm.tsx +0 -273
- package/src/components/ConfirmationDialog.tsx +0 -48
- package/src/components/CurrencyCodeSelector.tsx +0 -60
- package/src/components/CurrencyInput.tsx +0 -80
- package/src/components/DashboardPage.tsx +0 -24
- package/src/components/DropdownMenu.tsx +0 -105
- package/src/components/ExpirationSecondsSelector.tsx +0 -60
- package/src/components/FakeEmailAdminPanel.tsx +0 -374
- package/src/components/Flag.tsx +0 -52
- package/src/components/ForgotPasswordForm.tsx +0 -174
- package/src/components/LoginForm.tsx +0 -468
- package/src/components/LogoutPage.tsx +0 -21
- package/src/components/RegisterForm.tsx +0 -1169
- package/src/components/ResetPasswordForm.tsx +0 -247
- package/src/components/SideMenu.tsx +0 -46
- package/src/components/SideMenuListItem.tsx +0 -75
- package/src/components/T.tsx +0 -24
- package/src/components/TDiv.tsx +0 -26
- package/src/components/TImgAlt.tsx +0 -28
- package/src/components/TopMenu.tsx +0 -252
- package/src/components/TotpSetupForm.tsx +0 -188
- package/src/components/TotpVerificationForm.tsx +0 -148
- package/src/components/TranslatedTitle.tsx +0 -31
- package/src/components/UserLanguageSelector.tsx +0 -45
- package/src/components/UserMenu.tsx +0 -15
- package/src/components/UserSettingsForm.tsx +0 -904
- package/src/components/VerifyEmailPage.tsx +0 -222
- package/src/components/__tests__/RegisterForm.totp.spec.tsx +0 -377
- package/src/components/__tests__/TotpSetupForm.spec.tsx +0 -258
- package/src/components/__tests__/TotpVerificationForm.spec.tsx +0 -259
- package/src/components/__tests__/UserSettingsForm.totp.spec.tsx +0 -396
- package/src/contexts/AuthProvider.spec.tsx +0 -1284
- package/src/contexts/AuthProvider.tsx +0 -977
- package/src/contexts/I18nProvider.tsx +0 -164
- package/src/contexts/MenuContext.tsx +0 -426
- package/src/contexts/SuiteConfigProvider.tsx +0 -93
- package/src/contexts/ThemeProvider.tsx +0 -67
- package/src/hooks/useAuthenticatedApi.tsx +0 -67
- package/src/hooks/useBackupCodes.ts +0 -105
- package/src/hooks/useEmailVerification.ts +0 -54
- package/src/hooks/useExpiringValue.ts +0 -78
- package/src/hooks/useLocalStorage.ts +0 -18
- package/src/hooks/useUserSettings.ts +0 -271
- package/src/interfaces/IAppConfig.ts +0 -7
- package/src/interfaces/ICategoryConfig.ts +0 -41
- package/src/interfaces/IMenuConfig.ts +0 -28
- package/src/interfaces/IMenuOption.ts +0 -79
- package/src/services/__mocks__/authService.ts +0 -14
- package/src/services/__tests__/authService.totp.property.spec.ts +0 -360
- package/src/services/__tests__/authService.totp.spec.ts +0 -439
- package/src/services/api.ts +0 -13
- package/src/services/authService.ts +0 -692
- package/src/services/authenticatedApi.ts +0 -17
- package/src/services/index.ts +0 -3
- package/src/types/MenuType.ts +0 -15
- package/src/types/expirationSeconds.ts +0 -18
- package/src/types/index.ts +0 -1
- package/src/types/translation.ts +0 -20
- package/src/wrappers/BackupCodeLoginWrapper.tsx +0 -34
- package/src/wrappers/BackupCodesWrapper.tsx +0 -28
- package/src/wrappers/ChangePasswordFormWrapper.tsx +0 -34
- package/src/wrappers/ForgotPasswordFormWrapper.tsx +0 -45
- package/src/wrappers/LoginFormWrapper.tsx +0 -108
- package/src/wrappers/LogoutPageWrapper.tsx +0 -30
- package/src/wrappers/RegisterFormWrapper.tsx +0 -109
- package/src/wrappers/ResetPasswordFormWrapper.tsx +0 -57
- package/src/wrappers/UserSettingsFormWrapper.tsx +0 -140
- package/src/wrappers/VerifyEmailPageWrapper.tsx +0 -27
- package/src/wrappers/__tests__/LoginFormWrapper.totp.spec.tsx +0 -339
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RegisterForm = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
7
|
+
const material_1 = require("@mui/material");
|
|
8
|
+
const formik_1 = require("formik");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const Yup = tslib_1.__importStar(require("yup"));
|
|
11
|
+
const bip39_1 = require("bip39");
|
|
12
|
+
const contexts_1 = require("../contexts");
|
|
13
|
+
const TotpSetupForm_1 = require("./TotpSetupForm");
|
|
14
|
+
const RegisterForm = ({ onSubmit, timezones, getInitialTimezone, usernameValidation, emailValidation, displayNameValidation, timezoneValidation, passwordValidation, confirmPasswordValidation, enableTotpSetup = false, onTotpSetup, onTotpConfirm, onTotpSetupComplete, disallowedEmailDomains, additionalFields, additionalInitialValues = {}, additionalValidation = {}, labels = {}, }) => {
|
|
15
|
+
const { tComponent } = (0, contexts_1.useI18n)();
|
|
16
|
+
const [apiErrors, setApiErrors] = (0, react_1.useState)({});
|
|
17
|
+
const [mnemonic, setMnemonic] = (0, react_1.useState)(null);
|
|
18
|
+
const [usePassword, setUsePassword] = (0, react_1.useState)(true);
|
|
19
|
+
const [registrationSuccess, setRegistrationSuccess] = (0, react_1.useState)(false);
|
|
20
|
+
const [registering, setRegistering] = (0, react_1.useState)(false);
|
|
21
|
+
const [showMnemonicInput, setShowMnemonicInput] = (0, react_1.useState)(false);
|
|
22
|
+
const [autoMnemonic, setAutoMnemonic] = (0, react_1.useState)(() => (0, bip39_1.generateMnemonic)(256));
|
|
23
|
+
const [showTotpSetup, setShowTotpSetup] = (0, react_1.useState)(false);
|
|
24
|
+
const [totpProvisioningUri, setTotpProvisioningUri] = (0, react_1.useState)(null);
|
|
25
|
+
const [totpSecret, setTotpSecret] = (0, react_1.useState)(null);
|
|
26
|
+
const [totpSetupError, setTotpSetupError] = (0, react_1.useState)(null);
|
|
27
|
+
const [totpSetupComplete, setTotpSetupComplete] = (0, react_1.useState)(false);
|
|
28
|
+
const [totpSetupLoading, setTotpSetupLoading] = (0, react_1.useState)(false);
|
|
29
|
+
const initiateTotpSetup = (0, react_1.useCallback)(async () => {
|
|
30
|
+
if (!onTotpSetup)
|
|
31
|
+
return;
|
|
32
|
+
setTotpSetupLoading(true);
|
|
33
|
+
setTotpSetupError(null);
|
|
34
|
+
try {
|
|
35
|
+
const result = await onTotpSetup();
|
|
36
|
+
if ('error' in result) {
|
|
37
|
+
setTotpSetupError(result.error);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
setTotpProvisioningUri(result.provisioningUri);
|
|
41
|
+
setTotpSecret(result.secret);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
setTotpSetupError(labels.totpSetupError || 'Failed to set up two-factor authentication');
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
setTotpSetupLoading(false);
|
|
49
|
+
}
|
|
50
|
+
}, [onTotpSetup, labels.totpSetupError]);
|
|
51
|
+
const handleTotpConfirm = (0, react_1.useCallback)(async (code) => {
|
|
52
|
+
if (!onTotpConfirm) {
|
|
53
|
+
return { error: 'TOTP confirmation is not available' };
|
|
54
|
+
}
|
|
55
|
+
const result = await onTotpConfirm(code);
|
|
56
|
+
if ('success' in result && result.success) {
|
|
57
|
+
setTotpSetupComplete(true);
|
|
58
|
+
setShowTotpSetup(false);
|
|
59
|
+
if (onTotpSetupComplete) {
|
|
60
|
+
onTotpSetupComplete();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}, [onTotpConfirm, onTotpSetupComplete]);
|
|
65
|
+
const handleSkipTotp = (0, react_1.useCallback)(() => {
|
|
66
|
+
setShowTotpSetup(false);
|
|
67
|
+
}, []);
|
|
68
|
+
const validation = {
|
|
69
|
+
username: usernameValidation ||
|
|
70
|
+
Yup.string()
|
|
71
|
+
.min(suite_core_lib_1.Constants.UsernameMinLength, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_UsernameMinLengthTemplate))
|
|
72
|
+
.max(suite_core_lib_1.Constants.UsernameMaxLength, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_UsernameMaxLengthTemplate))
|
|
73
|
+
.matches(suite_core_lib_1.Constants.UsernameRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_UsernameRegexErrorTemplate))
|
|
74
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
75
|
+
email: emailValidation ||
|
|
76
|
+
Yup.string()
|
|
77
|
+
.email(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidEmail))
|
|
78
|
+
.test('disallowed-domain', '', function (value) {
|
|
79
|
+
if (!value || !disallowedEmailDomains?.length)
|
|
80
|
+
return true;
|
|
81
|
+
const atIndex = value.lastIndexOf('@');
|
|
82
|
+
if (atIndex <= 0)
|
|
83
|
+
return true;
|
|
84
|
+
const domain = value.slice(atIndex + 1).toLowerCase();
|
|
85
|
+
const blocked = disallowedEmailDomains.find((d) => d.toLowerCase() === domain);
|
|
86
|
+
if (!blocked)
|
|
87
|
+
return true;
|
|
88
|
+
return this.createError({
|
|
89
|
+
message: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_EmailDomainNotAllowedTemplate, { domain: blocked }),
|
|
90
|
+
});
|
|
91
|
+
})
|
|
92
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
93
|
+
displayName: !suite_core_lib_1.Constants.EnableDisplayName
|
|
94
|
+
? Yup.string().strip()
|
|
95
|
+
: displayNameValidation ||
|
|
96
|
+
Yup.string()
|
|
97
|
+
.min(suite_core_lib_1.Constants.DisplayNameMinLength, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_DisplayNameMinLengthTemplate))
|
|
98
|
+
.max(suite_core_lib_1.Constants.DisplayNameMaxLength, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_DisplayNameMaxLengthTemplate))
|
|
99
|
+
.matches(suite_core_lib_1.Constants.DisplayNameRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_DisplayNameRegexErrorTemplate))
|
|
100
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
101
|
+
directChallenge: Yup.boolean(),
|
|
102
|
+
timezone: timezoneValidation ||
|
|
103
|
+
Yup.string()
|
|
104
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_TimezoneRequired))
|
|
105
|
+
.oneOf(timezones, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_TimezoneInvalid)),
|
|
106
|
+
password: passwordValidation ||
|
|
107
|
+
Yup.string()
|
|
108
|
+
.matches(suite_core_lib_1.Constants.PasswordRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordRegexErrorTemplate))
|
|
109
|
+
.min(8, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordMinLengthTemplate))
|
|
110
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
111
|
+
confirmPassword: confirmPasswordValidation ||
|
|
112
|
+
Yup.string()
|
|
113
|
+
.oneOf([Yup.ref('password')], tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordMatch))
|
|
114
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
115
|
+
mnemonic: Yup.string()
|
|
116
|
+
.optional()
|
|
117
|
+
.test('mnemonic-format', tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_MnemonicRegex), (value) => {
|
|
118
|
+
if (!value || value.trim() === '')
|
|
119
|
+
return true;
|
|
120
|
+
return suite_core_lib_1.Constants.MnemonicRegex.test(value.trim());
|
|
121
|
+
}),
|
|
122
|
+
};
|
|
123
|
+
const formik = (0, formik_1.useFormik)({
|
|
124
|
+
initialValues: {
|
|
125
|
+
username: '',
|
|
126
|
+
email: '',
|
|
127
|
+
...(suite_core_lib_1.Constants.EnableDisplayName ? { displayName: '' } : {}),
|
|
128
|
+
timezone: getInitialTimezone(),
|
|
129
|
+
password: '',
|
|
130
|
+
confirmPassword: '',
|
|
131
|
+
directChallenge: false,
|
|
132
|
+
mnemonic: '',
|
|
133
|
+
...additionalInitialValues,
|
|
134
|
+
},
|
|
135
|
+
enableReinitialize: true,
|
|
136
|
+
validationSchema: Yup.object({
|
|
137
|
+
username: validation.username,
|
|
138
|
+
email: validation.email,
|
|
139
|
+
...(suite_core_lib_1.Constants.EnableDisplayName
|
|
140
|
+
? { displayName: validation.displayName }
|
|
141
|
+
: {}),
|
|
142
|
+
timezone: validation.timezone,
|
|
143
|
+
...(usePassword
|
|
144
|
+
? {
|
|
145
|
+
password: validation.password,
|
|
146
|
+
confirmPassword: validation.confirmPassword,
|
|
147
|
+
}
|
|
148
|
+
: {}),
|
|
149
|
+
...(showMnemonicInput ? { mnemonic: validation.mnemonic } : {}),
|
|
150
|
+
...additionalValidation,
|
|
151
|
+
}),
|
|
152
|
+
onSubmit: async (values, { setSubmitting, setFieldError, setTouched }) => {
|
|
153
|
+
setRegistering(true);
|
|
154
|
+
setApiErrors({});
|
|
155
|
+
try {
|
|
156
|
+
const effectiveMnemonic = !showMnemonicInput
|
|
157
|
+
? autoMnemonic
|
|
158
|
+
: (values.mnemonic?.trim() || autoMnemonic);
|
|
159
|
+
const registerResult = await onSubmit({ ...values, mnemonic: effectiveMnemonic }, usePassword);
|
|
160
|
+
if ('success' in registerResult && registerResult.success) {
|
|
161
|
+
setRegistrationSuccess(true);
|
|
162
|
+
if (registerResult.mnemonic) {
|
|
163
|
+
setMnemonic(registerResult.mnemonic);
|
|
164
|
+
}
|
|
165
|
+
if (enableTotpSetup && onTotpSetup) {
|
|
166
|
+
setShowTotpSetup(true);
|
|
167
|
+
// Fire-and-forget: initiate TOTP setup in background
|
|
168
|
+
// The setup state is managed by initiateTotpSetup
|
|
169
|
+
initiateTotpSetup();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
setRegistrationSuccess(false);
|
|
174
|
+
const newApiErrors = {};
|
|
175
|
+
const fieldsToTouch = {};
|
|
176
|
+
if ('field' in registerResult && registerResult.field) {
|
|
177
|
+
setFieldError(registerResult.field, registerResult.error);
|
|
178
|
+
fieldsToTouch[registerResult.field] = true;
|
|
179
|
+
}
|
|
180
|
+
if ('errors' in registerResult && registerResult.errors) {
|
|
181
|
+
registerResult.errors.forEach((err) => {
|
|
182
|
+
if (err.path && err.msg) {
|
|
183
|
+
setFieldError(err.path, err.msg);
|
|
184
|
+
fieldsToTouch[err.path] = true;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
if ('error' in registerResult &&
|
|
189
|
+
registerResult.error &&
|
|
190
|
+
!Object.keys(newApiErrors).length) {
|
|
191
|
+
newApiErrors.general = registerResult.error;
|
|
192
|
+
}
|
|
193
|
+
setApiErrors(newApiErrors);
|
|
194
|
+
setTouched(fieldsToTouch, false);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
catch (err) {
|
|
198
|
+
console.error('[RegisterForm] onSubmit error:', err);
|
|
199
|
+
setApiErrors({
|
|
200
|
+
general: err instanceof Error ? err.message : String(err),
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
setSubmitting(false);
|
|
204
|
+
setRegistering(false);
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Container, { maxWidth: "sm", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
208
|
+
mt: 8,
|
|
209
|
+
display: 'flex',
|
|
210
|
+
flexDirection: 'column',
|
|
211
|
+
alignItems: 'center',
|
|
212
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: labels.title ||
|
|
213
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Registration) }), mnemonic || registrationSuccess ? ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { mt: 2, width: '100%' }, children: showTotpSetup && !totpSetupComplete ? ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", component: "h2", gutterBottom: true, fontWeight: "bold", sx: { textAlign: 'center' }, children: labels.totpSetupTitle || 'Set Up Two-Factor Authentication' }), totpSetupLoading && ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", sx: { textAlign: 'center', mt: 2 }, children: "Loading TOTP setup..." })), totpSetupError && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: totpSetupError })), totpProvisioningUri && totpSecret && ((0, jsx_runtime_1.jsx)(TotpSetupForm_1.TotpSetupForm, { provisioningUri: totpProvisioningUri, secret: totpSecret, onConfirm: handleTotpConfirm })), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center', mt: 2 }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "text", onClick: handleSkipTotp, "data-testid": "skip-totp-button", children: labels.totpSkipButton || 'Skip' }) })] })) : totpSetupComplete ? ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: labels.totpSetupSuccess ||
|
|
214
|
+
'Two-factor authentication has been enabled successfully.' }), mnemonic ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { textAlign: 'center', mb: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", component: "h2", gutterBottom: true, fontWeight: "bold", children: labels.successTitle ||
|
|
215
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: labels.mnemonicSuccess ||
|
|
216
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_MnemonicSuccess) })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
217
|
+
display: 'grid',
|
|
218
|
+
gridTemplateColumns: 'repeat(3, 1fr)',
|
|
219
|
+
gap: 1.5,
|
|
220
|
+
mb: 3,
|
|
221
|
+
}, children: mnemonic.split(/\s+/).map((word, i) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
222
|
+
display: 'flex',
|
|
223
|
+
alignItems: 'center',
|
|
224
|
+
justifyContent: 'center',
|
|
225
|
+
gap: 0.5,
|
|
226
|
+
py: 1,
|
|
227
|
+
px: 1.5,
|
|
228
|
+
borderRadius: 2,
|
|
229
|
+
border: '1px solid',
|
|
230
|
+
borderColor: 'divider',
|
|
231
|
+
bgcolor: 'action.hover',
|
|
232
|
+
}, children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "caption", color: "text.secondary", sx: { minWidth: '1.5em', textAlign: 'right' }, children: [i + 1, "."] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", fontWeight: "bold", children: word })] }, i))) }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center' }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", color: "primary", size: "large", href: "/verify-email", sx: { borderRadius: 6, px: 4 }, children: labels.savedRecoveryPhrase ||
|
|
233
|
+
labels.proceedToLogin ||
|
|
234
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SavedRecoveryPhrase) }) }), (0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "success", sx: { mt: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", component: "div", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Success) })] })] })) : ((0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: labels.successTitle ||
|
|
235
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", component: "div", children: [tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Success), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center', mt: 1 }, children: (0, jsx_runtime_1.jsx)(material_1.Link, { href: "/login", children: labels.proceedToLogin ||
|
|
236
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ProceedToLogin) }) })] })] }))] })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: mnemonic ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { textAlign: 'center', mb: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", component: "h2", gutterBottom: true, fontWeight: "bold", children: labels.successTitle ||
|
|
237
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: labels.mnemonicSuccess ||
|
|
238
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_MnemonicSuccess) })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
239
|
+
display: 'grid',
|
|
240
|
+
gridTemplateColumns: 'repeat(3, 1fr)',
|
|
241
|
+
gap: 1.5,
|
|
242
|
+
mb: 3,
|
|
243
|
+
}, children: mnemonic.split(/\s+/).map((word, i) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
244
|
+
display: 'flex',
|
|
245
|
+
alignItems: 'center',
|
|
246
|
+
justifyContent: 'center',
|
|
247
|
+
gap: 0.5,
|
|
248
|
+
py: 1,
|
|
249
|
+
px: 1.5,
|
|
250
|
+
borderRadius: 2,
|
|
251
|
+
border: '1px solid',
|
|
252
|
+
borderColor: 'divider',
|
|
253
|
+
bgcolor: 'action.hover',
|
|
254
|
+
}, children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "caption", color: "text.secondary", sx: { minWidth: '1.5em', textAlign: 'right' }, children: [i + 1, "."] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", fontWeight: "bold", children: word })] }, i))) }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center' }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", color: "primary", size: "large", href: "/verify-email", sx: { borderRadius: 6, px: 4 }, children: labels.savedRecoveryPhrase ||
|
|
255
|
+
labels.proceedToLogin ||
|
|
256
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SavedRecoveryPhrase) }) }), (0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "success", sx: { mt: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", component: "div", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Success) })] })] })) : ((0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: labels.successTitle ||
|
|
257
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", component: "div", children: [tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Success), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center', mt: 1 }, children: (0, jsx_runtime_1.jsx)(material_1.Link, { href: "/login", children: labels.proceedToLogin ||
|
|
258
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ProceedToLogin) }) })] })] })) })) })) : ((0, jsx_runtime_1.jsxs)(material_1.Box, { component: "form", onSubmit: formik.handleSubmit, sx: { mt: 1, width: '100%' }, children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "username", name: "username", label: labels.username ||
|
|
259
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Username), value: formik.values.username, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.username &&
|
|
260
|
+
(formik.errors.username || apiErrors.username)), helperText: formik.touched.username &&
|
|
261
|
+
(formik.errors.username || apiErrors.username), margin: "normal" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "email", name: "email", label: labels.email ||
|
|
262
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Email), value: formik.values.email, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.email && (formik.errors.email || apiErrors.email)), helperText: formik.touched.email && (formik.errors.email || apiErrors.email), margin: "normal" }), suite_core_lib_1.Constants.EnableDisplayName && ((0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "displayName", name: "displayName", label: labels.displayName ||
|
|
263
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_DisplayName), value: formik.values.displayName, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.displayName &&
|
|
264
|
+
(formik.errors.displayName || apiErrors.displayName)), helperText: formik.touched.displayName &&
|
|
265
|
+
(formik.errors.displayName || apiErrors.displayName), margin: "normal" })), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: "timezone-label", children: labels.timezone ||
|
|
266
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Timezone) }), (0, jsx_runtime_1.jsx)(material_1.Select, { labelId: "timezone-label", id: "timezone", name: "timezone", value: formik.values.timezone, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.timezone && Boolean(formik.errors.timezone), label: labels.timezone ||
|
|
267
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Timezone), children: timezones.map((tz) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: tz, children: tz }, tz))) }), formik.touched.timezone &&
|
|
268
|
+
(formik.errors.timezone || apiErrors.timezone) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", variant: "caption", children: formik.errors.timezone || apiErrors.timezone }))] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { display: 'flex', alignItems: 'center', mt: 2 }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "text", onClick: () => setUsePassword(!usePassword), children: usePassword
|
|
269
|
+
? labels.useMnemonic ||
|
|
270
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_UseMnemonic)
|
|
271
|
+
: labels.usePassword ||
|
|
272
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_UsePassword) }) }), usePassword && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "password", name: "password", label: labels.password ||
|
|
273
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Password), type: "password", value: formik.values.password, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.password && formik.errors.password), helperText: formik.touched.password && formik.errors.password, margin: "normal" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "confirmPassword", name: "confirmPassword", label: labels.confirmPassword ||
|
|
274
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_ConfirmNewPassword), type: "password", value: formik.values.confirmPassword, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.confirmPassword &&
|
|
275
|
+
formik.errors.confirmPassword), helperText: formik.touched.confirmPassword &&
|
|
276
|
+
formik.errors.confirmPassword, margin: "normal" }), (0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "info", sx: { mt: 1 }, children: labels?.passwordAuthInfo ||
|
|
277
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_PasswordAuthInfo) })] })), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { id: "directChallenge", name: "directChallenge", checked: formik.values.directChallenge || false, onChange: formik.handleChange }), label: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_DirectChallengeLabel) }), (0, jsx_runtime_1.jsx)(material_1.FormHelperText, { children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_DirectChallengeHelper) })] }), additionalFields && additionalFields(formik, usePassword), !showMnemonicInput && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle2", gutterBottom: true, children: labels.mnemonic || 'Your Recovery Phrase — save this before registering' }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
278
|
+
display: 'grid',
|
|
279
|
+
gridTemplateColumns: 'repeat(3, 1fr)',
|
|
280
|
+
gap: 1,
|
|
281
|
+
mb: 1,
|
|
282
|
+
}, children: autoMnemonic.split(/\s+/).map((word, i) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
283
|
+
display: 'flex',
|
|
284
|
+
alignItems: 'center',
|
|
285
|
+
gap: 0.5,
|
|
286
|
+
py: 0.5,
|
|
287
|
+
px: 1,
|
|
288
|
+
borderRadius: 1,
|
|
289
|
+
border: '1px solid',
|
|
290
|
+
borderColor: 'divider',
|
|
291
|
+
bgcolor: 'action.hover',
|
|
292
|
+
}, children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "caption", color: "text.secondary", sx: { minWidth: '1.5em', textAlign: 'right' }, children: [i + 1, "."] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", fontWeight: "bold", children: word })] }, i))) }), (0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "warning", sx: { mb: 1 }, children: "Write down these words in order. You will need them to recover your account." }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "text", size: "small", onClick: () => setAutoMnemonic((0, bip39_1.generateMnemonic)(256)), children: "Regenerate" })] })), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { mt: 1 }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "text", size: "small", onClick: () => setShowMnemonicInput(!showMnemonicInput), "aria-expanded": showMnemonicInput, "aria-controls": "mnemonic-input", children: showMnemonicInput
|
|
293
|
+
? tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_ClearMnemonic)
|
|
294
|
+
: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Mnemonic) }) }), showMnemonicInput && ((0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "mnemonic-input", name: "mnemonic", label: labels.mnemonic ||
|
|
295
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Mnemonic), value: formik.values.mnemonic, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.mnemonic &&
|
|
296
|
+
(formik.errors.mnemonic || apiErrors.mnemonic)), helperText: formik.touched.mnemonic &&
|
|
297
|
+
(formik.errors.mnemonic || apiErrors.mnemonic), margin: "normal", multiline: true, minRows: 2 })), apiErrors.general && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: apiErrors.general })), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", color: "primary", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: registering
|
|
298
|
+
? labels.registering ||
|
|
299
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Registering)
|
|
300
|
+
: labels.register ||
|
|
301
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_RegisterButton) }), registering && ((0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2, whiteSpace: 'pre-wrap' }, children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: labels.registering ||
|
|
302
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Registering) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", component: "div", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_RegisteringMessage) })] })), !registrationSuccess && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center' }, children: (0, jsx_runtime_1.jsx)(material_1.Link, { href: "/login", variant: "body2", children: labels.loginLink ||
|
|
303
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_LoginLink) }) }))] }))] }) }));
|
|
304
|
+
};
|
|
305
|
+
exports.RegisterForm = RegisterForm;
|
|
306
|
+
exports.default = exports.RegisterForm;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import * as Yup from 'yup';
|
|
3
|
+
export interface ResetPasswordFormValues {
|
|
4
|
+
password: string;
|
|
5
|
+
confirmPassword: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ResetPasswordFormProps {
|
|
8
|
+
token: string | null;
|
|
9
|
+
onSubmit: (token: string, password: string) => Promise<void>;
|
|
10
|
+
passwordValidation?: Yup.StringSchema;
|
|
11
|
+
confirmPasswordValidation?: Yup.StringSchema;
|
|
12
|
+
labels?: {
|
|
13
|
+
title?: string;
|
|
14
|
+
password?: string;
|
|
15
|
+
confirmPassword?: string;
|
|
16
|
+
resetButton?: string;
|
|
17
|
+
successMessage?: string;
|
|
18
|
+
invalidToken?: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export declare const ResetPasswordForm: FC<ResetPasswordFormProps>;
|
|
22
|
+
export default ResetPasswordForm;
|
|
23
|
+
//# sourceMappingURL=ResetPasswordForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResetPasswordForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/ResetPasswordForm.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAG3B,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,yBAAyB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IAC7C,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED,eAAO,MAAM,iBAAiB,EAAE,EAAE,CAAC,sBAAsB,CA6MxD,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResetPasswordForm = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
7
|
+
const material_1 = require("@mui/material");
|
|
8
|
+
const formik_1 = require("formik");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const Yup = tslib_1.__importStar(require("yup"));
|
|
11
|
+
const contexts_1 = require("../contexts");
|
|
12
|
+
const ResetPasswordForm = ({ token, onSubmit, passwordValidation, confirmPasswordValidation, labels = {}, }) => {
|
|
13
|
+
const { tComponent } = (0, contexts_1.useI18n)();
|
|
14
|
+
const [success, setSuccess] = (0, react_1.useState)(false);
|
|
15
|
+
const [apiError, setApiError] = (0, react_1.useState)('');
|
|
16
|
+
const validation = {
|
|
17
|
+
password: passwordValidation ||
|
|
18
|
+
Yup.string()
|
|
19
|
+
.min(suite_core_lib_1.Constants.PasswordMinLength, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordMinLengthTemplate))
|
|
20
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
21
|
+
confirmPassword: confirmPasswordValidation ||
|
|
22
|
+
Yup.string()
|
|
23
|
+
.oneOf([Yup.ref('password')], tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordMatch))
|
|
24
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
25
|
+
};
|
|
26
|
+
const translatedLabels = {
|
|
27
|
+
title: labels.title ||
|
|
28
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.PasswordReset_Title),
|
|
29
|
+
password: labels.password ||
|
|
30
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_NewPassword),
|
|
31
|
+
confirmPassword: labels.confirmPassword ||
|
|
32
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_ConfirmNewPassword),
|
|
33
|
+
resetButton: labels.resetButton ||
|
|
34
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.PasswordReset_Button),
|
|
35
|
+
successMessage: labels.successMessage ||
|
|
36
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.PasswordReset_Success),
|
|
37
|
+
invalidToken: labels.invalidToken ||
|
|
38
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ForgotPassword_InvalidToken),
|
|
39
|
+
};
|
|
40
|
+
const formik = (0, formik_1.useFormik)({
|
|
41
|
+
initialValues: {
|
|
42
|
+
password: '',
|
|
43
|
+
confirmPassword: '',
|
|
44
|
+
},
|
|
45
|
+
validationSchema: Yup.object({
|
|
46
|
+
password: validation.password,
|
|
47
|
+
confirmPassword: validation.confirmPassword,
|
|
48
|
+
}),
|
|
49
|
+
onSubmit: async (values) => {
|
|
50
|
+
if (!token) {
|
|
51
|
+
setApiError(translatedLabels.invalidToken);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
await onSubmit(token, values.password);
|
|
56
|
+
setSuccess(true);
|
|
57
|
+
setApiError('');
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
const err = error;
|
|
61
|
+
setApiError(err.response?.data?.message ||
|
|
62
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Error_PasswordChange));
|
|
63
|
+
setSuccess(false);
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
if (!token) {
|
|
68
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Container, { maxWidth: "sm", children: (0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 4 }, children: translatedLabels.invalidToken }) }));
|
|
69
|
+
}
|
|
70
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Container, { maxWidth: "sm", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
71
|
+
mt: 8,
|
|
72
|
+
display: 'flex',
|
|
73
|
+
flexDirection: 'column',
|
|
74
|
+
alignItems: 'center',
|
|
75
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: translatedLabels.title }), (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "form", onSubmit: formik.handleSubmit, sx: { mt: 1, width: '100%' }, children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "password", name: "password", label: translatedLabels.password, type: "password", value: formik.values.password, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.password && formik.errors.password), helperText: formik.touched.password && formik.errors.password, margin: "normal" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "confirmPassword", name: "confirmPassword", label: translatedLabels.confirmPassword, type: "password", value: formik.values.confirmPassword, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.confirmPassword && formik.errors.confirmPassword), helperText: formik.touched.confirmPassword && formik.errors.confirmPassword, margin: "normal" }), apiError && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: apiError })), success && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: translatedLabels.successMessage })), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", color: "primary", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: translatedLabels.resetButton })] })] }) }));
|
|
76
|
+
};
|
|
77
|
+
exports.ResetPasswordForm = ResetPasswordForm;
|
|
78
|
+
exports.default = exports.ResetPasswordForm;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SideMenu.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/SideMenu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAO3B,UAAU,aAAa;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CA8BtC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SideMenu = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const material_1 = require("@mui/material");
|
|
6
|
+
const react_router_1 = require("react-router");
|
|
7
|
+
const MenuContext_1 = require("../contexts/MenuContext");
|
|
8
|
+
const MenuType_1 = require("../types/MenuType");
|
|
9
|
+
const SideMenuListItem_1 = require("./SideMenuListItem");
|
|
10
|
+
const SideMenu = ({ isOpen, onClose }) => {
|
|
11
|
+
const { getMenuOptions } = (0, MenuContext_1.useMenu)();
|
|
12
|
+
const navigate = (0, react_router_1.useNavigate)();
|
|
13
|
+
const menuOptions = getMenuOptions(MenuType_1.MenuTypes.SideMenu, true);
|
|
14
|
+
const handleNavigate = (link) => {
|
|
15
|
+
if (typeof link === 'string') {
|
|
16
|
+
navigate(link);
|
|
17
|
+
}
|
|
18
|
+
else if (link.pathname) {
|
|
19
|
+
navigate(link.pathname, { state: link.state });
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Drawer, { anchor: "left", open: isOpen, onClose: onClose, children: (0, jsx_runtime_1.jsx)(material_1.List, { children: menuOptions.map((item) => ((0, jsx_runtime_1.jsx)(SideMenuListItem_1.SideMenuListItem, { menuItem: item, onClose: onClose, onNavigate: handleNavigate }, item.id))) }) }));
|
|
23
|
+
};
|
|
24
|
+
exports.SideMenu = SideMenu;
|
|
25
|
+
exports.default = exports.SideMenu;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { IMenuOption } from '../interfaces';
|
|
3
|
+
export interface SideMenuListItemProps {
|
|
4
|
+
menuItem: IMenuOption;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
onNavigate?: (link: string | Partial<{
|
|
7
|
+
pathname: string;
|
|
8
|
+
state?: unknown;
|
|
9
|
+
}>) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const SideMenuListItem: FC<SideMenuListItemProps>;
|
|
12
|
+
export default SideMenuListItem;
|
|
13
|
+
//# sourceMappingURL=SideMenuListItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SideMenuListItem.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/SideMenuListItem.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,EAAE,EAAe,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,WAAW,CAAC;IACtB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,CAAC,EAAE,CACX,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,KAC1D,IAAI,CAAC;CACX;AAED,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAuDtD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SideMenuListItem = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const material_1 = require("@mui/material");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const SideMenuListItem = ({ menuItem, onClose, onNavigate, }) => {
|
|
8
|
+
const handleMenuItemClick = (0, react_1.useCallback)((option) => (event) => {
|
|
9
|
+
event.stopPropagation();
|
|
10
|
+
if (option.action) {
|
|
11
|
+
option.action();
|
|
12
|
+
}
|
|
13
|
+
else if (option.link !== undefined && onNavigate) {
|
|
14
|
+
if (typeof option.link === 'string') {
|
|
15
|
+
onNavigate(option.link);
|
|
16
|
+
}
|
|
17
|
+
else if (typeof option.link === 'object' &&
|
|
18
|
+
'pathname' in option.link &&
|
|
19
|
+
option.link.pathname) {
|
|
20
|
+
onNavigate({
|
|
21
|
+
pathname: option.link.pathname,
|
|
22
|
+
state: 'state' in option.link ? option.link.state : undefined,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
onClose();
|
|
27
|
+
}, [onNavigate, onClose]);
|
|
28
|
+
if (menuItem.divider) {
|
|
29
|
+
return (0, jsx_runtime_1.jsx)(material_1.Divider, { sx: { ...menuItem.sideSx } }, menuItem.id);
|
|
30
|
+
}
|
|
31
|
+
else if (menuItem.link) {
|
|
32
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.ListItemButton, { onClick: handleMenuItemClick(menuItem), sx: { ...menuItem.sideSx }, children: [menuItem.icon && (0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { sx: { ...menuItem.sideIconSx }, children: menuItem.icon }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: menuItem.label, sx: { ...menuItem.sideTextSx } })] }, menuItem.id));
|
|
33
|
+
}
|
|
34
|
+
else if (menuItem.action) {
|
|
35
|
+
const action = menuItem.action;
|
|
36
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.ListItemButton, { onClick: async () => {
|
|
37
|
+
await action();
|
|
38
|
+
onClose();
|
|
39
|
+
}, sx: { ...menuItem.sideSx }, children: [menuItem.icon && (0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { sx: { ...menuItem.sideIconSx }, children: menuItem.icon }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: menuItem.label, sx: { ...menuItem.sideTextSx } })] }, menuItem.id));
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
};
|
|
43
|
+
exports.SideMenuListItem = SideMenuListItem;
|
|
44
|
+
exports.default = exports.SideMenuListItem;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface FCParams<TEnum extends string> {
|
|
2
|
+
stringKey: TEnum;
|
|
3
|
+
vars?: Record<string, string | number>;
|
|
4
|
+
}
|
|
5
|
+
export declare const Tbranded: <TEnum extends string>({ stringKey, vars, }: FCParams<TEnum>) => string | undefined;
|
|
6
|
+
export default Tbranded;
|
|
7
|
+
//# sourceMappingURL=T.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"T.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/T.tsx"],"names":[],"mappings":"AAKA,UAAU,QAAQ,CAAC,KAAK,SAAS,MAAM;IACrC,SAAS,EAAE,KAAK,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CACxC;AAED,eAAO,MAAM,QAAQ,GAAI,KAAK,SAAS,MAAM,EAAE,sBAG5C,QAAQ,CAAC,KAAK,CAAC,KAAG,MAAM,GAAG,SAQ7B,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/app/components/T.tsx
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Tbranded = void 0;
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const contexts_1 = require("../contexts");
|
|
7
|
+
const Tbranded = ({ stringKey, vars, }) => {
|
|
8
|
+
const { currentLanguage, tBranded } = (0, contexts_1.useI18n)();
|
|
9
|
+
const translated = (0, react_1.useMemo)(() => tBranded(stringKey, vars, currentLanguage), [tBranded, stringKey, vars, currentLanguage]);
|
|
10
|
+
return translated;
|
|
11
|
+
};
|
|
12
|
+
exports.Tbranded = Tbranded;
|
|
13
|
+
exports.default = exports.Tbranded;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DetailedHTMLProps, HTMLAttributes, ReactElement } from 'react';
|
|
2
|
+
interface FCParams<TEnum extends string> {
|
|
3
|
+
stringKey: TEnum;
|
|
4
|
+
vars?: Record<string, string | number>;
|
|
5
|
+
divOptions?: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
|
|
6
|
+
}
|
|
7
|
+
export declare const TDivBranded: <TEnum extends string>({ stringKey, vars, divOptions, }: FCParams<TEnum>) => ReactElement;
|
|
8
|
+
export default TDivBranded;
|
|
9
|
+
//# sourceMappingURL=TDiv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TDiv.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/TDiv.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,YAAY,EAAW,MAAM,OAAO,CAAC;AAGjF,UAAU,QAAQ,CAAC,KAAK,SAAS,MAAM;IACrC,SAAS,EAAE,KAAK,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACvC,UAAU,CAAC,EAAE,iBAAiB,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC,CAAC;CAChF;AAED,eAAO,MAAM,WAAW,GAAI,KAAK,SAAS,MAAM,EAAE,kCAI/C,QAAQ,CAAC,KAAK,CAAC,KAAG,YAQpB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TDivBranded = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
// src/app/components/TDiv.tsx
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const contexts_1 = require("../contexts");
|
|
8
|
+
const TDivBranded = ({ stringKey, vars, divOptions, }) => {
|
|
9
|
+
const { currentLanguage, tBranded } = (0, contexts_1.useI18n)();
|
|
10
|
+
const translated = (0, react_1.useMemo)(() => tBranded(stringKey, vars, currentLanguage), [tBranded, stringKey, vars, currentLanguage]);
|
|
11
|
+
return (0, jsx_runtime_1.jsx)("div", { ...divOptions, children: translated });
|
|
12
|
+
};
|
|
13
|
+
exports.TDivBranded = TDivBranded;
|
|
14
|
+
exports.default = exports.TDivBranded;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DetailedHTMLProps, ImgHTMLAttributes, ReactElement } from 'react';
|
|
2
|
+
interface FCParams<TEnum extends string> {
|
|
3
|
+
src: string;
|
|
4
|
+
stringKey: TEnum;
|
|
5
|
+
vars?: Record<string, string | number>;
|
|
6
|
+
imgOptions?: DetailedHTMLProps<ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>;
|
|
7
|
+
}
|
|
8
|
+
export declare const TImgAlt: <TEnum extends string>({ src, stringKey, vars, imgOptions, }: FCParams<TEnum>) => ReactElement;
|
|
9
|
+
export default TImgAlt;
|
|
10
|
+
//# sourceMappingURL=TImgAlt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TImgAlt.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/TImgAlt.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,YAAY,EAAW,MAAM,OAAO,CAAC;AAGpF,UAAU,QAAQ,CAAC,KAAK,SAAS,MAAM;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,KAAK,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACvC,UAAU,CAAC,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC,CAAC;CACvF;AAED,eAAO,MAAM,OAAO,GAAI,KAAK,SAAS,MAAM,EAAE,uCAK3C,QAAQ,CAAC,KAAK,CAAC,KAAG,YAQpB,CAAC;AAEF,eAAe,OAAO,CAAC"}
|