@seafile/seafile-calendar 0.0.29-alpha.2 → 0.0.29-alpha.4
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.
- package/assets/index.css +1177 -0
- package/es/Calendar.js +440 -0
- package/es/FullCalendar.js +182 -0
- package/es/MonthCalendar.js +135 -0
- package/es/Picker.js +245 -0
- package/es/RangeCalendar.js +876 -0
- package/es/calendar/CalendarFooter.js +93 -0
- package/es/calendar/CalendarHeader.js +257 -0
- package/es/calendar/CalendarRightPanel.js +121 -0
- package/es/calendar/OkButton.js +22 -0
- package/es/calendar/TimePickerButton.js +28 -0
- package/es/calendar/TodayButton.js +28 -0
- package/es/date/DateConstants.js +19 -0
- package/es/date/DateInput.js +233 -0
- package/es/date/DateTBody.js +280 -0
- package/es/date/DateTHead.js +85 -0
- package/es/date/DateTable.js +32 -0
- package/es/decade/DecadePanel.js +181 -0
- package/es/full-calendar/CalendarHeader.js +180 -0
- package/es/index.js +3 -0
- package/es/locale/ar_EG.js +27 -0
- package/es/locale/bg_BG.js +27 -0
- package/es/locale/ca_ES.js +27 -0
- package/es/locale/cs_CZ.js +27 -0
- package/es/locale/da_DK.js +27 -0
- package/es/locale/de_DE.js +27 -0
- package/es/locale/el_GR.js +27 -0
- package/es/locale/en_GB.js +27 -0
- package/es/locale/en_US.js +28 -0
- package/es/locale/es_ES.js +27 -0
- package/es/locale/et_EE.js +27 -0
- package/es/locale/fa_IR.js +27 -0
- package/es/locale/fi_FI.js +27 -0
- package/es/locale/fr_BE.js +27 -0
- package/es/locale/fr_FR.js +27 -0
- package/es/locale/he_IL.js +28 -0
- package/es/locale/hi_IN.js +28 -0
- package/es/locale/hr_HR.js +28 -0
- package/es/locale/hu_HU.js +27 -0
- package/es/locale/id_ID.js +28 -0
- package/es/locale/is_IS.js +27 -0
- package/es/locale/it_IT.js +27 -0
- package/es/locale/ja_JP.js +26 -0
- package/es/locale/kn_IN.js +28 -0
- package/es/locale/ko_KR.js +27 -0
- package/es/locale/ku_IQ.js +27 -0
- package/es/locale/lv_LV.js +27 -0
- package/es/locale/mm_MM.js +28 -0
- package/es/locale/mn_MN.js +28 -0
- package/es/locale/ms_MY.js +27 -0
- package/es/locale/nb_NO.js +27 -0
- package/es/locale/nl_BE.js +27 -0
- package/es/locale/nl_NL.js +27 -0
- package/es/locale/pl_PL.js +27 -0
- package/es/locale/pt_BR.js +27 -0
- package/es/locale/pt_PT.js +27 -0
- package/es/locale/ro_RO.js +28 -0
- package/es/locale/ru_RU.js +27 -0
- package/es/locale/sk_SK.js +27 -0
- package/es/locale/sl_SI.js +27 -0
- package/es/locale/sr_RS.js +27 -0
- package/es/locale/sv_SE.js +27 -0
- package/es/locale/ta_IN.js +28 -0
- package/es/locale/th_TH.js +27 -0
- package/es/locale/tr_TR.js +27 -0
- package/es/locale/ug_CN.js +26 -0
- package/es/locale/uk_UA.js +27 -0
- package/es/locale/vi_VN.js +28 -0
- package/es/locale/zh_CN.js +27 -0
- package/es/locale/zh_TW.js +26 -0
- package/es/mixin/CalendarMixin.js +123 -0
- package/es/mixin/CommonMixin.js +85 -0
- package/es/month/MonthPanel.js +154 -0
- package/es/month/MonthTable.js +156 -0
- package/es/picker/placements.js +35 -0
- package/es/range-calendar/CalendarPart.js +151 -0
- package/es/util/dayjs.js +17 -0
- package/es/util/index.js +105 -0
- package/es/util/toTime.js +21 -0
- package/es/year/YearPanel.js +194 -0
- package/lib/Calendar.js +503 -0
- package/lib/FullCalendar.js +221 -0
- package/lib/MonthCalendar.js +172 -0
- package/lib/Picker.js +282 -0
- package/lib/RangeCalendar.js +925 -0
- package/lib/calendar/CalendarFooter.js +134 -0
- package/lib/calendar/CalendarHeader.js +290 -0
- package/lib/calendar/CalendarRightPanel.js +145 -0
- package/lib/calendar/OkButton.js +32 -0
- package/lib/calendar/TimePickerButton.js +41 -0
- package/lib/calendar/TodayButton.js +39 -0
- package/lib/date/DateConstants.js +23 -0
- package/lib/date/DateInput.js +265 -0
- package/lib/date/DateTBody.js +307 -0
- package/lib/date/DateTHead.js +105 -0
- package/lib/date/DateTable.js +54 -0
- package/lib/decade/DecadePanel.js +207 -0
- package/lib/full-calendar/CalendarHeader.js +201 -0
- package/lib/index.js +12 -0
- package/lib/locale/ar_EG.js +31 -0
- package/lib/locale/bg_BG.js +31 -0
- package/lib/locale/ca_ES.js +31 -0
- package/lib/locale/cs_CZ.js +31 -0
- package/lib/locale/da_DK.js +31 -0
- package/lib/locale/de_DE.js +31 -0
- package/lib/locale/el_GR.js +31 -0
- package/lib/locale/en_GB.js +31 -0
- package/lib/locale/en_US.js +32 -0
- package/lib/locale/es_ES.js +31 -0
- package/lib/locale/et_EE.js +31 -0
- package/lib/locale/fa_IR.js +31 -0
- package/lib/locale/fi_FI.js +31 -0
- package/lib/locale/fr_BE.js +31 -0
- package/lib/locale/fr_FR.js +31 -0
- package/lib/locale/he_IL.js +32 -0
- package/lib/locale/hi_IN.js +32 -0
- package/lib/locale/hr_HR.js +32 -0
- package/lib/locale/hu_HU.js +31 -0
- package/lib/locale/id_ID.js +32 -0
- package/lib/locale/is_IS.js +31 -0
- package/lib/locale/it_IT.js +31 -0
- package/lib/locale/ja_JP.js +30 -0
- package/lib/locale/kn_IN.js +32 -0
- package/lib/locale/ko_KR.js +31 -0
- package/lib/locale/ku_IQ.js +31 -0
- package/lib/locale/lv_LV.js +31 -0
- package/lib/locale/mm_MM.js +32 -0
- package/lib/locale/mn_MN.js +32 -0
- package/lib/locale/ms_MY.js +31 -0
- package/lib/locale/nb_NO.js +31 -0
- package/lib/locale/nl_BE.js +31 -0
- package/lib/locale/nl_NL.js +31 -0
- package/lib/locale/pl_PL.js +31 -0
- package/lib/locale/pt_BR.js +31 -0
- package/lib/locale/pt_PT.js +31 -0
- package/lib/locale/ro_RO.js +32 -0
- package/lib/locale/ru_RU.js +31 -0
- package/lib/locale/sk_SK.js +31 -0
- package/lib/locale/sl_SI.js +31 -0
- package/lib/locale/sr_RS.js +31 -0
- package/lib/locale/sv_SE.js +31 -0
- package/lib/locale/ta_IN.js +32 -0
- package/lib/locale/th_TH.js +31 -0
- package/lib/locale/tr_TR.js +31 -0
- package/lib/locale/ug_CN.js +30 -0
- package/lib/locale/uk_UA.js +31 -0
- package/lib/locale/vi_VN.js +32 -0
- package/lib/locale/zh_CN.js +31 -0
- package/lib/locale/zh_TW.js +30 -0
- package/lib/mixin/CalendarMixin.js +153 -0
- package/lib/mixin/CommonMixin.js +106 -0
- package/lib/month/MonthPanel.js +179 -0
- package/lib/month/MonthTable.js +181 -0
- package/lib/picker/placements.js +39 -0
- package/lib/range-calendar/CalendarPart.js +184 -0
- package/lib/util/dayjs.js +46 -0
- package/lib/util/index.js +130 -0
- package/lib/util/toTime.js +28 -0
- package/lib/year/YearPanel.js +219 -0
- 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,265 @@
|
|
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 cachedSelectionStart = void 0;
|
44
|
+
var cachedSelectionEnd = void 0;
|
45
|
+
var dateInputInstance = void 0;
|
46
|
+
|
47
|
+
var DateInput = function (_React$Component) {
|
48
|
+
(0, _inherits3['default'])(DateInput, _React$Component);
|
49
|
+
|
50
|
+
function DateInput(props) {
|
51
|
+
(0, _classCallCheck3['default'])(this, DateInput);
|
52
|
+
|
53
|
+
var _this = (0, _possibleConstructorReturn3['default'])(this, _React$Component.call(this, props));
|
54
|
+
|
55
|
+
_initialiseProps.call(_this);
|
56
|
+
|
57
|
+
var selectedValue = props.selectedValue;
|
58
|
+
|
59
|
+
_this.state = {
|
60
|
+
str: (0, _util.formatDate)(selectedValue, _this.props.format),
|
61
|
+
invalid: false,
|
62
|
+
hasFocus: false
|
63
|
+
};
|
64
|
+
return _this;
|
65
|
+
}
|
66
|
+
|
67
|
+
DateInput.prototype.componentDidUpdate = function componentDidUpdate() {
|
68
|
+
if (dateInputInstance && this.state.hasFocus && !this.state.invalid && !(cachedSelectionStart === 0 && cachedSelectionEnd === 0)) {
|
69
|
+
dateInputInstance.setSelectionRange(cachedSelectionStart, cachedSelectionEnd);
|
70
|
+
}
|
71
|
+
};
|
72
|
+
|
73
|
+
DateInput.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, state) {
|
74
|
+
var newState = {};
|
75
|
+
|
76
|
+
if (dateInputInstance) {
|
77
|
+
cachedSelectionStart = dateInputInstance.selectionStart;
|
78
|
+
cachedSelectionEnd = dateInputInstance.selectionEnd;
|
79
|
+
}
|
80
|
+
// when popup show, click body will call this, bug!
|
81
|
+
var selectedValue = nextProps.selectedValue;
|
82
|
+
if (!state.hasFocus) {
|
83
|
+
newState = {
|
84
|
+
str: (0, _util.formatDate)(selectedValue, nextProps.format),
|
85
|
+
invalid: false
|
86
|
+
};
|
87
|
+
}
|
88
|
+
|
89
|
+
return newState;
|
90
|
+
};
|
91
|
+
|
92
|
+
DateInput.getInstance = function getInstance() {
|
93
|
+
return dateInputInstance;
|
94
|
+
};
|
95
|
+
|
96
|
+
DateInput.prototype.render = function render() {
|
97
|
+
var props = this.props;
|
98
|
+
var _state = this.state,
|
99
|
+
invalid = _state.invalid,
|
100
|
+
str = _state.str;
|
101
|
+
var locale = props.locale,
|
102
|
+
prefixCls = props.prefixCls,
|
103
|
+
placeholder = props.placeholder,
|
104
|
+
clearIcon = props.clearIcon,
|
105
|
+
inputMode = props.inputMode;
|
106
|
+
|
107
|
+
var invalidClass = invalid ? prefixCls + '-input-invalid' : '';
|
108
|
+
return _react2['default'].createElement(
|
109
|
+
'div',
|
110
|
+
{ className: prefixCls + '-input-wrap' },
|
111
|
+
_react2['default'].createElement(
|
112
|
+
'div',
|
113
|
+
{ className: prefixCls + '-date-input-wrap' },
|
114
|
+
_react2['default'].createElement('input', {
|
115
|
+
ref: this.saveDateInput,
|
116
|
+
className: prefixCls + '-input ' + invalidClass,
|
117
|
+
value: str,
|
118
|
+
disabled: props.disabled,
|
119
|
+
placeholder: placeholder,
|
120
|
+
onChange: this.onInputChange,
|
121
|
+
onKeyDown: this.onKeyDown,
|
122
|
+
onFocus: this.onFocus,
|
123
|
+
onBlur: this.onBlur,
|
124
|
+
inputMode: inputMode
|
125
|
+
})
|
126
|
+
),
|
127
|
+
props.showClear ? _react2['default'].createElement(
|
128
|
+
'a',
|
129
|
+
{
|
130
|
+
role: 'button',
|
131
|
+
title: locale.clear,
|
132
|
+
onClick: this.onClear
|
133
|
+
},
|
134
|
+
clearIcon || _react2['default'].createElement('span', { className: prefixCls + '-clear-btn' })
|
135
|
+
) : null
|
136
|
+
);
|
137
|
+
};
|
138
|
+
|
139
|
+
return DateInput;
|
140
|
+
}(_react2['default'].Component);
|
141
|
+
|
142
|
+
DateInput.propTypes = {
|
143
|
+
prefixCls: _propTypes2['default'].string,
|
144
|
+
timePicker: _propTypes2['default'].object,
|
145
|
+
value: _propTypes2['default'].object,
|
146
|
+
disabledTime: _propTypes2['default'].any,
|
147
|
+
format: _propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].arrayOf(_propTypes2['default'].string)]),
|
148
|
+
locale: _propTypes2['default'].object,
|
149
|
+
disabledDate: _propTypes2['default'].func,
|
150
|
+
onChange: _propTypes2['default'].func,
|
151
|
+
onClear: _propTypes2['default'].func,
|
152
|
+
placeholder: _propTypes2['default'].string,
|
153
|
+
onSelect: _propTypes2['default'].func,
|
154
|
+
selectedValue: _propTypes2['default'].object,
|
155
|
+
clearIcon: _propTypes2['default'].node,
|
156
|
+
inputMode: _propTypes2['default'].string
|
157
|
+
};
|
158
|
+
|
159
|
+
var _initialiseProps = function _initialiseProps() {
|
160
|
+
var _this2 = this;
|
161
|
+
|
162
|
+
this.onClear = function () {
|
163
|
+
_this2.setState({
|
164
|
+
str: ''
|
165
|
+
});
|
166
|
+
_this2.props.onClear(null);
|
167
|
+
};
|
168
|
+
|
169
|
+
this.onInputChange = function (event) {
|
170
|
+
var str = event.target.value;
|
171
|
+
var _props = _this2.props,
|
172
|
+
disabledDate = _props.disabledDate,
|
173
|
+
format = _props.format,
|
174
|
+
onChange = _props.onChange,
|
175
|
+
selectedValue = _props.selectedValue;
|
176
|
+
|
177
|
+
// 没有内容,合法并直接退出
|
178
|
+
|
179
|
+
if (!str) {
|
180
|
+
onChange(null);
|
181
|
+
_this2.setState({
|
182
|
+
invalid: false,
|
183
|
+
str: str
|
184
|
+
});
|
185
|
+
return;
|
186
|
+
}
|
187
|
+
|
188
|
+
// 不合法直接退出
|
189
|
+
var parsed = (0, _dayjs2['default'])(str, format, true);
|
190
|
+
if (!parsed.isValid()) {
|
191
|
+
_this2.setState({
|
192
|
+
invalid: true,
|
193
|
+
str: str
|
194
|
+
});
|
195
|
+
return;
|
196
|
+
}
|
197
|
+
|
198
|
+
var value = _this2.props.value.clone();
|
199
|
+
value = value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
|
200
|
+
|
201
|
+
if (!value || disabledDate && disabledDate(value)) {
|
202
|
+
_this2.setState({
|
203
|
+
invalid: true,
|
204
|
+
str: str
|
205
|
+
});
|
206
|
+
return;
|
207
|
+
}
|
208
|
+
|
209
|
+
if (selectedValue !== value || selectedValue && value && !selectedValue.isSame(value)) {
|
210
|
+
_this2.setState({
|
211
|
+
invalid: false,
|
212
|
+
str: str
|
213
|
+
});
|
214
|
+
onChange(value);
|
215
|
+
}
|
216
|
+
};
|
217
|
+
|
218
|
+
this.onFocus = function () {
|
219
|
+
_this2.setState({ hasFocus: true });
|
220
|
+
};
|
221
|
+
|
222
|
+
this.onBlur = function () {
|
223
|
+
_this2.setState(function (prevState, prevProps) {
|
224
|
+
return {
|
225
|
+
hasFocus: false,
|
226
|
+
str: (0, _util.formatDate)(prevProps.value, prevProps.format)
|
227
|
+
};
|
228
|
+
});
|
229
|
+
};
|
230
|
+
|
231
|
+
this.onKeyDown = function (event) {
|
232
|
+
var keyCode = event.keyCode;
|
233
|
+
var _props2 = _this2.props,
|
234
|
+
onSelect = _props2.onSelect,
|
235
|
+
value = _props2.value,
|
236
|
+
disabledDate = _props2.disabledDate;
|
237
|
+
|
238
|
+
if (keyCode === _KeyCode2['default'].ENTER && onSelect) {
|
239
|
+
var validateDate = !disabledDate || !disabledDate(value);
|
240
|
+
if (validateDate) {
|
241
|
+
onSelect(value.clone());
|
242
|
+
}
|
243
|
+
event.preventDefault();
|
244
|
+
}
|
245
|
+
};
|
246
|
+
|
247
|
+
this.getRootDOMNode = function () {
|
248
|
+
return _reactDom2['default'].findDOMNode(_this2);
|
249
|
+
};
|
250
|
+
|
251
|
+
this.focus = function () {
|
252
|
+
if (dateInputInstance) {
|
253
|
+
dateInputInstance.focus();
|
254
|
+
}
|
255
|
+
};
|
256
|
+
|
257
|
+
this.saveDateInput = function (dateInput) {
|
258
|
+
dateInputInstance = dateInput;
|
259
|
+
};
|
260
|
+
};
|
261
|
+
|
262
|
+
(0, _reactLifecyclesCompat.polyfill)(DateInput);
|
263
|
+
|
264
|
+
exports['default'] = DateInput;
|
265
|
+
module.exports = exports['default'];
|
@@ -0,0 +1,307 @@
|
|
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'];
|
@@ -0,0 +1,105 @@
|
|
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
|
+
for (var dateColIndex = 0; dateColIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT; dateColIndex++) {
|
54
|
+
var index = (firstDay + dateColIndex) % DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT;
|
55
|
+
veryShortWeekdays[dateColIndex] = allWeekdaysMin[index];
|
56
|
+
weekDays[dateColIndex] = allWeekdaysShort[index];
|
57
|
+
}
|
58
|
+
|
59
|
+
if (props.showWeekNumber) {
|
60
|
+
showWeekNumberEl = _react2['default'].createElement(
|
61
|
+
'th',
|
62
|
+
{
|
63
|
+
role: 'columnheader',
|
64
|
+
className: prefixCls + '-column-header ' + prefixCls + '-week-number-header'
|
65
|
+
},
|
66
|
+
_react2['default'].createElement(
|
67
|
+
'span',
|
68
|
+
{ className: prefixCls + '-column-header-inner' },
|
69
|
+
'x'
|
70
|
+
)
|
71
|
+
);
|
72
|
+
}
|
73
|
+
var weekDaysEls = weekDays.map(function (day, xindex) {
|
74
|
+
return _react2['default'].createElement(
|
75
|
+
'th',
|
76
|
+
{
|
77
|
+
key: xindex,
|
78
|
+
role: 'columnheader',
|
79
|
+
title: day,
|
80
|
+
className: prefixCls + '-column-header'
|
81
|
+
},
|
82
|
+
_react2['default'].createElement(
|
83
|
+
'span',
|
84
|
+
{ className: prefixCls + '-column-header-inner' },
|
85
|
+
veryShortWeekdays[xindex]
|
86
|
+
)
|
87
|
+
);
|
88
|
+
});
|
89
|
+
return _react2['default'].createElement(
|
90
|
+
'thead',
|
91
|
+
null,
|
92
|
+
_react2['default'].createElement(
|
93
|
+
'tr',
|
94
|
+
{ role: 'row' },
|
95
|
+
showWeekNumberEl,
|
96
|
+
weekDaysEls
|
97
|
+
)
|
98
|
+
);
|
99
|
+
};
|
100
|
+
|
101
|
+
return DateTHead;
|
102
|
+
}(_react2['default'].Component);
|
103
|
+
|
104
|
+
exports['default'] = DateTHead;
|
105
|
+
module.exports = exports['default'];
|