@0xchain/pagination 0.0.1 → 1.1.0-beta.1

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