@aboutbits/react-pagination
Advanced tools
Comparing version 0.0.10 to 1.0.0
@@ -13,3 +13,3 @@ var __assign = (this && this.__assign) || function () { | ||
import { useCallback, useMemo } from 'react'; | ||
import { useHistory, useLocation, useRouteMatch } from 'react-router-dom'; | ||
import { useNavigate, useLocation } from 'react-router-dom'; | ||
import { IndexType } from './types'; | ||
@@ -31,5 +31,4 @@ import { convert } from './utils'; | ||
var _a = config || {}, _b = _a.indexType, indexType = _b === void 0 ? IndexType.ZERO_BASED : _b, _c = _a.pageSize, pageSize = _c === void 0 ? 15 : _c; | ||
var routerHistory = useHistory(); | ||
var routerUrl = useRouteMatch().url; | ||
var routeQuery = useLocation().search; | ||
var navigate = useNavigate(); | ||
var _d = useLocation(), routerUrl = _d.pathname, routeQuery = _d.search; | ||
var params = useMemo(function () { return new URLSearchParams(routeQuery); }, [routeQuery]); | ||
@@ -49,7 +48,7 @@ var updateQuery = useCallback(function (queryParameters) { | ||
params.delete('size'); | ||
routerHistory.push({ | ||
navigate({ | ||
pathname: routerUrl, | ||
search: params.toString(), | ||
}); | ||
}, [routerHistory, params]); | ||
}, [navigate, params]); | ||
var clear = useCallback(function () { | ||
@@ -61,14 +60,14 @@ for (var parameter in config === null || config === void 0 ? void 0 : config.defaultQueryParameters) { | ||
params.delete('size'); | ||
routerHistory.push({ | ||
navigate({ | ||
pathname: routerUrl, | ||
search: params.toString(), | ||
}); | ||
}, [routerHistory, params]); | ||
}, [navigate, params]); | ||
var setPage = useCallback(function (page) { | ||
params.set('page', page.toString()); | ||
routerHistory.push({ | ||
navigate({ | ||
pathname: routerUrl, | ||
search: params.toString(), | ||
}); | ||
}, [routerHistory, params]); | ||
}, [navigate, params]); | ||
return { | ||
@@ -75,0 +74,0 @@ queryParameters: extractCurrentQueryParameters(params, config === null || config === void 0 ? void 0 : config.defaultQueryParameters), |
@@ -33,5 +33,4 @@ "use strict"; | ||
var _a = config || {}, _b = _a.indexType, indexType = _b === void 0 ? types_1.IndexType.ZERO_BASED : _b, _c = _a.pageSize, pageSize = _c === void 0 ? 15 : _c; | ||
var routerHistory = (0, react_router_dom_1.useHistory)(); | ||
var routerUrl = (0, react_router_dom_1.useRouteMatch)().url; | ||
var routeQuery = (0, react_router_dom_1.useLocation)().search; | ||
var navigate = (0, react_router_dom_1.useNavigate)(); | ||
var _d = (0, react_router_dom_1.useLocation)(), routerUrl = _d.pathname, routeQuery = _d.search; | ||
var params = (0, react_1.useMemo)(function () { return new URLSearchParams(routeQuery); }, [routeQuery]); | ||
@@ -51,7 +50,7 @@ var updateQuery = (0, react_1.useCallback)(function (queryParameters) { | ||
params.delete('size'); | ||
routerHistory.push({ | ||
navigate({ | ||
pathname: routerUrl, | ||
search: params.toString(), | ||
}); | ||
}, [routerHistory, params]); | ||
}, [navigate, params]); | ||
var clear = (0, react_1.useCallback)(function () { | ||
@@ -63,14 +62,14 @@ for (var parameter in config === null || config === void 0 ? void 0 : config.defaultQueryParameters) { | ||
params.delete('size'); | ||
routerHistory.push({ | ||
navigate({ | ||
pathname: routerUrl, | ||
search: params.toString(), | ||
}); | ||
}, [routerHistory, params]); | ||
}, [navigate, params]); | ||
var setPage = (0, react_1.useCallback)(function (page) { | ||
params.set('page', page.toString()); | ||
routerHistory.push({ | ||
navigate({ | ||
pathname: routerUrl, | ||
search: params.toString(), | ||
}); | ||
}, [routerHistory, params]); | ||
}, [navigate, params]); | ||
return { | ||
@@ -77,0 +76,0 @@ queryParameters: extractCurrentQueryParameters(params, config === null || config === void 0 ? void 0 : config.defaultQueryParameters), |
{ | ||
"name": "@aboutbits/react-pagination", | ||
"version": "0.0.10", | ||
"version": "1.0.0", | ||
"description": "Pagination hooks for React", | ||
"sideEffects": false, | ||
"engines": { | ||
"npm": "^8", | ||
"node": "^16" | ||
}, | ||
"scripts": { | ||
@@ -12,2 +16,3 @@ "build": "npm run build:node && npm run build:esm", | ||
"lint:fix": "npm run lint -- --fix", | ||
"typecheck": "tsc --noEmit", | ||
"test": "jest --verbose --passWithNoTests", | ||
@@ -43,28 +48,39 @@ "prepare": "npm run build", | ||
"devDependencies": { | ||
"@testing-library/jest-dom": "^5.11.10", | ||
"@testing-library/react": "^11.2.6", | ||
"@testing-library/react-hooks": "^5.1.3", | ||
"@types/jest": "^26.0.22", | ||
"@types/react": "^17.0.3", | ||
"@types/react-router-dom": "^5.1.8", | ||
"@typescript-eslint/eslint-plugin": "^4.21.0", | ||
"@typescript-eslint/parser": "^4.21.0", | ||
"eslint": "^7.23.0", | ||
"eslint-config-prettier": "^8.1.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-jest": "^24.3.4", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"jest": "^26.6.3", | ||
"next": "^11.0.1", | ||
"next-router-mock": "^0.6.1", | ||
"prettier": "^2.2.1", | ||
"@testing-library/jest-dom": "^5.16.4", | ||
"@testing-library/react": "^12.0.0", | ||
"@testing-library/react-hooks": "^8.0.1", | ||
"@types/jest": "^28.1.3", | ||
"@types/react": "^17.0.0", | ||
"@types/react-router-dom": "^5.3.3", | ||
"@typescript-eslint/eslint-plugin": "^5.30.0", | ||
"@typescript-eslint/parser": "^5.30.0", | ||
"eslint": "^8.18.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-jest": "^26.5.3", | ||
"eslint-plugin-prettier": "^4.1.0", | ||
"jest": "^28.1.1", | ||
"jest-environment-jsdom": "^28.1.1", | ||
"next": "^12.2.0", | ||
"next-router-mock": "^0.7.4", | ||
"prettier": "^2.7.1", | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2", | ||
"react-router-dom": "^5.2.0", | ||
"ts-jest": "^26.5.4", | ||
"typescript": "^4.2.4" | ||
"react-router-dom": "^6.3.0", | ||
"ts-jest": "^28.0.5", | ||
"typescript": "^4.7.4" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.0.0 || ^17.0.0" | ||
"next": "^12.0.0", | ||
"react": "^16.0.0 || ^17.0.0", | ||
"react-router-dom": "^6.0.0" | ||
}, | ||
"peerDependenciesMeta": { | ||
"next": { | ||
"optional": true | ||
}, | ||
"react-router-dom": { | ||
"optional": true | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
37692
0
3
23
541