@gravity-ui/page-constructor 4.5.3 → 4.6.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/Slider/Arrow/Arrow.js +2 -1
- package/build/cjs/blocks/Slider/Slider.css +4 -1
- package/build/cjs/blocks/Slider/Slider.js +32 -6
- package/build/cjs/blocks/Slider/i18n/en.json +4 -0
- package/build/cjs/blocks/Slider/i18n/index.d.ts +2 -0
- package/build/cjs/blocks/Slider/i18n/index.js +8 -0
- package/build/cjs/blocks/Slider/i18n/ru.json +4 -0
- package/build/cjs/components/HTML/HTML.d.ts +3 -1
- package/build/cjs/components/HTML/HTML.js +2 -1
- package/build/cjs/components/Link/Link.d.ts +2 -1
- package/build/cjs/components/Link/Link.js +4 -2
- package/build/cjs/components/YFMWrapper/YFMWrapper.d.ts +3 -2
- package/build/cjs/components/YFMWrapper/YFMWrapper.js +1 -1
- package/build/cjs/constructor-items.d.ts +1 -1
- package/build/cjs/sub-blocks/Content/Content.d.ts +3 -1
- package/build/cjs/sub-blocks/Content/Content.js +7 -5
- package/build/cjs/sub-blocks/Content/ContentList/ContentList.d.ts +2 -1
- package/build/cjs/sub-blocks/Content/ContentList/ContentList.js +7 -5
- package/build/cjs/utils/blocks.d.ts +1 -0
- package/build/cjs/utils/blocks.js +14 -1
- package/build/esm/blocks/Slider/Arrow/Arrow.js +2 -1
- package/build/esm/blocks/Slider/Slider.css +4 -1
- package/build/esm/blocks/Slider/Slider.js +33 -7
- package/build/esm/blocks/Slider/i18n/en.json +4 -0
- package/build/esm/blocks/Slider/i18n/index.d.ts +2 -0
- package/build/esm/blocks/Slider/i18n/index.js +5 -0
- package/build/esm/blocks/Slider/i18n/ru.json +4 -0
- package/build/esm/components/HTML/HTML.d.ts +3 -1
- package/build/esm/components/HTML/HTML.js +2 -1
- package/build/esm/components/Link/Link.d.ts +2 -1
- package/build/esm/components/Link/Link.js +4 -2
- package/build/esm/components/YFMWrapper/YFMWrapper.d.ts +3 -2
- package/build/esm/components/YFMWrapper/YFMWrapper.js +1 -1
- package/build/esm/constructor-items.d.ts +1 -1
- package/build/esm/sub-blocks/Content/Content.d.ts +3 -1
- package/build/esm/sub-blocks/Content/Content.js +7 -5
- package/build/esm/sub-blocks/Content/ContentList/ContentList.d.ts +2 -1
- package/build/esm/sub-blocks/Content/ContentList/ContentList.js +7 -5
- package/build/esm/utils/blocks.d.ts +1 -0
- package/build/esm/utils/blocks.js +12 -0
- package/package.json +1 -1
- package/server/utils/blocks.d.ts +1 -0
- package/server/utils/blocks.js +14 -1
- package/widget/index.js +1 -1
|
@@ -3,6 +3,7 @@ import { Button, Title, YFMWrapper } from '../../components';
|
|
|
3
3
|
import LinkBlock from '../../components/Link/Link';
|
|
4
4
|
import { Col } from '../../grid';
|
|
5
5
|
import { block } from '../../utils';
|
|
6
|
+
import { getQaAttrubutes } from '../../utils/blocks';
|
|
6
7
|
import ContentList from './ContentList/ContentList';
|
|
7
8
|
import './Content.css';
|
|
8
9
|
const b = block('content');
|
|
@@ -34,23 +35,24 @@ function getButtonSize(size) {
|
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
const Content = (props) => {
|
|
37
|
-
const { title, text, additionalInfo, size = 'l', links, buttons, colSizes = { all: 12, sm: 8 }, centered, theme, className, list, } = props;
|
|
38
|
+
const { title, text, additionalInfo, size = 'l', links, buttons, colSizes = { all: 12, sm: 8 }, centered, theme, className, list, qa, } = props;
|
|
39
|
+
const qaAttributes = getQaAttrubutes(qa, ['links', 'link', 'buttons', 'button', 'list']);
|
|
38
40
|
const titleProps = !title || typeof title === 'string'
|
|
39
41
|
? { text: title, textSize: getTextSize(size) }
|
|
40
42
|
: title;
|
|
41
43
|
const hasTitle = Boolean(title);
|
|
42
|
-
return (React.createElement(Col, { className: b({ size, centered, theme }, className), reset: true, sizes: colSizes },
|
|
44
|
+
return (React.createElement(Col, { className: b({ size, centered, theme }, className), reset: true, sizes: colSizes, qa: qaAttributes.container },
|
|
43
45
|
title && React.createElement(Title, { className: b('title'), title: titleProps, colSizes: { all: 12 } }),
|
|
44
46
|
text && (React.createElement("div", { className: b('text', { ['without-title']: !hasTitle }) },
|
|
45
47
|
React.createElement(YFMWrapper, { content: text, modifiers: { constructor: true, [`constructor-size-${size}`]: true } }))),
|
|
46
|
-
(list === null || list === void 0 ? void 0 : list.length) ? React.createElement(ContentList, { list: list, size: size }) : null,
|
|
48
|
+
(list === null || list === void 0 ? void 0 : list.length) ? React.createElement(ContentList, { list: list, size: size, qa: qaAttributes.list }) : null,
|
|
47
49
|
additionalInfo && (React.createElement("div", { className: b('notice') },
|
|
48
50
|
React.createElement(YFMWrapper, { content: additionalInfo, modifiers: {
|
|
49
51
|
constructor: true,
|
|
50
52
|
'constructor-notice': true,
|
|
51
53
|
[`constructor-size-${size}`]: true,
|
|
52
54
|
} }))),
|
|
53
|
-
links && (React.createElement("div", { className: b('links') }, links.map((link) => (React.createElement(LinkBlock, Object.assign({ className: b('link') }, link, { textSize: getLinkSize(size), key: link.url })))))),
|
|
54
|
-
buttons && (React.createElement("div", { className: b('buttons') }, buttons.map((item) => (React.createElement(Button, Object.assign({ className: b('button') }, item, { key: item.url, size: getButtonSize(size) }))))))));
|
|
55
|
+
links && (React.createElement("div", { className: b('links'), "data-qa": qaAttributes.links }, links.map((link) => (React.createElement(LinkBlock, Object.assign({ className: b('link') }, link, { textSize: getLinkSize(size), key: link.url, qa: qaAttributes.link })))))),
|
|
56
|
+
buttons && (React.createElement("div", { className: b('buttons'), "data-qa": qaAttributes.buttons }, buttons.map((item) => (React.createElement(Button, Object.assign({ className: b('button') }, item, { key: item.url, size: getButtonSize(size), qa: qaAttributes.button }))))))));
|
|
55
57
|
};
|
|
56
58
|
export default Content;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ContentItemProps, ContentSize } from '../../../models';
|
|
2
|
+
import { QAProps } from '../../../models/common';
|
|
2
3
|
import './ContentList.css';
|
|
3
4
|
interface ContentListProps {
|
|
4
5
|
list: ContentItemProps[];
|
|
5
6
|
size: ContentSize;
|
|
6
7
|
}
|
|
7
|
-
declare const ContentList: ({ list, size }: ContentListProps) => JSX.Element;
|
|
8
|
+
declare const ContentList: ({ list, size, qa }: ContentListProps & QAProps) => JSX.Element;
|
|
8
9
|
export default ContentList;
|
|
@@ -5,6 +5,7 @@ import Image from '../../../components/Image/Image';
|
|
|
5
5
|
import { getMediaImage } from '../../../components/Media/Image/utils';
|
|
6
6
|
import { useTheme } from '../../../context/theme';
|
|
7
7
|
import { block, getThemedValue } from '../../../utils';
|
|
8
|
+
import { getQaAttrubutes } from '../../../utils/blocks';
|
|
8
9
|
import './ContentList.css';
|
|
9
10
|
const b = block('content-list');
|
|
10
11
|
function getHeadingLevel(size) {
|
|
@@ -16,18 +17,19 @@ function getHeadingLevel(size) {
|
|
|
16
17
|
return 'h3';
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
|
-
const ContentList = ({ list, size }) => {
|
|
20
|
+
const ContentList = ({ list, size, qa }) => {
|
|
20
21
|
const theme = useTheme();
|
|
21
|
-
|
|
22
|
+
const qaAttributes = getQaAttrubutes(qa, ['image', 'title', 'text']);
|
|
23
|
+
return (React.createElement("div", { className: b({ size }), "data-qa": qa }, list === null || list === void 0 ? void 0 : list.map((item) => {
|
|
22
24
|
const { icon, title, text } = item;
|
|
23
25
|
const iconThemed = getThemedValue(icon, theme);
|
|
24
26
|
const iconData = getMediaImage(iconThemed);
|
|
25
27
|
return (React.createElement("div", { className: b('item'), key: uuidv4() },
|
|
26
|
-
React.createElement(Image, Object.assign({}, iconData, { className: b('icon') })),
|
|
28
|
+
React.createElement(Image, Object.assign({}, iconData, { className: b('icon'), qa: qaAttributes.image })),
|
|
27
29
|
React.createElement("div", null,
|
|
28
30
|
title &&
|
|
29
|
-
React.createElement(getHeadingLevel(size), { className: b('title') }, title),
|
|
30
|
-
text && (React.createElement(YFMWrapper, { className: b('text'), content: text, modifiers: { constructor: true } })))));
|
|
31
|
+
React.createElement(getHeadingLevel(size), { className: b('title'), 'data-qa': qaAttributes.title }, title),
|
|
32
|
+
text && (React.createElement(YFMWrapper, { className: b('text'), content: text, modifiers: { constructor: true }, qa: qaAttributes.text })))));
|
|
31
33
|
})));
|
|
32
34
|
};
|
|
33
35
|
export default ContentList;
|
|
@@ -7,3 +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?: Array<string>) => Record<string, string>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { camelCase } from 'lodash';
|
|
1
2
|
import { PCShareSocialNetwork } from '../models';
|
|
2
3
|
const BLOCK_ELEMENTS = [
|
|
3
4
|
'div',
|
|
@@ -36,6 +37,7 @@ const BLOCK_ELEMENTS = [
|
|
|
36
37
|
'td',
|
|
37
38
|
];
|
|
38
39
|
const BLOCK_ELEMENTS_REGEX = `<(${BLOCK_ELEMENTS.join('|')})[^>]*>`;
|
|
40
|
+
const QA_ATTRIBUTES_KEYS = ['container', 'content', 'wrapper', 'image', 'button'];
|
|
39
41
|
export function getHeaderTag(size) {
|
|
40
42
|
switch (size) {
|
|
41
43
|
case 'l':
|
|
@@ -109,3 +111,13 @@ export const getShareLink = (url, type, title, text) => {
|
|
|
109
111
|
return undefined;
|
|
110
112
|
}
|
|
111
113
|
};
|
|
114
|
+
export const getQaAttrubutes = (qa, customKeys = []) => {
|
|
115
|
+
const attributes = {};
|
|
116
|
+
if (qa) {
|
|
117
|
+
const keys = QA_ATTRIBUTES_KEYS.concat(customKeys);
|
|
118
|
+
keys.forEach((key) => {
|
|
119
|
+
attributes[camelCase(key)] = `${qa}-${key}`;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return attributes;
|
|
123
|
+
};
|
package/package.json
CHANGED
package/server/utils/blocks.d.ts
CHANGED
|
@@ -7,3 +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?: Array<string>) => Record<string, string>;
|
package/server/utils/blocks.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getShareLink = exports.getHeaderBlock = exports.getOrderedBlocks = exports.getCustomTypes = exports.getCustomItems = exports.getBlockKey = exports.hasBlockTag = exports.getHeaderTag = void 0;
|
|
3
|
+
exports.getQaAttrubutes = exports.getShareLink = exports.getHeaderBlock = exports.getOrderedBlocks = exports.getCustomTypes = exports.getCustomItems = exports.getBlockKey = exports.hasBlockTag = exports.getHeaderTag = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
4
5
|
const models_1 = require("../models");
|
|
5
6
|
const BLOCK_ELEMENTS = [
|
|
6
7
|
'div',
|
|
@@ -39,6 +40,7 @@ const BLOCK_ELEMENTS = [
|
|
|
39
40
|
'td',
|
|
40
41
|
];
|
|
41
42
|
const BLOCK_ELEMENTS_REGEX = `<(${BLOCK_ELEMENTS.join('|')})[^>]*>`;
|
|
43
|
+
const QA_ATTRIBUTES_KEYS = ['container', 'content', 'wrapper', 'image', 'button'];
|
|
42
44
|
function getHeaderTag(size) {
|
|
43
45
|
switch (size) {
|
|
44
46
|
case 'l':
|
|
@@ -120,3 +122,14 @@ const getShareLink = (url, type, title, text) => {
|
|
|
120
122
|
}
|
|
121
123
|
};
|
|
122
124
|
exports.getShareLink = getShareLink;
|
|
125
|
+
const getQaAttrubutes = (qa, customKeys = []) => {
|
|
126
|
+
const attributes = {};
|
|
127
|
+
if (qa) {
|
|
128
|
+
const keys = QA_ATTRIBUTES_KEYS.concat(customKeys);
|
|
129
|
+
keys.forEach((key) => {
|
|
130
|
+
attributes[(0, lodash_1.camelCase)(key)] = `${qa}-${key}`;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return attributes;
|
|
134
|
+
};
|
|
135
|
+
exports.getQaAttrubutes = getQaAttrubutes;
|