@gravity-ui/page-constructor 4.36.0-alpha.0 → 4.36.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/build/cjs/blocks/Companies/Companies.css +0 -16
- package/build/cjs/blocks/Companies/Companies.d.ts +1 -1
- package/build/cjs/blocks/Companies/Companies.js +2 -2
- package/build/cjs/blocks/Form/Form.css +1 -6
- package/build/cjs/blocks/Form/Form.js +2 -4
- package/build/cjs/blocks/Tabs/Tabs.css +33 -3
- package/build/cjs/blocks/Tabs/Tabs.js +18 -21
- package/build/cjs/components/Image/Image.d.ts +1 -2
- package/build/cjs/components/Image/Image.js +2 -2
- package/build/cjs/components/ImageBase/ImageBase.d.ts +1 -2
- package/build/cjs/components/Media/Image/Image.d.ts +0 -1
- package/build/cjs/components/Media/Image/Image.js +2 -2
- package/build/cjs/components/Media/Media.js +3 -4
- package/build/cjs/components/VideoBlock/VideoBlock.d.ts +0 -1
- package/build/cjs/components/VideoBlock/VideoBlock.js +2 -2
- package/build/cjs/constructor-items.d.ts +1 -1
- package/build/cjs/models/constructor-items/blocks.d.ts +1 -0
- package/build/cjs/text-transform/config.js +1 -0
- package/build/esm/blocks/Companies/Companies.css +0 -16
- package/build/esm/blocks/Companies/Companies.d.ts +1 -1
- package/build/esm/blocks/Companies/Companies.js +3 -3
- package/build/esm/blocks/Form/Form.css +1 -6
- package/build/esm/blocks/Form/Form.js +2 -4
- package/build/esm/blocks/Tabs/Tabs.css +33 -3
- package/build/esm/blocks/Tabs/Tabs.js +19 -22
- package/build/esm/components/Image/Image.d.ts +1 -2
- package/build/esm/components/Image/Image.js +3 -3
- package/build/esm/components/ImageBase/ImageBase.d.ts +1 -2
- package/build/esm/components/Media/Image/Image.d.ts +0 -1
- package/build/esm/components/Media/Image/Image.js +2 -2
- package/build/esm/components/Media/Media.js +3 -4
- package/build/esm/components/VideoBlock/VideoBlock.d.ts +0 -1
- package/build/esm/components/VideoBlock/VideoBlock.js +2 -2
- package/build/esm/constructor-items.d.ts +1 -1
- package/build/esm/models/constructor-items/blocks.d.ts +1 -0
- package/build/esm/text-transform/config.js +1 -0
- package/package.json +1 -1
- package/server/models/constructor-items/blocks.d.ts +1 -0
- package/server/text-transform/config.js +1 -0
- package/widget/index.js +1 -1
- package/build/cjs/blocks/Tabs/TabsTextContent/TabsTextContent.css +0 -20
- package/build/cjs/blocks/Tabs/TabsTextContent/TabsTextContent.d.ts +0 -10
- package/build/cjs/blocks/Tabs/TabsTextContent/TabsTextContent.js +0 -17
- package/build/esm/blocks/Tabs/TabsTextContent/TabsTextContent.css +0 -20
- package/build/esm/blocks/Tabs/TabsTextContent/TabsTextContent.d.ts +0 -11
- package/build/esm/blocks/Tabs/TabsTextContent/TabsTextContent.js +0 -13
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { Fragment,
|
|
1
|
+
import React, { Fragment, useRef, useState } from 'react';
|
|
2
2
|
import { useUniqId } from '@gravity-ui/uikit';
|
|
3
3
|
import AnimateBlock from '../../components/AnimateBlock/AnimateBlock';
|
|
4
4
|
import ButtonTabs from '../../components/ButtonTabs/ButtonTabs';
|
|
@@ -9,12 +9,12 @@ import Title from '../../components/Title/Title';
|
|
|
9
9
|
import { getHeight } from '../../components/VideoBlock/VideoBlock';
|
|
10
10
|
import { useTheme } from '../../context/theme';
|
|
11
11
|
import { Col, GridColumnOrderClasses, Row } from '../../grid';
|
|
12
|
+
import { Content } from '../../sub-blocks';
|
|
12
13
|
import { block, getThemedValue } from '../../utils';
|
|
13
|
-
import TabsTextContent from './TabsTextContent/TabsTextContent';
|
|
14
14
|
import './Tabs.css';
|
|
15
15
|
const b = block('tabs-block');
|
|
16
16
|
export const TabsBlock = ({ items, title, description, animated, tabsColSizes, centered, direction = 'media-content', contentSize = 's', }) => {
|
|
17
|
-
var _a
|
|
17
|
+
var _a;
|
|
18
18
|
const [activeTab, setActiveTab] = useState(items[0].tabName);
|
|
19
19
|
const [play, setPlay] = useState(false);
|
|
20
20
|
const theme = useTheme();
|
|
@@ -23,24 +23,11 @@ export const TabsBlock = ({ items, title, description, animated, tabsColSizes, c
|
|
|
23
23
|
const isReverse = direction === 'content-media';
|
|
24
24
|
const ref = useRef(null);
|
|
25
25
|
const mediaWidth = (_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.offsetWidth;
|
|
26
|
+
const mediaHeight = mediaWidth && getHeight(mediaWidth);
|
|
26
27
|
const captionId = useUniqId();
|
|
27
|
-
const themedMedia = getThemedValue(activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.media, theme);
|
|
28
|
-
const mediaVideoHeight = mediaWidth && getHeight(mediaWidth);
|
|
29
|
-
const setVideoHeight = !(themedMedia === null || themedMedia === void 0 ? void 0 : themedMedia.image) && !(activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.image);
|
|
30
|
-
const [minImageHeight, setMinImageHeight] = useState((_b = ref === null || ref === void 0 ? void 0 : ref.current) === null || _b === void 0 ? void 0 : _b.offsetHeight);
|
|
31
|
-
// TODO remove property support activeTabData?.image. Use only activeTabData?.media?.image
|
|
32
28
|
let imageProps;
|
|
33
|
-
const handleImageHeight = useCallback(() => {
|
|
34
|
-
var _a;
|
|
35
|
-
setMinImageHeight((_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.offsetHeight);
|
|
36
|
-
}, []);
|
|
37
|
-
const onSelectTab = (id, e) => {
|
|
38
|
-
setActiveTab(id);
|
|
39
|
-
handleImageHeight();
|
|
40
|
-
e.currentTarget.scrollIntoView({ inline: 'center', behavior: 'smooth', block: 'nearest' });
|
|
41
|
-
};
|
|
42
29
|
if (activeTabData) {
|
|
43
|
-
const themedImage = getThemedValue(activeTabData
|
|
30
|
+
const themedImage = getThemedValue(activeTabData.image, theme);
|
|
44
31
|
imageProps = themedImage && getMediaImage(themedImage);
|
|
45
32
|
if (activeTabData.caption && imageProps) {
|
|
46
33
|
Object.assign(imageProps, {
|
|
@@ -50,18 +37,28 @@ export const TabsBlock = ({ items, title, description, animated, tabsColSizes, c
|
|
|
50
37
|
}
|
|
51
38
|
const showMedia = Boolean((activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.media) || imageProps);
|
|
52
39
|
const showText = Boolean(activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.text);
|
|
53
|
-
const textContent = activeTabData && showText && (React.createElement(
|
|
40
|
+
const textContent = activeTabData && showText && (React.createElement(Col, { sizes: { all: 12, md: showMedia ? 4 : 8 }, className: b('content', { centered: centered }) },
|
|
41
|
+
React.createElement("div", { className: b('content-wrapper', {
|
|
42
|
+
margin: Boolean(((activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.media) || imageProps) && !isReverse),
|
|
43
|
+
}) },
|
|
44
|
+
React.createElement(Content, { title: activeTabData.title, text: activeTabData.text, additionalInfo: activeTabData.additionalInfo, size: contentSize, links: [
|
|
45
|
+
...(activeTabData.link ? [activeTabData.link] : []),
|
|
46
|
+
...(activeTabData.links || []),
|
|
47
|
+
], buttons: activeTabData.buttons, colSizes: { all: 12 } }))));
|
|
54
48
|
const mediaContent = showMedia && (React.createElement(Col, { sizes: { all: 12, md: 8 }, orders: {
|
|
55
49
|
all: GridColumnOrderClasses.Last,
|
|
56
50
|
md: GridColumnOrderClasses.First,
|
|
57
51
|
}, className: b('col', { centered: centered }) },
|
|
58
|
-
React.createElement("div", {
|
|
59
|
-
React.createElement(Media, Object.assign({}, getThemedValue(activeTabData.media, theme), { key: activeTab, className: b('media'), playVideo: play, height: setVideoHeight ? mediaVideoHeight : undefined, handleImageLoad: handleImageHeight }))))),
|
|
52
|
+
React.createElement("div", { ref: ref }, (activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.media) && (React.createElement(Media, Object.assign({}, getThemedValue(activeTabData.media, theme), { key: activeTab, className: b('media'), playVideo: play, height: mediaHeight })))),
|
|
60
53
|
imageProps && (React.createElement(Fragment, null,
|
|
61
54
|
React.createElement(FullscreenImage, Object.assign({}, imageProps, { imageClassName: b('image') })))),
|
|
62
55
|
(activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.caption) && (React.createElement("p", { className: b('caption'), id: captionId }, activeTabData.caption))));
|
|
56
|
+
const onSelectTab = (id, e) => {
|
|
57
|
+
setActiveTab(id);
|
|
58
|
+
e.currentTarget.scrollIntoView({ inline: 'center', behavior: 'smooth', block: 'nearest' });
|
|
59
|
+
};
|
|
63
60
|
return (React.createElement(AnimateBlock, { className: b(), onScroll: () => setPlay(true), animate: animated },
|
|
64
|
-
React.createElement(Title, { title: title, subtitle: description, className: b('title', { centered: centered }) }),
|
|
61
|
+
React.createElement(Title, { title: title, subtitle: description, className: b('block-title', { centered: centered }) }),
|
|
65
62
|
React.createElement(Row, null,
|
|
66
63
|
React.createElement(Col, { sizes: tabsColSizes },
|
|
67
64
|
React.createElement(ButtonTabs, { items: tabs, onSelectTab: onSelectTab, activeTab: activeTab, className: b('tabs', { centered: centered }) }))),
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { CSSProperties, MouseEventHandler
|
|
1
|
+
import { CSSProperties, MouseEventHandler } from 'react';
|
|
2
2
|
import { ImageDeviceProps, ImageObjectProps, QAProps } from '../../models';
|
|
3
3
|
export interface ImageProps extends Partial<ImageObjectProps>, Partial<ImageDeviceProps>, QAProps {
|
|
4
4
|
style?: CSSProperties;
|
|
5
5
|
className?: string;
|
|
6
6
|
onClick?: MouseEventHandler;
|
|
7
|
-
onLoad?: ReactEventHandler<HTMLDivElement>;
|
|
8
7
|
containerClassName?: string;
|
|
9
8
|
}
|
|
10
9
|
export interface DeviceSpecificFragmentProps extends QAProps {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { Fragment, useContext, useState
|
|
1
|
+
import React, { Fragment, useContext, useState } from 'react';
|
|
2
2
|
import { BREAKPOINTS } from '../../constants';
|
|
3
3
|
import { ProjectSettingsContext } from '../../context/projectSettingsContext';
|
|
4
4
|
import { getQaAttrubutes } from '../../utils';
|
|
@@ -12,7 +12,7 @@ const DeviceSpecificFragment = ({ disableWebp, src, breakpoint, qa, }) => (React
|
|
|
12
12
|
React.createElement("source", { srcSet: src, media: `(max-width: ${breakpoint}px)`, "data-qa": qa })));
|
|
13
13
|
const Image = (props) => {
|
|
14
14
|
const projectSettings = useContext(ProjectSettingsContext);
|
|
15
|
-
const { src: imageSrc, alt, disableCompress, tablet, desktop, mobile, style, className, onClick,
|
|
15
|
+
const { src: imageSrc, alt, disableCompress, tablet, desktop, mobile, style, className, onClick, containerClassName, qa, } = props;
|
|
16
16
|
const [imgLoadingError, setImgLoadingError] = useState(false);
|
|
17
17
|
const src = imageSrc || desktop;
|
|
18
18
|
if (!src) {
|
|
@@ -27,6 +27,6 @@ const Image = (props) => {
|
|
|
27
27
|
mobile && (React.createElement(DeviceSpecificFragment, { src: mobile, disableWebp: disableWebp, breakpoint: BREAKPOINTS.sm, qa: qaAttributes.mobileSource })),
|
|
28
28
|
tablet && (React.createElement(DeviceSpecificFragment, { src: tablet, disableWebp: disableWebp, breakpoint: BREAKPOINTS.md, qa: qaAttributes.tabletSource })),
|
|
29
29
|
src && !disableWebp && (React.createElement("source", { srcSet: checkWebP(src), type: "image/webp", "data-qa": qaAttributes.desktopSourceCompressed })),
|
|
30
|
-
React.createElement(ImageBase, { className: className, alt: alt, src: src, style: style, onClick: onClick, onError: () => setImgLoadingError(true)
|
|
30
|
+
React.createElement(ImageBase, { className: className, alt: alt, src: src, style: style, onClick: onClick, onError: () => setImgLoadingError(true) })));
|
|
31
31
|
};
|
|
32
32
|
export default Image;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { CSSProperties, MouseEventHandler
|
|
1
|
+
import { CSSProperties, MouseEventHandler } from 'react';
|
|
2
2
|
import { ImageObjectProps } from '../../models';
|
|
3
3
|
export interface ImageBaseProps extends Partial<ImageObjectProps> {
|
|
4
4
|
style?: CSSProperties;
|
|
5
5
|
className?: string;
|
|
6
6
|
onClick?: MouseEventHandler;
|
|
7
|
-
onLoad?: ReactEventHandler<HTMLDivElement>;
|
|
8
7
|
onError?: () => void;
|
|
9
8
|
}
|
|
10
9
|
export declare const ImageBase: (props: ImageBaseProps) => JSX.Element;
|
|
@@ -12,7 +12,7 @@ import './Image.css';
|
|
|
12
12
|
const b = block('media-component-image');
|
|
13
13
|
export const defaultAnimatedDivQa = 'animated-div';
|
|
14
14
|
const Image = (props) => {
|
|
15
|
-
const { parallax, image, height, imageClassName, isBackground, hasVideoFallback, video, fullscreen, qa,
|
|
15
|
+
const { parallax, image, height, imageClassName, isBackground, hasVideoFallback, video, fullscreen, qa, } = props;
|
|
16
16
|
const qaAttributes = getQaAttrubutes(qa, 'fullscreen-image', 'animate', 'background-image', 'image-view', 'slider-block');
|
|
17
17
|
const [scrollY, setScrollY] = useState(0);
|
|
18
18
|
const [{ springScrollY }, springSetScrollY] = useSpring(() => ({
|
|
@@ -46,7 +46,7 @@ const Image = (props) => {
|
|
|
46
46
|
};
|
|
47
47
|
const imageOnly = (oneImage) => {
|
|
48
48
|
const imageData = getMediaImage(oneImage);
|
|
49
|
-
return (React.createElement(ImageView, Object.assign({}, imageData, { className: imageClass, style: { height }, qa: qaAttributes.imageView
|
|
49
|
+
return (React.createElement(ImageView, Object.assign({}, imageData, { className: imageClass, style: { height }, qa: qaAttributes.imageView })));
|
|
50
50
|
};
|
|
51
51
|
const imageSlider = (imageArray) => {
|
|
52
52
|
const fullscreenItem = fullscreen === undefined || fullscreen;
|
|
@@ -8,13 +8,13 @@ import Video from './Video/Video';
|
|
|
8
8
|
import './Media.css';
|
|
9
9
|
const b = block('Media');
|
|
10
10
|
export const Media = (props) => {
|
|
11
|
-
const { image, video, youtube, dataLens, color, height, previewImg, parallax = false, metrika, fullscreen, analyticsEvents, className, imageClassName, videoClassName, youtubeClassName, playVideo = true, isBackground, playButton, customBarControlsClassName, qa, ratio, autoplay,
|
|
11
|
+
const { image, video, youtube, dataLens, color, height, previewImg, parallax = false, metrika, fullscreen, analyticsEvents, className, imageClassName, videoClassName, youtubeClassName, playVideo = true, isBackground, playButton, customBarControlsClassName, qa, ratio, autoplay, } = props;
|
|
12
12
|
const [hasVideoFallback, setHasVideoFallback] = useState(false);
|
|
13
13
|
const qaAttributes = getQaAttrubutes(qa, 'video');
|
|
14
14
|
const content = useMemo(() => {
|
|
15
15
|
let result = [];
|
|
16
16
|
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, qa: qaAttributes.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, qa: qaAttributes.image }));
|
|
18
18
|
}
|
|
19
19
|
if (video) {
|
|
20
20
|
const videoProps = {
|
|
@@ -40,7 +40,7 @@ export const Media = (props) => {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
if (youtube) {
|
|
43
|
-
result = (React.createElement(YoutubeBlock, { className: b('youtube', youtubeClassName), record: youtube, attributes: { color: 'white', rel: '0' }, previewImg: previewImg, height: height, fullscreen: fullscreen, analyticsEvents: analyticsEvents, autoplay: autoplay
|
|
43
|
+
result = (React.createElement(YoutubeBlock, { className: b('youtube', youtubeClassName), record: youtube, attributes: { color: 'white', rel: '0' }, previewImg: previewImg, height: height, fullscreen: fullscreen, analyticsEvents: analyticsEvents, autoplay: autoplay }));
|
|
44
44
|
}
|
|
45
45
|
if (dataLens) {
|
|
46
46
|
result = React.createElement(DataLens, { dataLens: dataLens });
|
|
@@ -69,7 +69,6 @@ export const Media = (props) => {
|
|
|
69
69
|
ratio,
|
|
70
70
|
youtubeClassName,
|
|
71
71
|
autoplay,
|
|
72
|
-
handleImageLoad,
|
|
73
72
|
]);
|
|
74
73
|
return (React.createElement("div", { className: b(null, className), style: { backgroundColor: color }, "data-qa": qa }, content));
|
|
75
74
|
};
|
|
@@ -17,7 +17,6 @@ export interface VideoBlockProps extends AnalyticsEventsBase {
|
|
|
17
17
|
height?: number;
|
|
18
18
|
fullscreen?: boolean;
|
|
19
19
|
autoplay?: boolean;
|
|
20
|
-
handleImageLoad?: () => void;
|
|
21
20
|
}
|
|
22
21
|
declare const VideoBlock: (props: VideoBlockProps) => JSX.Element | null;
|
|
23
22
|
export default VideoBlock;
|
|
@@ -37,7 +37,7 @@ export function getHeight(width) {
|
|
|
37
37
|
return (width / 16) * 9;
|
|
38
38
|
}
|
|
39
39
|
const VideoBlock = (props) => {
|
|
40
|
-
const { stream, record, attributes, className, id, previewImg, playButton, height, fullscreen, analyticsEvents, autoplay,
|
|
40
|
+
const { stream, record, attributes, className, id, previewImg, playButton, height, fullscreen, analyticsEvents, autoplay, } = props;
|
|
41
41
|
const handleAnalytics = useAnalytics(DefaultEventNames.VideoPreview);
|
|
42
42
|
const src = getVideoSrc(stream, record);
|
|
43
43
|
const ref = useRef(null);
|
|
@@ -91,7 +91,7 @@ const VideoBlock = (props) => {
|
|
|
91
91
|
return null;
|
|
92
92
|
}
|
|
93
93
|
return (React.createElement("div", { className: b(null, className), ref: ref, style: { height: currentHeight } }, previewImg && !hidePreview && !fullscreen && (React.createElement("div", { className: b('preview'), onClick: onPreviewClick },
|
|
94
|
-
React.createElement(Image, { src: previewImg, className: b('image'), containerClassName: b('image-wrapper')
|
|
94
|
+
React.createElement(Image, { src: previewImg, className: b('image'), containerClassName: b('image-wrapper') }),
|
|
95
95
|
playButton || (React.createElement("button", { title: "Play", className: b('button') },
|
|
96
96
|
React.createElement(Icon, { className: b('icon'), data: PlayVideo, size: 24 })))))));
|
|
97
97
|
};
|
|
@@ -4,7 +4,7 @@ export declare const blockMap: {
|
|
|
4
4
|
"promo-features-block": (props: import("./models").PromoFeaturesProps) => JSX.Element;
|
|
5
5
|
"questions-block": (props: import("./models").QuestionsProps) => JSX.Element;
|
|
6
6
|
"banner-block": (props: import("./models").BannerBlockProps) => JSX.Element;
|
|
7
|
-
"companies-block": ({ title, images, animated }: import("./models").CompaniesBlockProps) => JSX.Element;
|
|
7
|
+
"companies-block": ({ title, description, images, animated }: import("./models").CompaniesBlockProps) => JSX.Element;
|
|
8
8
|
"media-block": (props: import("./models").MediaBlockProps) => JSX.Element;
|
|
9
9
|
"info-block": (props: import("./models").InfoBlockProps) => JSX.Element;
|
|
10
10
|
"table-block": (props: import("./models").TableBlockProps) => JSX.Element;
|
|
@@ -154,6 +154,7 @@ export interface BannerBlockProps extends BannerCardProps, Animatable {
|
|
|
154
154
|
}
|
|
155
155
|
export interface CompaniesBlockProps extends Animatable {
|
|
156
156
|
title: string;
|
|
157
|
+
description?: string;
|
|
157
158
|
images: ThemeSupporting<ImageDeviceProps>;
|
|
158
159
|
}
|
|
159
160
|
export interface MediaBaseBlockProps extends Animatable, MediaContentProps {
|
package/package.json
CHANGED
|
@@ -154,6 +154,7 @@ export interface BannerBlockProps extends BannerCardProps, Animatable {
|
|
|
154
154
|
}
|
|
155
155
|
export interface CompaniesBlockProps extends Animatable {
|
|
156
156
|
title: string;
|
|
157
|
+
description?: string;
|
|
157
158
|
images: ThemeSupporting<ImageDeviceProps>;
|
|
158
159
|
}
|
|
159
160
|
export interface MediaBaseBlockProps extends Animatable, MediaContentProps {
|