react-day-picker 8.2.1 → 8.3.1
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 +1171 -40
- package/dist/index.esm.d.ts +1171 -0
- package/dist/index.esm.js +119 -120
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +123 -120
- package/dist/index.js.map +1 -1
- package/dist/react-day-picker.min.js +1 -1
- package/dist/style.css +9 -11
- package/dist/style.module.css +9 -11
- package/package.json +3 -3
- package/src/components/HeadRow/HeadRow.tsx +2 -1
- package/src/components/HeadRow/utils/getWeekdays.test.ts +10 -0
- package/src/components/HeadRow/utils/getWeekdays.ts +9 -3
- package/src/components/Month/Month.test.tsx +11 -0
- package/src/components/Month/Month.tsx +5 -1
- package/src/components/Table/Table.test.tsx +19 -3
- package/src/components/Table/Table.tsx +6 -2
- package/src/components/Table/__snapshots__/Table.test.tsx.snap +39 -21
- package/src/components/Table/utils/daysToMonthWeeks.ts +15 -3
- package/src/components/Table/utils/getMonthWeeks.test.ts +33 -1
- package/src/components/Table/utils/getMonthWeeks.ts +2 -3
- package/src/contexts/DayPicker/{useDayPicker.test.ts → DayPickerContext.test.ts} +13 -29
- package/src/contexts/DayPicker/DayPickerContext.tsx +34 -52
- package/src/contexts/DayPicker/{defaultContextValue.ts → defaultContextValues.ts} +18 -1
- package/src/contexts/DayPicker/index.ts +0 -1
- package/src/contexts/Focus/{useFocusContext.test.ts → FocusContext.test.ts} +0 -0
- package/src/contexts/Focus/FocusContext.tsx +19 -6
- package/src/contexts/Focus/index.ts +0 -1
- package/src/contexts/Focus/utils/getInitialFocusTarget.test.tsx +37 -8
- package/src/contexts/Focus/utils/getInitialFocusTarget.tsx +0 -1
- package/src/contexts/Focus/utils/getNextFocus.test.tsx +75 -50
- package/src/contexts/Focus/utils/getNextFocus.tsx +54 -19
- package/src/contexts/Modifiers/{useModifiers.test.ts → ModifiersContext.test.ts} +0 -0
- package/src/contexts/Modifiers/ModifiersContext.tsx +16 -1
- package/src/contexts/Modifiers/index.ts +1 -1
- package/src/contexts/Modifiers/utils/getInternalModifiers.test.ts +3 -2
- package/src/contexts/Modifiers/utils/isMatch.test.ts +24 -5
- package/src/contexts/Modifiers/utils/isMatch.ts +11 -3
- package/src/contexts/Navigation/{useNavigation.test.ts → NavigationContext.test.ts} +6 -5
- package/src/contexts/Navigation/NavigationContext.tsx +15 -1
- package/src/contexts/Navigation/index.ts +0 -1
- package/src/contexts/Navigation/useNavigationState.test.ts +4 -1
- package/src/contexts/SelectMultiple/{useSelectMultiple.test.ts → SelectMultipleContext.test.ts} +4 -2
- package/src/contexts/SelectMultiple/SelectMultipleContext.tsx +16 -1
- package/src/contexts/SelectMultiple/index.ts +0 -1
- package/src/contexts/SelectRange/{useSelectRange.test.ts → SelectRangeContext.test.ts} +4 -21
- package/src/contexts/SelectRange/SelectRangeContext.tsx +51 -36
- package/src/contexts/SelectRange/index.ts +0 -1
- package/src/contexts/SelectSingle/{useSelectSingle.test.ts → SelectSingleContext.test.ts} +1 -1
- package/src/contexts/SelectSingle/SelectSingleContext.tsx +16 -1
- package/src/contexts/SelectSingle/index.ts +0 -1
- package/src/style.css +9 -11
- package/src/types/DayPickerBase.ts +28 -6
- package/src/types/DayPickerDefault.ts +2 -2
- package/src/types/EventHandlers.ts +9 -11
- package/src/types/Matchers.ts +1 -1
- package/dist/DayPicker.d.ts +0 -93
- package/dist/components/Button/Button.d.ts +0 -7
- package/dist/components/Button/index.d.ts +0 -1
- package/dist/components/Caption/Caption.d.ts +0 -19
- package/dist/components/Caption/index.d.ts +0 -1
- package/dist/components/CaptionDropdowns/CaptionDropdowns.d.ts +0 -5
- package/dist/components/CaptionDropdowns/index.d.ts +0 -1
- package/dist/components/CaptionLabel/CaptionLabel.d.ts +0 -9
- package/dist/components/CaptionLabel/index.d.ts +0 -1
- package/dist/components/CaptionNavigation/CaptionNavigation.d.ts +0 -5
- package/dist/components/CaptionNavigation/index.d.ts +0 -1
- package/dist/components/Day/Day.d.ts +0 -12
- package/dist/components/Day/index.d.ts +0 -1
- package/dist/components/DayContent/DayContent.d.ts +0 -12
- package/dist/components/DayContent/index.d.ts +0 -1
- package/dist/components/Dropdown/Dropdown.d.ts +0 -20
- package/dist/components/Dropdown/index.d.ts +0 -1
- package/dist/components/Footer/Footer.d.ts +0 -2
- package/dist/components/Footer/index.d.ts +0 -1
- package/dist/components/Head/Head.d.ts +0 -2
- package/dist/components/Head/index.d.ts +0 -1
- package/dist/components/HeadRow/HeadRow.d.ts +0 -4
- package/dist/components/HeadRow/index.d.ts +0 -1
- package/dist/components/HeadRow/utils/getWeekdays.d.ts +0 -8
- package/dist/components/HeadRow/utils/index.d.ts +0 -1
- package/dist/components/IconDropdown/IconDropdown.d.ts +0 -5
- package/dist/components/IconDropdown/index.d.ts +0 -1
- package/dist/components/IconLeft/IconLeft.d.ts +0 -5
- package/dist/components/IconLeft/index.d.ts +0 -1
- package/dist/components/IconRight/IconRight.d.ts +0 -5
- package/dist/components/IconRight/index.d.ts +0 -1
- package/dist/components/Month/Month.d.ts +0 -7
- package/dist/components/Month/index.d.ts +0 -1
- package/dist/components/MonthsDropdown/MonthsDropdown.d.ts +0 -9
- package/dist/components/MonthsDropdown/index.d.ts +0 -1
- package/dist/components/Navigation/Navigation.d.ts +0 -20
- package/dist/components/Navigation/index.d.ts +0 -1
- package/dist/components/Root/Root.d.ts +0 -2
- package/dist/components/Root/index.d.ts +0 -1
- package/dist/components/Row/Row.d.ts +0 -13
- package/dist/components/Row/index.d.ts +0 -1
- package/dist/components/Table/Table.d.ts +0 -9
- package/dist/components/Table/index.d.ts +0 -1
- package/dist/components/Table/utils/daysToMonthWeeks.d.ts +0 -8
- package/dist/components/Table/utils/getMonthWeeks.d.ts +0 -21
- package/dist/components/WeekNumber/WeekNumber.d.ts +0 -14
- package/dist/components/WeekNumber/index.d.ts +0 -1
- package/dist/components/YearsDropdown/YearsDropdown.d.ts +0 -15
- package/dist/components/YearsDropdown/index.d.ts +0 -1
- package/dist/contexts/DayPicker/DayPickerContext.d.ts +0 -50
- package/dist/contexts/DayPicker/defaultClassNames.d.ts +0 -5
- package/dist/contexts/DayPicker/defaultContextValue.d.ts +0 -6
- package/dist/contexts/DayPicker/formatters/formatCaption.d.ts +0 -7
- package/dist/contexts/DayPicker/formatters/formatDay.d.ts +0 -7
- package/dist/contexts/DayPicker/formatters/formatMonthCaption.d.ts +0 -7
- package/dist/contexts/DayPicker/formatters/formatWeekNumber.d.ts +0 -4
- package/dist/contexts/DayPicker/formatters/formatWeekdayName.d.ts +0 -7
- package/dist/contexts/DayPicker/formatters/formatYearCaption.d.ts +0 -6
- package/dist/contexts/DayPicker/formatters/index.d.ts +0 -6
- package/dist/contexts/DayPicker/index.d.ts +0 -2
- package/dist/contexts/DayPicker/labels/index.d.ts +0 -7
- package/dist/contexts/DayPicker/labels/labelDay.d.ts +0 -5
- package/dist/contexts/DayPicker/labels/labelMonthDropdown.d.ts +0 -4
- package/dist/contexts/DayPicker/labels/labelNext.d.ts +0 -5
- package/dist/contexts/DayPicker/labels/labelPrevious.d.ts +0 -5
- package/dist/contexts/DayPicker/labels/labelWeekNumber.d.ts +0 -5
- package/dist/contexts/DayPicker/labels/labelWeekday.d.ts +0 -5
- package/dist/contexts/DayPicker/labels/labelYearDropdown.d.ts +0 -4
- package/dist/contexts/DayPicker/useDayPicker.d.ts +0 -8
- package/dist/contexts/DayPicker/utils/index.d.ts +0 -1
- package/dist/contexts/DayPicker/utils/parseFromToProps.d.ts +0 -6
- package/dist/contexts/Focus/FocusContext.d.ts +0 -36
- package/dist/contexts/Focus/index.d.ts +0 -2
- package/dist/contexts/Focus/useFocusContext.d.ts +0 -8
- package/dist/contexts/Focus/utils/getInitialFocusTarget.d.ts +0 -3
- package/dist/contexts/Focus/utils/getNextFocus.d.ts +0 -9
- package/dist/contexts/Modifiers/ModifiersContext.d.ts +0 -9
- package/dist/contexts/Modifiers/index.d.ts +0 -2
- package/dist/contexts/Modifiers/useModifiers.d.ts +0 -9
- package/dist/contexts/Modifiers/utils/getActiveModifiers.d.ts +0 -7
- package/dist/contexts/Modifiers/utils/getCustomModifiers.d.ts +0 -3
- package/dist/contexts/Modifiers/utils/getInternalModifiers.d.ts +0 -6
- package/dist/contexts/Modifiers/utils/isDateInRange.d.ts +0 -3
- package/dist/contexts/Modifiers/utils/isMatch.d.ts +0 -19
- package/dist/contexts/Modifiers/utils/matcherToArray.d.ts +0 -3
- package/dist/contexts/Navigation/NavigationContext.d.ts +0 -27
- package/dist/contexts/Navigation/index.d.ts +0 -2
- package/dist/contexts/Navigation/useNavigation.d.ts +0 -8
- package/dist/contexts/Navigation/useNavigationState.d.ts +0 -7
- package/dist/contexts/Navigation/utils/getDisplayMonths.d.ts +0 -8
- package/dist/contexts/Navigation/utils/getInitialMonth.d.ts +0 -3
- package/dist/contexts/Navigation/utils/getNextMonth.d.ts +0 -18
- package/dist/contexts/Navigation/utils/getPreviousMonth.d.ts +0 -19
- package/dist/contexts/RootProvider.d.ts +0 -8
- package/dist/contexts/SelectMultiple/SelectMultipleContext.d.ts +0 -35
- package/dist/contexts/SelectMultiple/index.d.ts +0 -2
- package/dist/contexts/SelectMultiple/useSelectMultiple.d.ts +0 -7
- package/dist/contexts/SelectRange/SelectRangeContext.d.ts +0 -36
- package/dist/contexts/SelectRange/index.d.ts +0 -2
- package/dist/contexts/SelectRange/useSelectRange.d.ts +0 -7
- package/dist/contexts/SelectRange/utils/addToRange.d.ts +0 -8
- package/dist/contexts/SelectSingle/SelectSingleContext.d.ts +0 -30
- package/dist/contexts/SelectSingle/index.d.ts +0 -2
- package/dist/contexts/SelectSingle/useSelectSingle.d.ts +0 -7
- package/dist/hooks/useActiveModifiers/index.d.ts +0 -1
- package/dist/hooks/useActiveModifiers/useActiveModifiers.d.ts +0 -15
- package/dist/hooks/useControlledValue/index.d.ts +0 -1
- package/dist/hooks/useControlledValue/useControlledValue.d.ts +0 -12
- package/dist/hooks/useDayEventHandlers/index.d.ts +0 -1
- package/dist/hooks/useDayEventHandlers/useDayEventHandlers.d.ts +0 -26
- package/dist/hooks/useDayRender/index.d.ts +0 -1
- package/dist/hooks/useDayRender/useDayRender.d.ts +0 -32
- package/dist/hooks/useDayRender/utils/getDayClassNames.d.ts +0 -10
- package/dist/hooks/useDayRender/utils/getDayStyle.d.ts +0 -5
- package/dist/hooks/useId/index.d.ts +0 -1
- package/dist/hooks/useId/useId.d.ts +0 -19
- package/dist/hooks/useInput/index.d.ts +0 -1
- package/dist/hooks/useInput/useInput.d.ts +0 -28
- package/dist/hooks/useInput/utils/isValidDate.d.ts +0 -2
- package/dist/hooks/useSelectedDays/index.d.ts +0 -1
- package/dist/hooks/useSelectedDays/useSelectedDays.d.ts +0 -10
- package/dist/types/DayPickerBase.d.ts +0 -255
- package/dist/types/DayPickerDefault.d.ts +0 -8
- package/dist/types/DayPickerMultiple.d.ts +0 -18
- package/dist/types/DayPickerRange.d.ts +0 -19
- package/dist/types/DayPickerSingle.d.ts +0 -16
- package/dist/types/EventHandlers.d.ts +0 -51
- package/dist/types/Formatters.d.ts +0 -24
- package/dist/types/Labels.d.ts +0 -28
- package/dist/types/Matchers.d.ts +0 -84
- package/dist/types/Modifiers.d.ts +0 -49
- package/dist/types/Styles.d.ts +0 -102
- package/src/contexts/DayPicker/useDayPicker.ts +0 -17
- package/src/contexts/Focus/useFocusContext.ts +0 -17
- package/src/contexts/Modifiers/useModifiers.ts +0 -20
- package/src/contexts/Navigation/useNavigation.ts +0 -17
- package/src/contexts/SelectMultiple/useSelectMultiple.ts +0 -21
- package/src/contexts/SelectRange/useSelectRange.ts +0 -19
- package/src/contexts/SelectSingle/useSelectSingle.ts +0 -21
package/dist/index.esm.js
CHANGED
|
@@ -14,18 +14,23 @@ import isBefore from 'date-fns/isBefore';
|
|
|
14
14
|
import isSameMonth from 'date-fns/isSameMonth';
|
|
15
15
|
import differenceInCalendarMonths from 'date-fns/differenceInCalendarMonths';
|
|
16
16
|
import addDays from 'date-fns/addDays';
|
|
17
|
+
import startOfISOWeek from 'date-fns/startOfISOWeek';
|
|
17
18
|
import startOfWeek from 'date-fns/startOfWeek';
|
|
18
19
|
import getUnixTime from 'date-fns/getUnixTime';
|
|
19
20
|
import isSameDay from 'date-fns/isSameDay';
|
|
20
21
|
import differenceInCalendarDays from 'date-fns/differenceInCalendarDays';
|
|
22
|
+
import subDays from 'date-fns/subDays';
|
|
21
23
|
import isAfter from 'date-fns/isAfter';
|
|
24
|
+
import { isAfter as isAfter$1 } from 'date-fns';
|
|
22
25
|
import isDate from 'date-fns/isDate';
|
|
23
26
|
import addWeeks from 'date-fns/addWeeks';
|
|
24
27
|
import addYears from 'date-fns/addYears';
|
|
28
|
+
import endOfISOWeek from 'date-fns/endOfISOWeek';
|
|
25
29
|
import endOfWeek from 'date-fns/endOfWeek';
|
|
26
30
|
import max from 'date-fns/max';
|
|
27
31
|
import min from 'date-fns/min';
|
|
28
32
|
import getWeeksInMonth from 'date-fns/getWeeksInMonth';
|
|
33
|
+
import getISOWeek from 'date-fns/getISOWeek';
|
|
29
34
|
import getWeek from 'date-fns/getWeek';
|
|
30
35
|
import parse from 'date-fns/parse';
|
|
31
36
|
|
|
@@ -255,7 +260,7 @@ var labels = /*#__PURE__*/Object.freeze({
|
|
|
255
260
|
* Returns the default values to use in the DayPickerContext, in case they are
|
|
256
261
|
* not passed down with the DayPicker initial props.
|
|
257
262
|
*/
|
|
258
|
-
function
|
|
263
|
+
function getDefaultContextValues() {
|
|
259
264
|
var captionLayout = 'buttons';
|
|
260
265
|
var classNames = defaultClassNames;
|
|
261
266
|
var locale = enUS;
|
|
@@ -314,12 +319,13 @@ var DayPickerContext = createContext(undefined);
|
|
|
314
319
|
* initial DayPicker props.
|
|
315
320
|
*/
|
|
316
321
|
function DayPickerProvider(props) {
|
|
317
|
-
var _a
|
|
322
|
+
var _a;
|
|
318
323
|
var initialProps = props.initialProps;
|
|
319
|
-
var
|
|
320
|
-
var
|
|
321
|
-
var captionLayout = (_a = initialProps.captionLayout) !== null && _a !== void 0 ? _a :
|
|
324
|
+
var defaultContextValues = getDefaultContextValues();
|
|
325
|
+
var _b = parseFromToProps(initialProps), fromDate = _b.fromDate, toDate = _b.toDate;
|
|
326
|
+
var captionLayout = (_a = initialProps.captionLayout) !== null && _a !== void 0 ? _a : defaultContextValues.captionLayout;
|
|
322
327
|
if (captionLayout !== 'buttons' && (!fromDate || !toDate)) {
|
|
328
|
+
// When no from/to dates are set, the caption is always buttons
|
|
323
329
|
captionLayout = 'buttons';
|
|
324
330
|
}
|
|
325
331
|
var onSelect;
|
|
@@ -328,61 +334,9 @@ function DayPickerProvider(props) {
|
|
|
328
334
|
isDayPickerRange(initialProps)) {
|
|
329
335
|
onSelect = initialProps.onSelect;
|
|
330
336
|
}
|
|
331
|
-
var value = {
|
|
332
|
-
captionLayout: captionLayout,
|
|
333
|
-
className: initialProps.className,
|
|
334
|
-
classNames: __assign(__assign({}, defaults.classNames), initialProps.classNames),
|
|
335
|
-
components: __assign(__assign({}, defaults.components), initialProps.components),
|
|
336
|
-
defaultMonth: initialProps.defaultMonth,
|
|
337
|
-
dir: initialProps.dir,
|
|
338
|
-
disabled: initialProps.disabled,
|
|
339
|
-
disableNavigation: initialProps.disableNavigation,
|
|
340
|
-
fixedWeeks: initialProps.fixedWeeks,
|
|
341
|
-
footer: initialProps.footer,
|
|
342
|
-
formatters: __assign(__assign({}, defaults.formatters), initialProps.formatters),
|
|
343
|
-
fromDate: fromDate,
|
|
344
|
-
hidden: initialProps.hidden,
|
|
345
|
-
hideHead: initialProps.hideHead,
|
|
346
|
-
initialFocus: initialProps.initialFocus,
|
|
347
|
-
labels: __assign(__assign({}, defaults.labels), initialProps.labels),
|
|
348
|
-
locale: (_b = initialProps.locale) !== null && _b !== void 0 ? _b : defaults.locale,
|
|
349
|
-
mode: initialProps.mode || 'default',
|
|
350
|
-
modifiers: __assign(__assign({}, defaults.modifiers), initialProps.modifiers),
|
|
351
|
-
modifiersClassNames: __assign(__assign({}, defaults.modifiersClassNames), initialProps.modifiersClassNames),
|
|
352
|
-
modifiersStyles: initialProps.modifiersStyles,
|
|
353
|
-
month: initialProps.month,
|
|
354
|
-
numberOfMonths: (_c = initialProps.numberOfMonths) !== null && _c !== void 0 ? _c : defaults.numberOfMonths,
|
|
355
|
-
onDayBlur: initialProps.onDayBlur,
|
|
356
|
-
onDayClick: initialProps.onDayClick,
|
|
357
|
-
onDayFocus: initialProps.onDayFocus,
|
|
358
|
-
onDayKeyDown: initialProps.onDayKeyDown,
|
|
359
|
-
onDayKeyPress: initialProps.onDayKeyPress,
|
|
360
|
-
onDayKeyUp: initialProps.onDayKeyUp,
|
|
361
|
-
onDayMouseEnter: initialProps.onDayMouseEnter,
|
|
362
|
-
onDayMouseLeave: initialProps.onDayMouseLeave,
|
|
363
|
-
onDayTouchCancel: initialProps.onDayTouchCancel,
|
|
364
|
-
onDayTouchEnd: initialProps.onDayTouchEnd,
|
|
365
|
-
onDayTouchMove: initialProps.onDayTouchMove,
|
|
366
|
-
onDayTouchStart: initialProps.onDayTouchStart,
|
|
367
|
-
onMonthChange: initialProps.onMonthChange,
|
|
368
|
-
onNextClick: initialProps.onNextClick,
|
|
369
|
-
onPrevClick: initialProps.onPrevClick,
|
|
370
|
-
onSelect: onSelect,
|
|
371
|
-
onWeekNumberClick: initialProps.onWeekNumberClick,
|
|
372
|
-
pagedNavigation: initialProps.pagedNavigation,
|
|
373
|
-
reverseMonths: initialProps.reverseMonths,
|
|
374
|
-
selected: initialProps.selected,
|
|
375
|
-
showOutsideDays: initialProps.showOutsideDays,
|
|
376
|
-
showWeekNumber: initialProps.showWeekNumber,
|
|
377
|
-
style: initialProps.style,
|
|
378
|
-
styles: __assign(__assign({}, defaults.styles), initialProps.styles),
|
|
379
|
-
toDate: toDate,
|
|
380
|
-
today: (_d = initialProps.today) !== null && _d !== void 0 ? _d : defaults.today,
|
|
381
|
-
weekStartsOn: initialProps.weekStartsOn
|
|
382
|
-
};
|
|
337
|
+
var value = __assign(__assign(__assign({}, defaultContextValues), initialProps), { captionLayout: captionLayout, classNames: __assign(__assign({}, defaultContextValues.classNames), initialProps.classNames), components: __assign({}, initialProps.components), formatters: __assign(__assign({}, defaultContextValues.formatters), initialProps.formatters), fromDate: fromDate, labels: __assign(__assign({}, defaultContextValues.labels), initialProps.labels), mode: initialProps.mode || defaultContextValues.mode, modifiers: __assign(__assign({}, defaultContextValues.modifiers), initialProps.modifiers), modifiersClassNames: __assign(__assign({}, defaultContextValues.modifiersClassNames), initialProps.modifiersClassNames), onSelect: onSelect, styles: __assign(__assign({}, defaultContextValues.styles), initialProps.styles), toDate: toDate });
|
|
383
338
|
return (React__default.createElement(DayPickerContext.Provider, { value: value }, props.children));
|
|
384
339
|
}
|
|
385
|
-
|
|
386
340
|
/**
|
|
387
341
|
* Hook to access the {@link DayPickerContextValue}.
|
|
388
342
|
*
|
|
@@ -651,7 +605,6 @@ function NavigationProvider(props) {
|
|
|
651
605
|
};
|
|
652
606
|
return (React__default.createElement(NavigationContext.Provider, { value: value }, props.children));
|
|
653
607
|
}
|
|
654
|
-
|
|
655
608
|
/**
|
|
656
609
|
* Hook to access the {@link NavigationContextValue}. Use this hook to navigate
|
|
657
610
|
* between months or years in DayPicker.
|
|
@@ -812,9 +765,13 @@ function Footer() {
|
|
|
812
765
|
* the weekday names (Monday, Tuesday, etc.).
|
|
813
766
|
*/
|
|
814
767
|
function getWeekdays(locale,
|
|
815
|
-
/** The index of the first day of the week (0 - Sunday) */
|
|
816
|
-
weekStartsOn
|
|
817
|
-
|
|
768
|
+
/** The index of the first day of the week (0 - Sunday). */
|
|
769
|
+
weekStartsOn,
|
|
770
|
+
/** Use ISOWeek instead of locale/ */
|
|
771
|
+
ISOWeek) {
|
|
772
|
+
var start = ISOWeek
|
|
773
|
+
? startOfISOWeek(new Date())
|
|
774
|
+
: startOfWeek(new Date(), { locale: locale, weekStartsOn: weekStartsOn });
|
|
818
775
|
var days = [];
|
|
819
776
|
for (var i = 0; i < 7; i++) {
|
|
820
777
|
var day = addDays(start, i);
|
|
@@ -827,8 +784,8 @@ weekStartsOn) {
|
|
|
827
784
|
* Render the HeadRow component - i.e. the table head row with the weekday names.
|
|
828
785
|
*/
|
|
829
786
|
function HeadRow() {
|
|
830
|
-
var _a = useDayPicker(), classNames = _a.classNames, styles = _a.styles, showWeekNumber = _a.showWeekNumber, locale = _a.locale, weekStartsOn = _a.weekStartsOn, formatWeekdayName = _a.formatters.formatWeekdayName, labelWeekday = _a.labels.labelWeekday;
|
|
831
|
-
var weekdays = getWeekdays(locale, weekStartsOn);
|
|
787
|
+
var _a = useDayPicker(), classNames = _a.classNames, styles = _a.styles, showWeekNumber = _a.showWeekNumber, locale = _a.locale, weekStartsOn = _a.weekStartsOn, ISOWeek = _a.ISOWeek, formatWeekdayName = _a.formatters.formatWeekdayName, labelWeekday = _a.labels.labelWeekday;
|
|
788
|
+
var weekdays = getWeekdays(locale, weekStartsOn, ISOWeek);
|
|
832
789
|
return (React__default.createElement("tr", { style: styles.head_row, className: classNames.head_row },
|
|
833
790
|
showWeekNumber && (React__default.createElement("th", { scope: "col", style: styles.head_cell, className: classNames.head_cell })),
|
|
834
791
|
weekdays.map(function (weekday, i) { return (React__default.createElement("th", { key: i, scope: "col", className: classNames.head_cell, style: styles.head_cell },
|
|
@@ -916,7 +873,6 @@ function SelectMultipleProviderInternal(_a) {
|
|
|
916
873
|
};
|
|
917
874
|
return (React__default.createElement(SelectMultipleContext.Provider, { value: contextValue }, children));
|
|
918
875
|
}
|
|
919
|
-
|
|
920
876
|
/**
|
|
921
877
|
* Hook to access the {@link SelectMultipleContextValue}.
|
|
922
878
|
*
|
|
@@ -997,18 +953,8 @@ function SelectRangeProviderInternal(_a) {
|
|
|
997
953
|
var onDayClick = function (day, activeModifiers, e) {
|
|
998
954
|
var _a, _b;
|
|
999
955
|
(_a = initialProps.onDayClick) === null || _a === void 0 ? void 0 : _a.call(initialProps, day, activeModifiers, e);
|
|
1000
|
-
var
|
|
1001
|
-
|
|
1002
|
-
selected &&
|
|
1003
|
-
(range === null || range === void 0 ? void 0 : range.to) &&
|
|
1004
|
-
range.from &&
|
|
1005
|
-
range.from !== range.to) {
|
|
1006
|
-
var diff = Math.abs(differenceInCalendarDays(range === null || range === void 0 ? void 0 : range.to, range === null || range === void 0 ? void 0 : range.from));
|
|
1007
|
-
if ((min && diff < min) || (max && diff >= max)) {
|
|
1008
|
-
return;
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
(_b = initialProps.onSelect) === null || _b === void 0 ? void 0 : _b.call(initialProps, range, day, activeModifiers, e);
|
|
956
|
+
var newRange = addToRange(day, selected);
|
|
957
|
+
(_b = initialProps.onSelect) === null || _b === void 0 ? void 0 : _b.call(initialProps, newRange, day, activeModifiers, e);
|
|
1012
958
|
};
|
|
1013
959
|
var modifiers = {
|
|
1014
960
|
range_start: [],
|
|
@@ -1031,25 +977,42 @@ function SelectRangeProviderInternal(_a) {
|
|
|
1031
977
|
];
|
|
1032
978
|
}
|
|
1033
979
|
}
|
|
1034
|
-
if (min
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
(
|
|
1039
|
-
|
|
1040
|
-
}
|
|
980
|
+
if (min) {
|
|
981
|
+
if (selectedFrom && !selectedTo) {
|
|
982
|
+
modifiers.disabled.push({
|
|
983
|
+
after: subDays(selectedFrom, min - 1),
|
|
984
|
+
before: addDays(selectedFrom, min - 1)
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
if (selectedFrom && selectedTo) {
|
|
988
|
+
modifiers.disabled.push({
|
|
989
|
+
after: selectedFrom,
|
|
990
|
+
before: addDays(selectedFrom, min - 1)
|
|
991
|
+
});
|
|
992
|
+
}
|
|
1041
993
|
}
|
|
1042
|
-
if (max
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
994
|
+
if (max) {
|
|
995
|
+
if (selectedFrom && !selectedTo) {
|
|
996
|
+
modifiers.disabled.push({
|
|
997
|
+
before: addDays(selectedFrom, -max + 1)
|
|
998
|
+
});
|
|
999
|
+
modifiers.disabled.push({
|
|
1000
|
+
after: addDays(selectedFrom, max - 1)
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
if (selectedFrom && selectedTo) {
|
|
1004
|
+
var selectedCount = differenceInCalendarDays(selectedTo, selectedFrom) + 1;
|
|
1005
|
+
var offset = max - selectedCount;
|
|
1006
|
+
modifiers.disabled.push({
|
|
1007
|
+
before: subDays(selectedFrom, offset)
|
|
1008
|
+
});
|
|
1009
|
+
modifiers.disabled.push({
|
|
1010
|
+
after: addDays(selectedTo, offset)
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1049
1013
|
}
|
|
1050
1014
|
return (React__default.createElement(SelectRangeContext.Provider, { value: { selected: selected, onDayClick: onDayClick, modifiers: modifiers } }, children));
|
|
1051
1015
|
}
|
|
1052
|
-
|
|
1053
1016
|
/**
|
|
1054
1017
|
* Hook to access the {@link SelectRangeContextValue}.
|
|
1055
1018
|
*
|
|
@@ -1150,7 +1113,6 @@ function ModifiersProvider(props) {
|
|
|
1150
1113
|
var modifiers = __assign(__assign({}, internalModifiers), customModifiers);
|
|
1151
1114
|
return (React__default.createElement(ModifiersContext.Provider, { value: modifiers }, props.children));
|
|
1152
1115
|
}
|
|
1153
|
-
|
|
1154
1116
|
/**
|
|
1155
1117
|
* Return the modifiers used by DayPicker.
|
|
1156
1118
|
*
|
|
@@ -1254,9 +1216,17 @@ function isMatch(day, matchers) {
|
|
|
1254
1216
|
return matcher.dayOfWeek.includes(day.getDay());
|
|
1255
1217
|
}
|
|
1256
1218
|
if (isDateInterval(matcher)) {
|
|
1257
|
-
var
|
|
1258
|
-
var
|
|
1259
|
-
|
|
1219
|
+
var diffBefore = differenceInCalendarDays(matcher.before, day);
|
|
1220
|
+
var diffAfter = differenceInCalendarDays(matcher.after, day);
|
|
1221
|
+
var isDayBefore = diffBefore > 0;
|
|
1222
|
+
var isDayAfter = diffAfter < 0;
|
|
1223
|
+
var isClosedInterval = isAfter$1(matcher.before, matcher.after);
|
|
1224
|
+
if (isClosedInterval) {
|
|
1225
|
+
return isDayAfter && isDayBefore;
|
|
1226
|
+
}
|
|
1227
|
+
else {
|
|
1228
|
+
return isDayBefore || isDayAfter;
|
|
1229
|
+
}
|
|
1260
1230
|
}
|
|
1261
1231
|
if (isDateAfterType(matcher)) {
|
|
1262
1232
|
return differenceInCalendarDays(day, matcher.after) > 0;
|
|
@@ -1326,18 +1296,26 @@ function getInitialFocusTarget(displayMonths, modifiers) {
|
|
|
1326
1296
|
}
|
|
1327
1297
|
}
|
|
1328
1298
|
|
|
1299
|
+
var MAX_RETRY = 365;
|
|
1329
1300
|
/** Return the next date to be focused. */
|
|
1330
|
-
function getNextFocus(
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
var weekStartsOn = options.weekStartsOn, fromDate = options.fromDate, toDate = options.toDate, locale = options.locale;
|
|
1301
|
+
function getNextFocus(focusedDay, options) {
|
|
1302
|
+
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;
|
|
1303
|
+
var weekStartsOn = context.weekStartsOn, fromDate = context.fromDate, toDate = context.toDate, locale = context.locale;
|
|
1334
1304
|
var moveFns = {
|
|
1335
1305
|
day: addDays,
|
|
1336
1306
|
week: addWeeks,
|
|
1337
1307
|
month: addMonths,
|
|
1338
1308
|
year: addYears,
|
|
1339
|
-
startOfWeek: function (date) {
|
|
1340
|
-
|
|
1309
|
+
startOfWeek: function (date) {
|
|
1310
|
+
return context.ISOWeek
|
|
1311
|
+
? startOfISOWeek(date)
|
|
1312
|
+
: startOfWeek(date, { locale: locale, weekStartsOn: weekStartsOn });
|
|
1313
|
+
},
|
|
1314
|
+
endOfWeek: function (date) {
|
|
1315
|
+
return context.ISOWeek
|
|
1316
|
+
? endOfISOWeek(date)
|
|
1317
|
+
: endOfWeek(date, { locale: locale, weekStartsOn: weekStartsOn });
|
|
1318
|
+
}
|
|
1341
1319
|
};
|
|
1342
1320
|
var newFocusedDay = moveFns[moveBy](focusedDay, direction === 'after' ? 1 : -1);
|
|
1343
1321
|
if (direction === 'before' && fromDate) {
|
|
@@ -1346,14 +1324,26 @@ focusedDay, moveBy, direction, options, modifiers) {
|
|
|
1346
1324
|
else if (direction === 'after' && toDate) {
|
|
1347
1325
|
newFocusedDay = min([toDate, newFocusedDay]);
|
|
1348
1326
|
}
|
|
1327
|
+
var isFocusable = true;
|
|
1349
1328
|
if (modifiers) {
|
|
1350
1329
|
var activeModifiers = getActiveModifiers(newFocusedDay, modifiers);
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1330
|
+
isFocusable = !activeModifiers.disabled && !activeModifiers.hidden;
|
|
1331
|
+
}
|
|
1332
|
+
if (isFocusable) {
|
|
1333
|
+
return newFocusedDay;
|
|
1334
|
+
}
|
|
1335
|
+
else {
|
|
1336
|
+
if (retry.count > MAX_RETRY) {
|
|
1337
|
+
return retry.lastFocused;
|
|
1354
1338
|
}
|
|
1339
|
+
return getNextFocus(newFocusedDay, {
|
|
1340
|
+
moveBy: moveBy,
|
|
1341
|
+
direction: direction,
|
|
1342
|
+
context: context,
|
|
1343
|
+
modifiers: modifiers,
|
|
1344
|
+
retry: __assign(__assign({}, retry), { count: retry.count + 1 })
|
|
1345
|
+
});
|
|
1355
1346
|
}
|
|
1356
|
-
return newFocusedDay;
|
|
1357
1347
|
}
|
|
1358
1348
|
|
|
1359
1349
|
/**
|
|
@@ -1380,11 +1370,16 @@ function FocusProvider(props) {
|
|
|
1380
1370
|
var focus = function (date) {
|
|
1381
1371
|
setFocusedDay(date);
|
|
1382
1372
|
};
|
|
1383
|
-
var
|
|
1373
|
+
var context = useDayPicker();
|
|
1384
1374
|
var moveFocus = function (moveBy, direction) {
|
|
1385
1375
|
if (!focusedDay)
|
|
1386
1376
|
return;
|
|
1387
|
-
var nextFocused = getNextFocus(focusedDay,
|
|
1377
|
+
var nextFocused = getNextFocus(focusedDay, {
|
|
1378
|
+
moveBy: moveBy,
|
|
1379
|
+
direction: direction,
|
|
1380
|
+
context: context,
|
|
1381
|
+
modifiers: modifiers
|
|
1382
|
+
});
|
|
1388
1383
|
if (isSameDay(focusedDay, nextFocused))
|
|
1389
1384
|
return undefined;
|
|
1390
1385
|
navigation.goToDate(nextFocused, focusedDay);
|
|
@@ -1408,7 +1403,6 @@ function FocusProvider(props) {
|
|
|
1408
1403
|
};
|
|
1409
1404
|
return (React__default.createElement(FocusContext.Provider, { value: value }, props.children));
|
|
1410
1405
|
}
|
|
1411
|
-
|
|
1412
1406
|
/**
|
|
1413
1407
|
* Hook to access the {@link FocusContextValue}. Use this hook to handle the
|
|
1414
1408
|
* focus state of the elements.
|
|
@@ -1476,7 +1470,6 @@ function SelectSingleProviderInternal(_a) {
|
|
|
1476
1470
|
};
|
|
1477
1471
|
return (React__default.createElement(SelectSingleContext.Provider, { value: contextValue }, children));
|
|
1478
1472
|
}
|
|
1479
|
-
|
|
1480
1473
|
/**
|
|
1481
1474
|
* Hook to access the {@link SelectSingleContextValue}.
|
|
1482
1475
|
*
|
|
@@ -1811,15 +1804,21 @@ function Row(props) {
|
|
|
1811
1804
|
|
|
1812
1805
|
/** Return the weeks between two dates. */
|
|
1813
1806
|
function daysToMonthWeeks(fromDate, toDate, options) {
|
|
1814
|
-
var toWeek =
|
|
1815
|
-
|
|
1807
|
+
var toWeek = (options === null || options === void 0 ? void 0 : options.ISOWeek)
|
|
1808
|
+
? endOfISOWeek(toDate)
|
|
1809
|
+
: endOfWeek(toDate, options);
|
|
1810
|
+
var fromWeek = (options === null || options === void 0 ? void 0 : options.ISOWeek)
|
|
1811
|
+
? startOfISOWeek(fromDate)
|
|
1812
|
+
: startOfWeek(fromDate, options);
|
|
1816
1813
|
var nOfDays = differenceInCalendarDays(toWeek, fromWeek);
|
|
1817
1814
|
var days = [];
|
|
1818
1815
|
for (var i = 0; i <= nOfDays; i++) {
|
|
1819
1816
|
days.push(addDays(fromWeek, i));
|
|
1820
1817
|
}
|
|
1821
1818
|
var weeksInMonth = days.reduce(function (result, date) {
|
|
1822
|
-
var weekNumber =
|
|
1819
|
+
var weekNumber = (options === null || options === void 0 ? void 0 : options.ISOWeek)
|
|
1820
|
+
? getISOWeek(date)
|
|
1821
|
+
: getWeek(date, options);
|
|
1823
1822
|
var existingWeek = result.find(function (value) { return value.weekNumber === weekNumber; });
|
|
1824
1823
|
if (existingWeek) {
|
|
1825
1824
|
existingWeek.dates.push(date);
|
|
@@ -1838,12 +1837,10 @@ function daysToMonthWeeks(fromDate, toDate, options) {
|
|
|
1838
1837
|
* Return the weeks belonging to the given month, adding the "outside days" to
|
|
1839
1838
|
* the first and last week.
|
|
1840
1839
|
*/
|
|
1841
|
-
function getMonthWeeks(
|
|
1842
|
-
/** The month to get the weeks from */
|
|
1843
|
-
month, options) {
|
|
1840
|
+
function getMonthWeeks(month, options) {
|
|
1844
1841
|
var weeksInMonth = daysToMonthWeeks(startOfMonth(month), endOfMonth(month), options);
|
|
1845
|
-
// Add extra weeks to the month, up to 6 weeks
|
|
1846
1842
|
if (options === null || options === void 0 ? void 0 : options.useFixedWeeks) {
|
|
1843
|
+
// Add extra weeks to the month, up to 6 weeks
|
|
1847
1844
|
var nrOfMonthWeeks = getWeeksInMonth(month, options);
|
|
1848
1845
|
if (nrOfMonthWeeks < 6) {
|
|
1849
1846
|
var lastWeek = weeksInMonth[weeksInMonth.length - 1];
|
|
@@ -1859,11 +1856,13 @@ month, options) {
|
|
|
1859
1856
|
/** Render the table with the calendar. */
|
|
1860
1857
|
function Table(props) {
|
|
1861
1858
|
var _a, _b, _c;
|
|
1862
|
-
var _d = useDayPicker(), locale = _d.locale, classNames = _d.classNames, styles = _d.styles, hideHead = _d.hideHead, fixedWeeks = _d.fixedWeeks, components = _d.components, weekStartsOn = _d.weekStartsOn;
|
|
1859
|
+
var _d = useDayPicker(), locale = _d.locale, classNames = _d.classNames, styles = _d.styles, hideHead = _d.hideHead, fixedWeeks = _d.fixedWeeks, components = _d.components, weekStartsOn = _d.weekStartsOn, firstWeekContainsDate = _d.firstWeekContainsDate, ISOWeek = _d.ISOWeek;
|
|
1863
1860
|
var weeks = getMonthWeeks(props.displayMonth, {
|
|
1864
1861
|
useFixedWeeks: Boolean(fixedWeeks),
|
|
1862
|
+
ISOWeek: ISOWeek,
|
|
1865
1863
|
locale: locale,
|
|
1866
|
-
weekStartsOn: weekStartsOn
|
|
1864
|
+
weekStartsOn: weekStartsOn,
|
|
1865
|
+
firstWeekContainsDate: firstWeekContainsDate
|
|
1867
1866
|
});
|
|
1868
1867
|
var HeadComponent = (_a = components === null || components === void 0 ? void 0 : components.Head) !== null && _a !== void 0 ? _a : Head;
|
|
1869
1868
|
var RowComponent = (_b = components === null || components === void 0 ? void 0 : components.Row) !== null && _b !== void 0 ? _b : Row;
|
|
@@ -1958,7 +1957,7 @@ function Month(props) {
|
|
|
1958
1957
|
var dayPicker = useDayPicker();
|
|
1959
1958
|
var dir = dayPicker.dir, classNames = dayPicker.classNames, styles = dayPicker.styles, components = dayPicker.components;
|
|
1960
1959
|
var displayMonths = useNavigation().displayMonths;
|
|
1961
|
-
var captionId = useId();
|
|
1960
|
+
var captionId = useId(dayPicker.id ? "".concat(dayPicker.id, "-").concat(props.displayIndex) : undefined);
|
|
1962
1961
|
var className = [classNames.month];
|
|
1963
1962
|
var style = styles.month;
|
|
1964
1963
|
var isStart = props.displayIndex === 0;
|