@seafile/seafile-calendar 0.1.2 → 1.0.0-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
@@ -15,6 +15,7 @@ import CalendarRightPanel from './calendar/CalendarRightPanel';
15
15
  import { calendarMixinWrapper, calendarMixinPropTypes, calendarMixinDefaultProps, getNowByCurrentStateValue } from './mixin/CalendarMixin';
16
16
  import { commonMixinWrapper, propType, defaultProp } from './mixin/CommonMixin';
17
17
  import DateInput from './date/DateInput';
18
+ import TimeInput from './time/TimeInput';
18
19
  import { getTimeConfig, getTodayTime, syncTime, CALENDAR_STATUS } from './util';
19
20
  import { goStartMonth, goEndMonth, goTime } from './util/toTime';
20
21
  import localeData from 'dayjs/plugin/localeData';
@@ -78,12 +79,13 @@ var Calendar = function (_React$Component) {
78
79
  };
79
80
 
80
81
  Calendar.prototype.render = function render() {
82
+ var _this2 = this;
83
+
81
84
  var props = this.props,
82
85
  state = this.state;
83
86
  var locale = props.locale,
84
87
  prefixCls = props.prefixCls,
85
88
  disabledDate = props.disabledDate,
86
- dateInputPlaceholder = props.dateInputPlaceholder,
87
89
  timePicker = props.timePicker,
88
90
  onClickRightPanelTime = props.onClickRightPanelTime,
89
91
  disabledTime = props.disabledTime,
@@ -120,16 +122,23 @@ var Calendar = function (_React$Component) {
120
122
 
121
123
  timePickerEle = React.cloneElement(timePicker, timePickerProps);
122
124
  }
123
- var calendarInputPlaceholder = dateInputPlaceholder || (Array.isArray(this.getFormat()) ? this.getFormat()[0] : this.getFormat());
125
+
126
+ var baseFormat = Array.isArray(this.getFormat()) ? this.getFormat()[0] : this.getFormat();
127
+ var headerDatePlaceholder = baseFormat.replace(/\s*HH:mm(?::ss)?\s*/, '').trim() || 'YYYY-MM-DD';
124
128
  var inputFormat = Array.isArray(this.getFormat()) ? this.getFormat() : [this.getFormat()];
129
+ // For the date input, strip any time tokens from formats so date and time are shown separately
130
+ var stripTime = function stripTime(f) {
131
+ return typeof f === 'string' ? f.replace(/\s*HH:mm(?::ss)?\s*/, '').trim() : f;
132
+ };
133
+ var dateOnlyFormats = Array.isArray(this.getFormat()) ? this.getFormat().map(stripTime) : [stripTime(this.getFormat())];
125
134
 
126
135
  var dateInputElement = props.showDateInput ? React.createElement(DateInput, {
127
- format: inputFormat,
136
+ format: dateOnlyFormats,
128
137
  key: 'date-input',
129
138
  value: value,
130
139
  locale: locale,
131
- placeholder: calendarInputPlaceholder,
132
- showClear: true,
140
+ placeholder: headerDatePlaceholder,
141
+ showClear: false,
133
142
  disabledTime: disabledTime,
134
143
  disabledDate: disabledDate,
135
144
  onClear: this.onClear,
@@ -141,6 +150,16 @@ var Calendar = function (_React$Component) {
141
150
  inputMode: inputMode
142
151
  }) : null;
143
152
 
153
+ var timeInputTopElement = React.createElement(TimeInput, {
154
+ key: 'time-input-top',
155
+ prefixCls: prefixCls,
156
+ value: value,
157
+ selectedValue: selectedValue,
158
+ onChange: this.onTimeInputChange,
159
+ onSelect: this.onTimeInputSelect,
160
+ inputMode: 'numeric'
161
+ });
162
+
144
163
  var children = [];
145
164
  if (props.renderSidebar) {
146
165
  children.push(props.renderSidebar());
@@ -148,7 +167,24 @@ var Calendar = function (_React$Component) {
148
167
  children.push(React.createElement(
149
168
  'div',
150
169
  { className: prefixCls + '-panel', key: 'panel' },
151
- dateInputElement,
170
+ React.createElement(
171
+ 'div',
172
+ { className: prefixCls + '-inputs' },
173
+ React.createElement(
174
+ 'div',
175
+ { className: prefixCls + '-date-input-col' },
176
+ React.createElement(
177
+ 'div',
178
+ { className: prefixCls + '-date-input' },
179
+ dateInputElement
180
+ )
181
+ ),
182
+ showHourAndMinute && React.createElement(
183
+ 'div',
184
+ { className: prefixCls + '-time-input-col' },
185
+ timeInputTopElement
186
+ )
187
+ ),
152
188
  React.createElement(
153
189
  'div',
154
190
  { className: prefixCls + '-date-panel-container' },
@@ -192,39 +228,45 @@ var Calendar = function (_React$Component) {
192
228
  firstDayOfWeek: firstDayOfWeek,
193
229
  currentStatus: currentStatus
194
230
  })
195
- ),
196
- React.createElement(CalendarFooter, {
197
- showOk: props.showOk,
198
- mode: mode,
199
- renderFooter: props.renderFooter,
200
- locale: locale,
201
- prefixCls: prefixCls,
202
- showToday: props.showToday,
203
- disabledTime: disabledTime,
204
- showTimePicker: showTimePicker,
205
- showDateInput: props.showDateInput,
206
- timePicker: timePicker,
207
- selectedValue: selectedValue,
208
- value: value,
209
- disabledDate: disabledDate,
210
- okDisabled: props.showOk !== false && (!selectedValue || !this.isAllowedDate(selectedValue)),
211
- onOk: this.onOk,
212
- onSelect: this.onSelect,
213
- onToday: this.onToday,
214
- onOpenTimePicker: this.openTimePicker,
215
- onCloseTimePicker: this.closeTimePicker
216
- })
231
+ )
217
232
  ),
218
233
  showHourAndMinute && React.createElement(CalendarRightPanel, {
219
234
  prefixCls: prefixCls,
220
235
  value: value,
236
+ selectedValue: selectedValue,
221
237
  locale: locale,
222
- onSelect: this.onDateTableSelect,
238
+ onSelect: function onSelect(v) {
239
+ if (!_this2.state.hasExplicitTime) {
240
+ _this2.setState({ hasExplicitTime: true });
241
+ }
242
+ _this2.onDateTableSelect(v);
243
+ },
223
244
  onClickRightPanelTime: onClickRightPanelTime,
224
245
  defaultMinutesTime: this.props.defaultMinutesTime,
225
246
  format: inputFormat
226
247
  })
227
- )
248
+ ),
249
+ React.createElement(CalendarFooter, {
250
+ showOk: props.showOk,
251
+ mode: mode,
252
+ renderFooter: props.renderFooter,
253
+ locale: locale,
254
+ prefixCls: prefixCls,
255
+ showToday: props.showToday,
256
+ disabledTime: disabledTime,
257
+ showTimePicker: showTimePicker,
258
+ showDateInput: props.showDateInput,
259
+ timePicker: timePicker,
260
+ selectedValue: selectedValue,
261
+ value: value,
262
+ disabledDate: disabledDate,
263
+ okDisabled: props.showOk !== false && (!selectedValue || !this.isAllowedDate(selectedValue)),
264
+ onOk: this.onOk,
265
+ onSelect: this.onSelect,
266
+ onToday: this.onToday,
267
+ onOpenTimePicker: this.openTimePicker,
268
+ onCloseTimePicker: this.closeTimePicker
269
+ })
228
270
  ));
229
271
 
230
272
  return this.renderRoot({
@@ -285,14 +327,14 @@ Calendar.defaultProps = _extends({}, calendarMixinDefaultProps, defaultProp, {
285
327
  });
286
328
 
287
329
  var _initialiseProps = function _initialiseProps() {
288
- var _this2 = this;
330
+ var _this3 = this;
289
331
 
290
332
  this.onPanelChange = function (value, mode) {
291
- var props = _this2.props,
292
- state = _this2.state;
333
+ var props = _this3.props,
334
+ state = _this3.state;
293
335
 
294
336
  if (!('mode' in props)) {
295
- _this2.setState({ mode: mode });
337
+ _this3.setState({ mode: mode });
296
338
  }
297
339
  props.onPanelChange(value || state.value, mode);
298
340
  };
@@ -304,109 +346,109 @@ var _initialiseProps = function _initialiseProps() {
304
346
  var keyCode = event.keyCode;
305
347
  // mac
306
348
  var ctrlKey = event.ctrlKey || event.metaKey;
307
- var disabledDate = _this2.props.disabledDate;
308
- var value = _this2.state.value;
349
+ var disabledDate = _this3.props.disabledDate;
350
+ var value = _this3.state.value;
309
351
 
310
352
  switch (keyCode) {
311
353
  case KeyCode.DOWN:
312
- _this2.goTime(1, 'weeks');
354
+ _this3.goTime(1, 'weeks');
313
355
  event.preventDefault();
314
356
  return 1;
315
357
  case KeyCode.UP:
316
- _this2.goTime(-1, 'weeks');
358
+ _this3.goTime(-1, 'weeks');
317
359
  event.preventDefault();
318
360
  return 1;
319
361
  case KeyCode.LEFT:
320
362
  if (ctrlKey) {
321
- _this2.goTime(-1, 'years');
363
+ _this3.goTime(-1, 'years');
322
364
  } else {
323
- _this2.goTime(-1, 'days');
365
+ _this3.goTime(-1, 'days');
324
366
  }
325
367
  event.preventDefault();
326
368
  return 1;
327
369
  case KeyCode.RIGHT:
328
370
  if (ctrlKey) {
329
- _this2.goTime(1, 'years');
371
+ _this3.goTime(1, 'years');
330
372
  } else {
331
- _this2.goTime(1, 'days');
373
+ _this3.goTime(1, 'days');
332
374
  }
333
375
  event.preventDefault();
334
376
  return 1;
335
377
  case KeyCode.HOME:
336
- _this2.setValue(goStartMonth(_this2.state.value));
378
+ _this3.setValue(goStartMonth(_this3.state.value));
337
379
  event.preventDefault();
338
380
  return 1;
339
381
  case KeyCode.END:
340
- _this2.setValue(goEndMonth(_this2.state.value));
382
+ _this3.setValue(goEndMonth(_this3.state.value));
341
383
  event.preventDefault();
342
384
  return 1;
343
385
  case KeyCode.PAGE_DOWN:
344
- _this2.goTime(1, 'month');
386
+ _this3.goTime(1, 'month');
345
387
  event.preventDefault();
346
388
  return 1;
347
389
  case KeyCode.PAGE_UP:
348
- _this2.goTime(-1, 'month');
390
+ _this3.goTime(-1, 'month');
349
391
  event.preventDefault();
350
392
  return 1;
351
393
  case KeyCode.ENTER:
352
394
  if (!disabledDate || !disabledDate(value)) {
353
- _this2.onSelect(value, {
395
+ _this3.onSelect(value, {
354
396
  source: 'keyboard'
355
397
  });
356
398
  }
357
399
  event.preventDefault();
358
400
  return 1;
359
401
  default:
360
- _this2.props.onKeyDown(event);
402
+ _this3.props.onKeyDown(event);
361
403
  return 1;
362
404
  }
363
405
  };
364
406
 
365
407
  this.onClear = function () {
366
- _this2.onSelect(null);
367
- _this2.props.onClear();
368
- _this2.setState({ currentStatus: CALENDAR_STATUS.CURRENT_TIME });
408
+ _this3.onSelect(null);
409
+ _this3.props.onClear();
410
+ _this3.setState({ currentStatus: CALENDAR_STATUS.CURRENT_TIME, hasExplicitTime: false });
369
411
  };
370
412
 
371
413
  this.onOk = function () {
372
- var selectedValue = _this2.state.selectedValue;
414
+ var selectedValue = _this3.state.selectedValue;
373
415
 
374
- if (_this2.isAllowedDate(selectedValue)) {
375
- _this2.props.onOk(selectedValue);
416
+ if (_this3.isAllowedDate(selectedValue)) {
417
+ _this3.props.onOk(selectedValue);
376
418
  }
377
419
  };
378
420
 
379
421
  this.onDateInputChange = function (value) {
380
- _this2.onSelect(value, {
422
+ _this3.onSelect(value, {
381
423
  source: 'dateInput'
382
424
  });
383
425
  };
384
426
 
385
427
  this.onDateInputSelect = function (value) {
386
- _this2.onSelect(value, {
428
+ _this3.onSelect(value, {
387
429
  source: 'dateInputSelect'
388
430
  });
389
431
  };
390
432
 
391
433
  this.onDateTableSelect = function (value) {
392
- var timePicker = _this2.props.timePicker;
393
- var selectedValue = _this2.state.selectedValue;
434
+ var timePicker = _this3.props.timePicker;
435
+ var selectedValue = _this3.state.selectedValue;
394
436
 
395
- _this2.setState({ currentStatus: CALENDAR_STATUS.SPECIFIC_TIME });
437
+ _this3.setState({ currentStatus: CALENDAR_STATUS.SPECIFIC_TIME });
396
438
  if (!selectedValue && timePicker) {
397
439
  var timePickerDefaultValue = timePicker.props.defaultValue;
398
440
  if (timePickerDefaultValue) {
399
441
  syncTime(timePickerDefaultValue, value);
400
442
  }
401
443
  }
402
- _this2.onSelect(value);
444
+ _this3.onSelect(value);
403
445
  };
404
446
 
405
447
  this.onToday = function () {
406
- var value = _this2.state.value;
448
+ var value = _this3.state.value;
407
449
 
408
450
  var now = getTodayTime(value);
409
- _this2.onSelect(now, {
451
+ _this3.onSelect(now, {
410
452
  source: 'todayButton'
411
453
  });
412
454
  };
@@ -414,33 +456,48 @@ var _initialiseProps = function _initialiseProps() {
414
456
  this.onBlur = function (event) {
415
457
  setTimeout(function () {
416
458
  var dateInput = DateInput.getInstance();
417
- var rootInstance = _this2.rootInstance;
459
+ var timeInput = TimeInput.getInstance && TimeInput.getInstance();
460
+ var rootInstance = _this3.rootInstance;
418
461
 
419
- if (!rootInstance || rootInstance.contains(document.activeElement) || dateInput && dateInput.contains(document.activeElement)) {
462
+ if (!rootInstance || rootInstance.contains(document.activeElement) || dateInput && dateInput.contains(document.activeElement) || timeInput && timeInput.contains && timeInput.contains(document.activeElement)) {
420
463
  // focused element is still part of Calendar
421
464
  return;
422
465
  }
423
466
 
424
- if (_this2.props.onBlur) {
425
- _this2.props.onBlur(event);
467
+ if (_this3.props.onBlur) {
468
+ _this3.props.onBlur(event);
426
469
  }
427
470
  }, 0);
428
471
  };
429
472
 
473
+ this.onTimeInputChange = function (value) {
474
+ if (!_this3.state.hasExplicitTime) {
475
+ _this3.setState({ hasExplicitTime: true });
476
+ }
477
+ _this3.onSelect(value, { source: 'timeInputChange' });
478
+ };
479
+
480
+ this.onTimeInputSelect = function (value) {
481
+ if (!_this3.state.hasExplicitTime) {
482
+ _this3.setState({ hasExplicitTime: true });
483
+ }
484
+ _this3.onSelect(value, { source: 'timeInputSelect' });
485
+ };
486
+
430
487
  this.getRootDOMNode = function () {
431
- return ReactDOM.findDOMNode(_this2);
488
+ return ReactDOM.findDOMNode(_this3);
432
489
  };
433
490
 
434
491
  this.openTimePicker = function () {
435
- _this2.onPanelChange(null, 'time');
492
+ _this3.onPanelChange(null, 'time');
436
493
  };
437
494
 
438
495
  this.closeTimePicker = function () {
439
- _this2.onPanelChange(null, 'date');
496
+ _this3.onPanelChange(null, 'date');
440
497
  };
441
498
 
442
499
  this.goTime = function (direction, unit) {
443
- _this2.setValue(goTime(_this2.state.value, direction, unit));
500
+ _this3.setValue(goTime(_this3.state.value, direction, unit));
444
501
  };
445
502
  };
446
503
 
@@ -13,103 +13,232 @@ var CalendarRightPanel = function (_React$Component) {
13
13
 
14
14
  var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
15
15
 
16
- _this.onSelect = function (value) {
17
- _this.setState({
18
- highlightTime: value
19
- });
20
- _this.props.onSelect(value);
21
- _this.props.onClickRightPanelTime();
16
+ _this.centerScroll = function (container, index) {
17
+ if (!container || index < 0) return;
18
+ var firstItem = container.querySelector('li');
19
+ var itemHeight = firstItem && firstItem.offsetHeight || 32;
20
+ var containerHeight = container.clientHeight || 0;
21
+ var maxScroll = Math.max(0, container.scrollHeight - containerHeight);
22
+ var target = index * itemHeight - (containerHeight / 2 - itemHeight / 2);
23
+ if (target < 0) target = 0;
24
+ if (target > maxScroll) target = maxScroll;
25
+ container.scrollTop = target;
22
26
  };
23
27
 
24
- _this.getTimes = function () {
25
- var times = [];
26
- for (var i = 0; i < 24; i++) {
27
- var str = (String(i) + ':00').padStart(5, '0');
28
- var str1 = (String(i) + ':30').padStart(5, '0');
29
- times.push(str);
30
- times.push(str1);
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;
32
+ var current = base.clone().hour(h).minute(m);
33
+ _this.skipScrollUpdates = 2;
34
+ _this.setState({ highlightTime: current });
35
+ _this.props.onSelect(current);
36
+ if (_this.props.onClickRightPanelTime) {
37
+ _this.props.onClickRightPanelTime();
31
38
  }
32
- return times;
33
39
  };
34
40
 
35
- _this.scrollUp = function () {
36
- _this.timeRef.current.scrollBy(0, -200);
41
+ _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;
45
+ var current = base.clone().hour(h).minute(m);
46
+ _this.skipScrollUpdates = 2;
47
+ _this.setState({ highlightTime: current });
48
+ _this.props.onSelect(current);
49
+ };
50
+
51
+ _this.getHours = function () {
52
+ return Array.from({ length: 24 }, function (_, i) {
53
+ return String(i).padStart(2, '0');
54
+ });
55
+ };
56
+
57
+ _this.getMinutes = function () {
58
+ return Array.from({ length: 60 }, function (_, i) {
59
+ return String(i).padStart(2, '0');
60
+ });
37
61
  };
38
62
 
39
- _this.scrollDown = function () {
40
- _this.timeRef.current.scrollBy(0, 200);
63
+ _this.getSelectedHour = function () {
64
+ var highlightTime = _this.state.highlightTime;
65
+ var _this$props = _this.props,
66
+ value = _this$props.value,
67
+ selectedValue = _this$props.selectedValue;
68
+
69
+ var v = highlightTime || selectedValue || value;
70
+ return v ? v.format('HH') : '00';
71
+ };
72
+
73
+ _this.getSelectedMinute = function () {
74
+ var highlightTime = _this.state.highlightTime;
75
+ var _this$props2 = _this.props,
76
+ value = _this$props2.value,
77
+ selectedValue = _this$props2.selectedValue;
78
+
79
+ var v = highlightTime || selectedValue || value;
80
+ return v ? v.format('mm') : '00';
41
81
  };
42
82
 
43
83
  var format = Array.isArray(_this.props.format) ? _this.props.format[0] : _this.props.format;
44
84
  _this.state = {
45
- highlightTime: _this.props.value || null,
85
+ highlightTime: _this.props.selectedValue || _this.props.value || null,
46
86
  localeFormat: format
47
87
  };
48
- _this.timeRef = React.createRef();
49
- _this.times = _this.getTimes();
88
+
89
+ _this.hoursRef = React.createRef();
90
+ _this.minutesRef = React.createRef();
91
+ _this.hours = _this.getHours();
92
+ _this.minutes = _this.getMinutes();
93
+
94
+ _this.skipScrollUpdates = 0;
50
95
  return _this;
51
96
  }
52
97
 
98
+ CalendarRightPanel.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {
99
+ if (nextProps.selectedValue) {
100
+ if (!prevState.highlightTime || !prevState.highlightTime.isSame(nextProps.selectedValue)) {
101
+ return { highlightTime: nextProps.selectedValue };
102
+ }
103
+ }
104
+ return null;
105
+ };
106
+
53
107
  CalendarRightPanel.prototype.componentDidMount = function componentDidMount() {
54
- var defaultMinutesTime = this.props.defaultMinutesTime;
108
+ var _this2 = this;
55
109
 
56
- var showTimeIndex = this.times.findIndex(function (item) {
57
- return item >= defaultMinutesTime;
110
+ var _props = this.props,
111
+ defaultMinutesTime = _props.defaultMinutesTime,
112
+ value = _props.value,
113
+ selectedValue = _props.selectedValue;
114
+
115
+ var baseTime = defaultMinutesTime || (selectedValue || value ? (selectedValue || value).format('HH:mm') : '00:00');
116
+ var base = baseTime.split(':');
117
+ var hIdx = this.hours.findIndex(function (h) {
118
+ return h === base[0];
119
+ });
120
+ var mIdx = this.minutes.findIndex(function (m) {
121
+ return m === base[1];
58
122
  });
59
- var scrollTimeIndex = showTimeIndex > -1 ? showTimeIndex - 1 : 16;
60
- this.timeRef.current.scrollTo(0, 34 * scrollTimeIndex);
123
+ var hourIndex = hIdx > -1 ? hIdx : 0;
124
+ var minuteIndex = mIdx > -1 ? mIdx : 0;
125
+
126
+ if (typeof window !== 'undefined' && window.requestAnimationFrame) {
127
+ window.requestAnimationFrame(function () {
128
+ _this2.centerScroll(_this2.hoursRef.current, hourIndex);
129
+ _this2.centerScroll(_this2.minutesRef.current, minuteIndex);
130
+ });
131
+ } else {
132
+ this.centerScroll(this.hoursRef.current, hourIndex);
133
+ this.centerScroll(this.minutesRef.current, minuteIndex);
134
+ }
135
+ };
136
+
137
+ CalendarRightPanel.prototype.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
138
+ var _this3 = this;
139
+
140
+ var prevV = prevState.highlightTime || prevProps.selectedValue || prevProps.value;
141
+ var currV = this.state.highlightTime || this.props.selectedValue || this.props.value;
142
+
143
+ var prevH = prevV ? prevV.format('HH') : '00';
144
+ var prevM = prevV ? prevV.format('mm') : '00';
145
+ var currH = currV ? currV.format('HH') : '00';
146
+ var currM = currV ? currV.format('mm') : '00';
147
+
148
+ if (this.skipScrollUpdates > 0) {
149
+ this.skipScrollUpdates -= 1;
150
+ return;
151
+ }
152
+
153
+ var hChanged = prevH !== currH;
154
+ var mChanged = prevM !== currM;
155
+ if (hChanged || mChanged) {
156
+ var scrollHours = function scrollHours() {
157
+ if (hChanged) {
158
+ var hIdx = _this3.hours.findIndex(function (h) {
159
+ return h === currH;
160
+ });
161
+ var hourIndex = hIdx > -1 ? hIdx : 0;
162
+ _this3.centerScroll(_this3.hoursRef.current, hourIndex);
163
+ }
164
+ if (mChanged) {
165
+ var mIdx = _this3.minutes.findIndex(function (m) {
166
+ return m === currM;
167
+ });
168
+ var minuteIndex = mIdx > -1 ? mIdx : 0;
169
+ _this3.centerScroll(_this3.minutesRef.current, minuteIndex);
170
+ }
171
+ };
172
+ if (typeof window !== 'undefined' && window.requestAnimationFrame) {
173
+ window.requestAnimationFrame(scrollHours);
174
+ } else {
175
+ scrollHours();
176
+ }
177
+ }
61
178
  };
62
179
 
63
180
  CalendarRightPanel.prototype.render = function render() {
64
- var _this2 = this;
181
+ var _this4 = this;
65
182
 
66
- var _props = this.props,
67
- value = _props.value,
68
- prefixCls = _props.prefixCls,
69
- locale = _props.locale;
183
+ var prefixCls = this.props.prefixCls;
70
184
 
71
- var highlight = this.state.highlightTime;
72
- var highlightTime = highlight ? highlight.format().slice(11, 16) : null;
73
- var isZhcn = locale && locale.today === '今天';
185
+ var selectedHour = this.getSelectedHour();
186
+ var selectedMinute = this.getSelectedMinute();
74
187
  return React.createElement(
75
188
  'div',
76
189
  { className: prefixCls + '-right-panel' },
77
190
  React.createElement(
78
191
  'div',
79
- { className: prefixCls + '-right-panel-header', onClick: this.scrollUp },
80
- React.createElement('span', null)
192
+ { className: prefixCls + '-right-panel-time-header' },
193
+ selectedHour,
194
+ ':',
195
+ selectedMinute
81
196
  ),
82
197
  React.createElement(
83
198
  'div',
84
- { className: prefixCls + '-right-panel-body', ref: this.timeRef },
199
+ { className: prefixCls + '-right-panel-body' },
85
200
  React.createElement(
86
- 'ul',
87
- null,
88
- this.times.map(function (time) {
89
- var _time$split$map = time.split(':').map(function (n) {
90
- return parseInt(n, 10);
91
- }),
92
- h = _time$split$map[0],
93
- m = _time$split$map[1];
94
-
95
- var current = value.hour(h).minute(m).second(0);
96
- current = isZhcn ? current.locale('zh-cn') : current.locale('en-gb');
97
- return React.createElement(
98
- 'li',
99
- {
100
- key: time,
101
- onClick: _this2.onSelect.bind(_this2, current),
102
- className: '' + (highlightTime === time ? prefixCls + '-selected-time' : '')
103
- },
104
- time
105
- );
106
- })
201
+ 'div',
202
+ { className: prefixCls + '-right-panel-col', ref: this.hoursRef },
203
+ React.createElement(
204
+ 'ul',
205
+ null,
206
+ this.hours.map(function (h) {
207
+ return React.createElement(
208
+ 'li',
209
+ {
210
+ key: h,
211
+ onClick: function onClick() {
212
+ return _this4.onSelectHour(h);
213
+ },
214
+ className: prefixCls + '-right-panel-item ' + (h === selectedHour ? prefixCls + '-right-panel-item-selected' : '')
215
+ },
216
+ h
217
+ );
218
+ })
219
+ )
220
+ ),
221
+ React.createElement(
222
+ 'div',
223
+ { className: prefixCls + '-right-panel-col', ref: this.minutesRef },
224
+ React.createElement(
225
+ 'ul',
226
+ null,
227
+ this.minutes.map(function (m) {
228
+ return React.createElement(
229
+ 'li',
230
+ {
231
+ key: m,
232
+ onClick: function onClick() {
233
+ return _this4.onSelectMinute(m);
234
+ },
235
+ className: prefixCls + '-right-panel-item ' + (m === selectedMinute ? prefixCls + '-right-panel-item-selected' : '')
236
+ },
237
+ m
238
+ );
239
+ })
240
+ )
107
241
  )
108
- ),
109
- React.createElement(
110
- 'div',
111
- { className: prefixCls + '-right-panel-footer', onClick: this.scrollDown },
112
- React.createElement('span', null)
113
242
  )
114
243
  );
115
244
  };
@@ -120,6 +249,7 @@ var CalendarRightPanel = function (_React$Component) {
120
249
  CalendarRightPanel.propTypes = {
121
250
  prefixCls: PropTypes.string,
122
251
  value: PropTypes.object,
252
+ selectedValue: PropTypes.object,
123
253
  onSelect: PropTypes.func,
124
254
  onClickRightPanelTime: PropTypes.func,
125
255
  locale: PropTypes.object,
@@ -150,7 +150,6 @@ var _initialiseProps = function _initialiseProps() {
150
150
  onChange = _props.onChange,
151
151
  selectedValue = _props.selectedValue;
152
152
 
153
- // 没有内容,合法并直接退出
154
153
 
155
154
  if (!str || !calendarStr) {
156
155
  _this3.setState({ isInputEmpty: true });