@gravity-ui/page-constructor 1.7.0-alpha.5 → 1.7.0-alpha.6
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/Header/Header.css +1 -1
- package/build/cjs/components/navigation/components/Header/Header.d.ts +1 -21
- package/build/cjs/components/navigation/components/Header/Header.js +40 -64
- package/build/cjs/components/navigation/components/MobileNavigation/MobileNavigation.css +1 -1
- package/build/cjs/components/navigation/components/NavigationItem/NavigationItem.js +8 -3
- package/build/esm/components/navigation/components/Header/Header.css +1 -1
- package/build/esm/components/navigation/components/Header/Header.d.ts +1 -21
- package/build/esm/components/navigation/components/Header/Header.js +38 -64
- package/build/esm/components/navigation/components/MobileNavigation/MobileNavigation.css +1 -1
- package/build/esm/components/navigation/components/NavigationItem/NavigationItem.js +8 -3
- package/package.json +1 -1
|
@@ -4,25 +4,5 @@ export interface HeaderProps {
|
|
|
4
4
|
logo: NavigationLogo;
|
|
5
5
|
data: HeaderData;
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
isSidebarOpened: boolean;
|
|
9
|
-
activeItemIndex: number;
|
|
10
|
-
}
|
|
11
|
-
declare class Header extends React.Component<HeaderProps, HeaderState> {
|
|
12
|
-
ref: React.RefObject<unknown>;
|
|
13
|
-
state: {
|
|
14
|
-
isSidebarOpened: boolean;
|
|
15
|
-
activeItemIndex: number;
|
|
16
|
-
};
|
|
17
|
-
render(): JSX.Element;
|
|
18
|
-
private renderLeft;
|
|
19
|
-
private renderLogo;
|
|
20
|
-
private renderRight;
|
|
21
|
-
private renderRightItems;
|
|
22
|
-
private renderMobileMenuButton;
|
|
23
|
-
private renderMobileNavigation;
|
|
24
|
-
private onActiveItemChange;
|
|
25
|
-
private onSidebarOpenedChange;
|
|
26
|
-
private hideSidebar;
|
|
27
|
-
}
|
|
7
|
+
export declare const Header: React.FC<HeaderProps>;
|
|
28
8
|
export default Header;
|
|
@@ -1,81 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Header = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
const react_1 = (0, tslib_1.__importStar)(require("react"));
|
|
5
6
|
const bem_cn_lite_1 = (0, tslib_1.__importDefault)(require("bem-cn-lite"));
|
|
6
7
|
const grid_1 = require("../../../../grid");
|
|
7
8
|
const OutsideClick_1 = (0, tslib_1.__importDefault)(require("../../../OutsideClick/OutsideClick"));
|
|
8
9
|
const Control_1 = (0, tslib_1.__importDefault)(require("../../../Control/Control"));
|
|
9
|
-
const Logo_1 = (0, tslib_1.__importDefault)(require("../Logo/Logo"));
|
|
10
10
|
const Navigation_1 = (0, tslib_1.__importDefault)(require("../Navigation/Navigation"));
|
|
11
11
|
const MobileNavigation_1 = (0, tslib_1.__importDefault)(require("../MobileNavigation/MobileNavigation"));
|
|
12
12
|
const NavigationItem_1 = (0, tslib_1.__importDefault)(require("../NavigationItem/NavigationItem"));
|
|
13
|
+
const Logo_1 = (0, tslib_1.__importDefault)(require("../Logo/Logo"));
|
|
13
14
|
const icons_1 = require("../../../../icons");
|
|
14
15
|
const b = (0, bem_cn_lite_1.default)('header');
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
render() {
|
|
34
|
-
return (react_1.default.createElement(grid_1.Grid, { className: b() },
|
|
35
|
-
react_1.default.createElement(grid_1.Row, null,
|
|
36
|
-
react_1.default.createElement(grid_1.Col, null,
|
|
37
|
-
react_1.default.createElement("header", { className: b('wrapper') },
|
|
38
|
-
this.renderLogo(),
|
|
39
|
-
this.renderLeft(),
|
|
40
|
-
this.renderRight(),
|
|
41
|
-
this.renderMobileNavigation())))));
|
|
42
|
-
}
|
|
43
|
-
renderLeft() {
|
|
44
|
-
const { activeItemIndex } = this.state;
|
|
45
|
-
const { leftItems } = this.props.data;
|
|
46
|
-
return (leftItems && (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: this.onActiveItemChange }))));
|
|
48
|
-
}
|
|
49
|
-
renderLogo() {
|
|
50
|
-
const { logo } = this.props;
|
|
51
|
-
if (!logo) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
return (react_1.default.createElement("div", { className: b('left') },
|
|
55
|
-
react_1.default.createElement(Logo_1.default, Object.assign({}, logo, { className: b('logo') }))));
|
|
56
|
-
}
|
|
57
|
-
renderRight() {
|
|
58
|
-
return (react_1.default.createElement("div", { className: b('right') },
|
|
59
|
-
this.renderMobileMenuButton(),
|
|
60
|
-
this.renderRightItems()));
|
|
61
|
-
}
|
|
62
|
-
renderRightItems() {
|
|
63
|
-
const { rightItems } = this.props.data;
|
|
64
|
-
return (rightItems && (react_1.default.createElement("div", { className: b('buttons') }, rightItems.map((button) => (react_1.default.createElement(NavigationItem_1.default, { key: button.text, data: button, className: b('button') }))))));
|
|
65
|
-
}
|
|
66
|
-
renderMobileMenuButton() {
|
|
67
|
-
const { isSidebarOpened } = this.state;
|
|
16
|
+
const Header = ({ data, logo }) => {
|
|
17
|
+
const { leftItems, rightItems } = data;
|
|
18
|
+
const [isSidebarOpened, setIsSidebarOpened] = (0, react_1.useState)(false);
|
|
19
|
+
const [activeItemIndex, setActiveItemIndex] = (0, react_1.useState)(-1);
|
|
20
|
+
const onActiveItemChange = (0, react_1.useCallback)((index) => {
|
|
21
|
+
setActiveItemIndex(index);
|
|
22
|
+
}, []);
|
|
23
|
+
const onSidebarOpenedChange = (0, react_1.useCallback)((isOpen) => {
|
|
24
|
+
setIsSidebarOpened(isOpen);
|
|
25
|
+
}, []);
|
|
26
|
+
const hideSidebar = (0, react_1.useCallback)(() => {
|
|
27
|
+
setIsSidebarOpened(false);
|
|
28
|
+
}, []);
|
|
29
|
+
const renderLogo = (react_1.default.createElement("div", { className: b('left') },
|
|
30
|
+
react_1.default.createElement(Logo_1.default, Object.assign({}, logo, { className: b('logo') }))));
|
|
31
|
+
const renderLeft = (react_1.default.createElement("div", { className: b('navigation-container') },
|
|
32
|
+
react_1.default.createElement(Navigation_1.default, { className: b('navigation'), links: leftItems, activeItemIndex: activeItemIndex, onActiveItemChange: onActiveItemChange })));
|
|
33
|
+
const renderMobileMenuButton = () => {
|
|
68
34
|
const iconProps = { icon: isSidebarOpened ? icons_1.NavigationClose : icons_1.NavigationOpen, iconSize: 36 };
|
|
69
35
|
return (react_1.default.createElement(Control_1.default, Object.assign({ className: b('mobile-menu-button'), onClick: (e) => {
|
|
70
36
|
e.stopPropagation();
|
|
71
|
-
|
|
37
|
+
onSidebarOpenedChange(!isSidebarOpened);
|
|
72
38
|
}, size: "l" }, iconProps)));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
39
|
+
};
|
|
40
|
+
const renderRightItems = (react_1.default.createElement("div", { className: b('buttons') }, rightItems &&
|
|
41
|
+
rightItems.map((button) => (react_1.default.createElement(NavigationItem_1.default, { key: button.text, data: button, className: b('button') })))));
|
|
42
|
+
const renderRight = (react_1.default.createElement("div", { className: b('right') },
|
|
43
|
+
renderMobileMenuButton(),
|
|
44
|
+
rightItems && renderRightItems));
|
|
45
|
+
const renderMobileNavigation = (react_1.default.createElement(OutsideClick_1.default, { onOutsideClick: () => onSidebarOpenedChange(false) },
|
|
46
|
+
react_1.default.createElement(MobileNavigation_1.default, { topItems: leftItems, bottomItems: rightItems, isOpened: isSidebarOpened, activeItemIndex: activeItemIndex, onActiveItemChange: onActiveItemChange, onClose: hideSidebar })));
|
|
47
|
+
return (react_1.default.createElement(grid_1.Grid, { className: b() },
|
|
48
|
+
react_1.default.createElement(grid_1.Row, null,
|
|
49
|
+
react_1.default.createElement(grid_1.Col, null,
|
|
50
|
+
react_1.default.createElement("header", { className: b('wrapper') },
|
|
51
|
+
logo && renderLogo,
|
|
52
|
+
leftItems && renderLeft,
|
|
53
|
+
renderRight,
|
|
54
|
+
renderMobileNavigation)))));
|
|
55
|
+
};
|
|
56
|
+
exports.Header = Header;
|
|
57
|
+
exports.default = exports.Header;
|
|
@@ -9,7 +9,7 @@ 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:
|
|
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
|
}
|
|
@@ -22,15 +22,20 @@ const NavigationDropdown = (_a) => {
|
|
|
22
22
|
react_1.default.createElement(index_1.ToggleArrow, { className: b('dropdown'), size: 12, type: 'vertical', iconType: "navigation", open: isOpened })));
|
|
23
23
|
};
|
|
24
24
|
const NavigationLink = (props) => {
|
|
25
|
-
const { hostname } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
25
|
+
const { hostname, Link } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
26
26
|
const { url, text, icon, arrow, target } = props, rest = (0, tslib_1.__rest)(props, ["url", "text", "icon", "arrow", "target"]);
|
|
27
27
|
const linkExtraProps = (0, utils_1.getLinkProps)(url, hostname, target);
|
|
28
28
|
const iconData = icon && (0, utils_2.getMediaImage)(icon);
|
|
29
29
|
const content = (react_1.default.createElement(react_1.Fragment, null,
|
|
30
30
|
react_1.default.createElement(Content, { text: text, icon: iconData }),
|
|
31
31
|
arrow && react_1.default.createElement(icons_1.NavigationArrow, { className: b('arrow') })));
|
|
32
|
-
|
|
33
|
-
react_1.default.createElement("a", Object.assign({}, rest), content))
|
|
32
|
+
if ((linkExtraProps === null || linkExtraProps === void 0 ? void 0 : linkExtraProps.target) || !Link) {
|
|
33
|
+
return (react_1.default.createElement("a", Object.assign({ href: url, title: text }, rest, linkExtraProps), content));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
return (react_1.default.createElement(index_1.RouterLink, { href: url, passHref: true },
|
|
37
|
+
react_1.default.createElement("a", Object.assign({}, rest), content)));
|
|
38
|
+
}
|
|
34
39
|
};
|
|
35
40
|
const NavigationButton = (props) => {
|
|
36
41
|
const { url, target } = props;
|
|
@@ -5,25 +5,5 @@ export interface HeaderProps {
|
|
|
5
5
|
logo: NavigationLogo;
|
|
6
6
|
data: HeaderData;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
isSidebarOpened: boolean;
|
|
10
|
-
activeItemIndex: number;
|
|
11
|
-
}
|
|
12
|
-
declare class Header extends React.Component<HeaderProps, HeaderState> {
|
|
13
|
-
ref: React.RefObject<unknown>;
|
|
14
|
-
state: {
|
|
15
|
-
isSidebarOpened: boolean;
|
|
16
|
-
activeItemIndex: number;
|
|
17
|
-
};
|
|
18
|
-
render(): JSX.Element;
|
|
19
|
-
private renderLeft;
|
|
20
|
-
private renderLogo;
|
|
21
|
-
private renderRight;
|
|
22
|
-
private renderRightItems;
|
|
23
|
-
private renderMobileMenuButton;
|
|
24
|
-
private renderMobileNavigation;
|
|
25
|
-
private onActiveItemChange;
|
|
26
|
-
private onSidebarOpenedChange;
|
|
27
|
-
private hideSidebar;
|
|
28
|
-
}
|
|
8
|
+
export declare const Header: React.FC<HeaderProps>;
|
|
29
9
|
export default Header;
|
|
@@ -1,79 +1,53 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useCallback, useState } from 'react';
|
|
2
2
|
import block from 'bem-cn-lite';
|
|
3
3
|
import { Col, Grid, Row } from '../../../../grid';
|
|
4
4
|
import OutsideClick from '../../../OutsideClick/OutsideClick';
|
|
5
5
|
import Control from '../../../Control/Control';
|
|
6
|
-
import Logo from '../Logo/Logo';
|
|
7
6
|
import Navigation from '../Navigation/Navigation';
|
|
8
7
|
import MobileNavigation from '../MobileNavigation/MobileNavigation';
|
|
9
8
|
import NavigationItem from '../NavigationItem/NavigationItem';
|
|
9
|
+
import Logo from '../Logo/Logo';
|
|
10
10
|
import { NavigationClose, NavigationOpen } from '../../../../icons';
|
|
11
11
|
import './Header.css';
|
|
12
12
|
const b = block('header');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
render() {
|
|
32
|
-
return (React.createElement(Grid, { className: b() },
|
|
33
|
-
React.createElement(Row, null,
|
|
34
|
-
React.createElement(Col, null,
|
|
35
|
-
React.createElement("header", { className: b('wrapper') },
|
|
36
|
-
this.renderLogo(),
|
|
37
|
-
this.renderLeft(),
|
|
38
|
-
this.renderRight(),
|
|
39
|
-
this.renderMobileNavigation())))));
|
|
40
|
-
}
|
|
41
|
-
renderLeft() {
|
|
42
|
-
const { activeItemIndex } = this.state;
|
|
43
|
-
const { leftItems } = this.props.data;
|
|
44
|
-
return (leftItems && (React.createElement("div", { className: b('navigation-container') },
|
|
45
|
-
React.createElement(Navigation, { className: b('navigation'), links: leftItems, activeItemIndex: activeItemIndex, onActiveItemChange: this.onActiveItemChange }))));
|
|
46
|
-
}
|
|
47
|
-
renderLogo() {
|
|
48
|
-
const { logo } = this.props;
|
|
49
|
-
if (!logo) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
return (React.createElement("div", { className: b('left') },
|
|
53
|
-
React.createElement(Logo, Object.assign({}, logo, { className: b('logo') }))));
|
|
54
|
-
}
|
|
55
|
-
renderRight() {
|
|
56
|
-
return (React.createElement("div", { className: b('right') },
|
|
57
|
-
this.renderMobileMenuButton(),
|
|
58
|
-
this.renderRightItems()));
|
|
59
|
-
}
|
|
60
|
-
renderRightItems() {
|
|
61
|
-
const { rightItems } = this.props.data;
|
|
62
|
-
return (rightItems && (React.createElement("div", { className: b('buttons') }, rightItems.map((button) => (React.createElement(NavigationItem, { key: button.text, data: button, className: b('button') }))))));
|
|
63
|
-
}
|
|
64
|
-
renderMobileMenuButton() {
|
|
65
|
-
const { isSidebarOpened } = this.state;
|
|
13
|
+
export const Header = ({ data, logo }) => {
|
|
14
|
+
const { leftItems, rightItems } = data;
|
|
15
|
+
const [isSidebarOpened, setIsSidebarOpened] = useState(false);
|
|
16
|
+
const [activeItemIndex, setActiveItemIndex] = useState(-1);
|
|
17
|
+
const onActiveItemChange = useCallback((index) => {
|
|
18
|
+
setActiveItemIndex(index);
|
|
19
|
+
}, []);
|
|
20
|
+
const onSidebarOpenedChange = useCallback((isOpen) => {
|
|
21
|
+
setIsSidebarOpened(isOpen);
|
|
22
|
+
}, []);
|
|
23
|
+
const hideSidebar = useCallback(() => {
|
|
24
|
+
setIsSidebarOpened(false);
|
|
25
|
+
}, []);
|
|
26
|
+
const renderLogo = (React.createElement("div", { className: b('left') },
|
|
27
|
+
React.createElement(Logo, Object.assign({}, logo, { className: b('logo') }))));
|
|
28
|
+
const renderLeft = (React.createElement("div", { className: b('navigation-container') },
|
|
29
|
+
React.createElement(Navigation, { className: b('navigation'), links: leftItems, activeItemIndex: activeItemIndex, onActiveItemChange: onActiveItemChange })));
|
|
30
|
+
const renderMobileMenuButton = () => {
|
|
66
31
|
const iconProps = { icon: isSidebarOpened ? NavigationClose : NavigationOpen, iconSize: 36 };
|
|
67
32
|
return (React.createElement(Control, Object.assign({ className: b('mobile-menu-button'), onClick: (e) => {
|
|
68
33
|
e.stopPropagation();
|
|
69
|
-
|
|
34
|
+
onSidebarOpenedChange(!isSidebarOpened);
|
|
70
35
|
}, size: "l" }, iconProps)));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
}
|
|
36
|
+
};
|
|
37
|
+
const renderRightItems = (React.createElement("div", { className: b('buttons') }, rightItems &&
|
|
38
|
+
rightItems.map((button) => (React.createElement(NavigationItem, { key: button.text, data: button, className: b('button') })))));
|
|
39
|
+
const renderRight = (React.createElement("div", { className: b('right') },
|
|
40
|
+
renderMobileMenuButton(),
|
|
41
|
+
rightItems && renderRightItems));
|
|
42
|
+
const renderMobileNavigation = (React.createElement(OutsideClick, { onOutsideClick: () => onSidebarOpenedChange(false) },
|
|
43
|
+
React.createElement(MobileNavigation, { topItems: leftItems, bottomItems: rightItems, isOpened: isSidebarOpened, activeItemIndex: activeItemIndex, onActiveItemChange: onActiveItemChange, onClose: hideSidebar })));
|
|
44
|
+
return (React.createElement(Grid, { className: b() },
|
|
45
|
+
React.createElement(Row, null,
|
|
46
|
+
React.createElement(Col, null,
|
|
47
|
+
React.createElement("header", { className: b('wrapper') },
|
|
48
|
+
logo && renderLogo,
|
|
49
|
+
leftItems && renderLeft,
|
|
50
|
+
renderRight,
|
|
51
|
+
renderMobileNavigation)))));
|
|
52
|
+
};
|
|
79
53
|
export default Header;
|
|
@@ -9,7 +9,7 @@ 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:
|
|
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
|
}
|
|
@@ -21,15 +21,20 @@ const NavigationDropdown = (_a) => {
|
|
|
21
21
|
React.createElement(ToggleArrow, { className: b('dropdown'), size: 12, type: 'vertical', iconType: "navigation", open: isOpened })));
|
|
22
22
|
};
|
|
23
23
|
const NavigationLink = (props) => {
|
|
24
|
-
const { hostname } = useContext(LocationContext);
|
|
24
|
+
const { hostname, Link } = useContext(LocationContext);
|
|
25
25
|
const { url, text, icon, arrow, target } = props, rest = __rest(props, ["url", "text", "icon", "arrow", "target"]);
|
|
26
26
|
const linkExtraProps = getLinkProps(url, hostname, target);
|
|
27
27
|
const iconData = icon && getMediaImage(icon);
|
|
28
28
|
const content = (React.createElement(Fragment, null,
|
|
29
29
|
React.createElement(Content, { text: text, icon: iconData }),
|
|
30
30
|
arrow && React.createElement(NavigationArrow, { className: b('arrow') })));
|
|
31
|
-
|
|
32
|
-
React.createElement("a", Object.assign({}, rest), content))
|
|
31
|
+
if ((linkExtraProps === null || linkExtraProps === void 0 ? void 0 : linkExtraProps.target) || !Link) {
|
|
32
|
+
return (React.createElement("a", Object.assign({ href: url, title: text }, rest, linkExtraProps), content));
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return (React.createElement(RouterLink, { href: url, passHref: true },
|
|
36
|
+
React.createElement("a", Object.assign({}, rest), content)));
|
|
37
|
+
}
|
|
33
38
|
};
|
|
34
39
|
const NavigationButton = (props) => {
|
|
35
40
|
const { url, target } = props;
|