@seafile/seafile-calendar 0.0.31 → 0.0.32-alpha.jh6

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