react-day-picker 8.4.0 → 8.5.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/dist/index.d.ts +123 -70
- package/dist/index.esm.js +14 -50
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +122 -158
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -0
- package/dist/index.min.js.map +1 -0
- package/dist/style.css +2 -1
- package/dist/style.css.d.ts +38 -37
- package/dist/style.css.map +1 -0
- package/dist/style.module.css +0 -1
- package/dist/style.module.css.d.ts +38 -37
- package/package.json +35 -32
- package/src/DayPicker.tsx +1 -1
- package/src/components/Caption/Caption.test.tsx +2 -2
- package/src/components/CaptionDropdowns/CaptionDropdowns.test.tsx +7 -6
- package/src/components/CaptionLabel/CaptionLabel.test.tsx +1 -1
- package/src/components/CaptionLabel/CaptionLabel.tsx +3 -3
- package/src/components/CaptionNavigation/CaptionNavigation.test.tsx +11 -10
- package/src/components/CaptionNavigation/CaptionNavigation.tsx +1 -1
- package/src/components/Day/Day.test.tsx +15 -16
- package/src/components/Day/Day.tsx +1 -1
- package/src/components/DayContent/DayContent.test.tsx +1 -1
- package/src/components/Footer/Footer.test.tsx +1 -1
- package/src/components/HeadRow/HeadRow.test.tsx +1 -20
- package/src/components/HeadRow/HeadRow.tsx +2 -6
- package/src/components/HeadRow/utils/getWeekdays.test.ts +1 -1
- package/src/components/HeadRow/utils/getWeekdays.ts +1 -5
- package/src/components/Month/Month.test.tsx +1 -1
- package/src/components/MonthsDropdown/MonthsDropdown.test.tsx +3 -2
- package/src/components/MonthsDropdown/MonthsDropdown.tsx +1 -3
- package/src/components/Navigation/Navigation.test.tsx +10 -9
- package/src/components/Root/Root.test.tsx +2 -3
- package/src/components/Row/Row.tsx +2 -1
- package/src/components/Table/Table.tsx +1 -1
- package/src/components/Table/__snapshots__/Table.test.tsx.snap +219 -210
- package/src/components/Table/utils/daysToMonthWeeks.ts +11 -10
- package/src/components/Table/utils/getMonthWeeks.ts +7 -6
- package/src/components/YearsDropdown/YearsDropdown.test.tsx +3 -2
- package/src/components/YearsDropdown/YearsDropdown.tsx +1 -3
- package/src/contexts/DayPicker/DayPickerContext.test.ts +55 -138
- package/src/contexts/DayPicker/defaultContextValues.ts +1 -1
- package/src/contexts/DayPicker/formatters/formatCaption.test.ts +1 -1
- package/src/contexts/DayPicker/formatters/formatCaption.ts +1 -2
- package/src/contexts/DayPicker/formatters/formatDay.ts +1 -1
- package/src/contexts/DayPicker/formatters/formatMonthCaption.test.ts +1 -1
- package/src/contexts/DayPicker/formatters/formatMonthCaption.ts +1 -1
- package/src/contexts/DayPicker/formatters/formatWeekdayName.test.ts +3 -3
- package/src/contexts/DayPicker/formatters/formatWeekdayName.ts +2 -2
- package/src/contexts/DayPicker/formatters/formatYearCaption.ts +1 -1
- package/src/contexts/DayPicker/labels/labelDay.ts +1 -1
- package/src/contexts/DayPicker/labels/labelWeekday.test.ts +1 -1
- package/src/contexts/DayPicker/labels/labelWeekday.ts +1 -1
- package/src/contexts/DayPicker/utils/parseFromToProps.ts +1 -3
- package/src/contexts/Focus/FocusContext.test.ts +35 -62
- package/src/contexts/Focus/FocusContext.tsx +1 -1
- package/src/contexts/Focus/utils/getInitialFocusTarget.ts +1 -3
- package/src/contexts/Focus/utils/getNextFocus.ts +12 -10
- package/src/contexts/Modifiers/ModifiersContext.test.ts +8 -14
- package/src/contexts/Modifiers/utils/getActiveModifiers.ts +1 -1
- package/src/contexts/Modifiers/utils/isDateInRange.ts +1 -2
- package/src/contexts/Modifiers/utils/isMatch.ts +1 -4
- package/src/contexts/Navigation/NavigationContext.test.ts +12 -17
- package/src/contexts/Navigation/NavigationContext.tsx +1 -3
- package/src/contexts/Navigation/useNavigationState.test.ts +9 -16
- package/src/contexts/Navigation/useNavigationState.ts +6 -4
- package/src/contexts/Navigation/utils/getDisplayMonths.ts +1 -3
- package/src/contexts/Navigation/utils/getInitialMonth.ts +1 -3
- package/src/contexts/Navigation/utils/getNextMonth.ts +1 -3
- package/src/contexts/Navigation/utils/getPreviousMonth.ts +1 -3
- package/src/contexts/SelectMultiple/SelectMultipleContext.test.ts +15 -20
- package/src/contexts/SelectMultiple/SelectMultipleContext.tsx +1 -1
- package/src/contexts/SelectRange/SelectRangeContext.test.ts +23 -29
- package/src/contexts/SelectRange/SelectRangeContext.tsx +6 -4
- package/src/contexts/SelectRange/utils/addToRange.ts +1 -3
- package/src/contexts/SelectSingle/SelectSingleContext.test.ts +18 -15
- package/src/hooks/useActiveModifiers/useActiveModifiers.test.tsx +9 -16
- package/src/hooks/useControlledValue/useControlledValue.test.ts +16 -39
- package/src/hooks/useDayEventHandlers/useDayEventHandlers.test.tsx +18 -78
- package/src/hooks/useDayRender/useDayRender.test.tsx +68 -95
- package/src/hooks/useDayRender/useDayRender.tsx +5 -8
- package/src/hooks/useInput/useInput.ts +2 -4
- package/src/hooks/useSelectedDays/useSelectedDays.test.ts +15 -45
- package/src/index.ts +1 -0
- package/src/style.css +0 -1
- package/src/style.css.d.ts +37 -36
- package/src/types/Labels.ts +1 -0
- package/dist/index.esm.d.ts +0 -1175
- package/dist/react-day-picker.min.js +0 -1
package/dist/index.js
CHANGED
|
@@ -1,39 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var
|
|
5
|
-
var format = require('date-fns/format');
|
|
6
|
-
var endOfMonth = require('date-fns/endOfMonth');
|
|
7
|
-
var startOfDay = require('date-fns/startOfDay');
|
|
8
|
-
var startOfMonth = require('date-fns/startOfMonth');
|
|
9
|
-
var isSameYear = require('date-fns/isSameYear');
|
|
10
|
-
var setMonth = require('date-fns/setMonth');
|
|
11
|
-
var setYear = require('date-fns/setYear');
|
|
12
|
-
var startOfYear = require('date-fns/startOfYear');
|
|
13
|
-
var addMonths = require('date-fns/addMonths');
|
|
14
|
-
var isBefore = require('date-fns/isBefore');
|
|
15
|
-
var isSameMonth = require('date-fns/isSameMonth');
|
|
16
|
-
var differenceInCalendarMonths = require('date-fns/differenceInCalendarMonths');
|
|
17
|
-
var addDays = require('date-fns/addDays');
|
|
18
|
-
var startOfISOWeek = require('date-fns/startOfISOWeek');
|
|
19
|
-
var startOfWeek = require('date-fns/startOfWeek');
|
|
20
|
-
var getUnixTime = require('date-fns/getUnixTime');
|
|
21
|
-
var isSameDay = require('date-fns/isSameDay');
|
|
4
|
+
var locale = require('date-fns/locale');
|
|
22
5
|
var dateFns = require('date-fns');
|
|
23
|
-
var differenceInCalendarDays = require('date-fns/differenceInCalendarDays');
|
|
24
|
-
var subDays = require('date-fns/subDays');
|
|
25
|
-
var isAfter = require('date-fns/isAfter');
|
|
26
|
-
var isDate = require('date-fns/isDate');
|
|
27
|
-
var addWeeks = require('date-fns/addWeeks');
|
|
28
|
-
var addYears = require('date-fns/addYears');
|
|
29
|
-
var endOfISOWeek = require('date-fns/endOfISOWeek');
|
|
30
|
-
var endOfWeek = require('date-fns/endOfWeek');
|
|
31
|
-
var max = require('date-fns/max');
|
|
32
|
-
var min = require('date-fns/min');
|
|
33
|
-
var getWeeksInMonth = require('date-fns/getWeeksInMonth');
|
|
34
|
-
var getISOWeek = require('date-fns/getISOWeek');
|
|
35
|
-
var getWeek = require('date-fns/getWeek');
|
|
36
|
-
var parse = require('date-fns/parse');
|
|
37
6
|
|
|
38
7
|
function _interopNamespaceDefault(e) {
|
|
39
8
|
var n = Object.create(null);
|
|
@@ -168,21 +137,21 @@ var defaultClassNames = {
|
|
|
168
137
|
* The default formatter for the caption.
|
|
169
138
|
*/
|
|
170
139
|
function formatCaption(month, options) {
|
|
171
|
-
return format(month, 'LLLL y', options);
|
|
140
|
+
return dateFns.format(month, 'LLLL y', options);
|
|
172
141
|
}
|
|
173
142
|
|
|
174
143
|
/**
|
|
175
144
|
* The default formatter for the Day button.
|
|
176
145
|
*/
|
|
177
146
|
function formatDay(day, options) {
|
|
178
|
-
return format(day, 'd', options);
|
|
147
|
+
return dateFns.format(day, 'd', options);
|
|
179
148
|
}
|
|
180
149
|
|
|
181
150
|
/**
|
|
182
151
|
* The default formatter for the Month caption.
|
|
183
152
|
*/
|
|
184
153
|
function formatMonthCaption(month, options) {
|
|
185
|
-
return format(month, 'LLLL', options);
|
|
154
|
+
return dateFns.format(month, 'LLLL', options);
|
|
186
155
|
}
|
|
187
156
|
|
|
188
157
|
/**
|
|
@@ -196,14 +165,14 @@ function formatWeekNumber(weekNumber) {
|
|
|
196
165
|
* The default formatter for the name of the weekday.
|
|
197
166
|
*/
|
|
198
167
|
function formatWeekdayName(weekday, options) {
|
|
199
|
-
return format(weekday, 'cccccc', options);
|
|
168
|
+
return dateFns.format(weekday, 'cccccc', options).toUpperCase();
|
|
200
169
|
}
|
|
201
170
|
|
|
202
171
|
/**
|
|
203
172
|
* The default formatter for the Year caption.
|
|
204
173
|
*/
|
|
205
174
|
function formatYearCaption(year, options) {
|
|
206
|
-
return format(year, 'yyyy', options);
|
|
175
|
+
return dateFns.format(year, 'yyyy', options);
|
|
207
176
|
}
|
|
208
177
|
|
|
209
178
|
var formatters = /*#__PURE__*/Object.freeze({
|
|
@@ -220,7 +189,7 @@ var formatters = /*#__PURE__*/Object.freeze({
|
|
|
220
189
|
* The default ARIA label for the day button.
|
|
221
190
|
*/
|
|
222
191
|
var labelDay = function (day, activeModifiers, options) {
|
|
223
|
-
return format(day, 'do MMMM (EEEE)', options);
|
|
192
|
+
return dateFns.format(day, 'do MMMM (EEEE)', options);
|
|
224
193
|
};
|
|
225
194
|
|
|
226
195
|
/**
|
|
@@ -248,7 +217,7 @@ var labelPrevious = function () {
|
|
|
248
217
|
* The default ARIA label for the Weekday element.
|
|
249
218
|
*/
|
|
250
219
|
var labelWeekday = function (day, options) {
|
|
251
|
-
return format(day, 'cccc', options);
|
|
220
|
+
return dateFns.format(day, 'cccc', options);
|
|
252
221
|
};
|
|
253
222
|
|
|
254
223
|
/**
|
|
@@ -271,8 +240,8 @@ var labels = /*#__PURE__*/Object.freeze({
|
|
|
271
240
|
labelMonthDropdown: labelMonthDropdown,
|
|
272
241
|
labelNext: labelNext,
|
|
273
242
|
labelPrevious: labelPrevious,
|
|
274
|
-
labelWeekday: labelWeekday,
|
|
275
243
|
labelWeekNumber: labelWeekNumber,
|
|
244
|
+
labelWeekday: labelWeekday,
|
|
276
245
|
labelYearDropdown: labelYearDropdown
|
|
277
246
|
});
|
|
278
247
|
|
|
@@ -283,7 +252,7 @@ var labels = /*#__PURE__*/Object.freeze({
|
|
|
283
252
|
function getDefaultContextValues() {
|
|
284
253
|
var captionLayout = 'buttons';
|
|
285
254
|
var classNames = defaultClassNames;
|
|
286
|
-
var locale = enUS;
|
|
255
|
+
var locale$1 = locale.enUS;
|
|
287
256
|
var modifiersClassNames = {};
|
|
288
257
|
var modifiers = {};
|
|
289
258
|
var numberOfMonths = 1;
|
|
@@ -294,7 +263,7 @@ function getDefaultContextValues() {
|
|
|
294
263
|
classNames: classNames,
|
|
295
264
|
formatters: formatters,
|
|
296
265
|
labels: labels,
|
|
297
|
-
locale: locale,
|
|
266
|
+
locale: locale$1,
|
|
298
267
|
modifiersClassNames: modifiersClassNames,
|
|
299
268
|
modifiers: modifiers,
|
|
300
269
|
numberOfMonths: numberOfMonths,
|
|
@@ -309,20 +278,20 @@ function parseFromToProps(props) {
|
|
|
309
278
|
var fromYear = props.fromYear, toYear = props.toYear, fromMonth = props.fromMonth, toMonth = props.toMonth;
|
|
310
279
|
var fromDate = props.fromDate, toDate = props.toDate;
|
|
311
280
|
if (fromMonth) {
|
|
312
|
-
fromDate = startOfMonth(fromMonth);
|
|
281
|
+
fromDate = dateFns.startOfMonth(fromMonth);
|
|
313
282
|
}
|
|
314
283
|
else if (fromYear) {
|
|
315
284
|
fromDate = new Date(fromYear, 0, 1);
|
|
316
285
|
}
|
|
317
286
|
if (toMonth) {
|
|
318
|
-
toDate = endOfMonth(toMonth);
|
|
287
|
+
toDate = dateFns.endOfMonth(toMonth);
|
|
319
288
|
}
|
|
320
289
|
else if (toYear) {
|
|
321
290
|
toDate = new Date(toYear, 11, 31);
|
|
322
291
|
}
|
|
323
292
|
return {
|
|
324
|
-
fromDate: fromDate ? startOfDay(fromDate) : undefined,
|
|
325
|
-
toDate: toDate ? startOfDay(toDate) : undefined
|
|
293
|
+
fromDate: fromDate ? dateFns.startOfDay(fromDate) : undefined,
|
|
294
|
+
toDate: toDate ? dateFns.startOfDay(toDate) : undefined
|
|
326
295
|
};
|
|
327
296
|
}
|
|
328
297
|
|
|
@@ -374,7 +343,7 @@ function useDayPicker() {
|
|
|
374
343
|
/** Render the caption for the displayed month. This component is used when `captionLayout="buttons"`. */
|
|
375
344
|
function CaptionLabel(props) {
|
|
376
345
|
var _a = useDayPicker(), locale = _a.locale, classNames = _a.classNames, styles = _a.styles, formatCaption = _a.formatters.formatCaption;
|
|
377
|
-
return (React.createElement("
|
|
346
|
+
return (React.createElement("div", { className: classNames.caption_label, style: styles.caption_label, "aria-live": "polite", role: "presentation", id: props.id }, formatCaption(props.displayMonth, { locale: locale })));
|
|
378
347
|
}
|
|
379
348
|
|
|
380
349
|
/**
|
|
@@ -412,23 +381,23 @@ function MonthsDropdown(props) {
|
|
|
412
381
|
if (!toDate)
|
|
413
382
|
return React.createElement(React.Fragment, null);
|
|
414
383
|
var dropdownMonths = [];
|
|
415
|
-
if (isSameYear(fromDate, toDate)) {
|
|
384
|
+
if (dateFns.isSameYear(fromDate, toDate)) {
|
|
416
385
|
// only display the months included in the range
|
|
417
|
-
var date = startOfMonth(fromDate);
|
|
386
|
+
var date = dateFns.startOfMonth(fromDate);
|
|
418
387
|
for (var month = fromDate.getMonth(); month <= toDate.getMonth(); month++) {
|
|
419
|
-
dropdownMonths.push(setMonth(date, month));
|
|
388
|
+
dropdownMonths.push(dateFns.setMonth(date, month));
|
|
420
389
|
}
|
|
421
390
|
}
|
|
422
391
|
else {
|
|
423
392
|
// display all the 12 months
|
|
424
|
-
var date = startOfMonth(new Date()); // Any date should be OK, as we just need the year
|
|
393
|
+
var date = dateFns.startOfMonth(new Date()); // Any date should be OK, as we just need the year
|
|
425
394
|
for (var month = 0; month <= 11; month++) {
|
|
426
|
-
dropdownMonths.push(setMonth(date, month));
|
|
395
|
+
dropdownMonths.push(dateFns.setMonth(date, month));
|
|
427
396
|
}
|
|
428
397
|
}
|
|
429
398
|
var handleChange = function (e) {
|
|
430
399
|
var selectedMonth = Number(e.target.value);
|
|
431
|
-
var newMonth = setMonth(startOfMonth(props.displayMonth), selectedMonth);
|
|
400
|
+
var newMonth = dateFns.setMonth(dateFns.startOfMonth(props.displayMonth), selectedMonth);
|
|
432
401
|
props.onChange(newMonth);
|
|
433
402
|
};
|
|
434
403
|
var DropdownComponent = (_a = components === null || components === void 0 ? void 0 : components.Dropdown) !== null && _a !== void 0 ? _a : Dropdown;
|
|
@@ -452,10 +421,10 @@ function YearsDropdown(props) {
|
|
|
452
421
|
var fromYear = fromDate.getFullYear();
|
|
453
422
|
var toYear = toDate.getFullYear();
|
|
454
423
|
for (var year = fromYear; year <= toYear; year++) {
|
|
455
|
-
years.push(setYear(startOfYear(new Date()), year));
|
|
424
|
+
years.push(dateFns.setYear(dateFns.startOfYear(new Date()), year));
|
|
456
425
|
}
|
|
457
426
|
var handleChange = function (e) {
|
|
458
|
-
var newMonth = setYear(startOfMonth(displayMonth), Number(e.target.value));
|
|
427
|
+
var newMonth = dateFns.setYear(dateFns.startOfMonth(displayMonth), Number(e.target.value));
|
|
459
428
|
props.onChange(newMonth);
|
|
460
429
|
};
|
|
461
430
|
var DropdownComponent = (_a = components === null || components === void 0 ? void 0 : components.Dropdown) !== null && _a !== void 0 ? _a : Dropdown;
|
|
@@ -483,15 +452,15 @@ function getInitialMonth(context) {
|
|
|
483
452
|
var initialMonth = month || defaultMonth || today || new Date();
|
|
484
453
|
var toDate = context.toDate, fromDate = context.fromDate, _a = context.numberOfMonths, numberOfMonths = _a === void 0 ? 1 : _a;
|
|
485
454
|
// Fix the initialMonth if is after the to-date
|
|
486
|
-
if (toDate && differenceInCalendarMonths(toDate, initialMonth) < 0) {
|
|
455
|
+
if (toDate && dateFns.differenceInCalendarMonths(toDate, initialMonth) < 0) {
|
|
487
456
|
var offset = -1 * (numberOfMonths - 1);
|
|
488
|
-
initialMonth = addMonths(toDate, offset);
|
|
457
|
+
initialMonth = dateFns.addMonths(toDate, offset);
|
|
489
458
|
}
|
|
490
459
|
// Fix the initialMonth if is before the from-date
|
|
491
|
-
if (fromDate && differenceInCalendarMonths(initialMonth, fromDate) < 0) {
|
|
460
|
+
if (fromDate && dateFns.differenceInCalendarMonths(initialMonth, fromDate) < 0) {
|
|
492
461
|
initialMonth = fromDate;
|
|
493
462
|
}
|
|
494
|
-
return startOfMonth(initialMonth);
|
|
463
|
+
return dateFns.startOfMonth(initialMonth);
|
|
495
464
|
}
|
|
496
465
|
|
|
497
466
|
/** Controls the navigation state. */
|
|
@@ -503,7 +472,7 @@ function useNavigationState() {
|
|
|
503
472
|
var _a;
|
|
504
473
|
if (context.disableNavigation)
|
|
505
474
|
return;
|
|
506
|
-
var month = startOfMonth(date);
|
|
475
|
+
var month = dateFns.startOfMonth(date);
|
|
507
476
|
setMonth(month);
|
|
508
477
|
(_a = context.onMonthChange) === null || _a === void 0 ? void 0 : _a.call(context, month);
|
|
509
478
|
};
|
|
@@ -516,12 +485,12 @@ function useNavigationState() {
|
|
|
516
485
|
*/
|
|
517
486
|
function getDisplayMonths(month, _a) {
|
|
518
487
|
var reverseMonths = _a.reverseMonths, numberOfMonths = _a.numberOfMonths;
|
|
519
|
-
var start = startOfMonth(month);
|
|
520
|
-
var end = startOfMonth(addMonths(start, numberOfMonths));
|
|
521
|
-
var monthsDiff = differenceInCalendarMonths(end, start);
|
|
488
|
+
var start = dateFns.startOfMonth(month);
|
|
489
|
+
var end = dateFns.startOfMonth(dateFns.addMonths(start, numberOfMonths));
|
|
490
|
+
var monthsDiff = dateFns.differenceInCalendarMonths(end, start);
|
|
522
491
|
var months = [];
|
|
523
492
|
for (var i = 0; i < monthsDiff; i++) {
|
|
524
|
-
var nextMonth = addMonths(start, i);
|
|
493
|
+
var nextMonth = dateFns.addMonths(start, i);
|
|
525
494
|
months.push(nextMonth);
|
|
526
495
|
}
|
|
527
496
|
if (reverseMonths)
|
|
@@ -545,16 +514,16 @@ function getNextMonth(startingMonth, options) {
|
|
|
545
514
|
}
|
|
546
515
|
var toDate = options.toDate, pagedNavigation = options.pagedNavigation, _a = options.numberOfMonths, numberOfMonths = _a === void 0 ? 1 : _a;
|
|
547
516
|
var offset = pagedNavigation ? numberOfMonths : 1;
|
|
548
|
-
var month = startOfMonth(startingMonth);
|
|
517
|
+
var month = dateFns.startOfMonth(startingMonth);
|
|
549
518
|
if (!toDate) {
|
|
550
|
-
return addMonths(month, offset);
|
|
519
|
+
return dateFns.addMonths(month, offset);
|
|
551
520
|
}
|
|
552
|
-
var monthsDiff = differenceInCalendarMonths(toDate, startingMonth);
|
|
521
|
+
var monthsDiff = dateFns.differenceInCalendarMonths(toDate, startingMonth);
|
|
553
522
|
if (monthsDiff < numberOfMonths) {
|
|
554
523
|
return undefined;
|
|
555
524
|
}
|
|
556
525
|
// Jump forward as the number of months when paged navigation
|
|
557
|
-
return addMonths(month, offset);
|
|
526
|
+
return dateFns.addMonths(month, offset);
|
|
558
527
|
}
|
|
559
528
|
|
|
560
529
|
/**
|
|
@@ -574,16 +543,16 @@ function getPreviousMonth(startingMonth, options) {
|
|
|
574
543
|
}
|
|
575
544
|
var fromDate = options.fromDate, pagedNavigation = options.pagedNavigation, _a = options.numberOfMonths, numberOfMonths = _a === void 0 ? 1 : _a;
|
|
576
545
|
var offset = pagedNavigation ? numberOfMonths : 1;
|
|
577
|
-
var month = startOfMonth(startingMonth);
|
|
546
|
+
var month = dateFns.startOfMonth(startingMonth);
|
|
578
547
|
if (!fromDate) {
|
|
579
|
-
return addMonths(month, -offset);
|
|
548
|
+
return dateFns.addMonths(month, -offset);
|
|
580
549
|
}
|
|
581
|
-
var monthsDiff = differenceInCalendarMonths(month, fromDate);
|
|
550
|
+
var monthsDiff = dateFns.differenceInCalendarMonths(month, fromDate);
|
|
582
551
|
if (monthsDiff <= 0) {
|
|
583
552
|
return undefined;
|
|
584
553
|
}
|
|
585
554
|
// Jump back as the number of months when paged navigation
|
|
586
|
-
return addMonths(month, -offset);
|
|
555
|
+
return dateFns.addMonths(month, -offset);
|
|
587
556
|
}
|
|
588
557
|
|
|
589
558
|
/**
|
|
@@ -600,15 +569,15 @@ function NavigationProvider(props) {
|
|
|
600
569
|
var previousMonth = getPreviousMonth(currentMonth, dayPicker);
|
|
601
570
|
var isDateDisplayed = function (date) {
|
|
602
571
|
return displayMonths.some(function (displayMonth) {
|
|
603
|
-
return isSameMonth(date, displayMonth);
|
|
572
|
+
return dateFns.isSameMonth(date, displayMonth);
|
|
604
573
|
});
|
|
605
574
|
};
|
|
606
575
|
var goToDate = function (date, refDate) {
|
|
607
576
|
if (isDateDisplayed(date)) {
|
|
608
577
|
return;
|
|
609
578
|
}
|
|
610
|
-
if (refDate && isBefore(date, refDate)) {
|
|
611
|
-
goToMonth(addMonths(date, 1 + dayPicker.numberOfMonths * -1));
|
|
579
|
+
if (refDate && dateFns.isBefore(date, refDate)) {
|
|
580
|
+
goToMonth(dateFns.addMonths(date, 1 + dayPicker.numberOfMonths * -1));
|
|
612
581
|
}
|
|
613
582
|
else {
|
|
614
583
|
goToMonth(date);
|
|
@@ -723,7 +692,7 @@ function CaptionNavigation(props) {
|
|
|
723
692
|
var _c = useDayPicker(), numberOfMonths = _c.numberOfMonths, dir = _c.dir, components = _c.components;
|
|
724
693
|
var _d = useNavigation(), previousMonth = _d.previousMonth, nextMonth = _d.nextMonth, goToMonth = _d.goToMonth, displayMonths = _d.displayMonths;
|
|
725
694
|
var displayIndex = displayMonths.findIndex(function (month) {
|
|
726
|
-
return isSameMonth(props.displayMonth, month);
|
|
695
|
+
return dateFns.isSameMonth(props.displayMonth, month);
|
|
727
696
|
});
|
|
728
697
|
var isFirst = displayIndex === 0;
|
|
729
698
|
var isLast = displayIndex === displayMonths.length - 1;
|
|
@@ -790,11 +759,11 @@ weekStartsOn,
|
|
|
790
759
|
/** Use ISOWeek instead of locale/ */
|
|
791
760
|
ISOWeek) {
|
|
792
761
|
var start = ISOWeek
|
|
793
|
-
? startOfISOWeek(new Date())
|
|
794
|
-
: startOfWeek(new Date(), { locale: locale, weekStartsOn: weekStartsOn });
|
|
762
|
+
? dateFns.startOfISOWeek(new Date())
|
|
763
|
+
: dateFns.startOfWeek(new Date(), { locale: locale, weekStartsOn: weekStartsOn });
|
|
795
764
|
var days = [];
|
|
796
765
|
for (var i = 0; i < 7; i++) {
|
|
797
|
-
var day = addDays(start, i);
|
|
766
|
+
var day = dateFns.addDays(start, i);
|
|
798
767
|
days.push(day);
|
|
799
768
|
}
|
|
800
769
|
return days;
|
|
@@ -808,9 +777,7 @@ function HeadRow() {
|
|
|
808
777
|
var weekdays = getWeekdays(locale, weekStartsOn, ISOWeek);
|
|
809
778
|
return (React.createElement("tr", { style: styles.head_row, className: classNames.head_row },
|
|
810
779
|
showWeekNumber && (React.createElement("th", { scope: "col", style: styles.head_cell, className: classNames.head_cell })),
|
|
811
|
-
weekdays.map(function (weekday, i) { return (React.createElement("th", { key: i, scope: "col", className: classNames.head_cell, style: styles.head_cell },
|
|
812
|
-
React.createElement("span", { "aria-hidden": true }, formatWeekdayName(weekday, { locale: locale })),
|
|
813
|
-
React.createElement("span", { className: classNames.vhidden }, labelWeekday(weekday, { locale: locale })))); })));
|
|
780
|
+
weekdays.map(function (weekday, i) { return (React.createElement("th", { key: i, scope: "col", className: classNames.head_cell, style: styles.head_cell, "aria-label": labelWeekday(weekday, { locale: locale }) }, formatWeekdayName(weekday, { locale: locale }))); })));
|
|
814
781
|
}
|
|
815
782
|
|
|
816
783
|
/** Render the table head. */
|
|
@@ -865,7 +832,7 @@ function SelectMultipleProviderInternal(_a) {
|
|
|
865
832
|
var selectedDays = selected ? __spreadArray([], selected, true) : [];
|
|
866
833
|
if (activeModifiers.selected) {
|
|
867
834
|
var index = selectedDays.findIndex(function (selectedDay) {
|
|
868
|
-
return isSameDay(day, selectedDay);
|
|
835
|
+
return dateFns.isSameDay(day, selectedDay);
|
|
869
836
|
});
|
|
870
837
|
selectedDays.splice(index, 1);
|
|
871
838
|
}
|
|
@@ -881,7 +848,7 @@ function SelectMultipleProviderInternal(_a) {
|
|
|
881
848
|
modifiers.disabled.push(function (day) {
|
|
882
849
|
var isMaxSelected = max && selected.length > max - 1;
|
|
883
850
|
var isSelected = selected.some(function (selectedDay) {
|
|
884
|
-
return isSameDay(selectedDay, day);
|
|
851
|
+
return dateFns.isSameDay(selectedDay, day);
|
|
885
852
|
});
|
|
886
853
|
return Boolean(isMaxSelected && !isSelected);
|
|
887
854
|
});
|
|
@@ -917,25 +884,25 @@ function addToRange(day, range) {
|
|
|
917
884
|
if (!from) {
|
|
918
885
|
return { from: day, to: undefined };
|
|
919
886
|
}
|
|
920
|
-
if (!to && isSameDay(from, day)) {
|
|
887
|
+
if (!to && dateFns.isSameDay(from, day)) {
|
|
921
888
|
return { from: from, to: day };
|
|
922
889
|
}
|
|
923
|
-
if (!to && isBefore(day, from)) {
|
|
890
|
+
if (!to && dateFns.isBefore(day, from)) {
|
|
924
891
|
return { from: day, to: from };
|
|
925
892
|
}
|
|
926
893
|
if (!to) {
|
|
927
894
|
return { from: from, to: day };
|
|
928
895
|
}
|
|
929
|
-
if (isSameDay(to, day) && isSameDay(from, day)) {
|
|
896
|
+
if (dateFns.isSameDay(to, day) && dateFns.isSameDay(from, day)) {
|
|
930
897
|
return undefined;
|
|
931
898
|
}
|
|
932
|
-
if (isSameDay(to, day)) {
|
|
899
|
+
if (dateFns.isSameDay(to, day)) {
|
|
933
900
|
return { from: to, to: undefined };
|
|
934
901
|
}
|
|
935
|
-
if (isSameDay(from, day)) {
|
|
902
|
+
if (dateFns.isSameDay(from, day)) {
|
|
936
903
|
return undefined;
|
|
937
904
|
}
|
|
938
|
-
if (isAfter(from, day)) {
|
|
905
|
+
if (dateFns.isAfter(from, day)) {
|
|
939
906
|
return { from: day, to: to };
|
|
940
907
|
}
|
|
941
908
|
return { from: from, to: day };
|
|
@@ -1002,34 +969,34 @@ function SelectRangeProviderInternal(_a) {
|
|
|
1002
969
|
if (min) {
|
|
1003
970
|
if (selectedFrom && !selectedTo) {
|
|
1004
971
|
modifiers.disabled.push({
|
|
1005
|
-
after: subDays(selectedFrom, min - 1),
|
|
1006
|
-
before: addDays(selectedFrom, min - 1)
|
|
972
|
+
after: dateFns.subDays(selectedFrom, min - 1),
|
|
973
|
+
before: dateFns.addDays(selectedFrom, min - 1)
|
|
1007
974
|
});
|
|
1008
975
|
}
|
|
1009
976
|
if (selectedFrom && selectedTo) {
|
|
1010
977
|
modifiers.disabled.push({
|
|
1011
978
|
after: selectedFrom,
|
|
1012
|
-
before: addDays(selectedFrom, min - 1)
|
|
979
|
+
before: dateFns.addDays(selectedFrom, min - 1)
|
|
1013
980
|
});
|
|
1014
981
|
}
|
|
1015
982
|
}
|
|
1016
983
|
if (max) {
|
|
1017
984
|
if (selectedFrom && !selectedTo) {
|
|
1018
985
|
modifiers.disabled.push({
|
|
1019
|
-
before: addDays(selectedFrom, -max + 1)
|
|
986
|
+
before: dateFns.addDays(selectedFrom, -max + 1)
|
|
1020
987
|
});
|
|
1021
988
|
modifiers.disabled.push({
|
|
1022
|
-
after: addDays(selectedFrom, max - 1)
|
|
989
|
+
after: dateFns.addDays(selectedFrom, max - 1)
|
|
1023
990
|
});
|
|
1024
991
|
}
|
|
1025
992
|
if (selectedFrom && selectedTo) {
|
|
1026
|
-
var selectedCount = differenceInCalendarDays(selectedTo, selectedFrom) + 1;
|
|
993
|
+
var selectedCount = dateFns.differenceInCalendarDays(selectedTo, selectedFrom) + 1;
|
|
1027
994
|
var offset = max - selectedCount;
|
|
1028
995
|
modifiers.disabled.push({
|
|
1029
|
-
before: subDays(selectedFrom, offset)
|
|
996
|
+
before: dateFns.subDays(selectedFrom, offset)
|
|
1030
997
|
});
|
|
1031
998
|
modifiers.disabled.push({
|
|
1032
|
-
after: addDays(selectedTo, offset)
|
|
999
|
+
after: dateFns.addDays(selectedTo, offset)
|
|
1033
1000
|
});
|
|
1034
1001
|
}
|
|
1035
1002
|
}
|
|
@@ -1181,28 +1148,28 @@ function isDateInRange(date, range) {
|
|
|
1181
1148
|
if (!from) {
|
|
1182
1149
|
return false;
|
|
1183
1150
|
}
|
|
1184
|
-
if (!to && isSameDay(from, date)) {
|
|
1151
|
+
if (!to && dateFns.isSameDay(from, date)) {
|
|
1185
1152
|
return true;
|
|
1186
1153
|
}
|
|
1187
1154
|
if (!to) {
|
|
1188
1155
|
return false;
|
|
1189
1156
|
}
|
|
1190
|
-
var isRangeInverted = differenceInCalendarDays(to, from) < 0;
|
|
1157
|
+
var isRangeInverted = dateFns.differenceInCalendarDays(to, from) < 0;
|
|
1191
1158
|
if (isRangeInverted) {
|
|
1192
1159
|
_a = [to, from], from = _a[0], to = _a[1];
|
|
1193
1160
|
}
|
|
1194
|
-
var isInRange = differenceInCalendarDays(date, from) >= 0 &&
|
|
1195
|
-
differenceInCalendarDays(to, date) >= 0;
|
|
1161
|
+
var isInRange = dateFns.differenceInCalendarDays(date, from) >= 0 &&
|
|
1162
|
+
dateFns.differenceInCalendarDays(to, date) >= 0;
|
|
1196
1163
|
return isInRange;
|
|
1197
1164
|
}
|
|
1198
1165
|
|
|
1199
1166
|
/** Returns true if `value` is a Date type. */
|
|
1200
1167
|
function isDateType(value) {
|
|
1201
|
-
return isDate(value);
|
|
1168
|
+
return dateFns.isDate(value);
|
|
1202
1169
|
}
|
|
1203
1170
|
/** Returns true if `value` is an array of valid dates. */
|
|
1204
1171
|
function isArrayOfDates(value) {
|
|
1205
|
-
return Array.isArray(value) && value.every(isDate);
|
|
1172
|
+
return Array.isArray(value) && value.every(dateFns.isDate);
|
|
1206
1173
|
}
|
|
1207
1174
|
/**
|
|
1208
1175
|
* Returns whether a day matches against at least one of the given Matchers.
|
|
@@ -1227,7 +1194,7 @@ function isMatch(day, matchers) {
|
|
|
1227
1194
|
return matcher;
|
|
1228
1195
|
}
|
|
1229
1196
|
if (isDateType(matcher)) {
|
|
1230
|
-
return isSameDay(day, matcher);
|
|
1197
|
+
return dateFns.isSameDay(day, matcher);
|
|
1231
1198
|
}
|
|
1232
1199
|
if (isArrayOfDates(matcher)) {
|
|
1233
1200
|
return matcher.includes(day);
|
|
@@ -1239,8 +1206,8 @@ function isMatch(day, matchers) {
|
|
|
1239
1206
|
return matcher.dayOfWeek.includes(day.getDay());
|
|
1240
1207
|
}
|
|
1241
1208
|
if (isDateInterval(matcher)) {
|
|
1242
|
-
var diffBefore = differenceInCalendarDays(matcher.before, day);
|
|
1243
|
-
var diffAfter = differenceInCalendarDays(matcher.after, day);
|
|
1209
|
+
var diffBefore = dateFns.differenceInCalendarDays(matcher.before, day);
|
|
1210
|
+
var diffAfter = dateFns.differenceInCalendarDays(matcher.after, day);
|
|
1244
1211
|
var isDayBefore = diffBefore > 0;
|
|
1245
1212
|
var isDayAfter = diffAfter < 0;
|
|
1246
1213
|
var isClosedInterval = dateFns.isAfter(matcher.before, matcher.after);
|
|
@@ -1252,10 +1219,10 @@ function isMatch(day, matchers) {
|
|
|
1252
1219
|
}
|
|
1253
1220
|
}
|
|
1254
1221
|
if (isDateAfterType(matcher)) {
|
|
1255
|
-
return differenceInCalendarDays(day, matcher.after) > 0;
|
|
1222
|
+
return dateFns.differenceInCalendarDays(day, matcher.after) > 0;
|
|
1256
1223
|
}
|
|
1257
1224
|
if (isDateBeforeType(matcher)) {
|
|
1258
|
-
return differenceInCalendarDays(matcher.before, day) > 0;
|
|
1225
|
+
return dateFns.differenceInCalendarDays(matcher.before, day) > 0;
|
|
1259
1226
|
}
|
|
1260
1227
|
if (typeof matcher === 'function') {
|
|
1261
1228
|
return matcher(day);
|
|
@@ -1279,7 +1246,7 @@ displayMonth) {
|
|
|
1279
1246
|
}, []);
|
|
1280
1247
|
var activeModifiers = {};
|
|
1281
1248
|
matchedModifiers.forEach(function (modifier) { return (activeModifiers[modifier] = true); });
|
|
1282
|
-
if (displayMonth && !isSameMonth(day, displayMonth)) {
|
|
1249
|
+
if (displayMonth && !dateFns.isSameMonth(day, displayMonth)) {
|
|
1283
1250
|
activeModifiers.outside = true;
|
|
1284
1251
|
}
|
|
1285
1252
|
return activeModifiers;
|
|
@@ -1294,8 +1261,8 @@ displayMonth) {
|
|
|
1294
1261
|
* https://github.com/gpbl/react-day-picker/pull/1576
|
|
1295
1262
|
*/
|
|
1296
1263
|
function getInitialFocusTarget(displayMonths, modifiers) {
|
|
1297
|
-
var firstDayInMonth = startOfMonth(displayMonths[0]);
|
|
1298
|
-
var lastDayInMonth = endOfMonth(displayMonths[displayMonths.length - 1]);
|
|
1264
|
+
var firstDayInMonth = dateFns.startOfMonth(displayMonths[0]);
|
|
1265
|
+
var lastDayInMonth = dateFns.endOfMonth(displayMonths[displayMonths.length - 1]);
|
|
1299
1266
|
// TODO: cleanup code
|
|
1300
1267
|
var firstFocusableDay;
|
|
1301
1268
|
var today;
|
|
@@ -1304,7 +1271,7 @@ function getInitialFocusTarget(displayMonths, modifiers) {
|
|
|
1304
1271
|
var activeModifiers = getActiveModifiers(date, modifiers);
|
|
1305
1272
|
var isFocusable = !activeModifiers.disabled && !activeModifiers.hidden;
|
|
1306
1273
|
if (!isFocusable) {
|
|
1307
|
-
date = addDays(date, 1);
|
|
1274
|
+
date = dateFns.addDays(date, 1);
|
|
1308
1275
|
continue;
|
|
1309
1276
|
}
|
|
1310
1277
|
if (activeModifiers.selected) {
|
|
@@ -1316,7 +1283,7 @@ function getInitialFocusTarget(displayMonths, modifiers) {
|
|
|
1316
1283
|
if (!firstFocusableDay) {
|
|
1317
1284
|
firstFocusableDay = date;
|
|
1318
1285
|
}
|
|
1319
|
-
date = addDays(date, 1);
|
|
1286
|
+
date = dateFns.addDays(date, 1);
|
|
1320
1287
|
}
|
|
1321
1288
|
if (today) {
|
|
1322
1289
|
return today;
|
|
@@ -1332,27 +1299,27 @@ function getNextFocus(focusedDay, options) {
|
|
|
1332
1299
|
var moveBy = options.moveBy, direction = options.direction, context = options.context, modifiers = options.modifiers, _a = options.retry, retry = _a === void 0 ? { count: 0, lastFocused: focusedDay } : _a;
|
|
1333
1300
|
var weekStartsOn = context.weekStartsOn, fromDate = context.fromDate, toDate = context.toDate, locale = context.locale;
|
|
1334
1301
|
var moveFns = {
|
|
1335
|
-
day: addDays,
|
|
1336
|
-
week: addWeeks,
|
|
1337
|
-
month: addMonths,
|
|
1338
|
-
year: addYears,
|
|
1302
|
+
day: dateFns.addDays,
|
|
1303
|
+
week: dateFns.addWeeks,
|
|
1304
|
+
month: dateFns.addMonths,
|
|
1305
|
+
year: dateFns.addYears,
|
|
1339
1306
|
startOfWeek: function (date) {
|
|
1340
1307
|
return context.ISOWeek
|
|
1341
|
-
? startOfISOWeek(date)
|
|
1342
|
-
: startOfWeek(date, { locale: locale, weekStartsOn: weekStartsOn });
|
|
1308
|
+
? dateFns.startOfISOWeek(date)
|
|
1309
|
+
: dateFns.startOfWeek(date, { locale: locale, weekStartsOn: weekStartsOn });
|
|
1343
1310
|
},
|
|
1344
1311
|
endOfWeek: function (date) {
|
|
1345
1312
|
return context.ISOWeek
|
|
1346
|
-
? endOfISOWeek(date)
|
|
1347
|
-
: endOfWeek(date, { locale: locale, weekStartsOn: weekStartsOn });
|
|
1313
|
+
? dateFns.endOfISOWeek(date)
|
|
1314
|
+
: dateFns.endOfWeek(date, { locale: locale, weekStartsOn: weekStartsOn });
|
|
1348
1315
|
}
|
|
1349
1316
|
};
|
|
1350
1317
|
var newFocusedDay = moveFns[moveBy](focusedDay, direction === 'after' ? 1 : -1);
|
|
1351
1318
|
if (direction === 'before' && fromDate) {
|
|
1352
|
-
newFocusedDay = max([fromDate, newFocusedDay]);
|
|
1319
|
+
newFocusedDay = dateFns.max([fromDate, newFocusedDay]);
|
|
1353
1320
|
}
|
|
1354
1321
|
else if (direction === 'after' && toDate) {
|
|
1355
|
-
newFocusedDay = min([toDate, newFocusedDay]);
|
|
1322
|
+
newFocusedDay = dateFns.min([toDate, newFocusedDay]);
|
|
1356
1323
|
}
|
|
1357
1324
|
var isFocusable = true;
|
|
1358
1325
|
if (modifiers) {
|
|
@@ -1410,7 +1377,7 @@ function FocusProvider(props) {
|
|
|
1410
1377
|
context: context,
|
|
1411
1378
|
modifiers: modifiers
|
|
1412
1379
|
});
|
|
1413
|
-
if (isSameDay(focusedDay, nextFocused))
|
|
1380
|
+
if (dateFns.isSameDay(focusedDay, nextFocused))
|
|
1414
1381
|
return undefined;
|
|
1415
1382
|
navigation.goToDate(nextFocused, focusedDay);
|
|
1416
1383
|
focus(nextFocused);
|
|
@@ -1753,7 +1720,7 @@ buttonRef) {
|
|
|
1753
1720
|
return;
|
|
1754
1721
|
if (!isButton)
|
|
1755
1722
|
return;
|
|
1756
|
-
if (isSameDay(focusContext.focusedDay, day)) {
|
|
1723
|
+
if (dateFns.isSameDay(focusContext.focusedDay, day)) {
|
|
1757
1724
|
(_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
1758
1725
|
}
|
|
1759
1726
|
}, [
|
|
@@ -1765,9 +1732,6 @@ buttonRef) {
|
|
|
1765
1732
|
]);
|
|
1766
1733
|
var className = getDayClassNames(dayPicker, activeModifiers).join(' ');
|
|
1767
1734
|
var style = getDayStyle(dayPicker, activeModifiers);
|
|
1768
|
-
var ariaLabel = dayPicker.labels.labelDay(day, activeModifiers, {
|
|
1769
|
-
locale: dayPicker.locale
|
|
1770
|
-
});
|
|
1771
1735
|
var isHidden = Boolean((activeModifiers.outside && !dayPicker.showOutsideDays) ||
|
|
1772
1736
|
activeModifiers.hidden);
|
|
1773
1737
|
var DayContentComponent = (_c = (_b = dayPicker.components) === null || _b === void 0 ? void 0 : _b.DayContent) !== null && _c !== void 0 ? _c : DayContent;
|
|
@@ -1776,13 +1740,13 @@ buttonRef) {
|
|
|
1776
1740
|
style: style,
|
|
1777
1741
|
className: className,
|
|
1778
1742
|
children: children,
|
|
1779
|
-
'
|
|
1743
|
+
role: 'gridcell'
|
|
1780
1744
|
};
|
|
1781
1745
|
var isFocusTarget = focusContext.focusTarget &&
|
|
1782
|
-
isSameDay(focusContext.focusTarget, day) &&
|
|
1746
|
+
dateFns.isSameDay(focusContext.focusTarget, day) &&
|
|
1783
1747
|
!activeModifiers.outside;
|
|
1784
|
-
var isFocused = focusContext.focusedDay && isSameDay(focusContext.focusedDay, day);
|
|
1785
|
-
var buttonProps = __assign(__assign(__assign({}, divProps), (_a = { disabled: activeModifiers.disabled }, _a['aria-
|
|
1748
|
+
var isFocused = focusContext.focusedDay && dateFns.isSameDay(focusContext.focusedDay, day);
|
|
1749
|
+
var buttonProps = __assign(__assign(__assign({}, divProps), (_a = { disabled: activeModifiers.disabled, role: 'gridcell' }, _a['aria-selected'] = activeModifiers.selected, _a.tabIndex = isFocused || isFocusTarget ? 0 : -1, _a)), eventHandlers);
|
|
1786
1750
|
var dayRender = {
|
|
1787
1751
|
isButton: isButton,
|
|
1788
1752
|
isHidden: isHidden,
|
|
@@ -1802,7 +1766,7 @@ function Day(props) {
|
|
|
1802
1766
|
var buttonRef = React.useRef(null);
|
|
1803
1767
|
var dayRender = useDayRender(props.date, props.displayMonth, buttonRef);
|
|
1804
1768
|
if (dayRender.isHidden) {
|
|
1805
|
-
return React.createElement(
|
|
1769
|
+
return React.createElement("div", { role: "gridcell" });
|
|
1806
1770
|
}
|
|
1807
1771
|
if (!dayRender.isButton) {
|
|
1808
1772
|
return React.createElement("div", __assign({}, dayRender.divProps));
|
|
@@ -1841,27 +1805,27 @@ function Row(props) {
|
|
|
1841
1805
|
}
|
|
1842
1806
|
return (React.createElement("tr", { className: classNames.row, style: styles.row },
|
|
1843
1807
|
weekNumberCell,
|
|
1844
|
-
props.dates.map(function (date) { return (React.createElement("td", { className: classNames.cell, style: styles.cell, key: getUnixTime(date) },
|
|
1808
|
+
props.dates.map(function (date) { return (React.createElement("td", { className: classNames.cell, style: styles.cell, key: dateFns.getUnixTime(date), role: "presentation" },
|
|
1845
1809
|
React.createElement(DayComponent, { displayMonth: props.displayMonth, date: date }))); })));
|
|
1846
1810
|
}
|
|
1847
1811
|
|
|
1848
1812
|
/** Return the weeks between two dates. */
|
|
1849
1813
|
function daysToMonthWeeks(fromDate, toDate, options) {
|
|
1850
1814
|
var toWeek = (options === null || options === void 0 ? void 0 : options.ISOWeek)
|
|
1851
|
-
? endOfISOWeek(toDate)
|
|
1852
|
-
: endOfWeek(toDate, options);
|
|
1815
|
+
? dateFns.endOfISOWeek(toDate)
|
|
1816
|
+
: dateFns.endOfWeek(toDate, options);
|
|
1853
1817
|
var fromWeek = (options === null || options === void 0 ? void 0 : options.ISOWeek)
|
|
1854
|
-
? startOfISOWeek(fromDate)
|
|
1855
|
-
: startOfWeek(fromDate, options);
|
|
1856
|
-
var nOfDays = differenceInCalendarDays(toWeek, fromWeek);
|
|
1818
|
+
? dateFns.startOfISOWeek(fromDate)
|
|
1819
|
+
: dateFns.startOfWeek(fromDate, options);
|
|
1820
|
+
var nOfDays = dateFns.differenceInCalendarDays(toWeek, fromWeek);
|
|
1857
1821
|
var days = [];
|
|
1858
1822
|
for (var i = 0; i <= nOfDays; i++) {
|
|
1859
|
-
days.push(addDays(fromWeek, i));
|
|
1823
|
+
days.push(dateFns.addDays(fromWeek, i));
|
|
1860
1824
|
}
|
|
1861
1825
|
var weeksInMonth = days.reduce(function (result, date) {
|
|
1862
1826
|
var weekNumber = (options === null || options === void 0 ? void 0 : options.ISOWeek)
|
|
1863
|
-
? getISOWeek(date)
|
|
1864
|
-
: getWeek(date, options);
|
|
1827
|
+
? dateFns.getISOWeek(date)
|
|
1828
|
+
: dateFns.getWeek(date, options);
|
|
1865
1829
|
var existingWeek = result.find(function (value) { return value.weekNumber === weekNumber; });
|
|
1866
1830
|
if (existingWeek) {
|
|
1867
1831
|
existingWeek.dates.push(date);
|
|
@@ -1881,15 +1845,15 @@ function daysToMonthWeeks(fromDate, toDate, options) {
|
|
|
1881
1845
|
* the first and last week.
|
|
1882
1846
|
*/
|
|
1883
1847
|
function getMonthWeeks(month, options) {
|
|
1884
|
-
var weeksInMonth = daysToMonthWeeks(startOfMonth(month), endOfMonth(month), options);
|
|
1848
|
+
var weeksInMonth = daysToMonthWeeks(dateFns.startOfMonth(month), dateFns.endOfMonth(month), options);
|
|
1885
1849
|
if (options === null || options === void 0 ? void 0 : options.useFixedWeeks) {
|
|
1886
1850
|
// Add extra weeks to the month, up to 6 weeks
|
|
1887
|
-
var nrOfMonthWeeks = getWeeksInMonth(month, options);
|
|
1851
|
+
var nrOfMonthWeeks = dateFns.getWeeksInMonth(month, options);
|
|
1888
1852
|
if (nrOfMonthWeeks < 6) {
|
|
1889
1853
|
var lastWeek = weeksInMonth[weeksInMonth.length - 1];
|
|
1890
1854
|
var lastDate = lastWeek.dates[lastWeek.dates.length - 1];
|
|
1891
|
-
var toDate = addWeeks(lastDate, 6 - nrOfMonthWeeks);
|
|
1892
|
-
var extraWeeks = daysToMonthWeeks(addWeeks(lastDate, 1), toDate, options);
|
|
1855
|
+
var toDate = dateFns.addWeeks(lastDate, 6 - nrOfMonthWeeks);
|
|
1856
|
+
var extraWeeks = daysToMonthWeeks(dateFns.addWeeks(lastDate, 1), toDate, options);
|
|
1893
1857
|
weeksInMonth.push.apply(weeksInMonth, extraWeeks);
|
|
1894
1858
|
}
|
|
1895
1859
|
}
|
|
@@ -1912,7 +1876,7 @@ function Table(props) {
|
|
|
1912
1876
|
var FooterComponent = (_c = components === null || components === void 0 ? void 0 : components.Footer) !== null && _c !== void 0 ? _c : Footer;
|
|
1913
1877
|
return (React.createElement("table", { className: classNames.table, style: styles.table, role: "grid", "aria-labelledby": props['aria-labelledby'] },
|
|
1914
1878
|
!hideHead && React.createElement(HeadComponent, null),
|
|
1915
|
-
React.createElement("tbody", { className: classNames.tbody, style: styles.tbody }, weeks.map(function (week) { return (React.createElement(RowComponent, { displayMonth: props.displayMonth, key: week.weekNumber, dates: week.dates, weekNumber: week.weekNumber })); })),
|
|
1879
|
+
React.createElement("tbody", { className: classNames.tbody, style: styles.tbody, role: "rowgroup" }, weeks.map(function (week) { return (React.createElement(RowComponent, { displayMonth: props.displayMonth, key: week.weekNumber, dates: week.dates, weekNumber: week.weekNumber })); })),
|
|
1916
1880
|
React.createElement(FooterComponent, null)));
|
|
1917
1881
|
}
|
|
1918
1882
|
|
|
@@ -2158,7 +2122,7 @@ function RootProvider(props) {
|
|
|
2158
2122
|
* For example, to use Spanish locale:
|
|
2159
2123
|
*
|
|
2160
2124
|
* ```
|
|
2161
|
-
* import es from 'date-fns/locale
|
|
2125
|
+
* import { es } from 'date-fns/locale';
|
|
2162
2126
|
* <DayPicker locale={es} />
|
|
2163
2127
|
* ```
|
|
2164
2128
|
*/
|
|
@@ -2175,15 +2139,15 @@ function isValidDate(day) {
|
|
|
2175
2139
|
/** Return props and setters for binding an input field to DayPicker. */
|
|
2176
2140
|
function useInput(options) {
|
|
2177
2141
|
if (options === void 0) { options = {}; }
|
|
2178
|
-
var _a = options.locale, locale = _a === void 0 ? enUS : _a, required = options.required, _b = options.format, format
|
|
2142
|
+
var _a = options.locale, locale$1 = _a === void 0 ? locale.enUS : _a, required = options.required, _b = options.format, format = _b === void 0 ? 'PP' : _b, defaultSelected = options.defaultSelected, _c = options.today, today = _c === void 0 ? new Date() : _c;
|
|
2179
2143
|
var _d = parseFromToProps(options), fromDate = _d.fromDate, toDate = _d.toDate;
|
|
2180
2144
|
// Shortcut to the DateFns functions
|
|
2181
|
-
var parseValue = function (value) { return parse(value, format
|
|
2145
|
+
var parseValue = function (value) { return dateFns.parse(value, format, today, { locale: locale$1 }); };
|
|
2182
2146
|
// Initialize states
|
|
2183
2147
|
var _e = React.useState(defaultSelected !== null && defaultSelected !== void 0 ? defaultSelected : today), month = _e[0], setMonth = _e[1];
|
|
2184
2148
|
var _f = React.useState(defaultSelected), selectedDay = _f[0], setSelectedDay = _f[1];
|
|
2185
2149
|
var defaultInputValue = defaultSelected
|
|
2186
|
-
? format(defaultSelected, format
|
|
2150
|
+
? dateFns.format(defaultSelected, format, { locale: locale$1 })
|
|
2187
2151
|
: '';
|
|
2188
2152
|
var _g = React.useState(defaultInputValue), inputValue = _g[0], setInputValue = _g[1];
|
|
2189
2153
|
var reset = function () {
|
|
@@ -2194,7 +2158,7 @@ function useInput(options) {
|
|
|
2194
2158
|
var setSelected = function (date) {
|
|
2195
2159
|
setSelectedDay(date);
|
|
2196
2160
|
setMonth(date !== null && date !== void 0 ? date : today);
|
|
2197
|
-
setInputValue(date ? format(date, format
|
|
2161
|
+
setInputValue(date ? dateFns.format(date, format, { locale: locale$1 }) : '');
|
|
2198
2162
|
};
|
|
2199
2163
|
var handleDayClick = function (day, _a) {
|
|
2200
2164
|
var selected = _a.selected;
|
|
@@ -2204,7 +2168,7 @@ function useInput(options) {
|
|
|
2204
2168
|
return;
|
|
2205
2169
|
}
|
|
2206
2170
|
setSelectedDay(day);
|
|
2207
|
-
setInputValue(day ? format(day, format
|
|
2171
|
+
setInputValue(day ? dateFns.format(day, format, { locale: locale$1 }) : '');
|
|
2208
2172
|
};
|
|
2209
2173
|
var handleMonthChange = function (month) {
|
|
2210
2174
|
setMonth(month);
|
|
@@ -2215,8 +2179,8 @@ function useInput(options) {
|
|
|
2215
2179
|
var handleChange = function (e) {
|
|
2216
2180
|
setInputValue(e.target.value);
|
|
2217
2181
|
var day = parseValue(e.target.value);
|
|
2218
|
-
var isBefore = fromDate && differenceInCalendarDays(fromDate, day) > 0;
|
|
2219
|
-
var isAfter = toDate && differenceInCalendarDays(day, toDate) > 0;
|
|
2182
|
+
var isBefore = fromDate && dateFns.differenceInCalendarDays(fromDate, day) > 0;
|
|
2183
|
+
var isAfter = toDate && dateFns.differenceInCalendarDays(day, toDate) > 0;
|
|
2220
2184
|
if (!isValidDate(day) || isBefore || isAfter) {
|
|
2221
2185
|
setSelectedDay(undefined);
|
|
2222
2186
|
return;
|
|
@@ -2249,7 +2213,7 @@ function useInput(options) {
|
|
|
2249
2213
|
onDayClick: handleDayClick,
|
|
2250
2214
|
onMonthChange: handleMonthChange,
|
|
2251
2215
|
selected: selectedDay,
|
|
2252
|
-
locale: locale,
|
|
2216
|
+
locale: locale$1,
|
|
2253
2217
|
fromDate: fromDate,
|
|
2254
2218
|
toDate: toDate,
|
|
2255
2219
|
today: today
|
|
@@ -2259,7 +2223,7 @@ function useInput(options) {
|
|
|
2259
2223
|
onChange: handleChange,
|
|
2260
2224
|
onFocus: handleFocus,
|
|
2261
2225
|
value: inputValue,
|
|
2262
|
-
placeholder: format(new Date(), format
|
|
2226
|
+
placeholder: dateFns.format(new Date(), format, { locale: locale$1 })
|
|
2263
2227
|
};
|
|
2264
2228
|
return { dayPickerProps: dayPickerProps, inputProps: inputProps, reset: reset, setSelected: setSelected };
|
|
2265
2229
|
}
|