@seafile/seafile-calendar 0.0.31 → 0.0.32-alpha.1
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 +11 -12
- package/dist/rc-calendar.css +11 -12
- package/dist/rc-calendar.css.map +1 -1
- package/dist/rc-calendar.js +100 -54
- package/dist/rc-calendar.js.map +1 -1
- package/dist/rc-calendar.min.css +11 -12
- package/dist/rc-calendar.min.css.map +1 -1
- package/dist/rc-calendar.min.js +1 -1
- package/es/Calendar.js +12 -6
- package/es/date/DateInput.js +43 -19
- package/es/date/DateTBody.js +6 -4
- package/es/util/index.js +14 -2
- package/lib/Calendar.js +11 -5
- package/lib/date/DateInput.js +42 -19
- package/lib/date/DateTBody.js +5 -3
- package/lib/util/index.js +15 -3
- package/package.json +2 -5
package/es/date/DateInput.js
CHANGED
|
@@ -8,6 +8,7 @@ import KeyCode from 'rc-util/es/KeyCode';
|
|
|
8
8
|
import { polyfill } from 'react-lifecycles-compat';
|
|
9
9
|
import dayjs from 'dayjs';
|
|
10
10
|
import { formatDate, initializeStr } from '../util';
|
|
11
|
+
|
|
11
12
|
var customParseFormat = require('dayjs/plugin/customParseFormat');
|
|
12
13
|
|
|
13
14
|
dayjs.extend(customParseFormat);
|
|
@@ -31,11 +32,23 @@ var DateInput = function (_React$Component) {
|
|
|
31
32
|
_this.state = {
|
|
32
33
|
str: formatDate(selectedValue, _this.props.format),
|
|
33
34
|
hasFocus: false,
|
|
35
|
+
isInputEmpty: false,
|
|
34
36
|
localFormat: _this.props.format[0]
|
|
35
37
|
};
|
|
36
38
|
return _this;
|
|
37
39
|
}
|
|
38
40
|
|
|
41
|
+
DateInput.prototype.componentDidMount = function componentDidMount() {
|
|
42
|
+
var _this2 = this;
|
|
43
|
+
|
|
44
|
+
setTimeout(function () {
|
|
45
|
+
_this2.focus();
|
|
46
|
+
}, 1);
|
|
47
|
+
setTimeout(function () {
|
|
48
|
+
_this2.focus();
|
|
49
|
+
}, 1000);
|
|
50
|
+
};
|
|
51
|
+
|
|
39
52
|
DateInput.prototype.componentDidUpdate = function componentDidUpdate() {
|
|
40
53
|
if (dateInputInstance && this.state.hasFocus && !(cachedSelectionStart === 0 && cachedSelectionEnd === 0)) {
|
|
41
54
|
dateInputInstance.setSelectionRange(cachedSelectionStart, cachedSelectionEnd);
|
|
@@ -87,10 +100,11 @@ var DateInput = function (_React$Component) {
|
|
|
87
100
|
onKeyDown: this.onKeyDown,
|
|
88
101
|
onFocus: this.onFocus,
|
|
89
102
|
onBlur: this.onBlur,
|
|
90
|
-
inputMode: inputMode
|
|
103
|
+
inputMode: inputMode,
|
|
104
|
+
tabIndex: '0'
|
|
91
105
|
})
|
|
92
106
|
),
|
|
93
|
-
props.showClear
|
|
107
|
+
props.showClear && React.createElement(
|
|
94
108
|
'a',
|
|
95
109
|
{
|
|
96
110
|
role: 'button',
|
|
@@ -98,7 +112,7 @@ var DateInput = function (_React$Component) {
|
|
|
98
112
|
onClick: this.onClear
|
|
99
113
|
},
|
|
100
114
|
clearIcon || React.createElement('span', { className: prefixCls + '-clear-btn' })
|
|
101
|
-
)
|
|
115
|
+
)
|
|
102
116
|
);
|
|
103
117
|
};
|
|
104
118
|
|
|
@@ -123,17 +137,17 @@ DateInput.propTypes = {
|
|
|
123
137
|
};
|
|
124
138
|
|
|
125
139
|
var _initialiseProps = function _initialiseProps() {
|
|
126
|
-
var
|
|
140
|
+
var _this3 = this;
|
|
127
141
|
|
|
128
142
|
this.onClear = function () {
|
|
129
|
-
|
|
130
|
-
|
|
143
|
+
_this3.setState({ str: '' });
|
|
144
|
+
_this3.props.onClear(null);
|
|
131
145
|
};
|
|
132
146
|
|
|
133
147
|
this.onInputChange = function (event) {
|
|
134
148
|
var str = event.target.value;
|
|
135
|
-
var calendarStr = initializeStr(str,
|
|
136
|
-
var _props =
|
|
149
|
+
var calendarStr = initializeStr(str, _this3.state.localFormat) || '';
|
|
150
|
+
var _props = _this3.props,
|
|
137
151
|
disabledDate = _props.disabledDate,
|
|
138
152
|
format = _props.format,
|
|
139
153
|
onChange = _props.onChange,
|
|
@@ -141,32 +155,38 @@ var _initialiseProps = function _initialiseProps() {
|
|
|
141
155
|
|
|
142
156
|
// 没有内容,合法并直接退出
|
|
143
157
|
|
|
144
|
-
if (!calendarStr) {
|
|
145
|
-
|
|
146
|
-
|
|
158
|
+
if (!str || !calendarStr) {
|
|
159
|
+
console.log('没有内容,合法并直接退出');
|
|
160
|
+
_this3.setState({ isInputEmpty: true });
|
|
161
|
+
_this3.onClear();
|
|
147
162
|
return;
|
|
148
163
|
}
|
|
164
|
+
|
|
165
|
+
if (_this3.state.isInputEmpty) {
|
|
166
|
+
_this3.setState({ isInputEmpty: false });
|
|
167
|
+
}
|
|
168
|
+
|
|
149
169
|
var parsed = dayjs(calendarStr, format[0]);
|
|
150
|
-
var value =
|
|
170
|
+
var value = _this3.props.value.clone();
|
|
151
171
|
value = value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
|
|
152
172
|
|
|
153
173
|
if (!value || disabledDate && disabledDate(value)) {
|
|
154
|
-
|
|
174
|
+
_this3.setState({ str: str });
|
|
155
175
|
return;
|
|
156
176
|
}
|
|
157
177
|
|
|
158
178
|
if (selectedValue !== value || selectedValue && value && !selectedValue.isSame(value)) {
|
|
159
|
-
|
|
179
|
+
_this3.setState({ str: str });
|
|
160
180
|
onChange(value);
|
|
161
181
|
}
|
|
162
182
|
};
|
|
163
183
|
|
|
164
184
|
this.onFocus = function () {
|
|
165
|
-
|
|
185
|
+
_this3.setState({ hasFocus: true });
|
|
166
186
|
};
|
|
167
187
|
|
|
168
188
|
this.onBlur = function () {
|
|
169
|
-
|
|
189
|
+
_this3.setState(function (prevState, prevProps) {
|
|
170
190
|
return {
|
|
171
191
|
hasFocus: false,
|
|
172
192
|
str: formatDate(prevProps.value, prevProps.format)
|
|
@@ -176,7 +196,7 @@ var _initialiseProps = function _initialiseProps() {
|
|
|
176
196
|
|
|
177
197
|
this.onKeyDown = function (event) {
|
|
178
198
|
var keyCode = event.keyCode;
|
|
179
|
-
var _props2 =
|
|
199
|
+
var _props2 = _this3.props,
|
|
180
200
|
onSelect = _props2.onSelect,
|
|
181
201
|
value = _props2.value,
|
|
182
202
|
disabledDate = _props2.disabledDate;
|
|
@@ -184,14 +204,18 @@ var _initialiseProps = function _initialiseProps() {
|
|
|
184
204
|
if (keyCode === KeyCode.ENTER && onSelect) {
|
|
185
205
|
var validateDate = !disabledDate || !disabledDate(value);
|
|
186
206
|
if (validateDate) {
|
|
187
|
-
|
|
207
|
+
if (_this3.state.isInputEmpty) {
|
|
208
|
+
onSelect(null);
|
|
209
|
+
} else {
|
|
210
|
+
onSelect(value.clone());
|
|
211
|
+
}
|
|
188
212
|
}
|
|
189
213
|
event.preventDefault();
|
|
190
214
|
}
|
|
191
215
|
};
|
|
192
216
|
|
|
193
217
|
this.getRootDOMNode = function () {
|
|
194
|
-
return ReactDOM.findDOMNode(
|
|
218
|
+
return ReactDOM.findDOMNode(_this3);
|
|
195
219
|
};
|
|
196
220
|
|
|
197
221
|
this.focus = function () {
|
package/es/date/DateTBody.js
CHANGED
|
@@ -5,7 +5,7 @@ import React from 'react';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import cx from 'classnames';
|
|
7
7
|
import DateConstants from './DateConstants';
|
|
8
|
-
import { getTitleString, getTodayTime } from '../util/';
|
|
8
|
+
import { getTitleString, getTodayTime, syncCurrentTime } from '../util/';
|
|
9
9
|
|
|
10
10
|
var DATE_ROW_COLUMN_COUNT = DateConstants.DATE_ROW_COLUMN_COUNT,
|
|
11
11
|
DAY_NAME_TO_INDEX = DateConstants.DAY_NAME_TO_INDEX;
|
|
@@ -52,7 +52,8 @@ var DateTBody = function (_React$Component) {
|
|
|
52
52
|
dateRender = props.dateRender,
|
|
53
53
|
disabledDate = props.disabledDate,
|
|
54
54
|
hoverValue = props.hoverValue,
|
|
55
|
-
firstDayOfWeek = props.firstDayOfWeek
|
|
55
|
+
firstDayOfWeek = props.firstDayOfWeek,
|
|
56
|
+
currentStatus = props.currentStatus;
|
|
56
57
|
|
|
57
58
|
var iIndex = void 0;
|
|
58
59
|
var jIndex = void 0;
|
|
@@ -120,7 +121,7 @@ var DateTBody = function (_React$Component) {
|
|
|
120
121
|
for (jIndex = 0; jIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT; jIndex++) {
|
|
121
122
|
var next = null;
|
|
122
123
|
var last = null;
|
|
123
|
-
current = dateTable[passed];
|
|
124
|
+
current = syncCurrentTime(dateTable[passed], currentStatus);
|
|
124
125
|
if (jIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT - 1) {
|
|
125
126
|
next = dateTable[passed + 1];
|
|
126
127
|
}
|
|
@@ -272,7 +273,8 @@ DateTBody.propTypes = {
|
|
|
272
273
|
value: PropTypes.object,
|
|
273
274
|
hoverValue: PropTypes.any,
|
|
274
275
|
showWeekNumber: PropTypes.bool,
|
|
275
|
-
firstDayOfWeek: PropTypes.string
|
|
276
|
+
firstDayOfWeek: PropTypes.string,
|
|
277
|
+
currentStatus: PropTypes.string
|
|
276
278
|
};
|
|
277
279
|
DateTBody.defaultProps = {
|
|
278
280
|
hoverValue: []
|
package/es/util/index.js
CHANGED
|
@@ -27,6 +27,18 @@ export var DATE_FORMATS = {
|
|
|
27
27
|
Germany_Russia_etcAndTime: 'DD.MM.YYYY HH:mm'
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
export var CALENDAR_STATUS = {
|
|
31
|
+
SPECIFIC_TIME: 'specific_time',
|
|
32
|
+
CURRENT_TIME: 'current_time'
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export var syncCurrentTime = function syncCurrentTime(date, status) {
|
|
36
|
+
if (status === CALENDAR_STATUS.CURRENT_TIME) {
|
|
37
|
+
return date.hour(dayjs().hour()).minute(dayjs().minute()).second(dayjs().second());
|
|
38
|
+
}
|
|
39
|
+
return date;
|
|
40
|
+
};
|
|
41
|
+
|
|
30
42
|
var defaultDisabledTime = {
|
|
31
43
|
disabledHours: function disabledHours() {
|
|
32
44
|
return [];
|
|
@@ -478,7 +490,7 @@ export function initializeStr(str, format) {
|
|
|
478
490
|
return '' + _day10 + dateDelimater + _month10 + dateDelimater + _year10;
|
|
479
491
|
} else if (inputStrLength >= 1 && inputStrLength <= 8) {
|
|
480
492
|
var _dateStr6 = inputStr.slice(0, 2);
|
|
481
|
-
var _monthStr6 = inputStr.slice(2, 4);
|
|
493
|
+
var _monthStr6 = inputStr.slice(2, 4) || getCurrentMonth();
|
|
482
494
|
var _yearStr6 = inputStr.slice(4, inputStr.length);
|
|
483
495
|
var _validateYear11 = validateCalendarYear(_yearStr6);
|
|
484
496
|
|
|
@@ -522,7 +534,7 @@ export function initializeStr(str, format) {
|
|
|
522
534
|
return '' + _day12 + dateDelimater + _month12 + dateDelimater + _year12 + ' ' + time;
|
|
523
535
|
} else if (_datePart2.length >= 1 && _datePart2.length <= 8) {
|
|
524
536
|
var _dateStr7 = _datePart2.slice(0, 2);
|
|
525
|
-
var _monthStr7 = _datePart2.slice(2, 4);
|
|
537
|
+
var _monthStr7 = _datePart2.slice(2, 4) || getCurrentMonth();
|
|
526
538
|
var _yearStr7 = _datePart2.slice(4, _datePart2.length);
|
|
527
539
|
var _timeParts2 = tokenizeFormattedDate(inputStr, format);
|
|
528
540
|
time = validateTime(_timeParts2[1] + ':' + _timeParts2[2]);
|
package/lib/Calendar.js
CHANGED
|
@@ -108,7 +108,8 @@ var Calendar = function (_React$Component) {
|
|
|
108
108
|
_this.state = {
|
|
109
109
|
mode: _this.props.mode || 'date',
|
|
110
110
|
value: getMomentObjectIfValid(props.value) || getMomentObjectIfValid(props.defaultValue) || (0, _dayjs2['default'])(),
|
|
111
|
-
selectedValue: props.selectedValue || props.defaultSelectedValue
|
|
111
|
+
selectedValue: props.selectedValue || props.defaultSelectedValue,
|
|
112
|
+
currentStatus: _util.CALENDAR_STATUS.SPECIFIC_TIME
|
|
112
113
|
};
|
|
113
114
|
return _this;
|
|
114
115
|
}
|
|
@@ -156,7 +157,8 @@ var Calendar = function (_React$Component) {
|
|
|
156
157
|
showWeekNumber = props.showWeekNumber;
|
|
157
158
|
var value = state.value,
|
|
158
159
|
selectedValue = state.selectedValue,
|
|
159
|
-
mode = state.mode
|
|
160
|
+
mode = state.mode,
|
|
161
|
+
currentStatus = state.currentStatus;
|
|
160
162
|
|
|
161
163
|
var showTimePicker = mode === 'time';
|
|
162
164
|
var disabledTimeConfig = showTimePicker && disabledTime && timePicker ? (0, _util.getTimeConfig)(selectedValue, disabledTime) : null;
|
|
@@ -181,9 +183,10 @@ var Calendar = function (_React$Component) {
|
|
|
181
183
|
timePickerEle = _react2['default'].cloneElement(timePicker, timePickerProps);
|
|
182
184
|
}
|
|
183
185
|
var calendarInputPlaceholder = dateInputPlaceholder || (Array.isArray(this.getFormat()) ? this.getFormat()[0] : this.getFormat());
|
|
186
|
+
var inputFormat = Array.isArray(this.getFormat()) ? this.getFormat() : [this.getFormat()];
|
|
184
187
|
|
|
185
188
|
var dateInputElement = props.showDateInput ? _react2['default'].createElement(_DateInput2['default'], {
|
|
186
|
-
format:
|
|
189
|
+
format: inputFormat,
|
|
187
190
|
key: 'date-input',
|
|
188
191
|
value: value,
|
|
189
192
|
locale: locale,
|
|
@@ -248,7 +251,8 @@ var Calendar = function (_React$Component) {
|
|
|
248
251
|
onSelect: this.onDateTableSelect,
|
|
249
252
|
disabledDate: disabledDate,
|
|
250
253
|
showWeekNumber: showWeekNumber,
|
|
251
|
-
firstDayOfWeek: firstDayOfWeek
|
|
254
|
+
firstDayOfWeek: firstDayOfWeek,
|
|
255
|
+
currentStatus: currentStatus
|
|
252
256
|
})
|
|
253
257
|
),
|
|
254
258
|
_react2['default'].createElement(_CalendarFooter2['default'], {
|
|
@@ -280,7 +284,7 @@ var Calendar = function (_React$Component) {
|
|
|
280
284
|
onSelect: this.onDateTableSelect,
|
|
281
285
|
onClickRightPanelTime: onClickRightPanelTime,
|
|
282
286
|
defaultMinutesTime: this.props.defaultMinutesTime,
|
|
283
|
-
format:
|
|
287
|
+
format: inputFormat
|
|
284
288
|
})
|
|
285
289
|
)
|
|
286
290
|
));
|
|
@@ -423,6 +427,7 @@ var _initialiseProps = function _initialiseProps() {
|
|
|
423
427
|
this.onClear = function () {
|
|
424
428
|
_this2.onSelect(null);
|
|
425
429
|
_this2.props.onClear();
|
|
430
|
+
_this2.setState({ currentStatus: _util.CALENDAR_STATUS.CURRENT_TIME });
|
|
426
431
|
};
|
|
427
432
|
|
|
428
433
|
this.onOk = function () {
|
|
@@ -449,6 +454,7 @@ var _initialiseProps = function _initialiseProps() {
|
|
|
449
454
|
var timePicker = _this2.props.timePicker;
|
|
450
455
|
var selectedValue = _this2.state.selectedValue;
|
|
451
456
|
|
|
457
|
+
_this2.setState({ currentStatus: _util.CALENDAR_STATUS.SPECIFIC_TIME });
|
|
452
458
|
if (!selectedValue && timePicker) {
|
|
453
459
|
var timePickerDefaultValue = timePicker.props.defaultValue;
|
|
454
460
|
if (timePickerDefaultValue) {
|
package/lib/date/DateInput.js
CHANGED
|
@@ -63,11 +63,23 @@ var DateInput = function (_React$Component) {
|
|
|
63
63
|
_this.state = {
|
|
64
64
|
str: (0, _util.formatDate)(selectedValue, _this.props.format),
|
|
65
65
|
hasFocus: false,
|
|
66
|
+
isInputEmpty: false,
|
|
66
67
|
localFormat: _this.props.format[0]
|
|
67
68
|
};
|
|
68
69
|
return _this;
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
DateInput.prototype.componentDidMount = function componentDidMount() {
|
|
73
|
+
var _this2 = this;
|
|
74
|
+
|
|
75
|
+
setTimeout(function () {
|
|
76
|
+
_this2.focus();
|
|
77
|
+
}, 1);
|
|
78
|
+
setTimeout(function () {
|
|
79
|
+
_this2.focus();
|
|
80
|
+
}, 1000);
|
|
81
|
+
};
|
|
82
|
+
|
|
71
83
|
DateInput.prototype.componentDidUpdate = function componentDidUpdate() {
|
|
72
84
|
if (dateInputInstance && this.state.hasFocus && !(cachedSelectionStart === 0 && cachedSelectionEnd === 0)) {
|
|
73
85
|
dateInputInstance.setSelectionRange(cachedSelectionStart, cachedSelectionEnd);
|
|
@@ -119,10 +131,11 @@ var DateInput = function (_React$Component) {
|
|
|
119
131
|
onKeyDown: this.onKeyDown,
|
|
120
132
|
onFocus: this.onFocus,
|
|
121
133
|
onBlur: this.onBlur,
|
|
122
|
-
inputMode: inputMode
|
|
134
|
+
inputMode: inputMode,
|
|
135
|
+
tabIndex: '0'
|
|
123
136
|
})
|
|
124
137
|
),
|
|
125
|
-
props.showClear
|
|
138
|
+
props.showClear && _react2['default'].createElement(
|
|
126
139
|
'a',
|
|
127
140
|
{
|
|
128
141
|
role: 'button',
|
|
@@ -130,7 +143,7 @@ var DateInput = function (_React$Component) {
|
|
|
130
143
|
onClick: this.onClear
|
|
131
144
|
},
|
|
132
145
|
clearIcon || _react2['default'].createElement('span', { className: prefixCls + '-clear-btn' })
|
|
133
|
-
)
|
|
146
|
+
)
|
|
134
147
|
);
|
|
135
148
|
};
|
|
136
149
|
|
|
@@ -155,17 +168,17 @@ DateInput.propTypes = {
|
|
|
155
168
|
};
|
|
156
169
|
|
|
157
170
|
var _initialiseProps = function _initialiseProps() {
|
|
158
|
-
var
|
|
171
|
+
var _this3 = this;
|
|
159
172
|
|
|
160
173
|
this.onClear = function () {
|
|
161
|
-
|
|
162
|
-
|
|
174
|
+
_this3.setState({ str: '' });
|
|
175
|
+
_this3.props.onClear(null);
|
|
163
176
|
};
|
|
164
177
|
|
|
165
178
|
this.onInputChange = function (event) {
|
|
166
179
|
var str = event.target.value;
|
|
167
|
-
var calendarStr = (0, _util.initializeStr)(str,
|
|
168
|
-
var _props =
|
|
180
|
+
var calendarStr = (0, _util.initializeStr)(str, _this3.state.localFormat) || '';
|
|
181
|
+
var _props = _this3.props,
|
|
169
182
|
disabledDate = _props.disabledDate,
|
|
170
183
|
format = _props.format,
|
|
171
184
|
onChange = _props.onChange,
|
|
@@ -173,32 +186,38 @@ var _initialiseProps = function _initialiseProps() {
|
|
|
173
186
|
|
|
174
187
|
// 没有内容,合法并直接退出
|
|
175
188
|
|
|
176
|
-
if (!calendarStr) {
|
|
177
|
-
|
|
178
|
-
|
|
189
|
+
if (!str || !calendarStr) {
|
|
190
|
+
console.log('没有内容,合法并直接退出');
|
|
191
|
+
_this3.setState({ isInputEmpty: true });
|
|
192
|
+
_this3.onClear();
|
|
179
193
|
return;
|
|
180
194
|
}
|
|
195
|
+
|
|
196
|
+
if (_this3.state.isInputEmpty) {
|
|
197
|
+
_this3.setState({ isInputEmpty: false });
|
|
198
|
+
}
|
|
199
|
+
|
|
181
200
|
var parsed = (0, _dayjs2['default'])(calendarStr, format[0]);
|
|
182
|
-
var value =
|
|
201
|
+
var value = _this3.props.value.clone();
|
|
183
202
|
value = value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
|
|
184
203
|
|
|
185
204
|
if (!value || disabledDate && disabledDate(value)) {
|
|
186
|
-
|
|
205
|
+
_this3.setState({ str: str });
|
|
187
206
|
return;
|
|
188
207
|
}
|
|
189
208
|
|
|
190
209
|
if (selectedValue !== value || selectedValue && value && !selectedValue.isSame(value)) {
|
|
191
|
-
|
|
210
|
+
_this3.setState({ str: str });
|
|
192
211
|
onChange(value);
|
|
193
212
|
}
|
|
194
213
|
};
|
|
195
214
|
|
|
196
215
|
this.onFocus = function () {
|
|
197
|
-
|
|
216
|
+
_this3.setState({ hasFocus: true });
|
|
198
217
|
};
|
|
199
218
|
|
|
200
219
|
this.onBlur = function () {
|
|
201
|
-
|
|
220
|
+
_this3.setState(function (prevState, prevProps) {
|
|
202
221
|
return {
|
|
203
222
|
hasFocus: false,
|
|
204
223
|
str: (0, _util.formatDate)(prevProps.value, prevProps.format)
|
|
@@ -208,7 +227,7 @@ var _initialiseProps = function _initialiseProps() {
|
|
|
208
227
|
|
|
209
228
|
this.onKeyDown = function (event) {
|
|
210
229
|
var keyCode = event.keyCode;
|
|
211
|
-
var _props2 =
|
|
230
|
+
var _props2 = _this3.props,
|
|
212
231
|
onSelect = _props2.onSelect,
|
|
213
232
|
value = _props2.value,
|
|
214
233
|
disabledDate = _props2.disabledDate;
|
|
@@ -216,14 +235,18 @@ var _initialiseProps = function _initialiseProps() {
|
|
|
216
235
|
if (keyCode === _KeyCode2['default'].ENTER && onSelect) {
|
|
217
236
|
var validateDate = !disabledDate || !disabledDate(value);
|
|
218
237
|
if (validateDate) {
|
|
219
|
-
|
|
238
|
+
if (_this3.state.isInputEmpty) {
|
|
239
|
+
onSelect(null);
|
|
240
|
+
} else {
|
|
241
|
+
onSelect(value.clone());
|
|
242
|
+
}
|
|
220
243
|
}
|
|
221
244
|
event.preventDefault();
|
|
222
245
|
}
|
|
223
246
|
};
|
|
224
247
|
|
|
225
248
|
this.getRootDOMNode = function () {
|
|
226
|
-
return _reactDom2['default'].findDOMNode(
|
|
249
|
+
return _reactDom2['default'].findDOMNode(_this3);
|
|
227
250
|
};
|
|
228
251
|
|
|
229
252
|
this.focus = function () {
|
package/lib/date/DateTBody.js
CHANGED
|
@@ -78,7 +78,8 @@ var DateTBody = function (_React$Component) {
|
|
|
78
78
|
dateRender = props.dateRender,
|
|
79
79
|
disabledDate = props.disabledDate,
|
|
80
80
|
hoverValue = props.hoverValue,
|
|
81
|
-
firstDayOfWeek = props.firstDayOfWeek
|
|
81
|
+
firstDayOfWeek = props.firstDayOfWeek,
|
|
82
|
+
currentStatus = props.currentStatus;
|
|
82
83
|
|
|
83
84
|
var iIndex = void 0;
|
|
84
85
|
var jIndex = void 0;
|
|
@@ -146,7 +147,7 @@ var DateTBody = function (_React$Component) {
|
|
|
146
147
|
for (jIndex = 0; jIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT; jIndex++) {
|
|
147
148
|
var next = null;
|
|
148
149
|
var last = null;
|
|
149
|
-
current = dateTable[passed];
|
|
150
|
+
current = (0, _util.syncCurrentTime)(dateTable[passed], currentStatus);
|
|
150
151
|
if (jIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT - 1) {
|
|
151
152
|
next = dateTable[passed + 1];
|
|
152
153
|
}
|
|
@@ -298,7 +299,8 @@ DateTBody.propTypes = {
|
|
|
298
299
|
value: _propTypes2['default'].object,
|
|
299
300
|
hoverValue: _propTypes2['default'].any,
|
|
300
301
|
showWeekNumber: _propTypes2['default'].bool,
|
|
301
|
-
firstDayOfWeek: _propTypes2['default'].string
|
|
302
|
+
firstDayOfWeek: _propTypes2['default'].string,
|
|
303
|
+
currentStatus: _propTypes2['default'].string
|
|
302
304
|
};
|
|
303
305
|
DateTBody.defaultProps = {
|
|
304
306
|
hoverValue: []
|
package/lib/util/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.isLeapYear = exports.DATE_FORMATS = exports.getCurrentTime = exports.getCurrentYear = exports.getCurrentMonth = exports.getCurrentDate = undefined;
|
|
4
|
+
exports.isLeapYear = exports.syncCurrentTime = exports.CALENDAR_STATUS = exports.DATE_FORMATS = exports.getCurrentTime = exports.getCurrentYear = exports.getCurrentMonth = exports.getCurrentDate = undefined;
|
|
5
5
|
|
|
6
6
|
var _extends2 = require('babel-runtime/helpers/extends');
|
|
7
7
|
|
|
@@ -62,6 +62,18 @@ var DATE_FORMATS = exports.DATE_FORMATS = {
|
|
|
62
62
|
Germany_Russia_etcAndTime: 'DD.MM.YYYY HH:mm'
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
+
var CALENDAR_STATUS = exports.CALENDAR_STATUS = {
|
|
66
|
+
SPECIFIC_TIME: 'specific_time',
|
|
67
|
+
CURRENT_TIME: 'current_time'
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
var syncCurrentTime = exports.syncCurrentTime = function syncCurrentTime(date, status) {
|
|
71
|
+
if (status === CALENDAR_STATUS.CURRENT_TIME) {
|
|
72
|
+
return date.hour((0, _dayjs2['default'])().hour()).minute((0, _dayjs2['default'])().minute()).second((0, _dayjs2['default'])().second());
|
|
73
|
+
}
|
|
74
|
+
return date;
|
|
75
|
+
};
|
|
76
|
+
|
|
65
77
|
var defaultDisabledTime = {
|
|
66
78
|
disabledHours: function disabledHours() {
|
|
67
79
|
return [];
|
|
@@ -513,7 +525,7 @@ function initializeStr(str, format) {
|
|
|
513
525
|
return '' + _day10 + dateDelimater + _month10 + dateDelimater + _year10;
|
|
514
526
|
} else if (inputStrLength >= 1 && inputStrLength <= 8) {
|
|
515
527
|
var _dateStr6 = inputStr.slice(0, 2);
|
|
516
|
-
var _monthStr6 = inputStr.slice(2, 4);
|
|
528
|
+
var _monthStr6 = inputStr.slice(2, 4) || getCurrentMonth();
|
|
517
529
|
var _yearStr6 = inputStr.slice(4, inputStr.length);
|
|
518
530
|
var _validateYear11 = validateCalendarYear(_yearStr6);
|
|
519
531
|
|
|
@@ -557,7 +569,7 @@ function initializeStr(str, format) {
|
|
|
557
569
|
return '' + _day12 + dateDelimater + _month12 + dateDelimater + _year12 + ' ' + time;
|
|
558
570
|
} else if (_datePart2.length >= 1 && _datePart2.length <= 8) {
|
|
559
571
|
var _dateStr7 = _datePart2.slice(0, 2);
|
|
560
|
-
var _monthStr7 = _datePart2.slice(2, 4);
|
|
572
|
+
var _monthStr7 = _datePart2.slice(2, 4) || getCurrentMonth();
|
|
561
573
|
var _yearStr7 = _datePart2.slice(4, _datePart2.length);
|
|
562
574
|
var _timeParts2 = tokenizeFormattedDate(inputStr, format);
|
|
563
575
|
time = validateTime(_timeParts2[1] + ':' + _timeParts2[2]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seafile/seafile-calendar",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32-alpha.1",
|
|
4
4
|
"description": "React Calendar",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -68,13 +68,13 @@
|
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@types/react": "^16.3.13",
|
|
70
70
|
"async": "~3.1.0",
|
|
71
|
+
"chokidar": "^4.0.3",
|
|
71
72
|
"dtslint": "^0.9.0",
|
|
72
73
|
"enzyme": "^3.3.0",
|
|
73
74
|
"enzyme-adapter-react-16": "^1.1.1",
|
|
74
75
|
"enzyme-to-json": "^3.3.1",
|
|
75
76
|
"jest": "^22.1.4",
|
|
76
77
|
"mockdate": "^2.0.1",
|
|
77
|
-
"pre-commit": "1.x",
|
|
78
78
|
"rc-dialog": "^7.0.0",
|
|
79
79
|
"rc-select": "^9.1.5",
|
|
80
80
|
"rc-time-picker": "^3.1.0",
|
|
@@ -85,9 +85,6 @@
|
|
|
85
85
|
"tslint": "^5.9.1",
|
|
86
86
|
"typescript": "^3.4.1"
|
|
87
87
|
},
|
|
88
|
-
"pre-commit": [
|
|
89
|
-
"lint"
|
|
90
|
-
],
|
|
91
88
|
"dependencies": {
|
|
92
89
|
"babel-runtime": "6.x",
|
|
93
90
|
"classnames": "2.x",
|