@elliemae/ds-date-range-picker 1.55.0-next.7 → 2.0.0-alpha.10
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/DSDateRangePicker.js +111 -183
- package/cjs/components/DSDateRangePickerImpl.js +238 -305
- package/cjs/components/DatePickerLabel/DatePickerLabel.js +9 -12
- package/cjs/components/DatePickerRangeHeader/DatePickerRangeHeader.js +36 -54
- package/cjs/components/DayPickerRangeController.js +74 -132
- package/cjs/index.js +6 -31
- package/cjs/isMaxDiffSafe.js +5 -6
- package/cjs/package.json +7 -0
- package/esm/DSDateRangePicker.js +100 -172
- package/esm/components/DSDateRangePickerImpl.js +225 -286
- package/esm/components/DatePickerLabel/DatePickerLabel.js +8 -11
- package/esm/components/DatePickerRangeHeader/DatePickerRangeHeader.js +32 -49
- package/esm/components/DayPickerRangeController.js +72 -126
- package/esm/index.js +0 -25
- package/esm/isMaxDiffSafe.js +5 -6
- package/esm/package.json +7 -0
- package/package.json +52 -11
- package/types/DSDateRangePicker.d.ts +92 -0
- package/types/components/DSDateRangePickerImpl.d.ts +24 -0
- package/types/components/DatePickerLabel/DatePickerLabel.d.ts +6 -0
- package/types/components/DatePickerRangeHeader/DatePickerRangeHeader.d.ts +10 -0
- package/types/components/DayPickerRangeController.d.ts +36 -0
- package/types/index.d.ts +2 -0
- package/types/isMaxDiffSafe.d.ts +2 -0
- package/DSDateRangePicker/package.json +0 -10
- package/cjs/DSDateRangePicker.js.map +0 -1
- package/cjs/components/DSDateRangePickerImpl.js.map +0 -1
- package/cjs/components/DatePickerLabel/DatePickerLabel.js.map +0 -1
- package/cjs/components/DatePickerRangeHeader/DatePickerRangeHeader.js.map +0 -1
- package/cjs/components/DayPickerRangeController.js.map +0 -1
- package/cjs/index.js.map +0 -1
- package/cjs/isMaxDiffSafe.js.map +0 -1
- package/components/DSDateRangePickerImpl/package.json +0 -10
- package/components/DatePickerLabel/DatePickerLabel/package.json +0 -10
- package/components/DatePickerRangeHeader/DatePickerRangeHeader/package.json +0 -10
- package/components/DayPickerRangeController/package.json +0 -10
- package/esm/DSDateRangePicker.js.map +0 -1
- package/esm/components/DSDateRangePickerImpl.js.map +0 -1
- package/esm/components/DatePickerLabel/DatePickerLabel.js.map +0 -1
- package/esm/components/DatePickerRangeHeader/DatePickerRangeHeader.js.map +0 -1
- package/esm/components/DayPickerRangeController.js.map +0 -1
- package/esm/index.js.map +0 -1
- package/esm/isMaxDiffSafe.js.map +0 -1
- package/isMaxDiffSafe/package.json +0 -10
|
@@ -1,89 +1,73 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
3
|
import moment from 'moment';
|
|
4
4
|
import DSInputMask, { MASK_TYPES, MASK_PIPES } from '@elliemae/ds-basic/form/InputMask';
|
|
5
5
|
import DSInputGroup from '@elliemae/ds-basic/form/InputGroup';
|
|
6
6
|
import { aggregatedClasses } from '@elliemae/ds-classnames';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const blockname = 'date-range-picker';
|
|
9
|
+
const Header = aggregatedClasses('div')(blockname, 'header');
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const formatDate = date => {
|
|
12
12
|
if (date) {
|
|
13
13
|
return date.format('MMDDYYYY');
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
selectedStartDate = _ref.selectedStartDate,
|
|
31
|
-
selectedEndDate = _ref.selectedEndDate;
|
|
32
|
-
|
|
33
|
-
var _useState = useState(selectedStartDate ? formatDate(selectedStartDate) : ''),
|
|
34
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
-
startValue = _useState2[0],
|
|
36
|
-
setStartValue = _useState2[1];
|
|
37
|
-
|
|
38
|
-
var _useState3 = useState(selectedEndDate ? formatDate(selectedEndDate) : ''),
|
|
39
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
40
|
-
endValue = _useState4[0],
|
|
41
|
-
setEndValue = _useState4[1];
|
|
42
|
-
|
|
43
|
-
useEffect(function () {
|
|
44
|
-
var startDate = formatDate(selectedStartDate);
|
|
45
|
-
var endDate = formatDate(selectedEndDate);
|
|
17
|
+
const DatePickerRangeHeader = ({
|
|
18
|
+
placeholderStart = 'Start Date',
|
|
19
|
+
placeholderEnd = 'End Date',
|
|
20
|
+
onStartInputChange = () => null,
|
|
21
|
+
onEndInputChange = () => null,
|
|
22
|
+
selectedStartDate,
|
|
23
|
+
selectedEndDate
|
|
24
|
+
}) => {
|
|
25
|
+
const [startValue, setStartValue] = useState(selectedStartDate ? formatDate(selectedStartDate) : '');
|
|
26
|
+
const [endValue, setEndValue] = useState(selectedEndDate ? formatDate(selectedEndDate) : '');
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const startDate = formatDate(selectedStartDate);
|
|
29
|
+
const endDate = formatDate(selectedEndDate);
|
|
46
30
|
startDate !== startValue && setStartValue(startDate);
|
|
47
31
|
endDate !== endValue && setEndValue(endDate);
|
|
48
32
|
}, [selectedStartDate, selectedEndDate]);
|
|
49
33
|
|
|
50
|
-
|
|
51
|
-
|
|
34
|
+
const handleOnChangeStart = e => {
|
|
35
|
+
const newStartValue = e.target.value;
|
|
52
36
|
setStartValue(newStartValue);
|
|
53
37
|
};
|
|
54
38
|
|
|
55
|
-
|
|
56
|
-
|
|
39
|
+
const handleOnChangeEnd = e => {
|
|
40
|
+
const newEndValue = e.target.value;
|
|
57
41
|
setEndValue(newEndValue);
|
|
58
42
|
};
|
|
59
43
|
|
|
60
|
-
|
|
61
|
-
|
|
44
|
+
const handleOnBlurStart = e => {
|
|
45
|
+
const newStartValue = e.target.value;
|
|
62
46
|
onStartInputChange(moment(newStartValue));
|
|
63
47
|
};
|
|
64
48
|
|
|
65
|
-
|
|
66
|
-
|
|
49
|
+
const handleOnBlurEnd = e => {
|
|
50
|
+
const newEndValue = e.target.value;
|
|
67
51
|
onEndInputChange(moment(newEndValue));
|
|
68
52
|
};
|
|
69
53
|
|
|
70
|
-
|
|
54
|
+
const handleOnKeyDownStart = e => {
|
|
71
55
|
if (e.key === 'Enter') {
|
|
72
|
-
|
|
56
|
+
const newValue = e.target.value;
|
|
73
57
|
onStartInputChange(moment(newValue));
|
|
74
58
|
e.target.blur();
|
|
75
59
|
}
|
|
76
60
|
};
|
|
77
61
|
|
|
78
|
-
|
|
62
|
+
const handleOnKeyDownEnd = e => {
|
|
79
63
|
if (e.key === 'Enter') {
|
|
80
|
-
|
|
64
|
+
const newValue = e.target.value;
|
|
81
65
|
onEndInputChange(moment(newValue));
|
|
82
66
|
e.target.blur();
|
|
83
67
|
}
|
|
84
68
|
};
|
|
85
69
|
|
|
86
|
-
return /*#__PURE__*/
|
|
70
|
+
return /*#__PURE__*/_jsx(Header, {}, void 0, /*#__PURE__*/_jsx(DSInputGroup, {}, void 0, /*#__PURE__*/_jsx(DSInputMask, {
|
|
87
71
|
"aria-label": placeholderStart || 'Date Picker Input Mask',
|
|
88
72
|
mask: MASK_TYPES.DATE,
|
|
89
73
|
onBlur: handleOnBlurStart,
|
|
@@ -92,7 +76,7 @@ var DatePickerRangeHeader = function DatePickerRangeHeader(_ref) {
|
|
|
92
76
|
pipe: MASK_PIPES.AUTO_CORRECT_DATE,
|
|
93
77
|
placeholder: placeholderStart,
|
|
94
78
|
value: startValue
|
|
95
|
-
}), /*#__PURE__*/
|
|
79
|
+
}), /*#__PURE__*/_jsx(DSInputMask, {
|
|
96
80
|
"aria-label": placeholderEnd || 'Date Picker Input Mask',
|
|
97
81
|
mask: MASK_TYPES.DATE,
|
|
98
82
|
onBlur: handleOnBlurEnd,
|
|
@@ -105,4 +89,3 @@ var DatePickerRangeHeader = function DatePickerRangeHeader(_ref) {
|
|
|
105
89
|
};
|
|
106
90
|
|
|
107
91
|
export { DatePickerRangeHeader as default };
|
|
108
|
-
//# sourceMappingURL=DatePickerRangeHeader.js.map
|
|
@@ -1,89 +1,53 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import _toArray from '@babel/runtime/helpers/esm/toArray';
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
4
3
|
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
5
|
-
import
|
|
6
|
-
import PropTypes from 'prop-types';
|
|
7
|
-
import moment from 'moment';
|
|
4
|
+
import { useRef, useEffect } from 'react';
|
|
8
5
|
import { DayPickerRangeController as DayPickerRangeController$1 } from 'react-dates';
|
|
9
6
|
import { DatePickerNavigation, DatePickerDay, renderMonthElement } from '@elliemae/ds-date-picker';
|
|
10
7
|
import ChevronLeft from '@elliemae/ds-icons/ChevronLeft';
|
|
11
8
|
import { convertPropToCssClassName } from '@elliemae/ds-classnames';
|
|
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
|
-
return null;
|
|
41
|
-
} : _ref$onOutsideClick,
|
|
42
|
-
_ref$isDayBlocked = _ref.isDayBlocked,
|
|
43
|
-
isDayBlocked = _ref$isDayBlocked === void 0 ? function () {
|
|
44
|
-
return null;
|
|
45
|
-
} : _ref$isDayBlocked,
|
|
46
|
-
_ref$isDayHighlighted = _ref.isDayHighlighted,
|
|
47
|
-
isDayHighlighted = _ref$isDayHighlighted === void 0 ? function () {
|
|
48
|
-
return null;
|
|
49
|
-
} : _ref$isDayHighlighted,
|
|
50
|
-
_ref$isOutsideRange = _ref.isOutsideRange,
|
|
51
|
-
isOutsideRange = _ref$isOutsideRange === void 0 ? function () {
|
|
52
|
-
return null;
|
|
53
|
-
} : _ref$isOutsideRange,
|
|
54
|
-
_ref$onNextMonthClick = _ref.onNextMonthClick,
|
|
55
|
-
onNextMonthClick = _ref$onNextMonthClick === void 0 ? function () {
|
|
56
|
-
return null;
|
|
57
|
-
} : _ref$onNextMonthClick,
|
|
58
|
-
_ref$onPrevMonthClick = _ref.onPrevMonthClick,
|
|
59
|
-
onPrevMonthClick = _ref$onPrevMonthClick === void 0 ? function () {
|
|
60
|
-
return null;
|
|
61
|
-
} : _ref$onPrevMonthClick,
|
|
9
|
+
import { jsx } from 'react/jsx-runtime';
|
|
10
|
+
|
|
11
|
+
const _excluded = ["endDate", "startDate", "displayFormatDay", "focusedInput", "enableOutsideDays", "onDatesChange", "onFocusChange", "onOutsideClick", "isDayBlocked", "isDayHighlighted", "isOutsideRange", "onNextMonthClick", "onPrevMonthClick"];
|
|
12
|
+
|
|
13
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
+
|
|
15
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
16
|
+
const {
|
|
17
|
+
classNameElement,
|
|
18
|
+
classNameBlock
|
|
19
|
+
} = convertPropToCssClassName('datepicker-range');
|
|
20
|
+
|
|
21
|
+
const DayPickerRangeController = _ref => {
|
|
22
|
+
let {
|
|
23
|
+
endDate = undefined,
|
|
24
|
+
startDate = undefined,
|
|
25
|
+
displayFormatDay = 'D',
|
|
26
|
+
focusedInput = undefined,
|
|
27
|
+
enableOutsideDays = false,
|
|
28
|
+
onDatesChange = () => null,
|
|
29
|
+
onFocusChange = () => null,
|
|
30
|
+
onOutsideClick = () => null,
|
|
31
|
+
isDayBlocked = () => null,
|
|
32
|
+
isDayHighlighted = () => null,
|
|
33
|
+
isOutsideRange = () => null,
|
|
34
|
+
onNextMonthClick = () => null,
|
|
35
|
+
onPrevMonthClick = () => null
|
|
36
|
+
} = _ref,
|
|
62
37
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
63
38
|
|
|
64
|
-
|
|
65
|
-
useEffect(
|
|
66
|
-
|
|
67
|
-
|
|
39
|
+
const datePickerRef = useRef();
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
const handleMouseUp = () => {
|
|
42
|
+
const focusedElement = document.activeElement;
|
|
68
43
|
focusedElement.blur();
|
|
69
44
|
};
|
|
70
45
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
var _restOfDays$slice = restOfDays.slice(-1),
|
|
78
|
-
_restOfDays$slice2 = _slicedToArray(_restOfDays$slice, 1),
|
|
79
|
-
lastDay = _restOfDays$slice2[0];
|
|
80
|
-
|
|
81
|
-
var focusedElement = document.activeElement;
|
|
82
|
-
|
|
83
|
-
var _document$getElements3 = document.getElementsByClassName('DayPickerNavigation_button'),
|
|
84
|
-
_document$getElements4 = _slicedToArray(_document$getElements3, 2),
|
|
85
|
-
prev = _document$getElements4[0],
|
|
86
|
-
next = _document$getElements4[1];
|
|
46
|
+
const handleKeyDown = event => {
|
|
47
|
+
const [firstDay, ...restOfDays] = document.getElementsByClassName('CalendarMonthGrid_month__horizontal')[1].getElementsByClassName('CalendarDay');
|
|
48
|
+
const [lastDay] = restOfDays.slice(-1);
|
|
49
|
+
const focusedElement = document.activeElement;
|
|
50
|
+
const [prev, next] = document.getElementsByClassName('DayPickerNavigation_button');
|
|
87
51
|
|
|
88
52
|
switch (event.key) {
|
|
89
53
|
case 'Home':
|
|
@@ -100,12 +64,12 @@ var DayPickerRangeController = function DayPickerRangeController(_ref) {
|
|
|
100
64
|
case ' ':
|
|
101
65
|
if (focusedElement === prev) {
|
|
102
66
|
event.stopPropagation();
|
|
103
|
-
setTimeout(
|
|
67
|
+
setTimeout(() => {
|
|
104
68
|
prev.focus();
|
|
105
69
|
}, 240);
|
|
106
70
|
} else if (focusedElement === next) {
|
|
107
71
|
event.stopPropagation();
|
|
108
|
-
setTimeout(
|
|
72
|
+
setTimeout(() => {
|
|
109
73
|
next === null || next === void 0 ? void 0 : next.focus();
|
|
110
74
|
}, 240);
|
|
111
75
|
}
|
|
@@ -124,64 +88,46 @@ var DayPickerRangeController = function DayPickerRangeController(_ref) {
|
|
|
124
88
|
|
|
125
89
|
datePickerRef.current.addEventListener('mouseup', handleMouseUp, false);
|
|
126
90
|
datePickerRef.current.addEventListener('keydown', handleKeyDown, false);
|
|
127
|
-
return
|
|
91
|
+
return () => {
|
|
128
92
|
if (datePickerRef.current) {
|
|
129
93
|
datePickerRef.current.removeEventListener('mouseup', handleMouseUp, false);
|
|
130
94
|
datePickerRef.current.removeEventListener('keydown', handleKeyDown, false);
|
|
131
95
|
}
|
|
132
96
|
};
|
|
133
97
|
}, []);
|
|
134
|
-
return /*#__PURE__*/
|
|
98
|
+
return /*#__PURE__*/jsx("div", {
|
|
135
99
|
ref: datePickerRef,
|
|
136
100
|
className: classNameBlock('wrapper-day-picker-single-date-controller'),
|
|
137
|
-
"data-testid": otherProps['data-testid'] || 'date-range-picker-controller'
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
return /*#__PURE__*/React.createElement(DatePickerDay, {
|
|
101
|
+
"data-testid": otherProps['data-testid'] || 'date-range-picker-controller',
|
|
102
|
+
children: /*#__PURE__*/jsx(DayPickerRangeController$1, _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
103
|
+
isDayBlocked: isDayBlocked,
|
|
104
|
+
isDayHighlighted: isDayHighlighted,
|
|
105
|
+
isOutsideRange: isOutsideRange,
|
|
106
|
+
enableOutsideDays: enableOutsideDays,
|
|
107
|
+
endDate: endDate,
|
|
108
|
+
focused: true,
|
|
109
|
+
focusedInput: focusedInput,
|
|
110
|
+
hideKeyboardShortcutsPanel: true,
|
|
111
|
+
navNext: /*#__PURE__*/_jsx(DatePickerNavigation, {
|
|
112
|
+
className: classNameElement('navigation-next')
|
|
113
|
+
}),
|
|
114
|
+
navPrev: /*#__PURE__*/_jsx(DatePickerNavigation, {
|
|
115
|
+
className: classNameElement('navigation-prev'),
|
|
116
|
+
icon: ChevronLeft
|
|
117
|
+
}),
|
|
118
|
+
onDatesChange: onDatesChange,
|
|
119
|
+
onFocusChange: onFocusChange,
|
|
120
|
+
onOutsideClick: onOutsideClick,
|
|
121
|
+
onNextMonthClick: onNextMonthClick,
|
|
122
|
+
onPrevMonthClick: onPrevMonthClick,
|
|
123
|
+
renderDayContents: date => /*#__PURE__*/_jsx(DatePickerDay, {
|
|
161
124
|
className: classNameElement('day-contents'),
|
|
162
125
|
date: date.format(displayFormatDay)
|
|
163
|
-
})
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
})
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
DayPickerRangeController.propTypes = {
|
|
171
|
-
endDate: PropTypes.instanceOf(Date, moment),
|
|
172
|
-
startDate: PropTypes.instanceOf(Date, moment),
|
|
173
|
-
displayFormatDay: PropTypes.string,
|
|
174
|
-
focusedInput: PropTypes.bool,
|
|
175
|
-
onDatesChange: PropTypes.func,
|
|
176
|
-
onFocusChange: PropTypes.func,
|
|
177
|
-
onOutsideClick: PropTypes.func,
|
|
178
|
-
onNextMonthClick: PropTypes.func,
|
|
179
|
-
onPrevMonthClick: PropTypes.func,
|
|
180
|
-
enableOutsideDays: PropTypes.bool,
|
|
181
|
-
isDayBlocked: PropTypes.func,
|
|
182
|
-
isDayHighlighted: PropTypes.func,
|
|
183
|
-
isOutsideRange: PropTypes.func
|
|
126
|
+
}),
|
|
127
|
+
renderMonthElement: renderMonthElement,
|
|
128
|
+
startDate: startDate
|
|
129
|
+
}))
|
|
130
|
+
});
|
|
184
131
|
};
|
|
185
132
|
|
|
186
133
|
export { DayPickerRangeController as default };
|
|
187
|
-
//# sourceMappingURL=DayPickerRangeController.js.map
|
package/esm/index.js
CHANGED
|
@@ -1,28 +1,3 @@
|
|
|
1
1
|
export { DateRangePickerWithSchema, default } from './DSDateRangePicker.js';
|
|
2
2
|
export { default as DayPickerRangeController } from './components/DayPickerRangeController.js';
|
|
3
3
|
export { END_DATE, START_DATE } from './components/DSDateRangePickerImpl.js';
|
|
4
|
-
import '@babel/runtime/helpers/esm/extends';
|
|
5
|
-
import 'react';
|
|
6
|
-
import 'react-desc';
|
|
7
|
-
import '@elliemae/ds-classnames';
|
|
8
|
-
import 'moment';
|
|
9
|
-
import 'react-dates/initialize';
|
|
10
|
-
import 'react-dates';
|
|
11
|
-
import '@babel/runtime/helpers/esm/slicedToArray';
|
|
12
|
-
import '@babel/runtime/helpers/esm/toArray';
|
|
13
|
-
import '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
14
|
-
import 'prop-types';
|
|
15
|
-
import '@elliemae/ds-date-picker';
|
|
16
|
-
import '@elliemae/ds-icons/ChevronLeft';
|
|
17
|
-
import '@babel/runtime/helpers/esm/classCallCheck';
|
|
18
|
-
import '@babel/runtime/helpers/esm/createClass';
|
|
19
|
-
import '@babel/runtime/helpers/esm/assertThisInitialized';
|
|
20
|
-
import '@babel/runtime/helpers/esm/inherits';
|
|
21
|
-
import '@babel/runtime/helpers/esm/possibleConstructorReturn';
|
|
22
|
-
import '@babel/runtime/helpers/esm/getPrototypeOf';
|
|
23
|
-
import '@babel/runtime/helpers/esm/defineProperty';
|
|
24
|
-
import '@elliemae/ds-basic/form/InputMask';
|
|
25
|
-
import '@elliemae/ds-basic/form/FormItem';
|
|
26
|
-
import '@elliemae/ds-basic/Popper';
|
|
27
|
-
import './isMaxDiffSafe.js';
|
|
28
|
-
//# sourceMappingURL=index.js.map
|
package/esm/isMaxDiffSafe.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* eslint-disable max-params */
|
|
2
|
-
|
|
2
|
+
const MAX_YEARS_DIFF = 150; // https://jira.elliemae.io/browse/PUI-4145
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const isMaxDiffSafe = (startDate, endDate, prevStart, prevEnd) => {
|
|
5
5
|
try {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const diff = Math.abs(endDate.diff(startDate, 'years'));
|
|
7
|
+
const diffStart = Math.abs(startDate.diff(prevStart, 'years'));
|
|
8
|
+
const diffEnd = Math.abs(endDate.diff(prevEnd, 'years'));
|
|
9
9
|
return diff < MAX_YEARS_DIFF && diffStart < MAX_YEARS_DIFF && diffEnd < MAX_YEARS_DIFF;
|
|
10
10
|
} catch (error) {
|
|
11
11
|
return true;
|
|
@@ -13,4 +13,3 @@ var isMaxDiffSafe = function isMaxDiffSafe(startDate, endDate, prevStart, prevEn
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export { MAX_YEARS_DIFF, isMaxDiffSafe };
|
|
16
|
-
//# sourceMappingURL=isMaxDiffSafe.js.map
|
package/esm/package.json
ADDED
package/package.json
CHANGED
|
@@ -1,14 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-date-range-picker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.10",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"description": "
|
|
6
|
-
"
|
|
7
|
-
"
|
|
5
|
+
"description": "ICE MT - Dimsum - Date Range Picker",
|
|
6
|
+
"module": "./esm/index.js",
|
|
7
|
+
"main": "./cjs/index.js",
|
|
8
|
+
"types": "./types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./esm/index.js",
|
|
12
|
+
"require": "./cjs/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./isMaxDiffSafe": {
|
|
15
|
+
"import": "./esm/isMaxDiffSafe.js",
|
|
16
|
+
"require": "./cjs/isMaxDiffSafe.js"
|
|
17
|
+
},
|
|
18
|
+
"./DSDateRangePicker": {
|
|
19
|
+
"import": "./esm/DSDateRangePicker.js",
|
|
20
|
+
"require": "./cjs/DSDateRangePicker.js"
|
|
21
|
+
},
|
|
22
|
+
"./components/DSDateRangePickerImpl": {
|
|
23
|
+
"import": "./esm/components/DSDateRangePickerImpl.js",
|
|
24
|
+
"require": "./cjs/components/DSDateRangePickerImpl.js"
|
|
25
|
+
},
|
|
26
|
+
"./components/DayPickerRangeController": {
|
|
27
|
+
"import": "./esm/components/DayPickerRangeController.js",
|
|
28
|
+
"require": "./cjs/components/DayPickerRangeController.js"
|
|
29
|
+
},
|
|
30
|
+
"./components/DatePickerRangeHeader/DatePickerRangeHeader": {
|
|
31
|
+
"import": "./esm/components/DatePickerRangeHeader/DatePickerRangeHeader.js",
|
|
32
|
+
"require": "./cjs/components/DatePickerRangeHeader/DatePickerRangeHeader.js"
|
|
33
|
+
},
|
|
34
|
+
"./components/DatePickerLabel/DatePickerLabel": {
|
|
35
|
+
"import": "./esm/components/DatePickerLabel/DatePickerLabel.js",
|
|
36
|
+
"require": "./cjs/components/DatePickerLabel/DatePickerLabel.js"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
8
39
|
"sideEffects": [
|
|
9
40
|
"*.css",
|
|
10
41
|
"*.scss"
|
|
11
42
|
],
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://git.elliemae.io/platform-ui/dimsum.git"
|
|
46
|
+
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"npm": ">=7",
|
|
49
|
+
"node": ">=14"
|
|
50
|
+
},
|
|
51
|
+
"author": "ICE MT",
|
|
12
52
|
"scripts": {
|
|
13
53
|
"dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
|
|
14
54
|
"prebuild": "exit 0",
|
|
@@ -16,21 +56,22 @@
|
|
|
16
56
|
"build": "node ../../scripts/build/build.js"
|
|
17
57
|
},
|
|
18
58
|
"dependencies": {
|
|
19
|
-
"@elliemae/ds-basic": "
|
|
20
|
-
"@elliemae/ds-classnames": "
|
|
21
|
-
"@elliemae/ds-date-picker": "
|
|
59
|
+
"@elliemae/ds-basic": "2.0.0-alpha.10",
|
|
60
|
+
"@elliemae/ds-classnames": "2.0.0-alpha.10",
|
|
61
|
+
"@elliemae/ds-date-picker": "2.0.0-alpha.10",
|
|
22
62
|
"moment": "~2.29.1",
|
|
23
63
|
"prop-types": "~15.7.2",
|
|
24
64
|
"react-dates": "~21.8.0",
|
|
25
65
|
"react-text-mask": "~5.4.3"
|
|
26
66
|
},
|
|
27
67
|
"peerDependencies": {
|
|
28
|
-
"lodash": "^4.17.
|
|
29
|
-
"react": "~17.0.
|
|
30
|
-
"react-dom": "^17.0.
|
|
68
|
+
"lodash": "^4.17.21",
|
|
69
|
+
"react": "~17.0.2",
|
|
70
|
+
"react-dom": "^17.0.2"
|
|
31
71
|
},
|
|
32
72
|
"publishConfig": {
|
|
33
73
|
"access": "public",
|
|
34
|
-
"directory": "dist"
|
|
74
|
+
"directory": "dist",
|
|
75
|
+
"generateSubmodules": true
|
|
35
76
|
}
|
|
36
77
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import moment from 'moment';
|
|
3
|
+
import 'react-dates/initialize';
|
|
4
|
+
import DayPickerRangeController from './components/DayPickerRangeController';
|
|
5
|
+
import { START_DATE, END_DATE } from './components/DSDateRangePickerImpl';
|
|
6
|
+
declare const DSDateRangePicker: {
|
|
7
|
+
({ containerProps, className, disabled, required, startDateRequired, endDateRequired, id, hasError, validationMessage, readOnly, screenReaderInputMessage, initialVisibleMonth, firstDayOfWeek, keepOpenOnDateSelect, reopenPickerOnClearDates, hideKeyboardShortcutsPanel, onPrevMonthClick, onNextMonthClick, onClose, onOutsideClick, transitionDuration, verticalSpacing, minimumNights, isDayBlocked, isOutsideRange, isDayHighlighted, displayFormat, displayFormatDay, phrases, startDate, endDate, startDateId, endDateId, labelFrom, labelTo, enableOutsideDays, onChangeStartInput, onChangeEndInput, onDatesChange, }: {
|
|
8
|
+
containerProps?: {} | undefined;
|
|
9
|
+
className?: string | undefined;
|
|
10
|
+
disabled?: boolean | undefined;
|
|
11
|
+
required?: boolean | undefined;
|
|
12
|
+
startDateRequired?: boolean | undefined;
|
|
13
|
+
endDateRequired?: boolean | undefined;
|
|
14
|
+
id: any;
|
|
15
|
+
hasError?: boolean | undefined;
|
|
16
|
+
validationMessage?: string | undefined;
|
|
17
|
+
readOnly?: boolean | undefined;
|
|
18
|
+
screenReaderInputMessage?: string | undefined;
|
|
19
|
+
initialVisibleMonth?: moment.Moment | undefined;
|
|
20
|
+
firstDayOfWeek?: number | undefined;
|
|
21
|
+
keepOpenOnDateSelect?: boolean | undefined;
|
|
22
|
+
reopenPickerOnClearDates?: boolean | undefined;
|
|
23
|
+
hideKeyboardShortcutsPanel?: boolean | undefined;
|
|
24
|
+
onPrevMonthClick?: (() => null) | undefined;
|
|
25
|
+
onNextMonthClick?: (() => null) | undefined;
|
|
26
|
+
onClose?: (() => null) | undefined;
|
|
27
|
+
onOutsideClick?: (() => null) | undefined;
|
|
28
|
+
transitionDuration?: number | undefined;
|
|
29
|
+
verticalSpacing?: number | undefined;
|
|
30
|
+
minimumNights?: number | undefined;
|
|
31
|
+
isDayBlocked?: (() => boolean) | undefined;
|
|
32
|
+
isOutsideRange?: (() => boolean) | undefined;
|
|
33
|
+
isDayHighlighted?: (() => boolean) | undefined;
|
|
34
|
+
displayFormat?: string | undefined;
|
|
35
|
+
displayFormatDay?: string | undefined;
|
|
36
|
+
phrases?: any;
|
|
37
|
+
startDate: any;
|
|
38
|
+
endDate: any;
|
|
39
|
+
startDateId?: string | undefined;
|
|
40
|
+
endDateId?: string | undefined;
|
|
41
|
+
labelFrom?: string | undefined;
|
|
42
|
+
labelTo?: string | undefined;
|
|
43
|
+
enableOutsideDays?: boolean | undefined;
|
|
44
|
+
onChangeStartInput?: (() => null) | undefined;
|
|
45
|
+
onChangeEndInput?: (() => null) | undefined;
|
|
46
|
+
onDatesChange?: (() => null) | undefined;
|
|
47
|
+
}): JSX.Element;
|
|
48
|
+
propTypes: {
|
|
49
|
+
containerProps: any;
|
|
50
|
+
className: any;
|
|
51
|
+
disabled: any;
|
|
52
|
+
required: any;
|
|
53
|
+
startDateRequired: any;
|
|
54
|
+
endDateRequired: any;
|
|
55
|
+
id: any;
|
|
56
|
+
hasError: any;
|
|
57
|
+
validationMessage: any;
|
|
58
|
+
readOnly: any;
|
|
59
|
+
screenReaderInputMessage: any;
|
|
60
|
+
initialVisibleMonth: any;
|
|
61
|
+
firstDayOfWeek: any;
|
|
62
|
+
keepOpenOnDateSelect: any;
|
|
63
|
+
reopenPickerOnClearDates: any;
|
|
64
|
+
hideKeyboardShortcutsPanel: any;
|
|
65
|
+
onPrevMonthClick: any;
|
|
66
|
+
onNextMonthClick: any;
|
|
67
|
+
onClose: any;
|
|
68
|
+
transitionDuration: any;
|
|
69
|
+
verticalSpacing: any;
|
|
70
|
+
isDayBlocked: any;
|
|
71
|
+
isOutsideRange: any;
|
|
72
|
+
isDayHighlighted: any;
|
|
73
|
+
minimumNights: number;
|
|
74
|
+
displayFormat: any;
|
|
75
|
+
displayFormatDay: any;
|
|
76
|
+
phrases: any;
|
|
77
|
+
startDate: any;
|
|
78
|
+
endDate: any;
|
|
79
|
+
startDateId: any;
|
|
80
|
+
endDateId: any;
|
|
81
|
+
labelFrom: any;
|
|
82
|
+
labelTo: any;
|
|
83
|
+
enableOutsideDays: any;
|
|
84
|
+
onDatesChange: any;
|
|
85
|
+
onChangeStartInput: any;
|
|
86
|
+
onChangeEndInput: any;
|
|
87
|
+
onOutsideClick: any;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
declare const DateRangePickerWithSchema: any;
|
|
91
|
+
export { DayPickerRangeController, START_DATE, END_DATE, DateRangePickerWithSchema, };
|
|
92
|
+
export default DSDateRangePicker;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const START_DATE = "startDate";
|
|
3
|
+
export declare const END_DATE = "endDate";
|
|
4
|
+
export default class DSDateRangePickerImpl extends React.Component {
|
|
5
|
+
constructor(props: any);
|
|
6
|
+
componentDidMount(): void;
|
|
7
|
+
componentWillUnmount(): void;
|
|
8
|
+
onDatesChange: ({ startDate, endDate }: {
|
|
9
|
+
startDate: any;
|
|
10
|
+
endDate: any;
|
|
11
|
+
}) => void;
|
|
12
|
+
onFocusChange: () => void;
|
|
13
|
+
handleKeyDown: (event: any) => void;
|
|
14
|
+
getSafeStartInputValue: () => any;
|
|
15
|
+
getSafeEndInputValue: () => any;
|
|
16
|
+
changeFocus: () => void;
|
|
17
|
+
handleChangeStart: (e: any) => void;
|
|
18
|
+
handleChangeEnd: (e: any) => void;
|
|
19
|
+
handleChangeDate: ({ startDate: _start, endDate }: {
|
|
20
|
+
startDate: any;
|
|
21
|
+
endDate: any;
|
|
22
|
+
}) => void;
|
|
23
|
+
render(): JSX.Element;
|
|
24
|
+
}
|