@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,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useEmailVerification = void 0;
|
|
4
|
-
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const contexts_1 = require("../contexts");
|
|
7
|
-
const services_1 = require("../services");
|
|
8
|
-
const useEmailVerification = () => {
|
|
9
|
-
const { baseUrl } = (0, contexts_1.useSuiteConfig)();
|
|
10
|
-
const api = (0, react_1.useMemo)(() => (0, services_1.createAuthenticatedApiClient)(baseUrl), [baseUrl]);
|
|
11
|
-
const [isVerifying, setIsVerifying] = (0, react_1.useState)(false);
|
|
12
|
-
const [error, setError] = (0, react_1.useState)(null);
|
|
13
|
-
const verifyEmail = (0, react_1.useCallback)(async (verificationToken) => {
|
|
14
|
-
setIsVerifying(true);
|
|
15
|
-
setError(null);
|
|
16
|
-
try {
|
|
17
|
-
const result = await api.post('/user/verify-email', {
|
|
18
|
-
token: verificationToken,
|
|
19
|
-
});
|
|
20
|
-
return { success: true, message: result.data.message };
|
|
21
|
-
}
|
|
22
|
-
catch (err) {
|
|
23
|
-
const axiosError = err;
|
|
24
|
-
const errorMessage = axiosError.response?.data?.message ||
|
|
25
|
-
(0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Error_VerificationFailed);
|
|
26
|
-
const error = new Error(errorMessage);
|
|
27
|
-
setError(error);
|
|
28
|
-
return { success: false, message: errorMessage };
|
|
29
|
-
}
|
|
30
|
-
finally {
|
|
31
|
-
setIsVerifying(false);
|
|
32
|
-
}
|
|
33
|
-
}, [api]);
|
|
34
|
-
return {
|
|
35
|
-
isVerifying,
|
|
36
|
-
error,
|
|
37
|
-
verifyEmail,
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
exports.useEmailVerification = useEmailVerification;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface TimerInfo {
|
|
2
|
-
timeout: NodeJS.Timeout;
|
|
3
|
-
startTime: number;
|
|
4
|
-
durationMs: number;
|
|
5
|
-
}
|
|
6
|
-
export interface ExpiringValueReturn<T> {
|
|
7
|
-
value: T | undefined;
|
|
8
|
-
setValue: (newValue: T, durationSeconds?: number, saveToStorage?: boolean) => () => void;
|
|
9
|
-
clearValue: () => void;
|
|
10
|
-
getRemainingTime: () => number;
|
|
11
|
-
isActive: boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare function useExpiringValue<T>(defaultDurationSeconds: number, localStorageKey?: string): ExpiringValueReturn<T>;
|
|
14
|
-
//# sourceMappingURL=useExpiringValue.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useExpiringValue.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/hooks/useExpiringValue.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC;IACrB,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,eAAe,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,OAAO,KAAK,MAAM,IAAI,CAAC;IACzF,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,gBAAgB,EAAE,MAAM,MAAM,CAAC;IAC/B,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,sBAAsB,EAAE,MAAM,EAC9B,eAAe,CAAC,EAAE,MAAM,GACvB,mBAAmB,CAAC,CAAC,CAAC,CA0DxB"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useExpiringValue = useExpiringValue;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
function useExpiringValue(defaultDurationSeconds, localStorageKey) {
|
|
6
|
-
const [value, _setValue] = (0, react_1.useState)(undefined);
|
|
7
|
-
const [timer, setTimer] = (0, react_1.useState)(undefined);
|
|
8
|
-
const [durationSeconds, _setDurationSeconds] = (0, react_1.useState)(() => {
|
|
9
|
-
if (localStorageKey) {
|
|
10
|
-
const stored = localStorage.getItem(localStorageKey);
|
|
11
|
-
return stored ? parseInt(stored, 10) : defaultDurationSeconds;
|
|
12
|
-
}
|
|
13
|
-
return defaultDurationSeconds;
|
|
14
|
-
});
|
|
15
|
-
const getRemainingTime = (0, react_1.useCallback)(() => {
|
|
16
|
-
if (!timer)
|
|
17
|
-
return 0;
|
|
18
|
-
const elapsed = Date.now() - timer.startTime;
|
|
19
|
-
const remaining = Math.max(0, timer.durationMs - elapsed);
|
|
20
|
-
return Math.ceil(remaining / 1000);
|
|
21
|
-
}, [timer]);
|
|
22
|
-
const setValue = (0, react_1.useCallback)((newValue, customDurationSeconds, saveToStorage) => {
|
|
23
|
-
const finalDurationSeconds = customDurationSeconds ?? durationSeconds;
|
|
24
|
-
if (saveToStorage && customDurationSeconds !== undefined && localStorageKey) {
|
|
25
|
-
_setDurationSeconds(customDurationSeconds);
|
|
26
|
-
localStorage.setItem(localStorageKey, customDurationSeconds.toString());
|
|
27
|
-
}
|
|
28
|
-
_setValue(newValue);
|
|
29
|
-
if (timer) {
|
|
30
|
-
clearTimeout(timer.timeout);
|
|
31
|
-
}
|
|
32
|
-
const startTime = Date.now();
|
|
33
|
-
const durationMs = finalDurationSeconds * 1000;
|
|
34
|
-
const timeout = setTimeout(() => {
|
|
35
|
-
_setValue(undefined);
|
|
36
|
-
setTimer(undefined);
|
|
37
|
-
}, durationMs);
|
|
38
|
-
setTimer({ timeout, startTime, durationMs });
|
|
39
|
-
return () => {
|
|
40
|
-
clearTimeout(timeout);
|
|
41
|
-
setTimer(undefined);
|
|
42
|
-
};
|
|
43
|
-
}, [durationSeconds, timer, localStorageKey]);
|
|
44
|
-
const clearValue = (0, react_1.useCallback)(() => {
|
|
45
|
-
if (timer) {
|
|
46
|
-
clearTimeout(timer.timeout);
|
|
47
|
-
setTimer(undefined);
|
|
48
|
-
}
|
|
49
|
-
_setValue(undefined);
|
|
50
|
-
}, [timer]);
|
|
51
|
-
const isActive = Boolean(timer && value !== undefined);
|
|
52
|
-
return { value, setValue, clearValue, getRemainingTime, isActive };
|
|
53
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLocalStorage.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/hooks/useLocalStorage.ts"],"names":[],"mappings":"AAGA,wBAAgB,eAAe,CAAC,CAAC,EAC/B,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,CAAC,GACd,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,CAWzB"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useLocalStorage = useLocalStorage;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
6
|
-
function useLocalStorage(key, defaultValue) {
|
|
7
|
-
const [storedValue, setStoredValue] = (0, react_1.useState)(() => {
|
|
8
|
-
return suite_core_lib_1.LocalStorageManager.getValue(key, defaultValue);
|
|
9
|
-
});
|
|
10
|
-
const setValue = (0, react_1.useCallback)((value) => {
|
|
11
|
-
setStoredValue(value);
|
|
12
|
-
suite_core_lib_1.LocalStorageManager.setValue(key, value);
|
|
13
|
-
}, [key]);
|
|
14
|
-
return [storedValue, setValue];
|
|
15
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { IUserSettings, IUserSettingsDTO } from '@digitaldefiance/suite-core-lib';
|
|
2
|
-
export interface UseUserSettingsOptions {
|
|
3
|
-
authenticatedApi: {
|
|
4
|
-
post: <T = unknown>(url: string, data: Record<string, unknown>) => Promise<{
|
|
5
|
-
data: T;
|
|
6
|
-
}>;
|
|
7
|
-
};
|
|
8
|
-
isAuthenticated: boolean;
|
|
9
|
-
}
|
|
10
|
-
export interface UseUserSettingsResult {
|
|
11
|
-
currentLanguage: string;
|
|
12
|
-
changeLanguage: (languageCode: string) => Promise<void>;
|
|
13
|
-
userSettings: IUserSettings | undefined;
|
|
14
|
-
setUserSettingAndUpdateSettings: (setting?: Partial<IUserSettings>) => Promise<void>;
|
|
15
|
-
toggleColorMode: () => Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Hook for managing user settings state and synchronization.
|
|
19
|
-
* Used by AuthProvider to handle user settings logic.
|
|
20
|
-
*/
|
|
21
|
-
export declare const useUserSettings: ({ authenticatedApi, isAuthenticated, }: UseUserSettingsOptions) => UseUserSettingsResult;
|
|
22
|
-
export interface UserSettingsValues extends IUserSettingsDTO {
|
|
23
|
-
[key: string]: string | boolean | undefined;
|
|
24
|
-
}
|
|
25
|
-
export interface UseUserSettingsPublicResult {
|
|
26
|
-
settings: UserSettingsValues | null;
|
|
27
|
-
isLoading: boolean;
|
|
28
|
-
error: Error | null;
|
|
29
|
-
updateSettings: (values: UserSettingsValues) => Promise<{
|
|
30
|
-
success: boolean;
|
|
31
|
-
message: string;
|
|
32
|
-
} | {
|
|
33
|
-
error: string;
|
|
34
|
-
errorType?: string;
|
|
35
|
-
field?: string;
|
|
36
|
-
errors?: Array<{
|
|
37
|
-
path: string;
|
|
38
|
-
msg: string;
|
|
39
|
-
}>;
|
|
40
|
-
}>;
|
|
41
|
-
refreshSettings: () => Promise<void>;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Public hook for components to manage user settings.
|
|
45
|
-
* Provides a simpler API for fetching and updating settings.
|
|
46
|
-
*/
|
|
47
|
-
export declare const useUserSettingsPublic: () => UseUserSettingsPublicResult;
|
|
48
|
-
//# sourceMappingURL=useUserSettings.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useUserSettings.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/hooks/useUserSettings.ts"],"names":[],"mappings":"AAQA,OAAO,EAGL,aAAa,EACb,gBAAgB,EAGjB,MAAM,iCAAiC,CAAC;AAYzC,MAAM,WAAW,sBAAsB;IACrC,gBAAgB,EAAE;QAChB,IAAI,EAAE,CAAC,CAAC,GAAG,OAAO,EAChB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC1B,OAAO,CAAC;YAAE,IAAI,EAAE,CAAC,CAAA;SAAE,CAAC,CAAC;KAC3B,CAAC;IACF,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,YAAY,EAAE,aAAa,GAAG,SAAS,CAAC;IACxC,+BAA+B,EAAE,CAC/B,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,KAC7B,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,eAAe,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,wCAG7B,sBAAsB,KAAG,qBAsF3B,CAAC;AAGF,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;IAC1D,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CAC7C;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACpC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,cAAc,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,OAAO,CACnD;QACE,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;KACjB,GACD;QACE,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAC/C,CACJ,CAAC;IACF,eAAe,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,QAAO,2BAoGxC,CAAC"}
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useUserSettingsPublic = exports.useUserSettings = void 0;
|
|
4
|
-
const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
|
|
5
|
-
const i18n_lib_1 = require("@digitaldefiance/i18n-lib");
|
|
6
|
-
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
7
|
-
const react_1 = require("react");
|
|
8
|
-
const contexts_1 = require("../contexts");
|
|
9
|
-
const defaultUserSettings = {
|
|
10
|
-
darkMode: false,
|
|
11
|
-
currency: new i18n_lib_1.CurrencyCode(i18n_lib_1.DefaultCurrencyCode),
|
|
12
|
-
timezone: new i18n_lib_1.Timezone(i18n_lib_1.DefaultTimezone),
|
|
13
|
-
siteLanguage: i18n_lib_1.DefaultLanguageCode,
|
|
14
|
-
directChallenge: false,
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Hook for managing user settings state and synchronization.
|
|
18
|
-
* Used by AuthProvider to handle user settings logic.
|
|
19
|
-
*/
|
|
20
|
-
const useUserSettings = ({ authenticatedApi, isAuthenticated, }) => {
|
|
21
|
-
const { setColorMode: themeSetPaletteMode, mode: currentThemeMode } = (0, contexts_1.useTheme)();
|
|
22
|
-
const { currentLanguage, changeLanguage } = (0, contexts_1.useI18n)();
|
|
23
|
-
const [userSettings, setUserSettings] = (0, react_1.useState)(undefined);
|
|
24
|
-
const setUserSettingAndUpdateSettings = (0, react_1.useCallback)(async (setting) => {
|
|
25
|
-
if (setting) {
|
|
26
|
-
// Merge settings with defaults and existing settings
|
|
27
|
-
const merged = {
|
|
28
|
-
...defaultUserSettings,
|
|
29
|
-
...(userSettings ? userSettings : {}),
|
|
30
|
-
...setting,
|
|
31
|
-
};
|
|
32
|
-
// TypeScript requires all IUserSettings fields, but during initialization
|
|
33
|
-
// some fields like email may not be set yet. We'll use Partial until
|
|
34
|
-
// all required fields are available.
|
|
35
|
-
setUserSettings(merged);
|
|
36
|
-
if (setting.darkMode !== undefined) {
|
|
37
|
-
themeSetPaletteMode(setting.darkMode ? 'dark' : 'light');
|
|
38
|
-
}
|
|
39
|
-
if (setting.siteLanguage !== undefined &&
|
|
40
|
-
setting.siteLanguage !== currentLanguage) {
|
|
41
|
-
await changeLanguage(setting.siteLanguage);
|
|
42
|
-
}
|
|
43
|
-
// Send to server if authenticated and we have complete settings (including email)
|
|
44
|
-
if (isAuthenticated && merged.email) {
|
|
45
|
-
const dehydratedSettings = (0, suite_core_lib_1.dehydrateUserSettings)(merged);
|
|
46
|
-
await authenticatedApi.post('/user/settings', dehydratedSettings);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
setUserSettings(undefined);
|
|
51
|
-
themeSetPaletteMode('light');
|
|
52
|
-
}
|
|
53
|
-
}, [
|
|
54
|
-
isAuthenticated,
|
|
55
|
-
userSettings,
|
|
56
|
-
currentLanguage,
|
|
57
|
-
changeLanguage,
|
|
58
|
-
themeSetPaletteMode,
|
|
59
|
-
authenticatedApi,
|
|
60
|
-
]);
|
|
61
|
-
const changeLanguageSetting = (0, react_1.useCallback)(async (languageCode) => {
|
|
62
|
-
await setUserSettingAndUpdateSettings({ siteLanguage: languageCode });
|
|
63
|
-
}, [setUserSettingAndUpdateSettings]);
|
|
64
|
-
const toggleColorMode = (0, react_1.useCallback)(async () => {
|
|
65
|
-
// When not authenticated, read from the current theme mode
|
|
66
|
-
// When authenticated, read from userSettings (synced with server)
|
|
67
|
-
const currentDarkMode = isAuthenticated
|
|
68
|
-
? userSettings?.darkMode ?? false
|
|
69
|
-
: currentThemeMode === 'dark';
|
|
70
|
-
await setUserSettingAndUpdateSettings({ darkMode: !currentDarkMode });
|
|
71
|
-
}, [
|
|
72
|
-
isAuthenticated,
|
|
73
|
-
userSettings?.darkMode,
|
|
74
|
-
currentThemeMode,
|
|
75
|
-
setUserSettingAndUpdateSettings,
|
|
76
|
-
]);
|
|
77
|
-
return {
|
|
78
|
-
changeLanguage: changeLanguageSetting,
|
|
79
|
-
currentLanguage,
|
|
80
|
-
userSettings,
|
|
81
|
-
setUserSettingAndUpdateSettings,
|
|
82
|
-
toggleColorMode,
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
exports.useUserSettings = useUserSettings;
|
|
86
|
-
/**
|
|
87
|
-
* Public hook for components to manage user settings.
|
|
88
|
-
* Provides a simpler API for fetching and updating settings.
|
|
89
|
-
*/
|
|
90
|
-
const useUserSettingsPublic = () => {
|
|
91
|
-
const { userData, setUserSetting, userSettings } = (0, contexts_1.useAuth)();
|
|
92
|
-
const [settings, setSettings] = (0, react_1.useState)(null);
|
|
93
|
-
const [isLoading, setIsLoading] = (0, react_1.useState)(true);
|
|
94
|
-
const [error, setError] = (0, react_1.useState)(null);
|
|
95
|
-
const refreshSettings = (0, react_1.useCallback)(async () => {
|
|
96
|
-
setIsLoading(true);
|
|
97
|
-
setError(null);
|
|
98
|
-
try {
|
|
99
|
-
if (userSettings) {
|
|
100
|
-
const dehydratedSettings = (0, suite_core_lib_1.dehydrateUserSettings)(userSettings);
|
|
101
|
-
setSettings(dehydratedSettings);
|
|
102
|
-
}
|
|
103
|
-
else if (userData) {
|
|
104
|
-
const fallback = {
|
|
105
|
-
email: userData.email || '',
|
|
106
|
-
timezone: userData.timezone || 'UTC',
|
|
107
|
-
siteLanguage: userData.siteLanguage || 'en-US',
|
|
108
|
-
currency: userData.currency || 'USD',
|
|
109
|
-
darkMode: userData.darkMode || false,
|
|
110
|
-
directChallenge: userData.directChallenge || false,
|
|
111
|
-
...(userData.displayName !== undefined ? { displayName: userData.displayName } : {}),
|
|
112
|
-
};
|
|
113
|
-
setSettings(fallback);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
catch (err) {
|
|
117
|
-
setError(err instanceof Error
|
|
118
|
-
? err
|
|
119
|
-
: new suite_core_lib_1.TranslatableSuiteError(suite_core_lib_1.SuiteCoreStringKey.Settings_RetrieveFailure));
|
|
120
|
-
}
|
|
121
|
-
finally {
|
|
122
|
-
setIsLoading(false);
|
|
123
|
-
}
|
|
124
|
-
}, [userSettings, userData]);
|
|
125
|
-
(0, react_1.useEffect)(() => {
|
|
126
|
-
refreshSettings();
|
|
127
|
-
}, [refreshSettings]);
|
|
128
|
-
const updateSettings = (0, react_1.useCallback)(async (values) => {
|
|
129
|
-
setIsLoading(true);
|
|
130
|
-
setError(null);
|
|
131
|
-
try {
|
|
132
|
-
await setUserSetting({
|
|
133
|
-
darkMode: values.darkMode,
|
|
134
|
-
currency: new i18n_lib_1.CurrencyCode(values.currency),
|
|
135
|
-
timezone: new i18n_lib_1.Timezone(values.timezone),
|
|
136
|
-
siteLanguage: values.siteLanguage,
|
|
137
|
-
email: new ecies_lib_1.EmailString(values.email),
|
|
138
|
-
directChallenge: values.directChallenge,
|
|
139
|
-
...(values.displayName !== undefined ? { displayName: values.displayName } : {}),
|
|
140
|
-
});
|
|
141
|
-
setSettings(values);
|
|
142
|
-
return {
|
|
143
|
-
success: true,
|
|
144
|
-
message: (0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Settings_SaveSuccess),
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
catch (err) {
|
|
148
|
-
const axiosError = err;
|
|
149
|
-
const errorMessage = axiosError.response?.data?.message ||
|
|
150
|
-
(0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Settings_UpdateFailed);
|
|
151
|
-
setError(err instanceof Error ? err : new Error(errorMessage));
|
|
152
|
-
return {
|
|
153
|
-
error: errorMessage,
|
|
154
|
-
errorType: axiosError.response?.data?.errorType,
|
|
155
|
-
field: axiosError.response?.data?.field,
|
|
156
|
-
errors: axiosError.response?.data?.errors,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
finally {
|
|
160
|
-
setIsLoading(false);
|
|
161
|
-
}
|
|
162
|
-
}, [setUserSetting]);
|
|
163
|
-
return {
|
|
164
|
-
settings,
|
|
165
|
-
isLoading,
|
|
166
|
-
error,
|
|
167
|
-
updateSettings,
|
|
168
|
-
refreshSettings,
|
|
169
|
-
};
|
|
170
|
-
};
|
|
171
|
-
exports.useUserSettingsPublic = useUserSettingsPublic;
|
package/src/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-express-suite-react-components/src/index.ts"],"names":[],"mappings":"AACA,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
|
package/src/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
// Export all components
|
|
5
|
-
tslib_1.__exportStar(require("./auth"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./components"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./contexts"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./hooks"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./interfaces"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./services"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./types"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./wrappers"), exports);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IAppConfig.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/interfaces/IAppConfig.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { ReactElement, ReactNode } from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Configuration for a TopMenu category (mega-menu container).
|
|
4
|
-
*
|
|
5
|
-
* Categories let you group multiple icon dropdowns under a single AppBar
|
|
6
|
-
* button. Menus opt into a category by setting `IMenuConfig.category` (or
|
|
7
|
-
* `AdditionalDropdownMenu.category`) to this category's `id`. The TopMenu
|
|
8
|
-
* renders one icon button per category that has at least one matching menu;
|
|
9
|
-
* clicking it opens a popover containing the matching menus as icon tiles.
|
|
10
|
-
*
|
|
11
|
-
* Backwards compatibility: if `TopMenu` is not given a `categories` array,
|
|
12
|
-
* or if a menu does not declare a `category`, it renders inline in the AppBar
|
|
13
|
-
* exactly as before.
|
|
14
|
-
*/
|
|
15
|
-
export interface ICategoryConfig {
|
|
16
|
-
/** Unique identifier referenced by `IMenuConfig.category`. */
|
|
17
|
-
id: string;
|
|
18
|
-
/** Icon shown on the AppBar trigger button. */
|
|
19
|
-
icon: ReactElement;
|
|
20
|
-
/**
|
|
21
|
-
* Optional accessible label / tooltip / panel header. Plain string for
|
|
22
|
-
* tooltip; render-prop or node for the panel header if `showHeader` is true.
|
|
23
|
-
*/
|
|
24
|
-
label?: string;
|
|
25
|
-
/** Optional header content shown above the tile grid when `showHeader` is true. */
|
|
26
|
-
header?: ReactNode;
|
|
27
|
-
/** Show the `header` (or `label`) above the tile grid. Defaults to false. */
|
|
28
|
-
showHeader?: boolean;
|
|
29
|
-
/** Show the menu label under each tile inside the popover. Defaults to true. */
|
|
30
|
-
showLabels?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Sort order for placement in the AppBar. Higher numbers render first
|
|
33
|
-
* (same convention as `IMenuConfig.priority`). Defaults to 0.
|
|
34
|
-
*/
|
|
35
|
-
priority?: number;
|
|
36
|
-
/** Number of tile columns in the popover grid. Defaults to 3. */
|
|
37
|
-
columns?: number;
|
|
38
|
-
/** Hide the category trigger when it has no matching menus. Defaults to true. */
|
|
39
|
-
hideWhenEmpty?: boolean;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=ICategoryConfig.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ICategoryConfig.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/interfaces/ICategoryConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEhD;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,eAAe;IAC9B,8DAA8D;IAC9D,EAAE,EAAE,MAAM,CAAC;IACX,+CAA+C;IAC/C,IAAI,EAAE,YAAY,CAAC;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mFAAmF;IACnF,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,6EAA6E;IAC7E,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gFAAgF;IAChF,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { IMenuOption } from './IMenuOption';
|
|
3
|
-
import { createMenuType } from '../types';
|
|
4
|
-
export interface IMenuConfig {
|
|
5
|
-
menuType: ReturnType<typeof createMenuType>;
|
|
6
|
-
menuIcon: ReactElement;
|
|
7
|
-
priority?: number;
|
|
8
|
-
options: IMenuOption[];
|
|
9
|
-
isUserMenu?: boolean;
|
|
10
|
-
/** Optional callback invoked when the icon button is clicked. */
|
|
11
|
-
action?: () => void;
|
|
12
|
-
/** When true, the menu icon is hidden if there are no sub-options. Defaults to false. */
|
|
13
|
-
hideWhenEmpty?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Optional category identifier. When the TopMenu is configured with matching
|
|
16
|
-
* `categories`, this menu is rendered as a tile inside that category's
|
|
17
|
-
* mega-menu popover instead of inline in the AppBar. When omitted (or no
|
|
18
|
-
* matching category exists), the menu renders inline as a normal dropdown.
|
|
19
|
-
*/
|
|
20
|
-
category?: string;
|
|
21
|
-
/**
|
|
22
|
-
* Optional human-readable label. When the menu is rendered as a tile inside
|
|
23
|
-
* a category popover with `showLabels` enabled, this is shown under the icon.
|
|
24
|
-
* Also used as the IconButton tooltip. Falls back to `menuType` when omitted.
|
|
25
|
-
*/
|
|
26
|
-
label?: string;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=IMenuConfig.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IMenuConfig.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/interfaces/IMenuConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;IAC5C,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,yFAAyF;IACzF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { To } from 'react-router';
|
|
3
|
-
import { MenuType } from '../types/MenuType';
|
|
4
|
-
import { SxProps } from '@mui/system';
|
|
5
|
-
import { Theme } from '@mui/material';
|
|
6
|
-
export interface IMenuOption {
|
|
7
|
-
/**
|
|
8
|
-
* Unique identifier for the menu option
|
|
9
|
-
*/
|
|
10
|
-
id: string;
|
|
11
|
-
/**
|
|
12
|
-
* Text to display for the menu option
|
|
13
|
-
*/
|
|
14
|
-
label: string | ReactNode | Array<ReactNode>;
|
|
15
|
-
/**
|
|
16
|
-
* Where the menu option should be displayed
|
|
17
|
-
*/
|
|
18
|
-
includeOnMenus: MenuType[];
|
|
19
|
-
/**
|
|
20
|
-
* Display order for the menu option. Lower numbers are displayed first.
|
|
21
|
-
*/
|
|
22
|
-
index: number;
|
|
23
|
-
/**
|
|
24
|
-
* Whether the menu option is a divider
|
|
25
|
-
*/
|
|
26
|
-
divider?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Icon to display for the menu option
|
|
29
|
-
*/
|
|
30
|
-
icon?: ReactNode;
|
|
31
|
-
/**
|
|
32
|
-
* Link to navigate to when the menu option is clicked
|
|
33
|
-
* Mutually exclusive with `action`
|
|
34
|
-
* Can be a string, a react-router To object, or an object with pathname and optional state
|
|
35
|
-
*/
|
|
36
|
-
link?: To | {
|
|
37
|
-
pathname: string;
|
|
38
|
-
state?: unknown;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Function to execute when the menu option is clicked
|
|
42
|
-
* Mutually exclusive with `link`
|
|
43
|
-
* @returns void
|
|
44
|
-
*/
|
|
45
|
-
action?: () => void;
|
|
46
|
-
/**
|
|
47
|
-
* Whether the menu option requires authentication
|
|
48
|
-
* true = requires authentication
|
|
49
|
-
* false = requires unauthenticated
|
|
50
|
-
* undefined = always show
|
|
51
|
-
*/
|
|
52
|
-
requiresAuth: boolean | undefined;
|
|
53
|
-
/**
|
|
54
|
-
* Whether the menu option requires the user to be a global admin
|
|
55
|
-
* true = only show to global admins
|
|
56
|
-
* undefined/false = no admin requirement
|
|
57
|
-
*/
|
|
58
|
-
requiresAdmin?: boolean;
|
|
59
|
-
/**
|
|
60
|
-
* Custom filter function to determine if the menu option should be displayed
|
|
61
|
-
* @param option - The menu option to filter
|
|
62
|
-
* @returns boolean
|
|
63
|
-
*/
|
|
64
|
-
filter?: (option: IMenuOption) => boolean;
|
|
65
|
-
/**
|
|
66
|
-
* Additional CSS properties
|
|
67
|
-
*/
|
|
68
|
-
additionalSx?: SxProps<Theme>;
|
|
69
|
-
/**
|
|
70
|
-
* Additional CSS properties for the side menu variant
|
|
71
|
-
*/
|
|
72
|
-
sideSx?: SxProps<Theme>;
|
|
73
|
-
/**
|
|
74
|
-
* Additional CSS properties for the side menu variant Icon sub item
|
|
75
|
-
*/
|
|
76
|
-
sideIconSx?: SxProps<Theme>;
|
|
77
|
-
/**
|
|
78
|
-
* Additional CSS properties for the side menu variant Text sub item
|
|
79
|
-
*/
|
|
80
|
-
sideTextSx?: SxProps<Theme>;
|
|
81
|
-
}
|
|
82
|
-
//# sourceMappingURL=IMenuOption.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IMenuOption.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/interfaces/IMenuOption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;IAC7C;;OAEG;IACH,cAAc,EAAE,QAAQ,EAAE,CAAC;IAC3B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;;OAIG;IACH,IAAI,CAAC,EAAE,EAAE,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAClD;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB;;;;;OAKG;IACH,YAAY,EAAE,OAAO,GAAG,SAAS,CAAC;IAClC;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC;IAC1C;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9B;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACxB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAC5B;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;CAC7B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC"}
|
package/src/interfaces/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./IAppConfig"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./IMenuOption"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./IMenuConfig"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./ICategoryConfig"), exports);
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export declare const mockAuthService: {
|
|
2
|
-
verifyToken: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
3
|
-
directLogin: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
4
|
-
emailChallengeLogin: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
5
|
-
refreshToken: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
6
|
-
register: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
7
|
-
requestEmailLogin: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
8
|
-
backupCodeLogin: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
9
|
-
changePassword: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
10
|
-
};
|
|
11
|
-
export declare const createAuthService: import("jest-mock").Mock<() => {
|
|
12
|
-
verifyToken: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
13
|
-
directLogin: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
14
|
-
emailChallengeLogin: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
15
|
-
refreshToken: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
16
|
-
register: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
17
|
-
requestEmailLogin: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
18
|
-
backupCodeLogin: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
19
|
-
changePassword: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
20
|
-
}>;
|
|
21
|
-
//# sourceMappingURL=authService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authService.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-express-suite-react-components/src/services/__mocks__/authService.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;;;;;;;;CAS3B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;EAAiC,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAuthService = exports.mockAuthService = void 0;
|
|
4
|
-
const globals_1 = require("@jest/globals");
|
|
5
|
-
exports.mockAuthService = {
|
|
6
|
-
verifyToken: globals_1.jest.fn(),
|
|
7
|
-
directLogin: globals_1.jest.fn(),
|
|
8
|
-
emailChallengeLogin: globals_1.jest.fn(),
|
|
9
|
-
refreshToken: globals_1.jest.fn(),
|
|
10
|
-
register: globals_1.jest.fn(),
|
|
11
|
-
requestEmailLogin: globals_1.jest.fn(),
|
|
12
|
-
backupCodeLogin: globals_1.jest.fn(),
|
|
13
|
-
changePassword: globals_1.jest.fn(),
|
|
14
|
-
};
|
|
15
|
-
exports.createAuthService = globals_1.jest.fn(() => exports.mockAuthService);
|
package/src/services/api.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/services/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,uBAU9C"}
|