react-luminus-components 1.2.65 → 1.2.67
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 +37 -37
- package/dist/main.cjs.js +1 -1
- package/dist/main.es.js +624 -628
- 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-KFDzvABU.cjs"),n=require("react"),v=require("./useConfirm-B8EHGeWd.cjs");require("react-hook-form");const l=require("./EventType-CPDIBxba.cjs"),y=()=>{const{confirmTexts:t}=n.useContext(e.LuminusComponentsContext),{isShown:r,text:s,onFinish:o}=v.usePrompt(),{options:a}=n.useContext(e.PromptContext),[c,u]=n.useState(a.defaultValue??""),i=n.useCallback(()=>{o(null)},[o]),d=n.useCallback(()=>{o(c)},[o,c]);n.useEffect(()=>{r===!0&&u(a.defaultValue??"")},[r,a.defaultValue]);const x=n.useMemo(()=>({value:c,onChange:E=>u(E.currentTarget.value),className:"w-100",autoFocus:!0,tabIndex:0}),[c]);return e.jsxRuntimeExports.jsxs(l.Modal,{show:r,size:"sm",centered:!0,onHide:i,children:[e.jsxRuntimeExports.jsx(l.Modal.Header,{children:e.jsxRuntimeExports.jsx(l.Modal.Title,{children:s})}),e.jsxRuntimeExports.jsxs(l.Modal.Body,{children:[a.input==="textarea"?e.jsxRuntimeExports.jsx("textarea",{...x,rows:5}):void 0,a.input==="input"?e.jsxRuntimeExports.jsx("input",{...x,type:a.type}):void 0]}),e.jsxRuntimeExports.jsxs(l.Modal.Footer,{children:[e.jsxRuntimeExports.jsx("button",{type:"button",className:"btn btn-secondary",onClick:i,children:t.cancel}),e.jsxRuntimeExports.jsx("button",{type:"button",className:"btn btn-primary ml",onClick:d,disabled:a.required&&!c,children:t.confirm})]})]})},I=({children:t})=>{const[r,s]=n.useState(!1),[o,a]=n.useState(""),[c,u]=n.useState({input:"textarea",type:"text"}),i=n.useRef(()=>{}),d=n.useCallback(C=>{a(C),s(!0)},[]),x=n.useCallback(()=>{s(!1)},[]),E=n.useMemo(()=>({isShown:r,text:o,showPrompt:d,hidePrompt:x,resolveRef:i,options:c,setOptions:u}),[r,o,d,x,c]);return e.jsxRuntimeExports.jsxs(e.PromptContext.Provider,{value:E,children:[t,e.jsxRuntimeExports.jsx(y,{})]})},T=({children:t})=>{const[r,s]=n.useState(!1),[o,a]=n.useState(""),c=n.useCallback(d=>{s(!0),a(d)},[]),u=n.useCallback(()=>{s(!1)},[]),i=n.useMemo(()=>({show:r,text:o,showConfirm:c,hideConfirm:u}),[r,o,c,u]);return e.jsxRuntimeExports.jsxs(e.ConfirmContext.Provider,{value:i,children:[e.jsxRuntimeExports.jsx(U,{}),t]})},h=({cookieDomain:t,axiosInstance:r,LinkComponent:s,NavigateComponent:o,language:a,axiosTexts:c,confirmTexts:u,formValidationTexts:i,homeDashboardTexts:d,formSubmitTexts:x,appSearchTexts:E,customSelectTexts:C,children:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./NoInputContainer-KFDzvABU.cjs"),n=require("react"),v=require("./useConfirm-B8EHGeWd.cjs");require("react-hook-form");const l=require("./EventType-CPDIBxba.cjs"),y=()=>{const{confirmTexts:t}=n.useContext(e.LuminusComponentsContext),{isShown:r,text:s,onFinish:o}=v.usePrompt(),{options:a}=n.useContext(e.PromptContext),[c,u]=n.useState(a.defaultValue??""),i=n.useCallback(()=>{o(null)},[o]),d=n.useCallback(()=>{o(c)},[o,c]);n.useEffect(()=>{r===!0&&u(a.defaultValue??"")},[r,a.defaultValue]);const x=n.useMemo(()=>({value:c,onChange:E=>u(E.currentTarget.value),className:"w-100",autoFocus:!0,tabIndex:0}),[c]);return e.jsxRuntimeExports.jsxs(l.Modal,{show:r,size:"sm",centered:!0,onHide:i,children:[e.jsxRuntimeExports.jsx(l.Modal.Header,{children:e.jsxRuntimeExports.jsx(l.Modal.Title,{children:s})}),e.jsxRuntimeExports.jsxs(l.Modal.Body,{children:[a.input==="textarea"?e.jsxRuntimeExports.jsx("textarea",{...x,rows:5}):void 0,a.input==="input"?e.jsxRuntimeExports.jsx("input",{...x,type:a.type}):void 0]}),e.jsxRuntimeExports.jsxs(l.Modal.Footer,{children:[e.jsxRuntimeExports.jsx("button",{type:"button",className:"btn btn-secondary",onClick:i,children:t.cancel}),e.jsxRuntimeExports.jsx("button",{type:"button",className:"btn btn-primary ml",onClick:d,disabled:a.required&&!c,children:t.confirm})]})]})},I=({children:t})=>{const[r,s]=n.useState(!1),[o,a]=n.useState(""),[c,u]=n.useState({input:"textarea",type:"text"}),i=n.useRef(()=>{}),d=n.useCallback(C=>{a(C),s(!0)},[]),x=n.useCallback(()=>{s(!1)},[]),E=n.useMemo(()=>({isShown:r,text:o,showPrompt:d,hidePrompt:x,resolveRef:i,options:c,setOptions:u}),[r,o,d,x,c]);return e.jsxRuntimeExports.jsxs(e.PromptContext.Provider,{value:E,children:[t,e.jsxRuntimeExports.jsx(y,{})]})},T=({children:t})=>{const[r,s]=n.useState(!1),[o,a]=n.useState(""),c=n.useCallback(d=>{s(!0),a(d)},[]),u=n.useCallback(()=>{s(!1)},[]),i=n.useMemo(()=>({show:r,text:o,showConfirm:c,hideConfirm:u}),[r,o,c,u]);return e.jsxRuntimeExports.jsxs(e.ConfirmContext.Provider,{value:i,children:[e.jsxRuntimeExports.jsx(U,{}),t]})},h=({cookieDomain:t,axiosInstance:r,LinkComponent:s,NavigateComponent:o,language:a,axiosTexts:c,confirmTexts:u,formValidationTexts:i,homeDashboardTexts:d,formSubmitTexts:x,appSearchTexts:E,customSelectTexts:C,children:R})=>{const m=n.useMemo(()=>({axiosInstance:r,cookieDomain:t,LinkComponent:s,NavigateComponent:o,language:a,axiosTexts:c,confirmTexts:u,formValidationTexts:i,homeDashboardTexts:d,formSubmitTexts:x,appSearchTexts:E,customSelectTexts:C}),[r,t,s,o,a,c,u,i,d,x,E,C]);return e.jsxRuntimeExports.jsx(e.LuminusComponentsContext.Provider,{value:m,children:e.jsxRuntimeExports.jsx(T,{children:e.jsxRuntimeExports.jsxs(I,{children:[e.jsxRuntimeExports.jsx(e.Ie,{}),R]})})})},j=({children:t})=>{const[r,s]=n.useState(!1),[o]=n.useState(new Set),a=n.useCallback(i=>{o.add(i),s(!0)},[o]),c=n.useCallback(i=>{o.delete(i),o.size===0&&s(!1)},[o]),u=n.useMemo(()=>({isLoading:r,startLoading:a,stopLoading:c}),[r,a,c]);return e.jsxRuntimeExports.jsxs(e.LoadingContext.Provider,{value:u,children:[r&&e.jsxRuntimeExports.jsx(l.Loading,{}),t]})};/*! @azure/msal-browser v3.14.0 2024-05-07 */class P{static getInteractionStatusFromEvent(r,s){switch(r.eventType){case l.EventType.LOGIN_START:return e.InteractionStatus.Login;case l.EventType.SSO_SILENT_START:return e.InteractionStatus.SsoSilent;case l.EventType.ACQUIRE_TOKEN_START:if(r.interactionType===e.InteractionType.Redirect||r.interactionType===e.InteractionType.Popup)return e.InteractionStatus.AcquireToken;break;case l.EventType.HANDLE_REDIRECT_START:return e.InteractionStatus.HandleRedirect;case l.EventType.LOGOUT_START:return e.InteractionStatus.Logout;case l.EventType.SSO_SILENT_SUCCESS:case l.EventType.SSO_SILENT_FAILURE:if(s&&s!==e.InteractionStatus.SsoSilent)break;return e.InteractionStatus.None;case l.EventType.LOGOUT_END:if(s&&s!==e.InteractionStatus.Logout)break;return e.InteractionStatus.None;case l.EventType.HANDLE_REDIRECT_END:if(s&&s!==e.InteractionStatus.HandleRedirect)break;return e.InteractionStatus.None;case l.EventType.LOGIN_SUCCESS:case l.EventType.LOGIN_FAILURE:case l.EventType.ACQUIRE_TOKEN_SUCCESS:case l.EventType.ACQUIRE_TOKEN_FAILURE:case l.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",g="2.0.16";/*! @azure/msal-react v2.0.16 2024-05-07 */const S={UNBLOCK_INPROGRESS:"UNBLOCK_INPROGRESS",EVENT:"EVENT"},k=(t,r)=>{const{type:s,payload:o}=r;let a=t.inProgress;switch(s){case S.UNBLOCK_INPROGRESS:t.inProgress===e.InteractionStatus.Startup&&(a=e.InteractionStatus.None,o.logger.info("MsalProvider - handleRedirectPromise resolved, setting inProgress to 'none'"));break;case S.EVENT:const u=o.message,i=P.getInteractionStatusFromEvent(u,t.inProgress);i&&(o.logger.info(`MsalProvider - ${u.eventType} results in setting inProgress from ${t.inProgress} to ${i}`),a=i);break;default:throw new Error(`Unknown action type: ${s}`)}const c=o.instance.getAllAccounts();return a!==t.inProgress&&!e.accountArraysAreEqual(c,t.accounts)?{...t,inProgress:a,accounts:c}:a!==t.inProgress?{...t,inProgress:a}:e.accountArraysAreEqual(c,t.accounts)?t:{...t,accounts:c}};function L({instance:t,children:r}){n.useEffect(()=>{t.initializeWrapperLibrary(e.WrapperSKU.React,g)},[t]);const s=n.useMemo(()=>t.getLogger().clone(b,g),[t]),[o,a]=n.useReducer(k,void 0,()=>({inProgress:e.InteractionStatus.Startup,accounts:t.getAllAccounts()}));n.useEffect(()=>{const u=t.addEventCallback(i=>{a({payload:{instance:t,logger:s,message:i},type:S.EVENT})});return s.verbose(`MsalProvider - Registered event callback with id: ${u}`),t.initialize().then(()=>{t.handleRedirectPromise().catch(()=>{}).finally(()=>{a({payload:{instance:t,logger:s},type:S.UNBLOCK_INPROGRESS})})}).catch(()=>{}),()=>{u&&(s.verbose(`MsalProvider - Removing event callback ${u}`),t.removeEventCallback(u))}},[t,s]);const c={instance:t,inProgress:o.inProgress,accounts:o.accounts,logger:s};return n.createElement(e.MsalContext.Provider,{value:c},r)}const N=({children:t})=>{const r=e.useAxios(),{msalInstance:s}=n.useContext(e.AuthContext),[o,a]=n.useState(!1),c=n.useCallback(()=>{const m=localStorage.getItem("user")??null;return m?JSON.parse(m):null},[]),[u,i]=n.useState(c()),d=n.useCallback(async m=>{let p=null;return await r.get("/user/detail",m?{headers:{Authorization:`Bearer ${m}`}}:void 0).then(f=>{p=f.data}).catch(()=>{p=null}),localStorage.setItem("user",JSON.stringify(p)),p},[r]),x=n.useCallback(()=>{localStorage.removeItem("user")},[]),E=n.useCallback(async m=>{a(!0);const p=await d(m);return a(!1),p?(i(p),!0):!1},[d]),C=n.useCallback(()=>{x(),i(null)},[x]),R=n.useMemo(()=>({user:u,loggingInProgress:o,loginUser:E,logoutUser:C}),[u,E,C,o]);return n.useEffect(()=>{i(c())},[c]),n.useEffect(()=>{if(s){const m=s.addEventCallback(p=>{if(p.eventType===l.EventType.LOGIN_SUCCESS&&p.payload){const f=p.payload;E(f.accessToken).catch(()=>C())}});return()=>{m&&s.removeEventCallback(m)}}return()=>{}},[s,E,C]),e.jsxRuntimeExports.jsx(e.UserContext.Provider,{value:R,children:t})},A=({...t})=>{const{cookieDomain:r}=n.useContext(e.LuminusComponentsContext),[,s]=e.useCookies(["Authorization"]),[o,a]=n.useState(null),c=n.useMemo(()=>({useMsal:t.useMsal??!1,storedToken:(o==null?void 0:o.token)??null,msalInstance:t.useMsal?t.msalInstance??null:null,msalScopes:t.useMsal?t.msalScopes??[]:[]}),[t,o]);return n.useEffect(()=>{if(t.useMsal){const u=t.msalInstance.addEventCallback(i=>{if(i.eventType===l.EventType.LOGIN_SUCCESS||i.eventType===l.EventType.ACQUIRE_TOKEN_SUCCESS&&i.payload){const d=i.payload,x=d.account;t.msalInstance.setActiveAccount(x);const E=d.accessToken,C=d.expiresOn;a({token:E,expiresOn:C})}});return()=>{u&&t.msalInstance.removeEventCallback(u)}}return()=>{}},[t]),n.useEffect(()=>{o&&s("Authorization",o.token,{path:"/",secure:!0,sameSite:"none",domain:r,expires:o.expiresOn??void 0})},[o,r,s]),e.jsxRuntimeExports.jsx(e.AuthContext.Provider,{value:c,children:t.useMsal?e.jsxRuntimeExports.jsx(L,{instance:t.msalInstance,children:t.children}):t.children})},U=()=>{const{confirmTexts:t}=n.useContext(e.LuminusComponentsContext),{onConfirm:r,onCancel:s,text:o,show:a}=v.useConfirm();return e.jsxRuntimeExports.jsx(l.Modal,{show:a,size:"sm",centered:!0,onHide:s,children:e.jsxRuntimeExports.jsxs(l.Modal.Body,{children:[e.jsxRuntimeExports.jsx("div",{className:"mb-5 text-center",children:e.jsxRuntimeExports.jsx(e.Typography,{variant:"h6",children:o})}),e.jsxRuntimeExports.jsxs("div",{className:"w-100 d-flex gap-5",children:[e.jsxRuntimeExports.jsx("button",{type:"button",className:"btn btn-secondary w-100",onClick:s,children:t.no}),e.jsxRuntimeExports.jsx("button",{type:"button",className:"btn btn-primary w-100 ml",onClick:r,children:t.yes})]})]})})};exports.AuthContext=e.AuthContext;exports.LoadingContext=e.LoadingContext;exports.LuminusComponentsContext=e.LuminusComponentsContext;exports.UserContext=e.UserContext;exports.AuthProvider=A;exports.LoadingProvider=j;exports.LuminusComponentsProvider=h;exports.UserProvider=N;
|
package/dist/contexts.es.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { N as T, aj as k, j as a, ak as _, al as j, am as O, L as
|
|
2
|
-
import
|
|
1
|
+
import { N as T, aj as k, j as a, ak as _, al as j, am as O, L as y, K as l, an as U, ao as w, ap as p, a3 as M, a7 as A, a9 as G, aq as z, X as F } from "./NoInputContainer-2Ycv-Em1.js";
|
|
2
|
+
import K, { useContext as S, useState as C, useCallback as f, useEffect as I, useMemo as P, useRef as B, useReducer as H } from "react";
|
|
3
3
|
import { u as D, a as V } from "./useConfirm-DHU1tOje.js";
|
|
4
4
|
import "react-hook-form";
|
|
5
5
|
import { M as v, L as $, E as u } from "./EventType-CL7YvlYX.js";
|
|
6
6
|
const q = () => {
|
|
7
|
-
const { confirmTexts: e } =
|
|
7
|
+
const { confirmTexts: e } = S(T), { isShown: s, text: t, onFinish: n } = D(), { options: o } = S(k), [r, i] = C(o.defaultValue ?? ""), c = f(() => {
|
|
8
8
|
n(null);
|
|
9
9
|
}, [n]), d = f(() => {
|
|
10
10
|
n(r);
|
|
@@ -32,8 +32,8 @@ const q = () => {
|
|
|
32
32
|
] });
|
|
33
33
|
}, Q = ({ children: e }) => {
|
|
34
34
|
const [s, t] = C(!1), [n, o] = C(""), [r, i] = C({ input: "textarea", type: "text" }), c = B(() => {
|
|
35
|
-
}), d = f((
|
|
36
|
-
o(
|
|
35
|
+
}), d = f((E) => {
|
|
36
|
+
o(E), t(!0);
|
|
37
37
|
}, []), g = f(() => {
|
|
38
38
|
t(!1);
|
|
39
39
|
}, []), m = P(() => ({
|
|
@@ -59,8 +59,8 @@ const q = () => {
|
|
|
59
59
|
/* @__PURE__ */ a.jsx(ee, {}),
|
|
60
60
|
e
|
|
61
61
|
] });
|
|
62
|
-
}, ae = ({ cookieDomain: e, axiosInstance: s, LinkComponent: t, NavigateComponent: n, language: o, axiosTexts: r, confirmTexts: i, formValidationTexts: c, homeDashboardTexts: d, formSubmitTexts: g, appSearchTexts: m, customSelectTexts:
|
|
63
|
-
const
|
|
62
|
+
}, ae = ({ cookieDomain: e, axiosInstance: s, LinkComponent: t, NavigateComponent: n, language: o, axiosTexts: r, confirmTexts: i, formValidationTexts: c, homeDashboardTexts: d, formSubmitTexts: g, appSearchTexts: m, customSelectTexts: E, children: N }) => {
|
|
63
|
+
const x = P(() => ({
|
|
64
64
|
axiosInstance: s,
|
|
65
65
|
cookieDomain: e,
|
|
66
66
|
LinkComponent: t,
|
|
@@ -72,7 +72,7 @@ const q = () => {
|
|
|
72
72
|
homeDashboardTexts: d,
|
|
73
73
|
formSubmitTexts: g,
|
|
74
74
|
appSearchTexts: m,
|
|
75
|
-
customSelectTexts:
|
|
75
|
+
customSelectTexts: E
|
|
76
76
|
}), [
|
|
77
77
|
s,
|
|
78
78
|
e,
|
|
@@ -85,9 +85,9 @@ const q = () => {
|
|
|
85
85
|
d,
|
|
86
86
|
g,
|
|
87
87
|
m,
|
|
88
|
-
|
|
88
|
+
E
|
|
89
89
|
]);
|
|
90
|
-
return /* @__PURE__ */ a.jsx(T.Provider, { value:
|
|
90
|
+
return /* @__PURE__ */ a.jsx(T.Provider, { value: x, children: /* @__PURE__ */ a.jsx(J, { children: /* @__PURE__ */ a.jsxs(Q, { children: [
|
|
91
91
|
/* @__PURE__ */ a.jsx(j, {}),
|
|
92
92
|
N
|
|
93
93
|
] }) }) });
|
|
@@ -116,7 +116,7 @@ class W {
|
|
|
116
116
|
case u.SSO_SILENT_START:
|
|
117
117
|
return l.SsoSilent;
|
|
118
118
|
case u.ACQUIRE_TOKEN_START:
|
|
119
|
-
if (s.interactionType ===
|
|
119
|
+
if (s.interactionType === y.Redirect || s.interactionType === y.Popup)
|
|
120
120
|
return l.AcquireToken;
|
|
121
121
|
break;
|
|
122
122
|
case u.HANDLE_REDIRECT_START:
|
|
@@ -141,7 +141,7 @@ class W {
|
|
|
141
141
|
case u.ACQUIRE_TOKEN_SUCCESS:
|
|
142
142
|
case u.ACQUIRE_TOKEN_FAILURE:
|
|
143
143
|
case u.RESTORE_FROM_BFCACHE:
|
|
144
|
-
if (s.interactionType ===
|
|
144
|
+
if (s.interactionType === y.Redirect || s.interactionType === y.Popup) {
|
|
145
145
|
if (t && t !== l.Login && t !== l.AcquireToken)
|
|
146
146
|
break;
|
|
147
147
|
return l.None;
|
|
@@ -154,17 +154,17 @@ class W {
|
|
|
154
154
|
/*! @azure/msal-react v2.0.16 2024-05-07 */
|
|
155
155
|
const X = "@azure/msal-react", L = "2.0.16";
|
|
156
156
|
/*! @azure/msal-react v2.0.16 2024-05-07 */
|
|
157
|
-
const
|
|
157
|
+
const R = {
|
|
158
158
|
UNBLOCK_INPROGRESS: "UNBLOCK_INPROGRESS",
|
|
159
159
|
EVENT: "EVENT"
|
|
160
160
|
}, Y = (e, s) => {
|
|
161
161
|
const { type: t, payload: n } = s;
|
|
162
162
|
let o = e.inProgress;
|
|
163
163
|
switch (t) {
|
|
164
|
-
case
|
|
164
|
+
case R.UNBLOCK_INPROGRESS:
|
|
165
165
|
e.inProgress === l.Startup && (o = l.None, n.logger.info("MsalProvider - handleRedirectPromise resolved, setting inProgress to 'none'"));
|
|
166
166
|
break;
|
|
167
|
-
case
|
|
167
|
+
case R.EVENT:
|
|
168
168
|
const i = n.message, c = W.getInteractionStatusFromEvent(i, e.inProgress);
|
|
169
169
|
c && (n.logger.info(`MsalProvider - ${i.eventType} results in setting inProgress from ${e.inProgress} to ${c}`), o = c);
|
|
170
170
|
break;
|
|
@@ -200,7 +200,7 @@ function Z({ instance: e, children: s }) {
|
|
|
200
200
|
logger: t,
|
|
201
201
|
message: c
|
|
202
202
|
},
|
|
203
|
-
type:
|
|
203
|
+
type: R.EVENT
|
|
204
204
|
});
|
|
205
205
|
});
|
|
206
206
|
return t.verbose(`MsalProvider - Registered event callback with id: ${i}`), e.initialize().then(() => {
|
|
@@ -211,7 +211,7 @@ function Z({ instance: e, children: s }) {
|
|
|
211
211
|
instance: e,
|
|
212
212
|
logger: t
|
|
213
213
|
},
|
|
214
|
-
type:
|
|
214
|
+
type: R.UNBLOCK_INPROGRESS
|
|
215
215
|
});
|
|
216
216
|
});
|
|
217
217
|
}).catch(() => {
|
|
@@ -225,47 +225,47 @@ function Z({ instance: e, children: s }) {
|
|
|
225
225
|
accounts: n.accounts,
|
|
226
226
|
logger: t
|
|
227
227
|
};
|
|
228
|
-
return
|
|
228
|
+
return K.createElement(w.Provider, { value: r }, s);
|
|
229
229
|
}
|
|
230
230
|
const ie = ({ children: e }) => {
|
|
231
|
-
const s = M(), { msalInstance: t } =
|
|
232
|
-
const
|
|
233
|
-
return
|
|
234
|
-
}, []), [i, c] = C(r()), d = f(async (
|
|
231
|
+
const s = M(), { msalInstance: t } = S(A), [n, o] = C(!1), r = f(() => {
|
|
232
|
+
const x = localStorage.getItem("user") ?? null;
|
|
233
|
+
return x ? JSON.parse(x) : null;
|
|
234
|
+
}, []), [i, c] = C(r()), d = f(async (x) => {
|
|
235
235
|
let h = null;
|
|
236
|
-
return await s.get("/user/detail",
|
|
236
|
+
return await s.get("/user/detail", x ? { headers: { Authorization: `Bearer ${x}` } } : void 0).then((b) => {
|
|
237
237
|
h = b.data;
|
|
238
238
|
}).catch(() => {
|
|
239
239
|
h = null;
|
|
240
240
|
}), localStorage.setItem("user", JSON.stringify(h)), h;
|
|
241
241
|
}, [s]), g = f(() => {
|
|
242
242
|
localStorage.removeItem("user");
|
|
243
|
-
}, []), m = f(async (
|
|
243
|
+
}, []), m = f(async (x) => {
|
|
244
244
|
o(!0);
|
|
245
|
-
const h = await d(
|
|
245
|
+
const h = await d(x);
|
|
246
246
|
return o(!1), h ? (c(h), !0) : !1;
|
|
247
|
-
}, [d]),
|
|
247
|
+
}, [d]), E = f(() => {
|
|
248
248
|
g(), c(null);
|
|
249
|
-
}, [g]), N = P(() => ({ user: i, loggingInProgress: n, loginUser: m, logoutUser:
|
|
249
|
+
}, [g]), N = P(() => ({ user: i, loggingInProgress: n, loginUser: m, logoutUser: E }), [i, m, E, n]);
|
|
250
250
|
return I(() => {
|
|
251
251
|
c(r());
|
|
252
252
|
}, [r]), I(() => {
|
|
253
253
|
if (t) {
|
|
254
|
-
const
|
|
255
|
-
if (h.eventType === u.
|
|
254
|
+
const x = t.addEventCallback((h) => {
|
|
255
|
+
if (h.eventType === u.LOGIN_SUCCESS && h.payload) {
|
|
256
256
|
const b = h.payload;
|
|
257
|
-
m(b.accessToken).catch(() =>
|
|
257
|
+
m(b.accessToken).catch(() => E());
|
|
258
258
|
}
|
|
259
259
|
});
|
|
260
260
|
return () => {
|
|
261
|
-
|
|
261
|
+
x && t.removeEventCallback(x);
|
|
262
262
|
};
|
|
263
263
|
}
|
|
264
264
|
return () => {
|
|
265
265
|
};
|
|
266
|
-
}, [t, m,
|
|
266
|
+
}, [t, m, E]), /* @__PURE__ */ a.jsx(G.Provider, { value: N, children: e });
|
|
267
267
|
}, le = ({ ...e }) => {
|
|
268
|
-
const { cookieDomain: s } =
|
|
268
|
+
const { cookieDomain: s } = S(T), [, t] = z(["Authorization"]), [n, o] = C(null), r = P(() => ({
|
|
269
269
|
useMsal: e.useMsal ?? !1,
|
|
270
270
|
storedToken: (n == null ? void 0 : n.token) ?? null,
|
|
271
271
|
msalInstance: e.useMsal ? e.msalInstance ?? null : null,
|
|
@@ -277,8 +277,8 @@ const ie = ({ children: e }) => {
|
|
|
277
277
|
if (c.eventType === u.LOGIN_SUCCESS || c.eventType === u.ACQUIRE_TOKEN_SUCCESS && c.payload) {
|
|
278
278
|
const d = c.payload, g = d.account;
|
|
279
279
|
e.msalInstance.setActiveAccount(g);
|
|
280
|
-
const m = d.accessToken,
|
|
281
|
-
o({ token: m, expiresOn:
|
|
280
|
+
const m = d.accessToken, E = d.expiresOn;
|
|
281
|
+
o({ token: m, expiresOn: E });
|
|
282
282
|
}
|
|
283
283
|
});
|
|
284
284
|
return () => {
|
|
@@ -297,7 +297,7 @@ const ie = ({ children: e }) => {
|
|
|
297
297
|
});
|
|
298
298
|
}, [n, s, t]), /* @__PURE__ */ a.jsx(A.Provider, { value: r, children: e.useMsal ? /* @__PURE__ */ a.jsx(Z, { instance: e.msalInstance, children: e.children }) : e.children });
|
|
299
299
|
}, ee = () => {
|
|
300
|
-
const { confirmTexts: e } =
|
|
300
|
+
const { confirmTexts: e } = S(T), { onConfirm: s, onCancel: t, text: n, show: o } = V();
|
|
301
301
|
return /* @__PURE__ */ a.jsx(v, { show: o, size: "sm", centered: !0, onHide: t, children: /* @__PURE__ */ a.jsxs(v.Body, { children: [
|
|
302
302
|
/* @__PURE__ */ a.jsx("div", { className: "mb-5 text-center", children: /* @__PURE__ */ a.jsx(F, { variant: "h6", children: n }) }),
|
|
303
303
|
/* @__PURE__ */ a.jsxs("div", { className: "w-100 d-flex gap-5", children: [
|
|
@@ -313,6 +313,6 @@ export {
|
|
|
313
313
|
ce as LoadingProvider,
|
|
314
314
|
T as LuminusComponentsContext,
|
|
315
315
|
ae as LuminusComponentsProvider,
|
|
316
|
-
|
|
316
|
+
G as UserContext,
|
|
317
317
|
ie as UserProvider
|
|
318
318
|
};
|