react-luminus-components 2.1.10 → 2.1.11

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.
@@ -17,6 +17,7 @@ export { default as usePersistentState } from './usePersistentState/usePersisten
17
17
  export { default as useEmployeePhotoPath } from './useEmployeePhotoPath/useEmployeePhotoPath';
18
18
  export { default as useClipboard } from './useClipboard/useClipboard';
19
19
  export { default as useGetApiDataBound } from './useGetApiDataBound/useGetApiDataBound';
20
+ export { default as useGetDataBoundExtended } from './useGetDataBound/useGetDataBoundExtended';
20
21
  export { default as useWindowSize } from './useWindowSize/useWindowSize';
21
22
  export { default as useRenderDraggableInPortal } from './useRenderDraggableInPortal/useRenderDraggableInPortal';
22
23
  export { default as useScrollSave } from './useScrollSave/useScrollSave';
@@ -0,0 +1,9 @@
1
+ type UseGetDataBoundExtendedOptions = {
2
+ customBaseUrl?: string;
3
+ customToken?: string;
4
+ };
5
+ declare function useGetDataBoundExtended<T>(url: string, options?: UseGetDataBoundExtendedOptions): {
6
+ data: T;
7
+ reloadData: () => void;
8
+ };
9
+ export default useGetDataBoundExtended;
package/dist/hooks.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./DelegationContext-B1WXROG2.cjs"),P=require("./useIsFormDirty-76y8Dca-.cjs"),G=require("./useWindowSize-CLoDaEYh.cjs"),d=require("react"),K=require("./index-jmbq5h95.cjs"),Q=require("react-dom"),W=require("./useIsBrowserOnline-CREGrf2l.cjs"),T=new Map;function _(s,n){const e=v.useAxios({silent:!0,differentBaseUrl:n==null?void 0:n.customBaseUrl,customToken:n==null?void 0:n.customToken}),t=d.useRef(null);if(!T.has(s)){const f=e.get(s).then(r=>(T.set(s,{status:"success",data:r.data}),t.current=setTimeout(()=>{T.delete(s),t.current=null},1e4),r.data)).catch(r=>{throw T.set(s,{status:"error",error:r}),t.current=setTimeout(()=>{T.delete(s),t.current=null},1e3),r});throw T.set(s,{status:"pending",promise:f}),f}const o=T.get(s);if(o.status==="pending")throw o.promise;if(o.status==="error")throw o.error;return o.data}const z=s=>n=>(window.addEventListener(`storage_${s}`,n),()=>window.removeEventListener(`storage_${s}`,n)),J=(s,n,e)=>{const t=K.compilerRuntimeExports.c(15),o=e===void 0?localStorage:e,[f]=d.useState(n);let r;t[0]!==n?(r=JSON.stringify(n),t[0]=n,t[1]=r):r=t[1];const u=d.useRef(r),w=d.useRef(n);let S;t[2]!==s||t[3]!==f||t[4]!==o?(S=()=>{const l=o.getItem(s);return l!==u.current&&(u.current=l,w.current=u.current?JSON.parse(u.current):f),w.current},t[2]=s,t[3]=f,t[4]=o,t[5]=S):S=t[5];const y=S;let m;t[6]!==s?(m=z(s),t[6]=s,t[7]=m):m=t[7];const I=m,i=d.useSyncExternalStore(I,y);let a;t[8]!==y||t[9]!==s||t[10]!==o?(a=l=>{const O=typeof l=="function"?l(y()):l;o.setItem(s,JSON.stringify(O)),window.dispatchEvent(new Event(`storage_${s}`))},t[8]=y,t[9]=s,t[10]=o,t[11]=a):a=t[11];const c=a;let h;return t[12]!==c||t[13]!==i?(h=[i,c],t[12]=c,t[13]=i,t[14]=h):h=t[14],h},M=(s,n,e)=>{let t="pending",o;const f=s.then(r=>{t="success",o=r},r=>{const u=r==null?void 0:r.response;(u==null?void 0:u.status)===404&&e?(t="error-404",o=r):(t="error",o=r)});return()=>{switch(t){case"pending":throw f;case"success":return o;case"error":if(o.code==="ERR_CANCELED")return null;throw o;case"error-404":throw new Error("404");default:throw new Error("Unknown status")}}},b={loadOnInit:!0,silent:!1,enabled:!0,nullStateBeforeLoad:!0,nullStateOnFail:!1},Z=(s,n)=>{const e=K.compilerRuntimeExports.c(26),{loadOnInit:t,enabled:o,silent:f,nullStateBeforeLoad:r,nullStateOnFail:u,customApiUrl:w,customBearerToken:S,dataTransformer:y,errorBoundaryOn404:m}=n===void 0?b:n,I=t===void 0?b.loadOnInit:t,i=o===void 0?b.enabled:o,a=f===void 0?b.silent:f,c=r===void 0?b.nullStateBeforeLoad:r,h=u===void 0?b.nullStateOnFail:u;let p;e[0]!==m?(p=m?[404]:void 0,e[0]=m,e[1]=p):p=e[1];let l;e[2]!==w||e[3]!==S||e[4]!==a||e[5]!==p?(l={silent:a,customToken:S,differentBaseUrl:w,noToastOnStatus:p},e[2]=w,e[3]=S,e[4]=a,e[5]=p,e[6]=l):l=e[6];const O=v.useAxios(l),{startLoading:D,stopLoading:g}=d.useContext(v.LoadingContext),E=d.useRef(0),{isAuthenticated:B}=v.useAuth(),[R,N]=d.useState(null);let A;e[7]!==O||e[8]!==y||e[9]!==i||e[10]!==m||e[11]!==B||e[12]!==c||e[13]!==h||e[14]!==a||e[15]!==D||e[16]!==g||e[17]!==s?(A=async($,U)=>{if(!B()||i===!1)return;!a&&D(`loadData-${s}-${U}`),c&&N(null);const H=O.get(s,{signal:$}).then(V=>y?y(V.data):V.data).finally(()=>!a&&g(`loadData-${s}-${U}`));N(M(H,h??!1,m??!1))},e[7]=O,e[8]=y,e[9]=i,e[10]=m,e[11]=B,e[12]=c,e[13]=h,e[14]=a,e[15]=D,e[16]=g,e[17]=s,e[18]=A):A=e[18];const C=A;let x,L;e[19]!==C||e[20]!==I?(L=()=>{if(I===!1)return;const $=new AbortController;return C($.signal,E.current=E.current+1),()=>{$.abort()}},x=[C,I],e[19]=C,e[20]=I,e[21]=x,e[22]=L):(x=e[21],L=e[22]),d.useEffect(L,x);let q;return e[23]!==R||e[24]!==C?(q={data:R,setData:N,reloadData:C},e[23]=R,e[24]=C,e[25]=q):q=e[25],q},j=()=>{const s=d.useRef({}).current;return d.useEffect(()=>{const n=document.createElement("div");return n.style.position="absolute",n.style.pointerEvents="none",n.style.top="0",n.style.width="100%",n.style.height="100%",s.elt=n,document.body.appendChild(n),()=>{document.body.removeChild(n)}},[s]),n=>(e,...t)=>{const o=n(e,...t);return e.draggableProps.style.position==="fixed"?Q.createPortal(o,s.elt):o}},F={storageKey:"--tmp-scroll-save--",requiredHeight:100,retryInterval:50},X=(s,n)=>{const e=K.compilerRuntimeExports.c(18),{storageKey:t,requiredHeight:o,retryInterval:f}=n===void 0?F:n,r=t===void 0?F.storageKey:t,u=o===void 0?F.requiredHeight:o,w=f===void 0?F.retryInterval:f,[S,y]=d.useState(!1),m=d.useRef(null);let I;e[0]!==r?(I=()=>{const g=localStorage.getItem(r);return localStorage.removeItem(r),g===null?null:Number(g)},e[0]=r,e[1]=I):I=e[1];const i=I;let a;e[2]!==r?(a=g=>{localStorage.setItem(r,g)},e[2]=r,e[3]=a):a=e[3];const c=a;let h,p;e[4]!==S||e[5]!==u||e[6]!==i||e[7]!==w||e[8]!==s?(h=()=>{const g=window.setInterval(()=>{if(!S&&s.current!==null&&s.current.getBoundingClientRect().height>u){y(!0);const E=i();E!==null&&s.current.scrollTo({top:E}),window.clearInterval(g)}},w);return()=>{window.clearTimeout(g)}},p=[S,u,i,w,s],e[4]=S,e[5]=u,e[6]=i,e[7]=w,e[8]=s,e[9]=h,e[10]=p):(h=e[9],p=e[10]),d.useEffect(h,p);let l,O;e[11]!==c||e[12]!==s?(l=()=>{var E;const g=new AbortController;return(E=s.current)==null||E.addEventListener("scrollend",()=>{var B;m.current=((B=s.current)==null?void 0:B.scrollTop)??0,c((m.current??0).toString())},{signal:g.signal}),()=>g.abort()},O=[c,s],e[11]=c,e[12]=s,e[13]=l,e[14]=O):(l=e[13],O=e[14]),d.useEffect(l,O);let D;return e[15]!==i||e[16]!==c?(D={saveValue:c,retrieveValue:i},e[15]=i,e[16]=c,e[17]=D):D=e[17],D};exports.cancelToken=v.cancelToken;exports.useAuth=v.useAuth;exports.useAxios=v.useAxios;exports.useConfirm=v.useConfirm;exports.useGetApiData=v.useGetApiData;exports.useKeyPress=v.useKeyPress;exports.useLocalStorageState=v.useLocalStorageState;exports.useNotifications=v.useNotifications;exports.usePrompt=v.usePrompt;exports.useClipboard=P.useClipboard;exports.useEmployeePhotoPath=P.useEmployeePhotoPath;exports.useFormControlType=P.useFormControlType;exports.useIsFormDirty=P.useIsFormDirty;exports.useSearchQuery=P.useSearchQuery;exports.useSearchQueryState=P.useSearchQueryState;exports.useZodSchemaTypes=P.useZodSchemaTypes;exports.useClickOutside=G.useClickOutside;exports.usePermissions=G.usePermissions;exports.useWindowSize=G.useWindowSize;exports.useIsBrowserOnline=W.useIsBrowserOnline;exports.useGetApiDataBound=Z;exports.useGetDataBound=_;exports.usePersistentState=J;exports.useRenderDraggableInPortal=j;exports.useScrollSave=X;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./DelegationContext-B1WXROG2.cjs"),x=require("./useIsFormDirty-76y8Dca-.cjs"),U=require("./useWindowSize-CLoDaEYh.cjs"),l=require("react"),K=require("./index-jmbq5h95.cjs"),Q=require("react-dom"),W=require("./useIsBrowserOnline-CREGrf2l.cjs"),B=new Map;function _(t,n){const e=h.useAxios({silent:!0,differentBaseUrl:n==null?void 0:n.customBaseUrl,customToken:n==null?void 0:n.customToken}),s=l.useRef(null);if(!B.has(t)){const u=e.get(t).then(o=>(B.set(t,{status:"success",data:o.data}),s.current=setTimeout(()=>{B.delete(t),s.current=null},1e4),o.data)).catch(o=>{throw B.set(t,{status:"error",error:o}),s.current=setTimeout(()=>{B.delete(t),s.current=null},1e3),o});throw B.set(t,{status:"pending",promise:u}),u}const r=B.get(t);if(r.status==="pending")throw r.promise;if(r.status==="error")throw r.error;return r.data}const z=t=>n=>(window.addEventListener(`storage_${t}`,n),()=>window.removeEventListener(`storage_${t}`,n)),J=(t,n,e)=>{const s=K.compilerRuntimeExports.c(15),r=e===void 0?localStorage:e,[u]=l.useState(n);let o;s[0]!==n?(o=JSON.stringify(n),s[0]=n,s[1]=o):o=s[1];const a=l.useRef(o),p=l.useRef(n);let S;s[2]!==t||s[3]!==u||s[4]!==r?(S=()=>{const i=r.getItem(t);return i!==a.current&&(a.current=i,p.current=a.current?JSON.parse(a.current):u),p.current},s[2]=t,s[3]=u,s[4]=r,s[5]=S):S=s[5];const y=S;let m;s[6]!==t?(m=z(t),s[6]=t,s[7]=m):m=s[7];const T=m,d=l.useSyncExternalStore(T,y);let c;s[8]!==y||s[9]!==t||s[10]!==r?(c=i=>{const D=typeof i=="function"?i(y()):i;r.setItem(t,JSON.stringify(D)),window.dispatchEvent(new Event(`storage_${t}`))},s[8]=y,s[9]=t,s[10]=r,s[11]=c):c=s[11];const f=c;let w;return s[12]!==f||s[13]!==d?(w=[d,f],s[12]=f,s[13]=d,s[14]=w):w=s[14],w},k=(t,n,e)=>{let s="pending",r;const u=t.then(o=>{s="success",r=o},o=>{const a=o==null?void 0:o.response;(a==null?void 0:a.status)===404&&e?(s="error-404",r=o):(s="error",r=o)});return()=>{switch(s){case"pending":throw u;case"success":return r;case"error":if(r.code==="ERR_CANCELED")return null;throw r;case"error-404":throw new Error("404");default:throw new Error("Unknown status")}}},P={loadOnInit:!0,silent:!1,enabled:!0,nullStateBeforeLoad:!0,nullStateOnFail:!1},Z=(t,n)=>{const e=K.compilerRuntimeExports.c(26),{loadOnInit:s,enabled:r,silent:u,nullStateBeforeLoad:o,nullStateOnFail:a,customApiUrl:p,customBearerToken:S,dataTransformer:y,errorBoundaryOn404:m}=n===void 0?P:n,T=s===void 0?P.loadOnInit:s,d=r===void 0?P.enabled:r,c=u===void 0?P.silent:u,f=o===void 0?P.nullStateBeforeLoad:o,w=a===void 0?P.nullStateOnFail:a;let v;e[0]!==m?(v=m?[404]:void 0,e[0]=m,e[1]=v):v=e[1];let i;e[2]!==p||e[3]!==S||e[4]!==c||e[5]!==v?(i={silent:c,customToken:S,differentBaseUrl:p,noToastOnStatus:v},e[2]=p,e[3]=S,e[4]=c,e[5]=v,e[6]=i):i=e[6];const D=h.useAxios(i),{startLoading:I,stopLoading:g}=l.useContext(h.LoadingContext),E=l.useRef(0),{isAuthenticated:b}=h.useAuth(),[G,N]=l.useState(null);let A;e[7]!==D||e[8]!==y||e[9]!==d||e[10]!==m||e[11]!==b||e[12]!==f||e[13]!==w||e[14]!==c||e[15]!==I||e[16]!==g||e[17]!==t?(A=async(R,V)=>{if(!b()||d===!1)return;!c&&I(`loadData-${t}-${V}`),f&&N(null);const M=D.get(t,{signal:R}).then(H=>y?y(H.data):H.data).finally(()=>!c&&g(`loadData-${t}-${V}`));N(k(M,w??!1,m??!1))},e[7]=D,e[8]=y,e[9]=d,e[10]=m,e[11]=b,e[12]=f,e[13]=w,e[14]=c,e[15]=I,e[16]=g,e[17]=t,e[18]=A):A=e[18];const C=A;let L,$;e[19]!==C||e[20]!==T?($=()=>{if(T===!1)return;const R=new AbortController;return C(R.signal,E.current=E.current+1),()=>{R.abort()}},L=[C,T],e[19]=C,e[20]=T,e[21]=L,e[22]=$):(L=e[21],$=e[22]),l.useEffect($,L);let q;return e[23]!==G||e[24]!==C?(q={data:G,setData:N,reloadData:C},e[23]=G,e[24]=C,e[25]=q):q=e[25],q},O=new Map;function j(t,n){const e=h.useAxios({silent:!0,differentBaseUrl:n==null?void 0:n.customBaseUrl,customToken:n==null?void 0:n.customToken}),s=l.useRef(null),r=l.useCallback(()=>e.get(t).then(a=>(O.set(t,{status:"success",data:a.data}),s.current=window.setTimeout(()=>{O.delete(t),s.current=null},1e3*10),a.data)).catch(a=>{throw O.set(t,{status:"error",error:a}),s.current=window.setTimeout(()=>{O.delete(t),s.current=null},1e3*1),a}),[e,t]);if(!O.has(t)){const a=r();throw O.set(t,{status:"pending",promise:a}),a}const u=O.get(t);if(u.status==="pending")throw u.promise;if(u.status==="error")throw u.error;const o=l.useCallback(()=>{l.startTransition(()=>{O.delete(t),s.current!==null&&(window.clearTimeout(s.current),s.current=null),r()})},[r,t]);return{data:u.data,reloadData:o}}const X=()=>{const t=l.useRef({}).current;return l.useEffect(()=>{const n=document.createElement("div");return n.style.position="absolute",n.style.pointerEvents="none",n.style.top="0",n.style.width="100%",n.style.height="100%",t.elt=n,document.body.appendChild(n),()=>{document.body.removeChild(n)}},[t]),n=>(e,...s)=>{const r=n(e,...s);return e.draggableProps.style.position==="fixed"?Q.createPortal(r,t.elt):r}},F={storageKey:"--tmp-scroll-save--",requiredHeight:100,retryInterval:50},Y=(t,n)=>{const e=K.compilerRuntimeExports.c(18),{storageKey:s,requiredHeight:r,retryInterval:u}=n===void 0?F:n,o=s===void 0?F.storageKey:s,a=r===void 0?F.requiredHeight:r,p=u===void 0?F.retryInterval:u,[S,y]=l.useState(!1),m=l.useRef(null);let T;e[0]!==o?(T=()=>{const g=localStorage.getItem(o);return localStorage.removeItem(o),g===null?null:Number(g)},e[0]=o,e[1]=T):T=e[1];const d=T;let c;e[2]!==o?(c=g=>{localStorage.setItem(o,g)},e[2]=o,e[3]=c):c=e[3];const f=c;let w,v;e[4]!==S||e[5]!==a||e[6]!==d||e[7]!==p||e[8]!==t?(w=()=>{const g=window.setInterval(()=>{if(!S&&t.current!==null&&t.current.getBoundingClientRect().height>a){y(!0);const E=d();E!==null&&t.current.scrollTo({top:E}),window.clearInterval(g)}},p);return()=>{window.clearTimeout(g)}},v=[S,a,d,p,t],e[4]=S,e[5]=a,e[6]=d,e[7]=p,e[8]=t,e[9]=w,e[10]=v):(w=e[9],v=e[10]),l.useEffect(w,v);let i,D;e[11]!==f||e[12]!==t?(i=()=>{var E;const g=new AbortController;return(E=t.current)==null||E.addEventListener("scrollend",()=>{var b;m.current=((b=t.current)==null?void 0:b.scrollTop)??0,f((m.current??0).toString())},{signal:g.signal}),()=>g.abort()},D=[f,t],e[11]=f,e[12]=t,e[13]=i,e[14]=D):(i=e[13],D=e[14]),l.useEffect(i,D);let I;return e[15]!==d||e[16]!==f?(I={saveValue:f,retrieveValue:d},e[15]=d,e[16]=f,e[17]=I):I=e[17],I};exports.cancelToken=h.cancelToken;exports.useAuth=h.useAuth;exports.useAxios=h.useAxios;exports.useConfirm=h.useConfirm;exports.useGetApiData=h.useGetApiData;exports.useKeyPress=h.useKeyPress;exports.useLocalStorageState=h.useLocalStorageState;exports.useNotifications=h.useNotifications;exports.usePrompt=h.usePrompt;exports.useClipboard=x.useClipboard;exports.useEmployeePhotoPath=x.useEmployeePhotoPath;exports.useFormControlType=x.useFormControlType;exports.useIsFormDirty=x.useIsFormDirty;exports.useSearchQuery=x.useSearchQuery;exports.useSearchQueryState=x.useSearchQueryState;exports.useZodSchemaTypes=x.useZodSchemaTypes;exports.useClickOutside=U.useClickOutside;exports.usePermissions=U.usePermissions;exports.useWindowSize=U.useWindowSize;exports.useIsBrowserOnline=W.useIsBrowserOnline;exports.useGetApiDataBound=Z;exports.useGetDataBound=_;exports.useGetDataBoundExtended=j;exports.usePersistentState=J;exports.useRenderDraggableInPortal=X;exports.useScrollSave=Y;
package/dist/hooks.es.js CHANGED
@@ -1,83 +1,83 @@
1
- import { u as _, L as J, i as Q } from "./DelegationContext-CCnk58PI.js";
2
- import { l as ut, d as it, b as ct, h as dt, g as ft, e as mt, c as gt } from "./DelegationContext-CCnk58PI.js";
3
- import { c as ht, f as St, u as pt, a as wt, d as yt, e as It, b as Ot } from "./useIsFormDirty-Ba5uhPH7.js";
4
- import { b as Tt, a as Ct, u as Et } from "./useWindowSize-7W91GsJQ.js";
5
- import { useRef as D, useState as U, useSyncExternalStore as W, useContext as z, useEffect as F } from "react";
6
- import { c as V } from "./index-4IYT9u10.js";
7
- import { createPortal as M } from "react-dom";
8
- import { u as xt } from "./useIsBrowserOnline-RAirIO4c.js";
9
- const T = /* @__PURE__ */ new Map();
10
- function et(s, n) {
11
- const t = _({
1
+ import { u as V, L as Q, i as W } from "./DelegationContext-CCnk58PI.js";
2
+ import { l as ft, d as mt, b as gt, h as ht, g as wt, e as vt, c as St } from "./DelegationContext-CCnk58PI.js";
3
+ import { c as Tt, f as yt, u as It, a as bt, d as Ot, e as Dt, b as Bt } from "./useIsFormDirty-Ba5uhPH7.js";
4
+ import { b as Et, a as xt, u as Lt } from "./useWindowSize-7W91GsJQ.js";
5
+ import { useRef as B, useState as q, useSyncExternalStore as z, useContext as Z, useEffect as N, useCallback as J, startTransition as j } from "react";
6
+ import { c as G } from "./index-4IYT9u10.js";
7
+ import { createPortal as R } from "react-dom";
8
+ import { u as Pt } from "./useIsBrowserOnline-RAirIO4c.js";
9
+ const D = /* @__PURE__ */ new Map();
10
+ function rt(e, n) {
11
+ const t = V({
12
12
  silent: !0,
13
13
  differentBaseUrl: n == null ? void 0 : n.customBaseUrl,
14
14
  customToken: n == null ? void 0 : n.customToken
15
- }), e = D(null);
16
- if (!T.has(s)) {
17
- const d = t.get(s).then((r) => (T.set(s, {
15
+ }), s = B(null);
16
+ if (!D.has(e)) {
17
+ const u = t.get(e).then((a) => (D.set(e, {
18
18
  status: "success",
19
- data: r.data
20
- }), e.current = setTimeout(() => {
21
- T.delete(s), e.current = null;
22
- }, 1e4), r.data)).catch((r) => {
23
- throw T.set(s, {
19
+ data: a.data
20
+ }), s.current = setTimeout(() => {
21
+ D.delete(e), s.current = null;
22
+ }, 1e4), a.data)).catch((a) => {
23
+ throw D.set(e, {
24
24
  status: "error",
25
- error: r
26
- }), e.current = setTimeout(() => {
27
- T.delete(s), e.current = null;
28
- }, 1e3), r;
25
+ error: a
26
+ }), s.current = setTimeout(() => {
27
+ D.delete(e), s.current = null;
28
+ }, 1e3), a;
29
29
  });
30
- throw T.set(s, {
30
+ throw D.set(e, {
31
31
  status: "pending",
32
- promise: d
33
- }), d;
32
+ promise: u
33
+ }), u;
34
34
  }
35
- const o = T.get(s);
36
- if (o.status === "pending")
37
- throw o.promise;
38
- if (o.status === "error")
39
- throw o.error;
40
- return o.data;
35
+ const r = D.get(e);
36
+ if (r.status === "pending")
37
+ throw r.promise;
38
+ if (r.status === "error")
39
+ throw r.error;
40
+ return r.data;
41
41
  }
42
- const Z = (s) => (n) => (window.addEventListener(`storage_${s}`, n), () => window.removeEventListener(`storage_${s}`, n)), st = (s, n, t) => {
43
- const e = V.c(15), o = t === void 0 ? localStorage : t, [d] = U(n);
44
- let r;
45
- e[0] !== n ? (r = JSON.stringify(n), e[0] = n, e[1] = r) : r = e[1];
46
- const l = D(r), S = D(n);
42
+ const X = (e) => (n) => (window.addEventListener(`storage_${e}`, n), () => window.removeEventListener(`storage_${e}`, n)), at = (e, n, t) => {
43
+ const s = G.c(15), r = t === void 0 ? localStorage : t, [u] = q(n);
44
+ let a;
45
+ s[0] !== n ? (a = JSON.stringify(n), s[0] = n, s[1] = a) : a = s[1];
46
+ const o = B(a), v = B(n);
47
47
  let g;
48
- e[2] !== s || e[3] !== d || e[4] !== o ? (g = () => {
49
- const u = o.getItem(s);
50
- return u !== l.current && (l.current = u, S.current = l.current ? JSON.parse(l.current) : d), S.current;
51
- }, e[2] = s, e[3] = d, e[4] = o, e[5] = g) : g = e[5];
52
- const p = g;
48
+ s[2] !== e || s[3] !== u || s[4] !== r ? (g = () => {
49
+ const c = r.getItem(e);
50
+ return c !== o.current && (o.current = c, v.current = o.current ? JSON.parse(o.current) : u), v.current;
51
+ }, s[2] = e, s[3] = u, s[4] = r, s[5] = g) : g = s[5];
52
+ const S = g;
53
53
  let f;
54
- e[6] !== s ? (f = Z(s), e[6] = s, e[7] = f) : f = e[7];
55
- const i = W(f, p);
56
- let a;
57
- e[8] !== p || e[9] !== s || e[10] !== o ? (a = (u) => {
58
- const y = typeof u == "function" ? u(p()) : u;
59
- o.setItem(s, JSON.stringify(y)), window.dispatchEvent(new Event(`storage_${s}`));
60
- }, e[8] = p, e[9] = s, e[10] = o, e[11] = a) : a = e[11];
61
- const c = a;
62
- let v;
63
- return e[12] !== c || e[13] !== i ? (v = [i, c], e[12] = c, e[13] = i, e[14] = v) : v = e[14], v;
64
- }, j = (s, n, t) => {
65
- let e = "pending", o;
66
- const d = s.then((r) => {
67
- e = "success", o = r;
68
- }, (r) => {
69
- const l = r == null ? void 0 : r.response;
70
- (l == null ? void 0 : l.status) === 404 && t ? (e = "error-404", o = r) : (e = "error", o = r);
54
+ s[6] !== e ? (f = X(e), s[6] = e, s[7] = f) : f = s[7];
55
+ const i = z(f, S);
56
+ let l;
57
+ s[8] !== S || s[9] !== e || s[10] !== r ? (l = (c) => {
58
+ const T = typeof c == "function" ? c(S()) : c;
59
+ r.setItem(e, JSON.stringify(T)), window.dispatchEvent(new Event(`storage_${e}`));
60
+ }, s[8] = S, s[9] = e, s[10] = r, s[11] = l) : l = s[11];
61
+ const d = l;
62
+ let h;
63
+ return s[12] !== d || s[13] !== i ? (h = [i, d], s[12] = d, s[13] = i, s[14] = h) : h = s[14], h;
64
+ }, Y = (e, n, t) => {
65
+ let s = "pending", r;
66
+ const u = e.then((a) => {
67
+ s = "success", r = a;
68
+ }, (a) => {
69
+ const o = a == null ? void 0 : a.response;
70
+ (o == null ? void 0 : o.status) === 404 && t ? (s = "error-404", r = a) : (s = "error", r = a);
71
71
  });
72
72
  return () => {
73
- switch (e) {
73
+ switch (s) {
74
74
  case "pending":
75
- throw d;
75
+ throw u;
76
76
  case "success":
77
- return o;
77
+ return r;
78
78
  case "error":
79
- if (o.code === "ERR_CANCELED") return null;
80
- throw o;
79
+ if (r.code === "ERR_CANCELED") return null;
80
+ throw r;
81
81
  case "error-404":
82
82
  throw new Error("404");
83
83
  default:
@@ -90,147 +90,189 @@ const Z = (s) => (n) => (window.addEventListener(`storage_${s}`, n), () => windo
90
90
  enabled: !0,
91
91
  nullStateBeforeLoad: !0,
92
92
  nullStateOnFail: !1
93
- }, nt = (s, n) => {
94
- const t = V.c(26), {
95
- loadOnInit: e,
96
- enabled: o,
97
- silent: d,
98
- nullStateBeforeLoad: r,
99
- nullStateOnFail: l,
100
- customApiUrl: S,
93
+ }, ot = (e, n) => {
94
+ const t = G.c(26), {
95
+ loadOnInit: s,
96
+ enabled: r,
97
+ silent: u,
98
+ nullStateBeforeLoad: a,
99
+ nullStateOnFail: o,
100
+ customApiUrl: v,
101
101
  customBearerToken: g,
102
- dataTransformer: p,
102
+ dataTransformer: S,
103
103
  errorBoundaryOn404: f
104
- } = n === void 0 ? E : n, w = e === void 0 ? E.loadOnInit : e, i = o === void 0 ? E.enabled : o, a = d === void 0 ? E.silent : d, c = r === void 0 ? E.nullStateBeforeLoad : r, v = l === void 0 ? E.nullStateOnFail : l;
105
- let h;
106
- t[0] !== f ? (h = f ? [404] : void 0, t[0] = f, t[1] = h) : h = t[1];
107
- let u;
108
- t[2] !== S || t[3] !== g || t[4] !== a || t[5] !== h ? (u = {
109
- silent: a,
104
+ } = n === void 0 ? E : n, p = s === void 0 ? E.loadOnInit : s, i = r === void 0 ? E.enabled : r, l = u === void 0 ? E.silent : u, d = a === void 0 ? E.nullStateBeforeLoad : a, h = o === void 0 ? E.nullStateOnFail : o;
105
+ let w;
106
+ t[0] !== f ? (w = f ? [404] : void 0, t[0] = f, t[1] = w) : w = t[1];
107
+ let c;
108
+ t[2] !== v || t[3] !== g || t[4] !== l || t[5] !== w ? (c = {
109
+ silent: l,
110
110
  customToken: g,
111
- differentBaseUrl: S,
112
- noToastOnStatus: h
113
- }, t[2] = S, t[3] = g, t[4] = a, t[5] = h, t[6] = u) : u = t[6];
114
- const y = _(u), {
115
- startLoading: I,
111
+ differentBaseUrl: v,
112
+ noToastOnStatus: w
113
+ }, t[2] = v, t[3] = g, t[4] = l, t[5] = w, t[6] = c) : c = t[6];
114
+ const T = V(c), {
115
+ startLoading: y,
116
116
  stopLoading: m
117
- } = z(J), O = D(0), {
117
+ } = Z(Q), I = B(0), {
118
118
  isAuthenticated: C
119
- } = Q(), [N, K] = U(null);
119
+ } = W(), [U, K] = q(null);
120
120
  let x;
121
- t[7] !== y || t[8] !== p || t[9] !== i || t[10] !== f || t[11] !== C || t[12] !== c || t[13] !== v || t[14] !== a || t[15] !== I || t[16] !== m || t[17] !== s ? (x = async (P, q) => {
121
+ t[7] !== T || t[8] !== S || t[9] !== i || t[10] !== f || t[11] !== C || t[12] !== d || t[13] !== h || t[14] !== l || t[15] !== y || t[16] !== m || t[17] !== e ? (x = async (A, H) => {
122
122
  if (!C() || i === !1)
123
123
  return;
124
- !a && I(`loadData-${s}-${q}`), c && K(null);
125
- const G = y.get(s, {
126
- signal: P
127
- }).then((H) => p ? p(H.data) : H.data).finally(() => !a && m(`loadData-${s}-${q}`));
128
- K(j(G, v ?? !1, f ?? !1));
129
- }, t[7] = y, t[8] = p, t[9] = i, t[10] = f, t[11] = C, t[12] = c, t[13] = v, t[14] = a, t[15] = I, t[16] = m, t[17] = s, t[18] = x) : x = t[18];
130
- const b = x;
131
- let B, L;
132
- t[19] !== b || t[20] !== w ? (L = () => {
133
- if (w === !1)
124
+ !l && y(`loadData-${e}-${H}`), d && K(null);
125
+ const M = T.get(e, {
126
+ signal: A
127
+ }).then((_) => S ? S(_.data) : _.data).finally(() => !l && m(`loadData-${e}-${H}`));
128
+ K(Y(M, h ?? !1, f ?? !1));
129
+ }, t[7] = T, t[8] = S, t[9] = i, t[10] = f, t[11] = C, t[12] = d, t[13] = h, t[14] = l, t[15] = y, t[16] = m, t[17] = e, t[18] = x) : x = t[18];
130
+ const O = x;
131
+ let L, $;
132
+ t[19] !== O || t[20] !== p ? ($ = () => {
133
+ if (p === !1)
134
134
  return;
135
- const P = new AbortController();
136
- return b(P.signal, O.current = O.current + 1), () => {
137
- P.abort();
135
+ const A = new AbortController();
136
+ return O(A.signal, I.current = I.current + 1), () => {
137
+ A.abort();
138
138
  };
139
- }, B = [b, w], t[19] = b, t[20] = w, t[21] = B, t[22] = L) : (B = t[21], L = t[22]), F(L, B);
140
- let $;
141
- return t[23] !== N || t[24] !== b ? ($ = {
142
- data: N,
139
+ }, L = [O, p], t[19] = O, t[20] = p, t[21] = L, t[22] = $) : (L = t[21], $ = t[22]), N($, L);
140
+ let P;
141
+ return t[23] !== U || t[24] !== O ? (P = {
142
+ data: U,
143
143
  setData: K,
144
- reloadData: b
145
- }, t[23] = N, t[24] = b, t[25] = $) : $ = t[25], $;
146
- }, rt = () => {
147
- const s = D({}).current;
148
- return F(() => {
144
+ reloadData: O
145
+ }, t[23] = U, t[24] = O, t[25] = P) : P = t[25], P;
146
+ }, b = /* @__PURE__ */ new Map();
147
+ function ut(e, n) {
148
+ const t = V({
149
+ silent: !0,
150
+ differentBaseUrl: n == null ? void 0 : n.customBaseUrl,
151
+ customToken: n == null ? void 0 : n.customToken
152
+ }), s = B(null), r = J(() => t.get(e).then((o) => (b.set(e, {
153
+ status: "success",
154
+ data: o.data
155
+ }), s.current = window.setTimeout(() => {
156
+ b.delete(e), s.current = null;
157
+ }, 1e3 * 10), o.data)).catch((o) => {
158
+ throw b.set(e, {
159
+ status: "error",
160
+ error: o
161
+ }), s.current = window.setTimeout(() => {
162
+ b.delete(e), s.current = null;
163
+ }, 1e3 * 1), o;
164
+ }), [t, e]);
165
+ if (!b.has(e)) {
166
+ const o = r();
167
+ throw b.set(e, {
168
+ status: "pending",
169
+ promise: o
170
+ }), o;
171
+ }
172
+ const u = b.get(e);
173
+ if (u.status === "pending")
174
+ throw u.promise;
175
+ if (u.status === "error")
176
+ throw u.error;
177
+ const a = J(() => {
178
+ j(() => {
179
+ b.delete(e), s.current !== null && (window.clearTimeout(s.current), s.current = null), r();
180
+ });
181
+ }, [r, e]);
182
+ return {
183
+ data: u.data,
184
+ reloadData: a
185
+ };
186
+ }
187
+ const lt = () => {
188
+ const e = B({}).current;
189
+ return N(() => {
149
190
  const n = document.createElement("div");
150
- return n.style.position = "absolute", n.style.pointerEvents = "none", n.style.top = "0", n.style.width = "100%", n.style.height = "100%", s.elt = n, document.body.appendChild(n), () => {
191
+ return n.style.position = "absolute", n.style.pointerEvents = "none", n.style.top = "0", n.style.width = "100%", n.style.height = "100%", e.elt = n, document.body.appendChild(n), () => {
151
192
  document.body.removeChild(n);
152
193
  };
153
- }, [s]), (n) => (t, ...e) => {
154
- const o = n(t, ...e);
155
- return t.draggableProps.style.position === "fixed" ? M(o, s.elt) : o;
194
+ }, [e]), (n) => (t, ...s) => {
195
+ const r = n(t, ...s);
196
+ return t.draggableProps.style.position === "fixed" ? R(r, e.elt) : r;
156
197
  };
157
- }, A = {
198
+ }, F = {
158
199
  storageKey: "--tmp-scroll-save--",
159
200
  requiredHeight: 100,
160
201
  retryInterval: 50
161
- }, ot = (s, n) => {
162
- const t = V.c(18), {
163
- storageKey: e,
164
- requiredHeight: o,
165
- retryInterval: d
166
- } = n === void 0 ? A : n, r = e === void 0 ? A.storageKey : e, l = o === void 0 ? A.requiredHeight : o, S = d === void 0 ? A.retryInterval : d, [g, p] = U(!1), f = D(null);
167
- let w;
168
- t[0] !== r ? (w = () => {
169
- const m = localStorage.getItem(r);
170
- return localStorage.removeItem(r), m === null ? null : Number(m);
171
- }, t[0] = r, t[1] = w) : w = t[1];
172
- const i = w;
173
- let a;
174
- t[2] !== r ? (a = (m) => {
175
- localStorage.setItem(r, m);
176
- }, t[2] = r, t[3] = a) : a = t[3];
177
- const c = a;
178
- let v, h;
179
- t[4] !== g || t[5] !== l || t[6] !== i || t[7] !== S || t[8] !== s ? (v = () => {
202
+ }, ct = (e, n) => {
203
+ const t = G.c(18), {
204
+ storageKey: s,
205
+ requiredHeight: r,
206
+ retryInterval: u
207
+ } = n === void 0 ? F : n, a = s === void 0 ? F.storageKey : s, o = r === void 0 ? F.requiredHeight : r, v = u === void 0 ? F.retryInterval : u, [g, S] = q(!1), f = B(null);
208
+ let p;
209
+ t[0] !== a ? (p = () => {
210
+ const m = localStorage.getItem(a);
211
+ return localStorage.removeItem(a), m === null ? null : Number(m);
212
+ }, t[0] = a, t[1] = p) : p = t[1];
213
+ const i = p;
214
+ let l;
215
+ t[2] !== a ? (l = (m) => {
216
+ localStorage.setItem(a, m);
217
+ }, t[2] = a, t[3] = l) : l = t[3];
218
+ const d = l;
219
+ let h, w;
220
+ t[4] !== g || t[5] !== o || t[6] !== i || t[7] !== v || t[8] !== e ? (h = () => {
180
221
  const m = window.setInterval(() => {
181
- if (!g && s.current !== null && s.current.getBoundingClientRect().height > l) {
182
- p(!0);
183
- const O = i();
184
- O !== null && s.current.scrollTo({
185
- top: O
222
+ if (!g && e.current !== null && e.current.getBoundingClientRect().height > o) {
223
+ S(!0);
224
+ const I = i();
225
+ I !== null && e.current.scrollTo({
226
+ top: I
186
227
  }), window.clearInterval(m);
187
228
  }
188
- }, S);
229
+ }, v);
189
230
  return () => {
190
231
  window.clearTimeout(m);
191
232
  };
192
- }, h = [g, l, i, S, s], t[4] = g, t[5] = l, t[6] = i, t[7] = S, t[8] = s, t[9] = v, t[10] = h) : (v = t[9], h = t[10]), F(v, h);
193
- let u, y;
194
- t[11] !== c || t[12] !== s ? (u = () => {
195
- var O;
233
+ }, w = [g, o, i, v, e], t[4] = g, t[5] = o, t[6] = i, t[7] = v, t[8] = e, t[9] = h, t[10] = w) : (h = t[9], w = t[10]), N(h, w);
234
+ let c, T;
235
+ t[11] !== d || t[12] !== e ? (c = () => {
236
+ var I;
196
237
  const m = new AbortController();
197
- return (O = s.current) == null || O.addEventListener("scrollend", () => {
238
+ return (I = e.current) == null || I.addEventListener("scrollend", () => {
198
239
  var C;
199
- f.current = ((C = s.current) == null ? void 0 : C.scrollTop) ?? 0, c((f.current ?? 0).toString());
240
+ f.current = ((C = e.current) == null ? void 0 : C.scrollTop) ?? 0, d((f.current ?? 0).toString());
200
241
  }, {
201
242
  signal: m.signal
202
243
  }), () => m.abort();
203
- }, y = [c, s], t[11] = c, t[12] = s, t[13] = u, t[14] = y) : (u = t[13], y = t[14]), F(u, y);
204
- let I;
205
- return t[15] !== i || t[16] !== c ? (I = {
206
- saveValue: c,
244
+ }, T = [d, e], t[11] = d, t[12] = e, t[13] = c, t[14] = T) : (c = t[13], T = t[14]), N(c, T);
245
+ let y;
246
+ return t[15] !== i || t[16] !== d ? (y = {
247
+ saveValue: d,
207
248
  retrieveValue: i
208
- }, t[15] = i, t[16] = c, t[17] = I) : I = t[17], I;
249
+ }, t[15] = i, t[16] = d, t[17] = y) : y = t[17], y;
209
250
  };
210
251
  export {
211
- ut as cancelToken,
212
- Q as useAuth,
213
- _ as useAxios,
214
- Tt as useClickOutside,
215
- ht as useClipboard,
216
- it as useConfirm,
217
- St as useEmployeePhotoPath,
218
- pt as useFormControlType,
219
- ct as useGetApiData,
220
- nt as useGetApiDataBound,
221
- et as useGetDataBound,
222
- xt as useIsBrowserOnline,
223
- wt as useIsFormDirty,
224
- dt as useKeyPress,
225
- ft as useLocalStorageState,
226
- mt as useNotifications,
227
- Ct as usePermissions,
228
- st as usePersistentState,
229
- gt as usePrompt,
230
- rt as useRenderDraggableInPortal,
231
- ot as useScrollSave,
232
- yt as useSearchQuery,
233
- It as useSearchQueryState,
234
- Et as useWindowSize,
235
- Ot as useZodSchemaTypes
252
+ ft as cancelToken,
253
+ W as useAuth,
254
+ V as useAxios,
255
+ Et as useClickOutside,
256
+ Tt as useClipboard,
257
+ mt as useConfirm,
258
+ yt as useEmployeePhotoPath,
259
+ It as useFormControlType,
260
+ gt as useGetApiData,
261
+ ot as useGetApiDataBound,
262
+ rt as useGetDataBound,
263
+ ut as useGetDataBoundExtended,
264
+ Pt as useIsBrowserOnline,
265
+ bt as useIsFormDirty,
266
+ ht as useKeyPress,
267
+ wt as useLocalStorageState,
268
+ vt as useNotifications,
269
+ xt as usePermissions,
270
+ at as usePersistentState,
271
+ St as usePrompt,
272
+ lt as useRenderDraggableInPortal,
273
+ ct as useScrollSave,
274
+ Ot as useSearchQuery,
275
+ Dt as useSearchQueryState,
276
+ Lt as useWindowSize,
277
+ Bt as useZodSchemaTypes
236
278
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-luminus-components",
3
- "version": "2.1.10",
3
+ "version": "2.1.11",
4
4
  "description": "Library of React Components reusable in Luminus projects (Fleetman, CAFM)",
5
5
  "type": "module",
6
6
  "repository": {