react-luminus-components 2.0.5-beta.r19-8 → 2.0.5-beta.r19-10

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.
@@ -0,0 +1 @@
1
+ "use strict";const q=require("./nivo-bar-D9jkkQXQ.cjs");require("react/jsx-runtime");const a=require("react");require("react-router");require("react-dom");require("react-hook-form");require("react-flexmonster");require("@azure/msal-browser");require("@azure/msal-react");const S={loadOnInit:!0,silent:!1,enabled:!0,nullStateBeforeLoad:!0,nullStateOnFail:!1},w=(e,{loadOnInit:u=S.loadOnInit,enabled:t=S.enabled,silent:o=S.silent,nullStateBeforeLoad:c=S.nullStateBeforeLoad,nullStateOnFail:s=S.nullStateOnFail,customApiUrl:C,customBearerToken:f,dataTransformer:r}=S)=>{const n=q.useAxios({silent:o,customToken:f,differentBaseUrl:C}),[p,i]=a.useState(0),{startLoading:d,stopLoading:b}=a.useContext(q.LoadingContext),m=a.useRef(0),{isAuthenticated:x}=q.useAuth(),[v,D]=a.useState(null),A=a.useRef(u??!1),g=a.useCallback(async(L,h)=>{if(!x()||t===!1)return null;i(l=>l+1),!o&&d(`loadData-${e}-${h}`),c&&D(null);let R;try{const l=await n.get(e,{signal:L}),$=r?r(l.data):l.data;D($),R=$}catch(l){throw s&&D(null),l}finally{A.current=!1,i(l=>l-1),!o&&b(`loadData-${e}-${h}`)}return R},[x,t,o,d,e,c,n,r,s,b]),I=a.useCallback(async()=>{g()},[g]),O=a.useCallback(async()=>g(),[g]);return a.useEffect(()=>{if(u===!1)return;if(n.interceptorsUsed===!1){console.error("useGetApiData: could not load data because interceptors are not used");return}const L=new AbortController;return g(L.signal,++m.current),()=>{L.abort()}},[g,u,n.interceptorsUsed]),{data:v,setData:D,reloadData:I,isLoading:A.current||p>0,reloadDataWithReturn:O}},B=(e,u)=>{const t=q.compilerRuntimeExports.c(12);let o;t[0]!==u||t[1]!==e?(o=()=>{const d=localStorage.getItem(e);return d!=null&&d!=="undefined"?JSON.parse(d):u},t[0]=u,t[1]=e,t[2]=o):o=t[2];const c=o,[s,C]=a.useState(c);let f,r;t[3]!==e||t[4]!==s?(f=()=>{localStorage.setItem(e,JSON.stringify(s))},r=[e,s],t[3]=e,t[4]=s,t[5]=f,t[6]=r):(f=t[5],r=t[6]),a.useEffect(f,r);let n;t[7]!==c?(n=()=>{C(c)},t[7]=c,t[8]=n):n=t[8];const p=n;let i;return t[9]!==p||t[10]!==s?(i=[s,C,p],t[9]=p,t[10]=s,t[11]=i):i=t[11],i};exports.useGetApiData=w;exports.useLocalStorageState=B;
@@ -0,0 +1,95 @@
1
+ import { ao as E, aq as F, bd as G, c as J } from "./nivo-bar-CyXsS9At.js";
2
+ import "react/jsx-runtime";
3
+ import { useState as C, useContext as N, useRef as O, useCallback as L, useEffect as R } from "react";
4
+ import "react-router";
5
+ import "react-dom";
6
+ import "react-hook-form";
7
+ import "react-flexmonster";
8
+ import "@azure/msal-browser";
9
+ import "@azure/msal-react";
10
+ const p = {
11
+ loadOnInit: !0,
12
+ silent: !1,
13
+ enabled: !0,
14
+ nullStateBeforeLoad: !0,
15
+ nullStateOnFail: !1
16
+ }, Q = (e, {
17
+ loadOnInit: l = p.loadOnInit,
18
+ enabled: t = p.enabled,
19
+ silent: a = p.silent,
20
+ nullStateBeforeLoad: i = p.nullStateBeforeLoad,
21
+ nullStateOnFail: o = p.nullStateOnFail,
22
+ customApiUrl: m,
23
+ customBearerToken: d,
24
+ dataTransformer: s
25
+ } = p) => {
26
+ const n = E({
27
+ silent: a,
28
+ customToken: d,
29
+ differentBaseUrl: m
30
+ }), [g, c] = C(0), {
31
+ startLoading: u,
32
+ stopLoading: x
33
+ } = N(F), v = O(0), {
34
+ isAuthenticated: b
35
+ } = G(), [w, S] = C(null), h = O(l ?? !1), f = L(async (D, A) => {
36
+ if (!b() || t === !1)
37
+ return null;
38
+ c((r) => r + 1), !a && u(`loadData-${e}-${A}`), i && S(null);
39
+ let $;
40
+ try {
41
+ const r = await n.get(e, {
42
+ signal: D
43
+ }), I = s ? s(r.data) : r.data;
44
+ S(I), $ = I;
45
+ } catch (r) {
46
+ throw o && S(null), r;
47
+ } finally {
48
+ h.current = !1, c((r) => r - 1), !a && x(`loadData-${e}-${A}`);
49
+ }
50
+ return $;
51
+ }, [b, t, a, u, e, i, n, s, o, x]), U = L(async () => {
52
+ f();
53
+ }, [f]), B = L(async () => f(), [f]);
54
+ return R(() => {
55
+ if (l === !1)
56
+ return;
57
+ if (n.interceptorsUsed === !1) {
58
+ console.error("useGetApiData: could not load data because interceptors are not used");
59
+ return;
60
+ }
61
+ const D = new AbortController();
62
+ return f(D.signal, ++v.current), () => {
63
+ D.abort();
64
+ };
65
+ }, [f, l, n.interceptorsUsed]), {
66
+ data: w,
67
+ setData: S,
68
+ reloadData: U,
69
+ isLoading: h.current || g > 0,
70
+ reloadDataWithReturn: B
71
+ };
72
+ }, X = (e, l) => {
73
+ const t = J.c(12);
74
+ let a;
75
+ t[0] !== l || t[1] !== e ? (a = () => {
76
+ const u = localStorage.getItem(e);
77
+ return u != null && u !== "undefined" ? JSON.parse(u) : l;
78
+ }, t[0] = l, t[1] = e, t[2] = a) : a = t[2];
79
+ const i = a, [o, m] = C(i);
80
+ let d, s;
81
+ t[3] !== e || t[4] !== o ? (d = () => {
82
+ localStorage.setItem(e, JSON.stringify(o));
83
+ }, s = [e, o], t[3] = e, t[4] = o, t[5] = d, t[6] = s) : (d = t[5], s = t[6]), R(d, s);
84
+ let n;
85
+ t[7] !== i ? (n = () => {
86
+ m(i);
87
+ }, t[7] = i, t[8] = n) : n = t[8];
88
+ const g = n;
89
+ let c;
90
+ return t[9] !== g || t[10] !== o ? (c = [o, m, g], t[9] = g, t[10] = o, t[11] = c) : c = t[11], c;
91
+ };
92
+ export {
93
+ X as a,
94
+ Q as u
95
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-luminus-components",
3
- "version": "2.0.5-beta.r19-8",
3
+ "version": "2.0.5-beta.r19-10",
4
4
  "description": "Library of React Components reusable in Luminus projects (Fleetman, CAFM)",
5
5
  "type": "module",
6
6
  "repository": {
@@ -1 +0,0 @@
1
- "use strict";const b=require("./nivo-bar-D9jkkQXQ.cjs");require("react/jsx-runtime");const a=require("react");require("react-router");require("react-dom");require("react-hook-form");require("react-flexmonster");require("@azure/msal-browser");require("@azure/msal-react");const d={loadOnInit:!0,silent:!1,enabled:!0,nullStateBeforeLoad:!0,nullStateOnFail:!1},B=(e,{loadOnInit:f=d.loadOnInit,enabled:t=d.enabled,silent:s=d.silent,nullStateBeforeLoad:u=d.nullStateBeforeLoad,nullStateOnFail:o=d.nullStateOnFail,customApiUrl:L,customBearerToken:g,dataTransformer:r}=d)=>{const n=b.useAxios({silent:s,customToken:g,differentBaseUrl:L}),[p,c]=a.useState(d.loadOnInit??!1),{startLoading:i,stopLoading:q}=a.useContext(b.LoadingContext),w=a.useRef(0),{isAuthenticated:x}=b.useAuth(),A=a.useCallback(l=>{i(l),c(()=>!0)},[i]),I=a.useCallback(l=>{q(l),c(()=>!1)},[q]),[R,C]=a.useState(null),S=a.useCallback(async(l,O)=>{if(!x()||t===!1)return null;!s&&A(`loadData-${e}-${O}`),u&&C(null);let h;try{const D=await n.get(e,{signal:l}),m=r?r(D.data):D.data;C(m),h=m}catch(D){throw o&&C(null),D}finally{!s&&I(`loadData-${e}-${O}`)}return h},[x,t,s,A,e,u,n,r,o,I]),$=a.useCallback(async()=>{S()},[S]),v=a.useCallback(async()=>S(),[S]);return a.useEffect(()=>{if(f===!1)return;if(n.interceptorsUsed===!1){console.error("useGetApiData: could not load data because interceptors are not used"),setTimeout(()=>{window.location.reload()},1e3*10);return}const l=new AbortController;return S(l.signal,++w.current),()=>{l.abort()}},[S,f,n.interceptorsUsed]),{data:R,setData:C,reloadData:$,isLoading:p,reloadDataWithReturn:v}},E=(e,f)=>{const t=b.compilerRuntimeExports.c(12);let s;t[0]!==f||t[1]!==e?(s=()=>{const i=localStorage.getItem(e);return i!=null&&i!=="undefined"?JSON.parse(i):f},t[0]=f,t[1]=e,t[2]=s):s=t[2];const u=s,[o,L]=a.useState(u);let g,r;t[3]!==e||t[4]!==o?(g=()=>{localStorage.setItem(e,JSON.stringify(o))},r=[e,o],t[3]=e,t[4]=o,t[5]=g,t[6]=r):(g=t[5],r=t[6]),a.useEffect(g,r);let n;t[7]!==u?(n=()=>{L(u)},t[7]=u,t[8]=n):n=t[8];const p=n;let c;return t[9]!==p||t[10]!==o?(c=[o,L,p],t[9]=p,t[10]=o,t[11]=c):c=t[11],c};exports.useGetApiData=B;exports.useLocalStorageState=E;
@@ -1,101 +0,0 @@
1
- import { ao as E, aq as G, bd as J, c as N } from "./nivo-bar-CyXsS9At.js";
2
- import "react/jsx-runtime";
3
- import { useState as x, useContext as q, useRef as F, useCallback as m, useEffect as $ } from "react";
4
- import "react-router";
5
- import "react-dom";
6
- import "react-hook-form";
7
- import "react-flexmonster";
8
- import "@azure/msal-browser";
9
- import "@azure/msal-react";
10
- const d = {
11
- loadOnInit: !0,
12
- silent: !1,
13
- enabled: !0,
14
- nullStateBeforeLoad: !0,
15
- nullStateOnFail: !1
16
- }, T = (e, {
17
- loadOnInit: u = d.loadOnInit,
18
- enabled: t = d.enabled,
19
- silent: a = d.silent,
20
- nullStateBeforeLoad: l = d.nullStateBeforeLoad,
21
- nullStateOnFail: o = d.nullStateOnFail,
22
- customApiUrl: S,
23
- customBearerToken: f,
24
- dataTransformer: n
25
- } = d) => {
26
- const s = E({
27
- silent: a,
28
- customToken: f,
29
- differentBaseUrl: S
30
- }), [g, i] = x(d.loadOnInit ?? !1), {
31
- startLoading: c,
32
- stopLoading: b
33
- } = q(G), R = F(0), {
34
- isAuthenticated: C
35
- } = J(), I = m((r) => {
36
- c(r), i(() => !0);
37
- }, [c]), A = m((r) => {
38
- b(r), i(() => !1);
39
- }, [b]), [v, L] = x(null), p = m(async (r, O) => {
40
- if (!C() || t === !1)
41
- return null;
42
- !a && I(`loadData-${e}-${O}`), l && L(null);
43
- let h;
44
- try {
45
- const D = await s.get(e, {
46
- signal: r
47
- }), w = n ? n(D.data) : D.data;
48
- L(w), h = w;
49
- } catch (D) {
50
- throw o && L(null), D;
51
- } finally {
52
- !a && A(`loadData-${e}-${O}`);
53
- }
54
- return h;
55
- }, [C, t, a, I, e, l, s, n, o, A]), U = m(async () => {
56
- p();
57
- }, [p]), B = m(async () => p(), [p]);
58
- return $(() => {
59
- if (u === !1)
60
- return;
61
- if (s.interceptorsUsed === !1) {
62
- console.error("useGetApiData: could not load data because interceptors are not used"), setTimeout(() => {
63
- window.location.reload();
64
- }, 1e3 * 10);
65
- return;
66
- }
67
- const r = new AbortController();
68
- return p(r.signal, ++R.current), () => {
69
- r.abort();
70
- };
71
- }, [p, u, s.interceptorsUsed]), {
72
- data: v,
73
- setData: L,
74
- reloadData: U,
75
- isLoading: g,
76
- reloadDataWithReturn: B
77
- };
78
- }, X = (e, u) => {
79
- const t = N.c(12);
80
- let a;
81
- t[0] !== u || t[1] !== e ? (a = () => {
82
- const c = localStorage.getItem(e);
83
- return c != null && c !== "undefined" ? JSON.parse(c) : u;
84
- }, t[0] = u, t[1] = e, t[2] = a) : a = t[2];
85
- const l = a, [o, S] = x(l);
86
- let f, n;
87
- t[3] !== e || t[4] !== o ? (f = () => {
88
- localStorage.setItem(e, JSON.stringify(o));
89
- }, n = [e, o], t[3] = e, t[4] = o, t[5] = f, t[6] = n) : (f = t[5], n = t[6]), $(f, n);
90
- let s;
91
- t[7] !== l ? (s = () => {
92
- S(l);
93
- }, t[7] = l, t[8] = s) : s = t[8];
94
- const g = s;
95
- let i;
96
- return t[9] !== g || t[10] !== o ? (i = [o, S, g], t[9] = g, t[10] = o, t[11] = i) : i = t[11], i;
97
- };
98
- export {
99
- X as a,
100
- T as u
101
- };