var _class, _temp;

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

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; }

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; }

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Instance from './instance.js';

var Calendar = (_temp = _class = function (_Component) {
  _inherits(Calendar, _Component);

  function Calendar(props) {
    _classCallCheck(this, Calendar);

    return _possibleConstructorReturn(this, _Component.call(this, props));
  }

  Calendar.prototype.componentDidMount = function componentDidMount() {
    if (this.instance) return;
    var _props = this.props,
        type = _props.type,
        titleFormat = _props.titleFormat,
        disableBeforeDate = _props.disableBeforeDate,
        disableAfterDate = _props.disableAfterDate,
        verticalDrag = _props.verticalDrag,
        defaultDate = _props.defaultDate,
        prevHTML = _props.prevHTML,
        nextHTML = _props.nextHTML,
        onChange = _props.onChange,
        onClick = _props.onClick,
        fail = _props.fail;

    var instance = new Instance(this.$el, {
      viewType: type,
      titleFormat: titleFormat,

      disableBeforeDate: disableBeforeDate,
      disableAfterDate: disableAfterDate,
      verticalDrag: verticalDrag,
      defaultDate: defaultDate,
      prevHTML: prevHTML,
      nextHTML: nextHTML,
      onChange: onChange,
      onClick: onClick,
      fail: fail
    });
    this.instance = instance;
  };

  Calendar.prototype.render = function render() {
    var _this2 = this;

    return React.createElement('div', { ref: function ref(el) {
        _this2.$el = el;
      }, className: 'calendar' });
  };

  return Calendar;
}(Component), _class.defaultProps = {
  type: 'month',
  verticalDrag: true,
  prevHTML: '&lt',
  nextHTML: '&gt'
}, _temp);
export { Calendar as default };
Calendar.propTypes = process.env.NODE_ENV !== "production" ? {
  type: PropTypes.string, // week|month
  titleFormat: PropTypes.string, // 标题日期格式化 YYYY年MM月DD日 周E 第W周
  disableBeforeDate: PropTypes.object, // 禁用之前日期
  disableAfterDate: PropTypes.object, // 禁用之后日期
  verticalDrag: PropTypes.bool, // 是否允许垂直拖动
  defaultDate: PropTypes.object, // 默认日期
  prevHTML: PropTypes.string, // 左箭头
  nextHTML: PropTypes.string, // 右箭头
  onChange: PropTypes.func,
  onClick: PropTypes.func,
  fail: PropTypes.func
} : {};