@frontegg/nextjs 7.0.11-alpha.5168486590 → 7.0.11
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/CHANGELOG.md +12 -27
- package/common/FronteggBaseProvider.js +1 -2
- package/common/FronteggBaseProvider.js.map +1 -1
- package/index.js +1 -1
- package/package.json +3 -3
- package/sdkVersion.js +1 -1
- package/sdkVersion.js.map +1 -1
- package/common/CustomComponentHolder.d.ts +0 -11
- package/common/CustomComponentHolder.js +0 -108
- package/common/CustomComponentHolder.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,30 +1,15 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
## [7.0.11](https://github.com/frontegg/frontegg-nextjs/compare/v7.0.10...v7.0.11) (2023-6-
|
|
4
|
-
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- FR-11722 - fix hosted login with hash [PLEASE DON'T MERGE YET]
|
|
15
|
-
- FR-11611 - login per tenant self service small fixes
|
|
16
|
-
|
|
17
|
-
- FR-11881 - restore search params after closing the admin portal
|
|
18
|
-
- FR-11878 - QA fixes for login per tenant self service
|
|
19
|
-
- FR-11887 - Entitlements SDK - Load entitlements list & make the data accessible for the wrappers
|
|
20
|
-
- FR-11152 - cyprus phone area code 2 fa screen
|
|
21
|
-
- FR-11658 - merge 6.99.x
|
|
22
|
-
- FR-11652 - Add option to upload metadata file instead of metadata url
|
|
23
|
-
- FR-11529 - fix bug white borders dark mode
|
|
24
|
-
- FR-11769 - add meta data to context
|
|
25
|
-
|
|
26
|
-
### NextJS Wrapper 7.0.11:
|
|
27
|
-
- FR-11848 - allow using react hooks in custom components
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
## [7.0.11](https://github.com/frontegg/frontegg-nextjs/compare/v7.0.10...v7.0.11) (2023-6-6)
|
|
4
|
+
|
|
5
|
+
- Improve login preview for login per tenant self service to rendered inside iframe
|
|
6
|
+
- Added required to fields in invite user modal
|
|
7
|
+
- Improve error handling for login
|
|
8
|
+
- Added MSP - all accounts main page and state
|
|
9
|
+
|
|
10
|
+
### NextJS Wrapper 7.0.11:
|
|
11
|
+
- Added support for null in custom component
|
|
12
|
+
|
|
28
13
|
# Change Log
|
|
29
14
|
|
|
30
15
|
## [7.0.10](https://github.com/frontegg/frontegg-nextjs/compare/v7.0.9...v7.0.10) (2023-5-28)
|
|
@@ -15,7 +15,6 @@ var _AppContext = _interopRequireDefault(require("./AppContext"));
|
|
|
15
15
|
var _initializeFronteggApp = _interopRequireDefault(require("../utils/initializeFronteggApp"));
|
|
16
16
|
var _useRequestAuthorizeSSR = _interopRequireDefault(require("./useRequestAuthorizeSSR"));
|
|
17
17
|
var _useOnRedirectTo = _interopRequireDefault(require("../utils/useOnRedirectTo"));
|
|
18
|
-
var _CustomComponentHolder = require("./CustomComponentHolder");
|
|
19
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
19
|
const _excluded = ["router", "appName"];
|
|
21
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -60,7 +59,7 @@ const Connector = _ref => {
|
|
|
60
59
|
});
|
|
61
60
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_AppContext.default.Provider, {
|
|
62
61
|
value: app,
|
|
63
|
-
children: [!isSSR && /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
62
|
+
children: [!isSSR && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHooks.CustomComponentRegister, {
|
|
64
63
|
app: app,
|
|
65
64
|
themeOptions: props.themeOptions
|
|
66
65
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHooks.FronteggStoreProvider, (0, _extends2.default)({}, (0, _extends2.default)({}, props, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FronteggBaseProvider.js","names":["_interopRequireDefault","require","Object","defineProperty","exports","value","FronteggBaseProvider","_extends2","_objectWithoutPropertiesLoose2","_react","_interopRequireWildcard","_reactHooks","_restApi","_AppContext","_initializeFronteggApp","_useRequestAuthorizeSSR","_useOnRedirectTo","
|
|
1
|
+
{"version":3,"file":"FronteggBaseProvider.js","names":["_interopRequireDefault","require","Object","defineProperty","exports","value","FronteggBaseProvider","_extends2","_objectWithoutPropertiesLoose2","_react","_interopRequireWildcard","_reactHooks","_restApi","_AppContext","_initializeFronteggApp","_useRequestAuthorizeSSR","_useOnRedirectTo","_jsxRuntime","_excluded","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","Connector","_ref","_props$basename","_props$authOptions","router","appName","props","isSSR","window","user","session","tenants","baseName","basename","ssrStoreHolder","useRef","storeHolder","current","undefined","onRedirectTo","useOnRedirectTo","authOptions","routes","app","useMemo","initializeFronteggApp","options","ContextHolder","setOnRedirectTo","useRequestAuthorizeSSR","jsxs","Provider","children","jsx","CustomComponentRegister","themeOptions","FronteggStoreProvider","framework"],"sources":["../../../../packages/nextjs/src/common/FronteggBaseProvider.tsx"],"sourcesContent":["'use client';\n\nimport React, { FC, useMemo, useRef } from 'react';\nimport { FronteggStoreProvider, CustomComponentRegister } from '@frontegg/react-hooks';\nimport { ContextHolder } from '@frontegg/rest-api';\nimport type { FronteggProviderProps } from '../types';\nimport AppContext from './AppContext';\nimport initializeFronteggApp from '../utils/initializeFronteggApp';\nimport useRequestAuthorizeSSR from './useRequestAuthorizeSSR';\nimport useOnRedirectTo from '../utils/useOnRedirectTo';\n\nconst Connector: FC<FronteggProviderProps> = ({ router, appName = 'default', ...props }) => {\n const isSSR = typeof window === 'undefined';\n const { user, session, tenants } = props;\n const baseName = props.basename ?? '';\n const ssrStoreHolder = useRef({});\n const storeHolder = isSSR ? ssrStoreHolder.current : undefined;\n\n const onRedirectTo = useOnRedirectTo(baseName, router, props.authOptions?.routes);\n\n const app = useMemo(\n () =>\n initializeFronteggApp({\n options: { ...props, basename: baseName },\n onRedirectTo,\n appName,\n storeHolder,\n }),\n [props]\n );\n ContextHolder.setOnRedirectTo(onRedirectTo);\n\n // useEffect(() => {\n // if(window.location.pathname == '/account/login') {\n // app.store.dispatch({ type: 'auth/requestAuthorize', payload: true });\n // }\n // }, [app]);\n useRequestAuthorizeSSR({ app, user, tenants, session });\n return (\n <AppContext.Provider value={app}>\n {!isSSR && <CustomComponentRegister app={app} themeOptions={props.themeOptions} />}\n <FronteggStoreProvider {...({ ...props, app } as any)}>{props.children}</FronteggStoreProvider>\n </AppContext.Provider>\n );\n};\n\nexport const FronteggBaseProvider: FC<FronteggProviderProps> = (props) => {\n return (\n <Connector {...props} framework={'nextjs'}>\n {props.children}\n </Connector>\n );\n};\n"],"mappings":";AAAA,YAAY;;AAAC,IAAAA,sBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,KAAA;AAAA;AAAAD,OAAA,CAAAE,oBAAA;AAAA,IAAAC,SAAA,GAAAP,sBAAA,CAAAC,OAAA;AAAA,IAAAO,8BAAA,GAAAR,sBAAA,CAAAC,OAAA;AAEb,IAAAQ,MAAA,GAAAC,uBAAA,CAAAT,OAAA;AACA,IAAAU,WAAA,GAAAV,OAAA;AACA,IAAAW,QAAA,GAAAX,OAAA;AAEA,IAAAY,WAAA,GAAAb,sBAAA,CAAAC,OAAA;AACA,IAAAa,sBAAA,GAAAd,sBAAA,CAAAC,OAAA;AACA,IAAAc,uBAAA,GAAAf,sBAAA,CAAAC,OAAA;AACA,IAAAe,gBAAA,GAAAhB,sBA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A,EAAC7D,WAAA,CAAA8D,uBAAuB;MAACX,GAAG,EAAEA,GAAI;MAACY,YAAY,EAAE7B,KAAK,CAAC6B;IAAa,EAAG,eAClF,IAAAzD,WAAA,CAAAuD,GAAA,EAAC7D,WAAA,CAAAgE,qBAAqB,MAAApE,SAAA,CAAAmB,OAAA,UAAAnB,SAAA,CAAAmB,OAAA,MAAWmB,KAAK;MAAEiB;IAAG;MAAAS,QAAA,EAAa1B,KAAK,CAAC0B;IAAQ,GAAyB;EAAA,EAC3E;AAE1B,CAAC;AAEM,MAAMjE,oBAA+C,GAAIuC,KAAK,IAAK;EACxE,oBACE,IAAA5B,WAAA,CAAAuD,GAAA,EAACjC,SAAS,MAAAhC,SAAA,CAAAmB,OAAA,MAAKmB,KAAK;IAAE+B,SAAS,EAAE,QAAS;IAAAL,QAAA,EACvC1B,KAAK,CAAC0B;EAAQ,GACL;AAEhB,CAAC;AAACnE,OAAA,CAAAE,oBAAA,GAAAA,oBAAA"}
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/nextjs",
|
|
3
3
|
"libName": "FronteggNextJs",
|
|
4
|
-
"version": "7.0.11
|
|
4
|
+
"version": "7.0.11",
|
|
5
5
|
"author": "Frontegg LTD",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"lint-json": "eslint -c .eslintrc.json -o ./lint-report.json --format json --no-color ./src/**/*.{ts,tsx}"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@frontegg/js": "6.
|
|
31
|
-
"@frontegg/react-hooks": "6.
|
|
30
|
+
"@frontegg/js": "6.104.0",
|
|
31
|
+
"@frontegg/react-hooks": "6.104.0",
|
|
32
32
|
"http-proxy": "^1.18.1",
|
|
33
33
|
"iron-session": "^6.3.1",
|
|
34
34
|
"jose": "^4.12.2"
|
package/sdkVersion.js
CHANGED
package/sdkVersion.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdkVersion.js","names":["version","exports","default","_default"],"sources":["../../../packages/nextjs/src/sdkVersion.ts"],"sourcesContent":["export default { version: '7.0.11
|
|
1
|
+
{"version":3,"file":"sdkVersion.js","names":["version","exports","default","_default"],"sources":["../../../packages/nextjs/src/sdkVersion.ts"],"sourcesContent":["export default { version: '7.0.11' };\n"],"mappings":";;;;;;eAAe;EAAEA,OAAO,EAAE;AAAS,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAC,QAAA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { FC, ReactElement } from 'react';
|
|
2
|
-
import { FronteggAppInstance } from '@frontegg/types';
|
|
3
|
-
export declare class CustomComponentHolder {
|
|
4
|
-
private static components;
|
|
5
|
-
static set(name: string, element: any): void;
|
|
6
|
-
static get(name: string): ReactElement;
|
|
7
|
-
}
|
|
8
|
-
export declare const CustomComponentRegister: FC<{
|
|
9
|
-
app: FronteggAppInstance;
|
|
10
|
-
themeOptions: any;
|
|
11
|
-
}>;
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
'use client';
|
|
3
|
-
|
|
4
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.CustomComponentRegister = exports.CustomComponentHolder = void 0;
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
11
|
-
var _reactIs = require("react-is");
|
|
12
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
-
class CustomComponentHolder {
|
|
16
|
-
static set(name, element) {
|
|
17
|
-
CustomComponentHolder.components[name] = element;
|
|
18
|
-
}
|
|
19
|
-
static get(name) {
|
|
20
|
-
return CustomComponentHolder.components[name];
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.CustomComponentHolder = CustomComponentHolder;
|
|
24
|
-
CustomComponentHolder.components = {};
|
|
25
|
-
const overrideValue = (object, key, value) => {
|
|
26
|
-
const keys = key.split('.');
|
|
27
|
-
let iterator = object;
|
|
28
|
-
while (keys.length > 1) {
|
|
29
|
-
iterator = iterator[keys.shift()];
|
|
30
|
-
}
|
|
31
|
-
iterator[keys.shift()] = value;
|
|
32
|
-
};
|
|
33
|
-
const Registerer = props => {
|
|
34
|
-
var _app$loginBoxContaine;
|
|
35
|
-
const {
|
|
36
|
-
app,
|
|
37
|
-
themeKey
|
|
38
|
-
} = props;
|
|
39
|
-
const value = CustomComponentHolder.get(themeKey);
|
|
40
|
-
const [mounted, setMounted] = (0, _react.useState)(false);
|
|
41
|
-
const mount = (0, _react.useCallback)(() => {
|
|
42
|
-
setMounted(true);
|
|
43
|
-
}, []);
|
|
44
|
-
const unmount = (0, _react.useCallback)(() => {
|
|
45
|
-
setMounted(false);
|
|
46
|
-
}, []);
|
|
47
|
-
overrideValue(app.options.themeOptions, themeKey, {
|
|
48
|
-
type: 'slot',
|
|
49
|
-
themeKey,
|
|
50
|
-
mount,
|
|
51
|
-
unmount
|
|
52
|
-
});
|
|
53
|
-
let element = (_app$loginBoxContaine = app.loginBoxContainer) == null ? void 0 : _app$loginBoxContaine.querySelector(`[slot="${themeKey}"]`);
|
|
54
|
-
if (!element && typeof document !== undefined) {
|
|
55
|
-
var _app$loginBoxContaine2;
|
|
56
|
-
element = document.createElement('div');
|
|
57
|
-
element.slot = themeKey;
|
|
58
|
-
(_app$loginBoxContaine2 = app.loginBoxContainer) == null ? void 0 : _app$loginBoxContaine2.appendChild(element);
|
|
59
|
-
}
|
|
60
|
-
return element && mounted ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.default.Fragment, {
|
|
61
|
-
children: /*#__PURE__*/_reactDom.default.createPortal(value, element)
|
|
62
|
-
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {});
|
|
63
|
-
};
|
|
64
|
-
const CustomComponentRegister = ({
|
|
65
|
-
app,
|
|
66
|
-
themeOptions
|
|
67
|
-
}) => {
|
|
68
|
-
const keys = (0, _react.useMemo)(() => {
|
|
69
|
-
if (!themeOptions || !themeOptions.loginBox) {
|
|
70
|
-
return [];
|
|
71
|
-
}
|
|
72
|
-
const loop = (key, obj, keyPath) => {
|
|
73
|
-
if (typeof obj !== 'object' && typeof obj !== 'function') {
|
|
74
|
-
return [];
|
|
75
|
-
}
|
|
76
|
-
if (typeof obj === 'function') {
|
|
77
|
-
try {
|
|
78
|
-
obj = /*#__PURE__*/_react.default.createElement(obj);
|
|
79
|
-
if ( /*#__PURE__*/(0, _react.isValidElement)(obj) || (0, _reactIs.isElement)(obj)) {
|
|
80
|
-
const generatedKey = `${keyPath}.${key}`;
|
|
81
|
-
CustomComponentHolder.set(generatedKey, obj);
|
|
82
|
-
return [generatedKey];
|
|
83
|
-
}
|
|
84
|
-
} catch (e) {}
|
|
85
|
-
}
|
|
86
|
-
if ( /*#__PURE__*/(0, _react.isValidElement)(obj) || (0, _reactIs.isElement)(obj)) {
|
|
87
|
-
const generatedKey = `${keyPath}.${key}`;
|
|
88
|
-
CustomComponentHolder.set(generatedKey, obj);
|
|
89
|
-
return [generatedKey];
|
|
90
|
-
} else {
|
|
91
|
-
const elements = [];
|
|
92
|
-
Object.keys(obj).forEach(k => {
|
|
93
|
-
elements.push(...loop(k, obj[k], keyPath === '' ? key : `${keyPath}.${key}`));
|
|
94
|
-
});
|
|
95
|
-
return elements;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
return loop('loginBox', themeOptions.loginBox, '');
|
|
99
|
-
}, []);
|
|
100
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
101
|
-
children: keys.map(key => /*#__PURE__*/(0, _jsxRuntime.jsx)(Registerer, {
|
|
102
|
-
app: app,
|
|
103
|
-
themeKey: key
|
|
104
|
-
}, key))
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
|
-
exports.CustomComponentRegister = CustomComponentRegister;
|
|
108
|
-
//# sourceMappingURL=CustomComponentHolder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CustomComponentHolder.js","names":["_interopRequireDefault","require","Object","defineProperty","exports","value","CustomComponentRegister","CustomComponentHolder","_react","_interopRequireWildcard","_reactDom","_reactIs","_jsxRuntime","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","name","element","components","overrideValue","object","keys","split","iterator","length","shift","Registerer","props","_app$loginBoxContaine","app","themeKey","mounted","setMounted","useState","mount","useCallback","unmount","options","themeOptions","type","loginBoxContainer","querySelector","document","undefined","_app$loginBoxContaine2","createElement","slot","appendChild","jsx","Fragment","children","ReactDOM","createPortal","useMemo","loginBox","loop","keyPath","React","isValidElement","isElement","generatedKey","e","elements","forEach","k","push","map"],"sources":["../../../../packages/nextjs/src/common/CustomComponentHolder.tsx"],"sourcesContent":["'use client';\n\nimport React, { FC, isValidElement, ReactElement, useCallback, useMemo, useState } from 'react';\nimport ReactDOM from 'react-dom';\nimport { FronteggAppInstance } from '@frontegg/types';\nimport { isElement } from 'react-is';\n\nexport class CustomComponentHolder {\n private static components: { [name in string]: ReactElement } = {};\n\n public static set(name: string, element: any) {\n CustomComponentHolder.components[name] = element;\n }\n\n public static get(name: string): ReactElement {\n return CustomComponentHolder.components[name];\n }\n}\n\nconst overrideValue = (object: any, key: string, value: any) => {\n const keys: string[] = key.split('.');\n let iterator = object;\n while (keys.length > 1) {\n iterator = iterator[keys.shift() as any];\n }\n iterator[keys.shift() as any] = value;\n};\nconst Registerer: FC<{ app: FronteggAppInstance; themeKey: string }> = (props) => {\n const { app, themeKey } = props;\n const value = CustomComponentHolder.get(themeKey);\n const [mounted, setMounted] = useState(false);\n\n const mount = useCallback(() => {\n setMounted(true);\n }, []);\n const unmount = useCallback(() => {\n setMounted(false);\n }, []);\n\n overrideValue(app.options.themeOptions!, themeKey, { type: 'slot', themeKey, mount, unmount });\n\n let element = app.loginBoxContainer?.querySelector(`[slot=\"${themeKey}\"]`);\n if (!element && typeof document !== undefined) {\n element = document.createElement('div');\n element.slot = themeKey;\n app.loginBoxContainer?.appendChild(element);\n }\n\n return element && mounted ? <React.Fragment>{ReactDOM.createPortal(value, element)}</React.Fragment> : <></>;\n};\n\nexport const CustomComponentRegister: FC<{ app: FronteggAppInstance; themeOptions: any }> = ({ app, themeOptions }) => {\n const keys = useMemo(() => {\n if (!themeOptions || !themeOptions.loginBox) {\n return [];\n }\n const loop = (key: string, obj: any, keyPath: string): string[] => {\n if (typeof obj !== 'object' && typeof obj !== 'function') {\n return [];\n }\n if (typeof obj === 'function') {\n try {\n obj = React.createElement(obj);\n if (isValidElement(obj) || isElement(obj)) {\n const generatedKey = `${keyPath}.${key}`;\n CustomComponentHolder.set(generatedKey, obj);\n return [generatedKey];\n }\n } catch (e) {}\n }\n if (isValidElement(obj) || isElement(obj)) {\n const generatedKey = `${keyPath}.${key}`;\n CustomComponentHolder.set(generatedKey, obj);\n return [generatedKey];\n } else {\n const elements: string[] = [];\n Object.keys(obj).forEach((k) => {\n elements.push(...loop(k, obj[k], keyPath === '' ? key : `${keyPath}.${key}`));\n });\n return elements;\n }\n };\n return loop('loginBox', themeOptions.loginBox, '');\n }, []);\n\n return (\n <>\n {keys.map((key) => (\n <Registerer key={key} app={app} themeKey={key} />\n ))}\n </>\n );\n};\n"],"mappings":";AAAA,YAAY;;AAAC,IAAAA,sBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,KAAA;AAAA;AAAAD,OAAA,CAAAE,uBAAA,GAAAF,OAAA,CAAAG,qBAAA;AAEb,IAAAC,MAAA,GAAAC,uBAAA,CAAAR,OAAA;AACA,IAAAS,SAAA,GAAAV,sBAAA,CAAAC,OAAA;AAEA,IAAAU,QAAA,GAAAV,OAAA;AAAqC,IAAAW,WAAA,GAAAX,OAAA;AAAA,SAAAY,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAL,wBAAAS,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAA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