@seafile/seafile-calendar 0.0.29-alpha.2 → 0.0.29-alpha.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 (160) hide show
  1. package/assets/index.css +1177 -0
  2. package/es/Calendar.js +440 -0
  3. package/es/FullCalendar.js +182 -0
  4. package/es/MonthCalendar.js +135 -0
  5. package/es/Picker.js +245 -0
  6. package/es/RangeCalendar.js +876 -0
  7. package/es/calendar/CalendarFooter.js +93 -0
  8. package/es/calendar/CalendarHeader.js +257 -0
  9. package/es/calendar/CalendarRightPanel.js +121 -0
  10. package/es/calendar/OkButton.js +22 -0
  11. package/es/calendar/TimePickerButton.js +28 -0
  12. package/es/calendar/TodayButton.js +28 -0
  13. package/es/date/DateConstants.js +19 -0
  14. package/es/date/DateInput.js +233 -0
  15. package/es/date/DateTBody.js +280 -0
  16. package/es/date/DateTHead.js +85 -0
  17. package/es/date/DateTable.js +32 -0
  18. package/es/decade/DecadePanel.js +181 -0
  19. package/es/full-calendar/CalendarHeader.js +180 -0
  20. package/es/index.js +3 -0
  21. package/es/locale/ar_EG.js +27 -0
  22. package/es/locale/bg_BG.js +27 -0
  23. package/es/locale/ca_ES.js +27 -0
  24. package/es/locale/cs_CZ.js +27 -0
  25. package/es/locale/da_DK.js +27 -0
  26. package/es/locale/de_DE.js +27 -0
  27. package/es/locale/el_GR.js +27 -0
  28. package/es/locale/en_GB.js +27 -0
  29. package/es/locale/en_US.js +28 -0
  30. package/es/locale/es_ES.js +27 -0
  31. package/es/locale/et_EE.js +27 -0
  32. package/es/locale/fa_IR.js +27 -0
  33. package/es/locale/fi_FI.js +27 -0
  34. package/es/locale/fr_BE.js +27 -0
  35. package/es/locale/fr_FR.js +27 -0
  36. package/es/locale/he_IL.js +28 -0
  37. package/es/locale/hi_IN.js +28 -0
  38. package/es/locale/hr_HR.js +28 -0
  39. package/es/locale/hu_HU.js +27 -0
  40. package/es/locale/id_ID.js +28 -0
  41. package/es/locale/is_IS.js +27 -0
  42. package/es/locale/it_IT.js +27 -0
  43. package/es/locale/ja_JP.js +26 -0
  44. package/es/locale/kn_IN.js +28 -0
  45. package/es/locale/ko_KR.js +27 -0
  46. package/es/locale/ku_IQ.js +27 -0
  47. package/es/locale/lv_LV.js +27 -0
  48. package/es/locale/mm_MM.js +28 -0
  49. package/es/locale/mn_MN.js +28 -0
  50. package/es/locale/ms_MY.js +27 -0
  51. package/es/locale/nb_NO.js +27 -0
  52. package/es/locale/nl_BE.js +27 -0
  53. package/es/locale/nl_NL.js +27 -0
  54. package/es/locale/pl_PL.js +27 -0
  55. package/es/locale/pt_BR.js +27 -0
  56. package/es/locale/pt_PT.js +27 -0
  57. package/es/locale/ro_RO.js +28 -0
  58. package/es/locale/ru_RU.js +27 -0
  59. package/es/locale/sk_SK.js +27 -0
  60. package/es/locale/sl_SI.js +27 -0
  61. package/es/locale/sr_RS.js +27 -0
  62. package/es/locale/sv_SE.js +27 -0
  63. package/es/locale/ta_IN.js +28 -0
  64. package/es/locale/th_TH.js +27 -0
  65. package/es/locale/tr_TR.js +27 -0
  66. package/es/locale/ug_CN.js +26 -0
  67. package/es/locale/uk_UA.js +27 -0
  68. package/es/locale/vi_VN.js +28 -0
  69. package/es/locale/zh_CN.js +27 -0
  70. package/es/locale/zh_TW.js +26 -0
  71. package/es/mixin/CalendarMixin.js +123 -0
  72. package/es/mixin/CommonMixin.js +85 -0
  73. package/es/month/MonthPanel.js +154 -0
  74. package/es/month/MonthTable.js +156 -0
  75. package/es/picker/placements.js +35 -0
  76. package/es/range-calendar/CalendarPart.js +151 -0
  77. package/es/util/dayjs.js +17 -0
  78. package/es/util/index.js +105 -0
  79. package/es/util/toTime.js +21 -0
  80. package/es/year/YearPanel.js +194 -0
  81. package/lib/Calendar.js +503 -0
  82. package/lib/FullCalendar.js +221 -0
  83. package/lib/MonthCalendar.js +172 -0
  84. package/lib/Picker.js +282 -0
  85. package/lib/RangeCalendar.js +925 -0
  86. package/lib/calendar/CalendarFooter.js +134 -0
  87. package/lib/calendar/CalendarHeader.js +290 -0
  88. package/lib/calendar/CalendarRightPanel.js +145 -0
  89. package/lib/calendar/OkButton.js +32 -0
  90. package/lib/calendar/TimePickerButton.js +41 -0
  91. package/lib/calendar/TodayButton.js +39 -0
  92. package/lib/date/DateConstants.js +23 -0
  93. package/lib/date/DateInput.js +265 -0
  94. package/lib/date/DateTBody.js +307 -0
  95. package/lib/date/DateTHead.js +105 -0
  96. package/lib/date/DateTable.js +54 -0
  97. package/lib/decade/DecadePanel.js +207 -0
  98. package/lib/full-calendar/CalendarHeader.js +201 -0
  99. package/lib/index.js +12 -0
  100. package/lib/locale/ar_EG.js +31 -0
  101. package/lib/locale/bg_BG.js +31 -0
  102. package/lib/locale/ca_ES.js +31 -0
  103. package/lib/locale/cs_CZ.js +31 -0
  104. package/lib/locale/da_DK.js +31 -0
  105. package/lib/locale/de_DE.js +31 -0
  106. package/lib/locale/el_GR.js +31 -0
  107. package/lib/locale/en_GB.js +31 -0
  108. package/lib/locale/en_US.js +32 -0
  109. package/lib/locale/es_ES.js +31 -0
  110. package/lib/locale/et_EE.js +31 -0
  111. package/lib/locale/fa_IR.js +31 -0
  112. package/lib/locale/fi_FI.js +31 -0
  113. package/lib/locale/fr_BE.js +31 -0
  114. package/lib/locale/fr_FR.js +31 -0
  115. package/lib/locale/he_IL.js +32 -0
  116. package/lib/locale/hi_IN.js +32 -0
  117. package/lib/locale/hr_HR.js +32 -0
  118. package/lib/locale/hu_HU.js +31 -0
  119. package/lib/locale/id_ID.js +32 -0
  120. package/lib/locale/is_IS.js +31 -0
  121. package/lib/locale/it_IT.js +31 -0
  122. package/lib/locale/ja_JP.js +30 -0
  123. package/lib/locale/kn_IN.js +32 -0
  124. package/lib/locale/ko_KR.js +31 -0
  125. package/lib/locale/ku_IQ.js +31 -0
  126. package/lib/locale/lv_LV.js +31 -0
  127. package/lib/locale/mm_MM.js +32 -0
  128. package/lib/locale/mn_MN.js +32 -0
  129. package/lib/locale/ms_MY.js +31 -0
  130. package/lib/locale/nb_NO.js +31 -0
  131. package/lib/locale/nl_BE.js +31 -0
  132. package/lib/locale/nl_NL.js +31 -0
  133. package/lib/locale/pl_PL.js +31 -0
  134. package/lib/locale/pt_BR.js +31 -0
  135. package/lib/locale/pt_PT.js +31 -0
  136. package/lib/locale/ro_RO.js +32 -0
  137. package/lib/locale/ru_RU.js +31 -0
  138. package/lib/locale/sk_SK.js +31 -0
  139. package/lib/locale/sl_SI.js +31 -0
  140. package/lib/locale/sr_RS.js +31 -0
  141. package/lib/locale/sv_SE.js +31 -0
  142. package/lib/locale/ta_IN.js +32 -0
  143. package/lib/locale/th_TH.js +31 -0
  144. package/lib/locale/tr_TR.js +31 -0
  145. package/lib/locale/ug_CN.js +30 -0
  146. package/lib/locale/uk_UA.js +31 -0
  147. package/lib/locale/vi_VN.js +32 -0
  148. package/lib/locale/zh_CN.js +31 -0
  149. package/lib/locale/zh_TW.js +30 -0
  150. package/lib/mixin/CalendarMixin.js +153 -0
  151. package/lib/mixin/CommonMixin.js +106 -0
  152. package/lib/month/MonthPanel.js +179 -0
  153. package/lib/month/MonthTable.js +181 -0
  154. package/lib/picker/placements.js +39 -0
  155. package/lib/range-calendar/CalendarPart.js +184 -0
  156. package/lib/util/dayjs.js +46 -0
  157. package/lib/util/index.js +130 -0
  158. package/lib/util/toTime.js +28 -0
  159. package/lib/year/YearPanel.js +219 -0
  160. package/package.json +1 -1
@@ -0,0 +1,233 @@
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 } 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
+
28
+ _this.state = {
29
+ str: formatDate(selectedValue, _this.props.format),
30
+ invalid: false,
31
+ hasFocus: false
32
+ };
33
+ return _this;
34
+ }
35
+
36
+ DateInput.prototype.componentDidUpdate = function componentDidUpdate() {
37
+ if (dateInputInstance && this.state.hasFocus && !this.state.invalid && !(cachedSelectionStart === 0 && cachedSelectionEnd === 0)) {
38
+ dateInputInstance.setSelectionRange(cachedSelectionStart, cachedSelectionEnd);
39
+ }
40
+ };
41
+
42
+ DateInput.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, state) {
43
+ var newState = {};
44
+
45
+ if (dateInputInstance) {
46
+ cachedSelectionStart = dateInputInstance.selectionStart;
47
+ cachedSelectionEnd = dateInputInstance.selectionEnd;
48
+ }
49
+ // when popup show, click body will call this, bug!
50
+ var selectedValue = nextProps.selectedValue;
51
+ if (!state.hasFocus) {
52
+ newState = {
53
+ str: formatDate(selectedValue, nextProps.format),
54
+ invalid: false
55
+ };
56
+ }
57
+
58
+ return newState;
59
+ };
60
+
61
+ DateInput.getInstance = function getInstance() {
62
+ return dateInputInstance;
63
+ };
64
+
65
+ DateInput.prototype.render = function render() {
66
+ var props = this.props;
67
+ var _state = this.state,
68
+ invalid = _state.invalid,
69
+ str = _state.str;
70
+ var locale = props.locale,
71
+ prefixCls = props.prefixCls,
72
+ placeholder = props.placeholder,
73
+ clearIcon = props.clearIcon,
74
+ inputMode = props.inputMode;
75
+
76
+ var invalidClass = invalid ? prefixCls + '-input-invalid' : '';
77
+ return React.createElement(
78
+ 'div',
79
+ { className: prefixCls + '-input-wrap' },
80
+ React.createElement(
81
+ 'div',
82
+ { className: prefixCls + '-date-input-wrap' },
83
+ React.createElement('input', {
84
+ ref: this.saveDateInput,
85
+ className: prefixCls + '-input ' + invalidClass,
86
+ value: str,
87
+ disabled: props.disabled,
88
+ placeholder: placeholder,
89
+ onChange: this.onInputChange,
90
+ onKeyDown: this.onKeyDown,
91
+ onFocus: this.onFocus,
92
+ onBlur: this.onBlur,
93
+ inputMode: inputMode
94
+ })
95
+ ),
96
+ props.showClear ? React.createElement(
97
+ 'a',
98
+ {
99
+ role: 'button',
100
+ title: locale.clear,
101
+ onClick: this.onClear
102
+ },
103
+ clearIcon || React.createElement('span', { className: prefixCls + '-clear-btn' })
104
+ ) : null
105
+ );
106
+ };
107
+
108
+ return DateInput;
109
+ }(React.Component);
110
+
111
+ DateInput.propTypes = {
112
+ prefixCls: PropTypes.string,
113
+ timePicker: PropTypes.object,
114
+ value: PropTypes.object,
115
+ disabledTime: PropTypes.any,
116
+ format: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
117
+ locale: PropTypes.object,
118
+ disabledDate: PropTypes.func,
119
+ onChange: PropTypes.func,
120
+ onClear: PropTypes.func,
121
+ placeholder: PropTypes.string,
122
+ onSelect: PropTypes.func,
123
+ selectedValue: PropTypes.object,
124
+ clearIcon: PropTypes.node,
125
+ inputMode: PropTypes.string
126
+ };
127
+
128
+ var _initialiseProps = function _initialiseProps() {
129
+ var _this2 = this;
130
+
131
+ this.onClear = function () {
132
+ _this2.setState({
133
+ str: ''
134
+ });
135
+ _this2.props.onClear(null);
136
+ };
137
+
138
+ this.onInputChange = function (event) {
139
+ var str = event.target.value;
140
+ var _props = _this2.props,
141
+ disabledDate = _props.disabledDate,
142
+ format = _props.format,
143
+ onChange = _props.onChange,
144
+ selectedValue = _props.selectedValue;
145
+
146
+ // 没有内容,合法并直接退出
147
+
148
+ if (!str) {
149
+ onChange(null);
150
+ _this2.setState({
151
+ invalid: false,
152
+ str: str
153
+ });
154
+ return;
155
+ }
156
+
157
+ // 不合法直接退出
158
+ var parsed = dayjs(str, format, true);
159
+ if (!parsed.isValid()) {
160
+ _this2.setState({
161
+ invalid: true,
162
+ str: str
163
+ });
164
+ return;
165
+ }
166
+
167
+ var value = _this2.props.value.clone();
168
+ value = value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
169
+
170
+ if (!value || disabledDate && disabledDate(value)) {
171
+ _this2.setState({
172
+ invalid: true,
173
+ str: str
174
+ });
175
+ return;
176
+ }
177
+
178
+ if (selectedValue !== value || selectedValue && value && !selectedValue.isSame(value)) {
179
+ _this2.setState({
180
+ invalid: false,
181
+ str: str
182
+ });
183
+ onChange(value);
184
+ }
185
+ };
186
+
187
+ this.onFocus = function () {
188
+ _this2.setState({ hasFocus: true });
189
+ };
190
+
191
+ this.onBlur = function () {
192
+ _this2.setState(function (prevState, prevProps) {
193
+ return {
194
+ hasFocus: false,
195
+ str: formatDate(prevProps.value, prevProps.format)
196
+ };
197
+ });
198
+ };
199
+
200
+ this.onKeyDown = function (event) {
201
+ var keyCode = event.keyCode;
202
+ var _props2 = _this2.props,
203
+ onSelect = _props2.onSelect,
204
+ value = _props2.value,
205
+ disabledDate = _props2.disabledDate;
206
+
207
+ if (keyCode === KeyCode.ENTER && onSelect) {
208
+ var validateDate = !disabledDate || !disabledDate(value);
209
+ if (validateDate) {
210
+ onSelect(value.clone());
211
+ }
212
+ event.preventDefault();
213
+ }
214
+ };
215
+
216
+ this.getRootDOMNode = function () {
217
+ return ReactDOM.findDOMNode(_this2);
218
+ };
219
+
220
+ this.focus = function () {
221
+ if (dateInputInstance) {
222
+ dateInputInstance.focus();
223
+ }
224
+ };
225
+
226
+ this.saveDateInput = function (dateInput) {
227
+ dateInputInstance = dateInput;
228
+ };
229
+ };
230
+
231
+ polyfill(DateInput);
232
+
233
+ export default DateInput;
@@ -0,0 +1,280 @@
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 PropTypes from 'prop-types';
6
+ import cx from 'classnames';
7
+ import DateConstants from './DateConstants';
8
+ import { getTitleString, getTodayTime } from '../util/';
9
+
10
+ var DATE_ROW_COLUMN_COUNT = DateConstants.DATE_ROW_COLUMN_COUNT,
11
+ DAY_NAME_TO_INDEX = DateConstants.DAY_NAME_TO_INDEX;
12
+
13
+
14
+ function isSameDay(one, two) {
15
+ return one && two && one.isSame(two, 'day');
16
+ }
17
+
18
+ function beforeCurrentMonthYear(current, today) {
19
+ if (current.year() < today.year()) {
20
+ return 1;
21
+ }
22
+ return current.year() === today.year() && current.month() < today.month();
23
+ }
24
+
25
+ function afterCurrentMonthYear(current, today) {
26
+ if (current.year() > today.year()) {
27
+ return 1;
28
+ }
29
+ return current.year() === today.year() && current.month() > today.month();
30
+ }
31
+
32
+ function getIdFromDate(date) {
33
+ return 'rc-calendar-' + date.year() + '-' + date.month() + '-' + date.date();
34
+ }
35
+
36
+ var DateTBody = function (_React$Component) {
37
+ _inherits(DateTBody, _React$Component);
38
+
39
+ function DateTBody() {
40
+ _classCallCheck(this, DateTBody);
41
+
42
+ return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
43
+ }
44
+
45
+ DateTBody.prototype.render = function render() {
46
+ var props = this.props;
47
+ var contentRender = props.contentRender,
48
+ prefixCls = props.prefixCls,
49
+ selectedValue = props.selectedValue,
50
+ value = props.value,
51
+ showWeekNumber = props.showWeekNumber,
52
+ dateRender = props.dateRender,
53
+ disabledDate = props.disabledDate,
54
+ hoverValue = props.hoverValue,
55
+ firstDayOfWeek = props.firstDayOfWeek;
56
+
57
+ var iIndex = void 0;
58
+ var jIndex = void 0;
59
+ var current = void 0;
60
+ var dateTable = [];
61
+ var today = getTodayTime(value);
62
+ var cellClass = prefixCls + '-cell';
63
+ var weekNumberCellClass = prefixCls + '-week-number-cell';
64
+ var dateClass = prefixCls + '-date';
65
+ var todayClass = prefixCls + '-today';
66
+ var selectedClass = prefixCls + '-selected-day';
67
+ var selectedDateClass = prefixCls + '-selected-date'; // do not move with mouse operation
68
+ var selectedStartDateClass = prefixCls + '-selected-start-date';
69
+ var selectedEndDateClass = prefixCls + '-selected-end-date';
70
+ var inRangeClass = prefixCls + '-in-range-cell';
71
+ var lastMonthDayClass = prefixCls + '-last-month-cell';
72
+ var nextMonthDayClass = prefixCls + '-next-month-btn-day';
73
+ var disabledClass = prefixCls + '-disabled-cell';
74
+ var firstDisableClass = prefixCls + '-disabled-cell-first-of-row';
75
+ var lastDisableClass = prefixCls + '-disabled-cell-last-of-row';
76
+ var lastDayOfMonthClass = prefixCls + '-last-day-of-month';
77
+ var month1 = value.clone();
78
+ month1 = month1.date(1);
79
+ var day = month1.day();
80
+ var firstDayName = typeof firstDayOfWeek === 'string' ? firstDayOfWeek[0].toUpperCase() + firstDayOfWeek.slice(1) : 'Sunday';
81
+ var firstDayIndex = DAY_NAME_TO_INDEX[firstDayName] ? DAY_NAME_TO_INDEX[firstDayName] : 0;
82
+ var lastMonthDiffDay = (day + 7 - firstDayIndex) % 7;
83
+ // calculate last month
84
+ var lastMonth1 = month1.clone();
85
+ lastMonth1 = lastMonth1.add(0 - lastMonthDiffDay, 'days');
86
+ var passed = 0;
87
+
88
+ for (iIndex = 0; iIndex < DATE_ROW_COLUMN_COUNT.DATE_ROW_COUNT; iIndex++) {
89
+ for (jIndex = 0; jIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT; jIndex++) {
90
+ current = lastMonth1;
91
+ if (passed) {
92
+ current = current.clone();
93
+ current = current.add(passed, 'days');
94
+ }
95
+ dateTable.push(current);
96
+ passed++;
97
+ }
98
+ }
99
+ var tableHtml = [];
100
+ passed = 0;
101
+
102
+ for (iIndex = 0; iIndex < DATE_ROW_COLUMN_COUNT.DATE_ROW_COUNT; iIndex++) {
103
+ var _cx;
104
+
105
+ var isCurrentWeek = void 0;
106
+ var weekNumberCell = void 0;
107
+ var isActiveWeek = false;
108
+ var dateCells = [];
109
+ if (showWeekNumber) {
110
+ weekNumberCell = React.createElement(
111
+ 'td',
112
+ {
113
+ key: dateTable[passed].week(),
114
+ role: 'gridcell',
115
+ className: weekNumberCellClass
116
+ },
117
+ dateTable[passed].week()
118
+ );
119
+ }
120
+ for (jIndex = 0; jIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT; jIndex++) {
121
+ var next = null;
122
+ var last = null;
123
+ current = dateTable[passed];
124
+ if (jIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT - 1) {
125
+ next = dateTable[passed + 1];
126
+ }
127
+ if (jIndex > 0) {
128
+ last = dateTable[passed - 1];
129
+ }
130
+ var cls = cellClass;
131
+ var disabled = false;
132
+ var selected = false;
133
+
134
+ if (isSameDay(current, today)) {
135
+ cls += ' ' + todayClass;
136
+ isCurrentWeek = true;
137
+ }
138
+
139
+ var isBeforeCurrentMonthYear = beforeCurrentMonthYear(current, value);
140
+ var isAfterCurrentMonthYear = afterCurrentMonthYear(current, value);
141
+
142
+ if (selectedValue && Array.isArray(selectedValue)) {
143
+ var rangeValue = hoverValue.length ? hoverValue : selectedValue;
144
+ if (!isBeforeCurrentMonthYear && !isAfterCurrentMonthYear) {
145
+ var startValue = rangeValue[0];
146
+ var endValue = rangeValue[1];
147
+ if (startValue) {
148
+ if (isSameDay(current, startValue)) {
149
+ selected = true;
150
+ isActiveWeek = true;
151
+ cls += ' ' + selectedStartDateClass;
152
+ }
153
+ }
154
+ if (startValue || endValue) {
155
+ if (isSameDay(current, endValue)) {
156
+ selected = true;
157
+ isActiveWeek = true;
158
+ cls += ' ' + selectedEndDateClass;
159
+ } else if ((startValue === null || startValue === undefined) && current.isBefore(endValue, 'day')) {
160
+ cls += ' ' + inRangeClass;
161
+ } else if ((endValue === null || endValue === undefined) && current.isAfter(startValue, 'day')) {
162
+ cls += ' ' + inRangeClass;
163
+ } else if (current.isAfter(startValue, 'day') && current.isBefore(endValue, 'day')) {
164
+ cls += ' ' + inRangeClass;
165
+ }
166
+ }
167
+ }
168
+ } else if (isSameDay(current, value)) {
169
+ // keyboard change value, highlight works
170
+ selected = true;
171
+ isActiveWeek = true;
172
+ }
173
+
174
+ if (isSameDay(current, selectedValue)) {
175
+ cls += ' ' + selectedDateClass;
176
+ }
177
+
178
+ if (isBeforeCurrentMonthYear) {
179
+ cls += ' ' + lastMonthDayClass;
180
+ }
181
+
182
+ if (isAfterCurrentMonthYear) {
183
+ cls += ' ' + nextMonthDayClass;
184
+ }
185
+
186
+ if (current.clone().endOf('month').date() === current.date()) {
187
+ cls += ' ' + lastDayOfMonthClass;
188
+ }
189
+
190
+ if (disabledDate) {
191
+ if (disabledDate(current, value)) {
192
+ disabled = true;
193
+
194
+ if (!last || !disabledDate(last, value)) {
195
+ cls += ' ' + firstDisableClass;
196
+ }
197
+
198
+ if (!next || !disabledDate(next, value)) {
199
+ cls += ' ' + lastDisableClass;
200
+ }
201
+ }
202
+ }
203
+
204
+ if (selected) {
205
+ cls += ' ' + selectedClass;
206
+ }
207
+
208
+ if (disabled) {
209
+ cls += ' ' + disabledClass;
210
+ }
211
+
212
+ var dateHtml = void 0;
213
+ if (dateRender) {
214
+ dateHtml = dateRender(current, value);
215
+ } else {
216
+ var content = contentRender ? contentRender(current, value) : current.date();
217
+ dateHtml = React.createElement(
218
+ 'div',
219
+ {
220
+ key: getIdFromDate(current),
221
+ className: dateClass,
222
+ 'aria-selected': selected,
223
+ 'aria-disabled': disabled
224
+ },
225
+ content
226
+ );
227
+ }
228
+
229
+ dateCells.push(React.createElement(
230
+ 'td',
231
+ {
232
+ key: passed,
233
+ onClick: disabled ? undefined : props.onSelect.bind(null, current),
234
+ onMouseEnter: disabled ? undefined : props.onDayHover && props.onDayHover.bind(null, current) || undefined,
235
+ role: 'gridcell',
236
+ title: getTitleString(current),
237
+ className: cls
238
+ },
239
+ dateHtml
240
+ ));
241
+
242
+ passed++;
243
+ }
244
+
245
+ tableHtml.push(React.createElement(
246
+ 'tr',
247
+ {
248
+ key: iIndex,
249
+ role: 'row',
250
+ className: cx((_cx = {}, _cx[prefixCls + '-current-week'] = isCurrentWeek, _cx[prefixCls + '-active-week'] = isActiveWeek, _cx))
251
+ },
252
+ weekNumberCell,
253
+ dateCells
254
+ ));
255
+ }
256
+ return React.createElement(
257
+ 'tbody',
258
+ { className: prefixCls + '-tbody' },
259
+ tableHtml
260
+ );
261
+ };
262
+
263
+ return DateTBody;
264
+ }(React.Component);
265
+
266
+ DateTBody.propTypes = {
267
+ contentRender: PropTypes.func,
268
+ dateRender: PropTypes.func,
269
+ disabledDate: PropTypes.func,
270
+ prefixCls: PropTypes.string,
271
+ selectedValue: PropTypes.oneOfType([PropTypes.object, PropTypes.arrayOf(PropTypes.object)]),
272
+ value: PropTypes.object,
273
+ hoverValue: PropTypes.any,
274
+ showWeekNumber: PropTypes.bool,
275
+ firstDayOfWeek: PropTypes.string
276
+ };
277
+ DateTBody.defaultProps = {
278
+ hoverValue: []
279
+ };
280
+ export default DateTBody;
@@ -0,0 +1,85 @@
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 DateConstants from './DateConstants';
6
+
7
+ var DAY_NAME_TO_INDEX = DateConstants.DAY_NAME_TO_INDEX,
8
+ DATE_ROW_COLUMN_COUNT = DateConstants.DATE_ROW_COLUMN_COUNT;
9
+
10
+ var DateTHead = function (_React$Component) {
11
+ _inherits(DateTHead, _React$Component);
12
+
13
+ function DateTHead() {
14
+ _classCallCheck(this, DateTHead);
15
+
16
+ return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
17
+ }
18
+
19
+ DateTHead.prototype.render = function render() {
20
+ var props = this.props;
21
+ var value = props.value;
22
+ var localeData = value.localeData();
23
+ var prefixCls = props.prefixCls;
24
+ var veryShortWeekdays = [];
25
+ var weekDays = [];
26
+
27
+ var allWeekdaysMin = localeData.weekdaysMin();
28
+ var allWeekdaysShort = localeData.weekdaysShort();
29
+
30
+ var firstDayName = typeof props.firstDayOfWeek === 'string' ? props.firstDayOfWeek[0].toUpperCase() + props.firstDayOfWeek.slice(1) : 'Sunday';
31
+ var firstDay = DAY_NAME_TO_INDEX[firstDayName] ? DAY_NAME_TO_INDEX[firstDayName] : 0;
32
+
33
+ var showWeekNumberEl = void 0;
34
+ for (var dateColIndex = 0; dateColIndex < DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT; dateColIndex++) {
35
+ var index = (firstDay + dateColIndex) % DATE_ROW_COLUMN_COUNT.DATE_COL_COUNT;
36
+ veryShortWeekdays[dateColIndex] = allWeekdaysMin[index];
37
+ weekDays[dateColIndex] = allWeekdaysShort[index];
38
+ }
39
+
40
+ if (props.showWeekNumber) {
41
+ showWeekNumberEl = React.createElement(
42
+ 'th',
43
+ {
44
+ role: 'columnheader',
45
+ className: prefixCls + '-column-header ' + prefixCls + '-week-number-header'
46
+ },
47
+ React.createElement(
48
+ 'span',
49
+ { className: prefixCls + '-column-header-inner' },
50
+ 'x'
51
+ )
52
+ );
53
+ }
54
+ var weekDaysEls = weekDays.map(function (day, xindex) {
55
+ return React.createElement(
56
+ 'th',
57
+ {
58
+ key: xindex,
59
+ role: 'columnheader',
60
+ title: day,
61
+ className: prefixCls + '-column-header'
62
+ },
63
+ React.createElement(
64
+ 'span',
65
+ { className: prefixCls + '-column-header-inner' },
66
+ veryShortWeekdays[xindex]
67
+ )
68
+ );
69
+ });
70
+ return React.createElement(
71
+ 'thead',
72
+ null,
73
+ React.createElement(
74
+ 'tr',
75
+ { role: 'row' },
76
+ showWeekNumberEl,
77
+ weekDaysEls
78
+ )
79
+ );
80
+ };
81
+
82
+ return DateTHead;
83
+ }(React.Component);
84
+
85
+ export default DateTHead;
@@ -0,0 +1,32 @@
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
+
5
+ import React from 'react';
6
+ import DateTHead from './DateTHead';
7
+ import DateTBody from './DateTBody';
8
+
9
+ var DateTable = function (_React$Component) {
10
+ _inherits(DateTable, _React$Component);
11
+
12
+ function DateTable() {
13
+ _classCallCheck(this, DateTable);
14
+
15
+ return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
16
+ }
17
+
18
+ DateTable.prototype.render = function render() {
19
+ var props = this.props;
20
+ var prefixCls = props.prefixCls;
21
+ return React.createElement(
22
+ 'table',
23
+ { className: prefixCls + '-table', cellSpacing: '0', role: 'grid' },
24
+ React.createElement(DateTHead, props),
25
+ React.createElement(DateTBody, props)
26
+ );
27
+ };
28
+
29
+ return DateTable;
30
+ }(React.Component);
31
+
32
+ export default DateTable;