@gravity-ui/page-constructor 4.11.1 → 4.13.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/Icons/Icons.js +6 -1
- package/build/cjs/blocks/Icons/schema.d.ts +162 -0
- package/build/cjs/blocks/Icons/schema.js +11 -0
- package/build/cjs/components/BackgroundImage/BackgroundImage.d.ts +1 -0
- package/build/cjs/components/BackgroundImage/BackgroundImage.js +5 -2
- package/build/cjs/components/BackgroundMedia/BackgroundMedia.d.ts +1 -1
- package/build/cjs/components/BackgroundMedia/BackgroundMedia.js +4 -3
- package/build/cjs/components/Image/Image.js +7 -5
- package/build/cjs/components/Media/Image/Image.d.ts +3 -2
- package/build/cjs/components/Media/Image/Image.js +8 -5
- package/build/cjs/components/Media/Media.d.ts +2 -2
- package/build/cjs/components/Media/Media.js +9 -6
- package/build/cjs/components/Media/Video/Video.d.ts +2 -2
- package/build/cjs/components/Media/Video/Video.js +13 -4
- package/build/cjs/models/constructor-items/blocks.d.ts +7 -5
- package/build/cjs/models/constructor-items/common.d.ts +1 -1
- package/build/cjs/text-transform/common.d.ts +7 -2
- package/build/cjs/text-transform/common.js +8 -2
- package/build/cjs/text-transform/transformers.d.ts +2 -0
- package/build/cjs/text-transform/transformers.js +11 -8
- package/build/cjs/utils/blocks.d.ts +1 -1
- package/build/cjs/utils/blocks.js +4 -3
- package/build/esm/blocks/Icons/Icons.js +7 -2
- package/build/esm/blocks/Icons/schema.d.ts +162 -0
- package/build/esm/blocks/Icons/schema.js +11 -0
- package/build/esm/components/BackgroundImage/BackgroundImage.d.ts +1 -0
- package/build/esm/components/BackgroundImage/BackgroundImage.js +5 -3
- package/build/esm/components/BackgroundMedia/BackgroundMedia.d.ts +1 -1
- package/build/esm/components/BackgroundMedia/BackgroundMedia.js +5 -4
- package/build/esm/components/Image/Image.js +7 -5
- package/build/esm/components/Media/Image/Image.d.ts +3 -2
- package/build/esm/components/Media/Image/Image.js +8 -6
- package/build/esm/components/Media/Media.d.ts +2 -2
- package/build/esm/components/Media/Media.js +10 -7
- package/build/esm/components/Media/Video/Video.d.ts +2 -2
- package/build/esm/components/Media/Video/Video.js +14 -5
- package/build/esm/models/constructor-items/blocks.d.ts +7 -5
- package/build/esm/models/constructor-items/common.d.ts +1 -1
- package/build/esm/text-transform/common.d.ts +7 -2
- package/build/esm/text-transform/common.js +7 -2
- package/build/esm/text-transform/transformers.d.ts +2 -0
- package/build/esm/text-transform/transformers.js +11 -8
- package/build/esm/utils/blocks.d.ts +1 -1
- package/build/esm/utils/blocks.js +5 -4
- package/package.json +1 -1
- package/server/models/constructor-items/blocks.d.ts +7 -5
- package/server/models/constructor-items/common.d.ts +1 -1
- package/server/text-transform/common.d.ts +7 -2
- package/server/text-transform/common.js +10 -2
- package/server/text-transform/transformers.d.ts +2 -0
- package/server/text-transform/transformers.js +11 -8
- package/server/utils/blocks.d.ts +1 -1
- package/server/utils/blocks.js +4 -3
- package/widget/index.js +1 -1
|
@@ -4,6 +4,7 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
5
|
const components_1 = require("../../components");
|
|
6
6
|
const locationContext_1 = require("../../context/locationContext");
|
|
7
|
+
const hooks_1 = require("../../hooks");
|
|
7
8
|
const utils_1 = require("../../utils");
|
|
8
9
|
const b = (0, utils_1.block)('icons-block');
|
|
9
10
|
const getItemContent = (item) => (react_1.default.createElement(react_1.Fragment, null,
|
|
@@ -11,12 +12,16 @@ const getItemContent = (item) => (react_1.default.createElement(react_1.Fragment
|
|
|
11
12
|
react_1.default.createElement("p", { className: b('text') }, item.text)));
|
|
12
13
|
const Icons = ({ title, size = 's', items }) => {
|
|
13
14
|
const { hostname } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
15
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)();
|
|
16
|
+
const onClick = (0, react_1.useCallback)(({ analyticsEvents, url }) => {
|
|
17
|
+
handleAnalytics(analyticsEvents, { url });
|
|
18
|
+
}, [handleAnalytics]);
|
|
14
19
|
return (react_1.default.createElement("div", { className: b({ size }) },
|
|
15
20
|
title && react_1.default.createElement(components_1.Title, { className: b('header'), title: title, colSizes: { all: 12 } }),
|
|
16
21
|
items.map((item) => {
|
|
17
22
|
const itemContent = getItemContent(item);
|
|
18
23
|
const { url, text } = item;
|
|
19
|
-
return url ? (react_1.default.createElement("a", Object.assign({ className: b('item'), key: url, href: url, "aria-label": text, title: text }, (0, utils_1.getLinkProps)(url, hostname)), itemContent)) : (react_1.default.createElement("div", { className: b('item'), key: url }, itemContent));
|
|
24
|
+
return url ? (react_1.default.createElement("a", Object.assign({ className: b('item'), key: url, href: url, "aria-label": text, title: text }, (0, utils_1.getLinkProps)(url, hostname), { onClick: () => onClick(item) }), itemContent)) : (react_1.default.createElement("div", { className: b('item'), key: url }, itemContent));
|
|
20
25
|
})));
|
|
21
26
|
};
|
|
22
27
|
exports.default = Icons;
|
|
@@ -29,6 +29,87 @@ export declare const IconsProps: {
|
|
|
29
29
|
type: string;
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
|
+
analyticsEvents: {
|
|
33
|
+
oneOf: ({
|
|
34
|
+
optionName: string;
|
|
35
|
+
type: string;
|
|
36
|
+
additionalProperties: {
|
|
37
|
+
type: string;
|
|
38
|
+
};
|
|
39
|
+
required: string[];
|
|
40
|
+
properties: {
|
|
41
|
+
name: {
|
|
42
|
+
type: string;
|
|
43
|
+
};
|
|
44
|
+
type: {
|
|
45
|
+
type: string;
|
|
46
|
+
};
|
|
47
|
+
counters: {
|
|
48
|
+
type: string;
|
|
49
|
+
additionalProperties: boolean;
|
|
50
|
+
required: never[];
|
|
51
|
+
properties: {
|
|
52
|
+
include: {
|
|
53
|
+
type: string;
|
|
54
|
+
items: {
|
|
55
|
+
type: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
exclude: {
|
|
59
|
+
type: string;
|
|
60
|
+
items: {
|
|
61
|
+
type: string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
context: {
|
|
67
|
+
type: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
items?: undefined;
|
|
71
|
+
} | {
|
|
72
|
+
type: string;
|
|
73
|
+
items: {
|
|
74
|
+
type: string;
|
|
75
|
+
additionalProperties: {
|
|
76
|
+
type: string;
|
|
77
|
+
};
|
|
78
|
+
required: string[];
|
|
79
|
+
properties: {
|
|
80
|
+
name: {
|
|
81
|
+
type: string;
|
|
82
|
+
};
|
|
83
|
+
type: {
|
|
84
|
+
type: string;
|
|
85
|
+
};
|
|
86
|
+
counters: {
|
|
87
|
+
type: string;
|
|
88
|
+
additionalProperties: boolean;
|
|
89
|
+
required: never[];
|
|
90
|
+
properties: {
|
|
91
|
+
include: {
|
|
92
|
+
type: string;
|
|
93
|
+
items: {
|
|
94
|
+
type: string;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
exclude: {
|
|
98
|
+
type: string;
|
|
99
|
+
items: {
|
|
100
|
+
type: string;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
context: {
|
|
106
|
+
type: string;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
optionName: string;
|
|
111
|
+
})[];
|
|
112
|
+
};
|
|
32
113
|
};
|
|
33
114
|
};
|
|
34
115
|
animated: {
|
|
@@ -96,6 +177,87 @@ export declare const IconsBlock: {
|
|
|
96
177
|
type: string;
|
|
97
178
|
};
|
|
98
179
|
};
|
|
180
|
+
analyticsEvents: {
|
|
181
|
+
oneOf: ({
|
|
182
|
+
optionName: string;
|
|
183
|
+
type: string;
|
|
184
|
+
additionalProperties: {
|
|
185
|
+
type: string;
|
|
186
|
+
};
|
|
187
|
+
required: string[];
|
|
188
|
+
properties: {
|
|
189
|
+
name: {
|
|
190
|
+
type: string;
|
|
191
|
+
};
|
|
192
|
+
type: {
|
|
193
|
+
type: string;
|
|
194
|
+
};
|
|
195
|
+
counters: {
|
|
196
|
+
type: string;
|
|
197
|
+
additionalProperties: boolean;
|
|
198
|
+
required: never[];
|
|
199
|
+
properties: {
|
|
200
|
+
include: {
|
|
201
|
+
type: string;
|
|
202
|
+
items: {
|
|
203
|
+
type: string;
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
exclude: {
|
|
207
|
+
type: string;
|
|
208
|
+
items: {
|
|
209
|
+
type: string;
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
context: {
|
|
215
|
+
type: string;
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
items?: undefined;
|
|
219
|
+
} | {
|
|
220
|
+
type: string;
|
|
221
|
+
items: {
|
|
222
|
+
type: string;
|
|
223
|
+
additionalProperties: {
|
|
224
|
+
type: string;
|
|
225
|
+
};
|
|
226
|
+
required: string[];
|
|
227
|
+
properties: {
|
|
228
|
+
name: {
|
|
229
|
+
type: string;
|
|
230
|
+
};
|
|
231
|
+
type: {
|
|
232
|
+
type: string;
|
|
233
|
+
};
|
|
234
|
+
counters: {
|
|
235
|
+
type: string;
|
|
236
|
+
additionalProperties: boolean;
|
|
237
|
+
required: never[];
|
|
238
|
+
properties: {
|
|
239
|
+
include: {
|
|
240
|
+
type: string;
|
|
241
|
+
items: {
|
|
242
|
+
type: string;
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
exclude: {
|
|
246
|
+
type: string;
|
|
247
|
+
items: {
|
|
248
|
+
type: string;
|
|
249
|
+
};
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
context: {
|
|
254
|
+
type: string;
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
optionName: string;
|
|
259
|
+
})[];
|
|
260
|
+
};
|
|
99
261
|
};
|
|
100
262
|
};
|
|
101
263
|
animated: {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.IconsBlock = exports.IconsProps = void 0;
|
|
4
4
|
const common_1 = require("../../schema/validators/common");
|
|
5
|
+
const event_1 = require("../../schema/validators/event");
|
|
5
6
|
exports.IconsProps = {
|
|
6
7
|
additionalProperties: false,
|
|
7
8
|
required: ['size', 'items'],
|
|
@@ -30,6 +31,16 @@ exports.IconsProps = {
|
|
|
30
31
|
type: 'string',
|
|
31
32
|
},
|
|
32
33
|
},
|
|
34
|
+
analyticsEvents: {
|
|
35
|
+
oneOf: [
|
|
36
|
+
Object.assign(Object.assign({}, event_1.AnalyticsEventSchema), { optionName: 'single' }),
|
|
37
|
+
{
|
|
38
|
+
type: 'array',
|
|
39
|
+
items: event_1.AnalyticsEventSchema,
|
|
40
|
+
optionName: 'list',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
33
44
|
},
|
|
34
45
|
} }),
|
|
35
46
|
};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.qaIdByDefault = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
6
|
const utils_1 = require("../../utils");
|
|
6
7
|
const Image_1 = tslib_1.__importDefault(require("../Image/Image"));
|
|
8
|
+
exports.qaIdByDefault = 'background-image';
|
|
7
9
|
const b = (0, utils_1.block)('storage-background-image');
|
|
8
10
|
const BackgroundImage = (props) => {
|
|
9
11
|
const { children, src, desktop, className, imageClassName, style, hide, qa } = props;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
const qaAttributes = (0, utils_1.getQaAttrubutes)(qa || exports.qaIdByDefault);
|
|
13
|
+
return (react_1.default.createElement("div", { className: b(null, className), style: style, "data-qa": qa || exports.qaIdByDefault },
|
|
14
|
+
(src || desktop) && !hide && (react_1.default.createElement(Image_1.default, Object.assign({}, props, { className: b('img', imageClassName), qa: qaAttributes.image }))),
|
|
12
15
|
children && react_1.default.createElement("div", { className: b('container') }, children)));
|
|
13
16
|
};
|
|
14
17
|
exports.default = BackgroundImage;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { BackgroundMediaProps } from '../../models';
|
|
2
|
-
declare const BackgroundMedia: ({ className, color, animated, parallax, video, mediaClassName, fullWidthMedia, ...props }: BackgroundMediaProps) => JSX.Element;
|
|
2
|
+
declare const BackgroundMedia: ({ className, color, animated, parallax, video, mediaClassName, fullWidthMedia, qa, ...props }: BackgroundMediaProps) => JSX.Element;
|
|
3
3
|
export default BackgroundMedia;
|
|
@@ -8,10 +8,11 @@ const AnimateBlock_1 = tslib_1.__importDefault(require("../AnimateBlock/AnimateB
|
|
|
8
8
|
const Media_1 = tslib_1.__importDefault(require("../Media/Media"));
|
|
9
9
|
const b = (0, utils_1.block)('BackgroundMedia');
|
|
10
10
|
const BackgroundMedia = (_a) => {
|
|
11
|
-
var { className, color, animated, parallax = true, video, mediaClassName, fullWidthMedia } = _a, props = tslib_1.__rest(_a, ["className", "color", "animated", "parallax", "video", "mediaClassName", "fullWidthMedia"]);
|
|
11
|
+
var { className, color, animated, parallax = true, video, mediaClassName, fullWidthMedia, qa } = _a, props = tslib_1.__rest(_a, ["className", "color", "animated", "parallax", "video", "mediaClassName", "fullWidthMedia", "qa"]);
|
|
12
12
|
const isMobile = (0, react_1.useContext)(mobileContext_1.MobileContext);
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const qaAttributes = (0, utils_1.getQaAttrubutes)(qa, 'media');
|
|
14
|
+
return (react_1.default.createElement(AnimateBlock_1.default, { className: b(null, className), style: { backgroundColor: color }, animate: animated, qa: qaAttributes.animate },
|
|
15
|
+
react_1.default.createElement(Media_1.default, Object.assign({ className: b('media', { 'full-width-media': fullWidthMedia }, mediaClassName), imageClassName: b('image'), videoClassName: b('video'), isBackground: true, qa: qaAttributes.media }, Object.assign({ height: 720, color,
|
|
15
16
|
parallax, video: isMobile ? undefined : video }, props)))));
|
|
16
17
|
};
|
|
17
18
|
exports.default = BackgroundMedia;
|
|
@@ -4,6 +4,7 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
5
|
const constants_1 = require("../../constants");
|
|
6
6
|
const projectSettingsContext_1 = require("../../context/projectSettingsContext");
|
|
7
|
+
const utils_1 = require("../../utils");
|
|
7
8
|
const imageCompress_1 = require("../../utils/imageCompress");
|
|
8
9
|
const ImageBase_1 = tslib_1.__importDefault(require("../ImageBase/ImageBase"));
|
|
9
10
|
const i18n_1 = tslib_1.__importDefault(require("./i18n"));
|
|
@@ -18,18 +19,19 @@ const Image = (props) => {
|
|
|
18
19
|
if (!src) {
|
|
19
20
|
return null;
|
|
20
21
|
}
|
|
22
|
+
const qaAttributes = (0, utils_1.getQaAttrubutes)(qa, 'mobile-webp-source', 'mobile-source', 'tablet-webp-source', 'tablet-source', 'display-source');
|
|
21
23
|
const disableWebp = projectSettings.disableCompress ||
|
|
22
24
|
disableCompress ||
|
|
23
25
|
!(0, imageCompress_1.isCompressible)(src) ||
|
|
24
26
|
imgLoadingError;
|
|
25
27
|
return (react_1.default.createElement("picture", { className: containerClassName, "data-qa": qa },
|
|
26
28
|
mobile && (react_1.default.createElement(react_1.Fragment, null,
|
|
27
|
-
!disableWebp && (react_1.default.createElement("source", { srcSet: checkWebP(mobile), type: "image/webp", media: `(max-width: ${constants_1.BREAKPOINTS.sm}px)
|
|
28
|
-
react_1.default.createElement("source", { srcSet: mobile, media: `(max-width: ${constants_1.BREAKPOINTS.sm}px)
|
|
29
|
+
!disableWebp && (react_1.default.createElement("source", { srcSet: checkWebP(mobile), type: "image/webp", media: `(max-width: ${constants_1.BREAKPOINTS.sm}px)`, "data-qa": qaAttributes.mobileWebpSource })),
|
|
30
|
+
react_1.default.createElement("source", { srcSet: mobile, media: `(max-width: ${constants_1.BREAKPOINTS.sm}px)`, "data-qa": qaAttributes.mobileSource }))),
|
|
29
31
|
tablet && (react_1.default.createElement(react_1.Fragment, null,
|
|
30
|
-
!disableWebp && (react_1.default.createElement("source", { srcSet: checkWebP(tablet), type: "image/webp", media: `(max-width: ${constants_1.BREAKPOINTS.md}px)
|
|
31
|
-
react_1.default.createElement("source", { srcSet: tablet, media: `(max-width: ${constants_1.BREAKPOINTS.md}px)
|
|
32
|
-
src && !disableWebp && react_1.default.createElement("source", { srcSet: checkWebP(src), type: "image/webp" }),
|
|
32
|
+
!disableWebp && (react_1.default.createElement("source", { srcSet: checkWebP(tablet), type: "image/webp", media: `(max-width: ${constants_1.BREAKPOINTS.md}px)`, "data-qa": qaAttributes.tabletWebpSource })),
|
|
33
|
+
react_1.default.createElement("source", { srcSet: tablet, media: `(max-width: ${constants_1.BREAKPOINTS.md}px)`, "data-qa": qaAttributes.tabletSource }))),
|
|
34
|
+
src && !disableWebp && (react_1.default.createElement("source", { srcSet: checkWebP(src), type: "image/webp", "data-qa": qaAttributes.displaySource })),
|
|
33
35
|
react_1.default.createElement(ImageBase_1.default, { className: className, alt: alt, src: src, style: style, onClick: onClick, onError: () => setImgLoadingError(true) })));
|
|
34
36
|
};
|
|
35
37
|
exports.default = Image;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MediaComponentImageProps } from '../../../models';
|
|
1
|
+
import { MediaComponentImageProps, QAProps } from '../../../models';
|
|
2
2
|
export interface ImageAdditionProps {
|
|
3
3
|
imageClassName?: string;
|
|
4
4
|
isBackground?: boolean;
|
|
@@ -7,6 +7,7 @@ export interface ImageAdditionProps {
|
|
|
7
7
|
interface InnerImageProps {
|
|
8
8
|
hasVideoFallback: boolean;
|
|
9
9
|
}
|
|
10
|
-
type ImageAllProps = ImageAdditionProps & MediaComponentImageProps & InnerImageProps;
|
|
10
|
+
type ImageAllProps = ImageAdditionProps & MediaComponentImageProps & InnerImageProps & QAProps;
|
|
11
|
+
export declare const defaultAnimatedDivQa = "animated-div";
|
|
11
12
|
declare const Image: (props: ImageAllProps) => JSX.Element;
|
|
12
13
|
export default Image;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultAnimatedDivQa = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
6
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
@@ -12,8 +13,10 @@ const FullscreenImage_1 = tslib_1.__importDefault(require("../../FullscreenImage
|
|
|
12
13
|
const Image_1 = tslib_1.__importDefault(require("../../Image/Image"));
|
|
13
14
|
const utils_2 = require("./utils");
|
|
14
15
|
const b = (0, utils_1.block)('media-component-image');
|
|
16
|
+
exports.defaultAnimatedDivQa = 'animated-div';
|
|
15
17
|
const Image = (props) => {
|
|
16
|
-
const { parallax, image, height, imageClassName, isBackground, hasVideoFallback, video, fullscreen, } = props;
|
|
18
|
+
const { parallax, image, height, imageClassName, isBackground, hasVideoFallback, video, fullscreen, qa, } = props;
|
|
19
|
+
const qaAttributes = (0, utils_1.getQaAttrubutes)(qa, 'fullscreen-image', 'animate', 'background-image', 'image-view', 'slider-block');
|
|
17
20
|
const [scrollY, setScrollY] = (0, react_1.useState)(0);
|
|
18
21
|
const [{ springScrollY }, springSetScrollY] = (0, react_spring_1.useSpring)(() => ({
|
|
19
22
|
springScrollY: 0,
|
|
@@ -37,16 +40,16 @@ const Image = (props) => {
|
|
|
37
40
|
const imageClass = b('item', { withVideo: Boolean(video) && !hasVideoFallback }, imageClassName);
|
|
38
41
|
const renderFullscreenImage = (item) => {
|
|
39
42
|
const itemData = (0, utils_2.getMediaImage)(item);
|
|
40
|
-
return (react_1.default.createElement(FullscreenImage_1.default, Object.assign({ key: itemData.alt }, itemData, { imageClassName: imageClass, imageStyle: { height } })));
|
|
43
|
+
return (react_1.default.createElement(FullscreenImage_1.default, Object.assign({ key: itemData.alt }, itemData, { imageClassName: imageClass, imageStyle: { height }, qa: qaAttributes.fullscreenImage })));
|
|
41
44
|
};
|
|
42
45
|
const imageBackground = (oneImage) => {
|
|
43
46
|
const imageData = (0, utils_2.getMediaImage)(oneImage);
|
|
44
|
-
return (react_1.default.createElement(react_spring_1.animated.div, { style: { transform: parallaxInterpolate
|
|
45
|
-
react_1.default.createElement(BackgroundImage_1.default, Object.assign({}, imageData, { className: imageClass, style: { height } }))));
|
|
47
|
+
return (react_1.default.createElement(react_spring_1.animated.div, { style: { transform: parallaxInterpolate }, "data-qa": qaAttributes.animate },
|
|
48
|
+
react_1.default.createElement(BackgroundImage_1.default, Object.assign({}, imageData, { className: imageClass, style: { height }, qa: qaAttributes.backgroundImage }))));
|
|
46
49
|
};
|
|
47
50
|
const imageOnly = (oneImage) => {
|
|
48
51
|
const imageData = (0, utils_2.getMediaImage)(oneImage);
|
|
49
|
-
return react_1.default.createElement(Image_1.default, Object.assign({}, imageData, { className: imageClass, style: { height } }));
|
|
52
|
+
return (react_1.default.createElement(Image_1.default, Object.assign({}, imageData, { className: imageClass, style: { height }, qa: qaAttributes.imageView })));
|
|
50
53
|
};
|
|
51
54
|
const imageSlider = (imageArray) => {
|
|
52
55
|
const fullscreenItem = fullscreen === undefined || fullscreen;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { MediaProps } from '../../models';
|
|
1
|
+
import { MediaProps, QAProps } from '../../models';
|
|
2
2
|
import { ImageAdditionProps } from './Image/Image';
|
|
3
3
|
import { VideoAdditionProps } from './Video/Video';
|
|
4
|
-
export interface MediaAllProps extends MediaProps, VideoAdditionProps, ImageAdditionProps {
|
|
4
|
+
export interface MediaAllProps extends MediaProps, VideoAdditionProps, ImageAdditionProps, QAProps {
|
|
5
5
|
className?: string;
|
|
6
6
|
youtubeClassName?: string;
|
|
7
7
|
}
|
|
@@ -11,12 +11,13 @@ const Image_1 = tslib_1.__importDefault(require("./Image/Image"));
|
|
|
11
11
|
const Video_1 = tslib_1.__importDefault(require("./Video/Video"));
|
|
12
12
|
const b = (0, utils_1.block)('Media');
|
|
13
13
|
const Media = (props) => {
|
|
14
|
-
const { image, video, youtube, dataLens, color, height, previewImg, parallax = false, metrika, fullscreen, analyticsEvents, className, imageClassName, videoClassName, youtubeClassName, playVideo = true, isBackground, playButton, customBarControlsClassName, } = props;
|
|
14
|
+
const { image, video, youtube, dataLens, color, height, previewImg, parallax = false, metrika, fullscreen, analyticsEvents, className, imageClassName, videoClassName, youtubeClassName, playVideo = true, isBackground, playButton, customBarControlsClassName, qa, } = props;
|
|
15
15
|
const [hasVideoFallback, setHasVideoFallback] = (0, react_1.useState)(false);
|
|
16
|
+
const qaAttributes = (0, utils_1.getQaAttrubutes)(qa, 'video');
|
|
16
17
|
const content = (0, react_1.useMemo)(() => {
|
|
17
18
|
let result = [];
|
|
18
19
|
if (image) {
|
|
19
|
-
result.push(react_1.default.createElement(Image_1.default, { key: "image", parallax: parallax, image: image, height: height, imageClassName: imageClassName, isBackground: isBackground, video: video, hasVideoFallback: hasVideoFallback, fullscreen: fullscreen }));
|
|
20
|
+
result.push(react_1.default.createElement(Image_1.default, { key: "image", parallax: parallax, image: image, height: height, imageClassName: imageClassName, isBackground: isBackground, video: video, hasVideoFallback: hasVideoFallback, fullscreen: fullscreen, qa: qaAttributes.image }));
|
|
20
21
|
}
|
|
21
22
|
if (video) {
|
|
22
23
|
const videoProps = {
|
|
@@ -34,10 +35,10 @@ const Media = (props) => {
|
|
|
34
35
|
setHasVideoFallback,
|
|
35
36
|
};
|
|
36
37
|
if (fullscreen) {
|
|
37
|
-
result.push(react_1.default.createElement(FullscreenVideo_1.default, Object.assign({}, videoProps)));
|
|
38
|
+
result.push(react_1.default.createElement(FullscreenVideo_1.default, Object.assign({}, videoProps, { qa: qaAttributes.video })));
|
|
38
39
|
}
|
|
39
40
|
else {
|
|
40
|
-
result.push(react_1.default.createElement(Video_1.default, Object.assign({}, videoProps)));
|
|
41
|
+
result.push(react_1.default.createElement(Video_1.default, Object.assign({}, videoProps, { qa: qaAttributes.video })));
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
if (youtube) {
|
|
@@ -57,6 +58,9 @@ const Media = (props) => {
|
|
|
57
58
|
imageClassName,
|
|
58
59
|
isBackground,
|
|
59
60
|
hasVideoFallback,
|
|
61
|
+
fullscreen,
|
|
62
|
+
qaAttributes.image,
|
|
63
|
+
qaAttributes.video,
|
|
60
64
|
videoClassName,
|
|
61
65
|
metrika,
|
|
62
66
|
analyticsEvents,
|
|
@@ -65,9 +69,8 @@ const Media = (props) => {
|
|
|
65
69
|
playButton,
|
|
66
70
|
customBarControlsClassName,
|
|
67
71
|
youtubeClassName,
|
|
68
|
-
fullscreen,
|
|
69
72
|
]);
|
|
70
|
-
return (react_1.default.createElement("div", { className: b(null, className), style: { backgroundColor: color } }, content));
|
|
73
|
+
return (react_1.default.createElement("div", { className: b(null, className), style: { backgroundColor: color }, "data-qa": qa }, content));
|
|
71
74
|
};
|
|
72
75
|
exports.Media = Media;
|
|
73
76
|
exports.default = exports.Media;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { MediaComponentVideoProps, PlayButtonProps } from '../../../models';
|
|
2
|
+
import { MediaComponentVideoProps, PlayButtonProps, QAProps } from '../../../models';
|
|
3
3
|
export interface VideoAdditionProps {
|
|
4
4
|
playButton?: PlayButtonProps;
|
|
5
5
|
customBarControlsClassName?: string;
|
|
@@ -10,6 +10,6 @@ interface InnerVideoProps {
|
|
|
10
10
|
setHasVideoFallback: React.Dispatch<boolean>;
|
|
11
11
|
hasVideoFallback: boolean;
|
|
12
12
|
}
|
|
13
|
-
export type VideoAllProps = VideoAdditionProps & MediaComponentVideoProps & InnerVideoProps;
|
|
13
|
+
export type VideoAllProps = VideoAdditionProps & MediaComponentVideoProps & InnerVideoProps & QAProps;
|
|
14
14
|
declare const Video: (props: VideoAllProps) => JSX.Element | null;
|
|
15
15
|
export default Video;
|
|
@@ -8,7 +8,8 @@ const ReactPlayer_1 = tslib_1.__importDefault(require("../../ReactPlayer/ReactPl
|
|
|
8
8
|
const utils_2 = require("./utils");
|
|
9
9
|
const b = (0, utils_1.block)('media-component-video');
|
|
10
10
|
const Video = (props) => {
|
|
11
|
-
const { video, height, metrika, analyticsEvents, previewImg, playButton: commonPlayButton, customBarControlsClassName, videoClassName, playVideo, setHasVideoFallback, hasVideoFallback, } = props;
|
|
11
|
+
const { video, height, metrika, analyticsEvents, previewImg, playButton: commonPlayButton, customBarControlsClassName, videoClassName, playVideo, setHasVideoFallback, hasVideoFallback, qa, } = props;
|
|
12
|
+
const qaAttributes = (0, utils_1.getQaAttrubutes)(qa, 'source');
|
|
12
13
|
const ref = (0, react_1.useRef)(null);
|
|
13
14
|
(0, react_1.useEffect)(() => {
|
|
14
15
|
if (ref && ref.current) {
|
|
@@ -44,12 +45,20 @@ const Video = (props) => {
|
|
|
44
45
|
analyticsEvents,
|
|
45
46
|
]);
|
|
46
47
|
const defaultVideoBlock = (0, react_1.useMemo)(() => {
|
|
47
|
-
return video.src.length && !hasVideoFallback ? (react_1.default.createElement("div", { className: b('wrap', videoClassName), style: { height } },
|
|
48
|
+
return video.src.length && !hasVideoFallback ? (react_1.default.createElement("div", { className: b('wrap', videoClassName), style: { height }, "data-qa": qaAttributes.default },
|
|
48
49
|
react_1.default.createElement("video", { disablePictureInPicture: true, playsInline: true,
|
|
49
50
|
// @ts-ignore
|
|
50
51
|
// eslint-disable-next-line react/no-unknown-property
|
|
51
|
-
pip: "false", className: b('item'), ref: ref, preload: "metadata", muted: true, "aria-label": video.ariaLabel }, (0, utils_2.getVideoTypesWithPriority)(video.src).map(({ src, type }, index) => (react_1.default.createElement("source", { key: index, src: src, type: type })))))) : null;
|
|
52
|
-
}, [
|
|
52
|
+
pip: "false", className: b('item'), ref: ref, preload: "metadata", muted: true, "aria-label": video.ariaLabel }, (0, utils_2.getVideoTypesWithPriority)(video.src).map(({ src, type }, index) => (react_1.default.createElement("source", { key: index, src: src, type: type, "data-qa": qaAttributes.source })))))) : null;
|
|
53
|
+
}, [
|
|
54
|
+
video.src,
|
|
55
|
+
video.ariaLabel,
|
|
56
|
+
hasVideoFallback,
|
|
57
|
+
videoClassName,
|
|
58
|
+
height,
|
|
59
|
+
qaAttributes.default,
|
|
60
|
+
qaAttributes.source,
|
|
61
|
+
]);
|
|
53
62
|
switch (video.type) {
|
|
54
63
|
case models_1.MediaVideoType.Player:
|
|
55
64
|
return reactPlayerBlock;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { ButtonSize } from '@gravity-ui/uikit';
|
|
3
3
|
import { GridColumnSize, GridColumnSizesType } from '../../grid/types';
|
|
4
4
|
import { ThemeSupporting } from '../../utils';
|
|
5
|
+
import { AnalyticsEventsBase } from '../common';
|
|
5
6
|
import { AnchorProps, Animatable, BackgroundImageProps, ButtonProps, ContentSize, ContentTextSize, ContentTheme, FileLinkProps, HeaderBreadCrumbsProps, HeaderImageSize, HeaderOffset, HeaderWidth, ImageDeviceProps, Justify, LegendTableMarkerType, LinkProps, MapProps, MediaDirection, MediaProps, TextSize, TextTheme, ThemedImage, ThemedMediaProps, ThemedMediaVideoProps, TitleItemBaseProps, TitleItemProps } from './common';
|
|
6
7
|
import { BannerCardProps, SubBlock, SubBlockModels } from './sub-blocks';
|
|
7
8
|
export declare enum BlockType {
|
|
@@ -241,14 +242,15 @@ export interface FilterBlockProps extends Animatable, LoadableChildren {
|
|
|
241
242
|
colSizes?: GridColumnSizesType;
|
|
242
243
|
centered?: boolean;
|
|
243
244
|
}
|
|
245
|
+
export interface IconsBlockItemProps extends AnalyticsEventsBase {
|
|
246
|
+
url: string;
|
|
247
|
+
text: string;
|
|
248
|
+
src: string;
|
|
249
|
+
}
|
|
244
250
|
export interface IconsBlockProps {
|
|
245
251
|
title?: string;
|
|
246
252
|
size?: 's' | 'm' | 'l';
|
|
247
|
-
items:
|
|
248
|
-
url: string;
|
|
249
|
-
text: string;
|
|
250
|
-
src: string;
|
|
251
|
-
}[];
|
|
253
|
+
items: IconsBlockItemProps[];
|
|
252
254
|
}
|
|
253
255
|
interface ContentLayoutBlockParams {
|
|
254
256
|
size?: ContentSize;
|
|
@@ -186,7 +186,7 @@ export interface MediaComponentDataLensProps {
|
|
|
186
186
|
export interface MediaProps extends Animatable, Partial<MediaComponentDataLensProps>, Partial<MediaComponentYoutubeProps>, Partial<MediaComponentImageProps>, Partial<MediaComponentVideoProps> {
|
|
187
187
|
color?: string;
|
|
188
188
|
}
|
|
189
|
-
export interface BackgroundMediaProps extends MediaProps, Animatable {
|
|
189
|
+
export interface BackgroundMediaProps extends MediaProps, Animatable, QAProps {
|
|
190
190
|
fullWidthMedia?: boolean;
|
|
191
191
|
className?: string;
|
|
192
192
|
mediaClassName?: string;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
+
import { MarkdownItPluginCb } from '@doc-tools/transform/lib/plugins/typings';
|
|
1
2
|
import { Lang } from '../utils/configure';
|
|
2
3
|
export type ComplexItem = {
|
|
3
4
|
[key: string]: string;
|
|
4
5
|
};
|
|
5
6
|
export type Item = string | null | ComplexItem;
|
|
6
7
|
export type Transformer = (text: string) => string;
|
|
7
|
-
export type TransformerRaw = (lang: Lang, content: string
|
|
8
|
+
export type TransformerRaw = (lang: Lang, content: string, options: {
|
|
9
|
+
plugins: MarkdownItPluginCb[];
|
|
10
|
+
}) => string;
|
|
8
11
|
export type Parser<T = any> = (transformer: Transformer, block: T) => T;
|
|
9
12
|
export declare const createItemsParser: (fields: string[]) => (transformer: Transformer, items: Item[]) => (string | {
|
|
10
13
|
[x: string]: string;
|
|
11
14
|
} | null)[];
|
|
12
|
-
export declare function yfmTransformer(lang: Lang, content: string
|
|
15
|
+
export declare function yfmTransformer(lang: Lang, content: string, options?: {
|
|
16
|
+
plugins?: MarkdownItPluginCb[];
|
|
17
|
+
}): string;
|
|
13
18
|
export declare function typografTransformer(lang: Lang, content: string): string;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.typografTransformer = exports.yfmTransformer = exports.createItemsParser = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const plugins_1 = tslib_1.__importDefault(require("@doc-tools/transform/lib/plugins"));
|
|
4
6
|
const utils_1 = require("./utils");
|
|
5
7
|
const createItemsParser = (fields) => (transformer, items) => items.map((item) => {
|
|
6
8
|
if (!item) {
|
|
@@ -20,8 +22,12 @@ const createItemsParser = (fields) => (transformer, items) => items.map((item) =
|
|
|
20
22
|
}
|
|
21
23
|
});
|
|
22
24
|
exports.createItemsParser = createItemsParser;
|
|
23
|
-
function yfmTransformer(lang, content) {
|
|
24
|
-
const {
|
|
25
|
+
function yfmTransformer(lang, content, options = {}) {
|
|
26
|
+
const { plugins = [] } = options;
|
|
27
|
+
const { html } = (0, utils_1.fullTransform)(content, {
|
|
28
|
+
lang,
|
|
29
|
+
plugins: [...plugins_1.default, ...plugins],
|
|
30
|
+
});
|
|
25
31
|
return html;
|
|
26
32
|
}
|
|
27
33
|
exports.yfmTransformer = yfmTransformer;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MarkdownItPluginCb } from '@doc-tools/transform/lib/plugins/typings';
|
|
1
2
|
import { ConstructorBlock } from '../models/constructor';
|
|
2
3
|
import { Lang } from '../utils/configure';
|
|
3
4
|
export type ContentVariables = Record<string, string>;
|
|
@@ -9,6 +10,7 @@ export type ContentTransformerProps = {
|
|
|
9
10
|
lang: Lang;
|
|
10
11
|
customConfig?: {};
|
|
11
12
|
vars?: ContentVariables;
|
|
13
|
+
plugins?: MarkdownItPluginCb[];
|
|
12
14
|
};
|
|
13
15
|
};
|
|
14
16
|
export declare const contentTransformer: ({ content, options }: ContentTransformerProps) => {
|
|
@@ -2,17 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.contentTransformer = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
/* eslint-disable no-param-reassign */
|
|
6
|
-
/* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
7
5
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
8
6
|
const config_1 = require("./config");
|
|
9
7
|
const filter_1 = require("./filter");
|
|
10
|
-
function transformBlocks(blocks, lang, customConfig = {}) {
|
|
8
|
+
function transformBlocks(blocks, lang, customConfig = {}, options = {}) {
|
|
11
9
|
const fullConfig = Object.assign(Object.assign({}, config_1.config), customConfig);
|
|
10
|
+
const { plugins = [] } = options;
|
|
12
11
|
const clonedBlocks = lodash_1.default.cloneDeep(blocks);
|
|
13
|
-
return clonedBlocks.map((block) => transformBlock(lang, fullConfig, block));
|
|
12
|
+
return clonedBlocks.map((block) => transformBlock(lang, fullConfig, block, plugins));
|
|
14
13
|
}
|
|
15
|
-
function transformBlock(lang, blocksConfig, block) {
|
|
14
|
+
function transformBlock(lang, blocksConfig, block, plugins) {
|
|
16
15
|
const blockConfig = blocksConfig[block.type];
|
|
17
16
|
if (block) {
|
|
18
17
|
if ('randomOrder' in block && block.randomOrder && 'children' in block && block.children) {
|
|
@@ -23,7 +22,9 @@ function transformBlock(lang, blocksConfig, block) {
|
|
|
23
22
|
const configs = Array.isArray(blockConfig) ? blockConfig : [blockConfig];
|
|
24
23
|
configs.forEach((transformConfig) => {
|
|
25
24
|
const { fields, transformer: transformerRaw, parser } = transformConfig;
|
|
26
|
-
const transformer =
|
|
25
|
+
const transformer = (content) =>
|
|
26
|
+
// eslint-disable-next-line no-useless-call
|
|
27
|
+
transformerRaw.call(null, lang, content, { plugins });
|
|
27
28
|
if (fields) {
|
|
28
29
|
fields.forEach((field) => {
|
|
29
30
|
if (block[field]) {
|
|
@@ -47,9 +48,11 @@ function transformBlock(lang, blocksConfig, block) {
|
|
|
47
48
|
return block;
|
|
48
49
|
}
|
|
49
50
|
const contentTransformer = ({ content, options }) => {
|
|
50
|
-
const { lang, customConfig = {}, vars } = options;
|
|
51
|
+
const { lang, customConfig = {}, vars, plugins = [] } = options;
|
|
51
52
|
const { blocks = [] } = (vars ? (0, filter_1.filterContent)(content, vars) : content);
|
|
52
|
-
const transformedBlocks = transformBlocks(blocks, lang, customConfig
|
|
53
|
+
const transformedBlocks = transformBlocks(blocks, lang, customConfig, {
|
|
54
|
+
plugins,
|
|
55
|
+
});
|
|
53
56
|
return {
|
|
54
57
|
blocks: transformedBlocks,
|
|
55
58
|
};
|
|
@@ -7,4 +7,4 @@ export declare const getCustomTypes: (types: (keyof CustomConfig)[], customBlock
|
|
|
7
7
|
export declare const getOrderedBlocks: (blocks: ConstructorBlock[], headerBlockTypes?: string[]) => ConstructorBlock[];
|
|
8
8
|
export declare const getHeaderBlock: (blocks: ConstructorBlock[], headerBlockTypes?: string[]) => ConstructorBlock | undefined;
|
|
9
9
|
export declare const getShareLink: (url: string, type: PCShareSocialNetwork, title?: string, text?: string) => string | undefined;
|
|
10
|
-
export declare const getQaAttrubutes: (qa?: string, customKeys
|
|
10
|
+
export declare const getQaAttrubutes: (qa?: string, ...customKeys: (string | Array<string>)[]) => Record<string, string>;
|