@elliemae/ds-date-time-picker 2.3.1 → 3.0.0-alpha.3
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/dist/cjs/DSDateTimePicker.js +185 -0
- package/dist/cjs/DSDateTimePicker.js.map +7 -0
- package/dist/cjs/components/DateTimePickerImpl.js +284 -0
- package/dist/cjs/components/DateTimePickerImpl.js.map +7 -0
- package/dist/cjs/index.js +37 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/lang/english.js +39 -0
- package/dist/cjs/lang/english.js.map +7 -0
- package/dist/cjs/tests/utils.js +54 -0
- package/dist/cjs/tests/utils.js.map +7 -0
- package/dist/cjs/utils.js +45 -0
- package/dist/cjs/utils.js.map +7 -0
- package/dist/esm/DSDateTimePicker.js +158 -0
- package/dist/esm/DSDateTimePicker.js.map +7 -0
- package/dist/esm/components/DateTimePickerImpl.js +257 -0
- package/dist/esm/components/DateTimePickerImpl.js.map +7 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/lang/english.js +10 -0
- package/dist/esm/lang/english.js.map +7 -0
- package/dist/esm/tests/utils.js +27 -0
- package/dist/esm/tests/utils.js.map +7 -0
- package/dist/esm/utils.js +16 -0
- package/dist/esm/utils.js.map +7 -0
- package/package.json +41 -32
- package/cjs/DSDateTimePicker.js +0 -193
- package/cjs/components/DateTimePickerImpl.js +0 -285
- package/cjs/index.js +0 -10
- package/cjs/lang/english.js +0 -9
- package/cjs/utils.js +0 -22
- package/esm/DSDateTimePicker.js +0 -182
- package/esm/components/DateTimePickerImpl.js +0 -276
- package/esm/index.js +0 -1
- package/esm/lang/english.js +0 -7
- package/esm/utils.js +0 -14
- package/types/DSDateTimePicker.d.ts +0 -165
- package/types/components/DateTimePickerImpl.d.ts +0 -75
- package/types/index.d.ts +0 -1
- package/types/lang/english.d.ts +0 -6
- package/types/tests/DateTimePicker-events.test.d.ts +0 -1
- package/types/tests/DateTimePickerSelectedDate.test.d.ts +0 -1
- package/types/tests/utils.d.ts +0 -1
- package/types/utils.d.ts +0 -2
package/esm/DSDateTimePicker.js
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
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; }
|
|
20
|
-
const {
|
|
21
|
-
placeholder: placeholderDefault,
|
|
22
|
-
className: classNameDefault,
|
|
23
|
-
id: idDefault
|
|
24
|
-
} = english;
|
|
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, {
|
|
69
|
-
id
|
|
70
|
-
});
|
|
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
|
-
})
|
|
83
|
-
}));
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const dateTimePickerProps = {
|
|
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
|
-
*/
|
|
109
|
-
datePickerProps: PropTypes.shape({
|
|
110
|
-
disabled: PropTypes.bool,
|
|
111
|
-
numberOfMonths: PropTypes.number,
|
|
112
|
-
readOnly: PropTypes.bool,
|
|
113
|
-
enableOutsideDays: PropTypes.bool,
|
|
114
|
-
transitionDuration: PropTypes.number,
|
|
115
|
-
firstDayOfWeek: PropTypes.number,
|
|
116
|
-
keepOpenOnDateSelect: PropTypes.bool,
|
|
117
|
-
hideKeyboardShortcutsPanel: PropTypes.bool,
|
|
118
|
-
onPrevMonthClick: PropTypes.func,
|
|
119
|
-
onNextMonthClick: PropTypes.func,
|
|
120
|
-
onClose: PropTypes.func,
|
|
121
|
-
onDateChange: PropTypes.func,
|
|
122
|
-
phrases: PropTypes.shape({
|
|
123
|
-
calendarLabel: PropTypes.string,
|
|
124
|
-
closeDatePicker: PropTypes.string,
|
|
125
|
-
clearDates: PropTypes.string,
|
|
126
|
-
focusStartDate: PropTypes.string,
|
|
127
|
-
jumpToPrevMonth: PropTypes.string,
|
|
128
|
-
jumpToNextMonth: PropTypes.string,
|
|
129
|
-
keyboardShortcuts: PropTypes.string,
|
|
130
|
-
showKeyboardShortcutsPanel: PropTypes.string,
|
|
131
|
-
hideKeyboardShortcutsPanel: PropTypes.string,
|
|
132
|
-
openThisPanel: PropTypes.string,
|
|
133
|
-
enterKey: PropTypes.string,
|
|
134
|
-
leftArrowRightArrow: PropTypes.string,
|
|
135
|
-
upArrowDownArrow: PropTypes.string,
|
|
136
|
-
pageUpPageDown: PropTypes.string,
|
|
137
|
-
homeEnd: PropTypes.string,
|
|
138
|
-
escape: PropTypes.string,
|
|
139
|
-
questionMark: PropTypes.string,
|
|
140
|
-
selectFocusedDate: PropTypes.string,
|
|
141
|
-
moveFocusByOneDay: PropTypes.string,
|
|
142
|
-
moveFocusByOneWeek: PropTypes.string,
|
|
143
|
-
moveFocusByOneMonth: PropTypes.string,
|
|
144
|
-
moveFocustoStartAndEndOfWeek: PropTypes.string,
|
|
145
|
-
returnFocusToInput: PropTypes.string,
|
|
146
|
-
keyboardNavigationInstructions: PropTypes.string,
|
|
147
|
-
chooseAvailableStartDate: PropTypes.func,
|
|
148
|
-
chooseAvailableEndDate: PropTypes.func,
|
|
149
|
-
dateIsUnavailable: PropTypes.func,
|
|
150
|
-
dateIsSelected: PropTypes.func,
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* ZIndex for the picker popup
|
|
154
|
-
*/
|
|
155
|
-
zIndex: PropTypes.number
|
|
156
|
-
}),
|
|
157
|
-
displayFormatDay: PropTypes.string,
|
|
158
|
-
isDayBlocked: PropTypes.func,
|
|
159
|
-
isOutsideRange: PropTypes.func,
|
|
160
|
-
isDayHighlighted: PropTypes.func
|
|
161
|
-
}).description('DatePicker properties'),
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Input placeholder
|
|
165
|
-
*/
|
|
166
|
-
placeholder: PropTypes.string.description('Input placeholder'),
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* TimePicker properties
|
|
170
|
-
*/
|
|
171
|
-
timePickerProps: PropTypes.shape({
|
|
172
|
-
format: PropTypes.string,
|
|
173
|
-
onChange: PropTypes.func
|
|
174
|
-
}).description('TimePicker properties'),
|
|
175
|
-
dateInputProps: PropTypes.shape({
|
|
176
|
-
onDateInputDateChange: PropTypes.func
|
|
177
|
-
}).description('DateInputProperties')
|
|
178
|
-
};
|
|
179
|
-
const DateTimePickerWithSchema = describe(DSDateTimePicker);
|
|
180
|
-
DateTimePickerWithSchema.propTypes = dateTimePickerProps;
|
|
181
|
-
|
|
182
|
-
export { DateTimePickerWithSchema, DSDateTimePicker as default };
|
|
@@ -1,276 +0,0 @@
|
|
|
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);
|
|
73
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
74
|
-
const disabledTimeRange = disabledTimes && {
|
|
75
|
-
from: convertTimeString(disabledTimes.from),
|
|
76
|
-
to: convertTimeString(disabledTimes.to)
|
|
77
|
-
};
|
|
78
|
-
const dateTimePickerWrapperRef = useRef();
|
|
79
|
-
const fullFormat = "".concat(formatDate, " ").concat(format);
|
|
80
|
-
useEffect(() => {
|
|
81
|
-
if (date) {
|
|
82
|
-
setSelectedDate(moment(date));
|
|
83
|
-
} else if (date === null) setSelectedDate(undefined);
|
|
84
|
-
}, [date]);
|
|
85
|
-
const visiblePanels = useMemo(() => getVisibleTimeByFormat(format), []);
|
|
86
|
-
const currentYear = moment().year();
|
|
87
|
-
|
|
88
|
-
const handleDatePickerChange = dateSelected => {
|
|
89
|
-
const splittedDate = updateDateAndTime(dateSelected, selectedDate);
|
|
90
|
-
|
|
91
|
-
if (!readOnly) {
|
|
92
|
-
setSelectedDate(splittedDate);
|
|
93
|
-
onDateChange(splittedDate);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const onTimeChange = pickerTime => {
|
|
98
|
-
const splittedDate = updateDateAndTime(selectedDate, pickerTime);
|
|
99
|
-
onChangeTimePicker(splittedDate);
|
|
100
|
-
setSelectedDate(splittedDate);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const handleInputChange = (inputValue, type) => {
|
|
104
|
-
onDatePickerChange(inputValue);
|
|
105
|
-
let timeBlocked = false;
|
|
106
|
-
const inputMoment = moment(inputValue, fullFormat);
|
|
107
|
-
setIncompleteInput(inputValue);
|
|
108
|
-
|
|
109
|
-
if (type === 'date') {
|
|
110
|
-
const splittedDate = updateDateAndTime(inputMoment, selectedDate);
|
|
111
|
-
|
|
112
|
-
if (inputValue.length < 8) {
|
|
113
|
-
onErrorDate({
|
|
114
|
-
message: 'date incomplete',
|
|
115
|
-
inputValue
|
|
116
|
-
});
|
|
117
|
-
if (clearable) onDateChange('error');
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (inputValue.length === 8 && inputMoment.isValid()) {
|
|
122
|
-
setSelectedDate(splittedDate);
|
|
123
|
-
onChangeTimePicker(splittedDate);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
onDateChange(splittedDate);
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (disabledTimeRange) {
|
|
131
|
-
const hour = inputValue.hour();
|
|
132
|
-
const min = inputValue.minutes();
|
|
133
|
-
const {
|
|
134
|
-
from,
|
|
135
|
-
to
|
|
136
|
-
} = disabledTimeRange;
|
|
137
|
-
|
|
138
|
-
if (hour > from.hour && hour < to.hour || hour === to.hour && min < to.min) {
|
|
139
|
-
timeBlocked = true;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (timeBlocked) onErrorTime({
|
|
144
|
-
message: 'time blocked',
|
|
145
|
-
inputValue
|
|
146
|
-
});
|
|
147
|
-
const dateBlocked = isDayBlocked(inputMoment);
|
|
148
|
-
if (dateBlocked) onErrorDate({
|
|
149
|
-
message: 'date blocked',
|
|
150
|
-
inputValue
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
if (!timeBlocked && !dateBlocked) {
|
|
154
|
-
onDateChange(inputValue);
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
const handleOutsideClick = event => {
|
|
159
|
-
if (!dateTimePickerWrapperRef.current.contains(event.target)) {
|
|
160
|
-
setIsOpen(false);
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
const handleClickEscape = () => setIsOpen(false);
|
|
165
|
-
|
|
166
|
-
const handleOpen = () => setIsOpen(true);
|
|
167
|
-
|
|
168
|
-
const handleContainerBlur = event => {
|
|
169
|
-
if (!isOpen && !event.currentTarget.contains(event.relatedTarget)) {
|
|
170
|
-
onBlur(event, selectedDate !== null && selectedDate !== void 0 && selectedDate.isValid() ? selectedDate : {
|
|
171
|
-
error: true,
|
|
172
|
-
message: 'incomplete input',
|
|
173
|
-
input: incompleteInput
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
if (clearable && !selectedDate && !!incompleteInput) {
|
|
177
|
-
const inputMoment = moment(incompleteInput, fullFormat);
|
|
178
|
-
const splittedDate = updateDateAndTime(inputMoment, selectedDate);
|
|
179
|
-
setSelectedDate(splittedDate);
|
|
180
|
-
onDateChange(splittedDate);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
useEffect(() => {
|
|
186
|
-
if (!isOpen) onBlur({}, selectedDate !== null && selectedDate !== void 0 && selectedDate.isValid() ? selectedDate : {
|
|
187
|
-
error: true,
|
|
188
|
-
message: 'incomplete input',
|
|
189
|
-
input: incompleteInput
|
|
190
|
-
});
|
|
191
|
-
}, [isOpen]);
|
|
192
|
-
const hasSelectedDate = !!selectedDate;
|
|
193
|
-
return /*#__PURE__*/_jsx(DSInputGroup, {
|
|
194
|
-
containerProps: {
|
|
195
|
-
onBlur: handleContainerBlur
|
|
196
|
-
},
|
|
197
|
-
rightAddon: /*#__PURE__*/_jsx(DatePickerDropdown, {
|
|
198
|
-
disabled: disabled,
|
|
199
|
-
isOpen: isOpen,
|
|
200
|
-
zIndex: zIndex,
|
|
201
|
-
menu: /*#__PURE__*/jsxs(DateTimePickerWrapper, {
|
|
202
|
-
ref: dateTimePickerWrapperRef,
|
|
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
|
-
}),
|
|
238
|
-
onClick: handleOpen,
|
|
239
|
-
readOnly: readOnly
|
|
240
|
-
})
|
|
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
|
-
},
|
|
268
|
-
isShowElipsisActive: false,
|
|
269
|
-
disabled: disabled,
|
|
270
|
-
onChange: handleInputChange,
|
|
271
|
-
placeholder: placeholder,
|
|
272
|
-
value: selectedDate
|
|
273
|
-
}));
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
export { DSDateTimePickerImpl as default };
|
package/esm/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { DateTimePickerWithSchema, default } from './DSDateTimePicker.js';
|
package/esm/lang/english.js
DELETED
package/esm/utils.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import moment from 'moment';
|
|
2
|
-
|
|
3
|
-
const updateDateAndTime = (date, time) => {
|
|
4
|
-
const splittedDate = moment();
|
|
5
|
-
splittedDate.month(date === null || date === void 0 ? void 0 : date.get('month'));
|
|
6
|
-
splittedDate.year(date === null || date === void 0 ? void 0 : date.get('year'));
|
|
7
|
-
splittedDate.date(date === null || date === void 0 ? void 0 : date.get('date'));
|
|
8
|
-
splittedDate.hour(time === null || time === void 0 ? void 0 : time.get('hour'));
|
|
9
|
-
splittedDate.minute(time === null || time === void 0 ? void 0 : time.get('minute'));
|
|
10
|
-
splittedDate.second(time === null || time === void 0 ? void 0 : time.get('second'));
|
|
11
|
-
return splittedDate;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { updateDateAndTime };
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
/// <reference path="../../../../shared/typings/react-desc.d.ts" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
|
-
declare const DSDateTimePicker: {
|
|
4
|
-
({ containerProps, className, id, placeholder, date, clearable, onBlur, datePickerProps, timePickerProps, dateInputProps, }: {
|
|
5
|
-
containerProps?: {} | undefined;
|
|
6
|
-
className?: string | undefined;
|
|
7
|
-
id?: string | undefined;
|
|
8
|
-
placeholder?: string | undefined;
|
|
9
|
-
date: any;
|
|
10
|
-
clearable?: boolean | undefined;
|
|
11
|
-
onBlur?: (() => null) | undefined;
|
|
12
|
-
datePickerProps?: {
|
|
13
|
-
disabled: boolean;
|
|
14
|
-
numberOfMonths: number;
|
|
15
|
-
readOnly: boolean;
|
|
16
|
-
enableOutsideDays: boolean;
|
|
17
|
-
transitionDuration: number;
|
|
18
|
-
firstDayOfWeek: number;
|
|
19
|
-
keepOpenOnDateSelect: boolean;
|
|
20
|
-
hideKeyboardShortcutsPanel: boolean;
|
|
21
|
-
onPrevMonthClick: () => null;
|
|
22
|
-
onNextMonthClick: () => null;
|
|
23
|
-
onClose: () => null;
|
|
24
|
-
onchange: () => null;
|
|
25
|
-
onDateChange: () => null;
|
|
26
|
-
phrases: {
|
|
27
|
-
calendarLabel: string;
|
|
28
|
-
roleDescription: string;
|
|
29
|
-
closeDatePicker: string;
|
|
30
|
-
clearDate: string;
|
|
31
|
-
jumpToPrevMonth: string;
|
|
32
|
-
jumpToNextMonth: string;
|
|
33
|
-
keyboardShortcuts: string;
|
|
34
|
-
showKeyboardShortcutsPanel: string;
|
|
35
|
-
hideKeyboardShortcutsPanel: string;
|
|
36
|
-
openThisPanel: string;
|
|
37
|
-
enterKey: string;
|
|
38
|
-
leftArrowRightArrow: string;
|
|
39
|
-
upArrowDownArrow: string;
|
|
40
|
-
pageUpPageDown: string;
|
|
41
|
-
homeEnd: string;
|
|
42
|
-
escape: string;
|
|
43
|
-
questionMark: string;
|
|
44
|
-
selectFocusedDate: string;
|
|
45
|
-
moveFocusByOneDay: string;
|
|
46
|
-
moveFocusByOneWeek: string;
|
|
47
|
-
moveFocusByOneMonth: string;
|
|
48
|
-
moveFocustoStartAndEndOfWeek: string;
|
|
49
|
-
returnFocusToInput: string;
|
|
50
|
-
keyboardForwardNavigationInstructions: string;
|
|
51
|
-
keyboardBackwardNavigationInstructions: string;
|
|
52
|
-
chooseAvailableDate: ({ date }: {
|
|
53
|
-
date: any;
|
|
54
|
-
}) => any;
|
|
55
|
-
dateIsUnavailable: ({ date }: {
|
|
56
|
-
date: any;
|
|
57
|
-
}) => string;
|
|
58
|
-
dateIsSelected: ({ date }: {
|
|
59
|
-
date: any;
|
|
60
|
-
}) => string;
|
|
61
|
-
};
|
|
62
|
-
displayFormatDay: string;
|
|
63
|
-
isDayBlocked: () => boolean;
|
|
64
|
-
isOutsideRange: () => boolean;
|
|
65
|
-
isDayHighlighted: () => boolean;
|
|
66
|
-
zIndex: number;
|
|
67
|
-
} | undefined;
|
|
68
|
-
timePickerProps?: {
|
|
69
|
-
format: string;
|
|
70
|
-
onChange: () => null;
|
|
71
|
-
disabledTimes: undefined;
|
|
72
|
-
minutesInterval: number;
|
|
73
|
-
} | undefined;
|
|
74
|
-
dateInputProps?: {
|
|
75
|
-
onDateInputDateChange: () => null;
|
|
76
|
-
} | undefined;
|
|
77
|
-
}): JSX.Element;
|
|
78
|
-
propTypes: {
|
|
79
|
-
containerProps: {
|
|
80
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
81
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
82
|
-
};
|
|
83
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
84
|
-
};
|
|
85
|
-
className: {
|
|
86
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
87
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
88
|
-
};
|
|
89
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
90
|
-
};
|
|
91
|
-
id: {
|
|
92
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
93
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
94
|
-
};
|
|
95
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* on blur callback
|
|
99
|
-
*/
|
|
100
|
-
onBlur: {
|
|
101
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
102
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
103
|
-
};
|
|
104
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* Initial date, by default current date
|
|
108
|
-
*/
|
|
109
|
-
date: {
|
|
110
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
111
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
112
|
-
};
|
|
113
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
114
|
-
};
|
|
115
|
-
/**
|
|
116
|
-
* Flag to trigger onDateChange on error
|
|
117
|
-
*/
|
|
118
|
-
clearable: {
|
|
119
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
120
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
121
|
-
};
|
|
122
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
123
|
-
};
|
|
124
|
-
/**
|
|
125
|
-
* DatePicker properties
|
|
126
|
-
*/
|
|
127
|
-
datePickerProps: {
|
|
128
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
129
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
130
|
-
};
|
|
131
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
132
|
-
};
|
|
133
|
-
/**
|
|
134
|
-
* Input placeholder
|
|
135
|
-
*/
|
|
136
|
-
placeholder: {
|
|
137
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
138
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
139
|
-
};
|
|
140
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
141
|
-
};
|
|
142
|
-
/**
|
|
143
|
-
* TimePicker properties
|
|
144
|
-
*/
|
|
145
|
-
timePickerProps: {
|
|
146
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
147
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
148
|
-
};
|
|
149
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
150
|
-
};
|
|
151
|
-
dateInputProps: {
|
|
152
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
153
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
154
|
-
};
|
|
155
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
156
|
-
};
|
|
157
|
-
};
|
|
158
|
-
};
|
|
159
|
-
declare const DateTimePickerWithSchema: {
|
|
160
|
-
(props?: unknown): JSX.Element;
|
|
161
|
-
propTypes: unknown;
|
|
162
|
-
toTypescript: () => import("react-desc").TypescriptSchema;
|
|
163
|
-
};
|
|
164
|
-
export { DateTimePickerWithSchema };
|
|
165
|
-
export default DSDateTimePicker;
|