@seafile/seafile-calendar 0.0.30-beta.3 → 0.0.30-beta.4

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 (163) hide show
  1. package/dist/rc-calendar.js +459 -436
  2. package/dist/rc-calendar.js.map +1 -1
  3. package/dist/rc-calendar.min.js +1 -1
  4. package/package.json +1 -2
  5. package/assets/index.css +0 -1177
  6. package/es/Calendar.js +0 -454
  7. package/es/FullCalendar.js +0 -182
  8. package/es/MonthCalendar.js +0 -135
  9. package/es/Picker.js +0 -245
  10. package/es/RangeCalendar.js +0 -876
  11. package/es/calendar/CalendarFooter.js +0 -93
  12. package/es/calendar/CalendarHeader.js +0 -257
  13. package/es/calendar/CalendarRightPanel.js +0 -135
  14. package/es/calendar/OkButton.js +0 -22
  15. package/es/calendar/TimePickerButton.js +0 -28
  16. package/es/calendar/TodayButton.js +0 -28
  17. package/es/date/DateConstants.js +0 -19
  18. package/es/date/DateInput.js +0 -444
  19. package/es/date/DateTBody.js +0 -280
  20. package/es/date/DateTHead.js +0 -86
  21. package/es/date/DateTable.js +0 -32
  22. package/es/decade/DecadePanel.js +0 -181
  23. package/es/full-calendar/CalendarHeader.js +0 -180
  24. package/es/index.js +0 -3
  25. package/es/locale/ar_EG.js +0 -27
  26. package/es/locale/bg_BG.js +0 -27
  27. package/es/locale/ca_ES.js +0 -27
  28. package/es/locale/cs_CZ.js +0 -27
  29. package/es/locale/da_DK.js +0 -27
  30. package/es/locale/de_DE.js +0 -27
  31. package/es/locale/el_GR.js +0 -27
  32. package/es/locale/en_GB.js +0 -27
  33. package/es/locale/en_US.js +0 -28
  34. package/es/locale/es_ES.js +0 -27
  35. package/es/locale/et_EE.js +0 -27
  36. package/es/locale/fa_IR.js +0 -27
  37. package/es/locale/fi_FI.js +0 -27
  38. package/es/locale/fr_BE.js +0 -27
  39. package/es/locale/fr_FR.js +0 -27
  40. package/es/locale/he_IL.js +0 -28
  41. package/es/locale/hi_IN.js +0 -28
  42. package/es/locale/hr_HR.js +0 -28
  43. package/es/locale/hu_HU.js +0 -27
  44. package/es/locale/id_ID.js +0 -28
  45. package/es/locale/is_IS.js +0 -27
  46. package/es/locale/it_IT.js +0 -27
  47. package/es/locale/ja_JP.js +0 -26
  48. package/es/locale/kn_IN.js +0 -28
  49. package/es/locale/ko_KR.js +0 -27
  50. package/es/locale/ku_IQ.js +0 -27
  51. package/es/locale/lv_LV.js +0 -27
  52. package/es/locale/mm_MM.js +0 -28
  53. package/es/locale/mn_MN.js +0 -28
  54. package/es/locale/ms_MY.js +0 -27
  55. package/es/locale/nb_NO.js +0 -27
  56. package/es/locale/nl_BE.js +0 -27
  57. package/es/locale/nl_NL.js +0 -27
  58. package/es/locale/pl_PL.js +0 -27
  59. package/es/locale/pt_BR.js +0 -27
  60. package/es/locale/pt_PT.js +0 -27
  61. package/es/locale/ro_RO.js +0 -28
  62. package/es/locale/ru_RU.js +0 -27
  63. package/es/locale/sk_SK.js +0 -27
  64. package/es/locale/sl_SI.js +0 -27
  65. package/es/locale/sr_RS.js +0 -27
  66. package/es/locale/sv_SE.js +0 -27
  67. package/es/locale/ta_IN.js +0 -28
  68. package/es/locale/th_TH.js +0 -27
  69. package/es/locale/tr_TR.js +0 -27
  70. package/es/locale/ug_CN.js +0 -26
  71. package/es/locale/uk_UA.js +0 -27
  72. package/es/locale/vi_VN.js +0 -28
  73. package/es/locale/zh_CN.js +0 -27
  74. package/es/locale/zh_TW.js +0 -26
  75. package/es/mixin/CalendarMixin.js +0 -123
  76. package/es/mixin/CommonMixin.js +0 -85
  77. package/es/month/MonthPanel.js +0 -154
  78. package/es/month/MonthTable.js +0 -156
  79. package/es/picker/placements.js +0 -35
  80. package/es/range-calendar/CalendarPart.js +0 -151
  81. package/es/util/dayjs.js +0 -17
  82. package/es/util/index.js +0 -272
  83. package/es/util/toTime.js +0 -21
  84. package/es/year/YearPanel.js +0 -194
  85. package/lib/Calendar.js +0 -517
  86. package/lib/FullCalendar.js +0 -221
  87. package/lib/MonthCalendar.js +0 -172
  88. package/lib/Picker.js +0 -282
  89. package/lib/RangeCalendar.js +0 -925
  90. package/lib/calendar/CalendarFooter.js +0 -134
  91. package/lib/calendar/CalendarHeader.js +0 -290
  92. package/lib/calendar/CalendarRightPanel.js +0 -160
  93. package/lib/calendar/OkButton.js +0 -32
  94. package/lib/calendar/TimePickerButton.js +0 -41
  95. package/lib/calendar/TodayButton.js +0 -39
  96. package/lib/date/DateConstants.js +0 -23
  97. package/lib/date/DateInput.js +0 -476
  98. package/lib/date/DateTBody.js +0 -307
  99. package/lib/date/DateTHead.js +0 -106
  100. package/lib/date/DateTable.js +0 -54
  101. package/lib/decade/DecadePanel.js +0 -207
  102. package/lib/full-calendar/CalendarHeader.js +0 -201
  103. package/lib/index.js +0 -12
  104. package/lib/locale/ar_EG.js +0 -31
  105. package/lib/locale/bg_BG.js +0 -31
  106. package/lib/locale/ca_ES.js +0 -31
  107. package/lib/locale/cs_CZ.js +0 -31
  108. package/lib/locale/da_DK.js +0 -31
  109. package/lib/locale/de_DE.js +0 -31
  110. package/lib/locale/el_GR.js +0 -31
  111. package/lib/locale/en_GB.js +0 -31
  112. package/lib/locale/en_US.js +0 -32
  113. package/lib/locale/es_ES.js +0 -31
  114. package/lib/locale/et_EE.js +0 -31
  115. package/lib/locale/fa_IR.js +0 -31
  116. package/lib/locale/fi_FI.js +0 -31
  117. package/lib/locale/fr_BE.js +0 -31
  118. package/lib/locale/fr_FR.js +0 -31
  119. package/lib/locale/he_IL.js +0 -32
  120. package/lib/locale/hi_IN.js +0 -32
  121. package/lib/locale/hr_HR.js +0 -32
  122. package/lib/locale/hu_HU.js +0 -31
  123. package/lib/locale/id_ID.js +0 -32
  124. package/lib/locale/is_IS.js +0 -31
  125. package/lib/locale/it_IT.js +0 -31
  126. package/lib/locale/ja_JP.js +0 -30
  127. package/lib/locale/kn_IN.js +0 -32
  128. package/lib/locale/ko_KR.js +0 -31
  129. package/lib/locale/ku_IQ.js +0 -31
  130. package/lib/locale/lv_LV.js +0 -31
  131. package/lib/locale/mm_MM.js +0 -32
  132. package/lib/locale/mn_MN.js +0 -32
  133. package/lib/locale/ms_MY.js +0 -31
  134. package/lib/locale/nb_NO.js +0 -31
  135. package/lib/locale/nl_BE.js +0 -31
  136. package/lib/locale/nl_NL.js +0 -31
  137. package/lib/locale/pl_PL.js +0 -31
  138. package/lib/locale/pt_BR.js +0 -31
  139. package/lib/locale/pt_PT.js +0 -31
  140. package/lib/locale/ro_RO.js +0 -32
  141. package/lib/locale/ru_RU.js +0 -31
  142. package/lib/locale/sk_SK.js +0 -31
  143. package/lib/locale/sl_SI.js +0 -31
  144. package/lib/locale/sr_RS.js +0 -31
  145. package/lib/locale/sv_SE.js +0 -31
  146. package/lib/locale/ta_IN.js +0 -32
  147. package/lib/locale/th_TH.js +0 -31
  148. package/lib/locale/tr_TR.js +0 -31
  149. package/lib/locale/ug_CN.js +0 -30
  150. package/lib/locale/uk_UA.js +0 -31
  151. package/lib/locale/vi_VN.js +0 -32
  152. package/lib/locale/zh_CN.js +0 -31
  153. package/lib/locale/zh_TW.js +0 -30
  154. package/lib/mixin/CalendarMixin.js +0 -153
  155. package/lib/mixin/CommonMixin.js +0 -106
  156. package/lib/month/MonthPanel.js +0 -179
  157. package/lib/month/MonthTable.js +0 -181
  158. package/lib/picker/placements.js +0 -39
  159. package/lib/range-calendar/CalendarPart.js +0 -184
  160. package/lib/util/dayjs.js +0 -46
  161. package/lib/util/index.js +0 -307
  162. package/lib/util/toTime.js +0 -28
  163. package/lib/year/YearPanel.js +0 -219
@@ -1,444 +0,0 @@
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
- import React from 'react';
5
- import ReactDOM from 'react-dom';
6
- import PropTypes from 'prop-types';
7
- import KeyCode from 'rc-util/es/KeyCode';
8
- import { polyfill } from 'react-lifecycles-compat';
9
- import dayjs from 'dayjs';
10
- import { formatDate, DATE_FORMATS, currentDate, currentMonth, currentYear, stringCurrentDate, stringCurrentMonth, formatDateLocal, hasSpecialChar, isValidMonth, isValidDay, fullValidYear, getDateFormatByStr, isCurrentYear, validateTime, delimate } from '../util';
11
-
12
- var cachedSelectionStart = void 0;
13
- var cachedSelectionEnd = void 0;
14
- var dateInputInstance = void 0;
15
-
16
- var DateInput = function (_React$Component) {
17
- _inherits(DateInput, _React$Component);
18
-
19
- function DateInput(props) {
20
- _classCallCheck(this, DateInput);
21
-
22
- var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
23
-
24
- _initialiseProps.call(_this);
25
-
26
- var selectedValue = props.selectedValue;
27
- var formatPrefix = _this.props.format[0];
28
- _this.state = {
29
- timeStr: '',
30
- dateStr: '',
31
- str: formatDate(selectedValue, _this.props.format),
32
- hasFocus: false,
33
- localeFormat: formatPrefix,
34
- delimiter: delimate(formatPrefix),
35
- cananderIput: ''
36
- };
37
- return _this;
38
- }
39
-
40
- DateInput.prototype.componentDidUpdate = function componentDidUpdate() {
41
- if (dateInputInstance && this.state.hasFocus && !(cachedSelectionStart === 0 && cachedSelectionEnd === 0)) {
42
- dateInputInstance.setSelectionRange(cachedSelectionStart, cachedSelectionEnd);
43
- }
44
- };
45
-
46
- DateInput.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, state) {
47
- var newState = {};
48
-
49
- if (dateInputInstance) {
50
- cachedSelectionStart = dateInputInstance.selectionStart;
51
- cachedSelectionEnd = dateInputInstance.selectionEnd;
52
- }
53
- // when popup show, click body will call this, bug!
54
- var selectedValue = nextProps.selectedValue;
55
- if (!state.hasFocus) {
56
- var timeStr = formatDate(selectedValue, nextProps.format).split(' ')[0];
57
- var parts = timeStr.split(state.delimiter);
58
- var timeParts = formatDate(selectedValue, nextProps.format).split(' ')[1];
59
- if (parts.length === 3) {
60
- if (state.localeFormat === DATE_FORMATS.ISO) {
61
- newState = { str: parts[0].padStart(4, 0) + '-' + parts[1] + '-' + parts[2] };
62
- } else if (state.localeFormat === DATE_FORMATS.ISOAndTime) {
63
- newState = {
64
- str: parts[0].padStart(4, 0) + '-' + parts[1] + '-' + parts[2] + ' ' + (nextProps.showHourAndMinute ? timeParts : ''), // eslint-disable-line max-len
65
- dateStr: parts[0].padStart(4, 0) + '-' + parts[1] + '-' + parts[2]
66
- };
67
- } else if (state.localeFormat === DATE_FORMATS.US) {
68
- newState = { str: Number(parts[0]) + '/' + Number(parts[1]) + '/' + parts[2].padStart(4, 0) };
69
- } else if (state.localeFormat === DATE_FORMATS.USAndTime) {
70
- newState = {
71
- str: Number(parts[0]) + '/' + Number(parts[1]) + '/' + parts[2].padStart(4, 0) + ' ' + (nextProps.showHourAndMinute ? timeParts : ''), // eslint-disable-line max-len
72
- dateStr: Number(parts[0]) + '/' + Number(parts[1]) + '/' + parts[2].padStart(4, 0)
73
- };
74
- } else if (state.localeFormat === DATE_FORMATS.European || state.localeFormat === DATE_FORMATS.Germany_Russia_etc) {
75
- newState = { str: '' + Number(parts[0]) + state.delimiter + Number(parts[1]) + state.delimiter + parts[2].padStart(4, 0) }; // eslint-disable-line max-len
76
- } else if (state.localeFormat === DATE_FORMATS.EuropeanAndTime || state.localeFormat === DATE_FORMATS.Germany_Russia_etcAndTime) {
77
- newState = {
78
- str: '' + Number(parts[0]) + state.delimiter + Number(parts[1]) + state.delimiter + parts[2].padStart(4, 0) + ' ' + (nextProps.showHourAndMinute ? timeParts : ''), // eslint-disable-line max-len
79
- dateStr: '' + Number(parts[0]) + state.delimiter + Number(parts[1]) + state.delimiter + parts[2].padStart(4, 0) // eslint-disable-line max-len
80
- };
81
- }
82
- }
83
- }
84
- return newState;
85
- };
86
-
87
- DateInput.getInstance = function getInstance() {
88
- return dateInputInstance;
89
- };
90
-
91
- DateInput.prototype.normalizeDateInput = function normalizeDateInput(str) {
92
- var day = void 0;
93
- var month = void 0;
94
- var year = void 0;
95
- var parts = formatDateLocal(str, this.state.localeFormat, DATE_FORMATS);
96
- var delimiter = this.state.delimiter;
97
- var hasSpecial = hasSpecialChar(str);
98
- if (this.state.localeFormat === DATE_FORMATS.ISO || this.state.localeFormat === DATE_FORMATS.ISOAndTime) {
99
- var numStr = str.replace(/[^0-9]/g, '');
100
- if (numStr.length === 7) {
101
- year = numStr.slice(0, 4);
102
- month = numStr.slice(4, 6).padStart(2, '0');
103
- day = numStr.slice(6, 7).padStart(2, '0');
104
- if (!isValidDay(day)) {
105
- return year + '-' + stringCurrentMonth + '-' + stringCurrentDate;
106
- }
107
- return year + '-' + month + '-' + day;
108
- }
109
- if (hasSpecial) {
110
- year = fullValidYear(parts[0]);
111
- month = Number(parts[1]);
112
- day = Number(parts[2]);
113
- if (month >= 1 && month <= 12) {
114
- if (isValidDay(day)) {
115
- return year + '-' + String(month).padStart(2, '0') + '-' + String(day).padStart(2, '0');
116
- }
117
- return year + '-' + String(month).padStart(2, '0') + '-01';
118
- }
119
- if ((month >= 13 || month < 1) && isNaN(day)) {
120
- return year + '-' + stringCurrentMonth + '-' + stringCurrentDate;
121
- }
122
- if (!month && !day) {
123
- return year + '-01-01';
124
- }
125
- }
126
- if (str.length >= 1 && str.length <= 8) {
127
- year = fullValidYear(str.slice(0, 4));
128
- month = str.slice(4, 6);
129
- day = Number(str.slice(6, 8));
130
- if (str.length === 5 && Number(month) < 1) {
131
- return year + '-' + stringCurrentMonth + '-' + stringCurrentDate + ' ';
132
- }
133
- if (str.length === 6 && Number(month) < 1) {
134
- return year + '-' + stringCurrentMonth + '-' + stringCurrentDate;
135
- }
136
- if (str.length === 7) {
137
- if (!isValidDay(day)) {
138
- return year + '-' + String(isValidMonth(month)).padStart(2, '0') + '-' + stringCurrentDate;
139
- }
140
- return year + '-' + String(isValidMonth(month)).padStart(2, '0') + '-' + String(day).padStart(2, '0'); // eslint-disable-line max-len
141
- }
142
- if (str.length === 8) {
143
- if (!isValidDay(day)) {
144
- return isCurrentYear(year, month, day) + '-' + String(isValidMonth(month)).padStart(2, '0') + '-' + stringCurrentDate; // eslint-disable-line max-len
145
- }
146
- return isCurrentYear(year, month, day) + '-' + String(isValidMonth(month)).padStart(2, '0') + '-' + String(day).padStart(2, '0'); // eslint-disable-line max-len
147
- }
148
- if (Number(month) >= 1 && Number(month) <= 12 && isValidDay(day)) {
149
- return year + '-' + month.padStart(2, '0') + '-' + String(day).padStart(2, '0');
150
- }
151
- return year + '-' + (month ? month.padStart(2, '0') : '01') + '-' + (day ? String(day).padStart(2, '0') : '01'); // eslint-disable-line max-len
152
- }
153
- return currentYear + '/' + stringCurrentMonth + '/' + stringCurrentDate;
154
- }
155
- if (this.state.localeFormat === DATE_FORMATS.US || this.state.localeFormat === DATE_FORMATS.USAndTime) {
156
- if (hasSpecial) {
157
- month = Number(parts[0]);
158
- day = Number(parts[1]);
159
- year = fullValidYear(parts[2]);
160
- if (month >= 1 && month <= 12 && isValidDay(day)) {
161
- return month + '/' + day + '/' + year;
162
- }
163
- return currentMonth + '/' + currentDate + '/' + currentYear;
164
- }
165
- if (str.length >= 1 && str.length <= 8) {
166
- month = Number(str.slice(0, 2));
167
- day = Number(str.slice(2, 4));
168
- year = fullValidYear(str.slice(4, str.length));
169
- if (month >= 1 && month <= 12) {
170
- if (isValidDay(day)) {
171
- return month + '/' + day + '/' + year;
172
- }
173
- if (!day) {
174
- return month + '/1/' + year;
175
- }
176
- return currentMonth + '/' + currentDate + '/' + currentYear;
177
- }
178
- }
179
- return currentMonth + '/' + currentDate + '/' + currentYear;
180
- }
181
- if (this.state.localeFormat === DATE_FORMATS.European || this.state.localeFormat === DATE_FORMATS.EuropeanAndTime || this.state.localeFormat === DATE_FORMATS.Germany_Russia_etcAndTime || this.state.localeFormat === DATE_FORMATS.Germany_Russia_etc) {
182
- if (hasSpecial) {
183
- day = parts[0];
184
- month = parts[1];
185
- year = fullValidYear(parts[2]);
186
- if (isValidDay(day) && Number(month) >= 1 && Number(month) <= 12) {
187
- return '' + Number(day) + delimiter + Number(month) + delimiter + year;
188
- }
189
- return '' + currentDate + delimiter + currentMonth + delimiter + currentYear;
190
- }
191
- if (str.length >= 1 && str.length <= 8) {
192
- day = Number(str.slice(0, 2));
193
- var monthStr = str.slice(2, 4);
194
- month = isValidMonth(monthStr);
195
- var yearStr = str.slice(4, str.length);
196
- year = fullValidYear(yearStr);
197
- if (Number(monthStr) >= 1 && Number(monthStr) <= 12 && isValidDay(day)) {
198
- return '' + Number(day) + delimiter + Number(month) + delimiter + year;
199
- }
200
- }
201
- return '' + currentDate + delimiter + currentMonth + delimiter + currentYear;
202
- }
203
- };
204
-
205
- DateInput.prototype.render = function render() {
206
- var props = this.props;
207
- var _state = this.state,
208
- str = _state.str,
209
- dateStr = _state.dateStr,
210
- timeStr = _state.timeStr;
211
- var locale = props.locale,
212
- prefixCls = props.prefixCls,
213
- placeholder = props.placeholder,
214
- clearIcon = props.clearIcon,
215
- inputMode = props.inputMode,
216
- showHourAndMinute = props.showHourAndMinute;
217
-
218
- return React.createElement(
219
- 'div',
220
- { className: prefixCls + '-input-wrap' },
221
- showHourAndMinute ? React.createElement(
222
- 'div',
223
- { className: prefixCls + '-date-input-wrap', style: { display: 'flex' } },
224
- React.createElement(
225
- 'div',
226
- null,
227
- React.createElement('input', {
228
- ref: this.saveDateInput,
229
- className: prefixCls + '-input',
230
- value: dateStr,
231
- disabled: props.disabled,
232
- placeholder: placeholder.slice(0, 10),
233
- onChange: this.onInputChangeDate,
234
- onKeyDown: this.onKeyDown,
235
- onFocus: this.onFocus,
236
- onBlur: this.onBlur,
237
- inputMode: inputMode
238
- })
239
- ),
240
- React.createElement(
241
- 'div',
242
- null,
243
- React.createElement('input', {
244
- ref: this.saveDateInput,
245
- className: prefixCls + '-input',
246
- value: timeStr,
247
- disabled: props.disabled,
248
- placeholder: 'HH:mm',
249
- onChange: this.onInputChangeHourMinute,
250
- onKeyDown: this.onKeyDown,
251
- onFocus: this.onFocus,
252
- onBlur: this.TimeBlure,
253
- inputMode: inputMode
254
- })
255
- )
256
- ) : React.createElement(
257
- 'div',
258
- { className: prefixCls + '-date-input-wrap', style: { display: 'flex' } },
259
- React.createElement('input', {
260
- ref: this.saveDateInput,
261
- className: prefixCls + '-input',
262
- value: str,
263
- disabled: props.disabled,
264
- placeholder: placeholder,
265
- onChange: this.onInputChangeAll,
266
- onKeyDown: this.onKeyDown,
267
- onFocus: this.onFocus,
268
- onBlur: this.onBlur,
269
- inputMode: inputMode
270
- })
271
- ),
272
- props.showClear ? React.createElement(
273
- 'a',
274
- {
275
- role: 'button',
276
- title: locale.clear,
277
- onClick: this.onClear
278
- },
279
- clearIcon || React.createElement('span', { className: prefixCls + '-clear-btn' })
280
- ) : null
281
- );
282
- };
283
-
284
- return DateInput;
285
- }(React.Component);
286
-
287
- DateInput.propTypes = {
288
- prefixCls: PropTypes.string,
289
- timePicker: PropTypes.object,
290
- value: PropTypes.object,
291
- disabledTime: PropTypes.any,
292
- format: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
293
- locale: PropTypes.object,
294
- disabledDate: PropTypes.func,
295
- onChange: PropTypes.func,
296
- onClear: PropTypes.func,
297
- placeholder: PropTypes.string,
298
- onSelect: PropTypes.func,
299
- selectedValue: PropTypes.object,
300
- clearIcon: PropTypes.node,
301
- inputMode: PropTypes.string,
302
- showHourAndMinute: PropTypes.bool,
303
- onChangeCananderIput: PropTypes.func
304
- };
305
-
306
- var _initialiseProps = function _initialiseProps() {
307
- var _this2 = this;
308
-
309
- this.onClear = function () {
310
- var _props = _this2.props,
311
- showHourAndMinute = _props.showHourAndMinute,
312
- onClear = _props.onClear;
313
-
314
- if (showHourAndMinute) {
315
- _this2.setState({
316
- dateStr: '',
317
- timeStr: ''
318
- });
319
- } else {
320
- _this2.setState({
321
- str: ''
322
- });
323
- }
324
- onClear(null);
325
- };
326
-
327
- this.onInputChange = function (str) {
328
- var cananderStr = _this2.normalizeDateInput(str, _this2.props.showHourAndMinute);
329
- var _props2 = _this2.props,
330
- disabledDate = _props2.disabledDate,
331
- onChange = _props2.onChange,
332
- selectedValue = _props2.selectedValue;
333
-
334
- var parts = formatDateLocal(cananderStr, _this2.state.localeFormat);
335
- var hourMinuteStr = validateTime(_this2.state.timeStr);
336
- _this2.setState({ timeStr: hourMinuteStr });
337
- cananderStr = cananderStr + ' ' + hourMinuteStr;
338
- // 没有内容,合法并直接退出
339
- if (!str) {
340
- onChange(null);
341
- _this2.setState({ str: str });
342
- return;
343
- }
344
- // 不合法直接退出
345
- var format = getDateFormatByStr(cananderStr, _this2.state.localeFormat);
346
- var parsed = dayjs(cananderStr, format);
347
- var value = _this2.props.value.clone();
348
- value = value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
349
-
350
- if (_this2.state.localeFormat === DATE_FORMATS.ISO || _this2.state.localeFormat === DATE_FORMATS.ISOAndTime) {
351
- if (parts[0] && parts[0].length === 4 && (parts[0].slice(0, 3) === '000' || parts[0].slice(0, 2) === '00')) {
352
- value.year(parts[0]);
353
- }
354
- }
355
- 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) {
356
- if (parts[2] && parts[2].length === 4 && (parts[2].slice(0, 3) === '000' || parts[2].slice(0, 2) === '00')) {
357
- value.year(parts[2]);
358
- }
359
- }
360
- if (!value || disabledDate && disabledDate(value)) {
361
- _this2.setState({ str: str });
362
- return;
363
- }
364
-
365
- if (selectedValue !== value || selectedValue && value && !selectedValue.isSame(value)) {
366
- _this2.setState({ str: str });
367
- onChange(value);
368
- }
369
- };
370
-
371
- this.onInputChangeAll = function (event) {
372
- var str = event.target.value;
373
- _this2.onInputChange(str);
374
- };
375
-
376
- this.onInputChangeDate = function (event) {
377
- var dateStr = event.target.value;
378
- _this2.setState({ dateStr: dateStr });
379
- _this2.onInputChange(dateStr);
380
- };
381
-
382
- this.onInputChangeHourMinute = function (e) {
383
- var timeStr = e.target.value;
384
- _this2.setState({ timeStr: timeStr });
385
- };
386
-
387
- this.onFocus = function () {
388
- _this2.setState({ hasFocus: true });
389
- };
390
-
391
- this.onBlur = function () {
392
- _this2.setState(function (prevState, prevProps) {
393
- return {
394
- hasFocus: false,
395
- str: formatDate(prevProps.value, prevProps.format)
396
- };
397
- });
398
- };
399
-
400
- this.onKeyDown = function (event) {
401
- var keyCode = event.keyCode;
402
- var _props3 = _this2.props,
403
- onSelect = _props3.onSelect,
404
- value = _props3.value,
405
- disabledDate = _props3.disabledDate;
406
-
407
- if (keyCode === KeyCode.ENTER && onSelect) {
408
- var validateDate = !disabledDate || !disabledDate(value);
409
- if (validateDate) {
410
- onSelect(value.clone());
411
- }
412
- event.preventDefault();
413
- }
414
- };
415
-
416
- this.getRootDOMNode = function () {
417
- return ReactDOM.findDOMNode(_this2);
418
- };
419
-
420
- this.focus = function () {
421
- if (dateInputInstance) {
422
- dateInputInstance.focus();
423
- }
424
- };
425
-
426
- this.TimeBlure = function () {
427
- var hourMinuteStr = validateTime(_this2.state.timeStr);
428
- _this2.setState({ timeStr: hourMinuteStr }, function () {
429
- _this2.onInputChange(_this2.state.str);
430
- });
431
- };
432
-
433
- this.focusTimeInput = function (timeStr) {
434
- _this2.setState({ timeStr: timeStr });
435
- };
436
-
437
- this.saveDateInput = function (dateInput) {
438
- dateInputInstance = dateInput;
439
- };
440
- };
441
-
442
- polyfill(DateInput);
443
-
444
- export default DateInput;