@seafile/seafile-calendar 0.0.30-beta.1 → 0.0.30-beta.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.
Files changed (167) hide show
  1. package/assets/index.css +1177 -0
  2. package/dist/rc-calendar.css +1179 -0
  3. package/dist/rc-calendar.css.map +1 -0
  4. package/dist/rc-calendar.js +7500 -0
  5. package/dist/rc-calendar.js.map +1 -0
  6. package/dist/rc-calendar.min.css +1179 -0
  7. package/dist/rc-calendar.min.css.map +1 -0
  8. package/dist/rc-calendar.min.js +1 -0
  9. package/es/Calendar.js +454 -0
  10. package/es/FullCalendar.js +182 -0
  11. package/es/MonthCalendar.js +135 -0
  12. package/es/Picker.js +245 -0
  13. package/es/RangeCalendar.js +876 -0
  14. package/es/calendar/CalendarFooter.js +93 -0
  15. package/es/calendar/CalendarHeader.js +257 -0
  16. package/es/calendar/CalendarRightPanel.js +135 -0
  17. package/es/calendar/OkButton.js +22 -0
  18. package/es/calendar/TimePickerButton.js +28 -0
  19. package/es/calendar/TodayButton.js +28 -0
  20. package/es/date/DateConstants.js +19 -0
  21. package/es/date/DateInput.js +444 -0
  22. package/es/date/DateTBody.js +280 -0
  23. package/es/date/DateTHead.js +86 -0
  24. package/es/date/DateTable.js +32 -0
  25. package/es/decade/DecadePanel.js +181 -0
  26. package/es/full-calendar/CalendarHeader.js +180 -0
  27. package/es/index.js +3 -0
  28. package/es/locale/ar_EG.js +27 -0
  29. package/es/locale/bg_BG.js +27 -0
  30. package/es/locale/ca_ES.js +27 -0
  31. package/es/locale/cs_CZ.js +27 -0
  32. package/es/locale/da_DK.js +27 -0
  33. package/es/locale/de_DE.js +27 -0
  34. package/es/locale/el_GR.js +27 -0
  35. package/es/locale/en_GB.js +27 -0
  36. package/es/locale/en_US.js +28 -0
  37. package/es/locale/es_ES.js +27 -0
  38. package/es/locale/et_EE.js +27 -0
  39. package/es/locale/fa_IR.js +27 -0
  40. package/es/locale/fi_FI.js +27 -0
  41. package/es/locale/fr_BE.js +27 -0
  42. package/es/locale/fr_FR.js +27 -0
  43. package/es/locale/he_IL.js +28 -0
  44. package/es/locale/hi_IN.js +28 -0
  45. package/es/locale/hr_HR.js +28 -0
  46. package/es/locale/hu_HU.js +27 -0
  47. package/es/locale/id_ID.js +28 -0
  48. package/es/locale/is_IS.js +27 -0
  49. package/es/locale/it_IT.js +27 -0
  50. package/es/locale/ja_JP.js +26 -0
  51. package/es/locale/kn_IN.js +28 -0
  52. package/es/locale/ko_KR.js +27 -0
  53. package/es/locale/ku_IQ.js +27 -0
  54. package/es/locale/lv_LV.js +27 -0
  55. package/es/locale/mm_MM.js +28 -0
  56. package/es/locale/mn_MN.js +28 -0
  57. package/es/locale/ms_MY.js +27 -0
  58. package/es/locale/nb_NO.js +27 -0
  59. package/es/locale/nl_BE.js +27 -0
  60. package/es/locale/nl_NL.js +27 -0
  61. package/es/locale/pl_PL.js +27 -0
  62. package/es/locale/pt_BR.js +27 -0
  63. package/es/locale/pt_PT.js +27 -0
  64. package/es/locale/ro_RO.js +28 -0
  65. package/es/locale/ru_RU.js +27 -0
  66. package/es/locale/sk_SK.js +27 -0
  67. package/es/locale/sl_SI.js +27 -0
  68. package/es/locale/sr_RS.js +27 -0
  69. package/es/locale/sv_SE.js +27 -0
  70. package/es/locale/ta_IN.js +28 -0
  71. package/es/locale/th_TH.js +27 -0
  72. package/es/locale/tr_TR.js +27 -0
  73. package/es/locale/ug_CN.js +26 -0
  74. package/es/locale/uk_UA.js +27 -0
  75. package/es/locale/vi_VN.js +28 -0
  76. package/es/locale/zh_CN.js +27 -0
  77. package/es/locale/zh_TW.js +26 -0
  78. package/es/mixin/CalendarMixin.js +123 -0
  79. package/es/mixin/CommonMixin.js +85 -0
  80. package/es/month/MonthPanel.js +154 -0
  81. package/es/month/MonthTable.js +156 -0
  82. package/es/picker/placements.js +35 -0
  83. package/es/range-calendar/CalendarPart.js +151 -0
  84. package/es/util/dayjs.js +17 -0
  85. package/es/util/index.js +272 -0
  86. package/es/util/toTime.js +21 -0
  87. package/es/year/YearPanel.js +194 -0
  88. package/lib/Calendar.js +517 -0
  89. package/lib/FullCalendar.js +221 -0
  90. package/lib/MonthCalendar.js +172 -0
  91. package/lib/Picker.js +282 -0
  92. package/lib/RangeCalendar.js +925 -0
  93. package/lib/calendar/CalendarFooter.js +134 -0
  94. package/lib/calendar/CalendarHeader.js +290 -0
  95. package/lib/calendar/CalendarRightPanel.js +160 -0
  96. package/lib/calendar/OkButton.js +32 -0
  97. package/lib/calendar/TimePickerButton.js +41 -0
  98. package/lib/calendar/TodayButton.js +39 -0
  99. package/lib/date/DateConstants.js +23 -0
  100. package/lib/date/DateInput.js +476 -0
  101. package/lib/date/DateTBody.js +307 -0
  102. package/lib/date/DateTHead.js +106 -0
  103. package/lib/date/DateTable.js +54 -0
  104. package/lib/decade/DecadePanel.js +207 -0
  105. package/lib/full-calendar/CalendarHeader.js +201 -0
  106. package/lib/index.js +12 -0
  107. package/lib/locale/ar_EG.js +31 -0
  108. package/lib/locale/bg_BG.js +31 -0
  109. package/lib/locale/ca_ES.js +31 -0
  110. package/lib/locale/cs_CZ.js +31 -0
  111. package/lib/locale/da_DK.js +31 -0
  112. package/lib/locale/de_DE.js +31 -0
  113. package/lib/locale/el_GR.js +31 -0
  114. package/lib/locale/en_GB.js +31 -0
  115. package/lib/locale/en_US.js +32 -0
  116. package/lib/locale/es_ES.js +31 -0
  117. package/lib/locale/et_EE.js +31 -0
  118. package/lib/locale/fa_IR.js +31 -0
  119. package/lib/locale/fi_FI.js +31 -0
  120. package/lib/locale/fr_BE.js +31 -0
  121. package/lib/locale/fr_FR.js +31 -0
  122. package/lib/locale/he_IL.js +32 -0
  123. package/lib/locale/hi_IN.js +32 -0
  124. package/lib/locale/hr_HR.js +32 -0
  125. package/lib/locale/hu_HU.js +31 -0
  126. package/lib/locale/id_ID.js +32 -0
  127. package/lib/locale/is_IS.js +31 -0
  128. package/lib/locale/it_IT.js +31 -0
  129. package/lib/locale/ja_JP.js +30 -0
  130. package/lib/locale/kn_IN.js +32 -0
  131. package/lib/locale/ko_KR.js +31 -0
  132. package/lib/locale/ku_IQ.js +31 -0
  133. package/lib/locale/lv_LV.js +31 -0
  134. package/lib/locale/mm_MM.js +32 -0
  135. package/lib/locale/mn_MN.js +32 -0
  136. package/lib/locale/ms_MY.js +31 -0
  137. package/lib/locale/nb_NO.js +31 -0
  138. package/lib/locale/nl_BE.js +31 -0
  139. package/lib/locale/nl_NL.js +31 -0
  140. package/lib/locale/pl_PL.js +31 -0
  141. package/lib/locale/pt_BR.js +31 -0
  142. package/lib/locale/pt_PT.js +31 -0
  143. package/lib/locale/ro_RO.js +32 -0
  144. package/lib/locale/ru_RU.js +31 -0
  145. package/lib/locale/sk_SK.js +31 -0
  146. package/lib/locale/sl_SI.js +31 -0
  147. package/lib/locale/sr_RS.js +31 -0
  148. package/lib/locale/sv_SE.js +31 -0
  149. package/lib/locale/ta_IN.js +32 -0
  150. package/lib/locale/th_TH.js +31 -0
  151. package/lib/locale/tr_TR.js +31 -0
  152. package/lib/locale/ug_CN.js +30 -0
  153. package/lib/locale/uk_UA.js +31 -0
  154. package/lib/locale/vi_VN.js +32 -0
  155. package/lib/locale/zh_CN.js +31 -0
  156. package/lib/locale/zh_TW.js +30 -0
  157. package/lib/mixin/CalendarMixin.js +153 -0
  158. package/lib/mixin/CommonMixin.js +106 -0
  159. package/lib/month/MonthPanel.js +179 -0
  160. package/lib/month/MonthTable.js +181 -0
  161. package/lib/picker/placements.js +39 -0
  162. package/lib/range-calendar/CalendarPart.js +184 -0
  163. package/lib/util/dayjs.js +46 -0
  164. package/lib/util/index.js +307 -0
  165. package/lib/util/toTime.js +28 -0
  166. package/lib/year/YearPanel.js +219 -0
  167. package/package.json +2 -1
@@ -0,0 +1,444 @@
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;