@seafile/seafile-calendar 0.0.29-gzc31 → 0.0.29-prop3.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/lib/Calendar.js CHANGED
@@ -180,13 +180,14 @@ var Calendar = function (_React$Component) {
180
180
 
181
181
  timePickerEle = _react2['default'].cloneElement(timePicker, timePickerProps);
182
182
  }
183
+ var calanderInputPlaceholder = dateInputPlaceholder || (Array.isArray(this.getFormat()) ? this.getFormat()[0] : this.getFormat());
183
184
 
184
185
  var dateInputElement = props.showDateInput ? _react2['default'].createElement(_DateInput2['default'], {
185
186
  format: this.getFormat(),
186
187
  key: 'date-input',
187
188
  value: value,
188
189
  locale: locale,
189
- placeholder: dateInputPlaceholder || this.getFormat()[0],
190
+ placeholder: calanderInputPlaceholder,
190
191
  showClear: true,
191
192
  disabledTime: disabledTime,
192
193
  disabledDate: disabledDate,
@@ -196,8 +197,7 @@ var Calendar = function (_React$Component) {
196
197
  onChange: this.onDateInputChange,
197
198
  onSelect: this.onDateInputSelect,
198
199
  clearIcon: clearIcon,
199
- inputMode: inputMode,
200
- showHourAndMinute: showHourAndMinute
200
+ inputMode: inputMode
201
201
  }) : null;
202
202
 
203
203
  var children = [];
@@ -434,7 +434,6 @@ var _initialiseProps = function _initialiseProps() {
434
434
  };
435
435
 
436
436
  this.onDateInputChange = function (value) {
437
- if (!value) return;
438
437
  _this2.onSelect(value, {
439
438
  source: 'dateInput'
440
439
  });
package/lib/Picker.js CHANGED
@@ -251,7 +251,6 @@ var _initialiseProps = function _initialiseProps() {
251
251
  open: open
252
252
  }, callback);
253
253
  }
254
- console.log(11111);
255
254
  onOpenChange(open);
256
255
  }
257
256
  };
@@ -111,7 +111,7 @@ var CalendarRightPanel = function (_React$Component) {
111
111
  'ul',
112
112
  null,
113
113
  this.times.map(function (time) {
114
- var parts = (0, _util.formatDateLocal)(selectedDate, _this2.state.localeFormat);
114
+ var parts = (0, _util.tokenizeFormattedDate)(selectedDate, _this2.state.localeFormat);
115
115
  var current = (0, _dayjs2['default'])(selectedDate + ' ' + time).year(parts[0]).month(parts[1] - 1).date(parts[2]); // eslint-disable-line max-len
116
116
  current = isZhcn ? current.locale('zh-cn') : current.locale('en-gb');
117
117
  return _react2['default'].createElement(
@@ -40,6 +40,10 @@ var _util = require('../util');
40
40
 
41
41
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
42
42
 
43
+ var customParseFormat = require('dayjs/plugin/customParseFormat');
44
+
45
+ _dayjs2['default'].extend(customParseFormat);
46
+
43
47
  var cachedSelectionStart = void 0;
44
48
  var cachedSelectionEnd = void 0;
45
49
  var dateInputInstance = void 0;
@@ -55,12 +59,11 @@ var DateInput = function (_React$Component) {
55
59
  _initialiseProps.call(_this);
56
60
 
57
61
  var selectedValue = props.selectedValue;
58
- var formatPrefix = _this.props.format[0];
62
+
59
63
  _this.state = {
60
64
  str: (0, _util.formatDate)(selectedValue, _this.props.format),
61
65
  hasFocus: false,
62
- localeFormat: formatPrefix,
63
- delimiter: (0, _util.delimate)(formatPrefix)
66
+ localFormat: _this.props.format[0]
64
67
  };
65
68
  return _this;
66
69
  }
@@ -81,30 +84,7 @@ var DateInput = function (_React$Component) {
81
84
  // when popup show, click body will call this, bug!
82
85
  var selectedValue = nextProps.selectedValue;
83
86
  if (!state.hasFocus) {
84
- var timeStr = (0, _util.formatDate)(selectedValue, nextProps.format).split(' ')[0];
85
- var parts = timeStr.split(state.delimiter);
86
- var timeParts = (0, _util.formatDate)(selectedValue, nextProps.format).split(' ')[1];
87
- if (parts.length === 3) {
88
- if (state.localeFormat === _util.DATE_FORMATS.ISO) {
89
- newState = { str: parts[0].padStart(4, 0) + '-' + parts[1] + '-' + parts[2] };
90
- } else if (state.localeFormat === _util.DATE_FORMATS.ISOAndTime) {
91
- newState = {
92
- str: parts[0].padStart(4, 0) + '-' + parts[1] + '-' + parts[2] + ' ' + (nextProps.showHourAndMinute ? timeParts : '') // eslint-disable-line max-len
93
- };
94
- } else if (state.localeFormat === _util.DATE_FORMATS.US) {
95
- newState = { str: Number(parts[0]) + '/' + Number(parts[1]) + '/' + parts[2].padStart(4, 0) };
96
- } else if (state.localeFormat === _util.DATE_FORMATS.USAndTime) {
97
- newState = {
98
- str: Number(parts[0]) + '/' + Number(parts[1]) + '/' + parts[2].padStart(4, 0) + ' ' + (nextProps.showHourAndMinute ? timeParts : '') // eslint-disable-line max-len
99
- };
100
- } else if (state.localeFormat === _util.DATE_FORMATS.European || state.localeFormat === _util.DATE_FORMATS.Germany_Russia_etc) {
101
- newState = { str: '' + Number(parts[0]) + state.delimiter + Number(parts[1]) + state.delimiter + parts[2].padStart(4, 0) }; // eslint-disable-line max-len
102
- } else if (state.localeFormat === _util.DATE_FORMATS.EuropeanAndTime || state.localeFormat === _util.DATE_FORMATS.Germany_Russia_etcAndTime) {
103
- newState = {
104
- str: '' + Number(parts[0]) + state.delimiter + Number(parts[1]) + state.delimiter + parts[2].padStart(4, 0) + ' ' + (nextProps.showHourAndMinute ? timeParts : '') // eslint-disable-line max-len
105
- };
106
- }
107
- }
87
+ newState = { str: (0, _util.formatDate)(selectedValue, nextProps.format) };
108
88
  }
109
89
 
110
90
  return newState;
@@ -171,64 +151,43 @@ DateInput.propTypes = {
171
151
  onSelect: _propTypes2['default'].func,
172
152
  selectedValue: _propTypes2['default'].object,
173
153
  clearIcon: _propTypes2['default'].node,
174
- inputMode: _propTypes2['default'].string,
175
- showHourAndMinute: _propTypes2['default'].bool
154
+ inputMode: _propTypes2['default'].string
176
155
  };
177
156
 
178
157
  var _initialiseProps = function _initialiseProps() {
179
158
  var _this2 = this;
180
159
 
181
160
  this.onClear = function () {
182
- _this2.setState({
183
- str: ''
184
- });
161
+ _this2.setState({ str: '' });
185
162
  _this2.props.onClear(null);
186
163
  };
187
164
 
188
165
  this.onInputChange = function (event) {
189
166
  var str = event.target.value;
190
- console.log('str', str);
191
- var cananderStr = (0, _util.normalizeDateInput)(str, _this2.state.localeFormat, _this2.state.delimiter);
167
+ var calendarStr = (0, _util.initializeStr)(str, _this2.state.localFormat) || '';
192
168
  var _props = _this2.props,
193
169
  disabledDate = _props.disabledDate,
170
+ format = _props.format,
194
171
  onChange = _props.onChange,
195
172
  selectedValue = _props.selectedValue;
196
173
 
197
- var parts = (0, _util.formatDateLocal)(cananderStr, _this2.state.localeFormat);
198
174
  // 没有内容,合法并直接退出
199
- console.log('cananderStr', cananderStr);
200
175
 
201
- if (!str) {
202
- console.log('我不想走进来');
176
+ if (!calendarStr) {
203
177
  onChange(null);
204
178
  _this2.setState({ str: '' });
205
179
  return;
206
180
  }
207
- // 不合法直接退出
208
- var format = (0, _util.getDateFormatByStr)(cananderStr, _this2.state.localeFormat);
209
- var parsed = (0, _dayjs2['default'])(cananderStr, format);
181
+ var parsed = (0, _dayjs2['default'])(calendarStr, format[0]);
210
182
  var value = _this2.props.value.clone();
211
- value.locale('zh-cn');
212
- if (_this2.state.localeFormat === _util.DATE_FORMATS.ISO || _this2.state.localeFormat === _util.DATE_FORMATS.ISOAndTime) {
213
- if (parts[0] && parts[0].length === 4 && (parts[0].slice(0, 3) === '000' || parts[0].slice(0, 2) === '00')) {
214
- value = value.year(parts[0]).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
215
- } else {
216
- value = value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
217
- }
218
- } else if (_this2.state.localeFormat === _util.DATE_FORMATS.European || _this2.state.localeFormat === _util.DATE_FORMATS.EuropeanAndTime || _this2.state.localeFormat === _util.DATE_FORMATS.US || _this2.state.localeFormat === _util.DATE_FORMATS.USAndTime || _this2.state.localeFormat === _util.DATE_FORMATS.Germany_Russia_etc || _this2.state.localeFormat === _util.DATE_FORMATS.Germany_Russia_etcAndTime) {
219
- if (parts[2] && parts[2].length === 4 && (parts[2].slice(0, 3) === '000' || parts[2].slice(0, 2) === '00')) {
220
- value = value.year(parts[2]).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
221
- } else {
222
- value = value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
223
- }
224
- }
183
+ value = value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
184
+
225
185
  if (!value || disabledDate && disabledDate(value)) {
226
186
  _this2.setState({ str: str });
227
187
  return;
228
188
  }
229
189
 
230
190
  if (selectedValue !== value || selectedValue && value && !selectedValue.isSame(value)) {
231
- console.log('成功🏅');
232
191
  _this2.setState({ str: str });
233
192
  onChange(value);
234
193
  }