@elliemae/ds-date-range-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.
Files changed (49) hide show
  1. package/dist/cjs/DSDateRangePicker.js +226 -0
  2. package/dist/cjs/DSDateRangePicker.js.map +7 -0
  3. package/dist/cjs/components/DSDateRangePickerImpl.js +293 -0
  4. package/dist/cjs/components/DSDateRangePickerImpl.js.map +7 -0
  5. package/dist/cjs/components/DatePickerLabel/DatePickerLabel.js +39 -0
  6. package/dist/cjs/components/DatePickerLabel/DatePickerLabel.js.map +7 -0
  7. package/dist/cjs/components/DatePickerRangeHeader/DatePickerRangeHeader.js +112 -0
  8. package/dist/cjs/components/DatePickerRangeHeader/DatePickerRangeHeader.js.map +7 -0
  9. package/dist/cjs/components/DayPickerRangeController.js +203 -0
  10. package/dist/cjs/components/DayPickerRangeController.js.map +7 -0
  11. package/dist/cjs/index.js +36 -0
  12. package/dist/cjs/index.js.map +7 -0
  13. package/dist/cjs/isMaxDiffSafe.js +46 -0
  14. package/dist/cjs/isMaxDiffSafe.js.map +7 -0
  15. package/dist/esm/DSDateRangePicker.js +202 -0
  16. package/dist/esm/DSDateRangePicker.js.map +7 -0
  17. package/dist/esm/components/DSDateRangePickerImpl.js +264 -0
  18. package/dist/esm/components/DSDateRangePickerImpl.js.map +7 -0
  19. package/dist/esm/components/DatePickerLabel/DatePickerLabel.js +10 -0
  20. package/dist/esm/components/DatePickerLabel/DatePickerLabel.js.map +7 -0
  21. package/{esm → dist/esm}/components/DatePickerRangeHeader/DatePickerRangeHeader.js +36 -45
  22. package/dist/esm/components/DatePickerRangeHeader/DatePickerRangeHeader.js.map +7 -0
  23. package/dist/esm/components/DayPickerRangeController.js +176 -0
  24. package/dist/esm/components/DayPickerRangeController.js.map +7 -0
  25. package/dist/esm/index.js +7 -0
  26. package/dist/esm/index.js.map +7 -0
  27. package/dist/esm/isMaxDiffSafe.js +17 -0
  28. package/dist/esm/isMaxDiffSafe.js.map +7 -0
  29. package/package.json +41 -32
  30. package/cjs/DSDateRangePicker.js +0 -204
  31. package/cjs/components/DSDateRangePickerImpl.js +0 -343
  32. package/cjs/components/DatePickerLabel/DatePickerLabel.js +0 -20
  33. package/cjs/components/DatePickerRangeHeader/DatePickerRangeHeader.js +0 -100
  34. package/cjs/components/DayPickerRangeController.js +0 -147
  35. package/cjs/index.js +0 -15
  36. package/cjs/isMaxDiffSafe.js +0 -20
  37. package/esm/DSDateRangePicker.js +0 -191
  38. package/esm/components/DSDateRangePickerImpl.js +0 -330
  39. package/esm/components/DatePickerLabel/DatePickerLabel.js +0 -14
  40. package/esm/components/DayPickerRangeController.js +0 -139
  41. package/esm/index.js +0 -3
  42. package/esm/isMaxDiffSafe.js +0 -15
  43. package/types/DSDateRangePicker.d.ts +0 -243
  44. package/types/components/DSDateRangePickerImpl.d.ts +0 -24
  45. package/types/components/DatePickerLabel/DatePickerLabel.d.ts +0 -6
  46. package/types/components/DatePickerRangeHeader/DatePickerRangeHeader.d.ts +0 -10
  47. package/types/components/DayPickerRangeController.d.ts +0 -36
  48. package/types/index.d.ts +0 -2
  49. package/types/isMaxDiffSafe.d.ts +0 -2
@@ -1,191 +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 { convertPropToCssClassName } from '@elliemae/ds-classnames';
11
- import moment from 'moment';
12
- import 'react-dates/initialize';
13
- import { DateRangePickerPhrases } from 'react-dates/lib/defaultPhrases';
14
- export { default as DayPickerRangeController } from './components/DayPickerRangeController.js';
15
- import DSDateRangePickerImpl from './components/DSDateRangePickerImpl.js';
16
- export { END_DATE, START_DATE } from './components/DSDateRangePickerImpl.js';
17
- import { jsx } from 'react/jsx-runtime';
18
-
19
- 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; }
20
-
21
- 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; }
22
-
23
- const DSDateRangePicker = _ref => {
24
- let {
25
- containerProps = {},
26
- className = '',
27
- disabled = false,
28
- required = false,
29
- startDateRequired = false,
30
- endDateRequired = false,
31
- id,
32
- hasError = false,
33
- validationMessage = '',
34
- readOnly = false,
35
- screenReaderInputMessage = 'Select date',
36
- initialVisibleMonth = moment(),
37
- firstDayOfWeek = 0,
38
- keepOpenOnDateSelect = true,
39
- reopenPickerOnClearDates = false,
40
- hideKeyboardShortcutsPanel = true,
41
- onPrevMonthClick = () => null,
42
- onNextMonthClick = () => null,
43
- onClose = () => null,
44
- onOutsideClick = () => null,
45
- transitionDuration = 0,
46
- verticalSpacing = 0,
47
- minimumNights = 0,
48
- isDayBlocked = () => false,
49
- isOutsideRange = () => false,
50
- isDayHighlighted = () => false,
51
- displayFormat = 'L',
52
- displayFormatDay = 'D',
53
- phrases = DateRangePickerPhrases,
54
- startDate,
55
- endDate,
56
- startDateId = 'startDateId',
57
- endDateId = 'endDateId',
58
- labelFrom = 'From',
59
- labelTo = 'To',
60
- enableOutsideDays = true,
61
- onChangeStartInput = () => null,
62
- onChangeEndInput = () => null,
63
- onDatesChange = () => null
64
- } = _ref;
65
- const {
66
- cssClassName,
67
- prefixBlockName
68
- } = convertPropToCssClassName('datepicker', className, {
69
- hasError,
70
- readOnly,
71
- disabled,
72
- id
73
- });
74
- return /*#__PURE__*/jsx("div", _objectSpread(_objectSpread({}, containerProps), {}, {
75
- className: "".concat(prefixBlockName, "-range ").concat(cssClassName, " ").concat(prefixBlockName, "-range"),
76
- children: /*#__PURE__*/_jsx(DSDateRangePickerImpl, {
77
- appendToBody: true,
78
- disabled: disabled,
79
- displayFormat: displayFormat,
80
- displayFormatDay: displayFormatDay,
81
- enableOutsideDays: enableOutsideDays,
82
- endDate: endDate,
83
- endDateId: endDateId,
84
- firstDayOfWeek: firstDayOfWeek,
85
- hideKeyboardShortcutsPanel: hideKeyboardShortcutsPanel,
86
- initialVisibleMonth: () => initialVisibleMonth ? moment(initialVisibleMonth) : moment(startDate),
87
- isDayBlocked: isDayBlocked,
88
- isDayHighlighted: isDayHighlighted,
89
- isOutsideRange: isOutsideRange === true || isOutsideRange === false ? () => isOutsideRange : isOutsideRange,
90
- keepOpenOnDateSelect: keepOpenOnDateSelect,
91
- labelFrom: labelFrom,
92
- labelTo: labelTo,
93
- minimumNights: minimumNights,
94
- onDatesChange: onDatesChange,
95
- onChangeStartInput: onChangeStartInput,
96
- onChangeEndInput: onChangeEndInput,
97
- onClose: onClose,
98
- onNextMonthClick: onNextMonthClick,
99
- onPrevMonthClick: onPrevMonthClick,
100
- onOutsideClick: onOutsideClick,
101
- phrases: phrases,
102
- readOnly: readOnly,
103
- reopenPickerOnClearDates: reopenPickerOnClearDates,
104
- required: required,
105
- startDateRequired: startDateRequired,
106
- endDateRequired: endDateRequired,
107
- screenReaderInputMessage: screenReaderInputMessage,
108
- startDate: startDate,
109
- startDateId: startDateId,
110
- transitionDuration: transitionDuration,
111
- verticalSpacing: verticalSpacing,
112
- hasError: hasError,
113
- validationMessage: validationMessage
114
- })
115
- }));
116
- };
117
-
118
- const dateRangePickerProps = {
119
- containerProps: PropTypes.shape({}).description('Set of Properties attached to the main container'),
120
- className: PropTypes.string.description('html class attribute'),
121
- disabled: PropTypes.bool.description('disable component or not').defaultValue(false),
122
- required: PropTypes.bool.description('input is required or not').defaultValue(false),
123
- startDateRequired: PropTypes.bool.description('start date is required or not').defaultValue(false),
124
- endDateRequired: PropTypes.bool.description('end date is required or not').defaultValue(false),
125
- id: PropTypes.string.description('components id'),
126
- hasError: PropTypes.bool.description('set error state').defaultValue(false),
127
- validationMessage: PropTypes.string.description('validation message'),
128
- readOnly: PropTypes.bool.description('component is read only or not').description(false),
129
- screenReaderInputMessage: PropTypes.string.description('message to be anounced by screen reader').defaultValue('select date'),
130
- initialVisibleMonth: PropTypes.instanceOf(Date, moment).description('initial visible month'),
131
- firstDayOfWeek: PropTypes.number.description('first day of week').defaultValue(0),
132
- keepOpenOnDateSelect: PropTypes.bool.description('keep picker open when a date is selected').defaultValue(true),
133
- reopenPickerOnClearDates: PropTypes.bool.description('reopen picker when clearing dates').defaultValue(false),
134
- hideKeyboardShortcutsPanel: PropTypes.bool.description('hide keyabord shortcut panel or not'),
135
- onPrevMonthClick: PropTypes.func.description('function executed when clicking on prev month button'),
136
- onNextMonthClick: PropTypes.func.description('function executed when clicking on next month button'),
137
- onClose: PropTypes.func.description('function executed when component closes'),
138
- transitionDuration: PropTypes.number.description('transition duration').defaultValue(0),
139
- verticalSpacing: PropTypes.number.description('vertical spacing'),
140
- isDayBlocked: PropTypes.func.description('function that returns each day and disables desired dates'),
141
- isOutsideRange: PropTypes.func.description('function that returns each day and disables outisde range dates'),
142
- isDayHighlighted: PropTypes.func.description('function that returns each day and higlights desired dates'),
143
- minimumNights: 0,
144
- displayFormat: PropTypes.string.description('display format').defaultValue('L'),
145
- displayFormatDay: PropTypes.string.description('display format day').defaultValue('D'),
146
- phrases: PropTypes.shape({
147
- calendarLabel: PropTypes.string,
148
- closeDatePicker: PropTypes.string,
149
- clearDates: PropTypes.string,
150
- focusStartDate: PropTypes.string,
151
- jumpToPrevMonth: PropTypes.string,
152
- jumpToNextMonth: PropTypes.string,
153
- keyboardShortcuts: PropTypes.string,
154
- showKeyboardShortcutsPanel: PropTypes.string,
155
- hideKeyboardShortcutsPanel: PropTypes.string,
156
- openThisPanel: PropTypes.string,
157
- enterKey: PropTypes.string,
158
- leftArrowRightArrow: PropTypes.string,
159
- upArrowDownArrow: PropTypes.string,
160
- pageUpPageDown: PropTypes.string,
161
- homeEnd: PropTypes.string,
162
- escape: PropTypes.string,
163
- questionMark: PropTypes.string,
164
- selectFocusedDate: PropTypes.string,
165
- moveFocusByOneDay: PropTypes.string,
166
- moveFocusByOneWeek: PropTypes.string,
167
- moveFocusByOneMonth: PropTypes.string,
168
- moveFocustoStartAndEndOfWeek: PropTypes.string,
169
- returnFocusToInput: PropTypes.string,
170
- keyboardNavigationInstructions: PropTypes.string,
171
- chooseAvailableStartDate: PropTypes.func,
172
- chooseAvailableEndDate: PropTypes.func,
173
- dateIsUnavailable: PropTypes.func,
174
- dateIsSelected: PropTypes.func
175
- }).description('react-dates phrases'),
176
- startDate: PropTypes.instanceOf(Date, moment).description('start date value'),
177
- endDate: PropTypes.instanceOf(Date, moment).description('end date value'),
178
- startDateId: PropTypes.string.description('start date id'),
179
- endDateId: PropTypes.string.description('end date id'),
180
- labelFrom: PropTypes.string.description('label of start date input'),
181
- labelTo: PropTypes.string.description('label of end date input'),
182
- enableOutsideDays: PropTypes.bool.description('enable days outside current month').defaultValue('true'),
183
- onDatesChange: PropTypes.func.description('function executed when dates change'),
184
- onChangeStartInput: PropTypes.func.description('function executed when start date input changes'),
185
- onChangeEndInput: PropTypes.func.description('function executed when end date input changes'),
186
- onOutsideClick: PropTypes.func.description('function executed when clicking outside component')
187
- };
188
- const DateRangePickerWithSchema = describe(DSDateRangePicker);
189
- DateRangePickerWithSchema.propTypes = dateRangePickerProps;
190
-
191
- export { DateRangePickerWithSchema, DSDateRangePicker as default };
@@ -1,330 +0,0 @@
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 {
18
- constructor(props) {
19
- super(props);
20
-
21
- this.onDatesChange = _ref => {
22
- let {
23
- startDate,
24
- endDate
25
- } = _ref;
26
- const {
27
- onDatesChange
28
- } = this.props;
29
- onDatesChange(startDate, endDate);
30
- const safe = isMaxDiffSafe(startDate, endDate, this.state.startDate, this.state.endDate);
31
-
32
- if (!safe) {
33
- this.setState({
34
- showPicker: false
35
- });
36
- }
37
-
38
- this.setState({
39
- startDate,
40
- endDate,
41
- primaryStartInput: false,
42
- primaryEndInput: false
43
- });
44
- };
45
-
46
- this.onFocusChange = () => {
47
- this.setState(_ref2 => {
48
- let {
49
- focusedInput
50
- } = _ref2;
51
- return {
52
- focusedInput: focusedInput === START_DATE ? END_DATE : START_DATE
53
- };
54
- });
55
- };
56
-
57
- this.handleKeyDown = event => {
58
- if (event.key === 'Escape') this.setState({
59
- showPicker: false
60
- });
61
- };
62
-
63
- this.getSafeStartInputValue = () => {
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');
72
- };
73
-
74
- this.getSafeEndInputValue = () => {
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');
83
- };
84
-
85
- this.changeFocus = () => {
86
- const {
87
- disabled
88
- } = this.props;
89
-
90
- if (!disabled) {
91
- this.setState(() => ({
92
- focusedInput: 'startDate'
93
- }));
94
- }
95
- };
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;
108
- const startInputVal = e.target.value;
109
- let momentValue = null;
110
-
111
- if (startInputVal && moment(startInputVal, 'MM/DD/YYYY', true).isValid()) {
112
- momentValue = moment(startInputVal);
113
- }
114
-
115
- const startDateBlocked = isDayBlocked(momentValue);
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());
118
- const canEndBeSameAsStart = minimumNights === 0;
119
- const isStartAcceptableWithSelectedEnd = !endDate || areDatesValid && (canEndBeSameAsStart && momentValue.diff(endDate, 'days') <= 0 || !canEndBeSameAsStart && momentValue.diff(endDate, 'days') < 0);
120
- const invalidDate = !isStartDateAcceptable || !isStartAcceptableWithSelectedEnd;
121
- if (startDateBlocked) momentValue = null;
122
- onChangeStartInput(momentValue);
123
- this.setState(prevState => ({
124
- startDate: momentValue,
125
- startInput: startInputVal,
126
- primaryStartInput: true,
127
- startDateError: invalidDate,
128
- endDateError: !isStartDateAcceptable || !prevState.endDateError ? prevState.endDateError : !isStartAcceptableWithSelectedEnd
129
- }));
130
- };
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;
143
- const endInputValue = e.target.value;
144
- let momentValue = null;
145
-
146
- if (endInputValue && moment(endInputValue, 'MM/DD/YYYY', true).isValid()) {
147
- momentValue = moment(endInputValue);
148
- }
149
-
150
- const endDateBlocked = isDayBlocked(momentValue);
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());
153
- const canEndBeSameAsStart = minimumNights === 0;
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
-
159
- const invalidDate = !isEndDateAcceptable || !isEndAcceptableWithSelectedStart;
160
- if (endDateBlocked) momentValue = null;
161
- onChangeEndInput(momentValue);
162
- this.setState(prevState => ({
163
- endDate: momentValue,
164
- endInput: endInputValue,
165
- primaryEndInput: true,
166
- startDateError: !isEndDateAcceptable || !prevState.startDateError ? prevState.startDateError : !isEndAcceptableWithSelectedStart,
167
- endDateError: invalidDate
168
- }));
169
- };
170
-
171
- this.handleChangeDate = _ref3 => {
172
- let {
173
- startDate: _start,
174
- endDate
175
- } = _ref3;
176
-
177
- if (_start && endDate) {
178
- this.setState({
179
- startDate: moment(_start),
180
- endDate,
181
- primaryStartInput: false,
182
- primaryEndInput: false
183
- });
184
- } else if (_start) {
185
- this.setState({
186
- startDate: moment(_start),
187
- primaryStartInput: false
188
- });
189
- } else if (endDate) {
190
- this.setState({
191
- endDate,
192
- primaryEndInput: false
193
- });
194
- }
195
- };
196
-
197
- this.state = {
198
- startDate: props.startDate ? moment(props.startDate) : null,
199
- endDate: props.endDate ? moment(props.endDate) : null,
200
- focusedInput: START_DATE,
201
- showPicker: false,
202
- startDateError: false,
203
- endDateError: false
204
- };
205
- }
206
-
207
- componentDidMount() {
208
- document.addEventListener('keydown', this.handleKeyDown, false);
209
- }
210
-
211
- componentWillUnmount() {
212
- document.removeEventListener('keydown', this.handleKeyDown, false);
213
- }
214
-
215
- render() {
216
- const {
217
- startDate,
218
- endDate,
219
- focusedInput,
220
- showPicker,
221
- startDateError,
222
- endDateError
223
- } = this.state;
224
- const {
225
- disabled,
226
- displayFormatDay,
227
- minimumNights,
228
- labelFrom,
229
- labelTo,
230
- isDayBlocked,
231
- isDayHighlighted,
232
- isOutsideRange,
233
- enableOutsideDays,
234
- startDateRequired,
235
- endDateRequired,
236
- onOutsideClick,
237
- onNextMonthClick,
238
- onPrevMonthClick,
239
- onClose,
240
- hasError,
241
- validationMessage
242
- } = this.props;
243
- const inputClass = classNameBlock('inputs', 'range-picker');
244
- const inputClassModifier = '';
245
- const safeStartInputValue = this.getSafeStartInputValue();
246
- const safeEndInputValue = this.getSafeEndInputValue();
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, {
252
- floatingLabel: true,
253
- inputComponent: DSInputMask,
254
- labelText: labelFrom,
255
- mask: MASK_TYPES.DATE,
256
- onChange: this.handleChangeStart,
257
- onFocus: () => this.setState({
258
- showPicker: false
259
- }),
260
- pipe: MASK_PIPES.AUTO_CORRECT_DATE,
261
- value: safeStartInputValue,
262
- required: startDateRequired,
263
- hasError: hasError || startDateError,
264
- placeholder: "MM/DD/YYYY"
265
- }), /*#__PURE__*/_jsx(DSFormItemLayout, {
266
- floatingLabel: true,
267
- inputComponent: DSInputMask,
268
- labelText: labelTo,
269
- mask: MASK_TYPES.DATE,
270
- onChange: this.handleChangeEnd,
271
- onFocus: () => this.setState({
272
- showPicker: false
273
- }),
274
- pipe: MASK_PIPES.AUTO_CORRECT_DATE,
275
- value: safeEndInputValue,
276
- required: endDateRequired,
277
- hasError: hasError || endDateError,
278
- validationMessage: validationMessage,
279
- placeholder: "MM/DD/YYYY"
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,
291
- hideKeyboardShortcutsPanel: true,
292
- minimumNights: minimumNights,
293
- onDatesChange: this.onDatesChange,
294
- onFocusChange: this.onFocusChange,
295
- onOutsideClick: e => {
296
- onOutsideClick(e);
297
- this.setState({
298
- showPicker: false
299
- });
300
- },
301
- onNextMonthClick: onNextMonthClick,
302
- onPrevMonthClick: onPrevMonthClick,
303
- startDate: startDate,
304
- renderMonthElement: renderMonthElement
305
- })),
306
- isOpen: showPicker && !startDateError && !endDateError,
307
- onClose: onClose,
308
- placement: "bottom-end",
309
- showArrow: false,
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
- }
324
- }))
325
- })));
326
- }
327
-
328
- }
329
-
330
- export { END_DATE, START_DATE, DSDateRangePickerImpl as default };
@@ -1,14 +0,0 @@
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));
12
- };
13
-
14
- export { Label as default };
@@ -1,139 +0,0 @@
1
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
- import _jsx from '@babel/runtime/helpers/esm/jsx';
3
- import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
4
- import 'core-js/modules/web.dom-collections.iterator.js';
5
- import 'core-js/modules/esnext.async-iterator.filter.js';
6
- import 'core-js/modules/esnext.iterator.constructor.js';
7
- import 'core-js/modules/esnext.iterator.filter.js';
8
- import 'core-js/modules/esnext.async-iterator.for-each.js';
9
- import 'core-js/modules/esnext.iterator.for-each.js';
10
- import { useRef, useEffect } from 'react';
11
- import { DayPickerRangeController as DayPickerRangeController$1 } from 'react-dates';
12
- import { DatePickerNavigation, DatePickerDay, renderMonthElement } from '@elliemae/ds-date-picker';
13
- import { ChevronLeft } from '@elliemae/ds-icons';
14
- import { convertPropToCssClassName } from '@elliemae/ds-classnames';
15
- import { jsx } from 'react/jsx-runtime';
16
-
17
- const _excluded = ["endDate", "startDate", "displayFormatDay", "focusedInput", "enableOutsideDays", "onDatesChange", "onFocusChange", "onOutsideClick", "isDayBlocked", "isDayHighlighted", "isOutsideRange", "onNextMonthClick", "onPrevMonthClick"];
18
-
19
- 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; }
20
-
21
- 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; }
22
- const {
23
- classNameElement,
24
- classNameBlock
25
- } = convertPropToCssClassName('datepicker-range');
26
-
27
- const DayPickerRangeController = _ref => {
28
- let {
29
- endDate = undefined,
30
- startDate = undefined,
31
- displayFormatDay = 'D',
32
- focusedInput = undefined,
33
- enableOutsideDays = false,
34
- onDatesChange = () => null,
35
- onFocusChange = () => null,
36
- onOutsideClick = () => null,
37
- isDayBlocked = () => null,
38
- isDayHighlighted = () => null,
39
- isOutsideRange = () => null,
40
- onNextMonthClick = () => null,
41
- onPrevMonthClick = () => null
42
- } = _ref,
43
- otherProps = _objectWithoutProperties(_ref, _excluded);
44
-
45
- const datePickerRef = useRef();
46
- useEffect(() => {
47
- const handleMouseUp = () => {
48
- const focusedElement = document.activeElement;
49
- focusedElement.blur();
50
- };
51
-
52
- const handleKeyDown = event => {
53
- const [firstDay, ...restOfDays] = document.getElementsByClassName('CalendarMonthGrid_month__horizontal')[1].getElementsByClassName('CalendarDay');
54
- const [lastDay] = restOfDays.slice(-1);
55
- const focusedElement = document.activeElement;
56
- const [prev, next] = document.getElementsByClassName('DayPickerNavigation_button');
57
-
58
- switch (event.key) {
59
- case 'Home':
60
- event.stopPropagation();
61
- firstDay.focus();
62
- break;
63
-
64
- case 'End':
65
- event.stopPropagation();
66
- lastDay.focus();
67
- break;
68
-
69
- case 'Enter':
70
- case ' ':
71
- if (focusedElement === prev) {
72
- event.stopPropagation();
73
- setTimeout(() => {
74
- prev.focus();
75
- }, 240);
76
- } else if (focusedElement === next) {
77
- event.stopPropagation();
78
- setTimeout(() => {
79
- next === null || next === void 0 ? void 0 : next.focus();
80
- }, 240);
81
- }
82
-
83
- break;
84
-
85
- case 'Tab':
86
- if (firstDay === focusedElement || restOfDays.includes(focusedElement)) {
87
- event.preventDefault();
88
- prev.focus();
89
- }
90
-
91
- break;
92
- }
93
- };
94
-
95
- datePickerRef.current.addEventListener('mouseup', handleMouseUp, false);
96
- datePickerRef.current.addEventListener('keydown', handleKeyDown, false);
97
- return () => {
98
- if (datePickerRef.current) {
99
- datePickerRef.current.removeEventListener('mouseup', handleMouseUp, false);
100
- datePickerRef.current.removeEventListener('keydown', handleKeyDown, false);
101
- }
102
- };
103
- }, []);
104
- return /*#__PURE__*/jsx("div", {
105
- ref: datePickerRef,
106
- className: classNameBlock('wrapper-day-picker-single-date-controller'),
107
- "data-testid": otherProps['data-testid'] || 'date-range-picker-controller',
108
- children: /*#__PURE__*/jsx(DayPickerRangeController$1, _objectSpread(_objectSpread({}, otherProps), {}, {
109
- isDayBlocked: isDayBlocked,
110
- isDayHighlighted: isDayHighlighted,
111
- isOutsideRange: isOutsideRange,
112
- enableOutsideDays: enableOutsideDays,
113
- endDate: endDate,
114
- focused: true,
115
- focusedInput: focusedInput,
116
- hideKeyboardShortcutsPanel: true,
117
- navNext: /*#__PURE__*/_jsx(DatePickerNavigation, {
118
- className: classNameElement('navigation-next')
119
- }),
120
- navPrev: /*#__PURE__*/_jsx(DatePickerNavigation, {
121
- className: classNameElement('navigation-prev'),
122
- icon: ChevronLeft
123
- }),
124
- onDatesChange: onDatesChange,
125
- onFocusChange: onFocusChange,
126
- onOutsideClick: onOutsideClick,
127
- onNextMonthClick: onNextMonthClick,
128
- onPrevMonthClick: onPrevMonthClick,
129
- renderDayContents: date => /*#__PURE__*/_jsx(DatePickerDay, {
130
- className: classNameElement('day-contents'),
131
- date: date.format(displayFormatDay)
132
- }),
133
- renderMonthElement: renderMonthElement,
134
- startDate: startDate
135
- }))
136
- });
137
- };
138
-
139
- export { DayPickerRangeController as default };
package/esm/index.js DELETED
@@ -1,3 +0,0 @@
1
- export { DateRangePickerWithSchema, default } from './DSDateRangePicker.js';
2
- export { default as DayPickerRangeController } from './components/DayPickerRangeController.js';
3
- export { END_DATE, START_DATE } from './components/DSDateRangePickerImpl.js';