@bodynarf/react.components 1.4.25 → 1.4.27
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.
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @returns Array of nearest numbers to current page
|
|
8
8
|
*/
|
|
9
9
|
export const generatePageNumbers = (page, count, size = 3) => {
|
|
10
|
-
if (page < 0 || count <= 0 || page > count
|
|
10
|
+
if (page < 0 || count <= 0 || page > count) {
|
|
11
11
|
return [];
|
|
12
12
|
}
|
|
13
13
|
return [
|
package/hooks/usePagination.d.ts
CHANGED
|
@@ -16,5 +16,5 @@ export interface PaginationState {
|
|
|
16
16
|
* @param dependencies List of dependencies. On any dependency update current page will be set to 1
|
|
17
17
|
* @returns Pair of hook-stored state and handler for slicing current page items
|
|
18
18
|
*/
|
|
19
|
-
export declare const usePagination: (length: number, size
|
|
19
|
+
export declare const usePagination: (length: number, size?: number, initPage?: number, dependencies?: DependencyList) => [PaginationState, (data: Array<any>) => Array<any>];
|
|
20
20
|
//# sourceMappingURL=usePagination.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePagination.d.ts","sourceRoot":"","sources":["../../src/hooks/usePagination.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA6C,MAAM,OAAO,CAAC;AAElF,2BAA2B;AAC3B,MAAM,WAAW,eAAe;IAC5B,6BAA6B;IAC7B,WAAW,EAAE,MAAM,CAAC;IAEpB,sBAAsB;IACtB,UAAU,EAAE,MAAM,CAAC;IAEnB,6BAA6B;IAC7B,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAKD;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,WAAY,MAAM,
|
|
1
|
+
{"version":3,"file":"usePagination.d.ts","sourceRoot":"","sources":["../../src/hooks/usePagination.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA6C,MAAM,OAAO,CAAC;AAElF,2BAA2B;AAC3B,MAAM,WAAW,eAAe;IAC5B,6BAA6B;IAC7B,WAAW,EAAE,MAAM,CAAC;IAEpB,sBAAsB;IACtB,UAAU,EAAE,MAAM,CAAC;IAEnB,6BAA6B;IAC7B,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAKD;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,WAAY,MAAM,SAAQ,MAAM,aAA8B,MAAM,6DAAmE,MAAM,GAAG,CAAC,KAAK,MAAM,GAAG,CAAC,CAwBzL,CAAC"}
|
package/hooks/usePagination.js
CHANGED
|
@@ -9,7 +9,7 @@ const defaultPageSize = 30;
|
|
|
9
9
|
* @param dependencies List of dependencies. On any dependency update current page will be set to 1
|
|
10
10
|
* @returns Pair of hook-stored state and handler for slicing current page items
|
|
11
11
|
*/
|
|
12
|
-
export const usePagination = (length, size = defaultPageSize, initPage = 1, dependencies) => {
|
|
12
|
+
export const usePagination = (length, size = defaultPageSize, initPage = 1, dependencies = []) => {
|
|
13
13
|
const [currentPage, setCurrentPage] = useState(initPage);
|
|
14
14
|
const count = useMemo(() => Math.ceil(length / size), [size, length]);
|
|
15
15
|
const onChange = useCallback((page) => setCurrentPage(page), [setCurrentPage]);
|