@mijn-ui/react-pagination 0.0.8 → 0.0.10
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/README.md +0 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.js +36 -116
- package/dist/metafile-esm.json +1 -1
- package/package.json +12 -10
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +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-
|
|
3
|
+
import { UnstyledProps } from '@mijn-ui/react-core';
|
|
4
|
+
import { paginationStyles } from '@mijn-ui/react-theme';
|
|
4
5
|
|
|
5
6
|
type PaginationContextType = {
|
|
7
|
+
styles: ReturnType<typeof paginationStyles>;
|
|
6
8
|
paginationRange: number[];
|
|
7
9
|
currentPage: number;
|
|
8
10
|
prevEllipsisActive: boolean;
|
|
@@ -10,7 +12,8 @@ type PaginationContextType = {
|
|
|
10
12
|
setPage: (page: number) => void;
|
|
11
13
|
goToPreviousPage: () => void;
|
|
12
14
|
goToNextPage: () => void;
|
|
13
|
-
};
|
|
15
|
+
} & UnstyledProps;
|
|
16
|
+
declare const usePaginationContext: () => PaginationContextType;
|
|
14
17
|
type PaginationProps = {
|
|
15
18
|
totalPages: number;
|
|
16
19
|
itemsPerPage: number;
|
|
@@ -19,7 +22,6 @@ type PaginationProps = {
|
|
|
19
22
|
onChangePage?: (page: number) => void;
|
|
20
23
|
} & UnstyledProps;
|
|
21
24
|
declare const Pagination: React.FC<PaginationProps>;
|
|
22
|
-
declare const usePagination: () => PaginationContextType;
|
|
23
25
|
type PaginationContentProps = React.ComponentPropsWithRef<"nav"> & UnstyledProps;
|
|
24
26
|
declare const PaginationContent: ({ className, unstyled, ...props }: PaginationContentProps) => react_jsx_runtime.JSX.Element;
|
|
25
27
|
type PaginationListProps = React.ComponentProps<"ul"> & UnstyledProps;
|
|
@@ -33,4 +35,4 @@ declare const PaginationPreviousEllipsis: ({ className, unstyled, ...props }: Pa
|
|
|
33
35
|
type PaginationNextEllipsisProps = React.ComponentProps<"span"> & UnstyledProps;
|
|
34
36
|
declare const PaginationNextEllipsis: ({ className, unstyled, ...props }: PaginationNextEllipsisProps) => react_jsx_runtime.JSX.Element | undefined;
|
|
35
37
|
|
|
36
|
-
export { Pagination, PaginationContent, PaginationList, PaginationNextButton, PaginationNextEllipsis, PaginationPreviousButton, PaginationPreviousEllipsis,
|
|
38
|
+
export { Pagination, PaginationContent, PaginationList, PaginationNextButton, PaginationNextEllipsis, PaginationPreviousButton, PaginationPreviousEllipsis, usePaginationContext };
|
package/dist/index.js
CHANGED
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
// src/pagination.tsx
|
|
4
4
|
import * as React from "react";
|
|
5
|
-
import {
|
|
6
|
-
import { UnstyledProvider, useUnstyled } from "@mijn-ui/react-utilities/context";
|
|
7
|
-
import { applyUnstyled } from "@mijn-ui/react-utilities/shared";
|
|
5
|
+
import { createContext } from "@mijn-ui/react-utilities";
|
|
8
6
|
import { EllipsisIcon } from "@mijn-ui/shared-icons";
|
|
7
|
+
import { paginationStyles } from "@mijn-ui/react-theme";
|
|
8
|
+
import { useTVUnstyled } from "@mijn-ui/react-hooks";
|
|
9
9
|
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
var [PaginationProvider, usePaginationContext] = createContext({
|
|
11
|
+
name: "PaginationContext",
|
|
12
|
+
strict: true,
|
|
13
|
+
errorMessage: "usePaginationContext: `context` is undefined. Seems you forgot to wrap component within <Pagination />"
|
|
14
|
+
});
|
|
10
15
|
var usePaginationRange = ({
|
|
11
16
|
totalPages,
|
|
12
17
|
itemsPerPage,
|
|
@@ -47,7 +52,10 @@ var usePaginationRange = ({
|
|
|
47
52
|
nextEllipsisActive: rightBound < totalPageCount
|
|
48
53
|
};
|
|
49
54
|
};
|
|
50
|
-
var
|
|
55
|
+
var usePaginationStyles = (unstyledOverride) => {
|
|
56
|
+
const context = usePaginationContext();
|
|
57
|
+
return useTVUnstyled(context, unstyledOverride);
|
|
58
|
+
};
|
|
51
59
|
var Pagination = ({
|
|
52
60
|
unstyled = false,
|
|
53
61
|
totalPages,
|
|
@@ -78,106 +86,54 @@ var Pagination = ({
|
|
|
78
86
|
setInternalCurrentPage(propsCurrentPage);
|
|
79
87
|
}
|
|
80
88
|
}, [propsCurrentPage, isControlled]);
|
|
89
|
+
const styles = paginationStyles();
|
|
81
90
|
return /* @__PURE__ */ jsx(
|
|
82
|
-
|
|
91
|
+
PaginationProvider,
|
|
83
92
|
{
|
|
84
93
|
value: {
|
|
94
|
+
unstyled,
|
|
95
|
+
styles,
|
|
85
96
|
paginationRange: paginationRange.range,
|
|
86
|
-
currentPage,
|
|
87
97
|
prevEllipsisActive: paginationRange.prevEllipsisActive,
|
|
88
98
|
nextEllipsisActive: paginationRange.nextEllipsisActive,
|
|
99
|
+
currentPage,
|
|
89
100
|
setPage,
|
|
90
101
|
goToPreviousPage,
|
|
91
102
|
goToNextPage
|
|
92
103
|
},
|
|
93
|
-
children
|
|
104
|
+
children
|
|
94
105
|
}
|
|
95
106
|
);
|
|
96
107
|
};
|
|
97
|
-
var usePagination = () => {
|
|
98
|
-
const context = React.useContext(PaginationContext);
|
|
99
|
-
if (context === void 0) {
|
|
100
|
-
throw new Error(
|
|
101
|
-
"usePaginationContext must be used within a PaginationProvider"
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
return context;
|
|
105
|
-
};
|
|
106
108
|
var PaginationContent = ({
|
|
107
109
|
className,
|
|
108
110
|
unstyled,
|
|
109
111
|
...props
|
|
110
112
|
}) => {
|
|
111
|
-
const {
|
|
112
|
-
|
|
113
|
-
return /* @__PURE__ */ jsx(
|
|
114
|
-
"nav",
|
|
115
|
-
{
|
|
116
|
-
className: applyUnstyled(
|
|
117
|
-
isUnstyled,
|
|
118
|
-
"flex items-center gap-2",
|
|
119
|
-
className
|
|
120
|
-
),
|
|
121
|
-
...props
|
|
122
|
-
}
|
|
123
|
-
);
|
|
113
|
+
const { content } = usePaginationStyles(unstyled);
|
|
114
|
+
return /* @__PURE__ */ jsx("nav", { className: content({ className }), ...props });
|
|
124
115
|
};
|
|
125
116
|
var PaginationList = ({
|
|
126
117
|
className,
|
|
127
118
|
unstyled,
|
|
128
119
|
...props
|
|
129
120
|
}) => {
|
|
130
|
-
const { currentPage, setPage, paginationRange } =
|
|
131
|
-
const {
|
|
132
|
-
|
|
133
|
-
return /* @__PURE__ */ jsx(
|
|
134
|
-
"ul",
|
|
135
|
-
{
|
|
136
|
-
className: applyUnstyled(
|
|
137
|
-
isUnstyled,
|
|
138
|
-
"flex flex-row items-center gap-1",
|
|
139
|
-
className
|
|
140
|
-
),
|
|
141
|
-
...props,
|
|
142
|
-
children: paginationRange.map((page, index) => /* @__PURE__ */ jsx("li", { onClick: () => setPage(page), children: /* @__PURE__ */ jsx(
|
|
143
|
-
"button",
|
|
144
|
-
{
|
|
145
|
-
className: applyUnstyled(
|
|
146
|
-
isUnstyled,
|
|
147
|
-
buttonStyles({
|
|
148
|
-
variant: page === currentPage ? "outline" : "text",
|
|
149
|
-
color: "accent",
|
|
150
|
-
size: "icon"
|
|
151
|
-
})
|
|
152
|
-
),
|
|
153
|
-
children: page
|
|
154
|
-
}
|
|
155
|
-
) }, index))
|
|
156
|
-
}
|
|
157
|
-
);
|
|
121
|
+
const { currentPage, setPage, paginationRange } = usePaginationContext();
|
|
122
|
+
const { list, item } = usePaginationStyles(unstyled);
|
|
123
|
+
return /* @__PURE__ */ jsx("ul", { className: list({ className }), ...props, children: paginationRange.map((page, index) => /* @__PURE__ */ jsx("li", { onClick: () => setPage(page), children: /* @__PURE__ */ jsx("button", { className: item({ active: currentPage === page }), children: page }) }, index)) });
|
|
158
124
|
};
|
|
159
125
|
var PaginationPreviousButton = ({
|
|
160
126
|
className,
|
|
161
127
|
unstyled,
|
|
162
128
|
...props
|
|
163
129
|
}) => {
|
|
164
|
-
const { goToPreviousPage } =
|
|
165
|
-
const {
|
|
166
|
-
const isUnstyled = unstyled ?? contextUnstyled;
|
|
130
|
+
const { goToPreviousPage } = usePaginationContext();
|
|
131
|
+
const { previousBtn } = usePaginationStyles(unstyled);
|
|
167
132
|
return /* @__PURE__ */ jsx(
|
|
168
133
|
"button",
|
|
169
134
|
{
|
|
170
135
|
onClick: goToPreviousPage,
|
|
171
|
-
className:
|
|
172
|
-
isUnstyled,
|
|
173
|
-
buttonStyles({
|
|
174
|
-
variant: "text",
|
|
175
|
-
color: "accent",
|
|
176
|
-
size: "md",
|
|
177
|
-
className: "gap-1 font-medium"
|
|
178
|
-
}),
|
|
179
|
-
className
|
|
180
|
-
),
|
|
136
|
+
className: previousBtn({ className }),
|
|
181
137
|
...props
|
|
182
138
|
}
|
|
183
139
|
);
|
|
@@ -187,23 +143,13 @@ var PaginationNextButton = ({
|
|
|
187
143
|
unstyled,
|
|
188
144
|
...props
|
|
189
145
|
}) => {
|
|
190
|
-
const { goToNextPage } =
|
|
191
|
-
const {
|
|
192
|
-
const isUnstyled = unstyled ?? contextUnstyled;
|
|
146
|
+
const { goToNextPage } = usePaginationContext();
|
|
147
|
+
const { nextBtn } = usePaginationStyles(unstyled);
|
|
193
148
|
return /* @__PURE__ */ jsx(
|
|
194
149
|
"button",
|
|
195
150
|
{
|
|
196
151
|
onClick: goToNextPage,
|
|
197
|
-
className:
|
|
198
|
-
isUnstyled,
|
|
199
|
-
buttonStyles({
|
|
200
|
-
variant: "text",
|
|
201
|
-
color: "accent",
|
|
202
|
-
size: "md",
|
|
203
|
-
className: "gap-1 pl-2.5 font-medium"
|
|
204
|
-
}),
|
|
205
|
-
className
|
|
206
|
-
),
|
|
152
|
+
className: nextBtn({ className }),
|
|
207
153
|
...props
|
|
208
154
|
}
|
|
209
155
|
);
|
|
@@ -213,46 +159,20 @@ var PaginationPreviousEllipsis = ({
|
|
|
213
159
|
unstyled,
|
|
214
160
|
...props
|
|
215
161
|
}) => {
|
|
216
|
-
const { prevEllipsisActive } =
|
|
217
|
-
const {
|
|
218
|
-
const isUnstyled = unstyled ?? contextUnstyled;
|
|
162
|
+
const { prevEllipsisActive } = usePaginationContext();
|
|
163
|
+
const { previousElipsis } = usePaginationStyles(unstyled);
|
|
219
164
|
if (!prevEllipsisActive) return;
|
|
220
|
-
return /* @__PURE__ */ jsx(
|
|
221
|
-
"span",
|
|
222
|
-
{
|
|
223
|
-
"aria-hidden": true,
|
|
224
|
-
className: applyUnstyled(
|
|
225
|
-
isUnstyled,
|
|
226
|
-
"flex h-9 w-9 items-center justify-center",
|
|
227
|
-
className
|
|
228
|
-
),
|
|
229
|
-
...props,
|
|
230
|
-
children: /* @__PURE__ */ jsx(EllipsisIcon, { className: "size-4" })
|
|
231
|
-
}
|
|
232
|
-
);
|
|
165
|
+
return /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: previousElipsis({ className }), ...props, children: /* @__PURE__ */ jsx(EllipsisIcon, { className: "size-4" }) });
|
|
233
166
|
};
|
|
234
167
|
var PaginationNextEllipsis = ({
|
|
235
168
|
className,
|
|
236
169
|
unstyled,
|
|
237
170
|
...props
|
|
238
171
|
}) => {
|
|
239
|
-
const { nextEllipsisActive } =
|
|
240
|
-
const {
|
|
241
|
-
const isUnstyled = unstyled ?? contextUnstyled;
|
|
172
|
+
const { nextEllipsisActive } = usePaginationContext();
|
|
173
|
+
const { nextElipsis } = usePaginationStyles(unstyled);
|
|
242
174
|
if (!nextEllipsisActive) return;
|
|
243
|
-
return /* @__PURE__ */ jsx(
|
|
244
|
-
"span",
|
|
245
|
-
{
|
|
246
|
-
"aria-hidden": true,
|
|
247
|
-
className: applyUnstyled(
|
|
248
|
-
isUnstyled,
|
|
249
|
-
"flex h-9 w-9 items-center justify-center",
|
|
250
|
-
className
|
|
251
|
-
),
|
|
252
|
-
...props,
|
|
253
|
-
children: /* @__PURE__ */ jsx(EllipsisIcon, { className: "size-4" })
|
|
254
|
-
}
|
|
255
|
-
);
|
|
175
|
+
return /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: nextElipsis({ className }), ...props, children: /* @__PURE__ */ jsx(EllipsisIcon, { className: "size-4" }) });
|
|
256
176
|
};
|
|
257
177
|
export {
|
|
258
178
|
Pagination,
|
|
@@ -262,5 +182,5 @@ export {
|
|
|
262
182
|
PaginationNextEllipsis,
|
|
263
183
|
PaginationPreviousButton,
|
|
264
184
|
PaginationPreviousEllipsis,
|
|
265
|
-
|
|
185
|
+
usePaginationContext
|
|
266
186
|
};
|
package/dist/metafile-esm.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/pagination.tsx":{"bytes":
|
|
1
|
+
{"inputs":{"src/pagination.tsx":{"bytes":9271,"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":5343},"src/index.ts":{"bytesInOutput":0}},"bytes":5561}}}
|
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.10",
|
|
5
5
|
"homepage": "https://mijn-ui.vercel.app",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -20,23 +20,25 @@
|
|
|
20
20
|
"exports": "./dist/index.js",
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
22
|
"devDependencies": {
|
|
23
|
+
"react": "19.0.0",
|
|
24
|
+
"react-dom": "19.0.0",
|
|
23
25
|
"@next/eslint-plugin-next": "^15.0.3",
|
|
24
|
-
"@types/react": "^
|
|
25
|
-
"@types/react-dom": "^
|
|
26
|
+
"@types/react": "^19.0.0",
|
|
27
|
+
"@types/react-dom": "^19.0.0",
|
|
26
28
|
"eslint-config-custom": "0.0.1",
|
|
27
29
|
"tsconfig": "0.0.0",
|
|
28
30
|
"tsup-config": "0.0.0"
|
|
29
31
|
},
|
|
30
32
|
"dependencies": {
|
|
31
|
-
"react": "
|
|
32
|
-
"
|
|
33
|
-
"@mijn-ui/
|
|
34
|
-
"@mijn-ui/react-
|
|
35
|
-
"@mijn-ui/react-button": "0.0.8"
|
|
33
|
+
"@mijn-ui/react-core": "0.0.2",
|
|
34
|
+
"@mijn-ui/shared-icons": "0.0.3",
|
|
35
|
+
"@mijn-ui/react-utilities": "0.0.8",
|
|
36
|
+
"@mijn-ui/react-hooks": "0.0.9"
|
|
36
37
|
},
|
|
37
38
|
"peerDependencies": {
|
|
38
39
|
"react": "^19.0",
|
|
39
|
-
"react-dom": "^19.0"
|
|
40
|
+
"react-dom": "^19.0",
|
|
41
|
+
"@mijn-ui/react-theme": "0.0.7"
|
|
40
42
|
},
|
|
41
43
|
"publishConfig": {
|
|
42
44
|
"access": "public"
|
|
@@ -47,7 +49,7 @@
|
|
|
47
49
|
"nextjs"
|
|
48
50
|
],
|
|
49
51
|
"scripts": {
|
|
50
|
-
"clean": "rimraf dist",
|
|
52
|
+
"clean": "rimraf dist .turbo",
|
|
51
53
|
"build": "tsup",
|
|
52
54
|
"lint": "eslint .",
|
|
53
55
|
"lint:fix": "eslint . --fix",
|