@wangxinowo/vue-datepicker-next 1.0.2 → 1.0.5
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/README.md +510 -104
- package/dist/vue-datepicker-next.min.css +156 -7
- package/dist/vue-datepicker-next.min.js +3 -3
- package/package.json +88 -88
- package/src/components/calendar/locale/zh_CN.js +2 -0
- package/src/components/date-picker/PresetPanel.jsx +148 -102
- package/src/components/date-picker/style/MonthPanel.less +15 -0
- package/src/components/date-picker/style/RangePicker.less +515 -407
- package/src/components/date-picker/style/YearPanel.less +15 -0
- package/src/components/date-picker/style/presets.less +120 -69
- package/src/components/date-picker/wrapPicker.js +2 -2
- package/src/components/locale/default.js +35 -34
- package/src/components/time-picker/index.jsx +2 -2
- package/src/components/vc-calendar/src/Calendar.jsx +2 -2
- package/src/components/vc-calendar/src/FullCalendar.jsx +2 -2
- package/src/components/vc-calendar/src/MonthCalendar.jsx +2 -2
- package/src/components/vc-calendar/src/RangeCalendar.jsx +1105 -1031
- package/src/components/vc-calendar/src/calendar/CalendarHeader.jsx +277 -264
- package/src/components/vc-calendar/src/month/MonthPanel.jsx +130 -123
- package/src/components/vc-calendar/src/month/MonthTable.jsx +252 -138
- package/src/components/vc-calendar/src/range-calendar/CalendarPart.jsx +180 -171
- package/src/components/vc-calendar/src/year/YearPanel.jsx +242 -167
- package/src/components/vc-pagination/locale/zh_CN.js +15 -0
- package/src/index.js +48 -44
|
@@ -1,123 +1,130 @@
|
|
|
1
|
-
import PropTypes from '../../../_util/vue-types';
|
|
2
|
-
import BaseMixin from '../../../_util/BaseMixin';
|
|
3
|
-
import { hasProp, getListeners } from '../../../_util/props-util';
|
|
4
|
-
import MonthTable from './MonthTable';
|
|
5
|
-
|
|
6
|
-
function goYear(direction) {
|
|
7
|
-
this.changeYear(direction);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function noop() {}
|
|
11
|
-
|
|
12
|
-
const MonthPanel = {
|
|
13
|
-
name: 'MonthPanel',
|
|
14
|
-
mixins: [BaseMixin],
|
|
15
|
-
props: {
|
|
16
|
-
value: PropTypes.any,
|
|
17
|
-
defaultValue: PropTypes.any,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
class={`${prefixCls}-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
1
|
+
import PropTypes from '../../../_util/vue-types';
|
|
2
|
+
import BaseMixin from '../../../_util/BaseMixin';
|
|
3
|
+
import { hasProp, getListeners } from '../../../_util/props-util';
|
|
4
|
+
import MonthTable from './MonthTable';
|
|
5
|
+
|
|
6
|
+
function goYear(direction) {
|
|
7
|
+
this.changeYear(direction);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function noop() {}
|
|
11
|
+
|
|
12
|
+
const MonthPanel = {
|
|
13
|
+
name: 'MonthPanel',
|
|
14
|
+
mixins: [BaseMixin],
|
|
15
|
+
props: {
|
|
16
|
+
value: PropTypes.any,
|
|
17
|
+
defaultValue: PropTypes.any,
|
|
18
|
+
// 支持单个值或数组(范围选择)
|
|
19
|
+
selectedValue: PropTypes.oneOfType([PropTypes.any, PropTypes.array]),
|
|
20
|
+
// hover 值,用于范围选择时的预览效果
|
|
21
|
+
hoverValue: PropTypes.array.def([]),
|
|
22
|
+
cellRender: PropTypes.any,
|
|
23
|
+
contentRender: PropTypes.any,
|
|
24
|
+
locale: PropTypes.any,
|
|
25
|
+
rootPrefixCls: PropTypes.string,
|
|
26
|
+
// onChange: PropTypes.func,
|
|
27
|
+
disabledDate: PropTypes.func,
|
|
28
|
+
// onSelect: PropTypes.func,
|
|
29
|
+
renderFooter: PropTypes.func,
|
|
30
|
+
changeYear: PropTypes.func.def(noop),
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
data() {
|
|
34
|
+
const { value, defaultValue } = this;
|
|
35
|
+
// bind methods
|
|
36
|
+
this.nextYear = goYear.bind(this, 1);
|
|
37
|
+
this.previousYear = goYear.bind(this, -1);
|
|
38
|
+
return {
|
|
39
|
+
sValue: value || defaultValue,
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
watch: {
|
|
43
|
+
value(val) {
|
|
44
|
+
this.setState({
|
|
45
|
+
sValue: val,
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
methods: {
|
|
50
|
+
setAndSelectValue(value) {
|
|
51
|
+
this.setValue(value);
|
|
52
|
+
this.__emit('select', value);
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
setValue(value) {
|
|
56
|
+
if (hasProp(this, 'value')) {
|
|
57
|
+
this.setState({
|
|
58
|
+
sValue: value,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
render() {
|
|
65
|
+
const {
|
|
66
|
+
sValue,
|
|
67
|
+
cellRender,
|
|
68
|
+
contentRender,
|
|
69
|
+
locale,
|
|
70
|
+
rootPrefixCls,
|
|
71
|
+
disabledDate,
|
|
72
|
+
renderFooter,
|
|
73
|
+
selectedValue,
|
|
74
|
+
hoverValue,
|
|
75
|
+
} = this;
|
|
76
|
+
const year = sValue.year();
|
|
77
|
+
const prefixCls = `${rootPrefixCls}-month-panel`;
|
|
78
|
+
const monthHover = getListeners(this).monthHover || noop;
|
|
79
|
+
|
|
80
|
+
const footer = renderFooter && renderFooter('month');
|
|
81
|
+
return (
|
|
82
|
+
<div class={prefixCls}>
|
|
83
|
+
<div>
|
|
84
|
+
<div class={`${prefixCls}-header`}>
|
|
85
|
+
<a
|
|
86
|
+
class={`${prefixCls}-prev-year-btn`}
|
|
87
|
+
role="button"
|
|
88
|
+
onClick={this.previousYear}
|
|
89
|
+
title={locale.previousYear}
|
|
90
|
+
/>
|
|
91
|
+
|
|
92
|
+
<a
|
|
93
|
+
class={`${prefixCls}-year-select`}
|
|
94
|
+
role="button"
|
|
95
|
+
onClick={getListeners(this).yearPanelShow || noop}
|
|
96
|
+
title={locale.yearSelect}
|
|
97
|
+
>
|
|
98
|
+
<span class={`${prefixCls}-year-select-content`}>{year}</span>
|
|
99
|
+
<span class={`${prefixCls}-year-select-arrow`}>x</span>
|
|
100
|
+
</a>
|
|
101
|
+
|
|
102
|
+
<a
|
|
103
|
+
class={`${prefixCls}-next-year-btn`}
|
|
104
|
+
role="button"
|
|
105
|
+
onClick={this.nextYear}
|
|
106
|
+
title={locale.nextYear}
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
<div class={`${prefixCls}-body`}>
|
|
110
|
+
<MonthTable
|
|
111
|
+
disabledDate={disabledDate}
|
|
112
|
+
onSelect={this.setAndSelectValue}
|
|
113
|
+
onMonthHover={monthHover}
|
|
114
|
+
locale={locale}
|
|
115
|
+
value={sValue}
|
|
116
|
+
selectedValue={selectedValue}
|
|
117
|
+
hoverValue={hoverValue}
|
|
118
|
+
cellRender={cellRender}
|
|
119
|
+
contentRender={contentRender}
|
|
120
|
+
prefixCls={prefixCls}
|
|
121
|
+
/>
|
|
122
|
+
</div>
|
|
123
|
+
{footer && <div class={`${prefixCls}-footer`}>{footer}</div>}
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
);
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export default MonthPanel;
|
|
@@ -1,138 +1,252 @@
|
|
|
1
|
-
import PropTypes from '../../../_util/vue-types';
|
|
2
|
-
import BaseMixin from '../../../_util/BaseMixin';
|
|
3
|
-
import { getTodayTime, getMonthName } from '../util/index';
|
|
4
|
-
|
|
5
|
-
const ROW = 4;
|
|
6
|
-
const COL = 3;
|
|
7
|
-
|
|
8
|
-
function noop() {}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
value(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
1
|
+
import PropTypes from '../../../_util/vue-types';
|
|
2
|
+
import BaseMixin from '../../../_util/BaseMixin';
|
|
3
|
+
import { getTodayTime, getMonthName } from '../util/index';
|
|
4
|
+
|
|
5
|
+
const ROW = 4;
|
|
6
|
+
const COL = 3;
|
|
7
|
+
|
|
8
|
+
function noop() {}
|
|
9
|
+
|
|
10
|
+
// 判断是否为范围选择模式
|
|
11
|
+
function isRangeMode(selectedValue) {
|
|
12
|
+
return Array.isArray(selectedValue);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 获取范围开始的年月
|
|
16
|
+
function getRangeStart(value) {
|
|
17
|
+
if (!isRangeMode(value) || !value[0]) return null;
|
|
18
|
+
return {
|
|
19
|
+
year: value[0].year(),
|
|
20
|
+
month: value[0].month(),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 获取范围结束的年月
|
|
25
|
+
function getRangeEnd(value) {
|
|
26
|
+
if (!isRangeMode(value) || !value[1]) return null;
|
|
27
|
+
return {
|
|
28
|
+
year: value[1].year(),
|
|
29
|
+
month: value[1].month(),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// 比较两个年月
|
|
34
|
+
function compareYearMonth(year1, month1, year2, month2) {
|
|
35
|
+
if (year1 !== year2) return year1 - year2;
|
|
36
|
+
return month1 - month2;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const MonthTable = {
|
|
40
|
+
name: 'MonthTable',
|
|
41
|
+
mixins: [BaseMixin],
|
|
42
|
+
props: {
|
|
43
|
+
cellRender: PropTypes.func,
|
|
44
|
+
prefixCls: PropTypes.string,
|
|
45
|
+
value: PropTypes.object,
|
|
46
|
+
// 支持单个值或数组(范围选择)
|
|
47
|
+
selectedValue: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
48
|
+
// hover 值,用于范围选择时的预览效果
|
|
49
|
+
hoverValue: PropTypes.array.def([]),
|
|
50
|
+
locale: PropTypes.any,
|
|
51
|
+
contentRender: PropTypes.any,
|
|
52
|
+
disabledDate: PropTypes.func,
|
|
53
|
+
},
|
|
54
|
+
data() {
|
|
55
|
+
return {
|
|
56
|
+
sValue: this.value,
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
watch: {
|
|
60
|
+
value(val) {
|
|
61
|
+
this.setState({
|
|
62
|
+
sValue: val,
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
methods: {
|
|
67
|
+
setAndSelectValue(value) {
|
|
68
|
+
this.setState({
|
|
69
|
+
sValue: value,
|
|
70
|
+
});
|
|
71
|
+
this.__emit('select', value);
|
|
72
|
+
},
|
|
73
|
+
chooseMonth(month) {
|
|
74
|
+
const next = this.sValue.clone();
|
|
75
|
+
next.month(month);
|
|
76
|
+
this.setAndSelectValue(next);
|
|
77
|
+
},
|
|
78
|
+
months() {
|
|
79
|
+
const value = this.sValue;
|
|
80
|
+
const current = value.clone();
|
|
81
|
+
const months = [];
|
|
82
|
+
let index = 0;
|
|
83
|
+
for (let rowIndex = 0; rowIndex < ROW; rowIndex++) {
|
|
84
|
+
months[rowIndex] = [];
|
|
85
|
+
for (let colIndex = 0; colIndex < COL; colIndex++) {
|
|
86
|
+
current.month(index);
|
|
87
|
+
const content = getMonthName(current);
|
|
88
|
+
months[rowIndex][colIndex] = {
|
|
89
|
+
value: index,
|
|
90
|
+
content,
|
|
91
|
+
title: content,
|
|
92
|
+
};
|
|
93
|
+
index++;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return months;
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
render() {
|
|
101
|
+
const props = this.$props;
|
|
102
|
+
const value = this.sValue;
|
|
103
|
+
const { selectedValue, hoverValue } = props;
|
|
104
|
+
const today = getTodayTime(value);
|
|
105
|
+
const months = this.months();
|
|
106
|
+
const { prefixCls, locale, contentRender, cellRender, disabledDate } = props;
|
|
107
|
+
const monthHover = this.$listeners.monthHover || noop;
|
|
108
|
+
|
|
109
|
+
// 判断是范围模式还是单值模式
|
|
110
|
+
const rangeMode = isRangeMode(selectedValue);
|
|
111
|
+
|
|
112
|
+
// 使用 hoverValue 进行范围预览(如果存在的话)
|
|
113
|
+
const rangeValue = hoverValue && hoverValue.length ? hoverValue : selectedValue;
|
|
114
|
+
const rangeStart = getRangeStart(rangeValue);
|
|
115
|
+
const rangeEnd = getRangeEnd(rangeValue);
|
|
116
|
+
|
|
117
|
+
// 选中值(用于显示实际选中的起始和结束)
|
|
118
|
+
const selectedStart = getRangeStart(selectedValue);
|
|
119
|
+
const selectedEnd = getRangeEnd(selectedValue);
|
|
120
|
+
|
|
121
|
+
// 单值模式:只有当 selectedValue 存在且与当前面板年份相同时,才显示选中状态
|
|
122
|
+
const hasSelectedValue = !rangeMode && selectedValue && selectedValue.year() === value.year();
|
|
123
|
+
const selectedMonth = hasSelectedValue ? selectedValue.month() : -1;
|
|
124
|
+
|
|
125
|
+
// 获取根前缀类(用于 in-range-cell 类名)
|
|
126
|
+
const rootPrefixCls = prefixCls.replace('-month-panel', '');
|
|
127
|
+
const currentYear = value.year();
|
|
128
|
+
|
|
129
|
+
const monthsEls = months.map((month, index) => {
|
|
130
|
+
const tds = month.map(monthData => {
|
|
131
|
+
let disabled = false;
|
|
132
|
+
if (disabledDate) {
|
|
133
|
+
const testValue = value.clone();
|
|
134
|
+
testValue.month(monthData.value);
|
|
135
|
+
disabled = disabledDate(testValue);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// 判断当前月份是否在选中范围内(使用实际选中值)
|
|
139
|
+
let isSelectedStart = false;
|
|
140
|
+
let isSelectedEnd = false;
|
|
141
|
+
|
|
142
|
+
if (rangeMode && selectedStart) {
|
|
143
|
+
isSelectedStart = selectedStart.year === currentYear && selectedStart.month === monthData.value;
|
|
144
|
+
}
|
|
145
|
+
if (rangeMode && selectedEnd) {
|
|
146
|
+
isSelectedEnd = selectedEnd.year === currentYear && selectedEnd.month === monthData.value;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// 判断当前月份是否在范围内(使用 rangeValue,可能是 hover 值)
|
|
150
|
+
let isRangeStart = false;
|
|
151
|
+
let isRangeEnd = false;
|
|
152
|
+
let isInRange = false;
|
|
153
|
+
|
|
154
|
+
if (rangeMode && rangeStart && rangeEnd) {
|
|
155
|
+
// 当前月份的年月
|
|
156
|
+
const currentYearMonth = { year: currentYear, month: monthData.value };
|
|
157
|
+
|
|
158
|
+
// 判断是否为范围开始
|
|
159
|
+
isRangeStart = rangeStart.year === currentYear && rangeStart.month === monthData.value;
|
|
160
|
+
|
|
161
|
+
// 判断是否为范围结束
|
|
162
|
+
isRangeEnd = rangeEnd.year === currentYear && rangeEnd.month === monthData.value;
|
|
163
|
+
|
|
164
|
+
// 判断是否在范围中间
|
|
165
|
+
const compareWithStart = compareYearMonth(
|
|
166
|
+
currentYear,
|
|
167
|
+
monthData.value,
|
|
168
|
+
rangeStart.year,
|
|
169
|
+
rangeStart.month
|
|
170
|
+
);
|
|
171
|
+
const compareWithEnd = compareYearMonth(
|
|
172
|
+
currentYear,
|
|
173
|
+
monthData.value,
|
|
174
|
+
rangeEnd.year,
|
|
175
|
+
rangeEnd.month
|
|
176
|
+
);
|
|
177
|
+
isInRange = compareWithStart > 0 && compareWithEnd < 0;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// 判断是否为 hover 预览状态(有 hoverValue 时)
|
|
181
|
+
const isHoverRange = hoverValue && hoverValue.length > 0;
|
|
182
|
+
|
|
183
|
+
const classNameMap = {
|
|
184
|
+
[`${prefixCls}-cell`]: 1,
|
|
185
|
+
[`${prefixCls}-cell-disabled`]: disabled,
|
|
186
|
+
// 单值模式的选中状态
|
|
187
|
+
[`${prefixCls}-selected-cell`]: monthData.value === selectedMonth,
|
|
188
|
+
// 范围模式的选中状态(实际选中)
|
|
189
|
+
[`${prefixCls}-selected-start-cell`]: isSelectedStart,
|
|
190
|
+
[`${prefixCls}-selected-end-cell`]: isSelectedEnd,
|
|
191
|
+
// 范围背景(包括 hover 预览)
|
|
192
|
+
[`${rootPrefixCls}-in-range-cell`]: isInRange || isRangeStart || isRangeEnd,
|
|
193
|
+
// hover 预览状态(仅当有 hoverValue 时才添加 hover 样式类)
|
|
194
|
+
[`${rootPrefixCls}-in-hover-range-cell`]: isHoverRange && (isInRange || isRangeStart || isRangeEnd),
|
|
195
|
+
[`${prefixCls}-current-cell`]:
|
|
196
|
+
today.year() === value.year() && monthData.value === today.month(),
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// hover 处理函数
|
|
200
|
+
const hoverHandler = () => {
|
|
201
|
+
if (disabled) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const hoverTime = value.clone().month(monthData.value);
|
|
205
|
+
monthHover(hoverTime);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
let cellEl;
|
|
209
|
+
if (cellRender) {
|
|
210
|
+
const currentValue = value.clone();
|
|
211
|
+
currentValue.month(monthData.value);
|
|
212
|
+
cellEl = cellRender(currentValue, locale);
|
|
213
|
+
} else {
|
|
214
|
+
let content;
|
|
215
|
+
if (contentRender) {
|
|
216
|
+
const currentValue = value.clone();
|
|
217
|
+
currentValue.month(monthData.value);
|
|
218
|
+
content = contentRender(currentValue, locale);
|
|
219
|
+
} else {
|
|
220
|
+
content = monthData.content;
|
|
221
|
+
}
|
|
222
|
+
cellEl = <a class={`${prefixCls}-month`}>{content}</a>;
|
|
223
|
+
}
|
|
224
|
+
return (
|
|
225
|
+
<td
|
|
226
|
+
role="gridcell"
|
|
227
|
+
key={monthData.value}
|
|
228
|
+
onClick={disabled ? noop : () => this.chooseMonth(monthData.value)}
|
|
229
|
+
onMouseenter={hoverHandler}
|
|
230
|
+
title={monthData.title}
|
|
231
|
+
class={classNameMap}
|
|
232
|
+
>
|
|
233
|
+
{cellEl}
|
|
234
|
+
</td>
|
|
235
|
+
);
|
|
236
|
+
});
|
|
237
|
+
return (
|
|
238
|
+
<tr key={index} role="row">
|
|
239
|
+
{tds}
|
|
240
|
+
</tr>
|
|
241
|
+
);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
return (
|
|
245
|
+
<table class={`${prefixCls}-table`} cellSpacing="0" role="grid">
|
|
246
|
+
<tbody class={`${prefixCls}-tbody`}>{monthsEls}</tbody>
|
|
247
|
+
</table>
|
|
248
|
+
);
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
export default MonthTable;
|