@elliemae/ds-date-range-picker 2.2.0-alpha.2 → 2.2.0-beta.0
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 +193 -199
- package/cjs/components/DSDateRangePickerImpl.js +222 -172
- package/cjs/components/DatePickerLabel/DatePickerLabel.js +19 -38
- package/cjs/components/DatePickerRangeHeader/DatePickerRangeHeader.js +62 -74
- package/cjs/components/DayPickerRangeController.js +109 -123
- package/cjs/index.js +15 -36
- package/cjs/isMaxDiffSafe.js +13 -39
- package/esm/DSDateRangePicker.js +150 -143
- package/esm/components/DSDateRangePickerImpl.js +197 -131
- package/esm/components/DatePickerLabel/DatePickerLabel.js +13 -9
- package/esm/components/DatePickerRangeHeader/DatePickerRangeHeader.js +45 -36
- package/esm/components/DayPickerRangeController.js +99 -92
- package/esm/index.js +3 -7
- package/esm/isMaxDiffSafe.js +8 -10
- package/package.json +6 -6
- package/types/DSDateRangePicker.d.ts +1 -41
- package/cjs/DSDateRangePicker.js.map +0 -7
- package/cjs/components/DSDateRangePickerImpl.js.map +0 -7
- package/cjs/components/DatePickerLabel/DatePickerLabel.js.map +0 -7
- package/cjs/components/DatePickerRangeHeader/DatePickerRangeHeader.js.map +0 -7
- package/cjs/components/DayPickerRangeController.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/isMaxDiffSafe.js.map +0 -7
- package/esm/DSDateRangePicker.js.map +0 -7
- package/esm/components/DSDateRangePickerImpl.js.map +0 -7
- package/esm/components/DatePickerLabel/DatePickerLabel.js.map +0 -7
- package/esm/components/DatePickerRangeHeader/DatePickerRangeHeader.js.map +0 -7
- package/esm/components/DayPickerRangeController.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/isMaxDiffSafe.js.map +0 -7
|
@@ -1,26 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
const START_DATE =
|
|
12
|
-
const END_DATE =
|
|
13
|
-
const {
|
|
14
|
-
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import moment from 'moment';
|
|
4
|
+
import { convertPropToCssClassName } from '@elliemae/ds-classnames';
|
|
5
|
+
import { DSFormItemLayout, DSInputMask, MASK_TYPES, MASK_PIPES } from '@elliemae/ds-form';
|
|
6
|
+
import DSPopper from '@elliemae/ds-popper';
|
|
7
|
+
import { renderMonthElement, DatePickerPicker } from '@elliemae/ds-date-picker';
|
|
8
|
+
import DayPickerRangeController from './DayPickerRangeController.js';
|
|
9
|
+
import { isMaxDiffSafe } from '../isMaxDiffSafe.js';
|
|
10
|
+
|
|
11
|
+
const START_DATE = 'startDate';
|
|
12
|
+
const END_DATE = 'endDate';
|
|
13
|
+
const {
|
|
14
|
+
classNameElement,
|
|
15
|
+
classNameBlock
|
|
16
|
+
} = convertPropToCssClassName('datepicker');
|
|
17
|
+
class DSDateRangePickerImpl extends React.Component {
|
|
15
18
|
constructor(props) {
|
|
16
19
|
super(props);
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
|
|
21
|
+
this.onDatesChange = _ref => {
|
|
22
|
+
let {
|
|
23
|
+
startDate,
|
|
24
|
+
endDate
|
|
25
|
+
} = _ref;
|
|
26
|
+
const {
|
|
27
|
+
onDatesChange
|
|
28
|
+
} = this.props;
|
|
19
29
|
onDatesChange(startDate, endDate);
|
|
20
30
|
const safe = isMaxDiffSafe(startDate, endDate, this.state.startDate, this.state.endDate);
|
|
31
|
+
|
|
21
32
|
if (!safe) {
|
|
22
|
-
this.setState({
|
|
33
|
+
this.setState({
|
|
34
|
+
showPicker: false
|
|
35
|
+
});
|
|
23
36
|
}
|
|
37
|
+
|
|
24
38
|
this.setState({
|
|
25
39
|
startDate,
|
|
26
40
|
endDate,
|
|
@@ -28,55 +42,85 @@ class DSDateRangePickerImpl extends React2.Component {
|
|
|
28
42
|
primaryEndInput: false
|
|
29
43
|
});
|
|
30
44
|
};
|
|
45
|
+
|
|
31
46
|
this.onFocusChange = () => {
|
|
32
|
-
this.setState(
|
|
33
|
-
|
|
34
|
-
|
|
47
|
+
this.setState(_ref2 => {
|
|
48
|
+
let {
|
|
49
|
+
focusedInput
|
|
50
|
+
} = _ref2;
|
|
51
|
+
return {
|
|
52
|
+
focusedInput: focusedInput === START_DATE ? END_DATE : START_DATE
|
|
53
|
+
};
|
|
54
|
+
});
|
|
35
55
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
56
|
+
|
|
57
|
+
this.handleKeyDown = event => {
|
|
58
|
+
if (event.key === 'Escape') this.setState({
|
|
59
|
+
showPicker: false
|
|
60
|
+
});
|
|
39
61
|
};
|
|
62
|
+
|
|
40
63
|
this.getSafeStartInputValue = () => {
|
|
41
|
-
const {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
64
|
+
const {
|
|
65
|
+
startInput,
|
|
66
|
+
primaryStartInput,
|
|
67
|
+
startDate
|
|
68
|
+
} = this.state;
|
|
69
|
+
if (primaryStartInput && startInput) return startInput;
|
|
70
|
+
if (!startDate) return '';
|
|
71
|
+
return startDate.format('MMDDYYYY');
|
|
47
72
|
};
|
|
73
|
+
|
|
48
74
|
this.getSafeEndInputValue = () => {
|
|
49
|
-
const {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
75
|
+
const {
|
|
76
|
+
endInput,
|
|
77
|
+
primaryEndInput,
|
|
78
|
+
endDate
|
|
79
|
+
} = this.state;
|
|
80
|
+
if (primaryEndInput && endInput) return endInput;
|
|
81
|
+
if (!endDate) return '';
|
|
82
|
+
return endDate.format('MMDDYYYY');
|
|
55
83
|
};
|
|
84
|
+
|
|
56
85
|
this.changeFocus = () => {
|
|
57
|
-
const {
|
|
86
|
+
const {
|
|
87
|
+
disabled
|
|
88
|
+
} = this.props;
|
|
89
|
+
|
|
58
90
|
if (!disabled) {
|
|
59
|
-
this.setState(() => ({
|
|
91
|
+
this.setState(() => ({
|
|
92
|
+
focusedInput: 'startDate'
|
|
93
|
+
}));
|
|
60
94
|
}
|
|
61
95
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
96
|
+
|
|
97
|
+
this.handleChangeStart = e => {
|
|
98
|
+
var _momentValue;
|
|
99
|
+
|
|
100
|
+
const {
|
|
101
|
+
onChangeStartInput,
|
|
102
|
+
isDayBlocked,
|
|
103
|
+
minimumNights
|
|
104
|
+
} = this.props;
|
|
105
|
+
const {
|
|
106
|
+
endDate
|
|
107
|
+
} = this.state;
|
|
65
108
|
const startInputVal = e.target.value;
|
|
66
109
|
let momentValue = null;
|
|
67
|
-
|
|
110
|
+
|
|
111
|
+
if (startInputVal && moment(startInputVal, 'MM/DD/YYYY', true).isValid()) {
|
|
68
112
|
momentValue = moment(startInputVal);
|
|
69
113
|
}
|
|
114
|
+
|
|
70
115
|
const startDateBlocked = isDayBlocked(momentValue);
|
|
71
|
-
const isStartDateAcceptable = !startDateBlocked && momentValue && startInputVal !==
|
|
72
|
-
const areDatesValid = endDate && momentValue && endDate
|
|
116
|
+
const isStartDateAcceptable = !startDateBlocked && momentValue && startInputVal !== '';
|
|
117
|
+
const areDatesValid = endDate && momentValue && (endDate === null || endDate === void 0 ? void 0 : endDate.isValid()) && ((_momentValue = momentValue) === null || _momentValue === void 0 ? void 0 : _momentValue.isValid());
|
|
73
118
|
const canEndBeSameAsStart = minimumNights === 0;
|
|
74
|
-
const isStartAcceptableWithSelectedEnd = !endDate || areDatesValid && (canEndBeSameAsStart && momentValue.diff(endDate,
|
|
119
|
+
const isStartAcceptableWithSelectedEnd = !endDate || areDatesValid && (canEndBeSameAsStart && momentValue.diff(endDate, 'days') <= 0 || !canEndBeSameAsStart && momentValue.diff(endDate, 'days') < 0);
|
|
75
120
|
const invalidDate = !isStartDateAcceptable || !isStartAcceptableWithSelectedEnd;
|
|
76
|
-
if (startDateBlocked)
|
|
77
|
-
momentValue = null;
|
|
121
|
+
if (startDateBlocked) momentValue = null;
|
|
78
122
|
onChangeStartInput(momentValue);
|
|
79
|
-
this.setState(
|
|
123
|
+
this.setState(prevState => ({
|
|
80
124
|
startDate: momentValue,
|
|
81
125
|
startInput: startInputVal,
|
|
82
126
|
primaryStartInput: true,
|
|
@@ -84,24 +128,38 @@ class DSDateRangePickerImpl extends React2.Component {
|
|
|
84
128
|
endDateError: !isStartDateAcceptable || !prevState.endDateError ? prevState.endDateError : !isStartAcceptableWithSelectedEnd
|
|
85
129
|
}));
|
|
86
130
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
131
|
+
|
|
132
|
+
this.handleChangeEnd = e => {
|
|
133
|
+
var _momentValue2;
|
|
134
|
+
|
|
135
|
+
const {
|
|
136
|
+
onChangeEndInput,
|
|
137
|
+
isDayBlocked,
|
|
138
|
+
minimumNights
|
|
139
|
+
} = this.props;
|
|
140
|
+
const {
|
|
141
|
+
startDate
|
|
142
|
+
} = this.state;
|
|
90
143
|
const endInputValue = e.target.value;
|
|
91
144
|
let momentValue = null;
|
|
92
|
-
|
|
145
|
+
|
|
146
|
+
if (endInputValue && moment(endInputValue, 'MM/DD/YYYY', true).isValid()) {
|
|
93
147
|
momentValue = moment(endInputValue);
|
|
94
148
|
}
|
|
149
|
+
|
|
95
150
|
const endDateBlocked = isDayBlocked(momentValue);
|
|
96
|
-
const isEndDateAcceptable = !endDateBlocked && momentValue && endInputValue !==
|
|
97
|
-
const areDatesValid = startDate && momentValue && startDate
|
|
151
|
+
const isEndDateAcceptable = !endDateBlocked && momentValue && endInputValue !== '';
|
|
152
|
+
const areDatesValid = startDate && momentValue && (startDate === null || startDate === void 0 ? void 0 : startDate.isValid()) && ((_momentValue2 = momentValue) === null || _momentValue2 === void 0 ? void 0 : _momentValue2.isValid());
|
|
98
153
|
const canEndBeSameAsStart = minimumNights === 0;
|
|
99
|
-
const isEndAcceptableWithSelectedStart = !startDate ||
|
|
154
|
+
const isEndAcceptableWithSelectedStart = !startDate || // we can't compare with start date because it's not yet set
|
|
155
|
+
areDatesValid && ( // it's set and both are valid
|
|
156
|
+
canEndBeSameAsStart && momentValue.diff(startDate, 'days') >= 0 || // >= is valid
|
|
157
|
+
!canEndBeSameAsStart && momentValue.diff(startDate, 'days') > 0); // only > is valid
|
|
158
|
+
|
|
100
159
|
const invalidDate = !isEndDateAcceptable || !isEndAcceptableWithSelectedStart;
|
|
101
|
-
if (endDateBlocked)
|
|
102
|
-
momentValue = null;
|
|
160
|
+
if (endDateBlocked) momentValue = null;
|
|
103
161
|
onChangeEndInput(momentValue);
|
|
104
|
-
this.setState(
|
|
162
|
+
this.setState(prevState => ({
|
|
105
163
|
endDate: momentValue,
|
|
106
164
|
endInput: endInputValue,
|
|
107
165
|
primaryEndInput: true,
|
|
@@ -109,7 +167,13 @@ class DSDateRangePickerImpl extends React2.Component {
|
|
|
109
167
|
endDateError: invalidDate
|
|
110
168
|
}));
|
|
111
169
|
};
|
|
112
|
-
|
|
170
|
+
|
|
171
|
+
this.handleChangeDate = _ref3 => {
|
|
172
|
+
let {
|
|
173
|
+
startDate: _start,
|
|
174
|
+
endDate
|
|
175
|
+
} = _ref3;
|
|
176
|
+
|
|
113
177
|
if (_start && endDate) {
|
|
114
178
|
this.setState({
|
|
115
179
|
startDate: moment(_start),
|
|
@@ -118,11 +182,18 @@ class DSDateRangePickerImpl extends React2.Component {
|
|
|
118
182
|
primaryEndInput: false
|
|
119
183
|
});
|
|
120
184
|
} else if (_start) {
|
|
121
|
-
this.setState({
|
|
185
|
+
this.setState({
|
|
186
|
+
startDate: moment(_start),
|
|
187
|
+
primaryStartInput: false
|
|
188
|
+
});
|
|
122
189
|
} else if (endDate) {
|
|
123
|
-
this.setState({
|
|
190
|
+
this.setState({
|
|
191
|
+
endDate,
|
|
192
|
+
primaryEndInput: false
|
|
193
|
+
});
|
|
124
194
|
}
|
|
125
195
|
};
|
|
196
|
+
|
|
126
197
|
this.state = {
|
|
127
198
|
startDate: props.startDate ? moment(props.startDate) : null,
|
|
128
199
|
endDate: props.endDate ? moment(props.endDate) : null,
|
|
@@ -132,14 +203,24 @@ class DSDateRangePickerImpl extends React2.Component {
|
|
|
132
203
|
endDateError: false
|
|
133
204
|
};
|
|
134
205
|
}
|
|
206
|
+
|
|
135
207
|
componentDidMount() {
|
|
136
|
-
document.addEventListener(
|
|
208
|
+
document.addEventListener('keydown', this.handleKeyDown, false);
|
|
137
209
|
}
|
|
210
|
+
|
|
138
211
|
componentWillUnmount() {
|
|
139
|
-
document.removeEventListener(
|
|
212
|
+
document.removeEventListener('keydown', this.handleKeyDown, false);
|
|
140
213
|
}
|
|
214
|
+
|
|
141
215
|
render() {
|
|
142
|
-
const {
|
|
216
|
+
const {
|
|
217
|
+
startDate,
|
|
218
|
+
endDate,
|
|
219
|
+
focusedInput,
|
|
220
|
+
showPicker,
|
|
221
|
+
startDateError,
|
|
222
|
+
endDateError
|
|
223
|
+
} = this.state;
|
|
143
224
|
const {
|
|
144
225
|
disabled,
|
|
145
226
|
displayFormatDay,
|
|
@@ -159,106 +240,91 @@ class DSDateRangePickerImpl extends React2.Component {
|
|
|
159
240
|
hasError,
|
|
160
241
|
validationMessage
|
|
161
242
|
} = this.props;
|
|
162
|
-
const inputClass = classNameBlock(
|
|
163
|
-
const inputClassModifier =
|
|
243
|
+
const inputClass = classNameBlock('inputs', 'range-picker');
|
|
244
|
+
const inputClassModifier = '';
|
|
164
245
|
const safeStartInputValue = this.getSafeStartInputValue();
|
|
165
246
|
const safeEndInputValue = this.getSafeEndInputValue();
|
|
166
|
-
return
|
|
167
|
-
className:
|
|
168
|
-
},
|
|
169
|
-
className: classNameBlock(
|
|
170
|
-
},
|
|
247
|
+
return /*#__PURE__*/_jsx("div", {
|
|
248
|
+
className: "".concat(inputClass, " ").concat(inputClassModifier)
|
|
249
|
+
}, void 0, /*#__PURE__*/_jsx("div", {
|
|
250
|
+
className: classNameBlock('wrapper-input-date-range-picker-controller')
|
|
251
|
+
}, void 0, /*#__PURE__*/_jsx(DSFormItemLayout, {
|
|
171
252
|
floatingLabel: true,
|
|
172
253
|
inputComponent: DSInputMask,
|
|
173
254
|
labelText: labelFrom,
|
|
174
255
|
mask: MASK_TYPES.DATE,
|
|
175
256
|
onChange: this.handleChangeStart,
|
|
176
|
-
onFocus: () => this.setState({
|
|
257
|
+
onFocus: () => this.setState({
|
|
258
|
+
showPicker: false
|
|
259
|
+
}),
|
|
177
260
|
pipe: MASK_PIPES.AUTO_CORRECT_DATE,
|
|
178
261
|
value: safeStartInputValue,
|
|
179
262
|
required: startDateRequired,
|
|
180
263
|
hasError: hasError || startDateError,
|
|
181
264
|
placeholder: "MM/DD/YYYY"
|
|
182
|
-
}),
|
|
265
|
+
}), /*#__PURE__*/_jsx(DSFormItemLayout, {
|
|
183
266
|
floatingLabel: true,
|
|
184
267
|
inputComponent: DSInputMask,
|
|
185
268
|
labelText: labelTo,
|
|
186
269
|
mask: MASK_TYPES.DATE,
|
|
187
270
|
onChange: this.handleChangeEnd,
|
|
188
|
-
onFocus: () => this.setState({
|
|
271
|
+
onFocus: () => this.setState({
|
|
272
|
+
showPicker: false
|
|
273
|
+
}),
|
|
189
274
|
pipe: MASK_PIPES.AUTO_CORRECT_DATE,
|
|
190
275
|
value: safeEndInputValue,
|
|
191
276
|
required: endDateRequired,
|
|
192
277
|
hasError: hasError || endDateError,
|
|
193
|
-
validationMessage,
|
|
278
|
+
validationMessage: validationMessage,
|
|
194
279
|
placeholder: "MM/DD/YYYY"
|
|
195
|
-
})),
|
|
196
|
-
className: classNameBlock(
|
|
197
|
-
},
|
|
198
|
-
contentComponent:
|
|
199
|
-
enableOutsideDays,
|
|
200
|
-
isDayBlocked,
|
|
201
|
-
isDayHighlighted,
|
|
202
|
-
isOutsideRange,
|
|
203
|
-
displayFormatDay,
|
|
204
|
-
endDate,
|
|
205
|
-
focusedInput,
|
|
280
|
+
})), /*#__PURE__*/_jsx("div", {
|
|
281
|
+
className: classNameBlock('wrapper-button-date-range-picker-controller')
|
|
282
|
+
}, void 0, /*#__PURE__*/_jsx(DSPopper, {
|
|
283
|
+
contentComponent: /*#__PURE__*/_jsx("div", {}, void 0, showPicker && /*#__PURE__*/_jsx(DayPickerRangeController, {
|
|
284
|
+
enableOutsideDays: enableOutsideDays,
|
|
285
|
+
isDayBlocked: isDayBlocked,
|
|
286
|
+
isDayHighlighted: isDayHighlighted,
|
|
287
|
+
isOutsideRange: isOutsideRange,
|
|
288
|
+
displayFormatDay: displayFormatDay,
|
|
289
|
+
endDate: endDate,
|
|
290
|
+
focusedInput: focusedInput,
|
|
206
291
|
hideKeyboardShortcutsPanel: true,
|
|
207
|
-
minimumNights,
|
|
292
|
+
minimumNights: minimumNights,
|
|
208
293
|
onDatesChange: this.onDatesChange,
|
|
209
294
|
onFocusChange: this.onFocusChange,
|
|
210
|
-
onOutsideClick:
|
|
295
|
+
onOutsideClick: e => {
|
|
211
296
|
onOutsideClick(e);
|
|
212
|
-
this.setState({
|
|
297
|
+
this.setState({
|
|
298
|
+
showPicker: false
|
|
299
|
+
});
|
|
213
300
|
},
|
|
214
|
-
onNextMonthClick,
|
|
215
|
-
onPrevMonthClick,
|
|
216
|
-
startDate,
|
|
217
|
-
renderMonthElement
|
|
301
|
+
onNextMonthClick: onNextMonthClick,
|
|
302
|
+
onPrevMonthClick: onPrevMonthClick,
|
|
303
|
+
startDate: startDate,
|
|
304
|
+
renderMonthElement: renderMonthElement
|
|
218
305
|
})),
|
|
219
306
|
isOpen: showPicker && !startDateError && !endDateError,
|
|
220
|
-
onClose,
|
|
307
|
+
onClose: onClose,
|
|
221
308
|
placement: "bottom-end",
|
|
222
309
|
showArrow: false,
|
|
223
|
-
triggerComponent:
|
|
224
|
-
onFocus: () => this.setState({
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
310
|
+
triggerComponent: /*#__PURE__*/_jsx("div", {
|
|
311
|
+
onFocus: () => this.setState({
|
|
312
|
+
showPicker: true
|
|
313
|
+
})
|
|
314
|
+
}, void 0, /*#__PURE__*/_jsx(DatePickerPicker, {
|
|
315
|
+
className: classNameElement('picker'),
|
|
316
|
+
disabled: disabled,
|
|
317
|
+
onClick: () => this.setState({
|
|
318
|
+
showPicker: true
|
|
319
|
+
})
|
|
320
|
+
}), hasError && validationMessage && /*#__PURE__*/_jsx("div", {
|
|
321
|
+
style: {
|
|
322
|
+
height: 15
|
|
323
|
+
}
|
|
231
324
|
}))
|
|
232
325
|
})));
|
|
233
326
|
}
|
|
327
|
+
|
|
234
328
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
endDate: PropTypes.instanceOf(Date, moment),
|
|
238
|
-
onDatesChange: PropTypes.func,
|
|
239
|
-
onChangeStartInput: PropTypes.func,
|
|
240
|
-
onChangeEndInput: PropTypes.func,
|
|
241
|
-
onNextMonthClick: PropTypes.func,
|
|
242
|
-
onPrevMonthClick: PropTypes.func,
|
|
243
|
-
onClose: PropTypes.func,
|
|
244
|
-
onOutsideClick: PropTypes.func,
|
|
245
|
-
disabled: PropTypes.bool,
|
|
246
|
-
displayFormatDay: PropTypes.string,
|
|
247
|
-
minimumNights: PropTypes.number,
|
|
248
|
-
labelTo: PropTypes.string,
|
|
249
|
-
labelFrom: PropTypes.string,
|
|
250
|
-
isDayBlocked: PropTypes.func,
|
|
251
|
-
isDayHighlighted: PropTypes.func,
|
|
252
|
-
isOutsideRange: PropTypes.func,
|
|
253
|
-
enableOutsideDays: PropTypes.bool,
|
|
254
|
-
startDateRequired: PropTypes.bool,
|
|
255
|
-
endDateRequired: PropTypes.bool,
|
|
256
|
-
hasError: PropTypes.bool,
|
|
257
|
-
validationMessage: PropTypes.string
|
|
258
|
-
};
|
|
259
|
-
export {
|
|
260
|
-
END_DATE,
|
|
261
|
-
START_DATE,
|
|
262
|
-
DSDateRangePickerImpl as default
|
|
263
|
-
};
|
|
264
|
-
//# sourceMappingURL=DSDateRangePickerImpl.js.map
|
|
329
|
+
|
|
330
|
+
export { END_DATE, START_DATE, DSDateRangePickerImpl as default };
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'react';
|
|
3
|
+
|
|
4
|
+
const Label = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
className = 'date-picker-label',
|
|
7
|
+
label = ''
|
|
8
|
+
} = _ref;
|
|
9
|
+
return /*#__PURE__*/_jsx("div", {
|
|
10
|
+
className: className
|
|
11
|
+
}, void 0, /*#__PURE__*/_jsx("span", {}, void 0, label));
|
|
9
12
|
};
|
|
10
|
-
|
|
13
|
+
|
|
14
|
+
export { Label as default };
|
|
@@ -1,63 +1,75 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
|
+
import moment from 'moment';
|
|
5
|
+
import DSInputMask, { DSInputGroup, MASK_TYPES, MASK_PIPES } from '@elliemae/ds-form';
|
|
6
|
+
import { aggregatedClasses } from '@elliemae/ds-classnames';
|
|
7
|
+
|
|
8
|
+
const blockname = 'date-range-picker';
|
|
9
|
+
const Header = aggregatedClasses('div')(blockname, 'header');
|
|
10
|
+
|
|
11
|
+
const formatDate = date => {
|
|
9
12
|
if (date) {
|
|
10
|
-
return date.format(
|
|
13
|
+
return date.format('MMDDYYYY');
|
|
11
14
|
}
|
|
12
15
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
|
|
17
|
+
const DatePickerRangeHeader = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
placeholderStart = 'Start Date',
|
|
20
|
+
placeholderEnd = 'End Date',
|
|
21
|
+
onStartInputChange = () => null,
|
|
22
|
+
onEndInputChange = () => null,
|
|
23
|
+
selectedStartDate,
|
|
24
|
+
selectedEndDate
|
|
25
|
+
} = _ref;
|
|
26
|
+
const [startValue, setStartValue] = useState(selectedStartDate ? formatDate(selectedStartDate) : '');
|
|
27
|
+
const [endValue, setEndValue] = useState(selectedEndDate ? formatDate(selectedEndDate) : '');
|
|
23
28
|
useEffect(() => {
|
|
24
29
|
const startDate = formatDate(selectedStartDate);
|
|
25
30
|
const endDate = formatDate(selectedEndDate);
|
|
26
31
|
startDate !== startValue && setStartValue(startDate);
|
|
27
32
|
endDate !== endValue && setEndValue(endDate);
|
|
28
33
|
}, [selectedStartDate, selectedEndDate]);
|
|
29
|
-
|
|
34
|
+
|
|
35
|
+
const handleOnChangeStart = e => {
|
|
30
36
|
const newStartValue = e.target.value;
|
|
31
37
|
setStartValue(newStartValue);
|
|
32
38
|
};
|
|
33
|
-
|
|
39
|
+
|
|
40
|
+
const handleOnChangeEnd = e => {
|
|
34
41
|
const newEndValue = e.target.value;
|
|
35
42
|
setEndValue(newEndValue);
|
|
36
43
|
};
|
|
37
|
-
|
|
44
|
+
|
|
45
|
+
const handleOnBlurStart = e => {
|
|
38
46
|
const newStartValue = e.target.value;
|
|
39
47
|
onStartInputChange(moment(newStartValue));
|
|
40
48
|
};
|
|
41
|
-
|
|
49
|
+
|
|
50
|
+
const handleOnBlurEnd = e => {
|
|
42
51
|
const newEndValue = e.target.value;
|
|
43
52
|
onEndInputChange(moment(newEndValue));
|
|
44
53
|
};
|
|
45
|
-
|
|
46
|
-
|
|
54
|
+
|
|
55
|
+
const handleOnKeyDownStart = e => {
|
|
56
|
+
if (e.key === 'Enter') {
|
|
47
57
|
const newValue = e.target.value;
|
|
48
58
|
onStartInputChange(moment(newValue));
|
|
49
59
|
e.target.blur();
|
|
50
60
|
}
|
|
51
61
|
};
|
|
52
|
-
|
|
53
|
-
|
|
62
|
+
|
|
63
|
+
const handleOnKeyDownEnd = e => {
|
|
64
|
+
if (e.key === 'Enter') {
|
|
54
65
|
const newValue = e.target.value;
|
|
55
66
|
onEndInputChange(moment(newValue));
|
|
56
67
|
e.target.blur();
|
|
57
68
|
}
|
|
58
69
|
};
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
|
|
71
|
+
return /*#__PURE__*/_jsx(Header, {}, void 0, /*#__PURE__*/_jsx(DSInputGroup, {}, void 0, /*#__PURE__*/_jsx(DSInputMask, {
|
|
72
|
+
"aria-label": placeholderStart || 'Date Picker Input Mask',
|
|
61
73
|
mask: MASK_TYPES.DATE,
|
|
62
74
|
onBlur: handleOnBlurStart,
|
|
63
75
|
onChange: handleOnChangeStart,
|
|
@@ -65,8 +77,8 @@ const DatePickerRangeHeader = ({
|
|
|
65
77
|
pipe: MASK_PIPES.AUTO_CORRECT_DATE,
|
|
66
78
|
placeholder: placeholderStart,
|
|
67
79
|
value: startValue
|
|
68
|
-
}),
|
|
69
|
-
"aria-label": placeholderEnd ||
|
|
80
|
+
}), /*#__PURE__*/_jsx(DSInputMask, {
|
|
81
|
+
"aria-label": placeholderEnd || 'Date Picker Input Mask',
|
|
70
82
|
mask: MASK_TYPES.DATE,
|
|
71
83
|
onBlur: handleOnBlurEnd,
|
|
72
84
|
onChange: handleOnChangeEnd,
|
|
@@ -76,8 +88,5 @@ const DatePickerRangeHeader = ({
|
|
|
76
88
|
value: endValue
|
|
77
89
|
})));
|
|
78
90
|
};
|
|
79
|
-
|
|
80
|
-
export {
|
|
81
|
-
DatePickerRangeHeader_default as default
|
|
82
|
-
};
|
|
83
|
-
//# sourceMappingURL=DatePickerRangeHeader.js.map
|
|
91
|
+
|
|
92
|
+
export { DatePickerRangeHeader as default };
|