@gravity-ui/page-constructor 4.36.0 → 4.37.0
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/README.md +10 -0
- package/build/cjs/blocks/Icons/Icons.d.ts +1 -1
- package/build/cjs/blocks/Icons/Icons.js +2 -2
- package/build/cjs/components/RootCn/index.d.ts +4 -0
- package/build/cjs/components/RootCn/index.js +11 -0
- package/build/cjs/constructor-items.d.ts +1 -1
- package/build/cjs/containers/PageConstructor/PageConstructor.js +2 -3
- package/build/cjs/index.d.ts +1 -0
- package/build/cjs/index.js +1 -0
- package/build/cjs/models/constructor-items/blocks.d.ts +1 -0
- package/build/cjs/navigation/components/Navigation/Navigation.css +0 -3
- package/build/cjs/navigation/components/Navigation/Navigation.d.ts +2 -2
- package/build/cjs/navigation/components/Navigation/Navigation.js +2 -2
- package/build/cjs/navigation/components/NavigationItem/NavigationItem.js +2 -2
- package/build/cjs/navigation/components/NavigationItem/hooks/useNavigationItemMap.d.ts +7 -0
- package/build/cjs/navigation/components/NavigationItem/hooks/useNavigationItemMap.js +13 -0
- package/build/cjs/navigation/components/Standalone/index.d.ts +3 -0
- package/build/cjs/navigation/components/Standalone/index.js +9 -0
- package/build/cjs/navigation/containers/Layout/Layout.css +7 -2
- package/build/cjs/navigation/containers/Layout/Layout.js +1 -1
- package/build/cjs/navigation/index.d.ts +1 -0
- package/build/cjs/navigation/index.js +8 -0
- package/build/cjs/text-transform/config.js +1 -7
- package/build/cjs/utils/cn.d.ts +1 -0
- package/build/cjs/utils/cn.js +3 -1
- package/build/esm/blocks/Icons/Icons.d.ts +1 -1
- package/build/esm/blocks/Icons/Icons.js +2 -2
- package/build/esm/components/RootCn/index.d.ts +4 -0
- package/build/esm/components/RootCn/index.js +8 -0
- package/build/esm/constructor-items.d.ts +1 -1
- package/build/esm/containers/PageConstructor/PageConstructor.js +3 -4
- package/build/esm/index.d.ts +1 -0
- package/build/esm/index.js +1 -0
- package/build/esm/models/constructor-items/blocks.d.ts +1 -0
- package/build/esm/navigation/components/Navigation/Navigation.css +0 -3
- package/build/esm/navigation/components/Navigation/Navigation.d.ts +2 -2
- package/build/esm/navigation/components/Navigation/Navigation.js +2 -2
- package/build/esm/navigation/components/NavigationItem/NavigationItem.js +3 -3
- package/build/esm/navigation/components/NavigationItem/hooks/useNavigationItemMap.d.ts +7 -0
- package/build/esm/navigation/components/NavigationItem/hooks/useNavigationItemMap.js +8 -0
- package/build/esm/navigation/components/Standalone/index.d.ts +3 -0
- package/build/esm/navigation/components/Standalone/index.js +6 -0
- package/build/esm/navigation/containers/Layout/Layout.css +7 -2
- package/build/esm/navigation/containers/Layout/Layout.js +1 -1
- package/build/esm/navigation/index.d.ts +1 -0
- package/build/esm/navigation/index.js +1 -0
- package/build/esm/text-transform/config.js +1 -7
- package/build/esm/utils/cn.d.ts +1 -0
- package/build/esm/utils/cn.js +2 -0
- package/package.json +1 -1
- package/server/models/constructor-items/blocks.d.ts +1 -0
- package/server/text-transform/config.js +1 -7
- package/server/utils/cn.d.ts +1 -0
- package/server/utils/cn.js +3 -1
- package/widget/index.js +1 -1
package/README.md
CHANGED
|
@@ -162,6 +162,16 @@ const Page: React.FC<PageProps> = ({children}) => (
|
|
|
162
162
|
);
|
|
163
163
|
```
|
|
164
164
|
|
|
165
|
+
### Navigation
|
|
166
|
+
|
|
167
|
+
Page navigation can also be used separately from the constructor:
|
|
168
|
+
|
|
169
|
+
```jsx
|
|
170
|
+
import {Navigation} from '@gravity-ui/page-constructor';
|
|
171
|
+
|
|
172
|
+
const Page: React.FC<PageProps> = ({data, logo}) => <Navigation data={data} logo={logo} />;
|
|
173
|
+
```
|
|
174
|
+
|
|
165
175
|
### Blocks
|
|
166
176
|
|
|
167
177
|
Each block is an atomic top-level component. They're stored in the `src/units/constructor/blocks` directory.
|
|
@@ -10,14 +10,14 @@ const b = (0, utils_1.block)('icons-block');
|
|
|
10
10
|
const getItemContent = (item) => (react_1.default.createElement(react_1.Fragment, null,
|
|
11
11
|
react_1.default.createElement(components_1.Image, { className: b('image'), src: item.src }),
|
|
12
12
|
react_1.default.createElement("p", { className: b('text') }, item.text)));
|
|
13
|
-
const Icons = ({ title, size = 's', items }) => {
|
|
13
|
+
const Icons = ({ title, description, size = 's', items }) => {
|
|
14
14
|
const { hostname } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
15
15
|
const handleAnalytics = (0, hooks_1.useAnalytics)();
|
|
16
16
|
const onClick = (0, react_1.useCallback)(({ analyticsEvents, url }) => {
|
|
17
17
|
handleAnalytics(analyticsEvents, { url });
|
|
18
18
|
}, [handleAnalytics]);
|
|
19
19
|
return (react_1.default.createElement("div", { className: b({ size }) },
|
|
20
|
-
title && react_1.default.createElement(components_1.Title, { className: b('header'), title: title, colSizes: { all: 12 } }),
|
|
20
|
+
(title || description) && (react_1.default.createElement(components_1.Title, { className: b('header'), title: title, subtitle: description, colSizes: { all: 12 } })),
|
|
21
21
|
items.map((item) => {
|
|
22
22
|
const itemContent = getItemContent(item);
|
|
23
23
|
const { url, text } = item;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
+
const theme_1 = require("../../context/theme");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const RootCn = ({ className, children }) => {
|
|
8
|
+
const theme = (0, theme_1.useTheme)();
|
|
9
|
+
return react_1.default.createElement("div", { className: (0, utils_1.rootCn)({ theme }, className) }, children);
|
|
10
|
+
};
|
|
11
|
+
exports.default = RootCn;
|
|
@@ -10,7 +10,7 @@ export declare const blockMap: {
|
|
|
10
10
|
"table-block": (props: import("./models").TableBlockProps) => JSX.Element;
|
|
11
11
|
"tabs-block": ({ items, title, description, animated, tabsColSizes, centered, direction, contentSize, }: import("./models").TabsBlockProps) => JSX.Element;
|
|
12
12
|
"header-block": (props: import("./models").WithChildren<import("./models").HeaderBlockProps & import("./models").ClassNameProps>) => JSX.Element;
|
|
13
|
-
"icons-block": ({ title, size, items }: import("./models").IconsBlockProps) => JSX.Element;
|
|
13
|
+
"icons-block": ({ title, description, size, items }: import("./models").IconsBlockProps) => JSX.Element;
|
|
14
14
|
"header-slider-block": ({ items, arrows, ...props }: import("./models").HeaderSliderBlockProps) => JSX.Element;
|
|
15
15
|
"card-layout-block": import("react").FC<import("./blocks/CardLayout/CardLayout").CardLayoutBlockProps>;
|
|
16
16
|
"content-layout-block": (props: import("./models").ContentLayoutBlockProps) => JSX.Element;
|
|
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
6
|
require("@doc-tools/transform/dist/js/yfm");
|
|
7
7
|
const BackgroundMedia_1 = tslib_1.__importDefault(require("../../components/BackgroundMedia/BackgroundMedia"));
|
|
8
|
-
const
|
|
8
|
+
const RootCn_1 = tslib_1.__importDefault(require("../../components/RootCn"));
|
|
9
9
|
const constructor_items_1 = require("../../constructor-items");
|
|
10
10
|
const animateContext_1 = require("../../context/animateContext");
|
|
11
11
|
const innerContext_1 = require("../../context/innerContext");
|
|
@@ -18,7 +18,6 @@ const ConstructorBlocks_1 = require("./components/ConstructorBlocks");
|
|
|
18
18
|
const ConstructorItem_1 = require("./components/ConstructorItem");
|
|
19
19
|
const ConstructorRow_1 = require("./components/ConstructorRow");
|
|
20
20
|
const b = (0, utils_1.block)('page-constructor');
|
|
21
|
-
const ycr = (0, utils_1.cn)(constants_1.UIKIT_ROOT_CLASS);
|
|
22
21
|
const Constructor = (props) => {
|
|
23
22
|
const { content: { blocks = [], background = {} } = {}, renderMenu, shouldRenderBlock, navigation, custom, } = props;
|
|
24
23
|
const { context } = (0, react_1.useMemo)(() => ({
|
|
@@ -44,7 +43,7 @@ const Constructor = (props) => {
|
|
|
44
43
|
const restBlocks = (0, utils_1.getOrderedBlocks)(blocks, context.headerBlockTypes);
|
|
45
44
|
const themedBackground = (0, utils_1.getThemedValue)(background, theme);
|
|
46
45
|
return (react_1.default.createElement(innerContext_1.InnerContext.Provider, { value: context },
|
|
47
|
-
react_1.default.createElement(
|
|
46
|
+
react_1.default.createElement(RootCn_1.default, null,
|
|
48
47
|
react_1.default.createElement("div", { className: b('wrapper') },
|
|
49
48
|
themedBackground && (react_1.default.createElement(BackgroundMedia_1.default, Object.assign({}, themedBackground, { className: b('background') }))),
|
|
50
49
|
react_1.default.createElement(Layout_1.default, { navigation: navigation },
|
package/build/cjs/index.d.ts
CHANGED
package/build/cjs/index.js
CHANGED
|
@@ -15,5 +15,6 @@ tslib_1.__exportStar(require("./utils"), exports);
|
|
|
15
15
|
tslib_1.__exportStar(require("./schema"), exports);
|
|
16
16
|
tslib_1.__exportStar(require("./hooks"), exports);
|
|
17
17
|
tslib_1.__exportStar(require("./icons"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./navigation"), exports);
|
|
18
19
|
var constants_1 = require("./constants");
|
|
19
20
|
Object.defineProperty(exports, "BREAKPOINTS", { enumerable: true, get: function () { return constants_1.BREAKPOINTS; } });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { HeaderData, ThemedNavigationLogoData } from '../../../models';
|
|
3
|
-
export interface NavigationProps {
|
|
2
|
+
import { ClassNameProps, HeaderData, ThemedNavigationLogoData } from '../../../models';
|
|
3
|
+
export interface NavigationProps extends ClassNameProps {
|
|
4
4
|
logo: ThemedNavigationLogoData;
|
|
5
5
|
data: HeaderData;
|
|
6
6
|
}
|
|
@@ -11,7 +11,7 @@ const utils_2 = require("../../utils");
|
|
|
11
11
|
const DesktopNavigation_1 = tslib_1.__importDefault(require("../DesktopNavigation/DesktopNavigation"));
|
|
12
12
|
const MobileNavigation_1 = tslib_1.__importDefault(require("../MobileNavigation/MobileNavigation"));
|
|
13
13
|
const b = (0, utils_1.block)('navigation');
|
|
14
|
-
const Navigation = ({ data, logo }) => {
|
|
14
|
+
const Navigation = ({ data, logo, className }) => {
|
|
15
15
|
const { leftItems, rightItems, iconSize = 20, withBorder = false } = data;
|
|
16
16
|
const [isSidebarOpened, setIsSidebarOpened] = (0, react_1.useState)(false);
|
|
17
17
|
const [activeItemId, setActiveItemId] = (0, react_1.useState)(undefined);
|
|
@@ -33,7 +33,7 @@ const Navigation = ({ data, logo }) => {
|
|
|
33
33
|
window.addEventListener('scroll', scrollHandler, { passive: true });
|
|
34
34
|
return () => window.removeEventListener('scroll', scrollHandler);
|
|
35
35
|
});
|
|
36
|
-
return (react_1.default.createElement(grid_1.Grid, { className: b({ 'with-border': showBorder }) },
|
|
36
|
+
return (react_1.default.createElement(grid_1.Grid, { className: b({ 'with-border': showBorder }, className) },
|
|
37
37
|
react_1.default.createElement(grid_1.Row, null,
|
|
38
38
|
react_1.default.createElement(grid_1.Col, null,
|
|
39
39
|
react_1.default.createElement("nav", null,
|
|
@@ -4,15 +4,15 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
5
|
const omit_1 = tslib_1.__importDefault(require("lodash/omit"));
|
|
6
6
|
const blockIdContext_1 = require("../../../context/blockIdContext");
|
|
7
|
-
const innerContext_1 = require("../../../context/innerContext");
|
|
8
7
|
const models_1 = require("../../../models");
|
|
9
8
|
const utils_1 = require("../../../utils");
|
|
9
|
+
const useNavigationItemMap_1 = require("./hooks/useNavigationItemMap");
|
|
10
10
|
const b = (0, utils_1.block)('navigation-item');
|
|
11
11
|
const ANALYTICS_ID = 'navigation';
|
|
12
12
|
const NavigationItem = (_a) => {
|
|
13
13
|
var { data, className, menuLayout } = _a, props = tslib_1.__rest(_a, ["data", "className", "menuLayout"]);
|
|
14
14
|
const { type = models_1.NavigationItemType.Link } = data;
|
|
15
|
-
const
|
|
15
|
+
const navItemMap = (0, useNavigationItemMap_1.useNavigationItemMap)();
|
|
16
16
|
const Component = navItemMap[type];
|
|
17
17
|
const componentProps = (0, react_1.useMemo)(() => {
|
|
18
18
|
const componentProperties = Object.assign(Object.assign({}, data), props);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const useNavigationItemMap: () => {
|
|
2
|
+
button: import("react").FC<Pick<import("../../../models").NavigationItemProps, "className"> & import("../../../..").ButtonProps>;
|
|
3
|
+
social: import("react").FC<import("../../SocialIcon/SocialIcon").NavigationSocialItemOwnProps>;
|
|
4
|
+
dropdown: ({ text, icon, className, iconSize, hidePopup, items, isActive, ...props }: import("../../../models").NavigationItemProps & import("../../../..").NavigationDropdownItem) => JSX.Element;
|
|
5
|
+
link: import("react").FC<import("../../../models").NavigationItemProps & import("../../../..").NavigationLinkItem>;
|
|
6
|
+
"github-button": ({ text, url, className, label, size, icon, urlTitle, }: import("../../../models").NavigationItemProps & import("../../../..").NavigationGithubButton) => JSX.Element;
|
|
7
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useNavigationItemMap = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
|
|
7
|
+
const constructor_items_1 = require("../../../../constructor-items");
|
|
8
|
+
const innerContext_1 = require("../../../../context/innerContext");
|
|
9
|
+
const useNavigationItemMap = () => {
|
|
10
|
+
const { navItemMap } = (0, react_1.useContext)(innerContext_1.InnerContext);
|
|
11
|
+
return (0, isEmpty_1.default)(navItemMap) ? constructor_items_1.navItemMap : navItemMap;
|
|
12
|
+
};
|
|
13
|
+
exports.useNavigationItemMap = useNavigationItemMap;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
+
const RootCn_1 = tslib_1.__importDefault(require("../../../components/RootCn"));
|
|
6
|
+
const Navigation_1 = tslib_1.__importDefault(require("./../../components/Navigation/Navigation"));
|
|
7
|
+
const Standalone = (props) => (react_1.default.createElement(RootCn_1.default, null,
|
|
8
|
+
react_1.default.createElement(Navigation_1.default, Object.assign({}, props))));
|
|
9
|
+
exports.default = Standalone;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
.layout {
|
|
1
|
+
.pc-layout {
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
min-height: 100vh;
|
|
5
5
|
}
|
|
6
|
-
.layout__content {
|
|
6
|
+
.pc-layout__content {
|
|
7
7
|
display: flex;
|
|
8
8
|
flex-grow: 1;
|
|
9
9
|
flex-direction: column;
|
|
10
|
+
}
|
|
11
|
+
.pc-layout__navigation {
|
|
12
|
+
position: sticky;
|
|
13
|
+
z-index: 98;
|
|
14
|
+
top: 0;
|
|
10
15
|
}
|
|
@@ -6,6 +6,6 @@ const utils_1 = require("../../../utils");
|
|
|
6
6
|
const Navigation_1 = tslib_1.__importDefault(require("../../components/Navigation/Navigation"));
|
|
7
7
|
const b = (0, utils_1.block)('layout');
|
|
8
8
|
const Layout = ({ children, navigation }) => (react_1.default.createElement("div", { className: b() },
|
|
9
|
-
navigation && react_1.default.createElement(Navigation_1.default, { data: navigation.header, logo: navigation.logo }),
|
|
9
|
+
navigation && (react_1.default.createElement(Navigation_1.default, { data: navigation.header, logo: navigation.logo, className: b('navigation') })),
|
|
10
10
|
react_1.default.createElement("main", { className: b('content') }, children)));
|
|
11
11
|
exports.default = Layout;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Navigation } from './components/Standalone';
|
|
@@ -0,0 +1,8 @@
|
|
|
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.Navigation = void 0;
|
|
7
|
+
var Standalone_1 = require("./components/Standalone");
|
|
8
|
+
Object.defineProperty(exports, "Navigation", { enumerable: true, get: function () { return __importDefault(Standalone_1).default; } });
|
|
@@ -302,11 +302,5 @@ exports.config = {
|
|
|
302
302
|
},
|
|
303
303
|
],
|
|
304
304
|
[models_1.BlockType.CardLayoutBlock]: exports.blockHeaderTransformer,
|
|
305
|
-
[models_1.BlockType.IconsBlock]:
|
|
306
|
-
{
|
|
307
|
-
fields: ['title'],
|
|
308
|
-
transformer: common_1.typografTransformer,
|
|
309
|
-
parser: parseTitle,
|
|
310
|
-
},
|
|
311
|
-
],
|
|
305
|
+
[models_1.BlockType.IconsBlock]: exports.blockHeaderTransformer,
|
|
312
306
|
};
|
package/build/cjs/utils/cn.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const NAMESPACE = "pc-";
|
|
2
2
|
export declare const cn: import("@bem-react/classname").ClassNameInitilizer;
|
|
3
3
|
export declare const block: import("@bem-react/classname").ClassNameInitilizer;
|
|
4
|
+
export declare const rootCn: import("@bem-react/classname").ClassNameFormatter;
|
|
4
5
|
export type CnBlock = ReturnType<typeof cn>;
|
package/build/cjs/utils/cn.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.block = exports.cn = exports.NAMESPACE = void 0;
|
|
3
|
+
exports.rootCn = exports.block = exports.cn = exports.NAMESPACE = void 0;
|
|
4
4
|
const classname_1 = require("@bem-react/classname");
|
|
5
|
+
const constants_1 = require("../components/constants");
|
|
5
6
|
exports.NAMESPACE = 'pc-';
|
|
6
7
|
exports.cn = (0, classname_1.withNaming)({ e: '__', m: '_' });
|
|
7
8
|
exports.block = (0, classname_1.withNaming)({ n: exports.NAMESPACE, e: '__', m: '_' });
|
|
9
|
+
exports.rootCn = (0, exports.cn)(constants_1.UIKIT_ROOT_CLASS);
|
|
@@ -8,14 +8,14 @@ const b = block('icons-block');
|
|
|
8
8
|
const getItemContent = (item) => (React.createElement(Fragment, null,
|
|
9
9
|
React.createElement(Image, { className: b('image'), src: item.src }),
|
|
10
10
|
React.createElement("p", { className: b('text') }, item.text)));
|
|
11
|
-
const Icons = ({ title, size = 's', items }) => {
|
|
11
|
+
const Icons = ({ title, description, size = 's', items }) => {
|
|
12
12
|
const { hostname } = useContext(LocationContext);
|
|
13
13
|
const handleAnalytics = useAnalytics();
|
|
14
14
|
const onClick = useCallback(({ analyticsEvents, url }) => {
|
|
15
15
|
handleAnalytics(analyticsEvents, { url });
|
|
16
16
|
}, [handleAnalytics]);
|
|
17
17
|
return (React.createElement("div", { className: b({ size }) },
|
|
18
|
-
title && React.createElement(Title, { className: b('header'), title: title, colSizes: { all: 12 } }),
|
|
18
|
+
(title || description) && (React.createElement(Title, { className: b('header'), title: title, subtitle: description, colSizes: { all: 12 } })),
|
|
19
19
|
items.map((item) => {
|
|
20
20
|
const itemContent = getItemContent(item);
|
|
21
21
|
const { url, text } = item;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useTheme } from '../../context/theme';
|
|
3
|
+
import { rootCn } from '../../utils';
|
|
4
|
+
const RootCn = ({ className, children }) => {
|
|
5
|
+
const theme = useTheme();
|
|
6
|
+
return React.createElement("div", { className: rootCn({ theme }, className) }, children);
|
|
7
|
+
};
|
|
8
|
+
export default RootCn;
|
|
@@ -10,7 +10,7 @@ export declare const blockMap: {
|
|
|
10
10
|
"table-block": (props: import("./models").TableBlockProps) => JSX.Element;
|
|
11
11
|
"tabs-block": ({ items, title, description, animated, tabsColSizes, centered, direction, contentSize, }: import("./models").TabsBlockProps) => JSX.Element;
|
|
12
12
|
"header-block": (props: import("./models").WithChildren<import("./models").HeaderBlockProps & import("./models").ClassNameProps>) => JSX.Element;
|
|
13
|
-
"icons-block": ({ title, size, items }: import("./models").IconsBlockProps) => JSX.Element;
|
|
13
|
+
"icons-block": ({ title, description, size, items }: import("./models").IconsBlockProps) => JSX.Element;
|
|
14
14
|
"header-slider-block": ({ items, arrows, ...props }: import("./models").HeaderSliderBlockProps) => JSX.Element;
|
|
15
15
|
"card-layout-block": import("react").FC<import("./blocks/CardLayout/CardLayout").CardLayoutBlockProps>;
|
|
16
16
|
"content-layout-block": (props: import("./models").ContentLayoutBlockProps) => JSX.Element;
|
|
@@ -2,7 +2,7 @@ import { __rest } from "tslib";
|
|
|
2
2
|
import React, { useMemo } from 'react';
|
|
3
3
|
import '@doc-tools/transform/dist/js/yfm';
|
|
4
4
|
import BackgroundMedia from '../../components/BackgroundMedia/BackgroundMedia';
|
|
5
|
-
import
|
|
5
|
+
import RootCn from '../../components/RootCn';
|
|
6
6
|
import { blockMap, navItemMap, subBlockMap } from '../../constructor-items';
|
|
7
7
|
import { AnimateContext } from '../../context/animateContext';
|
|
8
8
|
import { InnerContext } from '../../context/innerContext';
|
|
@@ -10,13 +10,12 @@ import { useTheme } from '../../context/theme';
|
|
|
10
10
|
import { Grid } from '../../grid';
|
|
11
11
|
import { BlockType, BlockTypes, HeaderBlockTypes, NavigationItemTypes, SubBlockTypes, } from '../../models';
|
|
12
12
|
import Layout from '../../navigation/containers/Layout/Layout';
|
|
13
|
-
import {
|
|
13
|
+
import { block as cnBlock, getCustomItems, getCustomTypes, getHeaderBlock, getOrderedBlocks, getThemedValue, } from '../../utils';
|
|
14
14
|
import { ConstructorBlocks } from './components/ConstructorBlocks';
|
|
15
15
|
import { ConstructorHeader } from './components/ConstructorItem';
|
|
16
16
|
import { ConstructorRow } from './components/ConstructorRow';
|
|
17
17
|
import './PageConstructor.css';
|
|
18
18
|
const b = cnBlock('page-constructor');
|
|
19
|
-
const ycr = blockOrigin(UIKIT_ROOT_CLASS);
|
|
20
19
|
export const Constructor = (props) => {
|
|
21
20
|
const { content: { blocks = [], background = {} } = {}, renderMenu, shouldRenderBlock, navigation, custom, } = props;
|
|
22
21
|
const { context } = useMemo(() => ({
|
|
@@ -42,7 +41,7 @@ export const Constructor = (props) => {
|
|
|
42
41
|
const restBlocks = getOrderedBlocks(blocks, context.headerBlockTypes);
|
|
43
42
|
const themedBackground = getThemedValue(background, theme);
|
|
44
43
|
return (React.createElement(InnerContext.Provider, { value: context },
|
|
45
|
-
React.createElement(
|
|
44
|
+
React.createElement(RootCn, null,
|
|
46
45
|
React.createElement("div", { className: b('wrapper') },
|
|
47
46
|
themedBackground && (React.createElement(BackgroundMedia, Object.assign({}, themedBackground, { className: b('background') }))),
|
|
48
47
|
React.createElement(Layout, { navigation: navigation },
|
package/build/esm/index.d.ts
CHANGED
package/build/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { HeaderData, ThemedNavigationLogoData } from '../../../models';
|
|
2
|
+
import { ClassNameProps, HeaderData, ThemedNavigationLogoData } from '../../../models';
|
|
3
3
|
import './Navigation.css';
|
|
4
|
-
export interface NavigationProps {
|
|
4
|
+
export interface NavigationProps extends ClassNameProps {
|
|
5
5
|
logo: ThemedNavigationLogoData;
|
|
6
6
|
data: HeaderData;
|
|
7
7
|
}
|
|
@@ -8,7 +8,7 @@ import DesktopNavigation from '../DesktopNavigation/DesktopNavigation';
|
|
|
8
8
|
import MobileNavigation from '../MobileNavigation/MobileNavigation';
|
|
9
9
|
import './Navigation.css';
|
|
10
10
|
const b = block('navigation');
|
|
11
|
-
export const Navigation = ({ data, logo }) => {
|
|
11
|
+
export const Navigation = ({ data, logo, className }) => {
|
|
12
12
|
const { leftItems, rightItems, iconSize = 20, withBorder = false } = data;
|
|
13
13
|
const [isSidebarOpened, setIsSidebarOpened] = useState(false);
|
|
14
14
|
const [activeItemId, setActiveItemId] = useState(undefined);
|
|
@@ -30,7 +30,7 @@ export const Navigation = ({ data, logo }) => {
|
|
|
30
30
|
window.addEventListener('scroll', scrollHandler, { passive: true });
|
|
31
31
|
return () => window.removeEventListener('scroll', scrollHandler);
|
|
32
32
|
});
|
|
33
|
-
return (React.createElement(Grid, { className: b({ 'with-border': showBorder }) },
|
|
33
|
+
return (React.createElement(Grid, { className: b({ 'with-border': showBorder }, className) },
|
|
34
34
|
React.createElement(Row, null,
|
|
35
35
|
React.createElement(Col, null,
|
|
36
36
|
React.createElement("nav", null,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
3
|
import omit from 'lodash/omit';
|
|
4
4
|
import { BlockIdContext } from '../../../context/blockIdContext';
|
|
5
|
-
import { InnerContext } from '../../../context/innerContext';
|
|
6
5
|
import { NavigationItemType } from '../../../models';
|
|
7
6
|
import { block } from '../../../utils';
|
|
7
|
+
import { useNavigationItemMap } from './hooks/useNavigationItemMap';
|
|
8
8
|
import './NavigationItem.css';
|
|
9
9
|
const b = block('navigation-item');
|
|
10
10
|
const ANALYTICS_ID = 'navigation';
|
|
11
11
|
const NavigationItem = (_a) => {
|
|
12
12
|
var { data, className, menuLayout } = _a, props = __rest(_a, ["data", "className", "menuLayout"]);
|
|
13
13
|
const { type = NavigationItemType.Link } = data;
|
|
14
|
-
const
|
|
14
|
+
const navItemMap = useNavigationItemMap();
|
|
15
15
|
const Component = navItemMap[type];
|
|
16
16
|
const componentProps = useMemo(() => {
|
|
17
17
|
const componentProperties = Object.assign(Object.assign({}, data), props);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const useNavigationItemMap: () => {
|
|
2
|
+
button: import("react").FC<Pick<import("../../../models").NavigationItemProps, "className"> & import("../../../..").ButtonProps>;
|
|
3
|
+
social: import("react").FC<import("../../SocialIcon/SocialIcon").NavigationSocialItemOwnProps>;
|
|
4
|
+
dropdown: ({ text, icon, className, iconSize, hidePopup, items, isActive, ...props }: import("../../../models").NavigationItemProps & import("../../../..").NavigationDropdownItem) => JSX.Element;
|
|
5
|
+
link: import("react").FC<import("../../../models").NavigationItemProps & import("../../../..").NavigationLinkItem>;
|
|
6
|
+
"github-button": ({ text, url, className, label, size, icon, urlTitle, }: import("../../../models").NavigationItemProps & import("../../../..").NavigationGithubButton) => JSX.Element;
|
|
7
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import isEmpty from 'lodash/isEmpty';
|
|
3
|
+
import { navItemMap as NavItemMapDefault } from '../../../../constructor-items';
|
|
4
|
+
import { InnerContext } from '../../../../context/innerContext';
|
|
5
|
+
export const useNavigationItemMap = () => {
|
|
6
|
+
const { navItemMap } = useContext(InnerContext);
|
|
7
|
+
return isEmpty(navItemMap) ? NavItemMapDefault : navItemMap;
|
|
8
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import RootCn from '../../../components/RootCn';
|
|
3
|
+
import Navigation from './../../components/Navigation/Navigation';
|
|
4
|
+
const Standalone = (props) => (React.createElement(RootCn, null,
|
|
5
|
+
React.createElement(Navigation, Object.assign({}, props))));
|
|
6
|
+
export default Standalone;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
.layout {
|
|
1
|
+
.pc-layout {
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
min-height: 100vh;
|
|
5
5
|
}
|
|
6
|
-
.layout__content {
|
|
6
|
+
.pc-layout__content {
|
|
7
7
|
display: flex;
|
|
8
8
|
flex-grow: 1;
|
|
9
9
|
flex-direction: column;
|
|
10
|
+
}
|
|
11
|
+
.pc-layout__navigation {
|
|
12
|
+
position: sticky;
|
|
13
|
+
z-index: 98;
|
|
14
|
+
top: 0;
|
|
10
15
|
}
|
|
@@ -4,6 +4,6 @@ import Navigation from '../../components/Navigation/Navigation';
|
|
|
4
4
|
import './Layout.css';
|
|
5
5
|
const b = block('layout');
|
|
6
6
|
const Layout = ({ children, navigation }) => (React.createElement("div", { className: b() },
|
|
7
|
-
navigation && React.createElement(Navigation, { data: navigation.header, logo: navigation.logo }),
|
|
7
|
+
navigation && (React.createElement(Navigation, { data: navigation.header, logo: navigation.logo, className: b('navigation') })),
|
|
8
8
|
React.createElement("main", { className: b('content') }, children)));
|
|
9
9
|
export default Layout;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Navigation } from './components/Standalone';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Navigation } from './components/Standalone';
|
|
@@ -299,11 +299,5 @@ export const config = {
|
|
|
299
299
|
},
|
|
300
300
|
],
|
|
301
301
|
[BlockType.CardLayoutBlock]: blockHeaderTransformer,
|
|
302
|
-
[BlockType.IconsBlock]:
|
|
303
|
-
{
|
|
304
|
-
fields: ['title'],
|
|
305
|
-
transformer: typografTransformer,
|
|
306
|
-
parser: parseTitle,
|
|
307
|
-
},
|
|
308
|
-
],
|
|
302
|
+
[BlockType.IconsBlock]: blockHeaderTransformer,
|
|
309
303
|
};
|
package/build/esm/utils/cn.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const NAMESPACE = "pc-";
|
|
2
2
|
export declare const cn: import("@bem-react/classname").ClassNameInitilizer;
|
|
3
3
|
export declare const block: import("@bem-react/classname").ClassNameInitilizer;
|
|
4
|
+
export declare const rootCn: import("@bem-react/classname").ClassNameFormatter;
|
|
4
5
|
export type CnBlock = ReturnType<typeof cn>;
|
package/build/esm/utils/cn.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { withNaming } from '@bem-react/classname';
|
|
2
|
+
import { UIKIT_ROOT_CLASS } from '../components/constants';
|
|
2
3
|
export const NAMESPACE = 'pc-';
|
|
3
4
|
export const cn = withNaming({ e: '__', m: '_' });
|
|
4
5
|
export const block = withNaming({ n: NAMESPACE, e: '__', m: '_' });
|
|
6
|
+
export const rootCn = cn(UIKIT_ROOT_CLASS);
|
package/package.json
CHANGED
|
@@ -312,11 +312,5 @@ exports.config = {
|
|
|
312
312
|
},
|
|
313
313
|
],
|
|
314
314
|
[models_1.BlockType.CardLayoutBlock]: exports.blockHeaderTransformer,
|
|
315
|
-
[models_1.BlockType.IconsBlock]:
|
|
316
|
-
{
|
|
317
|
-
fields: ['title'],
|
|
318
|
-
transformer: common_1.typografTransformer,
|
|
319
|
-
parser: parseTitle,
|
|
320
|
-
},
|
|
321
|
-
],
|
|
315
|
+
[models_1.BlockType.IconsBlock]: exports.blockHeaderTransformer,
|
|
322
316
|
};
|
package/server/utils/cn.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const NAMESPACE = "pc-";
|
|
2
2
|
export declare const cn: import("@bem-react/classname").ClassNameInitilizer;
|
|
3
3
|
export declare const block: import("@bem-react/classname").ClassNameInitilizer;
|
|
4
|
+
export declare const rootCn: import("@bem-react/classname").ClassNameFormatter;
|
|
4
5
|
export type CnBlock = ReturnType<typeof cn>;
|