v-page 3.0.0-beta.2 → 3.0.0-beta.4

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
@@ -8,18 +8,21 @@ If you are using vue `2.x` version, please use [v-page 2.x](https://github.com/T
8
8
 
9
9
  ## Examples and Documentation
10
10
 
11
- Examples and documentation please visit below sites
11
+ Documentation and examples and please visit below sites
12
12
 
13
- - [github pages for english](https://terryz.github.io/vue/#/page)
14
-
15
- The jQuery version: [bPage](https://github.com/TerryZ/bPage)
13
+ - [github-pages](https://terryz.github.io/docs-vue3/page/)
16
14
 
17
15
  ## Installation
18
16
 
19
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)
20
18
 
21
19
  ```sh
22
- 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
23
26
  ```
24
27
 
25
28
  Include and install plugin in your `main.js` file
@@ -41,7 +44,7 @@ You also can use `v-page` in local component
41
44
 
42
45
  ```vue
43
46
  <template>
44
- <page />
47
+ <Page />
45
48
  </template>
46
49
 
47
50
  <script setup>
package/dist/v-page.js CHANGED
@@ -1,4 +1,4 @@
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;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)}})();
1
+ (function(){"use strict";try{if(typeof document<"u"){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,
@@ -1,2 +1,2 @@
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;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)}})();
1
+ (function(){"use strict";try{if(typeof document<"u"){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
  (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,22 +1,25 @@
1
1
  {
2
2
  "name": "v-page",
3
3
  "description": "A simple pagination bar",
4
- "version": "3.0.0-beta.2",
4
+ "version": "3.0.0-beta.4",
5
5
  "author": "TerryZ <terry5@foxmail.com>",
6
6
  "type": "module",
7
7
  "files": [
8
- "/dist",
9
- "/types"
8
+ "./dist",
9
+ "./types"
10
10
  ],
11
11
  "main": "./dist/v-page.umd.cjs",
12
12
  "module": "./dist/v-page.js",
13
13
  "exports": {
14
14
  ".": {
15
- "import": "./dist/v-page.js",
15
+ "import": {
16
+ "types": "./types/index.d.ts",
17
+ "default": "./dist/v-page.js"
18
+ },
16
19
  "require": "./dist/v-page.umd.cjs"
17
20
  }
18
21
  },
19
- "typings": "types/index.d.ts",
22
+ "typings": "./types/index.d.ts",
20
23
  "license": "MIT",
21
24
  "scripts": {
22
25
  "dev": "vite",
@@ -42,24 +45,24 @@
42
45
  "vue": "^3.2.0"
43
46
  },
44
47
  "dependencies": {
45
- "vue": "^3.2.45"
48
+ "vue": "^3.3.4"
46
49
  },
47
50
  "devDependencies": {
48
- "@rushstack/eslint-patch": "^1.2.0",
49
- "@vitejs/plugin-vue": "^4.0.0",
50
- "@vitejs/plugin-vue-jsx": "^3.0.0",
51
+ "@rushstack/eslint-patch": "^1.3.3",
52
+ "@vitejs/plugin-vue": "^4.3.4",
53
+ "@vitejs/plugin-vue-jsx": "^3.0.2",
51
54
  "@vue/eslint-config-standard": "^8.0.1",
52
- "@vue/test-utils": "^2.2.7",
53
- "bootstrap": "^5.2.3",
54
- "c8": "^7.12.0",
55
- "eslint": "^8.32.0",
56
- "eslint-plugin-vue": "^9.9.0",
57
- "jsdom": "^21.1.0",
58
- "sass": "^1.57.1",
59
- "sass-loader": "^13.2.0",
60
- "typescript": "^4.9.4",
61
- "vite": "^4.0.4",
62
- "vite-plugin-css-injected-by-js": "^2.4.0",
63
- "vitest": "^0.28.2"
55
+ "@vue/test-utils": "^2.4.1",
56
+ "bootstrap": "^5.3.1",
57
+ "c8": "^8.0.1",
58
+ "eslint": "^8.49.0",
59
+ "eslint-plugin-vue": "^9.17.0",
60
+ "jsdom": "^22.1.0",
61
+ "sass": "^1.66.1",
62
+ "sass-loader": "^13.3.2",
63
+ "typescript": "^5.2.2",
64
+ "vite": "^4.4.9",
65
+ "vite-plugin-css-injected-by-js": "^3.3.0",
66
+ "vitest": "^0.34.4"
64
67
  }
65
68
  }
package/types/index.d.ts CHANGED
@@ -1,65 +1,103 @@
1
- import { DefineComponent, ComputedOptions, MethodOptions, ComponentOptionsMixin } from 'vue'
1
+ import {
2
+ DefineComponent,
3
+ ComputedOptions,
4
+ MethodOptions,
5
+ ComponentOptionsMixin,
6
+ ObjectEmitsOptions,
7
+ SlotsType
8
+ } from 'vue'
9
+
10
+ export declare interface PageInfo {
11
+ pageNumber: number
12
+ pageSize: number
13
+ }
14
+
15
+ declare interface EmitEvents extends ObjectEmitsOptions {
16
+ /** Update pageNumber value */
17
+ 'update:modelValue': (pageNumber: number) => void
18
+ /** The event respond pageNumber or pageSize change */
19
+ change: (data: PageInfo) => void
20
+ }
2
21
 
3
- type EmitEvents = 'update:modelValue' | 'change'
22
+ declare interface Slots extends SlotsType {
23
+ default: {
24
+ pageNumber: number
25
+ pageSize: number
26
+ totalPage: number
27
+ totalRow: number
28
+ isFirst: boolean
29
+ isLast: boolean
30
+ }
31
+ }
4
32
 
5
33
  /**
6
34
  * Pagination plugin for Vue
7
35
  */
8
36
  declare interface Props {
9
37
  /**
10
- * the number of current page
38
+ * The number of current page
11
39
  */
12
- value: number
40
+ modelValue?: number
13
41
  /**
14
- * the number of total record
42
+ * The number of total record
15
43
  */
16
44
  totalRow: number
17
45
  /**
18
- * v-page language (default: `cn`)
46
+ * v-page language
47
+ * @default `cn`
19
48
  */
20
49
  language?: string
21
50
  /**
22
- * page size list (default: [10, 20, 50, 100])
51
+ * Page size list
52
+ * @default [10, 20, 50, 100]
23
53
  */
24
54
  pageSizeMenu?: boolean|number[]
25
55
  /**
26
- * alignment direction (default: `right`)
56
+ * Alignment direction
57
+ * @default `right`
27
58
  */
28
59
  align?: string
29
60
  /**
30
- * disabled the pagination (default: false)
61
+ * Disabled the pagination
62
+ * @default false
31
63
  */
32
64
  disabled?: boolean
33
65
  /**
34
- * whether to display the border (default: true)
66
+ * Whether to display the border
67
+ * @default true
35
68
  */
36
69
  border?: boolean
37
70
  /**
38
- * whether to display page info bar (default: true)
71
+ * Whether to display page info bar
72
+ * @default true
39
73
  */
40
74
  info?: boolean
41
75
  /**
42
- * whether to display page number buttons (default: true)
76
+ * Whether to display page number buttons
77
+ * @default true
43
78
  */
44
79
  pageNumber?: boolean
45
80
  /**
46
- * whether to display first page button (default: true)
81
+ * Whether to display first page button
82
+ * @default true
47
83
  */
48
84
  first?: boolean
49
85
  /**
50
- * whether to display last page button (default: true)
86
+ * Whether to display last page button
87
+ * @default true
51
88
  */
52
89
  last?: boolean
53
90
  /**
54
- * whether add `All` item in page length list (default: false)
91
+ * Whether add `All` item in page length list
92
+ * @default false
55
93
  */
56
94
  displayAll?: boolean
57
95
  }
58
96
 
59
97
  declare interface Methods extends MethodOptions {
60
- /** go to the specified page */
98
+ /** Go to the specified page */
61
99
  goPage: (pageNumber: number) => void
62
- /** re-emit `change` event and output pagination states data */
100
+ /** Re-emit `change` event and output pagination states data */
63
101
  reload: () => void
64
102
  }
65
103
 
@@ -71,11 +109,14 @@ declare const Page: DefineComponent<
71
109
  Methods,
72
110
  ComponentOptionsMixin,
73
111
  ComponentOptionsMixin,
74
- EmitEvents[],
75
112
  EmitEvents,
76
- Props
113
+ '',
114
+ {},
115
+ {},
116
+ {},
117
+ Slots
77
118
  >
78
119
 
79
120
  export { Page }
80
121
 
81
- export default Page
122
+ export default Page