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

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