@gravity-ui/page-constructor 1.7.0-alpha.2 → 1.7.0-alpha.3

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.
@@ -15,7 +15,6 @@ unpredictable css rules order in build */
15
15
  }
16
16
  .logo__icon {
17
17
  display: flex;
18
- height: 36px;
19
18
  margin-right: 8px;
20
19
  object-fit: contain;
21
20
  }
@@ -11,7 +11,7 @@ const Logo = ({ icon, text, className }) => {
11
11
  const imageData = (0, utils_1.getMediaImage)(icon);
12
12
  return (react_1.default.createElement(RouterLink_1.default, { href: "/", passHref: true },
13
13
  react_1.default.createElement("div", { className: b(null, className) },
14
- imageData && react_1.default.createElement(index_1.Image, Object.assign({}, imageData)),
14
+ imageData && react_1.default.createElement(index_1.Image, Object.assign({ className: b('icon') }, imageData)),
15
15
  react_1.default.createElement("span", { className: b('text') }, text))));
16
16
  };
17
17
  exports.default = Logo;
@@ -1,5 +1,5 @@
1
1
  import React, { MouseEventHandler } from 'react';
2
- import { NavigationButtonItem, NavigationDropdownItem, NavigationSocialItem, NavigationLinkItem } from '../../../../models/navigation';
2
+ import { NavigationButtonItem, NavigationDropdownItem, NavigationSocialItem, NavigationLinkItem } from '../../../../models';
3
3
  declare type DropdownItemData = Omit<NavigationDropdownItem, 'items'>;
4
4
  export declare type NavigationItemData = NavigationLinkItem | NavigationButtonItem | NavigationSocialItem | DropdownItemData;
5
5
  export interface NavigationItemProps {
@@ -6,13 +6,13 @@ const bem_cn_lite_1 = (0, tslib_1.__importDefault)(require("bem-cn-lite"));
6
6
  const index_1 = require("../../../index");
7
7
  const utils_1 = require("../../../../utils");
8
8
  const locationContext_1 = require("../../../../context/locationContext");
9
- const navigation_1 = require("../../../../models/navigation");
9
+ const models_1 = require("../../../../models");
10
10
  const icons_1 = require("../../../../icons");
11
11
  const SocialIcon_1 = (0, tslib_1.__importDefault)(require("../SocialIcon/SocialIcon"));
12
12
  const utils_2 = require("../../../Media/Image/utils");
13
13
  const b = (0, bem_cn_lite_1.default)('navigation-item');
14
14
  const Content = ({ text, icon }) => (react_1.default.createElement(react_1.Fragment, null,
15
- icon && react_1.default.createElement("img", Object.assign({ className: b('icon') }, icon)),
15
+ icon && react_1.default.createElement(index_1.Image, Object.assign({ className: b('icon') }, icon)),
16
16
  react_1.default.createElement("span", { className: b('text') }, text)));
17
17
  const NavigationDropdown = (_a) => {
18
18
  var { text, icon, isOpened } = _a, props = (0, tslib_1.__rest)(_a, ["text", "icon", "isOpened"]);
@@ -32,17 +32,22 @@ const NavigationLink = (props) => {
32
32
  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 },
33
33
  react_1.default.createElement("a", Object.assign({}, rest), content)));
34
34
  };
35
+ const NavigationButton = (props) => {
36
+ const { url, target } = props;
37
+ return target ? (react_1.default.createElement(index_1.Button, Object.assign({}, props, { url: url }))) : (react_1.default.createElement(index_1.RouterLink, { href: url },
38
+ react_1.default.createElement(index_1.Button, Object.assign({}, props, { url: url }))));
39
+ };
35
40
  //todo: add types support form component in map
36
41
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
42
  const NavigationItemsMap = {
38
- [navigation_1.NavigationItemType.Button]: index_1.RouterLink,
39
- [navigation_1.NavigationItemType.Social]: SocialIcon_1.default,
40
- [navigation_1.NavigationItemType.Dropdown]: NavigationDropdown,
41
- [navigation_1.NavigationItemType.Link]: NavigationLink,
43
+ [models_1.NavigationItemType.Button]: NavigationButton,
44
+ [models_1.NavigationItemType.Social]: SocialIcon_1.default,
45
+ [models_1.NavigationItemType.Dropdown]: NavigationDropdown,
46
+ [models_1.NavigationItemType.Link]: NavigationLink,
42
47
  };
43
48
  const NavigationItem = (_a) => {
44
49
  var { data, className } = _a, props = (0, tslib_1.__rest)(_a, ["data", "className"]);
45
- const { type = navigation_1.NavigationItemType.Link } = data;
50
+ const { type = models_1.NavigationItemType.Link } = data;
46
51
  const Component = NavigationItemsMap[type];
47
52
  const componentProps = (0, react_1.useMemo)(() => (Object.assign(Object.assign({ className: b({ type }, className) }, data), props)), [className, data, props, type]);
48
53
  return react_1.default.createElement(Component, Object.assign({}, componentProps));
@@ -15,7 +15,6 @@ unpredictable css rules order in build */
15
15
  }
16
16
  .logo__icon {
17
17
  display: flex;
18
- height: 36px;
19
18
  margin-right: 8px;
20
19
  object-fit: contain;
21
20
  }
@@ -9,7 +9,7 @@ const Logo = ({ icon, text, className }) => {
9
9
  const imageData = getMediaImage(icon);
10
10
  return (React.createElement(RouterLink, { href: "/", passHref: true },
11
11
  React.createElement("div", { className: b(null, className) },
12
- imageData && React.createElement(Image, Object.assign({}, imageData)),
12
+ imageData && React.createElement(Image, Object.assign({ className: b('icon') }, imageData)),
13
13
  React.createElement("span", { className: b('text') }, text))));
14
14
  };
15
15
  export default Logo;
@@ -1,5 +1,5 @@
1
1
  import React, { MouseEventHandler } from 'react';
2
- import { NavigationButtonItem, NavigationDropdownItem, NavigationSocialItem, NavigationLinkItem } from '../../../../models/navigation';
2
+ import { NavigationButtonItem, NavigationDropdownItem, NavigationSocialItem, NavigationLinkItem } from '../../../../models';
3
3
  import './NavigationItem.css';
4
4
  declare type DropdownItemData = Omit<NavigationDropdownItem, 'items'>;
5
5
  export declare type NavigationItemData = NavigationLinkItem | NavigationButtonItem | NavigationSocialItem | DropdownItemData;
@@ -1,17 +1,17 @@
1
1
  import { __rest } from "tslib";
2
2
  import React, { Fragment, useContext, useMemo } from 'react';
3
3
  import block from 'bem-cn-lite';
4
- import { RouterLink, ToggleArrow } from '../../../index';
4
+ import { RouterLink, ToggleArrow, Button, Image } from '../../../index';
5
5
  import { getLinkProps } from '../../../../utils';
6
6
  import { LocationContext } from '../../../../context/locationContext';
7
- import { NavigationItemType, } from '../../../../models/navigation';
7
+ import { NavigationItemType, } from '../../../../models';
8
8
  import { NavigationArrow } from '../../../../icons';
9
9
  import SocialIcon from '../SocialIcon/SocialIcon';
10
10
  import { getMediaImage } from '../../../Media/Image/utils';
11
11
  import './NavigationItem.css';
12
12
  const b = block('navigation-item');
13
13
  const Content = ({ text, icon }) => (React.createElement(Fragment, null,
14
- icon && React.createElement("img", Object.assign({ className: b('icon') }, icon)),
14
+ icon && React.createElement(Image, Object.assign({ className: b('icon') }, icon)),
15
15
  React.createElement("span", { className: b('text') }, text)));
16
16
  const NavigationDropdown = (_a) => {
17
17
  var { text, icon, isOpened } = _a, props = __rest(_a, ["text", "icon", "isOpened"]);
@@ -31,10 +31,15 @@ const NavigationLink = (props) => {
31
31
  return (linkExtraProps === null || linkExtraProps === void 0 ? void 0 : linkExtraProps.target) ? (React.createElement("a", Object.assign({ href: url, title: text }, rest, linkExtraProps), content)) : (React.createElement(RouterLink, { href: url, passHref: true },
32
32
  React.createElement("a", Object.assign({}, rest), content)));
33
33
  };
34
+ const NavigationButton = (props) => {
35
+ const { url, target } = props;
36
+ return target ? (React.createElement(Button, Object.assign({}, props, { url: url }))) : (React.createElement(RouterLink, { href: url },
37
+ React.createElement(Button, Object.assign({}, props, { url: url }))));
38
+ };
34
39
  //todo: add types support form component in map
35
40
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
41
  const NavigationItemsMap = {
37
- [NavigationItemType.Button]: RouterLink,
42
+ [NavigationItemType.Button]: NavigationButton,
38
43
  [NavigationItemType.Social]: SocialIcon,
39
44
  [NavigationItemType.Dropdown]: NavigationDropdown,
40
45
  [NavigationItemType.Link]: NavigationLink,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "1.7.0-alpha.2",
3
+ "version": "1.7.0-alpha.3",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {