@seafile/seafile-calendar 0.0.29-gzc32 → 0.0.29-prop3.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/dist/rc-calendar.js +395 -458
- 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 -2
- package/es/calendar/CalendarRightPanel.js +2 -2
- package/es/date/DateInput.js +15 -58
- package/es/util/index.js +342 -366
- package/lib/Calendar.js +3 -4
- package/lib/Picker.js +0 -2
- package/lib/calendar/CalendarRightPanel.js +1 -1
- package/lib/date/DateInput.js +15 -57
- package/lib/util/index.js +349 -375
- 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,65 +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
|
-
console.log(11111);
|
159
134
|
var str = event.target.value;
|
160
|
-
|
161
|
-
var cananderStr = normalizeDateInput(str, _this2.state.localeFormat, _this2.state.delimiter);
|
135
|
+
var calendarStr = initializeStr(str, _this2.state.localFormat) || '';
|
162
136
|
var _props = _this2.props,
|
163
137
|
disabledDate = _props.disabledDate,
|
138
|
+
format = _props.format,
|
164
139
|
onChange = _props.onChange,
|
165
140
|
selectedValue = _props.selectedValue;
|
166
141
|
|
167
|
-
var parts = formatDateLocal(cananderStr, _this2.state.localeFormat);
|
168
142
|
// 没有内容,合法并直接退出
|
169
|
-
console.log('cananderStr', cananderStr);
|
170
143
|
|
171
|
-
if (!
|
172
|
-
console.log('我不想走进来');
|
144
|
+
if (!calendarStr) {
|
173
145
|
onChange(null);
|
174
146
|
_this2.setState({ str: '' });
|
175
147
|
return;
|
176
148
|
}
|
177
|
-
|
178
|
-
var format = getDateFormatByStr(cananderStr, _this2.state.localeFormat);
|
179
|
-
var parsed = dayjs(cananderStr, format);
|
149
|
+
var parsed = dayjs(calendarStr, format[0]);
|
180
150
|
var value = _this2.props.value.clone();
|
181
|
-
value.
|
182
|
-
|
183
|
-
if (parts[0] && parts[0].length === 4 && (parts[0].slice(0, 3) === '000' || parts[0].slice(0, 2) === '00')) {
|
184
|
-
value = value.year(parts[0]).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
|
185
|
-
} else {
|
186
|
-
value = value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
|
187
|
-
}
|
188
|
-
} 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) {
|
189
|
-
if (parts[2] && parts[2].length === 4 && (parts[2].slice(0, 3) === '000' || parts[2].slice(0, 2) === '00')) {
|
190
|
-
value = value.year(parts[2]).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
|
191
|
-
} else {
|
192
|
-
value = value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
|
193
|
-
}
|
194
|
-
}
|
151
|
+
value = value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
|
152
|
+
|
195
153
|
if (!value || disabledDate && disabledDate(value)) {
|
196
154
|
_this2.setState({ str: str });
|
197
155
|
return;
|
198
156
|
}
|
199
157
|
|
200
158
|
if (selectedValue !== value || selectedValue && value && !selectedValue.isSame(value)) {
|
201
|
-
console.log('成功🏅');
|
202
159
|
_this2.setState({ str: str });
|
203
160
|
onChange(value);
|
204
161
|
}
|