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/lib/index.tsx
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React, { FC } from "react";
|
|
2
|
+
import { defaultStylesEnum } from "./components/constants";
|
|
3
|
+
import { Item, ItemList, Wrapper } from "./components";
|
|
4
|
+
import { range } from "./components/utils";
|
|
2
5
|
|
|
3
|
-
interface
|
|
6
|
+
interface PaginationProps {
|
|
4
7
|
paginationStart: 0 | 1;
|
|
5
8
|
currentIndex: number;
|
|
6
9
|
totalPages: number;
|
|
@@ -16,7 +19,7 @@ interface IPagination {
|
|
|
16
19
|
className?: string;
|
|
17
20
|
}
|
|
18
21
|
|
|
19
|
-
const Pagination: FC<
|
|
22
|
+
const Pagination: FC<PaginationProps> = ({
|
|
20
23
|
paginationStart,
|
|
21
24
|
currentIndex,
|
|
22
25
|
totalPages,
|
|
@@ -30,304 +33,323 @@ const Pagination: FC<IPagination> = ({
|
|
|
30
33
|
disableItemClass = "",
|
|
31
34
|
className,
|
|
32
35
|
}) => {
|
|
33
|
-
console.log(totalPages, currentIndex);
|
|
34
|
-
const countItems = [1, 2, 3, 4];
|
|
35
|
-
|
|
36
|
-
enum defaultStylesEnum {
|
|
37
|
-
wrapperClass = "wrapperClass",
|
|
38
|
-
itemListClass = "itemListClass",
|
|
39
|
-
itemClass = "itemClass",
|
|
40
|
-
selectedItemClass = "selectedItemClass",
|
|
41
|
-
disableItemClass = "disableItemClass",
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const defaultStyles: Record<defaultStylesEnum, React.CSSProperties> = {
|
|
45
|
-
wrapperClass: {
|
|
46
|
-
position: "sticky",
|
|
47
|
-
display: "flex",
|
|
48
|
-
justifyContent: "center",
|
|
49
|
-
alignItems: "center",
|
|
50
|
-
width: "100%",
|
|
51
|
-
bottom: 0,
|
|
52
|
-
},
|
|
53
|
-
itemListClass: {
|
|
54
|
-
padding: "10px 0",
|
|
55
|
-
},
|
|
56
|
-
itemClass: {
|
|
57
|
-
display: "inline",
|
|
58
|
-
cursor: "pointer",
|
|
59
|
-
padding: "6px 12px",
|
|
60
|
-
borderRadius: "4px",
|
|
61
|
-
margin: "0 2px",
|
|
62
|
-
backgroundColor: "#45c954",
|
|
63
|
-
userSelect: "none",
|
|
64
|
-
},
|
|
65
|
-
selectedItemClass: {
|
|
66
|
-
display: "inline",
|
|
67
|
-
cursor: "pointer",
|
|
68
|
-
padding: "6px 12px",
|
|
69
|
-
borderRadius: "4px",
|
|
70
|
-
margin: "0 2px",
|
|
71
|
-
backgroundColor: "#48bbff",
|
|
72
|
-
userSelect: "none",
|
|
73
|
-
},
|
|
74
|
-
disableItemClass: {
|
|
75
|
-
display: "inline",
|
|
76
|
-
cursor: "not-allowed",
|
|
77
|
-
padding: "6px 12px",
|
|
78
|
-
borderRadius: "4px",
|
|
79
|
-
margin: "0 2px",
|
|
80
|
-
userSelect: "none",
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
|
|
84
36
|
if (totalPages <= 1) {
|
|
85
37
|
return (
|
|
86
|
-
<
|
|
87
|
-
<
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
38
|
+
<Wrapper wrapperClass={className ? className : wrapperClass} isDefaultStyles={isDefaultStyles}>
|
|
39
|
+
<ItemList itemListClass={itemListClass} isDefaultStyles={isDefaultStyles}>
|
|
40
|
+
<Item
|
|
41
|
+
itemClass={disableItemClass}
|
|
42
|
+
itemStyle={defaultStylesEnum.disableItemClass}
|
|
43
|
+
isDefaultStyles={isDefaultStyles}
|
|
44
|
+
>
|
|
45
|
+
{`<<`}
|
|
46
|
+
</Item>
|
|
47
|
+
|
|
48
|
+
<Item
|
|
49
|
+
itemClass={disableItemClass}
|
|
50
|
+
itemStyle={defaultStylesEnum.disableItemClass}
|
|
51
|
+
isDefaultStyles={isDefaultStyles}
|
|
52
|
+
>
|
|
53
|
+
1
|
|
54
|
+
</Item>
|
|
55
|
+
|
|
56
|
+
<Item
|
|
57
|
+
itemClass={disableItemClass}
|
|
58
|
+
itemStyle={defaultStylesEnum.disableItemClass}
|
|
59
|
+
isDefaultStyles={isDefaultStyles}
|
|
60
|
+
>
|
|
61
|
+
{`>>`}
|
|
62
|
+
</Item>
|
|
63
|
+
</ItemList>
|
|
64
|
+
</Wrapper>
|
|
92
65
|
);
|
|
93
66
|
}
|
|
94
67
|
|
|
95
68
|
if (totalPages > 1 && totalPages < 4) {
|
|
96
69
|
return (
|
|
97
|
-
<
|
|
98
|
-
<
|
|
99
|
-
{
|
|
100
|
-
const index = paginationStart === 0 ? el
|
|
70
|
+
<Wrapper wrapperClass={className ? className : wrapperClass} isDefaultStyles={isDefaultStyles}>
|
|
71
|
+
<ItemList itemListClass={itemListClass} isDefaultStyles={isDefaultStyles}>
|
|
72
|
+
{range(totalPages).map((el) => {
|
|
73
|
+
const index = paginationStart === 0 ? el : el + 1;
|
|
101
74
|
if (currentIndex === index) {
|
|
102
75
|
return (
|
|
103
|
-
<
|
|
104
|
-
|
|
105
|
-
|
|
76
|
+
<Item
|
|
77
|
+
itemClass={selectedItemClass}
|
|
78
|
+
itemStyle={defaultStylesEnum.selectedItemClass}
|
|
79
|
+
isDefaultStyles={isDefaultStyles}
|
|
106
80
|
key={el}
|
|
107
81
|
>
|
|
108
|
-
{el}
|
|
109
|
-
</
|
|
82
|
+
{el + 1}
|
|
83
|
+
</Item>
|
|
110
84
|
);
|
|
111
85
|
}
|
|
112
86
|
return (
|
|
113
|
-
<
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
87
|
+
<Item
|
|
88
|
+
itemClass={selectedItemClass}
|
|
89
|
+
itemStyle={defaultStylesEnum.itemClass}
|
|
90
|
+
isDefaultStyles={isDefaultStyles}
|
|
117
91
|
onClick={() => setIndex(index)}
|
|
92
|
+
key={el}
|
|
118
93
|
>
|
|
119
|
-
{el}
|
|
120
|
-
</
|
|
94
|
+
{el + 1}
|
|
95
|
+
</Item>
|
|
121
96
|
);
|
|
122
97
|
})}
|
|
123
|
-
</
|
|
124
|
-
</
|
|
98
|
+
</ItemList>
|
|
99
|
+
</Wrapper>
|
|
125
100
|
);
|
|
126
101
|
}
|
|
127
102
|
|
|
128
103
|
if (totalPages === 4) {
|
|
129
104
|
return (
|
|
130
|
-
<
|
|
131
|
-
<
|
|
105
|
+
<Wrapper wrapperClass={className ? className : wrapperClass} isDefaultStyles={isDefaultStyles}>
|
|
106
|
+
<ItemList itemListClass={itemListClass} isDefaultStyles={isDefaultStyles}>
|
|
132
107
|
{currentIndex > (paginationStart === 0 ? 0 : 1) ? (
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
|
|
108
|
+
<Item
|
|
109
|
+
itemClass={itemClass}
|
|
110
|
+
itemStyle={defaultStylesEnum.itemClass}
|
|
111
|
+
isDefaultStyles={isDefaultStyles}
|
|
136
112
|
onClick={() => setIndex(currentIndex - 1)}
|
|
137
|
-
>
|
|
113
|
+
>
|
|
114
|
+
{`<<`}
|
|
115
|
+
</Item>
|
|
138
116
|
) : (
|
|
139
|
-
<
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
117
|
+
<Item
|
|
118
|
+
itemClass={disableItemClass}
|
|
119
|
+
itemStyle={defaultStylesEnum.disableItemClass}
|
|
120
|
+
isDefaultStyles={isDefaultStyles}
|
|
121
|
+
>
|
|
122
|
+
{`<<`}
|
|
123
|
+
</Item>
|
|
143
124
|
)}
|
|
144
|
-
{
|
|
145
|
-
const index = paginationStart === 0 ? el
|
|
125
|
+
{range(totalPages).map((el) => {
|
|
126
|
+
const index = paginationStart === 0 ? el : el + 1;
|
|
146
127
|
if (currentIndex === index) {
|
|
147
128
|
return (
|
|
148
|
-
<
|
|
149
|
-
|
|
150
|
-
|
|
129
|
+
<Item
|
|
130
|
+
itemClass={selectedItemClass}
|
|
131
|
+
itemStyle={defaultStylesEnum.selectedItemClass}
|
|
132
|
+
isDefaultStyles={isDefaultStyles}
|
|
151
133
|
key={el}
|
|
152
134
|
>
|
|
153
|
-
{el}
|
|
154
|
-
</
|
|
135
|
+
{el + 1}
|
|
136
|
+
</Item>
|
|
155
137
|
);
|
|
156
138
|
}
|
|
157
139
|
return (
|
|
158
|
-
<
|
|
159
|
-
|
|
160
|
-
|
|
140
|
+
<Item
|
|
141
|
+
itemClass={selectedItemClass}
|
|
142
|
+
itemStyle={defaultStylesEnum.itemClass}
|
|
143
|
+
isDefaultStyles={isDefaultStyles}
|
|
161
144
|
key={el}
|
|
162
145
|
onClick={() => setIndex(index)}
|
|
163
146
|
>
|
|
164
|
-
{el}
|
|
165
|
-
</
|
|
147
|
+
{el + 1}
|
|
148
|
+
</Item>
|
|
166
149
|
);
|
|
167
150
|
})}
|
|
168
151
|
{currentIndex < (paginationStart === 0 ? 3 : 4) ? (
|
|
169
|
-
<
|
|
170
|
-
|
|
171
|
-
|
|
152
|
+
<Item
|
|
153
|
+
itemClass={itemClass}
|
|
154
|
+
itemStyle={defaultStylesEnum.itemClass}
|
|
155
|
+
isDefaultStyles={isDefaultStyles}
|
|
172
156
|
onClick={() => setIndex(currentIndex + 1)}
|
|
173
|
-
>
|
|
157
|
+
>
|
|
158
|
+
{`>>`}
|
|
159
|
+
</Item>
|
|
174
160
|
) : (
|
|
175
|
-
<
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
161
|
+
<Item
|
|
162
|
+
itemClass={disableItemClass}
|
|
163
|
+
itemStyle={defaultStylesEnum.disableItemClass}
|
|
164
|
+
isDefaultStyles={isDefaultStyles}
|
|
165
|
+
>
|
|
166
|
+
{`>>`}
|
|
167
|
+
</Item>
|
|
179
168
|
)}
|
|
180
|
-
</
|
|
181
|
-
</
|
|
169
|
+
</ItemList>
|
|
170
|
+
</Wrapper>
|
|
182
171
|
);
|
|
183
172
|
}
|
|
184
173
|
|
|
185
174
|
return (
|
|
186
|
-
|
|
187
|
-
<
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
175
|
+
<Wrapper wrapperClass={className ? className : wrapperClass} isDefaultStyles={isDefaultStyles}>
|
|
176
|
+
<ItemList itemListClass={itemListClass} isDefaultStyles={isDefaultStyles}>
|
|
177
|
+
{/*Previous button*/}
|
|
178
|
+
{currentIndex > (paginationStart === 0 ? 0 : 1) ? (
|
|
179
|
+
<Item
|
|
180
|
+
itemClass={itemClass}
|
|
181
|
+
itemStyle={defaultStylesEnum.itemClass}
|
|
182
|
+
isDefaultStyles={isDefaultStyles}
|
|
183
|
+
onClick={() => setIndex(currentIndex - 1)}
|
|
184
|
+
>
|
|
185
|
+
{`<<`}
|
|
186
|
+
</Item>
|
|
187
|
+
) : (
|
|
188
|
+
<Item
|
|
189
|
+
itemClass={disableItemClass}
|
|
190
|
+
itemStyle={defaultStylesEnum.disableItemClass}
|
|
191
|
+
isDefaultStyles={isDefaultStyles}
|
|
192
|
+
>
|
|
193
|
+
{`<<`}
|
|
194
|
+
</Item>
|
|
195
|
+
)}
|
|
196
|
+
{/*First page button*/}
|
|
197
|
+
{currentIndex > (paginationStart == 0 ? 2 : 3) ? (
|
|
198
|
+
<Item
|
|
199
|
+
itemClass={itemClass}
|
|
200
|
+
itemStyle={defaultStylesEnum.itemClass}
|
|
201
|
+
isDefaultStyles={isDefaultStyles}
|
|
202
|
+
onClick={() => setIndex(paginationStart === 0 ? 0 : 1)}
|
|
203
|
+
>
|
|
204
|
+
{`1`}
|
|
205
|
+
</Item>
|
|
206
|
+
) : null}
|
|
209
207
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
<li
|
|
215
|
-
className={selectedItemClass}
|
|
216
|
-
style={isDefaultStyles ? defaultStyles.selectedItemClass : undefined}
|
|
217
|
-
key={el}
|
|
218
|
-
>
|
|
219
|
-
{el}
|
|
220
|
-
</li>
|
|
221
|
-
);
|
|
222
|
-
}
|
|
208
|
+
{currentIndex < (paginationStart === 0 ? 3 : 4)
|
|
209
|
+
? range(4).map((el) => {
|
|
210
|
+
const index = paginationStart === 0 ? el : el + 1;
|
|
211
|
+
if (currentIndex === index) {
|
|
223
212
|
return (
|
|
224
|
-
<
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
213
|
+
<Item
|
|
214
|
+
itemClass={selectedItemClass}
|
|
215
|
+
itemStyle={defaultStylesEnum.selectedItemClass}
|
|
216
|
+
isDefaultStyles={isDefaultStyles}
|
|
228
217
|
key={el}
|
|
229
218
|
>
|
|
230
|
-
{el}
|
|
231
|
-
</
|
|
219
|
+
{el + 1}
|
|
220
|
+
</Item>
|
|
232
221
|
);
|
|
233
|
-
}
|
|
234
|
-
|
|
222
|
+
}
|
|
223
|
+
return (
|
|
224
|
+
<Item
|
|
225
|
+
itemClass={itemClass}
|
|
226
|
+
itemStyle={defaultStylesEnum.itemClass}
|
|
227
|
+
isDefaultStyles={isDefaultStyles}
|
|
228
|
+
onClick={() => setIndex(index)}
|
|
229
|
+
key={el}
|
|
230
|
+
>
|
|
231
|
+
{el + 1}
|
|
232
|
+
</Item>
|
|
233
|
+
);
|
|
234
|
+
})
|
|
235
|
+
: null}
|
|
235
236
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
237
|
+
{currentIndex > (paginationStart === 0 ? 2 : 3) ? (
|
|
238
|
+
<Item
|
|
239
|
+
itemClass={disableItemClass}
|
|
240
|
+
itemStyle={defaultStylesEnum.disableItemClass}
|
|
241
|
+
isDefaultStyles={isDefaultStyles}
|
|
242
|
+
>
|
|
243
|
+
{`...`}
|
|
244
|
+
</Item>
|
|
245
|
+
) : null}
|
|
242
246
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
247
|
+
{currentIndex > (paginationStart === 0 ? 2 : 3) &&
|
|
248
|
+
(paginationStart === 0 ? currentIndex : currentIndex - 1) < totalPages ? (
|
|
249
|
+
<>
|
|
250
|
+
{currentIndex === (paginationStart === 0 ? totalPages - 2 : totalPages - 1) && (
|
|
251
|
+
<Item
|
|
252
|
+
itemClass={itemClass}
|
|
253
|
+
itemStyle={defaultStylesEnum.itemClass}
|
|
254
|
+
isDefaultStyles={isDefaultStyles}
|
|
255
|
+
onClick={() => setIndex(paginationStart === 0 ? totalPages - 4 : totalPages - 3)}
|
|
256
|
+
>
|
|
257
|
+
{totalPages - 3}
|
|
258
|
+
</Item>
|
|
259
|
+
)}
|
|
260
|
+
|
|
261
|
+
{currentIndex === (paginationStart === 0 ? totalPages - 1 : totalPages) && (
|
|
262
|
+
<>
|
|
263
|
+
<Item
|
|
264
|
+
itemClass={itemClass}
|
|
265
|
+
itemStyle={defaultStylesEnum.itemClass}
|
|
266
|
+
isDefaultStyles={isDefaultStyles}
|
|
250
267
|
onClick={() => setIndex(paginationStart === 0 ? totalPages - 4 : totalPages - 3)}
|
|
251
268
|
>
|
|
252
269
|
{totalPages - 3}
|
|
253
|
-
</
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
</li>
|
|
265
|
-
<li
|
|
266
|
-
className={itemClass}
|
|
267
|
-
style={isDefaultStyles ? defaultStyles.itemClass : undefined}
|
|
268
|
-
onClick={() => setIndex(paginationStart === 0 ? totalPages - 3 : totalPages - 2)}
|
|
269
|
-
>
|
|
270
|
-
{totalPages - 2}
|
|
271
|
-
</li>
|
|
272
|
-
</>
|
|
273
|
-
)}
|
|
270
|
+
</Item>
|
|
271
|
+
<Item
|
|
272
|
+
itemClass={itemClass}
|
|
273
|
+
itemStyle={defaultStylesEnum.itemClass}
|
|
274
|
+
isDefaultStyles={isDefaultStyles}
|
|
275
|
+
onClick={() => setIndex(paginationStart === 0 ? totalPages - 3 : totalPages - 2)}
|
|
276
|
+
>
|
|
277
|
+
{totalPages - 2}
|
|
278
|
+
</Item>
|
|
279
|
+
</>
|
|
280
|
+
)}
|
|
274
281
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
+
<Item
|
|
283
|
+
itemClass={itemClass}
|
|
284
|
+
itemStyle={defaultStylesEnum.itemClass}
|
|
285
|
+
isDefaultStyles={isDefaultStyles}
|
|
286
|
+
onClick={() => setIndex(currentIndex - 1)}
|
|
287
|
+
>
|
|
288
|
+
{paginationStart === 0 ? currentIndex : currentIndex - 1}
|
|
289
|
+
</Item>
|
|
282
290
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
291
|
+
<Item
|
|
292
|
+
itemClass={selectedItemClass}
|
|
293
|
+
itemStyle={defaultStylesEnum.selectedItemClass}
|
|
294
|
+
isDefaultStyles={isDefaultStyles}
|
|
295
|
+
>
|
|
296
|
+
{paginationStart === 0 ? currentIndex + 1 : currentIndex}
|
|
297
|
+
</Item>
|
|
286
298
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
299
|
+
{currentIndex < (paginationStart === 0 ? totalPages - 1 : totalPages) ? (
|
|
300
|
+
<Item
|
|
301
|
+
itemClass={itemClass}
|
|
302
|
+
itemStyle={defaultStylesEnum.itemClass}
|
|
303
|
+
isDefaultStyles={isDefaultStyles}
|
|
304
|
+
onClick={() => setIndex(currentIndex + 1)}
|
|
305
|
+
>
|
|
306
|
+
{paginationStart === 0 ? currentIndex + 2 : currentIndex + 1}
|
|
307
|
+
</Item>
|
|
308
|
+
) : null}
|
|
309
|
+
</>
|
|
310
|
+
) : null}
|
|
298
311
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
312
|
+
{currentIndex < (paginationStart === 0 ? totalPages - 3 : totalPages - 2) ? (
|
|
313
|
+
<Item
|
|
314
|
+
itemClass={disableItemClass}
|
|
315
|
+
itemStyle={defaultStylesEnum.disableItemClass}
|
|
316
|
+
isDefaultStyles={isDefaultStyles}
|
|
317
|
+
>
|
|
318
|
+
{`...`}
|
|
319
|
+
</Item>
|
|
320
|
+
) : null}
|
|
305
321
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
322
|
+
{currentIndex < (paginationStart === 0 ? totalPages - 2 : totalPages - 1) ? (
|
|
323
|
+
<Item
|
|
324
|
+
itemClass={itemClass}
|
|
325
|
+
itemStyle={defaultStylesEnum.itemClass}
|
|
326
|
+
isDefaultStyles={isDefaultStyles}
|
|
327
|
+
onClick={() => setIndex(paginationStart === 0 ? totalPages - 1 : totalPages)}
|
|
328
|
+
>
|
|
329
|
+
{totalPages}
|
|
330
|
+
</Item>
|
|
331
|
+
) : null}
|
|
315
332
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
333
|
+
{(paginationStart === 0 ? currentIndex + 1 : currentIndex) < totalPages ? (
|
|
334
|
+
<Item
|
|
335
|
+
itemClass={itemClass}
|
|
336
|
+
itemStyle={defaultStylesEnum.itemClass}
|
|
337
|
+
isDefaultStyles={isDefaultStyles}
|
|
338
|
+
onClick={() => setIndex(currentIndex + 1)}
|
|
339
|
+
>
|
|
340
|
+
{`>>`}
|
|
341
|
+
</Item>
|
|
342
|
+
) : (
|
|
343
|
+
<Item
|
|
344
|
+
itemClass={disableItemClass}
|
|
345
|
+
itemStyle={defaultStylesEnum.disableItemClass}
|
|
346
|
+
isDefaultStyles={isDefaultStyles}
|
|
347
|
+
>
|
|
348
|
+
{`>>`}
|
|
349
|
+
</Item>
|
|
350
|
+
)}
|
|
351
|
+
</ItemList>
|
|
352
|
+
</Wrapper>
|
|
331
353
|
);
|
|
332
354
|
};
|
|
333
355
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "best-react-pagination",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Pagination for work with React",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
"@babel/preset-env": "^7.15.8",
|
|
34
34
|
"@babel/preset-react": "^7.14.5",
|
|
35
35
|
"@babel/preset-typescript": "^7.15.0",
|
|
36
|
+
"@commitlint/cli": "^15.0.0",
|
|
37
|
+
"@commitlint/config-conventional": "^15.0.0",
|
|
36
38
|
"@types/jest": "^27.0.2",
|
|
37
39
|
"@types/node": "^16.11.0",
|
|
38
40
|
"@types/react": "^17.0.30",
|
|
@@ -45,13 +47,13 @@
|
|
|
45
47
|
"clean-webpack-plugin": "^4.0.0",
|
|
46
48
|
"copy-webpack-plugin": "^9.0.1",
|
|
47
49
|
"eslint": "^7.32.0",
|
|
48
|
-
"@commitlint/cli": "^15.0.0",
|
|
49
|
-
"@commitlint/config-conventional": "^15.0.0",
|
|
50
50
|
"eslint-plugin-react": "^7.26.1",
|
|
51
51
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
52
|
+
"fs-extra": "^10.0.0",
|
|
52
53
|
"husky": "^7.0.4",
|
|
53
54
|
"jest": "^27.2.5",
|
|
54
55
|
"lint-staged": "^12.1.2",
|
|
56
|
+
"ncp": "^2.0.0",
|
|
55
57
|
"prettier": "^2.5.1",
|
|
56
58
|
"react": "17.0.2",
|
|
57
59
|
"react-dom": "^17.0.2",
|
package/tsconfig.json
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"outDir": "./dist/",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"jsx": "react",
|
|
13
|
-
"strict": true,
|
|
14
|
-
"allowJs": true,
|
|
15
|
-
"moduleResolution": "node"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "./dist/",
|
|
4
|
+
"noImplicitAny": true,
|
|
5
|
+
"esModuleInterop": true,
|
|
6
|
+
"module": "CommonJS",
|
|
7
|
+
"sourceMap": true,
|
|
8
|
+
"target": "ESNext",
|
|
9
|
+
"lib": ["ESNext", "dom"],
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"declarationDir": "dist",
|
|
12
|
+
"jsx": "react",
|
|
13
|
+
"strict": true,
|
|
14
|
+
"allowJs": true,
|
|
15
|
+
"moduleResolution": "node",
|
|
16
|
+
"downlevelIteration": true
|
|
17
|
+
},
|
|
18
|
+
"include": ["./lib/index.tsx"],
|
|
19
|
+
"exclude": [
|
|
20
|
+
"node_modules",
|
|
21
|
+
"dist",
|
|
22
|
+
"test"
|
|
23
|
+
]
|
|
24
|
+
}
|