@frontegg/react-hooks 6.105.0-alpha.2 → 6.105.0
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/FronteggProvider/index.d.ts +1 -0
- package/FronteggProvider/index.js +6 -4
- package/common/CustomComponentHolder.d.ts +2 -2
- package/common/CustomComponentHolder.js +9 -4
- package/index.js +1 -1
- package/node/FronteggProvider/index.js +5 -4
- package/node/common/CustomComponentHolder.js +9 -4
- package/node/index.js +1 -1
- package/package.json +3 -3
|
@@ -6,6 +6,7 @@ declare type FronteggProviderProps = {
|
|
|
6
6
|
contextOptions?: ContextOptions;
|
|
7
7
|
setLoading?: (loading: boolean) => void;
|
|
8
8
|
children?: ReactNode | undefined;
|
|
9
|
+
alwaysVisibleChildren?: ReactNode;
|
|
9
10
|
};
|
|
10
11
|
export declare const FronteggStoreProvider: FC<FronteggProviderProps>;
|
|
11
12
|
export {};
|
|
@@ -8,6 +8,7 @@ import { useAuth, useAuthRoutes } from '../auth';
|
|
|
8
8
|
import { Provider, FronteggStoreContext } from '../FronteggStoreContext';
|
|
9
9
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
12
|
const defaultSetLoading = loading => {
|
|
12
13
|
if (loading) {
|
|
13
14
|
document.body.classList.add('frontegg-loading');
|
|
@@ -97,7 +98,8 @@ export const FronteggStoreProvider = props => {
|
|
|
97
98
|
children,
|
|
98
99
|
app,
|
|
99
100
|
contextOptions,
|
|
100
|
-
setLoading = defaultSetLoading
|
|
101
|
+
setLoading = defaultSetLoading,
|
|
102
|
+
alwaysVisibleChildren
|
|
101
103
|
} = props;
|
|
102
104
|
|
|
103
105
|
// TODO: make this optionals more readable
|
|
@@ -119,13 +121,13 @@ export const FronteggStoreProvider = props => {
|
|
|
119
121
|
appName: (_app$name = app == null ? void 0 : app.name) != null ? _app$name : 'default'
|
|
120
122
|
}, app, previewMode, authOptions, undefined, false, app == null ? void 0 : (_app$options7 = app.options) == null ? void 0 : _app$options7.urlStrategy);
|
|
121
123
|
}, [app, previewMode]);
|
|
122
|
-
return /*#__PURE__*/
|
|
124
|
+
return /*#__PURE__*/_jsxs(Provider, {
|
|
123
125
|
context: FronteggStoreContext,
|
|
124
126
|
store: store,
|
|
125
|
-
children: /*#__PURE__*/_jsx(FronteggContent, {
|
|
127
|
+
children: [alwaysVisibleChildren, /*#__PURE__*/_jsx(FronteggContent, {
|
|
126
128
|
setLoading: setLoading,
|
|
127
129
|
app: app,
|
|
128
130
|
children: children
|
|
129
|
-
})
|
|
131
|
+
})]
|
|
130
132
|
});
|
|
131
133
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FC,
|
|
1
|
+
import { FC, FunctionComponent } from 'react';
|
|
2
2
|
import { FronteggAppInstance } from '@frontegg/types';
|
|
3
3
|
/**
|
|
4
4
|
* CustomComponentRegister is used to support using react hooks inside custom components.
|
|
@@ -6,7 +6,7 @@ import { FronteggAppInstance } from '@frontegg/types';
|
|
|
6
6
|
export declare class CustomComponentHolder {
|
|
7
7
|
private static components;
|
|
8
8
|
static set(name: string, element: any): void;
|
|
9
|
-
static get(name: string):
|
|
9
|
+
static get(name: string): FunctionComponent;
|
|
10
10
|
}
|
|
11
11
|
export declare const CustomComponentRegister: FC<{
|
|
12
12
|
app: FronteggAppInstance;
|
|
@@ -32,8 +32,10 @@ const Registerer = props => {
|
|
|
32
32
|
} = props;
|
|
33
33
|
const value = CustomComponentHolder.get(themeKey);
|
|
34
34
|
const [mounted, setMounted] = useState(false);
|
|
35
|
-
const
|
|
35
|
+
const [componentProps, setComponentProps] = useState({});
|
|
36
|
+
const mount = useCallback((props = {}) => {
|
|
36
37
|
setMounted(true);
|
|
38
|
+
setComponentProps(props);
|
|
37
39
|
}, []);
|
|
38
40
|
const unmount = useCallback(() => {
|
|
39
41
|
setMounted(false);
|
|
@@ -51,8 +53,9 @@ const Registerer = props => {
|
|
|
51
53
|
element.slot = themeKey;
|
|
52
54
|
(_app$loginBoxContaine2 = app.loginBoxContainer) == null ? void 0 : _app$loginBoxContaine2.appendChild(element);
|
|
53
55
|
}
|
|
56
|
+
const component = /*#__PURE__*/React.createElement(value, componentProps);
|
|
54
57
|
return element && mounted ? /*#__PURE__*/_jsx(React.Fragment, {
|
|
55
|
-
children: /*#__PURE__*/ReactDOM.createPortal(
|
|
58
|
+
children: /*#__PURE__*/ReactDOM.createPortal(component, element)
|
|
56
59
|
}) : /*#__PURE__*/_jsx(_Fragment, {});
|
|
57
60
|
};
|
|
58
61
|
export const CustomComponentRegister = ({
|
|
@@ -69,8 +72,10 @@ export const CustomComponentRegister = ({
|
|
|
69
72
|
}
|
|
70
73
|
if (typeof obj === 'function') {
|
|
71
74
|
try {
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
const reactElement = /*#__PURE__*/React.createElement(obj, {
|
|
76
|
+
title: 'title'
|
|
77
|
+
});
|
|
78
|
+
if ( /*#__PURE__*/isValidElement(reactElement) || isElement(reactElement)) {
|
|
74
79
|
const generatedKey = `${keyPath}.${key}`;
|
|
75
80
|
CustomComponentHolder.set(generatedKey, obj);
|
|
76
81
|
return [generatedKey];
|
package/index.js
CHANGED
|
@@ -105,7 +105,8 @@ const FronteggStoreProvider = props => {
|
|
|
105
105
|
children,
|
|
106
106
|
app,
|
|
107
107
|
contextOptions,
|
|
108
|
-
setLoading = defaultSetLoading
|
|
108
|
+
setLoading = defaultSetLoading,
|
|
109
|
+
alwaysVisibleChildren
|
|
109
110
|
} = props;
|
|
110
111
|
|
|
111
112
|
// TODO: make this optionals more readable
|
|
@@ -127,14 +128,14 @@ const FronteggStoreProvider = props => {
|
|
|
127
128
|
appName: (_app$name = app == null ? void 0 : app.name) != null ? _app$name : 'default'
|
|
128
129
|
}, app, previewMode, authOptions, undefined, false, app == null ? void 0 : (_app$options7 = app.options) == null ? void 0 : _app$options7.urlStrategy);
|
|
129
130
|
}, [app, previewMode]);
|
|
130
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
131
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_FronteggStoreContext.Provider, {
|
|
131
132
|
context: _FronteggStoreContext.FronteggStoreContext,
|
|
132
133
|
store: store,
|
|
133
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(FronteggContent, {
|
|
134
|
+
children: [alwaysVisibleChildren, /*#__PURE__*/(0, _jsxRuntime.jsx)(FronteggContent, {
|
|
134
135
|
setLoading: setLoading,
|
|
135
136
|
app: app,
|
|
136
137
|
children: children
|
|
137
|
-
})
|
|
138
|
+
})]
|
|
138
139
|
});
|
|
139
140
|
};
|
|
140
141
|
exports.FronteggStoreProvider = FronteggStoreProvider;
|
|
@@ -40,8 +40,10 @@ const Registerer = props => {
|
|
|
40
40
|
} = props;
|
|
41
41
|
const value = CustomComponentHolder.get(themeKey);
|
|
42
42
|
const [mounted, setMounted] = (0, _react.useState)(false);
|
|
43
|
-
const
|
|
43
|
+
const [componentProps, setComponentProps] = (0, _react.useState)({});
|
|
44
|
+
const mount = (0, _react.useCallback)((props = {}) => {
|
|
44
45
|
setMounted(true);
|
|
46
|
+
setComponentProps(props);
|
|
45
47
|
}, []);
|
|
46
48
|
const unmount = (0, _react.useCallback)(() => {
|
|
47
49
|
setMounted(false);
|
|
@@ -59,8 +61,9 @@ const Registerer = props => {
|
|
|
59
61
|
element.slot = themeKey;
|
|
60
62
|
(_app$loginBoxContaine2 = app.loginBoxContainer) == null ? void 0 : _app$loginBoxContaine2.appendChild(element);
|
|
61
63
|
}
|
|
64
|
+
const component = /*#__PURE__*/_react.default.createElement(value, componentProps);
|
|
62
65
|
return element && mounted ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.default.Fragment, {
|
|
63
|
-
children: /*#__PURE__*/_reactDom.default.createPortal(
|
|
66
|
+
children: /*#__PURE__*/_reactDom.default.createPortal(component, element)
|
|
64
67
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {});
|
|
65
68
|
};
|
|
66
69
|
const CustomComponentRegister = ({
|
|
@@ -77,8 +80,10 @@ const CustomComponentRegister = ({
|
|
|
77
80
|
}
|
|
78
81
|
if (typeof obj === 'function') {
|
|
79
82
|
try {
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
const reactElement = /*#__PURE__*/_react.default.createElement(obj, {
|
|
84
|
+
title: 'title'
|
|
85
|
+
});
|
|
86
|
+
if ( /*#__PURE__*/(0, _react.isValidElement)(reactElement) || (0, _reactIs.isElement)(reactElement)) {
|
|
82
87
|
const generatedKey = `${keyPath}.${key}`;
|
|
83
88
|
CustomComponentHolder.set(generatedKey, obj);
|
|
84
89
|
return [generatedKey];
|
package/node/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/react-hooks",
|
|
3
|
-
"version": "6.105.0
|
|
3
|
+
"version": "6.105.0",
|
|
4
4
|
"main": "./node/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Frontegg LTD",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@babel/runtime": "^7.18.6",
|
|
9
|
-
"@frontegg/redux-store": "6.105.0
|
|
10
|
-
"@frontegg/types": "6.105.0
|
|
9
|
+
"@frontegg/redux-store": "6.105.0",
|
|
10
|
+
"@frontegg/types": "6.105.0",
|
|
11
11
|
"@types/react": "*",
|
|
12
12
|
"get-value": "^3.0.1",
|
|
13
13
|
"react-redux": "^7.x"
|