@seafile/seafile-calendar 0.0.30 → 0.0.31-APloi0.1

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 (163) hide show
  1. package/assets/index.css +1177 -0
  2. package/dist/rc-calendar.js +72 -50
  3. package/dist/rc-calendar.js.map +1 -1
  4. package/dist/rc-calendar.min.js +1 -1
  5. package/es/Calendar.js +451 -0
  6. package/es/FullCalendar.js +182 -0
  7. package/es/MonthCalendar.js +135 -0
  8. package/es/Picker.js +246 -0
  9. package/es/RangeCalendar.js +876 -0
  10. package/es/calendar/CalendarFooter.js +93 -0
  11. package/es/calendar/CalendarHeader.js +257 -0
  12. package/es/calendar/CalendarRightPanel.js +126 -0
  13. package/es/calendar/OkButton.js +22 -0
  14. package/es/calendar/TimePickerButton.js +28 -0
  15. package/es/calendar/TodayButton.js +28 -0
  16. package/es/date/DateConstants.js +19 -0
  17. package/es/date/DateInput.js +215 -0
  18. package/es/date/DateTBody.js +287 -0
  19. package/es/date/DateTHead.js +86 -0
  20. package/es/date/DateTable.js +32 -0
  21. package/es/decade/DecadePanel.js +181 -0
  22. package/es/full-calendar/CalendarHeader.js +180 -0
  23. package/es/index.js +3 -0
  24. package/es/locale/ar_EG.js +27 -0
  25. package/es/locale/bg_BG.js +27 -0
  26. package/es/locale/ca_ES.js +27 -0
  27. package/es/locale/cs_CZ.js +27 -0
  28. package/es/locale/da_DK.js +27 -0
  29. package/es/locale/de_DE.js +27 -0
  30. package/es/locale/el_GR.js +27 -0
  31. package/es/locale/en_GB.js +27 -0
  32. package/es/locale/en_US.js +28 -0
  33. package/es/locale/es_ES.js +27 -0
  34. package/es/locale/et_EE.js +27 -0
  35. package/es/locale/fa_IR.js +27 -0
  36. package/es/locale/fi_FI.js +27 -0
  37. package/es/locale/fr_BE.js +27 -0
  38. package/es/locale/fr_FR.js +27 -0
  39. package/es/locale/he_IL.js +28 -0
  40. package/es/locale/hi_IN.js +28 -0
  41. package/es/locale/hr_HR.js +28 -0
  42. package/es/locale/hu_HU.js +27 -0
  43. package/es/locale/id_ID.js +28 -0
  44. package/es/locale/is_IS.js +27 -0
  45. package/es/locale/it_IT.js +27 -0
  46. package/es/locale/ja_JP.js +26 -0
  47. package/es/locale/kn_IN.js +28 -0
  48. package/es/locale/ko_KR.js +27 -0
  49. package/es/locale/ku_IQ.js +27 -0
  50. package/es/locale/lv_LV.js +27 -0
  51. package/es/locale/mm_MM.js +28 -0
  52. package/es/locale/mn_MN.js +28 -0
  53. package/es/locale/ms_MY.js +27 -0
  54. package/es/locale/nb_NO.js +27 -0
  55. package/es/locale/nl_BE.js +27 -0
  56. package/es/locale/nl_NL.js +27 -0
  57. package/es/locale/pl_PL.js +27 -0
  58. package/es/locale/pt_BR.js +27 -0
  59. package/es/locale/pt_PT.js +27 -0
  60. package/es/locale/ro_RO.js +28 -0
  61. package/es/locale/ru_RU.js +27 -0
  62. package/es/locale/sk_SK.js +27 -0
  63. package/es/locale/sl_SI.js +27 -0
  64. package/es/locale/sr_RS.js +27 -0
  65. package/es/locale/sv_SE.js +27 -0
  66. package/es/locale/ta_IN.js +28 -0
  67. package/es/locale/th_TH.js +27 -0
  68. package/es/locale/tr_TR.js +27 -0
  69. package/es/locale/ug_CN.js +26 -0
  70. package/es/locale/uk_UA.js +27 -0
  71. package/es/locale/vi_VN.js +28 -0
  72. package/es/locale/zh_CN.js +27 -0
  73. package/es/locale/zh_TW.js +26 -0
  74. package/es/mixin/CalendarMixin.js +123 -0
  75. package/es/mixin/CommonMixin.js +85 -0
  76. package/es/month/MonthPanel.js +154 -0
  77. package/es/month/MonthTable.js +156 -0
  78. package/es/picker/placements.js +35 -0
  79. package/es/range-calendar/CalendarPart.js +151 -0
  80. package/es/util/dayjs.js +17 -0
  81. package/es/util/index.js +545 -0
  82. package/es/util/toTime.js +21 -0
  83. package/es/year/YearPanel.js +194 -0
  84. package/lib/Calendar.js +514 -0
  85. package/lib/FullCalendar.js +221 -0
  86. package/lib/MonthCalendar.js +172 -0
  87. package/lib/Picker.js +283 -0
  88. package/lib/RangeCalendar.js +925 -0
  89. package/lib/calendar/CalendarFooter.js +134 -0
  90. package/lib/calendar/CalendarHeader.js +290 -0
  91. package/lib/calendar/CalendarRightPanel.js +151 -0
  92. package/lib/calendar/OkButton.js +32 -0
  93. package/lib/calendar/TimePickerButton.js +41 -0
  94. package/lib/calendar/TodayButton.js +39 -0
  95. package/lib/date/DateConstants.js +23 -0
  96. package/lib/date/DateInput.js +248 -0
  97. package/lib/date/DateTBody.js +317 -0
  98. package/lib/date/DateTHead.js +106 -0
  99. package/lib/date/DateTable.js +54 -0
  100. package/lib/decade/DecadePanel.js +207 -0
  101. package/lib/full-calendar/CalendarHeader.js +201 -0
  102. package/lib/index.js +12 -0
  103. package/lib/locale/ar_EG.js +31 -0
  104. package/lib/locale/bg_BG.js +31 -0
  105. package/lib/locale/ca_ES.js +31 -0
  106. package/lib/locale/cs_CZ.js +31 -0
  107. package/lib/locale/da_DK.js +31 -0
  108. package/lib/locale/de_DE.js +31 -0
  109. package/lib/locale/el_GR.js +31 -0
  110. package/lib/locale/en_GB.js +31 -0
  111. package/lib/locale/en_US.js +32 -0
  112. package/lib/locale/es_ES.js +31 -0
  113. package/lib/locale/et_EE.js +31 -0
  114. package/lib/locale/fa_IR.js +31 -0
  115. package/lib/locale/fi_FI.js +31 -0
  116. package/lib/locale/fr_BE.js +31 -0
  117. package/lib/locale/fr_FR.js +31 -0
  118. package/lib/locale/he_IL.js +32 -0
  119. package/lib/locale/hi_IN.js +32 -0
  120. package/lib/locale/hr_HR.js +32 -0
  121. package/lib/locale/hu_HU.js +31 -0
  122. package/lib/locale/id_ID.js +32 -0
  123. package/lib/locale/is_IS.js +31 -0
  124. package/lib/locale/it_IT.js +31 -0
  125. package/lib/locale/ja_JP.js +30 -0
  126. package/lib/locale/kn_IN.js +32 -0
  127. package/lib/locale/ko_KR.js +31 -0
  128. package/lib/locale/ku_IQ.js +31 -0
  129. package/lib/locale/lv_LV.js +31 -0
  130. package/lib/locale/mm_MM.js +32 -0
  131. package/lib/locale/mn_MN.js +32 -0
  132. package/lib/locale/ms_MY.js +31 -0
  133. package/lib/locale/nb_NO.js +31 -0
  134. package/lib/locale/nl_BE.js +31 -0
  135. package/lib/locale/nl_NL.js +31 -0
  136. package/lib/locale/pl_PL.js +31 -0
  137. package/lib/locale/pt_BR.js +31 -0
  138. package/lib/locale/pt_PT.js +31 -0
  139. package/lib/locale/ro_RO.js +32 -0
  140. package/lib/locale/ru_RU.js +31 -0
  141. package/lib/locale/sk_SK.js +31 -0
  142. package/lib/locale/sl_SI.js +31 -0
  143. package/lib/locale/sr_RS.js +31 -0
  144. package/lib/locale/sv_SE.js +31 -0
  145. package/lib/locale/ta_IN.js +32 -0
  146. package/lib/locale/th_TH.js +31 -0
  147. package/lib/locale/tr_TR.js +31 -0
  148. package/lib/locale/ug_CN.js +30 -0
  149. package/lib/locale/uk_UA.js +31 -0
  150. package/lib/locale/vi_VN.js +32 -0
  151. package/lib/locale/zh_CN.js +31 -0
  152. package/lib/locale/zh_TW.js +30 -0
  153. package/lib/mixin/CalendarMixin.js +153 -0
  154. package/lib/mixin/CommonMixin.js +106 -0
  155. package/lib/month/MonthPanel.js +179 -0
  156. package/lib/month/MonthTable.js +181 -0
  157. package/lib/picker/placements.js +39 -0
  158. package/lib/range-calendar/CalendarPart.js +184 -0
  159. package/lib/util/dayjs.js +46 -0
  160. package/lib/util/index.js +580 -0
  161. package/lib/util/toTime.js +28 -0
  162. package/lib/year/YearPanel.js +219 -0
  163. package/package.json +1 -1
package/es/Calendar.js ADDED
@@ -0,0 +1,451 @@
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 ReactDOM from 'react-dom';
7
+ import PropTypes from 'prop-types';
8
+ import KeyCode from 'rc-util/es/KeyCode';
9
+ import { polyfill } from 'react-lifecycles-compat';
10
+ import dayjs from 'dayjs';
11
+ import DateTable from './date/DateTable';
12
+ import CalendarHeader from './calendar/CalendarHeader';
13
+ import CalendarFooter from './calendar/CalendarFooter';
14
+ import CalendarRightPanel from './calendar/CalendarRightPanel';
15
+ import { calendarMixinWrapper, calendarMixinPropTypes, calendarMixinDefaultProps, getNowByCurrentStateValue } from './mixin/CalendarMixin';
16
+ import { commonMixinWrapper, propType, defaultProp } from './mixin/CommonMixin';
17
+ import DateInput from './date/DateInput';
18
+ import { getTimeConfig, getTodayTime, syncTime } from './util';
19
+ import { goStartMonth, goEndMonth, goTime } from './util/toTime';
20
+ import localeData from 'dayjs/plugin/localeData';
21
+ import utc from 'dayjs/plugin/utc';
22
+ import weekOfYear from 'dayjs/plugin/weekOfYear';
23
+ dayjs.extend(utc);
24
+ dayjs.extend(localeData);
25
+ dayjs.extend(weekOfYear);
26
+
27
+ function noop() {}
28
+
29
+ var getMomentObjectIfValid = function getMomentObjectIfValid(date) {
30
+ if (dayjs.isDayjs(date) && date.isValid()) {
31
+ return date;
32
+ }
33
+ return false;
34
+ };
35
+
36
+ var Calendar = function (_React$Component) {
37
+ _inherits(Calendar, _React$Component);
38
+
39
+ function Calendar(props) {
40
+ _classCallCheck(this, Calendar);
41
+
42
+ var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
43
+
44
+ _initialiseProps.call(_this);
45
+
46
+ _this.state = {
47
+ mode: _this.props.mode || 'date',
48
+ value: getMomentObjectIfValid(props.value) || getMomentObjectIfValid(props.defaultValue) || dayjs(),
49
+ selectedValue: props.selectedValue || props.defaultSelectedValue,
50
+ currentStatus: 0
51
+ };
52
+ return _this;
53
+ }
54
+
55
+ Calendar.prototype.componentDidMount = function componentDidMount() {
56
+ if (this.props.showDateInput) {
57
+ this.saveFocusElement(DateInput.getInstance());
58
+ }
59
+ };
60
+
61
+ Calendar.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, state) {
62
+ var value = nextProps.value,
63
+ selectedValue = nextProps.selectedValue;
64
+
65
+ var newState = {};
66
+
67
+ if ('mode' in nextProps && state.mode !== nextProps.mode) {
68
+ newState = { mode: nextProps.mode };
69
+ }
70
+ if ('value' in nextProps) {
71
+ newState.value = getMomentObjectIfValid(value) || getMomentObjectIfValid(nextProps.defaultValue) || getNowByCurrentStateValue(state.value);
72
+ }
73
+ if ('selectedValue' in nextProps) {
74
+ newState.selectedValue = selectedValue;
75
+ }
76
+
77
+ return newState;
78
+ };
79
+
80
+ Calendar.prototype.render = function render() {
81
+ var props = this.props,
82
+ state = this.state;
83
+ var locale = props.locale,
84
+ prefixCls = props.prefixCls,
85
+ disabledDate = props.disabledDate,
86
+ dateInputPlaceholder = props.dateInputPlaceholder,
87
+ timePicker = props.timePicker,
88
+ onClickRightPanelTime = props.onClickRightPanelTime,
89
+ disabledTime = props.disabledTime,
90
+ clearIcon = props.clearIcon,
91
+ renderFooter = props.renderFooter,
92
+ inputMode = props.inputMode,
93
+ showHourAndMinute = props.showHourAndMinute,
94
+ firstDayOfWeek = props.firstDayOfWeek,
95
+ showWeekNumber = props.showWeekNumber,
96
+ shouldDisplayCurrent = props.shouldDisplayCurrent;
97
+ var value = state.value,
98
+ selectedValue = state.selectedValue,
99
+ mode = state.mode,
100
+ currentStatus = state.currentStatus;
101
+
102
+ var showTimePicker = mode === 'time';
103
+ var disabledTimeConfig = showTimePicker && disabledTime && timePicker ? getTimeConfig(selectedValue, disabledTime) : null;
104
+
105
+ var timePickerEle = null;
106
+
107
+ if (timePicker && showTimePicker) {
108
+ var timePickerProps = _extends({
109
+ showHour: true,
110
+ showSecond: true,
111
+ showMinute: true
112
+ }, timePicker.props, disabledTimeConfig, {
113
+ onChange: this.onDateInputChange,
114
+ value: selectedValue,
115
+ disabledTime: disabledTime
116
+ });
117
+
118
+ if (timePicker.props.defaultValue !== undefined) {
119
+ timePickerProps.defaultOpenValue = timePicker.props.defaultValue;
120
+ }
121
+
122
+ timePickerEle = React.cloneElement(timePicker, timePickerProps);
123
+ }
124
+ var calendarInputPlaceholder = dateInputPlaceholder || (Array.isArray(this.getFormat()) ? this.getFormat()[0] : this.getFormat());
125
+
126
+ var dateInputElement = props.showDateInput ? React.createElement(DateInput, {
127
+ format: this.getFormat(),
128
+ key: 'date-input',
129
+ value: value,
130
+ locale: locale,
131
+ placeholder: calendarInputPlaceholder,
132
+ showClear: true,
133
+ shouldDisplayCurrent: shouldDisplayCurrent,
134
+ disabledTime: disabledTime,
135
+ disabledDate: disabledDate,
136
+ onClear: this.onClear,
137
+ prefixCls: prefixCls,
138
+ selectedValue: selectedValue,
139
+ onChange: this.onDateInputChange,
140
+ onSelect: this.onDateInputSelect,
141
+ clearIcon: clearIcon,
142
+ inputMode: inputMode
143
+ }) : null;
144
+
145
+ var children = [];
146
+ if (props.renderSidebar) {
147
+ children.push(props.renderSidebar());
148
+ }
149
+ children.push(React.createElement(
150
+ 'div',
151
+ { className: prefixCls + '-panel', key: 'panel' },
152
+ dateInputElement,
153
+ React.createElement(
154
+ 'div',
155
+ { className: prefixCls + '-date-panel-container' },
156
+ React.createElement(
157
+ 'div',
158
+ {
159
+ tabIndex: this.props.focusablePanel ? 0 : undefined,
160
+ className: prefixCls + '-date-panel'
161
+ },
162
+ React.createElement(CalendarHeader, {
163
+ locale: locale,
164
+ mode: mode,
165
+ value: value,
166
+ onValueChange: this.setValue,
167
+ onPanelChange: this.onPanelChange,
168
+ renderFooter: renderFooter,
169
+ showTimePicker: showTimePicker,
170
+ prefixCls: prefixCls
171
+ }),
172
+ timePicker && showTimePicker ? React.createElement(
173
+ 'div',
174
+ { className: prefixCls + '-time-picker' },
175
+ React.createElement(
176
+ 'div',
177
+ { className: prefixCls + '-time-picker-panel' },
178
+ timePickerEle
179
+ )
180
+ ) : null,
181
+ React.createElement(
182
+ 'div',
183
+ { className: prefixCls + '-body' },
184
+ React.createElement(DateTable, {
185
+ locale: locale,
186
+ value: value,
187
+ selectedValue: selectedValue,
188
+ prefixCls: prefixCls,
189
+ dateRender: props.dateRender,
190
+ onSelect: this.onDateTableSelect,
191
+ disabledDate: disabledDate,
192
+ showWeekNumber: showWeekNumber,
193
+ firstDayOfWeek: firstDayOfWeek,
194
+ currentStatus: currentStatus
195
+ })
196
+ ),
197
+ React.createElement(CalendarFooter, {
198
+ showOk: props.showOk,
199
+ mode: mode,
200
+ renderFooter: props.renderFooter,
201
+ locale: locale,
202
+ prefixCls: prefixCls,
203
+ showToday: props.showToday,
204
+ disabledTime: disabledTime,
205
+ showTimePicker: showTimePicker,
206
+ showDateInput: props.showDateInput,
207
+ timePicker: timePicker,
208
+ selectedValue: selectedValue,
209
+ value: value,
210
+ disabledDate: disabledDate,
211
+ okDisabled: props.showOk !== false && (!selectedValue || !this.isAllowedDate(selectedValue)),
212
+ onOk: this.onOk,
213
+ onSelect: this.onSelect,
214
+ onToday: this.onToday,
215
+ onOpenTimePicker: this.openTimePicker,
216
+ onCloseTimePicker: this.closeTimePicker
217
+ })
218
+ ),
219
+ showHourAndMinute && React.createElement(CalendarRightPanel, {
220
+ prefixCls: prefixCls,
221
+ value: value,
222
+ locale: locale,
223
+ onSelect: this.onDateTableSelect,
224
+ onClickRightPanelTime: onClickRightPanelTime,
225
+ defaultMinutesTime: this.props.defaultMinutesTime,
226
+ format: this.getFormat()
227
+ })
228
+ )
229
+ ));
230
+
231
+ return this.renderRoot({
232
+ children: children,
233
+ className: props.showWeekNumber ? prefixCls + '-week-number' : ''
234
+ });
235
+ };
236
+
237
+ return Calendar;
238
+ }(React.Component);
239
+
240
+ Calendar.propTypes = _extends({}, calendarMixinPropTypes, propType, {
241
+ prefixCls: PropTypes.string,
242
+ className: PropTypes.string,
243
+ style: PropTypes.object,
244
+ defaultValue: PropTypes.object,
245
+ value: PropTypes.object,
246
+ selectedValue: PropTypes.object,
247
+ defaultSelectedValue: PropTypes.object,
248
+ mode: PropTypes.oneOf(['time', 'date', 'month', 'year', 'decade']),
249
+ locale: PropTypes.object,
250
+ showDateInput: PropTypes.bool,
251
+ showWeekNumber: PropTypes.bool,
252
+ showToday: PropTypes.bool,
253
+ showOk: PropTypes.bool,
254
+ showHourAndMinute: PropTypes.bool,
255
+ defaultMinutesTime: PropTypes.string,
256
+ onSelect: PropTypes.func,
257
+ onOk: PropTypes.func,
258
+ onKeyDown: PropTypes.func,
259
+ timePicker: PropTypes.element,
260
+ dateInputPlaceholder: PropTypes.any,
261
+ onClear: PropTypes.func,
262
+ onChange: PropTypes.func,
263
+ onPanelChange: PropTypes.func,
264
+ disabledDate: PropTypes.func,
265
+ disabledTime: PropTypes.any,
266
+ dateRender: PropTypes.func,
267
+ renderFooter: PropTypes.func,
268
+ renderSidebar: PropTypes.func,
269
+ clearIcon: PropTypes.node,
270
+ focusablePanel: PropTypes.bool,
271
+ inputMode: PropTypes.string,
272
+ onBlur: PropTypes.func,
273
+ onClickRightPanelTime: PropTypes.func,
274
+ firstDayOfWeek: PropTypes.string,
275
+ shouldDisplayCurrent: PropTypes.bool
276
+ });
277
+ Calendar.defaultProps = _extends({}, calendarMixinDefaultProps, defaultProp, {
278
+ showToday: true,
279
+ showDateInput: true,
280
+ showHourAndMinute: false,
281
+ timePicker: null,
282
+ onOk: noop,
283
+ onPanelChange: noop,
284
+ onClickRightPanelTime: noop,
285
+ focusablePanel: true,
286
+ firstDayOfWeek: 'Sunday'
287
+ });
288
+
289
+ var _initialiseProps = function _initialiseProps() {
290
+ var _this2 = this;
291
+
292
+ this.onPanelChange = function (value, mode) {
293
+ var props = _this2.props,
294
+ state = _this2.state;
295
+
296
+ if (!('mode' in props)) {
297
+ _this2.setState({ mode: mode });
298
+ }
299
+ props.onPanelChange(value || state.value, mode);
300
+ };
301
+
302
+ this.onKeyDown = function (event) {
303
+ if (event.target.nodeName.toLowerCase() === 'input') {
304
+ return undefined;
305
+ }
306
+ var keyCode = event.keyCode;
307
+ // mac
308
+ var ctrlKey = event.ctrlKey || event.metaKey;
309
+ var disabledDate = _this2.props.disabledDate;
310
+ var value = _this2.state.value;
311
+
312
+ switch (keyCode) {
313
+ case KeyCode.DOWN:
314
+ _this2.goTime(1, 'weeks');
315
+ event.preventDefault();
316
+ return 1;
317
+ case KeyCode.UP:
318
+ _this2.goTime(-1, 'weeks');
319
+ event.preventDefault();
320
+ return 1;
321
+ case KeyCode.LEFT:
322
+ if (ctrlKey) {
323
+ _this2.goTime(-1, 'years');
324
+ } else {
325
+ _this2.goTime(-1, 'days');
326
+ }
327
+ event.preventDefault();
328
+ return 1;
329
+ case KeyCode.RIGHT:
330
+ if (ctrlKey) {
331
+ _this2.goTime(1, 'years');
332
+ } else {
333
+ _this2.goTime(1, 'days');
334
+ }
335
+ event.preventDefault();
336
+ return 1;
337
+ case KeyCode.HOME:
338
+ _this2.setValue(goStartMonth(_this2.state.value));
339
+ event.preventDefault();
340
+ return 1;
341
+ case KeyCode.END:
342
+ _this2.setValue(goEndMonth(_this2.state.value));
343
+ event.preventDefault();
344
+ return 1;
345
+ case KeyCode.PAGE_DOWN:
346
+ _this2.goTime(1, 'month');
347
+ event.preventDefault();
348
+ return 1;
349
+ case KeyCode.PAGE_UP:
350
+ _this2.goTime(-1, 'month');
351
+ event.preventDefault();
352
+ return 1;
353
+ case KeyCode.ENTER:
354
+ if (!disabledDate || !disabledDate(value)) {
355
+ _this2.onSelect(value, {
356
+ source: 'keyboard'
357
+ });
358
+ }
359
+ event.preventDefault();
360
+ return 1;
361
+ default:
362
+ _this2.props.onKeyDown(event);
363
+ return 1;
364
+ }
365
+ };
366
+
367
+ this.onClear = function () {
368
+ _this2.onSelect(null);
369
+ _this2.props.onClear();
370
+ _this2.setState({ currentStatus: 1 });
371
+ };
372
+
373
+ this.onOk = function () {
374
+ var selectedValue = _this2.state.selectedValue;
375
+
376
+ if (_this2.isAllowedDate(selectedValue)) {
377
+ _this2.props.onOk(selectedValue);
378
+ }
379
+ };
380
+
381
+ this.onDateInputChange = function (value) {
382
+ _this2.onSelect(value, {
383
+ source: 'dateInput'
384
+ });
385
+ };
386
+
387
+ this.onDateInputSelect = function (value) {
388
+ _this2.onSelect(value, {
389
+ source: 'dateInputSelect'
390
+ });
391
+ };
392
+
393
+ this.onDateTableSelect = function (value) {
394
+ var timePicker = _this2.props.timePicker;
395
+ var selectedValue = _this2.state.selectedValue;
396
+
397
+ _this2.setState({ currentStatus: 0 });
398
+ if (!selectedValue && timePicker) {
399
+ var timePickerDefaultValue = timePicker.props.defaultValue;
400
+ if (timePickerDefaultValue) {
401
+ syncTime(timePickerDefaultValue, value);
402
+ }
403
+ }
404
+ _this2.onSelect(value);
405
+ };
406
+
407
+ this.onToday = function () {
408
+ var value = _this2.state.value;
409
+
410
+ var now = getTodayTime(value);
411
+ _this2.onSelect(now, {
412
+ source: 'todayButton'
413
+ });
414
+ };
415
+
416
+ this.onBlur = function (event) {
417
+ setTimeout(function () {
418
+ var dateInput = DateInput.getInstance();
419
+ var rootInstance = _this2.rootInstance;
420
+
421
+ if (!rootInstance || rootInstance.contains(document.activeElement) || dateInput && dateInput.contains(document.activeElement)) {
422
+ // focused element is still part of Calendar
423
+ return;
424
+ }
425
+
426
+ if (_this2.props.onBlur) {
427
+ _this2.props.onBlur(event);
428
+ }
429
+ }, 0);
430
+ };
431
+
432
+ this.getRootDOMNode = function () {
433
+ return ReactDOM.findDOMNode(_this2);
434
+ };
435
+
436
+ this.openTimePicker = function () {
437
+ _this2.onPanelChange(null, 'time');
438
+ };
439
+
440
+ this.closeTimePicker = function () {
441
+ _this2.onPanelChange(null, 'date');
442
+ };
443
+
444
+ this.goTime = function (direction, unit) {
445
+ _this2.setValue(goTime(_this2.state.value, direction, unit));
446
+ };
447
+ };
448
+
449
+ polyfill(Calendar);
450
+
451
+ export default calendarMixinWrapper(commonMixinWrapper(Calendar));
@@ -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));