react-luminus-components 1.3.7 → 1.3.8
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.
- package/dist/contexts.cjs.js +1 -1
- package/dist/contexts.es.js +73 -73
- package/package.json +1 -1
package/dist/contexts.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./NoInputContainer-BxMb-BuJ.cjs"),n=require("react");require("./latinize-DaqzUOla.cjs");require("react-hook-form");const T=require("./useConfirm-qcfEqXzH.cjs"),i=require("./PrimaryButton-Jg-rT_fb.cjs"),j=({children:t})=>{const[r,s]=n.useState(!1),[a,o]=n.useState(""),c=n.useCallback(d=>{s(!0),o(d)},[]),u=n.useCallback(()=>{s(!1)},[]),l=n.useMemo(()=>({show:r,text:a,showConfirm:c,hideConfirm:u}),[r,a,c,u]);return e.jsxRuntimeExports.jsxs(e.ConfirmContext.Provider,{value:l,children:[e.jsxRuntimeExports.jsx(M,{}),t]})},h=()=>{const{confirmTexts:t}=n.useContext(e.LuminusComponentsContext),{isShown:r,text:s,onFinish:a}=T.usePrompt(),{options:o}=n.useContext(e.PromptContext),[c,u]=n.useState(o.defaultValue??""),l=n.useCallback(()=>{a(null)},[a]),d=n.useCallback(m=>{m.preventDefault(),!(o.required&&!c)&&a(c)},[a,o.required,c]);n.useEffect(()=>{r===!0&&u(o.defaultValue??"")},[r,o.defaultValue]);const x=n.useMemo(()=>({value:c,onChange:m=>u(m.currentTarget.value),className:"w-100",autoFocus:!0,tabIndex:0}),[c]);return e.jsxRuntimeExports.jsxs(i.Modal,{show:r,size:"sm",centered:!0,onHide:l,children:[e.jsxRuntimeExports.jsx(i.Modal.Header,{className:"justify-content-center",children:e.jsxRuntimeExports.jsx(i.Modal.Title,{children:s})}),e.jsxRuntimeExports.jsxs("form",{onSubmit:d,children:[e.jsxRuntimeExports.jsxs(i.Modal.Body,{children:[o.input==="textarea"?e.jsxRuntimeExports.jsx("textarea",{...x,rows:5}):void 0,o.input==="input"?e.jsxRuntimeExports.jsx(i.FormControl,{...x,type:o.type}):void 0]}),e.jsxRuntimeExports.jsxs(i.Modal.Footer,{className:"w-100 d-flex gap-5",children:[e.jsxRuntimeExports.jsx(i.PrimaryButton,{variant:"outlined",color:"secondary",onClick:l,className:"flex-grow-1",children:t.cancel}),e.jsxRuntimeExports.jsx(i.PrimaryButton,{color:"primary",disabled:o.required&&!c,type:"submit",className:"flex-grow-1",children:t.confirm})]})]})]})},P=({children:t})=>{const[r,s]=n.useState(!1),[a,o]=n.useState(""),[c,u]=n.useState({input:"textarea",type:"text"}),l=n.useRef(()=>{}),d=n.useCallback(S=>{o(S),s(!0)},[]),x=n.useCallback(()=>{s(!1)},[]),m=n.useMemo(()=>({isShown:r,text:a,showPrompt:d,hidePrompt:x,resolveRef:l,options:c,setOptions:u}),[r,a,d,x,c]);return e.jsxRuntimeExports.jsxs(e.PromptContext.Provider,{value:m,children:[t,e.jsxRuntimeExports.jsx(h,{})]})},L=({cookieDomain:t,axiosOptions:r,LinkComponent:s,NavigateComponent:a,language:o,axiosTexts:c,confirmTexts:u,formValidationTexts:l,homeDashboardTexts:d,formSubmitTexts:x,appSearchTexts:m,customSelectTexts:S,errorBoundaryTexts:R,widgetTexts:p,children:f})=>{const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./NoInputContainer-BxMb-BuJ.cjs"),n=require("react");require("./latinize-DaqzUOla.cjs");require("react-hook-form");const T=require("./useConfirm-qcfEqXzH.cjs"),i=require("./PrimaryButton-Jg-rT_fb.cjs"),j=({children:t})=>{const[r,s]=n.useState(!1),[a,o]=n.useState(""),c=n.useCallback(d=>{s(!0),o(d)},[]),u=n.useCallback(()=>{s(!1)},[]),l=n.useMemo(()=>({show:r,text:a,showConfirm:c,hideConfirm:u}),[r,a,c,u]);return e.jsxRuntimeExports.jsxs(e.ConfirmContext.Provider,{value:l,children:[e.jsxRuntimeExports.jsx(M,{}),t]})},h=()=>{const{confirmTexts:t}=n.useContext(e.LuminusComponentsContext),{isShown:r,text:s,onFinish:a}=T.usePrompt(),{options:o}=n.useContext(e.PromptContext),[c,u]=n.useState(o.defaultValue??""),l=n.useCallback(()=>{a(null)},[a]),d=n.useCallback(m=>{m.preventDefault(),!(o.required&&!c)&&a(c)},[a,o.required,c]);n.useEffect(()=>{r===!0&&u(o.defaultValue??"")},[r,o.defaultValue]);const x=n.useMemo(()=>({value:c,onChange:m=>u(m.currentTarget.value),className:"w-100",autoFocus:!0,tabIndex:0}),[c]);return e.jsxRuntimeExports.jsxs(i.Modal,{show:r,size:"sm",centered:!0,onHide:l,children:[e.jsxRuntimeExports.jsx(i.Modal.Header,{className:"justify-content-center",children:e.jsxRuntimeExports.jsx(i.Modal.Title,{children:s})}),e.jsxRuntimeExports.jsxs("form",{onSubmit:d,children:[e.jsxRuntimeExports.jsxs(i.Modal.Body,{children:[o.input==="textarea"?e.jsxRuntimeExports.jsx("textarea",{...x,rows:5}):void 0,o.input==="input"?e.jsxRuntimeExports.jsx(i.FormControl,{...x,type:o.type}):void 0]}),e.jsxRuntimeExports.jsxs(i.Modal.Footer,{className:"w-100 d-flex gap-5",children:[e.jsxRuntimeExports.jsx(i.PrimaryButton,{variant:"outlined",color:"secondary",onClick:l,className:"flex-grow-1",children:t.cancel}),e.jsxRuntimeExports.jsx(i.PrimaryButton,{color:"primary",disabled:o.required&&!c,type:"submit",className:"flex-grow-1",children:t.confirm})]})]})]})},P=({children:t})=>{const[r,s]=n.useState(!1),[a,o]=n.useState(""),[c,u]=n.useState({input:"textarea",type:"text"}),l=n.useRef(()=>{}),d=n.useCallback(S=>{o(S),s(!0)},[]),x=n.useCallback(()=>{s(!1)},[]),m=n.useMemo(()=>({isShown:r,text:a,showPrompt:d,hidePrompt:x,resolveRef:l,options:c,setOptions:u}),[r,a,d,x,c]);return e.jsxRuntimeExports.jsxs(e.PromptContext.Provider,{value:m,children:[t,e.jsxRuntimeExports.jsx(h,{})]})},L=({cookieDomain:t,axiosOptions:r,LinkComponent:s,NavigateComponent:a,language:o,axiosTexts:c,confirmTexts:u,formValidationTexts:l,homeDashboardTexts:d,formSubmitTexts:x,appSearchTexts:m,customSelectTexts:S,errorBoundaryTexts:R,widgetTexts:p,children:f})=>{const I=n.useMemo(()=>({axiosOptions:r,cookieDomain:t,LinkComponent:s,NavigateComponent:a,language:o,axiosTexts:c,confirmTexts:u,formValidationTexts:l,homeDashboardTexts:d,formSubmitTexts:x,appSearchTexts:m,customSelectTexts:S,errorBoundaryTexts:R,widgetTexts:p}),[r,t,s,a,o,c,u,l,d,x,m,S,R,p]);return e.jsxRuntimeExports.jsx(e.LuminusComponentsContext.Provider,{value:I,children:e.jsxRuntimeExports.jsx(j,{children:e.jsxRuntimeExports.jsxs(P,{children:[e.jsxRuntimeExports.jsx(e.Ie,{}),f]})})})},N=({children:t})=>{const[r,s]=n.useState(!1),[a]=n.useState(new Set),o=n.useCallback(l=>{a.add(l),s(!0)},[a]),c=n.useCallback(l=>{a.delete(l),a.size===0&&s(!1)},[a]),u=n.useMemo(()=>({isLoading:r,startLoading:o,stopLoading:c}),[r,o,c]);return e.jsxRuntimeExports.jsxs(e.LoadingContext.Provider,{value:u,children:[r&&e.jsxRuntimeExports.jsx(i.Loading,{}),t]})};/*! @azure/msal-browser v3.14.0 2024-05-07 */class k{static getInteractionStatusFromEvent(r,s){switch(r.eventType){case i.EventType.LOGIN_START:return e.InteractionStatus.Login;case i.EventType.SSO_SILENT_START:return e.InteractionStatus.SsoSilent;case i.EventType.ACQUIRE_TOKEN_START:if(r.interactionType===e.InteractionType.Redirect||r.interactionType===e.InteractionType.Popup)return e.InteractionStatus.AcquireToken;break;case i.EventType.HANDLE_REDIRECT_START:return e.InteractionStatus.HandleRedirect;case i.EventType.LOGOUT_START:return e.InteractionStatus.Logout;case i.EventType.SSO_SILENT_SUCCESS:case i.EventType.SSO_SILENT_FAILURE:if(s&&s!==e.InteractionStatus.SsoSilent)break;return e.InteractionStatus.None;case i.EventType.LOGOUT_END:if(s&&s!==e.InteractionStatus.Logout)break;return e.InteractionStatus.None;case i.EventType.HANDLE_REDIRECT_END:if(s&&s!==e.InteractionStatus.HandleRedirect)break;return e.InteractionStatus.None;case i.EventType.LOGIN_SUCCESS:case i.EventType.LOGIN_FAILURE:case i.EventType.ACQUIRE_TOKEN_SUCCESS:case i.EventType.ACQUIRE_TOKEN_FAILURE:case i.EventType.RESTORE_FROM_BFCACHE:if(r.interactionType===e.InteractionType.Redirect||r.interactionType===e.InteractionType.Popup){if(s&&s!==e.InteractionStatus.Login&&s!==e.InteractionStatus.AcquireToken)break;return e.InteractionStatus.None}break}return null}}/*! @azure/msal-react v2.0.16 2024-05-07 */const b="@azure/msal-react",v="2.0.16";/*! @azure/msal-react v2.0.16 2024-05-07 */const g={UNBLOCK_INPROGRESS:"UNBLOCK_INPROGRESS",EVENT:"EVENT"},A=(t,r)=>{const{type:s,payload:a}=r;let o=t.inProgress;switch(s){case g.UNBLOCK_INPROGRESS:t.inProgress===e.InteractionStatus.Startup&&(o=e.InteractionStatus.None,a.logger.info("MsalProvider - handleRedirectPromise resolved, setting inProgress to 'none'"));break;case g.EVENT:const u=a.message,l=k.getInteractionStatusFromEvent(u,t.inProgress);l&&(a.logger.info(`MsalProvider - ${u.eventType} results in setting inProgress from ${t.inProgress} to ${l}`),o=l);break;default:throw new Error(`Unknown action type: ${s}`)}const c=a.instance.getAllAccounts();return o!==t.inProgress&&!e.accountArraysAreEqual(c,t.accounts)?{...t,inProgress:o,accounts:c}:o!==t.inProgress?{...t,inProgress:o}:e.accountArraysAreEqual(c,t.accounts)?t:{...t,accounts:c}};function O({instance:t,children:r}){n.useEffect(()=>{t.initializeWrapperLibrary(e.WrapperSKU.React,v)},[t]);const s=n.useMemo(()=>t.getLogger().clone(b,v),[t]),[a,o]=n.useReducer(A,void 0,()=>({inProgress:e.InteractionStatus.Startup,accounts:t.getAllAccounts()}));n.useEffect(()=>{const u=t.addEventCallback(l=>{o({payload:{instance:t,logger:s,message:l},type:g.EVENT})});return s.verbose(`MsalProvider - Registered event callback with id: ${u}`),t.initialize().then(()=>{t.handleRedirectPromise().catch(()=>{}).finally(()=>{o({payload:{instance:t,logger:s},type:g.UNBLOCK_INPROGRESS})})}).catch(()=>{}),()=>{u&&(s.verbose(`MsalProvider - Removing event callback ${u}`),t.removeEventCallback(u))}},[t,s]);const c={instance:t,inProgress:a.inProgress,accounts:a.accounts,logger:s};return n.createElement(e.MsalContext.Provider,{value:c},r)}const U=({children:t})=>{const r=e.useAxios(),{msalInstance:s}=n.useContext(e.AuthContext),{getToken:a}=e.useAuth(),[o,c]=n.useState(null),u=n.useCallback(async()=>{const E=await a();E&&c(E)},[a]);n.useEffect(()=>{u()},[u]);const d=n.useCallback(()=>{const E=localStorage.getItem("user")??null;return E?JSON.parse(E??""):null},[])(),[x,m]=n.useState({state:d?e.LoginState.LOGGED_IN:e.LoginState.LOGGING_IN,user:d}),S=n.useCallback(async E=>{let C=null;return await r.get("/user/detail",E?{headers:{Authorization:`Bearer ${E}`}}:void 0).then(y=>{C=y.data}).catch(()=>{C=null}),C},[r]),R=n.useCallback(()=>{localStorage.removeItem("user"),m({state:e.LoginState.LOGGED_OUT,user:null})},[]),p=n.useCallback(async E=>{m({state:e.LoginState.LOGGING_IN,user:null});const C=await S(E);return C?(m({state:e.LoginState.LOGGED_IN,user:C}),localStorage.setItem("user",JSON.stringify(C)),!0):(m({state:e.LoginState.LOGIN_FAILED,user:null}),!1)},[S]),f=n.useCallback(()=>{R()},[R]),I=n.useMemo(()=>({user:x.user,userLoginState:x,loginUser:p,logoutUser:f}),[x,p,f]);return n.useEffect(()=>{if(s){const E=s.addEventCallback(C=>{if(C.eventType===i.EventType.LOGIN_SUCCESS&&C.payload){const y=C.payload;c(y.accessToken)}});return()=>{E&&s.removeEventCallback(E)}}return()=>{}},[s,p,f]),n.useEffect(()=>{o&&p(o).catch(()=>f())},[o,p,f]),e.jsxRuntimeExports.jsx(e.UserContext.Provider,{value:I,children:t})},_=({...t})=>{const{cookieDomain:r}=n.useContext(e.LuminusComponentsContext),[,s]=e.useCookies(["Authorization"]),a=n.useMemo(()=>({useMsal:t.useMsal??!1,msalInstance:t.useMsal?t.msalInstance??null:null,msalScopes:t.useMsal?t.msalScopes??[]:[]}),[t]);return n.useEffect(()=>{if(t.useMsal){const o=t.msalInstance.addEventCallback(c=>{if(c.eventType===i.EventType.LOGIN_SUCCESS||c.eventType===i.EventType.ACQUIRE_TOKEN_SUCCESS&&c.payload){const u=c.payload,l=u.account;t.msalInstance.setActiveAccount(l);const d=u.accessToken,x=u.expiresOn;s("Authorization",d,{path:"/",secure:!0,sameSite:"none",domain:r,expires:x??void 0})}});return()=>{o&&t.msalInstance.removeEventCallback(o)}}return()=>{}},[t,s,r]),e.jsxRuntimeExports.jsx(e.AuthContext.Provider,{value:a,children:t.useMsal?e.jsxRuntimeExports.jsx(O,{instance:t.msalInstance,children:t.children}):t.children})},M=()=>{const{confirmTexts:t}=n.useContext(e.LuminusComponentsContext),{onConfirm:r,onCancel:s,text:a,show:o}=T.useConfirm();return e.jsxRuntimeExports.jsxs(i.Modal,{show:o,size:"sm",centered:!0,onHide:s,children:[e.jsxRuntimeExports.jsx(i.Modal.Header,{className:"justify-content-center",children:e.jsxRuntimeExports.jsx(i.Modal.Title,{children:a})}),e.jsxRuntimeExports.jsx(i.Modal.Body,{children:e.jsxRuntimeExports.jsxs("div",{className:"w-100 d-flex gap-5",children:[e.jsxRuntimeExports.jsx(i.PrimaryButton,{type:"button",variant:"outlined",color:"secondary",className:"w-100",onClick:s,children:t.no}),e.jsxRuntimeExports.jsx(i.PrimaryButton,{type:"button",color:"primary",onClick:r,className:"w-100 ml",children:t.yes})]})})]})};exports.AuthContext=e.AuthContext;exports.LoadingContext=e.LoadingContext;exports.LuminusComponentsContext=e.LuminusComponentsContext;exports.UserContext=e.UserContext;exports.AuthProvider=_;exports.LoadingProvider=N;exports.LuminusComponentsProvider=L;exports.UserProvider=U;
|
package/dist/contexts.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { j as a, am as G, Q as
|
|
2
|
-
import V, { useState as h, useCallback as f, useMemo as
|
|
1
|
+
import { j as a, am as G, Q as O, an as b, ao as M, ap as D, M as L, L as l, aq as F, ar as z, as as k, a4 as H, a8 as w, a9 as K, ab as y, aa as B, at as q } from "./NoInputContainer-Cl1VEez2.js";
|
|
2
|
+
import V, { useState as h, useCallback as f, useMemo as N, useContext as T, useEffect as v, useRef as $, useReducer as Q } from "react";
|
|
3
3
|
import "./latinize-BQrinury.js";
|
|
4
4
|
import "react-hook-form";
|
|
5
5
|
import { u as J, a as W } from "./useConfirm-BiFAJsnv.js";
|
|
@@ -9,23 +9,23 @@ const Z = ({ children: e }) => {
|
|
|
9
9
|
t(!0), s(d);
|
|
10
10
|
}, []), c = f(() => {
|
|
11
11
|
t(!1);
|
|
12
|
-
}, []), i =
|
|
12
|
+
}, []), i = N(() => ({ show: n, text: o, showConfirm: r, hideConfirm: c }), [n, o, r, c]);
|
|
13
13
|
return /* @__PURE__ */ a.jsxs(G.Provider, { value: i, children: [
|
|
14
14
|
/* @__PURE__ */ a.jsx(ae, {}),
|
|
15
15
|
e
|
|
16
16
|
] });
|
|
17
17
|
}, ee = () => {
|
|
18
|
-
const { confirmTexts: e } =
|
|
18
|
+
const { confirmTexts: e } = T(O), { isShown: n, text: t, onFinish: o } = J(), { options: s } = T(b), [r, c] = h(s.defaultValue ?? ""), i = f(() => {
|
|
19
19
|
o(null);
|
|
20
|
-
}, [o]), d = f((
|
|
21
|
-
|
|
20
|
+
}, [o]), d = f((g) => {
|
|
21
|
+
g.preventDefault(), !(s.required && !r) && o(r);
|
|
22
22
|
}, [o, s.required, r]);
|
|
23
23
|
v(() => {
|
|
24
24
|
n === !0 && c(s.defaultValue ?? "");
|
|
25
25
|
}, [n, s.defaultValue]);
|
|
26
|
-
const m =
|
|
26
|
+
const m = N(() => ({
|
|
27
27
|
value: r,
|
|
28
|
-
onChange: (
|
|
28
|
+
onChange: (g) => c(g.currentTarget.value),
|
|
29
29
|
className: "w-100",
|
|
30
30
|
autoFocus: !0,
|
|
31
31
|
tabIndex: 0
|
|
@@ -45,11 +45,11 @@ const Z = ({ children: e }) => {
|
|
|
45
45
|
] });
|
|
46
46
|
}, te = ({ children: e }) => {
|
|
47
47
|
const [n, t] = h(!1), [o, s] = h(""), [r, c] = h({ input: "textarea", type: "text" }), i = $(() => {
|
|
48
|
-
}), d = f((
|
|
49
|
-
s(
|
|
48
|
+
}), d = f((P) => {
|
|
49
|
+
s(P), t(!0);
|
|
50
50
|
}, []), m = f(() => {
|
|
51
51
|
t(!1);
|
|
52
|
-
}, []),
|
|
52
|
+
}, []), g = N(() => ({
|
|
53
53
|
isShown: n,
|
|
54
54
|
text: o,
|
|
55
55
|
showPrompt: d,
|
|
@@ -58,12 +58,12 @@ const Z = ({ children: e }) => {
|
|
|
58
58
|
options: r,
|
|
59
59
|
setOptions: c
|
|
60
60
|
}), [n, o, d, m, r]);
|
|
61
|
-
return /* @__PURE__ */ a.jsxs(b.Provider, { value:
|
|
61
|
+
return /* @__PURE__ */ a.jsxs(b.Provider, { value: g, children: [
|
|
62
62
|
e,
|
|
63
63
|
/* @__PURE__ */ a.jsx(ee, {})
|
|
64
64
|
] });
|
|
65
|
-
}, fe = ({ cookieDomain: e, axiosOptions: n, LinkComponent: t, NavigateComponent: o, language: s, axiosTexts: r, confirmTexts: c, formValidationTexts: i, homeDashboardTexts: d, formSubmitTexts: m, appSearchTexts:
|
|
66
|
-
const A =
|
|
65
|
+
}, fe = ({ cookieDomain: e, axiosOptions: n, LinkComponent: t, NavigateComponent: o, language: s, axiosTexts: r, confirmTexts: c, formValidationTexts: i, homeDashboardTexts: d, formSubmitTexts: m, appSearchTexts: g, customSelectTexts: P, errorBoundaryTexts: R, widgetTexts: I, children: S }) => {
|
|
66
|
+
const A = N(() => ({
|
|
67
67
|
axiosOptions: n,
|
|
68
68
|
cookieDomain: e,
|
|
69
69
|
LinkComponent: t,
|
|
@@ -74,9 +74,9 @@ const Z = ({ children: e }) => {
|
|
|
74
74
|
formValidationTexts: i,
|
|
75
75
|
homeDashboardTexts: d,
|
|
76
76
|
formSubmitTexts: m,
|
|
77
|
-
appSearchTexts:
|
|
78
|
-
customSelectTexts:
|
|
79
|
-
errorBoundaryTexts:
|
|
77
|
+
appSearchTexts: g,
|
|
78
|
+
customSelectTexts: P,
|
|
79
|
+
errorBoundaryTexts: R,
|
|
80
80
|
widgetTexts: I
|
|
81
81
|
}), [
|
|
82
82
|
n,
|
|
@@ -89,21 +89,21 @@ const Z = ({ children: e }) => {
|
|
|
89
89
|
i,
|
|
90
90
|
d,
|
|
91
91
|
m,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
g,
|
|
93
|
+
P,
|
|
94
|
+
R,
|
|
95
95
|
I
|
|
96
96
|
]);
|
|
97
|
-
return /* @__PURE__ */ a.jsx(
|
|
97
|
+
return /* @__PURE__ */ a.jsx(O.Provider, { value: A, children: /* @__PURE__ */ a.jsx(Z, { children: /* @__PURE__ */ a.jsxs(te, { children: [
|
|
98
98
|
/* @__PURE__ */ a.jsx(M, {}),
|
|
99
|
-
|
|
99
|
+
S
|
|
100
100
|
] }) }) });
|
|
101
|
-
},
|
|
101
|
+
}, ge = ({ children: e }) => {
|
|
102
102
|
const [n, t] = h(!1), [o] = h(/* @__PURE__ */ new Set()), s = f((i) => {
|
|
103
103
|
o.add(i), t(!0);
|
|
104
104
|
}, [o]), r = f((i) => {
|
|
105
105
|
o.delete(i), o.size === 0 && t(!1);
|
|
106
|
-
}, [o]), c =
|
|
106
|
+
}, [o]), c = N(() => ({ isLoading: n, startLoading: s, stopLoading: r }), [n, s, r]);
|
|
107
107
|
return /* @__PURE__ */ a.jsxs(D.Provider, { value: c, children: [
|
|
108
108
|
n && /* @__PURE__ */ a.jsx(Y, {}),
|
|
109
109
|
e
|
|
@@ -159,19 +159,19 @@ class se {
|
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
/*! @azure/msal-react v2.0.16 2024-05-07 */
|
|
162
|
-
const ne = "@azure/msal-react",
|
|
162
|
+
const ne = "@azure/msal-react", U = "2.0.16";
|
|
163
163
|
/*! @azure/msal-react v2.0.16 2024-05-07 */
|
|
164
|
-
const
|
|
164
|
+
const p = {
|
|
165
165
|
UNBLOCK_INPROGRESS: "UNBLOCK_INPROGRESS",
|
|
166
166
|
EVENT: "EVENT"
|
|
167
167
|
}, oe = (e, n) => {
|
|
168
168
|
const { type: t, payload: o } = n;
|
|
169
169
|
let s = e.inProgress;
|
|
170
170
|
switch (t) {
|
|
171
|
-
case
|
|
171
|
+
case p.UNBLOCK_INPROGRESS:
|
|
172
172
|
e.inProgress === l.Startup && (s = l.None, o.logger.info("MsalProvider - handleRedirectPromise resolved, setting inProgress to 'none'"));
|
|
173
173
|
break;
|
|
174
|
-
case
|
|
174
|
+
case p.EVENT:
|
|
175
175
|
const c = o.message, i = se.getInteractionStatusFromEvent(c, e.inProgress);
|
|
176
176
|
i && (o.logger.info(`MsalProvider - ${c.eventType} results in setting inProgress from ${e.inProgress} to ${i}`), s = i);
|
|
177
177
|
break;
|
|
@@ -179,23 +179,23 @@ const O = {
|
|
|
179
179
|
throw new Error(`Unknown action type: ${t}`);
|
|
180
180
|
}
|
|
181
181
|
const r = o.instance.getAllAccounts();
|
|
182
|
-
return s !== e.inProgress && !
|
|
182
|
+
return s !== e.inProgress && !k(r, e.accounts) ? {
|
|
183
183
|
...e,
|
|
184
184
|
inProgress: s,
|
|
185
185
|
accounts: r
|
|
186
186
|
} : s !== e.inProgress ? {
|
|
187
187
|
...e,
|
|
188
188
|
inProgress: s
|
|
189
|
-
} :
|
|
189
|
+
} : k(r, e.accounts) ? e : {
|
|
190
190
|
...e,
|
|
191
191
|
accounts: r
|
|
192
192
|
};
|
|
193
193
|
};
|
|
194
194
|
function re({ instance: e, children: n }) {
|
|
195
195
|
v(() => {
|
|
196
|
-
e.initializeWrapperLibrary(F.React,
|
|
196
|
+
e.initializeWrapperLibrary(F.React, U);
|
|
197
197
|
}, [e]);
|
|
198
|
-
const t =
|
|
198
|
+
const t = N(() => e.getLogger().clone(ne, U), [e]), [o, s] = Q(oe, void 0, () => ({
|
|
199
199
|
inProgress: l.Startup,
|
|
200
200
|
accounts: e.getAllAccounts()
|
|
201
201
|
}));
|
|
@@ -207,7 +207,7 @@ function re({ instance: e, children: n }) {
|
|
|
207
207
|
logger: t,
|
|
208
208
|
message: i
|
|
209
209
|
},
|
|
210
|
-
type:
|
|
210
|
+
type: p.EVENT
|
|
211
211
|
});
|
|
212
212
|
});
|
|
213
213
|
return t.verbose(`MsalProvider - Registered event callback with id: ${c}`), e.initialize().then(() => {
|
|
@@ -218,7 +218,7 @@ function re({ instance: e, children: n }) {
|
|
|
218
218
|
instance: e,
|
|
219
219
|
logger: t
|
|
220
220
|
},
|
|
221
|
-
type:
|
|
221
|
+
type: p.UNBLOCK_INPROGRESS
|
|
222
222
|
});
|
|
223
223
|
});
|
|
224
224
|
}).catch(() => {
|
|
@@ -234,72 +234,72 @@ function re({ instance: e, children: n }) {
|
|
|
234
234
|
};
|
|
235
235
|
return V.createElement(z.Provider, { value: r }, n);
|
|
236
236
|
}
|
|
237
|
-
const
|
|
238
|
-
const n = H(), { msalInstance: t } =
|
|
239
|
-
const
|
|
240
|
-
|
|
237
|
+
const Ee = ({ children: e }) => {
|
|
238
|
+
const n = H(), { msalInstance: t } = T(w), { getToken: o } = K(), [s, r] = h(null), c = f(async () => {
|
|
239
|
+
const E = await o();
|
|
240
|
+
E && r(E);
|
|
241
241
|
}, [o]);
|
|
242
242
|
v(() => {
|
|
243
243
|
c();
|
|
244
244
|
}, [c]);
|
|
245
245
|
const d = f(() => {
|
|
246
|
-
const
|
|
247
|
-
return
|
|
248
|
-
}, [])(), [m,
|
|
249
|
-
state: d ?
|
|
246
|
+
const E = localStorage.getItem("user") ?? null;
|
|
247
|
+
return E ? JSON.parse(E ?? "") : null;
|
|
248
|
+
}, [])(), [m, g] = h({
|
|
249
|
+
state: d ? y.LOGGED_IN : y.LOGGING_IN,
|
|
250
250
|
user: d
|
|
251
|
-
}),
|
|
251
|
+
}), P = f(async (E) => {
|
|
252
252
|
let x = null;
|
|
253
|
-
return await n.get("/user/detail",
|
|
254
|
-
x =
|
|
253
|
+
return await n.get("/user/detail", E ? { headers: { Authorization: `Bearer ${E}` } } : void 0).then((j) => {
|
|
254
|
+
x = j.data;
|
|
255
255
|
}).catch(() => {
|
|
256
256
|
x = null;
|
|
257
257
|
}), x;
|
|
258
|
-
}, [n]),
|
|
259
|
-
localStorage.removeItem("user"),
|
|
260
|
-
state:
|
|
258
|
+
}, [n]), R = f(() => {
|
|
259
|
+
localStorage.removeItem("user"), g({
|
|
260
|
+
state: y.LOGGED_OUT,
|
|
261
261
|
user: null
|
|
262
262
|
});
|
|
263
|
-
}, []), I = f(async (
|
|
264
|
-
|
|
265
|
-
state:
|
|
263
|
+
}, []), I = f(async (E) => {
|
|
264
|
+
g({
|
|
265
|
+
state: y.LOGGING_IN,
|
|
266
266
|
user: null
|
|
267
267
|
});
|
|
268
|
-
const x = await
|
|
269
|
-
return x ? (
|
|
270
|
-
state:
|
|
268
|
+
const x = await P(E);
|
|
269
|
+
return x ? (g({
|
|
270
|
+
state: y.LOGGED_IN,
|
|
271
271
|
user: x
|
|
272
|
-
}), localStorage.setItem("user", JSON.stringify(x)), !0) : (
|
|
273
|
-
state:
|
|
272
|
+
}), localStorage.setItem("user", JSON.stringify(x)), !0) : (g({
|
|
273
|
+
state: y.LOGIN_FAILED,
|
|
274
274
|
user: null
|
|
275
275
|
}), !1);
|
|
276
|
-
}, [
|
|
277
|
-
|
|
278
|
-
}, [
|
|
276
|
+
}, [P]), S = f(() => {
|
|
277
|
+
R();
|
|
278
|
+
}, [R]), A = N(() => ({
|
|
279
279
|
user: m.user,
|
|
280
280
|
userLoginState: m,
|
|
281
281
|
loginUser: I,
|
|
282
|
-
logoutUser:
|
|
283
|
-
}), [m, I,
|
|
282
|
+
logoutUser: S
|
|
283
|
+
}), [m, I, S]);
|
|
284
284
|
return v(() => {
|
|
285
285
|
if (t) {
|
|
286
|
-
const
|
|
286
|
+
const E = t.addEventCallback((x) => {
|
|
287
287
|
if (x.eventType === u.LOGIN_SUCCESS && x.payload) {
|
|
288
|
-
const
|
|
289
|
-
r(
|
|
288
|
+
const j = x.payload;
|
|
289
|
+
r(j.accessToken);
|
|
290
290
|
}
|
|
291
291
|
});
|
|
292
292
|
return () => {
|
|
293
|
-
|
|
293
|
+
E && t.removeEventCallback(E);
|
|
294
294
|
};
|
|
295
295
|
}
|
|
296
296
|
return () => {
|
|
297
297
|
};
|
|
298
|
-
}, [t, I,
|
|
299
|
-
s && I(s).catch(() =>
|
|
300
|
-
}, [s, I,
|
|
298
|
+
}, [t, I, S]), v(() => {
|
|
299
|
+
s && I(s).catch(() => S());
|
|
300
|
+
}, [s, I, S]), /* @__PURE__ */ a.jsx(B.Provider, { value: A, children: e });
|
|
301
301
|
}, xe = ({ ...e }) => {
|
|
302
|
-
const { cookieDomain: n } =
|
|
302
|
+
const { cookieDomain: n } = T(O), [, t] = q(["Authorization"]), o = N(() => ({
|
|
303
303
|
useMsal: e.useMsal ?? !1,
|
|
304
304
|
msalInstance: e.useMsal ? e.msalInstance ?? null : null,
|
|
305
305
|
msalScopes: e.useMsal ? e.msalScopes ?? [] : []
|
|
@@ -328,7 +328,7 @@ const ge = ({ children: e }) => {
|
|
|
328
328
|
};
|
|
329
329
|
}, [e, t, n]), /* @__PURE__ */ a.jsx(w.Provider, { value: o, children: e.useMsal ? /* @__PURE__ */ a.jsx(re, { instance: e.msalInstance, children: e.children }) : e.children });
|
|
330
330
|
}, ae = () => {
|
|
331
|
-
const { confirmTexts: e } =
|
|
331
|
+
const { confirmTexts: e } = T(O), { onConfirm: n, onCancel: t, text: o, show: s } = W();
|
|
332
332
|
return /* @__PURE__ */ a.jsxs(C, { show: s, size: "sm", centered: !0, onHide: t, children: [
|
|
333
333
|
/* @__PURE__ */ a.jsx(C.Header, { className: "justify-content-center", children: /* @__PURE__ */ a.jsx(C.Title, { children: o }) }),
|
|
334
334
|
/* @__PURE__ */ a.jsx(C.Body, { children: /* @__PURE__ */ a.jsxs("div", { className: "w-100 d-flex gap-5", children: [
|
|
@@ -341,9 +341,9 @@ export {
|
|
|
341
341
|
w as AuthContext,
|
|
342
342
|
xe as AuthProvider,
|
|
343
343
|
D as LoadingContext,
|
|
344
|
-
|
|
345
|
-
|
|
344
|
+
ge as LoadingProvider,
|
|
345
|
+
O as LuminusComponentsContext,
|
|
346
346
|
fe as LuminusComponentsProvider,
|
|
347
347
|
B as UserContext,
|
|
348
|
-
|
|
348
|
+
Ee as UserProvider
|
|
349
349
|
};
|