dhre-ui-kit 0.0.41 → 0.0.42
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dhre-ui-kit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.42",
|
|
4
4
|
"main": "src/index.ts",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"react-native-blob-util": "^0.19.11",
|
|
32
32
|
"react-native-calendars": "^1.1306.0",
|
|
33
33
|
"react-native-country-picker-modal": "^2.0.0",
|
|
34
|
+
"react-native-element-dropdown": "^2.12.1",
|
|
34
35
|
"react-native-gesture-handler": "2.17.0",
|
|
35
36
|
"react-native-otp-verify": "^1.1.8",
|
|
36
37
|
"react-native-paper": "^5.12.5",
|
|
@@ -37,6 +37,7 @@ interface MobileNumberInputProps {
|
|
|
37
37
|
getCountryCode: (countryCode: string) => void;
|
|
38
38
|
maxLength: number;
|
|
39
39
|
errorMessage: string;
|
|
40
|
+
label: string;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
const CountryDropDown = ({
|
|
@@ -52,11 +53,13 @@ const CountryDropDown = ({
|
|
|
52
53
|
getCountryCode,
|
|
53
54
|
maxLength,
|
|
54
55
|
errorMessage,
|
|
56
|
+
label,
|
|
55
57
|
}: MobileNumberInputProps) => {
|
|
56
58
|
const [countryCode, setCountryCode] =
|
|
57
59
|
useState<CountryCode>(defaultCountryCode);
|
|
58
60
|
const [callingCode, setCallingCode] = useState<string>(defaultCallingCode);
|
|
59
61
|
const [pickerVisible, setPickerVisible] = useState<boolean>(false);
|
|
62
|
+
const [isFocused, setIsFocused] = useState<boolean>(false);
|
|
60
63
|
|
|
61
64
|
const handleSelect = (country: Country) => {
|
|
62
65
|
setCountryCode(country.cca2);
|
|
@@ -82,15 +85,26 @@ const CountryDropDown = ({
|
|
|
82
85
|
{callingCode}
|
|
83
86
|
</Text>
|
|
84
87
|
</View>
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
<View style={styles.flex}>
|
|
89
|
+
{(isFocused || value) && (
|
|
90
|
+
<CustomTypography
|
|
91
|
+
variant={'L2_REGULAR'}
|
|
92
|
+
text={label ?? ''}
|
|
93
|
+
style={styles.floatingLabel}
|
|
94
|
+
/>
|
|
95
|
+
)}
|
|
96
|
+
<TextInput
|
|
97
|
+
style={[styles.input, inputStyle]}
|
|
98
|
+
placeholder={!isFocused ? placeholder : ''}
|
|
99
|
+
keyboardType="phone-pad"
|
|
100
|
+
value={value}
|
|
101
|
+
onChangeText={onChangeText}
|
|
102
|
+
onFocus={() => setIsFocused(true)}
|
|
103
|
+
onBlur={() => setIsFocused(false)}
|
|
104
|
+
maxLength={maxLength}
|
|
105
|
+
placeholderTextColor={theme.CONTENT_SECONDRY['light']}
|
|
106
|
+
/>
|
|
107
|
+
</View>
|
|
94
108
|
</View>
|
|
95
109
|
{errorMessage ? (
|
|
96
110
|
<CustomTypography
|
|
@@ -98,7 +112,7 @@ const CountryDropDown = ({
|
|
|
98
112
|
text={errorMessage ?? ''}
|
|
99
113
|
style={{
|
|
100
114
|
...styles.errorStyle,
|
|
101
|
-
color: '#EB0542', // need to check with
|
|
115
|
+
color: '#EB0542', // need to check this color with designer
|
|
102
116
|
}}
|
|
103
117
|
/>
|
|
104
118
|
) : null}
|
|
@@ -107,11 +121,15 @@ const CountryDropDown = ({
|
|
|
107
121
|
};
|
|
108
122
|
|
|
109
123
|
const styles = StyleSheet.create({
|
|
124
|
+
flex: {
|
|
125
|
+
flex: 1,
|
|
126
|
+
},
|
|
110
127
|
container: {
|
|
111
128
|
flexDirection: 'row',
|
|
112
129
|
alignItems: 'center',
|
|
113
130
|
borderColor: DHRE_COLORS_TEXT.DH_BLACK,
|
|
114
131
|
borderWidth: 1,
|
|
132
|
+
height: verticalScale(48),
|
|
115
133
|
borderRadius: moderateScale(8),
|
|
116
134
|
paddingHorizontal: horizontalScale(10),
|
|
117
135
|
paddingVertical: verticalScale(8),
|
|
@@ -133,6 +151,16 @@ const styles = StyleSheet.create({
|
|
|
133
151
|
borderLeftColor: DHRE_COLORS_TEXT.DH_TEXTLIGHTEST,
|
|
134
152
|
paddingLeft: horizontalScale(8),
|
|
135
153
|
},
|
|
154
|
+
floatingLabel: {
|
|
155
|
+
position: 'absolute',
|
|
156
|
+
left: horizontalScale(-88),
|
|
157
|
+
top: verticalScale(-16),
|
|
158
|
+
fontSize: moderateScale(12),
|
|
159
|
+
color: DHRE_COLORS_TEXT.DH_BLACK,
|
|
160
|
+
backgroundColor: DHRE_COLORS_TEXT.DH_WHITE,
|
|
161
|
+
paddingHorizontal: horizontalScale(4),
|
|
162
|
+
zIndex: 1,
|
|
163
|
+
},
|
|
136
164
|
errorStyle: {
|
|
137
165
|
marginTop: verticalScale(4),
|
|
138
166
|
},
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import React, {useState} from 'react';
|
|
2
|
+
import {
|
|
3
|
+
StyleSheet,
|
|
4
|
+
Text,
|
|
5
|
+
View,
|
|
6
|
+
ViewStyle,
|
|
7
|
+
TextStyle,
|
|
8
|
+
ImageStyle,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import {Dropdown} from 'react-native-element-dropdown';
|
|
11
|
+
import {horizontalScale, verticalScale} from '../../utils/stylehelper';
|
|
12
|
+
import theme from '../../theme/themes';
|
|
13
|
+
|
|
14
|
+
interface CustomDropdownProps {
|
|
15
|
+
data: {[key: string]: string}[];
|
|
16
|
+
labelField?: string;
|
|
17
|
+
valueField?: string;
|
|
18
|
+
label?: string;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
containerStyle?: ViewStyle;
|
|
21
|
+
dropdownStyle?: ViewStyle;
|
|
22
|
+
placeholderStyle?: TextStyle;
|
|
23
|
+
selectedTextStyle?: TextStyle;
|
|
24
|
+
iconStyle?: ImageStyle;
|
|
25
|
+
labelStyle?: TextStyle;
|
|
26
|
+
defaultValue?: string;
|
|
27
|
+
iconColor?: string;
|
|
28
|
+
itemTextStyle?: TextStyle;
|
|
29
|
+
onValueChange?: (value: string) => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const CustomDropdown: React.FC<CustomDropdownProps> = ({
|
|
33
|
+
data,
|
|
34
|
+
labelField = 'label',
|
|
35
|
+
valueField = 'value',
|
|
36
|
+
label,
|
|
37
|
+
placeholder,
|
|
38
|
+
containerStyle,
|
|
39
|
+
dropdownStyle,
|
|
40
|
+
placeholderStyle,
|
|
41
|
+
selectedTextStyle,
|
|
42
|
+
iconStyle,
|
|
43
|
+
labelStyle,
|
|
44
|
+
defaultValue,
|
|
45
|
+
iconColor,
|
|
46
|
+
itemTextStyle,
|
|
47
|
+
onValueChange,
|
|
48
|
+
}) => {
|
|
49
|
+
const [value, setValue] = useState<string | undefined>(defaultValue);
|
|
50
|
+
const [isFocus, setIsFocus] = useState<boolean>(false);
|
|
51
|
+
|
|
52
|
+
const renderLabel = () => {
|
|
53
|
+
if (value || isFocus) {
|
|
54
|
+
return (
|
|
55
|
+
<Text
|
|
56
|
+
style={[
|
|
57
|
+
styles.label,
|
|
58
|
+
labelStyle,
|
|
59
|
+
isFocus && {color: theme.BORDER_INVERTED['light']},
|
|
60
|
+
]}>
|
|
61
|
+
{label}
|
|
62
|
+
</Text>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const handleValueChange = (item: {[key: string]: string}) => {
|
|
69
|
+
const newValue = item[valueField];
|
|
70
|
+
setValue(newValue);
|
|
71
|
+
setIsFocus(false);
|
|
72
|
+
if (onValueChange) {
|
|
73
|
+
onValueChange(newValue);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<View style={[styles.container, containerStyle]}>
|
|
79
|
+
{label && renderLabel()}
|
|
80
|
+
<Dropdown
|
|
81
|
+
style={[
|
|
82
|
+
styles.dropdown,
|
|
83
|
+
dropdownStyle,
|
|
84
|
+
isFocus && {borderColor: theme.BORDER_INVERTED['light']},
|
|
85
|
+
]}
|
|
86
|
+
placeholderStyle={[styles.placeholderStyle, placeholderStyle]}
|
|
87
|
+
selectedTextStyle={[styles.selectedTextStyle, selectedTextStyle]}
|
|
88
|
+
iconStyle={[styles.iconStyle, iconStyle]}
|
|
89
|
+
data={data ?? []}
|
|
90
|
+
labelField={labelField}
|
|
91
|
+
valueField={valueField}
|
|
92
|
+
placeholder={!isFocus ? placeholder : ''}
|
|
93
|
+
value={value}
|
|
94
|
+
onFocus={() => setIsFocus(true)}
|
|
95
|
+
onBlur={() => setIsFocus(false)}
|
|
96
|
+
onChange={handleValueChange}
|
|
97
|
+
iconColor={iconColor}
|
|
98
|
+
dropdownPosition="bottom"
|
|
99
|
+
itemTextStyle={itemTextStyle}
|
|
100
|
+
/>
|
|
101
|
+
</View>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const styles = StyleSheet.create({
|
|
106
|
+
container: {
|
|
107
|
+
backgroundColor: theme.SURFACE_STATIC['light'],
|
|
108
|
+
marginVertical: verticalScale(4), // External margin
|
|
109
|
+
},
|
|
110
|
+
dropdown: {
|
|
111
|
+
height: verticalScale(48),
|
|
112
|
+
borderColor: theme.BORDER_PRIMARY['light'],
|
|
113
|
+
borderWidth: 1,
|
|
114
|
+
borderRadius: 8,
|
|
115
|
+
paddingHorizontal: horizontalScale(12),
|
|
116
|
+
backgroundColor: theme.SURFACE_STATIC['light'],
|
|
117
|
+
},
|
|
118
|
+
label: {
|
|
119
|
+
position: 'absolute',
|
|
120
|
+
backgroundColor: theme.SURFACE_STATIC['light'],
|
|
121
|
+
left: horizontalScale(10),
|
|
122
|
+
top: verticalScale(-8),
|
|
123
|
+
zIndex: 10,
|
|
124
|
+
paddingHorizontal: horizontalScale(4),
|
|
125
|
+
fontSize: verticalScale(12),
|
|
126
|
+
},
|
|
127
|
+
placeholderStyle: {
|
|
128
|
+
fontSize: verticalScale(16),
|
|
129
|
+
},
|
|
130
|
+
selectedTextStyle: {
|
|
131
|
+
fontSize: verticalScale(16),
|
|
132
|
+
},
|
|
133
|
+
iconStyle: {
|
|
134
|
+
width: horizontalScale(20),
|
|
135
|
+
height: verticalScale(20),
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
export default CustomDropdown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default} from './DropDown';
|
|
@@ -58,7 +58,7 @@ const CommonTextInput: React.FC<CommonTextInputProps> = ({
|
|
|
58
58
|
text={errorMessage ?? ''}
|
|
59
59
|
style={{
|
|
60
60
|
...styles.errorStyle,
|
|
61
|
-
color: '#EB0542', // need to check with
|
|
61
|
+
color: '#EB0542', // need to check this color with designer
|
|
62
62
|
}}
|
|
63
63
|
/>
|
|
64
64
|
) : null}
|
|
@@ -68,15 +68,22 @@ const CommonTextInput: React.FC<CommonTextInputProps> = ({
|
|
|
68
68
|
|
|
69
69
|
const styles = StyleSheet.create({
|
|
70
70
|
input: {
|
|
71
|
-
marginVertical: verticalScale(
|
|
71
|
+
marginVertical: verticalScale(8),
|
|
72
72
|
backgroundColor: DHRE_COLORS_TEXT.DH_WHITE,
|
|
73
|
+
paddingVertical: 0,
|
|
74
|
+
height: verticalScale(48),
|
|
75
|
+
justifyContent: 'center',
|
|
73
76
|
},
|
|
74
77
|
errorInput: {
|
|
75
78
|
marginTop: verticalScale(12),
|
|
76
79
|
backgroundColor: DHRE_COLORS_TEXT.DH_WHITE,
|
|
80
|
+
paddingVertical: 0,
|
|
81
|
+
height: verticalScale(48),
|
|
82
|
+
justifyContent: 'center',
|
|
77
83
|
},
|
|
78
84
|
outlineStyle: {
|
|
79
85
|
borderWidth: 1,
|
|
86
|
+
height: verticalScale(48),
|
|
80
87
|
borderRadius: moderateScale(8),
|
|
81
88
|
},
|
|
82
89
|
errorStyle: {
|
package/src/index.ts
CHANGED
|
@@ -35,6 +35,7 @@ export {default as Category} from './components/scrollList';
|
|
|
35
35
|
export {default as FeedbackForm} from './components/feedback';
|
|
36
36
|
export {default as CountryPicker} from './components/countryPicker';
|
|
37
37
|
export {default as TextInput} from './components/textInput';
|
|
38
|
+
export {default as DropDown} from './components/dropDown';
|
|
38
39
|
|
|
39
40
|
export {FONT_STYLES} from './theme/fonts';
|
|
40
41
|
export {FontStyle, Theme} from './utils/appEnum';
|