@aws-amplify/ui-react-native 2.4.5 → 2.5.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.
Files changed (61) hide show
  1. package/dist/Authenticator/Authenticator.d.ts +33 -0
  2. package/dist/Authenticator/Authenticator.js +5 -1
  3. package/dist/Authenticator/Defaults/SelectMfaType/SelectMfaType.d.ts +14 -0
  4. package/dist/Authenticator/Defaults/SelectMfaType/SelectMfaType.js +39 -0
  5. package/dist/Authenticator/Defaults/SelectMfaType/index.d.ts +1 -0
  6. package/dist/Authenticator/Defaults/SelectMfaType/index.js +1 -0
  7. package/dist/Authenticator/Defaults/SetupEmail/SetupEmail.d.ts +14 -0
  8. package/dist/Authenticator/Defaults/SetupEmail/SetupEmail.js +39 -0
  9. package/dist/Authenticator/Defaults/SetupEmail/index.d.ts +1 -0
  10. package/dist/Authenticator/Defaults/SetupEmail/index.js +1 -0
  11. package/dist/Authenticator/Defaults/VerifyUser/VerifyUser.js +2 -2
  12. package/dist/Authenticator/Defaults/index.d.ts +3 -1
  13. package/dist/Authenticator/Defaults/index.js +2 -0
  14. package/dist/Authenticator/Defaults/types.d.ts +22 -0
  15. package/dist/Authenticator/common/DefaultFormFields/DefaultSelectMfaTypeFormFields.d.ts +7 -0
  16. package/dist/Authenticator/common/DefaultFormFields/DefaultSelectMfaTypeFormFields.js +12 -0
  17. package/dist/Authenticator/common/DefaultFormFields/{DefaultRadioFormFields.d.ts → DefaultVerifyUserFormFields.d.ts} +2 -2
  18. package/dist/Authenticator/common/DefaultFormFields/{DefaultRadioFormFields.js → DefaultVerifyUserFormFields.js} +7 -5
  19. package/dist/Authenticator/common/DefaultFormFields/index.d.ts +2 -1
  20. package/dist/Authenticator/common/DefaultFormFields/index.js +2 -1
  21. package/dist/Authenticator/hooks/useFieldValues/useFieldValues.js +52 -19
  22. package/dist/Authenticator/hooks/useFieldValues/utils.d.ts +2 -1
  23. package/dist/Authenticator/hooks/useFieldValues/utils.js +26 -3
  24. package/dist/Authenticator/index.d.ts +1 -1
  25. package/dist/index.d.ts +1 -1
  26. package/dist/primitives/RadioGroup/RadioGroup.d.ts +1 -0
  27. package/dist/primitives/RadioGroup/RadioGroup.js +2 -1
  28. package/dist/version.d.ts +1 -1
  29. package/dist/version.js +1 -1
  30. package/lib/Authenticator/Authenticator.js +4 -0
  31. package/lib/Authenticator/Defaults/SelectMfaType/SelectMfaType.js +42 -0
  32. package/lib/Authenticator/Defaults/SelectMfaType/index.js +8 -0
  33. package/lib/Authenticator/Defaults/SetupEmail/SetupEmail.js +42 -0
  34. package/lib/Authenticator/Defaults/SetupEmail/index.js +8 -0
  35. package/lib/Authenticator/Defaults/VerifyUser/VerifyUser.js +1 -1
  36. package/lib/Authenticator/Defaults/index.js +5 -1
  37. package/lib/Authenticator/common/DefaultFormFields/DefaultSelectMfaTypeFormFields.js +15 -0
  38. package/lib/Authenticator/common/DefaultFormFields/{DefaultRadioFormFields.js → DefaultVerifyUserFormFields.js} +7 -5
  39. package/lib/Authenticator/common/DefaultFormFields/index.js +5 -3
  40. package/lib/Authenticator/hooks/useFieldValues/useFieldValues.js +51 -18
  41. package/lib/Authenticator/hooks/useFieldValues/utils.js +29 -5
  42. package/lib/primitives/RadioGroup/RadioGroup.js +3 -1
  43. package/lib/version.js +1 -1
  44. package/package.json +4 -4
  45. package/src/Authenticator/Authenticator.tsx +6 -0
  46. package/src/Authenticator/Defaults/SelectMfaType/SelectMfaType.tsx +87 -0
  47. package/src/Authenticator/Defaults/SelectMfaType/index.ts +1 -0
  48. package/src/Authenticator/Defaults/SetupEmail/SetupEmail.tsx +86 -0
  49. package/src/Authenticator/Defaults/SetupEmail/index.ts +1 -0
  50. package/src/Authenticator/Defaults/VerifyUser/VerifyUser.tsx +2 -2
  51. package/src/Authenticator/Defaults/index.ts +4 -0
  52. package/src/Authenticator/Defaults/types.ts +30 -0
  53. package/src/Authenticator/common/DefaultFormFields/DefaultSelectMfaTypeFormFields.tsx +35 -0
  54. package/src/Authenticator/common/DefaultFormFields/{DefaultRadioFormFields.tsx → DefaultVerifyUserFormFields.tsx} +8 -7
  55. package/src/Authenticator/common/DefaultFormFields/index.ts +2 -1
  56. package/src/Authenticator/hooks/useFieldValues/useFieldValues.ts +65 -21
  57. package/src/Authenticator/hooks/useFieldValues/utils.ts +40 -5
  58. package/src/Authenticator/index.ts +2 -0
  59. package/src/index.ts +2 -0
  60. package/src/primitives/RadioGroup/RadioGroup.tsx +7 -1
  61. package/src/version.ts +1 -1
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = tslib_1.__importStar(require("react"));
5
+ const ui_1 = require("@aws-amplify/ui");
6
+ const common_1 = require("../../common");
7
+ const hooks_1 = require("../../hooks");
8
+ const COMPONENT_NAME = 'SetupEmail';
9
+ const { getBackToSignInText, getConfirmText, getConfirmingText, getSetupEmailText, } = ui_1.authenticatorTextUtil;
10
+ const SetupEmail = ({ fields, handleBlur, handleChange, handleSubmit, isPending, toSignIn, validationErrors, ...rest }) => {
11
+ const { disableFormSubmit: disabled, fields: fieldsWithHandlers, fieldValidationErrors, handleFormSubmit, } = (0, hooks_1.useFieldValues)({
12
+ componentName: COMPONENT_NAME,
13
+ fields,
14
+ handleBlur,
15
+ handleChange,
16
+ handleSubmit,
17
+ validationErrors,
18
+ });
19
+ const headerText = getSetupEmailText();
20
+ const primaryButtonText = isPending ? getConfirmingText() : getConfirmText();
21
+ const secondaryButtonText = getBackToSignInText();
22
+ const buttons = (0, react_1.useMemo)(() => ({
23
+ primary: {
24
+ children: primaryButtonText,
25
+ disabled,
26
+ onPress: handleFormSubmit,
27
+ },
28
+ links: [{ children: secondaryButtonText, onPress: toSignIn }],
29
+ }), [
30
+ disabled,
31
+ handleFormSubmit,
32
+ primaryButtonText,
33
+ secondaryButtonText,
34
+ toSignIn,
35
+ ]);
36
+ return (<common_1.DefaultContent {...rest} buttons={buttons} headerText={headerText} fields={fieldsWithHandlers} isPending={isPending} validationErrors={fieldValidationErrors}/>);
37
+ };
38
+ SetupEmail.Footer = common_1.DefaultFooter;
39
+ SetupEmail.FormFields = common_1.DefaultTextFormFields;
40
+ SetupEmail.Header = common_1.DefaultHeader;
41
+ SetupEmail.displayName = COMPONENT_NAME;
42
+ exports.default = SetupEmail;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SetupEmail = void 0;
7
+ var SetupEmail_1 = require("./SetupEmail");
8
+ Object.defineProperty(exports, "SetupEmail", { enumerable: true, get: function () { return __importDefault(SetupEmail_1).default; } });
@@ -27,7 +27,7 @@ const VerifyUser = ({ fields, handleBlur, handleChange, handleSubmit, skipVerifi
27
27
  return (<common_1.DefaultContent {...rest} body={bodyText} buttons={buttons} fields={fieldsWithHandlers} headerText={headerText} validationErrors={fieldValidationErrors}/>);
28
28
  };
29
29
  VerifyUser.Footer = common_1.DefaultFooter;
30
- VerifyUser.FormFields = common_1.DefaultRadioFormFields;
30
+ VerifyUser.FormFields = common_1.DefaultVerifyUserFormFields;
31
31
  VerifyUser.Header = common_1.DefaultHeader;
32
32
  VerifyUser.displayName = COMPONENT_NAME;
33
33
  exports.default = VerifyUser;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VerifyUser = exports.SignUp = exports.SignIn = exports.SetupTotp = exports.ForgotPassword = exports.ForceNewPassword = exports.ConfirmVerifyUser = exports.ConfirmSignUp = exports.ConfirmSignIn = exports.ConfirmResetPassword = void 0;
3
+ exports.SetupEmail = exports.SelectMfaType = exports.VerifyUser = exports.SignUp = exports.SignIn = exports.SetupTotp = exports.ForgotPassword = exports.ForceNewPassword = exports.ConfirmVerifyUser = exports.ConfirmSignUp = exports.ConfirmSignIn = exports.ConfirmResetPassword = void 0;
4
4
  var ConfirmResetPassword_1 = require("./ConfirmResetPassword");
5
5
  Object.defineProperty(exports, "ConfirmResetPassword", { enumerable: true, get: function () { return ConfirmResetPassword_1.ConfirmResetPassword; } });
6
6
  var ConfirmSignIn_1 = require("./ConfirmSignIn");
@@ -21,3 +21,7 @@ var SignUp_1 = require("./SignUp");
21
21
  Object.defineProperty(exports, "SignUp", { enumerable: true, get: function () { return SignUp_1.SignUp; } });
22
22
  var VerifyUser_1 = require("./VerifyUser");
23
23
  Object.defineProperty(exports, "VerifyUser", { enumerable: true, get: function () { return VerifyUser_1.VerifyUser; } });
24
+ var SelectMfaType_1 = require("./SelectMfaType");
25
+ Object.defineProperty(exports, "SelectMfaType", { enumerable: true, get: function () { return SelectMfaType_1.SelectMfaType; } });
26
+ var SetupEmail_1 = require("./SetupEmail");
27
+ Object.defineProperty(exports, "SetupEmail", { enumerable: true, get: function () { return SetupEmail_1.SetupEmail; } });
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = tslib_1.__importDefault(require("react"));
5
+ const RadioGroup_1 = require("../../../primitives/RadioGroup");
6
+ const Radio_1 = require("../../../primitives/Radio");
7
+ const DefaultSelectMfaTypeFormFields = ({ fields = [], fieldContainerStyle, fieldLabelStyle, isPending, style, }) => {
8
+ // set initial value for radio field based on selected bool
9
+ const initialValue = fields.find((field) => !!field.selected)?.value;
10
+ return (<RadioGroup_1.RadioGroup disabled={isPending} style={style} initialValue={initialValue}>
11
+ {fields.map(({ value, label, ...props }) => (<Radio_1.Radio {...props} key={value} value={value} label={label} labelStyle={fieldLabelStyle} style={fieldContainerStyle}/>))}
12
+ </RadioGroup_1.RadioGroup>);
13
+ };
14
+ DefaultSelectMfaTypeFormFields.displayName = 'FormFields';
15
+ exports.default = DefaultSelectMfaTypeFormFields;
@@ -8,9 +8,11 @@ const attributeMap = {
8
8
  email: 'Email',
9
9
  phone_number: 'Phone Number',
10
10
  };
11
- const DefaultRadioFormFields = ({ fields, fieldContainerStyle, fieldLabelStyle, isPending, style, }) => {
12
- return (<primitives_1.RadioGroup disabled={isPending} style={style}>
13
- {(fields ?? []).map(({ name, value, ...props }) => {
11
+ const DefaultVerifyUserFormFields = ({ fields = [], fieldContainerStyle, fieldLabelStyle, isPending, style, }) => {
12
+ // set initial value for radio field based on selected bool
13
+ const initialValue = fields.find((field) => !!field.selected)?.name;
14
+ return (<primitives_1.RadioGroup disabled={isPending} style={style} initialValue={initialValue}>
15
+ {fields.map(({ name, value, ...props }) => {
14
16
  const attributeType = attributeMap[name];
15
17
  return (<primitives_1.Radio {...props} key={value}
16
18
  // value has to be name, because Auth is only interested in the
@@ -19,5 +21,5 @@ const DefaultRadioFormFields = ({ fields, fieldContainerStyle, fieldLabelStyle,
19
21
  })}
20
22
  </primitives_1.RadioGroup>);
21
23
  };
22
- DefaultRadioFormFields.displayName = 'FormFields';
23
- exports.default = DefaultRadioFormFields;
24
+ DefaultVerifyUserFormFields.displayName = 'FormFields';
25
+ exports.default = DefaultVerifyUserFormFields;
@@ -3,8 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DefaultTextFormFields = exports.DefaultRadioFormFields = void 0;
7
- var DefaultRadioFormFields_1 = require("./DefaultRadioFormFields");
8
- Object.defineProperty(exports, "DefaultRadioFormFields", { enumerable: true, get: function () { return __importDefault(DefaultRadioFormFields_1).default; } });
6
+ exports.DefaultSelectMfaTypeFormFields = exports.DefaultVerifyUserFormFields = exports.DefaultTextFormFields = void 0;
9
7
  var DefaultTextFormFields_1 = require("./DefaultTextFormFields");
10
8
  Object.defineProperty(exports, "DefaultTextFormFields", { enumerable: true, get: function () { return __importDefault(DefaultTextFormFields_1).default; } });
9
+ var DefaultVerifyUserFormFields_1 = require("./DefaultVerifyUserFormFields");
10
+ Object.defineProperty(exports, "DefaultVerifyUserFormFields", { enumerable: true, get: function () { return __importDefault(DefaultVerifyUserFormFields_1).default; } });
11
+ var DefaultSelectMfaTypeFormFields_1 = require("./DefaultSelectMfaTypeFormFields");
12
+ Object.defineProperty(exports, "DefaultSelectMfaTypeFormFields", { enumerable: true, get: function () { return __importDefault(DefaultSelectMfaTypeFormFields_1).default; } });
@@ -5,29 +5,68 @@ const utils_1 = require("aws-amplify/utils");
5
5
  const utils_2 = require("./utils");
6
6
  const logger = new utils_1.ConsoleLogger('Authenticator');
7
7
  function useFieldValues({ componentName, fields = [], handleBlur, handleChange, handleSubmit, validationErrors, }) {
8
- const [values, setValues] = (0, react_1.useState)({});
9
8
  const [touched, setTouched] = (0, react_1.useState)({});
10
9
  const [fieldValidationErrors, setFieldValidationErrors] = (0, react_1.useState)({});
11
- const isRadioFieldComponent = componentName === 'VerifyUser';
10
+ const isVerifyUserRoute = componentName === 'VerifyUser';
11
+ const isSelectMfaTypeRoute = componentName === 'SelectMfaType';
12
+ const isRadioFieldComponent = isVerifyUserRoute || isSelectMfaTypeRoute;
13
+ // initialize values based on route
14
+ // select mfa type screen should auto select first radio option
15
+ const [values, setValues] = (0, react_1.useState)(() => {
16
+ const result = {};
17
+ if (isSelectMfaTypeRoute) {
18
+ const initialValue = fields[0]?.value;
19
+ if (initialValue) {
20
+ result.mfa_type = initialValue;
21
+ }
22
+ }
23
+ if (isVerifyUserRoute) {
24
+ const initialValue = fields[0]?.name;
25
+ if (initialValue) {
26
+ result.unverifiedAttr = initialValue;
27
+ }
28
+ }
29
+ return result;
30
+ });
12
31
  const sanitizedFields = (0, react_1.useMemo)(() => {
13
32
  if (!Array.isArray(fields)) {
14
33
  logger.warn(`Invalid fields type of ${typeof fields} passed to ${componentName}. fields must be of type array.`);
15
34
  return [];
16
35
  }
17
- if (isRadioFieldComponent) {
18
- return (0, utils_2.getSanitizedRadioFields)(fields, componentName);
36
+ if (isVerifyUserRoute) {
37
+ return (0, utils_2.getSanitizedVerifyUserFields)(fields);
38
+ }
39
+ if (isSelectMfaTypeRoute) {
40
+ return (0, utils_2.getSanitizedSelectMfaTypeFields)(fields);
19
41
  }
20
42
  return (0, utils_2.getSanitizedTextFields)(fields, componentName);
21
- }, [componentName, fields, isRadioFieldComponent]);
43
+ }, [componentName, fields, isVerifyUserRoute, isSelectMfaTypeRoute]);
22
44
  const fieldsWithHandlers = sanitizedFields.map((field) => {
23
45
  if ((0, utils_2.isRadioFieldOptions)(field)) {
24
46
  const onChange = (value) => {
25
47
  // call `onChange` passed as radio `field` option
26
48
  field.onChange?.(value);
27
- // set `name` as value of 'unverifiedAttr'
28
- setValues({ unverifiedAttr: value });
49
+ // on VerifyUser route, set `name` as value of 'unverifiedAttr'
50
+ // on SelectMfaTYpe route, set `name` as value of 'mfa_type'
51
+ const fieldName = isVerifyUserRoute
52
+ ? 'unverifiedAttr'
53
+ : isSelectMfaTypeRoute
54
+ ? 'mfa_type'
55
+ : field.name;
56
+ setValues((prev) => ({ ...prev, [fieldName]: value }));
29
57
  };
30
- return { ...field, onChange };
58
+ const result = {
59
+ ...field,
60
+ onChange,
61
+ };
62
+ // bind selected boolean attribute for radio field
63
+ if (isSelectMfaTypeRoute) {
64
+ result.selected = values.mfa_type === field.value;
65
+ }
66
+ if (isVerifyUserRoute) {
67
+ result.selected = values.unverifiedAttr === field.name;
68
+ }
69
+ return result;
31
70
  }
32
71
  const { name, label, labelHidden, ...rest } = field;
33
72
  const onBlur = (event) => {
@@ -63,17 +102,11 @@ function useFieldValues({ componentName, fields = [], handleBlur, handleChange,
63
102
  value: values[name],
64
103
  };
65
104
  });
66
- const disableFormSubmit = isRadioFieldComponent
105
+ const disableFormSubmit = isVerifyUserRoute
67
106
  ? !values.unverifiedAttr
68
- : fieldsWithHandlers.some(({ required, value }) => {
69
- if (!required) {
70
- return false;
71
- }
72
- if (value) {
73
- return false;
74
- }
75
- return true;
76
- });
107
+ : isSelectMfaTypeRoute
108
+ ? !values.mfa_type
109
+ : fieldsWithHandlers.some(({ required, value }) => required && !value);
77
110
  const handleFormSubmit = () => {
78
111
  const submitValue = isRadioFieldComponent
79
112
  ? values
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runFieldValidation = exports.getRouteTypedFields = exports.getTypedFields = exports.getTypedField = exports.getSanitizedTextFields = exports.getSanitizedRadioFields = exports.isRadioFieldOptions = void 0;
3
+ exports.runFieldValidation = exports.getRouteTypedFields = exports.getTypedFields = exports.getTypedField = exports.getSanitizedTextFields = exports.getSanitizedSelectMfaTypeFields = exports.getSanitizedVerifyUserFields = exports.isRadioFieldOptions = void 0;
4
4
  const utils_1 = require("aws-amplify/utils");
5
5
  const ui_1 = require("@aws-amplify/ui");
6
6
  const ui_react_core_1 = require("@aws-amplify/ui-react-core");
@@ -9,11 +9,11 @@ const logger = new utils_1.ConsoleLogger('Authenticator');
9
9
  const { getInvalidEmailText, getRequiredFieldText } = ui_1.authenticatorTextUtil;
10
10
  const isRadioFieldOptions = (field) => field?.type === 'radio';
11
11
  exports.isRadioFieldOptions = isRadioFieldOptions;
12
- const getSanitizedRadioFields = (fields, componentName) => {
12
+ const getSanitizedVerifyUserFields = (fields) => {
13
13
  const values = {};
14
14
  return fields.filter((field) => {
15
15
  if (!(0, exports.isRadioFieldOptions)(field)) {
16
- logger.warn(`${componentName} component does not support text fields. field with type ${field.type} has been ignored.`);
16
+ logger.warn(`VerifyUser component does not support text fields. field with type ${field.type} has been ignored.`);
17
17
  return false;
18
18
  }
19
19
  const { name, value } = field;
@@ -34,7 +34,28 @@ const getSanitizedRadioFields = (fields, componentName) => {
34
34
  return true;
35
35
  });
36
36
  };
37
- exports.getSanitizedRadioFields = getSanitizedRadioFields;
37
+ exports.getSanitizedVerifyUserFields = getSanitizedVerifyUserFields;
38
+ const getSanitizedSelectMfaTypeFields = (fields) => {
39
+ const values = {};
40
+ return fields.filter((field) => {
41
+ const { value } = field;
42
+ if (!(0, exports.isRadioFieldOptions)(field)) {
43
+ logger.warn(`SelectMfaType component does not support non-radio fields; field with type "${field.type}" has been ignored.`);
44
+ return false;
45
+ }
46
+ if (!value) {
47
+ logger.warn('Each field must have a value; field has been ignored.');
48
+ return false;
49
+ }
50
+ if (values[value]) {
51
+ logger.warn(`Each field value must be unique; field with duplicate value of "${value}" has been ignored.`);
52
+ return false;
53
+ }
54
+ values[value] = true;
55
+ return true;
56
+ });
57
+ };
58
+ exports.getSanitizedSelectMfaTypeFields = getSanitizedSelectMfaTypeFields;
38
59
  const getSanitizedTextFields = (fields, componentName) => {
39
60
  const names = {};
40
61
  return fields.filter((field) => {
@@ -103,8 +124,11 @@ function getRouteTypedFields({ fields, route, }) {
103
124
  }
104
125
  // `VerifyUser` does not require additional updates to the shape of `fields`
105
126
  const isVerifyUserRoute = route === 'verifyUser';
127
+ const isSelectMfaTypeRoute = route === 'selectMfaType';
106
128
  const radioFields = fields;
107
- return isVerifyUserRoute ? radioFields : (0, exports.getTypedFields)(fields);
129
+ return isVerifyUserRoute || isSelectMfaTypeRoute
130
+ ? radioFields
131
+ : (0, exports.getTypedFields)(fields);
108
132
  }
109
133
  exports.getRouteTypedFields = getRouteTypedFields;
110
134
  /**
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RADIO_GROUP_CONTAINER_TEST_ID = void 0;
3
4
  const tslib_1 = require("tslib");
4
5
  const react_1 = tslib_1.__importStar(require("react"));
5
6
  const react_native_1 = require("react-native");
@@ -8,6 +9,7 @@ const theme_1 = require("../../theme");
8
9
  const Label_1 = require("../Label");
9
10
  const utils_1 = require("../Label/utils");
10
11
  const styles_1 = require("./styles");
12
+ exports.RADIO_GROUP_CONTAINER_TEST_ID = 'amplify__radio-group__container';
11
13
  function RadioGroup({ accessible = true, accessibilityRole = 'radiogroup', children, direction = 'vertical', disabled, initialValue, label, labelPosition = 'top', labelStyle, onChange, onValueChange, size, style, ...rest }) {
12
14
  const theme = (0, theme_1.useTheme)();
13
15
  const themedStyle = (0, styles_1.getThemedStyles)(theme);
@@ -29,7 +31,7 @@ function RadioGroup({ accessible = true, accessibilityRole = 'radiogroup', child
29
31
  setValue(nextValue);
30
32
  onChange?.(nextValue);
31
33
  }, [onChange]);
32
- return (<react_native_1.View {...rest} style={[themedStyle.container, containerStyle, style]}>
34
+ return (<react_native_1.View {...rest} style={[themedStyle.container, containerStyle, style]} testID={exports.RADIO_GROUP_CONTAINER_TEST_ID}>
33
35
  <react_native_1.View accessible={accessible} accessibilityRole={accessibilityRole} style={childContainerStyle}>
34
36
  {react_1.Children.map(children, (child) => {
35
37
  if ((0, react_1.isValidElement)(child)) {
package/lib/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '2.4.5';
4
+ exports.VERSION = '2.5.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/ui-react-native",
3
- "version": "2.4.5",
3
+ "version": "2.5.1",
4
4
  "main": "lib/index.js",
5
5
  "module": "dist/index.js",
6
6
  "react-native": "src/index.ts",
@@ -30,9 +30,9 @@
30
30
  "react-native-safe-area-context": "^5.2.0"
31
31
  },
32
32
  "dependencies": {
33
- "@aws-amplify/ui": "6.9.1",
34
- "@aws-amplify/ui-react-core": "3.3.5",
35
- "@aws-amplify/ui-react-core-notifications": "2.2.5"
33
+ "@aws-amplify/ui": "6.10.1",
34
+ "@aws-amplify/ui-react-core": "3.4.1",
35
+ "@aws-amplify/ui-react-core-notifications": "2.2.7"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "aws-amplify": "^6.9.0",
@@ -28,6 +28,8 @@ import {
28
28
  SignIn,
29
29
  SignUp,
30
30
  VerifyUser,
31
+ SetupEmail,
32
+ SelectMfaType,
31
33
  } from './Defaults';
32
34
 
33
35
  const DEFAULTS = {
@@ -41,6 +43,8 @@ const DEFAULTS = {
41
43
  SignIn,
42
44
  SignUp,
43
45
  VerifyUser,
46
+ SetupEmail,
47
+ SelectMfaType,
44
48
  };
45
49
 
46
50
  const routePropSelector = ({
@@ -118,5 +122,7 @@ Authenticator.SetupTotp = SetupTotp;
118
122
  Authenticator.SignIn = SignIn;
119
123
  Authenticator.SignUp = SignUp;
120
124
  Authenticator.VerifyUser = VerifyUser;
125
+ Authenticator.SetupEmail = SetupEmail;
126
+ Authenticator.SelectMfaType = SelectMfaType;
121
127
 
122
128
  export default Authenticator;
@@ -0,0 +1,87 @@
1
+ import React, { useMemo } from 'react';
2
+ import { authenticatorTextUtil } from '@aws-amplify/ui';
3
+
4
+ import {
5
+ DefaultContent,
6
+ DefaultFooter,
7
+ DefaultHeader,
8
+ DefaultSelectMfaTypeFormFields,
9
+ } from '../../common';
10
+ import { useFieldValues } from '../../hooks';
11
+
12
+ import { DefaultSelectMfaTypeProps } from '../types';
13
+
14
+ const COMPONENT_NAME = 'SelectMfaType';
15
+
16
+ const {
17
+ getSelectMfaTypeByChallengeName,
18
+ getBackToSignInText,
19
+ getConfirmText,
20
+ getConfirmingText,
21
+ } = authenticatorTextUtil;
22
+
23
+ const SelectMfaType = ({
24
+ challengeName,
25
+ fields,
26
+ handleBlur,
27
+ handleChange,
28
+ handleSubmit,
29
+ isPending,
30
+ toSignIn,
31
+ validationErrors,
32
+ ...rest
33
+ }: DefaultSelectMfaTypeProps): React.JSX.Element => {
34
+ const {
35
+ disableFormSubmit: disabled,
36
+ fields: fieldsWithHandlers,
37
+ fieldValidationErrors,
38
+ handleFormSubmit,
39
+ } = useFieldValues({
40
+ componentName: COMPONENT_NAME,
41
+ fields,
42
+ handleBlur,
43
+ handleChange,
44
+ handleSubmit,
45
+ validationErrors,
46
+ });
47
+
48
+ const headerText = getSelectMfaTypeByChallengeName(challengeName);
49
+ const primaryButtonText = isPending ? getConfirmingText() : getConfirmText();
50
+ const secondaryButtonText = getBackToSignInText();
51
+
52
+ const buttons = useMemo(
53
+ () => ({
54
+ primary: {
55
+ children: primaryButtonText,
56
+ disabled,
57
+ onPress: handleFormSubmit,
58
+ },
59
+ links: [{ children: secondaryButtonText, onPress: toSignIn }],
60
+ }),
61
+ [
62
+ disabled,
63
+ handleFormSubmit,
64
+ primaryButtonText,
65
+ secondaryButtonText,
66
+ toSignIn,
67
+ ]
68
+ );
69
+
70
+ return (
71
+ <DefaultContent
72
+ {...rest}
73
+ buttons={buttons}
74
+ headerText={headerText}
75
+ fields={fieldsWithHandlers}
76
+ isPending={isPending}
77
+ validationErrors={fieldValidationErrors}
78
+ />
79
+ );
80
+ };
81
+
82
+ SelectMfaType.Footer = DefaultFooter;
83
+ SelectMfaType.FormFields = DefaultSelectMfaTypeFormFields;
84
+ SelectMfaType.Header = DefaultHeader;
85
+
86
+ SelectMfaType.displayName = COMPONENT_NAME;
87
+ export default SelectMfaType;
@@ -0,0 +1 @@
1
+ export { default as SelectMfaType } from './SelectMfaType';
@@ -0,0 +1,86 @@
1
+ import React, { useMemo } from 'react';
2
+ import { authenticatorTextUtil } from '@aws-amplify/ui';
3
+
4
+ import {
5
+ DefaultContent,
6
+ DefaultFooter,
7
+ DefaultTextFormFields,
8
+ DefaultHeader,
9
+ } from '../../common';
10
+ import { useFieldValues } from '../../hooks';
11
+
12
+ import { DefaultSetupEmailProps } from '../types';
13
+
14
+ const COMPONENT_NAME = 'SetupEmail';
15
+
16
+ const {
17
+ getBackToSignInText,
18
+ getConfirmText,
19
+ getConfirmingText,
20
+ getSetupEmailText,
21
+ } = authenticatorTextUtil;
22
+
23
+ const SetupEmail = ({
24
+ fields,
25
+ handleBlur,
26
+ handleChange,
27
+ handleSubmit,
28
+ isPending,
29
+ toSignIn,
30
+ validationErrors,
31
+ ...rest
32
+ }: DefaultSetupEmailProps): React.JSX.Element => {
33
+ const {
34
+ disableFormSubmit: disabled,
35
+ fields: fieldsWithHandlers,
36
+ fieldValidationErrors,
37
+ handleFormSubmit,
38
+ } = useFieldValues({
39
+ componentName: COMPONENT_NAME,
40
+ fields,
41
+ handleBlur,
42
+ handleChange,
43
+ handleSubmit,
44
+ validationErrors,
45
+ });
46
+
47
+ const headerText = getSetupEmailText();
48
+ const primaryButtonText = isPending ? getConfirmingText() : getConfirmText();
49
+ const secondaryButtonText = getBackToSignInText();
50
+
51
+ const buttons = useMemo(
52
+ () => ({
53
+ primary: {
54
+ children: primaryButtonText,
55
+ disabled,
56
+ onPress: handleFormSubmit,
57
+ },
58
+ links: [{ children: secondaryButtonText, onPress: toSignIn }],
59
+ }),
60
+ [
61
+ disabled,
62
+ handleFormSubmit,
63
+ primaryButtonText,
64
+ secondaryButtonText,
65
+ toSignIn,
66
+ ]
67
+ );
68
+
69
+ return (
70
+ <DefaultContent
71
+ {...rest}
72
+ buttons={buttons}
73
+ headerText={headerText}
74
+ fields={fieldsWithHandlers}
75
+ isPending={isPending}
76
+ validationErrors={fieldValidationErrors}
77
+ />
78
+ );
79
+ };
80
+
81
+ SetupEmail.Footer = DefaultFooter;
82
+ SetupEmail.FormFields = DefaultTextFormFields;
83
+ SetupEmail.Header = DefaultHeader;
84
+
85
+ SetupEmail.displayName = COMPONENT_NAME;
86
+ export default SetupEmail;
@@ -0,0 +1 @@
1
+ export { default as SetupEmail } from './SetupEmail';
@@ -5,7 +5,7 @@ import {
5
5
  DefaultContent,
6
6
  DefaultFooter,
7
7
  DefaultHeader,
8
- DefaultRadioFormFields,
8
+ DefaultVerifyUserFormFields,
9
9
  } from '../../common';
10
10
  import { useFieldValues } from '../../hooks';
11
11
  import { DefaultVerifyUserProps } from '../types';
@@ -68,7 +68,7 @@ const VerifyUser = ({
68
68
  };
69
69
 
70
70
  VerifyUser.Footer = DefaultFooter;
71
- VerifyUser.FormFields = DefaultRadioFormFields;
71
+ VerifyUser.FormFields = DefaultVerifyUserFormFields;
72
72
  VerifyUser.Header = DefaultHeader;
73
73
 
74
74
  VerifyUser.displayName = COMPONENT_NAME;
@@ -8,6 +8,8 @@ export { SetupTotp } from './SetupTotp';
8
8
  export { SignIn } from './SignIn';
9
9
  export { SignUp } from './SignUp';
10
10
  export { VerifyUser } from './VerifyUser';
11
+ export { SelectMfaType } from './SelectMfaType';
12
+ export { SetupEmail } from './SetupEmail';
11
13
  export {
12
14
  Components,
13
15
  DefaultComponents,
@@ -17,6 +19,8 @@ export {
17
19
  ConfirmVerifyUserProps,
18
20
  ForceNewPasswordProps,
19
21
  ForgotPasswordProps,
22
+ SelectMfaTypeProps,
23
+ SetupEmailProps,
20
24
  SetupTotpProps,
21
25
  SignInProps,
22
26
  SignUpProps,
@@ -15,6 +15,8 @@ export interface SetupTotpStyle {}
15
15
  export interface SignInStyle {}
16
16
  export interface SignUpStyle {}
17
17
  export interface VerifyUserStyle {}
18
+ export interface SetupEmailStyle {}
19
+ export interface SelectMfaTypeStyle {}
18
20
 
19
21
  export type DefaultComponents<
20
22
  FieldType = {},
@@ -85,6 +87,20 @@ export type DefaultVerifyUserProps = React.ComponentPropsWithoutRef<
85
87
  >['VerifyUser']
86
88
  >;
87
89
 
90
+ export type DefaultSetupEmailProps = React.ComponentPropsWithoutRef<
91
+ DefaultComponents<
92
+ TextFieldOptionsType,
93
+ { style?: SetupEmailStyle }
94
+ >['SetupEmail']
95
+ >;
96
+
97
+ export type DefaultSelectMfaTypeProps = React.ComponentPropsWithoutRef<
98
+ DefaultComponents<
99
+ RadioFieldOptions,
100
+ { style?: SelectMfaTypeStyle }
101
+ >['SelectMfaType']
102
+ >;
103
+
88
104
  /**
89
105
  * Custom Authenticator components
90
106
  */
@@ -143,6 +159,16 @@ type VerifyUserComponent<P = {}> = OverrideComponents<
143
159
  { style?: VerifyUserStyle } & P
144
160
  >['VerifyUser'];
145
161
 
162
+ type SetupEmailComponent<P = {}> = OverrideComponents<
163
+ TextFieldOptionsType,
164
+ { style?: SetupEmailStyle } & P
165
+ >['SetupEmail'];
166
+
167
+ type SelectMfaTypeComponent<P = {}> = OverrideComponents<
168
+ RadioFieldOptions,
169
+ { style?: SelectMfaTypeStyle } & P
170
+ >['SelectMfaType'];
171
+
146
172
  /**
147
173
  * Override `Authenticator` components param
148
174
  */
@@ -153,6 +179,8 @@ export interface Components {
153
179
  ConfirmVerifyUser?: ConfirmVerifyUserComponent;
154
180
  ForceNewPassword?: ForceNewPasswordComponent;
155
181
  ForgotPassword?: ForgotPasswordComponent;
182
+ SelectMfaType?: SelectMfaTypeComponent;
183
+ SetupEmail?: SetupEmailComponent;
156
184
  SetupTotp?: SetupTotpComponent;
157
185
  SignIn?: SignInComponent;
158
186
  SignUp?: SignUpComponent;
@@ -166,6 +194,8 @@ export interface ConfirmSignUpProps extends DefaultConfirmSignUpProps {}
166
194
  export interface ConfirmVerifyUserProps extends DefaultConfirmVerifyUserProps {}
167
195
  export interface ForceNewPasswordProps extends DefaultForceNewPasswordProps {}
168
196
  export interface ForgotPasswordProps extends DefaultForgotPasswordProps {}
197
+ export interface SelectMfaTypeProps extends DefaultSelectMfaTypeProps {}
198
+ export interface SetupEmailProps extends DefaultSetupEmailProps {}
169
199
  export interface SetupTotpProps extends DefaultSetupTotpProps {}
170
200
  export interface SignInProps extends DefaultSignInProps {}
171
201
  export interface SignUpProps extends DefaultSignUpProps {}