@elliemae/pui-app-sdk 5.9.0 → 5.10.1
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/cjs/communication/http-client/index.js +3 -6
- package/dist/cjs/communication/http-client/response-interceptor.js +1 -2
- package/dist/cjs/data/appMiddleware.js +1 -2
- package/dist/cjs/data/queryMiddleware.js +1 -2
- package/dist/cjs/index.js +3 -0
- package/dist/cjs/sideeffect/error-toast/index.js +1 -2
- package/dist/cjs/sideeffect/wait-message/index.js +2 -4
- package/dist/cjs/utils/app-config/index.js +1 -2
- package/dist/cjs/utils/custom-hooks/use-state-selector.js +47 -0
- package/dist/cjs/utils/micro-frontend/console-logger.js +1 -2
- package/dist/cjs/utils/micro-frontend/guest.js +5 -10
- package/dist/cjs/utils/micro-frontend/host.js +7 -14
- package/dist/cjs/utils/micro-frontend/index.js +4 -8
- package/dist/cjs/utils/micro-frontend/ssfguest-adapter.js +1 -2
- package/dist/cjs/utils/session.js +2 -3
- package/dist/cjs/utils/window.js +3 -6
- package/dist/cjs/view/error-toast/index.js +1 -2
- package/dist/cjs/view/fields/autocomplete/index.js +2 -4
- package/dist/cjs/view/fields/input-mask/index.js +2 -4
- package/dist/cjs/view/form/index.js +1 -2
- package/dist/cjs/view/login/index.js +2 -4
- package/dist/cjs/view/micro-app/app-factory/index.js +8 -16
- package/dist/cjs/view/micro-app/resources/manifest.js +1 -2
- package/dist/cjs/view/micro-app/resources/script.js +6 -12
- package/dist/cjs/view/micro-app/resources/style.js +3 -6
- package/dist/cjs/view/micro-app/use-app-will-render.js +6 -11
- package/dist/cjs/view/micro-app/utils.js +2 -4
- package/dist/cjs/view/micro-iframe-app/use-frame-loaded.js +2 -3
- package/dist/cjs/view/session-timeout/index.js +1 -2
- package/dist/cjs/view/wait-message/use-html-wait-message.js +1 -2
- package/dist/esm/communication/http-client/index.js +3 -6
- package/dist/esm/communication/http-client/response-interceptor.js +1 -2
- package/dist/esm/data/appMiddleware.js +1 -2
- package/dist/esm/data/queryMiddleware.js +1 -2
- package/dist/esm/index.js +6 -0
- package/dist/esm/sideeffect/error-toast/index.js +1 -2
- package/dist/esm/sideeffect/wait-message/index.js +2 -4
- package/dist/esm/utils/app-config/index.js +1 -2
- package/dist/esm/utils/custom-hooks/use-state-selector.js +27 -0
- package/dist/esm/utils/micro-frontend/console-logger.js +1 -2
- package/dist/esm/utils/micro-frontend/guest.js +5 -10
- package/dist/esm/utils/micro-frontend/host.js +7 -14
- package/dist/esm/utils/micro-frontend/index.js +4 -8
- package/dist/esm/utils/micro-frontend/ssfguest-adapter.js +1 -2
- package/dist/esm/utils/session.js +2 -3
- package/dist/esm/utils/window.js +3 -6
- package/dist/esm/view/error-toast/index.js +1 -2
- package/dist/esm/view/fields/autocomplete/index.js +2 -4
- package/dist/esm/view/fields/input-mask/index.js +2 -4
- package/dist/esm/view/form/index.js +1 -2
- package/dist/esm/view/login/index.js +2 -4
- package/dist/esm/view/micro-app/app-factory/index.js +8 -16
- package/dist/esm/view/micro-app/resources/manifest.js +1 -2
- package/dist/esm/view/micro-app/resources/script.js +6 -12
- package/dist/esm/view/micro-app/resources/style.js +3 -6
- package/dist/esm/view/micro-app/use-app-will-render.js +6 -11
- package/dist/esm/view/micro-app/utils.js +2 -4
- package/dist/esm/view/micro-iframe-app/use-frame-loaded.js +2 -3
- package/dist/esm/view/session-timeout/index.js +1 -2
- package/dist/esm/view/wait-message/use-html-wait-message.js +1 -2
- package/dist/types/lib/api/helpers.d.ts +1 -1
- package/dist/types/lib/index.d.ts +3 -0
- package/dist/types/lib/utils/custom-hooks/use-state-selector.d.ts +40 -0
- package/dist/types/lib/view/fields/toggle/index.stories.d.ts +1 -1
- package/package.json +32 -32
|
@@ -25,7 +25,6 @@ var import_react = require("react");
|
|
|
25
25
|
const useHTMLWaitMessage = (close) => {
|
|
26
26
|
(0, import_react.useEffect)(() => {
|
|
27
27
|
const htmlWaitMsgElement = document.getElementById("em-wait-message");
|
|
28
|
-
if (htmlWaitMsgElement && close)
|
|
29
|
-
htmlWaitMsgElement.remove();
|
|
28
|
+
if (htmlWaitMsgElement && close) htmlWaitMsgElement.remove();
|
|
30
29
|
}, [close]);
|
|
31
30
|
};
|
|
@@ -13,14 +13,11 @@ const getHTTPClient = ({
|
|
|
13
13
|
baseURL,
|
|
14
14
|
headers
|
|
15
15
|
});
|
|
16
|
-
if (client?.defaults?.timeout)
|
|
17
|
-
client.defaults.timeout = REQUEST_TIMEOUT;
|
|
16
|
+
if (client?.defaults?.timeout) client.defaults.timeout = REQUEST_TIMEOUT;
|
|
18
17
|
setupRetry(client);
|
|
19
18
|
const { request, response } = client?.interceptors || {};
|
|
20
|
-
if (request)
|
|
21
|
-
|
|
22
|
-
if (response)
|
|
23
|
-
response.use(handleSuccess, handleFailure);
|
|
19
|
+
if (request) request.use(requestInterceptor);
|
|
20
|
+
if (response) response.use(handleSuccess, handleFailure);
|
|
24
21
|
return client;
|
|
25
22
|
};
|
|
26
23
|
const getAuthHTTPClient = ({
|
|
@@ -10,8 +10,7 @@ const handleFailure = (error) => {
|
|
|
10
10
|
if (status === HTTP_UNAUTHORIZED && unAuthorizedFailureHandler && typeof unAuthorizedFailureHandler === "function") {
|
|
11
11
|
return unAuthorizedFailureHandler(error).then((authorizationHeader) => {
|
|
12
12
|
const { config } = error;
|
|
13
|
-
if (!config?.headers)
|
|
14
|
-
throw error;
|
|
13
|
+
if (!config?.headers) throw error;
|
|
15
14
|
config.headers["Authorization"] = authorizationHeader;
|
|
16
15
|
return new Promise((resolve, reject) => {
|
|
17
16
|
axios.request(config).then(resolve).catch(reject);
|
|
@@ -13,8 +13,7 @@ const addMiddleware = ({
|
|
|
13
13
|
key,
|
|
14
14
|
middleware
|
|
15
15
|
}) => {
|
|
16
|
-
if (middlewareDispatchFns.has(key) || !store)
|
|
17
|
-
return;
|
|
16
|
+
if (middlewareDispatchFns.has(key) || !store) return;
|
|
18
17
|
middlewareDispatchFns.set(key, middleware(store));
|
|
19
18
|
};
|
|
20
19
|
const removeMiddleware = (key) => {
|
|
@@ -12,8 +12,7 @@ const addMiddleware = ({
|
|
|
12
12
|
reducerPath,
|
|
13
13
|
middleware
|
|
14
14
|
}) => {
|
|
15
|
-
if (middlewareDispatchFns.has(reducerPath) || !store)
|
|
16
|
-
return;
|
|
15
|
+
if (middlewareDispatchFns.has(reducerPath) || !store) return;
|
|
17
16
|
middlewareDispatchFns.set(reducerPath, middleware(store));
|
|
18
17
|
};
|
|
19
18
|
const removeMiddleware = (reducerPath) => {
|
package/dist/esm/index.js
CHANGED
|
@@ -23,6 +23,10 @@ import {
|
|
|
23
23
|
useAppSelector,
|
|
24
24
|
useAppMiddleware
|
|
25
25
|
} from "./data/react.js";
|
|
26
|
+
import {
|
|
27
|
+
useStateSelector,
|
|
28
|
+
useStateSelectorShallow
|
|
29
|
+
} from "./utils/custom-hooks/use-state-selector.js";
|
|
26
30
|
import { errorMiddleware } from "./data/errorMiddleware.js";
|
|
27
31
|
import {
|
|
28
32
|
startSideEffect,
|
|
@@ -240,6 +244,8 @@ export {
|
|
|
240
244
|
useInjectSaga,
|
|
241
245
|
useInjectSideEffect,
|
|
242
246
|
useMediaQueryList,
|
|
247
|
+
useStateSelector,
|
|
248
|
+
useStateSelectorShallow,
|
|
243
249
|
waitMessage as waitMessageAction,
|
|
244
250
|
withAppDecorator
|
|
245
251
|
};
|
|
@@ -10,8 +10,7 @@ function* openErrorToast(action) {
|
|
|
10
10
|
);
|
|
11
11
|
const host = yield call(microApp.getHost.bind(microApp));
|
|
12
12
|
const message = action?.payload?.description || action?.payload?.messageText;
|
|
13
|
-
if (host && message)
|
|
14
|
-
yield call(host.openErrorBanner.bind(host), message);
|
|
13
|
+
if (host && message) yield call(host.openErrorBanner.bind(host), message);
|
|
15
14
|
} catch (ex) {
|
|
16
15
|
getLogger().error({
|
|
17
16
|
...logRecords.ERR_TOAST_OPEN_FAILED,
|
|
@@ -9,8 +9,7 @@ function* openWaitMessage() {
|
|
|
9
9
|
CMicroAppGuest.getInstance.bind(CMicroAppGuest)
|
|
10
10
|
);
|
|
11
11
|
const host = yield call(microApp.getHost.bind(microApp));
|
|
12
|
-
if (host)
|
|
13
|
-
yield call(host.openWaitMessage.bind(host));
|
|
12
|
+
if (host) yield call(host.openWaitMessage.bind(host));
|
|
14
13
|
} catch (ex) {
|
|
15
14
|
getLogger().error({
|
|
16
15
|
...logRecords.WAIT_MSG_OPEN_FAILED,
|
|
@@ -24,8 +23,7 @@ function* closeWaitMessage() {
|
|
|
24
23
|
CMicroAppGuest.getInstance.bind(CMicroAppGuest)
|
|
25
24
|
);
|
|
26
25
|
const host = yield call(microApp.getHost.bind(microApp));
|
|
27
|
-
if (host)
|
|
28
|
-
yield call(host.closeWaitMessage.bind(host));
|
|
26
|
+
if (host) yield call(host.closeWaitMessage.bind(host));
|
|
29
27
|
} catch (ex) {
|
|
30
28
|
getLogger().error({
|
|
31
29
|
...logRecords.WAIT_MSG_CLOSE_FAILED,
|
|
@@ -7,8 +7,7 @@ import { getAppConfigValue } from "./config.js";
|
|
|
7
7
|
const parseAppConfig = (data) => {
|
|
8
8
|
const { activeEnv } = data;
|
|
9
9
|
const activeEnvConfig = data.env[activeEnv] || {};
|
|
10
|
-
if (data.env)
|
|
11
|
-
delete data.env;
|
|
10
|
+
if (data.env) delete data.env;
|
|
12
11
|
setAppConfig(_.merge(data, activeEnvConfig));
|
|
13
12
|
sessionStorage.setItem("envName", activeEnv);
|
|
14
13
|
setAppDynamicsUserData({ envName: activeEnv });
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { useSelector, shallowEqual } from "react-redux";
|
|
3
|
+
function useStateSelector(selectStateFieldFunc, fieldName = "", {
|
|
4
|
+
defaultValue = void 0,
|
|
5
|
+
equalityFn = void 0
|
|
6
|
+
} = {}) {
|
|
7
|
+
const [finalDefaultValue] = useState(
|
|
8
|
+
defaultValue
|
|
9
|
+
);
|
|
10
|
+
return useSelector(
|
|
11
|
+
selectStateFieldFunc(fieldName, finalDefaultValue),
|
|
12
|
+
equalityFn
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
function useStateSelectorShallow(selectStateFieldFunc, fieldName = "", {
|
|
16
|
+
defaultValue = void 0,
|
|
17
|
+
equalityFn = shallowEqual
|
|
18
|
+
} = {}) {
|
|
19
|
+
return useStateSelector(selectStateFieldFunc, fieldName, {
|
|
20
|
+
defaultValue,
|
|
21
|
+
equalityFn
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
useStateSelector,
|
|
26
|
+
useStateSelectorShallow
|
|
27
|
+
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { logger as uiLogger, Console } from "@elliemae/pui-diagnostics";
|
|
2
2
|
import { getAppConfigValue } from "../app-config/config.js";
|
|
3
3
|
const logger = (() => {
|
|
4
|
-
if (!uiLogger)
|
|
5
|
-
return console;
|
|
4
|
+
if (!uiLogger) return console;
|
|
6
5
|
return uiLogger({
|
|
7
6
|
transport: Console(),
|
|
8
7
|
index: "app",
|
|
@@ -92,8 +92,7 @@ class CMicroAppGuest {
|
|
|
92
92
|
}
|
|
93
93
|
if (!host) {
|
|
94
94
|
const ssfAdapter = new SSFGuestAdapter();
|
|
95
|
-
if (!await ssfAdapter.init())
|
|
96
|
-
return null;
|
|
95
|
+
if (!await ssfAdapter.init()) return null;
|
|
97
96
|
host = ssfAdapter;
|
|
98
97
|
}
|
|
99
98
|
}
|
|
@@ -104,8 +103,7 @@ class CMicroAppGuest {
|
|
|
104
103
|
this.props.history = options?.history || this.props.history;
|
|
105
104
|
if (!this.props.host) {
|
|
106
105
|
const host = await this.getSSFAdapter();
|
|
107
|
-
if (host)
|
|
108
|
-
this.props.host = host;
|
|
106
|
+
if (host) this.props.host = host;
|
|
109
107
|
}
|
|
110
108
|
__webpack_public_path__ = __webpack_public_path__.replace(/\/?$/, "/");
|
|
111
109
|
return loadAppConfig().then(() => {
|
|
@@ -113,15 +111,13 @@ class CMicroAppGuest {
|
|
|
113
111
|
const userId = this.getSessionStorageItem("userId") || "";
|
|
114
112
|
updateBAEventParameters({ appId: this.appId, instanceId, userId });
|
|
115
113
|
setAppDynamicsUserData({ appId: this.appId, instanceId, userId });
|
|
116
|
-
if (this.onInit)
|
|
117
|
-
this.onInit(this.props);
|
|
114
|
+
if (this.onInit) this.onInit(this.props);
|
|
118
115
|
});
|
|
119
116
|
}
|
|
120
117
|
mount(options = { containerId: "app-container" }) {
|
|
121
118
|
this.containerId = options?.containerId;
|
|
122
119
|
return Promise.resolve().then(() => {
|
|
123
|
-
if (this.onMount)
|
|
124
|
-
this.onMount(options);
|
|
120
|
+
if (this.onMount) this.onMount(options);
|
|
125
121
|
});
|
|
126
122
|
}
|
|
127
123
|
unmount(options) {
|
|
@@ -134,8 +130,7 @@ class CMicroAppGuest {
|
|
|
134
130
|
return this.onGetRef ? this.onGetRef() : null;
|
|
135
131
|
}
|
|
136
132
|
navigate(url, state) {
|
|
137
|
-
if (url)
|
|
138
|
-
this.props.history.push(url, state);
|
|
133
|
+
if (url) this.props.history.push(url, state);
|
|
139
134
|
}
|
|
140
135
|
}
|
|
141
136
|
export {
|
|
@@ -50,8 +50,7 @@ class CMicroAppHost {
|
|
|
50
50
|
this.renewSessionTimer = this.renewSessionTimer.bind(this);
|
|
51
51
|
this.setSystemVersion = this.setSystemVersion.bind(this);
|
|
52
52
|
loadAppConfig().then(() => {
|
|
53
|
-
if (this.onInit)
|
|
54
|
-
this.onInit(this.props);
|
|
53
|
+
if (this.onInit) this.onInit(this.props);
|
|
55
54
|
}).catch(() => {
|
|
56
55
|
});
|
|
57
56
|
updateBAEventParameters({ appId: this.appId });
|
|
@@ -97,23 +96,19 @@ class CMicroAppHost {
|
|
|
97
96
|
unsubscribe(token);
|
|
98
97
|
}
|
|
99
98
|
navigate(url, state) {
|
|
100
|
-
if (url)
|
|
101
|
-
this.props.history.push(url, state);
|
|
99
|
+
if (url) this.props.history.push(url, state);
|
|
102
100
|
}
|
|
103
101
|
openWaitMessage() {
|
|
104
102
|
const store = getStore();
|
|
105
|
-
if (store)
|
|
106
|
-
store.dispatch(waitMessage.open());
|
|
103
|
+
if (store) store.dispatch(waitMessage.open());
|
|
107
104
|
}
|
|
108
105
|
closeWaitMessage() {
|
|
109
106
|
const store = getStore();
|
|
110
|
-
if (store)
|
|
111
|
-
store.dispatch(waitMessage.close());
|
|
107
|
+
if (store) store.dispatch(waitMessage.close());
|
|
112
108
|
}
|
|
113
109
|
openErrorBanner(message) {
|
|
114
110
|
const store = getStore();
|
|
115
|
-
if (store)
|
|
116
|
-
store.dispatch(error.set({ description: message }));
|
|
111
|
+
if (store) store.dispatch(error.set({ description: message }));
|
|
117
112
|
}
|
|
118
113
|
getAuthToken() {
|
|
119
114
|
return getWindow().sessionStorage.getItem("Authorization");
|
|
@@ -123,13 +118,11 @@ class CMicroAppHost {
|
|
|
123
118
|
}
|
|
124
119
|
logout() {
|
|
125
120
|
const store = getStore();
|
|
126
|
-
if (store)
|
|
127
|
-
store.dispatch(logout.confirm());
|
|
121
|
+
if (store) store.dispatch(logout.confirm());
|
|
128
122
|
}
|
|
129
123
|
renewSessionTimer() {
|
|
130
124
|
resetUserIdleTime();
|
|
131
|
-
if (this.onRenewSessionTimer)
|
|
132
|
-
this.onRenewSessionTimer();
|
|
125
|
+
if (this.onRenewSessionTimer) this.onRenewSessionTimer();
|
|
133
126
|
}
|
|
134
127
|
getBreakpoint() {
|
|
135
128
|
return getCurrentBreakpoint();
|
|
@@ -8,10 +8,8 @@ const isGuest = () => CMicroAppGuest.isInitialized();
|
|
|
8
8
|
const isStandAloneGuest = () => isGuest() && window.top === window.self;
|
|
9
9
|
const getLogger = () => isHost() ? CMicroAppHost.getInstance().getLogger() : CMicroAppGuest.getInstance().getLogger();
|
|
10
10
|
const isProduction = (mode) => {
|
|
11
|
-
if (isCIBuild())
|
|
12
|
-
|
|
13
|
-
if (mode)
|
|
14
|
-
return mode === "production";
|
|
11
|
+
if (isCIBuild()) return true;
|
|
12
|
+
if (mode) return mode === "production";
|
|
15
13
|
return true;
|
|
16
14
|
};
|
|
17
15
|
const getVersionedPath = (path) => {
|
|
@@ -32,10 +30,8 @@ const getMicroFrontEndAppConfig = (appInfo) => {
|
|
|
32
30
|
);
|
|
33
31
|
const { mode = "production" } = microFEAppConfig;
|
|
34
32
|
const envConfig = isProduction(mode) ? microFEAppConfig.production : microFEAppConfig.development;
|
|
35
|
-
if (microFEAppConfig.production)
|
|
36
|
-
|
|
37
|
-
if (microFEAppConfig.development)
|
|
38
|
-
delete microFEAppConfig.development;
|
|
33
|
+
if (microFEAppConfig.production) delete microFEAppConfig.production;
|
|
34
|
+
if (microFEAppConfig.development) delete microFEAppConfig.development;
|
|
39
35
|
const microFEConfig = _.merge(
|
|
40
36
|
appInfo,
|
|
41
37
|
{
|
|
@@ -87,9 +87,8 @@ const subscribeToResetSession = (onResetListener) => {
|
|
|
87
87
|
return removeListeners.bind(null, resetListeners, onResetListener);
|
|
88
88
|
};
|
|
89
89
|
const trackActivity = (element, cb) => {
|
|
90
|
-
if (!element)
|
|
91
|
-
|
|
92
|
-
};
|
|
90
|
+
if (!element) return () => {
|
|
91
|
+
};
|
|
93
92
|
const thorttledCb = throttle(cb, THROTTLING_TIME, { leading: true });
|
|
94
93
|
userInteractionEvents.forEach(
|
|
95
94
|
(r) => element.addEventListener(r, thorttledCb)
|
package/dist/esm/utils/window.js
CHANGED
|
@@ -21,16 +21,13 @@ const convertBreakpointToNumber = (breakpoint) => Number(breakpoint.replace("px"
|
|
|
21
21
|
const getCurrentBreakpoint = () => {
|
|
22
22
|
const { width } = getViewportSize();
|
|
23
23
|
const { breakpoints } = getDefaultTheme();
|
|
24
|
-
if (width <= convertBreakpointToNumber(breakpoints.small))
|
|
25
|
-
|
|
26
|
-
if (width <= convertBreakpointToNumber(breakpoints.medium))
|
|
27
|
-
return "medium";
|
|
24
|
+
if (width <= convertBreakpointToNumber(breakpoints.small)) return "small";
|
|
25
|
+
if (width <= convertBreakpointToNumber(breakpoints.medium)) return "medium";
|
|
28
26
|
return "large";
|
|
29
27
|
};
|
|
30
28
|
const getAssetPath = () => {
|
|
31
29
|
const assetPath = window?.emui?._ASSET_PATH || "latest/";
|
|
32
|
-
if (!window.emui?.version)
|
|
33
|
-
return assetPath;
|
|
30
|
+
if (!window.emui?.version) return assetPath;
|
|
34
31
|
const majorMinorVersion = window.emui?.version.match(/^(?:\d+\.\d+)*/g);
|
|
35
32
|
return majorMinorVersion && majorMinorVersion[0] ? assetPath.replace("latest/", `${majorMinorVersion[0]}/`) : assetPath;
|
|
36
33
|
};
|
|
@@ -16,8 +16,7 @@ const ErrorToast = memo((props) => {
|
|
|
16
16
|
...storeError
|
|
17
17
|
};
|
|
18
18
|
const messageText = toastProps.description || toastProps.messageText;
|
|
19
|
-
if (messageText)
|
|
20
|
-
toast({ messageText, ...toastProps }, {});
|
|
19
|
+
if (messageText) toast({ messageText, ...toastProps }, {});
|
|
21
20
|
dispatch(error.clear());
|
|
22
21
|
}
|
|
23
22
|
}, [storeError, props, dispatch]);
|
|
@@ -3,8 +3,7 @@ import { useCallback } from "react";
|
|
|
3
3
|
import { DSAutocomplete } from "@elliemae/ds-controlled-form";
|
|
4
4
|
import { useFormContext } from "react-hook-form";
|
|
5
5
|
const filterOptions = (allOptions, newFilter) => {
|
|
6
|
-
if (!newFilter)
|
|
7
|
-
return allOptions;
|
|
6
|
+
if (!newFilter) return allOptions;
|
|
8
7
|
const filtered = allOptions.filter(
|
|
9
8
|
(option) => option.type === "section" || option.label.toLowerCase().includes(newFilter?.toLowerCase())
|
|
10
9
|
);
|
|
@@ -15,8 +14,7 @@ const Autocomplete = ({ children, ...rest }) => {
|
|
|
15
14
|
const watchedFilter = watch(rest.name);
|
|
16
15
|
const onSelect = useCallback(
|
|
17
16
|
(newValue, ...otherArgs) => {
|
|
18
|
-
if (rest.onSelect)
|
|
19
|
-
rest.onSelect(newValue, ...otherArgs);
|
|
17
|
+
if (rest.onSelect) rest.onSelect(newValue, ...otherArgs);
|
|
20
18
|
else
|
|
21
19
|
setValue(rest.name, newValue, {
|
|
22
20
|
shouldValidate: true,
|
|
@@ -23,13 +23,11 @@ const InputMask = ({
|
|
|
23
23
|
...props,
|
|
24
24
|
onChange: (e) => {
|
|
25
25
|
onChange(e);
|
|
26
|
-
if (changeHandler)
|
|
27
|
-
changeHandler(e);
|
|
26
|
+
if (changeHandler) changeHandler(e);
|
|
28
27
|
},
|
|
29
28
|
onBlur: (e) => {
|
|
30
29
|
onBlur();
|
|
31
|
-
if (onBlurHandler)
|
|
32
|
-
onBlurHandler(e);
|
|
30
|
+
if (onBlurHandler) onBlurHandler(e);
|
|
33
31
|
}
|
|
34
32
|
}
|
|
35
33
|
)
|
|
@@ -16,8 +16,7 @@ const Form = ({
|
|
|
16
16
|
}) => {
|
|
17
17
|
const methods = useForm(reactHookFormProps);
|
|
18
18
|
const formProps = {};
|
|
19
|
-
if (onSubmit)
|
|
20
|
-
formProps.onSubmit = methods.handleSubmit(onSubmit);
|
|
19
|
+
if (onSubmit) formProps.onSubmit = methods.handleSubmit(onSubmit);
|
|
21
20
|
const providerProps = Object.assign(methods, {
|
|
22
21
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
23
22
|
formProps: reactHookFormProps
|
|
@@ -13,12 +13,10 @@ const Login = ({
|
|
|
13
13
|
const dispatch = useAppDispatch();
|
|
14
14
|
const ref = useRef(false);
|
|
15
15
|
useEffect(() => {
|
|
16
|
-
if (ref.current)
|
|
17
|
-
return;
|
|
16
|
+
if (ref.current) return;
|
|
18
17
|
ref.current = true;
|
|
19
18
|
login({ clientId, scope, responseType }).then(({ authorized }) => {
|
|
20
|
-
if (authorized)
|
|
21
|
-
setUserAuthorized(true);
|
|
19
|
+
if (authorized) setUserAuthorized(true);
|
|
22
20
|
dispatch({ type: LOGIN_SUCCESS });
|
|
23
21
|
}).catch(() => {
|
|
24
22
|
}).finally(() => {
|
|
@@ -72,11 +72,9 @@ const mountApp = async ({ id, name }) => {
|
|
|
72
72
|
};
|
|
73
73
|
const unmountApp = async ({ id, name }) => {
|
|
74
74
|
const app = (window.emui || {})[id];
|
|
75
|
-
if (!app)
|
|
76
|
-
return null;
|
|
75
|
+
if (!app) return null;
|
|
77
76
|
const { unmount } = app;
|
|
78
|
-
if (!unmount)
|
|
79
|
-
return null;
|
|
77
|
+
if (!unmount) return null;
|
|
80
78
|
if (typeof unmount !== "function")
|
|
81
79
|
throw new Error(
|
|
82
80
|
`unmount failed for application ${name} with id ${id}. unmount is not a valid function`
|
|
@@ -94,8 +92,7 @@ const addAppToActiveAppList = (id, elementIds) => {
|
|
|
94
92
|
const { getRef } = app;
|
|
95
93
|
activeApps[id] = { elementIds };
|
|
96
94
|
const host = CMicroAppHost.getInstance();
|
|
97
|
-
if (host)
|
|
98
|
-
host.activeGuests[id] = getRef && getRef() || {};
|
|
95
|
+
if (host) host.activeGuests[id] = getRef && getRef() || {};
|
|
99
96
|
return Promise.resolve();
|
|
100
97
|
};
|
|
101
98
|
const waitAndInitApplication = (appConfig, requests) => (
|
|
@@ -108,14 +105,12 @@ const waitAndInitApplication = (appConfig, requests) => (
|
|
|
108
105
|
);
|
|
109
106
|
const removeAssetsFromDOM = (id, documentEle = document) => {
|
|
110
107
|
const host = CMicroAppHost.getInstance();
|
|
111
|
-
if (host)
|
|
112
|
-
delete host.activeGuests[id];
|
|
108
|
+
if (host) delete host.activeGuests[id];
|
|
113
109
|
const { elementIds } = activeApps[id] || {};
|
|
114
110
|
if (elementIds) {
|
|
115
111
|
elementIds.forEach((elementId) => {
|
|
116
112
|
const ele = documentEle.getElementById(elementId);
|
|
117
|
-
if (ele)
|
|
118
|
-
ele.remove();
|
|
113
|
+
if (ele) ele.remove();
|
|
119
114
|
});
|
|
120
115
|
delete activeApps[id];
|
|
121
116
|
}
|
|
@@ -138,18 +133,15 @@ const unloadApp = ({
|
|
|
138
133
|
hostUrl,
|
|
139
134
|
documentEle
|
|
140
135
|
}) => {
|
|
141
|
-
if (!hostUrl)
|
|
142
|
-
throw new Error("Unable to unload app. hostUrl is required");
|
|
136
|
+
if (!hostUrl) throw new Error("Unable to unload app. hostUrl is required");
|
|
143
137
|
getLogger().info(logRecords.APP_UNLOADING(id));
|
|
144
138
|
const app = (window.emui || {})[id];
|
|
145
|
-
if (!app)
|
|
146
|
-
return;
|
|
139
|
+
if (!app) return;
|
|
147
140
|
removeAssetsFromDOM(id, documentEle);
|
|
148
141
|
removeDynamicImportedScripts(hostUrl, documentEle);
|
|
149
142
|
removePrefetchLinks(hostUrl, documentEle);
|
|
150
143
|
removeDynamicImportedStyles(hostUrl, documentEle);
|
|
151
|
-
if (window.emui && window.emui[id])
|
|
152
|
-
delete window.emui[id];
|
|
144
|
+
if (window.emui && window.emui[id]) delete window.emui[id];
|
|
153
145
|
getLogger().info(logRecords.APP_UNLOADING_COMPLETE(id));
|
|
154
146
|
};
|
|
155
147
|
export {
|
|
@@ -39,8 +39,7 @@ const getAppManifest = async ({
|
|
|
39
39
|
};
|
|
40
40
|
const getFullFileNameofAssetsFromManifest = (manifest, assetNames = []) => assetNames.reduce((assets, assetName) => {
|
|
41
41
|
const fullFileName = manifest[assetName];
|
|
42
|
-
if (fullFileName)
|
|
43
|
-
assets.push(fullFileName);
|
|
42
|
+
if (fullFileName) assets.push(fullFileName);
|
|
44
43
|
else {
|
|
45
44
|
const logRecord = logRecords.ASSET_NOT_FOUND_IN_MANIFEST(assetName);
|
|
46
45
|
getLogger().error(logRecord);
|
|
@@ -7,24 +7,20 @@ const addScriptToDOM = ({ name, hostUrl, documentEle }, fileName, index) => {
|
|
|
7
7
|
throw new Error("Unable to add scripts to DOM. hostUrl is required.");
|
|
8
8
|
return new Promise((resolve, reject) => {
|
|
9
9
|
const ele = documentEle.createElement("script");
|
|
10
|
-
if (!ele)
|
|
11
|
-
reject(new Error("Unable to insert Application scripts."));
|
|
10
|
+
if (!ele) reject(new Error("Unable to insert Application scripts."));
|
|
12
11
|
ele.id = `${APP_SCRIPT_ID_PREFIX}${name}-${index}`;
|
|
13
12
|
const url = new URL(fileName, hostUrl);
|
|
14
13
|
ele.src = removeDoubleSlash(url.href);
|
|
15
14
|
ele.onload = resolve.bind(null, ele.id);
|
|
16
15
|
ele.onerror = reject.bind(null, ele.id);
|
|
17
16
|
ele.async = false;
|
|
18
|
-
if (isHeadScript(ele.src))
|
|
19
|
-
|
|
20
|
-
else
|
|
21
|
-
documentEle.body.appendChild(ele);
|
|
17
|
+
if (isHeadScript(ele.src)) documentEle.head.appendChild(ele);
|
|
18
|
+
else documentEle.body.appendChild(ele);
|
|
22
19
|
});
|
|
23
20
|
};
|
|
24
21
|
const removeScriptFromDOM = (elementId = "", documentEle = document) => new Promise((resolve) => {
|
|
25
22
|
const ele = documentEle.getElementById(elementId);
|
|
26
|
-
if (!ele)
|
|
27
|
-
console.warn(new Error(`script with id ${elementId} not found`));
|
|
23
|
+
if (!ele) console.warn(new Error(`script with id ${elementId} not found`));
|
|
28
24
|
ele.remove();
|
|
29
25
|
resolve();
|
|
30
26
|
});
|
|
@@ -34,8 +30,7 @@ const removeDynamicImportedScripts = (hostUrl, documentEle) => {
|
|
|
34
30
|
for (let index = scriptElements.length - 1; index >= 0; index -= 1) {
|
|
35
31
|
const scriptEle = scriptElements[index];
|
|
36
32
|
const { src } = scriptEle;
|
|
37
|
-
if (hostPattern.test(src))
|
|
38
|
-
scriptEle.remove();
|
|
33
|
+
if (hostPattern.test(src)) scriptEle.remove();
|
|
39
34
|
}
|
|
40
35
|
};
|
|
41
36
|
const removePrefetchLinks = (hostUrl, documentEle) => {
|
|
@@ -44,8 +39,7 @@ const removePrefetchLinks = (hostUrl, documentEle) => {
|
|
|
44
39
|
for (let index = prefetchElements.length - 1; index >= 0; index -= 1) {
|
|
45
40
|
const ele = prefetchElements[index];
|
|
46
41
|
const { href } = ele;
|
|
47
|
-
if (hostPattern.test(href))
|
|
48
|
-
ele.remove();
|
|
42
|
+
if (hostPattern.test(href)) ele.remove();
|
|
49
43
|
}
|
|
50
44
|
};
|
|
51
45
|
export {
|
|
@@ -5,8 +5,7 @@ const addStylesToDOM = ({ name, hostUrl, documentEle }, fileName, index) => {
|
|
|
5
5
|
throw new Error("Unable to add styles to DOM. hostUrl is required.");
|
|
6
6
|
return new Promise((resolve, reject) => {
|
|
7
7
|
const ele = documentEle.createElement("link");
|
|
8
|
-
if (!ele)
|
|
9
|
-
reject(new Error("Unable to insert Application styles."));
|
|
8
|
+
if (!ele) reject(new Error("Unable to insert Application styles."));
|
|
10
9
|
ele.id = `${APP_STYLE_ID_PREFIX}${name}-${index}`;
|
|
11
10
|
ele.rel = "stylesheet";
|
|
12
11
|
const url = new URL(fileName, hostUrl);
|
|
@@ -17,8 +16,7 @@ const addStylesToDOM = ({ name, hostUrl, documentEle }, fileName, index) => {
|
|
|
17
16
|
};
|
|
18
17
|
const removeStyleFromDOM = (elementId = "", documentEle = document) => new Promise((resolve) => {
|
|
19
18
|
const ele = documentEle.getElementById(elementId);
|
|
20
|
-
if (!ele)
|
|
21
|
-
console.warn(new Error(`style with id ${elementId} not found`));
|
|
19
|
+
if (!ele) console.warn(new Error(`style with id ${elementId} not found`));
|
|
22
20
|
ele.remove();
|
|
23
21
|
resolve();
|
|
24
22
|
});
|
|
@@ -28,8 +26,7 @@ const removeDynamicImportedStyles = (hostUrl, documentEle) => {
|
|
|
28
26
|
for (let index = prefetchElements.length - 1; index >= 0; index -= 1) {
|
|
29
27
|
const ele = prefetchElements[index];
|
|
30
28
|
const { href } = ele;
|
|
31
|
-
if (hostPattern.test(href))
|
|
32
|
-
ele.remove();
|
|
29
|
+
if (hostPattern.test(href)) ele.remove();
|
|
33
30
|
}
|
|
34
31
|
};
|
|
35
32
|
export {
|
|
@@ -33,19 +33,16 @@ const useAppWillRender = ({
|
|
|
33
33
|
async (appConfig, loadFailed = false) => {
|
|
34
34
|
await unmountApp(appConfig);
|
|
35
35
|
unloadApp(appConfig);
|
|
36
|
-
if (!loadFailed && onUnloadComplete)
|
|
37
|
-
onUnloadComplete();
|
|
36
|
+
if (!loadFailed && onUnloadComplete) onUnloadComplete();
|
|
38
37
|
},
|
|
39
38
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
39
|
[]
|
|
41
40
|
);
|
|
42
41
|
const load = useCallback(
|
|
43
42
|
async (appConfig) => {
|
|
44
|
-
if (dispatch)
|
|
45
|
-
dispatch(waitMessage.open());
|
|
43
|
+
if (dispatch) dispatch(waitMessage.open());
|
|
46
44
|
try {
|
|
47
|
-
if (ref.current)
|
|
48
|
-
await ref.current;
|
|
45
|
+
if (ref.current) await ref.current;
|
|
49
46
|
await loadApp(appConfig);
|
|
50
47
|
await mountApp(appConfig);
|
|
51
48
|
} catch (ex) {
|
|
@@ -56,15 +53,13 @@ const useAppWillRender = ({
|
|
|
56
53
|
await unload(appConfig, true);
|
|
57
54
|
throw ex;
|
|
58
55
|
}
|
|
59
|
-
if (dispatch)
|
|
60
|
-
dispatch(waitMessage.close());
|
|
56
|
+
if (dispatch) dispatch(waitMessage.close());
|
|
61
57
|
},
|
|
62
58
|
[dispatch, unload]
|
|
63
59
|
);
|
|
64
60
|
useLayoutEffect(() => {
|
|
65
|
-
if (!documentEle)
|
|
66
|
-
|
|
67
|
-
};
|
|
61
|
+
if (!documentEle) return () => {
|
|
62
|
+
};
|
|
68
63
|
const appConfig = merge(getConfig(), {
|
|
69
64
|
documentEle,
|
|
70
65
|
history,
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { getAppConfigValue } from "../../utils/app-config/config.js";
|
|
2
2
|
const getNavigationLinks = () => {
|
|
3
3
|
const microApps = getAppConfigValue("microFrontendApps");
|
|
4
|
-
if (!microApps)
|
|
5
|
-
return [];
|
|
4
|
+
if (!microApps) return [];
|
|
6
5
|
return Object.keys(microApps).reduce((value, id) => {
|
|
7
6
|
const { name, homeRoute } = microApps[id] || {};
|
|
8
|
-
if (name && homeRoute)
|
|
9
|
-
value.push({ id, name, path: homeRoute });
|
|
7
|
+
if (name && homeRoute) value.push({ id, name, path: homeRoute });
|
|
10
8
|
return value;
|
|
11
9
|
}, []);
|
|
12
10
|
};
|
|
@@ -20,9 +20,8 @@ const updateContainerId = (id, documentEle) => {
|
|
|
20
20
|
};
|
|
21
21
|
const useFrameLoaded = ({ id, documentEle }) => {
|
|
22
22
|
useEffect(() => {
|
|
23
|
-
if (!documentEle)
|
|
24
|
-
|
|
25
|
-
};
|
|
23
|
+
if (!documentEle) return () => {
|
|
24
|
+
};
|
|
26
25
|
const host = CMicroAppHost.getInstance();
|
|
27
26
|
addBaseTag(id, documentEle);
|
|
28
27
|
updateContainerId(id, documentEle);
|
|
@@ -18,8 +18,7 @@ const SessionTimeout = () => {
|
|
|
18
18
|
initSessionMonitoring();
|
|
19
19
|
const warningCb = subscribeToSessionExpiryWarning(
|
|
20
20
|
(sessionExpiryWarningNotifiedAt) => {
|
|
21
|
-
if (!sessionExpiryWarningNotifiedAt)
|
|
22
|
-
return;
|
|
21
|
+
if (!sessionExpiryWarningNotifiedAt) return;
|
|
23
22
|
setwarningNotifiedAt(sessionExpiryWarningNotifiedAt);
|
|
24
23
|
setSessionExpiryWarning(true);
|
|
25
24
|
}
|
|
@@ -2,8 +2,7 @@ import { useEffect } from "react";
|
|
|
2
2
|
const useHTMLWaitMessage = (close) => {
|
|
3
3
|
useEffect(() => {
|
|
4
4
|
const htmlWaitMsgElement = document.getElementById("em-wait-message");
|
|
5
|
-
if (htmlWaitMsgElement && close)
|
|
6
|
-
htmlWaitMsgElement.remove();
|
|
5
|
+
if (htmlWaitMsgElement && close) htmlWaitMsgElement.remove();
|
|
7
6
|
}, [close]);
|
|
8
7
|
};
|
|
9
8
|
export {
|