@digitaldefiance/express-suite-react-components 2.9.9 → 2.9.12
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 +3 -3
- package/src/components/ApiAccess.d.ts.map +1 -1
- package/src/components/ApiAccess.js +16 -9
- package/src/components/BackupCodeLoginForm.d.ts +2 -2
- package/src/components/BackupCodeLoginForm.d.ts.map +1 -1
- package/src/components/BackupCodeLoginForm.js +62 -29
- package/src/components/BackupCodesForm.d.ts.map +1 -1
- package/src/components/BackupCodesForm.js +29 -17
- package/src/components/ChangePasswordForm.d.ts.map +1 -1
- package/src/components/ChangePasswordForm.js +29 -17
- package/src/components/ExpirationSecondsSelector.d.ts +3 -3
- package/src/components/ExpirationSecondsSelector.d.ts.map +1 -1
- package/src/components/ExpirationSecondsSelector.js +1 -1
- package/src/components/Flag.d.ts.map +1 -1
- package/src/components/ForgotPasswordForm.d.ts.map +1 -1
- package/src/components/ForgotPasswordForm.js +16 -9
- package/src/components/LoginForm.d.ts +2 -2
- package/src/components/LoginForm.d.ts.map +1 -1
- package/src/components/LoginForm.js +52 -29
- package/src/components/RegisterForm.d.ts +5 -3
- package/src/components/RegisterForm.d.ts.map +1 -1
- package/src/components/RegisterForm.js +62 -27
- package/src/components/ResetPasswordForm.d.ts.map +1 -1
- package/src/components/ResetPasswordForm.js +25 -15
- package/src/components/TopMenu.d.ts.map +1 -1
- package/src/components/TopMenu.js +2 -3
- package/src/components/TranslatedTitle.d.ts +1 -1
- package/src/components/TranslatedTitle.d.ts.map +1 -1
- package/src/components/TranslatedTitle.js +1 -1
- package/src/components/UserSettingsForm.d.ts +4 -3
- package/src/components/UserSettingsForm.d.ts.map +1 -1
- package/src/components/UserSettingsForm.js +58 -25
- package/src/components/VerifyEmailPage.d.ts.map +1 -1
- package/src/components/VerifyEmailPage.js +20 -11
- package/src/contexts/AuthProvider.d.ts +4 -4
- package/src/contexts/AuthProvider.d.ts.map +1 -1
- package/src/contexts/AuthProvider.js +82 -27
- package/src/contexts/I18nProvider.d.ts.map +1 -1
- package/src/contexts/MenuContext.d.ts +2 -2
- package/src/contexts/MenuContext.d.ts.map +1 -1
- package/src/contexts/MenuContext.js +72 -43
- package/src/hooks/useBackupCodes.d.ts.map +1 -1
- package/src/hooks/useBackupCodes.js +8 -4
- package/src/hooks/useEmailVerification.d.ts.map +1 -1
- package/src/hooks/useEmailVerification.js +8 -4
- package/src/hooks/useUserSettings.d.ts +4 -2
- package/src/hooks/useUserSettings.d.ts.map +1 -1
- package/src/hooks/useUserSettings.js +30 -13
- package/src/services/authService.d.ts.map +1 -1
- package/src/services/authService.js +58 -70
- package/src/wrappers/BackupCodeLoginWrapper.d.ts.map +1 -1
- package/src/wrappers/BackupCodeLoginWrapper.js +0 -1
- package/src/wrappers/ChangePasswordFormWrapper.d.ts.map +1 -1
- package/src/wrappers/RegisterFormWrapper.d.ts.map +1 -1
- package/src/wrappers/RegisterFormWrapper.js +7 -2
|
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.UserSettingsForm = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const i18n_lib_1 = require("@digitaldefiance/i18n-lib");
|
|
7
|
+
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
6
8
|
const material_1 = require("@mui/material");
|
|
7
9
|
const formik_1 = require("formik");
|
|
10
|
+
const moment_timezone_1 = tslib_1.__importDefault(require("moment-timezone"));
|
|
8
11
|
const react_1 = require("react");
|
|
9
12
|
const Yup = tslib_1.__importStar(require("yup"));
|
|
10
|
-
const moment_timezone_1 = tslib_1.__importDefault(require("moment-timezone"));
|
|
11
|
-
const i18n_lib_1 = require("@digitaldefiance/i18n-lib");
|
|
12
|
-
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
13
13
|
const contexts_1 = require("../contexts");
|
|
14
14
|
const UserSettingsForm = ({ initialValues, onSubmit, languages, emailValidation, timezoneValidation, siteLanguageValidation, currencyValidation, darkModeValidation, directChallengeValidation, additionalFields, additionalInitialValues = {}, additionalValidation = {}, labels = {}, }) => {
|
|
15
15
|
const { tComponent } = (0, contexts_1.useI18n)();
|
|
@@ -17,23 +17,29 @@ const UserSettingsForm = ({ initialValues, onSubmit, languages, emailValidation,
|
|
|
17
17
|
const [saving, setSaving] = (0, react_1.useState)(false);
|
|
18
18
|
const [successMessage, setSuccessMessage] = (0, react_1.useState)(null);
|
|
19
19
|
const timezones = (0, react_1.useMemo)(() => moment_timezone_1.default.tz.names(), []);
|
|
20
|
-
const currencies = (0, react_1.useMemo)(() => i18n_lib_1.CurrencyCode.getAllData().map(c => ({
|
|
20
|
+
const currencies = (0, react_1.useMemo)(() => i18n_lib_1.CurrencyCode.getAllData().map((c) => ({
|
|
21
|
+
code: c.code,
|
|
22
|
+
label: `${c.code} - ${c.currency}`,
|
|
23
|
+
})), []);
|
|
21
24
|
const validation = {
|
|
22
|
-
email: emailValidation ||
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required))
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
email: emailValidation ||
|
|
26
|
+
Yup.string()
|
|
27
|
+
.email(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidEmail))
|
|
28
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
29
|
+
timezone: timezoneValidation ||
|
|
30
|
+
Yup.string()
|
|
31
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_TimezoneRequired))
|
|
32
|
+
.test('valid-timezone', tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_TimezoneInvalid), (value) => !value || moment_timezone_1.default.tz.zone(value) !== null),
|
|
33
|
+
siteLanguage: siteLanguageValidation ||
|
|
34
|
+
Yup.string().required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
35
|
+
currency: currencyValidation ||
|
|
36
|
+
Yup.string()
|
|
37
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required))
|
|
38
|
+
.test('valid-currency', tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required), (value) => !value || i18n_lib_1.CurrencyCode.isValid(value)),
|
|
39
|
+
darkMode: darkModeValidation ||
|
|
40
|
+
Yup.boolean().required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
41
|
+
directChallenge: directChallengeValidation ||
|
|
42
|
+
Yup.boolean().required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
37
43
|
};
|
|
38
44
|
const formik = (0, formik_1.useFormik)({
|
|
39
45
|
initialValues: {
|
|
@@ -55,7 +61,9 @@ const UserSettingsForm = ({ initialValues, onSubmit, languages, emailValidation,
|
|
|
55
61
|
setSuccessMessage(null);
|
|
56
62
|
const result = await onSubmit(values);
|
|
57
63
|
if ('success' in result && result.success) {
|
|
58
|
-
setSuccessMessage(result.message ||
|
|
64
|
+
setSuccessMessage(result.message ||
|
|
65
|
+
labels.successMessage ||
|
|
66
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_SaveSuccess));
|
|
59
67
|
setApiErrors({});
|
|
60
68
|
}
|
|
61
69
|
else {
|
|
@@ -73,7 +81,9 @@ const UserSettingsForm = ({ initialValues, onSubmit, languages, emailValidation,
|
|
|
73
81
|
}
|
|
74
82
|
});
|
|
75
83
|
}
|
|
76
|
-
if ('error' in result &&
|
|
84
|
+
if ('error' in result &&
|
|
85
|
+
result.error &&
|
|
86
|
+
!Object.keys(newApiErrors).length) {
|
|
77
87
|
newApiErrors.general = result.error;
|
|
78
88
|
}
|
|
79
89
|
setApiErrors(newApiErrors);
|
|
@@ -83,11 +93,34 @@ const UserSettingsForm = ({ initialValues, onSubmit, languages, emailValidation,
|
|
|
83
93
|
setSaving(false);
|
|
84
94
|
},
|
|
85
95
|
});
|
|
86
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Container, { maxWidth: "sm", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
96
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Container, { maxWidth: "sm", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
97
|
+
mt: 4,
|
|
98
|
+
display: 'flex',
|
|
99
|
+
flexDirection: 'column',
|
|
100
|
+
alignItems: 'center',
|
|
101
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: labels.title ||
|
|
102
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Title) }), (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "form", onSubmit: formik.handleSubmit, sx: { mt: 1, width: '100%' }, children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "email", name: "email", label: labels.email ||
|
|
103
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Email), value: formik.values.email, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.email && (formik.errors.email || apiErrors.email)), helperText: (formik.touched.email &&
|
|
104
|
+
(formik.errors.email || apiErrors.email)) ||
|
|
87
105
|
labels.emailHelper ||
|
|
88
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_EmailHelper), margin: "normal" }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: "timezone-label", children: labels.timezone ||
|
|
89
|
-
|
|
90
|
-
|
|
106
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_EmailHelper), margin: "normal" }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: "timezone-label", children: labels.timezone ||
|
|
107
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Timezone) }), (0, jsx_runtime_1.jsx)(material_1.Select, { labelId: "timezone-label", id: "timezone", name: "timezone", value: formik.values.timezone, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.timezone && Boolean(formik.errors.timezone), label: labels.timezone ||
|
|
108
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Timezone), children: timezones.map((tz) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: tz, children: tz }, tz))) }), formik.touched.timezone &&
|
|
109
|
+
(formik.errors.timezone || apiErrors.timezone) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", variant: "caption", children: formik.errors.timezone || apiErrors.timezone }))] }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: "language-label", children: labels.siteLanguage ||
|
|
110
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_SiteLanguage) }), (0, jsx_runtime_1.jsx)(material_1.Select, { labelId: "language-label", id: "siteLanguage", name: "siteLanguage", value: formik.values.siteLanguage, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.siteLanguage &&
|
|
111
|
+
Boolean(formik.errors.siteLanguage), label: labels.siteLanguage ||
|
|
112
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_SiteLanguage), children: languages.map((lang) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: lang.code, children: lang.label }, lang.code))) }), formik.touched.siteLanguage &&
|
|
113
|
+
(formik.errors.siteLanguage || apiErrors.siteLanguage) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", variant: "caption", children: formik.errors.siteLanguage || apiErrors.siteLanguage }))] }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: "currency-label", children: labels.currency ||
|
|
114
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Currency) }), (0, jsx_runtime_1.jsx)(material_1.Select, { labelId: "currency-label", id: "currency", name: "currency", value: formik.values.currency, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.currency && Boolean(formik.errors.currency), label: labels.currency ||
|
|
115
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Currency), children: currencies.map((curr) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: curr.code, children: curr.label }, curr.code))) }), formik.touched.currency &&
|
|
116
|
+
(formik.errors.currency || apiErrors.currency) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", variant: "caption", children: formik.errors.currency || apiErrors.currency }))] }), (0, jsx_runtime_1.jsx)(material_1.FormControl, { fullWidth: true, margin: "normal", children: (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Switch, { id: "darkMode", name: "darkMode", checked: formik.values.darkMode, onChange: formik.handleChange }), label: labels.darkMode ||
|
|
117
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_DarkMode) }) }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Switch, { id: "directChallenge", name: "directChallenge", checked: formik.values.directChallenge, onChange: formik.handleChange }), label: labels.directChallenge ||
|
|
118
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_DirectChallengeLabel) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", color: "text.secondary", sx: { ml: 4, mt: -1 }, children: labels.directChallengeHelper ||
|
|
119
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_DirectChallengeHelper) })] }), additionalFields && additionalFields(formik), apiErrors.general && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: apiErrors.general })), successMessage && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: successMessage })), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", color: "primary", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: saving
|
|
120
|
+
? labels.saving ||
|
|
121
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Saving)
|
|
122
|
+
: labels.save ||
|
|
123
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Save) })] })] }) }));
|
|
91
124
|
};
|
|
92
125
|
exports.UserSettingsForm = UserSettingsForm;
|
|
93
126
|
exports.default = exports.UserSettingsForm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VerifyEmailPage.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/VerifyEmailPage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"VerifyEmailPage.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/VerifyEmailPage.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,EAAE,EAAgC,MAAM,OAAO,CAAC;AAGzD,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7E,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAoJpD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -2,24 +2,33 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VerifyEmailPage = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
5
6
|
const material_1 = require("@mui/material");
|
|
6
7
|
const react_1 = require("react");
|
|
7
|
-
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
8
8
|
const contexts_1 = require("../contexts");
|
|
9
9
|
const VerifyEmailPage = ({ token, onVerify, labels = {}, loginLink = '/login', resendLink = '/resend-verification', }) => {
|
|
10
|
-
const {
|
|
10
|
+
const { tComponent } = (0, contexts_1.useI18n)();
|
|
11
11
|
const [message, setMessage] = (0, react_1.useState)('');
|
|
12
12
|
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
13
13
|
const [verificationStatus, setVerificationStatus] = (0, react_1.useState)('pending');
|
|
14
|
-
const translatedLabels = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
const translatedLabels = (0, react_1.useMemo)(() => {
|
|
15
|
+
return {
|
|
16
|
+
title: labels.title ||
|
|
17
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_EmailVerification),
|
|
18
|
+
success: labels.success ||
|
|
19
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.EmailVerification_Success),
|
|
20
|
+
failed: labels.failed ||
|
|
21
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.EmailVerification_Failed),
|
|
22
|
+
noToken: labels.noToken ||
|
|
23
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.NoVerificationTokenProvided),
|
|
24
|
+
proceedToLogin: labels.proceedToLogin ||
|
|
25
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ProceedToLogin),
|
|
26
|
+
contactSupport: labels.contactSupport ||
|
|
27
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.HavingTroubleContactSupport),
|
|
28
|
+
requestNewEmail: labels.requestNewEmail ||
|
|
29
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.RequestNewVerificationEmail),
|
|
30
|
+
};
|
|
31
|
+
}, [labels, tComponent]);
|
|
23
32
|
(0, react_1.useEffect)(() => {
|
|
24
33
|
const verifyEmail = async (verificationToken) => {
|
|
25
34
|
try {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Member as FrontendMember,
|
|
1
|
+
import { EmailString, Member as FrontendMember, IECIESConfig, SecureString } from '@digitaldefiance/ecies-lib';
|
|
2
2
|
import { CurrencyCode } from '@digitaldefiance/i18n-lib';
|
|
3
|
+
import { IConstants, IRequestUserDTO, ISuccessMessage, IUserSettings } from '@digitaldefiance/suite-core-lib';
|
|
3
4
|
import { Wallet } from '@ethereumjs/wallet';
|
|
4
|
-
import { ReactNode } from 'react';
|
|
5
|
-
import { ISuccessMessage, IRequestUserDTO, IConstants, IUserSettings } from '@digitaldefiance/suite-core-lib';
|
|
6
5
|
import { PaletteMode } from '@mui/material';
|
|
6
|
+
import { ReactNode } from 'react';
|
|
7
7
|
export interface AuthContextData {
|
|
8
8
|
/**
|
|
9
9
|
* True if the user has a global admin role
|
|
@@ -147,6 +147,6 @@ export type AuthProviderProps = {
|
|
|
147
147
|
onLogout?: () => void;
|
|
148
148
|
};
|
|
149
149
|
export declare const AuthContext: import("react").Context<AuthContextData>;
|
|
150
|
-
export declare const AuthProvider: ({ children, baseUrl, constants, eciesConfig, onLogout }: AuthProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
150
|
+
export declare const AuthProvider: ({ children, baseUrl, constants, eciesConfig, onLogout, }: AuthProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
151
151
|
export declare const useAuth: () => AuthContextData;
|
|
152
152
|
//# sourceMappingURL=AuthProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthProvider.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/contexts/AuthProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"AuthProvider.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/contexts/AuthProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EACX,MAAM,IAAI,cAAc,EACxB,YAAY,EAGZ,YAAY,EACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,YAAY,EAEb,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,UAAU,EACV,eAAe,EACf,eAAe,EACf,aAAa,EAGd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAEL,SAAS,EAMV,MAAM,OAAO,CAAC;AASf,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;;OAQG;IACH,eAAe,EAAE,CACf,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,OAAO,EACxB,WAAW,CAAC,EAAE,MAAM,KACjB,OAAO,CACR;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GACzE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CACrC,CAAC;IACF;;;OAGG;IACH,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB;;;;;OAKG;IACH,cAAc,EAAE,CACd,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,KAChB,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;IAC9B,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,UAAU,CAAC;IACtB,WAAW,EAAE,YAAY,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,WAAW,0CAEvB,CAAC;AAurBF,eAAO,MAAM,YAAY,GAAI,0DAM1B,iBAAiB,4CAWnB,CAAC;AAEF,eAAO,MAAM,OAAO,uBAEnB,CAAC"}
|
|
@@ -4,18 +4,18 @@ exports.useAuth = exports.AuthProvider = exports.AuthContext = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
|
|
6
6
|
const i18n_lib_1 = require("@digitaldefiance/i18n-lib");
|
|
7
|
+
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
7
8
|
const react_1 = require("react");
|
|
8
|
-
const I18nProvider_1 = require("./I18nProvider");
|
|
9
|
-
const ThemeProvider_1 = require("./ThemeProvider");
|
|
10
|
-
const authService_1 = require("../services/authService");
|
|
11
|
-
const authenticatedApi_1 = require("../services/authenticatedApi");
|
|
12
9
|
const useExpiringValue_1 = require("../hooks/useExpiringValue");
|
|
13
10
|
const useLocalStorage_1 = require("../hooks/useLocalStorage");
|
|
14
11
|
const useUserSettings_1 = require("../hooks/useUserSettings");
|
|
15
|
-
const
|
|
12
|
+
const authService_1 = require("../services/authService");
|
|
13
|
+
const authenticatedApi_1 = require("../services/authenticatedApi");
|
|
14
|
+
const I18nProvider_1 = require("./I18nProvider");
|
|
15
|
+
const ThemeProvider_1 = require("./ThemeProvider");
|
|
16
16
|
exports.AuthContext = (0, react_1.createContext)({});
|
|
17
|
-
const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout }) => {
|
|
18
|
-
const {
|
|
17
|
+
const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout, }) => {
|
|
18
|
+
const { tComponent } = (0, I18nProvider_1.useI18n)();
|
|
19
19
|
const { setColorMode: themeSetPaletteMode, mode: colorMode } = (0, ThemeProvider_1.useTheme)();
|
|
20
20
|
const authService = (0, react_1.useMemo)(() => (0, authService_1.createAuthService)(constants, baseUrl, eciesConfig), [constants, baseUrl, eciesConfig]);
|
|
21
21
|
const authenticatedApi = (0, react_1.useMemo)(() => (0, authenticatedApi_1.createAuthenticatedApiClient)(baseUrl), [baseUrl]);
|
|
@@ -53,7 +53,9 @@ const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout
|
|
|
53
53
|
(0, react_1.useEffect)(() => {
|
|
54
54
|
if (user?.siteLanguage) {
|
|
55
55
|
(async () => {
|
|
56
|
-
await setUserSettingAndUpdateSettings({
|
|
56
|
+
await setUserSettingAndUpdateSettings({
|
|
57
|
+
siteLanguage: user.siteLanguage,
|
|
58
|
+
});
|
|
57
59
|
})();
|
|
58
60
|
}
|
|
59
61
|
// We intentionally only react to changes in the user's saved language.
|
|
@@ -67,7 +69,14 @@ const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout
|
|
|
67
69
|
}
|
|
68
70
|
// Only save to storage if a custom duration was provided
|
|
69
71
|
return mnemonicManager.setValue(mnemonic, finalDurationSeconds, durationSeconds !== undefined);
|
|
70
|
-
},
|
|
72
|
+
},
|
|
73
|
+
// mnemonicManager is intentionally excluded as it's a stable reference from useExpiringValue
|
|
74
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
75
|
+
[
|
|
76
|
+
mnemonicExpirationSeconds,
|
|
77
|
+
mnemonicManager.setValue,
|
|
78
|
+
_setMnemonicExpirationSeconds,
|
|
79
|
+
]);
|
|
71
80
|
const setWallet = (0, react_1.useCallback)((wallet, durationSeconds) => {
|
|
72
81
|
const finalDurationSeconds = durationSeconds ?? walletExpirationSeconds;
|
|
73
82
|
// Store the duration to localStorage if provided
|
|
@@ -76,7 +85,14 @@ const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout
|
|
|
76
85
|
}
|
|
77
86
|
// Only save to storage if a custom duration was provided
|
|
78
87
|
return walletManager.setValue(wallet, finalDurationSeconds, durationSeconds !== undefined);
|
|
79
|
-
},
|
|
88
|
+
},
|
|
89
|
+
// walletManager is intentionally excluded as it's a stable reference from useExpiringValue
|
|
90
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
|
+
[
|
|
92
|
+
walletExpirationSeconds,
|
|
93
|
+
walletManager.setValue,
|
|
94
|
+
_setWalletExpirationSeconds,
|
|
95
|
+
]);
|
|
80
96
|
const clearMnemonic = mnemonicManager.clearValue;
|
|
81
97
|
const clearWallet = walletManager.clearValue;
|
|
82
98
|
const checkAuth = (0, react_1.useCallback)(async () => {
|
|
@@ -104,7 +120,7 @@ const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout
|
|
|
104
120
|
else if ('id' in userData && 'email' in userData) {
|
|
105
121
|
const userDataDTO = userData;
|
|
106
122
|
setUser(userDataDTO);
|
|
107
|
-
setIsGlobalAdmin(
|
|
123
|
+
setIsGlobalAdmin(userDataDTO.roles.some((r) => r.admin));
|
|
108
124
|
setIsAuthenticated(true);
|
|
109
125
|
setToken(token);
|
|
110
126
|
await setUserSettingAndUpdateSettings({
|
|
@@ -128,7 +144,13 @@ const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout
|
|
|
128
144
|
setLoading(false);
|
|
129
145
|
setIsCheckingAuth(false);
|
|
130
146
|
}
|
|
131
|
-
}, [
|
|
147
|
+
}, [
|
|
148
|
+
authService,
|
|
149
|
+
clearMnemonic,
|
|
150
|
+
clearWallet,
|
|
151
|
+
setUserSettingAndUpdateSettings,
|
|
152
|
+
themeSetPaletteMode,
|
|
153
|
+
]);
|
|
132
154
|
(0, react_1.useEffect)(() => {
|
|
133
155
|
const token = localStorage.getItem('authToken');
|
|
134
156
|
if (token) {
|
|
@@ -206,7 +228,10 @@ const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout
|
|
|
206
228
|
}, []);
|
|
207
229
|
const passwordLogin = (0, react_1.useCallback)(async (password, username, email) => {
|
|
208
230
|
if (!isBrowserPasswordLoginAvailable()) {
|
|
209
|
-
return {
|
|
231
|
+
return {
|
|
232
|
+
error: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Error_Login_PasswordLoginNotSetup),
|
|
233
|
+
errorType: 'PasswordLoginNotSetup',
|
|
234
|
+
};
|
|
210
235
|
}
|
|
211
236
|
setLoading(true);
|
|
212
237
|
const passwordLoginService = getPasswordLoginService();
|
|
@@ -227,7 +252,15 @@ const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout
|
|
|
227
252
|
});
|
|
228
253
|
}
|
|
229
254
|
return loginResult;
|
|
230
|
-
}, [
|
|
255
|
+
}, [
|
|
256
|
+
authService,
|
|
257
|
+
getPasswordLoginService,
|
|
258
|
+
setMnemonic,
|
|
259
|
+
setWallet,
|
|
260
|
+
tComponent,
|
|
261
|
+
isBrowserPasswordLoginAvailable,
|
|
262
|
+
setUserSettingAndUpdateSettings,
|
|
263
|
+
]);
|
|
231
264
|
const refreshToken = (0, react_1.useCallback)(async () => {
|
|
232
265
|
try {
|
|
233
266
|
const result = await authService.refreshToken();
|
|
@@ -248,14 +281,14 @@ const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout
|
|
|
248
281
|
const register = (0, react_1.useCallback)(async (username, email, timezone, password) => {
|
|
249
282
|
const registerResult = await authService.register(username, email, timezone, password);
|
|
250
283
|
return registerResult;
|
|
251
|
-
}, [
|
|
284
|
+
}, [authService]);
|
|
252
285
|
const requestEmailLogin = (0, react_1.useCallback)(async (username, email) => {
|
|
253
286
|
setLoading(true);
|
|
254
287
|
const result = await authService.requestEmailLogin(username, email);
|
|
255
288
|
setLoading(false);
|
|
256
289
|
return result;
|
|
257
|
-
}, [
|
|
258
|
-
const setUpBrowserPasswordLogin = (0, react_1.useCallback)(async (mnemonic, password
|
|
290
|
+
}, [authService]);
|
|
291
|
+
const setUpBrowserPasswordLogin = (0, react_1.useCallback)(async (mnemonic, password) => {
|
|
259
292
|
setLoading(true);
|
|
260
293
|
const passwordLoginService = getPasswordLoginService();
|
|
261
294
|
try {
|
|
@@ -263,13 +296,19 @@ const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout
|
|
|
263
296
|
setLoading(false);
|
|
264
297
|
setWallet(wallet);
|
|
265
298
|
setMnemonic(mnemonic);
|
|
266
|
-
return {
|
|
299
|
+
return {
|
|
300
|
+
success: true,
|
|
301
|
+
message: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.PasswordLogin_Setup_Success),
|
|
302
|
+
};
|
|
267
303
|
}
|
|
268
304
|
catch {
|
|
269
305
|
setLoading(false);
|
|
270
|
-
return {
|
|
306
|
+
return {
|
|
307
|
+
success: false,
|
|
308
|
+
message: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.PasswordLogin_Setup_Failure),
|
|
309
|
+
};
|
|
271
310
|
}
|
|
272
|
-
}, [setMnemonic, setWallet,
|
|
311
|
+
}, [getPasswordLoginService, setMnemonic, setWallet, tComponent]);
|
|
273
312
|
const backupCodeLogin = (0, react_1.useCallback)(async (identifier, code, isEmail, recoverMnemonic, newPassword) => {
|
|
274
313
|
setLoading(true);
|
|
275
314
|
const loginResult = await authService.backupCodeLogin(identifier, code, isEmail, recoverMnemonic, newPassword);
|
|
@@ -327,7 +366,10 @@ const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout
|
|
|
327
366
|
}, [authService, setUserSettingAndUpdateSettings]);
|
|
328
367
|
const changePassword = (0, react_1.useCallback)(async (currentPassword, newPassword) => {
|
|
329
368
|
if (!isBrowserPasswordLoginAvailable()) {
|
|
330
|
-
return {
|
|
369
|
+
return {
|
|
370
|
+
error: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Error_Login_PasswordLoginNotSetup),
|
|
371
|
+
errorType: 'PasswordLoginNotSetup',
|
|
372
|
+
};
|
|
331
373
|
}
|
|
332
374
|
setLoading(true);
|
|
333
375
|
try {
|
|
@@ -335,19 +377,31 @@ const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout
|
|
|
335
377
|
const { mnemonic, wallet } = await passwordLoginService.getWalletAndMnemonicFromLocalStorageBundle(new ecies_lib_1.SecureString(currentPassword));
|
|
336
378
|
if (!mnemonic) {
|
|
337
379
|
setLoading(false);
|
|
338
|
-
return {
|
|
380
|
+
return {
|
|
381
|
+
error: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.PasswordLogin_InvalidCurrentPassword),
|
|
382
|
+
errorType: 'InvalidCurrentPassword',
|
|
383
|
+
};
|
|
339
384
|
}
|
|
340
385
|
await passwordLoginService.setupPasswordLoginLocalStorageBundle(mnemonic, new ecies_lib_1.SecureString(newPassword));
|
|
341
386
|
setLoading(false);
|
|
342
387
|
setWallet(wallet);
|
|
343
388
|
setMnemonic(mnemonic);
|
|
344
|
-
return {
|
|
389
|
+
return {
|
|
390
|
+
success: true,
|
|
391
|
+
message: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.PasswordChange_Success),
|
|
392
|
+
};
|
|
345
393
|
}
|
|
346
|
-
catch
|
|
394
|
+
catch {
|
|
347
395
|
setLoading(false);
|
|
348
396
|
return { error: 'Password change failed' };
|
|
349
397
|
}
|
|
350
|
-
}, [
|
|
398
|
+
}, [
|
|
399
|
+
getPasswordLoginService,
|
|
400
|
+
setMnemonic,
|
|
401
|
+
setWallet,
|
|
402
|
+
tComponent,
|
|
403
|
+
isBrowserPasswordLoginAvailable,
|
|
404
|
+
]);
|
|
351
405
|
const contextValue = (0, react_1.useMemo)(() => {
|
|
352
406
|
const setUserAndIsAuthenticated = async (newUser) => {
|
|
353
407
|
setUser(newUser);
|
|
@@ -394,8 +448,9 @@ const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout
|
|
|
394
448
|
wallet: walletManager.value,
|
|
395
449
|
walletExpirationSeconds,
|
|
396
450
|
};
|
|
451
|
+
// authenticatedApi is intentionally excluded as it's a stable reference from useMemo
|
|
452
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
397
453
|
}, [
|
|
398
|
-
authenticatedApi,
|
|
399
454
|
authState,
|
|
400
455
|
backupCodeLogin,
|
|
401
456
|
changePassword,
|
|
@@ -436,7 +491,7 @@ const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout
|
|
|
436
491
|
]);
|
|
437
492
|
return ((0, jsx_runtime_1.jsx)(exports.AuthContext.Provider, { value: contextValue, children: children }));
|
|
438
493
|
};
|
|
439
|
-
const AuthProvider = ({ children, baseUrl, constants, eciesConfig, onLogout }) => {
|
|
494
|
+
const AuthProvider = ({ children, baseUrl, constants, eciesConfig, onLogout, }) => {
|
|
440
495
|
return ((0, jsx_runtime_1.jsx)(AuthProviderInner, { baseUrl: baseUrl, constants: constants, eciesConfig: eciesConfig, onLogout: onLogout, children: children }));
|
|
441
496
|
};
|
|
442
497
|
exports.AuthProvider = AuthProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18nProvider.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/contexts/I18nProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"I18nProvider.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/contexts/I18nProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAGX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,EAAE,EACF,SAAS,EAIV,MAAM,OAAO,CAAC;AAEf,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,EAAE,UAAU,CAAC;IACvB,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACxD;AAED,MAAM,WAAW,eAAe;IAC9B,CAAC,EAAE,CACD,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EACtC,QAAQ,CAAC,EAAE,MAAM,KACd,MAAM,CAAC;IACZ,UAAU,EAAE,CAAC,UAAU,SAAS,MAAM,EACpC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,UAAU,EACrB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EACtC,QAAQ,CAAC,EAAE,MAAM,KACd,MAAM,CAAC;IACZ,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,eAAe,EAAE,MAAM,CAAC;CACzB;AAID,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAkE9C,CAAC;AAEF,eAAO,MAAM,OAAO,uBAMnB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
|
-
import { MenuType } from '../types/MenuType';
|
|
3
|
-
import { IMenuOption } from '../interfaces/IMenuOption';
|
|
4
2
|
import { IMenuConfig } from '../interfaces/IMenuConfig';
|
|
3
|
+
import { IMenuOption } from '../interfaces/IMenuOption';
|
|
4
|
+
import { MenuType } from '../types/MenuType';
|
|
5
5
|
interface MenuProviderProps {
|
|
6
6
|
children: ReactNode;
|
|
7
7
|
menuConfigs?: IMenuConfig[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuContext.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/contexts/MenuContext.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MenuContext.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/contexts/MenuContext.tsx"],"names":[],"mappings":"AAoBA,OAAO,EACL,EAAE,EACF,SAAS,EAQV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,QAAQ,EAAa,MAAM,mBAAmB,CAAC;AAMxD,UAAU,iBAAiB;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,WAAW,CAAC,EAAE,WAAW,EAAE,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,UAAU,eAAe;IACvB,WAAW,EAAE,WAAW,EAAE,CAAC;IAC3B,cAAc,EAAE,CACd,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,OAAO,KACrB,WAAW,EAAE,CAAC;IACnB,kBAAkB,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,MAAM,IAAI,CAAC;IACxD,mBAAmB,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,MAAM,IAAI,CAAC;IAC5D,WAAW,EAAE,MAAM,KAAK,CAAC,WAAW,CAAC,CAAC;CACvC;AAID,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAyU9C,CAAC;AAEF,eAAO,MAAM,OAAO,QAAO,eAM1B,CAAC"}
|