forked from Hacker0x01/react-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
week.js
73 lines (59 loc) · 2.09 KB
/
week.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
'use strict';
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _createReactClass = require('create-react-class');
var _createReactClass2 = _interopRequireDefault(_createReactClass);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _day = require('./day');
var _day2 = _interopRequireDefault(_day);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var Week = (0, _createReactClass2.default)({
displayName: 'Week',
propTypes: {
day: _propTypes2.default.object.isRequired,
endDate: _propTypes2.default.object,
excludeDates: _propTypes2.default.array,
filterDate: _propTypes2.default.func,
includeDates: _propTypes2.default.array,
maxDate: _propTypes2.default.object,
minDate: _propTypes2.default.object,
month: _propTypes2.default.number,
onDayClick: _propTypes2.default.func,
selected: _propTypes2.default.object,
startDate: _propTypes2.default.object
},
handleDayClick: function handleDayClick(day) {
if (this.props.onDayClick) {
this.props.onDayClick(day);
}
},
renderDays: function renderDays() {
var _this = this;
var startOfWeek = this.props.day.clone().startOf('week');
return [0, 1, 2, 3, 4, 5, 6].map(function (offset) {
var day = startOfWeek.clone().add(offset, 'days');
return _react2.default.createElement(_day2.default, {
key: offset,
day: day,
month: _this.props.month,
onClick: _this.handleDayClick.bind(_this, day),
minDate: _this.props.minDate,
maxDate: _this.props.maxDate,
excludeDates: _this.props.excludeDates,
includeDates: _this.props.includeDates,
filterDate: _this.props.filterDate,
selected: _this.props.selected,
startDate: _this.props.startDate,
endDate: _this.props.endDate });
});
},
render: function render() {
return _react2.default.createElement(
'div',
{ className: 'react-datepicker__week' },
this.renderDays()
);
}
});
module.exports = Week;