@seafile/seafile-calendar 0.0.8883 → 0.0.88882

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,
@@ -193,7 +192,6 @@ var Calendar = function (_React$Component) {
193
192
  locale: locale,
194
193
  placeholder: calendarInputPlaceholder,
195
194
  showClear: true,
196
- shouldDisplayCurrent: shouldDisplayCurrent,
197
195
  disabledTime: disabledTime,
198
196
  disabledDate: disabledDate,
199
197
  onClear: this.onClear,
@@ -334,8 +332,7 @@ Calendar.propTypes = (0, _extends3['default'])({}, _CalendarMixin.calendarMixinP
334
332
  inputMode: _propTypes2['default'].string,
335
333
  onBlur: _propTypes2['default'].func,
336
334
  onClickRightPanelTime: _propTypes2['default'].func,
337
- firstDayOfWeek: _propTypes2['default'].string,
338
- shouldDisplayCurrent: _propTypes2['default'].bool
335
+ firstDayOfWeek: _propTypes2['default'].string
339
336
  });
340
337
  Calendar.defaultProps = (0, _extends3['default'])({}, _CalendarMixin.calendarMixinDefaultProps, _CommonMixin.defaultProp, {
341
338
  showToday: true,
@@ -367,6 +364,7 @@ var _initialiseProps = function _initialiseProps() {
367
364
  return undefined;
368
365
  }
369
366
  var keyCode = event.keyCode;
367
+ console.log('keyCode', keyCode);
370
368
  // mac
371
369
  var ctrlKey = event.ctrlKey || event.metaKey;
372
370
  var disabledDate = _this2.props.disabledDate;
@@ -430,7 +428,7 @@ var _initialiseProps = function _initialiseProps() {
430
428
  this.onClear = function () {
431
429
  _this2.onSelect(null);
432
430
  _this2.props.onClear();
433
- _this2.setState({ currentStatus: 1 });
431
+ _this2.setState({ currentStatus: 'todayTime' });
434
432
  };
435
433
 
436
434
  this.onOk = function () {
@@ -457,7 +455,7 @@ var _initialiseProps = function _initialiseProps() {
457
455
  var timePicker = _this2.props.timePicker;
458
456
  var selectedValue = _this2.state.selectedValue;
459
457
 
460
- _this2.setState({ currentStatus: 0 });
458
+ _this2.setState({ currentStatus: 'selectDateTime' });
461
459
  if (!selectedValue && timePicker) {
462
460
  var timePickerDefaultValue = timePicker.props.defaultValue;
463
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 (_this2.state.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,10 +214,15 @@ 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) {
224
- onSelect(value.clone());
221
+ if (_this2.state.emptyValue) {
222
+ onSelect(null);
223
+ } else {
224
+ onSelect(value.clone());
225
+ }
225
226
  }
226
227
  event.preventDefault();
227
228
  }
@@ -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.8883",
3
+ "version": "0.0.88882",
4
4
  "description": "React Calendar",
5
5
  "keywords": [
6
6
  "react",