@fluentui/react-datepicker-compat 0.0.0-beta.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/.swcrc +30 -0
- package/CHANGELOG.json +56 -0
- package/CHANGELOG.md +19 -0
- package/LICENSE +15 -0
- package/README.md +42 -0
- package/dist/index.d.ts +1156 -0
- package/lib/Calendar.js +2 -0
- package/lib/Calendar.js.map +1 -0
- package/lib/CalendarDay.js +2 -0
- package/lib/CalendarDay.js.map +1 -0
- package/lib/CalendarDayGrid.js +2 -0
- package/lib/CalendarDayGrid.js.map +1 -0
- package/lib/CalendarMonth.js +2 -0
- package/lib/CalendarMonth.js.map +1 -0
- package/lib/CalendarPicker.js +2 -0
- package/lib/CalendarPicker.js.map +1 -0
- package/lib/CalendarYear.js +2 -0
- package/lib/CalendarYear.js.map +1 -0
- package/lib/DatePicker.js +2 -0
- package/lib/DatePicker.js.map +1 -0
- package/lib/components/Calendar/Calendar.js +319 -0
- package/lib/components/Calendar/Calendar.js.map +1 -0
- package/lib/components/Calendar/Calendar.types.js +15 -0
- package/lib/components/Calendar/Calendar.types.js.map +1 -0
- package/lib/components/Calendar/defaults.js +3 -0
- package/lib/components/Calendar/defaults.js.map +1 -0
- package/lib/components/Calendar/index.js +5 -0
- package/lib/components/Calendar/index.js.map +1 -0
- package/lib/components/Calendar/useCalendarStyles.js +149 -0
- package/lib/components/Calendar/useCalendarStyles.js.map +1 -0
- package/lib/components/CalendarDay/CalendarDay.js +143 -0
- package/lib/components/CalendarDay/CalendarDay.js.map +1 -0
- package/lib/components/CalendarDay/CalendarDay.types.js +2 -0
- package/lib/components/CalendarDay/CalendarDay.types.js.map +1 -0
- package/lib/components/CalendarDay/index.js +4 -0
- package/lib/components/CalendarDay/index.js.map +1 -0
- package/lib/components/CalendarDay/useCalendarDayStyles.js +180 -0
- package/lib/components/CalendarDay/useCalendarDayStyles.js.map +1 -0
- package/lib/components/CalendarDayGrid/CalendarDayGrid.js +183 -0
- package/lib/components/CalendarDayGrid/CalendarDayGrid.js.map +1 -0
- package/lib/components/CalendarDayGrid/CalendarDayGrid.types.js +2 -0
- package/lib/components/CalendarDayGrid/CalendarDayGrid.types.js.map +1 -0
- package/lib/components/CalendarDayGrid/CalendarGridDayCell.js +193 -0
- package/lib/components/CalendarDayGrid/CalendarGridDayCell.js.map +1 -0
- package/lib/components/CalendarDayGrid/CalendarGridRow.js +40 -0
- package/lib/components/CalendarDayGrid/CalendarGridRow.js.map +1 -0
- package/lib/components/CalendarDayGrid/CalendarMonthHeaderRow.js +46 -0
- package/lib/components/CalendarDayGrid/CalendarMonthHeaderRow.js.map +1 -0
- package/lib/components/CalendarDayGrid/index.js +5 -0
- package/lib/components/CalendarDayGrid/index.js.map +1 -0
- package/lib/components/CalendarDayGrid/useCalendarDayGridStyles.js +443 -0
- package/lib/components/CalendarDayGrid/useCalendarDayGridStyles.js.map +1 -0
- package/lib/components/CalendarDayGrid/useWeekCornerStyles.js +98 -0
- package/lib/components/CalendarDayGrid/useWeekCornerStyles.js.map +1 -0
- package/lib/components/CalendarDayGrid/useWeeks.js +47 -0
- package/lib/components/CalendarDayGrid/useWeeks.js.map +1 -0
- package/lib/components/CalendarMonth/CalendarMonth.js +282 -0
- package/lib/components/CalendarMonth/CalendarMonth.js.map +1 -0
- package/lib/components/CalendarMonth/CalendarMonth.types.js +2 -0
- package/lib/components/CalendarMonth/CalendarMonth.types.js.map +1 -0
- package/lib/components/CalendarMonth/index.js +4 -0
- package/lib/components/CalendarMonth/index.js.map +1 -0
- package/lib/components/CalendarMonth/useCalendarMonthStyles.js +10 -0
- package/lib/components/CalendarMonth/useCalendarMonthStyles.js.map +1 -0
- package/lib/components/CalendarPicker/CalendarPicker.types.js +2 -0
- package/lib/components/CalendarPicker/CalendarPicker.types.js.map +1 -0
- package/lib/components/CalendarPicker/index.js +3 -0
- package/lib/components/CalendarPicker/index.js.map +1 -0
- package/lib/components/CalendarPicker/useCalendarPickerStyles.js +371 -0
- package/lib/components/CalendarPicker/useCalendarPickerStyles.js.map +1 -0
- package/lib/components/CalendarYear/CalendarYear.js +350 -0
- package/lib/components/CalendarYear/CalendarYear.js.map +1 -0
- package/lib/components/CalendarYear/CalendarYear.types.js +2 -0
- package/lib/components/CalendarYear/CalendarYear.types.js.map +1 -0
- package/lib/components/CalendarYear/index.js +4 -0
- package/lib/components/CalendarYear/index.js.map +1 -0
- package/lib/components/CalendarYear/useCalendarYearStyles.js +10 -0
- package/lib/components/CalendarYear/useCalendarYearStyles.js.map +1 -0
- package/lib/components/DatePicker/DatePicker.js +11 -0
- package/lib/components/DatePicker/DatePicker.js.map +1 -0
- package/lib/components/DatePicker/DatePicker.types.js +2 -0
- package/lib/components/DatePicker/DatePicker.types.js.map +1 -0
- package/lib/components/DatePicker/defaults.js +13 -0
- package/lib/components/DatePicker/defaults.js.map +1 -0
- package/lib/components/DatePicker/index.js +7 -0
- package/lib/components/DatePicker/index.js.map +1 -0
- package/lib/components/DatePicker/renderDatePicker.js +35 -0
- package/lib/components/DatePicker/renderDatePicker.js.map +1 -0
- package/lib/components/DatePicker/useDatePicker.js +453 -0
- package/lib/components/DatePicker/useDatePicker.js.map +1 -0
- package/lib/components/DatePicker/useDatePickerStyles.js +62 -0
- package/lib/components/DatePicker/useDatePickerStyles.js.map +1 -0
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -0
- package/lib/utils/animations.js +98 -0
- package/lib/utils/animations.js.map +1 -0
- package/lib/utils/constants.js +64 -0
- package/lib/utils/constants.js.map +1 -0
- package/lib/utils/dateFormatting/dateFormatting.defaults.js +58 -0
- package/lib/utils/dateFormatting/dateFormatting.defaults.js.map +1 -0
- package/lib/utils/dateFormatting/dateFormatting.types.js +2 -0
- package/lib/utils/dateFormatting/dateFormatting.types.js.map +1 -0
- package/lib/utils/dateFormatting/index.js +3 -0
- package/lib/utils/dateFormatting/index.js.map +1 -0
- package/lib/utils/dateGrid/dateGrid.types.js +2 -0
- package/lib/utils/dateGrid/dateGrid.types.js.map +1 -0
- package/lib/utils/dateGrid/findAvailableDate.js +29 -0
- package/lib/utils/dateGrid/findAvailableDate.js.map +1 -0
- package/lib/utils/dateGrid/getBoundedDateRange.js +18 -0
- package/lib/utils/dateGrid/getBoundedDateRange.js.map +1 -0
- package/lib/utils/dateGrid/getDateRangeTypeToUse.js +18 -0
- package/lib/utils/dateGrid/getDateRangeTypeToUse.js.map +1 -0
- package/lib/utils/dateGrid/getDayGrid.js +85 -0
- package/lib/utils/dateGrid/getDayGrid.js.map +1 -0
- package/lib/utils/dateGrid/index.js +6 -0
- package/lib/utils/dateGrid/index.js.map +1 -0
- package/lib/utils/dateGrid/isAfterMaxDate.js +13 -0
- package/lib/utils/dateGrid/isAfterMaxDate.js.map +1 -0
- package/lib/utils/dateGrid/isBeforeMinDate.js +13 -0
- package/lib/utils/dateGrid/isBeforeMinDate.js.map +1 -0
- package/lib/utils/dateGrid/isContiguous.js +19 -0
- package/lib/utils/dateGrid/isContiguous.js.map +1 -0
- package/lib/utils/dateGrid/isRestrictedDate.js +21 -0
- package/lib/utils/dateGrid/isRestrictedDate.js.map +1 -0
- package/lib/utils/dateMath/dateMath.js +358 -0
- package/lib/utils/dateMath/dateMath.js.map +1 -0
- package/lib/utils/dateMath/index.js +2 -0
- package/lib/utils/dateMath/index.js.map +1 -0
- package/lib/utils/dom.js +9 -0
- package/lib/utils/dom.js.map +1 -0
- package/lib/utils/focus.js +28 -0
- package/lib/utils/focus.js.map +1 -0
- package/lib/utils/index.js +8 -0
- package/lib/utils/index.js.map +1 -0
- package/lib-commonjs/Calendar.js +9 -0
- package/lib-commonjs/Calendar.js.map +1 -0
- package/lib-commonjs/CalendarDay.js +9 -0
- package/lib-commonjs/CalendarDay.js.map +1 -0
- package/lib-commonjs/CalendarDayGrid.js +9 -0
- package/lib-commonjs/CalendarDayGrid.js.map +1 -0
- package/lib-commonjs/CalendarMonth.js +9 -0
- package/lib-commonjs/CalendarMonth.js.map +1 -0
- package/lib-commonjs/CalendarPicker.js +9 -0
- package/lib-commonjs/CalendarPicker.js.map +1 -0
- package/lib-commonjs/CalendarYear.js +9 -0
- package/lib-commonjs/CalendarYear.js.map +1 -0
- package/lib-commonjs/DatePicker.js +9 -0
- package/lib-commonjs/DatePicker.js.map +1 -0
- package/lib-commonjs/components/Calendar/Calendar.js +306 -0
- package/lib-commonjs/components/Calendar/Calendar.js.map +1 -0
- package/lib-commonjs/components/Calendar/Calendar.types.js +21 -0
- package/lib-commonjs/components/Calendar/Calendar.types.js.map +1 -0
- package/lib-commonjs/components/Calendar/defaults.js +12 -0
- package/lib-commonjs/components/Calendar/defaults.js.map +1 -0
- package/lib-commonjs/components/Calendar/index.js +16 -0
- package/lib-commonjs/components/Calendar/index.js.map +1 -0
- package/lib-commonjs/components/Calendar/useCalendarStyles.js +286 -0
- package/lib-commonjs/components/Calendar/useCalendarStyles.js.map +1 -0
- package/lib-commonjs/components/CalendarDay/CalendarDay.js +124 -0
- package/lib-commonjs/components/CalendarDay/CalendarDay.js.map +1 -0
- package/lib-commonjs/components/CalendarDay/CalendarDay.types.js +9 -0
- package/lib-commonjs/components/CalendarDay/CalendarDay.types.js.map +1 -0
- package/lib-commonjs/components/CalendarDay/index.js +11 -0
- package/lib-commonjs/components/CalendarDay/index.js.map +1 -0
- package/lib-commonjs/components/CalendarDay/useCalendarDayStyles.js +356 -0
- package/lib-commonjs/components/CalendarDay/useCalendarDayStyles.js.map +1 -0
- package/lib-commonjs/components/CalendarDayGrid/CalendarDayGrid.js +181 -0
- package/lib-commonjs/components/CalendarDayGrid/CalendarDayGrid.js.map +1 -0
- package/lib-commonjs/components/CalendarDayGrid/CalendarDayGrid.types.js +9 -0
- package/lib-commonjs/components/CalendarDayGrid/CalendarDayGrid.types.js.map +1 -0
- package/lib-commonjs/components/CalendarDayGrid/CalendarGridDayCell.js +173 -0
- package/lib-commonjs/components/CalendarDayGrid/CalendarGridDayCell.js.map +1 -0
- package/lib-commonjs/components/CalendarDayGrid/CalendarGridRow.js +35 -0
- package/lib-commonjs/components/CalendarDayGrid/CalendarGridRow.js.map +1 -0
- package/lib-commonjs/components/CalendarDayGrid/CalendarMonthHeaderRow.js +45 -0
- package/lib-commonjs/components/CalendarDayGrid/CalendarMonthHeaderRow.js.map +1 -0
- package/lib-commonjs/components/CalendarDayGrid/index.js +21 -0
- package/lib-commonjs/components/CalendarDayGrid/index.js.map +1 -0
- package/lib-commonjs/components/CalendarDayGrid/useCalendarDayGridStyles.js +916 -0
- package/lib-commonjs/components/CalendarDayGrid/useCalendarDayGridStyles.js.map +1 -0
- package/lib-commonjs/components/CalendarDayGrid/useWeekCornerStyles.js +103 -0
- package/lib-commonjs/components/CalendarDayGrid/useWeekCornerStyles.js.map +1 -0
- package/lib-commonjs/components/CalendarDayGrid/useWeeks.js +54 -0
- package/lib-commonjs/components/CalendarDayGrid/useWeeks.js.map +1 -0
- package/lib-commonjs/components/CalendarMonth/CalendarMonth.js +271 -0
- package/lib-commonjs/components/CalendarMonth/CalendarMonth.js.map +1 -0
- package/lib-commonjs/components/CalendarMonth/CalendarMonth.types.js +9 -0
- package/lib-commonjs/components/CalendarMonth/CalendarMonth.types.js.map +1 -0
- package/lib-commonjs/components/CalendarMonth/index.js +11 -0
- package/lib-commonjs/components/CalendarMonth/index.js.map +1 -0
- package/lib-commonjs/components/CalendarMonth/useCalendarMonthStyles.js +14 -0
- package/lib-commonjs/components/CalendarMonth/useCalendarMonthStyles.js.map +1 -0
- package/lib-commonjs/components/CalendarPicker/CalendarPicker.types.js +7 -0
- package/lib-commonjs/components/CalendarPicker/CalendarPicker.types.js.map +1 -0
- package/lib-commonjs/components/CalendarPicker/index.js +10 -0
- package/lib-commonjs/components/CalendarPicker/index.js.map +1 -0
- package/lib-commonjs/components/CalendarPicker/useCalendarPickerStyles.js +746 -0
- package/lib-commonjs/components/CalendarPicker/useCalendarPickerStyles.js.map +1 -0
- package/lib-commonjs/components/CalendarYear/CalendarYear.js +307 -0
- package/lib-commonjs/components/CalendarYear/CalendarYear.js.map +1 -0
- package/lib-commonjs/components/CalendarYear/CalendarYear.types.js +9 -0
- package/lib-commonjs/components/CalendarYear/CalendarYear.types.js.map +1 -0
- package/lib-commonjs/components/CalendarYear/index.js +11 -0
- package/lib-commonjs/components/CalendarYear/index.js.map +1 -0
- package/lib-commonjs/components/CalendarYear/useCalendarYearStyles.js +14 -0
- package/lib-commonjs/components/CalendarYear/useCalendarYearStyles.js.map +1 -0
- package/lib-commonjs/components/DatePicker/DatePicker.js +21 -0
- package/lib-commonjs/components/DatePicker/DatePicker.js.map +1 -0
- package/lib-commonjs/components/DatePicker/DatePicker.types.js +9 -0
- package/lib-commonjs/components/DatePicker/DatePicker.types.js.map +1 -0
- package/lib-commonjs/components/DatePicker/defaults.js +22 -0
- package/lib-commonjs/components/DatePicker/defaults.js.map +1 -0
- package/lib-commonjs/components/DatePicker/index.js +14 -0
- package/lib-commonjs/components/DatePicker/index.js.map +1 -0
- package/lib-commonjs/components/DatePicker/renderDatePicker.js +33 -0
- package/lib-commonjs/components/DatePicker/renderDatePicker.js.map +1 -0
- package/lib-commonjs/components/DatePicker/useDatePicker.js +486 -0
- package/lib-commonjs/components/DatePicker/useDatePicker.js.map +1 -0
- package/lib-commonjs/components/DatePicker/useDatePickerStyles.js +100 -0
- package/lib-commonjs/components/DatePicker/useDatePickerStyles.js.map +1 -0
- package/lib-commonjs/index.js +50 -0
- package/lib-commonjs/index.js.map +1 -0
- package/lib-commonjs/utils/animations.js +126 -0
- package/lib-commonjs/utils/animations.js.map +1 -0
- package/lib-commonjs/utils/constants.js +82 -0
- package/lib-commonjs/utils/constants.js.map +1 -0
- package/lib-commonjs/utils/dateFormatting/dateFormatting.defaults.js +102 -0
- package/lib-commonjs/utils/dateFormatting/dateFormatting.defaults.js.map +1 -0
- package/lib-commonjs/utils/dateFormatting/dateFormatting.types.js +7 -0
- package/lib-commonjs/utils/dateFormatting/dateFormatting.types.js.map +1 -0
- package/lib-commonjs/utils/dateFormatting/index.js +10 -0
- package/lib-commonjs/utils/dateFormatting/index.js.map +1 -0
- package/lib-commonjs/utils/dateGrid/dateGrid.types.js +7 -0
- package/lib-commonjs/utils/dateGrid/dateGrid.types.js.map +1 -0
- package/lib-commonjs/utils/dateGrid/findAvailableDate.js +29 -0
- package/lib-commonjs/utils/dateGrid/findAvailableDate.js.map +1 -0
- package/lib-commonjs/utils/dateGrid/getBoundedDateRange.js +23 -0
- package/lib-commonjs/utils/dateGrid/getBoundedDateRange.js.map +1 -0
- package/lib-commonjs/utils/dateGrid/getDateRangeTypeToUse.js +20 -0
- package/lib-commonjs/utils/dateGrid/getDateRangeTypeToUse.js.map +1 -0
- package/lib-commonjs/utils/dateGrid/getDayGrid.js +76 -0
- package/lib-commonjs/utils/dateGrid/getDayGrid.js.map +1 -0
- package/lib-commonjs/utils/dateGrid/index.js +13 -0
- package/lib-commonjs/utils/dateGrid/index.js.map +1 -0
- package/lib-commonjs/utils/dateGrid/isAfterMaxDate.js +15 -0
- package/lib-commonjs/utils/dateGrid/isAfterMaxDate.js.map +1 -0
- package/lib-commonjs/utils/dateGrid/isBeforeMinDate.js +15 -0
- package/lib-commonjs/utils/dateGrid/isBeforeMinDate.js.map +1 -0
- package/lib-commonjs/utils/dateGrid/isContiguous.js +28 -0
- package/lib-commonjs/utils/dateGrid/isContiguous.js.map +1 -0
- package/lib-commonjs/utils/dateGrid/isRestrictedDate.js +21 -0
- package/lib-commonjs/utils/dateGrid/isRestrictedDate.js.map +1 -0
- package/lib-commonjs/utils/dateMath/dateMath.js +274 -0
- package/lib-commonjs/utils/dateMath/dateMath.js.map +1 -0
- package/lib-commonjs/utils/dateMath/index.js +9 -0
- package/lib-commonjs/utils/dateMath/index.js.map +1 -0
- package/lib-commonjs/utils/dom.js +18 -0
- package/lib-commonjs/utils/dom.js.map +1 -0
- package/lib-commonjs/utils/focus.js +31 -0
- package/lib-commonjs/utils/focus.js.map +1 -0
- package/lib-commonjs/utils/index.js +15 -0
- package/lib-commonjs/utils/index.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ArrowDown, Enter, Escape } from '@fluentui/keyboard-keys';
|
|
3
|
+
import { CalendarMonthRegular } from '@fluentui/react-icons';
|
|
4
|
+
import { Input } from '@fluentui/react-input';
|
|
5
|
+
import { Field } from '@fluentui/react-field';
|
|
6
|
+
import { getNativeElementProps, mergeCallbacks, resolveShorthand, useControllableState, useId } from '@fluentui/react-utilities';
|
|
7
|
+
import { compareDatePart, getDatePartHashValue, DayOfWeek, FirstWeekOfYear } from '../../utils';
|
|
8
|
+
import { Calendar } from '../Calendar/Calendar';
|
|
9
|
+
import { defaultDatePickerStrings } from './defaults';
|
|
10
|
+
import { Popover } from '@fluentui/react-popover';
|
|
11
|
+
import { PopoverSurface } from '@fluentui/react-popover';
|
|
12
|
+
function isDateOutOfBounds(date, minDate, maxDate) {
|
|
13
|
+
return !!minDate && compareDatePart(minDate, date) > 0 || !!maxDate && compareDatePart(maxDate, date) < 0;
|
|
14
|
+
}
|
|
15
|
+
function useFocusLogic() {
|
|
16
|
+
const inputRef = React.useRef(null);
|
|
17
|
+
const preventFocusOpeningPicker = React.useRef(false);
|
|
18
|
+
const focus = () => {
|
|
19
|
+
var _inputRef_current, _inputRef_current_focus;
|
|
20
|
+
(_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : (_inputRef_current_focus = _inputRef_current.focus) === null || _inputRef_current_focus === void 0 ? void 0 : _inputRef_current_focus.call(_inputRef_current);
|
|
21
|
+
};
|
|
22
|
+
const preventNextFocusOpeningPicker = () => {
|
|
23
|
+
preventFocusOpeningPicker.current = true;
|
|
24
|
+
};
|
|
25
|
+
return [focus, inputRef, preventFocusOpeningPicker, preventNextFocusOpeningPicker];
|
|
26
|
+
}
|
|
27
|
+
function useCalendarVisibility({
|
|
28
|
+
allowTextInput,
|
|
29
|
+
onAfterMenuDismiss
|
|
30
|
+
}, focus) {
|
|
31
|
+
const [isCalendarShown, setIsCalendarShown] = React.useState(false);
|
|
32
|
+
const isMounted = React.useRef(false);
|
|
33
|
+
React.useEffect(() => {
|
|
34
|
+
if (isMounted.current && !isCalendarShown) {
|
|
35
|
+
// If DatePicker's menu (Calendar) is closed, run onAfterMenuDismiss
|
|
36
|
+
onAfterMenuDismiss === null || onAfterMenuDismiss === void 0 ? void 0 : onAfterMenuDismiss();
|
|
37
|
+
}
|
|
38
|
+
isMounted.current = true;
|
|
39
|
+
},
|
|
40
|
+
// Should only run on allowTextInput or isCalendarShown change
|
|
41
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
42
|
+
[allowTextInput, isCalendarShown]);
|
|
43
|
+
return [isCalendarShown, setIsCalendarShown];
|
|
44
|
+
}
|
|
45
|
+
function useSelectedDate({
|
|
46
|
+
formatDate,
|
|
47
|
+
onSelectDate,
|
|
48
|
+
value
|
|
49
|
+
}) {
|
|
50
|
+
const [selectedDate, setSelectedDateState] = useControllableState({
|
|
51
|
+
initialState: undefined,
|
|
52
|
+
state: value
|
|
53
|
+
});
|
|
54
|
+
const [formattedDate, setFormattedDate] = React.useState(() => value && formatDate ? formatDate(value) : '');
|
|
55
|
+
const setSelectedDate = newDate => {
|
|
56
|
+
if (selectedDate === undefined && newDate !== undefined || selectedDate !== undefined && newDate === undefined || newDate && selectedDate && (newDate > selectedDate || newDate < selectedDate)) {
|
|
57
|
+
onSelectDate === null || onSelectDate === void 0 ? void 0 : onSelectDate(newDate);
|
|
58
|
+
}
|
|
59
|
+
setSelectedDateState(newDate);
|
|
60
|
+
setFormattedDate(newDate && formatDate ? formatDate(newDate) : '');
|
|
61
|
+
};
|
|
62
|
+
React.useEffect(() => {
|
|
63
|
+
setFormattedDate(value && formatDate ? formatDate(value) : '');
|
|
64
|
+
}, [formatDate, value]);
|
|
65
|
+
return [selectedDate, formattedDate, setSelectedDate, setFormattedDate];
|
|
66
|
+
}
|
|
67
|
+
function useErrorMessage({
|
|
68
|
+
allowTextInput,
|
|
69
|
+
formatDate,
|
|
70
|
+
isRequired,
|
|
71
|
+
maxDate,
|
|
72
|
+
minDate,
|
|
73
|
+
onSelectDate,
|
|
74
|
+
parseDateFromString,
|
|
75
|
+
strings
|
|
76
|
+
}, selectedDate, setSelectedDate, inputValue, isCalendarShown) {
|
|
77
|
+
const [errorMessage, setErrorMessage] = React.useState();
|
|
78
|
+
const [statusMessage, setStatusMessage] = React.useState();
|
|
79
|
+
const validateTextInput = (date = null) => {
|
|
80
|
+
if (allowTextInput) {
|
|
81
|
+
if (inputValue || date) {
|
|
82
|
+
// Don't parse if the selected date has the same formatted string as what we're about to parse.
|
|
83
|
+
// The formatted string might be ambiguous (ex: "1/2/3" or "New Year Eve") and the parser might
|
|
84
|
+
// not be able to come up with the exact same date.
|
|
85
|
+
if (selectedDate && !errorMessage && formatDate && formatDate(date !== null && date !== void 0 ? date : selectedDate) === inputValue) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
date = date || parseDateFromString(inputValue);
|
|
89
|
+
// Check if date is null, or date is Invalid Date
|
|
90
|
+
if (!date || isNaN(date.getTime())) {
|
|
91
|
+
// Reset invalid input field, if formatting is available
|
|
92
|
+
setSelectedDate(selectedDate);
|
|
93
|
+
// default the newer isResetStatusMessage string to invalidInputErrorMessage for legacy support
|
|
94
|
+
const selectedText = formatDate ? formatDate(selectedDate) : '';
|
|
95
|
+
const statusText = strings.isResetStatusMessage ? strings.isResetStatusMessage.replace('{0}', inputValue).replace('{1}', selectedText) : strings.invalidInputErrorMessage || '';
|
|
96
|
+
setStatusMessage(statusText);
|
|
97
|
+
} else {
|
|
98
|
+
// Check against optional date boundaries
|
|
99
|
+
if (isDateOutOfBounds(date, minDate, maxDate)) {
|
|
100
|
+
setErrorMessage(strings.isOutOfBoundsErrorMessage || ' ');
|
|
101
|
+
} else {
|
|
102
|
+
setSelectedDate(date);
|
|
103
|
+
setErrorMessage(undefined);
|
|
104
|
+
setStatusMessage(undefined);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
// Only show error for empty inputValue if it is a required field
|
|
109
|
+
setErrorMessage(isRequired ? strings.isRequiredErrorMessage || ' ' : undefined);
|
|
110
|
+
// If no input date string or input date string is invalid
|
|
111
|
+
// date variable will be null, callback should expect null value for this case
|
|
112
|
+
onSelectDate === null || onSelectDate === void 0 ? void 0 : onSelectDate(date);
|
|
113
|
+
}
|
|
114
|
+
} else if (isRequired && !inputValue) {
|
|
115
|
+
// Check when DatePicker is a required field but has NO input value
|
|
116
|
+
setErrorMessage(strings.isRequiredErrorMessage || ' ');
|
|
117
|
+
} else {
|
|
118
|
+
// Cleanup the error message and status message
|
|
119
|
+
setErrorMessage(undefined);
|
|
120
|
+
setStatusMessage(undefined);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const minDatePartHashValue = minDate && getDatePartHashValue(minDate);
|
|
124
|
+
const maxDatePartHashValue = maxDate && getDatePartHashValue(maxDate);
|
|
125
|
+
const selectedDatePartHashValue = selectedDate && getDatePartHashValue(selectedDate);
|
|
126
|
+
React.useEffect(() => {
|
|
127
|
+
if (isRequired && !selectedDate) {
|
|
128
|
+
setErrorMessage(strings.isRequiredErrorMessage || ' ');
|
|
129
|
+
} else if (selectedDate && isDateOutOfBounds(selectedDate, minDate, maxDate)) {
|
|
130
|
+
setErrorMessage(strings.isOutOfBoundsErrorMessage || ' ');
|
|
131
|
+
} else {
|
|
132
|
+
setErrorMessage(undefined);
|
|
133
|
+
}
|
|
134
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
135
|
+
}, [
|
|
136
|
+
// We don't want to compare the date itself, since two instances of date at the same time are not equal
|
|
137
|
+
minDatePartHashValue, maxDatePartHashValue, selectedDatePartHashValue, isRequired]);
|
|
138
|
+
return [isCalendarShown ? undefined : errorMessage, validateTextInput, setErrorMessage, isCalendarShown ? undefined : statusMessage, setStatusMessage];
|
|
139
|
+
}
|
|
140
|
+
const defaultFormatDate = date => date ? date.toDateString() : '';
|
|
141
|
+
const defaultParseDateFromString = dateStr => {
|
|
142
|
+
const date = Date.parse(dateStr);
|
|
143
|
+
return date ? new Date(date) : null;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Create the state required to render DatePicker.
|
|
147
|
+
*
|
|
148
|
+
* The returned state can be modified with hooks such as useDatePickerStyles_unstable,
|
|
149
|
+
* before being passed to renderDatePicker_unstable.
|
|
150
|
+
*
|
|
151
|
+
* @param props - props from this instance of DatePicker
|
|
152
|
+
* @param ref - reference to root HTMLElement of DatePicker
|
|
153
|
+
*/
|
|
154
|
+
export const useDatePicker_unstable = (props, ref) => {
|
|
155
|
+
var _props_input;
|
|
156
|
+
const {
|
|
157
|
+
allowTextInput = false,
|
|
158
|
+
allFocusable = false,
|
|
159
|
+
borderless = false,
|
|
160
|
+
dateTimeFormatter,
|
|
161
|
+
disabled,
|
|
162
|
+
disableAutoFocus = true,
|
|
163
|
+
firstDayOfWeek = DayOfWeek.Sunday,
|
|
164
|
+
firstWeekOfYear = FirstWeekOfYear.FirstDay,
|
|
165
|
+
formatDate = defaultFormatDate,
|
|
166
|
+
highlightCurrentMonth = false,
|
|
167
|
+
highlightSelectedMonth = false,
|
|
168
|
+
initialPickerDate = new Date(),
|
|
169
|
+
isMonthPickerVisible = true,
|
|
170
|
+
isRequired = false,
|
|
171
|
+
label,
|
|
172
|
+
maxDate,
|
|
173
|
+
minDate,
|
|
174
|
+
onAfterMenuDismiss,
|
|
175
|
+
onSelectDate: onUserSelectDate,
|
|
176
|
+
parseDateFromString = defaultParseDateFromString,
|
|
177
|
+
placeholder,
|
|
178
|
+
showCloseButton = false,
|
|
179
|
+
showGoToToday = true,
|
|
180
|
+
showMonthPickerAsOverlay = false,
|
|
181
|
+
showWeekNumbers = false,
|
|
182
|
+
strings = defaultDatePickerStrings,
|
|
183
|
+
tabIndex,
|
|
184
|
+
today,
|
|
185
|
+
underlined = false,
|
|
186
|
+
value
|
|
187
|
+
} = props;
|
|
188
|
+
const id = useId('DatePicker', props.id);
|
|
189
|
+
const calloutId = useId('DatePicker-Callout');
|
|
190
|
+
const calendar = React.useRef(null);
|
|
191
|
+
const [focus, _, preventFocusOpeningPicker, preventNextFocusOpeningPicker] = useFocusLogic();
|
|
192
|
+
const [isCalendarShown, setIsCalendarShown] = useCalendarVisibility({
|
|
193
|
+
allowTextInput,
|
|
194
|
+
onAfterMenuDismiss
|
|
195
|
+
}, focus);
|
|
196
|
+
const [selectedDate, formattedDate, setSelectedDate, setFormattedDate] = useSelectedDate({
|
|
197
|
+
formatDate,
|
|
198
|
+
onSelectDate: onUserSelectDate,
|
|
199
|
+
value
|
|
200
|
+
});
|
|
201
|
+
const [errorMessage, validateTextInput, setErrorMessage, statusMessage, setStatusMessage] = useErrorMessage({
|
|
202
|
+
allowTextInput,
|
|
203
|
+
formatDate,
|
|
204
|
+
isRequired,
|
|
205
|
+
maxDate,
|
|
206
|
+
minDate,
|
|
207
|
+
onSelectDate: onUserSelectDate,
|
|
208
|
+
parseDateFromString,
|
|
209
|
+
strings
|
|
210
|
+
}, selectedDate, setSelectedDate, formattedDate, isCalendarShown);
|
|
211
|
+
const dismissDatePickerPopup = React.useCallback(newlySelectedDate => {
|
|
212
|
+
if (isCalendarShown) {
|
|
213
|
+
setIsCalendarShown(false);
|
|
214
|
+
validateTextInput(newlySelectedDate);
|
|
215
|
+
if (!allowTextInput && newlySelectedDate) {
|
|
216
|
+
setSelectedDate(newlySelectedDate);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}, [allowTextInput, isCalendarShown, setIsCalendarShown, setSelectedDate, validateTextInput]);
|
|
220
|
+
const showDatePickerPopup = React.useCallback(() => {
|
|
221
|
+
if (!isCalendarShown) {
|
|
222
|
+
preventNextFocusOpeningPicker();
|
|
223
|
+
setIsCalendarShown(true);
|
|
224
|
+
}
|
|
225
|
+
}, [isCalendarShown, preventNextFocusOpeningPicker, setIsCalendarShown]);
|
|
226
|
+
/**
|
|
227
|
+
* Callback for closing the calendar callout
|
|
228
|
+
*/
|
|
229
|
+
const calendarDismissed = React.useCallback(newlySelectedDate => {
|
|
230
|
+
preventNextFocusOpeningPicker();
|
|
231
|
+
dismissDatePickerPopup(newlySelectedDate);
|
|
232
|
+
// don't need to focus the text box, if necessary the focusTrapZone will do it
|
|
233
|
+
}, [dismissDatePickerPopup, preventNextFocusOpeningPicker]);
|
|
234
|
+
const handleEscKey = React.useCallback(ev => {
|
|
235
|
+
if (isCalendarShown) {
|
|
236
|
+
ev.stopPropagation();
|
|
237
|
+
calendarDismissed();
|
|
238
|
+
}
|
|
239
|
+
}, [calendarDismissed, isCalendarShown]);
|
|
240
|
+
React.useImperativeHandle(props.componentRef, () => ({
|
|
241
|
+
focus,
|
|
242
|
+
reset() {
|
|
243
|
+
setIsCalendarShown(false);
|
|
244
|
+
setSelectedDate(undefined);
|
|
245
|
+
setErrorMessage(undefined);
|
|
246
|
+
setStatusMessage(undefined);
|
|
247
|
+
},
|
|
248
|
+
showDatePickerPopup
|
|
249
|
+
}), [focus, setErrorMessage, setIsCalendarShown, setSelectedDate, setStatusMessage, showDatePickerPopup]);
|
|
250
|
+
const onInputFocus = React.useCallback(() => {
|
|
251
|
+
if (disableAutoFocus) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if (!allowTextInput) {
|
|
255
|
+
if (!preventFocusOpeningPicker.current) {
|
|
256
|
+
showDatePickerPopup();
|
|
257
|
+
}
|
|
258
|
+
preventFocusOpeningPicker.current = false;
|
|
259
|
+
}
|
|
260
|
+
}, [allowTextInput, disableAutoFocus, preventFocusOpeningPicker, showDatePickerPopup]);
|
|
261
|
+
const onInputBlur = React.useCallback(() => {
|
|
262
|
+
validateTextInput();
|
|
263
|
+
}, [validateTextInput]);
|
|
264
|
+
const onInputChange = React.useCallback((ev, data) => {
|
|
265
|
+
const {
|
|
266
|
+
value: newValue
|
|
267
|
+
} = data;
|
|
268
|
+
if (allowTextInput) {
|
|
269
|
+
if (isCalendarShown) {
|
|
270
|
+
dismissDatePickerPopup();
|
|
271
|
+
}
|
|
272
|
+
setFormattedDate(newValue);
|
|
273
|
+
}
|
|
274
|
+
}, [allowTextInput, dismissDatePickerPopup, isCalendarShown, setFormattedDate]);
|
|
275
|
+
const onInputKeyDown = React.useCallback(ev => {
|
|
276
|
+
switch (ev.key) {
|
|
277
|
+
case Enter:
|
|
278
|
+
ev.preventDefault();
|
|
279
|
+
ev.stopPropagation();
|
|
280
|
+
if (!isCalendarShown) {
|
|
281
|
+
validateTextInput();
|
|
282
|
+
showDatePickerPopup();
|
|
283
|
+
} else {
|
|
284
|
+
// When DatePicker allows input date string directly,
|
|
285
|
+
// it is expected to hit another enter to close the popup
|
|
286
|
+
if (props.allowTextInput) {
|
|
287
|
+
dismissDatePickerPopup();
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
break;
|
|
291
|
+
case Escape:
|
|
292
|
+
handleEscKey(ev);
|
|
293
|
+
break;
|
|
294
|
+
case ArrowDown:
|
|
295
|
+
if (ev.altKey && !isCalendarShown) {
|
|
296
|
+
showDatePickerPopup();
|
|
297
|
+
}
|
|
298
|
+
break;
|
|
299
|
+
default:
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
}, [dismissDatePickerPopup, handleEscKey, isCalendarShown, props.allowTextInput, showDatePickerPopup, validateTextInput]);
|
|
303
|
+
const onInputClick = React.useCallback(() => {
|
|
304
|
+
// default openOnClick to !props.disableAutoFocus for legacy support of disableAutoFocus behavior
|
|
305
|
+
const openOnClick = props.openOnClick || !props.disableAutoFocus;
|
|
306
|
+
if (openOnClick && !isCalendarShown && !props.disabled) {
|
|
307
|
+
showDatePickerPopup();
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
if (props.allowTextInput) {
|
|
311
|
+
dismissDatePickerPopup();
|
|
312
|
+
}
|
|
313
|
+
}, [dismissDatePickerPopup, isCalendarShown, props.allowTextInput, props.disabled, props.disableAutoFocus, props.openOnClick, showDatePickerPopup]);
|
|
314
|
+
const onIconClick = ev => {
|
|
315
|
+
ev.stopPropagation();
|
|
316
|
+
if (!isCalendarShown && !props.disabled) {
|
|
317
|
+
showDatePickerPopup();
|
|
318
|
+
} else if (props.allowTextInput) {
|
|
319
|
+
dismissDatePickerPopup();
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
const inputId = props.id && props.id !== id ? props.id : id + '-label';
|
|
323
|
+
const inputAppearance = underlined ? 'underline' : borderless ? 'filled-lighter' : 'outline';
|
|
324
|
+
const onPopoverOpenChange = React.useCallback((ev, data) => {
|
|
325
|
+
if (!data.open) {
|
|
326
|
+
calendarDismissed();
|
|
327
|
+
}
|
|
328
|
+
}, [calendarDismissed]);
|
|
329
|
+
const root = getNativeElementProps('div', {
|
|
330
|
+
ref,
|
|
331
|
+
...props
|
|
332
|
+
});
|
|
333
|
+
const inputRef = React.useRef(null);
|
|
334
|
+
const inputShorthand = resolveShorthand(props.input, {
|
|
335
|
+
required: true,
|
|
336
|
+
defaultProps: {
|
|
337
|
+
appearance: inputAppearance,
|
|
338
|
+
'aria-controls': isCalendarShown ? calloutId : undefined,
|
|
339
|
+
'aria-expanded': isCalendarShown,
|
|
340
|
+
'aria-haspopup': 'dialog',
|
|
341
|
+
'aria-label': props['aria-label'],
|
|
342
|
+
contentAfter: /*#__PURE__*/React.createElement(CalendarMonthRegular, {
|
|
343
|
+
onClick: onIconClick
|
|
344
|
+
}),
|
|
345
|
+
disabled,
|
|
346
|
+
id: inputId,
|
|
347
|
+
placeholder,
|
|
348
|
+
readOnly: !allowTextInput,
|
|
349
|
+
required: isRequired,
|
|
350
|
+
role: 'combobox',
|
|
351
|
+
tabIndex,
|
|
352
|
+
root: {
|
|
353
|
+
ref: inputRef
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
inputShorthand.onBlur = onInputBlur;
|
|
358
|
+
inputShorthand.onClick = onInputClick;
|
|
359
|
+
inputShorthand.onFocus = onInputFocus;
|
|
360
|
+
inputShorthand.onKeyDown = onInputKeyDown;
|
|
361
|
+
inputShorthand.onChange = mergeCallbacks(onInputChange, (_props_input = props.input) === null || _props_input === void 0 ? void 0 : _props_input.onChange);
|
|
362
|
+
inputShorthand.value = formattedDate;
|
|
363
|
+
const fieldShorthand = resolveShorthand(props.field, {
|
|
364
|
+
defaultProps: {
|
|
365
|
+
label,
|
|
366
|
+
required: isRequired,
|
|
367
|
+
validationMessage: errorMessage !== null && errorMessage !== void 0 ? errorMessage : statusMessage,
|
|
368
|
+
validationState: errorMessage ? 'error' : undefined
|
|
369
|
+
},
|
|
370
|
+
required: true
|
|
371
|
+
});
|
|
372
|
+
const wrapperShorthand = resolveShorthand(props.wrapper, {
|
|
373
|
+
defaultProps: {
|
|
374
|
+
'aria-owns': isCalendarShown ? calloutId : undefined
|
|
375
|
+
},
|
|
376
|
+
required: true
|
|
377
|
+
});
|
|
378
|
+
const positioningRef = React.useRef(null);
|
|
379
|
+
const popoverShorthand = resolveShorthand(props.popover, {
|
|
380
|
+
defaultProps: {
|
|
381
|
+
onOpenChange: onPopoverOpenChange,
|
|
382
|
+
open: isCalendarShown,
|
|
383
|
+
positioning: {
|
|
384
|
+
align: 'start',
|
|
385
|
+
position: 'below',
|
|
386
|
+
positioningRef
|
|
387
|
+
},
|
|
388
|
+
trapFocus: true
|
|
389
|
+
},
|
|
390
|
+
required: true
|
|
391
|
+
});
|
|
392
|
+
const popoverSurfaceShorthand = resolveShorthand(props.popoverSurface, {
|
|
393
|
+
defaultProps: {
|
|
394
|
+
'aria-label': 'Calendar',
|
|
395
|
+
id: calloutId,
|
|
396
|
+
role: 'dialog'
|
|
397
|
+
},
|
|
398
|
+
required: true
|
|
399
|
+
});
|
|
400
|
+
const calendarShorthand = resolveShorthand(props.calendar, {
|
|
401
|
+
required: true,
|
|
402
|
+
defaultProps: {
|
|
403
|
+
allFocusable,
|
|
404
|
+
componentRef: calendar,
|
|
405
|
+
dateTimeFormatter,
|
|
406
|
+
firstDayOfWeek,
|
|
407
|
+
firstWeekOfYear,
|
|
408
|
+
highlightCurrentMonth,
|
|
409
|
+
highlightSelectedMonth,
|
|
410
|
+
isMonthPickerVisible,
|
|
411
|
+
maxDate,
|
|
412
|
+
minDate,
|
|
413
|
+
onDismiss: calendarDismissed,
|
|
414
|
+
showCloseButton,
|
|
415
|
+
showGoToToday,
|
|
416
|
+
showMonthPickerAsOverlay,
|
|
417
|
+
showWeekNumbers,
|
|
418
|
+
strings,
|
|
419
|
+
today,
|
|
420
|
+
value: selectedDate || initialPickerDate
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
const state = {
|
|
424
|
+
disabled: !!disabled,
|
|
425
|
+
isDatePickerShown: isCalendarShown,
|
|
426
|
+
// Slots definition
|
|
427
|
+
components: {
|
|
428
|
+
root: 'div',
|
|
429
|
+
field: Field,
|
|
430
|
+
input: Input,
|
|
431
|
+
wrapper: 'div',
|
|
432
|
+
popover: Popover,
|
|
433
|
+
popoverSurface: PopoverSurface,
|
|
434
|
+
calendar: Calendar
|
|
435
|
+
},
|
|
436
|
+
calendar: calendarShorthand,
|
|
437
|
+
input: inputShorthand,
|
|
438
|
+
field: fieldShorthand,
|
|
439
|
+
popover: popoverShorthand,
|
|
440
|
+
popoverSurface: popoverSurfaceShorthand,
|
|
441
|
+
root,
|
|
442
|
+
wrapper: wrapperShorthand
|
|
443
|
+
};
|
|
444
|
+
state.calendar.onSelectDate = mergeCallbacks(state.calendar.onSelectDate, calendarDismissed);
|
|
445
|
+
React.useEffect(() => {
|
|
446
|
+
if (inputRef.current) {
|
|
447
|
+
var _positioningRef_current;
|
|
448
|
+
(_positioningRef_current = positioningRef.current) === null || _positioningRef_current === void 0 ? void 0 : _positioningRef_current.setTarget(inputRef.current);
|
|
449
|
+
}
|
|
450
|
+
}, [inputRef, positioningRef]);
|
|
451
|
+
return state;
|
|
452
|
+
};
|
|
453
|
+
//# sourceMappingURL=useDatePicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","ArrowDown","Enter","Escape","CalendarMonthRegular","Input","Field","getNativeElementProps","mergeCallbacks","resolveShorthand","useControllableState","useId","compareDatePart","getDatePartHashValue","DayOfWeek","FirstWeekOfYear","Calendar","defaultDatePickerStrings","Popover","PopoverSurface","isDateOutOfBounds","date","minDate","maxDate","useFocusLogic","inputRef","useRef","preventFocusOpeningPicker","focus","_inputRef_current","_inputRef_current_focus","current","call","preventNextFocusOpeningPicker","useCalendarVisibility","allowTextInput","onAfterMenuDismiss","isCalendarShown","setIsCalendarShown","useState","isMounted","useEffect","useSelectedDate","formatDate","onSelectDate","value","selectedDate","setSelectedDateState","initialState","undefined","state","formattedDate","setFormattedDate","setSelectedDate","newDate","useErrorMessage","isRequired","parseDateFromString","strings","inputValue","errorMessage","setErrorMessage","statusMessage","setStatusMessage","validateTextInput","isNaN","getTime","selectedText","statusText","isResetStatusMessage","replace","invalidInputErrorMessage","isOutOfBoundsErrorMessage","isRequiredErrorMessage","minDatePartHashValue","maxDatePartHashValue","selectedDatePartHashValue","defaultFormatDate","toDateString","defaultParseDateFromString","dateStr","Date","parse","useDatePicker_unstable","props","ref","_props_input","allFocusable","borderless","dateTimeFormatter","disabled","disableAutoFocus","firstDayOfWeek","Sunday","firstWeekOfYear","FirstDay","highlightCurrentMonth","highlightSelectedMonth","initialPickerDate","isMonthPickerVisible","label","onUserSelectDate","placeholder","showCloseButton","showGoToToday","showMonthPickerAsOverlay","showWeekNumbers","tabIndex","today","underlined","id","calloutId","calendar","_","dismissDatePickerPopup","useCallback","newlySelectedDate","showDatePickerPopup","calendarDismissed","handleEscKey","ev","stopPropagation","useImperativeHandle","componentRef","reset","onInputFocus","onInputBlur","onInputChange","data","newValue","onInputKeyDown","key","preventDefault","altKey","onInputClick","openOnClick","onIconClick","inputId","inputAppearance","onPopoverOpenChange","open","root","inputShorthand","input","required","defaultProps","appearance","contentAfter","createElement","onClick","readOnly","role","onBlur","onFocus","onKeyDown","onChange","fieldShorthand","field","validationMessage","validationState","wrapperShorthand","wrapper","positioningRef","popoverShorthand","popover","onOpenChange","positioning","align","position","trapFocus","popoverSurfaceShorthand","popoverSurface","calendarShorthand","onDismiss","isDatePickerShown","components","_positioningRef_current","setTarget"],"sources":["../../../src/components/DatePicker/useDatePicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ArrowDown, Enter, Escape } from '@fluentui/keyboard-keys';\nimport { CalendarMonthRegular } from '@fluentui/react-icons';\nimport { Input } from '@fluentui/react-input';\nimport { Field } from '@fluentui/react-field';\nimport {\n getNativeElementProps,\n mergeCallbacks,\n resolveShorthand,\n useControllableState,\n useId,\n} from '@fluentui/react-utilities';\nimport { compareDatePart, getDatePartHashValue, DayOfWeek, FirstWeekOfYear } from '../../utils';\nimport { Calendar } from '../Calendar/Calendar';\nimport { defaultDatePickerStrings } from './defaults';\nimport { OnOpenChangeData, OpenPopoverEvents, Popover } from '@fluentui/react-popover';\nimport { PopoverSurface } from '@fluentui/react-popover';\nimport { PositioningImperativeRef } from '@fluentui/react-positioning';\nimport type { PopoverProps } from '@fluentui/react-popover';\nimport type { InputProps, InputOnChangeData } from '@fluentui/react-input';\nimport type { CalendarProps, ICalendar } from '../Calendar/Calendar.types';\nimport type { DatePickerProps, DatePickerState } from './DatePicker.types';\n\nfunction isDateOutOfBounds(date: Date, minDate?: Date, maxDate?: Date): boolean {\n return (!!minDate && compareDatePart(minDate!, date) > 0) || (!!maxDate && compareDatePart(maxDate!, date) < 0);\n}\n\nfunction useFocusLogic() {\n const inputRef = React.useRef<{ focus: () => void }>(null);\n const preventFocusOpeningPicker = React.useRef(false);\n\n const focus = () => {\n inputRef.current?.focus?.();\n };\n\n const preventNextFocusOpeningPicker = () => {\n preventFocusOpeningPicker.current = true;\n };\n\n return [focus, inputRef, preventFocusOpeningPicker, preventNextFocusOpeningPicker] as const;\n}\n\nfunction useCalendarVisibility({ allowTextInput, onAfterMenuDismiss }: DatePickerProps, focus: () => void) {\n const [isCalendarShown, setIsCalendarShown] = React.useState(false);\n const isMounted = React.useRef(false);\n\n React.useEffect(\n () => {\n if (isMounted.current && !isCalendarShown) {\n // If DatePicker's menu (Calendar) is closed, run onAfterMenuDismiss\n onAfterMenuDismiss?.();\n }\n isMounted.current = true;\n },\n // Should only run on allowTextInput or isCalendarShown change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [allowTextInput, isCalendarShown],\n );\n\n return [isCalendarShown, setIsCalendarShown] as const;\n}\n\nfunction useSelectedDate({ formatDate, onSelectDate, value }: DatePickerProps) {\n const [selectedDate, setSelectedDateState] = useControllableState({\n initialState: undefined,\n state: value,\n });\n const [formattedDate, setFormattedDate] = React.useState(() => (value && formatDate ? formatDate(value) : ''));\n\n const setSelectedDate = (newDate: Date | undefined) => {\n if (\n (selectedDate === undefined && newDate !== undefined) ||\n (selectedDate !== undefined && newDate === undefined) ||\n (newDate && selectedDate && (newDate > selectedDate || newDate < selectedDate))\n ) {\n onSelectDate?.(newDate);\n }\n\n setSelectedDateState(newDate);\n setFormattedDate(newDate && formatDate ? formatDate(newDate) : '');\n };\n\n React.useEffect(() => {\n setFormattedDate(value && formatDate ? formatDate(value) : '');\n }, [formatDate, value]);\n\n return [selectedDate, formattedDate, setSelectedDate, setFormattedDate] as const;\n}\n\nfunction useErrorMessage(\n {\n allowTextInput,\n formatDate,\n isRequired,\n maxDate,\n minDate,\n onSelectDate,\n parseDateFromString,\n strings,\n }: DatePickerProps,\n selectedDate: Date | undefined,\n setSelectedDate: (date: Date | undefined) => void,\n inputValue: string,\n isCalendarShown: boolean,\n) {\n const [errorMessage, setErrorMessage] = React.useState<string | undefined>();\n const [statusMessage, setStatusMessage] = React.useState<string | undefined>();\n\n const validateTextInput = (date: Date | null = null): void => {\n if (allowTextInput) {\n if (inputValue || date) {\n // Don't parse if the selected date has the same formatted string as what we're about to parse.\n // The formatted string might be ambiguous (ex: \"1/2/3\" or \"New Year Eve\") and the parser might\n // not be able to come up with the exact same date.\n if (selectedDate && !errorMessage && formatDate && formatDate(date ?? selectedDate) === inputValue) {\n return;\n }\n date = date || parseDateFromString!(inputValue);\n\n // Check if date is null, or date is Invalid Date\n if (!date || isNaN(date.getTime())) {\n // Reset invalid input field, if formatting is available\n setSelectedDate(selectedDate);\n // default the newer isResetStatusMessage string to invalidInputErrorMessage for legacy support\n const selectedText = formatDate ? formatDate(selectedDate) : '';\n const statusText = strings!.isResetStatusMessage\n ? strings!.isResetStatusMessage.replace('{0}', inputValue).replace('{1}', selectedText)\n : strings!.invalidInputErrorMessage || '';\n setStatusMessage(statusText);\n } else {\n // Check against optional date boundaries\n if (isDateOutOfBounds(date, minDate, maxDate)) {\n setErrorMessage(strings!.isOutOfBoundsErrorMessage || ' ');\n } else {\n setSelectedDate(date);\n setErrorMessage(undefined);\n setStatusMessage(undefined);\n }\n }\n } else {\n // Only show error for empty inputValue if it is a required field\n setErrorMessage(isRequired ? strings!.isRequiredErrorMessage || ' ' : undefined);\n\n // If no input date string or input date string is invalid\n // date variable will be null, callback should expect null value for this case\n onSelectDate?.(date);\n }\n } else if (isRequired && !inputValue) {\n // Check when DatePicker is a required field but has NO input value\n setErrorMessage(strings!.isRequiredErrorMessage || ' ');\n } else {\n // Cleanup the error message and status message\n setErrorMessage(undefined);\n setStatusMessage(undefined);\n }\n };\n\n const minDatePartHashValue = minDate && getDatePartHashValue(minDate);\n const maxDatePartHashValue = maxDate && getDatePartHashValue(maxDate);\n const selectedDatePartHashValue = selectedDate && getDatePartHashValue(selectedDate);\n React.useEffect(() => {\n if (isRequired && !selectedDate) {\n setErrorMessage(strings!.isRequiredErrorMessage || ' ');\n } else if (selectedDate && isDateOutOfBounds(selectedDate, minDate, maxDate)) {\n setErrorMessage(strings!.isOutOfBoundsErrorMessage || ' ');\n } else {\n setErrorMessage(undefined);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n // We don't want to compare the date itself, since two instances of date at the same time are not equal\n minDatePartHashValue,\n maxDatePartHashValue,\n selectedDatePartHashValue,\n isRequired,\n ]);\n\n return [\n isCalendarShown ? undefined : errorMessage,\n validateTextInput,\n setErrorMessage,\n isCalendarShown ? undefined : statusMessage,\n setStatusMessage,\n ] as const;\n}\n\nconst defaultFormatDate = (date?: Date) => (date ? date.toDateString() : '');\nconst defaultParseDateFromString = (dateStr: string) => {\n const date = Date.parse(dateStr);\n return date ? new Date(date) : null;\n};\n\n/**\n * Create the state required to render DatePicker.\n *\n * The returned state can be modified with hooks such as useDatePickerStyles_unstable,\n * before being passed to renderDatePicker_unstable.\n *\n * @param props - props from this instance of DatePicker\n * @param ref - reference to root HTMLElement of DatePicker\n */\nexport const useDatePicker_unstable = (props: DatePickerProps, ref: React.Ref<HTMLElement>): DatePickerState => {\n const {\n allowTextInput = false,\n allFocusable = false,\n borderless = false,\n dateTimeFormatter,\n disabled,\n disableAutoFocus = true,\n firstDayOfWeek = DayOfWeek.Sunday,\n firstWeekOfYear = FirstWeekOfYear.FirstDay,\n formatDate = defaultFormatDate,\n highlightCurrentMonth = false,\n highlightSelectedMonth = false,\n initialPickerDate = new Date(),\n isMonthPickerVisible = true,\n isRequired = false,\n label,\n maxDate,\n minDate,\n onAfterMenuDismiss,\n onSelectDate: onUserSelectDate,\n parseDateFromString = defaultParseDateFromString,\n placeholder,\n showCloseButton = false,\n showGoToToday = true,\n showMonthPickerAsOverlay = false,\n showWeekNumbers = false,\n strings = defaultDatePickerStrings,\n tabIndex,\n today,\n underlined = false,\n value,\n } = props;\n\n const id = useId('DatePicker', props.id);\n const calloutId = useId('DatePicker-Callout');\n\n const calendar = React.useRef<ICalendar>(null);\n\n const [focus, _, preventFocusOpeningPicker, preventNextFocusOpeningPicker] = useFocusLogic();\n const [isCalendarShown, setIsCalendarShown] = useCalendarVisibility({ allowTextInput, onAfterMenuDismiss }, focus);\n const [selectedDate, formattedDate, setSelectedDate, setFormattedDate] = useSelectedDate({\n formatDate,\n onSelectDate: onUserSelectDate,\n value,\n });\n const [errorMessage, validateTextInput, setErrorMessage, statusMessage, setStatusMessage] = useErrorMessage(\n {\n allowTextInput,\n formatDate,\n isRequired,\n maxDate,\n minDate,\n onSelectDate: onUserSelectDate,\n parseDateFromString,\n strings,\n },\n selectedDate,\n setSelectedDate,\n formattedDate,\n isCalendarShown,\n );\n\n const dismissDatePickerPopup = React.useCallback(\n (newlySelectedDate?: Date): void => {\n if (isCalendarShown) {\n setIsCalendarShown(false);\n\n validateTextInput(newlySelectedDate);\n if (!allowTextInput && newlySelectedDate) {\n setSelectedDate(newlySelectedDate);\n }\n }\n },\n [allowTextInput, isCalendarShown, setIsCalendarShown, setSelectedDate, validateTextInput],\n );\n\n const showDatePickerPopup = React.useCallback((): void => {\n if (!isCalendarShown) {\n preventNextFocusOpeningPicker();\n setIsCalendarShown(true);\n }\n }, [isCalendarShown, preventNextFocusOpeningPicker, setIsCalendarShown]);\n\n /**\n * Callback for closing the calendar callout\n */\n const calendarDismissed = React.useCallback(\n (newlySelectedDate?: Date): void => {\n preventNextFocusOpeningPicker();\n dismissDatePickerPopup(newlySelectedDate);\n // don't need to focus the text box, if necessary the focusTrapZone will do it\n },\n [dismissDatePickerPopup, preventNextFocusOpeningPicker],\n );\n\n const handleEscKey = React.useCallback(\n (ev: React.KeyboardEvent<HTMLElement>): void => {\n if (isCalendarShown) {\n ev.stopPropagation();\n calendarDismissed();\n }\n },\n [calendarDismissed, isCalendarShown],\n );\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n focus,\n reset() {\n setIsCalendarShown(false);\n setSelectedDate(undefined);\n setErrorMessage(undefined);\n setStatusMessage(undefined);\n },\n showDatePickerPopup,\n }),\n [focus, setErrorMessage, setIsCalendarShown, setSelectedDate, setStatusMessage, showDatePickerPopup],\n );\n\n const onInputFocus = React.useCallback((): void => {\n if (disableAutoFocus) {\n return;\n }\n\n if (!allowTextInput) {\n if (!preventFocusOpeningPicker.current) {\n showDatePickerPopup();\n }\n preventFocusOpeningPicker.current = false;\n }\n }, [allowTextInput, disableAutoFocus, preventFocusOpeningPicker, showDatePickerPopup]);\n\n const onInputBlur = React.useCallback((): void => {\n validateTextInput();\n }, [validateTextInput]);\n\n const onInputChange = React.useCallback(\n (ev: React.FormEvent<HTMLInputElement | HTMLTextAreaElement>, data: InputOnChangeData): void => {\n const { value: newValue } = data;\n\n if (allowTextInput) {\n if (isCalendarShown) {\n dismissDatePickerPopup();\n }\n\n setFormattedDate(newValue);\n }\n },\n [allowTextInput, dismissDatePickerPopup, isCalendarShown, setFormattedDate],\n );\n\n const onInputKeyDown = React.useCallback(\n (ev: React.KeyboardEvent<HTMLElement>): void => {\n switch (ev.key) {\n case Enter:\n ev.preventDefault();\n ev.stopPropagation();\n if (!isCalendarShown) {\n validateTextInput();\n showDatePickerPopup();\n } else {\n // When DatePicker allows input date string directly,\n // it is expected to hit another enter to close the popup\n if (props.allowTextInput) {\n dismissDatePickerPopup();\n }\n }\n break;\n\n case Escape:\n handleEscKey(ev);\n break;\n\n case ArrowDown:\n if (ev.altKey && !isCalendarShown) {\n showDatePickerPopup();\n }\n break;\n\n default:\n break;\n }\n },\n [\n dismissDatePickerPopup,\n handleEscKey,\n isCalendarShown,\n props.allowTextInput,\n showDatePickerPopup,\n validateTextInput,\n ],\n );\n\n const onInputClick = React.useCallback((): void => {\n // default openOnClick to !props.disableAutoFocus for legacy support of disableAutoFocus behavior\n const openOnClick = props.openOnClick || !props.disableAutoFocus;\n if (openOnClick && !isCalendarShown && !props.disabled) {\n showDatePickerPopup();\n return;\n }\n if (props.allowTextInput) {\n dismissDatePickerPopup();\n }\n }, [\n dismissDatePickerPopup,\n isCalendarShown,\n props.allowTextInput,\n props.disabled,\n props.disableAutoFocus,\n props.openOnClick,\n showDatePickerPopup,\n ]);\n\n const onIconClick = (ev: React.MouseEvent<HTMLElement>): void => {\n ev.stopPropagation();\n if (!isCalendarShown && !props.disabled) {\n showDatePickerPopup();\n } else if (props.allowTextInput) {\n dismissDatePickerPopup();\n }\n };\n\n const inputId = props.id && props.id !== id ? props.id : id + '-label';\n\n const inputAppearance: InputProps['appearance'] = underlined\n ? 'underline'\n : borderless\n ? 'filled-lighter'\n : 'outline';\n\n const onPopoverOpenChange = React.useCallback(\n (ev: OpenPopoverEvents, data: OnOpenChangeData) => {\n if (!data.open) {\n calendarDismissed();\n }\n },\n [calendarDismissed],\n );\n\n const root = getNativeElementProps('div', {\n ref,\n ...props,\n });\n\n const inputRef = React.useRef<HTMLInputElement>(null);\n const inputShorthand = resolveShorthand(props.input, {\n required: true,\n defaultProps: {\n appearance: inputAppearance,\n 'aria-controls': isCalendarShown ? calloutId : undefined,\n 'aria-expanded': isCalendarShown,\n 'aria-haspopup': 'dialog',\n 'aria-label': props['aria-label'],\n contentAfter: <CalendarMonthRegular onClick={onIconClick as unknown as React.MouseEventHandler<SVGElement>} />,\n disabled,\n id: inputId,\n placeholder,\n readOnly: !allowTextInput,\n required: isRequired,\n role: 'combobox',\n tabIndex,\n root: {\n ref: inputRef,\n },\n },\n });\n inputShorthand.onBlur = onInputBlur;\n inputShorthand.onClick = onInputClick;\n inputShorthand.onFocus = onInputFocus;\n inputShorthand.onKeyDown = onInputKeyDown;\n inputShorthand.onChange = mergeCallbacks(onInputChange, props.input?.onChange);\n inputShorthand.value = formattedDate;\n\n const fieldShorthand = resolveShorthand(props.field, {\n defaultProps: {\n label,\n required: isRequired,\n validationMessage: errorMessage ?? statusMessage,\n validationState: errorMessage ? 'error' : undefined,\n },\n required: true,\n });\n\n const wrapperShorthand = resolveShorthand(props.wrapper, {\n defaultProps: {\n 'aria-owns': isCalendarShown ? calloutId : undefined,\n },\n required: true,\n });\n\n const positioningRef = React.useRef<PositioningImperativeRef>(null);\n const popoverShorthand = resolveShorthand(props.popover, {\n defaultProps: {\n onOpenChange: onPopoverOpenChange,\n open: isCalendarShown,\n positioning: { align: 'start', position: 'below', positioningRef },\n trapFocus: true,\n },\n required: true,\n });\n\n const popoverSurfaceShorthand = resolveShorthand(props.popoverSurface, {\n defaultProps: {\n 'aria-label': 'Calendar',\n id: calloutId,\n role: 'dialog',\n },\n required: true,\n });\n\n const calendarShorthand = resolveShorthand(props.calendar, {\n required: true,\n defaultProps: {\n allFocusable,\n componentRef: calendar,\n dateTimeFormatter,\n firstDayOfWeek,\n firstWeekOfYear,\n highlightCurrentMonth,\n highlightSelectedMonth,\n isMonthPickerVisible,\n maxDate,\n minDate,\n onDismiss: calendarDismissed,\n showCloseButton,\n showGoToToday,\n showMonthPickerAsOverlay,\n showWeekNumbers,\n strings,\n today,\n value: selectedDate || initialPickerDate,\n },\n });\n\n const state: DatePickerState = {\n disabled: !!disabled,\n isDatePickerShown: isCalendarShown,\n\n // Slots definition\n components: {\n root: 'div',\n field: Field,\n input: Input,\n wrapper: 'div',\n popover: Popover as React.FC<Partial<PopoverProps>>,\n popoverSurface: PopoverSurface,\n calendar: Calendar as React.FC<Partial<CalendarProps>>,\n },\n\n calendar: calendarShorthand,\n input: inputShorthand,\n field: fieldShorthand,\n popover: popoverShorthand,\n popoverSurface: popoverSurfaceShorthand,\n root,\n wrapper: wrapperShorthand,\n };\n\n state.calendar.onSelectDate = mergeCallbacks(state.calendar.onSelectDate, calendarDismissed);\n\n React.useEffect(() => {\n if (inputRef.current) {\n positioningRef.current?.setTarget(inputRef.current);\n }\n }, [inputRef, positioningRef]);\n\n return state;\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,SAAS,EAAEC,KAAK,EAAEC,MAAM,QAAQ;AACzC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,KAAK,QAAQ;AACtB,SAASC,KAAK,QAAQ;AACtB,SACEC,qBAAqB,EACrBC,cAAc,EACdC,gBAAgB,EAChBC,oBAAoB,EACpBC,KAAK,QACA;AACP,SAASC,eAAe,EAAEC,oBAAoB,EAAEC,SAAS,EAAEC,eAAe,QAAQ;AAClF,SAASC,QAAQ,QAAQ;AACzB,SAASC,wBAAwB,QAAQ;AACzC,SAA8CC,OAAO,QAAQ;AAC7D,SAASC,cAAc,QAAQ;AAO/B,SAASC,kBAAkBC,IAAU,EAAEC,OAAc,E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,EAAE;UACpBiJ,uBAAA;MAAA,CAAAA,uBAAA,GAAAd,cAAA,CAAenI,OAAO,cAAtBiJ,uBAAA,uBAAAA,uBAAA,CAAwBC,SAAA,CAAUxJ,QAAA,CAASM,OAAO;IACpD;EACF,GAAG,CAACN,QAAA,EAAUyI,cAAA,CAAe;EAE7B,OAAOhH,KAAA;AACT"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { tokens } from '@fluentui/react-theme';
|
|
2
|
+
import { __styles, mergeClasses, shorthands } from '@griffel/react';
|
|
3
|
+
export const datePickerClassNames = {
|
|
4
|
+
root: 'fui-DatePicker',
|
|
5
|
+
field: 'fui-DatePicker__field',
|
|
6
|
+
wrapper: 'fui-DatePicker__wrapper',
|
|
7
|
+
popover: 'fui-DatePicker__popover',
|
|
8
|
+
popoverSurface: 'fui-DatePicker__popoverSurface',
|
|
9
|
+
input: 'fui-DatePicker__input',
|
|
10
|
+
calendar: 'fui-DatePicker__calendar'
|
|
11
|
+
};
|
|
12
|
+
const useRootStyles = /*#__PURE__*/__styles({
|
|
13
|
+
base: {
|
|
14
|
+
Bahqtrf: "fk6fouc",
|
|
15
|
+
Be2twd7: "f1pp30po",
|
|
16
|
+
Bhrd7zp: "figsok6"
|
|
17
|
+
},
|
|
18
|
+
normalize: {
|
|
19
|
+
E5pizo: "f1couhl3",
|
|
20
|
+
B7ck84d: "f1ewtqcl",
|
|
21
|
+
B6of3ja: "f1hu3pq6",
|
|
22
|
+
t21cq0: ["f11qmguv", "f1tyq0we"],
|
|
23
|
+
jrapky: "f19f4twv",
|
|
24
|
+
Frg6f3: ["f1tyq0we", "f11qmguv"],
|
|
25
|
+
z8tnut: "f1g0x7ka",
|
|
26
|
+
z189sj: ["fhxju0i", "f1cnd47f"],
|
|
27
|
+
Byoj8tv: "f1qch9an",
|
|
28
|
+
uwmqm3: ["f1cnd47f", "fhxju0i"]
|
|
29
|
+
}
|
|
30
|
+
}, {
|
|
31
|
+
d: [".fk6fouc{font-family:var(--fontFamilyBase);}", ".f1pp30po{font-size:var(--fontSizeBase500);}", ".figsok6{font-weight:var(--fontWeightRegular);}", ".f1couhl3{box-shadow:none;}", ".f1ewtqcl{box-sizing:border-box;}", ".f1hu3pq6{margin-top:0;}", ".f11qmguv{margin-right:0;}", ".f1tyq0we{margin-left:0;}", ".f19f4twv{margin-bottom:0;}", ".f1g0x7ka{padding-top:0;}", ".fhxju0i{padding-right:0;}", ".f1cnd47f{padding-left:0;}", ".f1qch9an{padding-bottom:0;}"]
|
|
32
|
+
});
|
|
33
|
+
const useTextFieldStyles = /*#__PURE__*/__styles({
|
|
34
|
+
base: {
|
|
35
|
+
qhf8xq: "f10pi13n",
|
|
36
|
+
f6m02n: "f1lzi3di"
|
|
37
|
+
},
|
|
38
|
+
disabled: {
|
|
39
|
+
f6m02n: "f1a7qz7c"
|
|
40
|
+
}
|
|
41
|
+
}, {
|
|
42
|
+
d: [".f10pi13n{position:relative;}", ".f1lzi3di input[readonly]{cursor:pointer;}", ".f1a7qz7c input[readonly]{cursor:default;}"]
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* Apply styling to the DatePicker slots based on the state
|
|
46
|
+
*/
|
|
47
|
+
export const useDatePickerStyles_unstable = state => {
|
|
48
|
+
const rootStyles = useRootStyles();
|
|
49
|
+
const textFieldStyles = useTextFieldStyles();
|
|
50
|
+
const {
|
|
51
|
+
disabled,
|
|
52
|
+
isDatePickerShown
|
|
53
|
+
} = state;
|
|
54
|
+
state.root.className = mergeClasses(datePickerClassNames.root, rootStyles.base, isDatePickerShown && 'is-open', rootStyles.normalize, state.root.className);
|
|
55
|
+
state.wrapper.className = mergeClasses(datePickerClassNames.wrapper, state.wrapper.className);
|
|
56
|
+
state.input.className = mergeClasses(datePickerClassNames.input, textFieldStyles.base, disabled && textFieldStyles.disabled, state.input.className);
|
|
57
|
+
state.field.className = mergeClasses(datePickerClassNames.field, state.field.className);
|
|
58
|
+
state.popoverSurface.className = mergeClasses(datePickerClassNames.popoverSurface, state.popoverSurface.className);
|
|
59
|
+
state.calendar.className = mergeClasses(datePickerClassNames.calendar, state.calendar.className);
|
|
60
|
+
return state;
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=useDatePickerStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["tokens","__styles","mergeClasses","shorthands","datePickerClassNames","root","field","wrapper","popover","popoverSurface","input","calendar","useRootStyles","base","Bahqtrf","Be2twd7","Bhrd7zp","normalize","E5pizo","B7ck84d","B6of3ja","t21cq0","jrapky","Frg6f3","z8tnut","z189sj","Byoj8tv","uwmqm3","d","useTextFieldStyles","qhf8xq","f6m02n","disabled","useDatePickerStyles_unstable","state","rootStyles","textFieldStyles","isDatePickerShown","className"],"sources":["../../../src/components/DatePicker/useDatePickerStyles.ts"],"sourcesContent":["import { tokens } from '@fluentui/react-theme';\nimport { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport type { DatePickerSlots, DatePickerState } from './DatePicker.types';\n\nexport const datePickerClassNames: SlotClassNames<DatePickerSlots> = {\n root: 'fui-DatePicker',\n field: 'fui-DatePicker__field',\n wrapper: 'fui-DatePicker__wrapper',\n popover: 'fui-DatePicker__popover',\n popoverSurface: 'fui-DatePicker__popoverSurface',\n input: 'fui-DatePicker__input',\n calendar: 'fui-DatePicker__calendar',\n};\n\nconst useRootStyles = makeStyles({\n base: {\n fontFamily: tokens.fontFamilyBase,\n // NOTE: Using 20px as we don't have an 18px font size in the ramp\n fontSize: tokens.fontSizeBase500,\n fontWeight: tokens.fontWeightRegular,\n },\n normalize: {\n boxShadow: 'none',\n boxSizing: 'border-box',\n ...shorthands.margin(0),\n ...shorthands.padding(0),\n },\n});\n\nconst useTextFieldStyles = makeStyles({\n base: {\n position: 'relative',\n '& input[readonly]': {\n cursor: 'pointer',\n },\n },\n disabled: {\n '& input[readonly]': {\n cursor: 'default',\n },\n },\n});\n\n/**\n * Apply styling to the DatePicker slots based on the state\n */\nexport const useDatePickerStyles_unstable = (state: DatePickerState): DatePickerState => {\n const rootStyles = useRootStyles();\n const textFieldStyles = useTextFieldStyles();\n const { disabled, isDatePickerShown } = state;\n\n state.root.className = mergeClasses(\n datePickerClassNames.root,\n rootStyles.base,\n isDatePickerShown && 'is-open',\n rootStyles.normalize,\n state.root.className,\n );\n\n state.wrapper.className = mergeClasses(datePickerClassNames.wrapper, state.wrapper.className);\n\n state.input.className = mergeClasses(\n datePickerClassNames.input,\n textFieldStyles.base,\n disabled && textFieldStyles.disabled,\n state.input.className,\n );\n\n state.field.className = mergeClasses(datePickerClassNames.field, state.field.className);\n\n state.popoverSurface.className = mergeClasses(datePickerClassNames.popoverSurface, state.popoverSurface.className);\n\n state.calendar.className = mergeClasses(datePickerClassNames.calendar, state.calendar.className);\n\n return state;\n};\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ;AACvB,SAAAC,QAAA,EAAqBC,YAAY,EAAEC,UAAU,QAAQ;AAIrD,OAAO,MAAMC,oBAAA,GAAwD;EACnEC,IAAA,EAAM;EACNC,KAAA,EAAO;EACPC,OAAA,EAAS;EACTC,OAAA,EAAS;EACTC,cAAA,EAAgB;EAChBC,KAAA,EAAO;EACPC,QAAA,EAAU;AACZ;AAEA,MAAMC,aAAA,gBAAgBX,QAAA;EAAAY,IAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;EAAA;EAAAC,SAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;AAAA;EAAAC,CAAA;AAAA,EAatB;AAEA,MAAMC,kBAAA,gBAAqB5B,QAAA;EAAAY,IAAA;IAAAiB,MAAA;IAAAC,MAAA;EAAA;EAAAC,QAAA;IAAAD,MAAA;EAAA;AAAA;EAAAH,CAAA;AAAA,EAY3B;AAEA;;;AAGA,OA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+
export { DatePicker, datePickerClassNames, defaultDatePickerStrings, renderDatePicker_unstable, useDatePicker_unstable, useDatePickerStyles_unstable } from './DatePicker';
|
|
3
|
+
export { DAYS_IN_WEEK, DateRangeType, DayOfWeek, FirstWeekOfYear, MonthOfYear, TimeConstants, addDays, addMonths, addWeeks, addYears, compareDatePart, compareDates, getDatePartHashValue, getDateRangeArray, getEndDateOfWeek, getMonthEnd, getMonthStart, getStartDateOfWeek, getWeekNumber, getWeekNumbersInMonth, getYearEnd, getYearStart, isInDateRangeArray, setMonth } from './utils';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AnimationDirection","defaultCalendarStrings","DatePicker","datePickerClassNames","defaultDatePickerStrings","renderDatePicker_unstable","useDatePicker_unstable","useDatePickerStyles_unstable","DAYS_IN_WEEK","DateRangeType","DayOfWeek","FirstWeekOfYear","MonthOfYear","TimeConstants","addDays","addMonths","addWeeks","addYears","compareDatePart","compareDates","getDatePartHashValue","getDateRangeArray","getEndDateOfWeek","getMonthEnd","getMonthStart","getStartDateOfWeek","getWeekNumber","getWeekNumbersInMonth","getYearEnd","getYearStart","isInDateRangeArray","setMonth"],"sources":["../src/index.ts"],"sourcesContent":["export { AnimationDirection, defaultCalendarStrings } from './Calendar';\nexport type { CalendarProps, ICalendar } from './Calendar';\n\nexport type { CalendarDayProps, ICalendarDay } from './CalendarDay';\n\nexport type { CalendarMonthProps, ICalendarMonth } from './CalendarMonth';\n\nexport {\n DatePicker,\n datePickerClassNames,\n defaultDatePickerStrings,\n renderDatePicker_unstable,\n useDatePicker_unstable,\n useDatePickerStyles_unstable,\n} from './DatePicker';\nexport type { DatePickerProps, DatePickerStrings, IDatePicker } from './DatePicker';\n\nexport {\n DAYS_IN_WEEK,\n DateRangeType,\n DayOfWeek,\n FirstWeekOfYear,\n MonthOfYear,\n TimeConstants,\n addDays,\n addMonths,\n addWeeks,\n addYears,\n compareDatePart,\n compareDates,\n getDatePartHashValue,\n getDateRangeArray,\n getEndDateOfWeek,\n getMonthEnd,\n getMonthStart,\n getStartDateOfWeek,\n getWeekNumber,\n getWeekNumbersInMonth,\n getYearEnd,\n getYearStart,\n isInDateRangeArray,\n setMonth,\n} from './utils';\nexport type { CalendarStrings, DateFormatting, DateGridStrings } from './utils';\n"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,sBAAsB,QAAQ;AAO3D,SACEC,UAAU,EACVC,oBAAoB,EACpBC,wBAAwB,EACxBC,yBAAyB,EACzBC,sBAAsB,EACtBC,4BAA4B,QACvB;AAGP,SACEC,YAAY,EACZC,aAAa,EACbC,SAAS,EACTC,eAAe,EACfC,WAAW,EACXC,aAAa,EACbC,OAAO,EACPC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,eAAe,EACfC,YAAY,EACZC,oBAAoB,EACpBC,iBAAiB,EACjBC,gBAAgB,EAChBC,WAAW,EACXC,aAAa,EACbC,kBAAkB,EAClBC,aAAa,EACbC,qBAAqB,EACrBC,UAAU,EACVC,YAAY,EACZC,kBAAkB,EAClBC,QAAQ,QACH"}
|