@uxf/datepicker 14.0.0 → 14.1.0
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/hooks/use-date-picker-navigation.js +238 -89
- package/hooks/use-date-picker.js +252 -91
- package/hooks/use-date-range-picker.js +315 -203
- package/hooks/use-day.js +230 -68
- package/hooks/use-decade.js +53 -9
- package/hooks/use-hour.js +102 -33
- package/hooks/use-hours.js +31 -9
- package/hooks/use-minute.js +102 -33
- package/hooks/use-minutes.js +31 -9
- package/hooks/use-month.js +70 -12
- package/hooks/use-time-picker.js +249 -75
- package/hooks/use-year.js +46 -9
- package/package.json +6 -6
|
@@ -1,100 +1,249 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useDatePickerNavigation = useDatePickerNavigation;
|
|
4
|
-
const
|
|
4
|
+
const compiler_runtime_1 = require("react/compiler-runtime");
|
|
5
5
|
const create_date_string_1 = require("../utils/create-date-string");
|
|
6
6
|
const date_string_1 = require("../utils/date-string");
|
|
7
7
|
const get_initial_months_1 = require("../utils/get-initial-months");
|
|
8
8
|
const get_next_active_month_1 = require("../utils/get-next-active-month");
|
|
9
|
-
function useDatePickerNavigation(
|
|
9
|
+
function useDatePickerNavigation(t0) {
|
|
10
10
|
var _a, _b;
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
11
|
+
const $ = (0, compiler_runtime_1.c)(62);
|
|
12
|
+
const { activeMonths, setActiveMonths, setFocusedDate, minBookingDate, maxBookingDate, numberOfMonths } = t0;
|
|
13
|
+
let t1;
|
|
14
|
+
if ($[0] !== activeMonths || $[1] !== numberOfMonths || $[2] !== setActiveMonths || $[3] !== setFocusedDate) {
|
|
15
|
+
t1 = () => {
|
|
16
|
+
const newActiveMonths = (0, get_next_active_month_1.getNextActiveMonth)(activeMonths, numberOfMonths, -1);
|
|
17
|
+
setActiveMonths(newActiveMonths);
|
|
18
|
+
setFocusedDate(null);
|
|
19
|
+
return newActiveMonths;
|
|
20
|
+
};
|
|
21
|
+
$[0] = activeMonths;
|
|
22
|
+
$[1] = numberOfMonths;
|
|
23
|
+
$[2] = setActiveMonths;
|
|
24
|
+
$[3] = setFocusedDate;
|
|
25
|
+
$[4] = t1;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
t1 = $[4];
|
|
29
|
+
}
|
|
30
|
+
const goToPrevMonths = t1;
|
|
31
|
+
let t2;
|
|
32
|
+
if ($[5] !== activeMonths || $[6] !== numberOfMonths || $[7] !== setActiveMonths || $[8] !== setFocusedDate) {
|
|
33
|
+
t2 = () => {
|
|
34
|
+
const newActiveMonths_0 = (0, get_next_active_month_1.getNextActiveMonth)(activeMonths, numberOfMonths, -1, 1);
|
|
35
|
+
setActiveMonths(newActiveMonths_0);
|
|
36
|
+
setFocusedDate(null);
|
|
37
|
+
return newActiveMonths_0;
|
|
38
|
+
};
|
|
39
|
+
$[5] = activeMonths;
|
|
40
|
+
$[6] = numberOfMonths;
|
|
41
|
+
$[7] = setActiveMonths;
|
|
42
|
+
$[8] = setFocusedDate;
|
|
43
|
+
$[9] = t2;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
t2 = $[9];
|
|
47
|
+
}
|
|
48
|
+
const goToPrevMonthsByOneMonth = t2;
|
|
49
|
+
let t3;
|
|
50
|
+
if ($[10] !== activeMonths || $[11] !== numberOfMonths || $[12] !== setActiveMonths || $[13] !== setFocusedDate) {
|
|
51
|
+
t3 = () => {
|
|
52
|
+
const newActiveMonths_1 = (0, get_next_active_month_1.getNextActiveMonth)(activeMonths, numberOfMonths, 1);
|
|
53
|
+
setActiveMonths(newActiveMonths_1);
|
|
54
|
+
setFocusedDate(null);
|
|
55
|
+
return newActiveMonths_1;
|
|
56
|
+
};
|
|
57
|
+
$[10] = activeMonths;
|
|
58
|
+
$[11] = numberOfMonths;
|
|
59
|
+
$[12] = setActiveMonths;
|
|
60
|
+
$[13] = setFocusedDate;
|
|
61
|
+
$[14] = t3;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
t3 = $[14];
|
|
65
|
+
}
|
|
66
|
+
const goToNextMonths = t3;
|
|
67
|
+
let t4;
|
|
68
|
+
if ($[15] !== activeMonths || $[16] !== numberOfMonths || $[17] !== setActiveMonths || $[18] !== setFocusedDate) {
|
|
69
|
+
t4 = () => {
|
|
70
|
+
const newActiveMonths_2 = (0, get_next_active_month_1.getNextActiveMonth)(activeMonths, numberOfMonths, 1, 1);
|
|
71
|
+
setActiveMonths(newActiveMonths_2);
|
|
72
|
+
setFocusedDate(null);
|
|
73
|
+
return newActiveMonths_2;
|
|
74
|
+
};
|
|
75
|
+
$[15] = activeMonths;
|
|
76
|
+
$[16] = numberOfMonths;
|
|
77
|
+
$[17] = setActiveMonths;
|
|
78
|
+
$[18] = setFocusedDate;
|
|
79
|
+
$[19] = t4;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
t4 = $[19];
|
|
83
|
+
}
|
|
84
|
+
const goToNextMonthsByOneMonth = t4;
|
|
85
|
+
let t5;
|
|
86
|
+
if ($[20] !== numberOfMonths || $[21] !== setActiveMonths || $[22] !== setFocusedDate) {
|
|
87
|
+
t5 = date => {
|
|
88
|
+
const newActiveMonths_3 = (0, get_initial_months_1.getInitialMonths)(numberOfMonths, date);
|
|
89
|
+
setActiveMonths(newActiveMonths_3);
|
|
90
|
+
setFocusedDate(null);
|
|
91
|
+
return newActiveMonths_3;
|
|
92
|
+
};
|
|
93
|
+
$[20] = numberOfMonths;
|
|
94
|
+
$[21] = setActiveMonths;
|
|
95
|
+
$[22] = setFocusedDate;
|
|
96
|
+
$[23] = t5;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
t5 = $[23];
|
|
100
|
+
}
|
|
101
|
+
const goToDate = t5;
|
|
102
|
+
let t6;
|
|
103
|
+
if ($[24] !== activeMonths || $[25] !== numberOfMonths || $[26] !== setActiveMonths || $[27] !== setFocusedDate) {
|
|
104
|
+
t6 = t7 => {
|
|
105
|
+
const numYears = t7 === undefined ? 1 : t7;
|
|
106
|
+
const newActiveMonths_4 = (0, get_next_active_month_1.getNextActiveMonth)(activeMonths, numberOfMonths, -(numYears * 12 - numberOfMonths + 1));
|
|
107
|
+
setActiveMonths(newActiveMonths_4);
|
|
108
|
+
setFocusedDate(null);
|
|
109
|
+
return newActiveMonths_4;
|
|
110
|
+
};
|
|
111
|
+
$[24] = activeMonths;
|
|
112
|
+
$[25] = numberOfMonths;
|
|
113
|
+
$[26] = setActiveMonths;
|
|
114
|
+
$[27] = setFocusedDate;
|
|
115
|
+
$[28] = t6;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
t6 = $[28];
|
|
119
|
+
}
|
|
120
|
+
const goToPrevYear = t6;
|
|
121
|
+
let t7;
|
|
122
|
+
if ($[29] !== activeMonths || $[30] !== numberOfMonths || $[31] !== setActiveMonths || $[32] !== setFocusedDate) {
|
|
123
|
+
t7 = t8 => {
|
|
124
|
+
const numYears_0 = t8 === undefined ? 1 : t8;
|
|
125
|
+
const newActiveMonths_5 = (0, get_next_active_month_1.getNextActiveMonth)(activeMonths, numberOfMonths, numYears_0 * 12 - numberOfMonths + 1);
|
|
126
|
+
setActiveMonths(newActiveMonths_5);
|
|
127
|
+
setFocusedDate(null);
|
|
128
|
+
return newActiveMonths_5;
|
|
129
|
+
};
|
|
130
|
+
$[29] = activeMonths;
|
|
131
|
+
$[30] = numberOfMonths;
|
|
132
|
+
$[31] = setActiveMonths;
|
|
133
|
+
$[32] = setFocusedDate;
|
|
134
|
+
$[33] = t7;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
t7 = $[33];
|
|
138
|
+
}
|
|
139
|
+
const goToNextYear = t7;
|
|
140
|
+
let canGoToPrevMonth;
|
|
141
|
+
let firstYear;
|
|
142
|
+
let lastYear;
|
|
143
|
+
let t8;
|
|
144
|
+
if ($[34] !== activeMonths || $[35] !== maxBookingDate || $[36] !== minBookingDate) {
|
|
145
|
+
const firstMonthStr = (0, date_string_1.toDateString)((_b = (_a = activeMonths.at(0)) === null || _a === void 0 ? void 0 : _a.date) !== null && _b !== void 0 ? _b : new Date());
|
|
146
|
+
const lastMonthStr = (0, date_string_1.toDateString)(activeMonths[activeMonths.length - 1].date);
|
|
147
|
+
firstYear = parseInt(firstMonthStr.slice(0, 4), 10);
|
|
148
|
+
lastYear = parseInt(lastMonthStr.slice(0, 4), 10);
|
|
149
|
+
canGoToPrevMonth = !minBookingDate || minBookingDate <= firstMonthStr;
|
|
150
|
+
t8 = !maxBookingDate || (0, date_string_1.addMonths)(lastMonthStr, 1) <= maxBookingDate;
|
|
151
|
+
$[34] = activeMonths;
|
|
152
|
+
$[35] = maxBookingDate;
|
|
153
|
+
$[36] = minBookingDate;
|
|
154
|
+
$[37] = canGoToPrevMonth;
|
|
155
|
+
$[38] = firstYear;
|
|
156
|
+
$[39] = lastYear;
|
|
157
|
+
$[40] = t8;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
canGoToPrevMonth = $[37];
|
|
161
|
+
firstYear = $[38];
|
|
162
|
+
lastYear = $[39];
|
|
163
|
+
t8 = $[40];
|
|
164
|
+
}
|
|
165
|
+
const canGoToNextMonth = t8;
|
|
62
166
|
const canGoToPrevYear = !minBookingDate || (0, create_date_string_1.createDateString)(firstYear - 1, 11, 31) >= minBookingDate;
|
|
63
|
-
// Can navigate forward a year if Jan 1 of (lastYear + 1) is still within maxBookingDate.
|
|
64
167
|
const canGoToNextYear = !maxBookingDate || (0, create_date_string_1.createDateString)(lastYear + 1, 0) <= maxBookingDate;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
168
|
+
let t9;
|
|
169
|
+
if ($[41] !== maxBookingDate || $[42] !== minBookingDate) {
|
|
170
|
+
t9 = (month, type) => {
|
|
171
|
+
if (!minBookingDate && !maxBookingDate) {
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
const ds = (0, date_string_1.toDateString)(month);
|
|
175
|
+
const year = parseInt(ds.slice(0, 4), 10);
|
|
176
|
+
if (type === "month") {
|
|
177
|
+
const afterMin = !minBookingDate || (0, date_string_1.addMonths)(ds, 1) > minBookingDate;
|
|
178
|
+
const beforeMax = !maxBookingDate || (0, date_string_1.addDays)(ds, -1) < maxBookingDate;
|
|
179
|
+
return afterMin && beforeMax;
|
|
180
|
+
}
|
|
181
|
+
const afterMin_0 = !minBookingDate || (0, create_date_string_1.createDateString)(year + 1, 0) > minBookingDate;
|
|
182
|
+
const beforeMax_0 = !maxBookingDate || (0, create_date_string_1.createDateString)(year - 1, 11, 31) < maxBookingDate;
|
|
183
|
+
return afterMin_0 && beforeMax_0;
|
|
184
|
+
};
|
|
185
|
+
$[41] = maxBookingDate;
|
|
186
|
+
$[42] = minBookingDate;
|
|
187
|
+
$[43] = t9;
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
t9 = $[43];
|
|
191
|
+
}
|
|
192
|
+
const canGoTo = t9;
|
|
193
|
+
let t10;
|
|
194
|
+
if ($[44] !== canGoTo) {
|
|
195
|
+
t10 = date_0 => canGoTo(date_0, "month");
|
|
196
|
+
$[44] = canGoTo;
|
|
197
|
+
$[45] = t10;
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
t10 = $[45];
|
|
201
|
+
}
|
|
202
|
+
const canGoToMonth = t10;
|
|
203
|
+
let t11;
|
|
204
|
+
if ($[46] !== canGoTo) {
|
|
205
|
+
t11 = date_1 => canGoTo(date_1, "year");
|
|
206
|
+
$[46] = canGoTo;
|
|
207
|
+
$[47] = t11;
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
t11 = $[47];
|
|
211
|
+
}
|
|
212
|
+
const canGoToYear = t11;
|
|
213
|
+
let t12;
|
|
214
|
+
if ($[48] !== canGoToMonth || $[49] !== canGoToNextMonth || $[50] !== canGoToNextYear || $[51] !== canGoToPrevMonth || $[52] !== canGoToPrevYear || $[53] !== canGoToYear || $[54] !== goToDate || $[55] !== goToNextMonths || $[56] !== goToNextMonthsByOneMonth || $[57] !== goToNextYear || $[58] !== goToPrevMonths || $[59] !== goToPrevMonthsByOneMonth || $[60] !== goToPrevYear) {
|
|
215
|
+
t12 = {
|
|
216
|
+
canGoToMonth,
|
|
217
|
+
canGoToNextMonth,
|
|
218
|
+
canGoToNextYear,
|
|
219
|
+
canGoToPrevMonth,
|
|
220
|
+
canGoToPrevYear,
|
|
221
|
+
canGoToYear,
|
|
222
|
+
goToDate,
|
|
223
|
+
goToNextMonths,
|
|
224
|
+
goToNextMonthsByOneMonth,
|
|
225
|
+
goToNextYear,
|
|
226
|
+
goToPrevMonths,
|
|
227
|
+
goToPrevMonthsByOneMonth,
|
|
228
|
+
goToPrevYear
|
|
229
|
+
};
|
|
230
|
+
$[48] = canGoToMonth;
|
|
231
|
+
$[49] = canGoToNextMonth;
|
|
232
|
+
$[50] = canGoToNextYear;
|
|
233
|
+
$[51] = canGoToPrevMonth;
|
|
234
|
+
$[52] = canGoToPrevYear;
|
|
235
|
+
$[53] = canGoToYear;
|
|
236
|
+
$[54] = goToDate;
|
|
237
|
+
$[55] = goToNextMonths;
|
|
238
|
+
$[56] = goToNextMonthsByOneMonth;
|
|
239
|
+
$[57] = goToNextYear;
|
|
240
|
+
$[58] = goToPrevMonths;
|
|
241
|
+
$[59] = goToPrevMonthsByOneMonth;
|
|
242
|
+
$[60] = goToPrevYear;
|
|
243
|
+
$[61] = t12;
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
t12 = $[61];
|
|
247
|
+
}
|
|
248
|
+
return t12;
|
|
100
249
|
}
|