@frontegg/react-hooks 6.2.5 → 6.5.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.
Files changed (85) hide show
  1. package/FronteggProvider.js +1 -3
  2. package/FronteggStoreContext.d.ts +11 -6
  3. package/FronteggStoreContext.js +3 -2
  4. package/audits/auditLogs.d.ts +3 -3
  5. package/audits/auditLogs.js +6 -1
  6. package/audits/auditsMetadata.d.ts +3 -3
  7. package/audits/auditsMetadata.js +7 -2
  8. package/audits/hooks.d.ts +7 -2
  9. package/audits/hooks.js +8 -8
  10. package/auth/acceptInvitation.d.ts +3 -3
  11. package/auth/acceptInvitation.js +6 -1
  12. package/auth/activateAccount.d.ts +3 -3
  13. package/auth/activateAccount.js +6 -1
  14. package/auth/apiTokens.d.ts +3 -3
  15. package/auth/apiTokens.js +6 -1
  16. package/auth/forgotPassword.d.ts +3 -3
  17. package/auth/forgotPassword.js +6 -1
  18. package/auth/hooks.d.ts +4 -4
  19. package/auth/hooks.js +2 -2
  20. package/auth/login.d.ts +3 -3
  21. package/auth/login.js +6 -1
  22. package/auth/mfa.d.ts +4 -2
  23. package/auth/mfa.js +6 -1
  24. package/auth/profile.d.ts +3 -3
  25. package/auth/profile.js +6 -1
  26. package/auth/resetPhoneNumber.d.ts +3 -3
  27. package/auth/resetPhoneNumber.js +6 -1
  28. package/auth/roles.d.ts +3 -3
  29. package/auth/roles.js +6 -1
  30. package/auth/securityPolicy.d.ts +3 -3
  31. package/auth/securityPolicy.js +6 -1
  32. package/auth/sessions.d.ts +3 -3
  33. package/auth/sessions.js +6 -1
  34. package/auth/sessionsPolicy.d.ts +4 -5
  35. package/auth/sessionsPolicy.js +6 -1
  36. package/auth/signup.d.ts +3 -3
  37. package/auth/signup.js +6 -1
  38. package/auth/socialLogin.d.ts +3 -3
  39. package/auth/socialLogin.js +6 -1
  40. package/auth/sso.d.ts +4 -2
  41. package/auth/sso.js +6 -1
  42. package/auth/team.d.ts +3 -3
  43. package/auth/team.js +6 -1
  44. package/auth/tenants.d.ts +3 -3
  45. package/auth/tenants.js +6 -1
  46. package/connectivity/hooks.d.ts +3 -2
  47. package/connectivity/hooks.js +5 -6
  48. package/flags/index.d.ts +1 -0
  49. package/flags/index.js +1 -0
  50. package/flags/package.json +6 -0
  51. package/flags/useFeatureFlags.d.ts +1 -0
  52. package/flags/useFeatureFlags.js +10 -0
  53. package/index.d.ts +1 -0
  54. package/index.js +2 -1
  55. package/node/FronteggProvider.js +1 -5
  56. package/node/FronteggStoreContext.js +4 -8
  57. package/node/audits/auditLogs.js +6 -3
  58. package/node/audits/auditsMetadata.js +8 -5
  59. package/node/audits/hooks.js +10 -10
  60. package/node/auth/acceptInvitation.js +6 -3
  61. package/node/auth/activateAccount.js +6 -3
  62. package/node/auth/apiTokens.js +6 -3
  63. package/node/auth/forgotPassword.js +6 -3
  64. package/node/auth/hooks.js +5 -5
  65. package/node/auth/login.js +6 -3
  66. package/node/auth/mfa.js +6 -3
  67. package/node/auth/profile.js +6 -3
  68. package/node/auth/resetPhoneNumber.js +6 -3
  69. package/node/auth/roles.js +6 -3
  70. package/node/auth/securityPolicy.js +6 -3
  71. package/node/auth/sessions.js +6 -3
  72. package/node/auth/sessionsPolicy.js +6 -3
  73. package/node/auth/signup.js +6 -3
  74. package/node/auth/socialLogin.js +6 -3
  75. package/node/auth/sso.js +6 -3
  76. package/node/auth/team.js +6 -3
  77. package/node/auth/tenants.js +6 -3
  78. package/node/connectivity/hooks.js +6 -9
  79. package/node/flags/index.js +18 -0
  80. package/node/flags/useFeatureFlags.js +20 -0
  81. package/node/index.js +14 -1
  82. package/node/vendor/hooks.js +6 -9
  83. package/package.json +4 -4
  84. package/vendor/hooks.d.ts +3 -2
  85. package/vendor/hooks.js +5 -6
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useConnectivityState = exports.useConnectivityActions = void 0;
6
+ exports.useConnectivityActions = void 0;
7
+ exports.useConnectivityState = useConnectivityState;
7
8
 
8
9
  var _react = require("react");
9
10
 
@@ -13,15 +14,11 @@ var _FronteggStoreContext = require("../FronteggStoreContext");
13
14
 
14
15
  var _reduxStore = require("@frontegg/redux-store");
15
16
 
16
- const useConnectivityState = stateMapper => {
17
- return (0, _FronteggStoreContext.useSelector)(state => {
18
- var _stateMapper;
19
-
20
- return (_stateMapper = stateMapper == null ? void 0 : stateMapper(state[_reduxStore.connectivityStoreName])) != null ? _stateMapper : state[_reduxStore.connectivityStoreName];
21
- }, _reactRedux.shallowEqual);
22
- };
17
+ const defaultMapper = state => state;
23
18
 
24
- exports.useConnectivityState = useConnectivityState;
19
+ function useConnectivityState(stateMapper = defaultMapper) {
20
+ return (0, _FronteggStoreContext.useSelector)(state => stateMapper(state[_reduxStore.connectivityStoreName]), _reactRedux.shallowEqual);
21
+ }
25
22
 
26
23
  const useConnectivityActions = () => {
27
24
  const dispatch = (0, _FronteggStoreContext.useDispatch)();
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _useFeatureFlags = require("./useFeatureFlags");
8
+
9
+ Object.keys(_useFeatureFlags).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _useFeatureFlags[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _useFeatureFlags[key];
16
+ }
17
+ });
18
+ });
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useFeatureFlags = void 0;
7
+
8
+ var _common = require("../common");
9
+
10
+ const useFeatureFlags = (...flags) => {
11
+ var _injector$flags;
12
+
13
+ const {
14
+ injector
15
+ } = (0, _common.useShadowDom)();
16
+ const featureFlags = (_injector$flags = injector.flags) != null ? _injector$flags : {};
17
+ return flags.map(flag => featureFlags[flag] === 'on');
18
+ };
19
+
20
+ exports.useFeatureFlags = useFeatureFlags;
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.2.5
1
+ /** @license Frontegg v6.5.0
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -87,6 +87,19 @@ Object.keys(_vendor).forEach(function (key) {
87
87
  });
88
88
  });
89
89
 
90
+ var _flags = require("./flags");
91
+
92
+ Object.keys(_flags).forEach(function (key) {
93
+ if (key === "default" || key === "__esModule") return;
94
+ if (key in exports && exports[key] === _flags[key]) return;
95
+ Object.defineProperty(exports, key, {
96
+ enumerable: true,
97
+ get: function () {
98
+ return _flags[key];
99
+ }
100
+ });
101
+ });
102
+
90
103
  var _FronteggProvider = require("./FronteggProvider");
91
104
 
92
105
  Object.keys(_FronteggProvider).forEach(function (key) {
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useVendorState = exports.useVendorActions = void 0;
6
+ exports.useVendorActions = void 0;
7
+ exports.useVendorState = useVendorState;
7
8
 
8
9
  var _react = require("react");
9
10
 
@@ -13,15 +14,11 @@ var _reactRedux = require("react-redux");
13
14
 
14
15
  var _FronteggStoreContext = require("../FronteggStoreContext");
15
16
 
16
- const useVendorState = stateMapper => {
17
- return (0, _FronteggStoreContext.useSelector)(state => {
18
- var _stateMapper;
19
-
20
- return (_stateMapper = stateMapper == null ? void 0 : stateMapper(state[_reduxStore.vendorStoreName])) != null ? _stateMapper : state[_reduxStore.vendorStoreName];
21
- }, _reactRedux.shallowEqual);
22
- };
17
+ const defaultMapper = state => state;
23
18
 
24
- exports.useVendorState = useVendorState;
19
+ function useVendorState(stateMapper = defaultMapper) {
20
+ return (0, _FronteggStoreContext.useSelector)(state => stateMapper(state[_reduxStore.vendorStoreName]), _reactRedux.shallowEqual);
21
+ }
25
22
 
26
23
  const useVendorActions = () => {
27
24
  const dispatch = (0, _FronteggStoreContext.useDispatch)();
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@frontegg/react-hooks",
3
- "version": "6.2.5",
3
+ "version": "6.5.0",
4
4
  "main": "./node/index.js",
5
5
  "license": "MIT",
6
6
  "author": "Frontegg LTD",
7
7
  "dependencies": {
8
- "@babel/runtime": "^7.17.2",
9
- "@frontegg/redux-store": "6.2.5",
10
- "@frontegg/types": "6.2.5",
8
+ "@babel/runtime": "^7.18.6",
9
+ "@frontegg/redux-store": "6.5.0",
10
+ "@frontegg/types": "6.5.0",
11
11
  "@types/react": "*",
12
12
  "react-redux": "^7.x"
13
13
  },
package/vendor/hooks.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { VendorActions, VendorState } from '@frontegg/redux-store';
2
- export declare type VendorStateMapper<S extends object> = (state: VendorState) => S;
2
+ export declare type VendorStateMapper<S> = (state: VendorState) => S;
3
3
  export declare type StateHookFunction<T> = (() => T) & (<S extends object>(mapper: (state: T) => S) => S);
4
- export declare const useVendorState: <S extends object>(stateMapper?: VendorStateMapper<S> | undefined) => S;
4
+ export declare function useVendorState(): VendorState;
5
+ export declare function useVendorState<S>(stateMapper: VendorStateMapper<S>): S;
5
6
  export declare const useVendorActions: () => VendorActions;
package/vendor/hooks.js CHANGED
@@ -2,13 +2,12 @@ import { useMemo } from 'react';
2
2
  import { bindActionCreators, vendorActions, vendorStoreName } from '@frontegg/redux-store';
3
3
  import { shallowEqual } from 'react-redux';
4
4
  import { useSelector, useDispatch } from '../FronteggStoreContext';
5
- export const useVendorState = stateMapper => {
6
- return useSelector(state => {
7
- var _stateMapper;
8
5
 
9
- return (_stateMapper = stateMapper == null ? void 0 : stateMapper(state[vendorStoreName])) != null ? _stateMapper : state[vendorStoreName];
10
- }, shallowEqual);
11
- };
6
+ const defaultMapper = state => state;
7
+
8
+ export function useVendorState(stateMapper = defaultMapper) {
9
+ return useSelector(state => stateMapper(state[vendorStoreName]), shallowEqual);
10
+ }
12
11
  export const useVendorActions = () => {
13
12
  const dispatch = useDispatch();
14
13
  return useMemo(() => bindActionCreators(vendorActions, dispatch), [vendorActions]);