ublo-lib 1.44.13 → 1.44.15
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/es/common/components/date-picker/calendar.d.ts.map +1 -1
- package/es/common/components/date-picker/calendar.js +6 -3
- package/es/common/components/date-picker/data.d.ts.map +1 -1
- package/es/common/components/date-picker/data.js +2 -2
- package/es/common/components/date-picker/date-item.js +5 -5
- package/es/common/components/date-picker/utils.d.ts +3 -2
- package/es/common/components/date-picker/utils.d.ts.map +1 -1
- package/es/common/components/date-picker/utils.js +65 -52
- package/es/esf/components/period-picker/weeks.module.css +2 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../../../src/common/components/date-picker/calendar.js"],"names":[],"mappings":"AAaA;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../../../src/common/components/date-picker/calendar.js"],"names":[],"mappings":"AAaA;;;;;;;;;;;;4CAwQC"}
|
|
@@ -12,7 +12,7 @@ import * as Data from "./data";
|
|
|
12
12
|
import * as Utils from "./utils";
|
|
13
13
|
import styles from "./calendar.module.css";
|
|
14
14
|
export default function Calendar({ display, stayDates = [], min, max, onSubmit, availabilities, close, singleDate, submitOnSelectionEnd, disableConfirmModal, defaultSelecting, }) {
|
|
15
|
-
const date = min ?
|
|
15
|
+
const date = min ? Utils.createGMTDate(min) : Utils.createGMTDate();
|
|
16
16
|
const { lang } = useUbloContext();
|
|
17
17
|
const [selectedDates, setSelectedDates] = React.useState(stayDates);
|
|
18
18
|
const firstRangeDate = selectedDates[0];
|
|
@@ -71,7 +71,7 @@ export default function Calendar({ display, stayDates = [], min, max, onSubmit,
|
|
|
71
71
|
setMonthAlt(month + 1);
|
|
72
72
|
}
|
|
73
73
|
}, [month, year]);
|
|
74
|
-
const now =
|
|
74
|
+
const now = Utils.createGMTDate();
|
|
75
75
|
const currentMonth = now.getMonth() + 1;
|
|
76
76
|
const currentYear = now.getFullYear();
|
|
77
77
|
const isPast = month <= currentMonth && year <= currentYear;
|
|
@@ -97,7 +97,10 @@ export default function Calendar({ display, stayDates = [], min, max, onSubmit,
|
|
|
97
97
|
const { stays } = await fetcher({ ...rest, start, numberDays });
|
|
98
98
|
if (stays?.length) {
|
|
99
99
|
const formattedStays = stays.map((stay) => {
|
|
100
|
-
return {
|
|
100
|
+
return {
|
|
101
|
+
start: Utils.createGMTDate(stay.start),
|
|
102
|
+
end: Utils.createGMTDate(stay.end),
|
|
103
|
+
};
|
|
101
104
|
});
|
|
102
105
|
setStays(formattedStays);
|
|
103
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/common/components/date-picker/data.js"],"names":[],"mappings":";;;;;;;;;;;AAaA,+
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/common/components/date-picker/data.js"],"names":[],"mappings":";;;;;;;;;;;AAaA,+BAA6D;AAE7D,gCAA+D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2H/D,6BAA8B,CAAC,CAAC;AAEzB,kEAyCN"}
|
|
@@ -8,8 +8,8 @@ export const BREAKPOINTS = {
|
|
|
8
8
|
TABLET: 745,
|
|
9
9
|
PHONE: 650,
|
|
10
10
|
};
|
|
11
|
-
export const THIS_YEAR =
|
|
12
|
-
export const THIS_MONTH =
|
|
11
|
+
export const THIS_YEAR = Utils.createGMTDate().getFullYear();
|
|
12
|
+
export const THIS_MONTH = Utils.createGMTDate().getMonth() + 1;
|
|
13
13
|
export const MONTHS = {
|
|
14
14
|
fr: {
|
|
15
15
|
january: "Janvier",
|
|
@@ -9,11 +9,11 @@ import * as Messages from "./messages";
|
|
|
9
9
|
import styles from "./date-item.module.css";
|
|
10
10
|
export default function DateItem({ date, index, month, year, min, max, selectedDates, setSelectedDates, setFirstSelectedDate, setLastSelectedDate, selecting, setSelecting, singleDate, submitOnSelectionEnd, onSubmit, stays, matchingStays, allMatchingStaysEnd, }) {
|
|
11
11
|
const { lang } = useUbloContext();
|
|
12
|
-
const today =
|
|
13
|
-
const _date = React.useMemo(() =>
|
|
12
|
+
const today = Utils.createGMTDate();
|
|
13
|
+
const _date = React.useMemo(() => Utils.createGMTDate(date), [date]);
|
|
14
14
|
_date.setHours(0, 0, 0, 0);
|
|
15
15
|
const isToday = Utils.isSameDay(_date, today);
|
|
16
|
-
const monthReference =
|
|
16
|
+
const monthReference = Utils.createGMTDate(`${Utils.zeroPad(year, 2)}-${Utils.zeroPad(month, 2)}-02`);
|
|
17
17
|
const isInMonth = month && year && Utils.isSameMonth(_date, monthReference);
|
|
18
18
|
const isInPastMonth = Utils.isInPastMonth(_date, monthReference);
|
|
19
19
|
const isInNextMonth = Utils.isInNextMonth(_date, monthReference);
|
|
@@ -35,8 +35,8 @@ export default function DateItem({ date, index, month, year, min, max, selectedD
|
|
|
35
35
|
}) || false;
|
|
36
36
|
const shortestMatchingStaysLength = enableAvailability &&
|
|
37
37
|
matchingStays?.reduce((acc, stay) => {
|
|
38
|
-
const fromDate =
|
|
39
|
-
const toDate =
|
|
38
|
+
const fromDate = Utils.createGMTDate(stay.start);
|
|
39
|
+
const toDate = Utils.createGMTDate(stay.end);
|
|
40
40
|
const days = Utils.getDateInterval(fromDate, toDate);
|
|
41
41
|
const nights = days.length - 1;
|
|
42
42
|
if (nights < acc) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export function
|
|
2
|
-
export function getMatchingStays(stays: any, selectedDates: any): any;
|
|
1
|
+
export function createGMTDate(fromDate: any): Date;
|
|
3
2
|
export function zeroPad(value: any, length: any): string;
|
|
4
3
|
export function getMonthDays(month?: number, year?: number): 30 | 29 | 28 | 31;
|
|
5
4
|
export function getMonthFirstDay(month?: number, year?: number): number;
|
|
@@ -13,6 +12,7 @@ export function isInNextMonth(date: any, basedate?: Date): boolean;
|
|
|
13
12
|
export function isPast(date: any): boolean;
|
|
14
13
|
export function isBefore(date: any, ref: any): boolean;
|
|
15
14
|
export function isAfter(date: any, ref: any): boolean;
|
|
15
|
+
export function addDays(_date: any, days: any): Date;
|
|
16
16
|
export function getDateInterval(startDate: any, endDate: any): any[];
|
|
17
17
|
export function getDateISO(date?: Date): string;
|
|
18
18
|
export function getQueryDateInterval(firstDate: any, nights: any): any[];
|
|
@@ -24,4 +24,5 @@ export function getNextMonth(month: any, year: any): {
|
|
|
24
24
|
month: any;
|
|
25
25
|
year: any;
|
|
26
26
|
};
|
|
27
|
+
export function getMatchingStays(stays: any, selectedDates: any): any;
|
|
27
28
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/common/components/date-picker/utils.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/common/components/date-picker/utils.js"],"names":[],"mappings":"AAEA,mDAiBC;AAED,yDAEC;AAED,+EAWC;AAED,wEAOC;AAED,kDAOC;AAED,8CAOC;AAED,2CAKC;AAED,iEAaC;AAED,+DAmBC;AAED,mEAgBC;AAED,mEAgBC;AAED,2CAKC;AAED,uDAKC;AAED,sDAKC;AAED,qDAIC;AAED,qEAQC;AAED,gDAOC;AAED,yEAaC;AAED;;;EAKC;AAED;;;EAKC;AAED,sEAQC"}
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import * as Data from "./data";
|
|
2
|
-
export
|
|
3
|
-
|
|
2
|
+
export function createGMTDate(fromDate) {
|
|
3
|
+
const date = fromDate ? new Date(fromDate) : new Date();
|
|
4
|
+
const day = date.getDate();
|
|
5
|
+
const month = date.getMonth();
|
|
6
|
+
const year = date.getFullYear();
|
|
7
|
+
date.setMinutes(date.getMinutes() + date.getTimezoneOffset());
|
|
8
|
+
date.setHours(0);
|
|
9
|
+
const newDay = date.getDate();
|
|
10
|
+
const newMonth = date.getMonth();
|
|
11
|
+
const newYear = date.getFullYear();
|
|
12
|
+
if (date.getTimezoneOffset() < 0 &&
|
|
13
|
+
(newDay < day || newMonth < month || newYear < year)) {
|
|
14
|
+
date.setDate(date.getDate() + 1);
|
|
15
|
+
}
|
|
16
|
+
return date;
|
|
17
|
+
}
|
|
18
|
+
export function zeroPad(value, length) {
|
|
19
|
+
return `${value}`.padStart(length, "0");
|
|
20
|
+
}
|
|
21
|
+
export function getMonthDays(month = Data.THIS_MONTH, year = Data.THIS_YEAR) {
|
|
4
22
|
const months30 = [4, 6, 9, 11];
|
|
5
23
|
const leapYear = year % 4 === 0;
|
|
6
24
|
return month === 2
|
|
@@ -10,34 +28,34 @@ export const getMonthDays = (month = Data.THIS_MONTH, year = Data.THIS_YEAR) =>
|
|
|
10
28
|
: months30.includes(month)
|
|
11
29
|
? 30
|
|
12
30
|
: 31;
|
|
13
|
-
}
|
|
14
|
-
export
|
|
15
|
-
const date =
|
|
31
|
+
}
|
|
32
|
+
export function getMonthFirstDay(month = Data.THIS_MONTH, year = Data.THIS_YEAR) {
|
|
33
|
+
const date = createGMTDate(`${year}-${zeroPad(month, 2)}-01`);
|
|
16
34
|
date.setHours(0, 0, 0, 0);
|
|
17
35
|
return date.getDay();
|
|
18
|
-
}
|
|
19
|
-
export
|
|
20
|
-
const _date =
|
|
36
|
+
}
|
|
37
|
+
export function weekToLongDate(date) {
|
|
38
|
+
const _date = createGMTDate(date);
|
|
21
39
|
_date.setHours(0, 0, 0, 0);
|
|
22
40
|
const dd = zeroPad(_date.getDate(), 2);
|
|
23
41
|
const mm = zeroPad(_date.getMonth() + 1, 2);
|
|
24
42
|
const yy = _date.getFullYear();
|
|
25
43
|
return `${dd}/${mm}/${yy}`;
|
|
26
|
-
}
|
|
27
|
-
export
|
|
28
|
-
const d =
|
|
44
|
+
}
|
|
45
|
+
export function formatDate(date) {
|
|
46
|
+
const d = createGMTDate(date);
|
|
29
47
|
d.setHours(0, 0, 0, 0);
|
|
30
48
|
const day = zeroPad(d.getDate(), 2);
|
|
31
49
|
const month = zeroPad(d.getMonth() + 1, 2);
|
|
32
50
|
const year = d.getFullYear();
|
|
33
51
|
return `${year}-${month}-${day}`;
|
|
34
|
-
}
|
|
35
|
-
export
|
|
52
|
+
}
|
|
53
|
+
export function isDate(date) {
|
|
36
54
|
const isDate = Object.prototype.toString.call(date) === "[object Date]";
|
|
37
55
|
const isValidDate = date && !Number.isNaN(date.valueOf());
|
|
38
56
|
return isDate && isValidDate;
|
|
39
|
-
}
|
|
40
|
-
export
|
|
57
|
+
}
|
|
58
|
+
export function isSameMonth(date, basedate = createGMTDate()) {
|
|
41
59
|
if (!(isDate(date) && isDate(basedate)))
|
|
42
60
|
return false;
|
|
43
61
|
date.setHours(0, 0, 0, 0);
|
|
@@ -47,8 +65,8 @@ export const isSameMonth = (date, basedate = new Date()) => {
|
|
|
47
65
|
const dateMonth = date.getMonth() + 1;
|
|
48
66
|
const dateYear = date.getFullYear();
|
|
49
67
|
return basedateMonth === dateMonth && basedateYear === dateYear;
|
|
50
|
-
}
|
|
51
|
-
export
|
|
68
|
+
}
|
|
69
|
+
export function isSameDay(date, basedate = createGMTDate()) {
|
|
52
70
|
if (!(isDate(date) && isDate(basedate)))
|
|
53
71
|
return false;
|
|
54
72
|
date.setHours(0, 0, 0, 0);
|
|
@@ -62,8 +80,8 @@ export const isSameDay = (date, basedate = new Date()) => {
|
|
|
62
80
|
return (basedateDate === dateDate &&
|
|
63
81
|
basedateMonth === dateMonth &&
|
|
64
82
|
basedateYear === dateYear);
|
|
65
|
-
}
|
|
66
|
-
export
|
|
83
|
+
}
|
|
84
|
+
export function isInPastMonth(date, basedate = createGMTDate()) {
|
|
67
85
|
if (!(isDate(date) && isDate(basedate)))
|
|
68
86
|
return false;
|
|
69
87
|
date.setHours(0, 0, 0, 0);
|
|
@@ -77,8 +95,8 @@ export const isInPastMonth = (date, basedate = new Date()) => {
|
|
|
77
95
|
if (basedateYear > dateYear)
|
|
78
96
|
return true;
|
|
79
97
|
return basedateMonth > dateMonth;
|
|
80
|
-
}
|
|
81
|
-
export
|
|
98
|
+
}
|
|
99
|
+
export function isInNextMonth(date, basedate = createGMTDate()) {
|
|
82
100
|
if (!(isDate(date) && isDate(basedate)))
|
|
83
101
|
return false;
|
|
84
102
|
date.setHours(0, 0, 0, 0);
|
|
@@ -92,38 +110,33 @@ export const isInNextMonth = (date, basedate = new Date()) => {
|
|
|
92
110
|
if (basedateYear < dateYear)
|
|
93
111
|
return true;
|
|
94
112
|
return basedateMonth < dateMonth;
|
|
95
|
-
}
|
|
96
|
-
export
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
const now = new Date();
|
|
113
|
+
}
|
|
114
|
+
export function isPast(date) {
|
|
115
|
+
const _date = createGMTDate(date);
|
|
116
|
+
const now = createGMTDate();
|
|
100
117
|
now.setHours(0, 0, 0, 0);
|
|
101
118
|
return _date < now;
|
|
102
|
-
}
|
|
103
|
-
export
|
|
119
|
+
}
|
|
120
|
+
export function isBefore(date, ref) {
|
|
104
121
|
if (!date || !ref)
|
|
105
122
|
return false;
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
const _date = new Date(d);
|
|
109
|
-
const _ref = new Date(r);
|
|
123
|
+
const _date = createGMTDate(date);
|
|
124
|
+
const _ref = createGMTDate(ref);
|
|
110
125
|
return _date < _ref;
|
|
111
|
-
}
|
|
112
|
-
export
|
|
126
|
+
}
|
|
127
|
+
export function isAfter(date, ref) {
|
|
113
128
|
if (!date || !ref)
|
|
114
129
|
return false;
|
|
115
|
-
const
|
|
116
|
-
const
|
|
117
|
-
const _date = new Date(d);
|
|
118
|
-
const _ref = new Date(r);
|
|
130
|
+
const _date = createGMTDate(date);
|
|
131
|
+
const _ref = createGMTDate(ref);
|
|
119
132
|
return _date > _ref;
|
|
120
|
-
}
|
|
133
|
+
}
|
|
121
134
|
export function addDays(_date, days) {
|
|
122
|
-
const date =
|
|
135
|
+
const date = createGMTDate(_date);
|
|
123
136
|
date.setDate(date.getDate() + days);
|
|
124
137
|
return date;
|
|
125
138
|
}
|
|
126
|
-
export
|
|
139
|
+
export function getDateInterval(startDate, endDate) {
|
|
127
140
|
const dates = [];
|
|
128
141
|
let currentDate = startDate;
|
|
129
142
|
while (currentDate <= endDate) {
|
|
@@ -131,35 +144,35 @@ export const getDateInterval = (startDate, endDate) => {
|
|
|
131
144
|
currentDate = addDays(currentDate, 1);
|
|
132
145
|
}
|
|
133
146
|
return dates;
|
|
134
|
-
}
|
|
135
|
-
export
|
|
147
|
+
}
|
|
148
|
+
export function getDateISO(date = createGMTDate()) {
|
|
136
149
|
if (!isDate(date))
|
|
137
150
|
return null;
|
|
138
151
|
return `${date.getFullYear()}-${zeroPad(date.getMonth() + 1, 2)}-${zeroPad(date.getDate(), 2)}`;
|
|
139
|
-
}
|
|
140
|
-
export
|
|
152
|
+
}
|
|
153
|
+
export function getQueryDateInterval(firstDate, nights) {
|
|
141
154
|
const splittedDate = [
|
|
142
155
|
firstDate.slice(0, 4),
|
|
143
156
|
firstDate.slice(4, 6),
|
|
144
157
|
firstDate.slice(6, 8),
|
|
145
158
|
];
|
|
146
|
-
const from =
|
|
159
|
+
const from = createGMTDate(splittedDate.join("-"));
|
|
147
160
|
from.setHours(0, 0, 0, 0);
|
|
148
|
-
const to =
|
|
161
|
+
const to = createGMTDate(from);
|
|
149
162
|
to.setDate(to.getDate() + parseInt(nights));
|
|
150
163
|
const interval = getDateInterval(from, to);
|
|
151
164
|
return interval;
|
|
152
|
-
}
|
|
153
|
-
export
|
|
165
|
+
}
|
|
166
|
+
export function getPreviousMonth(month, year) {
|
|
154
167
|
const prevMonth = month > 1 ? month - 1 : 12;
|
|
155
168
|
const prevMonthYear = month > 1 ? year : year - 1;
|
|
156
169
|
return { month: prevMonth, year: prevMonthYear };
|
|
157
|
-
}
|
|
158
|
-
export
|
|
170
|
+
}
|
|
171
|
+
export function getNextMonth(month, year) {
|
|
159
172
|
const nextMonth = month < 12 ? month + 1 : 1;
|
|
160
173
|
const nextMonthYear = month < 12 ? year : year + 1;
|
|
161
174
|
return { month: nextMonth, year: nextMonthYear };
|
|
162
|
-
}
|
|
175
|
+
}
|
|
163
176
|
export function getMatchingStays(stays, selectedDates) {
|
|
164
177
|
if (!stays?.length || !selectedDates.length)
|
|
165
178
|
return;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
padding: 0 26px 10px 26px;
|
|
20
20
|
overflow: auto;
|
|
21
21
|
scroll-behavior: smooth;
|
|
22
|
-
scrollbar-width:
|
|
22
|
+
scrollbar-width: none;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
@media (min-width: 1100px) {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
--item-height: 20px;
|
|
29
29
|
|
|
30
30
|
padding: 0 26px;
|
|
31
|
-
|
|
31
|
+
overflow: visible;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|