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