@gravity-ui/page-constructor 4.4.1 → 4.5.1
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/ButtonTabs/ButtonTabs.js +6 -1
- package/build/cjs/components/CardBase/CardBase.css +4 -4
- package/build/cjs/components/ReactPlayer/ReactPlayer.js +4 -2
- package/build/cjs/constructor-items.d.ts +7 -0
- package/build/cjs/constructor-items.js +11 -1
- package/build/cjs/containers/PageConstructor/PageConstructor.d.ts +2 -1
- package/build/cjs/containers/PageConstructor/PageConstructor.js +9 -4
- package/build/cjs/context/innerContext/InnerContext.d.ts +3 -1
- package/build/cjs/context/innerContext/InnerContext.js +2 -0
- package/build/cjs/editor/store/index.js +1 -1
- package/build/cjs/editor/utils/index.d.ts +1 -0
- package/build/cjs/models/constructor-items/common.d.ts +1 -1
- package/build/cjs/models/constructor.d.ts +1 -0
- package/build/cjs/models/navigation.d.ts +1 -0
- package/build/cjs/models/navigation.js +2 -1
- package/build/cjs/navigation/components/MobileMenuButton/MobileMenuButton.js +1 -0
- package/build/cjs/navigation/components/NavigationItem/NavigationItem.js +3 -15
- package/build/cjs/navigation/components/NavigationItem/index.d.ts +6 -0
- package/build/cjs/navigation/components/NavigationItem/index.js +14 -0
- package/build/cjs/navigation/components/NavigationListItem/NavigationListItem.js +1 -1
- package/build/cjs/navigation/components/NavigationPopup/NavigationPopup.js +1 -1
- package/build/cjs/sub-blocks/BackgroundCard/BackgroundCard.js +1 -2
- package/build/cjs/sub-blocks/Quote/Quote.css +0 -3
- package/build/cjs/utils/blocks.d.ts +2 -6
- package/build/cjs/utils/blocks.js +11 -16
- package/build/esm/components/ButtonTabs/ButtonTabs.js +6 -1
- package/build/esm/components/CardBase/CardBase.css +4 -4
- package/build/esm/components/ReactPlayer/ReactPlayer.js +6 -4
- package/build/esm/constructor-items.d.ts +7 -0
- package/build/esm/constructor-items.js +10 -1
- package/build/esm/containers/PageConstructor/PageConstructor.d.ts +2 -1
- package/build/esm/containers/PageConstructor/PageConstructor.js +12 -7
- package/build/esm/context/innerContext/InnerContext.d.ts +3 -1
- package/build/esm/context/innerContext/InnerContext.js +2 -0
- package/build/esm/editor/store/index.js +2 -2
- package/build/esm/editor/utils/index.d.ts +1 -0
- package/build/esm/models/constructor-items/common.d.ts +1 -1
- package/build/esm/models/constructor.d.ts +1 -0
- package/build/esm/models/navigation.d.ts +1 -0
- package/build/esm/models/navigation.js +1 -0
- package/build/esm/navigation/components/MobileMenuButton/MobileMenuButton.js +1 -0
- package/build/esm/navigation/components/NavigationItem/NavigationItem.js +4 -16
- package/build/esm/navigation/components/NavigationItem/index.d.ts +6 -0
- package/build/esm/navigation/components/NavigationItem/index.js +6 -0
- package/build/esm/navigation/components/NavigationListItem/NavigationListItem.js +1 -1
- package/build/esm/navigation/components/NavigationPopup/NavigationPopup.js +1 -1
- package/build/esm/sub-blocks/BackgroundCard/BackgroundCard.js +1 -2
- package/build/esm/sub-blocks/Quote/Quote.css +0 -3
- package/build/esm/utils/blocks.d.ts +2 -6
- package/build/esm/utils/blocks.js +8 -11
- package/package.json +2 -1
- package/server/models/constructor-items/common.d.ts +1 -1
- package/server/models/constructor.d.ts +1 -0
- package/server/models/navigation.d.ts +1 -0
- package/server/models/navigation.js +2 -1
- package/server/utils/blocks.d.ts +2 -6
- package/server/utils/blocks.js +11 -16
- package/styles/mixins.scss +3 -1
- package/widget/index.js +1 -1
|
@@ -6,6 +6,7 @@ export var NavigationItemType;
|
|
|
6
6
|
NavigationItemType["Social"] = "social";
|
|
7
7
|
NavigationItemType["GithubButton"] = "github-button";
|
|
8
8
|
})(NavigationItemType || (NavigationItemType = {}));
|
|
9
|
+
export const NavigationItemTypes = Object.values(NavigationItemType);
|
|
9
10
|
export var NavigationGithubButtonIcon;
|
|
10
11
|
(function (NavigationGithubButtonIcon) {
|
|
11
12
|
NavigationGithubButtonIcon["heart"] = "octicon-heart";
|
|
@@ -7,5 +7,6 @@ const b = block('mobile-menu-button');
|
|
|
7
7
|
const ICON_SIZE = 36;
|
|
8
8
|
export const MobileMenuButton = ({ isSidebarOpened, onSidebarOpenedChange, }) => (React.createElement(Control, { className: b(), onClick: (e) => {
|
|
9
9
|
e.stopPropagation();
|
|
10
|
+
e.nativeEvent.stopImmediatePropagation();
|
|
10
11
|
onSidebarOpenedChange(!isSidebarOpened);
|
|
11
12
|
}, size: "l", icon: isSidebarOpened ? NavigationClose : NavigationOpen, iconSize: ICON_SIZE }));
|
|
@@ -1,30 +1,18 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import React, { useMemo } from 'react';
|
|
2
|
+
import React, { useContext, useMemo } from 'react';
|
|
3
3
|
import { omit } from 'lodash';
|
|
4
4
|
import { BlockIdContext } from '../../../context/blockIdContext';
|
|
5
|
+
import { InnerContext } from '../../../context/innerContext';
|
|
5
6
|
import { NavigationItemType } from '../../../models';
|
|
6
7
|
import { block } from '../../../utils';
|
|
7
|
-
import SocialIcon from '../SocialIcon/SocialIcon';
|
|
8
|
-
import { GithubButton } from './components/GithubButton/GithubButton';
|
|
9
|
-
import { NavigationButton } from './components/NavigationButton/NavigationButton';
|
|
10
|
-
import { NavigationDropdown } from './components/NavigationDropdown/NavigationDropdown';
|
|
11
|
-
import { NavigationLink } from './components/NavigationLink/NavigationLink';
|
|
12
8
|
import './NavigationItem.css';
|
|
13
9
|
const b = block('navigation-item');
|
|
14
10
|
const ANALYTICS_ID = 'navigation';
|
|
15
|
-
//todo: add types support form component in map
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
-
const NavigationItemsMap = {
|
|
18
|
-
[NavigationItemType.Button]: NavigationButton,
|
|
19
|
-
[NavigationItemType.Social]: SocialIcon,
|
|
20
|
-
[NavigationItemType.Dropdown]: NavigationDropdown,
|
|
21
|
-
[NavigationItemType.Link]: NavigationLink,
|
|
22
|
-
[NavigationItemType.GithubButton]: GithubButton,
|
|
23
|
-
};
|
|
24
11
|
const NavigationItem = (_a) => {
|
|
25
12
|
var { data, className, menuLayout } = _a, props = __rest(_a, ["data", "className", "menuLayout"]);
|
|
26
13
|
const { type = NavigationItemType.Link } = data;
|
|
27
|
-
const
|
|
14
|
+
const { navItemMap } = useContext(InnerContext);
|
|
15
|
+
const Component = navItemMap[type];
|
|
28
16
|
const componentProps = useMemo(() => {
|
|
29
17
|
const componentProperties = Object.assign(Object.assign({}, data), props);
|
|
30
18
|
if (type !== NavigationItemType.Dropdown) {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { GithubButton } from './components/GithubButton/GithubButton';
|
|
2
|
+
export { NavigationButton } from './components/NavigationButton/NavigationButton';
|
|
3
|
+
export { NavigationDropdown } from './components/NavigationDropdown/NavigationDropdown';
|
|
4
|
+
export { NavigationLink } from './components/NavigationLink/NavigationLink';
|
|
5
|
+
import NavigationItem from './NavigationItem';
|
|
6
|
+
export default NavigationItem;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { GithubButton } from './components/GithubButton/GithubButton';
|
|
2
|
+
export { NavigationButton } from './components/NavigationButton/NavigationButton';
|
|
3
|
+
export { NavigationDropdown } from './components/NavigationDropdown/NavigationDropdown';
|
|
4
|
+
export { NavigationLink } from './components/NavigationLink/NavigationLink';
|
|
5
|
+
import NavigationItem from './NavigationItem';
|
|
6
|
+
export default NavigationItem;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { getItemClickHandler } from '../../utils';
|
|
4
|
-
import NavigationItem from '../NavigationItem
|
|
4
|
+
import NavigationItem from '../NavigationItem';
|
|
5
5
|
const NavigationListItem = (_a) => {
|
|
6
6
|
var { column, index, activeItemId, onActiveItemChange } = _a, props = __rest(_a, ["column", "index", "activeItemId", "onActiveItemChange"]);
|
|
7
7
|
const id = `${column}-${index}`;
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Popup } from '@gravity-ui/uikit';
|
|
3
3
|
import { block } from '../../../utils';
|
|
4
4
|
import { NavigationLayout } from '../../models';
|
|
5
|
-
import NavigationItem from '../NavigationItem
|
|
5
|
+
import NavigationItem from '../NavigationItem';
|
|
6
6
|
import './NavigationPopup.css';
|
|
7
7
|
const b = block('navigation-popup');
|
|
8
8
|
const OFFSET_RESET = [0, 0];
|
|
@@ -9,9 +9,8 @@ const BackgroundCard = (props) => {
|
|
|
9
9
|
const { url, title, text, border, background, paddingBottom, backgroundColor, additionalInfo, theme: cardTheme = 'default', links, buttons, } = props;
|
|
10
10
|
const theme = useTheme();
|
|
11
11
|
const hasBackgroundColor = backgroundColor || cardTheme !== 'default';
|
|
12
|
-
const link = hasBackgroundColor || border === 'line' ? undefined : url;
|
|
13
12
|
const borderType = hasBackgroundColor ? 'none' : border;
|
|
14
|
-
return (React.createElement(CardBase, { className: b({ padding: paddingBottom, theme: cardTheme }), url:
|
|
13
|
+
return (React.createElement(CardBase, { className: b({ padding: paddingBottom, theme: cardTheme }), url: url, border: borderType },
|
|
15
14
|
React.createElement(CardBase.Content, null,
|
|
16
15
|
React.createElement(BackgroundImage, Object.assign({ className: b('image') }, getThemedValue(background, theme), { style: { backgroundColor } })),
|
|
17
16
|
React.createElement(Content, { title: title, text: text, additionalInfo: additionalInfo, size: "s", theme: cardTheme, links: links, buttons: buttons, colSizes: { all: 12, md: 12 } }))));
|
|
@@ -31,9 +31,6 @@ unpredictable css rules order in build */
|
|
|
31
31
|
.pc-quote_border_line {
|
|
32
32
|
border: 1px solid var(--g-color-line-generic);
|
|
33
33
|
}
|
|
34
|
-
.pc-quote_border_line, .pc-quote_border_none {
|
|
35
|
-
cursor: default;
|
|
36
|
-
}
|
|
37
34
|
@media (min-width: 577px) {
|
|
38
35
|
.slick-slide:not(.slick-active) .pc-quote {
|
|
39
36
|
box-shadow: none;
|
|
@@ -2,12 +2,8 @@ import { ConstructorBlock, CustomConfig, PCShareSocialNetwork, TextSize } from '
|
|
|
2
2
|
export declare function getHeaderTag(size: TextSize): "h1" | "h2" | "h3" | "h4";
|
|
3
3
|
export declare function hasBlockTag(content: string): boolean;
|
|
4
4
|
export declare function getBlockKey(block: ConstructorBlock, index: number): string;
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
[x: string]: any;
|
|
8
|
-
};
|
|
9
|
-
export declare const getCustomSubBlockTypes: (customBlocks?: CustomConfig) => string[];
|
|
10
|
-
export declare const getCustomHeaderTypes: (customBlocks?: CustomConfig) => string[];
|
|
5
|
+
export declare const getCustomItems: (types: (keyof CustomConfig)[], customBlocks?: CustomConfig) => {};
|
|
6
|
+
export declare const getCustomTypes: (types: (keyof CustomConfig)[], customBlocks?: CustomConfig) => string[];
|
|
11
7
|
export declare const getOrderedBlocks: (blocks: ConstructorBlock[], headerBlockTypes?: string[]) => ConstructorBlock[];
|
|
12
8
|
export declare const getHeaderBlock: (blocks: ConstructorBlock[], headerBlockTypes?: string[]) => ConstructorBlock | undefined;
|
|
13
9
|
export declare const getShareLink: (url: string, type: PCShareSocialNetwork, title?: string, text?: string) => string | undefined;
|
|
@@ -56,18 +56,15 @@ export function hasBlockTag(content) {
|
|
|
56
56
|
export function getBlockKey(block, index) {
|
|
57
57
|
return `${block.type}-${index}`;
|
|
58
58
|
}
|
|
59
|
-
export const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
export const getCustomItems = ({ blocks = {}, headers = {}, subBlocks = {} } = {}) => (Object.assign(Object.assign(Object.assign({}, blocks), headers), subBlocks));
|
|
64
|
-
export const getCustomSubBlockTypes = (customBlocks = {}) => {
|
|
65
|
-
const { subBlocks = {} } = customBlocks;
|
|
66
|
-
return Object.keys(subBlocks);
|
|
59
|
+
export const getCustomItems = (types, customBlocks = {}) => {
|
|
60
|
+
return types.reduce((result, type) => {
|
|
61
|
+
return Object.assign(result, customBlocks[type] || {});
|
|
62
|
+
}, {});
|
|
67
63
|
};
|
|
68
|
-
export const
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
export const getCustomTypes = (types, customBlocks = {}) => {
|
|
65
|
+
return types.reduce((result, type) => {
|
|
66
|
+
return result.concat(Object.keys(customBlocks[type] || {}));
|
|
67
|
+
}, []);
|
|
71
68
|
};
|
|
72
69
|
const getShareUrlWithParams = (url, params = {}) => {
|
|
73
70
|
const result = new URL(url);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/page-constructor",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.1",
|
|
4
4
|
"description": "Gravity UI Page Constructor",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -99,6 +99,7 @@
|
|
|
99
99
|
"sanitize-html": "2.6.1",
|
|
100
100
|
"snakecase-keys": "^5.1.0",
|
|
101
101
|
"typograf": "^6.14.0",
|
|
102
|
+
"utility-types": "^3.10.0",
|
|
102
103
|
"uuid": "^9.0.0"
|
|
103
104
|
},
|
|
104
105
|
"peerDependencies": {
|
|
@@ -132,7 +132,7 @@ export interface FileLinkProps extends ClassNameProps, Tabbable {
|
|
|
132
132
|
onClick?: () => void;
|
|
133
133
|
}
|
|
134
134
|
export type ButtonTheme = ButtonView | 'github' | 'app-store' | 'google-play' | 'scale' | 'monochrome';
|
|
135
|
-
export interface ButtonProps extends AnalyticsEventsBase, Pick<UikitButtonProps, 'size' | 'width'> {
|
|
135
|
+
export interface ButtonProps extends AnalyticsEventsBase, Pick<UikitButtonProps, 'size' | 'width' | 'extraProps'> {
|
|
136
136
|
text: string;
|
|
137
137
|
url: string;
|
|
138
138
|
primary?: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NavigationGithubButtonIcon = exports.NavigationItemType = void 0;
|
|
3
|
+
exports.NavigationGithubButtonIcon = exports.NavigationItemTypes = exports.NavigationItemType = void 0;
|
|
4
4
|
var NavigationItemType;
|
|
5
5
|
(function (NavigationItemType) {
|
|
6
6
|
NavigationItemType["Link"] = "link";
|
|
@@ -9,6 +9,7 @@ var NavigationItemType;
|
|
|
9
9
|
NavigationItemType["Social"] = "social";
|
|
10
10
|
NavigationItemType["GithubButton"] = "github-button";
|
|
11
11
|
})(NavigationItemType = exports.NavigationItemType || (exports.NavigationItemType = {}));
|
|
12
|
+
exports.NavigationItemTypes = Object.values(NavigationItemType);
|
|
12
13
|
var NavigationGithubButtonIcon;
|
|
13
14
|
(function (NavigationGithubButtonIcon) {
|
|
14
15
|
NavigationGithubButtonIcon["heart"] = "octicon-heart";
|
package/server/utils/blocks.d.ts
CHANGED
|
@@ -2,12 +2,8 @@ import { ConstructorBlock, CustomConfig, PCShareSocialNetwork, TextSize } from '
|
|
|
2
2
|
export declare function getHeaderTag(size: TextSize): "h1" | "h2" | "h3" | "h4";
|
|
3
3
|
export declare function hasBlockTag(content: string): boolean;
|
|
4
4
|
export declare function getBlockKey(block: ConstructorBlock, index: number): string;
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
[x: string]: any;
|
|
8
|
-
};
|
|
9
|
-
export declare const getCustomSubBlockTypes: (customBlocks?: CustomConfig) => string[];
|
|
10
|
-
export declare const getCustomHeaderTypes: (customBlocks?: CustomConfig) => string[];
|
|
5
|
+
export declare const getCustomItems: (types: (keyof CustomConfig)[], customBlocks?: CustomConfig) => {};
|
|
6
|
+
export declare const getCustomTypes: (types: (keyof CustomConfig)[], customBlocks?: CustomConfig) => string[];
|
|
11
7
|
export declare const getOrderedBlocks: (blocks: ConstructorBlock[], headerBlockTypes?: string[]) => ConstructorBlock[];
|
|
12
8
|
export declare const getHeaderBlock: (blocks: ConstructorBlock[], headerBlockTypes?: string[]) => ConstructorBlock | undefined;
|
|
13
9
|
export declare const getShareLink: (url: string, type: PCShareSocialNetwork, title?: string, text?: string) => string | undefined;
|
package/server/utils/blocks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getShareLink = exports.getHeaderBlock = exports.getOrderedBlocks = exports.
|
|
3
|
+
exports.getShareLink = exports.getHeaderBlock = exports.getOrderedBlocks = exports.getCustomTypes = exports.getCustomItems = exports.getBlockKey = exports.hasBlockTag = exports.getHeaderTag = void 0;
|
|
4
4
|
const models_1 = require("../models");
|
|
5
5
|
const BLOCK_ELEMENTS = [
|
|
6
6
|
'div',
|
|
@@ -62,23 +62,18 @@ function getBlockKey(block, index) {
|
|
|
62
62
|
return `${block.type}-${index}`;
|
|
63
63
|
}
|
|
64
64
|
exports.getBlockKey = getBlockKey;
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
exports.getCustomBlockTypes = getCustomBlockTypes;
|
|
70
|
-
const getCustomItems = ({ blocks = {}, headers = {}, subBlocks = {} } = {}) => (Object.assign(Object.assign(Object.assign({}, blocks), headers), subBlocks));
|
|
71
|
-
exports.getCustomItems = getCustomItems;
|
|
72
|
-
const getCustomSubBlockTypes = (customBlocks = {}) => {
|
|
73
|
-
const { subBlocks = {} } = customBlocks;
|
|
74
|
-
return Object.keys(subBlocks);
|
|
65
|
+
const getCustomItems = (types, customBlocks = {}) => {
|
|
66
|
+
return types.reduce((result, type) => {
|
|
67
|
+
return Object.assign(result, customBlocks[type] || {});
|
|
68
|
+
}, {});
|
|
75
69
|
};
|
|
76
|
-
exports.
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
exports.getCustomItems = getCustomItems;
|
|
71
|
+
const getCustomTypes = (types, customBlocks = {}) => {
|
|
72
|
+
return types.reduce((result, type) => {
|
|
73
|
+
return result.concat(Object.keys(customBlocks[type] || {}));
|
|
74
|
+
}, []);
|
|
80
75
|
};
|
|
81
|
-
exports.
|
|
76
|
+
exports.getCustomTypes = getCustomTypes;
|
|
82
77
|
const getShareUrlWithParams = (url, params = {}) => {
|
|
83
78
|
const result = new URL(url);
|
|
84
79
|
Object.entries(params).forEach(([name, value]) => {
|