v-page 3.3.0 → 3.5.0

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/package.json CHANGED
@@ -1,74 +1,95 @@
1
- {
2
- "name": "v-page",
3
- "description": "A simple pagination bar",
4
- "version": "3.3.0",
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
- "./types": {
22
- "import": {
23
- "types": "./types/index.d.ts"
24
- }
25
- }
26
- },
27
- "typings": "./types/index.d.ts",
28
- "license": "MIT",
29
- "scripts": {
30
- "dev": "vite",
31
- "build": "vite build",
32
- "preview": "vite preview --port 4173",
33
- "test:unit": "vitest",
34
- "coverage": "vitest run --coverage",
35
- "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore"
36
- },
37
- "repository": {
38
- "type": "git",
39
- "url": "git+https://github.com/TerryZ/v-page.git"
40
- },
41
- "keywords": [
42
- "front-end",
43
- "web",
44
- "vue",
45
- "vuejs",
46
- "page",
47
- "pagination"
48
- ],
49
- "peerDependencies": {
50
- "vue": "^3.4.0"
51
- },
52
- "dependencies": {
53
- "vue": "^3.5.13"
54
- },
55
- "devDependencies": {
56
- "@rushstack/eslint-patch": "^1.10.4",
57
- "@vitejs/plugin-vue": "^5.2.1",
58
- "@vitejs/plugin-vue-jsx": "^4.1.1",
59
- "@vitest/coverage-v8": "^2.1.8",
60
- "@vue/eslint-config-standard": "^8.0.1",
61
- "@vue/test-utils": "^2.4.6",
62
- "bootstrap": "^5.3.3",
63
- "eslint": "^8.50.0",
64
- "eslint-plugin-vue": "^9.32.0",
65
- "postcss": "^8.4.49",
66
- "autoprefixer": "^10.4.20",
67
- "jsdom": "^25.0.1",
68
- "sass": "^1.83.0",
69
- "typescript": "^5.7.2",
70
- "vite": "^6.0.5",
71
- "vite-plugin-css-injected-by-js": "^3.5.2",
72
- "vitest": "^2.1.8"
73
- }
74
- }
1
+ {
2
+ "name": "v-page",
3
+ "description": "A simple pagination bar",
4
+ "version": "3.5.0",
5
+ "author": "TerryZ <terry5@foxmail.com>",
6
+ "type": "module",
7
+ "files": [
8
+ "./dist"
9
+ ],
10
+ "engines": {
11
+ "node": "^20.19.0 || >=22.12.0"
12
+ },
13
+ "main": "./dist/v-page.cjs",
14
+ "module": "./dist/v-page.js",
15
+ "exports": {
16
+ ".": {
17
+ "import": {
18
+ "types": "./dist/types/index.d.ts",
19
+ "default": "./dist/v-page.js"
20
+ },
21
+ "require": "./dist/v-page.cjs"
22
+ },
23
+ "./types": {
24
+ "import": {
25
+ "types": "./dist/types/index.d.ts"
26
+ }
27
+ }
28
+ },
29
+ "typings": "./dist/types/index.d.ts",
30
+ "license": "MIT",
31
+ "packageManager": "pnpm@10.27.0",
32
+ "browserslist": [
33
+ "> 1%",
34
+ "last 2 versions",
35
+ "not dead"
36
+ ],
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/TerryZ/v-page.git"
40
+ },
41
+ "keywords": [
42
+ "front-end",
43
+ "web",
44
+ "vue",
45
+ "vuejs",
46
+ "page",
47
+ "pagination"
48
+ ],
49
+ "scripts": {
50
+ "dev": "vite",
51
+ "build": "run-p type-check \"build-only {@}\" --",
52
+ "preview": "vite preview",
53
+ "test:unit": "vitest",
54
+ "build-only": "vite build",
55
+ "type-check": "vue-tsc --build",
56
+ "lint": "eslint . --fix --cache",
57
+ "coverage": "vitest run --coverage",
58
+ "format": "prettier --write --experimental-cli src/"
59
+ },
60
+ "dependencies": {
61
+ "vue": "^3.5.16"
62
+ },
63
+ "peerDependencies": {
64
+ "vue": "^3.5.0"
65
+ },
66
+ "devDependencies": {
67
+ "@tsconfig/node24": "^24.0.3",
68
+ "@types/jsdom": "^27.0.0",
69
+ "@types/node": "^24.10.4",
70
+ "@vitejs/plugin-vue": "^6.0.3",
71
+ "@vitejs/plugin-vue-jsx": "^5.1.3",
72
+ "@vitest/eslint-plugin": "^1.6.4",
73
+ "@vitest/coverage-v8": "^4.0.16",
74
+ "@vue/eslint-config-prettier": "^10.2.0",
75
+ "@vue/eslint-config-typescript": "^14.6.0",
76
+ "@vue/test-utils": "^2.4.6",
77
+ "@vue/tsconfig": "^0.8.1",
78
+ "bootstrap": "^5.3.8",
79
+ "eslint": "^9.39.2",
80
+ "eslint-plugin-vue": "~10.6.2",
81
+ "jiti": "^2.6.1",
82
+ "jsdom": "^27.3.0",
83
+ "npm-run-all2": "^8.0.4",
84
+ "prettier": "3.7.4",
85
+ "sass": "^1.97.1",
86
+ "postcss": "^8.5.6",
87
+ "autoprefixer": "^10.4.21",
88
+ "typescript": "~5.8.3",
89
+ "vite": "^7.3.0",
90
+ "vite-plugin-css-injected-by-js": "^3.5.2",
91
+ "vite-plugin-dts": "^4.5.4",
92
+ "vitest": "^4.0.16",
93
+ "vue-tsc": "^3.2.1"
94
+ }
95
+ }
@@ -1,2 +0,0 @@
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.v-pagination--disabled a,.v-pagination.v-pagination--disabled select{color:#ddd!important}.v-pagination.v-pagination--disabled .v-pagination__item a{cursor:default!important}.v-pagination.v-pagination--disabled .v-pagination__item a:hover{background-color:transparent}.v-pagination.v-pagination--disabled.v-pagination--border ul{background-color:#fafafa}.v-pagination.v-pagination--circle .v-pagination__item a{border-radius:50rem;border:1px solid transparent;min-height:30px;min-width:30px;padding:0 .6rem;display:flex;align-items:center;justify-content:center}.v-pagination.v-pagination--circle .v-pagination__item a:hover{border:1px solid #f7f7f7}.v-pagination.v-pagination--circle .v-pagination__item.disabled a:hover{border:1px solid transparent}.v-pagination.v-pagination--circle .v-pagination__item.active a{border:1px solid #ddd!important;background-color:transparent!important;box-shadow:0 1px 3px #0000001a}.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:.5rem;display:inline-flex;align-items:center;cursor:default}.v-pagination ul li.v-pagination__list a,.v-pagination ul li.v-pagination__info a{color:#888}.v-pagination ul li.active a,.v-pagination ul li.disabled a{cursor:default!important}.v-pagination ul li.v-pagination__item a:hover{background-color:#f7f7f7;color:#000;cursor:pointer}.v-pagination ul li.active a{background-color:#eee!important;color:#aaa}.v-pagination ul li.active a:hover{color:#aaa}.v-pagination ul li.disabled a{color:#ddd!important}.v-pagination ul li.disabled a:hover{background-color:transparent}.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:.3rem}.v-pagination.v-pagination--border ul{box-shadow:0 1px 2px #0000000d;border-radius:.5rem}.v-pagination.v-pagination--border ul li a{border:1px solid #DEE2E6;border-left:0;border-radius:0}.v-pagination.v-pagination--border ul li:first-child>a{border-bottom-left-radius:.5rem;border-top-left-radius:.5rem;border-left:1px solid #DEE2E6}.v-pagination.v-pagination--border ul li:last-child>a{border-top-right-radius:.5rem;border-bottom-right-radius:.5rem}.v-pagination.v-pagination--border ul li.active a{color:#aaa;background-color:#eee}")),document.head.appendChild(i)}}catch(a){console.error("vite-plugin-css-injected-by-js",a)}})();
2
- (function(o,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(o=typeof globalThis<"u"?globalThis:o||self,e(o.VPage={},o.Vue))})(this,function(o,e){"use strict";const I=[10,20,50,100],y=0,[X,Y,F]=["left","center","right"],d=Symbol("pagination"),[T,m,v,z,j]=["cn","en","de","jp","pt"],V={[T]:{pageLength:"每页记录数",pageInfo:"第 #pageNumber#/#totalPage# 页(共#totalRow#条记录)",first:"首页",last:"尾页",all:"全部"},[m]:{pageLength:"Per page",pageInfo:"Page #pageNumber#/#totalPage# (total #totalRow# records)",first:"First",last:"Last",all:"All"},[v]:{pageLength:"Seitenlänge",pageInfo:"Aktuell #pageNumber#/#totalPage# (gesamt #totalRow# Aufzeichnungen)",first:"Zuerst",last:"Letzte",all:"Alle"},[z]:{pageLength:"ページごとの記録数",pageInfo:"現在の第 #pageNumber#/#totalPage# ページ(全部で #totalRow# 条の記録)",first:"トップページ",last:"尾のページ",all:"すべて"},[j]:{pageLength:"Resultados por página",pageInfo:"#pageNumber#/#totalPage# (total de #totalRow#)",first:"Início",last:"Fim",all:"Todos"}};function w(a,t,n){if(t<=n)return 1;const u=Math.floor(n/2),l=t-n+1,i=a-u;return i<1?1:i>l?l:i}function B(a,t,n){const u=w(a,t,n);return Array.from({length:n}).map((l,i)=>u+i).filter(l=>l>=1&&l<=t)}function O(a=m){const t=String(a).toLowerCase();return V[Object.hasOwn(V,t)?t:m]}const p=e.defineComponent({name:"PaginationBar",props:{modelValue:{type:Number,default:0},pageSize:{type:Number,default:10},totalRow:{type:Number,default:0},language:{type:String,default:m},align:{type:String,default:F},pageSizeMenu:{type:[Array],default:()=>I},disabled:{type:Boolean,default:!1},circle:{type:Boolean,default:!1},border:{type:Boolean,default:!1},displayAll:{type:Boolean,default:!1},hideOnSinglePage:{type:Boolean,default:!1}},emits:["update:modelValue","update:pageSize","change"],setup(a,{emit:t,slots:n}){const{pageSizeMenu:u,totalRow:l}=e.toRefs(a),i=e.ref(0),P=e.ref(5),r=e.ref(a.pageSize??10),f=e.computed(()=>{const g=Array.from(Array.isArray(u.value)&&u.value.length>0?u.value:I);return r.value!==0&&!g.includes(r.value)&&g.push(r.value),g.sort((s,J)=>s-J)}),c=e.computed(()=>r.value===y?1:Math.ceil(l.value/r.value)),S=e.computed(()=>B(i.value,c.value,P.value)),H=e.computed(()=>({"v-pagination":!0,"v-pagination--right":a.align==="right","v-pagination--center":a.align==="center","v-pagination--disabled":a.disabled,"v-pagination--border":a.border,"v-pagination--circle":!a.border&&a.circle})),R=e.computed(()=>i.value===1),A=e.computed(()=>i.value===c.value);e.watch(()=>a.modelValue,_),e.watch(()=>a.pageSize,E);function _(g=1){if(a.disabled||typeof g!="number")return;let s=g<1?1:g;g>c.value&&c.value>0&&(s=c.value),s!==i.value&&(i.value=s,t("update:modelValue",i.value),L())}function E(g){if(typeof g=="number"&&!(g<0)&&g!==r.value){if(r.value=g,t("update:pageSize",r.value),i.value===1)return L();_(1)}}function L(){t("change",{pageNumber:i.value,pageSize:Number(r.value),totalPage:c.value})}return e.onMounted(()=>_(a.modelValue||1)),e.provide(d,{lang:O(a.language),pageSize:r,sizeList:f,pageNumbers:S,isFirst:R,isLast:A,current:i,totalPage:c,changePageNumber:_,changePageSize:E,...e.toRefs(a)}),()=>{var s;if(a.hideOnSinglePage&&c.value<=1)return null;const g={pageNumber:i.value,pageSize:r.value,totalPage:c.value,totalRow:l.value,isFirst:R.value,isLast:A.value};return e.createVNode("div",{class:H.value},[e.createVNode("ul",null,[(s=n==null?void 0:n.default)==null?void 0:s.call(n,g)])])}}});function h(a){return typeof a=="function"||Object.prototype.toString.call(a)==="[object Object]"&&!e.isVNode(a)}function b(a,{slots:t}){var n;return e.createVNode("a",{href:"javascript:void(0)"},[(n=t==null?void 0:t.default)==null?void 0:n.call(t)])}function N({classes:a,pageNumberValue:t,name:n}){const{changePageNumber:u}=e.inject(d);return e.createVNode("li",{class:["v-pagination__item",...a]},[e.createVNode(b,{onClick:()=>u(t)},h(n)?n:{default:()=>[n]})])}function G(){const{lang:a,sizeList:t,pageSize:n,disabled:u,displayAll:l,changePageSize:i}=e.inject(d),P=()=>t.value.map(f=>e.createVNode("option",{key:f,value:f,selected:n.value===f},[f])),r=()=>l.value?e.createVNode("option",{value:y,selected:n.value===y},[a.all]):null;return e.createVNode("li",{class:"v-pagination__list"},[e.createVNode(b,null,{default:()=>[e.createVNode("span",null,[a.pageLength]),e.createVNode("select",{disabled:u.value,onChange:f=>i(Number(f.target.value))},[e.createVNode(P,null,null),e.createVNode(r,null,null)])]})])}function M(){const{lang:a,current:t,totalPage:n,totalRow:u}=e.inject(d),l=a.pageInfo.replace("#pageNumber#",t.value).replace("#totalPage#",n.value).replace("#totalRow#",u.value);return e.createVNode("li",{class:"v-pagination__info"},[e.createVNode(b,null,h(l)?l:{default:()=>[l]})])}function D(a,{slots:t}){return e.createVNode("li",{class:"v-pagination__slot"},[e.createVNode(b,null,{default:()=>{var n;return[(n=t==null?void 0:t.default)==null?void 0:n.call(t)]}})])}function U(){const{pageNumbers:a,current:t}=e.inject(d);return a.value.map(n=>e.createVNode(N,{key:n,classes:[{active:n===t.value}],pageNumberValue:n,name:n},null))}function Z(){const{isFirst:a,lang:t}=e.inject(d);return e.createVNode(N,{classes:["v-pagination__first",{disabled:a.value}],pageNumberValue:1,name:t.first},null)}function C(){const{isFirst:a,current:t}=e.inject(d);return e.createVNode(N,{classes:["v-pagination__previous",{disabled:a.value}],pageNumberValue:t.value-1,name:"«"},null)}function k(){const{isLast:a,current:t}=e.inject(d);return e.createVNode(N,{classes:["v-pagination__next",{disabled:a.value}],pageNumberValue:t.value+1,name:"»"},null)}function q(){const{isLast:a,totalPage:t,lang:n}=e.inject(d);return e.createVNode(N,{classes:["v-pagination__last",{disabled:a.value}],pageNumberValue:t.value,name:n.last},null)}p.install=(a,t={})=>{if(Object.keys(t).length){const{props:n}=p,{language:u,align:l,info:i,border:P,pageNumber:r,first:f,last:c,pageSizeMenu:S}=t;u&&(n.language.default=u),l&&(n.align.default=l),typeof i=="boolean"&&(n.info.default=i),typeof P=="boolean"&&(n.border.default=P),typeof r=="boolean"&&(n.pageNumber.default=r),typeof f=="boolean"&&(n.first.default=f),typeof c=="boolean"&&(n.last.default=c),typeof S<"u"&&(n.pageSizeMenu.default=S)}a.component(p.name,p)},o.PaginationBar=p,o.PaginationFirstPage=Z,o.PaginationInfo=M,o.PaginationLastPage=q,o.PaginationNextPage=k,o.PaginationPageNumbers=U,o.PaginationPageSizeOptions=G,o.PaginationPanel=D,o.PaginationPreviousPage=C,o.default=p,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/types/index.d.ts DELETED
@@ -1,135 +0,0 @@
1
- import {
2
- AllowedComponentProps,
3
- ComponentCustomProps,
4
- VNodeProps,
5
- VNode
6
- } from 'vue'
7
-
8
- export declare interface PageInfo {
9
- pageNumber: number
10
- pageSize: number
11
- totalPage: number
12
- }
13
-
14
- export declare interface PageSlotData {
15
- pageNumber: number
16
- pageSize: number
17
- totalPage: number
18
- totalRow: number
19
- isFirst: boolean
20
- isLast: boolean
21
- }
22
-
23
- /**
24
- * Pagination plugin for Vue
25
- */
26
- declare interface PaginationProps {
27
- /**
28
- * The number of current page
29
- */
30
- modelValue?: number
31
- /**
32
- * The number of total record
33
- */
34
- totalRow: number
35
- /**
36
- * The number of page size
37
- * @default 10
38
- */
39
- pageSize?: number
40
- /**
41
- * v-page language
42
- * @default `en`
43
- */
44
- language?: 'cn' | 'en' | 'de' | 'jp' | 'pt'
45
- /**
46
- * Page size list
47
- * @default [10, 20, 50, 100]
48
- */
49
- pageSizeMenu?: number[]
50
- /**
51
- * Alignment direction
52
- * @default `right`
53
- */
54
- align?: 'left' | 'right' | 'center'
55
- /**
56
- * Disabled the pagination
57
- * @default false
58
- */
59
- disabled?: boolean
60
- /**
61
- * Whether to display the border
62
- * @default true
63
- */
64
- border?: boolean
65
- /**
66
- * Round style page number button
67
- * @default false
68
- */
69
- circle?: boolean
70
- /**
71
- * Whether add `All` item in page length list
72
- * @default false
73
- */
74
- displayAll?: boolean
75
- /**
76
- * Hide pagination when only have one page
77
- * @default false
78
- */
79
- hideOnSinglePage?: boolean
80
- }
81
-
82
- /** Update pageNumber value */
83
- type EmitUpdateModelValue = (event: "update:modelValue", value: number) => void
84
- /** Update pageSize value */
85
- type EmitUpdatePageSize = (event: "update:pageSize", value: number) => void
86
- /** The event respond pageNumber or pageSize change */
87
- type EmitChange = (event: "change", value: PageInfo) => void
88
-
89
- type ComponentProps = AllowedComponentProps & ComponentCustomProps & VNodeProps
90
-
91
- declare interface PaginationBar {
92
- new (): {
93
- $props: ComponentProps & PaginationProps
94
- $emit: EmitUpdateModelValue & EmitUpdatePageSize & EmitChange
95
- $slots: {
96
- default?: (defaultSlotData: PageSlotData) => VNode[]
97
- }
98
- }
99
- }
100
- declare interface PaginationComponent {
101
- new (): {
102
- $props: ComponentProps
103
- }
104
- }
105
- declare interface PaginationPanel {
106
- new (): {
107
- $props: ComponentProps
108
- $slots: {
109
- default?: () => VNode[]
110
- }
111
- }
112
- }
113
- declare const PaginationBar: PaginationBar
114
- declare const PaginationPageSizeOptions: PaginationComponent
115
- declare const PaginationInfo: PaginationComponent
116
- declare const PaginationPageNumbers: PaginationComponent
117
- declare const PaginationFirstPage: PaginationComponent
118
- declare const PaginationPreviousPage: PaginationComponent
119
- declare const PaginationNextPage: PaginationComponent
120
- declare const PaginationLastPage: PaginationComponent
121
- declare const PaginationPanel: PaginationPanel
122
-
123
- export {
124
- PaginationBar,
125
- PaginationPageSizeOptions,
126
- PaginationInfo,
127
- PaginationPageNumbers,
128
- PaginationFirstPage,
129
- PaginationPreviousPage,
130
- PaginationNextPage,
131
- PaginationLastPage,
132
- PaginationPanel
133
- }
134
-
135
- export default PaginationBar