UNPKG

3.24 kBJavaScriptView Raw
1var _class, _temp;
2
3function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
5function _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; }
6
7function _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; }
8
9import React, { Component } from 'react';
10import PropTypes from 'prop-types';
11import Instance from './instance.js';
12
13var Calendar = (_temp = _class = function (_Component) {
14 _inherits(Calendar, _Component);
15
16 function Calendar(props) {
17 _classCallCheck(this, Calendar);
18
19 return _possibleConstructorReturn(this, _Component.call(this, props));
20 }
21
22 Calendar.prototype.componentDidMount = function componentDidMount() {
23 if (this.instance) return;
24 var _props = this.props,
25 type = _props.type,
26 titleFormat = _props.titleFormat,
27 disableBeforeDate = _props.disableBeforeDate,
28 disableAfterDate = _props.disableAfterDate,
29 verticalDrag = _props.verticalDrag,
30 defaultDate = _props.defaultDate,
31 prevHTML = _props.prevHTML,
32 nextHTML = _props.nextHTML,
33 onChange = _props.onChange,
34 onClick = _props.onClick,
35 onError = _props.onError;
36
37 var instance = new Instance(this.$el, {
38 viewType: type,
39 titleFormat: titleFormat,
40
41 disableBeforeDate: disableBeforeDate,
42 disableAfterDate: disableAfterDate,
43 verticalDrag: verticalDrag,
44 defaultDate: defaultDate,
45 prevHTML: prevHTML,
46 nextHTML: nextHTML,
47 onChange: onChange,
48 onClick: onClick,
49 onError: onError
50 });
51 this.instance = instance;
52 };
53
54 Calendar.prototype.render = function render() {
55 var _this2 = this;
56
57 return React.createElement('div', { ref: function ref(el) {
58 _this2.$el = el;
59 }, className: 'calendar' });
60 };
61
62 return Calendar;
63}(Component), _class.defaultProps = {
64 type: 'month',
65 verticalDrag: true,
66 prevHTML: '&lt',
67 nextHTML: '&gt'
68}, _temp);
69export { Calendar as default };
70Calendar.propTypes = process.env.NODE_ENV !== "production" ? {
71 type: PropTypes.string, // week|month
72 titleFormat: PropTypes.string, // 标题日期格式化 YYYY年MM月DD日 周E 第W周
73 disableBeforeDate: PropTypes.object, // 禁用之前日期
74 disableAfterDate: PropTypes.object, // 禁用之后日期
75 verticalDrag: PropTypes.bool, // 是否允许垂直拖动
76 defaultDate: PropTypes.object, // 默认日期
77 prevHTML: PropTypes.string, // 左箭头
78 nextHTML: PropTypes.string, // 右箭头
79 onChange: PropTypes.func,
80 onClick: PropTypes.func,
81 onError: PropTypes.func
82} : {};
\No newline at end of file