ublo-lib 1.18.2 → 1.18.4
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 +6 -0
- package/es/common/components/date-picker/date-item.js +4 -1
- package/es/common/components/date-picker/date-picker.js +4 -0
- package/es/common/components/date-picker/month.js +4 -0
- package/es/common/components/date-picker/utils.js +9 -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,
|
|
@@ -190,6 +192,8 @@ function Calendar({
|
|
|
190
192
|
display: display,
|
|
191
193
|
month: month,
|
|
192
194
|
year: year,
|
|
195
|
+
min: min,
|
|
196
|
+
max: max,
|
|
193
197
|
selecting: selecting,
|
|
194
198
|
setSelecting: setSelecting,
|
|
195
199
|
selectedDates: selectedDates,
|
|
@@ -208,6 +212,8 @@ function Calendar({
|
|
|
208
212
|
display: display,
|
|
209
213
|
month: monthAlt,
|
|
210
214
|
year: yearAlt,
|
|
215
|
+
min: min,
|
|
216
|
+
max: max,
|
|
211
217
|
selecting: selecting,
|
|
212
218
|
setSelecting: setSelecting,
|
|
213
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,6 +17,8 @@ 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,
|
|
@@ -93,6 +95,8 @@ const DatePicker = ({
|
|
|
93
95
|
setMode: setCurrentMode,
|
|
94
96
|
display: display,
|
|
95
97
|
stayDates: stayDates,
|
|
98
|
+
min: min,
|
|
99
|
+
max: max,
|
|
96
100
|
onSubmit: onSubmit,
|
|
97
101
|
rules: rules,
|
|
98
102
|
specialRule: specialRule,
|
|
@@ -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,12 +59,21 @@ 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);
|
|
65
66
|
const _ref = new Date(r);
|
|
66
67
|
return _date < _ref;
|
|
67
68
|
};
|
|
69
|
+
export const isAfter = (date, ref) => {
|
|
70
|
+
if (!date || !ref) return false;
|
|
71
|
+
const d = Array.isArray(date) ? date.join("-") : date;
|
|
72
|
+
const r = Array.isArray(ref) ? ref.join("-") : ref;
|
|
73
|
+
const _date = new Date(d);
|
|
74
|
+
const _ref = new Date(r);
|
|
75
|
+
return _date > _ref;
|
|
76
|
+
};
|
|
68
77
|
export function addDays(_date, days) {
|
|
69
78
|
const date = new Date(_date);
|
|
70
79
|
date.setDate(date.getDate() + days);
|