@elliemae/ds-controlled-form 2.4.1-rc.7 → 2.4.1-rc.8
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/date-time-picker/ControlledDateTimePickerCTX.js +1 -114
- package/cjs/date-time-picker/ControlledDateTimePickerDatatestid.js +0 -2
- package/cjs/date-time-picker/config/useChangeHandlers.js +264 -0
- package/cjs/date-time-picker/config/useControlledDateTimePicker.js +37 -420
- package/cjs/date-time-picker/config/useGetDestructuredValues.js +25 -68
- package/cjs/date-time-picker/config/useGetFlags.js +173 -0
- package/cjs/date-time-picker/config/useGetPropsBasedOnType.js +101 -0
- package/cjs/date-time-picker/config/useGetPropsWithDefault.js +2 -3
- package/cjs/date-time-picker/config/useGetReferences.js +86 -0
- package/cjs/date-time-picker/config/useGlobalKeyHandlers.js +106 -0
- package/cjs/date-time-picker/config/useRelevantValueFromProps.js +39 -0
- package/cjs/date-time-picker/config/useValidateProps.js +47 -42
- package/cjs/date-time-picker/parts/ClearButton/ClearButton.js +20 -8
- package/cjs/date-time-picker/parts/ControlledDateTimePickerContent.js +14 -12
- package/cjs/date-time-picker/parts/DateInputs/useDateInputs.js +5 -5
- package/cjs/date-time-picker/parts/Pickers/Calendar/Calendar.js +11 -13
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarContent.js +4 -1
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarContext.js +1 -49
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarDaysList.js +4 -4
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarHead.js +10 -7
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarIconTrigger.js +8 -4
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarMonthDays.js +5 -2
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarWrapper.js +5 -2
- package/cjs/date-time-picker/parts/Pickers/Calendar/Day.js +18 -18
- package/cjs/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +24 -122
- package/cjs/date-time-picker/parts/Pickers/Calendar/useCurrentDisplayedMonthYearLogic.js +32 -4
- package/cjs/date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +10 -6
- package/cjs/date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.js +30 -14
- package/cjs/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +7 -4
- package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheel.js +7 -3
- package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelContext.js +1 -16
- package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +0 -1
- package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +10 -10
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/HoursList.js +18 -13
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +60 -33
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +18 -13
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/TimeWheel.js +11 -13
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/TimeWheelContent.js +5 -2
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/TimeWheelContext.js +1 -65
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/TimeWheelIconTrigger.js +8 -3
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/TimeWheelWrapper.js +5 -2
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/useConfigTimePickerCTX.js +18 -116
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/useCurrentDisplayedWheelsLogic.js +52 -94
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.js +4 -1
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +1 -1
- package/cjs/date-time-picker/parts/TimeInputs/HHInput.js +1 -3
- package/cjs/date-time-picker/parts/TimeInputs/MeridiemInput.js +1 -1
- package/cjs/date-time-picker/parts/TimeInputs/TimeInputs.js +3 -7
- package/cjs/date-time-picker/parts/TimeInputs/useTimeInputs.js +3 -6
- package/cjs/date-time-picker/propTypes.js +56 -23
- package/cjs/date-time-picker/sharedTypes.js +2 -0
- package/cjs/date-time-picker/utils/dateHelpers.js +56 -56
- package/cjs/date-time-picker/utils/hooks/useGetMonthYearFromDateStringOrEmptyStartingMonth.js +2 -5
- package/cjs/date-time-picker/utils/hooks/useGetStartingFocusedDay.js +50 -47
- package/cjs/date-time-picker/utils/hooks/useOnClickOutside.js +1 -2
- package/cjs/date-time-picker/utils/stringHelpers.js +8 -14
- package/cjs/date-time-picker/utils/typeGuards.js +14 -0
- package/esm/date-time-picker/ControlledDateTimePickerCTX.js +3 -115
- package/esm/date-time-picker/ControlledDateTimePickerDatatestid.js +0 -2
- package/esm/date-time-picker/config/useChangeHandlers.js +256 -0
- package/esm/date-time-picker/config/useControlledDateTimePicker.js +38 -421
- package/esm/date-time-picker/config/useGetDestructuredValues.js +21 -68
- package/esm/date-time-picker/config/useGetFlags.js +165 -0
- package/esm/date-time-picker/config/useGetPropsBasedOnType.js +97 -0
- package/esm/date-time-picker/config/useGetPropsWithDefault.js +1 -2
- package/esm/date-time-picker/config/useGetReferences.js +82 -0
- package/esm/date-time-picker/config/useGlobalKeyHandlers.js +98 -0
- package/esm/date-time-picker/config/useRelevantValueFromProps.js +35 -0
- package/esm/date-time-picker/config/useValidateProps.js +47 -42
- package/esm/date-time-picker/parts/ClearButton/ClearButton.js +20 -9
- package/esm/date-time-picker/parts/ControlledDateTimePickerContent.js +14 -12
- package/esm/date-time-picker/parts/DateInputs/useDateInputs.js +5 -5
- package/esm/date-time-picker/parts/Pickers/Calendar/Calendar.js +11 -13
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarContent.js +4 -1
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarContext.js +2 -50
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarDaysList.js +4 -4
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarHead.js +10 -7
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarIconTrigger.js +9 -5
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarMonthDays.js +5 -2
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarWrapper.js +5 -2
- package/esm/date-time-picker/parts/Pickers/Calendar/Day.js +18 -18
- package/esm/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +23 -125
- package/esm/date-time-picker/parts/Pickers/Calendar/useCurrentDisplayedMonthYearLogic.js +33 -5
- package/esm/date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +10 -6
- package/esm/date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.js +30 -14
- package/esm/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +7 -4
- package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheel.js +9 -5
- package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelContext.js +1 -16
- package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +1 -2
- package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +10 -10
- package/esm/date-time-picker/parts/Pickers/TimeWheel/HoursList.js +18 -13
- package/esm/date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +59 -33
- package/esm/date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +18 -13
- package/esm/date-time-picker/parts/Pickers/TimeWheel/TimeWheel.js +11 -13
- package/esm/date-time-picker/parts/Pickers/TimeWheel/TimeWheelContent.js +5 -2
- package/esm/date-time-picker/parts/Pickers/TimeWheel/TimeWheelContext.js +2 -66
- package/esm/date-time-picker/parts/Pickers/TimeWheel/TimeWheelIconTrigger.js +8 -3
- package/esm/date-time-picker/parts/Pickers/TimeWheel/TimeWheelWrapper.js +5 -2
- package/esm/date-time-picker/parts/Pickers/TimeWheel/useConfigTimePickerCTX.js +15 -117
- package/esm/date-time-picker/parts/Pickers/TimeWheel/useCurrentDisplayedWheelsLogic.js +54 -96
- package/esm/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.js +4 -1
- package/esm/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +1 -1
- package/esm/date-time-picker/parts/TimeInputs/HHInput.js +1 -3
- package/esm/date-time-picker/parts/TimeInputs/MeridiemInput.js +1 -1
- package/esm/date-time-picker/parts/TimeInputs/TimeInputs.js +3 -7
- package/esm/date-time-picker/parts/TimeInputs/useTimeInputs.js +3 -6
- package/esm/date-time-picker/propTypes.js +49 -17
- package/esm/date-time-picker/sharedTypes.js +1 -0
- package/esm/date-time-picker/utils/dateHelpers.js +57 -57
- package/esm/date-time-picker/utils/hooks/useGetMonthYearFromDateStringOrEmptyStartingMonth.js +2 -5
- package/esm/date-time-picker/utils/hooks/useGetStartingFocusedDay.js +46 -47
- package/esm/date-time-picker/utils/hooks/useOnClickOutside.js +1 -2
- package/esm/date-time-picker/utils/stringHelpers.js +8 -14
- package/esm/date-time-picker/utils/typeGuards.js +8 -0
- package/package.json +47 -15
- package/types/date-time-picker/ControlledDateTimePicker.d.ts +25 -80
- package/types/date-time-picker/ControlledDateTimePickerCTX.d.ts +1 -2
- package/types/date-time-picker/ControlledDateTimePickerDatatestid.d.ts +46 -46
- package/types/date-time-picker/ControlledDateTimePickerTypes.d.ts +15 -15
- package/types/date-time-picker/config/useChangeHandlers.d.ts +25 -0
- package/types/date-time-picker/config/useControlledDateTimePicker.d.ts +18 -2
- package/types/date-time-picker/config/useGetDestructuredValues.d.ts +30 -4
- package/types/date-time-picker/config/useGetFlags.d.ts +27 -0
- package/types/date-time-picker/config/useGetPropsBasedOnType.d.ts +28 -0
- package/types/date-time-picker/config/useGetPropsWithDefault.d.ts +2 -2
- package/types/date-time-picker/config/useGetReferences.d.ts +39 -0
- package/types/date-time-picker/config/useGlobalKeyHandlers.d.ts +16 -0
- package/types/date-time-picker/config/useRelevantValueFromProps.d.ts +10 -0
- package/types/date-time-picker/config/useValidateProps.d.ts +2 -2
- package/types/date-time-picker/parts/ClearButton/useClearButton.d.ts +6 -6
- package/types/date-time-picker/parts/DateInputs/DDInput.d.ts +6 -6
- package/types/date-time-picker/parts/DateInputs/MMInput.d.ts +6 -6
- package/types/date-time-picker/parts/DateInputs/YYYYInput.d.ts +6 -6
- package/types/date-time-picker/parts/DateInputs/useDateInputs.d.ts +2 -2
- package/types/date-time-picker/parts/Pickers/Calendar/Calendar.d.ts +4 -2
- package/types/date-time-picker/parts/Pickers/Calendar/CalendarContext.d.ts +3 -63
- package/types/date-time-picker/parts/Pickers/Calendar/CalendarDaysList.d.ts +4 -4
- package/types/date-time-picker/parts/Pickers/Calendar/CalendarFooter.d.ts +2 -2
- package/types/date-time-picker/parts/Pickers/Calendar/Day.d.ts +2 -2
- package/types/date-time-picker/parts/Pickers/Calendar/useCurrentDisplayedMonthYearLogic.d.ts +15 -2
- package/types/date-time-picker/parts/Pickers/Calendar/useFocusLogic.d.ts +12 -5
- package/types/date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.d.ts +17 -11
- package/types/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelContext.d.ts +1 -16
- package/types/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelFooter.d.ts +2 -2
- package/types/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.d.ts +15 -1
- package/types/date-time-picker/parts/Pickers/TimeWheel/TimeWheel.d.ts +4 -2
- package/types/date-time-picker/parts/Pickers/TimeWheel/TimeWheelContext.d.ts +3 -62
- package/types/date-time-picker/parts/Pickers/TimeWheel/TimeWheelFooter.d.ts +2 -2
- package/types/date-time-picker/parts/Pickers/TimeWheel/useConfigTimePickerCTX.d.ts +4 -1
- package/types/date-time-picker/parts/Pickers/TimeWheel/useCurrentDisplayedWheelsLogic.d.ts +16 -5
- package/types/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.d.ts +18 -3
- package/types/date-time-picker/parts/TimeInputs/HHInput.d.ts +6 -6
- package/types/date-time-picker/parts/TimeInputs/MeridiemInput.d.ts +6 -6
- package/types/date-time-picker/parts/TimeInputs/MinutesInput.d.ts +6 -6
- package/types/date-time-picker/parts/TimeInputs/useTimeInputs.d.ts +22 -2
- package/types/date-time-picker/parts/config.d.ts +3 -3
- package/types/date-time-picker/sharedTypes.d.ts +94 -0
- package/types/date-time-picker/utils/constants.d.ts +33 -33
- package/types/date-time-picker/utils/dateHelpers.d.ts +15 -14
- package/types/date-time-picker/utils/dateTimeHelpers.d.ts +3 -3
- package/types/date-time-picker/utils/hooks/useGetDayFromDateString.d.ts +1 -1
- package/types/date-time-picker/utils/hooks/useGetMonthYearFromDateStringOrEmptyStartingMonth.d.ts +2 -2
- package/types/date-time-picker/utils/hooks/useGetStartingFocusedDay.d.ts +6 -6
- package/types/date-time-picker/utils/hooks/useOnClickOutside.d.ts +1 -1
- package/types/date-time-picker/utils/timeHelpers.d.ts +2 -2
- package/types/date-time-picker/utils/typeGuards.d.ts +4 -0
- package/types/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.d.ts +0 -2
- package/types/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.d.ts +0 -12
- package/types/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.d.ts +0 -2
- package/types/date-time-picker/propTypes.d.ts +0 -81
|
@@ -33,9 +33,7 @@ const HHInput = /*#__PURE__*/React__default["default"].memo(_ref => {
|
|
|
33
33
|
autoFocusHourInput
|
|
34
34
|
} = _ref;
|
|
35
35
|
const validateOnChange = React.useCallback(e => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (isInvalidHour(e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value)) {
|
|
36
|
+
if (isInvalidHour(e.target.value)) {
|
|
39
37
|
e.preventDefault();
|
|
40
38
|
return;
|
|
41
39
|
}
|
|
@@ -17,7 +17,7 @@ const validSecondDigits = ['m', 'M'];
|
|
|
17
17
|
|
|
18
18
|
const isInvalidMeridiem = meridiem => {
|
|
19
19
|
if (meridiem === '') return false;
|
|
20
|
-
const [firstDigit, secondDigit] = meridiem
|
|
20
|
+
const [firstDigit, secondDigit] = meridiem.split('');
|
|
21
21
|
const isValidFirstDigit = meridiem.length < 1 && !firstDigit || validFirstDigits.includes(firstDigit);
|
|
22
22
|
const isValidSecondDigit = !secondDigit || validSecondDigits.includes(secondDigit);
|
|
23
23
|
return meridiem.length > 2 || !isValidFirstDigit || !isValidSecondDigit;
|
|
@@ -20,30 +20,26 @@ var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
|
20
20
|
var _StyledColonSeparator, _StyledSeparator;
|
|
21
21
|
const TimeInputs = () => {
|
|
22
22
|
const {
|
|
23
|
-
hours,
|
|
24
|
-
minutes,
|
|
25
|
-
// seconds,
|
|
26
|
-
meridiem,
|
|
27
23
|
autoFocusHourInput,
|
|
28
24
|
disabled,
|
|
29
25
|
onHoursChange,
|
|
30
26
|
onMinutesChange,
|
|
31
|
-
// onSecondsChange,
|
|
32
27
|
onMeridiemChange,
|
|
33
28
|
onHoursBlur,
|
|
34
29
|
onMinutesBlur,
|
|
35
|
-
// onSecondsBlur,
|
|
36
30
|
onMeridiemBlur,
|
|
37
31
|
onHoursFocus,
|
|
38
32
|
onMeridiemFocus,
|
|
39
33
|
onMinutesFocus,
|
|
40
34
|
onHoursKeyDown,
|
|
41
35
|
onMinutesKeyDown,
|
|
42
|
-
// onSecondsKeyDown,
|
|
43
36
|
onMeridiemKeyDown
|
|
44
37
|
} = useTimeInputs.useTimeInputs(); // we do this here so HHInput,MinutesInput, MeridiemInput can be pure components memoized via React.memo
|
|
45
38
|
|
|
46
39
|
const {
|
|
40
|
+
hours,
|
|
41
|
+
minutes,
|
|
42
|
+
meridiem,
|
|
47
43
|
hourInputRef,
|
|
48
44
|
minutesInputRef,
|
|
49
45
|
meridiemInputRef,
|
|
@@ -11,7 +11,6 @@ var stringHelpers = require('../../utils/stringHelpers.js');
|
|
|
11
11
|
const useTimeInputs = () => {
|
|
12
12
|
const {
|
|
13
13
|
props: {
|
|
14
|
-
minutesInterval,
|
|
15
14
|
disabled
|
|
16
15
|
},
|
|
17
16
|
lastSegmentRef,
|
|
@@ -34,7 +33,8 @@ const useTimeInputs = () => {
|
|
|
34
33
|
handleChangeHours,
|
|
35
34
|
handleChangeMinutes,
|
|
36
35
|
handleChangeMeridiem,
|
|
37
|
-
setLatestInteractionRegion
|
|
36
|
+
setLatestInteractionRegion,
|
|
37
|
+
minutesInterval
|
|
38
38
|
} = React.useContext(ControlledDateTimePickerCTX.ControlledDateTimePickerContext);
|
|
39
39
|
const setLatestInteractionRegionTimeInputs = React.useCallback(() => {
|
|
40
40
|
setLatestInteractionRegion('time-inputs');
|
|
@@ -229,9 +229,6 @@ const useTimeInputs = () => {
|
|
|
229
229
|
});
|
|
230
230
|
}, [handleChangeMeridiem]);
|
|
231
231
|
return React.useMemo(() => ({
|
|
232
|
-
hours,
|
|
233
|
-
minutes,
|
|
234
|
-
meridiem,
|
|
235
232
|
autoFocusHourInput,
|
|
236
233
|
disabled,
|
|
237
234
|
handleChangeHours,
|
|
@@ -249,7 +246,7 @@ const useTimeInputs = () => {
|
|
|
249
246
|
onHoursKeyDown,
|
|
250
247
|
onMinutesKeyDown,
|
|
251
248
|
onMeridiemKeyDown
|
|
252
|
-
}), [
|
|
249
|
+
}), [autoFocusHourInput, disabled, handleChangeHours, onHoursFocus, onHoursChange, handleChangeMinutes, onMinutesFocus, onMinutesChange, handleChangeMeridiem, onMeridiemFocus, onMeridiemChange, onHoursBlur, onMinutesBlur, onMeridiemBlur, onHoursKeyDown, onMinutesKeyDown, onMeridiemKeyDown]);
|
|
253
250
|
};
|
|
254
251
|
|
|
255
252
|
exports.useTimeInputs = useTimeInputs;
|
|
@@ -2,31 +2,64 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var dsPropsHelpers = require('@elliemae/ds-props-helpers');
|
|
6
6
|
|
|
7
|
+
/* eslint-disable max-lines */
|
|
8
|
+
|
|
9
|
+
const noop = () => {};
|
|
10
|
+
|
|
11
|
+
const defaultReturnFalse = () => false;
|
|
12
|
+
|
|
13
|
+
const defaultProps = {
|
|
14
|
+
type: 'full-date-time',
|
|
15
|
+
onDateChange: noop,
|
|
16
|
+
onMonthChange: noop,
|
|
17
|
+
onDayChange: noop,
|
|
18
|
+
onYearChange: noop,
|
|
19
|
+
onTimeChange: noop,
|
|
20
|
+
onHourChange: noop,
|
|
21
|
+
onMinuteChange: noop,
|
|
22
|
+
onMeridiemChange: noop,
|
|
23
|
+
onPickerOpen: noop,
|
|
24
|
+
onPickerClose: noop,
|
|
25
|
+
getIsDisabledDay: defaultReturnFalse,
|
|
26
|
+
getIsOutOfRangeDay: defaultReturnFalse,
|
|
27
|
+
getIsStartRangeDay: defaultReturnFalse,
|
|
28
|
+
getIsDayInRange: defaultReturnFalse,
|
|
29
|
+
getIsEndRangeDay: defaultReturnFalse,
|
|
30
|
+
getIsDisabledTime: defaultReturnFalse,
|
|
31
|
+
minutesInterval: 1,
|
|
32
|
+
isClearable: false,
|
|
33
|
+
disabled: false,
|
|
34
|
+
hasError: false,
|
|
35
|
+
autoFocus: false,
|
|
36
|
+
preventCloseOnSelection: false
|
|
37
|
+
};
|
|
7
38
|
const propTypes = {
|
|
8
|
-
type:
|
|
9
|
-
disabled:
|
|
10
|
-
isClearable:
|
|
11
|
-
dateTime:
|
|
12
|
-
date:
|
|
13
|
-
time:
|
|
14
|
-
onDateChange:
|
|
15
|
-
onTimeChange:
|
|
16
|
-
onDateTimeChange:
|
|
17
|
-
onMonthChange:
|
|
18
|
-
onDayChange:
|
|
19
|
-
onYearChange:
|
|
20
|
-
onHourChange:
|
|
21
|
-
onMinuteChange:
|
|
22
|
-
onMeridiemChange:
|
|
23
|
-
getIsDisabledDay:
|
|
24
|
-
getIsOutOfRangeDay:
|
|
25
|
-
getIsDisabledTime:
|
|
26
|
-
emptyPickerStartingMonth:
|
|
27
|
-
onCalendarOpenFocusedDay:
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
type: dsPropsHelpers.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'),
|
|
40
|
+
disabled: dsPropsHelpers.PropTypes.bool.description('wheter or not the input is disabled').defaultValue(false),
|
|
41
|
+
isClearable: dsPropsHelpers.PropTypes.bool.description('with or without clearable button').defaultValue(false),
|
|
42
|
+
dateTime: dsPropsHelpers.PropTypes.string.description('when using date-time types, this is the value of the controller'),
|
|
43
|
+
date: dsPropsHelpers.PropTypes.string.description('when using date types, this is the value of the controller'),
|
|
44
|
+
time: dsPropsHelpers.PropTypes.string.description('when using time types, this is the value of the controller'),
|
|
45
|
+
onDateChange: dsPropsHelpers.PropTypes.func.description('(newDateString, metaInformations) => void'),
|
|
46
|
+
onTimeChange: dsPropsHelpers.PropTypes.func.description('(newTimeString, metaInformations) => void'),
|
|
47
|
+
onDateTimeChange: dsPropsHelpers.PropTypes.func.description('(newDateTimeString, metaInformations) => void'),
|
|
48
|
+
onMonthChange: dsPropsHelpers.PropTypes.func.description('(newMonthString, event, metaInformations) => void'),
|
|
49
|
+
onDayChange: dsPropsHelpers.PropTypes.func.description('(newDayString, event, metaInformations) => void'),
|
|
50
|
+
onYearChange: dsPropsHelpers.PropTypes.func.description('(newYearString, event, metaInformations) => void'),
|
|
51
|
+
onHourChange: dsPropsHelpers.PropTypes.func.description('(newHourString, event, metaInformations) => void'),
|
|
52
|
+
onMinuteChange: dsPropsHelpers.PropTypes.func.description('(newMinuteString, event, metaInformations) => void'),
|
|
53
|
+
onMeridiemChange: dsPropsHelpers.PropTypes.func.description('(newMeridiemString, event, metaInformations) => void'),
|
|
54
|
+
getIsDisabledDay: dsPropsHelpers.PropTypes.func.description('(dayAsString) => true for marking as disabled, false for marking as valid'),
|
|
55
|
+
getIsOutOfRangeDay: dsPropsHelpers.PropTypes.func.description('(dayAsString) => true for marking as disabled, false for marking as valid'),
|
|
56
|
+
getIsDisabledTime: dsPropsHelpers.PropTypes.func.description('(timeAsString) => true for marking as disabled, false for marking as valid'),
|
|
57
|
+
emptyPickerStartingMonth: dsPropsHelpers.PropTypes.string.description('which month to start the calendar on open, when value is empty, string following the "MM/__/YYYY" pattern'),
|
|
58
|
+
onCalendarOpenFocusedDay: dsPropsHelpers.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 current month'),
|
|
59
|
+
onTimeWheelOpenStartingTime: dsPropsHelpers.PropTypes.string.description('which day to start the timewheel on picker open when value is empty, string following the HH:MM AA" pattern').defaultValue('01:00 AM'),
|
|
60
|
+
minutesInterval: dsPropsHelpers.PropTypes.number.description('increments/decrements of minutes in time related controllers interactions').defaultValue('1'),
|
|
61
|
+
'data-testid': dsPropsHelpers.PropTypes.string.description('Unique id for tests.').defaultValue('')
|
|
30
62
|
};
|
|
31
63
|
|
|
64
|
+
exports.defaultProps = defaultProps;
|
|
32
65
|
exports.propTypes = propTypes;
|
|
@@ -10,12 +10,68 @@ var constants = require('./constants.js');
|
|
|
10
10
|
var stringHelpers = require('./stringHelpers.js');
|
|
11
11
|
var numberHelpers = require('./numberHelpers.js');
|
|
12
12
|
|
|
13
|
+
const getDateValuesFromDate = day => {
|
|
14
|
+
var _day$getMonth, _day$getDate, _day$getFullYear;
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
month: day === null || day === void 0 ? void 0 : (_day$getMonth = day.getMonth) === null || _day$getMonth === void 0 ? void 0 : _day$getMonth.call(day),
|
|
18
|
+
day: day === null || day === void 0 ? void 0 : (_day$getDate = day.getDate) === null || _day$getDate === void 0 ? void 0 : _day$getDate.call(day),
|
|
19
|
+
year: day === null || day === void 0 ? void 0 : (_day$getFullYear = day.getFullYear) === null || _day$getFullYear === void 0 ? void 0 : _day$getFullYear.call(day)
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
const getDateStringFromDay = day => {
|
|
23
|
+
const monthFromDay = stringHelpers.prependStringWithPlaceHolders("".concat(day.getMonth() + 1), 2); // months from 1-12
|
|
24
|
+
|
|
25
|
+
const dayFromDay = stringHelpers.prependStringWithPlaceHolders("".concat(day.getDate()), 2);
|
|
26
|
+
const yearFromDay = stringHelpers.prependStringWithPlaceHolders("".concat(day.getFullYear()), 4);
|
|
27
|
+
return "".concat(monthFromDay, "/").concat(dayFromDay, "/").concat(yearFromDay);
|
|
28
|
+
};
|
|
29
|
+
const getTimeStringFromDay = day => {
|
|
30
|
+
const hoursNum = day.getHours();
|
|
31
|
+
const meridiem = hoursNum > 12 ? 'PM' : 'AM';
|
|
32
|
+
const twelveHourFormat = hoursNum > 12 ? hoursNum - 12 : hoursNum;
|
|
33
|
+
const minutesNum = day.getMinutes();
|
|
34
|
+
const hoursFromDay = stringHelpers.prependStringWithPlaceHolders("".concat(twelveHourFormat), 2);
|
|
35
|
+
const minutesFromDay = stringHelpers.prependStringWithPlaceHolders("".concat(minutesNum), 2);
|
|
36
|
+
return "".concat(hoursFromDay, ":").concat(minutesFromDay, " ").concat(meridiem);
|
|
37
|
+
};
|
|
38
|
+
const getMonthNameByMonthNumber = monthNumber => constants.monthNames[monthNumber];
|
|
39
|
+
const isSameDateMoment = (dateA, dateB) => {
|
|
40
|
+
var _dateA$getTime, _dateB$getTime;
|
|
41
|
+
|
|
42
|
+
return (dateA === null || dateA === void 0 ? void 0 : (_dateA$getTime = dateA.getTime) === null || _dateA$getTime === void 0 ? void 0 : _dateA$getTime.call(dateA)) === (dateB === null || dateB === void 0 ? void 0 : (_dateB$getTime = dateB.getTime) === null || _dateB$getTime === void 0 ? void 0 : _dateB$getTime.call(dateB));
|
|
43
|
+
};
|
|
44
|
+
const compareTwoDatesDayEquality = (dayA, dayB) => {
|
|
45
|
+
const {
|
|
46
|
+
day: currD,
|
|
47
|
+
month: currM,
|
|
48
|
+
year: currY
|
|
49
|
+
} = getDateValuesFromDate(dayA);
|
|
50
|
+
const {
|
|
51
|
+
day: focusD,
|
|
52
|
+
month: focusM,
|
|
53
|
+
year: focusY
|
|
54
|
+
} = getDateValuesFromDate(dayB);
|
|
55
|
+
return currD === focusD && currM === focusM && currY === focusY;
|
|
56
|
+
};
|
|
13
57
|
const getLastDayOfMonth = (month, year) => new Date(year, month + 1, 0);
|
|
14
58
|
const isValidDayForTheMonth = (month, year, day) => {
|
|
15
59
|
var _Date, _Date$getMonth;
|
|
16
60
|
|
|
17
61
|
return ((_Date = new Date(year, month, day)) === null || _Date === void 0 ? void 0 : (_Date$getMonth = _Date.getMonth) === null || _Date$getMonth === void 0 ? void 0 : _Date$getMonth.call(_Date)) === month;
|
|
18
62
|
};
|
|
63
|
+
const getDayFromDateString = dateString => {
|
|
64
|
+
const {
|
|
65
|
+
month,
|
|
66
|
+
day,
|
|
67
|
+
year
|
|
68
|
+
} = stringHelpers.deconstructValuesFromDateString(dateString);
|
|
69
|
+
const monthNum = numberHelpers.convertToPositiveNumberIfPossible(month);
|
|
70
|
+
const dayNum = numberHelpers.convertToPositiveNumberIfPossible(day);
|
|
71
|
+
const yearNum = numberHelpers.convertToPositiveNumberIfPossible(year);
|
|
72
|
+
if (monthNum !== -1 && dayNum !== -1 && yearNum !== -1 && isValidDayForTheMonth(monthNum - 1, yearNum, dayNum)) return new Date(yearNum, monthNum - 1, dayNum);
|
|
73
|
+
return null;
|
|
74
|
+
};
|
|
19
75
|
const isValidDayForTheMonthDateString = dateString => {
|
|
20
76
|
var _getDayFromDateString, _getDayFromDateString2;
|
|
21
77
|
|
|
@@ -186,62 +242,6 @@ const getFiveBySevenCurrentMonthDaysMatrix = (month, year) => {
|
|
|
186
242
|
}));
|
|
187
243
|
return [...previousMonthDaysToPrepend, ...currentMonthDays, ...nextMonthDaysToAppend];
|
|
188
244
|
};
|
|
189
|
-
const getDateValuesFromDate = day => {
|
|
190
|
-
var _day$getMonth, _day$getDate, _day$getFullYear;
|
|
191
|
-
|
|
192
|
-
return {
|
|
193
|
-
month: day === null || day === void 0 ? void 0 : (_day$getMonth = day.getMonth) === null || _day$getMonth === void 0 ? void 0 : _day$getMonth.call(day),
|
|
194
|
-
day: day === null || day === void 0 ? void 0 : (_day$getDate = day.getDate) === null || _day$getDate === void 0 ? void 0 : _day$getDate.call(day),
|
|
195
|
-
year: day === null || day === void 0 ? void 0 : (_day$getFullYear = day.getFullYear) === null || _day$getFullYear === void 0 ? void 0 : _day$getFullYear.call(day)
|
|
196
|
-
};
|
|
197
|
-
};
|
|
198
|
-
const getDateStringFromDay = day => {
|
|
199
|
-
const monthFromDay = stringHelpers.prependStringWithPlaceHolders("".concat(day.getMonth() + 1), 2); // months from 1-12
|
|
200
|
-
|
|
201
|
-
const dayFromDay = stringHelpers.prependStringWithPlaceHolders("".concat(day.getDate()), 2);
|
|
202
|
-
const yearFromDay = stringHelpers.prependStringWithPlaceHolders("".concat(day.getFullYear()), 4);
|
|
203
|
-
return "".concat(monthFromDay, "/").concat(dayFromDay, "/").concat(yearFromDay);
|
|
204
|
-
};
|
|
205
|
-
const getTimeStringFromDay = day => {
|
|
206
|
-
const hoursNum = day.getHours();
|
|
207
|
-
const meridiem = hoursNum > 12 ? 'PM' : 'AM';
|
|
208
|
-
const twelveHourFormat = hoursNum > 12 ? hoursNum - 12 : hoursNum;
|
|
209
|
-
const minutesNum = day.getMinutes();
|
|
210
|
-
const hoursFromDay = stringHelpers.prependStringWithPlaceHolders("".concat(twelveHourFormat), 2);
|
|
211
|
-
const minutesFromDay = stringHelpers.prependStringWithPlaceHolders("".concat(minutesNum), 2);
|
|
212
|
-
return "".concat(hoursFromDay, ":").concat(minutesFromDay, " ").concat(meridiem);
|
|
213
|
-
};
|
|
214
|
-
const getDayFromDateString = dateString => {
|
|
215
|
-
const {
|
|
216
|
-
month,
|
|
217
|
-
day,
|
|
218
|
-
year
|
|
219
|
-
} = stringHelpers.deconstructValuesFromDateString(dateString);
|
|
220
|
-
const monthNum = numberHelpers.convertToPositiveNumberIfPossible(month);
|
|
221
|
-
const dayNum = numberHelpers.convertToPositiveNumberIfPossible(day);
|
|
222
|
-
const yearNum = numberHelpers.convertToPositiveNumberIfPossible(year);
|
|
223
|
-
if (monthNum !== -1 && dayNum !== -1 && yearNum !== -1 && isValidDayForTheMonth(monthNum - 1, yearNum, dayNum)) return new Date(yearNum, monthNum - 1, dayNum);
|
|
224
|
-
return null;
|
|
225
|
-
};
|
|
226
|
-
const getMonthNameByMonthNumber = monthNumber => constants.monthNames[monthNumber];
|
|
227
|
-
const isSameDateMoment = (dateA, dateB) => {
|
|
228
|
-
var _dateA$getTime, _dateB$getTime;
|
|
229
|
-
|
|
230
|
-
return (dateA === null || dateA === void 0 ? void 0 : (_dateA$getTime = dateA.getTime) === null || _dateA$getTime === void 0 ? void 0 : _dateA$getTime.call(dateA)) === (dateB === null || dateB === void 0 ? void 0 : (_dateB$getTime = dateB.getTime) === null || _dateB$getTime === void 0 ? void 0 : _dateB$getTime.call(dateB));
|
|
231
|
-
};
|
|
232
|
-
const compareTwoDatesDayEquality = (dayA, dayB) => {
|
|
233
|
-
const {
|
|
234
|
-
day: currD,
|
|
235
|
-
month: currM,
|
|
236
|
-
year: currY
|
|
237
|
-
} = getDateValuesFromDate(dayA);
|
|
238
|
-
const {
|
|
239
|
-
day: focusD,
|
|
240
|
-
month: focusM,
|
|
241
|
-
year: focusY
|
|
242
|
-
} = getDateValuesFromDate(dayB);
|
|
243
|
-
return currD === focusD && currM === focusM && currY === focusY;
|
|
244
|
-
};
|
|
245
245
|
|
|
246
246
|
exports.compareTwoDatesDayEquality = compareTwoDatesDayEquality;
|
|
247
247
|
exports.dateAddMonths = dateAddMonths;
|
package/cjs/date-time-picker/utils/hooks/useGetMonthYearFromDateStringOrEmptyStartingMonth.js
CHANGED
|
@@ -9,12 +9,9 @@ var stringHelpers = require('../stringHelpers.js');
|
|
|
9
9
|
const useGetMonthYearFromDateStringOrEmptyStartingMonth = () => {
|
|
10
10
|
const {
|
|
11
11
|
dateStringFromProps,
|
|
12
|
-
|
|
13
|
-
emptyPickerStartingMonth
|
|
14
|
-
}
|
|
12
|
+
emptyPickerStartingMonth
|
|
15
13
|
} = React.useContext(ControlledDateTimePickerCTX.ControlledDateTimePickerContext);
|
|
16
14
|
return React.useMemo(() => {
|
|
17
|
-
const emptyPickerStartingMonthDefault = "".concat(new Date().getMonth() + 1, "/__/").concat(new Date().getFullYear());
|
|
18
15
|
const {
|
|
19
16
|
month: stringMonthVal,
|
|
20
17
|
year: stringYearVal
|
|
@@ -22,7 +19,7 @@ const useGetMonthYearFromDateStringOrEmptyStartingMonth = () => {
|
|
|
22
19
|
const {
|
|
23
20
|
month: emptyStringSplitMonth,
|
|
24
21
|
year: emptyStringSplitYear
|
|
25
|
-
} = stringHelpers.deconstructValuesFromDateString(emptyPickerStartingMonth
|
|
22
|
+
} = stringHelpers.deconstructValuesFromDateString(emptyPickerStartingMonth);
|
|
26
23
|
const userEmptyStringMonth = Number.parseInt(emptyStringSplitMonth, 10);
|
|
27
24
|
const userEmptyStringYear = Number.parseInt(emptyStringSplitYear, 10);
|
|
28
25
|
const month = stringMonthVal === '' || stringMonthVal.length !== 2 ? userEmptyStringMonth - 1 : Number.parseInt(stringMonthVal, 10) - 1; // month is 0~11 in javascript Date...
|
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
10
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
5
11
|
var React = require('react');
|
|
6
12
|
var ControlledDateTimePickerCTX = require('../../ControlledDateTimePickerCTX.js');
|
|
7
13
|
var stringHelpers = require('../stringHelpers.js');
|
|
@@ -9,7 +15,13 @@ var numberHelpers = require('../numberHelpers.js');
|
|
|
9
15
|
var dateHelpers = require('../dateHelpers.js');
|
|
10
16
|
var useGetDayFromDateString = require('./useGetDayFromDateString.js');
|
|
11
17
|
|
|
12
|
-
|
|
18
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
|
+
|
|
20
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
21
|
+
|
|
22
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23
|
+
|
|
24
|
+
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__default["default"](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; }
|
|
13
25
|
const empty = {
|
|
14
26
|
startFocusedYear: null,
|
|
15
27
|
startFocusedDay: null,
|
|
@@ -18,61 +30,52 @@ const empty = {
|
|
|
18
30
|
};
|
|
19
31
|
const useGetStartingFocusedDay = () => {
|
|
20
32
|
const {
|
|
21
|
-
|
|
22
|
-
onCalendarOpenFocusedDay
|
|
23
|
-
}
|
|
33
|
+
onCalendarOpenFocusedDay
|
|
24
34
|
} = React.useContext(ControlledDateTimePickerCTX.ControlledDateTimePickerContext);
|
|
25
35
|
const dayFromInputValues = useGetDayFromDateString.useGetDayFromDateString();
|
|
26
36
|
return React.useMemo(() => {
|
|
27
|
-
const {
|
|
28
|
-
month: inputValuesSplitMonth,
|
|
29
|
-
day: inputValuesSplitDay,
|
|
30
|
-
year: inputValuesDaySplitYear
|
|
31
|
-
} = dateHelpers.getDateValuesFromDate(dayFromInputValues);
|
|
32
|
-
let startFocusedMonth = null;
|
|
33
|
-
let startFocusedDay = null;
|
|
34
|
-
let startFocusedYear = null;
|
|
35
|
-
let startFocusedDate = null;
|
|
36
|
-
const isInputFilledAndValid = inputValuesSplitMonth && inputValuesSplitDay && inputValuesDaySplitYear && dateHelpers.isValidDayForTheMonth(inputValuesSplitMonth, inputValuesDaySplitYear, inputValuesSplitDay);
|
|
37
|
-
const isOnCalendarOpenFocusedDayEmpty = !onCalendarOpenFocusedDay;
|
|
38
|
-
const shouldFillWithOnCalendarOpenFocusedDay = !isInputFilledAndValid && !isOnCalendarOpenFocusedDayEmpty; // if input was filled start focus is the filled value (if it's valid day for the month)
|
|
37
|
+
const startingDay = _objectSpread({}, empty);
|
|
39
38
|
|
|
40
|
-
if (
|
|
41
|
-
startFocusedMonth = inputValuesSplitMonth;
|
|
42
|
-
startFocusedDay = inputValuesSplitDay;
|
|
43
|
-
startFocusedYear = inputValuesDaySplitYear;
|
|
44
|
-
startFocusedDate = dayFromInputValues; // if input was not filled (or filled invalid) and there is no onCalendarOpenFocusedDay start focus is not a day
|
|
45
|
-
} // if input was not filled and there is onCalendarOpenFocusedDay start focus is onCalendarOpenFocusedDay day
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (!isInputFilledAndValid && isOnCalendarOpenFocusedDayEmpty) return empty;
|
|
49
|
-
|
|
50
|
-
if (shouldFillWithOnCalendarOpenFocusedDay) {
|
|
39
|
+
if (dayFromInputValues) {
|
|
51
40
|
const {
|
|
52
|
-
month:
|
|
53
|
-
day:
|
|
54
|
-
year:
|
|
55
|
-
} =
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
41
|
+
month: inputValuesSplitMonth,
|
|
42
|
+
day: inputValuesSplitDay,
|
|
43
|
+
year: inputValuesDaySplitYear
|
|
44
|
+
} = dateHelpers.getDateValuesFromDate(dayFromInputValues);
|
|
45
|
+
const isInputFilledAndValid = inputValuesSplitMonth && inputValuesSplitDay && inputValuesDaySplitYear && dateHelpers.isValidDayForTheMonth(inputValuesSplitMonth, inputValuesDaySplitYear, inputValuesSplitDay);
|
|
46
|
+
const isOnCalendarOpenFocusedDayEmpty = !onCalendarOpenFocusedDay;
|
|
47
|
+
const shouldFillWithOnCalendarOpenFocusedDay = !isInputFilledAndValid && !isOnCalendarOpenFocusedDayEmpty; // if input was filled start focus is the filled value (if it's valid day for the month)
|
|
48
|
+
|
|
49
|
+
if (isInputFilledAndValid) {
|
|
50
|
+
startingDay.startFocusedMonth = inputValuesSplitMonth;
|
|
51
|
+
startingDay.startFocusedDay = inputValuesSplitDay;
|
|
52
|
+
startingDay.startFocusedYear = inputValuesDaySplitYear;
|
|
53
|
+
startingDay.startFocusedDate = dayFromInputValues; // if input was not filled (or filled invalid) and there is no onCalendarOpenFocusedDay start focus is not a day
|
|
54
|
+
} else if (isOnCalendarOpenFocusedDayEmpty) {
|
|
55
|
+
// if input was not filled and there is onCalendarOpenFocusedDay start focus is onCalendarOpenFocusedDay day
|
|
56
|
+
return empty;
|
|
57
|
+
} else if (shouldFillWithOnCalendarOpenFocusedDay) {
|
|
58
|
+
const {
|
|
59
|
+
month: focusedDaySplitMonth,
|
|
60
|
+
day: focusedDaySplitDay,
|
|
61
|
+
year: focusedDaySplitYear
|
|
62
|
+
} = stringHelpers.deconstructValuesFromDateString(onCalendarOpenFocusedDay);
|
|
63
|
+
const monthAsInt = numberHelpers.convertToPositiveNumberIfPossible(focusedDaySplitMonth);
|
|
64
|
+
const dayAsInt = numberHelpers.convertToPositiveNumberIfPossible(focusedDaySplitDay);
|
|
65
|
+
const yearAsInt = numberHelpers.convertToPositiveNumberIfPossible(focusedDaySplitYear); // if this condition is false, return will be the same as return empty
|
|
66
|
+
// because startFocusedMonth/Day/Year/Date will be === null
|
|
67
|
+
// which is the expected result
|
|
61
68
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
if (monthAsInt !== -1 && dayAsInt !== -1 && yearAsInt !== -1 && dateHelpers.isValidDayForTheMonth(monthAsInt - 1, yearAsInt, dayAsInt)) {
|
|
70
|
+
startingDay.startFocusedMonth = monthAsInt;
|
|
71
|
+
startingDay.startFocusedDay = dayAsInt;
|
|
72
|
+
startingDay.startFocusedYear = yearAsInt;
|
|
73
|
+
startingDay.startFocusedDate = new Date(yearAsInt, monthAsInt - 1, dayAsInt);
|
|
74
|
+
}
|
|
67
75
|
}
|
|
68
76
|
}
|
|
69
77
|
|
|
70
|
-
return
|
|
71
|
-
startFocusedYear,
|
|
72
|
-
startFocusedDay,
|
|
73
|
-
startFocusedMonth,
|
|
74
|
-
startFocusedDate
|
|
75
|
-
};
|
|
78
|
+
return startingDay;
|
|
76
79
|
}, [dayFromInputValues, onCalendarOpenFocusedDay]);
|
|
77
80
|
};
|
|
78
81
|
|
|
@@ -10,10 +10,9 @@ const useOnClickOutside = (ref, handler) => {
|
|
|
10
10
|
var _ref$contains;
|
|
11
11
|
|
|
12
12
|
// Do nothing if clicking ref's element or descendent elements
|
|
13
|
-
if (!ref || ref !== null && ref !== void 0 && (_ref$contains = ref.contains) !== null && _ref$contains !== void 0 && _ref$contains.call(ref, event.target)) {
|
|
13
|
+
if (event.target instanceof Element) if (!ref || ref !== null && ref !== void 0 && (_ref$contains = ref.contains) !== null && _ref$contains !== void 0 && _ref$contains.call(ref, event.target)) {
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
16
|
handler(event);
|
|
18
17
|
};
|
|
19
18
|
|
|
@@ -10,7 +10,6 @@ var constants = require('./constants.js');
|
|
|
10
10
|
var numberHelpers = require('./numberHelpers.js');
|
|
11
11
|
|
|
12
12
|
/* eslint-disable max-lines */
|
|
13
|
-
|
|
14
13
|
const prependStringWithPlaceHolders = function (val, finalLength) {
|
|
15
14
|
let placeholder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '0';
|
|
16
15
|
if (val.length === finalLength) return val;
|
|
@@ -40,7 +39,7 @@ const dateTimeToDate = dateTime => {
|
|
|
40
39
|
return dateTime === null || dateTime === void 0 ? void 0 : (_dateTime$split = dateTime.split) === null || _dateTime$split === void 0 ? void 0 : (_dateTime$split$call = _dateTime$split.call(dateTime, ' ')) === null || _dateTime$split$call === void 0 ? void 0 : _dateTime$split$call[0];
|
|
41
40
|
};
|
|
42
41
|
const deconstructValuesFromDateString = dateString => {
|
|
43
|
-
const [dirtyMonth = '', dirtyDay = '', dirtyYear = ''] = dateString
|
|
42
|
+
const [dirtyMonth = '', dirtyDay = '', dirtyYear = ''] = dateString.split('/');
|
|
44
43
|
const replaceAllRegexp = /_/g;
|
|
45
44
|
return {
|
|
46
45
|
month: (dirtyMonth || '').replace(replaceAllRegexp, ''),
|
|
@@ -49,8 +48,8 @@ const deconstructValuesFromDateString = dateString => {
|
|
|
49
48
|
};
|
|
50
49
|
};
|
|
51
50
|
const deconstructValuesFromTimeString = timeString => {
|
|
52
|
-
const [dirtyHour = '', dirtyMintuesAndMeridiem = ''] = timeString
|
|
53
|
-
const [dirtyMinutes = '', dirtyMeridiem = ''] = dirtyMintuesAndMeridiem
|
|
51
|
+
const [dirtyHour = '', dirtyMintuesAndMeridiem = ''] = timeString.split(':');
|
|
52
|
+
const [dirtyMinutes = '', dirtyMeridiem = ''] = dirtyMintuesAndMeridiem.split(' ');
|
|
54
53
|
const replaceAllRegexp = /_/g;
|
|
55
54
|
return {
|
|
56
55
|
hours: (dirtyHour || '').replace(replaceAllRegexp, ''),
|
|
@@ -87,26 +86,21 @@ const getFormattedTimeString = _ref2 => {
|
|
|
87
86
|
return "".concat(finalHour, ":").concat(finalMinutes, " ").concat(finalMeridiem);
|
|
88
87
|
};
|
|
89
88
|
const dateTimeToTime = dateTime => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
_date, // timeNumbers = '__:__:__', // <-- seconds format
|
|
94
|
-
timeNumbers = '__:__', timeMeridiem = '__'] = dateTime === null || dateTime === void 0 ? void 0 : (_dateTime$split2 = dateTime.split) === null || _dateTime$split2 === void 0 ? void 0 : _dateTime$split2.call(dateTime, ' ');
|
|
89
|
+
const [// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
|
|
90
|
+
date, // timeNumbers = '__:__:__', // <-- seconds format
|
|
91
|
+
timeNumbers = '__:__', timeMeridiem = '__'] = dateTime.split(' ');
|
|
95
92
|
return "".concat(timeNumbers, " ").concat(timeMeridiem);
|
|
96
93
|
};
|
|
97
94
|
const deconstructTimeValues = timeString => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const [dirtyTimes, dirtyMeridiem] = timeString === null || timeString === void 0 ? void 0 : (_timeString$split = timeString.split) === null || _timeString$split === void 0 ? void 0 : _timeString$split.call(timeString, ' '); // <--['__:__','__']
|
|
95
|
+
const [dirtyTimes = '', dirtyMeridiem] = timeString.split(' '); // <--['__:__','__']
|
|
101
96
|
|
|
102
|
-
const [dirtyHours, dirtyMinutes] =
|
|
97
|
+
const [dirtyHours, dirtyMinutes] = dirtyTimes.split(':'); // <--['__','__']
|
|
103
98
|
|
|
104
99
|
const regex = /_/g; // Note the 'g' flag, which matches all occurrences of the expression
|
|
105
100
|
|
|
106
101
|
const newValues = {
|
|
107
102
|
hours: (dirtyHours || '').replace(regex, ''),
|
|
108
103
|
minutes: (dirtyMinutes || '').replace(regex, ''),
|
|
109
|
-
// seconds: (dirtySeconds||"").replace(regex, ''),
|
|
110
104
|
meridiem: (dirtyMeridiem || '').replace(regex, '')
|
|
111
105
|
};
|
|
112
106
|
return newValues;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const dateTimeTypes = ['full-date-time', 'date-time-inputs', 'date-time-picker', 'date-time-picker-controller-only'];
|
|
6
|
+
const dateTypes = ['full-date', 'date-inputs', 'date-picker', 'date-picker-controller-only'];
|
|
7
|
+
const timeTypes = ['full-time', 'time-inputs', 'time-picker', 'time-picker-controller-only'];
|
|
8
|
+
const getIsDateTime = props => dateTimeTypes.includes(props.type);
|
|
9
|
+
const getIsDate = props => dateTypes.includes(props.type);
|
|
10
|
+
const getIsTime = props => timeTypes.includes(props.type);
|
|
11
|
+
|
|
12
|
+
exports.getIsDate = getIsDate;
|
|
13
|
+
exports.getIsDateTime = getIsDateTime;
|
|
14
|
+
exports.getIsTime = getIsTime;
|