@seafile/seafile-calendar 0.0.13 → 0.0.17

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