v-page 2.0.6 → 2.0.10
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 +93 -90
- package/dist/v-page.js +1 -1
- package/dist/v-page.js.map +1 -1
- package/package.json +39 -14
- package/types/index.d.ts +62 -0
- package/.babelrc +0 -6
- package/.editorconfig +0 -9
- package/src/Page.vue +0 -185
- package/src/index.js +0 -21
- package/src/language.js +0 -28
- package/src/page.scss +0 -125
- package/webpack.config.js +0 -113
package/src/Page.vue
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="v-pagination" :class="classes">
|
|
3
|
-
<ul>
|
|
4
|
-
<!-- page length list -->
|
|
5
|
-
<li class="v-pagination__list" v-if="pageSizeMenu">
|
|
6
|
-
<a>{{i18n.pageLength}}
|
|
7
|
-
<select @change="switchLength" v-model="pageSize" :disabled="disabled">
|
|
8
|
-
<option :key="index" v-for="(len,index) in pageSizeMenu">{{len}}</option>
|
|
9
|
-
</select>
|
|
10
|
-
</a>
|
|
11
|
-
</li>
|
|
12
|
-
<!-- page info -->
|
|
13
|
-
<li class="v-pagination__info" v-if="info">
|
|
14
|
-
<a v-text="pageInfo"></a>
|
|
15
|
-
</li>
|
|
16
|
-
|
|
17
|
-
<li :class="{disabled:currentPage === 1||disabled} " v-if="first">
|
|
18
|
-
<a href="javascript:void(0);" @click="switchPage('first')" v-text="i18n.first"></a>
|
|
19
|
-
</li>
|
|
20
|
-
<li :class="{disabled:currentPage === 1||disabled}">
|
|
21
|
-
<a href="javascript:void(0);" @click="switchPage('previous')" v-text="i18n.previous"></a>
|
|
22
|
-
</li>
|
|
23
|
-
|
|
24
|
-
<!-- page numbers -->
|
|
25
|
-
<template v-if="pageNumber">
|
|
26
|
-
<li :class="{active:(num === currentPage),disabled:disabled&&num !== currentPage}"
|
|
27
|
-
v-for="(num,index) in pageNumbers" :key="index">
|
|
28
|
-
<a href="javascript:void(0);" @click="switchPage(num)" v-text="num"></a>
|
|
29
|
-
</li>
|
|
30
|
-
</template>
|
|
31
|
-
|
|
32
|
-
<li :class="{disabled:currentPage === totalPage||disabled}">
|
|
33
|
-
<a href="javascript:void(0);" @click="switchPage('next')" v-text="i18n.next"></a>
|
|
34
|
-
</li>
|
|
35
|
-
<li :class="{disabled:currentPage === totalPage||disabled}" v-if="last">
|
|
36
|
-
<a href="javascript:void(0);" @click="switchPage('last')" v-text="i18n.last"></a>
|
|
37
|
-
</li>
|
|
38
|
-
</ul>
|
|
39
|
-
</div>
|
|
40
|
-
</template>
|
|
41
|
-
|
|
42
|
-
<script>
|
|
43
|
-
import languages from './language';
|
|
44
|
-
import './page.scss';
|
|
45
|
-
|
|
46
|
-
const FIRST = 1;
|
|
47
|
-
|
|
48
|
-
export default {
|
|
49
|
-
name: "v-page",
|
|
50
|
-
props: {
|
|
51
|
-
totalRow: {
|
|
52
|
-
type: Number,
|
|
53
|
-
default: 0
|
|
54
|
-
},
|
|
55
|
-
pageSizeMenu: {
|
|
56
|
-
type: [Boolean, Array],
|
|
57
|
-
default: function () {
|
|
58
|
-
return [10, 20, 50, 100];
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
language: {
|
|
62
|
-
type: String,
|
|
63
|
-
default: 'cn'
|
|
64
|
-
},
|
|
65
|
-
align: {
|
|
66
|
-
type: String,
|
|
67
|
-
default: 'right'
|
|
68
|
-
},
|
|
69
|
-
disabled: {
|
|
70
|
-
type: Boolean,
|
|
71
|
-
default: false
|
|
72
|
-
},
|
|
73
|
-
border: {
|
|
74
|
-
type: Boolean,
|
|
75
|
-
default: true
|
|
76
|
-
},
|
|
77
|
-
info: {
|
|
78
|
-
type: Boolean,
|
|
79
|
-
default: true
|
|
80
|
-
},
|
|
81
|
-
pageNumber: {
|
|
82
|
-
type: Boolean,
|
|
83
|
-
default: true
|
|
84
|
-
},
|
|
85
|
-
first: {
|
|
86
|
-
type: Boolean,
|
|
87
|
-
default: true
|
|
88
|
-
},
|
|
89
|
-
last: {
|
|
90
|
-
type: Boolean,
|
|
91
|
-
default: true
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
data() {
|
|
95
|
-
return {
|
|
96
|
-
pageSize: this.pageSizeMenu === false ? 10 : this.pageSizeMenu[0],
|
|
97
|
-
totalPage: 0,
|
|
98
|
-
currentPage: 0,
|
|
99
|
-
pageNumberSize: 5,
|
|
100
|
-
i18n: languages[this.language] || languages['cn']
|
|
101
|
-
};
|
|
102
|
-
},
|
|
103
|
-
computed: {
|
|
104
|
-
pageNumbers() {
|
|
105
|
-
let start = 1, end, nums = [], half = Math.floor(this.pageNumberSize / 2);
|
|
106
|
-
if (this.totalPage < this.pageNumberSize) end = this.totalPage;
|
|
107
|
-
else if (this.currentPage <= half) end = this.pageNumberSize;
|
|
108
|
-
else if (this.currentPage >= (this.totalPage - half)) {
|
|
109
|
-
start = this.totalPage - this.pageNumberSize + 1;
|
|
110
|
-
end = this.totalPage;
|
|
111
|
-
} else {
|
|
112
|
-
start = this.currentPage - half;
|
|
113
|
-
end = start + this.pageNumberSize - 1;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
for (let i = start; i <= end; i++) {
|
|
117
|
-
nums.push(i);
|
|
118
|
-
}
|
|
119
|
-
return nums;
|
|
120
|
-
},
|
|
121
|
-
pageInfo() {
|
|
122
|
-
return this.i18n.pageInfo.replace('#pageNumber#', this.currentPage)
|
|
123
|
-
.replace('#totalPage#', this.totalPage)
|
|
124
|
-
.replace('#totalRow#', this.totalRow);
|
|
125
|
-
},
|
|
126
|
-
classes(){
|
|
127
|
-
return {
|
|
128
|
-
'v-pagination--no-border': !this.border,
|
|
129
|
-
'v-pagination--right': this.align === 'right',
|
|
130
|
-
'v-pagination--center': this.align === 'center'
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
watch: {
|
|
135
|
-
totalRow() {
|
|
136
|
-
this.calcTotalPage();
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
methods: {
|
|
140
|
-
goPage(pNum) {
|
|
141
|
-
if(typeof pNum !== 'number') return;
|
|
142
|
-
let num = FIRST;
|
|
143
|
-
if(pNum > num) num = pNum;
|
|
144
|
-
if(pNum > this.totalPage && this.totalPage > 0) num = this.totalPage;
|
|
145
|
-
|
|
146
|
-
if(num === this.currentPage) return;
|
|
147
|
-
this.currentPage = num;
|
|
148
|
-
this.change();
|
|
149
|
-
this.calcTotalPage();
|
|
150
|
-
},
|
|
151
|
-
reload(){
|
|
152
|
-
this.change();
|
|
153
|
-
},
|
|
154
|
-
change(){
|
|
155
|
-
this.$emit('page-change', {
|
|
156
|
-
pageNumber: this.currentPage,
|
|
157
|
-
pageSize: Number(this.pageSize)
|
|
158
|
-
});
|
|
159
|
-
},
|
|
160
|
-
calcTotalPage() {
|
|
161
|
-
this.totalPage = Math.ceil(this.totalRow / this.pageSize);
|
|
162
|
-
},
|
|
163
|
-
position(target){
|
|
164
|
-
if (typeof target === 'string') {
|
|
165
|
-
switch (target) {
|
|
166
|
-
case 'first': return FIRST;
|
|
167
|
-
case 'previous': return this.currentPage - 1;
|
|
168
|
-
case 'next': return this.currentPage + 1;
|
|
169
|
-
case 'last': return this.totalPage;
|
|
170
|
-
}
|
|
171
|
-
} else if (typeof target === 'number') return target;
|
|
172
|
-
},
|
|
173
|
-
switchPage(target) {
|
|
174
|
-
if (this.disabled) return;
|
|
175
|
-
this.goPage(this.position(target));
|
|
176
|
-
},
|
|
177
|
-
switchLength() {
|
|
178
|
-
this.goPage(FIRST);
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
mounted() {
|
|
182
|
-
this.goPage(FIRST);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
</script>
|
package/src/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import vPage from './Page';
|
|
2
|
-
|
|
3
|
-
const Plugin = {
|
|
4
|
-
install(Vue, options = {}){
|
|
5
|
-
if(Object.keys(options).length){
|
|
6
|
-
if(options.language) vPage.props.language.default = options.language;
|
|
7
|
-
if(options.align) vPage.props.align.default = options.align;
|
|
8
|
-
if(typeof options.info === 'boolean') vPage.props.info.default = options.info;
|
|
9
|
-
if(typeof options.border === 'boolean') vPage.props.border.default = options.border;
|
|
10
|
-
if(typeof options.pageNumber === 'boolean') vPage.props.pageNumber.default = options.pageNumber;
|
|
11
|
-
if(typeof options.first === 'boolean') vPage.props.first.default = options.first;
|
|
12
|
-
if(typeof options.last === 'boolean') vPage.props.last.default = options.last;
|
|
13
|
-
if(typeof options.pageSizeMenu !== 'undefined')
|
|
14
|
-
vPage.props.pageSizeMenu.default = options.pageSizeMenu;
|
|
15
|
-
}
|
|
16
|
-
Vue.component(vPage.name, vPage);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export {vPage};
|
|
21
|
-
export default Plugin;
|
package/src/language.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const languages = {
|
|
2
|
-
cn: {
|
|
3
|
-
pageLength: '每页记录数 ',
|
|
4
|
-
pageInfo: `当前显示第 #pageNumber# / #totalPage# 页(共#totalRow#条记录)`,
|
|
5
|
-
first: '首页',
|
|
6
|
-
previous: '«',
|
|
7
|
-
next: '»',
|
|
8
|
-
last: '尾页'
|
|
9
|
-
},
|
|
10
|
-
en: {
|
|
11
|
-
pageLength: 'Page length ',
|
|
12
|
-
pageInfo: 'Current #pageNumber# / #totalPage# (total #totalRow# records)',
|
|
13
|
-
first: 'First',
|
|
14
|
-
previous: '«',
|
|
15
|
-
next: '»',
|
|
16
|
-
last: 'Last'
|
|
17
|
-
},
|
|
18
|
-
jp: {
|
|
19
|
-
pageLength: 'ページごとの記録数',
|
|
20
|
-
pageInfo: '現在の第 #pageNumber# / #totalPage# ページ(全部で #totalRow# 条の記録)',
|
|
21
|
-
first: 'トップページ',
|
|
22
|
-
previous: '«',
|
|
23
|
-
next: '»',
|
|
24
|
-
last: '尾のページ'
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export default languages;
|
package/src/page.scss
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
$borderRadius: 2px;
|
|
2
|
-
div.v-pagination {
|
|
3
|
-
margin: 0;
|
|
4
|
-
display: block;
|
|
5
|
-
|
|
6
|
-
&.v-pagination--right { text-align: right; }
|
|
7
|
-
&.v-pagination--center { text-align: center; }
|
|
8
|
-
|
|
9
|
-
& > ul {
|
|
10
|
-
display: inline-block;
|
|
11
|
-
list-style: none;
|
|
12
|
-
margin: 0;
|
|
13
|
-
padding: 0;
|
|
14
|
-
-webkit-border-radius: 0;
|
|
15
|
-
-moz-border-radius: 0;
|
|
16
|
-
border-radius: 0;
|
|
17
|
-
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
|
18
|
-
-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
|
19
|
-
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
|
20
|
-
|
|
21
|
-
& > li {
|
|
22
|
-
text-align: center;margin: 0;display: inline;
|
|
23
|
-
|
|
24
|
-
& > a {
|
|
25
|
-
margin: 0 0 0 -1px;
|
|
26
|
-
position: relative;
|
|
27
|
-
border: 1px solid #DEE2E6;
|
|
28
|
-
padding: 6px 12px;
|
|
29
|
-
line-height: 1.4;
|
|
30
|
-
-webkit-box-shadow: none;
|
|
31
|
-
-moz-box-shadow: none;
|
|
32
|
-
box-shadow: none;
|
|
33
|
-
background-color: white;
|
|
34
|
-
font-size: 14px;
|
|
35
|
-
display: inline-block;
|
|
36
|
-
float: left;
|
|
37
|
-
text-decoration: none;
|
|
38
|
-
color: #333;
|
|
39
|
-
-webkit-transition: all .5s cubic-bezier(.175, .885, .32, 1);
|
|
40
|
-
transition: all .5s cubic-bezier(.175, .885, .32, 1);
|
|
41
|
-
|
|
42
|
-
&:hover {
|
|
43
|
-
z-index: 2;
|
|
44
|
-
-webkit-box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
|
|
45
|
-
-moz-box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
|
|
46
|
-
box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
&.disabled > a,
|
|
51
|
-
&.v-pagination__list > a,
|
|
52
|
-
&.v-pagination__info > a {
|
|
53
|
-
color: #999;cursor: default;
|
|
54
|
-
&:hover { color: #999;background-color: white;box-shadow: none; }
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
&.active > a,
|
|
58
|
-
&.active > span {
|
|
59
|
-
cursor: default;color: #999;background-color: #eee;
|
|
60
|
-
&:hover { box-shadow: none; }
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
&:first-child > a,
|
|
64
|
-
&:first-child > span {
|
|
65
|
-
border-left-width: 1px;
|
|
66
|
-
border-bottom-left-radius: $borderRadius;
|
|
67
|
-
border-top-left-radius: $borderRadius;
|
|
68
|
-
-webkit-border-bottom-left-radius: $borderRadius;
|
|
69
|
-
-webkit-border-top-left-radius: $borderRadius;
|
|
70
|
-
-moz-border-radius-bottomleft: $borderRadius;
|
|
71
|
-
-moz-border-radius-topleft: $borderRadius;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
&:last-child > a,
|
|
75
|
-
&:last-child > span {
|
|
76
|
-
border-top-right-radius: $borderRadius;
|
|
77
|
-
border-bottom-right-radius: $borderRadius;
|
|
78
|
-
-webkit-border-bottom-right-radius: $borderRadius;
|
|
79
|
-
-webkit-border-top-right-radius: $borderRadius;
|
|
80
|
-
-moz-border-radius-bottomright: $borderRadius;
|
|
81
|
-
-moz-border-radius-topright: $borderRadius;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
&.v-pagination__list {
|
|
85
|
-
select {
|
|
86
|
-
margin-left: 5px;
|
|
87
|
-
width: auto !important;
|
|
88
|
-
font-size: 12px;
|
|
89
|
-
padding: 0;
|
|
90
|
-
display: inline-block;
|
|
91
|
-
border: 1px solid #ccc;
|
|
92
|
-
color: #333;
|
|
93
|
-
outline: 0;
|
|
94
|
-
|
|
95
|
-
&:hover {
|
|
96
|
-
-webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
|
|
97
|
-
-moz-box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
|
|
98
|
-
box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
&[disabled] { color: #999; }
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
&.v-pagination--no-border {
|
|
108
|
-
& > ul {
|
|
109
|
-
box-shadow: none;
|
|
110
|
-
|
|
111
|
-
& > li {
|
|
112
|
-
&:not(.active):not(.disabled):not(.v-pagination__info):not(.v-pagination__list) a:hover {
|
|
113
|
-
box-shadow: none;z-index: auto;background-color: #ddd;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
&.active a { background-color: #f5f5f5;color: #aaa; }
|
|
117
|
-
|
|
118
|
-
& > a {
|
|
119
|
-
border: 0;
|
|
120
|
-
&:hover { z-index: auto; }
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
package/webpack.config.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
var path = require('path')
|
|
2
|
-
var webpack = require('webpack')
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
//entry: './src/main.js',
|
|
6
|
-
entry: './src/index.js',
|
|
7
|
-
output: {
|
|
8
|
-
path: path.resolve(__dirname, './dist'),
|
|
9
|
-
publicPath: '/dist/',
|
|
10
|
-
//filename: 'build.js'
|
|
11
|
-
filename: 'v-page.js',
|
|
12
|
-
library: 'vPage',
|
|
13
|
-
libraryTarget: 'umd',
|
|
14
|
-
umdNamedDefine: true
|
|
15
|
-
},
|
|
16
|
-
module: {
|
|
17
|
-
rules: [
|
|
18
|
-
{
|
|
19
|
-
test: /\.css$/,
|
|
20
|
-
use: [
|
|
21
|
-
'vue-style-loader',
|
|
22
|
-
'css-loader'
|
|
23
|
-
],
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
test: /\.scss$/,
|
|
27
|
-
use: [
|
|
28
|
-
'vue-style-loader',
|
|
29
|
-
'css-loader',
|
|
30
|
-
'sass-loader'
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
test: /\.sass$/,
|
|
35
|
-
use: [
|
|
36
|
-
'vue-style-loader',
|
|
37
|
-
'css-loader',
|
|
38
|
-
'sass-loader?indentedSyntax'
|
|
39
|
-
],
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
test: /\.vue$/,
|
|
43
|
-
loader: 'vue-loader',
|
|
44
|
-
options: {
|
|
45
|
-
loaders: {
|
|
46
|
-
// Since sass-loader (weirdly) has SCSS as its default parse mode, we map
|
|
47
|
-
// the "scss" and "sass" values for the lang attribute to the right configs here.
|
|
48
|
-
// other preprocessors should work out of the box, no loader config like this necessary.
|
|
49
|
-
'scss': [
|
|
50
|
-
'vue-style-loader',
|
|
51
|
-
'css-loader',
|
|
52
|
-
'sass-loader'
|
|
53
|
-
],
|
|
54
|
-
'sass': [
|
|
55
|
-
'vue-style-loader',
|
|
56
|
-
'css-loader',
|
|
57
|
-
'sass-loader?indentedSyntax'
|
|
58
|
-
]
|
|
59
|
-
}
|
|
60
|
-
// other vue-loader options go here
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
test: /\.js$/,
|
|
65
|
-
loader: 'babel-loader',
|
|
66
|
-
exclude: /node_modules/
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
test: /\.(png|jpg|gif|svg)$/,
|
|
70
|
-
loader: 'file-loader',
|
|
71
|
-
options: {
|
|
72
|
-
name: '[name].[ext]?[hash]'
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
]
|
|
76
|
-
},
|
|
77
|
-
resolve: {
|
|
78
|
-
alias: {
|
|
79
|
-
'vue$': 'vue/dist/vue.esm.js'
|
|
80
|
-
},
|
|
81
|
-
extensions: ['*', '.js', '.vue', '.json']
|
|
82
|
-
},
|
|
83
|
-
devServer: {
|
|
84
|
-
historyApiFallback: true,
|
|
85
|
-
noInfo: true,
|
|
86
|
-
overlay: true
|
|
87
|
-
},
|
|
88
|
-
performance: {
|
|
89
|
-
hints: false
|
|
90
|
-
},
|
|
91
|
-
devtool: '#eval-source-map'
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (process.env.NODE_ENV === 'production') {
|
|
95
|
-
module.exports.devtool = '#source-map'
|
|
96
|
-
// http://vue-loader.vuejs.org/en/workflow/production.html
|
|
97
|
-
module.exports.plugins = (module.exports.plugins || []).concat([
|
|
98
|
-
new webpack.DefinePlugin({
|
|
99
|
-
'process.env': {
|
|
100
|
-
NODE_ENV: '"production"'
|
|
101
|
-
}
|
|
102
|
-
}),
|
|
103
|
-
new webpack.optimize.UglifyJsPlugin({
|
|
104
|
-
sourceMap: true,
|
|
105
|
-
compress: {
|
|
106
|
-
warnings: false
|
|
107
|
-
}
|
|
108
|
-
}),
|
|
109
|
-
new webpack.LoaderOptionsPlugin({
|
|
110
|
-
minimize: true
|
|
111
|
-
})
|
|
112
|
-
])
|
|
113
|
-
}
|