@gravity-ui/page-constructor 1.22.1-alpha.3 → 1.23.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.
- package/CHANGELOG.md +7 -0
- package/build/cjs/navigation/components/Header/Header.css +0 -23
- package/build/cjs/navigation/components/Header/Header.js +8 -12
- package/build/cjs/navigation/components/MobileNavigation/MobileNavigation.css +2 -5
- package/build/cjs/navigation/components/MobileNavigation/MobileNavigation.d.ts +2 -2
- package/build/cjs/navigation/components/MobileNavigation/MobileNavigation.js +11 -11
- package/build/cjs/navigation/components/Navigation/Navigation.css +11 -0
- package/build/cjs/navigation/components/Navigation/Navigation.d.ts +11 -4
- package/build/cjs/navigation/components/Navigation/Navigation.js +23 -5
- package/build/esm/navigation/components/Header/Header.css +0 -23
- package/build/esm/navigation/components/Header/Header.js +8 -12
- package/build/esm/navigation/components/MobileNavigation/MobileNavigation.css +2 -5
- package/build/esm/navigation/components/MobileNavigation/MobileNavigation.d.ts +2 -2
- package/build/esm/navigation/components/MobileNavigation/MobileNavigation.js +11 -11
- package/build/esm/navigation/components/Navigation/Navigation.css +11 -0
- package/build/esm/navigation/components/Navigation/Navigation.d.ts +11 -4
- package/build/esm/navigation/components/Navigation/Navigation.js +25 -6
- package/package.json +1 -4
- package/build/cjs/navigation/components/NavigationDropdownItem/NavigationDropdownItem.d.ts +0 -11
- package/build/cjs/navigation/components/NavigationDropdownItem/NavigationDropdownItem.js +0 -14
- package/build/cjs/navigation/components/NavigationListItem/NavigationListItem.css +0 -11
- package/build/cjs/navigation/components/NavigationListItem/NavigationListItem.d.ts +0 -16
- package/build/cjs/navigation/components/NavigationListItem/NavigationListItem.js +0 -28
- package/build/cjs/navigation/constants.d.ts +0 -6
- package/build/cjs/navigation/constants.js +0 -10
- package/build/cjs/navigation/utils.d.ts +0 -10
- package/build/cjs/navigation/utils.js +0 -9
- package/build/esm/navigation/components/NavigationDropdownItem/NavigationDropdownItem.d.ts +0 -11
- package/build/esm/navigation/components/NavigationDropdownItem/NavigationDropdownItem.js +0 -12
- package/build/esm/navigation/components/NavigationListItem/NavigationListItem.css +0 -11
- package/build/esm/navigation/components/NavigationListItem/NavigationListItem.d.ts +0 -17
- package/build/esm/navigation/components/NavigationListItem/NavigationListItem.js +0 -24
- package/build/esm/navigation/constants.d.ts +0 -6
- package/build/esm/navigation/constants.js +0 -7
- package/build/esm/navigation/utils.d.ts +0 -10
- package/build/esm/navigation/utils.js +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.23.0](https://github.com/gravity-ui/page-constructor/compare/v1.22.1...v1.23.0) (2023-03-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add release flow to README.md ([#183](https://github.com/gravity-ui/page-constructor/issues/183)) ([c7d7923](https://github.com/gravity-ui/page-constructor/commit/c7d7923c034b88a8e8167023448d8a071926cc26))
|
|
9
|
+
|
|
3
10
|
## [1.22.1](https://github.com/gravity-ui/page-constructor/compare/v1.22.0...v1.22.1) (2023-03-07)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -41,8 +41,6 @@ unpredictable css rules order in build */
|
|
|
41
41
|
.pc-header__right {
|
|
42
42
|
flex: 0;
|
|
43
43
|
justify-content: flex-end;
|
|
44
|
-
font-size: var(--yc-text-body-2-font-size);
|
|
45
|
-
line-height: var(--yc-text-body-2-line-height);
|
|
46
44
|
}
|
|
47
45
|
.pc-header__navigation-container {
|
|
48
46
|
display: flex;
|
|
@@ -55,9 +53,6 @@ unpredictable css rules order in build */
|
|
|
55
53
|
.pc-header__buttons {
|
|
56
54
|
display: flex;
|
|
57
55
|
align-items: center;
|
|
58
|
-
margin: 0;
|
|
59
|
-
padding: 0;
|
|
60
|
-
list-style: none;
|
|
61
56
|
}
|
|
62
57
|
@media (max-width: 768px) {
|
|
63
58
|
.pc-header__buttons {
|
|
@@ -67,24 +62,6 @@ unpredictable css rules order in build */
|
|
|
67
62
|
.pc-header__buttons > *:not(:last-child) {
|
|
68
63
|
margin-right: 16px;
|
|
69
64
|
}
|
|
70
|
-
.pc-header__buttons-item {
|
|
71
|
-
position: relative;
|
|
72
|
-
height: var(--header-height);
|
|
73
|
-
line-height: var(--header-height);
|
|
74
|
-
cursor: pointer;
|
|
75
|
-
outline: none;
|
|
76
|
-
color: inherit;
|
|
77
|
-
text-decoration: none;
|
|
78
|
-
}
|
|
79
|
-
.utilityfocus .pc-header__buttons-item:focus {
|
|
80
|
-
outline: 2px solid #ffdb4d;
|
|
81
|
-
}
|
|
82
|
-
.pc-header__buttons-item:hover, .pc-header__buttons-item:active {
|
|
83
|
-
color: var(--yc-color-text-link);
|
|
84
|
-
}
|
|
85
|
-
.pc-header__buttons-item:not(:last-child) {
|
|
86
|
-
margin-right: 20px;
|
|
87
|
-
}
|
|
88
65
|
.pc-header__button {
|
|
89
66
|
margin-top: 0;
|
|
90
67
|
}
|
|
@@ -7,12 +7,11 @@ const utils_1 = require("../../../utils");
|
|
|
7
7
|
const grid_1 = require("../../../grid");
|
|
8
8
|
const OutsideClick_1 = tslib_1.__importDefault(require("../../../components/OutsideClick/OutsideClick"));
|
|
9
9
|
const Control_1 = tslib_1.__importDefault(require("../../../components/Control/Control"));
|
|
10
|
-
const icons_1 = require("../../../icons");
|
|
11
|
-
const constants_1 = require("../../constants");
|
|
12
10
|
const Navigation_1 = tslib_1.__importDefault(require("../Navigation/Navigation"));
|
|
13
11
|
const MobileNavigation_1 = tslib_1.__importDefault(require("../MobileNavigation/MobileNavigation"));
|
|
12
|
+
const NavigationItem_1 = tslib_1.__importDefault(require("../NavigationItem/NavigationItem"));
|
|
14
13
|
const Logo_1 = tslib_1.__importDefault(require("../Logo/Logo"));
|
|
15
|
-
const
|
|
14
|
+
const icons_1 = require("../../../icons");
|
|
16
15
|
const b = (0, utils_1.block)('header');
|
|
17
16
|
const ICON_SIZE = 36;
|
|
18
17
|
const MobileMenuButton = ({ isSidebarOpened, onSidebarOpenedChange, }) => {
|
|
@@ -28,13 +27,10 @@ const MobileMenuButton = ({ isSidebarOpened, onSidebarOpenedChange, }) => {
|
|
|
28
27
|
const Header = ({ data, logo }) => {
|
|
29
28
|
const { leftItems, rightItems } = data;
|
|
30
29
|
const [isSidebarOpened, setIsSidebarOpened] = (0, react_1.useState)(false);
|
|
31
|
-
const [
|
|
32
|
-
const onActiveItemChange = (0, react_1.useCallback)((index
|
|
33
|
-
|
|
30
|
+
const [activeItemIndex, setActiveItemIndex] = (0, react_1.useState)(-1);
|
|
31
|
+
const onActiveItemChange = (0, react_1.useCallback)((index) => {
|
|
32
|
+
setActiveItemIndex(index);
|
|
34
33
|
}, []);
|
|
35
|
-
const hidePopup = (0, react_1.useCallback)(() => {
|
|
36
|
-
onActiveItemChange('');
|
|
37
|
-
}, [onActiveItemChange]);
|
|
38
34
|
const onSidebarOpenedChange = (0, react_1.useCallback)((isOpen) => {
|
|
39
35
|
setIsSidebarOpened(isOpen);
|
|
40
36
|
}, []);
|
|
@@ -48,12 +44,12 @@ const Header = ({ data, logo }) => {
|
|
|
48
44
|
logo && (react_1.default.createElement("div", { className: b('left') },
|
|
49
45
|
react_1.default.createElement(Logo_1.default, Object.assign({}, logo, { className: b('logo') })))),
|
|
50
46
|
react_1.default.createElement("div", { className: b('navigation-container') },
|
|
51
|
-
react_1.default.createElement(Navigation_1.default, { className: b('navigation'), links: leftItems,
|
|
47
|
+
react_1.default.createElement(Navigation_1.default, { className: b('navigation'), links: leftItems, activeItemIndex: activeItemIndex, onActiveItemChange: onActiveItemChange })),
|
|
52
48
|
react_1.default.createElement("div", { className: b('right') },
|
|
53
49
|
react_1.default.createElement(MobileMenuButton, { isSidebarOpened: isSidebarOpened, onSidebarOpenedChange: onSidebarOpenedChange }),
|
|
54
|
-
rightItems && (react_1.default.createElement("
|
|
50
|
+
rightItems && (react_1.default.createElement("div", { className: b('buttons') }, rightItems.map((button) => (react_1.default.createElement(NavigationItem_1.default, { key: button.text, data: button })))))),
|
|
55
51
|
react_1.default.createElement(OutsideClick_1.default, { onOutsideClick: () => onSidebarOpenedChange(false) },
|
|
56
|
-
react_1.default.createElement(MobileNavigation_1.default, { topItems: leftItems, bottomItems: rightItems, isOpened: isSidebarOpened,
|
|
52
|
+
react_1.default.createElement(MobileNavigation_1.default, { topItems: leftItems, bottomItems: rightItems, isOpened: isSidebarOpened, activeItemIndex: activeItemIndex, onActiveItemChange: onActiveItemChange, onClose: hideSidebar })))))));
|
|
57
53
|
};
|
|
58
54
|
exports.Header = Header;
|
|
59
55
|
exports.default = exports.Header;
|
|
@@ -24,10 +24,7 @@ unpredictable css rules order in build */
|
|
|
24
24
|
.pc-mobile-navigation__button {
|
|
25
25
|
margin-top: 24px;
|
|
26
26
|
}
|
|
27
|
-
.pc-mobile-
|
|
28
|
-
margin-bottom: 24px;
|
|
29
|
-
}
|
|
30
|
-
.pc-mobile-navigation__rows {
|
|
27
|
+
.pc-mobile-navigation__links {
|
|
31
28
|
position: relative;
|
|
32
29
|
display: flex;
|
|
33
30
|
flex-direction: column;
|
|
@@ -36,7 +33,7 @@ unpredictable css rules order in build */
|
|
|
36
33
|
padding: 0;
|
|
37
34
|
list-style: none;
|
|
38
35
|
}
|
|
39
|
-
.pc-mobile-
|
|
36
|
+
.pc-mobile-navigation__links-item:not(:last-child) {
|
|
40
37
|
margin-bottom: 24px;
|
|
41
38
|
}
|
|
42
39
|
.pc-mobile-navigation__dropdown-item:not(:last-child) {
|
|
@@ -5,9 +5,9 @@ export interface MobileNavigationProps {
|
|
|
5
5
|
isOpened?: boolean;
|
|
6
6
|
topItems?: NavigationItemModel[];
|
|
7
7
|
bottomItems?: NavigationItemModel[];
|
|
8
|
-
|
|
8
|
+
activeItemIndex: number;
|
|
9
9
|
onClose: () => void;
|
|
10
|
-
onActiveItemChange: (index:
|
|
10
|
+
onActiveItemChange: (index: number) => void;
|
|
11
11
|
}
|
|
12
12
|
declare const MobileNavigation: React.FC<MobileNavigationProps>;
|
|
13
13
|
export default MobileNavigation;
|
|
@@ -6,7 +6,6 @@ const uikit_1 = require("@gravity-ui/uikit");
|
|
|
6
6
|
const utils_1 = require("../../../utils");
|
|
7
7
|
const Foldable_1 = tslib_1.__importDefault(require("../../../components/Foldable/Foldable"));
|
|
8
8
|
const models_1 = require("../../../models");
|
|
9
|
-
const constants_1 = require("../../constants");
|
|
10
9
|
const NavigationItem_1 = tslib_1.__importDefault(require("../NavigationItem/NavigationItem"));
|
|
11
10
|
const b = (0, utils_1.block)('mobile-navigation');
|
|
12
11
|
const MobileNavigationDropdown = ({ data, onItemClick, onToggle, isOpened = false, }) => {
|
|
@@ -15,31 +14,32 @@ const MobileNavigationDropdown = ({ data, onItemClick, onToggle, isOpened = fals
|
|
|
15
14
|
react_1.default.createElement(NavigationItem_1.default, { data: data, onClick: onToggle, isOpened: isOpened }),
|
|
16
15
|
isOpened && (react_1.default.createElement(uikit_1.Popup, { anchorRef: ref, open: isOpened, className: b('popup') }, data.items.map((item) => (react_1.default.createElement(NavigationItem_1.default, { key: item.text, data: item, className: b('dropdown-item'), onClick: onItemClick })))))));
|
|
17
16
|
};
|
|
18
|
-
const MobileNavigationItem = ({
|
|
19
|
-
const id = `${column}-${index}`;
|
|
20
|
-
const isActive = id === activeItemId && isOpened;
|
|
17
|
+
const MobileNavigationItem = ({ link, index, isActive, onActiveItemChange, onClose, }) => {
|
|
21
18
|
const toggleActive = (0, react_1.useCallback)((e) => {
|
|
22
19
|
e.stopPropagation();
|
|
23
20
|
if (onActiveItemChange) {
|
|
24
|
-
onActiveItemChange(isActive ?
|
|
21
|
+
onActiveItemChange(isActive ? -1 : index);
|
|
25
22
|
}
|
|
26
|
-
}, [
|
|
23
|
+
}, [isActive, index, onActiveItemChange]);
|
|
27
24
|
const onItemClick = (0, react_1.useCallback)((e) => {
|
|
28
25
|
toggleActive(e);
|
|
29
26
|
onClose();
|
|
30
27
|
}, [toggleActive, onClose]);
|
|
31
|
-
return (react_1.default.createElement("li", { key: index, className: b('
|
|
28
|
+
return (react_1.default.createElement("li", { key: index, className: b('links-item') }, link.type === models_1.NavigationItemType.Dropdown ? (react_1.default.createElement(MobileNavigationDropdown, { data: link, onToggle: toggleActive, isOpened: isActive, onItemClick: onItemClick })) : (react_1.default.createElement(NavigationItem_1.default, { data: link, onClick: onItemClick }))));
|
|
32
29
|
};
|
|
33
30
|
const MobileNavigation = (props) => {
|
|
34
31
|
if (typeof window === 'undefined') {
|
|
35
32
|
return null;
|
|
36
33
|
}
|
|
37
|
-
const { isOpened, topItems, bottomItems,
|
|
34
|
+
const { isOpened, topItems, bottomItems, activeItemIndex, onActiveItemChange, onClose } = props;
|
|
38
35
|
return (react_1.default.createElement(uikit_1.Portal, null,
|
|
39
36
|
react_1.default.createElement(Foldable_1.default, { key: topItems === null || topItems === void 0 ? void 0 : topItems.length, className: b(), isOpened: Boolean(isOpened) },
|
|
40
37
|
react_1.default.createElement("div", { className: b('wrapper') },
|
|
41
|
-
react_1.default.createElement("nav",
|
|
42
|
-
react_1.default.createElement("ul", { className: b('
|
|
43
|
-
|
|
38
|
+
react_1.default.createElement("nav", null,
|
|
39
|
+
react_1.default.createElement("ul", { className: b('links') }, topItems === null || topItems === void 0 ? void 0 : topItems.map((link, index) => {
|
|
40
|
+
const isActive = index === activeItemIndex;
|
|
41
|
+
return (react_1.default.createElement(MobileNavigationItem, { key: index, link: link, index: index, isActive: isOpened && isActive, onClose: onClose, onActiveItemChange: onActiveItemChange }));
|
|
42
|
+
}))), bottomItems === null || bottomItems === void 0 ? void 0 :
|
|
43
|
+
bottomItems.map((item) => (react_1.default.createElement(NavigationItem_1.default, { key: item.text, data: item, className: b('button') })))))));
|
|
44
44
|
};
|
|
45
45
|
exports.default = MobileNavigation;
|
|
@@ -29,4 +29,15 @@ unpredictable css rules order in build */
|
|
|
29
29
|
}
|
|
30
30
|
.pc-navigation__links-item:not(:last-child) {
|
|
31
31
|
margin-right: 20px;
|
|
32
|
+
}
|
|
33
|
+
.pc-navigation__slider-container {
|
|
34
|
+
position: absolute;
|
|
35
|
+
right: 0;
|
|
36
|
+
bottom: 0;
|
|
37
|
+
left: 0;
|
|
38
|
+
}
|
|
39
|
+
.pc-navigation__slider {
|
|
40
|
+
width: 100%;
|
|
41
|
+
height: 2px;
|
|
42
|
+
background-color: var(--yc-color-text-link);
|
|
32
43
|
}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { NavigationItemModel } from '../../../models/navigation';
|
|
1
|
+
import React, { MouseEventHandler } from 'react';
|
|
2
|
+
import { NavigationDropdownItem, NavigationItemModel } from '../../../models/navigation';
|
|
3
3
|
export interface NavigationProps {
|
|
4
4
|
links: NavigationItemModel[];
|
|
5
|
-
|
|
6
|
-
onActiveItemChange: (index:
|
|
5
|
+
activeItemIndex: number;
|
|
6
|
+
onActiveItemChange: (index: number) => void;
|
|
7
7
|
className?: string;
|
|
8
8
|
highlightActiveItem?: boolean;
|
|
9
9
|
}
|
|
10
|
+
export interface NavigationDropdownProps {
|
|
11
|
+
data: NavigationDropdownItem;
|
|
12
|
+
onClick: MouseEventHandler;
|
|
13
|
+
isActive: boolean;
|
|
14
|
+
position: number;
|
|
15
|
+
hidePopup: () => void;
|
|
16
|
+
}
|
|
10
17
|
declare const Navigation: React.FC<NavigationProps>;
|
|
11
18
|
export default Navigation;
|
|
@@ -5,18 +5,29 @@ const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
|
5
5
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
6
|
const utils_1 = require("../../../utils");
|
|
7
7
|
const OverflowScroller_1 = tslib_1.__importDefault(require("../../../components/OverflowScroller/OverflowScroller"));
|
|
8
|
+
const navigation_1 = require("../../../models/navigation");
|
|
9
|
+
const NavigationPopup_1 = tslib_1.__importDefault(require("../NavigationPopup/NavigationPopup"));
|
|
10
|
+
const NavigationItem_1 = tslib_1.__importDefault(require("../NavigationItem/NavigationItem"));
|
|
8
11
|
const locationContext_1 = require("../../../context/locationContext");
|
|
9
|
-
const constants_1 = require("../../constants");
|
|
10
|
-
const NavigationListItem_1 = require("../NavigationListItem/NavigationListItem");
|
|
11
12
|
const b = (0, utils_1.block)('navigation');
|
|
12
|
-
const
|
|
13
|
+
const NavigationDropdown = ({ data, isActive, position, hidePopup, onClick, }) => {
|
|
14
|
+
const { text, items } = data, popupProps = tslib_1.__rest(data, ["text", "items"]);
|
|
15
|
+
return (react_1.default.createElement(react_1.Fragment, null,
|
|
16
|
+
react_1.default.createElement(NavigationItem_1.default, { className: b('link'), onClick: onClick, isOpened: isActive, data: { text, type: navigation_1.NavigationItemType.Dropdown } }),
|
|
17
|
+
isActive && (react_1.default.createElement(NavigationPopup_1.default, Object.assign({ left: position, onClose: hidePopup, items: items }, popupProps)))));
|
|
18
|
+
};
|
|
19
|
+
const Navigation = ({ className, onActiveItemChange, links, activeItemIndex, highlightActiveItem, }) => {
|
|
13
20
|
const { asPath, pathname } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
14
21
|
const itemRefs = (0, react_1.useRef)([]);
|
|
15
22
|
const [itemPositions, setItemPosition] = (0, react_1.useState)([]);
|
|
16
23
|
const [lastLeftScroll, setLastLeftScroll] = (0, react_1.useState)(0);
|
|
17
24
|
const hidePopup = (0, react_1.useCallback)(() => {
|
|
18
|
-
onActiveItemChange(
|
|
25
|
+
onActiveItemChange(-1);
|
|
19
26
|
}, [onActiveItemChange]);
|
|
27
|
+
const getItemClickHandler = (0, react_1.useCallback)((index) => (e) => {
|
|
28
|
+
e.stopPropagation();
|
|
29
|
+
onActiveItemChange(index === activeItemIndex ? -1 : index);
|
|
30
|
+
}, [activeItemIndex, onActiveItemChange]);
|
|
20
31
|
const calculateItemPositions = (0, react_1.useCallback)(() => {
|
|
21
32
|
if (itemRefs.current.length) {
|
|
22
33
|
const currentItemPositions = itemRefs.current.map((itemRef) => (itemRef && itemRef.getBoundingClientRect().left) || 0);
|
|
@@ -46,6 +57,13 @@ const Navigation = ({ className, onActiveItemChange, links, activeItemId, highli
|
|
|
46
57
|
}, [hidePopup, asPath, pathname]);
|
|
47
58
|
return (react_1.default.createElement(OverflowScroller_1.default, { className: b(null, className), onScrollStart: hidePopup, onScrollEnd: calculateItemPositions },
|
|
48
59
|
react_1.default.createElement("nav", null,
|
|
49
|
-
react_1.default.createElement("ul", { className: b('links') }, links.map((link, index) =>
|
|
60
|
+
react_1.default.createElement("ul", { className: b('links') }, links.map((link, index) => {
|
|
61
|
+
const isActive = index === activeItemIndex;
|
|
62
|
+
const onClick = getItemClickHandler(index);
|
|
63
|
+
return (react_1.default.createElement("li", { ref: (el) => itemRefs.current.push(el), key: index, className: b('links-item') },
|
|
64
|
+
link.type === navigation_1.NavigationItemType.Dropdown ? (react_1.default.createElement(NavigationDropdown, { data: link, onClick: onClick, isActive: isActive, position: itemPositions[index], hidePopup: hidePopup })) : (react_1.default.createElement(NavigationItem_1.default, { data: link, onClick: onClick })),
|
|
65
|
+
highlightActiveItem && isActive && (react_1.default.createElement("div", { className: b('slider-container') },
|
|
66
|
+
react_1.default.createElement("div", { className: b('slider') })))));
|
|
67
|
+
})))));
|
|
50
68
|
};
|
|
51
69
|
exports.default = Navigation;
|
|
@@ -41,8 +41,6 @@ unpredictable css rules order in build */
|
|
|
41
41
|
.pc-header__right {
|
|
42
42
|
flex: 0;
|
|
43
43
|
justify-content: flex-end;
|
|
44
|
-
font-size: var(--yc-text-body-2-font-size);
|
|
45
|
-
line-height: var(--yc-text-body-2-line-height);
|
|
46
44
|
}
|
|
47
45
|
.pc-header__navigation-container {
|
|
48
46
|
display: flex;
|
|
@@ -55,9 +53,6 @@ unpredictable css rules order in build */
|
|
|
55
53
|
.pc-header__buttons {
|
|
56
54
|
display: flex;
|
|
57
55
|
align-items: center;
|
|
58
|
-
margin: 0;
|
|
59
|
-
padding: 0;
|
|
60
|
-
list-style: none;
|
|
61
56
|
}
|
|
62
57
|
@media (max-width: 768px) {
|
|
63
58
|
.pc-header__buttons {
|
|
@@ -67,24 +62,6 @@ unpredictable css rules order in build */
|
|
|
67
62
|
.pc-header__buttons > *:not(:last-child) {
|
|
68
63
|
margin-right: 16px;
|
|
69
64
|
}
|
|
70
|
-
.pc-header__buttons-item {
|
|
71
|
-
position: relative;
|
|
72
|
-
height: var(--header-height);
|
|
73
|
-
line-height: var(--header-height);
|
|
74
|
-
cursor: pointer;
|
|
75
|
-
outline: none;
|
|
76
|
-
color: inherit;
|
|
77
|
-
text-decoration: none;
|
|
78
|
-
}
|
|
79
|
-
.utilityfocus .pc-header__buttons-item:focus {
|
|
80
|
-
outline: 2px solid #ffdb4d;
|
|
81
|
-
}
|
|
82
|
-
.pc-header__buttons-item:hover, .pc-header__buttons-item:active {
|
|
83
|
-
color: var(--yc-color-text-link);
|
|
84
|
-
}
|
|
85
|
-
.pc-header__buttons-item:not(:last-child) {
|
|
86
|
-
margin-right: 20px;
|
|
87
|
-
}
|
|
88
65
|
.pc-header__button {
|
|
89
66
|
margin-top: 0;
|
|
90
67
|
}
|
|
@@ -3,12 +3,11 @@ import { block } from '../../../utils';
|
|
|
3
3
|
import { Col, Grid, Row } from '../../../grid';
|
|
4
4
|
import OutsideClick from '../../../components/OutsideClick/OutsideClick';
|
|
5
5
|
import Control from '../../../components/Control/Control';
|
|
6
|
-
import { NavigationClose, NavigationOpen } from '../../../icons';
|
|
7
|
-
import { ItemColumnName } from '../../constants';
|
|
8
6
|
import Navigation from '../Navigation/Navigation';
|
|
9
7
|
import MobileNavigation from '../MobileNavigation/MobileNavigation';
|
|
8
|
+
import NavigationItem from '../NavigationItem/NavigationItem';
|
|
10
9
|
import Logo from '../Logo/Logo';
|
|
11
|
-
import {
|
|
10
|
+
import { NavigationClose, NavigationOpen } from '../../../icons';
|
|
12
11
|
import './Header.css';
|
|
13
12
|
const b = block('header');
|
|
14
13
|
const ICON_SIZE = 36;
|
|
@@ -25,13 +24,10 @@ const MobileMenuButton = ({ isSidebarOpened, onSidebarOpenedChange, }) => {
|
|
|
25
24
|
export const Header = ({ data, logo }) => {
|
|
26
25
|
const { leftItems, rightItems } = data;
|
|
27
26
|
const [isSidebarOpened, setIsSidebarOpened] = useState(false);
|
|
28
|
-
const [
|
|
29
|
-
const onActiveItemChange = useCallback((index
|
|
30
|
-
|
|
27
|
+
const [activeItemIndex, setActiveItemIndex] = useState(-1);
|
|
28
|
+
const onActiveItemChange = useCallback((index) => {
|
|
29
|
+
setActiveItemIndex(index);
|
|
31
30
|
}, []);
|
|
32
|
-
const hidePopup = useCallback(() => {
|
|
33
|
-
onActiveItemChange('');
|
|
34
|
-
}, [onActiveItemChange]);
|
|
35
31
|
const onSidebarOpenedChange = useCallback((isOpen) => {
|
|
36
32
|
setIsSidebarOpened(isOpen);
|
|
37
33
|
}, []);
|
|
@@ -45,11 +41,11 @@ export const Header = ({ data, logo }) => {
|
|
|
45
41
|
logo && (React.createElement("div", { className: b('left') },
|
|
46
42
|
React.createElement(Logo, Object.assign({}, logo, { className: b('logo') })))),
|
|
47
43
|
React.createElement("div", { className: b('navigation-container') },
|
|
48
|
-
React.createElement(Navigation, { className: b('navigation'), links: leftItems,
|
|
44
|
+
React.createElement(Navigation, { className: b('navigation'), links: leftItems, activeItemIndex: activeItemIndex, onActiveItemChange: onActiveItemChange })),
|
|
49
45
|
React.createElement("div", { className: b('right') },
|
|
50
46
|
React.createElement(MobileMenuButton, { isSidebarOpened: isSidebarOpened, onSidebarOpenedChange: onSidebarOpenedChange }),
|
|
51
|
-
rightItems && (React.createElement("
|
|
47
|
+
rightItems && (React.createElement("div", { className: b('buttons') }, rightItems.map((button) => (React.createElement(NavigationItem, { key: button.text, data: button })))))),
|
|
52
48
|
React.createElement(OutsideClick, { onOutsideClick: () => onSidebarOpenedChange(false) },
|
|
53
|
-
React.createElement(MobileNavigation, { topItems: leftItems, bottomItems: rightItems, isOpened: isSidebarOpened,
|
|
49
|
+
React.createElement(MobileNavigation, { topItems: leftItems, bottomItems: rightItems, isOpened: isSidebarOpened, activeItemIndex: activeItemIndex, onActiveItemChange: onActiveItemChange, onClose: hideSidebar })))))));
|
|
54
50
|
};
|
|
55
51
|
export default Header;
|
|
@@ -24,10 +24,7 @@ unpredictable css rules order in build */
|
|
|
24
24
|
.pc-mobile-navigation__button {
|
|
25
25
|
margin-top: 24px;
|
|
26
26
|
}
|
|
27
|
-
.pc-mobile-
|
|
28
|
-
margin-bottom: 24px;
|
|
29
|
-
}
|
|
30
|
-
.pc-mobile-navigation__rows {
|
|
27
|
+
.pc-mobile-navigation__links {
|
|
31
28
|
position: relative;
|
|
32
29
|
display: flex;
|
|
33
30
|
flex-direction: column;
|
|
@@ -36,7 +33,7 @@ unpredictable css rules order in build */
|
|
|
36
33
|
padding: 0;
|
|
37
34
|
list-style: none;
|
|
38
35
|
}
|
|
39
|
-
.pc-mobile-
|
|
36
|
+
.pc-mobile-navigation__links-item:not(:last-child) {
|
|
40
37
|
margin-bottom: 24px;
|
|
41
38
|
}
|
|
42
39
|
.pc-mobile-navigation__dropdown-item:not(:last-child) {
|
|
@@ -6,9 +6,9 @@ export interface MobileNavigationProps {
|
|
|
6
6
|
isOpened?: boolean;
|
|
7
7
|
topItems?: NavigationItemModel[];
|
|
8
8
|
bottomItems?: NavigationItemModel[];
|
|
9
|
-
|
|
9
|
+
activeItemIndex: number;
|
|
10
10
|
onClose: () => void;
|
|
11
|
-
onActiveItemChange: (index:
|
|
11
|
+
onActiveItemChange: (index: number) => void;
|
|
12
12
|
}
|
|
13
13
|
declare const MobileNavigation: React.FC<MobileNavigationProps>;
|
|
14
14
|
export default MobileNavigation;
|
|
@@ -3,7 +3,6 @@ import { Popup, Portal } from '@gravity-ui/uikit';
|
|
|
3
3
|
import { block } from '../../../utils';
|
|
4
4
|
import Foldable from '../../../components/Foldable/Foldable';
|
|
5
5
|
import { NavigationItemType } from '../../../models';
|
|
6
|
-
import { ItemColumnName } from '../../constants';
|
|
7
6
|
import NavigationItem from '../NavigationItem/NavigationItem';
|
|
8
7
|
import './MobileNavigation.css';
|
|
9
8
|
const b = block('mobile-navigation');
|
|
@@ -13,31 +12,32 @@ const MobileNavigationDropdown = ({ data, onItemClick, onToggle, isOpened = fals
|
|
|
13
12
|
React.createElement(NavigationItem, { data: data, onClick: onToggle, isOpened: isOpened }),
|
|
14
13
|
isOpened && (React.createElement(Popup, { anchorRef: ref, open: isOpened, className: b('popup') }, data.items.map((item) => (React.createElement(NavigationItem, { key: item.text, data: item, className: b('dropdown-item'), onClick: onItemClick })))))));
|
|
15
14
|
};
|
|
16
|
-
const MobileNavigationItem = ({
|
|
17
|
-
const id = `${column}-${index}`;
|
|
18
|
-
const isActive = id === activeItemId && isOpened;
|
|
15
|
+
const MobileNavigationItem = ({ link, index, isActive, onActiveItemChange, onClose, }) => {
|
|
19
16
|
const toggleActive = useCallback((e) => {
|
|
20
17
|
e.stopPropagation();
|
|
21
18
|
if (onActiveItemChange) {
|
|
22
|
-
onActiveItemChange(isActive ?
|
|
19
|
+
onActiveItemChange(isActive ? -1 : index);
|
|
23
20
|
}
|
|
24
|
-
}, [
|
|
21
|
+
}, [isActive, index, onActiveItemChange]);
|
|
25
22
|
const onItemClick = useCallback((e) => {
|
|
26
23
|
toggleActive(e);
|
|
27
24
|
onClose();
|
|
28
25
|
}, [toggleActive, onClose]);
|
|
29
|
-
return (React.createElement("li", { key: index, className: b('
|
|
26
|
+
return (React.createElement("li", { key: index, className: b('links-item') }, link.type === NavigationItemType.Dropdown ? (React.createElement(MobileNavigationDropdown, { data: link, onToggle: toggleActive, isOpened: isActive, onItemClick: onItemClick })) : (React.createElement(NavigationItem, { data: link, onClick: onItemClick }))));
|
|
30
27
|
};
|
|
31
28
|
const MobileNavigation = (props) => {
|
|
32
29
|
if (typeof window === 'undefined') {
|
|
33
30
|
return null;
|
|
34
31
|
}
|
|
35
|
-
const { isOpened, topItems, bottomItems,
|
|
32
|
+
const { isOpened, topItems, bottomItems, activeItemIndex, onActiveItemChange, onClose } = props;
|
|
36
33
|
return (React.createElement(Portal, null,
|
|
37
34
|
React.createElement(Foldable, { key: topItems === null || topItems === void 0 ? void 0 : topItems.length, className: b(), isOpened: Boolean(isOpened) },
|
|
38
35
|
React.createElement("div", { className: b('wrapper') },
|
|
39
|
-
React.createElement("nav",
|
|
40
|
-
React.createElement("ul", { className: b('
|
|
41
|
-
|
|
36
|
+
React.createElement("nav", null,
|
|
37
|
+
React.createElement("ul", { className: b('links') }, topItems === null || topItems === void 0 ? void 0 : topItems.map((link, index) => {
|
|
38
|
+
const isActive = index === activeItemIndex;
|
|
39
|
+
return (React.createElement(MobileNavigationItem, { key: index, link: link, index: index, isActive: isOpened && isActive, onClose: onClose, onActiveItemChange: onActiveItemChange }));
|
|
40
|
+
}))), bottomItems === null || bottomItems === void 0 ? void 0 :
|
|
41
|
+
bottomItems.map((item) => (React.createElement(NavigationItem, { key: item.text, data: item, className: b('button') })))))));
|
|
42
42
|
};
|
|
43
43
|
export default MobileNavigation;
|
|
@@ -29,4 +29,15 @@ unpredictable css rules order in build */
|
|
|
29
29
|
}
|
|
30
30
|
.pc-navigation__links-item:not(:last-child) {
|
|
31
31
|
margin-right: 20px;
|
|
32
|
+
}
|
|
33
|
+
.pc-navigation__slider-container {
|
|
34
|
+
position: absolute;
|
|
35
|
+
right: 0;
|
|
36
|
+
bottom: 0;
|
|
37
|
+
left: 0;
|
|
38
|
+
}
|
|
39
|
+
.pc-navigation__slider {
|
|
40
|
+
width: 100%;
|
|
41
|
+
height: 2px;
|
|
42
|
+
background-color: var(--yc-color-text-link);
|
|
32
43
|
}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { NavigationItemModel } from '../../../models/navigation';
|
|
1
|
+
import React, { MouseEventHandler } from 'react';
|
|
2
|
+
import { NavigationDropdownItem, NavigationItemModel } from '../../../models/navigation';
|
|
3
3
|
import './Navigation.css';
|
|
4
4
|
export interface NavigationProps {
|
|
5
5
|
links: NavigationItemModel[];
|
|
6
|
-
|
|
7
|
-
onActiveItemChange: (index:
|
|
6
|
+
activeItemIndex: number;
|
|
7
|
+
onActiveItemChange: (index: number) => void;
|
|
8
8
|
className?: string;
|
|
9
9
|
highlightActiveItem?: boolean;
|
|
10
10
|
}
|
|
11
|
+
export interface NavigationDropdownProps {
|
|
12
|
+
data: NavigationDropdownItem;
|
|
13
|
+
onClick: MouseEventHandler;
|
|
14
|
+
isActive: boolean;
|
|
15
|
+
position: number;
|
|
16
|
+
hidePopup: () => void;
|
|
17
|
+
}
|
|
11
18
|
declare const Navigation: React.FC<NavigationProps>;
|
|
12
19
|
export default Navigation;
|
|
@@ -1,20 +1,32 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
1
2
|
import _ from 'lodash';
|
|
2
|
-
import React, { useState, useEffect, useCallback, useContext, useRef } from 'react';
|
|
3
|
+
import React, { Fragment, useState, useEffect, useCallback, useContext, useRef, } from 'react';
|
|
3
4
|
import { block } from '../../../utils';
|
|
4
5
|
import OverflowScroller from '../../../components/OverflowScroller/OverflowScroller';
|
|
6
|
+
import { NavigationItemType, } from '../../../models/navigation';
|
|
7
|
+
import NavigationPopup from '../NavigationPopup/NavigationPopup';
|
|
8
|
+
import NavigationItem from '../NavigationItem/NavigationItem';
|
|
5
9
|
import { LocationContext } from '../../../context/locationContext';
|
|
6
|
-
import { ItemColumnName } from '../../constants';
|
|
7
|
-
import { NavigationListItem } from '../NavigationListItem/NavigationListItem';
|
|
8
10
|
import './Navigation.css';
|
|
9
11
|
const b = block('navigation');
|
|
10
|
-
const
|
|
12
|
+
const NavigationDropdown = ({ data, isActive, position, hidePopup, onClick, }) => {
|
|
13
|
+
const { text, items } = data, popupProps = __rest(data, ["text", "items"]);
|
|
14
|
+
return (React.createElement(Fragment, null,
|
|
15
|
+
React.createElement(NavigationItem, { className: b('link'), onClick: onClick, isOpened: isActive, data: { text, type: NavigationItemType.Dropdown } }),
|
|
16
|
+
isActive && (React.createElement(NavigationPopup, Object.assign({ left: position, onClose: hidePopup, items: items }, popupProps)))));
|
|
17
|
+
};
|
|
18
|
+
const Navigation = ({ className, onActiveItemChange, links, activeItemIndex, highlightActiveItem, }) => {
|
|
11
19
|
const { asPath, pathname } = useContext(LocationContext);
|
|
12
20
|
const itemRefs = useRef([]);
|
|
13
21
|
const [itemPositions, setItemPosition] = useState([]);
|
|
14
22
|
const [lastLeftScroll, setLastLeftScroll] = useState(0);
|
|
15
23
|
const hidePopup = useCallback(() => {
|
|
16
|
-
onActiveItemChange(
|
|
24
|
+
onActiveItemChange(-1);
|
|
17
25
|
}, [onActiveItemChange]);
|
|
26
|
+
const getItemClickHandler = useCallback((index) => (e) => {
|
|
27
|
+
e.stopPropagation();
|
|
28
|
+
onActiveItemChange(index === activeItemIndex ? -1 : index);
|
|
29
|
+
}, [activeItemIndex, onActiveItemChange]);
|
|
18
30
|
const calculateItemPositions = useCallback(() => {
|
|
19
31
|
if (itemRefs.current.length) {
|
|
20
32
|
const currentItemPositions = itemRefs.current.map((itemRef) => (itemRef && itemRef.getBoundingClientRect().left) || 0);
|
|
@@ -44,6 +56,13 @@ const Navigation = ({ className, onActiveItemChange, links, activeItemId, highli
|
|
|
44
56
|
}, [hidePopup, asPath, pathname]);
|
|
45
57
|
return (React.createElement(OverflowScroller, { className: b(null, className), onScrollStart: hidePopup, onScrollEnd: calculateItemPositions },
|
|
46
58
|
React.createElement("nav", null,
|
|
47
|
-
React.createElement("ul", { className: b('links') }, links.map((link, index) =>
|
|
59
|
+
React.createElement("ul", { className: b('links') }, links.map((link, index) => {
|
|
60
|
+
const isActive = index === activeItemIndex;
|
|
61
|
+
const onClick = getItemClickHandler(index);
|
|
62
|
+
return (React.createElement("li", { ref: (el) => itemRefs.current.push(el), key: index, className: b('links-item') },
|
|
63
|
+
link.type === NavigationItemType.Dropdown ? (React.createElement(NavigationDropdown, { data: link, onClick: onClick, isActive: isActive, position: itemPositions[index], hidePopup: hidePopup })) : (React.createElement(NavigationItem, { data: link, onClick: onClick })),
|
|
64
|
+
highlightActiveItem && isActive && (React.createElement("div", { className: b('slider-container') },
|
|
65
|
+
React.createElement("div", { className: b('slider') })))));
|
|
66
|
+
})))));
|
|
48
67
|
};
|
|
49
68
|
export default Navigation;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/page-constructor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.23.0",
|
|
4
4
|
"description": "Gravity UI Page Constructor",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -136,8 +136,5 @@
|
|
|
136
136
|
"*.{json,yaml,yml,md}": [
|
|
137
137
|
"prettier --write"
|
|
138
138
|
]
|
|
139
|
-
},
|
|
140
|
-
"publishConfig": {
|
|
141
|
-
"tag": "alpha"
|
|
142
139
|
}
|
|
143
140
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React, { MouseEventHandler } from 'react';
|
|
2
|
-
import { NavigationDropdownItem } from '../../../models';
|
|
3
|
-
export interface NavigationDropdownProps {
|
|
4
|
-
data: NavigationDropdownItem;
|
|
5
|
-
onClick: MouseEventHandler;
|
|
6
|
-
isActive: boolean;
|
|
7
|
-
position: number;
|
|
8
|
-
hidePopup: () => void;
|
|
9
|
-
}
|
|
10
|
-
declare const NavigationDropdown: React.FC<NavigationDropdownProps>;
|
|
11
|
-
export default NavigationDropdown;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
-
const models_1 = require("../../../models");
|
|
6
|
-
const NavigationItem_1 = tslib_1.__importDefault(require("../NavigationItem/NavigationItem"));
|
|
7
|
-
const NavigationPopup_1 = tslib_1.__importDefault(require("../NavigationPopup/NavigationPopup"));
|
|
8
|
-
const NavigationDropdown = ({ data, isActive, position, hidePopup, onClick, }) => {
|
|
9
|
-
const { text, icon, items } = data, popupProps = tslib_1.__rest(data, ["text", "icon", "items"]);
|
|
10
|
-
return (react_1.default.createElement(react_1.Fragment, null,
|
|
11
|
-
react_1.default.createElement(NavigationItem_1.default, { onClick: onClick, isOpened: isActive, data: { text, type: models_1.NavigationItemType.Dropdown, icon } }),
|
|
12
|
-
isActive && (react_1.default.createElement(NavigationPopup_1.default, Object.assign({ left: position, onClose: hidePopup, items: items }, popupProps)))));
|
|
13
|
-
};
|
|
14
|
-
exports.default = NavigationDropdown;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ClassNameProps, NavigationItemModel } from '../../../models';
|
|
3
|
-
import { ItemColumnName } from '../../constants';
|
|
4
|
-
type NavigationListItemProps = {
|
|
5
|
-
item: NavigationItemModel;
|
|
6
|
-
index: number;
|
|
7
|
-
activeItemId: string;
|
|
8
|
-
hidePopup: () => void;
|
|
9
|
-
column: ItemColumnName;
|
|
10
|
-
onActiveItemChange: (index: string) => void;
|
|
11
|
-
itemPositions?: number[];
|
|
12
|
-
itemRefs?: React.MutableRefObject<(HTMLLIElement | null)[]>;
|
|
13
|
-
highlightActiveItem?: boolean;
|
|
14
|
-
} & ClassNameProps;
|
|
15
|
-
export declare const NavigationListItem: ({ item, itemRefs, className, index, activeItemId, highlightActiveItem, hidePopup, itemPositions, column, onActiveItemChange, }: NavigationListItemProps) => JSX.Element;
|
|
16
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NavigationListItem = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
-
const utils_1 = require("../../../utils");
|
|
7
|
-
const models_1 = require("../../../models");
|
|
8
|
-
const utils_2 = require("../../utils");
|
|
9
|
-
const NavigationDropdownItem_1 = tslib_1.__importDefault(require("../NavigationDropdownItem/NavigationDropdownItem"));
|
|
10
|
-
const NavigationItem_1 = tslib_1.__importDefault(require("../NavigationItem/NavigationItem"));
|
|
11
|
-
const b = (0, utils_1.block)('navigation');
|
|
12
|
-
const NavigationListItem = ({ item, itemRefs, className, index, activeItemId, highlightActiveItem, hidePopup, itemPositions, column, onActiveItemChange, }) => {
|
|
13
|
-
var _a;
|
|
14
|
-
const ref = (0, react_1.useRef)(null);
|
|
15
|
-
const id = `${column}-${index}`;
|
|
16
|
-
const isActive = id === activeItemId;
|
|
17
|
-
const onClick = (0, utils_2.getItemClickHandler)({
|
|
18
|
-
column,
|
|
19
|
-
index,
|
|
20
|
-
activeItemId,
|
|
21
|
-
onActiveItemChange,
|
|
22
|
-
});
|
|
23
|
-
return (react_1.default.createElement("li", { ref: itemRefs ? (el) => itemRefs.current.push(el) : ref, className: className },
|
|
24
|
-
item.type === models_1.NavigationItemType.Dropdown ? (react_1.default.createElement(NavigationDropdownItem_1.default, { data: item, onClick: onClick, isActive: isActive, position: (itemPositions === null || itemPositions === void 0 ? void 0 : itemPositions[index]) || ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().left) || 0, hidePopup: hidePopup })) : (react_1.default.createElement(NavigationItem_1.default, { data: item, onClick: onClick })),
|
|
25
|
-
highlightActiveItem && isActive && (react_1.default.createElement("div", { className: b('slider-container') },
|
|
26
|
-
react_1.default.createElement("div", { className: b('slider') })))));
|
|
27
|
-
};
|
|
28
|
-
exports.NavigationListItem = NavigationListItem;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ItemColumnName = void 0;
|
|
4
|
-
var ItemColumnName;
|
|
5
|
-
(function (ItemColumnName) {
|
|
6
|
-
ItemColumnName["Left"] = "left";
|
|
7
|
-
ItemColumnName["Right"] = "right";
|
|
8
|
-
ItemColumnName["Top"] = "top";
|
|
9
|
-
ItemColumnName["Bottom"] = "bottom";
|
|
10
|
-
})(ItemColumnName = exports.ItemColumnName || (exports.ItemColumnName = {}));
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { MouseEventHandler } from 'react';
|
|
2
|
-
import { ItemColumnName } from './constants';
|
|
3
|
-
type GetItemClickHandlerArgs = {
|
|
4
|
-
column: ItemColumnName;
|
|
5
|
-
index: number;
|
|
6
|
-
activeItemId: string;
|
|
7
|
-
onActiveItemChange: (index: string) => void;
|
|
8
|
-
};
|
|
9
|
-
export declare const getItemClickHandler: ({ column, index, onActiveItemChange, }: GetItemClickHandlerArgs) => MouseEventHandler;
|
|
10
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getItemClickHandler = void 0;
|
|
4
|
-
const getItemClickHandler = ({ column, index, onActiveItemChange, activeItemId }) => (e) => {
|
|
5
|
-
const id = `${column}-${index}`;
|
|
6
|
-
e.stopPropagation();
|
|
7
|
-
onActiveItemChange(id === activeItemId ? '' : `${column}-${index}`);
|
|
8
|
-
};
|
|
9
|
-
exports.getItemClickHandler = getItemClickHandler;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React, { MouseEventHandler } from 'react';
|
|
2
|
-
import { NavigationDropdownItem } from '../../../models';
|
|
3
|
-
export interface NavigationDropdownProps {
|
|
4
|
-
data: NavigationDropdownItem;
|
|
5
|
-
onClick: MouseEventHandler;
|
|
6
|
-
isActive: boolean;
|
|
7
|
-
position: number;
|
|
8
|
-
hidePopup: () => void;
|
|
9
|
-
}
|
|
10
|
-
declare const NavigationDropdown: React.FC<NavigationDropdownProps>;
|
|
11
|
-
export default NavigationDropdown;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { __rest } from "tslib";
|
|
2
|
-
import React, { Fragment } from 'react';
|
|
3
|
-
import { NavigationItemType } from '../../../models';
|
|
4
|
-
import NavigationItem from '../NavigationItem/NavigationItem';
|
|
5
|
-
import NavigationPopup from '../NavigationPopup/NavigationPopup';
|
|
6
|
-
const NavigationDropdown = ({ data, isActive, position, hidePopup, onClick, }) => {
|
|
7
|
-
const { text, icon, items } = data, popupProps = __rest(data, ["text", "icon", "items"]);
|
|
8
|
-
return (React.createElement(Fragment, null,
|
|
9
|
-
React.createElement(NavigationItem, { onClick: onClick, isOpened: isActive, data: { text, type: NavigationItemType.Dropdown, icon } }),
|
|
10
|
-
isActive && (React.createElement(NavigationPopup, Object.assign({ left: position, onClose: hidePopup, items: items }, popupProps)))));
|
|
11
|
-
};
|
|
12
|
-
export default NavigationDropdown;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ClassNameProps, NavigationItemModel } from '../../../models';
|
|
3
|
-
import { ItemColumnName } from '../../constants';
|
|
4
|
-
import './NavigationListItem.css';
|
|
5
|
-
type NavigationListItemProps = {
|
|
6
|
-
item: NavigationItemModel;
|
|
7
|
-
index: number;
|
|
8
|
-
activeItemId: string;
|
|
9
|
-
hidePopup: () => void;
|
|
10
|
-
column: ItemColumnName;
|
|
11
|
-
onActiveItemChange: (index: string) => void;
|
|
12
|
-
itemPositions?: number[];
|
|
13
|
-
itemRefs?: React.MutableRefObject<(HTMLLIElement | null)[]>;
|
|
14
|
-
highlightActiveItem?: boolean;
|
|
15
|
-
} & ClassNameProps;
|
|
16
|
-
export declare const NavigationListItem: ({ item, itemRefs, className, index, activeItemId, highlightActiveItem, hidePopup, itemPositions, column, onActiveItemChange, }: NavigationListItemProps) => JSX.Element;
|
|
17
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React, { useRef } from 'react';
|
|
2
|
-
import { block } from '../../../utils';
|
|
3
|
-
import { NavigationItemType } from '../../../models';
|
|
4
|
-
import { getItemClickHandler } from '../../utils';
|
|
5
|
-
import NavigationDropdownItem from '../NavigationDropdownItem/NavigationDropdownItem';
|
|
6
|
-
import NavigationItem from '../NavigationItem/NavigationItem';
|
|
7
|
-
import './NavigationListItem.css';
|
|
8
|
-
const b = block('navigation');
|
|
9
|
-
export const NavigationListItem = ({ item, itemRefs, className, index, activeItemId, highlightActiveItem, hidePopup, itemPositions, column, onActiveItemChange, }) => {
|
|
10
|
-
var _a;
|
|
11
|
-
const ref = useRef(null);
|
|
12
|
-
const id = `${column}-${index}`;
|
|
13
|
-
const isActive = id === activeItemId;
|
|
14
|
-
const onClick = getItemClickHandler({
|
|
15
|
-
column,
|
|
16
|
-
index,
|
|
17
|
-
activeItemId,
|
|
18
|
-
onActiveItemChange,
|
|
19
|
-
});
|
|
20
|
-
return (React.createElement("li", { ref: itemRefs ? (el) => itemRefs.current.push(el) : ref, className: className },
|
|
21
|
-
item.type === NavigationItemType.Dropdown ? (React.createElement(NavigationDropdownItem, { data: item, onClick: onClick, isActive: isActive, position: (itemPositions === null || itemPositions === void 0 ? void 0 : itemPositions[index]) || ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().left) || 0, hidePopup: hidePopup })) : (React.createElement(NavigationItem, { data: item, onClick: onClick })),
|
|
22
|
-
highlightActiveItem && isActive && (React.createElement("div", { className: b('slider-container') },
|
|
23
|
-
React.createElement("div", { className: b('slider') })))));
|
|
24
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { MouseEventHandler } from 'react';
|
|
2
|
-
import { ItemColumnName } from './constants';
|
|
3
|
-
type GetItemClickHandlerArgs = {
|
|
4
|
-
column: ItemColumnName;
|
|
5
|
-
index: number;
|
|
6
|
-
activeItemId: string;
|
|
7
|
-
onActiveItemChange: (index: string) => void;
|
|
8
|
-
};
|
|
9
|
-
export declare const getItemClickHandler: ({ column, index, onActiveItemChange, }: GetItemClickHandlerArgs) => MouseEventHandler;
|
|
10
|
-
export {};
|