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