@gravity-ui/page-constructor 2.22.0-alpha → 2.22.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/CHANGELOG.md +60 -0
- package/build/cjs/components/Anchor/Anchor.d.ts +2 -2
- package/build/cjs/components/Anchor/Anchor.js +1 -1
- package/build/cjs/components/BackgroundImage/BackgroundImage.js +2 -2
- package/build/cjs/components/BlockBase/BlockBase.d.ts +3 -2
- package/build/cjs/components/BlockBase/BlockBase.js +4 -2
- package/build/cjs/components/Button/Button.css +3 -0
- package/build/cjs/components/Button/Button.js +5 -4
- package/build/cjs/components/FullscreenMedia/FullscreenMedia.js +3 -1
- package/build/cjs/components/Image/Image.d.ts +1 -0
- package/build/cjs/components/Image/Image.js +2 -2
- package/build/cjs/components/Media/Image/Image.js +3 -3
- package/build/cjs/components/Media/Media.js +5 -3
- package/build/cjs/containers/Loadable/Loadable.d.ts +2 -2
- package/build/cjs/containers/PageConstructor/PageConstructor.js +5 -3
- package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +3 -2
- package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts +1 -1
- package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.js +5 -5
- package/build/cjs/context/innerContext/InnerContext.d.ts +2 -1
- package/build/cjs/customization/BlockDecoration.d.ts +3 -0
- package/build/cjs/customization/BlockDecoration.js +22 -0
- package/build/cjs/editor/Components/AddBlock/AddBlock.css +82 -0
- package/build/cjs/editor/Components/AddBlock/AddBlock.d.ts +7 -0
- package/build/cjs/editor/Components/AddBlock/AddBlock.js +43 -0
- package/build/cjs/editor/Components/EditBlock/EditBlock.css +47 -0
- package/build/cjs/editor/Components/EditBlock/EditBlock.d.ts +4 -0
- package/build/cjs/editor/Components/EditBlock/EditBlock.js +32 -0
- package/build/cjs/editor/Containers/Editor.d.ts +2 -0
- package/build/cjs/editor/Containers/Editor.js +24 -0
- package/build/cjs/editor/data/index.d.ts +13 -0
- package/build/cjs/editor/data/index.js +27 -0
- package/build/cjs/editor/data/previews/default-preview.d.ts +3 -0
- package/build/cjs/editor/data/previews/default-preview.js +18 -0
- package/build/cjs/editor/data/previews/header-block.d.ts +3 -0
- package/build/cjs/editor/data/previews/header-block.js +19 -0
- package/build/cjs/editor/index.d.ts +2 -0
- package/build/cjs/editor/index.js +7 -0
- package/build/cjs/editor/store/index.d.ts +15 -0
- package/build/cjs/editor/store/index.js +32 -0
- package/build/cjs/editor/store/reducer.d.ts +41 -0
- package/build/cjs/editor/store/reducer.js +59 -0
- package/build/cjs/editor/store/utils.d.ts +13 -0
- package/build/cjs/editor/store/utils.js +34 -0
- package/build/cjs/editor/styles/mixins.css +0 -0
- package/build/cjs/editor/styles/variables.css +0 -0
- package/build/cjs/editor/types/index.d.ts +17 -0
- package/build/cjs/editor/types/index.js +2 -0
- package/build/cjs/editor/utils/index.d.ts +11 -0
- package/build/cjs/editor/utils/index.js +12 -0
- package/build/cjs/grid/Col/Col.d.ts +1 -1
- package/build/cjs/hooks/useMetrika.js +0 -7
- package/build/cjs/internal-typings/global.d.ts +18 -16
- package/build/cjs/models/constructor-items/blocks.d.ts +1 -11
- package/build/cjs/models/constructor-items/blocks.js +0 -2
- package/build/cjs/models/constructor-items/common.d.ts +3 -3
- package/build/cjs/models/constructor.d.ts +4 -1
- package/build/cjs/models/customization.d.ts +9 -0
- package/build/cjs/models/customization.js +2 -0
- package/build/cjs/models/index.d.ts +1 -0
- package/build/cjs/models/index.js +1 -0
- package/build/cjs/sub-blocks/HubspotForm/HubspotFormContainer.d.ts +2 -1
- package/build/cjs/sub-blocks/HubspotForm/HubspotFormContainer.js +5 -2
- package/build/cjs/sub-blocks/HubspotForm/index.d.ts +1 -1
- package/build/cjs/sub-blocks/HubspotForm/index.js +6 -5
- package/build/cjs/utils/blocks.d.ts +4 -1
- package/build/cjs/utils/blocks.js +11 -1
- package/build/esm/components/Anchor/Anchor.d.ts +2 -2
- package/build/esm/components/Anchor/Anchor.js +1 -1
- package/build/esm/components/BackgroundImage/BackgroundImage.js +2 -2
- package/build/esm/components/BlockBase/BlockBase.d.ts +3 -2
- package/build/esm/components/BlockBase/BlockBase.js +4 -2
- package/build/esm/components/Button/Button.css +3 -0
- package/build/esm/components/Button/Button.js +5 -4
- package/build/esm/components/FullscreenMedia/FullscreenMedia.js +3 -1
- package/build/esm/components/Image/Image.d.ts +1 -0
- package/build/esm/components/Image/Image.js +2 -2
- package/build/esm/components/Media/Image/Image.js +3 -3
- package/build/esm/components/Media/Media.js +5 -3
- package/build/esm/containers/Loadable/Loadable.d.ts +2 -2
- package/build/esm/containers/PageConstructor/PageConstructor.js +6 -4
- package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +3 -2
- package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts +1 -1
- package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.js +5 -5
- package/build/esm/context/innerContext/InnerContext.d.ts +2 -1
- package/build/esm/customization/BlockDecoration.d.ts +3 -0
- package/build/esm/customization/BlockDecoration.js +17 -0
- package/build/esm/editor/Components/AddBlock/AddBlock.css +82 -0
- package/build/esm/editor/Components/AddBlock/AddBlock.d.ts +8 -0
- package/build/esm/editor/Components/AddBlock/AddBlock.js +41 -0
- package/build/esm/editor/Components/EditBlock/EditBlock.css +47 -0
- package/build/esm/editor/Components/EditBlock/EditBlock.d.ts +5 -0
- package/build/esm/editor/Components/EditBlock/EditBlock.js +30 -0
- package/build/esm/editor/Containers/Editor.d.ts +2 -0
- package/build/esm/editor/Containers/Editor.js +20 -0
- package/build/esm/editor/data/index.d.ts +13 -0
- package/build/esm/editor/data/index.js +24 -0
- package/build/esm/editor/data/previews/default-preview.d.ts +3 -0
- package/build/esm/editor/data/previews/default-preview.js +15 -0
- package/build/esm/editor/data/previews/header-block.d.ts +3 -0
- package/build/esm/editor/data/previews/header-block.js +16 -0
- package/build/esm/editor/index.d.ts +2 -0
- package/build/esm/editor/index.js +2 -0
- package/build/esm/editor/store/index.d.ts +15 -0
- package/build/esm/editor/store/index.js +28 -0
- package/build/esm/editor/store/reducer.d.ts +41 -0
- package/build/esm/editor/store/reducer.js +55 -0
- package/build/esm/editor/store/utils.d.ts +13 -0
- package/build/esm/editor/store/utils.js +26 -0
- package/build/esm/editor/styles/mixins.css +0 -0
- package/build/esm/editor/styles/variables.css +0 -0
- package/build/esm/editor/types/index.d.ts +17 -0
- package/build/esm/editor/utils/index.d.ts +11 -0
- package/build/esm/editor/utils/index.js +6 -0
- package/build/esm/grid/Col/Col.d.ts +1 -1
- package/build/esm/hooks/useMetrika.js +0 -7
- package/build/esm/internal-typings/global.d.ts +18 -16
- package/build/esm/models/constructor-items/blocks.d.ts +1 -11
- package/build/esm/models/constructor-items/blocks.js +0 -2
- package/build/esm/models/constructor-items/common.d.ts +3 -3
- package/build/esm/models/constructor.d.ts +4 -1
- package/build/esm/models/customization.d.ts +9 -0
- package/build/esm/models/index.d.ts +1 -0
- package/build/esm/models/index.js +1 -0
- package/build/esm/sub-blocks/HubspotForm/HubspotFormContainer.d.ts +2 -1
- package/build/esm/sub-blocks/HubspotForm/HubspotFormContainer.js +6 -3
- package/build/esm/sub-blocks/HubspotForm/index.d.ts +1 -1
- package/build/esm/sub-blocks/HubspotForm/index.js +7 -6
- package/build/esm/utils/blocks.d.ts +4 -1
- package/build/esm/utils/blocks.js +7 -0
- package/package.json +4 -6
- package/server/models/constructor-items/blocks.d.ts +1 -11
- package/server/models/constructor-items/blocks.js +0 -2
- package/server/models/constructor-items/common.d.ts +3 -3
- package/server/models/constructor.d.ts +4 -1
- package/server/models/customization.d.ts +9 -0
- package/server/models/customization.js +2 -0
- package/server/models/index.d.ts +1 -0
- package/server/models/index.js +1 -0
- package/server/utils/blocks.d.ts +4 -1
- package/server/utils/blocks.js +11 -1
- package/build/cjs/components/Anchor/__tests__/Anchor.test.js +0 -21
- package/build/cjs/components/AnimateBlock/__tests__/AnimateBlock.test.js +0 -36
- package/build/cjs/components/Author/__tests__/Author.test.d.ts +0 -1
- package/build/cjs/components/Author/__tests__/Author.test.js +0 -49
- package/build/cjs/components/BackLink/__tests__/BackLink.test.d.ts +0 -1
- package/build/cjs/components/BackLink/__tests__/BackLink.test.js +0 -63
- package/build/cjs/components/BlockBase/__tests__/BlockBase.test.d.ts +0 -1
- package/build/cjs/components/BlockBase/__tests__/BlockBase.test.js +0 -44
- package/build/cjs/components/Button/__tests__/Button.test.d.ts +0 -1
- package/build/cjs/components/Button/__tests__/Button.test.js +0 -91
- package/build/cjs/components/ButtonTabs/__tests__/ButtonTabs.test.d.ts +0 -1
- package/build/cjs/components/ButtonTabs/__tests__/ButtonTabs.test.js +0 -58
- package/build/esm/components/Anchor/__tests__/Anchor.test.d.ts +0 -1
- package/build/esm/components/Anchor/__tests__/Anchor.test.js +0 -18
- package/build/esm/components/AnimateBlock/__tests__/AnimateBlock.test.d.ts +0 -1
- package/build/esm/components/AnimateBlock/__tests__/AnimateBlock.test.js +0 -33
- package/build/esm/components/Author/__tests__/Author.test.d.ts +0 -1
- package/build/esm/components/Author/__tests__/Author.test.js +0 -46
- package/build/esm/components/BackLink/__tests__/BackLink.test.d.ts +0 -1
- package/build/esm/components/BackLink/__tests__/BackLink.test.js +0 -60
- package/build/esm/components/BlockBase/__tests__/BlockBase.test.d.ts +0 -1
- package/build/esm/components/BlockBase/__tests__/BlockBase.test.js +0 -41
- package/build/esm/components/Button/__tests__/Button.test.d.ts +0 -1
- package/build/esm/components/Button/__tests__/Button.test.js +0 -88
- package/build/esm/components/ButtonTabs/__tests__/ButtonTabs.test.d.ts +0 -1
- package/build/esm/components/ButtonTabs/__tests__/ButtonTabs.test.js +0 -55
- /package/build/{cjs/components/Anchor/__tests__/Anchor.test.d.ts → esm/editor/types/index.js} +0 -0
- /package/build/{cjs/components/AnimateBlock/__tests__/AnimateBlock.test.d.ts → esm/models/customization.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { HubspotFormProps } from '../../models';
|
|
3
|
-
declare const HubspotForm: React.
|
|
3
|
+
declare const HubspotForm: React.ForwardRefExoticComponent<HubspotFormProps & React.RefAttributes<HTMLDivElement>>;
|
|
4
4
|
export default HubspotForm;
|
|
@@ -10,7 +10,7 @@ const models_1 = require("../../models");
|
|
|
10
10
|
const utils_1 = require("../../utils");
|
|
11
11
|
const HubspotFormContainer_1 = tslib_1.__importDefault(require("./HubspotFormContainer"));
|
|
12
12
|
const b = (0, utils_1.block)('hubspot-form');
|
|
13
|
-
const HubspotForm = (props) => {
|
|
13
|
+
const HubspotForm = (0, react_1.forwardRef)((props, ref) => {
|
|
14
14
|
const { className, theme: themeProp, isMobile: isMobileProp, formId, formInstanceId, portalId, region, formClassName, pixelEvents,
|
|
15
15
|
// hubspotEvents, // TODO: decide how to handle them
|
|
16
16
|
analyticsEvents, onBeforeSubmit, onSubmit, onBeforeLoad, onLoad, createDOMElement, onSubmitError, } = props;
|
|
@@ -25,10 +25,10 @@ const HubspotForm = (props) => {
|
|
|
25
25
|
onBeforeSubmit,
|
|
26
26
|
onLoad,
|
|
27
27
|
onSubmitError,
|
|
28
|
-
onSubmit: (
|
|
28
|
+
onSubmit: (event) => {
|
|
29
29
|
handleMetrika === null || handleMetrika === void 0 ? void 0 : handleMetrika({ pixelEvents });
|
|
30
30
|
handleAnalytics(analyticsEvents);
|
|
31
|
-
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(
|
|
31
|
+
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(event);
|
|
32
32
|
},
|
|
33
33
|
}), [
|
|
34
34
|
onBeforeLoad,
|
|
@@ -42,6 +42,7 @@ const HubspotForm = (props) => {
|
|
|
42
42
|
onSubmitError,
|
|
43
43
|
]);
|
|
44
44
|
(0, hooks_1.useHandleHubspotEvents)(handlers, formId);
|
|
45
|
-
return (react_1.default.createElement(HubspotFormContainer_1.default, { createDOMElement: createDOMElement, key: [formClassName, formId, formInstanceId, portalId, region].join(), className: b({ theme, mobile }, className), formClassName: formClassName, formId: formId, portalId: portalId, formInstanceId: formInstanceId, region: region }));
|
|
46
|
-
};
|
|
45
|
+
return (react_1.default.createElement(HubspotFormContainer_1.default, { createDOMElement: createDOMElement, key: [formClassName, formId, formInstanceId, portalId, region].join(), className: b({ theme, mobile }, className), formClassName: formClassName, formId: formId, portalId: portalId, formInstanceId: formInstanceId, region: region, ref: ref }));
|
|
46
|
+
});
|
|
47
|
+
HubspotForm.displayName = 'HubspotForm';
|
|
47
48
|
exports.default = HubspotForm;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CustomConfig, PCShareSocialNetwork, TextSize } from '../models';
|
|
1
|
+
import { Block, CustomConfig, PCShareSocialNetwork, TextSize } from '../models';
|
|
2
2
|
import { ConstructorBlock } from '../models/constructor';
|
|
3
3
|
export declare function getHeaderTag(size: TextSize): "h1" | "h2" | "h4" | "h5";
|
|
4
4
|
export declare function getBlockKey(block: ConstructorBlock, index: number): string;
|
|
@@ -8,4 +8,7 @@ export declare const getCustomItems: ({ blocks, headers, subBlocks }?: CustomCon
|
|
|
8
8
|
};
|
|
9
9
|
export declare const getCustomSubBlockTypes: (customBlocks?: CustomConfig) => string[];
|
|
10
10
|
export declare const getCustomHeaderTypes: (customBlocks?: CustomConfig) => string[];
|
|
11
|
+
export declare const getOrderedBlocks: (blocks: Block[], headerBlockTypes?: string[]) => Block[];
|
|
12
|
+
export declare const getHeaderBlock: (blocks: Block[], headerBlockTypes?: string[]) => Block | undefined;
|
|
11
13
|
export declare const getShareLink: (url: string, type: PCShareSocialNetwork, title?: string, text?: string) => string | undefined;
|
|
14
|
+
export declare const getBlockIndexFromId: (blockId?: string) => number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getShareLink = exports.getCustomHeaderTypes = exports.getCustomSubBlockTypes = exports.getCustomItems = exports.getCustomBlockTypes = exports.getBlockKey = exports.getHeaderTag = void 0;
|
|
3
|
+
exports.getBlockIndexFromId = exports.getShareLink = exports.getHeaderBlock = exports.getOrderedBlocks = exports.getCustomHeaderTypes = exports.getCustomSubBlockTypes = exports.getCustomItems = exports.getCustomBlockTypes = exports.getBlockKey = exports.getHeaderTag = void 0;
|
|
4
4
|
const models_1 = require("../models");
|
|
5
5
|
function getHeaderTag(size) {
|
|
6
6
|
switch (size) {
|
|
@@ -46,6 +46,14 @@ const getShareUrlWithParams = (url, params = {}) => {
|
|
|
46
46
|
});
|
|
47
47
|
return result.toString();
|
|
48
48
|
};
|
|
49
|
+
const getOrderedBlocks = (blocks, headerBlockTypes = []) => {
|
|
50
|
+
return blocks.filter(({ type }) => !headerBlockTypes.includes(type));
|
|
51
|
+
};
|
|
52
|
+
exports.getOrderedBlocks = getOrderedBlocks;
|
|
53
|
+
const getHeaderBlock = (blocks, headerBlockTypes = []) => {
|
|
54
|
+
return blocks.find(({ type }) => headerBlockTypes.includes(type));
|
|
55
|
+
};
|
|
56
|
+
exports.getHeaderBlock = getHeaderBlock;
|
|
49
57
|
const getShareLink = (url, type, title, text) => {
|
|
50
58
|
// https://github.com/bradvin/social-share-urls
|
|
51
59
|
switch (type) {
|
|
@@ -75,3 +83,5 @@ const getShareLink = (url, type, title, text) => {
|
|
|
75
83
|
}
|
|
76
84
|
};
|
|
77
85
|
exports.getShareLink = getShareLink;
|
|
86
|
+
const getBlockIndexFromId = (blockId) => { var _a; return Number((_a = blockId === null || blockId === void 0 ? void 0 : blockId.split('-')) === null || _a === void 0 ? void 0 : _a.slice(-1).pop()); };
|
|
87
|
+
exports.getBlockIndexFromId = getBlockIndexFromId;
|
|
@@ -3,7 +3,7 @@ import './Anchor.css';
|
|
|
3
3
|
export declare const qaIdByDefault = "qa-anchor";
|
|
4
4
|
export interface AnchorProps extends ClassNameProps {
|
|
5
5
|
id: string;
|
|
6
|
-
|
|
6
|
+
qa?: string;
|
|
7
7
|
}
|
|
8
|
-
declare const Anchor: ({ id, className,
|
|
8
|
+
declare const Anchor: ({ id, className, qa }: AnchorProps) => JSX.Element;
|
|
9
9
|
export default Anchor;
|
|
@@ -4,5 +4,5 @@ import { block } from '../../utils';
|
|
|
4
4
|
import './Anchor.css';
|
|
5
5
|
const b = block('Anchor');
|
|
6
6
|
export const qaIdByDefault = 'qa-anchor';
|
|
7
|
-
const Anchor = ({ id, className,
|
|
7
|
+
const Anchor = ({ id, className, qa }) => (React.createElement("div", { id: id, className: b(null, className), "data-qa": qa || qaIdByDefault }));
|
|
8
8
|
export default Anchor;
|
|
@@ -4,8 +4,8 @@ import Image from '../Image/Image';
|
|
|
4
4
|
import './BackgroundImage.css';
|
|
5
5
|
const b = block('storage-background-image');
|
|
6
6
|
const BackgroundImage = (props) => {
|
|
7
|
-
const { children, src, desktop, className, imageClassName, style, hide } = props;
|
|
8
|
-
return (React.createElement("div", { className: b(null, className), style: style },
|
|
7
|
+
const { children, src, desktop, className, imageClassName, style, hide, qa } = props;
|
|
8
|
+
return (React.createElement("div", { className: b(null, className), style: style, "data-qa": qa },
|
|
9
9
|
(src || desktop) && !hide && React.createElement(Image, Object.assign({}, props, { className: b('img', imageClassName) })),
|
|
10
10
|
children && React.createElement("div", { className: b('container') }, children)));
|
|
11
11
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { BlockBaseProps, ClassNameProps } from '../../models';
|
|
2
3
|
import './BlockBase.css';
|
|
3
|
-
declare const BlockBase: (props:
|
|
4
|
+
declare const BlockBase: (props: PropsWithChildren<BlockBaseProps & ClassNameProps>) => JSX.Element;
|
|
4
5
|
export default BlockBase;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { BlockDecoration } from '../../customization/BlockDecoration';
|
|
2
3
|
import { Col } from '../../grid';
|
|
3
4
|
import { block } from '../../utils';
|
|
4
5
|
import Anchor from '../Anchor/Anchor';
|
|
@@ -7,7 +8,8 @@ const b = block('block-base');
|
|
|
7
8
|
const BlockBase = (props) => {
|
|
8
9
|
const { anchor, visible, children, className, resetPaddings, qa } = props;
|
|
9
10
|
return (React.createElement(Col, { className: b({ ['reset-paddings']: resetPaddings }, className), visible: visible, reset: true, dataQa: qa },
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
React.createElement(BlockDecoration, null,
|
|
12
|
+
anchor && React.createElement(Anchor, { id: anchor.url, className: b('anchor') }),
|
|
13
|
+
children)));
|
|
12
14
|
};
|
|
13
15
|
export default BlockBase;
|
|
@@ -14,7 +14,7 @@ const b = block('button-block');
|
|
|
14
14
|
const Button = (props) => {
|
|
15
15
|
const handleMetrika = useMetrika();
|
|
16
16
|
const { lang, tld } = useContext(LocaleContext);
|
|
17
|
-
const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text } = props, rest = __rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text"]);
|
|
17
|
+
const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text, width } = props, rest = __rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text", "width"]);
|
|
18
18
|
const defaultImgPosition = 'left';
|
|
19
19
|
const handleAnalytics = useAnalytics(DefaultEventNames.Button, url);
|
|
20
20
|
const onClick = useCallback((e) => {
|
|
@@ -24,12 +24,13 @@ const Button = (props) => {
|
|
|
24
24
|
onClickOrigin(e);
|
|
25
25
|
}
|
|
26
26
|
}, [handleMetrika, metrikaGoals, pixelEvents, handleAnalytics, analyticsEvents, onClickOrigin]);
|
|
27
|
+
const buttonModifiers = { size, theme, width };
|
|
27
28
|
const buttonImg = img instanceof Object
|
|
28
29
|
? { url: img.url, position: img.position || defaultImgPosition, alt: img.alt }
|
|
29
30
|
: { url: img, position: defaultImgPosition };
|
|
30
31
|
const buttonClass = img
|
|
31
|
-
? b({ position: buttonImg.position
|
|
32
|
-
: b({
|
|
32
|
+
? b(Object.assign({ position: buttonImg.position }, buttonModifiers), className)
|
|
33
|
+
: b(Object.assign({}, buttonModifiers), className);
|
|
33
34
|
const buttonProps = Object.assign(Object.assign({}, rest), { onClick });
|
|
34
35
|
if (theme === 'app-store' || theme === 'google-play') {
|
|
35
36
|
const platform = theme === 'app-store' ? Platform.IOS : Platform.ANDROID;
|
|
@@ -42,7 +43,7 @@ const Button = (props) => {
|
|
|
42
43
|
image = undefined;
|
|
43
44
|
}
|
|
44
45
|
const buttonTheme = theme === 'scale' ? 'accent' : theme;
|
|
45
|
-
return (React.createElement(CommonButton, Object.assign({ className: buttonClass, view: toCommonView(buttonTheme), size: toCommonSize(size), href: url ? setUrlTld(url, tld) : undefined }, buttonProps),
|
|
46
|
+
return (React.createElement(CommonButton, Object.assign({ className: buttonClass, view: toCommonView(buttonTheme), size: toCommonSize(size), href: url ? setUrlTld(url, tld) : undefined, width: width }, buttonProps),
|
|
46
47
|
icon && buttonImg.position === 'left' ? icon : null,
|
|
47
48
|
React.createElement("span", { className: b('content') },
|
|
48
49
|
image && buttonImg.position === 'left' ? image : null,
|
|
@@ -8,6 +8,8 @@ const b = block('full-screen-media');
|
|
|
8
8
|
const FULL_SCREEN_ICON_SIZE = 18;
|
|
9
9
|
const CLOSE_ICON_SIZE = 30;
|
|
10
10
|
const getMediaClass = (type) => b('modal-media', { type });
|
|
11
|
+
// TODO delete along with showFullScreenIcon props
|
|
12
|
+
const getShowFullscreenIcon = ({ showFullScreenIcon = true, showFullscreenIcon = true }) => showFullScreenIcon && showFullscreenIcon;
|
|
11
13
|
const FullscreenMedia = ({ children, showFullScreenIcon = true, showFullscreenIcon = true, }) => {
|
|
12
14
|
const [isOpened, setIsOpened] = useState(false);
|
|
13
15
|
const isMobile = useContext(MobileContext);
|
|
@@ -22,7 +24,7 @@ const FullscreenMedia = ({ children, showFullScreenIcon = true, showFullscreenIc
|
|
|
22
24
|
return (React.createElement("div", { className: b() },
|
|
23
25
|
React.createElement("div", { className: b('media-wrapper'), onClickCapture: openModal },
|
|
24
26
|
children({ className: b('inline-media') }),
|
|
25
|
-
showFullScreenIcon
|
|
27
|
+
getShowFullscreenIcon({ showFullScreenIcon, showFullscreenIcon }) && (React.createElement("div", { className: b('icon-wrapper'), onClickCapture: openModal },
|
|
26
28
|
React.createElement(Icon, { data: FullScreen, width: FULL_SCREEN_ICON_SIZE, height: FULL_SCREEN_ICON_SIZE, className: b('icon') })))),
|
|
27
29
|
isOpened && (React.createElement(Modal, { open: isOpened, onClose: closeModal, className: b('modal') },
|
|
28
30
|
React.createElement("div", { className: b('modal-content') },
|
|
@@ -5,6 +5,7 @@ export interface ImageProps extends Partial<ImageObjectProps>, Partial<ImageDevi
|
|
|
5
5
|
className?: string;
|
|
6
6
|
onClick?: MouseEventHandler;
|
|
7
7
|
containerClassName?: string;
|
|
8
|
+
qa?: string;
|
|
8
9
|
}
|
|
9
10
|
declare const Image: (props: ImageProps) => JSX.Element | null;
|
|
10
11
|
export default Image;
|
|
@@ -9,7 +9,7 @@ const checkWebP = (src) => {
|
|
|
9
9
|
};
|
|
10
10
|
const Image = (props) => {
|
|
11
11
|
const projectSettings = useContext(ProjectSettingsContext);
|
|
12
|
-
const { src: imageSrc, alt = i18n('img-alt'), disableCompress, tablet, desktop, mobile, style, className, onClick, containerClassName, } = props;
|
|
12
|
+
const { src: imageSrc, alt = i18n('img-alt'), disableCompress, tablet, desktop, mobile, style, className, onClick, containerClassName, qa, } = props;
|
|
13
13
|
const [imgLoadingError, setImgLoadingError] = useState(false);
|
|
14
14
|
const src = imageSrc || desktop;
|
|
15
15
|
if (!src) {
|
|
@@ -19,7 +19,7 @@ const Image = (props) => {
|
|
|
19
19
|
disableCompress ||
|
|
20
20
|
!isCompressible(src) ||
|
|
21
21
|
imgLoadingError;
|
|
22
|
-
return (React.createElement("picture", { className: containerClassName },
|
|
22
|
+
return (React.createElement("picture", { className: containerClassName, "data-qa": qa },
|
|
23
23
|
mobile && (React.createElement(Fragment, null,
|
|
24
24
|
!disableWebp && (React.createElement("source", { srcSet: checkWebP(mobile), type: "image/webp", media: `(max-width: ${BREAKPOINTS.sm}px)` })),
|
|
25
25
|
React.createElement("source", { srcSet: mobile, media: `(max-width: ${BREAKPOINTS.sm}px)` }))),
|
|
@@ -32,7 +32,7 @@ const Image = (props) => {
|
|
|
32
32
|
parallaxInterpolate = springScrollY.interpolate((value) => `translateY(-${Number(value) / parallaxLevel}px)`);
|
|
33
33
|
}
|
|
34
34
|
const imageClass = b('item', { withVideo: Boolean(video) && !hasVideoFallback }, imageClassName);
|
|
35
|
-
const
|
|
35
|
+
const renderFullscreenImage = (item) => {
|
|
36
36
|
const itemData = getMediaImage(item);
|
|
37
37
|
return (React.createElement(FullscreenImage, Object.assign({ key: itemData.alt }, itemData, { imageClassName: imageClass, imageStyle: { height } })));
|
|
38
38
|
};
|
|
@@ -47,13 +47,13 @@ const Image = (props) => {
|
|
|
47
47
|
};
|
|
48
48
|
const imageSlider = (imageArray) => {
|
|
49
49
|
const fullscreenItem = fullscreen === undefined || fullscreen;
|
|
50
|
-
return (React.createElement(SliderBlock, { slidesToShow: 1, type: SliderType.MediaCard }, imageArray.map((item) => fullscreenItem ?
|
|
50
|
+
return (React.createElement(SliderBlock, { slidesToShow: 1, type: SliderType.MediaCard }, imageArray.map((item) => fullscreenItem ? renderFullscreenImage(item) : imageOnly(item))));
|
|
51
51
|
};
|
|
52
52
|
if (Array.isArray(image)) {
|
|
53
53
|
return imageSlider(image);
|
|
54
54
|
}
|
|
55
55
|
if (fullscreen) {
|
|
56
|
-
return
|
|
56
|
+
return renderFullscreenImage(image);
|
|
57
57
|
}
|
|
58
58
|
return isBackground ? imageBackground(image) : imageOnly(image);
|
|
59
59
|
};
|
|
@@ -7,6 +7,8 @@ import Image from './Image/Image';
|
|
|
7
7
|
import Video from './Video/Video';
|
|
8
8
|
import './Media.css';
|
|
9
9
|
const b = block('Media');
|
|
10
|
+
// TODO delete along with fullScreen props
|
|
11
|
+
const getFullscreen = ({ fullScreen, fullscreen }) => fullScreen || fullscreen;
|
|
10
12
|
export const Media = (props) => {
|
|
11
13
|
const { image, video, youtube, dataLens, color, height, previewImg, parallax = false, metrika, fullScreen, fullscreen, analyticsEvents, } = props;
|
|
12
14
|
const { className, imageClassName, videoClassName, youtubeClassName, playVideo = true, isBackground, playButton, customBarControlsClassName, } = props;
|
|
@@ -14,7 +16,7 @@ export const Media = (props) => {
|
|
|
14
16
|
const content = useMemo(() => {
|
|
15
17
|
let result = [];
|
|
16
18
|
if (image) {
|
|
17
|
-
result.push(React.createElement(Image, { key: "image", parallax: parallax, image: image, height: height, imageClassName: imageClassName, isBackground: isBackground, video: video, hasVideoFallback: hasVideoFallback, fullscreen: fullScreen
|
|
19
|
+
result.push(React.createElement(Image, { key: "image", parallax: parallax, image: image, height: height, imageClassName: imageClassName, isBackground: isBackground, video: video, hasVideoFallback: hasVideoFallback, fullscreen: getFullscreen({ fullScreen, fullscreen }) }));
|
|
18
20
|
}
|
|
19
21
|
if (video) {
|
|
20
22
|
const videoProps = {
|
|
@@ -31,7 +33,7 @@ export const Media = (props) => {
|
|
|
31
33
|
hasVideoFallback,
|
|
32
34
|
setHasVideoFallback,
|
|
33
35
|
};
|
|
34
|
-
if (fullScreen
|
|
36
|
+
if (getFullscreen({ fullScreen, fullscreen })) {
|
|
35
37
|
result.push(React.createElement(FullscreenVideo, Object.assign({}, videoProps)));
|
|
36
38
|
}
|
|
37
39
|
else {
|
|
@@ -39,7 +41,7 @@ export const Media = (props) => {
|
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
if (youtube) {
|
|
42
|
-
result = (React.createElement(YoutubeBlock, { className: b('youtube', youtubeClassName), record: youtube, attributes: { color: 'white', rel: '0' }, previewImg: previewImg, height: height, fullscreen: fullScreen
|
|
44
|
+
result = (React.createElement(YoutubeBlock, { className: b('youtube', youtubeClassName), record: youtube, attributes: { color: 'white', rel: '0' }, previewImg: previewImg, height: height, fullscreen: getFullscreen({ fullScreen, fullscreen }) }));
|
|
43
45
|
}
|
|
44
46
|
if (dataLens) {
|
|
45
47
|
result = React.createElement(DataLens, { dataLens: dataLens });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ConstructorItem, CustomItem, FetchLoadableData, LoadableData, LoadableProps } from '../../models';
|
|
3
3
|
import './Loadable.css';
|
|
4
4
|
export interface LoadableState {
|
|
5
5
|
loading: boolean;
|
|
@@ -9,7 +9,7 @@ export interface LoadableState {
|
|
|
9
9
|
export interface LoadableComponentsProps extends Omit<PropsWithChildren<LoadableProps>, 'source'> {
|
|
10
10
|
Component: CustomItem;
|
|
11
11
|
ChildComponent: CustomItem;
|
|
12
|
-
block:
|
|
12
|
+
block: ConstructorItem;
|
|
13
13
|
blockKey: string;
|
|
14
14
|
fetch: FetchLoadableData;
|
|
15
15
|
}
|
|
@@ -9,7 +9,7 @@ import { ThemeValueContext } from '../../context/theme/ThemeValueContext';
|
|
|
9
9
|
import { Grid } from '../../grid';
|
|
10
10
|
import { BlockType, BlockTypes, HeaderBlockTypes, SubBlockTypes, } from '../../models';
|
|
11
11
|
import Layout from '../../navigation/containers/Layout/Layout';
|
|
12
|
-
import { block as cnBlock, getCustomBlockTypes, getCustomHeaderTypes, getCustomItems, getCustomSubBlockTypes, getThemedValue, } from '../../utils';
|
|
12
|
+
import { block as cnBlock, getCustomBlockTypes, getCustomHeaderTypes, getCustomItems, getCustomSubBlockTypes, getHeaderBlock, getOrderedBlocks, getThemedValue, } from '../../utils';
|
|
13
13
|
import { ConstructorBlocks } from './components/ConstructorBlocks';
|
|
14
14
|
import { ConstructorFootnotes } from './components/ConstructorFootnotes';
|
|
15
15
|
import { ConstructorHeader } from './components/ConstructorItem';
|
|
@@ -26,13 +26,15 @@ export const Constructor = (props) => {
|
|
|
26
26
|
itemMap: Object.assign(Object.assign(Object.assign({}, blockMap), subBlockMap), getCustomItems(custom)),
|
|
27
27
|
loadables: custom === null || custom === void 0 ? void 0 : custom.loadable,
|
|
28
28
|
shouldRenderBlock,
|
|
29
|
+
customization: {
|
|
30
|
+
decorators: custom === null || custom === void 0 ? void 0 : custom.decorators,
|
|
31
|
+
},
|
|
29
32
|
},
|
|
30
33
|
}), [custom, shouldRenderBlock]);
|
|
31
34
|
const { themeValue: theme } = useContext(ThemeValueContext);
|
|
32
35
|
const hasFootnotes = footnotes.length > 0;
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const restBlocks = blocks === null || blocks === void 0 ? void 0 : blocks.filter((block) => !isHeaderBlock(block));
|
|
36
|
+
const header = getHeaderBlock(blocks, context.headerBlockTypes);
|
|
37
|
+
const restBlocks = getOrderedBlocks(blocks, context.headerBlockTypes);
|
|
36
38
|
const themedBackground = getThemedValue(background, theme);
|
|
37
39
|
return (React.createElement(InnerContext.Provider, { value: context },
|
|
38
40
|
React.createElement("div", { className: b() },
|
package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { Fragment, useContext } from 'react';
|
|
2
2
|
import _ from 'lodash';
|
|
3
|
+
import { BlockIdContext } from '../../../../context/blockIdContext';
|
|
3
4
|
import { InnerContext } from '../../../../context/innerContext';
|
|
4
5
|
import { getBlockKey } from '../../../../utils';
|
|
5
6
|
import { ConstructorBlock } from '../ConstructorBlock/ConstructorBlock';
|
|
@@ -30,9 +31,9 @@ export const ConstructorBlocks = ({ items }) => {
|
|
|
30
31
|
if ('children' in item && item.children) {
|
|
31
32
|
children = item.children.map(renderer.bind(null, blockId));
|
|
32
33
|
}
|
|
33
|
-
itemElement = (React.createElement(ConstructorItem, { data: item,
|
|
34
|
+
itemElement = (React.createElement(ConstructorItem, { data: item, blockKey: blockId }, children));
|
|
34
35
|
}
|
|
35
|
-
return blockTypes.includes(item.type) ? (React.createElement(ConstructorBlock, { data: item
|
|
36
|
+
return (React.createElement(BlockIdContext.Provider, { value: blockId, key: blockId }, blockTypes.includes(item.type) ? (React.createElement(ConstructorBlock, { data: item }, itemElement)) : (itemElement)));
|
|
36
37
|
};
|
|
37
38
|
return React.createElement(Fragment, null, items.map(renderer.bind(null, '')));
|
|
38
39
|
};
|
package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export interface ConstructorItemProps {
|
|
|
3
3
|
data: ConstructorItemType;
|
|
4
4
|
blockKey: string;
|
|
5
5
|
}
|
|
6
|
-
export declare const ConstructorItem: ({ data,
|
|
6
|
+
export declare const ConstructorItem: ({ data, children }: WithChildren<ConstructorItemProps>) => JSX.Element;
|
|
7
7
|
export declare const ConstructorHeader: ({ data, blockKey, }: Pick<ConstructorItemProps, 'data' | 'blockKey'>) => JSX.Element;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
|
-
import { BlockIdContext } from '../../../../context/blockIdContext';
|
|
4
3
|
import { InnerContext } from '../../../../context/innerContext';
|
|
5
|
-
|
|
4
|
+
import { BlockDecoration } from '../../../../customization/BlockDecoration';
|
|
5
|
+
export const ConstructorItem = ({ data, children }) => {
|
|
6
6
|
const { itemMap } = useContext(InnerContext);
|
|
7
7
|
const { type } = data, rest = __rest(data, ["type"]);
|
|
8
8
|
const Component = itemMap[type];
|
|
9
|
-
return
|
|
10
|
-
React.createElement(Component, Object.assign({}, rest), children)));
|
|
9
|
+
return React.createElement(Component, Object.assign({}, rest), children);
|
|
11
10
|
};
|
|
12
|
-
export const ConstructorHeader = ({ data, blockKey, }) => (React.createElement(
|
|
11
|
+
export const ConstructorHeader = ({ data, blockKey, }) => (React.createElement(BlockDecoration, { id: data.type },
|
|
12
|
+
React.createElement(ConstructorItem, { data: data, key: data.type, blockKey: blockKey })));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ItemMap } from '../../containers/PageConstructor/PageConstructor';
|
|
3
|
-
import { LoadableConfig, ShouldRenderBlock } from '../../models';
|
|
3
|
+
import { CustomConfig, LoadableConfig, ShouldRenderBlock } from '../../models';
|
|
4
4
|
export interface InnerContextType {
|
|
5
5
|
blockTypes: string[];
|
|
6
6
|
subBlockTypes: string[];
|
|
@@ -8,5 +8,6 @@ export interface InnerContextType {
|
|
|
8
8
|
itemMap: ItemMap;
|
|
9
9
|
loadables?: LoadableConfig;
|
|
10
10
|
shouldRenderBlock?: ShouldRenderBlock;
|
|
11
|
+
customization?: Pick<CustomConfig, 'decorators'>;
|
|
11
12
|
}
|
|
12
13
|
export declare const InnerContext: React.Context<InnerContextType>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { Fragment, useContext } from 'react';
|
|
2
|
+
import { BlockIdContext } from '../context/blockIdContext';
|
|
3
|
+
import { InnerContext } from '../context/innerContext';
|
|
4
|
+
import { getBlockIndexFromId } from '../utils';
|
|
5
|
+
export const BlockDecoration = (props) => {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const blockContenxtId = getBlockIndexFromId(useContext(BlockIdContext));
|
|
8
|
+
const { headerBlockTypes } = useContext(InnerContext);
|
|
9
|
+
const blockId = props.id || blockContenxtId;
|
|
10
|
+
const isHeader = Boolean(props.id && headerBlockTypes.includes(props.id));
|
|
11
|
+
const block = React.createElement(Fragment, null, props.children);
|
|
12
|
+
const blockDecorators = (_b = (_a = useContext(InnerContext).customization) === null || _a === void 0 ? void 0 : _a.decorators) === null || _b === void 0 ? void 0 : _b.block;
|
|
13
|
+
if (!blockDecorators) {
|
|
14
|
+
return block;
|
|
15
|
+
}
|
|
16
|
+
return blockDecorators.reduce((children, decorator) => (React.createElement(Fragment, null, decorator({ children, id: blockId, isHeader }))), block);
|
|
17
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/* use this for style redefinitions to awoid problems with
|
|
2
|
+
unpredictable css rules order in build */
|
|
3
|
+
.pc-add-block {
|
|
4
|
+
position: fixed;
|
|
5
|
+
bottom: 32px;
|
|
6
|
+
left: 50%;
|
|
7
|
+
transform: translateX(-50%);
|
|
8
|
+
z-index: 110;
|
|
9
|
+
}
|
|
10
|
+
.pc-add-block__button {
|
|
11
|
+
display: inline-block;
|
|
12
|
+
margin: 0;
|
|
13
|
+
padding: 0;
|
|
14
|
+
font: inherit;
|
|
15
|
+
border: none;
|
|
16
|
+
outline: none;
|
|
17
|
+
color: inherit;
|
|
18
|
+
background: none;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
display: flex;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
align-items: center;
|
|
23
|
+
transition: transform 0.2s;
|
|
24
|
+
width: 76px;
|
|
25
|
+
height: 40px;
|
|
26
|
+
color: var(--yc-color-text-inverted-primary);
|
|
27
|
+
background-color: var(--yc-color-promo-base-neon);
|
|
28
|
+
border-radius: 8px;
|
|
29
|
+
}
|
|
30
|
+
.pc-add-block__button:hover {
|
|
31
|
+
transform: scale(1.05);
|
|
32
|
+
}
|
|
33
|
+
.pc-add-block__icon {
|
|
34
|
+
width: 16px;
|
|
35
|
+
height: 16px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.pc-add-block__popup {
|
|
39
|
+
min-width: 420px;
|
|
40
|
+
border-radius: var(--pc-border-radius);
|
|
41
|
+
box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.06), 0px 4px 24px rgba(0, 0, 0, 0.06);
|
|
42
|
+
}
|
|
43
|
+
.pc-add-block__popup .pc-add-block__search {
|
|
44
|
+
padding: 20px 20px 0;
|
|
45
|
+
}
|
|
46
|
+
.pc-add-block__popup .pc-add-block__blocks {
|
|
47
|
+
display: flex;
|
|
48
|
+
flex-direction: column;
|
|
49
|
+
padding: 20px;
|
|
50
|
+
height: 296px;
|
|
51
|
+
max-height: 296px;
|
|
52
|
+
overflow-y: auto;
|
|
53
|
+
}
|
|
54
|
+
.pc-add-block__popup .pc-add-block__block {
|
|
55
|
+
display: flex;
|
|
56
|
+
justify-content: center;
|
|
57
|
+
align-items: center;
|
|
58
|
+
transition: transform 0.2s;
|
|
59
|
+
margin-top: 20px;
|
|
60
|
+
justify-content: flex-start;
|
|
61
|
+
cursor: pointer;
|
|
62
|
+
}
|
|
63
|
+
.pc-add-block__popup .pc-add-block__block:hover {
|
|
64
|
+
transform: scale(1.05);
|
|
65
|
+
}
|
|
66
|
+
.pc-add-block__popup .pc-add-block__block:first-child {
|
|
67
|
+
margin-top: 0;
|
|
68
|
+
}
|
|
69
|
+
.pc-add-block__popup .pc-add-block__preview {
|
|
70
|
+
width: 148px;
|
|
71
|
+
height: 74px;
|
|
72
|
+
border-radius: var(--pc-border-radius);
|
|
73
|
+
margin-right: 16px;
|
|
74
|
+
}
|
|
75
|
+
.pc-add-block__popup .pc-add-block__title {
|
|
76
|
+
font-size: var(--yc-text-body-2-font-size);
|
|
77
|
+
line-height: var(--yc-text-body-2-line-height);
|
|
78
|
+
}
|
|
79
|
+
.pc-add-block__popup .pc-add-block__title,
|
|
80
|
+
.pc-add-block__popup .pc-add-block__description {
|
|
81
|
+
margin: 0;
|
|
82
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { Block } from '../../../models';
|
|
3
|
+
import './AddBlock.css';
|
|
4
|
+
export interface AddBlockProps {
|
|
5
|
+
onAdd: (data: Block) => void;
|
|
6
|
+
}
|
|
7
|
+
declare const AddBlock: ({ onAdd }: PropsWithChildren<AddBlockProps>) => JSX.Element;
|
|
8
|
+
export default AddBlock;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React, { useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { Plus } from '@gravity-ui/icons';
|
|
3
|
+
import { Popup, TextInput } from '@gravity-ui/uikit';
|
|
4
|
+
import { blockMap } from '../../../constructor-items';
|
|
5
|
+
import { block } from '../../../utils';
|
|
6
|
+
import EditorBlocksData from '../../data';
|
|
7
|
+
import './AddBlock.css';
|
|
8
|
+
const b = block('add-block');
|
|
9
|
+
const sortedBlockNames = Object.keys(blockMap).sort();
|
|
10
|
+
const AddBlock = ({ onAdd }) => {
|
|
11
|
+
const [isOpened, setIsOpened] = useState(false);
|
|
12
|
+
const [search, setSearch] = useState('');
|
|
13
|
+
const ref = useRef(null);
|
|
14
|
+
const blocks = useMemo(() => sortedBlockNames.filter((blockName) => EditorBlocksData[blockName].meta.title
|
|
15
|
+
.toLocaleLowerCase()
|
|
16
|
+
.startsWith(search.toLocaleLowerCase())), [search]);
|
|
17
|
+
return (React.createElement("div", { className: b(), ref: ref },
|
|
18
|
+
React.createElement("button", { className: b('button'), onClick: () => {
|
|
19
|
+
setIsOpened(!isOpened);
|
|
20
|
+
setSearch('');
|
|
21
|
+
} },
|
|
22
|
+
React.createElement(Plus, { className: b('icon') })),
|
|
23
|
+
isOpened && (React.createElement(Popup, { anchorRef: ref, open: isOpened, className: b('popup'), placement: "top", offset: [0, 24], onOutsideClick: () => setIsOpened(false) },
|
|
24
|
+
React.createElement("div", { className: b('search') },
|
|
25
|
+
React.createElement(TextInput, { placeholder: "search", type: "text", value: search, size: "l", onUpdate: (value) => setSearch(value) })),
|
|
26
|
+
React.createElement("div", { className: b('blocks') }, blocks.map((blockName) => {
|
|
27
|
+
var _a;
|
|
28
|
+
const blockData = EditorBlocksData[blockName];
|
|
29
|
+
const Preview = blockData === null || blockData === void 0 ? void 0 : blockData.preview;
|
|
30
|
+
return (React.createElement("div", { key: blockName, className: b('block'), onClick: () => {
|
|
31
|
+
onAdd(blockData === null || blockData === void 0 ? void 0 : blockData.template);
|
|
32
|
+
setIsOpened(false);
|
|
33
|
+
} },
|
|
34
|
+
React.createElement("div", { className: b('preview') },
|
|
35
|
+
React.createElement(Preview, null)),
|
|
36
|
+
React.createElement("div", { className: b('info') },
|
|
37
|
+
React.createElement("h4", { className: b('title') }, blockData.meta.title),
|
|
38
|
+
((_a = blockData === null || blockData === void 0 ? void 0 : blockData.meta) === null || _a === void 0 ? void 0 : _a.description) && (React.createElement("p", { className: b('description') }, blockData.meta.description)))));
|
|
39
|
+
}))))));
|
|
40
|
+
};
|
|
41
|
+
export default AddBlock;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* use this for style redefinitions to awoid problems with
|
|
2
|
+
unpredictable css rules order in build */
|
|
3
|
+
.pc-edit-block {
|
|
4
|
+
cursor: pointer;
|
|
5
|
+
position: relative;
|
|
6
|
+
}
|
|
7
|
+
.pc-edit-block__controls {
|
|
8
|
+
position: absolute;
|
|
9
|
+
width: calc(100% + 40px);
|
|
10
|
+
height: calc(100% + 40px);
|
|
11
|
+
top: -20px;
|
|
12
|
+
left: -20px;
|
|
13
|
+
border-radius: 8px;
|
|
14
|
+
z-index: 100;
|
|
15
|
+
}
|
|
16
|
+
.pc-edit-block__controls_isHeader {
|
|
17
|
+
width: 100%;
|
|
18
|
+
height: 100%;
|
|
19
|
+
top: 0;
|
|
20
|
+
left: 0;
|
|
21
|
+
}
|
|
22
|
+
.pc-edit-block__controls_active {
|
|
23
|
+
border: 4px solid var(--yc-color-promo-base-neon);
|
|
24
|
+
}
|
|
25
|
+
.pc-edit-block__controls-content {
|
|
26
|
+
display: flex;
|
|
27
|
+
position: absolute;
|
|
28
|
+
bottom: -44px;
|
|
29
|
+
left: 50%;
|
|
30
|
+
transform: translateX(-50%);
|
|
31
|
+
}
|
|
32
|
+
.pc-edit-block__control {
|
|
33
|
+
display: flex;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
align-items: center;
|
|
36
|
+
transition: transform 0.2s;
|
|
37
|
+
width: 24px;
|
|
38
|
+
height: 24px;
|
|
39
|
+
border-radius: calc(8px / 2);
|
|
40
|
+
background-color: var(--yc-color-promo-highlight-neon);
|
|
41
|
+
}
|
|
42
|
+
.pc-edit-block__control:hover {
|
|
43
|
+
transform: scale(1.1);
|
|
44
|
+
}
|
|
45
|
+
.pc-edit-block__control:not(:first-child) {
|
|
46
|
+
margin-left: 12px;
|
|
47
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { EditBlockProps } from '../../../editor/types';
|
|
3
|
+
import './EditBlock.css';
|
|
4
|
+
declare const _default: React.MemoExoticComponent<({ id, isHeader, activeBlockId, onDelete, onSelect, onCopy, onOrderChange, children, orderedBlocksCount, }: EditBlockProps) => JSX.Element>;
|
|
5
|
+
export default _default;
|