@seafile/seafile-calendar 0.0.30 → 0.0.31-APloi0.2

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