ublo-lib 1.44.14 → 1.44.16

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.
@@ -1 +1 @@
1
- {"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../../../src/common/components/date-picker/calendar.js"],"names":[],"mappings":"AAaA;;;;;;;;;;;;4CAqQC"}
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 ? new Date(min) : new Date();
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 = new Date();
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 { start: new Date(stay.start), end: new Date(stay.end) };
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,+BAAkD;AAElD,gCAAoD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2HpD,6BAA8B,CAAC,CAAC;AAEzB,kEAyCN"}
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 = new Date().getFullYear();
12
- export const THIS_MONTH = new Date().getMonth() + 1;
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 = new Date();
13
- const _date = React.useMemo(() => new Date(date), [date]);
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 = new Date(`${Utils.zeroPad(year, 2)}-${Utils.zeroPad(month, 2)}-02`);
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 = new Date(stay.start);
39
- const toDate = new Date(stay.end);
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 addDays(_date: any, days: any): Date;
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":"AAwJA,qDAIC;AAkDD,sEAQC;AApNM,yDAAmE;AAEnE,+EAcN;AAEM,wEAON;AAEM,kDAON;AAEM,8CAON;AAEM,2CAKN;AAEM,iEAaN;AAEM,+DAmBN;AAEM,mEAgBN;AAEM,mEAgBN;AAEM,2CAMN;AAEM,uDAON;AAEM,sDAON;AAQM,qEAQN;AAEM,gDAON;AAEM,yEAaN;AAEM;;;EAKN;AAEM;;;EAKN"}
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 const zeroPad = (value, length) => `${value}`.padStart(length, "0");
3
- export const getMonthDays = (month = Data.THIS_MONTH, year = Data.THIS_YEAR) => {
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 const getMonthFirstDay = (month = Data.THIS_MONTH, year = Data.THIS_YEAR) => {
15
- const date = new Date(`${year}-${zeroPad(month, 2)}-01`);
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 const weekToLongDate = (date) => {
20
- const _date = new Date(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 const formatDate = (date) => {
28
- const d = new Date(date);
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 const isDate = (date) => {
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 const isSameMonth = (date, basedate = new Date()) => {
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 const isSameDay = (date, basedate = new Date()) => {
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 const isInPastMonth = (date, basedate = new Date()) => {
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 const isInNextMonth = (date, basedate = new Date()) => {
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 const isPast = (date) => {
97
- const d = Array.isArray(date) ? date.join("-") : date;
98
- const _date = new Date(d);
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 const isBefore = (date, ref) => {
119
+ }
120
+ export function isBefore(date, ref) {
104
121
  if (!date || !ref)
105
122
  return false;
106
- const d = Array.isArray(date) ? date.join("-") : date;
107
- const r = Array.isArray(ref) ? ref.join("-") : ref;
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 const isAfter = (date, ref) => {
126
+ }
127
+ export function isAfter(date, ref) {
113
128
  if (!date || !ref)
114
129
  return false;
115
- const d = Array.isArray(date) ? date.join("-") : date;
116
- const r = Array.isArray(ref) ? ref.join("-") : ref;
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 = new Date(_date);
135
+ const date = createGMTDate(_date);
123
136
  date.setDate(date.getDate() + days);
124
137
  return date;
125
138
  }
126
- export const getDateInterval = (startDate, endDate) => {
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 const getDateISO = (date = new Date()) => {
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 const getQueryDateInterval = (firstDate, nights) => {
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 = new Date(splittedDate.join("-"));
159
+ const from = createGMTDate(splittedDate.join("-"));
147
160
  from.setHours(0, 0, 0, 0);
148
- const to = new Date(from);
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 const getPreviousMonth = (month, year) => {
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 const getNextMonth = (month, year) => {
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;
@@ -1 +1 @@
1
- {"version":3,"file":"use-injected-cms-markup.d.ts","sourceRoot":"","sources":["../../../src/common/hooks/use-injected-cms-markup.js"],"names":[],"mappings":";AAaA,wEA+BC"}
1
+ {"version":3,"file":"use-injected-cms-markup.d.ts","sourceRoot":"","sources":["../../../src/common/hooks/use-injected-cms-markup.js"],"names":[],"mappings":";AAaA,wEAqCC"}
@@ -12,28 +12,32 @@ const findAllByKey = (obj, keyToFind) => {
12
12
  const useInjectedCmsMarkup = (entries, isReady) => {
13
13
  const { cmsMode } = useUbloContext();
14
14
  const injectCmsMarkup = React.useCallback(async () => {
15
- await window.Cms.register();
16
- const formats = window.Cms.sectionClasses;
17
- entries.forEach((entry) => {
18
- const { key, value } = entry;
19
- const isArray = Array.isArray(value);
20
- const targets = findAllByKey(formats, key);
21
- targets.forEach((target) => {
22
- if (!target?.markup)
23
- return;
24
- if (isArray) {
25
- const formattedRows = value.map((v) => {
26
- return { name: v, markup: `<tr><td>${v}</td></tr>` };
27
- });
28
- const [anchor] = target.markup;
29
- target.markup = anchor ? [anchor, ...formattedRows] : formattedRows;
30
- }
31
- else {
32
- target.markup = value;
33
- }
15
+ window.requestAnimationFrame(() => window.requestAnimationFrame(async () => {
16
+ await window.Cms.register();
17
+ const formats = window.Cms.sectionClasses;
18
+ entries.forEach((entry) => {
19
+ const { key, value } = entry;
20
+ const isArray = Array.isArray(value);
21
+ const targets = findAllByKey(formats, key);
22
+ targets.forEach((target) => {
23
+ if (!target?.markup)
24
+ return;
25
+ if (isArray) {
26
+ const formattedRows = value.map((v) => {
27
+ return { name: v, markup: `<tr><td>${v}</td></tr>` };
28
+ });
29
+ const [anchor] = target.markup;
30
+ target.markup = anchor
31
+ ? [anchor, ...formattedRows]
32
+ : formattedRows;
33
+ }
34
+ else {
35
+ target.markup = value;
36
+ }
37
+ });
34
38
  });
35
- });
36
- await window.Cms.analyse();
39
+ await window.Cms.analyse();
40
+ }));
37
41
  }, [entries]);
38
42
  React.useEffect(() => {
39
43
  if (isReady && cmsMode === "connected") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.44.14",
3
+ "version": "1.44.16",
4
4
  "peerDependencies": {
5
5
  "classnames": "^2.5.1",
6
6
  "dt-design-system": "^3.12.0",