@seafile/seafile-calendar 0.0.32 → 0.0.91

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/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: _util.CALENDAR_STATUS.SPECIFIC_TIME
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: inputFormat,
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: inputFormat
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: _util.CALENDAR_STATUS.CURRENT_TIME });
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: _util.CALENDAR_STATUS.SPECIFIC_TIME });
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),
@@ -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,7 +151,8 @@ 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() {
@@ -170,20 +170,19 @@ var _initialiseProps = function _initialiseProps() {
170
170
  disabledDate = _props.disabledDate,
171
171
  format = _props.format,
172
172
  onChange = _props.onChange,
173
- selectedValue = _props.selectedValue;
174
-
173
+ selectedValue = _props.selectedValue,
174
+ shouldDisplayCurrent = _props.shouldDisplayCurrent;
175
175
  // 没有内容,合法并直接退出
176
176
 
177
177
  if (!str || !calendarStr) {
178
- _this2.setState({ isInputEmpty: true });
179
- _this2.onClear();
178
+ if (shouldDisplayCurrent) {
179
+ _this2.setState({ str: '' });
180
+ onChange((0, _dayjs2['default'])());
181
+ } else {
182
+ _this2.onClear();
183
+ }
180
184
  return;
181
185
  }
182
-
183
- if (_this2.state.isInputEmpty) {
184
- _this2.setState({ isInputEmpty: false });
185
- }
186
-
187
186
  var parsed = (0, _dayjs2['default'])(calendarStr, format[0]);
188
187
  var value = _this2.props.value.clone();
189
188
  value = value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
@@ -222,11 +221,7 @@ var _initialiseProps = function _initialiseProps() {
222
221
  if (keyCode === _KeyCode2['default'].ENTER && onSelect) {
223
222
  var validateDate = !disabledDate || !disabledDate(value);
224
223
  if (validateDate) {
225
- if (_this2.state.isInputEmpty) {
226
- onSelect(null);
227
- } else {
228
- onSelect(value.clone());
229
- }
224
+ onSelect(value.clone());
230
225
  }
231
226
  event.preventDefault();
232
227
  }
@@ -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
- current = (0, _util.syncCurrentTime)(dateTable[passed], currentStatus);
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'].string
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.syncCurrentTime = exports.CALENDAR_STATUS = exports.DATE_FORMATS = exports.getCurrentTime = exports.getCurrentYear = exports.getCurrentMonth = exports.getCurrentDate = undefined;
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.32",
3
+ "version": "0.0.91",
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",