@seafile/seafile-calendar 0.1.0 → 0.1.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/{dist/rc-calendar.css → assets/index.css} +11 -13
  2. package/es/Calendar.js +449 -0
  3. package/es/FullCalendar.js +182 -0
  4. package/es/MonthCalendar.js +135 -0
  5. package/es/Picker.js +245 -0
  6. package/es/RangeCalendar.js +876 -0
  7. package/es/calendar/CalendarFooter.js +93 -0
  8. package/es/calendar/CalendarHeader.js +257 -0
  9. package/es/calendar/CalendarRightPanel.js +129 -0
  10. package/es/calendar/OkButton.js +22 -0
  11. package/es/calendar/TimePickerButton.js +28 -0
  12. package/es/calendar/TodayButton.js +28 -0
  13. package/es/date/DateConstants.js +19 -0
  14. package/es/date/DateInput.js +230 -0
  15. package/es/date/DateTBody.js +282 -0
  16. package/es/date/DateTHead.js +86 -0
  17. package/es/date/DateTable.js +32 -0
  18. package/es/decade/DecadePanel.js +181 -0
  19. package/es/full-calendar/CalendarHeader.js +180 -0
  20. package/es/index.js +3 -0
  21. package/es/locale/ar_EG.js +27 -0
  22. package/es/locale/bg_BG.js +27 -0
  23. package/es/locale/ca_ES.js +27 -0
  24. package/es/locale/cs_CZ.js +27 -0
  25. package/es/locale/da_DK.js +27 -0
  26. package/es/locale/de_DE.js +27 -0
  27. package/es/locale/el_GR.js +27 -0
  28. package/es/locale/en_GB.js +27 -0
  29. package/es/locale/en_US.js +28 -0
  30. package/es/locale/es_ES.js +27 -0
  31. package/es/locale/et_EE.js +27 -0
  32. package/es/locale/fa_IR.js +27 -0
  33. package/es/locale/fi_FI.js +27 -0
  34. package/es/locale/fr_BE.js +27 -0
  35. package/es/locale/fr_FR.js +27 -0
  36. package/es/locale/he_IL.js +28 -0
  37. package/es/locale/hi_IN.js +28 -0
  38. package/es/locale/hr_HR.js +28 -0
  39. package/es/locale/hu_HU.js +27 -0
  40. package/es/locale/id_ID.js +28 -0
  41. package/es/locale/is_IS.js +27 -0
  42. package/es/locale/it_IT.js +27 -0
  43. package/es/locale/ja_JP.js +26 -0
  44. package/es/locale/kn_IN.js +28 -0
  45. package/es/locale/ko_KR.js +27 -0
  46. package/es/locale/ku_IQ.js +27 -0
  47. package/es/locale/lv_LV.js +27 -0
  48. package/es/locale/mm_MM.js +28 -0
  49. package/es/locale/mn_MN.js +28 -0
  50. package/es/locale/ms_MY.js +27 -0
  51. package/es/locale/nb_NO.js +27 -0
  52. package/es/locale/nl_BE.js +27 -0
  53. package/es/locale/nl_NL.js +27 -0
  54. package/es/locale/pl_PL.js +27 -0
  55. package/es/locale/pt_BR.js +27 -0
  56. package/es/locale/pt_PT.js +27 -0
  57. package/es/locale/ro_RO.js +28 -0
  58. package/es/locale/ru_RU.js +27 -0
  59. package/es/locale/sk_SK.js +27 -0
  60. package/es/locale/sl_SI.js +27 -0
  61. package/es/locale/sr_RS.js +27 -0
  62. package/es/locale/sv_SE.js +27 -0
  63. package/es/locale/ta_IN.js +28 -0
  64. package/es/locale/th_TH.js +27 -0
  65. package/es/locale/tr_TR.js +27 -0
  66. package/es/locale/ug_CN.js +26 -0
  67. package/es/locale/uk_UA.js +27 -0
  68. package/es/locale/vi_VN.js +28 -0
  69. package/es/locale/zh_CN.js +27 -0
  70. package/es/locale/zh_TW.js +26 -0
  71. package/es/mixin/CalendarMixin.js +123 -0
  72. package/es/mixin/CommonMixin.js +85 -0
  73. package/es/month/MonthPanel.js +154 -0
  74. package/es/month/MonthTable.js +156 -0
  75. package/es/picker/placements.js +35 -0
  76. package/es/range-calendar/CalendarPart.js +151 -0
  77. package/es/util/dayjs.js +17 -0
  78. package/es/util/index.js +557 -0
  79. package/es/util/toTime.js +21 -0
  80. package/es/year/YearPanel.js +194 -0
  81. package/lib/Calendar.js +512 -0
  82. package/lib/FullCalendar.js +221 -0
  83. package/lib/MonthCalendar.js +172 -0
  84. package/lib/Picker.js +282 -0
  85. package/lib/RangeCalendar.js +925 -0
  86. package/lib/calendar/CalendarFooter.js +134 -0
  87. package/lib/calendar/CalendarHeader.js +290 -0
  88. package/lib/calendar/CalendarRightPanel.js +153 -0
  89. package/lib/calendar/OkButton.js +32 -0
  90. package/lib/calendar/TimePickerButton.js +41 -0
  91. package/lib/calendar/TodayButton.js +39 -0
  92. package/lib/date/DateConstants.js +23 -0
  93. package/lib/date/DateInput.js +262 -0
  94. package/lib/date/DateTBody.js +309 -0
  95. package/lib/date/DateTHead.js +106 -0
  96. package/lib/date/DateTable.js +54 -0
  97. package/lib/decade/DecadePanel.js +207 -0
  98. package/lib/full-calendar/CalendarHeader.js +201 -0
  99. package/lib/index.js +12 -0
  100. package/lib/locale/ar_EG.js +31 -0
  101. package/lib/locale/bg_BG.js +31 -0
  102. package/lib/locale/ca_ES.js +31 -0
  103. package/lib/locale/cs_CZ.js +31 -0
  104. package/lib/locale/da_DK.js +31 -0
  105. package/lib/locale/de_DE.js +31 -0
  106. package/lib/locale/el_GR.js +31 -0
  107. package/lib/locale/en_GB.js +31 -0
  108. package/lib/locale/en_US.js +32 -0
  109. package/lib/locale/es_ES.js +31 -0
  110. package/lib/locale/et_EE.js +31 -0
  111. package/lib/locale/fa_IR.js +31 -0
  112. package/lib/locale/fi_FI.js +31 -0
  113. package/lib/locale/fr_BE.js +31 -0
  114. package/lib/locale/fr_FR.js +31 -0
  115. package/lib/locale/he_IL.js +32 -0
  116. package/lib/locale/hi_IN.js +32 -0
  117. package/lib/locale/hr_HR.js +32 -0
  118. package/lib/locale/hu_HU.js +31 -0
  119. package/lib/locale/id_ID.js +32 -0
  120. package/lib/locale/is_IS.js +31 -0
  121. package/lib/locale/it_IT.js +31 -0
  122. package/lib/locale/ja_JP.js +30 -0
  123. package/lib/locale/kn_IN.js +32 -0
  124. package/lib/locale/ko_KR.js +31 -0
  125. package/lib/locale/ku_IQ.js +31 -0
  126. package/lib/locale/lv_LV.js +31 -0
  127. package/lib/locale/mm_MM.js +32 -0
  128. package/lib/locale/mn_MN.js +32 -0
  129. package/lib/locale/ms_MY.js +31 -0
  130. package/lib/locale/nb_NO.js +31 -0
  131. package/lib/locale/nl_BE.js +31 -0
  132. package/lib/locale/nl_NL.js +31 -0
  133. package/lib/locale/pl_PL.js +31 -0
  134. package/lib/locale/pt_BR.js +31 -0
  135. package/lib/locale/pt_PT.js +31 -0
  136. package/lib/locale/ro_RO.js +32 -0
  137. package/lib/locale/ru_RU.js +31 -0
  138. package/lib/locale/sk_SK.js +31 -0
  139. package/lib/locale/sl_SI.js +31 -0
  140. package/lib/locale/sr_RS.js +31 -0
  141. package/lib/locale/sv_SE.js +31 -0
  142. package/lib/locale/ta_IN.js +32 -0
  143. package/lib/locale/th_TH.js +31 -0
  144. package/lib/locale/tr_TR.js +31 -0
  145. package/lib/locale/ug_CN.js +30 -0
  146. package/lib/locale/uk_UA.js +31 -0
  147. package/lib/locale/vi_VN.js +32 -0
  148. package/lib/locale/zh_CN.js +31 -0
  149. package/lib/locale/zh_TW.js +30 -0
  150. package/lib/mixin/CalendarMixin.js +153 -0
  151. package/lib/mixin/CommonMixin.js +106 -0
  152. package/lib/month/MonthPanel.js +179 -0
  153. package/lib/month/MonthTable.js +181 -0
  154. package/lib/picker/placements.js +39 -0
  155. package/lib/range-calendar/CalendarPart.js +184 -0
  156. package/lib/util/dayjs.js +46 -0
  157. package/lib/util/index.js +592 -0
  158. package/lib/util/toTime.js +28 -0
  159. package/lib/year/YearPanel.js +219 -0
  160. package/package.json +2 -1
  161. package/dist/rc-calendar.css.map +0 -1
  162. package/dist/rc-calendar.js +0 -7565
  163. package/dist/rc-calendar.js.map +0 -1
  164. package/dist/rc-calendar.min.css +0 -1178
  165. package/dist/rc-calendar.min.css.map +0 -1
  166. package/dist/rc-calendar.min.js +0 -1
@@ -0,0 +1,182 @@
1
+ import _extends from 'babel-runtime/helpers/extends';
2
+ import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
3
+ import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
4
+ import _inherits from 'babel-runtime/helpers/inherits';
5
+ import React from 'react';
6
+ import PropTypes from 'prop-types';
7
+ import { polyfill } from 'react-lifecycles-compat';
8
+ import DateTable from './date/DateTable';
9
+ import MonthTable from './month/MonthTable';
10
+ import { calendarMixinWrapper, calendarMixinPropTypes, calendarMixinDefaultProps, getNowByCurrentStateValue } from './mixin/CalendarMixin';
11
+ import { commonMixinWrapper, propType, defaultProp } from './mixin/CommonMixin';
12
+ import CalendarHeader from './full-calendar/CalendarHeader';
13
+ import dayjs from './util/dayjs';
14
+
15
+ var FullCalendar = function (_React$Component) {
16
+ _inherits(FullCalendar, _React$Component);
17
+
18
+ function FullCalendar(props) {
19
+ _classCallCheck(this, FullCalendar);
20
+
21
+ var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
22
+
23
+ _initialiseProps.call(_this);
24
+
25
+ var type = void 0;
26
+ if ('type' in props) {
27
+ type = props.type;
28
+ } else {
29
+ type = props.defaultType;
30
+ }
31
+
32
+ _this.state = {
33
+ type: type,
34
+ value: props.value || props.defaultValue || dayjs(),
35
+ selectedValue: props.selectedValue || props.defaultSelectedValue
36
+ };
37
+ return _this;
38
+ }
39
+
40
+ FullCalendar.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, state) {
41
+ var newState = {};
42
+ var value = nextProps.value,
43
+ selectedValue = nextProps.selectedValue;
44
+
45
+
46
+ if ('type' in nextProps) {
47
+ newState = {
48
+ type: nextProps.type
49
+ };
50
+ }
51
+ if ('value' in nextProps) {
52
+ newState.value = value || nextProps.defaultValue || getNowByCurrentStateValue(state.value);
53
+ }
54
+ if ('selectedValue' in nextProps) {
55
+ newState.selectedValue = selectedValue;
56
+ }
57
+
58
+ return newState;
59
+ };
60
+
61
+ FullCalendar.prototype.render = function render() {
62
+ var props = this.props;
63
+ var locale = props.locale,
64
+ prefixCls = props.prefixCls,
65
+ fullscreen = props.fullscreen,
66
+ showHeader = props.showHeader,
67
+ headerComponent = props.headerComponent,
68
+ headerRender = props.headerRender,
69
+ disabledDate = props.disabledDate;
70
+ var _state = this.state,
71
+ value = _state.value,
72
+ type = _state.type;
73
+
74
+
75
+ var header = null;
76
+ if (showHeader) {
77
+ if (headerRender) {
78
+ header = headerRender(value, type, locale);
79
+ } else {
80
+ var TheHeader = headerComponent || CalendarHeader;
81
+ header = React.createElement(TheHeader, _extends({
82
+ key: 'calendar-header'
83
+ }, props, {
84
+ prefixCls: prefixCls + '-full',
85
+ type: type,
86
+ value: value,
87
+ onTypeChange: this.setType,
88
+ onValueChange: this.setValue
89
+ }));
90
+ }
91
+ }
92
+
93
+ var table = type === 'date' ? React.createElement(DateTable, {
94
+ dateRender: props.dateCellRender,
95
+ contentRender: props.dateCellContentRender,
96
+ locale: locale,
97
+ prefixCls: prefixCls,
98
+ onSelect: this.onSelect,
99
+ value: value,
100
+ disabledDate: disabledDate
101
+ }) : React.createElement(MonthTable, {
102
+ cellRender: props.monthCellRender,
103
+ contentRender: props.monthCellContentRender,
104
+ locale: locale,
105
+ onSelect: this.onMonthSelect,
106
+ prefixCls: prefixCls + '-month-panel',
107
+ value: value,
108
+ disabledDate: disabledDate
109
+ });
110
+
111
+ var children = [header, React.createElement(
112
+ 'div',
113
+ { key: 'calendar-body', className: prefixCls + '-calendar-body' },
114
+ table
115
+ )];
116
+
117
+ var className = [prefixCls + '-full'];
118
+
119
+ if (fullscreen) {
120
+ className.push(prefixCls + '-fullscreen');
121
+ }
122
+
123
+ return this.renderRoot({
124
+ children: children,
125
+ className: className.join(' ')
126
+ });
127
+ };
128
+
129
+ return FullCalendar;
130
+ }(React.Component);
131
+
132
+ FullCalendar.propTypes = _extends({}, calendarMixinPropTypes, propType, {
133
+ defaultType: PropTypes.string,
134
+ type: PropTypes.string,
135
+ prefixCls: PropTypes.string,
136
+ locale: PropTypes.object,
137
+ onTypeChange: PropTypes.func,
138
+ fullscreen: PropTypes.bool,
139
+ monthCellRender: PropTypes.func,
140
+ dateCellRender: PropTypes.func,
141
+ showTypeSwitch: PropTypes.bool,
142
+ Select: PropTypes.func.isRequired,
143
+ headerComponents: PropTypes.array,
144
+ headerComponent: PropTypes.object, // The whole header component
145
+ headerRender: PropTypes.func,
146
+ showHeader: PropTypes.bool,
147
+ disabledDate: PropTypes.func,
148
+ value: PropTypes.object,
149
+ defaultValue: PropTypes.object,
150
+ selectedValue: PropTypes.object,
151
+ defaultSelectedValue: PropTypes.object
152
+ });
153
+ FullCalendar.defaultProps = _extends({}, calendarMixinDefaultProps, defaultProp, {
154
+ defaultType: 'date',
155
+ fullscreen: false,
156
+ showTypeSwitch: true,
157
+ showHeader: true,
158
+ onTypeChange: function onTypeChange() {}
159
+ });
160
+
161
+ var _initialiseProps = function _initialiseProps() {
162
+ var _this2 = this;
163
+
164
+ this.onMonthSelect = function (value) {
165
+ _this2.onSelect(value, {
166
+ target: 'month'
167
+ });
168
+ };
169
+
170
+ this.setType = function (type) {
171
+ if (!('type' in _this2.props)) {
172
+ _this2.setState({
173
+ type: type
174
+ });
175
+ }
176
+ _this2.props.onTypeChange(type);
177
+ };
178
+ };
179
+
180
+ polyfill(FullCalendar);
181
+
182
+ export default calendarMixinWrapper(commonMixinWrapper(FullCalendar));
@@ -0,0 +1,135 @@
1
+ import _extends from 'babel-runtime/helpers/extends';
2
+ import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
3
+ import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
4
+ import _inherits from 'babel-runtime/helpers/inherits';
5
+ import React from 'react';
6
+ import PropTypes from 'prop-types';
7
+ import KeyCode from 'rc-util/es/KeyCode';
8
+ import { polyfill } from 'react-lifecycles-compat';
9
+ import CalendarHeader from './calendar/CalendarHeader';
10
+ import CalendarFooter from './calendar/CalendarFooter';
11
+ import { calendarMixinWrapper, calendarMixinPropTypes, calendarMixinDefaultProps } from './mixin/CalendarMixin';
12
+ import { commonMixinWrapper, propType, defaultProp } from './mixin/CommonMixin';
13
+ import dayjs from './util/dayjs';
14
+
15
+ var MonthCalendar = function (_React$Component) {
16
+ _inherits(MonthCalendar, _React$Component);
17
+
18
+ function MonthCalendar(props) {
19
+ _classCallCheck(this, MonthCalendar);
20
+
21
+ var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
22
+
23
+ _this.onKeyDown = function (event) {
24
+ var keyCode = event.keyCode;
25
+ var ctrlKey = event.ctrlKey || event.metaKey;
26
+ var stateValue = _this.state.value;
27
+ var disabledDate = _this.props.disabledDate;
28
+
29
+ var value = stateValue;
30
+ switch (keyCode) {
31
+ case KeyCode.DOWN:
32
+ value = stateValue.clone();
33
+ value = value.add(3, 'months');
34
+ break;
35
+ case KeyCode.UP:
36
+ value = stateValue.clone();
37
+ value = value.add(-3, 'months');
38
+ break;
39
+ case KeyCode.LEFT:
40
+ value = stateValue.clone();
41
+ if (ctrlKey) {
42
+ value = value.add(-1, 'years');
43
+ } else {
44
+ value = value.add(-1, 'months');
45
+ }
46
+ break;
47
+ case KeyCode.RIGHT:
48
+ value = stateValue.clone();
49
+ if (ctrlKey) {
50
+ value = value.add(1, 'years');
51
+ } else {
52
+ value = value.add(1, 'months');
53
+ }
54
+ break;
55
+ case KeyCode.ENTER:
56
+ if (!disabledDate || !disabledDate(stateValue)) {
57
+ _this.onSelect(stateValue);
58
+ }
59
+ event.preventDefault();
60
+ return 1;
61
+ default:
62
+ return undefined;
63
+ }
64
+ if (value !== stateValue) {
65
+ _this.setValue(value);
66
+ event.preventDefault();
67
+ return 1;
68
+ }
69
+ };
70
+
71
+ _this.handlePanelChange = function (_, mode) {
72
+ if (mode !== 'date') {
73
+ _this.setState({ mode: mode });
74
+ }
75
+ };
76
+
77
+ _this.state = {
78
+ mode: 'month',
79
+ value: props.value || props.defaultValue || dayjs(),
80
+ selectedValue: props.selectedValue || props.defaultSelectedValue
81
+ };
82
+ return _this;
83
+ }
84
+
85
+ MonthCalendar.prototype.render = function render() {
86
+ var props = this.props,
87
+ state = this.state;
88
+ var mode = state.mode,
89
+ value = state.value;
90
+
91
+ var children = React.createElement(
92
+ 'div',
93
+ { className: props.prefixCls + '-month-calendar-content' },
94
+ React.createElement(
95
+ 'div',
96
+ { className: props.prefixCls + '-month-header-wrap' },
97
+ React.createElement(CalendarHeader, {
98
+ prefixCls: props.prefixCls,
99
+ mode: mode,
100
+ value: value,
101
+ locale: props.locale,
102
+ disabledMonth: props.disabledDate,
103
+ monthCellRender: props.monthCellRender,
104
+ monthCellContentRender: props.monthCellContentRender,
105
+ onMonthSelect: this.onSelect,
106
+ onValueChange: this.setValue,
107
+ onPanelChange: this.handlePanelChange
108
+ })
109
+ ),
110
+ React.createElement(CalendarFooter, {
111
+ prefixCls: props.prefixCls,
112
+ renderFooter: props.renderFooter
113
+ })
114
+ );
115
+ return this.renderRoot({
116
+ className: props.prefixCls + '-month-calendar',
117
+ children: children
118
+ });
119
+ };
120
+
121
+ return MonthCalendar;
122
+ }(React.Component);
123
+
124
+ MonthCalendar.propTypes = _extends({}, calendarMixinPropTypes, propType, {
125
+ monthCellRender: PropTypes.func,
126
+ value: PropTypes.object,
127
+ defaultValue: PropTypes.object,
128
+ selectedValue: PropTypes.object,
129
+ defaultSelectedValue: PropTypes.object,
130
+ disabledDate: PropTypes.func
131
+ });
132
+ MonthCalendar.defaultProps = _extends({}, defaultProp, calendarMixinDefaultProps);
133
+
134
+
135
+ export default polyfill(calendarMixinWrapper(commonMixinWrapper(MonthCalendar)));
package/es/Picker.js ADDED
@@ -0,0 +1,245 @@
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 React from 'react';
5
+ import ReactDOM from 'react-dom';
6
+ import PropTypes from 'prop-types';
7
+ import { polyfill } from 'react-lifecycles-compat';
8
+ import createChainedFunction from 'rc-util/es/createChainedFunction';
9
+ import KeyCode from 'rc-util/es/KeyCode';
10
+ import placements from './picker/placements';
11
+ import Trigger from 'rc-trigger';
12
+
13
+ function noop() {}
14
+
15
+ function refFn(field, component) {
16
+ this[field] = component;
17
+ }
18
+
19
+ var Picker = function (_React$Component) {
20
+ _inherits(Picker, _React$Component);
21
+
22
+ function Picker(props) {
23
+ _classCallCheck(this, Picker);
24
+
25
+ var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
26
+
27
+ _initialiseProps.call(_this);
28
+
29
+ var open = void 0;
30
+ if ('open' in props) {
31
+ open = props.open;
32
+ } else {
33
+ open = props.defaultOpen;
34
+ }
35
+ var value = props.value || props.defaultValue;
36
+ _this.saveCalendarRef = refFn.bind(_this, 'calendarInstance');
37
+
38
+ _this.state = {
39
+ open: open,
40
+ value: value
41
+ };
42
+ return _this;
43
+ }
44
+
45
+ Picker.prototype.componentDidUpdate = function componentDidUpdate(_, prevState) {
46
+ if (!prevState.open && this.state.open) {
47
+ // setTimeout is for making sure saveCalendarRef happen before focusCalendar
48
+ this.focusTimeout = setTimeout(this.focusCalendar, 0, this);
49
+ }
50
+ };
51
+
52
+ Picker.prototype.componentWillUnmount = function componentWillUnmount() {
53
+ clearTimeout(this.focusTimeout);
54
+ };
55
+
56
+ Picker.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps) {
57
+ var newState = {};
58
+ var value = nextProps.value,
59
+ open = nextProps.open;
60
+
61
+ if ('value' in nextProps) {
62
+ newState.value = value;
63
+ }
64
+ if (open !== undefined) {
65
+ newState.open = open;
66
+ }
67
+ return newState;
68
+ };
69
+
70
+ Picker.prototype.render = function render() {
71
+ var props = this.props;
72
+ var prefixCls = props.prefixCls,
73
+ placement = props.placement,
74
+ style = props.style,
75
+ getCalendarContainer = props.getCalendarContainer,
76
+ align = props.align,
77
+ animation = props.animation,
78
+ disabled = props.disabled,
79
+ dropdownClassName = props.dropdownClassName,
80
+ transitionName = props.transitionName,
81
+ children = props.children;
82
+
83
+ var state = this.state;
84
+ return React.createElement(
85
+ Trigger,
86
+ {
87
+ popup: this.getCalendarElement(),
88
+ popupAlign: align,
89
+ builtinPlacements: placements,
90
+ popupPlacement: placement,
91
+ action: disabled && !state.open ? [] : ['click'],
92
+ destroyPopupOnHide: true,
93
+ getPopupContainer: getCalendarContainer,
94
+ popupStyle: style,
95
+ popupAnimation: animation,
96
+ popupTransitionName: transitionName,
97
+ popupVisible: state.open,
98
+ onPopupVisibleChange: this.onVisibleChange,
99
+ prefixCls: prefixCls,
100
+ popupClassName: dropdownClassName
101
+ },
102
+ React.cloneElement(children(state, props), { onKeyDown: this.onKeyDown })
103
+ );
104
+ };
105
+
106
+ return Picker;
107
+ }(React.Component);
108
+
109
+ Picker.propTypes = {
110
+ animation: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
111
+ disabled: PropTypes.bool,
112
+ transitionName: PropTypes.string,
113
+ onChange: PropTypes.func,
114
+ onOpenChange: PropTypes.func,
115
+ children: PropTypes.func,
116
+ getCalendarContainer: PropTypes.func,
117
+ calendar: PropTypes.element,
118
+ style: PropTypes.object,
119
+ open: PropTypes.bool,
120
+ defaultOpen: PropTypes.bool,
121
+ prefixCls: PropTypes.string,
122
+ placement: PropTypes.any,
123
+ value: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
124
+ defaultValue: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
125
+ align: PropTypes.object,
126
+ dateRender: PropTypes.func,
127
+ onBlur: PropTypes.func
128
+ };
129
+ Picker.defaultProps = {
130
+ prefixCls: 'rc-calendar-picker',
131
+ style: {},
132
+ align: {},
133
+ placement: 'bottomLeft',
134
+ defaultOpen: false,
135
+ onChange: noop,
136
+ onOpenChange: noop,
137
+ onBlur: noop
138
+ };
139
+
140
+ var _initialiseProps = function _initialiseProps() {
141
+ var _this2 = this;
142
+
143
+ this.onCalendarKeyDown = function (event) {
144
+ if (event.keyCode === KeyCode.ESC) {
145
+ event.stopPropagation();
146
+ _this2.close(_this2.focus);
147
+ }
148
+ };
149
+
150
+ this.onCalendarSelect = function (value) {
151
+ var cause = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
152
+
153
+ var props = _this2.props;
154
+ if (!('value' in props)) {
155
+ _this2.setState({
156
+ value: value
157
+ });
158
+ }
159
+ if (cause.source === 'keyboard' || cause.source === 'dateInputSelect' || !props.calendar.props.timePicker && cause.source !== 'dateInput' || cause.source === 'todayButton') {
160
+ _this2.close(_this2.focus);
161
+ }
162
+ props.onChange(value);
163
+ };
164
+
165
+ this.onKeyDown = function (event) {
166
+ if (!_this2.state.open && (event.keyCode === KeyCode.DOWN || event.keyCode === KeyCode.ENTER)) {
167
+ _this2.open();
168
+ event.preventDefault();
169
+ }
170
+ };
171
+
172
+ this.onCalendarOk = function () {
173
+ _this2.close(_this2.focus);
174
+ };
175
+
176
+ this.onCalendarClear = function () {
177
+ _this2.close(_this2.focus);
178
+ };
179
+
180
+ this.onCalendarBlur = function () {
181
+ _this2.setOpen(false);
182
+ };
183
+
184
+ this.onVisibleChange = function (open) {
185
+ _this2.setOpen(open);
186
+ };
187
+
188
+ this.getCalendarElement = function () {
189
+ var props = _this2.props;
190
+ var state = _this2.state;
191
+ var calendarProps = props.calendar.props;
192
+ var value = state.value;
193
+
194
+ var defaultValue = value;
195
+ var extraProps = {
196
+ ref: _this2.saveCalendarRef,
197
+ defaultValue: defaultValue || calendarProps.defaultValue,
198
+ selectedValue: value,
199
+ onKeyDown: _this2.onCalendarKeyDown,
200
+ onOk: createChainedFunction(calendarProps.onOk, _this2.onCalendarOk),
201
+ onSelect: createChainedFunction(calendarProps.onSelect, _this2.onCalendarSelect),
202
+ onClear: createChainedFunction(calendarProps.onClear, _this2.onCalendarClear),
203
+ onBlur: createChainedFunction(calendarProps.onBlur, _this2.onCalendarBlur)
204
+ };
205
+
206
+ return React.cloneElement(props.calendar, extraProps);
207
+ };
208
+
209
+ this.setOpen = function (open, callback) {
210
+ var onOpenChange = _this2.props.onOpenChange;
211
+
212
+ if (_this2.state.open !== open) {
213
+ if (!('open' in _this2.props)) {
214
+ _this2.setState({
215
+ open: open
216
+ }, callback);
217
+ }
218
+ onOpenChange(open);
219
+ }
220
+ };
221
+
222
+ this.open = function (callback) {
223
+ _this2.setOpen(true, callback);
224
+ };
225
+
226
+ this.close = function (callback) {
227
+ _this2.setOpen(false, callback);
228
+ };
229
+
230
+ this.focus = function () {
231
+ if (!_this2.state.open) {
232
+ ReactDOM.findDOMNode(_this2).focus();
233
+ }
234
+ };
235
+
236
+ this.focusCalendar = function () {
237
+ if (_this2.state.open && !!_this2.calendarInstance) {
238
+ _this2.calendarInstance.focus();
239
+ }
240
+ };
241
+ };
242
+
243
+ polyfill(Picker);
244
+
245
+ export default Picker;