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