UNPKG

25.4 kBJavaScriptView Raw
1/*
2 * Copyright 2016 Palantir Technologies, Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import classNames from "classnames";
17import * as React from "react";
18import DayPicker from "react-day-picker";
19import { AbstractPureComponent2, Boundary, DISPLAYNAME_PREFIX, Divider } from "@blueprintjs/core";
20import * as DateClasses from "./common/classes";
21import * as DateUtils from "./common/dateUtils";
22import * as Errors from "./common/errors";
23import { MonthAndYear } from "./common/monthAndYear";
24import { DatePickerCaption } from "./datePickerCaption";
25import { combineModifiers, getDefaultMaxDate, getDefaultMinDate, HOVERED_RANGE_MODIFIER, SELECTED_RANGE_MODIFIER, } from "./datePickerCore";
26import { DatePickerNavbar } from "./datePickerNavbar";
27import { DateRangeSelectionStrategy } from "./dateRangeSelectionStrategy";
28import { Shortcuts } from "./shortcuts";
29import { TimePicker } from "./timePicker";
30export class DateRangePicker extends AbstractPureComponent2 {
31 static defaultProps = {
32 allowSingleDayRange: false,
33 contiguousCalendarMonths: true,
34 dayPickerProps: {},
35 maxDate: getDefaultMaxDate(),
36 minDate: getDefaultMinDate(),
37 reverseMonthAndYearMenus: false,
38 shortcuts: true,
39 singleMonthOnly: false,
40 timePickerProps: {},
41 };
42 static displayName = `${DISPLAYNAME_PREFIX}.DateRangePicker`;
43 // these will get merged with the user's own
44 modifiers = {
45 [SELECTED_RANGE_MODIFIER]: day => {
46 const { value } = this.state;
47 return value[0] != null && value[1] != null && DateUtils.isDayInRange(day, value, true);
48 },
49 [`${SELECTED_RANGE_MODIFIER}-start`]: day => DateUtils.areSameDay(this.state.value[0], day),
50 [`${SELECTED_RANGE_MODIFIER}-end`]: day => DateUtils.areSameDay(this.state.value[1], day),
51 [HOVERED_RANGE_MODIFIER]: day => {
52 const { hoverValue, value: [selectedStart, selectedEnd], } = this.state;
53 if (selectedStart == null && selectedEnd == null) {
54 return false;
55 }
56 if (hoverValue == null || hoverValue[0] == null || hoverValue[1] == null) {
57 return false;
58 }
59 return DateUtils.isDayInRange(day, hoverValue, true);
60 },
61 [`${HOVERED_RANGE_MODIFIER}-start`]: day => {
62 const { hoverValue } = this.state;
63 if (hoverValue == null || hoverValue[0] == null) {
64 return false;
65 }
66 return DateUtils.areSameDay(hoverValue[0], day);
67 },
68 [`${HOVERED_RANGE_MODIFIER}-end`]: day => {
69 const { hoverValue } = this.state;
70 if (hoverValue == null || hoverValue[1] == null) {
71 return false;
72 }
73 return DateUtils.areSameDay(hoverValue[1], day);
74 },
75 };
76 constructor(props, context) {
77 super(props, context);
78 const value = getInitialValue(props);
79 const time = value;
80 const initialMonth = getInitialMonth(props, value);
81 // if the initial month is the last month of the picker's
82 // allowable range, the react-day-picker library will show
83 // the max month on the left and the *min* month on the right.
84 // subtracting one avoids that weird, wraparound state (#289).
85 const initialMonthEqualsMinMonth = DateUtils.areSameMonth(initialMonth, props.minDate);
86 const initalMonthEqualsMaxMonth = DateUtils.areSameMonth(initialMonth, props.maxDate);
87 if (!props.singleMonthOnly && !initialMonthEqualsMinMonth && initalMonthEqualsMaxMonth) {
88 initialMonth.setMonth(initialMonth.getMonth() - 1);
89 }
90 // show the selected end date's encompassing month in the right view if
91 // the calendars don't have to be contiguous.
92 // if left view and right view months are the same, show next month in the right view.
93 const leftView = MonthAndYear.fromDate(initialMonth);
94 const rightDate = value[1];
95 const rightView = !props.contiguousCalendarMonths && rightDate != null && !DateUtils.areSameMonth(initialMonth, rightDate)
96 ? MonthAndYear.fromDate(rightDate)
97 : leftView.getNextMonth();
98 this.state = {
99 hoverValue: [null, null],
100 leftView,
101 rightView,
102 selectedShortcutIndex: this.props.selectedShortcutIndex !== undefined ? this.props.selectedShortcutIndex : -1,
103 time,
104 value,
105 };
106 }
107 render() {
108 const { className, contiguousCalendarMonths, singleMonthOnly } = this.props;
109 const isShowingOneMonth = singleMonthOnly || DateUtils.areSameMonth(this.props.minDate, this.props.maxDate);
110 const classes = classNames(DateClasses.DATEPICKER, DateClasses.DATERANGEPICKER, className, {
111 [DateClasses.DATERANGEPICKER_CONTIGUOUS]: contiguousCalendarMonths,
112 [DateClasses.DATERANGEPICKER_SINGLE_MONTH]: isShowingOneMonth,
113 });
114 // use the left DayPicker when we only need one
115 return (React.createElement("div", { className: classes },
116 this.maybeRenderShortcuts(),
117 React.createElement("div", null,
118 this.renderCalendars(isShowingOneMonth),
119 this.maybeRenderTimePickers())));
120 }
121 componentDidUpdate(prevProps, prevState) {
122 super.componentDidUpdate(prevProps, prevState);
123 if (!DateUtils.areRangesEqual(prevProps.value, this.props.value) ||
124 prevProps.contiguousCalendarMonths !== this.props.contiguousCalendarMonths) {
125 const nextState = getStateChange(prevProps.value, this.props.value, this.state, prevProps.contiguousCalendarMonths);
126 this.setState(nextState);
127 }
128 if (this.props.selectedShortcutIndex !== prevProps.selectedShortcutIndex) {
129 this.setState({ selectedShortcutIndex: this.props.selectedShortcutIndex });
130 }
131 }
132 validateProps(props) {
133 const { defaultValue, initialMonth, maxDate, minDate, boundaryToModify, value } = props;
134 const dateRange = [minDate, maxDate];
135 if (defaultValue != null && !DateUtils.isDayRangeInRange(defaultValue, dateRange)) {
136 console.error(Errors.DATERANGEPICKER_DEFAULT_VALUE_INVALID);
137 }
138 if (initialMonth != null && !DateUtils.isMonthInRange(initialMonth, dateRange)) {
139 console.error(Errors.DATERANGEPICKER_INITIAL_MONTH_INVALID);
140 }
141 if (maxDate != null && minDate != null && maxDate < minDate && !DateUtils.areSameDay(maxDate, minDate)) {
142 console.error(Errors.DATERANGEPICKER_MAX_DATE_INVALID);
143 }
144 if (value != null && !DateUtils.isDayRangeInRange(value, dateRange)) {
145 console.error(Errors.DATERANGEPICKER_VALUE_INVALID);
146 }
147 if (boundaryToModify != null && boundaryToModify !== Boundary.START && boundaryToModify !== Boundary.END) {
148 console.error(Errors.DATERANGEPICKER_PREFERRED_BOUNDARY_TO_MODIFY_INVALID);
149 }
150 }
151 shouldHighlightCurrentDay = (date) => {
152 const { highlightCurrentDay } = this.props;
153 return highlightCurrentDay && DateUtils.isToday(date);
154 };
155 getDateRangePickerModifiers = () => {
156 const { modifiers } = this.props;
157 return combineModifiers(this.modifiers, {
158 isToday: this.shouldHighlightCurrentDay,
159 ...modifiers,
160 });
161 };
162 renderDay = (day) => {
163 const date = day.getDate();
164 return React.createElement("div", { className: DateClasses.DATEPICKER_DAY_WRAPPER }, date);
165 };
166 disabledDays = (day) => !DateUtils.isDayInRange(day, [this.props.minDate, this.props.maxDate]);
167 getDisabledDaysModifier = () => {
168 const { dayPickerProps: { disabledDays }, } = this.props;
169 return disabledDays instanceof Array ? [this.disabledDays, ...disabledDays] : [this.disabledDays, disabledDays];
170 };
171 maybeRenderShortcuts() {
172 const { shortcuts } = this.props;
173 if (shortcuts == null || shortcuts === false) {
174 return null;
175 }
176 const { selectedShortcutIndex } = this.state;
177 const { allowSingleDayRange, maxDate, minDate, timePrecision } = this.props;
178 return [
179 React.createElement(Shortcuts, { key: "shortcuts", ...{
180 allowSingleDayRange,
181 maxDate,
182 minDate,
183 selectedShortcutIndex,
184 shortcuts,
185 timePrecision,
186 }, onShortcutClick: this.handleShortcutClick }),
187 React.createElement(Divider, { key: "div" }),
188 ];
189 }
190 maybeRenderTimePickers() {
191 const { timePrecision, timePickerProps } = this.props;
192 if (timePrecision == null && timePickerProps === DateRangePicker.defaultProps.timePickerProps) {
193 return null;
194 }
195 return (React.createElement("div", { className: DateClasses.DATERANGEPICKER_TIMEPICKERS },
196 React.createElement(TimePicker, { precision: timePrecision, ...timePickerProps, onChange: this.handleTimeChangeLeftCalendar, value: this.state.time[0] }),
197 React.createElement(TimePicker, { precision: timePrecision, ...timePickerProps, onChange: this.handleTimeChangeRightCalendar, value: this.state.time[1] })));
198 }
199 handleTimeChange = (newTime, dateIndex) => {
200 this.props.timePickerProps?.onChange?.(newTime);
201 const { value, time } = this.state;
202 const newValue = DateUtils.getDateTime(value[dateIndex] != null ? DateUtils.clone(value[dateIndex]) : new Date(), newTime);
203 const newDateRange = [value[0], value[1]];
204 newDateRange[dateIndex] = newValue;
205 const newTimeRange = [time[0], time[1]];
206 newTimeRange[dateIndex] = newTime;
207 this.props.onChange?.(newDateRange);
208 this.setState({ value: newDateRange, time: newTimeRange });
209 };
210 handleTimeChangeLeftCalendar = (time) => {
211 this.handleTimeChange(time, 0);
212 };
213 handleTimeChangeRightCalendar = (time) => {
214 this.handleTimeChange(time, 1);
215 };
216 renderCalendars(isShowingOneMonth) {
217 const { dayPickerProps, locale, localeUtils, maxDate, minDate } = this.props;
218 const dayPickerBaseProps = {
219 locale,
220 localeUtils,
221 modifiers: this.getDateRangePickerModifiers(),
222 showOutsideDays: true,
223 ...dayPickerProps,
224 disabledDays: this.getDisabledDaysModifier(),
225 onDayClick: this.handleDayClick,
226 onDayMouseEnter: this.handleDayMouseEnter,
227 onDayMouseLeave: this.handleDayMouseLeave,
228 selectedDays: this.state.value,
229 };
230 if (isShowingOneMonth) {
231 return (React.createElement(DayPicker, { ...dayPickerBaseProps, captionElement: this.renderSingleCaption, navbarElement: this.renderSingleNavbar, fromMonth: minDate, month: this.state.leftView.getFullDate(), numberOfMonths: 1, onMonthChange: this.handleLeftMonthChange, toMonth: maxDate, renderDay: dayPickerProps?.renderDay ?? this.renderDay }));
232 }
233 else {
234 return [
235 React.createElement(DayPicker, { key: "left", ...dayPickerBaseProps, canChangeMonth: true, captionElement: this.renderLeftCaption, navbarElement: this.renderLeftNavbar, fromMonth: minDate, month: this.state.leftView.getFullDate(), numberOfMonths: 1, onMonthChange: this.handleLeftMonthChange, toMonth: DateUtils.getDatePreviousMonth(maxDate), renderDay: dayPickerProps?.renderDay ?? this.renderDay }),
236 React.createElement(DayPicker, { key: "right", ...dayPickerBaseProps, canChangeMonth: true, captionElement: this.renderRightCaption, navbarElement: this.renderRightNavbar, fromMonth: DateUtils.getDateNextMonth(minDate), month: this.state.rightView.getFullDate(), numberOfMonths: 1, onMonthChange: this.handleRightMonthChange, toMonth: maxDate, renderDay: dayPickerProps?.renderDay ?? this.renderDay }),
237 ];
238 }
239 }
240 renderSingleNavbar = (navbarProps) => (React.createElement(DatePickerNavbar, { ...navbarProps, maxDate: this.props.maxDate, minDate: this.props.minDate }));
241 renderLeftNavbar = (navbarProps) => (React.createElement(DatePickerNavbar, { ...navbarProps, hideRightNavButton: this.props.contiguousCalendarMonths, maxDate: this.props.maxDate, minDate: this.props.minDate }));
242 renderRightNavbar = (navbarProps) => (React.createElement(DatePickerNavbar, { ...navbarProps, hideLeftNavButton: this.props.contiguousCalendarMonths, maxDate: this.props.maxDate, minDate: this.props.minDate }));
243 renderSingleCaption = (captionProps) => (React.createElement(DatePickerCaption, { ...captionProps, maxDate: this.props.maxDate, minDate: this.props.minDate, onMonthChange: this.handleLeftMonthSelectChange, onYearChange: this.handleLeftYearSelectChange, reverseMonthAndYearMenus: this.props.reverseMonthAndYearMenus }));
244 renderLeftCaption = (captionProps) => (React.createElement(DatePickerCaption, { ...captionProps, maxDate: DateUtils.getDatePreviousMonth(this.props.maxDate), minDate: this.props.minDate, onMonthChange: this.handleLeftMonthSelectChange, onYearChange: this.handleLeftYearSelectChange, reverseMonthAndYearMenus: this.props.reverseMonthAndYearMenus }));
245 renderRightCaption = (captionProps) => (React.createElement(DatePickerCaption, { ...captionProps, maxDate: this.props.maxDate, minDate: DateUtils.getDateNextMonth(this.props.minDate), onMonthChange: this.handleRightMonthSelectChange, onYearChange: this.handleRightYearSelectChange, reverseMonthAndYearMenus: this.props.reverseMonthAndYearMenus }));
246 handleDayMouseEnter = (day, modifiers, e) => {
247 this.props.dayPickerProps.onDayMouseEnter?.(day, modifiers, e);
248 if (modifiers.disabled) {
249 return;
250 }
251 const { dateRange, boundary } = DateRangeSelectionStrategy.getNextState(this.state.value, day, this.props.allowSingleDayRange, this.props.boundaryToModify);
252 this.setState({ hoverValue: dateRange });
253 this.props.onHoverChange?.(dateRange, day, boundary);
254 };
255 handleDayMouseLeave = (day, modifiers, e) => {
256 this.props.dayPickerProps.onDayMouseLeave?.(day, modifiers, e);
257 if (modifiers.disabled) {
258 return;
259 }
260 this.setState({ hoverValue: undefined });
261 this.props.onHoverChange?.(undefined, day, undefined);
262 };
263 handleDayClick = (day, modifiers, e) => {
264 this.props.dayPickerProps.onDayClick?.(day, modifiers, e);
265 if (modifiers.disabled) {
266 // rerender base component to get around bug where you can navigate past bounds by clicking days
267 this.forceUpdate();
268 return;
269 }
270 const nextValue = DateRangeSelectionStrategy.getNextState(this.state.value, day, this.props.allowSingleDayRange, this.props.boundaryToModify).dateRange;
271 // update the hovered date range after click to show the newly selected
272 // state, at leasts until the mouse moves again
273 this.handleDayMouseEnter(day, modifiers, e);
274 this.handleNextState(nextValue);
275 };
276 handleShortcutClick = (shortcut, selectedShortcutIndex) => {
277 const { onChange, contiguousCalendarMonths, onShortcutChange } = this.props;
278 const { dateRange, includeTime } = shortcut;
279 if (includeTime) {
280 const newDateRange = [dateRange[0], dateRange[1]];
281 const newTimeRange = [dateRange[0], dateRange[1]];
282 const nextState = getStateChange(this.state.value, dateRange, this.state, contiguousCalendarMonths);
283 this.setState({ ...nextState, time: newTimeRange });
284 onChange?.(newDateRange);
285 }
286 else {
287 this.handleNextState(dateRange);
288 }
289 if (this.props.selectedShortcutIndex === undefined) {
290 this.setState({ selectedShortcutIndex });
291 }
292 onShortcutChange?.(shortcut, selectedShortcutIndex);
293 };
294 handleNextState = (nextValue) => {
295 const { value } = this.state;
296 nextValue[0] = DateUtils.getDateTime(nextValue[0], this.state.time[0]);
297 nextValue[1] = DateUtils.getDateTime(nextValue[1], this.state.time[1]);
298 const nextState = getStateChange(value, nextValue, this.state, this.props.contiguousCalendarMonths);
299 if (this.props.value == null) {
300 this.setState(nextState);
301 }
302 this.props.onChange?.(nextValue);
303 };
304 handleLeftMonthChange = (newDate) => {
305 const leftView = MonthAndYear.fromDate(newDate);
306 this.props.dayPickerProps.onMonthChange?.(leftView.getFullDate());
307 this.updateLeftView(leftView);
308 };
309 handleRightMonthChange = (newDate) => {
310 const rightView = MonthAndYear.fromDate(newDate);
311 this.props.dayPickerProps.onMonthChange?.(rightView.getFullDate());
312 this.updateRightView(rightView);
313 };
314 handleLeftMonthSelectChange = (leftMonth) => {
315 const leftView = new MonthAndYear(leftMonth, this.state.leftView.getYear());
316 this.props.dayPickerProps.onMonthChange?.(leftView.getFullDate());
317 this.updateLeftView(leftView);
318 };
319 handleRightMonthSelectChange = (rightMonth) => {
320 const rightView = new MonthAndYear(rightMonth, this.state.rightView.getYear());
321 this.props.dayPickerProps.onMonthChange?.(rightView.getFullDate());
322 this.updateRightView(rightView);
323 };
324 updateLeftView(leftView) {
325 let rightView = this.state.rightView.clone();
326 if (!leftView.isBefore(rightView) || this.props.contiguousCalendarMonths) {
327 rightView = leftView.getNextMonth();
328 }
329 this.setViews(leftView, rightView);
330 }
331 updateRightView(rightView) {
332 let leftView = this.state.leftView.clone();
333 if (!rightView.isAfter(leftView) || this.props.contiguousCalendarMonths) {
334 leftView = rightView.getPreviousMonth();
335 }
336 this.setViews(leftView, rightView);
337 }
338 /*
339 * The min / max months are offset by one because we are showing two months.
340 * We do a comparison check to see if
341 * a) the proposed [Month, Year] change throws the two calendars out of order
342 * b) the proposed [Month, Year] goes beyond the min / max months
343 * and rectify appropriately.
344 */
345 handleLeftYearSelectChange = (leftDisplayYear) => {
346 let leftView = new MonthAndYear(this.state.leftView.getMonth(), leftDisplayYear);
347 this.props.dayPickerProps.onMonthChange?.(leftView.getFullDate());
348 const { minDate, maxDate } = this.props;
349 const adjustedMaxDate = DateUtils.getDatePreviousMonth(maxDate);
350 const minMonthAndYear = new MonthAndYear(minDate.getMonth(), minDate.getFullYear());
351 const maxMonthAndYear = new MonthAndYear(adjustedMaxDate.getMonth(), adjustedMaxDate.getFullYear());
352 if (leftView.isBefore(minMonthAndYear)) {
353 leftView = minMonthAndYear;
354 }
355 else if (leftView.isAfter(maxMonthAndYear)) {
356 leftView = maxMonthAndYear;
357 }
358 let rightView = this.state.rightView.clone();
359 if (!leftView.isBefore(rightView) || this.props.contiguousCalendarMonths) {
360 rightView = leftView.getNextMonth();
361 }
362 this.setViews(leftView, rightView);
363 };
364 handleRightYearSelectChange = (rightDisplayYear) => {
365 let rightView = new MonthAndYear(this.state.rightView.getMonth(), rightDisplayYear);
366 this.props.dayPickerProps.onMonthChange?.(rightView.getFullDate());
367 const { minDate, maxDate } = this.props;
368 const adjustedMinDate = DateUtils.getDateNextMonth(minDate);
369 const minMonthAndYear = MonthAndYear.fromDate(adjustedMinDate);
370 const maxMonthAndYear = MonthAndYear.fromDate(maxDate);
371 if (rightView.isBefore(minMonthAndYear)) {
372 rightView = minMonthAndYear;
373 }
374 else if (rightView.isAfter(maxMonthAndYear)) {
375 rightView = maxMonthAndYear;
376 }
377 let leftView = this.state.leftView.clone();
378 if (!rightView.isAfter(leftView) || this.props.contiguousCalendarMonths) {
379 leftView = rightView.getPreviousMonth();
380 }
381 this.setViews(leftView, rightView);
382 };
383 setViews(leftView, rightView) {
384 this.setState({ leftView, rightView });
385 }
386}
387function getStateChange(value, nextValue, state, contiguousCalendarMonths) {
388 if (value != null && nextValue == null) {
389 return { value: [null, null] };
390 }
391 else if (nextValue != null) {
392 let leftView = state.leftView.clone();
393 let rightView = state.rightView.clone();
394 const nextValueStartView = MonthAndYear.fromDate(nextValue[0]);
395 const nextValueEndView = MonthAndYear.fromDate(nextValue[1]);
396 // Only end date selected.
397 // If the newly selected end date isn't in either of the displayed months, then
398 // - set the right DayPicker to the month of the selected end date
399 // - ensure the left DayPicker is before the right, changing if needed
400 if (nextValueStartView == null && nextValueEndView != null) {
401 if (!nextValueEndView.isSame(leftView) && !nextValueEndView.isSame(rightView)) {
402 rightView = nextValueEndView;
403 if (!leftView.isBefore(rightView)) {
404 leftView = rightView.getPreviousMonth();
405 }
406 }
407 }
408 else if (nextValueStartView != null && nextValueEndView == null) {
409 // Only start date selected.
410 // If the newly selected start date isn't in either of the displayed months, then
411 // - set the left DayPicker to the month of the selected start date
412 // - ensure the right DayPicker is before the left, changing if needed
413 if (!nextValueStartView.isSame(leftView) && !nextValueStartView.isSame(rightView)) {
414 leftView = nextValueStartView;
415 if (!rightView.isAfter(leftView)) {
416 rightView = leftView.getNextMonth();
417 }
418 }
419 }
420 else if (nextValueStartView != null && nextValueEndView != null) {
421 // Both start and end date months are identical
422 // If the selected month isn't in either of the displayed months, then
423 // - set the left DayPicker to be the selected month
424 // - set the right DayPicker to +1
425 if (nextValueStartView.isSame(nextValueEndView)) {
426 if (leftView.isSame(nextValueStartView) || rightView.isSame(nextValueStartView)) {
427 // do nothing
428 }
429 else {
430 leftView = nextValueStartView;
431 rightView = nextValueStartView.getNextMonth();
432 }
433 }
434 else {
435 // Different start and end date months, adjust display months.
436 if (!leftView.isSame(nextValueStartView)) {
437 leftView = nextValueStartView;
438 rightView = nextValueStartView.getNextMonth();
439 }
440 if (contiguousCalendarMonths === false && !rightView.isSame(nextValueEndView)) {
441 rightView = nextValueEndView;
442 }
443 }
444 }
445 return {
446 leftView,
447 rightView,
448 value: nextValue,
449 };
450 }
451 else if (contiguousCalendarMonths === true) {
452 // contiguousCalendarMonths is toggled on.
453 // If the previous leftView and rightView are not contiguous, then set the right DayPicker to left + 1
454 if (!state.leftView.getNextMonth().isSameMonth(state.rightView)) {
455 const nextRightView = state.leftView.getNextMonth();
456 return { rightView: nextRightView };
457 }
458 }
459 return {};
460}
461function getInitialValue(props) {
462 if (props.value != null) {
463 return props.value;
464 }
465 if (props.defaultValue != null) {
466 return props.defaultValue;
467 }
468 return [null, null];
469}
470function getInitialMonth(props, value) {
471 const today = new Date();
472 // != because we must have a real `Date` to begin the calendar on.
473 if (props.initialMonth != null) {
474 return props.initialMonth;
475 }
476 else if (value[0] != null) {
477 return DateUtils.clone(value[0]);
478 }
479 else if (value[1] != null) {
480 const month = DateUtils.clone(value[1]);
481 if (!DateUtils.areSameMonth(month, props.minDate)) {
482 month.setMonth(month.getMonth() - 1);
483 }
484 return month;
485 }
486 else if (DateUtils.isDayInRange(today, [props.minDate, props.maxDate])) {
487 return today;
488 }
489 else {
490 return DateUtils.getDateBetween([props.minDate, props.maxDate]);
491 }
492}
493//# sourceMappingURL=dateRangePicker.js.map
\No newline at end of file