@gravity-ui/page-constructor 1.7.0-alpha.1 → 1.7.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +58 -36
  2. package/build/cjs/components/OverflowScroller/OverflowScroller.css +2 -0
  3. package/build/cjs/components/RouterLink/RouterLink.d.ts +1 -1
  4. package/build/cjs/components/index.d.ts +1 -0
  5. package/build/cjs/components/index.js +39 -40
  6. package/build/cjs/components/navigation/components/Header/Header.css +19 -19
  7. package/build/cjs/components/navigation/components/Header/Header.d.ts +2 -22
  8. package/build/cjs/components/navigation/components/Header/Header.js +40 -70
  9. package/build/cjs/components/navigation/components/Logo/Logo.css +13 -8
  10. package/build/cjs/components/navigation/components/Logo/Logo.d.ts +1 -1
  11. package/build/cjs/components/navigation/components/Logo/Logo.js +11 -7
  12. package/build/cjs/components/navigation/components/MobileNavigation/MobileNavigation.css +17 -11
  13. package/build/cjs/components/navigation/components/MobileNavigation/MobileNavigation.js +3 -3
  14. package/build/cjs/components/navigation/components/Navigation/Navigation.css +8 -8
  15. package/build/cjs/components/navigation/components/Navigation/Navigation.d.ts +9 -2
  16. package/build/cjs/components/navigation/components/Navigation/Navigation.js +18 -19
  17. package/build/cjs/components/navigation/components/NavigationItem/NavigationItem.css +9 -9
  18. package/build/cjs/components/navigation/components/NavigationItem/NavigationItem.d.ts +1 -3
  19. package/build/cjs/components/navigation/components/NavigationItem/NavigationItem.js +27 -15
  20. package/build/cjs/components/navigation/components/NavigationPopup/NavigationPopup.css +4 -4
  21. package/build/cjs/components/navigation/components/NavigationPopup/NavigationPopup.d.ts +4 -18
  22. package/build/cjs/components/navigation/components/NavigationPopup/NavigationPopup.js +34 -46
  23. package/build/cjs/components/navigation/components/SocialIcon/SocialIcon.css +3 -3
  24. package/build/cjs/components/navigation/components/SocialIcon/SocialIcon.d.ts +1 -1
  25. package/build/cjs/components/navigation/components/SocialIcon/SocialIcon.js +8 -4
  26. package/build/cjs/components/navigation/components/index.d.ts +7 -0
  27. package/build/cjs/components/navigation/components/index.js +20 -0
  28. package/build/cjs/components/navigation/containers/Layout/Layout.css +10 -0
  29. package/build/cjs/components/navigation/containers/Layout/Layout.d.ts +8 -0
  30. package/build/cjs/components/navigation/containers/Layout/Layout.js +11 -0
  31. package/build/cjs/containers/PageConstructor/PageConstructor.d.ts +3 -4
  32. package/build/cjs/containers/PageConstructor/PageConstructor.js +11 -11
  33. package/build/cjs/models/index.d.ts +1 -0
  34. package/build/cjs/models/index.js +1 -0
  35. package/build/cjs/models/navigation.d.ts +8 -5
  36. package/build/esm/components/OverflowScroller/OverflowScroller.css +2 -0
  37. package/build/esm/components/RouterLink/RouterLink.d.ts +1 -1
  38. package/build/esm/components/index.d.ts +1 -0
  39. package/build/esm/components/index.js +1 -0
  40. package/build/esm/components/navigation/components/Header/Header.css +19 -19
  41. package/build/esm/components/navigation/components/Header/Header.d.ts +2 -22
  42. package/build/esm/components/navigation/components/Header/Header.js +37 -69
  43. package/build/esm/components/navigation/components/Logo/Logo.css +13 -8
  44. package/build/esm/components/navigation/components/Logo/Logo.d.ts +1 -1
  45. package/build/esm/components/navigation/components/Logo/Logo.js +10 -6
  46. package/build/esm/components/navigation/components/MobileNavigation/MobileNavigation.css +17 -11
  47. package/build/esm/components/navigation/components/MobileNavigation/MobileNavigation.js +2 -2
  48. package/build/esm/components/navigation/components/Navigation/Navigation.css +8 -8
  49. package/build/esm/components/navigation/components/Navigation/Navigation.d.ts +9 -2
  50. package/build/esm/components/navigation/components/Navigation/Navigation.js +17 -18
  51. package/build/esm/components/navigation/components/NavigationItem/NavigationItem.css +9 -9
  52. package/build/esm/components/navigation/components/NavigationItem/NavigationItem.d.ts +1 -3
  53. package/build/esm/components/navigation/components/NavigationItem/NavigationItem.js +23 -11
  54. package/build/esm/components/navigation/components/NavigationPopup/NavigationPopup.css +4 -4
  55. package/build/esm/components/navigation/components/NavigationPopup/NavigationPopup.d.ts +4 -18
  56. package/build/esm/components/navigation/components/NavigationPopup/NavigationPopup.js +32 -45
  57. package/build/esm/components/navigation/components/SocialIcon/SocialIcon.css +3 -3
  58. package/build/esm/components/navigation/components/SocialIcon/SocialIcon.d.ts +1 -1
  59. package/build/esm/components/navigation/components/SocialIcon/SocialIcon.js +7 -3
  60. package/build/esm/components/navigation/components/index.d.ts +7 -0
  61. package/build/esm/components/navigation/components/index.js +7 -0
  62. package/build/esm/components/navigation/containers/Layout/Layout.css +10 -0
  63. package/build/esm/components/navigation/containers/Layout/Layout.d.ts +9 -0
  64. package/build/esm/components/navigation/containers/Layout/Layout.js +9 -0
  65. package/build/esm/containers/PageConstructor/PageConstructor.d.ts +3 -4
  66. package/build/esm/containers/PageConstructor/PageConstructor.js +11 -11
  67. package/build/esm/models/index.d.ts +1 -0
  68. package/build/esm/models/index.js +1 -0
  69. package/build/esm/models/navigation.d.ts +8 -5
  70. package/package.json +1 -4
  71. package/server/models/index.d.ts +1 -0
  72. package/server/models/index.js +1 -0
  73. package/server/models/navigation.d.ts +62 -0
  74. package/server/models/navigation.js +10 -0
@@ -1,6 +1,6 @@
1
1
  /* use this for style redefinitions to awoid problems with
2
2
  unpredictable css rules order in build */
3
- .mobile-navigation {
3
+ .pc-mobile-navigation {
4
4
  position: fixed;
5
5
  z-index: 100;
6
6
  top: var(--header-height);
@@ -9,22 +9,22 @@ unpredictable css rules order in build */
9
9
  border-bottom-right-radius: var(--pc-border-radius);
10
10
  border-bottom-left-radius: var(--pc-border-radius);
11
11
  background-color: var(--yc-color-base-background);
12
- box-shadow: 0px 3px 10px var(--yc-color-sfx-shadow);
12
+ box-shadow: 0 3px 10px var(--yc-color-sfx-shadow);
13
13
  font-size: var(--yc-text-body-2-font-size);
14
14
  line-height: var(--yc-text-body-2-line-height);
15
15
  }
16
16
  @media (min-width: 769px) {
17
- .mobile-navigation {
17
+ .pc-mobile-navigation {
18
18
  display: none;
19
19
  }
20
20
  }
21
- .mobile-navigation__wrapper {
22
- padding: 32px 20px;
21
+ .pc-mobile-navigation__wrapper {
22
+ padding: 32px 48px;
23
23
  }
24
- .mobile-navigation__button {
24
+ .pc-mobile-navigation__button {
25
25
  margin-top: 24px;
26
26
  }
27
- .mobile-navigation__links {
27
+ .pc-mobile-navigation__links {
28
28
  position: relative;
29
29
  display: flex;
30
30
  flex-direction: column;
@@ -33,13 +33,13 @@ unpredictable css rules order in build */
33
33
  padding: 0;
34
34
  list-style: none;
35
35
  }
36
- .mobile-navigation__links-item:not(:last-child) {
36
+ .pc-mobile-navigation__links-item:not(:last-child) {
37
37
  margin-bottom: 24px;
38
38
  }
39
- .mobile-navigation__dropdown-item:not(:last-child) {
39
+ .pc-mobile-navigation__dropdown-item:not(:last-child) {
40
40
  margin-bottom: 16px;
41
41
  }
42
- .mobile-navigation__popup {
42
+ .pc-mobile-navigation__popup {
43
43
  z-index: 101;
44
44
  display: flex;
45
45
  flex-direction: column;
@@ -52,7 +52,13 @@ unpredictable css rules order in build */
52
52
  box-shadow: 0 3px 10px var(--yc-color-sfx-shadow);
53
53
  }
54
54
  @media (min-width: 769px) {
55
- .mobile-navigation__popup {
55
+ .pc-mobile-navigation__popup {
56
56
  display: none;
57
57
  }
58
+ }
59
+ @media (max-width: 576px) {
60
+ .pc-mobile-navigation__wrapper {
61
+ padding-left: 24px;
62
+ padding-right: 24px;
63
+ }
58
64
  }
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const bem_cn_lite_1 = (0, tslib_1.__importDefault)(require("bem-cn-lite"));
5
4
  const react_1 = (0, tslib_1.__importStar)(require("react"));
6
- const Foldable_1 = (0, tslib_1.__importDefault)(require("../../../Foldable/Foldable"));
7
5
  const uikit_1 = require("@gravity-ui/uikit");
6
+ const utils_1 = require("../../../../utils");
7
+ const Foldable_1 = (0, tslib_1.__importDefault)(require("../../../Foldable/Foldable"));
8
8
  const navigation_1 = require("../../../../models/navigation");
9
9
  const NavigationItem_1 = (0, tslib_1.__importDefault)(require("../NavigationItem/NavigationItem"));
10
- const b = (0, bem_cn_lite_1.default)('mobile-navigation');
10
+ const b = (0, utils_1.block)('mobile-navigation');
11
11
  const MobileNavigationDropdown = ({ data, onItemClick, onToggle, isOpened = false, }) => {
12
12
  const ref = (0, react_1.useRef)(null);
13
13
  return (react_1.default.createElement("div", { ref: ref, className: b('dropdown') },
@@ -1,10 +1,10 @@
1
1
  /* use this for style redefinitions to awoid problems with
2
2
  unpredictable css rules order in build */
3
- .navigation {
3
+ .pc-navigation {
4
4
  font-size: var(--yc-text-body-2-font-size);
5
5
  line-height: var(--yc-text-body-2-line-height);
6
6
  }
7
- .navigation__links {
7
+ .pc-navigation__links {
8
8
  position: relative;
9
9
  display: flex;
10
10
  align-items: center;
@@ -12,7 +12,7 @@ unpredictable css rules order in build */
12
12
  padding: 0;
13
13
  list-style: none;
14
14
  }
15
- .navigation__links-item {
15
+ .pc-navigation__links-item {
16
16
  position: relative;
17
17
  height: var(--header-height);
18
18
  line-height: var(--header-height);
@@ -21,22 +21,22 @@ unpredictable css rules order in build */
21
21
  color: inherit;
22
22
  text-decoration: none;
23
23
  }
24
- .utilityfocus .navigation__links-item:focus {
24
+ .utilityfocus .pc-navigation__links-item:focus {
25
25
  outline: 2px solid #ffdb4d;
26
26
  }
27
- .navigation__links-item:hover, .navigation__links-item:active {
27
+ .pc-navigation__links-item:hover, .pc-navigation__links-item:active {
28
28
  color: var(--yc-color-text-link);
29
29
  }
30
- .navigation__links-item:not(:last-child) {
30
+ .pc-navigation__links-item:not(:last-child) {
31
31
  margin-right: 20px;
32
32
  }
33
- .navigation__slider-container {
33
+ .pc-navigation__slider-container {
34
34
  position: absolute;
35
35
  right: 0;
36
36
  bottom: 0;
37
37
  left: 0;
38
38
  }
39
- .navigation__slider {
39
+ .pc-navigation__slider {
40
40
  width: 100%;
41
41
  height: 2px;
42
42
  background-color: var(--yc-color-text-link);
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- import { NavigationItem as NavigationItemModel } from '../../../../models/navigation';
1
+ import React, { MouseEventHandler } from 'react';
2
+ import { NavigationDropdownItem, NavigationItem as NavigationItemModel } from '../../../../models/navigation';
3
3
  export interface NavigationProps {
4
4
  links: NavigationItemModel[];
5
5
  activeItemIndex: number;
@@ -7,5 +7,12 @@ export interface NavigationProps {
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;
@@ -2,14 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
5
- const bem_cn_lite_1 = (0, tslib_1.__importDefault)(require("bem-cn-lite"));
6
5
  const react_1 = (0, tslib_1.__importStar)(require("react"));
6
+ const utils_1 = require("../../../../utils");
7
7
  const OverflowScroller_1 = (0, tslib_1.__importDefault)(require("../../../OverflowScroller/OverflowScroller"));
8
8
  const navigation_1 = require("../../../../models/navigation");
9
9
  const NavigationPopup_1 = (0, tslib_1.__importDefault)(require("../NavigationPopup/NavigationPopup"));
10
10
  const NavigationItem_1 = (0, tslib_1.__importDefault)(require("../NavigationItem/NavigationItem"));
11
11
  const locationContext_1 = require("../../../../context/locationContext");
12
- const b = (0, bem_cn_lite_1.default)('navigation');
12
+ const b = (0, utils_1.block)('navigation');
13
+ const NavigationDropdown = ({ data, isActive, position, hidePopup, onClick, }) => {
14
+ const { text, items } = data, popupProps = (0, 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
+ };
13
19
  const Navigation = ({ className, onActiveItemChange, links, activeItemIndex, highlightActiveItem, }) => {
14
20
  const { asPath, pathname } = (0, react_1.useContext)(locationContext_1.LocationContext);
15
21
  const itemRefs = (0, react_1.useRef)([]);
@@ -22,22 +28,6 @@ const Navigation = ({ className, onActiveItemChange, links, activeItemIndex, hig
22
28
  e.stopPropagation();
23
29
  onActiveItemChange(index === activeItemIndex ? -1 : index);
24
30
  }, [activeItemIndex, onActiveItemChange]);
25
- const renderNavDropdown = (data, onClick, isActive, position) => {
26
- const { text, items } = data, popupProps = (0, tslib_1.__rest)(data, ["text", "items"]);
27
- return (react_1.default.createElement(react_1.Fragment, null,
28
- react_1.default.createElement(NavigationItem_1.default, { className: b('link'), onClick: onClick, isOpened: isActive, data: { text, type: navigation_1.NavigationItemType.Dropdown } }),
29
- isActive && (react_1.default.createElement(NavigationPopup_1.default, Object.assign({ left: position, onClose: hidePopup, items: items }, popupProps)))));
30
- };
31
- const slider = (react_1.default.createElement("div", { className: b('slider-container') },
32
- react_1.default.createElement("div", { className: b('slider') })));
33
- const content = (react_1.default.createElement("nav", null,
34
- react_1.default.createElement("ul", { className: b('links') }, links.map((link, index) => {
35
- const isActive = index === activeItemIndex;
36
- const onClick = getItemClickHandler(index);
37
- return (react_1.default.createElement("li", { ref: (el) => itemRefs.current.push(el), key: index, className: b('links-item') },
38
- link.type === navigation_1.NavigationItemType.Dropdown ? (renderNavDropdown(link, onClick, isActive, itemPositions[index])) : (react_1.default.createElement(NavigationItem_1.default, { data: link, onClick: onClick })),
39
- highlightActiveItem && isActive && slider));
40
- }))));
41
31
  const calculateItemPositions = (0, react_1.useCallback)(() => {
42
32
  if (itemRefs.current.length) {
43
33
  const currentItemPositions = itemRefs.current.map((itemRef) => (itemRef && itemRef.getBoundingClientRect().left) || 0);
@@ -65,6 +55,15 @@ const Navigation = ({ className, onActiveItemChange, links, activeItemIndex, hig
65
55
  (0, react_1.useEffect)(() => {
66
56
  hidePopup();
67
57
  }, [hidePopup, asPath, pathname]);
68
- return (react_1.default.createElement(OverflowScroller_1.default, { className: b(null, className), onScrollStart: hidePopup, onScrollEnd: calculateItemPositions }, content));
58
+ return (react_1.default.createElement(OverflowScroller_1.default, { className: b(null, className), onScrollStart: hidePopup, onScrollEnd: calculateItemPositions },
59
+ 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
+ })))));
69
68
  };
70
69
  exports.default = Navigation;
@@ -1,40 +1,40 @@
1
1
  /* use this for style redefinitions to awoid problems with
2
2
  unpredictable css rules order in build */
3
- .navigation-item {
3
+ .pc-navigation-item {
4
4
  position: relative;
5
5
  display: flex;
6
6
  align-items: center;
7
7
  }
8
- .navigation-item_type_link {
8
+ .pc-navigation-item_type_link {
9
9
  color: var(--yc-color-text-primary);
10
10
  color: inherit;
11
11
  text-decoration: none;
12
12
  outline: none;
13
13
  }
14
- .utilityfocus .navigation-item_type_link:focus {
14
+ .utilityfocus .pc-navigation-item_type_link:focus {
15
15
  outline: 2px solid #ffdb4d;
16
16
  }
17
- .navigation-item_type_link:hover, .navigation-item_type_link_active {
17
+ .pc-navigation-item_type_link:hover, .pc-navigation-item_type_link_active {
18
18
  color: var(--yc-color-text-link);
19
19
  }
20
- .navigation-item_type_button {
20
+ .pc-navigation-item_type_button {
21
21
  display: inline-block;
22
22
  }
23
- .navigation-item__arrow {
23
+ .pc-navigation-item__arrow {
24
24
  position: relative;
25
25
  top: -2px;
26
26
  width: 9px;
27
27
  height: 9px;
28
28
  margin-left: 5px;
29
29
  }
30
- .navigation-item__icon {
30
+ .pc-navigation-item__icon {
31
+ display: flex;
31
32
  width: 20px;
32
33
  height: 20px;
33
34
  margin-right: 8px;
34
- border-radius: 50%;
35
35
  object-fit: cover;
36
36
  }
37
- .navigation-item__dropdown {
37
+ .pc-navigation-item__dropdown {
38
38
  margin-left: 7px;
39
39
  color: var(--yc-color-text-secondary);
40
40
  }
@@ -1,7 +1,5 @@
1
1
  import React, { MouseEventHandler } from 'react';
2
- import { NavigationButtonItem, NavigationDropdownItem, NavigationSocialItem, NavigationLinkItem } from '../../../../models/navigation';
3
- declare type DropdownItemData = Omit<NavigationDropdownItem, 'items'>;
4
- export declare type NavigationItemData = NavigationLinkItem | NavigationButtonItem | NavigationSocialItem | DropdownItemData;
2
+ import { NavigationItemData } from '../../../../models';
5
3
  export interface NavigationItemProps {
6
4
  data: NavigationItemData;
7
5
  className?: string;
@@ -2,44 +2,56 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const react_1 = (0, tslib_1.__importStar)(require("react"));
5
- const bem_cn_lite_1 = (0, tslib_1.__importDefault)(require("bem-cn-lite"));
6
- const index_1 = require("../../../index");
7
5
  const utils_1 = require("../../../../utils");
6
+ const index_1 = require("../../../index");
8
7
  const locationContext_1 = require("../../../../context/locationContext");
9
- const navigation_1 = require("../../../../models/navigation");
8
+ const models_1 = require("../../../../models");
10
9
  const icons_1 = require("../../../../icons");
11
10
  const SocialIcon_1 = (0, tslib_1.__importDefault)(require("../SocialIcon/SocialIcon"));
12
- const b = (0, bem_cn_lite_1.default)('navigation-item');
11
+ const utils_2 = require("../../../Media/Image/utils");
12
+ const b = (0, utils_1.block)('navigation-item');
13
13
  const Content = ({ text, icon }) => (react_1.default.createElement(react_1.Fragment, null,
14
- icon && react_1.default.createElement("img", { className: b('icon'), src: icon }),
14
+ icon && react_1.default.createElement(index_1.Image, Object.assign({ className: b('icon') }, icon)),
15
15
  react_1.default.createElement("span", { className: b('text') }, text)));
16
16
  const NavigationDropdown = (_a) => {
17
17
  var { text, icon, isOpened } = _a, props = (0, tslib_1.__rest)(_a, ["text", "icon", "isOpened"]);
18
+ const iconData = icon && (0, utils_2.getMediaImage)(icon);
18
19
  return (react_1.default.createElement("span", Object.assign({}, props),
19
- react_1.default.createElement(Content, { text: text, icon: icon }),
20
+ react_1.default.createElement(Content, { text: text, icon: iconData }),
20
21
  react_1.default.createElement(index_1.ToggleArrow, { className: b('dropdown'), size: 12, type: 'vertical', iconType: "navigation", open: isOpened })));
21
22
  };
22
23
  const NavigationLink = (props) => {
23
- const { hostname } = (0, react_1.useContext)(locationContext_1.LocationContext);
24
+ const { hostname, Link } = (0, react_1.useContext)(locationContext_1.LocationContext);
24
25
  const { url, text, icon, arrow, target } = props, rest = (0, tslib_1.__rest)(props, ["url", "text", "icon", "arrow", "target"]);
25
26
  const linkExtraProps = (0, utils_1.getLinkProps)(url, hostname, target);
27
+ const iconData = icon && (0, utils_2.getMediaImage)(icon);
26
28
  const content = (react_1.default.createElement(react_1.Fragment, null,
27
- react_1.default.createElement(Content, { text: text, icon: icon }),
29
+ react_1.default.createElement(Content, { text: text, icon: iconData }),
28
30
  arrow && react_1.default.createElement(icons_1.NavigationArrow, { className: b('arrow') })));
29
- return (linkExtraProps === null || linkExtraProps === void 0 ? void 0 : linkExtraProps.target) ? (react_1.default.createElement("a", Object.assign({ href: url, title: text }, rest, linkExtraProps), content)) : (react_1.default.createElement(index_1.RouterLink, { href: url, passHref: true },
30
- react_1.default.createElement("a", Object.assign({}, rest), content)));
31
+ if ((linkExtraProps === null || linkExtraProps === void 0 ? void 0 : linkExtraProps.target) || !Link) {
32
+ return (react_1.default.createElement("a", Object.assign({ href: url, title: text }, rest, linkExtraProps), content));
33
+ }
34
+ else {
35
+ return (react_1.default.createElement(index_1.RouterLink, { href: url, passHref: true },
36
+ react_1.default.createElement("a", Object.assign({}, rest), content)));
37
+ }
38
+ };
39
+ const NavigationButton = (props) => {
40
+ const { url, target } = props;
41
+ return target ? (react_1.default.createElement(index_1.Button, Object.assign({}, props, { url: url }))) : (react_1.default.createElement(index_1.RouterLink, { href: url },
42
+ react_1.default.createElement(index_1.Button, Object.assign({}, props, { url: url }))));
31
43
  };
32
44
  //todo: add types support form component in map
33
45
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
46
  const NavigationItemsMap = {
35
- [navigation_1.NavigationItemType.Button]: index_1.RouterLink,
36
- [navigation_1.NavigationItemType.Social]: SocialIcon_1.default,
37
- [navigation_1.NavigationItemType.Dropdown]: NavigationDropdown,
38
- [navigation_1.NavigationItemType.Link]: NavigationLink,
47
+ [models_1.NavigationItemType.Button]: NavigationButton,
48
+ [models_1.NavigationItemType.Social]: SocialIcon_1.default,
49
+ [models_1.NavigationItemType.Dropdown]: NavigationDropdown,
50
+ [models_1.NavigationItemType.Link]: NavigationLink,
39
51
  };
40
52
  const NavigationItem = (_a) => {
41
53
  var { data, className } = _a, props = (0, tslib_1.__rest)(_a, ["data", "className"]);
42
- const { type = navigation_1.NavigationItemType.Link } = data;
54
+ const { type = models_1.NavigationItemType.Link } = data;
43
55
  const Component = NavigationItemsMap[type];
44
56
  const componentProps = (0, react_1.useMemo)(() => (Object.assign(Object.assign({ className: b({ type }, className) }, data), props)), [className, data, props, type]);
45
57
  return react_1.default.createElement(Component, Object.assign({}, componentProps));
@@ -1,6 +1,6 @@
1
1
  /* use this for style redefinitions to awoid problems with
2
2
  unpredictable css rules order in build */
3
- .navigation-popup {
3
+ .pc-navigation-popup {
4
4
  position: fixed;
5
5
  top: calc(var(--header-height) - 16px);
6
6
  padding-right: 4px;
@@ -18,16 +18,16 @@ unpredictable css rules order in build */
18
18
  box-shadow: 0 3px 10px var(--yc-color-sfx-shadow);
19
19
  }
20
20
  @media (max-width: 768px) {
21
- .navigation-popup {
21
+ .pc-navigation-popup {
22
22
  display: none;
23
23
  }
24
24
  }
25
- .navigation-popup__link {
25
+ .pc-navigation-popup__link {
26
26
  height: 36px;
27
27
  padding: 8px 12px;
28
28
  border-radius: 8px;
29
29
  }
30
- .navigation-popup__link:hover {
30
+ .pc-navigation-popup__link:hover {
31
31
  color: var(--yc-color-text-primary);
32
32
  background-color: var(--yc-color-base-simple-hover);
33
33
  }
@@ -1,24 +1,10 @@
1
- import React, { RefObject } from 'react';
2
- import { NavigationLinkItem } from '../../../../models/navigation';
1
+ import React from 'react';
2
+ import { NavigationLinkItem } from '../../../../models';
3
3
  export interface NavigationPopupProps {
4
4
  items: NavigationLinkItem[];
5
5
  onClose: () => void;
6
6
  left?: number;
7
7
  className?: string;
8
8
  }
9
- interface NavigationPopupState {
10
- calculatedLeft?: number;
11
- }
12
- export default class NavigationPopup extends React.Component<NavigationPopupProps, NavigationPopupState> {
13
- ref: RefObject<HTMLDivElement>;
14
- state: {
15
- calculatedLeft: number | undefined;
16
- };
17
- private calculateLeft;
18
- componentDidMount(): void;
19
- componentDidUpdate(prevProps: NavigationPopupProps): void;
20
- componentWillUnmount(): void;
21
- render(): JSX.Element | null;
22
- private renderDefaultPopup;
23
- }
24
- export {};
9
+ export declare const NavigationPopup: React.FC<NavigationPopupProps>;
10
+ export default NavigationPopup;
@@ -1,57 +1,45 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NavigationPopup = void 0;
3
4
  const tslib_1 = require("tslib");
4
5
  const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
5
- const bem_cn_lite_1 = (0, tslib_1.__importDefault)(require("bem-cn-lite"));
6
6
  const react_1 = (0, tslib_1.__importStar)(require("react"));
7
7
  const uikit_1 = require("@gravity-ui/uikit");
8
+ const utils_1 = require("../../../../utils");
8
9
  const index_1 = require("../../../index");
9
10
  const NavigationItem_1 = (0, tslib_1.__importDefault)(require("../NavigationItem/NavigationItem"));
10
- const b = (0, bem_cn_lite_1.default)('navigation-popup');
11
- class NavigationPopup extends react_1.default.Component {
12
- constructor() {
13
- super(...arguments);
14
- this.ref = (0, react_1.createRef)();
15
- this.state = {
16
- calculatedLeft: this.props.left,
17
- };
18
- this.calculateLeft = lodash_1.default.debounce(() => {
19
- const { left } = this.props;
20
- if (this.ref && this.ref.current && left) {
21
- const right = left + this.ref.current.offsetWidth;
22
- const docWidth = document.body.clientWidth;
23
- const calculatedLeft = right > docWidth ? left - (right - docWidth) : left;
24
- this.setState({ calculatedLeft });
25
- }
26
- else {
27
- this.setState({ calculatedLeft: left });
28
- }
29
- }, 100);
30
- }
31
- componentDidMount() {
32
- this.calculateLeft();
33
- window.addEventListener('resize', this.calculateLeft);
34
- }
35
- componentDidUpdate(prevProps) {
36
- if (prevProps.left !== this.props.left) {
37
- this.calculateLeft();
11
+ const b = (0, utils_1.block)('navigation-popup');
12
+ const NavigationPopup = ({ items, left, onClose }) => {
13
+ const [calculatedLeft, setCalculatedLeft] = (0, react_1.useState)(left);
14
+ const popupRef = (0, react_1.useRef)(null);
15
+ const calculateLeft = (0, react_1.useCallback)(() => {
16
+ if (popupRef && popupRef.current && left) {
17
+ const right = left + popupRef.current.offsetWidth;
18
+ const docWidth = document.body.clientWidth;
19
+ const currentLeft = right > docWidth ? left - (right - docWidth) : left;
20
+ setCalculatedLeft(currentLeft);
38
21
  }
39
- }
40
- componentWillUnmount() {
41
- window.removeEventListener('resize', this.calculateLeft);
42
- }
43
- render() {
44
- if (!document || !document.body) {
45
- return null;
22
+ else {
23
+ setCalculatedLeft(left);
46
24
  }
47
- const { onClose } = this.props;
48
- const { calculatedLeft } = this.state;
49
- return (react_1.default.createElement(uikit_1.Portal, null,
50
- react_1.default.createElement("div", { ref: this.ref, className: b(), style: { left: calculatedLeft } },
51
- react_1.default.createElement(index_1.OutsideClick, { onOutsideClick: onClose }, this.renderDefaultPopup()))));
52
- }
53
- renderDefaultPopup() {
54
- return (react_1.default.createElement(react_1.Fragment, null, this.props.items.map((item) => (react_1.default.createElement(NavigationItem_1.default, { key: item.text, className: b('link'), data: item })))));
25
+ }, [left]);
26
+ (0, react_1.useEffect)(() => {
27
+ const debounceCalculateLeft = lodash_1.default.debounce(calculateLeft, 100);
28
+ calculateLeft();
29
+ window.addEventListener('resize', debounceCalculateLeft);
30
+ return () => {
31
+ window.removeEventListener('resize', debounceCalculateLeft);
32
+ };
33
+ }, [calculateLeft]);
34
+ (0, react_1.useEffect)(() => {
35
+ calculateLeft();
36
+ }, [calculateLeft, left]);
37
+ if (!document || !document.body) {
38
+ return null;
55
39
  }
56
- }
57
- exports.default = NavigationPopup;
40
+ return (react_1.default.createElement(uikit_1.Portal, null,
41
+ react_1.default.createElement("div", { ref: popupRef, className: b(), style: { left: calculatedLeft } },
42
+ react_1.default.createElement(index_1.OutsideClick, { onOutsideClick: onClose }, items.map((item) => (react_1.default.createElement(NavigationItem_1.default, { key: item.text, className: b('link'), data: item })))))));
43
+ };
44
+ exports.NavigationPopup = NavigationPopup;
45
+ exports.default = exports.NavigationPopup;
@@ -1,6 +1,6 @@
1
1
  /* use this for style redefinitions to awoid problems with
2
2
  unpredictable css rules order in build */
3
- .social-icon {
3
+ .pc-social-icon {
4
4
  display: flex;
5
5
  justify-content: center;
6
6
  align-items: center;
@@ -11,10 +11,10 @@ unpredictable css rules order in build */
11
11
  border-radius: 50%;
12
12
  background-color: var(--yc-color-base-generic);
13
13
  }
14
- .social-icon:hover {
14
+ .pc-social-icon:hover {
15
15
  background-color: var(--yc-color-base-generic-hover);
16
16
  }
17
- .social-icon__icon {
17
+ .pc-social-icon__icon {
18
18
  width: 16px;
19
19
  height: 16px;
20
20
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { NavigationSocialItem } from '../../../../models/navigation';
2
+ import { NavigationSocialItem } from '../../../../models';
3
3
  export interface NavigationSocialItemProps extends NavigationSocialItem {
4
4
  className?: string;
5
5
  }
@@ -2,9 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const react_1 = (0, tslib_1.__importDefault)(require("react"));
5
- const bem_cn_lite_1 = (0, tslib_1.__importDefault)(require("bem-cn-lite"));
5
+ const utils_1 = require("../../../../utils");
6
6
  const index_1 = require("../../../index");
7
- const b = (0, bem_cn_lite_1.default)('social-icon');
8
- const SocialIcon = ({ icon, url, className }) => (react_1.default.createElement("a", { href: url, target: "_blank", rel: "noopener noreferrer", className: b(null, className) },
9
- react_1.default.createElement(index_1.Image, { className: b('icon'), src: icon })));
7
+ const utils_2 = require("../../../Media/Image/utils");
8
+ const b = (0, utils_1.block)('social-icon');
9
+ const SocialIcon = ({ icon, url, className }) => {
10
+ const iconData = (0, utils_2.getMediaImage)(icon);
11
+ return (react_1.default.createElement("a", { href: url, target: "_blank", rel: "noopener noreferrer", className: b(null, className) },
12
+ react_1.default.createElement(index_1.Image, Object.assign({ className: b('icon') }, iconData))));
13
+ };
10
14
  exports.default = SocialIcon;
@@ -0,0 +1,7 @@
1
+ export { default as Header } from './Header/Header';
2
+ export { default as NavigationItem } from './NavigationItem/NavigationItem';
3
+ export { default as Logo } from './Logo/Logo';
4
+ export { default as MobileNavigation } from './MobileNavigation/MobileNavigation';
5
+ export { default as Navigation } from './Navigation/Navigation';
6
+ export { default as NavigationPopup } from './NavigationPopup/NavigationPopup';
7
+ export { default as SocialIcon } from './SocialIcon/SocialIcon';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SocialIcon = exports.NavigationPopup = exports.Navigation = exports.MobileNavigation = exports.Logo = exports.NavigationItem = exports.Header = void 0;
7
+ var Header_1 = require("./Header/Header");
8
+ Object.defineProperty(exports, "Header", { enumerable: true, get: function () { return __importDefault(Header_1).default; } });
9
+ var NavigationItem_1 = require("./NavigationItem/NavigationItem");
10
+ Object.defineProperty(exports, "NavigationItem", { enumerable: true, get: function () { return __importDefault(NavigationItem_1).default; } });
11
+ var Logo_1 = require("./Logo/Logo");
12
+ Object.defineProperty(exports, "Logo", { enumerable: true, get: function () { return __importDefault(Logo_1).default; } });
13
+ var MobileNavigation_1 = require("./MobileNavigation/MobileNavigation");
14
+ Object.defineProperty(exports, "MobileNavigation", { enumerable: true, get: function () { return __importDefault(MobileNavigation_1).default; } });
15
+ var Navigation_1 = require("./Navigation/Navigation");
16
+ Object.defineProperty(exports, "Navigation", { enumerable: true, get: function () { return __importDefault(Navigation_1).default; } });
17
+ var NavigationPopup_1 = require("./NavigationPopup/NavigationPopup");
18
+ Object.defineProperty(exports, "NavigationPopup", { enumerable: true, get: function () { return __importDefault(NavigationPopup_1).default; } });
19
+ var SocialIcon_1 = require("./SocialIcon/SocialIcon");
20
+ Object.defineProperty(exports, "SocialIcon", { enumerable: true, get: function () { return __importDefault(SocialIcon_1).default; } });
@@ -0,0 +1,10 @@
1
+ .layout {
2
+ display: flex;
3
+ flex-direction: column;
4
+ min-height: 100vh;
5
+ }
6
+ .layout__content {
7
+ display: flex;
8
+ flex-grow: 1;
9
+ flex-direction: column;
10
+ }
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { NavigationData } from '../../../../models';
3
+ export interface LayoutProps {
4
+ navigation?: NavigationData;
5
+ children?: React.ReactNode;
6
+ }
7
+ declare const Layout: React.FC<LayoutProps>;
8
+ export default Layout;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = (0, tslib_1.__importDefault)(require("react"));
5
+ const utils_1 = require("../../../../utils");
6
+ const Header_1 = (0, tslib_1.__importDefault)(require("../../components/Header/Header"));
7
+ const b = (0, utils_1.block)('layout');
8
+ const Layout = ({ children, navigation }) => (react_1.default.createElement("div", { className: b() },
9
+ navigation && react_1.default.createElement(Header_1.default, { data: navigation.header, logo: navigation.logo }),
10
+ react_1.default.createElement("main", { className: b('content') }, children)));
11
+ exports.default = Layout;
@@ -1,15 +1,14 @@
1
1
  import React from 'react';
2
- import { ShouldRenderBlock, CustomConfig, PageContent, CustomItems } from '../../models';
3
- import { blockMap, subBlockMap } from '../../constructor-items';
4
- import { NavigationData } from '../../models/navigation';
5
2
  import '@doc-tools/transform/dist/js/yfm';
3
+ import { ShouldRenderBlock, CustomConfig, PageContent, CustomItems, NavigationData } from '../../models';
4
+ import { blockMap, subBlockMap } from '../../constructor-items';
6
5
  export declare type ItemMap = typeof blockMap & typeof subBlockMap & CustomItems;
7
6
  export interface PageConstructorProps {
8
7
  content?: PageContent;
9
8
  shouldRenderBlock?: ShouldRenderBlock;
10
9
  custom?: CustomConfig;
11
10
  renderMenu?: () => React.ReactNode;
12
- navigationData?: NavigationData;
11
+ navigation?: NavigationData;
13
12
  }
14
13
  export declare const Constructor: (props: PageConstructorProps) => JSX.Element;
15
14
  export declare const PageConstructor: (props: PageConstructorProps) => JSX.Element;