@seafile/seafile-calendar 0.0.13 → 0.0.17-beta

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.
Files changed (40) hide show
  1. package/assets/index.css +1 -3
  2. package/dist/rc-calendar.css +1 -3
  3. package/dist/rc-calendar.css.map +1 -1
  4. package/dist/rc-calendar.js +307 -5929
  5. package/dist/rc-calendar.js.map +1 -1
  6. package/dist/rc-calendar.min.css +1 -3
  7. package/dist/rc-calendar.min.css.map +1 -1
  8. package/dist/rc-calendar.min.js +1 -1
  9. package/es/Calendar.js +12 -4
  10. package/es/FullCalendar.js +2 -2
  11. package/es/MonthCalendar.js +8 -8
  12. package/es/RangeCalendar.js +4 -4
  13. package/es/calendar/CalendarHeader.js +2 -2
  14. package/es/calendar/CalendarRightPanel.js +24 -13
  15. package/es/date/DateInput.js +3 -3
  16. package/es/date/DateTBody.js +3 -3
  17. package/es/date/DateTHead.js +27 -30
  18. package/es/decade/DecadePanel.js +3 -3
  19. package/es/full-calendar/CalendarHeader.js +3 -3
  20. package/es/mixin/CalendarMixin.js +2 -2
  21. package/es/month/MonthTable.js +5 -5
  22. package/es/util/index.js +11 -8
  23. package/es/year/YearPanel.js +3 -3
  24. package/index.d.ts +10 -10
  25. package/lib/Calendar.js +23 -5
  26. package/lib/FullCalendar.js +3 -3
  27. package/lib/MonthCalendar.js +9 -9
  28. package/lib/RangeCalendar.js +5 -5
  29. package/lib/calendar/CalendarHeader.js +2 -2
  30. package/lib/calendar/CalendarRightPanel.js +25 -14
  31. package/lib/date/DateInput.js +4 -4
  32. package/lib/date/DateTBody.js +3 -3
  33. package/lib/date/DateTHead.js +41 -50
  34. package/lib/decade/DecadePanel.js +3 -3
  35. package/lib/full-calendar/CalendarHeader.js +3 -3
  36. package/lib/mixin/CalendarMixin.js +3 -3
  37. package/lib/month/MonthTable.js +5 -5
  38. package/lib/util/index.js +15 -9
  39. package/lib/year/YearPanel.js +3 -3
  40. package/package.json +2 -2
@@ -44,9 +44,9 @@ var _CalendarMixin = require('./mixin/CalendarMixin');
44
44
 
45
45
  var _CommonMixin = require('./mixin/CommonMixin');
46
46
 
47
- var _moment = require('moment');
47
+ var _dayjs = require('dayjs');
48
48
 
49
- var _moment2 = _interopRequireDefault(_moment);
49
+ var _dayjs2 = _interopRequireDefault(_dayjs);
50
50
 
51
51
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
52
52
 
@@ -68,26 +68,26 @@ var MonthCalendar = function (_React$Component) {
68
68
  switch (keyCode) {
69
69
  case _KeyCode2['default'].DOWN:
70
70
  value = stateValue.clone();
71
- value.add(3, 'months');
71
+ value = value.add(3, 'months');
72
72
  break;
73
73
  case _KeyCode2['default'].UP:
74
74
  value = stateValue.clone();
75
- value.add(-3, 'months');
75
+ value = value.add(-3, 'months');
76
76
  break;
77
77
  case _KeyCode2['default'].LEFT:
78
78
  value = stateValue.clone();
79
79
  if (ctrlKey) {
80
- value.add(-1, 'years');
80
+ value = value.add(-1, 'years');
81
81
  } else {
82
- value.add(-1, 'months');
82
+ value = value.add(-1, 'months');
83
83
  }
84
84
  break;
85
85
  case _KeyCode2['default'].RIGHT:
86
86
  value = stateValue.clone();
87
87
  if (ctrlKey) {
88
- value.add(1, 'years');
88
+ value = value.add(1, 'years');
89
89
  } else {
90
- value.add(1, 'months');
90
+ value = value.add(1, 'months');
91
91
  }
92
92
  break;
93
93
  case _KeyCode2['default'].ENTER:
@@ -114,7 +114,7 @@ var MonthCalendar = function (_React$Component) {
114
114
 
115
115
  _this.state = {
116
116
  mode: 'month',
117
- value: props.value || props.defaultValue || (0, _moment2['default'])(),
117
+ value: props.value || props.defaultValue || (0, _dayjs2['default'])(),
118
118
  selectedValue: props.selectedValue || props.defaultSelectedValue
119
119
  };
120
120
  return _this;
@@ -26,9 +26,9 @@ var _propTypes = require('prop-types');
26
26
 
27
27
  var _propTypes2 = _interopRequireDefault(_propTypes);
28
28
 
29
- var _moment = require('moment');
29
+ var _dayjs = require('dayjs');
30
30
 
31
- var _moment2 = _interopRequireDefault(_moment);
31
+ var _dayjs2 = _interopRequireDefault(_dayjs);
32
32
 
33
33
  var _classnames2 = require('classnames');
34
34
 
@@ -103,7 +103,7 @@ function normalizeAnchor(props, init) {
103
103
  var selectedValue = props.selectedValue || init && props.defaultSelectedValue;
104
104
  var value = props.value || init && props.defaultValue;
105
105
  var normalizedValue = value ? getValueFromSelectedValue(value) : getValueFromSelectedValue(selectedValue);
106
- return !isEmptyArray(normalizedValue) ? normalizedValue : init && [(0, _moment2['default'])(), (0, _moment2['default'])().add(1, 'months')];
106
+ return !isEmptyArray(normalizedValue) ? normalizedValue : init && [(0, _dayjs2['default'])(), (0, _dayjs2['default'])().add(1, 'months')];
107
107
  }
108
108
 
109
109
  function generateOptions(length, extraOptionGen) {
@@ -462,7 +462,7 @@ var _initialiseProps = function _initialiseProps() {
462
462
  var nextHoverValue = void 0;
463
463
 
464
464
  if (!firstSelectedValue) {
465
- currentHoverTime = hoverValue[0] || selectedValue[0] || value[0] || (0, _moment2['default'])();
465
+ currentHoverTime = hoverValue[0] || selectedValue[0] || value[0] || (0, _dayjs2['default'])();
466
466
  nextHoverTime = func(currentHoverTime);
467
467
  nextHoverValue = [nextHoverTime];
468
468
  _this2.fireHoverValueChange(nextHoverValue);
@@ -852,7 +852,7 @@ var _initialiseProps = function _initialiseProps() {
852
852
 
853
853
  // 尚未选择过时间,直接输入的话
854
854
  if (!_this2.state.selectedValue[0] || !_this2.state.selectedValue[1]) {
855
- var startValue = selectedValue[0] || (0, _moment2['default'])();
855
+ var startValue = selectedValue[0] || (0, _dayjs2['default'])();
856
856
  var endValue = selectedValue[1] || startValue.clone().add(1, 'months');
857
857
  _this2.setState({
858
858
  selectedValue: selectedValue,
@@ -42,13 +42,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'd
42
42
 
43
43
  function goMonth(direction) {
44
44
  var next = this.props.value.clone();
45
- next.add(direction, 'months');
45
+ next = next.add(direction, 'months');
46
46
  this.props.onValueChange(next);
47
47
  }
48
48
 
49
49
  function goYear(direction) {
50
50
  var next = this.props.value.clone();
51
- next.add(direction, 'years');
51
+ next = next.add(direction, 'years');
52
52
  this.props.onValueChange(next);
53
53
  }
54
54
 
@@ -22,9 +22,9 @@ var _propTypes = require('prop-types');
22
22
 
23
23
  var _propTypes2 = _interopRequireDefault(_propTypes);
24
24
 
25
- var _moment = require('moment');
25
+ var _dayjs = require('dayjs');
26
26
 
27
- var _moment2 = _interopRequireDefault(_moment);
27
+ var _dayjs2 = _interopRequireDefault(_dayjs);
28
28
 
29
29
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
30
30
 
@@ -44,6 +44,17 @@ var CalendarRightPanel = function (_React$Component) {
44
44
  _this.props.onClickRightPanelTime();
45
45
  };
46
46
 
47
+ _this.getTimes = function () {
48
+ var times = [];
49
+ for (var i = 0; i < 24; i++) {
50
+ var str = (String(i) + ':00').padStart(5, '0');
51
+ var str1 = (String(i) + ':30').padStart(5, '0');
52
+ times.push(str);
53
+ times.push(str1);
54
+ }
55
+ return times;
56
+ };
57
+
47
58
  _this.scrollUp = function () {
48
59
  _this.timeRef.current.scrollBy(0, -200);
49
60
  };
@@ -56,12 +67,18 @@ var CalendarRightPanel = function (_React$Component) {
56
67
  highlightTime: _this.props.value || null
57
68
  };
58
69
  _this.timeRef = _react2['default'].createRef();
70
+ _this.times = _this.getTimes();
59
71
  return _this;
60
72
  }
61
73
 
62
74
  CalendarRightPanel.prototype.componentDidMount = function componentDidMount() {
63
- // The default time is 8, page scroll to 08:00
64
- this.timeRef.current.scrollTo(0, 34 * 16);
75
+ var defaultMinutesTime = this.props.defaultMinutesTime;
76
+
77
+ var showTimeIndex = this.times.findIndex(function (item) {
78
+ return item === defaultMinutesTime;
79
+ });
80
+ var scrollTimeIndex = showTimeIndex > -1 ? showTimeIndex : 16;
81
+ this.timeRef.current.scrollTo(0, 34 * scrollTimeIndex);
65
82
  };
66
83
 
67
84
  CalendarRightPanel.prototype.render = function render() {
@@ -73,13 +90,6 @@ var CalendarRightPanel = function (_React$Component) {
73
90
  locale = _props.locale;
74
91
 
75
92
  var selectedDate = value.format().slice(0, 10);
76
- var times = [];
77
- for (var i = 0; i < 24; i++) {
78
- var str = (String(i) + ':00').padStart(5, '0');
79
- var str1 = (String(i) + ':30').padStart(5, '0');
80
- times.push(str);
81
- times.push(str1);
82
- }
83
93
  var highlight = this.state.highlightTime;
84
94
  var highlightTime = highlight ? highlight.format().slice(11, 16) : null;
85
95
  var isZhcn = locale && locale.today === '今天';
@@ -97,8 +107,8 @@ var CalendarRightPanel = function (_React$Component) {
97
107
  _react2['default'].createElement(
98
108
  'ul',
99
109
  null,
100
- times.map(function (time) {
101
- var current = (0, _moment2['default'])(selectedDate + ' ' + time);
110
+ this.times.map(function (time) {
111
+ var current = (0, _dayjs2['default'])(selectedDate + ' ' + time);
102
112
  current = isZhcn ? current.locale('zh-cn') : current.locale('en-gb');
103
113
  return _react2['default'].createElement(
104
114
  'li',
@@ -128,7 +138,8 @@ CalendarRightPanel.propTypes = {
128
138
  value: _propTypes2['default'].object,
129
139
  onSelect: _propTypes2['default'].func,
130
140
  onClickRightPanelTime: _propTypes2['default'].func,
131
- locale: _propTypes2['default'].object
141
+ locale: _propTypes2['default'].object,
142
+ defaultMinutesTime: _propTypes2['default'].string
132
143
  };
133
144
  exports['default'] = CalendarRightPanel;
134
145
  module.exports = exports['default'];
@@ -32,9 +32,9 @@ var _KeyCode2 = _interopRequireDefault(_KeyCode);
32
32
 
33
33
  var _reactLifecyclesCompat = require('react-lifecycles-compat');
34
34
 
35
- var _moment = require('moment');
35
+ var _dayjs = require('dayjs');
36
36
 
37
- var _moment2 = _interopRequireDefault(_moment);
37
+ var _dayjs2 = _interopRequireDefault(_dayjs);
38
38
 
39
39
  var _util = require('../util');
40
40
 
@@ -186,7 +186,7 @@ var _initialiseProps = function _initialiseProps() {
186
186
  }
187
187
 
188
188
  // 不合法直接退出
189
- var parsed = (0, _moment2['default'])(str, format, true);
189
+ var parsed = (0, _dayjs2['default'])(str, format, true);
190
190
  if (!parsed.isValid()) {
191
191
  _this2.setState({
192
192
  invalid: true,
@@ -196,7 +196,7 @@ var _initialiseProps = function _initialiseProps() {
196
196
  }
197
197
 
198
198
  var value = _this2.props.value.clone();
199
- value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
199
+ value = value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
200
200
 
201
201
  if (!value || disabledDate && disabledDate(value)) {
202
202
  _this2.setState({
@@ -96,7 +96,7 @@ var DateTBody = function (_React$Component) {
96
96
  var lastDisableClass = prefixCls + '-disabled-cell-last-of-row';
97
97
  var lastDayOfMonthClass = prefixCls + '-last-day-of-month';
98
98
  var month1 = value.clone();
99
- month1.date(1);
99
+ month1 = month1.date(1);
100
100
  var day = month1.day();
101
101
  // const firstDayOfWeek = value.localeData().firstDayOfWeek();
102
102
  // We set Sunday(7) as the first day of the week in seafile-calendar.
@@ -104,7 +104,7 @@ var DateTBody = function (_React$Component) {
104
104
  var lastMonthDiffDay = (day + 7 - firstDayOfWeek) % 7;
105
105
  // calculate last month
106
106
  var lastMonth1 = month1.clone();
107
- lastMonth1.add(0 - lastMonthDiffDay, 'days');
107
+ lastMonth1 = lastMonth1.add(0 - lastMonthDiffDay, 'days');
108
108
  var passed = 0;
109
109
 
110
110
  for (iIndex = 0; iIndex < _DateConstants2['default'].DATE_ROW_COUNT; iIndex++) {
@@ -112,7 +112,7 @@ var DateTBody = function (_React$Component) {
112
112
  current = lastMonth1;
113
113
  if (passed) {
114
114
  current = current.clone();
115
- current.add(passed, 'days');
115
+ current = current.add(passed, 'days');
116
116
  }
117
117
  dateTable.push(current);
118
118
  passed++;
@@ -1,39 +1,31 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
4
 
5
- var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
5
+ var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
6
6
 
7
7
  var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
8
8
 
9
- var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
9
+ var _possibleConstructorReturn2 = require("babel-runtime/helpers/possibleConstructorReturn");
10
10
 
11
11
  var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
12
12
 
13
- var _inherits2 = require('babel-runtime/helpers/inherits');
13
+ var _inherits2 = require("babel-runtime/helpers/inherits");
14
14
 
15
15
  var _inherits3 = _interopRequireDefault(_inherits2);
16
16
 
17
- var _react = require('react');
17
+ var _react = require("react");
18
18
 
19
19
  var _react2 = _interopRequireDefault(_react);
20
20
 
21
- var _DateConstants = require('./DateConstants');
22
-
23
- var _DateConstants2 = _interopRequireDefault(_DateConstants);
24
-
25
- var _moment = require('moment');
26
-
27
- var _moment2 = _interopRequireDefault(_moment);
28
-
29
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
21
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
30
22
 
31
23
  var DateTHead = function (_React$Component) {
32
- (0, _inherits3['default'])(DateTHead, _React$Component);
24
+ (0, _inherits3["default"])(DateTHead, _React$Component);
33
25
 
34
26
  function DateTHead() {
35
- (0, _classCallCheck3['default'])(this, DateTHead);
36
- return (0, _possibleConstructorReturn3['default'])(this, _React$Component.apply(this, arguments));
27
+ (0, _classCallCheck3["default"])(this, DateTHead);
28
+ return (0, _possibleConstructorReturn3["default"])(this, _React$Component.apply(this, arguments));
37
29
  }
38
30
 
39
31
  DateTHead.prototype.render = function render() {
@@ -41,56 +33,55 @@ var DateTHead = function (_React$Component) {
41
33
  var value = props.value;
42
34
  var localeData = value.localeData();
43
35
  var prefixCls = props.prefixCls;
44
- var veryShortWeekdays = [];
45
- var weekDays = [];
36
+ // const veryShortWeekdays = [];
37
+ // const weekDays = [];
46
38
  // const firstDayOfWeek = localeData.firstDayOfWeek();
47
39
  // We set Sunday(7) as the first day of the week in seafile-calendar.
48
- var firstDayOfWeek = 7;
49
40
  var showWeekNumberEl = void 0;
50
- var now = (0, _moment2['default'])();
51
- for (var dateColIndex = 0; dateColIndex < _DateConstants2['default'].DATE_COL_COUNT; dateColIndex++) {
52
- var index = (firstDayOfWeek + dateColIndex) % _DateConstants2['default'].DATE_COL_COUNT;
53
- now.day(index);
54
- veryShortWeekdays[dateColIndex] = localeData.weekdaysMin(now);
55
- weekDays[dateColIndex] = localeData.weekdaysShort(now);
56
- }
57
-
41
+ // for (let dateColIndex = 0; dateColIndex < DateConstants.DATE_COL_COUNT; dateColIndex++) {
42
+ // const index = (firstDayOfWeek + dateColIndex) % DateConstants.DATE_COL_COUNT;
43
+ // now.day(index);
44
+ // veryShortWeekdays[dateColIndex] = localeData.weekdaysMin();
45
+ // weekDays[dateColIndex] = localeData.weekdaysShort();
46
+ // }
47
+ var veryShortWeekdays = localeData.weekdaysMin();
48
+ var weekDays = localeData.weekdaysShort();
58
49
  if (props.showWeekNumber) {
59
- showWeekNumberEl = _react2['default'].createElement(
60
- 'th',
50
+ showWeekNumberEl = _react2["default"].createElement(
51
+ "th",
61
52
  {
62
- role: 'columnheader',
63
- className: prefixCls + '-column-header ' + prefixCls + '-week-number-header'
53
+ role: "columnheader",
54
+ className: prefixCls + "-column-header " + prefixCls + "-week-number-header"
64
55
  },
65
- _react2['default'].createElement(
66
- 'span',
67
- { className: prefixCls + '-column-header-inner' },
68
- 'x'
56
+ _react2["default"].createElement(
57
+ "span",
58
+ { className: prefixCls + "-column-header-inner" },
59
+ "x"
69
60
  )
70
61
  );
71
62
  }
72
63
  var weekDaysEls = weekDays.map(function (day, xindex) {
73
- return _react2['default'].createElement(
74
- 'th',
64
+ return _react2["default"].createElement(
65
+ "th",
75
66
  {
76
67
  key: xindex,
77
- role: 'columnheader',
68
+ role: "columnheader",
78
69
  title: day,
79
- className: prefixCls + '-column-header'
70
+ className: prefixCls + "-column-header"
80
71
  },
81
- _react2['default'].createElement(
82
- 'span',
83
- { className: prefixCls + '-column-header-inner' },
72
+ _react2["default"].createElement(
73
+ "span",
74
+ { className: prefixCls + "-column-header-inner" },
84
75
  veryShortWeekdays[xindex]
85
76
  )
86
77
  );
87
78
  });
88
- return _react2['default'].createElement(
89
- 'thead',
79
+ return _react2["default"].createElement(
80
+ "thead",
90
81
  null,
91
- _react2['default'].createElement(
92
- 'tr',
93
- { role: 'row' },
82
+ _react2["default"].createElement(
83
+ "tr",
84
+ { role: "row" },
94
85
  showWeekNumberEl,
95
86
  weekDaysEls
96
87
  )
@@ -98,7 +89,7 @@ var DateTHead = function (_React$Component) {
98
89
  };
99
90
 
100
91
  return DateTHead;
101
- }(_react2['default'].Component);
92
+ }(_react2["default"].Component);
102
93
 
103
- exports['default'] = DateTHead;
94
+ exports["default"] = DateTHead;
104
95
  module.exports = exports['default'];
@@ -34,7 +34,7 @@ var COL = 3;
34
34
 
35
35
  function goYear(direction) {
36
36
  var next = this.state.value.clone();
37
- next.add(direction, 'years');
37
+ next = next.add(direction, 'years');
38
38
  this.setState({
39
39
  value: next
40
40
  });
@@ -42,8 +42,8 @@ function goYear(direction) {
42
42
 
43
43
  function chooseDecade(year, event) {
44
44
  var next = this.state.value.clone();
45
- next.year(year);
46
- next.month(this.state.value.month());
45
+ next = next.year(year);
46
+ next = next.month(this.state.value.month());
47
47
  this.props.onSelect(next);
48
48
  event.preventDefault();
49
49
  }
@@ -38,13 +38,13 @@ var CalendarHeader = function (_Component) {
38
38
 
39
39
  CalendarHeader.prototype.onYearChange = function onYearChange(year) {
40
40
  var newValue = this.props.value.clone();
41
- newValue.year(parseInt(year, 10));
41
+ newValue = newValue.year(parseInt(year, 10));
42
42
  this.props.onValueChange(newValue);
43
43
  };
44
44
 
45
45
  CalendarHeader.prototype.onMonthChange = function onMonthChange(month) {
46
46
  var newValue = this.props.value.clone();
47
- newValue.month(parseInt(month, 10));
47
+ newValue = newValue.month(parseInt(month, 10));
48
48
  this.props.onValueChange(newValue);
49
49
  };
50
50
 
@@ -90,7 +90,7 @@ var CalendarHeader = function (_Component) {
90
90
  var Select = props.Select;
91
91
 
92
92
  for (var index = 0; index < 12; index++) {
93
- t.month(index);
93
+ t = t.month(index);
94
94
  options.push(_react2['default'].createElement(
95
95
  Select.Option,
96
96
  { key: '' + index },
@@ -29,9 +29,9 @@ var _classnames = require('classnames');
29
29
 
30
30
  var _classnames2 = _interopRequireDefault(_classnames);
31
31
 
32
- var _moment = require('moment');
32
+ var _dayjs = require('dayjs');
33
33
 
34
- var _moment2 = _interopRequireDefault(_moment);
34
+ var _dayjs2 = _interopRequireDefault(_dayjs);
35
35
 
36
36
  var _index = require('../util/index');
37
37
 
@@ -44,7 +44,7 @@ function getNowByCurrentStateValue(value) {
44
44
  if (value) {
45
45
  ret = (0, _index.getTodayTime)(value);
46
46
  } else {
47
- ret = (0, _moment2['default'])();
47
+ ret = (0, _dayjs2['default'])();
48
48
  }
49
49
  return ret;
50
50
  }
@@ -35,7 +35,7 @@ var COL = 3;
35
35
 
36
36
  function chooseMonth(month) {
37
37
  var next = this.state.value.clone();
38
- next.month(month);
38
+ next = next.month(month);
39
39
  this.setAndSelectValue(next);
40
40
  }
41
41
 
@@ -78,7 +78,7 @@ var MonthTable = function (_Component) {
78
78
  for (var rowIndex = 0; rowIndex < ROW; rowIndex++) {
79
79
  months[rowIndex] = [];
80
80
  for (var colIndex = 0; colIndex < COL; colIndex++) {
81
- current.month(index);
81
+ current = current.month(index);
82
82
  var content = (0, _index.getMonthName)(current);
83
83
  months[rowIndex][colIndex] = {
84
84
  value: index,
@@ -111,20 +111,20 @@ var MonthTable = function (_Component) {
111
111
  var disabled = false;
112
112
  if (props.disabledDate) {
113
113
  var testValue = value.clone();
114
- testValue.month(monthData.value);
114
+ testValue = testValue.month(monthData.value);
115
115
  disabled = props.disabledDate(testValue);
116
116
  }
117
117
  var classNameMap = (_classNameMap = {}, _classNameMap[prefixCls + '-cell'] = 1, _classNameMap[prefixCls + '-cell-disabled'] = disabled, _classNameMap[prefixCls + '-selected-cell'] = monthData.value === currentMonth, _classNameMap[prefixCls + '-current-cell'] = today.year() === value.year() && monthData.value === today.month(), _classNameMap);
118
118
  var cellEl = void 0;
119
119
  if (cellRender) {
120
120
  var currentValue = value.clone();
121
- currentValue.month(monthData.value);
121
+ currentValue = currentValue.month(monthData.value);
122
122
  cellEl = cellRender(currentValue, locale);
123
123
  } else {
124
124
  var content = void 0;
125
125
  if (contentRender) {
126
126
  var _currentValue = value.clone();
127
- _currentValue.month(monthData.value);
127
+ _currentValue = _currentValue.month(monthData.value);
128
128
  content = contentRender(_currentValue, locale);
129
129
  } else {
130
130
  content = monthData.content;
package/lib/util/index.js CHANGED
@@ -17,12 +17,18 @@ exports.isTimeValid = isTimeValid;
17
17
  exports.isAllowedDate = isAllowedDate;
18
18
  exports.formatDate = formatDate;
19
19
 
20
- var _moment = require('moment');
20
+ var _dayjs = require('dayjs');
21
21
 
22
- var _moment2 = _interopRequireDefault(_moment);
22
+ var _dayjs2 = _interopRequireDefault(_dayjs);
23
+
24
+ var _utc = require('dayjs/plugin/utc');
25
+
26
+ var _utc2 = _interopRequireDefault(_utc);
23
27
 
24
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
25
29
 
30
+ _dayjs2['default'].extend(_utc2['default']);
31
+
26
32
  var defaultDisabledTime = {
27
33
  disabledHours: function disabledHours() {
28
34
  return [];
@@ -36,8 +42,8 @@ var defaultDisabledTime = {
36
42
  };
37
43
 
38
44
  function getTodayTime(value) {
39
- var today = (0, _moment2['default'])();
40
- today.locale(value.locale()).utcOffset(value.utcOffset());
45
+ var today = (0, _dayjs2['default'])();
46
+ today = today.locale(value.locale()).utcOffset(value.utcOffset());
41
47
  return today;
42
48
  }
43
49
 
@@ -57,11 +63,11 @@ function getMonthName(month) {
57
63
  }
58
64
 
59
65
  function syncTime(from, to) {
60
- if (!_moment2['default'].isMoment(from) || !_moment2['default'].isMoment(to)) return;
61
- to.hour(from.hour());
62
- to.minute(from.minute());
63
- to.second(from.second());
64
- to.millisecond(from.millisecond());
66
+ if (!_dayjs2['default'].isDayjs(from) || !_dayjs2['default'].isDayjs(to)) return;
67
+ to = to.hour(from.hour());
68
+ to = to.minute(from.minute());
69
+ to = to.second(from.second());
70
+ to = to.millisecond(from.millisecond());
65
71
  }
66
72
 
67
73
  function getTimeConfig(value, disabledTime) {
@@ -33,7 +33,7 @@ var COL = 3;
33
33
 
34
34
  function goYear(direction) {
35
35
  var value = this.state.value.clone();
36
- value.add(direction, 'year');
36
+ value = value.add(direction, 'year');
37
37
  this.setState({
38
38
  value: value
39
39
  });
@@ -41,8 +41,8 @@ function goYear(direction) {
41
41
 
42
42
  function chooseYear(year) {
43
43
  var value = this.state.value.clone();
44
- value.year(year);
45
- value.month(this.state.value.month());
44
+ value = value.year(year);
45
+ value = value.month(this.state.value.month());
46
46
  this.setState({
47
47
  value: value
48
48
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/seafile-calendar",
3
- "version": "0.0.13",
3
+ "version": "0.0.17beta",
4
4
  "description": "React Calendar",
5
5
  "keywords": [
6
6
  "react",
@@ -91,7 +91,7 @@
91
91
  "dependencies": {
92
92
  "babel-runtime": "6.x",
93
93
  "classnames": "2.x",
94
- "moment": "2.x",
94
+ "dayjs": "1.10.7",
95
95
  "prop-types": "^15.5.8",
96
96
  "rc-trigger": "^2.2.0",
97
97
  "rc-util": "^4.1.1",