ublo-lib 1.18.1 → 1.18.3
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.js +9 -2
- package/es/common/components/date-picker/date-item.js +4 -1
- package/es/common/components/date-picker/date-picker.js +20 -6
- package/es/common/components/date-picker/month.js +4 -0
- package/es/common/components/date-picker/utils.js +1 -0
- package/package.json +1 -1
|
@@ -20,6 +20,8 @@ function Calendar({
|
|
|
20
20
|
setMode,
|
|
21
21
|
display,
|
|
22
22
|
stayDates = [],
|
|
23
|
+
min,
|
|
24
|
+
max,
|
|
23
25
|
onSubmit,
|
|
24
26
|
specialRule,
|
|
25
27
|
setSpecialRule,
|
|
@@ -27,7 +29,8 @@ function Calendar({
|
|
|
27
29
|
hideModes,
|
|
28
30
|
singleDate,
|
|
29
31
|
submitOnSelectionEnd,
|
|
30
|
-
availabilities
|
|
32
|
+
availabilities,
|
|
33
|
+
disableConfirmModal
|
|
31
34
|
}) {
|
|
32
35
|
const isDateObject = Utils.isDate(date);
|
|
33
36
|
const _date = isDateObject ? date : new Date();
|
|
@@ -66,7 +69,7 @@ function Calendar({
|
|
|
66
69
|
};
|
|
67
70
|
const submit = dates => {
|
|
68
71
|
const hasCart = window.sessionStorage.cartId !== undefined;
|
|
69
|
-
if (hasCart) {
|
|
72
|
+
if (!disableConfirmModal && hasCart) {
|
|
70
73
|
setShowPopup(true);
|
|
71
74
|
} else {
|
|
72
75
|
onSubmit(dates);
|
|
@@ -189,6 +192,8 @@ function Calendar({
|
|
|
189
192
|
display: display,
|
|
190
193
|
month: month,
|
|
191
194
|
year: year,
|
|
195
|
+
min: min,
|
|
196
|
+
max: max,
|
|
192
197
|
selecting: selecting,
|
|
193
198
|
setSelecting: setSelecting,
|
|
194
199
|
selectedDates: selectedDates,
|
|
@@ -207,6 +212,8 @@ function Calendar({
|
|
|
207
212
|
display: display,
|
|
208
213
|
month: monthAlt,
|
|
209
214
|
year: yearAlt,
|
|
215
|
+
min: min,
|
|
216
|
+
max: max,
|
|
210
217
|
selecting: selecting,
|
|
211
218
|
setSelecting: setSelecting,
|
|
212
219
|
selectedDates: selectedDates,
|
|
@@ -10,6 +10,8 @@ const DateItem = ({
|
|
|
10
10
|
index,
|
|
11
11
|
month,
|
|
12
12
|
year,
|
|
13
|
+
min,
|
|
14
|
+
max,
|
|
13
15
|
selectedDates,
|
|
14
16
|
setSelectedDates,
|
|
15
17
|
setFirstSelectedDate,
|
|
@@ -92,13 +94,14 @@ const DateItem = ({
|
|
|
92
94
|
}
|
|
93
95
|
};
|
|
94
96
|
const isSelected = !!selectedDates.find(d => d.getTime() === _date.getTime());
|
|
97
|
+
const isDisabled = Utils.isBefore(date, min) || Utils.isAfter(date, max);
|
|
95
98
|
const classes = classNames(styles.date, {
|
|
96
99
|
[styles.dateToday]: isToday,
|
|
97
100
|
[styles.dateSelected]: isSelected,
|
|
98
101
|
[styles.dateFirstSelected]: isFirstSelected,
|
|
99
102
|
[styles.dateLastSelected]: isLastSelected,
|
|
100
103
|
[styles.dateNotInMonth]: !inMonth,
|
|
101
|
-
[styles.dateIsPast]: isPastDate,
|
|
104
|
+
[styles.dateIsPast]: isPastDate || isDisabled,
|
|
102
105
|
[styles.dateSaturday]: mode === Data.MODES.SATURDAY && Utils.isSaturday(date),
|
|
103
106
|
[styles.dateSunday]: mode === Data.MODES.SUNDAY && Utils.isSunday(date),
|
|
104
107
|
[styles.available]: enableAvailability && isAvailable,
|
|
@@ -17,11 +17,14 @@ const DatePicker = ({
|
|
|
17
17
|
popup = true,
|
|
18
18
|
close,
|
|
19
19
|
hideModes,
|
|
20
|
+
min,
|
|
21
|
+
max,
|
|
20
22
|
defaultMode = Data.MODES[DEFAULT_MODE],
|
|
21
23
|
rules,
|
|
22
24
|
singleDate,
|
|
23
25
|
submitOnSelectionEnd,
|
|
24
|
-
availabilities
|
|
26
|
+
availabilities,
|
|
27
|
+
disableConfirmModal
|
|
25
28
|
}) => {
|
|
26
29
|
const [display, setDisplay] = React.useState(Data.DISPLAYS.DESKTOP);
|
|
27
30
|
const [specialRule, setSpecialRule] = React.useState();
|
|
@@ -30,12 +33,20 @@ const DatePicker = ({
|
|
|
30
33
|
} = useUbloContext();
|
|
31
34
|
const showModes = display !== Data.DISPLAYS.PHONE && !hideModes;
|
|
32
35
|
const getDefaultMode = () => {
|
|
33
|
-
if (!showModes)
|
|
34
|
-
|
|
36
|
+
if (!showModes) {
|
|
37
|
+
return Data.MODES.CUSTOM;
|
|
38
|
+
}
|
|
39
|
+
if (stayDates.length === 0) {
|
|
40
|
+
return defaultMode;
|
|
41
|
+
}
|
|
35
42
|
const firstDate = stayDates[0];
|
|
36
43
|
const lastDate = stayDates[stayDates.length - 1];
|
|
37
|
-
if (Utils.isSaturday(firstDate) && Utils.isSaturday(lastDate))
|
|
38
|
-
|
|
44
|
+
if (Utils.isSaturday(firstDate) && Utils.isSaturday(lastDate)) {
|
|
45
|
+
return Data.MODES.SATURDAY;
|
|
46
|
+
}
|
|
47
|
+
if (Utils.isSunday(firstDate) && Utils.isSunday(lastDate)) {
|
|
48
|
+
return Data.MODES.SUNDAY;
|
|
49
|
+
}
|
|
39
50
|
return Data.MODES.CUSTOM;
|
|
40
51
|
};
|
|
41
52
|
const [currentMode, setCurrentMode] = React.useState(getDefaultMode());
|
|
@@ -84,6 +95,8 @@ const DatePicker = ({
|
|
|
84
95
|
setMode: setCurrentMode,
|
|
85
96
|
display: display,
|
|
86
97
|
stayDates: stayDates,
|
|
98
|
+
min: min,
|
|
99
|
+
max: max,
|
|
87
100
|
onSubmit: onSubmit,
|
|
88
101
|
rules: rules,
|
|
89
102
|
specialRule: specialRule,
|
|
@@ -91,7 +104,8 @@ const DatePicker = ({
|
|
|
91
104
|
hideModes: hideModes,
|
|
92
105
|
singleDate: singleDate,
|
|
93
106
|
submitOnSelectionEnd: submitOnSelectionEnd,
|
|
94
|
-
availabilities: availabilities
|
|
107
|
+
availabilities: availabilities,
|
|
108
|
+
disableConfirmModal: disableConfirmModal
|
|
95
109
|
}), specialRule && _jsxs("div", {
|
|
96
110
|
className: styles.specialRule,
|
|
97
111
|
children: [_jsx(Icons.Info, {}), _jsxs("div", {
|
|
@@ -12,6 +12,8 @@ const Month = ({
|
|
|
12
12
|
display,
|
|
13
13
|
month,
|
|
14
14
|
year,
|
|
15
|
+
min,
|
|
16
|
+
max,
|
|
15
17
|
selecting,
|
|
16
18
|
setSelecting,
|
|
17
19
|
selectedDates,
|
|
@@ -58,6 +60,8 @@ const Month = ({
|
|
|
58
60
|
date: date,
|
|
59
61
|
month: month,
|
|
60
62
|
year: year,
|
|
63
|
+
min: min,
|
|
64
|
+
max: max,
|
|
61
65
|
selectedDates: selectedDates,
|
|
62
66
|
setSelectedDates: setSelectedDates,
|
|
63
67
|
setFirstSelectedDate: setFirstSelectedDate,
|
|
@@ -59,6 +59,7 @@ export const isPast = date => {
|
|
|
59
59
|
return _date < now;
|
|
60
60
|
};
|
|
61
61
|
export const isBefore = (date, ref) => {
|
|
62
|
+
if (!date || !ref) return false;
|
|
62
63
|
const d = Array.isArray(date) ? date.join("-") : date;
|
|
63
64
|
const r = Array.isArray(ref) ? ref.join("-") : ref;
|
|
64
65
|
const _date = new Date(d);
|