@gravity-ui/page-constructor 1.26.1 → 1.26.2-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 +34 -14
- package/README.md +7 -8
- package/build/cjs/blocks/Map/schema.d.ts +0 -12
- package/build/cjs/blocks/Share/Share.css +12 -11
- package/build/cjs/components/BlockHeader/BlockHeader.css +2 -2
- package/build/cjs/components/Button/Button.d.ts +1 -0
- package/build/cjs/components/Button/Button.js +1 -1
- 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/Button/utils.d.ts +1 -0
- package/build/cjs/components/Button/utils.js +2 -1
- package/build/cjs/components/ButtonTabs/ButtonTabs.css +6 -6
- package/build/cjs/components/HTML/HTML.d.ts +1 -1
- package/build/cjs/components/Map/GoogleMap.js +7 -5
- package/build/cjs/components/Map/Map.css +5 -0
- package/build/cjs/components/Map/YMap/YMap.d.ts +4 -2
- package/build/cjs/components/Map/YMap/YMap.js +18 -10
- package/build/cjs/components/Map/YMap/YandexMap.js +18 -9
- package/build/cjs/components/ReactPlayer/utils.js +13 -12
- package/build/cjs/components/Title/Title.css +20 -5
- package/build/cjs/components/Title/Title.d.ts +1 -1
- package/build/cjs/components/Title/Title.js +4 -2
- package/build/cjs/models/constructor-items/common.d.ts +5 -5
- package/build/cjs/navigation/components/Navigation/Navigation.js +7 -6
- package/build/cjs/schema/validators/common.d.ts +0 -6
- package/build/cjs/schema/validators/common.js +0 -4
- package/build/cjs/sub-blocks/BannerCard/BannerCard.css +2 -1
- package/build/cjs/sub-blocks/Content/Content.css +6 -0
- package/build/cjs/sub-blocks/HubspotForm/HubspotForm.css +1 -0
- package/build/cjs/utils/blocks.d.ts +1 -1
- package/build/cjs/utils/blocks.js +2 -0
- package/build/esm/blocks/Map/schema.d.ts +0 -12
- package/build/esm/blocks/Share/Share.css +12 -11
- package/build/esm/components/BlockHeader/BlockHeader.css +2 -2
- package/build/esm/components/Button/Button.d.ts +1 -0
- package/build/esm/components/Button/Button.js +2 -2
- 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/Button/utils.d.ts +1 -0
- package/build/esm/components/Button/utils.js +1 -0
- package/build/esm/components/ButtonTabs/ButtonTabs.css +6 -6
- package/build/esm/components/HTML/HTML.d.ts +1 -1
- package/build/esm/components/Map/GoogleMap.js +7 -5
- package/build/esm/components/Map/Map.css +5 -0
- package/build/esm/components/Map/YMap/YMap.d.ts +4 -2
- package/build/esm/components/Map/YMap/YMap.js +18 -10
- package/build/esm/components/Map/YMap/YandexMap.js +18 -9
- package/build/esm/components/ReactPlayer/utils.js +13 -12
- package/build/esm/components/Title/Title.css +20 -5
- package/build/esm/components/Title/Title.d.ts +1 -1
- package/build/esm/components/Title/Title.js +4 -2
- package/build/esm/models/constructor-items/common.d.ts +5 -5
- package/build/esm/navigation/components/Navigation/Navigation.js +7 -6
- package/build/esm/schema/validators/common.d.ts +0 -6
- package/build/esm/schema/validators/common.js +0 -4
- package/build/esm/sub-blocks/BannerCard/BannerCard.css +2 -1
- package/build/esm/sub-blocks/Content/Content.css +6 -0
- package/build/esm/sub-blocks/HubspotForm/HubspotForm.css +1 -0
- package/build/esm/utils/blocks.d.ts +1 -1
- package/build/esm/utils/blocks.js +2 -0
- package/package.json +7 -6
- package/server/models/constructor-items/common.d.ts +5 -5
- package/server/utils/blocks.d.ts +1 -1
- package/server/utils/blocks.js +2 -0
- package/styles/mixins.scss +9 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,39 +1,59 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [
|
|
3
|
+
## [2.2.0](https://github.com/gravity-ui/page-constructor/compare/v2.1.1...v2.2.0) (2023-03-29)
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
###
|
|
6
|
+
### Features
|
|
7
7
|
|
|
8
|
-
*
|
|
8
|
+
* dropdown a ReactPlayer version ([#254](https://github.com/gravity-ui/page-constructor/issues/254)) ([fec1c3f](https://github.com/gravity-ui/page-constructor/commit/fec1c3fee50dcd86d08c0501f80d7aca0795e026))
|
|
9
9
|
|
|
10
|
+
## [2.1.1](https://github.com/gravity-ui/page-constructor/compare/v2.1.0...v2.1.1) (2023-03-28)
|
|
10
11
|
|
|
11
|
-
### chore
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
* bump release ([095fa6c](https://github.com/gravity-ui/page-constructor/commit/095fa6cf8022f9bc2fa6ad555d8d960c16771b29))
|
|
13
|
+
### Bug Fixes
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
* quotes validator schema ([#247](https://github.com/gravity-ui/page-constructor/issues/247)) ([87b8587](https://github.com/gravity-ui/page-constructor/commit/87b8587bcd5fe2bb96b5d70aae9eb6ca9e189f33))
|
|
16
|
+
|
|
17
|
+
## [2.1.0](https://github.com/gravity-ui/page-constructor/compare/v2.0.3...v2.1.0) (2023-03-27)
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
### Features
|
|
20
21
|
|
|
21
|
-
*
|
|
22
|
+
* **Title:** add size xs ([#207](https://github.com/gravity-ui/page-constructor/issues/207)) ([1fd8cf7](https://github.com/gravity-ui/page-constructor/commit/1fd8cf7aeaf4a6a993a3ffcce576a41d61c3b66b))
|
|
23
|
+
|
|
24
|
+
## [2.0.3](https://github.com/gravity-ui/page-constructor/compare/v2.0.2...v2.0.3) (2023-03-27)
|
|
22
25
|
|
|
23
26
|
|
|
24
27
|
### Bug Fixes
|
|
25
28
|
|
|
26
|
-
*
|
|
27
|
-
* **package:** up version ([#241](https://github.com/gravity-ui/page-constructor/issues/241)) ([9b6d3f2](https://github.com/gravity-ui/page-constructor/commit/9b6d3f2ecace4e1e51c52a4c422aa44850bbefec))
|
|
28
|
-
* remove description and inputs ([000a85e](https://github.com/gravity-ui/page-constructor/commit/000a85ee6d1d9fedb0cef74d990be4065a750efb))
|
|
29
|
-
* try to release version ([6fc35f2](https://github.com/gravity-ui/page-constructor/commit/6fc35f2043097f883b9ad87bb348f73cc138be1e))
|
|
29
|
+
* **Tabs:** wrap tabs on desktop ([#237](https://github.com/gravity-ui/page-constructor/issues/237)) ([68dd965](https://github.com/gravity-ui/page-constructor/commit/68dd965b8d5ad9439f8c59211232911695c30fd3))
|
|
30
30
|
|
|
31
|
-
## [
|
|
31
|
+
## [2.0.2](https://github.com/gravity-ui/page-constructor/compare/v2.0.1...v2.0.2) (2023-03-24)
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
### Bug Fixes
|
|
35
35
|
|
|
36
|
-
*
|
|
36
|
+
* add specificity for few buttons ([#230](https://github.com/gravity-ui/page-constructor/issues/230)) ([22b0891](https://github.com/gravity-ui/page-constructor/commit/22b089158ed184d03726c5d0e0cff27307f1dec1))
|
|
37
|
+
|
|
38
|
+
## [2.0.1](https://github.com/gravity-ui/page-constructor/compare/v2.0.0...v2.0.1) (2023-03-24)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Bug Fixes
|
|
42
|
+
|
|
43
|
+
* handle margins for centered links and buttons in Content ([#223](https://github.com/gravity-ui/page-constructor/issues/223)) ([50590f2](https://github.com/gravity-ui/page-constructor/commit/50590f288cba7d3dd88e4f91e1642d0a34061fb9))
|
|
44
|
+
* **Navigation:** fix issue with remaining event handler in effect ([#220](https://github.com/gravity-ui/page-constructor/issues/220)) ([d494523](https://github.com/gravity-ui/page-constructor/commit/d4945238ee52f7cca92ea4b092f0701ab4d99693))
|
|
45
|
+
|
|
46
|
+
## [2.0.0](https://github.com/gravity-ui/page-constructor/compare/v1.25.2...v2.0.0) (2023-03-23)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
### ⚠ BREAKING CHANGES
|
|
50
|
+
|
|
51
|
+
* update uikit up to 4, update react up to 18([#134](https://github.com/gravity-ui/page-constructor/issues/134)) (#212)
|
|
52
|
+
|
|
53
|
+
### Features
|
|
54
|
+
|
|
55
|
+
* map-block changing the logic of zoom and center ([#219](https://github.com/gravity-ui/page-constructor/issues/219)) ([d332844](https://github.com/gravity-ui/page-constructor/commit/d33284425878cdbfacdf7813826d909e9ab696cb))
|
|
56
|
+
* update uikit up to 4, update react up to 18([#134](https://github.com/gravity-ui/page-constructor/issues/134)) ([#212](https://github.com/gravity-ui/page-constructor/issues/212)) ([377b1f5](https://github.com/gravity-ui/page-constructor/commit/377b1f59c25d08458082232075e2e7bcfe84fe5c))
|
|
37
57
|
|
|
38
58
|
## [1.25.2](https://github.com/gravity-ui/page-constructor/compare/v1.25.1...v1.25.2) (2023-03-21)
|
|
39
59
|
|
package/README.md
CHANGED
|
@@ -306,6 +306,13 @@ In usual cases we use two types of commits:
|
|
|
306
306
|
1. fix: a commit of the type fix patches a bug in your codebase (this correlates with PATCH in Semantic Versioning).
|
|
307
307
|
2. feat: a commit of the type feat introduces a new feature to the codebase (this correlates with MINOR in Semantic Versioning).
|
|
308
308
|
3. BREAKING CHANGE: a commit that has a footer BREAKING CHANGE:, or appends a ! after the type/scope, introduces a breaking API change (correlating with MAJOR in Semantic Versioning). A BREAKING CHANGE can be part of commits of any type.
|
|
309
|
+
4. To set release package version manually you need to add `Release-As: <version>` to your commit message e.g.
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
git commit -m 'chore: bump release
|
|
313
|
+
|
|
314
|
+
Release-As: 1.2.3'
|
|
315
|
+
```
|
|
309
316
|
|
|
310
317
|
You can see all information [here](https://www.conventionalcommits.org/en/v1.0.0/).
|
|
311
318
|
|
|
@@ -316,11 +323,3 @@ When you receive the approval of your pull-request from the code owners and pass
|
|
|
316
323
|
3. Wait until robot creates a PR with a new version of the package and information about your changes in CHANGELOG.md. You can see the process on [the Actions tab](https://github.com/gravity-ui/page-constructor/actions).
|
|
317
324
|
4. Check your changes in CHANGELOG.md and approve robot's PR.
|
|
318
325
|
5. Squash and merge PR. You can see release process on [the Actions tab](https://github.com/gravity-ui/page-constructor/actions).
|
|
319
|
-
|
|
320
|
-
For now, we have two major version of package. If you want to have your changes in major one (1.x.x) for some reasons, e.g. you aren't ready for major 2.x.x. update, please do the following:
|
|
321
|
-
|
|
322
|
-
1. Create PR wit your changes as you usually do to the branch main.
|
|
323
|
-
2. Release package version in major 2.x.x.
|
|
324
|
-
3. Then you have to fetch a branch `version-1.x.x/fixes` - it is a branch with major 1.x.x and changes which were created after the release version 2.x.x.
|
|
325
|
-
4. Cherry-pick your commit from major 2.x.x to a branch which was released from the branch `version-1.x.x/fixes` and create a PR.
|
|
326
|
-
5. After that you have to follow regular flow above.
|
|
@@ -6,12 +6,6 @@ export declare const Map: {
|
|
|
6
6
|
zoom: {
|
|
7
7
|
type: string;
|
|
8
8
|
};
|
|
9
|
-
center: {
|
|
10
|
-
type: string;
|
|
11
|
-
items: {
|
|
12
|
-
type: string;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
9
|
address: {
|
|
16
10
|
type: string;
|
|
17
11
|
};
|
|
@@ -70,12 +64,6 @@ export declare const MapBlock: {
|
|
|
70
64
|
zoom: {
|
|
71
65
|
type: string;
|
|
72
66
|
};
|
|
73
|
-
center: {
|
|
74
|
-
type: string;
|
|
75
|
-
items: {
|
|
76
|
-
type: string;
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
67
|
address: {
|
|
80
68
|
type: string;
|
|
81
69
|
};
|
|
@@ -17,46 +17,47 @@ unpredictable css rules order in build */
|
|
|
17
17
|
justify-content: center;
|
|
18
18
|
margin-top: 16px;
|
|
19
19
|
}
|
|
20
|
-
.pc-share-block__item {
|
|
20
|
+
.pc-share-block__item.pc-share-block__item {
|
|
21
21
|
display: flex;
|
|
22
22
|
justify-content: center;
|
|
23
23
|
width: 48px;
|
|
24
24
|
height: 48px;
|
|
25
25
|
border-radius: 100%;
|
|
26
26
|
}
|
|
27
|
-
.pc-share-block__item_type_vk {
|
|
27
|
+
.pc-share-block__item.pc-share-block__item_type_vk {
|
|
28
28
|
background-color: var(--yc-color-vk);
|
|
29
29
|
}
|
|
30
|
-
.pc-share-block__item_type_facebook {
|
|
30
|
+
.pc-share-block__item.pc-share-block__item_type_facebook {
|
|
31
31
|
background-color: var(--yc-color-facebook);
|
|
32
32
|
}
|
|
33
|
-
.pc-share-block__item_type_twitter {
|
|
33
|
+
.pc-share-block__item.pc-share-block__item_type_twitter {
|
|
34
34
|
background-color: var(--yc-color-twitter);
|
|
35
35
|
}
|
|
36
|
-
.pc-share-block__item_type_telegram {
|
|
36
|
+
.pc-share-block__item.pc-share-block__item_type_telegram {
|
|
37
37
|
background-color: var(--yc-color-telegram);
|
|
38
38
|
}
|
|
39
|
-
.pc-share-block__item_type_telegram {
|
|
39
|
+
.pc-share-block__item.pc-share-block__item_type_telegram {
|
|
40
40
|
background-color: var(--yc-color-telegram);
|
|
41
41
|
}
|
|
42
|
-
.pc-share-block__item_type_linkedin {
|
|
42
|
+
.pc-share-block__item.pc-share-block__item_type_linkedin {
|
|
43
43
|
background-color: var(--yc-color-linkedin);
|
|
44
44
|
}
|
|
45
|
-
.pc-share-block__item.pc-share-block__item:before {
|
|
45
|
+
.pc-share-block__item.pc-share-block__item.pc-share-block__item.pc-share-block__item:before {
|
|
46
46
|
border-radius: 100%;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
.pc-share-block__item:hover:before {
|
|
49
|
+
.pc-share-block__item.pc-share-block__item:hover:before {
|
|
50
50
|
/* stylelint-disable-next-line declaration-no-important */
|
|
51
51
|
background-color: var(--yc-color-base-generic) !important;
|
|
52
52
|
border-radius: 100%;
|
|
53
53
|
}
|
|
54
|
-
.pc-share-block__item + .pc-share-block__item {
|
|
54
|
+
.pc-share-block__item.pc-share-block__item + .pc-share-block__item.pc-share-block__item {
|
|
55
55
|
margin-left: 12px;
|
|
56
56
|
}
|
|
57
|
-
.pc-share-block__item svg {
|
|
57
|
+
.pc-share-block__item.pc-share-block__item svg {
|
|
58
58
|
color: var(--yc-color-base-background);
|
|
59
59
|
}
|
|
60
|
+
|
|
60
61
|
@media (max-width: 577px) {
|
|
61
62
|
.pc-share-block__items {
|
|
62
63
|
flex-wrap: wrap;
|
|
@@ -7,10 +7,10 @@ unpredictable css rules order in build */
|
|
|
7
7
|
font-size: var(--yc-text-body-3-font-size);
|
|
8
8
|
line-height: var(--yc-text-body-3-line-height);
|
|
9
9
|
}
|
|
10
|
-
.pc-block-header__description_titleSize_s {
|
|
10
|
+
.pc-block-header__description_titleSize_s, .pc-block-header__description_titleSize_xs {
|
|
11
11
|
margin-top: 8px;
|
|
12
12
|
}
|
|
13
|
-
.pc-block-header__description_titleSize_s .yfm {
|
|
13
|
+
.pc-block-header__description_titleSize_s .yfm, .pc-block-header__description_titleSize_xs .yfm {
|
|
14
14
|
font-size: var(--yc-text-body-2-font-size);
|
|
15
15
|
line-height: var(--yc-text-body-2-line-height);
|
|
16
16
|
}
|
|
@@ -38,7 +38,7 @@ const Button = (props) => {
|
|
|
38
38
|
let icon;
|
|
39
39
|
let image = img && react_1.default.createElement("img", { className: b('image'), src: buttonImg.url, alt: buttonImg.alt });
|
|
40
40
|
if (theme === 'github') {
|
|
41
|
-
icon = react_1.default.createElement(uikit_1.Icon, { className: b('icon'), data: icons_1.Github, size: 24 });
|
|
41
|
+
icon = react_1.default.createElement(uikit_1.Icon, { className: b('icon'), data: icons_1.Github, size: 24, qa: utils_2.ICON_QA });
|
|
42
42
|
image = undefined;
|
|
43
43
|
}
|
|
44
44
|
const buttonTheme = theme === 'scale' ? 'accent' : theme;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
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 utils_1 = require("../utils");
|
|
8
|
+
const Button_1 = tslib_1.__importDefault(require("../Button"));
|
|
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,4 +1,5 @@
|
|
|
1
1
|
import { ButtonSize, ButtonView } from '@gravity-ui/uikit';
|
|
2
|
+
export declare const ICON_QA = "button-icon";
|
|
2
3
|
export type OldButtonTheme = 'normal' | 'action' | 'flat' | 'light' | 'clear' | 'raised' | 'pseudo' | 'link' | 'accent' | 'websearch' | 'flat-special' | 'normal-special' | 'normal-dark' | 'pseudo-special';
|
|
3
4
|
export type OldButtonSize = 'xs' | 'ns' | 's' | 'm' | 'l' | 'n' | 'head' | 'promo';
|
|
4
5
|
export declare const toCommonView: (theme: OldButtonTheme) => ButtonView;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toCommonSize = exports.toCommonView = void 0;
|
|
3
|
+
exports.toCommonSize = exports.toCommonView = exports.ICON_QA = void 0;
|
|
4
|
+
exports.ICON_QA = 'button-icon';
|
|
4
5
|
const themeMap = {
|
|
5
6
|
normal: 'normal',
|
|
6
7
|
action: 'action',
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
/* use this for style redefinitions to awoid problems with
|
|
2
2
|
unpredictable css rules order in build */
|
|
3
|
-
.pc-button-tabs__item {
|
|
3
|
+
.pc-button-tabs__item.pc-button-tabs__item {
|
|
4
4
|
margin-right: 8px;
|
|
5
5
|
margin-bottom: 12px;
|
|
6
6
|
--yc-button-background-color: var(--pc-tab-item-background-color);
|
|
7
7
|
--yc-button-background-color-hover: var(--pc-tab-item-background-color-hover);
|
|
8
8
|
}
|
|
9
|
-
.pc-button-tabs__item, .pc-button-tabs__item:link, .pc-button-tabs__item:visited, .pc-button-tabs__item:active, .pc-button-tabs__item:focus {
|
|
9
|
+
.pc-button-tabs__item.pc-button-tabs__item, .pc-button-tabs__item.pc-button-tabs__item:link, .pc-button-tabs__item.pc-button-tabs__item:visited, .pc-button-tabs__item.pc-button-tabs__item:active, .pc-button-tabs__item.pc-button-tabs__item:focus {
|
|
10
10
|
color: var(--pc-tab-item-color);
|
|
11
11
|
}
|
|
12
|
-
.pc-button-tabs__item:hover {
|
|
12
|
+
.pc-button-tabs__item.pc-button-tabs__item:hover {
|
|
13
13
|
color: var(--pc-tab-item-color);
|
|
14
14
|
}
|
|
15
|
-
.pc-button-tabs__item_active {
|
|
15
|
+
.pc-button-tabs__item.pc-button-tabs__item_active {
|
|
16
16
|
pointer-events: none;
|
|
17
17
|
--yc-button-background-color: var(--pc-selected-tab-item-background-color);
|
|
18
18
|
--yc-button-background-color-hover: var(--pc-selected-tab-item-background-color-hover);
|
|
19
19
|
}
|
|
20
|
-
.pc-button-tabs__item_active, .pc-button-tabs__item_active:link, .pc-button-tabs__item_active:visited, .pc-button-tabs__item_active:active, .pc-button-tabs__item_active:focus {
|
|
20
|
+
.pc-button-tabs__item.pc-button-tabs__item_active, .pc-button-tabs__item.pc-button-tabs__item_active:link, .pc-button-tabs__item.pc-button-tabs__item_active:visited, .pc-button-tabs__item.pc-button-tabs__item_active:active, .pc-button-tabs__item.pc-button-tabs__item_active:focus {
|
|
21
21
|
color: var(--pc-selected-tab-item-color);
|
|
22
22
|
}
|
|
23
|
-
.pc-button-tabs__item_active:hover {
|
|
23
|
+
.pc-button-tabs__item.pc-button-tabs__item_active:hover {
|
|
24
24
|
color: var(--pc-selected-tab-item-color);
|
|
25
25
|
}
|
|
@@ -7,7 +7,7 @@ export interface HTMLProps {
|
|
|
7
7
|
}
|
|
8
8
|
declare const HTML: ({ children, block, className }: WithChildren<HTMLProps>) => React.DetailedReactHTMLElement<{
|
|
9
9
|
dangerouslySetInnerHTML: {
|
|
10
|
-
__html: string
|
|
10
|
+
__html: string | (string & React.ReactElement<any, string | React.JSXElementConstructor<any>>) | (string & React.ReactFragment) | (string & React.ReactPortal);
|
|
11
11
|
};
|
|
12
12
|
className: string | undefined;
|
|
13
13
|
}, HTMLElement> | null;
|
|
@@ -8,18 +8,20 @@ const mapsContext_1 = require("../../context/mapsContext/mapsContext");
|
|
|
8
8
|
const localeContext_1 = require("../../context/localeContext/localeContext");
|
|
9
9
|
const mobileContext_1 = require("../../context/mobileContext");
|
|
10
10
|
const helpers_1 = require("./helpers");
|
|
11
|
+
const configure_1 = require("../../utils/configure");
|
|
11
12
|
const b = (0, utils_1.block)('map');
|
|
12
|
-
function getScriptSrc(
|
|
13
|
-
|
|
13
|
+
function getScriptSrc(params) {
|
|
14
|
+
const { apiKey, scriptSrc, address, lang, zoom } = params;
|
|
15
|
+
return `${scriptSrc}?key=${apiKey}&language=${lang}${zoom ? '&zoom=' + zoom : ''}&q=${encodeURI(address)}`;
|
|
14
16
|
}
|
|
15
17
|
const GoogleMap = (props) => {
|
|
16
|
-
const { address } = props;
|
|
18
|
+
const { address, zoom } = props;
|
|
17
19
|
const { apiKey, scriptSrc } = (0, react_1.useContext)(mapsContext_1.MapsContext);
|
|
18
|
-
const { lang =
|
|
20
|
+
const { lang = configure_1.Lang.Ru } = (0, react_1.useContext)(localeContext_1.LocaleContext);
|
|
19
21
|
const isMobile = (0, react_1.useContext)(mobileContext_1.MobileContext);
|
|
20
22
|
const [height, setHeight] = (0, react_1.useState)(undefined);
|
|
21
23
|
const ref = (0, react_1.useRef)(null);
|
|
22
|
-
const src = (0, react_1.useMemo)(() => getScriptSrc(apiKey, scriptSrc, address, lang), [apiKey, scriptSrc, address, lang]);
|
|
24
|
+
const src = (0, react_1.useMemo)(() => getScriptSrc({ apiKey, scriptSrc, address, lang, zoom }), [apiKey, scriptSrc, address, lang, zoom]);
|
|
23
25
|
(0, react_1.useEffect)(() => {
|
|
24
26
|
const updateSize = lodash_1.default.debounce(() => {
|
|
25
27
|
if (ref.current) {
|
|
@@ -7,9 +7,13 @@ unpredictable css rules order in build */
|
|
|
7
7
|
overflow: hidden;
|
|
8
8
|
display: flex;
|
|
9
9
|
}
|
|
10
|
+
.pc-map_hidden {
|
|
11
|
+
opacity: 0;
|
|
12
|
+
}
|
|
10
13
|
.pc-map__spinner {
|
|
11
14
|
margin: 0 auto;
|
|
12
15
|
align-self: center;
|
|
16
|
+
position: absolute;
|
|
13
17
|
}
|
|
14
18
|
.pc-map__wrapper {
|
|
15
19
|
min-height: 300px;
|
|
@@ -17,4 +21,5 @@ unpredictable css rules order in build */
|
|
|
17
21
|
flex-direction: column;
|
|
18
22
|
align-items: center;
|
|
19
23
|
justify-content: center;
|
|
24
|
+
position: relative;
|
|
20
25
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { YMapMarker } from '../../../models';
|
|
1
|
+
import { YMapProps, YMapMarker } from '../../../models';
|
|
2
|
+
type PlacemarksProps = Pick<YMapProps, 'zoom' | 'markers'>;
|
|
2
3
|
export declare class YMap {
|
|
3
4
|
private ymap;
|
|
4
5
|
private mapRef;
|
|
5
6
|
private coords;
|
|
6
7
|
constructor(ymap: Ymaps.Map, mapRef: HTMLDivElement | null);
|
|
7
|
-
showPlacemarks(
|
|
8
|
+
showPlacemarks(props: PlacemarksProps): Promise<void>;
|
|
8
9
|
findAddress(marker: YMapMarker): Promise<void>;
|
|
9
10
|
findCoordinate(marker: YMapMarker): void;
|
|
10
11
|
private drawPlaceMarkStyle;
|
|
11
12
|
private recalcZoomAndCenter;
|
|
12
13
|
private clearOldPlacemarks;
|
|
13
14
|
}
|
|
15
|
+
export {};
|
|
@@ -22,9 +22,9 @@ class YMap {
|
|
|
22
22
|
this.ymap = ymap;
|
|
23
23
|
this.mapRef = mapRef;
|
|
24
24
|
}
|
|
25
|
-
async showPlacemarks(
|
|
25
|
+
async showPlacemarks(props) {
|
|
26
26
|
this.clearOldPlacemarks();
|
|
27
|
-
for (const marker of markers) {
|
|
27
|
+
for (const marker of props.markers) {
|
|
28
28
|
if (marker.address) {
|
|
29
29
|
await this.findAddress(marker);
|
|
30
30
|
}
|
|
@@ -32,7 +32,7 @@ class YMap {
|
|
|
32
32
|
this.findCoordinate(marker);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
this.recalcZoomAndCenter();
|
|
35
|
+
this.recalcZoomAndCenter(props);
|
|
36
36
|
}
|
|
37
37
|
async findAddress(marker) {
|
|
38
38
|
try {
|
|
@@ -52,10 +52,7 @@ class YMap {
|
|
|
52
52
|
this.ymap.geoObjects.add(geoObject);
|
|
53
53
|
}
|
|
54
54
|
drawPlaceMarkStyle(geoObject, marker) {
|
|
55
|
-
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const { iconColor, preset = DEFAULT_PLACEMARKS_PRESET } = marker.label;
|
|
55
|
+
const { iconColor, preset = DEFAULT_PLACEMARKS_PRESET } = marker.label || {};
|
|
59
56
|
let localIconColor = iconColor;
|
|
60
57
|
// You can set the preset option together with the iconColor option only if it not a 'Stretchy' preset
|
|
61
58
|
if (!preset.includes('Stretchy') && !iconColor) {
|
|
@@ -68,9 +65,10 @@ class YMap {
|
|
|
68
65
|
}
|
|
69
66
|
});
|
|
70
67
|
}
|
|
71
|
-
recalcZoomAndCenter() {
|
|
68
|
+
recalcZoomAndCenter(props) {
|
|
72
69
|
var _a, _b;
|
|
73
70
|
const coordsLength = this.coords.length;
|
|
71
|
+
const { zoom = 0 } = props;
|
|
74
72
|
if (!coordsLength) {
|
|
75
73
|
return;
|
|
76
74
|
}
|
|
@@ -79,10 +77,20 @@ class YMap {
|
|
|
79
77
|
leftBottom = [Math.min(leftBottom[0], point[0]), Math.min(leftBottom[1], point[1])];
|
|
80
78
|
rightTop = [Math.max(rightTop[0], point[0]), Math.max(rightTop[1], point[1])];
|
|
81
79
|
});
|
|
82
|
-
|
|
80
|
+
let newMapParams = {
|
|
81
|
+
zoom,
|
|
82
|
+
center: [],
|
|
83
|
+
};
|
|
84
|
+
if (zoom) {
|
|
85
|
+
// compute only the center
|
|
86
|
+
newMapParams.center = window.ymaps.util.bounds.getCenter([leftBottom, rightTop]);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
newMapParams = window.ymaps.util.bounds.getCenterAndZoom([leftBottom, rightTop], [(_a = this.mapRef) === null || _a === void 0 ? void 0 : _a.clientWidth, (_b = this.mapRef) === null || _b === void 0 ? void 0 : _b.clientHeight], undefined, { margin: DEFAULT_MAP_CONTROL_BUTTON_HEIGHT });
|
|
90
|
+
}
|
|
83
91
|
this.ymap.setCenter(newMapParams.center);
|
|
84
92
|
// Use default zoom for one placemark
|
|
85
|
-
if (coordsLength > 1) {
|
|
93
|
+
if (coordsLength > 1 && !zoom) {
|
|
86
94
|
this.ymap.setZoom(newMapParams.zoom);
|
|
87
95
|
}
|
|
88
96
|
}
|
|
@@ -16,8 +16,12 @@ const helpers_1 = require("../helpers");
|
|
|
16
16
|
const b = (0, utils_1.block)('map');
|
|
17
17
|
const DEFAULT_CONTAINER_ID = 'ymap';
|
|
18
18
|
const DEFAULT_ZOOM = 9;
|
|
19
|
+
// Center - is a required parameter for creating a new map
|
|
20
|
+
// We use this init center to create a map
|
|
21
|
+
// The real center of the map will be calculated later, using the coordinates of the markers
|
|
22
|
+
const INITIAL_CENTER = [0, 0];
|
|
19
23
|
const YandexMap = (props) => {
|
|
20
|
-
const { markers, zoom,
|
|
24
|
+
const { markers, zoom, id } = props;
|
|
21
25
|
const { apiKey, scriptSrc, nonce } = (0, react_1.useContext)(mapsContext_1.MapsContext);
|
|
22
26
|
const isMobile = (0, react_1.useContext)(mobileContext_1.MobileContext);
|
|
23
27
|
const { lang = 'ru' } = (0, react_1.useContext)(localeContext_1.LocaleContext);
|
|
@@ -26,6 +30,7 @@ const YandexMap = (props) => {
|
|
|
26
30
|
const [height, setHeight] = (0, react_1.useState)(undefined);
|
|
27
31
|
const ref = (0, react_1.useRef)(null);
|
|
28
32
|
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
33
|
+
const [ready, setReady] = (0, react_1.useState)(false);
|
|
29
34
|
const [attemptsIndex, setAttemptsIndex] = (0, react_1.useState)(0);
|
|
30
35
|
const onTryAgain = (0, react_1.useCallback)(() => {
|
|
31
36
|
setAttemptsIndex(attemptsIndex + 1);
|
|
@@ -33,20 +38,17 @@ const YandexMap = (props) => {
|
|
|
33
38
|
(0, react_1.useEffect)(() => {
|
|
34
39
|
(async function () {
|
|
35
40
|
var _a;
|
|
36
|
-
if (!center) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
41
|
setLoading(true);
|
|
40
42
|
await YandexMapApiLoader_1.YMapsApiLoader.loadApi(apiKey, scriptSrc, lang, nonce);
|
|
41
43
|
(_a = window.ymaps) === null || _a === void 0 ? void 0 : _a.ready(() => {
|
|
42
44
|
setYmaps(new YMap_1.YMap(new window.ymaps.Map(containerId, {
|
|
43
|
-
center,
|
|
45
|
+
center: INITIAL_CENTER,
|
|
44
46
|
zoom: zoom || DEFAULT_ZOOM,
|
|
45
47
|
}, { autoFitToViewport: 'always' }), ref.current));
|
|
46
48
|
});
|
|
47
49
|
setLoading(false);
|
|
48
50
|
})();
|
|
49
|
-
}, [apiKey, lang, scriptSrc, containerId, zoom,
|
|
51
|
+
}, [apiKey, lang, scriptSrc, containerId, zoom, nonce, attemptsIndex, setLoading]);
|
|
50
52
|
(0, react_1.useEffect)(() => {
|
|
51
53
|
const updateSize = lodash_1.default.debounce(() => {
|
|
52
54
|
if (ref.current) {
|
|
@@ -61,12 +63,19 @@ const YandexMap = (props) => {
|
|
|
61
63
|
}, [markers, ymap, setYmaps, isMobile]);
|
|
62
64
|
(0, react_1.useEffect)(() => {
|
|
63
65
|
if (ymap) {
|
|
64
|
-
|
|
66
|
+
// show with computed center and placemarks
|
|
67
|
+
const showPlacemarks = async () => {
|
|
68
|
+
await ymap.showPlacemarks({ markers, zoom });
|
|
69
|
+
setReady(true);
|
|
70
|
+
};
|
|
71
|
+
showPlacemarks();
|
|
65
72
|
}
|
|
66
73
|
});
|
|
67
|
-
if (!
|
|
74
|
+
if (!markers)
|
|
68
75
|
return null;
|
|
69
76
|
return (react_1.default.createElement(ErrorWrapper_1.default, { isError: YandexMapApiLoader_1.YMapsApiLoader.status === YandexMapApiLoader_1.MapApiStatus.Error, text: (0, i18n_1.default)('map-load-error'), buttonText: (0, i18n_1.default)('map-try-again'), handler: onTryAgain, className: b('wrapper') },
|
|
70
|
-
react_1.default.createElement("div", {
|
|
77
|
+
react_1.default.createElement("div", { className: b('wrapper') },
|
|
78
|
+
react_1.default.createElement("div", { id: containerId, className: b({ hidden: !ready }), ref: ref, style: { height } }),
|
|
79
|
+
loading ? react_1.default.createElement(uikit_1.Spin, { size: "xl", className: b('spinner') }) : null)));
|
|
71
80
|
};
|
|
72
81
|
exports.default = YandexMap;
|
|
@@ -4,20 +4,21 @@ exports.checkYoutubeVideos = void 0;
|
|
|
4
4
|
// the file serves to support live video with react-player@2.9
|
|
5
5
|
const LIVE_YUOTUBE_VIDEO_REGEX = /(?:youtu\.be\/live\/|youtube(?:-nocookie)?\.com\/(?:live\/))((\w|-){11})/;
|
|
6
6
|
const YOUTUBE_VIDEO_TEMPLATE = 'https://www.youtube.com/watch?v=';
|
|
7
|
+
const transformYoutubeUrl = (src) => {
|
|
8
|
+
var _a;
|
|
9
|
+
if (LIVE_YUOTUBE_VIDEO_REGEX.test(src)) {
|
|
10
|
+
const youtubeLiveId = (_a = src.match(LIVE_YUOTUBE_VIDEO_REGEX)) === null || _a === void 0 ? void 0 : _a[1];
|
|
11
|
+
if (!youtubeLiveId) {
|
|
12
|
+
return src;
|
|
13
|
+
}
|
|
14
|
+
return `${YOUTUBE_VIDEO_TEMPLATE}${youtubeLiveId}`;
|
|
15
|
+
}
|
|
16
|
+
return src;
|
|
17
|
+
};
|
|
7
18
|
const checkYoutubeVideos = (src) => {
|
|
8
19
|
if (Array.isArray(src)) {
|
|
9
|
-
return src.map((videoUrl) =>
|
|
10
|
-
var _a;
|
|
11
|
-
if (LIVE_YUOTUBE_VIDEO_REGEX.test(videoUrl)) {
|
|
12
|
-
const youtubeLiveId = (_a = videoUrl.match(LIVE_YUOTUBE_VIDEO_REGEX)) === null || _a === void 0 ? void 0 : _a[1];
|
|
13
|
-
if (!youtubeLiveId) {
|
|
14
|
-
return videoUrl;
|
|
15
|
-
}
|
|
16
|
-
return `${YOUTUBE_VIDEO_TEMPLATE}${youtubeLiveId}`;
|
|
17
|
-
}
|
|
18
|
-
return videoUrl;
|
|
19
|
-
});
|
|
20
|
+
return src.map((videoUrl) => transformYoutubeUrl(videoUrl));
|
|
20
21
|
}
|
|
21
|
-
return src;
|
|
22
|
+
return transformYoutubeUrl(src);
|
|
22
23
|
};
|
|
23
24
|
exports.checkYoutubeVideos = checkYoutubeVideos;
|