@gravity-ui/page-constructor 1.19.1 → 1.20.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 (147) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +79 -6
  3. package/build/cjs/blocks/Banner/schema.d.ts +234 -0
  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 +81 -0
  7. package/build/cjs/blocks/Header/schema.d.ts +3 -0
  8. package/build/cjs/blocks/HeaderSlider/schema.d.ts +3 -0
  9. package/build/cjs/blocks/Icons/schema.d.ts +6 -0
  10. package/build/cjs/blocks/LinkTable/schema.d.ts +3 -0
  11. package/build/cjs/blocks/Map/schema.d.ts +81 -0
  12. package/build/cjs/blocks/Media/schema.d.ts +162 -0
  13. package/build/cjs/blocks/PromoFeaturesBlock/schema.d.ts +3 -0
  14. package/build/cjs/blocks/Questions/schema.d.ts +3 -0
  15. package/build/cjs/blocks/Share/Share.js +5 -1
  16. package/build/cjs/blocks/Simple/schema.d.ts +3 -0
  17. package/build/cjs/blocks/Slider/schema.d.ts +3 -0
  18. package/build/cjs/blocks/Table/schema.d.ts +3 -0
  19. package/build/cjs/blocks/Tabs/schema.d.ts +81 -0
  20. package/build/cjs/components/BackLink/BackLink.js +5 -1
  21. package/build/cjs/components/Button/Button.js +6 -2
  22. package/build/cjs/components/CardBase/CardBase.d.ts +2 -1
  23. package/build/cjs/components/CardBase/CardBase.js +5 -1
  24. package/build/cjs/components/Link/Link.js +5 -1
  25. package/build/cjs/components/Media/Media.js +3 -2
  26. package/build/cjs/components/Media/Video/Video.js +3 -2
  27. package/build/cjs/components/ReactPlayer/ReactPlayer.js +16 -3
  28. package/build/cjs/components/YandexForm/YandexForm.d.ts +2 -1
  29. package/build/cjs/components/YandexForm/YandexForm.js +14 -2
  30. package/build/cjs/containers/PageConstructor/Provider.d.ts +2 -0
  31. package/build/cjs/containers/PageConstructor/Provider.js +3 -1
  32. package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +7 -4
  33. package/build/cjs/context/analyticsContext/analyticsContext.d.ts +7 -0
  34. package/build/cjs/context/analyticsContext/analyticsContext.js +6 -0
  35. package/build/cjs/context/analyticsContext/index.d.ts +1 -0
  36. package/build/cjs/context/analyticsContext/index.js +4 -0
  37. package/build/cjs/context/blockIdContext/blockIdContext.d.ts +3 -0
  38. package/build/cjs/context/blockIdContext/blockIdContext.js +6 -0
  39. package/build/cjs/context/blockIdContext/index.d.ts +1 -0
  40. package/build/cjs/context/blockIdContext/index.js +4 -0
  41. package/build/cjs/context/metrikaContext/metrikaContext.d.ts +6 -0
  42. package/build/cjs/hooks/index.d.ts +1 -0
  43. package/build/cjs/hooks/index.js +1 -0
  44. package/build/cjs/hooks/useAnalytics.d.ts +2 -0
  45. package/build/cjs/hooks/useAnalytics.js +35 -0
  46. package/build/cjs/hooks/useMetrika.d.ts +6 -0
  47. package/build/cjs/hooks/useMetrika.js +8 -0
  48. package/build/cjs/models/common.d.ts +45 -0
  49. package/build/cjs/models/common.js +22 -1
  50. package/build/cjs/models/constructor-items/common.d.ts +5 -5
  51. package/build/cjs/models/constructor-items/sub-blocks.d.ts +2 -2
  52. package/build/cjs/models/navigation.d.ts +3 -9
  53. package/build/cjs/models/navigation.js +0 -1
  54. package/build/cjs/navigation/components/NavigationItem/NavigationItem.js +4 -3
  55. package/build/cjs/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.js +4 -2
  56. package/build/cjs/schema/validators/common.d.ts +249 -0
  57. package/build/cjs/schema/validators/common.js +14 -0
  58. package/build/cjs/schema/validators/event.d.ts +37 -0
  59. package/build/cjs/schema/validators/event.js +38 -0
  60. package/build/cjs/sub-blocks/HubspotForm/index.js +15 -2
  61. package/build/cjs/sub-blocks/LayoutItem/utils.d.ts +13 -0
  62. package/build/cjs/sub-blocks/Quote/Quote.js +4 -1
  63. package/build/cjs/utils/analytics.d.ts +2 -0
  64. package/build/cjs/utils/analytics.js +17 -0
  65. package/build/cjs/utils/index.d.ts +1 -0
  66. package/build/cjs/utils/index.js +1 -0
  67. package/build/esm/blocks/Banner/schema.d.ts +234 -0
  68. package/build/esm/blocks/CardLayout/schema.d.ts +6 -0
  69. package/build/esm/blocks/ContentLayout/schema.d.ts +3 -0
  70. package/build/esm/blocks/ExtendedFeatures/schema.d.ts +81 -0
  71. package/build/esm/blocks/Header/schema.d.ts +3 -0
  72. package/build/esm/blocks/HeaderSlider/schema.d.ts +3 -0
  73. package/build/esm/blocks/Icons/schema.d.ts +6 -0
  74. package/build/esm/blocks/LinkTable/schema.d.ts +3 -0
  75. package/build/esm/blocks/Map/schema.d.ts +81 -0
  76. package/build/esm/blocks/Media/schema.d.ts +162 -0
  77. package/build/esm/blocks/PromoFeaturesBlock/schema.d.ts +3 -0
  78. package/build/esm/blocks/Questions/schema.d.ts +3 -0
  79. package/build/esm/blocks/Share/Share.js +6 -2
  80. package/build/esm/blocks/Simple/schema.d.ts +3 -0
  81. package/build/esm/blocks/Slider/schema.d.ts +3 -0
  82. package/build/esm/blocks/Table/schema.d.ts +3 -0
  83. package/build/esm/blocks/Tabs/schema.d.ts +81 -0
  84. package/build/esm/components/BackLink/BackLink.js +5 -1
  85. package/build/esm/components/Button/Button.js +6 -2
  86. package/build/esm/components/CardBase/CardBase.d.ts +2 -1
  87. package/build/esm/components/CardBase/CardBase.js +5 -1
  88. package/build/esm/components/Link/Link.js +5 -1
  89. package/build/esm/components/Media/Media.js +3 -2
  90. package/build/esm/components/Media/Video/Video.js +3 -2
  91. package/build/esm/components/ReactPlayer/ReactPlayer.js +17 -4
  92. package/build/esm/components/YandexForm/YandexForm.d.ts +2 -1
  93. package/build/esm/components/YandexForm/YandexForm.js +14 -2
  94. package/build/esm/containers/PageConstructor/Provider.d.ts +2 -0
  95. package/build/esm/containers/PageConstructor/Provider.js +3 -1
  96. package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +7 -4
  97. package/build/esm/context/analyticsContext/analyticsContext.d.ts +7 -0
  98. package/build/esm/context/analyticsContext/analyticsContext.js +2 -0
  99. package/build/esm/context/analyticsContext/index.d.ts +1 -0
  100. package/build/esm/context/analyticsContext/index.js +1 -0
  101. package/build/esm/context/blockIdContext/blockIdContext.d.ts +3 -0
  102. package/build/esm/context/blockIdContext/blockIdContext.js +2 -0
  103. package/build/esm/context/blockIdContext/index.d.ts +1 -0
  104. package/build/esm/context/blockIdContext/index.js +1 -0
  105. package/build/esm/context/metrikaContext/metrikaContext.d.ts +6 -0
  106. package/build/esm/hooks/index.d.ts +1 -0
  107. package/build/esm/hooks/index.js +1 -0
  108. package/build/esm/hooks/useAnalytics.d.ts +2 -0
  109. package/build/esm/hooks/useAnalytics.js +31 -0
  110. package/build/esm/hooks/useMetrika.d.ts +6 -0
  111. package/build/esm/hooks/useMetrika.js +8 -0
  112. package/build/esm/models/common.d.ts +45 -0
  113. package/build/esm/models/common.js +21 -0
  114. package/build/esm/models/constructor-items/common.d.ts +5 -5
  115. package/build/esm/models/constructor-items/sub-blocks.d.ts +2 -2
  116. package/build/esm/models/navigation.d.ts +3 -9
  117. package/build/esm/models/navigation.js +0 -1
  118. package/build/esm/navigation/components/NavigationItem/NavigationItem.js +4 -3
  119. package/build/esm/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.js +4 -2
  120. package/build/esm/schema/validators/common.d.ts +249 -0
  121. package/build/esm/schema/validators/common.js +14 -0
  122. package/build/esm/schema/validators/event.d.ts +37 -0
  123. package/build/esm/schema/validators/event.js +35 -0
  124. package/build/esm/sub-blocks/HubspotForm/index.js +16 -3
  125. package/build/esm/sub-blocks/LayoutItem/utils.d.ts +13 -0
  126. package/build/esm/sub-blocks/Quote/Quote.js +6 -3
  127. package/build/esm/utils/analytics.d.ts +2 -0
  128. package/build/esm/utils/analytics.js +13 -0
  129. package/build/esm/utils/index.d.ts +1 -0
  130. package/build/esm/utils/index.js +1 -0
  131. package/package.json +1 -2
  132. package/server/models/common.d.ts +45 -0
  133. package/server/models/common.js +22 -1
  134. package/server/models/constructor-items/common.d.ts +5 -5
  135. package/server/models/constructor-items/sub-blocks.d.ts +2 -2
  136. package/server/models/navigation.d.ts +3 -9
  137. package/server/models/navigation.js +0 -1
  138. package/server/utils/analytics.d.ts +2 -0
  139. package/server/utils/analytics.js +17 -0
  140. package/server/utils/index.d.ts +1 -0
  141. package/server/utils/index.js +1 -0
  142. package/build/cjs/navigation/components/NavigationItem/components/GithubStars/GithubStars.css +0 -14
  143. package/build/cjs/navigation/components/NavigationItem/components/GithubStars/GithubStars.d.ts +0 -5
  144. package/build/cjs/navigation/components/NavigationItem/components/GithubStars/GithubStars.js +0 -11
  145. package/build/esm/navigation/components/NavigationItem/components/GithubStars/GithubStars.css +0 -14
  146. package/build/esm/navigation/components/NavigationItem/components/GithubStars/GithubStars.d.ts +0 -6
  147. package/build/esm/navigation/components/NavigationItem/components/GithubStars/GithubStars.js +0 -7
@@ -287,6 +287,84 @@ export declare const MediaBlockBaseProps: {
287
287
  };
288
288
  };
289
289
  };
290
+ analyticsEvents: {
291
+ anyOf: ({
292
+ type: string;
293
+ additionalProperties: {
294
+ type: string;
295
+ };
296
+ required: string[];
297
+ properties: {
298
+ name: {
299
+ type: string;
300
+ };
301
+ type: {
302
+ type: string;
303
+ };
304
+ counters: {
305
+ type: string;
306
+ additionalProperties: boolean;
307
+ required: never[];
308
+ properties: {
309
+ include: {
310
+ type: string;
311
+ items: {
312
+ type: string;
313
+ };
314
+ };
315
+ exclude: {
316
+ type: string;
317
+ items: {
318
+ type: string;
319
+ };
320
+ };
321
+ };
322
+ };
323
+ context: {
324
+ type: string;
325
+ };
326
+ };
327
+ } | {
328
+ type: string;
329
+ items: {
330
+ type: string;
331
+ additionalProperties: {
332
+ type: string;
333
+ };
334
+ required: string[];
335
+ properties: {
336
+ name: {
337
+ type: string;
338
+ };
339
+ type: {
340
+ type: string;
341
+ };
342
+ counters: {
343
+ type: string;
344
+ additionalProperties: boolean;
345
+ required: never[];
346
+ properties: {
347
+ include: {
348
+ type: string;
349
+ items: {
350
+ type: string;
351
+ };
352
+ };
353
+ exclude: {
354
+ type: string;
355
+ items: {
356
+ type: string;
357
+ };
358
+ };
359
+ };
360
+ };
361
+ context: {
362
+ type: string;
363
+ };
364
+ };
365
+ };
366
+ })[];
367
+ };
290
368
  target: {
291
369
  type: string;
292
370
  enum: string[];
@@ -386,6 +464,9 @@ export declare const MediaBlockBaseProps: {
386
464
  resetPaddings: {
387
465
  type: string;
388
466
  };
467
+ context: {
468
+ type: string;
469
+ };
389
470
  type: {};
390
471
  when: {};
391
472
  };
@@ -682,6 +763,84 @@ export declare const MediaBlock: {
682
763
  };
683
764
  };
684
765
  };
766
+ analyticsEvents: {
767
+ anyOf: ({
768
+ type: string;
769
+ additionalProperties: {
770
+ type: string;
771
+ };
772
+ required: string[];
773
+ properties: {
774
+ name: {
775
+ type: string;
776
+ };
777
+ type: {
778
+ type: string;
779
+ };
780
+ counters: {
781
+ type: string;
782
+ additionalProperties: boolean;
783
+ required: never[];
784
+ properties: {
785
+ include: {
786
+ type: string;
787
+ items: {
788
+ type: string;
789
+ };
790
+ };
791
+ exclude: {
792
+ type: string;
793
+ items: {
794
+ type: string;
795
+ };
796
+ };
797
+ };
798
+ };
799
+ context: {
800
+ type: string;
801
+ };
802
+ };
803
+ } | {
804
+ type: string;
805
+ items: {
806
+ type: string;
807
+ additionalProperties: {
808
+ type: string;
809
+ };
810
+ required: string[];
811
+ properties: {
812
+ name: {
813
+ type: string;
814
+ };
815
+ type: {
816
+ type: string;
817
+ };
818
+ counters: {
819
+ type: string;
820
+ additionalProperties: boolean;
821
+ required: never[];
822
+ properties: {
823
+ include: {
824
+ type: string;
825
+ items: {
826
+ type: string;
827
+ };
828
+ };
829
+ exclude: {
830
+ type: string;
831
+ items: {
832
+ type: string;
833
+ };
834
+ };
835
+ };
836
+ };
837
+ context: {
838
+ type: string;
839
+ };
840
+ };
841
+ };
842
+ })[];
843
+ };
685
844
  target: {
686
845
  type: string;
687
846
  enum: string[];
@@ -781,6 +940,9 @@ export declare const MediaBlock: {
781
940
  resetPaddings: {
782
941
  type: string;
783
942
  };
943
+ context: {
944
+ type: string;
945
+ };
784
946
  type: {};
785
947
  when: {};
786
948
  };
@@ -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
  };
@@ -4,8 +4,10 @@ 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");
8
9
  const i18n_1 = tslib_1.__importDefault(require("./i18n"));
10
+ const hooks_1 = require("../../hooks");
9
11
  const Facebook_1 = require("../../icons/Facebook");
10
12
  const Twitter_1 = require("../../icons/Twitter");
11
13
  const Linkedin_1 = require("../../icons/Linkedin");
@@ -21,13 +23,15 @@ const icons = {
21
23
  const b = (0, utils_1.block)('share-block');
22
24
  const Share = ({ items, title }) => {
23
25
  const { pathname, hostname } = (0, react_1.useContext)(locationContext_1.LocationContext);
26
+ const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.ShareButton);
27
+ const handleButtonClick = (0, react_1.useCallback)(() => handleAnalytics(), [handleAnalytics]);
24
28
  return (react_1.default.createElement("div", { className: b() },
25
29
  react_1.default.createElement("h5", { className: b('title') }, title || (0, i18n_1.default)('constructor-share')),
26
30
  react_1.default.createElement("div", { className: b('items') }, items.map((type) => {
27
31
  const url = (0, utils_1.getAbsolutePath)(hostname, pathname);
28
32
  const socialUrl = (0, utils_1.getShareLink)(url, type);
29
33
  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 }) })));
34
+ 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
35
  }))));
32
36
  };
33
37
  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
  };
@@ -177,6 +177,84 @@ export declare const tabsItem: {
177
177
  type: string;
178
178
  enum: string[];
179
179
  };
180
+ analyticsEvents: {
181
+ anyOf: ({
182
+ type: string;
183
+ additionalProperties: {
184
+ type: string;
185
+ };
186
+ required: string[];
187
+ properties: {
188
+ name: {
189
+ type: string;
190
+ };
191
+ type: {
192
+ type: string;
193
+ };
194
+ counters: {
195
+ type: string;
196
+ additionalProperties: boolean;
197
+ required: never[];
198
+ properties: {
199
+ include: {
200
+ type: string;
201
+ items: {
202
+ type: string;
203
+ };
204
+ };
205
+ exclude: {
206
+ type: string;
207
+ items: {
208
+ type: string;
209
+ };
210
+ };
211
+ };
212
+ };
213
+ context: {
214
+ type: string;
215
+ };
216
+ };
217
+ } | {
218
+ type: string;
219
+ items: {
220
+ type: string;
221
+ additionalProperties: {
222
+ type: string;
223
+ };
224
+ required: string[];
225
+ properties: {
226
+ name: {
227
+ type: string;
228
+ };
229
+ type: {
230
+ type: string;
231
+ };
232
+ counters: {
233
+ type: string;
234
+ additionalProperties: boolean;
235
+ required: never[];
236
+ properties: {
237
+ include: {
238
+ type: string;
239
+ items: {
240
+ type: string;
241
+ };
242
+ };
243
+ exclude: {
244
+ type: string;
245
+ items: {
246
+ type: string;
247
+ };
248
+ };
249
+ };
250
+ };
251
+ context: {
252
+ type: string;
253
+ };
254
+ };
255
+ };
256
+ })[];
257
+ };
180
258
  type: {};
181
259
  when: {};
182
260
  };
@@ -341,6 +419,9 @@ export declare const TabsBlock: {
341
419
  resetPaddings: {
342
420
  type: string;
343
421
  };
422
+ context: {
423
+ type: string;
424
+ };
344
425
  type: {};
345
426
  when: {};
346
427
  };
@@ -5,10 +5,14 @@ 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");
8
10
  function BackLink(props) {
9
11
  const { history } = (0, react_1.useContext)(locationContext_1.LocationContext);
10
12
  const { url, title, theme = 'default', size = 'l', className, shouldHandleBackAction = false, onClick, } = props;
13
+ const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.ShareButton, url);
11
14
  const backActionHandler = (0, react_1.useCallback)(async () => {
15
+ handleAnalytics();
12
16
  if (!history) {
13
17
  return;
14
18
  }
@@ -21,7 +25,7 @@ function BackLink(props) {
21
25
  else {
22
26
  history.push({ pathname: url });
23
27
  }
24
- }, [history, onClick, url]);
28
+ }, [handleAnalytics, history, onClick, url]);
25
29
  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
30
  react_1.default.createElement(uikit_1.Icon, { data: icons_1.ArrowSidebar, size: 24 }),
27
31
  react_1.default.createElement("span", null, title)));
@@ -4,22 +4,26 @@ 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");
11
+ const hooks_1 = require("../../hooks");
10
12
  const icons_1 = require("../../icons");
11
13
  const b = (0, utils_1.block)('button-block');
12
14
  const Button = (props) => {
13
15
  const handleMetrika = (0, useMetrika_1.useMetrika)();
14
16
  const { lang, tld } = (0, react_1.useContext)(localeContext_1.LocaleContext);
15
- const { className, metrikaGoals, pixelEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text } = props, rest = tslib_1.__rest(props, ["className", "metrikaGoals", "pixelEvents", "size", "theme", "url", "img", "onClick", "text"]);
17
+ 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"]);
16
18
  const defaultImgPosition = 'left';
19
+ const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.Button, url);
17
20
  const onClick = (0, react_1.useCallback)(() => {
18
21
  handleMetrika({ metrikaGoals, pixelEvents });
22
+ handleAnalytics(analyticsEvents);
19
23
  if (onClickOrigin) {
20
24
  onClickOrigin();
21
25
  }
22
- }, [handleMetrika, metrikaGoals, pixelEvents, onClickOrigin]);
26
+ }, [handleMetrika, metrikaGoals, pixelEvents, handleAnalytics, analyticsEvents, onClickOrigin]);
23
27
  const buttonImg = img instanceof Object
24
28
  ? { url: img.url, position: img.position || defaultImgPosition, alt: img.alt }
25
29
  : { url: img, position: defaultImgPosition };
@@ -1,6 +1,7 @@
1
1
  import React, { ReactElement, HTMLAttributeAnchorTarget } from 'react';
2
2
  import { ButtonPixel, CardBaseProps as CardBaseParams, ImageProps, MetrikaGoal, WithChildren } from '../../models';
3
- export interface CardBaseProps extends CardBaseParams {
3
+ import { AnalyticsEventsBase } from '../../models/common';
4
+ export interface CardBaseProps extends AnalyticsEventsBase, CardBaseParams {
4
5
  className?: string;
5
6
  bodyClassName?: string;
6
7
  contentClassName?: string;
@@ -7,13 +7,16 @@ const utils_1 = require("../../utils");
7
7
  const BackgroundImage_1 = tslib_1.__importDefault(require("../BackgroundImage/BackgroundImage"));
8
8
  const RouterLink_1 = tslib_1.__importDefault(require("../RouterLink/RouterLink"));
9
9
  const useMetrika_1 = require("../../hooks/useMetrika");
10
+ const common_1 = require("../../models/common");
11
+ const hooks_1 = require("../../hooks");
10
12
  const b = (0, utils_1.block)('card-base-block');
11
13
  const Header = () => null;
12
14
  const Content = () => null;
13
15
  const Footer = () => null;
14
16
  const Layout = (props) => {
15
- const { className, bodyClassName, metrikaGoals, pixelEvents, contentClassName, children, url, target, border = 'shadow', } = props;
17
+ const { className, bodyClassName, metrikaGoals, pixelEvents, analyticsEvents, contentClassName, children, url, target, border = 'shadow', } = props;
16
18
  const handleMetrika = (0, useMetrika_1.useMetrika)();
19
+ const handleAnalytics = (0, hooks_1.useAnalytics)(common_1.DefaultEventNames.CardBase, url);
17
20
  let header, content, footer, image, headerClass, footerClass;
18
21
  function handleChild(child) {
19
22
  switch (child.type) {
@@ -46,6 +49,7 @@ const Layout = (props) => {
46
49
  const fullClassName = b({ border }, className);
47
50
  const onClick = () => {
48
51
  handleMetrika({ metrikaGoals, pixelEvents });
52
+ handleAnalytics(analyticsEvents);
49
53
  };
50
54
  return url ? (react_1.default.createElement(RouterLink_1.default, { href: url },
51
55
  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));
@@ -4,12 +4,14 @@ 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"));
10
11
  const localeContext_1 = require("../../context/localeContext/localeContext");
11
12
  const locationContext_1 = require("../../context/locationContext/locationContext");
12
13
  const useMetrika_1 = require("../../hooks/useMetrika");
14
+ const hooks_1 = require("../../hooks");
13
15
  const b = (0, utils_1.block)('link-block');
14
16
  const WORD_JOINER_SYM = '\u200b';
15
17
  function getArrowSize(size) {
@@ -25,14 +27,16 @@ function getArrowSize(size) {
25
27
  }
26
28
  }
27
29
  const LinkBlock = (props) => {
28
- const { text, url, arrow, metrikaGoals, pixelEvents, theme = 'file-link', colorTheme = 'light', textSize = 'm', className, target, children, } = props;
30
+ const { text, url, arrow, metrikaGoals, pixelEvents, analyticsEvents, theme = 'file-link', colorTheme = 'light', textSize = 'm', className, target, children, } = props;
29
31
  const handleMetrika = (0, useMetrika_1.useMetrika)();
32
+ const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.Link, url);
30
33
  const { hostname } = (0, react_1.useContext)(locationContext_1.LocationContext);
31
34
  const { tld } = (0, react_1.useContext)(localeContext_1.LocaleContext);
32
35
  const href = (0, utils_1.setUrlTld)(props.url, tld);
33
36
  const defaultTextSize = theme === 'back' ? 'l' : 'm';
34
37
  const onClick = () => {
35
38
  handleMetrika({ metrikaGoals, pixelEvents });
39
+ handleAnalytics(analyticsEvents);
36
40
  };
37
41
  const getLinkByType = () => {
38
42
  switch (theme) {
@@ -10,7 +10,7 @@ const Video_1 = tslib_1.__importDefault(require("./Video/Video"));
10
10
  const VideoBlock_1 = tslib_1.__importDefault(require("../VideoBlock/VideoBlock"));
11
11
  const b = (0, utils_1.block)('Media');
12
12
  const Media = (props) => {
13
- const { image, video, youtube, dataLens, color, height, previewImg, parallax = false, metrika, fullScreen, } = props;
13
+ const { image, video, youtube, dataLens, color, height, previewImg, parallax = false, metrika, fullScreen, analyticsEvents, } = props;
14
14
  const { className, imageClassName, videoClassName, youtubeClassName, playVideo = true, isBackground, playButton, customBarControlsClassName, } = props;
15
15
  const [hasVideoFallback, setHasVideoFallback] = (0, react_1.useState)(false);
16
16
  const content = (0, react_1.useMemo)(() => {
@@ -19,7 +19,7 @@ const Media = (props) => {
19
19
  result.push(react_1.default.createElement(Image_1.default, { key: "image", parallax: parallax, image: image, height: height, imageClassName: imageClassName, isBackground: isBackground, video: video, hasVideoFallback: hasVideoFallback }));
20
20
  }
21
21
  if (video) {
22
- result.push(react_1.default.createElement(Video_1.default, { key: "video", video: video, videoClassName: videoClassName, height: height, metrika: metrika, playVideo: playVideo, previewImg: previewImg, playButton: playButton, customBarControlsClassName: customBarControlsClassName, hasVideoFallback: hasVideoFallback, setHasVideoFallback: setHasVideoFallback }));
22
+ result.push(react_1.default.createElement(Video_1.default, { key: "video", video: video, videoClassName: videoClassName, height: height, metrika: metrika, analyticsEvents: analyticsEvents, playVideo: playVideo, previewImg: previewImg, playButton: playButton, customBarControlsClassName: customBarControlsClassName, hasVideoFallback: hasVideoFallback, setHasVideoFallback: setHasVideoFallback }));
23
23
  }
24
24
  if (youtube) {
25
25
  result = (react_1.default.createElement(VideoBlock_1.default, { className: b('youtube', youtubeClassName), record: youtube, attributes: { color: 'white', rel: '0' }, previewImg: previewImg, height: height, fullScreen: fullScreen }));
@@ -40,6 +40,7 @@ const Media = (props) => {
40
40
  hasVideoFallback,
41
41
  videoClassName,
42
42
  metrika,
43
+ analyticsEvents,
43
44
  playVideo,
44
45
  previewImg,
45
46
  playButton,
@@ -8,7 +8,7 @@ const utils_1 = require("./utils");
8
8
  const utils_2 = require("../../../utils");
9
9
  const b = (0, utils_2.block)('media-component-video');
10
10
  const Video = (props) => {
11
- const { video, height, metrika, previewImg, playButton: commonPlayButton, customBarControlsClassName, videoClassName, playVideo, setHasVideoFallback, hasVideoFallback, } = props;
11
+ const { video, height, metrika, analyticsEvents, previewImg, playButton: commonPlayButton, customBarControlsClassName, videoClassName, playVideo, setHasVideoFallback, hasVideoFallback, } = props;
12
12
  const ref = (0, react_1.useRef)(null);
13
13
  (0, react_1.useEffect)(() => {
14
14
  if (ref && ref.current) {
@@ -31,7 +31,7 @@ const Video = (props) => {
31
31
  }, [playVideo, video, setHasVideoFallback]);
32
32
  const reactPlayerBlock = (0, react_1.useMemo)(() => {
33
33
  const { src, loop, controls, muted, autoplay = true, elapsedTime, playButton } = video;
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, height: height }));
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
37
  height,
@@ -41,6 +41,7 @@ const Video = (props) => {
41
41
  commonPlayButton,
42
42
  customBarControlsClassName,
43
43
  metrika,
44
+ analyticsEvents,
44
45
  ]);
45
46
  const defaultVideoBlock = (0, react_1.useMemo)(() => {
46
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 hooks_1 = require("../../hooks");
15
16
  const icons_1 = require("../../icons");
16
17
  const b = (0, utils_1.block)('ReactPlayer');
17
18
  const FPS = 60;
@@ -19,7 +20,7 @@ const FPS = 60;
19
20
  exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
20
21
  const isMobile = (0, react_1.useContext)(mobileContext_1.MobileContext);
21
22
  const { metrika } = (0, react_1.useContext)(metrikaContext_1.MetrikaContext);
22
- const { src, previewImgUrl, loop = false, controls = models_1.MediaVideoControlsType.Default, muted: initiallyMuted = false, elapsedTime, playButton, className, customBarControlsClassName, showPreview, onClickPreview, metrika: videoMetrika, height, } = props;
23
+ const { src, previewImgUrl, loop = false, controls = models_1.MediaVideoControlsType.Default, muted: initiallyMuted = false, elapsedTime, playButton, className, customBarControlsClassName, showPreview, onClickPreview, metrika: videoMetrika, analyticsEvents, height, } = props;
23
24
  const { type = models_1.PlayButtonType.Default, theme = models_1.PlayButtonThemes.Blue, text, className: buttonClassName, } = playButton || {};
24
25
  const autoPlay = Boolean(!isMobile && !previewImgUrl && props.autoplay);
25
26
  const mute = initiallyMuted || autoPlay;
@@ -34,6 +35,13 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
34
35
  const [started, setStarted] = (0, react_1.useState)(autoPlay);
35
36
  const [paused, setPaused] = (0, react_1.useState)(false);
36
37
  const [ended, setEnded] = (0, react_1.useState)(false);
38
+ const eventsArray = (0, react_1.useMemo)(() => {
39
+ if (analyticsEvents) {
40
+ return Array.isArray(analyticsEvents) ? analyticsEvents : [analyticsEvents];
41
+ }
42
+ return [];
43
+ }, [analyticsEvents]);
44
+ const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.ReactPlayerControls);
37
45
  (0, react_1.useImperativeHandle)(originRef, () => ({
38
46
  pause: () => setIsPlaying(false),
39
47
  }));
@@ -82,6 +90,8 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
82
90
  window.removeEventListener('resize', updateSize);
83
91
  };
84
92
  }, []);
93
+ const playEvents = (0, react_1.useMemo)(() => eventsArray === null || eventsArray === void 0 ? void 0 : eventsArray.filter((e) => e.type === models_1.PredefinedEventTypes.Play), [eventsArray]);
94
+ const stopEvents = (0, react_1.useMemo)(() => eventsArray === null || eventsArray === void 0 ? void 0 : eventsArray.filter((e) => e.type === models_1.PredefinedEventTypes.Stop), [eventsArray]);
85
95
  const playIcon = (0, react_1.useMemo)(() => {
86
96
  let playButtonContent;
87
97
  switch (type) {
@@ -107,12 +117,14 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
107
117
  metrika.reachGoals(goal, counterName);
108
118
  }
109
119
  }
120
+ const events = isMuted ? playEvents : stopEvents;
121
+ handleAnalytics(events);
110
122
  if (isMuted) {
111
123
  setProps({ playingVideoRef: ref.current });
112
124
  }
113
125
  // In order to the progress bar to update (equals 0) before displaying
114
126
  setTimeout(() => setMuted(!isMuted), 0);
115
- }, [playerRef, setProps, videoMetrika, metrika]);
127
+ }, [playerRef, metrika, videoMetrika, handleAnalytics, playEvents, stopEvents, setProps]);
116
128
  const handleClick = (0, react_1.useCallback)(() => changeMute(muted), [changeMute, muted]);
117
129
  const handleClickPreview = (0, react_1.useCallback)(() => {
118
130
  setIsPlaying(true);
@@ -123,7 +135,8 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
123
135
  metrika.reachGoals(play, counterName);
124
136
  }
125
137
  }
126
- }, [onClickPreview, setIsPlaying, videoMetrika, metrika]);
138
+ handleAnalytics(playEvents);
139
+ }, [onClickPreview, metrika, videoMetrika, handleAnalytics, playEvents]);
127
140
  const onPause = (0, react_1.useCallback)(() => {
128
141
  // For support correct state for youtube
129
142
  setIsPlaying(false);
@@ -1,6 +1,7 @@
1
1
  import { PixelEvent } from '../../models';
2
+ import { AnalyticsEventsBase } from '../../models/common';
2
3
  export declare const YANDEX_FORM_ORIGIN = "https://forms.yandex.ru";
3
- export interface YandexFormProps {
4
+ export interface YandexFormProps extends AnalyticsEventsBase {
4
5
  id: number | string;
5
6
  containerId?: string;
6
7
  theme?: string;