@elliemae/ds-controlled-form 2.4.1-rc.6 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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
|
@@ -9,7 +9,7 @@ const validSecondDigits = ['m', 'M'];
|
|
|
9
9
|
|
|
10
10
|
const isInvalidMeridiem = meridiem => {
|
|
11
11
|
if (meridiem === '') return false;
|
|
12
|
-
const [firstDigit, secondDigit] = meridiem
|
|
12
|
+
const [firstDigit, secondDigit] = meridiem.split('');
|
|
13
13
|
const isValidFirstDigit = meridiem.length < 1 && !firstDigit || validFirstDigits.includes(firstDigit);
|
|
14
14
|
const isValidSecondDigit = !secondDigit || validSecondDigits.includes(secondDigit);
|
|
15
15
|
return meridiem.length > 2 || !isValidFirstDigit || !isValidSecondDigit;
|
|
@@ -12,30 +12,26 @@ import { StyledFocusWithIn, StyledColonSeparator, StyledSeparator } from '../Sty
|
|
|
12
12
|
var _StyledColonSeparator, _StyledSeparator;
|
|
13
13
|
const TimeInputs = () => {
|
|
14
14
|
const {
|
|
15
|
-
hours,
|
|
16
|
-
minutes,
|
|
17
|
-
// seconds,
|
|
18
|
-
meridiem,
|
|
19
15
|
autoFocusHourInput,
|
|
20
16
|
disabled,
|
|
21
17
|
onHoursChange,
|
|
22
18
|
onMinutesChange,
|
|
23
|
-
// onSecondsChange,
|
|
24
19
|
onMeridiemChange,
|
|
25
20
|
onHoursBlur,
|
|
26
21
|
onMinutesBlur,
|
|
27
|
-
// onSecondsBlur,
|
|
28
22
|
onMeridiemBlur,
|
|
29
23
|
onHoursFocus,
|
|
30
24
|
onMeridiemFocus,
|
|
31
25
|
onMinutesFocus,
|
|
32
26
|
onHoursKeyDown,
|
|
33
27
|
onMinutesKeyDown,
|
|
34
|
-
// onSecondsKeyDown,
|
|
35
28
|
onMeridiemKeyDown
|
|
36
29
|
} = useTimeInputs(); // we do this here so HHInput,MinutesInput, MeridiemInput can be pure components memoized via React.memo
|
|
37
30
|
|
|
38
31
|
const {
|
|
32
|
+
hours,
|
|
33
|
+
minutes,
|
|
34
|
+
meridiem,
|
|
39
35
|
hourInputRef,
|
|
40
36
|
minutesInputRef,
|
|
41
37
|
meridiemInputRef,
|
|
@@ -7,7 +7,6 @@ import { prependStringWithPlaceHolders } from '../../utils/stringHelpers.js';
|
|
|
7
7
|
const useTimeInputs = () => {
|
|
8
8
|
const {
|
|
9
9
|
props: {
|
|
10
|
-
minutesInterval,
|
|
11
10
|
disabled
|
|
12
11
|
},
|
|
13
12
|
lastSegmentRef,
|
|
@@ -30,7 +29,8 @@ const useTimeInputs = () => {
|
|
|
30
29
|
handleChangeHours,
|
|
31
30
|
handleChangeMinutes,
|
|
32
31
|
handleChangeMeridiem,
|
|
33
|
-
setLatestInteractionRegion
|
|
32
|
+
setLatestInteractionRegion,
|
|
33
|
+
minutesInterval
|
|
34
34
|
} = useContext(ControlledDateTimePickerContext);
|
|
35
35
|
const setLatestInteractionRegionTimeInputs = useCallback(() => {
|
|
36
36
|
setLatestInteractionRegion('time-inputs');
|
|
@@ -225,9 +225,6 @@ const useTimeInputs = () => {
|
|
|
225
225
|
});
|
|
226
226
|
}, [handleChangeMeridiem]);
|
|
227
227
|
return useMemo(() => ({
|
|
228
|
-
hours,
|
|
229
|
-
minutes,
|
|
230
|
-
meridiem,
|
|
231
228
|
autoFocusHourInput,
|
|
232
229
|
disabled,
|
|
233
230
|
handleChangeHours,
|
|
@@ -245,7 +242,7 @@ const useTimeInputs = () => {
|
|
|
245
242
|
onHoursKeyDown,
|
|
246
243
|
onMinutesKeyDown,
|
|
247
244
|
onMeridiemKeyDown
|
|
248
|
-
}), [
|
|
245
|
+
}), [autoFocusHourInput, disabled, handleChangeHours, onHoursFocus, onHoursChange, handleChangeMinutes, onMinutesFocus, onMinutesChange, handleChangeMeridiem, onMeridiemFocus, onMeridiemChange, onHoursBlur, onMinutesBlur, onMeridiemBlur, onHoursKeyDown, onMinutesKeyDown, onMeridiemKeyDown]);
|
|
249
246
|
};
|
|
250
247
|
|
|
251
248
|
export { useTimeInputs };
|
|
@@ -1,28 +1,60 @@
|
|
|
1
|
-
import { PropTypes } from '
|
|
1
|
+
import { PropTypes } from '@elliemae/ds-props-helpers';
|
|
2
2
|
|
|
3
|
+
/* eslint-disable max-lines */
|
|
4
|
+
|
|
5
|
+
const noop = () => {};
|
|
6
|
+
|
|
7
|
+
const defaultReturnFalse = () => false;
|
|
8
|
+
|
|
9
|
+
const defaultProps = {
|
|
10
|
+
type: 'full-date-time',
|
|
11
|
+
onDateChange: noop,
|
|
12
|
+
onMonthChange: noop,
|
|
13
|
+
onDayChange: noop,
|
|
14
|
+
onYearChange: noop,
|
|
15
|
+
onTimeChange: noop,
|
|
16
|
+
onHourChange: noop,
|
|
17
|
+
onMinuteChange: noop,
|
|
18
|
+
onMeridiemChange: noop,
|
|
19
|
+
onPickerOpen: noop,
|
|
20
|
+
onPickerClose: noop,
|
|
21
|
+
getIsDisabledDay: defaultReturnFalse,
|
|
22
|
+
getIsOutOfRangeDay: defaultReturnFalse,
|
|
23
|
+
getIsStartRangeDay: defaultReturnFalse,
|
|
24
|
+
getIsDayInRange: defaultReturnFalse,
|
|
25
|
+
getIsEndRangeDay: defaultReturnFalse,
|
|
26
|
+
getIsDisabledTime: defaultReturnFalse,
|
|
27
|
+
minutesInterval: 1,
|
|
28
|
+
isClearable: false,
|
|
29
|
+
disabled: false,
|
|
30
|
+
hasError: false,
|
|
31
|
+
autoFocus: false,
|
|
32
|
+
preventCloseOnSelection: false
|
|
33
|
+
};
|
|
3
34
|
const propTypes = {
|
|
4
35
|
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(
|
|
6
|
-
isClearable: PropTypes.bool.description('with or without clearable button').defaultValue(
|
|
36
|
+
disabled: PropTypes.bool.description('wheter or not the input is disabled').defaultValue(false),
|
|
37
|
+
isClearable: PropTypes.bool.description('with or without clearable button').defaultValue(false),
|
|
7
38
|
dateTime: PropTypes.string.description('when using date-time types, this is the value of the controller'),
|
|
8
39
|
date: PropTypes.string.description('when using date types, this is the value of the controller'),
|
|
9
40
|
time: PropTypes.string.description('when using time types, this is the value of the controller'),
|
|
10
|
-
onDateChange: PropTypes.func.description('(newDateString, metaInformations) => void')
|
|
11
|
-
onTimeChange: PropTypes.func.description('(newTimeString, metaInformations) => void')
|
|
12
|
-
onDateTimeChange: PropTypes.func.description('(newDateTimeString, metaInformations) => void')
|
|
13
|
-
onMonthChange: PropTypes.func.description('(newMonthString, event, metaInformations) => void')
|
|
14
|
-
onDayChange: PropTypes.func.description('(newDayString, event, metaInformations) => void')
|
|
15
|
-
onYearChange: PropTypes.func.description('(newYearString, event, metaInformations) => void')
|
|
16
|
-
onHourChange: PropTypes.func.description('(newHourString, event, metaInformations) => void')
|
|
17
|
-
onMinuteChange: PropTypes.func.description('(newMinuteString, event, metaInformations) => void')
|
|
18
|
-
onMeridiemChange: PropTypes.func.description('(newMeridiemString, event, metaInformations) => void')
|
|
19
|
-
getIsDisabledDay: PropTypes.func.description('(dayAsString) => true for marking as disabled, false for marking as valid')
|
|
20
|
-
getIsOutOfRangeDay: PropTypes.func.description('(dayAsString) => true for marking as disabled, false for marking as valid')
|
|
21
|
-
getIsDisabledTime: PropTypes.func.description('(timeAsString) => true for marking as disabled, false for marking as valid')
|
|
41
|
+
onDateChange: PropTypes.func.description('(newDateString, metaInformations) => void'),
|
|
42
|
+
onTimeChange: PropTypes.func.description('(newTimeString, metaInformations) => void'),
|
|
43
|
+
onDateTimeChange: PropTypes.func.description('(newDateTimeString, metaInformations) => void'),
|
|
44
|
+
onMonthChange: PropTypes.func.description('(newMonthString, event, metaInformations) => void'),
|
|
45
|
+
onDayChange: PropTypes.func.description('(newDayString, event, metaInformations) => void'),
|
|
46
|
+
onYearChange: PropTypes.func.description('(newYearString, event, metaInformations) => void'),
|
|
47
|
+
onHourChange: PropTypes.func.description('(newHourString, event, metaInformations) => void'),
|
|
48
|
+
onMinuteChange: PropTypes.func.description('(newMinuteString, event, metaInformations) => void'),
|
|
49
|
+
onMeridiemChange: PropTypes.func.description('(newMeridiemString, event, metaInformations) => void'),
|
|
50
|
+
getIsDisabledDay: PropTypes.func.description('(dayAsString) => true for marking as disabled, false for marking as valid'),
|
|
51
|
+
getIsOutOfRangeDay: PropTypes.func.description('(dayAsString) => true for marking as disabled, false for marking as valid'),
|
|
52
|
+
getIsDisabledTime: PropTypes.func.description('(timeAsString) => true for marking as disabled, false for marking as valid'),
|
|
22
53
|
emptyPickerStartingMonth: PropTypes.string.description('which month to start the calendar on open, when value is empty, string following the "MM/__/YYYY" pattern'),
|
|
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
|
|
54
|
+
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 current month'),
|
|
55
|
+
onTimeWheelOpenStartingTime: 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'),
|
|
24
56
|
minutesInterval: PropTypes.number.description('increments/decrements of minutes in time related controllers interactions').defaultValue('1'),
|
|
25
57
|
'data-testid': PropTypes.string.description('Unique id for tests.').defaultValue('')
|
|
26
58
|
};
|
|
27
59
|
|
|
28
|
-
export { propTypes };
|
|
60
|
+
export { defaultProps, propTypes };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -3,15 +3,71 @@ import 'core-js/modules/esnext.iterator.map.js';
|
|
|
3
3
|
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
4
4
|
import { createRef } from 'react';
|
|
5
5
|
import { monthNames } from './constants.js';
|
|
6
|
-
import {
|
|
6
|
+
import { prependStringWithPlaceHolders, deconstructValuesFromDateString, isIncompleteString } from './stringHelpers.js';
|
|
7
7
|
import { convertToPositiveNumberIfPossible } from './numberHelpers.js';
|
|
8
8
|
|
|
9
|
+
const getDateValuesFromDate = day => {
|
|
10
|
+
var _day$getMonth, _day$getDate, _day$getFullYear;
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
month: day === null || day === void 0 ? void 0 : (_day$getMonth = day.getMonth) === null || _day$getMonth === void 0 ? void 0 : _day$getMonth.call(day),
|
|
14
|
+
day: day === null || day === void 0 ? void 0 : (_day$getDate = day.getDate) === null || _day$getDate === void 0 ? void 0 : _day$getDate.call(day),
|
|
15
|
+
year: day === null || day === void 0 ? void 0 : (_day$getFullYear = day.getFullYear) === null || _day$getFullYear === void 0 ? void 0 : _day$getFullYear.call(day)
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
const getDateStringFromDay = day => {
|
|
19
|
+
const monthFromDay = prependStringWithPlaceHolders("".concat(day.getMonth() + 1), 2); // months from 1-12
|
|
20
|
+
|
|
21
|
+
const dayFromDay = prependStringWithPlaceHolders("".concat(day.getDate()), 2);
|
|
22
|
+
const yearFromDay = prependStringWithPlaceHolders("".concat(day.getFullYear()), 4);
|
|
23
|
+
return "".concat(monthFromDay, "/").concat(dayFromDay, "/").concat(yearFromDay);
|
|
24
|
+
};
|
|
25
|
+
const getTimeStringFromDay = day => {
|
|
26
|
+
const hoursNum = day.getHours();
|
|
27
|
+
const meridiem = hoursNum > 12 ? 'PM' : 'AM';
|
|
28
|
+
const twelveHourFormat = hoursNum > 12 ? hoursNum - 12 : hoursNum;
|
|
29
|
+
const minutesNum = day.getMinutes();
|
|
30
|
+
const hoursFromDay = prependStringWithPlaceHolders("".concat(twelveHourFormat), 2);
|
|
31
|
+
const minutesFromDay = prependStringWithPlaceHolders("".concat(minutesNum), 2);
|
|
32
|
+
return "".concat(hoursFromDay, ":").concat(minutesFromDay, " ").concat(meridiem);
|
|
33
|
+
};
|
|
34
|
+
const getMonthNameByMonthNumber = monthNumber => monthNames[monthNumber];
|
|
35
|
+
const isSameDateMoment = (dateA, dateB) => {
|
|
36
|
+
var _dateA$getTime, _dateB$getTime;
|
|
37
|
+
|
|
38
|
+
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));
|
|
39
|
+
};
|
|
40
|
+
const compareTwoDatesDayEquality = (dayA, dayB) => {
|
|
41
|
+
const {
|
|
42
|
+
day: currD,
|
|
43
|
+
month: currM,
|
|
44
|
+
year: currY
|
|
45
|
+
} = getDateValuesFromDate(dayA);
|
|
46
|
+
const {
|
|
47
|
+
day: focusD,
|
|
48
|
+
month: focusM,
|
|
49
|
+
year: focusY
|
|
50
|
+
} = getDateValuesFromDate(dayB);
|
|
51
|
+
return currD === focusD && currM === focusM && currY === focusY;
|
|
52
|
+
};
|
|
9
53
|
const getLastDayOfMonth = (month, year) => new Date(year, month + 1, 0);
|
|
10
54
|
const isValidDayForTheMonth = (month, year, day) => {
|
|
11
55
|
var _Date, _Date$getMonth;
|
|
12
56
|
|
|
13
57
|
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;
|
|
14
58
|
};
|
|
59
|
+
const getDayFromDateString = dateString => {
|
|
60
|
+
const {
|
|
61
|
+
month,
|
|
62
|
+
day,
|
|
63
|
+
year
|
|
64
|
+
} = deconstructValuesFromDateString(dateString);
|
|
65
|
+
const monthNum = convertToPositiveNumberIfPossible(month);
|
|
66
|
+
const dayNum = convertToPositiveNumberIfPossible(day);
|
|
67
|
+
const yearNum = convertToPositiveNumberIfPossible(year);
|
|
68
|
+
if (monthNum !== -1 && dayNum !== -1 && yearNum !== -1 && isValidDayForTheMonth(monthNum - 1, yearNum, dayNum)) return new Date(yearNum, monthNum - 1, dayNum);
|
|
69
|
+
return null;
|
|
70
|
+
};
|
|
15
71
|
const isValidDayForTheMonthDateString = dateString => {
|
|
16
72
|
var _getDayFromDateString, _getDayFromDateString2;
|
|
17
73
|
|
|
@@ -182,61 +238,5 @@ const getFiveBySevenCurrentMonthDaysMatrix = (month, year) => {
|
|
|
182
238
|
}));
|
|
183
239
|
return [...previousMonthDaysToPrepend, ...currentMonthDays, ...nextMonthDaysToAppend];
|
|
184
240
|
};
|
|
185
|
-
const getDateValuesFromDate = day => {
|
|
186
|
-
var _day$getMonth, _day$getDate, _day$getFullYear;
|
|
187
|
-
|
|
188
|
-
return {
|
|
189
|
-
month: day === null || day === void 0 ? void 0 : (_day$getMonth = day.getMonth) === null || _day$getMonth === void 0 ? void 0 : _day$getMonth.call(day),
|
|
190
|
-
day: day === null || day === void 0 ? void 0 : (_day$getDate = day.getDate) === null || _day$getDate === void 0 ? void 0 : _day$getDate.call(day),
|
|
191
|
-
year: day === null || day === void 0 ? void 0 : (_day$getFullYear = day.getFullYear) === null || _day$getFullYear === void 0 ? void 0 : _day$getFullYear.call(day)
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
const getDateStringFromDay = day => {
|
|
195
|
-
const monthFromDay = prependStringWithPlaceHolders("".concat(day.getMonth() + 1), 2); // months from 1-12
|
|
196
|
-
|
|
197
|
-
const dayFromDay = prependStringWithPlaceHolders("".concat(day.getDate()), 2);
|
|
198
|
-
const yearFromDay = prependStringWithPlaceHolders("".concat(day.getFullYear()), 4);
|
|
199
|
-
return "".concat(monthFromDay, "/").concat(dayFromDay, "/").concat(yearFromDay);
|
|
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
|
-
};
|
|
210
|
-
const getDayFromDateString = dateString => {
|
|
211
|
-
const {
|
|
212
|
-
month,
|
|
213
|
-
day,
|
|
214
|
-
year
|
|
215
|
-
} = deconstructValuesFromDateString(dateString);
|
|
216
|
-
const monthNum = convertToPositiveNumberIfPossible(month);
|
|
217
|
-
const dayNum = convertToPositiveNumberIfPossible(day);
|
|
218
|
-
const yearNum = convertToPositiveNumberIfPossible(year);
|
|
219
|
-
if (monthNum !== -1 && dayNum !== -1 && yearNum !== -1 && isValidDayForTheMonth(monthNum - 1, yearNum, dayNum)) return new Date(yearNum, monthNum - 1, dayNum);
|
|
220
|
-
return null;
|
|
221
|
-
};
|
|
222
|
-
const getMonthNameByMonthNumber = monthNumber => monthNames[monthNumber];
|
|
223
|
-
const isSameDateMoment = (dateA, dateB) => {
|
|
224
|
-
var _dateA$getTime, _dateB$getTime;
|
|
225
|
-
|
|
226
|
-
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));
|
|
227
|
-
};
|
|
228
|
-
const compareTwoDatesDayEquality = (dayA, dayB) => {
|
|
229
|
-
const {
|
|
230
|
-
day: currD,
|
|
231
|
-
month: currM,
|
|
232
|
-
year: currY
|
|
233
|
-
} = getDateValuesFromDate(dayA);
|
|
234
|
-
const {
|
|
235
|
-
day: focusD,
|
|
236
|
-
month: focusM,
|
|
237
|
-
year: focusY
|
|
238
|
-
} = getDateValuesFromDate(dayB);
|
|
239
|
-
return currD === focusD && currM === focusM && currY === focusY;
|
|
240
|
-
};
|
|
241
241
|
|
|
242
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 };
|
package/esm/date-time-picker/utils/hooks/useGetMonthYearFromDateStringOrEmptyStartingMonth.js
CHANGED
|
@@ -5,12 +5,9 @@ import { deconstructValuesFromDateString } from '../stringHelpers.js';
|
|
|
5
5
|
const useGetMonthYearFromDateStringOrEmptyStartingMonth = () => {
|
|
6
6
|
const {
|
|
7
7
|
dateStringFromProps,
|
|
8
|
-
|
|
9
|
-
emptyPickerStartingMonth
|
|
10
|
-
}
|
|
8
|
+
emptyPickerStartingMonth
|
|
11
9
|
} = useContext(ControlledDateTimePickerContext);
|
|
12
10
|
return useMemo(() => {
|
|
13
|
-
const emptyPickerStartingMonthDefault = "".concat(new Date().getMonth() + 1, "/__/").concat(new Date().getFullYear());
|
|
14
11
|
const {
|
|
15
12
|
month: stringMonthVal,
|
|
16
13
|
year: stringYearVal
|
|
@@ -18,7 +15,7 @@ const useGetMonthYearFromDateStringOrEmptyStartingMonth = () => {
|
|
|
18
15
|
const {
|
|
19
16
|
month: emptyStringSplitMonth,
|
|
20
17
|
year: emptyStringSplitYear
|
|
21
|
-
} = deconstructValuesFromDateString(emptyPickerStartingMonth
|
|
18
|
+
} = deconstructValuesFromDateString(emptyPickerStartingMonth);
|
|
22
19
|
const userEmptyStringMonth = Number.parseInt(emptyStringSplitMonth, 10);
|
|
23
20
|
const userEmptyStringYear = Number.parseInt(emptyStringSplitYear, 10);
|
|
24
21
|
const month = stringMonthVal === '' || stringMonthVal.length !== 2 ? userEmptyStringMonth - 1 : Number.parseInt(stringMonthVal, 10) - 1; // month is 0~11 in javascript Date...
|
|
@@ -1,3 +1,9 @@
|
|
|
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';
|
|
6
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
1
7
|
import { useContext, useMemo } from 'react';
|
|
2
8
|
import { ControlledDateTimePickerContext } from '../../ControlledDateTimePickerCTX.js';
|
|
3
9
|
import { deconstructValuesFromDateString } from '../stringHelpers.js';
|
|
@@ -5,7 +11,9 @@ import { convertToPositiveNumberIfPossible } from '../numberHelpers.js';
|
|
|
5
11
|
import { getDateValuesFromDate, isValidDayForTheMonth } from '../dateHelpers.js';
|
|
6
12
|
import { useGetDayFromDateString } from './useGetDayFromDateString.js';
|
|
7
13
|
|
|
8
|
-
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
9
17
|
const empty = {
|
|
10
18
|
startFocusedYear: null,
|
|
11
19
|
startFocusedDay: null,
|
|
@@ -14,61 +22,52 @@ const empty = {
|
|
|
14
22
|
};
|
|
15
23
|
const useGetStartingFocusedDay = () => {
|
|
16
24
|
const {
|
|
17
|
-
|
|
18
|
-
onCalendarOpenFocusedDay
|
|
19
|
-
}
|
|
25
|
+
onCalendarOpenFocusedDay
|
|
20
26
|
} = useContext(ControlledDateTimePickerContext);
|
|
21
27
|
const dayFromInputValues = useGetDayFromDateString();
|
|
22
28
|
return useMemo(() => {
|
|
23
|
-
const {
|
|
24
|
-
month: inputValuesSplitMonth,
|
|
25
|
-
day: inputValuesSplitDay,
|
|
26
|
-
year: inputValuesDaySplitYear
|
|
27
|
-
} = getDateValuesFromDate(dayFromInputValues);
|
|
28
|
-
let startFocusedMonth = null;
|
|
29
|
-
let startFocusedDay = null;
|
|
30
|
-
let startFocusedYear = null;
|
|
31
|
-
let startFocusedDate = null;
|
|
32
|
-
const isInputFilledAndValid = inputValuesSplitMonth && inputValuesSplitDay && inputValuesDaySplitYear && isValidDayForTheMonth(inputValuesSplitMonth, inputValuesDaySplitYear, inputValuesSplitDay);
|
|
33
|
-
const isOnCalendarOpenFocusedDayEmpty = !onCalendarOpenFocusedDay;
|
|
34
|
-
const shouldFillWithOnCalendarOpenFocusedDay = !isInputFilledAndValid && !isOnCalendarOpenFocusedDayEmpty; // if input was filled start focus is the filled value (if it's valid day for the month)
|
|
35
|
-
|
|
36
|
-
if (isInputFilledAndValid) {
|
|
37
|
-
startFocusedMonth = inputValuesSplitMonth;
|
|
38
|
-
startFocusedDay = inputValuesSplitDay;
|
|
39
|
-
startFocusedYear = inputValuesDaySplitYear;
|
|
40
|
-
startFocusedDate = dayFromInputValues; // if input was not filled (or filled invalid) and there is no onCalendarOpenFocusedDay start focus is not a day
|
|
41
|
-
} // if input was not filled and there is onCalendarOpenFocusedDay start focus is onCalendarOpenFocusedDay day
|
|
29
|
+
const startingDay = _objectSpread({}, empty);
|
|
42
30
|
|
|
43
|
-
|
|
44
|
-
if (!isInputFilledAndValid && isOnCalendarOpenFocusedDayEmpty) return empty;
|
|
45
|
-
|
|
46
|
-
if (shouldFillWithOnCalendarOpenFocusedDay) {
|
|
31
|
+
if (dayFromInputValues) {
|
|
47
32
|
const {
|
|
48
|
-
month:
|
|
49
|
-
day:
|
|
50
|
-
year:
|
|
51
|
-
} =
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
33
|
+
month: inputValuesSplitMonth,
|
|
34
|
+
day: inputValuesSplitDay,
|
|
35
|
+
year: inputValuesDaySplitYear
|
|
36
|
+
} = getDateValuesFromDate(dayFromInputValues);
|
|
37
|
+
const isInputFilledAndValid = inputValuesSplitMonth && inputValuesSplitDay && inputValuesDaySplitYear && isValidDayForTheMonth(inputValuesSplitMonth, inputValuesDaySplitYear, inputValuesSplitDay);
|
|
38
|
+
const isOnCalendarOpenFocusedDayEmpty = !onCalendarOpenFocusedDay;
|
|
39
|
+
const shouldFillWithOnCalendarOpenFocusedDay = !isInputFilledAndValid && !isOnCalendarOpenFocusedDayEmpty; // if input was filled start focus is the filled value (if it's valid day for the month)
|
|
40
|
+
|
|
41
|
+
if (isInputFilledAndValid) {
|
|
42
|
+
startingDay.startFocusedMonth = inputValuesSplitMonth;
|
|
43
|
+
startingDay.startFocusedDay = inputValuesSplitDay;
|
|
44
|
+
startingDay.startFocusedYear = inputValuesDaySplitYear;
|
|
45
|
+
startingDay.startFocusedDate = dayFromInputValues; // if input was not filled (or filled invalid) and there is no onCalendarOpenFocusedDay start focus is not a day
|
|
46
|
+
} else if (isOnCalendarOpenFocusedDayEmpty) {
|
|
47
|
+
// if input was not filled and there is onCalendarOpenFocusedDay start focus is onCalendarOpenFocusedDay day
|
|
48
|
+
return empty;
|
|
49
|
+
} else if (shouldFillWithOnCalendarOpenFocusedDay) {
|
|
50
|
+
const {
|
|
51
|
+
month: focusedDaySplitMonth,
|
|
52
|
+
day: focusedDaySplitDay,
|
|
53
|
+
year: focusedDaySplitYear
|
|
54
|
+
} = deconstructValuesFromDateString(onCalendarOpenFocusedDay);
|
|
55
|
+
const monthAsInt = convertToPositiveNumberIfPossible(focusedDaySplitMonth);
|
|
56
|
+
const dayAsInt = convertToPositiveNumberIfPossible(focusedDaySplitDay);
|
|
57
|
+
const yearAsInt = convertToPositiveNumberIfPossible(focusedDaySplitYear); // if this condition is false, return will be the same as return empty
|
|
58
|
+
// because startFocusedMonth/Day/Year/Date will be === null
|
|
59
|
+
// which is the expected result
|
|
57
60
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
if (monthAsInt !== -1 && dayAsInt !== -1 && yearAsInt !== -1 && isValidDayForTheMonth(monthAsInt - 1, yearAsInt, dayAsInt)) {
|
|
62
|
+
startingDay.startFocusedMonth = monthAsInt;
|
|
63
|
+
startingDay.startFocusedDay = dayAsInt;
|
|
64
|
+
startingDay.startFocusedYear = yearAsInt;
|
|
65
|
+
startingDay.startFocusedDate = new Date(yearAsInt, monthAsInt - 1, dayAsInt);
|
|
66
|
+
}
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
69
|
|
|
66
|
-
return
|
|
67
|
-
startFocusedYear,
|
|
68
|
-
startFocusedDay,
|
|
69
|
-
startFocusedMonth,
|
|
70
|
-
startFocusedDate
|
|
71
|
-
};
|
|
70
|
+
return startingDay;
|
|
72
71
|
}, [dayFromInputValues, onCalendarOpenFocusedDay]);
|
|
73
72
|
};
|
|
74
73
|
|
|
@@ -6,10 +6,9 @@ const useOnClickOutside = (ref, handler) => {
|
|
|
6
6
|
var _ref$contains;
|
|
7
7
|
|
|
8
8
|
// Do nothing if clicking ref's element or descendent elements
|
|
9
|
-
if (!ref || ref !== null && ref !== void 0 && (_ref$contains = ref.contains) !== null && _ref$contains !== void 0 && _ref$contains.call(ref, event.target)) {
|
|
9
|
+
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)) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
12
|
handler(event);
|
|
14
13
|
};
|
|
15
14
|
|
|
@@ -6,7 +6,6 @@ import { monthNames, announcableCardinalDays } from './constants.js';
|
|
|
6
6
|
import { convertToPositiveNumberIfPossible } from './numberHelpers.js';
|
|
7
7
|
|
|
8
8
|
/* eslint-disable max-lines */
|
|
9
|
-
|
|
10
9
|
const prependStringWithPlaceHolders = function (val, finalLength) {
|
|
11
10
|
let placeholder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '0';
|
|
12
11
|
if (val.length === finalLength) return val;
|
|
@@ -36,7 +35,7 @@ const dateTimeToDate = dateTime => {
|
|
|
36
35
|
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];
|
|
37
36
|
};
|
|
38
37
|
const deconstructValuesFromDateString = dateString => {
|
|
39
|
-
const [dirtyMonth = '', dirtyDay = '', dirtyYear = ''] = dateString
|
|
38
|
+
const [dirtyMonth = '', dirtyDay = '', dirtyYear = ''] = dateString.split('/');
|
|
40
39
|
const replaceAllRegexp = /_/g;
|
|
41
40
|
return {
|
|
42
41
|
month: (dirtyMonth || '').replace(replaceAllRegexp, ''),
|
|
@@ -45,8 +44,8 @@ const deconstructValuesFromDateString = dateString => {
|
|
|
45
44
|
};
|
|
46
45
|
};
|
|
47
46
|
const deconstructValuesFromTimeString = timeString => {
|
|
48
|
-
const [dirtyHour = '', dirtyMintuesAndMeridiem = ''] = timeString
|
|
49
|
-
const [dirtyMinutes = '', dirtyMeridiem = ''] = dirtyMintuesAndMeridiem
|
|
47
|
+
const [dirtyHour = '', dirtyMintuesAndMeridiem = ''] = timeString.split(':');
|
|
48
|
+
const [dirtyMinutes = '', dirtyMeridiem = ''] = dirtyMintuesAndMeridiem.split(' ');
|
|
50
49
|
const replaceAllRegexp = /_/g;
|
|
51
50
|
return {
|
|
52
51
|
hours: (dirtyHour || '').replace(replaceAllRegexp, ''),
|
|
@@ -83,26 +82,21 @@ const getFormattedTimeString = _ref2 => {
|
|
|
83
82
|
return "".concat(finalHour, ":").concat(finalMinutes, " ").concat(finalMeridiem);
|
|
84
83
|
};
|
|
85
84
|
const dateTimeToTime = dateTime => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
_date, // timeNumbers = '__:__:__', // <-- seconds format
|
|
90
|
-
timeNumbers = '__:__', timeMeridiem = '__'] = dateTime === null || dateTime === void 0 ? void 0 : (_dateTime$split2 = dateTime.split) === null || _dateTime$split2 === void 0 ? void 0 : _dateTime$split2.call(dateTime, ' ');
|
|
85
|
+
const [// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
|
|
86
|
+
date, // timeNumbers = '__:__:__', // <-- seconds format
|
|
87
|
+
timeNumbers = '__:__', timeMeridiem = '__'] = dateTime.split(' ');
|
|
91
88
|
return "".concat(timeNumbers, " ").concat(timeMeridiem);
|
|
92
89
|
};
|
|
93
90
|
const deconstructTimeValues = timeString => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
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, ' '); // <--['__:__','__']
|
|
91
|
+
const [dirtyTimes = '', dirtyMeridiem] = timeString.split(' '); // <--['__:__','__']
|
|
97
92
|
|
|
98
|
-
const [dirtyHours, dirtyMinutes] =
|
|
93
|
+
const [dirtyHours, dirtyMinutes] = dirtyTimes.split(':'); // <--['__','__']
|
|
99
94
|
|
|
100
95
|
const regex = /_/g; // Note the 'g' flag, which matches all occurrences of the expression
|
|
101
96
|
|
|
102
97
|
const newValues = {
|
|
103
98
|
hours: (dirtyHours || '').replace(regex, ''),
|
|
104
99
|
minutes: (dirtyMinutes || '').replace(regex, ''),
|
|
105
|
-
// seconds: (dirtySeconds||"").replace(regex, ''),
|
|
106
100
|
meridiem: (dirtyMeridiem || '').replace(regex, '')
|
|
107
101
|
};
|
|
108
102
|
return newValues;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const dateTimeTypes = ['full-date-time', 'date-time-inputs', 'date-time-picker', 'date-time-picker-controller-only'];
|
|
2
|
+
const dateTypes = ['full-date', 'date-inputs', 'date-picker', 'date-picker-controller-only'];
|
|
3
|
+
const timeTypes = ['full-time', 'time-inputs', 'time-picker', 'time-picker-controller-only'];
|
|
4
|
+
const getIsDateTime = props => dateTimeTypes.includes(props.type);
|
|
5
|
+
const getIsDate = props => dateTypes.includes(props.type);
|
|
6
|
+
const getIsTime = props => timeTypes.includes(props.type);
|
|
7
|
+
|
|
8
|
+
export { getIsDate, getIsDateTime, getIsTime };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-controlled-form",
|
|
3
|
-
"version": "2.4.1
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Controlled Form Controllers",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -159,6 +159,10 @@
|
|
|
159
159
|
"import": "./esm/large-text-input/DSControlledLargeTextInput.js",
|
|
160
160
|
"require": "./cjs/large-text-input/DSControlledLargeTextInput.js"
|
|
161
161
|
},
|
|
162
|
+
"./date-time-picker/utils/typeGuards": {
|
|
163
|
+
"import": "./esm/date-time-picker/utils/typeGuards.js",
|
|
164
|
+
"require": "./cjs/date-time-picker/utils/typeGuards.js"
|
|
165
|
+
},
|
|
162
166
|
"./date-time-picker/utils/timeHelpers": {
|
|
163
167
|
"import": "./esm/date-time-picker/utils/timeHelpers.js",
|
|
164
168
|
"require": "./cjs/date-time-picker/utils/timeHelpers.js"
|
|
@@ -199,6 +203,10 @@
|
|
|
199
203
|
"import": "./esm/date-time-picker/utils/constants.js",
|
|
200
204
|
"require": "./cjs/date-time-picker/utils/constants.js"
|
|
201
205
|
},
|
|
206
|
+
"./date-time-picker/sharedTypes": {
|
|
207
|
+
"import": "./esm/date-time-picker/sharedTypes.js",
|
|
208
|
+
"require": "./cjs/date-time-picker/sharedTypes.js"
|
|
209
|
+
},
|
|
202
210
|
"./date-time-picker/propTypes": {
|
|
203
211
|
"import": "./esm/date-time-picker/propTypes.js",
|
|
204
212
|
"require": "./cjs/date-time-picker/propTypes.js"
|
|
@@ -455,10 +463,30 @@
|
|
|
455
463
|
"import": "./esm/date-time-picker/config/useValidateProps.js",
|
|
456
464
|
"require": "./cjs/date-time-picker/config/useValidateProps.js"
|
|
457
465
|
},
|
|
466
|
+
"./date-time-picker/config/useRelevantValueFromProps": {
|
|
467
|
+
"import": "./esm/date-time-picker/config/useRelevantValueFromProps.js",
|
|
468
|
+
"require": "./cjs/date-time-picker/config/useRelevantValueFromProps.js"
|
|
469
|
+
},
|
|
470
|
+
"./date-time-picker/config/useGlobalKeyHandlers": {
|
|
471
|
+
"import": "./esm/date-time-picker/config/useGlobalKeyHandlers.js",
|
|
472
|
+
"require": "./cjs/date-time-picker/config/useGlobalKeyHandlers.js"
|
|
473
|
+
},
|
|
474
|
+
"./date-time-picker/config/useGetReferences": {
|
|
475
|
+
"import": "./esm/date-time-picker/config/useGetReferences.js",
|
|
476
|
+
"require": "./cjs/date-time-picker/config/useGetReferences.js"
|
|
477
|
+
},
|
|
458
478
|
"./date-time-picker/config/useGetPropsWithDefault": {
|
|
459
479
|
"import": "./esm/date-time-picker/config/useGetPropsWithDefault.js",
|
|
460
480
|
"require": "./cjs/date-time-picker/config/useGetPropsWithDefault.js"
|
|
461
481
|
},
|
|
482
|
+
"./date-time-picker/config/useGetPropsBasedOnType": {
|
|
483
|
+
"import": "./esm/date-time-picker/config/useGetPropsBasedOnType.js",
|
|
484
|
+
"require": "./cjs/date-time-picker/config/useGetPropsBasedOnType.js"
|
|
485
|
+
},
|
|
486
|
+
"./date-time-picker/config/useGetFlags": {
|
|
487
|
+
"import": "./esm/date-time-picker/config/useGetFlags.js",
|
|
488
|
+
"require": "./cjs/date-time-picker/config/useGetFlags.js"
|
|
489
|
+
},
|
|
462
490
|
"./date-time-picker/config/useGetDestructuredValues": {
|
|
463
491
|
"import": "./esm/date-time-picker/config/useGetDestructuredValues.js",
|
|
464
492
|
"require": "./cjs/date-time-picker/config/useGetDestructuredValues.js"
|
|
@@ -467,6 +495,10 @@
|
|
|
467
495
|
"import": "./esm/date-time-picker/config/useControlledDateTimePicker.js",
|
|
468
496
|
"require": "./cjs/date-time-picker/config/useControlledDateTimePicker.js"
|
|
469
497
|
},
|
|
498
|
+
"./date-time-picker/config/useChangeHandlers": {
|
|
499
|
+
"import": "./esm/date-time-picker/config/useChangeHandlers.js",
|
|
500
|
+
"require": "./cjs/date-time-picker/config/useChangeHandlers.js"
|
|
501
|
+
},
|
|
470
502
|
"./date-range-picker/propTypes": {
|
|
471
503
|
"import": "./esm/date-range-picker/propTypes.js",
|
|
472
504
|
"require": "./cjs/date-range-picker/propTypes.js"
|
|
@@ -808,20 +840,20 @@
|
|
|
808
840
|
"build": "node ../../scripts/build/build.js"
|
|
809
841
|
},
|
|
810
842
|
"dependencies": {
|
|
811
|
-
"@elliemae/ds-button": "2.4.1
|
|
812
|
-
"@elliemae/ds-circular-progress-indicator": "2.4.1
|
|
813
|
-
"@elliemae/ds-controlled-form": "2.4.1
|
|
814
|
-
"@elliemae/ds-form": "2.4.1
|
|
815
|
-
"@elliemae/ds-form-layout-blocks": "2.4.1
|
|
816
|
-
"@elliemae/ds-grid": "2.4.1
|
|
817
|
-
"@elliemae/ds-icon": "2.4.1
|
|
818
|
-
"@elliemae/ds-icons": "2.4.1
|
|
819
|
-
"@elliemae/ds-pills": "2.4.1
|
|
820
|
-
"@elliemae/ds-popperjs": "2.4.1
|
|
821
|
-
"@elliemae/ds-props-helpers": "2.4.1
|
|
822
|
-
"@elliemae/ds-system": "2.4.1
|
|
823
|
-
"@elliemae/ds-tooltip": "2.4.1
|
|
824
|
-
"@elliemae/ds-truncated-tooltip-text": "2.4.1
|
|
843
|
+
"@elliemae/ds-button": "2.4.1",
|
|
844
|
+
"@elliemae/ds-circular-progress-indicator": "2.4.1",
|
|
845
|
+
"@elliemae/ds-controlled-form": "2.4.1",
|
|
846
|
+
"@elliemae/ds-form": "2.4.1",
|
|
847
|
+
"@elliemae/ds-form-layout-blocks": "2.4.1",
|
|
848
|
+
"@elliemae/ds-grid": "2.4.1",
|
|
849
|
+
"@elliemae/ds-icon": "2.4.1",
|
|
850
|
+
"@elliemae/ds-icons": "2.4.1",
|
|
851
|
+
"@elliemae/ds-pills": "2.4.1",
|
|
852
|
+
"@elliemae/ds-popperjs": "2.4.1",
|
|
853
|
+
"@elliemae/ds-props-helpers": "2.4.1",
|
|
854
|
+
"@elliemae/ds-system": "2.4.1",
|
|
855
|
+
"@elliemae/ds-tooltip": "2.4.1",
|
|
856
|
+
"@elliemae/ds-truncated-tooltip-text": "2.4.1",
|
|
825
857
|
"prop-types": "~15.7.2",
|
|
826
858
|
"react-desc": "~4.1.3",
|
|
827
859
|
"react-popper": "~2.2.5",
|