@fluentui/react-datepicker-compat 0.0.0-nightly-20230512-0423.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +65 -31
- package/CHANGELOG.md +24 -18
- package/dist/index.d.ts +1165 -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.styles.js +149 -0
- package/lib/components/Calendar/useCalendarStyles.styles.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.styles.js +180 -0
- package/lib/components/CalendarDay/useCalendarDayStyles.styles.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.styles.js +443 -0
- package/lib/components/CalendarDayGrid/useCalendarDayGridStyles.styles.js.map +1 -0
- package/lib/components/CalendarDayGrid/useWeekCornerStyles.styles.js +98 -0
- package/lib/components/CalendarDayGrid/useWeekCornerStyles.styles.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.styles.js +371 -0
- package/lib/components/CalendarPicker/useCalendarPickerStyles.styles.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.styles.js +10 -0
- package/lib/components/CalendarYear/useCalendarYearStyles.styles.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 +15 -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 +18 -0
- package/lib/components/DatePicker/renderDatePicker.js.map +1 -0
- package/lib/components/DatePicker/useDatePicker.js +395 -0
- package/lib/components/DatePicker/useDatePicker.js.map +1 -0
- package/lib/components/DatePicker/useDatePickerStyles.styles.js +38 -0
- package/lib/components/DatePicker/useDatePickerStyles.styles.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/utils/usePopupPositioning.js +25 -0
- package/lib/utils/usePopupPositioning.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.styles.js +286 -0
- package/lib-commonjs/components/Calendar/useCalendarStyles.styles.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.styles.js +356 -0
- package/lib-commonjs/components/CalendarDay/useCalendarDayStyles.styles.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.styles.js +916 -0
- package/lib-commonjs/components/CalendarDayGrid/useCalendarDayGridStyles.styles.js.map +1 -0
- package/lib-commonjs/components/CalendarDayGrid/useWeekCornerStyles.styles.js +103 -0
- package/lib-commonjs/components/CalendarDayGrid/useWeekCornerStyles.styles.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.styles.js +746 -0
- package/lib-commonjs/components/CalendarPicker/useCalendarPickerStyles.styles.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.styles.js +14 -0
- package/lib-commonjs/components/CalendarYear/useCalendarYearStyles.styles.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 +30 -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 +20 -0
- package/lib-commonjs/components/DatePicker/renderDatePicker.js.map +1 -0
- package/lib-commonjs/components/DatePicker/useDatePicker.js +440 -0
- package/lib-commonjs/components/DatePicker/useDatePicker.js.map +1 -0
- package/lib-commonjs/components/DatePicker/useDatePickerStyles.styles.js +55 -0
- package/lib-commonjs/components/DatePicker/useDatePickerStyles.styles.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/lib-commonjs/utils/usePopupPositioning.js +26 -0
- package/lib-commonjs/utils/usePopupPositioning.js.map +1 -0
- package/package.json +19 -14
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ArrowDown, Enter, Escape } from '@fluentui/keyboard-keys';
|
|
3
|
+
import { Calendar } from '../Calendar/Calendar';
|
|
4
|
+
import { CalendarMonthRegular } from '@fluentui/react-icons';
|
|
5
|
+
import { compareDatePart, DayOfWeek, FirstWeekOfYear } from '../../utils';
|
|
6
|
+
import { defaultDatePickerStrings } from './defaults';
|
|
7
|
+
import { Input } from '@fluentui/react-input';
|
|
8
|
+
import { mergeCallbacks, resolveShorthand, useControllableState, useEventCallback, useId, useMergedRefs, useOnClickOutside, useOnScrollOutside } from '@fluentui/react-utilities';
|
|
9
|
+
import { useFieldContext_unstable as useFieldContext } from '@fluentui/react-field';
|
|
10
|
+
import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
|
|
11
|
+
import { useFocusFinders, useModalAttributes } from '@fluentui/react-tabster';
|
|
12
|
+
import { usePopupPositioning } from '../../utils/usePopupPositioning';
|
|
13
|
+
function isDateOutOfBounds(date, minDate, maxDate) {
|
|
14
|
+
return !!minDate && compareDatePart(minDate, date) > 0 || !!maxDate && compareDatePart(maxDate, date) < 0;
|
|
15
|
+
}
|
|
16
|
+
function useFocusLogic() {
|
|
17
|
+
const inputRef = React.useRef(null);
|
|
18
|
+
const preventFocusOpeningPicker = React.useRef(false);
|
|
19
|
+
const focus = () => {
|
|
20
|
+
var _inputRef_current, _inputRef_current_focus;
|
|
21
|
+
(_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);
|
|
22
|
+
};
|
|
23
|
+
const preventNextFocusOpeningPicker = () => {
|
|
24
|
+
preventFocusOpeningPicker.current = true;
|
|
25
|
+
};
|
|
26
|
+
return [focus, inputRef, preventFocusOpeningPicker, preventNextFocusOpeningPicker];
|
|
27
|
+
}
|
|
28
|
+
function usePopupVisibility(props) {
|
|
29
|
+
const [open, setOpen] = useControllableState({
|
|
30
|
+
initialState: false,
|
|
31
|
+
defaultState: props.defaultOpen,
|
|
32
|
+
state: props.open
|
|
33
|
+
});
|
|
34
|
+
const isMounted = React.useRef(false);
|
|
35
|
+
React.useEffect(() => {
|
|
36
|
+
if (isMounted.current && !open) {
|
|
37
|
+
var
|
|
38
|
+
// If DatePicker's menu (Calendar) is closed, run onAfterMenuDismiss
|
|
39
|
+
_props_onOpenChange;
|
|
40
|
+
(_props_onOpenChange = props.onOpenChange) === null || _props_onOpenChange === void 0 ? void 0 : _props_onOpenChange.call(props, false);
|
|
41
|
+
}
|
|
42
|
+
isMounted.current = true;
|
|
43
|
+
},
|
|
44
|
+
// Should only run on allowTextInput or open change
|
|
45
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
|
+
[props.allowTextInput, open]);
|
|
47
|
+
return [open, setOpen];
|
|
48
|
+
}
|
|
49
|
+
function useSelectedDate({
|
|
50
|
+
formatDate,
|
|
51
|
+
onSelectDate,
|
|
52
|
+
value
|
|
53
|
+
}) {
|
|
54
|
+
const [selectedDate, setSelectedDateState] = useControllableState({
|
|
55
|
+
initialState: undefined,
|
|
56
|
+
state: value
|
|
57
|
+
});
|
|
58
|
+
const [formattedDate, setFormattedDate] = React.useState(() => value && formatDate ? formatDate(value) : '');
|
|
59
|
+
const setSelectedDate = newDate => {
|
|
60
|
+
if (selectedDate === undefined && newDate !== undefined || selectedDate !== undefined && newDate === undefined || newDate && selectedDate && (newDate > selectedDate || newDate < selectedDate)) {
|
|
61
|
+
onSelectDate === null || onSelectDate === void 0 ? void 0 : onSelectDate(newDate);
|
|
62
|
+
}
|
|
63
|
+
setSelectedDateState(newDate);
|
|
64
|
+
setFormattedDate(newDate && formatDate ? formatDate(newDate) : '');
|
|
65
|
+
};
|
|
66
|
+
React.useEffect(() => {
|
|
67
|
+
setFormattedDate(value && formatDate ? formatDate(value) : '');
|
|
68
|
+
}, [formatDate, value]);
|
|
69
|
+
return [selectedDate, formattedDate, setSelectedDate, setFormattedDate];
|
|
70
|
+
}
|
|
71
|
+
const defaultFormatDate = date => date ? date.toDateString() : '';
|
|
72
|
+
const defaultParseDateFromString = dateStr => {
|
|
73
|
+
const date = Date.parse(dateStr);
|
|
74
|
+
return date ? new Date(date) : null;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Create the state required to render DatePicker.
|
|
78
|
+
*
|
|
79
|
+
* The returned state can be modified with hooks such as useDatePickerStyles_unstable,
|
|
80
|
+
* before being passed to renderDatePicker_unstable.
|
|
81
|
+
*
|
|
82
|
+
* @param props - props from this instance of DatePicker
|
|
83
|
+
* @param ref - reference to root Input slot
|
|
84
|
+
*/
|
|
85
|
+
export const useDatePicker_unstable = (props, ref) => {
|
|
86
|
+
const {
|
|
87
|
+
allowTextInput = false,
|
|
88
|
+
allFocusable = false,
|
|
89
|
+
borderless = false,
|
|
90
|
+
dateTimeFormatter,
|
|
91
|
+
defaultOpen = false,
|
|
92
|
+
disableAutoFocus = true,
|
|
93
|
+
firstDayOfWeek = DayOfWeek.Sunday,
|
|
94
|
+
firstWeekOfYear = FirstWeekOfYear.FirstDay,
|
|
95
|
+
formatDate = defaultFormatDate,
|
|
96
|
+
highlightCurrentMonth = false,
|
|
97
|
+
highlightSelectedMonth = false,
|
|
98
|
+
initialPickerDate = new Date(),
|
|
99
|
+
inlinePopup = false,
|
|
100
|
+
isMonthPickerVisible = true,
|
|
101
|
+
maxDate,
|
|
102
|
+
minDate,
|
|
103
|
+
onOpenChange,
|
|
104
|
+
onSelectDate: onUserSelectDate,
|
|
105
|
+
openOnClick = true,
|
|
106
|
+
onValidationResult,
|
|
107
|
+
parseDateFromString = defaultParseDateFromString,
|
|
108
|
+
showCloseButton = false,
|
|
109
|
+
showGoToToday = true,
|
|
110
|
+
showMonthPickerAsOverlay = false,
|
|
111
|
+
showWeekNumbers = false,
|
|
112
|
+
strings = defaultDatePickerStrings,
|
|
113
|
+
today,
|
|
114
|
+
underlined = false,
|
|
115
|
+
value,
|
|
116
|
+
...restOfProps
|
|
117
|
+
} = props;
|
|
118
|
+
const calendar = React.useRef(null);
|
|
119
|
+
const [focus, rootRef, preventFocusOpeningPicker, preventNextFocusOpeningPicker] = useFocusLogic();
|
|
120
|
+
const [selectedDate, formattedDate, setSelectedDate, setFormattedDate] = useSelectedDate({
|
|
121
|
+
formatDate,
|
|
122
|
+
onSelectDate: onUserSelectDate,
|
|
123
|
+
value
|
|
124
|
+
});
|
|
125
|
+
const [open, setOpenState] = usePopupVisibility(props);
|
|
126
|
+
const fieldContext = useFieldContext();
|
|
127
|
+
var _fieldContext_required;
|
|
128
|
+
const required = (_fieldContext_required = fieldContext === null || fieldContext === void 0 ? void 0 : fieldContext.required) !== null && _fieldContext_required !== void 0 ? _fieldContext_required : props.required;
|
|
129
|
+
const popupSurfaceId = useId('datePicker-popoverSurface');
|
|
130
|
+
const validateTextInput = React.useCallback((date = null) => {
|
|
131
|
+
let error;
|
|
132
|
+
if (allowTextInput) {
|
|
133
|
+
if (formattedDate || date) {
|
|
134
|
+
// Don't parse if the selected date has the same formatted string as what we're about to parse.
|
|
135
|
+
// The formatted string might be ambiguous (ex: "1/2/3" or "New Year Eve") and the parser might
|
|
136
|
+
// not be able to come up with the exact same date.
|
|
137
|
+
if (selectedDate && formatDate && formatDate(date !== null && date !== void 0 ? date : selectedDate) === formattedDate) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
date = date || parseDateFromString(formattedDate);
|
|
141
|
+
// Check if date is null or date is an invalid date
|
|
142
|
+
if (!date || isNaN(date.getTime())) {
|
|
143
|
+
// Reset input if formatting is available
|
|
144
|
+
setSelectedDate(selectedDate);
|
|
145
|
+
error = 'invalid-input';
|
|
146
|
+
} else {
|
|
147
|
+
if (isDateOutOfBounds(date, minDate, maxDate)) {
|
|
148
|
+
error = 'out-of-bounds';
|
|
149
|
+
} else {
|
|
150
|
+
setSelectedDate(date);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
} else {
|
|
154
|
+
if (required) {
|
|
155
|
+
error = 'required-input';
|
|
156
|
+
}
|
|
157
|
+
onUserSelectDate === null || onUserSelectDate === void 0 ? void 0 : onUserSelectDate(date);
|
|
158
|
+
}
|
|
159
|
+
} else if (required && !formattedDate) {
|
|
160
|
+
error = 'required-input';
|
|
161
|
+
}
|
|
162
|
+
onValidationResult === null || onValidationResult === void 0 ? void 0 : onValidationResult({
|
|
163
|
+
error
|
|
164
|
+
});
|
|
165
|
+
}, [allowTextInput, formatDate, formattedDate, maxDate, minDate, onUserSelectDate, onValidationResult, parseDateFromString, required, selectedDate, setSelectedDate]);
|
|
166
|
+
const setOpen = React.useCallback(newState => {
|
|
167
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(newState);
|
|
168
|
+
setOpenState(newState);
|
|
169
|
+
}, [onOpenChange, setOpenState]);
|
|
170
|
+
const dismissDatePickerPopup = React.useCallback(newlySelectedDate => {
|
|
171
|
+
if (open) {
|
|
172
|
+
setOpen(false);
|
|
173
|
+
validateTextInput(newlySelectedDate);
|
|
174
|
+
if (!allowTextInput && newlySelectedDate) {
|
|
175
|
+
setSelectedDate(newlySelectedDate);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}, [allowTextInput, open, setOpen, setSelectedDate, validateTextInput]);
|
|
179
|
+
const showDatePickerPopup = React.useCallback(() => {
|
|
180
|
+
if (!open) {
|
|
181
|
+
preventNextFocusOpeningPicker();
|
|
182
|
+
setOpen(true);
|
|
183
|
+
}
|
|
184
|
+
}, [open, preventNextFocusOpeningPicker, setOpen]);
|
|
185
|
+
/**
|
|
186
|
+
* Callback for closing the calendar callout
|
|
187
|
+
*/
|
|
188
|
+
const calendarDismissed = React.useCallback(newlySelectedDate => {
|
|
189
|
+
preventNextFocusOpeningPicker();
|
|
190
|
+
dismissDatePickerPopup(newlySelectedDate);
|
|
191
|
+
}, [dismissDatePickerPopup, preventNextFocusOpeningPicker]);
|
|
192
|
+
const onInputChange = React.useCallback((ev, data) => {
|
|
193
|
+
const {
|
|
194
|
+
value: newValue
|
|
195
|
+
} = data;
|
|
196
|
+
if (allowTextInput) {
|
|
197
|
+
if (open) {
|
|
198
|
+
dismissDatePickerPopup();
|
|
199
|
+
}
|
|
200
|
+
setFormattedDate(newValue);
|
|
201
|
+
}
|
|
202
|
+
}, [allowTextInput, dismissDatePickerPopup, open, setFormattedDate]);
|
|
203
|
+
const onInputBlur = React.useCallback(() => {
|
|
204
|
+
validateTextInput();
|
|
205
|
+
}, [validateTextInput]);
|
|
206
|
+
const onInputKeyDown = React.useCallback(ev => {
|
|
207
|
+
switch (ev.key) {
|
|
208
|
+
case Enter:
|
|
209
|
+
ev.preventDefault();
|
|
210
|
+
ev.stopPropagation();
|
|
211
|
+
if (!open) {
|
|
212
|
+
validateTextInput();
|
|
213
|
+
showDatePickerPopup();
|
|
214
|
+
} else {
|
|
215
|
+
// When DatePicker allows input date string directly,
|
|
216
|
+
// it is expected to hit another enter to close the popup
|
|
217
|
+
if (props.allowTextInput) {
|
|
218
|
+
dismissDatePickerPopup();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
break;
|
|
222
|
+
case Escape:
|
|
223
|
+
ev.stopPropagation();
|
|
224
|
+
ev.preventDefault();
|
|
225
|
+
if (open) {
|
|
226
|
+
calendarDismissed();
|
|
227
|
+
}
|
|
228
|
+
break;
|
|
229
|
+
case ArrowDown:
|
|
230
|
+
ev.preventDefault();
|
|
231
|
+
if (ev.altKey && !open) {
|
|
232
|
+
showDatePickerPopup();
|
|
233
|
+
}
|
|
234
|
+
break;
|
|
235
|
+
default:
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
}, [calendarDismissed, dismissDatePickerPopup, open, props.allowTextInput, showDatePickerPopup, validateTextInput]);
|
|
239
|
+
const onInputFocus = React.useCallback(() => {
|
|
240
|
+
if (disableAutoFocus) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (!allowTextInput) {
|
|
244
|
+
if (!preventFocusOpeningPicker.current) {
|
|
245
|
+
showDatePickerPopup();
|
|
246
|
+
}
|
|
247
|
+
preventFocusOpeningPicker.current = false;
|
|
248
|
+
}
|
|
249
|
+
}, [allowTextInput, disableAutoFocus, preventFocusOpeningPicker, showDatePickerPopup]);
|
|
250
|
+
const onInputClick = React.useCallback(() => {
|
|
251
|
+
// default openOnClick to !props.disableAutoFocus for legacy support of disableAutoFocus behavior
|
|
252
|
+
if ((openOnClick || !disableAutoFocus) && !open && !props.disabled) {
|
|
253
|
+
showDatePickerPopup();
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
if (allowTextInput) {
|
|
257
|
+
dismissDatePickerPopup();
|
|
258
|
+
}
|
|
259
|
+
}, [allowTextInput, disableAutoFocus, dismissDatePickerPopup, openOnClick, open, props.disabled, showDatePickerPopup]);
|
|
260
|
+
const onIconClick = ev => {
|
|
261
|
+
ev.stopPropagation();
|
|
262
|
+
if (!open && !props.disabled) {
|
|
263
|
+
showDatePickerPopup();
|
|
264
|
+
} else if (props.allowTextInput) {
|
|
265
|
+
dismissDatePickerPopup();
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
const inputAppearance = underlined ? 'underline' : borderless ? 'filled-lighter' : 'outline';
|
|
269
|
+
const [triggerWrapperRef, popupRef] = usePopupPositioning(props);
|
|
270
|
+
const rootShorthand = resolveShorthand(restOfProps, {
|
|
271
|
+
required: true,
|
|
272
|
+
defaultProps: {
|
|
273
|
+
appearance: inputAppearance,
|
|
274
|
+
'aria-controls': open ? popupSurfaceId : undefined,
|
|
275
|
+
'aria-expanded': open,
|
|
276
|
+
'aria-haspopup': 'dialog',
|
|
277
|
+
contentAfter: /*#__PURE__*/React.createElement(CalendarMonthRegular, {
|
|
278
|
+
onClick: onIconClick
|
|
279
|
+
}),
|
|
280
|
+
readOnly: !allowTextInput,
|
|
281
|
+
role: 'combobox',
|
|
282
|
+
root: {
|
|
283
|
+
ref: useMergedRefs(triggerWrapperRef, ref),
|
|
284
|
+
'aria-owns': popupSurfaceId
|
|
285
|
+
},
|
|
286
|
+
input: {
|
|
287
|
+
ref: rootRef
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
rootShorthand.onChange = mergeCallbacks(rootShorthand.onChange, onInputChange);
|
|
292
|
+
rootShorthand.onBlur = mergeCallbacks(rootShorthand.onBlur, onInputBlur);
|
|
293
|
+
rootShorthand.onKeyDown = mergeCallbacks(rootShorthand.onKeyDown, onInputKeyDown);
|
|
294
|
+
rootShorthand.onFocus = mergeCallbacks(rootShorthand.onFocus, onInputFocus);
|
|
295
|
+
rootShorthand.onClick = mergeCallbacks(rootShorthand.onClick, onInputClick);
|
|
296
|
+
const {
|
|
297
|
+
modalAttributes
|
|
298
|
+
} = useModalAttributes({
|
|
299
|
+
trapFocus: true,
|
|
300
|
+
alwaysFocusable: true,
|
|
301
|
+
legacyTrapFocus: false
|
|
302
|
+
});
|
|
303
|
+
const popupSurfaceShorthand = open ? resolveShorthand(props.popupSurface, {
|
|
304
|
+
required: true,
|
|
305
|
+
defaultProps: {
|
|
306
|
+
'aria-label': 'Calendar',
|
|
307
|
+
'aria-modal': true,
|
|
308
|
+
id: popupSurfaceId,
|
|
309
|
+
role: 'dialog',
|
|
310
|
+
ref: popupRef,
|
|
311
|
+
...modalAttributes
|
|
312
|
+
}
|
|
313
|
+
}) : undefined;
|
|
314
|
+
const {
|
|
315
|
+
targetDocument
|
|
316
|
+
} = useFluent();
|
|
317
|
+
useOnClickOutside({
|
|
318
|
+
element: targetDocument,
|
|
319
|
+
callback: ev => dismissDatePickerPopup(),
|
|
320
|
+
refs: [triggerWrapperRef, popupRef],
|
|
321
|
+
disabled: !open
|
|
322
|
+
});
|
|
323
|
+
useOnScrollOutside({
|
|
324
|
+
element: targetDocument,
|
|
325
|
+
callback: ev => dismissDatePickerPopup(),
|
|
326
|
+
refs: [triggerWrapperRef, popupRef],
|
|
327
|
+
disabled: !open
|
|
328
|
+
});
|
|
329
|
+
const {
|
|
330
|
+
findFirstFocusable
|
|
331
|
+
} = useFocusFinders();
|
|
332
|
+
React.useEffect(() => {
|
|
333
|
+
if (disableAutoFocus) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
if (open && popupRef.current) {
|
|
337
|
+
const firstFocusable = findFirstFocusable(popupRef.current);
|
|
338
|
+
firstFocusable === null || firstFocusable === void 0 ? void 0 : firstFocusable.focus();
|
|
339
|
+
}
|
|
340
|
+
}, [disableAutoFocus, findFirstFocusable, open, popupRef]);
|
|
341
|
+
const popupOnClick = useEventCallback(mergeCallbacks(ev => {
|
|
342
|
+
var _rootRef_current;
|
|
343
|
+
(_rootRef_current = rootRef.current) === null || _rootRef_current === void 0 ? void 0 : _rootRef_current.focus();
|
|
344
|
+
}, popupSurfaceShorthand === null || popupSurfaceShorthand === void 0 ? void 0 : popupSurfaceShorthand.onClick));
|
|
345
|
+
if (popupSurfaceShorthand) {
|
|
346
|
+
popupSurfaceShorthand.onClick = popupOnClick;
|
|
347
|
+
}
|
|
348
|
+
const calendarShorthand = resolveShorthand(props.calendar, {
|
|
349
|
+
required: true,
|
|
350
|
+
defaultProps: {
|
|
351
|
+
allFocusable,
|
|
352
|
+
componentRef: calendar,
|
|
353
|
+
dateTimeFormatter,
|
|
354
|
+
firstDayOfWeek,
|
|
355
|
+
firstWeekOfYear,
|
|
356
|
+
highlightCurrentMonth,
|
|
357
|
+
highlightSelectedMonth,
|
|
358
|
+
isMonthPickerVisible,
|
|
359
|
+
maxDate,
|
|
360
|
+
minDate,
|
|
361
|
+
onDismiss: calendarDismissed,
|
|
362
|
+
showCloseButton,
|
|
363
|
+
showGoToToday,
|
|
364
|
+
showMonthPickerAsOverlay,
|
|
365
|
+
showWeekNumbers,
|
|
366
|
+
strings,
|
|
367
|
+
today,
|
|
368
|
+
value: selectedDate || initialPickerDate
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
React.useImperativeHandle(props.componentRef, () => ({
|
|
372
|
+
focus,
|
|
373
|
+
reset() {
|
|
374
|
+
setOpen(false);
|
|
375
|
+
setSelectedDate(undefined);
|
|
376
|
+
},
|
|
377
|
+
showDatePickerPopup
|
|
378
|
+
}), [focus, setOpen, setSelectedDate, showDatePickerPopup]);
|
|
379
|
+
const state = {
|
|
380
|
+
disabled: !!props.disabled,
|
|
381
|
+
inlinePopup,
|
|
382
|
+
components: {
|
|
383
|
+
root: Input,
|
|
384
|
+
calendar: Calendar,
|
|
385
|
+
popupSurface: 'div'
|
|
386
|
+
},
|
|
387
|
+
calendar: calendarShorthand,
|
|
388
|
+
root: rootShorthand,
|
|
389
|
+
popupSurface: popupSurfaceShorthand
|
|
390
|
+
};
|
|
391
|
+
state.root.value = formattedDate;
|
|
392
|
+
state.calendar.onSelectDate = mergeCallbacks(state.calendar.onSelectDate, calendarDismissed);
|
|
393
|
+
return state;
|
|
394
|
+
};
|
|
395
|
+
//# sourceMappingURL=useDatePicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","ArrowDown","Enter","Escape","Calendar","CalendarMonthRegular","compareDatePart","DayOfWeek","FirstWeekOfYear","defaultDatePickerStrings","Input","mergeCallbacks","resolveShorthand","useControllableState","useEventCallback","useId","useMergedRefs","useOnClickOutside","useOnScrollOutside","useFieldContext_unstable","useFieldContext","useFluent_unstable","useFluent","useFocusFinders","useModalAttributes","usePopupPositioning","isDateOutOfBounds","date","minDate","maxDate","useFocusLogic","inputRef","useRef","preventFocusOpeningPicker","focus","_inputRef_current","_inputRef_current_focus","current","call","preventNextFocusOpeningPicker","usePopupVisibility","props","open","setOpen","initialState","defaultState","defaultOpen","state","isMounted","useEffect","_props_onOpenChange","onOpenChange","allowTextInput","useSelectedDate","formatDate","onSelectDate","value","selectedDate","setSelectedDateState","undefined","formattedDate","setFormattedDate","useState","setSelectedDate","newDate","defaultFormatDate","toDateString","defaultParseDateFromString","dateStr","Date","parse","useDatePicker_unstable","ref","allFocusable","borderless","dateTimeFormatter","disableAutoFocus","firstDayOfWeek","Sunday","firstWeekOfYear","FirstDay","highlightCurrentMonth","highlightSelectedMonth","initialPickerDate","inlinePopup","isMonthPickerVisible","onUserSelectDate","openOnClick","onValidationResult","parseDateFromString","showCloseButton","showGoToToday","showMonthPickerAsOverlay","showWeekNumbers","strings","today","underlined","restOfProps","calendar","rootRef","setOpenState","fieldContext","_fieldContext_required","required","popupSurfaceId","validateTextInput","useCallback","error","isNaN","getTime","newState","dismissDatePickerPopup","newlySelectedDate","showDatePickerPopup","calendarDismissed","onInputChange","ev","data","newValue","onInputBlur","onInputKeyDown","key","preventDefault","stopPropagation","altKey","onInputFocus","onInputClick","disabled","onIconClick","inputAppearance","triggerWrapperRef","popupRef","rootShorthand","defaultProps","appearance","contentAfter","createElement","onClick","readOnly","role","root","input","onChange","onBlur","onKeyDown","onFocus","modalAttributes","trapFocus","alwaysFocusable","legacyTrapFocus","popupSurfaceShorthand","popupSurface","id","targetDocument","element","callback","refs","findFirstFocusable","firstFocusable","popupOnClick","_rootRef_current","calendarShorthand","componentRef","onDismiss","useImperativeHandle","reset","components"],"sources":["../../../src/components/DatePicker/useDatePicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ArrowDown, Enter, Escape } from '@fluentui/keyboard-keys';\nimport { Calendar } from '../Calendar/Calendar';\nimport { CalendarMonthRegular } from '@fluentui/react-icons';\nimport { compareDatePart, DayOfWeek, FirstWeekOfYear } from '../../utils';\nimport { defaultDatePickerStrings } from './defaults';\nimport { Input } from '@fluentui/react-input';\nimport {\n mergeCallbacks,\n resolveShorthand,\n useControllableState,\n useEventCallback,\n useId,\n useMergedRefs,\n useOnClickOutside,\n useOnScrollOutside,\n} from '@fluentui/react-utilities';\nimport { useFieldContext_unstable as useFieldContext } from '@fluentui/react-field';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useFocusFinders, useModalAttributes } from '@fluentui/react-tabster';\nimport { usePopupPositioning } from '../../utils/usePopupPositioning';\nimport type { CalendarProps, ICalendar } from '../Calendar/Calendar.types';\nimport type { DatePickerProps, DatePickerState, DatePickerValidationResultData } from './DatePicker.types';\nimport type { InputProps, InputOnChangeData } from '@fluentui/react-input';\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<HTMLInputElement>(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 usePopupVisibility(props: DatePickerProps) {\n const [open, setOpen] = useControllableState({\n initialState: false,\n defaultState: props.defaultOpen,\n state: props.open,\n });\n const isMounted = React.useRef(false);\n\n React.useEffect(\n () => {\n if (isMounted.current && !open) {\n // If DatePicker's menu (Calendar) is closed, run onAfterMenuDismiss\n props.onOpenChange?.(false);\n }\n isMounted.current = true;\n },\n // Should only run on allowTextInput or open change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [props.allowTextInput, open],\n );\n\n return [open, setOpen] 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\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 Input slot\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 defaultOpen = false,\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 inlinePopup = false,\n isMonthPickerVisible = true,\n maxDate,\n minDate,\n onOpenChange,\n onSelectDate: onUserSelectDate,\n openOnClick = true,\n onValidationResult,\n parseDateFromString = defaultParseDateFromString,\n showCloseButton = false,\n showGoToToday = true,\n showMonthPickerAsOverlay = false,\n showWeekNumbers = false,\n strings = defaultDatePickerStrings,\n today,\n underlined = false,\n value,\n ...restOfProps\n } = props;\n const calendar = React.useRef<ICalendar>(null);\n const [focus, rootRef, preventFocusOpeningPicker, preventNextFocusOpeningPicker] = useFocusLogic();\n const [selectedDate, formattedDate, setSelectedDate, setFormattedDate] = useSelectedDate({\n formatDate,\n onSelectDate: onUserSelectDate,\n value,\n });\n const [open, setOpenState] = usePopupVisibility(props);\n const fieldContext = useFieldContext();\n const required = fieldContext?.required ?? props.required;\n const popupSurfaceId = useId('datePicker-popoverSurface');\n\n const validateTextInput = React.useCallback(\n (date: Date | null = null): void => {\n let error: DatePickerValidationResultData['error'] | undefined;\n\n if (allowTextInput) {\n if (formattedDate || 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 && formatDate && formatDate(date ?? selectedDate) === formattedDate) {\n return;\n }\n date = date || parseDateFromString!(formattedDate);\n\n // Check if date is null or date is an invalid date\n if (!date || isNaN(date.getTime())) {\n // Reset input if formatting is available\n setSelectedDate(selectedDate);\n error = 'invalid-input';\n } else {\n if (isDateOutOfBounds(date, minDate, maxDate)) {\n error = 'out-of-bounds';\n } else {\n setSelectedDate(date);\n }\n }\n } else {\n if (required) {\n error = 'required-input';\n }\n\n onUserSelectDate?.(date);\n }\n } else if (required && !formattedDate) {\n error = 'required-input';\n }\n\n onValidationResult?.({ error });\n },\n [\n allowTextInput,\n formatDate,\n formattedDate,\n maxDate,\n minDate,\n onUserSelectDate,\n onValidationResult,\n parseDateFromString,\n required,\n selectedDate,\n setSelectedDate,\n ],\n );\n\n const setOpen = React.useCallback(\n (newState: boolean) => {\n onOpenChange?.(newState);\n setOpenState(newState);\n },\n [onOpenChange, setOpenState],\n );\n\n const dismissDatePickerPopup = React.useCallback(\n (newlySelectedDate?: Date): void => {\n if (open) {\n setOpen(false);\n\n validateTextInput(newlySelectedDate);\n if (!allowTextInput && newlySelectedDate) {\n setSelectedDate(newlySelectedDate);\n }\n }\n },\n [allowTextInput, open, setOpen, setSelectedDate, validateTextInput],\n );\n\n const showDatePickerPopup = React.useCallback((): void => {\n if (!open) {\n preventNextFocusOpeningPicker();\n setOpen(true);\n }\n }, [open, preventNextFocusOpeningPicker, setOpen]);\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 },\n [dismissDatePickerPopup, preventNextFocusOpeningPicker],\n );\n\n const onInputChange = React.useCallback(\n (ev: React.ChangeEvent<HTMLInputElement>, data: InputOnChangeData) => {\n const { value: newValue } = data;\n\n if (allowTextInput) {\n if (open) {\n dismissDatePickerPopup();\n }\n\n setFormattedDate(newValue);\n }\n },\n [allowTextInput, dismissDatePickerPopup, open, setFormattedDate],\n );\n\n const onInputBlur: React.FocusEventHandler<HTMLInputElement> = React.useCallback((): void => {\n validateTextInput();\n }, [validateTextInput]);\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 (!open) {\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 ev.stopPropagation();\n ev.preventDefault();\n if (open) {\n calendarDismissed();\n }\n break;\n\n case ArrowDown:\n ev.preventDefault();\n if (ev.altKey && !open) {\n showDatePickerPopup();\n }\n break;\n\n default:\n break;\n }\n },\n [calendarDismissed, dismissDatePickerPopup, open, props.allowTextInput, showDatePickerPopup, validateTextInput],\n );\n\n const onInputFocus: React.FocusEventHandler<HTMLInputElement> = 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 onInputClick: React.MouseEventHandler<HTMLInputElement> = React.useCallback((): void => {\n // default openOnClick to !props.disableAutoFocus for legacy support of disableAutoFocus behavior\n if ((openOnClick || !disableAutoFocus) && !open && !props.disabled) {\n showDatePickerPopup();\n return;\n }\n\n if (allowTextInput) {\n dismissDatePickerPopup();\n }\n }, [\n allowTextInput,\n disableAutoFocus,\n dismissDatePickerPopup,\n openOnClick,\n open,\n props.disabled,\n showDatePickerPopup,\n ]);\n\n const onIconClick = (ev: React.MouseEvent<HTMLElement>): void => {\n ev.stopPropagation();\n if (!open && !props.disabled) {\n showDatePickerPopup();\n } else if (props.allowTextInput) {\n dismissDatePickerPopup();\n }\n };\n\n const inputAppearance: InputProps['appearance'] = underlined\n ? 'underline'\n : borderless\n ? 'filled-lighter'\n : 'outline';\n\n const [triggerWrapperRef, popupRef] = usePopupPositioning(props);\n const rootShorthand = resolveShorthand(restOfProps, {\n required: true,\n defaultProps: {\n appearance: inputAppearance,\n 'aria-controls': open ? popupSurfaceId : undefined,\n 'aria-expanded': open,\n 'aria-haspopup': 'dialog',\n contentAfter: <CalendarMonthRegular onClick={onIconClick as unknown as React.MouseEventHandler<SVGElement>} />,\n readOnly: !allowTextInput,\n role: 'combobox',\n root: {\n ref: useMergedRefs(triggerWrapperRef, ref),\n 'aria-owns': popupSurfaceId,\n },\n input: {\n ref: rootRef,\n },\n },\n });\n rootShorthand.onChange = mergeCallbacks(rootShorthand.onChange, onInputChange);\n rootShorthand.onBlur = mergeCallbacks(rootShorthand.onBlur, onInputBlur);\n rootShorthand.onKeyDown = mergeCallbacks(rootShorthand.onKeyDown, onInputKeyDown);\n rootShorthand.onFocus = mergeCallbacks(rootShorthand.onFocus, onInputFocus);\n rootShorthand.onClick = mergeCallbacks(rootShorthand.onClick, onInputClick);\n\n const { modalAttributes } = useModalAttributes({ trapFocus: true, alwaysFocusable: true, legacyTrapFocus: false });\n const popupSurfaceShorthand = open\n ? resolveShorthand(props.popupSurface, {\n required: true,\n defaultProps: {\n 'aria-label': 'Calendar',\n 'aria-modal': true,\n id: popupSurfaceId,\n role: 'dialog',\n ref: popupRef,\n ...modalAttributes,\n },\n })\n : undefined;\n\n const { targetDocument } = useFluent();\n useOnClickOutside({\n element: targetDocument,\n callback: ev => dismissDatePickerPopup(),\n refs: [triggerWrapperRef, popupRef],\n disabled: !open,\n });\n\n useOnScrollOutside({\n element: targetDocument,\n callback: ev => dismissDatePickerPopup(),\n refs: [triggerWrapperRef, popupRef],\n disabled: !open,\n });\n\n const { findFirstFocusable } = useFocusFinders();\n React.useEffect(() => {\n if (disableAutoFocus) {\n return;\n }\n\n if (open && popupRef.current) {\n const firstFocusable = findFirstFocusable(popupRef.current);\n firstFocusable?.focus();\n }\n }, [disableAutoFocus, findFirstFocusable, open, popupRef]);\n\n const popupOnClick = useEventCallback(\n mergeCallbacks((ev: React.MouseEvent<HTMLDivElement>) => {\n rootRef.current?.focus();\n }, popupSurfaceShorthand?.onClick),\n );\n\n if (popupSurfaceShorthand) {\n popupSurfaceShorthand.onClick = popupOnClick;\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 React.useImperativeHandle(\n props.componentRef,\n () => ({\n focus,\n reset() {\n setOpen(false);\n setSelectedDate(undefined);\n },\n showDatePickerPopup,\n }),\n [focus, setOpen, setSelectedDate, showDatePickerPopup],\n );\n\n const state: DatePickerState = {\n disabled: !!props.disabled,\n inlinePopup,\n\n components: {\n root: Input,\n calendar: Calendar as React.FC<Partial<CalendarProps>>,\n popupSurface: 'div',\n },\n\n calendar: calendarShorthand,\n root: rootShorthand,\n popupSurface: popupSurfaceShorthand,\n };\n\n state.root.value = formattedDate;\n state.calendar.onSelectDate = mergeCallbacks(state.calendar.onSel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,EAAU9F,QAAA;MACVmJ,YAAA,EAAc;IAChB;IAEArD,QAAA,EAAU+D,iBAAA;IACVrB,IAAA,EAAMR,aAAA;IACNmB,YAAA,EAAcD;EAChB;EAEAvG,KAAA,CAAM6F,IAAI,CAACpF,KAAK,GAAGI,aAAA;EACnBb,KAAA,CAAMmD,QAAQ,CAAC3C,YAAY,GAAG5C,cAAA,CAAeoC,KAAA,CAAMmD,QAAQ,CAAC3C,YAAY,EAAE2D,iBAAA;EAE1E,OAAOnE,KAAA;AACT"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { __resetStyles, __styles, mergeClasses } from '@griffel/react';
|
|
2
|
+
import { tokens, typographyStyles } from '@fluentui/react-theme';
|
|
3
|
+
export const datePickerClassNames = {
|
|
4
|
+
root: 'fui-DatePicker',
|
|
5
|
+
calendar: 'fui-DatePicker__calendar',
|
|
6
|
+
popupSurface: 'fui-DatePicker__popupSurface'
|
|
7
|
+
};
|
|
8
|
+
const useStyles = /*#__PURE__*/__styles({
|
|
9
|
+
base: {
|
|
10
|
+
qhf8xq: "f10pi13n",
|
|
11
|
+
Bceei9c: "f1k6fduh",
|
|
12
|
+
xfaavh: "faxec97"
|
|
13
|
+
},
|
|
14
|
+
disabled: {
|
|
15
|
+
Bceei9c: "f158kwzp",
|
|
16
|
+
xfaavh: "f19qwlmg"
|
|
17
|
+
}
|
|
18
|
+
}, {
|
|
19
|
+
d: [".f10pi13n{position:relative;}", ".f1k6fduh{cursor:pointer;}", ".faxec97 input{cursor:pointer;}", ".f158kwzp{cursor:default;}", ".f19qwlmg input{cursor:default;}"]
|
|
20
|
+
});
|
|
21
|
+
const usePopupSurfaceClassName = /*#__PURE__*/__resetStyles("r1ytv1z8", null, [".r1ytv1z8{background-color:var(--colorNeutralBackground1);box-shadow:var(--shadow16);border-radius:var(--borderRadiusMedium);border-width:1px;border-style:solid;border-color:var(--colorTransparentStroke);display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;color:var(--colorNeutralForeground1);font-family:var(--fontFamilyBase);font-size:var(--fontSizeBase300);font-weight:var(--fontWeightRegular);line-height:var(--lineHeightBase300);}"]);
|
|
22
|
+
/**
|
|
23
|
+
* Apply styling to the DatePicker slots based on the state
|
|
24
|
+
*/
|
|
25
|
+
export const useDatePickerStyles_unstable = state => {
|
|
26
|
+
const styles = useStyles();
|
|
27
|
+
const popupSurfaceClassName = usePopupSurfaceClassName();
|
|
28
|
+
const {
|
|
29
|
+
disabled
|
|
30
|
+
} = state;
|
|
31
|
+
state.root.className = mergeClasses(datePickerClassNames.root, styles.base, disabled && styles.disabled, state.root.className);
|
|
32
|
+
if (state.popupSurface) {
|
|
33
|
+
state.popupSurface.className = mergeClasses(datePickerClassNames.popupSurface, popupSurfaceClassName, state.popupSurface.className);
|
|
34
|
+
}
|
|
35
|
+
state.calendar.className = mergeClasses(datePickerClassNames.calendar, state.calendar.className);
|
|
36
|
+
return state;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=useDatePickerStyles.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__resetStyles","__styles","mergeClasses","tokens","typographyStyles","datePickerClassNames","root","calendar","popupSurface","useStyles","base","qhf8xq","Bceei9c","xfaavh","disabled","d","usePopupSurfaceClassName","useDatePickerStyles_unstable","state","styles","popupSurfaceClassName","className"],"sources":["../../../src/components/DatePicker/useDatePickerStyles.styles.ts"],"sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses } from '@griffel/react';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\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 calendar: 'fui-DatePicker__calendar',\n popupSurface: 'fui-DatePicker__popupSurface',\n};\n\nconst useStyles = makeStyles({\n base: {\n position: 'relative',\n cursor: 'pointer',\n '& input': {\n cursor: 'pointer',\n },\n },\n disabled: {\n cursor: 'default',\n '& input': {\n cursor: 'default',\n },\n },\n});\n\nconst usePopupSurfaceClassName = makeResetStyles({\n backgroundColor: tokens.colorNeutralBackground1,\n boxShadow: tokens.shadow16,\n borderRadius: tokens.borderRadiusMedium,\n borderWidth: '1px',\n borderStyle: 'solid',\n borderColor: tokens.colorTransparentStroke,\n display: 'inline-flex',\n color: tokens.colorNeutralForeground1,\n ...typographyStyles.body1,\n});\n\n/**\n * Apply styling to the DatePicker slots based on the state\n */\nexport const useDatePickerStyles_unstable = (state: DatePickerState): DatePickerState => {\n const styles = useStyles();\n const popupSurfaceClassName = usePopupSurfaceClassName();\n const { disabled } = state;\n\n state.root.className = mergeClasses(\n datePickerClassNames.root,\n styles.base,\n disabled && styles.disabled,\n state.root.className,\n );\n\n if (state.popupSurface) {\n state.popupSurface.className = mergeClasses(\n datePickerClassNames.popupSurface,\n popupSurfaceClassName,\n state.popupSurface.className,\n );\n }\n\n state.calendar.className = mergeClasses(datePickerClassNames.calendar, state.calendar.className);\n\n return state;\n};\n"],"mappings":"AAAA,SAAAA,aAAA,EAAAC,QAAA,EAAsCC,YAAY,QAAQ;AAC1D,SAASC,MAAM,EAAEC,gBAAgB,QAAQ;AAIzC,OAAO,MAAMC,oBAAA,GAAwD;EACnEC,IAAA,EAAM;EACNC,QAAA,EAAU;EACVC,YAAA,EAAc;AAChB;AAEA,MAAMC,SAAA,gBAAYR,QAAA;EAAAS,IAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;EAAAC,QAAA;IAAAF,OAAA;IAAAC,MAAA;EAAA;AAAA;EAAAE,CAAA;AAAA,EAclB;AAEA,MAAMC,wBAAA,gBAA2BhB,aAAA,6fAUjC;AAEA;;;AAGA,OAAO,MAAMiB,4BAAA,GAAgCC,KAAA,IAA4C;EACvF,MAAMC,MAAA,GAASV,SAAA;EACf,MAAMW,qBAAA,GAAwBJ,wBAAA;EAC9B,MAAM;IAAEF;EAAQ,CAAE,GAAGI,KAAA;EAErBA,KAAA,CAAMZ,IAAI,CAACe,SAAS,GAAGnB,YAAA,CACrBG,oBAAA,CAAqBC,IAAI,EACzBa,MAAA,CAAOT,IAAI,EACXI,QAAA,IAAYK,MAAA,CAAOL,QAAQ,EAC3BI,KAAA,CAAMZ,IAAI,CAACe,SAAS;EAGtB,IAAIH,KAAA,CAAMV,YAAY,EAAE;IACtBU,KAAA,CAAMV,YAAY,CAACa,SAAS,GAAGnB,YAAA,CAC7BG,oBAAA,CAAqBG,YAAY,EACjCY,qBAAA,EACAF,KAAA,CAAMV,YAAY,CAACa,SAAS;EAEhC;EAEAH,KAAA,CAAMX,QAAQ,CAACc,SAAS,GAAGnB,YAAA,CAAaG,oBAAA,CAAqBE,QAAQ,EAAEW,KAAA,CAAMX,QAAQ,CAACc,SAAS;EAE/F,OAAOH,KAAA;AACT"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { AnimationDirection } from './Calendar';
|
|
2
|
+
export { DatePicker, datePickerClassNames, defaultDatePickerErrorStrings, 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","DatePicker","datePickerClassNames","defaultDatePickerErrorStrings","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 } 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 defaultDatePickerErrorStrings,\n defaultDatePickerStrings,\n renderDatePicker_unstable,\n useDatePicker_unstable,\n useDatePickerStyles_unstable,\n} from './DatePicker';\nexport type { DatePickerErrorType, DatePickerProps, DatePickerValidationResultData, 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,QAAQ;AAOnC,SACEC,UAAU,EACVC,oBAAoB,EACpBC,6BAA6B,EAC7BC,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"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { shorthands } from '@griffel/react';
|
|
2
|
+
export const EASING_FUNCTION_1 = 'cubic-bezier(.1,.9,.2,1)';
|
|
3
|
+
export const EASING_FUNCTION_2 = 'cubic-bezier(.1,.25,.75,.9)';
|
|
4
|
+
export const DURATION_1 = '0.167s';
|
|
5
|
+
export const DURATION_2 = '0.267s';
|
|
6
|
+
export const DURATION_3 = '0.367s';
|
|
7
|
+
export const DURATION_4 = '0.467s';
|
|
8
|
+
export const FADE_IN = {
|
|
9
|
+
from: {
|
|
10
|
+
opacity: 0
|
|
11
|
+
},
|
|
12
|
+
to: {
|
|
13
|
+
opacity: 1
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export const FADE_OUT = {
|
|
17
|
+
from: {
|
|
18
|
+
opacity: 1
|
|
19
|
+
},
|
|
20
|
+
to: {
|
|
21
|
+
opacity: 0,
|
|
22
|
+
visibility: 'hidden'
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
export const SLIDE_DOWN_IN20 = {
|
|
26
|
+
from: {
|
|
27
|
+
pointerEvents: 'none',
|
|
28
|
+
transform: 'translate3d(0, -20px, 0)'
|
|
29
|
+
},
|
|
30
|
+
to: {
|
|
31
|
+
pointerEvents: 'auto',
|
|
32
|
+
transform: 'translate3d(0, 0, 0)'
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
export const SLIDE_LEFT_IN20 = {
|
|
36
|
+
from: {
|
|
37
|
+
pointerEvents: 'none',
|
|
38
|
+
transform: 'translate3d(20px, 0, 0)'
|
|
39
|
+
},
|
|
40
|
+
to: {
|
|
41
|
+
pointerEvents: 'auto',
|
|
42
|
+
transform: 'translate3d(0, 0, 0)'
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
export const SLIDE_RIGHT_IN20 = {
|
|
46
|
+
from: {
|
|
47
|
+
pointerEvents: 'none',
|
|
48
|
+
transform: 'translate3d(-20px, 0, 0)'
|
|
49
|
+
},
|
|
50
|
+
to: {
|
|
51
|
+
pointerEvents: 'auto',
|
|
52
|
+
transform: 'translate3d(0, 0, 0)'
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
export const SLIDE_UP_IN20 = {
|
|
56
|
+
from: {
|
|
57
|
+
pointerEvents: 'none',
|
|
58
|
+
transform: 'translate3d(0, 20px, 0)'
|
|
59
|
+
},
|
|
60
|
+
to: {
|
|
61
|
+
pointerEvents: 'auto',
|
|
62
|
+
transform: 'translate3d(0, 0, 0)'
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
export const SLIDE_DOWN_OUT20 = {
|
|
66
|
+
from: {
|
|
67
|
+
transform: 'translate3d(0, 0, 0)'
|
|
68
|
+
},
|
|
69
|
+
to: {
|
|
70
|
+
transform: 'translate3d(0, 20px, 0)'
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
export const SLIDE_UP_OUT20 = {
|
|
74
|
+
from: {
|
|
75
|
+
transform: 'translate3d(0, 0, 0)'
|
|
76
|
+
},
|
|
77
|
+
to: {
|
|
78
|
+
transform: 'translate3d(0, -20px, 0)'
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
export const TRANSITION_ROW_DISAPPEARANCE = {
|
|
82
|
+
'100%': {
|
|
83
|
+
height: '0px',
|
|
84
|
+
... /*#__PURE__*/shorthands.overflow('hidden'),
|
|
85
|
+
width: '0px'
|
|
86
|
+
},
|
|
87
|
+
'99.9%': {
|
|
88
|
+
height: '28px',
|
|
89
|
+
... /*#__PURE__*/shorthands.overflow('visible'),
|
|
90
|
+
width: '100%'
|
|
91
|
+
},
|
|
92
|
+
'0%': {
|
|
93
|
+
height: '28px',
|
|
94
|
+
... /*#__PURE__*/shorthands.overflow('visible'),
|
|
95
|
+
width: '100%'
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=animations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["shorthands","EASING_FUNCTION_1","EASING_FUNCTION_2","DURATION_1","DURATION_2","DURATION_3","DURATION_4","FADE_IN","from","opacity","to","FADE_OUT","visibility","SLIDE_DOWN_IN20","pointerEvents","transform","SLIDE_LEFT_IN20","SLIDE_RIGHT_IN20","SLIDE_UP_IN20","SLIDE_DOWN_OUT20","SLIDE_UP_OUT20","TRANSITION_ROW_DISAPPEARANCE","height","overflow","width"],"sources":["../../src/utils/animations.ts"],"sourcesContent":["import { shorthands } from '@griffel/react';\n\nexport const EASING_FUNCTION_1 = 'cubic-bezier(.1,.9,.2,1)';\nexport const EASING_FUNCTION_2 = 'cubic-bezier(.1,.25,.75,.9)';\nexport const DURATION_1 = '0.167s';\nexport const DURATION_2 = '0.267s';\nexport const DURATION_3 = '0.367s';\nexport const DURATION_4 = '0.467s';\n\nexport const FADE_IN = {\n from: {\n opacity: 0,\n },\n to: {\n opacity: 1,\n },\n};\nexport const FADE_OUT = {\n from: {\n opacity: 1,\n },\n to: {\n opacity: 0,\n visibility: 'hidden' as const,\n },\n};\nexport const SLIDE_DOWN_IN20 = {\n from: {\n pointerEvents: 'none' as const,\n transform: 'translate3d(0, -20px, 0)',\n },\n to: {\n pointerEvents: 'auto' as const,\n transform: 'translate3d(0, 0, 0)',\n },\n};\nexport const SLIDE_LEFT_IN20 = {\n from: {\n pointerEvents: 'none' as const,\n transform: 'translate3d(20px, 0, 0)',\n },\n to: {\n pointerEvents: 'auto' as const,\n transform: 'translate3d(0, 0, 0)',\n },\n};\nexport const SLIDE_RIGHT_IN20 = {\n from: {\n pointerEvents: 'none' as const,\n transform: 'translate3d(-20px, 0, 0)',\n },\n to: {\n pointerEvents: 'auto' as const,\n transform: 'translate3d(0, 0, 0)',\n },\n};\nexport const SLIDE_UP_IN20 = {\n from: {\n pointerEvents: 'none' as const,\n transform: 'translate3d(0, 20px, 0)',\n },\n to: {\n pointerEvents: 'auto' as const,\n transform: 'translate3d(0, 0, 0)',\n },\n};\nexport const SLIDE_DOWN_OUT20 = {\n from: {\n transform: 'translate3d(0, 0, 0)',\n },\n to: {\n transform: 'translate3d(0, 20px, 0)',\n },\n};\nexport const SLIDE_UP_OUT20 = {\n from: {\n transform: 'translate3d(0, 0, 0)',\n },\n to: {\n transform: 'translate3d(0, -20px, 0)',\n },\n};\nexport const TRANSITION_ROW_DISAPPEARANCE = {\n '100%': {\n height: '0px',\n ...shorthands.overflow('hidden'),\n width: '0px',\n },\n '99.9%': {\n height: '28px',\n ...shorthands.overflow('visible'),\n width: '100%',\n },\n '0%': {\n height: '28px',\n ...shorthands.overflow('visible'),\n width: '100%',\n },\n};\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ;AAE3B,OAAO,MAAMC,iBAAA,GAAoB;AACjC,OAAO,MAAMC,iBAAA,GAAoB;AACjC,OAAO,MAAMC,UAAA,GAAa;AAC1B,OAAO,MAAMC,UAAA,GAAa;AAC1B,OAAO,MAAMC,UAAA,GAAa;AAC1B,OAAO,MAAMC,UAAA,GAAa;AAE1B,OAAO,MAAMC,OAAA,GAAU;EACrBC,IAAA,EAAM;IACJC,OAAA,EAAS;EACX;EACAC,EAAA,EAAI;IACFD,OAAA,EAAS;EACX;AACF;AACA,OAAO,MAAME,QAAA,GAAW;EACtBH,IAAA,EAAM;IACJC,OAAA,EAAS;EACX;EACAC,EAAA,EAAI;IACFD,OAAA,EAAS;IACTG,UAAA,EAAY;EACd;AACF;AACA,OAAO,MAAMC,eAAA,GAAkB;EAC7BL,IAAA,EAAM;IACJM,aAAA,EAAe;IACfC,SAAA,EAAW;EACb;EACAL,EAAA,EAAI;IACFI,aAAA,EAAe;IACfC,SAAA,EAAW;EACb;AACF;AACA,OAAO,MAAMC,eAAA,GAAkB;EAC7BR,IAAA,EAAM;IACJM,aAAA,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