@gravity-ui/page-constructor 1.10.1 → 1.10.2-alpha.1

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/build/cjs/blocks/Share/Share.css +13 -1
  3. package/build/cjs/blocks/Share/Share.js +18 -9
  4. package/build/cjs/blocks/Share/schema.d.ts +1 -5
  5. package/build/cjs/blocks/Share/schema.js +4 -4
  6. package/build/cjs/components/Image/Image.js +2 -1
  7. package/build/cjs/icons/Facebook.d.ts +2 -0
  8. package/build/cjs/icons/Facebook.js +9 -0
  9. package/build/cjs/icons/Linkedin.d.ts +2 -0
  10. package/build/cjs/icons/Linkedin.js +9 -0
  11. package/build/cjs/icons/Telegram.d.ts +2 -0
  12. package/build/cjs/icons/Telegram.js +9 -0
  13. package/build/cjs/icons/Twitter.d.ts +2 -0
  14. package/build/cjs/icons/Twitter.js +9 -0
  15. package/build/cjs/icons/Vk.d.ts +2 -0
  16. package/build/cjs/icons/Vk.js +9 -0
  17. package/build/cjs/models/constructor-items/blocks.d.ts +2 -1
  18. package/build/cjs/models/constructor-items/blocks.js +1 -0
  19. package/build/cjs/schema/index.js +48 -44
  20. package/build/cjs/utils/blocks.d.ts +2 -1
  21. package/build/cjs/utils/blocks.js +40 -1
  22. package/build/esm/blocks/Share/Share.css +13 -1
  23. package/build/esm/blocks/Share/Share.js +20 -11
  24. package/build/esm/blocks/Share/schema.d.ts +1 -5
  25. package/build/esm/blocks/Share/schema.js +4 -4
  26. package/build/esm/components/Image/Image.js +2 -1
  27. package/build/esm/icons/Facebook.d.ts +2 -0
  28. package/build/esm/icons/Facebook.js +4 -0
  29. package/build/esm/icons/Linkedin.d.ts +2 -0
  30. package/build/esm/icons/Linkedin.js +4 -0
  31. package/build/esm/icons/Telegram.d.ts +2 -0
  32. package/build/esm/icons/Telegram.js +4 -0
  33. package/build/esm/icons/Twitter.d.ts +2 -0
  34. package/build/esm/icons/Twitter.js +4 -0
  35. package/build/esm/icons/Vk.d.ts +2 -0
  36. package/build/esm/icons/Vk.js +4 -0
  37. package/build/esm/models/constructor-items/blocks.d.ts +2 -1
  38. package/build/esm/models/constructor-items/blocks.js +1 -0
  39. package/build/esm/schema/index.js +49 -45
  40. package/build/esm/utils/blocks.d.ts +2 -1
  41. package/build/esm/utils/blocks.js +38 -0
  42. package/package.json +6 -3
  43. package/server/models/constructor-items/blocks.d.ts +2 -1
  44. package/server/models/constructor-items/blocks.js +1 -0
  45. package/server/utils/blocks.d.ts +2 -1
  46. package/server/utils/blocks.js +40 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.10.2](https://github.com/gravity-ui/page-constructor/compare/v1.10.1...v1.10.2) (2022-12-13)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * shema validation ([#80](https://github.com/gravity-ui/page-constructor/issues/80)) ([c0d2f92](https://github.com/gravity-ui/page-constructor/commit/c0d2f92c1dabab86f9cb9264714821aa391e4c4c))
9
+
3
10
  ## [1.10.1](https://github.com/gravity-ui/page-constructor/compare/v1.10.0...v1.10.1) (2022-12-13)
4
11
 
5
12
 
@@ -36,9 +36,16 @@ unpredictable css rules order in build */
36
36
  .pc-share-block__item_type_telegram {
37
37
  background-color: var(--yc-color-telegram);
38
38
  }
39
- .pc-share-block__item:before {
39
+ .pc-share-block__item_type_telegram {
40
+ background-color: var(--yc-color-telegram);
41
+ }
42
+ .pc-share-block__item_type_linkedin {
43
+ background-color: var(--yc-color-linkedin);
44
+ }
45
+ .pc-share-block__item.pc-share-block__item:before {
40
46
  border-radius: 100%;
41
47
  }
48
+
42
49
  .pc-share-block__item:hover:before {
43
50
  /* stylelint-disable-next-line declaration-no-important */
44
51
  background-color: var(--yc-color-base-generic) !important;
@@ -49,4 +56,9 @@ unpredictable css rules order in build */
49
56
  }
50
57
  .pc-share-block__item svg {
51
58
  color: var(--yc-color-base-background);
59
+ }
60
+ @media (max-width: 577px) {
61
+ .pc-share-block__items {
62
+ flex-wrap: wrap;
63
+ }
52
64
  }
@@ -4,21 +4,30 @@ const tslib_1 = require("tslib");
4
4
  const react_1 = (0, tslib_1.__importStar)(require("react"));
5
5
  const uikit_1 = require("@gravity-ui/uikit");
6
6
  const utils_1 = require("../../utils");
7
- const models_1 = require("../../models");
8
7
  const locationContext_1 = require("../../context/locationContext");
9
8
  const i18n_1 = (0, tslib_1.__importDefault)(require("./i18n"));
10
- const b = (0, utils_1.block)('share-block');
11
- // TODO https://st.yandex-team.ru/CLOUDFRONT-11753
12
- const pcShareSocialNetwork = {
13
- [models_1.PCShareSocialNetwork.Vk]: uikit_1.ShareSocialNetwork.VK,
14
- [models_1.PCShareSocialNetwork.Telegram]: uikit_1.ShareSocialNetwork.Telegram,
15
- [models_1.PCShareSocialNetwork.Twitter]: uikit_1.ShareSocialNetwork.Twitter,
16
- [models_1.PCShareSocialNetwork.Facebook]: uikit_1.ShareSocialNetwork.Facebook,
9
+ const Facebook_1 = require("../../icons/Facebook");
10
+ const Twitter_1 = require("../../icons/Twitter");
11
+ const Linkedin_1 = require("../../icons/Linkedin");
12
+ const Vk_1 = require("../../icons/Vk");
13
+ const Telegram_1 = require("../../icons/Telegram");
14
+ const icons = {
15
+ facebook: Facebook_1.Facebook,
16
+ twitter: Twitter_1.Twitter,
17
+ linkedin: Linkedin_1.Linkedin,
18
+ vk: Vk_1.Vk,
19
+ telegram: Telegram_1.Telegram,
17
20
  };
21
+ const b = (0, utils_1.block)('share-block');
18
22
  const Share = ({ items, title }) => {
19
23
  const { pathname, hostname } = (0, react_1.useContext)(locationContext_1.LocationContext);
20
24
  return (react_1.default.createElement("div", { className: b() },
21
25
  react_1.default.createElement("h5", { className: b('title') }, title || (0, i18n_1.default)('constructor-share')),
22
- react_1.default.createElement("div", { className: b('items') }, items.map((type) => (react_1.default.createElement(uikit_1.ShareList.Item, { key: type, url: (0, utils_1.getAbsolutePath)(hostname, pathname), className: b('item', { type: type.toLowerCase() }), type: pcShareSocialNetwork[type] }))))));
26
+ react_1.default.createElement("div", { className: b('items') }, items.map((type) => {
27
+ const url = (0, utils_1.getAbsolutePath)(hostname, pathname);
28
+ const socialUrl = (0, utils_1.getShareLink)(url, type);
29
+ const icon = icons[type];
30
+ return (react_1.default.createElement(uikit_1.Button, { key: type, view: "flat", size: "l", target: "_blank", href: socialUrl, className: b('item', { type: type.toLowerCase() }) }, icon && react_1.default.createElement(uikit_1.Icon, { data: icon, size: 24, className: b('icon', { type }) })));
31
+ }))));
23
32
  };
24
33
  exports.default = Share;
@@ -10,11 +10,7 @@ export declare const ShareBlock: {
10
10
  type: string;
11
11
  items: {
12
12
  type: string;
13
- properties: {
14
- when: {
15
- type: string;
16
- };
17
- };
13
+ enum: string[];
18
14
  };
19
15
  };
20
16
  type: {};
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ShareBlock = void 0;
4
- const utils_1 = require("../../schema/validators/utils");
5
4
  const common_1 = require("../../schema/validators/common");
6
5
  exports.ShareBlock = {
7
6
  'share-block': {
@@ -9,11 +8,12 @@ exports.ShareBlock = {
9
8
  required: ['items'],
10
9
  properties: Object.assign(Object.assign({}, common_1.BaseProps), { title: {
11
10
  type: 'string',
12
- }, items: (0, utils_1.filteredArray)({
13
- properties: {
11
+ }, items: {
12
+ type: 'array',
13
+ items: {
14
14
  type: 'string',
15
15
  enum: ['telegram', 'facebook', 'twitter', 'vk'],
16
16
  },
17
- }) }),
17
+ } }),
18
18
  },
19
19
  };
@@ -26,8 +26,9 @@ const Image = (props) => {
26
26
  react_1.default.createElement("source", { srcSet: mobile, media: `(max-width: ${constants_1.BREAKPOINTS.sm}px)` }))),
27
27
  tablet && (react_1.default.createElement(react_1.Fragment, null,
28
28
  !disableWebp && (react_1.default.createElement("source", { srcSet: checkWebP(tablet), type: "image/webp", media: `(max-width: ${constants_1.BREAKPOINTS.md}px)` })),
29
+ "]",
29
30
  react_1.default.createElement("source", { srcSet: tablet, media: `(max-width: ${constants_1.BREAKPOINTS.md}px)` }))),
30
- desktop && !disableWebp && react_1.default.createElement("source", { srcSet: checkWebP(imageSrc), type: "image/webp" }),
31
+ imageSrc && !disableWebp && react_1.default.createElement("source", { srcSet: checkWebP(imageSrc), type: "image/webp" }),
31
32
  react_1.default.createElement("img", { className: className, src: imageSrc, alt: alt, style: style, onClick: onClick, onError: () => setImgLoadingError(true) })));
32
33
  };
33
34
  exports.default = Image;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const Facebook: React.FC<React.SVGProps<SVGSVGElement>>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Facebook = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = (0, tslib_1.__importDefault)(require("react"));
6
+ const svg_1 = require("../utils/svg");
7
+ const Facebook = (props) => (react_1.default.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "currentColor" }, svg_1.a11yHiddenSvgProps, props),
8
+ react_1.default.createElement("path", { d: "M13.79 22H9.93v-9.501H8V9.225h1.93V7.26C9.93 4.589 11.017 3 14.113 3h2.577v3.275h-1.61c-1.206 0-1.285.457-1.285 1.311l-.006 1.639h2.918l-.341 3.274H13.79V22z" })));
9
+ exports.Facebook = Facebook;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const Linkedin: React.FC<React.SVGProps<SVGSVGElement>>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Linkedin = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = (0, tslib_1.__importDefault)(require("react"));
6
+ const svg_1 = require("../utils/svg");
7
+ const Linkedin = (props) => (react_1.default.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "currentColor" }, svg_1.a11yHiddenSvgProps, props),
8
+ react_1.default.createElement("path", { d: "M21.3779 19.3506H17.7796V13.7149C17.7796 12.371 17.7556 10.641 15.908 10.641C14.0339 10.641 13.7471 12.1053 13.7471 13.6171V19.3503H10.1487V7.76094H13.6032V9.34475H13.6515C13.9972 8.7536 14.4968 8.2673 15.097 7.93763C15.6972 7.60796 16.3756 7.44726 17.0599 7.47266C20.707 7.47266 21.3794 9.8718 21.3794 12.9929L21.3779 19.3506ZM6.08857 6.17675C5.67556 6.17682 5.2718 6.05442 4.92836 5.82501C4.58492 5.5956 4.31722 5.26949 4.1591 4.88792C4.00097 4.50633 3.95956 4.08644 4.04005 3.68132C4.12055 3.2762 4.31936 2.90406 4.61135 2.61194C4.90333 2.31983 5.27537 2.12085 5.68043 2.0402C6.08549 1.95954 6.50536 2.00084 6.88696 2.15883C7.26854 2.31683 7.59472 2.58444 7.82423 2.92782C8.05375 3.27122 8.1763 3.67496 8.17637 4.088C8.17642 4.36226 8.12246 4.63383 8.01757 4.88721C7.91267 5.14061 7.75889 5.37086 7.56502 5.56482C7.37114 5.75877 7.14098 5.91264 6.88765 6.01764C6.63431 6.12264 6.36278 6.1767 6.08857 6.17675ZM7.88774 19.3506H4.28561V7.76094H7.88774V19.3506Z" })));
9
+ exports.Linkedin = Linkedin;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const Telegram: React.FC<React.SVGProps<SVGSVGElement>>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Telegram = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = (0, tslib_1.__importDefault)(require("react"));
6
+ const svg_1 = require("../utils/svg");
7
+ const Telegram = (props) => (react_1.default.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "currentColor" }, svg_1.a11yHiddenSvgProps, props),
8
+ react_1.default.createElement("path", { d: "M2.336 11.932l4.378 1.634 1.694 5.45a.515.515 0 0 0 .819.246l2.44-1.99a.728.728 0 0 1 .888-.024l4.401 3.196c.303.22.732.054.808-.312l3.225-15.51a.516.516 0 0 0-.691-.587L2.33 10.968a.516.516 0 0 0 .006.965zm5.799.764l8.556-5.27c.154-.094.312.114.18.237L9.81 14.226c-.248.231-.408.54-.454.876l-.24 1.783c-.032.238-.367.261-.432.031l-.925-3.25a.862.862 0 0 1 .376-.97z" })));
9
+ exports.Telegram = Telegram;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const Twitter: React.FC<React.SVGProps<SVGSVGElement>>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Twitter = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = (0, tslib_1.__importDefault)(require("react"));
6
+ const svg_1 = require("../utils/svg");
7
+ const Twitter = (props) => (react_1.default.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "currentColor" }, svg_1.a11yHiddenSvgProps, props),
8
+ react_1.default.createElement("path", { d: "M19.644 6.675a4.247 4.247 0 0 0 1.803-2.362c-.793.49-1.67.844-2.606 1.036A4.016 4.016 0 0 0 15.846 4c-2.265 0-4.101 1.913-4.101 4.272 0 .335.034.66.104.973C8.44 9.066 5.417 7.367 3.392 4.78a4.397 4.397 0 0 0-.555 2.149c0 1.481.724 2.789 1.825 3.556a3.994 3.994 0 0 1-1.859-.534v.053c0 2.07 1.413 3.797 3.293 4.188-.345.1-.707.15-1.083.15-.264 0-.522-.025-.77-.075.52 1.696 2.036 2.933 3.832 2.966A8.028 8.028 0 0 1 2 19.004a11.29 11.29 0 0 0 6.29 1.92c7.548 0 11.673-6.51 11.673-12.156 0-.186-.002-.37-.01-.553A8.508 8.508 0 0 0 22 6.003c-.736.34-1.527.57-2.356.672z" })));
9
+ exports.Twitter = Twitter;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const Vk: React.FC<React.SVGProps<SVGSVGElement>>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Vk = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = (0, tslib_1.__importDefault)(require("react"));
6
+ const svg_1 = require("../utils/svg");
7
+ const Vk = (props) => (react_1.default.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "currentColor" }, svg_1.a11yHiddenSvgProps, props),
8
+ react_1.default.createElement("path", { d: "M19.934 13.916c.73.713 1.5 1.383 2.155 2.167.289.349.563.708.772 1.113.297.575.028 1.208-.488 1.242l-3.205-.001c-.826.068-1.486-.265-2.04-.83-.444-.452-.855-.933-1.282-1.4a3.04 3.04 0 0 0-.576-.513c-.438-.284-.818-.197-1.068.26-.254.464-.312.978-.337 1.495-.034.754-.263.953-1.02.987-1.62.077-3.158-.168-4.587-.985-1.26-.721-2.236-1.738-3.086-2.89-1.655-2.242-2.922-4.706-4.06-7.239-.257-.57-.07-.877.56-.888a87.013 87.013 0 0 1 3.138-.001c.425.006.706.25.87.651.566 1.391 1.258 2.715 2.127 3.941.231.327.467.653.803.883.372.255.655.17.83-.244.11-.262.16-.545.184-.826.083-.967.094-1.933-.051-2.897-.09-.602-.428-.991-1.029-1.105-.306-.058-.26-.172-.112-.347.257-.302.5-.49.983-.49h3.622c.57.113.697.37.775.943l.003 4.024c-.006.222.11.881.51 1.028.321.105.532-.152.724-.355.868-.92 1.487-2.008 2.04-3.134.245-.495.456-1.01.66-1.524.152-.381.39-.569.82-.56l3.485.003c.104 0 .208.001.309.018.587.1.748.353.566.927-.285.9-.842 1.65-1.385 2.403-.582.805-1.204 1.582-1.78 2.39-.53.74-.488 1.112.17 1.754z" })));
9
+ exports.Vk = Vk;
@@ -280,7 +280,8 @@ export declare enum PCShareSocialNetwork {
280
280
  Vk = "vk",
281
281
  Telegram = "telegram",
282
282
  Twitter = "twitter",
283
- Facebook = "facebook"
283
+ Facebook = "facebook",
284
+ LinkedIn = "linkedin"
284
285
  }
285
286
  export interface ShareBlockProps {
286
287
  items: PCShareSocialNetwork[];
@@ -46,4 +46,5 @@ var PCShareSocialNetwork;
46
46
  PCShareSocialNetwork["Telegram"] = "telegram";
47
47
  PCShareSocialNetwork["Twitter"] = "twitter";
48
48
  PCShareSocialNetwork["Facebook"] = "facebook";
49
+ PCShareSocialNetwork["LinkedIn"] = "linkedin";
49
50
  })(PCShareSocialNetwork = exports.PCShareSocialNetwork || (exports.PCShareSocialNetwork = {}));
@@ -13,6 +13,50 @@ const getBlocksCases = (blocks) => {
13
13
  exports.getBlocksCases = getBlocksCases;
14
14
  function generateDefaultSchema(config) {
15
15
  const { cards = {}, blocks = {}, extensions = {} } = config !== null && config !== void 0 ? config : {};
16
+ const blockValidators = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, sub_blocks_1.Divider), blocks_1.ExtendedFeaturesBlock), blocks_1.PromoFeaturesBlock), blocks_1.SliderBlock), blocks_1.QuestionsBlock), blocks_1.HeaderBlock), blocks_1.BannerBlock), blocks_1.CompaniesBlock), blocks_1.MediaBlock), blocks_1.InfoBlock), blocks_1.SecurityBlock), blocks_1.TableBlock), blocks_1.TabsBlock), blocks_1.SimpleBlock), blocks_1.LinkTableBlock), blocks_1.PreviewBlock), blocks_1.HeaderSliderBlock), blocks_1.IconsBlock), blocks_1.CardLayoutBlock), blocks_1.ContentLayoutBlock), blocks_1.ShareBlock);
17
+ const cardValidators = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, sub_blocks_1.PartnerBlock), sub_blocks_1.MediaCardBlock), blocks_1.BannerCard), sub_blocks_1.PriceDetailedBlock), sub_blocks_1.TutorialCard), sub_blocks_1.BackgroundCard), sub_blocks_1.NewsCard), sub_blocks_1.CardWithImage), sub_blocks_1.Quote), sub_blocks_1.BasicCard);
18
+ const constructorBlockSchemaNames = [
19
+ 'divider',
20
+ 'quote',
21
+ 'event',
22
+ 'post',
23
+ 'extended-features-block',
24
+ 'promo-features-block',
25
+ 'slider-block',
26
+ 'questions-block',
27
+ 'header-block',
28
+ 'banner-block',
29
+ 'companies-block',
30
+ 'media-block',
31
+ 'info-block',
32
+ 'security-block',
33
+ 'table-block',
34
+ 'tabs-block',
35
+ 'simple-block',
36
+ 'link-table-block',
37
+ 'preview-block',
38
+ 'price-detailed',
39
+ 'header-slider-block',
40
+ 'cards-with-image-block',
41
+ 'icons-block',
42
+ 'card-layout-block',
43
+ 'content-layout-block',
44
+ 'share-block',
45
+ ];
46
+ const constructorCardSchemaNames = [
47
+ 'partner',
48
+ 'media-card',
49
+ 'banner-card',
50
+ 'price-detailed',
51
+ 'tutoral-card',
52
+ 'background-card',
53
+ 'news-card',
54
+ 'card-with-image',
55
+ 'quote',
56
+ 'basic-card',
57
+ ];
58
+ const configBlockSchemaNames = Object.keys(blocks).filter((item) => !constructorBlockSchemaNames.includes(item));
59
+ const configCardSchemaNames = Object.keys(cards).filter((item) => !constructorCardSchemaNames.includes(item));
16
60
  return {
17
61
  $id: 'self',
18
62
  definitions: {
@@ -22,38 +66,11 @@ function generateDefaultSchema(config) {
22
66
  properties: {
23
67
  type: {
24
68
  type: 'string',
25
- enum: [
26
- 'divider',
27
- 'quote',
28
- 'event',
29
- 'post',
30
- 'extended-features-block',
31
- 'promo-features-block',
32
- 'slider-block',
33
- 'questions-block',
34
- 'header-block',
35
- 'banner-block',
36
- 'companies-block',
37
- 'media-block',
38
- 'info-block',
39
- 'security-block',
40
- 'table-block',
41
- 'tabs-block',
42
- 'simple-block',
43
- 'link-table-block',
44
- 'preview-block',
45
- 'price-detailed',
46
- 'header-slider-block',
47
- 'cards-with-image-block',
48
- 'icons-block',
49
- 'card-layout-block',
50
- 'content-layout-block',
51
- ...Object.keys(blocks),
52
- ],
69
+ enum: [...constructorBlockSchemaNames, ...configBlockSchemaNames],
53
70
  },
54
71
  },
55
72
  select: { $data: '0/type' },
56
- selectCases: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, blocks_1.TabsBlock), blocks_1.SliderBlock), blocks_1.ExtendedFeaturesBlock), blocks_1.PromoFeaturesBlock), blocks_1.HeaderBlock), blocks_1.BannerBlock), blocks_1.CompaniesBlock), blocks_1.MediaBlock), blocks_1.InfoBlock), blocks_1.QuestionsBlock), blocks_1.SecurityBlock), blocks_1.TableBlock), blocks_1.SimpleBlock), blocks_1.LinkTableBlock), blocks_1.PreviewBlock), blocks_1.HeaderSliderBlock), blocks_1.IconsBlock), blocks_1.CardLayoutBlock), blocks_1.ContentLayoutBlock), sub_blocks_1.Divider), blocks_1.ShareBlock), (0, exports.getBlocksCases)(blocks)),
73
+ selectCases: Object.assign(Object.assign({}, blockValidators), (0, exports.getBlocksCases)(blocks)),
57
74
  }),
58
75
  cards: (0, utils_1.filteredItem)({
59
76
  type: 'object',
@@ -61,24 +78,11 @@ function generateDefaultSchema(config) {
61
78
  properties: {
62
79
  type: {
63
80
  type: 'string',
64
- enum: [
65
- 'partner',
66
- 'post',
67
- 'media-card',
68
- 'banner-card',
69
- 'price-detailed',
70
- 'tutoral-card',
71
- 'background-card',
72
- 'news-card',
73
- 'card-with-image',
74
- 'quote',
75
- 'basic-card',
76
- ...Object.keys(cards),
77
- ],
81
+ enum: [...constructorCardSchemaNames, ...configCardSchemaNames],
78
82
  },
79
83
  },
80
84
  select: { $data: '0/type' },
81
- selectCases: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, sub_blocks_1.PartnerBlock), sub_blocks_1.MediaCardBlock), blocks_1.BannerCard), sub_blocks_1.PriceDetailedBlock), sub_blocks_1.TutorialCard), sub_blocks_1.BackgroundCard), sub_blocks_1.NewsCard), sub_blocks_1.CardWithImage), sub_blocks_1.Quote), (0, exports.getBlocksCases)(cards)),
85
+ selectCases: Object.assign(Object.assign({}, cardValidators), (0, exports.getBlocksCases)(cards)),
82
86
  }),
83
87
  },
84
88
  type: 'object',
@@ -1,5 +1,5 @@
1
1
  import { ConstructorBlock } from '../models/constructor';
2
- import { TextSize, CustomConfig } from '../models';
2
+ import { TextSize, CustomConfig, PCShareSocialNetwork } from '../models';
3
3
  export declare function getHeaderTag(size: TextSize): "h1" | "h4" | "h2";
4
4
  export declare function getBlockKey(block: ConstructorBlock, index: number): string;
5
5
  export declare const getCustomBlockTypes: ({ blocks, headers }?: CustomConfig) => string[];
@@ -7,3 +7,4 @@ export declare const getCustomItems: ({ blocks, headers, subBlocks }?: CustomCon
7
7
  [x: string]: any;
8
8
  };
9
9
  export declare const getCustomHeaderTypes: (customBlocks?: CustomConfig) => string[];
10
+ export declare const getShareLink: (url: string, type: PCShareSocialNetwork, title?: string | undefined, text?: string | undefined) => string | undefined;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCustomHeaderTypes = exports.getCustomItems = exports.getCustomBlockTypes = exports.getBlockKey = exports.getHeaderTag = void 0;
3
+ exports.getShareLink = exports.getCustomHeaderTypes = exports.getCustomItems = exports.getCustomBlockTypes = exports.getBlockKey = exports.getHeaderTag = void 0;
4
+ const models_1 = require("../models");
4
5
  function getHeaderTag(size) {
5
6
  switch (size) {
6
7
  case 'l':
@@ -29,3 +30,41 @@ const getCustomHeaderTypes = (customBlocks = {}) => {
29
30
  return Object.keys(headers);
30
31
  };
31
32
  exports.getCustomHeaderTypes = getCustomHeaderTypes;
33
+ const getShareUrlWithParams = (url, params = {}) => {
34
+ const result = new URL(url);
35
+ Object.entries(params).forEach(([name, value]) => {
36
+ if (value) {
37
+ result.searchParams.set(name, value);
38
+ }
39
+ });
40
+ return result.toString();
41
+ };
42
+ const getShareLink = (url, type, title, text) => {
43
+ // https://github.com/bradvin/social-share-urls
44
+ switch (type) {
45
+ case models_1.PCShareSocialNetwork.Telegram:
46
+ return getShareUrlWithParams('https://t.me/share/url', { url, text: title });
47
+ case models_1.PCShareSocialNetwork.Facebook:
48
+ return getShareUrlWithParams('https://facebook.com/sharer.php', { u: url });
49
+ case models_1.PCShareSocialNetwork.Twitter:
50
+ return getShareUrlWithParams('https://twitter.com/intent/tweet', {
51
+ url,
52
+ text: title,
53
+ });
54
+ case models_1.PCShareSocialNetwork.Vk:
55
+ return getShareUrlWithParams('https://vk.com/share.php', {
56
+ url,
57
+ title,
58
+ comment: text,
59
+ });
60
+ case models_1.PCShareSocialNetwork.LinkedIn:
61
+ return getShareUrlWithParams('https://www.linkedin.com/sharing/share-offsite/', {
62
+ url,
63
+ });
64
+ default:
65
+ // eslint-disable-next-line no-console
66
+ console.error(`Unknown share type: ${type}`);
67
+ return undefined;
68
+ }
69
+ };
70
+ exports.getShareLink = getShareLink;
@@ -36,9 +36,16 @@ unpredictable css rules order in build */
36
36
  .pc-share-block__item_type_telegram {
37
37
  background-color: var(--yc-color-telegram);
38
38
  }
39
- .pc-share-block__item:before {
39
+ .pc-share-block__item_type_telegram {
40
+ background-color: var(--yc-color-telegram);
41
+ }
42
+ .pc-share-block__item_type_linkedin {
43
+ background-color: var(--yc-color-linkedin);
44
+ }
45
+ .pc-share-block__item.pc-share-block__item:before {
40
46
  border-radius: 100%;
41
47
  }
48
+
42
49
  .pc-share-block__item:hover:before {
43
50
  /* stylelint-disable-next-line declaration-no-important */
44
51
  background-color: var(--yc-color-base-generic) !important;
@@ -49,4 +56,9 @@ unpredictable css rules order in build */
49
56
  }
50
57
  .pc-share-block__item svg {
51
58
  color: var(--yc-color-base-background);
59
+ }
60
+ @media (max-width: 577px) {
61
+ .pc-share-block__items {
62
+ flex-wrap: wrap;
63
+ }
52
64
  }
@@ -1,22 +1,31 @@
1
1
  import React, { useContext } from 'react';
2
- import { ShareList, ShareSocialNetwork } from '@gravity-ui/uikit';
3
- import { block, getAbsolutePath } from '../../utils';
4
- import { PCShareSocialNetwork } from '../../models';
2
+ import { Icon, Button } from '@gravity-ui/uikit';
3
+ import { block, getAbsolutePath, getShareLink } from '../../utils';
5
4
  import { LocationContext } from '../../context/locationContext';
6
5
  import i18n from './i18n';
6
+ import { Facebook } from '../../icons/Facebook';
7
+ import { Twitter } from '../../icons/Twitter';
8
+ import { Linkedin } from '../../icons/Linkedin';
9
+ import { Vk } from '../../icons/Vk';
10
+ import { Telegram } from '../../icons/Telegram';
7
11
  import './Share.css';
8
- const b = block('share-block');
9
- // TODO https://st.yandex-team.ru/CLOUDFRONT-11753
10
- const pcShareSocialNetwork = {
11
- [PCShareSocialNetwork.Vk]: ShareSocialNetwork.VK,
12
- [PCShareSocialNetwork.Telegram]: ShareSocialNetwork.Telegram,
13
- [PCShareSocialNetwork.Twitter]: ShareSocialNetwork.Twitter,
14
- [PCShareSocialNetwork.Facebook]: ShareSocialNetwork.Facebook,
12
+ const icons = {
13
+ facebook: Facebook,
14
+ twitter: Twitter,
15
+ linkedin: Linkedin,
16
+ vk: Vk,
17
+ telegram: Telegram,
15
18
  };
19
+ const b = block('share-block');
16
20
  const Share = ({ items, title }) => {
17
21
  const { pathname, hostname } = useContext(LocationContext);
18
22
  return (React.createElement("div", { className: b() },
19
23
  React.createElement("h5", { className: b('title') }, title || i18n('constructor-share')),
20
- React.createElement("div", { className: b('items') }, items.map((type) => (React.createElement(ShareList.Item, { key: type, url: getAbsolutePath(hostname, pathname), className: b('item', { type: type.toLowerCase() }), type: pcShareSocialNetwork[type] }))))));
24
+ React.createElement("div", { className: b('items') }, items.map((type) => {
25
+ const url = getAbsolutePath(hostname, pathname);
26
+ const socialUrl = getShareLink(url, type);
27
+ const icon = icons[type];
28
+ return (React.createElement(Button, { key: type, view: "flat", size: "l", target: "_blank", href: socialUrl, className: b('item', { type: type.toLowerCase() }) }, icon && React.createElement(Icon, { data: icon, size: 24, className: b('icon', { type }) })));
29
+ }))));
21
30
  };
22
31
  export default Share;
@@ -10,11 +10,7 @@ export declare const ShareBlock: {
10
10
  type: string;
11
11
  items: {
12
12
  type: string;
13
- properties: {
14
- when: {
15
- type: string;
16
- };
17
- };
13
+ enum: string[];
18
14
  };
19
15
  };
20
16
  type: {};
@@ -1,4 +1,3 @@
1
- import { filteredArray } from '../../schema/validators/utils';
2
1
  import { BaseProps } from '../../schema/validators/common';
3
2
  export const ShareBlock = {
4
3
  'share-block': {
@@ -6,11 +5,12 @@ export const ShareBlock = {
6
5
  required: ['items'],
7
6
  properties: Object.assign(Object.assign({}, BaseProps), { title: {
8
7
  type: 'string',
9
- }, items: filteredArray({
10
- properties: {
8
+ }, items: {
9
+ type: 'array',
10
+ items: {
11
11
  type: 'string',
12
12
  enum: ['telegram', 'facebook', 'twitter', 'vk'],
13
13
  },
14
- }) }),
14
+ } }),
15
15
  },
16
16
  };
@@ -23,8 +23,9 @@ const Image = (props) => {
23
23
  React.createElement("source", { srcSet: mobile, media: `(max-width: ${BREAKPOINTS.sm}px)` }))),
24
24
  tablet && (React.createElement(Fragment, null,
25
25
  !disableWebp && (React.createElement("source", { srcSet: checkWebP(tablet), type: "image/webp", media: `(max-width: ${BREAKPOINTS.md}px)` })),
26
+ "]",
26
27
  React.createElement("source", { srcSet: tablet, media: `(max-width: ${BREAKPOINTS.md}px)` }))),
27
- desktop && !disableWebp && React.createElement("source", { srcSet: checkWebP(imageSrc), type: "image/webp" }),
28
+ imageSrc && !disableWebp && React.createElement("source", { srcSet: checkWebP(imageSrc), type: "image/webp" }),
28
29
  React.createElement("img", { className: className, src: imageSrc, alt: alt, style: style, onClick: onClick, onError: () => setImgLoadingError(true) })));
29
30
  };
30
31
  export default Image;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const Facebook: React.FC<React.SVGProps<SVGSVGElement>>;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { a11yHiddenSvgProps } from '../utils/svg';
3
+ export const Facebook = (props) => (React.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "currentColor" }, a11yHiddenSvgProps, props),
4
+ React.createElement("path", { d: "M13.79 22H9.93v-9.501H8V9.225h1.93V7.26C9.93 4.589 11.017 3 14.113 3h2.577v3.275h-1.61c-1.206 0-1.285.457-1.285 1.311l-.006 1.639h2.918l-.341 3.274H13.79V22z" })));
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const Linkedin: React.FC<React.SVGProps<SVGSVGElement>>;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { a11yHiddenSvgProps } from '../utils/svg';
3
+ export const Linkedin = (props) => (React.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "currentColor" }, a11yHiddenSvgProps, props),
4
+ React.createElement("path", { d: "M21.3779 19.3506H17.7796V13.7149C17.7796 12.371 17.7556 10.641 15.908 10.641C14.0339 10.641 13.7471 12.1053 13.7471 13.6171V19.3503H10.1487V7.76094H13.6032V9.34475H13.6515C13.9972 8.7536 14.4968 8.2673 15.097 7.93763C15.6972 7.60796 16.3756 7.44726 17.0599 7.47266C20.707 7.47266 21.3794 9.8718 21.3794 12.9929L21.3779 19.3506ZM6.08857 6.17675C5.67556 6.17682 5.2718 6.05442 4.92836 5.82501C4.58492 5.5956 4.31722 5.26949 4.1591 4.88792C4.00097 4.50633 3.95956 4.08644 4.04005 3.68132C4.12055 3.2762 4.31936 2.90406 4.61135 2.61194C4.90333 2.31983 5.27537 2.12085 5.68043 2.0402C6.08549 1.95954 6.50536 2.00084 6.88696 2.15883C7.26854 2.31683 7.59472 2.58444 7.82423 2.92782C8.05375 3.27122 8.1763 3.67496 8.17637 4.088C8.17642 4.36226 8.12246 4.63383 8.01757 4.88721C7.91267 5.14061 7.75889 5.37086 7.56502 5.56482C7.37114 5.75877 7.14098 5.91264 6.88765 6.01764C6.63431 6.12264 6.36278 6.1767 6.08857 6.17675ZM7.88774 19.3506H4.28561V7.76094H7.88774V19.3506Z" })));
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const Telegram: React.FC<React.SVGProps<SVGSVGElement>>;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { a11yHiddenSvgProps } from '../utils/svg';
3
+ export const Telegram = (props) => (React.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "currentColor" }, a11yHiddenSvgProps, props),
4
+ React.createElement("path", { d: "M2.336 11.932l4.378 1.634 1.694 5.45a.515.515 0 0 0 .819.246l2.44-1.99a.728.728 0 0 1 .888-.024l4.401 3.196c.303.22.732.054.808-.312l3.225-15.51a.516.516 0 0 0-.691-.587L2.33 10.968a.516.516 0 0 0 .006.965zm5.799.764l8.556-5.27c.154-.094.312.114.18.237L9.81 14.226c-.248.231-.408.54-.454.876l-.24 1.783c-.032.238-.367.261-.432.031l-.925-3.25a.862.862 0 0 1 .376-.97z" })));
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const Twitter: React.FC<React.SVGProps<SVGSVGElement>>;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { a11yHiddenSvgProps } from '../utils/svg';
3
+ export const Twitter = (props) => (React.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "currentColor" }, a11yHiddenSvgProps, props),
4
+ React.createElement("path", { d: "M19.644 6.675a4.247 4.247 0 0 0 1.803-2.362c-.793.49-1.67.844-2.606 1.036A4.016 4.016 0 0 0 15.846 4c-2.265 0-4.101 1.913-4.101 4.272 0 .335.034.66.104.973C8.44 9.066 5.417 7.367 3.392 4.78a4.397 4.397 0 0 0-.555 2.149c0 1.481.724 2.789 1.825 3.556a3.994 3.994 0 0 1-1.859-.534v.053c0 2.07 1.413 3.797 3.293 4.188-.345.1-.707.15-1.083.15-.264 0-.522-.025-.77-.075.52 1.696 2.036 2.933 3.832 2.966A8.028 8.028 0 0 1 2 19.004a11.29 11.29 0 0 0 6.29 1.92c7.548 0 11.673-6.51 11.673-12.156 0-.186-.002-.37-.01-.553A8.508 8.508 0 0 0 22 6.003c-.736.34-1.527.57-2.356.672z" })));
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const Vk: React.FC<React.SVGProps<SVGSVGElement>>;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { a11yHiddenSvgProps } from '../utils/svg';
3
+ export const Vk = (props) => (React.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "currentColor" }, a11yHiddenSvgProps, props),
4
+ React.createElement("path", { d: "M19.934 13.916c.73.713 1.5 1.383 2.155 2.167.289.349.563.708.772 1.113.297.575.028 1.208-.488 1.242l-3.205-.001c-.826.068-1.486-.265-2.04-.83-.444-.452-.855-.933-1.282-1.4a3.04 3.04 0 0 0-.576-.513c-.438-.284-.818-.197-1.068.26-.254.464-.312.978-.337 1.495-.034.754-.263.953-1.02.987-1.62.077-3.158-.168-4.587-.985-1.26-.721-2.236-1.738-3.086-2.89-1.655-2.242-2.922-4.706-4.06-7.239-.257-.57-.07-.877.56-.888a87.013 87.013 0 0 1 3.138-.001c.425.006.706.25.87.651.566 1.391 1.258 2.715 2.127 3.941.231.327.467.653.803.883.372.255.655.17.83-.244.11-.262.16-.545.184-.826.083-.967.094-1.933-.051-2.897-.09-.602-.428-.991-1.029-1.105-.306-.058-.26-.172-.112-.347.257-.302.5-.49.983-.49h3.622c.57.113.697.37.775.943l.003 4.024c-.006.222.11.881.51 1.028.321.105.532-.152.724-.355.868-.92 1.487-2.008 2.04-3.134.245-.495.456-1.01.66-1.524.152-.381.39-.569.82-.56l3.485.003c.104 0 .208.001.309.018.587.1.748.353.566.927-.285.9-.842 1.65-1.385 2.403-.582.805-1.204 1.582-1.78 2.39-.53.74-.488 1.112.17 1.754z" })));
@@ -280,7 +280,8 @@ export declare enum PCShareSocialNetwork {
280
280
  Vk = "vk",
281
281
  Telegram = "telegram",
282
282
  Twitter = "twitter",
283
- Facebook = "facebook"
283
+ Facebook = "facebook",
284
+ LinkedIn = "linkedin"
284
285
  }
285
286
  export interface ShareBlockProps {
286
287
  items: PCShareSocialNetwork[];
@@ -43,4 +43,5 @@ export var PCShareSocialNetwork;
43
43
  PCShareSocialNetwork["Telegram"] = "telegram";
44
44
  PCShareSocialNetwork["Twitter"] = "twitter";
45
45
  PCShareSocialNetwork["Facebook"] = "facebook";
46
+ PCShareSocialNetwork["LinkedIn"] = "linkedin";
46
47
  })(PCShareSocialNetwork || (PCShareSocialNetwork = {}));
@@ -1,6 +1,6 @@
1
1
  export { validators } from './validators';
2
2
  import { TabsBlock, BannerCard, SliderBlock, ExtendedFeaturesBlock, HeaderBlock, BannerBlock, CompaniesBlock, MediaBlock, InfoBlock, QuestionsBlock, SecurityBlock, TableBlock, SimpleBlock, LinkTableBlock, PromoFeaturesBlock, PreviewBlock, ContentLayoutBlock, HeaderSliderBlock, IconsBlock, CardLayoutBlock, ShareBlock, } from './validators/blocks';
3
- import { PartnerBlock, MediaCardBlock, TutorialCard, BackgroundCard, NewsCard, CardWithImage, PriceDetailedBlock, Quote, Divider, } from './validators/sub-blocks';
3
+ import { PartnerBlock, MediaCardBlock, TutorialCard, BackgroundCard, NewsCard, CardWithImage, PriceDetailedBlock, Quote, Divider, BasicCard, } from './validators/sub-blocks';
4
4
  import { AnimatableProps, BackgroundProps, MenuProps, withTheme } from './validators/common';
5
5
  import { filteredItem } from './validators/utils';
6
6
  export const getBlocksCases = (blocks) => {
@@ -8,6 +8,50 @@ export const getBlocksCases = (blocks) => {
8
8
  };
9
9
  export function generateDefaultSchema(config) {
10
10
  const { cards = {}, blocks = {}, extensions = {} } = config !== null && config !== void 0 ? config : {};
11
+ const blockValidators = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, Divider), ExtendedFeaturesBlock), PromoFeaturesBlock), SliderBlock), QuestionsBlock), HeaderBlock), BannerBlock), CompaniesBlock), MediaBlock), InfoBlock), SecurityBlock), TableBlock), TabsBlock), SimpleBlock), LinkTableBlock), PreviewBlock), HeaderSliderBlock), IconsBlock), CardLayoutBlock), ContentLayoutBlock), ShareBlock);
12
+ const cardValidators = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, PartnerBlock), MediaCardBlock), BannerCard), PriceDetailedBlock), TutorialCard), BackgroundCard), NewsCard), CardWithImage), Quote), BasicCard);
13
+ const constructorBlockSchemaNames = [
14
+ 'divider',
15
+ 'quote',
16
+ 'event',
17
+ 'post',
18
+ 'extended-features-block',
19
+ 'promo-features-block',
20
+ 'slider-block',
21
+ 'questions-block',
22
+ 'header-block',
23
+ 'banner-block',
24
+ 'companies-block',
25
+ 'media-block',
26
+ 'info-block',
27
+ 'security-block',
28
+ 'table-block',
29
+ 'tabs-block',
30
+ 'simple-block',
31
+ 'link-table-block',
32
+ 'preview-block',
33
+ 'price-detailed',
34
+ 'header-slider-block',
35
+ 'cards-with-image-block',
36
+ 'icons-block',
37
+ 'card-layout-block',
38
+ 'content-layout-block',
39
+ 'share-block',
40
+ ];
41
+ const constructorCardSchemaNames = [
42
+ 'partner',
43
+ 'media-card',
44
+ 'banner-card',
45
+ 'price-detailed',
46
+ 'tutoral-card',
47
+ 'background-card',
48
+ 'news-card',
49
+ 'card-with-image',
50
+ 'quote',
51
+ 'basic-card',
52
+ ];
53
+ const configBlockSchemaNames = Object.keys(blocks).filter((item) => !constructorBlockSchemaNames.includes(item));
54
+ const configCardSchemaNames = Object.keys(cards).filter((item) => !constructorCardSchemaNames.includes(item));
11
55
  return {
12
56
  $id: 'self',
13
57
  definitions: {
@@ -17,38 +61,11 @@ export function generateDefaultSchema(config) {
17
61
  properties: {
18
62
  type: {
19
63
  type: 'string',
20
- enum: [
21
- 'divider',
22
- 'quote',
23
- 'event',
24
- 'post',
25
- 'extended-features-block',
26
- 'promo-features-block',
27
- 'slider-block',
28
- 'questions-block',
29
- 'header-block',
30
- 'banner-block',
31
- 'companies-block',
32
- 'media-block',
33
- 'info-block',
34
- 'security-block',
35
- 'table-block',
36
- 'tabs-block',
37
- 'simple-block',
38
- 'link-table-block',
39
- 'preview-block',
40
- 'price-detailed',
41
- 'header-slider-block',
42
- 'cards-with-image-block',
43
- 'icons-block',
44
- 'card-layout-block',
45
- 'content-layout-block',
46
- ...Object.keys(blocks),
47
- ],
64
+ enum: [...constructorBlockSchemaNames, ...configBlockSchemaNames],
48
65
  },
49
66
  },
50
67
  select: { $data: '0/type' },
51
- selectCases: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, TabsBlock), SliderBlock), ExtendedFeaturesBlock), PromoFeaturesBlock), HeaderBlock), BannerBlock), CompaniesBlock), MediaBlock), InfoBlock), QuestionsBlock), SecurityBlock), TableBlock), SimpleBlock), LinkTableBlock), PreviewBlock), HeaderSliderBlock), IconsBlock), CardLayoutBlock), ContentLayoutBlock), Divider), ShareBlock), getBlocksCases(blocks)),
68
+ selectCases: Object.assign(Object.assign({}, blockValidators), getBlocksCases(blocks)),
52
69
  }),
53
70
  cards: filteredItem({
54
71
  type: 'object',
@@ -56,24 +73,11 @@ export function generateDefaultSchema(config) {
56
73
  properties: {
57
74
  type: {
58
75
  type: 'string',
59
- enum: [
60
- 'partner',
61
- 'post',
62
- 'media-card',
63
- 'banner-card',
64
- 'price-detailed',
65
- 'tutoral-card',
66
- 'background-card',
67
- 'news-card',
68
- 'card-with-image',
69
- 'quote',
70
- 'basic-card',
71
- ...Object.keys(cards),
72
- ],
76
+ enum: [...constructorCardSchemaNames, ...configCardSchemaNames],
73
77
  },
74
78
  },
75
79
  select: { $data: '0/type' },
76
- selectCases: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, PartnerBlock), MediaCardBlock), BannerCard), PriceDetailedBlock), TutorialCard), BackgroundCard), NewsCard), CardWithImage), Quote), getBlocksCases(cards)),
80
+ selectCases: Object.assign(Object.assign({}, cardValidators), getBlocksCases(cards)),
77
81
  }),
78
82
  },
79
83
  type: 'object',
@@ -1,5 +1,5 @@
1
1
  import { ConstructorBlock } from '../models/constructor';
2
- import { TextSize, CustomConfig } from '../models';
2
+ import { TextSize, CustomConfig, PCShareSocialNetwork } from '../models';
3
3
  export declare function getHeaderTag(size: TextSize): "h1" | "h4" | "h2";
4
4
  export declare function getBlockKey(block: ConstructorBlock, index: number): string;
5
5
  export declare const getCustomBlockTypes: ({ blocks, headers }?: CustomConfig) => string[];
@@ -7,3 +7,4 @@ export declare const getCustomItems: ({ blocks, headers, subBlocks }?: CustomCon
7
7
  [x: string]: any;
8
8
  };
9
9
  export declare const getCustomHeaderTypes: (customBlocks?: CustomConfig) => string[];
10
+ export declare const getShareLink: (url: string, type: PCShareSocialNetwork, title?: string | undefined, text?: string | undefined) => string | undefined;
@@ -1,3 +1,4 @@
1
+ import { PCShareSocialNetwork } from '../models';
1
2
  export function getHeaderTag(size) {
2
3
  switch (size) {
3
4
  case 'l':
@@ -21,3 +22,40 @@ export const getCustomHeaderTypes = (customBlocks = {}) => {
21
22
  const { headers = {} } = customBlocks;
22
23
  return Object.keys(headers);
23
24
  };
25
+ const getShareUrlWithParams = (url, params = {}) => {
26
+ const result = new URL(url);
27
+ Object.entries(params).forEach(([name, value]) => {
28
+ if (value) {
29
+ result.searchParams.set(name, value);
30
+ }
31
+ });
32
+ return result.toString();
33
+ };
34
+ export const getShareLink = (url, type, title, text) => {
35
+ // https://github.com/bradvin/social-share-urls
36
+ switch (type) {
37
+ case PCShareSocialNetwork.Telegram:
38
+ return getShareUrlWithParams('https://t.me/share/url', { url, text: title });
39
+ case PCShareSocialNetwork.Facebook:
40
+ return getShareUrlWithParams('https://facebook.com/sharer.php', { u: url });
41
+ case PCShareSocialNetwork.Twitter:
42
+ return getShareUrlWithParams('https://twitter.com/intent/tweet', {
43
+ url,
44
+ text: title,
45
+ });
46
+ case PCShareSocialNetwork.Vk:
47
+ return getShareUrlWithParams('https://vk.com/share.php', {
48
+ url,
49
+ title,
50
+ comment: text,
51
+ });
52
+ case PCShareSocialNetwork.LinkedIn:
53
+ return getShareUrlWithParams('https://www.linkedin.com/sharing/share-offsite/', {
54
+ url,
55
+ });
56
+ default:
57
+ // eslint-disable-next-line no-console
58
+ console.error(`Unknown share type: ${type}`);
59
+ return undefined;
60
+ }
61
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "1.10.1",
3
+ "version": "1.10.2-alpha.1",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "peerDependencies": {
60
60
  "react": "^16.0.0 || ^17.0.0",
61
- "@gravity-ui/uikit": "^3.0.1",
61
+ "@gravity-ui/uikit": "^3.11.0",
62
62
  "@doc-tools/transform": "^2.6.1"
63
63
  },
64
64
  "devDependencies": {
@@ -69,7 +69,7 @@
69
69
  "@gravity-ui/prettier-config": "^1.0.1",
70
70
  "@gravity-ui/stylelint-config": "^1.0.0",
71
71
  "@gravity-ui/tsconfig": "^1.0.0",
72
- "@gravity-ui/uikit": "^3.0.1",
72
+ "@gravity-ui/uikit": "^3.11.0",
73
73
  "@storybook/addon-actions": "^6.3.12",
74
74
  "@storybook/addon-essentials": "^6.5.10",
75
75
  "@storybook/addon-knobs": "^6.3.1",
@@ -121,5 +121,8 @@
121
121
  "*.{json,yaml,yml,md}": [
122
122
  "prettier --write"
123
123
  ]
124
+ },
125
+ "publishConfig": {
126
+ "tag": "alpha"
124
127
  }
125
128
  }
@@ -280,7 +280,8 @@ export declare enum PCShareSocialNetwork {
280
280
  Vk = "vk",
281
281
  Telegram = "telegram",
282
282
  Twitter = "twitter",
283
- Facebook = "facebook"
283
+ Facebook = "facebook",
284
+ LinkedIn = "linkedin"
284
285
  }
285
286
  export interface ShareBlockProps {
286
287
  items: PCShareSocialNetwork[];
@@ -46,4 +46,5 @@ var PCShareSocialNetwork;
46
46
  PCShareSocialNetwork["Telegram"] = "telegram";
47
47
  PCShareSocialNetwork["Twitter"] = "twitter";
48
48
  PCShareSocialNetwork["Facebook"] = "facebook";
49
+ PCShareSocialNetwork["LinkedIn"] = "linkedin";
49
50
  })(PCShareSocialNetwork = exports.PCShareSocialNetwork || (exports.PCShareSocialNetwork = {}));
@@ -1,5 +1,5 @@
1
1
  import { ConstructorBlock } from '../models/constructor';
2
- import { TextSize, CustomConfig } from '../models';
2
+ import { TextSize, CustomConfig, PCShareSocialNetwork } from '../models';
3
3
  export declare function getHeaderTag(size: TextSize): "h1" | "h4" | "h2";
4
4
  export declare function getBlockKey(block: ConstructorBlock, index: number): string;
5
5
  export declare const getCustomBlockTypes: ({ blocks, headers }?: CustomConfig) => string[];
@@ -7,3 +7,4 @@ export declare const getCustomItems: ({ blocks, headers, subBlocks }?: CustomCon
7
7
  [x: string]: any;
8
8
  };
9
9
  export declare const getCustomHeaderTypes: (customBlocks?: CustomConfig) => string[];
10
+ export declare const getShareLink: (url: string, type: PCShareSocialNetwork, title?: string | undefined, text?: string | undefined) => string | undefined;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCustomHeaderTypes = exports.getCustomItems = exports.getCustomBlockTypes = exports.getBlockKey = exports.getHeaderTag = void 0;
3
+ exports.getShareLink = exports.getCustomHeaderTypes = exports.getCustomItems = exports.getCustomBlockTypes = exports.getBlockKey = exports.getHeaderTag = void 0;
4
+ const models_1 = require("../models");
4
5
  function getHeaderTag(size) {
5
6
  switch (size) {
6
7
  case 'l':
@@ -29,3 +30,41 @@ const getCustomHeaderTypes = (customBlocks = {}) => {
29
30
  return Object.keys(headers);
30
31
  };
31
32
  exports.getCustomHeaderTypes = getCustomHeaderTypes;
33
+ const getShareUrlWithParams = (url, params = {}) => {
34
+ const result = new URL(url);
35
+ Object.entries(params).forEach(([name, value]) => {
36
+ if (value) {
37
+ result.searchParams.set(name, value);
38
+ }
39
+ });
40
+ return result.toString();
41
+ };
42
+ const getShareLink = (url, type, title, text) => {
43
+ // https://github.com/bradvin/social-share-urls
44
+ switch (type) {
45
+ case models_1.PCShareSocialNetwork.Telegram:
46
+ return getShareUrlWithParams('https://t.me/share/url', { url, text: title });
47
+ case models_1.PCShareSocialNetwork.Facebook:
48
+ return getShareUrlWithParams('https://facebook.com/sharer.php', { u: url });
49
+ case models_1.PCShareSocialNetwork.Twitter:
50
+ return getShareUrlWithParams('https://twitter.com/intent/tweet', {
51
+ url,
52
+ text: title,
53
+ });
54
+ case models_1.PCShareSocialNetwork.Vk:
55
+ return getShareUrlWithParams('https://vk.com/share.php', {
56
+ url,
57
+ title,
58
+ comment: text,
59
+ });
60
+ case models_1.PCShareSocialNetwork.LinkedIn:
61
+ return getShareUrlWithParams('https://www.linkedin.com/sharing/share-offsite/', {
62
+ url,
63
+ });
64
+ default:
65
+ // eslint-disable-next-line no-console
66
+ console.error(`Unknown share type: ${type}`);
67
+ return undefined;
68
+ }
69
+ };
70
+ exports.getShareLink = getShareLink;