v-page 3.0.0-beta.1 → 3.0.0-beta.3

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 CHANGED
@@ -1,51 +1,54 @@
1
- # [v-page](https://terryz.github.io/vue/#/page) · [![circle ci](https://circleci.com/gh/TerryZ/v-page.svg?style=svg)](https://circleci.com/gh/TerryZ/v-page) [![code coverage](https://codecov.io/gh/TerryZ/v-page/branch/master/graph/badge.svg)](https://codecov.io/gh/TerryZ/v-page) [![npm version](https://img.shields.io/npm/v/v-page.svg)](https://www.npmjs.com/package/v-page) [![license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://mit-license.org/) [![npm download](https://img.shields.io/npm/dy/v-page.svg)](https://www.npmjs.com/package/v-page) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
1
+ # [v-page](https://terryz.github.io/vue/#/page) · [![CircleCI](https://dl.circleci.com/status-badge/img/gh/TerryZ/v-page/tree/master.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/TerryZ/v-page/tree/master) [![code coverage](https://codecov.io/gh/TerryZ/v-page/branch/master/graph/badge.svg)](https://codecov.io/gh/TerryZ/v-page) [![npm version](https://img.shields.io/npm/v/v-page.svg)](https://www.npmjs.com/package/v-page) [![license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://mit-license.org/) [![npm download](https://img.shields.io/npm/dy/v-page.svg)](https://www.npmjs.com/package/v-page) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
2
2
 
3
- A simple pagination bar, including size Menu, i18n support, based on **Vue2**
3
+ A simple pagination bar for vue3, including size Menu, i18n support
4
4
 
5
5
  <img src="https://terryz.github.io/image/v-page/v-page.png" alt="v-page" height="54px">
6
6
 
7
- ## Examples and Documentation
7
+ If you are using vue `2.x` version, please use [v-page 2.x](https://github.com/TerryZ/v-page/tree/dev-vue-2) version instead
8
8
 
9
- Live Examples on [CodePen](https://codepen.io/terry05/pen/yjZYLR), more exmaples and documentation please visit below sites
9
+ ## Examples and Documentation
10
10
 
11
- - [English site](https://terryz.github.io/vue/#/page)
12
- - [国内站点](https://terryz.gitee.io/vue/#/page)
11
+ Documentation and examples and please visit below sites
13
12
 
14
- The jQuery version: [bPage](https://github.com/TerryZ/bPage)
13
+ - [github-pages](https://terryz.github.io/docs-vue3/page/)
15
14
 
16
15
  ## Installation
17
16
 
18
- <a href="https://nodei.co/npm/v-page/"><img src="https://nodei.co/npm/v-page.png"></a>
17
+ [![https://nodei.co/npm/v-page.png?downloads=true&downloadRank=true&stars=true](https://nodei.co/npm/v-page.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/v-page)
19
18
 
20
19
  ```sh
21
- npm i -S v-page
20
+ # npm
21
+ npm i v-page
22
+ # yarn
23
+ yarn add v-page
24
+ # pnpm
25
+ pnpm add v-page
22
26
  ```
23
27
 
24
- Include and install plugin in your `main.js` file.
28
+ Include and install plugin in your `main.js` file
25
29
 
26
30
  ```js
27
31
  // add component in global scope as plugin
28
- import Vue from 'vue'
32
+ import { createApp } from 'vue'
33
+ import App from './app.vue'
29
34
  import Page from 'v-page'
30
- Vue.use(Page, {
31
- global config options
35
+
36
+ const app = createApp(App)
37
+ app.use(Page, {
38
+ // globally config options
32
39
  })
40
+ app.mount('#app')
33
41
  ```
34
42
 
35
43
  You also can use `v-page` in local component
36
44
 
37
45
  ```vue
38
46
  <template>
39
- <v-page></v-page>
47
+ <Page />
40
48
  </template>
41
49
 
42
- <script>
50
+ <script setup>
43
51
  import { Page } from 'v-page'
44
- export default {
45
- components: {
46
- 'v-page': Page
47
- }
48
- }
49
52
  </script>
50
53
  ```
51
54
 
@@ -54,24 +57,20 @@ export default {
54
57
  ```vue
55
58
  <template>
56
59
  <v-page
60
+ v-model="pageNumber"
57
61
  :total-row="totalRow"
58
- @page-change="pageChange"
59
- ></v-page>
62
+ @change="pageChange"
63
+ />
60
64
  </template>
61
65
 
62
- <script>
63
- export default {
64
- data () {
65
- return {
66
- totalRow: 100 // required option
67
- }
68
- },
69
- methods: {
70
- // receive page info change callback
71
- pageChange (pInfo) {
72
- console.log(pInfo) // { pageNumber: 1, pageSize: 10 }
73
- }
74
- }
66
+ <script setup>
67
+ import { ref } from 'vue'
68
+
69
+ const pageNumber = ref(3)
70
+ const totalRow = ref(100)
71
+ // respond for pagination change
72
+ function pageChange (data) {
73
+ console.log(pInfo) // { pageNumber: 1, pageSize: 10 }
75
74
  }
76
75
  </script>
77
76
  ```
package/dist/v-page.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(){"use strict";try{var i=document.createElement("style");i.appendChild(document.createTextNode(".v-pagination{display:flex;justify-content:flex-start;box-sizing:border-box}.v-pagination--right{justify-content:flex-end}.v-pagination--center{justify-content:center}.v-pagination ul{margin:0;padding:0;display:flex}.v-pagination ul li{list-style:none;display:flex}.v-pagination ul li a{padding:.3rem .6rem;text-decoration:none;line-height:1.3;font-size:14px;margin:0;outline:0;color:#333;border-radius:.25rem}.v-pagination ul li:not(.active):not(.disabled):not(.v-pagination__list):not(.v-pagination__info):not(.v-pagination__slot) a:hover{background-color:#fafafa}.v-pagination ul li.active a{background-color:#eee;color:#aaa}.v-pagination ul li.disabled a{color:#999;cursor:default}.v-pagination ul li select{width:auto!important;font-size:12px;padding:0;outline:0;margin:0 0 0 5px;border:1px solid #ccc;color:#333;border-radius:2px}.v-pagination ul li select:hover[disabled]{color:#999}.v-pagination.v-pagination--border ul{box-shadow:0 1px 2px #0000000d;border-radius:.25rem}.v-pagination.v-pagination--border ul li:not(:first-child) a{margin-left:-1px}.v-pagination.v-pagination--border ul li a{border:1px solid #DEE2E6;border-radius:0}.v-pagination.v-pagination--border ul li:first-child>a{border-bottom-left-radius:.25rem;border-top-left-radius:.25rem}.v-pagination.v-pagination--border ul li:last-child>a{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.v-pagination.v-pagination--border ul li.active a{color:#999;background-color:#eee}")),document.head.appendChild(i)}catch(a){console.error("vite-plugin-css-injected-by-js",a)}})();
1
+ (function(){"use strict";try{if(typeof document!="undefined"){var i=document.createElement("style");i.appendChild(document.createTextNode(".v-pagination{display:flex;justify-content:flex-start;box-sizing:border-box}.v-pagination--right{justify-content:flex-end}.v-pagination--center{justify-content:center}.v-pagination ul{margin:0;padding:0;display:flex}.v-pagination ul li{list-style:none;display:flex}.v-pagination ul li a{padding:.3rem .6rem;text-decoration:none;pointer-events:none;line-height:1.3;font-size:14px;margin:0;outline:0;color:#333;border-radius:.25rem}.v-pagination ul li:not(.active):not(.disabled):not(.v-pagination__list):not(.v-pagination__info):not(.v-pagination__slot) a:hover{background-color:#fafafa}.v-pagination ul li.active a{background-color:#eee;color:#aaa}.v-pagination ul li.disabled a{color:#999;cursor:default}.v-pagination ul li select{width:auto!important;font-size:12px;padding:0;outline:0;margin:0 0 0 5px;border:1px solid #ccc;color:#333;border-radius:2px}.v-pagination ul li select:hover[disabled]{color:#999}.v-pagination.v-pagination--border ul{box-shadow:0 1px 2px #0000000d;border-radius:.25rem}.v-pagination.v-pagination--border ul li:not(:first-child) a{margin-left:-1px}.v-pagination.v-pagination--border ul li a{border:1px solid #DEE2E6;border-radius:0}.v-pagination.v-pagination--border ul li:first-child>a{border-bottom-left-radius:.25rem;border-top-left-radius:.25rem}.v-pagination.v-pagination--border ul li:last-child>a{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.v-pagination.v-pagination--border ul li.active a{color:#999;background-color:#eee}")),document.head.appendChild(i)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
2
2
  import { defineComponent as F, toRefs as j, ref as P, computed as c, watch as k, onMounted as O, h as u } from "vue";
3
3
  const [
4
4
  z,
@@ -8,45 +8,45 @@ const [
8
8
  Z
9
9
  ] = ["cn", "en", "de", "jp", "pt"], I = {
10
10
  [z]: {
11
- pageLength: "\u6BCF\u9875\u8BB0\u5F55\u6570 ",
12
- pageInfo: "\u5F53\u524D\u663E\u793A\u7B2C #pageNumber# / #totalPage# \u9875\uFF08\u5171#totalRow#\u6761\u8BB0\u5F55\uFF09",
13
- first: "\u9996\u9875",
14
- previous: "\xAB",
15
- next: "\xBB",
16
- last: "\u5C3E\u9875",
17
- all: "\u5168\u90E8"
11
+ pageLength: "每页记录数 ",
12
+ pageInfo: "当前显示第 #pageNumber# / #totalPage# 页(共#totalRow#条记录)",
13
+ first: "首页",
14
+ previous: "«",
15
+ next: "»",
16
+ last: "尾页",
17
+ all: "全部"
18
18
  },
19
19
  [T]: {
20
20
  pageLength: "Page length ",
21
21
  pageInfo: "Current #pageNumber# / #totalPage# (total #totalRow# records)",
22
22
  first: "First",
23
- previous: "\xAB",
24
- next: "\xBB",
23
+ previous: "«",
24
+ next: "»",
25
25
  last: "Last",
26
26
  all: "All"
27
27
  },
28
28
  [D]: {
29
- pageLength: "Seitenl\xE4nge ",
29
+ pageLength: "Seitenlänge ",
30
30
  pageInfo: "Aktuell #pageNumber# / #totalPage# (gesamt #totalRow# Aufzeichnungen)",
31
31
  first: "Zuerst",
32
- previous: "\xAB",
33
- next: "\xBB",
32
+ previous: "«",
33
+ next: "»",
34
34
  last: "Letzte",
35
35
  all: "Alle"
36
36
  },
37
37
  [G]: {
38
- pageLength: "\u30DA\u30FC\u30B8\u3054\u3068\u306E\u8A18\u9332\u6570",
39
- pageInfo: "\u73FE\u5728\u306E\u7B2C #pageNumber# / #totalPage# \u30DA\u30FC\u30B8\uFF08\u5168\u90E8\u3067 #totalRow# \u6761\u306E\u8A18\u9332\uFF09",
40
- first: "\u30C8\u30C3\u30D7\u30DA\u30FC\u30B8",
41
- previous: "\xAB",
42
- next: "\xBB",
43
- last: "\u5C3E\u306E\u30DA\u30FC\u30B8",
44
- all: "\u3059\u3079\u3066"
38
+ pageLength: "ページごとの記録数",
39
+ pageInfo: "現在の第 #pageNumber# / #totalPage# ページ(全部で #totalRow# 条の記録)",
40
+ first: "トップページ",
41
+ previous: "«",
42
+ next: "»",
43
+ last: "尾のページ",
44
+ all: "すべて"
45
45
  },
46
46
  [Z]: {
47
- pageLength: "Resultados por p\xE1gina ",
47
+ pageLength: "Resultados por página ",
48
48
  pageInfo: "#pageNumber# / #totalPage# (total de #totalRow#)",
49
- first: "In\xEDcio",
49
+ first: "Início",
50
50
  previous: "<",
51
51
  next: ">",
52
52
  last: "Fim",
@@ -69,17 +69,29 @@ const R = F({
69
69
  modelValue: { type: Number, default: 0 },
70
70
  totalRow: { type: Number, default: 0 },
71
71
  language: { type: String, default: z },
72
+ /**
73
+ * Page size list
74
+ * false: close page size list
75
+ * array: custom page sizes list
76
+ */
72
77
  pageSizeMenu: {
73
78
  type: [Boolean, Array],
74
79
  default: () => q
75
80
  },
81
+ /**
82
+ * Pagination alignment direction
83
+ * `left`, `center` and `right`(default)
84
+ */
76
85
  align: { type: String, default: "right" },
77
86
  disabled: { type: Boolean, default: !1 },
78
87
  border: { type: Boolean, default: !1 },
79
88
  info: { type: Boolean, default: !0 },
80
89
  pageNumber: { type: Boolean, default: !0 },
90
+ /** first page button */
81
91
  first: { type: Boolean, default: !0 },
92
+ /** last page button */
82
93
  last: { type: Boolean, default: !0 },
94
+ /** display all records */
83
95
  displayAll: { type: Boolean, default: !1 }
84
96
  },
85
97
  emits: ["update:modelValue", "change"],
@@ -1,2 +1,2 @@
1
- (function(){"use strict";try{var i=document.createElement("style");i.appendChild(document.createTextNode(".v-pagination{display:flex;justify-content:flex-start;box-sizing:border-box}.v-pagination--right{justify-content:flex-end}.v-pagination--center{justify-content:center}.v-pagination ul{margin:0;padding:0;display:flex}.v-pagination ul li{list-style:none;display:flex}.v-pagination ul li a{padding:.3rem .6rem;text-decoration:none;line-height:1.3;font-size:14px;margin:0;outline:0;color:#333;border-radius:.25rem}.v-pagination ul li:not(.active):not(.disabled):not(.v-pagination__list):not(.v-pagination__info):not(.v-pagination__slot) a:hover{background-color:#fafafa}.v-pagination ul li.active a{background-color:#eee;color:#aaa}.v-pagination ul li.disabled a{color:#999;cursor:default}.v-pagination ul li select{width:auto!important;font-size:12px;padding:0;outline:0;margin:0 0 0 5px;border:1px solid #ccc;color:#333;border-radius:2px}.v-pagination ul li select:hover[disabled]{color:#999}.v-pagination.v-pagination--border ul{box-shadow:0 1px 2px #0000000d;border-radius:.25rem}.v-pagination.v-pagination--border ul li:not(:first-child) a{margin-left:-1px}.v-pagination.v-pagination--border ul li a{border:1px solid #DEE2E6;border-radius:0}.v-pagination.v-pagination--border ul li:first-child>a{border-bottom-left-radius:.25rem;border-top-left-radius:.25rem}.v-pagination.v-pagination--border ul li:last-child>a{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.v-pagination.v-pagination--border ul li.active a{color:#999;background-color:#eee}")),document.head.appendChild(i)}catch(a){console.error("vite-plugin-css-injected-by-js",a)}})();
2
- (function(p,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(p=typeof globalThis<"u"?globalThis:p||self,e(p.VPage={},p.Vue))})(this,function(p,e){"use strict";const Z="",[R,x,B,V,T]=["cn","en","de","jp","pt"],z={[R]:{pageLength:"\u6BCF\u9875\u8BB0\u5F55\u6570 ",pageInfo:"\u5F53\u524D\u663E\u793A\u7B2C #pageNumber# / #totalPage# \u9875\uFF08\u5171#totalRow#\u6761\u8BB0\u5F55\uFF09",first:"\u9996\u9875",previous:"\xAB",next:"\xBB",last:"\u5C3E\u9875",all:"\u5168\u90E8"},[x]:{pageLength:"Page length ",pageInfo:"Current #pageNumber# / #totalPage# (total #totalRow# records)",first:"First",previous:"\xAB",next:"\xBB",last:"Last",all:"All"},[B]:{pageLength:"Seitenl\xE4nge ",pageInfo:"Aktuell #pageNumber# / #totalPage# (gesamt #totalRow# Aufzeichnungen)",first:"Zuerst",previous:"\xAB",next:"\xBB",last:"Letzte",all:"Alle"},[V]:{pageLength:"\u30DA\u30FC\u30B8\u3054\u3068\u306E\u8A18\u9332\u6570",pageInfo:"\u73FE\u5728\u306E\u7B2C #pageNumber# / #totalPage# \u30DA\u30FC\u30B8\uFF08\u5168\u90E8\u3067 #totalRow# \u6761\u306E\u8A18\u9332\uFF09",first:"\u30C8\u30C3\u30D7\u30DA\u30FC\u30B8",previous:"\xAB",next:"\xBB",last:"\u5C3E\u306E\u30DA\u30FC\u30B8",all:"\u3059\u3079\u3066"},[T]:{pageLength:"Resultados por p\xE1gina ",pageInfo:"#pageNumber# / #totalPage# (total de #totalRow#)",first:"In\xEDcio",previous:"<",next:">",last:"Fim",all:"Todos"}},s=1,j=5,C=10,E=[C,20,50,100],w=0;function F(a,r,l){if(r<=l)return s;const c=Math.floor(l/2),o=r-l+1,i=a-c;return i<s?s:i>o?o:i}function O(a,r,l){const c=F(a,r,l);return Array.from({length:l}).map((o,i)=>c+i).filter(o=>o>=s&&o<=r)}const h=e.defineComponent({name:"VPage",props:{modelValue:{type:Number,default:0},totalRow:{type:Number,default:0},language:{type:String,default:R},pageSizeMenu:{type:[Boolean,Array],default:()=>E},align:{type:String,default:"right"},disabled:{type:Boolean,default:!1},border:{type:Boolean,default:!1},info:{type:Boolean,default:!0},pageNumber:{type:Boolean,default:!0},first:{type:Boolean,default:!0},last:{type:Boolean,default:!0},displayAll:{type:Boolean,default:!1}},emits:["update:modelValue","change"],setup(a,{emit:r,slots:l,expose:c}){const{pageSizeMenu:o,totalRow:i}=e.toRefs(a),n=e.ref(0),f=e.ref(o.value===!1?C:o.value[0]),_=e.ref(j),g=e.ref(z[a.language]||z[R]),b=e.ref(-1),d=e.computed(()=>f.value===w?s:Math.ceil(i.value/f.value)),I=e.computed(()=>O(n.value,d.value,_.value)),k=e.computed(()=>g.value.pageInfo.replace("#pageNumber#",n.value).replace("#totalPage#",d.value).replace("#totalRow#",i.value)),D=e.computed(()=>({"v-pagination":!0,"v-pagination--border":a.border,"v-pagination--right":a.align==="right","v-pagination--center":a.align==="center","v-pagination--disabled":a.disabled})),A=e.computed(()=>n.value===s),L=e.computed(()=>n.value===d.value);e.watch(()=>a.modelValue,t=>{typeof t=="number"&&t>0&&m(t,!1)});function m(t=s,P=!0){if(a.disabled||typeof t!="number")return;let v=t<s?s:t;t>d.value&&d.value>0&&(v=d.value),!(v===n.value&&f.value===b.value)&&(n.value=v,P&&r("update:modelValue",n.value),b.value=f.value,M())}function M(){r("change",{pageNumber:n.value,pageSize:Number(f.value)})}function y(t,P,v){const u={href:"javascript:void(0)",onClick:()=>m(P)};return e.h("li",{class:t},[e.h("a",u,v)])}return e.onMounted(()=>{m(a.modelValue||s)}),c({current:n,totalPage:d,pageNumbers:I,goPage:m,reload:M}),()=>{const t=[];if(Array.isArray(o.value)&&o.value.length){const u={disabled:a.disabled,onChange:S=>{f.value=Number(S.target.value),m()}},N=o.value.map(S=>e.h("option",{value:S},S));a.displayAll&&N.push(e.h("option",{value:w},g.value.all));const G=e.h("li",{class:"v-pagination__list"},[e.h("a",[e.h("span",g.value.pageLength),e.h("select",u,N)])]);t.push(G)}if(a.info&&t.push(e.h("li",{class:"v-pagination__info"},[e.h("a",k.value)])),"default"in l){const u=e.h("li",{class:"v-pagination__slot"},[e.h("a",l.default({pageNumber:n.value,pageSize:f.value,totalPage:d.value,totalRow:i.value,isFirst:A.value,isLast:L.value}))]);t.push(u)}if(a.first){const u=["v-pagination__first",{disabled:A.value}];t.push(y(u,s,g.value.first))}const P=["v-pagination__previous",{disabled:A.value}];t.push(y(P,n.value-1,g.value.previous)),a.pageNumber&&t.push(...I.value.map(u=>{const N={active:u===n.value};return y(N,u,u)}));const v=["v-pagination__next",{disabled:L.value}];if(t.push(y(v,n.value+1,g.value.next)),a.last){const u=["v-pagination__last",{disabled:L.value}];t.push(y(u,d.value,g.value.last))}return e.h("div",{class:D.value},[e.h("ul",t)])}}});h.install=(a,r={})=>{if(Object.keys(r).length){const{props:l}=h,{language:c,align:o,info:i,border:n,pageNumber:f,first:_,last:g,pageSizeMenu:b}=r;c&&(l.language.default=c),o&&(l.align.default=o),typeof i=="boolean"&&(l.info.default=i),typeof n=="boolean"&&(l.border.default=n),typeof f=="boolean"&&(l.pageNumber.default=f),typeof _=="boolean"&&(l.first.default=_),typeof g=="boolean"&&(l.last.default=g),typeof b<"u"&&(l.pageSizeMenu.default=b)}a.component(h.name,h)},p.Page=h,p.default=h,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(){"use strict";try{if(typeof document!="undefined"){var i=document.createElement("style");i.appendChild(document.createTextNode(".v-pagination{display:flex;justify-content:flex-start;box-sizing:border-box}.v-pagination--right{justify-content:flex-end}.v-pagination--center{justify-content:center}.v-pagination ul{margin:0;padding:0;display:flex}.v-pagination ul li{list-style:none;display:flex}.v-pagination ul li a{padding:.3rem .6rem;text-decoration:none;pointer-events:none;line-height:1.3;font-size:14px;margin:0;outline:0;color:#333;border-radius:.25rem}.v-pagination ul li:not(.active):not(.disabled):not(.v-pagination__list):not(.v-pagination__info):not(.v-pagination__slot) a:hover{background-color:#fafafa}.v-pagination ul li.active a{background-color:#eee;color:#aaa}.v-pagination ul li.disabled a{color:#999;cursor:default}.v-pagination ul li select{width:auto!important;font-size:12px;padding:0;outline:0;margin:0 0 0 5px;border:1px solid #ccc;color:#333;border-radius:2px}.v-pagination ul li select:hover[disabled]{color:#999}.v-pagination.v-pagination--border ul{box-shadow:0 1px 2px #0000000d;border-radius:.25rem}.v-pagination.v-pagination--border ul li:not(:first-child) a{margin-left:-1px}.v-pagination.v-pagination--border ul li a{border:1px solid #DEE2E6;border-radius:0}.v-pagination.v-pagination--border ul li:first-child>a{border-bottom-left-radius:.25rem;border-top-left-radius:.25rem}.v-pagination.v-pagination--border ul li:last-child>a{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.v-pagination.v-pagination--border ul li.active a{color:#999;background-color:#eee}")),document.head.appendChild(i)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
2
+ (function(p,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(p=typeof globalThis<"u"?globalThis:p||self,e(p.VPage={},p.Vue))})(this,function(p,e){"use strict";const Z="",[R,x,B,V,T]=["cn","en","de","jp","pt"],z={[R]:{pageLength:"每页记录数 ",pageInfo:"当前显示第 #pageNumber# / #totalPage# 页(共#totalRow#条记录)",first:"首页",previous:"«",next:"»",last:"尾页",all:"全部"},[x]:{pageLength:"Page length ",pageInfo:"Current #pageNumber# / #totalPage# (total #totalRow# records)",first:"First",previous:"«",next:"»",last:"Last",all:"All"},[B]:{pageLength:"Seitenlänge ",pageInfo:"Aktuell #pageNumber# / #totalPage# (gesamt #totalRow# Aufzeichnungen)",first:"Zuerst",previous:"«",next:"»",last:"Letzte",all:"Alle"},[V]:{pageLength:"ページごとの記録数",pageInfo:"現在の第 #pageNumber# / #totalPage# ページ(全部で #totalRow# 条の記録)",first:"トップページ",previous:"«",next:"»",last:"尾のページ",all:"すべて"},[T]:{pageLength:"Resultados por página ",pageInfo:"#pageNumber# / #totalPage# (total de #totalRow#)",first:"Início",previous:"<",next:">",last:"Fim",all:"Todos"}},s=1,j=5,C=10,E=[C,20,50,100],w=0;function F(a,r,l){if(r<=l)return s;const c=Math.floor(l/2),o=r-l+1,i=a-c;return i<s?s:i>o?o:i}function O(a,r,l){const c=F(a,r,l);return Array.from({length:l}).map((o,i)=>c+i).filter(o=>o>=s&&o<=r)}const h=e.defineComponent({name:"VPage",props:{modelValue:{type:Number,default:0},totalRow:{type:Number,default:0},language:{type:String,default:R},pageSizeMenu:{type:[Boolean,Array],default:()=>E},align:{type:String,default:"right"},disabled:{type:Boolean,default:!1},border:{type:Boolean,default:!1},info:{type:Boolean,default:!0},pageNumber:{type:Boolean,default:!0},first:{type:Boolean,default:!0},last:{type:Boolean,default:!0},displayAll:{type:Boolean,default:!1}},emits:["update:modelValue","change"],setup(a,{emit:r,slots:l,expose:c}){const{pageSizeMenu:o,totalRow:i}=e.toRefs(a),n=e.ref(0),f=e.ref(o.value===!1?C:o.value[0]),_=e.ref(j),g=e.ref(z[a.language]||z[R]),b=e.ref(-1),d=e.computed(()=>f.value===w?s:Math.ceil(i.value/f.value)),I=e.computed(()=>O(n.value,d.value,_.value)),k=e.computed(()=>g.value.pageInfo.replace("#pageNumber#",n.value).replace("#totalPage#",d.value).replace("#totalRow#",i.value)),D=e.computed(()=>({"v-pagination":!0,"v-pagination--border":a.border,"v-pagination--right":a.align==="right","v-pagination--center":a.align==="center","v-pagination--disabled":a.disabled})),A=e.computed(()=>n.value===s),L=e.computed(()=>n.value===d.value);e.watch(()=>a.modelValue,t=>{typeof t=="number"&&t>0&&m(t,!1)});function m(t=s,P=!0){if(a.disabled||typeof t!="number")return;let v=t<s?s:t;t>d.value&&d.value>0&&(v=d.value),!(v===n.value&&f.value===b.value)&&(n.value=v,P&&r("update:modelValue",n.value),b.value=f.value,M())}function M(){r("change",{pageNumber:n.value,pageSize:Number(f.value)})}function y(t,P,v){const u={href:"javascript:void(0)",onClick:()=>m(P)};return e.h("li",{class:t},[e.h("a",u,v)])}return e.onMounted(()=>{m(a.modelValue||s)}),c({current:n,totalPage:d,pageNumbers:I,goPage:m,reload:M}),()=>{const t=[];if(Array.isArray(o.value)&&o.value.length){const u={disabled:a.disabled,onChange:S=>{f.value=Number(S.target.value),m()}},N=o.value.map(S=>e.h("option",{value:S},S));a.displayAll&&N.push(e.h("option",{value:w},g.value.all));const G=e.h("li",{class:"v-pagination__list"},[e.h("a",[e.h("span",g.value.pageLength),e.h("select",u,N)])]);t.push(G)}if(a.info&&t.push(e.h("li",{class:"v-pagination__info"},[e.h("a",k.value)])),"default"in l){const u=e.h("li",{class:"v-pagination__slot"},[e.h("a",l.default({pageNumber:n.value,pageSize:f.value,totalPage:d.value,totalRow:i.value,isFirst:A.value,isLast:L.value}))]);t.push(u)}if(a.first){const u=["v-pagination__first",{disabled:A.value}];t.push(y(u,s,g.value.first))}const P=["v-pagination__previous",{disabled:A.value}];t.push(y(P,n.value-1,g.value.previous)),a.pageNumber&&t.push(...I.value.map(u=>{const N={active:u===n.value};return y(N,u,u)}));const v=["v-pagination__next",{disabled:L.value}];if(t.push(y(v,n.value+1,g.value.next)),a.last){const u=["v-pagination__last",{disabled:L.value}];t.push(y(u,d.value,g.value.last))}return e.h("div",{class:D.value},[e.h("ul",t)])}}});h.install=(a,r={})=>{if(Object.keys(r).length){const{props:l}=h,{language:c,align:o,info:i,border:n,pageNumber:f,first:_,last:g,pageSizeMenu:b}=r;c&&(l.language.default=c),o&&(l.align.default=o),typeof i=="boolean"&&(l.info.default=i),typeof n=="boolean"&&(l.border.default=n),typeof f=="boolean"&&(l.pageNumber.default=f),typeof _=="boolean"&&(l.first.default=_),typeof g=="boolean"&&(l.last.default=g),typeof b<"u"&&(l.pageSizeMenu.default=b)}a.component(h.name,h)},p.Page=h,p.default=h,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,66 +1,68 @@
1
- {
2
- "name": "v-page",
3
- "description": "A simple pagination bar",
4
- "version": "3.0.0-beta.1",
5
- "author": "TerryZ <terry5@foxmail.com>",
6
- "type": "module",
7
- "files": [
8
- "/dist",
9
- "/types"
10
- ],
11
- "main": "./dist/v-page.umd.cjs",
12
- "module": "./dist/v-page.js",
13
- "exports": {
14
- ".": {
15
- "import": "./dist/v-page.js",
16
- "require": "./dist/v-page.umd.cjs"
17
- }
18
- },
19
- "typings": "types/index.d.ts",
20
- "license": "MIT",
21
-
22
- "scripts": {
23
- "dev": "vite",
24
- "build": "vite build",
25
- "preview": "vite preview --port 4173",
26
- "test:unit": "vitest",
27
- "coverage": "vitest run --coverage",
28
- "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore"
29
- },
30
- "repository": {
31
- "type": "git",
32
- "url": "https://github.com/TerryZ/v-page.git"
33
- },
34
- "keywords": [
35
- "front-end",
36
- "web",
37
- "vue",
38
- "vuejs",
39
- "page",
40
- "pagination"
41
- ],
42
- "peerDependencies": {
43
- "vue": "^3.2.0"
44
- },
45
- "dependencies": {
46
- "vue": "^3.2.37"
47
- },
48
- "devDependencies": {
49
- "@rushstack/eslint-patch": "^1.1.4",
50
- "@vitejs/plugin-vue": "^3.0.3",
51
- "@vitejs/plugin-vue-jsx": "^2.0.0",
52
- "@vue/eslint-config-standard": "^8.0.1",
53
- "@vue/test-utils": "^2.0.2",
54
- "bootstrap": "^5.2.0",
55
- "c8": "^7.12.0",
56
- "eslint": "^8.21.0",
57
- "eslint-plugin-vue": "^9.3.0",
58
- "jsdom": "^20.0.0",
59
- "sass": "^1.54.5",
60
- "sass-loader": "^13.0.2",
61
- "typescript": "^4.7.4",
62
- "vite": "^3.0.9",
63
- "vite-plugin-css-injected-by-js": "^2.0.3",
64
- "vitest": "^0.21.0"
65
- }
66
- }
1
+ {
2
+ "name": "v-page",
3
+ "description": "A simple pagination bar",
4
+ "version": "3.0.0-beta.3",
5
+ "author": "TerryZ <terry5@foxmail.com>",
6
+ "type": "module",
7
+ "files": [
8
+ "./dist",
9
+ "./types"
10
+ ],
11
+ "main": "./dist/v-page.umd.cjs",
12
+ "module": "./dist/v-page.js",
13
+ "exports": {
14
+ ".": {
15
+ "import": {
16
+ "types": "./types/index.d.ts",
17
+ "default": "./dist/v-page.js"
18
+ },
19
+ "require": "./dist/v-page.umd.cjs"
20
+ }
21
+ },
22
+ "typings": "./types/index.d.ts",
23
+ "license": "MIT",
24
+ "scripts": {
25
+ "dev": "vite",
26
+ "build": "vite build",
27
+ "preview": "vite preview --port 4173",
28
+ "test:unit": "vitest",
29
+ "coverage": "vitest run --coverage",
30
+ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/TerryZ/v-page.git"
35
+ },
36
+ "keywords": [
37
+ "front-end",
38
+ "web",
39
+ "vue",
40
+ "vuejs",
41
+ "page",
42
+ "pagination"
43
+ ],
44
+ "peerDependencies": {
45
+ "vue": "^3.2.0"
46
+ },
47
+ "dependencies": {
48
+ "vue": "^3.2.45"
49
+ },
50
+ "devDependencies": {
51
+ "@rushstack/eslint-patch": "^1.2.0",
52
+ "@vitejs/plugin-vue": "^4.0.0",
53
+ "@vitejs/plugin-vue-jsx": "^3.0.0",
54
+ "@vue/eslint-config-standard": "^8.0.1",
55
+ "@vue/test-utils": "^2.2.7",
56
+ "bootstrap": "^5.2.3",
57
+ "c8": "^7.12.0",
58
+ "eslint": "^8.32.0",
59
+ "eslint-plugin-vue": "^9.9.0",
60
+ "jsdom": "^21.1.0",
61
+ "sass": "^1.57.1",
62
+ "sass-loader": "^13.2.0",
63
+ "typescript": "^4.9.4",
64
+ "vite": "^4.0.4",
65
+ "vite-plugin-css-injected-by-js": "^2.4.0",
66
+ "vitest": "^0.28.2"
67
+ }
68
+ }