secullum-react-native-ui 4.16.2-beta.3 → 4.16.2-beta.4
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.
|
@@ -17,7 +17,7 @@ export interface RangeDatePickerState {
|
|
|
17
17
|
showStartDateModal: boolean;
|
|
18
18
|
count: number;
|
|
19
19
|
}
|
|
20
|
-
export declare class RangeDatePicker extends React.
|
|
20
|
+
export declare class RangeDatePicker extends React.Component<RangeDatePickerProperties, RangeDatePickerState> {
|
|
21
21
|
state: RangeDatePickerState;
|
|
22
22
|
private calendarRef;
|
|
23
23
|
componentWillMount(): void;
|
|
@@ -11,7 +11,39 @@ const layout_1 = require("../modules/layout");
|
|
|
11
11
|
require("react-date-range/dist/styles.css");
|
|
12
12
|
const react_native_1 = require("react-native");
|
|
13
13
|
require("../../styles/RangeDatePicker.css");
|
|
14
|
-
|
|
14
|
+
function compareDates(date1, date2) {
|
|
15
|
+
if (date1 instanceof Date && date2 instanceof Date) {
|
|
16
|
+
return date1.getTime() === date2.getTime();
|
|
17
|
+
}
|
|
18
|
+
return date1 === date2;
|
|
19
|
+
}
|
|
20
|
+
class PureDateRange extends React.Component {
|
|
21
|
+
// Without this check, every time the parent re-renders it would
|
|
22
|
+
// recreate the DateRange with the initial startDate value,
|
|
23
|
+
// even if the date hasn't actually changed.
|
|
24
|
+
// This causes the calendar to reset and the user loses the current
|
|
25
|
+
// selection while interacting.
|
|
26
|
+
// Related issue on GitLab 12293
|
|
27
|
+
shouldComponentUpdate(nextProps) {
|
|
28
|
+
if (nextProps.onChange !== this.props.onChange) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
return (!compareDates(nextProps.startDate, this.props.startDate) ||
|
|
32
|
+
!compareDates(nextProps.endDate, this.props.endDate));
|
|
33
|
+
}
|
|
34
|
+
render() {
|
|
35
|
+
const { startDate, endDate, onChange } = this.props;
|
|
36
|
+
const theme = (0, theme_1.getTheme)();
|
|
37
|
+
return (React.createElement(react_date_range_1.DateRange, { locale: (0, format_1.getDateFnsLocale)(), showDateDisplay: false, ranges: [
|
|
38
|
+
{
|
|
39
|
+
startDate,
|
|
40
|
+
endDate,
|
|
41
|
+
key: 'selection'
|
|
42
|
+
}
|
|
43
|
+
], rangeColors: [theme.backgroundColor3], onChange: onChange, weekdayDisplayFormat: (0, format_1.getLocale)() === 'pt' ? 'EEEEEE' : 'E' }));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
class RangeDatePicker extends React.Component {
|
|
15
47
|
constructor() {
|
|
16
48
|
super(...arguments);
|
|
17
49
|
this.state = {
|
|
@@ -108,13 +140,7 @@ class RangeDatePicker extends React.PureComponent {
|
|
|
108
140
|
marginTop: '-150px',
|
|
109
141
|
fontFamily: theme.fontFamily1
|
|
110
142
|
} },
|
|
111
|
-
React.createElement(
|
|
112
|
-
{
|
|
113
|
-
startDate: startDate,
|
|
114
|
-
endDate: endDate,
|
|
115
|
-
key: 'selection'
|
|
116
|
-
}
|
|
117
|
-
], rangeColors: [theme.backgroundColor3], onChange: this.handleRangeDateConfirm, weekdayDisplayFormat: (0, format_1.getLocale)() === 'pt' ? 'EEEEEE' : 'E' }))))));
|
|
143
|
+
React.createElement(PureDateRange, { startDate: startDate, endDate: endDate, onChange: this.handleRangeDateConfirm }))))));
|
|
118
144
|
}
|
|
119
145
|
}
|
|
120
146
|
exports.RangeDatePicker = RangeDatePicker;
|