1 | import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
2 | import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
3 | import _inherits from 'babel-runtime/helpers/inherits';
|
4 | import PropTypes from 'prop-types';
|
5 | import enUs from '../locale/en_US';
|
6 |
|
7 | function noop() {}
|
8 |
|
9 | export var propType = {
|
10 | className: PropTypes.string,
|
11 | locale: PropTypes.object,
|
12 | style: PropTypes.object,
|
13 | visible: PropTypes.bool,
|
14 | onSelect: PropTypes.func,
|
15 | prefixCls: PropTypes.string,
|
16 | onChange: PropTypes.func,
|
17 | onOk: PropTypes.func
|
18 | };
|
19 |
|
20 | export var defaultProp = {
|
21 | locale: enUs,
|
22 | style: {},
|
23 | visible: true,
|
24 | prefixCls: 'rc-calendar',
|
25 | className: '',
|
26 | onSelect: noop,
|
27 | onChange: noop,
|
28 | onClear: noop,
|
29 | renderFooter: function renderFooter() {
|
30 | return null;
|
31 | },
|
32 | renderSidebar: function renderSidebar() {
|
33 | return null;
|
34 | }
|
35 | };
|
36 |
|
37 | export var commonMixinWrapper = function commonMixinWrapper(ComposeComponent) {
|
38 | var _class, _temp2;
|
39 |
|
40 | return _temp2 = _class = function (_ComposeComponent) {
|
41 | _inherits(_class, _ComposeComponent);
|
42 |
|
43 | function _class() {
|
44 | var _temp, _this, _ret;
|
45 |
|
46 | _classCallCheck(this, _class);
|
47 |
|
48 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
49 | args[_key] = arguments[_key];
|
50 | }
|
51 |
|
52 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, _ComposeComponent.call.apply(_ComposeComponent, [this].concat(args))), _this), _this.getFormat = function () {
|
53 | var format = _this.props.format;
|
54 | var _this$props = _this.props,
|
55 | locale = _this$props.locale,
|
56 | timePicker = _this$props.timePicker;
|
57 |
|
58 | if (!format) {
|
59 | if (timePicker) {
|
60 | format = locale.dateTimeFormat;
|
61 | } else {
|
62 | format = locale.dateFormat;
|
63 | }
|
64 | }
|
65 | return format;
|
66 | }, _this.focus = function () {
|
67 | if (_this.focusElement) {
|
68 | _this.focusElement.focus();
|
69 | } else if (_this.rootInstance) {
|
70 | _this.rootInstance.focus();
|
71 | }
|
72 | }, _this.saveFocusElement = function (focusElement) {
|
73 | _this.focusElement = focusElement;
|
74 | }, _this.saveRoot = function (root) {
|
75 | _this.rootInstance = root;
|
76 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
77 | }
|
78 |
|
79 | _class.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
|
80 | return this.props.visible || nextProps.visible;
|
81 | };
|
82 |
|
83 | return _class;
|
84 | }(ComposeComponent), _class.displayName = 'CommonMixinWrapper', _class.defaultProps = ComposeComponent.defaultProps, _class.getDerivedStateFromProps = ComposeComponent.getDerivedStateFromProps, _temp2;
|
85 | }; |
\ | No newline at end of file |