@widergy/mobile-ui 1.14.5 → 1.15.0
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/CHANGELOG.md +14 -0
- package/lib/components/UTBaseInputField/components/IconAdornment/index.js +2 -2
- package/lib/components/UTBaseInputField/constants.js +6 -2
- package/lib/components/UTBaseInputField/index.js +26 -22
- package/lib/components/UTPhoneInput/constants.js +303 -0
- package/lib/components/UTPhoneInput/index.js +296 -0
- package/lib/components/UTPhoneInput/styles.js +18 -0
- package/lib/components/UTSelectableCard/index.js +41 -48
- package/lib/components/UTSelectableCard/styles.js +6 -1
- package/lib/components/UTTextArea/index.js +3 -1
- package/lib/components/UTTextInput/versions/V1/components/TextInputField/index.js +6 -3
- package/lib/components/UTTextInput/versions/V1/index.js +4 -2
- package/lib/components/UTTextInput/versions/V1/proptypes.js +2 -1
- package/lib/components/UTWorkflowContainer/versions/V1/components/BottomActions/styles.js +1 -1
- package/lib/constants/inputs.js +4 -0
- package/lib/index.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [1.15.0](https://github.com/widergy/mobile-ui/compare/v1.14.6...v1.15.0) (2024-07-31)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* new phone input component ([#325](https://github.com/widergy/mobile-ui/issues/325)) ([6c6d20d](https://github.com/widergy/mobile-ui/commit/6c6d20d8395e4d30a1917a5309c325c62a89e79c))
|
|
7
|
+
|
|
8
|
+
## [1.14.6](https://github.com/widergy/mobile-ui/compare/v1.14.5...v1.14.6) (2024-07-26)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* utselectablecard image icon and standarization ([#322](https://github.com/widergy/mobile-ui/issues/322)) ([9ad22ac](https://github.com/widergy/mobile-ui/commit/9ad22acdcdd4263e74469cb4a7ce645161b7f6d5))
|
|
14
|
+
|
|
1
15
|
## [1.14.5](https://github.com/widergy/mobile-ui/compare/v1.14.4...v1.14.5) (2024-07-26)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { shape, string, elementType,
|
|
2
|
+
import { bool, shape, string, elementType, oneOfType } from 'prop-types';
|
|
3
3
|
import { TextPropTypes } from 'deprecated-react-native-prop-types';
|
|
4
4
|
|
|
5
5
|
import { isUTIcon } from '../../../UTIcon/utils';
|
|
@@ -21,7 +21,7 @@ const IconAdornment = ({ Icon, error, inputStyle, changeOnError = false }) => {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
IconAdornment.propTypes = {
|
|
24
|
-
error: string,
|
|
24
|
+
error: oneOfType([bool, string]),
|
|
25
25
|
Icon: elementType,
|
|
26
26
|
inputStyle: shape({
|
|
27
27
|
root: TextPropTypes.style
|
|
@@ -6,13 +6,17 @@ import TooltipAdornment from './components/TooltipAdornment';
|
|
|
6
6
|
|
|
7
7
|
export const TYPES = {
|
|
8
8
|
EMAIL: 'email',
|
|
9
|
+
NUMBER: 'number',
|
|
9
10
|
NUMERIC: 'numeric',
|
|
10
|
-
PASSWORD: 'password'
|
|
11
|
+
PASSWORD: 'password',
|
|
12
|
+
PHONE: 'phone'
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
export const KEYBOARD_BY_TYPE = {
|
|
14
16
|
[TYPES.EMAIL]: 'email-address',
|
|
15
|
-
[TYPES.
|
|
17
|
+
[TYPES.NUMBER]: 'number-pad',
|
|
18
|
+
[TYPES.NUMERIC]: 'numeric',
|
|
19
|
+
[TYPES.PHONE]: 'phone-pad'
|
|
16
20
|
};
|
|
17
21
|
|
|
18
22
|
export const COMPONENT_KEYS = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { forwardRef, useCallback, useEffect, useLayoutEffect, useState } from 'react';
|
|
2
|
-
import { bool, func, number, string, arrayOf, shape } from 'prop-types';
|
|
2
|
+
import { bool, func, number, string, arrayOf, shape, oneOfType } from 'prop-types';
|
|
3
3
|
import { View, TextInput } from 'react-native';
|
|
4
4
|
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
5
5
|
|
|
@@ -17,7 +17,7 @@ const UTBaseInputField = forwardRef(
|
|
|
17
17
|
error,
|
|
18
18
|
inputSize,
|
|
19
19
|
leftAdornments,
|
|
20
|
-
|
|
20
|
+
maxLength,
|
|
21
21
|
maxRows,
|
|
22
22
|
onBlur,
|
|
23
23
|
onChange,
|
|
@@ -27,6 +27,7 @@ const UTBaseInputField = forwardRef(
|
|
|
27
27
|
readOnly,
|
|
28
28
|
returnKeyType,
|
|
29
29
|
rightAdornments,
|
|
30
|
+
showCharacterCount,
|
|
30
31
|
style,
|
|
31
32
|
type,
|
|
32
33
|
value
|
|
@@ -54,8 +55,7 @@ const UTBaseInputField = forwardRef(
|
|
|
54
55
|
if (!inputWidth || !text) return text;
|
|
55
56
|
const charWidth = 8;
|
|
56
57
|
const maxCharsPerLine = Math.floor(inputWidth / charWidth);
|
|
57
|
-
|
|
58
|
-
return text.length > maxLength ? `${text.substring(0, maxLength - 3)}...` : text;
|
|
58
|
+
return text.length > maxCharsPerLine ? `${text.substring(0, maxCharsPerLine - 3)}...` : text;
|
|
59
59
|
},
|
|
60
60
|
[inputWidth]
|
|
61
61
|
);
|
|
@@ -97,19 +97,22 @@ const UTBaseInputField = forwardRef(
|
|
|
97
97
|
const autoCapitalize = type === TYPES.EMAIL ? 'none' : 'sentences';
|
|
98
98
|
const keyboardType = KEYBOARD_BY_TYPE[type] || 'default';
|
|
99
99
|
|
|
100
|
-
const renderElement = useCallback(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
100
|
+
const renderElement = useCallback(
|
|
101
|
+
element => {
|
|
102
|
+
const Component = COMPONENTS_MAPPER[element.name];
|
|
103
|
+
return Component ? (
|
|
104
|
+
<Component
|
|
105
|
+
actionStyle={actionStyle}
|
|
106
|
+
disabled={disabled}
|
|
107
|
+
error={error}
|
|
108
|
+
inputStyle={inputStyle}
|
|
109
|
+
key={element.name}
|
|
110
|
+
{...element.props}
|
|
111
|
+
/>
|
|
112
|
+
) : null;
|
|
113
|
+
},
|
|
114
|
+
[error]
|
|
115
|
+
);
|
|
113
116
|
|
|
114
117
|
return (
|
|
115
118
|
<View style={containerStyle}>
|
|
@@ -120,7 +123,7 @@ const UTBaseInputField = forwardRef(
|
|
|
120
123
|
autoCorrect={false}
|
|
121
124
|
editable={!disabled && !readOnly}
|
|
122
125
|
keyboardType={keyboardType}
|
|
123
|
-
maxLength={
|
|
126
|
+
maxLength={maxLength}
|
|
124
127
|
multiline={multiline}
|
|
125
128
|
numberOfLines={maxRows}
|
|
126
129
|
onChangeText={onChange}
|
|
@@ -139,10 +142,10 @@ const UTBaseInputField = forwardRef(
|
|
|
139
142
|
/>
|
|
140
143
|
{rightAdornments.map(renderElement)}
|
|
141
144
|
</View>
|
|
142
|
-
{
|
|
145
|
+
{maxLength && showCharacterCount && (
|
|
143
146
|
<View style={textLengthRowStyle}>
|
|
144
147
|
<UTLabel colorTheme="gray" variant="small">
|
|
145
|
-
{value?.length || 0}/{
|
|
148
|
+
{value?.length || 0}/{maxLength}
|
|
146
149
|
</UTLabel>
|
|
147
150
|
</View>
|
|
148
151
|
)}
|
|
@@ -156,7 +159,7 @@ UTBaseInputField.displayName = 'UTBaseInputField';
|
|
|
156
159
|
UTBaseInputField.propTypes = {
|
|
157
160
|
alwaysShowPlaceholder: bool,
|
|
158
161
|
disabled: bool,
|
|
159
|
-
error: string,
|
|
162
|
+
error: oneOfType([bool, string]),
|
|
160
163
|
inputSize: string,
|
|
161
164
|
leftAdornments: arrayOf(
|
|
162
165
|
shape({
|
|
@@ -164,7 +167,7 @@ UTBaseInputField.propTypes = {
|
|
|
164
167
|
props: shape({})
|
|
165
168
|
})
|
|
166
169
|
),
|
|
167
|
-
|
|
170
|
+
maxLength: number,
|
|
168
171
|
maxRows: number,
|
|
169
172
|
onBlur: func,
|
|
170
173
|
onChange: func,
|
|
@@ -179,6 +182,7 @@ UTBaseInputField.propTypes = {
|
|
|
179
182
|
props: shape({})
|
|
180
183
|
})
|
|
181
184
|
),
|
|
185
|
+
showCharacterCount: bool,
|
|
182
186
|
style: shape({
|
|
183
187
|
container: ViewPropTypes.style,
|
|
184
188
|
input: ViewPropTypes.style,
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
export const AREA_CODES = [
|
|
2
|
+
{ code: '11', city: 'AMBA' },
|
|
3
|
+
{ code: '220', city: 'MERLO' },
|
|
4
|
+
{ code: '221', city: 'LA PLATA' },
|
|
5
|
+
{ code: '223', city: 'MAR DEL PLATA' },
|
|
6
|
+
{ code: '230', city: 'PILAR ' },
|
|
7
|
+
{ code: '236', city: 'JUNÍN' },
|
|
8
|
+
{ code: '237', city: 'MORENO' },
|
|
9
|
+
{ code: '249', city: 'TANDIL' },
|
|
10
|
+
{ code: '260', city: 'SAN RAFAEL' },
|
|
11
|
+
{ code: '261', city: 'MENDOZA' },
|
|
12
|
+
{ code: '263', city: 'SAN MARTÍN' },
|
|
13
|
+
{ code: '264', city: 'SAN JUAN' },
|
|
14
|
+
{ code: '266', city: 'SAN LUIS' },
|
|
15
|
+
{ code: '280', city: 'TRELEW' },
|
|
16
|
+
{ code: '291', city: 'BAHÍA BLANCA' },
|
|
17
|
+
{ code: '294', city: 'SAN CARLOS DE BARILOCHE' },
|
|
18
|
+
{ code: '297', city: 'COMODORO RIVADAVIA' },
|
|
19
|
+
{ code: '298', city: 'GENERAL ROCA' },
|
|
20
|
+
{ code: '299', city: 'NEUQUÉN' },
|
|
21
|
+
{ code: '336', city: 'SAN NICOLÁS DE LOS ARROYOS ' },
|
|
22
|
+
{ code: '341', city: 'ROSARIO ' },
|
|
23
|
+
{ code: '342', city: 'SANTA FE' },
|
|
24
|
+
{ code: '343', city: 'PARANÁ' },
|
|
25
|
+
{ code: '345', city: 'CONCORDIA' },
|
|
26
|
+
{ code: '348', city: 'BELÉN DE ESCOBAR ' },
|
|
27
|
+
{ code: '351', city: 'CÓRDOBA' },
|
|
28
|
+
{ code: '353', city: 'VILLA MARÍA' },
|
|
29
|
+
{ code: '358', city: 'RÍO CUARTO' },
|
|
30
|
+
{ code: '362', city: 'RESISTENCIA' },
|
|
31
|
+
{ code: '364', city: 'PRESIDENCIA ROQUE SÁENZ PEÑA' },
|
|
32
|
+
{ code: '370', city: 'FORMOSA' },
|
|
33
|
+
{ code: '376', city: 'POSADAS' },
|
|
34
|
+
{ code: '379', city: 'CORRIENTES' },
|
|
35
|
+
{ code: '380', city: 'LA RIOJA' },
|
|
36
|
+
{ code: '381', city: 'SAN MIGUEL DE TUCUMÁN' },
|
|
37
|
+
{ code: '383', city: 'SAN FERNANDO DEL VALLE DE CATAMARCA' },
|
|
38
|
+
{ code: '385', city: 'SANTIAGO DEL ESTERO' },
|
|
39
|
+
{ code: '387', city: 'SALTA' },
|
|
40
|
+
{ code: '388', city: 'SAN SALVADOR DE JUJUY' },
|
|
41
|
+
{ code: '2202', city: 'GONZÁLEZ CATÁN' },
|
|
42
|
+
{ code: '2221', city: 'MAGDALENA ' },
|
|
43
|
+
{ code: '2223', city: 'BRANDSEN ' },
|
|
44
|
+
{ code: '2224', city: 'GLEW ' },
|
|
45
|
+
{ code: '2225', city: 'ALEJANDRO KORN' },
|
|
46
|
+
{ code: '2226', city: 'CAÑUELAS' },
|
|
47
|
+
{ code: '2227', city: 'LOBOS ' },
|
|
48
|
+
{ code: '2229', city: 'JUAN MARÍA GUTIÉRREZ ' },
|
|
49
|
+
{ code: '2241', city: 'CHASCOMÚS' },
|
|
50
|
+
{ code: '2242', city: 'LEZAMA' },
|
|
51
|
+
{ code: '2243', city: 'GENERAL BELGRANO' },
|
|
52
|
+
{ code: '2244', city: 'LAS FLORES' },
|
|
53
|
+
{ code: '2245', city: 'DOLORES' },
|
|
54
|
+
{ code: '2246', city: 'SANTA TERESITA' },
|
|
55
|
+
{ code: '2252', city: 'SAN CLEMENTE DEL TUYÚ' },
|
|
56
|
+
{ code: '2254', city: 'PINAMAR' },
|
|
57
|
+
{ code: '2255', city: 'VILLA GESELL' },
|
|
58
|
+
{ code: '2257', city: 'MAR DE AJÓ' },
|
|
59
|
+
{ code: '2261', city: 'LOBERÍA' },
|
|
60
|
+
{ code: '2262', city: 'NECOCHEA' },
|
|
61
|
+
{ code: '2264', city: 'NICANOR OLIVERA (EST. LA DULCE)' },
|
|
62
|
+
{ code: '2265', city: 'CORONEL VIDAL' },
|
|
63
|
+
{ code: '2266', city: 'BALCARCE' },
|
|
64
|
+
{ code: '2267', city: 'GENERAL JUAN MADARIAGA' },
|
|
65
|
+
{ code: '2268', city: 'MAIPÚ' },
|
|
66
|
+
{ code: '2271', city: 'SAN MIGUEL DEL MONTE' },
|
|
67
|
+
{ code: '2272', city: 'NAVARRO' },
|
|
68
|
+
{ code: '2273', city: 'CARMEN DE ARECO' },
|
|
69
|
+
{ code: '2274', city: 'CARLOS SPEGAZZINI' },
|
|
70
|
+
{ code: '2281', city: 'AZUL' },
|
|
71
|
+
{ code: '2283', city: 'TAPALQUÉ' },
|
|
72
|
+
{ code: '2284', city: 'OLAVARRÍA' },
|
|
73
|
+
{ code: '2285', city: 'LAPRIDA' },
|
|
74
|
+
{ code: '2286', city: 'GENERAL LA MADRID' },
|
|
75
|
+
{ code: '2291', city: 'MIRAMAR' },
|
|
76
|
+
{ code: '2292', city: 'BENITO JUÁREZ' },
|
|
77
|
+
{ code: '2296', city: 'AYACUCHO' },
|
|
78
|
+
{ code: '2297', city: 'RAUCH' },
|
|
79
|
+
{ code: '2302', city: 'GENERAL PICO' },
|
|
80
|
+
{ code: '2314', city: 'SAN CARLOS DE BOLÍVAR' },
|
|
81
|
+
{ code: '2316', city: 'DAIREAUX' },
|
|
82
|
+
{ code: '2317', city: 'NUEVE DE JULIO' },
|
|
83
|
+
{ code: '2320', city: 'JOSÉ C. PAZ' },
|
|
84
|
+
{ code: '2323', city: 'LUJÁN' },
|
|
85
|
+
{ code: '2324', city: 'MERCEDES' },
|
|
86
|
+
{ code: '2325', city: 'SAN ANDRÉS DE GILES' },
|
|
87
|
+
{ code: '2326', city: 'SAN ANTONIO DE ARECO' },
|
|
88
|
+
{ code: '2331', city: 'REALICÓ' },
|
|
89
|
+
{ code: '2333', city: 'QUEMÚ QUEMÚ' },
|
|
90
|
+
{ code: '2334', city: 'EDUARDO CASTEX' },
|
|
91
|
+
{ code: '2335', city: 'CALEUFÚ' },
|
|
92
|
+
{ code: '2336', city: 'HUINCA RENANCÓ' },
|
|
93
|
+
{ code: '2337', city: 'AMÉRICA' },
|
|
94
|
+
{ code: '2338', city: 'VICTORICA' },
|
|
95
|
+
{ code: '2342', city: 'BRAGADO' },
|
|
96
|
+
{ code: '2343', city: 'NORBERTO DE LA RIESTRA' },
|
|
97
|
+
{ code: '2344', city: 'SALADILLO' },
|
|
98
|
+
{ code: '2345', city: '25 DE MAYO' },
|
|
99
|
+
{ code: '2346', city: 'CHIVILCOY' },
|
|
100
|
+
{ code: '2352', city: 'CHACABUCO' },
|
|
101
|
+
{ code: '2353', city: 'GENERAL ARENALES' },
|
|
102
|
+
{ code: '2354', city: 'VEDIA' },
|
|
103
|
+
{ code: '2355', city: 'LINCOLN' },
|
|
104
|
+
{ code: '2356', city: 'GENERAL PINTO' },
|
|
105
|
+
{ code: '2357', city: 'CARLOS TEJEDOR' },
|
|
106
|
+
{ code: '2358', city: 'LOS TOLDOS' },
|
|
107
|
+
{ code: '2392', city: 'TRENQUE LAUQUEN' },
|
|
108
|
+
{ code: '2393', city: 'SALAZAR' },
|
|
109
|
+
{ code: '2394', city: 'TRES LOMAS' },
|
|
110
|
+
{ code: '2395', city: 'CARLOS CASARES' },
|
|
111
|
+
{ code: '2396', city: 'PEHUAJÓ' },
|
|
112
|
+
{ code: '2473', city: 'COLÓN' },
|
|
113
|
+
{ code: '2474', city: 'SALTO' },
|
|
114
|
+
{ code: '2475', city: 'ROJAS' },
|
|
115
|
+
{ code: '2477', city: 'PERGAMINO' },
|
|
116
|
+
{ code: '2478', city: 'ARRECIFES' },
|
|
117
|
+
{ code: '2622', city: 'TUNUYÁN' },
|
|
118
|
+
{ code: '2624', city: 'USPALLATA' },
|
|
119
|
+
{ code: '2625', city: 'GENERAL ALVEAR' },
|
|
120
|
+
{ code: '2626', city: 'LA PAZ' },
|
|
121
|
+
{ code: '2646', city: 'VILLA SAN AGUSTÍN' },
|
|
122
|
+
{ code: '2647', city: 'SAN JOSÉ DE JÁCHAL' },
|
|
123
|
+
{ code: '2648', city: 'CALINGASTA' },
|
|
124
|
+
{ code: '2651', city: 'SAN FRANCISCO DEL MONTE DE ORO' },
|
|
125
|
+
{ code: '2652', city: 'SAN LUIS' },
|
|
126
|
+
{ code: '2655', city: 'LA TOMA' },
|
|
127
|
+
{ code: '2656', city: 'TILISARAO' },
|
|
128
|
+
{ code: '2657', city: 'VILLA MERCEDES' },
|
|
129
|
+
{ code: '2658', city: 'BUENA ESPERANZA' },
|
|
130
|
+
{ code: '2901', city: 'USHUAIA' },
|
|
131
|
+
{ code: '2902', city: 'RÍO TURBIO' },
|
|
132
|
+
{ code: '2903', city: 'RÍO MAYO' },
|
|
133
|
+
{ code: '2920', city: 'VIEDMA' },
|
|
134
|
+
{ code: '2921', city: 'CORONEL DORREGO' },
|
|
135
|
+
{ code: '2922', city: 'CORONEL PRINGLES' },
|
|
136
|
+
{ code: '2923', city: 'PIGÜÉ' },
|
|
137
|
+
{ code: '2924', city: 'DARREGUEIRA' },
|
|
138
|
+
{ code: '2925', city: 'VILLA IRIS' },
|
|
139
|
+
{ code: '2926', city: 'CORONEL SUÁREZ' },
|
|
140
|
+
{ code: '2927', city: 'MÉDANOS' },
|
|
141
|
+
{ code: '2928', city: 'PEDRO LURO ' },
|
|
142
|
+
{ code: '2929', city: 'GUAMINÍ' },
|
|
143
|
+
{ code: '2931', city: 'RÍO COLORADO' },
|
|
144
|
+
{ code: '2932', city: 'PUNTA ALTA' },
|
|
145
|
+
{ code: '2933', city: 'HUANGUELÉN' },
|
|
146
|
+
{ code: '2934', city: 'SAN ANTONIO OESTE' },
|
|
147
|
+
{ code: '2935', city: 'RIVERA' },
|
|
148
|
+
{ code: '2936', city: 'CARHUÉ ' },
|
|
149
|
+
{ code: '2940', city: 'INGENIERO JACOBACCI' },
|
|
150
|
+
{ code: '2942', city: 'ZAPALA' },
|
|
151
|
+
{ code: '2945', city: 'ESQUEL' },
|
|
152
|
+
{ code: '2946', city: 'CHOELE CHOEL' },
|
|
153
|
+
{ code: '2948', city: 'CHOS MALAL' },
|
|
154
|
+
{ code: '2952', city: 'GENERAL ACHA' },
|
|
155
|
+
{ code: '2953', city: 'MACACHÍN' },
|
|
156
|
+
{ code: '2954', city: 'SANTA ROSA' },
|
|
157
|
+
{ code: '2962', city: 'PUERTO SAN JULIÁN' },
|
|
158
|
+
{ code: '2963', city: 'PERITO MORENO' },
|
|
159
|
+
{ code: '2964', city: 'RÍO GRANDE' },
|
|
160
|
+
{ code: '2966', city: 'RÍO GALLEGOS' },
|
|
161
|
+
{ code: '2972', city: 'SAN MARTÍN DE LOS ANDES' },
|
|
162
|
+
{ code: '2982', city: 'ORENSE' },
|
|
163
|
+
{ code: '2983', city: 'TRES ARROYOS' },
|
|
164
|
+
{ code: '3327', city: 'BENAVÍDEZ' },
|
|
165
|
+
{ code: '3329', city: 'SAN PEDRO' },
|
|
166
|
+
{ code: '3382', city: 'RUFINO' },
|
|
167
|
+
{ code: '3385', city: 'LABOULAYE' },
|
|
168
|
+
{ code: '3387', city: 'BUCHARDO' },
|
|
169
|
+
{ code: '3388', city: 'GENERAL VILLEGAS' },
|
|
170
|
+
{ code: '3400', city: 'VILLA CONSTITUCIÓN' },
|
|
171
|
+
{ code: '3401', city: 'EL TRÉBOL' },
|
|
172
|
+
{ code: '3402', city: 'ARROYO SECO' },
|
|
173
|
+
{ code: '3404', city: 'SAN CARLOS CENTRO' },
|
|
174
|
+
{ code: '3405', city: 'SAN JAVIER' },
|
|
175
|
+
{ code: '3406', city: 'SAN JORGE' },
|
|
176
|
+
{ code: '3407', city: 'RAMALLO' },
|
|
177
|
+
{ code: '3408', city: 'SAN CRISTÓBAL' },
|
|
178
|
+
{ code: '3409', city: 'MOISÉS VILLE' },
|
|
179
|
+
{ code: '3435', city: 'NOGOYÁ' },
|
|
180
|
+
{ code: '3436', city: 'VICTORIA' },
|
|
181
|
+
{ code: '3437', city: 'LA PAZ' },
|
|
182
|
+
{ code: '3438', city: 'BOVRIL' },
|
|
183
|
+
{ code: '3442', city: 'CONCEPCIÓN DEL URUGUAY' },
|
|
184
|
+
{ code: '3444', city: 'GUALEGUAY' },
|
|
185
|
+
{ code: '3445', city: 'ROSARIO DEL TALA' },
|
|
186
|
+
{ code: '3446', city: 'GUALEGUAYCHÚ' },
|
|
187
|
+
{ code: '3447', city: 'COLÓN' },
|
|
188
|
+
{ code: '3454', city: 'FEDERAL' },
|
|
189
|
+
{ code: '3455', city: 'VILLAGUAY' },
|
|
190
|
+
{ code: '3456', city: 'CHAJARÍ' },
|
|
191
|
+
{ code: '3458', city: 'SAN JOSÉ DE FELICIANO' },
|
|
192
|
+
{ code: '3460', city: 'SANTA TERESA ' },
|
|
193
|
+
{ code: '3462', city: 'VENADO TUERTO' },
|
|
194
|
+
{ code: '3463', city: 'CANALS' },
|
|
195
|
+
{ code: '3464', city: 'CASILDA' },
|
|
196
|
+
{ code: '3465', city: 'FIRMAT' },
|
|
197
|
+
{ code: '3466', city: 'BARRANCAS' },
|
|
198
|
+
{ code: '3467', city: 'CRUZ ALTA' },
|
|
199
|
+
{ code: '3468', city: 'CORRAL DE BUSTOS' },
|
|
200
|
+
{ code: '3469', city: 'ACEBAL' },
|
|
201
|
+
{ code: '3471', city: 'CAÑADA DE GÓMEZ' },
|
|
202
|
+
{ code: '3472', city: 'MARCOS JUÁREZ' },
|
|
203
|
+
{ code: '3476', city: 'SAN LORENZO' },
|
|
204
|
+
{ code: '3482', city: 'RECONQUISTA' },
|
|
205
|
+
{ code: '3483', city: 'VERA' },
|
|
206
|
+
{ code: '3487', city: 'ZÁRATE' },
|
|
207
|
+
{ code: '3489', city: 'CAMPANA' },
|
|
208
|
+
{ code: '3491', city: 'CERES' },
|
|
209
|
+
{ code: '3492', city: 'RAFAELA' },
|
|
210
|
+
{ code: '3493', city: 'SUNCHALES' },
|
|
211
|
+
{ code: '3496', city: 'ESPERANZA' },
|
|
212
|
+
{ code: '3497', city: 'LLAMBI CAMPBELL' },
|
|
213
|
+
{ code: '3498', city: 'SAN JUSTO' },
|
|
214
|
+
{ code: '3521', city: 'DEÁN FUNES ' },
|
|
215
|
+
{ code: '3522', city: 'VILLA DE MARÍA' },
|
|
216
|
+
{ code: '3524', city: 'VILLA DEL TOTORAL' },
|
|
217
|
+
{ code: '3525', city: 'JESÚS MARÍA' },
|
|
218
|
+
{ code: '3532', city: 'OLIVA' },
|
|
219
|
+
{ code: '3533', city: 'LAS VARILLAS' },
|
|
220
|
+
{ code: '3537', city: 'BELL VILLE' },
|
|
221
|
+
{ code: '3541', city: 'VILLA CARLOS PAZ' },
|
|
222
|
+
{ code: '3542', city: 'SALSACATE' },
|
|
223
|
+
{ code: '3543', city: 'CÓRDOBA (ARGÜELLO)' },
|
|
224
|
+
{ code: '3544', city: 'VILLA DOLORES' },
|
|
225
|
+
{ code: '3546', city: 'SANTA ROSA DE CALAMUCHITA' },
|
|
226
|
+
{ code: '3547', city: 'ALTA GRACIA' },
|
|
227
|
+
{ code: '3548', city: 'LA FALDA' },
|
|
228
|
+
{ code: '3549', city: 'CRUZ DEL EJE' },
|
|
229
|
+
{ code: '3562', city: 'MORTEROS' },
|
|
230
|
+
{ code: '3563', city: 'BALNEARIA' },
|
|
231
|
+
{ code: '3564', city: 'SAN FRANCISCO' },
|
|
232
|
+
{ code: '3571', city: 'RÍO TERCERO' },
|
|
233
|
+
{ code: '3572', city: 'RÍO SEGUNDO' },
|
|
234
|
+
{ code: '3573', city: 'VILLA DEL ROSARIO' },
|
|
235
|
+
{ code: '3574', city: 'RÍO PRIMERO' },
|
|
236
|
+
{ code: '3575', city: 'LA PUERTA' },
|
|
237
|
+
{ code: '3576', city: 'ARROYITO' },
|
|
238
|
+
{ code: '3582', city: 'SAMPACHO' },
|
|
239
|
+
{ code: '3583', city: 'VICUÑA MACKENNA' },
|
|
240
|
+
{ code: '3584', city: 'LA CARLOTA' },
|
|
241
|
+
{ code: '3585', city: 'ADELIA MARÍA' },
|
|
242
|
+
{ code: '3711', city: 'INGENIERO JUÁREZ' },
|
|
243
|
+
{ code: '3715', city: 'LAS LOMITAS' },
|
|
244
|
+
{ code: '3716', city: 'COMANDANTE FONTANA' },
|
|
245
|
+
{ code: '3718', city: 'CLORINDA' },
|
|
246
|
+
{ code: '3721', city: 'CHARADAI' },
|
|
247
|
+
{ code: '3725', city: 'GENERAL JOSÉ DE SAN MARTÍN' },
|
|
248
|
+
{ code: '3731', city: 'CHARATA ' },
|
|
249
|
+
{ code: '3734', city: 'PRESIDENCIA DE LA PLAZA' },
|
|
250
|
+
{ code: '3735', city: 'VILLA ÁNGELA' },
|
|
251
|
+
{ code: '3741', city: 'BERNARDO DE IRIGOYEN' },
|
|
252
|
+
{ code: '3743', city: 'PUERTO RICO' },
|
|
253
|
+
{ code: '3751', city: 'ELDORADO' },
|
|
254
|
+
{ code: '3754', city: 'LEANDRO N. ALEM' },
|
|
255
|
+
{ code: '3755', city: 'OBERÁ' },
|
|
256
|
+
{ code: '3756', city: 'SANTO TOMÉ' },
|
|
257
|
+
{ code: '3757', city: 'PUERTO IGUAZÚ' },
|
|
258
|
+
{ code: '3758', city: 'APÓSTOLES' },
|
|
259
|
+
{ code: '3772', city: 'PASO DE LOS LIBRES' },
|
|
260
|
+
{ code: '3773', city: 'MERCEDES' },
|
|
261
|
+
{ code: '3774', city: 'CURUZÚ CUATIÁ' },
|
|
262
|
+
{ code: '3775', city: 'MONTE CASEROS' },
|
|
263
|
+
{ code: '3777', city: 'GOYA' },
|
|
264
|
+
{ code: '3781', city: 'CAÁ CATÍ' },
|
|
265
|
+
{ code: '3782', city: 'SALADAS' },
|
|
266
|
+
{ code: '3786', city: 'ITUZAINGÓ' },
|
|
267
|
+
{ code: '3821', city: 'CHEPES' },
|
|
268
|
+
{ code: '3825', city: 'CHILECITO' },
|
|
269
|
+
{ code: '3826', city: 'CHAMICAL' },
|
|
270
|
+
{ code: '3827', city: 'AIMOGASTA' },
|
|
271
|
+
{ code: '3832', city: 'RECREO' },
|
|
272
|
+
{ code: '3835', city: 'ANDALGALÁ' },
|
|
273
|
+
{ code: '3837', city: 'TINOGASTA ' },
|
|
274
|
+
{ code: '3838', city: 'SANTA MARÍA' },
|
|
275
|
+
{ code: '3841', city: 'MONTE QUEMADO' },
|
|
276
|
+
{ code: '3843', city: 'QUIMILÍ' },
|
|
277
|
+
{ code: '3844', city: 'AÑATUYA' },
|
|
278
|
+
{ code: '3845', city: 'LORETO' },
|
|
279
|
+
{ code: '3846', city: 'TINTINA' },
|
|
280
|
+
{ code: '3854', city: 'FRÍAS' },
|
|
281
|
+
{ code: '3855', city: 'SUNCHO CORRAL' },
|
|
282
|
+
{ code: '3856', city: 'VILLA OJO DE AGUA' },
|
|
283
|
+
{ code: '3857', city: 'BANDERA' },
|
|
284
|
+
{ code: '3858', city: 'TERMAS DE RÍO HONDO' },
|
|
285
|
+
{ code: '3861', city: 'NUEVA ESPERANZA' },
|
|
286
|
+
{ code: '3862', city: 'TRANCAS' },
|
|
287
|
+
{ code: '3863', city: 'MONTEROS' },
|
|
288
|
+
{ code: '3865', city: 'CONCEPCIÓN' },
|
|
289
|
+
{ code: '3867', city: 'TAFÍ DEL VALLE' },
|
|
290
|
+
{ code: '3868', city: 'CAFAYATE' },
|
|
291
|
+
{ code: '3869', city: 'RANCHILLOS Y SAN MIGUEL ' },
|
|
292
|
+
{ code: '3873', city: 'TARTAGAL' },
|
|
293
|
+
{ code: '3876', city: 'SAN JOSÉ DE METÁN' },
|
|
294
|
+
{ code: '3877', city: 'JOAQUÍN VÍCTOR GONZÁLEZ' },
|
|
295
|
+
{ code: '3878', city: 'ORÁN' },
|
|
296
|
+
{ code: '3885', city: 'LA QUIACA' },
|
|
297
|
+
{ code: '3886', city: 'LIBERTADOR GENERAL SAN MARTÍN' },
|
|
298
|
+
{ code: '3887', city: 'HUMAHUACA' },
|
|
299
|
+
{ code: '3888', city: 'SAN PEDRO DE JUJUY' },
|
|
300
|
+
{ code: '3891', city: 'GRANEROS' },
|
|
301
|
+
{ code: '3892', city: 'AMAICHA DEL VALLE' },
|
|
302
|
+
{ code: '3894', city: 'BURRUYACÚ' }
|
|
303
|
+
];
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { bool, elementType, func, number, shape, string } from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import UTBaseInputField from '../UTBaseInputField';
|
|
6
|
+
import UTFieldLabel from '../UTFieldLabel';
|
|
7
|
+
import UTLabel from '../UTLabel';
|
|
8
|
+
import UTValidation from '../UTValidation';
|
|
9
|
+
import { formatErrorToValidation } from '../UTValidation/utils';
|
|
10
|
+
import { LABEL_VARIANTS } from '../../constants/inputs';
|
|
11
|
+
import { COMPONENT_KEYS } from '../UTBaseInputField/constants';
|
|
12
|
+
import { validationDataProptypes } from '../UTValidation/constants';
|
|
13
|
+
|
|
14
|
+
import { AREA_CODES } from './constants';
|
|
15
|
+
import styles from './styles';
|
|
16
|
+
|
|
17
|
+
class UTPhoneInput extends PureComponent {
|
|
18
|
+
constructor(props) {
|
|
19
|
+
super(props);
|
|
20
|
+
this.state = {
|
|
21
|
+
areaCode: '',
|
|
22
|
+
bigFocus: false,
|
|
23
|
+
areaCodeError: '',
|
|
24
|
+
firstFocus: false,
|
|
25
|
+
isValidCode: false,
|
|
26
|
+
phoneNumber: '',
|
|
27
|
+
phoneRef: null,
|
|
28
|
+
secondFocus: false
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
this.handleFirstBlur = this.handleBlur('firstFocus');
|
|
32
|
+
this.handleSecondBlur = this.handleBlur('secondFocus');
|
|
33
|
+
this.handleFirstFocus = this.handleFocus('firstFocus');
|
|
34
|
+
this.handleSecondFocus = this.handleFocus('secondFocus');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
componentDidMount() {
|
|
38
|
+
this.updateValue();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
componentDidUpdate(prevProps) {
|
|
42
|
+
const { value } = this.props;
|
|
43
|
+
if (prevProps.value !== value) this.updateValue();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
changeText = updateFunction => {
|
|
47
|
+
const { areaCode, phoneNumber } = this.state;
|
|
48
|
+
const { withAreaCode } = this.props;
|
|
49
|
+
|
|
50
|
+
if (withAreaCode && (areaCode || phoneNumber)) {
|
|
51
|
+
updateFunction(`${areaCode}-${phoneNumber}`);
|
|
52
|
+
} else if (!withAreaCode) {
|
|
53
|
+
updateFunction(phoneNumber);
|
|
54
|
+
} else {
|
|
55
|
+
updateFunction('');
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
getAreaCodeState = value => {
|
|
60
|
+
const {
|
|
61
|
+
translations: { areaCodeWithoutZeroError, invalidAreaCodeError }
|
|
62
|
+
} = this.props;
|
|
63
|
+
let newState = {};
|
|
64
|
+
if (value && value.slice(0, 1) === '0') {
|
|
65
|
+
newState = { areaCodeError: areaCodeWithoutZeroError };
|
|
66
|
+
} else {
|
|
67
|
+
const code = AREA_CODES.find(element => element.code === value);
|
|
68
|
+
newState = {
|
|
69
|
+
areaCodeError: value?.length && !code && invalidAreaCodeError,
|
|
70
|
+
isValidCode: !!code,
|
|
71
|
+
phoneNumber: ''
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return { ...newState, areaCode: value };
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
handleBlur = keyname => async () => {
|
|
79
|
+
this.setState({
|
|
80
|
+
[keyname]: false
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
await new Promise(resolve => setTimeout(resolve, 150));
|
|
84
|
+
|
|
85
|
+
const { secondFocus, firstFocus, bigFocus } = this.state;
|
|
86
|
+
const { onBlur } = this.props;
|
|
87
|
+
|
|
88
|
+
if (!secondFocus && !firstFocus && bigFocus) {
|
|
89
|
+
this.changeText(onBlur);
|
|
90
|
+
this.setState({
|
|
91
|
+
bigFocus: false
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
handleChangeAreaCode = value => {
|
|
97
|
+
this.setState(this.getAreaCodeState(value), () => {
|
|
98
|
+
const { onChange } = this.props;
|
|
99
|
+
this.changeText(onChange);
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
handleChangePhone = value => {
|
|
104
|
+
this.setState({ phoneNumber: value }, () => {
|
|
105
|
+
const { onChange } = this.props;
|
|
106
|
+
this.changeText(onChange);
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
handleFocus = keyname => () => {
|
|
111
|
+
const { onFocus } = this.props;
|
|
112
|
+
const { bigFocus } = this.state;
|
|
113
|
+
|
|
114
|
+
if (!bigFocus) {
|
|
115
|
+
onFocus();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
this.setState({
|
|
119
|
+
[keyname]: true,
|
|
120
|
+
bigFocus: true
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
handleSubmitEditing = () => {
|
|
125
|
+
const { phoneRef, areaCodeError } = this.state;
|
|
126
|
+
if (!areaCodeError) {
|
|
127
|
+
phoneRef.focus();
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
phoneInputRef = ref => this.setState({ phoneRef: ref });
|
|
132
|
+
|
|
133
|
+
updateValue = () => {
|
|
134
|
+
const { value, withAreaCode } = this.props;
|
|
135
|
+
if (value) {
|
|
136
|
+
if (withAreaCode) {
|
|
137
|
+
const phone = value.split('-');
|
|
138
|
+
if (phone.length === 2) {
|
|
139
|
+
const newAreaCodeState = this.getAreaCodeState(phone[0]);
|
|
140
|
+
this.setState({
|
|
141
|
+
...newAreaCodeState,
|
|
142
|
+
phoneNumber: phone[1]
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
} else {
|
|
146
|
+
this.setState({ phoneNumber: value });
|
|
147
|
+
}
|
|
148
|
+
} else {
|
|
149
|
+
this.setState({
|
|
150
|
+
areaCode: '',
|
|
151
|
+
phoneNumber: '',
|
|
152
|
+
areaCodeError: '',
|
|
153
|
+
isValidCode: false
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
render() {
|
|
159
|
+
const {
|
|
160
|
+
areaCodePlaceholder,
|
|
161
|
+
countryCode,
|
|
162
|
+
editable,
|
|
163
|
+
formError,
|
|
164
|
+
helpText,
|
|
165
|
+
InputRef,
|
|
166
|
+
label,
|
|
167
|
+
labelVariant,
|
|
168
|
+
maxLength,
|
|
169
|
+
onSubmitEditing,
|
|
170
|
+
placeholder,
|
|
171
|
+
readOnly,
|
|
172
|
+
required,
|
|
173
|
+
RightIcon,
|
|
174
|
+
validations,
|
|
175
|
+
withAreaCode
|
|
176
|
+
} = this.props;
|
|
177
|
+
const { areaCode, areaCodeError, isValidCode, phoneNumber } = this.state;
|
|
178
|
+
|
|
179
|
+
const labelColorTheme = readOnly ? 'gray' : 'dark';
|
|
180
|
+
|
|
181
|
+
const validationErrors =
|
|
182
|
+
validations ||
|
|
183
|
+
(areaCodeError && formatErrorToValidation(areaCodeError)) ||
|
|
184
|
+
(formError && formatErrorToValidation(formError));
|
|
185
|
+
|
|
186
|
+
const hasError = validationErrors?.length > 0;
|
|
187
|
+
|
|
188
|
+
return (
|
|
189
|
+
<View style={styles.container}>
|
|
190
|
+
{label && (
|
|
191
|
+
<UTFieldLabel
|
|
192
|
+
colorTheme={labelColorTheme}
|
|
193
|
+
required={required}
|
|
194
|
+
variant={LABEL_VARIANTS[labelVariant]}
|
|
195
|
+
>
|
|
196
|
+
{label}
|
|
197
|
+
</UTFieldLabel>
|
|
198
|
+
)}
|
|
199
|
+
<View style={styles.inputsContainer}>
|
|
200
|
+
{withAreaCode ? (
|
|
201
|
+
<UTBaseInputField
|
|
202
|
+
alwaysShowPlaceholder
|
|
203
|
+
disabled={!editable || readOnly}
|
|
204
|
+
error={hasError}
|
|
205
|
+
leftAdornments={[]}
|
|
206
|
+
maxLength={4}
|
|
207
|
+
onBlur={this.handleFirstBlur}
|
|
208
|
+
onChange={this.handleChangeAreaCode}
|
|
209
|
+
onFocus={this.handleFirstFocus}
|
|
210
|
+
onSubmitEditing={this.handleSubmitEditing}
|
|
211
|
+
placeholder={areaCodePlaceholder}
|
|
212
|
+
ref={InputRef}
|
|
213
|
+
returnKeyType="next"
|
|
214
|
+
rightAdornments={[
|
|
215
|
+
{ name: COMPONENT_KEYS.ICON, props: { Icon: RightIcon, changeOnError: true } }
|
|
216
|
+
]}
|
|
217
|
+
style={{ container: styles.areaCode }}
|
|
218
|
+
type="number"
|
|
219
|
+
value={areaCode}
|
|
220
|
+
/>
|
|
221
|
+
) : null}
|
|
222
|
+
<View style={styles.phoneNumber}>
|
|
223
|
+
<UTBaseInputField
|
|
224
|
+
alwaysShowPlaceholder
|
|
225
|
+
disabled={(withAreaCode && !isValidCode) || !editable || readOnly}
|
|
226
|
+
error={hasError && !areaCodeError}
|
|
227
|
+
leftAdornments={
|
|
228
|
+
countryCode && !withAreaCode
|
|
229
|
+
? [{ name: COMPONENT_KEYS.PREFIX, props: { text: countryCode } }]
|
|
230
|
+
: []
|
|
231
|
+
}
|
|
232
|
+
maxLength={withAreaCode ? maxLength - (areaCode?.length || 0) : maxLength}
|
|
233
|
+
onBlur={this.handleSecondBlur}
|
|
234
|
+
onChange={this.handleChangePhone}
|
|
235
|
+
onFocus={this.handleSecondFocus}
|
|
236
|
+
onSubmitEditing={onSubmitEditing}
|
|
237
|
+
placeholder={placeholder}
|
|
238
|
+
ref={this.phoneInputRef}
|
|
239
|
+
returnKeyType="done"
|
|
240
|
+
rightAdornments={[
|
|
241
|
+
{ name: COMPONENT_KEYS.ICON, props: { Icon: RightIcon, changeOnError: true } }
|
|
242
|
+
]}
|
|
243
|
+
type="number"
|
|
244
|
+
value={phoneNumber}
|
|
245
|
+
/>
|
|
246
|
+
</View>
|
|
247
|
+
</View>
|
|
248
|
+
{helpText && (
|
|
249
|
+
<UTLabel colorTheme="gray" variant="small">
|
|
250
|
+
{helpText}
|
|
251
|
+
</UTLabel>
|
|
252
|
+
)}
|
|
253
|
+
{validationErrors && <UTValidation validationData={validationErrors} />}
|
|
254
|
+
</View>
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
UTPhoneInput.defaultProps = {
|
|
260
|
+
labelVariant: 'large',
|
|
261
|
+
maxLength: 10,
|
|
262
|
+
translations: {
|
|
263
|
+
areaCodeWithoutZeroError: 'Ingrese el código sin 0',
|
|
264
|
+
invalidAreaCodeError: 'Código de área inválido'
|
|
265
|
+
},
|
|
266
|
+
withAreaCode: true
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
UTPhoneInput.propTypes = {
|
|
270
|
+
areaCodePlaceholder: string,
|
|
271
|
+
countryCode: string,
|
|
272
|
+
editable: bool,
|
|
273
|
+
formError: string,
|
|
274
|
+
helpText: string,
|
|
275
|
+
InputRef: func,
|
|
276
|
+
label: string,
|
|
277
|
+
labelVariant: string,
|
|
278
|
+
maxLength: number,
|
|
279
|
+
onBlur: func,
|
|
280
|
+
onChange: func,
|
|
281
|
+
onFocus: func,
|
|
282
|
+
onSubmitEditing: func,
|
|
283
|
+
placeholder: string,
|
|
284
|
+
readOnly: bool,
|
|
285
|
+
required: bool,
|
|
286
|
+
RightIcon: elementType,
|
|
287
|
+
translations: shape({
|
|
288
|
+
areaCodeWithoutZeroError: string,
|
|
289
|
+
invalidAreaCodeError: string
|
|
290
|
+
}),
|
|
291
|
+
validations: validationDataProptypes,
|
|
292
|
+
value: string,
|
|
293
|
+
withAreaCode: bool
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
export default UTPhoneInput;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export default StyleSheet.create({
|
|
4
|
+
areaCode: {
|
|
5
|
+
flex: 1
|
|
6
|
+
},
|
|
7
|
+
container: {
|
|
8
|
+
gap: 12
|
|
9
|
+
},
|
|
10
|
+
inputsContainer: {
|
|
11
|
+
alignItems: 'flex-start',
|
|
12
|
+
flexDirection: 'row',
|
|
13
|
+
gap: 8
|
|
14
|
+
},
|
|
15
|
+
phoneNumber: {
|
|
16
|
+
flex: 2
|
|
17
|
+
}
|
|
18
|
+
});
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { bool, func, shape, string } from 'prop-types';
|
|
3
|
-
import { View } from 'react-native';
|
|
2
|
+
import { bool, func, number, shape, string } from 'prop-types';
|
|
3
|
+
import { Image, View } from 'react-native';
|
|
4
4
|
import merge from 'lodash/merge';
|
|
5
5
|
import { isEmpty } from 'lodash';
|
|
6
6
|
|
|
7
7
|
import Touchable from '../Touchable';
|
|
8
8
|
import Surface from '../Surface';
|
|
9
9
|
import UTTooltip from '../UTTooltip';
|
|
10
|
-
import Label from '../Label';
|
|
11
10
|
import { useTheme } from '../../theming';
|
|
12
|
-
import
|
|
11
|
+
import UTIcon from '../UTIcon';
|
|
12
|
+
import UTLabel from '../UTLabel';
|
|
13
13
|
|
|
14
|
-
import { getUTSelectableCardStyles, ICON_SIZE } from './styles';
|
|
14
|
+
import { getColorTheme, getUTSelectableCardStyles, ICON_SIZE } from './styles';
|
|
15
15
|
|
|
16
16
|
const UTSelectableCard = ({
|
|
17
17
|
additionalInfo = {},
|
|
@@ -19,7 +19,7 @@ const UTSelectableCard = ({
|
|
|
19
19
|
checkIcon = true,
|
|
20
20
|
description,
|
|
21
21
|
disabled = false,
|
|
22
|
-
|
|
22
|
+
Icon,
|
|
23
23
|
onPress,
|
|
24
24
|
selected = false,
|
|
25
25
|
size = 'medium',
|
|
@@ -34,8 +34,7 @@ const UTSelectableCard = ({
|
|
|
34
34
|
theme?.UTSelectableCard,
|
|
35
35
|
style
|
|
36
36
|
);
|
|
37
|
-
|
|
38
|
-
const { selectedColor = 'royalblue', disabledColor = 'gray', baseColor = 'black' } = themedStyles;
|
|
37
|
+
const colorTheme = getColorTheme(selected, disabled);
|
|
39
38
|
|
|
40
39
|
return (
|
|
41
40
|
<Surface style={themedStyles.outerContainer}>
|
|
@@ -50,72 +49,66 @@ const UTSelectableCard = ({
|
|
|
50
49
|
]}
|
|
51
50
|
>
|
|
52
51
|
<View style={themedStyles.container}>
|
|
53
|
-
{!isEmpty(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
52
|
+
{!isEmpty(Icon) &&
|
|
53
|
+
(Icon.url ? (
|
|
54
|
+
<Image
|
|
55
|
+
source={{ uri: Icon.url }}
|
|
56
|
+
width={Icon.size || ICON_SIZE}
|
|
57
|
+
height={Icon.size || ICON_SIZE}
|
|
58
|
+
style={[themedStyles.image, themedStyles.icon]}
|
|
59
|
+
/>
|
|
60
|
+
) : (
|
|
61
|
+
<UTIcon
|
|
62
|
+
name={Icon.name}
|
|
63
|
+
colorTheme={colorTheme}
|
|
64
|
+
shade={Icon.shade}
|
|
65
|
+
size={Icon.size || ICON_SIZE}
|
|
66
|
+
style={themedStyles.icon}
|
|
67
|
+
/>
|
|
68
|
+
))}
|
|
64
69
|
<View style={themedStyles.textContainer}>
|
|
65
70
|
<View style={themedStyles.column}>
|
|
66
71
|
<View style={[themedStyles.titleAndTooltip, selected && themedStyles.selectedTitleAndTooltip]}>
|
|
67
|
-
<
|
|
68
|
-
|
|
72
|
+
<UTLabel
|
|
73
|
+
colorTheme={colorTheme}
|
|
74
|
+
weight="medium"
|
|
75
|
+
variant="subtitle1"
|
|
69
76
|
style={tooltip && themedStyles.titleMargin}
|
|
70
77
|
>
|
|
71
78
|
{titleText}
|
|
72
|
-
</
|
|
79
|
+
</UTLabel>
|
|
73
80
|
{tooltip && (
|
|
74
|
-
<UTTooltip content={<
|
|
75
|
-
<
|
|
76
|
-
color={selected ? selectedColor : disabled ? disabledColor : baseColor}
|
|
77
|
-
name="help-outline"
|
|
78
|
-
/>
|
|
81
|
+
<UTTooltip content={<UTLabel>{tooltip}</UTLabel>} position="top">
|
|
82
|
+
<UTIcon colorTheme={colorTheme} name="IconHelp" />
|
|
79
83
|
</UTTooltip>
|
|
80
84
|
)}
|
|
81
85
|
</View>
|
|
82
86
|
{description && (
|
|
83
|
-
<
|
|
84
|
-
color={selected ? selectedColor : disabled ? disabledColor : baseColor}
|
|
85
|
-
medium
|
|
86
|
-
style={themedStyles.description}
|
|
87
|
-
>
|
|
87
|
+
<UTLabel colorTheme={selected ? 'accent' : 'gray'} style={themedStyles.description}>
|
|
88
88
|
{description}
|
|
89
|
-
</
|
|
89
|
+
</UTLabel>
|
|
90
90
|
)}
|
|
91
91
|
</View>
|
|
92
92
|
{!isEmpty(additionalInfo) && (
|
|
93
93
|
<View style={themedStyles.column}>
|
|
94
94
|
{!!additionalInfo.title && (
|
|
95
|
-
<
|
|
96
|
-
bold
|
|
97
|
-
color={selected ? selectedColor : disabled ? disabledColor : baseColor}
|
|
98
|
-
medium
|
|
99
|
-
right
|
|
100
|
-
>
|
|
95
|
+
<UTLabel colorTheme={colorTheme} style={themedStyles.additionalInfo}>
|
|
101
96
|
{additionalInfo.title}
|
|
102
|
-
</
|
|
97
|
+
</UTLabel>
|
|
103
98
|
)}
|
|
104
99
|
{!!additionalInfo.description && (
|
|
105
|
-
<
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
right
|
|
109
|
-
style={themedStyles.description}
|
|
100
|
+
<UTLabel
|
|
101
|
+
colorTheme={colorTheme}
|
|
102
|
+
style={[themedStyles.description, themedStyles.additionalInfo]}
|
|
110
103
|
>
|
|
111
104
|
{additionalInfo.description}
|
|
112
|
-
</
|
|
105
|
+
</UTLabel>
|
|
113
106
|
)}
|
|
114
107
|
</View>
|
|
115
108
|
)}
|
|
116
109
|
</View>
|
|
117
110
|
{checkIcon && selected && (
|
|
118
|
-
<
|
|
111
|
+
<UTIcon colorTheme="accent" name="IconCheck" style={themedStyles.checkIcon} />
|
|
119
112
|
)}
|
|
120
113
|
</View>
|
|
121
114
|
</Touchable>
|
|
@@ -129,7 +122,7 @@ UTSelectableCard.propTypes = {
|
|
|
129
122
|
checkIcon: bool,
|
|
130
123
|
description: string,
|
|
131
124
|
disabled: bool,
|
|
132
|
-
|
|
125
|
+
Icon: shape({ name: string, shade: string, size: number }),
|
|
133
126
|
onPress: func,
|
|
134
127
|
selected: bool,
|
|
135
128
|
size: string,
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
2
|
|
|
3
|
-
export const ICON_SIZE =
|
|
3
|
+
export const ICON_SIZE = 40;
|
|
4
4
|
|
|
5
5
|
export const getUTSelectableCardStyles = (theme = {}) =>
|
|
6
6
|
StyleSheet.create({
|
|
7
|
+
additionalInfo: {
|
|
8
|
+
textAlign: 'right'
|
|
9
|
+
},
|
|
7
10
|
checkIcon: {
|
|
8
11
|
marginLeft: 16
|
|
9
12
|
},
|
|
@@ -82,3 +85,5 @@ export const getUTSelectableCardStyles = (theme = {}) =>
|
|
|
82
85
|
borderWidth: 2
|
|
83
86
|
}
|
|
84
87
|
});
|
|
88
|
+
|
|
89
|
+
export const getColorTheme = (selected, disabled) => (selected ? 'accent' : disabled ? 'gray' : 'dark');
|
|
@@ -5,7 +5,9 @@ import propTypes from '../UTTextInput/versions/V1/proptypes';
|
|
|
5
5
|
|
|
6
6
|
import { DEFAULT_PROPS } from './constants';
|
|
7
7
|
|
|
8
|
-
const UTTextArea = ({ maxRows, ...props }) =>
|
|
8
|
+
const UTTextArea = ({ maxRows, ...props }) => (
|
|
9
|
+
<UTTextInput showCharacterCount maxRows={maxRows} version="V1" {...props} />
|
|
10
|
+
);
|
|
9
11
|
|
|
10
12
|
UTTextArea.defaultProps = DEFAULT_PROPS;
|
|
11
13
|
|
|
@@ -13,7 +13,7 @@ const TextInputField = ({
|
|
|
13
13
|
InputRef,
|
|
14
14
|
inputSize,
|
|
15
15
|
LeftIcon,
|
|
16
|
-
|
|
16
|
+
maxLength,
|
|
17
17
|
maxRows,
|
|
18
18
|
onBlur,
|
|
19
19
|
onChange,
|
|
@@ -24,6 +24,7 @@ const TextInputField = ({
|
|
|
24
24
|
readOnly,
|
|
25
25
|
returnKeyType,
|
|
26
26
|
RightIcon,
|
|
27
|
+
showCharacterCount,
|
|
27
28
|
style,
|
|
28
29
|
suffix,
|
|
29
30
|
tooltip,
|
|
@@ -49,7 +50,7 @@ const TextInputField = ({
|
|
|
49
50
|
error={error}
|
|
50
51
|
inputSize={inputSize}
|
|
51
52
|
leftAdornments={leftAdornments}
|
|
52
|
-
|
|
53
|
+
maxLength={maxLength}
|
|
53
54
|
maxRows={maxRows}
|
|
54
55
|
onBlur={onBlur}
|
|
55
56
|
onChange={onChange}
|
|
@@ -60,6 +61,7 @@ const TextInputField = ({
|
|
|
60
61
|
ref={InputRef}
|
|
61
62
|
returnKeyType={returnKeyType}
|
|
62
63
|
rightAdornments={rightAdornments}
|
|
64
|
+
showCharacterCount={showCharacterCount}
|
|
63
65
|
style={style}
|
|
64
66
|
type={type}
|
|
65
67
|
value={value}
|
|
@@ -77,7 +79,7 @@ TextInputField.propTypes = {
|
|
|
77
79
|
InputRef: func,
|
|
78
80
|
inputSize: string,
|
|
79
81
|
LeftIcon: elementType,
|
|
80
|
-
|
|
82
|
+
maxLength: number,
|
|
81
83
|
maxRows: number,
|
|
82
84
|
onBlur: func,
|
|
83
85
|
onChange: func,
|
|
@@ -88,6 +90,7 @@ TextInputField.propTypes = {
|
|
|
88
90
|
readOnly: bool,
|
|
89
91
|
returnKeyType: string,
|
|
90
92
|
RightIcon: elementType,
|
|
93
|
+
showCharacterCount: bool,
|
|
91
94
|
style: shape({
|
|
92
95
|
container: ViewPropTypes.style,
|
|
93
96
|
input: ViewPropTypes.style,
|
|
@@ -22,7 +22,7 @@ const UTTextInput = ({
|
|
|
22
22
|
label,
|
|
23
23
|
labelVariant,
|
|
24
24
|
LeftIcon,
|
|
25
|
-
|
|
25
|
+
maxLength,
|
|
26
26
|
maxRows,
|
|
27
27
|
onBlur,
|
|
28
28
|
onChange,
|
|
@@ -34,6 +34,7 @@ const UTTextInput = ({
|
|
|
34
34
|
required,
|
|
35
35
|
returnKeyType,
|
|
36
36
|
RightIcon,
|
|
37
|
+
showCharacterCount,
|
|
37
38
|
style,
|
|
38
39
|
suffix,
|
|
39
40
|
tooltip,
|
|
@@ -60,7 +61,7 @@ const UTTextInput = ({
|
|
|
60
61
|
InputRef={InputRef}
|
|
61
62
|
inputSize={inputSize}
|
|
62
63
|
LeftIcon={LeftIcon}
|
|
63
|
-
|
|
64
|
+
maxLength={maxLength}
|
|
64
65
|
maxRows={maxRows}
|
|
65
66
|
onBlur={onBlur}
|
|
66
67
|
onChange={onChange}
|
|
@@ -71,6 +72,7 @@ const UTTextInput = ({
|
|
|
71
72
|
readOnly={readOnly}
|
|
72
73
|
returnKeyType={returnKeyType}
|
|
73
74
|
RightIcon={RightIcon}
|
|
75
|
+
showCharacterCount={showCharacterCount}
|
|
74
76
|
style={style}
|
|
75
77
|
suffix={suffix}
|
|
76
78
|
tooltip={tooltip}
|
|
@@ -14,7 +14,7 @@ export default {
|
|
|
14
14
|
label: string,
|
|
15
15
|
labelVariant: string,
|
|
16
16
|
LeftIcon: elementType,
|
|
17
|
-
|
|
17
|
+
maxLength: number,
|
|
18
18
|
maxRows: number,
|
|
19
19
|
onBlur: func,
|
|
20
20
|
onChange: func,
|
|
@@ -26,6 +26,7 @@ export default {
|
|
|
26
26
|
required: bool,
|
|
27
27
|
returnKeyType: string,
|
|
28
28
|
RightIcon: elementType,
|
|
29
|
+
showCharacterCount: bool,
|
|
29
30
|
style: shape({
|
|
30
31
|
container: ViewPropTypes.style,
|
|
31
32
|
input: ViewPropTypes.style,
|
package/lib/index.js
CHANGED
|
@@ -62,6 +62,7 @@ export { default as UTStepFeedback } from './components/UTStepFeedback';
|
|
|
62
62
|
export { default as UTAutocomplete } from './components/UTAutocomplete';
|
|
63
63
|
export { default as UTTracker } from './components/UTTracker';
|
|
64
64
|
export { default as ImageRadio } from './components/ImageRadio';
|
|
65
|
+
export { default as UTPhoneInput } from './components/UTPhoneInput';
|
|
65
66
|
// Loading
|
|
66
67
|
export { default as Loading } from './components/Loading';
|
|
67
68
|
export { default as UTLoading } from './components/UTLoading';
|
package/package.json
CHANGED