@seafile/seafile-calendar 1.0.1-beta.4 → 1.0.2-alpha.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/es/Calendar.js CHANGED
@@ -79,8 +79,6 @@ var Calendar = function (_React$Component) {
79
79
  };
80
80
 
81
81
  Calendar.prototype.render = function render() {
82
- var _this2 = this;
83
-
84
82
  var props = this.props,
85
83
  state = this.state;
86
84
  var locale = props.locale,
@@ -185,7 +183,11 @@ var Calendar = function (_React$Component) {
185
183
  showTimeControls && React.createElement(
186
184
  'div',
187
185
  { className: prefixCls + '-time-input-col' },
188
- timeInputTopElement
186
+ React.createElement(
187
+ 'div',
188
+ { className: prefixCls + '-time-input' },
189
+ timeInputTopElement
190
+ )
189
191
  )
190
192
  ),
191
193
  React.createElement(
@@ -238,9 +240,7 @@ var Calendar = function (_React$Component) {
238
240
  value: value,
239
241
  selectedValue: selectedValue,
240
242
  locale: locale,
241
- onSelect: function onSelect(v) {
242
- return _this2.onDateTableSelect(v);
243
- },
243
+ onSelect: this.onDateTableSelect,
244
244
  onClickRightPanelTime: onClickRightPanelTime,
245
245
  defaultMinutesTime: this.props.defaultMinutesTime,
246
246
  format: inputFormat
@@ -327,14 +327,14 @@ Calendar.defaultProps = _extends({}, calendarMixinDefaultProps, defaultProp, {
327
327
  });
328
328
 
329
329
  var _initialiseProps = function _initialiseProps() {
330
- var _this3 = this;
330
+ var _this2 = this;
331
331
 
332
332
  this.onPanelChange = function (value, mode) {
333
- var props = _this3.props,
334
- state = _this3.state;
333
+ var props = _this2.props,
334
+ state = _this2.state;
335
335
 
336
336
  if (!('mode' in props)) {
337
- _this3.setState({ mode: mode });
337
+ _this2.setState({ mode: mode });
338
338
  }
339
339
  props.onPanelChange(value || state.value, mode);
340
340
  };
@@ -346,109 +346,112 @@ var _initialiseProps = function _initialiseProps() {
346
346
  var keyCode = event.keyCode;
347
347
  // mac
348
348
  var ctrlKey = event.ctrlKey || event.metaKey;
349
- var disabledDate = _this3.props.disabledDate;
350
- var value = _this3.state.value;
349
+ var disabledDate = _this2.props.disabledDate;
350
+ var value = _this2.state.value;
351
351
 
352
352
  switch (keyCode) {
353
353
  case KeyCode.DOWN:
354
- _this3.goTime(1, 'weeks');
354
+ _this2.goTime(1, 'weeks');
355
355
  event.preventDefault();
356
356
  return 1;
357
357
  case KeyCode.UP:
358
- _this3.goTime(-1, 'weeks');
358
+ _this2.goTime(-1, 'weeks');
359
359
  event.preventDefault();
360
360
  return 1;
361
361
  case KeyCode.LEFT:
362
362
  if (ctrlKey) {
363
- _this3.goTime(-1, 'years');
363
+ _this2.goTime(-1, 'years');
364
364
  } else {
365
- _this3.goTime(-1, 'days');
365
+ _this2.goTime(-1, 'days');
366
366
  }
367
367
  event.preventDefault();
368
368
  return 1;
369
369
  case KeyCode.RIGHT:
370
370
  if (ctrlKey) {
371
- _this3.goTime(1, 'years');
371
+ _this2.goTime(1, 'years');
372
372
  } else {
373
- _this3.goTime(1, 'days');
373
+ _this2.goTime(1, 'days');
374
374
  }
375
375
  event.preventDefault();
376
376
  return 1;
377
377
  case KeyCode.HOME:
378
- _this3.setValue(goStartMonth(_this3.state.value));
378
+ _this2.setValue(goStartMonth(_this2.state.value));
379
379
  event.preventDefault();
380
380
  return 1;
381
381
  case KeyCode.END:
382
- _this3.setValue(goEndMonth(_this3.state.value));
382
+ _this2.setValue(goEndMonth(_this2.state.value));
383
383
  event.preventDefault();
384
384
  return 1;
385
385
  case KeyCode.PAGE_DOWN:
386
- _this3.goTime(1, 'month');
386
+ _this2.goTime(1, 'month');
387
387
  event.preventDefault();
388
388
  return 1;
389
389
  case KeyCode.PAGE_UP:
390
- _this3.goTime(-1, 'month');
390
+ _this2.goTime(-1, 'month');
391
391
  event.preventDefault();
392
392
  return 1;
393
393
  case KeyCode.ENTER:
394
394
  if (!disabledDate || !disabledDate(value)) {
395
- _this3.onSelect(value, {
395
+ _this2.onSelect(value, {
396
396
  source: 'keyboard'
397
397
  });
398
398
  }
399
399
  event.preventDefault();
400
400
  return 1;
401
401
  default:
402
- _this3.props.onKeyDown(event);
402
+ _this2.props.onKeyDown(event);
403
403
  return 1;
404
404
  }
405
405
  };
406
406
 
407
407
  this.onClear = function () {
408
- _this3.onSelect(null);
409
- _this3.props.onClear();
410
- _this3.setState({ currentStatus: CALENDAR_STATUS.CURRENT_TIME });
408
+ _this2.onSelect(null);
409
+ _this2.props.onClear();
410
+ _this2.setState({ currentStatus: CALENDAR_STATUS.CURRENT_TIME });
411
411
  };
412
412
 
413
413
  this.onOk = function () {
414
- var selectedValue = _this3.state.selectedValue;
414
+ var selectedValue = _this2.state.selectedValue;
415
415
 
416
- if (_this3.isAllowedDate(selectedValue)) {
417
- _this3.props.onOk(selectedValue);
416
+ if (_this2.isAllowedDate(selectedValue)) {
417
+ _this2.props.onOk(selectedValue);
418
418
  }
419
419
  };
420
420
 
421
421
  this.onDateInputChange = function (value) {
422
- _this3.onSelect(value, {
422
+ var now = dayjs();
423
+ if (value && value.hour() === 0 && value.minute() === 0 && value.second() === 0) {
424
+ value = value.hour(now.hour()).minute(now.minute()).second(now.second());
425
+ }
426
+ _this2.onSelect(value, {
423
427
  source: 'dateInput'
424
428
  });
425
429
  };
426
430
 
427
431
  this.onDateInputSelect = function (value) {
428
- _this3.onSelect(value, {
432
+ var now = dayjs();
433
+ if (value && value.hour() === 0 && value.minute() === 0 && value.second() === 0) {
434
+ value = value.hour(now.hour()).minute(now.minute()).second(now.second());
435
+ }
436
+ _this2.onSelect(value, {
429
437
  source: 'dateInputSelect'
430
438
  });
431
439
  };
432
440
 
433
441
  this.onDateTableSelect = function (value) {
434
- var timePicker = _this3.props.timePicker;
435
- var selectedValue = _this3.state.selectedValue;
436
-
437
- _this3.setState({ currentStatus: CALENDAR_STATUS.SPECIFIC_TIME });
438
- if (!selectedValue && timePicker) {
439
- var timePickerDefaultValue = timePicker.props.defaultValue;
440
- if (timePickerDefaultValue) {
441
- syncTime(timePickerDefaultValue, value);
442
- }
442
+ _this2.setState({ currentStatus: CALENDAR_STATUS.SPECIFIC_TIME });
443
+ var now = dayjs();
444
+ if (value && value.hour() === 0 && value.minute() === 0 && value.second() === 0) {
445
+ value = value.hour(now.hour()).minute(now.minute()).second(now.second());
443
446
  }
444
- _this3.onSelect(value);
447
+ _this2.onSelect(value);
445
448
  };
446
449
 
447
450
  this.onToday = function () {
448
- var value = _this3.state.value;
451
+ var value = _this2.state.value;
449
452
 
450
453
  var now = getTodayTime(value);
451
- _this3.onSelect(now, {
454
+ _this2.onSelect(now, {
452
455
  source: 'todayButton'
453
456
  });
454
457
  };
@@ -457,41 +460,41 @@ var _initialiseProps = function _initialiseProps() {
457
460
  setTimeout(function () {
458
461
  var dateInput = DateInput.getInstance();
459
462
  var timeInput = TimeInput.getInstance && TimeInput.getInstance();
460
- var rootInstance = _this3.rootInstance;
463
+ var rootInstance = _this2.rootInstance;
461
464
 
462
465
  if (!rootInstance || rootInstance.contains(document.activeElement) || dateInput && dateInput.contains(document.activeElement) || timeInput && timeInput.contains && timeInput.contains(document.activeElement)) {
463
466
  // focused element is still part of Calendar
464
467
  return;
465
468
  }
466
469
 
467
- if (_this3.props.onBlur) {
468
- _this3.props.onBlur(event);
470
+ if (_this2.props.onBlur) {
471
+ _this2.props.onBlur(event);
469
472
  }
470
473
  }, 0);
471
474
  };
472
475
 
473
476
  this.onTimeInputChange = function (value) {
474
- _this3.onSelect(value, { source: 'timeInputChange' });
477
+ _this2.onSelect(value, { source: 'timeInputChange' });
475
478
  };
476
479
 
477
480
  this.onTimeInputSelect = function (value) {
478
- _this3.onSelect(value, { source: 'timeInputSelect' });
481
+ _this2.onSelect(value, { source: 'timeInputSelect' });
479
482
  };
480
483
 
481
484
  this.getRootDOMNode = function () {
482
- return ReactDOM.findDOMNode(_this3);
485
+ return ReactDOM.findDOMNode(_this2);
483
486
  };
484
487
 
485
488
  this.openTimePicker = function () {
486
- _this3.onPanelChange(null, 'time');
489
+ _this2.onPanelChange(null, 'time');
487
490
  };
488
491
 
489
492
  this.closeTimePicker = function () {
490
- _this3.onPanelChange(null, 'date');
493
+ _this2.onPanelChange(null, 'date');
491
494
  };
492
495
 
493
496
  this.goTime = function (direction, unit) {
494
- _this3.setValue(goTime(_this3.state.value, direction, unit));
497
+ _this2.setValue(goTime(_this2.state.value, direction, unit));
495
498
  };
496
499
  };
497
500
 
@@ -100,7 +100,7 @@ var CalendarHeader = function (_React$Component) {
100
100
  { className: prefixCls + '-header' },
101
101
  React.createElement(
102
102
  'div',
103
- { style: { position: 'relative' } },
103
+ { style: { position: 'relative', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center' } },
104
104
  showIf(enablePrev && !showTimePicker, React.createElement('a', {
105
105
  className: prefixCls + '-prev-year-btn',
106
106
  role: 'button',
@@ -26,9 +26,10 @@ var CalendarRightPanel = function (_React$Component) {
26
26
  };
27
27
 
28
28
  _this.onSelectMinute = function (minute) {
29
- var base = _this.props.selectedValue || _this.props.value || _this.state.highlightTime || dayjs();
30
- var h = parseInt(_this.getSelectedHour(), 10) || 0;
31
- var m = parseInt(minute, 10) || 0;
29
+ var base = _this.props.selectedValue || _this.state.highlightTime || _this.props.value || dayjs();
30
+ var selectedHour = _this.getSelectedHour();
31
+ var h = selectedHour !== null ? parseInt(selectedHour, 10) : dayjs().hour();
32
+ var m = parseInt(minute, 10);
32
33
  var current = base.clone().hour(h).minute(m);
33
34
  _this.skipScrollUpdates = 2;
34
35
  _this.setState({ highlightTime: current });
@@ -39,9 +40,10 @@ var CalendarRightPanel = function (_React$Component) {
39
40
  };
40
41
 
41
42
  _this.onSelectHour = function (hour) {
42
- var base = _this.props.selectedValue || _this.props.value || _this.state.highlightTime || dayjs();
43
- var h = parseInt(hour, 10) || 0;
44
- var m = parseInt(_this.getSelectedMinute(), 10) || 0;
43
+ var base = _this.props.selectedValue || _this.state.highlightTime || dayjs();
44
+ var h = parseInt(hour, 10);
45
+ var selectedMinute = _this.getSelectedMinute();
46
+ var m = selectedMinute !== null ? parseInt(selectedMinute, 10) : dayjs().minute();
45
47
  var current = base.clone().hour(h).minute(m);
46
48
  _this.skipScrollUpdates = 2;
47
49
  _this.setState({ highlightTime: current });
@@ -62,27 +64,23 @@ var CalendarRightPanel = function (_React$Component) {
62
64
 
63
65
  _this.getSelectedHour = function () {
64
66
  var highlightTime = _this.state.highlightTime;
65
- var _this$props = _this.props,
66
- value = _this$props.value,
67
- selectedValue = _this$props.selectedValue;
67
+ var selectedValue = _this.props.selectedValue;
68
68
 
69
- var v = highlightTime || selectedValue || value;
70
- return v ? v.format('HH') : '00';
69
+ var v = highlightTime || selectedValue || null;
70
+ return v ? v.format('HH') : null;
71
71
  };
72
72
 
73
73
  _this.getSelectedMinute = function () {
74
74
  var highlightTime = _this.state.highlightTime;
75
- var _this$props2 = _this.props,
76
- value = _this$props2.value,
77
- selectedValue = _this$props2.selectedValue;
75
+ var selectedValue = _this.props.selectedValue;
78
76
 
79
- var v = highlightTime || selectedValue || value;
80
- return v ? v.format('mm') : '00';
77
+ var v = highlightTime || selectedValue || null;
78
+ return v ? v.format('mm') : null;
81
79
  };
82
80
 
83
81
  var format = Array.isArray(_this.props.format) ? _this.props.format[0] : _this.props.format;
84
82
  _this.state = {
85
- highlightTime: _this.props.selectedValue || _this.props.value || null,
83
+ highlightTime: _this.props.selectedValue || null,
86
84
  localeFormat: format
87
85
  };
88
86
 
@@ -109,10 +107,9 @@ var CalendarRightPanel = function (_React$Component) {
109
107
 
110
108
  var _props = this.props,
111
109
  defaultMinutesTime = _props.defaultMinutesTime,
112
- value = _props.value,
113
110
  selectedValue = _props.selectedValue;
114
111
 
115
- var baseTime = defaultMinutesTime || (selectedValue || value ? (selectedValue || value).format('HH:mm') : '00:00');
112
+ var baseTime = defaultMinutesTime || (selectedValue ? selectedValue.format('HH:mm') : dayjs().format('HH:mm'));
116
113
  var base = baseTime.split(':');
117
114
  var hIdx = this.hours.findIndex(function (h) {
118
115
  return h === base[0];
@@ -137,8 +134,8 @@ var CalendarRightPanel = function (_React$Component) {
137
134
  CalendarRightPanel.prototype.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
138
135
  var _this3 = this;
139
136
 
140
- var prevV = prevState.highlightTime || prevProps.selectedValue || prevProps.value;
141
- var currV = this.state.highlightTime || this.props.selectedValue || this.props.value;
137
+ var prevV = prevState.highlightTime || prevProps.selectedValue || dayjs();
138
+ var currV = this.state.highlightTime || this.props.selectedValue || dayjs();
142
139
 
143
140
  var prevH = prevV ? prevV.format('HH') : '00';
144
141
  var prevM = prevV ? prevV.format('mm') : '00';
@@ -184,15 +181,20 @@ var CalendarRightPanel = function (_React$Component) {
184
181
 
185
182
  var selectedHour = this.getSelectedHour();
186
183
  var selectedMinute = this.getSelectedMinute();
184
+ var currentHour = dayjs().format('HH');
185
+ var currentMinute = dayjs().format('mm');
186
+ var displayHour = selectedHour || currentHour;
187
+ var displayMinute = selectedMinute || currentMinute;
188
+
187
189
  return React.createElement(
188
190
  'div',
189
191
  { className: prefixCls + '-right-panel' },
190
192
  React.createElement(
191
193
  'div',
192
- { className: prefixCls + '-right-panel-time-header' },
193
- selectedHour,
194
+ { className: prefixCls + '-right-panel-header ' + prefixCls + '-header' },
195
+ displayHour,
194
196
  ':',
195
- selectedMinute
197
+ displayMinute
196
198
  ),
197
199
  React.createElement(
198
200
  'div',
@@ -204,6 +206,9 @@ var CalendarRightPanel = function (_React$Component) {
204
206
  'ul',
205
207
  null,
206
208
  this.hours.map(function (h) {
209
+ var isSelected = selectedHour && h === selectedHour;
210
+ var isCurrent = !selectedHour && h === currentHour;
211
+ var className = prefixCls + '-right-panel-item-text ' + (isSelected ? prefixCls + '-right-panel-item-selected' : '') + ' ' + (isCurrent ? prefixCls + '-right-panel-item-current' : '');
207
212
  return React.createElement(
208
213
  'li',
209
214
  {
@@ -211,10 +216,14 @@ var CalendarRightPanel = function (_React$Component) {
211
216
  onClick: function onClick() {
212
217
  return _this4.onSelectHour(h);
213
218
  },
214
- className: prefixCls + '-right-panel-item ' + (h === selectedHour ? prefixCls + '-right-panel-item-selected' : ''),
219
+ className: prefixCls + '-right-panel-item',
215
220
  title: h
216
221
  },
217
- h
222
+ React.createElement(
223
+ 'span',
224
+ { className: className },
225
+ h
226
+ )
218
227
  );
219
228
  })
220
229
  )
@@ -226,6 +235,9 @@ var CalendarRightPanel = function (_React$Component) {
226
235
  'ul',
227
236
  null,
228
237
  this.minutes.map(function (m) {
238
+ var isSelected = selectedMinute && m === selectedMinute;
239
+ var isCurrent = !selectedMinute && m === currentMinute;
240
+ var className = prefixCls + '-right-panel-item-text ' + (isSelected ? prefixCls + '-right-panel-item-selected' : '') + ' ' + (isCurrent ? prefixCls + '-right-panel-item-current' : '');
229
241
  return React.createElement(
230
242
  'li',
231
243
  {
@@ -233,10 +245,14 @@ var CalendarRightPanel = function (_React$Component) {
233
245
  onClick: function onClick() {
234
246
  return _this4.onSelectMinute(m);
235
247
  },
236
- className: prefixCls + '-right-panel-item ' + (m === selectedMinute ? prefixCls + '-right-panel-item-selected' : ''),
248
+ className: prefixCls + '-right-panel-item',
237
249
  title: m
238
250
  },
239
- m
251
+ React.createElement(
252
+ 'span',
253
+ { className: className },
254
+ m
255
+ )
240
256
  );
241
257
  })
242
258
  )
@@ -88,6 +88,7 @@ var DateInput = function (_React$Component) {
88
88
  'div',
89
89
  { className: prefixCls + '-date-input-wrap' },
90
90
  React.createElement('input', {
91
+ id: 'date-input',
91
92
  ref: this.saveDateInput,
92
93
  className: prefixCls + '-input',
93
94
  value: str,
@@ -141,22 +141,27 @@ var TimeInput = function (_React$Component) {
141
141
  disabled = _props.disabled,
142
142
  className = _props.className;
143
143
 
144
- var inputCls = className || prefixCls + '-time-input ' + prefixCls + '-text-input';
144
+ var inputCls = className || prefixCls + '-input';
145
145
  return React.createElement(
146
146
  'div',
147
- { className: prefixCls + '-time-input-outer' },
148
- React.createElement('input', {
149
- ref: this.saveRef,
150
- className: inputCls,
151
- value: this.state.str,
152
- disabled: disabled,
153
- placeholder: placeholder,
154
- onChange: this.onInputChange,
155
- onKeyDown: this.onKeyDown,
156
- onFocus: this.onFocus,
157
- onBlur: this.onBlur,
158
- inputMode: inputMode
159
- })
147
+ { className: prefixCls + '-input-wrap' },
148
+ React.createElement(
149
+ 'div',
150
+ { className: prefixCls + '-time-input-wrap' },
151
+ React.createElement('input', {
152
+ id: 'time-input',
153
+ ref: this.saveRef,
154
+ className: inputCls,
155
+ value: this.state.str,
156
+ disabled: disabled,
157
+ placeholder: placeholder,
158
+ onChange: this.onInputChange,
159
+ onKeyDown: this.onKeyDown,
160
+ onFocus: this.onFocus,
161
+ onBlur: this.onBlur,
162
+ inputMode: inputMode
163
+ })
164
+ )
160
165
  );
161
166
  };
162
167