@seafile/seafile-calendar 0.0.29-gzc31 → 0.0.29-prop3.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/dist/rc-calendar.js +355 -462
- package/dist/rc-calendar.js.map +1 -1
- package/dist/rc-calendar.min.js +1 -1
- package/es/Calendar.js +3 -4
- package/es/Picker.js +0 -1
- package/es/calendar/CalendarRightPanel.js +2 -2
- package/es/date/DateInput.js +15 -57
- package/es/util/index.js +300 -369
- package/lib/Calendar.js +3 -4
- package/lib/Picker.js +0 -1
- package/lib/calendar/CalendarRightPanel.js +1 -1
- package/lib/date/DateInput.js +15 -56
- package/lib/util/index.js +307 -378
- package/package.json +1 -1
package/es/date/DateInput.js
CHANGED
@@ -7,7 +7,10 @@ import PropTypes from 'prop-types';
|
|
7
7
|
import KeyCode from 'rc-util/es/KeyCode';
|
8
8
|
import { polyfill } from 'react-lifecycles-compat';
|
9
9
|
import dayjs from 'dayjs';
|
10
|
-
import { formatDate,
|
10
|
+
import { formatDate, initializeStr } from '../util';
|
11
|
+
var customParseFormat = require('dayjs/plugin/customParseFormat');
|
12
|
+
|
13
|
+
dayjs.extend(customParseFormat);
|
11
14
|
|
12
15
|
var cachedSelectionStart = void 0;
|
13
16
|
var cachedSelectionEnd = void 0;
|
@@ -24,12 +27,11 @@ var DateInput = function (_React$Component) {
|
|
24
27
|
_initialiseProps.call(_this);
|
25
28
|
|
26
29
|
var selectedValue = props.selectedValue;
|
27
|
-
|
30
|
+
|
28
31
|
_this.state = {
|
29
32
|
str: formatDate(selectedValue, _this.props.format),
|
30
33
|
hasFocus: false,
|
31
|
-
|
32
|
-
delimiter: delimate(formatPrefix)
|
34
|
+
localFormat: _this.props.format[0]
|
33
35
|
};
|
34
36
|
return _this;
|
35
37
|
}
|
@@ -50,30 +52,7 @@ var DateInput = function (_React$Component) {
|
|
50
52
|
// when popup show, click body will call this, bug!
|
51
53
|
var selectedValue = nextProps.selectedValue;
|
52
54
|
if (!state.hasFocus) {
|
53
|
-
|
54
|
-
var parts = timeStr.split(state.delimiter);
|
55
|
-
var timeParts = formatDate(selectedValue, nextProps.format).split(' ')[1];
|
56
|
-
if (parts.length === 3) {
|
57
|
-
if (state.localeFormat === DATE_FORMATS.ISO) {
|
58
|
-
newState = { str: parts[0].padStart(4, 0) + '-' + parts[1] + '-' + parts[2] };
|
59
|
-
} else if (state.localeFormat === DATE_FORMATS.ISOAndTime) {
|
60
|
-
newState = {
|
61
|
-
str: parts[0].padStart(4, 0) + '-' + parts[1] + '-' + parts[2] + ' ' + (nextProps.showHourAndMinute ? timeParts : '') // eslint-disable-line max-len
|
62
|
-
};
|
63
|
-
} else if (state.localeFormat === DATE_FORMATS.US) {
|
64
|
-
newState = { str: Number(parts[0]) + '/' + Number(parts[1]) + '/' + parts[2].padStart(4, 0) };
|
65
|
-
} else if (state.localeFormat === DATE_FORMATS.USAndTime) {
|
66
|
-
newState = {
|
67
|
-
str: Number(parts[0]) + '/' + Number(parts[1]) + '/' + parts[2].padStart(4, 0) + ' ' + (nextProps.showHourAndMinute ? timeParts : '') // eslint-disable-line max-len
|
68
|
-
};
|
69
|
-
} else if (state.localeFormat === DATE_FORMATS.European || state.localeFormat === DATE_FORMATS.Germany_Russia_etc) {
|
70
|
-
newState = { str: '' + Number(parts[0]) + state.delimiter + Number(parts[1]) + state.delimiter + parts[2].padStart(4, 0) }; // eslint-disable-line max-len
|
71
|
-
} else if (state.localeFormat === DATE_FORMATS.EuropeanAndTime || state.localeFormat === DATE_FORMATS.Germany_Russia_etcAndTime) {
|
72
|
-
newState = {
|
73
|
-
str: '' + Number(parts[0]) + state.delimiter + Number(parts[1]) + state.delimiter + parts[2].padStart(4, 0) + ' ' + (nextProps.showHourAndMinute ? timeParts : '') // eslint-disable-line max-len
|
74
|
-
};
|
75
|
-
}
|
76
|
-
}
|
55
|
+
newState = { str: formatDate(selectedValue, nextProps.format) };
|
77
56
|
}
|
78
57
|
|
79
58
|
return newState;
|
@@ -140,64 +119,43 @@ DateInput.propTypes = {
|
|
140
119
|
onSelect: PropTypes.func,
|
141
120
|
selectedValue: PropTypes.object,
|
142
121
|
clearIcon: PropTypes.node,
|
143
|
-
inputMode: PropTypes.string
|
144
|
-
showHourAndMinute: PropTypes.bool
|
122
|
+
inputMode: PropTypes.string
|
145
123
|
};
|
146
124
|
|
147
125
|
var _initialiseProps = function _initialiseProps() {
|
148
126
|
var _this2 = this;
|
149
127
|
|
150
128
|
this.onClear = function () {
|
151
|
-
_this2.setState({
|
152
|
-
str: ''
|
153
|
-
});
|
129
|
+
_this2.setState({ str: '' });
|
154
130
|
_this2.props.onClear(null);
|
155
131
|
};
|
156
132
|
|
157
133
|
this.onInputChange = function (event) {
|
158
134
|
var str = event.target.value;
|
159
|
-
|
160
|
-
var cananderStr = normalizeDateInput(str, _this2.state.localeFormat, _this2.state.delimiter);
|
135
|
+
var calendarStr = initializeStr(str, _this2.state.localFormat) || '';
|
161
136
|
var _props = _this2.props,
|
162
137
|
disabledDate = _props.disabledDate,
|
138
|
+
format = _props.format,
|
163
139
|
onChange = _props.onChange,
|
164
140
|
selectedValue = _props.selectedValue;
|
165
141
|
|
166
|
-
var parts = formatDateLocal(cananderStr, _this2.state.localeFormat);
|
167
142
|
// 没有内容,合法并直接退出
|
168
|
-
console.log('cananderStr', cananderStr);
|
169
143
|
|
170
|
-
if (!
|
171
|
-
console.log('我不想走进来');
|
144
|
+
if (!calendarStr) {
|
172
145
|
onChange(null);
|
173
146
|
_this2.setState({ str: '' });
|
174
147
|
return;
|
175
148
|
}
|
176
|
-
|
177
|
-
var format = getDateFormatByStr(cananderStr, _this2.state.localeFormat);
|
178
|
-
var parsed = dayjs(cananderStr, format);
|
149
|
+
var parsed = dayjs(calendarStr, format[0]);
|
179
150
|
var value = _this2.props.value.clone();
|
180
|
-
value.
|
181
|
-
|
182
|
-
if (parts[0] && parts[0].length === 4 && (parts[0].slice(0, 3) === '000' || parts[0].slice(0, 2) === '00')) {
|
183
|
-
value = value.year(parts[0]).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
|
184
|
-
} else {
|
185
|
-
value = value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
|
186
|
-
}
|
187
|
-
} else if (_this2.state.localeFormat === DATE_FORMATS.European || _this2.state.localeFormat === DATE_FORMATS.EuropeanAndTime || _this2.state.localeFormat === DATE_FORMATS.US || _this2.state.localeFormat === DATE_FORMATS.USAndTime || _this2.state.localeFormat === DATE_FORMATS.Germany_Russia_etc || _this2.state.localeFormat === DATE_FORMATS.Germany_Russia_etcAndTime) {
|
188
|
-
if (parts[2] && parts[2].length === 4 && (parts[2].slice(0, 3) === '000' || parts[2].slice(0, 2) === '00')) {
|
189
|
-
value = value.year(parts[2]).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
|
190
|
-
} else {
|
191
|
-
value = value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
|
192
|
-
}
|
193
|
-
}
|
151
|
+
value = value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
|
152
|
+
|
194
153
|
if (!value || disabledDate && disabledDate(value)) {
|
195
154
|
_this2.setState({ str: str });
|
196
155
|
return;
|
197
156
|
}
|
198
157
|
|
199
158
|
if (selectedValue !== value || selectedValue && value && !selectedValue.isSame(value)) {
|
200
|
-
console.log('成功🏅');
|
201
159
|
_this2.setState({ str: str });
|
202
160
|
onChange(value);
|
203
161
|
}
|