react-luminus-components 1.3.252 → 1.3.254

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 i=require("./nivo-bar.es-zNqQYP51.cjs"),e=require("react");require("react-router-dom");require("react-dom");require("react-hook-form");require("react-flexmonster");require("@azure/msal-browser");require("@azure/msal-react");const a={loadOnInit:!0,silent:!1,enabled:!0,nullStateBeforeLoad:!0,nullStateOnFail:!1},B=(n,{loadOnInit:c=a.loadOnInit,enabled:d=a.enabled,silent:o=a.silent,nullStateBeforeLoad:f=a.nullStateBeforeLoad,nullStateOnFail:g=a.nullStateOnFail,customApiUrl:h,customBearerToken:k,dataTransformer:l}=a)=>{const L=i.useAxios({silent:o,customToken:k,differentBaseUrl:h}),[S,C]=e.useState(!1),{startLoading:q,stopLoading:D}=e.useContext(i.LoadingContext),$=e.useRef(0),{isAuthenticated:b}=i.useAuth(),p=e.useCallback(t=>{q(t),C(()=>!0)},[q]),x=e.useCallback(t=>{D(t),C(()=>!1)},[D]),[w,s]=e.useState(null),u=e.useCallback(async(t,A)=>{if(b()&&d!==!1){!o&&p(`loadData-${n}-${A}`),f&&s(null);try{const r=await L.get(n,{signal:t}),y=l?l(r.data):r.data;s(y)}catch(r){throw g&&s(null),r}finally{!o&&x(`loadData-${n}-${A}`)}}},[b,d,o,p,n,f,L,l,g,x]);return e.useEffect(()=>{if(c===!1)return;const t=new AbortController;return u(t.signal,++$.current),()=>{t.abort()}},[u,c]),{data:w,setData:s,reloadData:u,isLoading:S}};exports.useGetApiData=B;
@@ -0,0 +1,57 @@
1
+ import { aj as k, al as B, b2 as I } from "./nivo-bar.es-DOi9xK6m.js";
2
+ import { useState as A, useContext as R, useRef as j, useCallback as i, useEffect as v } from "react";
3
+ import "react-router-dom";
4
+ import "react-dom";
5
+ import "react-hook-form";
6
+ import "react-flexmonster";
7
+ import "@azure/msal-browser";
8
+ import "@azure/msal-react";
9
+ const a = {
10
+ loadOnInit: !0,
11
+ silent: !1,
12
+ enabled: !0,
13
+ nullStateBeforeLoad: !0,
14
+ nullStateOnFail: !1
15
+ }, K = (o, { loadOnInit: u = a.loadOnInit, enabled: c = a.enabled, silent: e = a.silent, nullStateBeforeLoad: d = a.nullStateBeforeLoad, nullStateOnFail: f = a.nullStateOnFail, customApiUrl: h, customBearerToken: $, dataTransformer: r } = a) => {
16
+ const p = k({ silent: e, customToken: $, differentBaseUrl: h }), [w, g] = A(!1), { startLoading: m, stopLoading: L } = R(B), y = j(0), { isAuthenticated: x } = I(), C = i((t) => {
17
+ m(t), g(() => !0);
18
+ }, [m]), D = i((t) => {
19
+ L(t), g(() => !1);
20
+ }, [L]), [O, n] = A(null), l = i(async (t, b) => {
21
+ if (x() && c !== !1) {
22
+ !e && C(`loadData-${o}-${b}`), d && n(null);
23
+ try {
24
+ const s = await p.get(o, {
25
+ signal: t
26
+ }), S = r ? r(s.data) : s.data;
27
+ n(S);
28
+ } catch (s) {
29
+ throw f && n(null), s;
30
+ } finally {
31
+ !e && D(`loadData-${o}-${b}`);
32
+ }
33
+ }
34
+ }, [
35
+ x,
36
+ c,
37
+ e,
38
+ C,
39
+ o,
40
+ d,
41
+ p,
42
+ r,
43
+ f,
44
+ D
45
+ ]);
46
+ return v(() => {
47
+ if (u === !1)
48
+ return;
49
+ const t = new AbortController();
50
+ return l(t.signal, ++y.current), () => {
51
+ t.abort();
52
+ };
53
+ }, [l, u]), { data: O, setData: n, reloadData: l, isLoading: w };
54
+ };
55
+ export {
56
+ K as u
57
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-luminus-components",
3
- "version": "1.3.252",
3
+ "version": "1.3.254",
4
4
  "description": "Library of React Components reusable in Luminus projects (Fleetman, CAFM)",
5
5
  "type": "module",
6
6
  "repository": {
@@ -1,3 +0,0 @@
1
- import { Datum } from '@nivo/line';
2
-
3
- export declare const sortData: (data: readonly Datum[], disabled: boolean) => readonly Datum[];
@@ -1,53 +0,0 @@
1
- import { aj as L, al as $, b2 as w } from "./nivo-bar.es-DOi9xK6m.js";
2
- import { useContext as y, useRef as O, useState as S, useCallback as k, useEffect as B } from "react";
3
- import "react-router-dom";
4
- import "react-dom";
5
- import "react-hook-form";
6
- import "react-flexmonster";
7
- import "@azure/msal-browser";
8
- import "@azure/msal-react";
9
- const t = {
10
- loadOnInit: !0,
11
- silent: !1,
12
- enabled: !0,
13
- nullStateBeforeLoad: !0,
14
- nullStateOnFail: !1
15
- }, q = (a, { loadOnInit: i = t.loadOnInit, enabled: u = t.enabled, silent: o = t.silent, nullStateBeforeLoad: c = t.nullStateBeforeLoad, nullStateOnFail: f = t.nullStateOnFail, customApiUrl: g, customBearerToken: x, dataTransformer: r } = t) => {
16
- const d = L({ silent: o, customToken: x, differentBaseUrl: g }), { startLoading: p, stopLoading: m } = y($), A = O(0), { isAuthenticated: D } = w(), [C, e] = S(null), l = k(async (n, b) => {
17
- if (D() && u !== !1) {
18
- !o && p(`loadData-${a}-${b}`), c && e(null);
19
- try {
20
- const s = await d.get(a, {
21
- signal: n
22
- }), h = r ? r(s.data) : s.data;
23
- e(h);
24
- } catch (s) {
25
- throw f && e(null), s;
26
- } finally {
27
- !o && m(`loadData-${a}-${b}`);
28
- }
29
- }
30
- }, [
31
- D,
32
- u,
33
- o,
34
- p,
35
- a,
36
- c,
37
- d,
38
- r,
39
- f,
40
- m
41
- ]);
42
- return B(() => {
43
- if (i === !1)
44
- return;
45
- const n = new AbortController();
46
- return l(n.signal, ++A.current), () => {
47
- n.abort();
48
- };
49
- }, [l, i]), { data: C, setData: e, reloadData: l };
50
- };
51
- export {
52
- q as u
53
- };
@@ -1 +0,0 @@
1
- "use strict";const i=require("./nivo-bar.es-zNqQYP51.cjs"),e=require("react");require("react-router-dom");require("react-dom");require("react-hook-form");require("react-flexmonster");require("@azure/msal-browser");require("@azure/msal-react");const t={loadOnInit:!0,silent:!1,enabled:!0,nullStateBeforeLoad:!0,nullStateOnFail:!1},w=(a,{loadOnInit:c=t.loadOnInit,enabled:f=t.enabled,silent:n=t.silent,nullStateBeforeLoad:d=t.nullStateBeforeLoad,nullStateOnFail:q=t.nullStateOnFail,customApiUrl:h,customBearerToken:p,dataTransformer:u}=t)=>{const D=i.useAxios({silent:n,customToken:p,differentBaseUrl:h}),{startLoading:A,stopLoading:b}=e.useContext(i.LoadingContext),x=e.useRef(0),{isAuthenticated:g}=i.useAuth(),[L,r]=e.useState(null),l=e.useCallback(async(o,C)=>{if(g()&&f!==!1){!n&&A(`loadData-${a}-${C}`),d&&r(null);try{const s=await D.get(a,{signal:o}),$=u?u(s.data):s.data;r($)}catch(s){throw q&&r(null),s}finally{!n&&b(`loadData-${a}-${C}`)}}},[g,f,n,A,a,d,D,u,q,b]);return e.useEffect(()=>{if(c===!1)return;const o=new AbortController;return l(o.signal,++x.current),()=>{o.abort()}},[l,c]),{data:L,setData:r,reloadData:l}};exports.useGetApiData=w;