react-native-international-phone-number 0.9.2 → 0.9.3

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
@@ -46,7 +46,8 @@
46
46
  - 🎨 Lib with UI customizable;
47
47
  - 🌎 Phone Input Mask according with the selected country;
48
48
  - 👨‍💻 Functional and class component support;
49
- - 🈶 22 languages supported.
49
+ - 🈶 22 languages supported;
50
+ - ♿ Accessibility.
50
51
 
51
52
  <br>
52
53
 
@@ -96,6 +97,7 @@
96
97
  - [Lib Functions](#functions)
97
98
  - [Supported languages](#🎌-supported-languages-🎌)
98
99
  - [Testing](#testing)
100
+ - [Accessibility](#accessibility)
99
101
  - [Contributing](#contributing)
100
102
  - [License](#license)
101
103
 
@@ -854,8 +856,34 @@ export default function App() {
854
856
  When utilizing this package, you may need to target the PhoneInput component in your automated tests. To facilitate this, we provide a testID props for the PhoneInput component. The testID can be integrated with popular testing libraries such as @testing-library/react-native or Maestro. This enables you to efficiently locate and interact with PhoneInput elements within your tests, ensuring a robust and reliable testing experience.
855
857
 
856
858
  ```jsx
857
- // Assuming PhoneInput has testID="phone-number"
858
- const phoneInput = getByTestId('phone-number-flag');
859
+ // Assuming PhoneInput has testID="countryPicker"
860
+ const phoneInput = getByTestId('countryPickerPhoneInput');
861
+ const flagContainerButton = getByTestId(
862
+ 'countryPickerFlagContainerButton'
863
+ );
864
+ ```
865
+
866
+ Others testID provided inside countries modal:
867
+
868
+ - The wrapping `FlatList` component: 'countryCodesPickerFlatList'
869
+ - The country search `TextInput` component: 'countryCodesPickerSearchInput'
870
+ - The country button (`TouchableOpacity`) component: 'countryCodesPickerCountryButton'
871
+
872
+ <br>
873
+
874
+ ## Accessibility
875
+
876
+ Ensure your app is inclusive and usable by everyone by leveraging built-in React Native accessibility features. The accessibility props are covered by this package. Use the default accessibility props or costumize your own:
877
+
878
+ ```jsx
879
+ <PhoneInput
880
+ accessibilityRoleFlagContainerButton="button"
881
+ accessibilityLabelFlagContainerButton="Countries button"
882
+ accessibilityHintFlagContainerButton="Click to open the countries modal"
883
+ accessibilityRolePhoneInput="input"
884
+ accessibilityLabelPhoneInput="Phone Number input"
885
+ accessibilityHintPhoneInput="Write the phone number"
886
+ />
859
887
  ```
860
888
 
861
889
  <br>
@@ -333,7 +333,7 @@ export const countries = [
333
333
  zh: '阿根廷',
334
334
  tr: 'Arjantin',
335
335
  },
336
- phoneMasks: ['### ### ####'],
336
+ phoneMasks: ['### ### ####', '# ## #### ####', '# ### #### ####'],
337
337
  },
338
338
  {
339
339
  callingCode: '+1',
@@ -3378,7 +3378,7 @@ export const countries = [
3378
3378
  en: 'Jordan',
3379
3379
  ar: 'الأردن',
3380
3380
  es: 'Jordania',
3381
- fr: 'Jordan',
3381
+ fr: 'Jordanie',
3382
3382
  he: 'ירדן',
3383
3383
  it: 'Giordania',
3384
3384
  jp: 'ヨルダン',
@@ -5531,7 +5531,7 @@ export const countries = [
5531
5531
  en: 'Portugal',
5532
5532
  ar: 'البرتغال',
5533
5533
  es: 'Portugal',
5534
- fr: 'Le Portugal',
5534
+ fr: 'Portugal',
5535
5535
  he: 'פורטוגל',
5536
5536
  it: 'Portogallo',
5537
5537
  jp: 'ポルトガ ル',
@@ -6460,7 +6460,7 @@ export const countries = [
6460
6460
  en: 'Togo',
6461
6461
  ar: 'توغو',
6462
6462
  es: 'Togo',
6463
- fr: 'Aller',
6463
+ fr: 'Togo',
6464
6464
  he: 'טוגו',
6465
6465
  it: 'Andare',
6466
6466
  jp: 'トーゴ',
package/lib/index.js CHANGED
@@ -74,6 +74,12 @@ const PhoneInput = forwardRef(
74
74
  rtl,
75
75
  allowZeroAfterCallingCode,
76
76
  testID,
77
+ accessibilityRoleFlagContainerButton,
78
+ accessibilityLabelFlagContainerButton,
79
+ accessibilityHintFlagContainerButton,
80
+ accessibilityRolePhoneInput,
81
+ accessibilityLabelPhoneInput,
82
+ accessibilityHintPhoneInput,
77
83
  ...rest
78
84
  },
79
85
  ref
@@ -130,6 +136,12 @@ const PhoneInput = forwardRef(
130
136
  rtl,
131
137
  allowZeroAfterCallingCode,
132
138
  testID,
139
+ accessibilityRoleFlagContainerButton,
140
+ accessibilityLabelFlagContainerButton,
141
+ accessibilityHintFlagContainerButton,
142
+ accessibilityRolePhoneInput,
143
+ accessibilityLabelPhoneInput,
144
+ accessibilityHintPhoneInput,
133
145
  ...rest,
134
146
  },
135
147
  };
@@ -343,10 +355,7 @@ const PhoneInput = forwardRef(
343
355
  // Create a separate constant for each part of the component
344
356
  const touchableStart = (
345
357
  <>
346
- <Text
347
- testID={`${testID}-flag`}
348
- style={getFlagStyle(phoneInputStyles?.flag)}
349
- >
358
+ <Text style={getFlagStyle(phoneInputStyles?.flag)}>
350
359
  {countryValue?.flag}
351
360
  </Text>
352
361
  {customCaret || (
@@ -389,6 +398,22 @@ const PhoneInput = forwardRef(
389
398
 
390
399
  const touchablePart = (
391
400
  <TouchableOpacity
401
+ testID={
402
+ testID
403
+ ? `${testID}FlagContainerButton`
404
+ : `countryPickerFlagContainerButton`
405
+ }
406
+ accessibillityRole={
407
+ accessibilityRoleFlagContainerButton || 'button'
408
+ }
409
+ accessibilityLabel={
410
+ accessibilityLabelFlagContainerButton ||
411
+ 'Countries button'
412
+ }
413
+ accessibilityHint={
414
+ accessibilityHintFlagContainerButton ||
415
+ 'Click to open the countries modal'
416
+ }
392
417
  activeOpacity={disabled || modalDisabled ? 1 : 0.6}
393
418
  onPress={() =>
394
419
  disabled || modalDisabled ? null : setShow(true)
@@ -431,8 +456,18 @@ const PhoneInput = forwardRef(
431
456
  editable={!disabled}
432
457
  value={inputValue}
433
458
  onChangeText={onChangeText}
434
- keyboardType="numeric"
459
+ keyboardType="number-pad"
435
460
  ref={textInputRef}
461
+ testID={
462
+ testID ? `${testID}PhoneInput` : `countryPickerPhoneInput`
463
+ }
464
+ accessibillityRole={accessibilityRolePhoneInput || 'input'}
465
+ accessibilityLabel={
466
+ accessibilityLabelPhoneInput || 'Phone Number input'
467
+ }
468
+ accessibilityHint={
469
+ accessibilityHintPhoneInput || 'Write the phone number'
470
+ }
436
471
  {...rest}
437
472
  />
438
473
  );
@@ -488,7 +523,6 @@ const PhoneInput = forwardRef(
488
523
  showOnly={showOnly}
489
524
  excludedCountries={excludedCountries}
490
525
  popularCountries={popularCountries}
491
- testID={testID}
492
526
  ListHeaderComponent={({ countries, lang, onPress }) => {
493
527
  return (
494
528
  <View>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-international-phone-number",
3
3
  "author": "AstrOOnauta (https://github.com/AstrOOnauta)",
4
- "version": "0.9.2",
4
+ "version": "0.9.3",
5
5
  "description": "International mobile phone input component with mask for React Native",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",