react-luminus-components 1.2.111 → 1.2.112
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 +126 -126
- 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-B2NLKTjL.cjs"),n=require("react");require("./latinize-DaqzUOla.cjs");require("react-hook-form");const y=require("./useConfirm-k8Kyrbnb.cjs"),i=require("./PrimaryButton-DdX5Urwd.cjs"),v=({children:t})=>{const[r,s]=n.useState(!1),[a,o]=n.useState(""),c=n.useCallback(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./NoInputContainer-B2NLKTjL.cjs"),n=require("react");require("./latinize-DaqzUOla.cjs");require("react-hook-form");const y=require("./useConfirm-k8Kyrbnb.cjs"),i=require("./PrimaryButton-DdX5Urwd.cjs"),v=({children:t})=>{const[r,s]=n.useState(!1),[a,o]=n.useState(""),c=n.useCallback(m=>{s(!0),o(m)},[]),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(U,{}),t]})},I=()=>{const{confirmTexts:t}=n.useContext(e.LuminusComponentsContext),{isShown:r,text:s,onFinish:a}=y.usePrompt(),{options:o}=n.useContext(e.PromptContext),[c,u]=n.useState(o.defaultValue??""),l=n.useCallback(()=>{a(null)},[a]),m=n.useCallback(C=>{C.preventDefault(),!(o.required&&!c)&&a(c)},[a,o.required,c]);n.useEffect(()=>{r===!0&&u(o.defaultValue??"")},[r,o.defaultValue]);const E=n.useMemo(()=>({value:c,onChange:C=>u(C.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:m,children:[e.jsxRuntimeExports.jsxs(i.Modal.Body,{children:[o.input==="textarea"?e.jsxRuntimeExports.jsx("textarea",{...E,rows:5}):void 0,o.input==="input"?e.jsxRuntimeExports.jsx(i.FormControl,{...E,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})]})]})]})},j=({children:t})=>{const[r,s]=n.useState(!1),[a,o]=n.useState(""),[c,u]=n.useState({input:"textarea",type:"text"}),l=n.useRef(()=>{}),m=n.useCallback(p=>{o(p),s(!0)},[]),E=n.useCallback(()=>{s(!1)},[]),C=n.useMemo(()=>({isShown:r,text:a,showPrompt:m,hidePrompt:E,resolveRef:l,options:c,setOptions:u}),[r,a,m,E,c]);return e.jsxRuntimeExports.jsxs(e.PromptContext.Provider,{value:C,children:[t,e.jsxRuntimeExports.jsx(I,{})]})},P=({cookieDomain:t,axiosOptions:r,LinkComponent:s,NavigateComponent:a,language:o,axiosTexts:c,confirmTexts:u,formValidationTexts:l,homeDashboardTexts:m,formSubmitTexts:E,appSearchTexts:C,customSelectTexts:p,errorBoundaryTexts:f,widgetTexts:d,children:x})=>{const g=n.useMemo(()=>({axiosOptions:r,cookieDomain:t,LinkComponent:s,NavigateComponent:a,language:o,axiosTexts:c,confirmTexts:u,formValidationTexts:l,homeDashboardTexts:m,formSubmitTexts:E,appSearchTexts:C,customSelectTexts:p,errorBoundaryTexts:f,widgetTexts:d}),[r,t,s,a,o,c,u,l,m,E,C,p,f,d]);return e.jsxRuntimeExports.jsx(e.LuminusComponentsContext.Provider,{value:g,children:e.jsxRuntimeExports.jsx(v,{children:e.jsxRuntimeExports.jsxs(j,{children:[e.jsxRuntimeExports.jsx(e.Ie,{}),x]})})})},h=({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 T{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 N="@azure/msal-react",S="2.0.16";/*! @azure/msal-react v2.0.16 2024-05-07 */const R={UNBLOCK_INPROGRESS:"UNBLOCK_INPROGRESS",EVENT:"EVENT"},L=(t,r)=>{const{type:s,payload:a}=r;let o=t.inProgress;switch(s){case R.UNBLOCK_INPROGRESS:t.inProgress===e.InteractionStatus.Startup&&(o=e.InteractionStatus.None,a.logger.info("MsalProvider - handleRedirectPromise resolved, setting inProgress to 'none'"));break;case R.EVENT:const u=a.message,l=T.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 b({instance:t,children:r}){n.useEffect(()=>{t.initializeWrapperLibrary(e.WrapperSKU.React,S)},[t]);const s=n.useMemo(()=>t.getLogger().clone(N,S),[t]),[a,o]=n.useReducer(L,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:R.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:R.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 k=({children:t})=>{const r=e.useAxios(),{msalInstance:s}=n.useContext(e.AuthContext),[a,o]=n.useState(!1),c=n.useCallback(()=>{const d=localStorage.getItem("user")??null;return console.log("getting user from storage",d?JSON.parse(d):null),d?JSON.parse(d??""):null},[]),[u,l]=n.useState(c()),m=n.useCallback(async d=>{let x=null;return await r.get("/user/detail",d?{headers:{Authorization:`Bearer ${d}`}}:void 0).then(g=>{x=g.data,console.log("user login response",x)}).catch(()=>{x=null,console.log("user login failed")}),localStorage.setItem("user",JSON.stringify(x)),x},[r]),E=n.useCallback(()=>{localStorage.removeItem("user")},[]),C=n.useCallback(async d=>{o(!0);const x=await m(d);return o(!1),x?(console.log("setting user",x),l(x),!0):!1},[m]),p=n.useCallback(()=>{E(),l(null)},[E]),f=n.useMemo(()=>({user:u,loggingInProgress:a,loginUser:C,logoutUser:p}),[u,C,p,a]);return n.useEffect(()=>{l(c())},[c]),n.useEffect(()=>{if(s){const d=s.addEventCallback(x=>{if(x.eventType===i.EventType.LOGIN_SUCCESS&&x.payload){const g=x.payload;C(g.accessToken).catch(()=>p())}});return()=>{d&&s.removeEventCallback(d)}}return()=>{}},[s,C,p]),e.jsxRuntimeExports.jsx(e.UserContext.Provider,{value:f,children:t})},A=({...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 m=u.accessToken,E=u.expiresOn;s("Authorization",m,{path:"/",secure:!0,sameSite:"none",domain:r,expires:E??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(b,{instance:t.msalInstance,children:t.children}):t.children})},U=()=>{const{confirmTexts:t}=n.useContext(e.LuminusComponentsContext),{onConfirm:r,onCancel:s,text:a,show:o}=y.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=A;exports.LoadingProvider=h;exports.LuminusComponentsProvider=P;exports.UserProvider=k;
|
package/dist/contexts.es.js
CHANGED
|
@@ -1,111 +1,111 @@
|
|
|
1
|
-
import { j as a, al as
|
|
1
|
+
import { j as a, al as U, Q as L, am as _, an as k, ao as b, M as N, L as i, ap as w, aq as M, ar as j, a4 as F, a8 as O, aa as G, as as z } from "./NoInputContainer-CnWtqd6M.js";
|
|
2
2
|
import H, { useState as h, useCallback as E, useMemo as v, useContext as R, useEffect as I, useRef as K, useReducer as B } from "react";
|
|
3
3
|
import "./latinize-BQrinury.js";
|
|
4
4
|
import "react-hook-form";
|
|
5
5
|
import { u as D, a as q } from "./useConfirm-C4vc6fDa.js";
|
|
6
6
|
import { M as P, b as V, P as T, L as $, E as u } from "./PrimaryButton-JmPJBth0.js";
|
|
7
7
|
const Q = ({ children: e }) => {
|
|
8
|
-
const [
|
|
9
|
-
n(!0),
|
|
8
|
+
const [t, n] = h(!1), [o, s] = h(""), r = E((m) => {
|
|
9
|
+
n(!0), s(m);
|
|
10
10
|
}, []), c = E(() => {
|
|
11
11
|
n(!1);
|
|
12
|
-
}, []),
|
|
13
|
-
return /* @__PURE__ */ a.jsxs(
|
|
12
|
+
}, []), l = v(() => ({ show: t, text: o, showConfirm: r, hideConfirm: c }), [t, o, r, c]);
|
|
13
|
+
return /* @__PURE__ */ a.jsxs(U.Provider, { value: l, children: [
|
|
14
14
|
/* @__PURE__ */ a.jsx(ne, {}),
|
|
15
15
|
e
|
|
16
16
|
] });
|
|
17
17
|
}, J = () => {
|
|
18
|
-
const { confirmTexts: e } = R(L), { isShown:
|
|
18
|
+
const { confirmTexts: e } = R(L), { isShown: t, text: n, onFinish: o } = D(), { options: s } = R(_), [r, c] = h(s.defaultValue ?? ""), l = E(() => {
|
|
19
19
|
o(null);
|
|
20
|
-
}, [o]),
|
|
21
|
-
|
|
22
|
-
}, [o,
|
|
20
|
+
}, [o]), m = E((x) => {
|
|
21
|
+
x.preventDefault(), !(s.required && !r) && o(r);
|
|
22
|
+
}, [o, s.required, r]);
|
|
23
23
|
I(() => {
|
|
24
|
-
|
|
25
|
-
}, [
|
|
26
|
-
const
|
|
24
|
+
t === !0 && c(s.defaultValue ?? "");
|
|
25
|
+
}, [t, s.defaultValue]);
|
|
26
|
+
const f = v(() => ({
|
|
27
27
|
value: r,
|
|
28
|
-
onChange: (
|
|
28
|
+
onChange: (x) => c(x.currentTarget.value),
|
|
29
29
|
className: "w-100",
|
|
30
30
|
autoFocus: !0,
|
|
31
31
|
tabIndex: 0
|
|
32
32
|
}), [r]);
|
|
33
|
-
return /* @__PURE__ */ a.jsxs(P, { show:
|
|
33
|
+
return /* @__PURE__ */ a.jsxs(P, { show: t, size: "sm", centered: !0, onHide: l, children: [
|
|
34
34
|
/* @__PURE__ */ a.jsx(P.Header, { className: "justify-content-center", children: /* @__PURE__ */ a.jsx(P.Title, { children: n }) }),
|
|
35
|
-
/* @__PURE__ */ a.jsxs("form", { onSubmit:
|
|
35
|
+
/* @__PURE__ */ a.jsxs("form", { onSubmit: m, children: [
|
|
36
36
|
/* @__PURE__ */ a.jsxs(P.Body, { children: [
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
s.input === "textarea" ? /* @__PURE__ */ a.jsx("textarea", { ...f, rows: 5 }) : void 0,
|
|
38
|
+
s.input === "input" ? /* @__PURE__ */ a.jsx(V, { ...f, type: s.type }) : void 0
|
|
39
39
|
] }),
|
|
40
40
|
/* @__PURE__ */ a.jsxs(P.Footer, { className: "w-100 d-flex gap-5", children: [
|
|
41
|
-
/* @__PURE__ */ a.jsx(T, { variant: "outlined", color: "secondary", onClick:
|
|
42
|
-
/* @__PURE__ */ a.jsx(T, { color: "primary", disabled:
|
|
41
|
+
/* @__PURE__ */ a.jsx(T, { variant: "outlined", color: "secondary", onClick: l, className: "flex-grow-1", children: e.cancel }),
|
|
42
|
+
/* @__PURE__ */ a.jsx(T, { color: "primary", disabled: s.required && !r, type: "submit", className: "flex-grow-1", children: e.confirm })
|
|
43
43
|
] })
|
|
44
44
|
] })
|
|
45
45
|
] });
|
|
46
46
|
}, W = ({ children: e }) => {
|
|
47
|
-
const [
|
|
48
|
-
}),
|
|
49
|
-
|
|
50
|
-
}, []),
|
|
47
|
+
const [t, n] = h(!1), [o, s] = h(""), [r, c] = h({ input: "textarea", type: "text" }), l = K(() => {
|
|
48
|
+
}), m = E((C) => {
|
|
49
|
+
s(C), n(!0);
|
|
50
|
+
}, []), f = E(() => {
|
|
51
51
|
n(!1);
|
|
52
|
-
}, []),
|
|
53
|
-
isShown:
|
|
52
|
+
}, []), x = v(() => ({
|
|
53
|
+
isShown: t,
|
|
54
54
|
text: o,
|
|
55
|
-
showPrompt:
|
|
56
|
-
hidePrompt:
|
|
57
|
-
resolveRef:
|
|
55
|
+
showPrompt: m,
|
|
56
|
+
hidePrompt: f,
|
|
57
|
+
resolveRef: l,
|
|
58
58
|
options: r,
|
|
59
59
|
setOptions: c
|
|
60
|
-
}), [
|
|
61
|
-
return /* @__PURE__ */ a.jsxs(_.Provider, { value:
|
|
60
|
+
}), [t, o, m, f, r]);
|
|
61
|
+
return /* @__PURE__ */ a.jsxs(_.Provider, { value: x, children: [
|
|
62
62
|
e,
|
|
63
63
|
/* @__PURE__ */ a.jsx(J, {})
|
|
64
64
|
] });
|
|
65
|
-
},
|
|
65
|
+
}, le = ({ cookieDomain: e, axiosOptions: t, LinkComponent: n, NavigateComponent: o, language: s, axiosTexts: r, confirmTexts: c, formValidationTexts: l, homeDashboardTexts: m, formSubmitTexts: f, appSearchTexts: x, customSelectTexts: C, errorBoundaryTexts: y, widgetTexts: d, children: g }) => {
|
|
66
66
|
const S = v(() => ({
|
|
67
|
-
axiosOptions:
|
|
67
|
+
axiosOptions: t,
|
|
68
68
|
cookieDomain: e,
|
|
69
69
|
LinkComponent: n,
|
|
70
70
|
NavigateComponent: o,
|
|
71
|
-
language:
|
|
71
|
+
language: s,
|
|
72
72
|
axiosTexts: r,
|
|
73
73
|
confirmTexts: c,
|
|
74
|
-
formValidationTexts:
|
|
75
|
-
homeDashboardTexts:
|
|
76
|
-
formSubmitTexts:
|
|
77
|
-
appSearchTexts:
|
|
74
|
+
formValidationTexts: l,
|
|
75
|
+
homeDashboardTexts: m,
|
|
76
|
+
formSubmitTexts: f,
|
|
77
|
+
appSearchTexts: x,
|
|
78
78
|
customSelectTexts: C,
|
|
79
79
|
errorBoundaryTexts: y,
|
|
80
|
-
widgetTexts:
|
|
80
|
+
widgetTexts: d
|
|
81
81
|
}), [
|
|
82
|
-
|
|
82
|
+
t,
|
|
83
83
|
e,
|
|
84
84
|
n,
|
|
85
85
|
o,
|
|
86
|
-
|
|
86
|
+
s,
|
|
87
87
|
r,
|
|
88
88
|
c,
|
|
89
|
-
|
|
90
|
-
d,
|
|
89
|
+
l,
|
|
91
90
|
m,
|
|
92
91
|
f,
|
|
92
|
+
x,
|
|
93
93
|
C,
|
|
94
94
|
y,
|
|
95
|
-
|
|
95
|
+
d
|
|
96
96
|
]);
|
|
97
97
|
return /* @__PURE__ */ a.jsx(L.Provider, { value: S, children: /* @__PURE__ */ a.jsx(Q, { children: /* @__PURE__ */ a.jsxs(W, { children: [
|
|
98
98
|
/* @__PURE__ */ a.jsx(k, {}),
|
|
99
|
-
|
|
99
|
+
g
|
|
100
100
|
] }) }) });
|
|
101
|
-
},
|
|
102
|
-
const [
|
|
103
|
-
o.add(
|
|
104
|
-
}, [o]), r = E((
|
|
105
|
-
o.delete(
|
|
106
|
-
}, [o]), c = v(() => ({ isLoading:
|
|
101
|
+
}, ie = ({ children: e }) => {
|
|
102
|
+
const [t, n] = h(!1), [o] = h(/* @__PURE__ */ new Set()), s = E((l) => {
|
|
103
|
+
o.add(l), n(!0);
|
|
104
|
+
}, [o]), r = E((l) => {
|
|
105
|
+
o.delete(l), o.size === 0 && n(!1);
|
|
106
|
+
}, [o]), c = v(() => ({ isLoading: t, startLoading: s, stopLoading: r }), [t, s, r]);
|
|
107
107
|
return /* @__PURE__ */ a.jsxs(b.Provider, { value: c, children: [
|
|
108
|
-
|
|
108
|
+
t && /* @__PURE__ */ a.jsx($, {}),
|
|
109
109
|
e
|
|
110
110
|
] });
|
|
111
111
|
};
|
|
@@ -116,42 +116,42 @@ class X {
|
|
|
116
116
|
* @param message
|
|
117
117
|
* @param currentStatus
|
|
118
118
|
*/
|
|
119
|
-
static getInteractionStatusFromEvent(
|
|
120
|
-
switch (
|
|
119
|
+
static getInteractionStatusFromEvent(t, n) {
|
|
120
|
+
switch (t.eventType) {
|
|
121
121
|
case u.LOGIN_START:
|
|
122
|
-
return
|
|
122
|
+
return i.Login;
|
|
123
123
|
case u.SSO_SILENT_START:
|
|
124
|
-
return
|
|
124
|
+
return i.SsoSilent;
|
|
125
125
|
case u.ACQUIRE_TOKEN_START:
|
|
126
|
-
if (
|
|
127
|
-
return
|
|
126
|
+
if (t.interactionType === N.Redirect || t.interactionType === N.Popup)
|
|
127
|
+
return i.AcquireToken;
|
|
128
128
|
break;
|
|
129
129
|
case u.HANDLE_REDIRECT_START:
|
|
130
|
-
return
|
|
130
|
+
return i.HandleRedirect;
|
|
131
131
|
case u.LOGOUT_START:
|
|
132
|
-
return
|
|
132
|
+
return i.Logout;
|
|
133
133
|
case u.SSO_SILENT_SUCCESS:
|
|
134
134
|
case u.SSO_SILENT_FAILURE:
|
|
135
|
-
if (n && n !==
|
|
135
|
+
if (n && n !== i.SsoSilent)
|
|
136
136
|
break;
|
|
137
|
-
return
|
|
137
|
+
return i.None;
|
|
138
138
|
case u.LOGOUT_END:
|
|
139
|
-
if (n && n !==
|
|
139
|
+
if (n && n !== i.Logout)
|
|
140
140
|
break;
|
|
141
|
-
return
|
|
141
|
+
return i.None;
|
|
142
142
|
case u.HANDLE_REDIRECT_END:
|
|
143
|
-
if (n && n !==
|
|
143
|
+
if (n && n !== i.HandleRedirect)
|
|
144
144
|
break;
|
|
145
|
-
return
|
|
145
|
+
return i.None;
|
|
146
146
|
case u.LOGIN_SUCCESS:
|
|
147
147
|
case u.LOGIN_FAILURE:
|
|
148
148
|
case u.ACQUIRE_TOKEN_SUCCESS:
|
|
149
149
|
case u.ACQUIRE_TOKEN_FAILURE:
|
|
150
150
|
case u.RESTORE_FROM_BFCACHE:
|
|
151
|
-
if (
|
|
152
|
-
if (n && n !==
|
|
151
|
+
if (t.interactionType === N.Redirect || t.interactionType === N.Popup) {
|
|
152
|
+
if (n && n !== i.Login && n !== i.AcquireToken)
|
|
153
153
|
break;
|
|
154
|
-
return
|
|
154
|
+
return i.None;
|
|
155
155
|
}
|
|
156
156
|
break;
|
|
157
157
|
}
|
|
@@ -164,48 +164,48 @@ const Y = "@azure/msal-react", A = "2.0.16";
|
|
|
164
164
|
const p = {
|
|
165
165
|
UNBLOCK_INPROGRESS: "UNBLOCK_INPROGRESS",
|
|
166
166
|
EVENT: "EVENT"
|
|
167
|
-
}, Z = (e,
|
|
168
|
-
const { type: n, payload: o } =
|
|
169
|
-
let
|
|
167
|
+
}, Z = (e, t) => {
|
|
168
|
+
const { type: n, payload: o } = t;
|
|
169
|
+
let s = e.inProgress;
|
|
170
170
|
switch (n) {
|
|
171
171
|
case p.UNBLOCK_INPROGRESS:
|
|
172
|
-
e.inProgress ===
|
|
172
|
+
e.inProgress === i.Startup && (s = i.None, o.logger.info("MsalProvider - handleRedirectPromise resolved, setting inProgress to 'none'"));
|
|
173
173
|
break;
|
|
174
174
|
case p.EVENT:
|
|
175
|
-
const c = o.message,
|
|
176
|
-
|
|
175
|
+
const c = o.message, l = X.getInteractionStatusFromEvent(c, e.inProgress);
|
|
176
|
+
l && (o.logger.info(`MsalProvider - ${c.eventType} results in setting inProgress from ${e.inProgress} to ${l}`), s = l);
|
|
177
177
|
break;
|
|
178
178
|
default:
|
|
179
179
|
throw new Error(`Unknown action type: ${n}`);
|
|
180
180
|
}
|
|
181
181
|
const r = o.instance.getAllAccounts();
|
|
182
|
-
return
|
|
182
|
+
return s !== e.inProgress && !j(r, e.accounts) ? {
|
|
183
183
|
...e,
|
|
184
|
-
inProgress:
|
|
184
|
+
inProgress: s,
|
|
185
185
|
accounts: r
|
|
186
|
-
} :
|
|
186
|
+
} : s !== e.inProgress ? {
|
|
187
187
|
...e,
|
|
188
|
-
inProgress:
|
|
188
|
+
inProgress: s
|
|
189
189
|
} : j(r, e.accounts) ? e : {
|
|
190
190
|
...e,
|
|
191
191
|
accounts: r
|
|
192
192
|
};
|
|
193
193
|
};
|
|
194
|
-
function ee({ instance: e, children:
|
|
194
|
+
function ee({ instance: e, children: t }) {
|
|
195
195
|
I(() => {
|
|
196
196
|
e.initializeWrapperLibrary(w.React, A);
|
|
197
197
|
}, [e]);
|
|
198
|
-
const n = v(() => e.getLogger().clone(Y, A), [e]), [o,
|
|
199
|
-
inProgress:
|
|
198
|
+
const n = v(() => e.getLogger().clone(Y, A), [e]), [o, s] = B(Z, void 0, () => ({
|
|
199
|
+
inProgress: i.Startup,
|
|
200
200
|
accounts: e.getAllAccounts()
|
|
201
201
|
}));
|
|
202
202
|
I(() => {
|
|
203
|
-
const c = e.addEventCallback((
|
|
204
|
-
|
|
203
|
+
const c = e.addEventCallback((l) => {
|
|
204
|
+
s({
|
|
205
205
|
payload: {
|
|
206
206
|
instance: e,
|
|
207
207
|
logger: n,
|
|
208
|
-
message:
|
|
208
|
+
message: l
|
|
209
209
|
},
|
|
210
210
|
type: p.EVENT
|
|
211
211
|
});
|
|
@@ -213,7 +213,7 @@ function ee({ instance: e, children: s }) {
|
|
|
213
213
|
return n.verbose(`MsalProvider - Registered event callback with id: ${c}`), e.initialize().then(() => {
|
|
214
214
|
e.handleRedirectPromise().catch(() => {
|
|
215
215
|
}).finally(() => {
|
|
216
|
-
|
|
216
|
+
s({
|
|
217
217
|
payload: {
|
|
218
218
|
instance: e,
|
|
219
219
|
logger: n
|
|
@@ -232,91 +232,91 @@ function ee({ instance: e, children: s }) {
|
|
|
232
232
|
accounts: o.accounts,
|
|
233
233
|
logger: n
|
|
234
234
|
};
|
|
235
|
-
return H.createElement(M.Provider, { value: r },
|
|
235
|
+
return H.createElement(M.Provider, { value: r }, t);
|
|
236
236
|
}
|
|
237
237
|
const ue = ({ children: e }) => {
|
|
238
|
-
const
|
|
239
|
-
const
|
|
240
|
-
return
|
|
241
|
-
}, []), [c,
|
|
242
|
-
let
|
|
243
|
-
return await
|
|
244
|
-
|
|
238
|
+
const t = F(), { msalInstance: n } = R(O), [o, s] = h(!1), r = E(() => {
|
|
239
|
+
const d = localStorage.getItem("user") ?? null;
|
|
240
|
+
return console.log("getting user from storage", d ? JSON.parse(d) : null), d ? JSON.parse(d ?? "") : null;
|
|
241
|
+
}, []), [c, l] = h(r()), m = E(async (d) => {
|
|
242
|
+
let g = null;
|
|
243
|
+
return await t.get("/user/detail", d ? { headers: { Authorization: `Bearer ${d}` } } : void 0).then((S) => {
|
|
244
|
+
g = S.data, console.log("user login response", g);
|
|
245
245
|
}).catch(() => {
|
|
246
|
-
|
|
247
|
-
}), localStorage.setItem("user", JSON.stringify(
|
|
248
|
-
}, [
|
|
246
|
+
g = null, console.log("user login failed");
|
|
247
|
+
}), localStorage.setItem("user", JSON.stringify(g)), g;
|
|
248
|
+
}, [t]), f = E(() => {
|
|
249
249
|
localStorage.removeItem("user");
|
|
250
|
-
}, []),
|
|
251
|
-
|
|
252
|
-
const
|
|
253
|
-
return
|
|
254
|
-
}, [
|
|
255
|
-
|
|
256
|
-
}, [
|
|
250
|
+
}, []), x = E(async (d) => {
|
|
251
|
+
s(!0);
|
|
252
|
+
const g = await m(d);
|
|
253
|
+
return s(!1), g ? (console.log("setting user", g), l(g), !0) : !1;
|
|
254
|
+
}, [m]), C = E(() => {
|
|
255
|
+
f(), l(null);
|
|
256
|
+
}, [f]), y = v(() => ({ user: c, loggingInProgress: o, loginUser: x, logoutUser: C }), [c, x, C, o]);
|
|
257
257
|
return I(() => {
|
|
258
|
-
|
|
258
|
+
l(r());
|
|
259
259
|
}, [r]), I(() => {
|
|
260
260
|
if (n) {
|
|
261
|
-
const
|
|
262
|
-
if (
|
|
263
|
-
const S =
|
|
264
|
-
|
|
261
|
+
const d = n.addEventCallback((g) => {
|
|
262
|
+
if (g.eventType === u.LOGIN_SUCCESS && g.payload) {
|
|
263
|
+
const S = g.payload;
|
|
264
|
+
x(S.accessToken).catch(() => C());
|
|
265
265
|
}
|
|
266
266
|
});
|
|
267
267
|
return () => {
|
|
268
|
-
|
|
268
|
+
d && n.removeEventCallback(d);
|
|
269
269
|
};
|
|
270
270
|
}
|
|
271
271
|
return () => {
|
|
272
272
|
};
|
|
273
|
-
}, [n,
|
|
273
|
+
}, [n, x, C]), /* @__PURE__ */ a.jsx(G.Provider, { value: y, children: e });
|
|
274
274
|
}, de = ({ ...e }) => {
|
|
275
|
-
const { cookieDomain:
|
|
275
|
+
const { cookieDomain: t } = R(L), [, n] = z(["Authorization"]), o = v(() => ({
|
|
276
276
|
useMsal: e.useMsal ?? !1,
|
|
277
277
|
msalInstance: e.useMsal ? e.msalInstance ?? null : null,
|
|
278
278
|
msalScopes: e.useMsal ? e.msalScopes ?? [] : []
|
|
279
279
|
}), [e]);
|
|
280
280
|
return I(() => {
|
|
281
281
|
if (e.useMsal) {
|
|
282
|
-
const
|
|
282
|
+
const s = e.msalInstance.addEventCallback((r) => {
|
|
283
283
|
if (r.eventType === u.LOGIN_SUCCESS || r.eventType === u.ACQUIRE_TOKEN_SUCCESS && r.payload) {
|
|
284
|
-
const c = r.payload,
|
|
285
|
-
e.msalInstance.setActiveAccount(
|
|
286
|
-
const
|
|
287
|
-
n("Authorization",
|
|
284
|
+
const c = r.payload, l = c.account;
|
|
285
|
+
e.msalInstance.setActiveAccount(l);
|
|
286
|
+
const m = c.accessToken, f = c.expiresOn;
|
|
287
|
+
n("Authorization", m, {
|
|
288
288
|
path: "/",
|
|
289
289
|
secure: !0,
|
|
290
290
|
sameSite: "none",
|
|
291
|
-
domain:
|
|
292
|
-
expires:
|
|
291
|
+
domain: t,
|
|
292
|
+
expires: f ?? void 0
|
|
293
293
|
});
|
|
294
294
|
}
|
|
295
295
|
});
|
|
296
296
|
return () => {
|
|
297
|
-
|
|
297
|
+
s && e.msalInstance.removeEventCallback(s);
|
|
298
298
|
};
|
|
299
299
|
}
|
|
300
300
|
return () => {
|
|
301
301
|
};
|
|
302
|
-
}, [e, n,
|
|
302
|
+
}, [e, n, t]), /* @__PURE__ */ a.jsx(O.Provider, { value: o, children: e.useMsal ? /* @__PURE__ */ a.jsx(ee, { instance: e.msalInstance, children: e.children }) : e.children });
|
|
303
303
|
}, ne = () => {
|
|
304
|
-
const { confirmTexts: e } = R(L), { onConfirm:
|
|
305
|
-
return /* @__PURE__ */ a.jsxs(P, { show:
|
|
304
|
+
const { confirmTexts: e } = R(L), { onConfirm: t, onCancel: n, text: o, show: s } = q();
|
|
305
|
+
return /* @__PURE__ */ a.jsxs(P, { show: s, size: "sm", centered: !0, onHide: n, children: [
|
|
306
306
|
/* @__PURE__ */ a.jsx(P.Header, { className: "justify-content-center", children: /* @__PURE__ */ a.jsx(P.Title, { children: o }) }),
|
|
307
307
|
/* @__PURE__ */ a.jsx(P.Body, { children: /* @__PURE__ */ a.jsxs("div", { className: "w-100 d-flex gap-5", children: [
|
|
308
308
|
/* @__PURE__ */ a.jsx(T, { type: "button", variant: "outlined", color: "secondary", className: "w-100", onClick: n, children: e.no }),
|
|
309
|
-
/* @__PURE__ */ a.jsx(T, { type: "button", color: "primary", onClick:
|
|
309
|
+
/* @__PURE__ */ a.jsx(T, { type: "button", color: "primary", onClick: t, className: "w-100 ml", children: e.yes })
|
|
310
310
|
] }) })
|
|
311
311
|
] });
|
|
312
312
|
};
|
|
313
313
|
export {
|
|
314
|
-
|
|
314
|
+
O as AuthContext,
|
|
315
315
|
de as AuthProvider,
|
|
316
316
|
b as LoadingContext,
|
|
317
|
-
|
|
317
|
+
ie as LoadingProvider,
|
|
318
318
|
L as LuminusComponentsContext,
|
|
319
|
-
|
|
319
|
+
le as LuminusComponentsProvider,
|
|
320
320
|
G as UserContext,
|
|
321
321
|
ue as UserProvider
|
|
322
322
|
};
|