@seafile/seafile-calendar 0.0.29-alpha.2 → 0.0.29-alpha10
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.
- package/assets/index.css +1177 -0
- package/dist/rc-calendar.css +1179 -0
- package/dist/rc-calendar.css.map +1 -0
- package/dist/rc-calendar.js +7588 -0
- package/dist/rc-calendar.js.map +1 -0
- package/dist/rc-calendar.min.css +1179 -0
- package/dist/rc-calendar.min.css.map +1 -0
- package/dist/rc-calendar.min.js +1 -0
- package/es/Calendar.js +444 -0
- package/es/FullCalendar.js +182 -0
- package/es/MonthCalendar.js +135 -0
- package/es/Picker.js +245 -0
- package/es/RangeCalendar.js +876 -0
- package/es/calendar/CalendarFooter.js +93 -0
- package/es/calendar/CalendarHeader.js +257 -0
- package/es/calendar/CalendarRightPanel.js +135 -0
- package/es/calendar/OkButton.js +22 -0
- package/es/calendar/TimePickerButton.js +28 -0
- package/es/calendar/TodayButton.js +28 -0
- package/es/date/DateConstants.js +19 -0
- package/es/date/DateInput.js +249 -0
- package/es/date/DateTBody.js +280 -0
- package/es/date/DateTHead.js +86 -0
- package/es/date/DateTable.js +32 -0
- package/es/decade/DecadePanel.js +181 -0
- package/es/full-calendar/CalendarHeader.js +180 -0
- package/es/index.js +3 -0
- package/es/locale/ar_EG.js +27 -0
- package/es/locale/bg_BG.js +27 -0
- package/es/locale/ca_ES.js +27 -0
- package/es/locale/cs_CZ.js +27 -0
- package/es/locale/da_DK.js +27 -0
- package/es/locale/de_DE.js +27 -0
- package/es/locale/el_GR.js +27 -0
- package/es/locale/en_GB.js +27 -0
- package/es/locale/en_US.js +28 -0
- package/es/locale/es_ES.js +27 -0
- package/es/locale/et_EE.js +27 -0
- package/es/locale/fa_IR.js +27 -0
- package/es/locale/fi_FI.js +27 -0
- package/es/locale/fr_BE.js +27 -0
- package/es/locale/fr_FR.js +27 -0
- package/es/locale/he_IL.js +28 -0
- package/es/locale/hi_IN.js +28 -0
- package/es/locale/hr_HR.js +28 -0
- package/es/locale/hu_HU.js +27 -0
- package/es/locale/id_ID.js +28 -0
- package/es/locale/is_IS.js +27 -0
- package/es/locale/it_IT.js +27 -0
- package/es/locale/ja_JP.js +26 -0
- package/es/locale/kn_IN.js +28 -0
- package/es/locale/ko_KR.js +27 -0
- package/es/locale/ku_IQ.js +27 -0
- package/es/locale/lv_LV.js +27 -0
- package/es/locale/mm_MM.js +28 -0
- package/es/locale/mn_MN.js +28 -0
- package/es/locale/ms_MY.js +27 -0
- package/es/locale/nb_NO.js +27 -0
- package/es/locale/nl_BE.js +27 -0
- package/es/locale/nl_NL.js +27 -0
- package/es/locale/pl_PL.js +27 -0
- package/es/locale/pt_BR.js +27 -0
- package/es/locale/pt_PT.js +27 -0
- package/es/locale/ro_RO.js +28 -0
- package/es/locale/ru_RU.js +27 -0
- package/es/locale/sk_SK.js +27 -0
- package/es/locale/sl_SI.js +27 -0
- package/es/locale/sr_RS.js +27 -0
- package/es/locale/sv_SE.js +27 -0
- package/es/locale/ta_IN.js +28 -0
- package/es/locale/th_TH.js +27 -0
- package/es/locale/tr_TR.js +27 -0
- package/es/locale/ug_CN.js +26 -0
- package/es/locale/uk_UA.js +27 -0
- package/es/locale/vi_VN.js +28 -0
- package/es/locale/zh_CN.js +27 -0
- package/es/locale/zh_TW.js +26 -0
- package/es/mixin/CalendarMixin.js +123 -0
- package/es/mixin/CommonMixin.js +85 -0
- package/es/month/MonthPanel.js +154 -0
- package/es/month/MonthTable.js +156 -0
- package/es/picker/placements.js +35 -0
- package/es/range-calendar/CalendarPart.js +151 -0
- package/es/util/dayjs.js +17 -0
- package/es/util/index.js +564 -0
- package/es/util/toTime.js +21 -0
- package/es/year/YearPanel.js +194 -0
- package/lib/Calendar.js +507 -0
- package/lib/FullCalendar.js +221 -0
- package/lib/MonthCalendar.js +172 -0
- package/lib/Picker.js +282 -0
- package/lib/RangeCalendar.js +925 -0
- package/lib/calendar/CalendarFooter.js +134 -0
- package/lib/calendar/CalendarHeader.js +290 -0
- package/lib/calendar/CalendarRightPanel.js +160 -0
- package/lib/calendar/OkButton.js +32 -0
- package/lib/calendar/TimePickerButton.js +41 -0
- package/lib/calendar/TodayButton.js +39 -0
- package/lib/date/DateConstants.js +23 -0
- package/lib/date/DateInput.js +281 -0
- package/lib/date/DateTBody.js +307 -0
- package/lib/date/DateTHead.js +106 -0
- package/lib/date/DateTable.js +54 -0
- package/lib/decade/DecadePanel.js +207 -0
- package/lib/full-calendar/CalendarHeader.js +201 -0
- package/lib/index.js +12 -0
- package/lib/locale/ar_EG.js +31 -0
- package/lib/locale/bg_BG.js +31 -0
- package/lib/locale/ca_ES.js +31 -0
- package/lib/locale/cs_CZ.js +31 -0
- package/lib/locale/da_DK.js +31 -0
- package/lib/locale/de_DE.js +31 -0
- package/lib/locale/el_GR.js +31 -0
- package/lib/locale/en_GB.js +31 -0
- package/lib/locale/en_US.js +32 -0
- package/lib/locale/es_ES.js +31 -0
- package/lib/locale/et_EE.js +31 -0
- package/lib/locale/fa_IR.js +31 -0
- package/lib/locale/fi_FI.js +31 -0
- package/lib/locale/fr_BE.js +31 -0
- package/lib/locale/fr_FR.js +31 -0
- package/lib/locale/he_IL.js +32 -0
- package/lib/locale/hi_IN.js +32 -0
- package/lib/locale/hr_HR.js +32 -0
- package/lib/locale/hu_HU.js +31 -0
- package/lib/locale/id_ID.js +32 -0
- package/lib/locale/is_IS.js +31 -0
- package/lib/locale/it_IT.js +31 -0
- package/lib/locale/ja_JP.js +30 -0
- package/lib/locale/kn_IN.js +32 -0
- package/lib/locale/ko_KR.js +31 -0
- package/lib/locale/ku_IQ.js +31 -0
- package/lib/locale/lv_LV.js +31 -0
- package/lib/locale/mm_MM.js +32 -0
- package/lib/locale/mn_MN.js +32 -0
- package/lib/locale/ms_MY.js +31 -0
- package/lib/locale/nb_NO.js +31 -0
- package/lib/locale/nl_BE.js +31 -0
- package/lib/locale/nl_NL.js +31 -0
- package/lib/locale/pl_PL.js +31 -0
- package/lib/locale/pt_BR.js +31 -0
- package/lib/locale/pt_PT.js +31 -0
- package/lib/locale/ro_RO.js +32 -0
- package/lib/locale/ru_RU.js +31 -0
- package/lib/locale/sk_SK.js +31 -0
- package/lib/locale/sl_SI.js +31 -0
- package/lib/locale/sr_RS.js +31 -0
- package/lib/locale/sv_SE.js +31 -0
- package/lib/locale/ta_IN.js +32 -0
- package/lib/locale/th_TH.js +31 -0
- package/lib/locale/tr_TR.js +31 -0
- package/lib/locale/ug_CN.js +30 -0
- package/lib/locale/uk_UA.js +31 -0
- package/lib/locale/vi_VN.js +32 -0
- package/lib/locale/zh_CN.js +31 -0
- package/lib/locale/zh_TW.js +30 -0
- package/lib/mixin/CalendarMixin.js +153 -0
- package/lib/mixin/CommonMixin.js +106 -0
- package/lib/month/MonthPanel.js +179 -0
- package/lib/month/MonthTable.js +181 -0
- package/lib/picker/placements.js +39 -0
- package/lib/range-calendar/CalendarPart.js +184 -0
- package/lib/util/dayjs.js +46 -0
- package/lib/util/index.js +601 -0
- package/lib/util/toTime.js +28 -0
- package/lib/year/YearPanel.js +219 -0
- package/package.json +1 -1
@@ -0,0 +1,93 @@
|
|
1
|
+
import _extends from 'babel-runtime/helpers/extends';
|
2
|
+
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
3
|
+
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
4
|
+
import _inherits from 'babel-runtime/helpers/inherits';
|
5
|
+
import React from 'react';
|
6
|
+
import ReactDOM from 'react-dom';
|
7
|
+
import PropTypes from 'prop-types';
|
8
|
+
import toFragment from 'rc-util/es/Children/mapSelf';
|
9
|
+
import cx from 'classnames';
|
10
|
+
import TodayButton from '../calendar/TodayButton';
|
11
|
+
import OkButton from '../calendar/OkButton';
|
12
|
+
import TimePickerButton from '../calendar/TimePickerButton';
|
13
|
+
|
14
|
+
var CalendarFooter = function (_React$Component) {
|
15
|
+
_inherits(CalendarFooter, _React$Component);
|
16
|
+
|
17
|
+
function CalendarFooter() {
|
18
|
+
_classCallCheck(this, CalendarFooter);
|
19
|
+
|
20
|
+
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
|
21
|
+
}
|
22
|
+
|
23
|
+
CalendarFooter.prototype.onSelect = function onSelect(value) {
|
24
|
+
this.props.onSelect(value);
|
25
|
+
};
|
26
|
+
|
27
|
+
CalendarFooter.prototype.getRootDOMNode = function getRootDOMNode() {
|
28
|
+
return ReactDOM.findDOMNode(this);
|
29
|
+
};
|
30
|
+
|
31
|
+
CalendarFooter.prototype.render = function render() {
|
32
|
+
var props = this.props;
|
33
|
+
var value = props.value,
|
34
|
+
prefixCls = props.prefixCls,
|
35
|
+
showOk = props.showOk,
|
36
|
+
timePicker = props.timePicker,
|
37
|
+
renderFooter = props.renderFooter,
|
38
|
+
mode = props.mode;
|
39
|
+
|
40
|
+
var footerEl = null;
|
41
|
+
var extraFooter = renderFooter && renderFooter(mode);
|
42
|
+
if (props.showToday || timePicker || extraFooter) {
|
43
|
+
var _cx;
|
44
|
+
|
45
|
+
var nowEl = void 0;
|
46
|
+
if (props.showToday) {
|
47
|
+
nowEl = React.createElement(TodayButton, _extends({}, props, { value: value }));
|
48
|
+
}
|
49
|
+
var okBtn = void 0;
|
50
|
+
if (showOk === true || showOk !== false && !!props.timePicker) {
|
51
|
+
okBtn = React.createElement(OkButton, props);
|
52
|
+
}
|
53
|
+
var timePickerBtn = void 0;
|
54
|
+
if (!!props.timePicker) {
|
55
|
+
timePickerBtn = React.createElement(TimePickerButton, props);
|
56
|
+
}
|
57
|
+
|
58
|
+
var footerBtn = void 0;
|
59
|
+
if (nowEl || timePickerBtn || okBtn || extraFooter) {
|
60
|
+
footerBtn = React.createElement(
|
61
|
+
'span',
|
62
|
+
{ className: prefixCls + '-footer-btn' },
|
63
|
+
extraFooter,
|
64
|
+
toFragment([nowEl, timePickerBtn, okBtn])
|
65
|
+
);
|
66
|
+
}
|
67
|
+
var cls = cx(prefixCls + '-footer', (_cx = {}, _cx[prefixCls + '-footer-show-ok'] = okBtn, _cx));
|
68
|
+
footerEl = React.createElement(
|
69
|
+
'div',
|
70
|
+
{ className: cls },
|
71
|
+
footerBtn
|
72
|
+
);
|
73
|
+
}
|
74
|
+
return footerEl;
|
75
|
+
};
|
76
|
+
|
77
|
+
return CalendarFooter;
|
78
|
+
}(React.Component);
|
79
|
+
|
80
|
+
CalendarFooter.propTypes = {
|
81
|
+
prefixCls: PropTypes.string,
|
82
|
+
showDateInput: PropTypes.bool,
|
83
|
+
disabledTime: PropTypes.any,
|
84
|
+
timePicker: PropTypes.element,
|
85
|
+
selectedValue: PropTypes.any,
|
86
|
+
showOk: PropTypes.bool,
|
87
|
+
onSelect: PropTypes.func,
|
88
|
+
value: PropTypes.object,
|
89
|
+
renderFooter: PropTypes.func,
|
90
|
+
defaultValue: PropTypes.object,
|
91
|
+
mode: PropTypes.string
|
92
|
+
};
|
93
|
+
export default CalendarFooter;
|
@@ -0,0 +1,257 @@
|
|
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 toFragment from 'rc-util/es/Children/mapSelf';
|
7
|
+
import MonthPanel from '../month/MonthPanel';
|
8
|
+
import YearPanel from '../year/YearPanel';
|
9
|
+
import DecadePanel from '../decade/DecadePanel';
|
10
|
+
|
11
|
+
function goMonth(direction) {
|
12
|
+
var next = this.props.value.clone();
|
13
|
+
next = next.add(direction, 'months');
|
14
|
+
this.props.onValueChange(next);
|
15
|
+
}
|
16
|
+
|
17
|
+
function goYear(direction) {
|
18
|
+
var next = this.props.value.clone();
|
19
|
+
next = next.add(direction, 'years');
|
20
|
+
this.props.onValueChange(next);
|
21
|
+
}
|
22
|
+
|
23
|
+
function showIf(condition, el) {
|
24
|
+
return condition ? el : null;
|
25
|
+
}
|
26
|
+
|
27
|
+
var CalendarHeader = function (_React$Component) {
|
28
|
+
_inherits(CalendarHeader, _React$Component);
|
29
|
+
|
30
|
+
function CalendarHeader(props) {
|
31
|
+
_classCallCheck(this, CalendarHeader);
|
32
|
+
|
33
|
+
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
|
34
|
+
|
35
|
+
_initialiseProps.call(_this);
|
36
|
+
|
37
|
+
_this.nextMonth = goMonth.bind(_this, 1);
|
38
|
+
_this.previousMonth = goMonth.bind(_this, -1);
|
39
|
+
_this.nextYear = goYear.bind(_this, 1);
|
40
|
+
_this.previousYear = goYear.bind(_this, -1);
|
41
|
+
|
42
|
+
_this.state = { yearPanelReferer: null };
|
43
|
+
return _this;
|
44
|
+
}
|
45
|
+
|
46
|
+
CalendarHeader.prototype.render = function render() {
|
47
|
+
var _this2 = this;
|
48
|
+
|
49
|
+
var props = this.props;
|
50
|
+
var prefixCls = props.prefixCls,
|
51
|
+
locale = props.locale,
|
52
|
+
mode = props.mode,
|
53
|
+
value = props.value,
|
54
|
+
showTimePicker = props.showTimePicker,
|
55
|
+
enableNext = props.enableNext,
|
56
|
+
enablePrev = props.enablePrev,
|
57
|
+
disabledMonth = props.disabledMonth,
|
58
|
+
renderFooter = props.renderFooter;
|
59
|
+
|
60
|
+
|
61
|
+
var panel = null;
|
62
|
+
if (mode === 'month') {
|
63
|
+
panel = React.createElement(MonthPanel, {
|
64
|
+
locale: locale,
|
65
|
+
value: value,
|
66
|
+
rootPrefixCls: prefixCls,
|
67
|
+
onSelect: this.onMonthSelect,
|
68
|
+
onYearPanelShow: function onYearPanelShow() {
|
69
|
+
return _this2.showYearPanel('month');
|
70
|
+
},
|
71
|
+
disabledDate: disabledMonth,
|
72
|
+
cellRender: props.monthCellRender,
|
73
|
+
contentRender: props.monthCellContentRender,
|
74
|
+
renderFooter: renderFooter,
|
75
|
+
changeYear: this.changeYear
|
76
|
+
});
|
77
|
+
}
|
78
|
+
if (mode === 'year') {
|
79
|
+
panel = React.createElement(YearPanel, {
|
80
|
+
locale: locale,
|
81
|
+
defaultValue: value,
|
82
|
+
rootPrefixCls: prefixCls,
|
83
|
+
onSelect: this.onYearSelect,
|
84
|
+
onDecadePanelShow: this.showDecadePanel,
|
85
|
+
renderFooter: renderFooter
|
86
|
+
});
|
87
|
+
}
|
88
|
+
if (mode === 'decade') {
|
89
|
+
panel = React.createElement(DecadePanel, {
|
90
|
+
locale: locale,
|
91
|
+
defaultValue: value,
|
92
|
+
rootPrefixCls: prefixCls,
|
93
|
+
onSelect: this.onDecadeSelect,
|
94
|
+
renderFooter: renderFooter
|
95
|
+
});
|
96
|
+
}
|
97
|
+
|
98
|
+
return React.createElement(
|
99
|
+
'div',
|
100
|
+
{ className: prefixCls + '-header' },
|
101
|
+
React.createElement(
|
102
|
+
'div',
|
103
|
+
{ style: { position: 'relative' } },
|
104
|
+
showIf(enablePrev && !showTimePicker, React.createElement('a', {
|
105
|
+
className: prefixCls + '-prev-year-btn',
|
106
|
+
role: 'button',
|
107
|
+
onClick: this.previousYear,
|
108
|
+
title: locale.previousYear
|
109
|
+
})),
|
110
|
+
showIf(enablePrev && !showTimePicker, React.createElement('a', {
|
111
|
+
className: prefixCls + '-prev-month-btn',
|
112
|
+
role: 'button',
|
113
|
+
onClick: this.previousMonth,
|
114
|
+
title: locale.previousMonth
|
115
|
+
})),
|
116
|
+
this.monthYearElement(showTimePicker),
|
117
|
+
showIf(enableNext && !showTimePicker, React.createElement('a', {
|
118
|
+
className: prefixCls + '-next-month-btn',
|
119
|
+
onClick: this.nextMonth,
|
120
|
+
title: locale.nextMonth
|
121
|
+
})),
|
122
|
+
showIf(enableNext && !showTimePicker, React.createElement('a', {
|
123
|
+
className: prefixCls + '-next-year-btn',
|
124
|
+
onClick: this.nextYear,
|
125
|
+
title: locale.nextYear
|
126
|
+
}))
|
127
|
+
),
|
128
|
+
panel
|
129
|
+
);
|
130
|
+
};
|
131
|
+
|
132
|
+
return CalendarHeader;
|
133
|
+
}(React.Component);
|
134
|
+
|
135
|
+
CalendarHeader.propTypes = {
|
136
|
+
prefixCls: PropTypes.string,
|
137
|
+
value: PropTypes.object,
|
138
|
+
onValueChange: PropTypes.func,
|
139
|
+
showTimePicker: PropTypes.bool,
|
140
|
+
onPanelChange: PropTypes.func,
|
141
|
+
locale: PropTypes.object,
|
142
|
+
enablePrev: PropTypes.any,
|
143
|
+
enableNext: PropTypes.any,
|
144
|
+
disabledMonth: PropTypes.func,
|
145
|
+
renderFooter: PropTypes.func,
|
146
|
+
onMonthSelect: PropTypes.func
|
147
|
+
};
|
148
|
+
CalendarHeader.defaultProps = {
|
149
|
+
enableNext: 1,
|
150
|
+
enablePrev: 1,
|
151
|
+
onPanelChange: function onPanelChange() {},
|
152
|
+
onValueChange: function onValueChange() {}
|
153
|
+
};
|
154
|
+
|
155
|
+
var _initialiseProps = function _initialiseProps() {
|
156
|
+
var _this3 = this;
|
157
|
+
|
158
|
+
this.onMonthSelect = function (value) {
|
159
|
+
_this3.props.onPanelChange(value, 'date');
|
160
|
+
if (_this3.props.onMonthSelect) {
|
161
|
+
_this3.props.onMonthSelect(value);
|
162
|
+
} else {
|
163
|
+
_this3.props.onValueChange(value);
|
164
|
+
}
|
165
|
+
};
|
166
|
+
|
167
|
+
this.onYearSelect = function (value) {
|
168
|
+
var referer = _this3.state.yearPanelReferer;
|
169
|
+
_this3.setState({ yearPanelReferer: null });
|
170
|
+
_this3.props.onPanelChange(value, referer);
|
171
|
+
_this3.props.onValueChange(value);
|
172
|
+
};
|
173
|
+
|
174
|
+
this.onDecadeSelect = function (value) {
|
175
|
+
_this3.props.onPanelChange(value, 'year');
|
176
|
+
_this3.props.onValueChange(value);
|
177
|
+
};
|
178
|
+
|
179
|
+
this.changeYear = function (direction) {
|
180
|
+
if (direction > 0) {
|
181
|
+
_this3.nextYear();
|
182
|
+
} else {
|
183
|
+
_this3.previousYear();
|
184
|
+
}
|
185
|
+
};
|
186
|
+
|
187
|
+
this.monthYearElement = function (showTimePicker) {
|
188
|
+
var props = _this3.props;
|
189
|
+
var prefixCls = props.prefixCls;
|
190
|
+
var locale = props.locale;
|
191
|
+
var value = props.value;
|
192
|
+
var localeData = value.localeData();
|
193
|
+
var monthBeforeYear = locale.monthBeforeYear;
|
194
|
+
var selectClassName = prefixCls + '-' + (monthBeforeYear ? 'my-select' : 'ym-select');
|
195
|
+
var timeClassName = showTimePicker ? ' ' + prefixCls + '-time-status' : '';
|
196
|
+
var year = React.createElement(
|
197
|
+
'a',
|
198
|
+
{
|
199
|
+
className: prefixCls + '-year-select' + timeClassName,
|
200
|
+
role: 'button',
|
201
|
+
onClick: showTimePicker ? null : function () {
|
202
|
+
return _this3.showYearPanel('date');
|
203
|
+
},
|
204
|
+
title: showTimePicker ? null : locale.yearSelect
|
205
|
+
},
|
206
|
+
value.format(locale.yearFormat)
|
207
|
+
);
|
208
|
+
var month = React.createElement(
|
209
|
+
'a',
|
210
|
+
{
|
211
|
+
className: prefixCls + '-month-select' + timeClassName,
|
212
|
+
role: 'button',
|
213
|
+
onClick: showTimePicker ? null : _this3.showMonthPanel,
|
214
|
+
title: showTimePicker ? null : locale.monthSelect
|
215
|
+
},
|
216
|
+
locale.monthFormat ? value.format(locale.monthFormat) : localeData.monthsShort(value)
|
217
|
+
);
|
218
|
+
var day = void 0;
|
219
|
+
if (showTimePicker) {
|
220
|
+
day = React.createElement(
|
221
|
+
'a',
|
222
|
+
{
|
223
|
+
className: prefixCls + '-day-select' + timeClassName,
|
224
|
+
role: 'button'
|
225
|
+
},
|
226
|
+
value.format(locale.dayFormat)
|
227
|
+
);
|
228
|
+
}
|
229
|
+
var my = [];
|
230
|
+
if (monthBeforeYear) {
|
231
|
+
my = [month, day, year];
|
232
|
+
} else {
|
233
|
+
my = [year, month, day];
|
234
|
+
}
|
235
|
+
return React.createElement(
|
236
|
+
'span',
|
237
|
+
{ className: selectClassName },
|
238
|
+
toFragment(my)
|
239
|
+
);
|
240
|
+
};
|
241
|
+
|
242
|
+
this.showMonthPanel = function () {
|
243
|
+
// null means that users' interaction doesn't change value
|
244
|
+
_this3.props.onPanelChange(null, 'month');
|
245
|
+
};
|
246
|
+
|
247
|
+
this.showYearPanel = function (referer) {
|
248
|
+
_this3.setState({ yearPanelReferer: referer });
|
249
|
+
_this3.props.onPanelChange(null, 'year');
|
250
|
+
};
|
251
|
+
|
252
|
+
this.showDecadePanel = function () {
|
253
|
+
_this3.props.onPanelChange(null, 'decade');
|
254
|
+
};
|
255
|
+
};
|
256
|
+
|
257
|
+
export default CalendarHeader;
|
@@ -0,0 +1,135 @@
|
|
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 dayjs from 'dayjs';
|
7
|
+
import { formatDateLocal } from '../util';
|
8
|
+
|
9
|
+
var CalendarRightPanel = function (_React$Component) {
|
10
|
+
_inherits(CalendarRightPanel, _React$Component);
|
11
|
+
|
12
|
+
function CalendarRightPanel(props) {
|
13
|
+
_classCallCheck(this, CalendarRightPanel);
|
14
|
+
|
15
|
+
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
|
16
|
+
|
17
|
+
_this.onSelect = function (value) {
|
18
|
+
_this.setState({
|
19
|
+
highlightTime: value
|
20
|
+
});
|
21
|
+
_this.props.onSelect(value);
|
22
|
+
_this.props.onClickRightPanelTime();
|
23
|
+
};
|
24
|
+
|
25
|
+
_this.getTimes = function () {
|
26
|
+
var times = [];
|
27
|
+
for (var i = 0; i < 24; i++) {
|
28
|
+
var str = (String(i) + ':00').padStart(5, '0');
|
29
|
+
var str1 = (String(i) + ':30').padStart(5, '0');
|
30
|
+
times.push(str);
|
31
|
+
times.push(str1);
|
32
|
+
}
|
33
|
+
return times;
|
34
|
+
};
|
35
|
+
|
36
|
+
_this.scrollUp = function () {
|
37
|
+
_this.timeRef.current.scrollBy(0, -200);
|
38
|
+
};
|
39
|
+
|
40
|
+
_this.scrollDown = function () {
|
41
|
+
_this.timeRef.current.scrollBy(0, 200);
|
42
|
+
};
|
43
|
+
|
44
|
+
_this.state = {
|
45
|
+
highlightTime: _this.props.value || null,
|
46
|
+
localeFormat: _this.props.format[0]
|
47
|
+
};
|
48
|
+
_this.timeRef = React.createRef();
|
49
|
+
_this.times = _this.getTimes();
|
50
|
+
return _this;
|
51
|
+
}
|
52
|
+
|
53
|
+
CalendarRightPanel.prototype.componentDidMount = function componentDidMount() {
|
54
|
+
var defaultMinutesTime = this.props.defaultMinutesTime;
|
55
|
+
|
56
|
+
var showTimeIndex = this.times.findIndex(function (item) {
|
57
|
+
return item >= defaultMinutesTime;
|
58
|
+
});
|
59
|
+
var scrollTimeIndex = showTimeIndex > -1 ? showTimeIndex - 1 : 16;
|
60
|
+
this.timeRef.current.scrollTo(0, 34 * scrollTimeIndex);
|
61
|
+
};
|
62
|
+
|
63
|
+
CalendarRightPanel.prototype.render = function render() {
|
64
|
+
var _this2 = this;
|
65
|
+
|
66
|
+
var _props = this.props,
|
67
|
+
value = _props.value,
|
68
|
+
prefixCls = _props.prefixCls,
|
69
|
+
locale = _props.locale,
|
70
|
+
showHourAndMinute = _props.showHourAndMinute;
|
71
|
+
|
72
|
+
var selectedDate = value.format().slice(0, 10);
|
73
|
+
if (showHourAndMinute) {
|
74
|
+
selectedDate = value.format().slice(0, String(value.format()).indexOf('T')).padStart(10, 0);
|
75
|
+
}
|
76
|
+
var highlight = this.state.highlightTime;
|
77
|
+
var highlightTime = highlight ? highlight.format().slice(11, 16) : null;
|
78
|
+
var isZhcn = locale && locale.today === '今天';
|
79
|
+
return React.createElement(
|
80
|
+
'div',
|
81
|
+
{ className: prefixCls + '-right-panel' },
|
82
|
+
React.createElement(
|
83
|
+
'div',
|
84
|
+
{ className: prefixCls + '-right-panel-header', onClick: this.scrollUp },
|
85
|
+
React.createElement('span', null)
|
86
|
+
),
|
87
|
+
React.createElement(
|
88
|
+
'div',
|
89
|
+
{ className: prefixCls + '-right-panel-body', ref: this.timeRef },
|
90
|
+
React.createElement(
|
91
|
+
'ul',
|
92
|
+
null,
|
93
|
+
this.times.map(function (time) {
|
94
|
+
var current = dayjs(selectedDate + ' ' + time);
|
95
|
+
if (showHourAndMinute) {
|
96
|
+
var parts = formatDateLocal(selectedDate, _this2.state.localeFormat);
|
97
|
+
if (parts[0] && parts[0].length === 4 && (parts[0].slice(0, 3) === '000' || parts[0].slice(0, 2) === '00')) {
|
98
|
+
current.year(parts[0]);
|
99
|
+
}
|
100
|
+
}
|
101
|
+
current = isZhcn ? current.locale('zh-cn') : current.locale('en-gb');
|
102
|
+
return React.createElement(
|
103
|
+
'li',
|
104
|
+
{
|
105
|
+
key: time,
|
106
|
+
onClick: _this2.onSelect.bind(_this2, current),
|
107
|
+
className: '' + (highlightTime === time ? prefixCls + '-selected-time' : '')
|
108
|
+
},
|
109
|
+
time
|
110
|
+
);
|
111
|
+
})
|
112
|
+
)
|
113
|
+
),
|
114
|
+
React.createElement(
|
115
|
+
'div',
|
116
|
+
{ className: prefixCls + '-right-panel-footer', onClick: this.scrollDown },
|
117
|
+
React.createElement('span', null)
|
118
|
+
)
|
119
|
+
);
|
120
|
+
};
|
121
|
+
|
122
|
+
return CalendarRightPanel;
|
123
|
+
}(React.Component);
|
124
|
+
|
125
|
+
CalendarRightPanel.propTypes = {
|
126
|
+
prefixCls: PropTypes.string,
|
127
|
+
value: PropTypes.object,
|
128
|
+
onSelect: PropTypes.func,
|
129
|
+
onClickRightPanelTime: PropTypes.func,
|
130
|
+
locale: PropTypes.object,
|
131
|
+
defaultMinutesTime: PropTypes.string,
|
132
|
+
format: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
|
133
|
+
showHourAndMinute: PropTypes.bool
|
134
|
+
};
|
135
|
+
export default CalendarRightPanel;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
|
3
|
+
export default function OkButton(_ref) {
|
4
|
+
var prefixCls = _ref.prefixCls,
|
5
|
+
locale = _ref.locale,
|
6
|
+
okDisabled = _ref.okDisabled,
|
7
|
+
onOk = _ref.onOk;
|
8
|
+
|
9
|
+
var className = prefixCls + "-ok-btn";
|
10
|
+
if (okDisabled) {
|
11
|
+
className += " " + prefixCls + "-ok-btn-disabled";
|
12
|
+
}
|
13
|
+
return React.createElement(
|
14
|
+
"a",
|
15
|
+
{
|
16
|
+
className: className,
|
17
|
+
role: "button",
|
18
|
+
onClick: okDisabled ? null : onOk
|
19
|
+
},
|
20
|
+
locale.ok
|
21
|
+
);
|
22
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import classnames from 'classnames';
|
3
|
+
|
4
|
+
export default function TimePickerButton(_ref) {
|
5
|
+
var _classnames;
|
6
|
+
|
7
|
+
var prefixCls = _ref.prefixCls,
|
8
|
+
locale = _ref.locale,
|
9
|
+
showTimePicker = _ref.showTimePicker,
|
10
|
+
onOpenTimePicker = _ref.onOpenTimePicker,
|
11
|
+
onCloseTimePicker = _ref.onCloseTimePicker,
|
12
|
+
timePickerDisabled = _ref.timePickerDisabled;
|
13
|
+
|
14
|
+
var className = classnames((_classnames = {}, _classnames[prefixCls + '-time-picker-btn'] = true, _classnames[prefixCls + '-time-picker-btn-disabled'] = timePickerDisabled, _classnames));
|
15
|
+
var onClick = null;
|
16
|
+
if (!timePickerDisabled) {
|
17
|
+
onClick = showTimePicker ? onCloseTimePicker : onOpenTimePicker;
|
18
|
+
}
|
19
|
+
return React.createElement(
|
20
|
+
'a',
|
21
|
+
{
|
22
|
+
className: className,
|
23
|
+
role: 'button',
|
24
|
+
onClick: onClick
|
25
|
+
},
|
26
|
+
showTimePicker ? locale.dateSelect : locale.timeSelect
|
27
|
+
);
|
28
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { getTodayTimeStr, getTodayTime, isAllowedDate } from '../util/';
|
3
|
+
|
4
|
+
export default function TodayButton(_ref) {
|
5
|
+
var prefixCls = _ref.prefixCls,
|
6
|
+
locale = _ref.locale,
|
7
|
+
value = _ref.value,
|
8
|
+
timePicker = _ref.timePicker,
|
9
|
+
disabled = _ref.disabled,
|
10
|
+
disabledDate = _ref.disabledDate,
|
11
|
+
onToday = _ref.onToday,
|
12
|
+
text = _ref.text;
|
13
|
+
|
14
|
+
var localeNow = (!text && timePicker ? locale.now : text) || locale.today;
|
15
|
+
var disabledToday = disabledDate && !isAllowedDate(getTodayTime(value), disabledDate);
|
16
|
+
var isDisabled = disabledToday || disabled;
|
17
|
+
var disabledTodayClass = isDisabled ? prefixCls + '-today-btn-disabled' : '';
|
18
|
+
return React.createElement(
|
19
|
+
'a',
|
20
|
+
{
|
21
|
+
className: prefixCls + '-today-btn ' + disabledTodayClass,
|
22
|
+
role: 'button',
|
23
|
+
onClick: isDisabled ? null : onToday,
|
24
|
+
title: getTodayTimeStr(value)
|
25
|
+
},
|
26
|
+
localeNow
|
27
|
+
);
|
28
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
var DATE_ROW_COLUMN_COUNT = {
|
2
|
+
DATE_ROW_COUNT: 6,
|
3
|
+
DATE_COL_COUNT: 7
|
4
|
+
};
|
5
|
+
|
6
|
+
var DAY_NAME_TO_INDEX = {
|
7
|
+
Sunday: 0,
|
8
|
+
Monday: 1,
|
9
|
+
Tuesday: 2,
|
10
|
+
Wednesday: 3,
|
11
|
+
Thursday: 4,
|
12
|
+
Friday: 5,
|
13
|
+
Saturday: 6
|
14
|
+
};
|
15
|
+
|
16
|
+
export default {
|
17
|
+
DATE_ROW_COLUMN_COUNT: DATE_ROW_COLUMN_COUNT,
|
18
|
+
DAY_NAME_TO_INDEX: DAY_NAME_TO_INDEX
|
19
|
+
};
|