@seafile/seafile-calendar 0.1.3-beta.1 → 0.1.3

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.
@@ -3,8 +3,6 @@ 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 dayjs from 'dayjs';
7
- import { tokenizeFormattedDate } from '../util';
8
6
 
9
7
  var CalendarRightPanel = function (_React$Component) {
10
8
  _inherits(CalendarRightPanel, _React$Component);
@@ -69,7 +67,6 @@ var CalendarRightPanel = function (_React$Component) {
69
67
  prefixCls = _props.prefixCls,
70
68
  locale = _props.locale;
71
69
 
72
- var selectedDate = value.format().slice(0, String(value.format()).indexOf('T'));
73
70
  var highlight = this.state.highlightTime;
74
71
  var highlightTime = highlight ? highlight.format().slice(11, 16) : null;
75
72
  var isZhcn = locale && locale.today === '今天';
@@ -88,8 +85,11 @@ var CalendarRightPanel = function (_React$Component) {
88
85
  'ul',
89
86
  null,
90
87
  this.times.map(function (time) {
91
- var parts = tokenizeFormattedDate(selectedDate, _this2.state.localeFormat);
92
- var current = dayjs(selectedDate + ' ' + time).year(parts[0]).month(parts[1] - 1).date(parts[2]); // eslint-disable-line max-len
88
+ var _time$split = time.split(':'),
89
+ hour = _time$split[0],
90
+ minute = _time$split[1];
91
+
92
+ var current = value.clone().hour(parseInt(hour, 10)).minute(parseInt(minute, 10)).second(0);
93
93
  current = isZhcn ? current.locale('zh-cn') : current.locale('en-gb');
94
94
  return React.createElement(
95
95
  'li',
package/es/util/index.js CHANGED
@@ -196,7 +196,7 @@ export function validateTime(inputTime) {
196
196
  return getCurrentTime();
197
197
  }
198
198
  var trimmed = inputTime.trim();
199
- var timeRegex = /^(\d{2}):(\d{2})$/;
199
+ var timeRegex = /^(\d{1,2}):(\d{1,2})$/;
200
200
  var match = trimmed.match(timeRegex);
201
201
  if (!match) {
202
202
  return getCurrentTime();
@@ -206,7 +206,9 @@ export function validateTime(inputTime) {
206
206
  if (hour > 23 || minute > 59) {
207
207
  return getCurrentTime();
208
208
  }
209
- return match[1] + ':' + match[2];
209
+ var h = String(hour).padStart(2, '0');
210
+ var m = String(minute).padStart(2, '0');
211
+ return h + ':' + m;
210
212
  }
211
213
 
212
214
  export function delimate(format) {
@@ -22,12 +22,6 @@ var _propTypes = require('prop-types');
22
22
 
23
23
  var _propTypes2 = _interopRequireDefault(_propTypes);
24
24
 
25
- var _dayjs = require('dayjs');
26
-
27
- var _dayjs2 = _interopRequireDefault(_dayjs);
28
-
29
- var _util = require('../util');
30
-
31
25
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
32
26
 
33
27
  var CalendarRightPanel = function (_React$Component) {
@@ -93,7 +87,6 @@ var CalendarRightPanel = function (_React$Component) {
93
87
  prefixCls = _props.prefixCls,
94
88
  locale = _props.locale;
95
89
 
96
- var selectedDate = value.format().slice(0, String(value.format()).indexOf('T'));
97
90
  var highlight = this.state.highlightTime;
98
91
  var highlightTime = highlight ? highlight.format().slice(11, 16) : null;
99
92
  var isZhcn = locale && locale.today === '今天';
@@ -112,8 +105,11 @@ var CalendarRightPanel = function (_React$Component) {
112
105
  'ul',
113
106
  null,
114
107
  this.times.map(function (time) {
115
- var parts = (0, _util.tokenizeFormattedDate)(selectedDate, _this2.state.localeFormat);
116
- var current = (0, _dayjs2['default'])(selectedDate + ' ' + time).year(parts[0]).month(parts[1] - 1).date(parts[2]); // eslint-disable-line max-len
108
+ var _time$split = time.split(':'),
109
+ hour = _time$split[0],
110
+ minute = _time$split[1];
111
+
112
+ var current = value.clone().hour(parseInt(hour, 10)).minute(parseInt(minute, 10)).second(0);
117
113
  current = isZhcn ? current.locale('zh-cn') : current.locale('en-gb');
118
114
  return _react2['default'].createElement(
119
115
  'li',
package/lib/util/index.js CHANGED
@@ -231,7 +231,7 @@ function validateTime(inputTime) {
231
231
  return getCurrentTime();
232
232
  }
233
233
  var trimmed = inputTime.trim();
234
- var timeRegex = /^(\d{2}):(\d{2})$/;
234
+ var timeRegex = /^(\d{1,2}):(\d{1,2})$/;
235
235
  var match = trimmed.match(timeRegex);
236
236
  if (!match) {
237
237
  return getCurrentTime();
@@ -241,7 +241,9 @@ function validateTime(inputTime) {
241
241
  if (hour > 23 || minute > 59) {
242
242
  return getCurrentTime();
243
243
  }
244
- return match[1] + ':' + match[2];
244
+ var h = String(hour).padStart(2, '0');
245
+ var m = String(minute).padStart(2, '0');
246
+ return h + ':' + m;
245
247
  }
246
248
 
247
249
  function delimate(format) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/seafile-calendar",
3
- "version": "0.1.3-beta.1",
3
+ "version": "0.1.3",
4
4
  "description": "React Calendar",
5
5
  "keywords": [
6
6
  "react",