@seafile/seafile-calendar 0.0.8882 → 0.0.88881

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/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: 0
112
+ currentStatus: 'selectDateTime'
113
113
  };
114
114
  return _this;
115
115
  }
@@ -154,8 +154,7 @@ var Calendar = function (_React$Component) {
154
154
  inputMode = props.inputMode,
155
155
  showHourAndMinute = props.showHourAndMinute,
156
156
  firstDayOfWeek = props.firstDayOfWeek,
157
- showWeekNumber = props.showWeekNumber,
158
- shouldDisplayCurrent = props.shouldDisplayCurrent;
157
+ showWeekNumber = props.showWeekNumber;
159
158
  var value = state.value,
160
159
  selectedValue = state.selectedValue,
161
160
  mode = state.mode,
@@ -184,7 +183,8 @@ var Calendar = function (_React$Component) {
184
183
  timePickerEle = _react2['default'].cloneElement(timePicker, timePickerProps);
185
184
  }
186
185
  var calendarInputPlaceholder = dateInputPlaceholder || (Array.isArray(this.getFormat()) ? this.getFormat()[0] : this.getFormat());
187
- var inputFormat = dateInputPlaceholder || (Array.isArray(this.getFormat()) ? this.getFormat() : [this.getFormat()]);
186
+ var inputFormat = Array.isArray(this.getFormat()) ? this.getFormat() : [this.getFormat()];
187
+
188
188
  var dateInputElement = props.showDateInput ? _react2['default'].createElement(_DateInput2['default'], {
189
189
  format: inputFormat,
190
190
  key: 'date-input',
@@ -192,7 +192,6 @@ var Calendar = function (_React$Component) {
192
192
  locale: locale,
193
193
  placeholder: calendarInputPlaceholder,
194
194
  showClear: true,
195
- shouldDisplayCurrent: shouldDisplayCurrent,
196
195
  disabledTime: disabledTime,
197
196
  disabledDate: disabledDate,
198
197
  onClear: this.onClear,
@@ -333,8 +332,7 @@ Calendar.propTypes = (0, _extends3['default'])({}, _CalendarMixin.calendarMixinP
333
332
  inputMode: _propTypes2['default'].string,
334
333
  onBlur: _propTypes2['default'].func,
335
334
  onClickRightPanelTime: _propTypes2['default'].func,
336
- firstDayOfWeek: _propTypes2['default'].string,
337
- shouldDisplayCurrent: _propTypes2['default'].bool
335
+ firstDayOfWeek: _propTypes2['default'].string
338
336
  });
339
337
  Calendar.defaultProps = (0, _extends3['default'])({}, _CalendarMixin.calendarMixinDefaultProps, _CommonMixin.defaultProp, {
340
338
  showToday: true,
@@ -366,6 +364,7 @@ var _initialiseProps = function _initialiseProps() {
366
364
  return undefined;
367
365
  }
368
366
  var keyCode = event.keyCode;
367
+ console.log('keyCode', keyCode);
369
368
  // mac
370
369
  var ctrlKey = event.ctrlKey || event.metaKey;
371
370
  var disabledDate = _this2.props.disabledDate;
@@ -429,7 +428,7 @@ var _initialiseProps = function _initialiseProps() {
429
428
  this.onClear = function () {
430
429
  _this2.onSelect(null);
431
430
  _this2.props.onClear();
432
- _this2.setState({ currentStatus: 1 });
431
+ _this2.setState({ currentStatus: 'todayTime' });
433
432
  };
434
433
 
435
434
  this.onOk = function () {
@@ -456,7 +455,7 @@ var _initialiseProps = function _initialiseProps() {
456
455
  var timePicker = _this2.props.timePicker;
457
456
  var selectedValue = _this2.state.selectedValue;
458
457
 
459
- _this2.setState({ currentStatus: 0 });
458
+ _this2.setState({ currentStatus: 'selectDateTime' });
460
459
  if (!selectedValue && timePicker) {
461
460
  var timePickerDefaultValue = timePicker.props.defaultValue;
462
461
  if (timePickerDefaultValue) {
package/lib/Picker.js CHANGED
@@ -232,7 +232,6 @@ var _initialiseProps = function _initialiseProps() {
232
232
  ref: _this2.saveCalendarRef,
233
233
  defaultValue: defaultValue || calendarProps.defaultValue,
234
234
  selectedValue: value,
235
- shouldDisplayCurrent: calendarProps.shouldDisplayCurrent,
236
235
  onKeyDown: _this2.onCalendarKeyDown,
237
236
  onOk: (0, _createChainedFunction2['default'])(calendarProps.onOk, _this2.onCalendarOk),
238
237
  onSelect: (0, _createChainedFunction2['default'])(calendarProps.onSelect, _this2.onCalendarSelect),
@@ -63,6 +63,7 @@ var DateInput = function (_React$Component) {
63
63
  _this.state = {
64
64
  str: (0, _util.formatDate)(selectedValue, _this.props.format),
65
65
  hasFocus: false,
66
+ emptyValue: false,
66
67
  localFormat: _this.props.format[0]
67
68
  };
68
69
  return _this;
@@ -151,8 +152,7 @@ DateInput.propTypes = {
151
152
  onSelect: _propTypes2['default'].func,
152
153
  selectedValue: _propTypes2['default'].object,
153
154
  clearIcon: _propTypes2['default'].node,
154
- inputMode: _propTypes2['default'].string,
155
- shouldDisplayCurrent: _propTypes2['default'].bool
155
+ inputMode: _propTypes2['default'].string
156
156
  };
157
157
 
158
158
  var _initialiseProps = function _initialiseProps() {
@@ -170,19 +170,15 @@ var _initialiseProps = function _initialiseProps() {
170
170
  disabledDate = _props.disabledDate,
171
171
  format = _props.format,
172
172
  onChange = _props.onChange,
173
- selectedValue = _props.selectedValue,
174
- shouldDisplayCurrent = _props.shouldDisplayCurrent;
173
+ selectedValue = _props.selectedValue;
175
174
  // 没有内容,合法并直接退出
176
175
 
177
176
  if (!str || !calendarStr) {
178
- if (shouldDisplayCurrent) {
179
- _this2.setState({ str: '' });
180
- onChange((0, _dayjs2['default'])());
181
- } else {
182
- _this2.onClear();
183
- }
177
+ _this2.setState({ emptyValue: true });
178
+ _this2.onClear();
184
179
  return;
185
180
  }
181
+ if (emptyValue) _this2.setState({ emptyValue: false });
186
182
  var parsed = (0, _dayjs2['default'])(calendarStr, format[0]);
187
183
  var value = _this2.props.value.clone();
188
184
  value = value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
@@ -218,9 +214,13 @@ var _initialiseProps = function _initialiseProps() {
218
214
  value = _props2.value,
219
215
  disabledDate = _props2.disabledDate;
220
216
 
217
+ console.log('keyCode', keyCode, value);
221
218
  if (keyCode === _KeyCode2['default'].ENTER && onSelect) {
222
219
  var validateDate = !disabledDate || !disabledDate(value);
223
220
  if (validateDate) {
221
+ if (emptyValue) {
222
+ onSelect(null);
223
+ }
224
224
  onSelect(value.clone());
225
225
  }
226
226
  event.preventDefault();
@@ -151,7 +151,7 @@ var DateTBody = function (_React$Component) {
151
151
  for (jIndex = 0; jIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT; jIndex++) {
152
152
  var next = null;
153
153
  var last = null;
154
- if (currentStatus === 1) {
154
+ if (currentStatus === 'todayTime') {
155
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
156
  } else {
157
157
  current = dateTable[passed];
@@ -308,7 +308,7 @@ DateTBody.propTypes = {
308
308
  hoverValue: _propTypes2['default'].any,
309
309
  showWeekNumber: _propTypes2['default'].bool,
310
310
  firstDayOfWeek: _propTypes2['default'].string,
311
- currentStatus: _propTypes2['default'].number
311
+ currentStatus: _propTypes2['default'].string
312
312
  };
313
313
  DateTBody.defaultProps = {
314
314
  hoverValue: []
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/seafile-calendar",
3
- "version": "0.0.8882",
3
+ "version": "0.0.88881",
4
4
  "description": "React Calendar",
5
5
  "keywords": [
6
6
  "react",