@mijn-ui/react-pagination 0.0.11 → 0.0.13
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.d.ts +8 -8
- package/dist/index.js +68 -18
- package/dist/metafile-esm.json +1 -1
- package/package.json +9 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { UnstyledProps } from '@mijn-ui/react-
|
|
4
|
-
import { paginationStyles } from '@mijn-ui/react-theme';
|
|
3
|
+
import { UnstyledComponentWithSlots, PaginationSlots, paginationStyles, UnstyledProps } from '@mijn-ui/react-theme';
|
|
5
4
|
|
|
6
|
-
type
|
|
5
|
+
type PaginationBaseProps = UnstyledComponentWithSlots<PaginationSlots>;
|
|
6
|
+
type PaginationContextType = PaginationBaseProps & {
|
|
7
7
|
styles: ReturnType<typeof paginationStyles>;
|
|
8
8
|
paginationRange: number[];
|
|
9
9
|
currentPage: number;
|
|
@@ -12,7 +12,7 @@ type PaginationContextType = {
|
|
|
12
12
|
setPage: (page: number) => void;
|
|
13
13
|
goToPreviousPage: () => void;
|
|
14
14
|
goToNextPage: () => void;
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
16
|
declare const usePaginationContext: () => PaginationContextType;
|
|
17
17
|
type PaginationProps = {
|
|
18
18
|
totalPages: number;
|
|
@@ -20,7 +20,7 @@ type PaginationProps = {
|
|
|
20
20
|
children: React.ReactNode;
|
|
21
21
|
currentPage?: number;
|
|
22
22
|
onChangePage?: (page: number) => void;
|
|
23
|
-
} &
|
|
23
|
+
} & PaginationBaseProps;
|
|
24
24
|
declare const Pagination: React.FC<PaginationProps>;
|
|
25
25
|
type PaginationContentProps = React.ComponentPropsWithRef<"nav"> & UnstyledProps;
|
|
26
26
|
declare const PaginationContent: ({ className, unstyled, ...props }: PaginationContentProps) => react_jsx_runtime.JSX.Element;
|
|
@@ -31,8 +31,8 @@ declare const PaginationPreviousButton: ({ className, unstyled, ...props }: Pagi
|
|
|
31
31
|
type PaginationNextButtonProps = React.ComponentProps<"button"> & UnstyledProps;
|
|
32
32
|
declare const PaginationNextButton: ({ className, unstyled, ...props }: PaginationNextButtonProps) => react_jsx_runtime.JSX.Element;
|
|
33
33
|
type PaginationPreviousEllipsisProps = React.ComponentProps<"span"> & UnstyledProps;
|
|
34
|
-
declare const PaginationPreviousEllipsis: ({ className, unstyled, ...props }: PaginationPreviousEllipsisProps) => react_jsx_runtime.JSX.Element |
|
|
34
|
+
declare const PaginationPreviousEllipsis: ({ className, unstyled, ...props }: PaginationPreviousEllipsisProps) => react_jsx_runtime.JSX.Element | null;
|
|
35
35
|
type PaginationNextEllipsisProps = React.ComponentProps<"span"> & UnstyledProps;
|
|
36
|
-
declare const PaginationNextEllipsis: ({ className, unstyled, ...props }: PaginationNextEllipsisProps) => react_jsx_runtime.JSX.Element |
|
|
36
|
+
declare const PaginationNextEllipsis: ({ className, unstyled, ...props }: PaginationNextEllipsisProps) => react_jsx_runtime.JSX.Element | null;
|
|
37
37
|
|
|
38
|
-
export { Pagination, PaginationContent, PaginationList, PaginationNextButton, PaginationNextEllipsis, PaginationPreviousButton, PaginationPreviousEllipsis, usePaginationContext };
|
|
38
|
+
export { Pagination, PaginationContent, PaginationList, PaginationNextButton, PaginationNextEllipsis, PaginationPreviousButton, PaginationPreviousEllipsis, type PaginationProps, usePaginationContext };
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
// src/pagination.tsx
|
|
4
4
|
import * as React from "react";
|
|
5
|
+
import { useTVUnstyled } from "@mijn-ui/react-hooks";
|
|
6
|
+
import {
|
|
7
|
+
cn,
|
|
8
|
+
paginationStyles
|
|
9
|
+
} from "@mijn-ui/react-theme";
|
|
5
10
|
import { createContext } from "@mijn-ui/react-utilities";
|
|
6
11
|
import { EllipsisIcon } from "@mijn-ui/shared-icons";
|
|
7
|
-
import { paginationStyles } from "@mijn-ui/react-theme";
|
|
8
|
-
import { useTVUnstyled } from "@mijn-ui/react-hooks";
|
|
9
12
|
import { jsx } from "react/jsx-runtime";
|
|
10
13
|
var [PaginationProvider, usePaginationContext] = createContext({
|
|
11
14
|
name: "PaginationContext",
|
|
@@ -54,7 +57,8 @@ var usePaginationRange = ({
|
|
|
54
57
|
};
|
|
55
58
|
var usePaginationStyles = (unstyledOverride) => {
|
|
56
59
|
const context = usePaginationContext();
|
|
57
|
-
|
|
60
|
+
const unstyledSlots = useTVUnstyled(context, unstyledOverride);
|
|
61
|
+
return { ...unstyledSlots, classNames: context.classNames };
|
|
58
62
|
};
|
|
59
63
|
var Pagination = ({
|
|
60
64
|
unstyled = false,
|
|
@@ -62,7 +66,8 @@ var Pagination = ({
|
|
|
62
66
|
itemsPerPage,
|
|
63
67
|
children,
|
|
64
68
|
currentPage: propsCurrentPage,
|
|
65
|
-
onChangePage
|
|
69
|
+
onChangePage,
|
|
70
|
+
classNames
|
|
66
71
|
}) => {
|
|
67
72
|
const [internalCurrentPage, setInternalCurrentPage] = React.useState(1);
|
|
68
73
|
const isControlled = propsCurrentPage !== void 0;
|
|
@@ -93,6 +98,7 @@ var Pagination = ({
|
|
|
93
98
|
value: {
|
|
94
99
|
unstyled,
|
|
95
100
|
styles,
|
|
101
|
+
classNames,
|
|
96
102
|
paginationRange: paginationRange.range,
|
|
97
103
|
prevEllipsisActive: paginationRange.prevEllipsisActive,
|
|
98
104
|
nextEllipsisActive: paginationRange.nextEllipsisActive,
|
|
@@ -110,8 +116,14 @@ var PaginationContent = ({
|
|
|
110
116
|
unstyled,
|
|
111
117
|
...props
|
|
112
118
|
}) => {
|
|
113
|
-
const { content } = usePaginationStyles(unstyled);
|
|
114
|
-
return /* @__PURE__ */ jsx(
|
|
119
|
+
const { content, classNames } = usePaginationStyles(unstyled);
|
|
120
|
+
return /* @__PURE__ */ jsx(
|
|
121
|
+
"nav",
|
|
122
|
+
{
|
|
123
|
+
className: content({ className: cn(classNames?.content, className) }),
|
|
124
|
+
...props
|
|
125
|
+
}
|
|
126
|
+
);
|
|
115
127
|
};
|
|
116
128
|
var PaginationList = ({
|
|
117
129
|
className,
|
|
@@ -119,8 +131,24 @@ var PaginationList = ({
|
|
|
119
131
|
...props
|
|
120
132
|
}) => {
|
|
121
133
|
const { currentPage, setPage, paginationRange } = usePaginationContext();
|
|
122
|
-
const { list, item } = usePaginationStyles(unstyled);
|
|
123
|
-
return /* @__PURE__ */ jsx(
|
|
134
|
+
const { list, item, classNames } = usePaginationStyles(unstyled);
|
|
135
|
+
return /* @__PURE__ */ jsx(
|
|
136
|
+
"ul",
|
|
137
|
+
{
|
|
138
|
+
className: list({ className: cn(classNames?.list, className) }),
|
|
139
|
+
...props,
|
|
140
|
+
children: paginationRange.map((page, index) => /* @__PURE__ */ jsx("li", { onClick: () => setPage(page), children: /* @__PURE__ */ jsx(
|
|
141
|
+
"button",
|
|
142
|
+
{
|
|
143
|
+
className: item({
|
|
144
|
+
active: currentPage === page,
|
|
145
|
+
className: classNames?.item
|
|
146
|
+
}),
|
|
147
|
+
children: page
|
|
148
|
+
}
|
|
149
|
+
) }, index))
|
|
150
|
+
}
|
|
151
|
+
);
|
|
124
152
|
};
|
|
125
153
|
var PaginationPreviousButton = ({
|
|
126
154
|
className,
|
|
@@ -128,12 +156,14 @@ var PaginationPreviousButton = ({
|
|
|
128
156
|
...props
|
|
129
157
|
}) => {
|
|
130
158
|
const { goToPreviousPage } = usePaginationContext();
|
|
131
|
-
const { previousBtn } = usePaginationStyles(unstyled);
|
|
159
|
+
const { previousBtn, classNames } = usePaginationStyles(unstyled);
|
|
132
160
|
return /* @__PURE__ */ jsx(
|
|
133
161
|
"button",
|
|
134
162
|
{
|
|
135
163
|
onClick: goToPreviousPage,
|
|
136
|
-
className: previousBtn({
|
|
164
|
+
className: previousBtn({
|
|
165
|
+
className: cn(classNames?.previousBtn, className)
|
|
166
|
+
}),
|
|
137
167
|
...props
|
|
138
168
|
}
|
|
139
169
|
);
|
|
@@ -144,12 +174,12 @@ var PaginationNextButton = ({
|
|
|
144
174
|
...props
|
|
145
175
|
}) => {
|
|
146
176
|
const { goToNextPage } = usePaginationContext();
|
|
147
|
-
const { nextBtn } = usePaginationStyles(unstyled);
|
|
177
|
+
const { nextBtn, classNames } = usePaginationStyles(unstyled);
|
|
148
178
|
return /* @__PURE__ */ jsx(
|
|
149
179
|
"button",
|
|
150
180
|
{
|
|
151
181
|
onClick: goToNextPage,
|
|
152
|
-
className: nextBtn({ className }),
|
|
182
|
+
className: nextBtn({ className: cn(classNames?.nextBtn, className) }),
|
|
153
183
|
...props
|
|
154
184
|
}
|
|
155
185
|
);
|
|
@@ -160,9 +190,19 @@ var PaginationPreviousEllipsis = ({
|
|
|
160
190
|
...props
|
|
161
191
|
}) => {
|
|
162
192
|
const { prevEllipsisActive } = usePaginationContext();
|
|
163
|
-
const { previousElipsis } = usePaginationStyles(unstyled);
|
|
164
|
-
if (!prevEllipsisActive) return;
|
|
165
|
-
return /* @__PURE__ */ jsx(
|
|
193
|
+
const { previousElipsis, classNames } = usePaginationStyles(unstyled);
|
|
194
|
+
if (!prevEllipsisActive) return null;
|
|
195
|
+
return /* @__PURE__ */ jsx(
|
|
196
|
+
"span",
|
|
197
|
+
{
|
|
198
|
+
"aria-hidden": true,
|
|
199
|
+
className: previousElipsis({
|
|
200
|
+
className: cn(classNames?.previousElipsis, className)
|
|
201
|
+
}),
|
|
202
|
+
...props,
|
|
203
|
+
children: /* @__PURE__ */ jsx(EllipsisIcon, { className: "size-4" })
|
|
204
|
+
}
|
|
205
|
+
);
|
|
166
206
|
};
|
|
167
207
|
var PaginationNextEllipsis = ({
|
|
168
208
|
className,
|
|
@@ -170,9 +210,19 @@ var PaginationNextEllipsis = ({
|
|
|
170
210
|
...props
|
|
171
211
|
}) => {
|
|
172
212
|
const { nextEllipsisActive } = usePaginationContext();
|
|
173
|
-
const { nextElipsis } = usePaginationStyles(unstyled);
|
|
174
|
-
if (!nextEllipsisActive) return;
|
|
175
|
-
return /* @__PURE__ */ jsx(
|
|
213
|
+
const { nextElipsis, classNames } = usePaginationStyles(unstyled);
|
|
214
|
+
if (!nextEllipsisActive) return null;
|
|
215
|
+
return /* @__PURE__ */ jsx(
|
|
216
|
+
"span",
|
|
217
|
+
{
|
|
218
|
+
"aria-hidden": true,
|
|
219
|
+
className: nextElipsis({
|
|
220
|
+
className: cn(classNames?.nextElipsis, className)
|
|
221
|
+
}),
|
|
222
|
+
...props,
|
|
223
|
+
children: /* @__PURE__ */ jsx(EllipsisIcon, { className: "size-4" })
|
|
224
|
+
}
|
|
225
|
+
);
|
|
176
226
|
};
|
|
177
227
|
export {
|
|
178
228
|
Pagination,
|
package/dist/metafile-esm.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/pagination.tsx":{"bytes":
|
|
1
|
+
{"inputs":{"src/pagination.tsx":{"bytes":10034,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@mijn-ui/react-hooks","kind":"import-statement","external":true},{"path":"@mijn-ui/react-theme","kind":"import-statement","external":true},{"path":"@mijn-ui/react-utilities","kind":"import-statement","external":true},{"path":"@mijn-ui/shared-icons","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":29,"imports":[{"path":"src/pagination.tsx","kind":"import-statement","original":"./pagination"}],"format":"esm"}},"outputs":{"dist/index.js":{"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@mijn-ui/react-hooks","kind":"import-statement","external":true},{"path":"@mijn-ui/react-theme","kind":"import-statement","external":true},{"path":"@mijn-ui/react-utilities","kind":"import-statement","external":true},{"path":"@mijn-ui/shared-icons","kind":"import-statement","external":true},{"path":"react/jsx-runtime","kind":"import-statement","external":true}],"exports":["Pagination","PaginationContent","PaginationList","PaginationNextButton","PaginationNextEllipsis","PaginationPreviousButton","PaginationPreviousEllipsis","usePaginationContext"],"entryPoint":"src/index.ts","inputs":{"src/pagination.tsx":{"bytesInOutput":6073},"src/index.ts":{"bytesInOutput":0}},"bytes":6291}}}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mijn-ui/react-pagination",
|
|
3
3
|
"author": "Htet Aung Lin<htetaunglin.coder@gmail.com>",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.13",
|
|
5
5
|
"homepage": "https://mijn-ui.vercel.app",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -22,24 +22,26 @@
|
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"react": "19.0.0",
|
|
24
24
|
"react-dom": "19.0.0",
|
|
25
|
+
"react-icons": "^5.3.0",
|
|
25
26
|
"@next/eslint-plugin-next": "^15.0.3",
|
|
26
27
|
"@types/react": "^19.0.0",
|
|
27
28
|
"@types/react-dom": "^19.0.0",
|
|
28
|
-
"@mijn-ui/react-core": "0.0.
|
|
29
|
+
"@mijn-ui/react-core": "0.0.4",
|
|
30
|
+
"@mijn-ui/react-theme": "0.0.9",
|
|
29
31
|
"eslint-config-custom": "0.0.1",
|
|
30
32
|
"tsconfig": "0.0.0",
|
|
31
33
|
"tsup-config": "0.0.0"
|
|
32
34
|
},
|
|
33
35
|
"dependencies": {
|
|
34
|
-
"@mijn-ui/shared-icons": "0.0.
|
|
35
|
-
"@mijn-ui/react-utilities": "0.0.
|
|
36
|
-
"@mijn-ui/react-hooks": "0.0.
|
|
36
|
+
"@mijn-ui/shared-icons": "0.0.4",
|
|
37
|
+
"@mijn-ui/react-utilities": "0.0.9",
|
|
38
|
+
"@mijn-ui/react-hooks": "0.0.11"
|
|
37
39
|
},
|
|
38
40
|
"peerDependencies": {
|
|
39
41
|
"react": "^19.0",
|
|
40
42
|
"react-dom": "^19.0",
|
|
41
|
-
"@mijn-ui/react-theme": "^0.0.
|
|
42
|
-
"@mijn-ui/react-core": "^0.0.
|
|
43
|
+
"@mijn-ui/react-theme": "^0.0.9",
|
|
44
|
+
"@mijn-ui/react-core": "^0.0.4"
|
|
43
45
|
},
|
|
44
46
|
"publishConfig": {
|
|
45
47
|
"access": "public"
|