@elliemae/ds-controlled-form 2.0.0-alpha.11 → 2.0.0-alpha.12
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/controlled-checkbox/ControlledCheckbox.js +11 -4
- package/cjs/controlled-checkbox/config/useValidateProps.js +2 -2
- package/cjs/controlled-checkbox/propTypes.js +5 -4
- package/cjs/controlled-checkbox/styles.js +84 -48
- package/cjs/controlled-checkbox/utils/setMultipleRefs.js +4 -0
- package/cjs/controlled-checkbox/utils/styleHelpers.js +13 -7
- package/cjs/controlled-date-range-picker/ControlledDateRangePickerDatatestid.js +1 -18
- package/cjs/controlled-date-range-picker/config/useControlledDateRangePicker.js +19 -3
- package/cjs/controlled-date-range-picker/config/useRangePickerLogic.js +20 -12
- package/cjs/controlled-date-range-picker/parts/ControlledDateRangeCalendar.js +7 -0
- package/cjs/controlled-date-range-picker/parts/ControlledDateRangeContent.js +29 -8
- package/cjs/controlled-date-range-picker/parts/ControlledDateRangeFromDate.js +7 -0
- package/cjs/controlled-date-range-picker/parts/ControlledDateRangeToDate.js +7 -0
- package/cjs/controlled-date-time-picker/ControlledDateTimePickerCTX.js +12 -1
- package/cjs/controlled-date-time-picker/ControlledDateTimePickerDatatestid.js +5 -0
- package/cjs/controlled-date-time-picker/config/useControlledDateTimePicker.js +154 -13
- package/cjs/controlled-date-time-picker/config/useGetDestructuredValues.js +19 -16
- package/cjs/controlled-date-time-picker/parts/ClearButton/ClearButton.js +5 -6
- package/cjs/controlled-date-time-picker/parts/ClearButton/useClearButton.js +15 -3
- package/cjs/controlled-date-time-picker/parts/ControlledDateTimePickerContent.js +35 -14
- package/cjs/controlled-date-time-picker/parts/DateInputs/DDInput.js +15 -11
- package/cjs/controlled-date-time-picker/parts/DateInputs/DateInputs.js +8 -4
- package/cjs/controlled-date-time-picker/parts/DateInputs/MMInput.js +16 -12
- package/cjs/controlled-date-time-picker/parts/DateInputs/YYYYInput.js +15 -11
- package/cjs/controlled-date-time-picker/parts/DateInputs/useDateInputs.js +101 -33
- package/cjs/controlled-date-time-picker/parts/Pickers/Calendar/Calendar.js +4 -3
- package/cjs/controlled-date-time-picker/parts/Pickers/Calendar/CalendarBody.js +10 -7
- package/cjs/controlled-date-time-picker/parts/Pickers/Calendar/CalendarContent.js +4 -3
- package/cjs/controlled-date-time-picker/parts/Pickers/Calendar/CalendarContext.js +1 -0
- package/cjs/controlled-date-time-picker/parts/Pickers/Calendar/CalendarDaysList.js +33 -28
- package/cjs/controlled-date-time-picker/parts/Pickers/Calendar/CalendarHead.js +10 -17
- package/cjs/controlled-date-time-picker/parts/Pickers/Calendar/CalendarIconTrigger.js +10 -11
- package/cjs/controlled-date-time-picker/parts/Pickers/Calendar/CalendarWrapper.js +5 -0
- package/cjs/controlled-date-time-picker/parts/Pickers/Calendar/Day.js +20 -10
- package/cjs/controlled-date-time-picker/parts/Pickers/Calendar/Styleds.js +326 -117
- package/cjs/controlled-date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +8 -43
- package/cjs/controlled-date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +47 -21
- package/cjs/controlled-date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.js +59 -58
- package/cjs/controlled-date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +25 -13
- package/cjs/controlled-date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelContext.js +2 -1
- package/cjs/controlled-date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +10 -11
- package/cjs/controlled-date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelWrapper.js +5 -0
- package/cjs/controlled-date-time-picker/parts/Pickers/CalendarWithTimeWheel/Styleds.js +55 -25
- package/cjs/controlled-date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +18 -7
- package/cjs/controlled-date-time-picker/parts/Pickers/TimeWheel/HoursList.js +7 -0
- package/cjs/controlled-date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +1 -0
- package/cjs/controlled-date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +7 -0
- package/cjs/controlled-date-time-picker/parts/Pickers/TimeWheel/SecondsList.js +11 -7
- package/cjs/controlled-date-time-picker/parts/Pickers/TimeWheel/Styleds.js +201 -80
- package/cjs/controlled-date-time-picker/parts/Pickers/TimeWheel/TimeWheel.js +4 -3
- package/cjs/controlled-date-time-picker/parts/Pickers/TimeWheel/TimeWheelContent.js +4 -3
- package/cjs/controlled-date-time-picker/parts/Pickers/TimeWheel/TimeWheelContext.js +2 -1
- package/cjs/controlled-date-time-picker/parts/Pickers/TimeWheel/TimeWheelIconTrigger.js +10 -11
- package/cjs/controlled-date-time-picker/parts/Pickers/TimeWheel/TimeWheelWrapper.js +5 -0
- package/cjs/controlled-date-time-picker/parts/Pickers/TimeWheel/useConfigTimePickerCTX.js +6 -61
- package/cjs/controlled-date-time-picker/parts/Pickers/TimeWheel/useCurrentDisplayedWheelsLogic.js +8 -5
- package/cjs/controlled-date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.js +64 -141
- package/cjs/controlled-date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +11 -7
- package/cjs/controlled-date-time-picker/parts/Styleds.js +70 -26
- package/cjs/controlled-date-time-picker/parts/TimeInputs/HHInput.js +16 -12
- package/cjs/controlled-date-time-picker/parts/TimeInputs/MeridiemInput.js +15 -11
- package/cjs/controlled-date-time-picker/parts/TimeInputs/MinutesInput.js +15 -11
- package/cjs/controlled-date-time-picker/parts/TimeInputs/TimeInputs.js +8 -5
- package/cjs/controlled-date-time-picker/parts/TimeInputs/useTimeInputs.js +95 -173
- package/cjs/controlled-date-time-picker/propTypes.js +3 -1
- package/cjs/controlled-date-time-picker/utils/constants.js +16 -0
- package/cjs/controlled-date-time-picker/utils/dateHelpers.js +34 -16
- package/cjs/controlled-date-time-picker/utils/dateTimeHelpers.js +5 -0
- package/cjs/controlled-date-time-picker/utils/stringHelpers.js +23 -14
- package/cjs/controlled-date-time-picker/utils/timeHelpers.js +2 -1
- package/cjs/controlled-toggle/ControlledToggle.js +21 -15
- package/cjs/controlled-toggle/styles.js +138 -69
- package/cjs/controlled-toggle/utils/addTooltipOnReadOnly.js +2 -2
- package/cjs/controlled-toggle/utils/styleHelpers.js +15 -9
- package/esm/controlled-checkbox/ControlledCheckbox.js +11 -4
- package/esm/controlled-checkbox/config/useValidateProps.js +2 -2
- package/esm/controlled-checkbox/propTypes.js +5 -4
- package/esm/controlled-checkbox/styles.js +84 -48
- package/esm/controlled-checkbox/utils/setMultipleRefs.js +4 -0
- package/esm/controlled-checkbox/utils/styleHelpers.js +13 -7
- package/esm/controlled-date-range-picker/ControlledDateRangePickerDatatestid.js +1 -18
- package/esm/controlled-date-range-picker/config/useControlledDateRangePicker.js +15 -3
- package/esm/controlled-date-range-picker/config/useRangePickerLogic.js +20 -12
- package/esm/controlled-date-range-picker/parts/ControlledDateRangeCalendar.js +7 -0
- package/esm/controlled-date-range-picker/parts/ControlledDateRangeContent.js +28 -8
- package/esm/controlled-date-range-picker/parts/ControlledDateRangeFromDate.js +7 -0
- package/esm/controlled-date-range-picker/parts/ControlledDateRangeToDate.js +7 -0
- package/esm/controlled-date-time-picker/ControlledDateTimePickerCTX.js +12 -1
- package/esm/controlled-date-time-picker/ControlledDateTimePickerDatatestid.js +5 -0
- package/esm/controlled-date-time-picker/config/useControlledDateTimePicker.js +156 -15
- package/esm/controlled-date-time-picker/config/useGetDestructuredValues.js +19 -16
- package/esm/controlled-date-time-picker/parts/ClearButton/ClearButton.js +1 -1
- package/esm/controlled-date-time-picker/parts/ClearButton/useClearButton.js +15 -3
- package/esm/controlled-date-time-picker/parts/ControlledDateTimePickerContent.js +34 -14
- package/esm/controlled-date-time-picker/parts/DateInputs/DDInput.js +15 -11
- package/esm/controlled-date-time-picker/parts/DateInputs/DateInputs.js +8 -4
- package/esm/controlled-date-time-picker/parts/DateInputs/MMInput.js +16 -12
- package/esm/controlled-date-time-picker/parts/DateInputs/YYYYInput.js +15 -11
- package/esm/controlled-date-time-picker/parts/DateInputs/useDateInputs.js +101 -33
- package/esm/controlled-date-time-picker/parts/Pickers/Calendar/Calendar.js +4 -3
- package/esm/controlled-date-time-picker/parts/Pickers/Calendar/CalendarBody.js +10 -7
- package/esm/controlled-date-time-picker/parts/Pickers/Calendar/CalendarContent.js +4 -3
- package/esm/controlled-date-time-picker/parts/Pickers/Calendar/CalendarContext.js +1 -0
- package/esm/controlled-date-time-picker/parts/Pickers/Calendar/CalendarDaysList.js +33 -28
- package/esm/controlled-date-time-picker/parts/Pickers/Calendar/CalendarHead.js +1 -4
- package/esm/controlled-date-time-picker/parts/Pickers/Calendar/CalendarIconTrigger.js +7 -7
- package/esm/controlled-date-time-picker/parts/Pickers/Calendar/CalendarWrapper.js +5 -0
- package/esm/controlled-date-time-picker/parts/Pickers/Calendar/Day.js +20 -10
- package/esm/controlled-date-time-picker/parts/Pickers/Calendar/Styleds.js +321 -113
- package/esm/controlled-date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +8 -43
- package/esm/controlled-date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +48 -22
- package/esm/controlled-date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.js +60 -59
- package/esm/controlled-date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +26 -14
- package/esm/controlled-date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelContext.js +2 -1
- package/esm/controlled-date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +7 -7
- package/esm/controlled-date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelWrapper.js +5 -0
- package/esm/controlled-date-time-picker/parts/Pickers/CalendarWithTimeWheel/Styleds.js +53 -23
- package/esm/controlled-date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +18 -7
- package/esm/controlled-date-time-picker/parts/Pickers/TimeWheel/HoursList.js +7 -0
- package/esm/controlled-date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +1 -0
- package/esm/controlled-date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +7 -0
- package/esm/controlled-date-time-picker/parts/Pickers/TimeWheel/SecondsList.js +9 -3
- package/esm/controlled-date-time-picker/parts/Pickers/TimeWheel/Styleds.js +196 -76
- package/esm/controlled-date-time-picker/parts/Pickers/TimeWheel/TimeWheel.js +4 -3
- package/esm/controlled-date-time-picker/parts/Pickers/TimeWheel/TimeWheelContent.js +4 -3
- package/esm/controlled-date-time-picker/parts/Pickers/TimeWheel/TimeWheelContext.js +2 -1
- package/esm/controlled-date-time-picker/parts/Pickers/TimeWheel/TimeWheelIconTrigger.js +7 -7
- package/esm/controlled-date-time-picker/parts/Pickers/TimeWheel/TimeWheelWrapper.js +5 -0
- package/esm/controlled-date-time-picker/parts/Pickers/TimeWheel/useConfigTimePickerCTX.js +6 -61
- package/esm/controlled-date-time-picker/parts/Pickers/TimeWheel/useCurrentDisplayedWheelsLogic.js +8 -5
- package/esm/controlled-date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.js +65 -142
- package/esm/controlled-date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +12 -8
- package/esm/controlled-date-time-picker/parts/Styleds.js +68 -24
- package/esm/controlled-date-time-picker/parts/TimeInputs/HHInput.js +16 -12
- package/esm/controlled-date-time-picker/parts/TimeInputs/MeridiemInput.js +15 -11
- package/esm/controlled-date-time-picker/parts/TimeInputs/MinutesInput.js +15 -11
- package/esm/controlled-date-time-picker/parts/TimeInputs/TimeInputs.js +8 -5
- package/esm/controlled-date-time-picker/parts/TimeInputs/useTimeInputs.js +96 -170
- package/esm/controlled-date-time-picker/propTypes.js +3 -1
- package/esm/controlled-date-time-picker/utils/constants.js +10 -1
- package/esm/controlled-date-time-picker/utils/dateHelpers.js +34 -17
- package/esm/controlled-date-time-picker/utils/dateTimeHelpers.js +5 -0
- package/esm/controlled-date-time-picker/utils/stringHelpers.js +23 -14
- package/esm/controlled-date-time-picker/utils/timeHelpers.js +2 -1
- package/esm/controlled-toggle/ControlledToggle.js +21 -15
- package/esm/controlled-toggle/styles.js +138 -69
- package/esm/controlled-toggle/utils/addTooltipOnReadOnly.js +1 -1
- package/esm/controlled-toggle/utils/styleHelpers.js +15 -9
- package/package.json +21 -12
- package/types/controlled-checkbox/ControlledCheckbox.d.ts +60 -9
- package/types/controlled-checkbox/config/useValidateProps.d.ts +1 -1
- package/types/controlled-checkbox/index.d.d.ts +1 -0
- package/types/controlled-checkbox/propTypes.d.ts +55 -8
- package/types/controlled-checkbox/styles.d.ts +4 -4
- package/types/controlled-checkbox/tests/DSControlledCheckbox.keyboard.test.d.ts +1 -0
- package/types/controlled-checkbox/tests/DSControlledCheckbox.test.d.ts +1 -0
- package/types/controlled-checkbox/tests/DSControllledCheckbox.events.test.d.ts +1 -0
- package/types/controlled-date-range-picker/ControlledDateRangePicker.d.ts +12 -2
- package/types/controlled-date-range-picker/ControlledDateRangePickerDatatestid.d.ts +1 -18
- package/types/controlled-date-range-picker/propTypes.d.ts +7 -1
- package/types/controlled-date-range-picker/tests/date-range-picker.auto-advance.test.d.ts +1 -0
- package/types/controlled-date-range-picker/tests/date-range-picker.classes.test.d.ts +1 -0
- package/types/controlled-date-range-picker/tests/date-range-picker.clear-button.test.d.ts +1 -0
- package/types/controlled-date-range-picker/tests/date-range-picker.keyboard-focus.test.d.ts +1 -0
- package/types/controlled-date-range-picker/tests/date-range-picker.manual-delete-values.test.d.ts +1 -0
- package/types/controlled-date-range-picker/tests/date-range-picker.types-dom.test.d.ts +1 -0
- package/types/controlled-date-time-picker/ControlledDateTimePicker.d.ts +84 -21
- package/types/controlled-date-time-picker/ControlledDateTimePickerDatatestid.d.ts +3 -0
- package/types/controlled-date-time-picker/parts/DateInputs/DDInput.d.ts +2 -1
- package/types/controlled-date-time-picker/parts/DateInputs/MMInput.d.ts +2 -1
- package/types/controlled-date-time-picker/parts/DateInputs/YYYYInput.d.ts +2 -1
- package/types/controlled-date-time-picker/parts/Pickers/Calendar/CalendarContext.d.ts +2 -1
- package/types/controlled-date-time-picker/parts/Pickers/Calendar/Styleds.d.ts +16 -67
- package/types/controlled-date-time-picker/parts/Pickers/Calendar/useFocusLogic.d.ts +1 -3
- package/types/controlled-date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.d.ts +2 -17
- package/types/controlled-date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.d.ts +3 -6
- package/types/controlled-date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelContext.d.ts +1 -0
- package/types/controlled-date-time-picker/parts/Pickers/CalendarWithTimeWheel/Styleds.d.ts +6 -23
- package/types/controlled-date-time-picker/parts/Pickers/TimeWheel/Styleds.d.ts +16 -67
- package/types/controlled-date-time-picker/parts/Pickers/TimeWheel/TimeWheelContext.d.ts +1 -0
- package/types/controlled-date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.d.ts +3 -12
- package/types/controlled-date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.d.ts +1 -10
- package/types/controlled-date-time-picker/parts/Styleds.d.ts +12 -29
- package/types/controlled-date-time-picker/parts/TimeInputs/HHInput.d.ts +2 -1
- package/types/controlled-date-time-picker/parts/TimeInputs/MeridiemInput.d.ts +2 -1
- package/types/controlled-date-time-picker/parts/TimeInputs/MinutesInput.d.ts +2 -1
- package/types/controlled-date-time-picker/propTypes.d.ts +79 -20
- package/types/controlled-date-time-picker/tests/date-time-picker.keyboard.data-entry-typing.test.d.ts +1 -0
- package/types/controlled-date-time-picker/tests/date-time-picker.keyboard.fill-with-now.test.d.ts +1 -0
- package/types/controlled-date-time-picker/tests/date-time-picker.keyboard.regressive-backspace.test.d.ts +1 -0
- package/types/controlled-date-time-picker/tests/date-time-picker.keyboard.shortcut-clear.test.d.ts +1 -0
- package/types/controlled-date-time-picker/utils/constants.d.ts +9 -0
- package/types/controlled-date-time-picker/utils/dateHelpers.d.ts +1 -0
- package/types/controlled-toggle/ControlledToggle.d.ts +78 -13
- package/types/controlled-toggle/propTypes.d.ts +73 -12
- package/types/controlled-toggle/styles.d.ts +7 -7
- package/cjs/controlled-date-time-picker/parts/TimeInputs/SSInput.js +0 -53
- package/esm/controlled-date-time-picker/parts/TimeInputs/SSInput.js +0 -45
- package/types/controlled-date-time-picker/parts/TimeInputs/SSInput.d.ts +0 -13
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
1
|
import { useContext, useCallback, useMemo } from 'react';
|
|
3
2
|
import { ControlledDateTimePickerContext } from '../../ControlledDateTimePickerCTX.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { homeEndArrowUpDownSemiKeys, homeEndArrowUpDownSpaceKeys, homeEndArrowUpDownKeys } from '../../utils/constants.js';
|
|
4
|
+
import { prependStringWithPlaceHolders } from '../../utils/stringHelpers.js';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
|
+
/* eslint-disable complexity */
|
|
10
7
|
const useTimeInputs = () => {
|
|
11
8
|
const {
|
|
12
9
|
props: {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// onSecondsChange: appOnSecondsChange,
|
|
16
|
-
onMeridiemChange: appOnMeridiemChange,
|
|
17
|
-
getIsDisabledTime,
|
|
18
|
-
minutesInterval
|
|
10
|
+
minutesInterval,
|
|
11
|
+
disabled
|
|
19
12
|
},
|
|
13
|
+
lastSegmentRef,
|
|
20
14
|
hours,
|
|
21
15
|
minutes,
|
|
22
16
|
meridiem,
|
|
@@ -24,15 +18,18 @@ const useTimeInputs = () => {
|
|
|
24
18
|
withAnyRightController,
|
|
25
19
|
withAnyPicker,
|
|
26
20
|
withClearBtn,
|
|
21
|
+
isWithDateInputs,
|
|
27
22
|
hourInputRef,
|
|
28
23
|
minutesInputRef,
|
|
29
|
-
// secondsInputRef,
|
|
30
24
|
meridiemInputRef,
|
|
25
|
+
yearInputRef,
|
|
31
26
|
clearButtonRef,
|
|
32
27
|
pickerButtonRef,
|
|
33
28
|
monthInputRef,
|
|
34
29
|
autoFocusHourInput,
|
|
35
|
-
|
|
30
|
+
handleChangeHours,
|
|
31
|
+
handleChangeMinutes,
|
|
32
|
+
handleChangeMeridiem,
|
|
36
33
|
setLatestInteractionRegion
|
|
37
34
|
} = useContext(ControlledDateTimePickerContext);
|
|
38
35
|
const setLatestInteractionRegionTimeInputs = useCallback(() => {
|
|
@@ -48,23 +45,6 @@ const useTimeInputs = () => {
|
|
|
48
45
|
|
|
49
46
|
if (withAnyPicker) pickerButtonRef === null || pickerButtonRef === void 0 ? void 0 : (_pickerButtonRef$curr = pickerButtonRef.current) === null || _pickerButtonRef$curr === void 0 ? void 0 : (_pickerButtonRef$curr2 = _pickerButtonRef$curr.focus) === null || _pickerButtonRef$curr2 === void 0 ? void 0 : _pickerButtonRef$curr2.call(_pickerButtonRef$curr);else if (withClearBtn) clearButtonRef === null || clearButtonRef === void 0 ? void 0 : (_clearButtonRef$curre = clearButtonRef.current) === null || _clearButtonRef$curre === void 0 ? void 0 : (_clearButtonRef$curre2 = _clearButtonRef$curre.focus) === null || _clearButtonRef$curre2 === void 0 ? void 0 : _clearButtonRef$curre2.call(_clearButtonRef$curre);else 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);
|
|
50
47
|
}, [withAnyPicker, pickerButtonRef, withClearBtn, clearButtonRef, meridiemInputRef]);
|
|
51
|
-
const handleChangeHours = useCallback((newHours, e, metaInfo = {
|
|
52
|
-
isAutomaticFillTrigger: false
|
|
53
|
-
}) => {
|
|
54
|
-
const newTimeString = getFormattedTimeString({
|
|
55
|
-
hours: newHours,
|
|
56
|
-
minutes,
|
|
57
|
-
// seconds,
|
|
58
|
-
meridiem
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const finalMetaInfo = _objectSpread(_objectSpread(_objectSpread({}, metaInfo), getValidationTimeStringMetaInfo(newTimeString, getIsDisabledTime)), {}, {
|
|
62
|
-
newTimeString
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
appOnHourChange(newHours, e, finalMetaInfo);
|
|
66
|
-
handleChangeComposedTimeString(newTimeString, finalMetaInfo);
|
|
67
|
-
}, [minutes, meridiem, getIsDisabledTime, appOnHourChange, handleChangeComposedTimeString]);
|
|
68
48
|
const onHoursFocus = useCallback(() => {
|
|
69
49
|
setLatestInteractionRegionTimeInputs();
|
|
70
50
|
}, [setLatestInteractionRegionTimeInputs]);
|
|
@@ -79,25 +59,46 @@ const useTimeInputs = () => {
|
|
|
79
59
|
if (newHours.length === 2) minutesInputRef === null || minutesInputRef === void 0 ? void 0 : (_minutesInputRef$curr = minutesInputRef.current) === null || _minutesInputRef$curr === void 0 ? void 0 : (_minutesInputRef$curr2 = _minutesInputRef$curr.focus) === null || _minutesInputRef$curr2 === void 0 ? void 0 : _minutesInputRef$curr2.call(_minutesInputRef$curr);
|
|
80
60
|
}, [minutesInputRef, handleChangeHours]);
|
|
81
61
|
const onHoursKeyDown = useCallback(e => {
|
|
62
|
+
var _lastSegmentRef$curre, _lastSegmentRef$curre2;
|
|
63
|
+
|
|
82
64
|
const {
|
|
83
|
-
key
|
|
65
|
+
key,
|
|
66
|
+
ctrlKey,
|
|
67
|
+
metaKey
|
|
84
68
|
} = e;
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
if (
|
|
88
|
-
if (stopPropagationKeys.includes(key)) e.stopPropagation();
|
|
69
|
+
const hoursStringConvertedToInteger = Number.parseInt(hours, 10);
|
|
70
|
+
if (homeEndArrowUpDownSemiKeys.includes(key)) e.preventDefault();
|
|
71
|
+
if (homeEndArrowUpDownSemiKeys.includes(key)) e.stopPropagation();
|
|
89
72
|
if (key === 'Home') onHomeKeyDown();
|
|
90
73
|
if (key === 'End') onEndKeyDown();
|
|
91
74
|
|
|
92
75
|
if (key === 'ArrowUp' || key === 'ArrowDown') {
|
|
93
|
-
const hoursStringConvertedToInteger = Number.parseInt(hours, 10);
|
|
94
76
|
const hoursInteger = Number.isNaN(hoursStringConvertedToInteger) ? 0 : hoursStringConvertedToInteger;
|
|
95
77
|
let newHours;
|
|
96
78
|
if (key === 'ArrowUp') newHours = hoursInteger + 1 <= 12 ? hoursInteger + 1 : hoursInteger;else newHours = hoursInteger - 1 > 1 ? hoursInteger - 1 : 1;
|
|
97
79
|
newHours = prependStringWithPlaceHolders("".concat(newHours), 2);
|
|
98
80
|
handleChangeHours(newHours, e);
|
|
99
81
|
}
|
|
100
|
-
|
|
82
|
+
|
|
83
|
+
if (!Number.isNaN(hoursStringConvertedToInteger) && key === ':') {
|
|
84
|
+
var _minutesInputRef$curr3, _minutesInputRef$curr4;
|
|
85
|
+
|
|
86
|
+
const newHours = prependStringWithPlaceHolders("".concat(hoursStringConvertedToInteger), 2);
|
|
87
|
+
handleChangeHours(newHours, e); // auto-advance functionality:
|
|
88
|
+
|
|
89
|
+
if (newHours.length === 2) minutesInputRef === null || minutesInputRef === void 0 ? void 0 : (_minutesInputRef$curr3 = minutesInputRef.current) === null || _minutesInputRef$curr3 === void 0 ? void 0 : (_minutesInputRef$curr4 = _minutesInputRef$curr3.focus) === null || _minutesInputRef$curr4 === void 0 ? void 0 : _minutesInputRef$curr4.call(_minutesInputRef$curr3);
|
|
90
|
+
} // regressive backspace functionality
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
if (key === 'Backspace' && hours.length === 0 && isWithDateInputs) {
|
|
94
|
+
var _yearInputRef$current, _yearInputRef$current2;
|
|
95
|
+
|
|
96
|
+
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);
|
|
97
|
+
} // focus last fragment on fill with now
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
if ((ctrlKey || metaKey) && key === ';') lastSegmentRef === null || lastSegmentRef === void 0 ? void 0 : (_lastSegmentRef$curre = lastSegmentRef.current) === null || _lastSegmentRef$curre === void 0 ? void 0 : (_lastSegmentRef$curre2 = _lastSegmentRef$curre.focus) === null || _lastSegmentRef$curre2 === void 0 ? void 0 : _lastSegmentRef$curre2.call(_lastSegmentRef$curre);
|
|
101
|
+
}, [hours, onHomeKeyDown, onEndKeyDown, isWithDateInputs, lastSegmentRef, handleChangeHours, minutesInputRef, yearInputRef]);
|
|
101
102
|
const onHoursBlur = useCallback(e => {
|
|
102
103
|
var _e$target2;
|
|
103
104
|
|
|
@@ -108,23 +109,6 @@ const useTimeInputs = () => {
|
|
|
108
109
|
isAutomaticFillTrigger: true
|
|
109
110
|
});
|
|
110
111
|
}, [handleChangeHours]);
|
|
111
|
-
const handleChangeMinutes = useCallback((newMinutes, e, metaInfo = {
|
|
112
|
-
isAutomaticFillTrigger: false
|
|
113
|
-
}) => {
|
|
114
|
-
const newTimeString = getFormattedTimeString({
|
|
115
|
-
hours,
|
|
116
|
-
minutes: newMinutes,
|
|
117
|
-
// seconds,
|
|
118
|
-
meridiem
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
const finalMetaInfo = _objectSpread(_objectSpread(_objectSpread({}, metaInfo), getValidationTimeStringMetaInfo(newTimeString, getIsDisabledTime)), {}, {
|
|
122
|
-
newTimeString
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
appOnMinuteChange(newMinutes, e, finalMetaInfo);
|
|
126
|
-
handleChangeComposedTimeString(newTimeString, finalMetaInfo);
|
|
127
|
-
}, [hours, meridiem, getIsDisabledTime, appOnMinuteChange, handleChangeComposedTimeString]);
|
|
128
112
|
const onMinutesFocus = useCallback(() => {
|
|
129
113
|
setLatestInteractionRegionTimeInputs();
|
|
130
114
|
}, [setLatestInteractionRegionTimeInputs]);
|
|
@@ -140,25 +124,47 @@ const useTimeInputs = () => {
|
|
|
140
124
|
if (newMinutes.length === 2) meridiemInputRef === null || meridiemInputRef === void 0 ? void 0 : (_meridiemInputRef$cur3 = meridiemInputRef.current) === null || _meridiemInputRef$cur3 === void 0 ? void 0 : (_meridiemInputRef$cur4 = _meridiemInputRef$cur3.focus) === null || _meridiemInputRef$cur4 === void 0 ? void 0 : _meridiemInputRef$cur4.call(_meridiemInputRef$cur3);
|
|
141
125
|
}, [meridiemInputRef, handleChangeMinutes]);
|
|
142
126
|
const onMinutesKeyDown = useCallback(e => {
|
|
127
|
+
var _lastSegmentRef$curre3, _lastSegmentRef$curre4;
|
|
128
|
+
|
|
143
129
|
const {
|
|
144
|
-
key
|
|
130
|
+
key,
|
|
131
|
+
ctrlKey,
|
|
132
|
+
metaKey
|
|
145
133
|
} = e;
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
if (
|
|
149
|
-
if (stopPropagationKeys.includes(key)) e.stopPropagation();
|
|
134
|
+
const minutesStringConvertedToInteger = Number.parseInt(minutes, 10);
|
|
135
|
+
if (homeEndArrowUpDownSpaceKeys.includes(key)) e.preventDefault();
|
|
136
|
+
if (homeEndArrowUpDownSpaceKeys.includes(key)) e.stopPropagation();
|
|
150
137
|
if (key === 'Home') onHomeKeyDown();
|
|
151
138
|
if (key === 'End') onEndKeyDown();
|
|
152
139
|
|
|
153
140
|
if (key === 'ArrowUp' || key === 'ArrowDown') {
|
|
154
|
-
const minutesStringConvertedToInteger = Number.parseInt(minutes, 10);
|
|
155
141
|
const minutesInteger = Number.isNaN(minutesStringConvertedToInteger) ? 0 : minutesStringConvertedToInteger;
|
|
156
142
|
let newMinutes;
|
|
157
143
|
if (key === 'ArrowUp') newMinutes = minutesInteger + minutesInterval <= 59 ? minutesInteger + minutesInterval : minutesInteger;else newMinutes = minutesInteger - minutesInterval > 0 ? minutesInteger - minutesInterval : 0;
|
|
158
144
|
newMinutes = prependStringWithPlaceHolders("".concat(newMinutes), 2);
|
|
159
145
|
handleChangeMinutes(newMinutes, e);
|
|
160
146
|
}
|
|
161
|
-
|
|
147
|
+
|
|
148
|
+
if (!Number.isNaN(minutesStringConvertedToInteger) && key === ' ') {
|
|
149
|
+
var _meridiemInputRef$cur5, _meridiemInputRef$cur6;
|
|
150
|
+
|
|
151
|
+
const newMinutes = prependStringWithPlaceHolders("".concat(minutesStringConvertedToInteger), 2);
|
|
152
|
+
handleChangeMinutes(newMinutes, e); // auto-advance functionality:
|
|
153
|
+
// if (newMinutes.length === 2) secondsInputRef?.current?.focus?.();
|
|
154
|
+
|
|
155
|
+
if (newMinutes.length === 2) meridiemInputRef === null || meridiemInputRef === void 0 ? void 0 : (_meridiemInputRef$cur5 = meridiemInputRef.current) === null || _meridiemInputRef$cur5 === void 0 ? void 0 : (_meridiemInputRef$cur6 = _meridiemInputRef$cur5.focus) === null || _meridiemInputRef$cur6 === void 0 ? void 0 : _meridiemInputRef$cur6.call(_meridiemInputRef$cur5);
|
|
156
|
+
} // regressive backspace functionality
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
if (key === 'Backspace' && (minutes === null || minutes === void 0 ? void 0 : minutes.length) === 0) {
|
|
160
|
+
var _hourInputRef$current3, _hourInputRef$current4;
|
|
161
|
+
|
|
162
|
+
hourInputRef === null || hourInputRef === void 0 ? void 0 : (_hourInputRef$current3 = hourInputRef.current) === null || _hourInputRef$current3 === void 0 ? void 0 : (_hourInputRef$current4 = _hourInputRef$current3.focus) === null || _hourInputRef$current4 === void 0 ? void 0 : _hourInputRef$current4.call(_hourInputRef$current3);
|
|
163
|
+
} // focus last fragment on fill with now
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
if ((ctrlKey || metaKey) && key === ';') lastSegmentRef === null || lastSegmentRef === void 0 ? void 0 : (_lastSegmentRef$curre3 = lastSegmentRef.current) === null || _lastSegmentRef$curre3 === void 0 ? void 0 : (_lastSegmentRef$curre4 = _lastSegmentRef$curre3.focus) === null || _lastSegmentRef$curre4 === void 0 ? void 0 : _lastSegmentRef$curre4.call(_lastSegmentRef$curre3);
|
|
167
|
+
}, [minutes, onHomeKeyDown, onEndKeyDown, lastSegmentRef, minutesInterval, handleChangeMinutes, meridiemInputRef, hourInputRef]);
|
|
162
168
|
const onMinutesBlur = useCallback(e => {
|
|
163
169
|
var _e$target4;
|
|
164
170
|
|
|
@@ -166,119 +172,50 @@ const useTimeInputs = () => {
|
|
|
166
172
|
if (newMinutes.length > 0 && newMinutes.length < 2) handleChangeMinutes(prependStringWithPlaceHolders(newMinutes, 2), e, {
|
|
167
173
|
isAutomaticFillTrigger: true
|
|
168
174
|
});
|
|
169
|
-
}, [handleChangeMinutes]);
|
|
170
|
-
// (newSeconds, e, metaInfo = { isAutomaticFillTrigger: false }) => {
|
|
171
|
-
// const newTimeString = getFormattedTimeString({
|
|
172
|
-
// hours,
|
|
173
|
-
// minutes,
|
|
174
|
-
// seconds: newSeconds,
|
|
175
|
-
// meridiem,
|
|
176
|
-
// });
|
|
177
|
-
// appOnSecondsChange(newSeconds, e, metaInfo);
|
|
178
|
-
// handleChangeComposedTimeString(newTimeString, metaInfo);
|
|
179
|
-
// },
|
|
180
|
-
// [
|
|
181
|
-
// hours,
|
|
182
|
-
// minutes,
|
|
183
|
-
// meridiem,
|
|
184
|
-
// appOnSecondsChange,
|
|
185
|
-
// handleChangeComposedTimeString,
|
|
186
|
-
// ],
|
|
187
|
-
// );
|
|
188
|
-
// const onSecondsFocus: onFocusFuncT = useCallback(
|
|
189
|
-
// (e) => {
|
|
190
|
-
// setLatestInteractionRegionTimeInputs();
|
|
191
|
-
// },
|
|
192
|
-
// [setLatestInteractionRegionTimeInputs],
|
|
193
|
-
// );
|
|
194
|
-
// const onSecondsChange: onChangeFuncT = useCallback(
|
|
195
|
-
// (e) => {
|
|
196
|
-
// let newSeconds = e?.target?.value;
|
|
197
|
-
// // converts seconds 7~9 to 07~09
|
|
198
|
-
// if (Number.parseInt(newSeconds, 10) > 6)
|
|
199
|
-
// newSeconds = prependStringWithPlaceHolders(newSeconds, 2);
|
|
200
|
-
// handleChangeSeconds(newSeconds, e);
|
|
201
|
-
// // auto-advance functionality:
|
|
202
|
-
// if (newSeconds.length === 2) meridiemInputRef?.current?.focus?.();
|
|
203
|
-
// },
|
|
204
|
-
// [meridiemInputRef, handleChangeSeconds],
|
|
205
|
-
// );
|
|
206
|
-
// const onSecondsKeyDown: onKeyDownT = useCallback(
|
|
207
|
-
// (e) => {
|
|
208
|
-
// const { key } = e;
|
|
209
|
-
// const preventDefaultKeys = ['Home', 'End', 'ArrowUp', 'ArrowDown'];
|
|
210
|
-
// if (preventDefaultKeys.includes(key)) e.preventDefault();
|
|
211
|
-
// if (key === 'Home') onHomeKeyDown();
|
|
212
|
-
// if (key === 'End') onEndKeyDown();
|
|
213
|
-
// if (key === 'ArrowUp' || key === 'ArrowDown') {
|
|
214
|
-
// const secondsStringConvertedToInteger = Number.parseInt(seconds, 10);
|
|
215
|
-
// const secondsInteger = Number.isNaN(secondsStringConvertedToInteger) ? 0 : secondsStringConvertedToInteger;
|
|
216
|
-
// let newSeconds;
|
|
217
|
-
// if (key === 'ArrowUp') newSeconds = secondsInteger + 1 <= 59 ? secondsInteger + 1 : secondsInteger;
|
|
218
|
-
// else newSeconds = secondsInteger - 1 > 0 ? secondsInteger - 1 : 1;
|
|
219
|
-
// newSeconds = prependStringWithPlaceHolders(`${newSeconds}`, 2);
|
|
220
|
-
// handleChangeSeconds(newSeconds, e);
|
|
221
|
-
// }
|
|
222
|
-
// },
|
|
223
|
-
// [onHomeKeyDown, onEndKeyDown,handleChangeSeconds,newSeconds],
|
|
224
|
-
// );
|
|
225
|
-
// const onSecondsBlur: onBlurFuncT = useCallback(
|
|
226
|
-
// (e) => {
|
|
227
|
-
// const newSeconds = e?.target?.value;
|
|
228
|
-
// if (newSeconds.length > 0 && newSeconds.length < 2)
|
|
229
|
-
// handleChangeSeconds(prependStringWithPlaceHolders(newSeconds, 2), e, {
|
|
230
|
-
// isAutomaticFillTrigger: true,
|
|
231
|
-
// });
|
|
232
|
-
// },
|
|
233
|
-
// [handleChangeSeconds],
|
|
234
|
-
// );
|
|
235
|
-
|
|
236
|
-
const handleChangeMeridiem = useCallback((newMeridiem, e, metaInfo = {
|
|
237
|
-
isAutomaticFillTrigger: false
|
|
238
|
-
}) => {
|
|
239
|
-
const newTimeString = getFormattedTimeString({
|
|
240
|
-
hours,
|
|
241
|
-
minutes,
|
|
242
|
-
// seconds,
|
|
243
|
-
meridiem: newMeridiem
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
const finalMetaInfo = _objectSpread(_objectSpread(_objectSpread({}, metaInfo), getValidationTimeStringMetaInfo(newTimeString, getIsDisabledTime)), {}, {
|
|
247
|
-
newTimeString
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
appOnMeridiemChange(newMeridiem, e, finalMetaInfo);
|
|
251
|
-
handleChangeComposedTimeString(newTimeString, finalMetaInfo);
|
|
252
|
-
}, [hours, minutes, getIsDisabledTime, appOnMeridiemChange, handleChangeComposedTimeString]);
|
|
175
|
+
}, [handleChangeMinutes]);
|
|
253
176
|
const onMeridiemFocus = useCallback(() => {
|
|
254
177
|
setLatestInteractionRegionTimeInputs();
|
|
255
178
|
}, [setLatestInteractionRegionTimeInputs]);
|
|
256
179
|
const onMeridiemChange = useCallback(e => {
|
|
257
180
|
var _e$target5, _e$target5$value, _e$target5$value$toUp;
|
|
258
181
|
|
|
259
|
-
let newMeridiem = e === null || e === void 0 ? void 0 : (_e$target5 = e.target) === null || _e$target5 === void 0 ? void 0 : (_e$target5$value = _e$target5.value) === null || _e$target5$value === void 0 ? void 0 : (_e$target5$value$toUp = _e$target5$value.toUpperCase) === null || _e$target5$value$toUp === void 0 ? void 0 : _e$target5$value$toUp.call(_e$target5$value);
|
|
260
|
-
if
|
|
182
|
+
let newMeridiem = e === null || e === void 0 ? void 0 : (_e$target5 = e.target) === null || _e$target5 === void 0 ? void 0 : (_e$target5$value = _e$target5.value) === null || _e$target5$value === void 0 ? void 0 : (_e$target5$value$toUp = _e$target5$value.toUpperCase) === null || _e$target5$value$toUp === void 0 ? void 0 : _e$target5$value$toUp.call(_e$target5$value); // if new value is length 1,
|
|
183
|
+
// if previous value was empty, auto-complete
|
|
184
|
+
// if previous value was not empty, set to empty (regressive backspace)
|
|
185
|
+
|
|
186
|
+
if (newMeridiem.length === 1) if (meridiem === '') newMeridiem = "".concat(newMeridiem, "M");else newMeridiem = '';
|
|
261
187
|
handleChangeMeridiem(newMeridiem, e); // auto-advance functionality:
|
|
262
188
|
|
|
263
189
|
if (newMeridiem.length === 2 && withAnyRightController) {
|
|
264
190
|
var _clearButtonRef$curre3, _clearButtonRef$curre4, _pickerButtonRef$curr3, _pickerButtonRef$curr4;
|
|
265
191
|
|
|
266
|
-
if (withClearBtn) (_clearButtonRef$curre3 = clearButtonRef.current) === null || _clearButtonRef$curre3 === void 0 ? void 0 : (_clearButtonRef$curre4 = _clearButtonRef$curre3.focus) === null || _clearButtonRef$curre4 === void 0 ? void 0 : _clearButtonRef$curre4.call(_clearButtonRef$curre3);else if (withAnyPicker) pickerButtonRef === null || pickerButtonRef === void 0 ? void 0 : (_pickerButtonRef$curr3 = pickerButtonRef.current) === null || _pickerButtonRef$curr3 === void 0 ? void 0 : (_pickerButtonRef$curr4 = _pickerButtonRef$curr3.focus) === null || _pickerButtonRef$curr4 === void 0 ? void 0 : _pickerButtonRef$curr4.call(_pickerButtonRef$curr3);
|
|
192
|
+
if (withClearBtn) (_clearButtonRef$curre3 = clearButtonRef.current) === null || _clearButtonRef$curre3 === void 0 ? void 0 : (_clearButtonRef$curre4 = _clearButtonRef$curre3.focus) === null || _clearButtonRef$curre4 === void 0 ? void 0 : _clearButtonRef$curre4.call(_clearButtonRef$curre3);else if (withAnyPicker) pickerButtonRef === null || pickerButtonRef === void 0 ? void 0 : (_pickerButtonRef$curr3 = pickerButtonRef.current) === null || _pickerButtonRef$curr3 === void 0 ? void 0 : (_pickerButtonRef$curr4 = _pickerButtonRef$curr3.focus) === null || _pickerButtonRef$curr4 === void 0 ? void 0 : _pickerButtonRef$curr4.call(_pickerButtonRef$curr3);
|
|
267
193
|
}
|
|
268
|
-
}, [handleChangeMeridiem, withAnyRightController,
|
|
194
|
+
}, [meridiem, handleChangeMeridiem, withAnyRightController, withClearBtn, clearButtonRef, withAnyPicker, pickerButtonRef]);
|
|
269
195
|
const onMeridiemKeyDown = useCallback(e => {
|
|
196
|
+
var _lastSegmentRef$curre5, _lastSegmentRef$curre6;
|
|
197
|
+
|
|
270
198
|
const {
|
|
271
|
-
key
|
|
199
|
+
key,
|
|
200
|
+
ctrlKey,
|
|
201
|
+
metaKey
|
|
272
202
|
} = e;
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
if (preventDefaultKeys.includes(key)) e.preventDefault();
|
|
276
|
-
if (stopPropagationKeys.includes(key)) e.stopPropagation();
|
|
203
|
+
if (homeEndArrowUpDownKeys.includes(key)) e.preventDefault();
|
|
204
|
+
if (homeEndArrowUpDownKeys.includes(key)) e.stopPropagation();
|
|
277
205
|
if (key === 'Home') onHomeKeyDown();
|
|
278
206
|
if (key === 'End') onEndKeyDown();
|
|
279
207
|
if (key === 'ArrowUp' && meridiem !== 'AM') handleChangeMeridiem('AM', e);
|
|
280
|
-
if (key === 'ArrowDown' && meridiem !== 'PM') handleChangeMeridiem('PM', e);
|
|
281
|
-
|
|
208
|
+
if (key === 'ArrowDown' && meridiem !== 'PM') handleChangeMeridiem('PM', e); // regressive backspace functionality
|
|
209
|
+
|
|
210
|
+
if (key === 'Backspace') {
|
|
211
|
+
var _minutesInputRef$curr5, _minutesInputRef$curr6;
|
|
212
|
+
|
|
213
|
+
if ((meridiem === null || meridiem === void 0 ? void 0 : meridiem.length) === 2) handleChangeMeridiem('', e);else minutesInputRef === null || minutesInputRef === void 0 ? void 0 : (_minutesInputRef$curr5 = minutesInputRef.current) === null || _minutesInputRef$curr5 === void 0 ? void 0 : (_minutesInputRef$curr6 = _minutesInputRef$curr5.focus) === null || _minutesInputRef$curr6 === void 0 ? void 0 : _minutesInputRef$curr6.call(_minutesInputRef$curr5);
|
|
214
|
+
} // focus last fragment on fill with now
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
if ((ctrlKey || metaKey) && key === ';') lastSegmentRef === null || lastSegmentRef === void 0 ? void 0 : (_lastSegmentRef$curre5 = lastSegmentRef.current) === null || _lastSegmentRef$curre5 === void 0 ? void 0 : (_lastSegmentRef$curre6 = _lastSegmentRef$curre5.focus) === null || _lastSegmentRef$curre6 === void 0 ? void 0 : _lastSegmentRef$curre6.call(_lastSegmentRef$curre5);
|
|
218
|
+
}, [onHomeKeyDown, onEndKeyDown, meridiem, handleChangeMeridiem, lastSegmentRef, minutesInputRef]);
|
|
282
219
|
const onMeridiemBlur = useCallback(e => {
|
|
283
220
|
var _e$target6, _e$target6$value, _e$target6$value$toUp;
|
|
284
221
|
|
|
@@ -290,36 +227,25 @@ const useTimeInputs = () => {
|
|
|
290
227
|
return useMemo(() => ({
|
|
291
228
|
hours,
|
|
292
229
|
minutes,
|
|
293
|
-
// seconds,
|
|
294
230
|
meridiem,
|
|
295
231
|
autoFocusHourInput,
|
|
232
|
+
disabled,
|
|
296
233
|
handleChangeHours,
|
|
297
234
|
onHoursFocus,
|
|
298
235
|
onHoursChange,
|
|
299
236
|
handleChangeMinutes,
|
|
300
237
|
onMinutesFocus,
|
|
301
238
|
onMinutesChange,
|
|
302
|
-
// handleChangeSeconds,
|
|
303
|
-
// onSecondsFocus,
|
|
304
|
-
// onSecondsChange,
|
|
305
239
|
handleChangeMeridiem,
|
|
306
240
|
onMeridiemFocus,
|
|
307
241
|
onMeridiemChange,
|
|
308
242
|
onHoursBlur,
|
|
309
243
|
onMinutesBlur,
|
|
310
|
-
// onSecondsBlur,
|
|
311
244
|
onMeridiemBlur,
|
|
312
245
|
onHoursKeyDown,
|
|
313
246
|
onMinutesKeyDown,
|
|
314
|
-
// onSecondsKeyDown,
|
|
315
247
|
onMeridiemKeyDown
|
|
316
|
-
}), [hours, minutes,
|
|
317
|
-
meridiem, autoFocusHourInput, handleChangeHours, onHoursFocus, onHoursChange, handleChangeMinutes, onMinutesFocus, onMinutesChange, // handleChangeSeconds,
|
|
318
|
-
// onSecondsFocus,
|
|
319
|
-
// onSecondsChange,
|
|
320
|
-
handleChangeMeridiem, onMeridiemFocus, onMeridiemChange, onHoursBlur, onMinutesBlur, // onSecondsBlur,
|
|
321
|
-
onMeridiemBlur, onHoursKeyDown, onMinutesKeyDown, // onSecondsKeyDown,
|
|
322
|
-
onMeridiemKeyDown]);
|
|
248
|
+
}), [hours, minutes, meridiem, autoFocusHourInput, disabled, handleChangeHours, onHoursFocus, onHoursChange, handleChangeMinutes, onMinutesFocus, onMinutesChange, handleChangeMeridiem, onMeridiemFocus, onMeridiemChange, onHoursBlur, onMinutesBlur, onMeridiemBlur, onHoursKeyDown, onMinutesKeyDown, onMeridiemKeyDown]);
|
|
323
249
|
};
|
|
324
250
|
|
|
325
251
|
export { useTimeInputs };
|
|
@@ -2,6 +2,7 @@ import { PropTypes } from 'react-desc';
|
|
|
2
2
|
|
|
3
3
|
const propTypes = {
|
|
4
4
|
type: PropTypes.oneOf(['full-date-time', 'date-time-inputs', 'date-time-picker', 'date-time-picker-controller-only', 'full-date', 'date-inputs', 'date-picker', 'date-picker-controller-only', 'full-time', 'time-inputs', 'time-picker', 'time-picker-controller-only']).description('Type of time form control to use').defaultValue('full-date-time'),
|
|
5
|
+
disabled: PropTypes.bool.description('wheter or not the input is disabled').defaultValue('false'),
|
|
5
6
|
isClearable: PropTypes.bool.description('with or without clearable button').defaultValue('false'),
|
|
6
7
|
dateTime: PropTypes.string.description('when using date-time types, this is the value of the controller'),
|
|
7
8
|
date: PropTypes.string.description('when using date types, this is the value of the controller'),
|
|
@@ -20,7 +21,8 @@ const propTypes = {
|
|
|
20
21
|
getIsDisabledTime: PropTypes.func.description('(timeAsString) => true for marking as disabled, false for marking as valid').defaultValue(''),
|
|
21
22
|
emptyPickerStartingMonth: PropTypes.string.description('which month to start the calendar on open, when value is empty, string following the "MM/__/YYYY" pattern'),
|
|
22
23
|
onCalendarOpenFocusedDay: PropTypes.string.description('which day to focus on calendar open when value is empty, string following the "MM/DD/YYYY" pattern').defaultValue('if value is empty current month, else month corresponding the month'),
|
|
23
|
-
minutesInterval: PropTypes.number.description('increments/decrements of minutes in time related controllers interactions').defaultValue('1')
|
|
24
|
+
minutesInterval: PropTypes.number.description('increments/decrements of minutes in time related controllers interactions').defaultValue('1'),
|
|
25
|
+
'data-testid': PropTypes.string.description('Unique id for tests.').defaultValue('')
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
export { propTypes };
|
|
@@ -33,5 +33,14 @@ const announcableCardinalDays = {
|
|
|
33
33
|
30: 'thirtieth',
|
|
34
34
|
31: 'thirty first'
|
|
35
35
|
};
|
|
36
|
+
const homeEndAllArrowKeys = ['Home', 'End', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];
|
|
37
|
+
const homeEndKeys = ['Home', 'End'];
|
|
38
|
+
const homeEndArrowUpDownDashSlashesKeys = ['Home', 'End', 'ArrowUp', 'ArrowDown', '-', '/', '\\'];
|
|
39
|
+
const homeEndArrowUpDownSpaceKeys = ['Home', 'End', 'ArrowUp', 'ArrowDown', ' '];
|
|
40
|
+
const homeEndArrowUpDownSemiKeys = ['Home', 'End', 'ArrowUp', 'ArrowDown', ':'];
|
|
41
|
+
const homeEndArrowUpDownKeys = ['Home', 'End', 'ArrowUp', 'ArrowDown'];
|
|
42
|
+
const defaultMetaInfo = {
|
|
43
|
+
isAutomaticFillTrigger: false
|
|
44
|
+
};
|
|
36
45
|
|
|
37
|
-
export { announcableCardinalDays, monthNames, weekDays };
|
|
46
|
+
export { announcableCardinalDays, defaultMetaInfo, homeEndAllArrowKeys, homeEndArrowUpDownDashSlashesKeys, homeEndArrowUpDownKeys, homeEndArrowUpDownSemiKeys, homeEndArrowUpDownSpaceKeys, homeEndKeys, monthNames, weekDays };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
1
3
|
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
4
|
import { createRef } from 'react';
|
|
3
5
|
import { monthNames } from './constants.js';
|
|
@@ -22,9 +24,9 @@ const isValidDayForTheMonthDateString = dateString => {
|
|
|
22
24
|
const monthDateMonth = monthInt - 1;
|
|
23
25
|
return ((_getDayFromDateString = getDayFromDateString(dateString)) === null || _getDayFromDateString === void 0 ? void 0 : (_getDayFromDateString2 = _getDayFromDateString.getMonth) === null || _getDayFromDateString2 === void 0 ? void 0 : _getDayFromDateString2.call(_getDayFromDateString)) === monthDateMonth;
|
|
24
26
|
};
|
|
25
|
-
const getValidationDateStringMetaInfo = (dateString
|
|
26
|
-
getIsOutOfRangeDay = day => false
|
|
27
|
-
getIsDisabledDay = day => false
|
|
27
|
+
const getValidationDateStringMetaInfo = function (dateString) {
|
|
28
|
+
let getIsOutOfRangeDay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : day => false;
|
|
29
|
+
let getIsDisabledDay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : day => false;
|
|
28
30
|
const metaInfo = {};
|
|
29
31
|
|
|
30
32
|
if (!isIncompleteString(dateString)) {
|
|
@@ -59,15 +61,17 @@ const dateAddMonths = (date, value) => {
|
|
|
59
61
|
};
|
|
60
62
|
const dateAddYear = (date, value) => dateAddMonths(date, value * 12);
|
|
61
63
|
// sumFromDateValues supports negative values to "subtract"
|
|
62
|
-
const sumFromDateValues = ({
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
const sumFromDateValues = (_ref, _ref2) => {
|
|
65
|
+
let {
|
|
66
|
+
month,
|
|
67
|
+
year,
|
|
68
|
+
day = 1
|
|
69
|
+
} = _ref;
|
|
70
|
+
let {
|
|
71
|
+
monthsToSum = 0,
|
|
72
|
+
yearsToSum = 0,
|
|
73
|
+
daysToSum = 0
|
|
74
|
+
} = _ref2;
|
|
71
75
|
let newDate = new Date(year, month, day);
|
|
72
76
|
if (yearsToSum) newDate = dateAddYear(newDate, yearsToSum);
|
|
73
77
|
if (monthsToSum) newDate = dateAddMonths(newDate, monthsToSum);
|
|
@@ -87,22 +91,26 @@ const sumValuesToDate = (day, sumValues) => {
|
|
|
87
91
|
} = sumFromDateValues(dateAsVals, sumValues);
|
|
88
92
|
return new Date(year, month, newD);
|
|
89
93
|
};
|
|
90
|
-
const subtractYears = (date
|
|
94
|
+
const subtractYears = function (date) {
|
|
95
|
+
let howManyMore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
91
96
|
const newDate = new Date(date.getTime());
|
|
92
97
|
newDate.setFullYear(date.getFullYear() - howManyMore);
|
|
93
98
|
return newDate;
|
|
94
99
|
};
|
|
95
|
-
const subtractMonths = (date
|
|
100
|
+
const subtractMonths = function (date) {
|
|
101
|
+
let howManyMore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
96
102
|
const newDate = new Date(date.getTime());
|
|
97
103
|
newDate.setMonth(date.getMonth() - howManyMore);
|
|
98
104
|
return newDate;
|
|
99
105
|
};
|
|
100
|
-
const sumMonths = (date
|
|
106
|
+
const sumMonths = function (date) {
|
|
107
|
+
let howManyMore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
101
108
|
const newDate = new Date(date.getTime());
|
|
102
109
|
newDate.setMonth(date.getMonth() + howManyMore);
|
|
103
110
|
return newDate;
|
|
104
111
|
};
|
|
105
|
-
const sumYears = (date
|
|
112
|
+
const sumYears = function (date) {
|
|
113
|
+
let howManyMore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
106
114
|
const newDate = new Date(date.getTime());
|
|
107
115
|
newDate.setFullYear(date.getFullYear() + howManyMore);
|
|
108
116
|
return newDate;
|
|
@@ -190,6 +198,15 @@ const getDateStringFromDay = day => {
|
|
|
190
198
|
const yearFromDay = prependStringWithPlaceHolders("".concat(day.getFullYear()), 4);
|
|
191
199
|
return "".concat(monthFromDay, "/").concat(dayFromDay, "/").concat(yearFromDay);
|
|
192
200
|
};
|
|
201
|
+
const getTimeStringFromDay = day => {
|
|
202
|
+
const hoursNum = day.getHours();
|
|
203
|
+
const meridiem = hoursNum > 12 ? 'PM' : 'AM';
|
|
204
|
+
const twelveHourFormat = hoursNum > 12 ? hoursNum - 12 : hoursNum;
|
|
205
|
+
const minutesNum = day.getMinutes();
|
|
206
|
+
const hoursFromDay = prependStringWithPlaceHolders("".concat(twelveHourFormat), 2);
|
|
207
|
+
const minutesFromDay = prependStringWithPlaceHolders("".concat(minutesNum), 2);
|
|
208
|
+
return "".concat(hoursFromDay, ":").concat(minutesFromDay, " ").concat(meridiem);
|
|
209
|
+
};
|
|
193
210
|
const getDayFromDateString = dateString => {
|
|
194
211
|
const {
|
|
195
212
|
month,
|
|
@@ -222,4 +239,4 @@ const compareTwoDatesDayEquality = (dayA, dayB) => {
|
|
|
222
239
|
return currD === focusD && currM === focusM && currY === focusY;
|
|
223
240
|
};
|
|
224
241
|
|
|
225
|
-
export { compareTwoDatesDayEquality, dateAddMonths, dateAddYear, dateGetDaysInMonth, dateIsLeapYear, getDateStringFromDay, getDateValuesFromDate, getDayFromDateString, getDaysInMonth, getFirstXDaysFromNextMonth, getFiveBySevenCurrentMonthDaysMatrix, getHowManyDaysInMonth, getLastDayOfMonth, getLastXDaysFromPreviousMonth, getMonthNameByMonthNumber, getValidationDateStringMetaInfo, isLeapYear, isSameDateMoment, isValidDayForTheMonth, isValidDayForTheMonthDateString, subtractMonths, subtractYears, sumFromDateValues, sumMonths, sumValuesToDate, sumYears };
|
|
242
|
+
export { compareTwoDatesDayEquality, dateAddMonths, dateAddYear, dateGetDaysInMonth, dateIsLeapYear, getDateStringFromDay, getDateValuesFromDate, getDayFromDateString, getDaysInMonth, getFirstXDaysFromNextMonth, getFiveBySevenCurrentMonthDaysMatrix, getHowManyDaysInMonth, getLastDayOfMonth, getLastXDaysFromPreviousMonth, getMonthNameByMonthNumber, getTimeStringFromDay, getValidationDateStringMetaInfo, isLeapYear, isSameDateMoment, isValidDayForTheMonth, isValidDayForTheMonthDateString, subtractMonths, subtractYears, sumFromDateValues, sumMonths, sumValuesToDate, sumYears };
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
1
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
7
|
import { getValidationDateStringMetaInfo } from './dateHelpers.js';
|
|
3
8
|
import { getValidationTimeStringMetaInfo } from './timeHelpers.js';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
1
3
|
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
4
|
import 'core-js/modules/es.string.replace.js';
|
|
3
5
|
import { monthNames, announcableCardinalDays } from './constants.js';
|
|
@@ -5,21 +7,24 @@ import { convertToPositiveNumberIfPossible } from './numberHelpers.js';
|
|
|
5
7
|
|
|
6
8
|
/* eslint-disable max-lines */
|
|
7
9
|
|
|
8
|
-
const prependStringWithPlaceHolders = (val, finalLength
|
|
10
|
+
const prependStringWithPlaceHolders = function (val, finalLength) {
|
|
11
|
+
let placeholder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '0';
|
|
9
12
|
if (val.length === finalLength) return val;
|
|
10
13
|
const stringAsAnArray = val.split('').reverse();
|
|
11
14
|
return new Array(finalLength).fill(placeholder).map((_c, i) => stringAsAnArray[i] ? stringAsAnArray[i] : placeholder).reverse().join('');
|
|
12
15
|
};
|
|
13
|
-
const fillStringWithPlaceHolders = (val, finalLength
|
|
16
|
+
const fillStringWithPlaceHolders = function (val, finalLength) {
|
|
17
|
+
let placeholder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '_';
|
|
14
18
|
if (val.length === finalLength) return val;
|
|
15
19
|
const stringAsAnArray = val.split('');
|
|
16
20
|
return new Array(finalLength).fill(placeholder).map((_c, i) => stringAsAnArray[i] ? stringAsAnArray[i] : placeholder).join('');
|
|
17
21
|
};
|
|
18
|
-
const getFormattedDateString =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
const getFormattedDateString = _ref => {
|
|
23
|
+
let {
|
|
24
|
+
month,
|
|
25
|
+
day,
|
|
26
|
+
year
|
|
27
|
+
} = _ref;
|
|
23
28
|
const finalMonth = fillStringWithPlaceHolders(month, 2);
|
|
24
29
|
const finalDay = fillStringWithPlaceHolders(day, 2);
|
|
25
30
|
const finalYear = fillStringWithPlaceHolders(year, 4);
|
|
@@ -63,12 +68,13 @@ const isValidDateString = testString => {
|
|
|
63
68
|
if (Number.parseInt(month, 10) > 12 || Number.parseInt(day, 10) > 31 || Number.parseInt(year, 10) > 9999) return false;
|
|
64
69
|
return true;
|
|
65
70
|
};
|
|
66
|
-
const getFormattedTimeString =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
const getFormattedTimeString = _ref2 => {
|
|
72
|
+
let {
|
|
73
|
+
hours,
|
|
74
|
+
minutes,
|
|
75
|
+
// seconds,
|
|
76
|
+
meridiem
|
|
77
|
+
} = _ref2;
|
|
72
78
|
const finalHour = fillStringWithPlaceHolders(hours, 2);
|
|
73
79
|
const finalMinutes = fillStringWithPlaceHolders(minutes, 2); // const finalSeconds = fillStringWithPlaceHolders(seconds, 2); // <-- seconds format
|
|
74
80
|
|
|
@@ -114,7 +120,10 @@ const isValidTimeString = testString => {
|
|
|
114
120
|
if (Number.parseInt(hours, 10) > 12 || Number.parseInt(minutes, 10) > 60) return false;
|
|
115
121
|
return true;
|
|
116
122
|
};
|
|
117
|
-
const isIncompleteString = (testString
|
|
123
|
+
const isIncompleteString = function (testString) {
|
|
124
|
+
let placeholder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '_';
|
|
125
|
+
return testString === '' || testString.includes(placeholder);
|
|
126
|
+
};
|
|
118
127
|
const isEmptyDateStringMask = testString => testString === '__/__/____';
|
|
119
128
|
const isEmptyTimeStringMask = testString => testString === '__:__ __';
|
|
120
129
|
const isEmptyDateTimeStringMask = testString => testString === '__/__/____ __:__ __';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isIncompleteString } from './stringHelpers.js';
|
|
2
2
|
|
|
3
|
-
const getValidationTimeStringMetaInfo = (timeString
|
|
3
|
+
const getValidationTimeStringMetaInfo = function (timeString) {
|
|
4
|
+
let getIsDisabledTime = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : timeS => false;
|
|
4
5
|
const metaInfo = {};
|
|
5
6
|
|
|
6
7
|
if (!isIncompleteString(timeString)) {
|