@elliemae/ds-date-time-picker 2.2.0-alpha.2 → 2.2.0-next.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/DSDateTimePicker.js +181 -160
- package/cjs/components/DateTimePickerImpl.js +218 -187
- package/cjs/index.js +10 -37
- package/cjs/lang/english.js +9 -39
- package/cjs/utils.js +19 -42
- package/esm/DSDateTimePicker.js +116 -77
- package/esm/components/DateTimePickerImpl.js +194 -143
- package/esm/index.js +1 -8
- package/esm/lang/english.js +6 -9
- package/esm/utils.js +10 -12
- package/package.json +7 -7
- package/types/DSDateTimePicker.d.ts +1 -1
- package/types/components/DateTimePickerImpl.d.ts +0 -1
- package/types/index.d.ts +1 -1
- package/cjs/DSDateTimePicker.js.map +0 -7
- package/cjs/components/DateTimePickerImpl.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/lang/english.js.map +0 -7
- package/cjs/tests/utils.js +0 -42
- package/cjs/tests/utils.js.map +0 -7
- package/cjs/utils.js.map +0 -7
- package/esm/DSDateTimePicker.js.map +0 -7
- package/esm/components/DateTimePickerImpl.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/lang/english.js.map +0 -7
- package/esm/tests/utils.js +0 -13
- package/esm/tests/utils.js.map +0 -7
- package/esm/utils.js.map +0 -7
package/esm/DSDateTimePicker.js
CHANGED
|
@@ -1,78 +1,111 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
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';
|
|
7
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
8
|
+
import 'react';
|
|
9
|
+
import { PropTypes, describe } from 'react-desc';
|
|
10
|
+
import moment from 'moment';
|
|
11
|
+
import { convertPropToCssClassName } from '@elliemae/ds-classnames';
|
|
12
|
+
import { SingleDatePickerPhrases } from '@elliemae/ds-date-picker';
|
|
13
|
+
import DSDateTimePickerImpl from './components/DateTimePickerImpl.js';
|
|
14
|
+
import english from './lang/english.js';
|
|
15
|
+
import { jsx } from 'react/jsx-runtime';
|
|
16
|
+
|
|
17
|
+
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; }
|
|
18
|
+
|
|
19
|
+
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
20
|
const {
|
|
10
21
|
placeholder: placeholderDefault,
|
|
11
22
|
className: classNameDefault,
|
|
12
23
|
id: idDefault
|
|
13
24
|
} = english;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
25
|
+
|
|
26
|
+
const DSDateTimePicker = _ref => {
|
|
27
|
+
let {
|
|
28
|
+
containerProps = {},
|
|
29
|
+
className = classNameDefault,
|
|
30
|
+
id = idDefault,
|
|
31
|
+
placeholder = placeholderDefault,
|
|
32
|
+
date,
|
|
33
|
+
clearable = false,
|
|
34
|
+
onBlur = () => null,
|
|
35
|
+
datePickerProps = {
|
|
36
|
+
disabled: false,
|
|
37
|
+
numberOfMonths: 1,
|
|
38
|
+
readOnly: false,
|
|
39
|
+
enableOutsideDays: false,
|
|
40
|
+
transitionDuration: 0,
|
|
41
|
+
firstDayOfWeek: 0,
|
|
42
|
+
keepOpenOnDateSelect: true,
|
|
43
|
+
hideKeyboardShortcutsPanel: true,
|
|
44
|
+
onPrevMonthClick: () => null,
|
|
45
|
+
onNextMonthClick: () => null,
|
|
46
|
+
onClose: () => null,
|
|
47
|
+
onchange: () => null,
|
|
48
|
+
onDateChange: () => null,
|
|
49
|
+
phrases: SingleDatePickerPhrases,
|
|
50
|
+
displayFormatDay: 'D',
|
|
51
|
+
isDayBlocked: () => false,
|
|
52
|
+
isOutsideRange: () => false,
|
|
53
|
+
isDayHighlighted: () => false,
|
|
54
|
+
zIndex: 11
|
|
55
|
+
},
|
|
56
|
+
timePickerProps = {
|
|
57
|
+
format: 'hh:mm A',
|
|
58
|
+
onChange: () => null,
|
|
59
|
+
disabledTimes: undefined,
|
|
60
|
+
minutesInterval: 1
|
|
61
|
+
},
|
|
62
|
+
dateInputProps = {
|
|
63
|
+
onDateInputDateChange: () => null
|
|
64
|
+
}
|
|
65
|
+
} = _ref;
|
|
66
|
+
const {
|
|
67
|
+
cssClassName
|
|
68
|
+
} = convertPropToCssClassName('datetimepicker', className, {
|
|
54
69
|
id
|
|
55
70
|
});
|
|
56
|
-
return
|
|
57
|
-
className: cssClassName
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
return /*#__PURE__*/jsx("div", _objectSpread(_objectSpread({
|
|
72
|
+
className: cssClassName
|
|
73
|
+
}, containerProps), {}, {
|
|
74
|
+
children: /*#__PURE__*/_jsx(DSDateTimePickerImpl, {
|
|
75
|
+
clearable: clearable,
|
|
76
|
+
date: date,
|
|
77
|
+
datePickerProps: datePickerProps,
|
|
78
|
+
onBlur: onBlur,
|
|
79
|
+
placeholder: placeholder,
|
|
80
|
+
timePickerProps: timePickerProps,
|
|
81
|
+
dateInputProps: dateInputProps
|
|
82
|
+
})
|
|
67
83
|
}));
|
|
68
84
|
};
|
|
85
|
+
|
|
69
86
|
const dateTimePickerProps = {
|
|
70
|
-
containerProps: PropTypes.object.description(
|
|
71
|
-
className: PropTypes.string.description(
|
|
72
|
-
id: PropTypes.string.description(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
87
|
+
containerProps: PropTypes.object.description('Set of Properties attached to the main container'),
|
|
88
|
+
className: PropTypes.string.description('html class attribute'),
|
|
89
|
+
id: PropTypes.string.description('components id'),
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* on blur callback
|
|
93
|
+
*/
|
|
94
|
+
onBlur: PropTypes.func.description('on blur callback'),
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Initial date, by default current date
|
|
98
|
+
*/
|
|
99
|
+
date: PropTypes.instanceOf(Date, moment).description('Initial date, by default current date'),
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Flag to trigger onDateChange on error
|
|
103
|
+
*/
|
|
104
|
+
clearable: PropTypes.bool.description('Flag to trigger onDateChange on error'),
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* DatePicker properties
|
|
108
|
+
*/
|
|
76
109
|
datePickerProps: PropTypes.shape({
|
|
77
110
|
disabled: PropTypes.bool,
|
|
78
111
|
numberOfMonths: PropTypes.number,
|
|
@@ -115,29 +148,35 @@ const dateTimePickerProps = {
|
|
|
115
148
|
chooseAvailableEndDate: PropTypes.func,
|
|
116
149
|
dateIsUnavailable: PropTypes.func,
|
|
117
150
|
dateIsSelected: PropTypes.func,
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* ZIndex for the picker popup
|
|
154
|
+
*/
|
|
118
155
|
zIndex: PropTypes.number
|
|
119
156
|
}),
|
|
120
157
|
displayFormatDay: PropTypes.string,
|
|
121
158
|
isDayBlocked: PropTypes.func,
|
|
122
159
|
isOutsideRange: PropTypes.func,
|
|
123
160
|
isDayHighlighted: PropTypes.func
|
|
124
|
-
}).description(
|
|
125
|
-
|
|
161
|
+
}).description('DatePicker properties'),
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Input placeholder
|
|
165
|
+
*/
|
|
166
|
+
placeholder: PropTypes.string.description('Input placeholder'),
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* TimePicker properties
|
|
170
|
+
*/
|
|
126
171
|
timePickerProps: PropTypes.shape({
|
|
127
172
|
format: PropTypes.string,
|
|
128
173
|
onChange: PropTypes.func
|
|
129
|
-
}).description(
|
|
174
|
+
}).description('TimePicker properties'),
|
|
130
175
|
dateInputProps: PropTypes.shape({
|
|
131
176
|
onDateInputDateChange: PropTypes.func
|
|
132
|
-
}).description(
|
|
177
|
+
}).description('DateInputProperties')
|
|
133
178
|
};
|
|
134
|
-
DSDateTimePicker.propTypes = dateTimePickerProps;
|
|
135
179
|
const DateTimePickerWithSchema = describe(DSDateTimePicker);
|
|
136
180
|
DateTimePickerWithSchema.propTypes = dateTimePickerProps;
|
|
137
|
-
|
|
138
|
-
export {
|
|
139
|
-
DSDateTimePicker,
|
|
140
|
-
DateTimePickerWithSchema,
|
|
141
|
-
DSDateTimePicker_default as default
|
|
142
|
-
};
|
|
143
|
-
//# sourceMappingURL=DSDateTimePicker.js.map
|
|
181
|
+
|
|
182
|
+
export { DateTimePickerWithSchema, DSDateTimePicker as default };
|
|
@@ -1,133 +1,178 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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 _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
7
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
8
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
9
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
10
|
+
import { useState, useRef, useEffect, useMemo } from 'react';
|
|
11
|
+
import moment from 'moment';
|
|
12
|
+
import { aggregatedClasses } from '@elliemae/ds-classnames';
|
|
13
|
+
import { DatePickerDropdown, DSDatePickerController, SingleDatePickerPhrases } from '@elliemae/ds-date-picker';
|
|
14
|
+
import { DSInputGroup, DSInput, DateInputsV2Impl, TimeInputImpl } from '@elliemae/ds-form';
|
|
15
|
+
import { getVisibleTimeByFormat } from '@elliemae/ds-utilities';
|
|
16
|
+
import { DSTimePickerMenu, convertTimeString } from '@elliemae/ds-time-picker';
|
|
17
|
+
import { updateDateAndTime } from '../utils.js';
|
|
18
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
19
|
+
|
|
20
|
+
const _excluded = ["onChange"];
|
|
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(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; }
|
|
25
|
+
const blockName = 'date-time-picker';
|
|
26
|
+
const DateTimePickerWrapper = aggregatedClasses('div')(blockName, 'wrapper');
|
|
27
|
+
const TimePicker = aggregatedClasses(DSTimePickerMenu)(blockName, 'time-picker');
|
|
28
|
+
const TimePickerWrapper = aggregatedClasses('div')(blockName, 'time-picker-wrapper'); // const DateInput = aggregatedClasses(DateInputsV2Impl)(blockName, 'date-input');
|
|
29
|
+
|
|
30
|
+
const formatDate = 'MMDDYYYY';
|
|
31
|
+
|
|
32
|
+
const DSDateTimePickerImpl = _ref => {
|
|
33
|
+
let {
|
|
34
|
+
onBlur = () => null,
|
|
35
|
+
placeholder,
|
|
36
|
+
date,
|
|
37
|
+
clearable,
|
|
38
|
+
datePickerProps: {
|
|
39
|
+
disabled = false,
|
|
40
|
+
numberOfMonths = 1,
|
|
41
|
+
readOnly = false,
|
|
42
|
+
enableOutsideDays = false,
|
|
43
|
+
transitionDuration = 0,
|
|
44
|
+
firstDayOfWeek = 0,
|
|
45
|
+
keepOpenOnDateSelect = true,
|
|
46
|
+
hideKeyboardShortcutsPanel = true,
|
|
47
|
+
onPrevMonthClick = () => null,
|
|
48
|
+
onNextMonthClick = () => null,
|
|
49
|
+
onClose = () => null,
|
|
50
|
+
onChange: onDatePickerChange = () => null,
|
|
51
|
+
onDateChange = () => null,
|
|
52
|
+
onError: onErrorDate = () => null,
|
|
53
|
+
phrases = SingleDatePickerPhrases,
|
|
54
|
+
displayFormatDay = 'D',
|
|
55
|
+
isDayBlocked = () => false,
|
|
56
|
+
isOutsideRange = () => false,
|
|
57
|
+
isDayHighlighted = () => false,
|
|
58
|
+
zIndex = 11
|
|
59
|
+
},
|
|
60
|
+
timePickerProps: {
|
|
61
|
+
format = 'hh:mm A',
|
|
62
|
+
onChange: onChangeTimePicker = () => null,
|
|
63
|
+
disabledTimes = undefined,
|
|
64
|
+
onError: onErrorTime = () => null,
|
|
65
|
+
minutesInterval = 1
|
|
66
|
+
},
|
|
67
|
+
dateInputProps: {
|
|
68
|
+
onDateInputDateChange = () => null
|
|
69
|
+
}
|
|
70
|
+
} = _ref;
|
|
71
|
+
const [selectedDate, setSelectedDate] = useState(undefined);
|
|
72
|
+
const [incompleteInput, setIncompleteInput] = useState(undefined);
|
|
53
73
|
const [isOpen, setIsOpen] = useState(false);
|
|
54
74
|
const disabledTimeRange = disabledTimes && {
|
|
55
75
|
from: convertTimeString(disabledTimes.from),
|
|
56
76
|
to: convertTimeString(disabledTimes.to)
|
|
57
77
|
};
|
|
58
78
|
const dateTimePickerWrapperRef = useRef();
|
|
59
|
-
const fullFormat =
|
|
79
|
+
const fullFormat = "".concat(formatDate, " ").concat(format);
|
|
60
80
|
useEffect(() => {
|
|
61
81
|
if (date) {
|
|
62
82
|
setSelectedDate(moment(date));
|
|
63
|
-
} else if (date === null)
|
|
64
|
-
setSelectedDate(void 0);
|
|
83
|
+
} else if (date === null) setSelectedDate(undefined);
|
|
65
84
|
}, [date]);
|
|
66
85
|
const visiblePanels = useMemo(() => getVisibleTimeByFormat(format), []);
|
|
67
86
|
const currentYear = moment().year();
|
|
68
|
-
|
|
87
|
+
|
|
88
|
+
const handleDatePickerChange = dateSelected => {
|
|
69
89
|
const splittedDate = updateDateAndTime(dateSelected, selectedDate);
|
|
90
|
+
|
|
70
91
|
if (!readOnly) {
|
|
71
92
|
setSelectedDate(splittedDate);
|
|
72
93
|
onDateChange(splittedDate);
|
|
73
94
|
}
|
|
74
95
|
};
|
|
75
|
-
|
|
96
|
+
|
|
97
|
+
const onTimeChange = pickerTime => {
|
|
76
98
|
const splittedDate = updateDateAndTime(selectedDate, pickerTime);
|
|
77
99
|
onChangeTimePicker(splittedDate);
|
|
78
100
|
setSelectedDate(splittedDate);
|
|
79
101
|
};
|
|
102
|
+
|
|
80
103
|
const handleInputChange = (inputValue, type) => {
|
|
81
104
|
onDatePickerChange(inputValue);
|
|
82
105
|
let timeBlocked = false;
|
|
83
106
|
const inputMoment = moment(inputValue, fullFormat);
|
|
84
107
|
setIncompleteInput(inputValue);
|
|
85
|
-
|
|
108
|
+
|
|
109
|
+
if (type === 'date') {
|
|
86
110
|
const splittedDate = updateDateAndTime(inputMoment, selectedDate);
|
|
111
|
+
|
|
87
112
|
if (inputValue.length < 8) {
|
|
88
|
-
onErrorDate({
|
|
89
|
-
|
|
90
|
-
|
|
113
|
+
onErrorDate({
|
|
114
|
+
message: 'date incomplete',
|
|
115
|
+
inputValue
|
|
116
|
+
});
|
|
117
|
+
if (clearable) onDateChange('error');
|
|
91
118
|
return;
|
|
92
119
|
}
|
|
120
|
+
|
|
93
121
|
if (inputValue.length === 8 && inputMoment.isValid()) {
|
|
94
122
|
setSelectedDate(splittedDate);
|
|
95
123
|
onChangeTimePicker(splittedDate);
|
|
96
124
|
}
|
|
125
|
+
|
|
97
126
|
onDateChange(splittedDate);
|
|
98
127
|
return;
|
|
99
128
|
}
|
|
129
|
+
|
|
100
130
|
if (disabledTimeRange) {
|
|
101
131
|
const hour = inputValue.hour();
|
|
102
132
|
const min = inputValue.minutes();
|
|
103
|
-
const {
|
|
133
|
+
const {
|
|
134
|
+
from,
|
|
135
|
+
to
|
|
136
|
+
} = disabledTimeRange;
|
|
137
|
+
|
|
104
138
|
if (hour > from.hour && hour < to.hour || hour === to.hour && min < to.min) {
|
|
105
139
|
timeBlocked = true;
|
|
106
140
|
}
|
|
107
141
|
}
|
|
108
|
-
|
|
109
|
-
|
|
142
|
+
|
|
143
|
+
if (timeBlocked) onErrorTime({
|
|
144
|
+
message: 'time blocked',
|
|
145
|
+
inputValue
|
|
146
|
+
});
|
|
110
147
|
const dateBlocked = isDayBlocked(inputMoment);
|
|
111
|
-
if (dateBlocked)
|
|
112
|
-
|
|
148
|
+
if (dateBlocked) onErrorDate({
|
|
149
|
+
message: 'date blocked',
|
|
150
|
+
inputValue
|
|
151
|
+
});
|
|
152
|
+
|
|
113
153
|
if (!timeBlocked && !dateBlocked) {
|
|
114
154
|
onDateChange(inputValue);
|
|
115
155
|
}
|
|
116
156
|
};
|
|
117
|
-
|
|
157
|
+
|
|
158
|
+
const handleOutsideClick = event => {
|
|
118
159
|
if (!dateTimePickerWrapperRef.current.contains(event.target)) {
|
|
119
160
|
setIsOpen(false);
|
|
120
161
|
}
|
|
121
162
|
};
|
|
163
|
+
|
|
122
164
|
const handleClickEscape = () => setIsOpen(false);
|
|
165
|
+
|
|
123
166
|
const handleOpen = () => setIsOpen(true);
|
|
124
|
-
|
|
167
|
+
|
|
168
|
+
const handleContainerBlur = event => {
|
|
125
169
|
if (!isOpen && !event.currentTarget.contains(event.relatedTarget)) {
|
|
126
|
-
onBlur(event, selectedDate
|
|
170
|
+
onBlur(event, selectedDate !== null && selectedDate !== void 0 && selectedDate.isValid() ? selectedDate : {
|
|
127
171
|
error: true,
|
|
128
|
-
message:
|
|
172
|
+
message: 'incomplete input',
|
|
129
173
|
input: incompleteInput
|
|
130
174
|
});
|
|
175
|
+
|
|
131
176
|
if (clearable && !selectedDate && !!incompleteInput) {
|
|
132
177
|
const inputMoment = moment(incompleteInput, fullFormat);
|
|
133
178
|
const splittedDate = updateDateAndTime(inputMoment, selectedDate);
|
|
@@ -136,90 +181,96 @@ const DSDateTimePickerImpl = ({
|
|
|
136
181
|
}
|
|
137
182
|
}
|
|
138
183
|
};
|
|
184
|
+
|
|
139
185
|
useEffect(() => {
|
|
140
|
-
if (!isOpen)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
});
|
|
186
|
+
if (!isOpen) onBlur({}, selectedDate !== null && selectedDate !== void 0 && selectedDate.isValid() ? selectedDate : {
|
|
187
|
+
error: true,
|
|
188
|
+
message: 'incomplete input',
|
|
189
|
+
input: incompleteInput
|
|
190
|
+
});
|
|
146
191
|
}, [isOpen]);
|
|
147
192
|
const hasSelectedDate = !!selectedDate;
|
|
148
|
-
return
|
|
193
|
+
return /*#__PURE__*/_jsx(DSInputGroup, {
|
|
149
194
|
containerProps: {
|
|
150
195
|
onBlur: handleContainerBlur
|
|
151
196
|
},
|
|
152
|
-
rightAddon:
|
|
153
|
-
disabled,
|
|
154
|
-
isOpen,
|
|
155
|
-
zIndex,
|
|
156
|
-
menu:
|
|
197
|
+
rightAddon: /*#__PURE__*/_jsx(DatePickerDropdown, {
|
|
198
|
+
disabled: disabled,
|
|
199
|
+
isOpen: isOpen,
|
|
200
|
+
zIndex: zIndex,
|
|
201
|
+
menu: /*#__PURE__*/jsxs(DateTimePickerWrapper, {
|
|
157
202
|
ref: dateTimePickerWrapperRef,
|
|
158
|
-
"data-testid": "date-time-picker"
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
})
|
|
203
|
+
"data-testid": "date-time-picker",
|
|
204
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
205
|
+
className: hasSelectedDate ? 'has-selected-date' : 'without-selected-date',
|
|
206
|
+
"data-testid": "date-time-picker-portal-wrapper"
|
|
207
|
+
}, void 0, /*#__PURE__*/_jsx(DSDatePickerController, {
|
|
208
|
+
date: selectedDate,
|
|
209
|
+
displayFormatDay: displayFormatDay,
|
|
210
|
+
enableOutsideDays: enableOutsideDays,
|
|
211
|
+
firstDayOfWeek: firstDayOfWeek,
|
|
212
|
+
hideKeyboardShortcutsPanel: hideKeyboardShortcutsPanel,
|
|
213
|
+
isDayBlocked: isDayBlocked,
|
|
214
|
+
isDayHighlighted: isDayHighlighted,
|
|
215
|
+
isOutsideRange: isOutsideRange,
|
|
216
|
+
keepOpenOnDateSelect: keepOpenOnDateSelect,
|
|
217
|
+
numberOfMonths: numberOfMonths,
|
|
218
|
+
onClickEscape: handleClickEscape,
|
|
219
|
+
onClose: onClose,
|
|
220
|
+
onDateChange: handleDatePickerChange,
|
|
221
|
+
onNextMonthClick: onNextMonthClick,
|
|
222
|
+
onOutsideClick: event => handleOutsideClick(event),
|
|
223
|
+
onPrevMonthClick: onPrevMonthClick,
|
|
224
|
+
phrases: phrases,
|
|
225
|
+
transitionDuration: transitionDuration
|
|
226
|
+
})), /*#__PURE__*/_jsx(TimePickerWrapper, {}, void 0, /*#__PURE__*/jsx(TimePicker, _objectSpread({
|
|
227
|
+
disabled: disabled,
|
|
228
|
+
disabledTimes: disabledTimeRange,
|
|
229
|
+
format: format,
|
|
230
|
+
hasHeader: true,
|
|
231
|
+
hasHeaderDisplay: true,
|
|
232
|
+
onTimeChange: onTimeChange,
|
|
233
|
+
showSeconds: false,
|
|
234
|
+
minutesInterval: minutesInterval,
|
|
235
|
+
time: selectedDate
|
|
236
|
+
}, visiblePanels)))]
|
|
237
|
+
}),
|
|
193
238
|
onClick: handleOpen,
|
|
194
|
-
readOnly
|
|
239
|
+
readOnly: readOnly
|
|
195
240
|
})
|
|
196
|
-
},
|
|
197
|
-
customInputType:
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
241
|
+
}, void 0, /*#__PURE__*/_jsx(DSInput, {
|
|
242
|
+
customInputType: _ref2 => {
|
|
243
|
+
let {
|
|
244
|
+
onChange: handleChange
|
|
245
|
+
} = _ref2,
|
|
246
|
+
restInputProps = _objectWithoutProperties(_ref2, _excluded);
|
|
247
|
+
|
|
248
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
249
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
250
|
+
style: {
|
|
251
|
+
display: 'flex'
|
|
252
|
+
}
|
|
253
|
+
}, void 0, /*#__PURE__*/jsx(DateInputsV2Impl, _objectSpread(_objectSpread({
|
|
254
|
+
disabled: disabled,
|
|
255
|
+
onChange: input => handleChange(input, 'date')
|
|
256
|
+
}, restInputProps), {}, {
|
|
257
|
+
onDateChange: onDateInputDateChange,
|
|
258
|
+
yearMaxRange: currentYear + 100,
|
|
259
|
+
yearMinRange: currentYear - 100,
|
|
260
|
+
time: restInputProps.value && restInputProps.value.hour && restInputProps.value.isValid() ? restInputProps.value.format(formatDate) : restInputProps.value
|
|
261
|
+
}))), /*#__PURE__*/jsx(TimeInputImpl, _objectSpread({
|
|
262
|
+
disabled: disabled,
|
|
263
|
+
format: format,
|
|
264
|
+
onChange: time => handleChange(time, 'time')
|
|
265
|
+
}, restInputProps))]
|
|
266
|
+
});
|
|
267
|
+
},
|
|
213
268
|
isShowElipsisActive: false,
|
|
214
|
-
disabled,
|
|
269
|
+
disabled: disabled,
|
|
215
270
|
onChange: handleInputChange,
|
|
216
|
-
placeholder,
|
|
271
|
+
placeholder: placeholder,
|
|
217
272
|
value: selectedDate
|
|
218
273
|
}));
|
|
219
274
|
};
|
|
220
|
-
|
|
221
|
-
export {
|
|
222
|
-
DSDateTimePickerImpl,
|
|
223
|
-
DateTimePickerImpl_default as default
|
|
224
|
-
};
|
|
225
|
-
//# sourceMappingURL=DateTimePickerImpl.js.map
|
|
275
|
+
|
|
276
|
+
export { DSDateTimePickerImpl as default };
|
package/esm/index.js
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { default as default2, DSDateTimePicker, DateTimePickerWithSchema } from "./DSDateTimePicker";
|
|
3
|
-
export {
|
|
4
|
-
DSDateTimePicker,
|
|
5
|
-
DateTimePickerWithSchema,
|
|
6
|
-
default2 as default
|
|
7
|
-
};
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { DateTimePickerWithSchema, default } from './DSDateTimePicker.js';
|