@gravity-ui/page-constructor 2.23.0-alpha.0 → 2.23.0-alpha.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 (45) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/build/cjs/blocks/Header/Header.css +7 -6
  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/Security/schema.d.ts +78 -0
  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/models/navigation.d.ts +0 -1
  15. package/build/cjs/navigation/components/Header/Header.css +0 -2
  16. package/build/cjs/navigation/components/Header/Header.js +2 -16
  17. package/build/cjs/schema/validators/common.d.ts +78 -0
  18. package/build/cjs/schema/validators/common.js +3 -0
  19. package/build/cjs/sub-blocks/LayoutItem/schema.d.ts +78 -0
  20. package/build/cjs/sub-blocks/MediaCard/schema.d.ts +82 -0
  21. package/build/cjs/sub-blocks/MediaCard/schema.js +1 -1
  22. package/build/esm/blocks/Header/Header.css +7 -6
  23. package/build/esm/blocks/Header/schema.d.ts +234 -0
  24. package/build/esm/blocks/HeaderSlider/schema.d.ts +78 -0
  25. package/build/esm/blocks/Media/schema.d.ts +156 -0
  26. package/build/esm/blocks/PromoFeaturesBlock/schema.d.ts +78 -0
  27. package/build/esm/blocks/Security/schema.d.ts +78 -0
  28. package/build/esm/blocks/Tabs/schema.d.ts +78 -0
  29. package/build/esm/components/Media/Media.js +1 -1
  30. package/build/esm/components/VideoBlock/VideoBlock.d.ts +2 -1
  31. package/build/esm/components/VideoBlock/VideoBlock.js +6 -2
  32. package/build/esm/models/common.d.ts +2 -1
  33. package/build/esm/models/common.js +1 -0
  34. package/build/esm/models/navigation.d.ts +0 -1
  35. package/build/esm/navigation/components/Header/Header.css +0 -2
  36. package/build/esm/navigation/components/Header/Header.js +3 -17
  37. package/build/esm/schema/validators/common.d.ts +78 -0
  38. package/build/esm/schema/validators/common.js +3 -0
  39. package/build/esm/sub-blocks/LayoutItem/schema.d.ts +78 -0
  40. package/build/esm/sub-blocks/MediaCard/schema.d.ts +82 -0
  41. package/build/esm/sub-blocks/MediaCard/schema.js +2 -2
  42. package/package.json +1 -1
  43. package/server/models/common.d.ts +2 -1
  44. package/server/models/common.js +1 -0
  45. package/server/models/navigation.d.ts +0 -1
@@ -148,6 +148,84 @@ export declare const tabsItem: {
148
148
  fullscreen: {
149
149
  type: string;
150
150
  };
151
+ analyticsEvents: {
152
+ anyOf: ({
153
+ type: string;
154
+ additionalProperties: {
155
+ type: string;
156
+ };
157
+ required: string[];
158
+ properties: {
159
+ name: {
160
+ type: string;
161
+ };
162
+ type: {
163
+ type: string;
164
+ };
165
+ counters: {
166
+ type: string;
167
+ additionalProperties: boolean;
168
+ required: never[];
169
+ properties: {
170
+ include: {
171
+ type: string;
172
+ items: {
173
+ type: string;
174
+ };
175
+ };
176
+ exclude: {
177
+ type: string;
178
+ items: {
179
+ type: string;
180
+ };
181
+ };
182
+ };
183
+ };
184
+ context: {
185
+ type: string;
186
+ };
187
+ };
188
+ } | {
189
+ type: string;
190
+ items: {
191
+ type: string;
192
+ additionalProperties: {
193
+ type: string;
194
+ };
195
+ required: string[];
196
+ properties: {
197
+ name: {
198
+ type: string;
199
+ };
200
+ type: {
201
+ type: string;
202
+ };
203
+ counters: {
204
+ type: string;
205
+ additionalProperties: boolean;
206
+ required: never[];
207
+ properties: {
208
+ include: {
209
+ type: string;
210
+ items: {
211
+ type: string;
212
+ };
213
+ };
214
+ exclude: {
215
+ type: string;
216
+ items: {
217
+ type: string;
218
+ };
219
+ };
220
+ };
221
+ };
222
+ context: {
223
+ type: string;
224
+ };
225
+ };
226
+ };
227
+ })[];
228
+ };
151
229
  };
152
230
  } | {
153
231
  type: string;
@@ -41,7 +41,7 @@ export const Media = (props) => {
41
41
  }
42
42
  }
43
43
  if (youtube) {
44
- result = (React.createElement(YoutubeBlock, { className: b('youtube', youtubeClassName), record: youtube, attributes: { color: 'white', rel: '0' }, previewImg: previewImg, height: height, fullscreen: getFullscreen({ fullScreen, fullscreen }) }));
44
+ result = (React.createElement(YoutubeBlock, { className: b('youtube', youtubeClassName), record: youtube, attributes: { color: 'white', rel: '0' }, previewImg: previewImg, height: height, fullscreen: getFullscreen({ fullScreen, fullscreen }), analyticsEvents: analyticsEvents }));
45
45
  }
46
46
  if (dataLens) {
47
47
  result = React.createElement(DataLens, { dataLens: dataLens });
@@ -1,11 +1,12 @@
1
1
  import React from 'react';
2
+ import { AnalyticsEventsBase } from '../../models/common';
2
3
  import './VideoBlock.css';
3
4
  export declare const AUTOPLAY_ATTRIBUTES: {
4
5
  autoplay: number;
5
6
  mute: number;
6
7
  };
7
8
  export declare function getHeight(width: number): number;
8
- export interface VideoBlockProps {
9
+ export interface VideoBlockProps extends AnalyticsEventsBase {
9
10
  id?: string;
10
11
  stream?: string;
11
12
  record?: string;
@@ -2,7 +2,9 @@ import React, { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import { Icon } from '@gravity-ui/uikit';
3
3
  import _ from 'lodash';
4
4
  import { v4 as uuidv4 } from 'uuid';
5
+ import { useAnalytics } from '../../hooks/useAnalytics';
5
6
  import { PlayVideo } from '../../icons';
7
+ import { DefaultEventNames } from '../../models/common';
6
8
  import { block, getPageSearchParams } from '../../utils';
7
9
  import Image from '../Image/Image';
8
10
  import i18n from './i18n';
@@ -35,7 +37,8 @@ export function getHeight(width) {
35
37
  return (width / 16) * 9;
36
38
  }
37
39
  const VideoBlock = (props) => {
38
- const { stream, record, attributes, className, id, previewImg, playButton, height, fullScreen, fullscreen, } = props;
40
+ const { stream, record, attributes, className, id, previewImg, playButton, height, fullScreen, fullscreen, analyticsEvents, } = props;
41
+ const handleAnalytics = useAnalytics(DefaultEventNames.VideoPreview);
39
42
  const src = getVideoSrc(stream, record);
40
43
  const ref = useRef(null);
41
44
  const iframeRef = useRef();
@@ -44,11 +47,12 @@ const VideoBlock = (props) => {
44
47
  const [currentHeight, setCurrentHeight] = useState(height || undefined);
45
48
  const fullId = id || uuidv4();
46
49
  const onPreviewClick = useCallback(() => {
50
+ handleAnalytics(analyticsEvents);
47
51
  if (iframeRef.current) {
48
52
  iframeRef.current.src = `${src}?${getPageSearchParams(Object.assign(Object.assign({}, AUTOPLAY_ATTRIBUTES), (attributes || {})))}`;
49
53
  }
50
54
  setTimeout(() => setHidePreview(true), AUTOPLAY_DELAY);
51
- }, [src, attributes]);
55
+ }, [handleAnalytics, analyticsEvents, src, attributes]);
52
56
  useEffect(() => {
53
57
  const updateSize = _.debounce(() => {
54
58
  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[];
@@ -45,4 +45,5 @@ export var DefaultEventNames;
45
45
  DefaultEventNames["QuoteButton"] = "quote-button-click";
46
46
  DefaultEventNames["BackLink"] = "back-link-click";
47
47
  DefaultEventNames["Breadcrumb"] = "breadcrumb-click";
48
+ DefaultEventNames["VideoPreview"] = "video-preview-click";
48
49
  })(DefaultEventNames || (DefaultEventNames = {}));
@@ -63,7 +63,6 @@ export interface HeaderData {
63
63
  leftItems: NavigationItemModel[];
64
64
  rightItems?: NavigationItemModel[];
65
65
  iconSize?: number;
66
- withBorder?: boolean;
67
66
  }
68
67
  export interface FooterColumn {
69
68
  title: string;
@@ -9,8 +9,6 @@ unpredictable css rules order in build */
9
9
  align-items: center;
10
10
  height: var(--header-height);
11
11
  background-color: var(--yc-color-base-background);
12
- }
13
- .pc-header_with-border {
14
12
  box-shadow: inset 0 -1px 0 var(--yc-color-line-generic);
15
13
  }
16
14
  .pc-header__wrapper {
@@ -1,5 +1,4 @@
1
- import React, { useCallback, useEffect, useMemo, useState } from 'react';
2
- import _ from 'lodash';
1
+ import React, { useCallback, useMemo, useState } from 'react';
3
2
  import Control from '../../../components/Control/Control';
4
3
  import OutsideClick from '../../../components/OutsideClick/OutsideClick';
5
4
  import { Col, Grid, Row } from '../../../grid';
@@ -25,10 +24,9 @@ const MobileMenuButton = ({ isSidebarOpened, onSidebarOpenedChange, }) => {
25
24
  };
26
25
  const iconSizeKey = 'iconSize';
27
26
  export const Header = ({ data, logo }) => {
28
- const { leftItems, rightItems, iconSize = 20, withBorder = false } = data;
27
+ const { leftItems, rightItems, iconSize = 20 } = data;
29
28
  const [isSidebarOpened, setIsSidebarOpened] = useState(false);
30
29
  const [activeItemId, setactiveItemId] = useState(undefined);
31
- const [withHeaderBorder, setWithHeaderBorder] = useState(withBorder);
32
30
  const getNavigationItemWithIconSize = useCallback((item) => {
33
31
  if (!(iconSizeKey in item)) {
34
32
  return Object.assign(Object.assign({}, item), { iconSize });
@@ -49,19 +47,7 @@ export const Header = ({ data, logo }) => {
49
47
  const hideSidebar = useCallback(() => {
50
48
  setIsSidebarOpened(false);
51
49
  }, []);
52
- useEffect(() => {
53
- const handleScroll = () => {
54
- if (window.scrollY > 0 && !withBorder) {
55
- setWithHeaderBorder(true);
56
- }
57
- else if (window.scrollY === 0 && !withBorder) {
58
- setWithHeaderBorder(false);
59
- }
60
- };
61
- window.addEventListener('scroll', _.debounce(handleScroll, 5), { passive: true });
62
- return () => window.removeEventListener('scroll', _.debounce(handleScroll, 5));
63
- });
64
- return (React.createElement(Grid, { className: b({ 'with-border': withHeaderBorder }) },
50
+ return (React.createElement(Grid, { className: b() },
65
51
  React.createElement(Row, null,
66
52
  React.createElement(Col, null,
67
53
  React.createElement("header", { className: b('wrapper') },
@@ -1120,6 +1120,84 @@ export declare const MediaProps: {
1120
1120
  fullscreen: {
1121
1121
  type: string;
1122
1122
  };
1123
+ analyticsEvents: {
1124
+ anyOf: ({
1125
+ type: string;
1126
+ additionalProperties: {
1127
+ type: string;
1128
+ };
1129
+ required: string[];
1130
+ properties: {
1131
+ name: {
1132
+ type: string;
1133
+ };
1134
+ type: {
1135
+ type: string;
1136
+ };
1137
+ counters: {
1138
+ type: string;
1139
+ additionalProperties: boolean;
1140
+ required: never[];
1141
+ properties: {
1142
+ include: {
1143
+ type: string;
1144
+ items: {
1145
+ type: string;
1146
+ };
1147
+ };
1148
+ exclude: {
1149
+ type: string;
1150
+ items: {
1151
+ type: string;
1152
+ };
1153
+ };
1154
+ };
1155
+ };
1156
+ context: {
1157
+ type: string;
1158
+ };
1159
+ };
1160
+ } | {
1161
+ type: string;
1162
+ items: {
1163
+ type: string;
1164
+ additionalProperties: {
1165
+ type: string;
1166
+ };
1167
+ required: string[];
1168
+ properties: {
1169
+ name: {
1170
+ type: string;
1171
+ };
1172
+ type: {
1173
+ type: string;
1174
+ };
1175
+ counters: {
1176
+ type: string;
1177
+ additionalProperties: boolean;
1178
+ required: never[];
1179
+ properties: {
1180
+ include: {
1181
+ type: string;
1182
+ items: {
1183
+ type: string;
1184
+ };
1185
+ };
1186
+ exclude: {
1187
+ type: string;
1188
+ items: {
1189
+ type: string;
1190
+ };
1191
+ };
1192
+ };
1193
+ };
1194
+ context: {
1195
+ type: string;
1196
+ };
1197
+ };
1198
+ };
1199
+ })[];
1200
+ };
1123
1201
  };
1124
1202
  export declare const YMapMarkerLabel: {
1125
1203
  type: string;
@@ -459,6 +459,9 @@ export const MediaProps = {
459
459
  fullscreen: {
460
460
  type: 'boolean',
461
461
  },
462
+ analyticsEvents: {
463
+ anyOf: [AnalyticsEventSchema, { type: 'array', items: AnalyticsEventSchema }],
464
+ },
462
465
  };
463
466
  export const YMapMarkerLabel = {
464
467
  type: 'object',
@@ -138,6 +138,84 @@ export declare const LayoutItem: {
138
138
  fullscreen: {
139
139
  type: string;
140
140
  };
141
+ analyticsEvents: {
142
+ anyOf: ({
143
+ type: string;
144
+ additionalProperties: {
145
+ type: string;
146
+ };
147
+ required: string[];
148
+ properties: {
149
+ name: {
150
+ type: string;
151
+ };
152
+ type: {
153
+ type: string;
154
+ };
155
+ counters: {
156
+ type: string;
157
+ additionalProperties: boolean;
158
+ required: never[];
159
+ properties: {
160
+ include: {
161
+ type: string;
162
+ items: {
163
+ type: string;
164
+ };
165
+ };
166
+ exclude: {
167
+ type: string;
168
+ items: {
169
+ type: string;
170
+ };
171
+ };
172
+ };
173
+ };
174
+ context: {
175
+ type: string;
176
+ };
177
+ };
178
+ } | {
179
+ type: string;
180
+ items: {
181
+ type: string;
182
+ additionalProperties: {
183
+ type: string;
184
+ };
185
+ required: string[];
186
+ properties: {
187
+ name: {
188
+ type: string;
189
+ };
190
+ type: {
191
+ type: string;
192
+ };
193
+ counters: {
194
+ type: string;
195
+ additionalProperties: boolean;
196
+ required: never[];
197
+ properties: {
198
+ include: {
199
+ type: string;
200
+ items: {
201
+ type: string;
202
+ };
203
+ };
204
+ exclude: {
205
+ type: string;
206
+ items: {
207
+ type: string;
208
+ };
209
+ };
210
+ };
211
+ };
212
+ context: {
213
+ type: string;
214
+ };
215
+ };
216
+ };
217
+ })[];
218
+ };
141
219
  };
142
220
  content: Partial<{
143
221
  title: {
@@ -140,6 +140,88 @@ export declare const MediaCardBlock: {
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
+ };
221
+ border: {
222
+ type: string;
223
+ enum: string[];
224
+ };
143
225
  type: {};
144
226
  when: {};
145
227
  };
@@ -1,8 +1,8 @@
1
- import { AnimatableProps, BaseProps, MediaProps } from '../../schema/validators/common';
1
+ import { AnimatableProps, BaseProps, CardBase, MediaProps } from '../../schema/validators/common';
2
2
  export const MediaCardBlock = {
3
3
  'media-card': {
4
4
  additionalProperties: false,
5
5
  required: [],
6
- properties: Object.assign(Object.assign(Object.assign({}, BaseProps), MediaProps), AnimatableProps),
6
+ properties: Object.assign(Object.assign(Object.assign(Object.assign({}, BaseProps), CardBase), MediaProps), AnimatableProps),
7
7
  },
8
8
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "2.23.0-alpha.0",
3
+ "version": "2.23.0-alpha.1",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -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 = {}));
@@ -63,7 +63,6 @@ export interface HeaderData {
63
63
  leftItems: NavigationItemModel[];
64
64
  rightItems?: NavigationItemModel[];
65
65
  iconSize?: number;
66
- withBorder?: boolean;
67
66
  }
68
67
  export interface FooterColumn {
69
68
  title: string;