@seafile/seafile-calendar 0.0.30-beta.1 → 0.0.30-beta.3

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 (167) hide show
  1. package/assets/index.css +1177 -0
  2. package/dist/rc-calendar.css +1179 -0
  3. package/dist/rc-calendar.css.map +1 -0
  4. package/dist/rc-calendar.js +7500 -0
  5. package/dist/rc-calendar.js.map +1 -0
  6. package/dist/rc-calendar.min.css +1179 -0
  7. package/dist/rc-calendar.min.css.map +1 -0
  8. package/dist/rc-calendar.min.js +1 -0
  9. package/es/Calendar.js +454 -0
  10. package/es/FullCalendar.js +182 -0
  11. package/es/MonthCalendar.js +135 -0
  12. package/es/Picker.js +245 -0
  13. package/es/RangeCalendar.js +876 -0
  14. package/es/calendar/CalendarFooter.js +93 -0
  15. package/es/calendar/CalendarHeader.js +257 -0
  16. package/es/calendar/CalendarRightPanel.js +135 -0
  17. package/es/calendar/OkButton.js +22 -0
  18. package/es/calendar/TimePickerButton.js +28 -0
  19. package/es/calendar/TodayButton.js +28 -0
  20. package/es/date/DateConstants.js +19 -0
  21. package/es/date/DateInput.js +444 -0
  22. package/es/date/DateTBody.js +280 -0
  23. package/es/date/DateTHead.js +86 -0
  24. package/es/date/DateTable.js +32 -0
  25. package/es/decade/DecadePanel.js +181 -0
  26. package/es/full-calendar/CalendarHeader.js +180 -0
  27. package/es/index.js +3 -0
  28. package/es/locale/ar_EG.js +27 -0
  29. package/es/locale/bg_BG.js +27 -0
  30. package/es/locale/ca_ES.js +27 -0
  31. package/es/locale/cs_CZ.js +27 -0
  32. package/es/locale/da_DK.js +27 -0
  33. package/es/locale/de_DE.js +27 -0
  34. package/es/locale/el_GR.js +27 -0
  35. package/es/locale/en_GB.js +27 -0
  36. package/es/locale/en_US.js +28 -0
  37. package/es/locale/es_ES.js +27 -0
  38. package/es/locale/et_EE.js +27 -0
  39. package/es/locale/fa_IR.js +27 -0
  40. package/es/locale/fi_FI.js +27 -0
  41. package/es/locale/fr_BE.js +27 -0
  42. package/es/locale/fr_FR.js +27 -0
  43. package/es/locale/he_IL.js +28 -0
  44. package/es/locale/hi_IN.js +28 -0
  45. package/es/locale/hr_HR.js +28 -0
  46. package/es/locale/hu_HU.js +27 -0
  47. package/es/locale/id_ID.js +28 -0
  48. package/es/locale/is_IS.js +27 -0
  49. package/es/locale/it_IT.js +27 -0
  50. package/es/locale/ja_JP.js +26 -0
  51. package/es/locale/kn_IN.js +28 -0
  52. package/es/locale/ko_KR.js +27 -0
  53. package/es/locale/ku_IQ.js +27 -0
  54. package/es/locale/lv_LV.js +27 -0
  55. package/es/locale/mm_MM.js +28 -0
  56. package/es/locale/mn_MN.js +28 -0
  57. package/es/locale/ms_MY.js +27 -0
  58. package/es/locale/nb_NO.js +27 -0
  59. package/es/locale/nl_BE.js +27 -0
  60. package/es/locale/nl_NL.js +27 -0
  61. package/es/locale/pl_PL.js +27 -0
  62. package/es/locale/pt_BR.js +27 -0
  63. package/es/locale/pt_PT.js +27 -0
  64. package/es/locale/ro_RO.js +28 -0
  65. package/es/locale/ru_RU.js +27 -0
  66. package/es/locale/sk_SK.js +27 -0
  67. package/es/locale/sl_SI.js +27 -0
  68. package/es/locale/sr_RS.js +27 -0
  69. package/es/locale/sv_SE.js +27 -0
  70. package/es/locale/ta_IN.js +28 -0
  71. package/es/locale/th_TH.js +27 -0
  72. package/es/locale/tr_TR.js +27 -0
  73. package/es/locale/ug_CN.js +26 -0
  74. package/es/locale/uk_UA.js +27 -0
  75. package/es/locale/vi_VN.js +28 -0
  76. package/es/locale/zh_CN.js +27 -0
  77. package/es/locale/zh_TW.js +26 -0
  78. package/es/mixin/CalendarMixin.js +123 -0
  79. package/es/mixin/CommonMixin.js +85 -0
  80. package/es/month/MonthPanel.js +154 -0
  81. package/es/month/MonthTable.js +156 -0
  82. package/es/picker/placements.js +35 -0
  83. package/es/range-calendar/CalendarPart.js +151 -0
  84. package/es/util/dayjs.js +17 -0
  85. package/es/util/index.js +272 -0
  86. package/es/util/toTime.js +21 -0
  87. package/es/year/YearPanel.js +194 -0
  88. package/lib/Calendar.js +517 -0
  89. package/lib/FullCalendar.js +221 -0
  90. package/lib/MonthCalendar.js +172 -0
  91. package/lib/Picker.js +282 -0
  92. package/lib/RangeCalendar.js +925 -0
  93. package/lib/calendar/CalendarFooter.js +134 -0
  94. package/lib/calendar/CalendarHeader.js +290 -0
  95. package/lib/calendar/CalendarRightPanel.js +160 -0
  96. package/lib/calendar/OkButton.js +32 -0
  97. package/lib/calendar/TimePickerButton.js +41 -0
  98. package/lib/calendar/TodayButton.js +39 -0
  99. package/lib/date/DateConstants.js +23 -0
  100. package/lib/date/DateInput.js +476 -0
  101. package/lib/date/DateTBody.js +307 -0
  102. package/lib/date/DateTHead.js +106 -0
  103. package/lib/date/DateTable.js +54 -0
  104. package/lib/decade/DecadePanel.js +207 -0
  105. package/lib/full-calendar/CalendarHeader.js +201 -0
  106. package/lib/index.js +12 -0
  107. package/lib/locale/ar_EG.js +31 -0
  108. package/lib/locale/bg_BG.js +31 -0
  109. package/lib/locale/ca_ES.js +31 -0
  110. package/lib/locale/cs_CZ.js +31 -0
  111. package/lib/locale/da_DK.js +31 -0
  112. package/lib/locale/de_DE.js +31 -0
  113. package/lib/locale/el_GR.js +31 -0
  114. package/lib/locale/en_GB.js +31 -0
  115. package/lib/locale/en_US.js +32 -0
  116. package/lib/locale/es_ES.js +31 -0
  117. package/lib/locale/et_EE.js +31 -0
  118. package/lib/locale/fa_IR.js +31 -0
  119. package/lib/locale/fi_FI.js +31 -0
  120. package/lib/locale/fr_BE.js +31 -0
  121. package/lib/locale/fr_FR.js +31 -0
  122. package/lib/locale/he_IL.js +32 -0
  123. package/lib/locale/hi_IN.js +32 -0
  124. package/lib/locale/hr_HR.js +32 -0
  125. package/lib/locale/hu_HU.js +31 -0
  126. package/lib/locale/id_ID.js +32 -0
  127. package/lib/locale/is_IS.js +31 -0
  128. package/lib/locale/it_IT.js +31 -0
  129. package/lib/locale/ja_JP.js +30 -0
  130. package/lib/locale/kn_IN.js +32 -0
  131. package/lib/locale/ko_KR.js +31 -0
  132. package/lib/locale/ku_IQ.js +31 -0
  133. package/lib/locale/lv_LV.js +31 -0
  134. package/lib/locale/mm_MM.js +32 -0
  135. package/lib/locale/mn_MN.js +32 -0
  136. package/lib/locale/ms_MY.js +31 -0
  137. package/lib/locale/nb_NO.js +31 -0
  138. package/lib/locale/nl_BE.js +31 -0
  139. package/lib/locale/nl_NL.js +31 -0
  140. package/lib/locale/pl_PL.js +31 -0
  141. package/lib/locale/pt_BR.js +31 -0
  142. package/lib/locale/pt_PT.js +31 -0
  143. package/lib/locale/ro_RO.js +32 -0
  144. package/lib/locale/ru_RU.js +31 -0
  145. package/lib/locale/sk_SK.js +31 -0
  146. package/lib/locale/sl_SI.js +31 -0
  147. package/lib/locale/sr_RS.js +31 -0
  148. package/lib/locale/sv_SE.js +31 -0
  149. package/lib/locale/ta_IN.js +32 -0
  150. package/lib/locale/th_TH.js +31 -0
  151. package/lib/locale/tr_TR.js +31 -0
  152. package/lib/locale/ug_CN.js +30 -0
  153. package/lib/locale/uk_UA.js +31 -0
  154. package/lib/locale/vi_VN.js +32 -0
  155. package/lib/locale/zh_CN.js +31 -0
  156. package/lib/locale/zh_TW.js +30 -0
  157. package/lib/mixin/CalendarMixin.js +153 -0
  158. package/lib/mixin/CommonMixin.js +106 -0
  159. package/lib/month/MonthPanel.js +179 -0
  160. package/lib/month/MonthTable.js +181 -0
  161. package/lib/picker/placements.js +39 -0
  162. package/lib/range-calendar/CalendarPart.js +184 -0
  163. package/lib/util/dayjs.js +46 -0
  164. package/lib/util/index.js +307 -0
  165. package/lib/util/toTime.js +28 -0
  166. package/lib/year/YearPanel.js +219 -0
  167. package/package.json +2 -1
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ exports.__esModule = true;
4
+
5
+ var _dayjs = require('dayjs');
6
+
7
+ var _dayjs2 = _interopRequireDefault(_dayjs);
8
+
9
+ var _localeData = require('dayjs/plugin/localeData');
10
+
11
+ var _localeData2 = _interopRequireDefault(_localeData);
12
+
13
+ var _weekOfYear = require('dayjs/plugin/weekOfYear');
14
+
15
+ var _weekOfYear2 = _interopRequireDefault(_weekOfYear);
16
+
17
+ var _utc = require('dayjs/plugin/utc');
18
+
19
+ var _utc2 = _interopRequireDefault(_utc);
20
+
21
+ var _advancedFormat = require('dayjs/plugin/advancedFormat');
22
+
23
+ var _advancedFormat2 = _interopRequireDefault(_advancedFormat);
24
+
25
+ var _customParseFormat = require('dayjs/plugin/customParseFormat');
26
+
27
+ var _customParseFormat2 = _interopRequireDefault(_customParseFormat);
28
+
29
+ var _badMutable = require('dayjs/plugin/badMutable');
30
+
31
+ var _badMutable2 = _interopRequireDefault(_badMutable);
32
+
33
+ require('dayjs/locale/zh-cn');
34
+
35
+ require('dayjs/locale/en-gb');
36
+
37
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
38
+
39
+ _dayjs2['default'].extend(_localeData2['default']);
40
+ _dayjs2['default'].extend(_weekOfYear2['default']);
41
+ _dayjs2['default'].extend(_utc2['default']);
42
+ _dayjs2['default'].extend(_advancedFormat2['default']);
43
+ _dayjs2['default'].extend(_customParseFormat2['default']);
44
+ _dayjs2['default'].extend(_badMutable2['default']);
45
+ exports['default'] = _dayjs2['default'];
46
+ module.exports = exports['default'];
@@ -0,0 +1,307 @@
1
+ 'use strict';
2
+
3
+ exports.__esModule = true;
4
+ exports.DATE_FORMATS = exports.currentTime = exports.stringCurrentMonth = exports.stringCurrentDate = exports.nowTime = exports.currentYear = exports.currentMonth = exports.currentDate = undefined;
5
+
6
+ var _extends2 = require('babel-runtime/helpers/extends');
7
+
8
+ var _extends3 = _interopRequireDefault(_extends2);
9
+
10
+ exports.getTodayTime = getTodayTime;
11
+ exports.getTitleString = getTitleString;
12
+ exports.getTodayTimeStr = getTodayTimeStr;
13
+ exports.getMonthName = getMonthName;
14
+ exports.syncTime = syncTime;
15
+ exports.getTimeConfig = getTimeConfig;
16
+ exports.isTimeValidByConfig = isTimeValidByConfig;
17
+ exports.isTimeValid = isTimeValid;
18
+ exports.isAllowedDate = isAllowedDate;
19
+ exports.formatDate = formatDate;
20
+ exports.formatDateLocal = formatDateLocal;
21
+ exports.hasSpecialChar = hasSpecialChar;
22
+ exports.isValidMonth = isValidMonth;
23
+ exports.isValidDay = isValidDay;
24
+ exports.fullValidYear = fullValidYear;
25
+ exports.delimate = delimate;
26
+ exports.getDateFormatByStr = getDateFormatByStr;
27
+ exports.isCurrentYear = isCurrentYear;
28
+ exports.validateTime = validateTime;
29
+
30
+ var _dayjs = require('dayjs');
31
+
32
+ var _dayjs2 = _interopRequireDefault(_dayjs);
33
+
34
+ var _utc = require('dayjs/plugin/utc');
35
+
36
+ var _utc2 = _interopRequireDefault(_utc);
37
+
38
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
39
+
40
+ _dayjs2['default'].extend(_utc2['default']);
41
+ var currentDate = exports.currentDate = (0, _dayjs2['default'])().date();
42
+ var currentMonth = exports.currentMonth = (0, _dayjs2['default'])().month() + 1;
43
+ var currentYear = exports.currentYear = (0, _dayjs2['default'])().year();
44
+ var nowTime = exports.nowTime = (0, _dayjs2['default'])().format('HH:mm');
45
+ var stringCurrentDate = exports.stringCurrentDate = String(currentDate).padStart(2, '0');
46
+ var stringCurrentMonth = exports.stringCurrentMonth = String(currentMonth).padStart(2, '0');
47
+ var currentTime = exports.currentTime = (0, _dayjs2['default'])().format('HH:mm');
48
+
49
+ var DATE_FORMATS = exports.DATE_FORMATS = {
50
+ ISO: 'YYYY-MM-DD',
51
+ ISOAndTime: 'YYYY-MM-DD HH:mm',
52
+ US: 'M/D/YYYY',
53
+ USAndTime: 'M/D/YYYY HH:mm',
54
+ European: 'DD/MM/YYYY',
55
+ EuropeanAndTime: 'DD/MM/YYYY HH:mm',
56
+ Germany_Russia_etc: 'DD.MM.YYYY',
57
+ Germany_Russia_etcAndTime: 'DD.MM.YYYY HH:mm'
58
+ };
59
+
60
+ var defaultDisabledTime = {
61
+ disabledHours: function disabledHours() {
62
+ return [];
63
+ },
64
+ disabledMinutes: function disabledMinutes() {
65
+ return [];
66
+ },
67
+ disabledSeconds: function disabledSeconds() {
68
+ return [];
69
+ }
70
+ };
71
+
72
+ function getTodayTime(value) {
73
+ var today = (0, _dayjs2['default'])();
74
+ today = today.locale(value.locale()).utcOffset(value.utcOffset());
75
+ return today;
76
+ }
77
+
78
+ function getTitleString(value) {
79
+ return value.format('LL');
80
+ }
81
+
82
+ function getTodayTimeStr(value) {
83
+ var today = getTodayTime(value);
84
+ return getTitleString(today);
85
+ }
86
+
87
+ function getMonthName(month) {
88
+ var locale = month.locale();
89
+ var localeData = month.localeData();
90
+ return localeData[locale === 'zh-cn' ? 'months' : 'monthsShort'](month);
91
+ }
92
+
93
+ function syncTime(from, to) {
94
+ if (!_dayjs2['default'].isDayjs(from) || !_dayjs2['default'].isDayjs(to)) return;
95
+ to = to.hour(from.hour());
96
+ to = to.minute(from.minute());
97
+ to = to.second(from.second());
98
+ to = to.millisecond(from.millisecond());
99
+ }
100
+
101
+ function getTimeConfig(value, disabledTime) {
102
+ var disabledTimeConfig = disabledTime ? disabledTime(value) : {};
103
+ disabledTimeConfig = (0, _extends3['default'])({}, defaultDisabledTime, disabledTimeConfig);
104
+ return disabledTimeConfig;
105
+ }
106
+
107
+ function isTimeValidByConfig(value, disabledTimeConfig) {
108
+ var invalidTime = false;
109
+ if (value) {
110
+ var hour = value.hour();
111
+ var minutes = value.minute();
112
+ var seconds = value.second();
113
+ var disabledHours = disabledTimeConfig.disabledHours();
114
+ if (disabledHours.indexOf(hour) === -1) {
115
+ var disabledMinutes = disabledTimeConfig.disabledMinutes(hour);
116
+ if (disabledMinutes.indexOf(minutes) === -1) {
117
+ var disabledSeconds = disabledTimeConfig.disabledSeconds(hour, minutes);
118
+ invalidTime = disabledSeconds.indexOf(seconds) !== -1;
119
+ } else {
120
+ invalidTime = true;
121
+ }
122
+ } else {
123
+ invalidTime = true;
124
+ }
125
+ }
126
+ return !invalidTime;
127
+ }
128
+
129
+ function isTimeValid(value, disabledTime) {
130
+ var disabledTimeConfig = getTimeConfig(value, disabledTime);
131
+ return isTimeValidByConfig(value, disabledTimeConfig);
132
+ }
133
+
134
+ function isAllowedDate(value, disabledDate, disabledTime) {
135
+ if (disabledDate) {
136
+ if (disabledDate(value)) {
137
+ return false;
138
+ }
139
+ }
140
+ if (disabledTime) {
141
+ if (!isTimeValid(value, disabledTime)) {
142
+ return false;
143
+ }
144
+ }
145
+ return true;
146
+ }
147
+
148
+ function formatDate(value, format) {
149
+ if (!value) {
150
+ return '';
151
+ }
152
+
153
+ if (Array.isArray(format)) {
154
+ format = format[0];
155
+ }
156
+
157
+ return value.format(format);
158
+ }
159
+
160
+ function formatDateLocal(formatStr, format) {
161
+ var str = formatStr || '';
162
+ var cleanStr = void 0;
163
+ switch (format) {
164
+ case DATE_FORMATS.ISO:
165
+ case DATE_FORMATS.ISOAndTime:
166
+ cleanStr = str.replace(/[^0-9]+/g, '-');
167
+ return cleanStr.split('-').filter(Boolean).map(String);
168
+ case DATE_FORMATS.US:
169
+ case DATE_FORMATS.USAndTime:
170
+ case DATE_FORMATS.European:
171
+ case DATE_FORMATS.EuropeanAndTime:
172
+ cleanStr = str.replace(/[^0-9]+/g, '/');
173
+ return cleanStr.split('/').filter(Boolean).map(String);
174
+ case DATE_FORMATS.Germany_Russia_etc:
175
+ case DATE_FORMATS.Germany_Russia_etcAndTime:
176
+ cleanStr = str.replace(/[^0-9]+/g, '.');
177
+ return cleanStr.split('.').filter(Boolean).map(String);
178
+ default:
179
+ return [];
180
+ }
181
+ }
182
+
183
+ function hasSpecialChar(str) {
184
+ var matches = str.match(/[^0-9]/g);
185
+ return matches ? matches.length : 0;
186
+ }
187
+
188
+ function isValidMonth(monthStr) {
189
+ if (typeof monthStr === 'undefined' || monthStr === null) return currentMonth;
190
+ if (!/^\d+$/.test(Number(monthStr))) return currentMonth;
191
+ var month = Number(monthStr);
192
+ if (month >= 1 && month <= 12) {
193
+ return monthStr;
194
+ }
195
+ return currentMonth;
196
+ }
197
+
198
+ function isValidDay(dayStr) {
199
+ if (!/^\d+$/.test(dayStr)) return false;
200
+ var day = Number(dayStr);
201
+ if ([1, 3, 5, 7, 8, 10, 12].includes(currentMonth)) {
202
+ return day >= 1 && day <= 31;
203
+ }
204
+ if ([4, 6, 9, 11].includes(currentMonth)) {
205
+ return day >= 1 && day <= 30;
206
+ }
207
+ if (currentMonth === 2) {
208
+ var isLeapYear = function isLeapYear(year) {
209
+ return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
210
+ };
211
+ var year = currentYear;
212
+ if (isLeapYear(year)) {
213
+ return day >= 1 && day <= 29;
214
+ }
215
+ return day >= 1 && day <= 28;
216
+ }
217
+ }
218
+
219
+ function fullValidYear(yearStr) {
220
+ var year = yearStr;
221
+ if (!year || isNaN(year)) return currentYear;
222
+ if (year.length === 2) {
223
+ if (Number(year) >= 0 && Number(year) < 69) {
224
+ return year ? '20' + year : currentYear;
225
+ } else if (Number(year) >= 69 && Number(year) < 100) {
226
+ return year ? '19' + year : currentYear;
227
+ }
228
+ }
229
+ if (year.length === 4) {
230
+ return year;
231
+ }
232
+ return year ? year.padStart(4, '0') : currentYear;
233
+ }
234
+
235
+ function delimate(formatPrefix) {
236
+ var delimiter = void 0;
237
+ if (formatPrefix === DATE_FORMATS.Germany_Russia_etc || formatPrefix === DATE_FORMATS.Germany_Russia_etcAndTime) {
238
+ delimiter = '.';
239
+ } else if (formatPrefix === DATE_FORMATS.ISO || formatPrefix === DATE_FORMATS.ISOAndTime) {
240
+ delimiter = '-';
241
+ } else {
242
+ delimiter = '/';
243
+ }
244
+ return delimiter;
245
+ }
246
+
247
+ function getDateFormatByStr(str, format) {
248
+ var cananderStr = str || '';
249
+ var delimiter = delimate(format);
250
+ var parts = cananderStr.split(delimiter);
251
+ if (parts.length !== 3) return format;
252
+ if (format === DATE_FORMATS.ISO) {
253
+ return DATE_FORMATS.ISO;
254
+ }
255
+ if (format === DATE_FORMATS.ISOAndTime) {
256
+ return DATE_FORMATS.ISOAndTime;
257
+ }
258
+ if (format === DATE_FORMATS.US) {
259
+ return DATE_FORMATS.US;
260
+ }
261
+ if (format === DATE_FORMATS.USAndTime) {
262
+ return DATE_FORMATS.USAndTime;
263
+ }
264
+ if (format === DATE_FORMATS.European || format === DATE_FORMATS.Germany_Russia_etc || format === DATE_FORMATS.Germany_Russia_etcAndTime || format === DATE_FORMATS.EuropeanAndTime) {
265
+ var day = parts[0],
266
+ month = parts[1];
267
+
268
+ var dayLen = day.length;
269
+ var monthLen = month.length;
270
+ if (dayLen === 2 && monthLen === 2) {
271
+ return 'DD' + delimiter + 'MM' + delimiter + 'YYYY HH:mm';
272
+ } else if (dayLen === 2 && monthLen === 1) {
273
+ return 'DD' + delimiter + 'M' + delimiter + 'YYYY HH:mm';
274
+ } else if (dayLen === 1 && monthLen === 2) {
275
+ return 'D' + delimiter + 'MM' + delimiter + 'YYYY HH:mm';
276
+ } else if (dayLen === 1 && monthLen === 1) {
277
+ return 'D' + delimiter + 'M' + delimiter + 'YYYY HH:mm';
278
+ }
279
+ }
280
+ return format;
281
+ }
282
+
283
+ function isCurrentYear(year, month, day) {
284
+ return Number(month) >= 1 && Number(month) <= 12 && Number(day) >= 1 && Number(day) <= 31 ? year : currentYear; // eslint-disable-line max-len
285
+ }
286
+
287
+ function validateTime(inputTime) {
288
+ if (!inputTime || typeof inputTime !== 'string') {
289
+ return currentTime;
290
+ }
291
+ var trimmedInput = inputTime.trim();
292
+ var timeRegex = /^([0-1]?[0-9]|2[0-3]):([0-5][0-9])$/;
293
+
294
+ if (!timeRegex.test(trimmedInput)) {
295
+ return currentTime;
296
+ }
297
+
298
+ var _trimmedInput$split$m = trimmedInput.split(':').map(Number),
299
+ hours = _trimmedInput$split$m[0],
300
+ minutes = _trimmedInput$split$m[1];
301
+
302
+ var parsedTime = (0, _dayjs2['default'])().hour(hours).minute(minutes);
303
+ if (!parsedTime.isValid()) {
304
+ return currentTime;
305
+ }
306
+ return parsedTime.format('HH:mm');
307
+ }
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ exports.__esModule = true;
4
+ exports.goStartMonth = goStartMonth;
5
+ exports.goEndMonth = goEndMonth;
6
+ exports.goTime = goTime;
7
+ exports.includesTime = includesTime;
8
+ function goStartMonth(time) {
9
+ return time.clone().startOf('month');
10
+ }
11
+
12
+ function goEndMonth(time) {
13
+ return time.clone().endOf('month');
14
+ }
15
+
16
+ function goTime(time, direction, unit) {
17
+ return time.clone().add(direction, unit);
18
+ }
19
+
20
+ function includesTime() {
21
+ var timeList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
22
+ var time = arguments[1];
23
+ var unit = arguments[2];
24
+
25
+ return timeList.some(function (t) {
26
+ return t.isSame(time, unit);
27
+ });
28
+ }
@@ -0,0 +1,219 @@
1
+ 'use strict';
2
+
3
+ exports.__esModule = true;
4
+
5
+ var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
6
+
7
+ var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
8
+
9
+ var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
10
+
11
+ var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
12
+
13
+ var _inherits2 = require('babel-runtime/helpers/inherits');
14
+
15
+ var _inherits3 = _interopRequireDefault(_inherits2);
16
+
17
+ var _react = require('react');
18
+
19
+ var _react2 = _interopRequireDefault(_react);
20
+
21
+ var _propTypes = require('prop-types');
22
+
23
+ var _propTypes2 = _interopRequireDefault(_propTypes);
24
+
25
+ var _classnames = require('classnames');
26
+
27
+ var _classnames2 = _interopRequireDefault(_classnames);
28
+
29
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
30
+
31
+ var ROW = 4;
32
+ var COL = 3;
33
+
34
+ function goYear(direction) {
35
+ var value = this.state.value.clone();
36
+ value = value.add(direction, 'year');
37
+ this.setState({
38
+ value: value
39
+ });
40
+ }
41
+
42
+ function chooseYear(year) {
43
+ var value = this.state.value.clone();
44
+ value = value.year(year);
45
+ value = value.month(this.state.value.month());
46
+ this.setState({
47
+ value: value
48
+ });
49
+ this.props.onSelect(value);
50
+ }
51
+
52
+ var YearPanel = function (_React$Component) {
53
+ (0, _inherits3['default'])(YearPanel, _React$Component);
54
+
55
+ function YearPanel(props) {
56
+ (0, _classCallCheck3['default'])(this, YearPanel);
57
+
58
+ var _this = (0, _possibleConstructorReturn3['default'])(this, _React$Component.call(this, props));
59
+
60
+ _this.prefixCls = props.rootPrefixCls + '-year-panel';
61
+ _this.state = {
62
+ value: props.value || props.defaultValue
63
+ };
64
+ _this.nextDecade = goYear.bind(_this, 10);
65
+ _this.previousDecade = goYear.bind(_this, -10);
66
+ return _this;
67
+ }
68
+
69
+ YearPanel.prototype.years = function years() {
70
+ var value = this.state.value;
71
+ var currentYear = value.year();
72
+ var startYear = parseInt(currentYear / 10, 10) * 10;
73
+ var previousYear = startYear - 1;
74
+ var years = [];
75
+ var index = 0;
76
+ for (var rowIndex = 0; rowIndex < ROW; rowIndex++) {
77
+ years[rowIndex] = [];
78
+ for (var colIndex = 0; colIndex < COL; colIndex++) {
79
+ var year = previousYear + index;
80
+ var content = String(year);
81
+ years[rowIndex][colIndex] = {
82
+ content: content,
83
+ year: year,
84
+ title: content
85
+ };
86
+ index++;
87
+ }
88
+ }
89
+ return years;
90
+ };
91
+
92
+ YearPanel.prototype.render = function render() {
93
+ var _this2 = this;
94
+
95
+ var props = this.props;
96
+ var value = this.state.value;
97
+ var locale = props.locale,
98
+ renderFooter = props.renderFooter;
99
+
100
+ var years = this.years();
101
+ var currentYear = value.year();
102
+ var startYear = parseInt(currentYear / 10, 10) * 10;
103
+ var endYear = startYear + 9;
104
+ var prefixCls = this.prefixCls;
105
+
106
+ var yeasEls = years.map(function (row, index) {
107
+ var tds = row.map(function (yearData) {
108
+ var _classNameMap;
109
+
110
+ var classNameMap = (_classNameMap = {}, _classNameMap[prefixCls + '-cell'] = 1, _classNameMap[prefixCls + '-selected-cell'] = yearData.year === currentYear, _classNameMap);
111
+ return _react2['default'].createElement(
112
+ 'td',
113
+ {
114
+ role: 'gridcell',
115
+ title: yearData.title,
116
+ key: yearData.content,
117
+ onClick: chooseYear.bind(_this2, yearData.year),
118
+ className: (0, _classnames2['default'])(classNameMap)
119
+ },
120
+ _react2['default'].createElement(
121
+ 'a',
122
+ {
123
+ className: prefixCls + '-year'
124
+ },
125
+ yearData.content
126
+ )
127
+ );
128
+ });
129
+ return _react2['default'].createElement(
130
+ 'tr',
131
+ { key: index, role: 'row' },
132
+ tds
133
+ );
134
+ });
135
+
136
+ var footer = renderFooter && renderFooter('year');
137
+
138
+ return _react2['default'].createElement(
139
+ 'div',
140
+ { className: this.prefixCls },
141
+ _react2['default'].createElement(
142
+ 'div',
143
+ null,
144
+ _react2['default'].createElement(
145
+ 'div',
146
+ { className: prefixCls + '-header' },
147
+ _react2['default'].createElement('a', {
148
+ className: prefixCls + '-prev-decade-btn',
149
+ role: 'button',
150
+ onClick: this.previousDecade,
151
+ title: locale.previousDecade
152
+ }),
153
+ _react2['default'].createElement(
154
+ 'a',
155
+ {
156
+ className: prefixCls + '-decade-select',
157
+ role: 'button',
158
+ onClick: props.onDecadePanelShow,
159
+ title: locale.decadeSelect
160
+ },
161
+ _react2['default'].createElement(
162
+ 'span',
163
+ { className: prefixCls + '-decade-select-content' },
164
+ startYear,
165
+ '-',
166
+ endYear
167
+ ),
168
+ _react2['default'].createElement(
169
+ 'span',
170
+ { className: prefixCls + '-decade-select-arrow' },
171
+ 'x'
172
+ )
173
+ ),
174
+ _react2['default'].createElement('a', {
175
+ className: prefixCls + '-next-decade-btn',
176
+ role: 'button',
177
+ onClick: this.nextDecade,
178
+ title: locale.nextDecade
179
+ })
180
+ ),
181
+ _react2['default'].createElement(
182
+ 'div',
183
+ { className: prefixCls + '-body' },
184
+ _react2['default'].createElement(
185
+ 'table',
186
+ { className: prefixCls + '-table', cellSpacing: '0', role: 'grid' },
187
+ _react2['default'].createElement(
188
+ 'tbody',
189
+ { className: prefixCls + '-tbody' },
190
+ yeasEls
191
+ )
192
+ )
193
+ ),
194
+ footer && _react2['default'].createElement(
195
+ 'div',
196
+ { className: prefixCls + '-footer' },
197
+ footer
198
+ )
199
+ )
200
+ );
201
+ };
202
+
203
+ return YearPanel;
204
+ }(_react2['default'].Component);
205
+
206
+ exports['default'] = YearPanel;
207
+
208
+
209
+ YearPanel.propTypes = {
210
+ rootPrefixCls: _propTypes2['default'].string,
211
+ value: _propTypes2['default'].object,
212
+ defaultValue: _propTypes2['default'].object,
213
+ renderFooter: _propTypes2['default'].func
214
+ };
215
+
216
+ YearPanel.defaultProps = {
217
+ onSelect: function onSelect() {}
218
+ };
219
+ module.exports = exports['default'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/seafile-calendar",
3
- "version": "0.0.30-beta.1",
3
+ "version": "0.0.30-beta.3",
4
4
  "description": "React Calendar",
5
5
  "keywords": [
6
6
  "react",
@@ -91,6 +91,7 @@
91
91
  "dependencies": {
92
92
  "babel-runtime": "6.x",
93
93
  "classnames": "2.x",
94
+ "core-js": "^2.6.12",
94
95
  "dayjs": "1.10.7",
95
96
  "prop-types": "^15.5.8",
96
97
  "rc-trigger": "^2.2.0",