@digitaldefiance/express-suite-react-components 2.2.0 → 2.2.1
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/README.md
CHANGED
|
@@ -261,6 +261,32 @@ MIT © Digital Defiance
|
|
|
261
261
|
|
|
262
262
|
## ChangeLog
|
|
263
263
|
|
|
264
|
+
### v2.2.1
|
|
265
|
+
|
|
266
|
+
- Update BackupCodeLoginForm
|
|
267
|
+
|
|
268
|
+
### v2.2.0
|
|
269
|
+
|
|
270
|
+
#### Changed
|
|
271
|
+
- Updated peer dependencies: pinned `react-router-dom` to `6.29.0`
|
|
272
|
+
- Updated dependencies: `@digitaldefiance/i18n-lib` to `3.6.0`, `@digitaldefiance/suite-core-lib` to `2.2.1`
|
|
273
|
+
- Updated dev dependencies: pinned `react` and `react-dom` to `19.0.0`, downgraded `@testing-library/react` to `16.0.1`
|
|
274
|
+
- Replaced `BrowserRouter` with `MemoryRouter` in test files for better test isolation
|
|
275
|
+
|
|
276
|
+
#### Added
|
|
277
|
+
- Jest environment options: `resources: 'usable'` and `runScripts: 'dangerously'` for improved test compatibility
|
|
278
|
+
- `@testing-library/react-hooks` dev dependency (`8.0.1`)
|
|
279
|
+
- React strict mode configuration in test setup
|
|
280
|
+
- Custom render utility with `MemoryRouter` wrapper in `tests/test-utils.tsx`
|
|
281
|
+
|
|
282
|
+
#### Fixed
|
|
283
|
+
- Test environment configuration for React 19 compatibility
|
|
284
|
+
- Router setup in AuthProvider tests to use `MemoryRouter`
|
|
285
|
+
|
|
286
|
+
#### Removed
|
|
287
|
+
- Unused `renderWithProviders` helper function in UnAuthRoute tests
|
|
288
|
+
- External mock dependency for RegisterForm tests (inlined mock data)
|
|
289
|
+
|
|
264
290
|
### v2.1.57
|
|
265
291
|
|
|
266
292
|
- Update libs
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitaldefiance/express-suite-react-components",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "React MUI components for Digital Defiance Express Suite",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@digitaldefiance/i18n-lib": "3.6.0",
|
|
29
|
-
"@digitaldefiance/suite-core-lib": "2.2.
|
|
29
|
+
"@digitaldefiance/suite-core-lib": "2.2.3",
|
|
30
30
|
"@emotion/react": "^11.14.0",
|
|
31
31
|
"@emotion/styled": "^11.14.0",
|
|
32
32
|
"@mui/icons-material": "^7.0.2",
|
|
@@ -20,11 +20,7 @@ export interface BackupCodeLoginFormProps {
|
|
|
20
20
|
}>;
|
|
21
21
|
onNavigate?: (path: string, state?: any) => void;
|
|
22
22
|
isAuthenticated?: boolean;
|
|
23
|
-
|
|
24
|
-
usernameValidation?: Yup.StringSchema;
|
|
25
|
-
codeValidation?: Yup.StringSchema;
|
|
26
|
-
passwordValidation?: Yup.StringSchema;
|
|
27
|
-
confirmPasswordValidation?: Yup.StringSchema;
|
|
23
|
+
validationSchema?: Yup.ObjectSchema<any>;
|
|
28
24
|
labels?: {
|
|
29
25
|
title?: string;
|
|
30
26
|
email?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackupCodeLoginForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/BackupCodeLoginForm.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAI3B,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,CACR,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,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACjD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,
|
|
1
|
+
{"version":3,"file":"BackupCodeLoginForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/BackupCodeLoginForm.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAI3B,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,CACR,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,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACjD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACzC,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAAC,wBAAwB,CA4P5D,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -9,28 +9,13 @@ const react_1 = require("react");
|
|
|
9
9
|
const Yup = tslib_1.__importStar(require("yup"));
|
|
10
10
|
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
11
11
|
const contexts_1 = require("../contexts");
|
|
12
|
-
const BackupCodeLoginForm = ({ onSubmit, onNavigate, isAuthenticated = false,
|
|
12
|
+
const BackupCodeLoginForm = ({ onSubmit, onNavigate, isAuthenticated = false, validationSchema, labels = {}, }) => {
|
|
13
13
|
const { tComponent } = (0, contexts_1.useI18n)();
|
|
14
14
|
const [loginType, setLoginType] = (0, react_1.useState)('email');
|
|
15
15
|
const [loginError, setLoginError] = (0, react_1.useState)(null);
|
|
16
16
|
const [recoveredMnemonic, setRecoveredMnemonic] = (0, react_1.useState)(null);
|
|
17
17
|
const [successMessage, setSuccessMessage] = (0, react_1.useState)(null);
|
|
18
18
|
const [codesRemaining, setCodesRemaining] = (0, react_1.useState)(null);
|
|
19
|
-
const validation = {
|
|
20
|
-
email: emailValidation || Yup.string()
|
|
21
|
-
.email(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidEmail))
|
|
22
|
-
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
23
|
-
username: usernameValidation || Yup.string()
|
|
24
|
-
.matches(suite_core_lib_1.Constants.UsernameRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_UsernameRegexErrorTemplate))
|
|
25
|
-
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
26
|
-
code: codeValidation || Yup.string()
|
|
27
|
-
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required))
|
|
28
|
-
.matches(suite_core_lib_1.Constants.BACKUP_CODES.DisplayRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidBackupCode)),
|
|
29
|
-
password: passwordValidation || Yup.string()
|
|
30
|
-
.matches(suite_core_lib_1.Constants.PasswordRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordRegexErrorTemplate)),
|
|
31
|
-
confirmPassword: confirmPasswordValidation || Yup.string()
|
|
32
|
-
.oneOf([Yup.ref('newPassword')], tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordMatch)),
|
|
33
|
-
};
|
|
34
19
|
const translatedLabels = {
|
|
35
20
|
title: labels.title || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.BackupCodeRecovery_Title),
|
|
36
21
|
email: labels.email || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Email),
|
|
@@ -48,11 +33,26 @@ const BackupCodeLoginForm = ({ onSubmit, onNavigate, isAuthenticated = false, em
|
|
|
48
33
|
codesRemaining: labels.codesRemaining || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.BackupCodeRecovery_CodesRemainingTemplate),
|
|
49
34
|
unexpectedError: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_UnexpectedError),
|
|
50
35
|
};
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
36
|
+
const yupFieldValidation = {
|
|
37
|
+
email: Yup.string()
|
|
38
|
+
.email(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidEmail))
|
|
39
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
40
|
+
username: Yup.string()
|
|
41
|
+
.matches(suite_core_lib_1.Constants.UsernameRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_UsernameRegexErrorTemplate))
|
|
42
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
43
|
+
code: Yup.string()
|
|
44
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required))
|
|
45
|
+
.matches(suite_core_lib_1.Constants.BACKUP_CODES.DisplayRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidBackupCode)),
|
|
46
|
+
password: Yup.string()
|
|
47
|
+
.matches(suite_core_lib_1.Constants.PasswordRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordRegexErrorTemplate)),
|
|
48
|
+
confirmPassword: Yup.string()
|
|
49
|
+
.oneOf([Yup.ref('newPassword')], tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordMatch)),
|
|
50
|
+
};
|
|
51
|
+
const yupSchema = validationSchema ?? Yup.object({
|
|
52
|
+
[loginType]: loginType === 'email' ? yupFieldValidation.email : yupFieldValidation.username,
|
|
53
|
+
code: yupFieldValidation.code,
|
|
54
|
+
newPassword: yupFieldValidation.password,
|
|
55
|
+
confirmNewPassword: yupFieldValidation.confirmPassword,
|
|
56
56
|
});
|
|
57
57
|
const formik = (0, formik_1.useFormik)({
|
|
58
58
|
initialValues: {
|
|
@@ -63,7 +63,7 @@ const BackupCodeLoginForm = ({ onSubmit, onNavigate, isAuthenticated = false, em
|
|
|
63
63
|
confirmNewPassword: '',
|
|
64
64
|
recoverMnemonic: false,
|
|
65
65
|
},
|
|
66
|
-
validationSchema,
|
|
66
|
+
validationSchema: yupSchema,
|
|
67
67
|
onSubmit: async (values, { setSubmitting }) => {
|
|
68
68
|
try {
|
|
69
69
|
const loginResult = await onSubmit(loginType === 'email' ? values.email : values.username, values.code, loginType === 'email', values.recoverMnemonic, values.newPassword && values.newPassword.length > 0 ? values.newPassword : undefined);
|