@elliemae/ds-left-navigation 2.0.0-next.7 → 2.0.0-rc.10
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/cjs/LeftNavigationContext.js +0 -4
- package/cjs/common/getLeftBorderStyle.js +2 -2
- package/cjs/common/index.js +0 -2
- package/cjs/configs/useLeftNavConfig.js +13 -21
- package/cjs/configs/useLeftNavItems.js +7 -7
- package/cjs/exported-related/ChevronItem/index.js +7 -3
- package/cjs/exported-related/Icon/index.js +5 -0
- package/cjs/exported-related/ItemRenderer/index.js +4 -5
- package/cjs/exported-related/ItemRenderer/styled.js +27 -17
- package/cjs/exported-related/ItemRenderer/usePropsWithDefaults.js +5 -0
- package/cjs/exported-related/Notifications/index.js +41 -41
- package/cjs/exported-related/OpenWindowItem/index.js +7 -3
- package/cjs/hooks/useExpandableOnClickHandler.js +7 -6
- package/cjs/hooks/useKeyboardNavigation.js +7 -7
- package/cjs/hooks/useOpenableOnClickHandler.js +8 -7
- package/cjs/hooks/useSelectFirstBodyItem.js +13 -3
- package/cjs/outOfTheBox/ItemControlledDrilldown/index.js +17 -16
- package/cjs/outOfTheBox/ItemControlledDrilldown/styled.js +7 -4
- package/cjs/outOfTheBox/ItemHeader/index.js +20 -13
- package/cjs/outOfTheBox/ItemHeader/styled.js +3 -4
- package/cjs/outOfTheBox/ItemLink/index.js +18 -14
- package/cjs/outOfTheBox/ItemSection/index.js +6 -6
- package/cjs/outOfTheBox/ItemSeparator/index.js +6 -6
- package/cjs/outOfTheBox/ItemSubmenu/index.js +12 -12
- package/cjs/outOfTheBox/ItemSubmenu/styled.js +3 -4
- package/cjs/outOfTheBox/ItemTextLabel/index.js +11 -9
- package/cjs/outOfTheBox/ItemTextLabel/styled.js +7 -4
- package/cjs/outOfTheBox/ItemUncontrolledDrilldown/index.js +12 -13
- package/cjs/outOfTheBox/ItemUncontrolledDrilldown/styled.js +7 -4
- package/cjs/outOfTheBox/ItemWithDate/index.js +9 -8
- package/cjs/outOfTheBox/ItemWithDate/styled.js +7 -4
- package/cjs/outOfTheBox/index.js +6 -6
- package/cjs/parts/LeftNavContent/index.js +2 -0
- package/cjs/parts/LeftNavContent/styled.js +9 -6
- package/cjs/parts/LeftNavContentWithScrollbar/index.js +6 -1
- package/cjs/parts/LeftNavFooterItem/index.js +2 -11
- package/cjs/parts/LeftNavFooterItem/styled.js +8 -9
- package/cjs/parts/LeftNavLoading/index.js +13 -10
- package/cjs/parts/OutOfTheBoxMapItem.js +5 -0
- package/esm/LeftNavigationContext.js +0 -4
- package/esm/common/getLeftBorderStyle.js +2 -2
- package/esm/common/index.js +0 -1
- package/esm/configs/useLeftNavConfig.js +13 -21
- package/esm/configs/useLeftNavItems.js +7 -7
- package/esm/exported-related/ChevronItem/index.js +7 -2
- package/esm/exported-related/Icon/index.js +5 -0
- package/esm/exported-related/ItemRenderer/index.js +4 -5
- package/esm/exported-related/ItemRenderer/styled.js +27 -18
- package/esm/exported-related/ItemRenderer/usePropsWithDefaults.js +5 -0
- package/esm/exported-related/Notifications/index.js +41 -37
- package/esm/exported-related/OpenWindowItem/index.js +7 -2
- package/esm/hooks/useExpandableOnClickHandler.js +7 -6
- package/esm/hooks/useKeyboardNavigation.js +7 -7
- package/esm/hooks/useOpenableOnClickHandler.js +8 -7
- package/esm/hooks/useSelectFirstBodyItem.js +13 -3
- package/esm/outOfTheBox/ItemControlledDrilldown/index.js +14 -11
- package/esm/outOfTheBox/ItemControlledDrilldown/styled.js +7 -4
- package/esm/outOfTheBox/ItemHeader/index.js +20 -13
- package/esm/outOfTheBox/ItemHeader/styled.js +3 -3
- package/esm/outOfTheBox/ItemLink/index.js +18 -14
- package/esm/outOfTheBox/ItemSection/index.js +6 -6
- package/esm/outOfTheBox/ItemSeparator/index.js +6 -6
- package/esm/outOfTheBox/ItemSubmenu/index.js +12 -12
- package/esm/outOfTheBox/ItemSubmenu/styled.js +3 -3
- package/esm/outOfTheBox/ItemTextLabel/index.js +11 -9
- package/esm/outOfTheBox/ItemTextLabel/styled.js +7 -4
- package/esm/outOfTheBox/ItemUncontrolledDrilldown/index.js +11 -10
- package/esm/outOfTheBox/ItemUncontrolledDrilldown/styled.js +7 -4
- package/esm/outOfTheBox/ItemWithDate/index.js +9 -8
- package/esm/outOfTheBox/ItemWithDate/styled.js +7 -4
- package/esm/outOfTheBox/index.js +6 -6
- package/esm/parts/LeftNavContent/index.js +2 -0
- package/esm/parts/LeftNavContent/styled.js +9 -6
- package/esm/parts/LeftNavContentWithScrollbar/index.js +6 -1
- package/esm/parts/LeftNavFooterItem/index.js +1 -9
- package/esm/parts/LeftNavFooterItem/styled.js +3 -4
- package/esm/parts/LeftNavLoading/index.js +13 -10
- package/esm/parts/OutOfTheBoxMapItem.js +5 -0
- package/package.json +12 -17
- package/types/LeftNavigation.d.ts +43 -11
- package/types/LeftNavigationContext.d.ts +0 -4
- package/types/common/index.d.ts +0 -1
- package/types/exported-related/ItemRenderer/styled.d.ts +3 -2
- package/types/hooks/useKeyboardNavigation.d.ts +1 -1
- package/types/hooks/useSelectFirstBodyItem.d.ts +1 -1
- package/types/index.d.d.ts +5 -2
- package/types/outOfTheBox/ItemControlledDrilldown/styled.d.ts +2 -2
- package/types/outOfTheBox/ItemHeader/styled.d.ts +2 -2
- package/types/outOfTheBox/ItemLink/styled.d.ts +1 -1
- package/types/outOfTheBox/ItemSection/styled.d.ts +3 -3
- package/types/outOfTheBox/ItemSubmenu/styled.d.ts +2 -2
- package/types/outOfTheBox/ItemTextLabel/styled.d.ts +1 -1
- package/types/outOfTheBox/ItemUncontrolledDrilldown/styled.d.ts +2 -2
- package/types/outOfTheBox/ItemWithDate/styled.d.ts +2 -2
- package/types/parts/LeftNavContent/styled.d.ts +7 -11
- package/types/parts/LeftNavFooterItem/styled.d.ts +10 -6
- package/types/prop-types.d.ts +84 -18
- package/cjs/common/getFocusedByKeyboardStyle.js +0 -12
- package/cjs/configs/useGlobalKeyListeners.js +0 -31
- package/esm/common/getFocusedByKeyboardStyle.js +0 -8
- package/esm/configs/useGlobalKeyListeners.js +0 -22
- package/types/common/getFocusedByKeyboardStyle.d.ts +0 -4
- package/types/configs/useGlobalKeyListeners.d.ts +0 -6
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const StyledLabel: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("react").RefAttributes<
|
|
2
|
+
export declare const StyledLabel: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@elliemae/ds-grid/types/types").GridPropsT & import("react").RefAttributes<HTMLDivElement>>, import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const StyledLabel: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("react").RefAttributes<
|
|
2
|
+
export declare const StyledLabel: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@elliemae/ds-grid/types/types").GridPropsT & import("react").RefAttributes<HTMLDivElement>>, import("styled-components").DefaultTheme, {
|
|
3
3
|
labelBold: boolean;
|
|
4
4
|
}, never>;
|
|
5
|
-
export declare const StyledDate: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("react").RefAttributes<
|
|
5
|
+
export declare const StyledDate: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@elliemae/ds-grid/types/types").GridPropsT & import("react").RefAttributes<HTMLDivElement>>, import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const StyledLabel: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("react").RefAttributes<
|
|
2
|
+
export declare const StyledLabel: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@elliemae/ds-grid/types/types").GridPropsT & import("react").RefAttributes<HTMLDivElement>>, import("styled-components").DefaultTheme, {
|
|
3
3
|
labelBold: boolean;
|
|
4
4
|
}, never>;
|
|
5
|
-
export declare const StyledDate: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("react").RefAttributes<
|
|
5
|
+
export declare const StyledDate: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@elliemae/ds-grid/types/types").GridPropsT & import("react").RefAttributes<HTMLDivElement>>, import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -2,17 +2,13 @@ declare type LeftNavProps = {
|
|
|
2
2
|
expanded: boolean;
|
|
3
3
|
expandedWidth: string;
|
|
4
4
|
};
|
|
5
|
-
export declare const StyledLeftNavExpandAnimationWrapper: import("styled-components").StyledComponent<"nav",
|
|
6
|
-
export declare const StyledLeftNavAreasContainer: import("styled-components").StyledComponent<"div",
|
|
7
|
-
export declare const StyledLeftNavHeaderArea: import("styled-components").StyledComponent<"div",
|
|
5
|
+
export declare const StyledLeftNavExpandAnimationWrapper: import("styled-components").StyledComponent<"nav", import("styled-components").DefaultTheme, LeftNavProps, never>;
|
|
6
|
+
export declare const StyledLeftNavAreasContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, LeftNavProps, never>;
|
|
7
|
+
export declare const StyledLeftNavHeaderArea: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
8
|
+
export declare const StyledLeftNavBodyAreasContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
9
|
+
export declare const StyledLeftNavBodyHeaderArea: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
10
|
+
export declare const StyledLeftNavBodyItemsArea: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
8
11
|
selected: boolean;
|
|
9
12
|
}, never>;
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const StyledLeftNavBodyHeaderArea: import("styled-components").StyledComponent<"div", any, {
|
|
12
|
-
selected: boolean;
|
|
13
|
-
}, never>;
|
|
14
|
-
export declare const StyledLeftNavBodyItemsArea: import("styled-components").StyledComponent<"div", any, {
|
|
15
|
-
selected: boolean;
|
|
16
|
-
}, never>;
|
|
17
|
-
export declare const StyledLeftNavFooterArea: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
13
|
+
export declare const StyledLeftNavFooterArea: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
18
14
|
export {};
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const StyledFooterMenu: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("react").RefAttributes<
|
|
2
|
+
export declare const StyledFooterMenu: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@elliemae/ds-grid/types/types").GridPropsT & import("react").RefAttributes<HTMLDivElement>>, import("styled-components").DefaultTheme, {
|
|
3
3
|
theme: any;
|
|
4
4
|
selected: boolean;
|
|
5
5
|
}, never>;
|
|
6
|
-
export declare const StyledItemWrapper: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("react").RefAttributes<
|
|
7
|
-
export declare const StyledItem: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("react").RefAttributes<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
export declare const StyledItemWrapper: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@elliemae/ds-grid/types/types").GridPropsT & import("react").RefAttributes<HTMLDivElement>>, import("styled-components").DefaultTheme, {}, never>;
|
|
7
|
+
export declare const StyledItem: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@elliemae/ds-grid/types/types").GridPropsT & import("react").RefAttributes<HTMLDivElement>>, import("styled-components").DefaultTheme, {
|
|
8
|
+
theme: any;
|
|
9
|
+
selected: boolean;
|
|
10
|
+
opened: boolean;
|
|
11
|
+
}, never>;
|
|
12
|
+
export declare const StyledLabel: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@elliemae/ds-grid/types/types").GridPropsT & import("react").RefAttributes<HTMLDivElement>>, import("styled-components").DefaultTheme, {}, never>;
|
|
13
|
+
export declare const StyledSeparator: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@elliemae/ds-grid/types/types").GridPropsT & import("react").RefAttributes<HTMLDivElement>>, import("styled-components").DefaultTheme, {}, never>;
|
|
14
|
+
export declare const StyledMenuCollapse: import("styled-components").StyledComponent<(rest: any) => JSX.Element, import("styled-components").DefaultTheme, {}, never>;
|
package/types/prop-types.d.ts
CHANGED
|
@@ -1,22 +1,88 @@
|
|
|
1
|
+
/// <reference path="../../../../shared/typings/react-desc.d.ts" />
|
|
2
|
+
/// <reference types="react" />
|
|
1
3
|
export declare const leftNavItemProps: {
|
|
2
|
-
type:
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
type: {
|
|
5
|
+
defaultValue<T = unknown>(arg: T): {
|
|
6
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
7
|
+
};
|
|
8
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
9
|
+
};
|
|
10
|
+
dsId: {
|
|
11
|
+
defaultValue<T = unknown>(arg: T): {
|
|
12
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
13
|
+
};
|
|
14
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
15
|
+
};
|
|
16
|
+
Component: {
|
|
17
|
+
defaultValue<T = unknown>(arg: T): {
|
|
18
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
19
|
+
};
|
|
20
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
21
|
+
};
|
|
22
|
+
CollapsedComponent: {
|
|
23
|
+
defaultValue<T = unknown>(arg: T): {
|
|
24
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
25
|
+
};
|
|
26
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
27
|
+
};
|
|
28
|
+
itemOpts: {
|
|
29
|
+
defaultValue<T = unknown>(arg: T): {
|
|
30
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
31
|
+
};
|
|
32
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
33
|
+
};
|
|
7
34
|
};
|
|
8
35
|
export declare const leftNavigationProps: {
|
|
9
|
-
containerProps:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
36
|
+
containerProps: {
|
|
37
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
38
|
+
};
|
|
39
|
+
expanded: {
|
|
40
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
41
|
+
};
|
|
42
|
+
loading: {
|
|
43
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
44
|
+
};
|
|
45
|
+
tabIndex: {
|
|
46
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
47
|
+
};
|
|
48
|
+
openedItem: {
|
|
49
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
50
|
+
};
|
|
51
|
+
footerLabel: {
|
|
52
|
+
defaultValue<T = unknown>(arg: T): {
|
|
53
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
54
|
+
};
|
|
55
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
56
|
+
};
|
|
57
|
+
onFooterExpand: {
|
|
58
|
+
defaultValue<T = unknown>(arg: T): {
|
|
59
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
60
|
+
};
|
|
61
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
62
|
+
};
|
|
63
|
+
onFooterClose: {
|
|
64
|
+
defaultValue<T = unknown>(arg: T): {
|
|
65
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
66
|
+
};
|
|
67
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
68
|
+
};
|
|
69
|
+
onSelectedChange: {
|
|
70
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
71
|
+
};
|
|
72
|
+
onFocusChange: {
|
|
73
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
74
|
+
};
|
|
75
|
+
items: {
|
|
76
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
export declare const LeftNavItemPropsSchema: {
|
|
80
|
+
(props?: unknown): JSX.Element;
|
|
81
|
+
propTypes: unknown;
|
|
82
|
+
toTypescript: () => import("react-desc").TypescriptSchema;
|
|
83
|
+
};
|
|
84
|
+
export declare const LeftNavItemOptionsSchema: {
|
|
85
|
+
(props?: unknown): JSX.Element;
|
|
86
|
+
propTypes: unknown;
|
|
87
|
+
toTypescript: () => import("react-desc").TypescriptSchema;
|
|
20
88
|
};
|
|
21
|
-
export declare const LeftNavItemPropsSchema: any;
|
|
22
|
-
export declare const LeftNavItemOptionsSchema: any;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const commonFocusedByKeyboardBorder = (props, height, width) => "\n &:before {\n content: '';\n position: absolute;\n height: ".concat(height, ";\n width: ").concat(width, ";\n top: 0;\n left: 0px;\n border: 1px solid ").concat(props.theme.colors.brand[600], ";\n pointer-events: none;\n }\n");
|
|
6
|
-
|
|
7
|
-
const getFocusedByKeyboardBorderStyle = (props, height = '100%', width = '100%') => {
|
|
8
|
-
if (props.focused && props.focusedByKey) return commonFocusedByKeyboardBorder(props, height, width);
|
|
9
|
-
return '';
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
exports.getFocusedByKeyboardBorderStyle = getFocusedByKeyboardBorderStyle;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
|
|
7
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
-
|
|
9
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
|
-
|
|
11
|
-
const useGlobalKeyListeners = opts => {
|
|
12
|
-
const {
|
|
13
|
-
setFocusedByKey
|
|
14
|
-
} = opts;
|
|
15
|
-
React__default["default"].useEffect(() => {
|
|
16
|
-
const isKey = () => setFocusedByKey(true);
|
|
17
|
-
|
|
18
|
-
const isClick = () => setFocusedByKey(false); // To track wheter it's keyboard focus to apply the necessary style
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
window.addEventListener('keydown', isKey);
|
|
22
|
-
window.addEventListener('mousedown', isClick);
|
|
23
|
-
return () => {
|
|
24
|
-
window.removeEventListener('keydown', isKey);
|
|
25
|
-
window.removeEventListener('mousedown', isClick);
|
|
26
|
-
};
|
|
27
|
-
}, [setFocusedByKey]);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
exports["default"] = useGlobalKeyListeners;
|
|
31
|
-
exports.useGlobalKeyListeners = useGlobalKeyListeners;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
const commonFocusedByKeyboardBorder = (props, height, width) => "\n &:before {\n content: '';\n position: absolute;\n height: ".concat(height, ";\n width: ").concat(width, ";\n top: 0;\n left: 0px;\n border: 1px solid ").concat(props.theme.colors.brand[600], ";\n pointer-events: none;\n }\n");
|
|
2
|
-
|
|
3
|
-
const getFocusedByKeyboardBorderStyle = (props, height = '100%', width = '100%') => {
|
|
4
|
-
if (props.focused && props.focusedByKey) return commonFocusedByKeyboardBorder(props, height, width);
|
|
5
|
-
return '';
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export { getFocusedByKeyboardBorderStyle };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
const useGlobalKeyListeners = opts => {
|
|
4
|
-
const {
|
|
5
|
-
setFocusedByKey
|
|
6
|
-
} = opts;
|
|
7
|
-
React.useEffect(() => {
|
|
8
|
-
const isKey = () => setFocusedByKey(true);
|
|
9
|
-
|
|
10
|
-
const isClick = () => setFocusedByKey(false); // To track wheter it's keyboard focus to apply the necessary style
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
window.addEventListener('keydown', isKey);
|
|
14
|
-
window.addEventListener('mousedown', isClick);
|
|
15
|
-
return () => {
|
|
16
|
-
window.removeEventListener('keydown', isKey);
|
|
17
|
-
window.removeEventListener('mousedown', isClick);
|
|
18
|
-
};
|
|
19
|
-
}, [setFocusedByKey]);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export { useGlobalKeyListeners as default, useGlobalKeyListeners };
|