@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
@@ -144,6 +144,9 @@ export declare const ContentLayoutBlock: {
144
144
  resetPaddings: {
145
145
  type: string;
146
146
  };
147
+ context: {
148
+ type: string;
149
+ };
147
150
  type: {};
148
151
  when: {};
149
152
  };
@@ -124,6 +124,9 @@ export declare const ExtendedFeaturesBlock: {
124
124
  resetPaddings: {
125
125
  type: string;
126
126
  };
127
+ context: {
128
+ type: string;
129
+ };
127
130
  type: {};
128
131
  when: {};
129
132
  };
@@ -274,6 +274,84 @@ export declare const HeaderProperties: {
274
274
  type: string;
275
275
  contentType: string;
276
276
  };
277
+ analyticsEvents: {
278
+ anyOf: ({
279
+ type: string;
280
+ additionalProperties: {
281
+ type: string;
282
+ };
283
+ required: string[];
284
+ properties: {
285
+ name: {
286
+ type: string;
287
+ };
288
+ type: {
289
+ type: string;
290
+ };
291
+ counters: {
292
+ type: string;
293
+ additionalProperties: boolean;
294
+ required: never[];
295
+ properties: {
296
+ include: {
297
+ type: string;
298
+ items: {
299
+ type: string;
300
+ };
301
+ };
302
+ exclude: {
303
+ type: string;
304
+ items: {
305
+ type: string;
306
+ };
307
+ };
308
+ };
309
+ };
310
+ context: {
311
+ type: string;
312
+ };
313
+ };
314
+ } | {
315
+ type: string;
316
+ items: {
317
+ type: string;
318
+ additionalProperties: {
319
+ type: string;
320
+ };
321
+ required: string[];
322
+ properties: {
323
+ name: {
324
+ type: string;
325
+ };
326
+ type: {
327
+ type: string;
328
+ };
329
+ counters: {
330
+ type: string;
331
+ additionalProperties: boolean;
332
+ required: never[];
333
+ properties: {
334
+ include: {
335
+ type: string;
336
+ items: {
337
+ type: string;
338
+ };
339
+ };
340
+ exclude: {
341
+ type: string;
342
+ items: {
343
+ type: string;
344
+ };
345
+ };
346
+ };
347
+ };
348
+ context: {
349
+ type: string;
350
+ };
351
+ };
352
+ };
353
+ })[];
354
+ };
277
355
  };
278
356
  };
279
357
  imageSize: {
@@ -607,6 +685,84 @@ export declare const HeaderBlock: {
607
685
  type: string;
608
686
  contentType: string;
609
687
  };
688
+ analyticsEvents: {
689
+ anyOf: ({
690
+ type: string;
691
+ additionalProperties: {
692
+ type: string;
693
+ };
694
+ required: string[];
695
+ properties: {
696
+ name: {
697
+ type: string;
698
+ };
699
+ type: {
700
+ type: string;
701
+ };
702
+ counters: {
703
+ type: string;
704
+ additionalProperties: boolean;
705
+ required: never[];
706
+ properties: {
707
+ include: {
708
+ type: string;
709
+ items: {
710
+ type: string;
711
+ };
712
+ };
713
+ exclude: {
714
+ type: string;
715
+ items: {
716
+ type: string;
717
+ };
718
+ };
719
+ };
720
+ };
721
+ context: {
722
+ type: string;
723
+ };
724
+ };
725
+ } | {
726
+ type: string;
727
+ items: {
728
+ type: string;
729
+ additionalProperties: {
730
+ type: string;
731
+ };
732
+ required: string[];
733
+ properties: {
734
+ name: {
735
+ type: string;
736
+ };
737
+ type: {
738
+ type: string;
739
+ };
740
+ counters: {
741
+ type: string;
742
+ additionalProperties: boolean;
743
+ required: never[];
744
+ properties: {
745
+ include: {
746
+ type: string;
747
+ items: {
748
+ type: string;
749
+ };
750
+ };
751
+ exclude: {
752
+ type: string;
753
+ items: {
754
+ type: string;
755
+ };
756
+ };
757
+ };
758
+ };
759
+ context: {
760
+ type: string;
761
+ };
762
+ };
763
+ };
764
+ })[];
765
+ };
610
766
  };
611
767
  };
612
768
  imageSize: {
@@ -821,6 +977,9 @@ export declare const HeaderBlock: {
821
977
  resetPaddings: {
822
978
  type: string;
823
979
  };
980
+ context: {
981
+ type: string;
982
+ };
824
983
  type: {};
825
984
  when: {};
826
985
  };
@@ -1,6 +1,7 @@
1
1
  import { VideoProps, withTheme, BlockBaseProps, ButtonBlock, MediaProps, } from '../../schema/validators/common';
2
2
  import { filteredArray } from '../../schema/validators/utils';
3
3
  import { ImageProps } from '../../components/Image/schema';
4
+ import { AnalyticsEventSchema } from '../../schema/validators/event';
4
5
  export const HeaderBackgroundProps = {
5
6
  type: 'object',
6
7
  additionalProperties: false,
@@ -42,6 +43,9 @@ export const HeaderProperties = {
42
43
  type: 'string',
43
44
  contentType: 'text',
44
45
  },
46
+ analyticsEvents: {
47
+ anyOf: [AnalyticsEventSchema, { type: 'array', items: AnalyticsEventSchema }],
48
+ },
45
49
  },
46
50
  },
47
51
  imageSize: {
@@ -144,6 +144,84 @@ export declare const HeaderSliderBlock: {
144
144
  type: string;
145
145
  contentType: string;
146
146
  };
147
+ analyticsEvents: {
148
+ anyOf: ({
149
+ type: string;
150
+ additionalProperties: {
151
+ type: string;
152
+ };
153
+ required: string[];
154
+ properties: {
155
+ name: {
156
+ type: string;
157
+ };
158
+ type: {
159
+ type: string;
160
+ };
161
+ counters: {
162
+ type: string;
163
+ additionalProperties: boolean;
164
+ required: never[];
165
+ properties: {
166
+ include: {
167
+ type: string;
168
+ items: {
169
+ type: string;
170
+ };
171
+ };
172
+ exclude: {
173
+ type: string;
174
+ items: {
175
+ type: string;
176
+ };
177
+ };
178
+ };
179
+ };
180
+ context: {
181
+ type: string;
182
+ };
183
+ };
184
+ } | {
185
+ type: string;
186
+ items: {
187
+ type: string;
188
+ additionalProperties: {
189
+ type: string;
190
+ };
191
+ required: string[];
192
+ properties: {
193
+ name: {
194
+ type: string;
195
+ };
196
+ type: {
197
+ type: string;
198
+ };
199
+ counters: {
200
+ type: string;
201
+ additionalProperties: boolean;
202
+ required: never[];
203
+ properties: {
204
+ include: {
205
+ type: string;
206
+ items: {
207
+ type: string;
208
+ };
209
+ };
210
+ exclude: {
211
+ type: string;
212
+ items: {
213
+ type: string;
214
+ };
215
+ };
216
+ };
217
+ };
218
+ context: {
219
+ type: string;
220
+ };
221
+ };
222
+ };
223
+ })[];
224
+ };
147
225
  };
148
226
  };
149
227
  imageSize: {
@@ -433,6 +511,9 @@ export declare const HeaderSliderBlock: {
433
511
  resetPaddings: {
434
512
  type: string;
435
513
  };
514
+ context: {
515
+ type: string;
516
+ };
436
517
  type: {};
437
518
  when: {};
438
519
  };
@@ -54,6 +54,9 @@ export declare const IconsProps: {
54
54
  resetPaddings: {
55
55
  type: string;
56
56
  };
57
+ context: {
58
+ type: string;
59
+ };
57
60
  type: {};
58
61
  when: {};
59
62
  };
@@ -115,6 +118,9 @@ export declare const IconsBlock: {
115
118
  resetPaddings: {
116
119
  type: string;
117
120
  };
121
+ context: {
122
+ type: string;
123
+ };
118
124
  type: {};
119
125
  when: {};
120
126
  };
@@ -21,6 +21,9 @@ export declare const InfoBlock: {
21
21
  type: string;
22
22
  contentType: string;
23
23
  };
24
+ context: {
25
+ type: string;
26
+ };
24
27
  buttons: {
25
28
  type: string;
26
29
  items: {
@@ -18,6 +18,8 @@ export const InfoBlock = {
18
18
  }), sectionsTitle: {
19
19
  type: 'string',
20
20
  contentType: 'text',
21
+ }, context: {
22
+ type: 'string',
21
23
  }, buttons: filteredArray(ButtonBlock), theme: ThemeProps, links: filteredArray(LinkProps), leftContent: ContentProps, rightContent: ContentProps }),
22
24
  },
23
25
  };
@@ -67,6 +67,9 @@ export declare const LinkTableBlock: {
67
67
  resetPaddings: {
68
68
  type: string;
69
69
  };
70
+ context: {
71
+ type: string;
72
+ };
70
73
  type: {};
71
74
  when: {};
72
75
  };
@@ -459,6 +459,9 @@ export declare const MediaBlock: {
459
459
  };
460
460
  };
461
461
  };
462
+ context: {
463
+ type: string;
464
+ };
462
465
  };
463
466
  } | {
464
467
  type: string;
@@ -494,6 +497,9 @@ export declare const MediaBlock: {
494
497
  };
495
498
  };
496
499
  };
500
+ context: {
501
+ type: string;
502
+ };
497
503
  };
498
504
  };
499
505
  })[];
@@ -597,6 +603,9 @@ export declare const MediaBlock: {
597
603
  resetPaddings: {
598
604
  type: string;
599
605
  };
606
+ context: {
607
+ type: string;
608
+ };
600
609
  type: {};
601
610
  when: {};
602
611
  };
@@ -9,6 +9,7 @@ interface MediaContentProps extends Refable<HTMLDivElement> {
9
9
  switching: boolean;
10
10
  isActiveBlock: (id: number, isMediaBlock?: boolean) => boolean;
11
11
  showMediaContent: (id: number) => void;
12
+ context?: string;
12
13
  }
13
- declare const MediaContent: React.ForwardRefExoticComponent<Pick<MediaContentProps, "title" | "items" | "description" | "ratioMediaContent" | "switching" | "isActiveBlock" | "showMediaContent"> & React.RefAttributes<HTMLDivElement>>;
14
+ declare const MediaContent: React.ForwardRefExoticComponent<Pick<MediaContentProps, "title" | "context" | "items" | "description" | "ratioMediaContent" | "switching" | "isActiveBlock" | "showMediaContent"> & React.RefAttributes<HTMLDivElement>>;
14
15
  export default MediaContent;
@@ -30,6 +30,9 @@ export declare const PreviewBlock: {
30
30
  };
31
31
  };
32
32
  };
33
+ context: {
34
+ type: string;
35
+ };
33
36
  animated: {
34
37
  type: string;
35
38
  };
@@ -45,6 +45,8 @@ export const PreviewBlock = {
45
45
  }, ratioMediaContent: {
46
46
  type: 'string',
47
47
  enum: previewRatioMediaContent,
48
- }, items: filteredArray(PreviewItem) }),
48
+ }, items: filteredArray(PreviewItem), context: {
49
+ type: 'string',
50
+ } }),
49
51
  },
50
52
  };
@@ -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
  };
@@ -23,6 +23,8 @@ export const SecurityBlock = {
23
23
  },
24
24
  link: _.pick(LinkProps, ['text', 'url']),
25
25
  },
26
- }) }),
26
+ }), context: {
27
+ type: 'string',
28
+ } }),
27
29
  },
28
30
  };
@@ -1,8 +1,11 @@
1
- import React, { useContext } from 'react';
1
+ import React, { useContext, useCallback, useMemo } from 'react';
2
2
  import { Icon, Button } from '@gravity-ui/uikit';
3
3
  import { block, getAbsolutePath, getShareLink } from '../../utils';
4
+ import { PredefinedEventTypes } from '../../models';
4
5
  import { LocationContext } from '../../context/locationContext';
6
+ import { BlockPositionContext } from '../../context/blockPositionContext';
5
7
  import i18n from './i18n';
8
+ import { useAnalytics } from '../../hooks';
6
9
  import { Facebook } from '../../icons/Facebook';
7
10
  import { Twitter } from '../../icons/Twitter';
8
11
  import { Linkedin } from '../../icons/Linkedin';
@@ -19,13 +22,21 @@ const icons = {
19
22
  const b = block('share-block');
20
23
  const Share = ({ items, title }) => {
21
24
  const { pathname, hostname } = useContext(LocationContext);
25
+ const context = useContext(BlockPositionContext);
26
+ const defaultEvent = useMemo(() => ({
27
+ name: 'share-button-click',
28
+ type: PredefinedEventTypes.Default,
29
+ context,
30
+ }), [context]);
31
+ const handleAnalytics = useAnalytics(defaultEvent);
32
+ const handleButtonClick = useCallback(() => handleAnalytics(), [handleAnalytics]);
22
33
  return (React.createElement("div", { className: b() },
23
34
  React.createElement("h5", { className: b('title') }, title || i18n('constructor-share')),
24
35
  React.createElement("div", { className: b('items') }, items.map((type) => {
25
36
  const url = getAbsolutePath(hostname, pathname);
26
37
  const socialUrl = getShareLink(url, type);
27
38
  const icon = icons[type];
28
- return (React.createElement(Button, { key: type, view: "flat", size: "l", target: "_blank", href: socialUrl, className: b('item', { type: type.toLowerCase() }) }, icon && React.createElement(Icon, { data: icon, size: 24, className: b('icon', { type }) })));
39
+ return (React.createElement(Button, { key: type, view: "flat", size: "l", target: "_blank", href: socialUrl, className: b('item', { type: type.toLowerCase() }), onClick: handleButtonClick }, icon && React.createElement(Icon, { data: icon, size: 24, className: b('icon', { type }) })));
29
40
  }))));
30
41
  };
31
42
  export 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;
@@ -2,10 +2,20 @@ import React, { useCallback, useContext } from 'react';
2
2
  import { Button, Icon } from '@gravity-ui/uikit';
3
3
  import { ArrowSidebar } from '../../icons';
4
4
  import { LocationContext } from '../../context/locationContext';
5
+ import { useAnalytics } from '../../hooks';
6
+ import { PredefinedEventTypes } from '../../models';
7
+ const COMPONENT_NAME = 'backlink';
5
8
  export default function BackLink(props) {
6
9
  const { history } = useContext(LocationContext);
7
- const { url, title, theme = 'default', size = 'l', className, shouldHandleBackAction = false, onClick, } = props;
10
+ const { url, title, theme = 'default', size = 'l', className, shouldHandleBackAction = false, onClick, context = COMPONENT_NAME, } = props;
11
+ const handleAnalytics = useAnalytics({
12
+ name: 'back-link-click',
13
+ type: PredefinedEventTypes.Default,
14
+ context: context,
15
+ target: url,
16
+ });
8
17
  const backActionHandler = useCallback(async () => {
18
+ handleAnalytics();
9
19
  if (!history) {
10
20
  return;
11
21
  }
@@ -18,7 +28,7 @@ export default function BackLink(props) {
18
28
  else {
19
29
  history.push({ pathname: url });
20
30
  }
21
- }, [history, onClick, url]);
31
+ }, [handleAnalytics, history, onClick, url]);
22
32
  return (React.createElement(Button, { className: className, view: theme === 'special' ? 'flat-contrast' : 'flat-secondary', size: size, href: shouldHandleBackAction ? undefined : url, onClick: shouldHandleBackAction ? backActionHandler : undefined },
23
33
  React.createElement(Icon, { data: ArrowSidebar, size: 24 }),
24
34
  React.createElement("span", null, title)));
@@ -4,6 +4,7 @@ export interface ButtonProps extends Omit<ButtonParams, 'url'> {
4
4
  className?: string;
5
5
  url?: string;
6
6
  onClick?: () => void;
7
+ context?: string;
7
8
  }
8
9
  declare const Button: (props: ButtonProps) => JSX.Element;
9
10
  export default Button;
@@ -1,23 +1,36 @@
1
1
  import { __rest } from "tslib";
2
- import React, { useCallback, useContext } from 'react';
2
+ import React, { useCallback, useContext, useMemo } from 'react';
3
3
  import { Platform, Button as CommonButton, Icon, StoreBadge } from '@gravity-ui/uikit';
4
4
  import { block, setUrlTld } from '../../utils';
5
+ import { PredefinedEventTypes } from '../../models';
5
6
  import { toCommonSize, toCommonView } from './utils';
6
7
  import { LocaleContext } from '../../context/localeContext/localeContext';
7
8
  import { useMetrika } from '../../hooks/useMetrika';
8
9
  import { useAnalytics } from '../../hooks';
9
10
  import { Github } from '../../icons';
11
+ import { BlockPositionContext } from '../../context/blockPositionContext';
10
12
  import './Button.css';
13
+ const COMPONENT_NAME = 'button';
11
14
  const b = block('button-block');
12
15
  const Button = (props) => {
13
16
  const handleMetrika = useMetrika();
14
- const handleAnalytics = useAnalytics();
15
17
  const { lang, tld } = useContext(LocaleContext);
16
18
  const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text } = props, rest = __rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text"]);
19
+ const context = useContext(BlockPositionContext);
17
20
  const defaultImgPosition = 'left';
21
+ const defaultEvent = useMemo(() => ({
22
+ name: 'button-click',
23
+ type: PredefinedEventTypes.Default,
24
+ context: context || COMPONENT_NAME,
25
+ target: url,
26
+ }), [context, url]);
27
+ const handleAnalytics = useAnalytics(defaultEvent);
28
+ const blockPosition = useContext(BlockPositionContext);
29
+ // eslint-disable-next-line no-console
30
+ console.log({ blockPosition }, props);
18
31
  const onClick = useCallback(() => {
19
32
  handleMetrika({ metrikaGoals, pixelEvents });
20
- handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
33
+ handleAnalytics(analyticsEvents);
21
34
  if (onClickOrigin) {
22
35
  onClickOrigin();
23
36
  }
@@ -9,6 +9,7 @@ export interface ButtonTabsProps {
9
9
  items: ButtonTabsItemProps[];
10
10
  activeTab?: string;
11
11
  onSelectTab?: (tabId: string) => void;
12
+ context?: string;
12
13
  }
13
14
  declare const ButtonTabs: (props: ButtonTabsProps) => JSX.Element;
14
15
  export default ButtonTabs;
@@ -12,6 +12,7 @@ export interface CardBaseProps extends CardBaseParams {
12
12
  metrikaGoals?: MetrikaGoal;
13
13
  pixelEvents?: ButtonPixel;
14
14
  analyticsEvents?: AnalyticsEvent | AnalyticsEvent[];
15
+ context?: string;
15
16
  }
16
17
  export interface CardHeaderBaseProps {
17
18
  className?: string;