@gravity-ui/page-constructor 2.18.0 → 3.0.0-alpha.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 +0 -19
- package/build/cjs/blocks/index.d.ts +0 -4
- package/build/cjs/blocks/index.js +1 -9
- package/build/cjs/blocks/validators.d.ts +0 -4
- package/build/cjs/blocks/validators.js +0 -4
- package/build/cjs/components/Anchor/Anchor.d.ts +2 -2
- package/build/cjs/components/Anchor/Anchor.js +1 -1
- package/build/cjs/components/Anchor/__tests__/Anchor.test.d.ts +1 -0
- package/build/cjs/components/Anchor/__tests__/Anchor.test.js +21 -0
- package/build/cjs/components/AnimateBlock/__tests__/AnimateBlock.test.d.ts +1 -0
- package/build/cjs/components/AnimateBlock/__tests__/AnimateBlock.test.js +36 -0
- package/build/cjs/components/Author/__tests__/Author.test.d.ts +1 -0
- package/build/cjs/components/Author/__tests__/Author.test.js +49 -0
- package/build/cjs/components/BackLink/__tests__/BackLink.test.d.ts +1 -0
- package/build/cjs/components/BackLink/__tests__/BackLink.test.js +63 -0
- package/build/cjs/components/BlockBase/__tests__/BlockBase.test.d.ts +1 -0
- package/build/cjs/components/BlockBase/__tests__/BlockBase.test.js +44 -0
- package/build/cjs/components/Button/__tests__/Button.test.d.ts +1 -0
- package/build/cjs/components/Button/__tests__/Button.test.js +91 -0
- package/build/cjs/components/ButtonTabs/__tests__/ButtonTabs.test.d.ts +1 -0
- package/build/cjs/components/ButtonTabs/__tests__/ButtonTabs.test.js +58 -0
- package/build/cjs/components/index.d.ts +0 -1
- package/build/cjs/components/index.js +1 -3
- package/build/cjs/constructor-items.d.ts +0 -16
- package/build/cjs/constructor-items.js +0 -16
- package/build/cjs/grid/Col/Col.d.ts +1 -1
- package/build/cjs/hooks/index.d.ts +1 -1
- package/build/cjs/hooks/index.js +3 -3
- package/build/cjs/internal-typings/global.d.ts +16 -18
- package/build/cjs/models/constructor-items/blocks.d.ts +2 -50
- package/build/cjs/models/constructor-items/blocks.js +0 -4
- package/build/cjs/models/constructor-items/common.d.ts +0 -14
- package/build/cjs/models/constructor-items/common.js +1 -6
- package/build/cjs/models/constructor-items/sub-blocks.d.ts +5 -46
- package/build/cjs/models/constructor-items/sub-blocks.js +2 -11
- package/build/cjs/schema/index.js +2 -8
- package/build/cjs/schema/validators/blocks.d.ts +0 -4
- package/build/cjs/schema/validators/blocks.js +0 -4
- package/build/cjs/schema/validators/sub-blocks.d.ts +0 -3
- package/build/cjs/schema/validators/sub-blocks.js +0 -3
- package/build/cjs/sub-blocks/HubspotForm/HubspotFormContainer.d.ts +1 -2
- package/build/cjs/sub-blocks/HubspotForm/HubspotFormContainer.js +2 -5
- package/build/cjs/sub-blocks/HubspotForm/index.d.ts +1 -1
- package/build/cjs/sub-blocks/HubspotForm/index.js +5 -6
- package/build/cjs/sub-blocks/index.d.ts +0 -3
- package/build/cjs/sub-blocks/index.js +1 -7
- package/build/cjs/text-transform/{blocks.d.ts → common.d.ts} +1 -4
- package/build/cjs/text-transform/common.js +31 -0
- package/build/cjs/text-transform/config.d.ts +28 -0
- package/build/cjs/text-transform/config.js +291 -0
- package/build/cjs/text-transform/index.d.ts +3 -1
- package/build/cjs/text-transform/index.js +3 -1
- package/build/cjs/text-transform/transformers.d.ts +16 -0
- package/build/cjs/text-transform/transformers.js +61 -0
- package/build/cjs/utils/index.d.ts +0 -1
- package/build/cjs/utils/index.js +0 -1
- package/build/esm/blocks/index.d.ts +0 -4
- package/build/esm/blocks/index.js +0 -4
- package/build/esm/blocks/validators.d.ts +0 -4
- package/build/esm/blocks/validators.js +0 -4
- package/build/esm/components/Anchor/Anchor.d.ts +2 -2
- package/build/esm/components/Anchor/Anchor.js +1 -1
- package/build/esm/components/Anchor/__tests__/Anchor.test.d.ts +1 -0
- package/build/esm/components/Anchor/__tests__/Anchor.test.js +18 -0
- package/build/esm/components/AnimateBlock/__tests__/AnimateBlock.test.d.ts +1 -0
- package/build/esm/components/AnimateBlock/__tests__/AnimateBlock.test.js +33 -0
- package/build/esm/components/Author/__tests__/Author.test.d.ts +1 -0
- package/build/esm/components/Author/__tests__/Author.test.js +46 -0
- package/build/esm/components/BackLink/__tests__/BackLink.test.d.ts +1 -0
- package/build/esm/components/BackLink/__tests__/BackLink.test.js +60 -0
- package/build/esm/components/BlockBase/__tests__/BlockBase.test.d.ts +1 -0
- package/build/esm/components/BlockBase/__tests__/BlockBase.test.js +41 -0
- package/build/esm/components/Button/__tests__/Button.test.d.ts +1 -0
- package/build/esm/components/Button/__tests__/Button.test.js +88 -0
- package/build/esm/components/ButtonTabs/__tests__/ButtonTabs.test.d.ts +1 -0
- package/build/esm/components/ButtonTabs/__tests__/ButtonTabs.test.js +55 -0
- package/build/esm/components/index.d.ts +0 -1
- package/build/esm/components/index.js +0 -1
- package/build/esm/constructor-items.d.ts +0 -16
- package/build/esm/constructor-items.js +2 -18
- package/build/esm/grid/Col/Col.d.ts +1 -1
- package/build/esm/hooks/index.d.ts +1 -1
- package/build/esm/hooks/index.js +1 -1
- package/build/esm/internal-typings/global.d.ts +16 -18
- package/build/esm/models/constructor-items/blocks.d.ts +2 -50
- package/build/esm/models/constructor-items/blocks.js +0 -4
- package/build/esm/models/constructor-items/common.d.ts +0 -14
- package/build/esm/models/constructor-items/common.js +0 -5
- package/build/esm/models/constructor-items/sub-blocks.d.ts +5 -46
- package/build/esm/models/constructor-items/sub-blocks.js +2 -11
- package/build/esm/schema/index.js +4 -10
- package/build/esm/schema/validators/blocks.d.ts +0 -4
- package/build/esm/schema/validators/blocks.js +0 -4
- package/build/esm/schema/validators/sub-blocks.d.ts +0 -3
- package/build/esm/schema/validators/sub-blocks.js +0 -3
- package/build/esm/sub-blocks/HubspotForm/HubspotFormContainer.d.ts +1 -2
- package/build/esm/sub-blocks/HubspotForm/HubspotFormContainer.js +3 -6
- package/build/esm/sub-blocks/HubspotForm/index.d.ts +1 -1
- package/build/esm/sub-blocks/HubspotForm/index.js +6 -7
- package/build/esm/sub-blocks/index.d.ts +0 -3
- package/build/esm/sub-blocks/index.js +0 -3
- package/build/esm/text-transform/{blocks.d.ts → common.d.ts} +1 -4
- package/build/esm/text-transform/common.js +25 -0
- package/build/esm/text-transform/config.d.ts +28 -0
- package/build/esm/text-transform/{blocks.js → config.js} +15 -123
- package/build/esm/text-transform/index.d.ts +3 -1
- package/build/esm/text-transform/index.js +3 -1
- package/build/esm/text-transform/transformers.d.ts +16 -0
- package/build/esm/text-transform/transformers.js +56 -0
- package/build/esm/utils/index.d.ts +0 -1
- package/build/esm/utils/index.js +0 -1
- package/package.json +4 -1
- package/server/models/constructor-items/blocks.d.ts +2 -50
- package/server/models/constructor-items/blocks.js +0 -4
- package/server/models/constructor-items/common.d.ts +0 -14
- package/server/models/constructor-items/common.js +1 -6
- package/server/models/constructor-items/sub-blocks.d.ts +5 -46
- package/server/models/constructor-items/sub-blocks.js +2 -11
- package/server/text-transform/{blocks.d.ts → common.d.ts} +1 -4
- package/server/text-transform/common.js +31 -0
- package/server/text-transform/config.d.ts +28 -0
- package/server/text-transform/config.js +301 -0
- package/server/text-transform/index.d.ts +3 -1
- package/server/text-transform/index.js +3 -1
- package/server/text-transform/transformers.d.ts +16 -0
- package/server/text-transform/transformers.js +63 -0
- package/server/utils/index.d.ts +0 -1
- package/server/utils/index.js +0 -1
- package/build/cjs/blocks/LinkTable/LinkTable.css +0 -3
- package/build/cjs/blocks/LinkTable/LinkTable.d.ts +0 -3
- package/build/cjs/blocks/LinkTable/LinkTable.js +0 -22
- package/build/cjs/blocks/LinkTable/schema.d.ts +0 -77
- package/build/cjs/blocks/LinkTable/schema.js +0 -15
- package/build/cjs/blocks/Preview/MediaContent/MediaContent.css +0 -50
- package/build/cjs/blocks/Preview/MediaContent/MediaContent.d.ts +0 -13
- package/build/cjs/blocks/Preview/MediaContent/MediaContent.js +0 -49
- package/build/cjs/blocks/Preview/MediaContent/PreviewContent.css +0 -106
- package/build/cjs/blocks/Preview/MediaContent/PreviewContent.d.ts +0 -11
- package/build/cjs/blocks/Preview/MediaContent/PreviewContent.js +0 -17
- package/build/cjs/blocks/Preview/MediaContent/PreviewMedia.css +0 -54
- package/build/cjs/blocks/Preview/MediaContent/PreviewMedia.d.ts +0 -9
- package/build/cjs/blocks/Preview/MediaContent/PreviewMedia.js +0 -13
- package/build/cjs/blocks/Preview/Preview.css +0 -50
- package/build/cjs/blocks/Preview/Preview.d.ts +0 -3
- package/build/cjs/blocks/Preview/Preview.js +0 -130
- package/build/cjs/blocks/Preview/schema.d.ts +0 -40
- package/build/cjs/blocks/Preview/schema.js +0 -53
- package/build/cjs/blocks/Security/Security.css +0 -142
- package/build/cjs/blocks/Security/Security.d.ts +0 -3
- package/build/cjs/blocks/Security/Security.js +0 -29
- package/build/cjs/blocks/Security/schema.d.ts +0 -170
- package/build/cjs/blocks/Security/schema.js +0 -32
- package/build/cjs/blocks/Simple/Simple.css +0 -22
- package/build/cjs/blocks/Simple/Simple.d.ts +0 -3
- package/build/cjs/blocks/Simple/Simple.js +0 -22
- package/build/cjs/blocks/Simple/schema.d.ts +0 -68
- package/build/cjs/blocks/Simple/schema.js +0 -14
- package/build/cjs/components/HeightCalculator/HeightCalculator.css +0 -9
- package/build/cjs/components/HeightCalculator/HeightCalculator.d.ts +0 -10
- package/build/cjs/components/HeightCalculator/HeightCalculator.js +0 -44
- package/build/cjs/context/breakpointContext/breakpointContext.d.ts +0 -2
- package/build/cjs/context/breakpointContext/breakpointContext.js +0 -7
- package/build/cjs/context/breakpointContext/index.d.ts +0 -1
- package/build/cjs/context/breakpointContext/index.js +0 -4
- package/build/cjs/hooks/useIntersection.d.ts +0 -1
- package/build/cjs/hooks/useIntersection.js +0 -21
- package/build/cjs/sub-blocks/CardWithImage/CardWithImage.css +0 -19
- package/build/cjs/sub-blocks/CardWithImage/CardWithImage.d.ts +0 -3
- package/build/cjs/sub-blocks/CardWithImage/CardWithImage.js +0 -16
- package/build/cjs/sub-blocks/CardWithImage/schema.d.ts +0 -154
- package/build/cjs/sub-blocks/CardWithImage/schema.js +0 -46
- package/build/cjs/sub-blocks/Partner/Partner.css +0 -8
- package/build/cjs/sub-blocks/Partner/Partner.d.ts +0 -3
- package/build/cjs/sub-blocks/Partner/Partner.js +0 -15
- package/build/cjs/sub-blocks/Partner/schema.d.ts +0 -30
- package/build/cjs/sub-blocks/Partner/schema.js +0 -17
- package/build/cjs/sub-blocks/TutorialCard/TutorialCard.css +0 -20
- package/build/cjs/sub-blocks/TutorialCard/TutorialCard.d.ts +0 -3
- package/build/cjs/sub-blocks/TutorialCard/TutorialCard.js +0 -23
- package/build/cjs/sub-blocks/TutorialCard/schema.d.ts +0 -34
- package/build/cjs/sub-blocks/TutorialCard/schema.js +0 -20
- package/build/cjs/text-transform/blocks.js +0 -404
- package/build/cjs/utils/scroll.d.ts +0 -15
- package/build/cjs/utils/scroll.js +0 -35
- package/build/esm/blocks/LinkTable/LinkTable.css +0 -3
- package/build/esm/blocks/LinkTable/LinkTable.d.ts +0 -4
- package/build/esm/blocks/LinkTable/LinkTable.js +0 -21
- package/build/esm/blocks/LinkTable/schema.d.ts +0 -77
- package/build/esm/blocks/LinkTable/schema.js +0 -12
- package/build/esm/blocks/Preview/MediaContent/MediaContent.css +0 -50
- package/build/esm/blocks/Preview/MediaContent/MediaContent.d.ts +0 -14
- package/build/esm/blocks/Preview/MediaContent/MediaContent.js +0 -47
- package/build/esm/blocks/Preview/MediaContent/PreviewContent.css +0 -106
- package/build/esm/blocks/Preview/MediaContent/PreviewContent.d.ts +0 -12
- package/build/esm/blocks/Preview/MediaContent/PreviewContent.js +0 -15
- package/build/esm/blocks/Preview/MediaContent/PreviewMedia.css +0 -54
- package/build/esm/blocks/Preview/MediaContent/PreviewMedia.d.ts +0 -10
- package/build/esm/blocks/Preview/MediaContent/PreviewMedia.js +0 -11
- package/build/esm/blocks/Preview/Preview.css +0 -50
- package/build/esm/blocks/Preview/Preview.d.ts +0 -4
- package/build/esm/blocks/Preview/Preview.js +0 -126
- package/build/esm/blocks/Preview/schema.d.ts +0 -40
- package/build/esm/blocks/Preview/schema.js +0 -50
- package/build/esm/blocks/Security/Security.css +0 -142
- package/build/esm/blocks/Security/Security.d.ts +0 -4
- package/build/esm/blocks/Security/Security.js +0 -25
- package/build/esm/blocks/Security/schema.d.ts +0 -170
- package/build/esm/blocks/Security/schema.js +0 -28
- package/build/esm/blocks/Simple/Simple.css +0 -22
- package/build/esm/blocks/Simple/Simple.d.ts +0 -4
- package/build/esm/blocks/Simple/Simple.js +0 -18
- package/build/esm/blocks/Simple/schema.d.ts +0 -68
- package/build/esm/blocks/Simple/schema.js +0 -11
- package/build/esm/components/HeightCalculator/HeightCalculator.css +0 -9
- package/build/esm/components/HeightCalculator/HeightCalculator.d.ts +0 -11
- package/build/esm/components/HeightCalculator/HeightCalculator.js +0 -42
- package/build/esm/context/breakpointContext/breakpointContext.d.ts +0 -2
- package/build/esm/context/breakpointContext/breakpointContext.js +0 -3
- package/build/esm/context/breakpointContext/index.d.ts +0 -1
- package/build/esm/context/breakpointContext/index.js +0 -1
- package/build/esm/hooks/useIntersection.d.ts +0 -1
- package/build/esm/hooks/useIntersection.js +0 -17
- package/build/esm/sub-blocks/CardWithImage/CardWithImage.css +0 -19
- package/build/esm/sub-blocks/CardWithImage/CardWithImage.d.ts +0 -4
- package/build/esm/sub-blocks/CardWithImage/CardWithImage.js +0 -14
- package/build/esm/sub-blocks/CardWithImage/schema.d.ts +0 -154
- package/build/esm/sub-blocks/CardWithImage/schema.js +0 -43
- package/build/esm/sub-blocks/Partner/Partner.css +0 -8
- package/build/esm/sub-blocks/Partner/Partner.d.ts +0 -4
- package/build/esm/sub-blocks/Partner/Partner.js +0 -13
- package/build/esm/sub-blocks/Partner/schema.d.ts +0 -30
- package/build/esm/sub-blocks/Partner/schema.js +0 -14
- package/build/esm/sub-blocks/TutorialCard/TutorialCard.css +0 -20
- package/build/esm/sub-blocks/TutorialCard/TutorialCard.d.ts +0 -4
- package/build/esm/sub-blocks/TutorialCard/TutorialCard.js +0 -21
- package/build/esm/sub-blocks/TutorialCard/schema.d.ts +0 -34
- package/build/esm/sub-blocks/TutorialCard/schema.js +0 -17
- package/build/esm/utils/scroll.d.ts +0 -15
- package/build/esm/utils/scroll.js +0 -31
- package/server/text-transform/blocks.js +0 -417
- package/server/utils/scroll.d.ts +0 -15
- package/server/utils/scroll.js +0 -35
|
@@ -3,25 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.HubspotForm = exports.Content = exports.BasicCard = exports.BackgroundCard = exports.LayoutItem = exports.
|
|
6
|
+
exports.HubspotForm = exports.Content = exports.BasicCard = exports.BackgroundCard = exports.LayoutItem = exports.BannerCard = exports.MediaCard = exports.PriceDetailed = exports.NewsCard = exports.Quote = exports.Divider = void 0;
|
|
7
7
|
var Divider_1 = require("./Divider/Divider");
|
|
8
8
|
Object.defineProperty(exports, "Divider", { enumerable: true, get: function () { return __importDefault(Divider_1).default; } });
|
|
9
9
|
var Quote_1 = require("./Quote/Quote");
|
|
10
10
|
Object.defineProperty(exports, "Quote", { enumerable: true, get: function () { return __importDefault(Quote_1).default; } });
|
|
11
11
|
var NewsCard_1 = require("./NewsCard/NewsCard");
|
|
12
12
|
Object.defineProperty(exports, "NewsCard", { enumerable: true, get: function () { return __importDefault(NewsCard_1).default; } });
|
|
13
|
-
var Partner_1 = require("./Partner/Partner");
|
|
14
|
-
Object.defineProperty(exports, "Partner", { enumerable: true, get: function () { return __importDefault(Partner_1).default; } });
|
|
15
13
|
var PriceDetailed_1 = require("./PriceDetailed/PriceDetailed");
|
|
16
14
|
Object.defineProperty(exports, "PriceDetailed", { enumerable: true, get: function () { return __importDefault(PriceDetailed_1).default; } });
|
|
17
15
|
var MediaCard_1 = require("./MediaCard/MediaCard");
|
|
18
16
|
Object.defineProperty(exports, "MediaCard", { enumerable: true, get: function () { return __importDefault(MediaCard_1).default; } });
|
|
19
17
|
var BannerCard_1 = require("./BannerCard/BannerCard");
|
|
20
18
|
Object.defineProperty(exports, "BannerCard", { enumerable: true, get: function () { return __importDefault(BannerCard_1).default; } });
|
|
21
|
-
var TutorialCard_1 = require("./TutorialCard/TutorialCard");
|
|
22
|
-
Object.defineProperty(exports, "TutorialCard", { enumerable: true, get: function () { return __importDefault(TutorialCard_1).default; } });
|
|
23
|
-
var CardWithImage_1 = require("./CardWithImage/CardWithImage");
|
|
24
|
-
Object.defineProperty(exports, "CardWithImage", { enumerable: true, get: function () { return __importDefault(CardWithImage_1).default; } });
|
|
25
19
|
var LayoutItem_1 = require("./LayoutItem/LayoutItem");
|
|
26
20
|
Object.defineProperty(exports, "LayoutItem", { enumerable: true, get: function () { return __importDefault(LayoutItem_1).default; } });
|
|
27
21
|
var BackgroundCard_1 = require("./BackgroundCard/BackgroundCard");
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import { ConstructorBlock } from '../models/constructor';
|
|
2
1
|
import { Lang } from '../utils/configure';
|
|
3
2
|
export type ComplexItem = {
|
|
4
3
|
[key: string]: string;
|
|
5
4
|
};
|
|
6
5
|
export type Item = string | null | ComplexItem;
|
|
7
|
-
export type TransformerRaw = (lang: Lang, content: string) => string;
|
|
8
6
|
export type Transformer = (text: string) => string;
|
|
7
|
+
export type TransformerRaw = (lang: Lang, content: string) => string;
|
|
9
8
|
export type Parser<T = any> = (transformer: Transformer, block: T) => T;
|
|
10
9
|
export declare const createItemsParser: (fields: string[]) => (transformer: Transformer, items: Item[]) => (string | {
|
|
11
10
|
[x: string]: string;
|
|
12
11
|
} | null)[];
|
|
13
12
|
export declare function yfmTransformer(lang: Lang, content: string): string;
|
|
14
13
|
export declare function typografTransformer(lang: Lang, content: string): string;
|
|
15
|
-
export declare function transformBlocks(blocks: ConstructorBlock[], lang: Lang, customConfig?: {}): void;
|
|
16
|
-
export declare function transformFootnotes(footnotes: string[], lang: Lang): string[];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.typografTransformer = exports.yfmTransformer = exports.createItemsParser = void 0;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
const createItemsParser = (fields) => (transformer, items) => items.map((item) => {
|
|
6
|
+
if (!item) {
|
|
7
|
+
return item;
|
|
8
|
+
}
|
|
9
|
+
else if (typeof item === 'string') {
|
|
10
|
+
return transformer(item);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
return Object.assign(Object.assign({}, item), fields.reduce((acc, fieldName) => {
|
|
14
|
+
if (item[fieldName]) {
|
|
15
|
+
// eslint-disable-next-line no-param-reassign
|
|
16
|
+
acc[fieldName] = transformer(item[fieldName]);
|
|
17
|
+
}
|
|
18
|
+
return acc;
|
|
19
|
+
}, {}));
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
exports.createItemsParser = createItemsParser;
|
|
23
|
+
function yfmTransformer(lang, content) {
|
|
24
|
+
const { html } = (0, utils_1.fullTransform)(content, { lang });
|
|
25
|
+
return html;
|
|
26
|
+
}
|
|
27
|
+
exports.yfmTransformer = yfmTransformer;
|
|
28
|
+
function typografTransformer(lang, content) {
|
|
29
|
+
return (0, utils_1.typografToHTML)(content, lang);
|
|
30
|
+
}
|
|
31
|
+
exports.typografTransformer = typografTransformer;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { TitleProps } from '../models';
|
|
2
|
+
import { Parser, Transformer, TransformerRaw, typografTransformer, yfmTransformer } from './common';
|
|
3
|
+
export declare const blockHeaderTransformer: ({
|
|
4
|
+
fields: string[];
|
|
5
|
+
transformer: typeof typografTransformer;
|
|
6
|
+
parser: (transformer: Transformer, title: TitleProps | string) => string | {
|
|
7
|
+
text: string;
|
|
8
|
+
navTitle?: string | undefined;
|
|
9
|
+
anchor?: string | undefined;
|
|
10
|
+
justify?: import("../models").Justify | undefined;
|
|
11
|
+
textSize?: import("../models").TextSize | undefined;
|
|
12
|
+
url?: string | undefined;
|
|
13
|
+
custom?: import("react").ReactNode;
|
|
14
|
+
onClick?: (() => void) | undefined;
|
|
15
|
+
};
|
|
16
|
+
} | {
|
|
17
|
+
fields: string[];
|
|
18
|
+
transformer: typeof yfmTransformer;
|
|
19
|
+
parser?: undefined;
|
|
20
|
+
})[];
|
|
21
|
+
interface BlockConfig {
|
|
22
|
+
transformer: TransformerRaw;
|
|
23
|
+
fields?: string[];
|
|
24
|
+
parser?: Parser;
|
|
25
|
+
}
|
|
26
|
+
export type BlocksConfig = Record<string, BlockConfig | BlockConfig[]>;
|
|
27
|
+
export declare const config: BlocksConfig;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.config = exports.blockHeaderTransformer = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const models_1 = require("../models");
|
|
6
|
+
const common_1 = require("./common");
|
|
7
|
+
function parseTableBlock(transformer, content) {
|
|
8
|
+
const legend = content === null || content === void 0 ? void 0 : content.legend;
|
|
9
|
+
return Object.assign(Object.assign({}, (content || {})), { legend: legend && legend.map((string) => transformer(string)) });
|
|
10
|
+
}
|
|
11
|
+
function parseFeatures(transformer, items) {
|
|
12
|
+
return items.map((_a) => {
|
|
13
|
+
var { title, text } = _a, rest = tslib_1.__rest(_a, ["title", "text"]);
|
|
14
|
+
return (Object.assign({ title: title && transformer(title), text: text && transformer(text) }, rest));
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function parsePromoFeatures(transformer, items) {
|
|
18
|
+
return items.map((_a) => {
|
|
19
|
+
var { text } = _a, rest = tslib_1.__rest(_a, ["text"]);
|
|
20
|
+
return (Object.assign({ text: transformer(text) }, rest));
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const parseTitle = (transformer, title) => typeof title === 'object' && 'text' in title
|
|
24
|
+
? Object.assign(Object.assign({}, title), { text: transformer(title.text) }) : title && transformer(title);
|
|
25
|
+
const parseItemsTitle = (transformer, items) => items.map((_a) => {
|
|
26
|
+
var { title } = _a, rest = tslib_1.__rest(_a, ["title"]);
|
|
27
|
+
return (Object.assign({ title: title && parseTitle(transformer, title) }, rest));
|
|
28
|
+
});
|
|
29
|
+
function parsePriceDetailedBlock(transformer, block) {
|
|
30
|
+
const { priceType } = block;
|
|
31
|
+
/* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
32
|
+
block.items = block.items.map((item) => {
|
|
33
|
+
const { description, items: details = [] } = item;
|
|
34
|
+
if (priceType === 'marked-list') {
|
|
35
|
+
item.items = details.map((detail) => {
|
|
36
|
+
detail.text = detail.text && transformer(detail.text);
|
|
37
|
+
return detail;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
item.items = details.map((detail) => {
|
|
42
|
+
detail.description = detail.description && transformer(detail.description);
|
|
43
|
+
return detail;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
item.description = transformer(description);
|
|
47
|
+
return item;
|
|
48
|
+
});
|
|
49
|
+
/* eslint-enable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
50
|
+
return block;
|
|
51
|
+
}
|
|
52
|
+
const parseContentLayout = (transformer, content) => {
|
|
53
|
+
if (content) {
|
|
54
|
+
const { text, additionalInfo } = content;
|
|
55
|
+
/* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
56
|
+
if (text) {
|
|
57
|
+
content.text = transformer(text);
|
|
58
|
+
}
|
|
59
|
+
if (additionalInfo) {
|
|
60
|
+
content.additionalInfo = transformer(additionalInfo);
|
|
61
|
+
}
|
|
62
|
+
/* eslint-enable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
63
|
+
}
|
|
64
|
+
return content;
|
|
65
|
+
};
|
|
66
|
+
function parseContentLayoutTitle(transformer, content) {
|
|
67
|
+
if (content === null || content === void 0 ? void 0 : content.title) {
|
|
68
|
+
const { title } = content;
|
|
69
|
+
// eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign
|
|
70
|
+
content.title = title && parseTitle(transformer, title);
|
|
71
|
+
}
|
|
72
|
+
return content;
|
|
73
|
+
}
|
|
74
|
+
exports.blockHeaderTransformer = [
|
|
75
|
+
{
|
|
76
|
+
fields: ['title'],
|
|
77
|
+
transformer: common_1.typografTransformer,
|
|
78
|
+
parser: parseTitle,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
fields: ['description'],
|
|
82
|
+
transformer: common_1.yfmTransformer,
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
exports.config = {
|
|
86
|
+
[models_1.SubBlockType.BasicCard]: [
|
|
87
|
+
{
|
|
88
|
+
fields: ['title'],
|
|
89
|
+
transformer: common_1.typografTransformer,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
fields: ['text', 'additionalInfo'],
|
|
93
|
+
transformer: common_1.yfmTransformer,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
[models_1.SubBlockType.BackgroundCard]: [
|
|
97
|
+
{
|
|
98
|
+
fields: ['text', 'additionalInfo'],
|
|
99
|
+
transformer: common_1.yfmTransformer,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
fields: ['title'],
|
|
103
|
+
transformer: common_1.typografTransformer,
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
[models_1.SubBlockType.LayoutItem]: [
|
|
107
|
+
{
|
|
108
|
+
fields: ['content'],
|
|
109
|
+
parser: parseContentLayout,
|
|
110
|
+
transformer: common_1.yfmTransformer,
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
fields: ['content'],
|
|
114
|
+
parser: parseContentLayoutTitle,
|
|
115
|
+
transformer: common_1.typografTransformer,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
fields: ['metaInfo'],
|
|
119
|
+
parser: (0, common_1.createItemsParser)([]),
|
|
120
|
+
transformer: common_1.typografTransformer,
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
[models_1.SubBlockType.Quote]: {
|
|
124
|
+
fields: ['text'],
|
|
125
|
+
transformer: common_1.typografTransformer,
|
|
126
|
+
},
|
|
127
|
+
[models_1.BlockType.ExtendedFeaturesBlock]: [
|
|
128
|
+
...exports.blockHeaderTransformer,
|
|
129
|
+
{
|
|
130
|
+
fields: ['items'],
|
|
131
|
+
transformer: common_1.typografTransformer,
|
|
132
|
+
parser: (0, common_1.createItemsParser)(['title']),
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
fields: ['items'],
|
|
136
|
+
transformer: common_1.yfmTransformer,
|
|
137
|
+
parser: (0, common_1.createItemsParser)(['text', 'additionalInfo']),
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
[models_1.BlockType.PromoFeaturesBlock]: [
|
|
141
|
+
...exports.blockHeaderTransformer,
|
|
142
|
+
{
|
|
143
|
+
fields: ['items'],
|
|
144
|
+
transformer: common_1.yfmTransformer,
|
|
145
|
+
parser: parsePromoFeatures,
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
[models_1.BlockType.SliderBlock]: exports.blockHeaderTransformer,
|
|
149
|
+
[models_1.BlockType.QuestionsBlock]: [
|
|
150
|
+
{
|
|
151
|
+
fields: ['title'],
|
|
152
|
+
transformer: common_1.typografTransformer,
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
fields: ['text', 'additionalInfo'],
|
|
156
|
+
transformer: common_1.yfmTransformer,
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
fields: ['items'],
|
|
160
|
+
transformer: common_1.yfmTransformer,
|
|
161
|
+
parser: parseFeatures,
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
[models_1.BlockType.BannerBlock]: [
|
|
165
|
+
{
|
|
166
|
+
fields: ['title'],
|
|
167
|
+
transformer: common_1.typografTransformer,
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
fields: ['subtitle'],
|
|
171
|
+
transformer: common_1.yfmTransformer,
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
[models_1.SubBlockType.BannerCard]: [
|
|
175
|
+
{
|
|
176
|
+
fields: ['title'],
|
|
177
|
+
transformer: common_1.typografTransformer,
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
fields: ['subtitle'],
|
|
181
|
+
transformer: common_1.yfmTransformer,
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
[models_1.BlockType.MediaBlock]: [
|
|
185
|
+
...exports.blockHeaderTransformer,
|
|
186
|
+
{
|
|
187
|
+
fields: ['title', 'additionalInfo'],
|
|
188
|
+
transformer: common_1.yfmTransformer,
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
[models_1.BlockType.MapBlock]: [
|
|
192
|
+
...exports.blockHeaderTransformer,
|
|
193
|
+
{
|
|
194
|
+
fields: ['title', 'additionalInfo'],
|
|
195
|
+
transformer: common_1.yfmTransformer,
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
[models_1.BlockType.TabsBlock]: [
|
|
199
|
+
...exports.blockHeaderTransformer,
|
|
200
|
+
{
|
|
201
|
+
fields: ['items'],
|
|
202
|
+
transformer: common_1.yfmTransformer,
|
|
203
|
+
parser: (0, common_1.createItemsParser)(['text', 'additionalInfo']),
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
fields: ['items'],
|
|
207
|
+
transformer: common_1.typografTransformer,
|
|
208
|
+
parser: parseItemsTitle,
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
[models_1.BlockType.TableBlock]: [
|
|
212
|
+
{
|
|
213
|
+
fields: ['table'],
|
|
214
|
+
transformer: common_1.yfmTransformer,
|
|
215
|
+
parser: parseTableBlock,
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
[models_1.BlockType.HeaderSliderBlock]: [
|
|
219
|
+
{
|
|
220
|
+
fields: ['items'],
|
|
221
|
+
transformer: common_1.typografTransformer,
|
|
222
|
+
parser: (0, common_1.createItemsParser)(['title', 'overtitle']),
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
fields: ['items'],
|
|
226
|
+
transformer: common_1.yfmTransformer,
|
|
227
|
+
parser: (0, common_1.createItemsParser)(['description']),
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
[models_1.SubBlockType.PriceDetailed]: [
|
|
231
|
+
{
|
|
232
|
+
transformer: common_1.yfmTransformer,
|
|
233
|
+
parser: parsePriceDetailedBlock,
|
|
234
|
+
},
|
|
235
|
+
],
|
|
236
|
+
[models_1.BlockType.HeaderBlock]: [
|
|
237
|
+
{
|
|
238
|
+
fields: ['description'],
|
|
239
|
+
transformer: common_1.yfmTransformer,
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
[models_1.BlockType.ContentLayoutBlock]: [
|
|
243
|
+
{
|
|
244
|
+
fields: ['textContent'],
|
|
245
|
+
transformer: common_1.yfmTransformer,
|
|
246
|
+
parser: parseContentLayout,
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
fields: ['textContent'],
|
|
250
|
+
transformer: common_1.typografTransformer,
|
|
251
|
+
parser: parseContentLayoutTitle,
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
[models_1.SubBlockType.Content]: [
|
|
255
|
+
{
|
|
256
|
+
fields: ['text', 'additionalInfo'],
|
|
257
|
+
transformer: common_1.yfmTransformer,
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
fields: ['title'],
|
|
261
|
+
transformer: common_1.typografTransformer,
|
|
262
|
+
parser: parseTitle,
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
[models_1.BlockType.InfoBlock]: [
|
|
266
|
+
{
|
|
267
|
+
fields: ['rightContent', 'leftContent'],
|
|
268
|
+
transformer: common_1.yfmTransformer,
|
|
269
|
+
parser: parseContentLayout,
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
fields: ['rightContent', 'leftContent'],
|
|
273
|
+
transformer: common_1.typografTransformer,
|
|
274
|
+
parser: parseContentLayoutTitle,
|
|
275
|
+
},
|
|
276
|
+
],
|
|
277
|
+
[models_1.BlockType.ShareBlock]: [
|
|
278
|
+
{
|
|
279
|
+
fields: ['title'],
|
|
280
|
+
transformer: common_1.typografTransformer,
|
|
281
|
+
},
|
|
282
|
+
],
|
|
283
|
+
[models_1.BlockType.CardLayoutBlock]: exports.blockHeaderTransformer,
|
|
284
|
+
[models_1.BlockType.IconsBlock]: [
|
|
285
|
+
{
|
|
286
|
+
fields: ['title'],
|
|
287
|
+
transformer: common_1.typografTransformer,
|
|
288
|
+
parser: parseTitle,
|
|
289
|
+
},
|
|
290
|
+
],
|
|
291
|
+
};
|
|
@@ -2,4 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./utils"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./
|
|
5
|
+
tslib_1.__exportStar(require("./config"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./common"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./transformers"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ConstructorBlock } from '../models/constructor';
|
|
2
|
+
import { Lang } from '../utils/configure';
|
|
3
|
+
export type ContentTransformerProps = {
|
|
4
|
+
content: {
|
|
5
|
+
blocks?: ConstructorBlock[];
|
|
6
|
+
footnotes?: string[];
|
|
7
|
+
};
|
|
8
|
+
options: {
|
|
9
|
+
lang: Lang;
|
|
10
|
+
customConfig?: {};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare const contentTransformer: ({ content, options }: ContentTransformerProps) => {
|
|
14
|
+
blocks: ConstructorBlock[];
|
|
15
|
+
footnotes: string[];
|
|
16
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.contentTransformer = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
6
|
+
const config_1 = require("./config");
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
function transformBlocks(blocks, lang, customConfig = {}) {
|
|
9
|
+
const fullConfig = Object.assign(Object.assign({}, config_1.config), customConfig);
|
|
10
|
+
const clonedBlocks = lodash_1.default.cloneDeep(blocks);
|
|
11
|
+
return clonedBlocks.map((block) => transformBlock(lang, fullConfig, block));
|
|
12
|
+
}
|
|
13
|
+
function transformBlock(lang, blocksConfig, block) {
|
|
14
|
+
const blockConfig = blocksConfig[block.type];
|
|
15
|
+
if (block) {
|
|
16
|
+
if ('randomOrder' in block && block.randomOrder && 'children' in block && block.children) {
|
|
17
|
+
// eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign, no-param-reassign
|
|
18
|
+
block.children = lodash_1.default.shuffle(block.children);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (blockConfig) {
|
|
22
|
+
const configs = Array.isArray(blockConfig) ? blockConfig : [blockConfig];
|
|
23
|
+
configs.forEach((transformConfig) => {
|
|
24
|
+
const { fields, transformer: transformerRaw, parser } = transformConfig;
|
|
25
|
+
const transformer = transformerRaw.bind(null, lang);
|
|
26
|
+
if (fields) {
|
|
27
|
+
fields.forEach((field) => {
|
|
28
|
+
if (block[field]) {
|
|
29
|
+
if (parser) {
|
|
30
|
+
// eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign, no-param-reassign
|
|
31
|
+
block[field] = parser(transformer, block[field]);
|
|
32
|
+
}
|
|
33
|
+
else if (typeof block[field] === 'string') {
|
|
34
|
+
// eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign, no-param-reassign
|
|
35
|
+
block[field] = transformer(block[field]);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
else if (parser) {
|
|
41
|
+
parser(transformer, block);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if ('children' in block && block.children) {
|
|
46
|
+
// eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign, no-param-reassign
|
|
47
|
+
block.children = transformBlocks(block.children, lang, blocksConfig);
|
|
48
|
+
}
|
|
49
|
+
return block;
|
|
50
|
+
}
|
|
51
|
+
const contentTransformer = ({ content, options }) => {
|
|
52
|
+
const { lang, customConfig = {} } = options;
|
|
53
|
+
const { blocks = [], footnotes = [] } = content;
|
|
54
|
+
const transformedBlocks = transformBlocks(blocks, lang, customConfig);
|
|
55
|
+
const transformedFootnotes = (footnotes === null || footnotes === void 0 ? void 0 : footnotes.map((footnote) => (0, utils_1.fullTransform)(footnote, { path: __dirname, lang, allowHTML: true }).html).filter(Boolean)) || [];
|
|
56
|
+
return {
|
|
57
|
+
blocks: transformedBlocks,
|
|
58
|
+
footnotes: transformedFootnotes,
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
exports.contentTransformer = contentTransformer;
|
package/build/cjs/utils/index.js
CHANGED
|
@@ -5,7 +5,6 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
tslib_1.__exportStar(require("./common"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./analytics"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./blocks"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./scroll"), exports);
|
|
9
8
|
tslib_1.__exportStar(require("./url"), exports);
|
|
10
9
|
tslib_1.__exportStar(require("./cn"), exports);
|
|
11
10
|
tslib_1.__exportStar(require("./url"), exports);
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
export { default as BannerBlock } from './Banner/Banner';
|
|
2
2
|
export { default as CompaniesBlock } from './Companies/Companies';
|
|
3
|
-
export { default as SimpleBlock } from './Simple/Simple';
|
|
4
3
|
export { default as InfoBlock } from './Info/Info';
|
|
5
4
|
export { default as MediaBlock } from './Media/Media';
|
|
6
5
|
export { default as MapBlock } from './Map/Map';
|
|
7
|
-
export { default as PreviewBlock } from './Preview/Preview';
|
|
8
|
-
export { default as SecurityBlock } from './Security/Security';
|
|
9
6
|
export { default as SliderBlock } from './Slider/Slider';
|
|
10
7
|
export { default as ExtendedFeaturesBlock } from './ExtendedFeatures/ExtendedFeatures';
|
|
11
8
|
export { default as PromoFeaturesBlock } from './PromoFeaturesBlock/PromoFeaturesBlock';
|
|
12
9
|
export { default as QuestionsBlock } from './Questions/Questions';
|
|
13
10
|
export { default as TableBlock } from './Table/Table';
|
|
14
11
|
export { default as TabsBlock } from './Tabs/Tabs';
|
|
15
|
-
export { default as LinkTableBlock } from './LinkTable/LinkTable';
|
|
16
12
|
export { default as HeaderBlock } from './Header/Header';
|
|
17
13
|
export { default as IconsBlock } from './Icons/Icons';
|
|
18
14
|
export { default as HeaderSliderBlock } from './HeaderSlider/HeaderSlider';
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
export { default as BannerBlock } from './Banner/Banner';
|
|
2
2
|
export { default as CompaniesBlock } from './Companies/Companies';
|
|
3
|
-
export { default as SimpleBlock } from './Simple/Simple';
|
|
4
3
|
export { default as InfoBlock } from './Info/Info';
|
|
5
4
|
export { default as MediaBlock } from './Media/Media';
|
|
6
5
|
export { default as MapBlock } from './Map/Map';
|
|
7
|
-
export { default as PreviewBlock } from './Preview/Preview';
|
|
8
|
-
export { default as SecurityBlock } from './Security/Security';
|
|
9
6
|
export { default as SliderBlock } from './Slider/Slider';
|
|
10
7
|
export { default as ExtendedFeaturesBlock } from './ExtendedFeatures/ExtendedFeatures';
|
|
11
8
|
export { default as PromoFeaturesBlock } from './PromoFeaturesBlock/PromoFeaturesBlock';
|
|
12
9
|
export { default as QuestionsBlock } from './Questions/Questions';
|
|
13
10
|
export { default as TableBlock } from './Table/Table';
|
|
14
11
|
export { default as TabsBlock } from './Tabs/Tabs';
|
|
15
|
-
export { default as LinkTableBlock } from './LinkTable/LinkTable';
|
|
16
12
|
export { default as HeaderBlock } from './Header/Header';
|
|
17
13
|
export { default as IconsBlock } from './Icons/Icons';
|
|
18
14
|
export { default as HeaderSliderBlock } from './HeaderSlider/HeaderSlider';
|
|
@@ -7,13 +7,9 @@ export * from './Header/schema';
|
|
|
7
7
|
export * from './HeaderSlider/schema';
|
|
8
8
|
export * from './Icons/schema';
|
|
9
9
|
export * from './Info/schema';
|
|
10
|
-
export * from './LinkTable/schema';
|
|
11
10
|
export * from './Media/schema';
|
|
12
|
-
export * from './Preview/schema';
|
|
13
11
|
export * from './PromoFeaturesBlock/schema';
|
|
14
12
|
export * from './Questions/schema';
|
|
15
|
-
export * from './Security/schema';
|
|
16
|
-
export * from './Simple/schema';
|
|
17
13
|
export * from './Slider/schema';
|
|
18
14
|
export * from './Table/schema';
|
|
19
15
|
export * from './Share/schema';
|
|
@@ -7,13 +7,9 @@ export * from './Header/schema';
|
|
|
7
7
|
export * from './HeaderSlider/schema';
|
|
8
8
|
export * from './Icons/schema';
|
|
9
9
|
export * from './Info/schema';
|
|
10
|
-
export * from './LinkTable/schema';
|
|
11
10
|
export * from './Media/schema';
|
|
12
|
-
export * from './Preview/schema';
|
|
13
11
|
export * from './PromoFeaturesBlock/schema';
|
|
14
12
|
export * from './Questions/schema';
|
|
15
|
-
export * from './Security/schema';
|
|
16
|
-
export * from './Simple/schema';
|
|
17
13
|
export * from './Slider/schema';
|
|
18
14
|
export * from './Table/schema';
|
|
19
15
|
export * from './Share/schema';
|
|
@@ -3,7 +3,7 @@ import './Anchor.css';
|
|
|
3
3
|
export declare const qaIdByDefault = "qa-anchor";
|
|
4
4
|
export interface AnchorProps extends ClassNameProps {
|
|
5
5
|
id: string;
|
|
6
|
-
|
|
6
|
+
dataQa?: string;
|
|
7
7
|
}
|
|
8
|
-
declare const Anchor: ({ id, className,
|
|
8
|
+
declare const Anchor: ({ id, className, dataQa }: AnchorProps) => JSX.Element;
|
|
9
9
|
export default Anchor;
|
|
@@ -4,5 +4,5 @@ import { block } from '../../utils';
|
|
|
4
4
|
import './Anchor.css';
|
|
5
5
|
const b = block('Anchor');
|
|
6
6
|
export const qaIdByDefault = 'qa-anchor';
|
|
7
|
-
const Anchor = ({ id, className,
|
|
7
|
+
const Anchor = ({ id, className, dataQa }) => (React.createElement("div", { id: id, className: b(null, className), "data-qa": dataQa || qaIdByDefault }));
|
|
8
8
|
export default Anchor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import Anchor from '../Anchor';
|
|
4
|
+
const testId = 'anchor';
|
|
5
|
+
const anchorId = 'anchorId';
|
|
6
|
+
describe('Anchor', () => {
|
|
7
|
+
test('Has id', async () => {
|
|
8
|
+
render(React.createElement(Anchor, { id: anchorId, dataQa: testId }));
|
|
9
|
+
const anchor = screen.getByTestId(testId);
|
|
10
|
+
expect(anchor).toHaveAttribute('id', anchorId);
|
|
11
|
+
});
|
|
12
|
+
test('Has custom class', async () => {
|
|
13
|
+
const className = 'custom-anchor-class';
|
|
14
|
+
render(React.createElement(Anchor, { id: anchorId, className: className, dataQa: testId }));
|
|
15
|
+
const anchor = screen.getByTestId(testId);
|
|
16
|
+
expect(anchor).toHaveClass(className);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import AnimateBlock from '../AnimateBlock';
|
|
5
|
+
const qaId = 'animate-block';
|
|
6
|
+
describe('AnimateBlock', () => {
|
|
7
|
+
test('render AnimateBlock by default', async () => {
|
|
8
|
+
render(React.createElement(AnimateBlock, { qa: qaId }));
|
|
9
|
+
const component = screen.getByTestId(qaId);
|
|
10
|
+
expect(component).toBeInTheDocument();
|
|
11
|
+
});
|
|
12
|
+
test('add className', () => {
|
|
13
|
+
const className = 'my-class';
|
|
14
|
+
render(React.createElement(AnimateBlock, { qa: qaId, className: className }));
|
|
15
|
+
const component = screen.getByTestId(qaId);
|
|
16
|
+
expect(component).toHaveClass(className);
|
|
17
|
+
});
|
|
18
|
+
test('use passed style', () => {
|
|
19
|
+
const style = { color: 'red' };
|
|
20
|
+
render(React.createElement(AnimateBlock, { style: style, qa: qaId }));
|
|
21
|
+
const component = screen.getByTestId(qaId);
|
|
22
|
+
expect(component).toHaveStyle(style);
|
|
23
|
+
});
|
|
24
|
+
test('call onScroll', async () => {
|
|
25
|
+
const onScroll = jest.fn();
|
|
26
|
+
const user = userEvent.setup();
|
|
27
|
+
render(React.createElement("div", { style: { paddingTop: 100000 } },
|
|
28
|
+
React.createElement(AnimateBlock, { onScroll: onScroll, qa: qaId })));
|
|
29
|
+
const component = screen.getByTestId(qaId);
|
|
30
|
+
await user.hover(component);
|
|
31
|
+
expect(onScroll).toHaveBeenCalledTimes(1);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|