@frontegg/react-hooks 6.96.0 → 6.97.0-alpha.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.
@@ -4,3 +4,7 @@ export declare type CustomLoginStateMapper<S> = (state: CustomLoginState) => S;
4
4
  export declare function useCustomLoginState(): CustomLoginState;
5
5
  export declare function useCustomLoginState<S>(stateMapper: CustomLoginStateMapper<S>): S;
6
6
  export declare const useCustomLoginActions: () => CustomLoginActions;
7
+ export declare const useCustomLoginTheme: () => {
8
+ customLoginTheme: import("@frontegg/types").LoginBoxThemeOptions | undefined;
9
+ getCustomLoginThemeValue: (path?: string | undefined) => any;
10
+ };
@@ -1,7 +1,23 @@
1
1
  import { customLoginActions, customLoginReducers } from '@frontegg/redux-store';
2
2
  import { reducerActionsGenerator, stateHookGenerator } from './hooks';
3
+ import getValue from 'get-value';
4
+ import { useCallback } from 'react';
3
5
  const defaultMapper = state => state;
4
6
  export function useCustomLoginState(stateMapper = defaultMapper) {
5
7
  return stateHookGenerator(stateMapper, 'customLoginState');
6
8
  }
7
- export const useCustomLoginActions = () => reducerActionsGenerator(customLoginActions, customLoginReducers);
9
+ export const useCustomLoginActions = () => reducerActionsGenerator(customLoginActions, customLoginReducers);
10
+ const themeMapper = state => {
11
+ var _state$tenantMetadata, _state$tenantMetadata2, _state$tenantMetadata3;
12
+ return (_state$tenantMetadata = state.tenantMetadata) == null ? void 0 : (_state$tenantMetadata2 = _state$tenantMetadata.configuration) == null ? void 0 : (_state$tenantMetadata3 = _state$tenantMetadata2.themeV2) == null ? void 0 : _state$tenantMetadata3.loginBox;
13
+ };
14
+ export const useCustomLoginTheme = () => {
15
+ const customLoginTheme = useCustomLoginState(themeMapper);
16
+ const getCustomLoginThemeValue = useCallback(path => {
17
+ return path && customLoginTheme ? getValue(customLoginTheme, path) : customLoginTheme;
18
+ }, [customLoginTheme]);
19
+ return {
20
+ customLoginTheme,
21
+ getCustomLoginThemeValue
22
+ };
23
+ };
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.96.0
1
+ /** @license Frontegg v6.97.0-alpha.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.
@@ -1,15 +1,34 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.useCustomLoginActions = void 0;
7
8
  exports.useCustomLoginState = useCustomLoginState;
9
+ exports.useCustomLoginTheme = void 0;
8
10
  var _reduxStore = require("@frontegg/redux-store");
9
11
  var _hooks = require("./hooks");
12
+ var _getValue = _interopRequireDefault(require("get-value"));
13
+ var _react = require("react");
10
14
  const defaultMapper = state => state;
11
15
  function useCustomLoginState(stateMapper = defaultMapper) {
12
16
  return (0, _hooks.stateHookGenerator)(stateMapper, 'customLoginState');
13
17
  }
14
18
  const useCustomLoginActions = () => (0, _hooks.reducerActionsGenerator)(_reduxStore.customLoginActions, _reduxStore.customLoginReducers);
15
- exports.useCustomLoginActions = useCustomLoginActions;
19
+ exports.useCustomLoginActions = useCustomLoginActions;
20
+ const themeMapper = state => {
21
+ var _state$tenantMetadata, _state$tenantMetadata2, _state$tenantMetadata3;
22
+ return (_state$tenantMetadata = state.tenantMetadata) == null ? void 0 : (_state$tenantMetadata2 = _state$tenantMetadata.configuration) == null ? void 0 : (_state$tenantMetadata3 = _state$tenantMetadata2.themeV2) == null ? void 0 : _state$tenantMetadata3.loginBox;
23
+ };
24
+ const useCustomLoginTheme = () => {
25
+ const customLoginTheme = useCustomLoginState(themeMapper);
26
+ const getCustomLoginThemeValue = (0, _react.useCallback)(path => {
27
+ return path && customLoginTheme ? (0, _getValue.default)(customLoginTheme, path) : customLoginTheme;
28
+ }, [customLoginTheme]);
29
+ return {
30
+ customLoginTheme,
31
+ getCustomLoginThemeValue
32
+ };
33
+ };
34
+ exports.useCustomLoginTheme = useCustomLoginTheme;
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.96.0
1
+ /** @license Frontegg v6.97.0-alpha.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.
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@frontegg/react-hooks",
3
- "version": "6.96.0",
3
+ "version": "6.97.0-alpha.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.96.0",
10
- "@frontegg/types": "6.96.0",
9
+ "@frontegg/redux-store": "6.97.0-alpha.0",
10
+ "@frontegg/types": "6.97.0-alpha.0",
11
11
  "@types/react": "*",
12
12
  "react-redux": "^7.x"
13
13
  },