1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
8 |
|
9 | var _react = require('react');
|
10 |
|
11 | var _react2 = _interopRequireDefault(_react);
|
12 |
|
13 | var _propTypes = require('prop-types');
|
14 |
|
15 | var _propTypes2 = _interopRequireDefault(_propTypes);
|
16 |
|
17 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
18 |
|
19 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
20 |
|
21 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
22 |
|
23 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
24 |
|
25 | var MonthDropdownOptions = function (_React$Component) {
|
26 | _inherits(MonthDropdownOptions, _React$Component);
|
27 |
|
28 | function MonthDropdownOptions() {
|
29 | var _ref;
|
30 |
|
31 | var _temp, _this, _ret;
|
32 |
|
33 | _classCallCheck(this, MonthDropdownOptions);
|
34 |
|
35 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
36 | args[_key] = arguments[_key];
|
37 | }
|
38 |
|
39 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = MonthDropdownOptions.__proto__ || Object.getPrototypeOf(MonthDropdownOptions)).call.apply(_ref, [this].concat(args))), _this), _this.renderOptions = function () {
|
40 | return _this.props.monthNames.map(function (month, i) {
|
41 | return _react2.default.createElement(
|
42 | 'div',
|
43 | { className: 'react-datepicker__month-option',
|
44 | key: month,
|
45 | ref: month,
|
46 | onClick: _this.onChange.bind(_this, i) },
|
47 | _this.props.month === i ? _react2.default.createElement(
|
48 | 'span',
|
49 | { className: 'react-datepicker__month-option--selected' },
|
50 | '\u2713'
|
51 | ) : '',
|
52 | month
|
53 | );
|
54 | });
|
55 | }, _this.onChange = function (month) {
|
56 | return _this.props.onChange(month);
|
57 | }, _this.handleClickOutside = function () {
|
58 | return _this.props.onCancel();
|
59 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
60 | }
|
61 |
|
62 | _createClass(MonthDropdownOptions, [{
|
63 | key: 'render',
|
64 | value: function render() {
|
65 | return _react2.default.createElement(
|
66 | 'div',
|
67 | { className: 'react-datepicker__month-dropdown' },
|
68 | this.renderOptions()
|
69 | );
|
70 | }
|
71 | }]);
|
72 |
|
73 | return MonthDropdownOptions;
|
74 | }(_react2.default.Component);
|
75 |
|
76 | MonthDropdownOptions.propTypes = {
|
77 | onCancel: _propTypes2.default.func.isRequired,
|
78 | onChange: _propTypes2.default.func.isRequired,
|
79 | month: _propTypes2.default.number.isRequired,
|
80 | monthNames: _propTypes2.default.arrayOf(_propTypes2.default.string.isRequired).isRequired
|
81 | };
|
82 | exports.default = MonthDropdownOptions;
|