@gravity-ui/page-constructor 4.54.0 → 4.56.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.
Files changed (97) hide show
  1. package/build/cjs/blocks/Tabs/Tabs.css +8 -1
  2. package/build/cjs/blocks/Tabs/Tabs.js +3 -2
  3. package/build/cjs/blocks/Tabs/schema.d.ts +4 -0
  4. package/build/cjs/blocks/Tabs/schema.js +4 -1
  5. package/build/cjs/components/Buttons/Buttons.css +11 -0
  6. package/build/cjs/components/Buttons/Buttons.d.ts +12 -0
  7. package/build/cjs/components/Buttons/Buttons.js +18 -0
  8. package/build/cjs/components/CardBase/CardBase.d.ts +2 -3
  9. package/build/cjs/components/CardBase/CardBase.js +5 -6
  10. package/build/cjs/components/Foldable/Foldable.d.ts +3 -3
  11. package/build/cjs/components/Foldable/Foldable.js +4 -3
  12. package/build/cjs/components/Links/Links.css +14 -0
  13. package/build/cjs/components/Links/Links.d.ts +12 -0
  14. package/build/cjs/components/Links/Links.js +18 -0
  15. package/build/cjs/components/index.d.ts +2 -1
  16. package/build/cjs/components/index.js +4 -2
  17. package/build/cjs/constructor-items.d.ts +1 -1
  18. package/build/cjs/models/constructor-items/blocks.d.ts +1 -1
  19. package/build/cjs/models/constructor-items/common.d.ts +4 -0
  20. package/build/cjs/models/constructor-items/sub-blocks.d.ts +4 -4
  21. package/build/cjs/schema/constants.d.ts +12 -0
  22. package/build/cjs/sub-blocks/BackgroundCard/BackgroundCard.js +15 -3
  23. package/build/cjs/sub-blocks/BackgroundCard/schema.d.ts +4 -0
  24. package/build/cjs/sub-blocks/BackgroundCard/schema.js +3 -0
  25. package/build/cjs/sub-blocks/BasicCard/BasicCard.js +17 -8
  26. package/build/cjs/sub-blocks/BasicCard/schema.d.ts +4 -0
  27. package/build/cjs/sub-blocks/BasicCard/schema.js +3 -0
  28. package/build/cjs/sub-blocks/Content/Content.css +0 -22
  29. package/build/cjs/sub-blocks/Content/Content.js +10 -21
  30. package/build/cjs/sub-blocks/LayoutItem/LayoutItem.css +6 -0
  31. package/build/cjs/sub-blocks/LayoutItem/LayoutItem.d.ts +1 -1
  32. package/build/cjs/sub-blocks/LayoutItem/LayoutItem.js +16 -4
  33. package/build/cjs/sub-blocks/LayoutItem/schema.d.ts +4 -0
  34. package/build/cjs/sub-blocks/LayoutItem/schema.js +3 -0
  35. package/build/cjs/sub-blocks/PriceCard/PriceCard.css +2 -5
  36. package/build/cjs/sub-blocks/PriceCard/PriceCard.js +4 -4
  37. package/build/cjs/sub-blocks/PriceCard/schema.d.ts +4 -0
  38. package/build/cjs/sub-blocks/PriceCard/schema.js +3 -0
  39. package/build/cjs/sub-blocks/renderCardFooterControlsContainer/CardFooterControlsContainer.css +3 -0
  40. package/build/cjs/sub-blocks/renderCardFooterControlsContainer/renderCardFooterControlsContainer.d.ts +3 -0
  41. package/build/cjs/sub-blocks/renderCardFooterControlsContainer/renderCardFooterControlsContainer.js +9 -0
  42. package/build/cjs/utils/renderContentControls/ContentControls.css +6 -0
  43. package/build/cjs/utils/renderContentControls/renderContentControls.d.ts +11 -0
  44. package/build/cjs/utils/renderContentControls/renderContentControls.js +16 -0
  45. package/build/esm/blocks/Tabs/Tabs.css +8 -1
  46. package/build/esm/blocks/Tabs/Tabs.js +3 -2
  47. package/build/esm/blocks/Tabs/schema.d.ts +4 -0
  48. package/build/esm/blocks/Tabs/schema.js +4 -1
  49. package/build/esm/components/Buttons/Buttons.css +11 -0
  50. package/build/esm/components/Buttons/Buttons.d.ts +13 -0
  51. package/build/esm/components/Buttons/Buttons.js +16 -0
  52. package/build/esm/components/CardBase/CardBase.d.ts +2 -3
  53. package/build/esm/components/CardBase/CardBase.js +6 -7
  54. package/build/esm/components/Foldable/Foldable.d.ts +3 -3
  55. package/build/esm/components/Foldable/Foldable.js +5 -4
  56. package/build/esm/components/Links/Links.css +14 -0
  57. package/build/esm/components/Links/Links.d.ts +13 -0
  58. package/build/esm/components/Links/Links.js +16 -0
  59. package/build/esm/components/index.d.ts +2 -1
  60. package/build/esm/components/index.js +2 -1
  61. package/build/esm/constructor-items.d.ts +1 -1
  62. package/build/esm/models/constructor-items/blocks.d.ts +1 -1
  63. package/build/esm/models/constructor-items/common.d.ts +4 -0
  64. package/build/esm/models/constructor-items/sub-blocks.d.ts +4 -4
  65. package/build/esm/schema/constants.d.ts +12 -0
  66. package/build/esm/sub-blocks/BackgroundCard/BackgroundCard.js +15 -3
  67. package/build/esm/sub-blocks/BackgroundCard/schema.d.ts +4 -0
  68. package/build/esm/sub-blocks/BackgroundCard/schema.js +3 -0
  69. package/build/esm/sub-blocks/BasicCard/BasicCard.js +14 -5
  70. package/build/esm/sub-blocks/BasicCard/schema.d.ts +4 -0
  71. package/build/esm/sub-blocks/BasicCard/schema.js +3 -0
  72. package/build/esm/sub-blocks/Content/Content.css +0 -22
  73. package/build/esm/sub-blocks/Content/Content.js +11 -22
  74. package/build/esm/sub-blocks/LayoutItem/LayoutItem.css +6 -0
  75. package/build/esm/sub-blocks/LayoutItem/LayoutItem.d.ts +1 -1
  76. package/build/esm/sub-blocks/LayoutItem/LayoutItem.js +16 -4
  77. package/build/esm/sub-blocks/LayoutItem/schema.d.ts +4 -0
  78. package/build/esm/sub-blocks/LayoutItem/schema.js +3 -0
  79. package/build/esm/sub-blocks/PriceCard/PriceCard.css +2 -5
  80. package/build/esm/sub-blocks/PriceCard/PriceCard.js +5 -5
  81. package/build/esm/sub-blocks/PriceCard/schema.d.ts +4 -0
  82. package/build/esm/sub-blocks/PriceCard/schema.js +3 -0
  83. package/build/esm/sub-blocks/renderCardFooterControlsContainer/CardFooterControlsContainer.css +3 -0
  84. package/build/esm/sub-blocks/renderCardFooterControlsContainer/renderCardFooterControlsContainer.d.ts +3 -0
  85. package/build/esm/sub-blocks/renderCardFooterControlsContainer/renderCardFooterControlsContainer.js +6 -0
  86. package/build/esm/utils/renderContentControls/ContentControls.css +6 -0
  87. package/build/esm/utils/renderContentControls/renderContentControls.d.ts +12 -0
  88. package/build/esm/utils/renderContentControls/renderContentControls.js +14 -0
  89. package/package.json +1 -1
  90. package/server/models/constructor-items/blocks.d.ts +1 -1
  91. package/server/models/constructor-items/common.d.ts +4 -0
  92. package/server/models/constructor-items/sub-blocks.d.ts +4 -4
  93. package/widget/index.js +1 -1
  94. package/build/cjs/components/Link/Links.d.ts +0 -6
  95. package/build/cjs/components/Link/Links.js +0 -13
  96. package/build/esm/components/Link/Links.d.ts +0 -6
  97. package/build/esm/components/Link/Links.js +0 -10
@@ -1,3 +1,3 @@
1
1
  import { LayoutItemProps } from '../../models';
2
- declare const LayoutItem: ({ content: { links, ...content }, metaInfo, media, border, fullscreen, icon, className, analyticsEvents, }: LayoutItemProps) => JSX.Element;
2
+ declare const LayoutItem: ({ content: { links, buttons, ...content }, metaInfo, media, border, fullscreen, icon, className, analyticsEvents, controlPosition, }: LayoutItemProps) => JSX.Element;
3
3
  export default LayoutItem;
@@ -1,15 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const react_1 = tslib_1.__importDefault(require("react"));
4
+ const react_1 = tslib_1.__importStar(require("react"));
5
+ const uikit_1 = require("@gravity-ui/uikit");
5
6
  const components_1 = require("../../components");
6
7
  const utils_1 = require("../../utils");
8
+ const renderContentControls_1 = tslib_1.__importDefault(require("../../utils/renderContentControls/renderContentControls"));
7
9
  const Content_1 = tslib_1.__importDefault(require("../Content/Content"));
8
10
  const utils_2 = require("./utils");
9
11
  const b = (0, utils_1.block)('layout-item');
10
12
  const LayoutItem = (_a) => {
11
- var _b = _a.content, { links } = _b, content = tslib_1.__rest(_b, ["links"]), { metaInfo, media, border, fullscreen, icon, className, analyticsEvents } = _a;
12
- const contentProps = Object.assign(Object.assign({}, content), { links: (0, utils_2.getLayoutItemLinks)(links), size: 's', colSizes: { all: 12, md: 12 } });
13
+ var _b = _a.content, { links, buttons } = _b, content = tslib_1.__rest(_b, ["links", "buttons"]), { metaInfo, media, border, fullscreen, icon, className, analyticsEvents, controlPosition = 'content' } = _a;
14
+ const normalizedLinks = (0, react_1.useMemo)(() => (0, utils_2.getLayoutItemLinks)(links), [links]);
15
+ const areControlsInFooter = controlPosition === 'footer';
16
+ const contentProps = Object.assign(Object.assign(Object.assign({}, content), (areControlsInFooter ? {} : { links: normalizedLinks, buttons })), { size: 's', colSizes: { all: 12, md: 12 } });
17
+ const titleId = (0, uikit_1.useUniqId)();
18
+ const footerControls = (0, react_1.useMemo)(() => (0, renderContentControls_1.default)({
19
+ links: areControlsInFooter ? links : undefined,
20
+ buttons: areControlsInFooter ? buttons : undefined,
21
+ size: 's',
22
+ titleId,
23
+ }), [areControlsInFooter, links, buttons, titleId]);
13
24
  const renderMedia = () => {
14
25
  if (!media) {
15
26
  return null;
@@ -24,6 +35,7 @@ const LayoutItem = (_a) => {
24
35
  metaInfo && react_1.default.createElement(components_1.MetaInfo, { items: metaInfo, className: b('meta-info') }),
25
36
  react_1.default.createElement("div", { className: b('content', { 'no-media': !media }) },
26
37
  react_1.default.createElement(components_1.IconWrapper, { icon: icon },
27
- react_1.default.createElement(Content_1.default, Object.assign({}, contentProps))))));
38
+ react_1.default.createElement(Content_1.default, Object.assign({}, contentProps, { titleId: titleId })))),
39
+ footerControls));
28
40
  };
29
41
  exports.default = LayoutItem;
@@ -450,6 +450,10 @@ export declare const LayoutItem: {
450
450
  optionName: string;
451
451
  })[];
452
452
  };
453
+ controlPosition: {
454
+ type: string;
455
+ enum: string[];
456
+ };
453
457
  type: {};
454
458
  when: {
455
459
  type: string;
@@ -24,5 +24,8 @@ exports.LayoutItem = {
24
24
  optionName: 'list',
25
25
  },
26
26
  ],
27
+ }, controlPosition: {
28
+ type: 'string',
29
+ enum: ['content', 'footer'],
27
30
  } }),
28
31
  };
@@ -86,11 +86,8 @@ unpredictable css rules order in build */
86
86
  .pc-price-card__links, .pc-price-card__buttons {
87
87
  margin-top: 24px;
88
88
  }
89
- .pc-price-card__links > *:not(:last-child), .pc-price-card__buttons > *:not(:last-child) {
90
- margin-right: 16px;
91
- }
92
- .pc-price-card__link {
93
- margin-top: 0;
89
+ .pc-price-card__footer {
90
+ margin-top: 0px;
94
91
  }
95
92
  @media (max-width: 769px) {
96
93
  .pc-price-card__title, .pc-price-card__price {
@@ -9,11 +9,11 @@ const b = (0, utils_1.block)('price-card');
9
9
  const PriceCard = (props) => {
10
10
  const { border, title, price, pricePeriod, priceDetails, theme, description, list, buttons, links, backgroundColor, } = props;
11
11
  return (react_1.default.createElement(components_1.CardBase, { className: b({ theme }), border: border },
12
- react_1.default.createElement(components_1.CardBase.Content, null,
12
+ react_1.default.createElement(components_1.CardBase.Content, { key: "content" },
13
13
  react_1.default.createElement(components_1.BackgroundImage, { className: b('background'), style: { backgroundColor } }),
14
14
  react_1.default.createElement("div", { className: b('content', { theme }) },
15
15
  react_1.default.createElement("div", { className: b('info') },
16
- react_1.default.createElement("div", { className: b('title') }, title),
16
+ react_1.default.createElement(components_1.HTML, { className: b('title') }, title),
17
17
  react_1.default.createElement("div", { className: b('price') },
18
18
  react_1.default.createElement("div", null,
19
19
  react_1.default.createElement("span", { className: b('price-value') }, price),
@@ -27,7 +27,7 @@ const PriceCard = (props) => {
27
27
  icon: Check_1.default,
28
28
  text: item,
29
29
  })), size: "l" }))) : null),
30
- buttons && (react_1.default.createElement("div", { className: b('buttons') }, buttons.map((button) => (react_1.default.createElement(components_1.Button, Object.assign({ key: button.url }, button)))))),
31
- links && (react_1.default.createElement("div", { className: b('links') }, links.map((link) => (react_1.default.createElement(components_1.Link, Object.assign({ className: b('link'), key: link.url, textSize: "m" }, link))))))))));
30
+ react_1.default.createElement(components_1.Buttons, { className: b('buttons'), buttons: buttons, size: "s" }),
31
+ react_1.default.createElement(components_1.Links, { className: b('links'), links: links, size: "s" })))));
32
32
  };
33
33
  exports.default = PriceCard;
@@ -398,6 +398,10 @@ export declare const PriceCardBlock: {
398
398
  type: string;
399
399
  };
400
400
  };
401
+ controlPosition: {
402
+ type: string;
403
+ enum: string[];
404
+ };
401
405
  border: {
402
406
  type: string;
403
407
  enum: string[];
@@ -30,6 +30,9 @@ exports.PriceCardBlock = {
30
30
  items: {
31
31
  type: 'string',
32
32
  },
33
+ }, controlPosition: {
34
+ type: 'string',
35
+ enum: ['content', 'footer'],
33
36
  } }),
34
37
  },
35
38
  };
@@ -0,0 +1,3 @@
1
+ .pc-card-footer-controls {
2
+ margin-top: 0px;
3
+ }
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const renderCardFooterControlsContainer: (children: React.ReactElement) => JSX.Element;
3
+ export default renderCardFooterControlsContainer;
@@ -0,0 +1,9 @@
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 components_1 = require("../../components");
6
+ const utils_1 = require("../../utils");
7
+ const b = (0, utils_1.block)('card-footer-controls-containe');
8
+ const renderCardFooterControlsContainer = (children) => (react_1.default.createElement(components_1.CardBase.Footer, { className: b() }, children));
9
+ exports.default = renderCardFooterControlsContainer;
@@ -0,0 +1,6 @@
1
+ .pc-content-controls__links_size_s, .pc-content-controls__buttons_size_s {
2
+ margin-top: 16px;
3
+ }
4
+ .pc-content-controls__links_size_l, .pc-content-controls__buttons_size_l {
5
+ margin-top: 24px;
6
+ }
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { ButtonProps, ContentSize, LinkProps } from '../../models';
3
+ type ContentControlsArgs = {
4
+ links?: LinkProps[];
5
+ buttons?: ButtonProps[];
6
+ titleId?: string;
7
+ size?: ContentSize;
8
+ qa?: Record<string, string>;
9
+ };
10
+ declare const renderContentControls: ({ links, buttons, titleId, size, qa }: ContentControlsArgs, renderContainer?: (children: React.ReactElement) => React.ReactElement) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
11
+ export default renderContentControls;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = tslib_1.__importStar(require("react"));
5
+ const components_1 = require("../../components");
6
+ const utils_1 = require("../../utils");
7
+ const b = (0, utils_1.block)('content-controls');
8
+ const renderContentControls = ({ links, buttons, titleId, size = 's', qa = {} }, renderContainer = (children) => children) => {
9
+ const { links: linksQa, link: linkQa, buttons: buttonsQa, button: buttonQa } = qa;
10
+ return links || buttons
11
+ ? renderContainer(react_1.default.createElement(react_1.Fragment, null,
12
+ react_1.default.createElement(components_1.Links, { className: b('links', { size }), size: size, links: links, titleId: titleId, qa: linksQa, linkQa: linkQa }),
13
+ react_1.default.createElement(components_1.Buttons, { className: b('buttons', { size }), size: size, buttons: buttons, titleId: titleId, qa: buttonsQa, buttonQa: buttonQa })))
14
+ : null;
15
+ };
16
+ exports.default = renderContentControls;
@@ -46,11 +46,18 @@ unpredictable css rules order in build */
46
46
  object-fit: cover;
47
47
  display: block;
48
48
  }
49
- .pc-tabs-block__image, .pc-tabs-block__media {
49
+ .pc-tabs-block__image_border_shadow, .pc-tabs-block__media_border_shadow {
50
50
  box-shadow: 0 2px 8px var(--pc-color-sfx-shadow), 0 4px 24px var(--pc-color-sfx-shadow);
51
51
  overflow-x: hidden;
52
52
  border-radius: var(--pc-border-radius);
53
53
  }
54
+ .pc-tabs-block__image_border_line, .pc-tabs-block__media_border_line {
55
+ border-radius: var(--pc-border-radius);
56
+ border: 1px solid var(--g-color-line-generic);
57
+ }
58
+ .pc-tabs-block__image_border_none, .pc-tabs-block__media_border_none {
59
+ border-radius: var(--pc-border-radius);
60
+ }
54
61
  .pc-tabs-block__caption {
55
62
  font-size: var(--g-text-body-2-font-size);
56
63
  line-height: var(--g-text-body-2-line-height);
@@ -57,15 +57,16 @@ export const TabsBlock = ({ items, title, description, animated, tabsColSizes, c
57
57
  }
58
58
  const showMedia = Boolean((activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.media) || imageProps);
59
59
  const showText = Boolean(activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.text);
60
+ const border = (activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.border) || 'shadow';
60
61
  const textContent = activeTabData && showText && (React.createElement(TabsTextContent, { showMedia: showMedia, data: activeTabData, imageProps: imageProps ? imageProps : undefined, isReverse: isReverse, contentSize: contentSize, centered: centered }));
61
62
  const mediaContent = showMedia && (React.createElement(Col, { sizes: { all: 12, md: 8 }, orders: {
62
63
  all: GridColumnOrderClasses.Last,
63
64
  md: GridColumnOrderClasses.First,
64
65
  }, className: b('col', { centered: centered }) },
65
66
  React.createElement("div", { style: { minHeight: mediaVideoHeight || minImageHeight } }, (activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.media) && (React.createElement("div", { ref: ref },
66
- React.createElement(Media, Object.assign({}, getThemedValue(activeTabData.media, theme), { key: activeTab, className: b('media'), playVideo: play, height: mediaVideoHeight || undefined, onImageLoad: handleImageHeight }))))),
67
+ React.createElement(Media, Object.assign({}, getThemedValue(activeTabData.media, theme), { key: activeTab, className: b('media', { border }), playVideo: play, height: mediaVideoHeight || undefined, onImageLoad: handleImageHeight }))))),
67
68
  imageProps && (React.createElement(Fragment, null,
68
- React.createElement(FullscreenImage, Object.assign({}, imageProps, { imageClassName: b('image') })))),
69
+ React.createElement(FullscreenImage, Object.assign({}, imageProps, { imageClassName: b('image', { border }) })))),
69
70
  (activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.caption) && (React.createElement("p", { className: b('caption'), id: captionId },
70
71
  React.createElement(YFMWrapper, { content: activeTabData.caption, modifiers: { constructor: true }, id: captionId })))));
71
72
  return (React.createElement(AnimateBlock, { className: b(), onScroll: () => setPlay(true), animate: animated },
@@ -433,6 +433,10 @@ export declare const tabsItem: {
433
433
  optionName: string;
434
434
  })[];
435
435
  };
436
+ border: {
437
+ type: string;
438
+ enum: string[];
439
+ };
436
440
  title?: {
437
441
  oneOf: ({
438
442
  type: string;
@@ -18,7 +18,10 @@ export const tabsItem = {
18
18
  properties: MediaProps,
19
19
  }),
20
20
  //TODO deprecated
21
- link: LinkProps, image: withTheme(ImageProps) }),
21
+ link: LinkProps, image: withTheme(ImageProps), border: {
22
+ type: 'string',
23
+ enum: ['shadow', 'line', 'none'],
24
+ } }),
22
25
  };
23
26
  export const TabsBlock = {
24
27
  'tabs-block': {
@@ -0,0 +1,11 @@
1
+ .pc-buttons {
2
+ display: flex;
3
+ flex-wrap: wrap;
4
+ column-gap: 12px;
5
+ }
6
+ .pc-buttons_size_s {
7
+ row-gap: 8px;
8
+ }
9
+ .pc-buttons_size_l {
10
+ row-gap: 12px;
11
+ }
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { ButtonProps, ContentSize } from '../../models';
3
+ import './Buttons.css';
4
+ type ButtonsProps = {
5
+ className?: string;
6
+ buttons?: ButtonProps[];
7
+ size?: ContentSize;
8
+ titleId?: string;
9
+ qa?: string;
10
+ buttonQa?: string;
11
+ };
12
+ declare const Buttons: React.FC<ButtonsProps>;
13
+ export default Buttons;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { block } from '../../utils';
3
+ import Button from '../Button/Button';
4
+ import './Buttons.css';
5
+ const b = block('buttons');
6
+ function getButtonSize(size) {
7
+ switch (size) {
8
+ case 's':
9
+ return 'm';
10
+ case 'l':
11
+ default:
12
+ return 'xl';
13
+ }
14
+ }
15
+ const Buttons = ({ className, titleId, buttons, size = 's', qa, buttonQa }) => buttons ? (React.createElement("div", { className: b({ size }, className), "data-qa": qa }, buttons.map((item) => (React.createElement(Button, Object.assign({ className: b('button') }, item, { key: item.url, size: getButtonSize(size), qa: buttonQa, extraProps: Object.assign({ 'aria-describedby': item.urlTitle ? undefined : titleId }, item.extraProps) })))))) : null;
16
+ export default Buttons;
@@ -1,11 +1,10 @@
1
- import React, { HTMLAttributeAnchorTarget, ReactElement } from 'react';
1
+ import React, { HTMLAttributeAnchorTarget, PropsWithChildren } from 'react';
2
2
  import { AnalyticsEventsBase, ButtonPixel, CardBaseProps as CardBaseParams, ImageProps, MetrikaGoal, WithChildren } from '../../models';
3
3
  import './CardBase.css';
4
- export interface CardBaseProps extends AnalyticsEventsBase, CardBaseParams {
4
+ export interface CardBaseProps extends AnalyticsEventsBase, CardBaseParams, PropsWithChildren {
5
5
  className?: string;
6
6
  bodyClassName?: string;
7
7
  contentClassName?: string;
8
- children: ReactElement | ReactElement[];
9
8
  url?: string;
10
9
  urlTitle?: string;
11
10
  target?: HTMLAttributeAnchorTarget;
@@ -1,4 +1,4 @@
1
- import React, { Children, Fragment } from 'react';
1
+ import React, { Children, Fragment, isValidElement, } from 'react';
2
2
  import { Link } from '@gravity-ui/uikit';
3
3
  import { useAnalytics } from '../../hooks';
4
4
  import { useMetrika } from '../../hooks/useMetrika';
@@ -33,12 +33,11 @@ export const Layout = (props) => {
33
33
  break;
34
34
  }
35
35
  }
36
- if (Children.count(children) === 1) {
37
- handleChild(children);
38
- }
39
- else {
40
- Children.forEach(children, handleChild);
41
- }
36
+ Children.toArray(children).forEach((child) => {
37
+ if (isValidElement(child)) {
38
+ handleChild(child);
39
+ }
40
+ });
42
41
  const cardContent = (React.createElement(Fragment, null,
43
42
  (header || image) && (React.createElement(BackgroundImage, Object.assign({ className: b('header', headerClass) }, (typeof image === 'string' ? { src: image } : image), { qa: qaAttributes.header }),
44
43
  React.createElement("div", { className: b('header-content') }, header))),
@@ -1,8 +1,8 @@
1
- import { WithChildren } from '../../models';
1
+ import { QAProps, WithChildren } from '../../models';
2
2
  import './Foldable.css';
3
- export interface FoldableProps {
3
+ export interface FoldableProps extends QAProps {
4
4
  isOpened: boolean;
5
5
  className?: string;
6
6
  }
7
- declare const Foldable: ({ isOpened, children, className }: WithChildren<FoldableProps>) => JSX.Element;
7
+ declare const Foldable: ({ isOpened, children, className, qa }: WithChildren<FoldableProps>) => JSX.Element;
8
8
  export default Foldable;
@@ -1,9 +1,10 @@
1
1
  import React, { useEffect, useRef } from 'react';
2
2
  import useHeightCalculator from '../../hooks/useHeightCalculator';
3
- import { block } from '../../utils';
3
+ import { block, getQaAttrubutes } from '../../utils';
4
4
  import './Foldable.css';
5
5
  const b = block('foldable-block');
6
- const Foldable = ({ isOpened, children, className }) => {
6
+ const Foldable = ({ isOpened, children, className, qa }) => {
7
+ const qaAttributes = getQaAttrubutes(qa);
7
8
  const blockRef = useRef(null);
8
9
  const contentRef = useRef(null);
9
10
  const contentHeight = useHeightCalculator(contentRef);
@@ -12,7 +13,7 @@ const Foldable = ({ isOpened, children, className }) => {
12
13
  blockRef.current.style.height = isOpened && contentHeight ? `${contentHeight}px` : '0';
13
14
  }
14
15
  }, [isOpened, contentHeight]);
15
- return (React.createElement("div", { ref: blockRef, className: b({ open: isOpened }, className) },
16
- React.createElement("div", { ref: contentRef, className: b('content-container') }, children)));
16
+ return (React.createElement("div", { ref: blockRef, className: b({ open: isOpened }, className), "data-qa": qaAttributes.default },
17
+ React.createElement("div", { ref: contentRef, className: b('content-container'), "data-qa": qaAttributes.container }, children)));
17
18
  };
18
19
  export default Foldable;
@@ -0,0 +1,14 @@
1
+ .pc-links {
2
+ display: flex;
3
+ flex-direction: column;
4
+ align-items: baseline;
5
+ }
6
+ .pc-links__link {
7
+ margin-top: 0px;
8
+ }
9
+ .pc-links_size_s {
10
+ gap: 8px;
11
+ }
12
+ .pc-links_size_l {
13
+ gap: 12px;
14
+ }
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { ContentSize, LinkProps } from '../../models';
3
+ import './Links.css';
4
+ type LinksProps = {
5
+ className?: string;
6
+ titleId?: string;
7
+ links?: LinkProps[];
8
+ size?: ContentSize;
9
+ qa?: string;
10
+ linkQa?: string;
11
+ };
12
+ declare const Links: React.FC<LinksProps>;
13
+ export default Links;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { block } from '../../utils';
3
+ import Link from '../Link/Link';
4
+ import './Links.css';
5
+ const b = block('links');
6
+ function getLinkSize(size) {
7
+ switch (size) {
8
+ case 's':
9
+ return 'm';
10
+ case 'l':
11
+ default:
12
+ return 'l';
13
+ }
14
+ }
15
+ const Links = ({ className, titleId, links, size = 's', qa, linkQa }) => links ? (React.createElement("div", { className: b({ size }, className), "data-qa": qa }, links === null || links === void 0 ? void 0 : links.map((link) => (React.createElement(Link, Object.assign({ className: b('link') }, link, { textSize: getLinkSize(size), key: link.url, qa: linkQa, extraProps: Object.assign({ 'aria-describedby': link.urlTitle ? undefined : titleId }, link.extraProps) })))))) : null;
16
+ export default Links;
@@ -6,6 +6,7 @@ export { default as BackLink } from './BackLink/BackLink';
6
6
  export { default as BalancedMasonry } from './BalancedMasonry/BalancedMasonry';
7
7
  export { default as BlockBase } from './BlockBase/BlockBase';
8
8
  export { default as Button } from './Button/Button';
9
+ export { default as Buttons } from './Buttons/Buttons';
9
10
  export { default as CardBase } from './CardBase/CardBase';
10
11
  export { default as ErrorWrapper } from './ErrorWrapper/ErrorWrapper';
11
12
  export { default as FileLink } from './FileLink/FileLink';
@@ -16,7 +17,7 @@ export { default as HeaderBreadcrumbs } from './HeaderBreadcrumbs/HeaderBreadcru
16
17
  export { default as Image } from './Image/Image';
17
18
  export { default as ImageBase } from './ImageBase/ImageBase';
18
19
  export { default as Link } from './Link/Link';
19
- export { default as Links } from './Link/Links';
20
+ export { default as Links } from './Links/Links';
20
21
  export { default as Media } from './Media/Media';
21
22
  export { default as OutsideClick } from './OutsideClick/OutsideClick';
22
23
  export { default as ReactPlayer } from './ReactPlayer/ReactPlayer';
@@ -6,6 +6,7 @@ export { default as BackLink } from './BackLink/BackLink';
6
6
  export { default as BalancedMasonry } from './BalancedMasonry/BalancedMasonry';
7
7
  export { default as BlockBase } from './BlockBase/BlockBase';
8
8
  export { default as Button } from './Button/Button';
9
+ export { default as Buttons } from './Buttons/Buttons';
9
10
  export { default as CardBase } from './CardBase/CardBase';
10
11
  export { default as ErrorWrapper } from './ErrorWrapper/ErrorWrapper';
11
12
  export { default as FileLink } from './FileLink/FileLink';
@@ -16,7 +17,7 @@ export { default as HeaderBreadcrumbs } from './HeaderBreadcrumbs/HeaderBreadcru
16
17
  export { default as Image } from './Image/Image';
17
18
  export { default as ImageBase } from './ImageBase/ImageBase';
18
19
  export { default as Link } from './Link/Link';
19
- export { default as Links } from './Link/Links';
20
+ export { default as Links } from './Links/Links';
20
21
  export { default as Media } from './Media/Media';
21
22
  export { default as OutsideClick } from './OutsideClick/OutsideClick';
22
23
  export { default as ReactPlayer } from './ReactPlayer/ReactPlayer';
@@ -24,7 +24,7 @@ export declare const subBlockMap: {
24
24
  "price-detailed": (props: import("./models").PriceDetailedProps) => JSX.Element;
25
25
  "media-card": ({ border, analyticsEvents, ...mediaProps }: import("./models").MediaCardProps) => JSX.Element;
26
26
  "banner-card": (props: import("./models").BannerCardProps) => JSX.Element;
27
- "layout-item": ({ content: { links, ...content }, metaInfo, media, border, fullscreen, icon, className, analyticsEvents, }: import("./models").LayoutItemProps) => JSX.Element;
27
+ "layout-item": ({ content: { links, buttons, ...content }, metaInfo, media, border, fullscreen, icon, className, analyticsEvents, controlPosition, }: import("./models").LayoutItemProps) => JSX.Element;
28
28
  "background-card": (props: import("./models").BackgroundCardProps) => JSX.Element;
29
29
  "basic-card": (props: import("./models").BasicCardProps) => JSX.Element;
30
30
  content: (props: import("./sub-blocks/Content/Content").ContentProps) => JSX.Element;
@@ -209,7 +209,7 @@ export interface TableBlockProps {
209
209
  title: string;
210
210
  table: TableProps;
211
211
  }
212
- export interface TabsBlockItem extends Omit<ContentBlockProps, 'size' | 'colSizes' | 'centered' | 'theme'> {
212
+ export interface TabsBlockItem extends Omit<ContentBlockProps, 'size' | 'colSizes' | 'centered' | 'theme'>, WithBorder {
213
213
  tabName: string;
214
214
  /**
215
215
  * @deprecated Use array links from ContentBlockProps instead
@@ -297,9 +297,13 @@ export interface TitleItemBaseProps {
297
297
  export type MediaView = 'fit' | 'full';
298
298
  export type MediaBorder = 'shadow' | 'line' | 'none';
299
299
  export type CardBorder = MediaBorder;
300
+ export type ControlPosition = 'content' | 'footer';
300
301
  export interface CardBaseProps {
301
302
  border?: CardBorder;
302
303
  }
304
+ export type CardLayoutProps = {
305
+ controlPosition?: ControlPosition;
306
+ };
303
307
  export interface PriceDescriptionProps {
304
308
  title: string;
305
309
  detailedTitle?: string;
@@ -3,7 +3,7 @@ import { ThemeSupporting } from '../../utils';
3
3
  import { HubspotEventData, HubspotEventHandlers } from '../../utils/hubspot';
4
4
  import { AnalyticsEventsBase, PixelEvent } from '../common';
5
5
  import { ContentBlockProps } from './blocks';
6
- import { AuthorItem, ButtonPixel, ButtonProps, CardBaseProps, ContentTheme, DividerSize, ImageCardMargins, ImageObjectProps, ImageProps, LinkProps, MediaProps, MediaView, PriceDetailedProps, TextTheme, Themable, ThemedImage } from './common';
6
+ import { AuthorItem, ButtonPixel, ButtonProps, CardBaseProps, CardLayoutProps, ContentTheme, DividerSize, ImageCardMargins, ImageObjectProps, ImageProps, LinkProps, MediaProps, MediaView, PriceDetailedProps, TextTheme, Themable, ThemedImage } from './common';
7
7
  export declare enum SubBlockType {
8
8
  Divider = "divider",
9
9
  Quote = "quote",
@@ -97,14 +97,14 @@ export interface QuoteProps extends Themable, CardBaseProps {
97
97
  quoteType?: QuoteType;
98
98
  button?: ButtonProps;
99
99
  }
100
- export interface BackgroundCardProps extends CardBaseProps, AnalyticsEventsBase, Omit<ContentBlockProps, 'colSizes' | 'centered'> {
100
+ export interface BackgroundCardProps extends CardBaseProps, AnalyticsEventsBase, CardLayoutProps, Omit<ContentBlockProps, 'colSizes' | 'centered'> {
101
101
  url?: string;
102
102
  urlTitle?: string;
103
103
  background?: ThemeSupporting<ImageObjectProps>;
104
104
  paddingBottom?: 's' | 'm' | 'l' | 'xl';
105
105
  backgroundColor?: string;
106
106
  }
107
- export interface BasicCardProps extends CardBaseProps, AnalyticsEventsBase, Omit<ContentBlockProps, 'colSizes' | 'centered' | 'size' | 'theme'> {
107
+ export interface BasicCardProps extends CardBaseProps, AnalyticsEventsBase, CardLayoutProps, Omit<ContentBlockProps, 'colSizes' | 'centered' | 'size' | 'theme'> {
108
108
  url: string;
109
109
  urlTitle?: string;
110
110
  icon?: ImageProps;
@@ -134,7 +134,7 @@ export interface PriceCardProps extends CardBaseProps, Pick<ContentBlockProps, '
134
134
  backgroundColor?: string;
135
135
  list?: string[];
136
136
  }
137
- export interface LayoutItemProps extends ClassNameProps, AnalyticsEventsBase {
137
+ export interface LayoutItemProps extends ClassNameProps, CardLayoutProps, AnalyticsEventsBase {
138
138
  content: Omit<ContentBlockProps, 'colSizes' | 'centered' | 'size'>;
139
139
  media?: MediaProps;
140
140
  metaInfo?: string[];
@@ -476,6 +476,10 @@ export declare const cardSchemas: {
476
476
  type: string;
477
477
  };
478
478
  };
479
+ controlPosition: {
480
+ type: string;
481
+ enum: string[];
482
+ };
479
483
  border: {
480
484
  type: string;
481
485
  enum: string[];
@@ -518,6 +522,10 @@ export declare const cardSchemas: {
518
522
  type: string;
519
523
  enum: string[];
520
524
  };
525
+ controlPosition: {
526
+ type: string;
527
+ enum: string[];
528
+ };
521
529
  title: {
522
530
  oneOf: ({
523
531
  type: string;
@@ -855,6 +863,10 @@ export declare const cardSchemas: {
855
863
  optionName: string;
856
864
  })[];
857
865
  };
866
+ controlPosition: {
867
+ type: string;
868
+ enum: string[];
869
+ };
858
870
  title: {
859
871
  oneOf: ({
860
872
  type: string;
@@ -1,18 +1,30 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
+ import { useUniqId } from '@gravity-ui/uikit';
2
3
  import { BackgroundImage, CardBase } from '../../components/';
3
4
  import { useTheme } from '../../context/theme';
4
5
  import { block, getThemedValue } from '../../utils';
6
+ import renderContentControls from '../../utils/renderContentControls/renderContentControls';
5
7
  import Content from '../Content/Content';
8
+ import renderCardFooterControlsContainer from '../renderCardFooterControlsContainer/renderCardFooterControlsContainer';
6
9
  import './BackgroundCard.css';
7
10
  const b = block('background-card');
8
11
  const BackgroundCard = (props) => {
9
- const { url, title, text, border, background, paddingBottom, backgroundColor, additionalInfo, theme: cardTheme = 'default', links, buttons, analyticsEvents, urlTitle, } = props;
12
+ const { url, title, text, border, background, paddingBottom, backgroundColor, additionalInfo, theme: cardTheme = 'default', links, buttons, analyticsEvents, urlTitle, controlPosition = 'content', } = props;
13
+ const titleId = useUniqId();
10
14
  const theme = useTheme();
11
15
  const hasBackgroundColor = backgroundColor || cardTheme !== 'default';
12
16
  const borderType = hasBackgroundColor ? 'none' : border;
17
+ const areControlsInFooter = !paddingBottom && controlPosition === 'footer';
18
+ const footerControls = useMemo(() => renderContentControls({
19
+ links: areControlsInFooter ? links : undefined,
20
+ buttons: areControlsInFooter ? buttons : undefined,
21
+ size: 's',
22
+ titleId,
23
+ }, renderCardFooterControlsContainer), [areControlsInFooter, links, buttons, titleId]);
13
24
  return (React.createElement(CardBase, { className: b({ padding: paddingBottom, theme: cardTheme }), url: url, border: borderType, analyticsEvents: analyticsEvents, urlTitle: urlTitle },
14
25
  React.createElement(CardBase.Content, null,
15
26
  React.createElement(BackgroundImage, Object.assign({ className: b('image') }, getThemedValue(background, theme), { style: { backgroundColor } })),
16
- React.createElement(Content, { title: title, text: text, additionalInfo: additionalInfo, size: "s", theme: cardTheme, links: links, buttons: buttons, colSizes: { all: 12, md: 12 } }))));
27
+ React.createElement(Content, { titleId: titleId, title: title, text: text, additionalInfo: additionalInfo, size: "s", theme: cardTheme, links: areControlsInFooter ? undefined : links, buttons: areControlsInFooter ? undefined : buttons, colSizes: { all: 12, md: 12 } })),
28
+ footerControls));
17
29
  };
18
30
  export default BackgroundCard;
@@ -144,6 +144,10 @@ export declare const BackgroundCard: {
144
144
  optionName: string;
145
145
  })[];
146
146
  };
147
+ controlPosition: {
148
+ type: string;
149
+ enum: string[];
150
+ };
147
151
  title: {
148
152
  oneOf: ({
149
153
  type: string;
@@ -26,6 +26,9 @@ export const BackgroundCard = {
26
26
  optionName: 'list',
27
27
  },
28
28
  ],
29
+ }, controlPosition: {
30
+ type: 'string',
31
+ enum: ['content', 'footer'],
29
32
  } }),
30
33
  },
31
34
  };