@aws-amplify/ui-react-native 2.1.2 → 2.1.4

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.
@@ -1,24 +1,19 @@
1
1
  import React from 'react';
2
- import { censorAllButFirstAndLast, censorPhoneNumber } from '@aws-amplify/ui';
2
+ import { censorContactMethod } from '@aws-amplify/ui';
3
3
  import { Radio, RadioGroup } from '../../../primitives';
4
- const censorContactInformation = (name, value) => {
5
- let censoredVal = value;
6
- if (name === 'email') {
7
- const splitEmail = value.split('@');
8
- const censoredName = censorAllButFirstAndLast(splitEmail[0]);
9
- censoredVal = `${censoredName}@${splitEmail[1]}`;
10
- }
11
- else if (name === 'phone_number') {
12
- censoredVal = censorPhoneNumber(value);
13
- }
14
- return censoredVal;
4
+ const attributeMap = {
5
+ email: 'Email',
6
+ phone_number: 'Phone Number',
15
7
  };
16
8
  const DefaultRadioFormFields = ({ fields, fieldContainerStyle, fieldLabelStyle, isPending, style, }) => {
17
9
  return (<RadioGroup disabled={isPending} style={style}>
18
- {(fields ?? []).map(({ name, value, ...props }) => (<Radio {...props} key={value}
19
- // value has to be name, because Auth is only interested in the
20
- // string "email" or "phone_number", not the actual value
21
- value={name} label={censorContactInformation(name, value)} labelStyle={fieldLabelStyle} style={fieldContainerStyle}/>))}
10
+ {(fields ?? []).map(({ name, value, ...props }) => {
11
+ const attributeType = attributeMap[name];
12
+ return (<Radio {...props} key={value}
13
+ // value has to be name, because Auth is only interested in the
14
+ // string "email" or "phone_number", not the actual value
15
+ value={name} label={censorContactMethod(attributeType, value)} labelStyle={fieldLabelStyle} style={fieldContainerStyle}/>);
16
+ })}
22
17
  </RadioGroup>);
23
18
  };
24
19
  DefaultRadioFormFields.displayName = 'FormFields';
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "2.1.2";
1
+ export declare const VERSION = "2.1.4";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = '2.1.2';
1
+ export const VERSION = '2.1.4';
@@ -4,24 +4,19 @@ const tslib_1 = require("tslib");
4
4
  const react_1 = tslib_1.__importDefault(require("react"));
5
5
  const ui_1 = require("@aws-amplify/ui");
6
6
  const primitives_1 = require("../../../primitives");
7
- const censorContactInformation = (name, value) => {
8
- let censoredVal = value;
9
- if (name === 'email') {
10
- const splitEmail = value.split('@');
11
- const censoredName = (0, ui_1.censorAllButFirstAndLast)(splitEmail[0]);
12
- censoredVal = `${censoredName}@${splitEmail[1]}`;
13
- }
14
- else if (name === 'phone_number') {
15
- censoredVal = (0, ui_1.censorPhoneNumber)(value);
16
- }
17
- return censoredVal;
7
+ const attributeMap = {
8
+ email: 'Email',
9
+ phone_number: 'Phone Number',
18
10
  };
19
11
  const DefaultRadioFormFields = ({ fields, fieldContainerStyle, fieldLabelStyle, isPending, style, }) => {
20
12
  return (<primitives_1.RadioGroup disabled={isPending} style={style}>
21
- {(fields ?? []).map(({ name, value, ...props }) => (<primitives_1.Radio {...props} key={value}
22
- // value has to be name, because Auth is only interested in the
23
- // string "email" or "phone_number", not the actual value
24
- value={name} label={censorContactInformation(name, value)} labelStyle={fieldLabelStyle} style={fieldContainerStyle}/>))}
13
+ {(fields ?? []).map(({ name, value, ...props }) => {
14
+ const attributeType = attributeMap[name];
15
+ return (<primitives_1.Radio {...props} key={value}
16
+ // value has to be name, because Auth is only interested in the
17
+ // string "email" or "phone_number", not the actual value
18
+ value={name} label={(0, ui_1.censorContactMethod)(attributeType, value)} labelStyle={fieldLabelStyle} style={fieldContainerStyle}/>);
19
+ })}
25
20
  </primitives_1.RadioGroup>);
26
21
  };
27
22
  DefaultRadioFormFields.displayName = 'FormFields';
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.1.2';
4
+ exports.VERSION = '2.1.4';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/ui-react-native",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
4
4
  "main": "lib/index.js",
5
5
  "module": "dist/index.js",
6
6
  "react-native": "src/index.ts",
@@ -29,9 +29,9 @@
29
29
  "react-native-safe-area-context": "^4.7.3"
30
30
  },
31
31
  "dependencies": {
32
- "@aws-amplify/ui": "6.0.10",
33
- "@aws-amplify/ui-react-core": "3.0.10",
34
- "@aws-amplify/ui-react-core-notifications": "2.0.10"
32
+ "@aws-amplify/ui": "6.0.12",
33
+ "@aws-amplify/ui-react-core": "3.0.12",
34
+ "@aws-amplify/ui-react-core-notifications": "2.0.12"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "aws-amplify": "^6.0.2",
@@ -1,20 +1,17 @@
1
1
  import React from 'react';
2
- import { censorAllButFirstAndLast, censorPhoneNumber } from '@aws-amplify/ui';
2
+ import { censorContactMethod, ContactMethod } from '@aws-amplify/ui';
3
3
 
4
4
  import { Radio, RadioGroup } from '../../../primitives';
5
5
  import { DefaultRadioFormFieldsProps } from './types';
6
6
 
7
- const censorContactInformation = (name: string, value: string): string => {
8
- let censoredVal = value;
9
- if (name === 'email') {
10
- const splitEmail = value.split('@');
11
- const censoredName = censorAllButFirstAndLast(splitEmail[0]);
7
+ interface AttributeMap {
8
+ email: ContactMethod;
9
+ phone_number: ContactMethod;
10
+ }
12
11
 
13
- censoredVal = `${censoredName}@${splitEmail[1]}`;
14
- } else if (name === 'phone_number') {
15
- censoredVal = censorPhoneNumber(value);
16
- }
17
- return censoredVal;
12
+ const attributeMap: AttributeMap = {
13
+ email: 'Email',
14
+ phone_number: 'Phone Number',
18
15
  };
19
16
 
20
17
  const DefaultRadioFormFields = ({
@@ -26,18 +23,22 @@ const DefaultRadioFormFields = ({
26
23
  }: DefaultRadioFormFieldsProps): JSX.Element => {
27
24
  return (
28
25
  <RadioGroup disabled={isPending} style={style}>
29
- {(fields ?? []).map(({ name, value, ...props }) => (
30
- <Radio
31
- {...props}
32
- key={value}
33
- // value has to be name, because Auth is only interested in the
34
- // string "email" or "phone_number", not the actual value
35
- value={name}
36
- label={censorContactInformation(name, value)}
37
- labelStyle={fieldLabelStyle}
38
- style={fieldContainerStyle}
39
- />
40
- ))}
26
+ {(fields ?? []).map(({ name, value, ...props }) => {
27
+ const attributeType = attributeMap[name as keyof AttributeMap];
28
+
29
+ return (
30
+ <Radio
31
+ {...props}
32
+ key={value}
33
+ // value has to be name, because Auth is only interested in the
34
+ // string "email" or "phone_number", not the actual value
35
+ value={name}
36
+ label={censorContactMethod(attributeType, value)}
37
+ labelStyle={fieldLabelStyle}
38
+ style={fieldContainerStyle}
39
+ />
40
+ );
41
+ })}
41
42
  </RadioGroup>
42
43
  );
43
44
  };
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '2.1.2';
1
+ export const VERSION = '2.1.4';