@digitaldefiance/express-suite-react-components 5.0.1 → 5.0.2
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/LICENSE +21 -0
- package/package.json +3 -4
- package/src/auth/AdminRoute.tsx +54 -0
- package/src/auth/Private.tsx +17 -0
- package/src/auth/PrivateRoute.tsx +28 -0
- package/src/auth/UnAuth.tsx +16 -0
- package/src/auth/UnAuthRoute.tsx +30 -0
- package/src/auth/{index.d.ts → index.ts} +2 -3
- package/src/components/ApiAccess.tsx +175 -0
- package/src/components/BackupCodeLoginForm.tsx +489 -0
- package/src/components/BackupCodesForm.tsx +287 -0
- package/src/components/CategoryMenu.tsx +155 -0
- package/src/components/ChangePasswordForm.tsx +273 -0
- package/src/components/ConfirmationDialog.tsx +48 -0
- package/src/components/CurrencyCodeSelector.tsx +60 -0
- package/src/components/CurrencyInput.tsx +80 -0
- package/src/components/DashboardPage.tsx +24 -0
- package/src/components/DropdownMenu.tsx +105 -0
- package/src/components/ExpirationSecondsSelector.tsx +60 -0
- package/src/components/FakeEmailAdminPanel.tsx +374 -0
- package/src/components/Flag.tsx +52 -0
- package/src/components/ForgotPasswordForm.tsx +174 -0
- package/src/components/LoginForm.tsx +468 -0
- package/src/components/LogoutPage.tsx +21 -0
- package/src/components/RegisterForm.tsx +1169 -0
- package/src/components/ResetPasswordForm.tsx +247 -0
- package/src/components/SideMenu.tsx +46 -0
- package/src/components/SideMenuListItem.tsx +75 -0
- package/src/components/T.tsx +24 -0
- package/src/components/TDiv.tsx +26 -0
- package/src/components/TImgAlt.tsx +28 -0
- package/src/components/TopMenu.tsx +252 -0
- package/src/components/TotpSetupForm.tsx +188 -0
- package/src/components/TotpVerificationForm.tsx +148 -0
- package/src/components/TranslatedTitle.tsx +31 -0
- package/src/components/UserLanguageSelector.tsx +45 -0
- package/src/components/UserMenu.tsx +15 -0
- package/src/components/UserSettingsForm.tsx +904 -0
- package/src/components/VerifyEmailPage.tsx +222 -0
- package/src/components/__tests__/RegisterForm.totp.spec.tsx +377 -0
- package/src/components/__tests__/TotpSetupForm.spec.tsx +258 -0
- package/src/components/__tests__/TotpVerificationForm.spec.tsx +259 -0
- package/src/components/__tests__/UserSettingsForm.totp.spec.tsx +396 -0
- package/src/components/{index.d.ts → index.ts} +1 -1
- package/src/contexts/AuthProvider.spec.tsx +1284 -0
- package/src/contexts/AuthProvider.tsx +977 -0
- package/src/contexts/I18nProvider.tsx +164 -0
- package/src/contexts/MenuContext.tsx +426 -0
- package/src/contexts/SuiteConfigProvider.tsx +93 -0
- package/src/contexts/ThemeProvider.tsx +67 -0
- package/src/contexts/{index.d.ts → index.ts} +0 -1
- package/src/hooks/{index.d.ts → index.ts} +0 -1
- package/src/hooks/useAuthenticatedApi.tsx +67 -0
- package/src/hooks/useBackupCodes.ts +105 -0
- package/src/hooks/useEmailVerification.ts +54 -0
- package/src/hooks/useExpiringValue.ts +78 -0
- package/src/hooks/useLocalStorage.ts +18 -0
- package/src/hooks/useUserSettings.ts +271 -0
- package/src/{index.d.ts → index.ts} +1 -1
- package/src/interfaces/IAppConfig.ts +7 -0
- package/src/interfaces/ICategoryConfig.ts +41 -0
- package/src/interfaces/IMenuConfig.ts +28 -0
- package/src/interfaces/IMenuOption.ts +79 -0
- package/src/interfaces/{index.d.ts → index.ts} +0 -1
- package/src/services/__mocks__/authService.ts +14 -0
- package/src/services/__tests__/authService.totp.property.spec.ts +360 -0
- package/src/services/__tests__/authService.totp.spec.ts +439 -0
- package/src/services/api.ts +13 -0
- package/src/services/authService.ts +692 -0
- package/src/services/authenticatedApi.ts +17 -0
- package/src/services/index.ts +3 -0
- package/src/types/MenuType.ts +15 -0
- package/src/types/expirationSeconds.ts +18 -0
- package/src/types/index.ts +1 -0
- package/src/types/translation.ts +20 -0
- package/src/wrappers/BackupCodeLoginWrapper.tsx +34 -0
- package/src/wrappers/BackupCodesWrapper.tsx +28 -0
- package/src/wrappers/ChangePasswordFormWrapper.tsx +34 -0
- package/src/wrappers/ForgotPasswordFormWrapper.tsx +45 -0
- package/src/wrappers/LoginFormWrapper.tsx +108 -0
- package/src/wrappers/LogoutPageWrapper.tsx +30 -0
- package/src/wrappers/RegisterFormWrapper.tsx +109 -0
- package/src/wrappers/ResetPasswordFormWrapper.tsx +57 -0
- package/src/wrappers/UserSettingsFormWrapper.tsx +140 -0
- package/src/wrappers/VerifyEmailPageWrapper.tsx +27 -0
- package/src/wrappers/__tests__/LoginFormWrapper.totp.spec.tsx +339 -0
- package/src/wrappers/{index.d.ts → index.tsx} +10 -1
- package/src/auth/AdminRoute.d.ts +0 -8
- package/src/auth/AdminRoute.d.ts.map +0 -1
- package/src/auth/AdminRoute.js +0 -28
- package/src/auth/Private.d.ts +0 -6
- package/src/auth/Private.d.ts.map +0 -1
- package/src/auth/Private.js +0 -14
- package/src/auth/PrivateRoute.d.ts +0 -8
- package/src/auth/PrivateRoute.d.ts.map +0 -1
- package/src/auth/PrivateRoute.js +0 -23
- package/src/auth/UnAuth.d.ts +0 -6
- package/src/auth/UnAuth.d.ts.map +0 -1
- package/src/auth/UnAuth.js +0 -14
- package/src/auth/UnAuthRoute.d.ts +0 -8
- package/src/auth/UnAuthRoute.d.ts.map +0 -1
- package/src/auth/UnAuthRoute.js +0 -22
- package/src/auth/index.d.ts.map +0 -1
- package/src/auth/index.js +0 -12
- package/src/components/ApiAccess.d.ts +0 -16
- package/src/components/ApiAccess.d.ts.map +0 -1
- package/src/components/ApiAccess.js +0 -77
- package/src/components/BackupCodeLoginForm.d.ts +0 -43
- package/src/components/BackupCodeLoginForm.d.ts.map +0 -1
- package/src/components/BackupCodeLoginForm.js +0 -139
- package/src/components/BackupCodesForm.d.ts +0 -26
- package/src/components/BackupCodesForm.d.ts.map +0 -1
- package/src/components/BackupCodesForm.js +0 -120
- package/src/components/CategoryMenu.d.ts +0 -17
- package/src/components/CategoryMenu.d.ts.map +0 -1
- package/src/components/CategoryMenu.js +0 -65
- package/src/components/ChangePasswordForm.d.ts +0 -26
- package/src/components/ChangePasswordForm.d.ts.map +0 -1
- package/src/components/ChangePasswordForm.js +0 -78
- package/src/components/ConfirmationDialog.d.ts +0 -13
- package/src/components/ConfirmationDialog.d.ts.map +0 -1
- package/src/components/ConfirmationDialog.js +0 -10
- package/src/components/CurrencyCodeSelector.d.ts +0 -9
- package/src/components/CurrencyCodeSelector.d.ts.map +0 -1
- package/src/components/CurrencyCodeSelector.js +0 -31
- package/src/components/CurrencyInput.d.ts +0 -13
- package/src/components/CurrencyInput.d.ts.map +0 -1
- package/src/components/CurrencyInput.js +0 -22
- package/src/components/DashboardPage.d.ts +0 -8
- package/src/components/DashboardPage.d.ts.map +0 -1
- package/src/components/DashboardPage.js +0 -10
- package/src/components/DropdownMenu.d.ts +0 -13
- package/src/components/DropdownMenu.d.ts.map +0 -1
- package/src/components/DropdownMenu.js +0 -63
- package/src/components/ExpirationSecondsSelector.d.ts +0 -13
- package/src/components/ExpirationSecondsSelector.d.ts.map +0 -1
- package/src/components/ExpirationSecondsSelector.js +0 -32
- package/src/components/FakeEmailAdminPanel.d.ts +0 -23
- package/src/components/FakeEmailAdminPanel.d.ts.map +0 -1
- package/src/components/FakeEmailAdminPanel.js +0 -147
- package/src/components/Flag.d.ts +0 -20
- package/src/components/Flag.d.ts.map +0 -1
- package/src/components/Flag.js +0 -43
- package/src/components/ForgotPasswordForm.d.ts +0 -18
- package/src/components/ForgotPasswordForm.d.ts.map +0 -1
- package/src/components/ForgotPasswordForm.js +0 -61
- package/src/components/LoginForm.d.ts +0 -44
- package/src/components/LoginForm.d.ts.map +0 -1
- package/src/components/LoginForm.js +0 -123
- package/src/components/LogoutPage.d.ts +0 -8
- package/src/components/LogoutPage.d.ts.map +0 -1
- package/src/components/LogoutPage.js +0 -16
- package/src/components/RegisterForm.d.ts +0 -100
- package/src/components/RegisterForm.d.ts.map +0 -1
- package/src/components/RegisterForm.js +0 -306
- package/src/components/ResetPasswordForm.d.ts +0 -23
- package/src/components/ResetPasswordForm.d.ts.map +0 -1
- package/src/components/ResetPasswordForm.js +0 -78
- package/src/components/SideMenu.d.ts +0 -8
- package/src/components/SideMenu.d.ts.map +0 -1
- package/src/components/SideMenu.js +0 -25
- package/src/components/SideMenuListItem.d.ts +0 -13
- package/src/components/SideMenuListItem.d.ts.map +0 -1
- package/src/components/SideMenuListItem.js +0 -44
- package/src/components/T.d.ts +0 -7
- package/src/components/T.d.ts.map +0 -1
- package/src/components/T.js +0 -13
- package/src/components/TDiv.d.ts +0 -9
- package/src/components/TDiv.d.ts.map +0 -1
- package/src/components/TDiv.js +0 -14
- package/src/components/TImgAlt.d.ts +0 -10
- package/src/components/TImgAlt.d.ts.map +0 -1
- package/src/components/TImgAlt.js +0 -14
- package/src/components/TopMenu.d.ts +0 -50
- package/src/components/TopMenu.d.ts.map +0 -1
- package/src/components/TopMenu.js +0 -79
- package/src/components/TotpSetupForm.d.ts +0 -24
- package/src/components/TotpSetupForm.d.ts.map +0 -1
- package/src/components/TotpSetupForm.js +0 -82
- package/src/components/TotpVerificationForm.d.ts +0 -23
- package/src/components/TotpVerificationForm.d.ts.map +0 -1
- package/src/components/TotpVerificationForm.js +0 -66
- package/src/components/TranslatedTitle.d.ts +0 -8
- package/src/components/TranslatedTitle.d.ts.map +0 -1
- package/src/components/TranslatedTitle.js +0 -15
- package/src/components/UserLanguageSelector.d.ts +0 -4
- package/src/components/UserLanguageSelector.d.ts.map +0 -1
- package/src/components/UserLanguageSelector.js +0 -31
- package/src/components/UserMenu.d.ts +0 -4
- package/src/components/UserMenu.d.ts.map +0 -1
- package/src/components/UserMenu.js +0 -12
- package/src/components/UserSettingsForm.d.ts +0 -113
- package/src/components/UserSettingsForm.d.ts.map +0 -1
- package/src/components/UserSettingsForm.js +0 -269
- package/src/components/VerifyEmailPage.d.ts +0 -24
- package/src/components/VerifyEmailPage.d.ts.map +0 -1
- package/src/components/VerifyEmailPage.js +0 -81
- package/src/components/index.d.ts.map +0 -1
- package/src/components/index.js +0 -35
- package/src/contexts/AuthProvider.d.ts +0 -186
- package/src/contexts/AuthProvider.d.ts.map +0 -1
- package/src/contexts/AuthProvider.js +0 -515
- package/src/contexts/I18nProvider.d.ts +0 -27
- package/src/contexts/I18nProvider.d.ts.map +0 -1
- package/src/contexts/I18nProvider.js +0 -60
- package/src/contexts/MenuContext.d.ts +0 -20
- package/src/contexts/MenuContext.d.ts.map +0 -1
- package/src/contexts/MenuContext.js +0 -275
- package/src/contexts/SuiteConfigProvider.d.ts +0 -44
- package/src/contexts/SuiteConfigProvider.d.ts.map +0 -1
- package/src/contexts/SuiteConfigProvider.js +0 -43
- package/src/contexts/ThemeProvider.d.ts +0 -15
- package/src/contexts/ThemeProvider.d.ts.map +0 -1
- package/src/contexts/ThemeProvider.js +0 -36
- package/src/contexts/index.d.ts.map +0 -1
- package/src/contexts/index.js +0 -8
- package/src/hooks/index.d.ts.map +0 -1
- package/src/hooks/index.js +0 -9
- package/src/hooks/useAuthenticatedApi.d.ts +0 -34
- package/src/hooks/useAuthenticatedApi.d.ts.map +0 -1
- package/src/hooks/useAuthenticatedApi.js +0 -46
- package/src/hooks/useBackupCodes.d.ts +0 -15
- package/src/hooks/useBackupCodes.d.ts.map +0 -1
- package/src/hooks/useBackupCodes.js +0 -74
- package/src/hooks/useEmailVerification.d.ts +0 -10
- package/src/hooks/useEmailVerification.d.ts.map +0 -1
- package/src/hooks/useEmailVerification.js +0 -40
- package/src/hooks/useExpiringValue.d.ts +0 -14
- package/src/hooks/useExpiringValue.d.ts.map +0 -1
- package/src/hooks/useExpiringValue.js +0 -53
- package/src/hooks/useLocalStorage.d.ts +0 -2
- package/src/hooks/useLocalStorage.d.ts.map +0 -1
- package/src/hooks/useLocalStorage.js +0 -15
- package/src/hooks/useUserSettings.d.ts +0 -48
- package/src/hooks/useUserSettings.d.ts.map +0 -1
- package/src/hooks/useUserSettings.js +0 -171
- package/src/index.d.ts.map +0 -1
- package/src/index.js +0 -12
- package/src/interfaces/IAppConfig.d.ts +0 -8
- package/src/interfaces/IAppConfig.d.ts.map +0 -1
- package/src/interfaces/IAppConfig.js +0 -2
- package/src/interfaces/ICategoryConfig.d.ts +0 -41
- package/src/interfaces/ICategoryConfig.d.ts.map +0 -1
- package/src/interfaces/ICategoryConfig.js +0 -2
- package/src/interfaces/IMenuConfig.d.ts +0 -28
- package/src/interfaces/IMenuConfig.d.ts.map +0 -1
- package/src/interfaces/IMenuConfig.js +0 -2
- package/src/interfaces/IMenuOption.d.ts +0 -82
- package/src/interfaces/IMenuOption.d.ts.map +0 -1
- package/src/interfaces/IMenuOption.js +0 -2
- package/src/interfaces/index.d.ts.map +0 -1
- package/src/interfaces/index.js +0 -7
- package/src/services/__mocks__/authService.d.ts +0 -21
- package/src/services/__mocks__/authService.d.ts.map +0 -1
- package/src/services/__mocks__/authService.js +0 -15
- package/src/services/api.d.ts +0 -3
- package/src/services/api.d.ts.map +0 -1
- package/src/services/api.js +0 -14
- package/src/services/authService.d.ts +0 -126
- package/src/services/authService.d.ts.map +0 -1
- package/src/services/authService.js +0 -471
- package/src/services/authenticatedApi.d.ts +0 -3
- package/src/services/authenticatedApi.d.ts.map +0 -1
- package/src/services/authenticatedApi.js +0 -18
- package/src/services/index.d.ts +0 -4
- package/src/services/index.d.ts.map +0 -1
- package/src/services/index.js +0 -6
- package/src/types/MenuType.d.ts +0 -11
- package/src/types/MenuType.d.ts.map +0 -1
- package/src/types/MenuType.js +0 -12
- package/src/types/expirationSeconds.d.ts +0 -3
- package/src/types/expirationSeconds.d.ts.map +0 -1
- package/src/types/expirationSeconds.js +0 -17
- package/src/types/index.d.ts +0 -2
- package/src/types/index.d.ts.map +0 -1
- package/src/types/index.js +0 -4
- package/src/types/translation.d.ts +0 -10
- package/src/types/translation.d.ts.map +0 -1
- package/src/types/translation.js +0 -9
- package/src/wrappers/BackupCodeLoginWrapper.d.ts +0 -8
- package/src/wrappers/BackupCodeLoginWrapper.d.ts.map +0 -1
- package/src/wrappers/BackupCodeLoginWrapper.js +0 -20
- package/src/wrappers/BackupCodesWrapper.d.ts +0 -7
- package/src/wrappers/BackupCodesWrapper.d.ts.map +0 -1
- package/src/wrappers/BackupCodesWrapper.js +0 -17
- package/src/wrappers/ChangePasswordFormWrapper.d.ts +0 -8
- package/src/wrappers/ChangePasswordFormWrapper.d.ts.map +0 -1
- package/src/wrappers/ChangePasswordFormWrapper.js +0 -21
- package/src/wrappers/ForgotPasswordFormWrapper.d.ts +0 -8
- package/src/wrappers/ForgotPasswordFormWrapper.d.ts.map +0 -1
- package/src/wrappers/ForgotPasswordFormWrapper.js +0 -29
- package/src/wrappers/LoginFormWrapper.d.ts +0 -21
- package/src/wrappers/LoginFormWrapper.d.ts.map +0 -1
- package/src/wrappers/LoginFormWrapper.js +0 -72
- package/src/wrappers/LogoutPageWrapper.d.ts +0 -9
- package/src/wrappers/LogoutPageWrapper.d.ts.map +0 -1
- package/src/wrappers/LogoutPageWrapper.js +0 -21
- package/src/wrappers/RegisterFormWrapper.d.ts +0 -20
- package/src/wrappers/RegisterFormWrapper.d.ts.map +0 -1
- package/src/wrappers/RegisterFormWrapper.js +0 -51
- package/src/wrappers/ResetPasswordFormWrapper.d.ts +0 -9
- package/src/wrappers/ResetPasswordFormWrapper.d.ts.map +0 -1
- package/src/wrappers/ResetPasswordFormWrapper.js +0 -34
- package/src/wrappers/UserSettingsFormWrapper.d.ts +0 -29
- package/src/wrappers/UserSettingsFormWrapper.d.ts.map +0 -1
- package/src/wrappers/UserSettingsFormWrapper.js +0 -95
- package/src/wrappers/VerifyEmailPageWrapper.d.ts +0 -8
- package/src/wrappers/VerifyEmailPageWrapper.d.ts.map +0 -1
- package/src/wrappers/VerifyEmailPageWrapper.js +0 -21
- package/src/wrappers/index.d.ts.map +0 -1
- package/src/wrappers/index.js +0 -24
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// src/app/components/TranslatedTitle.tsx
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.TranslatedTitle = void 0;
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const contexts_1 = require("../contexts");
|
|
7
|
-
const TranslatedTitle = ({ componentId, stringKey, vars, }) => {
|
|
8
|
-
const { tComponent, currentLanguage } = (0, contexts_1.useI18n)();
|
|
9
|
-
(0, react_1.useEffect)(() => {
|
|
10
|
-
document.title = tComponent(componentId, stringKey, vars, currentLanguage);
|
|
11
|
-
}, [tComponent, componentId, stringKey, vars, currentLanguage]);
|
|
12
|
-
return null;
|
|
13
|
-
};
|
|
14
|
-
exports.TranslatedTitle = TranslatedTitle;
|
|
15
|
-
exports.default = exports.TranslatedTitle;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UserLanguageSelector.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/UserLanguageSelector.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAiC,MAAM,OAAO,CAAC;AAM1D,eAAO,MAAM,oBAAoB,EAAE,EAkClC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UserLanguageSelector = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const i18n_lib_1 = require("@digitaldefiance/i18n-lib");
|
|
6
|
-
const material_1 = require("@mui/material");
|
|
7
|
-
const react_1 = require("react");
|
|
8
|
-
const Flag_1 = require("./Flag");
|
|
9
|
-
const hooks_1 = require("../hooks");
|
|
10
|
-
const services_1 = require("../services");
|
|
11
|
-
const contexts_1 = require("../contexts");
|
|
12
|
-
const UserLanguageSelector = () => {
|
|
13
|
-
const { baseUrl } = (0, contexts_1.useSuiteConfig)();
|
|
14
|
-
const authenticatedApi = (0, react_1.useMemo)(() => (0, services_1.createAuthenticatedApiClient)(baseUrl), [baseUrl]);
|
|
15
|
-
const { isAuthenticated } = (0, contexts_1.useAuth)();
|
|
16
|
-
const { currentLanguage, changeLanguage } = (0, hooks_1.useUserSettings)({ authenticatedApi, isAuthenticated });
|
|
17
|
-
const [anchorEl, setAnchorEl] = (0, react_1.useState)(null);
|
|
18
|
-
const handleClick = (event) => {
|
|
19
|
-
setAnchorEl(event.currentTarget);
|
|
20
|
-
};
|
|
21
|
-
const handleClose = () => {
|
|
22
|
-
setAnchorEl(null);
|
|
23
|
-
};
|
|
24
|
-
const handleLanguageChange = (newLanguage) => {
|
|
25
|
-
changeLanguage(newLanguage);
|
|
26
|
-
handleClose();
|
|
27
|
-
};
|
|
28
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { onClick: handleClick, children: (0, jsx_runtime_1.jsx)(Flag_1.Flag, { language: currentLanguage }) }), (0, jsx_runtime_1.jsx)(material_1.Menu, { anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleClose, children: Object.values(i18n_lib_1.LanguageRegistry.getAllLanguages()).map((lang) => ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, { onClick: () => handleLanguageChange(lang.code), children: [(0, jsx_runtime_1.jsx)(Flag_1.Flag, { language: lang.code, sx: { mr: 1 } }), " ", lang.name] }, lang.code))) })] }));
|
|
29
|
-
};
|
|
30
|
-
exports.UserLanguageSelector = UserLanguageSelector;
|
|
31
|
-
exports.default = exports.UserLanguageSelector;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UserMenu.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/UserMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAK3B,eAAO,MAAM,QAAQ,EAAE,EAOtB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UserMenu = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const icons_material_1 = require("@mui/icons-material");
|
|
6
|
-
const MenuType_1 = require("../types/MenuType");
|
|
7
|
-
const DropdownMenu_1 = require("./DropdownMenu");
|
|
8
|
-
const UserMenu = () => {
|
|
9
|
-
return ((0, jsx_runtime_1.jsx)(DropdownMenu_1.DropdownMenu, { menuType: MenuType_1.MenuTypes.UserMenu, menuIcon: (0, jsx_runtime_1.jsx)(icons_material_1.AccountCircle, {}) }));
|
|
10
|
-
};
|
|
11
|
-
exports.UserMenu = UserMenu;
|
|
12
|
-
exports.default = exports.UserMenu;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { useFormik } from 'formik';
|
|
2
|
-
import { FC } from 'react';
|
|
3
|
-
import * as Yup from 'yup';
|
|
4
|
-
export interface UserSettingsFormValues {
|
|
5
|
-
email: string;
|
|
6
|
-
timezone: string;
|
|
7
|
-
siteLanguage: string;
|
|
8
|
-
currency: string;
|
|
9
|
-
darkMode: boolean;
|
|
10
|
-
directChallenge: boolean;
|
|
11
|
-
displayName?: string;
|
|
12
|
-
[key: string]: string | boolean | undefined;
|
|
13
|
-
}
|
|
14
|
-
export interface UserSettingsFormProps {
|
|
15
|
-
initialValues: UserSettingsFormValues;
|
|
16
|
-
onSubmit: (values: UserSettingsFormValues) => Promise<{
|
|
17
|
-
success: boolean;
|
|
18
|
-
message: string;
|
|
19
|
-
} | {
|
|
20
|
-
error: string;
|
|
21
|
-
errorType?: string;
|
|
22
|
-
field?: string;
|
|
23
|
-
errors?: Array<{
|
|
24
|
-
path: string;
|
|
25
|
-
msg: string;
|
|
26
|
-
}>;
|
|
27
|
-
}>;
|
|
28
|
-
languages: Array<{
|
|
29
|
-
code: string;
|
|
30
|
-
label: string;
|
|
31
|
-
}>;
|
|
32
|
-
emailValidation?: Yup.StringSchema;
|
|
33
|
-
timezoneValidation?: Yup.StringSchema;
|
|
34
|
-
siteLanguageValidation?: Yup.StringSchema;
|
|
35
|
-
currencyValidation?: Yup.StringSchema;
|
|
36
|
-
darkModeValidation?: Yup.BooleanSchema;
|
|
37
|
-
directChallengeValidation?: Yup.BooleanSchema;
|
|
38
|
-
displayNameValidation?: Yup.StringSchema;
|
|
39
|
-
additionalFields?: (formik: ReturnType<typeof useFormik<UserSettingsFormValues>>) => React.ReactNode;
|
|
40
|
-
additionalInitialValues?: Record<string, string | boolean>;
|
|
41
|
-
additionalValidation?: Record<string, Yup.Schema>;
|
|
42
|
-
/**
|
|
43
|
-
* Current TOTP 2FA status. When undefined (not passed), no TOTP controls are rendered.
|
|
44
|
-
* When false, an "Enable 2FA" button is shown. When true, "Disable 2FA" and "Reset 2FA" buttons are shown.
|
|
45
|
-
*/
|
|
46
|
-
totpEnabled?: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Called to initiate TOTP setup (e.g. AuthService.setupTotp()).
|
|
49
|
-
* Must return provisioning URI and secret on success, or an error.
|
|
50
|
-
*/
|
|
51
|
-
onTotpSetup?: () => Promise<{
|
|
52
|
-
provisioningUri: string;
|
|
53
|
-
secret: string;
|
|
54
|
-
} | {
|
|
55
|
-
error: string;
|
|
56
|
-
}>;
|
|
57
|
-
/**
|
|
58
|
-
* Called to confirm TOTP setup with a 6-digit code (e.g. AuthService.confirmTotp()).
|
|
59
|
-
*/
|
|
60
|
-
onTotpConfirm?: (code: string) => Promise<{
|
|
61
|
-
success: boolean;
|
|
62
|
-
} | {
|
|
63
|
-
error: string;
|
|
64
|
-
}>;
|
|
65
|
-
/**
|
|
66
|
-
* Called to disable TOTP with a 6-digit code (e.g. AuthService.disableTotp()).
|
|
67
|
-
*/
|
|
68
|
-
onTotpDisable?: (code: string) => Promise<{
|
|
69
|
-
success: boolean;
|
|
70
|
-
} | {
|
|
71
|
-
error: string;
|
|
72
|
-
}>;
|
|
73
|
-
/**
|
|
74
|
-
* Called to reset TOTP with a 6-digit code (e.g. AuthService.resetTotp()).
|
|
75
|
-
* Returns new provisioning URI and secret on success.
|
|
76
|
-
*/
|
|
77
|
-
onTotpReset?: (code: string) => Promise<{
|
|
78
|
-
provisioningUri: string;
|
|
79
|
-
secret: string;
|
|
80
|
-
} | {
|
|
81
|
-
error: string;
|
|
82
|
-
}>;
|
|
83
|
-
labels?: {
|
|
84
|
-
title?: string;
|
|
85
|
-
email?: string;
|
|
86
|
-
emailHelper?: string;
|
|
87
|
-
timezone?: string;
|
|
88
|
-
siteLanguage?: string;
|
|
89
|
-
currency?: string;
|
|
90
|
-
darkMode?: string;
|
|
91
|
-
directChallenge?: string;
|
|
92
|
-
directChallengeHelper?: string;
|
|
93
|
-
displayName?: string;
|
|
94
|
-
saving?: string;
|
|
95
|
-
save?: string;
|
|
96
|
-
successMessage?: string;
|
|
97
|
-
totpSectionTitle?: string;
|
|
98
|
-
totpStatusEnabled?: string;
|
|
99
|
-
totpStatusDisabled?: string;
|
|
100
|
-
totpEnableButton?: string;
|
|
101
|
-
totpDisableButton?: string;
|
|
102
|
-
totpResetButton?: string;
|
|
103
|
-
totpDisableCodeLabel?: string;
|
|
104
|
-
totpDisableSubmitButton?: string;
|
|
105
|
-
totpResetCodeLabel?: string;
|
|
106
|
-
totpResetSubmitButton?: string;
|
|
107
|
-
totpCancelButton?: string;
|
|
108
|
-
totpError?: string;
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
export declare const UserSettingsForm: FC<UserSettingsFormProps>;
|
|
112
|
-
export default UserSettingsForm;
|
|
113
|
-
//# sourceMappingURL=UserSettingsForm.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UserSettingsForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/UserSettingsForm.tsx"],"names":[],"mappings":"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"}
|
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UserSettingsForm = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const i18n_lib_1 = require("@digitaldefiance/i18n-lib");
|
|
7
|
-
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
8
|
-
const material_1 = require("@mui/material");
|
|
9
|
-
const formik_1 = require("formik");
|
|
10
|
-
const moment_timezone_1 = tslib_1.__importDefault(require("moment-timezone"));
|
|
11
|
-
const react_1 = require("react");
|
|
12
|
-
const Yup = tslib_1.__importStar(require("yup"));
|
|
13
|
-
const contexts_1 = require("../contexts");
|
|
14
|
-
const suite_core_lib_2 = require("@digitaldefiance/suite-core-lib");
|
|
15
|
-
const TotpSetupForm_1 = require("./TotpSetupForm");
|
|
16
|
-
const UserSettingsForm = ({ initialValues, onSubmit, languages, emailValidation, timezoneValidation, siteLanguageValidation, currencyValidation, darkModeValidation, directChallengeValidation, displayNameValidation, additionalFields, additionalInitialValues = {}, additionalValidation = {}, totpEnabled, onTotpSetup, onTotpConfirm, onTotpDisable, onTotpReset, labels = {}, }) => {
|
|
17
|
-
const { tComponent } = (0, contexts_1.useI18n)();
|
|
18
|
-
const [apiErrors, setApiErrors] = (0, react_1.useState)({});
|
|
19
|
-
const [saving, setSaving] = (0, react_1.useState)(false);
|
|
20
|
-
const [successMessage, setSuccessMessage] = (0, react_1.useState)(null);
|
|
21
|
-
// TOTP management state
|
|
22
|
-
const [totpStatus, setTotpStatus] = (0, react_1.useState)(totpEnabled);
|
|
23
|
-
// Sync totpStatus when the totpEnabled prop transitions from undefined to a
|
|
24
|
-
// concrete value (i.e. after the wrapper fetches it asynchronously).
|
|
25
|
-
(0, react_1.useEffect)(() => {
|
|
26
|
-
if (totpEnabled !== undefined) {
|
|
27
|
-
setTotpStatus(totpEnabled);
|
|
28
|
-
}
|
|
29
|
-
}, [totpEnabled]);
|
|
30
|
-
const [showTotpSetup, setShowTotpSetup] = (0, react_1.useState)(false);
|
|
31
|
-
const [totpProvisioningUri, setTotpProvisioningUri] = (0, react_1.useState)(null);
|
|
32
|
-
const [totpSecret, setTotpSecret] = (0, react_1.useState)(null);
|
|
33
|
-
const [totpSetupLoading, setTotpSetupLoading] = (0, react_1.useState)(false);
|
|
34
|
-
const [totpError, setTotpError] = (0, react_1.useState)(null);
|
|
35
|
-
const [showDisablePrompt, setShowDisablePrompt] = (0, react_1.useState)(false);
|
|
36
|
-
const [disableCode, setDisableCode] = (0, react_1.useState)('');
|
|
37
|
-
const [disableSubmitting, setDisableSubmitting] = (0, react_1.useState)(false);
|
|
38
|
-
const [showResetPrompt, setShowResetPrompt] = (0, react_1.useState)(false);
|
|
39
|
-
const [resetCode, setResetCode] = (0, react_1.useState)('');
|
|
40
|
-
const [resetSubmitting, setResetSubmitting] = (0, react_1.useState)(false);
|
|
41
|
-
const handleEnableTotp = (0, react_1.useCallback)(async () => {
|
|
42
|
-
if (!onTotpSetup)
|
|
43
|
-
return;
|
|
44
|
-
setTotpSetupLoading(true);
|
|
45
|
-
setTotpError(null);
|
|
46
|
-
try {
|
|
47
|
-
const result = await onTotpSetup();
|
|
48
|
-
if ('error' in result) {
|
|
49
|
-
setTotpError(result.error);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
setTotpProvisioningUri(result.provisioningUri);
|
|
53
|
-
setTotpSecret(result.secret);
|
|
54
|
-
setShowTotpSetup(true);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
catch {
|
|
58
|
-
setTotpError(labels.totpError || 'Failed to set up two-factor authentication');
|
|
59
|
-
}
|
|
60
|
-
finally {
|
|
61
|
-
setTotpSetupLoading(false);
|
|
62
|
-
}
|
|
63
|
-
}, [onTotpSetup, labels.totpError]);
|
|
64
|
-
const handleTotpConfirm = (0, react_1.useCallback)(async (code) => {
|
|
65
|
-
if (!onTotpConfirm) {
|
|
66
|
-
return { error: 'TOTP confirmation is not available' };
|
|
67
|
-
}
|
|
68
|
-
const result = await onTotpConfirm(code);
|
|
69
|
-
if ('success' in result && result.success) {
|
|
70
|
-
setTotpStatus(true);
|
|
71
|
-
setShowTotpSetup(false);
|
|
72
|
-
setTotpProvisioningUri(null);
|
|
73
|
-
setTotpSecret(null);
|
|
74
|
-
}
|
|
75
|
-
return result;
|
|
76
|
-
}, [onTotpConfirm]);
|
|
77
|
-
const handleDisableTotp = (0, react_1.useCallback)(async () => {
|
|
78
|
-
if (!onTotpDisable || !disableCode)
|
|
79
|
-
return;
|
|
80
|
-
setDisableSubmitting(true);
|
|
81
|
-
setTotpError(null);
|
|
82
|
-
try {
|
|
83
|
-
const result = await onTotpDisable(disableCode);
|
|
84
|
-
if ('error' in result) {
|
|
85
|
-
setTotpError(result.error);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
setTotpStatus(false);
|
|
89
|
-
setShowDisablePrompt(false);
|
|
90
|
-
setDisableCode('');
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
catch {
|
|
94
|
-
setTotpError(labels.totpError || 'Failed to disable two-factor authentication');
|
|
95
|
-
}
|
|
96
|
-
finally {
|
|
97
|
-
setDisableSubmitting(false);
|
|
98
|
-
}
|
|
99
|
-
}, [onTotpDisable, disableCode, labels.totpError]);
|
|
100
|
-
const handleResetTotp = (0, react_1.useCallback)(async () => {
|
|
101
|
-
if (!onTotpReset || !resetCode)
|
|
102
|
-
return;
|
|
103
|
-
setResetSubmitting(true);
|
|
104
|
-
setTotpError(null);
|
|
105
|
-
try {
|
|
106
|
-
const result = await onTotpReset(resetCode);
|
|
107
|
-
if ('error' in result) {
|
|
108
|
-
setTotpError(result.error);
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
setTotpProvisioningUri(result.provisioningUri);
|
|
112
|
-
setTotpSecret(result.secret);
|
|
113
|
-
setShowResetPrompt(false);
|
|
114
|
-
setResetCode('');
|
|
115
|
-
setShowTotpSetup(true);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
catch {
|
|
119
|
-
setTotpError(labels.totpError || 'Failed to reset two-factor authentication');
|
|
120
|
-
}
|
|
121
|
-
finally {
|
|
122
|
-
setResetSubmitting(false);
|
|
123
|
-
}
|
|
124
|
-
}, [onTotpReset, resetCode, labels.totpError]);
|
|
125
|
-
const handleCancelTotpAction = (0, react_1.useCallback)(() => {
|
|
126
|
-
setShowTotpSetup(false);
|
|
127
|
-
setShowDisablePrompt(false);
|
|
128
|
-
setShowResetPrompt(false);
|
|
129
|
-
setTotpProvisioningUri(null);
|
|
130
|
-
setTotpSecret(null);
|
|
131
|
-
setDisableCode('');
|
|
132
|
-
setResetCode('');
|
|
133
|
-
setTotpError(null);
|
|
134
|
-
}, []);
|
|
135
|
-
const timezones = (0, react_1.useMemo)(() => moment_timezone_1.default.tz.names(), []);
|
|
136
|
-
const currencies = (0, react_1.useMemo)(() => i18n_lib_1.CurrencyCode.getAllData().map((c) => ({
|
|
137
|
-
code: c.code,
|
|
138
|
-
label: `${c.code} - ${c.currency}`,
|
|
139
|
-
})), []);
|
|
140
|
-
const validation = {
|
|
141
|
-
email: emailValidation ||
|
|
142
|
-
Yup.string()
|
|
143
|
-
.email(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidEmail))
|
|
144
|
-
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
145
|
-
timezone: timezoneValidation ||
|
|
146
|
-
Yup.string()
|
|
147
|
-
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_TimezoneRequired))
|
|
148
|
-
.test('valid-timezone', tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_TimezoneInvalid), (value) => !value || moment_timezone_1.default.tz.zone(value) !== null),
|
|
149
|
-
siteLanguage: siteLanguageValidation ||
|
|
150
|
-
Yup.string().required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
151
|
-
currency: currencyValidation ||
|
|
152
|
-
Yup.string()
|
|
153
|
-
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required))
|
|
154
|
-
.test('valid-currency', tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required), (value) => !value || i18n_lib_1.CurrencyCode.isValid(value)),
|
|
155
|
-
darkMode: darkModeValidation ||
|
|
156
|
-
Yup.boolean().required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
157
|
-
directChallenge: directChallengeValidation ||
|
|
158
|
-
Yup.boolean().required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
159
|
-
...(suite_core_lib_2.Constants.EnableDisplayName ? {
|
|
160
|
-
displayName: displayNameValidation ||
|
|
161
|
-
Yup.string()
|
|
162
|
-
.min(suite_core_lib_2.Constants.DisplayNameMinLength, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_DisplayNameMinLengthTemplate))
|
|
163
|
-
.max(suite_core_lib_2.Constants.DisplayNameMaxLength, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_DisplayNameMaxLengthTemplate))
|
|
164
|
-
.matches(suite_core_lib_2.Constants.DisplayNameRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_DisplayNameRegexErrorTemplate)),
|
|
165
|
-
} : {}),
|
|
166
|
-
};
|
|
167
|
-
const formik = (0, formik_1.useFormik)({
|
|
168
|
-
initialValues: {
|
|
169
|
-
...initialValues,
|
|
170
|
-
...additionalInitialValues,
|
|
171
|
-
},
|
|
172
|
-
enableReinitialize: true,
|
|
173
|
-
validationSchema: Yup.object({
|
|
174
|
-
email: validation.email,
|
|
175
|
-
timezone: validation.timezone,
|
|
176
|
-
siteLanguage: validation.siteLanguage,
|
|
177
|
-
currency: validation.currency,
|
|
178
|
-
darkMode: validation.darkMode,
|
|
179
|
-
directChallenge: validation.directChallenge,
|
|
180
|
-
...(suite_core_lib_2.Constants.EnableDisplayName && validation.displayName ? { displayName: validation.displayName } : {}),
|
|
181
|
-
...additionalValidation,
|
|
182
|
-
}),
|
|
183
|
-
onSubmit: async (values, { setSubmitting, setFieldError, setTouched }) => {
|
|
184
|
-
setSaving(true);
|
|
185
|
-
setSuccessMessage(null);
|
|
186
|
-
const result = await onSubmit(values);
|
|
187
|
-
if ('success' in result && result.success) {
|
|
188
|
-
setSuccessMessage(result.message ||
|
|
189
|
-
labels.successMessage ||
|
|
190
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_SaveSuccess));
|
|
191
|
-
setApiErrors({});
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
const newApiErrors = {};
|
|
195
|
-
const fieldsToTouch = {};
|
|
196
|
-
if ('field' in result && result.field) {
|
|
197
|
-
setFieldError(result.field, result.error);
|
|
198
|
-
fieldsToTouch[result.field] = true;
|
|
199
|
-
}
|
|
200
|
-
if ('errors' in result && result.errors) {
|
|
201
|
-
result.errors.forEach((err) => {
|
|
202
|
-
if (err.path && err.msg) {
|
|
203
|
-
setFieldError(err.path, err.msg);
|
|
204
|
-
fieldsToTouch[err.path] = true;
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
if ('error' in result &&
|
|
209
|
-
result.error &&
|
|
210
|
-
!Object.keys(newApiErrors).length) {
|
|
211
|
-
newApiErrors.general = result.error;
|
|
212
|
-
}
|
|
213
|
-
setApiErrors(newApiErrors);
|
|
214
|
-
setTouched(fieldsToTouch, false);
|
|
215
|
-
}
|
|
216
|
-
setSubmitting(false);
|
|
217
|
-
setSaving(false);
|
|
218
|
-
},
|
|
219
|
-
});
|
|
220
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Container, { maxWidth: "sm", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
221
|
-
mt: 4,
|
|
222
|
-
display: 'flex',
|
|
223
|
-
flexDirection: 'column',
|
|
224
|
-
alignItems: 'center',
|
|
225
|
-
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: labels.title ||
|
|
226
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_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: "email", name: "email", label: labels.email ||
|
|
227
|
-
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 &&
|
|
228
|
-
(formik.errors.email || apiErrors.email)) ||
|
|
229
|
-
labels.emailHelper ||
|
|
230
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_EmailHelper), margin: "normal" }), suite_core_lib_2.Constants.EnableDisplayName && ((0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "displayName", name: "displayName", label: labels.displayName ||
|
|
231
|
-
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 && (formik.errors.displayName || apiErrors.displayName)), helperText: formik.touched.displayName && (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 ||
|
|
232
|
-
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 ||
|
|
233
|
-
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 &&
|
|
234
|
-
(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.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: "language-label", children: labels.siteLanguage ||
|
|
235
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_SiteLanguage) }), (0, jsx_runtime_1.jsx)(material_1.Select, { labelId: "language-label", id: "siteLanguage", name: "siteLanguage", value: formik.values.siteLanguage, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.siteLanguage &&
|
|
236
|
-
Boolean(formik.errors.siteLanguage), label: labels.siteLanguage ||
|
|
237
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_SiteLanguage), children: languages.map((lang) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: lang.code, children: lang.label }, lang.code))) }), formik.touched.siteLanguage &&
|
|
238
|
-
(formik.errors.siteLanguage || apiErrors.siteLanguage) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", variant: "caption", children: formik.errors.siteLanguage || apiErrors.siteLanguage }))] }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: "currency-label", children: labels.currency ||
|
|
239
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Currency) }), (0, jsx_runtime_1.jsx)(material_1.Select, { labelId: "currency-label", id: "currency", name: "currency", value: formik.values.currency, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.currency && Boolean(formik.errors.currency), label: labels.currency ||
|
|
240
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Currency), children: currencies.map((curr) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: curr.code, children: curr.label }, curr.code))) }), formik.touched.currency &&
|
|
241
|
-
(formik.errors.currency || apiErrors.currency) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", variant: "caption", children: formik.errors.currency || apiErrors.currency }))] }), (0, jsx_runtime_1.jsx)(material_1.FormControl, { fullWidth: true, margin: "normal", children: (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Switch, { id: "darkMode", name: "darkMode", checked: formik.values.darkMode, onChange: formik.handleChange }), label: labels.darkMode ||
|
|
242
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_DarkMode) }) }), (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.Switch, { id: "directChallenge", name: "directChallenge", checked: formik.values.directChallenge, onChange: formik.handleChange }), label: labels.directChallenge ||
|
|
243
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_DirectChallengeLabel) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", color: "text.secondary", sx: { ml: 4, mt: -1 }, children: labels.directChallengeHelper ||
|
|
244
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_DirectChallengeHelper) })] }), additionalFields && additionalFields(formik), apiErrors.general && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: apiErrors.general })), successMessage && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: 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: saving
|
|
245
|
-
? labels.saving ||
|
|
246
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Saving)
|
|
247
|
-
: labels.save ||
|
|
248
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Save) })] }), totpStatus !== undefined && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Divider, { sx: { mt: 3, mb: 2 } }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", component: "h2", gutterBottom: true, children: labels.totpSectionTitle || 'Two-Factor Authentication' }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", sx: { mb: 2 }, children: totpStatus
|
|
249
|
-
? (labels.totpStatusEnabled || '2FA is currently enabled')
|
|
250
|
-
: (labels.totpStatusDisabled || '2FA is currently disabled') }), totpError && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mb: 2 }, role: "alert", children: totpError })), !totpStatus && !showTotpSetup && ((0, jsx_runtime_1.jsx)(material_1.Button, { type: "button", variant: "outlined", onClick: handleEnableTotp, disabled: totpSetupLoading, "data-testid": "enable-totp-button", children: totpSetupLoading
|
|
251
|
-
? 'Setting up...'
|
|
252
|
-
: (labels.totpEnableButton || 'Enable 2FA') })), showTotpSetup && totpProvisioningUri && totpSecret && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 2 }, children: [(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: 1 }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { type: "button", variant: "text", onClick: handleCancelTotpAction, "data-testid": "cancel-totp-setup-button", children: labels.totpCancelButton || 'Cancel' }) })] })), totpStatus && !showTotpSetup && !showDisablePrompt && !showResetPrompt && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', gap: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Button, { type: "button", variant: "outlined", color: "error", onClick: () => { setShowDisablePrompt(true); setTotpError(null); }, "data-testid": "disable-totp-button", children: labels.totpDisableButton || 'Disable 2FA' }), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "button", variant: "outlined", onClick: () => { setShowResetPrompt(true); setTotpError(null); }, "data-testid": "reset-totp-button", children: labels.totpResetButton || 'Reset 2FA' })] })), showDisablePrompt && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", sx: { mb: 1 }, children: "Enter your current 2FA code to disable two-factor authentication:" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "totp-disable-code", name: "totp-disable-code", label: labels.totpDisableCodeLabel || 'TOTP Code', value: disableCode, onChange: (e) => setDisableCode(e.target.value), inputProps: {
|
|
253
|
-
'aria-label': labels.totpDisableCodeLabel || 'TOTP Code',
|
|
254
|
-
inputMode: 'numeric',
|
|
255
|
-
maxLength: 6,
|
|
256
|
-
pattern: '\\d{6}',
|
|
257
|
-
}, autoComplete: "one-time-code", margin: "normal" }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', gap: 2, mt: 1 }, children: [(0, jsx_runtime_1.jsx)(material_1.Button, { type: "button", variant: "contained", color: "error", onClick: handleDisableTotp, disabled: disableSubmitting || !/^\d{6}$/.test(disableCode), "data-testid": "disable-totp-submit-button", children: disableSubmitting
|
|
258
|
-
? 'Disabling...'
|
|
259
|
-
: (labels.totpDisableSubmitButton || 'Confirm Disable') }), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "button", variant: "text", onClick: handleCancelTotpAction, "data-testid": "cancel-disable-totp-button", children: labels.totpCancelButton || 'Cancel' })] })] })), showResetPrompt && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", sx: { mb: 1 }, children: "Enter your current 2FA code to reset two-factor authentication:" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "totp-reset-code", name: "totp-reset-code", label: labels.totpResetCodeLabel || 'TOTP Code', value: resetCode, onChange: (e) => setResetCode(e.target.value), inputProps: {
|
|
260
|
-
'aria-label': labels.totpResetCodeLabel || 'TOTP Code',
|
|
261
|
-
inputMode: 'numeric',
|
|
262
|
-
maxLength: 6,
|
|
263
|
-
pattern: '\\d{6}',
|
|
264
|
-
}, autoComplete: "one-time-code", margin: "normal" }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', gap: 2, mt: 1 }, children: [(0, jsx_runtime_1.jsx)(material_1.Button, { type: "button", variant: "contained", onClick: handleResetTotp, disabled: resetSubmitting || !/^\d{6}$/.test(resetCode), "data-testid": "reset-totp-submit-button", children: resetSubmitting
|
|
265
|
-
? 'Resetting...'
|
|
266
|
-
: (labels.totpResetSubmitButton || 'Confirm Reset') }), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "button", variant: "text", onClick: handleCancelTotpAction, "data-testid": "cancel-reset-totp-button", children: labels.totpCancelButton || 'Cancel' })] })] }))] }))] }) }));
|
|
267
|
-
};
|
|
268
|
-
exports.UserSettingsForm = UserSettingsForm;
|
|
269
|
-
exports.default = exports.UserSettingsForm;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
export interface VerifyEmailPageProps {
|
|
3
|
-
token: string | null;
|
|
4
|
-
onVerify: (token: string) => Promise<{
|
|
5
|
-
success: boolean;
|
|
6
|
-
message?: string;
|
|
7
|
-
}>;
|
|
8
|
-
labels?: {
|
|
9
|
-
title?: string;
|
|
10
|
-
verifying?: string;
|
|
11
|
-
success?: string;
|
|
12
|
-
failed?: string;
|
|
13
|
-
noToken?: string;
|
|
14
|
-
checkYourEmail?: string;
|
|
15
|
-
proceedToLogin?: string;
|
|
16
|
-
contactSupport?: string;
|
|
17
|
-
requestNewEmail?: string;
|
|
18
|
-
};
|
|
19
|
-
loginLink?: string;
|
|
20
|
-
resendLink?: string;
|
|
21
|
-
}
|
|
22
|
-
export declare const VerifyEmailPage: FC<VerifyEmailPageProps>;
|
|
23
|
-
export default VerifyEmailPage;
|
|
24
|
-
//# sourceMappingURL=VerifyEmailPage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"VerifyEmailPage.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/VerifyEmailPage.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,EAAE,EAAwC,MAAM,OAAO,CAAC;AAGjE,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7E,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAwLpD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VerifyEmailPage = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
6
|
-
const material_1 = require("@mui/material");
|
|
7
|
-
const react_1 = require("react");
|
|
8
|
-
const contexts_1 = require("../contexts");
|
|
9
|
-
const VerifyEmailPage = ({ token, onVerify, labels = {}, loginLink = '/login', resendLink = '/resend-verification', }) => {
|
|
10
|
-
const { tComponent } = (0, contexts_1.useI18n)();
|
|
11
|
-
const [message, setMessage] = (0, react_1.useState)('');
|
|
12
|
-
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
13
|
-
const [verificationStatus, setVerificationStatus] = (0, react_1.useState)('pending');
|
|
14
|
-
const translatedLabels = (0, react_1.useMemo)(() => {
|
|
15
|
-
return {
|
|
16
|
-
title: labels.title ||
|
|
17
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_EmailVerification),
|
|
18
|
-
success: labels.success ||
|
|
19
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.EmailVerification_Success),
|
|
20
|
-
failed: labels.failed ||
|
|
21
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.EmailVerification_Failed),
|
|
22
|
-
noToken: labels.noToken ||
|
|
23
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.NoVerificationTokenProvided),
|
|
24
|
-
checkYourEmail: labels.checkYourEmail ||
|
|
25
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_CheckYourEmail),
|
|
26
|
-
proceedToLogin: labels.proceedToLogin ||
|
|
27
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ProceedToLogin),
|
|
28
|
-
contactSupport: labels.contactSupport ||
|
|
29
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.HavingTroubleContactSupport),
|
|
30
|
-
requestNewEmail: labels.requestNewEmail ||
|
|
31
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.RequestNewVerificationEmail),
|
|
32
|
-
};
|
|
33
|
-
}, [labels, tComponent]);
|
|
34
|
-
// Use a ref to track whether verification has already been attempted,
|
|
35
|
-
// preventing infinite re-render loops from unstable onVerify references.
|
|
36
|
-
const hasVerified = (0, react_1.useRef)(false);
|
|
37
|
-
// Stable reference to onVerify to avoid re-triggering the effect
|
|
38
|
-
const onVerifyRef = (0, react_1.useRef)(onVerify);
|
|
39
|
-
onVerifyRef.current = onVerify;
|
|
40
|
-
(0, react_1.useEffect)(() => {
|
|
41
|
-
if (hasVerified.current)
|
|
42
|
-
return;
|
|
43
|
-
if (token) {
|
|
44
|
-
hasVerified.current = true;
|
|
45
|
-
const verifyEmail = async () => {
|
|
46
|
-
try {
|
|
47
|
-
const result = await onVerifyRef.current(token);
|
|
48
|
-
if (result.success) {
|
|
49
|
-
setMessage(result.message || translatedLabels.success);
|
|
50
|
-
setVerificationStatus('success');
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
setMessage(result.message || translatedLabels.failed);
|
|
54
|
-
setVerificationStatus('error');
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
catch {
|
|
58
|
-
setMessage(translatedLabels.failed);
|
|
59
|
-
setVerificationStatus('error');
|
|
60
|
-
}
|
|
61
|
-
finally {
|
|
62
|
-
setLoading(false);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
verifyEmail();
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
hasVerified.current = true;
|
|
69
|
-
setLoading(false);
|
|
70
|
-
setVerificationStatus('info');
|
|
71
|
-
}
|
|
72
|
-
}, [token, translatedLabels]);
|
|
73
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Container, { maxWidth: "sm", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
74
|
-
mt: 8,
|
|
75
|
-
display: 'flex',
|
|
76
|
-
flexDirection: 'column',
|
|
77
|
-
alignItems: 'center',
|
|
78
|
-
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: translatedLabels.title }), loading ? ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, {})) : ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { width: '100%', mt: 2 }, children: verificationStatus === 'info' ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "info", sx: { mb: 2 }, children: translatedLabels.noToken }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body1", children: [translatedLabels.contactSupport, ' ', (0, jsx_runtime_1.jsx)(material_1.Link, { href: resendLink, color: "primary", children: translatedLabels.requestNewEmail }), "."] })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Alert, { severity: verificationStatus === 'success' ? 'success' : 'error', sx: { mb: 2 }, children: message }), verificationStatus === 'success' && ((0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", color: "primary", component: material_1.Link, href: loginLink, fullWidth: true, children: translatedLabels.proceedToLogin })), verificationStatus === 'error' && ((0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body1", children: [translatedLabels.contactSupport, ' ', (0, jsx_runtime_1.jsx)(material_1.Link, { href: resendLink, color: "primary", children: translatedLabels.requestNewEmail }), "."] }))] })) }))] }) }));
|
|
79
|
-
};
|
|
80
|
-
exports.VerifyEmailPage = VerifyEmailPage;
|
|
81
|
-
exports.default = exports.VerifyEmailPage;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,KAAK,CAAC;AACpB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC"}
|
package/src/components/index.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
// Component exports
|
|
5
|
-
tslib_1.__exportStar(require("./ApiAccess"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./BackupCodeLoginForm"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./BackupCodesForm"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./CategoryMenu"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./ChangePasswordForm"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./ConfirmationDialog"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./CurrencyCodeSelector"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./CurrencyInput"), exports);
|
|
13
|
-
tslib_1.__exportStar(require("./DashboardPage"), exports);
|
|
14
|
-
tslib_1.__exportStar(require("./DropdownMenu"), exports);
|
|
15
|
-
tslib_1.__exportStar(require("./ExpirationSecondsSelector"), exports);
|
|
16
|
-
tslib_1.__exportStar(require("./FakeEmailAdminPanel"), exports);
|
|
17
|
-
tslib_1.__exportStar(require("./Flag"), exports);
|
|
18
|
-
tslib_1.__exportStar(require("./ForgotPasswordForm"), exports);
|
|
19
|
-
tslib_1.__exportStar(require("./LoginForm"), exports);
|
|
20
|
-
tslib_1.__exportStar(require("./LogoutPage"), exports);
|
|
21
|
-
tslib_1.__exportStar(require("./RegisterForm"), exports);
|
|
22
|
-
tslib_1.__exportStar(require("./ResetPasswordForm"), exports);
|
|
23
|
-
tslib_1.__exportStar(require("./UserSettingsForm"), exports);
|
|
24
|
-
tslib_1.__exportStar(require("./SideMenu"), exports);
|
|
25
|
-
tslib_1.__exportStar(require("./SideMenuListItem"), exports);
|
|
26
|
-
tslib_1.__exportStar(require("./TopMenu"), exports);
|
|
27
|
-
tslib_1.__exportStar(require("./TranslatedTitle"), exports);
|
|
28
|
-
tslib_1.__exportStar(require("./UserMenu"), exports);
|
|
29
|
-
tslib_1.__exportStar(require("./UserLanguageSelector"), exports);
|
|
30
|
-
tslib_1.__exportStar(require("./VerifyEmailPage"), exports);
|
|
31
|
-
tslib_1.__exportStar(require("./T"), exports);
|
|
32
|
-
tslib_1.__exportStar(require("./TDiv"), exports);
|
|
33
|
-
tslib_1.__exportStar(require("./TImgAlt"), exports);
|
|
34
|
-
tslib_1.__exportStar(require("./TotpSetupForm"), exports);
|
|
35
|
-
tslib_1.__exportStar(require("./TotpVerificationForm"), exports);
|