@react-pakistan/util-functions 3.0.3 → 3.0.4

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.
@@ -1 +1 @@
1
- var g=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var M=(e,r)=>{for(var i in r)g(e,i,{get:r[i],enumerable:!0})},Q=(e,r,i,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of x(r))!J.call(e,o)&&o!==i&&g(e,o,{get:()=>r[o],enumerable:!(c=U(r,o))||c.enumerable});return e};var B=e=>Q(g({},"__esModule",{value:!0}),e);var _={};M(_,{useModuleEntityV2:()=>H});module.exports=B(_);var d=require("react"),n=require("../constants/api-methods"),s=require("./use-fetch"),h=require("./use-debounce");const H=({byIdCallback:e,byIdDeps:r=[],byIdParams:i,deleteCallback:c,deleteDeps:o=[],deleteParams:p,listCallback:E,listDeps:k=[],listParams:u,listUrl:T,headers:l,searchQuery:C,unitByIdUrl:F,unitUrl:b,updateCallback:y,updateDeps:N=[],updateParams:P})=>{const w=(0,h.useDebounce)(C,800),a=(0,d.useRef)(null);(0,d.useEffect)(()=>()=>{a.current&&(globalThis.clearTimeout(a.current),a.current=null)},[]);const{error:I,fetchNow:f,loading:L}=(0,s.useFetch)(T,{method:n.API_METHODS.GET,params:u,headers:l,callback:E,credentials:!0},[w,u,...k]),m=(t=300)=>{a.current&&globalThis.clearTimeout(a.current),a.current=globalThis.setTimeout(()=>{try{f(void 0,{method:n.API_METHODS.GET,params:u,headers:l})}catch{}a.current=null},t)},{error:v,loading:A,fetchNow:V}=(0,s.useFetch)(b,{method:n.API_METHODS.PUT,body:JSON.stringify(P),headers:l,callback:t=>{if(y)try{y(t)}catch{}try{t&&t.ok&&m()}catch{}}},[...N]),{error:D,loading:R,fetchNow:j}=(0,s.useFetch)(F,{method:n.API_METHODS.GET,params:i,headers:l,callback:e},[...r]),{error:G,loading:O,fetchNow:S}=(0,s.useFetch)(b,{method:n.API_METHODS.DELETE,body:JSON.stringify(p),headers:l,callback:t=>{if(c)try{c(t)}catch{}try{t&&t.ok&&m()}catch{}}},[...o]);return{byIdError:D,byIdFetchNow:j,byIdLoading:R,deleteError:G,deleteFetchNow:S,deleteLoading:O,listError:I,listFetchNow:f,listLoading:L,updateError:v,updateFetchNow:V,updateLoading:A}};0&&(module.exports={useModuleEntityV2});
1
+ var g=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var x=(t,r)=>{for(var i in r)g(t,i,{get:r[i],enumerable:!0})},J=(t,r,i,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of S(r))!U.call(t,a)&&a!==i&&g(t,a,{get:()=>r[a],enumerable:!(c=O(r,a))||c.enumerable});return t};var M=t=>J(g({},"__esModule",{value:!0}),t);var H={};x(H,{useModuleEntityV2:()=>B});module.exports=M(H);var d=require("react"),n=require("../constants/api-methods"),s=require("./use-fetch");const B=({byIdCallback:t,byIdDeps:r=[],byIdParams:i,deleteCallback:c,deleteDeps:a=[],deleteParams:m,listCallback:p,listDeps:E=[],listParams:u,listUrl:k,headers:l,searchQuery:T,unitByIdUrl:C,unitUrl:b,updateCallback:y,updateDeps:F=[],updateParams:N})=>{const o=(0,d.useRef)(null);(0,d.useEffect)(()=>()=>{o.current&&(globalThis.clearTimeout(o.current),o.current=null)},[]);const{error:P,fetchNow:f,loading:w}=(0,s.useFetch)(k,{method:n.API_METHODS.GET,params:u,headers:l,callback:p,credentials:!0},[T,u,...E]),h=(e=300)=>{o.current&&globalThis.clearTimeout(o.current),o.current=globalThis.setTimeout(()=>{try{f(void 0,{method:n.API_METHODS.GET,params:u,headers:l})}catch{}o.current=null},e)},{error:I,loading:L,fetchNow:v}=(0,s.useFetch)(b,{method:n.API_METHODS.PUT,body:JSON.stringify(N),headers:l,callback:e=>{if(y)try{y(e)}catch{}try{e&&e.ok&&h()}catch{}}},[...F]),{error:A,loading:V,fetchNow:D}=(0,s.useFetch)(C,{method:n.API_METHODS.GET,params:i,headers:l,callback:t},[...r]),{error:R,loading:j,fetchNow:G}=(0,s.useFetch)(b,{method:n.API_METHODS.DELETE,body:JSON.stringify(m),headers:l,callback:e=>{if(c)try{c(e)}catch{}try{e&&e.ok&&h()}catch{}}},[...a]);return{byIdError:A,byIdFetchNow:D,byIdLoading:V,deleteError:R,deleteFetchNow:G,deleteLoading:j,listError:P,listFetchNow:f,listLoading:w,updateError:I,updateFetchNow:v,updateLoading:L}};0&&(module.exports={useModuleEntityV2});
@@ -1 +1 @@
1
- import{useRef as G,useEffect as O}from"react";import{API_METHODS as o}from"../constants/api-methods";import{useFetch as a}from"./use-fetch";import{useDebounce as S}from"./use-debounce";const B=({byIdCallback:u,byIdDeps:g=[],byIdParams:b,deleteCallback:n,deleteDeps:y=[],deleteParams:f,listCallback:m,listDeps:h=[],listParams:i,listUrl:p,headers:t,searchQuery:E,unitByIdUrl:k,unitUrl:c,updateCallback:l,updateDeps:T=[],updateParams:C})=>{const F=S(E,800),e=G(null);O(()=>()=>{e.current&&(globalThis.clearTimeout(e.current),e.current=null)},[]);const{error:N,fetchNow:s,loading:P}=a(p,{method:o.GET,params:i,headers:t,callback:m,credentials:!0},[F,i,...h]),d=(r=300)=>{e.current&&globalThis.clearTimeout(e.current),e.current=globalThis.setTimeout(()=>{try{s(void 0,{method:o.GET,params:i,headers:t})}catch{}e.current=null},r)},{error:w,loading:I,fetchNow:L}=a(c,{method:o.PUT,body:JSON.stringify(C),headers:t,callback:r=>{if(l)try{l(r)}catch{}try{r&&r.ok&&d()}catch{}}},[...T]),{error:v,loading:A,fetchNow:V}=a(k,{method:o.GET,params:b,headers:t,callback:u},[...g]),{error:D,loading:R,fetchNow:j}=a(c,{method:o.DELETE,body:JSON.stringify(f),headers:t,callback:r=>{if(n)try{n(r)}catch{}try{r&&r.ok&&d()}catch{}}},[...y]);return{byIdError:v,byIdFetchNow:V,byIdLoading:A,deleteError:D,deleteFetchNow:j,deleteLoading:R,listError:N,listFetchNow:s,listLoading:P,updateError:w,updateFetchNow:L,updateLoading:I}};export{B as useModuleEntityV2};
1
+ import{useRef as j,useEffect as G}from"react";import{API_METHODS as a}from"../constants/api-methods";import{useFetch as o}from"./use-fetch";const J=({byIdCallback:u,byIdDeps:g=[],byIdParams:b,deleteCallback:n,deleteDeps:y=[],deleteParams:f,listCallback:h,listDeps:m=[],listParams:i,listUrl:p,headers:e,searchQuery:E,unitByIdUrl:k,unitUrl:c,updateCallback:l,updateDeps:T=[],updateParams:C})=>{const t=j(null);G(()=>()=>{t.current&&(globalThis.clearTimeout(t.current),t.current=null)},[]);const{error:F,fetchNow:s,loading:N}=o(p,{method:a.GET,params:i,headers:e,callback:h,credentials:!0},[E,i,...m]),d=(r=300)=>{t.current&&globalThis.clearTimeout(t.current),t.current=globalThis.setTimeout(()=>{try{s(void 0,{method:a.GET,params:i,headers:e})}catch{}t.current=null},r)},{error:P,loading:w,fetchNow:I}=o(c,{method:a.PUT,body:JSON.stringify(C),headers:e,callback:r=>{if(l)try{l(r)}catch{}try{r&&r.ok&&d()}catch{}}},[...T]),{error:L,loading:v,fetchNow:A}=o(k,{method:a.GET,params:b,headers:e,callback:u},[...g]),{error:V,loading:D,fetchNow:R}=o(c,{method:a.DELETE,body:JSON.stringify(f),headers:e,callback:r=>{if(n)try{n(r)}catch{}try{r&&r.ok&&d()}catch{}}},[...y]);return{byIdError:L,byIdFetchNow:A,byIdLoading:v,deleteError:V,deleteFetchNow:R,deleteLoading:D,listError:F,listFetchNow:s,listLoading:N,updateError:P,updateFetchNow:I,updateLoading:w}};export{J as useModuleEntityV2};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pakistan/util-functions",
3
- "version": "3.0.3",
3
+ "version": "3.0.4",
4
4
  "description": "A library of all util functions",
5
5
  "scripts": {
6
6
  "add:tags": "scripts/add-tags.sh",