dhre-ui-kit 0.0.24 → 0.0.26
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/__mocks__/custom-text.mock.tsx +19 -0
- package/__mocks__/setup-tests.ts +21 -0
- package/__mocks__/svgMock.ts +2 -0
- package/package.json +3 -2
- package/src/components/customSearchBar/CustomSearchBar.interface.ts +7 -2
- package/src/components/customSearchBar/CustomSearchBar.tsx +26 -8
- package/src/index.ts +2 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {CustomTextProps} from '../src/components/customText/CustomText';
|
|
3
|
+
import CustomTypography from '../src/components/customTypography/CustomTypography';
|
|
4
|
+
|
|
5
|
+
// const mockProps: CustomTextProps = {
|
|
6
|
+
// text: 'string',
|
|
7
|
+
// variant: 'string',
|
|
8
|
+
// };
|
|
9
|
+
|
|
10
|
+
// const CustomText = jest.requireActual(
|
|
11
|
+
// 'dhre-ui-kit/src/components/customText/CustomText.tsx',
|
|
12
|
+
// );
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
CustomText: (mockProps: CustomTextProps) => {
|
|
16
|
+
const {text, variant} = mockProps;
|
|
17
|
+
return <CustomTypography variant={variant} text={text || ''} />;
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
jest.mock('rn-tooltip', () => {
|
|
2
|
+
return jest.fn(({children}) => children);
|
|
3
|
+
});
|
|
4
|
+
|
|
5
|
+
jest.mock('react-native-otp-verify', () => ({
|
|
6
|
+
getOtp: jest.fn(),
|
|
7
|
+
getHash: jest.fn(),
|
|
8
|
+
addListener: jest.fn(),
|
|
9
|
+
removeListener: jest.fn(),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
jest.mock('react-native-pdf', () => 'Pdf');
|
|
13
|
+
|
|
14
|
+
jest.mock('react-native-webview', () => {
|
|
15
|
+
return jest.fn().mockImplementation(() => {
|
|
16
|
+
return null;
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
jest.mock('react-redux', () => ({
|
|
20
|
+
useSelector: jest.fn(),
|
|
21
|
+
}));
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import {TextInputProps, ViewStyle} from 'react-native';
|
|
1
|
+
import {TextInputProps, TextStyle, ViewStyle} from 'react-native';
|
|
2
2
|
|
|
3
3
|
export interface CustomSearchBarProps extends TextInputProps {
|
|
4
4
|
height?: number;
|
|
5
|
-
testID?: string;
|
|
6
5
|
disabled?: boolean;
|
|
6
|
+
testID?: string;
|
|
7
7
|
inputContainerStyle?: ViewStyle;
|
|
8
|
+
searchIconStyle?: TextStyle;
|
|
9
|
+
crossIconStyle?: TextStyle;
|
|
10
|
+
inputStyle?: TextStyle;
|
|
11
|
+
onSearchIconPress?: () => void;
|
|
12
|
+
onCrossIconPress?: () => void;
|
|
8
13
|
handleOnChangeText?: (text: string) => void;
|
|
9
14
|
}
|
|
@@ -10,10 +10,16 @@ const CustomSearchBar = ({
|
|
|
10
10
|
disabled = false,
|
|
11
11
|
testID = 'CUSTOM-SEARCH-BAR',
|
|
12
12
|
inputContainerStyle,
|
|
13
|
+
searchIconStyle,
|
|
14
|
+
crossIconStyle,
|
|
15
|
+
inputStyle,
|
|
16
|
+
onSearchIconPress,
|
|
17
|
+
onCrossIconPress,
|
|
13
18
|
handleOnChangeText,
|
|
14
19
|
...props
|
|
15
20
|
}: CustomSearchBarProps) => {
|
|
16
21
|
const [value, setValue] = useState('');
|
|
22
|
+
|
|
17
23
|
return (
|
|
18
24
|
<View
|
|
19
25
|
testID={testID}
|
|
@@ -25,15 +31,22 @@ const CustomSearchBar = ({
|
|
|
25
31
|
},
|
|
26
32
|
inputContainerStyle,
|
|
27
33
|
]}>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
<Pressable
|
|
35
|
+
onPress={() => {
|
|
36
|
+
console.log('Search icon pressed'); // Default behavior
|
|
37
|
+
onSearchIconPress?.(); // Call custom handler if provided
|
|
38
|
+
}}
|
|
39
|
+
style={searchIconStyle}>
|
|
40
|
+
{React.cloneElement(<SearchIcon />, {
|
|
41
|
+
width: moderateScale(24),
|
|
42
|
+
height: moderateScale(24),
|
|
43
|
+
style: [styles.searchIconStyle, searchIconStyle],
|
|
44
|
+
})}
|
|
45
|
+
</Pressable>
|
|
33
46
|
<TextInput
|
|
34
47
|
{...props}
|
|
35
48
|
testID={`${testID}-INPUT`}
|
|
36
|
-
style={styles.input}
|
|
49
|
+
style={[styles.input, inputStyle]} // Apply custom input styles
|
|
37
50
|
editable={!disabled}
|
|
38
51
|
value={value}
|
|
39
52
|
placeholderTextColor={disabled ? '#686868' : '#A7A7A7'}
|
|
@@ -43,11 +56,16 @@ const CustomSearchBar = ({
|
|
|
43
56
|
}}
|
|
44
57
|
/>
|
|
45
58
|
{value && (
|
|
46
|
-
<Pressable
|
|
59
|
+
<Pressable
|
|
60
|
+
onPress={() => {
|
|
61
|
+
setValue(''); // Clear the input field
|
|
62
|
+
onCrossIconPress?.(); // Call custom handler if provided
|
|
63
|
+
}}
|
|
64
|
+
style={crossIconStyle}>
|
|
47
65
|
{React.cloneElement(<CrossIcon />, {
|
|
48
66
|
width: moderateScale(24),
|
|
49
67
|
height: moderateScale(24),
|
|
50
|
-
style: styles.crossIconStyle,
|
|
68
|
+
style: [styles.crossIconStyle, crossIconStyle],
|
|
51
69
|
})}
|
|
52
70
|
</Pressable>
|
|
53
71
|
)}
|