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/LICENSE +21 -21
- package/README.md +82 -103
- package/dist/types/PaginationBar.d.ts +142 -0
- package/dist/types/PaginationCore.d.ts +9 -0
- package/dist/types/constants.d.ts +8 -0
- package/dist/types/helper.d.ts +3 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/language.d.ts +4 -0
- package/dist/types/types.d.ts +51 -0
- package/dist/v-page.cjs +2 -0
- package/dist/v-page.js +239 -245
- package/package.json +95 -74
- package/dist/v-page.umd.cjs +0 -2
- package/types/index.d.ts +0 -135
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018 Terry Zeng
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Terry Zeng
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,103 +1,82 @@
|
|
|
1
|
-
# [v-page](https://terryz.github.io/vue/#/page) · [ · [](https://github.com/TerryZ/v-page/actions/workflows/npm-publish.yml) [](https://codecov.io/gh/TerryZ/v-page) [](https://www.npmjs.com/package/v-page) [](https://mit-license.org/) [](https://www.npmjs.com/package/v-page) [](https://standardjs.com)
|
|
2
|
+
|
|
3
|
+
A simple pagination bar for vue3, including size Menu, i18n support features
|
|
4
|
+
|
|
5
|
+
<img src="./examples/snapshot.png" alt="v-page" height="80">
|
|
6
|
+
<!--  -->
|
|
7
|
+
|
|
8
|
+
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
|
|
9
|
+
|
|
10
|
+
<!-- ## Features
|
|
11
|
+
|
|
12
|
+
- Simple interface style
|
|
13
|
+
- I18n supported
|
|
14
|
+
- Modularization of Pagination bar features
|
|
15
|
+
- -->
|
|
16
|
+
|
|
17
|
+
## Examples and Documentation
|
|
18
|
+
|
|
19
|
+
Documentation and examples and please visit below sites
|
|
20
|
+
|
|
21
|
+
- [github-pages](https://terryz.github.io/docs-vue3/page/)
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
[](https://www.npmjs.com/package/v-page)
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
# npm
|
|
29
|
+
npm i v-page
|
|
30
|
+
# yarn
|
|
31
|
+
yarn add v-page
|
|
32
|
+
# pnpm
|
|
33
|
+
pnpm add v-page
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Include and install plugin in your project
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { createApp } from 'vue'
|
|
40
|
+
import App from './app.vue'
|
|
41
|
+
import PaginationPlugin from 'v-page'
|
|
42
|
+
|
|
43
|
+
const app = createApp(App)
|
|
44
|
+
// install component globally
|
|
45
|
+
app.use(PaginationPlugin, {
|
|
46
|
+
// globally config options
|
|
47
|
+
language: 'cn'
|
|
48
|
+
})
|
|
49
|
+
app.mount('#app')
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Use `v-page` as a locally component
|
|
53
|
+
|
|
54
|
+
```vue
|
|
55
|
+
<template>
|
|
56
|
+
<PaginationBar />
|
|
57
|
+
</template>
|
|
58
|
+
|
|
59
|
+
<script setup>
|
|
60
|
+
import { PaginationBar } from 'v-page'
|
|
61
|
+
</script>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Usage
|
|
65
|
+
|
|
66
|
+
```vue
|
|
67
|
+
<template>
|
|
68
|
+
<PaginationBar v-model="pageNumber" :total-row="totalRow" @change="paginationChange" />
|
|
69
|
+
</template>
|
|
70
|
+
|
|
71
|
+
<script setup lang="ts">
|
|
72
|
+
import { ref } from 'vue'
|
|
73
|
+
import { PaginationBar, type PageInfo } from 'v-page'
|
|
74
|
+
// set default page to 3
|
|
75
|
+
const pageNumber = ref<number>(3)
|
|
76
|
+
const totalRow = ref<number>(100)
|
|
77
|
+
// respond for pagination change
|
|
78
|
+
function paginationChange(data: PageInfo) {
|
|
79
|
+
console.log(data) // { pageNumber: 1, pageSize: 10, totalPage: 10 }
|
|
80
|
+
}
|
|
81
|
+
</script>
|
|
82
|
+
```
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { SlotsType, PropType } from 'vue';
|
|
2
|
+
import { LanguageKey, AlignDirection, PageInfo, PageSlotData } from './types';
|
|
3
|
+
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
4
|
+
modelValue: {
|
|
5
|
+
type: NumberConstructor;
|
|
6
|
+
default: number;
|
|
7
|
+
};
|
|
8
|
+
pageSize: {
|
|
9
|
+
type: NumberConstructor;
|
|
10
|
+
default: number;
|
|
11
|
+
};
|
|
12
|
+
totalRow: {
|
|
13
|
+
type: NumberConstructor;
|
|
14
|
+
default: number;
|
|
15
|
+
};
|
|
16
|
+
language: {
|
|
17
|
+
type: PropType<LanguageKey>;
|
|
18
|
+
default: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Pagination alignment direction
|
|
22
|
+
* `left`, `center` and `right`(default)
|
|
23
|
+
*/
|
|
24
|
+
align: {
|
|
25
|
+
type: PropType<AlignDirection>;
|
|
26
|
+
default: string;
|
|
27
|
+
};
|
|
28
|
+
/** Page size list */
|
|
29
|
+
pageSizeMenu: {
|
|
30
|
+
type: PropType<number[]>;
|
|
31
|
+
default: () => number[];
|
|
32
|
+
};
|
|
33
|
+
disabled: {
|
|
34
|
+
type: BooleanConstructor;
|
|
35
|
+
default: boolean;
|
|
36
|
+
};
|
|
37
|
+
/** Round style page number button */
|
|
38
|
+
circle: {
|
|
39
|
+
type: BooleanConstructor;
|
|
40
|
+
default: boolean;
|
|
41
|
+
};
|
|
42
|
+
border: {
|
|
43
|
+
type: BooleanConstructor;
|
|
44
|
+
default: boolean;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Display all records
|
|
48
|
+
*
|
|
49
|
+
* will add `all` option in page size list
|
|
50
|
+
* and the page size will be 0
|
|
51
|
+
*/
|
|
52
|
+
displayAll: {
|
|
53
|
+
type: BooleanConstructor;
|
|
54
|
+
default: boolean;
|
|
55
|
+
};
|
|
56
|
+
/** Hide pagination when only have one page */
|
|
57
|
+
hideOnSinglePage: {
|
|
58
|
+
type: BooleanConstructor;
|
|
59
|
+
default: boolean;
|
|
60
|
+
};
|
|
61
|
+
}>, () => import("vue/jsx-runtime").JSX.Element | null, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
62
|
+
'update:modelValue': (value: number) => boolean;
|
|
63
|
+
'update:pageSize': (value: number) => boolean;
|
|
64
|
+
change: (pageInfo: PageInfo) => boolean;
|
|
65
|
+
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
66
|
+
modelValue: {
|
|
67
|
+
type: NumberConstructor;
|
|
68
|
+
default: number;
|
|
69
|
+
};
|
|
70
|
+
pageSize: {
|
|
71
|
+
type: NumberConstructor;
|
|
72
|
+
default: number;
|
|
73
|
+
};
|
|
74
|
+
totalRow: {
|
|
75
|
+
type: NumberConstructor;
|
|
76
|
+
default: number;
|
|
77
|
+
};
|
|
78
|
+
language: {
|
|
79
|
+
type: PropType<LanguageKey>;
|
|
80
|
+
default: string;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Pagination alignment direction
|
|
84
|
+
* `left`, `center` and `right`(default)
|
|
85
|
+
*/
|
|
86
|
+
align: {
|
|
87
|
+
type: PropType<AlignDirection>;
|
|
88
|
+
default: string;
|
|
89
|
+
};
|
|
90
|
+
/** Page size list */
|
|
91
|
+
pageSizeMenu: {
|
|
92
|
+
type: PropType<number[]>;
|
|
93
|
+
default: () => number[];
|
|
94
|
+
};
|
|
95
|
+
disabled: {
|
|
96
|
+
type: BooleanConstructor;
|
|
97
|
+
default: boolean;
|
|
98
|
+
};
|
|
99
|
+
/** Round style page number button */
|
|
100
|
+
circle: {
|
|
101
|
+
type: BooleanConstructor;
|
|
102
|
+
default: boolean;
|
|
103
|
+
};
|
|
104
|
+
border: {
|
|
105
|
+
type: BooleanConstructor;
|
|
106
|
+
default: boolean;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Display all records
|
|
110
|
+
*
|
|
111
|
+
* will add `all` option in page size list
|
|
112
|
+
* and the page size will be 0
|
|
113
|
+
*/
|
|
114
|
+
displayAll: {
|
|
115
|
+
type: BooleanConstructor;
|
|
116
|
+
default: boolean;
|
|
117
|
+
};
|
|
118
|
+
/** Hide pagination when only have one page */
|
|
119
|
+
hideOnSinglePage: {
|
|
120
|
+
type: BooleanConstructor;
|
|
121
|
+
default: boolean;
|
|
122
|
+
};
|
|
123
|
+
}>> & Readonly<{
|
|
124
|
+
"onUpdate:modelValue"?: ((value: number) => any) | undefined;
|
|
125
|
+
"onUpdate:pageSize"?: ((value: number) => any) | undefined;
|
|
126
|
+
onChange?: ((pageInfo: PageInfo) => any) | undefined;
|
|
127
|
+
}>, {
|
|
128
|
+
pageSize: number;
|
|
129
|
+
disabled: boolean;
|
|
130
|
+
displayAll: boolean;
|
|
131
|
+
totalRow: number;
|
|
132
|
+
circle: boolean;
|
|
133
|
+
modelValue: number;
|
|
134
|
+
language: LanguageKey;
|
|
135
|
+
align: AlignDirection;
|
|
136
|
+
pageSizeMenu: number[];
|
|
137
|
+
border: boolean;
|
|
138
|
+
hideOnSinglePage: boolean;
|
|
139
|
+
}, SlotsType<{
|
|
140
|
+
default: PageSlotData;
|
|
141
|
+
}>, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
142
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SetupContext } from 'vue';
|
|
2
|
+
export declare function PaginationPageSizes(): import("vue/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function PaginationInfo(): import("vue/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare function PaginationPanel(props: unknown, { slots }: SetupContext): import("vue/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare function PaginationPageNumbers(): import("vue/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function PaginationFirstPage(): import("vue/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function PaginationPreviousPage(): import("vue/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function PaginationNextPage(): import("vue/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function PaginationLastPage(): import("vue/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const FIRST = 1;
|
|
2
|
+
export declare const DEFAULT_PAGE_NUMBER_SIZE = 5;
|
|
3
|
+
export declare const DEFAULT_PAGE_SIZE = 10;
|
|
4
|
+
export declare const DEFAULT_PAGE_SIZE_MENU: number[];
|
|
5
|
+
export declare const ALL_RECORD_PAGE_SIZE = 0;
|
|
6
|
+
export declare const ALIGN_LEFT: string, ALIGN_CENTER: string, ALIGN_RIGHT: string;
|
|
7
|
+
export declare const keyInternal: unique symbol;
|
|
8
|
+
export declare const keyOptions: unique symbol;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { default as PaginationBar } from './PaginationBar';
|
|
2
|
+
import { LanguageKey, PaginationGlobalOptions } from './types';
|
|
3
|
+
export * from './types';
|
|
4
|
+
export * from './PaginationCore';
|
|
5
|
+
declare const PaginationPlugin: import('vue').ObjectPlugin<[(PaginationGlobalOptions | undefined)?]>, setLanguage: (language?: LanguageKey) => void;
|
|
6
|
+
export { PaginationBar, setLanguage };
|
|
7
|
+
export default PaginationPlugin;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Ref, ComputedRef } from 'vue';
|
|
2
|
+
export type LanguageKey = 'cn' | 'en' | 'de' | 'jp' | 'pt';
|
|
3
|
+
export type AlignDirection = 'left' | 'center' | 'right';
|
|
4
|
+
export interface LanguageRecord {
|
|
5
|
+
pageLength: string;
|
|
6
|
+
pageInfo: string;
|
|
7
|
+
first: string;
|
|
8
|
+
last: string;
|
|
9
|
+
all: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PaginationGlobalOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Component language
|
|
14
|
+
*/
|
|
15
|
+
language?: LanguageKey;
|
|
16
|
+
/**
|
|
17
|
+
* Register component globally
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
register?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface LinkProps {
|
|
23
|
+
classes?: (string | Record<string, boolean>)[];
|
|
24
|
+
pageNumberValue?: number;
|
|
25
|
+
name: string | number;
|
|
26
|
+
}
|
|
27
|
+
export interface PaginationProvided {
|
|
28
|
+
lang: ComputedRef<LanguageRecord>;
|
|
29
|
+
pageSize: Ref<number>;
|
|
30
|
+
totalRow: Ref<number>;
|
|
31
|
+
displayAll: Ref<boolean>;
|
|
32
|
+
disabled: Ref<boolean>;
|
|
33
|
+
sizeList: ComputedRef<number[]>;
|
|
34
|
+
pageNumbers: ComputedRef<number[]>;
|
|
35
|
+
isFirst: ComputedRef<boolean>;
|
|
36
|
+
isLast: ComputedRef<boolean>;
|
|
37
|
+
current: Ref<number>;
|
|
38
|
+
totalPage: ComputedRef<number>;
|
|
39
|
+
changePageNumber: (pNumber: number) => void;
|
|
40
|
+
changePageSize: (val: number) => void;
|
|
41
|
+
}
|
|
42
|
+
export declare interface PageInfo {
|
|
43
|
+
pageNumber: number;
|
|
44
|
+
pageSize: number;
|
|
45
|
+
totalPage: number;
|
|
46
|
+
}
|
|
47
|
+
export declare interface PageSlotData extends PageInfo {
|
|
48
|
+
totalRow: number;
|
|
49
|
+
isFirst: boolean;
|
|
50
|
+
isLast: boolean;
|
|
51
|
+
}
|
package/dist/v-page.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
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
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),r=1,H=5,S=10,z=[S,20,50,100],y=0,[ue,oe,J]=["left","center","right"],d=Symbol("pagination-internal"),R=Symbol("pagination-options"),[K,f,Q,W,X]=["cn","en","de","jp","pt"],E={[K]:{pageLength:"每页记录数",pageInfo:"第 #pageNumber#/#totalPage# 页(共#totalRow#条记录)",first:"首页",last:"尾页",all:"全部"},[f]:{pageLength:"Per page",pageInfo:"Page #pageNumber#/#totalPage# (total #totalRow# records)",first:"First",last:"Last",all:"All"},[Q]:{pageLength:"Seitenlänge",pageInfo:"Aktuell #pageNumber#/#totalPage# (gesamt #totalRow# Aufzeichnungen)",first:"Zuerst",last:"Letzte",all:"Alle"},[W]:{pageLength:"ページごとの記録数",pageInfo:"現在の第 #pageNumber#/#totalPage# ページ(全部で #totalRow# 条の記録)",first:"トップページ",last:"尾のページ",all:"すべて"},[X]:{pageLength:"Resultados por página",pageInfo:"#pageNumber#/#totalPage# (total de #totalRow#)",first:"Início",last:"Fim",all:"Todos"}};function Y(a,t,n){if(t<=n)return r;const u=Math.floor(n/2),l=t-n+1,s=a-u;return s<r?r:s>l?l:s}function $(a,t,n){const u=Y(a,t,n);return Array.from({length:n}).map((l,s)=>u+s).filter(l=>l>=r&&l<=t)}function ee(a=f){const t=String(a).toLowerCase();return E[Object.hasOwn(E,t)?t:f]}function j(a){return typeof a=="function"||Object.prototype.toString.call(a)==="[object Object]"&&!e.isVNode(a)}function b(a,{slots:t}){return e.createVNode("a",{href:"javascript:void(0)"},[t?.default?.()])}function P({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)},j(n)?n:{default:()=>[n]})])}function F(){const{lang:a,sizeList:t,pageSize:n,disabled:u,displayAll:l,changePageSize:s}=e.inject(d),p=()=>e.createVNode(e.Fragment,null,[t.value.map(o=>e.createVNode("option",{key:o,value:o,selected:n.value===o},[o]))]),g=()=>l.value?e.createVNode("option",{value:y,selected:n.value===y},[a.value.all]):null,V=o=>{const N=o.target;s(Number(N.value))};return e.createVNode("li",{class:"v-pagination__list"},[e.createVNode(b,null,{default:()=>[e.createVNode("span",null,[a.value.pageLength]),e.createVNode("select",{disabled:u.value,onChange:V},[e.createVNode(p,null,null),e.createVNode(g,null,null)])]})])}function w(){const{lang:a,current:t,totalPage:n,totalRow:u}=e.inject(d),l=a.value.pageInfo.replace("#pageNumber#",String(t.value)).replace("#totalPage#",String(n.value)).replace("#totalRow#",String(u.value));return e.createVNode("li",{class:"v-pagination__info"},[e.createVNode(b,null,j(l)?l:{default:()=>[l]})])}function ae(a,{slots:t}){return e.createVNode("li",{class:"v-pagination__slot"},[e.createVNode(b,null,{default:()=>[t?.default?.()]})])}function O(){const{pageNumbers:a,current:t}=e.inject(d);return e.createVNode(e.Fragment,null,[a.value.map(n=>e.createVNode(P,{key:n,classes:[{active:n===t.value}],pageNumberValue:n,name:n},null))])}function B(){const{isFirst:a,lang:t}=e.inject(d);return e.createVNode(P,{classes:["v-pagination__first",{disabled:a.value}],pageNumberValue:r,name:t.value.first},null)}function M(){const{isFirst:a,current:t}=e.inject(d);return e.createVNode(P,{classes:["v-pagination__previous",{disabled:a.value}],pageNumberValue:t.value-1,name:"«"},null)}function T(){const{isLast:a,current:t}=e.inject(d);return e.createVNode(P,{classes:["v-pagination__next",{disabled:a.value}],pageNumberValue:t.value+1,name:"»"},null)}function C(){const{isLast:a,totalPage:t,lang:n}=e.inject(d);return e.createVNode(P,{classes:["v-pagination__last",{disabled:a.value}],pageNumberValue:t.value,name:n.value.last},null)}const L=e.defineComponent({name:"PaginationBar",props:{modelValue:{type:Number,default:0},pageSize:{type:Number,default:S},totalRow:{type:Number,default:0},language:{type:String,default:f},align:{type:String,default:J},pageSizeMenu:{type:[Array],default:()=>z},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":a=>typeof a=="number","update:pageSize":a=>typeof a=="number",change:a=>typeof a<"u"},slots:Object,setup(a,{emit:t,slots:n}){const{pageSizeMenu:u,totalRow:l,displayAll:s,disabled:p}=e.toRefs(a),g=e.ref(0),V=e.ref(H),o=e.ref(a.pageSize??S),N=e.inject(R,e.ref("")),k=()=>a.language!==f?a.language:N.value?N.value:f,G=e.computed(()=>ee(k())),D=e.computed(()=>{const i=Array.from(Array.isArray(u.value)&&u.value.length>0?u.value:z);return o.value!==0&&!i.includes(o.value)&&i.push(o.value),i.sort((v,q)=>v-q)}),c=e.computed(()=>o.value===y?r:Math.ceil(l.value/o.value)),x=e.computed(()=>$(g.value,c.value,V.value)),U=e.computed(()=>({"v-pagination":!0,"v-pagination--right":a.align==="right","v-pagination--center":a.align==="center","v-pagination--disabled":p.value,"v-pagination--border":a.border,"v-pagination--circle":!a.border&&a.circle})),_=e.computed(()=>g.value===r),h=e.computed(()=>g.value===c.value);e.watch(()=>a.modelValue,m),e.watch(()=>a.pageSize,A);function m(i=r){if(p.value||typeof i!="number")return;let v=i<r?r:i;i>c.value&&c.value>0&&(v=c.value),v!==g.value&&(g.value=v,t("update:modelValue",g.value),I())}function A(i){if(typeof i=="number"&&!(i<0)&&i!==o.value){if(o.value=i,t("update:pageSize",o.value),g.value===r)return I();m(r)}}function I(){t("change",{pageNumber:g.value,pageSize:Number(o.value),totalPage:c.value})}function Z(){return n.default?e.createVNode("ul",null,[n.default({pageNumber:g.value,pageSize:o.value,totalPage:c.value,totalRow:l.value,isFirst:_.value,isLast:h.value})]):e.createVNode("ul",null,[e.createVNode(F,null,null),e.createVNode(w,null,null),e.createVNode(B,null,null),e.createVNode(M,null,null),e.createVNode(O,null,null),e.createVNode(T,null,null),e.createVNode(C,null,null)])}return e.onMounted(()=>m(a.modelValue||r)),e.provide(d,{lang:G,pageSize:o,sizeList:D,pageNumbers:x,isFirst:_,isLast:h,current:g,totalPage:c,changePageNumber:m,changePageSize:A,totalRow:l,displayAll:s,disabled:p}),()=>a.hideOnSinglePage&&c.value<=1?null:e.createVNode("div",{class:U.value},[e.createVNode(Z,null,null)])}}),te=()=>{const a=e.ref(f),t={install(u,l){u.provide(R,a),l?.language&&n(l.language),l?.register&&u.component(L.name,L)}},n=u=>{a.value=u||f};return{PaginationPlugin:t,setLanguage:n}},{PaginationPlugin:ne,setLanguage:le}=te();exports.PaginationBar=L;exports.PaginationFirstPage=B;exports.PaginationInfo=w;exports.PaginationLastPage=C;exports.PaginationNextPage=T;exports.PaginationPageNumbers=O;exports.PaginationPageSizes=F;exports.PaginationPanel=ae;exports.PaginationPreviousPage=M;exports.default=ne;exports.setLanguage=le;
|