dhre-ui-kit 0.0.49 → 0.0.50
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,3 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 = (
|
|
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
|
-
|
|
91
|
+
onButtonPress(selectedRange?.startDate, selectedRange?.endDate);
|
|
90
92
|
}}
|
|
91
93
|
containerStyle={styles.applyButton}
|
|
92
94
|
textStyle={styles.applyButtonText}
|