dhre-ui-kit 0.0.38 → 0.0.39

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.38",
3
+ "version": "0.0.39",
4
4
  "main": "src/index.ts",
5
5
  "files": [
6
6
  "src",
@@ -30,8 +30,10 @@
30
30
  "react-native": "0.74.3",
31
31
  "react-native-blob-util": "^0.19.11",
32
32
  "react-native-calendars": "^1.1306.0",
33
+ "react-native-country-picker-modal": "^2.0.0",
33
34
  "react-native-gesture-handler": "2.17.0",
34
35
  "react-native-otp-verify": "^1.1.8",
36
+ "react-native-paper": "^5.12.5",
35
37
  "react-native-pdf": "^6.7.5",
36
38
  "react-native-progress": "^5.0.1",
37
39
  "react-native-svg": "^15.4.0",
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import {View, Modal} from 'react-native';
2
+ import {View, Modal, KeyboardAvoidingView, Platform} from 'react-native';
3
3
  import {PanGestureHandler} from 'react-native-gesture-handler';
4
4
  import {BlurView} from '@react-native-community/blur';
5
5
  import {BottomDrawerProps} from './BottomDrawer.interface';
@@ -41,40 +41,44 @@ const BottomDrawer: React.FC<BottomDrawerProps> = ({
41
41
  visible={isModalVisible}
42
42
  onRequestClose={toggleModal}>
43
43
  <PanGestureHandler onGestureEvent={onSwipDown}>
44
- <View style={[styles.mainContainer, style]} testID={testID}>
45
- {showBlurView ? (
46
- <BlurView
47
- style={[styles.blurView, blurViewStyle]}
48
- blurType="light"
49
- blurAmount={blurAmount}
50
- />
51
- ) : null}
52
- <View style={[styles.modalContainer, modalContainerStyle]}>
53
- <View style={styles.separator} />
54
- <View style={styles.headerContainer}>
55
- {showLeftIcon &&
56
- React.cloneElement(leftIcon, {
57
- width: moderateScale(24),
58
- height: moderateScale(24),
59
- style: styles.leftIconStyle,
60
- onPress: onLeftIconPress,
61
- })}
62
- <CustomTypography
63
- variant={titleVariant}
64
- text={title}
65
- style={{...styles.title, ...titleStyle}}
44
+ <KeyboardAvoidingView
45
+ behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
46
+ style={{flex: 1}}>
47
+ <View style={[styles.mainContainer, style]} testID={testID}>
48
+ {showBlurView ? (
49
+ <BlurView
50
+ style={[styles.blurView, blurViewStyle]}
51
+ blurType="light"
52
+ blurAmount={blurAmount}
66
53
  />
67
- {showRightIcon &&
68
- React.cloneElement(rightIcon, {
69
- width: moderateScale(24),
70
- height: moderateScale(24),
71
- style: styles.rightIconStyle,
72
- onPress: toggleModal,
73
- })}
54
+ ) : null}
55
+ <View style={[styles.modalContainer, modalContainerStyle]}>
56
+ <View style={styles.separator} />
57
+ <View style={styles.headerContainer}>
58
+ {showLeftIcon &&
59
+ React.cloneElement(leftIcon, {
60
+ width: moderateScale(24),
61
+ height: moderateScale(24),
62
+ style: styles.leftIconStyle,
63
+ onPress: onLeftIconPress,
64
+ })}
65
+ <CustomTypography
66
+ variant={titleVariant}
67
+ text={title}
68
+ style={{...styles.title, ...titleStyle}}
69
+ />
70
+ {showRightIcon &&
71
+ React.cloneElement(rightIcon, {
72
+ width: moderateScale(24),
73
+ height: moderateScale(24),
74
+ style: styles.rightIconStyle,
75
+ onPress: toggleModal,
76
+ })}
77
+ </View>
78
+ {children}
74
79
  </View>
75
- {children}
76
80
  </View>
77
- </View>
81
+ </KeyboardAvoidingView>
78
82
  </PanGestureHandler>
79
83
  </Modal>
80
84
  );
@@ -0,0 +1,141 @@
1
+ import React, {useState} from 'react';
2
+ import {
3
+ View,
4
+ TextInput,
5
+ StyleSheet,
6
+ Text,
7
+ ViewStyle,
8
+ TextStyle,
9
+ } from 'react-native';
10
+ import CountryPicker, {
11
+ Country,
12
+ CountryCode,
13
+ } from 'react-native-country-picker-modal';
14
+ import {DHRE_COLORS_TEXT} from '../../theme/colors';
15
+ import {
16
+ moderateScale,
17
+ horizontalScale,
18
+ verticalScale,
19
+ } from '../../utils/stylehelper';
20
+ import CustomTypography from '../customTypography';
21
+ import theme from '../../theme/themes';
22
+ import {
23
+ DEFAULT_CALLING_CODE,
24
+ DEFAULT_COUNTRY_CODE,
25
+ } from '../../utils/constants';
26
+
27
+ interface MobileNumberInputProps {
28
+ defaultCountryCode?: CountryCode;
29
+ defaultCallingCode?: string;
30
+ placeholder: string;
31
+ onChangeText: (text: string) => void;
32
+ value: string;
33
+ containerStyle?: ViewStyle;
34
+ inputStyle?: TextStyle;
35
+ countryPickerStyle?: ViewStyle;
36
+ callingCodeStyle?: TextStyle;
37
+ getCountryCode: (countryCode: string) => void;
38
+ maxLength: number;
39
+ errorMessage: string;
40
+ }
41
+
42
+ const CountryDropDown = ({
43
+ defaultCountryCode = DEFAULT_COUNTRY_CODE,
44
+ defaultCallingCode = DEFAULT_CALLING_CODE,
45
+ placeholder,
46
+ onChangeText,
47
+ value,
48
+ containerStyle,
49
+ inputStyle,
50
+ countryPickerStyle,
51
+ callingCodeStyle,
52
+ getCountryCode,
53
+ maxLength,
54
+ errorMessage,
55
+ }: MobileNumberInputProps) => {
56
+ const [countryCode, setCountryCode] =
57
+ useState<CountryCode>(defaultCountryCode);
58
+ const [callingCode, setCallingCode] = useState<string>(defaultCallingCode);
59
+ const [pickerVisible, setPickerVisible] = useState<boolean>(false);
60
+
61
+ const handleSelect = (country: Country) => {
62
+ setCountryCode(country.cca2);
63
+ setCallingCode(`+${country.callingCode[0]}`);
64
+ getCountryCode(`+${country.callingCode[0]}`);
65
+ };
66
+
67
+ return (
68
+ <>
69
+ <View style={[styles.container, containerStyle]}>
70
+ <View style={[styles.countryPickerContainer, countryPickerStyle]}>
71
+ <CountryPicker
72
+ withFilter
73
+ withFlag
74
+ countryCode={countryCode}
75
+ withCallingCode
76
+ onSelect={handleSelect}
77
+ visible={pickerVisible}
78
+ />
79
+ <Text
80
+ onPress={() => setPickerVisible(true)}
81
+ style={[styles.callingCode, callingCodeStyle]}>
82
+ {callingCode}
83
+ </Text>
84
+ </View>
85
+ <TextInput
86
+ style={[styles.input, inputStyle]}
87
+ placeholder={placeholder}
88
+ keyboardType="phone-pad"
89
+ value={value}
90
+ onChangeText={onChangeText}
91
+ maxLength={maxLength}
92
+ placeholderTextColor={theme.CONTENT_SECONDRY['light']}
93
+ />
94
+ </View>
95
+ {errorMessage ? (
96
+ <CustomTypography
97
+ variant={'L2_REGULAR'}
98
+ text={errorMessage ?? ''}
99
+ style={{
100
+ ...styles.errorStyle,
101
+ color: '#EB0542', // need to check with BA
102
+ }}
103
+ />
104
+ ) : null}
105
+ </>
106
+ );
107
+ };
108
+
109
+ const styles = StyleSheet.create({
110
+ container: {
111
+ flexDirection: 'row',
112
+ alignItems: 'center',
113
+ borderColor: DHRE_COLORS_TEXT.DH_BLACK,
114
+ borderWidth: 1,
115
+ borderRadius: moderateScale(8),
116
+ paddingHorizontal: horizontalScale(10),
117
+ paddingVertical: verticalScale(8),
118
+ marginTop: verticalScale(20),
119
+ },
120
+ countryPickerContainer: {
121
+ flexDirection: 'row',
122
+ alignItems: 'center',
123
+ marginRight: horizontalScale(10),
124
+ },
125
+ callingCode: {
126
+ fontSize: moderateScale(16),
127
+ color: DHRE_COLORS_TEXT.DH_BLACK,
128
+ },
129
+ input: {
130
+ flex: 1,
131
+ fontSize: moderateScale(16),
132
+ borderLeftWidth: 1,
133
+ borderLeftColor: DHRE_COLORS_TEXT.DH_TEXTLIGHTEST,
134
+ paddingLeft: horizontalScale(8),
135
+ },
136
+ errorStyle: {
137
+ marginTop: verticalScale(4),
138
+ },
139
+ });
140
+
141
+ export default CountryDropDown;
@@ -0,0 +1 @@
1
+ export {default} from './CountryPicker';
@@ -0,0 +1,87 @@
1
+ import React from 'react';
2
+ import {StyleSheet, ViewStyle} from 'react-native';
3
+ import {TextInput} from 'react-native-paper';
4
+ import {DHRE_COLORS_TEXT} from '../../theme/colors';
5
+ import {verticalScale, moderateScale} from '../../utils/stylehelper';
6
+ import CustomTypography from '../customTypography';
7
+ import theme from '../../theme/themes';
8
+
9
+ interface CommonTextInputProps {
10
+ label: string;
11
+ value: string;
12
+ onChangeText: (text: string) => void;
13
+ placeholderText?: string;
14
+ isSecureTextEntry?: boolean;
15
+ activeBorderColor?: string;
16
+ inactiveBorderColor?: string;
17
+ borderRadius?: number;
18
+ inputStyle?: ViewStyle;
19
+ keyboardType?: 'default' | 'numeric' | 'email-address' | 'phone-pad';
20
+ maxLength?: number;
21
+ errorMessage?: string;
22
+ }
23
+
24
+ const CommonTextInput: React.FC<CommonTextInputProps> = ({
25
+ label,
26
+ value,
27
+ onChangeText,
28
+ isSecureTextEntry = false,
29
+ keyboardType = 'default',
30
+ placeholderText,
31
+ activeBorderColor = theme.CONTENT_PRIMARY['light'],
32
+ inactiveBorderColor = theme.BORDER_PRIMARY['light'],
33
+ inputStyle,
34
+ maxLength,
35
+ errorMessage,
36
+ }) => {
37
+ return (
38
+ <>
39
+ <TextInput
40
+ mode="outlined"
41
+ outlineStyle={{
42
+ ...styles.outlineStyle,
43
+ borderColor: value.length ? activeBorderColor : inactiveBorderColor,
44
+ }}
45
+ label={label}
46
+ value={value}
47
+ onChangeText={onChangeText}
48
+ secureTextEntry={isSecureTextEntry}
49
+ keyboardType={keyboardType}
50
+ theme={{colors: {primary: DHRE_COLORS_TEXT.DH_BLACK}}}
51
+ style={[errorMessage ? styles.errorInput : styles.input, inputStyle]}
52
+ maxLength={maxLength}
53
+ placeholder={placeholderText}
54
+ />
55
+ {errorMessage ? (
56
+ <CustomTypography
57
+ variant={'L2_REGULAR'}
58
+ text={errorMessage ?? ''}
59
+ style={{
60
+ ...styles.errorStyle,
61
+ color: '#EB0542', // need to check with BA
62
+ }}
63
+ />
64
+ ) : null}
65
+ </>
66
+ );
67
+ };
68
+
69
+ const styles = StyleSheet.create({
70
+ input: {
71
+ marginVertical: verticalScale(12),
72
+ backgroundColor: DHRE_COLORS_TEXT.DH_WHITE,
73
+ },
74
+ errorInput: {
75
+ marginTop: verticalScale(12),
76
+ backgroundColor: DHRE_COLORS_TEXT.DH_WHITE,
77
+ },
78
+ outlineStyle: {
79
+ borderWidth: 1,
80
+ borderRadius: moderateScale(8),
81
+ },
82
+ errorStyle: {
83
+ marginTop: verticalScale(4),
84
+ },
85
+ });
86
+
87
+ export default CommonTextInput;
@@ -0,0 +1 @@
1
+ export {default} from './Textinput';
package/src/index.ts CHANGED
@@ -33,6 +33,8 @@ export {default as OurOfficesButton} from './components/OutOfOffice';
33
33
  export {default as NotificationBandge} from './components/notificationBandge';
34
34
  export {default as Category} from './components/scrollList';
35
35
  export {default as FeedbackForm} from './components/feedback';
36
+ export {default as CountryPicker} from './components/countryPicker';
37
+ export {default as TextInput} from './components/textInput';
36
38
 
37
39
  export {FONT_STYLES} from './theme/fonts';
38
40
  export {DHRE_DEFAULT, DHRE_COLORS_TEXT} from './theme/colors';
@@ -15,3 +15,6 @@ export const BUTTON_TYPES = {
15
15
  FUNCTION_NOTICE_TEXT: 'functionNoticeText',
16
16
  TEXT: 'Text',
17
17
  };
18
+
19
+ export const DEFAULT_COUNTRY_CODE = 'AE';
20
+ export const DEFAULT_CALLING_CODE = '+971';