@gravity-ui/page-constructor 2.0.0-beta.0 → 2.0.0-beta.1

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 (40) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/build/cjs/blocks/ExtendedFeatures/ExtendedFeatures.css +4 -4
  3. package/build/cjs/blocks/ExtendedFeatures/ExtendedFeatures.js +1 -1
  4. package/build/cjs/navigation/components/Header/Header.css +23 -0
  5. package/build/cjs/navigation/components/Header/Header.js +12 -8
  6. package/build/cjs/navigation/components/MobileNavigation/MobileNavigation.css +5 -2
  7. package/build/cjs/navigation/components/MobileNavigation/MobileNavigation.d.ts +2 -2
  8. package/build/cjs/navigation/components/MobileNavigation/MobileNavigation.js +11 -11
  9. package/build/cjs/navigation/components/Navigation/Navigation.css +0 -11
  10. package/build/cjs/navigation/components/Navigation/Navigation.d.ts +4 -11
  11. package/build/cjs/navigation/components/Navigation/Navigation.js +5 -23
  12. package/build/cjs/navigation/components/NavigationDropdownItem/NavigationDropdownItem.d.ts +11 -0
  13. package/build/cjs/navigation/components/NavigationDropdownItem/NavigationDropdownItem.js +14 -0
  14. package/build/cjs/navigation/components/NavigationListItem/NavigationListItem.css +11 -0
  15. package/build/cjs/navigation/components/NavigationListItem/NavigationListItem.d.ts +16 -0
  16. package/build/cjs/navigation/components/NavigationListItem/NavigationListItem.js +28 -0
  17. package/build/cjs/navigation/constants.d.ts +6 -0
  18. package/build/cjs/navigation/constants.js +10 -0
  19. package/build/cjs/navigation/utils.d.ts +10 -0
  20. package/build/cjs/navigation/utils.js +11 -0
  21. package/build/esm/blocks/ExtendedFeatures/ExtendedFeatures.css +4 -4
  22. package/build/esm/blocks/ExtendedFeatures/ExtendedFeatures.js +1 -1
  23. package/build/esm/navigation/components/Header/Header.css +23 -0
  24. package/build/esm/navigation/components/Header/Header.js +12 -8
  25. package/build/esm/navigation/components/MobileNavigation/MobileNavigation.css +5 -2
  26. package/build/esm/navigation/components/MobileNavigation/MobileNavigation.d.ts +2 -2
  27. package/build/esm/navigation/components/MobileNavigation/MobileNavigation.js +11 -11
  28. package/build/esm/navigation/components/Navigation/Navigation.css +0 -11
  29. package/build/esm/navigation/components/Navigation/Navigation.d.ts +4 -11
  30. package/build/esm/navigation/components/Navigation/Navigation.js +6 -25
  31. package/build/esm/navigation/components/NavigationDropdownItem/NavigationDropdownItem.d.ts +11 -0
  32. package/build/esm/navigation/components/NavigationDropdownItem/NavigationDropdownItem.js +12 -0
  33. package/build/esm/navigation/components/NavigationListItem/NavigationListItem.css +11 -0
  34. package/build/esm/navigation/components/NavigationListItem/NavigationListItem.d.ts +17 -0
  35. package/build/esm/navigation/components/NavigationListItem/NavigationListItem.js +24 -0
  36. package/build/esm/navigation/constants.d.ts +6 -0
  37. package/build/esm/navigation/constants.js +7 -0
  38. package/build/esm/navigation/utils.d.ts +10 -0
  39. package/build/esm/navigation/utils.js +7 -0
  40. package/package.json +2 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.25.2](https://github.com/gravity-ui/page-constructor/compare/v1.25.1...v1.25.2) (2023-03-21)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **ExtendedFeatures:** label position fixed ([#175](https://github.com/gravity-ui/page-constructor/issues/175)) ([fb8d206](https://github.com/gravity-ui/page-constructor/commit/fb8d206ad2378564a1dc7a7295f02da13ae66df1))
9
+
10
+ ## [1.25.1](https://github.com/gravity-ui/page-constructor/compare/v1.25.0...v1.25.1) (2023-03-20)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * cannot read stopPropagation of undefined in navigation utils ([#221](https://github.com/gravity-ui/page-constructor/issues/221)) ([e20904a](https://github.com/gravity-ui/page-constructor/commit/e20904abfcc14339be777747a4c26187dba8cd58))
16
+
17
+ ## [1.25.0](https://github.com/gravity-ui/page-constructor/compare/v1.24.0...v1.25.0) (2023-03-14)
18
+
19
+
20
+ ### Features
21
+
22
+ * update react-player version ([#217](https://github.com/gravity-ui/page-constructor/issues/217)) ([806dea6](https://github.com/gravity-ui/page-constructor/commit/806dea69c911c789782b8100a364187675ebf3d3))
23
+
24
+ ## [1.24.0](https://github.com/gravity-ui/page-constructor/compare/v1.23.0...v1.24.0) (2023-03-13)
25
+
26
+
27
+ ### Features
28
+
29
+ * add dropdown item in right column of navigation ([#213](https://github.com/gravity-ui/page-constructor/issues/213)) ([71f23a8](https://github.com/gravity-ui/page-constructor/commit/71f23a8ff00948fa62b3bd5b7833b171b59176d6))
30
+
3
31
  ## [1.23.0](https://github.com/gravity-ui/page-constructor/compare/v1.22.1...v1.23.0) (2023-03-09)
4
32
 
5
33
 
@@ -21,7 +21,7 @@ unpredictable css rules order in build */
21
21
  line-height: var(--yc-text-header-1-line-height);
22
22
  color: var(--pc-text-header-color);
23
23
  font-weight: var(--yc-text-accent-font-weight);
24
- display: flex;
24
+ display: block;
25
25
  position: relative;
26
26
  margin-bottom: 8px;
27
27
  }
@@ -42,13 +42,13 @@ unpredictable css rules order in build */
42
42
  font-size: var(--yc-text-caption-2-font-size);
43
43
  line-height: var(--yc-text-caption-2-line-height);
44
44
  position: relative;
45
- top: 5px;
45
+ top: -3px;
46
46
  height: 16px;
47
47
  margin-left: 8px;
48
- padding: 0 5px;
48
+ padding: 1.5px 5px 2px;
49
49
  color: var(--yc-color-base-background);
50
50
  background-color: var(--yc-my-color-brand-normal);
51
- border-radius: 3px;
51
+ border-radius: 4px;
52
52
  }
53
53
  .pc-ExtendedFeaturesBlock__item-text, .pc-ExtendedFeaturesBlock__item-link {
54
54
  font-size: var(--yc-text-body-2-font-size);
@@ -33,7 +33,7 @@ const ExtendedFeaturesBlock = ({ title, description, items, colSizes = DEFAULT_S
33
33
  react_1.default.createElement("div", { className: b('container') },
34
34
  itemTitle && (react_1.default.createElement("h5", { className: b('item-title') },
35
35
  react_1.default.createElement(components_1.HTML, null, itemTitle),
36
- label && (react_1.default.createElement("div", { className: b('item-label') }, label)))),
36
+ label && (react_1.default.createElement("span", { className: b('item-label') }, label)))),
37
37
  react_1.default.createElement(sub_blocks_1.Content, { text: text, links: itemLinks, size: "s", colSizes: { all: 12, md: 12 }, buttons: buttons, additionalInfo: additionalInfo }))));
38
38
  })))));
39
39
  };
@@ -41,6 +41,8 @@ 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);
44
46
  }
45
47
  .pc-header__navigation-container {
46
48
  display: flex;
@@ -53,6 +55,9 @@ unpredictable css rules order in build */
53
55
  .pc-header__buttons {
54
56
  display: flex;
55
57
  align-items: center;
58
+ margin: 0;
59
+ padding: 0;
60
+ list-style: none;
56
61
  }
57
62
  @media (max-width: 768px) {
58
63
  .pc-header__buttons {
@@ -62,6 +67,24 @@ unpredictable css rules order in build */
62
67
  .pc-header__buttons > *:not(:last-child) {
63
68
  margin-right: 16px;
64
69
  }
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
+ }
65
88
  .pc-header__button {
66
89
  margin-top: 0;
67
90
  }
@@ -7,11 +7,12 @@ 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");
10
12
  const Navigation_1 = tslib_1.__importDefault(require("../Navigation/Navigation"));
11
13
  const MobileNavigation_1 = tslib_1.__importDefault(require("../MobileNavigation/MobileNavigation"));
12
- const NavigationItem_1 = tslib_1.__importDefault(require("../NavigationItem/NavigationItem"));
13
14
  const Logo_1 = tslib_1.__importDefault(require("../Logo/Logo"));
14
- const icons_1 = require("../../../icons");
15
+ const NavigationListItem_1 = require("../NavigationListItem/NavigationListItem");
15
16
  const b = (0, utils_1.block)('header');
16
17
  const ICON_SIZE = 36;
17
18
  const MobileMenuButton = ({ isSidebarOpened, onSidebarOpenedChange, }) => {
@@ -27,10 +28,13 @@ const MobileMenuButton = ({ isSidebarOpened, onSidebarOpenedChange, }) => {
27
28
  const Header = ({ data, logo }) => {
28
29
  const { leftItems, rightItems } = data;
29
30
  const [isSidebarOpened, setIsSidebarOpened] = (0, react_1.useState)(false);
30
- const [activeItemIndex, setActiveItemIndex] = (0, react_1.useState)(-1);
31
- const onActiveItemChange = (0, react_1.useCallback)((index) => {
32
- setActiveItemIndex(index);
31
+ const [activeItemId, setactiveItemId] = (0, react_1.useState)(undefined);
32
+ const onActiveItemChange = (0, react_1.useCallback)((id) => {
33
+ setactiveItemId(id);
33
34
  }, []);
35
+ const hidePopup = (0, react_1.useCallback)(() => {
36
+ onActiveItemChange();
37
+ }, [onActiveItemChange]);
34
38
  const onSidebarOpenedChange = (0, react_1.useCallback)((isOpen) => {
35
39
  setIsSidebarOpened(isOpen);
36
40
  }, []);
@@ -44,12 +48,12 @@ const Header = ({ data, logo }) => {
44
48
  logo && (react_1.default.createElement("div", { className: b('left') },
45
49
  react_1.default.createElement(Logo_1.default, Object.assign({}, logo, { className: b('logo') })))),
46
50
  react_1.default.createElement("div", { className: b('navigation-container') },
47
- react_1.default.createElement(Navigation_1.default, { className: b('navigation'), links: leftItems, activeItemIndex: activeItemIndex, onActiveItemChange: onActiveItemChange })),
51
+ react_1.default.createElement(Navigation_1.default, { className: b('navigation'), links: leftItems, activeItemId: activeItemId, onActiveItemChange: onActiveItemChange })),
48
52
  react_1.default.createElement("div", { className: b('right') },
49
53
  react_1.default.createElement(MobileMenuButton, { isSidebarOpened: isSidebarOpened, onSidebarOpenedChange: onSidebarOpenedChange }),
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 })))))),
54
+ rightItems && (react_1.default.createElement("ul", { className: b('buttons') }, rightItems.map((button, index) => (react_1.default.createElement(NavigationListItem_1.NavigationListItem, { key: index, className: b('buttons-item'), item: button, index: index, activeItemId: activeItemId, hidePopup: hidePopup, column: constants_1.ItemColumnName.Right, onActiveItemChange: onActiveItemChange })))))),
51
55
  react_1.default.createElement(OutsideClick_1.default, { onOutsideClick: () => onSidebarOpenedChange(false) },
52
- react_1.default.createElement(MobileNavigation_1.default, { topItems: leftItems, bottomItems: rightItems, isOpened: isSidebarOpened, activeItemIndex: activeItemIndex, onActiveItemChange: onActiveItemChange, onClose: hideSidebar })))))));
56
+ react_1.default.createElement(MobileNavigation_1.default, { topItems: leftItems, bottomItems: rightItems, isOpened: isSidebarOpened, activeItemId: activeItemId, onActiveItemChange: onActiveItemChange, onClose: hideSidebar })))))));
53
57
  };
54
58
  exports.Header = Header;
55
59
  exports.default = exports.Header;
@@ -24,7 +24,10 @@ unpredictable css rules order in build */
24
24
  .pc-mobile-navigation__button {
25
25
  margin-top: 24px;
26
26
  }
27
- .pc-mobile-navigation__links {
27
+ .pc-mobile-navigation__nav {
28
+ margin-bottom: 24px;
29
+ }
30
+ .pc-mobile-navigation__rows {
28
31
  position: relative;
29
32
  display: flex;
30
33
  flex-direction: column;
@@ -33,7 +36,7 @@ unpredictable css rules order in build */
33
36
  padding: 0;
34
37
  list-style: none;
35
38
  }
36
- .pc-mobile-navigation__links-item:not(:last-child) {
39
+ .pc-mobile-navigation__rows-item:not(:last-child) {
37
40
  margin-bottom: 24px;
38
41
  }
39
42
  .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
- activeItemIndex: number;
8
+ activeItemId?: string;
9
9
  onClose: () => void;
10
- onActiveItemChange: (index: number) => void;
10
+ onActiveItemChange: (id?: string) => void;
11
11
  }
12
12
  declare const MobileNavigation: React.FC<MobileNavigationProps>;
13
13
  export default MobileNavigation;
@@ -6,6 +6,7 @@ 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");
9
10
  const NavigationItem_1 = tslib_1.__importDefault(require("../NavigationItem/NavigationItem"));
10
11
  const b = (0, utils_1.block)('mobile-navigation');
11
12
  const MobileNavigationDropdown = ({ data, onItemClick, onToggle, isOpened = false, }) => {
@@ -14,32 +15,31 @@ const MobileNavigationDropdown = ({ data, onItemClick, onToggle, isOpened = fals
14
15
  react_1.default.createElement(NavigationItem_1.default, { data: data, onClick: onToggle, isOpened: isOpened }),
15
16
  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 })))))));
16
17
  };
17
- const MobileNavigationItem = ({ link, index, isActive, onActiveItemChange, onClose, }) => {
18
+ const MobileNavigationItem = ({ item, index, isOpened, activeItemId, onActiveItemChange, column, onClose, }) => {
19
+ const id = `${column}-${index}`;
20
+ const isActive = id === activeItemId && isOpened;
18
21
  const toggleActive = (0, react_1.useCallback)((e) => {
19
22
  e.stopPropagation();
20
23
  if (onActiveItemChange) {
21
- onActiveItemChange(isActive ? -1 : index);
24
+ onActiveItemChange(isActive ? undefined : `${column}-${index}`);
22
25
  }
23
- }, [isActive, index, onActiveItemChange]);
26
+ }, [onActiveItemChange, isActive, column, index]);
24
27
  const onItemClick = (0, react_1.useCallback)((e) => {
25
28
  toggleActive(e);
26
29
  onClose();
27
30
  }, [toggleActive, onClose]);
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 }))));
31
+ return (react_1.default.createElement("li", { key: index, className: b('rows-item') }, item.type === models_1.NavigationItemType.Dropdown ? (react_1.default.createElement(MobileNavigationDropdown, { data: item, onToggle: toggleActive, isOpened: isActive, onItemClick: onItemClick })) : (react_1.default.createElement(NavigationItem_1.default, { data: item, onClick: onItemClick }))));
29
32
  };
30
33
  const MobileNavigation = (props) => {
31
34
  if (typeof window === 'undefined') {
32
35
  return null;
33
36
  }
34
- const { isOpened, topItems, bottomItems, activeItemIndex, onActiveItemChange, onClose } = props;
37
+ const { isOpened, topItems, bottomItems, activeItemId, onActiveItemChange, onClose } = props;
35
38
  return (react_1.default.createElement(uikit_1.Portal, null,
36
39
  react_1.default.createElement(Foldable_1.default, { key: topItems === null || topItems === void 0 ? void 0 : topItems.length, className: b(), isOpened: Boolean(isOpened) },
37
40
  react_1.default.createElement("div", { className: b('wrapper') },
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') })))))));
41
+ react_1.default.createElement("nav", { className: b('nav') },
42
+ react_1.default.createElement("ul", { className: b('rows') }, topItems === null || topItems === void 0 ? void 0 : topItems.map((link, index) => (react_1.default.createElement(MobileNavigationItem, { key: index, item: link, column: constants_1.ItemColumnName.Top, index: index, isOpened: isOpened, activeItemId: activeItemId, onClose: onClose, onActiveItemChange: onActiveItemChange }))))),
43
+ react_1.default.createElement("ul", { className: b('rows') }, bottomItems === null || bottomItems === void 0 ? void 0 : bottomItems.map((item, index) => (react_1.default.createElement(MobileNavigationItem, { key: index, item: item, column: constants_1.ItemColumnName.Bottom, index: index, isOpened: isOpened, activeItemId: activeItemId, onClose: onClose, onActiveItemChange: onActiveItemChange }))))))));
44
44
  };
45
45
  exports.default = MobileNavigation;
@@ -29,15 +29,4 @@ 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);
43
32
  }
@@ -1,18 +1,11 @@
1
- import React, { MouseEventHandler } from 'react';
2
- import { NavigationDropdownItem, NavigationItemModel } from '../../../models/navigation';
1
+ import React from 'react';
2
+ import { NavigationItemModel } from '../../../models/navigation';
3
3
  export interface NavigationProps {
4
4
  links: NavigationItemModel[];
5
- activeItemIndex: number;
6
- onActiveItemChange: (index: number) => void;
5
+ activeItemId?: string;
7
6
  className?: string;
8
7
  highlightActiveItem?: boolean;
9
- }
10
- export interface NavigationDropdownProps {
11
- data: NavigationDropdownItem;
12
- onClick: MouseEventHandler;
13
- isActive: boolean;
14
- position: number;
15
- hidePopup: () => void;
8
+ onActiveItemChange: (id?: string) => void;
16
9
  }
17
10
  declare const Navigation: React.FC<NavigationProps>;
18
11
  export default Navigation;
@@ -5,29 +5,18 @@ 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"));
11
8
  const locationContext_1 = require("../../../context/locationContext");
9
+ const constants_1 = require("../../constants");
10
+ const NavigationListItem_1 = require("../NavigationListItem/NavigationListItem");
12
11
  const b = (0, utils_1.block)('navigation');
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, }) => {
12
+ const Navigation = ({ className, onActiveItemChange, links, activeItemId, highlightActiveItem, }) => {
20
13
  const { asPath, pathname } = (0, react_1.useContext)(locationContext_1.LocationContext);
21
14
  const itemRefs = (0, react_1.useRef)([]);
22
15
  const [itemPositions, setItemPosition] = (0, react_1.useState)([]);
23
16
  const [lastLeftScroll, setLastLeftScroll] = (0, react_1.useState)(0);
24
17
  const hidePopup = (0, react_1.useCallback)(() => {
25
- onActiveItemChange(-1);
18
+ onActiveItemChange();
26
19
  }, [onActiveItemChange]);
27
- const getItemClickHandler = (0, react_1.useCallback)((index) => (e) => {
28
- e.stopPropagation();
29
- onActiveItemChange(index === activeItemIndex ? -1 : index);
30
- }, [activeItemIndex, onActiveItemChange]);
31
20
  const calculateItemPositions = (0, react_1.useCallback)(() => {
32
21
  if (itemRefs.current.length) {
33
22
  const currentItemPositions = itemRefs.current.map((itemRef) => (itemRef && itemRef.getBoundingClientRect().left) || 0);
@@ -57,13 +46,6 @@ const Navigation = ({ className, onActiveItemChange, links, activeItemIndex, hig
57
46
  }, [hidePopup, asPath, pathname]);
58
47
  return (react_1.default.createElement(OverflowScroller_1.default, { className: b(null, className), onScrollStart: hidePopup, onScrollEnd: calculateItemPositions },
59
48
  react_1.default.createElement("nav", null,
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
- })))));
49
+ react_1.default.createElement("ul", { className: b('links') }, links.map((link, index) => (react_1.default.createElement(NavigationListItem_1.NavigationListItem, { key: index, className: b('links-item'), item: link, itemRefs: itemRefs, index: index, activeItemId: activeItemId, highlightActiveItem: highlightActiveItem, hidePopup: hidePopup, itemPositions: itemPositions, column: constants_1.ItemColumnName.Left, onActiveItemChange: onActiveItemChange })))))));
68
50
  };
69
51
  exports.default = Navigation;
@@ -0,0 +1,11 @@
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;
@@ -0,0 +1,14 @@
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;
@@ -0,0 +1,11 @@
1
+ .pc-navigation-list-item__slider-container {
2
+ position: absolute;
3
+ right: 0;
4
+ bottom: 0;
5
+ left: 0;
6
+ }
7
+ .pc-navigation-list-item__slider {
8
+ width: 100%;
9
+ height: 2px;
10
+ background-color: var(--yc-color-text-link);
11
+ }
@@ -0,0 +1,16 @@
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
+ column: ItemColumnName;
8
+ activeItemId?: string;
9
+ itemPositions?: number[];
10
+ itemRefs?: React.MutableRefObject<(HTMLLIElement | null)[]>;
11
+ highlightActiveItem?: boolean;
12
+ hidePopup: () => void;
13
+ onActiveItemChange: (id?: string) => void;
14
+ } & ClassNameProps;
15
+ export declare const NavigationListItem: ({ item, itemRefs, className, index, activeItemId, highlightActiveItem, hidePopup, itemPositions, column, onActiveItemChange, }: NavigationListItemProps) => JSX.Element;
16
+ export {};
@@ -0,0 +1,28 @@
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;
@@ -0,0 +1,6 @@
1
+ export declare enum ItemColumnName {
2
+ Left = "left",
3
+ Right = "right",
4
+ Top = "top",
5
+ Bottom = "bottom"
6
+ }
@@ -0,0 +1,10 @@
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 = {}));
@@ -0,0 +1,10 @@
1
+ import { MouseEventHandler } from 'react';
2
+ import { ItemColumnName } from './constants';
3
+ type GetItemClickHandlerArgs = {
4
+ column: ItemColumnName;
5
+ index: number;
6
+ activeItemId?: string;
7
+ onActiveItemChange: (id?: string) => void;
8
+ };
9
+ export declare const getItemClickHandler: ({ column, index, onActiveItemChange, }: GetItemClickHandlerArgs) => MouseEventHandler;
10
+ export {};
@@ -0,0 +1,11 @@
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
+ if (e) {
7
+ e.stopPropagation();
8
+ }
9
+ onActiveItemChange(id === activeItemId ? undefined : `${column}-${index}`);
10
+ };
11
+ exports.getItemClickHandler = getItemClickHandler;
@@ -21,7 +21,7 @@ unpredictable css rules order in build */
21
21
  line-height: var(--yc-text-header-1-line-height);
22
22
  color: var(--pc-text-header-color);
23
23
  font-weight: var(--yc-text-accent-font-weight);
24
- display: flex;
24
+ display: block;
25
25
  position: relative;
26
26
  margin-bottom: 8px;
27
27
  }
@@ -42,13 +42,13 @@ unpredictable css rules order in build */
42
42
  font-size: var(--yc-text-caption-2-font-size);
43
43
  line-height: var(--yc-text-caption-2-line-height);
44
44
  position: relative;
45
- top: 5px;
45
+ top: -3px;
46
46
  height: 16px;
47
47
  margin-left: 8px;
48
- padding: 0 5px;
48
+ padding: 1.5px 5px 2px;
49
49
  color: var(--yc-color-base-background);
50
50
  background-color: var(--yc-my-color-brand-normal);
51
- border-radius: 3px;
51
+ border-radius: 4px;
52
52
  }
53
53
  .pc-ExtendedFeaturesBlock__item-text, .pc-ExtendedFeaturesBlock__item-link {
54
54
  font-size: var(--yc-text-body-2-font-size);
@@ -30,7 +30,7 @@ export const ExtendedFeaturesBlock = ({ title, description, items, colSizes = DE
30
30
  React.createElement("div", { className: b('container') },
31
31
  itemTitle && (React.createElement("h5", { className: b('item-title') },
32
32
  React.createElement(HTML, null, itemTitle),
33
- label && (React.createElement("div", { className: b('item-label') }, label)))),
33
+ label && (React.createElement("span", { className: b('item-label') }, label)))),
34
34
  React.createElement(Content, { text: text, links: itemLinks, size: "s", colSizes: { all: 12, md: 12 }, buttons: buttons, additionalInfo: additionalInfo }))));
35
35
  })))));
36
36
  };
@@ -41,6 +41,8 @@ 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);
44
46
  }
45
47
  .pc-header__navigation-container {
46
48
  display: flex;
@@ -53,6 +55,9 @@ unpredictable css rules order in build */
53
55
  .pc-header__buttons {
54
56
  display: flex;
55
57
  align-items: center;
58
+ margin: 0;
59
+ padding: 0;
60
+ list-style: none;
56
61
  }
57
62
  @media (max-width: 768px) {
58
63
  .pc-header__buttons {
@@ -62,6 +67,24 @@ unpredictable css rules order in build */
62
67
  .pc-header__buttons > *:not(:last-child) {
63
68
  margin-right: 16px;
64
69
  }
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
+ }
65
88
  .pc-header__button {
66
89
  margin-top: 0;
67
90
  }
@@ -3,11 +3,12 @@ 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';
6
8
  import Navigation from '../Navigation/Navigation';
7
9
  import MobileNavigation from '../MobileNavigation/MobileNavigation';
8
- import NavigationItem from '../NavigationItem/NavigationItem';
9
10
  import Logo from '../Logo/Logo';
10
- import { NavigationClose, NavigationOpen } from '../../../icons';
11
+ import { NavigationListItem } from '../NavigationListItem/NavigationListItem';
11
12
  import './Header.css';
12
13
  const b = block('header');
13
14
  const ICON_SIZE = 36;
@@ -24,10 +25,13 @@ const MobileMenuButton = ({ isSidebarOpened, onSidebarOpenedChange, }) => {
24
25
  export const Header = ({ data, logo }) => {
25
26
  const { leftItems, rightItems } = data;
26
27
  const [isSidebarOpened, setIsSidebarOpened] = useState(false);
27
- const [activeItemIndex, setActiveItemIndex] = useState(-1);
28
- const onActiveItemChange = useCallback((index) => {
29
- setActiveItemIndex(index);
28
+ const [activeItemId, setactiveItemId] = useState(undefined);
29
+ const onActiveItemChange = useCallback((id) => {
30
+ setactiveItemId(id);
30
31
  }, []);
32
+ const hidePopup = useCallback(() => {
33
+ onActiveItemChange();
34
+ }, [onActiveItemChange]);
31
35
  const onSidebarOpenedChange = useCallback((isOpen) => {
32
36
  setIsSidebarOpened(isOpen);
33
37
  }, []);
@@ -41,11 +45,11 @@ export const Header = ({ data, logo }) => {
41
45
  logo && (React.createElement("div", { className: b('left') },
42
46
  React.createElement(Logo, Object.assign({}, logo, { className: b('logo') })))),
43
47
  React.createElement("div", { className: b('navigation-container') },
44
- React.createElement(Navigation, { className: b('navigation'), links: leftItems, activeItemIndex: activeItemIndex, onActiveItemChange: onActiveItemChange })),
48
+ React.createElement(Navigation, { className: b('navigation'), links: leftItems, activeItemId: activeItemId, onActiveItemChange: onActiveItemChange })),
45
49
  React.createElement("div", { className: b('right') },
46
50
  React.createElement(MobileMenuButton, { isSidebarOpened: isSidebarOpened, onSidebarOpenedChange: onSidebarOpenedChange }),
47
- rightItems && (React.createElement("div", { className: b('buttons') }, rightItems.map((button) => (React.createElement(NavigationItem, { key: button.text, data: button })))))),
51
+ rightItems && (React.createElement("ul", { className: b('buttons') }, rightItems.map((button, index) => (React.createElement(NavigationListItem, { key: index, className: b('buttons-item'), item: button, index: index, activeItemId: activeItemId, hidePopup: hidePopup, column: ItemColumnName.Right, onActiveItemChange: onActiveItemChange })))))),
48
52
  React.createElement(OutsideClick, { onOutsideClick: () => onSidebarOpenedChange(false) },
49
- React.createElement(MobileNavigation, { topItems: leftItems, bottomItems: rightItems, isOpened: isSidebarOpened, activeItemIndex: activeItemIndex, onActiveItemChange: onActiveItemChange, onClose: hideSidebar })))))));
53
+ React.createElement(MobileNavigation, { topItems: leftItems, bottomItems: rightItems, isOpened: isSidebarOpened, activeItemId: activeItemId, onActiveItemChange: onActiveItemChange, onClose: hideSidebar })))))));
50
54
  };
51
55
  export default Header;
@@ -24,7 +24,10 @@ unpredictable css rules order in build */
24
24
  .pc-mobile-navigation__button {
25
25
  margin-top: 24px;
26
26
  }
27
- .pc-mobile-navigation__links {
27
+ .pc-mobile-navigation__nav {
28
+ margin-bottom: 24px;
29
+ }
30
+ .pc-mobile-navigation__rows {
28
31
  position: relative;
29
32
  display: flex;
30
33
  flex-direction: column;
@@ -33,7 +36,7 @@ unpredictable css rules order in build */
33
36
  padding: 0;
34
37
  list-style: none;
35
38
  }
36
- .pc-mobile-navigation__links-item:not(:last-child) {
39
+ .pc-mobile-navigation__rows-item:not(:last-child) {
37
40
  margin-bottom: 24px;
38
41
  }
39
42
  .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
- activeItemIndex: number;
9
+ activeItemId?: string;
10
10
  onClose: () => void;
11
- onActiveItemChange: (index: number) => void;
11
+ onActiveItemChange: (id?: string) => void;
12
12
  }
13
13
  declare const MobileNavigation: React.FC<MobileNavigationProps>;
14
14
  export default MobileNavigation;
@@ -3,6 +3,7 @@ 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';
6
7
  import NavigationItem from '../NavigationItem/NavigationItem';
7
8
  import './MobileNavigation.css';
8
9
  const b = block('mobile-navigation');
@@ -12,32 +13,31 @@ const MobileNavigationDropdown = ({ data, onItemClick, onToggle, isOpened = fals
12
13
  React.createElement(NavigationItem, { data: data, onClick: onToggle, isOpened: isOpened }),
13
14
  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 })))))));
14
15
  };
15
- const MobileNavigationItem = ({ link, index, isActive, onActiveItemChange, onClose, }) => {
16
+ const MobileNavigationItem = ({ item, index, isOpened, activeItemId, onActiveItemChange, column, onClose, }) => {
17
+ const id = `${column}-${index}`;
18
+ const isActive = id === activeItemId && isOpened;
16
19
  const toggleActive = useCallback((e) => {
17
20
  e.stopPropagation();
18
21
  if (onActiveItemChange) {
19
- onActiveItemChange(isActive ? -1 : index);
22
+ onActiveItemChange(isActive ? undefined : `${column}-${index}`);
20
23
  }
21
- }, [isActive, index, onActiveItemChange]);
24
+ }, [onActiveItemChange, isActive, column, index]);
22
25
  const onItemClick = useCallback((e) => {
23
26
  toggleActive(e);
24
27
  onClose();
25
28
  }, [toggleActive, onClose]);
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 }))));
29
+ return (React.createElement("li", { key: index, className: b('rows-item') }, item.type === NavigationItemType.Dropdown ? (React.createElement(MobileNavigationDropdown, { data: item, onToggle: toggleActive, isOpened: isActive, onItemClick: onItemClick })) : (React.createElement(NavigationItem, { data: item, onClick: onItemClick }))));
27
30
  };
28
31
  const MobileNavigation = (props) => {
29
32
  if (typeof window === 'undefined') {
30
33
  return null;
31
34
  }
32
- const { isOpened, topItems, bottomItems, activeItemIndex, onActiveItemChange, onClose } = props;
35
+ const { isOpened, topItems, bottomItems, activeItemId, onActiveItemChange, onClose } = props;
33
36
  return (React.createElement(Portal, null,
34
37
  React.createElement(Foldable, { key: topItems === null || topItems === void 0 ? void 0 : topItems.length, className: b(), isOpened: Boolean(isOpened) },
35
38
  React.createElement("div", { className: b('wrapper') },
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') })))))));
39
+ React.createElement("nav", { className: b('nav') },
40
+ React.createElement("ul", { className: b('rows') }, topItems === null || topItems === void 0 ? void 0 : topItems.map((link, index) => (React.createElement(MobileNavigationItem, { key: index, item: link, column: ItemColumnName.Top, index: index, isOpened: isOpened, activeItemId: activeItemId, onClose: onClose, onActiveItemChange: onActiveItemChange }))))),
41
+ React.createElement("ul", { className: b('rows') }, bottomItems === null || bottomItems === void 0 ? void 0 : bottomItems.map((item, index) => (React.createElement(MobileNavigationItem, { key: index, item: item, column: ItemColumnName.Bottom, index: index, isOpened: isOpened, activeItemId: activeItemId, onClose: onClose, onActiveItemChange: onActiveItemChange }))))))));
42
42
  };
43
43
  export default MobileNavigation;
@@ -29,15 +29,4 @@ 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);
43
32
  }
@@ -1,19 +1,12 @@
1
- import React, { MouseEventHandler } from 'react';
2
- import { NavigationDropdownItem, NavigationItemModel } from '../../../models/navigation';
1
+ import React from 'react';
2
+ import { NavigationItemModel } from '../../../models/navigation';
3
3
  import './Navigation.css';
4
4
  export interface NavigationProps {
5
5
  links: NavigationItemModel[];
6
- activeItemIndex: number;
7
- onActiveItemChange: (index: number) => void;
6
+ activeItemId?: string;
8
7
  className?: string;
9
8
  highlightActiveItem?: boolean;
10
- }
11
- export interface NavigationDropdownProps {
12
- data: NavigationDropdownItem;
13
- onClick: MouseEventHandler;
14
- isActive: boolean;
15
- position: number;
16
- hidePopup: () => void;
9
+ onActiveItemChange: (id?: string) => void;
17
10
  }
18
11
  declare const Navigation: React.FC<NavigationProps>;
19
12
  export default Navigation;
@@ -1,32 +1,20 @@
1
- import { __rest } from "tslib";
2
1
  import _ from 'lodash';
3
- import React, { Fragment, useState, useEffect, useCallback, useContext, useRef, } from 'react';
2
+ import React, { useState, useEffect, useCallback, useContext, useRef } from 'react';
4
3
  import { block } from '../../../utils';
5
4
  import OverflowScroller from '../../../components/OverflowScroller/OverflowScroller';
6
- import { NavigationItemType, } from '../../../models/navigation';
7
- import NavigationPopup from '../NavigationPopup/NavigationPopup';
8
- import NavigationItem from '../NavigationItem/NavigationItem';
9
5
  import { LocationContext } from '../../../context/locationContext';
6
+ import { ItemColumnName } from '../../constants';
7
+ import { NavigationListItem } from '../NavigationListItem/NavigationListItem';
10
8
  import './Navigation.css';
11
9
  const b = block('navigation');
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, }) => {
10
+ const Navigation = ({ className, onActiveItemChange, links, activeItemId, highlightActiveItem, }) => {
19
11
  const { asPath, pathname } = useContext(LocationContext);
20
12
  const itemRefs = useRef([]);
21
13
  const [itemPositions, setItemPosition] = useState([]);
22
14
  const [lastLeftScroll, setLastLeftScroll] = useState(0);
23
15
  const hidePopup = useCallback(() => {
24
- onActiveItemChange(-1);
16
+ onActiveItemChange();
25
17
  }, [onActiveItemChange]);
26
- const getItemClickHandler = useCallback((index) => (e) => {
27
- e.stopPropagation();
28
- onActiveItemChange(index === activeItemIndex ? -1 : index);
29
- }, [activeItemIndex, onActiveItemChange]);
30
18
  const calculateItemPositions = useCallback(() => {
31
19
  if (itemRefs.current.length) {
32
20
  const currentItemPositions = itemRefs.current.map((itemRef) => (itemRef && itemRef.getBoundingClientRect().left) || 0);
@@ -56,13 +44,6 @@ const Navigation = ({ className, onActiveItemChange, links, activeItemIndex, hig
56
44
  }, [hidePopup, asPath, pathname]);
57
45
  return (React.createElement(OverflowScroller, { className: b(null, className), onScrollStart: hidePopup, onScrollEnd: calculateItemPositions },
58
46
  React.createElement("nav", null,
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
- })))));
47
+ React.createElement("ul", { className: b('links') }, links.map((link, index) => (React.createElement(NavigationListItem, { key: index, className: b('links-item'), item: link, itemRefs: itemRefs, index: index, activeItemId: activeItemId, highlightActiveItem: highlightActiveItem, hidePopup: hidePopup, itemPositions: itemPositions, column: ItemColumnName.Left, onActiveItemChange: onActiveItemChange })))))));
67
48
  };
68
49
  export default Navigation;
@@ -0,0 +1,11 @@
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;
@@ -0,0 +1,12 @@
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;
@@ -0,0 +1,11 @@
1
+ .pc-navigation-list-item__slider-container {
2
+ position: absolute;
3
+ right: 0;
4
+ bottom: 0;
5
+ left: 0;
6
+ }
7
+ .pc-navigation-list-item__slider {
8
+ width: 100%;
9
+ height: 2px;
10
+ background-color: var(--yc-color-text-link);
11
+ }
@@ -0,0 +1,17 @@
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
+ column: ItemColumnName;
9
+ activeItemId?: string;
10
+ itemPositions?: number[];
11
+ itemRefs?: React.MutableRefObject<(HTMLLIElement | null)[]>;
12
+ highlightActiveItem?: boolean;
13
+ hidePopup: () => void;
14
+ onActiveItemChange: (id?: string) => void;
15
+ } & ClassNameProps;
16
+ export declare const NavigationListItem: ({ item, itemRefs, className, index, activeItemId, highlightActiveItem, hidePopup, itemPositions, column, onActiveItemChange, }: NavigationListItemProps) => JSX.Element;
17
+ export {};
@@ -0,0 +1,24 @@
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
+ };
@@ -0,0 +1,6 @@
1
+ export declare enum ItemColumnName {
2
+ Left = "left",
3
+ Right = "right",
4
+ Top = "top",
5
+ Bottom = "bottom"
6
+ }
@@ -0,0 +1,7 @@
1
+ export var ItemColumnName;
2
+ (function (ItemColumnName) {
3
+ ItemColumnName["Left"] = "left";
4
+ ItemColumnName["Right"] = "right";
5
+ ItemColumnName["Top"] = "top";
6
+ ItemColumnName["Bottom"] = "bottom";
7
+ })(ItemColumnName || (ItemColumnName = {}));
@@ -0,0 +1,10 @@
1
+ import { MouseEventHandler } from 'react';
2
+ import { ItemColumnName } from './constants';
3
+ type GetItemClickHandlerArgs = {
4
+ column: ItemColumnName;
5
+ index: number;
6
+ activeItemId?: string;
7
+ onActiveItemChange: (id?: string) => void;
8
+ };
9
+ export declare const getItemClickHandler: ({ column, index, onActiveItemChange, }: GetItemClickHandlerArgs) => MouseEventHandler;
10
+ export {};
@@ -0,0 +1,7 @@
1
+ export const getItemClickHandler = ({ column, index, onActiveItemChange, activeItemId }) => (e) => {
2
+ const id = `${column}-${index}`;
3
+ if (e) {
4
+ e.stopPropagation();
5
+ }
6
+ onActiveItemChange(id === activeItemId ? undefined : `${column}-${index}`);
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "2.0.0-beta.0",
3
+ "version": "2.0.0-beta.1",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -50,7 +50,7 @@
50
50
  "bem-cn-lite": "^4.0.0",
51
51
  "github-buttons": "2.23.0",
52
52
  "lodash": "^4.17.21",
53
- "react-player": "^2.9.0",
53
+ "react-player": "^2.12.0",
54
54
  "react-slick": "^0.28.1",
55
55
  "react-spring": "^9.3.0",
56
56
  "react-transition-group": "^4.4.2",
@@ -137,8 +137,5 @@
137
137
  "*.{json,yaml,yml,md}": [
138
138
  "prettier --write"
139
139
  ]
140
- },
141
- "publishConfig": {
142
- "tag": "beta"
143
140
  }
144
141
  }