best-react-pagination 0.0.3 → 0.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/.eslintignore +1 -1
- package/LICENCE +12 -12
- package/demo/public/index.html +17 -17
- package/demo/src/App.tsx +10 -1
- package/demo/src/Pagination/components/Item/Item.tsx +19 -0
- package/demo/src/Pagination/components/Item/index.ts +1 -0
- package/demo/src/Pagination/components/ItemList/ItemList.tsx +17 -0
- package/demo/src/Pagination/components/ItemList/index.ts +1 -0
- package/demo/src/Pagination/components/Wrapper/Wrapper.tsx +17 -0
- package/demo/src/Pagination/components/Wrapper/index.ts +1 -0
- package/demo/src/Pagination/components/constants.ts +49 -0
- package/demo/src/Pagination/components/index.ts +3 -0
- package/demo/src/Pagination/components/utils.ts +3 -0
- package/demo/src/Pagination/index.tsx +259 -237
- package/demo/tsconfig.json +17 -17
- package/dist/components/Item/Item.d.ts +10 -0
- package/dist/components/Item/index.d.ts +1 -0
- package/dist/components/ItemList/ItemList.d.ts +7 -0
- package/dist/components/ItemList/index.d.ts +1 -0
- package/dist/components/Wrapper/Wrapper.d.ts +7 -0
- package/dist/components/Wrapper/index.d.ts +1 -0
- package/dist/components/constants.d.ts +9 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/utils.d.ts +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/husky.config.js +4 -4
- package/lib/components/Item/Item.tsx +19 -0
- package/lib/components/Item/index.ts +1 -0
- package/lib/components/ItemList/ItemList.tsx +17 -0
- package/lib/components/ItemList/index.ts +1 -0
- package/lib/components/Wrapper/Wrapper.tsx +17 -0
- package/lib/components/Wrapper/index.ts +1 -0
- package/lib/components/constants.ts +49 -0
- package/lib/components/index.ts +3 -0
- package/lib/components/utils.ts +3 -0
- package/lib/index.tsx +259 -237
- package/package.json +5 -3
- package/tsconfig.json +24 -23
- package/webpack.config.ts +53 -45
package/.eslintignore
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/dist
|
|
1
|
+
/dist
|
|
2
2
|
webpack.config.ts
|
package/LICENCE
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
Copyright (c) 2021, Dmitriy Tsybizov <dts97@yandex.ru>
|
|
2
|
-
|
|
3
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
4
|
-
purpose with or without fee is hereby granted, provided that the above
|
|
5
|
-
copyright notice and this permission notice appear in all copies.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
8
|
-
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
9
|
-
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
10
|
-
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
11
|
-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
12
|
-
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
1
|
+
Copyright (c) 2021, Dmitriy Tsybizov <dts97@yandex.ru>
|
|
2
|
+
|
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
4
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
5
|
+
copyright notice and this permission notice appear in all copies.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
8
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
9
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
10
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
11
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
12
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
13
13
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/demo/public/index.html
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
-
<meta name="theme-color" content="#000000" />
|
|
7
|
-
<meta
|
|
8
|
-
name="description"
|
|
9
|
-
content="Web site created using create-react-app"
|
|
10
|
-
/>
|
|
11
|
-
<title>React App</title>
|
|
12
|
-
</head>
|
|
13
|
-
<body>
|
|
14
|
-
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
15
|
-
<div id="root"></div>
|
|
16
|
-
</body>
|
|
17
|
-
</html>
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<meta name="theme-color" content="#000000" />
|
|
7
|
+
<meta
|
|
8
|
+
name="description"
|
|
9
|
+
content="Web site created using create-react-app"
|
|
10
|
+
/>
|
|
11
|
+
<title>React App</title>
|
|
12
|
+
</head>
|
|
13
|
+
<body>
|
|
14
|
+
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
15
|
+
<div id="root"></div>
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|
package/demo/src/App.tsx
CHANGED
|
@@ -4,10 +4,19 @@ import Pagination from "./Pagination";
|
|
|
4
4
|
|
|
5
5
|
const App: FC = () => {
|
|
6
6
|
const [index, setIndex] = useState(1);
|
|
7
|
+
const totalPages = 10;
|
|
8
|
+
|
|
9
|
+
console.log(`Current: ${index}. Total: ${totalPages}`);
|
|
7
10
|
|
|
8
11
|
return (
|
|
9
12
|
<>
|
|
10
|
-
<Pagination
|
|
13
|
+
<Pagination
|
|
14
|
+
paginationStart={1}
|
|
15
|
+
currentIndex={index}
|
|
16
|
+
setIndex={setIndex}
|
|
17
|
+
totalPages={totalPages}
|
|
18
|
+
isDefaultStyles={true}
|
|
19
|
+
/>
|
|
11
20
|
</>
|
|
12
21
|
);
|
|
13
22
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { FC } from "react";
|
|
2
|
+
import { defaultStyles, defaultStylesEnum } from "../constants";
|
|
3
|
+
|
|
4
|
+
interface ItemProps {
|
|
5
|
+
isDefaultStyles: boolean | undefined;
|
|
6
|
+
itemClass: string;
|
|
7
|
+
itemStyle: defaultStylesEnum;
|
|
8
|
+
onClick?: () => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const Item: FC<ItemProps> = ({ isDefaultStyles, itemClass, itemStyle, onClick, children }) => {
|
|
12
|
+
return (
|
|
13
|
+
<li className={itemClass} style={isDefaultStyles ? defaultStyles[itemStyle] : undefined} onClick={onClick}>
|
|
14
|
+
{children}
|
|
15
|
+
</li>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default Item;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./Item";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { FC } from "react";
|
|
2
|
+
import { defaultStyles } from "../constants";
|
|
3
|
+
|
|
4
|
+
interface ItemListProps {
|
|
5
|
+
isDefaultStyles: boolean | undefined;
|
|
6
|
+
itemListClass: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const ItemList: FC<ItemListProps> = ({ isDefaultStyles, itemListClass, children }) => {
|
|
10
|
+
return (
|
|
11
|
+
<ul className={itemListClass} style={isDefaultStyles ? defaultStyles.itemListClass : undefined}>
|
|
12
|
+
{children}
|
|
13
|
+
</ul>
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default ItemList;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./ItemList";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { FC } from "react";
|
|
2
|
+
import { defaultStyles } from "../constants";
|
|
3
|
+
|
|
4
|
+
interface WrapperProps {
|
|
5
|
+
isDefaultStyles: boolean | undefined;
|
|
6
|
+
wrapperClass: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const Wrapper: FC<WrapperProps> = ({ isDefaultStyles, wrapperClass, children }) => {
|
|
10
|
+
return (
|
|
11
|
+
<div className={wrapperClass} style={isDefaultStyles ? defaultStyles.wrapperClass : undefined}>
|
|
12
|
+
{children}
|
|
13
|
+
</div>
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default Wrapper;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./Wrapper";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export enum defaultStylesEnum {
|
|
4
|
+
wrapperClass = "wrapperClass",
|
|
5
|
+
itemListClass = "itemListClass",
|
|
6
|
+
itemClass = "itemClass",
|
|
7
|
+
selectedItemClass = "selectedItemClass",
|
|
8
|
+
disableItemClass = "disableItemClass",
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const defaultStyles: Record<defaultStylesEnum, React.CSSProperties> = {
|
|
12
|
+
wrapperClass: {
|
|
13
|
+
position: "sticky",
|
|
14
|
+
display: "flex",
|
|
15
|
+
justifyContent: "center",
|
|
16
|
+
alignItems: "center",
|
|
17
|
+
width: "100%",
|
|
18
|
+
bottom: 0,
|
|
19
|
+
},
|
|
20
|
+
itemListClass: {
|
|
21
|
+
padding: "10px 0",
|
|
22
|
+
},
|
|
23
|
+
itemClass: {
|
|
24
|
+
display: "inline",
|
|
25
|
+
cursor: "pointer",
|
|
26
|
+
padding: "6px 12px",
|
|
27
|
+
borderRadius: "4px",
|
|
28
|
+
margin: "0 2px",
|
|
29
|
+
backgroundColor: "#45c954",
|
|
30
|
+
userSelect: "none",
|
|
31
|
+
},
|
|
32
|
+
selectedItemClass: {
|
|
33
|
+
display: "inline",
|
|
34
|
+
cursor: "pointer",
|
|
35
|
+
padding: "6px 12px",
|
|
36
|
+
borderRadius: "4px",
|
|
37
|
+
margin: "0 2px",
|
|
38
|
+
backgroundColor: "#48bbff",
|
|
39
|
+
userSelect: "none",
|
|
40
|
+
},
|
|
41
|
+
disableItemClass: {
|
|
42
|
+
display: "inline",
|
|
43
|
+
cursor: "not-allowed",
|
|
44
|
+
padding: "6px 12px",
|
|
45
|
+
borderRadius: "4px",
|
|
46
|
+
margin: "0 2px",
|
|
47
|
+
userSelect: "none",
|
|
48
|
+
},
|
|
49
|
+
};
|