@seafile/seafile-calendar 0.0.30 → 0.0.31-APloi0.2

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 (163) hide show
  1. package/assets/index.css +1177 -0
  2. package/dist/rc-calendar.js +72 -50
  3. package/dist/rc-calendar.js.map +1 -1
  4. package/dist/rc-calendar.min.js +1 -1
  5. package/es/Calendar.js +451 -0
  6. package/es/FullCalendar.js +182 -0
  7. package/es/MonthCalendar.js +135 -0
  8. package/es/Picker.js +246 -0
  9. package/es/RangeCalendar.js +876 -0
  10. package/es/calendar/CalendarFooter.js +93 -0
  11. package/es/calendar/CalendarHeader.js +257 -0
  12. package/es/calendar/CalendarRightPanel.js +126 -0
  13. package/es/calendar/OkButton.js +22 -0
  14. package/es/calendar/TimePickerButton.js +28 -0
  15. package/es/calendar/TodayButton.js +28 -0
  16. package/es/date/DateConstants.js +19 -0
  17. package/es/date/DateInput.js +215 -0
  18. package/es/date/DateTBody.js +287 -0
  19. package/es/date/DateTHead.js +86 -0
  20. package/es/date/DateTable.js +32 -0
  21. package/es/decade/DecadePanel.js +181 -0
  22. package/es/full-calendar/CalendarHeader.js +180 -0
  23. package/es/index.js +3 -0
  24. package/es/locale/ar_EG.js +27 -0
  25. package/es/locale/bg_BG.js +27 -0
  26. package/es/locale/ca_ES.js +27 -0
  27. package/es/locale/cs_CZ.js +27 -0
  28. package/es/locale/da_DK.js +27 -0
  29. package/es/locale/de_DE.js +27 -0
  30. package/es/locale/el_GR.js +27 -0
  31. package/es/locale/en_GB.js +27 -0
  32. package/es/locale/en_US.js +28 -0
  33. package/es/locale/es_ES.js +27 -0
  34. package/es/locale/et_EE.js +27 -0
  35. package/es/locale/fa_IR.js +27 -0
  36. package/es/locale/fi_FI.js +27 -0
  37. package/es/locale/fr_BE.js +27 -0
  38. package/es/locale/fr_FR.js +27 -0
  39. package/es/locale/he_IL.js +28 -0
  40. package/es/locale/hi_IN.js +28 -0
  41. package/es/locale/hr_HR.js +28 -0
  42. package/es/locale/hu_HU.js +27 -0
  43. package/es/locale/id_ID.js +28 -0
  44. package/es/locale/is_IS.js +27 -0
  45. package/es/locale/it_IT.js +27 -0
  46. package/es/locale/ja_JP.js +26 -0
  47. package/es/locale/kn_IN.js +28 -0
  48. package/es/locale/ko_KR.js +27 -0
  49. package/es/locale/ku_IQ.js +27 -0
  50. package/es/locale/lv_LV.js +27 -0
  51. package/es/locale/mm_MM.js +28 -0
  52. package/es/locale/mn_MN.js +28 -0
  53. package/es/locale/ms_MY.js +27 -0
  54. package/es/locale/nb_NO.js +27 -0
  55. package/es/locale/nl_BE.js +27 -0
  56. package/es/locale/nl_NL.js +27 -0
  57. package/es/locale/pl_PL.js +27 -0
  58. package/es/locale/pt_BR.js +27 -0
  59. package/es/locale/pt_PT.js +27 -0
  60. package/es/locale/ro_RO.js +28 -0
  61. package/es/locale/ru_RU.js +27 -0
  62. package/es/locale/sk_SK.js +27 -0
  63. package/es/locale/sl_SI.js +27 -0
  64. package/es/locale/sr_RS.js +27 -0
  65. package/es/locale/sv_SE.js +27 -0
  66. package/es/locale/ta_IN.js +28 -0
  67. package/es/locale/th_TH.js +27 -0
  68. package/es/locale/tr_TR.js +27 -0
  69. package/es/locale/ug_CN.js +26 -0
  70. package/es/locale/uk_UA.js +27 -0
  71. package/es/locale/vi_VN.js +28 -0
  72. package/es/locale/zh_CN.js +27 -0
  73. package/es/locale/zh_TW.js +26 -0
  74. package/es/mixin/CalendarMixin.js +123 -0
  75. package/es/mixin/CommonMixin.js +85 -0
  76. package/es/month/MonthPanel.js +154 -0
  77. package/es/month/MonthTable.js +156 -0
  78. package/es/picker/placements.js +35 -0
  79. package/es/range-calendar/CalendarPart.js +151 -0
  80. package/es/util/dayjs.js +17 -0
  81. package/es/util/index.js +545 -0
  82. package/es/util/toTime.js +21 -0
  83. package/es/year/YearPanel.js +194 -0
  84. package/lib/Calendar.js +514 -0
  85. package/lib/FullCalendar.js +221 -0
  86. package/lib/MonthCalendar.js +172 -0
  87. package/lib/Picker.js +283 -0
  88. package/lib/RangeCalendar.js +925 -0
  89. package/lib/calendar/CalendarFooter.js +134 -0
  90. package/lib/calendar/CalendarHeader.js +290 -0
  91. package/lib/calendar/CalendarRightPanel.js +151 -0
  92. package/lib/calendar/OkButton.js +32 -0
  93. package/lib/calendar/TimePickerButton.js +41 -0
  94. package/lib/calendar/TodayButton.js +39 -0
  95. package/lib/date/DateConstants.js +23 -0
  96. package/lib/date/DateInput.js +248 -0
  97. package/lib/date/DateTBody.js +317 -0
  98. package/lib/date/DateTHead.js +106 -0
  99. package/lib/date/DateTable.js +54 -0
  100. package/lib/decade/DecadePanel.js +207 -0
  101. package/lib/full-calendar/CalendarHeader.js +201 -0
  102. package/lib/index.js +12 -0
  103. package/lib/locale/ar_EG.js +31 -0
  104. package/lib/locale/bg_BG.js +31 -0
  105. package/lib/locale/ca_ES.js +31 -0
  106. package/lib/locale/cs_CZ.js +31 -0
  107. package/lib/locale/da_DK.js +31 -0
  108. package/lib/locale/de_DE.js +31 -0
  109. package/lib/locale/el_GR.js +31 -0
  110. package/lib/locale/en_GB.js +31 -0
  111. package/lib/locale/en_US.js +32 -0
  112. package/lib/locale/es_ES.js +31 -0
  113. package/lib/locale/et_EE.js +31 -0
  114. package/lib/locale/fa_IR.js +31 -0
  115. package/lib/locale/fi_FI.js +31 -0
  116. package/lib/locale/fr_BE.js +31 -0
  117. package/lib/locale/fr_FR.js +31 -0
  118. package/lib/locale/he_IL.js +32 -0
  119. package/lib/locale/hi_IN.js +32 -0
  120. package/lib/locale/hr_HR.js +32 -0
  121. package/lib/locale/hu_HU.js +31 -0
  122. package/lib/locale/id_ID.js +32 -0
  123. package/lib/locale/is_IS.js +31 -0
  124. package/lib/locale/it_IT.js +31 -0
  125. package/lib/locale/ja_JP.js +30 -0
  126. package/lib/locale/kn_IN.js +32 -0
  127. package/lib/locale/ko_KR.js +31 -0
  128. package/lib/locale/ku_IQ.js +31 -0
  129. package/lib/locale/lv_LV.js +31 -0
  130. package/lib/locale/mm_MM.js +32 -0
  131. package/lib/locale/mn_MN.js +32 -0
  132. package/lib/locale/ms_MY.js +31 -0
  133. package/lib/locale/nb_NO.js +31 -0
  134. package/lib/locale/nl_BE.js +31 -0
  135. package/lib/locale/nl_NL.js +31 -0
  136. package/lib/locale/pl_PL.js +31 -0
  137. package/lib/locale/pt_BR.js +31 -0
  138. package/lib/locale/pt_PT.js +31 -0
  139. package/lib/locale/ro_RO.js +32 -0
  140. package/lib/locale/ru_RU.js +31 -0
  141. package/lib/locale/sk_SK.js +31 -0
  142. package/lib/locale/sl_SI.js +31 -0
  143. package/lib/locale/sr_RS.js +31 -0
  144. package/lib/locale/sv_SE.js +31 -0
  145. package/lib/locale/ta_IN.js +32 -0
  146. package/lib/locale/th_TH.js +31 -0
  147. package/lib/locale/tr_TR.js +31 -0
  148. package/lib/locale/ug_CN.js +30 -0
  149. package/lib/locale/uk_UA.js +31 -0
  150. package/lib/locale/vi_VN.js +32 -0
  151. package/lib/locale/zh_CN.js +31 -0
  152. package/lib/locale/zh_TW.js +30 -0
  153. package/lib/mixin/CalendarMixin.js +153 -0
  154. package/lib/mixin/CommonMixin.js +106 -0
  155. package/lib/month/MonthPanel.js +179 -0
  156. package/lib/month/MonthTable.js +181 -0
  157. package/lib/picker/placements.js +39 -0
  158. package/lib/range-calendar/CalendarPart.js +184 -0
  159. package/lib/util/dayjs.js +46 -0
  160. package/lib/util/index.js +580 -0
  161. package/lib/util/toTime.js +28 -0
  162. package/lib/year/YearPanel.js +219 -0
  163. package/package.json +1 -1
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ var DATE_ROW_COLUMN_COUNT = {
5
+ DATE_ROW_COUNT: 6,
6
+ DATE_COL_COUNT: 7
7
+ };
8
+
9
+ var DAY_NAME_TO_INDEX = {
10
+ Sunday: 0,
11
+ Monday: 1,
12
+ Tuesday: 2,
13
+ Wednesday: 3,
14
+ Thursday: 4,
15
+ Friday: 5,
16
+ Saturday: 6
17
+ };
18
+
19
+ exports["default"] = {
20
+ DATE_ROW_COLUMN_COUNT: DATE_ROW_COLUMN_COUNT,
21
+ DAY_NAME_TO_INDEX: DAY_NAME_TO_INDEX
22
+ };
23
+ module.exports = exports['default'];
@@ -0,0 +1,248 @@
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 _reactDom = require('react-dom');
22
+
23
+ var _reactDom2 = _interopRequireDefault(_reactDom);
24
+
25
+ var _propTypes = require('prop-types');
26
+
27
+ var _propTypes2 = _interopRequireDefault(_propTypes);
28
+
29
+ var _KeyCode = require('rc-util/lib/KeyCode');
30
+
31
+ var _KeyCode2 = _interopRequireDefault(_KeyCode);
32
+
33
+ var _reactLifecyclesCompat = require('react-lifecycles-compat');
34
+
35
+ var _dayjs = require('dayjs');
36
+
37
+ var _dayjs2 = _interopRequireDefault(_dayjs);
38
+
39
+ var _util = require('../util');
40
+
41
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
42
+
43
+ var customParseFormat = require('dayjs/plugin/customParseFormat');
44
+
45
+ _dayjs2['default'].extend(customParseFormat);
46
+
47
+ var cachedSelectionStart = void 0;
48
+ var cachedSelectionEnd = void 0;
49
+ var dateInputInstance = void 0;
50
+
51
+ var DateInput = function (_React$Component) {
52
+ (0, _inherits3['default'])(DateInput, _React$Component);
53
+
54
+ function DateInput(props) {
55
+ (0, _classCallCheck3['default'])(this, DateInput);
56
+
57
+ var _this = (0, _possibleConstructorReturn3['default'])(this, _React$Component.call(this, props));
58
+
59
+ _initialiseProps.call(_this);
60
+
61
+ var selectedValue = props.selectedValue;
62
+
63
+ _this.state = {
64
+ str: (0, _util.formatDate)(selectedValue, _this.props.format),
65
+ hasFocus: false,
66
+ localFormat: _this.props.format[0]
67
+ };
68
+ return _this;
69
+ }
70
+
71
+ DateInput.prototype.componentDidUpdate = function componentDidUpdate() {
72
+ if (dateInputInstance && this.state.hasFocus && !(cachedSelectionStart === 0 && cachedSelectionEnd === 0)) {
73
+ dateInputInstance.setSelectionRange(cachedSelectionStart, cachedSelectionEnd);
74
+ }
75
+ };
76
+
77
+ DateInput.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, state) {
78
+ var newState = {};
79
+
80
+ if (dateInputInstance) {
81
+ cachedSelectionStart = dateInputInstance.selectionStart;
82
+ cachedSelectionEnd = dateInputInstance.selectionEnd;
83
+ }
84
+ // when popup show, click body will call this, bug!
85
+ var selectedValue = nextProps.selectedValue;
86
+ if (!state.hasFocus) {
87
+ newState = { str: (0, _util.formatDate)(selectedValue, nextProps.format) };
88
+ }
89
+
90
+ return newState;
91
+ };
92
+
93
+ DateInput.getInstance = function getInstance() {
94
+ return dateInputInstance;
95
+ };
96
+
97
+ DateInput.prototype.render = function render() {
98
+ var props = this.props;
99
+ var str = this.state.str;
100
+ var locale = props.locale,
101
+ prefixCls = props.prefixCls,
102
+ placeholder = props.placeholder,
103
+ clearIcon = props.clearIcon,
104
+ inputMode = props.inputMode;
105
+
106
+ return _react2['default'].createElement(
107
+ 'div',
108
+ { className: prefixCls + '-input-wrap' },
109
+ _react2['default'].createElement(
110
+ 'div',
111
+ { className: prefixCls + '-date-input-wrap' },
112
+ _react2['default'].createElement('input', {
113
+ ref: this.saveDateInput,
114
+ className: prefixCls + '-input',
115
+ value: str,
116
+ disabled: props.disabled,
117
+ placeholder: placeholder,
118
+ onChange: this.onInputChange,
119
+ onKeyDown: this.onKeyDown,
120
+ onFocus: this.onFocus,
121
+ onBlur: this.onBlur,
122
+ inputMode: inputMode
123
+ })
124
+ ),
125
+ props.showClear ? _react2['default'].createElement(
126
+ 'a',
127
+ {
128
+ role: 'button',
129
+ title: locale.clear,
130
+ onClick: this.onClear
131
+ },
132
+ clearIcon || _react2['default'].createElement('span', { className: prefixCls + '-clear-btn' })
133
+ ) : null
134
+ );
135
+ };
136
+
137
+ return DateInput;
138
+ }(_react2['default'].Component);
139
+
140
+ DateInput.propTypes = {
141
+ prefixCls: _propTypes2['default'].string,
142
+ timePicker: _propTypes2['default'].object,
143
+ value: _propTypes2['default'].object,
144
+ disabledTime: _propTypes2['default'].any,
145
+ format: _propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].arrayOf(_propTypes2['default'].string)]),
146
+ locale: _propTypes2['default'].object,
147
+ disabledDate: _propTypes2['default'].func,
148
+ onChange: _propTypes2['default'].func,
149
+ onClear: _propTypes2['default'].func,
150
+ placeholder: _propTypes2['default'].string,
151
+ onSelect: _propTypes2['default'].func,
152
+ selectedValue: _propTypes2['default'].object,
153
+ clearIcon: _propTypes2['default'].node,
154
+ inputMode: _propTypes2['default'].string,
155
+ shouldDisplayCurrent: _propTypes2['default'].bool
156
+ };
157
+
158
+ var _initialiseProps = function _initialiseProps() {
159
+ var _this2 = this;
160
+
161
+ this.onClear = function () {
162
+ _this2.setState({ str: '' });
163
+ _this2.props.onClear(null);
164
+ };
165
+
166
+ this.onInputChange = function (event) {
167
+ var str = event.target.value;
168
+ var calendarStr = (0, _util.initializeStr)(str, _this2.state.localFormat) || '';
169
+ var _props = _this2.props,
170
+ disabledDate = _props.disabledDate,
171
+ format = _props.format,
172
+ onChange = _props.onChange,
173
+ selectedValue = _props.selectedValue,
174
+ shouldDisplayCurrent = _props.shouldDisplayCurrent;
175
+ // 没有内容,合法并直接退出
176
+
177
+ if (!str || !calendarStr) {
178
+ if (shouldDisplayCurrent) {
179
+ _this2.setState({ str: '' });
180
+ onChange((0, _dayjs2['default'])());
181
+ } else {
182
+ _this2.onClear();
183
+ }
184
+ return;
185
+ }
186
+ var parsed = (0, _dayjs2['default'])(calendarStr, format[0]);
187
+ var value = _this2.props.value.clone();
188
+ value = value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
189
+
190
+ if (!value || disabledDate && disabledDate(value)) {
191
+ _this2.setState({ str: str });
192
+ return;
193
+ }
194
+
195
+ if (selectedValue !== value || selectedValue && value && !selectedValue.isSame(value)) {
196
+ _this2.setState({ str: str });
197
+ onChange(value);
198
+ }
199
+ };
200
+
201
+ this.onFocus = function () {
202
+ _this2.setState({ hasFocus: true });
203
+ };
204
+
205
+ this.onBlur = function () {
206
+ _this2.setState(function (prevState, prevProps) {
207
+ return {
208
+ hasFocus: false,
209
+ str: (0, _util.formatDate)(prevProps.value, prevProps.format)
210
+ };
211
+ });
212
+ };
213
+
214
+ this.onKeyDown = function (event) {
215
+ var keyCode = event.keyCode;
216
+ var _props2 = _this2.props,
217
+ onSelect = _props2.onSelect,
218
+ value = _props2.value,
219
+ disabledDate = _props2.disabledDate;
220
+
221
+ if (keyCode === _KeyCode2['default'].ENTER && onSelect) {
222
+ var validateDate = !disabledDate || !disabledDate(value);
223
+ if (validateDate) {
224
+ onSelect(value.clone());
225
+ }
226
+ event.preventDefault();
227
+ }
228
+ };
229
+
230
+ this.getRootDOMNode = function () {
231
+ return _reactDom2['default'].findDOMNode(_this2);
232
+ };
233
+
234
+ this.focus = function () {
235
+ if (dateInputInstance) {
236
+ dateInputInstance.focus();
237
+ }
238
+ };
239
+
240
+ this.saveDateInput = function (dateInput) {
241
+ dateInputInstance = dateInput;
242
+ };
243
+ };
244
+
245
+ (0, _reactLifecyclesCompat.polyfill)(DateInput);
246
+
247
+ exports['default'] = DateInput;
248
+ module.exports = exports['default'];
@@ -0,0 +1,317 @@
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
+ var _DateConstants = require('./DateConstants');
30
+
31
+ var _DateConstants2 = _interopRequireDefault(_DateConstants);
32
+
33
+ var _util = require('../util/');
34
+
35
+ var _dayjs = require('dayjs');
36
+
37
+ var _dayjs2 = _interopRequireDefault(_dayjs);
38
+
39
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
40
+
41
+ var DATE_ROW_COLUMN_COUNT = _DateConstants2['default'].DATE_ROW_COLUMN_COUNT,
42
+ DAY_NAME_TO_INDEX = _DateConstants2['default'].DAY_NAME_TO_INDEX;
43
+
44
+
45
+ function isSameDay(one, two) {
46
+ return one && two && one.isSame(two, 'day');
47
+ }
48
+
49
+ function beforeCurrentMonthYear(current, today) {
50
+ if (current.year() < today.year()) {
51
+ return 1;
52
+ }
53
+ return current.year() === today.year() && current.month() < today.month();
54
+ }
55
+
56
+ function afterCurrentMonthYear(current, today) {
57
+ if (current.year() > today.year()) {
58
+ return 1;
59
+ }
60
+ return current.year() === today.year() && current.month() > today.month();
61
+ }
62
+
63
+ function getIdFromDate(date) {
64
+ return 'rc-calendar-' + date.year() + '-' + date.month() + '-' + date.date();
65
+ }
66
+
67
+ var DateTBody = function (_React$Component) {
68
+ (0, _inherits3['default'])(DateTBody, _React$Component);
69
+
70
+ function DateTBody() {
71
+ (0, _classCallCheck3['default'])(this, DateTBody);
72
+ return (0, _possibleConstructorReturn3['default'])(this, _React$Component.apply(this, arguments));
73
+ }
74
+
75
+ DateTBody.prototype.render = function render() {
76
+ var props = this.props;
77
+ var contentRender = props.contentRender,
78
+ prefixCls = props.prefixCls,
79
+ selectedValue = props.selectedValue,
80
+ value = props.value,
81
+ showWeekNumber = props.showWeekNumber,
82
+ dateRender = props.dateRender,
83
+ disabledDate = props.disabledDate,
84
+ hoverValue = props.hoverValue,
85
+ firstDayOfWeek = props.firstDayOfWeek,
86
+ currentStatus = props.currentStatus;
87
+
88
+ var iIndex = void 0;
89
+ var jIndex = void 0;
90
+ var current = void 0;
91
+ var dateTable = [];
92
+ var today = (0, _util.getTodayTime)(value);
93
+ var cellClass = prefixCls + '-cell';
94
+ var weekNumberCellClass = prefixCls + '-week-number-cell';
95
+ var dateClass = prefixCls + '-date';
96
+ var todayClass = prefixCls + '-today';
97
+ var selectedClass = prefixCls + '-selected-day';
98
+ var selectedDateClass = prefixCls + '-selected-date'; // do not move with mouse operation
99
+ var selectedStartDateClass = prefixCls + '-selected-start-date';
100
+ var selectedEndDateClass = prefixCls + '-selected-end-date';
101
+ var inRangeClass = prefixCls + '-in-range-cell';
102
+ var lastMonthDayClass = prefixCls + '-last-month-cell';
103
+ var nextMonthDayClass = prefixCls + '-next-month-btn-day';
104
+ var disabledClass = prefixCls + '-disabled-cell';
105
+ var firstDisableClass = prefixCls + '-disabled-cell-first-of-row';
106
+ var lastDisableClass = prefixCls + '-disabled-cell-last-of-row';
107
+ var lastDayOfMonthClass = prefixCls + '-last-day-of-month';
108
+ var month1 = value.clone();
109
+ month1 = month1.date(1);
110
+ var day = month1.day();
111
+ var firstDayName = typeof firstDayOfWeek === 'string' ? firstDayOfWeek[0].toUpperCase() + firstDayOfWeek.slice(1) : 'Sunday';
112
+ var firstDayIndex = DAY_NAME_TO_INDEX[firstDayName] ? DAY_NAME_TO_INDEX[firstDayName] : 0;
113
+ var lastMonthDiffDay = (day + 7 - firstDayIndex) % 7;
114
+ // calculate last month
115
+ var lastMonth1 = month1.clone();
116
+ lastMonth1 = lastMonth1.add(0 - lastMonthDiffDay, 'days');
117
+ var passed = 0;
118
+
119
+ for (iIndex = 0; iIndex < DATE_ROW_COLUMN_COUNT.DATE_ROW_COUNT; iIndex++) {
120
+ for (jIndex = 0; jIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT; jIndex++) {
121
+ current = lastMonth1;
122
+ if (passed) {
123
+ current = current.clone();
124
+ current = current.add(passed, 'days');
125
+ }
126
+ dateTable.push(current);
127
+ passed++;
128
+ }
129
+ }
130
+ var tableHtml = [];
131
+ passed = 0;
132
+
133
+ for (iIndex = 0; iIndex < DATE_ROW_COLUMN_COUNT.DATE_ROW_COUNT; iIndex++) {
134
+ var _cx;
135
+
136
+ var isCurrentWeek = void 0;
137
+ var weekNumberCell = void 0;
138
+ var isActiveWeek = false;
139
+ var dateCells = [];
140
+ if (showWeekNumber) {
141
+ weekNumberCell = _react2['default'].createElement(
142
+ 'td',
143
+ {
144
+ key: dateTable[passed].week(),
145
+ role: 'gridcell',
146
+ className: weekNumberCellClass
147
+ },
148
+ dateTable[passed].week()
149
+ );
150
+ }
151
+ for (jIndex = 0; jIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT; jIndex++) {
152
+ var next = null;
153
+ var last = null;
154
+ if (currentStatus === 1) {
155
+ current = dateTable[passed].hour((0, _dayjs2['default'])().hour()).minute((0, _dayjs2['default'])().minute()).second((0, _dayjs2['default'])().second()); // eslint-disable-line max-len
156
+ } else {
157
+ current = dateTable[passed];
158
+ }
159
+ if (jIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT - 1) {
160
+ next = dateTable[passed + 1];
161
+ }
162
+ if (jIndex > 0) {
163
+ last = dateTable[passed - 1];
164
+ }
165
+ var cls = cellClass;
166
+ var disabled = false;
167
+ var selected = false;
168
+
169
+ if (isSameDay(current, today)) {
170
+ cls += ' ' + todayClass;
171
+ isCurrentWeek = true;
172
+ }
173
+
174
+ var isBeforeCurrentMonthYear = beforeCurrentMonthYear(current, value);
175
+ var isAfterCurrentMonthYear = afterCurrentMonthYear(current, value);
176
+
177
+ if (selectedValue && Array.isArray(selectedValue)) {
178
+ var rangeValue = hoverValue.length ? hoverValue : selectedValue;
179
+ if (!isBeforeCurrentMonthYear && !isAfterCurrentMonthYear) {
180
+ var startValue = rangeValue[0];
181
+ var endValue = rangeValue[1];
182
+ if (startValue) {
183
+ if (isSameDay(current, startValue)) {
184
+ selected = true;
185
+ isActiveWeek = true;
186
+ cls += ' ' + selectedStartDateClass;
187
+ }
188
+ }
189
+ if (startValue || endValue) {
190
+ if (isSameDay(current, endValue)) {
191
+ selected = true;
192
+ isActiveWeek = true;
193
+ cls += ' ' + selectedEndDateClass;
194
+ } else if ((startValue === null || startValue === undefined) && current.isBefore(endValue, 'day')) {
195
+ cls += ' ' + inRangeClass;
196
+ } else if ((endValue === null || endValue === undefined) && current.isAfter(startValue, 'day')) {
197
+ cls += ' ' + inRangeClass;
198
+ } else if (current.isAfter(startValue, 'day') && current.isBefore(endValue, 'day')) {
199
+ cls += ' ' + inRangeClass;
200
+ }
201
+ }
202
+ }
203
+ } else if (isSameDay(current, value)) {
204
+ // keyboard change value, highlight works
205
+ selected = true;
206
+ isActiveWeek = true;
207
+ }
208
+
209
+ if (isSameDay(current, selectedValue)) {
210
+ cls += ' ' + selectedDateClass;
211
+ }
212
+
213
+ if (isBeforeCurrentMonthYear) {
214
+ cls += ' ' + lastMonthDayClass;
215
+ }
216
+
217
+ if (isAfterCurrentMonthYear) {
218
+ cls += ' ' + nextMonthDayClass;
219
+ }
220
+
221
+ if (current.clone().endOf('month').date() === current.date()) {
222
+ cls += ' ' + lastDayOfMonthClass;
223
+ }
224
+
225
+ if (disabledDate) {
226
+ if (disabledDate(current, value)) {
227
+ disabled = true;
228
+
229
+ if (!last || !disabledDate(last, value)) {
230
+ cls += ' ' + firstDisableClass;
231
+ }
232
+
233
+ if (!next || !disabledDate(next, value)) {
234
+ cls += ' ' + lastDisableClass;
235
+ }
236
+ }
237
+ }
238
+
239
+ if (selected) {
240
+ cls += ' ' + selectedClass;
241
+ }
242
+
243
+ if (disabled) {
244
+ cls += ' ' + disabledClass;
245
+ }
246
+
247
+ var dateHtml = void 0;
248
+ if (dateRender) {
249
+ dateHtml = dateRender(current, value);
250
+ } else {
251
+ var content = contentRender ? contentRender(current, value) : current.date();
252
+ dateHtml = _react2['default'].createElement(
253
+ 'div',
254
+ {
255
+ key: getIdFromDate(current),
256
+ className: dateClass,
257
+ 'aria-selected': selected,
258
+ 'aria-disabled': disabled
259
+ },
260
+ content
261
+ );
262
+ }
263
+
264
+ dateCells.push(_react2['default'].createElement(
265
+ 'td',
266
+ {
267
+ key: passed,
268
+ onClick: disabled ? undefined : props.onSelect.bind(null, current),
269
+ onMouseEnter: disabled ? undefined : props.onDayHover && props.onDayHover.bind(null, current) || undefined,
270
+ role: 'gridcell',
271
+ title: (0, _util.getTitleString)(current),
272
+ className: cls
273
+ },
274
+ dateHtml
275
+ ));
276
+
277
+ passed++;
278
+ }
279
+
280
+ tableHtml.push(_react2['default'].createElement(
281
+ 'tr',
282
+ {
283
+ key: iIndex,
284
+ role: 'row',
285
+ className: (0, _classnames2['default'])((_cx = {}, _cx[prefixCls + '-current-week'] = isCurrentWeek, _cx[prefixCls + '-active-week'] = isActiveWeek, _cx))
286
+ },
287
+ weekNumberCell,
288
+ dateCells
289
+ ));
290
+ }
291
+ return _react2['default'].createElement(
292
+ 'tbody',
293
+ { className: prefixCls + '-tbody' },
294
+ tableHtml
295
+ );
296
+ };
297
+
298
+ return DateTBody;
299
+ }(_react2['default'].Component);
300
+
301
+ DateTBody.propTypes = {
302
+ contentRender: _propTypes2['default'].func,
303
+ dateRender: _propTypes2['default'].func,
304
+ disabledDate: _propTypes2['default'].func,
305
+ prefixCls: _propTypes2['default'].string,
306
+ selectedValue: _propTypes2['default'].oneOfType([_propTypes2['default'].object, _propTypes2['default'].arrayOf(_propTypes2['default'].object)]),
307
+ value: _propTypes2['default'].object,
308
+ hoverValue: _propTypes2['default'].any,
309
+ showWeekNumber: _propTypes2['default'].bool,
310
+ firstDayOfWeek: _propTypes2['default'].string,
311
+ currentStatus: _propTypes2['default'].number
312
+ };
313
+ DateTBody.defaultProps = {
314
+ hoverValue: []
315
+ };
316
+ exports['default'] = DateTBody;
317
+ module.exports = exports['default'];
@@ -0,0 +1,106 @@
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 _DateConstants = require('./DateConstants');
22
+
23
+ var _DateConstants2 = _interopRequireDefault(_DateConstants);
24
+
25
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
26
+
27
+ var DAY_NAME_TO_INDEX = _DateConstants2['default'].DAY_NAME_TO_INDEX,
28
+ DATE_ROW_COLUMN_COUNT = _DateConstants2['default'].DATE_ROW_COLUMN_COUNT;
29
+
30
+ var DateTHead = function (_React$Component) {
31
+ (0, _inherits3['default'])(DateTHead, _React$Component);
32
+
33
+ function DateTHead() {
34
+ (0, _classCallCheck3['default'])(this, DateTHead);
35
+ return (0, _possibleConstructorReturn3['default'])(this, _React$Component.apply(this, arguments));
36
+ }
37
+
38
+ DateTHead.prototype.render = function render() {
39
+ var props = this.props;
40
+ var value = props.value;
41
+ var localeData = value.localeData();
42
+ var prefixCls = props.prefixCls;
43
+ var veryShortWeekdays = [];
44
+ var weekDays = [];
45
+
46
+ var allWeekdaysMin = localeData.weekdaysMin();
47
+ var allWeekdaysShort = localeData.weekdaysShort();
48
+
49
+ var firstDayName = typeof props.firstDayOfWeek === 'string' ? props.firstDayOfWeek[0].toUpperCase() + props.firstDayOfWeek.slice(1) : 'Sunday';
50
+ var firstDay = DAY_NAME_TO_INDEX[firstDayName] ? DAY_NAME_TO_INDEX[firstDayName] : 0;
51
+
52
+ var showWeekNumberEl = void 0;
53
+ var dateColumnCount = DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT;
54
+ for (var dateColIndex = 0; dateColIndex < dateColumnCount; dateColIndex++) {
55
+ var index = (firstDay + dateColIndex) % dateColumnCount;
56
+ veryShortWeekdays[dateColIndex] = allWeekdaysMin[index];
57
+ weekDays[dateColIndex] = allWeekdaysShort[index];
58
+ }
59
+
60
+ if (props.showWeekNumber) {
61
+ showWeekNumberEl = _react2['default'].createElement(
62
+ 'th',
63
+ {
64
+ role: 'columnheader',
65
+ className: prefixCls + '-column-header ' + prefixCls + '-week-number-header'
66
+ },
67
+ _react2['default'].createElement(
68
+ 'span',
69
+ { className: prefixCls + '-column-header-inner' },
70
+ 'x'
71
+ )
72
+ );
73
+ }
74
+ var weekDaysEls = weekDays.map(function (day, xindex) {
75
+ return _react2['default'].createElement(
76
+ 'th',
77
+ {
78
+ key: xindex,
79
+ role: 'columnheader',
80
+ title: day,
81
+ className: prefixCls + '-column-header'
82
+ },
83
+ _react2['default'].createElement(
84
+ 'span',
85
+ { className: prefixCls + '-column-header-inner' },
86
+ veryShortWeekdays[xindex]
87
+ )
88
+ );
89
+ });
90
+ return _react2['default'].createElement(
91
+ 'thead',
92
+ null,
93
+ _react2['default'].createElement(
94
+ 'tr',
95
+ { role: 'row' },
96
+ showWeekNumberEl,
97
+ weekDaysEls
98
+ )
99
+ );
100
+ };
101
+
102
+ return DateTHead;
103
+ }(_react2['default'].Component);
104
+
105
+ exports['default'] = DateTHead;
106
+ module.exports = exports['default'];