react-filter-by-url
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -8,6 +8,7 @@ /** | ||
*/ | ||
export declare function useFilter(params: string[], apiUrl: string): { | ||
queryStr: string; | ||
export declare function useUrlFilter(params: string[], apiUrl: string): { | ||
apiQuery: string; | ||
queryString: string; | ||
getDefaultParamValue: (params: string, defaultValue: string) => string; | ||
handleSelectFilter: (name: string, value: string) => void; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.useFilter = void 0; | ||
exports.useUrlFilter = void 0; | ||
const react_1 = require("react"); | ||
@@ -13,6 +13,7 @@ const react_router_dom_1 = require("react-router-dom"); | ||
*/ | ||
function useFilter(params, apiUrl) { | ||
function useUrlFilter(params, apiUrl) { | ||
const query = useQuery(); | ||
const navigate = (0, react_router_dom_1.useNavigate)(); | ||
const [queryStr, setQueryStr] = (0, react_1.useState)(apiUrl); | ||
const [apiQuery, setApiQuery] = (0, react_1.useState)(apiUrl); | ||
const [queryString, setQueryString] = (0, react_1.useState)(''); | ||
const handleSelectFilter = (name, value) => { | ||
@@ -22,3 +23,4 @@ const filter = convertParamsToFilterObject(params); | ||
const query = buildQuery(params, filter); | ||
setQueryStr(apiUrl + query); | ||
setApiQuery(apiUrl + query); | ||
setQueryString(query); | ||
navigate(query); | ||
@@ -44,3 +46,4 @@ }; | ||
return { | ||
queryStr, | ||
apiQuery, | ||
queryString, | ||
getDefaultParamValue, | ||
@@ -50,3 +53,3 @@ handleSelectFilter | ||
} | ||
exports.useFilter = useFilter; | ||
exports.useUrlFilter = useUrlFilter; | ||
function useQuery() { | ||
@@ -53,0 +56,0 @@ const { search } = (0, react_router_dom_1.useLocation)(); |
@@ -8,6 +8,7 @@ /** | ||
*/ | ||
export declare function useFilter(params: string[], apiUrl: string): { | ||
queryStr: string; | ||
export declare function useUrlFilter(params: string[], apiUrl: string): { | ||
apiQuery: string; | ||
queryString: string; | ||
getDefaultParamValue: (params: string, defaultValue: string) => string; | ||
handleSelectFilter: (name: string, value: string) => void; | ||
}; |
@@ -10,6 +10,7 @@ import { useMemo, useState } from 'react'; | ||
*/ | ||
export function useFilter(params, apiUrl) { | ||
export function useUrlFilter(params, apiUrl) { | ||
const query = useQuery(); | ||
const navigate = useNavigate(); | ||
const [queryStr, setQueryStr] = useState(apiUrl); | ||
const [apiQuery, setApiQuery] = useState(apiUrl); | ||
const [queryString, setQueryString] = useState(''); | ||
const handleSelectFilter = (name, value) => { | ||
@@ -19,3 +20,4 @@ const filter = convertParamsToFilterObject(params); | ||
const query = buildQuery(params, filter); | ||
setQueryStr(apiUrl + query); | ||
setApiQuery(apiUrl + query); | ||
setQueryString(query); | ||
navigate(query); | ||
@@ -41,3 +43,4 @@ }; | ||
return { | ||
queryStr, | ||
apiQuery, | ||
queryString, | ||
getDefaultParamValue, | ||
@@ -44,0 +47,0 @@ handleSelectFilter |
{ | ||
"name": "react-filter-by-url", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
14223
170