@elliemae/ds-controlled-form 2.4.2-rc.1 → 2.4.2-rc.13
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/cjs/autocomplete/config/useAutocomplete.js +0 -1
- package/cjs/autocomplete/parts/A11yFocusedOption.js +46 -0
- package/cjs/autocomplete/parts/container/Container.js +36 -24
- package/cjs/autocomplete/parts/container/styled.js +2 -2
- package/cjs/autocomplete/parts/container/useKeyboardNavigation.js +2 -2
- package/cjs/autocomplete/parts/menu-list/MenuList.js +6 -6
- package/cjs/autocomplete/parts/menu-list/styled.js +2 -2
- package/cjs/autocomplete/parts/menu-list/useItemRenderer.js +1 -1
- package/cjs/autocomplete/parts/styled.js +2 -0
- package/cjs/autocomplete/utils/listHelper.js +1 -1
- package/cjs/checkbox/ControlledCheckbox.js +1 -1
- package/cjs/checkbox/config/useValidateProps.js +6 -3
- package/cjs/checkbox/react-desc-prop-types.js +2 -1
- package/cjs/checkbox/styles.js +73 -27
- package/cjs/checkbox/utils/styleHelpers.js +20 -2
- package/cjs/combobox/ComboBoxCTX.js +6 -3
- package/cjs/combobox/config/useComboBox.js +16 -6
- package/cjs/combobox/config/useCorrectOptions.js +1 -2
- package/cjs/combobox/parts/A11yFocusedOption.js +14 -6
- package/cjs/combobox/parts/A11ySelectedValues.js +2 -4
- package/cjs/combobox/parts/DropdownIndicator.js +15 -7
- package/cjs/combobox/parts/container/Container.js +11 -14
- package/cjs/combobox/parts/container/styled.js +11 -10
- package/cjs/combobox/parts/controls/Controls.js +19 -27
- package/cjs/combobox/parts/controls/styled.js +54 -22
- package/cjs/combobox/parts/controls/useOnPillsNavigation.js +7 -15
- package/cjs/combobox/parts/controls-input/ControlsInput.js +2 -2
- package/cjs/combobox/parts/controls-input/styled.js +41 -11
- package/cjs/combobox/parts/controls-input/useControlsInput.js +4 -7
- package/cjs/combobox/parts/controls-input/useKeyboardNavigation.js +19 -28
- package/cjs/combobox/parts/controls-input/useMaskedOnChange.js +7 -7
- package/cjs/combobox/parts/dropdown-indicator/DropdownIndicator.js +2 -2
- package/cjs/combobox/parts/header-list/HeaderList.js +1 -1
- package/cjs/combobox/parts/header-list/styled.js +39 -10
- package/cjs/combobox/parts/header-list/useHeaderListHandlers.js +7 -14
- package/cjs/combobox/parts/menu-list/MenuList.js +8 -6
- package/cjs/combobox/parts/menu-list/styled.js +38 -20
- package/cjs/combobox/parts/menu-list/useItemRenderer.js +18 -17
- package/cjs/combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +1 -1
- package/cjs/combobox/parts/multi-selected-values-container/RemovableSelectedValuePill.js +1 -3
- package/cjs/combobox/parts/multi-selected-values-container/useGroupPills.js +1 -2
- package/cjs/combobox/parts/styled.js +6 -7
- package/cjs/combobox/react-desc-prop-types.js +3 -2
- package/cjs/combobox/sharedTypes.js +2 -2
- package/cjs/combobox/utils/listHelper.js +14 -9
- package/cjs/date-range-picker/config/useRangePickerLogic.js +4 -8
- package/cjs/date-range-picker/parts/ControlledDateRangeCalendar.js +0 -2
- package/cjs/date-range-picker/parts/ControlledDateRangeFromDate.js +0 -2
- package/cjs/date-range-picker/parts/ControlledDateRangeToDate.js +0 -2
- package/cjs/date-time-picker/config/useChangeHandlers.js +11 -15
- package/cjs/date-time-picker/config/useControlledDateTimePicker.js +14 -10
- package/cjs/date-time-picker/config/useFocusTracker.js +136 -0
- package/cjs/date-time-picker/config/useGetDestructuredValues.js +6 -6
- package/cjs/date-time-picker/config/useGetPropsBasedOnType.js +1 -1
- package/cjs/date-time-picker/config/useGetReferences.js +39 -18
- package/cjs/date-time-picker/config/useGlobalKeyHandlers.js +8 -12
- package/cjs/date-time-picker/config/useRelevantValueFromProps.js +1 -1
- package/cjs/date-time-picker/config/useValidateProps.js +42 -11
- package/cjs/date-time-picker/parts/ClearButton/ClearButton.js +10 -2
- package/cjs/date-time-picker/parts/ClearButton/useClearButton.js +12 -25
- package/cjs/date-time-picker/parts/ControlledDateTimePickerContent.js +4 -7
- package/cjs/date-time-picker/parts/DateInputs/DDInput.js +8 -6
- package/cjs/date-time-picker/parts/DateInputs/DateInputs.js +9 -4
- package/cjs/date-time-picker/parts/DateInputs/MMInput.js +8 -6
- package/cjs/date-time-picker/parts/DateInputs/YYYYInput.js +8 -6
- package/cjs/date-time-picker/parts/DateInputs/useDateInputs.js +84 -113
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarDaysList.js +4 -4
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarHead.js +25 -7
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarIconTrigger.js +1 -1
- package/cjs/date-time-picker/parts/Pickers/Calendar/Day.js +21 -17
- package/cjs/date-time-picker/parts/Pickers/Calendar/Styleds.js +44 -15
- package/cjs/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +13 -14
- package/cjs/date-time-picker/parts/Pickers/Calendar/useCurrentDisplayedMonthYearLogic.js +2 -1
- package/cjs/date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +2 -39
- package/cjs/date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.js +40 -73
- package/cjs/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +18 -29
- package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +2 -1
- package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +19 -27
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/HoursList.js +15 -11
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +17 -13
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +15 -11
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/SecondsList.js +2 -2
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/Styleds.js +47 -15
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/TimeWheelContent.js +1 -1
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/TimeWheelIconTrigger.js +1 -1
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/useCurrentDisplayedWheelsLogic.js +3 -3
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.js +36 -230
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +12 -17
- package/cjs/date-time-picker/parts/Styleds.js +12 -6
- package/cjs/date-time-picker/parts/TimeInputs/HHInput.js +7 -3
- package/cjs/date-time-picker/parts/TimeInputs/MeridiemInput.js +8 -7
- package/cjs/date-time-picker/parts/TimeInputs/MinutesInput.js +8 -6
- package/cjs/date-time-picker/parts/TimeInputs/TimeInputs.js +11 -6
- package/cjs/date-time-picker/parts/TimeInputs/useTimeInputs.js +55 -97
- package/cjs/date-time-picker/utils/constants.js +0 -12
- package/cjs/date-time-picker/utils/dateHelpers.js +17 -34
- package/cjs/date-time-picker/utils/hooks/useGetStartingFocusedDay.js +38 -36
- package/cjs/date-time-picker/utils/hooks/useOnClickOutside.js +1 -3
- package/cjs/date-time-picker/utils/stringHelpers.js +5 -11
- package/cjs/input-group/InputGroup.js +8 -7
- package/cjs/input-group/exported-related/data-test-ids.js +12 -0
- package/cjs/input-group/exported-related/index.js +12 -0
- package/cjs/input-group/exported-related/theming.js +13 -0
- package/cjs/input-group/styled.js +90 -23
- package/cjs/large-text-input/DSControlledLargeTextInput.js +1 -1
- package/cjs/large-text-input/styles.js +27 -13
- package/cjs/mask-hook/hooks/useNumberMask.js +1 -5
- package/cjs/mask-hook/hooks/usePhoneMask.js +1 -4
- package/cjs/mask-hook/hooks/useRegExpMask.js +4 -7
- package/cjs/mask-hook/hooks/useSSNMask.js +1 -4
- package/cjs/mask-hook/hooks/useZipCodeMask.js +1 -4
- package/cjs/mask-hook/utils/addSpecialCharacters.js +0 -1
- package/cjs/mask-hook/utils/flatStringArray.js +0 -1
- package/cjs/text-input/config/useInputText.js +0 -1
- package/cjs/text-input/styled/borders.js +18 -11
- package/cjs/text-input/styled/components.js +49 -10
- package/cjs/toggle/ControlledToggle.js +2 -3
- package/cjs/toggle/styles.js +7 -5
- package/esm/autocomplete/config/useAutocomplete.js +0 -1
- package/esm/autocomplete/parts/A11yFocusedOption.js +36 -0
- package/esm/autocomplete/parts/container/Container.js +39 -27
- package/esm/autocomplete/parts/container/styled.js +2 -2
- package/esm/autocomplete/parts/container/useKeyboardNavigation.js +2 -2
- package/esm/autocomplete/parts/menu-list/MenuList.js +7 -7
- package/esm/autocomplete/parts/menu-list/styled.js +2 -2
- package/esm/autocomplete/parts/menu-list/useItemRenderer.js +1 -1
- package/esm/autocomplete/parts/styled.js +1 -0
- package/esm/autocomplete/utils/listHelper.js +1 -1
- package/esm/checkbox/ControlledCheckbox.js +2 -2
- package/esm/checkbox/config/useValidateProps.js +6 -3
- package/esm/checkbox/react-desc-prop-types.js +2 -1
- package/esm/checkbox/styles.js +73 -24
- package/esm/checkbox/utils/styleHelpers.js +20 -2
- package/esm/combobox/ComboBoxCTX.js +6 -3
- package/esm/combobox/config/useComboBox.js +16 -6
- package/esm/combobox/config/useCorrectOptions.js +1 -2
- package/esm/combobox/parts/A11yFocusedOption.js +15 -7
- package/esm/combobox/parts/A11ySelectedValues.js +2 -4
- package/esm/combobox/parts/DropdownIndicator.js +15 -6
- package/esm/combobox/parts/container/Container.js +11 -14
- package/esm/combobox/parts/container/styled.js +11 -6
- package/esm/combobox/parts/controls/Controls.js +19 -27
- package/esm/combobox/parts/controls/styled.js +54 -18
- package/esm/combobox/parts/controls/useOnPillsNavigation.js +7 -15
- package/esm/combobox/parts/controls-input/ControlsInput.js +2 -2
- package/esm/combobox/parts/controls-input/styled.js +41 -7
- package/esm/combobox/parts/controls-input/useControlsInput.js +4 -7
- package/esm/combobox/parts/controls-input/useKeyboardNavigation.js +20 -29
- package/esm/combobox/parts/controls-input/useMaskedOnChange.js +7 -7
- package/esm/combobox/parts/dropdown-indicator/DropdownIndicator.js +2 -2
- package/esm/combobox/parts/header-list/HeaderList.js +1 -1
- package/esm/combobox/parts/header-list/styled.js +40 -7
- package/esm/combobox/parts/header-list/useHeaderListHandlers.js +7 -14
- package/esm/combobox/parts/menu-list/MenuList.js +8 -6
- package/esm/combobox/parts/menu-list/styled.js +38 -17
- package/esm/combobox/parts/menu-list/useItemRenderer.js +20 -19
- package/esm/combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +1 -1
- package/esm/combobox/parts/multi-selected-values-container/RemovableSelectedValuePill.js +1 -3
- package/esm/combobox/parts/multi-selected-values-container/useGroupPills.js +1 -2
- package/esm/combobox/parts/styled.js +6 -3
- package/esm/combobox/react-desc-prop-types.js +3 -2
- package/esm/combobox/sharedTypes.js +2 -2
- package/esm/combobox/utils/listHelper.js +14 -10
- package/esm/date-range-picker/config/useRangePickerLogic.js +3 -7
- package/esm/date-range-picker/parts/ControlledDateRangeCalendar.js +0 -2
- package/esm/date-range-picker/parts/ControlledDateRangeFromDate.js +0 -2
- package/esm/date-range-picker/parts/ControlledDateRangeToDate.js +0 -2
- package/esm/date-time-picker/config/useChangeHandlers.js +11 -15
- package/esm/date-time-picker/config/useControlledDateTimePicker.js +14 -10
- package/esm/date-time-picker/config/useFocusTracker.js +132 -0
- package/esm/date-time-picker/config/useGetDestructuredValues.js +6 -6
- package/esm/date-time-picker/config/useGetPropsBasedOnType.js +1 -1
- package/esm/date-time-picker/config/useGetReferences.js +40 -19
- package/esm/date-time-picker/config/useGlobalKeyHandlers.js +8 -12
- package/esm/date-time-picker/config/useRelevantValueFromProps.js +1 -1
- package/esm/date-time-picker/config/useValidateProps.js +42 -11
- package/esm/date-time-picker/parts/ClearButton/ClearButton.js +10 -2
- package/esm/date-time-picker/parts/ClearButton/useClearButton.js +12 -25
- package/esm/date-time-picker/parts/ControlledDateTimePickerContent.js +4 -7
- package/esm/date-time-picker/parts/DateInputs/DDInput.js +8 -6
- package/esm/date-time-picker/parts/DateInputs/DateInputs.js +9 -4
- package/esm/date-time-picker/parts/DateInputs/MMInput.js +8 -6
- package/esm/date-time-picker/parts/DateInputs/YYYYInput.js +8 -6
- package/esm/date-time-picker/parts/DateInputs/useDateInputs.js +85 -114
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarDaysList.js +4 -4
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarHead.js +26 -8
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarIconTrigger.js +1 -1
- package/esm/date-time-picker/parts/Pickers/Calendar/Day.js +21 -17
- package/esm/date-time-picker/parts/Pickers/Calendar/Styleds.js +44 -14
- package/esm/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +12 -13
- package/esm/date-time-picker/parts/Pickers/Calendar/useCurrentDisplayedMonthYearLogic.js +2 -1
- package/esm/date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +3 -40
- package/esm/date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.js +40 -73
- package/esm/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +18 -29
- package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +2 -1
- package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +19 -27
- package/esm/date-time-picker/parts/Pickers/TimeWheel/HoursList.js +16 -12
- package/esm/date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +18 -14
- package/esm/date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +16 -12
- package/esm/date-time-picker/parts/Pickers/TimeWheel/SecondsList.js +2 -2
- package/esm/date-time-picker/parts/Pickers/TimeWheel/Styleds.js +47 -14
- package/esm/date-time-picker/parts/Pickers/TimeWheel/TimeWheelContent.js +1 -1
- package/esm/date-time-picker/parts/Pickers/TimeWheel/TimeWheelIconTrigger.js +1 -1
- package/esm/date-time-picker/parts/Pickers/TimeWheel/useCurrentDisplayedWheelsLogic.js +3 -3
- package/esm/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.js +36 -230
- package/esm/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +12 -17
- package/esm/date-time-picker/parts/Styleds.js +12 -6
- package/esm/date-time-picker/parts/TimeInputs/HHInput.js +7 -3
- package/esm/date-time-picker/parts/TimeInputs/MeridiemInput.js +8 -7
- package/esm/date-time-picker/parts/TimeInputs/MinutesInput.js +8 -6
- package/esm/date-time-picker/parts/TimeInputs/TimeInputs.js +11 -6
- package/esm/date-time-picker/parts/TimeInputs/useTimeInputs.js +55 -97
- package/esm/date-time-picker/utils/constants.js +1 -7
- package/esm/date-time-picker/utils/dateHelpers.js +17 -34
- package/esm/date-time-picker/utils/hooks/useGetStartingFocusedDay.js +38 -36
- package/esm/date-time-picker/utils/hooks/useOnClickOutside.js +1 -3
- package/esm/date-time-picker/utils/stringHelpers.js +5 -11
- package/esm/input-group/InputGroup.js +5 -4
- package/esm/input-group/exported-related/data-test-ids.js +8 -0
- package/esm/input-group/exported-related/index.js +2 -0
- package/esm/input-group/exported-related/theming.js +8 -0
- package/esm/input-group/styled.js +89 -18
- package/esm/large-text-input/DSControlledLargeTextInput.js +1 -1
- package/esm/large-text-input/styles.js +27 -9
- package/esm/mask-hook/hooks/useNumberMask.js +1 -5
- package/esm/mask-hook/hooks/usePhoneMask.js +1 -4
- package/esm/mask-hook/hooks/useRegExpMask.js +4 -7
- package/esm/mask-hook/hooks/useSSNMask.js +1 -4
- package/esm/mask-hook/hooks/useZipCodeMask.js +1 -4
- package/esm/mask-hook/utils/addSpecialCharacters.js +0 -1
- package/esm/mask-hook/utils/flatStringArray.js +0 -1
- package/esm/text-input/config/useInputText.js +0 -1
- package/esm/text-input/styled/borders.js +18 -7
- package/esm/text-input/styled/components.js +49 -6
- package/esm/toggle/ControlledToggle.js +0 -1
- package/esm/toggle/styles.js +7 -5
- package/package.json +39 -15
- package/types/autocomplete/parts/A11yFocusedOption.d.ts +5 -0
- package/types/autocomplete/parts/container/styled.d.ts +1 -1
- package/types/autocomplete/parts/styled.d.ts +0 -0
- package/types/autocomplete/utils/listHelper.d.ts +5 -5
- package/types/checkbox/react-desc-prop-types.d.ts +1 -1
- package/types/checkbox/styles.d.ts +1 -0
- package/types/combobox/parts/menu-list/styled.d.ts +1 -0
- package/types/combobox/react-desc-prop-types.d.ts +8 -6
- package/types/combobox/sharedTypes.d.ts +3 -2
- package/types/combobox/utils/listHelper.d.ts +1 -0
- package/types/date-time-picker/config/useChangeHandlers.d.ts +3 -1
- package/types/date-time-picker/config/useControlledDateTimePicker.d.ts +2 -5
- package/types/date-time-picker/config/useFocusTracker.d.ts +38 -0
- package/types/date-time-picker/config/useGetPropsBasedOnType.d.ts +6 -6
- package/types/date-time-picker/config/useGetReferences.d.ts +30 -36
- package/types/date-time-picker/config/useGlobalKeyHandlers.d.ts +3 -1
- package/types/date-time-picker/parts/DateInputs/DDInput.d.ts +2 -1
- package/types/date-time-picker/parts/DateInputs/MMInput.d.ts +2 -1
- package/types/date-time-picker/parts/DateInputs/YYYYInput.d.ts +2 -1
- package/types/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.d.ts +14 -0
- package/types/date-time-picker/parts/Pickers/Calendar/useFocusLogic.d.ts +1 -2
- package/types/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.d.ts +19 -0
- package/types/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.d.ts +0 -6
- package/types/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.d.ts +14 -0
- package/types/date-time-picker/parts/TimeInputs/HHInput.d.ts +2 -1
- package/types/date-time-picker/parts/TimeInputs/MeridiemInput.d.ts +2 -1
- package/types/date-time-picker/parts/TimeInputs/MinutesInput.d.ts +2 -1
- package/types/date-time-picker/propTypes.d.ts +117 -0
- package/types/date-time-picker/sharedTypes.d.ts +1 -1
- package/types/date-time-picker/utils/constants.d.ts +0 -6
- package/types/input-group/exported-related/data-test-ids.d.ts +6 -0
- package/types/input-group/exported-related/index.d.ts +2 -0
- package/types/input-group/exported-related/theming.d.ts +6 -0
- package/types/input-group/styled.d.ts +4 -7
- package/types/text-input/config/useInputText.d.ts +4 -4
|
@@ -49,17 +49,16 @@ const Day = _ref => {
|
|
|
49
49
|
appOnDayChange,
|
|
50
50
|
appOnYearChange,
|
|
51
51
|
latestInteractionRegion,
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
isWithTimeWheelToo,
|
|
53
|
+
trackFocusCalendarMetafocusedDay
|
|
54
54
|
} = useContext(ControlledDateTimePickerContext);
|
|
55
55
|
const {
|
|
56
56
|
focusedDay,
|
|
57
57
|
handleDayOnKeyDown,
|
|
58
58
|
handleFocusMetaDayByDay,
|
|
59
|
-
closeCalendar
|
|
60
|
-
tryToFocusCurrentlyDataIsFocusedDay
|
|
59
|
+
closeCalendar
|
|
61
60
|
} = useContext(CalendarContext);
|
|
62
|
-
const isFocusedMetaDay = focusedDay
|
|
61
|
+
const isFocusedMetaDay = focusedDay?.day ? compareTwoDatesDayEquality(metaDay?.day, focusedDay?.day) : false;
|
|
63
62
|
const isSelected = useMemo(() => {
|
|
64
63
|
const selectedDate = getDayFromDateString(dateStringFromProps);
|
|
65
64
|
return selectedDate ? isSameDateMoment(day, selectedDate) : false;
|
|
@@ -72,7 +71,6 @@ const Day = _ref => {
|
|
|
72
71
|
const isDayInRange = !isStartRangeDay && !isEndRangeDay && getIsDayInRange(metaDay.dayAsString);
|
|
73
72
|
const handleOnDayClick = useCallback(e => {
|
|
74
73
|
handleFocusMetaDayByDay(day);
|
|
75
|
-
tryToFocusCurrentlyDataIsFocusedDay();
|
|
76
74
|
|
|
77
75
|
if (!isDisabled && !isOutOfRange) {
|
|
78
76
|
const newDateString = getDateStringFromDay(day);
|
|
@@ -86,18 +84,24 @@ const Day = _ref => {
|
|
|
86
84
|
day: dayNumber,
|
|
87
85
|
year
|
|
88
86
|
} = getDateValuesFromDate(day);
|
|
89
|
-
appOnMonthChange(
|
|
90
|
-
if (dayNumber) appOnDayChange(
|
|
91
|
-
appOnYearChange(
|
|
87
|
+
appOnMonthChange(`${month + 1}`, e, metaInfo);
|
|
88
|
+
if (dayNumber) appOnDayChange(`${dayNumber}`, e, metaInfo);
|
|
89
|
+
appOnYearChange(`${year}`, e, metaInfo);
|
|
92
90
|
handleChangeComposedDateString(newDateString, metaInfo);
|
|
93
|
-
|
|
91
|
+
trackFocusCalendarMetafocusedDay();
|
|
94
92
|
if (!isWithTimeWheelToo && !preventCloseOnSelection) closeCalendar();
|
|
95
93
|
}
|
|
96
|
-
}, [isDisabled, isOutOfRange,
|
|
94
|
+
}, [handleFocusMetaDayByDay, day, isDisabled, isOutOfRange, appOnMonthChange, appOnDayChange, appOnYearChange, handleChangeComposedDateString, trackFocusCalendarMetafocusedDay, isWithTimeWheelToo, preventCloseOnSelection, closeCalendar]);
|
|
95
|
+
const handleInnerRef = useCallback(ButtonDomNode => {
|
|
96
|
+
window.requestAnimationFrame(() => {
|
|
97
|
+
dayBtnRef.current = ButtonDomNode;
|
|
98
|
+
if (isFocused) ButtonDomNode?.focus?.();
|
|
99
|
+
});
|
|
100
|
+
}, [dayBtnRef, isFocused]);
|
|
97
101
|
const handleOnDayFocus = useCallback(() => {
|
|
98
|
-
|
|
99
|
-
}, [
|
|
100
|
-
const dayClassModifiers = useMemo(() =>
|
|
102
|
+
trackFocusCalendarMetafocusedDay('calendar-days');
|
|
103
|
+
}, [trackFocusCalendarMetafocusedDay]);
|
|
104
|
+
const dayClassModifiers = useMemo(() => `dayWrapper ${isSelected ? 'selectedDay ' : ''}${isDisabled ? 'disabledDay ' : ''}${isOutOfRange ? 'outOfRangeDay ' : ''}${isFocused ? 'focusedDay ' : ''}${isStartRangeDay ? 'startRangeDay ' : ''}${isDayInRange ? 'inRangeDay ' : ''}${isEndRangeDay ? 'endRangeDay ' : ''}${isCurrMonthDay ? '' : 'notCurrentMonth'}`, [isSelected, isDisabled, isOutOfRange, isFocused, isStartRangeDay, isDayInRange, isEndRangeDay, isCurrMonthDay]);
|
|
101
105
|
let dataTestid = ControlledDateTimePickerDatatestid.CALENDAR.DAY;
|
|
102
106
|
if (isSelected) dataTestid = ControlledDateTimePickerDatatestid.CALENDAR.SELECTED_DAY;
|
|
103
107
|
if (isFocused) dataTestid = ControlledDateTimePickerDatatestid.CALENDAR.FOCUSED_DAY;
|
|
@@ -113,7 +117,7 @@ const Day = _ref => {
|
|
|
113
117
|
'aria-colindex': colIndex
|
|
114
118
|
}), {}, {
|
|
115
119
|
children: /*#__PURE__*/_jsx(StyledDayBtn, {
|
|
116
|
-
"aria-label":
|
|
120
|
+
"aria-label": `${getAriaDayFromDateString(dayAsString)}, ${weekDays[metaDay.day.getDay()]}`,
|
|
117
121
|
"aria-disabled": isOutOfRange || isDisabled,
|
|
118
122
|
"aria-hidden": !!isInvisible,
|
|
119
123
|
buttonType: "raw",
|
|
@@ -124,11 +128,11 @@ const Day = _ref => {
|
|
|
124
128
|
onKeyDown: e => {
|
|
125
129
|
handleDayOnKeyDown(e, metaDay);
|
|
126
130
|
},
|
|
127
|
-
innerRef:
|
|
131
|
+
innerRef: handleInnerRef,
|
|
128
132
|
tabIndex: isSelected ? 0 : -1,
|
|
129
133
|
"data-isfocused": isFocused,
|
|
130
134
|
"data-testid": dataTestid
|
|
131
|
-
}, void 0,
|
|
135
|
+
}, void 0, `${day.getDate()}`)
|
|
132
136
|
}));
|
|
133
137
|
};
|
|
134
138
|
|
|
@@ -1,46 +1,76 @@
|
|
|
1
|
-
import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
|
|
2
1
|
import styled from 'styled-components';
|
|
3
2
|
import { css } from '@elliemae/ds-system';
|
|
4
3
|
import { Grid } from '@elliemae/ds-grid';
|
|
5
4
|
import { DSButtonV2 } from '@elliemae/ds-button';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
const diagonalLine = css
|
|
6
|
+
/* eslint-disable max-lines */
|
|
7
|
+
const diagonalLine = css`
|
|
8
|
+
&:before {
|
|
9
|
+
position: absolute;
|
|
10
|
+
content: '';
|
|
11
|
+
top: 48%;
|
|
12
|
+
left: -2px;
|
|
13
|
+
height: 1px;
|
|
14
|
+
width: calc(100% + 4px);
|
|
15
|
+
transform: rotate(45deg);
|
|
16
|
+
background-color: ${_ref => {
|
|
9
17
|
let {
|
|
10
18
|
theme
|
|
11
19
|
} = _ref;
|
|
12
20
|
return theme.colors.neutral[500];
|
|
13
|
-
}
|
|
14
|
-
|
|
21
|
+
}};
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
const focusBorder = css`
|
|
25
|
+
&:after {
|
|
26
|
+
position: absolute;
|
|
27
|
+
content: '';
|
|
28
|
+
top: -4px;
|
|
29
|
+
left: -4px;
|
|
30
|
+
width: calc(100% + 8px);
|
|
31
|
+
height: calc(100% + 8px);
|
|
32
|
+
border-radius: 50%;
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
15
35
|
const backgroundDateRange = {
|
|
16
|
-
inRange: css
|
|
36
|
+
inRange: css`
|
|
37
|
+
background-color: ${_ref2 => {
|
|
17
38
|
let {
|
|
18
39
|
theme
|
|
19
40
|
} = _ref2;
|
|
20
41
|
return theme.colors.brand[200];
|
|
21
|
-
}
|
|
42
|
+
}};
|
|
43
|
+
box-shadow: 4px 0 0 0 ${_ref3 => {
|
|
22
44
|
let {
|
|
23
45
|
theme
|
|
24
46
|
} = _ref3;
|
|
25
47
|
return theme.colors.brand[200];
|
|
26
|
-
}
|
|
27
|
-
|
|
48
|
+
}};
|
|
49
|
+
`,
|
|
50
|
+
startRange: css`
|
|
51
|
+
background-color: ${_ref4 => {
|
|
28
52
|
let {
|
|
29
53
|
theme
|
|
30
54
|
} = _ref4;
|
|
31
55
|
return theme.colors.brand[200];
|
|
32
|
-
}
|
|
56
|
+
}};
|
|
57
|
+
border-radius: 50% 0 0 50%;
|
|
58
|
+
box-shadow: 4px 0 0 0 ${_ref5 => {
|
|
33
59
|
let {
|
|
34
60
|
theme
|
|
35
61
|
} = _ref5;
|
|
36
62
|
return theme.colors.brand[200];
|
|
37
|
-
}
|
|
38
|
-
|
|
63
|
+
}};
|
|
64
|
+
`,
|
|
65
|
+
endRange: css`
|
|
66
|
+
background-color: ${_ref6 => {
|
|
39
67
|
let {
|
|
40
68
|
theme
|
|
41
69
|
} = _ref6;
|
|
42
70
|
return theme.colors.brand[200];
|
|
43
|
-
}
|
|
71
|
+
}};
|
|
72
|
+
border-radius: 0 50% 50% 0;
|
|
73
|
+
`
|
|
44
74
|
};
|
|
45
75
|
const StyledIconTriggerButton = /*#__PURE__*/styled(DSButtonV2).withConfig({
|
|
46
76
|
componentId: "sc-1vlmm1g-0"
|
|
@@ -130,7 +160,7 @@ const StyledWeekDaysListWrapper = /*#__PURE__*/styled(Grid).withConfig({
|
|
|
130
160
|
isHeader,
|
|
131
161
|
theme
|
|
132
162
|
} = _ref19;
|
|
133
|
-
return isHeader ?
|
|
163
|
+
return isHeader ? `background: ${theme.colors.neutral['050']}` : '';
|
|
134
164
|
}, _ref20 => {
|
|
135
165
|
let {
|
|
136
166
|
isHeader
|
|
@@ -4,7 +4,6 @@ import 'core-js/modules/esnext.iterator.filter.js';
|
|
|
4
4
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
5
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
8
7
|
import { useContext, useState, useCallback, useMemo } from 'react';
|
|
9
8
|
import { ControlledDateTimePickerContext } from '../../../ControlledDateTimePickerCTX.js';
|
|
10
9
|
import { useCurrentDisplayedMonthYearLogic } from './useCurrentDisplayedMonthYearLogic.js';
|
|
@@ -17,24 +16,24 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
17
16
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
17
|
const useConfigCalendarCTX = () => {
|
|
19
18
|
const {
|
|
20
|
-
|
|
19
|
+
trackFocusCalendarPrevYear,
|
|
20
|
+
trackFocusCalendarNextYear,
|
|
21
|
+
trackFocusCalendarPrevMonth,
|
|
22
|
+
trackFocusCalendarNextMonth
|
|
21
23
|
} = useContext(ControlledDateTimePickerContext);
|
|
22
24
|
const [showCalendar, setShowCalendar] = useState(false);
|
|
23
|
-
const setLatestInteractionRegionCalendarHead = useCallback(() => {
|
|
24
|
-
setLatestInteractionRegion('calendar-head');
|
|
25
|
-
}, [setLatestInteractionRegion]);
|
|
26
25
|
const onPrevYearFocus = useCallback(() => {
|
|
27
|
-
|
|
28
|
-
}, [
|
|
26
|
+
trackFocusCalendarPrevYear();
|
|
27
|
+
}, [trackFocusCalendarPrevYear]);
|
|
29
28
|
const onPrevMonthFocus = useCallback(() => {
|
|
30
|
-
|
|
31
|
-
}, [
|
|
29
|
+
trackFocusCalendarPrevMonth();
|
|
30
|
+
}, [trackFocusCalendarPrevMonth]);
|
|
32
31
|
const onNextMonthFocus = useCallback(() => {
|
|
33
|
-
|
|
34
|
-
}, [
|
|
32
|
+
trackFocusCalendarNextMonth();
|
|
33
|
+
}, [trackFocusCalendarNextMonth]);
|
|
35
34
|
const onNextYearFocus = useCallback(() => {
|
|
36
|
-
|
|
37
|
-
}, [
|
|
35
|
+
trackFocusCalendarNextYear();
|
|
36
|
+
}, [trackFocusCalendarNextYear]);
|
|
38
37
|
const currentDisplayedMonthLogic = useCurrentDisplayedMonthYearLogic();
|
|
39
38
|
const focusLogic = useFocusLogic({
|
|
40
39
|
currentDisplayedMonthLogic,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
1
|
import { useState, useEffect, useMemo, createRef, useCallback } from 'react';
|
|
3
2
|
import { useGetMonthYearFromDateStringOrEmptyStartingMonth } from '../../../utils/hooks/useGetMonthYearFromDateStringOrEmptyStartingMonth.js';
|
|
4
3
|
import { getFiveBySevenCurrentMonthDaysMatrix, sumValuesToDate, getDateStringFromDay, sumFromDateValues } from '../../../utils/dateHelpers.js';
|
|
5
4
|
|
|
5
|
+
/* eslint-disable complexity */
|
|
6
|
+
|
|
6
7
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
8
|
function sliceIntoChunks(arr, chunkSize) {
|
|
8
9
|
const res = [];
|
|
@@ -1,33 +1,14 @@
|
|
|
1
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
1
|
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
3
2
|
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
4
3
|
import 'core-js/modules/esnext.iterator.find.js';
|
|
5
|
-
import {
|
|
6
|
-
import { ControlledDateTimePickerContext } from '../../../ControlledDateTimePickerCTX.js';
|
|
4
|
+
import { useState, useMemo, useCallback } from 'react';
|
|
7
5
|
import { compareTwoDatesDayEquality } from '../../../utils/dateHelpers.js';
|
|
8
6
|
import { useGetStartingFocusedDay } from '../../../utils/hooks/useGetStartingFocusedDay.js';
|
|
9
7
|
|
|
10
|
-
// eslint-disable-next-line max-params
|
|
11
|
-
const loopWhileWaiting = function (cb) {
|
|
12
|
-
let shortcircuit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : () => false;
|
|
13
|
-
let timePerTry = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 100;
|
|
14
|
-
let maxTries = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 5;
|
|
15
|
-
let ab = maxTries;
|
|
16
|
-
const inter = setInterval(() => {
|
|
17
|
-
cb();
|
|
18
|
-
if (shortcircuit() || ab === 0) clearInterval(inter);
|
|
19
|
-
ab -= 1;
|
|
20
|
-
}, timePerTry);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
8
|
const useFocusLogic = _ref => {
|
|
24
9
|
let {
|
|
25
|
-
currentDisplayedMonthLogic
|
|
26
|
-
showCalendar
|
|
10
|
+
currentDisplayedMonthLogic
|
|
27
11
|
} = _ref;
|
|
28
|
-
const {
|
|
29
|
-
calendarDaysWrapperRef
|
|
30
|
-
} = useContext(ControlledDateTimePickerContext);
|
|
31
12
|
const {
|
|
32
13
|
daysArray
|
|
33
14
|
} = currentDisplayedMonthLogic;
|
|
@@ -59,23 +40,6 @@ const useFocusLogic = _ref => {
|
|
|
59
40
|
});
|
|
60
41
|
return newFocusedDay;
|
|
61
42
|
}, [daysArray, startFocusedDate, metadayToFocus]);
|
|
62
|
-
const tryToFocusCurrentlyDataIsFocusedDay = useCallback(function () {
|
|
63
|
-
let wrapperDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (calendarDaysWrapperRef === null || calendarDaysWrapperRef === void 0 ? void 0 : calendarDaysWrapperRef.current) || document;
|
|
64
|
-
let shortcircuit = false;
|
|
65
|
-
loopWhileWaiting(() => {
|
|
66
|
-
const domElem = wrapperDOM === null || wrapperDOM === void 0 ? void 0 : wrapperDOM.querySelector('[data-isfocused="true"]');
|
|
67
|
-
|
|
68
|
-
if (domElem) {
|
|
69
|
-
var _domElem$focus;
|
|
70
|
-
|
|
71
|
-
domElem === null || domElem === void 0 ? void 0 : (_domElem$focus = domElem.focus) === null || _domElem$focus === void 0 ? void 0 : _domElem$focus.call(domElem);
|
|
72
|
-
shortcircuit = true;
|
|
73
|
-
}
|
|
74
|
-
}, () => shortcircuit);
|
|
75
|
-
}, [calendarDaysWrapperRef]);
|
|
76
|
-
useLayoutEffect(() => {
|
|
77
|
-
if (showCalendar) tryToFocusCurrentlyDataIsFocusedDay(calendarDaysWrapperRef === null || calendarDaysWrapperRef === void 0 ? void 0 : calendarDaysWrapperRef.current);
|
|
78
|
-
}, [calendarDaysWrapperRef, focusedDay, showCalendar, tryToFocusCurrentlyDataIsFocusedDay]);
|
|
79
43
|
const handleFocusMetaDay = useCallback(metaDayToFocus => {
|
|
80
44
|
// if focusedDay is inside current daysArray we set Focused day
|
|
81
45
|
const newFocusedMetaDay = daysArray.find(_ref5 => {
|
|
@@ -101,11 +65,10 @@ const useFocusLogic = _ref => {
|
|
|
101
65
|
}, []);
|
|
102
66
|
return useMemo(() => ({
|
|
103
67
|
focusedDay,
|
|
104
|
-
tryToFocusCurrentlyDataIsFocusedDay,
|
|
105
68
|
resetFocusedDayToStartDate,
|
|
106
69
|
handleFocusMetaDay,
|
|
107
70
|
handleFocusMetaDayByDay
|
|
108
|
-
}), [focusedDay,
|
|
71
|
+
}), [focusedDay, resetFocusedDayToStartDate, handleFocusMetaDay, handleFocusMetaDayByDay]);
|
|
109
72
|
};
|
|
110
73
|
|
|
111
74
|
export { useFocusLogic };
|
|
@@ -4,7 +4,6 @@ import 'core-js/modules/esnext.iterator.find.js';
|
|
|
4
4
|
import { useContext, useCallback, useMemo } from 'react';
|
|
5
5
|
import { ControlledDateTimePickerContext } from '../../../ControlledDateTimePickerCTX.js';
|
|
6
6
|
import { sumValuesToDate } from '../../../utils/dateHelpers.js';
|
|
7
|
-
import { homeEndKeys, homeEndAllArrowKeys } from '../../../utils/constants.js';
|
|
8
7
|
|
|
9
8
|
const useKeyboardHandlers = _ref => {
|
|
10
9
|
let {
|
|
@@ -12,29 +11,26 @@ const useKeyboardHandlers = _ref => {
|
|
|
12
11
|
focusLogic
|
|
13
12
|
} = _ref;
|
|
14
13
|
const {
|
|
15
|
-
hideDate,
|
|
16
|
-
hideTime,
|
|
17
|
-
monthInputRef,
|
|
18
|
-
hourInputRef,
|
|
19
|
-
prevYearBtnRef,
|
|
20
|
-
prevMonthBtnRef,
|
|
21
|
-
nextMonthBtnRef,
|
|
22
|
-
nextYearBtnRef,
|
|
23
|
-
currMeridiemBtnRef,
|
|
24
14
|
isControllerOnly,
|
|
25
15
|
isWithTimeWheelToo,
|
|
26
|
-
setLatestInteractionRegion,
|
|
27
16
|
withAnyInputs,
|
|
28
17
|
isWithTimeInputs,
|
|
29
|
-
meridiemInputRef,
|
|
30
18
|
isWithDateInputs,
|
|
31
|
-
|
|
19
|
+
trackFocusFirstSegment,
|
|
20
|
+
trackFocusMeridiemInput,
|
|
21
|
+
trackFocusYearInput,
|
|
22
|
+
trackFocusCalendarPrevMonth,
|
|
23
|
+
trackFocusCalendarNextMonth,
|
|
24
|
+
trackFocusCalendarNextYear,
|
|
25
|
+
trackFocusCalendarPrevYear,
|
|
26
|
+
trackFocusTimewheelCurrMeridiem,
|
|
27
|
+
trackFocusCalendarMetafocusedDay
|
|
32
28
|
} = useContext(ControlledDateTimePickerContext);
|
|
33
29
|
const {
|
|
34
30
|
focusedDay,
|
|
35
31
|
handleFocusMetaDay,
|
|
36
|
-
handleFocusMetaDayByDay
|
|
37
|
-
|
|
32
|
+
handleFocusMetaDayByDay // tryToFocusCurrentlyDataIsFocusedDay
|
|
33
|
+
|
|
38
34
|
} = focusLogic;
|
|
39
35
|
const {
|
|
40
36
|
daysArray,
|
|
@@ -42,8 +38,6 @@ const useKeyboardHandlers = _ref => {
|
|
|
42
38
|
handleNextMonth
|
|
43
39
|
} = currentDisplayedMonthLogic;
|
|
44
40
|
const tryToFocusDayRegion = useCallback(() => {
|
|
45
|
-
setLatestInteractionRegion('calendar-days');
|
|
46
|
-
|
|
47
41
|
if (!focusedDay) {
|
|
48
42
|
const newFocusDay = daysArray.find(_ref2 => {
|
|
49
43
|
let {
|
|
@@ -51,42 +45,32 @@ const useKeyboardHandlers = _ref => {
|
|
|
51
45
|
} = _ref2;
|
|
52
46
|
return isCurrMonthDay;
|
|
53
47
|
});
|
|
54
|
-
if (newFocusDay)
|
|
55
|
-
handleFocusMetaDay(newFocusDay);
|
|
56
|
-
});
|
|
57
|
-
} else {
|
|
58
|
-
tryToFocusCurrentlyDataIsFocusedDay();
|
|
48
|
+
if (newFocusDay) handleFocusMetaDay(newFocusDay);
|
|
59
49
|
}
|
|
60
|
-
}, [daysArray, focusedDay, handleFocusMetaDay, setLatestInteractionRegion, tryToFocusCurrentlyDataIsFocusedDay]);
|
|
61
|
-
const onHomeKeyDownInsideCalendar = useCallback(() => {
|
|
62
|
-
var _prevMonthBtnRef$curr, _prevMonthBtnRef$curr2;
|
|
63
50
|
|
|
64
|
-
|
|
65
|
-
}, [
|
|
51
|
+
trackFocusCalendarMetafocusedDay();
|
|
52
|
+
}, [daysArray, focusedDay, handleFocusMetaDay, trackFocusCalendarMetafocusedDay]);
|
|
53
|
+
const onHomeKeyDownInsideCalendar = useCallback(() => {
|
|
54
|
+
trackFocusCalendarPrevMonth();
|
|
55
|
+
}, [trackFocusCalendarPrevMonth]);
|
|
66
56
|
const onEndKeyDownInsideCalendar = useCallback(() => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (isWithTimeWheelToo) currMeridiemBtnRef === null || currMeridiemBtnRef === void 0 ? void 0 : (_currMeridiemBtnRef$c = currMeridiemBtnRef.current) === null || _currMeridiemBtnRef$c === void 0 ? void 0 : (_currMeridiemBtnRef$c2 = _currMeridiemBtnRef$c.focus) === null || _currMeridiemBtnRef$c2 === void 0 ? void 0 : _currMeridiemBtnRef$c2.call(_currMeridiemBtnRef$c);else tryToFocusDayRegion();
|
|
70
|
-
}, [currMeridiemBtnRef, isWithTimeWheelToo, tryToFocusDayRegion]);
|
|
57
|
+
if (isWithTimeWheelToo) trackFocusTimewheelCurrMeridiem();else tryToFocusDayRegion();
|
|
58
|
+
}, [isWithTimeWheelToo, trackFocusTimewheelCurrMeridiem, tryToFocusDayRegion]);
|
|
71
59
|
const onHomeKeyDownTriggerIcon = useCallback(() => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (!hideDate) monthInputRef === null || monthInputRef === void 0 ? void 0 : (_monthInputRef$curren = monthInputRef.current) === null || _monthInputRef$curren === void 0 ? void 0 : (_monthInputRef$curren2 = _monthInputRef$curren.focus) === null || _monthInputRef$curren2 === void 0 ? void 0 : _monthInputRef$curren2.call(_monthInputRef$curren);else if (!hideTime) hourInputRef === null || hourInputRef === void 0 ? void 0 : (_hourInputRef$current = hourInputRef.current) === null || _hourInputRef$current === void 0 ? void 0 : (_hourInputRef$current2 = _hourInputRef$current.focus) === null || _hourInputRef$current2 === void 0 ? void 0 : _hourInputRef$current2.call(_hourInputRef$current);
|
|
75
|
-
}, [hideDate, hideTime, monthInputRef, hourInputRef]);
|
|
60
|
+
trackFocusFirstSegment();
|
|
61
|
+
}, [trackFocusFirstSegment]);
|
|
76
62
|
const handlePickerIconKeyDown = useCallback(e => {
|
|
77
63
|
const {
|
|
78
64
|
key
|
|
79
65
|
} = e;
|
|
80
|
-
if (
|
|
81
|
-
if (
|
|
66
|
+
if (['Home', 'End'].includes(key)) e.preventDefault();
|
|
67
|
+
if (['Home', 'End'].includes(key)) e.stopPropagation();
|
|
82
68
|
if (key === 'Home') onHomeKeyDownTriggerIcon();
|
|
83
69
|
|
|
84
70
|
if (key === 'Backspace' && withAnyInputs) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (isWithTimeInputs) meridiemInputRef === null || meridiemInputRef === void 0 ? void 0 : (_meridiemInputRef$cur = meridiemInputRef.current) === null || _meridiemInputRef$cur === void 0 ? void 0 : (_meridiemInputRef$cur2 = _meridiemInputRef$cur.focus) === null || _meridiemInputRef$cur2 === void 0 ? void 0 : _meridiemInputRef$cur2.call(_meridiemInputRef$cur);else if (isWithDateInputs) yearInputRef === null || yearInputRef === void 0 ? void 0 : (_yearInputRef$current = yearInputRef.current) === null || _yearInputRef$current === void 0 ? void 0 : (_yearInputRef$current2 = _yearInputRef$current.focus) === null || _yearInputRef$current2 === void 0 ? void 0 : _yearInputRef$current2.call(_yearInputRef$current);
|
|
71
|
+
if (isWithTimeInputs) trackFocusMeridiemInput();else if (isWithDateInputs) trackFocusYearInput();
|
|
88
72
|
}
|
|
89
|
-
}, [isWithDateInputs, isWithTimeInputs,
|
|
73
|
+
}, [isWithDateInputs, isWithTimeInputs, onHomeKeyDownTriggerIcon, trackFocusMeridiemInput, trackFocusYearInput, withAnyInputs]);
|
|
90
74
|
const handleDayOnKeyDown = useCallback((e, metaDay) => {
|
|
91
75
|
let newFocusedDayDate;
|
|
92
76
|
const {
|
|
@@ -96,8 +80,8 @@ const useKeyboardHandlers = _ref => {
|
|
|
96
80
|
key,
|
|
97
81
|
shiftKey
|
|
98
82
|
} = e;
|
|
99
|
-
if (
|
|
100
|
-
if (
|
|
83
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(key)) e.preventDefault();
|
|
84
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(key)) e.stopPropagation();
|
|
101
85
|
if (key === 'ArrowUp') newFocusedDayDate = sumValuesToDate(day, {
|
|
102
86
|
daysToSum: -7
|
|
103
87
|
});
|
|
@@ -127,21 +111,18 @@ const useKeyboardHandlers = _ref => {
|
|
|
127
111
|
|
|
128
112
|
if (newFocusedDayDate) {
|
|
129
113
|
handleFocusMetaDayByDay(newFocusedDayDate);
|
|
130
|
-
setTimeout(tryToFocusCurrentlyDataIsFocusedDay);
|
|
131
114
|
}
|
|
132
115
|
|
|
133
116
|
if (key === 'Home') onHomeKeyDownInsideCalendar();
|
|
134
117
|
if (key === 'End') onEndKeyDownInsideCalendar(); // TAB CYCLE IMPLEMENTATION
|
|
135
118
|
|
|
136
119
|
if (key === 'Tab' && !shiftKey && isControllerOnly === false && !isWithTimeWheelToo) {
|
|
137
|
-
var _prevMonthBtnRef$curr3, _prevMonthBtnRef$curr4;
|
|
138
|
-
|
|
139
120
|
// MUST prevent default since this is a custom focus switch
|
|
140
121
|
// NOT preventing the default event will cause unexpected result
|
|
141
122
|
e.preventDefault();
|
|
142
|
-
|
|
123
|
+
trackFocusCalendarPrevMonth();
|
|
143
124
|
}
|
|
144
|
-
}, [daysArray, handleFocusMetaDayByDay, handleNextMonth, handlePrevMonth, isControllerOnly, isWithTimeWheelToo, onEndKeyDownInsideCalendar, onHomeKeyDownInsideCalendar,
|
|
125
|
+
}, [daysArray, handleFocusMetaDayByDay, handleNextMonth, handlePrevMonth, isControllerOnly, isWithTimeWheelToo, onEndKeyDownInsideCalendar, onHomeKeyDownInsideCalendar, trackFocusCalendarPrevMonth]);
|
|
145
126
|
const handlePrevYearKeyDown = useCallback(e => {
|
|
146
127
|
const {
|
|
147
128
|
key,
|
|
@@ -152,13 +133,9 @@ const useKeyboardHandlers = _ref => {
|
|
|
152
133
|
e.preventDefault();
|
|
153
134
|
|
|
154
135
|
if (shiftKey) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
(_nextMonthBtnRef$curr = nextMonthBtnRef.current) === null || _nextMonthBtnRef$curr === void 0 ? void 0 : _nextMonthBtnRef$curr.focus();
|
|
136
|
+
trackFocusCalendarNextMonth();
|
|
158
137
|
} else {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
(_nextYearBtnRef$curre = nextYearBtnRef.current) === null || _nextYearBtnRef$curre === void 0 ? void 0 : _nextYearBtnRef$curre.focus();
|
|
138
|
+
trackFocusCalendarNextYear();
|
|
162
139
|
}
|
|
163
140
|
}
|
|
164
141
|
|
|
@@ -171,7 +148,7 @@ const useKeyboardHandlers = _ref => {
|
|
|
171
148
|
onEndKeyDownInsideCalendar();
|
|
172
149
|
e.preventDefault();
|
|
173
150
|
}
|
|
174
|
-
}, [
|
|
151
|
+
}, [onEndKeyDownInsideCalendar, onHomeKeyDownInsideCalendar, trackFocusCalendarNextMonth, trackFocusCalendarNextYear]);
|
|
175
152
|
const handlePrevMonthKeyDown = useCallback(e => {
|
|
176
153
|
const {
|
|
177
154
|
key,
|
|
@@ -182,16 +159,12 @@ const useKeyboardHandlers = _ref => {
|
|
|
182
159
|
if (shiftKey) {
|
|
183
160
|
// TAB CYCLE IMPLEMENTATION
|
|
184
161
|
if (!isControllerOnly) {
|
|
185
|
-
var _currMeridiemBtnRef$c3, _currMeridiemBtnRef$c4;
|
|
186
|
-
|
|
187
162
|
e.preventDefault();
|
|
188
|
-
if (isWithTimeWheelToo)
|
|
163
|
+
if (isWithTimeWheelToo) trackFocusTimewheelCurrMeridiem();else tryToFocusDayRegion();
|
|
189
164
|
}
|
|
190
165
|
} else {
|
|
191
|
-
var _nextMonthBtnRef$curr2;
|
|
192
|
-
|
|
193
166
|
e.preventDefault();
|
|
194
|
-
(
|
|
167
|
+
trackFocusCalendarNextMonth();
|
|
195
168
|
}
|
|
196
169
|
}
|
|
197
170
|
|
|
@@ -204,7 +177,7 @@ const useKeyboardHandlers = _ref => {
|
|
|
204
177
|
onEndKeyDownInsideCalendar();
|
|
205
178
|
e.preventDefault();
|
|
206
179
|
}
|
|
207
|
-
}, [
|
|
180
|
+
}, [isControllerOnly, isWithTimeWheelToo, onEndKeyDownInsideCalendar, onHomeKeyDownInsideCalendar, trackFocusCalendarNextMonth, trackFocusTimewheelCurrMeridiem, tryToFocusDayRegion]);
|
|
208
181
|
const handleNextMonthKeyDown = useCallback(e => {
|
|
209
182
|
const {
|
|
210
183
|
key,
|
|
@@ -215,13 +188,9 @@ const useKeyboardHandlers = _ref => {
|
|
|
215
188
|
e.preventDefault();
|
|
216
189
|
|
|
217
190
|
if (shiftKey) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
(_prevMonthBtnRef$curr5 = prevMonthBtnRef.current) === null || _prevMonthBtnRef$curr5 === void 0 ? void 0 : _prevMonthBtnRef$curr5.focus();
|
|
191
|
+
trackFocusCalendarPrevMonth();
|
|
221
192
|
} else {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
(_prevYearBtnRef$curre = prevYearBtnRef.current) === null || _prevYearBtnRef$curre === void 0 ? void 0 : _prevYearBtnRef$curre.focus();
|
|
193
|
+
trackFocusCalendarPrevYear();
|
|
225
194
|
}
|
|
226
195
|
}
|
|
227
196
|
|
|
@@ -234,7 +203,7 @@ const useKeyboardHandlers = _ref => {
|
|
|
234
203
|
onEndKeyDownInsideCalendar();
|
|
235
204
|
e.preventDefault();
|
|
236
205
|
}
|
|
237
|
-
}, [onEndKeyDownInsideCalendar, onHomeKeyDownInsideCalendar,
|
|
206
|
+
}, [onEndKeyDownInsideCalendar, onHomeKeyDownInsideCalendar, trackFocusCalendarPrevMonth, trackFocusCalendarPrevYear]);
|
|
238
207
|
const handleNextYearKeyDown = useCallback(e => {
|
|
239
208
|
const {
|
|
240
209
|
key,
|
|
@@ -245,9 +214,7 @@ const useKeyboardHandlers = _ref => {
|
|
|
245
214
|
e.preventDefault();
|
|
246
215
|
|
|
247
216
|
if (shiftKey) {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
prevYearBtnRef === null || prevYearBtnRef === void 0 ? void 0 : (_prevYearBtnRef$curre2 = prevYearBtnRef.current) === null || _prevYearBtnRef$curre2 === void 0 ? void 0 : (_prevYearBtnRef$curre3 = _prevYearBtnRef$curre2.focus) === null || _prevYearBtnRef$curre3 === void 0 ? void 0 : _prevYearBtnRef$curre3.call(_prevYearBtnRef$curre2);
|
|
217
|
+
trackFocusCalendarPrevYear();
|
|
251
218
|
}
|
|
252
219
|
|
|
253
220
|
if (!shiftKey) tryToFocusDayRegion();
|
|
@@ -262,7 +229,7 @@ const useKeyboardHandlers = _ref => {
|
|
|
262
229
|
onEndKeyDownInsideCalendar();
|
|
263
230
|
e.preventDefault();
|
|
264
231
|
}
|
|
265
|
-
}, [tryToFocusDayRegion,
|
|
232
|
+
}, [tryToFocusDayRegion, trackFocusCalendarPrevYear, onHomeKeyDownInsideCalendar, onEndKeyDownInsideCalendar]);
|
|
266
233
|
return useMemo(() => ({
|
|
267
234
|
handleDayOnKeyDown,
|
|
268
235
|
handlePrevYearKeyDown,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
1
|
import { useContext, useState, useCallback, useMemo } from 'react';
|
|
3
2
|
import { usePopper } from 'react-popper';
|
|
4
3
|
import { ControlledDateTimePickerContext } from '../../../ControlledDateTimePickerCTX.js';
|
|
5
4
|
import { useOnClickOutside } from '../../../utils/hooks/useOnClickOutside.js';
|
|
6
5
|
|
|
6
|
+
/* eslint-disable complexity */
|
|
7
7
|
const usePopperTriggerLogic = _ref => {
|
|
8
8
|
let {
|
|
9
9
|
focusLogic,
|
|
@@ -12,16 +12,19 @@ const usePopperTriggerLogic = _ref => {
|
|
|
12
12
|
} = _ref;
|
|
13
13
|
const {
|
|
14
14
|
focusedDay,
|
|
15
|
-
resetFocusedDayToStartDate
|
|
16
|
-
tryToFocusCurrentlyDataIsFocusedDay
|
|
15
|
+
resetFocusedDayToStartDate
|
|
17
16
|
} = focusLogic;
|
|
18
17
|
const {
|
|
19
18
|
props: {
|
|
20
19
|
onPickerOpen,
|
|
21
20
|
onPickerClose
|
|
22
21
|
},
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
pickerButtonRef,
|
|
23
|
+
trackFocusCalendarMetafocusedDay,
|
|
24
|
+
trackFocusCalendarPrevMonth,
|
|
25
|
+
trackFocusPicker,
|
|
26
|
+
latestInteractionRegion,
|
|
27
|
+
currFocusDescriber
|
|
25
28
|
} = useContext(ControlledDateTimePickerContext);
|
|
26
29
|
const [referenceElement, setReferenceElement] = useState(null);
|
|
27
30
|
const [popperElement, setPopperElement] = useState(null);
|
|
@@ -37,29 +40,18 @@ const usePopperTriggerLogic = _ref => {
|
|
|
37
40
|
|
|
38
41
|
const handleOnPickerOpen = useCallback(() => {
|
|
39
42
|
onPickerOpen();
|
|
40
|
-
|
|
41
|
-
}, [onPickerOpen, tryToFocusCurrentlyDataIsFocusedDay]);
|
|
43
|
+
}, [onPickerOpen]);
|
|
42
44
|
const openCalendar = useCallback(() => {
|
|
43
|
-
if (focusedDay)
|
|
44
|
-
var _focusedDay$dayBtnRef, _focusedDay$dayBtnRef2, _focusedDay$dayBtnRef3;
|
|
45
|
-
|
|
46
|
-
return focusedDay === null || focusedDay === void 0 ? void 0 : (_focusedDay$dayBtnRef = focusedDay.dayBtnRef) === null || _focusedDay$dayBtnRef === void 0 ? void 0 : (_focusedDay$dayBtnRef2 = _focusedDay$dayBtnRef.current) === null || _focusedDay$dayBtnRef2 === void 0 ? void 0 : (_focusedDay$dayBtnRef3 = _focusedDay$dayBtnRef2.focus) === null || _focusedDay$dayBtnRef3 === void 0 ? void 0 : _focusedDay$dayBtnRef3.call(_focusedDay$dayBtnRef2);
|
|
47
|
-
}, 100);else setTimeout(() => {
|
|
48
|
-
var _prevMonthBtnRef$curr, _prevMonthBtnRef$curr2;
|
|
49
|
-
|
|
50
|
-
return prevMonthBtnRef === null || prevMonthBtnRef === void 0 ? void 0 : (_prevMonthBtnRef$curr = prevMonthBtnRef.current) === null || _prevMonthBtnRef$curr === void 0 ? void 0 : (_prevMonthBtnRef$curr2 = _prevMonthBtnRef$curr.focus) === null || _prevMonthBtnRef$curr2 === void 0 ? void 0 : _prevMonthBtnRef$curr2.call(_prevMonthBtnRef$curr);
|
|
51
|
-
}, 100);
|
|
45
|
+
if (focusedDay) trackFocusCalendarMetafocusedDay();else trackFocusCalendarPrevMonth();
|
|
52
46
|
setShowCalendar(true);
|
|
53
47
|
handleOnPickerOpen();
|
|
54
|
-
}, [focusedDay, handleOnPickerOpen,
|
|
48
|
+
}, [focusedDay, handleOnPickerOpen, setShowCalendar, trackFocusCalendarMetafocusedDay, trackFocusCalendarPrevMonth]);
|
|
55
49
|
const closeCalendar = useCallback(() => {
|
|
56
|
-
var _pickerButtonRef$curr, _pickerButtonRef$curr2;
|
|
57
|
-
|
|
58
50
|
setShowCalendar(false);
|
|
59
51
|
onPickerClose();
|
|
60
52
|
resetFocusedDayToStartDate();
|
|
61
|
-
|
|
62
|
-
}, [setShowCalendar, onPickerClose, resetFocusedDayToStartDate,
|
|
53
|
+
trackFocusPicker();
|
|
54
|
+
}, [setShowCalendar, onPickerClose, resetFocusedDayToStartDate, trackFocusPicker]);
|
|
63
55
|
const handleToggleCalendar = useCallback(() => {
|
|
64
56
|
const isOpening = !showCalendar;
|
|
65
57
|
if (isOpening) openCalendar();else closeCalendar();
|
|
@@ -67,23 +59,20 @@ const usePopperTriggerLogic = _ref => {
|
|
|
67
59
|
const handleSetTriggerRef = useCallback(newRef => {
|
|
68
60
|
pickerButtonRef.current = newRef;
|
|
69
61
|
setReferenceElement(newRef);
|
|
70
|
-
|
|
62
|
+
if (latestInteractionRegion === 'picker-icon' && currFocusDescriber === 'date-picker-icon') newRef?.focus();
|
|
63
|
+
}, [currFocusDescriber, latestInteractionRegion, pickerButtonRef]);
|
|
71
64
|
const handleMenuWrapperKeyDown = useCallback(e => {
|
|
72
65
|
const {
|
|
73
66
|
key
|
|
74
67
|
} = e;
|
|
75
68
|
|
|
76
69
|
if (key === 'Escape') {
|
|
77
|
-
var _pickerButtonRef$curr3, _pickerButtonRef$curr4;
|
|
78
|
-
|
|
79
70
|
closeCalendar();
|
|
80
|
-
|
|
71
|
+
trackFocusPicker();
|
|
81
72
|
}
|
|
82
|
-
}, [closeCalendar,
|
|
73
|
+
}, [closeCalendar, trackFocusPicker]);
|
|
83
74
|
useOnClickOutside(popperElement, e => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (e.target instanceof Element && !(pickerButtonRef !== null && pickerButtonRef !== void 0 && (_pickerButtonRef$curr5 = pickerButtonRef.current) !== null && _pickerButtonRef$curr5 !== void 0 && (_pickerButtonRef$curr6 = _pickerButtonRef$curr5.contains) !== null && _pickerButtonRef$curr6 !== void 0 && _pickerButtonRef$curr6.call(_pickerButtonRef$curr5, e === null || e === void 0 ? void 0 : e.target))) closeCalendar();
|
|
75
|
+
if (e.target instanceof Element && !pickerButtonRef?.current?.contains?.(e?.target)) closeCalendar();
|
|
87
76
|
});
|
|
88
77
|
return useMemo(() => ({
|
|
89
78
|
closeCalendar,
|