@gravity-ui/page-constructor 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +15 -0
  3. package/build/cjs/blocks/Header/schema.d.ts +234 -0
  4. package/build/cjs/blocks/HeaderSlider/schema.d.ts +78 -0
  5. package/build/cjs/blocks/Media/schema.d.ts +156 -0
  6. package/build/cjs/blocks/PromoFeaturesBlock/schema.d.ts +78 -0
  7. package/build/cjs/blocks/Slider/Slider.js +1 -1
  8. package/build/cjs/blocks/Tabs/schema.d.ts +78 -0
  9. package/build/cjs/components/Media/Media.js +1 -1
  10. package/build/cjs/components/VideoBlock/VideoBlock.d.ts +2 -1
  11. package/build/cjs/components/VideoBlock/VideoBlock.js +6 -2
  12. package/build/cjs/models/common.d.ts +2 -1
  13. package/build/cjs/models/common.js +1 -0
  14. package/build/cjs/schema/validators/common.d.ts +78 -0
  15. package/build/cjs/schema/validators/common.js +3 -0
  16. package/build/cjs/sub-blocks/LayoutItem/schema.d.ts +78 -0
  17. package/build/cjs/sub-blocks/MediaCard/schema.d.ts +78 -0
  18. package/build/esm/blocks/Header/schema.d.ts +234 -0
  19. package/build/esm/blocks/HeaderSlider/schema.d.ts +78 -0
  20. package/build/esm/blocks/Media/schema.d.ts +156 -0
  21. package/build/esm/blocks/PromoFeaturesBlock/schema.d.ts +78 -0
  22. package/build/esm/blocks/Slider/Slider.js +2 -2
  23. package/build/esm/blocks/Tabs/schema.d.ts +78 -0
  24. package/build/esm/components/Media/Media.js +1 -1
  25. package/build/esm/components/VideoBlock/VideoBlock.d.ts +2 -1
  26. package/build/esm/components/VideoBlock/VideoBlock.js +6 -2
  27. package/build/esm/models/common.d.ts +2 -1
  28. package/build/esm/models/common.js +1 -0
  29. package/build/esm/schema/validators/common.d.ts +78 -0
  30. package/build/esm/schema/validators/common.js +3 -0
  31. package/build/esm/sub-blocks/LayoutItem/schema.d.ts +78 -0
  32. package/build/esm/sub-blocks/MediaCard/schema.d.ts +78 -0
  33. package/package.json +1 -1
  34. package/server/models/common.d.ts +2 -1
  35. package/server/models/common.js +1 -0
@@ -145,6 +145,84 @@ export declare const tabsItem: {
145
145
  fullscreen: {
146
146
  type: string;
147
147
  };
148
+ analyticsEvents: {
149
+ anyOf: ({
150
+ type: string;
151
+ additionalProperties: {
152
+ type: string;
153
+ };
154
+ required: string[];
155
+ properties: {
156
+ name: {
157
+ type: string;
158
+ };
159
+ type: {
160
+ type: string;
161
+ };
162
+ counters: {
163
+ type: string;
164
+ additionalProperties: boolean;
165
+ required: never[];
166
+ properties: {
167
+ include: {
168
+ type: string;
169
+ items: {
170
+ type: string;
171
+ };
172
+ };
173
+ exclude: {
174
+ type: string;
175
+ items: {
176
+ type: string;
177
+ };
178
+ };
179
+ };
180
+ };
181
+ context: {
182
+ type: string;
183
+ };
184
+ };
185
+ } | {
186
+ type: string;
187
+ items: {
188
+ type: string;
189
+ additionalProperties: {
190
+ type: string;
191
+ };
192
+ required: string[];
193
+ properties: {
194
+ name: {
195
+ type: string;
196
+ };
197
+ type: {
198
+ type: string;
199
+ };
200
+ counters: {
201
+ type: string;
202
+ additionalProperties: boolean;
203
+ required: never[];
204
+ properties: {
205
+ include: {
206
+ type: string;
207
+ items: {
208
+ type: string;
209
+ };
210
+ };
211
+ exclude: {
212
+ type: string;
213
+ items: {
214
+ type: string;
215
+ };
216
+ };
217
+ };
218
+ };
219
+ context: {
220
+ type: string;
221
+ };
222
+ };
223
+ };
224
+ })[];
225
+ };
148
226
  };
149
227
  } | {
150
228
  type: string;
@@ -42,7 +42,7 @@ const Media = (props) => {
42
42
  }
43
43
  }
44
44
  if (youtube) {
45
- 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 }));
45
+ 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, analyticsEvents: analyticsEvents }));
46
46
  }
47
47
  if (dataLens) {
48
48
  result = react_1.default.createElement(DataLens_1.default, { dataLens: dataLens });
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
+ import { AnalyticsEventsBase } from '../../models/common';
2
3
  export declare const AUTOPLAY_ATTRIBUTES: {
3
4
  autoplay: number;
4
5
  mute: number;
5
6
  };
6
7
  export declare function getHeight(width: number): number;
7
- export interface VideoBlockProps {
8
+ export interface VideoBlockProps extends AnalyticsEventsBase {
8
9
  id?: string;
9
10
  stream?: string;
10
11
  record?: string;
@@ -6,7 +6,9 @@ const react_1 = tslib_1.__importStar(require("react"));
6
6
  const uikit_1 = require("@gravity-ui/uikit");
7
7
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
8
8
  const uuid_1 = require("uuid");
9
+ const useAnalytics_1 = require("../../hooks/useAnalytics");
9
10
  const icons_1 = require("../../icons");
11
+ const common_1 = require("../../models/common");
10
12
  const utils_1 = require("../../utils");
11
13
  const Image_1 = tslib_1.__importDefault(require("../Image/Image"));
12
14
  const i18n_1 = tslib_1.__importDefault(require("./i18n"));
@@ -39,7 +41,8 @@ function getHeight(width) {
39
41
  }
40
42
  exports.getHeight = getHeight;
41
43
  const VideoBlock = (props) => {
42
- const { stream, record, attributes, className, id, previewImg, playButton, height, fullscreen } = props;
44
+ const { stream, record, attributes, className, id, previewImg, playButton, height, fullscreen, analyticsEvents, } = props;
45
+ const handleAnalytics = (0, useAnalytics_1.useAnalytics)(common_1.DefaultEventNames.VideoPreview);
43
46
  const src = getVideoSrc(stream, record);
44
47
  const ref = (0, react_1.useRef)(null);
45
48
  const iframeRef = (0, react_1.useRef)();
@@ -48,11 +51,12 @@ const VideoBlock = (props) => {
48
51
  const [currentHeight, setCurrentHeight] = (0, react_1.useState)(height || undefined);
49
52
  const fullId = id || (0, uuid_1.v4)();
50
53
  const onPreviewClick = (0, react_1.useCallback)(() => {
54
+ handleAnalytics(analyticsEvents);
51
55
  if (iframeRef.current) {
52
56
  iframeRef.current.src = `${src}?${(0, utils_1.getPageSearchParams)(Object.assign(Object.assign({}, exports.AUTOPLAY_ATTRIBUTES), (attributes || {})))}`;
53
57
  }
54
58
  setTimeout(() => setHidePreview(true), AUTOPLAY_DELAY);
55
- }, [src, attributes]);
59
+ }, [handleAnalytics, analyticsEvents, src, attributes]);
56
60
  (0, react_1.useEffect)(() => {
57
61
  const updateSize = lodash_1.default.debounce(() => {
58
62
  setCurrentHeight(ref.current ? Math.round(getHeight(ref.current.offsetWidth)) : undefined);
@@ -79,7 +79,8 @@ export declare enum DefaultEventNames {
79
79
  HubspotFormSubmit = "hubspot-form-submit",
80
80
  QuoteButton = "quote-button-click",
81
81
  BackLink = "back-link-click",
82
- Breadcrumb = "breadcrumb-click"
82
+ Breadcrumb = "breadcrumb-click",
83
+ VideoPreview = "video-preview-click"
83
84
  }
84
85
  export type AnalyticsCounters = {
85
86
  include?: string[];
@@ -48,4 +48,5 @@ var DefaultEventNames;
48
48
  DefaultEventNames["QuoteButton"] = "quote-button-click";
49
49
  DefaultEventNames["BackLink"] = "back-link-click";
50
50
  DefaultEventNames["Breadcrumb"] = "breadcrumb-click";
51
+ DefaultEventNames["VideoPreview"] = "video-preview-click";
51
52
  })(DefaultEventNames = exports.DefaultEventNames || (exports.DefaultEventNames = {}));
@@ -1117,6 +1117,84 @@ export declare const MediaProps: {
1117
1117
  fullscreen: {
1118
1118
  type: string;
1119
1119
  };
1120
+ analyticsEvents: {
1121
+ anyOf: ({
1122
+ type: string;
1123
+ additionalProperties: {
1124
+ type: string;
1125
+ };
1126
+ required: string[];
1127
+ properties: {
1128
+ name: {
1129
+ type: string;
1130
+ };
1131
+ type: {
1132
+ type: string;
1133
+ };
1134
+ counters: {
1135
+ type: string;
1136
+ additionalProperties: boolean;
1137
+ required: never[];
1138
+ properties: {
1139
+ include: {
1140
+ type: string;
1141
+ items: {
1142
+ type: string;
1143
+ };
1144
+ };
1145
+ exclude: {
1146
+ type: string;
1147
+ items: {
1148
+ type: string;
1149
+ };
1150
+ };
1151
+ };
1152
+ };
1153
+ context: {
1154
+ type: string;
1155
+ };
1156
+ };
1157
+ } | {
1158
+ type: string;
1159
+ items: {
1160
+ type: string;
1161
+ additionalProperties: {
1162
+ type: string;
1163
+ };
1164
+ required: string[];
1165
+ properties: {
1166
+ name: {
1167
+ type: string;
1168
+ };
1169
+ type: {
1170
+ type: string;
1171
+ };
1172
+ counters: {
1173
+ type: string;
1174
+ additionalProperties: boolean;
1175
+ required: never[];
1176
+ properties: {
1177
+ include: {
1178
+ type: string;
1179
+ items: {
1180
+ type: string;
1181
+ };
1182
+ };
1183
+ exclude: {
1184
+ type: string;
1185
+ items: {
1186
+ type: string;
1187
+ };
1188
+ };
1189
+ };
1190
+ };
1191
+ context: {
1192
+ type: string;
1193
+ };
1194
+ };
1195
+ };
1196
+ })[];
1197
+ };
1120
1198
  };
1121
1199
  export declare const YMapMarkerLabel: {
1122
1200
  type: string;
@@ -460,6 +460,9 @@ exports.MediaProps = {
460
460
  fullscreen: {
461
461
  type: 'boolean',
462
462
  },
463
+ analyticsEvents: {
464
+ anyOf: [event_1.AnalyticsEventSchema, { type: 'array', items: event_1.AnalyticsEventSchema }],
465
+ },
463
466
  };
464
467
  exports.YMapMarkerLabel = {
465
468
  type: 'object',
@@ -135,6 +135,84 @@ export declare const LayoutItem: {
135
135
  fullscreen: {
136
136
  type: string;
137
137
  };
138
+ analyticsEvents: {
139
+ anyOf: ({
140
+ type: string;
141
+ additionalProperties: {
142
+ type: string;
143
+ };
144
+ required: string[];
145
+ properties: {
146
+ name: {
147
+ type: string;
148
+ };
149
+ type: {
150
+ type: string;
151
+ };
152
+ counters: {
153
+ type: string;
154
+ additionalProperties: boolean;
155
+ required: never[];
156
+ properties: {
157
+ include: {
158
+ type: string;
159
+ items: {
160
+ type: string;
161
+ };
162
+ };
163
+ exclude: {
164
+ type: string;
165
+ items: {
166
+ type: string;
167
+ };
168
+ };
169
+ };
170
+ };
171
+ context: {
172
+ type: string;
173
+ };
174
+ };
175
+ } | {
176
+ type: string;
177
+ items: {
178
+ type: string;
179
+ additionalProperties: {
180
+ type: string;
181
+ };
182
+ required: string[];
183
+ properties: {
184
+ name: {
185
+ type: string;
186
+ };
187
+ type: {
188
+ type: string;
189
+ };
190
+ counters: {
191
+ type: string;
192
+ additionalProperties: boolean;
193
+ required: never[];
194
+ properties: {
195
+ include: {
196
+ type: string;
197
+ items: {
198
+ type: string;
199
+ };
200
+ };
201
+ exclude: {
202
+ type: string;
203
+ items: {
204
+ type: string;
205
+ };
206
+ };
207
+ };
208
+ };
209
+ context: {
210
+ type: string;
211
+ };
212
+ };
213
+ };
214
+ })[];
215
+ };
138
216
  };
139
217
  content: Partial<{
140
218
  title: {
@@ -137,6 +137,84 @@ export declare const MediaCardBlock: {
137
137
  fullscreen: {
138
138
  type: string;
139
139
  };
140
+ analyticsEvents: {
141
+ anyOf: ({
142
+ type: string;
143
+ additionalProperties: {
144
+ type: string;
145
+ };
146
+ required: string[];
147
+ properties: {
148
+ name: {
149
+ type: string;
150
+ };
151
+ type: {
152
+ type: string;
153
+ };
154
+ counters: {
155
+ type: string;
156
+ additionalProperties: boolean;
157
+ required: never[];
158
+ properties: {
159
+ include: {
160
+ type: string;
161
+ items: {
162
+ type: string;
163
+ };
164
+ };
165
+ exclude: {
166
+ type: string;
167
+ items: {
168
+ type: string;
169
+ };
170
+ };
171
+ };
172
+ };
173
+ context: {
174
+ type: string;
175
+ };
176
+ };
177
+ } | {
178
+ type: string;
179
+ items: {
180
+ type: string;
181
+ additionalProperties: {
182
+ type: string;
183
+ };
184
+ required: string[];
185
+ properties: {
186
+ name: {
187
+ type: string;
188
+ };
189
+ type: {
190
+ type: string;
191
+ };
192
+ counters: {
193
+ type: string;
194
+ additionalProperties: boolean;
195
+ required: never[];
196
+ properties: {
197
+ include: {
198
+ type: string;
199
+ items: {
200
+ type: string;
201
+ };
202
+ };
203
+ exclude: {
204
+ type: string;
205
+ items: {
206
+ type: string;
207
+ };
208
+ };
209
+ };
210
+ };
211
+ context: {
212
+ type: string;
213
+ };
214
+ };
215
+ };
216
+ })[];
217
+ };
140
218
  border: {
141
219
  type: string;
142
220
  enum: string[];
@@ -140,6 +140,84 @@ export declare const HeaderBackgroundProps: {
140
140
  fullscreen: {
141
141
  type: string;
142
142
  };
143
+ analyticsEvents: {
144
+ anyOf: ({
145
+ type: string;
146
+ additionalProperties: {
147
+ type: string;
148
+ };
149
+ required: string[];
150
+ properties: {
151
+ name: {
152
+ type: string;
153
+ };
154
+ type: {
155
+ type: string;
156
+ };
157
+ counters: {
158
+ type: string;
159
+ additionalProperties: boolean;
160
+ required: never[];
161
+ properties: {
162
+ include: {
163
+ type: string;
164
+ items: {
165
+ type: string;
166
+ };
167
+ };
168
+ exclude: {
169
+ type: string;
170
+ items: {
171
+ type: string;
172
+ };
173
+ };
174
+ };
175
+ };
176
+ context: {
177
+ type: string;
178
+ };
179
+ };
180
+ } | {
181
+ type: string;
182
+ items: {
183
+ type: string;
184
+ additionalProperties: {
185
+ type: string;
186
+ };
187
+ required: string[];
188
+ properties: {
189
+ name: {
190
+ type: string;
191
+ };
192
+ type: {
193
+ type: string;
194
+ };
195
+ counters: {
196
+ type: string;
197
+ additionalProperties: boolean;
198
+ required: never[];
199
+ properties: {
200
+ include: {
201
+ type: string;
202
+ items: {
203
+ type: string;
204
+ };
205
+ };
206
+ exclude: {
207
+ type: string;
208
+ items: {
209
+ type: string;
210
+ };
211
+ };
212
+ };
213
+ };
214
+ context: {
215
+ type: string;
216
+ };
217
+ };
218
+ };
219
+ })[];
220
+ };
143
221
  };
144
222
  };
145
223
  export declare const HeaderProperties: {
@@ -430,6 +508,84 @@ export declare const HeaderProperties: {
430
508
  fullscreen: {
431
509
  type: string;
432
510
  };
511
+ analyticsEvents: {
512
+ anyOf: ({
513
+ type: string;
514
+ additionalProperties: {
515
+ type: string;
516
+ };
517
+ required: string[];
518
+ properties: {
519
+ name: {
520
+ type: string;
521
+ };
522
+ type: {
523
+ type: string;
524
+ };
525
+ counters: {
526
+ type: string;
527
+ additionalProperties: boolean;
528
+ required: never[];
529
+ properties: {
530
+ include: {
531
+ type: string;
532
+ items: {
533
+ type: string;
534
+ };
535
+ };
536
+ exclude: {
537
+ type: string;
538
+ items: {
539
+ type: string;
540
+ };
541
+ };
542
+ };
543
+ };
544
+ context: {
545
+ type: string;
546
+ };
547
+ };
548
+ } | {
549
+ type: string;
550
+ items: {
551
+ type: string;
552
+ additionalProperties: {
553
+ type: string;
554
+ };
555
+ required: string[];
556
+ properties: {
557
+ name: {
558
+ type: string;
559
+ };
560
+ type: {
561
+ type: string;
562
+ };
563
+ counters: {
564
+ type: string;
565
+ additionalProperties: boolean;
566
+ required: never[];
567
+ properties: {
568
+ include: {
569
+ type: string;
570
+ items: {
571
+ type: string;
572
+ };
573
+ };
574
+ exclude: {
575
+ type: string;
576
+ items: {
577
+ type: string;
578
+ };
579
+ };
580
+ };
581
+ };
582
+ context: {
583
+ type: string;
584
+ };
585
+ };
586
+ };
587
+ })[];
588
+ };
433
589
  };
434
590
  } | {
435
591
  type: string;
@@ -766,6 +922,84 @@ export declare const HeaderBlock: {
766
922
  fullscreen: {
767
923
  type: string;
768
924
  };
925
+ analyticsEvents: {
926
+ anyOf: ({
927
+ type: string;
928
+ additionalProperties: {
929
+ type: string;
930
+ };
931
+ required: string[];
932
+ properties: {
933
+ name: {
934
+ type: string;
935
+ };
936
+ type: {
937
+ type: string;
938
+ };
939
+ counters: {
940
+ type: string;
941
+ additionalProperties: boolean;
942
+ required: never[];
943
+ properties: {
944
+ include: {
945
+ type: string;
946
+ items: {
947
+ type: string;
948
+ };
949
+ };
950
+ exclude: {
951
+ type: string;
952
+ items: {
953
+ type: string;
954
+ };
955
+ };
956
+ };
957
+ };
958
+ context: {
959
+ type: string;
960
+ };
961
+ };
962
+ } | {
963
+ type: string;
964
+ items: {
965
+ type: string;
966
+ additionalProperties: {
967
+ type: string;
968
+ };
969
+ required: string[];
970
+ properties: {
971
+ name: {
972
+ type: string;
973
+ };
974
+ type: {
975
+ type: string;
976
+ };
977
+ counters: {
978
+ type: string;
979
+ additionalProperties: boolean;
980
+ required: never[];
981
+ properties: {
982
+ include: {
983
+ type: string;
984
+ items: {
985
+ type: string;
986
+ };
987
+ };
988
+ exclude: {
989
+ type: string;
990
+ items: {
991
+ type: string;
992
+ };
993
+ };
994
+ };
995
+ };
996
+ context: {
997
+ type: string;
998
+ };
999
+ };
1000
+ };
1001
+ })[];
1002
+ };
769
1003
  };
770
1004
  } | {
771
1005
  type: string;