@digitaldefiance/express-suite-react-components 2.9.1 → 2.9.3
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 +11 -7
- 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} +1 -2
- package/src/components/ApiAccess.tsx +134 -0
- package/src/components/BackupCodeLoginForm.tsx +314 -0
- package/src/components/BackupCodesForm.tsx +198 -0
- package/src/components/ChangePasswordForm.tsx +182 -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 +92 -0
- package/src/components/ExpirationSecondsSelector.tsx +65 -0
- package/src/components/Flag.tsx +53 -0
- package/src/components/ForgotPasswordForm.tsx +120 -0
- package/src/components/LoginForm.tsx +307 -0
- package/src/components/LogoutPage.tsx +21 -0
- package/src/components/RegisterForm.tsx +354 -0
- package/src/components/ResetPasswordForm.tsx +164 -0
- package/src/components/SideMenu.tsx +46 -0
- package/src/components/SideMenuListItem.tsx +74 -0
- package/src/components/TopMenu.tsx +134 -0
- package/src/components/TranslatedTitle.tsx +22 -0
- package/src/components/UserLanguageSelector.tsx +45 -0
- package/src/components/UserMenu.tsx +15 -0
- package/src/components/UserSettingsForm.tsx +328 -0
- package/src/components/VerifyEmailPage.tsx +133 -0
- package/src/components/{index.d.ts → index.ts} +1 -1
- package/src/contexts/AuthProvider.spec.tsx +1060 -0
- package/src/contexts/AuthProvider.tsx +741 -0
- package/src/contexts/I18nProvider.tsx +85 -0
- package/src/contexts/MenuContext.tsx +310 -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/useBackupCodes.ts +85 -0
- package/src/hooks/useEmailVerification.ts +39 -0
- package/src/hooks/useExpiringValue.ts +78 -0
- package/src/hooks/useLocalStorage.ts +18 -0
- package/src/hooks/useUserSettings.ts +216 -0
- package/src/{index.d.ts → index.ts} +1 -1
- package/src/interfaces/IAppConfig.ts +5 -0
- package/src/interfaces/IMenuConfig.ts +11 -0
- package/src/interfaces/IMenuOption.ts +55 -0
- package/src/interfaces/index.ts +3 -0
- package/src/services/__mocks__/authService.ts +14 -0
- package/src/services/api.ts +13 -0
- package/src/services/authService.ts +422 -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 +35 -0
- package/src/wrappers/BackupCodesWrapper.tsx +28 -0
- package/src/wrappers/ChangePasswordFormWrapper.tsx +31 -0
- package/src/wrappers/LoginFormWrapper.tsx +59 -0
- package/src/wrappers/LogoutPageWrapper.tsx +30 -0
- package/src/wrappers/RegisterFormWrapper.tsx +48 -0
- package/src/wrappers/UserSettingsFormWrapper.tsx +39 -0
- package/src/wrappers/VerifyEmailPageWrapper.tsx +27 -0
- package/src/wrappers/{index.d.ts → index.tsx} +8 -1
- 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 -10
- package/src/components/ApiAccess.d.ts +0 -16
- package/src/components/ApiAccess.d.ts.map +0 -1
- package/src/components/ApiAccess.js +0 -70
- package/src/components/BackupCodeLoginForm.d.ts +0 -43
- package/src/components/BackupCodeLoginForm.d.ts.map +0 -1
- package/src/components/BackupCodeLoginForm.js +0 -106
- package/src/components/BackupCodesForm.d.ts +0 -26
- package/src/components/BackupCodesForm.d.ts.map +0 -1
- package/src/components/BackupCodesForm.js +0 -108
- package/src/components/ChangePasswordForm.d.ts +0 -26
- package/src/components/ChangePasswordForm.d.ts.map +0 -1
- package/src/components/ChangePasswordForm.js +0 -66
- 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 -9
- package/src/components/DropdownMenu.d.ts.map +0 -1
- package/src/components/DropdownMenu.js +0 -56
- 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/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 -54
- package/src/components/LoginForm.d.ts +0 -44
- package/src/components/LoginForm.d.ts.map +0 -1
- package/src/components/LoginForm.js +0 -99
- 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 -54
- package/src/components/RegisterForm.d.ts.map +0 -1
- package/src/components/RegisterForm.js +0 -105
- package/src/components/ResetPasswordForm.d.ts +0 -23
- package/src/components/ResetPasswordForm.d.ts.map +0 -1
- package/src/components/ResetPasswordForm.js +0 -68
- 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/TopMenu.d.ts +0 -24
- package/src/components/TopMenu.d.ts.map +0 -1
- package/src/components/TopMenu.js +0 -36
- package/src/components/TranslatedTitle.d.ts +0 -7
- 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 -56
- package/src/components/UserSettingsForm.d.ts.map +0 -1
- package/src/components/UserSettingsForm.js +0 -93
- package/src/components/VerifyEmailPage.d.ts +0 -23
- package/src/components/VerifyEmailPage.d.ts.map +0 -1
- package/src/components/VerifyEmailPage.js +0 -61
- package/src/components/index.d.ts.map +0 -1
- package/src/components/index.js +0 -28
- package/src/contexts/AuthProvider.d.ts +0 -152
- package/src/contexts/AuthProvider.d.ts.map +0 -1
- package/src/contexts/AuthProvider.js +0 -446
- package/src/contexts/I18nProvider.d.ts +0 -16
- package/src/contexts/I18nProvider.d.ts.map +0 -1
- package/src/contexts/I18nProvider.js +0 -46
- package/src/contexts/MenuContext.d.ts +0 -20
- package/src/contexts/MenuContext.d.ts.map +0 -1
- package/src/contexts/MenuContext.js +0 -244
- 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 -8
- package/src/hooks/useBackupCodes.d.ts +0 -15
- package/src/hooks/useBackupCodes.d.ts.map +0 -1
- package/src/hooks/useBackupCodes.js +0 -70
- package/src/hooks/useEmailVerification.d.ts +0 -10
- package/src/hooks/useEmailVerification.d.ts.map +0 -1
- package/src/hooks/useEmailVerification.js +0 -36
- 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 -46
- package/src/hooks/useUserSettings.d.ts.map +0 -1
- package/src/hooks/useUserSettings.js +0 -152
- package/src/index.d.ts.map +0 -1
- package/src/index.js +0 -12
- package/src/interfaces/IAppConfig.d.ts +0 -6
- package/src/interfaces/IAppConfig.d.ts.map +0 -1
- package/src/interfaces/IAppConfig.js +0 -2
- package/src/interfaces/IMenuConfig.d.ts +0 -11
- package/src/interfaces/IMenuConfig.d.ts.map +0 -1
- package/src/interfaces/IMenuConfig.js +0 -2
- package/src/interfaces/IMenuOption.d.ts +0 -58
- package/src/interfaces/IMenuOption.d.ts.map +0 -1
- package/src/interfaces/IMenuOption.js +0 -2
- package/src/interfaces/index.d.ts +0 -4
- package/src/interfaces/index.d.ts.map +0 -1
- package/src/interfaces/index.js +0 -6
- 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 -72
- package/src/services/authService.d.ts.map +0 -1
- package/src/services/authService.js +0 -347
- 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 -21
- 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/LoginFormWrapper.d.ts +0 -9
- package/src/wrappers/LoginFormWrapper.d.ts.map +0 -1
- package/src/wrappers/LoginFormWrapper.js +0 -43
- 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 -9
- package/src/wrappers/RegisterFormWrapper.d.ts.map +0 -1
- package/src/wrappers/RegisterFormWrapper.js +0 -26
- package/src/wrappers/UserSettingsFormWrapper.d.ts +0 -8
- package/src/wrappers/UserSettingsFormWrapper.d.ts.map +0 -1
- package/src/wrappers/UserSettingsFormWrapper.js +0 -24
- package/src/wrappers/VerifyEmailPageWrapper.d.ts +0 -8
- package/src/wrappers/VerifyEmailPageWrapper.d.ts.map +0 -1
- package/src/wrappers/VerifyEmailPageWrapper.js +0 -20
- package/src/wrappers/index.d.ts.map +0 -1
- package/src/wrappers/index.js +0 -20
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BackupCodesForm = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const material_1 = require("@mui/material");
|
|
7
|
-
const formik_1 = require("formik");
|
|
8
|
-
const react_1 = require("react");
|
|
9
|
-
const Yup = tslib_1.__importStar(require("yup"));
|
|
10
|
-
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
11
|
-
const contexts_1 = require("../contexts");
|
|
12
|
-
const BackupCodesForm = ({ onSubmit, backupCodesRemaining = null, mnemonicValidation, passwordValidation, labels = {}, }) => {
|
|
13
|
-
const { t, tComponent } = (0, contexts_1.useI18n)();
|
|
14
|
-
const [apiError, setApiError] = (0, react_1.useState)(null);
|
|
15
|
-
const [apiSuccess, setApiSuccess] = (0, react_1.useState)(null);
|
|
16
|
-
const [backupCodes, setBackupCodes] = (0, react_1.useState)(null);
|
|
17
|
-
const validation = {
|
|
18
|
-
mnemonic: mnemonicValidation || Yup.string()
|
|
19
|
-
.trim()
|
|
20
|
-
.matches(suite_core_lib_1.Constants.MnemonicRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_MnemonicRegex))
|
|
21
|
-
.optional(),
|
|
22
|
-
password: passwordValidation || Yup.string()
|
|
23
|
-
.trim()
|
|
24
|
-
.matches(suite_core_lib_1.Constants.PasswordRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordRegexErrorTemplate))
|
|
25
|
-
.optional(),
|
|
26
|
-
};
|
|
27
|
-
const translatedLabels = {
|
|
28
|
-
codesRemaining: labels.codesRemaining || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.BackupCodeRecovery_CodesRemainingTemplate),
|
|
29
|
-
mnemonic: labels.mnemonic || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Mnemonic),
|
|
30
|
-
password: labels.password || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Password),
|
|
31
|
-
generateButton: labels.generateButton || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.BackupCodeRecovery_GenerateNewCodes),
|
|
32
|
-
successTitle: labels.successTitle || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.BackupCodeRecovery_YourNewCodes),
|
|
33
|
-
xorError: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_MnemonicOrPasswordRequired),
|
|
34
|
-
unexpectedError: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_UnexpectedError),
|
|
35
|
-
};
|
|
36
|
-
const validationSchema = Yup.object({
|
|
37
|
-
mnemonic: validation.mnemonic,
|
|
38
|
-
password: validation.password,
|
|
39
|
-
})
|
|
40
|
-
.test('xor-mnemonic-password-mnemonic', translatedLabels.xorError, function (value) {
|
|
41
|
-
const mnemonic = value?.mnemonic?.trim() ?? '';
|
|
42
|
-
const password = value?.password?.trim() ?? '';
|
|
43
|
-
const hasMnemonic = mnemonic.length > 0;
|
|
44
|
-
const hasPassword = password.length > 0;
|
|
45
|
-
if (!hasMnemonic && !hasPassword) {
|
|
46
|
-
return this.createError({
|
|
47
|
-
path: 'mnemonic',
|
|
48
|
-
message: translatedLabels.xorError,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
if (hasMnemonic && hasPassword) {
|
|
52
|
-
return this.createError({
|
|
53
|
-
path: 'mnemonic',
|
|
54
|
-
message: translatedLabels.xorError,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
return true;
|
|
58
|
-
})
|
|
59
|
-
.test('xor-mnemonic-password-password', translatedLabels.xorError, function (value) {
|
|
60
|
-
const mnemonic = value?.mnemonic?.trim() ?? '';
|
|
61
|
-
const password = value?.password?.trim() ?? '';
|
|
62
|
-
const hasMnemonic = mnemonic.length > 0;
|
|
63
|
-
const hasPassword = password.length > 0;
|
|
64
|
-
if (!hasMnemonic && !hasPassword) {
|
|
65
|
-
return this.createError({
|
|
66
|
-
path: 'password',
|
|
67
|
-
message: translatedLabels.xorError,
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
if (hasMnemonic && hasPassword) {
|
|
71
|
-
return this.createError({
|
|
72
|
-
path: 'password',
|
|
73
|
-
message: translatedLabels.xorError,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
return true;
|
|
77
|
-
});
|
|
78
|
-
const formik = (0, formik_1.useFormik)({
|
|
79
|
-
initialValues: {
|
|
80
|
-
password: '',
|
|
81
|
-
mnemonic: '',
|
|
82
|
-
},
|
|
83
|
-
validationSchema,
|
|
84
|
-
onSubmit: async (values, { setSubmitting }) => {
|
|
85
|
-
try {
|
|
86
|
-
const result = await onSubmit(values);
|
|
87
|
-
if (result && result.backupCodes) {
|
|
88
|
-
setApiSuccess(translatedLabels.successTitle);
|
|
89
|
-
setBackupCodes(result.backupCodes);
|
|
90
|
-
}
|
|
91
|
-
if (result && result.message) {
|
|
92
|
-
setApiSuccess(result.message);
|
|
93
|
-
}
|
|
94
|
-
setApiError(null);
|
|
95
|
-
}
|
|
96
|
-
catch (e) {
|
|
97
|
-
setApiSuccess(null);
|
|
98
|
-
setApiError(e.response?.data?.message ?? translatedLabels.unexpectedError);
|
|
99
|
-
}
|
|
100
|
-
finally {
|
|
101
|
-
setSubmitting(false);
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Container, { component: "main", maxWidth: "xs", children: [(0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h1", variant: "h5", children: translatedLabels.codesRemaining.replace('{count}', String(backupCodesRemaining ?? 0)) }) }), (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, { margin: "normal", fullWidth: true, id: "mnemonic", label: translatedLabels.mnemonic, type: "password", name: "mnemonic", autoComplete: "mnemonic", autoFocus: true, value: formik.values.mnemonic, onChange: formik.handleChange, onBlur: formik.handleBlur, error: (formik.touched.mnemonic || formik.submitCount > 0) && Boolean(formik.errors.mnemonic), helperText: (formik.touched.mnemonic || formik.submitCount > 0) && formik.errors.mnemonic }), (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", fullWidth: true, name: "password", label: translatedLabels.password, type: "password", id: "password", value: formik.values.password, onChange: formik.handleChange, onBlur: formik.handleBlur, error: (formik.touched.password || formik.submitCount > 0) && Boolean(formik.errors.password), helperText: (formik.touched.password || formik.submitCount > 0) && formik.errors.password }), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", sx: { mt: 2 }, children: translatedLabels.generateButton })] }), apiError && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: apiError })), backupCodes && apiSuccess && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 2, mb: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h2", variant: "h6", children: apiSuccess }), (0, jsx_runtime_1.jsx)("ul", { children: backupCodes.map((code, index) => ((0, jsx_runtime_1.jsx)("li", { children: (0, jsx_runtime_1.jsx)("pre", { children: code }) }, index))) })] }))] }));
|
|
106
|
-
};
|
|
107
|
-
exports.BackupCodesForm = BackupCodesForm;
|
|
108
|
-
exports.default = exports.BackupCodesForm;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import * as Yup from 'yup';
|
|
3
|
-
export interface ChangePasswordFormValues {
|
|
4
|
-
currentPassword: string;
|
|
5
|
-
newPassword: string;
|
|
6
|
-
confirmPassword: string;
|
|
7
|
-
}
|
|
8
|
-
export interface ChangePasswordFormProps {
|
|
9
|
-
onSubmit: (values: ChangePasswordFormValues) => Promise<{
|
|
10
|
-
success?: boolean;
|
|
11
|
-
error?: string;
|
|
12
|
-
}>;
|
|
13
|
-
titleText?: string;
|
|
14
|
-
currentPasswordLabel?: string;
|
|
15
|
-
newPasswordLabel?: string;
|
|
16
|
-
confirmPasswordLabel?: string;
|
|
17
|
-
submitButtonText?: string;
|
|
18
|
-
submittingButtonText?: string;
|
|
19
|
-
successMessage?: string;
|
|
20
|
-
currentPasswordValidation?: Yup.StringSchema;
|
|
21
|
-
newPasswordValidation?: Yup.StringSchema;
|
|
22
|
-
confirmPasswordValidation?: Yup.StringSchema;
|
|
23
|
-
}
|
|
24
|
-
export declare const ChangePasswordForm: FC<ChangePasswordFormProps>;
|
|
25
|
-
export default ChangePasswordForm;
|
|
26
|
-
//# sourceMappingURL=ChangePasswordForm.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChangePasswordForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/ChangePasswordForm.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAI3B,MAAM,WAAW,wBAAwB;IACvC,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,CAAC,MAAM,EAAE,wBAAwB,KAAK,OAAO,CAAC;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yBAAyB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IAC7C,qBAAqB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACzC,yBAAyB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;CAC9C;AAED,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,uBAAuB,CAiJ1D,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ChangePasswordForm = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const material_1 = require("@mui/material");
|
|
7
|
-
const formik_1 = require("formik");
|
|
8
|
-
const react_1 = require("react");
|
|
9
|
-
const Yup = tslib_1.__importStar(require("yup"));
|
|
10
|
-
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
11
|
-
const contexts_1 = require("../contexts");
|
|
12
|
-
const ChangePasswordForm = ({ onSubmit, titleText, currentPasswordLabel, newPasswordLabel, confirmPasswordLabel, submitButtonText, submittingButtonText, successMessage, currentPasswordValidation, newPasswordValidation, confirmPasswordValidation, }) => {
|
|
13
|
-
const { t, tComponent } = (0, contexts_1.useI18n)();
|
|
14
|
-
const [success, setSuccess] = (0, react_1.useState)(false);
|
|
15
|
-
const [apiError, setApiError] = (0, react_1.useState)('');
|
|
16
|
-
const validation = {
|
|
17
|
-
currentPassword: currentPasswordValidation || Yup.string().required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
18
|
-
newPassword: newPasswordValidation || Yup.string()
|
|
19
|
-
.min(suite_core_lib_1.Constants.PasswordMinLength, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordMinLengthTemplate))
|
|
20
|
-
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
21
|
-
confirmPassword: confirmPasswordValidation || Yup.string()
|
|
22
|
-
.oneOf([Yup.ref('newPassword')], tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordMatch))
|
|
23
|
-
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
24
|
-
};
|
|
25
|
-
const labels = {
|
|
26
|
-
title: titleText || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_ChangePassword),
|
|
27
|
-
currentPassword: currentPasswordLabel || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_CurrentPassword),
|
|
28
|
-
newPassword: newPasswordLabel || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_NewPassword),
|
|
29
|
-
confirmPassword: confirmPasswordLabel || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_ConfirmNewPassword),
|
|
30
|
-
submitButton: submitButtonText || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_ChangePassword),
|
|
31
|
-
submittingButton: submittingButtonText || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_ChangingPassword),
|
|
32
|
-
success: successMessage || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.PasswordChange_Success),
|
|
33
|
-
};
|
|
34
|
-
const formik = (0, formik_1.useFormik)({
|
|
35
|
-
initialValues: {
|
|
36
|
-
currentPassword: '',
|
|
37
|
-
newPassword: '',
|
|
38
|
-
confirmPassword: '',
|
|
39
|
-
},
|
|
40
|
-
validationSchema: Yup.object({
|
|
41
|
-
currentPassword: validation.currentPassword,
|
|
42
|
-
newPassword: validation.newPassword,
|
|
43
|
-
confirmPassword: validation.confirmPassword,
|
|
44
|
-
}),
|
|
45
|
-
onSubmit: async (values, { resetForm }) => {
|
|
46
|
-
const result = await onSubmit(values);
|
|
47
|
-
if ('success' in result) {
|
|
48
|
-
setSuccess(true);
|
|
49
|
-
setApiError('');
|
|
50
|
-
resetForm();
|
|
51
|
-
}
|
|
52
|
-
else if ('error' in result && result.error) {
|
|
53
|
-
setApiError(result.error);
|
|
54
|
-
setSuccess(false);
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Container, { maxWidth: "sm", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
59
|
-
mt: 8,
|
|
60
|
-
display: 'flex',
|
|
61
|
-
flexDirection: 'column',
|
|
62
|
-
alignItems: 'center',
|
|
63
|
-
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: labels.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: "currentPassword", name: "currentPassword", label: labels.currentPassword, type: "password", value: formik.values.currentPassword, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.currentPassword && formik.errors.currentPassword), helperText: formik.touched.currentPassword && formik.errors.currentPassword, margin: "normal" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "newPassword", name: "newPassword", label: labels.newPassword, type: "password", value: formik.values.newPassword, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.newPassword && formik.errors.newPassword), helperText: formik.touched.newPassword && formik.errors.newPassword, margin: "normal" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "confirmPassword", name: "confirmPassword", label: labels.confirmPassword, type: "password", value: formik.values.confirmPassword, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.confirmPassword && formik.errors.confirmPassword), helperText: formik.touched.confirmPassword && formik.errors.confirmPassword, margin: "normal" }), apiError && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: apiError })), success && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: labels.success })), (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: formik.isSubmitting ? labels.submittingButton : labels.submitButton })] })] }) }));
|
|
64
|
-
};
|
|
65
|
-
exports.ChangePasswordForm = ChangePasswordForm;
|
|
66
|
-
exports.default = exports.ChangePasswordForm;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export interface ConfirmationDialogProps {
|
|
3
|
-
open: boolean;
|
|
4
|
-
title: string;
|
|
5
|
-
message: string;
|
|
6
|
-
confirmText?: string;
|
|
7
|
-
cancelText?: string;
|
|
8
|
-
onConfirm: () => void;
|
|
9
|
-
onCancel: () => void;
|
|
10
|
-
}
|
|
11
|
-
export declare const ConfirmationDialog: React.FC<ConfirmationDialogProps>;
|
|
12
|
-
export default ConfirmationDialog;
|
|
13
|
-
//# sourceMappingURL=ConfirmationDialog.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmationDialog.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/ConfirmationDialog.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAyBhE,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConfirmationDialog = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const material_1 = require("@mui/material");
|
|
6
|
-
const ConfirmationDialog = ({ open, title, message, confirmText = 'Confirm', cancelText = 'Cancel', onConfirm, onCancel, }) => {
|
|
7
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, { open: open, onClose: onCancel, children: [(0, jsx_runtime_1.jsx)(material_1.DialogTitle, { children: title }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsx)(material_1.DialogContentText, { children: message }) }), (0, jsx_runtime_1.jsxs)(material_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { onClick: onCancel, color: "primary", children: cancelText }), (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: onConfirm, color: "primary", children: confirmText })] })] }));
|
|
8
|
-
};
|
|
9
|
-
exports.ConfirmationDialog = ConfirmationDialog;
|
|
10
|
-
exports.default = exports.ConfirmationDialog;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
export interface CurrencyCodeSelectorProps {
|
|
3
|
-
name: string;
|
|
4
|
-
label: string;
|
|
5
|
-
onCurrencyChange?: (code: string) => void;
|
|
6
|
-
}
|
|
7
|
-
export declare const CurrencyCodeSelector: FC<CurrencyCodeSelectorProps>;
|
|
8
|
-
export default CurrencyCodeSelector;
|
|
9
|
-
//# sourceMappingURL=CurrencyCodeSelector.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CurrencyCodeSelector.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/CurrencyCodeSelector.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAe,EAAE,EAAE,MAAM,OAAO,CAAC;AAExC,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C;AAED,eAAO,MAAM,oBAAoB,EAAE,EAAE,CAAC,yBAAyB,CA8C9D,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CurrencyCodeSelector = 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 formik_1 = require("formik");
|
|
8
|
-
const CurrencyCodeSelector = ({ name, label, onCurrencyChange, }) => {
|
|
9
|
-
return ((0, jsx_runtime_1.jsx)(formik_1.Field, { name: name, children: ({ field, form }) => ((0, jsx_runtime_1.jsx)(material_1.TextField, { select: true, fullWidth: true, label: label, ...field, onChange: (event) => {
|
|
10
|
-
const selectedCode = event.target.value;
|
|
11
|
-
form.setFieldValue(name, selectedCode);
|
|
12
|
-
onCurrencyChange?.(selectedCode);
|
|
13
|
-
}, error: form.touched[name] && Boolean(form.errors[name]), helperText: form.touched[name] && form.errors[name], sx: {
|
|
14
|
-
'& .MuiSelect-select': {
|
|
15
|
-
paddingRight: '32px',
|
|
16
|
-
},
|
|
17
|
-
'& .MuiOutlinedInput-root': {
|
|
18
|
-
'& fieldset': {
|
|
19
|
-
borderColor: 'rgba(0, 0, 0, 0.23)',
|
|
20
|
-
},
|
|
21
|
-
'&:hover fieldset': {
|
|
22
|
-
borderColor: 'rgba(0, 0, 0, 0.87)',
|
|
23
|
-
},
|
|
24
|
-
'&.Mui-focused fieldset': {
|
|
25
|
-
borderColor: 'primary.main',
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
}, children: i18n_lib_1.CurrencyCode.getAll().map((code) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: code, children: code }, code))) })) }));
|
|
29
|
-
};
|
|
30
|
-
exports.CurrencyCodeSelector = CurrencyCodeSelector;
|
|
31
|
-
exports.default = exports.CurrencyCodeSelector;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface CurrencyInputProps {
|
|
2
|
-
value: number;
|
|
3
|
-
onChange: (value: number) => void;
|
|
4
|
-
currencyCode?: string;
|
|
5
|
-
locale?: string;
|
|
6
|
-
label: string;
|
|
7
|
-
error?: boolean;
|
|
8
|
-
helperText?: string;
|
|
9
|
-
name: string;
|
|
10
|
-
}
|
|
11
|
-
export declare const CurrencyInput: React.FC<CurrencyInputProps>;
|
|
12
|
-
export default CurrencyInput;
|
|
13
|
-
//# sourceMappingURL=CurrencyInput.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CurrencyInput.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/CurrencyInput.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA8DtD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CurrencyInput = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const material_1 = require("@mui/material");
|
|
6
|
-
const react_number_format_1 = require("react-number-format");
|
|
7
|
-
const i18n_lib_1 = require("@digitaldefiance/i18n-lib");
|
|
8
|
-
const CurrencyInput = ({ value, onChange, currencyCode = 'USD', locale = 'en-US', label, error, helperText, name, }) => {
|
|
9
|
-
const format = (0, i18n_lib_1.getCurrencyFormat)(locale, currencyCode);
|
|
10
|
-
if (format.position === 'infix') {
|
|
11
|
-
const [whole, decimal] = value.toString().split('.');
|
|
12
|
-
const displayValue = `${whole}${format.symbol}${format.decimalSeparator}${decimal || '00'}`;
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)(react_number_format_1.NumericFormat, { customInput: material_1.TextField, fullWidth: true, margin: "normal", label: label, value: displayValue, thousandSeparator: format.groupSeparator, decimalSeparator: format.decimalSeparator, decimalScale: 2, fixedDecimalScale: true, valueIsNumericString: true, onValueChange: (values) => {
|
|
14
|
-
onChange(values.floatValue || 0);
|
|
15
|
-
}, error: error, helperText: helperText, name: name }));
|
|
16
|
-
}
|
|
17
|
-
return ((0, jsx_runtime_1.jsx)(react_number_format_1.NumericFormat, { customInput: material_1.TextField, fullWidth: true, margin: "normal", label: label, value: value, thousandSeparator: format.groupSeparator, decimalSeparator: format.decimalSeparator, decimalScale: 2, fixedDecimalScale: true, prefix: format.position === 'prefix' ? format.symbol + ' ' : undefined, suffix: format.position === 'postfix' ? ' ' + format.symbol : undefined, valueIsNumericString: true, onValueChange: (values) => {
|
|
18
|
-
onChange(values.floatValue || 0);
|
|
19
|
-
}, error: error, helperText: helperText, name: name }));
|
|
20
|
-
};
|
|
21
|
-
exports.CurrencyInput = CurrencyInput;
|
|
22
|
-
exports.default = exports.CurrencyInput;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardPage.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/DashboardPage.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAahD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DashboardPage = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const material_1 = require("@mui/material");
|
|
6
|
-
const DashboardPage = ({ title = 'Dashboard', children }) => {
|
|
7
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Container, { maxWidth: "md", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { my: 4, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", component: "h1", gutterBottom: true, align: "center", children: title }), (0, jsx_runtime_1.jsx)(material_1.Box, { display: "flex", justifyContent: "center", mt: 3, children: children })] }) }));
|
|
8
|
-
};
|
|
9
|
-
exports.DashboardPage = DashboardPage;
|
|
10
|
-
exports.default = exports.DashboardPage;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { FC, ReactElement } from 'react';
|
|
2
|
-
import { MenuType } from '../types/MenuType';
|
|
3
|
-
interface DropdownMenuProps {
|
|
4
|
-
menuType: MenuType;
|
|
5
|
-
menuIcon: ReactElement;
|
|
6
|
-
}
|
|
7
|
-
export declare const DropdownMenu: FC<DropdownMenuProps>;
|
|
8
|
-
export default DropdownMenu;
|
|
9
|
-
//# sourceMappingURL=DropdownMenu.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenu.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/DropdownMenu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAc,YAAY,EAAyB,MAAM,OAAO,CAAC;AAE5E,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C,UAAU,iBAAiB;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,YAAY,CAAC;CACxB;AAED,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CA6E9C,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DropdownMenu = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const material_1 = require("@mui/material");
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const react_router_dom_1 = require("react-router-dom");
|
|
8
|
-
const MenuContext_1 = require("../contexts/MenuContext");
|
|
9
|
-
const DropdownMenu = ({ menuType, menuIcon }) => {
|
|
10
|
-
const { getMenuOptions } = (0, MenuContext_1.useMenu)();
|
|
11
|
-
const [anchorEl, setAnchorEl] = (0, react_1.useState)(null);
|
|
12
|
-
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
13
|
-
const handleClose = (0, react_1.useCallback)(() => {
|
|
14
|
-
setAnchorEl(null);
|
|
15
|
-
}, []);
|
|
16
|
-
const handleMenuItemClick = (0, react_1.useCallback)((option) => (event) => {
|
|
17
|
-
event.stopPropagation();
|
|
18
|
-
if (option.action) {
|
|
19
|
-
option.action();
|
|
20
|
-
}
|
|
21
|
-
else if (option.link !== undefined) {
|
|
22
|
-
if (typeof option.link === 'object' &&
|
|
23
|
-
'pathname' in option.link &&
|
|
24
|
-
'state' in option.link) {
|
|
25
|
-
navigate(option.link.pathname, { state: option.link.state });
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
navigate(option.link);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
handleClose(); // Call handleClose after handling the click
|
|
32
|
-
}, [navigate, handleClose]);
|
|
33
|
-
const handleClick = (0, react_1.useCallback)((event) => {
|
|
34
|
-
setAnchorEl(event.currentTarget);
|
|
35
|
-
}, []);
|
|
36
|
-
const menuItems = getMenuOptions(menuType, false);
|
|
37
|
-
if (menuItems.length === 0) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, { color: "inherit", onClick: handleClick, children: menuIcon }), (0, jsx_runtime_1.jsx)(material_1.Menu, { anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleClose, TransitionComponent: material_1.Fade, sx: {
|
|
41
|
-
'& .MuiPopover-paper': {
|
|
42
|
-
opacity: 0.5,
|
|
43
|
-
overflow: 'visible',
|
|
44
|
-
},
|
|
45
|
-
}, children: menuItems.map((option) => ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, { component: "li", onClick: handleMenuItemClick(option), sx: {
|
|
46
|
-
display: 'flex',
|
|
47
|
-
alignItems: 'center',
|
|
48
|
-
'& > svg': {
|
|
49
|
-
marginRight: 2,
|
|
50
|
-
width: 24,
|
|
51
|
-
height: 24,
|
|
52
|
-
},
|
|
53
|
-
}, children: [option.icon, option.label] }, option.id))) })] }));
|
|
54
|
-
};
|
|
55
|
-
exports.DropdownMenu = DropdownMenu;
|
|
56
|
-
exports.default = exports.DropdownMenu;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { FormikProps } from 'formik';
|
|
2
|
-
import { FC } from 'react';
|
|
3
|
-
export interface ExpirationSecondsSelectorProps {
|
|
4
|
-
name: string;
|
|
5
|
-
label: string;
|
|
6
|
-
formik: FormikProps<any>;
|
|
7
|
-
optionValues: number[];
|
|
8
|
-
optionNames: string[];
|
|
9
|
-
onChange?: (value: number) => void;
|
|
10
|
-
}
|
|
11
|
-
export declare const ExpirationSecondsSelector: FC<ExpirationSecondsSelectorProps>;
|
|
12
|
-
export default ExpirationSecondsSelector;
|
|
13
|
-
//# sourceMappingURL=ExpirationSecondsSelector.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExpirationSecondsSelector.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/ExpirationSecondsSelector.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAe,EAAE,EAAE,MAAM,OAAO,CAAC;AAExC,MAAM,WAAW,8BAA8B;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC;IACzB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED,eAAO,MAAM,yBAAyB,EAAE,EAAE,CAAC,8BAA8B,CAiDxE,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExpirationSecondsSelector = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const material_1 = require("@mui/material");
|
|
6
|
-
const ExpirationSecondsSelector = ({ name, label, formik, optionValues, optionNames, onChange, }) => {
|
|
7
|
-
return ((0, jsx_runtime_1.jsx)(material_1.TextField, { select: true, fullWidth: true, label: label, name: name, value: formik.values[name] ?? '', onChange: (event) => {
|
|
8
|
-
const selectedValue = event.target.value;
|
|
9
|
-
formik.setFieldValue(name, selectedValue);
|
|
10
|
-
if (onChange) {
|
|
11
|
-
onChange(parseInt(selectedValue));
|
|
12
|
-
}
|
|
13
|
-
}, error: formik.touched[name] && Boolean(formik.errors[name]), helperText: formik.touched[name] && formik.errors[name], sx: {
|
|
14
|
-
mt: 1,
|
|
15
|
-
'& .MuiSelect-select': {
|
|
16
|
-
paddingRight: '32px',
|
|
17
|
-
},
|
|
18
|
-
'& .MuiOutlinedInput-root': {
|
|
19
|
-
'& fieldset': {
|
|
20
|
-
borderColor: 'rgba(0, 0, 0, 0.23)',
|
|
21
|
-
},
|
|
22
|
-
'&:hover fieldset': {
|
|
23
|
-
borderColor: 'rgba(0, 0, 0, 0.87)',
|
|
24
|
-
},
|
|
25
|
-
'&.Mui-focused fieldset': {
|
|
26
|
-
borderColor: 'primary.main',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
}, children: optionNames.map((name, index) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: optionValues[index], children: name }, name))) }));
|
|
30
|
-
};
|
|
31
|
-
exports.ExpirationSecondsSelector = ExpirationSecondsSelector;
|
|
32
|
-
exports.default = exports.ExpirationSecondsSelector;
|
package/src/components/Flag.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { SxProps, Theme } from '@mui/material';
|
|
2
|
-
import { FC } from 'react';
|
|
3
|
-
export interface FlagProps {
|
|
4
|
-
language: string;
|
|
5
|
-
sx?: SxProps<Theme>;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* A simple component to display a flag icon for a given language.
|
|
9
|
-
*
|
|
10
|
-
* Props:
|
|
11
|
-
* language: The language to display a flag for, as a StringLanguages enum value.
|
|
12
|
-
* sx: Optional styles to apply to the component.
|
|
13
|
-
*
|
|
14
|
-
* Returns a Box component with an SVG flag icon from flagcdn.com as a ::before pseudo-element.
|
|
15
|
-
* The flag is sized to 1.5rem by default, but can be overridden by passing a custom sx prop.
|
|
16
|
-
* The component also includes an aria-label for accessibility, set to `Flag for <language>`.
|
|
17
|
-
*/
|
|
18
|
-
export declare const Flag: FC<FlagProps>;
|
|
19
|
-
export default Flag;
|
|
20
|
-
//# sourceMappingURL=Flag.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Flag.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/Flag.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAO,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAE3B,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CA6B9B,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
package/src/components/Flag.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Flag = 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
|
-
/**
|
|
8
|
-
* A simple component to display a flag icon for a given language.
|
|
9
|
-
*
|
|
10
|
-
* Props:
|
|
11
|
-
* language: The language to display a flag for, as a StringLanguages enum value.
|
|
12
|
-
* sx: Optional styles to apply to the component.
|
|
13
|
-
*
|
|
14
|
-
* Returns a Box component with an SVG flag icon from flagcdn.com as a ::before pseudo-element.
|
|
15
|
-
* The flag is sized to 1.5rem by default, but can be overridden by passing a custom sx prop.
|
|
16
|
-
* The component also includes an aria-label for accessibility, set to `Flag for <language>`.
|
|
17
|
-
*/
|
|
18
|
-
const Flag = ({ language, sx }) => {
|
|
19
|
-
const flagContent = (0, suite_core_lib_1.getFlagCode)(language);
|
|
20
|
-
if (!flagContent) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Box, { component: "span", "aria-label": `Flag for ${language}`, sx: {
|
|
24
|
-
fontSize: '1.5rem',
|
|
25
|
-
lineHeight: 1,
|
|
26
|
-
verticalAlign: 'middle',
|
|
27
|
-
'&::before': {
|
|
28
|
-
content: `" "`,
|
|
29
|
-
display: 'inline-block',
|
|
30
|
-
width: '1em',
|
|
31
|
-
height: '1em',
|
|
32
|
-
backgroundImage: `url(https://flagcdn.com/${flagContent.toLowerCase()}.svg)`,
|
|
33
|
-
backgroundSize: 'contain',
|
|
34
|
-
backgroundRepeat: 'no-repeat',
|
|
35
|
-
backgroundPosition: 'center',
|
|
36
|
-
border: '1px solid rgba(0, 0, 0, 0.1)',
|
|
37
|
-
borderRadius: '2px',
|
|
38
|
-
},
|
|
39
|
-
...sx,
|
|
40
|
-
} }));
|
|
41
|
-
};
|
|
42
|
-
exports.Flag = Flag;
|
|
43
|
-
exports.default = exports.Flag;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import * as Yup from 'yup';
|
|
3
|
-
export interface ForgotPasswordFormValues {
|
|
4
|
-
email: string;
|
|
5
|
-
}
|
|
6
|
-
export interface ForgotPasswordFormProps {
|
|
7
|
-
onSubmit: (values: ForgotPasswordFormValues) => Promise<void>;
|
|
8
|
-
emailValidation?: Yup.StringSchema;
|
|
9
|
-
labels?: {
|
|
10
|
-
title?: string;
|
|
11
|
-
email?: string;
|
|
12
|
-
sendResetLink?: string;
|
|
13
|
-
successMessage?: string;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export declare const ForgotPasswordForm: FC<ForgotPasswordFormProps>;
|
|
17
|
-
export default ForgotPasswordForm;
|
|
18
|
-
//# sourceMappingURL=ForgotPasswordForm.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ForgotPasswordForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/ForgotPasswordForm.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAI3B,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,CAAC,MAAM,EAAE,wBAAwB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,eAAe,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACnC,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,uBAAuB,CA+F1D,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ForgotPasswordForm = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const material_1 = require("@mui/material");
|
|
7
|
-
const formik_1 = require("formik");
|
|
8
|
-
const react_1 = require("react");
|
|
9
|
-
const Yup = tslib_1.__importStar(require("yup"));
|
|
10
|
-
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
11
|
-
const contexts_1 = require("../contexts");
|
|
12
|
-
const ForgotPasswordForm = ({ onSubmit, emailValidation, labels = {}, }) => {
|
|
13
|
-
const { tComponent } = (0, contexts_1.useI18n)();
|
|
14
|
-
const [success, setSuccess] = (0, react_1.useState)(false);
|
|
15
|
-
const [apiError, setApiError] = (0, react_1.useState)('');
|
|
16
|
-
const validation = {
|
|
17
|
-
email: emailValidation || Yup.string()
|
|
18
|
-
.email(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidEmail))
|
|
19
|
-
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
20
|
-
};
|
|
21
|
-
const translatedLabels = {
|
|
22
|
-
title: labels.title || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ForgotPassword_Title),
|
|
23
|
-
email: labels.email || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Email),
|
|
24
|
-
sendResetLink: labels.sendResetLink || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ForgotPassword_SendResetLink),
|
|
25
|
-
successMessage: labels.successMessage || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.PasswordReset_Success),
|
|
26
|
-
};
|
|
27
|
-
const formik = (0, formik_1.useFormik)({
|
|
28
|
-
initialValues: {
|
|
29
|
-
email: '',
|
|
30
|
-
},
|
|
31
|
-
validationSchema: Yup.object({
|
|
32
|
-
email: validation.email,
|
|
33
|
-
}),
|
|
34
|
-
onSubmit: async (values) => {
|
|
35
|
-
try {
|
|
36
|
-
await onSubmit(values);
|
|
37
|
-
setSuccess(true);
|
|
38
|
-
setApiError('');
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
setApiError(error.response?.data?.message || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ForgotPassword_Error));
|
|
42
|
-
setSuccess(false);
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Container, { maxWidth: "sm", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
47
|
-
mt: 8,
|
|
48
|
-
display: 'flex',
|
|
49
|
-
flexDirection: 'column',
|
|
50
|
-
alignItems: 'center',
|
|
51
|
-
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: translatedLabels.title }), (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "form", onSubmit: formik.handleSubmit, sx: { mt: 1, width: '100%' }, children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "email", name: "email", label: translatedLabels.email, value: formik.values.email, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.email && formik.errors.email), helperText: formik.touched.email && formik.errors.email, margin: "normal" }), apiError && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: apiError })), success && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: translatedLabels.successMessage })), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", color: "primary", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: translatedLabels.sendResetLink })] })] }) }));
|
|
52
|
-
};
|
|
53
|
-
exports.ForgotPasswordForm = ForgotPasswordForm;
|
|
54
|
-
exports.default = exports.ForgotPasswordForm;
|