@ichaingo/pagination 1.1.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/.babelrc +12 -0
- package/README.md +7 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +141 -0
- package/eslint.config.mjs +12 -0
- package/package.json +28 -0
- package/src/index.tsx +213 -0
- package/tsconfig.json +16 -0
- package/tsconfig.lib.json +50 -0
- package/tsconfig.spec.json +36 -0
- package/vite.config.ts +64 -0
package/.babelrc
ADDED
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface CustomPaginationProps {
|
|
2
|
+
className?: string;
|
|
3
|
+
total: number;
|
|
4
|
+
pageSize: number;
|
|
5
|
+
currentPage: number;
|
|
6
|
+
pageSizeOptions?: number[];
|
|
7
|
+
layout?: ('prev' | 'page' | 'next' | 'ellipsis' | 'sizes' | 'total')[];
|
|
8
|
+
onPageChange?: (page: number) => void;
|
|
9
|
+
onPageSizeChange?: (pageSize: number) => void;
|
|
10
|
+
}
|
|
11
|
+
export default function CustomPagination({ className, total: initialTotal, pageSize, pageSizeOptions, currentPage, layout, onPageChange, onPageSizeChange, }: CustomPaginationProps): import("react/jsx-runtime").JSX.Element | null;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAoBA,UAAU,qBAAqB;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,MAAM,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,CAAC,EAAE,CAAC;IACvE,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/C;AAED,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,SAAS,EACT,KAAK,EAAE,YAAY,EACnB,QAAQ,EACR,eAA8B,EAC9B,WAAW,EACX,MAA+D,EAC/D,YAAY,EACZ,gBAAgB,GACjB,EAAE,qBAAqB,kDA4KvB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as i, jsxs as d } from "react/jsx-runtime";
|
|
3
|
+
import * as y from "react";
|
|
4
|
+
import { Pagination as z, PaginationContent as j, PaginationItem as s, PaginationLink as a, PaginationEllipsis as v } from "@ichaingo/ui/pagination";
|
|
5
|
+
import { Select as V, SelectTrigger as S, SelectValue as L, SelectContent as I, SelectItem as R } from "@ichaingo/ui/select";
|
|
6
|
+
import { twMerge as m } from "tailwind-merge";
|
|
7
|
+
import { useTranslations as E } from "next-intl";
|
|
8
|
+
import { ChevronRight as F, ChevronLeft as G } from "lucide-react";
|
|
9
|
+
const N = 1e4;
|
|
10
|
+
function J({
|
|
11
|
+
className: k,
|
|
12
|
+
total: p,
|
|
13
|
+
pageSize: x,
|
|
14
|
+
pageSizeOptions: b = [10, 30, 50],
|
|
15
|
+
currentPage: r,
|
|
16
|
+
layout: u = ["prev", "page", "next", "ellipsis", "sizes", "total"],
|
|
17
|
+
onPageChange: t,
|
|
18
|
+
onPageSizeChange: h
|
|
19
|
+
}) {
|
|
20
|
+
const f = E(), w = Math.min(p, N), l = Math.ceil(w / x), M = () => {
|
|
21
|
+
const e = [];
|
|
22
|
+
let o = Math.max(1, r - Math.floor(1.5));
|
|
23
|
+
const n = Math.min(l, o + 3 - 1);
|
|
24
|
+
n - o + 1 < 3 && (o = Math.max(1, n - 3 + 1)), o > 1 && (e.push(
|
|
25
|
+
/* @__PURE__ */ i(s, { children: /* @__PURE__ */ i(
|
|
26
|
+
a,
|
|
27
|
+
{
|
|
28
|
+
size: "sm",
|
|
29
|
+
className: m(
|
|
30
|
+
"h-6 min-w-6 w-fit rounded-md cursor-pointer",
|
|
31
|
+
r === 1 ? "bg-[#000] text-[#fff]" : ""
|
|
32
|
+
),
|
|
33
|
+
onClick: () => t == null ? void 0 : t(1),
|
|
34
|
+
children: "1"
|
|
35
|
+
}
|
|
36
|
+
) }, "first")
|
|
37
|
+
), o > 2 && e.push(
|
|
38
|
+
/* @__PURE__ */ i(s, { children: /* @__PURE__ */ i(v, {}) }, "ellipsis-start")
|
|
39
|
+
));
|
|
40
|
+
for (let c = o; c <= n; c++)
|
|
41
|
+
e.push(
|
|
42
|
+
/* @__PURE__ */ i(s, { children: /* @__PURE__ */ i(
|
|
43
|
+
a,
|
|
44
|
+
{
|
|
45
|
+
size: "sm",
|
|
46
|
+
className: m(
|
|
47
|
+
"h-6 min-w-6 w-fit rounded-md cursor-pointer",
|
|
48
|
+
r === c ? "bg-[#000] text-[#fff]" : ""
|
|
49
|
+
),
|
|
50
|
+
onClick: () => t == null ? void 0 : t(c),
|
|
51
|
+
children: c
|
|
52
|
+
}
|
|
53
|
+
) }, c)
|
|
54
|
+
);
|
|
55
|
+
return n < l && (n < l - 1 && e.push(
|
|
56
|
+
/* @__PURE__ */ i(s, { className: "cursor-pointer", children: /* @__PURE__ */ i(v, {}) }, "ellipsis-end")
|
|
57
|
+
), e.push(
|
|
58
|
+
/* @__PURE__ */ i(s, { children: /* @__PURE__ */ i(
|
|
59
|
+
a,
|
|
60
|
+
{
|
|
61
|
+
size: "sm",
|
|
62
|
+
className: m(
|
|
63
|
+
"h-6 min-w-6 w-fit rounded-md cursor-pointer",
|
|
64
|
+
r === l ? "bg-[#000] text-[#fff]" : ""
|
|
65
|
+
),
|
|
66
|
+
onClick: () => t == null ? void 0 : t(l),
|
|
67
|
+
children: l
|
|
68
|
+
}
|
|
69
|
+
) }, "last")
|
|
70
|
+
)), e;
|
|
71
|
+
};
|
|
72
|
+
return w <= b[0] ? null : /* @__PURE__ */ i(z, { className: m("w-full max-w-[100vw] mt-3", k), children: /* @__PURE__ */ d(j, { className: "w-full flex flex-row items-center justify-between flex-wrap", children: [
|
|
73
|
+
u.includes("total") && /* @__PURE__ */ i(s, { className: "mr-auto order-1 flex-1 overflow-hidden md:overflow-visible md:order-0 ", children: /* @__PURE__ */ d("span", { className: "text-sm block text-subtitle w-full truncate", children: [
|
|
74
|
+
f("common.pagination.total"),
|
|
75
|
+
" ",
|
|
76
|
+
p,
|
|
77
|
+
" ",
|
|
78
|
+
f("common.pagination.item"),
|
|
79
|
+
p > N ? `${f("common.pagination.totalTip")}` : ""
|
|
80
|
+
] }) }, "total"),
|
|
81
|
+
/* @__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
|
+
switch (e) {
|
|
83
|
+
case "prev":
|
|
84
|
+
return /* @__PURE__ */ i(s, { children: /* @__PURE__ */ i(
|
|
85
|
+
a,
|
|
86
|
+
{
|
|
87
|
+
"aria-label": "Go to previous page",
|
|
88
|
+
size: "sm",
|
|
89
|
+
className: m(
|
|
90
|
+
"flex items-center justify-center pointer gap-1 shrink-0 cursor-pointer px-2",
|
|
91
|
+
r === 1 ? "pointer-events-none opacity-50" : ""
|
|
92
|
+
),
|
|
93
|
+
onClick: () => t == null ? void 0 : t(Math.max(1, r - 1)),
|
|
94
|
+
children: /* @__PURE__ */ i(G, { size: 16 })
|
|
95
|
+
}
|
|
96
|
+
) }, "prev");
|
|
97
|
+
case "page":
|
|
98
|
+
return /* @__PURE__ */ i(y.Fragment, { children: M() }, "page");
|
|
99
|
+
case "next":
|
|
100
|
+
return /* @__PURE__ */ i(s, { children: /* @__PURE__ */ i(
|
|
101
|
+
a,
|
|
102
|
+
{
|
|
103
|
+
size: "sm",
|
|
104
|
+
className: m(
|
|
105
|
+
"flex items-center justify-center pointer gap-1 shrink-0 cursor-pointer px-2",
|
|
106
|
+
r === l ? "pointer-events-none opacity-50" : ""
|
|
107
|
+
),
|
|
108
|
+
onClick: () => t == null ? void 0 : t(Math.min(l, r + 1)),
|
|
109
|
+
children: /* @__PURE__ */ i(F, { size: 16 })
|
|
110
|
+
}
|
|
111
|
+
) }, "next");
|
|
112
|
+
default:
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
}) }),
|
|
116
|
+
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: [
|
|
117
|
+
/* @__PURE__ */ i("span", { className: "text-sm text-muted-foreground", children: f("common.pagination.sizeLabel") }),
|
|
118
|
+
/* @__PURE__ */ d(
|
|
119
|
+
V,
|
|
120
|
+
{
|
|
121
|
+
value: x.toString(),
|
|
122
|
+
onValueChange: (e) => h(Number(e)),
|
|
123
|
+
children: [
|
|
124
|
+
/* @__PURE__ */ i(
|
|
125
|
+
S,
|
|
126
|
+
{
|
|
127
|
+
size: "sm",
|
|
128
|
+
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
|
+
children: /* @__PURE__ */ i(L, {})
|
|
130
|
+
}
|
|
131
|
+
),
|
|
132
|
+
/* @__PURE__ */ i(I, { className: "w-20 bg-module", children: b.map((e) => /* @__PURE__ */ i(R, { value: e.toString(), className: "text-sm px-2 py-1 cursor-pointer hover:bg-background", children: e }, e)) })
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
] }, "sizes")
|
|
137
|
+
] }) });
|
|
138
|
+
}
|
|
139
|
+
export {
|
|
140
|
+
J as default
|
|
141
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import nx from '@nx/eslint-plugin';
|
|
2
|
+
import baseConfig from '../../eslint.config.mjs';
|
|
3
|
+
|
|
4
|
+
export default [
|
|
5
|
+
...baseConfig,
|
|
6
|
+
...nx.configs['flat/react'],
|
|
7
|
+
{
|
|
8
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
|
|
9
|
+
// Override or add rules here
|
|
10
|
+
rules: {},
|
|
11
|
+
},
|
|
12
|
+
];
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ichaingo/pagination",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./package.json": "./package.json",
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"react": ">=18",
|
|
18
|
+
"react-dom": ">=18",
|
|
19
|
+
"next-intl": ">=4",
|
|
20
|
+
"tailwind-merge": "^2.5.5",
|
|
21
|
+
"lucide-react": "^0.539.0",
|
|
22
|
+
"@ichaingo/ui": "1.1.0"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"rollup-plugin-preserve-use-client": "^1.0.0"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import {
|
|
4
|
+
Pagination,
|
|
5
|
+
PaginationContent,
|
|
6
|
+
PaginationItem,
|
|
7
|
+
PaginationLink,
|
|
8
|
+
PaginationEllipsis,
|
|
9
|
+
} from "@ichaingo/ui/pagination";
|
|
10
|
+
import {
|
|
11
|
+
Select,
|
|
12
|
+
SelectContent,
|
|
13
|
+
SelectItem,
|
|
14
|
+
SelectTrigger,
|
|
15
|
+
SelectValue,
|
|
16
|
+
} from "@ichaingo/ui/select";
|
|
17
|
+
import { twMerge } from "tailwind-merge";
|
|
18
|
+
import { useTranslations } from "next-intl";
|
|
19
|
+
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
20
|
+
|
|
21
|
+
interface CustomPaginationProps {
|
|
22
|
+
className?: string;
|
|
23
|
+
total: number;
|
|
24
|
+
pageSize: number;
|
|
25
|
+
currentPage: number;
|
|
26
|
+
pageSizeOptions?: number[];
|
|
27
|
+
layout?: ('prev' | 'page' | 'next' | 'ellipsis' | 'sizes' | 'total')[];
|
|
28
|
+
onPageChange?: (page: number) => void;
|
|
29
|
+
onPageSizeChange?: (pageSize: number) => void;
|
|
30
|
+
}
|
|
31
|
+
const limit = 10000
|
|
32
|
+
export default function CustomPagination({
|
|
33
|
+
className,
|
|
34
|
+
total: initialTotal,
|
|
35
|
+
pageSize,
|
|
36
|
+
pageSizeOptions = [10, 30, 50],
|
|
37
|
+
currentPage,
|
|
38
|
+
layout = ['prev', 'page', 'next', 'ellipsis', 'sizes', 'total'],
|
|
39
|
+
onPageChange,
|
|
40
|
+
onPageSizeChange,
|
|
41
|
+
}: CustomPaginationProps) {
|
|
42
|
+
const t = useTranslations()
|
|
43
|
+
const total = Math.min(initialTotal, limit)
|
|
44
|
+
const totalPages = Math.ceil(total / pageSize);
|
|
45
|
+
|
|
46
|
+
const renderPageNumbers = () => {
|
|
47
|
+
const pages = [];
|
|
48
|
+
const maxVisiblePages = 3;
|
|
49
|
+
let startPage = Math.max(1, currentPage - Math.floor(maxVisiblePages / 2));
|
|
50
|
+
const endPage = Math.min(totalPages, startPage + maxVisiblePages - 1);
|
|
51
|
+
|
|
52
|
+
if (endPage - startPage + 1 < maxVisiblePages) {
|
|
53
|
+
startPage = Math.max(1, endPage - maxVisiblePages + 1);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Add first page and ellipsis if needed
|
|
57
|
+
if (startPage > 1) {
|
|
58
|
+
pages.push(
|
|
59
|
+
<PaginationItem key="first">
|
|
60
|
+
<PaginationLink
|
|
61
|
+
size="sm"
|
|
62
|
+
className={twMerge(
|
|
63
|
+
"h-6 min-w-6 w-fit rounded-md cursor-pointer",
|
|
64
|
+
currentPage === 1
|
|
65
|
+
? "bg-[#000] text-[#fff]"
|
|
66
|
+
: ""
|
|
67
|
+
)}
|
|
68
|
+
onClick={() => onPageChange?.(1)}
|
|
69
|
+
>
|
|
70
|
+
1
|
|
71
|
+
</PaginationLink>
|
|
72
|
+
</PaginationItem>
|
|
73
|
+
);
|
|
74
|
+
if (startPage > 2) {
|
|
75
|
+
pages.push(
|
|
76
|
+
<PaginationItem key="ellipsis-start">
|
|
77
|
+
<PaginationEllipsis />
|
|
78
|
+
</PaginationItem>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Add page numbers
|
|
84
|
+
for (let i = startPage; i <= endPage; i++) {
|
|
85
|
+
pages.push(
|
|
86
|
+
<PaginationItem key={i}>
|
|
87
|
+
<PaginationLink
|
|
88
|
+
size="sm"
|
|
89
|
+
className={twMerge(
|
|
90
|
+
"h-6 min-w-6 w-fit rounded-md cursor-pointer",
|
|
91
|
+
currentPage === i
|
|
92
|
+
? "bg-[#000] text-[#fff]"
|
|
93
|
+
: ""
|
|
94
|
+
)}
|
|
95
|
+
onClick={() => onPageChange?.(i)}
|
|
96
|
+
>
|
|
97
|
+
{i}
|
|
98
|
+
</PaginationLink>
|
|
99
|
+
</PaginationItem>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Add last page and ellipsis if needed
|
|
104
|
+
if (endPage < totalPages) {
|
|
105
|
+
if (endPage < totalPages - 1) {
|
|
106
|
+
pages.push(
|
|
107
|
+
<PaginationItem key="ellipsis-end" className="cursor-pointer">
|
|
108
|
+
<PaginationEllipsis />
|
|
109
|
+
</PaginationItem>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
pages.push(
|
|
113
|
+
<PaginationItem key="last">
|
|
114
|
+
<PaginationLink
|
|
115
|
+
size="sm"
|
|
116
|
+
className={twMerge(
|
|
117
|
+
"h-6 min-w-6 w-fit rounded-md cursor-pointer",
|
|
118
|
+
currentPage === totalPages
|
|
119
|
+
? "bg-[#000] text-[#fff]"
|
|
120
|
+
: ""
|
|
121
|
+
)}
|
|
122
|
+
onClick={() => onPageChange?.(totalPages)}
|
|
123
|
+
>
|
|
124
|
+
{totalPages}
|
|
125
|
+
</PaginationLink>
|
|
126
|
+
</PaginationItem>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return pages;
|
|
131
|
+
};
|
|
132
|
+
if (total <= pageSizeOptions[0]) {
|
|
133
|
+
return null
|
|
134
|
+
}
|
|
135
|
+
return (
|
|
136
|
+
<Pagination className={twMerge("w-full max-w-[100vw] mt-3", className)}>
|
|
137
|
+
<PaginationContent className="w-full flex flex-row items-center justify-between flex-wrap">
|
|
138
|
+
{layout.includes('total') && (
|
|
139
|
+
<PaginationItem key="total" className="mr-auto order-1 flex-1 overflow-hidden md:overflow-visible md:order-0 ">
|
|
140
|
+
<span className="text-sm block text-subtitle w-full truncate">
|
|
141
|
+
{t('common.pagination.total')} {initialTotal} {t('common.pagination.item')}
|
|
142
|
+
{initialTotal > limit ? `${t('common.pagination.totalTip')}` : ''}
|
|
143
|
+
</span>
|
|
144
|
+
</PaginationItem>
|
|
145
|
+
)}
|
|
146
|
+
<div className="w-full md:w-auto md:flex-2 flex items-center justify-center">
|
|
147
|
+
{layout.filter(item => item !== 'total' && item !== 'sizes').map((item) => {
|
|
148
|
+
switch (item) {
|
|
149
|
+
case 'prev':
|
|
150
|
+
return (
|
|
151
|
+
<PaginationItem key="prev">
|
|
152
|
+
<PaginationLink
|
|
153
|
+
aria-label="Go to previous page"
|
|
154
|
+
size="sm"
|
|
155
|
+
className={twMerge(
|
|
156
|
+
"flex items-center justify-center pointer gap-1 shrink-0 cursor-pointer px-2",
|
|
157
|
+
currentPage === 1 ? "pointer-events-none opacity-50" : "",
|
|
158
|
+
)}
|
|
159
|
+
onClick={() => onPageChange?.(Math.max(1, currentPage - 1))}
|
|
160
|
+
>
|
|
161
|
+
<ChevronLeft size={16} />
|
|
162
|
+
</PaginationLink>
|
|
163
|
+
</PaginationItem>
|
|
164
|
+
);
|
|
165
|
+
case 'page':
|
|
166
|
+
return <React.Fragment key="page">{renderPageNumbers()}</React.Fragment>;
|
|
167
|
+
case 'next':
|
|
168
|
+
return (
|
|
169
|
+
<PaginationItem key="next">
|
|
170
|
+
<PaginationLink
|
|
171
|
+
size="sm"
|
|
172
|
+
className={twMerge(
|
|
173
|
+
"flex items-center justify-center pointer gap-1 shrink-0 cursor-pointer px-2",
|
|
174
|
+
currentPage === totalPages ? "pointer-events-none opacity-50" : ""
|
|
175
|
+
)}
|
|
176
|
+
onClick={() => onPageChange?.(Math.min(totalPages, currentPage + 1))}
|
|
177
|
+
>
|
|
178
|
+
<ChevronRight size={16} />
|
|
179
|
+
</PaginationLink>
|
|
180
|
+
</PaginationItem>
|
|
181
|
+
);
|
|
182
|
+
default:
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
})}
|
|
186
|
+
</div>
|
|
187
|
+
{layout.includes('sizes') && onPageSizeChange && (
|
|
188
|
+
<PaginationItem key="sizes" className="gap-2 flex shrink-0 order-1 lg:order-0 items-center py-0.5 flex-1 justify-end">
|
|
189
|
+
<span className="text-sm text-muted-foreground">
|
|
190
|
+
{t('common.pagination.sizeLabel')}
|
|
191
|
+
</span>
|
|
192
|
+
<Select
|
|
193
|
+
value={pageSize.toString()}
|
|
194
|
+
onValueChange={(value: string) => onPageSizeChange(Number(value))}
|
|
195
|
+
>
|
|
196
|
+
<SelectTrigger
|
|
197
|
+
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">
|
|
198
|
+
<SelectValue />
|
|
199
|
+
</SelectTrigger>
|
|
200
|
+
<SelectContent className="w-20 bg-module">
|
|
201
|
+
{pageSizeOptions.map((size) => (
|
|
202
|
+
<SelectItem key={size} value={size.toString()} className="text-sm px-2 py-1 cursor-pointer hover:bg-background">
|
|
203
|
+
{size}
|
|
204
|
+
</SelectItem>
|
|
205
|
+
))}
|
|
206
|
+
</SelectContent>
|
|
207
|
+
</Select>
|
|
208
|
+
</PaginationItem>
|
|
209
|
+
)}
|
|
210
|
+
</PaginationContent>
|
|
211
|
+
</Pagination>
|
|
212
|
+
);
|
|
213
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "dist",
|
|
5
|
+
"types": [
|
|
6
|
+
"node",
|
|
7
|
+
"@nx/react/typings/cssmodule.d.ts",
|
|
8
|
+
"@nx/react/typings/image.d.ts",
|
|
9
|
+
"vite/client"
|
|
10
|
+
],
|
|
11
|
+
"rootDir": "src",
|
|
12
|
+
"jsx": "react-jsx",
|
|
13
|
+
"module": "esnext",
|
|
14
|
+
"moduleResolution": "bundler",
|
|
15
|
+
"tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo"
|
|
16
|
+
},
|
|
17
|
+
"exclude": [
|
|
18
|
+
"out-tsc",
|
|
19
|
+
"dist",
|
|
20
|
+
"**/*.spec.ts",
|
|
21
|
+
"**/*.test.ts",
|
|
22
|
+
"**/*.spec.tsx",
|
|
23
|
+
"**/*.test.tsx",
|
|
24
|
+
"**/*.spec.js",
|
|
25
|
+
"**/*.test.js",
|
|
26
|
+
"**/*.spec.jsx",
|
|
27
|
+
"**/*.test.jsx",
|
|
28
|
+
"vite.config.ts",
|
|
29
|
+
"vite.config.mts",
|
|
30
|
+
"vitest.config.ts",
|
|
31
|
+
"vitest.config.mts",
|
|
32
|
+
"src/**/*.test.ts",
|
|
33
|
+
"src/**/*.spec.ts",
|
|
34
|
+
"src/**/*.test.tsx",
|
|
35
|
+
"src/**/*.spec.tsx",
|
|
36
|
+
"src/**/*.test.js",
|
|
37
|
+
"src/**/*.spec.js",
|
|
38
|
+
"src/**/*.test.jsx",
|
|
39
|
+
"src/**/*.spec.jsx",
|
|
40
|
+
"eslint.config.js",
|
|
41
|
+
"eslint.config.cjs",
|
|
42
|
+
"eslint.config.mjs"
|
|
43
|
+
],
|
|
44
|
+
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"],
|
|
45
|
+
"references": [
|
|
46
|
+
{
|
|
47
|
+
"path": "../ui/tsconfig.lib.json"
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "./out-tsc/vitest",
|
|
5
|
+
"types": [
|
|
6
|
+
"vitest/globals",
|
|
7
|
+
"vitest/importMeta",
|
|
8
|
+
"vite/client",
|
|
9
|
+
"node",
|
|
10
|
+
"vitest"
|
|
11
|
+
],
|
|
12
|
+
"jsx": "react-jsx",
|
|
13
|
+
"module": "esnext",
|
|
14
|
+
"moduleResolution": "bundler"
|
|
15
|
+
},
|
|
16
|
+
"include": [
|
|
17
|
+
"vite.config.ts",
|
|
18
|
+
"vite.config.mts",
|
|
19
|
+
"vitest.config.ts",
|
|
20
|
+
"vitest.config.mts",
|
|
21
|
+
"src/**/*.test.ts",
|
|
22
|
+
"src/**/*.spec.ts",
|
|
23
|
+
"src/**/*.test.tsx",
|
|
24
|
+
"src/**/*.spec.tsx",
|
|
25
|
+
"src/**/*.test.js",
|
|
26
|
+
"src/**/*.spec.js",
|
|
27
|
+
"src/**/*.test.jsx",
|
|
28
|
+
"src/**/*.spec.jsx",
|
|
29
|
+
"src/**/*.d.ts"
|
|
30
|
+
],
|
|
31
|
+
"references": [
|
|
32
|
+
{
|
|
33
|
+
"path": "./tsconfig.lib.json"
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/// <reference types='vitest' />
|
|
2
|
+
import { defineConfig } from 'vite';
|
|
3
|
+
import react from '@vitejs/plugin-react';
|
|
4
|
+
import dts from 'vite-plugin-dts';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
import preserveUseClientDirective from 'rollup-plugin-preserve-use-client';
|
|
7
|
+
|
|
8
|
+
export default defineConfig(() => ({
|
|
9
|
+
root: __dirname,
|
|
10
|
+
cacheDir: '../../node_modules/.vite/packages/pagination',
|
|
11
|
+
plugins: [
|
|
12
|
+
react(),
|
|
13
|
+
preserveUseClientDirective(),
|
|
14
|
+
dts({
|
|
15
|
+
entryRoot: 'src',
|
|
16
|
+
tsconfigPath: path.join(__dirname, 'tsconfig.lib.json')
|
|
17
|
+
}),
|
|
18
|
+
],
|
|
19
|
+
// Uncomment this if you are using workers.
|
|
20
|
+
// worker: {
|
|
21
|
+
// plugins: [ nxViteTsPaths() ],
|
|
22
|
+
// },
|
|
23
|
+
// Configuration for building your library.
|
|
24
|
+
// See: https://vitejs.dev/guide/build.html#library-mode
|
|
25
|
+
build: {
|
|
26
|
+
outDir: './dist',
|
|
27
|
+
emptyOutDir: true,
|
|
28
|
+
minify: true,
|
|
29
|
+
reportCompressedSize: true,
|
|
30
|
+
commonjsOptions: {
|
|
31
|
+
transformMixedEsModules: true,
|
|
32
|
+
},
|
|
33
|
+
lib: {
|
|
34
|
+
// Could also be a dictionary or array of multiple entry points.
|
|
35
|
+
entry: 'src/index.tsx',
|
|
36
|
+
name: '@ichaingo/pagination',
|
|
37
|
+
fileName: 'index',
|
|
38
|
+
// Change this to the formats you want to support.
|
|
39
|
+
// Don't forget to update your package.json as well.
|
|
40
|
+
formats: ['es' as const],
|
|
41
|
+
},
|
|
42
|
+
rollupOptions: {
|
|
43
|
+
// External packages that should not be bundled into your library.
|
|
44
|
+
external: [
|
|
45
|
+
'react', 'react-dom', 'react/jsx-runtime', 'tailwind-merge', 'lucide-react', 'next-intl',
|
|
46
|
+
/^@ichaingo\/.+/,
|
|
47
|
+
/^@radix-ui\/.+/,
|
|
48
|
+
'next-themes',
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
test: {
|
|
53
|
+
name: '@ichaingo/pagination',
|
|
54
|
+
watch: false,
|
|
55
|
+
globals: true,
|
|
56
|
+
environment: 'jsdom',
|
|
57
|
+
include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
58
|
+
reporters: ['default'],
|
|
59
|
+
coverage: {
|
|
60
|
+
reportsDirectory: './test-output/vitest/coverage',
|
|
61
|
+
provider: 'v8' as const,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
}));
|