@matthew.ngo/react-filter-pilot
Version:
Powerful filtering, pagination, and sorting for React with TanStack Query integration
3 lines • 1.53 kB
JavaScript
import {a}from'../chunk-KDVV4H2M.js';import {transformFilterValue}from'./transformUtils';/* @matthew.ngo/react-filter-pilot - MIT License */
function c(n,a){const t={};return a.forEach(r=>{const e=r.urlKey||r.name,u=n.get(e);u!==null&&(t[r.name]=transformFilterValue(u,r.transformFromUrl));}),t}a(c,"parseUrlParams");function d(n,a){const t=new URLSearchParams;return a.forEach(r=>{const e=n[r.name],u=r.urlKey||r.name;if(e==null||e===r.defaultValue||Array.isArray(e)&&e.length===0||typeof e=="string"&&e.trim()==="")return;const l=transformFilterValue(e,r.transformToUrl);l!==void 0&&l!==""&&t.set(u,String(l));}),t}a(d,"buildUrlParams");function U(n,a){const t=new URLSearchParams;return a.forEach(r=>{if(r.syncWithUrl===false)return;const e=n[r.name],u=r.urlKey||r.name;if(e==null||e===r.defaultValue||Array.isArray(e)&&e.length===0||typeof e=="string"&&e.trim()==="")return;const l=transformFilterValue(e,r.transformToUrl);l!==void 0&&l!==""&&t.set(u,String(l));}),t}a(U,"buildSyncableUrlParams");function o(n){return n.filter(a=>a.syncWithUrl!==false).map(a=>a.urlKey||a.name)}a(o,"getManagedUrlKeys");function h(n){return n.filter(a=>a.syncWithUrl===false).map(a=>a.urlKey||a.name)}a(h,"getNonManagedUrlKeys");function p(n,a){return o(a).forEach(r=>{n.delete(r);}),n}a(p,"clearManagedUrlParams");export{U as buildSyncableUrlParams,d as buildUrlParams,p as clearManagedUrlParams,o as getManagedUrlKeys,h as getNonManagedUrlKeys,c as parseUrlParams};//# sourceMappingURL=urlUtils.js.map
//# sourceMappingURL=urlUtils.js.map