@seafile/seafile-calendar 0.0.30-beta.2 → 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,23 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ var DATE_ROW_COLUMN_COUNT = {
5
+ DATE_ROW_COUNT: 6,
6
+ DATE_COL_COUNT: 7
7
+ };
8
+
9
+ var DAY_NAME_TO_INDEX = {
10
+ Sunday: 0,
11
+ Monday: 1,
12
+ Tuesday: 2,
13
+ Wednesday: 3,
14
+ Thursday: 4,
15
+ Friday: 5,
16
+ Saturday: 6
17
+ };
18
+
19
+ exports["default"] = {
20
+ DATE_ROW_COLUMN_COUNT: DATE_ROW_COLUMN_COUNT,
21
+ DAY_NAME_TO_INDEX: DAY_NAME_TO_INDEX
22
+ };
23
+ module.exports = exports['default'];
@@ -0,0 +1,476 @@
1
+ 'use strict';
2
+
3
+ exports.__esModule = true;
4
+
5
+ var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
6
+
7
+ var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
8
+
9
+ var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
10
+
11
+ var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
12
+
13
+ var _inherits2 = require('babel-runtime/helpers/inherits');
14
+
15
+ var _inherits3 = _interopRequireDefault(_inherits2);
16
+
17
+ var _react = require('react');
18
+
19
+ var _react2 = _interopRequireDefault(_react);
20
+
21
+ var _reactDom = require('react-dom');
22
+
23
+ var _reactDom2 = _interopRequireDefault(_reactDom);
24
+
25
+ var _propTypes = require('prop-types');
26
+
27
+ var _propTypes2 = _interopRequireDefault(_propTypes);
28
+
29
+ var _KeyCode = require('rc-util/lib/KeyCode');
30
+
31
+ var _KeyCode2 = _interopRequireDefault(_KeyCode);
32
+
33
+ var _reactLifecyclesCompat = require('react-lifecycles-compat');
34
+
35
+ var _dayjs = require('dayjs');
36
+
37
+ var _dayjs2 = _interopRequireDefault(_dayjs);
38
+
39
+ var _util = require('../util');
40
+
41
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
42
+
43
+ var cachedSelectionStart = void 0;
44
+ var cachedSelectionEnd = void 0;
45
+ var dateInputInstance = void 0;
46
+
47
+ var DateInput = function (_React$Component) {
48
+ (0, _inherits3['default'])(DateInput, _React$Component);
49
+
50
+ function DateInput(props) {
51
+ (0, _classCallCheck3['default'])(this, DateInput);
52
+
53
+ var _this = (0, _possibleConstructorReturn3['default'])(this, _React$Component.call(this, props));
54
+
55
+ _initialiseProps.call(_this);
56
+
57
+ var selectedValue = props.selectedValue;
58
+ var formatPrefix = _this.props.format[0];
59
+ _this.state = {
60
+ timeStr: '',
61
+ dateStr: '',
62
+ str: (0, _util.formatDate)(selectedValue, _this.props.format),
63
+ hasFocus: false,
64
+ localeFormat: formatPrefix,
65
+ delimiter: (0, _util.delimate)(formatPrefix),
66
+ cananderIput: ''
67
+ };
68
+ return _this;
69
+ }
70
+
71
+ DateInput.prototype.componentDidUpdate = function componentDidUpdate() {
72
+ if (dateInputInstance && this.state.hasFocus && !(cachedSelectionStart === 0 && cachedSelectionEnd === 0)) {
73
+ dateInputInstance.setSelectionRange(cachedSelectionStart, cachedSelectionEnd);
74
+ }
75
+ };
76
+
77
+ DateInput.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, state) {
78
+ var newState = {};
79
+
80
+ if (dateInputInstance) {
81
+ cachedSelectionStart = dateInputInstance.selectionStart;
82
+ cachedSelectionEnd = dateInputInstance.selectionEnd;
83
+ }
84
+ // when popup show, click body will call this, bug!
85
+ var selectedValue = nextProps.selectedValue;
86
+ if (!state.hasFocus) {
87
+ var timeStr = (0, _util.formatDate)(selectedValue, nextProps.format).split(' ')[0];
88
+ var parts = timeStr.split(state.delimiter);
89
+ var timeParts = (0, _util.formatDate)(selectedValue, nextProps.format).split(' ')[1];
90
+ if (parts.length === 3) {
91
+ if (state.localeFormat === _util.DATE_FORMATS.ISO) {
92
+ newState = { str: parts[0].padStart(4, 0) + '-' + parts[1] + '-' + parts[2] };
93
+ } else if (state.localeFormat === _util.DATE_FORMATS.ISOAndTime) {
94
+ newState = {
95
+ str: parts[0].padStart(4, 0) + '-' + parts[1] + '-' + parts[2] + ' ' + (nextProps.showHourAndMinute ? timeParts : ''), // eslint-disable-line max-len
96
+ dateStr: parts[0].padStart(4, 0) + '-' + parts[1] + '-' + parts[2]
97
+ };
98
+ } else if (state.localeFormat === _util.DATE_FORMATS.US) {
99
+ newState = { str: Number(parts[0]) + '/' + Number(parts[1]) + '/' + parts[2].padStart(4, 0) };
100
+ } else if (state.localeFormat === _util.DATE_FORMATS.USAndTime) {
101
+ newState = {
102
+ str: Number(parts[0]) + '/' + Number(parts[1]) + '/' + parts[2].padStart(4, 0) + ' ' + (nextProps.showHourAndMinute ? timeParts : ''), // eslint-disable-line max-len
103
+ dateStr: Number(parts[0]) + '/' + Number(parts[1]) + '/' + parts[2].padStart(4, 0)
104
+ };
105
+ } else if (state.localeFormat === _util.DATE_FORMATS.European || state.localeFormat === _util.DATE_FORMATS.Germany_Russia_etc) {
106
+ newState = { str: '' + Number(parts[0]) + state.delimiter + Number(parts[1]) + state.delimiter + parts[2].padStart(4, 0) }; // eslint-disable-line max-len
107
+ } else if (state.localeFormat === _util.DATE_FORMATS.EuropeanAndTime || state.localeFormat === _util.DATE_FORMATS.Germany_Russia_etcAndTime) {
108
+ newState = {
109
+ str: '' + Number(parts[0]) + state.delimiter + Number(parts[1]) + state.delimiter + parts[2].padStart(4, 0) + ' ' + (nextProps.showHourAndMinute ? timeParts : ''), // eslint-disable-line max-len
110
+ dateStr: '' + Number(parts[0]) + state.delimiter + Number(parts[1]) + state.delimiter + parts[2].padStart(4, 0) // eslint-disable-line max-len
111
+ };
112
+ }
113
+ }
114
+ }
115
+ return newState;
116
+ };
117
+
118
+ DateInput.getInstance = function getInstance() {
119
+ return dateInputInstance;
120
+ };
121
+
122
+ DateInput.prototype.normalizeDateInput = function normalizeDateInput(str) {
123
+ var day = void 0;
124
+ var month = void 0;
125
+ var year = void 0;
126
+ var parts = (0, _util.formatDateLocal)(str, this.state.localeFormat, _util.DATE_FORMATS);
127
+ var delimiter = this.state.delimiter;
128
+ var hasSpecial = (0, _util.hasSpecialChar)(str);
129
+ if (this.state.localeFormat === _util.DATE_FORMATS.ISO || this.state.localeFormat === _util.DATE_FORMATS.ISOAndTime) {
130
+ var numStr = str.replace(/[^0-9]/g, '');
131
+ if (numStr.length === 7) {
132
+ year = numStr.slice(0, 4);
133
+ month = numStr.slice(4, 6).padStart(2, '0');
134
+ day = numStr.slice(6, 7).padStart(2, '0');
135
+ if (!(0, _util.isValidDay)(day)) {
136
+ return year + '-' + _util.stringCurrentMonth + '-' + _util.stringCurrentDate;
137
+ }
138
+ return year + '-' + month + '-' + day;
139
+ }
140
+ if (hasSpecial) {
141
+ year = (0, _util.fullValidYear)(parts[0]);
142
+ month = Number(parts[1]);
143
+ day = Number(parts[2]);
144
+ if (month >= 1 && month <= 12) {
145
+ if ((0, _util.isValidDay)(day)) {
146
+ return year + '-' + String(month).padStart(2, '0') + '-' + String(day).padStart(2, '0');
147
+ }
148
+ return year + '-' + String(month).padStart(2, '0') + '-01';
149
+ }
150
+ if ((month >= 13 || month < 1) && isNaN(day)) {
151
+ return year + '-' + _util.stringCurrentMonth + '-' + _util.stringCurrentDate;
152
+ }
153
+ if (!month && !day) {
154
+ return year + '-01-01';
155
+ }
156
+ }
157
+ if (str.length >= 1 && str.length <= 8) {
158
+ year = (0, _util.fullValidYear)(str.slice(0, 4));
159
+ month = str.slice(4, 6);
160
+ day = Number(str.slice(6, 8));
161
+ if (str.length === 5 && Number(month) < 1) {
162
+ return year + '-' + _util.stringCurrentMonth + '-' + _util.stringCurrentDate + ' ';
163
+ }
164
+ if (str.length === 6 && Number(month) < 1) {
165
+ return year + '-' + _util.stringCurrentMonth + '-' + _util.stringCurrentDate;
166
+ }
167
+ if (str.length === 7) {
168
+ if (!(0, _util.isValidDay)(day)) {
169
+ return year + '-' + String((0, _util.isValidMonth)(month)).padStart(2, '0') + '-' + _util.stringCurrentDate;
170
+ }
171
+ return year + '-' + String((0, _util.isValidMonth)(month)).padStart(2, '0') + '-' + String(day).padStart(2, '0'); // eslint-disable-line max-len
172
+ }
173
+ if (str.length === 8) {
174
+ if (!(0, _util.isValidDay)(day)) {
175
+ return (0, _util.isCurrentYear)(year, month, day) + '-' + String((0, _util.isValidMonth)(month)).padStart(2, '0') + '-' + _util.stringCurrentDate; // eslint-disable-line max-len
176
+ }
177
+ return (0, _util.isCurrentYear)(year, month, day) + '-' + String((0, _util.isValidMonth)(month)).padStart(2, '0') + '-' + String(day).padStart(2, '0'); // eslint-disable-line max-len
178
+ }
179
+ if (Number(month) >= 1 && Number(month) <= 12 && (0, _util.isValidDay)(day)) {
180
+ return year + '-' + month.padStart(2, '0') + '-' + String(day).padStart(2, '0');
181
+ }
182
+ return year + '-' + (month ? month.padStart(2, '0') : '01') + '-' + (day ? String(day).padStart(2, '0') : '01'); // eslint-disable-line max-len
183
+ }
184
+ return _util.currentYear + '/' + _util.stringCurrentMonth + '/' + _util.stringCurrentDate;
185
+ }
186
+ if (this.state.localeFormat === _util.DATE_FORMATS.US || this.state.localeFormat === _util.DATE_FORMATS.USAndTime) {
187
+ if (hasSpecial) {
188
+ month = Number(parts[0]);
189
+ day = Number(parts[1]);
190
+ year = (0, _util.fullValidYear)(parts[2]);
191
+ if (month >= 1 && month <= 12 && (0, _util.isValidDay)(day)) {
192
+ return month + '/' + day + '/' + year;
193
+ }
194
+ return _util.currentMonth + '/' + _util.currentDate + '/' + _util.currentYear;
195
+ }
196
+ if (str.length >= 1 && str.length <= 8) {
197
+ month = Number(str.slice(0, 2));
198
+ day = Number(str.slice(2, 4));
199
+ year = (0, _util.fullValidYear)(str.slice(4, str.length));
200
+ if (month >= 1 && month <= 12) {
201
+ if ((0, _util.isValidDay)(day)) {
202
+ return month + '/' + day + '/' + year;
203
+ }
204
+ if (!day) {
205
+ return month + '/1/' + year;
206
+ }
207
+ return _util.currentMonth + '/' + _util.currentDate + '/' + _util.currentYear;
208
+ }
209
+ }
210
+ return _util.currentMonth + '/' + _util.currentDate + '/' + _util.currentYear;
211
+ }
212
+ if (this.state.localeFormat === _util.DATE_FORMATS.European || this.state.localeFormat === _util.DATE_FORMATS.EuropeanAndTime || this.state.localeFormat === _util.DATE_FORMATS.Germany_Russia_etcAndTime || this.state.localeFormat === _util.DATE_FORMATS.Germany_Russia_etc) {
213
+ if (hasSpecial) {
214
+ day = parts[0];
215
+ month = parts[1];
216
+ year = (0, _util.fullValidYear)(parts[2]);
217
+ if ((0, _util.isValidDay)(day) && Number(month) >= 1 && Number(month) <= 12) {
218
+ return '' + Number(day) + delimiter + Number(month) + delimiter + year;
219
+ }
220
+ return '' + _util.currentDate + delimiter + _util.currentMonth + delimiter + _util.currentYear;
221
+ }
222
+ if (str.length >= 1 && str.length <= 8) {
223
+ day = Number(str.slice(0, 2));
224
+ var monthStr = str.slice(2, 4);
225
+ month = (0, _util.isValidMonth)(monthStr);
226
+ var yearStr = str.slice(4, str.length);
227
+ year = (0, _util.fullValidYear)(yearStr);
228
+ if (Number(monthStr) >= 1 && Number(monthStr) <= 12 && (0, _util.isValidDay)(day)) {
229
+ return '' + Number(day) + delimiter + Number(month) + delimiter + year;
230
+ }
231
+ }
232
+ return '' + _util.currentDate + delimiter + _util.currentMonth + delimiter + _util.currentYear;
233
+ }
234
+ };
235
+
236
+ DateInput.prototype.render = function render() {
237
+ var props = this.props;
238
+ var _state = this.state,
239
+ str = _state.str,
240
+ dateStr = _state.dateStr,
241
+ timeStr = _state.timeStr;
242
+ var locale = props.locale,
243
+ prefixCls = props.prefixCls,
244
+ placeholder = props.placeholder,
245
+ clearIcon = props.clearIcon,
246
+ inputMode = props.inputMode,
247
+ showHourAndMinute = props.showHourAndMinute;
248
+
249
+ return _react2['default'].createElement(
250
+ 'div',
251
+ { className: prefixCls + '-input-wrap' },
252
+ showHourAndMinute ? _react2['default'].createElement(
253
+ 'div',
254
+ { className: prefixCls + '-date-input-wrap', style: { display: 'flex' } },
255
+ _react2['default'].createElement(
256
+ 'div',
257
+ null,
258
+ _react2['default'].createElement('input', {
259
+ ref: this.saveDateInput,
260
+ className: prefixCls + '-input',
261
+ value: dateStr,
262
+ disabled: props.disabled,
263
+ placeholder: placeholder.slice(0, 10),
264
+ onChange: this.onInputChangeDate,
265
+ onKeyDown: this.onKeyDown,
266
+ onFocus: this.onFocus,
267
+ onBlur: this.onBlur,
268
+ inputMode: inputMode
269
+ })
270
+ ),
271
+ _react2['default'].createElement(
272
+ 'div',
273
+ null,
274
+ _react2['default'].createElement('input', {
275
+ ref: this.saveDateInput,
276
+ className: prefixCls + '-input',
277
+ value: timeStr,
278
+ disabled: props.disabled,
279
+ placeholder: 'HH:mm',
280
+ onChange: this.onInputChangeHourMinute,
281
+ onKeyDown: this.onKeyDown,
282
+ onFocus: this.onFocus,
283
+ onBlur: this.TimeBlure,
284
+ inputMode: inputMode
285
+ })
286
+ )
287
+ ) : _react2['default'].createElement(
288
+ 'div',
289
+ { className: prefixCls + '-date-input-wrap', style: { display: 'flex' } },
290
+ _react2['default'].createElement('input', {
291
+ ref: this.saveDateInput,
292
+ className: prefixCls + '-input',
293
+ value: str,
294
+ disabled: props.disabled,
295
+ placeholder: placeholder,
296
+ onChange: this.onInputChangeAll,
297
+ onKeyDown: this.onKeyDown,
298
+ onFocus: this.onFocus,
299
+ onBlur: this.onBlur,
300
+ inputMode: inputMode
301
+ })
302
+ ),
303
+ props.showClear ? _react2['default'].createElement(
304
+ 'a',
305
+ {
306
+ role: 'button',
307
+ title: locale.clear,
308
+ onClick: this.onClear
309
+ },
310
+ clearIcon || _react2['default'].createElement('span', { className: prefixCls + '-clear-btn' })
311
+ ) : null
312
+ );
313
+ };
314
+
315
+ return DateInput;
316
+ }(_react2['default'].Component);
317
+
318
+ DateInput.propTypes = {
319
+ prefixCls: _propTypes2['default'].string,
320
+ timePicker: _propTypes2['default'].object,
321
+ value: _propTypes2['default'].object,
322
+ disabledTime: _propTypes2['default'].any,
323
+ format: _propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].arrayOf(_propTypes2['default'].string)]),
324
+ locale: _propTypes2['default'].object,
325
+ disabledDate: _propTypes2['default'].func,
326
+ onChange: _propTypes2['default'].func,
327
+ onClear: _propTypes2['default'].func,
328
+ placeholder: _propTypes2['default'].string,
329
+ onSelect: _propTypes2['default'].func,
330
+ selectedValue: _propTypes2['default'].object,
331
+ clearIcon: _propTypes2['default'].node,
332
+ inputMode: _propTypes2['default'].string,
333
+ showHourAndMinute: _propTypes2['default'].bool,
334
+ onChangeCananderIput: _propTypes2['default'].func
335
+ };
336
+
337
+ var _initialiseProps = function _initialiseProps() {
338
+ var _this2 = this;
339
+
340
+ this.onClear = function () {
341
+ var _props = _this2.props,
342
+ showHourAndMinute = _props.showHourAndMinute,
343
+ onClear = _props.onClear;
344
+
345
+ if (showHourAndMinute) {
346
+ _this2.setState({
347
+ dateStr: '',
348
+ timeStr: ''
349
+ });
350
+ } else {
351
+ _this2.setState({
352
+ str: ''
353
+ });
354
+ }
355
+ onClear(null);
356
+ };
357
+
358
+ this.onInputChange = function (str) {
359
+ var cananderStr = _this2.normalizeDateInput(str, _this2.props.showHourAndMinute);
360
+ var _props2 = _this2.props,
361
+ disabledDate = _props2.disabledDate,
362
+ onChange = _props2.onChange,
363
+ selectedValue = _props2.selectedValue;
364
+
365
+ var parts = (0, _util.formatDateLocal)(cananderStr, _this2.state.localeFormat);
366
+ var hourMinuteStr = (0, _util.validateTime)(_this2.state.timeStr);
367
+ _this2.setState({ timeStr: hourMinuteStr });
368
+ cananderStr = cananderStr + ' ' + hourMinuteStr;
369
+ // 没有内容,合法并直接退出
370
+ if (!str) {
371
+ onChange(null);
372
+ _this2.setState({ str: str });
373
+ return;
374
+ }
375
+ // 不合法直接退出
376
+ var format = (0, _util.getDateFormatByStr)(cananderStr, _this2.state.localeFormat);
377
+ var parsed = (0, _dayjs2['default'])(cananderStr, format);
378
+ var value = _this2.props.value.clone();
379
+ value = value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
380
+
381
+ if (_this2.state.localeFormat === _util.DATE_FORMATS.ISO || _this2.state.localeFormat === _util.DATE_FORMATS.ISOAndTime) {
382
+ if (parts[0] && parts[0].length === 4 && (parts[0].slice(0, 3) === '000' || parts[0].slice(0, 2) === '00')) {
383
+ value.year(parts[0]);
384
+ }
385
+ }
386
+ if (_this2.state.localeFormat === _util.DATE_FORMATS.European || _this2.state.localeFormat === _util.DATE_FORMATS.EuropeanAndTime || _this2.state.localeFormat === _util.DATE_FORMATS.US || _this2.state.localeFormat === _util.DATE_FORMATS.USAndTime || _this2.state.localeFormat === _util.DATE_FORMATS.Germany_Russia_etc || _this2.state.localeFormat === _util.DATE_FORMATS.Germany_Russia_etcAndTime) {
387
+ if (parts[2] && parts[2].length === 4 && (parts[2].slice(0, 3) === '000' || parts[2].slice(0, 2) === '00')) {
388
+ value.year(parts[2]);
389
+ }
390
+ }
391
+ if (!value || disabledDate && disabledDate(value)) {
392
+ _this2.setState({ str: str });
393
+ return;
394
+ }
395
+
396
+ if (selectedValue !== value || selectedValue && value && !selectedValue.isSame(value)) {
397
+ _this2.setState({ str: str });
398
+ onChange(value);
399
+ }
400
+ };
401
+
402
+ this.onInputChangeAll = function (event) {
403
+ var str = event.target.value;
404
+ _this2.onInputChange(str);
405
+ };
406
+
407
+ this.onInputChangeDate = function (event) {
408
+ var dateStr = event.target.value;
409
+ _this2.setState({ dateStr: dateStr });
410
+ _this2.onInputChange(dateStr);
411
+ };
412
+
413
+ this.onInputChangeHourMinute = function (e) {
414
+ var timeStr = e.target.value;
415
+ _this2.setState({ timeStr: timeStr });
416
+ };
417
+
418
+ this.onFocus = function () {
419
+ _this2.setState({ hasFocus: true });
420
+ };
421
+
422
+ this.onBlur = function () {
423
+ _this2.setState(function (prevState, prevProps) {
424
+ return {
425
+ hasFocus: false,
426
+ str: (0, _util.formatDate)(prevProps.value, prevProps.format)
427
+ };
428
+ });
429
+ };
430
+
431
+ this.onKeyDown = function (event) {
432
+ var keyCode = event.keyCode;
433
+ var _props3 = _this2.props,
434
+ onSelect = _props3.onSelect,
435
+ value = _props3.value,
436
+ disabledDate = _props3.disabledDate;
437
+
438
+ if (keyCode === _KeyCode2['default'].ENTER && onSelect) {
439
+ var validateDate = !disabledDate || !disabledDate(value);
440
+ if (validateDate) {
441
+ onSelect(value.clone());
442
+ }
443
+ event.preventDefault();
444
+ }
445
+ };
446
+
447
+ this.getRootDOMNode = function () {
448
+ return _reactDom2['default'].findDOMNode(_this2);
449
+ };
450
+
451
+ this.focus = function () {
452
+ if (dateInputInstance) {
453
+ dateInputInstance.focus();
454
+ }
455
+ };
456
+
457
+ this.TimeBlure = function () {
458
+ var hourMinuteStr = (0, _util.validateTime)(_this2.state.timeStr);
459
+ _this2.setState({ timeStr: hourMinuteStr }, function () {
460
+ _this2.onInputChange(_this2.state.str);
461
+ });
462
+ };
463
+
464
+ this.focusTimeInput = function (timeStr) {
465
+ _this2.setState({ timeStr: timeStr });
466
+ };
467
+
468
+ this.saveDateInput = function (dateInput) {
469
+ dateInputInstance = dateInput;
470
+ };
471
+ };
472
+
473
+ (0, _reactLifecyclesCompat.polyfill)(DateInput);
474
+
475
+ exports['default'] = DateInput;
476
+ module.exports = exports['default'];