ordering-ui-react-native 0.22.31 → 0.22.32
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
CHANGED
|
@@ -6,7 +6,7 @@ import { useTheme } from 'styled-components/native';
|
|
|
6
6
|
import { Wrapper } from './styles';
|
|
7
7
|
import { OText, OIcon } from '../shared';
|
|
8
8
|
import { PhoneInputParams } from '../../types';
|
|
9
|
-
import { transformCountryCode } from '../../utils';
|
|
9
|
+
import { transformCountryCode, findExitingCode } from '../../utils';
|
|
10
10
|
|
|
11
11
|
export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
12
12
|
const {
|
|
@@ -97,10 +97,13 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
97
97
|
containerStyle={{ width: '100%' }}
|
|
98
98
|
ref={phoneInput}
|
|
99
99
|
defaultValue={userphoneNumber || defaultValue}
|
|
100
|
-
defaultCode={
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
defaultCode={defaultCode ?
|
|
101
|
+
!isNaN(defaultCode)
|
|
102
|
+
? transformCountryCode(defaultCode)
|
|
103
|
+
: findExitingCode(defaultCode)
|
|
104
|
+
: !isNaN((configs?.default_country_code?.value || '')?.replace(/\+/g, ''))
|
|
105
|
+
? transformCountryCode((configs?.default_country_code?.value || '')?.replace(/\+/g, ''))
|
|
106
|
+
: findExitingCode(configs?.default_country_code?.value?.toUpperCase())
|
|
104
107
|
}
|
|
105
108
|
onChangeFormattedText={(text: string) => handleChangeNumber(text)}
|
|
106
109
|
countryPickerProps={{
|
|
@@ -146,6 +146,11 @@ export const transformCountryCode = (countryCode: number) => {
|
|
|
146
146
|
return code?.countryCode;
|
|
147
147
|
};
|
|
148
148
|
|
|
149
|
+
export const findExitingCode = (countryCode: string) => {
|
|
150
|
+
const code = CODES.find((code: any) => code.countryCode === (countryCode || '').toUpperCase())
|
|
151
|
+
return code?.countryCode
|
|
152
|
+
}
|
|
153
|
+
|
|
149
154
|
/**
|
|
150
155
|
* Function to check if a number is decimal or not
|
|
151
156
|
* @param {*} value number to check if decimal or not
|