1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | require('./_commonjsHelpers-72d386ba.js');
|
6 | var defineProperty$1 = require('./defineProperty-0921a47c.js');
|
7 | var dayjs_min = require('./dayjs.min-aa59a48e.js');
|
8 |
|
9 | function handleDateSelect(_ref) {
|
10 | var date = _ref.date,
|
11 | startDate = _ref.startDate,
|
12 | endDate = _ref.endDate;
|
13 |
|
14 |
|
15 | if (startDate && dayjs_min.dayjs(date).isSame(startDate, 'day')) {
|
16 | return {
|
17 | startDate: null
|
18 | };
|
19 | }
|
20 |
|
21 |
|
22 | if (endDate && dayjs_min.dayjs(date).isSame(endDate, 'day')) {
|
23 | return {
|
24 | endDate: null
|
25 | };
|
26 | }
|
27 |
|
28 | var isValidStartDate = !endDate || !dayjs_min.dayjs(date).isAfter(endDate);
|
29 | var isValidEndDate = !startDate || !dayjs_min.dayjs(date).isBefore(startDate);
|
30 |
|
31 | var isValidDate = startDate ? isValidEndDate : isValidStartDate;
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 | if (startDate && endDate && isValidStartDate && dayjs_min.dayjs(date).isBefore(startDate, 'day')) {
|
39 | return {
|
40 | startDate: date
|
41 | };
|
42 | }
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | if (!startDate && endDate && dayjs_min.dayjs(date).isAfter(endDate)) {
|
48 | return {
|
49 | startDate: endDate,
|
50 | endDate: date
|
51 | };
|
52 | }
|
53 |
|
54 | if (!endDate && startDate && dayjs_min.dayjs(date).isBefore(startDate)) {
|
55 | return {
|
56 | startDate: date,
|
57 | endDate: startDate
|
58 | };
|
59 | }
|
60 |
|
61 | if (isValidDate) {
|
62 | return defineProperty$1._defineProperty({}, startDate ? 'endDate' : 'startDate', date);
|
63 | }
|
64 | }
|
65 |
|
66 | exports.handleDateSelect = handleDateSelect;
|
67 |
|