1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _vueTypes = require('../../../_util/vue-types');
var _vueTypes2 = _interopRequireDefault(_vueTypes);
var _BaseMixin = require('../../../_util/BaseMixin');
var _BaseMixin2 = _interopRequireDefault(_BaseMixin);
var _util = require('../util');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var CalendarHeader = {
mixins: [_BaseMixin2['default']],
props: {
value: _vueTypes2['default'].object,
locale: _vueTypes2['default'].object,
yearSelectOffset: _vueTypes2['default'].number.def(10),
yearSelectTotal: _vueTypes2['default'].number.def(20),
// onValueChange: PropTypes.func,
// onTypeChange: PropTypes.func,
Select: _vueTypes2['default'].object,
prefixCls: _vueTypes2['default'].string,
type: _vueTypes2['default'].string,
showTypeSwitch: _vueTypes2['default'].bool,
headerComponents: _vueTypes2['default'].array
},
methods: {
onYearChange: function onYearChange(year) {
var newValue = this.value.clone();
newValue.year(parseInt(year, 10));
this.__emit('valueChange', newValue);
},
onMonthChange: function onMonthChange(month) {
var newValue = this.value.clone();
newValue.month(parseInt(month, 10));
this.__emit('valueChange', newValue);
},
yearSelectElement: function yearSelectElement(year) {
var h = this.$createElement;
var yearSelectOffset = this.yearSelectOffset,
yearSelectTotal = this.yearSelectTotal,
prefixCls = this.prefixCls,
Select = this.Select;
var start = year - yearSelectOffset;
var end = start + yearSelectTotal;
var options = [];
for (var index = start; index < end; index++) {
options.push(h(
Select.Option,
{ key: '' + index },
[index]
));
}
return h(
Select,
{
'class': prefixCls + '-header-year-select',
on: {
'change': this.onYearChange
},
attrs: {
dropdownStyle: { zIndex: 2000 },
dropdownMenuStyle: { maxHeight: '250px', overflow: 'auto', fontSize: '12px' },
optionLabelProp: 'children',
value: String(year),
showSearch: false
}
},
[options]
);
},
monthSelectElement: function monthSelectElement(month) {
var h = this.$createElement;
var value = this.value,
Select = this.Select,
prefixCls = this.prefixCls;
var t = value.clone();
var options = [];
for (var index = 0; index < 12; index++) {
t.month(index);
options.push(h(
Select.Option,
{ key: '' + index },
[(0, _util.getMonthName)(t)]
));
}
return h(
Select,
{
'class': prefixCls + '-header-month-select',
attrs: { dropdownStyle: { zIndex: 2000 },
dropdownMenuStyle: {
maxHeight: '250px',
overflow: 'auto',
overflowX: 'hidden',
fontSize: '12px'
},
optionLabelProp: 'children',
value: String(month),
showSearch: false
},
on: {
'change': this.onMonthChange
}
},
[options]
);
},
changeTypeToDate: function changeTypeToDate() {
this.__emit('typeChange', 'date');
},
changeTypeToMonth: function changeTypeToMonth() {
this.__emit('typeChange', 'month');
}
},
render: function render() {
var h = arguments[0];
var value = this.value,
locale = this.locale,
prefixCls = this.prefixCls,
type = this.type,
showTypeSwitch = this.showTypeSwitch,
headerComponents = this.headerComponents;
var year = value.year();
var month = value.month();
var yearSelect = this.yearSelectElement(year);
var monthSelect = type === 'month' ? null : this.monthSelectElement(month);
var switchCls = prefixCls + '-header-switcher';
var typeSwitcher = showTypeSwitch ? h(
'span',
{ 'class': switchCls },
[type === 'date' ? h(
'span',
{ 'class': switchCls + '-focus' },
[locale.month]
) : h(
'span',
{
on: {
'click': this.changeTypeToDate
},
'class': switchCls + '-normal' },
[locale.month]
), type === 'month' ? h(
'span',
{ 'class': switchCls + '-focus' },
[locale.year]
) : h(
'span',
{
on: {
'click': this.changeTypeToMonth
},
'class': switchCls + '-normal' },
[locale.year]
)]
) : null;
return h(
'div',
{ 'class': prefixCls + '-header' },
[typeSwitcher, monthSelect, yearSelect, headerComponents]
);
}
};
exports['default'] = CalendarHeader;