@seafile/seafile-calendar 0.0.32 → 0.0.89
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/dist/rc-calendar.js +96 -101
- package/dist/rc-calendar.js.map +1 -1
- package/dist/rc-calendar.min.js +1 -1
- package/es/Calendar.js +11 -9
- package/es/Picker.js +1 -0
- package/es/date/DateInput.js +17 -17
- package/es/date/DateTBody.js +8 -3
- package/es/util/index.js +0 -12
- package/lib/Calendar.js +10 -8
- package/lib/Picker.js +1 -0
- package/lib/date/DateInput.js +17 -17
- package/lib/date/DateTBody.js +10 -2
- package/lib/util/index.js +1 -13
- package/package.json +1 -2
package/es/date/DateTBody.js
CHANGED
@@ -5,7 +5,8 @@ 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
|
8
|
+
import { getTitleString, getTodayTime } from '../util/';
|
9
|
+
import dayjs from 'dayjs';
|
9
10
|
|
10
11
|
var DATE_ROW_COLUMN_COUNT = DateConstants.DATE_ROW_COLUMN_COUNT,
|
11
12
|
DAY_NAME_TO_INDEX = DateConstants.DAY_NAME_TO_INDEX;
|
@@ -121,7 +122,11 @@ var DateTBody = function (_React$Component) {
|
|
121
122
|
for (jIndex = 0; jIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT; jIndex++) {
|
122
123
|
var next = null;
|
123
124
|
var last = null;
|
124
|
-
|
125
|
+
if (currentStatus === 1) {
|
126
|
+
current = dateTable[passed].hour(dayjs().hour()).minute(dayjs().minute()).second(dayjs().second()); // eslint-disable-line max-len
|
127
|
+
} else {
|
128
|
+
current = dateTable[passed];
|
129
|
+
}
|
125
130
|
if (jIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT - 1) {
|
126
131
|
next = dateTable[passed + 1];
|
127
132
|
}
|
@@ -274,7 +279,7 @@ DateTBody.propTypes = {
|
|
274
279
|
hoverValue: PropTypes.any,
|
275
280
|
showWeekNumber: PropTypes.bool,
|
276
281
|
firstDayOfWeek: PropTypes.string,
|
277
|
-
currentStatus: PropTypes.
|
282
|
+
currentStatus: PropTypes.number
|
278
283
|
};
|
279
284
|
DateTBody.defaultProps = {
|
280
285
|
hoverValue: []
|
package/es/util/index.js
CHANGED
@@ -27,18 +27,6 @@ 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
|
-
|
42
30
|
var defaultDisabledTime = {
|
43
31
|
disabledHours: function disabledHours() {
|
44
32
|
return [];
|
package/lib/Calendar.js
CHANGED
@@ -109,7 +109,7 @@ var Calendar = function (_React$Component) {
|
|
109
109
|
mode: _this.props.mode || 'date',
|
110
110
|
value: getMomentObjectIfValid(props.value) || getMomentObjectIfValid(props.defaultValue) || (0, _dayjs2['default'])(),
|
111
111
|
selectedValue: props.selectedValue || props.defaultSelectedValue,
|
112
|
-
currentStatus:
|
112
|
+
currentStatus: 0
|
113
113
|
};
|
114
114
|
return _this;
|
115
115
|
}
|
@@ -154,7 +154,8 @@ var Calendar = function (_React$Component) {
|
|
154
154
|
inputMode = props.inputMode,
|
155
155
|
showHourAndMinute = props.showHourAndMinute,
|
156
156
|
firstDayOfWeek = props.firstDayOfWeek,
|
157
|
-
showWeekNumber = props.showWeekNumber
|
157
|
+
showWeekNumber = props.showWeekNumber,
|
158
|
+
shouldDisplayCurrent = props.shouldDisplayCurrent;
|
158
159
|
var value = state.value,
|
159
160
|
selectedValue = state.selectedValue,
|
160
161
|
mode = state.mode,
|
@@ -183,15 +184,15 @@ var Calendar = function (_React$Component) {
|
|
183
184
|
timePickerEle = _react2['default'].cloneElement(timePicker, timePickerProps);
|
184
185
|
}
|
185
186
|
var calendarInputPlaceholder = dateInputPlaceholder || (Array.isArray(this.getFormat()) ? this.getFormat()[0] : this.getFormat());
|
186
|
-
var inputFormat = Array.isArray(this.getFormat()) ? this.getFormat() : [this.getFormat()];
|
187
187
|
|
188
188
|
var dateInputElement = props.showDateInput ? _react2['default'].createElement(_DateInput2['default'], {
|
189
|
-
format:
|
189
|
+
format: this.getFormat(),
|
190
190
|
key: 'date-input',
|
191
191
|
value: value,
|
192
192
|
locale: locale,
|
193
193
|
placeholder: calendarInputPlaceholder,
|
194
194
|
showClear: true,
|
195
|
+
shouldDisplayCurrent: shouldDisplayCurrent,
|
195
196
|
disabledTime: disabledTime,
|
196
197
|
disabledDate: disabledDate,
|
197
198
|
onClear: this.onClear,
|
@@ -284,7 +285,7 @@ var Calendar = function (_React$Component) {
|
|
284
285
|
onSelect: this.onDateTableSelect,
|
285
286
|
onClickRightPanelTime: onClickRightPanelTime,
|
286
287
|
defaultMinutesTime: this.props.defaultMinutesTime,
|
287
|
-
format:
|
288
|
+
format: this.getFormat()
|
288
289
|
})
|
289
290
|
)
|
290
291
|
));
|
@@ -332,7 +333,8 @@ Calendar.propTypes = (0, _extends3['default'])({}, _CalendarMixin.calendarMixinP
|
|
332
333
|
inputMode: _propTypes2['default'].string,
|
333
334
|
onBlur: _propTypes2['default'].func,
|
334
335
|
onClickRightPanelTime: _propTypes2['default'].func,
|
335
|
-
firstDayOfWeek: _propTypes2['default'].string
|
336
|
+
firstDayOfWeek: _propTypes2['default'].string,
|
337
|
+
shouldDisplayCurrent: _propTypes2['default'].bool
|
336
338
|
});
|
337
339
|
Calendar.defaultProps = (0, _extends3['default'])({}, _CalendarMixin.calendarMixinDefaultProps, _CommonMixin.defaultProp, {
|
338
340
|
showToday: true,
|
@@ -427,7 +429,7 @@ var _initialiseProps = function _initialiseProps() {
|
|
427
429
|
this.onClear = function () {
|
428
430
|
_this2.onSelect(null);
|
429
431
|
_this2.props.onClear();
|
430
|
-
_this2.setState({ currentStatus:
|
432
|
+
_this2.setState({ currentStatus: 1 });
|
431
433
|
};
|
432
434
|
|
433
435
|
this.onOk = function () {
|
@@ -454,7 +456,7 @@ var _initialiseProps = function _initialiseProps() {
|
|
454
456
|
var timePicker = _this2.props.timePicker;
|
455
457
|
var selectedValue = _this2.state.selectedValue;
|
456
458
|
|
457
|
-
_this2.setState({ currentStatus:
|
459
|
+
_this2.setState({ currentStatus: 0 });
|
458
460
|
if (!selectedValue && timePicker) {
|
459
461
|
var timePickerDefaultValue = timePicker.props.defaultValue;
|
460
462
|
if (timePickerDefaultValue) {
|
package/lib/Picker.js
CHANGED
@@ -232,6 +232,7 @@ var _initialiseProps = function _initialiseProps() {
|
|
232
232
|
ref: _this2.saveCalendarRef,
|
233
233
|
defaultValue: defaultValue || calendarProps.defaultValue,
|
234
234
|
selectedValue: value,
|
235
|
+
shouldDisplayCurrent: calendarProps.shouldDisplayCurrent,
|
235
236
|
onKeyDown: _this2.onCalendarKeyDown,
|
236
237
|
onOk: (0, _createChainedFunction2['default'])(calendarProps.onOk, _this2.onCalendarOk),
|
237
238
|
onSelect: (0, _createChainedFunction2['default'])(calendarProps.onSelect, _this2.onCalendarSelect),
|
package/lib/date/DateInput.js
CHANGED
@@ -63,7 +63,6 @@ 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,
|
67
66
|
localFormat: _this.props.format[0]
|
68
67
|
};
|
69
68
|
return _this;
|
@@ -152,13 +151,15 @@ DateInput.propTypes = {
|
|
152
151
|
onSelect: _propTypes2['default'].func,
|
153
152
|
selectedValue: _propTypes2['default'].object,
|
154
153
|
clearIcon: _propTypes2['default'].node,
|
155
|
-
inputMode: _propTypes2['default'].string
|
154
|
+
inputMode: _propTypes2['default'].string,
|
155
|
+
shouldDisplayCurrent: _propTypes2['default'].bool
|
156
156
|
};
|
157
157
|
|
158
158
|
var _initialiseProps = function _initialiseProps() {
|
159
159
|
var _this2 = this;
|
160
160
|
|
161
161
|
this.onClear = function () {
|
162
|
+
console.log('onClear');
|
162
163
|
_this2.setState({ str: '' });
|
163
164
|
_this2.props.onClear(null);
|
164
165
|
};
|
@@ -170,20 +171,23 @@ var _initialiseProps = function _initialiseProps() {
|
|
170
171
|
disabledDate = _props.disabledDate,
|
171
172
|
format = _props.format,
|
172
173
|
onChange = _props.onChange,
|
173
|
-
selectedValue = _props.selectedValue
|
174
|
-
|
174
|
+
selectedValue = _props.selectedValue,
|
175
|
+
shouldDisplayCurrent = _props.shouldDisplayCurrent;
|
175
176
|
// 没有内容,合法并直接退出
|
176
177
|
|
177
|
-
|
178
|
-
|
179
|
-
_this2.onClear();
|
180
|
-
return;
|
181
|
-
}
|
178
|
+
console.log('str', str);
|
179
|
+
console.log('calendarStr', calendarStr);
|
182
180
|
|
183
|
-
if (
|
184
|
-
|
181
|
+
if (!str) {
|
182
|
+
console.log('没有内容,合法并直接退出');
|
183
|
+
if (shouldDisplayCurrent) {
|
184
|
+
_this2.setState({ str: '' });
|
185
|
+
onChange((0, _dayjs2['default'])());
|
186
|
+
} else {
|
187
|
+
_this2.onClear();
|
188
|
+
}
|
189
|
+
return;
|
185
190
|
}
|
186
|
-
|
187
191
|
var parsed = (0, _dayjs2['default'])(calendarStr, format[0]);
|
188
192
|
var value = _this2.props.value.clone();
|
189
193
|
value = value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
|
@@ -222,11 +226,7 @@ var _initialiseProps = function _initialiseProps() {
|
|
222
226
|
if (keyCode === _KeyCode2['default'].ENTER && onSelect) {
|
223
227
|
var validateDate = !disabledDate || !disabledDate(value);
|
224
228
|
if (validateDate) {
|
225
|
-
|
226
|
-
onSelect(null);
|
227
|
-
} else {
|
228
|
-
onSelect(value.clone());
|
229
|
-
}
|
229
|
+
onSelect(value.clone());
|
230
230
|
}
|
231
231
|
event.preventDefault();
|
232
232
|
}
|
package/lib/date/DateTBody.js
CHANGED
@@ -32,6 +32,10 @@ var _DateConstants2 = _interopRequireDefault(_DateConstants);
|
|
32
32
|
|
33
33
|
var _util = require('../util/');
|
34
34
|
|
35
|
+
var _dayjs = require('dayjs');
|
36
|
+
|
37
|
+
var _dayjs2 = _interopRequireDefault(_dayjs);
|
38
|
+
|
35
39
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
36
40
|
|
37
41
|
var DATE_ROW_COLUMN_COUNT = _DateConstants2['default'].DATE_ROW_COLUMN_COUNT,
|
@@ -147,7 +151,11 @@ var DateTBody = function (_React$Component) {
|
|
147
151
|
for (jIndex = 0; jIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT; jIndex++) {
|
148
152
|
var next = null;
|
149
153
|
var last = null;
|
150
|
-
|
154
|
+
if (currentStatus === 1) {
|
155
|
+
current = dateTable[passed].hour((0, _dayjs2['default'])().hour()).minute((0, _dayjs2['default'])().minute()).second((0, _dayjs2['default'])().second()); // eslint-disable-line max-len
|
156
|
+
} else {
|
157
|
+
current = dateTable[passed];
|
158
|
+
}
|
151
159
|
if (jIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT - 1) {
|
152
160
|
next = dateTable[passed + 1];
|
153
161
|
}
|
@@ -300,7 +308,7 @@ DateTBody.propTypes = {
|
|
300
308
|
hoverValue: _propTypes2['default'].any,
|
301
309
|
showWeekNumber: _propTypes2['default'].bool,
|
302
310
|
firstDayOfWeek: _propTypes2['default'].string,
|
303
|
-
currentStatus: _propTypes2['default'].
|
311
|
+
currentStatus: _propTypes2['default'].number
|
304
312
|
};
|
305
313
|
DateTBody.defaultProps = {
|
306
314
|
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.
|
4
|
+
exports.isLeapYear = 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,18 +62,6 @@ 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
|
-
|
77
65
|
var defaultDisabledTime = {
|
78
66
|
disabledHours: function disabledHours() {
|
79
67
|
return [];
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@seafile/seafile-calendar",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.89",
|
4
4
|
"description": "React Calendar",
|
5
5
|
"keywords": [
|
6
6
|
"react",
|
@@ -68,7 +68,6 @@
|
|
68
68
|
"devDependencies": {
|
69
69
|
"@types/react": "^16.3.13",
|
70
70
|
"async": "~3.1.0",
|
71
|
-
"chokidar": "^4.0.3",
|
72
71
|
"dtslint": "^0.9.0",
|
73
72
|
"enzyme": "^3.3.0",
|
74
73
|
"enzyme-adapter-react-16": "^1.1.1",
|