@doyourjob/gravity-ui-page-constructor-addons 2.1.54 → 2.1.56
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/build/cjs/components/NewHeader/components/NHLoginButton/NHLoginButton.js +13 -3
- package/build/cjs/components/NewHeader/components/NHNavigation/NHNavigation.js +13 -4
- package/build/cjs/components/NewHeader/components/NHNavigationItem/NHNavigationItem.js +8 -1
- package/build/cjs/components/NewHeader/components/NHNavigationPopup/NHNavigationPopup.d.ts +3 -1
- package/build/cjs/components/NewHeader/components/NHNavigationPopup/NHNavigationPopup.js +2 -2
- package/build/esm/components/NewHeader/components/NHLoginButton/NHLoginButton.js +13 -3
- package/build/esm/components/NewHeader/components/NHNavigation/NHNavigation.js +13 -4
- package/build/esm/components/NewHeader/components/NHNavigationItem/NHNavigationItem.js +8 -1
- package/build/esm/components/NewHeader/components/NHNavigationPopup/NHNavigationPopup.d.ts +3 -1
- package/build/esm/components/NewHeader/components/NHNavigationPopup/NHNavigationPopup.js +2 -2
- package/package.json +1 -1
|
@@ -19,7 +19,10 @@ const NHLoginButton = ({ data, headerRef, setupRouteChangeHandler }) => {
|
|
|
19
19
|
const handleActiveTab = (0, react_1.useCallback)((val) => {
|
|
20
20
|
setPreviouslyFocusedElement(document.activeElement);
|
|
21
21
|
setPretendentAciveTab(val);
|
|
22
|
-
|
|
22
|
+
if (!isActive && val) {
|
|
23
|
+
setIsActive(true);
|
|
24
|
+
}
|
|
25
|
+
}, [isActive]);
|
|
23
26
|
const onEscapeKeyDown = (0, react_1.useCallback)((event) => {
|
|
24
27
|
if (event.key === 'Escape' && isActive) {
|
|
25
28
|
setIsActive(false);
|
|
@@ -28,7 +31,14 @@ const NHLoginButton = ({ data, headerRef, setupRouteChangeHandler }) => {
|
|
|
28
31
|
}
|
|
29
32
|
}, [isActive, previouslyFocusedElement]);
|
|
30
33
|
const handleMouseEnter = (0, react_1.useCallback)(() => handleActiveTab(true), [handleActiveTab]);
|
|
31
|
-
const handleMouseLeave = (0, react_1.useCallback)(() =>
|
|
34
|
+
const handleMouseLeave = (0, react_1.useCallback)((event) => {
|
|
35
|
+
const popup = document.getElementById(popupId);
|
|
36
|
+
const nextHoveredElement = (event === null || event === void 0 ? void 0 : event.relatedTarget) || (event === null || event === void 0 ? void 0 : event.nativeEvent.relatedTarget);
|
|
37
|
+
if (nextHoveredElement && (popup === null || popup === void 0 ? void 0 : popup.contains(nextHoveredElement))) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
handleActiveTab(false);
|
|
41
|
+
}, [handleActiveTab, popupId]);
|
|
32
42
|
const handleMouseDown = (0, react_1.useCallback)((event) => {
|
|
33
43
|
event.preventDefault();
|
|
34
44
|
}, []);
|
|
@@ -67,7 +77,7 @@ const NHLoginButton = ({ data, headerRef, setupRouteChangeHandler }) => {
|
|
|
67
77
|
react_1.default.createElement("button", { className: b(), type: "button", onMouseDown: handleMouseDown, onKeyDown: handleKeyDown, "aria-expanded": isActive, "aria-controls": popupId },
|
|
68
78
|
data.text,
|
|
69
79
|
react_1.default.createElement(uikit_1.Icon, { data: isActive ? ChevronUp_1.ChevronUp : ChevronDown_1.ChevronDown, size: 16 })),
|
|
70
|
-
isActive && (react_1.default.createElement(NHNavigationPopup_1.NHNavigationPopup, { headerRef: headerRef, id: popupId },
|
|
80
|
+
isActive && (react_1.default.createElement(NHNavigationPopup_1.NHNavigationPopup, { headerRef: headerRef, id: popupId, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave },
|
|
71
81
|
react_1.default.createElement(NHLoginPopup_1.NHLoginPopup, Object.assign({}, data))))));
|
|
72
82
|
};
|
|
73
83
|
exports.NHLoginButton = NHLoginButton;
|
|
@@ -33,8 +33,12 @@ const NHNavigation = ({ activeNavigationId, data, headerRef, navigationId, setup
|
|
|
33
33
|
}, [navigationId, setActiveNavigationId]);
|
|
34
34
|
const handleActiveTab = (0, react_1.useCallback)((currentIndex) => {
|
|
35
35
|
setPreviouslyFocusedElement(document.activeElement);
|
|
36
|
+
if (activeTab === constants_1.NO_MENU_TAB_SELECTED && currentIndex !== constants_1.NO_MENU_TAB_SELECTED) {
|
|
37
|
+
setNavigationTab(currentIndex);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
36
40
|
setPretendentAciveTab(currentIndex);
|
|
37
|
-
}, []);
|
|
41
|
+
}, [activeTab, setNavigationTab]);
|
|
38
42
|
const handleToggleTab = (0, react_1.useCallback)((currentIndex) => {
|
|
39
43
|
const focusedElement = document.activeElement;
|
|
40
44
|
const nextActiveTab = activeTab === currentIndex ? constants_1.NO_MENU_TAB_SELECTED : currentIndex;
|
|
@@ -86,10 +90,15 @@ const NHNavigation = ({ activeNavigationId, data, headerRef, navigationId, setup
|
|
|
86
90
|
(0, react_1.useEffect)(() => {
|
|
87
91
|
const timerId = setTimeout(() => {
|
|
88
92
|
setActiveTab(pretendentActiveTab);
|
|
89
|
-
|
|
93
|
+
if (pretendentActiveTab !== constants_1.NO_MENU_TAB_SELECTED) {
|
|
94
|
+
setActiveNavigationId(navigationId);
|
|
95
|
+
}
|
|
96
|
+
else if (activeNavigationId === navigationId) {
|
|
97
|
+
setActiveNavigationId(null);
|
|
98
|
+
}
|
|
90
99
|
}, constants_1.SWITCH_MENU_TAB_TIMEOUT);
|
|
91
100
|
return () => clearTimeout(timerId);
|
|
92
|
-
}, [
|
|
101
|
+
}, [activeNavigationId, navigationId, pretendentActiveTab, setActiveNavigationId]);
|
|
93
102
|
(0, react_1.useEffect)(() => {
|
|
94
103
|
if (activeNavigationId !== navigationId && activeTab !== constants_1.NO_MENU_TAB_SELECTED) {
|
|
95
104
|
setActiveTab(constants_1.NO_MENU_TAB_SELECTED);
|
|
@@ -113,6 +122,6 @@ const NHNavigation = ({ activeNavigationId, data, headerRef, navigationId, setup
|
|
|
113
122
|
};
|
|
114
123
|
}, [onEscapeKeyDown]);
|
|
115
124
|
return (react_1.default.createElement("nav", { onBlur: handleBlur },
|
|
116
|
-
react_1.default.createElement("ul", { className: b() }, data.map((item, i) => (react_1.default.createElement(NHNavigationItem_1.NHNavigationItem, { key: i, item: item, handleActiveTab: handleActiveTab, handleFocusTabPopup: handleFocusTabPopup, handleFocusTab: handleFocusTab, handleToggleTab: handleToggleTab, index: i, isActive: activeTab === i, tooltipId: `${tooltipPrefixId}-${i}` }, activeTab === i && item.type !== models_1.NHNavigationItemType.Link && (react_1.default.createElement(NHNavigationPopup_1.NHNavigationPopup, { headerRef: headerRef, id: `${tooltipPrefixId}-${i}
|
|
125
|
+
react_1.default.createElement("ul", { className: b() }, data.map((item, i) => (react_1.default.createElement(NHNavigationItem_1.NHNavigationItem, { key: i, item: item, handleActiveTab: handleActiveTab, handleFocusTabPopup: handleFocusTabPopup, handleFocusTab: handleFocusTab, handleToggleTab: handleToggleTab, index: i, isActive: activeTab === i, tooltipId: `${tooltipPrefixId}-${i}` }, activeTab === i && item.type !== models_1.NHNavigationItemType.Link && (react_1.default.createElement(NHNavigationPopup_1.NHNavigationPopup, { headerRef: headerRef, id: `${tooltipPrefixId}-${i}`, onMouseEnter: () => handleActiveTab(i), onMouseLeave: () => handleActiveTab(constants_1.NO_MENU_TAB_SELECTED) }, getPopupContent(item)))))))));
|
|
117
126
|
};
|
|
118
127
|
exports.NHNavigation = NHNavigation;
|
|
@@ -16,7 +16,14 @@ const NHNavigationItem = ({ item, isActive, handleActiveTab, handleFocusTab, han
|
|
|
16
16
|
var _a, _b, _c, _d;
|
|
17
17
|
const setupRouteChangeHandler = (0, react_1.useContext)(route_change_1.RouteChangeHandlerContext);
|
|
18
18
|
const handleMouseEnter = (0, react_1.useCallback)(() => handleActiveTab(index), [handleActiveTab, index]);
|
|
19
|
-
const handleMouseLeave = (0, react_1.useCallback)(() =>
|
|
19
|
+
const handleMouseLeave = (0, react_1.useCallback)((event) => {
|
|
20
|
+
const popup = tooltipId ? document.getElementById(tooltipId) : null;
|
|
21
|
+
const nextHoveredElement = (event === null || event === void 0 ? void 0 : event.relatedTarget) || (event === null || event === void 0 ? void 0 : event.nativeEvent.relatedTarget);
|
|
22
|
+
if (nextHoveredElement && (popup === null || popup === void 0 ? void 0 : popup.contains(nextHoveredElement))) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
handleActiveTab(constants_1.NO_MENU_TAB_SELECTED);
|
|
26
|
+
}, [handleActiveTab, tooltipId]);
|
|
20
27
|
const handleMouseDown = (0, react_1.useCallback)((event) => {
|
|
21
28
|
event.preventDefault();
|
|
22
29
|
}, []);
|
|
@@ -4,6 +4,8 @@ interface NavigationPopupProps {
|
|
|
4
4
|
headerRef?: RefObject<HTMLDivElement>;
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
id?: string;
|
|
7
|
+
onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
|
|
8
|
+
onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
|
|
7
9
|
}
|
|
8
|
-
export declare const NHNavigationPopup: ({ headerRef, children, id }: NavigationPopupProps) => React.ReactPortal | null;
|
|
10
|
+
export declare const NHNavigationPopup: ({ headerRef, children, id, onMouseEnter, onMouseLeave, }: NavigationPopupProps) => React.ReactPortal | null;
|
|
9
11
|
export {};
|
|
@@ -15,7 +15,7 @@ const getNextIndex = (currentIndex, offset, elementsCount) => {
|
|
|
15
15
|
}
|
|
16
16
|
return (currentIndex + offset + elementsCount) % elementsCount;
|
|
17
17
|
};
|
|
18
|
-
const NHNavigationPopup = ({ headerRef, children, id }) => {
|
|
18
|
+
const NHNavigationPopup = ({ headerRef, children, id, onMouseEnter, onMouseLeave, }) => {
|
|
19
19
|
const popupRef = (0, react_1.useRef)(null);
|
|
20
20
|
const focusRelativeElement = (0, react_1.useCallback)((offset) => {
|
|
21
21
|
const popup = popupRef.current;
|
|
@@ -64,7 +64,7 @@ const NHNavigationPopup = ({ headerRef, children, id }) => {
|
|
|
64
64
|
};
|
|
65
65
|
}, [focusRelativeElement]);
|
|
66
66
|
return (headerRef === null || headerRef === void 0 ? void 0 : headerRef.current)
|
|
67
|
-
? react_dom_1.default.createPortal(react_1.default.createElement("div", { className: b(), id: id, ref: popupRef }, children), headerRef.current)
|
|
67
|
+
? react_dom_1.default.createPortal(react_1.default.createElement("div", { className: b(), id: id, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, ref: popupRef }, children), headerRef.current)
|
|
68
68
|
: null;
|
|
69
69
|
};
|
|
70
70
|
exports.NHNavigationPopup = NHNavigationPopup;
|
|
@@ -16,7 +16,10 @@ export const NHLoginButton = ({ data, headerRef, setupRouteChangeHandler }) => {
|
|
|
16
16
|
const handleActiveTab = useCallback((val) => {
|
|
17
17
|
setPreviouslyFocusedElement(document.activeElement);
|
|
18
18
|
setPretendentAciveTab(val);
|
|
19
|
-
|
|
19
|
+
if (!isActive && val) {
|
|
20
|
+
setIsActive(true);
|
|
21
|
+
}
|
|
22
|
+
}, [isActive]);
|
|
20
23
|
const onEscapeKeyDown = useCallback((event) => {
|
|
21
24
|
if (event.key === 'Escape' && isActive) {
|
|
22
25
|
setIsActive(false);
|
|
@@ -25,7 +28,14 @@ export const NHLoginButton = ({ data, headerRef, setupRouteChangeHandler }) => {
|
|
|
25
28
|
}
|
|
26
29
|
}, [isActive, previouslyFocusedElement]);
|
|
27
30
|
const handleMouseEnter = useCallback(() => handleActiveTab(true), [handleActiveTab]);
|
|
28
|
-
const handleMouseLeave = useCallback(() =>
|
|
31
|
+
const handleMouseLeave = useCallback((event) => {
|
|
32
|
+
const popup = document.getElementById(popupId);
|
|
33
|
+
const nextHoveredElement = (event === null || event === void 0 ? void 0 : event.relatedTarget) || (event === null || event === void 0 ? void 0 : event.nativeEvent.relatedTarget);
|
|
34
|
+
if (nextHoveredElement && (popup === null || popup === void 0 ? void 0 : popup.contains(nextHoveredElement))) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
handleActiveTab(false);
|
|
38
|
+
}, [handleActiveTab, popupId]);
|
|
29
39
|
const handleMouseDown = useCallback((event) => {
|
|
30
40
|
event.preventDefault();
|
|
31
41
|
}, []);
|
|
@@ -64,6 +74,6 @@ export const NHLoginButton = ({ data, headerRef, setupRouteChangeHandler }) => {
|
|
|
64
74
|
React.createElement("button", { className: b(), type: "button", onMouseDown: handleMouseDown, onKeyDown: handleKeyDown, "aria-expanded": isActive, "aria-controls": popupId },
|
|
65
75
|
data.text,
|
|
66
76
|
React.createElement(Icon, { data: isActive ? ChevronUp : ChevronDown, size: 16 })),
|
|
67
|
-
isActive && (React.createElement(NHNavigationPopup, { headerRef: headerRef, id: popupId },
|
|
77
|
+
isActive && (React.createElement(NHNavigationPopup, { headerRef: headerRef, id: popupId, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave },
|
|
68
78
|
React.createElement(NHLoginPopup, Object.assign({}, data))))));
|
|
69
79
|
};
|
|
@@ -30,8 +30,12 @@ export const NHNavigation = ({ activeNavigationId, data, headerRef, navigationId
|
|
|
30
30
|
}, [navigationId, setActiveNavigationId]);
|
|
31
31
|
const handleActiveTab = useCallback((currentIndex) => {
|
|
32
32
|
setPreviouslyFocusedElement(document.activeElement);
|
|
33
|
+
if (activeTab === NO_MENU_TAB_SELECTED && currentIndex !== NO_MENU_TAB_SELECTED) {
|
|
34
|
+
setNavigationTab(currentIndex);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
33
37
|
setPretendentAciveTab(currentIndex);
|
|
34
|
-
}, []);
|
|
38
|
+
}, [activeTab, setNavigationTab]);
|
|
35
39
|
const handleToggleTab = useCallback((currentIndex) => {
|
|
36
40
|
const focusedElement = document.activeElement;
|
|
37
41
|
const nextActiveTab = activeTab === currentIndex ? NO_MENU_TAB_SELECTED : currentIndex;
|
|
@@ -83,10 +87,15 @@ export const NHNavigation = ({ activeNavigationId, data, headerRef, navigationId
|
|
|
83
87
|
useEffect(() => {
|
|
84
88
|
const timerId = setTimeout(() => {
|
|
85
89
|
setActiveTab(pretendentActiveTab);
|
|
86
|
-
|
|
90
|
+
if (pretendentActiveTab !== NO_MENU_TAB_SELECTED) {
|
|
91
|
+
setActiveNavigationId(navigationId);
|
|
92
|
+
}
|
|
93
|
+
else if (activeNavigationId === navigationId) {
|
|
94
|
+
setActiveNavigationId(null);
|
|
95
|
+
}
|
|
87
96
|
}, SWITCH_MENU_TAB_TIMEOUT);
|
|
88
97
|
return () => clearTimeout(timerId);
|
|
89
|
-
}, [
|
|
98
|
+
}, [activeNavigationId, navigationId, pretendentActiveTab, setActiveNavigationId]);
|
|
90
99
|
useEffect(() => {
|
|
91
100
|
if (activeNavigationId !== navigationId && activeTab !== NO_MENU_TAB_SELECTED) {
|
|
92
101
|
setActiveTab(NO_MENU_TAB_SELECTED);
|
|
@@ -110,5 +119,5 @@ export const NHNavigation = ({ activeNavigationId, data, headerRef, navigationId
|
|
|
110
119
|
};
|
|
111
120
|
}, [onEscapeKeyDown]);
|
|
112
121
|
return (React.createElement("nav", { onBlur: handleBlur },
|
|
113
|
-
React.createElement("ul", { className: b() }, data.map((item, i) => (React.createElement(NHNavigationItem, { key: i, item: item, handleActiveTab: handleActiveTab, handleFocusTabPopup: handleFocusTabPopup, handleFocusTab: handleFocusTab, handleToggleTab: handleToggleTab, index: i, isActive: activeTab === i, tooltipId: `${tooltipPrefixId}-${i}` }, activeTab === i && item.type !== NHNavigationItemType.Link && (React.createElement(NHNavigationPopup, { headerRef: headerRef, id: `${tooltipPrefixId}-${i}
|
|
122
|
+
React.createElement("ul", { className: b() }, data.map((item, i) => (React.createElement(NHNavigationItem, { key: i, item: item, handleActiveTab: handleActiveTab, handleFocusTabPopup: handleFocusTabPopup, handleFocusTab: handleFocusTab, handleToggleTab: handleToggleTab, index: i, isActive: activeTab === i, tooltipId: `${tooltipPrefixId}-${i}` }, activeTab === i && item.type !== NHNavigationItemType.Link && (React.createElement(NHNavigationPopup, { headerRef: headerRef, id: `${tooltipPrefixId}-${i}`, onMouseEnter: () => handleActiveTab(i), onMouseLeave: () => handleActiveTab(NO_MENU_TAB_SELECTED) }, getPopupContent(item)))))))));
|
|
114
123
|
};
|
|
@@ -13,7 +13,14 @@ export const NHNavigationItem = ({ item, isActive, handleActiveTab, handleFocusT
|
|
|
13
13
|
var _a, _b, _c, _d;
|
|
14
14
|
const setupRouteChangeHandler = useContext(RouteChangeHandlerContext);
|
|
15
15
|
const handleMouseEnter = useCallback(() => handleActiveTab(index), [handleActiveTab, index]);
|
|
16
|
-
const handleMouseLeave = useCallback(() =>
|
|
16
|
+
const handleMouseLeave = useCallback((event) => {
|
|
17
|
+
const popup = tooltipId ? document.getElementById(tooltipId) : null;
|
|
18
|
+
const nextHoveredElement = (event === null || event === void 0 ? void 0 : event.relatedTarget) || (event === null || event === void 0 ? void 0 : event.nativeEvent.relatedTarget);
|
|
19
|
+
if (nextHoveredElement && (popup === null || popup === void 0 ? void 0 : popup.contains(nextHoveredElement))) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
handleActiveTab(NO_MENU_TAB_SELECTED);
|
|
23
|
+
}, [handleActiveTab, tooltipId]);
|
|
17
24
|
const handleMouseDown = useCallback((event) => {
|
|
18
25
|
event.preventDefault();
|
|
19
26
|
}, []);
|
|
@@ -5,6 +5,8 @@ interface NavigationPopupProps {
|
|
|
5
5
|
headerRef?: RefObject<HTMLDivElement>;
|
|
6
6
|
children: React.ReactNode;
|
|
7
7
|
id?: string;
|
|
8
|
+
onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
|
|
9
|
+
onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
|
|
8
10
|
}
|
|
9
|
-
export declare const NHNavigationPopup: ({ headerRef, children, id }: NavigationPopupProps) => React.ReactPortal | null;
|
|
11
|
+
export declare const NHNavigationPopup: ({ headerRef, children, id, onMouseEnter, onMouseLeave, }: NavigationPopupProps) => React.ReactPortal | null;
|
|
10
12
|
export {};
|
|
@@ -12,7 +12,7 @@ const getNextIndex = (currentIndex, offset, elementsCount) => {
|
|
|
12
12
|
}
|
|
13
13
|
return (currentIndex + offset + elementsCount) % elementsCount;
|
|
14
14
|
};
|
|
15
|
-
export const NHNavigationPopup = ({ headerRef, children, id }) => {
|
|
15
|
+
export const NHNavigationPopup = ({ headerRef, children, id, onMouseEnter, onMouseLeave, }) => {
|
|
16
16
|
const popupRef = useRef(null);
|
|
17
17
|
const focusRelativeElement = useCallback((offset) => {
|
|
18
18
|
const popup = popupRef.current;
|
|
@@ -61,6 +61,6 @@ export const NHNavigationPopup = ({ headerRef, children, id }) => {
|
|
|
61
61
|
};
|
|
62
62
|
}, [focusRelativeElement]);
|
|
63
63
|
return (headerRef === null || headerRef === void 0 ? void 0 : headerRef.current)
|
|
64
|
-
? ReactDOM.createPortal(React.createElement("div", { className: b(), id: id, ref: popupRef }, children), headerRef.current)
|
|
64
|
+
? ReactDOM.createPortal(React.createElement("div", { className: b(), id: id, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, ref: popupRef }, children), headerRef.current)
|
|
65
65
|
: null;
|
|
66
66
|
};
|