@elliemae/ds-date-range-selector 2.3.1 → 3.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/DSDateRangeSelector.js +89 -0
- package/dist/cjs/DSDateRangeSelector.js.map +7 -0
- package/dist/cjs/components/CustomOptionRender/CustomOptionRender.js +46 -0
- package/dist/cjs/components/CustomOptionRender/CustomOptionRender.js.map +7 -0
- package/dist/cjs/components/DateRangeSelectorImpl.js +197 -0
- package/dist/cjs/components/DateRangeSelectorImpl.js.map +7 -0
- package/dist/cjs/index.js +38 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/options/dropdownPreselectedOptions.js +71 -0
- package/dist/cjs/options/dropdownPreselectedOptions.js.map +7 -0
- package/dist/esm/DSDateRangeSelector.js +64 -0
- package/dist/esm/DSDateRangeSelector.js.map +7 -0
- package/dist/esm/components/CustomOptionRender/CustomOptionRender.js +17 -0
- package/dist/esm/components/CustomOptionRender/CustomOptionRender.js.map +7 -0
- package/dist/esm/components/DateRangeSelectorImpl.js +170 -0
- package/dist/esm/components/DateRangeSelectorImpl.js.map +7 -0
- package/dist/esm/index.js +12 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/options/dropdownPreselectedOptions.js +42 -0
- package/dist/esm/options/dropdownPreselectedOptions.js.map +7 -0
- package/package.json +38 -29
- package/cjs/DSDateRangeSelector.js +0 -69
- package/cjs/components/CustomOptionRender/CustomOptionRender.js +0 -40
- package/cjs/components/DateRangeSelectorImpl.js +0 -233
- package/cjs/index.js +0 -12
- package/cjs/options/dropdownPreselectedOptions.js +0 -36
- package/esm/DSDateRangeSelector.js +0 -57
- package/esm/components/CustomOptionRender/CustomOptionRender.js +0 -34
- package/esm/components/DateRangeSelectorImpl.js +0 -224
- package/esm/index.js +0 -2
- package/esm/options/dropdownPreselectedOptions.js +0 -30
- package/types/DSDateRangeSelector.d.ts +0 -93
- package/types/components/CustomOptionRender/CustomOptionRender.d.ts +0 -18
- package/types/components/DateRangeSelectorImpl.d.ts +0 -17
- package/types/index.d.ts +0 -2
- package/types/options/dropdownPreselectedOptions.d.ts +0 -13
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
-
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
5
|
-
require('core-js/modules/esnext.async-iterator.find.js');
|
|
6
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
-
require('core-js/modules/esnext.iterator.find.js');
|
|
8
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
9
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
10
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
|
11
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
12
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
13
|
-
var react = require('react');
|
|
14
|
-
var moment = require('moment');
|
|
15
|
-
var reactSelect = require('react-select');
|
|
16
|
-
require('react-dates/initialize');
|
|
17
|
-
var reactDates = require('react-dates');
|
|
18
|
-
var dsClassnames = require('@elliemae/ds-classnames');
|
|
19
|
-
var dsForm = require('@elliemae/ds-form');
|
|
20
|
-
var DSPopper = require('@elliemae/ds-popper');
|
|
21
|
-
var dsDatePicker = require('@elliemae/ds-date-picker');
|
|
22
|
-
var dsIcons = require('@elliemae/ds-icons');
|
|
23
|
-
var dropdownPreselectedOptions = require('../options/dropdownPreselectedOptions.js');
|
|
24
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
25
|
-
|
|
26
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
27
|
-
|
|
28
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
29
|
-
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
30
|
-
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
31
|
-
var DSPopper__default = /*#__PURE__*/_interopDefaultLegacy(DSPopper);
|
|
32
|
-
|
|
33
|
-
var _div;
|
|
34
|
-
|
|
35
|
-
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; }
|
|
36
|
-
|
|
37
|
-
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__default["default"](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; }
|
|
38
|
-
const START_DATE = 'startDate';
|
|
39
|
-
const END_DATE = 'endDate';
|
|
40
|
-
const advanceOption = {
|
|
41
|
-
label: 'Custom',
|
|
42
|
-
value: dropdownPreselectedOptions.CUSTOM_OPTION_VALUE,
|
|
43
|
-
isAdvance: true
|
|
44
|
-
};
|
|
45
|
-
const {
|
|
46
|
-
cssClassName,
|
|
47
|
-
classNameElement,
|
|
48
|
-
classNameBlock
|
|
49
|
-
} = dsClassnames.convertPropToCssClassName('date-range-selector');
|
|
50
|
-
const {
|
|
51
|
-
classNameElement: pickerNameElement
|
|
52
|
-
} = dsClassnames.convertPropToCssClassName('datepicker');
|
|
53
|
-
|
|
54
|
-
class DateTimeRecurenceSelectorImpl extends react.Component {
|
|
55
|
-
constructor(props) {
|
|
56
|
-
super(props);
|
|
57
|
-
|
|
58
|
-
this.onChange = () => {
|
|
59
|
-
const {
|
|
60
|
-
onChange
|
|
61
|
-
} = this.props;
|
|
62
|
-
const {
|
|
63
|
-
customRange,
|
|
64
|
-
selected
|
|
65
|
-
} = this.state;
|
|
66
|
-
onChange(selected, customRange);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
this.onChangeDropdown = value => {
|
|
70
|
-
const {
|
|
71
|
-
dropdownPreselectedOptions
|
|
72
|
-
} = this.props;
|
|
73
|
-
const selected = dropdownPreselectedOptions.find(op => op.value === value);
|
|
74
|
-
const {
|
|
75
|
-
onChange
|
|
76
|
-
} = this.props;
|
|
77
|
-
|
|
78
|
-
if (!selected) {
|
|
79
|
-
this.setState({
|
|
80
|
-
selected: value
|
|
81
|
-
});
|
|
82
|
-
this.handleOpenModal();
|
|
83
|
-
} else if (selected) {
|
|
84
|
-
onChange(value);
|
|
85
|
-
this.setState({
|
|
86
|
-
selected: value,
|
|
87
|
-
openModal: false
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
this.handleConfirm = () => {
|
|
93
|
-
const {
|
|
94
|
-
customOptionRender: CustomOptionRender
|
|
95
|
-
} = this.props;
|
|
96
|
-
const {
|
|
97
|
-
customRange
|
|
98
|
-
} = this.state;
|
|
99
|
-
advanceOption.label = /*#__PURE__*/_jsx__default["default"](CustomOptionRender, {
|
|
100
|
-
customRange: customRange
|
|
101
|
-
});
|
|
102
|
-
this.onChange();
|
|
103
|
-
this.handleCloseModal();
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
this.handleOpenModal = () => this.setState({
|
|
107
|
-
openModal: true
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
this.handleCloseModal = () => this.setState({
|
|
111
|
-
openModal: false
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
const _customRange = {
|
|
115
|
-
startDate: props.startDate ? moment__default["default"](props.startDate) : moment__default["default"](),
|
|
116
|
-
endDate: props.endDate ? moment__default["default"](props.endDate) : moment__default["default"]()
|
|
117
|
-
};
|
|
118
|
-
this.state = {
|
|
119
|
-
openModal: false,
|
|
120
|
-
selected: props.value,
|
|
121
|
-
focusedInput: START_DATE,
|
|
122
|
-
customRange: _customRange
|
|
123
|
-
};
|
|
124
|
-
const {
|
|
125
|
-
customOptionRender: _CustomOptionRender
|
|
126
|
-
} = props;
|
|
127
|
-
advanceOption.label = /*#__PURE__*/_jsx__default["default"](_CustomOptionRender, {
|
|
128
|
-
customRange: _customRange
|
|
129
|
-
});
|
|
130
|
-
this.onDatesChange = this.onDatesChange.bind(this);
|
|
131
|
-
this.onFocusChange = this.onFocusChange.bind(this);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
onDatesChange(_ref) {
|
|
135
|
-
let {
|
|
136
|
-
startDate,
|
|
137
|
-
endDate
|
|
138
|
-
} = _ref;
|
|
139
|
-
this.setState({
|
|
140
|
-
customRange: {
|
|
141
|
-
startDate,
|
|
142
|
-
endDate
|
|
143
|
-
}
|
|
144
|
-
}, () => {
|
|
145
|
-
this.onChange();
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
onFocusChange() {
|
|
150
|
-
this.setState(_ref2 => {
|
|
151
|
-
let {
|
|
152
|
-
focusedInput
|
|
153
|
-
} = _ref2;
|
|
154
|
-
return {
|
|
155
|
-
focusedInput: focusedInput === START_DATE ? END_DATE : START_DATE
|
|
156
|
-
};
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
render() {
|
|
161
|
-
const {
|
|
162
|
-
placeholder,
|
|
163
|
-
dropdownPreselectedOptions,
|
|
164
|
-
displayFormatDay,
|
|
165
|
-
className,
|
|
166
|
-
disableCustomOption,
|
|
167
|
-
containerProps
|
|
168
|
-
} = this.props;
|
|
169
|
-
const {
|
|
170
|
-
selected,
|
|
171
|
-
openModal,
|
|
172
|
-
focusedInput,
|
|
173
|
-
customRange: {
|
|
174
|
-
startDate,
|
|
175
|
-
endDate
|
|
176
|
-
}
|
|
177
|
-
} = this.state;
|
|
178
|
-
let options = [...dropdownPreselectedOptions];
|
|
179
|
-
|
|
180
|
-
if (!disableCustomOption) {
|
|
181
|
-
options = [...options, advanceOption]; // eslint-disable-next-line max-lines
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
185
|
-
className: "".concat(cssClassName, " ").concat(className),
|
|
186
|
-
children: [/*#__PURE__*/_jsx__default["default"]("div", {
|
|
187
|
-
className: "".concat(classNameBlock('container-selector'))
|
|
188
|
-
}, void 0, /*#__PURE__*/_jsx__default["default"](dsForm.DSComboBox, {
|
|
189
|
-
className: "".concat(classNameElement('dropdown-field-selector')),
|
|
190
|
-
components: {
|
|
191
|
-
Option: props => /*#__PURE__*/jsxRuntime.jsx(reactSelect.components.Option, _objectSpread({}, props)),
|
|
192
|
-
IndicatorSeparator: () => null
|
|
193
|
-
},
|
|
194
|
-
onChange: this.onChangeDropdown,
|
|
195
|
-
onKeyDown: this.onKeyDown,
|
|
196
|
-
options: options,
|
|
197
|
-
placeholder: placeholder,
|
|
198
|
-
value: selected,
|
|
199
|
-
keepTypedValue: false // TEMPORARY FIX
|
|
200
|
-
|
|
201
|
-
})), /*#__PURE__*/_jsx__default["default"](DSPopper__default["default"], {
|
|
202
|
-
contentComponent: /*#__PURE__*/_jsx__default["default"]("div", {
|
|
203
|
-
className: classNameBlock('wrap-day-picker')
|
|
204
|
-
}, void 0, /*#__PURE__*/_jsx__default["default"](reactDates.DayPickerRangeController, {
|
|
205
|
-
endDate: endDate,
|
|
206
|
-
focusedInput: focusedInput,
|
|
207
|
-
hideKeyboardShortcutsPanel: true,
|
|
208
|
-
navNext: /*#__PURE__*/_jsx__default["default"](dsDatePicker.DatePickerNavigation, {
|
|
209
|
-
className: pickerNameElement('navigation-next')
|
|
210
|
-
}),
|
|
211
|
-
navPrev: /*#__PURE__*/_jsx__default["default"](dsDatePicker.DatePickerNavigation, {
|
|
212
|
-
className: pickerNameElement('navigation-prev'),
|
|
213
|
-
icon: dsIcons.ChevronLeft
|
|
214
|
-
}),
|
|
215
|
-
onDatesChange: this.onDatesChange,
|
|
216
|
-
onFocusChange: this.onFocusChange,
|
|
217
|
-
onOutsideClick: this.handleConfirm,
|
|
218
|
-
renderDayContents: date => /*#__PURE__*/_jsx__default["default"](dsDatePicker.DatePickerDay, {
|
|
219
|
-
className: pickerNameElement('day-contents'),
|
|
220
|
-
date: date.format(displayFormatDay)
|
|
221
|
-
}),
|
|
222
|
-
startDate: startDate
|
|
223
|
-
})),
|
|
224
|
-
isOpen: openModal,
|
|
225
|
-
showArrow: false,
|
|
226
|
-
triggerComponent: _div || (_div = /*#__PURE__*/_jsx__default["default"]("div", {}))
|
|
227
|
-
})]
|
|
228
|
-
}));
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
module.exports = DateTimeRecurenceSelectorImpl;
|
package/cjs/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var DSDateRangeSelector = require('./DSDateRangeSelector.js');
|
|
6
|
-
var dropdownPreselectedOptions = require('./options/dropdownPreselectedOptions.js');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.DateRangeRecurrenceSelectorWithSchema = DSDateRangeSelector.DateRangeRecurrenceSelectorWithSchema;
|
|
11
|
-
exports["default"] = DSDateRangeSelector["default"];
|
|
12
|
-
exports.CUSTOM_OPTION_VALUE = dropdownPreselectedOptions.CUSTOM_OPTION_VALUE;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const DropdownOptionsTypes = {
|
|
6
|
-
TODAY: 'today',
|
|
7
|
-
YESTERDAY: 'yesterday',
|
|
8
|
-
LAST_7_DAYS: '7days',
|
|
9
|
-
LAST_30_DAYS: '30days',
|
|
10
|
-
THIS_MONTH: 'thismonth',
|
|
11
|
-
LAST_MONTH: 'lastmonth'
|
|
12
|
-
};
|
|
13
|
-
const dropdownPreselectedOptions = [{
|
|
14
|
-
label: 'Today',
|
|
15
|
-
value: DropdownOptionsTypes.TODAY
|
|
16
|
-
}, {
|
|
17
|
-
label: 'Yesterday',
|
|
18
|
-
value: DropdownOptionsTypes.YESTERDAY
|
|
19
|
-
}, {
|
|
20
|
-
label: 'Last 7 Days',
|
|
21
|
-
value: DropdownOptionsTypes.LAST_7_DAYS
|
|
22
|
-
}, {
|
|
23
|
-
label: 'Last 30 days',
|
|
24
|
-
value: DropdownOptionsTypes.LAST_30_DAYS
|
|
25
|
-
}, {
|
|
26
|
-
label: 'This month',
|
|
27
|
-
value: DropdownOptionsTypes.THIS_MONTH
|
|
28
|
-
}, {
|
|
29
|
-
label: 'Last month',
|
|
30
|
-
value: DropdownOptionsTypes.LAST_MONTH
|
|
31
|
-
}];
|
|
32
|
-
const CUSTOM_OPTION_VALUE = 'custom-option-value';
|
|
33
|
-
|
|
34
|
-
exports.CUSTOM_OPTION_VALUE = CUSTOM_OPTION_VALUE;
|
|
35
|
-
exports.DropdownOptionsTypes = DropdownOptionsTypes;
|
|
36
|
-
exports.dropdownPreselectedOptions = dropdownPreselectedOptions;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
-
import 'react';
|
|
3
|
-
import { PropTypes, describe } from 'react-desc';
|
|
4
|
-
import moment from 'moment';
|
|
5
|
-
import DateTimeRecurenceSelectorImpl from './components/DateRangeSelectorImpl.js';
|
|
6
|
-
import { dropdownPreselectedOptions } from './options/dropdownPreselectedOptions.js';
|
|
7
|
-
export { CUSTOM_OPTION_VALUE, DropdownOptionsTypes, dropdownPreselectedOptions } from './options/dropdownPreselectedOptions.js';
|
|
8
|
-
import CustomOptionRender from './components/CustomOptionRender/CustomOptionRender.js';
|
|
9
|
-
|
|
10
|
-
const DSDateRangeSelector = _ref => {
|
|
11
|
-
let {
|
|
12
|
-
containerProps = {},
|
|
13
|
-
className = '',
|
|
14
|
-
preselectedOptions = dropdownPreselectedOptions,
|
|
15
|
-
onChange = () => null,
|
|
16
|
-
placeholder = 'Select Range',
|
|
17
|
-
value = null,
|
|
18
|
-
customOptionRender = CustomOptionRender,
|
|
19
|
-
startDate = null,
|
|
20
|
-
endDate = null,
|
|
21
|
-
displayFormatDay = 'D',
|
|
22
|
-
disableCustomOption = false
|
|
23
|
-
} = _ref;
|
|
24
|
-
return /*#__PURE__*/_jsx(DateTimeRecurenceSelectorImpl, {
|
|
25
|
-
className: className,
|
|
26
|
-
containerProps: containerProps,
|
|
27
|
-
customOptionRender: customOptionRender,
|
|
28
|
-
disableCustomOption: disableCustomOption,
|
|
29
|
-
displayFormatDay: displayFormatDay,
|
|
30
|
-
dropdownPreselectedOptions: preselectedOptions,
|
|
31
|
-
endDate: endDate,
|
|
32
|
-
onChange: onChange,
|
|
33
|
-
placeholder: placeholder,
|
|
34
|
-
startDate: startDate,
|
|
35
|
-
value: value
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
const dateRangeRecurrenceSelectorProps = {
|
|
39
|
-
containerProps: PropTypes.object.description('Set of properties attached to the main container'),
|
|
40
|
-
className: PropTypes.string.description('html class attribute'),
|
|
41
|
-
preselectedOptions: PropTypes.arrayOf(PropTypes.shape({
|
|
42
|
-
label: PropTypes.string,
|
|
43
|
-
value: PropTypes.string
|
|
44
|
-
})).description('options to display in dropdown menu'),
|
|
45
|
-
onChange: PropTypes.func.description('function executed when selection changes'),
|
|
46
|
-
placeholder: PropTypes.string.description('inputs placeholder').defaultValue('Select Range'),
|
|
47
|
-
value: PropTypes.oneOf([PropTypes.string, PropTypes.number]).description('selected value'),
|
|
48
|
-
customOptionRender: PropTypes.element.description('custom renderer for options'),
|
|
49
|
-
startDate: PropTypes.instanceOf(Date, moment).description('moment object of start date'),
|
|
50
|
-
endDate: PropTypes.instanceOf(Date, moment).description('moment object of end date'),
|
|
51
|
-
displayFormatDay: PropTypes.string.description('format to display date').defaultValue('D'),
|
|
52
|
-
disableCustomOption: PropTypes.bool.description('disables custom options').defaultValue(false)
|
|
53
|
-
};
|
|
54
|
-
const DateRangeRecurrenceSelectorWithSchema = describe(DSDateRangeSelector);
|
|
55
|
-
DateRangeRecurrenceSelectorWithSchema.propTypes = dateRangeRecurrenceSelectorProps;
|
|
56
|
-
|
|
57
|
-
export { DateRangeRecurrenceSelectorWithSchema, DSDateRangeSelector as default };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
-
import 'react';
|
|
3
|
-
import { convertPropToCssClassName } from '@elliemae/ds-classnames';
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
cssClassName
|
|
7
|
-
} = convertPropToCssClassName('date-range-selector-customoption');
|
|
8
|
-
/**
|
|
9
|
-
* @param root0
|
|
10
|
-
* @param root0.customRange
|
|
11
|
-
* @param root0.customRange.startDate
|
|
12
|
-
* @param root0.customRange.endDate
|
|
13
|
-
* @customRange {
|
|
14
|
-
endDate
|
|
15
|
-
startDate
|
|
16
|
-
}
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
const CustomOptionRender = _ref => {
|
|
20
|
-
let {
|
|
21
|
-
customRange: {
|
|
22
|
-
startDate,
|
|
23
|
-
endDate
|
|
24
|
-
}
|
|
25
|
-
} = _ref;
|
|
26
|
-
const start = startDate ? startDate.format('MM/DD/YYYY') : null;
|
|
27
|
-
const end = endDate ? endDate.format('MM/DD/YYYY') : null;
|
|
28
|
-
const display = "From ".concat(start, " to ").concat(end) || 'Custom';
|
|
29
|
-
return /*#__PURE__*/_jsx("em", {
|
|
30
|
-
className: cssClassName
|
|
31
|
-
}, void 0, display);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export { CustomOptionRender as default };
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
-
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
3
|
-
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
4
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.find.js';
|
|
6
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
7
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
8
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
9
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
10
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
11
|
-
import { Component } from 'react';
|
|
12
|
-
import moment from 'moment';
|
|
13
|
-
import { components } from 'react-select';
|
|
14
|
-
import 'react-dates/initialize';
|
|
15
|
-
import { DayPickerRangeController } from 'react-dates';
|
|
16
|
-
import { convertPropToCssClassName } from '@elliemae/ds-classnames';
|
|
17
|
-
import { DSComboBox } from '@elliemae/ds-form';
|
|
18
|
-
import DSPopper from '@elliemae/ds-popper';
|
|
19
|
-
import { DatePickerNavigation, DatePickerDay } from '@elliemae/ds-date-picker';
|
|
20
|
-
import { ChevronLeft } from '@elliemae/ds-icons';
|
|
21
|
-
import { CUSTOM_OPTION_VALUE } from '../options/dropdownPreselectedOptions.js';
|
|
22
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
23
|
-
|
|
24
|
-
var _div;
|
|
25
|
-
|
|
26
|
-
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; }
|
|
27
|
-
|
|
28
|
-
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; }
|
|
29
|
-
const START_DATE = 'startDate';
|
|
30
|
-
const END_DATE = 'endDate';
|
|
31
|
-
const advanceOption = {
|
|
32
|
-
label: 'Custom',
|
|
33
|
-
value: CUSTOM_OPTION_VALUE,
|
|
34
|
-
isAdvance: true
|
|
35
|
-
};
|
|
36
|
-
const {
|
|
37
|
-
cssClassName,
|
|
38
|
-
classNameElement,
|
|
39
|
-
classNameBlock
|
|
40
|
-
} = convertPropToCssClassName('date-range-selector');
|
|
41
|
-
const {
|
|
42
|
-
classNameElement: pickerNameElement
|
|
43
|
-
} = convertPropToCssClassName('datepicker');
|
|
44
|
-
|
|
45
|
-
class DateTimeRecurenceSelectorImpl extends Component {
|
|
46
|
-
constructor(props) {
|
|
47
|
-
super(props);
|
|
48
|
-
|
|
49
|
-
this.onChange = () => {
|
|
50
|
-
const {
|
|
51
|
-
onChange
|
|
52
|
-
} = this.props;
|
|
53
|
-
const {
|
|
54
|
-
customRange,
|
|
55
|
-
selected
|
|
56
|
-
} = this.state;
|
|
57
|
-
onChange(selected, customRange);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
this.onChangeDropdown = value => {
|
|
61
|
-
const {
|
|
62
|
-
dropdownPreselectedOptions
|
|
63
|
-
} = this.props;
|
|
64
|
-
const selected = dropdownPreselectedOptions.find(op => op.value === value);
|
|
65
|
-
const {
|
|
66
|
-
onChange
|
|
67
|
-
} = this.props;
|
|
68
|
-
|
|
69
|
-
if (!selected) {
|
|
70
|
-
this.setState({
|
|
71
|
-
selected: value
|
|
72
|
-
});
|
|
73
|
-
this.handleOpenModal();
|
|
74
|
-
} else if (selected) {
|
|
75
|
-
onChange(value);
|
|
76
|
-
this.setState({
|
|
77
|
-
selected: value,
|
|
78
|
-
openModal: false
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
this.handleConfirm = () => {
|
|
84
|
-
const {
|
|
85
|
-
customOptionRender: CustomOptionRender
|
|
86
|
-
} = this.props;
|
|
87
|
-
const {
|
|
88
|
-
customRange
|
|
89
|
-
} = this.state;
|
|
90
|
-
advanceOption.label = /*#__PURE__*/_jsx(CustomOptionRender, {
|
|
91
|
-
customRange: customRange
|
|
92
|
-
});
|
|
93
|
-
this.onChange();
|
|
94
|
-
this.handleCloseModal();
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
this.handleOpenModal = () => this.setState({
|
|
98
|
-
openModal: true
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
this.handleCloseModal = () => this.setState({
|
|
102
|
-
openModal: false
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
const _customRange = {
|
|
106
|
-
startDate: props.startDate ? moment(props.startDate) : moment(),
|
|
107
|
-
endDate: props.endDate ? moment(props.endDate) : moment()
|
|
108
|
-
};
|
|
109
|
-
this.state = {
|
|
110
|
-
openModal: false,
|
|
111
|
-
selected: props.value,
|
|
112
|
-
focusedInput: START_DATE,
|
|
113
|
-
customRange: _customRange
|
|
114
|
-
};
|
|
115
|
-
const {
|
|
116
|
-
customOptionRender: _CustomOptionRender
|
|
117
|
-
} = props;
|
|
118
|
-
advanceOption.label = /*#__PURE__*/_jsx(_CustomOptionRender, {
|
|
119
|
-
customRange: _customRange
|
|
120
|
-
});
|
|
121
|
-
this.onDatesChange = this.onDatesChange.bind(this);
|
|
122
|
-
this.onFocusChange = this.onFocusChange.bind(this);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
onDatesChange(_ref) {
|
|
126
|
-
let {
|
|
127
|
-
startDate,
|
|
128
|
-
endDate
|
|
129
|
-
} = _ref;
|
|
130
|
-
this.setState({
|
|
131
|
-
customRange: {
|
|
132
|
-
startDate,
|
|
133
|
-
endDate
|
|
134
|
-
}
|
|
135
|
-
}, () => {
|
|
136
|
-
this.onChange();
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
onFocusChange() {
|
|
141
|
-
this.setState(_ref2 => {
|
|
142
|
-
let {
|
|
143
|
-
focusedInput
|
|
144
|
-
} = _ref2;
|
|
145
|
-
return {
|
|
146
|
-
focusedInput: focusedInput === START_DATE ? END_DATE : START_DATE
|
|
147
|
-
};
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
render() {
|
|
152
|
-
const {
|
|
153
|
-
placeholder,
|
|
154
|
-
dropdownPreselectedOptions,
|
|
155
|
-
displayFormatDay,
|
|
156
|
-
className,
|
|
157
|
-
disableCustomOption,
|
|
158
|
-
containerProps
|
|
159
|
-
} = this.props;
|
|
160
|
-
const {
|
|
161
|
-
selected,
|
|
162
|
-
openModal,
|
|
163
|
-
focusedInput,
|
|
164
|
-
customRange: {
|
|
165
|
-
startDate,
|
|
166
|
-
endDate
|
|
167
|
-
}
|
|
168
|
-
} = this.state;
|
|
169
|
-
let options = [...dropdownPreselectedOptions];
|
|
170
|
-
|
|
171
|
-
if (!disableCustomOption) {
|
|
172
|
-
options = [...options, advanceOption]; // eslint-disable-next-line max-lines
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
176
|
-
className: "".concat(cssClassName, " ").concat(className),
|
|
177
|
-
children: [/*#__PURE__*/_jsx("div", {
|
|
178
|
-
className: "".concat(classNameBlock('container-selector'))
|
|
179
|
-
}, void 0, /*#__PURE__*/_jsx(DSComboBox, {
|
|
180
|
-
className: "".concat(classNameElement('dropdown-field-selector')),
|
|
181
|
-
components: {
|
|
182
|
-
Option: props => /*#__PURE__*/jsx(components.Option, _objectSpread({}, props)),
|
|
183
|
-
IndicatorSeparator: () => null
|
|
184
|
-
},
|
|
185
|
-
onChange: this.onChangeDropdown,
|
|
186
|
-
onKeyDown: this.onKeyDown,
|
|
187
|
-
options: options,
|
|
188
|
-
placeholder: placeholder,
|
|
189
|
-
value: selected,
|
|
190
|
-
keepTypedValue: false // TEMPORARY FIX
|
|
191
|
-
|
|
192
|
-
})), /*#__PURE__*/_jsx(DSPopper, {
|
|
193
|
-
contentComponent: /*#__PURE__*/_jsx("div", {
|
|
194
|
-
className: classNameBlock('wrap-day-picker')
|
|
195
|
-
}, void 0, /*#__PURE__*/_jsx(DayPickerRangeController, {
|
|
196
|
-
endDate: endDate,
|
|
197
|
-
focusedInput: focusedInput,
|
|
198
|
-
hideKeyboardShortcutsPanel: true,
|
|
199
|
-
navNext: /*#__PURE__*/_jsx(DatePickerNavigation, {
|
|
200
|
-
className: pickerNameElement('navigation-next')
|
|
201
|
-
}),
|
|
202
|
-
navPrev: /*#__PURE__*/_jsx(DatePickerNavigation, {
|
|
203
|
-
className: pickerNameElement('navigation-prev'),
|
|
204
|
-
icon: ChevronLeft
|
|
205
|
-
}),
|
|
206
|
-
onDatesChange: this.onDatesChange,
|
|
207
|
-
onFocusChange: this.onFocusChange,
|
|
208
|
-
onOutsideClick: this.handleConfirm,
|
|
209
|
-
renderDayContents: date => /*#__PURE__*/_jsx(DatePickerDay, {
|
|
210
|
-
className: pickerNameElement('day-contents'),
|
|
211
|
-
date: date.format(displayFormatDay)
|
|
212
|
-
}),
|
|
213
|
-
startDate: startDate
|
|
214
|
-
})),
|
|
215
|
-
isOpen: openModal,
|
|
216
|
-
showArrow: false,
|
|
217
|
-
triggerComponent: _div || (_div = /*#__PURE__*/_jsx("div", {}))
|
|
218
|
-
})]
|
|
219
|
-
}));
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
export { DateTimeRecurenceSelectorImpl as default };
|
package/esm/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const DropdownOptionsTypes = {
|
|
2
|
-
TODAY: 'today',
|
|
3
|
-
YESTERDAY: 'yesterday',
|
|
4
|
-
LAST_7_DAYS: '7days',
|
|
5
|
-
LAST_30_DAYS: '30days',
|
|
6
|
-
THIS_MONTH: 'thismonth',
|
|
7
|
-
LAST_MONTH: 'lastmonth'
|
|
8
|
-
};
|
|
9
|
-
const dropdownPreselectedOptions = [{
|
|
10
|
-
label: 'Today',
|
|
11
|
-
value: DropdownOptionsTypes.TODAY
|
|
12
|
-
}, {
|
|
13
|
-
label: 'Yesterday',
|
|
14
|
-
value: DropdownOptionsTypes.YESTERDAY
|
|
15
|
-
}, {
|
|
16
|
-
label: 'Last 7 Days',
|
|
17
|
-
value: DropdownOptionsTypes.LAST_7_DAYS
|
|
18
|
-
}, {
|
|
19
|
-
label: 'Last 30 days',
|
|
20
|
-
value: DropdownOptionsTypes.LAST_30_DAYS
|
|
21
|
-
}, {
|
|
22
|
-
label: 'This month',
|
|
23
|
-
value: DropdownOptionsTypes.THIS_MONTH
|
|
24
|
-
}, {
|
|
25
|
-
label: 'Last month',
|
|
26
|
-
value: DropdownOptionsTypes.LAST_MONTH
|
|
27
|
-
}];
|
|
28
|
-
const CUSTOM_OPTION_VALUE = 'custom-option-value';
|
|
29
|
-
|
|
30
|
-
export { CUSTOM_OPTION_VALUE, DropdownOptionsTypes, dropdownPreselectedOptions };
|