@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
@@ -10,7 +10,7 @@ import CalendarHeader from './calendar/CalendarHeader';
10
10
  import CalendarFooter from './calendar/CalendarFooter';
11
11
  import { calendarMixinWrapper, calendarMixinPropTypes, calendarMixinDefaultProps } from './mixin/CalendarMixin';
12
12
  import { commonMixinWrapper, propType, defaultProp } from './mixin/CommonMixin';
13
- import moment from 'moment';
13
+ import dayjs from 'dayjs';
14
14
 
15
15
  var MonthCalendar = function (_React$Component) {
16
16
  _inherits(MonthCalendar, _React$Component);
@@ -30,26 +30,26 @@ var MonthCalendar = function (_React$Component) {
30
30
  switch (keyCode) {
31
31
  case KeyCode.DOWN:
32
32
  value = stateValue.clone();
33
- value.add(3, 'months');
33
+ value = value.add(3, 'months');
34
34
  break;
35
35
  case KeyCode.UP:
36
36
  value = stateValue.clone();
37
- value.add(-3, 'months');
37
+ value = value.add(-3, 'months');
38
38
  break;
39
39
  case KeyCode.LEFT:
40
40
  value = stateValue.clone();
41
41
  if (ctrlKey) {
42
- value.add(-1, 'years');
42
+ value = value.add(-1, 'years');
43
43
  } else {
44
- value.add(-1, 'months');
44
+ value = value.add(-1, 'months');
45
45
  }
46
46
  break;
47
47
  case KeyCode.RIGHT:
48
48
  value = stateValue.clone();
49
49
  if (ctrlKey) {
50
- value.add(1, 'years');
50
+ value = value.add(1, 'years');
51
51
  } else {
52
- value.add(1, 'months');
52
+ value = value.add(1, 'months');
53
53
  }
54
54
  break;
55
55
  case KeyCode.ENTER:
@@ -76,7 +76,7 @@ var MonthCalendar = function (_React$Component) {
76
76
 
77
77
  _this.state = {
78
78
  mode: 'month',
79
- value: props.value || props.defaultValue || moment(),
79
+ value: props.value || props.defaultValue || dayjs(),
80
80
  selectedValue: props.selectedValue || props.defaultSelectedValue
81
81
  };
82
82
  return _this;
@@ -4,7 +4,7 @@ import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructo
4
4
  import _inherits from 'babel-runtime/helpers/inherits';
5
5
  import React from 'react';
6
6
  import PropTypes from 'prop-types';
7
- import moment from 'moment';
7
+ import dayjs from 'dayjs';
8
8
  import classnames from 'classnames';
9
9
  import { polyfill } from 'react-lifecycles-compat';
10
10
  import KeyCode from 'rc-util/es/KeyCode';
@@ -55,7 +55,7 @@ function normalizeAnchor(props, init) {
55
55
  var selectedValue = props.selectedValue || init && props.defaultSelectedValue;
56
56
  var value = props.value || init && props.defaultValue;
57
57
  var normalizedValue = value ? getValueFromSelectedValue(value) : getValueFromSelectedValue(selectedValue);
58
- return !isEmptyArray(normalizedValue) ? normalizedValue : init && [moment(), moment().add(1, 'months')];
58
+ return !isEmptyArray(normalizedValue) ? normalizedValue : init && [dayjs(), dayjs().add(1, 'months')];
59
59
  }
60
60
 
61
61
  function generateOptions(length, extraOptionGen) {
@@ -414,7 +414,7 @@ var _initialiseProps = function _initialiseProps() {
414
414
  var nextHoverValue = void 0;
415
415
 
416
416
  if (!firstSelectedValue) {
417
- currentHoverTime = hoverValue[0] || selectedValue[0] || value[0] || moment();
417
+ currentHoverTime = hoverValue[0] || selectedValue[0] || value[0] || dayjs();
418
418
  nextHoverTime = func(currentHoverTime);
419
419
  nextHoverValue = [nextHoverTime];
420
420
  _this2.fireHoverValueChange(nextHoverValue);
@@ -804,7 +804,7 @@ var _initialiseProps = function _initialiseProps() {
804
804
 
805
805
  // 尚未选择过时间,直接输入的话
806
806
  if (!_this2.state.selectedValue[0] || !_this2.state.selectedValue[1]) {
807
- var startValue = selectedValue[0] || moment();
807
+ var startValue = selectedValue[0] || dayjs();
808
808
  var endValue = selectedValue[1] || startValue.clone().add(1, 'months');
809
809
  _this2.setState({
810
810
  selectedValue: selectedValue,
@@ -10,13 +10,13 @@ import DecadePanel from '../decade/DecadePanel';
10
10
 
11
11
  function goMonth(direction) {
12
12
  var next = this.props.value.clone();
13
- next.add(direction, 'months');
13
+ next = next.add(direction, 'months');
14
14
  this.props.onValueChange(next);
15
15
  }
16
16
 
17
17
  function goYear(direction) {
18
18
  var next = this.props.value.clone();
19
- next.add(direction, 'years');
19
+ next = next.add(direction, 'years');
20
20
  this.props.onValueChange(next);
21
21
  }
22
22
 
@@ -3,7 +3,7 @@ import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructo
3
3
  import _inherits from 'babel-runtime/helpers/inherits';
4
4
  import React from 'react';
5
5
  import PropTypes from 'prop-types';
6
- import moment from 'moment';
6
+ import dayjs from 'dayjs';
7
7
 
8
8
  var CalendarRightPanel = function (_React$Component) {
9
9
  _inherits(CalendarRightPanel, _React$Component);
@@ -21,6 +21,17 @@ var CalendarRightPanel = function (_React$Component) {
21
21
  _this.props.onClickRightPanelTime();
22
22
  };
23
23
 
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);
31
+ }
32
+ return times;
33
+ };
34
+
24
35
  _this.scrollUp = function () {
25
36
  _this.timeRef.current.scrollBy(0, -200);
26
37
  };
@@ -33,12 +44,18 @@ var CalendarRightPanel = function (_React$Component) {
33
44
  highlightTime: _this.props.value || null
34
45
  };
35
46
  _this.timeRef = React.createRef();
47
+ _this.times = _this.getTimes();
36
48
  return _this;
37
49
  }
38
50
 
39
51
  CalendarRightPanel.prototype.componentDidMount = function componentDidMount() {
40
- // The default time is 8, page scroll to 08:00
41
- this.timeRef.current.scrollTo(0, 34 * 16);
52
+ var defaultMinutesTime = this.props.defaultMinutesTime;
53
+
54
+ var showTimeIndex = this.times.findIndex(function (item) {
55
+ return item === defaultMinutesTime;
56
+ });
57
+ var scrollTimeIndex = showTimeIndex > -1 ? showTimeIndex : 16;
58
+ this.timeRef.current.scrollTo(0, 34 * scrollTimeIndex);
42
59
  };
43
60
 
44
61
  CalendarRightPanel.prototype.render = function render() {
@@ -50,13 +67,6 @@ var CalendarRightPanel = function (_React$Component) {
50
67
  locale = _props.locale;
51
68
 
52
69
  var selectedDate = value.format().slice(0, 10);
53
- var times = [];
54
- for (var i = 0; i < 24; i++) {
55
- var str = (String(i) + ':00').padStart(5, '0');
56
- var str1 = (String(i) + ':30').padStart(5, '0');
57
- times.push(str);
58
- times.push(str1);
59
- }
60
70
  var highlight = this.state.highlightTime;
61
71
  var highlightTime = highlight ? highlight.format().slice(11, 16) : null;
62
72
  var isZhcn = locale && locale.today === '今天';
@@ -74,8 +84,8 @@ var CalendarRightPanel = function (_React$Component) {
74
84
  React.createElement(
75
85
  'ul',
76
86
  null,
77
- times.map(function (time) {
78
- var current = moment(selectedDate + ' ' + time);
87
+ this.times.map(function (time) {
88
+ var current = dayjs(selectedDate + ' ' + time);
79
89
  current = isZhcn ? current.locale('zh-cn') : current.locale('en-gb');
80
90
  return React.createElement(
81
91
  'li',
@@ -105,6 +115,7 @@ CalendarRightPanel.propTypes = {
105
115
  value: PropTypes.object,
106
116
  onSelect: PropTypes.func,
107
117
  onClickRightPanelTime: PropTypes.func,
108
- locale: PropTypes.object
118
+ locale: PropTypes.object,
119
+ defaultMinutesTime: PropTypes.string
109
120
  };
110
121
  export default CalendarRightPanel;
@@ -6,7 +6,7 @@ import ReactDOM from 'react-dom';
6
6
  import PropTypes from 'prop-types';
7
7
  import KeyCode from 'rc-util/es/KeyCode';
8
8
  import { polyfill } from 'react-lifecycles-compat';
9
- import moment from 'moment';
9
+ import dayjs from 'dayjs';
10
10
  import { formatDate } from '../util';
11
11
 
12
12
  var cachedSelectionStart = void 0;
@@ -155,7 +155,7 @@ var _initialiseProps = function _initialiseProps() {
155
155
  }
156
156
 
157
157
  // 不合法直接退出
158
- var parsed = moment(str, format, true);
158
+ var parsed = dayjs(str, format, true);
159
159
  if (!parsed.isValid()) {
160
160
  _this2.setState({
161
161
  invalid: true,
@@ -165,7 +165,7 @@ var _initialiseProps = function _initialiseProps() {
165
165
  }
166
166
 
167
167
  var value = _this2.props.value.clone();
168
- value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
168
+ value = value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
169
169
 
170
170
  if (!value || disabledDate && disabledDate(value)) {
171
171
  _this2.setState({
@@ -70,7 +70,7 @@ var DateTBody = function (_React$Component) {
70
70
  var lastDisableClass = prefixCls + '-disabled-cell-last-of-row';
71
71
  var lastDayOfMonthClass = prefixCls + '-last-day-of-month';
72
72
  var month1 = value.clone();
73
- month1.date(1);
73
+ month1 = month1.date(1);
74
74
  var day = month1.day();
75
75
  // const firstDayOfWeek = value.localeData().firstDayOfWeek();
76
76
  // We set Sunday(7) as the first day of the week in seafile-calendar.
@@ -78,7 +78,7 @@ var DateTBody = function (_React$Component) {
78
78
  var lastMonthDiffDay = (day + 7 - firstDayOfWeek) % 7;
79
79
  // calculate last month
80
80
  var lastMonth1 = month1.clone();
81
- lastMonth1.add(0 - lastMonthDiffDay, 'days');
81
+ lastMonth1 = lastMonth1.add(0 - lastMonthDiffDay, 'days');
82
82
  var passed = 0;
83
83
 
84
84
  for (iIndex = 0; iIndex < DateConstants.DATE_ROW_COUNT; iIndex++) {
@@ -86,7 +86,7 @@ var DateTBody = function (_React$Component) {
86
86
  current = lastMonth1;
87
87
  if (passed) {
88
88
  current = current.clone();
89
- current.add(passed, 'days');
89
+ current = current.add(passed, 'days');
90
90
  }
91
91
  dateTable.push(current);
92
92
  passed++;
@@ -1,9 +1,7 @@
1
- import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
2
- import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
3
- import _inherits from 'babel-runtime/helpers/inherits';
1
+ import _classCallCheck from "babel-runtime/helpers/classCallCheck";
2
+ import _possibleConstructorReturn from "babel-runtime/helpers/possibleConstructorReturn";
3
+ import _inherits from "babel-runtime/helpers/inherits";
4
4
  import React from 'react';
5
- import DateConstants from './DateConstants';
6
- import moment from 'moment';
7
5
 
8
6
  var DateTHead = function (_React$Component) {
9
7
  _inherits(DateTHead, _React$Component);
@@ -19,56 +17,55 @@ var DateTHead = function (_React$Component) {
19
17
  var value = props.value;
20
18
  var localeData = value.localeData();
21
19
  var prefixCls = props.prefixCls;
22
- var veryShortWeekdays = [];
23
- var weekDays = [];
20
+ // const veryShortWeekdays = [];
21
+ // const weekDays = [];
24
22
  // const firstDayOfWeek = localeData.firstDayOfWeek();
25
23
  // We set Sunday(7) as the first day of the week in seafile-calendar.
26
- var firstDayOfWeek = 7;
27
24
  var showWeekNumberEl = void 0;
28
- var now = moment();
29
- for (var dateColIndex = 0; dateColIndex < DateConstants.DATE_COL_COUNT; dateColIndex++) {
30
- var index = (firstDayOfWeek + dateColIndex) % DateConstants.DATE_COL_COUNT;
31
- now.day(index);
32
- veryShortWeekdays[dateColIndex] = localeData.weekdaysMin(now);
33
- weekDays[dateColIndex] = localeData.weekdaysShort(now);
34
- }
35
-
25
+ // for (let dateColIndex = 0; dateColIndex < DateConstants.DATE_COL_COUNT; dateColIndex++) {
26
+ // const index = (firstDayOfWeek + dateColIndex) % DateConstants.DATE_COL_COUNT;
27
+ // now.day(index);
28
+ // veryShortWeekdays[dateColIndex] = localeData.weekdaysMin();
29
+ // weekDays[dateColIndex] = localeData.weekdaysShort();
30
+ // }
31
+ var veryShortWeekdays = localeData.weekdaysMin();
32
+ var weekDays = localeData.weekdaysShort();
36
33
  if (props.showWeekNumber) {
37
34
  showWeekNumberEl = React.createElement(
38
- 'th',
35
+ "th",
39
36
  {
40
- role: 'columnheader',
41
- className: prefixCls + '-column-header ' + prefixCls + '-week-number-header'
37
+ role: "columnheader",
38
+ className: prefixCls + "-column-header " + prefixCls + "-week-number-header"
42
39
  },
43
40
  React.createElement(
44
- 'span',
45
- { className: prefixCls + '-column-header-inner' },
46
- 'x'
41
+ "span",
42
+ { className: prefixCls + "-column-header-inner" },
43
+ "x"
47
44
  )
48
45
  );
49
46
  }
50
47
  var weekDaysEls = weekDays.map(function (day, xindex) {
51
48
  return React.createElement(
52
- 'th',
49
+ "th",
53
50
  {
54
51
  key: xindex,
55
- role: 'columnheader',
52
+ role: "columnheader",
56
53
  title: day,
57
- className: prefixCls + '-column-header'
54
+ className: prefixCls + "-column-header"
58
55
  },
59
56
  React.createElement(
60
- 'span',
61
- { className: prefixCls + '-column-header-inner' },
57
+ "span",
58
+ { className: prefixCls + "-column-header-inner" },
62
59
  veryShortWeekdays[xindex]
63
60
  )
64
61
  );
65
62
  });
66
63
  return React.createElement(
67
- 'thead',
64
+ "thead",
68
65
  null,
69
66
  React.createElement(
70
- 'tr',
71
- { role: 'row' },
67
+ "tr",
68
+ { role: "row" },
72
69
  showWeekNumberEl,
73
70
  weekDaysEls
74
71
  )
@@ -9,7 +9,7 @@ import classnames from 'classnames';
9
9
 
10
10
  function goYear(direction) {
11
11
  var next = this.state.value.clone();
12
- next.add(direction, 'years');
12
+ next = next.add(direction, 'years');
13
13
  this.setState({
14
14
  value: next
15
15
  });
@@ -17,8 +17,8 @@ function goYear(direction) {
17
17
 
18
18
  function chooseDecade(year, event) {
19
19
  var next = this.state.value.clone();
20
- next.year(year);
21
- next.month(this.state.value.month());
20
+ next = next.year(year);
21
+ next = next.month(this.state.value.month());
22
22
  this.props.onSelect(next);
23
23
  event.preventDefault();
24
24
  }
@@ -18,13 +18,13 @@ var CalendarHeader = function (_Component) {
18
18
 
19
19
  CalendarHeader.prototype.onYearChange = function onYearChange(year) {
20
20
  var newValue = this.props.value.clone();
21
- newValue.year(parseInt(year, 10));
21
+ newValue = newValue.year(parseInt(year, 10));
22
22
  this.props.onValueChange(newValue);
23
23
  };
24
24
 
25
25
  CalendarHeader.prototype.onMonthChange = function onMonthChange(month) {
26
26
  var newValue = this.props.value.clone();
27
- newValue.month(parseInt(month, 10));
27
+ newValue = newValue.month(parseInt(month, 10));
28
28
  this.props.onValueChange(newValue);
29
29
  };
30
30
 
@@ -70,7 +70,7 @@ var CalendarHeader = function (_Component) {
70
70
  var Select = props.Select;
71
71
 
72
72
  for (var index = 0; index < 12; index++) {
73
- t.month(index);
73
+ t = t.month(index);
74
74
  options.push(React.createElement(
75
75
  Select.Option,
76
76
  { key: '' + index },
@@ -4,7 +4,7 @@ import _inherits from 'babel-runtime/helpers/inherits';
4
4
  import React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import classnames from 'classnames';
7
- import moment from 'moment';
7
+ import dayjs from 'dayjs';
8
8
  import { isAllowedDate, getTodayTime } from '../util/index';
9
9
 
10
10
  function noop() {}
@@ -14,7 +14,7 @@ export function getNowByCurrentStateValue(value) {
14
14
  if (value) {
15
15
  ret = getTodayTime(value);
16
16
  } else {
17
- ret = moment();
17
+ ret = dayjs();
18
18
  }
19
19
  return ret;
20
20
  }
@@ -11,7 +11,7 @@ var COL = 3;
11
11
 
12
12
  function chooseMonth(month) {
13
13
  var next = this.state.value.clone();
14
- next.month(month);
14
+ next = next.month(month);
15
15
  this.setAndSelectValue(next);
16
16
  }
17
17
 
@@ -54,7 +54,7 @@ var MonthTable = function (_Component) {
54
54
  for (var rowIndex = 0; rowIndex < ROW; rowIndex++) {
55
55
  months[rowIndex] = [];
56
56
  for (var colIndex = 0; colIndex < COL; colIndex++) {
57
- current.month(index);
57
+ current = current.month(index);
58
58
  var content = getMonthName(current);
59
59
  months[rowIndex][colIndex] = {
60
60
  value: index,
@@ -87,20 +87,20 @@ var MonthTable = function (_Component) {
87
87
  var disabled = false;
88
88
  if (props.disabledDate) {
89
89
  var testValue = value.clone();
90
- testValue.month(monthData.value);
90
+ testValue = testValue.month(monthData.value);
91
91
  disabled = props.disabledDate(testValue);
92
92
  }
93
93
  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);
94
94
  var cellEl = void 0;
95
95
  if (cellRender) {
96
96
  var currentValue = value.clone();
97
- currentValue.month(monthData.value);
97
+ currentValue = currentValue.month(monthData.value);
98
98
  cellEl = cellRender(currentValue, locale);
99
99
  } else {
100
100
  var content = void 0;
101
101
  if (contentRender) {
102
102
  var _currentValue = value.clone();
103
- _currentValue.month(monthData.value);
103
+ _currentValue = _currentValue.month(monthData.value);
104
104
  content = contentRender(_currentValue, locale);
105
105
  } else {
106
106
  content = monthData.content;
package/es/util/index.js CHANGED
@@ -1,5 +1,8 @@
1
1
  import _extends from 'babel-runtime/helpers/extends';
2
- import moment from 'moment';
2
+ import dayjs from 'dayjs';
3
+ import utc from 'dayjs/plugin/utc';
4
+
5
+ dayjs.extend(utc);
3
6
 
4
7
  var defaultDisabledTime = {
5
8
  disabledHours: function disabledHours() {
@@ -14,8 +17,8 @@ var defaultDisabledTime = {
14
17
  };
15
18
 
16
19
  export function getTodayTime(value) {
17
- var today = moment();
18
- today.locale(value.locale()).utcOffset(value.utcOffset());
20
+ var today = dayjs();
21
+ today = today.locale(value.locale()).utcOffset(value.utcOffset());
19
22
  return today;
20
23
  }
21
24
 
@@ -35,11 +38,11 @@ export function getMonthName(month) {
35
38
  }
36
39
 
37
40
  export function syncTime(from, to) {
38
- if (!moment.isMoment(from) || !moment.isMoment(to)) return;
39
- to.hour(from.hour());
40
- to.minute(from.minute());
41
- to.second(from.second());
42
- to.millisecond(from.millisecond());
41
+ if (!dayjs.isDayjs(from) || !dayjs.isDayjs(to)) return;
42
+ to = to.hour(from.hour());
43
+ to = to.minute(from.minute());
44
+ to = to.second(from.second());
45
+ to = to.millisecond(from.millisecond());
43
46
  }
44
47
 
45
48
  export function getTimeConfig(value, disabledTime) {
@@ -9,7 +9,7 @@ var COL = 3;
9
9
 
10
10
  function goYear(direction) {
11
11
  var value = this.state.value.clone();
12
- value.add(direction, 'year');
12
+ value = value.add(direction, 'year');
13
13
  this.setState({
14
14
  value: value
15
15
  });
@@ -17,8 +17,8 @@ function goYear(direction) {
17
17
 
18
18
  function chooseYear(year) {
19
19
  var value = this.state.value.clone();
20
- value.year(year);
21
- value.month(this.state.value.month());
20
+ value = value.year(year);
21
+ value = value.month(this.state.value.month());
22
22
  this.setState({
23
23
  value: value
24
24
  });
package/index.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  // Definitions: https://github.com/react-component/calendar
5
5
 
6
6
  import * as React from 'react';
7
- import { Moment } from 'moment';
7
+ import { Dayjs } from 'dayjs';
8
8
 
9
9
  export type Mode = 'time' | 'date' | 'month' | 'year' | 'decade';
10
10
 
@@ -12,9 +12,9 @@ export interface Props {
12
12
  prefixCls?: string;
13
13
  className?: string;
14
14
  style?: React.CSSProperties;
15
- defaultValue?: Moment;
16
- value?: Moment;
17
- selectedValue?: Moment;
15
+ defaultValue?: Dayjs;
16
+ value?: Dayjs;
17
+ selectedValue?: Dayjs;
18
18
  mode?: Mode;
19
19
  locale?: object;
20
20
  format?: string | string[];
@@ -22,18 +22,18 @@ export interface Props {
22
22
  showWeekNumber?: boolean;
23
23
  showToday?: boolean;
24
24
  showOk?: boolean;
25
- onSelect?: (date: Moment) => void;
25
+ onSelect?: (date: Dayjs) => void;
26
26
  onOk?: () => void;
27
27
  onKeyDown?: () => void;
28
28
  onClickRightPanelTime?: () => void;
29
29
  timePicker?: React.ReactNode;
30
30
  dateInputPlaceholder?: string;
31
31
  onClear?: () => void;
32
- onChange?: (date: Moment | null) => void;
33
- onPanelChange?: (date: Moment | null, mode: Mode) => void;
34
- disabledDate?: (current: Moment | undefined) => boolean;
35
- disabledTime?: (current: Moment | undefined) => object;
36
- dateRender?: (current: Moment, value: Moment) => React.ReactNode;
32
+ onChange?: (date: Dayjs | null) => void;
33
+ onPanelChange?: (date: Dayjs | null, mode: Mode) => void;
34
+ disabledDate?: (current: Dayjs | undefined) => boolean;
35
+ disabledTime?: (current: Dayjs | undefined) => object;
36
+ dateRender?: (current: Dayjs, value: Dayjs) => React.ReactNode;
37
37
  renderFooter?: () => React.ReactNode;
38
38
  renderSidebar?: () => React.ReactNode;
39
39
  inputMode?: string;
package/lib/Calendar.js CHANGED
@@ -36,6 +36,10 @@ var _KeyCode2 = _interopRequireDefault(_KeyCode);
36
36
 
37
37
  var _reactLifecyclesCompat = require('react-lifecycles-compat');
38
38
 
39
+ var _dayjs = require('dayjs');
40
+
41
+ var _dayjs2 = _interopRequireDefault(_dayjs);
42
+
39
43
  var _DateTable = require('./date/DateTable');
40
44
 
41
45
  var _DateTable2 = _interopRequireDefault(_DateTable);
@@ -64,16 +68,28 @@ var _util = require('./util');
64
68
 
65
69
  var _toTime = require('./util/toTime');
66
70
 
67
- var _moment = require('moment');
71
+ var _localeData = require('dayjs/plugin/localeData');
72
+
73
+ var _localeData2 = _interopRequireDefault(_localeData);
74
+
75
+ var _utc = require('dayjs/plugin/utc');
68
76
 
69
- var _moment2 = _interopRequireDefault(_moment);
77
+ var _utc2 = _interopRequireDefault(_utc);
78
+
79
+ var _weekOfYear = require('dayjs/plugin/weekOfYear');
80
+
81
+ var _weekOfYear2 = _interopRequireDefault(_weekOfYear);
70
82
 
71
83
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
72
84
 
85
+ _dayjs2['default'].extend(_utc2['default']);
86
+ _dayjs2['default'].extend(_localeData2['default']);
87
+ _dayjs2['default'].extend(_weekOfYear2['default']);
88
+
73
89
  function noop() {}
74
90
 
75
91
  var getMomentObjectIfValid = function getMomentObjectIfValid(date) {
76
- if (_moment2['default'].isMoment(date) && date.isValid()) {
92
+ if (_dayjs2['default'].isDayjs(date) && date.isValid()) {
77
93
  return date;
78
94
  }
79
95
  return false;
@@ -91,7 +107,7 @@ var Calendar = function (_React$Component) {
91
107
 
92
108
  _this.state = {
93
109
  mode: _this.props.mode || 'date',
94
- value: getMomentObjectIfValid(props.value) || getMomentObjectIfValid(props.defaultValue) || (0, _moment2['default'])(),
110
+ value: getMomentObjectIfValid(props.value) || getMomentObjectIfValid(props.defaultValue) || (0, _dayjs2['default'])(),
95
111
  selectedValue: props.selectedValue || props.defaultSelectedValue
96
112
  };
97
113
  return _this;
@@ -258,7 +274,8 @@ var Calendar = function (_React$Component) {
258
274
  value: value,
259
275
  locale: locale,
260
276
  onSelect: this.onDateTableSelect,
261
- onClickRightPanelTime: onClickRightPanelTime
277
+ onClickRightPanelTime: onClickRightPanelTime,
278
+ defaultMinutesTime: this.props.defaultMinutesTime
262
279
  })
263
280
  )
264
281
  ));
@@ -287,6 +304,7 @@ Calendar.propTypes = (0, _extends3['default'])({}, _CalendarMixin.calendarMixinP
287
304
  showToday: _propTypes2['default'].bool,
288
305
  showOk: _propTypes2['default'].bool,
289
306
  showHourAndMinute: _propTypes2['default'].bool,
307
+ defaultMinutesTime: _propTypes2['default'].string,
290
308
  onSelect: _propTypes2['default'].func,
291
309
  onOk: _propTypes2['default'].func,
292
310
  onKeyDown: _propTypes2['default'].func,
@@ -44,9 +44,9 @@ var _CalendarHeader = require('./full-calendar/CalendarHeader');
44
44
 
45
45
  var _CalendarHeader2 = _interopRequireDefault(_CalendarHeader);
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
 
@@ -69,7 +69,7 @@ var FullCalendar = function (_React$Component) {
69
69
 
70
70
  _this.state = {
71
71
  type: type,
72
- value: props.value || props.defaultValue || (0, _moment2['default'])(),
72
+ value: props.value || props.defaultValue || (0, _dayjs2['default'])(),
73
73
  selectedValue: props.selectedValue || props.defaultSelectedValue
74
74
  };
75
75
  return _this;