@0xchain/pagination 1.1.0-beta.4 → 1.1.0-beta.6
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/dist/index.js +51 -51
- package/package.json +2 -2
- package/src/index.tsx +5 -5
package/dist/index.js
CHANGED
|
@@ -1,77 +1,77 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as
|
|
2
|
+
import { jsx as e, jsxs as p } from "react/jsx-runtime";
|
|
3
3
|
import * as z from "react";
|
|
4
|
-
import { Pagination as j, PaginationContent as V, PaginationItem as
|
|
4
|
+
import { Pagination as j, PaginationContent as V, PaginationItem as r, PaginationLink as a, PaginationEllipsis as v } from "@0xchain/ui/pagination";
|
|
5
5
|
import { Select as S, SelectTrigger as L, SelectValue as I, SelectContent as R, SelectItem as E } from "@0xchain/ui/select";
|
|
6
|
-
import { twMerge as
|
|
6
|
+
import { twMerge as n } from "tailwind-merge";
|
|
7
7
|
import { useTranslations as F } from "next-intl";
|
|
8
8
|
import { ChevronRight as G, ChevronLeft as T } from "lucide-react";
|
|
9
9
|
const N = 1e4;
|
|
10
10
|
function K({
|
|
11
|
-
className:
|
|
11
|
+
className: k,
|
|
12
12
|
total: u,
|
|
13
13
|
pageSize: x,
|
|
14
14
|
pageSizeOptions: b = [10, 30, 50],
|
|
15
15
|
currentPage: s,
|
|
16
16
|
layout: f = ["prev", "page", "next", "ellipsis", "sizes", "total"],
|
|
17
|
-
onPageChange:
|
|
17
|
+
onPageChange: t,
|
|
18
18
|
onPageSizeChange: h,
|
|
19
|
-
totalLabel:
|
|
19
|
+
totalLabel: y
|
|
20
20
|
}) {
|
|
21
21
|
const d = F(), w = Math.min(u, N), l = Math.ceil(w / x), M = () => {
|
|
22
|
-
const
|
|
22
|
+
const i = [];
|
|
23
23
|
let o = Math.max(1, s - Math.floor(1.5));
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
/* @__PURE__ */
|
|
24
|
+
const m = Math.min(l, o + 3 - 1);
|
|
25
|
+
m - o + 1 < 3 && (o = Math.max(1, m - 3 + 1)), o > 1 && (i.push(
|
|
26
|
+
/* @__PURE__ */ e(r, { children: /* @__PURE__ */ e(
|
|
27
27
|
a,
|
|
28
28
|
{
|
|
29
29
|
size: "sm",
|
|
30
|
-
className:
|
|
30
|
+
className: n(
|
|
31
31
|
"h-6 min-w-6 w-fit rounded-md cursor-pointer",
|
|
32
|
-
s === 1 ? "bg-
|
|
32
|
+
s === 1 ? "bg-[#000]! text-primary-foreground!" : ""
|
|
33
33
|
),
|
|
34
|
-
onClick: () =>
|
|
34
|
+
onClick: () => t == null ? void 0 : t(1),
|
|
35
35
|
children: "1"
|
|
36
36
|
}
|
|
37
37
|
) }, "first")
|
|
38
|
-
), o > 2 &&
|
|
39
|
-
/* @__PURE__ */
|
|
38
|
+
), o > 2 && i.push(
|
|
39
|
+
/* @__PURE__ */ e(r, { children: /* @__PURE__ */ e(v, {}) }, "ellipsis-start")
|
|
40
40
|
));
|
|
41
|
-
for (let
|
|
42
|
-
|
|
43
|
-
/* @__PURE__ */
|
|
41
|
+
for (let c = o; c <= m; c++)
|
|
42
|
+
i.push(
|
|
43
|
+
/* @__PURE__ */ e(r, { children: /* @__PURE__ */ e(
|
|
44
44
|
a,
|
|
45
45
|
{
|
|
46
46
|
size: "sm",
|
|
47
|
-
className:
|
|
47
|
+
className: n(
|
|
48
48
|
"h-6 min-w-6 w-fit rounded-md cursor-pointer",
|
|
49
|
-
s ===
|
|
49
|
+
s === c ? "bg-[#000]! text-primary-foreground!" : ""
|
|
50
50
|
),
|
|
51
|
-
onClick: () =>
|
|
52
|
-
children:
|
|
51
|
+
onClick: () => t == null ? void 0 : t(c),
|
|
52
|
+
children: c
|
|
53
53
|
}
|
|
54
|
-
) },
|
|
54
|
+
) }, c)
|
|
55
55
|
);
|
|
56
|
-
return
|
|
57
|
-
/* @__PURE__ */
|
|
58
|
-
),
|
|
59
|
-
/* @__PURE__ */
|
|
56
|
+
return m < l && (m < l - 1 && i.push(
|
|
57
|
+
/* @__PURE__ */ e(r, { className: "cursor-pointer", children: /* @__PURE__ */ e(v, {}) }, "ellipsis-end")
|
|
58
|
+
), i.push(
|
|
59
|
+
/* @__PURE__ */ e(r, { children: /* @__PURE__ */ e(
|
|
60
60
|
a,
|
|
61
61
|
{
|
|
62
62
|
size: "sm",
|
|
63
|
-
className:
|
|
63
|
+
className: n(
|
|
64
64
|
"h-6 min-w-6 w-fit rounded-md cursor-pointer",
|
|
65
|
-
s === l ? "bg-
|
|
65
|
+
s === l ? "bg-[#000]! text-primary-foreground!" : ""
|
|
66
66
|
),
|
|
67
|
-
onClick: () =>
|
|
67
|
+
onClick: () => t == null ? void 0 : t(l),
|
|
68
68
|
children: l
|
|
69
69
|
}
|
|
70
70
|
) }, "last")
|
|
71
|
-
)),
|
|
71
|
+
)), i;
|
|
72
72
|
};
|
|
73
|
-
return w <= b[0] ? null : /* @__PURE__ */
|
|
74
|
-
f.includes("total") && /* @__PURE__ */
|
|
73
|
+
return w <= b[0] ? null : /* @__PURE__ */ e(j, { className: n("w-full max-w-screen mt-3", k), children: /* @__PURE__ */ p(V, { className: "w-full flex flex-row items-center justify-between flex-wrap", children: [
|
|
74
|
+
f.includes("total") && /* @__PURE__ */ e(r, { className: "mr-auto order-1 flex-1 overflow-hidden md:overflow-visible md:order-0 ", children: y || /* @__PURE__ */ p("span", { className: "text-sm block text-muted-foreground w-full truncate", children: [
|
|
75
75
|
d("common.pagination.total"),
|
|
76
76
|
" ",
|
|
77
77
|
u,
|
|
@@ -79,58 +79,58 @@ function K({
|
|
|
79
79
|
d("common.pagination.item"),
|
|
80
80
|
u > N ? `${d("common.pagination.totalTip")}` : ""
|
|
81
81
|
] }) }, "total"),
|
|
82
|
-
/* @__PURE__ */
|
|
83
|
-
switch (
|
|
82
|
+
/* @__PURE__ */ e("div", { className: "w-full md:w-auto md:flex-2 flex items-center justify-center", children: f.filter((i) => i !== "total" && i !== "sizes").map((i) => {
|
|
83
|
+
switch (i) {
|
|
84
84
|
case "prev":
|
|
85
|
-
return /* @__PURE__ */
|
|
85
|
+
return /* @__PURE__ */ e(r, { children: /* @__PURE__ */ e(
|
|
86
86
|
a,
|
|
87
87
|
{
|
|
88
88
|
"aria-label": "Go to previous page",
|
|
89
89
|
size: "sm",
|
|
90
|
-
className:
|
|
90
|
+
className: n(
|
|
91
91
|
"flex items-center justify-center pointer gap-1 shrink-0 cursor-pointer px-2",
|
|
92
92
|
s === 1 ? "pointer-events-none opacity-50" : ""
|
|
93
93
|
),
|
|
94
|
-
onClick: () =>
|
|
95
|
-
children: /* @__PURE__ */
|
|
94
|
+
onClick: () => t == null ? void 0 : t(Math.max(1, s - 1)),
|
|
95
|
+
children: /* @__PURE__ */ e(T, { size: 16 })
|
|
96
96
|
}
|
|
97
97
|
) }, "prev");
|
|
98
98
|
case "page":
|
|
99
|
-
return /* @__PURE__ */
|
|
99
|
+
return /* @__PURE__ */ e(z.Fragment, { children: M() }, "page");
|
|
100
100
|
case "next":
|
|
101
|
-
return /* @__PURE__ */
|
|
101
|
+
return /* @__PURE__ */ e(r, { children: /* @__PURE__ */ e(
|
|
102
102
|
a,
|
|
103
103
|
{
|
|
104
104
|
size: "sm",
|
|
105
|
-
className:
|
|
105
|
+
className: n(
|
|
106
106
|
"flex items-center justify-center pointer gap-1 shrink-0 cursor-pointer px-2",
|
|
107
107
|
s === l ? "pointer-events-none opacity-50" : ""
|
|
108
108
|
),
|
|
109
|
-
onClick: () =>
|
|
110
|
-
children: /* @__PURE__ */
|
|
109
|
+
onClick: () => t == null ? void 0 : t(Math.min(l, s + 1)),
|
|
110
|
+
children: /* @__PURE__ */ e(G, { size: 16 })
|
|
111
111
|
}
|
|
112
112
|
) }, "next");
|
|
113
113
|
default:
|
|
114
114
|
return null;
|
|
115
115
|
}
|
|
116
116
|
}) }),
|
|
117
|
-
f.includes("sizes") && h && /* @__PURE__ */ p(
|
|
118
|
-
/* @__PURE__ */
|
|
117
|
+
f.includes("sizes") && h && /* @__PURE__ */ p(r, { className: "gap-2 flex shrink-0 order-1 lg:order-0 items-center py-0.5 flex-1 justify-end", children: [
|
|
118
|
+
/* @__PURE__ */ e("span", { className: "text-sm text-muted-foreground", children: d("common.pagination.sizeLabel") }),
|
|
119
119
|
/* @__PURE__ */ p(
|
|
120
120
|
S,
|
|
121
121
|
{
|
|
122
122
|
value: x.toString(),
|
|
123
|
-
onValueChange: (
|
|
123
|
+
onValueChange: (i) => h(Number(i)),
|
|
124
124
|
children: [
|
|
125
|
-
/* @__PURE__ */
|
|
125
|
+
/* @__PURE__ */ e(
|
|
126
126
|
L,
|
|
127
127
|
{
|
|
128
128
|
size: "sm",
|
|
129
|
-
className: "border
|
|
130
|
-
children: /* @__PURE__ */
|
|
129
|
+
className: "border border-input w-[70px] focus:ring-0 text-foreground bg-background focus-visible:outline-0 focus-ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:border-input py-1",
|
|
130
|
+
children: /* @__PURE__ */ e(I, {})
|
|
131
131
|
}
|
|
132
132
|
),
|
|
133
|
-
/* @__PURE__ */
|
|
133
|
+
/* @__PURE__ */ e(R, { className: "w-20 bg-card", children: b.map((i) => /* @__PURE__ */ e(E, { value: i.toString(), className: "text-sm px-2 py-1 cursor-pointer hover:bg-background", children: i }, i)) })
|
|
134
134
|
]
|
|
135
135
|
}
|
|
136
136
|
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xchain/pagination",
|
|
3
|
-
"version": "1.1.0-beta.
|
|
3
|
+
"version": "1.1.0-beta.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"next-intl": "4.6.1",
|
|
20
20
|
"tailwind-merge": "3.3.1",
|
|
21
21
|
"lucide-react": "0.539.0",
|
|
22
|
-
"@0xchain/ui": "1.1.0-beta.
|
|
22
|
+
"@0xchain/ui": "1.1.0-beta.6"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"rollup-plugin-preserve-use-client": "3.0.1"
|
package/src/index.tsx
CHANGED
|
@@ -64,7 +64,7 @@ export default function CustomPagination({
|
|
|
64
64
|
className={twMerge(
|
|
65
65
|
"h-6 min-w-6 w-fit rounded-md cursor-pointer",
|
|
66
66
|
currentPage === 1
|
|
67
|
-
? "bg-
|
|
67
|
+
? "bg-[#000]! text-primary-foreground!"
|
|
68
68
|
: ""
|
|
69
69
|
)}
|
|
70
70
|
onClick={() => onPageChange?.(1)}
|
|
@@ -91,7 +91,7 @@ export default function CustomPagination({
|
|
|
91
91
|
className={twMerge(
|
|
92
92
|
"h-6 min-w-6 w-fit rounded-md cursor-pointer",
|
|
93
93
|
currentPage === i
|
|
94
|
-
? "bg-
|
|
94
|
+
? "bg-[#000]! text-primary-foreground!"
|
|
95
95
|
: ""
|
|
96
96
|
)}
|
|
97
97
|
onClick={() => onPageChange?.(i)}
|
|
@@ -118,7 +118,7 @@ export default function CustomPagination({
|
|
|
118
118
|
className={twMerge(
|
|
119
119
|
"h-6 min-w-6 w-fit rounded-md cursor-pointer",
|
|
120
120
|
currentPage === totalPages
|
|
121
|
-
? "bg-
|
|
121
|
+
? "bg-[#000]! text-primary-foreground!"
|
|
122
122
|
: ""
|
|
123
123
|
)}
|
|
124
124
|
onClick={() => onPageChange?.(totalPages)}
|
|
@@ -135,7 +135,7 @@ export default function CustomPagination({
|
|
|
135
135
|
return null
|
|
136
136
|
}
|
|
137
137
|
return (
|
|
138
|
-
<Pagination className={twMerge("w-full max-w-
|
|
138
|
+
<Pagination className={twMerge("w-full max-w-screen mt-3", className)}>
|
|
139
139
|
<PaginationContent className="w-full flex flex-row items-center justify-between flex-wrap">
|
|
140
140
|
{layout.includes('total') && (
|
|
141
141
|
<PaginationItem key="total" className="mr-auto order-1 flex-1 overflow-hidden md:overflow-visible md:order-0 ">
|
|
@@ -196,7 +196,7 @@ export default function CustomPagination({
|
|
|
196
196
|
onValueChange={(value: string) => onPageSizeChange(Number(value))}
|
|
197
197
|
>
|
|
198
198
|
<SelectTrigger
|
|
199
|
-
size="sm" className="border
|
|
199
|
+
size="sm" className="border border-input w-[70px] focus:ring-0 text-foreground bg-background focus-visible:outline-0 focus-ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:border-input py-1">
|
|
200
200
|
<SelectValue />
|
|
201
201
|
</SelectTrigger>
|
|
202
202
|
<SelectContent className="w-20 bg-card">
|