@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
package/esm/DSDateRangePicker.js
CHANGED
|
@@ -1,133 +1,148 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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, {
|
|
55
69
|
hasError,
|
|
56
70
|
readOnly,
|
|
57
71
|
disabled,
|
|
58
72
|
id
|
|
59
73
|
});
|
|
60
|
-
return
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
+
})
|
|
101
115
|
}));
|
|
102
116
|
};
|
|
117
|
+
|
|
103
118
|
const dateRangePickerProps = {
|
|
104
|
-
containerProps: PropTypes.shape({}).description(
|
|
105
|
-
className: PropTypes.string.description(
|
|
106
|
-
disabled: PropTypes.bool.description(
|
|
107
|
-
required: PropTypes.bool.description(
|
|
108
|
-
startDateRequired: PropTypes.bool.description(
|
|
109
|
-
endDateRequired: PropTypes.bool.description(
|
|
110
|
-
id: PropTypes.string.description(
|
|
111
|
-
hasError: PropTypes.bool.description(
|
|
112
|
-
validationMessage: PropTypes.string.description(
|
|
113
|
-
readOnly: PropTypes.bool.description(
|
|
114
|
-
screenReaderInputMessage: PropTypes.string.description(
|
|
115
|
-
initialVisibleMonth: PropTypes.instanceOf(Date, moment).description(
|
|
116
|
-
firstDayOfWeek: PropTypes.number.description(
|
|
117
|
-
keepOpenOnDateSelect: PropTypes.bool.description(
|
|
118
|
-
reopenPickerOnClearDates: PropTypes.bool.description(
|
|
119
|
-
hideKeyboardShortcutsPanel: PropTypes.bool.description(
|
|
120
|
-
onPrevMonthClick: PropTypes.func.description(
|
|
121
|
-
onNextMonthClick: PropTypes.func.description(
|
|
122
|
-
onClose: PropTypes.func.description(
|
|
123
|
-
transitionDuration: PropTypes.number.description(
|
|
124
|
-
verticalSpacing: PropTypes.number.description(
|
|
125
|
-
isDayBlocked: PropTypes.func.description(
|
|
126
|
-
isOutsideRange: PropTypes.func.description(
|
|
127
|
-
isDayHighlighted: PropTypes.func.description(
|
|
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'),
|
|
128
143
|
minimumNights: 0,
|
|
129
|
-
displayFormat: PropTypes.string.description(
|
|
130
|
-
displayFormatDay: PropTypes.string.description(
|
|
144
|
+
displayFormat: PropTypes.string.description('display format').defaultValue('L'),
|
|
145
|
+
displayFormatDay: PropTypes.string.description('display format day').defaultValue('D'),
|
|
131
146
|
phrases: PropTypes.shape({
|
|
132
147
|
calendarLabel: PropTypes.string,
|
|
133
148
|
closeDatePicker: PropTypes.string,
|
|
@@ -157,28 +172,20 @@ const dateRangePickerProps = {
|
|
|
157
172
|
chooseAvailableEndDate: PropTypes.func,
|
|
158
173
|
dateIsUnavailable: PropTypes.func,
|
|
159
174
|
dateIsSelected: PropTypes.func
|
|
160
|
-
}).description(
|
|
161
|
-
startDate: PropTypes.instanceOf(Date, moment).description(
|
|
162
|
-
endDate: PropTypes.instanceOf(Date, moment).description(
|
|
163
|
-
startDateId: PropTypes.string.description(
|
|
164
|
-
endDateId: PropTypes.string.description(
|
|
165
|
-
labelFrom: PropTypes.string.description(
|
|
166
|
-
labelTo: PropTypes.string.description(
|
|
167
|
-
enableOutsideDays: PropTypes.bool.description(
|
|
168
|
-
onDatesChange: PropTypes.func.description(
|
|
169
|
-
onChangeStartInput: PropTypes.func.description(
|
|
170
|
-
onChangeEndInput: PropTypes.func.description(
|
|
171
|
-
onOutsideClick: PropTypes.func.description(
|
|
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')
|
|
172
187
|
};
|
|
173
|
-
DSDateRangePicker.propTypes = dateRangePickerProps;
|
|
174
188
|
const DateRangePickerWithSchema = describe(DSDateRangePicker);
|
|
175
189
|
DateRangePickerWithSchema.propTypes = dateRangePickerProps;
|
|
176
|
-
|
|
177
|
-
export {
|
|
178
|
-
DateRangePickerWithSchema,
|
|
179
|
-
DayPickerRangeController,
|
|
180
|
-
END_DATE,
|
|
181
|
-
START_DATE,
|
|
182
|
-
DSDateRangePicker_default as default
|
|
183
|
-
};
|
|
184
|
-
//# sourceMappingURL=DSDateRangePicker.js.map
|
|
190
|
+
|
|
191
|
+
export { DateRangePickerWithSchema, DSDateRangePicker as default };
|