@gravity-ui/page-constructor 2.22.0-alpha → 2.22.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 +60 -0
- package/build/cjs/components/Anchor/Anchor.d.ts +2 -2
- package/build/cjs/components/Anchor/Anchor.js +1 -1
- package/build/cjs/components/BackgroundImage/BackgroundImage.js +2 -2
- package/build/cjs/components/BlockBase/BlockBase.d.ts +3 -2
- package/build/cjs/components/BlockBase/BlockBase.js +4 -2
- package/build/cjs/components/Button/Button.css +3 -0
- package/build/cjs/components/Button/Button.js +5 -4
- package/build/cjs/components/FullscreenMedia/FullscreenMedia.js +3 -1
- package/build/cjs/components/Image/Image.d.ts +1 -0
- package/build/cjs/components/Image/Image.js +2 -2
- package/build/cjs/components/Media/Image/Image.js +3 -3
- package/build/cjs/components/Media/Media.js +5 -3
- package/build/cjs/containers/Loadable/Loadable.d.ts +2 -2
- package/build/cjs/containers/PageConstructor/PageConstructor.js +5 -3
- package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +3 -2
- package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts +1 -1
- package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.js +5 -5
- package/build/cjs/context/innerContext/InnerContext.d.ts +2 -1
- package/build/cjs/customization/BlockDecoration.d.ts +3 -0
- package/build/cjs/customization/BlockDecoration.js +22 -0
- package/build/cjs/editor/Components/AddBlock/AddBlock.css +82 -0
- package/build/cjs/editor/Components/AddBlock/AddBlock.d.ts +7 -0
- package/build/cjs/editor/Components/AddBlock/AddBlock.js +43 -0
- package/build/cjs/editor/Components/EditBlock/EditBlock.css +47 -0
- package/build/cjs/editor/Components/EditBlock/EditBlock.d.ts +4 -0
- package/build/cjs/editor/Components/EditBlock/EditBlock.js +32 -0
- package/build/cjs/editor/Containers/Editor.d.ts +2 -0
- package/build/cjs/editor/Containers/Editor.js +24 -0
- package/build/cjs/editor/data/index.d.ts +13 -0
- package/build/cjs/editor/data/index.js +27 -0
- package/build/cjs/editor/data/previews/default-preview.d.ts +3 -0
- package/build/cjs/editor/data/previews/default-preview.js +18 -0
- package/build/cjs/editor/data/previews/header-block.d.ts +3 -0
- package/build/cjs/editor/data/previews/header-block.js +19 -0
- package/build/cjs/editor/index.d.ts +2 -0
- package/build/cjs/editor/index.js +7 -0
- package/build/cjs/editor/store/index.d.ts +15 -0
- package/build/cjs/editor/store/index.js +32 -0
- package/build/cjs/editor/store/reducer.d.ts +41 -0
- package/build/cjs/editor/store/reducer.js +59 -0
- package/build/cjs/editor/store/utils.d.ts +13 -0
- package/build/cjs/editor/store/utils.js +34 -0
- package/build/cjs/editor/styles/mixins.css +0 -0
- package/build/cjs/editor/styles/variables.css +0 -0
- package/build/cjs/editor/types/index.d.ts +17 -0
- package/build/cjs/editor/types/index.js +2 -0
- package/build/cjs/editor/utils/index.d.ts +11 -0
- package/build/cjs/editor/utils/index.js +12 -0
- package/build/cjs/grid/Col/Col.d.ts +1 -1
- package/build/cjs/hooks/useMetrika.js +0 -7
- package/build/cjs/internal-typings/global.d.ts +18 -16
- package/build/cjs/models/constructor-items/blocks.d.ts +1 -11
- package/build/cjs/models/constructor-items/blocks.js +0 -2
- package/build/cjs/models/constructor-items/common.d.ts +3 -3
- package/build/cjs/models/constructor.d.ts +4 -1
- package/build/cjs/models/customization.d.ts +9 -0
- package/build/cjs/models/customization.js +2 -0
- package/build/cjs/models/index.d.ts +1 -0
- package/build/cjs/models/index.js +1 -0
- 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/utils/blocks.d.ts +4 -1
- package/build/cjs/utils/blocks.js +11 -1
- package/build/esm/components/Anchor/Anchor.d.ts +2 -2
- package/build/esm/components/Anchor/Anchor.js +1 -1
- package/build/esm/components/BackgroundImage/BackgroundImage.js +2 -2
- package/build/esm/components/BlockBase/BlockBase.d.ts +3 -2
- package/build/esm/components/BlockBase/BlockBase.js +4 -2
- package/build/esm/components/Button/Button.css +3 -0
- package/build/esm/components/Button/Button.js +5 -4
- package/build/esm/components/FullscreenMedia/FullscreenMedia.js +3 -1
- package/build/esm/components/Image/Image.d.ts +1 -0
- package/build/esm/components/Image/Image.js +2 -2
- package/build/esm/components/Media/Image/Image.js +3 -3
- package/build/esm/components/Media/Media.js +5 -3
- package/build/esm/containers/Loadable/Loadable.d.ts +2 -2
- package/build/esm/containers/PageConstructor/PageConstructor.js +6 -4
- package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +3 -2
- package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts +1 -1
- package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.js +5 -5
- package/build/esm/context/innerContext/InnerContext.d.ts +2 -1
- package/build/esm/customization/BlockDecoration.d.ts +3 -0
- package/build/esm/customization/BlockDecoration.js +17 -0
- package/build/esm/editor/Components/AddBlock/AddBlock.css +82 -0
- package/build/esm/editor/Components/AddBlock/AddBlock.d.ts +8 -0
- package/build/esm/editor/Components/AddBlock/AddBlock.js +41 -0
- package/build/esm/editor/Components/EditBlock/EditBlock.css +47 -0
- package/build/esm/editor/Components/EditBlock/EditBlock.d.ts +5 -0
- package/build/esm/editor/Components/EditBlock/EditBlock.js +30 -0
- package/build/esm/editor/Containers/Editor.d.ts +2 -0
- package/build/esm/editor/Containers/Editor.js +20 -0
- package/build/esm/editor/data/index.d.ts +13 -0
- package/build/esm/editor/data/index.js +24 -0
- package/build/esm/editor/data/previews/default-preview.d.ts +3 -0
- package/build/esm/editor/data/previews/default-preview.js +15 -0
- package/build/esm/editor/data/previews/header-block.d.ts +3 -0
- package/build/esm/editor/data/previews/header-block.js +16 -0
- package/build/esm/editor/index.d.ts +2 -0
- package/build/esm/editor/index.js +2 -0
- package/build/esm/editor/store/index.d.ts +15 -0
- package/build/esm/editor/store/index.js +28 -0
- package/build/esm/editor/store/reducer.d.ts +41 -0
- package/build/esm/editor/store/reducer.js +55 -0
- package/build/esm/editor/store/utils.d.ts +13 -0
- package/build/esm/editor/store/utils.js +26 -0
- package/build/esm/editor/styles/mixins.css +0 -0
- package/build/esm/editor/styles/variables.css +0 -0
- package/build/esm/editor/types/index.d.ts +17 -0
- package/build/esm/editor/utils/index.d.ts +11 -0
- package/build/esm/editor/utils/index.js +6 -0
- package/build/esm/grid/Col/Col.d.ts +1 -1
- package/build/esm/hooks/useMetrika.js +0 -7
- package/build/esm/internal-typings/global.d.ts +18 -16
- package/build/esm/models/constructor-items/blocks.d.ts +1 -11
- package/build/esm/models/constructor-items/blocks.js +0 -2
- package/build/esm/models/constructor-items/common.d.ts +3 -3
- package/build/esm/models/constructor.d.ts +4 -1
- package/build/esm/models/customization.d.ts +9 -0
- package/build/esm/models/index.d.ts +1 -0
- package/build/esm/models/index.js +1 -0
- 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/utils/blocks.d.ts +4 -1
- package/build/esm/utils/blocks.js +7 -0
- package/package.json +4 -6
- package/server/models/constructor-items/blocks.d.ts +1 -11
- package/server/models/constructor-items/blocks.js +0 -2
- package/server/models/constructor-items/common.d.ts +3 -3
- package/server/models/constructor.d.ts +4 -1
- package/server/models/customization.d.ts +9 -0
- package/server/models/customization.js +2 -0
- package/server/models/index.d.ts +1 -0
- package/server/models/index.js +1 -0
- package/server/utils/blocks.d.ts +4 -1
- package/server/utils/blocks.js +11 -1
- package/build/cjs/components/Anchor/__tests__/Anchor.test.js +0 -21
- 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
- /package/build/{cjs/components/Anchor/__tests__/Anchor.test.d.ts → esm/editor/types/index.js} +0 -0
- /package/build/{cjs/components/AnimateBlock/__tests__/AnimateBlock.test.d.ts → esm/models/customization.js} +0 -0
|
@@ -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,4 @@
|
|
|
1
|
-
import { CustomConfig, PCShareSocialNetwork, TextSize } from '../models';
|
|
1
|
+
import { Block, CustomConfig, PCShareSocialNetwork, TextSize } from '../models';
|
|
2
2
|
import { ConstructorBlock } from '../models/constructor';
|
|
3
3
|
export declare function getHeaderTag(size: TextSize): "h1" | "h2" | "h4" | "h5";
|
|
4
4
|
export declare function getBlockKey(block: ConstructorBlock, index: number): string;
|
|
@@ -8,4 +8,7 @@ export declare const getCustomItems: ({ blocks, headers, subBlocks }?: CustomCon
|
|
|
8
8
|
};
|
|
9
9
|
export declare const getCustomSubBlockTypes: (customBlocks?: CustomConfig) => string[];
|
|
10
10
|
export declare const getCustomHeaderTypes: (customBlocks?: CustomConfig) => string[];
|
|
11
|
+
export declare const getOrderedBlocks: (blocks: Block[], headerBlockTypes?: string[]) => Block[];
|
|
12
|
+
export declare const getHeaderBlock: (blocks: Block[], headerBlockTypes?: string[]) => Block | undefined;
|
|
11
13
|
export declare const getShareLink: (url: string, type: PCShareSocialNetwork, title?: string, text?: string) => string | undefined;
|
|
14
|
+
export declare const getBlockIndexFromId: (blockId?: string) => number;
|
|
@@ -37,6 +37,12 @@ const getShareUrlWithParams = (url, params = {}) => {
|
|
|
37
37
|
});
|
|
38
38
|
return result.toString();
|
|
39
39
|
};
|
|
40
|
+
export const getOrderedBlocks = (blocks, headerBlockTypes = []) => {
|
|
41
|
+
return blocks.filter(({ type }) => !headerBlockTypes.includes(type));
|
|
42
|
+
};
|
|
43
|
+
export const getHeaderBlock = (blocks, headerBlockTypes = []) => {
|
|
44
|
+
return blocks.find(({ type }) => headerBlockTypes.includes(type));
|
|
45
|
+
};
|
|
40
46
|
export const getShareLink = (url, type, title, text) => {
|
|
41
47
|
// https://github.com/bradvin/social-share-urls
|
|
42
48
|
switch (type) {
|
|
@@ -65,3 +71,4 @@ export const getShareLink = (url, type, title, text) => {
|
|
|
65
71
|
return undefined;
|
|
66
72
|
}
|
|
67
73
|
};
|
|
74
|
+
export const getBlockIndexFromId = (blockId) => { var _a; return Number((_a = blockId === null || blockId === void 0 ? void 0 : blockId.split('-')) === null || _a === void 0 ? void 0 : _a.slice(-1).pop()); };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/page-constructor",
|
|
3
|
-
"version": "2.22.0
|
|
3
|
+
"version": "2.22.0",
|
|
4
4
|
"description": "Gravity UI Page Constructor",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -61,15 +61,16 @@
|
|
|
61
61
|
"uuid": "^9.0.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"
|
|
64
|
+
"@doc-tools/transform": "^2.6.1",
|
|
65
65
|
"@gravity-ui/uikit": "^4.1.0",
|
|
66
|
-
"
|
|
66
|
+
"react": "^16.0.0 || ^17.0.0 || ^18.0.0"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@commitlint/cli": "^17.1.2",
|
|
70
70
|
"@commitlint/config-conventional": "^17.1.0",
|
|
71
71
|
"@doc-tools/transform": "2.12.0",
|
|
72
72
|
"@gravity-ui/eslint-config": "^2.0.0",
|
|
73
|
+
"@gravity-ui/icons": "^2.1.0",
|
|
73
74
|
"@gravity-ui/prettier-config": "^1.0.1",
|
|
74
75
|
"@gravity-ui/stylelint-config": "^1.0.0",
|
|
75
76
|
"@gravity-ui/tsconfig": "^1.0.0",
|
|
@@ -138,8 +139,5 @@
|
|
|
138
139
|
"*.{json,yaml,yml,md}": [
|
|
139
140
|
"prettier --write"
|
|
140
141
|
]
|
|
141
|
-
},
|
|
142
|
-
"publishConfig": {
|
|
143
|
-
"tag": "alpha"
|
|
144
142
|
}
|
|
145
143
|
}
|
|
@@ -8,8 +8,6 @@ export declare enum BlockType {
|
|
|
8
8
|
PromoFeaturesBlock = "promo-features-block",
|
|
9
9
|
ExtendedFeaturesBlock = "extended-features-block",
|
|
10
10
|
SliderBlock = "slider-block",
|
|
11
|
-
CalculatorBlock = "calculator-block",
|
|
12
|
-
ServiceDemoBlock = "service-demo-block",
|
|
13
11
|
QuestionsBlock = "questions-block",
|
|
14
12
|
BannerBlock = "banner-block",
|
|
15
13
|
CompaniesBlock = "companies-block",
|
|
@@ -52,7 +50,6 @@ export interface LoadableProps {
|
|
|
52
50
|
export interface LoadableChildren {
|
|
53
51
|
loadable?: LoadableProps;
|
|
54
52
|
}
|
|
55
|
-
export type ServiceDemoProps = Animatable;
|
|
56
53
|
export declare enum SliderBreakpointNames {
|
|
57
54
|
Sm = "sm",
|
|
58
55
|
Md = "md",
|
|
@@ -114,7 +111,6 @@ export interface HeaderBlockProps {
|
|
|
114
111
|
breadcrumbs?: HeaderBreadCrumbsProps;
|
|
115
112
|
status?: JSX.Element;
|
|
116
113
|
}
|
|
117
|
-
export type CalculatorProps = Animatable;
|
|
118
114
|
export interface SimpleBlockProps extends Animatable, Childable {
|
|
119
115
|
title: TitleBaseProps;
|
|
120
116
|
description: string;
|
|
@@ -317,15 +313,9 @@ export interface ShareBlockProps {
|
|
|
317
313
|
export type HeaderBlockModel = {
|
|
318
314
|
type: BlockType.HeaderBlock;
|
|
319
315
|
} & HeaderBlockProps;
|
|
320
|
-
export type CalculatorBlockModel = {
|
|
321
|
-
type: BlockType.CalculatorBlock;
|
|
322
|
-
} & CalculatorProps;
|
|
323
316
|
export type SliderBlockModel = {
|
|
324
317
|
type: BlockType.SliderBlock;
|
|
325
318
|
} & SliderProps;
|
|
326
|
-
export type ServiceDemoBlockModel = {
|
|
327
|
-
type: BlockType.ServiceDemoBlock;
|
|
328
|
-
} & ServiceDemoProps;
|
|
329
319
|
export type ExtendedFeaturesBlockModel = {
|
|
330
320
|
type: BlockType.ExtendedFeaturesBlock;
|
|
331
321
|
} & ExtendedFeaturesProps;
|
|
@@ -386,6 +376,6 @@ export type ContentLayoutBlockModel = {
|
|
|
386
376
|
export type ShareBLockModel = {
|
|
387
377
|
type: BlockType.ShareBlock;
|
|
388
378
|
} & ShareBlockProps;
|
|
389
|
-
type BlockModels = SliderBlockModel |
|
|
379
|
+
type BlockModels = SliderBlockModel | ExtendedFeaturesBlockModel | PromoFeaturesBlockModel | QuestionsBlockModel | BannerBlockModel | CompaniesBlockModel | MediaBlockModel | MapBlockModel | InfoBlockModel | SecurityBlockModel | TableBlockModel | TabsBlockModel | SimpleBlockModel | LinkTableBlockModel | HeaderBlockModel | PreviewBlockModel | IconsBlockModel | HeaderSliderBlockModel | CardLayoutBlockModel | ContentLayoutBlockModel | ShareBLockModel | FilterBlockModel;
|
|
390
380
|
export type Block = BlockModels & BlockBaseProps;
|
|
391
381
|
export {};
|
|
@@ -6,8 +6,6 @@ var BlockType;
|
|
|
6
6
|
BlockType["PromoFeaturesBlock"] = "promo-features-block";
|
|
7
7
|
BlockType["ExtendedFeaturesBlock"] = "extended-features-block";
|
|
8
8
|
BlockType["SliderBlock"] = "slider-block";
|
|
9
|
-
BlockType["CalculatorBlock"] = "calculator-block";
|
|
10
|
-
BlockType["ServiceDemoBlock"] = "service-demo-block";
|
|
11
9
|
BlockType["QuestionsBlock"] = "questions-block";
|
|
12
10
|
BlockType["BannerBlock"] = "banner-block";
|
|
13
11
|
BlockType["CompaniesBlock"] = "companies-block";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ButtonView, ButtonProps as UikitButtonProps } from '@gravity-ui/uikit';
|
|
3
3
|
import { ThemeSupporting } from '../../utils/theme';
|
|
4
4
|
import { AnalyticsEventsBase, ClassNameProps, PixelEventType } from '../common';
|
|
5
5
|
export declare enum AuthorType {
|
|
@@ -99,6 +99,7 @@ export interface BackgroundImageProps extends React.HTMLProps<HTMLDivElement>, P
|
|
|
99
99
|
style?: CSSProperties;
|
|
100
100
|
imageClassName?: string;
|
|
101
101
|
hide?: boolean;
|
|
102
|
+
qa?: string;
|
|
102
103
|
}
|
|
103
104
|
export interface MediaVideoProps extends AnalyticsEventsBase {
|
|
104
105
|
src: string[];
|
|
@@ -131,11 +132,10 @@ export interface FileLinkProps extends ClassNameProps {
|
|
|
131
132
|
onClick?: () => void;
|
|
132
133
|
}
|
|
133
134
|
export type ButtonTheme = ButtonView | 'github' | 'app-store' | 'google-play' | 'scale' | 'monochrome';
|
|
134
|
-
export interface ButtonProps extends AnalyticsEventsBase {
|
|
135
|
+
export interface ButtonProps extends AnalyticsEventsBase, Pick<UikitButtonProps, 'size' | 'width'> {
|
|
135
136
|
text: string;
|
|
136
137
|
url: string;
|
|
137
138
|
primary?: boolean;
|
|
138
|
-
size?: ButtonSize;
|
|
139
139
|
theme?: ButtonTheme;
|
|
140
140
|
img?: ButtonImageProps | string;
|
|
141
141
|
metrikaGoals?: MetrikaGoal;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from 'react';
|
|
2
|
-
import { Animatable, Block, ConstructorItem, ThemedMediaProps, WithChildren } from './';
|
|
2
|
+
import { Animatable, Block, BlockDecoratorProps, ConstructorItem, ThemedMediaProps, WithChildren } from './';
|
|
3
3
|
export interface PageData {
|
|
4
4
|
content: PageContent;
|
|
5
5
|
}
|
|
@@ -41,5 +41,8 @@ export interface CustomConfig {
|
|
|
41
41
|
subBlocks?: CustomItems;
|
|
42
42
|
headers?: CustomItems;
|
|
43
43
|
loadable?: LoadableConfig;
|
|
44
|
+
decorators?: {
|
|
45
|
+
block?: ((props: BlockDecoratorProps) => React.ReactElement)[];
|
|
46
|
+
};
|
|
44
47
|
}
|
|
45
48
|
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
export interface BlockDecorationProps extends PropsWithChildren {
|
|
3
|
+
id?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface BlockDecoratorProps extends PropsWithChildren {
|
|
6
|
+
id: string | number;
|
|
7
|
+
isHeader?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export type BlockDecorator = (props: BlockDecoratorProps) => React.ReactElement;
|
package/server/models/index.d.ts
CHANGED
package/server/models/index.js
CHANGED
package/server/utils/blocks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CustomConfig, PCShareSocialNetwork, TextSize } from '../models';
|
|
1
|
+
import { Block, CustomConfig, PCShareSocialNetwork, TextSize } from '../models';
|
|
2
2
|
import { ConstructorBlock } from '../models/constructor';
|
|
3
3
|
export declare function getHeaderTag(size: TextSize): "h1" | "h2" | "h4" | "h5";
|
|
4
4
|
export declare function getBlockKey(block: ConstructorBlock, index: number): string;
|
|
@@ -8,4 +8,7 @@ export declare const getCustomItems: ({ blocks, headers, subBlocks }?: CustomCon
|
|
|
8
8
|
};
|
|
9
9
|
export declare const getCustomSubBlockTypes: (customBlocks?: CustomConfig) => string[];
|
|
10
10
|
export declare const getCustomHeaderTypes: (customBlocks?: CustomConfig) => string[];
|
|
11
|
+
export declare const getOrderedBlocks: (blocks: Block[], headerBlockTypes?: string[]) => Block[];
|
|
12
|
+
export declare const getHeaderBlock: (blocks: Block[], headerBlockTypes?: string[]) => Block | undefined;
|
|
11
13
|
export declare const getShareLink: (url: string, type: PCShareSocialNetwork, title?: string, text?: string) => string | undefined;
|
|
14
|
+
export declare const getBlockIndexFromId: (blockId?: string) => number;
|
package/server/utils/blocks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getShareLink = exports.getCustomHeaderTypes = exports.getCustomSubBlockTypes = exports.getCustomItems = exports.getCustomBlockTypes = exports.getBlockKey = exports.getHeaderTag = void 0;
|
|
3
|
+
exports.getBlockIndexFromId = exports.getShareLink = exports.getHeaderBlock = exports.getOrderedBlocks = exports.getCustomHeaderTypes = exports.getCustomSubBlockTypes = exports.getCustomItems = exports.getCustomBlockTypes = exports.getBlockKey = exports.getHeaderTag = void 0;
|
|
4
4
|
const models_1 = require("../models");
|
|
5
5
|
function getHeaderTag(size) {
|
|
6
6
|
switch (size) {
|
|
@@ -46,6 +46,14 @@ const getShareUrlWithParams = (url, params = {}) => {
|
|
|
46
46
|
});
|
|
47
47
|
return result.toString();
|
|
48
48
|
};
|
|
49
|
+
const getOrderedBlocks = (blocks, headerBlockTypes = []) => {
|
|
50
|
+
return blocks.filter(({ type }) => !headerBlockTypes.includes(type));
|
|
51
|
+
};
|
|
52
|
+
exports.getOrderedBlocks = getOrderedBlocks;
|
|
53
|
+
const getHeaderBlock = (blocks, headerBlockTypes = []) => {
|
|
54
|
+
return blocks.find(({ type }) => headerBlockTypes.includes(type));
|
|
55
|
+
};
|
|
56
|
+
exports.getHeaderBlock = getHeaderBlock;
|
|
49
57
|
const getShareLink = (url, type, title, text) => {
|
|
50
58
|
// https://github.com/bradvin/social-share-urls
|
|
51
59
|
switch (type) {
|
|
@@ -75,3 +83,5 @@ const getShareLink = (url, type, title, text) => {
|
|
|
75
83
|
}
|
|
76
84
|
};
|
|
77
85
|
exports.getShareLink = getShareLink;
|
|
86
|
+
const getBlockIndexFromId = (blockId) => { var _a; return Number((_a = blockId === null || blockId === void 0 ? void 0 : blockId.split('-')) === null || _a === void 0 ? void 0 : _a.slice(-1).pop()); };
|
|
87
|
+
exports.getBlockIndexFromId = getBlockIndexFromId;
|
|
@@ -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,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 {};
|
|
@@ -1,91 +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 Button_1 = tslib_1.__importDefault(require("../Button"));
|
|
8
|
-
const utils_1 = require("../utils");
|
|
9
|
-
const qaId = 'button-component';
|
|
10
|
-
const buttonProps = {
|
|
11
|
-
text: 'Button Text',
|
|
12
|
-
url: 'https://github.com/gravity-ui/',
|
|
13
|
-
target: '_blank',
|
|
14
|
-
img: {
|
|
15
|
-
url: 'https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/icon_1_light.svg',
|
|
16
|
-
position: 'left',
|
|
17
|
-
alt: 'alt-text',
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
const buttonViews = [
|
|
21
|
-
'normal',
|
|
22
|
-
'action',
|
|
23
|
-
'outlined',
|
|
24
|
-
'outlined-info',
|
|
25
|
-
'outlined-danger',
|
|
26
|
-
'raised',
|
|
27
|
-
'flat',
|
|
28
|
-
'flat-info',
|
|
29
|
-
'flat-danger',
|
|
30
|
-
'flat-secondary',
|
|
31
|
-
'normal-contrast',
|
|
32
|
-
'outlined-contrast',
|
|
33
|
-
'flat-contrast',
|
|
34
|
-
'github',
|
|
35
|
-
'scale',
|
|
36
|
-
'monochrome',
|
|
37
|
-
];
|
|
38
|
-
describe('Button', () => {
|
|
39
|
-
test('render button by default', async () => {
|
|
40
|
-
(0, react_2.render)(react_1.default.createElement(Button_1.default, { text: buttonProps.text }));
|
|
41
|
-
const button = react_2.screen.getByRole('button');
|
|
42
|
-
expect(button).toBeInTheDocument();
|
|
43
|
-
expect(button).toBeVisible();
|
|
44
|
-
expect(button).not.toBeDisabled();
|
|
45
|
-
});
|
|
46
|
-
test('should render <a /> tag', async () => {
|
|
47
|
-
(0, react_2.render)(react_1.default.createElement(Button_1.default, { text: buttonProps.text, url: buttonProps.url, target: buttonProps.target }));
|
|
48
|
-
const button = react_2.screen.getByRole('link');
|
|
49
|
-
expect(button).toBeVisible();
|
|
50
|
-
expect(button).toHaveAttribute('href', buttonProps.url);
|
|
51
|
-
expect(button).toHaveAttribute('target', buttonProps.target);
|
|
52
|
-
});
|
|
53
|
-
test('call onClick', async () => {
|
|
54
|
-
const user = user_event_1.default.setup();
|
|
55
|
-
const handleOnClick = jest.fn();
|
|
56
|
-
(0, react_2.render)(react_1.default.createElement(Button_1.default, { text: buttonProps.text, onClick: handleOnClick }));
|
|
57
|
-
const button = react_2.screen.getByRole('button');
|
|
58
|
-
await user.click(button);
|
|
59
|
-
expect(handleOnClick).toHaveBeenCalledTimes(1);
|
|
60
|
-
});
|
|
61
|
-
test.each(new Array('s', 'm', 'l', 'xl'))('render with given "%s" size', (size) => {
|
|
62
|
-
(0, react_2.render)(react_1.default.createElement(Button_1.default, { text: buttonProps.text, size: size, qa: qaId }));
|
|
63
|
-
const button = react_2.screen.getByTestId(qaId);
|
|
64
|
-
expect(button).toHaveClass(`pc-button-block_size_${size}`);
|
|
65
|
-
});
|
|
66
|
-
test.each(new Array(...buttonViews))('render with given "%s" view', (theme) => {
|
|
67
|
-
(0, react_2.render)(react_1.default.createElement(Button_1.default, { text: buttonProps.text, theme: theme, qa: qaId }));
|
|
68
|
-
const button = react_2.screen.getByTestId(qaId);
|
|
69
|
-
expect(button).toHaveClass(`pc-button-block_theme_${theme}`);
|
|
70
|
-
});
|
|
71
|
-
test('add className', () => {
|
|
72
|
-
const className = 'my-class';
|
|
73
|
-
(0, react_2.render)(react_1.default.createElement(Button_1.default, { text: buttonProps.text, className: className, qa: qaId }));
|
|
74
|
-
const button = react_2.screen.getByTestId(qaId);
|
|
75
|
-
expect(button).toHaveClass(className);
|
|
76
|
-
});
|
|
77
|
-
test('should render icon', () => {
|
|
78
|
-
(0, react_2.render)(react_1.default.createElement(Button_1.default, { text: buttonProps.text, img: buttonProps.img }));
|
|
79
|
-
const button = react_2.screen.getByRole('button');
|
|
80
|
-
const iconComponent = react_2.screen.getByRole('img');
|
|
81
|
-
expect(iconComponent).toBeVisible();
|
|
82
|
-
expect(button).toContainElement(iconComponent);
|
|
83
|
-
});
|
|
84
|
-
test('should render github icon', () => {
|
|
85
|
-
(0, react_2.render)(react_1.default.createElement(Button_1.default, { text: buttonProps.text, img: buttonProps.img, theme: "github" }));
|
|
86
|
-
const button = react_2.screen.getByRole('button');
|
|
87
|
-
const iconComponent = react_2.screen.getByTestId(utils_1.ICON_QA);
|
|
88
|
-
expect(iconComponent).toBeVisible();
|
|
89
|
-
expect(button).toContainElement(iconComponent);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|