@fluentui/react-datepicker-compat 0.1.4 → 0.1.6
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/CHANGELOG.json +169 -1
- package/CHANGELOG.md +43 -2
- package/dist/index.d.ts +4 -1
- package/lib/Calendar.js +0 -1
- package/lib/Calendar.js.map +1 -1
- package/lib/CalendarDay.js +0 -1
- package/lib/CalendarDay.js.map +1 -1
- package/lib/CalendarDayGrid.js +0 -1
- package/lib/CalendarDayGrid.js.map +1 -1
- package/lib/CalendarMonth.js +0 -1
- package/lib/CalendarMonth.js.map +1 -1
- package/lib/CalendarPicker.js +0 -1
- package/lib/CalendarPicker.js.map +1 -1
- package/lib/CalendarYear.js +0 -1
- package/lib/CalendarYear.js.map +1 -1
- package/lib/DatePicker.js +0 -1
- package/lib/DatePicker.js.map +1 -1
- package/lib/components/Calendar/Calendar.js +278 -300
- package/lib/components/Calendar/Calendar.js.map +1 -1
- package/lib/components/Calendar/Calendar.types.js +7 -12
- package/lib/components/Calendar/Calendar.types.js.map +1 -1
- package/lib/components/Calendar/defaults.js +0 -1
- package/lib/components/Calendar/defaults.js.map +1 -1
- package/lib/components/Calendar/index.js +0 -1
- package/lib/components/Calendar/index.js.map +1 -1
- package/lib/components/Calendar/useCalendarStyles.styles.js.map +1 -1
- package/lib/components/CalendarDay/CalendarDay.js +100 -128
- package/lib/components/CalendarDay/CalendarDay.js.map +1 -1
- package/lib/components/CalendarDay/CalendarDay.types.js +0 -1
- package/lib/components/CalendarDay/CalendarDay.types.js.map +1 -1
- package/lib/components/CalendarDay/index.js +0 -1
- package/lib/components/CalendarDay/index.js.map +1 -1
- package/lib/components/CalendarDay/useCalendarDayStyles.styles.js.map +1 -1
- package/lib/components/CalendarDayGrid/CalendarDayGrid.js +146 -159
- package/lib/components/CalendarDayGrid/CalendarDayGrid.js.map +1 -1
- package/lib/components/CalendarDayGrid/CalendarDayGrid.types.js +0 -1
- package/lib/components/CalendarDayGrid/CalendarDayGrid.types.js.map +1 -1
- package/lib/components/CalendarDayGrid/CalendarGridDayCell.js +150 -179
- package/lib/components/CalendarDayGrid/CalendarGridDayCell.js.map +1 -1
- package/lib/components/CalendarDayGrid/CalendarGridRow.js +20 -34
- package/lib/components/CalendarDayGrid/CalendarGridRow.js.map +1 -1
- package/lib/components/CalendarDayGrid/CalendarMonthHeaderRow.js +29 -39
- package/lib/components/CalendarDayGrid/CalendarMonthHeaderRow.js.map +1 -1
- package/lib/components/CalendarDayGrid/index.js +0 -1
- package/lib/components/CalendarDayGrid/index.js.map +1 -1
- package/lib/components/CalendarDayGrid/useCalendarDayGridStyles.styles.js.map +1 -1
- package/lib/components/CalendarDayGrid/useWeekCornerStyles.styles.js.map +1 -1
- package/lib/components/CalendarDayGrid/useWeeks.js +34 -36
- package/lib/components/CalendarDayGrid/useWeeks.js.map +1 -1
- package/lib/components/CalendarMonth/CalendarMonth.js +238 -258
- package/lib/components/CalendarMonth/CalendarMonth.js.map +1 -1
- package/lib/components/CalendarMonth/CalendarMonth.types.js +0 -1
- package/lib/components/CalendarMonth/CalendarMonth.types.js.map +1 -1
- package/lib/components/CalendarMonth/index.js +0 -1
- package/lib/components/CalendarMonth/index.js.map +1 -1
- package/lib/components/CalendarMonth/useCalendarMonthStyles.js +2 -4
- package/lib/components/CalendarMonth/useCalendarMonthStyles.js.map +1 -1
- package/lib/components/CalendarPicker/CalendarPicker.types.js +1 -2
- package/lib/components/CalendarPicker/CalendarPicker.types.js.map +1 -1
- package/lib/components/CalendarPicker/index.js +0 -1
- package/lib/components/CalendarPicker/index.js.map +1 -1
- package/lib/components/CalendarPicker/useCalendarPickerStyles.styles.js.map +1 -1
- package/lib/components/CalendarYear/CalendarYear.js +260 -312
- package/lib/components/CalendarYear/CalendarYear.js.map +1 -1
- package/lib/components/CalendarYear/CalendarYear.types.js +0 -1
- package/lib/components/CalendarYear/CalendarYear.types.js.map +1 -1
- package/lib/components/CalendarYear/index.js +0 -1
- package/lib/components/CalendarYear/index.js.map +1 -1
- package/lib/components/CalendarYear/useCalendarYearStyles.styles.js.map +1 -1
- package/lib/components/DatePicker/DatePicker.js +4 -5
- package/lib/components/DatePicker/DatePicker.js.map +1 -1
- package/lib/components/DatePicker/DatePicker.types.js +0 -1
- package/lib/components/DatePicker/DatePicker.types.js.map +1 -1
- package/lib/components/DatePicker/defaults.js +9 -10
- package/lib/components/DatePicker/defaults.js.map +1 -1
- package/lib/components/DatePicker/index.js +0 -1
- package/lib/components/DatePicker/index.js.map +1 -1
- package/lib/components/DatePicker/renderDatePicker.js +5 -12
- package/lib/components/DatePicker/renderDatePicker.js.map +1 -1
- package/lib/components/DatePicker/useDatePicker.js +402 -354
- package/lib/components/DatePicker/useDatePicker.js.map +1 -1
- package/lib/components/DatePicker/useDatePickerStyles.styles.js.map +1 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/utils/animations.js +72 -73
- package/lib/utils/animations.js.map +1 -1
- package/lib/utils/constants.js +50 -52
- package/lib/utils/constants.js.map +1 -1
- package/lib/utils/dateFormatting/dateFormatting.defaults.js +71 -34
- package/lib/utils/dateFormatting/dateFormatting.defaults.js.map +1 -1
- package/lib/utils/dateFormatting/dateFormatting.types.js +1 -2
- package/lib/utils/dateFormatting/dateFormatting.types.js.map +1 -1
- package/lib/utils/dateFormatting/index.js +0 -1
- package/lib/utils/dateFormatting/index.js.map +1 -1
- package/lib/utils/dateGrid/dateGrid.types.js +1 -2
- package/lib/utils/dateGrid/dateGrid.types.js.map +1 -1
- package/lib/utils/dateGrid/findAvailableDate.js +14 -21
- package/lib/utils/dateGrid/findAvailableDate.js.map +1 -1
- package/lib/utils/dateGrid/getBoundedDateRange.js +11 -11
- package/lib/utils/dateGrid/getBoundedDateRange.js.map +1 -1
- package/lib/utils/dateGrid/getDateRangeTypeToUse.js +6 -8
- package/lib/utils/dateGrid/getDateRangeTypeToUse.js.map +1 -1
- package/lib/utils/dateGrid/getDayGrid.js +59 -73
- package/lib/utils/dateGrid/getDayGrid.js.map +1 -1
- package/lib/utils/dateGrid/index.js +0 -1
- package/lib/utils/dateGrid/index.js.map +1 -1
- package/lib/utils/dateGrid/isAfterMaxDate.js +3 -7
- package/lib/utils/dateGrid/isAfterMaxDate.js.map +1 -1
- package/lib/utils/dateGrid/isBeforeMinDate.js +3 -7
- package/lib/utils/dateGrid/isBeforeMinDate.js.map +1 -1
- package/lib/utils/dateGrid/isContiguous.js +11 -12
- package/lib/utils/dateGrid/isContiguous.js.map +1 -1
- package/lib/utils/dateGrid/isRestrictedDate.js +7 -13
- package/lib/utils/dateGrid/isRestrictedDate.js.map +1 -1
- package/lib/utils/dateMath/dateMath.js +179 -198
- package/lib/utils/dateMath/dateMath.js.map +1 -1
- package/lib/utils/dateMath/index.js +0 -1
- package/lib/utils/dateMath/index.js.map +1 -1
- package/lib/utils/dom.js +5 -6
- package/lib/utils/dom.js.map +1 -1
- package/lib/utils/focus.js +17 -19
- package/lib/utils/focus.js.map +1 -1
- package/lib/utils/index.js +0 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/usePopupPositioning.js +12 -16
- package/lib/utils/usePopupPositioning.js.map +1 -1
- package/lib-commonjs/Calendar.js +0 -3
- package/lib-commonjs/Calendar.js.map +1 -1
- package/lib-commonjs/CalendarDay.js +0 -3
- package/lib-commonjs/CalendarDay.js.map +1 -1
- package/lib-commonjs/CalendarDayGrid.js +0 -3
- package/lib-commonjs/CalendarDayGrid.js.map +1 -1
- package/lib-commonjs/CalendarMonth.js +0 -3
- package/lib-commonjs/CalendarMonth.js.map +1 -1
- package/lib-commonjs/CalendarPicker.js +0 -3
- package/lib-commonjs/CalendarPicker.js.map +1 -1
- package/lib-commonjs/CalendarYear.js +0 -3
- package/lib-commonjs/CalendarYear.js.map +1 -1
- package/lib-commonjs/DatePicker.js +0 -3
- package/lib-commonjs/DatePicker.js.map +1 -1
- package/lib-commonjs/components/Calendar/Calendar.js +1 -3
- package/lib-commonjs/components/Calendar/Calendar.js.map +1 -1
- package/lib-commonjs/components/Calendar/Calendar.types.js +5 -7
- package/lib-commonjs/components/Calendar/Calendar.types.js.map +1 -1
- package/lib-commonjs/components/Calendar/defaults.js +1 -3
- package/lib-commonjs/components/Calendar/defaults.js.map +1 -1
- package/lib-commonjs/components/Calendar/index.js +0 -3
- package/lib-commonjs/components/Calendar/index.js.map +1 -1
- package/lib-commonjs/components/Calendar/useCalendarStyles.styles.js +0 -2
- package/lib-commonjs/components/Calendar/useCalendarStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CalendarDay/CalendarDay.js +1 -3
- package/lib-commonjs/components/CalendarDay/CalendarDay.js.map +1 -1
- package/lib-commonjs/components/CalendarDay/CalendarDay.types.js +0 -3
- package/lib-commonjs/components/CalendarDay/CalendarDay.types.js.map +1 -1
- package/lib-commonjs/components/CalendarDay/index.js +0 -3
- package/lib-commonjs/components/CalendarDay/index.js.map +1 -1
- package/lib-commonjs/components/CalendarDay/useCalendarDayStyles.styles.js +0 -2
- package/lib-commonjs/components/CalendarDay/useCalendarDayStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CalendarDayGrid/CalendarDayGrid.js +7 -9
- package/lib-commonjs/components/CalendarDayGrid/CalendarDayGrid.js.map +1 -1
- package/lib-commonjs/components/CalendarDayGrid/CalendarDayGrid.types.js +0 -3
- package/lib-commonjs/components/CalendarDayGrid/CalendarDayGrid.types.js.map +1 -1
- package/lib-commonjs/components/CalendarDayGrid/CalendarGridDayCell.js +1 -3
- package/lib-commonjs/components/CalendarDayGrid/CalendarGridDayCell.js.map +1 -1
- package/lib-commonjs/components/CalendarDayGrid/CalendarGridRow.js +1 -3
- package/lib-commonjs/components/CalendarDayGrid/CalendarGridRow.js.map +1 -1
- package/lib-commonjs/components/CalendarDayGrid/CalendarMonthHeaderRow.js +1 -3
- package/lib-commonjs/components/CalendarDayGrid/CalendarMonthHeaderRow.js.map +1 -1
- package/lib-commonjs/components/CalendarDayGrid/index.js +0 -3
- package/lib-commonjs/components/CalendarDayGrid/index.js.map +1 -1
- package/lib-commonjs/components/CalendarDayGrid/useCalendarDayGridStyles.styles.js +0 -2
- package/lib-commonjs/components/CalendarDayGrid/useCalendarDayGridStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CalendarDayGrid/useWeekCornerStyles.styles.js +0 -2
- package/lib-commonjs/components/CalendarDayGrid/useWeekCornerStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CalendarDayGrid/useWeeks.js +9 -11
- package/lib-commonjs/components/CalendarDayGrid/useWeeks.js.map +1 -1
- package/lib-commonjs/components/CalendarMonth/CalendarMonth.js +1 -3
- package/lib-commonjs/components/CalendarMonth/CalendarMonth.js.map +1 -1
- package/lib-commonjs/components/CalendarMonth/CalendarMonth.types.js +0 -3
- package/lib-commonjs/components/CalendarMonth/CalendarMonth.types.js.map +1 -1
- package/lib-commonjs/components/CalendarMonth/index.js +0 -3
- package/lib-commonjs/components/CalendarMonth/index.js.map +1 -1
- package/lib-commonjs/components/CalendarMonth/useCalendarMonthStyles.js +1 -3
- package/lib-commonjs/components/CalendarMonth/useCalendarMonthStyles.js.map +1 -1
- package/lib-commonjs/components/CalendarPicker/CalendarPicker.types.js +0 -3
- package/lib-commonjs/components/CalendarPicker/CalendarPicker.types.js.map +1 -1
- package/lib-commonjs/components/CalendarPicker/index.js +0 -3
- package/lib-commonjs/components/CalendarPicker/index.js.map +1 -1
- package/lib-commonjs/components/CalendarPicker/useCalendarPickerStyles.styles.js +0 -2
- package/lib-commonjs/components/CalendarPicker/useCalendarPickerStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CalendarYear/CalendarYear.js +1 -3
- package/lib-commonjs/components/CalendarYear/CalendarYear.js.map +1 -1
- package/lib-commonjs/components/CalendarYear/CalendarYear.types.js +0 -3
- package/lib-commonjs/components/CalendarYear/CalendarYear.types.js.map +1 -1
- package/lib-commonjs/components/CalendarYear/index.js +0 -3
- package/lib-commonjs/components/CalendarYear/index.js.map +1 -1
- package/lib-commonjs/components/CalendarYear/useCalendarYearStyles.styles.js +0 -2
- package/lib-commonjs/components/CalendarYear/useCalendarYearStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DatePicker/DatePicker.js +1 -3
- package/lib-commonjs/components/DatePicker/DatePicker.js.map +1 -1
- package/lib-commonjs/components/DatePicker/DatePicker.types.js +0 -3
- package/lib-commonjs/components/DatePicker/DatePicker.types.js.map +1 -1
- package/lib-commonjs/components/DatePicker/defaults.js +1 -3
- package/lib-commonjs/components/DatePicker/defaults.js.map +1 -1
- package/lib-commonjs/components/DatePicker/index.js +0 -3
- package/lib-commonjs/components/DatePicker/index.js.map +1 -1
- package/lib-commonjs/components/DatePicker/renderDatePicker.js +1 -3
- package/lib-commonjs/components/DatePicker/renderDatePicker.js.map +1 -1
- package/lib-commonjs/components/DatePicker/useDatePicker.js +14 -17
- package/lib-commonjs/components/DatePicker/useDatePicker.js.map +1 -1
- package/lib-commonjs/components/DatePicker/useDatePickerStyles.styles.js +0 -2
- package/lib-commonjs/components/DatePicker/useDatePickerStyles.styles.js.map +1 -1
- package/lib-commonjs/index.js +0 -3
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utils/animations.js +4 -6
- package/lib-commonjs/utils/animations.js.map +1 -1
- package/lib-commonjs/utils/constants.js +7 -9
- package/lib-commonjs/utils/constants.js.map +1 -1
- package/lib-commonjs/utils/dateFormatting/dateFormatting.defaults.js +1 -3
- package/lib-commonjs/utils/dateFormatting/dateFormatting.defaults.js.map +1 -1
- package/lib-commonjs/utils/dateFormatting/dateFormatting.types.js +0 -3
- package/lib-commonjs/utils/dateFormatting/dateFormatting.types.js.map +1 -1
- package/lib-commonjs/utils/dateFormatting/index.js +0 -3
- package/lib-commonjs/utils/dateFormatting/index.js.map +1 -1
- package/lib-commonjs/utils/dateGrid/dateGrid.types.js +0 -3
- package/lib-commonjs/utils/dateGrid/dateGrid.types.js.map +1 -1
- package/lib-commonjs/utils/dateGrid/findAvailableDate.js +1 -3
- package/lib-commonjs/utils/dateGrid/findAvailableDate.js.map +1 -1
- package/lib-commonjs/utils/dateGrid/getBoundedDateRange.js +1 -3
- package/lib-commonjs/utils/dateGrid/getBoundedDateRange.js.map +1 -1
- package/lib-commonjs/utils/dateGrid/getDateRangeTypeToUse.js +1 -3
- package/lib-commonjs/utils/dateGrid/getDateRangeTypeToUse.js.map +1 -1
- package/lib-commonjs/utils/dateGrid/getDayGrid.js +1 -3
- package/lib-commonjs/utils/dateGrid/getDayGrid.js.map +1 -1
- package/lib-commonjs/utils/dateGrid/index.js +0 -3
- package/lib-commonjs/utils/dateGrid/index.js.map +1 -1
- package/lib-commonjs/utils/dateGrid/isAfterMaxDate.js +1 -3
- package/lib-commonjs/utils/dateGrid/isAfterMaxDate.js.map +1 -1
- package/lib-commonjs/utils/dateGrid/isBeforeMinDate.js +1 -3
- package/lib-commonjs/utils/dateGrid/isBeforeMinDate.js.map +1 -1
- package/lib-commonjs/utils/dateGrid/isContiguous.js +1 -3
- package/lib-commonjs/utils/dateGrid/isContiguous.js.map +1 -1
- package/lib-commonjs/utils/dateGrid/isRestrictedDate.js +1 -3
- package/lib-commonjs/utils/dateGrid/isRestrictedDate.js.map +1 -1
- package/lib-commonjs/utils/dateMath/dateMath.js +1 -3
- package/lib-commonjs/utils/dateMath/dateMath.js.map +1 -1
- package/lib-commonjs/utils/dateMath/index.js +0 -3
- package/lib-commonjs/utils/dateMath/index.js.map +1 -1
- package/lib-commonjs/utils/dom.js +1 -3
- package/lib-commonjs/utils/dom.js.map +1 -1
- package/lib-commonjs/utils/focus.js +1 -3
- package/lib-commonjs/utils/focus.js.map +1 -1
- package/lib-commonjs/utils/index.js +0 -3
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/usePopupPositioning.js +1 -3
- package/lib-commonjs/utils/usePopupPositioning.js.map +1 -1
- package/package.json +14 -14
|
@@ -6,315 +6,293 @@ import { CalendarDay } from '../CalendarDay/CalendarDay';
|
|
|
6
6
|
import { CalendarMonth } from '../CalendarMonth/CalendarMonth';
|
|
7
7
|
import { useCalendarStyles_unstable } from './useCalendarStyles.styles';
|
|
8
8
|
const MIN_SIZE_FORCE_OVERLAY = 440;
|
|
9
|
-
const defaultWorkWeekDays = [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
9
|
+
const defaultWorkWeekDays = [
|
|
10
|
+
DayOfWeek.Monday,
|
|
11
|
+
DayOfWeek.Tuesday,
|
|
12
|
+
DayOfWeek.Wednesday,
|
|
13
|
+
DayOfWeek.Thursday,
|
|
14
|
+
DayOfWeek.Friday
|
|
15
|
+
];
|
|
16
|
+
function useDateState({ value , today =new Date() , onSelectDate }) {
|
|
17
|
+
/** The currently selected date in the calendar */ const [selectedDate, setSelectedDate] = useControllableState({
|
|
18
|
+
defaultState: today,
|
|
19
|
+
initialState: today,
|
|
20
|
+
state: value
|
|
21
|
+
});
|
|
22
|
+
/** The currently focused date in the day picker, but not necessarily selected */ const [navigatedDay = today, setNavigatedDay] = React.useState(value);
|
|
23
|
+
/** The currently focused date in the month picker, but not necessarily selected */ const [navigatedMonth = today, setNavigatedMonth] = React.useState(value);
|
|
24
|
+
/** If using a controlled value, when that value changes, navigate to that date */ const [lastSelectedDate = today, setLastSelectedDate] = React.useState(value);
|
|
25
|
+
if (value && lastSelectedDate.valueOf() !== value.valueOf()) {
|
|
26
|
+
setNavigatedDay(value);
|
|
27
|
+
setNavigatedMonth(value);
|
|
28
|
+
setLastSelectedDate(value);
|
|
29
|
+
}
|
|
30
|
+
const navigateMonth = (date)=>{
|
|
31
|
+
setNavigatedMonth(date);
|
|
32
|
+
};
|
|
33
|
+
const navigateDay = (date)=>{
|
|
34
|
+
setNavigatedMonth(date);
|
|
35
|
+
setNavigatedDay(date);
|
|
36
|
+
};
|
|
37
|
+
const onDateSelected = (date, selectedDateRangeArray)=>{
|
|
38
|
+
setNavigatedMonth(date);
|
|
39
|
+
setNavigatedDay(date);
|
|
40
|
+
setSelectedDate(date);
|
|
41
|
+
onSelectDate === null || onSelectDate === void 0 ? void 0 : onSelectDate(date, selectedDateRangeArray);
|
|
42
|
+
};
|
|
43
|
+
return [
|
|
44
|
+
selectedDate,
|
|
45
|
+
navigatedDay,
|
|
46
|
+
navigatedMonth,
|
|
47
|
+
onDateSelected,
|
|
48
|
+
navigateDay,
|
|
49
|
+
navigateMonth
|
|
50
|
+
];
|
|
45
51
|
}
|
|
46
|
-
function useVisibilityState({
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return [isMonthPickerVisible, isDayPickerVisible, toggleDayMonthPickerVisibility];
|
|
52
|
+
function useVisibilityState({ isDayPickerVisible: isDayPickerVisibleProp , isMonthPickerVisible: isMonthPickerVisibleProp , showMonthPickerAsOverlay }) {
|
|
53
|
+
/** State used to show/hide month picker */ const [isMonthPickerVisible, setIsMonthPickerVisible] = useControllableState({
|
|
54
|
+
defaultState: false,
|
|
55
|
+
initialState: true,
|
|
56
|
+
state: getShowMonthPickerAsOverlay({
|
|
57
|
+
isDayPickerVisible: isDayPickerVisibleProp,
|
|
58
|
+
showMonthPickerAsOverlay
|
|
59
|
+
}) ? undefined : isMonthPickerVisibleProp
|
|
60
|
+
});
|
|
61
|
+
/** State used to show/hide day picker */ const [isDayPickerVisible, setIsDayPickerVisible] = useControllableState({
|
|
62
|
+
defaultState: true,
|
|
63
|
+
initialState: true,
|
|
64
|
+
state: getShowMonthPickerAsOverlay({
|
|
65
|
+
isDayPickerVisible: isDayPickerVisibleProp,
|
|
66
|
+
showMonthPickerAsOverlay
|
|
67
|
+
}) ? undefined : isDayPickerVisibleProp
|
|
68
|
+
});
|
|
69
|
+
const toggleDayMonthPickerVisibility = ()=>{
|
|
70
|
+
setIsMonthPickerVisible(!isMonthPickerVisible);
|
|
71
|
+
setIsDayPickerVisible(!isDayPickerVisible);
|
|
72
|
+
};
|
|
73
|
+
return [
|
|
74
|
+
isMonthPickerVisible,
|
|
75
|
+
isDayPickerVisible,
|
|
76
|
+
toggleDayMonthPickerVisibility
|
|
77
|
+
];
|
|
73
78
|
}
|
|
74
|
-
function useFocusLogic({
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
79
|
+
function useFocusLogic({ componentRef }, isDayPickerVisible, isMonthPickerVisible) {
|
|
80
|
+
const dayPicker = React.useRef(null);
|
|
81
|
+
const monthPicker = React.useRef(null);
|
|
82
|
+
const focusOnUpdate = React.useRef(false);
|
|
83
|
+
const focus = React.useCallback(()=>{
|
|
84
|
+
if (isDayPickerVisible && dayPicker.current) {
|
|
85
|
+
focusAsync(dayPicker.current);
|
|
86
|
+
} else if (isMonthPickerVisible && monthPicker.current) {
|
|
87
|
+
focusAsync(monthPicker.current);
|
|
88
|
+
}
|
|
89
|
+
}, [
|
|
90
|
+
isDayPickerVisible,
|
|
91
|
+
isMonthPickerVisible
|
|
92
|
+
]);
|
|
93
|
+
React.useImperativeHandle(componentRef, ()=>({
|
|
94
|
+
focus
|
|
95
|
+
}), [
|
|
96
|
+
focus
|
|
97
|
+
]);
|
|
98
|
+
React.useEffect(()=>{
|
|
99
|
+
if (focusOnUpdate.current) {
|
|
100
|
+
focus();
|
|
101
|
+
focusOnUpdate.current = false;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
const focusOnNextUpdate = ()=>{
|
|
105
|
+
focusOnUpdate.current = true;
|
|
106
|
+
};
|
|
107
|
+
return [
|
|
108
|
+
dayPicker,
|
|
109
|
+
monthPicker,
|
|
110
|
+
focusOnNextUpdate
|
|
111
|
+
];
|
|
100
112
|
}
|
|
101
113
|
/**
|
|
102
114
|
* @internal
|
|
103
|
-
*/
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
strings = DEFAULT_CALENDAR_STRINGS,
|
|
131
|
-
today = new Date(),
|
|
132
|
-
value,
|
|
133
|
-
workWeekDays = defaultWorkWeekDays
|
|
134
|
-
} = props;
|
|
135
|
-
const [selectedDate, navigatedDay, navigatedMonth, onDateSelected, navigateDay, navigateMonth] = useDateState({
|
|
136
|
-
onSelectDate,
|
|
137
|
-
value,
|
|
138
|
-
today
|
|
139
|
-
});
|
|
140
|
-
const [isMonthPickerVisible, isDayPickerVisible, toggleDayMonthPickerVisibility] = useVisibilityState({
|
|
141
|
-
isDayPickerVisible: isDayPickerVisibleProp,
|
|
142
|
-
isMonthPickerVisible: isMonthPickerVisibleProp,
|
|
143
|
-
showMonthPickerAsOverlay: showMonthPickerAsOverlayProp
|
|
144
|
-
});
|
|
145
|
-
const [dayPicker, monthPicker, focusOnNextUpdate] = useFocusLogic({
|
|
146
|
-
componentRef
|
|
147
|
-
}, isDayPickerVisible, isMonthPickerVisible);
|
|
148
|
-
const renderGoToTodayButton = () => {
|
|
149
|
-
let goTodayEnabled = showGoToToday;
|
|
150
|
-
if (goTodayEnabled && today) {
|
|
151
|
-
goTodayEnabled = navigatedDay.getFullYear() !== today.getFullYear() || navigatedDay.getMonth() !== today.getMonth() || navigatedMonth.getFullYear() !== today.getFullYear() || navigatedMonth.getMonth() !== today.getMonth();
|
|
152
|
-
}
|
|
153
|
-
return showGoToToday && /*#__PURE__*/React.createElement("button", {
|
|
154
|
-
className: classes.goTodayButton,
|
|
155
|
-
onClick: onGotoToday,
|
|
156
|
-
onKeyDown: onButtonKeyDown(onGotoToday),
|
|
157
|
-
type: "button",
|
|
158
|
-
disabled: !goTodayEnabled
|
|
159
|
-
}, strings.goToToday);
|
|
160
|
-
};
|
|
161
|
-
const onNavigateDayDate = (date, focusOnNavigatedDay) => {
|
|
162
|
-
navigateDay(date);
|
|
163
|
-
if (focusOnNavigatedDay) {
|
|
164
|
-
focusOnNextUpdate();
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
const onNavigateMonthDate = (date, focusOnNavigatedDay) => {
|
|
168
|
-
if (focusOnNavigatedDay) {
|
|
169
|
-
focusOnNextUpdate();
|
|
170
|
-
}
|
|
171
|
-
if (!focusOnNavigatedDay) {
|
|
172
|
-
navigateMonth(date);
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
if (monthPickerOnly) {
|
|
176
|
-
onDateSelected(date);
|
|
177
|
-
}
|
|
178
|
-
navigateDay(date);
|
|
179
|
-
};
|
|
180
|
-
const onHeaderSelect = getShowMonthPickerAsOverlay({
|
|
181
|
-
isDayPickerVisible: isDayPickerVisibleProp,
|
|
182
|
-
showMonthPickerAsOverlay: showMonthPickerAsOverlayProp
|
|
183
|
-
}) ? () => {
|
|
184
|
-
toggleDayMonthPickerVisibility();
|
|
185
|
-
focusOnNextUpdate();
|
|
186
|
-
} : undefined;
|
|
187
|
-
const onGotoToday = () => {
|
|
188
|
-
navigateDay(today);
|
|
189
|
-
focusOnNextUpdate();
|
|
190
|
-
};
|
|
191
|
-
const onButtonKeyDown = callback => {
|
|
192
|
-
return ev => {
|
|
193
|
-
switch (ev.key) {
|
|
194
|
-
case Enter:
|
|
195
|
-
case Space:
|
|
196
|
-
callback();
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
115
|
+
*/ export const Calendar = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
|
|
116
|
+
const { allFocusable =false , calendarDayProps , calendarMonthProps , className , componentRef , dateRangeType =DateRangeType.Day , dateTimeFormatter =DEFAULT_DATE_FORMATTING , firstDayOfWeek =DayOfWeek.Sunday , firstWeekOfYear =FirstWeekOfYear.FirstDay , highlightCurrentMonth =false , highlightSelectedMonth =false , id , isDayPickerVisible: isDayPickerVisibleProp = true , isMonthPickerVisible: isMonthPickerVisibleProp = true , maxDate , minDate , onDismiss , onSelectDate , restrictedDates , showCloseButton =false , showGoToToday =true , showMonthPickerAsOverlay: showMonthPickerAsOverlayProp = false , showSixWeeksByDefault =false , showWeekNumbers =false , strings =DEFAULT_CALENDAR_STRINGS , today =new Date() , value , workWeekDays =defaultWorkWeekDays } = props;
|
|
117
|
+
const [selectedDate, navigatedDay, navigatedMonth, onDateSelected, navigateDay, navigateMonth] = useDateState({
|
|
118
|
+
onSelectDate,
|
|
119
|
+
value,
|
|
120
|
+
today
|
|
121
|
+
});
|
|
122
|
+
const [isMonthPickerVisible, isDayPickerVisible, toggleDayMonthPickerVisibility] = useVisibilityState({
|
|
123
|
+
isDayPickerVisible: isDayPickerVisibleProp,
|
|
124
|
+
isMonthPickerVisible: isMonthPickerVisibleProp,
|
|
125
|
+
showMonthPickerAsOverlay: showMonthPickerAsOverlayProp
|
|
126
|
+
});
|
|
127
|
+
const [dayPicker, monthPicker, focusOnNextUpdate] = useFocusLogic({
|
|
128
|
+
componentRef
|
|
129
|
+
}, isDayPickerVisible, isMonthPickerVisible);
|
|
130
|
+
const renderGoToTodayButton = ()=>{
|
|
131
|
+
let goTodayEnabled = showGoToToday;
|
|
132
|
+
if (goTodayEnabled && today) {
|
|
133
|
+
goTodayEnabled = navigatedDay.getFullYear() !== today.getFullYear() || navigatedDay.getMonth() !== today.getMonth() || navigatedMonth.getFullYear() !== today.getFullYear() || navigatedMonth.getMonth() !== today.getMonth();
|
|
134
|
+
}
|
|
135
|
+
return showGoToToday && /*#__PURE__*/ React.createElement("button", {
|
|
136
|
+
className: classes.goTodayButton,
|
|
137
|
+
onClick: onGotoToday,
|
|
138
|
+
onKeyDown: onButtonKeyDown(onGotoToday),
|
|
139
|
+
type: "button",
|
|
140
|
+
disabled: !goTodayEnabled
|
|
141
|
+
}, strings.goToToday);
|
|
199
142
|
};
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
case PageUp:
|
|
214
|
-
if (ev.ctrlKey) {
|
|
215
|
-
// go to next year
|
|
216
|
-
navigateDay(addYears(navigatedDay, 1));
|
|
217
|
-
} else {
|
|
218
|
-
// go to next month
|
|
219
|
-
navigateDay(addMonths(navigatedDay, 1));
|
|
143
|
+
const onNavigateDayDate = (date, focusOnNavigatedDay)=>{
|
|
144
|
+
navigateDay(date);
|
|
145
|
+
if (focusOnNavigatedDay) {
|
|
146
|
+
focusOnNextUpdate();
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const onNavigateMonthDate = (date, focusOnNavigatedDay)=>{
|
|
150
|
+
if (focusOnNavigatedDay) {
|
|
151
|
+
focusOnNextUpdate();
|
|
152
|
+
}
|
|
153
|
+
if (!focusOnNavigatedDay) {
|
|
154
|
+
navigateMonth(date);
|
|
155
|
+
return;
|
|
220
156
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
case PageDown:
|
|
224
|
-
if (ev.ctrlKey) {
|
|
225
|
-
// go to previous year
|
|
226
|
-
navigateDay(addYears(navigatedDay, -1));
|
|
227
|
-
} else {
|
|
228
|
-
// go to previous month
|
|
229
|
-
navigateDay(addMonths(navigatedDay, -1));
|
|
157
|
+
if (monthPickerOnly) {
|
|
158
|
+
onDateSelected(date);
|
|
230
159
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
160
|
+
navigateDay(date);
|
|
161
|
+
};
|
|
162
|
+
const onHeaderSelect = getShowMonthPickerAsOverlay({
|
|
163
|
+
isDayPickerVisible: isDayPickerVisibleProp,
|
|
164
|
+
showMonthPickerAsOverlay: showMonthPickerAsOverlayProp
|
|
165
|
+
}) ? ()=>{
|
|
166
|
+
toggleDayMonthPickerVisibility();
|
|
167
|
+
focusOnNextUpdate();
|
|
168
|
+
} : undefined;
|
|
169
|
+
const onGotoToday = ()=>{
|
|
170
|
+
navigateDay(today);
|
|
171
|
+
focusOnNextUpdate();
|
|
172
|
+
};
|
|
173
|
+
const onButtonKeyDown = (callback)=>{
|
|
174
|
+
return (ev)=>{
|
|
175
|
+
switch(ev.key){
|
|
176
|
+
case Enter:
|
|
177
|
+
case Space:
|
|
178
|
+
callback();
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
const onDatePickerPopupKeyDown = (ev)=>{
|
|
184
|
+
switch(ev.key){
|
|
185
|
+
case Enter:
|
|
186
|
+
ev.preventDefault();
|
|
187
|
+
break;
|
|
188
|
+
case Backspace:
|
|
189
|
+
ev.preventDefault();
|
|
190
|
+
break;
|
|
191
|
+
case Escape:
|
|
192
|
+
ev.stopPropagation();
|
|
193
|
+
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
|
194
|
+
break;
|
|
195
|
+
case PageUp:
|
|
196
|
+
if (ev.ctrlKey) {
|
|
197
|
+
// go to next year
|
|
198
|
+
navigateDay(addYears(navigatedDay, 1));
|
|
199
|
+
} else {
|
|
200
|
+
// go to next month
|
|
201
|
+
navigateDay(addMonths(navigatedDay, 1));
|
|
202
|
+
}
|
|
203
|
+
ev.preventDefault();
|
|
204
|
+
break;
|
|
205
|
+
case PageDown:
|
|
206
|
+
if (ev.ctrlKey) {
|
|
207
|
+
// go to previous year
|
|
208
|
+
navigateDay(addYears(navigatedDay, -1));
|
|
209
|
+
} else {
|
|
210
|
+
// go to previous month
|
|
211
|
+
navigateDay(addMonths(navigatedDay, -1));
|
|
212
|
+
}
|
|
213
|
+
ev.preventDefault();
|
|
214
|
+
break;
|
|
215
|
+
default:
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
const showMonthPickerAsOverlay = getShowMonthPickerAsOverlay(props);
|
|
220
|
+
const monthPickerOnly = !showMonthPickerAsOverlay && !isDayPickerVisible;
|
|
221
|
+
const classes = useCalendarStyles_unstable({
|
|
222
|
+
className,
|
|
223
|
+
isDayPickerVisible,
|
|
224
|
+
isMonthPickerVisible,
|
|
225
|
+
showWeekNumbers
|
|
226
|
+
});
|
|
227
|
+
let todayDateString = '';
|
|
228
|
+
let selectedDateString = '';
|
|
229
|
+
if (dateTimeFormatter && strings.todayDateFormatString) {
|
|
230
|
+
todayDateString = strings.todayDateFormatString.replace('{0}', dateTimeFormatter.formatMonthDayYear(today, strings));
|
|
231
|
+
}
|
|
232
|
+
if (dateTimeFormatter && strings.selectedDateFormatString) {
|
|
233
|
+
selectedDateString = strings.selectedDateFormatString.replace('{0}', dateTimeFormatter.formatMonthDayYear(selectedDate, strings));
|
|
235
234
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}, /*#__PURE__*/React.createElement(CalendarMonth, {
|
|
295
|
-
navigatedDate: navigatedMonth,
|
|
296
|
-
selectedDate: navigatedDay,
|
|
297
|
-
strings: strings,
|
|
298
|
-
// eslint-disable-next-line react/jsx-no-bind
|
|
299
|
-
onNavigateDate: onNavigateMonthDate,
|
|
300
|
-
today: today,
|
|
301
|
-
highlightCurrentMonth: highlightCurrentMonth,
|
|
302
|
-
highlightSelectedMonth: highlightSelectedMonth,
|
|
303
|
-
// eslint-disable-next-line react/jsx-no-bind
|
|
304
|
-
onHeaderSelect: onHeaderSelect,
|
|
305
|
-
dateTimeFormatter: dateTimeFormatter,
|
|
306
|
-
minDate: minDate,
|
|
307
|
-
maxDate: maxDate,
|
|
308
|
-
componentRef: monthPicker,
|
|
309
|
-
...calendarMonthProps
|
|
310
|
-
}), renderGoToTodayButton()) : renderGoToTodayButton());
|
|
235
|
+
const selectionAndTodayString = selectedDateString + ', ' + todayDateString;
|
|
236
|
+
return /*#__PURE__*/ React.createElement("div", {
|
|
237
|
+
id: id,
|
|
238
|
+
ref: forwardedRef,
|
|
239
|
+
role: "group",
|
|
240
|
+
"aria-label": selectionAndTodayString,
|
|
241
|
+
className: classes.root,
|
|
242
|
+
onKeyDown: onDatePickerPopupKeyDown
|
|
243
|
+
}, /*#__PURE__*/ React.createElement("div", {
|
|
244
|
+
className: classes.liveRegion,
|
|
245
|
+
"aria-live": "polite",
|
|
246
|
+
"aria-atomic": "true"
|
|
247
|
+
}, /*#__PURE__*/ React.createElement("span", null, selectedDateString)), isDayPickerVisible && /*#__PURE__*/ React.createElement(CalendarDay, {
|
|
248
|
+
selectedDate: selectedDate,
|
|
249
|
+
navigatedDate: navigatedDay,
|
|
250
|
+
today: today,
|
|
251
|
+
onSelectDate: onDateSelected,
|
|
252
|
+
// eslint-disable-next-line react/jsx-no-bind
|
|
253
|
+
onNavigateDate: onNavigateDayDate,
|
|
254
|
+
onDismiss: onDismiss,
|
|
255
|
+
firstDayOfWeek: firstDayOfWeek,
|
|
256
|
+
dateRangeType: dateRangeType,
|
|
257
|
+
strings: strings,
|
|
258
|
+
// eslint-disable-next-line react/jsx-no-bind
|
|
259
|
+
onHeaderSelect: onHeaderSelect,
|
|
260
|
+
showWeekNumbers: showWeekNumbers,
|
|
261
|
+
firstWeekOfYear: firstWeekOfYear,
|
|
262
|
+
dateTimeFormatter: dateTimeFormatter,
|
|
263
|
+
showSixWeeksByDefault: showSixWeeksByDefault,
|
|
264
|
+
minDate: minDate,
|
|
265
|
+
maxDate: maxDate,
|
|
266
|
+
restrictedDates: restrictedDates,
|
|
267
|
+
workWeekDays: workWeekDays,
|
|
268
|
+
componentRef: dayPicker,
|
|
269
|
+
showCloseButton: showCloseButton,
|
|
270
|
+
allFocusable: allFocusable,
|
|
271
|
+
...calendarDayProps
|
|
272
|
+
}), isDayPickerVisible && isMonthPickerVisible && /*#__PURE__*/ React.createElement("div", {
|
|
273
|
+
className: classes.divider
|
|
274
|
+
}), isMonthPickerVisible ? /*#__PURE__*/ React.createElement("div", {
|
|
275
|
+
className: classes.monthPickerWrapper
|
|
276
|
+
}, /*#__PURE__*/ React.createElement(CalendarMonth, {
|
|
277
|
+
navigatedDate: navigatedMonth,
|
|
278
|
+
selectedDate: navigatedDay,
|
|
279
|
+
strings: strings,
|
|
280
|
+
// eslint-disable-next-line react/jsx-no-bind
|
|
281
|
+
onNavigateDate: onNavigateMonthDate,
|
|
282
|
+
today: today,
|
|
283
|
+
highlightCurrentMonth: highlightCurrentMonth,
|
|
284
|
+
highlightSelectedMonth: highlightSelectedMonth,
|
|
285
|
+
// eslint-disable-next-line react/jsx-no-bind
|
|
286
|
+
onHeaderSelect: onHeaderSelect,
|
|
287
|
+
dateTimeFormatter: dateTimeFormatter,
|
|
288
|
+
minDate: minDate,
|
|
289
|
+
maxDate: maxDate,
|
|
290
|
+
componentRef: monthPicker,
|
|
291
|
+
...calendarMonthProps
|
|
292
|
+
}), renderGoToTodayButton()) : renderGoToTodayButton());
|
|
311
293
|
});
|
|
312
294
|
Calendar.displayName = 'Calendar';
|
|
313
|
-
function getShowMonthPickerAsOverlay({
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}) {
|
|
317
|
-
const win = getWindow();
|
|
318
|
-
return showMonthPickerAsOverlay || isDayPickerVisible && win && win.innerWidth <= MIN_SIZE_FORCE_OVERLAY;
|
|
295
|
+
function getShowMonthPickerAsOverlay({ isDayPickerVisible , showMonthPickerAsOverlay }) {
|
|
296
|
+
const win = getWindow();
|
|
297
|
+
return showMonthPickerAsOverlay || isDayPickerVisible && win && win.innerWidth <= MIN_SIZE_FORCE_OVERLAY;
|
|
319
298
|
}
|
|
320
|
-
//# sourceMappingURL=Calendar.js.map
|