react-select-datepicker 1.1.2 → 2.0.2
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/README.md +43 -70
- package/dist/_virtual/_tslib.js +15 -0
- package/dist/components/OptionsRenderer.d.ts +9 -0
- package/dist/components/OptionsRenderer.js +1 -0
- package/dist/components/SelectDatepicker.d.ts +4 -0
- package/dist/components/SelectDatepicker.js +1 -0
- package/dist/components/SelectRenderer.d.ts +16 -0
- package/dist/components/SelectRenderer.js +1 -0
- package/dist/index.d.ts +3 -4
- package/dist/index.js +1 -304
- package/dist/interfaces/ISelectDatePicker.d.ts +16 -0
- package/dist/types/SelectDatepickerOptions.d.ts +28 -0
- package/dist/utils/helpers.d.ts +19 -0
- package/dist/utils/helpers.js +1 -0
- package/package.json +102 -62
- package/dist/dateMap.d.ts +0 -4
- package/dist/dateValidation.d.ts +0 -16
- package/dist/helpers.d.ts +0 -5
- package/dist/index.es.js +0 -525
- package/dist/index.es.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.modern.js +0 -301
- package/dist/index.modern.js.map +0 -1
- package/dist/interfaces.d.ts +0 -26
- package/dist/og.d.ts +0 -19
- package/dist/setupTests.d.ts +0 -1
- package/dist/styles.d.ts +0 -3
- package/dist/tests/index.spec.d.ts +0 -1
package/dist/index.es.js
DELETED
|
@@ -1,525 +0,0 @@
|
|
|
1
|
-
import moment from 'moment';
|
|
2
|
-
import React, { Component } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Determine id provided date is a valid date and falls between date range
|
|
7
|
-
* @param {string} day
|
|
8
|
-
* @param {string} month
|
|
9
|
-
* @param {string} year
|
|
10
|
-
* @param {object} props
|
|
11
|
-
*/
|
|
12
|
-
var isValidDate = function isValidDate(day, month, year, props) {
|
|
13
|
-
var userDate = buildDateFromInput(day, month, year);
|
|
14
|
-
|
|
15
|
-
// Must be a valid date
|
|
16
|
-
if (!userDate.isValid()) {
|
|
17
|
-
return props.invalidMessage || 'Not a valid date';
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Must be same or before max date
|
|
21
|
-
if (props.maxDate) {
|
|
22
|
-
var maxDate = buildDateFromDate(props.maxDate);
|
|
23
|
-
if (!userDate.isSameOrBefore(maxDate)) {
|
|
24
|
-
return props.maxDateMessage || 'Date must be less than ' + maxDate.add(1, 'day').format('MMMM Do, YYYY');
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Must be same or after min date
|
|
29
|
-
if (props.minDate) {
|
|
30
|
-
var minDate = buildDateFromDate(props.minDate);
|
|
31
|
-
if (!userDate.isSameOrAfter(minDate)) {
|
|
32
|
-
return props.minDateMessage || 'Date must be greater than ' + minDate.subtract(1, 'day').format('MMMM Do, YYYY');
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return '';
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Build a moment date from input
|
|
41
|
-
* @param {string} day
|
|
42
|
-
* @param {string} month
|
|
43
|
-
* @param {string} year
|
|
44
|
-
*/
|
|
45
|
-
var buildDateFromInput = function buildDateFromInput(day, month, year) {
|
|
46
|
-
var date = moment(day + '/' + month + '/' + year, 'D/M/YYYY', true);
|
|
47
|
-
return date;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Build a moment date from date object
|
|
52
|
-
* @param {Date} date
|
|
53
|
-
*/
|
|
54
|
-
var buildDateFromDate = function buildDateFromDate(date) {
|
|
55
|
-
var newDate = moment(date);
|
|
56
|
-
return newDate;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
var MONTHMAP = {
|
|
60
|
-
1: 'January',
|
|
61
|
-
2: 'February',
|
|
62
|
-
3: 'March',
|
|
63
|
-
4: 'April',
|
|
64
|
-
5: 'May',
|
|
65
|
-
6: 'June',
|
|
66
|
-
7: 'July',
|
|
67
|
-
8: 'August',
|
|
68
|
-
9: 'September',
|
|
69
|
-
10: 'October',
|
|
70
|
-
11: 'November',
|
|
71
|
-
12: 'December'
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
var getDays = function getDays(showLabel, dayLabel) {
|
|
75
|
-
var days = [];
|
|
76
|
-
|
|
77
|
-
days.push(React.createElement(
|
|
78
|
-
'option',
|
|
79
|
-
{ value: '', disabled: true },
|
|
80
|
-
showLabel ? dayLabel || 'Day' : ''
|
|
81
|
-
));
|
|
82
|
-
|
|
83
|
-
for (var i = 1; i <= 31; i++) {
|
|
84
|
-
days.push(React.createElement(
|
|
85
|
-
'option',
|
|
86
|
-
{ value: '' + i },
|
|
87
|
-
i
|
|
88
|
-
));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return days;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
var getMonths = function getMonths(showLabel, monthLabel, monthNames) {
|
|
95
|
-
var months = [];
|
|
96
|
-
|
|
97
|
-
months.push(React.createElement(
|
|
98
|
-
'option',
|
|
99
|
-
{ value: '', disabled: true },
|
|
100
|
-
showLabel ? monthLabel || 'Month' : ''
|
|
101
|
-
));
|
|
102
|
-
|
|
103
|
-
for (var i = 1; i <= 12; i++) {
|
|
104
|
-
months.push(React.createElement(
|
|
105
|
-
'option',
|
|
106
|
-
{ value: '' + i },
|
|
107
|
-
monthNames ? monthNames[i - 1] : MONTHMAP[i]
|
|
108
|
-
));
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return months;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
var getYears = function getYears(max, min, showLabel, value, yearLabel) {
|
|
115
|
-
var years = [];
|
|
116
|
-
var maxYear = void 0;
|
|
117
|
-
var minYear = void 0;
|
|
118
|
-
|
|
119
|
-
if (!!max && !!min) {
|
|
120
|
-
// Max and min year
|
|
121
|
-
maxYear = moment(max).year();
|
|
122
|
-
minYear = moment(min).year();
|
|
123
|
-
} else if (!!max && !min) {
|
|
124
|
-
// Only max year
|
|
125
|
-
maxYear = moment(max).year();
|
|
126
|
-
minYear = 1900;
|
|
127
|
-
} else if (!max && !!min) {
|
|
128
|
-
// Only min year
|
|
129
|
-
maxYear = moment().year();
|
|
130
|
-
minYear = moment(min).year();
|
|
131
|
-
} else {
|
|
132
|
-
// No max or min
|
|
133
|
-
maxYear = moment(max).year();
|
|
134
|
-
minYear = 1900;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (value) {
|
|
138
|
-
if (value > maxYear) {
|
|
139
|
-
maxYear = value;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (value < minYear) {
|
|
143
|
-
minYear = value;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
years.push(React.createElement(
|
|
148
|
-
'option',
|
|
149
|
-
{ value: '', disabled: true },
|
|
150
|
-
showLabel ? yearLabel || 'Year' : ''
|
|
151
|
-
));
|
|
152
|
-
|
|
153
|
-
for (var i = maxYear; i >= minYear; i--) {
|
|
154
|
-
years.push(React.createElement(
|
|
155
|
-
'option',
|
|
156
|
-
{ value: '' + i },
|
|
157
|
-
i
|
|
158
|
-
));
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return years;
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
function styleInject(css, ref) {
|
|
165
|
-
if ( ref === void 0 ) ref = {};
|
|
166
|
-
var insertAt = ref.insertAt;
|
|
167
|
-
|
|
168
|
-
if (!css || typeof document === 'undefined') { return; }
|
|
169
|
-
|
|
170
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
171
|
-
var style = document.createElement('style');
|
|
172
|
-
style.type = 'text/css';
|
|
173
|
-
|
|
174
|
-
if (insertAt === 'top') {
|
|
175
|
-
if (head.firstChild) {
|
|
176
|
-
head.insertBefore(style, head.firstChild);
|
|
177
|
-
} else {
|
|
178
|
-
head.appendChild(style);
|
|
179
|
-
}
|
|
180
|
-
} else {
|
|
181
|
-
head.appendChild(style);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (style.styleSheet) {
|
|
185
|
-
style.styleSheet.cssText = css;
|
|
186
|
-
} else {
|
|
187
|
-
style.appendChild(document.createTextNode(css));
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
var css = ".styles_flexRow__3lnwY {\n display: flex;\n flex-direction: row;\n}\n\n.styles_flexColumn__25_Q1 {\n display: flex;\n flex-direction: column;\n}";
|
|
192
|
-
var styles = { "flexRow": "styles_flexRow__3lnwY", "flexColumn": "styles_flexColumn__25_Q1" };
|
|
193
|
-
styleInject(css);
|
|
194
|
-
|
|
195
|
-
var classCallCheck = function (instance, Constructor) {
|
|
196
|
-
if (!(instance instanceof Constructor)) {
|
|
197
|
-
throw new TypeError("Cannot call a class as a function");
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
var createClass = function () {
|
|
202
|
-
function defineProperties(target, props) {
|
|
203
|
-
for (var i = 0; i < props.length; i++) {
|
|
204
|
-
var descriptor = props[i];
|
|
205
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
206
|
-
descriptor.configurable = true;
|
|
207
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
208
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return function (Constructor, protoProps, staticProps) {
|
|
213
|
-
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
|
214
|
-
if (staticProps) defineProperties(Constructor, staticProps);
|
|
215
|
-
return Constructor;
|
|
216
|
-
};
|
|
217
|
-
}();
|
|
218
|
-
|
|
219
|
-
var defineProperty = function (obj, key, value) {
|
|
220
|
-
if (key in obj) {
|
|
221
|
-
Object.defineProperty(obj, key, {
|
|
222
|
-
value: value,
|
|
223
|
-
enumerable: true,
|
|
224
|
-
configurable: true,
|
|
225
|
-
writable: true
|
|
226
|
-
});
|
|
227
|
-
} else {
|
|
228
|
-
obj[key] = value;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
return obj;
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
var _extends = Object.assign || function (target) {
|
|
235
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
236
|
-
var source = arguments[i];
|
|
237
|
-
|
|
238
|
-
for (var key in source) {
|
|
239
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
240
|
-
target[key] = source[key];
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return target;
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
var inherits = function (subClass, superClass) {
|
|
249
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
250
|
-
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
254
|
-
constructor: {
|
|
255
|
-
value: subClass,
|
|
256
|
-
enumerable: false,
|
|
257
|
-
writable: true,
|
|
258
|
-
configurable: true
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
var possibleConstructorReturn = function (self, call) {
|
|
265
|
-
if (!self) {
|
|
266
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
return call && (typeof call === "object" || typeof call === "function") ? call : self;
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
var SelectDatepicker = function (_Component) {
|
|
273
|
-
inherits(SelectDatepicker, _Component);
|
|
274
|
-
|
|
275
|
-
function SelectDatepicker(props) {
|
|
276
|
-
classCallCheck(this, SelectDatepicker);
|
|
277
|
-
|
|
278
|
-
var _this = possibleConstructorReturn(this, (SelectDatepicker.__proto__ || Object.getPrototypeOf(SelectDatepicker)).call(this, props));
|
|
279
|
-
|
|
280
|
-
_initialiseProps.call(_this);
|
|
281
|
-
|
|
282
|
-
_this.state = _extends({
|
|
283
|
-
value: null,
|
|
284
|
-
error: null,
|
|
285
|
-
hasError: false
|
|
286
|
-
}, _this.getDateStateFromProps(props));
|
|
287
|
-
return _this;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Update state when props change
|
|
292
|
-
*/
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Parse date object into day, month, year state
|
|
297
|
-
*/
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* Handle input hange event
|
|
302
|
-
*/
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Validate inputs. Varify that they are set and contain a valid date.
|
|
307
|
-
*/
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* Set error state
|
|
312
|
-
*/
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* Convert inputs to date object and call onDateChange function
|
|
317
|
-
*/
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* Set date object in state and return new date
|
|
322
|
-
*/
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* Return requested date container
|
|
327
|
-
*/
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Renders a date container element
|
|
332
|
-
*/
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
createClass(SelectDatepicker, [{
|
|
336
|
-
key: 'render',
|
|
337
|
-
value: function render() {
|
|
338
|
-
var _this2 = this;
|
|
339
|
-
|
|
340
|
-
var orderArray = this.props.format.split('/');
|
|
341
|
-
return React.createElement(
|
|
342
|
-
'div',
|
|
343
|
-
{ className: 'rid ' + this.props.className },
|
|
344
|
-
React.createElement(
|
|
345
|
-
'div',
|
|
346
|
-
{ className: 'rid_date-container ' + styles.flexRow },
|
|
347
|
-
orderArray.map(function (value, i) {
|
|
348
|
-
return React.createElement(
|
|
349
|
-
React.Fragment,
|
|
350
|
-
{ key: i },
|
|
351
|
-
_this2.getDateFormat(value)
|
|
352
|
-
);
|
|
353
|
-
})
|
|
354
|
-
),
|
|
355
|
-
this.props.showErrors && React.createElement(
|
|
356
|
-
'div',
|
|
357
|
-
{ className: 'error-message' },
|
|
358
|
-
this.state.error
|
|
359
|
-
)
|
|
360
|
-
);
|
|
361
|
-
}
|
|
362
|
-
}]);
|
|
363
|
-
return SelectDatepicker;
|
|
364
|
-
}(Component);
|
|
365
|
-
|
|
366
|
-
var _initialiseProps = function _initialiseProps() {
|
|
367
|
-
var _this3 = this;
|
|
368
|
-
|
|
369
|
-
this.componentDidMount = function () {
|
|
370
|
-
_this3.validate();
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
this.componentWillReceiveProps = function (props) {
|
|
374
|
-
if (props.value !== _this3.state.value) {
|
|
375
|
-
_this3.setState(_extends({
|
|
376
|
-
value: props.value
|
|
377
|
-
}, _this3.getDateStateFromProps(props)));
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
return null;
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
this.getDateStateFromProps = function (props) {
|
|
384
|
-
return {
|
|
385
|
-
day: props.value ? props.value.getDate() : '',
|
|
386
|
-
month: props.value ? props.value.getMonth() + 1 : '',
|
|
387
|
-
year: props.value ? props.value.getFullYear() : ''
|
|
388
|
-
};
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
this.onInputChange = function (e) {
|
|
392
|
-
_this3.setState(defineProperty({
|
|
393
|
-
error: '',
|
|
394
|
-
hasError: false
|
|
395
|
-
}, e.target.name, e.target.value), function () {
|
|
396
|
-
_this3.validate();
|
|
397
|
-
});
|
|
398
|
-
};
|
|
399
|
-
|
|
400
|
-
this.validate = function () {
|
|
401
|
-
var _state = _this3.state,
|
|
402
|
-
day = _state.day,
|
|
403
|
-
month = _state.month,
|
|
404
|
-
year = _state.year;
|
|
405
|
-
|
|
406
|
-
// Must contain values
|
|
407
|
-
|
|
408
|
-
if (!day || !month || !year) {
|
|
409
|
-
_this3.onDateChange(null);
|
|
410
|
-
return;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
// Validate date input
|
|
414
|
-
var error = isValidDate(day, month, year, _this3.props);
|
|
415
|
-
if (error !== '') {
|
|
416
|
-
_this3.renderError(error, true);
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
_this3.validDateChange();
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
this.renderError = function (error, hasError) {
|
|
424
|
-
_this3.setState({
|
|
425
|
-
error: error,
|
|
426
|
-
hasError: hasError
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
_this3.onDateChange(null);
|
|
430
|
-
};
|
|
431
|
-
|
|
432
|
-
this.validDateChange = function () {
|
|
433
|
-
var date = buildDateFromInput(_this3.state.day, _this3.state.month, _this3.state.year);
|
|
434
|
-
|
|
435
|
-
_this3.onDateChange(date.toDate());
|
|
436
|
-
};
|
|
437
|
-
|
|
438
|
-
this.onDateChange = function (date) {
|
|
439
|
-
_this3.setState({
|
|
440
|
-
value: date
|
|
441
|
-
}, function () {
|
|
442
|
-
_this3.props.onDateChange(date);
|
|
443
|
-
});
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
this.getDateFormat = function (value) {
|
|
447
|
-
var dayLabel = _this3.props.labels && _this3.props.labels.day || 'Day';
|
|
448
|
-
var monthLabel = _this3.props.labels && _this3.props.labels.month || 'Month';
|
|
449
|
-
var yearLabel = _this3.props.labels && _this3.props.labels.year || 'Year';
|
|
450
|
-
|
|
451
|
-
var format = {
|
|
452
|
-
day: _this3.renderDateContainer('rid_day-container', 'day', dayLabel, _this3.state.day, getDays(_this3.props.showLabels, dayLabel)),
|
|
453
|
-
month: _this3.renderDateContainer('rid_month-container', 'month', monthLabel, _this3.state.month, getMonths(_this3.props.showLabels, monthLabel, _this3.props.monthNames)),
|
|
454
|
-
year: _this3.renderDateContainer('rid_year-container', 'year', yearLabel, _this3.state.year, getYears(_this3.props.maxDate, _this3.props.minDate, _this3.props.showLabels, _this3.state.year, yearLabel))
|
|
455
|
-
};
|
|
456
|
-
|
|
457
|
-
return format[value];
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
this.renderDateContainer = function (className, id, label, value, options) {
|
|
461
|
-
return React.createElement(
|
|
462
|
-
'div',
|
|
463
|
-
{ className: className + ' ' + styles.flexColumn },
|
|
464
|
-
_this3.props.showLabels ? React.createElement(
|
|
465
|
-
'label',
|
|
466
|
-
{ htmlFor: id },
|
|
467
|
-
label
|
|
468
|
-
) : null,
|
|
469
|
-
React.createElement(
|
|
470
|
-
'select',
|
|
471
|
-
{
|
|
472
|
-
className: '' + (_this3.state.hasError ? 'has-error' : ''),
|
|
473
|
-
id: id,
|
|
474
|
-
name: id,
|
|
475
|
-
value: value,
|
|
476
|
-
onChange: _this3.onInputChange
|
|
477
|
-
},
|
|
478
|
-
options.map(function (value, i) {
|
|
479
|
-
return React.createElement(
|
|
480
|
-
React.Fragment,
|
|
481
|
-
{ key: i },
|
|
482
|
-
value
|
|
483
|
-
);
|
|
484
|
-
})
|
|
485
|
-
)
|
|
486
|
-
);
|
|
487
|
-
};
|
|
488
|
-
};
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
SelectDatepicker.defaultProps = {
|
|
492
|
-
value: null,
|
|
493
|
-
showLabels: true,
|
|
494
|
-
showErrors: true,
|
|
495
|
-
format: 'month/day/year',
|
|
496
|
-
className: ''
|
|
497
|
-
};
|
|
498
|
-
|
|
499
|
-
SelectDatepicker.propTypes = {
|
|
500
|
-
value: PropTypes.instanceOf(Date),
|
|
501
|
-
// eslint-disable-next-line react/no-unused-prop-types
|
|
502
|
-
minDate: PropTypes.instanceOf(Date),
|
|
503
|
-
// eslint-disable-next-line react/no-unused-prop-types
|
|
504
|
-
maxDate: PropTypes.instanceOf(Date),
|
|
505
|
-
// eslint-disable-next-line react/no-unused-prop-types
|
|
506
|
-
maxDateMessage: PropTypes.string,
|
|
507
|
-
// eslint-disable-next-line react/no-unused-prop-types
|
|
508
|
-
minDateMessage: PropTypes.string,
|
|
509
|
-
// eslint-disable-next-line react/no-unused-prop-types
|
|
510
|
-
invalidMessage: PropTypes.string,
|
|
511
|
-
showLabels: PropTypes.bool,
|
|
512
|
-
showErrors: PropTypes.bool,
|
|
513
|
-
onDateChange: PropTypes.func,
|
|
514
|
-
className: PropTypes.string,
|
|
515
|
-
format: PropTypes.oneOf(['day/month/year', 'day/year/month', 'month/day/year', 'month/year/day', 'year/month/day', 'year/day/month']),
|
|
516
|
-
labels: PropTypes.shape({
|
|
517
|
-
year: PropTypes.string,
|
|
518
|
-
month: PropTypes.string,
|
|
519
|
-
day: PropTypes.string
|
|
520
|
-
}),
|
|
521
|
-
monthNames: PropTypes.arrayOf(PropTypes.string)
|
|
522
|
-
};
|
|
523
|
-
|
|
524
|
-
export default SelectDatepicker;
|
|
525
|
-
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/dateValidation.js","../src/dateMap.js","../node_modules/style-inject/dist/style-inject.es.js","../src/index.js"],"sourcesContent":["import moment from 'moment'\n\n/**\n * Determine id provided date is a valid date and falls between date range\n * @param {string} day\n * @param {string} month\n * @param {string} year\n * @param {object} props\n */\nconst isValidDate = (day, month, year, props) => {\n const userDate = buildDateFromInput(day, month, year)\n\n // Must be a valid date\n if (!userDate.isValid()) {\n return props.invalidMessage || 'Not a valid date'\n }\n\n // Must be same or before max date\n if (props.maxDate) {\n const maxDate = buildDateFromDate(props.maxDate)\n if (!userDate.isSameOrBefore(maxDate)) {\n return props.maxDateMessage || 'Date must be less than ' + maxDate.add(1, 'day').format('MMMM Do, YYYY')\n }\n }\n\n // Must be same or after min date\n if (props.minDate) {\n const minDate = buildDateFromDate(props.minDate)\n if (!userDate.isSameOrAfter(minDate)) {\n return props.minDateMessage || 'Date must be greater than ' + minDate.subtract(1, 'day').format('MMMM Do, YYYY')\n }\n }\n\n return ''\n}\n\n/**\n * Build a moment date from input\n * @param {string} day\n * @param {string} month\n * @param {string} year\n */\nconst buildDateFromInput = (day, month, year) => {\n const date = moment(`${day}/${month}/${year}`, 'D/M/YYYY', true)\n return date\n}\n\n/**\n * Build a moment date from date object\n * @param {Date} date\n */\nconst buildDateFromDate = date => {\n const newDate = moment(date)\n return newDate\n}\n\nexport { isValidDate, buildDateFromInput }\n","import React from 'react'\nimport moment from 'moment'\n\nconst MONTHMAP = {\n 1: 'January',\n 2: 'February',\n 3: 'March',\n 4: 'April',\n 5: 'May',\n 6: 'June',\n 7: 'July',\n 8: 'August',\n 9: 'September',\n 10: 'October',\n 11: 'November',\n 12: 'December'\n}\n\nconst getDays = (showLabel, dayLabel) => {\n const days = []\n\n days.push(<option value='' disabled>{showLabel ? dayLabel || 'Day' : ''}</option>)\n\n for (let i = 1; i <= 31; i++) {\n days.push(<option value={`${i}`}>{i}</option>)\n }\n\n return days\n}\n\nconst getMonths = (showLabel, monthLabel, monthNames) => {\n const months = []\n\n months.push(<option value='' disabled>{showLabel ? monthLabel || 'Month' : ''}</option>)\n\n for (let i = 1; i <= 12; i++) {\n months.push(<option value={`${i}`}>{monthNames ? monthNames[i - 1] : MONTHMAP[i]}</option>)\n }\n\n return months\n}\n\nconst getYears = (max, min, showLabel, value, yearLabel) => {\n const years = []\n let maxYear\n let minYear\n\n if (!!max && !!min) {\n // Max and min year\n maxYear = moment(max).year()\n minYear = moment(min).year()\n } else if (!!max && !min) {\n // Only max year\n maxYear = moment(max).year()\n minYear = 1900\n } else if (!max && !!min) {\n // Only min year\n maxYear = moment().year()\n minYear = moment(min).year()\n } else {\n // No max or min\n maxYear = moment(max).year()\n minYear = 1900\n }\n\n if (value) {\n if (value > maxYear) {\n maxYear = value\n }\n\n if (value < minYear) {\n minYear = value\n }\n }\n\n years.push(<option value='' disabled>{showLabel ? yearLabel || 'Year' : ''}</option>)\n\n for (let i = maxYear; i >= minYear; i--) {\n years.push(<option value={`${i}`}>{i}</option>)\n }\n\n return years\n}\n\nexport { getDays, getMonths, getYears }\n","function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport { isValidDate, buildDateFromInput } from './dateValidation'\nimport { getDays, getMonths, getYears } from './dateMap'\n\nimport styles from './styles.css'\n\nexport default class SelectDatepicker extends Component {\n constructor(props) {\n super(props)\n this.state = {\n value: null,\n error: null,\n hasError: false,\n ...this.getDateStateFromProps(props)\n }\n }\n\n componentDidMount = () => {\n this.validate()\n }\n\n /**\n * Update state when props change\n */\n componentWillReceiveProps = (props) => {\n if (props.value !== this.state.value) {\n this.setState({\n value: props.value,\n ...this.getDateStateFromProps(props)\n })\n }\n\n return null\n }\n\n /**\n * Parse date object into day, month, year state\n */\n getDateStateFromProps = (props) => {\n return {\n day: props.value ? props.value.getDate() : '',\n month: props.value ? props.value.getMonth() + 1 : '',\n year: props.value ? props.value.getFullYear() : ''\n }\n }\n\n /**\n * Handle input hange event\n */\n onInputChange = (e) => {\n this.setState({\n error: '',\n hasError: false,\n [e.target.name]: e.target.value\n }, () => {\n this.validate()\n })\n }\n\n /**\n * Validate inputs. Varify that they are set and contain a valid date.\n */\n validate = () => {\n const { day, month, year } = this.state\n\n // Must contain values\n if (!day || !month || !year) {\n this.onDateChange(null)\n return\n }\n\n // Validate date input\n const error = isValidDate(day, month, year, this.props)\n if (error !== '') {\n this.renderError(error, true)\n return\n }\n\n this.validDateChange()\n }\n\n /**\n * Set error state\n */\n renderError = (error, hasError) => {\n this.setState({\n error: error,\n hasError: hasError\n })\n\n this.onDateChange(null)\n }\n\n /**\n * Convert inputs to date object and call onDateChange function\n */\n validDateChange = () => {\n const date = buildDateFromInput(this.state.day, this.state.month, this.state.year)\n\n this.onDateChange(date.toDate())\n }\n\n /**\n * Set date object in state and return new date\n */\n onDateChange = (date) => {\n this.setState({\n value: date\n }, () => {\n this.props.onDateChange(date)\n })\n }\n\n /**\n * Return requested date container\n */\n getDateFormat = (value) => {\n const dayLabel = (this.props.labels && this.props.labels.day) || 'Day';\n const monthLabel = (this.props.labels && this.props.labels.month) || 'Month';\n const yearLabel = (this.props.labels && this.props.labels.year) ||'Year';\n\n const format = {\n day: this.renderDateContainer(\n 'rid_day-container',\n 'day',\n dayLabel,\n this.state.day,\n getDays(this.props.showLabels, dayLabel)\n ),\n month: this.renderDateContainer(\n 'rid_month-container',\n 'month',\n monthLabel,\n this.state.month,\n getMonths(this.props.showLabels, monthLabel, this.props.monthNames)\n ),\n year: this.renderDateContainer(\n 'rid_year-container',\n 'year',\n yearLabel,\n this.state.year,\n getYears(this.props.maxDate, this.props.minDate, this.props.showLabels, this.state.year, yearLabel)\n )\n }\n\n return format[value]\n }\n\n /**\n * Renders a date container element\n */\n renderDateContainer = (className, id, label, value, options) => {\n return (\n <div className={`${className} ${styles.flexColumn}`}>\n {this.props.showLabels ? <label htmlFor={id}>{label}</label> : null}\n <select\n className={`${this.state.hasError ? 'has-error' : ''}`}\n id={id}\n name={id}\n value={value}\n onChange={this.onInputChange}\n >\n {options.map((value, i) => {\n return (\n <React.Fragment key={i}>\n {value}\n </React.Fragment>\n )\n })}\n </select>\n </div>\n )\n }\n\n render() {\n const orderArray = this.props.format.split('/')\n return (\n <div className={`rid ${this.props.className}`}>\n <div className={`rid_date-container ${styles.flexRow}`}>\n {orderArray.map((value, i) => {\n return (\n <React.Fragment key={i}>\n {this.getDateFormat(value)}\n </React.Fragment>\n )\n })}\n </div>\n {this.props.showErrors && (\n <div className='error-message'>\n {this.state.error}\n </div>\n )}\n </div>\n )\n }\n}\n\nSelectDatepicker.defaultProps = {\n value: null,\n showLabels: true,\n showErrors: true,\n format: 'month/day/year',\n className: ''\n}\n\nSelectDatepicker.propTypes = {\n value: PropTypes.instanceOf(Date),\n // eslint-disable-next-line react/no-unused-prop-types\n minDate: PropTypes.instanceOf(Date),\n // eslint-disable-next-line react/no-unused-prop-types\n maxDate: PropTypes.instanceOf(Date),\n // eslint-disable-next-line react/no-unused-prop-types\n maxDateMessage: PropTypes.string,\n // eslint-disable-next-line react/no-unused-prop-types\n minDateMessage: PropTypes.string,\n // eslint-disable-next-line react/no-unused-prop-types\n invalidMessage: PropTypes.string,\n showLabels: PropTypes.bool,\n showErrors: PropTypes.bool,\n onDateChange: PropTypes.func,\n className: PropTypes.string,\n format: PropTypes.oneOf(\n [\n 'day/month/year',\n 'day/year/month',\n 'month/day/year',\n 'month/year/day',\n 'year/month/day',\n 'year/day/month'\n ]\n ),\n labels: PropTypes.shape({\n year: PropTypes.string,\n month: PropTypes.string,\n day: PropTypes.string\n }),\n monthNames: PropTypes.arrayOf(PropTypes.string)\n}\n"],"names":["isValidDate","day","month","year","props","userDate","buildDateFromInput","isValid","invalidMessage","maxDate","buildDateFromDate","isSameOrBefore","maxDateMessage","add","format","minDate","isSameOrAfter","minDateMessage","subtract","date","moment","newDate","MONTHMAP","getDays","showLabel","dayLabel","days","push","i","getMonths","monthLabel","monthNames","months","getYears","max","min","value","yearLabel","years","maxYear","minYear","SelectDatepicker","state","getDateStateFromProps","orderArray","split","className","styles","flexRow","map","getDateFormat","showErrors","error","Component","componentDidMount","validate","componentWillReceiveProps","setState","getDate","getMonth","getFullYear","onInputChange","e","target","name","onDateChange","renderError","validDateChange","hasError","toDate","labels","renderDateContainer","showLabels","id","label","options","flexColumn","defaultProps","propTypes","PropTypes","instanceOf","Date","string","bool","func","oneOf","shape","arrayOf"],"mappings":";;;;AAEA;;;;;;;AAOA,IAAMA,cAAc,SAAdA,WAAc,CAACC,GAAD,EAAMC,KAAN,EAAaC,IAAb,EAAmBC,KAAnB,EAA6B;MACzCC,WAAWC,mBAAmBL,GAAnB,EAAwBC,KAAxB,EAA+BC,IAA/B,CAAjB;;;MAGI,CAACE,SAASE,OAAT,EAAL,EAAyB;WAChBH,MAAMI,cAAN,IAAwB,kBAA/B;;;;MAIEJ,MAAMK,OAAV,EAAmB;QACXA,UAAUC,kBAAkBN,MAAMK,OAAxB,CAAhB;QACI,CAACJ,SAASM,cAAT,CAAwBF,OAAxB,CAAL,EAAuC;aAC9BL,MAAMQ,cAAN,IAAwB,4BAA4BH,QAAQI,GAAR,CAAY,CAAZ,EAAe,KAAf,EAAsBC,MAAtB,CAA6B,eAA7B,CAA3D;;;;;MAKAV,MAAMW,OAAV,EAAmB;QACXA,UAAUL,kBAAkBN,MAAMW,OAAxB,CAAhB;QACI,CAACV,SAASW,aAAT,CAAuBD,OAAvB,CAAL,EAAsC;aAC7BX,MAAMa,cAAN,IAAwB,+BAA+BF,QAAQG,QAAR,CAAiB,CAAjB,EAAoB,KAApB,EAA2BJ,MAA3B,CAAkC,eAAlC,CAA9D;;;;SAIG,EAAP;CAxBF;;;;;;;;AAiCA,IAAMR,qBAAqB,SAArBA,kBAAqB,CAACL,GAAD,EAAMC,KAAN,EAAaC,IAAb,EAAsB;MACzCgB,OAAOC,OAAUnB,GAAV,SAAiBC,KAAjB,SAA0BC,IAA1B,EAAkC,UAAlC,EAA8C,IAA9C,CAAb;SACOgB,IAAP;CAFF;;;;;;AASA,IAAMT,oBAAoB,SAApBA,iBAAoB,OAAQ;MAC1BW,UAAUD,OAAOD,IAAP,CAAhB;SACOE,OAAP;CAFF;;AChDA,IAAMC,WAAW;KACZ,SADY;KAEZ,UAFY;KAGZ,OAHY;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SAA2BC,OAAO6B,UAAvC;aACQxE,KAAL,CAAWoE,UAAX,GAAwB;;UAAO,SAASC,EAAhB;;OAAxB,GAA8D,IADjE;;;;2BAGkB,OAAK/B,KAAL,CAAW0B,QAAX,GAAsB,WAAtB,GAAoC,EAAlD,CADF;cAEMK,EAFN;gBAGQA,EAHR;iBAISrC,KAJT;oBAKY,OAAKyB;;gBAENZ,GAAR,CAAY,UAACb,KAAD,EAAQR,CAAR,EAAc;iBAEvB;iBAAA,CAAO,QAAP;cAAgB,KAAKA,CAArB;;WADF;SADD;;KAVP;;;;;AA6CJa,iBAAiBoC,YAAjB,GAAgC;SACvB,IADuB;cAElB,IAFkB;cAGlB,IAHkB;UAItB,gBAJsB;aAKnB;CALb;;AAQApC,iBAAiBqC,SAAjB,GAA6B;SACpBC,UAAUC,UAAV,CAAqBC,IAArB,CADoB;;WAGlBF,UAAUC,UAAV,CAAqBC,IAArB,CAHkB;;WAKlBF,UAAUC,UAAV,CAAqBC,IAArB,CALkB;;kBAOXF,UAAUG,MAPC;;kBASXH,UAAUG,MATC;;kBAWXH,UAAUG,MAXC;cAYfH,UAAUI,IAZK;cAafJ,UAAUI,IAbK;gBAcbJ,UAAUK,IAdG;aAehBL,UAAUG,MAfM;UAgBnBH,UAAUM,KAAV,CACN,CACE,gBADF,EAEE,gBAFF,EAGE,gBAHF,EAIE,gBAJF,EAKE,gBALF,EAME,gBANF,CADM,CAhBmB;UA0BnBN,UAAUO,KAAV,CAAgB;UAChBP,UAAUG,MADM;WAEfH,UAAUG,MAFK;SAGjBH,UAAUG;GAHT,CA1BmB;cA+BfH,UAAUQ,OAAV,CAAkBR,UAAUG,MAA5B;CA/Bd;;;;"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/dateValidation.ts","../src/dateMap.tsx","../src/helpers.ts","../src/styles.ts","../src/index.tsx"],"sourcesContent":["/**\n * Build a date from input\n * @param {string} day\n * @param {string} month\n * @param {string} year\n */\nconst buildDateFromInput = (day: string, month: string, year: string) => {\n const date = new Date(Number(year), Number(month) - 1, Number(day));\n return date;\n};\n\n/**\n * Check if the date value is a valid Date object and that it matches the values it was created from\n * @param date Date\n * @param day string\n * @param month string\n * @param year string\n */\nconst isValidDateObject = (\n date: Date,\n day: string,\n month: string,\n year: string,\n) => {\n const isDate = Object.prototype.toString.call(date) === '[object Date]';\n const dayMatch = date.getDate() === Number(day);\n const monthMatch = date.getMonth() === Number(month) - 1;\n const yearMatch = date.getFullYear() === Number(year);\n\n return isDate && dayMatch && monthMatch && yearMatch;\n};\n\n/**\n * Determine if provided date is a valid date and falls between date range\n * @param {string} day\n * @param {string} month\n * @param {string} year\n * @param {object} props\n */\nconst isValidDate = (day: string, month: string, year: string, props: any) => {\n const userDate = buildDateFromInput(day, month, year);\n\n // Must be a valid date\n if (!isValidDateObject(userDate, day, month, year)) {\n return props.invalidMessage || 'Not a valid date';\n }\n\n // Must be same or before max date\n if (props.maxDate) {\n const { maxDate } = props;\n if (userDate > maxDate) {\n const maxDatePlusOne = new Date(maxDate);\n maxDatePlusOne.setDate(maxDatePlusOne.getDate() + 1);\n\n return (\n props.maxDateMessage ||\n `Date must be less than ${maxDatePlusOne.toDateString().substring(3)}`\n );\n }\n }\n\n // Must be same or after min date\n if (props.minDate) {\n const { minDate } = props;\n if (userDate < minDate) {\n const minDateMinusOne = new Date(minDate);\n minDateMinusOne.setDate(minDateMinusOne.getDate() - 1);\n\n return (\n props.minDateMessage ||\n `Date must be greater than ${minDateMinusOne\n .toDateString()\n .substring(3)}`\n );\n }\n }\n\n return '';\n};\n\nexport { isValidDate, buildDateFromInput };\n","import React from 'react';\n\nconst MONTHMAP = {\n 1: 'January',\n 2: 'February',\n 3: 'March',\n 4: 'April',\n 5: 'May',\n 6: 'June',\n 7: 'July',\n 8: 'August',\n 9: 'September',\n 10: 'October',\n 11: 'November',\n 12: 'December',\n};\n\nconst getDays = (showPlaceholder: boolean, dayLabel: string) => {\n const days = [];\n\n days.push(\n <option value=\"\" disabled>\n {showPlaceholder ? dayLabel || 'Day' : ''}\n </option>,\n );\n\n for (let i = 1; i <= 31; i += 1) {\n days.push(<option value={`${i}`}>{i}</option>);\n }\n\n return days;\n};\n\nconst getMonths = (\n showPlaceholder: boolean,\n monthLabel: string,\n monthNames: Array<string> | undefined,\n) => {\n const months = [];\n\n months.push(\n <option value=\"\" disabled>\n {showPlaceholder ? monthLabel || 'Month' : ''}\n </option>,\n );\n\n for (let i = 1; i <= 12; i += 1) {\n months.push(\n <option value={`${i}`}>\n {monthNames ? monthNames[i - 1] : MONTHMAP[i]}\n </option>,\n );\n }\n\n return months;\n};\n\nconst getYears = (\n max: Date | undefined,\n min: Date | undefined,\n showPlaceholder: boolean,\n value: string,\n yearLabel: string,\n) => {\n const years = [];\n let maxYear;\n let minYear;\n\n if (max !== undefined) {\n maxYear = max.getFullYear();\n } else {\n maxYear = new Date().getFullYear();\n }\n\n if (min !== undefined) {\n minYear = min.getFullYear();\n } else {\n minYear = 1900;\n }\n\n if (value) {\n if (Number(value) > maxYear) {\n maxYear = Number(value);\n }\n\n if (Number(value) < minYear) {\n minYear = Number(value);\n }\n }\n\n years.push(\n <option value=\"\" disabled>\n {showPlaceholder ? yearLabel || 'Year' : ''}\n </option>,\n );\n\n for (let i = maxYear; i >= minYear; i -= 1) {\n years.push(<option value={`${i}`}>{i}</option>);\n }\n\n return years;\n};\n\nexport { getDays, getMonths, getYears };\n","import { IDate } from './interfaces';\n\n/**\n * Parse date object into day, month, year state\n */\nexport const spreadDateToObject = (dateValue: Date | null): IDate => {\n return {\n day: dateValue ? `${dateValue.getDate()}` : '',\n month: dateValue ? `${dateValue.getMonth() + 1}` : '',\n year: dateValue ? `${dateValue.getFullYear()}` : '',\n };\n};\n","export const flex: React.CSSProperties = {\n display: 'flex',\n};\n\nexport const flexColumn: React.CSSProperties = {\n display: 'flex',\n flexDirection: 'column',\n};\n","/* eslint-disable react/no-array-index-key */\nimport React, {\n useState,\n useCallback,\n ChangeEvent,\n useMemo,\n useEffect,\n} from 'react';\nimport { isValidDate, buildDateFromInput } from './dateValidation';\nimport { getDays, getMonths, getYears } from './dateMap';\nimport { IDate, ISelectDatePicker } from './interfaces';\nimport { spreadDateToObject } from './helpers';\nimport { flex, flexColumn } from './styles';\n\nconst SelectDatepicker: React.FC<ISelectDatePicker> = (props) => {\n const [isDirty, setIsDirty] = useState<boolean>(true);\n const [hasError, setHasError] = useState<boolean>(false);\n const [error, setError] = useState<string>();\n const [date, setDate] = useState<IDate>(spreadDateToObject(props.value));\n\n const orderArray = useMemo(() => props.format!.split('/'), [props.format]);\n\n /**\n * Call onDateChange prop with the provided date object\n */\n const onDateChange = useCallback(\n (newDate) => {\n props.onDateChange(newDate);\n },\n [props],\n );\n\n /**\n * Build a Date object and call the onDateChange function\n */\n const validDateChange = useCallback(() => {\n const newDate = buildDateFromInput(date.day, date.month, date.year);\n onDateChange(newDate);\n }, [date.day, date.month, date.year, onDateChange]);\n\n /**\n * Sets the error state and calls the onDateChange function with a null value\n */\n const renderError = useCallback(\n (err, hasErr) => {\n setError(err);\n setHasError(hasErr);\n onDateChange(null);\n },\n [onDateChange],\n );\n\n /**\n * Validates if a the inputs form a valid date\n * Returns null if values are not set\n * Returns null and errors if date is not valid\n * Returns a valid date object when everything passes\n */\n const validate = useCallback(() => {\n const { day, month, year } = date;\n\n // Must contain values\n if (!day || !month || !year) {\n onDateChange(null);\n return;\n }\n\n // Validate date input\n const errorString = isValidDate(day, month, year, props);\n if (errorString !== '') {\n renderError(errorString, true);\n return;\n }\n\n validDateChange();\n }, [date, onDateChange, props, renderError, validDateChange]);\n\n /**\n * Sets the date state when an input value changes\n */\n const onInputChange = useCallback(\n (e: ChangeEvent<HTMLSelectElement>) => {\n setDate({ ...date, [e.target.name]: e.target.value });\n setIsDirty(true);\n },\n [date],\n );\n\n /**\n * Create an input field with a form label\n */\n const inputField = useCallback(\n (id, label, value, options) => {\n const className = `rsd_${id}-container`;\n\n return (\n <div className={`${className}`} style={flexColumn}>\n {props.showLabels ? <label htmlFor={id}>{label}</label> : null}\n <select\n className={`${hasError ? 'has-error' : ''}`}\n id={id}\n name={id}\n value={value}\n onChange={onInputChange}>\n {options.map((option: string, i: number) => {\n return (\n <React.Fragment key={`${option}-${i}`}>{option}</React.Fragment>\n );\n })}\n </select>\n </div>\n );\n },\n [hasError, onInputChange, props.showLabels],\n );\n\n /**\n * Creates an object with all input field elements\n */\n const dateField = useMemo(() => {\n const { showPlaceholders, monthNames, maxDate, minDate, labels } = props;\n\n const dayLabel = (labels && labels.day) || 'Day';\n const monthLabel = (labels && labels.month) || 'Month';\n const yearLabel = (labels && labels.year) || 'Year';\n\n const fields = {\n day: inputField(\n 'day',\n dayLabel,\n date.day,\n getDays(showPlaceholders!, dayLabel),\n ),\n month: inputField(\n 'month',\n monthLabel,\n date.month,\n getMonths(showPlaceholders!, monthLabel, monthNames),\n ),\n year: inputField(\n 'year',\n yearLabel,\n date.year,\n getYears(maxDate, minDate, showPlaceholders!, date.year, yearLabel),\n ),\n };\n\n return fields;\n }, [date.day, date.month, date.year, inputField, props]);\n\n /**\n * When ever the date state changes then clear errors and validate the date\n */\n useEffect(() => {\n if (isDirty) {\n setError('');\n setHasError(false);\n validate();\n setIsDirty(false);\n }\n }, [isDirty]);\n\n useEffect(() => {\n const { value } = props;\n const { day, month, year } = date;\n\n if (value !== null && value !== buildDateFromInput(day, month, year)) {\n setDate(spreadDateToObject(value));\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [props]);\n\n return (\n <div className={`rsd ${props.className}`}>\n <div className=\"rsd_date-container\" style={flex}>\n {orderArray.map((key, i) => {\n return (\n <React.Fragment key={`${key}-${i}`}>\n {dateField[key]}\n </React.Fragment>\n );\n })}\n </div>\n {props.showErrors && hasError && (\n <div className=\"error-message\">{error}</div>\n )}\n </div>\n );\n};\n\nexport default SelectDatepicker;\n\nSelectDatepicker.defaultProps = {\n value: null,\n showLabels: true,\n showPlaceholders: true,\n showErrors: true,\n format: 'month/day/year',\n className: '',\n};\n"],"names":["buildDateFromInput","day","month","year","date","Date","Number","isValidDateObject","isDate","Object","prototype","toString","call","dayMatch","getDate","monthMatch","getMonth","yearMatch","getFullYear","isValidDate","props","userDate","invalidMessage","maxDate","maxDatePlusOne","setDate","maxDateMessage","toDateString","substring","minDate","minDateMinusOne","minDateMessage","MONTHMAP","getDays","showPlaceholder","dayLabel","days","push","React","value","disabled","i","getMonths","monthLabel","monthNames","months","getYears","max","min","yearLabel","years","maxYear","minYear","undefined","spreadDateToObject","dateValue","flex","display","flexColumn","flexDirection","SelectDatepicker","useState","isDirty","setIsDirty","hasError","setHasError","error","setError","orderArray","useMemo","format","split","onDateChange","useCallback","newDate","validDateChange","renderError","err","hasErr","validate","errorString","onInputChange","e","target","name","inputField","id","label","options","className","style","showLabels","htmlFor","onChange","map","option","Fragment","key","dateField","showPlaceholders","labels","fields","useEffect","showErrors","defaultProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,GAAD,EAAcC,KAAd,EAA6BC,IAA7B;AACzB,MAAMC,IAAI,GAAG,IAAIC,IAAJ,CAASC,MAAM,CAACH,IAAD,CAAf,EAAuBG,MAAM,CAACJ,KAAD,CAAN,GAAgB,CAAvC,EAA0CI,MAAM,CAACL,GAAD,CAAhD,CAAb;AACA,SAAOG,IAAP;AACD,CAHD;;AAYA,IAAMG,iBAAiB,GAAG,SAApBA,iBAAoB,CACxBH,IADwB,EAExBH,GAFwB,EAGxBC,KAHwB,EAIxBC,IAJwB;AAMxB,MAAMK,MAAM,GAAGC,MAAM,CAACC,SAAP,CAAiBC,QAAjB,CAA0BC,IAA1B,CAA+BR,IAA/B,MAAyC,eAAxD;AACA,MAAMS,QAAQ,GAAGT,IAAI,CAACU,OAAL,OAAmBR,MAAM,CAACL,GAAD,CAA1C;AACA,MAAMc,UAAU,GAAGX,IAAI,CAACY,QAAL,OAA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