@seafile/seafile-calendar 1.0.0-alpha.0 → 1.0.0-alpha.2

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/assets/index.css CHANGED
@@ -251,7 +251,7 @@
251
251
  }
252
252
  .rc-calendar-time-input-col {
253
253
  width: 122px;
254
- border-left: 1px solid #ccc;
254
+ border-left: 1px solid #eee;
255
255
  }
256
256
  .rc-calendar-date-input,
257
257
  .rc-calendar-time-input-outer {
@@ -272,13 +272,10 @@
272
272
  height: 30px;
273
273
  width: 100%;
274
274
  padding: 4px 10px;
275
- border: 1px solid #d9d9d9;
275
+ border: 1px solid #eee;
276
276
  border-radius: 3px;
277
277
  line-height: 1.5;
278
278
  }
279
- .rc-calendar-date-input input:hover {
280
- border-color: #ed7109;
281
- }
282
279
  .rc-calendar-date-input input:focus {
283
280
  border-color: #ed7109;
284
281
  box-shadow: 0 0 3px #ed7109;
@@ -291,15 +288,12 @@
291
288
  margin: 0;
292
289
  padding: 4px 10px;
293
290
  border-radius: 6px;
294
- border: 1px solid #d9d9d9;
291
+ border: 1px solid #eee;
295
292
  background: #fff;
296
293
  color: #666;
297
294
  line-height: 1.5;
298
295
  transition: border 0.3s, background 0.3s, box-shadow 0.3s;
299
296
  }
300
- .rc-calendar-text-input:hover {
301
- border-color: #ed7109;
302
- }
303
297
  .rc-calendar-text-input:focus {
304
298
  border-color: #ed7109;
305
299
  box-shadow: 0 0 3px #ed7109;
@@ -314,7 +308,7 @@
314
308
  -ms-user-select: none;
315
309
  user-select: none;
316
310
  -webkit-user-select: none;
317
- border-bottom: 1px solid #ccc;
311
+ border-bottom: 1px solid #eee;
318
312
  }
319
313
  .rc-calendar-header > a {
320
314
  font-weight: 600;
@@ -356,7 +350,7 @@
356
350
  .rc-calendar-month-select:hover,
357
351
  .rc-calendar-day-select:hover {
358
352
  cursor: pointer;
359
- color: #ed7109;
353
+ color: #f09f4f;
360
354
  }
361
355
  .rc-calendar-year-select.rc-calendar-time-status:hover,
362
356
  .rc-calendar-month-select.rc-calendar-time-status:hover,
@@ -382,7 +376,7 @@
382
376
  .rc-calendar-next-month-btn:hover,
383
377
  .rc-calendar-prev-year-btn:hover,
384
378
  .rc-calendar-next-year-btn:hover {
385
- color: #ed7109;
379
+ color: #555;
386
380
  }
387
381
  .rc-calendar-next-year-btn {
388
382
  right: 0;
@@ -432,6 +426,7 @@
432
426
  }
433
427
  .rc-calendar-cell {
434
428
  height: 36px;
429
+ padding: 0;
435
430
  }
436
431
  .rc-calendar-date {
437
432
  display: block;
@@ -449,10 +444,6 @@
449
444
  background: #fcecd9;
450
445
  cursor: pointer;
451
446
  }
452
- .rc-calendar-selected-day .rc-calendar-date {
453
- background: #ed7109;
454
- color: #fff;
455
- }
456
447
  .rc-calendar-selected-date .rc-calendar-date {
457
448
  background: #ed7109;
458
449
  color: #fff;
@@ -482,9 +473,23 @@
482
473
  .rc-calendar-next-month-btn-day .rc-calendar-date {
483
474
  color: #bbb;
484
475
  }
476
+ .rc-calendar-today .rc-calendar-date {
477
+ position: relative;
478
+ }
479
+ .rc-calendar-today .rc-calendar-date::before {
480
+ content: '';
481
+ background: #ed7109;
482
+ position: absolute;
483
+ width: 4px;
484
+ height: 4px;
485
+ border-radius: 50%;
486
+ left: 45%;
487
+ bottom: 0%;
488
+ display: inline-block;
489
+ }
485
490
  .rc-calendar-right-panel {
486
491
  height: inherit;
487
- border-left: 1px solid #ccc;
492
+ border-left: 1px solid #eee;
488
493
  }
489
494
  .rc-calendar-right-panel-time-header {
490
495
  height: 40px;
@@ -499,6 +504,7 @@
499
504
  display: -ms-flexbox;
500
505
  display: flex;
501
506
  padding: 4px;
507
+ scrollbar-color: auto;
502
508
  }
503
509
  .rc-calendar-right-panel-col {
504
510
  overflow-y: auto;
@@ -534,7 +540,7 @@
534
540
  height: 0;
535
541
  }
536
542
  .rc-calendar-footer {
537
- border-top: 1px solid #ccc;
543
+ border-top: 1px solid #eee;
538
544
  padding: 8px 0;
539
545
  text-align: center;
540
546
  position: relative;
@@ -581,16 +587,13 @@
581
587
  margin: 0 0;
582
588
  padding: 4px 10px;
583
589
  border-radius: 3px;
584
- border: 1px solid #d9d9d9;
590
+ border: 1px solid #eee;
585
591
  background-color: #ffffff;
586
592
  color: #666;
587
593
  line-height: 1.5;
588
594
  transform: border 0.3s cubic-bezier(0.35, 0, 0.25, 1), background 0.3s cubic-bezier(0.35, 0, 0.25, 1), box-shadow 0.3s cubic-bezier(0.35, 0, 0.25, 1);
589
595
  width: 100%;
590
596
  }
591
- .rc-calendar-time-input:hover {
592
- border-color: #ed7109;
593
- }
594
597
  .rc-calendar-time-input:focus {
595
598
  border-color: #ed7109;
596
599
  box-shadow: 0 0 3px #ed7109;
@@ -776,7 +779,7 @@
776
779
  cursor: not-allowed;
777
780
  }
778
781
  .rc-calendar-month-panel-selected-cell .rc-calendar-month-panel-month {
779
- background: #f09f3f;
782
+ background: #ed7109;
780
783
  color: #fff;
781
784
  }
782
785
  .rc-calendar-month-panel-selected-cell .rc-calendar-month-panel-month:hover {
@@ -896,11 +899,11 @@
896
899
  cursor: pointer;
897
900
  }
898
901
  .rc-calendar-year-panel-selected-cell .rc-calendar-year-panel-year {
899
- background: #f09f3f;
902
+ background: #ed7109;
900
903
  color: #fff;
901
904
  }
902
905
  .rc-calendar-year-panel-selected-cell .rc-calendar-year-panel-year:hover {
903
- background: #f09f3f;
906
+ background: #ed7109;
904
907
  color: #fff;
905
908
  }
906
909
  .rc-calendar-decade-panel {
package/es/Calendar.js CHANGED
@@ -48,8 +48,7 @@ var Calendar = function (_React$Component) {
48
48
  mode: _this.props.mode || 'date',
49
49
  value: getMomentObjectIfValid(props.value) || getMomentObjectIfValid(props.defaultValue) || dayjs(),
50
50
  selectedValue: props.selectedValue || props.defaultSelectedValue,
51
- currentStatus: CALENDAR_STATUS.SPECIFIC_TIME,
52
- hasExplicitTime: false
51
+ currentStatus: CALENDAR_STATUS.SPECIFIC_TIME
53
52
  };
54
53
  return _this;
55
54
  }
@@ -87,7 +86,6 @@ var Calendar = function (_React$Component) {
87
86
  var locale = props.locale,
88
87
  prefixCls = props.prefixCls,
89
88
  disabledDate = props.disabledDate,
90
- dateInputPlaceholder = props.dateInputPlaceholder,
91
89
  timePicker = props.timePicker,
92
90
  onClickRightPanelTime = props.onClickRightPanelTime,
93
91
  disabledTime = props.disabledTime,
@@ -128,9 +126,14 @@ var Calendar = function (_React$Component) {
128
126
  var baseFormat = Array.isArray(this.getFormat()) ? this.getFormat()[0] : this.getFormat();
129
127
  var headerDatePlaceholder = baseFormat.replace(/\s*HH:mm(?::ss)?\s*/, '').trim() || 'YYYY-MM-DD';
130
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())];
131
134
 
132
135
  var dateInputElement = props.showDateInput ? React.createElement(DateInput, {
133
- format: inputFormat,
136
+ format: dateOnlyFormats,
134
137
  key: 'date-input',
135
138
  value: value,
136
139
  locale: locale,
@@ -152,7 +155,6 @@ var Calendar = function (_React$Component) {
152
155
  prefixCls: prefixCls,
153
156
  value: value,
154
157
  selectedValue: selectedValue,
155
- showFromSelected: this.state.hasExplicitTime,
156
158
  onChange: this.onTimeInputChange,
157
159
  onSelect: this.onTimeInputSelect,
158
160
  inputMode: 'numeric'
@@ -177,7 +179,7 @@ var Calendar = function (_React$Component) {
177
179
  dateInputElement
178
180
  )
179
181
  ),
180
- React.createElement(
182
+ showHourAndMinute && React.createElement(
181
183
  'div',
182
184
  { className: prefixCls + '-time-input-col' },
183
185
  timeInputTopElement
@@ -2,7 +2,6 @@ import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
2
2
  import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
3
3
  import _inherits from 'babel-runtime/helpers/inherits';
4
4
  import React from 'react';
5
- import ReactDOM from 'react-dom';
6
5
  import PropTypes from 'prop-types';
7
6
  import { polyfill } from 'react-lifecycles-compat';
8
7
  import dayjs from 'dayjs';
@@ -67,14 +66,10 @@ var TimeInput = function (_React$Component) {
67
66
  var timeStr = initializeTime(str);
68
67
 
69
68
  if (!str || !timeStr) {
70
- _this.setState({ str: str, isInputEmpty: true });
69
+ _this.setState({ str: str });
71
70
  return;
72
71
  }
73
72
 
74
- if (_this.state.isInputEmpty) {
75
- _this.setState({ isInputEmpty: false });
76
- }
77
-
78
73
  var base = _this.props.selectedValue || _this.props.value || dayjs();
79
74
  var parsed = dayjs(timeStr, 'HH:mm');
80
75
  var next = base.clone().hour(parsed.hour()).minute(parsed.minute());
@@ -102,7 +97,7 @@ var TimeInput = function (_React$Component) {
102
97
  };
103
98
 
104
99
  _this.onBlur = function () {
105
- var base = _this.props.showFromSelected ? _this.props.selectedValue || null : null;
100
+ var base = _this.props.selectedValue ? _this.props.selectedValue : _this.props.value || null;
106
101
  _this.setState({
107
102
  hasFocus: false,
108
103
  str: base ? formatTime(base, _this.props.format) : ''
@@ -113,23 +108,14 @@ var TimeInput = function (_React$Component) {
113
108
  timeInputInstance = node;
114
109
  };
115
110
 
116
- _this.getRootDOMNode = function () {
117
- return ReactDOM.findDOMNode(_this);
118
- };
119
-
120
111
  _this.state = {
121
112
  str: '',
122
- hasFocus: false,
123
- isInputEmpty: true
113
+ hasFocus: false
124
114
  };
125
115
  return _this;
126
116
  }
127
117
 
128
- TimeInput.prototype.componentDidUpdate = function componentDidUpdate() {
129
- if (timeInputInstance && this.state.hasFocus && !(cachedSelectionStart === 0 && cachedSelectionEnd === 0)) {
130
- timeInputInstance.setSelectionRange(cachedSelectionStart, cachedSelectionEnd);
131
- }
132
- };
118
+ // Do not set state in componentDidMount; derive from props below to avoid being overwritten
133
119
 
134
120
  TimeInput.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, state) {
135
121
  var newState = null;
@@ -139,11 +125,8 @@ var TimeInput = function (_React$Component) {
139
125
  }
140
126
 
141
127
  if (!state.hasFocus) {
142
- if (nextProps.showFromSelected && nextProps.selectedValue) {
143
- newState = { str: formatTime(nextProps.selectedValue, nextProps.format) };
144
- } else {
145
- newState = { str: '' };
146
- }
128
+ var base = nextProps.selectedValue || null;
129
+ newState = { str: base ? formatTime(base, nextProps.format) : '' };
147
130
  }
148
131
  return newState;
149
132
  };
@@ -192,8 +175,7 @@ TimeInput.propTypes = {
192
175
  inputMode: PropTypes.string,
193
176
  format: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
194
177
  disabled: PropTypes.bool,
195
- className: PropTypes.string,
196
- showFromSelected: PropTypes.bool
178
+ className: PropTypes.string
197
179
  };
198
180
  TimeInput.defaultProps = {
199
181
  format: 'HH:mm',
package/lib/Calendar.js CHANGED
@@ -113,8 +113,7 @@ var Calendar = function (_React$Component) {
113
113
  mode: _this.props.mode || 'date',
114
114
  value: getMomentObjectIfValid(props.value) || getMomentObjectIfValid(props.defaultValue) || (0, _dayjs2['default'])(),
115
115
  selectedValue: props.selectedValue || props.defaultSelectedValue,
116
- currentStatus: _util.CALENDAR_STATUS.SPECIFIC_TIME,
117
- hasExplicitTime: false
116
+ currentStatus: _util.CALENDAR_STATUS.SPECIFIC_TIME
118
117
  };
119
118
  return _this;
120
119
  }
@@ -152,7 +151,6 @@ var Calendar = function (_React$Component) {
152
151
  var locale = props.locale,
153
152
  prefixCls = props.prefixCls,
154
153
  disabledDate = props.disabledDate,
155
- dateInputPlaceholder = props.dateInputPlaceholder,
156
154
  timePicker = props.timePicker,
157
155
  onClickRightPanelTime = props.onClickRightPanelTime,
158
156
  disabledTime = props.disabledTime,
@@ -193,9 +191,14 @@ var Calendar = function (_React$Component) {
193
191
  var baseFormat = Array.isArray(this.getFormat()) ? this.getFormat()[0] : this.getFormat();
194
192
  var headerDatePlaceholder = baseFormat.replace(/\s*HH:mm(?::ss)?\s*/, '').trim() || 'YYYY-MM-DD';
195
193
  var inputFormat = Array.isArray(this.getFormat()) ? this.getFormat() : [this.getFormat()];
194
+ // For the date input, strip any time tokens from formats so date and time are shown separately
195
+ var stripTime = function stripTime(f) {
196
+ return typeof f === 'string' ? f.replace(/\s*HH:mm(?::ss)?\s*/, '').trim() : f;
197
+ };
198
+ var dateOnlyFormats = Array.isArray(this.getFormat()) ? this.getFormat().map(stripTime) : [stripTime(this.getFormat())];
196
199
 
197
200
  var dateInputElement = props.showDateInput ? _react2['default'].createElement(_DateInput2['default'], {
198
- format: inputFormat,
201
+ format: dateOnlyFormats,
199
202
  key: 'date-input',
200
203
  value: value,
201
204
  locale: locale,
@@ -217,7 +220,6 @@ var Calendar = function (_React$Component) {
217
220
  prefixCls: prefixCls,
218
221
  value: value,
219
222
  selectedValue: selectedValue,
220
- showFromSelected: this.state.hasExplicitTime,
221
223
  onChange: this.onTimeInputChange,
222
224
  onSelect: this.onTimeInputSelect,
223
225
  inputMode: 'numeric'
@@ -242,7 +244,7 @@ var Calendar = function (_React$Component) {
242
244
  dateInputElement
243
245
  )
244
246
  ),
245
- _react2['default'].createElement(
247
+ showHourAndMinute && _react2['default'].createElement(
246
248
  'div',
247
249
  { className: prefixCls + '-time-input-col' },
248
250
  timeInputTopElement
@@ -18,10 +18,6 @@ var _react = require('react');
18
18
 
19
19
  var _react2 = _interopRequireDefault(_react);
20
20
 
21
- var _reactDom = require('react-dom');
22
-
23
- var _reactDom2 = _interopRequireDefault(_reactDom);
24
-
25
21
  var _propTypes = require('prop-types');
26
22
 
27
23
  var _propTypes2 = _interopRequireDefault(_propTypes);
@@ -94,14 +90,10 @@ var TimeInput = function (_React$Component) {
94
90
  var timeStr = initializeTime(str);
95
91
 
96
92
  if (!str || !timeStr) {
97
- _this.setState({ str: str, isInputEmpty: true });
93
+ _this.setState({ str: str });
98
94
  return;
99
95
  }
100
96
 
101
- if (_this.state.isInputEmpty) {
102
- _this.setState({ isInputEmpty: false });
103
- }
104
-
105
97
  var base = _this.props.selectedValue || _this.props.value || (0, _dayjs2['default'])();
106
98
  var parsed = (0, _dayjs2['default'])(timeStr, 'HH:mm');
107
99
  var next = base.clone().hour(parsed.hour()).minute(parsed.minute());
@@ -129,7 +121,7 @@ var TimeInput = function (_React$Component) {
129
121
  };
130
122
 
131
123
  _this.onBlur = function () {
132
- var base = _this.props.showFromSelected ? _this.props.selectedValue || null : null;
124
+ var base = _this.props.selectedValue ? _this.props.selectedValue : _this.props.value || null;
133
125
  _this.setState({
134
126
  hasFocus: false,
135
127
  str: base ? formatTime(base, _this.props.format) : ''
@@ -140,23 +132,14 @@ var TimeInput = function (_React$Component) {
140
132
  timeInputInstance = node;
141
133
  };
142
134
 
143
- _this.getRootDOMNode = function () {
144
- return _reactDom2['default'].findDOMNode(_this);
145
- };
146
-
147
135
  _this.state = {
148
136
  str: '',
149
- hasFocus: false,
150
- isInputEmpty: true
137
+ hasFocus: false
151
138
  };
152
139
  return _this;
153
140
  }
154
141
 
155
- TimeInput.prototype.componentDidUpdate = function componentDidUpdate() {
156
- if (timeInputInstance && this.state.hasFocus && !(cachedSelectionStart === 0 && cachedSelectionEnd === 0)) {
157
- timeInputInstance.setSelectionRange(cachedSelectionStart, cachedSelectionEnd);
158
- }
159
- };
142
+ // Do not set state in componentDidMount; derive from props below to avoid being overwritten
160
143
 
161
144
  TimeInput.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, state) {
162
145
  var newState = null;
@@ -166,11 +149,8 @@ var TimeInput = function (_React$Component) {
166
149
  }
167
150
 
168
151
  if (!state.hasFocus) {
169
- if (nextProps.showFromSelected && nextProps.selectedValue) {
170
- newState = { str: formatTime(nextProps.selectedValue, nextProps.format) };
171
- } else {
172
- newState = { str: '' };
173
- }
152
+ var base = nextProps.selectedValue || null;
153
+ newState = { str: base ? formatTime(base, nextProps.format) : '' };
174
154
  }
175
155
  return newState;
176
156
  };
@@ -219,8 +199,7 @@ TimeInput.propTypes = {
219
199
  inputMode: _propTypes2['default'].string,
220
200
  format: _propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].arrayOf(_propTypes2['default'].string)]),
221
201
  disabled: _propTypes2['default'].bool,
222
- className: _propTypes2['default'].string,
223
- showFromSelected: _propTypes2['default'].bool
202
+ className: _propTypes2['default'].string
224
203
  };
225
204
  TimeInput.defaultProps = {
226
205
  format: 'HH:mm',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/seafile-calendar",
3
- "version": "1.0.0-alpha.0",
3
+ "version": "1.0.0-alpha.2",
4
4
  "description": "React Calendar",
5
5
  "keywords": [
6
6
  "react",