@quantabit/pagination-sdk 1.0.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 -0
- package/README.md +28 -0
- package/dist/index.cjs +217 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.esm.js +208 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/styles.css.map +1 -0
- package/package.json +68 -0
- package/types/index.d.ts +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 QuantaBit Team
|
|
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
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @quantabit/pagination-sdk
|
|
2
|
+
|
|
3
|
+
> Pagination with number mode and simple mode
|
|
4
|
+
|
|
5
|
+
## Components
|
|
6
|
+
- **Pagination** — Full number pagination with ellipsis
|
|
7
|
+
- **SimplePagination** — Prev/Next only
|
|
8
|
+
- **usePagination** — Hook with page/offset/totalPages
|
|
9
|
+
|
|
10
|
+
```jsx
|
|
11
|
+
import { Pagination, usePagination } from '@quantabit/pagination-sdk';
|
|
12
|
+
const { current, next, prev } = usePagination(100, { pageSize: 10 });
|
|
13
|
+
<Pagination current={current} total={100} onChange={goTo}/>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## License
|
|
17
|
+
MIT
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 🌐 Brand & Links
|
|
24
|
+
- Official Mainnet: [QuantaBit Chain](https://qbitchain.io/)
|
|
25
|
+
- Developer Platform: [Developer Platform](https://developer.quantabit.io/)
|
|
26
|
+
- Open Platform: [Open Platform](https://open.quantabit.io/)
|
|
27
|
+
- Payment Platform: [Pay Platform](https://pay.qbitwallet.io/)
|
|
28
|
+
- Feedback: [Feedback](https://xwin.live/qbit)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
function Pagination({
|
|
6
|
+
current = 1,
|
|
7
|
+
total,
|
|
8
|
+
pageSize = 10,
|
|
9
|
+
onChange,
|
|
10
|
+
siblingCount = 1,
|
|
11
|
+
showTotal = true,
|
|
12
|
+
className = ''
|
|
13
|
+
}) {
|
|
14
|
+
const totalPages = Math.ceil(total / pageSize);
|
|
15
|
+
if (totalPages <= 1) return null;
|
|
16
|
+
const range = (s, e) => Array.from({
|
|
17
|
+
length: e - s + 1
|
|
18
|
+
}, (_, i) => s + i);
|
|
19
|
+
const pages = (() => {
|
|
20
|
+
const left = Math.max(2, current - siblingCount);
|
|
21
|
+
const right = Math.min(totalPages - 1, current + siblingCount);
|
|
22
|
+
const items = [];
|
|
23
|
+
items.push(1);
|
|
24
|
+
if (left > 2) items.push('...');
|
|
25
|
+
items.push(...range(left, right));
|
|
26
|
+
if (right < totalPages - 1) items.push('...');
|
|
27
|
+
if (totalPages > 1) items.push(totalPages);
|
|
28
|
+
return items;
|
|
29
|
+
})();
|
|
30
|
+
const btnStyle = active => ({
|
|
31
|
+
minWidth: 32,
|
|
32
|
+
height: 32,
|
|
33
|
+
borderRadius: 8,
|
|
34
|
+
border: 'none',
|
|
35
|
+
background: active ? '#3b82f6' : 'transparent',
|
|
36
|
+
color: active ? '#fff' : '#71717a',
|
|
37
|
+
cursor: 'pointer',
|
|
38
|
+
fontSize: 13,
|
|
39
|
+
fontWeight: active ? 600 : 400,
|
|
40
|
+
transition: 'all 0.2s',
|
|
41
|
+
display: 'flex',
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
justifyContent: 'center'
|
|
44
|
+
});
|
|
45
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
46
|
+
className: `qpg-pagination ${className}`,
|
|
47
|
+
style: {
|
|
48
|
+
display: 'flex',
|
|
49
|
+
alignItems: 'center',
|
|
50
|
+
gap: 4
|
|
51
|
+
}
|
|
52
|
+
}, showTotal && /*#__PURE__*/React.createElement("span", {
|
|
53
|
+
style: {
|
|
54
|
+
fontSize: 12,
|
|
55
|
+
color: '#a1a1aa',
|
|
56
|
+
marginRight: 8
|
|
57
|
+
}
|
|
58
|
+
}, total, " items"), /*#__PURE__*/React.createElement("button", {
|
|
59
|
+
onClick: () => current > 1 && onChange?.(current - 1),
|
|
60
|
+
disabled: current === 1,
|
|
61
|
+
style: {
|
|
62
|
+
...btnStyle(false),
|
|
63
|
+
opacity: current === 1 ? 0.4 : 1
|
|
64
|
+
}
|
|
65
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
66
|
+
width: "14",
|
|
67
|
+
height: "14",
|
|
68
|
+
viewBox: "0 0 24 24",
|
|
69
|
+
fill: "none",
|
|
70
|
+
stroke: "currentColor",
|
|
71
|
+
strokeWidth: "2"
|
|
72
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
73
|
+
d: "M15 18l-6-6 6-6"
|
|
74
|
+
}))), pages.map((p, i) => p === '...' ? /*#__PURE__*/React.createElement("span", {
|
|
75
|
+
key: 'd' + i,
|
|
76
|
+
style: {
|
|
77
|
+
color: '#a1a1aa',
|
|
78
|
+
padding: '0 4px'
|
|
79
|
+
}
|
|
80
|
+
}, "\u2026") : /*#__PURE__*/React.createElement("button", {
|
|
81
|
+
key: p,
|
|
82
|
+
onClick: () => onChange?.(p),
|
|
83
|
+
style: btnStyle(p === current)
|
|
84
|
+
}, p)), /*#__PURE__*/React.createElement("button", {
|
|
85
|
+
onClick: () => current < totalPages && onChange?.(current + 1),
|
|
86
|
+
disabled: current === totalPages,
|
|
87
|
+
style: {
|
|
88
|
+
...btnStyle(false),
|
|
89
|
+
opacity: current === totalPages ? 0.4 : 1
|
|
90
|
+
}
|
|
91
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
92
|
+
width: "14",
|
|
93
|
+
height: "14",
|
|
94
|
+
viewBox: "0 0 24 24",
|
|
95
|
+
fill: "none",
|
|
96
|
+
stroke: "currentColor",
|
|
97
|
+
strokeWidth: "2"
|
|
98
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
99
|
+
d: "M9 18l6-6-6-6"
|
|
100
|
+
}))));
|
|
101
|
+
}
|
|
102
|
+
function SimplePagination({
|
|
103
|
+
current = 1,
|
|
104
|
+
totalPages = 1,
|
|
105
|
+
onChange,
|
|
106
|
+
className = ''
|
|
107
|
+
}) {
|
|
108
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
109
|
+
className: `qpg-simple ${className}`,
|
|
110
|
+
style: {
|
|
111
|
+
display: 'flex',
|
|
112
|
+
alignItems: 'center',
|
|
113
|
+
gap: 12
|
|
114
|
+
}
|
|
115
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
116
|
+
onClick: () => current > 1 && onChange?.(current - 1),
|
|
117
|
+
disabled: current === 1,
|
|
118
|
+
style: {
|
|
119
|
+
padding: '6px 14px',
|
|
120
|
+
borderRadius: 8,
|
|
121
|
+
border: '1px solid #e4e4e7',
|
|
122
|
+
background: '#fff',
|
|
123
|
+
cursor: current === 1 ? 'not-allowed' : 'pointer',
|
|
124
|
+
fontSize: 13,
|
|
125
|
+
opacity: current === 1 ? 0.4 : 1
|
|
126
|
+
}
|
|
127
|
+
}, "\u2190 Prev"), /*#__PURE__*/React.createElement("span", {
|
|
128
|
+
style: {
|
|
129
|
+
fontSize: 13,
|
|
130
|
+
color: '#71717a'
|
|
131
|
+
}
|
|
132
|
+
}, current, " / ", totalPages), /*#__PURE__*/React.createElement("button", {
|
|
133
|
+
onClick: () => current < totalPages && onChange?.(current + 1),
|
|
134
|
+
disabled: current === totalPages,
|
|
135
|
+
style: {
|
|
136
|
+
padding: '6px 14px',
|
|
137
|
+
borderRadius: 8,
|
|
138
|
+
border: '1px solid #e4e4e7',
|
|
139
|
+
background: '#fff',
|
|
140
|
+
cursor: current === totalPages ? 'not-allowed' : 'pointer',
|
|
141
|
+
fontSize: 13,
|
|
142
|
+
opacity: current === totalPages ? 0.4 : 1
|
|
143
|
+
}
|
|
144
|
+
}, "Next \u2192"));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function usePagination(totalItems, opts = {}) {
|
|
148
|
+
const {
|
|
149
|
+
pageSize = 10,
|
|
150
|
+
initialPage = 1
|
|
151
|
+
} = opts;
|
|
152
|
+
const [current, setCurrent] = React.useState(initialPage);
|
|
153
|
+
const totalPages = Math.ceil(totalItems / pageSize);
|
|
154
|
+
const next = React.useCallback(() => setCurrent(c => Math.min(c + 1, totalPages)), [totalPages]);
|
|
155
|
+
const prev = React.useCallback(() => setCurrent(c => Math.max(c - 1, 1)), []);
|
|
156
|
+
const goTo = React.useCallback(p => setCurrent(Math.max(1, Math.min(p, totalPages))), [totalPages]);
|
|
157
|
+
const reset = React.useCallback(() => setCurrent(1), []);
|
|
158
|
+
const offset = React.useMemo(() => (current - 1) * pageSize, [current, pageSize]);
|
|
159
|
+
const isFirst = current === 1;
|
|
160
|
+
const isLast = current >= totalPages;
|
|
161
|
+
return {
|
|
162
|
+
current,
|
|
163
|
+
totalPages,
|
|
164
|
+
next,
|
|
165
|
+
prev,
|
|
166
|
+
goTo,
|
|
167
|
+
reset,
|
|
168
|
+
offset,
|
|
169
|
+
pageSize,
|
|
170
|
+
isFirst,
|
|
171
|
+
isLast
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const SUPPORTED_LANGUAGES = ['en', 'zh', 'ja', 'ko'];
|
|
176
|
+
const messages = {
|
|
177
|
+
en: {
|
|
178
|
+
"page.prev": "Previous",
|
|
179
|
+
"page.next": "Next",
|
|
180
|
+
"page.items": "items"
|
|
181
|
+
},
|
|
182
|
+
zh: {
|
|
183
|
+
"page.prev": "上一页",
|
|
184
|
+
"page.next": "下一页",
|
|
185
|
+
"page.items": "条"
|
|
186
|
+
},
|
|
187
|
+
ja: {
|
|
188
|
+
"page.prev": "前へ",
|
|
189
|
+
"page.next": "次へ",
|
|
190
|
+
"page.items": "件"
|
|
191
|
+
},
|
|
192
|
+
ko: {
|
|
193
|
+
"page.prev": "이전",
|
|
194
|
+
"page.next": "다음",
|
|
195
|
+
"page.items": "개"
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
let currentLang = 'en';
|
|
199
|
+
function setLanguage(l) {
|
|
200
|
+
if (SUPPORTED_LANGUAGES.includes(l)) currentLang = l;
|
|
201
|
+
}
|
|
202
|
+
function getLanguage() {
|
|
203
|
+
return currentLang;
|
|
204
|
+
}
|
|
205
|
+
function t(k) {
|
|
206
|
+
return messages[currentLang]?.[k] || messages.en?.[k] || k;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
exports.Pagination = Pagination;
|
|
210
|
+
exports.SUPPORTED_LANGUAGES = SUPPORTED_LANGUAGES;
|
|
211
|
+
exports.SimplePagination = SimplePagination;
|
|
212
|
+
exports.getLanguage = getLanguage;
|
|
213
|
+
exports.messages = messages;
|
|
214
|
+
exports.setLanguage = setLanguage;
|
|
215
|
+
exports.t = t;
|
|
216
|
+
exports.usePagination = usePagination;
|
|
217
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/components/Pagination.jsx","../src/hooks/usePagination.js","../src/i18n/index.js"],"sourcesContent":["import React from'react';\nexport function Pagination({current=1,total,pageSize=10,onChange,siblingCount=1,showTotal=true,className=''}){\n const totalPages=Math.ceil(total/pageSize);if(totalPages<=1)return null;\n const range=(s,e)=>Array.from({length:e-s+1},(_,i)=>s+i);\n const pages=(()=>{const left=Math.max(2,current-siblingCount);const right=Math.min(totalPages-1,current+siblingCount);\n const items=[];items.push(1);if(left>2)items.push('...');items.push(...range(left,right));\n if(right<totalPages-1)items.push('...');if(totalPages>1)items.push(totalPages);return items;})();\n const btnStyle=(active)=>({minWidth:32,height:32,borderRadius:8,border:'none',\n background:active?'#3b82f6':'transparent',color:active?'#fff':'#71717a',cursor:'pointer',\n fontSize:13,fontWeight:active?600:400,transition:'all 0.2s',display:'flex',alignItems:'center',justifyContent:'center'});\n return(<div className={`qpg-pagination ${className}`} style={{display:'flex',alignItems:'center',gap:4}}>\n {showTotal&&<span style={{fontSize:12,color:'#a1a1aa',marginRight:8}}>{total} items</span>}\n <button onClick={()=>current>1&&onChange?.(current-1)} disabled={current===1} style={{...btnStyle(false),opacity:current===1?0.4:1}}>\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\"><path d=\"M15 18l-6-6 6-6\"/></svg>\n </button>\n {pages.map((p,i)=>p==='...'?<span key={'d'+i} style={{color:'#a1a1aa',padding:'0 4px'}}>…</span>\n :<button key={p} onClick={()=>onChange?.(p)} style={btnStyle(p===current)}>{p}</button>)}\n <button onClick={()=>current<totalPages&&onChange?.(current+1)} disabled={current===totalPages} style={{...btnStyle(false),opacity:current===totalPages?0.4:1}}>\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\"><path d=\"M9 18l6-6-6-6\"/></svg>\n </button>\n </div>);\n}\nexport function SimplePagination({current=1,totalPages=1,onChange,className=''}){\n return(<div className={`qpg-simple ${className}`} style={{display:'flex',alignItems:'center',gap:12}}>\n <button onClick={()=>current>1&&onChange?.(current-1)} disabled={current===1}\n style={{padding:'6px 14px',borderRadius:8,border:'1px solid #e4e4e7',background:'#fff',\n cursor:current===1?'not-allowed':'pointer',fontSize:13,opacity:current===1?0.4:1}}>← Prev</button>\n <span style={{fontSize:13,color:'#71717a'}}>{current} / {totalPages}</span>\n <button onClick={()=>current<totalPages&&onChange?.(current+1)} disabled={current===totalPages}\n style={{padding:'6px 14px',borderRadius:8,border:'1px solid #e4e4e7',background:'#fff',\n cursor:current===totalPages?'not-allowed':'pointer',fontSize:13,opacity:current===totalPages?0.4:1}}>Next →</button>\n </div>);\n}\n","import{useState,useMemo,useCallback}from'react';\nexport function usePagination(totalItems,opts={}){const{pageSize=10,initialPage=1}=opts;\n const[current,setCurrent]=useState(initialPage);const totalPages=Math.ceil(totalItems/pageSize);\n const next=useCallback(()=>setCurrent(c=>Math.min(c+1,totalPages)),[totalPages]);\n const prev=useCallback(()=>setCurrent(c=>Math.max(c-1,1)),[]);\n const goTo=useCallback(p=>setCurrent(Math.max(1,Math.min(p,totalPages))),[totalPages]);\n const reset=useCallback(()=>setCurrent(1),[]);\n const offset=useMemo(()=>(current-1)*pageSize,[current,pageSize]);\n const isFirst=current===1;const isLast=current>=totalPages;\n return{current,totalPages,next,prev,goTo,reset,offset,pageSize,isFirst,isLast};\n}\n","export const SUPPORTED_LANGUAGES = ['en', 'zh', 'ja', 'ko'];\nexport const messages = {\n en: {\n \"page.prev\": \"Previous\",\n \"page.next\": \"Next\",\n \"page.items\": \"items\"\n},\n zh: {\n \"page.prev\": \"上一页\",\n \"page.next\": \"下一页\",\n \"page.items\": \"条\"\n},\n ja: {\n \"page.prev\": \"前へ\",\n \"page.next\": \"次へ\",\n \"page.items\": \"件\"\n},\n ko: {\n \"page.prev\": \"이전\",\n \"page.next\": \"다음\",\n \"page.items\": \"개\"\n}\n};\nlet currentLang = 'en';\nexport function setLanguage(l) { if (SUPPORTED_LANGUAGES.includes(l)) currentLang = l; }\nexport function getLanguage() { return currentLang; }\nexport function t(k) { return messages[currentLang]?.[k] || messages.en?.[k] || k; }\n"],"names":["Pagination","current","total","pageSize","onChange","siblingCount","showTotal","className","totalPages","Math","ceil","range","s","e","Array","from","length","_","i","pages","left","max","right","min","items","push","btnStyle","active","minWidth","height","borderRadius","border","background","color","cursor","fontSize","fontWeight","transition","display","alignItems","justifyContent","React","createElement","style","gap","marginRight","onClick","disabled","opacity","width","viewBox","fill","stroke","strokeWidth","d","map","p","key","padding","SimplePagination","usePagination","totalItems","opts","initialPage","setCurrent","useState","next","useCallback","c","prev","goTo","reset","offset","useMemo","isFirst","isLast","SUPPORTED_LANGUAGES","messages","en","zh","ja","ko","currentLang","setLanguage","l","includes","getLanguage","t","k"],"mappings":";;;;AACO,SAASA,UAAUA,CAAC;AAACC,EAAAA,OAAO,GAAC,CAAC;EAACC,KAAK;AAACC,EAAAA,QAAQ,GAAC,EAAE;EAACC,QAAQ;AAACC,EAAAA,YAAY,GAAC,CAAC;AAACC,EAAAA,SAAS,GAAC,IAAI;AAACC,EAAAA,SAAS,GAAC;AAAE,CAAC,EAAC;EAC3G,MAAMC,UAAU,GAACC,IAAI,CAACC,IAAI,CAACR,KAAK,GAACC,QAAQ,CAAC;AAAC,EAAA,IAAGK,UAAU,IAAE,CAAC,EAAC,OAAO,IAAI;EACvE,MAAMG,KAAK,GAACA,CAACC,CAAC,EAACC,C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EAAE,IAAIR,mBAAmB,CAACS,QAAQ,CAACD,CAAC,CAAC,EAAEF,WAAW,GAAGE,CAAC;AAAE;AAChF,SAASE,WAAWA,GAAG;AAAE,EAAA,OAAOJ,WAAW;AAAE;AAC7C,SAASK,CAACA,CAACC,CAAC,EAAE;AAAE,EAAA,OAAOX,QAAQ,CAACK,WAAW,CAAC,GAAGM,CAAC,CAAC,IAAIX,QAAQ,CAACC,EAAE,GAAGU,CAAC,CAAC,IAAIA,CAAC;AAAE;;;;;;;;;;;"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import React, { useState, useCallback, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
function Pagination({
|
|
4
|
+
current = 1,
|
|
5
|
+
total,
|
|
6
|
+
pageSize = 10,
|
|
7
|
+
onChange,
|
|
8
|
+
siblingCount = 1,
|
|
9
|
+
showTotal = true,
|
|
10
|
+
className = ''
|
|
11
|
+
}) {
|
|
12
|
+
const totalPages = Math.ceil(total / pageSize);
|
|
13
|
+
if (totalPages <= 1) return null;
|
|
14
|
+
const range = (s, e) => Array.from({
|
|
15
|
+
length: e - s + 1
|
|
16
|
+
}, (_, i) => s + i);
|
|
17
|
+
const pages = (() => {
|
|
18
|
+
const left = Math.max(2, current - siblingCount);
|
|
19
|
+
const right = Math.min(totalPages - 1, current + siblingCount);
|
|
20
|
+
const items = [];
|
|
21
|
+
items.push(1);
|
|
22
|
+
if (left > 2) items.push('...');
|
|
23
|
+
items.push(...range(left, right));
|
|
24
|
+
if (right < totalPages - 1) items.push('...');
|
|
25
|
+
if (totalPages > 1) items.push(totalPages);
|
|
26
|
+
return items;
|
|
27
|
+
})();
|
|
28
|
+
const btnStyle = active => ({
|
|
29
|
+
minWidth: 32,
|
|
30
|
+
height: 32,
|
|
31
|
+
borderRadius: 8,
|
|
32
|
+
border: 'none',
|
|
33
|
+
background: active ? '#3b82f6' : 'transparent',
|
|
34
|
+
color: active ? '#fff' : '#71717a',
|
|
35
|
+
cursor: 'pointer',
|
|
36
|
+
fontSize: 13,
|
|
37
|
+
fontWeight: active ? 600 : 400,
|
|
38
|
+
transition: 'all 0.2s',
|
|
39
|
+
display: 'flex',
|
|
40
|
+
alignItems: 'center',
|
|
41
|
+
justifyContent: 'center'
|
|
42
|
+
});
|
|
43
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
44
|
+
className: `qpg-pagination ${className}`,
|
|
45
|
+
style: {
|
|
46
|
+
display: 'flex',
|
|
47
|
+
alignItems: 'center',
|
|
48
|
+
gap: 4
|
|
49
|
+
}
|
|
50
|
+
}, showTotal && /*#__PURE__*/React.createElement("span", {
|
|
51
|
+
style: {
|
|
52
|
+
fontSize: 12,
|
|
53
|
+
color: '#a1a1aa',
|
|
54
|
+
marginRight: 8
|
|
55
|
+
}
|
|
56
|
+
}, total, " items"), /*#__PURE__*/React.createElement("button", {
|
|
57
|
+
onClick: () => current > 1 && onChange?.(current - 1),
|
|
58
|
+
disabled: current === 1,
|
|
59
|
+
style: {
|
|
60
|
+
...btnStyle(false),
|
|
61
|
+
opacity: current === 1 ? 0.4 : 1
|
|
62
|
+
}
|
|
63
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
64
|
+
width: "14",
|
|
65
|
+
height: "14",
|
|
66
|
+
viewBox: "0 0 24 24",
|
|
67
|
+
fill: "none",
|
|
68
|
+
stroke: "currentColor",
|
|
69
|
+
strokeWidth: "2"
|
|
70
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
71
|
+
d: "M15 18l-6-6 6-6"
|
|
72
|
+
}))), pages.map((p, i) => p === '...' ? /*#__PURE__*/React.createElement("span", {
|
|
73
|
+
key: 'd' + i,
|
|
74
|
+
style: {
|
|
75
|
+
color: '#a1a1aa',
|
|
76
|
+
padding: '0 4px'
|
|
77
|
+
}
|
|
78
|
+
}, "\u2026") : /*#__PURE__*/React.createElement("button", {
|
|
79
|
+
key: p,
|
|
80
|
+
onClick: () => onChange?.(p),
|
|
81
|
+
style: btnStyle(p === current)
|
|
82
|
+
}, p)), /*#__PURE__*/React.createElement("button", {
|
|
83
|
+
onClick: () => current < totalPages && onChange?.(current + 1),
|
|
84
|
+
disabled: current === totalPages,
|
|
85
|
+
style: {
|
|
86
|
+
...btnStyle(false),
|
|
87
|
+
opacity: current === totalPages ? 0.4 : 1
|
|
88
|
+
}
|
|
89
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
90
|
+
width: "14",
|
|
91
|
+
height: "14",
|
|
92
|
+
viewBox: "0 0 24 24",
|
|
93
|
+
fill: "none",
|
|
94
|
+
stroke: "currentColor",
|
|
95
|
+
strokeWidth: "2"
|
|
96
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
97
|
+
d: "M9 18l6-6-6-6"
|
|
98
|
+
}))));
|
|
99
|
+
}
|
|
100
|
+
function SimplePagination({
|
|
101
|
+
current = 1,
|
|
102
|
+
totalPages = 1,
|
|
103
|
+
onChange,
|
|
104
|
+
className = ''
|
|
105
|
+
}) {
|
|
106
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
107
|
+
className: `qpg-simple ${className}`,
|
|
108
|
+
style: {
|
|
109
|
+
display: 'flex',
|
|
110
|
+
alignItems: 'center',
|
|
111
|
+
gap: 12
|
|
112
|
+
}
|
|
113
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
114
|
+
onClick: () => current > 1 && onChange?.(current - 1),
|
|
115
|
+
disabled: current === 1,
|
|
116
|
+
style: {
|
|
117
|
+
padding: '6px 14px',
|
|
118
|
+
borderRadius: 8,
|
|
119
|
+
border: '1px solid #e4e4e7',
|
|
120
|
+
background: '#fff',
|
|
121
|
+
cursor: current === 1 ? 'not-allowed' : 'pointer',
|
|
122
|
+
fontSize: 13,
|
|
123
|
+
opacity: current === 1 ? 0.4 : 1
|
|
124
|
+
}
|
|
125
|
+
}, "\u2190 Prev"), /*#__PURE__*/React.createElement("span", {
|
|
126
|
+
style: {
|
|
127
|
+
fontSize: 13,
|
|
128
|
+
color: '#71717a'
|
|
129
|
+
}
|
|
130
|
+
}, current, " / ", totalPages), /*#__PURE__*/React.createElement("button", {
|
|
131
|
+
onClick: () => current < totalPages && onChange?.(current + 1),
|
|
132
|
+
disabled: current === totalPages,
|
|
133
|
+
style: {
|
|
134
|
+
padding: '6px 14px',
|
|
135
|
+
borderRadius: 8,
|
|
136
|
+
border: '1px solid #e4e4e7',
|
|
137
|
+
background: '#fff',
|
|
138
|
+
cursor: current === totalPages ? 'not-allowed' : 'pointer',
|
|
139
|
+
fontSize: 13,
|
|
140
|
+
opacity: current === totalPages ? 0.4 : 1
|
|
141
|
+
}
|
|
142
|
+
}, "Next \u2192"));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function usePagination(totalItems, opts = {}) {
|
|
146
|
+
const {
|
|
147
|
+
pageSize = 10,
|
|
148
|
+
initialPage = 1
|
|
149
|
+
} = opts;
|
|
150
|
+
const [current, setCurrent] = useState(initialPage);
|
|
151
|
+
const totalPages = Math.ceil(totalItems / pageSize);
|
|
152
|
+
const next = useCallback(() => setCurrent(c => Math.min(c + 1, totalPages)), [totalPages]);
|
|
153
|
+
const prev = useCallback(() => setCurrent(c => Math.max(c - 1, 1)), []);
|
|
154
|
+
const goTo = useCallback(p => setCurrent(Math.max(1, Math.min(p, totalPages))), [totalPages]);
|
|
155
|
+
const reset = useCallback(() => setCurrent(1), []);
|
|
156
|
+
const offset = useMemo(() => (current - 1) * pageSize, [current, pageSize]);
|
|
157
|
+
const isFirst = current === 1;
|
|
158
|
+
const isLast = current >= totalPages;
|
|
159
|
+
return {
|
|
160
|
+
current,
|
|
161
|
+
totalPages,
|
|
162
|
+
next,
|
|
163
|
+
prev,
|
|
164
|
+
goTo,
|
|
165
|
+
reset,
|
|
166
|
+
offset,
|
|
167
|
+
pageSize,
|
|
168
|
+
isFirst,
|
|
169
|
+
isLast
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const SUPPORTED_LANGUAGES = ['en', 'zh', 'ja', 'ko'];
|
|
174
|
+
const messages = {
|
|
175
|
+
en: {
|
|
176
|
+
"page.prev": "Previous",
|
|
177
|
+
"page.next": "Next",
|
|
178
|
+
"page.items": "items"
|
|
179
|
+
},
|
|
180
|
+
zh: {
|
|
181
|
+
"page.prev": "上一页",
|
|
182
|
+
"page.next": "下一页",
|
|
183
|
+
"page.items": "条"
|
|
184
|
+
},
|
|
185
|
+
ja: {
|
|
186
|
+
"page.prev": "前へ",
|
|
187
|
+
"page.next": "次へ",
|
|
188
|
+
"page.items": "件"
|
|
189
|
+
},
|
|
190
|
+
ko: {
|
|
191
|
+
"page.prev": "이전",
|
|
192
|
+
"page.next": "다음",
|
|
193
|
+
"page.items": "개"
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
let currentLang = 'en';
|
|
197
|
+
function setLanguage(l) {
|
|
198
|
+
if (SUPPORTED_LANGUAGES.includes(l)) currentLang = l;
|
|
199
|
+
}
|
|
200
|
+
function getLanguage() {
|
|
201
|
+
return currentLang;
|
|
202
|
+
}
|
|
203
|
+
function t(k) {
|
|
204
|
+
return messages[currentLang]?.[k] || messages.en?.[k] || k;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export { Pagination, SUPPORTED_LANGUAGES, SimplePagination, getLanguage, messages, setLanguage, t, usePagination };
|
|
208
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/components/Pagination.jsx","../src/hooks/usePagination.js","../src/i18n/index.js"],"sourcesContent":["import React from'react';\nexport function Pagination({current=1,total,pageSize=10,onChange,siblingCount=1,showTotal=true,className=''}){\n const totalPages=Math.ceil(total/pageSize);if(totalPages<=1)return null;\n const range=(s,e)=>Array.from({length:e-s+1},(_,i)=>s+i);\n const pages=(()=>{const left=Math.max(2,current-siblingCount);const right=Math.min(totalPages-1,current+siblingCount);\n const items=[];items.push(1);if(left>2)items.push('...');items.push(...range(left,right));\n if(right<totalPages-1)items.push('...');if(totalPages>1)items.push(totalPages);return items;})();\n const btnStyle=(active)=>({minWidth:32,height:32,borderRadius:8,border:'none',\n background:active?'#3b82f6':'transparent',color:active?'#fff':'#71717a',cursor:'pointer',\n fontSize:13,fontWeight:active?600:400,transition:'all 0.2s',display:'flex',alignItems:'center',justifyContent:'center'});\n return(<div className={`qpg-pagination ${className}`} style={{display:'flex',alignItems:'center',gap:4}}>\n {showTotal&&<span style={{fontSize:12,color:'#a1a1aa',marginRight:8}}>{total} items</span>}\n <button onClick={()=>current>1&&onChange?.(current-1)} disabled={current===1} style={{...btnStyle(false),opacity:current===1?0.4:1}}>\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\"><path d=\"M15 18l-6-6 6-6\"/></svg>\n </button>\n {pages.map((p,i)=>p==='...'?<span key={'d'+i} style={{color:'#a1a1aa',padding:'0 4px'}}>…</span>\n :<button key={p} onClick={()=>onChange?.(p)} style={btnStyle(p===current)}>{p}</button>)}\n <button onClick={()=>current<totalPages&&onChange?.(current+1)} disabled={current===totalPages} style={{...btnStyle(false),opacity:current===totalPages?0.4:1}}>\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\"><path d=\"M9 18l6-6-6-6\"/></svg>\n </button>\n </div>);\n}\nexport function SimplePagination({current=1,totalPages=1,onChange,className=''}){\n return(<div className={`qpg-simple ${className}`} style={{display:'flex',alignItems:'center',gap:12}}>\n <button onClick={()=>current>1&&onChange?.(current-1)} disabled={current===1}\n style={{padding:'6px 14px',borderRadius:8,border:'1px solid #e4e4e7',background:'#fff',\n cursor:current===1?'not-allowed':'pointer',fontSize:13,opacity:current===1?0.4:1}}>← Prev</button>\n <span style={{fontSize:13,color:'#71717a'}}>{current} / {totalPages}</span>\n <button onClick={()=>current<totalPages&&onChange?.(current+1)} disabled={current===totalPages}\n style={{padding:'6px 14px',borderRadius:8,border:'1px solid #e4e4e7',background:'#fff',\n cursor:current===totalPages?'not-allowed':'pointer',fontSize:13,opacity:current===totalPages?0.4:1}}>Next →</button>\n </div>);\n}\n","import{useState,useMemo,useCallback}from'react';\nexport function usePagination(totalItems,opts={}){const{pageSize=10,initialPage=1}=opts;\n const[current,setCurrent]=useState(initialPage);const totalPages=Math.ceil(totalItems/pageSize);\n const next=useCallback(()=>setCurrent(c=>Math.min(c+1,totalPages)),[totalPages]);\n const prev=useCallback(()=>setCurrent(c=>Math.max(c-1,1)),[]);\n const goTo=useCallback(p=>setCurrent(Math.max(1,Math.min(p,totalPages))),[totalPages]);\n const reset=useCallback(()=>setCurrent(1),[]);\n const offset=useMemo(()=>(current-1)*pageSize,[current,pageSize]);\n const isFirst=current===1;const isLast=current>=totalPages;\n return{current,totalPages,next,prev,goTo,reset,offset,pageSize,isFirst,isLast};\n}\n","export const SUPPORTED_LANGUAGES = ['en', 'zh', 'ja', 'ko'];\nexport const messages = {\n en: {\n \"page.prev\": \"Previous\",\n \"page.next\": \"Next\",\n \"page.items\": \"items\"\n},\n zh: {\n \"page.prev\": \"上一页\",\n \"page.next\": \"下一页\",\n \"page.items\": \"条\"\n},\n ja: {\n \"page.prev\": \"前へ\",\n \"page.next\": \"次へ\",\n \"page.items\": \"件\"\n},\n ko: {\n \"page.prev\": \"이전\",\n \"page.next\": \"다음\",\n \"page.items\": \"개\"\n}\n};\nlet currentLang = 'en';\nexport function setLanguage(l) { if (SUPPORTED_LANGUAGES.includes(l)) currentLang = l; }\nexport function getLanguage() { return currentLang; }\nexport function t(k) { return messages[currentLang]?.[k] || messages.en?.[k] || k; }\n"],"names":["Pagination","current","total","pageSize","onChange","siblingCount","showTotal","className","totalPages","Math","ceil","range","s","e","Array","from","length","_","i","pages","left","max","right","min","items","push","btnStyle","active","minWidth","height","borderRadius","border","background","color","cursor","fontSize","fontWeight","transition","display","alignItems","justifyContent","React","createElement","style","gap","marginRight","onClick","disabled","opacity","width","viewBox","fill","stroke","strokeWidth","d","map","p","key","padding","SimplePagination","usePagination","totalItems","opts","initialPage","setCurrent","useState","next","useCallback","c","prev","goTo","reset","offset","useMemo","isFirst","isLast","SUPPORTED_LANGUAGES","messages","en","zh","ja","ko","currentLang","setLanguage","l","includes","getLanguage","t","k"],"mappings":";;AACO,SAASA,UAAUA,CAAC;AAACC,EAAAA,OAAO,GAAC,CAAC;EAACC,KAAK;AAACC,EAAAA,QAAQ,GAAC,EAAE;EAACC,QAAQ;AAACC,EAAAA,YAAY,GAAC,CAAC;AAACC,EAAAA,SAAS,GAAC,IAAI;AAACC,EAAAA,SAAS,GAAC;AAAE,CAAC,EAAC;EAC3G,MAAMC,UAAU,GAACC,IAAI,CAACC,IAAI,CAACR,KAAK,GAACC,QAAQ,CAAC;AAAC,EAAA,IAAGK,UAAU,IAAE,CAAC,EAAC,OAAO,IAAI;EACvE,MAAMG,KAAK,GAACA,CAACC,CAAC,EAACC,CAAC,KAAGC,KAAK,CAACC,IAAI,CAAC;AAACC,IAAAA,MAAM,EAACH,CAAC,GAACD,CAAC,GAAC;GAAE,EAAC,CAACK,CAAC,EAACC,CAAC,KAAGN,CAAC,GAACM,CAAC,CAAC;EACxD,MAAMC,KAAK,GAAC,CAAC,MAAI;IAAC,MAAMC,IAAI,GAACX,IAAI,CAACY,GAAG,CAAC,CAAC,EAACpB,OAAO,GAACI,YAAY,CAAC;AAAC,IAAA,MAAMiB,KAAK,GAACb,IAAI,CAACc,GAAG,CAACf,UAAU,GAAC,CAAC,EAACP,OAAO,GAACI,YAAY,CAAC;IACnH,MAAMmB,KAAK,GAAC,EAAE;AAACA,IAAAA,KAAK,CAACC,IAAI,CAAC,CAAC,CAAC;IAAC,IAAGL,IAAI,GAAC,CAAC,EAACI,KAAK,CAACC,IAAI,CAAC,KAAK,CAAC;IAACD,KAAK,CAACC,IAAI,CAAC,GAAGd,KAAK,CAACS,IAAI,EAACE,KAAK,CAAC,CAAC;IACzF,IAAGA,KAAK,GAACd,UAAU,GAAC,CAAC,EAACgB,KAAK,CAAC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MAAMC,QAAQ,GAAG;AACtBC,EAAAA,EAAE,EAAE;AACJ,IAAA,WAAW,EAAE,UAAU;AACvB,IAAA,WAAW,EAAE,MAAM;AACnB,IAAA,YAAY,EAAE;GACf;AACCC,EAAAA,EAAE,EAAE;AACJ,IAAA,WAAW,EAAE,KAAK;AAClB,IAAA,WAAW,EAAE,KAAK;AAClB,IAAA,YAAY,EAAE;GACf;AACCC,EAAAA,EAAE,EAAE;AACJ,IAAA,WAAW,EAAE,IAAI;AACjB,IAAA,WAAW,EAAE,IAAI;AACjB,IAAA,YAAY,EAAE;GACf;AACCC,EAAAA,EAAE,EAAE;AACJ,IAAA,WAAW,EAAE,IAAI;AACjB,IAAA,WAAW,EAAE,IAAI;AACjB,IAAA,YAAY,EAAE;AAChB;AACA;AACA,IAAIC,WAAW,GAAG,IAAI;AACf,SAASC,WAAWA,CAACC,CAAC,EAAE;EAAE,IAAIR,mBAAmB,CAACS,QAAQ,CAACD,CAAC,CAAC,EAAEF,WAAW,GAAGE,CAAC;AAAE;AAChF,SAASE,WAAWA,GAAG;AAAE,EAAA,OAAOJ,WAAW;AAAE;AAC7C,SAASK,CAACA,CAACC,CAAC,EAAE;AAAE,EAAA,OAAOX,QAAQ,CAACK,WAAW,CAAC,GAAGM,CAAC,CAAC,IAAIX,QAAQ,CAACC,EAAE,GAAGU,CAAC,CAAC,IAAIA,CAAC;AAAE;;;;"}
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["pagination.css"],"names":[],"mappings":"AAAA,4CAA4C,yCAA0C,CAAC,uBAAuB,CAC9G,wCAAwC,8BAA8B,CAAC,uBAAuB","file":"styles.css","sourcesContent":[".qpg-pagination button:hover:not(:disabled){background:rgba(59,130,246,0.08)!important;color:#3b82f6!important}\n.qpg-simple button:hover:not(:disabled){border-color:#3b82f6!important;color:#3b82f6!important}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@quantabit/pagination-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Pagination components with number and simple modes",
|
|
6
|
+
"main": "dist/index.cjs",
|
|
7
|
+
"module": "dist/index.esm.js",
|
|
8
|
+
"types": "types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./types/index.d.ts",
|
|
12
|
+
"import": "./dist/index.esm.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"types",
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "rollup -c",
|
|
24
|
+
"dev": "rollup -c -w",
|
|
25
|
+
"test": "jest --passWithNoTests",
|
|
26
|
+
"prepublishOnly": "npm run build"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/quantabit-chain/qbit-sdk.git",
|
|
31
|
+
"directory": "packages/pagination-sdk"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"pagination",
|
|
35
|
+
"pager",
|
|
36
|
+
"react"
|
|
37
|
+
],
|
|
38
|
+
"author": "QuantaBit Team",
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=18.0.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"react": ">=17.0.0",
|
|
45
|
+
"react-dom": ">=17.0.0"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@quantabit/sdk-config": "^1.0.6"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"homepage": "https://github.com/quantabit-chain/qbit-sdk/tree/main/packages/pagination-sdk",
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://github.com/quantabit-chain/qbit-sdk/issues"
|
|
56
|
+
},
|
|
57
|
+
"sideEffects": [
|
|
58
|
+
"*.css"
|
|
59
|
+
],
|
|
60
|
+
"qbit": {
|
|
61
|
+
"privacy": {
|
|
62
|
+
"level": "functional",
|
|
63
|
+
"dataCollection": "Feature-related data for personalization. Requires user consent.",
|
|
64
|
+
"gdprCompliant": true,
|
|
65
|
+
"ccpaCompliant": true
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @quantabit/pagination-sdk TypeScript Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Auto-generated type stubs. Enhance with specific types as the SDK matures.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { FC, ReactNode } from 'react';
|
|
8
|
+
|
|
9
|
+
// ============ Components ============
|
|
10
|
+
|
|
11
|
+
export interface PaginationProps {
|
|
12
|
+
className?: string;
|
|
13
|
+
style?: React.CSSProperties;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export declare const Pagination: FC<PaginationProps>;
|
|
18
|
+
|
|
19
|
+
export interface SimplePaginationProps {
|
|
20
|
+
className?: string;
|
|
21
|
+
style?: React.CSSProperties;
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export declare const SimplePagination: FC<SimplePaginationProps>;
|
|
26
|
+
|
|
27
|
+
// ============ Hooks ============
|
|
28
|
+
|
|
29
|
+
export interface UsePaginationReturn {
|
|
30
|
+
data: any;
|
|
31
|
+
loading: boolean;
|
|
32
|
+
error: string | null;
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export declare function usePagination(...args: any[]): UsePaginationReturn;
|
|
37
|
+
|
|
38
|
+
// ============ Functions & Utilities ============
|
|
39
|
+
|
|
40
|
+
export declare const messages: Record<string, Record<string, string>>;
|
|
41
|
+
export declare const SUPPORTED_LANGUAGES: string[];
|
|
42
|
+
export declare function setLanguage(lang: string): void;
|
|
43
|
+
export declare function getLanguage(): string;
|
|
44
|
+
export declare function t(key: string, params?: Record<string, any>): string;
|
|
45
|
+
|