@digitaldefiance/express-suite-react-components 2.9.6 → 2.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -5
- package/src/auth/Private.d.ts +6 -0
- package/src/auth/Private.d.ts.map +1 -0
- package/src/auth/Private.js +14 -0
- package/src/auth/PrivateRoute.d.ts +8 -0
- package/src/auth/PrivateRoute.d.ts.map +1 -0
- package/src/auth/PrivateRoute.js +23 -0
- package/src/auth/UnAuth.d.ts +6 -0
- package/src/auth/UnAuth.d.ts.map +1 -0
- package/src/auth/UnAuth.js +14 -0
- package/src/auth/UnAuthRoute.d.ts +8 -0
- package/src/auth/UnAuthRoute.d.ts.map +1 -0
- package/src/auth/UnAuthRoute.js +22 -0
- package/src/auth/{index.ts → index.d.ts} +2 -1
- package/src/auth/index.d.ts.map +1 -0
- package/src/auth/index.js +10 -0
- package/src/components/ApiAccess.d.ts +16 -0
- package/src/components/ApiAccess.d.ts.map +1 -0
- package/src/components/ApiAccess.js +70 -0
- package/src/components/BackupCodeLoginForm.d.ts +43 -0
- package/src/components/BackupCodeLoginForm.d.ts.map +1 -0
- package/src/components/BackupCodeLoginForm.js +106 -0
- package/src/components/BackupCodesForm.d.ts +26 -0
- package/src/components/BackupCodesForm.d.ts.map +1 -0
- package/src/components/BackupCodesForm.js +108 -0
- package/src/components/ChangePasswordForm.d.ts +26 -0
- package/src/components/ChangePasswordForm.d.ts.map +1 -0
- package/src/components/ChangePasswordForm.js +66 -0
- package/src/components/ConfirmationDialog.d.ts +13 -0
- package/src/components/ConfirmationDialog.d.ts.map +1 -0
- package/src/components/ConfirmationDialog.js +10 -0
- package/src/components/CurrencyCodeSelector.d.ts +9 -0
- package/src/components/CurrencyCodeSelector.d.ts.map +1 -0
- package/src/components/CurrencyCodeSelector.js +31 -0
- package/src/components/CurrencyInput.d.ts +13 -0
- package/src/components/CurrencyInput.d.ts.map +1 -0
- package/src/components/CurrencyInput.js +22 -0
- package/src/components/DashboardPage.d.ts +8 -0
- package/src/components/DashboardPage.d.ts.map +1 -0
- package/src/components/DashboardPage.js +10 -0
- package/src/components/DropdownMenu.d.ts +9 -0
- package/src/components/DropdownMenu.d.ts.map +1 -0
- package/src/components/DropdownMenu.js +56 -0
- package/src/components/ExpirationSecondsSelector.d.ts +13 -0
- package/src/components/ExpirationSecondsSelector.d.ts.map +1 -0
- package/src/components/ExpirationSecondsSelector.js +32 -0
- package/src/components/Flag.d.ts +20 -0
- package/src/components/Flag.d.ts.map +1 -0
- package/src/components/Flag.js +43 -0
- package/src/components/ForgotPasswordForm.d.ts +18 -0
- package/src/components/ForgotPasswordForm.d.ts.map +1 -0
- package/src/components/ForgotPasswordForm.js +54 -0
- package/src/components/LoginForm.d.ts +44 -0
- package/src/components/LoginForm.d.ts.map +1 -0
- package/src/components/LoginForm.js +99 -0
- package/src/components/LogoutPage.d.ts +8 -0
- package/src/components/LogoutPage.d.ts.map +1 -0
- package/src/components/LogoutPage.js +16 -0
- package/src/components/RegisterForm.d.ts +54 -0
- package/src/components/RegisterForm.d.ts.map +1 -0
- package/src/components/RegisterForm.js +105 -0
- package/src/components/ResetPasswordForm.d.ts +23 -0
- package/src/components/ResetPasswordForm.d.ts.map +1 -0
- package/src/components/ResetPasswordForm.js +68 -0
- package/src/components/SideMenu.d.ts +8 -0
- package/src/components/SideMenu.d.ts.map +1 -0
- package/src/components/SideMenu.js +25 -0
- package/src/components/SideMenuListItem.d.ts +13 -0
- package/src/components/SideMenuListItem.d.ts.map +1 -0
- package/src/components/SideMenuListItem.js +44 -0
- package/src/components/TopMenu.d.ts +24 -0
- package/src/components/TopMenu.d.ts.map +1 -0
- package/src/components/TopMenu.js +42 -0
- package/src/components/TranslatedTitle.d.ts +7 -0
- package/src/components/TranslatedTitle.d.ts.map +1 -0
- package/src/components/TranslatedTitle.js +15 -0
- package/src/components/UserLanguageSelector.d.ts +4 -0
- package/src/components/UserLanguageSelector.d.ts.map +1 -0
- package/src/components/UserLanguageSelector.js +31 -0
- package/src/components/UserMenu.d.ts +4 -0
- package/src/components/UserMenu.d.ts.map +1 -0
- package/src/components/UserMenu.js +12 -0
- package/src/components/UserSettingsForm.d.ts +56 -0
- package/src/components/UserSettingsForm.d.ts.map +1 -0
- package/src/components/UserSettingsForm.js +93 -0
- package/src/components/VerifyEmailPage.d.ts +23 -0
- package/src/components/VerifyEmailPage.d.ts.map +1 -0
- package/src/components/VerifyEmailPage.js +61 -0
- package/src/components/{index.ts → index.d.ts} +1 -1
- package/src/components/index.d.ts.map +1 -0
- package/src/components/index.js +28 -0
- package/src/contexts/AuthProvider.d.ts +152 -0
- package/src/contexts/AuthProvider.d.ts.map +1 -0
- package/src/contexts/AuthProvider.js +446 -0
- package/src/contexts/I18nProvider.d.ts +16 -0
- package/src/contexts/I18nProvider.d.ts.map +1 -0
- package/src/contexts/I18nProvider.js +46 -0
- package/src/contexts/MenuContext.d.ts +20 -0
- package/src/contexts/MenuContext.d.ts.map +1 -0
- package/src/contexts/MenuContext.js +244 -0
- package/src/contexts/SuiteConfigProvider.d.ts +44 -0
- package/src/contexts/SuiteConfigProvider.d.ts.map +1 -0
- package/src/contexts/SuiteConfigProvider.js +43 -0
- package/src/contexts/ThemeProvider.d.ts +15 -0
- package/src/contexts/ThemeProvider.d.ts.map +1 -0
- package/src/contexts/ThemeProvider.js +36 -0
- package/src/contexts/{index.ts → index.d.ts} +1 -0
- package/src/contexts/index.d.ts.map +1 -0
- package/src/contexts/index.js +8 -0
- package/src/hooks/{index.ts → index.d.ts} +1 -0
- package/src/hooks/index.d.ts.map +1 -0
- package/src/hooks/index.js +8 -0
- package/src/hooks/useBackupCodes.d.ts +15 -0
- package/src/hooks/useBackupCodes.d.ts.map +1 -0
- package/src/hooks/useBackupCodes.js +70 -0
- package/src/hooks/useEmailVerification.d.ts +10 -0
- package/src/hooks/useEmailVerification.d.ts.map +1 -0
- package/src/hooks/useEmailVerification.js +36 -0
- package/src/hooks/useExpiringValue.d.ts +14 -0
- package/src/hooks/useExpiringValue.d.ts.map +1 -0
- package/src/hooks/useExpiringValue.js +53 -0
- package/src/hooks/useLocalStorage.d.ts +2 -0
- package/src/hooks/useLocalStorage.d.ts.map +1 -0
- package/src/hooks/useLocalStorage.js +15 -0
- package/src/hooks/useUserSettings.d.ts +46 -0
- package/src/hooks/useUserSettings.d.ts.map +1 -0
- package/src/hooks/useUserSettings.js +152 -0
- package/src/{index.ts → index.d.ts} +1 -1
- package/src/index.d.ts.map +1 -0
- package/src/index.js +12 -0
- package/src/interfaces/IAppConfig.d.ts +6 -0
- package/src/interfaces/IAppConfig.d.ts.map +1 -0
- package/src/interfaces/IAppConfig.js +2 -0
- package/src/interfaces/IMenuConfig.d.ts +11 -0
- package/src/interfaces/IMenuConfig.d.ts.map +1 -0
- package/src/interfaces/IMenuConfig.js +2 -0
- package/src/interfaces/IMenuOption.d.ts +58 -0
- package/src/interfaces/IMenuOption.d.ts.map +1 -0
- package/src/interfaces/IMenuOption.js +2 -0
- package/src/interfaces/index.d.ts +4 -0
- package/src/interfaces/index.d.ts.map +1 -0
- package/src/interfaces/index.js +6 -0
- package/src/services/__mocks__/authService.d.ts +21 -0
- package/src/services/__mocks__/authService.d.ts.map +1 -0
- package/src/services/__mocks__/authService.js +15 -0
- package/src/services/api.d.ts +3 -0
- package/src/services/api.d.ts.map +1 -0
- package/src/services/api.js +14 -0
- package/src/services/authService.d.ts +72 -0
- package/src/services/authService.d.ts.map +1 -0
- package/src/services/authService.js +347 -0
- package/src/services/authenticatedApi.d.ts +3 -0
- package/src/services/authenticatedApi.d.ts.map +1 -0
- package/src/services/authenticatedApi.js +18 -0
- package/src/services/index.d.ts +4 -0
- package/src/services/index.d.ts.map +1 -0
- package/src/services/index.js +6 -0
- package/src/types/MenuType.d.ts +11 -0
- package/src/types/MenuType.d.ts.map +1 -0
- package/src/types/MenuType.js +12 -0
- package/src/types/expirationSeconds.d.ts +3 -0
- package/src/types/expirationSeconds.d.ts.map +1 -0
- package/src/types/expirationSeconds.js +17 -0
- package/src/types/index.d.ts +2 -0
- package/src/types/index.d.ts.map +1 -0
- package/src/types/index.js +4 -0
- package/src/types/translation.d.ts +10 -0
- package/src/types/translation.d.ts.map +1 -0
- package/src/types/translation.js +9 -0
- package/src/wrappers/BackupCodeLoginWrapper.d.ts +8 -0
- package/src/wrappers/BackupCodeLoginWrapper.d.ts.map +1 -0
- package/src/wrappers/BackupCodeLoginWrapper.js +21 -0
- package/src/wrappers/BackupCodesWrapper.d.ts +7 -0
- package/src/wrappers/BackupCodesWrapper.d.ts.map +1 -0
- package/src/wrappers/BackupCodesWrapper.js +17 -0
- package/src/wrappers/ChangePasswordFormWrapper.d.ts +8 -0
- package/src/wrappers/ChangePasswordFormWrapper.d.ts.map +1 -0
- package/src/wrappers/ChangePasswordFormWrapper.js +21 -0
- package/src/wrappers/LoginFormWrapper.d.ts +9 -0
- package/src/wrappers/LoginFormWrapper.d.ts.map +1 -0
- package/src/wrappers/LoginFormWrapper.js +43 -0
- package/src/wrappers/LogoutPageWrapper.d.ts +9 -0
- package/src/wrappers/LogoutPageWrapper.d.ts.map +1 -0
- package/src/wrappers/LogoutPageWrapper.js +21 -0
- package/src/wrappers/RegisterFormWrapper.d.ts +9 -0
- package/src/wrappers/RegisterFormWrapper.d.ts.map +1 -0
- package/src/wrappers/RegisterFormWrapper.js +26 -0
- package/src/wrappers/UserSettingsFormWrapper.d.ts +8 -0
- package/src/wrappers/UserSettingsFormWrapper.d.ts.map +1 -0
- package/src/wrappers/UserSettingsFormWrapper.js +24 -0
- package/src/wrappers/VerifyEmailPageWrapper.d.ts +8 -0
- package/src/wrappers/VerifyEmailPageWrapper.d.ts.map +1 -0
- package/src/wrappers/VerifyEmailPageWrapper.js +20 -0
- package/src/wrappers/{index.tsx → index.d.ts} +1 -8
- package/src/wrappers/index.d.ts.map +1 -0
- package/src/wrappers/index.js +20 -0
- package/LICENSE +0 -21
- package/src/auth/Private.tsx +0 -17
- package/src/auth/PrivateRoute.tsx +0 -28
- package/src/auth/UnAuth.tsx +0 -16
- package/src/auth/UnAuthRoute.tsx +0 -30
- package/src/components/ApiAccess.tsx +0 -134
- package/src/components/BackupCodeLoginForm.tsx +0 -314
- package/src/components/BackupCodesForm.tsx +0 -198
- package/src/components/ChangePasswordForm.tsx +0 -182
- package/src/components/ConfirmationDialog.tsx +0 -48
- package/src/components/CurrencyCodeSelector.tsx +0 -60
- package/src/components/CurrencyInput.tsx +0 -80
- package/src/components/DashboardPage.tsx +0 -24
- package/src/components/DropdownMenu.tsx +0 -92
- package/src/components/ExpirationSecondsSelector.tsx +0 -65
- package/src/components/Flag.tsx +0 -53
- package/src/components/ForgotPasswordForm.tsx +0 -120
- package/src/components/LoginForm.tsx +0 -307
- package/src/components/LogoutPage.tsx +0 -21
- package/src/components/RegisterForm.tsx +0 -354
- package/src/components/ResetPasswordForm.tsx +0 -164
- package/src/components/SideMenu.tsx +0 -46
- package/src/components/SideMenuListItem.tsx +0 -74
- package/src/components/TopMenu.tsx +0 -149
- package/src/components/TranslatedTitle.tsx +0 -22
- package/src/components/UserLanguageSelector.tsx +0 -45
- package/src/components/UserMenu.tsx +0 -15
- package/src/components/UserSettingsForm.tsx +0 -328
- package/src/components/VerifyEmailPage.tsx +0 -133
- package/src/contexts/AuthProvider.spec.tsx +0 -1060
- package/src/contexts/AuthProvider.tsx +0 -741
- package/src/contexts/I18nProvider.tsx +0 -85
- package/src/contexts/MenuContext.tsx +0 -310
- package/src/contexts/SuiteConfigProvider.tsx +0 -93
- package/src/contexts/ThemeProvider.tsx +0 -67
- package/src/hooks/useBackupCodes.ts +0 -85
- package/src/hooks/useEmailVerification.ts +0 -39
- package/src/hooks/useExpiringValue.ts +0 -78
- package/src/hooks/useLocalStorage.ts +0 -18
- package/src/hooks/useUserSettings.ts +0 -216
- package/src/interfaces/IAppConfig.ts +0 -5
- package/src/interfaces/IMenuConfig.ts +0 -11
- package/src/interfaces/IMenuOption.ts +0 -55
- package/src/interfaces/index.ts +0 -3
- package/src/services/__mocks__/authService.ts +0 -14
- package/src/services/api.ts +0 -13
- package/src/services/authService.ts +0 -422
- package/src/services/authenticatedApi.ts +0 -17
- package/src/services/index.ts +0 -3
- package/src/types/MenuType.ts +0 -15
- package/src/types/expirationSeconds.ts +0 -18
- package/src/types/index.ts +0 -1
- package/src/types/translation.ts +0 -20
- package/src/wrappers/BackupCodeLoginWrapper.tsx +0 -35
- package/src/wrappers/BackupCodesWrapper.tsx +0 -28
- package/src/wrappers/ChangePasswordFormWrapper.tsx +0 -31
- package/src/wrappers/LoginFormWrapper.tsx +0 -59
- package/src/wrappers/LogoutPageWrapper.tsx +0 -30
- package/src/wrappers/RegisterFormWrapper.tsx +0 -48
- package/src/wrappers/UserSettingsFormWrapper.tsx +0 -39
- package/src/wrappers/VerifyEmailPageWrapper.tsx +0 -27
|
@@ -0,0 +1,66 @@
|
|
|
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;
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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;
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,31 @@
|
|
|
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;
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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;
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,56 @@
|
|
|
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;
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,32 @@
|
|
|
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;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,43 @@
|
|
|
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;
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,54 @@
|
|
|
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;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useFormik } from 'formik';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
import * as Yup from 'yup';
|
|
4
|
+
export interface LoginFormValues {
|
|
5
|
+
email?: string;
|
|
6
|
+
username?: string;
|
|
7
|
+
password?: string;
|
|
8
|
+
mnemonic?: string;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
export interface LoginFormProps {
|
|
12
|
+
onSubmit: (values: LoginFormValues) => Promise<void>;
|
|
13
|
+
loginType?: 'email' | 'username';
|
|
14
|
+
authType?: 'password' | 'mnemonic';
|
|
15
|
+
allowLoginTypeToggle?: boolean;
|
|
16
|
+
allowAuthTypeToggle?: boolean;
|
|
17
|
+
showForgotPassword?: boolean;
|
|
18
|
+
showSignUp?: boolean;
|
|
19
|
+
forgotPasswordLink?: string;
|
|
20
|
+
signUpLink?: string;
|
|
21
|
+
emailLabel?: string;
|
|
22
|
+
usernameLabel?: string;
|
|
23
|
+
passwordLabel?: string;
|
|
24
|
+
mnemonicLabel?: string;
|
|
25
|
+
signInButtonText?: string;
|
|
26
|
+
forgotPasswordText?: string;
|
|
27
|
+
signUpText?: string;
|
|
28
|
+
useUsernameText?: string;
|
|
29
|
+
useEmailText?: string;
|
|
30
|
+
useMnemonicText?: string;
|
|
31
|
+
usePasswordText?: string;
|
|
32
|
+
toggleVisibilityLabel?: string;
|
|
33
|
+
titleText?: string;
|
|
34
|
+
emailValidation?: Yup.StringSchema;
|
|
35
|
+
usernameValidation?: Yup.StringSchema;
|
|
36
|
+
passwordValidation?: Yup.StringSchema;
|
|
37
|
+
mnemonicValidation?: Yup.StringSchema;
|
|
38
|
+
additionalFields?: (formik: ReturnType<typeof useFormik<LoginFormValues>>) => React.ReactNode;
|
|
39
|
+
additionalInitialValues?: Record<string, any>;
|
|
40
|
+
additionalValidation?: Record<string, Yup.Schema>;
|
|
41
|
+
}
|
|
42
|
+
export declare const LoginForm: FC<LoginFormProps>;
|
|
43
|
+
export default LoginForm;
|
|
44
|
+
//# sourceMappingURL=LoginForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoginForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/LoginForm.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAI3B,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,SAAS,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IACjC,QAAQ,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IACnC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACnC,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,eAAe,CAAC,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;IAC9F,uBAAuB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9C,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACnD;AAED,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAsPxC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|