@seafile/seafile-calendar 0.0.12 → 0.0.16

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