@uxf/datepicker 11.96.0-canary.1 → 11.99.0
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/hooks/use-date-picker-navigation.js +12 -12
- package/hooks/use-date-picker.js +5 -5
- package/hooks/use-date-picker.test.js +1 -1
- package/hooks/use-date-range-picker.js +29 -51
- package/hooks/use-date-range-picker.test.js +2 -2
- package/hooks/use-day.js +11 -13
- package/hooks/use-day.test.js +5 -5
- package/hooks/use-decade.js +5 -5
- package/hooks/use-decade.test.js +23 -23
- package/hooks/use-month.js +4 -4
- package/hooks/use-month.test.js +83 -83
- package/hooks/use-year.js +3 -3
- package/hooks/use-year.test.js +29 -29
- package/package.json +2 -6
- package/utils/can-select-range.js +7 -7
- package/utils/dayjs-utils.d.ts +4 -0
- package/utils/{dayjs-en.js → dayjs-utils.js} +8 -5
- package/utils/get-current-year-month-and-date.js +2 -2
- package/utils/get-current-year-month-and-date.test.js +2 -2
- package/utils/get-date-intervals.test.js +12 -8
- package/utils/get-date-invervals.js +3 -3
- package/utils/get-date-month-and-year.js +4 -4
- package/utils/get-date-month-and-year.test.js +2 -2
- package/utils/get-days.js +9 -9
- package/utils/get-days.test.js +123 -126
- package/utils/get-each.js +7 -29
- package/utils/get-each.test.js +17 -17
- package/utils/get-initial-months.js +2 -2
- package/utils/get-initial-months.test.js +4 -4
- package/utils/get-months.js +4 -4
- package/utils/get-months.test.js +27 -30
- package/utils/get-next-active-month.js +3 -3
- package/utils/get-next-active-month.test.js +14 -14
- package/utils/get-weekday-labels.js +4 -4
- package/utils/get-weekday-labels.test.js +3 -3
- package/utils/get-years.js +2 -2
- package/utils/get-years.test.js +12 -15
- package/utils/is-date-blocked.js +4 -4
- package/utils/is-date-hovered.d.ts +1 -1
- package/utils/is-date-hovered.js +23 -38
- package/utils/is-date-inside-range.js +2 -7
- package/utils/is-end-date.js +2 -2
- package/utils/is-first-or-last-selected-date.js +3 -10
- package/utils/is-in-unavailable-dates.js +2 -4
- package/utils/is-start-date.js +2 -2
- package/utils/dayjs-en.d.ts +0 -4
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const get_next_active_month_1 = require("./get-next-active-month");
|
|
4
4
|
test("getNextActiveMonth", () => {
|
|
5
5
|
expect((0, get_next_active_month_1.getNextActiveMonth)([{ year: 2021, month: 0, date: new Date("2021-01-01") }], 1, 1)).toStrictEqual([
|
|
6
|
-
{ year: 2021, month: 1, date: new Date("2021-02-01T00:00:
|
|
6
|
+
{ year: 2021, month: 1, date: new Date("2021-02-01T00:00:00Z") },
|
|
7
7
|
]);
|
|
8
8
|
expect((0, get_next_active_month_1.getNextActiveMonth)([{ year: 2021, month: 9, date: new Date("2021-10-01") }], 1, 1)).toStrictEqual([
|
|
9
|
-
{ year: 2021, month: 10, date: new Date("2021-11-01T00:00:
|
|
9
|
+
{ year: 2021, month: 10, date: new Date("2021-11-01T00:00:00Z") },
|
|
10
10
|
]);
|
|
11
11
|
});
|
|
12
12
|
test("getNextActiveMonth with 2 months", () => {
|
|
@@ -14,8 +14,8 @@ test("getNextActiveMonth with 2 months", () => {
|
|
|
14
14
|
{ year: 2021, month: 0, date: new Date("2021-01-01") },
|
|
15
15
|
{ year: 2021, month: 1, date: new Date("2021-02-01") },
|
|
16
16
|
], 2, 1)).toStrictEqual([
|
|
17
|
-
{ year: 2021, month: 2, date: new Date("2021-03-01T00:00:
|
|
18
|
-
{ year: 2021, month: 3, date: new Date("2021-04-01T00:00:
|
|
17
|
+
{ year: 2021, month: 2, date: new Date("2021-03-01T00:00:00Z") },
|
|
18
|
+
{ year: 2021, month: 3, date: new Date("2021-04-01T00:00:00Z") },
|
|
19
19
|
]);
|
|
20
20
|
});
|
|
21
21
|
test("getNextActiveMonth with 2 months and step", () => {
|
|
@@ -23,8 +23,8 @@ test("getNextActiveMonth with 2 months and step", () => {
|
|
|
23
23
|
{ year: 2021, month: 0, date: new Date("2021-01-01") },
|
|
24
24
|
{ year: 2021, month: 1, date: new Date("2021-02-01") },
|
|
25
25
|
], 2, 1, 1)).toStrictEqual([
|
|
26
|
-
{ year: 2021, month: 1, date: new Date("2021-02-01T00:00:
|
|
27
|
-
{ year: 2021, month: 2, date: new Date("2021-03-01T00:00:
|
|
26
|
+
{ year: 2021, month: 1, date: new Date("2021-02-01T00:00:00Z") },
|
|
27
|
+
{ year: 2021, month: 2, date: new Date("2021-03-01T00:00:00Z") },
|
|
28
28
|
]);
|
|
29
29
|
});
|
|
30
30
|
test("getNextActiveMonth with 2 months and counter 0", () => {
|
|
@@ -32,8 +32,8 @@ test("getNextActiveMonth with 2 months and counter 0", () => {
|
|
|
32
32
|
{ year: 2021, month: 0, date: new Date("2021-01-01") },
|
|
33
33
|
{ year: 2021, month: 1, date: new Date("2021-02-01") },
|
|
34
34
|
], 2, 0)).toStrictEqual([
|
|
35
|
-
{ year: 2021, month: 1, date: new Date("2021-02-01T00:00:
|
|
36
|
-
{ year: 2021, month: 0, date: new Date("2021-01-01T00:00:
|
|
35
|
+
{ year: 2021, month: 1, date: new Date("2021-02-01T00:00:00Z") },
|
|
36
|
+
{ year: 2021, month: 0, date: new Date("2021-01-01T00:00:00Z") },
|
|
37
37
|
]);
|
|
38
38
|
});
|
|
39
39
|
test("getNextActiveMonth with 2 months and step and counter 0", () => {
|
|
@@ -41,8 +41,8 @@ test("getNextActiveMonth with 2 months and step and counter 0", () => {
|
|
|
41
41
|
{ year: 2021, month: 0, date: new Date("2021-01-01") },
|
|
42
42
|
{ year: 2021, month: 1, date: new Date("2021-02-01") },
|
|
43
43
|
], 2, 0, 1)).toStrictEqual([
|
|
44
|
-
{ year: 2021, month: 2, date: new Date("2021-03-01T00:00:
|
|
45
|
-
{ year: 2021, month: 1, date: new Date("2021-02-01T00:00:
|
|
44
|
+
{ year: 2021, month: 2, date: new Date("2021-03-01T00:00:00Z") },
|
|
45
|
+
{ year: 2021, month: 1, date: new Date("2021-02-01T00:00:00Z") },
|
|
46
46
|
]);
|
|
47
47
|
});
|
|
48
48
|
test("getNextActiveMonth with 2 months and negative counter", () => {
|
|
@@ -50,8 +50,8 @@ test("getNextActiveMonth with 2 months and negative counter", () => {
|
|
|
50
50
|
{ year: 2021, month: 0, date: new Date("2021-01-01") },
|
|
51
51
|
{ year: 2021, month: 1, date: new Date("2021-02-01") },
|
|
52
52
|
], 2, -1)).toStrictEqual([
|
|
53
|
-
{ year: 2020, month: 10, date: new Date("2020-11-01T00:00:
|
|
54
|
-
{ year: 2020, month: 11, date: new Date("2020-12-01T00:00:
|
|
53
|
+
{ year: 2020, month: 10, date: new Date("2020-11-01T00:00:00Z") },
|
|
54
|
+
{ year: 2020, month: 11, date: new Date("2020-12-01T00:00:00Z") },
|
|
55
55
|
]);
|
|
56
56
|
});
|
|
57
57
|
test("getNextActiveMonth with 2 months and step and negative counter", () => {
|
|
@@ -59,7 +59,7 @@ test("getNextActiveMonth with 2 months and step and negative counter", () => {
|
|
|
59
59
|
{ year: 2021, month: 0, date: new Date("2021-01-01") },
|
|
60
60
|
{ year: 2021, month: 1, date: new Date("2021-02-01") },
|
|
61
61
|
], 2, -1, 1)).toStrictEqual([
|
|
62
|
-
{ year: 2020, month: 11, date: new Date("2020-12-01T00:00:
|
|
63
|
-
{ year: 2021, month: 0, date: new Date("2021-01-01T00:00:
|
|
62
|
+
{ year: 2020, month: 11, date: new Date("2020-12-01T00:00:00Z") },
|
|
63
|
+
{ year: 2021, month: 0, date: new Date("2021-01-01T00:00:00Z") },
|
|
64
64
|
]);
|
|
65
65
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getWeekdayLabels = getWeekdayLabels;
|
|
4
|
-
const
|
|
4
|
+
const dayjs_utils_1 = require("./dayjs-utils");
|
|
5
5
|
const get_each_1 = require("./get-each");
|
|
6
|
-
function getWeekdayLabels({ firstDayOfWeek = 0, weekdayLabelFormat = (date) => (0,
|
|
7
|
-
const now =
|
|
8
|
-
const arr = (0, get_each_1.getEach)(
|
|
6
|
+
function getWeekdayLabels({ firstDayOfWeek = 0, weekdayLabelFormat = (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("dd"), }) {
|
|
7
|
+
const now = (0, dayjs_utils_1.dayjsEnWithTz)();
|
|
8
|
+
const arr = (0, get_each_1.getEach)(now.startOf("week").add(firstDayOfWeek, "day").toDate(), now.endOf("week").add(firstDayOfWeek, "day").toDate(), "day");
|
|
9
9
|
return arr.map((date) => weekdayLabelFormat(date));
|
|
10
10
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
require("dayjs/locale/cs");
|
|
4
|
-
const
|
|
4
|
+
const dayjs_utils_1 = require("./dayjs-utils");
|
|
5
5
|
const get_weekday_labels_1 = require("./get-weekday-labels");
|
|
6
6
|
test("getWeekdayLabels", () => {
|
|
7
7
|
expect((0, get_weekday_labels_1.getWeekdayLabels)({})).toStrictEqual(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]);
|
|
@@ -10,7 +10,7 @@ test("getWeekdayLabels with custom firstDayOfWeek", () => {
|
|
|
10
10
|
expect((0, get_weekday_labels_1.getWeekdayLabels)({ firstDayOfWeek: 1 })).toStrictEqual(["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"]);
|
|
11
11
|
});
|
|
12
12
|
test("getWeekdayLabels with custom format", () => {
|
|
13
|
-
expect((0, get_weekday_labels_1.getWeekdayLabels)({ weekdayLabelFormat: (date) => (0,
|
|
13
|
+
expect((0, get_weekday_labels_1.getWeekdayLabels)({ weekdayLabelFormat: (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("dddd") })).toStrictEqual([
|
|
14
14
|
"Sunday",
|
|
15
15
|
"Monday",
|
|
16
16
|
"Tuesday",
|
|
@@ -23,6 +23,6 @@ test("getWeekdayLabels with custom format", () => {
|
|
|
23
23
|
test("getWeekdayLabels with custom format and locale", () => {
|
|
24
24
|
expect((0, get_weekday_labels_1.getWeekdayLabels)({
|
|
25
25
|
firstDayOfWeek: 1,
|
|
26
|
-
weekdayLabelFormat: (date) => (0,
|
|
26
|
+
weekdayLabelFormat: (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).locale("cs").format("dddd"),
|
|
27
27
|
})).toStrictEqual(["pondělí", "úterý", "středa", "čtvrtek", "pátek", "sobota", "neděle"]);
|
|
28
28
|
});
|
package/utils/get-years.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getYears = getYears;
|
|
4
|
-
const
|
|
4
|
+
const dayjs_utils_1 = require("./dayjs-utils");
|
|
5
5
|
const get_each_1 = require("./get-each");
|
|
6
|
-
function getYears({ startYear, endYear, yearLabelFormat = (date) => (0,
|
|
6
|
+
function getYears({ startYear, endYear, yearLabelFormat = (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("YYYY"), }) {
|
|
7
7
|
return (0, get_each_1.getEach)(startYear, endYear, "year").map((d) => ({
|
|
8
8
|
date: d,
|
|
9
9
|
yearLabel: yearLabelFormat(d),
|
package/utils/get-years.test.js
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const dayjs_utils_1 = require("./dayjs-utils");
|
|
4
4
|
const get_years_1 = require("./get-years");
|
|
5
5
|
test("getYears", () => {
|
|
6
|
-
expect((0, get_years_1.getYears)({ startYear: new Date("2018-08-15"), endYear: new Date("2021-05-03") }).
|
|
7
|
-
|
|
8
|
-
date:
|
|
9
|
-
|
|
10
|
-
{ yearLabel: "
|
|
11
|
-
{ yearLabel: "2019", date: new Date("2019-01-01T00:00:00+01:00").toUTCString() },
|
|
12
|
-
{ yearLabel: "2020", date: new Date("2020-01-01T00:00:00+01:00").toUTCString() },
|
|
13
|
-
{ yearLabel: "2021", date: new Date("2021-01-01T00:00:00+01:00").toUTCString() },
|
|
6
|
+
expect((0, get_years_1.getYears)({ startYear: new Date("2018-08-15"), endYear: new Date("2021-05-03") })).toStrictEqual([
|
|
7
|
+
{ yearLabel: "2018", date: new Date("2018-01-01T00:00:00Z") },
|
|
8
|
+
{ yearLabel: "2019", date: new Date("2019-01-01T00:00:00Z") },
|
|
9
|
+
{ yearLabel: "2020", date: new Date("2020-01-01T00:00:00Z") },
|
|
10
|
+
{ yearLabel: "2021", date: new Date("2021-01-01T00:00:00Z") },
|
|
14
11
|
]);
|
|
15
12
|
});
|
|
16
13
|
test("getYears with custom format", () => {
|
|
17
14
|
expect((0, get_years_1.getYears)({
|
|
18
15
|
startYear: new Date("2018-08-15"),
|
|
19
16
|
endYear: new Date("2021-05-03"),
|
|
20
|
-
yearLabelFormat: (date) => (0,
|
|
21
|
-
})
|
|
22
|
-
{ yearLabel: "18", date: new Date("2018-01-01T00:00:
|
|
23
|
-
{ yearLabel: "19", date: new Date("2019-01-01T00:00:
|
|
24
|
-
{ yearLabel: "20", date: new Date("2020-01-01T00:00:
|
|
25
|
-
{ yearLabel: "21", date: new Date("2021-01-01T00:00:
|
|
17
|
+
yearLabelFormat: (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("YY"),
|
|
18
|
+
})).toStrictEqual([
|
|
19
|
+
{ yearLabel: "18", date: new Date("2018-01-01T00:00:00Z") },
|
|
20
|
+
{ yearLabel: "19", date: new Date("2019-01-01T00:00:00Z") },
|
|
21
|
+
{ yearLabel: "20", date: new Date("2020-01-01T00:00:00Z") },
|
|
22
|
+
{ yearLabel: "21", date: new Date("2021-01-01T00:00:00Z") },
|
|
26
23
|
]);
|
|
27
24
|
});
|
package/utils/is-date-blocked.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isDateBlocked = isDateBlocked;
|
|
4
|
-
const
|
|
4
|
+
const dayjs_utils_1 = require("./dayjs-utils");
|
|
5
5
|
const is_in_unavailable_dates_1 = require("./is-in-unavailable-dates");
|
|
6
6
|
function isDateBlocked({ date, minBookingDate, maxBookingDate, isDateBlockedFn, startDate, endDate, minBookingDays = 1, unavailableDates = [], }) {
|
|
7
7
|
const compareMinDate = minBookingDate
|
|
@@ -11,11 +11,11 @@ function isDateBlocked({ date, minBookingDate, maxBookingDate, isDateBlockedFn,
|
|
|
11
11
|
? new Date(maxBookingDate.getFullYear(), maxBookingDate.getMonth(), maxBookingDate.getDate(), 0, 0, 0)
|
|
12
12
|
: maxBookingDate;
|
|
13
13
|
return Boolean((0, is_in_unavailable_dates_1.isInUnavailableDates)(unavailableDates, date) ||
|
|
14
|
-
(compareMinDate && (0,
|
|
15
|
-
(compareMaxDate && (0,
|
|
14
|
+
(compareMinDate && (0, dayjs_utils_1.dayjsEnRaw)(date).isBefore(compareMinDate)) ||
|
|
15
|
+
(compareMaxDate && (0, dayjs_utils_1.dayjsEnRaw)(date).isAfter(compareMaxDate)) ||
|
|
16
16
|
(startDate &&
|
|
17
17
|
!endDate &&
|
|
18
18
|
minBookingDays > 1 &&
|
|
19
|
-
(0,
|
|
19
|
+
(0, dayjs_utils_1.dayjsEnRaw)(date).isBetween(startDate, (0, dayjs_utils_1.dayjsEnRaw)(startDate).add(minBookingDays - 2, "day"))) ||
|
|
20
20
|
(isDateBlockedFn && isDateBlockedFn(date)));
|
|
21
21
|
}
|
|
@@ -2,7 +2,7 @@ export interface IsDateHoveredProps {
|
|
|
2
2
|
startDate: Date | null;
|
|
3
3
|
endDate: Date | null;
|
|
4
4
|
date: Date;
|
|
5
|
-
isDateBlocked
|
|
5
|
+
isDateBlocked(date: Date): boolean;
|
|
6
6
|
hoveredDate: Date | null;
|
|
7
7
|
minBookingDays: number;
|
|
8
8
|
exactMinBookingDays: boolean;
|
package/utils/is-date-hovered.js
CHANGED
|
@@ -1,54 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isDateHovered = isDateHovered;
|
|
4
|
-
const
|
|
5
|
-
const date_fns_1 = require("date-fns");
|
|
6
|
-
const dayjs_en_1 = require("./dayjs-en");
|
|
4
|
+
const dayjs_utils_1 = require("./dayjs-utils");
|
|
7
5
|
const get_each_1 = require("./get-each");
|
|
8
|
-
function isBetween(date, start, end) {
|
|
9
|
-
return (0, date_fns_1.isAfter)(date, start) && (0, date_fns_1.isBefore)(date, end);
|
|
10
|
-
}
|
|
11
|
-
// eslint-disable-next-line complexity
|
|
12
6
|
function isDateHovered({ date, startDate, endDate, isDateBlocked, hoveredDate, minBookingDays, exactMinBookingDays, }) {
|
|
13
|
-
const dateTZ = new tz_1.TZDate(date, dayjs_en_1.DEFAULT_TIMEZONE);
|
|
14
|
-
const hoveredDateTZ = hoveredDate ? new tz_1.TZDate(hoveredDate, dayjs_en_1.DEFAULT_TIMEZONE) : null;
|
|
15
7
|
if (
|
|
16
8
|
// exact min booking days
|
|
17
|
-
|
|
9
|
+
hoveredDate &&
|
|
18
10
|
minBookingDays > 1 &&
|
|
19
11
|
exactMinBookingDays &&
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return true;
|
|
12
|
+
(0, dayjs_utils_1.dayjsEnRaw)(date).isBetween(hoveredDate, (0, dayjs_utils_1.dayjsEnRaw)(hoveredDate).add(minBookingDays - 1, "day"))) {
|
|
13
|
+
return !(0, get_each_1.getEach)(hoveredDate, (0, dayjs_utils_1.dayjsEnRaw)(hoveredDate)
|
|
14
|
+
.add(minBookingDays - 1, "day")
|
|
15
|
+
.toDate(), "day").some((d) => isDateBlocked(d));
|
|
25
16
|
}
|
|
26
|
-
|
|
27
|
-
const endDateTZ = endDate ? new tz_1.TZDate(endDate, dayjs_en_1.DEFAULT_TIMEZONE) : null;
|
|
28
|
-
if (
|
|
17
|
+
else if (
|
|
29
18
|
// min booking days
|
|
30
|
-
|
|
31
|
-
!
|
|
32
|
-
|
|
33
|
-
minBookingDays
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return true;
|
|
19
|
+
startDate &&
|
|
20
|
+
!endDate &&
|
|
21
|
+
hoveredDate &&
|
|
22
|
+
(0, dayjs_utils_1.dayjsEnRaw)(date).isBetween(startDate, (0, dayjs_utils_1.dayjsEnRaw)(startDate).add(minBookingDays - 1, "day")) &&
|
|
23
|
+
(0, dayjs_utils_1.dayjsEnRaw)(startDate).isSame(hoveredDate, "days") &&
|
|
24
|
+
minBookingDays > 1) {
|
|
25
|
+
return !(0, get_each_1.getEach)(startDate, (0, dayjs_utils_1.dayjsEnRaw)(startDate)
|
|
26
|
+
.add(minBookingDays - 1, "day")
|
|
27
|
+
.toDate(), "day").some((d) => isDateBlocked(d));
|
|
40
28
|
}
|
|
41
|
-
if (
|
|
29
|
+
else if (
|
|
42
30
|
// normal
|
|
43
|
-
|
|
44
|
-
!
|
|
45
|
-
|
|
46
|
-
!(0,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return !(0, get_each_1.getEach)(startDateTZ, hoveredDateTZ, "day").some((d) => isDateBlocked(d));
|
|
50
|
-
}
|
|
51
|
-
return true;
|
|
31
|
+
startDate &&
|
|
32
|
+
!endDate &&
|
|
33
|
+
hoveredDate &&
|
|
34
|
+
!(0, dayjs_utils_1.dayjsEnRaw)(hoveredDate).isBefore(startDate) &&
|
|
35
|
+
(0, dayjs_utils_1.dayjsEnRaw)(date).isBetween(startDate, hoveredDate)) {
|
|
36
|
+
return !(0, get_each_1.getEach)(startDate, hoveredDate, "day").some((d) => isDateBlocked(d));
|
|
52
37
|
}
|
|
53
38
|
return false;
|
|
54
39
|
}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isDateInsideRange = isDateInsideRange;
|
|
4
|
-
const
|
|
5
|
-
const date_fns_1 = require("date-fns");
|
|
6
|
-
const dayjs_en_1 = require("./dayjs-en");
|
|
7
|
-
function isBetween(date, start, end) {
|
|
8
|
-
return (0, date_fns_1.isAfter)(date, start) && (0, date_fns_1.isBefore)(date, end);
|
|
9
|
-
}
|
|
4
|
+
const dayjs_utils_1 = require("./dayjs-utils");
|
|
10
5
|
function isDateInsideRange(date, startDate, endDate) {
|
|
11
6
|
if (startDate && endDate) {
|
|
12
|
-
return
|
|
7
|
+
return (0, dayjs_utils_1.dayjsEnRaw)(date).isBetween(startDate, endDate);
|
|
13
8
|
}
|
|
14
9
|
return false;
|
|
15
10
|
}
|
package/utils/is-end-date.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isEndDate = isEndDate;
|
|
4
|
-
const
|
|
4
|
+
const dayjs_utils_1 = require("./dayjs-utils");
|
|
5
5
|
function isEndDate(date, endDate) {
|
|
6
|
-
return Boolean(endDate && (0,
|
|
6
|
+
return Boolean(endDate && (0, dayjs_utils_1.dayjsEnRaw)(date).isSame(endDate, "day"));
|
|
7
7
|
}
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isFirstOrLastSelectedDate = isFirstOrLastSelectedDate;
|
|
4
|
-
const
|
|
5
|
-
const date_fns_1 = require("date-fns");
|
|
6
|
-
const dayjs_en_1 = require("./dayjs-en");
|
|
4
|
+
const dayjs_utils_1 = require("./dayjs-utils");
|
|
7
5
|
function isFirstOrLastSelectedDate(date, startDate, endDate) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
const dateTZ = new tz_1.TZDate(date, dayjs_en_1.DEFAULT_TIMEZONE);
|
|
12
|
-
const startDateTZ = startDate ? new tz_1.TZDate(startDate, dayjs_en_1.DEFAULT_TIMEZONE) : null;
|
|
13
|
-
const endDateTZ = endDate ? new tz_1.TZDate(endDate, dayjs_en_1.DEFAULT_TIMEZONE) : null;
|
|
14
|
-
return Boolean((startDateTZ && (0, date_fns_1.isSameDay)(dateTZ, startDateTZ)) || (endDateTZ && (0, date_fns_1.isSameDay)(dateTZ, endDateTZ)));
|
|
6
|
+
return Boolean((startDate && (0, dayjs_utils_1.dayjsEnRaw)(date).isSame(startDate, "day")) ||
|
|
7
|
+
(endDate && (0, dayjs_utils_1.dayjsEnRaw)(date).isSame(endDate, "day")));
|
|
15
8
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isInUnavailableDates = isInUnavailableDates;
|
|
4
|
-
const
|
|
5
|
-
const date_fns_1 = require("date-fns");
|
|
6
|
-
const dayjs_en_1 = require("./dayjs-en");
|
|
4
|
+
const dayjs_utils_1 = require("./dayjs-utils");
|
|
7
5
|
function isInUnavailableDates(unavailableDates = [], date) {
|
|
8
|
-
return unavailableDates.some((_date) => (0,
|
|
6
|
+
return unavailableDates.some((_date) => (0, dayjs_utils_1.dayjsEnRaw)(date).isSame(_date, "day"));
|
|
9
7
|
}
|
package/utils/is-start-date.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isStartDate = isStartDate;
|
|
4
|
-
const
|
|
4
|
+
const dayjs_utils_1 = require("./dayjs-utils");
|
|
5
5
|
function isStartDate(date, startDate) {
|
|
6
|
-
return Boolean(startDate && (0,
|
|
6
|
+
return Boolean(startDate && (0, dayjs_utils_1.dayjsEnRaw)(date).isSame(startDate, "day"));
|
|
7
7
|
}
|
package/utils/dayjs-en.d.ts
DELETED