@gravity-ui/page-constructor 2.16.0 → 2.18.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 +19 -0
- package/build/cjs/blocks/Slider/Slider.css +88 -0
- package/build/cjs/blocks/Slider/Slider.js +0 -2
- package/build/cjs/components/Anchor/Anchor.d.ts +2 -2
- package/build/cjs/components/Anchor/Anchor.js +1 -1
- package/build/cjs/components/Map/YMap/YandexMap.js +1 -1
- package/build/cjs/components/ReactPlayer/ReactPlayer.js +1 -1
- package/build/cjs/components/VideoBlock/VideoBlock.js +1 -1
- package/build/cjs/components/YFMWrapper/YFMWrapper.js +1 -1
- package/build/cjs/containers/Loadable/Loadable.js +1 -1
- package/build/cjs/grid/Col/Col.d.ts +1 -1
- package/build/cjs/internal-typings/global.d.ts +18 -16
- 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/text-transform/blocks.js +2 -8
- package/build/cjs/text-transform/utils.d.ts +1 -1
- package/build/cjs/text-transform/utils.js +2 -2
- package/build/cjs/utils/scroll.js +1 -1
- package/build/esm/blocks/Slider/Slider.css +88 -0
- package/build/esm/blocks/Slider/Slider.d.ts +0 -1
- package/build/esm/blocks/Slider/Slider.js +0 -3
- package/build/esm/components/Anchor/Anchor.d.ts +2 -2
- package/build/esm/components/Anchor/Anchor.js +1 -1
- package/build/esm/components/Map/YMap/YandexMap.js +1 -1
- package/build/esm/components/ReactPlayer/ReactPlayer.js +1 -1
- package/build/esm/components/VideoBlock/VideoBlock.js +1 -1
- package/build/esm/components/YFMWrapper/YFMWrapper.js +1 -1
- package/build/esm/containers/Loadable/Loadable.js +1 -1
- package/build/esm/grid/Col/Col.d.ts +1 -1
- package/build/esm/internal-typings/global.d.ts +18 -16
- 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/text-transform/blocks.js +2 -8
- package/build/esm/text-transform/utils.d.ts +1 -1
- package/build/esm/text-transform/utils.js +2 -2
- package/build/esm/utils/scroll.js +1 -1
- package/package.json +1 -1
- package/server/text-transform/blocks.js +2 -8
- package/server/text-transform/utils.d.ts +1 -1
- package/server/text-transform/utils.js +2 -2
- package/server/utils/scroll.js +1 -1
- package/build/cjs/components/Anchor/__tests__/Anchor.test.d.ts +0 -1
- package/build/cjs/components/Anchor/__tests__/Anchor.test.js +0 -21
- package/build/cjs/components/AnimateBlock/__tests__/AnimateBlock.test.d.ts +0 -1
- 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
|
@@ -10,22 +10,17 @@ declare module '*.svg' {
|
|
|
10
10
|
export default path;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
portalId: string;
|
|
15
|
-
formId: string;
|
|
16
|
-
region?: string;
|
|
17
|
-
target?: string;
|
|
18
|
-
cssClass?: string;
|
|
19
|
-
formInstanceId?: string;
|
|
20
|
-
}
|
|
13
|
+
declare module '*.md';
|
|
21
14
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
declare namespace Hbspt {
|
|
16
|
+
interface CreateFormProps {
|
|
17
|
+
portalId: string;
|
|
18
|
+
formId: string;
|
|
19
|
+
region?: string;
|
|
20
|
+
target?: string;
|
|
21
|
+
cssClass?: string;
|
|
22
|
+
formInstanceId?: string;
|
|
23
|
+
}
|
|
29
24
|
}
|
|
30
25
|
|
|
31
26
|
declare namespace Ymaps {
|
|
@@ -63,4 +58,11 @@ declare namespace Ymaps {
|
|
|
63
58
|
}
|
|
64
59
|
}
|
|
65
60
|
|
|
66
|
-
|
|
61
|
+
interface Window {
|
|
62
|
+
hbspt?: {
|
|
63
|
+
forms: {
|
|
64
|
+
create: (args: Hbspt.CreateFormProps) => unknown;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
ymaps: Ymaps;
|
|
68
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { HubspotFormProps } from '../../models';
|
|
2
3
|
type HubspotFormContainerPropsKeys = 'className' | 'formId' | 'formInstanceId' | 'portalId' | 'region' | 'formClassName' | 'createDOMElement';
|
|
3
4
|
type HubspotFormContainerProps = Pick<HubspotFormProps, HubspotFormContainerPropsKeys>;
|
|
4
|
-
declare const HubspotFormContainer:
|
|
5
|
+
declare const HubspotFormContainer: React.ForwardRefExoticComponent<HubspotFormContainerProps & React.RefAttributes<HTMLDivElement>>;
|
|
5
6
|
export default HubspotFormContainer;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import React, { useRef } from 'react';
|
|
1
|
+
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
2
2
|
import { useMount } from '../../hooks';
|
|
3
3
|
import loadHubspotScript from './loadHubspotScript';
|
|
4
|
-
const HubspotFormContainer = (props) => {
|
|
4
|
+
const HubspotFormContainer = forwardRef((props, ref) => {
|
|
5
5
|
const { className, formId, formInstanceId, portalId, region, formClassName, createDOMElement, } = props;
|
|
6
6
|
const containerRef = useRef(null);
|
|
7
7
|
const hsContainerRef = useRef();
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
9
|
+
useImperativeHandle(ref, () => containerRef.current);
|
|
8
10
|
const containerId = formInstanceId
|
|
9
11
|
? `hubspot-form-${formId}-${formInstanceId}`
|
|
10
12
|
: `hubspot-form-${formId}`;
|
|
@@ -42,5 +44,6 @@ const HubspotFormContainer = (props) => {
|
|
|
42
44
|
};
|
|
43
45
|
});
|
|
44
46
|
return React.createElement("div", { className: className, id: containerId, ref: containerRef });
|
|
45
|
-
};
|
|
47
|
+
});
|
|
48
|
+
HubspotFormContainer.displayName = 'HubspotFormContainer';
|
|
46
49
|
export default HubspotFormContainer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { HubspotFormProps } from '../../models';
|
|
3
3
|
import './HubspotForm.css';
|
|
4
|
-
declare const HubspotForm: React.
|
|
4
|
+
declare const HubspotForm: React.ForwardRefExoticComponent<HubspotFormProps & React.RefAttributes<HTMLDivElement>>;
|
|
5
5
|
export default HubspotForm;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useContext, useMemo } from 'react';
|
|
1
|
+
import React, { forwardRef, useContext, useMemo } from 'react';
|
|
2
2
|
import { MobileContext } from '../../context/mobileContext';
|
|
3
3
|
import { ThemeValueContext } from '../../context/theme/ThemeValueContext';
|
|
4
4
|
import { useAnalytics, useHandleHubspotEvents } from '../../hooks';
|
|
@@ -8,7 +8,7 @@ import { block } from '../../utils';
|
|
|
8
8
|
import HubspotFormContainer from './HubspotFormContainer';
|
|
9
9
|
import './HubspotForm.css';
|
|
10
10
|
const b = block('hubspot-form');
|
|
11
|
-
const HubspotForm = (props) => {
|
|
11
|
+
const HubspotForm = forwardRef((props, ref) => {
|
|
12
12
|
const { className, theme: themeProp, isMobile: isMobileProp, formId, formInstanceId, portalId, region, formClassName, pixelEvents,
|
|
13
13
|
// hubspotEvents, // TODO: decide how to handle them
|
|
14
14
|
analyticsEvents, onBeforeSubmit, onSubmit, onBeforeLoad, onLoad, createDOMElement, onSubmitError, } = props;
|
|
@@ -23,10 +23,10 @@ const HubspotForm = (props) => {
|
|
|
23
23
|
onBeforeSubmit,
|
|
24
24
|
onLoad,
|
|
25
25
|
onSubmitError,
|
|
26
|
-
onSubmit: (
|
|
26
|
+
onSubmit: (event) => {
|
|
27
27
|
handleMetrika === null || handleMetrika === void 0 ? void 0 : handleMetrika({ pixelEvents });
|
|
28
28
|
handleAnalytics(analyticsEvents);
|
|
29
|
-
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(
|
|
29
|
+
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(event);
|
|
30
30
|
},
|
|
31
31
|
}), [
|
|
32
32
|
onBeforeLoad,
|
|
@@ -40,6 +40,7 @@ const HubspotForm = (props) => {
|
|
|
40
40
|
onSubmitError,
|
|
41
41
|
]);
|
|
42
42
|
useHandleHubspotEvents(handlers, formId);
|
|
43
|
-
return (React.createElement(HubspotFormContainer, { createDOMElement: createDOMElement, key: [formClassName, formId, formInstanceId, portalId, region].join(), className: b({ theme, mobile }, className), formClassName: formClassName, formId: formId, portalId: portalId, formInstanceId: formInstanceId, region: region }));
|
|
44
|
-
};
|
|
43
|
+
return (React.createElement(HubspotFormContainer, { 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 }));
|
|
44
|
+
});
|
|
45
|
+
HubspotForm.displayName = 'HubspotForm';
|
|
45
46
|
export default HubspotForm;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
+
/* eslint-disable no-param-reassign */
|
|
3
|
+
/* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
2
4
|
import _ from 'lodash';
|
|
3
5
|
import { BlockType, SubBlockType, } from '../models';
|
|
4
6
|
import { fullTransform, typografToHTML } from './utils';
|
|
@@ -43,7 +45,6 @@ const parseItemsTitle = (transformer, items) => items.map((_a) => {
|
|
|
43
45
|
});
|
|
44
46
|
function parsePriceDetailedBlock(transformer, block) {
|
|
45
47
|
const { priceType } = block;
|
|
46
|
-
/* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
47
48
|
block.items = block.items.map((item) => {
|
|
48
49
|
const { description, items: details = [] } = item;
|
|
49
50
|
if (priceType === 'marked-list') {
|
|
@@ -61,27 +62,23 @@ function parsePriceDetailedBlock(transformer, block) {
|
|
|
61
62
|
item.description = transformer(description);
|
|
62
63
|
return item;
|
|
63
64
|
});
|
|
64
|
-
/* eslint-enable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
65
65
|
return block;
|
|
66
66
|
}
|
|
67
67
|
const parseContentLayout = (transformer, content) => {
|
|
68
68
|
if (content) {
|
|
69
69
|
const { text, additionalInfo } = content;
|
|
70
|
-
/* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
71
70
|
if (text) {
|
|
72
71
|
content.text = transformer(text);
|
|
73
72
|
}
|
|
74
73
|
if (additionalInfo) {
|
|
75
74
|
content.additionalInfo = transformer(additionalInfo);
|
|
76
75
|
}
|
|
77
|
-
/* eslint-enable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
78
76
|
}
|
|
79
77
|
return content;
|
|
80
78
|
};
|
|
81
79
|
function parseContentLayoutTitle(transformer, content) {
|
|
82
80
|
if (content === null || content === void 0 ? void 0 : content.title) {
|
|
83
81
|
const { title } = content;
|
|
84
|
-
// eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign
|
|
85
82
|
content.title = title && parseTitle(transformer, title);
|
|
86
83
|
}
|
|
87
84
|
return content;
|
|
@@ -355,7 +352,6 @@ const config = {
|
|
|
355
352
|
function addRandomOrder(block) {
|
|
356
353
|
if (block) {
|
|
357
354
|
if ('randomOrder' in block && block.randomOrder && 'children' in block && block.children) {
|
|
358
|
-
// eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign
|
|
359
355
|
block.children = _.shuffle(block.children);
|
|
360
356
|
}
|
|
361
357
|
}
|
|
@@ -370,7 +366,6 @@ function transformBlock(lang, blocksConfig, block) {
|
|
|
370
366
|
const transformer = transformerRaw.bind(null, lang);
|
|
371
367
|
if (fields) {
|
|
372
368
|
fields.forEach((field) => {
|
|
373
|
-
/* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
374
369
|
if (block[field]) {
|
|
375
370
|
if (parser) {
|
|
376
371
|
block[field] = parser(transformer, block[field]);
|
|
@@ -379,7 +374,6 @@ function transformBlock(lang, blocksConfig, block) {
|
|
|
379
374
|
block[field] = transformer(block[field]);
|
|
380
375
|
}
|
|
381
376
|
}
|
|
382
|
-
/* eslint-enable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
383
377
|
});
|
|
384
378
|
}
|
|
385
379
|
else if (parser) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
+
import transformYFM from '@doc-tools/transform';
|
|
2
3
|
import sanitize from 'sanitize-html';
|
|
3
4
|
import Typograf from 'typograf';
|
|
4
|
-
import transformYFM from '@doc-tools/transform';
|
|
5
5
|
import { Lang } from '../utils/configure';
|
|
6
6
|
export var TransformType;
|
|
7
7
|
(function (TransformType) {
|
|
@@ -98,7 +98,7 @@ export function typografEntity({ entity, fields, lang = Lang.Ru, transformType =
|
|
|
98
98
|
const transformer = transformTypeMap[transformType];
|
|
99
99
|
fields.forEach((fieldName) => {
|
|
100
100
|
if (entity[fieldName]) {
|
|
101
|
-
// eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign
|
|
101
|
+
// eslint-disable-next-line no-param-reassign, no-not-accumulator-reassign/no-not-accumulator-reassign
|
|
102
102
|
entity[fieldName] = transformer(entity[fieldName], lang);
|
|
103
103
|
}
|
|
104
104
|
});
|
|
@@ -18,7 +18,7 @@ export function doSmoothScroll(element, startPosition, scrollOptions) {
|
|
|
18
18
|
}
|
|
19
19
|
function getChangeScrollFunction(direction, isReverse) {
|
|
20
20
|
return (element, scrollPosition, startPosition) => {
|
|
21
|
-
// eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign
|
|
21
|
+
// eslint-disable-next-line no-param-reassign, no-not-accumulator-reassign/no-not-accumulator-reassign
|
|
22
22
|
element[direction] = isReverse
|
|
23
23
|
? startPosition - scrollPosition
|
|
24
24
|
: startPosition + scrollPosition;
|
package/package.json
CHANGED
|
@@ -15,6 +15,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.transformFootnotes = exports.transformBlocks = exports.typografTransformer = exports.yfmTransformer = exports.createItemsParser = void 0;
|
|
18
|
+
/* eslint-disable no-param-reassign */
|
|
19
|
+
/* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
18
20
|
const lodash_1 = __importDefault(require("lodash"));
|
|
19
21
|
const models_1 = require("../models");
|
|
20
22
|
const utils_1 = require("./utils");
|
|
@@ -60,7 +62,6 @@ const parseItemsTitle = (transformer, items) => items.map((_a) => {
|
|
|
60
62
|
});
|
|
61
63
|
function parsePriceDetailedBlock(transformer, block) {
|
|
62
64
|
const { priceType } = block;
|
|
63
|
-
/* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
64
65
|
block.items = block.items.map((item) => {
|
|
65
66
|
const { description, items: details = [] } = item;
|
|
66
67
|
if (priceType === 'marked-list') {
|
|
@@ -78,27 +79,23 @@ function parsePriceDetailedBlock(transformer, block) {
|
|
|
78
79
|
item.description = transformer(description);
|
|
79
80
|
return item;
|
|
80
81
|
});
|
|
81
|
-
/* eslint-enable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
82
82
|
return block;
|
|
83
83
|
}
|
|
84
84
|
const parseContentLayout = (transformer, content) => {
|
|
85
85
|
if (content) {
|
|
86
86
|
const { text, additionalInfo } = content;
|
|
87
|
-
/* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
88
87
|
if (text) {
|
|
89
88
|
content.text = transformer(text);
|
|
90
89
|
}
|
|
91
90
|
if (additionalInfo) {
|
|
92
91
|
content.additionalInfo = transformer(additionalInfo);
|
|
93
92
|
}
|
|
94
|
-
/* eslint-enable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
95
93
|
}
|
|
96
94
|
return content;
|
|
97
95
|
};
|
|
98
96
|
function parseContentLayoutTitle(transformer, content) {
|
|
99
97
|
if (content === null || content === void 0 ? void 0 : content.title) {
|
|
100
98
|
const { title } = content;
|
|
101
|
-
// eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign
|
|
102
99
|
content.title = title && parseTitle(transformer, title);
|
|
103
100
|
}
|
|
104
101
|
return content;
|
|
@@ -374,7 +371,6 @@ const config = {
|
|
|
374
371
|
function addRandomOrder(block) {
|
|
375
372
|
if (block) {
|
|
376
373
|
if ('randomOrder' in block && block.randomOrder && 'children' in block && block.children) {
|
|
377
|
-
// eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign
|
|
378
374
|
block.children = lodash_1.default.shuffle(block.children);
|
|
379
375
|
}
|
|
380
376
|
}
|
|
@@ -389,7 +385,6 @@ function transformBlock(lang, blocksConfig, block) {
|
|
|
389
385
|
const transformer = transformerRaw.bind(null, lang);
|
|
390
386
|
if (fields) {
|
|
391
387
|
fields.forEach((field) => {
|
|
392
|
-
/* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
393
388
|
if (block[field]) {
|
|
394
389
|
if (parser) {
|
|
395
390
|
block[field] = parser(transformer, block[field]);
|
|
@@ -398,7 +393,6 @@ function transformBlock(lang, blocksConfig, block) {
|
|
|
398
393
|
block[field] = transformer(block[field]);
|
|
399
394
|
}
|
|
400
395
|
}
|
|
401
|
-
/* eslint-enable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
402
396
|
});
|
|
403
397
|
}
|
|
404
398
|
else if (parser) {
|
|
@@ -15,9 +15,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.typografEntity = exports.fullTransform = exports.transformMarkdown = exports.typografToText = exports.typografToHTML = exports.sanitizeHtml = exports.typograf = exports.sanitizeStripOptions = exports.typografConfig = exports.DEFAULT_ALLOWED_TAGS = exports.TransformType = void 0;
|
|
18
|
+
const transform_1 = __importDefault(require("@doc-tools/transform"));
|
|
18
19
|
const sanitize_html_1 = __importDefault(require("sanitize-html"));
|
|
19
20
|
const typograf_1 = __importDefault(require("typograf"));
|
|
20
|
-
const transform_1 = __importDefault(require("@doc-tools/transform"));
|
|
21
21
|
const configure_1 = require("../utils/configure");
|
|
22
22
|
var TransformType;
|
|
23
23
|
(function (TransformType) {
|
|
@@ -120,7 +120,7 @@ function typografEntity({ entity, fields, lang = configure_1.Lang.Ru, transformT
|
|
|
120
120
|
const transformer = transformTypeMap[transformType];
|
|
121
121
|
fields.forEach((fieldName) => {
|
|
122
122
|
if (entity[fieldName]) {
|
|
123
|
-
// eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign
|
|
123
|
+
// eslint-disable-next-line no-param-reassign, no-not-accumulator-reassign/no-not-accumulator-reassign
|
|
124
124
|
entity[fieldName] = transformer(entity[fieldName], lang);
|
|
125
125
|
}
|
|
126
126
|
});
|
package/server/utils/scroll.js
CHANGED
|
@@ -22,7 +22,7 @@ function doSmoothScroll(element, startPosition, scrollOptions) {
|
|
|
22
22
|
exports.doSmoothScroll = doSmoothScroll;
|
|
23
23
|
function getChangeScrollFunction(direction, isReverse) {
|
|
24
24
|
return (element, scrollPosition, startPosition) => {
|
|
25
|
-
// eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign
|
|
25
|
+
// eslint-disable-next-line no-param-reassign, no-not-accumulator-reassign/no-not-accumulator-reassign
|
|
26
26
|
element[direction] = isReverse
|
|
27
27
|
? startPosition - scrollPosition
|
|
28
28
|
: startPosition + scrollPosition;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
-
const react_2 = require("@testing-library/react");
|
|
6
|
-
const Anchor_1 = tslib_1.__importDefault(require("../Anchor"));
|
|
7
|
-
const testId = 'anchor';
|
|
8
|
-
const anchorId = 'anchorId';
|
|
9
|
-
describe('Anchor', () => {
|
|
10
|
-
test('Has id', async () => {
|
|
11
|
-
(0, react_2.render)(react_1.default.createElement(Anchor_1.default, { id: anchorId, dataQa: testId }));
|
|
12
|
-
const anchor = react_2.screen.getByTestId(testId);
|
|
13
|
-
expect(anchor).toHaveAttribute('id', anchorId);
|
|
14
|
-
});
|
|
15
|
-
test('Has custom class', async () => {
|
|
16
|
-
const className = 'custom-anchor-class';
|
|
17
|
-
(0, react_2.render)(react_1.default.createElement(Anchor_1.default, { id: anchorId, className: className, dataQa: testId }));
|
|
18
|
-
const anchor = react_2.screen.getByTestId(testId);
|
|
19
|
-
expect(anchor).toHaveClass(className);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
-
const react_2 = require("@testing-library/react");
|
|
6
|
-
const user_event_1 = tslib_1.__importDefault(require("@testing-library/user-event"));
|
|
7
|
-
const AnimateBlock_1 = tslib_1.__importDefault(require("../AnimateBlock"));
|
|
8
|
-
const qaId = 'animate-block';
|
|
9
|
-
describe('AnimateBlock', () => {
|
|
10
|
-
test('render AnimateBlock by default', async () => {
|
|
11
|
-
(0, react_2.render)(react_1.default.createElement(AnimateBlock_1.default, { qa: qaId }));
|
|
12
|
-
const component = react_2.screen.getByTestId(qaId);
|
|
13
|
-
expect(component).toBeInTheDocument();
|
|
14
|
-
});
|
|
15
|
-
test('add className', () => {
|
|
16
|
-
const className = 'my-class';
|
|
17
|
-
(0, react_2.render)(react_1.default.createElement(AnimateBlock_1.default, { qa: qaId, className: className }));
|
|
18
|
-
const component = react_2.screen.getByTestId(qaId);
|
|
19
|
-
expect(component).toHaveClass(className);
|
|
20
|
-
});
|
|
21
|
-
test('use passed style', () => {
|
|
22
|
-
const style = { color: 'red' };
|
|
23
|
-
(0, react_2.render)(react_1.default.createElement(AnimateBlock_1.default, { style: style, qa: qaId }));
|
|
24
|
-
const component = react_2.screen.getByTestId(qaId);
|
|
25
|
-
expect(component).toHaveStyle(style);
|
|
26
|
-
});
|
|
27
|
-
test('call onScroll', async () => {
|
|
28
|
-
const onScroll = jest.fn();
|
|
29
|
-
const user = user_event_1.default.setup();
|
|
30
|
-
(0, react_2.render)(react_1.default.createElement("div", { style: { paddingTop: 100000 } },
|
|
31
|
-
react_1.default.createElement(AnimateBlock_1.default, { onScroll: onScroll, qa: qaId })));
|
|
32
|
-
const component = react_2.screen.getByTestId(qaId);
|
|
33
|
-
await user.hover(component);
|
|
34
|
-
expect(onScroll).toHaveBeenCalledTimes(1);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
-
const react_2 = require("@testing-library/react");
|
|
6
|
-
const models_1 = require("../../../models");
|
|
7
|
-
const Author_1 = tslib_1.__importDefault(require("../Author"));
|
|
8
|
-
const testId = 'author';
|
|
9
|
-
const author = {
|
|
10
|
-
firstName: 'John',
|
|
11
|
-
secondName: 'Doe',
|
|
12
|
-
description: 'Web designer',
|
|
13
|
-
avatar: 'https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/img-gray.png',
|
|
14
|
-
};
|
|
15
|
-
describe('Author', () => {
|
|
16
|
-
test('Render author by default', async () => {
|
|
17
|
-
(0, react_2.render)(react_1.default.createElement(Author_1.default, { author: author, dataQa: testId }));
|
|
18
|
-
const object = react_2.screen.getByTestId(testId);
|
|
19
|
-
expect(object).toBeInTheDocument();
|
|
20
|
-
});
|
|
21
|
-
test('Has full name', async () => {
|
|
22
|
-
const name = `${author.firstName} ${author.secondName}`;
|
|
23
|
-
(0, react_2.render)(react_1.default.createElement(Author_1.default, { author: author, dataQa: testId }));
|
|
24
|
-
const object = react_2.screen.getByText(name);
|
|
25
|
-
expect(object).toBeInTheDocument();
|
|
26
|
-
});
|
|
27
|
-
test('Has first name only', async () => {
|
|
28
|
-
const name = author.firstName;
|
|
29
|
-
(0, react_2.render)(react_1.default.createElement(Author_1.default, { author: Object.assign(Object.assign({}, author), { secondName: '' }), dataQa: testId }));
|
|
30
|
-
const object = react_2.screen.getByText(name);
|
|
31
|
-
expect(object).toBeInTheDocument();
|
|
32
|
-
});
|
|
33
|
-
test('Has avatar', async () => {
|
|
34
|
-
(0, react_2.render)(react_1.default.createElement(Author_1.default, { author: author, dataQa: testId }));
|
|
35
|
-
const avatar = react_2.screen.getByRole('img');
|
|
36
|
-
expect(avatar).toBeInTheDocument();
|
|
37
|
-
expect(avatar).toHaveAttribute('src', author.avatar);
|
|
38
|
-
});
|
|
39
|
-
test('Has description', async () => {
|
|
40
|
-
(0, react_2.render)(react_1.default.createElement(Author_1.default, { author: author, dataQa: testId }));
|
|
41
|
-
const object = react_2.screen.getByText(author.description);
|
|
42
|
-
expect(object).toBeInTheDocument();
|
|
43
|
-
});
|
|
44
|
-
test.each(new Array(models_1.AuthorType.Column, models_1.AuthorType.Line))('Render with given "%s" type', (type) => {
|
|
45
|
-
(0, react_2.render)(react_1.default.createElement(Author_1.default, { author: author, dataQa: testId, type: type }));
|
|
46
|
-
const object = react_2.screen.getByTestId(testId);
|
|
47
|
-
expect(object).toHaveClass(`pc-author_type_${type}`);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
-
const react_2 = require("@testing-library/react");
|
|
6
|
-
const user_event_1 = tslib_1.__importDefault(require("@testing-library/user-event"));
|
|
7
|
-
const locationContext_1 = require("../../../context/locationContext");
|
|
8
|
-
const BackLink_1 = tslib_1.__importDefault(require("../BackLink"));
|
|
9
|
-
const backLinkProps = {
|
|
10
|
-
url: '#',
|
|
11
|
-
title: 'Button Title',
|
|
12
|
-
theme: 'default',
|
|
13
|
-
size: 's',
|
|
14
|
-
className: 'customClassName',
|
|
15
|
-
shouldHandleBackAction: true,
|
|
16
|
-
onClick: () => { },
|
|
17
|
-
};
|
|
18
|
-
describe('BackLink', () => {
|
|
19
|
-
test('Default render', async () => {
|
|
20
|
-
(0, react_2.render)(react_1.default.createElement(BackLink_1.default, Object.assign({}, backLinkProps)));
|
|
21
|
-
const backLink = react_2.screen.getByRole('button');
|
|
22
|
-
expect(backLink).toBeInTheDocument();
|
|
23
|
-
});
|
|
24
|
-
test('Has custom class', async () => {
|
|
25
|
-
(0, react_2.render)(react_1.default.createElement(BackLink_1.default, Object.assign({}, backLinkProps)));
|
|
26
|
-
const backLink = react_2.screen.getByRole('button');
|
|
27
|
-
expect(backLink).toHaveClass(backLinkProps.className);
|
|
28
|
-
});
|
|
29
|
-
test('Should render <a /> tag', async () => {
|
|
30
|
-
(0, react_2.render)(react_1.default.createElement(BackLink_1.default, Object.assign({}, backLinkProps, { shouldHandleBackAction: false })));
|
|
31
|
-
const backLink = react_2.screen.getByRole('link');
|
|
32
|
-
expect(backLink).toBeVisible();
|
|
33
|
-
expect(backLink).toHaveAttribute('href', backLinkProps.url);
|
|
34
|
-
});
|
|
35
|
-
test('Should render title', async () => {
|
|
36
|
-
(0, react_2.render)(react_1.default.createElement(BackLink_1.default, Object.assign({}, backLinkProps)));
|
|
37
|
-
const backLink = react_2.screen.getByText(backLinkProps.title);
|
|
38
|
-
expect(backLink).toBeInTheDocument();
|
|
39
|
-
});
|
|
40
|
-
test('Call onClick', async () => {
|
|
41
|
-
const user = user_event_1.default.setup();
|
|
42
|
-
const handleClick = jest.fn();
|
|
43
|
-
(0, react_2.render)(react_1.default.createElement(locationContext_1.LocationContext.Provider, { value: { history: { push: jest.fn() } } },
|
|
44
|
-
react_1.default.createElement(BackLink_1.default, Object.assign({}, backLinkProps, { onClick: handleClick }))));
|
|
45
|
-
const backLink = react_2.screen.getByRole('button');
|
|
46
|
-
await user.click(backLink);
|
|
47
|
-
expect(handleClick).toHaveBeenCalledTimes(1);
|
|
48
|
-
});
|
|
49
|
-
test.each(new Array('s', 'm', 'l', 'xl'))('Render with given "%s" size', (size) => {
|
|
50
|
-
(0, react_2.render)(react_1.default.createElement(BackLink_1.default, Object.assign({}, backLinkProps, { size: size })));
|
|
51
|
-
const backLink = react_2.screen.getByRole('button');
|
|
52
|
-
expect(backLink).toHaveClass(`yc-button_size_${size}`);
|
|
53
|
-
});
|
|
54
|
-
test.each(new Array('default', 'special'))('Render with given "%s" theme', (theme) => {
|
|
55
|
-
const matchView = {
|
|
56
|
-
default: 'flat-secondary',
|
|
57
|
-
special: 'flat-contrast',
|
|
58
|
-
};
|
|
59
|
-
(0, react_2.render)(react_1.default.createElement(BackLink_1.default, Object.assign({}, backLinkProps, { theme: theme })));
|
|
60
|
-
const backLink = react_2.screen.getByRole('button');
|
|
61
|
-
expect(backLink).toHaveClass(`yc-button_view_${matchView[theme]}`);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
-
const react_2 = require("@testing-library/react");
|
|
6
|
-
const Anchor_1 = require("../../../components/Anchor/Anchor");
|
|
7
|
-
const grid_1 = require("../../../grid");
|
|
8
|
-
const BlockBase_1 = tslib_1.__importDefault(require("../BlockBase"));
|
|
9
|
-
const qaId = 'block-base-component';
|
|
10
|
-
describe('BlockBase', () => {
|
|
11
|
-
test('render component by default', async () => {
|
|
12
|
-
(0, react_2.render)(react_1.default.createElement(BlockBase_1.default, { qa: qaId }));
|
|
13
|
-
const component = react_2.screen.getByTestId(qaId);
|
|
14
|
-
expect(component).toBeInTheDocument();
|
|
15
|
-
expect(component).toBeVisible();
|
|
16
|
-
expect(component).not.toBeDisabled();
|
|
17
|
-
});
|
|
18
|
-
test('add className', () => {
|
|
19
|
-
const className = 'my-class';
|
|
20
|
-
(0, react_2.render)(react_1.default.createElement(BlockBase_1.default, { qa: qaId, className: className }));
|
|
21
|
-
const component = react_2.screen.getByTestId(qaId);
|
|
22
|
-
expect(component).toHaveClass(className);
|
|
23
|
-
});
|
|
24
|
-
test('should reset paddings', () => {
|
|
25
|
-
(0, react_2.render)(react_1.default.createElement(BlockBase_1.default, { qa: qaId, resetPaddings: true }));
|
|
26
|
-
const component = react_2.screen.getByTestId(qaId);
|
|
27
|
-
expect(component).toHaveClass('pc-block-base_reset-paddings');
|
|
28
|
-
});
|
|
29
|
-
test.each(new Array(...Object.values(grid_1.GridColumnSize)))('render with given "%s" size', (size) => {
|
|
30
|
-
(0, react_2.render)(react_1.default.createElement(BlockBase_1.default, { qa: qaId, visible: size }));
|
|
31
|
-
const component = react_2.screen.getByTestId(qaId);
|
|
32
|
-
expect(component).toHaveClass(`d-${size}-block`);
|
|
33
|
-
});
|
|
34
|
-
test('should have anchor', () => {
|
|
35
|
-
const anchor = {
|
|
36
|
-
text: 'anchor',
|
|
37
|
-
url: 'https://github.com/gravity-ui/',
|
|
38
|
-
};
|
|
39
|
-
(0, react_2.render)(react_1.default.createElement(BlockBase_1.default, { anchor: anchor }));
|
|
40
|
-
const component = react_2.screen.getByTestId(Anchor_1.qaIdByDefault);
|
|
41
|
-
expect(component).toBeInTheDocument();
|
|
42
|
-
expect(component).toHaveAttribute('id', anchor.url);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|