dhre-ui-kit 0.0.49 → 0.0.51

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.49",
3
+ "version": "0.0.51",
4
4
  "main": "src/index.ts",
5
5
  "files": [
6
6
  "src",
@@ -6,6 +6,9 @@ export interface AccordionProps {
6
6
  testId?: string;
7
7
  containerStyle?: ViewStyle;
8
8
  titleStyle?: TextStyle;
9
- children: React.ReactNode;
10
9
  headerStyle?: ViewStyle;
10
+ children?: React.ReactNode;
11
+ isOpen: boolean;
12
+ onToggle: () => void;
13
+ optionalElement?: () => React.ReactNode; // Update this line
11
14
  }
@@ -15,7 +15,8 @@ const Accordion = ({
15
15
  children,
16
16
  isOpen,
17
17
  onToggle,
18
- }: AccordionProps & {isOpen: boolean; onToggle: () => void}) => {
18
+ optionalElement, // Destructure the new prop
19
+ }: AccordionProps) => {
19
20
  const contentRef = useRef<View>(null);
20
21
  const [animation] = useState(new Animated.Value(0));
21
22
  const [contentHeight, setContentHeight] = useState(0);
@@ -55,6 +56,9 @@ const Accordion = ({
55
56
  style: styles.iconStyle,
56
57
  })}
57
58
  </Pressable>
59
+
60
+ {optionalElement ? optionalElement() : null}
61
+
58
62
  <Animated.View style={[styles.content, {height: cardHeight}]}>
59
63
  <View
60
64
  ref={contentRef}
@@ -16,4 +16,6 @@ export interface CustomSearchBarProps extends TextInputProps {
16
16
  disablePlaceHolderStyle?: string;
17
17
  enablePlaceHolderStyle?: string;
18
18
  borderColor?: string;
19
+ setValue: (val: string) => void;
20
+ value: string;
19
21
  }
@@ -11,7 +11,15 @@ const mockProps = {
11
11
 
12
12
  describe('Custom search bar component', () => {
13
13
  it('Component renders correctly', () => {
14
- const {getByTestId} = render(<CustomSearchBar {...mockProps} />);
14
+ const {getByTestId} = render(
15
+ <CustomSearchBar
16
+ setValue={(val: string) => {
17
+ return val;
18
+ }}
19
+ value={''}
20
+ {...mockProps}
21
+ />,
22
+ );
15
23
  expect(getByTestId(mockProps.testID)).toBeTruthy();
16
24
  const textInput = getByTestId('CUSTOM-SEARCH-BAR-INPUT');
17
25
  fireEvent.changeText(textInput, 'test@example.com');
@@ -1,4 +1,4 @@
1
- import React, {useState} from 'react';
1
+ import React from 'react';
2
2
  import {Pressable, TextInput, View} from 'react-native';
3
3
  import {CrossIcon, SearchIcon} from '../../assets';
4
4
  import {moderateScale, verticalScale} from '../../utils/stylehelper';
@@ -6,6 +6,7 @@ import {CustomSearchBarProps} from './CustomSearchBar.interface';
6
6
  import styles from './CustomSearchBar.styles';
7
7
 
8
8
  const CustomSearchBar = ({
9
+ value,
9
10
  height = 40,
10
11
  disabled = false,
11
12
  testID = 'CUSTOM-SEARCH-BAR',
@@ -16,6 +17,7 @@ const CustomSearchBar = ({
16
17
  onSearchIconPress,
17
18
  onCrossIconPress,
18
19
  handleOnChangeText,
20
+ setValue,
19
21
  rightIcon = <CrossIcon />,
20
22
  disableBorderColor = '#4F4F4F',
21
23
  borderColor = '#FFFFFF',
@@ -23,8 +25,6 @@ const CustomSearchBar = ({
23
25
  enablePlaceHolderStyle = '#A7A7A7',
24
26
  ...props
25
27
  }: CustomSearchBarProps) => {
26
- const [value, setValue] = useState('');
27
-
28
28
  return (
29
29
  <View
30
30
  testID={testID}
@@ -1,3 +1,12 @@
1
- export interface DateRangePickerProps {
2
- onPress: (startDate: string, endDate: string) => void;
1
+ import {CalendarProps} from 'react-native-calendars';
2
+ export interface DateRangePickerProps extends CalendarProps {
3
+ onButtonPress: (startDate: string, endDate: string) => void;
4
+ }
5
+
6
+ export interface DayType {
7
+ dateString: string;
8
+ day: number;
9
+ month: number;
10
+ year: number;
11
+ timestamp: number;
3
12
  }
@@ -2,10 +2,11 @@ import React, {useState} from 'react';
2
2
  import {View} from 'react-native';
3
3
  import {Calendar} from 'react-native-calendars';
4
4
  import Button from '../button';
5
- import {DateRangePickerProps} from './DateRangePicker.interface';
5
+ import {DateRangePickerProps, DayType} from './DateRangePicker.interface';
6
6
  import styles from './DateRangePicker.styles';
7
7
 
8
- const DateRangePicker = ({onPress}: DateRangePickerProps) => {
8
+ const DateRangePicker = (props: DateRangePickerProps) => {
9
+ const {onButtonPress} = props;
9
10
  const [selectedRange, setSelectedRange] = useState<{
10
11
  startDate: string;
11
12
  endDate: string;
@@ -14,7 +15,7 @@ const DateRangePicker = ({onPress}: DateRangePickerProps) => {
14
15
  endDate: '',
15
16
  });
16
17
 
17
- const onDayPress = day => {
18
+ const onDayPress = (day: DayType) => {
18
19
  const {dateString} = day;
19
20
  const {startDate, endDate} = selectedRange;
20
21
 
@@ -82,11 +83,12 @@ const DateRangePicker = ({onPress}: DateRangePickerProps) => {
82
83
  color: '#A7A7A7',
83
84
  }}
84
85
  onDayPress={onDayPress}
86
+ {...props}
85
87
  />
86
88
  <Button
87
89
  title="Apply"
88
90
  onPress={() => {
89
- onPress(selectedRange?.startDate, selectedRange?.endDate);
91
+ onButtonPress(selectedRange?.startDate, selectedRange?.endDate);
90
92
  }}
91
93
  containerStyle={styles.applyButton}
92
94
  textStyle={styles.applyButtonText}