@seafile/seafile-calendar 0.0.30-beta.2 → 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,280 @@
1
+ import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
2
+ import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
3
+ import _inherits from 'babel-runtime/helpers/inherits';
4
+ import React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import cx from 'classnames';
7
+ import DateConstants from './DateConstants';
8
+ import { getTitleString, getTodayTime } from '../util/';
9
+
10
+ var DATE_ROW_COLUMN_COUNT = DateConstants.DATE_ROW_COLUMN_COUNT,
11
+ DAY_NAME_TO_INDEX = DateConstants.DAY_NAME_TO_INDEX;
12
+
13
+
14
+ function isSameDay(one, two) {
15
+ return one && two && one.isSame(two, 'day');
16
+ }
17
+
18
+ function beforeCurrentMonthYear(current, today) {
19
+ if (current.year() < today.year()) {
20
+ return 1;
21
+ }
22
+ return current.year() === today.year() && current.month() < today.month();
23
+ }
24
+
25
+ function afterCurrentMonthYear(current, today) {
26
+ if (current.year() > today.year()) {
27
+ return 1;
28
+ }
29
+ return current.year() === today.year() && current.month() > today.month();
30
+ }
31
+
32
+ function getIdFromDate(date) {
33
+ return 'rc-calendar-' + date.year() + '-' + date.month() + '-' + date.date();
34
+ }
35
+
36
+ var DateTBody = function (_React$Component) {
37
+ _inherits(DateTBody, _React$Component);
38
+
39
+ function DateTBody() {
40
+ _classCallCheck(this, DateTBody);
41
+
42
+ return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
43
+ }
44
+
45
+ DateTBody.prototype.render = function render() {
46
+ var props = this.props;
47
+ var contentRender = props.contentRender,
48
+ prefixCls = props.prefixCls,
49
+ selectedValue = props.selectedValue,
50
+ value = props.value,
51
+ showWeekNumber = props.showWeekNumber,
52
+ dateRender = props.dateRender,
53
+ disabledDate = props.disabledDate,
54
+ hoverValue = props.hoverValue,
55
+ firstDayOfWeek = props.firstDayOfWeek;
56
+
57
+ var iIndex = void 0;
58
+ var jIndex = void 0;
59
+ var current = void 0;
60
+ var dateTable = [];
61
+ var today = getTodayTime(value);
62
+ var cellClass = prefixCls + '-cell';
63
+ var weekNumberCellClass = prefixCls + '-week-number-cell';
64
+ var dateClass = prefixCls + '-date';
65
+ var todayClass = prefixCls + '-today';
66
+ var selectedClass = prefixCls + '-selected-day';
67
+ var selectedDateClass = prefixCls + '-selected-date'; // do not move with mouse operation
68
+ var selectedStartDateClass = prefixCls + '-selected-start-date';
69
+ var selectedEndDateClass = prefixCls + '-selected-end-date';
70
+ var inRangeClass = prefixCls + '-in-range-cell';
71
+ var lastMonthDayClass = prefixCls + '-last-month-cell';
72
+ var nextMonthDayClass = prefixCls + '-next-month-btn-day';
73
+ var disabledClass = prefixCls + '-disabled-cell';
74
+ var firstDisableClass = prefixCls + '-disabled-cell-first-of-row';
75
+ var lastDisableClass = prefixCls + '-disabled-cell-last-of-row';
76
+ var lastDayOfMonthClass = prefixCls + '-last-day-of-month';
77
+ var month1 = value.clone();
78
+ month1 = month1.date(1);
79
+ var day = month1.day();
80
+ var firstDayName = typeof firstDayOfWeek === 'string' ? firstDayOfWeek[0].toUpperCase() + firstDayOfWeek.slice(1) : 'Sunday';
81
+ var firstDayIndex = DAY_NAME_TO_INDEX[firstDayName] ? DAY_NAME_TO_INDEX[firstDayName] : 0;
82
+ var lastMonthDiffDay = (day + 7 - firstDayIndex) % 7;
83
+ // calculate last month
84
+ var lastMonth1 = month1.clone();
85
+ lastMonth1 = lastMonth1.add(0 - lastMonthDiffDay, 'days');
86
+ var passed = 0;
87
+
88
+ for (iIndex = 0; iIndex < DATE_ROW_COLUMN_COUNT.DATE_ROW_COUNT; iIndex++) {
89
+ for (jIndex = 0; jIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT; jIndex++) {
90
+ current = lastMonth1;
91
+ if (passed) {
92
+ current = current.clone();
93
+ current = current.add(passed, 'days');
94
+ }
95
+ dateTable.push(current);
96
+ passed++;
97
+ }
98
+ }
99
+ var tableHtml = [];
100
+ passed = 0;
101
+
102
+ for (iIndex = 0; iIndex < DATE_ROW_COLUMN_COUNT.DATE_ROW_COUNT; iIndex++) {
103
+ var _cx;
104
+
105
+ var isCurrentWeek = void 0;
106
+ var weekNumberCell = void 0;
107
+ var isActiveWeek = false;
108
+ var dateCells = [];
109
+ if (showWeekNumber) {
110
+ weekNumberCell = React.createElement(
111
+ 'td',
112
+ {
113
+ key: dateTable[passed].week(),
114
+ role: 'gridcell',
115
+ className: weekNumberCellClass
116
+ },
117
+ dateTable[passed].week()
118
+ );
119
+ }
120
+ for (jIndex = 0; jIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT; jIndex++) {
121
+ var next = null;
122
+ var last = null;
123
+ current = dateTable[passed];
124
+ if (jIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT - 1) {
125
+ next = dateTable[passed + 1];
126
+ }
127
+ if (jIndex > 0) {
128
+ last = dateTable[passed - 1];
129
+ }
130
+ var cls = cellClass;
131
+ var disabled = false;
132
+ var selected = false;
133
+
134
+ if (isSameDay(current, today)) {
135
+ cls += ' ' + todayClass;
136
+ isCurrentWeek = true;
137
+ }
138
+
139
+ var isBeforeCurrentMonthYear = beforeCurrentMonthYear(current, value);
140
+ var isAfterCurrentMonthYear = afterCurrentMonthYear(current, value);
141
+
142
+ if (selectedValue && Array.isArray(selectedValue)) {
143
+ var rangeValue = hoverValue.length ? hoverValue : selectedValue;
144
+ if (!isBeforeCurrentMonthYear && !isAfterCurrentMonthYear) {
145
+ var startValue = rangeValue[0];
146
+ var endValue = rangeValue[1];
147
+ if (startValue) {
148
+ if (isSameDay(current, startValue)) {
149
+ selected = true;
150
+ isActiveWeek = true;
151
+ cls += ' ' + selectedStartDateClass;
152
+ }
153
+ }
154
+ if (startValue || endValue) {
155
+ if (isSameDay(current, endValue)) {
156
+ selected = true;
157
+ isActiveWeek = true;
158
+ cls += ' ' + selectedEndDateClass;
159
+ } else if ((startValue === null || startValue === undefined) && current.isBefore(endValue, 'day')) {
160
+ cls += ' ' + inRangeClass;
161
+ } else if ((endValue === null || endValue === undefined) && current.isAfter(startValue, 'day')) {
162
+ cls += ' ' + inRangeClass;
163
+ } else if (current.isAfter(startValue, 'day') && current.isBefore(endValue, 'day')) {
164
+ cls += ' ' + inRangeClass;
165
+ }
166
+ }
167
+ }
168
+ } else if (isSameDay(current, value)) {
169
+ // keyboard change value, highlight works
170
+ selected = true;
171
+ isActiveWeek = true;
172
+ }
173
+
174
+ if (isSameDay(current, selectedValue)) {
175
+ cls += ' ' + selectedDateClass;
176
+ }
177
+
178
+ if (isBeforeCurrentMonthYear) {
179
+ cls += ' ' + lastMonthDayClass;
180
+ }
181
+
182
+ if (isAfterCurrentMonthYear) {
183
+ cls += ' ' + nextMonthDayClass;
184
+ }
185
+
186
+ if (current.clone().endOf('month').date() === current.date()) {
187
+ cls += ' ' + lastDayOfMonthClass;
188
+ }
189
+
190
+ if (disabledDate) {
191
+ if (disabledDate(current, value)) {
192
+ disabled = true;
193
+
194
+ if (!last || !disabledDate(last, value)) {
195
+ cls += ' ' + firstDisableClass;
196
+ }
197
+
198
+ if (!next || !disabledDate(next, value)) {
199
+ cls += ' ' + lastDisableClass;
200
+ }
201
+ }
202
+ }
203
+
204
+ if (selected) {
205
+ cls += ' ' + selectedClass;
206
+ }
207
+
208
+ if (disabled) {
209
+ cls += ' ' + disabledClass;
210
+ }
211
+
212
+ var dateHtml = void 0;
213
+ if (dateRender) {
214
+ dateHtml = dateRender(current, value);
215
+ } else {
216
+ var content = contentRender ? contentRender(current, value) : current.date();
217
+ dateHtml = React.createElement(
218
+ 'div',
219
+ {
220
+ key: getIdFromDate(current),
221
+ className: dateClass,
222
+ 'aria-selected': selected,
223
+ 'aria-disabled': disabled
224
+ },
225
+ content
226
+ );
227
+ }
228
+
229
+ dateCells.push(React.createElement(
230
+ 'td',
231
+ {
232
+ key: passed,
233
+ onClick: disabled ? undefined : props.onSelect.bind(null, current),
234
+ onMouseEnter: disabled ? undefined : props.onDayHover && props.onDayHover.bind(null, current) || undefined,
235
+ role: 'gridcell',
236
+ title: getTitleString(current),
237
+ className: cls
238
+ },
239
+ dateHtml
240
+ ));
241
+
242
+ passed++;
243
+ }
244
+
245
+ tableHtml.push(React.createElement(
246
+ 'tr',
247
+ {
248
+ key: iIndex,
249
+ role: 'row',
250
+ className: cx((_cx = {}, _cx[prefixCls + '-current-week'] = isCurrentWeek, _cx[prefixCls + '-active-week'] = isActiveWeek, _cx))
251
+ },
252
+ weekNumberCell,
253
+ dateCells
254
+ ));
255
+ }
256
+ return React.createElement(
257
+ 'tbody',
258
+ { className: prefixCls + '-tbody' },
259
+ tableHtml
260
+ );
261
+ };
262
+
263
+ return DateTBody;
264
+ }(React.Component);
265
+
266
+ DateTBody.propTypes = {
267
+ contentRender: PropTypes.func,
268
+ dateRender: PropTypes.func,
269
+ disabledDate: PropTypes.func,
270
+ prefixCls: PropTypes.string,
271
+ selectedValue: PropTypes.oneOfType([PropTypes.object, PropTypes.arrayOf(PropTypes.object)]),
272
+ value: PropTypes.object,
273
+ hoverValue: PropTypes.any,
274
+ showWeekNumber: PropTypes.bool,
275
+ firstDayOfWeek: PropTypes.string
276
+ };
277
+ DateTBody.defaultProps = {
278
+ hoverValue: []
279
+ };
280
+ export default DateTBody;
@@ -0,0 +1,86 @@
1
+ import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
2
+ import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
3
+ import _inherits from 'babel-runtime/helpers/inherits';
4
+ import React from 'react';
5
+ import DateConstants from './DateConstants';
6
+
7
+ var DAY_NAME_TO_INDEX = DateConstants.DAY_NAME_TO_INDEX,
8
+ DATE_ROW_COLUMN_COUNT = DateConstants.DATE_ROW_COLUMN_COUNT;
9
+
10
+ var DateTHead = function (_React$Component) {
11
+ _inherits(DateTHead, _React$Component);
12
+
13
+ function DateTHead() {
14
+ _classCallCheck(this, DateTHead);
15
+
16
+ return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
17
+ }
18
+
19
+ DateTHead.prototype.render = function render() {
20
+ var props = this.props;
21
+ var value = props.value;
22
+ var localeData = value.localeData();
23
+ var prefixCls = props.prefixCls;
24
+ var veryShortWeekdays = [];
25
+ var weekDays = [];
26
+
27
+ var allWeekdaysMin = localeData.weekdaysMin();
28
+ var allWeekdaysShort = localeData.weekdaysShort();
29
+
30
+ var firstDayName = typeof props.firstDayOfWeek === 'string' ? props.firstDayOfWeek[0].toUpperCase() + props.firstDayOfWeek.slice(1) : 'Sunday';
31
+ var firstDay = DAY_NAME_TO_INDEX[firstDayName] ? DAY_NAME_TO_INDEX[firstDayName] : 0;
32
+
33
+ var showWeekNumberEl = void 0;
34
+ var dateColumnCount = DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT;
35
+ for (var dateColIndex = 0; dateColIndex < dateColumnCount; dateColIndex++) {
36
+ var index = (firstDay + dateColIndex) % dateColumnCount;
37
+ veryShortWeekdays[dateColIndex] = allWeekdaysMin[index];
38
+ weekDays[dateColIndex] = allWeekdaysShort[index];
39
+ }
40
+
41
+ if (props.showWeekNumber) {
42
+ showWeekNumberEl = React.createElement(
43
+ 'th',
44
+ {
45
+ role: 'columnheader',
46
+ className: prefixCls + '-column-header ' + prefixCls + '-week-number-header'
47
+ },
48
+ React.createElement(
49
+ 'span',
50
+ { className: prefixCls + '-column-header-inner' },
51
+ 'x'
52
+ )
53
+ );
54
+ }
55
+ var weekDaysEls = weekDays.map(function (day, xindex) {
56
+ return React.createElement(
57
+ 'th',
58
+ {
59
+ key: xindex,
60
+ role: 'columnheader',
61
+ title: day,
62
+ className: prefixCls + '-column-header'
63
+ },
64
+ React.createElement(
65
+ 'span',
66
+ { className: prefixCls + '-column-header-inner' },
67
+ veryShortWeekdays[xindex]
68
+ )
69
+ );
70
+ });
71
+ return React.createElement(
72
+ 'thead',
73
+ null,
74
+ React.createElement(
75
+ 'tr',
76
+ { role: 'row' },
77
+ showWeekNumberEl,
78
+ weekDaysEls
79
+ )
80
+ );
81
+ };
82
+
83
+ return DateTHead;
84
+ }(React.Component);
85
+
86
+ export default DateTHead;
@@ -0,0 +1,32 @@
1
+ import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
2
+ import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
3
+ import _inherits from 'babel-runtime/helpers/inherits';
4
+
5
+ import React from 'react';
6
+ import DateTHead from './DateTHead';
7
+ import DateTBody from './DateTBody';
8
+
9
+ var DateTable = function (_React$Component) {
10
+ _inherits(DateTable, _React$Component);
11
+
12
+ function DateTable() {
13
+ _classCallCheck(this, DateTable);
14
+
15
+ return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
16
+ }
17
+
18
+ DateTable.prototype.render = function render() {
19
+ var props = this.props;
20
+ var prefixCls = props.prefixCls;
21
+ return React.createElement(
22
+ 'table',
23
+ { className: prefixCls + '-table', cellSpacing: '0', role: 'grid' },
24
+ React.createElement(DateTHead, props),
25
+ React.createElement(DateTBody, props)
26
+ );
27
+ };
28
+
29
+ return DateTable;
30
+ }(React.Component);
31
+
32
+ export default DateTable;
@@ -0,0 +1,181 @@
1
+ import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
2
+ import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
3
+ import _inherits from 'babel-runtime/helpers/inherits';
4
+ import React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ var ROW = 4;
7
+ var COL = 3;
8
+ import classnames from 'classnames';
9
+
10
+ function goYear(direction) {
11
+ var next = this.state.value.clone();
12
+ next = next.add(direction, 'years');
13
+ this.setState({
14
+ value: next
15
+ });
16
+ }
17
+
18
+ function chooseDecade(year, event) {
19
+ var next = this.state.value.clone();
20
+ next = next.year(year);
21
+ next = next.month(this.state.value.month());
22
+ this.props.onSelect(next);
23
+ event.preventDefault();
24
+ }
25
+
26
+ var DecadePanel = function (_React$Component) {
27
+ _inherits(DecadePanel, _React$Component);
28
+
29
+ function DecadePanel(props) {
30
+ _classCallCheck(this, DecadePanel);
31
+
32
+ var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
33
+
34
+ _this.state = {
35
+ value: props.value || props.defaultValue
36
+ };
37
+
38
+ // bind methods
39
+ _this.prefixCls = props.rootPrefixCls + '-decade-panel';
40
+ _this.nextCentury = goYear.bind(_this, 100);
41
+ _this.previousCentury = goYear.bind(_this, -100);
42
+ return _this;
43
+ }
44
+
45
+ DecadePanel.prototype.render = function render() {
46
+ var _this2 = this;
47
+
48
+ var value = this.state.value;
49
+ var _props = this.props,
50
+ locale = _props.locale,
51
+ renderFooter = _props.renderFooter;
52
+
53
+ var currentYear = value.year();
54
+ var startYear = parseInt(currentYear / 100, 10) * 100;
55
+ var preYear = startYear - 10;
56
+ var endYear = startYear + 99;
57
+ var decades = [];
58
+ var index = 0;
59
+ var prefixCls = this.prefixCls;
60
+
61
+ for (var rowIndex = 0; rowIndex < ROW; rowIndex++) {
62
+ decades[rowIndex] = [];
63
+ for (var colIndex = 0; colIndex < COL; colIndex++) {
64
+ var startDecade = preYear + index * 10;
65
+ var endDecade = preYear + index * 10 + 9;
66
+ decades[rowIndex][colIndex] = {
67
+ startDecade: startDecade,
68
+ endDecade: endDecade
69
+ };
70
+ index++;
71
+ }
72
+ }
73
+
74
+ var footer = renderFooter && renderFooter('decade');
75
+
76
+ var decadesEls = decades.map(function (row, decadeIndex) {
77
+ var tds = row.map(function (decadeData) {
78
+ var _classNameMap;
79
+
80
+ var dStartDecade = decadeData.startDecade;
81
+ var dEndDecade = decadeData.endDecade;
82
+ var isLast = dStartDecade < startYear;
83
+ var isNext = dEndDecade > endYear;
84
+ var classNameMap = (_classNameMap = {}, _classNameMap[prefixCls + '-cell'] = 1, _classNameMap[prefixCls + '-selected-cell'] = dStartDecade <= currentYear && currentYear <= dEndDecade, _classNameMap[prefixCls + '-last-century-cell'] = isLast, _classNameMap[prefixCls + '-next-century-cell'] = isNext, _classNameMap);
85
+ var content = dStartDecade + '-' + dEndDecade;
86
+ var clickHandler = void 0;
87
+ if (isLast) {
88
+ clickHandler = _this2.previousCentury;
89
+ } else if (isNext) {
90
+ clickHandler = _this2.nextCentury;
91
+ } else {
92
+ clickHandler = chooseDecade.bind(_this2, dStartDecade);
93
+ }
94
+ return React.createElement(
95
+ 'td',
96
+ {
97
+ key: dStartDecade,
98
+ onClick: clickHandler,
99
+ role: 'gridcell',
100
+ className: classnames(classNameMap)
101
+ },
102
+ React.createElement(
103
+ 'a',
104
+ {
105
+ className: prefixCls + '-decade'
106
+ },
107
+ content
108
+ )
109
+ );
110
+ });
111
+ return React.createElement(
112
+ 'tr',
113
+ { key: decadeIndex, role: 'row' },
114
+ tds
115
+ );
116
+ });
117
+
118
+ return React.createElement(
119
+ 'div',
120
+ { className: this.prefixCls },
121
+ React.createElement(
122
+ 'div',
123
+ { className: prefixCls + '-header' },
124
+ React.createElement('a', {
125
+ className: prefixCls + '-prev-century-btn',
126
+ role: 'button',
127
+ onClick: this.previousCentury,
128
+ title: locale.previousCentury
129
+ }),
130
+ React.createElement(
131
+ 'div',
132
+ { className: prefixCls + '-century' },
133
+ startYear,
134
+ '-',
135
+ endYear
136
+ ),
137
+ React.createElement('a', {
138
+ className: prefixCls + '-next-century-btn',
139
+ role: 'button',
140
+ onClick: this.nextCentury,
141
+ title: locale.nextCentury
142
+ })
143
+ ),
144
+ React.createElement(
145
+ 'div',
146
+ { className: prefixCls + '-body' },
147
+ React.createElement(
148
+ 'table',
149
+ { className: prefixCls + '-table', cellSpacing: '0', role: 'grid' },
150
+ React.createElement(
151
+ 'tbody',
152
+ { className: prefixCls + '-tbody' },
153
+ decadesEls
154
+ )
155
+ )
156
+ ),
157
+ footer && React.createElement(
158
+ 'div',
159
+ { className: prefixCls + '-footer' },
160
+ footer
161
+ )
162
+ );
163
+ };
164
+
165
+ return DecadePanel;
166
+ }(React.Component);
167
+
168
+ export default DecadePanel;
169
+
170
+
171
+ DecadePanel.propTypes = {
172
+ locale: PropTypes.object,
173
+ value: PropTypes.object,
174
+ defaultValue: PropTypes.object,
175
+ rootPrefixCls: PropTypes.string,
176
+ renderFooter: PropTypes.func
177
+ };
178
+
179
+ DecadePanel.defaultProps = {
180
+ onSelect: function onSelect() {}
181
+ };