@elliemae/ds-date-picker 1.61.0 → 2.0.0-alpha.12
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/DSDatePicker.js +139 -205
- package/cjs/components/DSDatePickerImpl.js +238 -273
- package/cjs/components/DatePickerController/DatePickerController.js +199 -297
- package/cjs/components/DatePickerDay/DatePickerDay.js +11 -18
- package/cjs/components/DatePickerDropdown.js +32 -45
- package/cjs/components/DatePickerHeader/DatePickerHeader.js +19 -36
- package/cjs/components/DatePickerNavigation/DatePickerNavigation.js +16 -28
- package/cjs/components/DatePickerPicker/DatePickerPicker.js +40 -49
- package/cjs/components/DatePickerRange/DatePickerRange.js +76 -85
- package/cjs/components/DatePickerRangeHeader/DatePickerRangeHeader.js +48 -82
- package/cjs/components/DatePickerRenderMonth/DatePickerRenderMonth.js +18 -20
- package/cjs/components/DatePickerSingleDate/DatePickerSingleDate.js +52 -75
- package/cjs/components/SingleRangeDateSwitcher/SingleRangeDateSwitcher.js +31 -30
- package/cjs/components/index.js +20 -36
- package/cjs/defaultPhrases.js +224 -211
- package/cjs/index.js +24 -50
- package/esm/DSDatePicker.js +108 -174
- package/esm/components/DSDatePickerImpl.js +231 -262
- package/esm/components/DatePickerController/DatePickerController.js +154 -246
- package/esm/components/DatePickerDay/DatePickerDay.js +10 -16
- package/esm/components/DatePickerDropdown.js +30 -42
- package/esm/components/DatePickerHeader/DatePickerHeader.js +19 -34
- package/esm/components/DatePickerNavigation/DatePickerNavigation.js +14 -26
- package/esm/components/DatePickerPicker/DatePickerPicker.js +23 -33
- package/esm/components/DatePickerRange/DatePickerRange.js +71 -79
- package/esm/components/DatePickerRangeHeader/DatePickerRangeHeader.js +48 -80
- package/esm/components/DatePickerRenderMonth/DatePickerRenderMonth.js +17 -19
- package/esm/components/DatePickerSingleDate/DatePickerSingleDate.js +48 -70
- package/esm/components/SingleRangeDateSwitcher/SingleRangeDateSwitcher.js +26 -25
- package/esm/components/index.js +0 -16
- package/esm/defaultPhrases.js +223 -210
- package/esm/index.js +4 -30
- package/package.json +99 -15
- package/types/components/DSDatePickerImpl.d.ts +20 -0
- package/types/components/DatePickerController/DatePickerController.d.ts +80 -0
- package/types/components/DatePickerDay/DatePickerDay.d.ts +13 -0
- package/types/components/DatePickerDropdown.d.ts +41 -0
- package/types/components/DatePickerHeader/DatePickerHeader.d.ts +15 -0
- package/types/components/DatePickerNavigation/DatePickerNavigation.d.ts +19 -0
- package/types/components/DatePickerPicker/DatePickerPicker.d.ts +48 -0
- package/types/components/DatePickerRange/DatePickerRange.d.ts +9 -0
- package/types/components/DatePickerRangeHeader/DatePickerRangeHeader.d.ts +23 -0
- package/types/components/DatePickerRangeHeader/tests/DatePickerRangeHeader.test.d.ts +1 -0
- package/types/components/DatePickerRenderMonth/DatePickerRenderMonth.d.ts +5 -0
- package/types/components/DatePickerSingleDate/DatePickerSingleDate.d.ts +11 -0
- package/types/components/SingleRangeDateSwitcher/SingleRangeDateSwitcher.d.ts +16 -0
- package/types/components/index.d.ts +10 -0
- package/types/components/tests/DatePickerHeader.test.d.ts +1 -0
- package/types/components/tests/DatePickerRange.test.d.ts +1 -0
- package/types/components/tests/DatePickerRangeHeader.test.d.ts +1 -0
- package/types/components/tests/DatePickerSelectedDate.test.d.ts +1 -0
- package/types/components/tests/DatePickerSingleDate.test.d.ts +1 -0
- package/types/components/tests/SingleRangeDateSwitcher.test.d.ts +1 -0
- package/types/defaultPhrases.d.ts +225 -0
- package/types/index.d.ts +3 -0
- package/DSDatePicker/package.json +0 -10
- package/cjs/DSDatePicker.js.map +0 -1
- package/cjs/components/DSDatePickerImpl.js.map +0 -1
- package/cjs/components/DatePickerController/DatePickerController.js.map +0 -1
- package/cjs/components/DatePickerDay/DatePickerDay.js.map +0 -1
- package/cjs/components/DatePickerDropdown.js.map +0 -1
- package/cjs/components/DatePickerHeader/DatePickerHeader.js.map +0 -1
- package/cjs/components/DatePickerNavigation/DatePickerNavigation.js.map +0 -1
- package/cjs/components/DatePickerPicker/DatePickerPicker.js.map +0 -1
- package/cjs/components/DatePickerRange/DatePickerRange.js.map +0 -1
- package/cjs/components/DatePickerRangeHeader/DatePickerRangeHeader.js.map +0 -1
- package/cjs/components/DatePickerRenderMonth/DatePickerRenderMonth.js.map +0 -1
- package/cjs/components/DatePickerSingleDate/DatePickerSingleDate.js.map +0 -1
- package/cjs/components/SingleRangeDateSwitcher/SingleRangeDateSwitcher.js.map +0 -1
- package/cjs/components/index.js.map +0 -1
- package/cjs/defaultPhrases.js.map +0 -1
- package/cjs/index.js.map +0 -1
- package/cjs/prop-types-fcbbf657.js +0 -18
- package/cjs/prop-types-fcbbf657.js.map +0 -1
- package/components/DSDatePickerImpl/package.json +0 -10
- package/components/DatePickerController/DatePickerController/package.json +0 -10
- package/components/DatePickerDay/DatePickerDay/package.json +0 -10
- package/components/DatePickerDropdown/package.json +0 -10
- package/components/DatePickerHeader/DatePickerHeader/package.json +0 -10
- package/components/DatePickerNavigation/DatePickerNavigation/package.json +0 -10
- package/components/DatePickerPicker/DatePickerPicker/package.json +0 -10
- package/components/DatePickerRange/DatePickerRange/package.json +0 -10
- package/components/DatePickerRangeHeader/DatePickerRangeHeader/package.json +0 -10
- package/components/DatePickerRenderMonth/DatePickerRenderMonth/package.json +0 -10
- package/components/DatePickerSingleDate/DatePickerSingleDate/package.json +0 -10
- package/components/SingleRangeDateSwitcher/SingleRangeDateSwitcher/package.json +0 -10
- package/components/package.json +0 -10
- package/defaultPhrases/package.json +0 -10
- package/esm/DSDatePicker.js.map +0 -1
- package/esm/components/DSDatePickerImpl.js.map +0 -1
- package/esm/components/DatePickerController/DatePickerController.js.map +0 -1
- package/esm/components/DatePickerDay/DatePickerDay.js.map +0 -1
- package/esm/components/DatePickerDropdown.js.map +0 -1
- package/esm/components/DatePickerHeader/DatePickerHeader.js.map +0 -1
- package/esm/components/DatePickerNavigation/DatePickerNavigation.js.map +0 -1
- package/esm/components/DatePickerPicker/DatePickerPicker.js.map +0 -1
- package/esm/components/DatePickerRange/DatePickerRange.js.map +0 -1
- package/esm/components/DatePickerRangeHeader/DatePickerRangeHeader.js.map +0 -1
- package/esm/components/DatePickerRenderMonth/DatePickerRenderMonth.js.map +0 -1
- package/esm/components/DatePickerSingleDate/DatePickerSingleDate.js.map +0 -1
- package/esm/components/SingleRangeDateSwitcher/SingleRangeDateSwitcher.js.map +0 -1
- package/esm/components/index.js.map +0 -1
- package/esm/defaultPhrases.js.map +0 -1
- package/esm/index.js.map +0 -1
- package/esm/prop-types-578e866b.js +0 -15
- package/esm/prop-types-578e866b.js.map +0 -1
|
@@ -1,63 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import _inherits from '@babel/runtime/helpers/esm/inherits';
|
|
4
|
-
import _possibleConstructorReturn from '@babel/runtime/helpers/esm/possibleConstructorReturn';
|
|
5
|
-
import _getPrototypeOf from '@babel/runtime/helpers/esm/getPrototypeOf';
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
6
3
|
import React from 'react';
|
|
7
4
|
import moment from 'moment';
|
|
8
5
|
import { DSInputGroup, DSDateInputV2 } from '@elliemae/ds-form';
|
|
9
6
|
import DSDatePickerController from './DatePickerController/DatePickerController.js';
|
|
10
7
|
import DatePickerDropdown from './DatePickerDropdown.js';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import '@elliemae/ds-icons';
|
|
20
|
-
import '../defaultPhrases.js';
|
|
21
|
-
import './DatePickerRenderMonth/DatePickerRenderMonth.js';
|
|
22
|
-
import '@elliemae/ds-grid';
|
|
23
|
-
import './DatePickerNavigation/DatePickerNavigation.js';
|
|
24
|
-
import '@elliemae/ds-icon';
|
|
25
|
-
import '../prop-types-578e866b.js';
|
|
26
|
-
import './DatePickerDay/DatePickerDay.js';
|
|
27
|
-
import '@elliemae/ds-popper';
|
|
28
|
-
import './DatePickerPicker/DatePickerPicker.js';
|
|
29
|
-
import '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
30
|
-
import '@elliemae/ds-button';
|
|
31
|
-
|
|
32
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
33
|
-
|
|
34
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
35
|
-
var FORMAT = 'MMDDYYYY';
|
|
36
|
-
|
|
37
|
-
var DSdatePickerImpl = /*#__PURE__*/function (_React$Component) {
|
|
38
|
-
_inherits(DSdatePickerImpl, _React$Component);
|
|
39
|
-
|
|
40
|
-
var _super = _createSuper(DSdatePickerImpl);
|
|
41
|
-
|
|
42
|
-
function DSdatePickerImpl(props) {
|
|
43
|
-
var _this;
|
|
44
|
-
|
|
45
|
-
_classCallCheck(this, DSdatePickerImpl);
|
|
46
|
-
|
|
47
|
-
_this = _super.call(this, props);
|
|
48
|
-
|
|
49
|
-
_this.onClickPicker = function () {
|
|
50
|
-
_this.setState({
|
|
8
|
+
|
|
9
|
+
const FORMAT = 'MMDDYYYY';
|
|
10
|
+
class DSdatePickerImpl extends React.Component {
|
|
11
|
+
constructor(props) {
|
|
12
|
+
super(props);
|
|
13
|
+
|
|
14
|
+
this.onClickPicker = () => {
|
|
15
|
+
this.setState({
|
|
51
16
|
inputFocused: true
|
|
52
17
|
});
|
|
53
18
|
};
|
|
54
19
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
20
|
+
this.getSafeValue = () => {
|
|
21
|
+
const {
|
|
22
|
+
value,
|
|
23
|
+
date,
|
|
24
|
+
defaultValue
|
|
25
|
+
} = this.props;
|
|
26
|
+
const {
|
|
27
|
+
selectedDate
|
|
28
|
+
} = this.state;
|
|
61
29
|
|
|
62
30
|
if (value) {
|
|
63
31
|
return moment(value, FORMAT, true);
|
|
@@ -78,35 +46,39 @@ var DSdatePickerImpl = /*#__PURE__*/function (_React$Component) {
|
|
|
78
46
|
return null;
|
|
79
47
|
};
|
|
80
48
|
|
|
81
|
-
|
|
82
|
-
|
|
49
|
+
this.getSafeInputValue = () => {
|
|
50
|
+
const safeValue = this.getSafeValue();
|
|
83
51
|
|
|
84
52
|
if (safeValue && safeValue.isValid()) {
|
|
85
53
|
return safeValue.format(FORMAT);
|
|
86
54
|
}
|
|
87
55
|
|
|
88
|
-
|
|
56
|
+
const {
|
|
57
|
+
dataInput
|
|
58
|
+
} = this.state;
|
|
89
59
|
return dataInput;
|
|
90
60
|
};
|
|
91
61
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
62
|
+
this.isControlled = () => {
|
|
63
|
+
const {
|
|
64
|
+
value,
|
|
65
|
+
date
|
|
66
|
+
} = this.props;
|
|
96
67
|
return Boolean(value) || Boolean(date);
|
|
97
68
|
};
|
|
98
69
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
70
|
+
this.handleDateChange = (date, event) => {
|
|
71
|
+
const {
|
|
72
|
+
readOnly,
|
|
73
|
+
onDateChange,
|
|
74
|
+
keepOpenOnDateSelect,
|
|
75
|
+
onChange,
|
|
76
|
+
onBlur
|
|
77
|
+
} = this.props;
|
|
106
78
|
|
|
107
79
|
if (!readOnly) {
|
|
108
|
-
if (!
|
|
109
|
-
|
|
80
|
+
if (!this.isControlled()) {
|
|
81
|
+
this.setState({
|
|
110
82
|
dataInput: date.format(FORMAT),
|
|
111
83
|
selectedDate: date
|
|
112
84
|
});
|
|
@@ -116,88 +88,86 @@ var DSdatePickerImpl = /*#__PURE__*/function (_React$Component) {
|
|
|
116
88
|
onDateChange(date);
|
|
117
89
|
|
|
118
90
|
if (!keepOpenOnDateSelect || event.key === 'Enter') {
|
|
119
|
-
|
|
91
|
+
this.setState({
|
|
120
92
|
inputFocused: false
|
|
121
93
|
});
|
|
122
|
-
|
|
123
94
|
onBlur(date.format(FORMAT), date);
|
|
124
95
|
}
|
|
125
96
|
}
|
|
126
97
|
};
|
|
127
98
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
99
|
+
this.handleInputChange = (dataInput, newDate) => {
|
|
100
|
+
const {
|
|
101
|
+
onChange
|
|
102
|
+
} = this.props;
|
|
103
|
+
const newState = {
|
|
104
|
+
dataInput,
|
|
132
105
|
selectedDate: newDate
|
|
133
106
|
};
|
|
134
|
-
|
|
135
|
-
_this.setState(function () {
|
|
136
|
-
return newState;
|
|
137
|
-
});
|
|
138
|
-
|
|
107
|
+
this.setState(() => newState);
|
|
139
108
|
onChange(dataInput, newDate);
|
|
140
109
|
};
|
|
141
110
|
|
|
142
|
-
|
|
111
|
+
this.handleChange = newDate => {
|
|
143
112
|
if (!newDate) return;
|
|
144
|
-
|
|
145
|
-
|
|
113
|
+
const {
|
|
114
|
+
onDateChange
|
|
115
|
+
} = this.props;
|
|
116
|
+
const momentValue = moment(newDate, FORMAT, true);
|
|
146
117
|
if (!momentValue.isValid()) return;
|
|
147
|
-
|
|
148
|
-
_this.setState({
|
|
118
|
+
this.setState({
|
|
149
119
|
selectedDate: momentValue
|
|
150
120
|
});
|
|
151
|
-
|
|
152
121
|
onDateChange(momentValue);
|
|
153
122
|
};
|
|
154
123
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
124
|
+
this.handleFocus = _ref => {
|
|
125
|
+
let {
|
|
126
|
+
focused
|
|
127
|
+
} = _ref;
|
|
128
|
+
this.setState({
|
|
159
129
|
inputFocused: focused
|
|
160
130
|
});
|
|
161
131
|
};
|
|
162
132
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
133
|
+
this.handleCalendarClose = () => {
|
|
134
|
+
const {
|
|
135
|
+
onClose
|
|
136
|
+
} = this.props;
|
|
137
|
+
this.setState({
|
|
167
138
|
inputFocused: false
|
|
168
139
|
});
|
|
169
|
-
|
|
170
|
-
_this.handleOnBlur();
|
|
171
|
-
|
|
140
|
+
this.handleOnBlur();
|
|
172
141
|
onClose();
|
|
173
142
|
};
|
|
174
143
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
144
|
+
this.handleClickEscape = () => {
|
|
145
|
+
const {
|
|
146
|
+
onClose
|
|
147
|
+
} = this.props;
|
|
148
|
+
this.setState({
|
|
179
149
|
inputFocused: false
|
|
180
150
|
});
|
|
181
|
-
|
|
182
|
-
_this.handleOnBlur();
|
|
183
|
-
|
|
151
|
+
this.handleOnBlur();
|
|
184
152
|
onClose();
|
|
185
153
|
};
|
|
186
154
|
|
|
187
|
-
|
|
188
|
-
setTimeout(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
155
|
+
this.handleOnBlur = () => {
|
|
156
|
+
setTimeout(() => {
|
|
157
|
+
const {
|
|
158
|
+
onBlur,
|
|
159
|
+
autoClear
|
|
160
|
+
} = this.props;
|
|
161
|
+
const {
|
|
162
|
+
dataInput,
|
|
163
|
+
selectedDate
|
|
164
|
+
} = this.state;
|
|
195
165
|
|
|
196
166
|
if (moment(selectedDate, FORMAT, true).isValid()) {
|
|
197
167
|
onBlur(dataInput, selectedDate);
|
|
198
168
|
} else {
|
|
199
169
|
if (autoClear) {
|
|
200
|
-
|
|
170
|
+
this.setState({
|
|
201
171
|
dataInput: undefined
|
|
202
172
|
});
|
|
203
173
|
}
|
|
@@ -207,171 +177,170 @@ var DSdatePickerImpl = /*#__PURE__*/function (_React$Component) {
|
|
|
207
177
|
});
|
|
208
178
|
};
|
|
209
179
|
|
|
210
|
-
|
|
211
|
-
|
|
180
|
+
this.handleInputFocus = dataInput => {
|
|
181
|
+
const {
|
|
182
|
+
onFocus
|
|
183
|
+
} = this.props;
|
|
212
184
|
onFocus(dataInput);
|
|
213
185
|
};
|
|
214
186
|
|
|
215
|
-
|
|
187
|
+
this.state = {
|
|
216
188
|
pickerRef: /*#__PURE__*/React.createRef(),
|
|
217
189
|
dataInput: '',
|
|
218
190
|
selectedDate: null,
|
|
219
191
|
inputFocused: false
|
|
220
192
|
};
|
|
221
|
-
return _this;
|
|
222
193
|
}
|
|
223
194
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
displayFormatDay = _this$props5.displayFormatDay,
|
|
245
|
-
isDayBlocked = _this$props5.isDayBlocked,
|
|
246
|
-
isOutsideRange = _this$props5.isOutsideRange,
|
|
247
|
-
isDayHighlighted = _this$props5.isDayHighlighted,
|
|
248
|
-
tabIndex = _this$props5.tabIndex,
|
|
249
|
-
zIndex = _this$props5.zIndex,
|
|
250
|
-
pickerProps = _this$props5.pickerProps,
|
|
251
|
-
calendarProps = _this$props5.calendarProps,
|
|
252
|
-
focusCurrentDate = _this$props5.focusCurrentDate;
|
|
253
|
-
var safedate = this.getSafeValue();
|
|
254
|
-
var safeInputValue = this.getSafeInputValue();
|
|
255
|
-
var hasSelectedDate = !!safedate;
|
|
256
|
-
return /*#__PURE__*/React.createElement(DSInputGroup, {
|
|
257
|
-
rightAddon: /*#__PURE__*/React.createElement(DatePickerDropdown, {
|
|
258
|
-
pickerRef: this.state.pickerRef,
|
|
259
|
-
disabled: disabled,
|
|
260
|
-
isOpen: inputFocused,
|
|
261
|
-
menu: /*#__PURE__*/React.createElement("div", {
|
|
262
|
-
style: {
|
|
263
|
-
minHeight: '310px',
|
|
264
|
-
zIndex: 1
|
|
265
|
-
},
|
|
266
|
-
className: hasSelectedDate ? 'has-selected-date' : 'without-selected-date',
|
|
267
|
-
"data-testid": "date-picker-portal-wrapper"
|
|
268
|
-
}, /*#__PURE__*/React.createElement(DSDatePickerController, {
|
|
269
|
-
date: safedate,
|
|
270
|
-
displayFormatDay: displayFormatDay,
|
|
271
|
-
enableOutsideDays: enableOutsideDays,
|
|
272
|
-
firstDayOfWeek: firstDayOfWeek,
|
|
273
|
-
hideKeyboardShortcutsPanel: hideKeyboardShortcutsPanel,
|
|
274
|
-
isDayBlocked: isDayBlocked,
|
|
275
|
-
isDayHighlighted: isDayHighlighted,
|
|
276
|
-
isOutsideRange: isOutsideRange,
|
|
277
|
-
keepOpenOnDateSelect: keepOpenOnDateSelect,
|
|
278
|
-
numberOfMonths: numberOfMonths,
|
|
279
|
-
onClickEscape: this.handleClickEscape,
|
|
280
|
-
onClose: function onClose() {
|
|
281
|
-
if (_this2.state.pickerRef.current) _this2.state.pickerRef.current.focus();
|
|
282
|
-
|
|
283
|
-
_onClose.apply(void 0, arguments);
|
|
284
|
-
|
|
285
|
-
_this2.setState({
|
|
286
|
-
inputFocused: false
|
|
287
|
-
});
|
|
288
|
-
},
|
|
289
|
-
onDateChange: this.handleDateChange,
|
|
290
|
-
onFocusChange: this.handleFocus,
|
|
291
|
-
onNextMonthClick: onNextMonthClick,
|
|
292
|
-
onOutsideClick: this.handleCalendarClose,
|
|
293
|
-
onPrevMonthClick: onPrevMonthClick,
|
|
294
|
-
phrases: phrases,
|
|
295
|
-
transitionDuration: transitionDuration,
|
|
296
|
-
calendarProps: calendarProps,
|
|
297
|
-
focusCurrentDate: focusCurrentDate
|
|
298
|
-
})),
|
|
299
|
-
onClick: this.onClickPicker,
|
|
300
|
-
readOnly: readOnly,
|
|
301
|
-
zIndex: zIndex,
|
|
302
|
-
pickerProps: pickerProps
|
|
303
|
-
})
|
|
304
|
-
}, /*#__PURE__*/React.createElement(DSDateInputV2, {
|
|
305
|
-
"data-testid": "datepicker-input",
|
|
306
|
-
"aria-label": placeholder || 'Date Picker Input',
|
|
307
|
-
disabled: disabled,
|
|
308
|
-
onBlur: this.handleOnBlur,
|
|
309
|
-
onChange: this.handleInputChange,
|
|
310
|
-
onDateChange: this.handleChange,
|
|
311
|
-
onFocus: this.handleInputFocus,
|
|
312
|
-
placeholder: placeholder,
|
|
313
|
-
tabIndex: tabIndex,
|
|
314
|
-
value: safeInputValue
|
|
315
|
-
}));
|
|
316
|
-
}
|
|
317
|
-
}], [{
|
|
318
|
-
key: "getDerivedStateFromProps",
|
|
319
|
-
value: function getDerivedStateFromProps(nextProps, prevState) {
|
|
320
|
-
var _ref2 = prevState || {},
|
|
321
|
-
prevVal = _ref2.dataInput,
|
|
322
|
-
prevDate = _ref2.selectedDate;
|
|
323
|
-
|
|
324
|
-
var nextVal = nextProps.value,
|
|
325
|
-
nextDate = nextProps.date;
|
|
326
|
-
var isPrevValMoment = prevVal instanceof moment;
|
|
327
|
-
var isPrevDateMoment = prevDate instanceof moment;
|
|
328
|
-
var prevValAsString = isPrevValMoment ? prevVal.format(FORMAT) : prevVal; // if users wants to clear, we use '==' to catch both undefined AND null
|
|
329
|
-
|
|
330
|
-
if (nextVal == null && nextDate == null) {
|
|
331
|
-
return {
|
|
332
|
-
dataInput: '',
|
|
333
|
-
selectedDate: null
|
|
334
|
-
};
|
|
335
|
-
} // when val is an incomplete state, we don't want to mess with the state
|
|
336
|
-
// it's incomplete when length is not the full mmddyyyy (length === 8)
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
if ((prevValAsString === null || prevValAsString === void 0 ? void 0 : prevValAsString.length) < 8) {
|
|
340
|
-
return null;
|
|
341
|
-
}
|
|
195
|
+
static getDerivedStateFromProps(nextProps, prevState) {
|
|
196
|
+
const {
|
|
197
|
+
dataInput: prevVal,
|
|
198
|
+
selectedDate: prevDate
|
|
199
|
+
} = prevState || {};
|
|
200
|
+
const {
|
|
201
|
+
value: nextVal,
|
|
202
|
+
date: nextDate
|
|
203
|
+
} = nextProps;
|
|
204
|
+
const isPrevValMoment = prevVal instanceof moment;
|
|
205
|
+
const isPrevDateMoment = prevDate instanceof moment;
|
|
206
|
+
const prevValAsString = isPrevValMoment ? prevVal.format(FORMAT) : prevVal; // if users wants to clear, we use '==' to catch both undefined AND null
|
|
207
|
+
|
|
208
|
+
if (nextVal == null && nextDate == null) {
|
|
209
|
+
return {
|
|
210
|
+
dataInput: '',
|
|
211
|
+
selectedDate: null
|
|
212
|
+
};
|
|
213
|
+
} // when val is an incomplete state, we don't want to mess with the state
|
|
214
|
+
// it's incomplete when length is not the full mmddyyyy (length === 8)
|
|
342
215
|
|
|
343
|
-
var prevDateAsString = isPrevDateMoment ? prevDate.format(FORMAT) : prevDate;
|
|
344
|
-
var isNextValMoment = nextVal instanceof moment;
|
|
345
|
-
var isNextDateMoment = nextDate instanceof moment;
|
|
346
|
-
var nextValAsString = isNextValMoment ? nextVal.format(FORMAT) : nextVal;
|
|
347
|
-
var nextValAsMoment = isNextValMoment ? nextVal : moment(nextVal);
|
|
348
|
-
var nextDateAsString = isNextDateMoment ? nextDate.format(FORMAT) : nextDate;
|
|
349
|
-
var nextDateAsMoment = isNextDateMoment ? nextDate : moment(nextDate);
|
|
350
|
-
var hasValChanged = nextValAsString !== prevValAsString;
|
|
351
|
-
var hasDateChanged = nextDateAsString !== prevDateAsString;
|
|
352
|
-
var newState = {};
|
|
353
|
-
var skipStateChange = true; // value has priority over date, if both date and value change we take date
|
|
354
|
-
// as such, order of condition is meaningful
|
|
355
|
-
|
|
356
|
-
if (hasDateChanged) {
|
|
357
|
-
skipStateChange = false;
|
|
358
|
-
newState.dataInput = nextDateAsString;
|
|
359
|
-
newState.selectedDate = nextDateAsMoment;
|
|
360
|
-
}
|
|
361
216
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
217
|
+
if ((prevValAsString === null || prevValAsString === void 0 ? void 0 : prevValAsString.length) < 8) {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const prevDateAsString = isPrevDateMoment ? prevDate.format(FORMAT) : prevDate;
|
|
222
|
+
const isNextValMoment = nextVal instanceof moment;
|
|
223
|
+
const isNextDateMoment = nextDate instanceof moment;
|
|
224
|
+
const nextValAsString = isNextValMoment ? nextVal.format(FORMAT) : nextVal;
|
|
225
|
+
const nextValAsMoment = isNextValMoment ? nextVal : moment(nextVal);
|
|
226
|
+
const nextDateAsString = isNextDateMoment ? nextDate.format(FORMAT) : nextDate;
|
|
227
|
+
const nextDateAsMoment = isNextDateMoment ? nextDate : moment(nextDate);
|
|
228
|
+
const hasValChanged = nextValAsString !== prevValAsString;
|
|
229
|
+
const hasDateChanged = nextDateAsString !== prevDateAsString;
|
|
230
|
+
const newState = {};
|
|
231
|
+
let skipStateChange = true; // value has priority over date, if both date and value change we take date
|
|
232
|
+
// as such, order of condition is meaningful
|
|
233
|
+
|
|
234
|
+
if (hasDateChanged) {
|
|
235
|
+
skipStateChange = false;
|
|
236
|
+
newState.dataInput = nextDateAsString;
|
|
237
|
+
newState.selectedDate = nextDateAsMoment;
|
|
238
|
+
}
|
|
367
239
|
|
|
368
|
-
|
|
369
|
-
|
|
240
|
+
if (hasValChanged) {
|
|
241
|
+
skipStateChange = false;
|
|
242
|
+
newState.dataInput = nextValAsString;
|
|
243
|
+
newState.selectedDate = nextValAsMoment;
|
|
370
244
|
}
|
|
371
|
-
}]);
|
|
372
245
|
|
|
373
|
-
|
|
374
|
-
|
|
246
|
+
if (skipStateChange) return null;
|
|
247
|
+
return newState;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
render() {
|
|
251
|
+
var _this = this;
|
|
252
|
+
|
|
253
|
+
const {
|
|
254
|
+
inputFocused
|
|
255
|
+
} = this.state;
|
|
256
|
+
const {
|
|
257
|
+
disabled,
|
|
258
|
+
numberOfMonths,
|
|
259
|
+
readOnly,
|
|
260
|
+
enableOutsideDays,
|
|
261
|
+
transitionDuration,
|
|
262
|
+
firstDayOfWeek,
|
|
263
|
+
keepOpenOnDateSelect,
|
|
264
|
+
hideKeyboardShortcutsPanel,
|
|
265
|
+
onPrevMonthClick,
|
|
266
|
+
onNextMonthClick,
|
|
267
|
+
onClose,
|
|
268
|
+
phrases,
|
|
269
|
+
placeholder,
|
|
270
|
+
displayFormatDay,
|
|
271
|
+
isDayBlocked,
|
|
272
|
+
isOutsideRange,
|
|
273
|
+
isDayHighlighted,
|
|
274
|
+
tabIndex,
|
|
275
|
+
zIndex,
|
|
276
|
+
pickerProps,
|
|
277
|
+
calendarProps,
|
|
278
|
+
focusCurrentDate
|
|
279
|
+
} = this.props;
|
|
280
|
+
const safedate = this.getSafeValue();
|
|
281
|
+
const safeInputValue = this.getSafeInputValue();
|
|
282
|
+
const hasSelectedDate = !!safedate;
|
|
283
|
+
return /*#__PURE__*/_jsx(DSInputGroup, {
|
|
284
|
+
rightAddon: /*#__PURE__*/_jsx(DatePickerDropdown, {
|
|
285
|
+
pickerRef: this.state.pickerRef,
|
|
286
|
+
disabled: disabled,
|
|
287
|
+
isOpen: inputFocused,
|
|
288
|
+
menu: /*#__PURE__*/_jsx("div", {
|
|
289
|
+
style: {
|
|
290
|
+
minHeight: '310px',
|
|
291
|
+
zIndex: 1
|
|
292
|
+
},
|
|
293
|
+
className: hasSelectedDate ? 'has-selected-date' : 'without-selected-date',
|
|
294
|
+
"data-testid": "date-picker-portal-wrapper"
|
|
295
|
+
}, void 0, /*#__PURE__*/_jsx(DSDatePickerController, {
|
|
296
|
+
date: safedate,
|
|
297
|
+
displayFormatDay: displayFormatDay,
|
|
298
|
+
enableOutsideDays: enableOutsideDays,
|
|
299
|
+
firstDayOfWeek: firstDayOfWeek,
|
|
300
|
+
hideKeyboardShortcutsPanel: hideKeyboardShortcutsPanel,
|
|
301
|
+
isDayBlocked: isDayBlocked,
|
|
302
|
+
isDayHighlighted: isDayHighlighted,
|
|
303
|
+
isOutsideRange: isOutsideRange,
|
|
304
|
+
keepOpenOnDateSelect: keepOpenOnDateSelect,
|
|
305
|
+
numberOfMonths: numberOfMonths,
|
|
306
|
+
onClickEscape: this.handleClickEscape,
|
|
307
|
+
onClose: function () {
|
|
308
|
+
if (_this.state.pickerRef.current) _this.state.pickerRef.current.focus();
|
|
309
|
+
onClose(...arguments);
|
|
310
|
+
|
|
311
|
+
_this.setState({
|
|
312
|
+
inputFocused: false
|
|
313
|
+
});
|
|
314
|
+
},
|
|
315
|
+
onDateChange: this.handleDateChange,
|
|
316
|
+
onFocusChange: this.handleFocus,
|
|
317
|
+
onNextMonthClick: onNextMonthClick,
|
|
318
|
+
onOutsideClick: this.handleCalendarClose,
|
|
319
|
+
onPrevMonthClick: onPrevMonthClick,
|
|
320
|
+
phrases: phrases,
|
|
321
|
+
transitionDuration: transitionDuration,
|
|
322
|
+
calendarProps: calendarProps,
|
|
323
|
+
focusCurrentDate: focusCurrentDate
|
|
324
|
+
})),
|
|
325
|
+
onClick: this.onClickPicker,
|
|
326
|
+
readOnly: readOnly,
|
|
327
|
+
zIndex: zIndex,
|
|
328
|
+
pickerProps: pickerProps
|
|
329
|
+
})
|
|
330
|
+
}, void 0, /*#__PURE__*/_jsx(DSDateInputV2, {
|
|
331
|
+
"data-testid": "datepicker-input",
|
|
332
|
+
"aria-label": placeholder || 'Date Picker Input',
|
|
333
|
+
disabled: disabled,
|
|
334
|
+
onBlur: this.handleOnBlur,
|
|
335
|
+
onChange: this.handleInputChange,
|
|
336
|
+
onDateChange: this.handleChange,
|
|
337
|
+
onFocus: this.handleInputFocus,
|
|
338
|
+
placeholder: placeholder,
|
|
339
|
+
tabIndex: tabIndex,
|
|
340
|
+
value: safeInputValue
|
|
341
|
+
}));
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
}
|
|
375
345
|
|
|
376
346
|
export { DSdatePickerImpl as default };
|
|
377
|
-
//# sourceMappingURL=DSDatePickerImpl.js.map
|