@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.
- package/build/cjs/components/navigation/components/Logo/Logo.css +0 -1
- package/build/cjs/components/navigation/components/Logo/Logo.js +1 -1
- package/build/cjs/components/navigation/components/NavigationItem/NavigationItem.d.ts +1 -1
- package/build/cjs/components/navigation/components/NavigationItem/NavigationItem.js +12 -7
- package/build/esm/components/navigation/components/Logo/Logo.css +0 -1
- package/build/esm/components/navigation/components/Logo/Logo.js +1 -1
- package/build/esm/components/navigation/components/NavigationItem/NavigationItem.d.ts +1 -1
- package/build/esm/components/navigation/components/NavigationItem/NavigationItem.js +9 -4
- package/package.json +1 -1
|
@@ -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
|
|
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
|
|
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(
|
|
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
|
-
[
|
|
39
|
-
[
|
|
40
|
-
[
|
|
41
|
-
[
|
|
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 =
|
|
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));
|
|
@@ -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
|
|
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
|
|
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(
|
|
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]:
|
|
42
|
+
[NavigationItemType.Button]: NavigationButton,
|
|
38
43
|
[NavigationItemType.Social]: SocialIcon,
|
|
39
44
|
[NavigationItemType.Dropdown]: NavigationDropdown,
|
|
40
45
|
[NavigationItemType.Link]: NavigationLink,
|