@frontegg/react-hooks
Advanced tools
Comparing version 2.1.1-alpha.773827200 to 2.1.1-alpha.775775142
import '../tslib.es6-e3c82a74.js'; | ||
import 'react'; | ||
import '@frontegg/redux-store/toolkit'; | ||
import 'react-redux'; | ||
import '@frontegg/redux-store/toolkit'; | ||
import '@frontegg/redux-store'; | ||
import '@frontegg/rest-api'; | ||
import '@frontegg/redux-store/auth'; | ||
import '@frontegg/redux-store/audits'; | ||
export { c as useAuditLogsActions, b as useAuditLogsState, a as useAuditsActions, e as useAuditsMetadataActions, d as useAuditsMetadataState, u as useAuditsState } from '../auditsMetadata-22daf6f1.js'; | ||
import '@frontegg/redux-store'; | ||
export { c as useAuditLogsActions, b as useAuditLogsState, a as useAuditsActions, e as useAuditsMetadataActions, d as useAuditsMetadataState, u as useAuditsState } from '../auditsMetadata-8a99c0b5.js'; | ||
//# sourceMappingURL=index.js.map |
import '../tslib.es6-e3c82a74.js'; | ||
import 'react'; | ||
import '@frontegg/redux-store/toolkit'; | ||
import 'react-redux'; | ||
import '@frontegg/redux-store/toolkit'; | ||
import '@frontegg/redux-store'; | ||
import '@frontegg/rest-api'; | ||
import '@frontegg/redux-store/auth'; | ||
import '@frontegg/rest-api'; | ||
export { s as reloadProfileIfNeeded, h as useAcceptInvitationActions, g as useAcceptInvitationState, j as useActivateAccountActions, i as useActivateAccountState, l as useApiTokensActions, k as useApiTokensState, u as useAuth, a as useAuthActions, c as useAuthRoutes, B as useAuthTeamActions, A as useAuthTeamState, e as useAuthUser, f as useAuthUserOrNull, n as useForgotPasswordActions, m as useForgotPasswordState, d as useIsAuthenticated, p as useLoginActions, o as useLoginState, r as useMfaActions, q as useMfaState, b as useOnRedirectTo, v as useProfileActions, t as useProfileState, J as useRolesActions, I as useRolesState, D as useSSOActions, C as useSSOState, F as useSecurityPolicyActions, E as useSecurityPolicyState, x as useSignUpActions, w as useSignUpState, z as useSocialLoginActions, y as useSocialLoginState, H as useTenantsActions, G as useTenantsState } from '../roles-4dcae1ac.js'; | ||
export { s as reloadProfileIfNeeded, h as useAcceptInvitationActions, g as useAcceptInvitationState, j as useActivateAccountActions, i as useActivateAccountState, l as useApiTokensActions, k as useApiTokensState, u as useAuth, a as useAuthActions, c as useAuthRoutes, B as useAuthTeamActions, A as useAuthTeamState, e as useAuthUser, f as useAuthUserOrNull, n as useForgotPasswordActions, m as useForgotPasswordState, d as useIsAuthenticated, p as useLoginActions, o as useLoginState, r as useMfaActions, q as useMfaState, b as useOnRedirectTo, v as useProfileActions, t as useProfileState, J as useRolesActions, I as useRolesState, D as useSSOActions, C as useSSOState, F as useSecurityPolicyActions, E as useSecurityPolicyState, x as useSignUpActions, w as useSignUpState, z as useSocialLoginActions, y as useSocialLoginState, H as useTenantsActions, G as useTenantsState } from '../roles-6446f670.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -8,3 +8,3 @@ import { FC } from 'react'; | ||
}; | ||
export { Provider, useSelector, useDispatch, shallowEqual, connect } from 'react-redux'; | ||
export declare const FronteggProvider: FC<FronteggProviderProps>; | ||
export {}; |
219
index.cjs.js
@@ -9,8 +9,8 @@ 'use strict'; | ||
var React__default = _interopDefault(React); | ||
var reactRedux = require('react-redux'); | ||
var toolkit = require('@frontegg/redux-store/toolkit'); | ||
var audits = require('@frontegg/redux-store/audits'); | ||
var reactRedux = require('react-redux'); | ||
var reduxStore = require('@frontegg/redux-store'); | ||
var restApi = require('@frontegg/rest-api'); | ||
var auth = require('@frontegg/redux-store/auth'); | ||
var restApi = require('@frontegg/rest-api'); | ||
@@ -43,36 +43,2 @@ /*! ***************************************************************************** | ||
var useAuditsState = function (stateMapper) { | ||
return reactRedux.useSelector(function (state) { var _a; return (_a = stateMapper === null || stateMapper === void 0 ? void 0 : stateMapper(state[audits.auditsStoreName])) !== null && _a !== void 0 ? _a : state[audits.auditsStoreName]; }, reactRedux.shallowEqual); | ||
}; | ||
var useAuditsActions = function () { | ||
var dispatch = reactRedux.useDispatch(); | ||
return React.useMemo(function () { return toolkit.bindActionCreators(audits.auditsActions, dispatch); }, [audits.auditsActions]); | ||
}; | ||
/** | ||
* hooks helpers | ||
*/ | ||
var sliceReducerActionsBy = function (reducer) { | ||
var reducerKeys = Object.keys(reducer); | ||
var reducerActions = reducerKeys.map(function (key) { | ||
var _a; | ||
return (_a = {}, _a[key] = audits.auditsActions[key], _a); | ||
}); | ||
return reducerActions.reduce(function (p, n) { return (__assign(__assign({}, p), n)); }, {}); | ||
}; | ||
var stateHookGenerator = function (stateMapper, subState) { | ||
return reactRedux.useSelector(function (state) { var _a; return (_a = stateMapper === null || stateMapper === void 0 ? void 0 : stateMapper(state[audits.auditsStoreName][subState])) !== null && _a !== void 0 ? _a : state[audits.auditsStoreName][subState]; }, reactRedux.shallowEqual); | ||
}; | ||
var reducerActionsGenerator = function (actions, reducers) { | ||
var dispatch = reactRedux.useDispatch(); | ||
return React.useMemo(function () { return toolkit.bindActionCreators(__assign(__assign({}, actions), sliceReducerActionsBy(reducers)), dispatch); }, [dispatch]); | ||
}; | ||
var useAuditLogsState = function (stateMapper) { return stateHookGenerator(stateMapper, 'auditLogsState'); }; | ||
var useAuditLogsActions = function () { return reducerActionsGenerator(reduxStore.auditLogsActions, reduxStore.auditLogsReducers); }; | ||
var useAuditsMetadataState = function (stateMapper) { return stateHookGenerator(stateMapper, 'auditsMetadataState'); }; | ||
var useAuditsMetadataActions = function () { | ||
return reducerActionsGenerator(audits.auditsMetadataActions, audits.auditsMetadataReducers); | ||
}; | ||
var defaultMapper = { | ||
@@ -139,3 +105,3 @@ state: function (state) { return state; }, | ||
*/ | ||
var sliceReducerActionsBy$1 = function (reducer) { | ||
var sliceReducerActionsBy = function (reducer) { | ||
var reducerKeys = Object.keys(reducer); | ||
@@ -148,37 +114,37 @@ var reducerActions = reducerKeys.map(function (key) { | ||
}; | ||
var stateHookGenerator$1 = function (stateMapper, subState) { | ||
var stateHookGenerator = function (stateMapper, subState) { | ||
return reactRedux.useSelector(function (state) { var _a; return (_a = stateMapper === null || stateMapper === void 0 ? void 0 : stateMapper(state[auth.authStoreName][subState])) !== null && _a !== void 0 ? _a : state[auth.authStoreName][subState]; }, reactRedux.shallowEqual); | ||
}; | ||
var reducerActionsGenerator$1 = function (actions, reducers) { | ||
var reducerActionsGenerator = function (actions, reducers) { | ||
var dispatch = reactRedux.useDispatch(); | ||
return React.useMemo(function () { return toolkit.bindActionCreators(__assign(__assign({}, actions), sliceReducerActionsBy$1(reducers)), dispatch); }, [dispatch]); | ||
return React.useMemo(function () { return toolkit.bindActionCreators(__assign(__assign({}, actions), sliceReducerActionsBy(reducers)), dispatch); }, [dispatch]); | ||
}; | ||
var useAcceptInvitationState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'acceptInvitationState'); }; | ||
var useAcceptInvitationState = function (stateMapper) { return stateHookGenerator(stateMapper, 'acceptInvitationState'); }; | ||
var useAcceptInvitationActions = function () { | ||
return reducerActionsGenerator$1(auth.acceptInvitationActions, auth.acceptInvitationReducers); | ||
return reducerActionsGenerator(auth.acceptInvitationActions, auth.acceptInvitationReducers); | ||
}; | ||
var useActivateAccountState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'activateState'); }; | ||
var useActivateAccountState = function (stateMapper) { return stateHookGenerator(stateMapper, 'activateState'); }; | ||
var useActivateAccountActions = function () { | ||
return reducerActionsGenerator$1(auth.activateAccountActions, auth.activateAccountReducers); | ||
return reducerActionsGenerator(auth.activateAccountActions, auth.activateAccountReducers); | ||
}; | ||
var useApiTokensState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'apiTokensState'); }; | ||
var useApiTokensActions = function () { return reducerActionsGenerator$1(auth.apiTokensActions, auth.apiTokensReducers); }; | ||
var useApiTokensState = function (stateMapper) { return stateHookGenerator(stateMapper, 'apiTokensState'); }; | ||
var useApiTokensActions = function () { return reducerActionsGenerator(auth.apiTokensActions, auth.apiTokensReducers); }; | ||
var useForgotPasswordState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'forgotPasswordState'); }; | ||
var useForgotPasswordState = function (stateMapper) { return stateHookGenerator(stateMapper, 'forgotPasswordState'); }; | ||
var useForgotPasswordActions = function () { | ||
return reducerActionsGenerator$1(auth.forgotPasswordActions, auth.forgotPasswordReducers); | ||
return reducerActionsGenerator(auth.forgotPasswordActions, auth.forgotPasswordReducers); | ||
}; | ||
var useLoginState = function (stateMapper) { | ||
return stateHookGenerator$1(stateMapper, 'loginState'); | ||
return stateHookGenerator(stateMapper, 'loginState'); | ||
}; | ||
var useLoginActions = function () { return reducerActionsGenerator$1(auth.loginActions, auth.loginReducers); }; | ||
var useLoginActions = function () { return reducerActionsGenerator(auth.loginActions, auth.loginReducers); }; | ||
var useMfaState = function (stateMapper) { | ||
return stateHookGenerator$1(stateMapper, 'mfaState'); | ||
return stateHookGenerator(stateMapper, 'mfaState'); | ||
}; | ||
var useMfaActions = function () { return reducerActionsGenerator$1(auth.mfaActions, auth.mfaReducers); }; | ||
var useMfaActions = function () { return reducerActionsGenerator(auth.mfaActions, auth.mfaReducers); }; | ||
@@ -192,33 +158,33 @@ var reloadProfileIfNeeded = function () { | ||
}; | ||
var useProfileState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'profileState'); }; | ||
var useProfileActions = function () { return reducerActionsGenerator$1(auth.profileActions, auth.profileReducers); }; | ||
var useProfileState = function (stateMapper) { return stateHookGenerator(stateMapper, 'profileState'); }; | ||
var useProfileActions = function () { return reducerActionsGenerator(auth.profileActions, auth.profileReducers); }; | ||
var useSignUpState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'signUpState'); }; | ||
var useSignUpActions = function () { return reducerActionsGenerator$1(auth.signUpActions, auth.signUpReducers); }; | ||
var useSignUpState = function (stateMapper) { return stateHookGenerator(stateMapper, 'signUpState'); }; | ||
var useSignUpActions = function () { return reducerActionsGenerator(auth.signUpActions, auth.signUpReducers); }; | ||
var useSocialLoginState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'socialLoginState'); }; | ||
var useSocialLoginState = function (stateMapper) { return stateHookGenerator(stateMapper, 'socialLoginState'); }; | ||
var useSocialLoginActions = function () { | ||
return reducerActionsGenerator$1(auth.socialLoginsActions, auth.socialLoginsReducer); | ||
return reducerActionsGenerator(auth.socialLoginsActions, auth.socialLoginsReducer); | ||
}; | ||
var useAuthTeamState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'teamState'); }; | ||
var useAuthTeamActions = function () { return reducerActionsGenerator$1(auth.teamActions, auth.teamReducers); }; | ||
var useAuthTeamState = function (stateMapper) { return stateHookGenerator(stateMapper, 'teamState'); }; | ||
var useAuthTeamActions = function () { return reducerActionsGenerator(auth.teamActions, auth.teamReducers); }; | ||
var useSSOState = function (stateMapper) { | ||
return stateHookGenerator$1(stateMapper, 'ssoState'); | ||
return stateHookGenerator(stateMapper, 'ssoState'); | ||
}; | ||
var useSSOActions = function () { return reducerActionsGenerator$1(auth.ssoActions, auth.ssoReducers); }; | ||
var useSSOActions = function () { return reducerActionsGenerator(auth.ssoActions, auth.ssoReducers); }; | ||
var useSecurityPolicyState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'securityPolicyState'); }; | ||
var useSecurityPolicyState = function (stateMapper) { return stateHookGenerator(stateMapper, 'securityPolicyState'); }; | ||
var useSecurityPolicyActions = function () { | ||
return reducerActionsGenerator$1(auth.securityPolicyActions, auth.securityPolicyReducers); | ||
return reducerActionsGenerator(auth.securityPolicyActions, auth.securityPolicyReducers); | ||
}; | ||
var useTenantsState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'tenantsState'); }; | ||
var useTenantsActions = function () { return reducerActionsGenerator$1(auth.tenantsActions, auth.tenantsReducers); }; | ||
var useTenantsState = function (stateMapper) { return stateHookGenerator(stateMapper, 'tenantsState'); }; | ||
var useTenantsActions = function () { return reducerActionsGenerator(auth.tenantsActions, auth.tenantsReducers); }; | ||
var useRolesState = function (stateMapper) { | ||
return stateHookGenerator$1(stateMapper, 'rolesState'); | ||
return stateHookGenerator(stateMapper, 'rolesState'); | ||
}; | ||
var useRolesActions = function () { return reducerActionsGenerator$1(auth.rolesActions, auth.rolesReducers); }; | ||
var useRolesActions = function () { return reducerActionsGenerator(auth.rolesActions, auth.rolesReducers); }; | ||
@@ -236,4 +202,44 @@ var setLoading = function (loading) { | ||
}; | ||
var HideChildrenIfFronteggRoutes = function (_a) { | ||
var children = _a.children, basename = _a.basename; | ||
var routes = useAuthRoutes(); | ||
var uriRef = React.useRef(window.location.pathname); | ||
var _b = React.useState(window.location.pathname), uri = _b[0], setUri = _b[1]; | ||
React.useEffect(function () { | ||
document.addEventListener('frontegg_onRedirectTo_fired', function () { | ||
if (uriRef.current !== window.location.pathname) { | ||
uriRef.current = window.location.pathname; | ||
setUri(document.location.pathname); | ||
} | ||
}); | ||
window.addEventListener('popstate', function () { | ||
if (uriRef.current !== window.location.pathname) { | ||
uriRef.current = window.location.pathname; | ||
setUri(document.location.pathname); | ||
} | ||
}); | ||
setInterval(function () { | ||
if (uriRef.current !== window.location.pathname) { | ||
uriRef.current = window.location.pathname; | ||
setUri(document.location.pathname); | ||
} | ||
}, 50); | ||
}, [setUri]); | ||
var calculatedBasename = basename ? (basename.endsWith('/') ? basename.substring(0, basename.length - 1) : '') : ''; | ||
switch (uri) { | ||
case calculatedBasename + routes.loginUrl: | ||
case calculatedBasename + routes.logoutUrl: | ||
case calculatedBasename + routes.activateUrl: | ||
case calculatedBasename + routes.acceptInvitationUrl: | ||
case calculatedBasename + routes.forgetPasswordUrl: | ||
case calculatedBasename + routes.resetPasswordUrl: | ||
case calculatedBasename + routes.socialLoginCallbackUrl: | ||
case calculatedBasename + routes.signUpUrl: | ||
return null; | ||
} | ||
return React__default.createElement(React__default.Fragment, null, children); | ||
}; | ||
var FronteggContent = function (_a) { | ||
var children = _a.children, setLoading = _a.setLoading; | ||
var _b; | ||
var children = _a.children, app = _a.app, setLoading = _a.setLoading; | ||
var isLoading = useAuth(function (_a) { | ||
@@ -243,2 +249,3 @@ var isLoading = _a.isLoading; | ||
}).isLoading; | ||
var customLoginBox = app ? !!((_b = app.options) === null || _b === void 0 ? void 0 : _b.customLoginBox) : true; | ||
setLoading(isLoading); | ||
@@ -248,13 +255,81 @@ if (isLoading) { | ||
} | ||
return React__default.createElement(React__default.Fragment, null, children); | ||
if (customLoginBox) { | ||
return React__default.createElement(React__default.Fragment, null, children); | ||
} | ||
return React__default.createElement(HideChildrenIfFronteggRoutes, { basename: app === null || app === void 0 ? void 0 : app.options.basename }, children); | ||
}; | ||
var FronteggProvider = function (_a) { | ||
var _b, _c; | ||
var children = _a.children, app = _a.app, contextOptions = _a.contextOptions, setLoadingProps = _a.setLoading; | ||
var context = contextOptions !== null && contextOptions !== void 0 ? contextOptions : app.options.contextOptions; | ||
var context = (_c = (_b = app === null || app === void 0 ? void 0 : app.options) === null || _b === void 0 ? void 0 : _b.contextOptions) !== null && _c !== void 0 ? _c : contextOptions; | ||
restApi.ContextHolder.setContext(context); | ||
var store = React.useMemo(function () { return reduxStore.createFronteggStore({ context: context }, app); }, [app]); | ||
return (React__default.createElement(reactRedux.Provider, { store: store }, | ||
React__default.createElement(FronteggContent, { setLoading: setLoadingProps !== null && setLoadingProps !== void 0 ? setLoadingProps : setLoading }, children))); | ||
React__default.createElement(FronteggContent, { setLoading: setLoadingProps !== null && setLoadingProps !== void 0 ? setLoadingProps : setLoading, app: app }, children))); | ||
}; | ||
var useAuditsState = function (stateMapper) { | ||
return reactRedux.useSelector(function (state) { var _a; return (_a = stateMapper === null || stateMapper === void 0 ? void 0 : stateMapper(state[audits.auditsStoreName])) !== null && _a !== void 0 ? _a : state[audits.auditsStoreName]; }, reactRedux.shallowEqual); | ||
}; | ||
var useAuditsActions = function () { | ||
var dispatch = reactRedux.useDispatch(); | ||
return React.useMemo(function () { return toolkit.bindActionCreators(audits.auditsActions, dispatch); }, [audits.auditsActions]); | ||
}; | ||
/** | ||
* hooks helpers | ||
*/ | ||
var sliceReducerActionsBy$1 = function (reducer) { | ||
var reducerKeys = Object.keys(reducer); | ||
var reducerActions = reducerKeys.map(function (key) { | ||
var _a; | ||
return (_a = {}, _a[key] = audits.auditsActions[key], _a); | ||
}); | ||
return reducerActions.reduce(function (p, n) { return (__assign(__assign({}, p), n)); }, {}); | ||
}; | ||
var stateHookGenerator$1 = function (stateMapper, subState) { | ||
return reactRedux.useSelector(function (state) { var _a; return (_a = stateMapper === null || stateMapper === void 0 ? void 0 : stateMapper(state[audits.auditsStoreName][subState])) !== null && _a !== void 0 ? _a : state[audits.auditsStoreName][subState]; }, reactRedux.shallowEqual); | ||
}; | ||
var reducerActionsGenerator$1 = function (actions, reducers) { | ||
var dispatch = reactRedux.useDispatch(); | ||
return React.useMemo(function () { return toolkit.bindActionCreators(__assign(__assign({}, actions), sliceReducerActionsBy$1(reducers)), dispatch); }, [dispatch]); | ||
}; | ||
var useAuditLogsState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'auditLogsState'); }; | ||
var useAuditLogsActions = function () { return reducerActionsGenerator$1(reduxStore.auditLogsActions, reduxStore.auditLogsReducers); }; | ||
var useAuditsMetadataState = function (stateMapper) { return stateHookGenerator$1(stateMapper, 'auditsMetadataState'); }; | ||
var useAuditsMetadataActions = function () { | ||
return reducerActionsGenerator$1(audits.auditsMetadataActions, audits.auditsMetadataReducers); | ||
}; | ||
Object.defineProperty(exports, 'Provider', { | ||
enumerable: true, | ||
get: function () { | ||
return reactRedux.Provider; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'connect', { | ||
enumerable: true, | ||
get: function () { | ||
return reactRedux.connect; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'shallowEqual', { | ||
enumerable: true, | ||
get: function () { | ||
return reactRedux.shallowEqual; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'useDispatch', { | ||
enumerable: true, | ||
get: function () { | ||
return reactRedux.useDispatch; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'useSelector', { | ||
enumerable: true, | ||
get: function () { | ||
return reactRedux.useSelector; | ||
} | ||
}); | ||
exports.FronteggProvider = FronteggProvider; | ||
@@ -261,0 +336,0 @@ exports.reloadProfileIfNeeded = reloadProfileIfNeeded; |
68
index.js
import './tslib.es6-e3c82a74.js'; | ||
import React, { useMemo } from 'react'; | ||
import React, { useMemo, useRef, useState, useEffect } from 'react'; | ||
import '@frontegg/redux-store/toolkit'; | ||
import { Provider } from 'react-redux'; | ||
import '@frontegg/redux-store/toolkit'; | ||
export { Provider, connect, shallowEqual, useDispatch, useSelector } from 'react-redux'; | ||
import { createFronteggStore } from '@frontegg/redux-store'; | ||
import { ContextHolder } from '@frontegg/rest-api'; | ||
import '@frontegg/redux-store/auth'; | ||
import { ContextHolder } from '@frontegg/rest-api'; | ||
import { u as useAuth } from './roles-4dcae1ac.js'; | ||
export { s as reloadProfileIfNeeded, h as useAcceptInvitationActions, g as useAcceptInvitationState, j as useActivateAccountActions, i as useActivateAccountState, l as useApiTokensActions, k as useApiTokensState, u as useAuth, a as useAuthActions, c as useAuthRoutes, B as useAuthTeamActions, A as useAuthTeamState, e as useAuthUser, f as useAuthUserOrNull, n as useForgotPasswordActions, m as useForgotPasswordState, d as useIsAuthenticated, p as useLoginActions, o as useLoginState, r as useMfaActions, q as useMfaState, b as useOnRedirectTo, v as useProfileActions, t as useProfileState, J as useRolesActions, I as useRolesState, D as useSSOActions, C as useSSOState, F as useSecurityPolicyActions, E as useSecurityPolicyState, x as useSignUpActions, w as useSignUpState, z as useSocialLoginActions, y as useSocialLoginState, H as useTenantsActions, G as useTenantsState } from './roles-4dcae1ac.js'; | ||
import { u as useAuth, c as useAuthRoutes } from './roles-6446f670.js'; | ||
export { s as reloadProfileIfNeeded, h as useAcceptInvitationActions, g as useAcceptInvitationState, j as useActivateAccountActions, i as useActivateAccountState, l as useApiTokensActions, k as useApiTokensState, u as useAuth, a as useAuthActions, c as useAuthRoutes, B as useAuthTeamActions, A as useAuthTeamState, e as useAuthUser, f as useAuthUserOrNull, n as useForgotPasswordActions, m as useForgotPasswordState, d as useIsAuthenticated, p as useLoginActions, o as useLoginState, r as useMfaActions, q as useMfaState, b as useOnRedirectTo, v as useProfileActions, t as useProfileState, J as useRolesActions, I as useRolesState, D as useSSOActions, C as useSSOState, F as useSecurityPolicyActions, E as useSecurityPolicyState, x as useSignUpActions, w as useSignUpState, z as useSocialLoginActions, y as useSocialLoginState, H as useTenantsActions, G as useTenantsState } from './roles-6446f670.js'; | ||
import '@frontegg/redux-store/audits'; | ||
export { c as useAuditLogsActions, b as useAuditLogsState, a as useAuditsActions, e as useAuditsMetadataActions, d as useAuditsMetadataState, u as useAuditsState } from './auditsMetadata-22daf6f1.js'; | ||
import { createFronteggStore } from '@frontegg/redux-store'; | ||
export { c as useAuditLogsActions, b as useAuditLogsState, a as useAuditsActions, e as useAuditsMetadataActions, d as useAuditsMetadataState, u as useAuditsState } from './auditsMetadata-8a99c0b5.js'; | ||
@@ -24,4 +25,44 @@ var setLoading = function (loading) { | ||
}; | ||
var HideChildrenIfFronteggRoutes = function (_a) { | ||
var children = _a.children, basename = _a.basename; | ||
var routes = useAuthRoutes(); | ||
var uriRef = useRef(window.location.pathname); | ||
var _b = useState(window.location.pathname), uri = _b[0], setUri = _b[1]; | ||
useEffect(function () { | ||
document.addEventListener('frontegg_onRedirectTo_fired', function () { | ||
if (uriRef.current !== window.location.pathname) { | ||
uriRef.current = window.location.pathname; | ||
setUri(document.location.pathname); | ||
} | ||
}); | ||
window.addEventListener('popstate', function () { | ||
if (uriRef.current !== window.location.pathname) { | ||
uriRef.current = window.location.pathname; | ||
setUri(document.location.pathname); | ||
} | ||
}); | ||
setInterval(function () { | ||
if (uriRef.current !== window.location.pathname) { | ||
uriRef.current = window.location.pathname; | ||
setUri(document.location.pathname); | ||
} | ||
}, 50); | ||
}, [setUri]); | ||
var calculatedBasename = basename ? (basename.endsWith('/') ? basename.substring(0, basename.length - 1) : '') : ''; | ||
switch (uri) { | ||
case calculatedBasename + routes.loginUrl: | ||
case calculatedBasename + routes.logoutUrl: | ||
case calculatedBasename + routes.activateUrl: | ||
case calculatedBasename + routes.acceptInvitationUrl: | ||
case calculatedBasename + routes.forgetPasswordUrl: | ||
case calculatedBasename + routes.resetPasswordUrl: | ||
case calculatedBasename + routes.socialLoginCallbackUrl: | ||
case calculatedBasename + routes.signUpUrl: | ||
return null; | ||
} | ||
return React.createElement(React.Fragment, null, children); | ||
}; | ||
var FronteggContent = function (_a) { | ||
var children = _a.children, setLoading = _a.setLoading; | ||
var _b; | ||
var children = _a.children, app = _a.app, setLoading = _a.setLoading; | ||
var isLoading = useAuth(function (_a) { | ||
@@ -31,2 +72,3 @@ var isLoading = _a.isLoading; | ||
}).isLoading; | ||
var customLoginBox = app ? !!((_b = app.options) === null || _b === void 0 ? void 0 : _b.customLoginBox) : true; | ||
setLoading(isLoading); | ||
@@ -36,11 +78,15 @@ if (isLoading) { | ||
} | ||
return React.createElement(React.Fragment, null, children); | ||
if (customLoginBox) { | ||
return React.createElement(React.Fragment, null, children); | ||
} | ||
return React.createElement(HideChildrenIfFronteggRoutes, { basename: app === null || app === void 0 ? void 0 : app.options.basename }, children); | ||
}; | ||
var FronteggProvider = function (_a) { | ||
var _b, _c; | ||
var children = _a.children, app = _a.app, contextOptions = _a.contextOptions, setLoadingProps = _a.setLoading; | ||
var context = contextOptions !== null && contextOptions !== void 0 ? contextOptions : app.options.contextOptions; | ||
var context = (_c = (_b = app === null || app === void 0 ? void 0 : app.options) === null || _b === void 0 ? void 0 : _b.contextOptions) !== null && _c !== void 0 ? _c : contextOptions; | ||
ContextHolder.setContext(context); | ||
var store = useMemo(function () { return createFronteggStore({ context: context }, app); }, [app]); | ||
return (React.createElement(Provider, { store: store }, | ||
React.createElement(FronteggContent, { setLoading: setLoadingProps !== null && setLoadingProps !== void 0 ? setLoadingProps : setLoading }, children))); | ||
React.createElement(FronteggContent, { setLoading: setLoadingProps !== null && setLoadingProps !== void 0 ? setLoadingProps : setLoading, app: app }, children))); | ||
}; | ||
@@ -47,0 +93,0 @@ |
{ | ||
"name": "@frontegg/react-hooks", | ||
"libName": "FronteggReactHooks", | ||
"version": "2.1.1-alpha.773827200", | ||
"version": "2.1.1-alpha.775775142", | ||
"author": "Frontegg LTD", | ||
@@ -9,6 +9,5 @@ "module": "index.esm.js", | ||
"dependencies": { | ||
"@frontegg/redux-store": "2.1.1-alpha.773827200", | ||
"react-redux": "7.x" | ||
"@frontegg/redux-store": "2.1.1-alpha.775775142" | ||
}, | ||
"gitHead": "c97536e2a621653c6033703267a89cb40e4081e2", | ||
"gitHead": "611407a75dbe69ffddcf1891b4bae4f378225c94", | ||
"main": "index.js", | ||
@@ -15,0 +14,0 @@ "es2015": "index.es.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
129237
1
830
+ Added@frontegg/redux-store@2.1.1-alpha.775775142(transitive)
+ Added@frontegg/rest-api@2.1.1-alpha.775775142(transitive)
- Removedreact-redux@7.x
- Removed@babel/runtime@7.26.9(transitive)
- Removed@frontegg/redux-store@2.1.1-alpha.773827200(transitive)
- Removed@frontegg/rest-api@2.1.1-alpha.773827200(transitive)
- Removed@redux-saga/core@1.3.0(transitive)
- Removed@redux-saga/deferred@1.2.1(transitive)
- Removed@redux-saga/delay-p@1.2.1(transitive)
- Removed@redux-saga/is@1.1.3(transitive)
- Removed@redux-saga/symbols@1.1.3(transitive)
- Removed@redux-saga/types@1.2.1(transitive)
- Removed@reduxjs/toolkit@1.9.7(transitive)
- Removed@types/hoist-non-react-statics@3.3.6(transitive)
- Removed@types/react@19.0.10(transitive)
- Removed@types/react-redux@7.1.34(transitive)
- Removedcsstype@3.1.3(transitive)
- Removedhoist-non-react-statics@3.3.2(transitive)
- Removedimmer@9.0.21(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedprop-types@15.8.1(transitive)
- Removedreact@18.3.1(transitive)
- Removedreact-is@16.13.117.0.2(transitive)
- Removedreact-redux@7.2.9(transitive)
- Removedredux@4.2.1(transitive)
- Removedredux-saga@1.3.0(transitive)
- Removedredux-thunk@2.4.2(transitive)
- Removedregenerator-runtime@0.14.1(transitive)
- Removedreselect@4.1.8(transitive)
- Removedtypescript-compare@0.0.2(transitive)
- Removedtypescript-logic@0.0.0(transitive)
- Removedtypescript-tuple@2.2.1(transitive)