best-react-pagination 0.1.1 → 0.1.2

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.
Files changed (47) hide show
  1. package/.idea/best-react-pagination.iml +9 -0
  2. package/.idea/codeStyles/Project.xml +58 -0
  3. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  4. package/.idea/discord.xml +7 -0
  5. package/.idea/git_toolbox_prj.xml +15 -0
  6. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  7. package/.idea/misc.xml +6 -0
  8. package/.idea/modules.xml +8 -0
  9. package/.idea/prettier.xml +6 -0
  10. package/.idea/vcs.xml +6 -0
  11. package/package.json +1 -1
  12. package/demo/.babelrc +0 -14
  13. package/demo/public/index.html +0 -17
  14. package/demo/src/App.tsx +0 -24
  15. package/demo/src/Pagination/components/Item/Item.tsx +0 -19
  16. package/demo/src/Pagination/components/Item/index.ts +0 -1
  17. package/demo/src/Pagination/components/ItemList/ItemList.tsx +0 -17
  18. package/demo/src/Pagination/components/ItemList/index.ts +0 -1
  19. package/demo/src/Pagination/components/Wrapper/Wrapper.tsx +0 -17
  20. package/demo/src/Pagination/components/Wrapper/index.ts +0 -1
  21. package/demo/src/Pagination/components/constants.ts +0 -49
  22. package/demo/src/Pagination/components/index.ts +0 -3
  23. package/demo/src/Pagination/components/utils.ts +0 -3
  24. package/demo/src/Pagination/index.tsx +0 -356
  25. package/demo/src/index.html +0 -11
  26. package/demo/src/index.tsx +0 -7
  27. package/demo/tsconfig.json +0 -18
  28. package/demo/webpack.config.js +0 -50
  29. package/dist/components/Item/Item.d.ts +0 -10
  30. package/dist/components/Item/index.d.ts +0 -1
  31. package/dist/components/ItemList/ItemList.d.ts +0 -7
  32. package/dist/components/ItemList/index.d.ts +0 -1
  33. package/dist/components/Wrapper/Wrapper.d.ts +0 -7
  34. package/dist/components/Wrapper/index.d.ts +0 -1
  35. package/dist/components/constants.d.ts +0 -9
  36. package/dist/components/index.d.ts +0 -3
  37. package/dist/components/utils.d.ts +0 -1
  38. package/lib/components/Item/Item.tsx +0 -19
  39. package/lib/components/Item/index.ts +0 -1
  40. package/lib/components/ItemList/ItemList.tsx +0 -17
  41. package/lib/components/ItemList/index.ts +0 -1
  42. package/lib/components/Wrapper/Wrapper.tsx +0 -17
  43. package/lib/components/Wrapper/index.ts +0 -1
  44. package/lib/components/constants.ts +0 -49
  45. package/lib/components/index.ts +0 -3
  46. package/lib/components/utils.ts +0 -3
  47. package/lib/index.tsx +0 -356
package/lib/index.tsx DELETED
@@ -1,356 +0,0 @@
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";
5
-
6
- interface PaginationProps {
7
- paginationStart: 0 | 1;
8
- currentIndex: number;
9
- totalPages: number;
10
- setIndex: React.Dispatch<React.SetStateAction<number>>;
11
- isDefaultStyles?: boolean;
12
-
13
- wrapperClass?: string;
14
- itemListClass?: string;
15
- itemClass?: string;
16
- selectedItemClass?: string;
17
- disableItemClass?: string;
18
-
19
- className?: string;
20
- }
21
-
22
- const Pagination: FC<PaginationProps> = ({
23
- paginationStart,
24
- currentIndex,
25
- totalPages,
26
- setIndex,
27
- isDefaultStyles,
28
-
29
- wrapperClass = "",
30
- itemListClass = "",
31
- itemClass = "",
32
- selectedItemClass = "",
33
- disableItemClass = "",
34
- className,
35
- }) => {
36
- if (totalPages <= 1) {
37
- return (
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>
65
- );
66
- }
67
-
68
- if (totalPages > 1 && totalPages < 4) {
69
- return (
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;
74
- if (currentIndex === index) {
75
- return (
76
- <Item
77
- itemClass={selectedItemClass}
78
- itemStyle={defaultStylesEnum.selectedItemClass}
79
- isDefaultStyles={isDefaultStyles}
80
- key={el}
81
- >
82
- {el + 1}
83
- </Item>
84
- );
85
- }
86
- return (
87
- <Item
88
- itemClass={selectedItemClass}
89
- itemStyle={defaultStylesEnum.itemClass}
90
- isDefaultStyles={isDefaultStyles}
91
- onClick={() => setIndex(index)}
92
- key={el}
93
- >
94
- {el + 1}
95
- </Item>
96
- );
97
- })}
98
- </ItemList>
99
- </Wrapper>
100
- );
101
- }
102
-
103
- if (totalPages === 4) {
104
- return (
105
- <Wrapper wrapperClass={className ? className : wrapperClass} isDefaultStyles={isDefaultStyles}>
106
- <ItemList itemListClass={itemListClass} isDefaultStyles={isDefaultStyles}>
107
- {currentIndex > (paginationStart === 0 ? 0 : 1) ? (
108
- <Item
109
- itemClass={itemClass}
110
- itemStyle={defaultStylesEnum.itemClass}
111
- isDefaultStyles={isDefaultStyles}
112
- onClick={() => setIndex(currentIndex - 1)}
113
- >
114
- {`<<`}
115
- </Item>
116
- ) : (
117
- <Item
118
- itemClass={disableItemClass}
119
- itemStyle={defaultStylesEnum.disableItemClass}
120
- isDefaultStyles={isDefaultStyles}
121
- >
122
- {`<<`}
123
- </Item>
124
- )}
125
- {range(totalPages).map((el) => {
126
- const index = paginationStart === 0 ? el : el + 1;
127
- if (currentIndex === index) {
128
- return (
129
- <Item
130
- itemClass={selectedItemClass}
131
- itemStyle={defaultStylesEnum.selectedItemClass}
132
- isDefaultStyles={isDefaultStyles}
133
- key={el}
134
- >
135
- {el + 1}
136
- </Item>
137
- );
138
- }
139
- return (
140
- <Item
141
- itemClass={selectedItemClass}
142
- itemStyle={defaultStylesEnum.itemClass}
143
- isDefaultStyles={isDefaultStyles}
144
- key={el}
145
- onClick={() => setIndex(index)}
146
- >
147
- {el + 1}
148
- </Item>
149
- );
150
- })}
151
- {currentIndex < (paginationStart === 0 ? 3 : 4) ? (
152
- <Item
153
- itemClass={itemClass}
154
- itemStyle={defaultStylesEnum.itemClass}
155
- isDefaultStyles={isDefaultStyles}
156
- onClick={() => setIndex(currentIndex + 1)}
157
- >
158
- {`>>`}
159
- </Item>
160
- ) : (
161
- <Item
162
- itemClass={disableItemClass}
163
- itemStyle={defaultStylesEnum.disableItemClass}
164
- isDefaultStyles={isDefaultStyles}
165
- >
166
- {`>>`}
167
- </Item>
168
- )}
169
- </ItemList>
170
- </Wrapper>
171
- );
172
- }
173
-
174
- return (
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}
207
-
208
- {currentIndex < (paginationStart === 0 ? 3 : 4)
209
- ? range(4).map((el) => {
210
- const index = paginationStart === 0 ? el : el + 1;
211
- if (currentIndex === index) {
212
- return (
213
- <Item
214
- itemClass={selectedItemClass}
215
- itemStyle={defaultStylesEnum.selectedItemClass}
216
- isDefaultStyles={isDefaultStyles}
217
- key={el}
218
- >
219
- {el + 1}
220
- </Item>
221
- );
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}
236
-
237
- {currentIndex > (paginationStart === 0 ? 2 : 3) ? (
238
- <Item
239
- itemClass={disableItemClass}
240
- itemStyle={defaultStylesEnum.disableItemClass}
241
- isDefaultStyles={isDefaultStyles}
242
- >
243
- {`...`}
244
- </Item>
245
- ) : null}
246
-
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}
267
- onClick={() => setIndex(paginationStart === 0 ? totalPages - 4 : totalPages - 3)}
268
- >
269
- {totalPages - 3}
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
- )}
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>
290
-
291
- <Item
292
- itemClass={selectedItemClass}
293
- itemStyle={defaultStylesEnum.selectedItemClass}
294
- isDefaultStyles={isDefaultStyles}
295
- >
296
- {paginationStart === 0 ? currentIndex + 1 : currentIndex}
297
- </Item>
298
-
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}
311
-
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}
321
-
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}
332
-
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>
353
- );
354
- };
355
-
356
- export default Pagination;