@gravity-ui/page-constructor 1.15.0-alpha.2 → 1.15.0-alpha.21

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 (149) hide show
  1. package/README.md +110 -5
  2. package/build/cjs/blocks/Banner/schema.d.ts +27 -0
  3. package/build/cjs/blocks/Banner/schema.js +3 -1
  4. package/build/cjs/blocks/CardLayout/schema.d.ts +6 -0
  5. package/build/cjs/blocks/ContentLayout/schema.d.ts +3 -0
  6. package/build/cjs/blocks/ExtendedFeatures/schema.d.ts +3 -0
  7. package/build/cjs/blocks/Header/schema.d.ts +159 -0
  8. package/build/cjs/blocks/Header/schema.js +4 -0
  9. package/build/cjs/blocks/HeaderSlider/schema.d.ts +81 -0
  10. package/build/cjs/blocks/Icons/schema.d.ts +6 -0
  11. package/build/cjs/blocks/Info/schema.d.ts +3 -0
  12. package/build/cjs/blocks/Info/schema.js +2 -0
  13. package/build/cjs/blocks/LinkTable/schema.d.ts +3 -0
  14. package/build/cjs/blocks/Media/schema.d.ts +9 -0
  15. package/build/cjs/blocks/Preview/MediaContent/MediaContent.d.ts +2 -1
  16. package/build/cjs/blocks/Preview/schema.d.ts +3 -0
  17. package/build/cjs/blocks/Preview/schema.js +3 -1
  18. package/build/cjs/blocks/PromoFeaturesBlock/schema.d.ts +3 -0
  19. package/build/cjs/blocks/Questions/schema.d.ts +3 -0
  20. package/build/cjs/blocks/Security/schema.d.ts +3 -0
  21. package/build/cjs/blocks/Security/schema.js +3 -1
  22. package/build/cjs/blocks/Share/Share.js +12 -1
  23. package/build/cjs/blocks/Simple/schema.d.ts +3 -0
  24. package/build/cjs/blocks/Slider/schema.d.ts +3 -0
  25. package/build/cjs/blocks/Table/schema.d.ts +3 -0
  26. package/build/cjs/blocks/Tabs/schema.d.ts +3 -0
  27. package/build/cjs/components/BackLink/BackLink.d.ts +1 -0
  28. package/build/cjs/components/BackLink/BackLink.js +12 -2
  29. package/build/cjs/components/Button/Button.d.ts +1 -0
  30. package/build/cjs/components/Button/Button.js +15 -2
  31. package/build/cjs/components/ButtonTabs/ButtonTabs.d.ts +1 -0
  32. package/build/cjs/components/CardBase/CardBase.d.ts +1 -0
  33. package/build/cjs/components/CardBase/CardBase.js +11 -2
  34. package/build/cjs/components/HeaderBreadcrumbs/HeaderBreadcrumbs.css +0 -30
  35. package/build/cjs/components/HeaderBreadcrumbs/HeaderBreadcrumbs.js +3 -11
  36. package/build/cjs/components/HeaderBreadcrumbs/HeaderBreadcrumbsItem.css +30 -0
  37. package/build/cjs/components/HeaderBreadcrumbs/HeaderBreadcrumbsItem.d.ts +12 -0
  38. package/build/cjs/components/HeaderBreadcrumbs/HeaderBreadcrumbsItem.js +28 -0
  39. package/build/cjs/components/Link/Link.js +11 -2
  40. package/build/cjs/components/Media/Video/Video.js +1 -1
  41. package/build/cjs/components/ReactPlayer/ReactPlayer.js +21 -25
  42. package/build/cjs/components/YandexForm/YandexForm.d.ts +1 -0
  43. package/build/cjs/components/YandexForm/YandexForm.js +11 -3
  44. package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +5 -4
  45. package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts +2 -1
  46. package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.js +4 -2
  47. package/build/cjs/context/analyticsContext/analyticsContext.d.ts +2 -1
  48. package/build/cjs/context/blockPositionContext/blockPositionContext.d.ts +3 -0
  49. package/build/cjs/context/blockPositionContext/blockPositionContext.js +6 -0
  50. package/build/cjs/context/blockPositionContext/index.d.ts +1 -0
  51. package/build/cjs/context/blockPositionContext/index.js +4 -0
  52. package/build/cjs/hooks/useAnalytics.d.ts +1 -1
  53. package/build/cjs/hooks/useAnalytics.js +13 -7
  54. package/build/cjs/models/common.d.ts +7 -4
  55. package/build/cjs/models/common.js +7 -1
  56. package/build/cjs/models/constructor-items/blocks.d.ts +10 -0
  57. package/build/cjs/models/constructor-items/common.d.ts +9 -4
  58. package/build/cjs/models/constructor-items/sub-blocks.d.ts +4 -1
  59. package/build/cjs/navigation/components/NavigationItem/NavigationItem.js +3 -2
  60. package/build/cjs/schema/validators/common.d.ts +15 -0
  61. package/build/cjs/schema/validators/common.js +2 -0
  62. package/build/cjs/schema/validators/event.d.ts +3 -0
  63. package/build/cjs/schema/validators/event.js +3 -0
  64. package/build/cjs/sub-blocks/BackgroundCard/schema.d.ts +3 -0
  65. package/build/cjs/sub-blocks/BackgroundCard/schema.js +2 -0
  66. package/build/cjs/sub-blocks/HubspotForm/index.js +10 -2
  67. package/build/cjs/sub-blocks/Quote/Quote.js +12 -1
  68. package/build/cjs/sub-blocks/Quote/schema.d.ts +3 -0
  69. package/build/cjs/sub-blocks/Quote/schema.js +3 -1
  70. package/build/cjs/utils/blocks.d.ts +7 -0
  71. package/build/cjs/utils/blocks.js +5 -1
  72. package/build/esm/blocks/Banner/schema.d.ts +27 -0
  73. package/build/esm/blocks/Banner/schema.js +3 -1
  74. package/build/esm/blocks/CardLayout/schema.d.ts +6 -0
  75. package/build/esm/blocks/ContentLayout/schema.d.ts +3 -0
  76. package/build/esm/blocks/ExtendedFeatures/schema.d.ts +3 -0
  77. package/build/esm/blocks/Header/schema.d.ts +159 -0
  78. package/build/esm/blocks/Header/schema.js +4 -0
  79. package/build/esm/blocks/HeaderSlider/schema.d.ts +81 -0
  80. package/build/esm/blocks/Icons/schema.d.ts +6 -0
  81. package/build/esm/blocks/Info/schema.d.ts +3 -0
  82. package/build/esm/blocks/Info/schema.js +2 -0
  83. package/build/esm/blocks/LinkTable/schema.d.ts +3 -0
  84. package/build/esm/blocks/Media/schema.d.ts +9 -0
  85. package/build/esm/blocks/Preview/MediaContent/MediaContent.d.ts +2 -1
  86. package/build/esm/blocks/Preview/schema.d.ts +3 -0
  87. package/build/esm/blocks/Preview/schema.js +3 -1
  88. package/build/esm/blocks/PromoFeaturesBlock/schema.d.ts +3 -0
  89. package/build/esm/blocks/Questions/schema.d.ts +3 -0
  90. package/build/esm/blocks/Security/schema.d.ts +3 -0
  91. package/build/esm/blocks/Security/schema.js +3 -1
  92. package/build/esm/blocks/Share/Share.js +13 -2
  93. package/build/esm/blocks/Simple/schema.d.ts +3 -0
  94. package/build/esm/blocks/Slider/schema.d.ts +3 -0
  95. package/build/esm/blocks/Table/schema.d.ts +3 -0
  96. package/build/esm/blocks/Tabs/schema.d.ts +3 -0
  97. package/build/esm/components/BackLink/BackLink.d.ts +1 -0
  98. package/build/esm/components/BackLink/BackLink.js +12 -2
  99. package/build/esm/components/Button/Button.d.ts +1 -0
  100. package/build/esm/components/Button/Button.js +16 -3
  101. package/build/esm/components/ButtonTabs/ButtonTabs.d.ts +1 -0
  102. package/build/esm/components/CardBase/CardBase.d.ts +1 -0
  103. package/build/esm/components/CardBase/CardBase.js +12 -3
  104. package/build/esm/components/HeaderBreadcrumbs/HeaderBreadcrumbs.css +0 -30
  105. package/build/esm/components/HeaderBreadcrumbs/HeaderBreadcrumbs.js +3 -11
  106. package/build/esm/components/HeaderBreadcrumbs/HeaderBreadcrumbsItem.css +30 -0
  107. package/build/esm/components/HeaderBreadcrumbs/HeaderBreadcrumbsItem.d.ts +13 -0
  108. package/build/esm/components/HeaderBreadcrumbs/HeaderBreadcrumbsItem.js +25 -0
  109. package/build/esm/components/Link/Link.js +12 -3
  110. package/build/esm/components/Media/Video/Video.js +1 -1
  111. package/build/esm/components/ReactPlayer/ReactPlayer.js +22 -26
  112. package/build/esm/components/YandexForm/YandexForm.d.ts +1 -0
  113. package/build/esm/components/YandexForm/YandexForm.js +12 -4
  114. package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +6 -5
  115. package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts +2 -1
  116. package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.js +4 -2
  117. package/build/esm/context/analyticsContext/analyticsContext.d.ts +2 -1
  118. package/build/esm/context/blockPositionContext/blockPositionContext.d.ts +3 -0
  119. package/build/esm/context/blockPositionContext/blockPositionContext.js +2 -0
  120. package/build/esm/context/blockPositionContext/index.d.ts +1 -0
  121. package/build/esm/context/blockPositionContext/index.js +1 -0
  122. package/build/esm/hooks/useAnalytics.d.ts +1 -1
  123. package/build/esm/hooks/useAnalytics.js +13 -7
  124. package/build/esm/models/common.d.ts +7 -4
  125. package/build/esm/models/common.js +6 -0
  126. package/build/esm/models/constructor-items/blocks.d.ts +10 -0
  127. package/build/esm/models/constructor-items/common.d.ts +9 -4
  128. package/build/esm/models/constructor-items/sub-blocks.d.ts +4 -1
  129. package/build/esm/navigation/components/NavigationItem/NavigationItem.js +3 -2
  130. package/build/esm/schema/validators/common.d.ts +15 -0
  131. package/build/esm/schema/validators/common.js +2 -0
  132. package/build/esm/schema/validators/event.d.ts +3 -0
  133. package/build/esm/schema/validators/event.js +3 -0
  134. package/build/esm/sub-blocks/BackgroundCard/schema.d.ts +3 -0
  135. package/build/esm/sub-blocks/BackgroundCard/schema.js +2 -0
  136. package/build/esm/sub-blocks/HubspotForm/index.js +10 -2
  137. package/build/esm/sub-blocks/Quote/Quote.js +14 -3
  138. package/build/esm/sub-blocks/Quote/schema.d.ts +3 -0
  139. package/build/esm/sub-blocks/Quote/schema.js +3 -1
  140. package/build/esm/utils/blocks.d.ts +7 -0
  141. package/build/esm/utils/blocks.js +3 -0
  142. package/package.json +1 -1
  143. package/server/models/common.d.ts +7 -4
  144. package/server/models/common.js +7 -1
  145. package/server/models/constructor-items/blocks.d.ts +10 -0
  146. package/server/models/constructor-items/common.d.ts +9 -4
  147. package/server/models/constructor-items/sub-blocks.d.ts +4 -1
  148. package/server/utils/blocks.d.ts +7 -0
  149. package/server/utils/blocks.js +5 -1
@@ -222,6 +222,9 @@ export declare const PromoFeaturesBlock: {
222
222
  resetPaddings: {
223
223
  type: string;
224
224
  };
225
+ context: {
226
+ type: string;
227
+ };
225
228
  type: {};
226
229
  when: {};
227
230
  };
@@ -91,6 +91,9 @@ export declare const QuestionsBlock: {
91
91
  resetPaddings: {
92
92
  type: string;
93
93
  };
94
+ context: {
95
+ type: string;
96
+ };
94
97
  type: {};
95
98
  when: {};
96
99
  };
@@ -160,6 +160,9 @@ export declare const SecurityBlock: {
160
160
  };
161
161
  };
162
162
  };
163
+ context: {
164
+ type: string;
165
+ };
163
166
  animated: {
164
167
  type: string;
165
168
  };
@@ -27,6 +27,8 @@ exports.SecurityBlock = {
27
27
  },
28
28
  link: lodash_1.default.pick(common_1.LinkProps, ['text', 'url']),
29
29
  },
30
- }) }),
30
+ }), context: {
31
+ type: 'string',
32
+ } }),
31
33
  },
32
34
  };
@@ -4,8 +4,11 @@ const tslib_1 = require("tslib");
4
4
  const react_1 = 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");
7
8
  const locationContext_1 = require("../../context/locationContext");
9
+ const blockPositionContext_1 = require("../../context/blockPositionContext");
8
10
  const i18n_1 = tslib_1.__importDefault(require("./i18n"));
11
+ const hooks_1 = require("../../hooks");
9
12
  const Facebook_1 = require("../../icons/Facebook");
10
13
  const Twitter_1 = require("../../icons/Twitter");
11
14
  const Linkedin_1 = require("../../icons/Linkedin");
@@ -21,13 +24,21 @@ const icons = {
21
24
  const b = (0, utils_1.block)('share-block');
22
25
  const Share = ({ items, title }) => {
23
26
  const { pathname, hostname } = (0, react_1.useContext)(locationContext_1.LocationContext);
27
+ const context = (0, react_1.useContext)(blockPositionContext_1.BlockPositionContext);
28
+ const defaultEvent = (0, react_1.useMemo)(() => ({
29
+ name: 'share-button-click',
30
+ type: models_1.PredefinedEventTypes.Default,
31
+ context,
32
+ }), [context]);
33
+ const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
34
+ const handleButtonClick = (0, react_1.useCallback)(() => handleAnalytics(), [handleAnalytics]);
24
35
  return (react_1.default.createElement("div", { className: b() },
25
36
  react_1.default.createElement("h5", { className: b('title') }, title || (0, i18n_1.default)('constructor-share')),
26
37
  react_1.default.createElement("div", { className: b('items') }, items.map((type) => {
27
38
  const url = (0, utils_1.getAbsolutePath)(hostname, pathname);
28
39
  const socialUrl = (0, utils_1.getShareLink)(url, type);
29
40
  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 }) })));
41
+ return (react_1.default.createElement(uikit_1.Button, { key: type, view: "flat", size: "l", target: "_blank", href: socialUrl, className: b('item', { type: type.toLowerCase() }), onClick: handleButtonClick }, icon && react_1.default.createElement(uikit_1.Icon, { data: icon, size: 24, className: b('icon', { type }) })));
31
42
  }))));
32
43
  };
33
44
  exports.default = Share;
@@ -33,6 +33,9 @@ export declare const SimpleBlock: {
33
33
  resetPaddings: {
34
34
  type: string;
35
35
  };
36
+ context: {
37
+ type: string;
38
+ };
36
39
  type: {};
37
40
  when: {};
38
41
  title: {
@@ -211,6 +211,9 @@ export declare const SliderBlock: {
211
211
  resetPaddings: {
212
212
  type: string;
213
213
  };
214
+ context: {
215
+ type: string;
216
+ };
214
217
  type: {};
215
218
  when: {};
216
219
  };
@@ -64,6 +64,9 @@ export declare const TableBlock: {
64
64
  resetPaddings: {
65
65
  type: string;
66
66
  };
67
+ context: {
68
+ type: string;
69
+ };
67
70
  type: {};
68
71
  when: {};
69
72
  };
@@ -341,6 +341,9 @@ export declare const TabsBlock: {
341
341
  resetPaddings: {
342
342
  type: string;
343
343
  };
344
+ context: {
345
+ type: string;
346
+ };
344
347
  type: {};
345
348
  when: {};
346
349
  };
@@ -9,5 +9,6 @@ export interface BackLinkProps {
9
9
  className?: string;
10
10
  shouldHandleBackAction?: boolean;
11
11
  onClick?: () => void;
12
+ context?: string;
12
13
  }
13
14
  export default function BackLink(props: BackLinkProps): JSX.Element;
@@ -5,10 +5,20 @@ const react_1 = tslib_1.__importStar(require("react"));
5
5
  const uikit_1 = require("@gravity-ui/uikit");
6
6
  const icons_1 = require("../../icons");
7
7
  const locationContext_1 = require("../../context/locationContext");
8
+ const hooks_1 = require("../../hooks");
9
+ const models_1 = require("../../models");
10
+ const COMPONENT_NAME = 'backlink';
8
11
  function BackLink(props) {
9
12
  const { history } = (0, react_1.useContext)(locationContext_1.LocationContext);
10
- const { url, title, theme = 'default', size = 'l', className, shouldHandleBackAction = false, onClick, } = props;
13
+ const { url, title, theme = 'default', size = 'l', className, shouldHandleBackAction = false, onClick, context = COMPONENT_NAME, } = props;
14
+ const handleAnalytics = (0, hooks_1.useAnalytics)({
15
+ name: 'back-link-click',
16
+ type: models_1.PredefinedEventTypes.Default,
17
+ context: context,
18
+ target: url,
19
+ });
11
20
  const backActionHandler = (0, react_1.useCallback)(async () => {
21
+ handleAnalytics();
12
22
  if (!history) {
13
23
  return;
14
24
  }
@@ -21,7 +31,7 @@ function BackLink(props) {
21
31
  else {
22
32
  history.push({ pathname: url });
23
33
  }
24
- }, [history, onClick, url]);
34
+ }, [handleAnalytics, history, onClick, url]);
25
35
  return (react_1.default.createElement(uikit_1.Button, { className: className, view: theme === 'special' ? 'flat-contrast' : 'flat-secondary', size: size, href: shouldHandleBackAction ? undefined : url, onClick: shouldHandleBackAction ? backActionHandler : undefined },
26
36
  react_1.default.createElement(uikit_1.Icon, { data: icons_1.ArrowSidebar, size: 24 }),
27
37
  react_1.default.createElement("span", null, title)));
@@ -3,6 +3,7 @@ export interface ButtonProps extends Omit<ButtonParams, 'url'> {
3
3
  className?: string;
4
4
  url?: string;
5
5
  onClick?: () => void;
6
+ context?: string;
6
7
  }
7
8
  declare const Button: (props: ButtonProps) => JSX.Element;
8
9
  export default Button;
@@ -4,21 +4,34 @@ const tslib_1 = require("tslib");
4
4
  const react_1 = 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");
7
8
  const utils_2 = require("./utils");
8
9
  const localeContext_1 = require("../../context/localeContext/localeContext");
9
10
  const useMetrika_1 = require("../../hooks/useMetrika");
10
11
  const hooks_1 = require("../../hooks");
11
12
  const icons_1 = require("../../icons");
13
+ const blockPositionContext_1 = require("../../context/blockPositionContext");
14
+ const COMPONENT_NAME = 'button';
12
15
  const b = (0, utils_1.block)('button-block');
13
16
  const Button = (props) => {
14
17
  const handleMetrika = (0, useMetrika_1.useMetrika)();
15
- const handleAnalytics = (0, hooks_1.useAnalytics)();
16
18
  const { lang, tld } = (0, react_1.useContext)(localeContext_1.LocaleContext);
17
19
  const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text } = props, rest = tslib_1.__rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text"]);
20
+ const context = (0, react_1.useContext)(blockPositionContext_1.BlockPositionContext);
18
21
  const defaultImgPosition = 'left';
22
+ const defaultEvent = (0, react_1.useMemo)(() => ({
23
+ name: 'button-click',
24
+ type: models_1.PredefinedEventTypes.Default,
25
+ context: context || COMPONENT_NAME,
26
+ target: url,
27
+ }), [context, url]);
28
+ const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
29
+ const blockPosition = (0, react_1.useContext)(blockPositionContext_1.BlockPositionContext);
30
+ // eslint-disable-next-line no-console
31
+ console.log({ blockPosition }, props);
19
32
  const onClick = (0, react_1.useCallback)(() => {
20
33
  handleMetrika({ metrikaGoals, pixelEvents });
21
- handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
34
+ handleAnalytics(analyticsEvents);
22
35
  if (onClickOrigin) {
23
36
  onClickOrigin();
24
37
  }
@@ -8,6 +8,7 @@ export interface ButtonTabsProps {
8
8
  items: ButtonTabsItemProps[];
9
9
  activeTab?: string;
10
10
  onSelectTab?: (tabId: string) => void;
11
+ context?: string;
11
12
  }
12
13
  declare const ButtonTabs: (props: ButtonTabsProps) => JSX.Element;
13
14
  export default ButtonTabs;
@@ -11,6 +11,7 @@ export interface CardBaseProps extends CardBaseParams {
11
11
  metrikaGoals?: MetrikaGoal;
12
12
  pixelEvents?: ButtonPixel;
13
13
  analyticsEvents?: AnalyticsEvent | AnalyticsEvent[];
14
+ context?: string;
14
15
  }
15
16
  export interface CardHeaderBaseProps {
16
17
  className?: string;
@@ -4,9 +4,11 @@ exports.Layout = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importStar(require("react"));
6
6
  const utils_1 = require("../../utils");
7
+ const blockPositionContext_1 = require("../../context/blockPositionContext");
7
8
  const BackgroundImage_1 = tslib_1.__importDefault(require("../BackgroundImage/BackgroundImage"));
8
9
  const RouterLink_1 = tslib_1.__importDefault(require("../RouterLink/RouterLink"));
9
10
  const useMetrika_1 = require("../../hooks/useMetrika");
11
+ const common_1 = require("../../models/common");
10
12
  const hooks_1 = require("../../hooks");
11
13
  const b = (0, utils_1.block)('card-base-block');
12
14
  const Header = () => null;
@@ -15,7 +17,14 @@ const Footer = () => null;
15
17
  const Layout = (props) => {
16
18
  const { className, bodyClassName, metrikaGoals, pixelEvents, analyticsEvents, contentClassName, children, url, target, border = 'shadow', } = props;
17
19
  const handleMetrika = (0, useMetrika_1.useMetrika)();
18
- const handleAnalytics = (0, hooks_1.useAnalytics)();
20
+ const context = (0, react_1.useContext)(blockPositionContext_1.BlockPositionContext);
21
+ const defaultEvent = (0, react_1.useMemo)(() => ({
22
+ name: 'card-base-click',
23
+ type: common_1.PredefinedEventTypes.Default,
24
+ context,
25
+ target: url,
26
+ }), [context, url]);
27
+ const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
19
28
  let header, content, footer, image, headerClass, footerClass;
20
29
  function handleChild(child) {
21
30
  switch (child.type) {
@@ -48,7 +57,7 @@ const Layout = (props) => {
48
57
  const fullClassName = b({ border }, className);
49
58
  const onClick = () => {
50
59
  handleMetrika({ metrikaGoals, pixelEvents });
51
- handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
60
+ handleAnalytics(analyticsEvents);
52
61
  };
53
62
  return url ? (react_1.default.createElement(RouterLink_1.default, { href: url },
54
63
  react_1.default.createElement("a", { href: url, target: target, rel: target === '_blank' ? 'noopener noreferrer' : undefined, className: fullClassName, draggable: false, onDragStart: (e) => e.preventDefault(), onClick: onClick }, cardContent))) : (react_1.default.createElement("div", { className: fullClassName }, cardContent));
@@ -1,36 +1,6 @@
1
- @charset "UTF-8";
2
- /* use this for style redefinitions to awoid problems with
3
- unpredictable css rules order in build */
4
1
  .pc-header-breadcrumbs {
5
2
  z-index: 11;
6
3
  }
7
- .pc-header-breadcrumbs__item {
8
- display: inline-block;
9
- }
10
- .pc-header-breadcrumbs__text {
11
- font-size: var(--yc-text-body-2-font-size);
12
- line-height: var(--yc-text-body-2-line-height);
13
- outline: none;
14
- color: var(--yc-color-text-link);
15
- text-decoration: none;
16
- cursor: pointer;
17
- color: var(--yc-color-text-secondary);
18
- }
19
- .utilityfocus .pc-header-breadcrumbs__text:focus {
20
- outline: 2px solid #ffdb4d;
21
- }
22
- .pc-header-breadcrumbs__text:hover, .pc-header-breadcrumbs__text:active {
23
- --pc-text-header-color: var(--yc-color-text-link-hover);
24
- color: var(--yc-color-text-link-hover);
25
- }
26
- .pc-header-breadcrumbs__text:after {
27
- content: " / ";
28
- margin: 0 8px 0 6px;
29
- color: var(--yc-color-text-secondary);
30
- }
31
- .pc-header-breadcrumbs__text:hover {
32
- color: var(--yc-color-text-primary);
33
- }
34
4
  .pc-header-breadcrumbs_theme_dark .pc-header-breadcrumbs__text {
35
5
  color: var(--yc-color-text-light-secondary);
36
6
  }
@@ -3,18 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const react_1 = tslib_1.__importDefault(require("react"));
5
5
  const utils_1 = require("../../utils");
6
- const useMetrika_1 = require("../../hooks/useMetrika");
7
- const hooks_1 = require("../../hooks");
6
+ const HeaderBreadcrumbsItem_1 = tslib_1.__importDefault(require("./HeaderBreadcrumbsItem"));
8
7
  const b = (0, utils_1.block)('header-breadcrumbs');
9
8
  function HeaderBreadcrumbs(props) {
10
- const { items, metrikaGoals, pixelEvents, analyticsEvents, theme = 'light', className } = props;
11
- const handleMetrika = (0, useMetrika_1.useMetrika)();
12
- const handleAnalytics = (0, hooks_1.useAnalytics)();
13
- const onClick = () => {
14
- handleMetrika({ metrikaGoals, pixelEvents });
15
- handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
16
- };
17
- return (react_1.default.createElement("div", { className: b({ theme }, className) }, items.map((item) => (react_1.default.createElement("div", { className: b('item'), key: item.url },
18
- react_1.default.createElement("a", { href: item.url, className: b('text'), onClick: onClick }, item.text))))));
9
+ const { items, metrikaGoals, pixelEvents, theme = 'light', className } = props;
10
+ return (react_1.default.createElement("div", { className: b({ theme }, className) }, items.map((item) => (react_1.default.createElement(HeaderBreadcrumbsItem_1.default, { key: item.url, url: item.url, text: item.text, metrikaGoals: metrikaGoals, pixelEvents: pixelEvents, analyticsEvents: item.analyticsEvents })))));
19
11
  }
20
12
  exports.default = HeaderBreadcrumbs;
@@ -0,0 +1,30 @@
1
+ @charset "UTF-8";
2
+ /* use this for style redefinitions to awoid problems with
3
+ unpredictable css rules order in build */
4
+ .pc-header-breadcrumbs-item__item {
5
+ display: inline-block;
6
+ }
7
+ .pc-header-breadcrumbs-item__text {
8
+ font-size: var(--yc-text-body-2-font-size);
9
+ line-height: var(--yc-text-body-2-line-height);
10
+ outline: none;
11
+ color: var(--yc-color-text-link);
12
+ text-decoration: none;
13
+ cursor: pointer;
14
+ color: var(--yc-color-text-secondary);
15
+ }
16
+ .utilityfocus .pc-header-breadcrumbs-item__text:focus {
17
+ outline: 2px solid #ffdb4d;
18
+ }
19
+ .pc-header-breadcrumbs-item__text:hover, .pc-header-breadcrumbs-item__text:active {
20
+ --pc-text-header-color: var(--yc-color-text-link-hover);
21
+ color: var(--yc-color-text-link-hover);
22
+ }
23
+ .pc-header-breadcrumbs-item__text:after {
24
+ content: " / ";
25
+ margin: 0 8px 0 6px;
26
+ color: var(--yc-color-text-secondary);
27
+ }
28
+ .pc-header-breadcrumbs-item__text:hover {
29
+ color: var(--yc-color-text-primary);
30
+ }
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from 'react';
2
+ import { AnalyticsEvent, ButtonPixel, MetrikaGoal } from '../../models';
3
+ type HeaderBreadcrumbsItemProps = {
4
+ url: string;
5
+ text: ReactNode;
6
+ metrikaGoals?: MetrikaGoal;
7
+ pixelEvents?: ButtonPixel;
8
+ analyticsEvents?: AnalyticsEvent | AnalyticsEvent[];
9
+ context?: string;
10
+ };
11
+ export default function HeaderBreadcrumbsItem({ url, text, metrikaGoals, pixelEvents, analyticsEvents, }: HeaderBreadcrumbsItemProps): JSX.Element;
12
+ export {};
@@ -0,0 +1,28 @@
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 utils_1 = require("../../utils");
6
+ const models_1 = require("../../models");
7
+ const useMetrika_1 = require("../../hooks/useMetrika");
8
+ const hooks_1 = require("../../hooks");
9
+ const blockPositionContext_1 = require("../../context/blockPositionContext");
10
+ const b = (0, utils_1.block)('header-breadcrumbs-item');
11
+ function HeaderBreadcrumbsItem({ url, text, metrikaGoals, pixelEvents, analyticsEvents, }) {
12
+ const handleMetrika = (0, useMetrika_1.useMetrika)();
13
+ const context = (0, react_1.useContext)(blockPositionContext_1.BlockPositionContext);
14
+ const defaultEvent = (0, react_1.useMemo)(() => ({
15
+ name: 'header-breadcrumbs-click',
16
+ type: models_1.PredefinedEventTypes.Default,
17
+ context: context,
18
+ target: url,
19
+ }), [context, url]);
20
+ const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
21
+ const onClick = () => {
22
+ handleMetrika({ metrikaGoals, pixelEvents });
23
+ handleAnalytics(analyticsEvents);
24
+ };
25
+ return (react_1.default.createElement("div", { className: b('item'), key: url },
26
+ react_1.default.createElement("a", { href: url, className: b('text'), onClick: onClick }, text)));
27
+ }
28
+ exports.default = HeaderBreadcrumbsItem;
@@ -4,6 +4,7 @@ const tslib_1 = require("tslib");
4
4
  const react_1 = 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");
7
8
  const icons_1 = require("../../icons");
8
9
  const FileLink_1 = tslib_1.__importDefault(require("../FileLink/FileLink"));
9
10
  const BackLink_1 = tslib_1.__importDefault(require("../BackLink/BackLink"));
@@ -11,6 +12,7 @@ const localeContext_1 = require("../../context/localeContext/localeContext");
11
12
  const locationContext_1 = require("../../context/locationContext/locationContext");
12
13
  const useMetrika_1 = require("../../hooks/useMetrika");
13
14
  const hooks_1 = require("../../hooks");
15
+ const blockPositionContext_1 = require("../../context/blockPositionContext");
14
16
  const b = (0, utils_1.block)('link-block');
15
17
  const WORD_JOINER_SYM = '\u200b';
16
18
  function getArrowSize(size) {
@@ -28,14 +30,21 @@ function getArrowSize(size) {
28
30
  const LinkBlock = (props) => {
29
31
  const { text, url, arrow, metrikaGoals, pixelEvents, analyticsEvents, theme = 'file-link', colorTheme = 'light', textSize = 'm', className, target, children, } = props;
30
32
  const handleMetrika = (0, useMetrika_1.useMetrika)();
31
- const handleAnalytics = (0, hooks_1.useAnalytics)();
33
+ const context = (0, react_1.useContext)(blockPositionContext_1.BlockPositionContext);
34
+ const defaultEvent = (0, react_1.useMemo)(() => ({
35
+ name: 'link-click',
36
+ type: models_1.PredefinedEventTypes.Default,
37
+ context,
38
+ target: url,
39
+ }), [context, url]);
40
+ const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
32
41
  const { hostname } = (0, react_1.useContext)(locationContext_1.LocationContext);
33
42
  const { tld } = (0, react_1.useContext)(localeContext_1.LocaleContext);
34
43
  const href = (0, utils_1.setUrlTld)(props.url, tld);
35
44
  const defaultTextSize = theme === 'back' ? 'l' : 'm';
36
45
  const onClick = () => {
37
46
  handleMetrika({ metrikaGoals, pixelEvents });
38
- handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
47
+ handleAnalytics(analyticsEvents);
39
48
  };
40
49
  const getLinkByType = () => {
41
50
  switch (theme) {
@@ -34,6 +34,7 @@ const Video = (props) => {
34
34
  return (react_1.default.createElement(ReactPlayer_1.default, { className: b('react-player', videoClassName), src: src, previewImgUrl: previewImg, loop: Boolean(loop), controls: controls, muted: muted, autoplay: autoplay && playVideo, elapsedTime: elapsedTime, playButton: playButton || commonPlayButton, customBarControlsClassName: customBarControlsClassName, metrika: metrika, analyticsEvents: analyticsEvents, height: height }));
35
35
  }, [
36
36
  video,
37
+ height,
37
38
  videoClassName,
38
39
  previewImg,
39
40
  playVideo,
@@ -41,7 +42,6 @@ const Video = (props) => {
41
42
  customBarControlsClassName,
42
43
  metrika,
43
44
  analyticsEvents,
44
- height,
45
45
  ]);
46
46
  const defaultVideoBlock = (0, react_1.useMemo)(() => {
47
47
  return video.src.length && !hasVideoFallback ? (react_1.default.createElement("div", { className: b('wrap', videoClassName), style: { height } },
@@ -12,6 +12,7 @@ const CustomBarControls_1 = tslib_1.__importDefault(require("./CustomBarControls
12
12
  const videoContext_1 = require("../../context/videoContext");
13
13
  const metrikaContext_1 = require("../../context/metrikaContext");
14
14
  const mobileContext_1 = require("../../context/mobileContext");
15
+ const blockPositionContext_1 = require("../../context/blockPositionContext");
15
16
  const icons_1 = require("../../icons");
16
17
  const hooks_1 = require("../../hooks");
17
18
  const b = (0, utils_1.block)('ReactPlayer');
@@ -35,7 +36,19 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
35
36
  const [started, setStarted] = (0, react_1.useState)(autoPlay);
36
37
  const [paused, setPaused] = (0, react_1.useState)(false);
37
38
  const [ended, setEnded] = (0, react_1.useState)(false);
38
- const handleAnalytics = (0, hooks_1.useAnalytics)();
39
+ const eventsArray = (0, react_1.useMemo)(() => {
40
+ if (analyticsEvents) {
41
+ return Array.isArray(analyticsEvents) ? analyticsEvents : [analyticsEvents];
42
+ }
43
+ return [];
44
+ }, [analyticsEvents]);
45
+ const context = (0, react_1.useContext)(blockPositionContext_1.BlockPositionContext);
46
+ const defaultEvent = (0, react_1.useMemo)(() => ({
47
+ name: 'react-player-controls-click',
48
+ type: models_1.PredefinedEventTypes.Default,
49
+ context: context,
50
+ }), [context]);
51
+ const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
39
52
  (0, react_1.useImperativeHandle)(originRef, () => ({
40
53
  pause: () => setIsPlaying(false),
41
54
  }));
@@ -84,8 +97,8 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
84
97
  window.removeEventListener('resize', updateSize);
85
98
  };
86
99
  }, []);
87
- const playEvents = (0, react_1.useMemo)(() => analyticsEvents === null || analyticsEvents === void 0 ? void 0 : analyticsEvents.filter((e) => e.type === 'play'), [analyticsEvents]);
88
- const stopEvents = (0, react_1.useMemo)(() => analyticsEvents === null || analyticsEvents === void 0 ? void 0 : analyticsEvents.filter((e) => e.type === 'stop'), [analyticsEvents]);
100
+ const playEvents = (0, react_1.useMemo)(() => eventsArray === null || eventsArray === void 0 ? void 0 : eventsArray.filter((e) => e.type === models_1.PredefinedEventTypes.Play), [eventsArray]);
101
+ const stopEvents = (0, react_1.useMemo)(() => eventsArray === null || eventsArray === void 0 ? void 0 : eventsArray.filter((e) => e.type === models_1.PredefinedEventTypes.Stop), [eventsArray]);
89
102
  const playIcon = (0, react_1.useMemo)(() => {
90
103
  let playButtonContent;
91
104
  switch (type) {
@@ -111,27 +124,14 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
111
124
  metrika.reachGoals(goal, counterName);
112
125
  }
113
126
  }
114
- if (handleAnalytics && analyticsEvents) {
115
- const events = isMuted ? playEvents : stopEvents;
116
- if (events) {
117
- handleAnalytics(events);
118
- }
119
- }
127
+ const events = isMuted ? playEvents : stopEvents;
128
+ handleAnalytics(events);
120
129
  if (isMuted) {
121
130
  setProps({ playingVideoRef: ref.current });
122
131
  }
123
132
  // In order to the progress bar to update (equals 0) before displaying
124
133
  setTimeout(() => setMuted(!isMuted), 0);
125
- }, [
126
- playerRef,
127
- metrika,
128
- videoMetrika,
129
- handleAnalytics,
130
- analyticsEvents,
131
- playEvents,
132
- stopEvents,
133
- setProps,
134
- ]);
134
+ }, [playerRef, metrika, videoMetrika, handleAnalytics, playEvents, stopEvents, setProps]);
135
135
  const handleClick = (0, react_1.useCallback)(() => changeMute(muted), [changeMute, muted]);
136
136
  const handleClickPreview = (0, react_1.useCallback)(() => {
137
137
  setIsPlaying(true);
@@ -142,12 +142,8 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
142
142
  metrika.reachGoals(play, counterName);
143
143
  }
144
144
  }
145
- if (handleAnalytics && analyticsEvents) {
146
- if (playEvents) {
147
- handleAnalytics(playEvents);
148
- }
149
- }
150
- }, [onClickPreview, metrika, videoMetrika, handleAnalytics, analyticsEvents, playEvents]);
145
+ handleAnalytics(playEvents);
146
+ }, [onClickPreview, metrika, videoMetrika, handleAnalytics, playEvents]);
151
147
  const onPause = (0, react_1.useCallback)(() => {
152
148
  // For support correct state for youtube
153
149
  setIsPlaying(false);
@@ -16,6 +16,7 @@ export interface YandexFormProps {
16
16
  metrikaGoals?: string | string[];
17
17
  pixelEvents?: string | string[] | PixelEvent | PixelEvent[];
18
18
  analyticsEvents?: AnalyticsEvent | AnalyticsEvent[];
19
+ context?: string;
19
20
  }
20
21
  declare const YandexForm: (props: YandexFormProps) => JSX.Element;
21
22
  export default YandexForm;
@@ -8,7 +8,9 @@ const localeContext_1 = require("../../context/localeContext");
8
8
  const mobileContext_1 = require("../../context/mobileContext");
9
9
  const utils_1 = require("../../utils");
10
10
  const useMetrika_1 = require("../../hooks/useMetrika");
11
- const hooks_1 = require("../..//hooks");
11
+ const common_1 = require("../../models/common");
12
+ const hooks_1 = require("../../hooks");
13
+ const blockPositionContext_1 = require("../../context/blockPositionContext");
12
14
  exports.YANDEX_FORM_ORIGIN = 'https://forms.yandex.ru';
13
15
  const CONTAINER_ID = 'pc-yandex-form-container';
14
16
  const b = (0, utils_1.block)('yandex-form');
@@ -18,7 +20,13 @@ const YandexForm = (props) => {
18
20
  const iframeRef = (0, react_1.useRef)();
19
21
  const yaFormOrigin = customFormOrigin || exports.YANDEX_FORM_ORIGIN;
20
22
  const handleMetrika = (0, useMetrika_1.useMetrika)();
21
- const handleAnalytics = (0, hooks_1.useAnalytics)();
23
+ const context = (0, react_1.useContext)(blockPositionContext_1.BlockPositionContext);
24
+ const defaultEvent = (0, react_1.useMemo)(() => ({
25
+ name: 'yndex-form-submit',
26
+ type: common_1.PredefinedEventTypes.Default,
27
+ context: context,
28
+ }), [context]);
29
+ const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
22
30
  const isMobile = (0, react_1.useContext)(mobileContext_1.MobileContext);
23
31
  const locale = (0, react_1.useContext)(localeContext_1.LocaleContext);
24
32
  const updateFormIframe = (0, react_1.useCallback)((container) => {
@@ -59,7 +67,7 @@ const YandexForm = (props) => {
59
67
  window.scrollBy(0, top - headerHeight);
60
68
  }
61
69
  handleMetrika({ metrikaGoals, pixelEvents });
62
- handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
70
+ handleAnalytics(analyticsEvents);
63
71
  if (onSubmit) {
64
72
  onSubmit();
65
73
  }
@@ -11,13 +11,14 @@ const ConstructorItem_1 = require("../ConstructorItem");
11
11
  const ConstructorBlock_1 = require("../ConstructorBlock/ConstructorBlock");
12
12
  const ConstructorBlocks = ({ items, shouldRenderBlock }) => {
13
13
  const { blockTypes, loadables, itemMap } = (0, react_1.useContext)(innerContext_1.InnerContext);
14
- const renderer = (item, index) => {
14
+ const renderer = (parentContext = '', item, index) => {
15
15
  if (!itemMap[item.type]) {
16
16
  return null;
17
17
  }
18
18
  let children;
19
19
  let itemElement;
20
20
  const key = (0, utils_1.getBlockKey)(item, index);
21
+ const context = (0, utils_1.getBlockContext)({ parentContext, block: item, index });
21
22
  if (shouldRenderBlock && !shouldRenderBlock(item, key)) {
22
23
  return null;
23
24
  }
@@ -31,12 +32,12 @@ const ConstructorBlocks = ({ items, shouldRenderBlock }) => {
31
32
  }
32
33
  else {
33
34
  if ('children' in item && item.children) {
34
- children = item.children.map(renderer);
35
+ children = item.children.map(renderer.bind(null, context));
35
36
  }
36
- itemElement = (react_1.default.createElement(ConstructorItem_1.ConstructorItem, { data: item, key: key }, children));
37
+ itemElement = (react_1.default.createElement(ConstructorItem_1.ConstructorItem, { data: item, key: key, context: context }, children));
37
38
  }
38
39
  return blockTypes.includes(item.type) ? (react_1.default.createElement(ConstructorBlock_1.ConstructorBlock, { data: item, key: key, Component: itemElement })) : (itemElement);
39
40
  };
40
- return react_1.default.createElement(react_1.Fragment, null, items.map(renderer));
41
+ return react_1.default.createElement(react_1.Fragment, null, items.map(renderer.bind(null, '')));
41
42
  };
42
43
  exports.ConstructorBlocks = ConstructorBlocks;
@@ -1,6 +1,7 @@
1
1
  import { ConstructorItem as ConstructorItemType, WithChildren } from '../../../../models';
2
2
  export interface ConstructorItemProps {
3
3
  data: ConstructorItemType;
4
+ context?: string;
4
5
  }
5
- export declare const ConstructorItem: ({ data, children }: WithChildren<ConstructorItemProps>) => JSX.Element;
6
+ export declare const ConstructorItem: ({ data, children, context }: WithChildren<ConstructorItemProps>) => JSX.Element;
6
7
  export declare const ConstructorHeader: ({ data }: Pick<ConstructorItemProps, 'data'>) => JSX.Element;