@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,264 +1,277 @@
|
|
|
1
|
-
import PropTypes from '../../../_util/vue-types';
|
|
2
|
-
import BaseMixin from '../../../_util/BaseMixin';
|
|
3
|
-
import { getOptionProps, getListeners } from '../../../_util/props-util';
|
|
4
|
-
import MonthPanel from '../month/MonthPanel';
|
|
5
|
-
import YearPanel from '../year/YearPanel';
|
|
6
|
-
import DecadePanel from '../decade/DecadePanel';
|
|
7
|
-
function noop() {}
|
|
8
|
-
function goMonth(direction) {
|
|
9
|
-
const next = this.value.clone();
|
|
10
|
-
next.add(direction, 'months');
|
|
11
|
-
this.__emit('valueChange', next);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function goYear(direction) {
|
|
15
|
-
const next = this.value.clone();
|
|
16
|
-
next.add(direction, 'years');
|
|
17
|
-
this.__emit('valueChange', next);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function showIf(condition, el) {
|
|
21
|
-
return condition ? el : null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const CalendarHeader = {
|
|
25
|
-
name: 'CalendarHeader',
|
|
26
|
-
mixins: [BaseMixin],
|
|
27
|
-
props: {
|
|
28
|
-
prefixCls: PropTypes.string,
|
|
29
|
-
value: PropTypes.object,
|
|
30
|
-
// onValueChange: PropTypes.func,
|
|
31
|
-
showTimePicker: PropTypes.bool,
|
|
32
|
-
// onPanelChange: PropTypes.func,
|
|
33
|
-
locale: PropTypes.object,
|
|
34
|
-
enablePrev: PropTypes.any.def(1),
|
|
35
|
-
enableNext: PropTypes.any.def(1),
|
|
36
|
-
disabledMonth: PropTypes.func,
|
|
37
|
-
mode: PropTypes.any,
|
|
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
|
-
this.__emit('valueChange', value);
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
const
|
|
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
|
-
this.__emit('panelChange', null, '
|
|
152
|
-
},
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
this.
|
|
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
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
1
|
+
import PropTypes from '../../../_util/vue-types';
|
|
2
|
+
import BaseMixin from '../../../_util/BaseMixin';
|
|
3
|
+
import { getOptionProps, getListeners } from '../../../_util/props-util';
|
|
4
|
+
import MonthPanel from '../month/MonthPanel';
|
|
5
|
+
import YearPanel from '../year/YearPanel';
|
|
6
|
+
import DecadePanel from '../decade/DecadePanel';
|
|
7
|
+
function noop() {}
|
|
8
|
+
function goMonth(direction) {
|
|
9
|
+
const next = this.value.clone();
|
|
10
|
+
next.add(direction, 'months');
|
|
11
|
+
this.__emit('valueChange', next);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function goYear(direction) {
|
|
15
|
+
const next = this.value.clone();
|
|
16
|
+
next.add(direction, 'years');
|
|
17
|
+
this.__emit('valueChange', next);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function showIf(condition, el) {
|
|
21
|
+
return condition ? el : null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const CalendarHeader = {
|
|
25
|
+
name: 'CalendarHeader',
|
|
26
|
+
mixins: [BaseMixin],
|
|
27
|
+
props: {
|
|
28
|
+
prefixCls: PropTypes.string,
|
|
29
|
+
value: PropTypes.object,
|
|
30
|
+
// onValueChange: PropTypes.func,
|
|
31
|
+
showTimePicker: PropTypes.bool,
|
|
32
|
+
// onPanelChange: PropTypes.func,
|
|
33
|
+
locale: PropTypes.object,
|
|
34
|
+
enablePrev: PropTypes.any.def(1),
|
|
35
|
+
enableNext: PropTypes.any.def(1),
|
|
36
|
+
disabledMonth: PropTypes.func,
|
|
37
|
+
mode: PropTypes.any,
|
|
38
|
+
// 支持数组形式,用于范围选择器
|
|
39
|
+
selectedValue: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
40
|
+
// hover 值,用于范围选择时的预览效果
|
|
41
|
+
hoverValue: PropTypes.array.def([]),
|
|
42
|
+
monthCellRender: PropTypes.func,
|
|
43
|
+
monthCellContentRender: PropTypes.func,
|
|
44
|
+
renderFooter: PropTypes.func,
|
|
45
|
+
// 用于范围选择器,标识是左面板还是右面板
|
|
46
|
+
direction: PropTypes.string,
|
|
47
|
+
},
|
|
48
|
+
data() {
|
|
49
|
+
this.nextMonth = goMonth.bind(this, 1);
|
|
50
|
+
this.previousMonth = goMonth.bind(this, -1);
|
|
51
|
+
this.nextYear = goYear.bind(this, 1);
|
|
52
|
+
this.previousYear = goYear.bind(this, -1);
|
|
53
|
+
return {
|
|
54
|
+
yearPanelReferer: null,
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
methods: {
|
|
58
|
+
onMonthSelect(value) {
|
|
59
|
+
this.__emit('panelChange', value, 'date');
|
|
60
|
+
if (getListeners(this).monthSelect) {
|
|
61
|
+
this.__emit('monthSelect', value);
|
|
62
|
+
} else {
|
|
63
|
+
// 只有当当前不是月份选择器模式时才触发 valueChange
|
|
64
|
+
// 当 mode === 'month' 时,表示用户在月份选择器模式下直接选择月份
|
|
65
|
+
// 此时不需要触发 valueChange,因为选择已通过 panelChange 处理
|
|
66
|
+
if (this.mode !== 'month') {
|
|
67
|
+
this.__emit('valueChange', value);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
onYearSelect(value) {
|
|
73
|
+
const referer = this.yearPanelReferer;
|
|
74
|
+
this.setState({ yearPanelReferer: null });
|
|
75
|
+
this.__emit('panelChange', value, referer);
|
|
76
|
+
// 只有当从其他面板进入年份选择时才触发 valueChange
|
|
77
|
+
// 当 referer 为 null 时,表示用户在年份选择器模式下直接选择年份
|
|
78
|
+
// 此时不需要触发 valueChange,因为选择已通过 panelChange 处理
|
|
79
|
+
// 触发 valueChange 会导致面板显示值被重置
|
|
80
|
+
if (referer) {
|
|
81
|
+
this.__emit('valueChange', value);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
onDecadeSelect(value) {
|
|
86
|
+
this.__emit('panelChange', value, 'year');
|
|
87
|
+
this.__emit('valueChange', value);
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
// 处理年份面板的十年导航变化
|
|
91
|
+
onYearValueChange(value) {
|
|
92
|
+
this.__emit('valueChange', value);
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
changeYear(direction) {
|
|
96
|
+
if (direction > 0) {
|
|
97
|
+
this.nextYear();
|
|
98
|
+
} else {
|
|
99
|
+
this.previousYear();
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
monthYearElement(showTimePicker) {
|
|
104
|
+
const props = this.$props;
|
|
105
|
+
const prefixCls = props.prefixCls;
|
|
106
|
+
const locale = props.locale;
|
|
107
|
+
const value = props.value;
|
|
108
|
+
const localeData = value.localeData();
|
|
109
|
+
const monthBeforeYear = locale.monthBeforeYear;
|
|
110
|
+
const selectClassName = `${prefixCls}-${monthBeforeYear ? 'my-select' : 'ym-select'}`;
|
|
111
|
+
const timeClassName = showTimePicker ? ` ${prefixCls}-time-status` : '';
|
|
112
|
+
const year = (
|
|
113
|
+
<a
|
|
114
|
+
class={`${prefixCls}-year-select${timeClassName}`}
|
|
115
|
+
role="button"
|
|
116
|
+
onClick={showTimePicker ? noop : () => this.showYearPanel('date')}
|
|
117
|
+
title={showTimePicker ? null : locale.yearSelect}
|
|
118
|
+
>
|
|
119
|
+
{value.format(locale.yearFormat)}
|
|
120
|
+
</a>
|
|
121
|
+
);
|
|
122
|
+
const month = (
|
|
123
|
+
<a
|
|
124
|
+
class={`${prefixCls}-month-select${timeClassName}`}
|
|
125
|
+
role="button"
|
|
126
|
+
onClick={showTimePicker ? noop : this.showMonthPanel}
|
|
127
|
+
title={showTimePicker ? null : locale.monthSelect}
|
|
128
|
+
>
|
|
129
|
+
{locale.monthFormat ? value.format(locale.monthFormat) : localeData.monthsShort(value)}
|
|
130
|
+
</a>
|
|
131
|
+
);
|
|
132
|
+
let day;
|
|
133
|
+
if (showTimePicker) {
|
|
134
|
+
day = (
|
|
135
|
+
<a class={`${prefixCls}-day-select${timeClassName}`} role="button">
|
|
136
|
+
{value.format(locale.dayFormat)}
|
|
137
|
+
</a>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
let my = [];
|
|
141
|
+
if (monthBeforeYear) {
|
|
142
|
+
my = [month, day, year];
|
|
143
|
+
} else {
|
|
144
|
+
my = [year, month, day];
|
|
145
|
+
}
|
|
146
|
+
return <span class={selectClassName}>{my}</span>;
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
showMonthPanel() {
|
|
150
|
+
// null means that users' interaction doesn't change value
|
|
151
|
+
this.__emit('panelChange', null, 'month');
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
showYearPanel(referer) {
|
|
155
|
+
this.setState({ yearPanelReferer: referer });
|
|
156
|
+
this.__emit('panelChange', null, 'year');
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
showDecadePanel() {
|
|
160
|
+
this.__emit('panelChange', null, 'decade');
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
render() {
|
|
165
|
+
const props = getOptionProps(this);
|
|
166
|
+
const {
|
|
167
|
+
prefixCls,
|
|
168
|
+
locale,
|
|
169
|
+
mode,
|
|
170
|
+
value,
|
|
171
|
+
showTimePicker,
|
|
172
|
+
enableNext,
|
|
173
|
+
enablePrev,
|
|
174
|
+
disabledMonth,
|
|
175
|
+
renderFooter,
|
|
176
|
+
selectedValue,
|
|
177
|
+
hoverValue,
|
|
178
|
+
} = props;
|
|
179
|
+
|
|
180
|
+
const yearHover = getListeners(this).yearHover || noop;
|
|
181
|
+
const monthHover = getListeners(this).monthHover || noop;
|
|
182
|
+
|
|
183
|
+
let panel = null;
|
|
184
|
+
if (mode === 'month') {
|
|
185
|
+
panel = (
|
|
186
|
+
<MonthPanel
|
|
187
|
+
locale={locale}
|
|
188
|
+
value={value}
|
|
189
|
+
selectedValue={selectedValue}
|
|
190
|
+
hoverValue={hoverValue}
|
|
191
|
+
rootPrefixCls={prefixCls}
|
|
192
|
+
onSelect={this.onMonthSelect}
|
|
193
|
+
onYearPanelShow={() => this.showYearPanel('month')}
|
|
194
|
+
onMonthHover={monthHover}
|
|
195
|
+
disabledDate={disabledMonth}
|
|
196
|
+
cellRender={props.monthCellRender}
|
|
197
|
+
contentRender={props.monthCellContentRender}
|
|
198
|
+
renderFooter={renderFooter}
|
|
199
|
+
changeYear={this.changeYear}
|
|
200
|
+
/>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
if (mode === 'year') {
|
|
204
|
+
panel = (
|
|
205
|
+
<YearPanel
|
|
206
|
+
locale={locale}
|
|
207
|
+
value={value}
|
|
208
|
+
selectedValue={selectedValue}
|
|
209
|
+
hoverValue={hoverValue}
|
|
210
|
+
rootPrefixCls={prefixCls}
|
|
211
|
+
onSelect={this.onYearSelect}
|
|
212
|
+
onValueChange={this.onYearValueChange}
|
|
213
|
+
onDecadePanelShow={this.showDecadePanel}
|
|
214
|
+
onYearHover={yearHover}
|
|
215
|
+
renderFooter={renderFooter}
|
|
216
|
+
disabledDate={disabledMonth}
|
|
217
|
+
/>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
if (mode === 'decade') {
|
|
221
|
+
panel = (
|
|
222
|
+
<DecadePanel
|
|
223
|
+
locale={locale}
|
|
224
|
+
value={value}
|
|
225
|
+
rootPrefixCls={prefixCls}
|
|
226
|
+
onSelect={this.onDecadeSelect}
|
|
227
|
+
renderFooter={renderFooter}
|
|
228
|
+
/>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return (
|
|
233
|
+
<div class={`${prefixCls}-header`}>
|
|
234
|
+
<div style={{ position: 'relative' }}>
|
|
235
|
+
{showIf(
|
|
236
|
+
enablePrev && !showTimePicker,
|
|
237
|
+
<a
|
|
238
|
+
class={`${prefixCls}-prev-year-btn`}
|
|
239
|
+
role="button"
|
|
240
|
+
onClick={this.previousYear}
|
|
241
|
+
title={locale.previousYear}
|
|
242
|
+
/>,
|
|
243
|
+
)}
|
|
244
|
+
{showIf(
|
|
245
|
+
enablePrev && !showTimePicker,
|
|
246
|
+
<a
|
|
247
|
+
class={`${prefixCls}-prev-month-btn`}
|
|
248
|
+
role="button"
|
|
249
|
+
onClick={this.previousMonth}
|
|
250
|
+
title={locale.previousMonth}
|
|
251
|
+
/>,
|
|
252
|
+
)}
|
|
253
|
+
{this.monthYearElement(showTimePicker)}
|
|
254
|
+
{showIf(
|
|
255
|
+
enableNext && !showTimePicker,
|
|
256
|
+
<a
|
|
257
|
+
class={`${prefixCls}-next-month-btn`}
|
|
258
|
+
onClick={this.nextMonth}
|
|
259
|
+
title={locale.nextMonth}
|
|
260
|
+
/>,
|
|
261
|
+
)}
|
|
262
|
+
{showIf(
|
|
263
|
+
enableNext && !showTimePicker,
|
|
264
|
+
<a
|
|
265
|
+
class={`${prefixCls}-next-year-btn`}
|
|
266
|
+
onClick={this.nextYear}
|
|
267
|
+
title={locale.nextYear}
|
|
268
|
+
/>,
|
|
269
|
+
)}
|
|
270
|
+
</div>
|
|
271
|
+
{panel}
|
|
272
|
+
</div>
|
|
273
|
+
);
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
export default CalendarHeader;
|