ublo-lib 1.40.7 → 1.40.9
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/date-item.d.ts.map +1 -1
- package/es/common/components/date-picker/date-item.js +6 -3
- package/es/common/components/date-picker/date-item.module.css +9 -0
- package/es/common/components/date-picker/date-picker.d.ts.map +1 -1
- package/es/common/components/date-picker/date-picker.js +0 -2
- package/es/common/components/date-picker/month.js +1 -1
- package/es/common/components/date-picker/utils.d.ts +2 -0
- package/es/common/components/date-picker/utils.d.ts.map +1 -1
- package/es/common/components/date-picker/utils.js +30 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-item.d.ts","sourceRoot":"","sources":["../../../../src/common/components/date-picker/date-item.js"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"date-item.d.ts","sourceRoot":"","sources":["../../../../src/common/components/date-picker/date-item.js"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;4CAuLC"}
|
|
@@ -13,9 +13,10 @@ export default function DateItem({ date, index, month, year, min, max, selectedD
|
|
|
13
13
|
const _date = React.useMemo(() => new Date(date), [date]);
|
|
14
14
|
_date.setHours(0, 0, 0, 0);
|
|
15
15
|
const isToday = Utils.isSameDay(_date, today);
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const monthReference = new Date(`${Utils.zeroPad(year, 2)}-${Utils.zeroPad(month, 2)}-02`);
|
|
17
|
+
const isInMonth = month && year && Utils.isSameMonth(_date, monthReference);
|
|
18
|
+
const isInPastMonth = Utils.isInPastMonth(_date, monthReference);
|
|
19
|
+
const isInNextMonth = Utils.isInNextMonth(_date, monthReference);
|
|
19
20
|
const firstSelectedDate = selectedDates[0];
|
|
20
21
|
const isFirstSelected = selectedDates.map(Number).indexOf(Number(_date)) === 0;
|
|
21
22
|
const isLastSelected = selectedDates.map(Number).indexOf(Number(_date)) ===
|
|
@@ -107,6 +108,8 @@ export default function DateItem({ date, index, month, year, min, max, selectedD
|
|
|
107
108
|
[styles.dateFirstSelected]: isFirstSelected,
|
|
108
109
|
[styles.dateLastSelected]: isLastSelected,
|
|
109
110
|
[styles.dateNotInMonth]: !isInMonth,
|
|
111
|
+
[styles.datePastMonth]: isInPastMonth,
|
|
112
|
+
[styles.dateNextMonth]: isInNextMonth,
|
|
110
113
|
[styles.dateIsPast]: !isSelected && isDisabled,
|
|
111
114
|
[styles.available]: enableAvailability && isAvailable,
|
|
112
115
|
[styles.notAvailable]: enableAvailability && !isAvailable && !isSelected,
|
|
@@ -64,6 +64,15 @@
|
|
|
64
64
|
opacity: 0.5;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
@media (min-width: 810px) {
|
|
68
|
+
[data-month]:nth-child(2) .dateNextMonth,
|
|
69
|
+
[data-month]:nth-child(3) .datePastMonth {
|
|
70
|
+
opacity: 0;
|
|
71
|
+
pointer-events: none;
|
|
72
|
+
touch-action: none;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
67
76
|
.date:not(:disabled):hover {
|
|
68
77
|
background-color: var(--ds-grey-200, #efefef);
|
|
69
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../../src/common/components/date-picker/date-picker.js"],"names":[],"mappings":"AAWA;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../../src/common/components/date-picker/date-picker.js"],"names":[],"mappings":"AAWA;;;;;;;;;;;;4CAqDC;sBA3DqB,QAAQ;uBACP,SAAS"}
|
|
@@ -13,11 +13,9 @@ export default function DatePicker({ stayDates = [], onSubmit, close, min, max,
|
|
|
13
13
|
React.useEffect(() => {
|
|
14
14
|
if (windowWidth <= Data.BREAKPOINTS.PHONE) {
|
|
15
15
|
setDisplay(Data.DISPLAYS.PHONE);
|
|
16
|
-
return;
|
|
17
16
|
}
|
|
18
17
|
if (windowWidth <= Data.BREAKPOINTS.TABLET) {
|
|
19
18
|
setDisplay(Data.DISPLAYS.TABLET);
|
|
20
|
-
return;
|
|
21
19
|
}
|
|
22
20
|
else {
|
|
23
21
|
setDisplay(Data.DISPLAYS.DESKTOP);
|
|
@@ -13,7 +13,7 @@ export default function Month({ display, month, year, min, max, selecting, setSe
|
|
|
13
13
|
const calendarMonth = month;
|
|
14
14
|
const calendarYear = year;
|
|
15
15
|
const calendarDates = Data.calendar(calendarMonth, calendarYear);
|
|
16
|
-
return (_jsxs("div", { className: styles.month, children: [_jsxs("div", { className: styles.title, children: [monthName, " ", year] }), _jsx("div", { className: styles.days, children: days.map((day) => {
|
|
16
|
+
return (_jsxs("div", { className: styles.month, "data-month": "", children: [_jsxs("div", { className: styles.title, children: [monthName, " ", year] }), _jsx("div", { className: styles.days, children: days.map((day) => {
|
|
17
17
|
return (_jsx("div", { className: styles.day, children: i18nWeekDays[day] }, day));
|
|
18
18
|
}) }), _jsx("div", { className: styles.dates, children: calendarDates.map((date, i) => {
|
|
19
19
|
return (_jsx(DateItem, { index: i, display: display, date: date, month: month, year: year, min: min, max: max, selectedDates: selectedDates, setSelectedDates: setSelectedDates, setFirstSelectedDate: setFirstSelectedDate, setLastSelectedDate: setLastSelectedDate, selecting: selecting, setSelecting: setSelecting, singleDate: singleDate, submitOnSelectionEnd: submitOnSelectionEnd, onSubmit: onSubmit, stays: stays, matchingStays: matchingStays, allMatchingStaysEnd: allMatchingStaysEnd }, i));
|
|
@@ -8,6 +8,8 @@ export function formatDate(date: any): string;
|
|
|
8
8
|
export function isDate(date: any): boolean;
|
|
9
9
|
export function isSameMonth(date: any, basedate?: Date): boolean;
|
|
10
10
|
export function isSameDay(date: any, basedate?: Date): boolean;
|
|
11
|
+
export function isInPastMonth(date: any, basedate?: Date): boolean;
|
|
12
|
+
export function isInNextMonth(date: any, basedate?: Date): boolean;
|
|
11
13
|
export function isPast(date: any): boolean;
|
|
12
14
|
export function isBefore(date: any, ref: any): boolean;
|
|
13
15
|
export function isAfter(date: any, ref: any): boolean;
|
|
@@ -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":"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"}
|
|
@@ -63,6 +63,36 @@ export const isSameDay = (date, basedate = new Date()) => {
|
|
|
63
63
|
basedateMonth === dateMonth &&
|
|
64
64
|
basedateYear === dateYear);
|
|
65
65
|
};
|
|
66
|
+
export const isInPastMonth = (date, basedate = new Date()) => {
|
|
67
|
+
if (!(isDate(date) && isDate(basedate)))
|
|
68
|
+
return false;
|
|
69
|
+
date.setHours(0, 0, 0, 0);
|
|
70
|
+
basedate.setHours(0, 0, 0, 0);
|
|
71
|
+
const basedateMonth = basedate.getMonth() + 1;
|
|
72
|
+
const basedateYear = basedate.getFullYear();
|
|
73
|
+
const dateMonth = date.getMonth() + 1;
|
|
74
|
+
const dateYear = date.getFullYear();
|
|
75
|
+
if (basedateYear < dateYear)
|
|
76
|
+
return false;
|
|
77
|
+
if (basedateYear > dateYear)
|
|
78
|
+
return true;
|
|
79
|
+
return basedateMonth > dateMonth;
|
|
80
|
+
};
|
|
81
|
+
export const isInNextMonth = (date, basedate = new Date()) => {
|
|
82
|
+
if (!(isDate(date) && isDate(basedate)))
|
|
83
|
+
return false;
|
|
84
|
+
date.setHours(0, 0, 0, 0);
|
|
85
|
+
basedate.setHours(0, 0, 0, 0);
|
|
86
|
+
const basedateMonth = basedate.getMonth() + 1;
|
|
87
|
+
const basedateYear = basedate.getFullYear();
|
|
88
|
+
const dateMonth = date.getMonth() + 1;
|
|
89
|
+
const dateYear = date.getFullYear();
|
|
90
|
+
if (basedateYear > dateYear)
|
|
91
|
+
return false;
|
|
92
|
+
if (basedateYear < dateYear)
|
|
93
|
+
return true;
|
|
94
|
+
return basedateMonth < dateMonth;
|
|
95
|
+
};
|
|
66
96
|
export const isPast = (date) => {
|
|
67
97
|
const d = Array.isArray(date) ? date.join("-") : date;
|
|
68
98
|
const _date = new Date(d);
|