react-day-picker 8.0.0 → 8.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/components/Caption/Caption.d.ts +2 -2
- package/dist/components/CaptionDropdowns/CaptionDropdowns.d.ts +5 -0
- package/dist/components/CaptionDropdowns/index.d.ts +1 -0
- package/dist/components/CaptionNavigation/CaptionNavigation.d.ts +5 -0
- package/dist/components/CaptionNavigation/index.d.ts +1 -0
- package/dist/components/Head/utils/getWeekdays.d.ts +4 -2
- package/dist/components/Table/utils/daysToMonthWeeks.d.ts +1 -1
- package/dist/components/Table/utils/getMonthWeeks.d.ts +1 -1
- package/dist/contexts/DayPicker/formatters/formatCaption.d.ts +1 -1
- package/dist/contexts/DayPicker/formatters/formatDay.d.ts +1 -1
- package/dist/contexts/DayPicker/formatters/formatMonthCaption.d.ts +1 -1
- package/dist/contexts/DayPicker/formatters/formatWeekdayName.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +145 -96
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +272 -196
- package/dist/index.js.map +1 -1
- package/dist/types/DayPickerBase.d.ts +5 -1
- package/dist/types/Labels.d.ts +1 -1
- package/package.json +15 -16
- package/CHANGELOG.md +0 -22
- package/dist/react-day-picker.min.js +0 -1
package/README.md
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
DayPicker is a date picker component for [React](https://reactjs.org).
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
$ npm install react-day-picker date-fns
|
|
7
|
-
$
|
|
6
|
+
$ npm install react-day-picker date-fns # using npm
|
|
7
|
+
$ pnpm install react-day-picker date-fns # using pnpm
|
|
8
|
+
$ yarn add react-day-picker date-fns # using yarn
|
|
8
9
|
```
|
|
9
10
|
|
|
10
11
|
<a href="https://www.npmjs.com/package/react-day-picker">
|
|
@@ -13,7 +13,7 @@ export interface CaptionProps {
|
|
|
13
13
|
*/
|
|
14
14
|
export declare type CaptionLayout = 'dropdown' | 'buttons';
|
|
15
15
|
/**
|
|
16
|
-
* Render the caption of a month
|
|
17
|
-
*
|
|
16
|
+
* Render the caption of a month. The caption has a different layout when
|
|
17
|
+
* setting the [[DayPickerProps.captionLayout]] prop.
|
|
18
18
|
*/
|
|
19
19
|
export declare function Caption(props: CaptionProps): JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CaptionDropdowns';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CaptionNavigation';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { Locale } from 'date-fns';
|
|
1
|
+
import type { Locale } from 'date-fns';
|
|
2
2
|
/**
|
|
3
3
|
* Generate a series of 7 days, starting from the week, to use for formatting
|
|
4
4
|
* the weekday names (Monday, Tuesday, etc.).
|
|
5
5
|
*/
|
|
6
|
-
export declare function getWeekdays(locale?: Locale
|
|
6
|
+
export declare function getWeekdays(locale?: Locale,
|
|
7
|
+
/** The index of the first day of the week (0 - Sunday) */
|
|
8
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6): Date[];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from './DayPicker';
|
|
2
2
|
export * from './components/Button';
|
|
3
3
|
export * from './components/Caption';
|
|
4
|
+
export * from './components/CaptionDropdowns';
|
|
4
5
|
export * from './components/CaptionLabel';
|
|
6
|
+
export * from './components/CaptionNavigation';
|
|
5
7
|
export * from './components/Day';
|
|
6
8
|
export * from './components/DayContent';
|
|
7
9
|
export * from './components/Dropdown';
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
import React, { useLayoutEffect, useEffect, useState, createContext, useContext, forwardRef, useRef } from 'react';
|
|
2
|
-
import { format, startOfDay, startOfMonth, isSameYear, setMonth, setYear, startOfYear, differenceInCalendarMonths, addMonths, isSameMonth, isBefore, startOfWeek, addDays, isSameDay, isAfter, differenceInCalendarDays, isDate, endOfMonth, addWeeks, endOfWeek, addYears, getUnixTime, getWeek, getWeeksInMonth, parse } from 'date-fns';
|
|
3
2
|
import enUS from 'date-fns/locale/en-US';
|
|
3
|
+
import format from 'date-fns/format';
|
|
4
|
+
import endOfMonth from 'date-fns/endOfMonth';
|
|
5
|
+
import startOfDay from 'date-fns/startOfDay';
|
|
6
|
+
import startOfMonth from 'date-fns/startOfMonth';
|
|
7
|
+
import isSameYear from 'date-fns/isSameYear';
|
|
8
|
+
import setMonth from 'date-fns/setMonth';
|
|
9
|
+
import setYear from 'date-fns/setYear';
|
|
10
|
+
import startOfYear from 'date-fns/startOfYear';
|
|
11
|
+
import addMonths from 'date-fns/addMonths';
|
|
12
|
+
import isBefore from 'date-fns/isBefore';
|
|
13
|
+
import isSameMonth from 'date-fns/isSameMonth';
|
|
14
|
+
import differenceInCalendarMonths from 'date-fns/differenceInCalendarMonths';
|
|
15
|
+
import addDays from 'date-fns/addDays';
|
|
16
|
+
import startOfWeek from 'date-fns/startOfWeek';
|
|
17
|
+
import getUnixTime from 'date-fns/getUnixTime';
|
|
18
|
+
import isSameDay from 'date-fns/isSameDay';
|
|
19
|
+
import addWeeks from 'date-fns/addWeeks';
|
|
20
|
+
import addYears from 'date-fns/addYears';
|
|
21
|
+
import endOfWeek from 'date-fns/endOfWeek';
|
|
22
|
+
import differenceInCalendarDays from 'date-fns/differenceInCalendarDays';
|
|
23
|
+
import isAfter from 'date-fns/isAfter';
|
|
24
|
+
import isDate from 'date-fns/isDate';
|
|
25
|
+
import getWeeksInMonth from 'date-fns/getWeeksInMonth';
|
|
26
|
+
import getWeek from 'date-fns/getWeek';
|
|
27
|
+
import parse from 'date-fns/parse';
|
|
4
28
|
|
|
5
29
|
/*! *****************************************************************************
|
|
6
30
|
Copyright (c) Microsoft Corporation.
|
|
@@ -389,7 +413,7 @@ function parseFromToProps(props) {
|
|
|
389
413
|
fromDate = new Date(fromYear, 0, 1);
|
|
390
414
|
}
|
|
391
415
|
if (toMonth) {
|
|
392
|
-
toDate =
|
|
416
|
+
toDate = endOfMonth(toMonth);
|
|
393
417
|
}
|
|
394
418
|
else if (toYear) {
|
|
395
419
|
toDate = new Date(toYear, 11, 31);
|
|
@@ -470,7 +494,8 @@ function DayPickerProvider(props) {
|
|
|
470
494
|
style: initialProps.style,
|
|
471
495
|
styles: __assign(__assign({}, defaults.styles), initialProps.styles),
|
|
472
496
|
toDate: toDate,
|
|
473
|
-
today: (_d = initialProps.today) !== null && _d !== void 0 ? _d : defaults.today
|
|
497
|
+
today: (_d = initialProps.today) !== null && _d !== void 0 ? _d : defaults.today,
|
|
498
|
+
weekStartsOn: initialProps.weekStartsOn
|
|
474
499
|
};
|
|
475
500
|
return (React.createElement(DayPickerContext.Provider, { value: value }, props.children));
|
|
476
501
|
}
|
|
@@ -553,63 +578,6 @@ function MonthsDropdown(props) {
|
|
|
553
578
|
return (React.createElement(DropdownComponent, { "aria-label": labelMonthDropdown(), className: classNames.dropdown_month, style: styles.dropdown_month, onChange: handleChange, value: props.displayMonth.getMonth(), caption: formatMonthCaption(props.displayMonth, { locale: locale }) }, dropdownMonths.map(function (m) { return (React.createElement("option", { key: m.getMonth(), value: m.getMonth() }, formatMonthCaption(m, { locale: locale }))); })));
|
|
554
579
|
}
|
|
555
580
|
|
|
556
|
-
/**
|
|
557
|
-
* Render the "previous month" button in the navigation.
|
|
558
|
-
*/
|
|
559
|
-
function IconLeft(props) {
|
|
560
|
-
return (React.createElement("svg", __assign({ width: "16px", height: "16px", viewBox: "0 0 120 120" }, props),
|
|
561
|
-
React.createElement("path", { d: "M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z", fill: "currentColor", fillRule: "nonzero" })));
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* Render the "next month" button in the navigation.
|
|
566
|
-
*/
|
|
567
|
-
function IconRight(props) {
|
|
568
|
-
return (React.createElement("svg", __assign({ width: "16px", height: "16px", viewBox: "0 0 120 120" }, props),
|
|
569
|
-
React.createElement("path", { d: "M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z", fill: "currentColor" })));
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
/**
|
|
573
|
-
* Render a button HTML element applying the reset class name.
|
|
574
|
-
*/
|
|
575
|
-
var Button = forwardRef(function (props, ref) {
|
|
576
|
-
var _a = useDayPicker(), classNames = _a.classNames, styles = _a.styles;
|
|
577
|
-
var classNamesArr = [classNames.button_reset, classNames.button];
|
|
578
|
-
if (props.className) {
|
|
579
|
-
classNamesArr.push(props.className);
|
|
580
|
-
}
|
|
581
|
-
var className = classNamesArr.join(' ');
|
|
582
|
-
var style = __assign(__assign({}, styles.button_reset), styles.button);
|
|
583
|
-
if (props.style) {
|
|
584
|
-
Object.assign(style, props.style);
|
|
585
|
-
}
|
|
586
|
-
return (React.createElement("button", __assign({}, props, { ref: ref, type: "button", className: className, style: style })));
|
|
587
|
-
});
|
|
588
|
-
|
|
589
|
-
/** A component rendering the navigation buttons or the drop-downs. */
|
|
590
|
-
function Navigation(props) {
|
|
591
|
-
var _a, _b;
|
|
592
|
-
var _c = useDayPicker(), dir = _c.dir, locale = _c.locale, classNames = _c.classNames, styles = _c.styles, _d = _c.labels, labelPrevious = _d.labelPrevious, labelNext = _d.labelNext, components = _c.components;
|
|
593
|
-
if (!props.nextMonth && !props.previousMonth) {
|
|
594
|
-
return React.createElement(React.Fragment, null);
|
|
595
|
-
}
|
|
596
|
-
var previousLabel = labelPrevious(props.previousMonth, { locale: locale });
|
|
597
|
-
var previousClassName = [
|
|
598
|
-
classNames.nav_button,
|
|
599
|
-
classNames.nav_button_previous
|
|
600
|
-
].join(' ');
|
|
601
|
-
var nextLabel = labelNext(props.nextMonth, { locale: locale });
|
|
602
|
-
var nextClassName = [
|
|
603
|
-
classNames.nav_button,
|
|
604
|
-
classNames.nav_button_next
|
|
605
|
-
].join(' ');
|
|
606
|
-
var IconRightComponent = (_a = components === null || components === void 0 ? void 0 : components.IconRight) !== null && _a !== void 0 ? _a : IconRight;
|
|
607
|
-
var IconLeftComponent = (_b = components === null || components === void 0 ? void 0 : components.IconLeft) !== null && _b !== void 0 ? _b : IconLeft;
|
|
608
|
-
return (React.createElement("div", { className: classNames.nav, style: styles.nav },
|
|
609
|
-
!props.hidePrevious && (React.createElement(Button, { "aria-label": previousLabel, className: previousClassName, style: styles.nav_button_previous, disabled: !props.previousMonth, onClick: props.onPreviousClick }, dir === 'rtl' ? (React.createElement(IconRightComponent, { className: classNames.nav_icon, style: styles.nav_icon })) : (React.createElement(IconLeftComponent, { className: classNames.nav_icon, style: styles.nav_icon })))),
|
|
610
|
-
!props.hideNext && (React.createElement(Button, { "aria-label": nextLabel, className: nextClassName, style: styles.nav_button_next, disabled: !props.nextMonth, onClick: props.onNextClick }, dir === 'rtl' ? (React.createElement(IconLeftComponent, { className: classNames.nav_icon, style: styles.nav_icon })) : (React.createElement(IconRightComponent, { className: classNames.nav_icon, style: styles.nav_icon }))))));
|
|
611
|
-
}
|
|
612
|
-
|
|
613
581
|
/**
|
|
614
582
|
* Render a dropdown to change the year. Take in account the `nav.fromDate` and
|
|
615
583
|
* `toDate` from context.
|
|
@@ -809,30 +777,89 @@ function useNavigation() {
|
|
|
809
777
|
}
|
|
810
778
|
|
|
811
779
|
/**
|
|
812
|
-
* Render
|
|
813
|
-
* The caption has a different layout when setting the [[DayPickerProps.captionLayout]] prop.
|
|
780
|
+
* Render a caption with the dropdowns to navigate between months and years.
|
|
814
781
|
*/
|
|
815
|
-
function
|
|
782
|
+
function CaptionDropdowns(props) {
|
|
816
783
|
var _a;
|
|
817
|
-
var _b;
|
|
818
|
-
var
|
|
819
|
-
var _d = useNavigation(), previousMonth = _d.previousMonth, nextMonth = _d.nextMonth, goToMonth = _d.goToMonth, displayMonths = _d.displayMonths;
|
|
820
|
-
var handlePreviousClick = function () {
|
|
821
|
-
if (!previousMonth)
|
|
822
|
-
return;
|
|
823
|
-
goToMonth(previousMonth);
|
|
824
|
-
onMonthChange === null || onMonthChange === void 0 ? void 0 : onMonthChange(previousMonth);
|
|
825
|
-
};
|
|
826
|
-
var handleNextClick = function () {
|
|
827
|
-
if (!nextMonth)
|
|
828
|
-
return;
|
|
829
|
-
goToMonth(nextMonth);
|
|
830
|
-
onMonthChange === null || onMonthChange === void 0 ? void 0 : onMonthChange(nextMonth);
|
|
831
|
-
};
|
|
784
|
+
var _b = useDayPicker(), classNames = _b.classNames, styles = _b.styles, onMonthChange = _b.onMonthChange, components = _b.components;
|
|
785
|
+
var goToMonth = useNavigation().goToMonth;
|
|
832
786
|
var handleMonthChange = function (newMonth) {
|
|
833
787
|
goToMonth(newMonth);
|
|
834
788
|
onMonthChange === null || onMonthChange === void 0 ? void 0 : onMonthChange(newMonth);
|
|
835
789
|
};
|
|
790
|
+
var CaptionLabelComponent = (_a = components === null || components === void 0 ? void 0 : components.CaptionLabel) !== null && _a !== void 0 ? _a : CaptionLabel;
|
|
791
|
+
var captionLabel = (React.createElement(CaptionLabelComponent, { id: props.id, displayMonth: props.displayMonth }));
|
|
792
|
+
return (React.createElement("div", { className: classNames.caption_dropdowns, style: styles.caption_dropdowns },
|
|
793
|
+
React.createElement("div", { className: classNames.vhidden }, captionLabel),
|
|
794
|
+
React.createElement(MonthsDropdown, { onChange: handleMonthChange, displayMonth: props.displayMonth }),
|
|
795
|
+
React.createElement(YearsDropdown, { onChange: handleMonthChange, displayMonth: props.displayMonth })));
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* Render the "previous month" button in the navigation.
|
|
800
|
+
*/
|
|
801
|
+
function IconLeft(props) {
|
|
802
|
+
return (React.createElement("svg", __assign({ width: "16px", height: "16px", viewBox: "0 0 120 120" }, props),
|
|
803
|
+
React.createElement("path", { d: "M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z", fill: "currentColor", fillRule: "nonzero" })));
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* Render the "next month" button in the navigation.
|
|
808
|
+
*/
|
|
809
|
+
function IconRight(props) {
|
|
810
|
+
return (React.createElement("svg", __assign({ width: "16px", height: "16px", viewBox: "0 0 120 120" }, props),
|
|
811
|
+
React.createElement("path", { d: "M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z", fill: "currentColor" })));
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Render a button HTML element applying the reset class name.
|
|
816
|
+
*/
|
|
817
|
+
var Button = forwardRef(function (props, ref) {
|
|
818
|
+
var _a = useDayPicker(), classNames = _a.classNames, styles = _a.styles;
|
|
819
|
+
var classNamesArr = [classNames.button_reset, classNames.button];
|
|
820
|
+
if (props.className) {
|
|
821
|
+
classNamesArr.push(props.className);
|
|
822
|
+
}
|
|
823
|
+
var className = classNamesArr.join(' ');
|
|
824
|
+
var style = __assign(__assign({}, styles.button_reset), styles.button);
|
|
825
|
+
if (props.style) {
|
|
826
|
+
Object.assign(style, props.style);
|
|
827
|
+
}
|
|
828
|
+
return (React.createElement("button", __assign({}, props, { ref: ref, type: "button", className: className, style: style })));
|
|
829
|
+
});
|
|
830
|
+
|
|
831
|
+
/** A component rendering the navigation buttons or the drop-downs. */
|
|
832
|
+
function Navigation(props) {
|
|
833
|
+
var _a, _b;
|
|
834
|
+
var _c = useDayPicker(), dir = _c.dir, locale = _c.locale, classNames = _c.classNames, styles = _c.styles, _d = _c.labels, labelPrevious = _d.labelPrevious, labelNext = _d.labelNext, components = _c.components;
|
|
835
|
+
if (!props.nextMonth && !props.previousMonth) {
|
|
836
|
+
return React.createElement(React.Fragment, null);
|
|
837
|
+
}
|
|
838
|
+
var previousLabel = labelPrevious(props.previousMonth, { locale: locale });
|
|
839
|
+
var previousClassName = [
|
|
840
|
+
classNames.nav_button,
|
|
841
|
+
classNames.nav_button_previous
|
|
842
|
+
].join(' ');
|
|
843
|
+
var nextLabel = labelNext(props.nextMonth, { locale: locale });
|
|
844
|
+
var nextClassName = [
|
|
845
|
+
classNames.nav_button,
|
|
846
|
+
classNames.nav_button_next
|
|
847
|
+
].join(' ');
|
|
848
|
+
var IconRightComponent = (_a = components === null || components === void 0 ? void 0 : components.IconRight) !== null && _a !== void 0 ? _a : IconRight;
|
|
849
|
+
var IconLeftComponent = (_b = components === null || components === void 0 ? void 0 : components.IconLeft) !== null && _b !== void 0 ? _b : IconLeft;
|
|
850
|
+
return (React.createElement("div", { className: classNames.nav, style: styles.nav },
|
|
851
|
+
!props.hidePrevious && (React.createElement(Button, { "aria-label": previousLabel, className: previousClassName, style: styles.nav_button_previous, disabled: !props.previousMonth, onClick: props.onPreviousClick }, dir === 'rtl' ? (React.createElement(IconRightComponent, { className: classNames.nav_icon, style: styles.nav_icon })) : (React.createElement(IconLeftComponent, { className: classNames.nav_icon, style: styles.nav_icon })))),
|
|
852
|
+
!props.hideNext && (React.createElement(Button, { "aria-label": nextLabel, className: nextClassName, style: styles.nav_button_next, disabled: !props.nextMonth, onClick: props.onNextClick }, dir === 'rtl' ? (React.createElement(IconLeftComponent, { className: classNames.nav_icon, style: styles.nav_icon })) : (React.createElement(IconRightComponent, { className: classNames.nav_icon, style: styles.nav_icon }))))));
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Render a caption with a button-based navigation.
|
|
857
|
+
*/
|
|
858
|
+
function CaptionNavigation(props) {
|
|
859
|
+
var _a;
|
|
860
|
+
var _b;
|
|
861
|
+
var _c = useDayPicker(), numberOfMonths = _c.numberOfMonths, onMonthChange = _c.onMonthChange, dir = _c.dir, components = _c.components;
|
|
862
|
+
var _d = useNavigation(), previousMonth = _d.previousMonth, nextMonth = _d.nextMonth, goToMonth = _d.goToMonth, displayMonths = _d.displayMonths;
|
|
836
863
|
var displayIndex = displayMonths.findIndex(function (month) {
|
|
837
864
|
return isSameMonth(props.displayMonth, month);
|
|
838
865
|
});
|
|
@@ -843,24 +870,44 @@ function Caption(props) {
|
|
|
843
870
|
}
|
|
844
871
|
var hideNext = numberOfMonths > 1 && (isFirst || !isLast);
|
|
845
872
|
var hidePrevious = numberOfMonths > 1 && (isLast || !isFirst);
|
|
873
|
+
var handlePreviousClick = function () {
|
|
874
|
+
if (!previousMonth)
|
|
875
|
+
return;
|
|
876
|
+
goToMonth(previousMonth);
|
|
877
|
+
onMonthChange === null || onMonthChange === void 0 ? void 0 : onMonthChange(previousMonth);
|
|
878
|
+
};
|
|
879
|
+
var handleNextClick = function () {
|
|
880
|
+
if (!nextMonth)
|
|
881
|
+
return;
|
|
882
|
+
goToMonth(nextMonth);
|
|
883
|
+
onMonthChange === null || onMonthChange === void 0 ? void 0 : onMonthChange(nextMonth);
|
|
884
|
+
};
|
|
846
885
|
var CaptionLabelComponent = (_b = components === null || components === void 0 ? void 0 : components.CaptionLabel) !== null && _b !== void 0 ? _b : CaptionLabel;
|
|
847
886
|
var captionLabel = (React.createElement(CaptionLabelComponent, { id: props.id, displayMonth: props.displayMonth }));
|
|
848
|
-
|
|
887
|
+
return (React.createElement(React.Fragment, null,
|
|
888
|
+
captionLabel,
|
|
889
|
+
React.createElement(Navigation, { displayMonth: props.displayMonth, hideNext: hideNext, hidePrevious: hidePrevious, nextMonth: nextMonth, previousMonth: previousMonth, onPreviousClick: handlePreviousClick, onNextClick: handleNextClick })));
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
/**
|
|
893
|
+
* Render the caption of a month. The caption has a different layout when
|
|
894
|
+
* setting the [[DayPickerProps.captionLayout]] prop.
|
|
895
|
+
*/
|
|
896
|
+
function Caption(props) {
|
|
897
|
+
var _a;
|
|
898
|
+
var _b = useDayPicker(), classNames = _b.classNames, disableNavigation = _b.disableNavigation, styles = _b.styles, captionLayout = _b.captionLayout, components = _b.components;
|
|
899
|
+
var CaptionLabelComponent = (_a = components === null || components === void 0 ? void 0 : components.CaptionLabel) !== null && _a !== void 0 ? _a : CaptionLabel;
|
|
900
|
+
var caption;
|
|
849
901
|
if (disableNavigation) {
|
|
850
|
-
|
|
902
|
+
caption = (React.createElement(CaptionLabelComponent, { id: props.id, displayMonth: props.displayMonth }));
|
|
851
903
|
}
|
|
852
904
|
else if (captionLayout === 'dropdown') {
|
|
853
|
-
|
|
854
|
-
React.createElement("div", { className: classNames.vhidden }, captionLabel),
|
|
855
|
-
React.createElement(MonthsDropdown, { onChange: handleMonthChange, displayMonth: props.displayMonth }),
|
|
856
|
-
React.createElement(YearsDropdown, { onChange: handleMonthChange, displayMonth: props.displayMonth })));
|
|
905
|
+
caption = (React.createElement(CaptionDropdowns, { displayMonth: props.displayMonth, id: props.id }));
|
|
857
906
|
}
|
|
858
907
|
else {
|
|
859
|
-
|
|
860
|
-
captionLabel,
|
|
861
|
-
React.createElement(Navigation, { displayMonth: props.displayMonth, hideNext: hideNext, hidePrevious: hidePrevious, nextMonth: nextMonth, previousMonth: previousMonth, onPreviousClick: handlePreviousClick, onNextClick: handleNextClick })));
|
|
908
|
+
caption = (React.createElement(CaptionNavigation, { displayMonth: props.displayMonth, id: props.id }));
|
|
862
909
|
}
|
|
863
|
-
return (React.createElement("div", { className: classNames.caption, style: styles.caption },
|
|
910
|
+
return (React.createElement("div", { className: classNames.caption, style: styles.caption }, caption));
|
|
864
911
|
}
|
|
865
912
|
|
|
866
913
|
/** Render the Footer component (empty as default).*/
|
|
@@ -877,8 +924,10 @@ function Footer() {
|
|
|
877
924
|
* Generate a series of 7 days, starting from the week, to use for formatting
|
|
878
925
|
* the weekday names (Monday, Tuesday, etc.).
|
|
879
926
|
*/
|
|
880
|
-
function getWeekdays(locale
|
|
881
|
-
|
|
927
|
+
function getWeekdays(locale,
|
|
928
|
+
/** The index of the first day of the week (0 - Sunday) */
|
|
929
|
+
weekStartsOn) {
|
|
930
|
+
var start = startOfWeek(new Date(), { locale: locale, weekStartsOn: weekStartsOn });
|
|
882
931
|
var days = [];
|
|
883
932
|
for (var i = 0; i < 7; i++) {
|
|
884
933
|
var day = addDays(start, i);
|
|
@@ -891,8 +940,8 @@ function getWeekdays(locale) {
|
|
|
891
940
|
* Render the Head component - i.e. the table head with the weekday names.
|
|
892
941
|
*/
|
|
893
942
|
function Head() {
|
|
894
|
-
var _a = useDayPicker(), classNames = _a.classNames, styles = _a.styles, showWeekNumber = _a.showWeekNumber, locale = _a.locale, formatWeekdayName = _a.formatters.formatWeekdayName, labelWeekday = _a.labels.labelWeekday;
|
|
895
|
-
var weekdays = getWeekdays(locale);
|
|
943
|
+
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;
|
|
944
|
+
var weekdays = getWeekdays(locale, weekStartsOn);
|
|
896
945
|
return (React.createElement("thead", { style: styles.head, className: classNames.head },
|
|
897
946
|
React.createElement("tr", { style: styles.head_row, className: classNames.head_row },
|
|
898
947
|
showWeekNumber && (React.createElement("th", { scope: "col", style: styles.head_cell, className: classNames.head_cell })),
|
|
@@ -1234,7 +1283,6 @@ function isDateInterval(matcher) {
|
|
|
1234
1283
|
}
|
|
1235
1284
|
/** Returns true if `value` is a [[DateRange]] type. */
|
|
1236
1285
|
function isDateRange(value) {
|
|
1237
|
-
// TODO: Check if dates?!
|
|
1238
1286
|
return Boolean(value && typeof value === 'object' && 'from' in value);
|
|
1239
1287
|
}
|
|
1240
1288
|
/** Returns true if `value` is of type [[DateAfter]]. */
|
|
@@ -1930,10 +1978,11 @@ month, options) {
|
|
|
1930
1978
|
/** Render the table with the calendar. */
|
|
1931
1979
|
function Table(props) {
|
|
1932
1980
|
var _a, _b, _c;
|
|
1933
|
-
var _d = useDayPicker(), locale = _d.locale, classNames = _d.classNames, styles = _d.styles, hideHead = _d.hideHead, fixedWeeks = _d.fixedWeeks, components = _d.components;
|
|
1981
|
+
var _d = useDayPicker(), locale = _d.locale, classNames = _d.classNames, styles = _d.styles, hideHead = _d.hideHead, fixedWeeks = _d.fixedWeeks, components = _d.components, weekStartsOn = _d.weekStartsOn;
|
|
1934
1982
|
var weeks = getMonthWeeks(props.displayMonth, {
|
|
1935
1983
|
useFixedWeeks: Boolean(fixedWeeks),
|
|
1936
|
-
locale: locale
|
|
1984
|
+
locale: locale,
|
|
1985
|
+
weekStartsOn: weekStartsOn
|
|
1937
1986
|
});
|
|
1938
1987
|
var HeadComponent = (_a = components === null || components === void 0 ? void 0 : components.Head) !== null && _a !== void 0 ? _a : Head;
|
|
1939
1988
|
var RowComponent = (_b = components === null || components === void 0 ? void 0 : components.Row) !== null && _b !== void 0 ? _b : Row;
|
|
@@ -2134,5 +2183,5 @@ function isDayPickerDefault(props) {
|
|
|
2134
2183
|
return props.mode === undefined || props.mode === 'default';
|
|
2135
2184
|
}
|
|
2136
2185
|
|
|
2137
|
-
export { Button, Caption, CaptionLabel, Day, DayContent, DayPicker, DayPickerContext, DayPickerProvider, Dropdown, FocusContext, FocusProvider, Footer, Head, IconDropdown, IconLeft, IconRight, InternalModifier, NavigationContext, NavigationProvider, RootProvider, Row, SelectMultipleContext, SelectMultipleProvider, SelectMultipleProviderInternal, SelectRangeContext, SelectRangeProvider, SelectRangeProviderInternal, SelectSingleContext, SelectSingleProvider, SelectSingleProviderInternal, WeekNumber, isDateAfterType, isDateBeforeType, isDateInterval, isDateRange, isDayOfWeekType, isDayPickerDefault, isDayPickerMultiple, isDayPickerRange, isDayPickerSingle, isMatch, useActiveModifiers, useDayPicker, useDayRender, useFocusContext, useInput, useNavigation, useSelectMultiple, useSelectRange, useSelectSingle };
|
|
2186
|
+
export { Button, Caption, CaptionDropdowns, CaptionLabel, CaptionNavigation, Day, DayContent, DayPicker, DayPickerContext, DayPickerProvider, Dropdown, FocusContext, FocusProvider, Footer, Head, IconDropdown, IconLeft, IconRight, InternalModifier, NavigationContext, NavigationProvider, RootProvider, Row, SelectMultipleContext, SelectMultipleProvider, SelectMultipleProviderInternal, SelectRangeContext, SelectRangeProvider, SelectRangeProviderInternal, SelectSingleContext, SelectSingleProvider, SelectSingleProviderInternal, WeekNumber, isDateAfterType, isDateBeforeType, isDateInterval, isDateRange, isDayOfWeekType, isDayPickerDefault, isDayPickerMultiple, isDayPickerRange, isDayPickerSingle, isMatch, useActiveModifiers, useDayPicker, useDayRender, useFocusContext, useInput, useNavigation, useSelectMultiple, useSelectRange, useSelectSingle };
|
|
2138
2187
|
//# sourceMappingURL=index.esm.js.map
|