@gravity-ui/page-constructor 1.14.0 → 1.15.0-alpha.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 (73) hide show
  1. package/build/cjs/blocks/Banner/schema.d.ts +234 -0
  2. package/build/cjs/blocks/Media/schema.d.ts +78 -0
  3. package/build/cjs/components/Button/Button.js +5 -2
  4. package/build/cjs/components/CardBase/CardBase.d.ts +2 -0
  5. package/build/cjs/components/CardBase/CardBase.js +4 -1
  6. package/build/cjs/components/HeaderBreadcrumbs/HeaderBreadcrumbs.js +4 -1
  7. package/build/cjs/components/Link/Link.js +4 -1
  8. package/build/cjs/components/Media/Media.js +3 -2
  9. package/build/cjs/components/Media/Video/Video.js +4 -3
  10. package/build/cjs/components/ReactPlayer/ReactPlayer.js +27 -3
  11. package/build/cjs/components/YandexForm/YandexForm.d.ts +2 -0
  12. package/build/cjs/components/YandexForm/YandexForm.js +13 -2
  13. package/build/cjs/containers/PageConstructor/Provider.d.ts +2 -0
  14. package/build/cjs/containers/PageConstructor/Provider.js +3 -1
  15. package/build/cjs/context/analyticsContext/analyticsContext.d.ts +6 -0
  16. package/build/cjs/context/analyticsContext/analyticsContext.js +6 -0
  17. package/build/cjs/context/analyticsContext/index.d.ts +1 -0
  18. package/build/cjs/context/analyticsContext/index.js +4 -0
  19. package/build/cjs/context/metrikaContext/metrikaContext.d.ts +6 -0
  20. package/build/cjs/hooks/index.d.ts +1 -0
  21. package/build/cjs/hooks/index.js +1 -0
  22. package/build/cjs/hooks/useAnalytics.d.ts +2 -0
  23. package/build/cjs/hooks/useAnalytics.js +18 -0
  24. package/build/cjs/hooks/useMetrika.d.ts +6 -0
  25. package/build/cjs/hooks/useMetrika.js +8 -0
  26. package/build/cjs/models/common.d.ts +36 -0
  27. package/build/cjs/models/common.js +3 -0
  28. package/build/cjs/models/constructor-items/common.d.ts +6 -1
  29. package/build/cjs/models/constructor-items/sub-blocks.d.ts +2 -1
  30. package/build/cjs/schema/validators/common.d.ts +168 -0
  31. package/build/cjs/schema/validators/common.js +10 -0
  32. package/build/cjs/schema/validators/event.d.ts +91 -0
  33. package/build/cjs/schema/validators/event.js +90 -0
  34. package/build/cjs/sub-blocks/HubspotForm/index.js +13 -2
  35. package/build/esm/blocks/Banner/schema.d.ts +234 -0
  36. package/build/esm/blocks/Media/schema.d.ts +78 -0
  37. package/build/esm/components/Button/Button.js +5 -2
  38. package/build/esm/components/CardBase/CardBase.d.ts +2 -0
  39. package/build/esm/components/CardBase/CardBase.js +4 -1
  40. package/build/esm/components/HeaderBreadcrumbs/HeaderBreadcrumbs.js +4 -1
  41. package/build/esm/components/Link/Link.js +4 -1
  42. package/build/esm/components/Media/Media.js +3 -2
  43. package/build/esm/components/Media/Video/Video.js +4 -3
  44. package/build/esm/components/ReactPlayer/ReactPlayer.js +27 -3
  45. package/build/esm/components/YandexForm/YandexForm.d.ts +2 -0
  46. package/build/esm/components/YandexForm/YandexForm.js +13 -2
  47. package/build/esm/containers/PageConstructor/Provider.d.ts +2 -0
  48. package/build/esm/containers/PageConstructor/Provider.js +3 -1
  49. package/build/esm/context/analyticsContext/analyticsContext.d.ts +6 -0
  50. package/build/esm/context/analyticsContext/analyticsContext.js +2 -0
  51. package/build/esm/context/analyticsContext/index.d.ts +1 -0
  52. package/build/esm/context/analyticsContext/index.js +1 -0
  53. package/build/esm/context/metrikaContext/metrikaContext.d.ts +6 -0
  54. package/build/esm/hooks/index.d.ts +1 -0
  55. package/build/esm/hooks/index.js +1 -0
  56. package/build/esm/hooks/useAnalytics.d.ts +2 -0
  57. package/build/esm/hooks/useAnalytics.js +14 -0
  58. package/build/esm/hooks/useMetrika.d.ts +6 -0
  59. package/build/esm/hooks/useMetrika.js +8 -0
  60. package/build/esm/models/common.d.ts +36 -0
  61. package/build/esm/models/common.js +3 -0
  62. package/build/esm/models/constructor-items/common.d.ts +6 -1
  63. package/build/esm/models/constructor-items/sub-blocks.d.ts +2 -1
  64. package/build/esm/schema/validators/common.d.ts +168 -0
  65. package/build/esm/schema/validators/common.js +10 -0
  66. package/build/esm/schema/validators/event.d.ts +91 -0
  67. package/build/esm/schema/validators/event.js +87 -0
  68. package/build/esm/sub-blocks/HubspotForm/index.js +14 -3
  69. package/package.json +4 -1
  70. package/server/models/common.d.ts +36 -0
  71. package/server/models/common.js +3 -0
  72. package/server/models/constructor-items/common.d.ts +6 -1
  73. package/server/models/constructor-items/sub-blocks.d.ts +2 -1
@@ -0,0 +1,91 @@
1
+ export declare const AnalyticsEventSchema: {
2
+ type: string;
3
+ additionalProperties: boolean;
4
+ required: string[];
5
+ properties: {
6
+ name: {
7
+ type: string;
8
+ };
9
+ type: {
10
+ type: string;
11
+ };
12
+ counters: {
13
+ type: string;
14
+ additionalProperties: boolean;
15
+ required: never[];
16
+ properties: {
17
+ include: {
18
+ type: string;
19
+ items: {
20
+ type: string;
21
+ };
22
+ };
23
+ exclude: {
24
+ type: string;
25
+ items: {
26
+ type: string;
27
+ };
28
+ };
29
+ };
30
+ };
31
+ category: {
32
+ type: string;
33
+ };
34
+ label: {
35
+ type: string;
36
+ };
37
+ params: {
38
+ type: string;
39
+ items: {
40
+ type: string;
41
+ additionalProperties: boolean;
42
+ required: string[];
43
+ properties: {
44
+ key: {
45
+ type: string;
46
+ };
47
+ value: {
48
+ type: string;
49
+ };
50
+ };
51
+ };
52
+ };
53
+ };
54
+ };
55
+ export declare const AnalyticsEventV2Schema: {
56
+ type: string;
57
+ propertyNames: {
58
+ type: string;
59
+ };
60
+ additionalProperty: {
61
+ type: string;
62
+ };
63
+ required: string[];
64
+ properties: {
65
+ name: {
66
+ type: string;
67
+ };
68
+ type: {
69
+ type: string;
70
+ };
71
+ counters: {
72
+ type: string;
73
+ additionalProperties: boolean;
74
+ required: never[];
75
+ properties: {
76
+ include: {
77
+ type: string;
78
+ items: {
79
+ type: string;
80
+ };
81
+ };
82
+ exclude: {
83
+ type: string;
84
+ items: {
85
+ type: string;
86
+ };
87
+ };
88
+ };
89
+ };
90
+ };
91
+ };
@@ -0,0 +1,87 @@
1
+ export const AnalyticsEventSchema = {
2
+ type: 'object',
3
+ additionalProperties: false,
4
+ required: ['name'],
5
+ properties: {
6
+ name: {
7
+ type: 'string',
8
+ },
9
+ type: {
10
+ type: 'string',
11
+ },
12
+ counters: {
13
+ type: 'object',
14
+ additionalProperties: false,
15
+ required: [],
16
+ properties: {
17
+ include: {
18
+ type: 'array',
19
+ items: {
20
+ type: 'string',
21
+ },
22
+ },
23
+ exclude: {
24
+ type: 'array',
25
+ items: {
26
+ type: 'string',
27
+ },
28
+ },
29
+ },
30
+ },
31
+ category: {
32
+ type: 'string',
33
+ },
34
+ label: {
35
+ type: 'string',
36
+ },
37
+ params: {
38
+ type: 'array',
39
+ items: {
40
+ type: 'object',
41
+ additionalProperties: false,
42
+ required: ['key', 'value'],
43
+ properties: {
44
+ key: {
45
+ type: 'string',
46
+ },
47
+ value: {
48
+ type: 'string',
49
+ },
50
+ },
51
+ },
52
+ },
53
+ },
54
+ };
55
+ export const AnalyticsEventV2Schema = {
56
+ type: 'object',
57
+ propertyNames: { type: 'string' },
58
+ additionalProperty: { type: 'number' },
59
+ required: ['name'],
60
+ properties: {
61
+ name: {
62
+ type: 'string',
63
+ },
64
+ type: {
65
+ type: 'string',
66
+ },
67
+ counters: {
68
+ type: 'object',
69
+ additionalProperties: false,
70
+ required: [],
71
+ properties: {
72
+ include: {
73
+ type: 'array',
74
+ items: {
75
+ type: 'string',
76
+ },
77
+ },
78
+ exclude: {
79
+ type: 'array',
80
+ items: {
81
+ type: 'string',
82
+ },
83
+ },
84
+ },
85
+ },
86
+ },
87
+ };
@@ -3,15 +3,16 @@ import { block } from '../../utils';
3
3
  import { ThemeValueContext } from '../../context/theme/ThemeValueContext';
4
4
  import { MobileContext } from '../../context/mobileContext';
5
5
  import { useMetrika } from '../../hooks/useMetrika';
6
- import { useHandleHubspotEvents } from '../../hooks';
6
+ import { useHandleHubspotEvents, useAnalytics } from '../../hooks';
7
7
  import HubspotFormContainer from './HubspotFormContainer';
8
8
  import './HubspotForm.css';
9
9
  const b = block('hubspot-form');
10
10
  const HubspotForm = (props) => {
11
11
  const { className, theme: themeProp, isMobile: isMobileProp, formId, formInstanceId, portalId, region, formClassName, pixelEvents,
12
12
  // hubspotEvents, // TODO: decide how to handle them
13
- onBeforeSubmit, onSubmit, onBeforeLoad, onLoad, } = props;
13
+ analyticsEvents, onBeforeSubmit, onSubmit, onBeforeLoad, onLoad, } = props;
14
14
  const handleMetrika = useMetrika();
15
+ const handleAnalytics = useAnalytics();
15
16
  const { themeValue } = useContext(ThemeValueContext);
16
17
  const isMobileValue = useContext(MobileContext);
17
18
  const theme = themeProp !== null && themeProp !== void 0 ? themeProp : themeValue;
@@ -22,9 +23,19 @@ const HubspotForm = (props) => {
22
23
  onLoad,
23
24
  onSubmit: (e) => {
24
25
  handleMetrika === null || handleMetrika === void 0 ? void 0 : handleMetrika({ pixelEvents });
26
+ handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
25
27
  onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(e);
26
28
  },
27
- }), [onBeforeLoad, onBeforeSubmit, onLoad, handleMetrika, pixelEvents, onSubmit]);
29
+ }), [
30
+ onBeforeLoad,
31
+ onBeforeSubmit,
32
+ onLoad,
33
+ handleMetrika,
34
+ pixelEvents,
35
+ handleAnalytics,
36
+ analyticsEvents,
37
+ onSubmit,
38
+ ]);
28
39
  useHandleHubspotEvents(handlers, formId);
29
40
  return (React.createElement(HubspotFormContainer, { key: [formClassName, formId, formInstanceId, portalId, region].join(), className: b({ theme, mobile }, className), formClassName: formClassName, formId: formId, portalId: portalId, formInstanceId: formInstanceId, region: region }));
30
41
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "1.14.0",
3
+ "version": "1.15.0-alpha.0",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -132,5 +132,8 @@
132
132
  "*.{json,yaml,yml,md}": [
133
133
  "prettier --write"
134
134
  ]
135
+ },
136
+ "publishConfig": {
137
+ "tag": "alpha"
135
138
  }
136
139
  }
@@ -7,12 +7,21 @@ export declare enum Theme {
7
7
  Light = "light",
8
8
  Dark = "dark"
9
9
  }
10
+ /**
11
+ * @deprecated Pixel will be deleted
12
+ */
10
13
  type PixelCommand = 'track' | 'trackCustom';
14
+ /**
15
+ * @deprecated Pixel will be deleted
16
+ */
11
17
  export interface PixelEvent {
12
18
  command: PixelCommand;
13
19
  event: PixelEventType | string;
14
20
  data?: Object;
15
21
  }
22
+ /**
23
+ * @deprecated Pixel will be deleted from package
24
+ */
16
25
  export declare enum PixelEventType {
17
26
  AddPaymentInfo = "AddPaymentInfo",
18
27
  AddToCart = "AddToCart",
@@ -36,11 +45,17 @@ export declare enum PixelEventType {
36
45
  export type Modifiers = {
37
46
  [name: string]: string | boolean | undefined;
38
47
  };
48
+ /**
49
+ * @deprecated Pixel will be deleted
50
+ */
39
51
  export interface Pixel<TEvent = string> {
40
52
  trackStandard: (event: TEvent, data?: Object) => void;
41
53
  trackCustom: (event: string, data?: Object) => void;
42
54
  track: (trackEvents: string | string[] | PixelEvent[] | PixelEvent) => void;
43
55
  }
56
+ /**
57
+ * @deprecated Metrika will be deleted
58
+ */
44
59
  export interface Metrika {
45
60
  reachGoal: (counterName: string, ...args: any) => void;
46
61
  reachGoals: (goals: MetrikaGoal, counterName?: string) => void;
@@ -49,4 +64,25 @@ export interface ClassNameProps {
49
64
  className?: string;
50
65
  }
51
66
  export type Timeout = ReturnType<typeof setTimeout> | undefined;
67
+ export type AnalyticsParameter = {
68
+ key: string;
69
+ value: string | number | boolean;
70
+ };
71
+ export type AnalyticsCounters = {
72
+ include?: string[];
73
+ exclude?: string[];
74
+ };
75
+ export type AnalyticsEvent = {
76
+ name: string;
77
+ type?: string;
78
+ counters?: AnalyticsCounters;
79
+ category?: string;
80
+ label?: string;
81
+ params?: AnalyticsParameter[];
82
+ };
83
+ export type AnalyticsEventV2<T = {}> = T & {
84
+ name: string;
85
+ type?: string;
86
+ counters?: AnalyticsCounters;
87
+ };
52
88
  export {};
@@ -6,6 +6,9 @@ var Theme;
6
6
  Theme["Light"] = "light";
7
7
  Theme["Dark"] = "dark";
8
8
  })(Theme = exports.Theme || (exports.Theme = {}));
9
+ /**
10
+ * @deprecated Pixel will be deleted from package
11
+ */
9
12
  var PixelEventType;
10
13
  (function (PixelEventType) {
11
14
  PixelEventType["AddPaymentInfo"] = "AddPaymentInfo";
@@ -1,7 +1,7 @@
1
1
  import { CSSProperties, ReactNode } from 'react';
2
2
  import { ButtonSize, ButtonView } from '@gravity-ui/uikit';
3
3
  import { ThemeSupporting } from '../../utils/theme';
4
- import { ClassNameProps, PixelEventType } from '../common';
4
+ import { AnalyticsEventV2, ClassNameProps, PixelEventType } from '../common';
5
5
  export declare enum AuthorType {
6
6
  Column = "column",
7
7
  Line = "line"
@@ -110,6 +110,7 @@ export interface MediaVideoProps {
110
110
  playButton?: PlayButtonProps;
111
111
  controls?: MediaVideoControlsType;
112
112
  metrika?: MetrikaVideo;
113
+ analyticsEvents?: AnalyticsEventV2[];
113
114
  }
114
115
  export interface LinkProps extends Stylable {
115
116
  url: string;
@@ -121,6 +122,7 @@ export interface LinkProps extends Stylable {
121
122
  target?: string;
122
123
  metrikaGoals?: MetrikaGoal;
123
124
  pixelEvents?: ButtonPixel;
125
+ analyticsEvents?: AnalyticsEventV2 | AnalyticsEventV2[];
124
126
  }
125
127
  export interface FileLinkProps extends ClassNameProps {
126
128
  href: string;
@@ -139,6 +141,7 @@ export interface ButtonProps {
139
141
  img?: ButtonImageProps | string;
140
142
  metrikaGoals?: MetrikaGoal;
141
143
  pixelEvents?: ButtonPixel;
144
+ analyticsEvents?: AnalyticsEventV2[];
142
145
  target?: string;
143
146
  }
144
147
  export interface ButtonImageProps {
@@ -167,6 +170,7 @@ export interface MediaComponentVideoProps {
167
170
  video: MediaVideoProps;
168
171
  height?: number;
169
172
  metrika?: MetrikaVideo;
173
+ analyticsEvents?: AnalyticsEventV2[];
170
174
  previewImg?: string;
171
175
  }
172
176
  export interface MediaComponentYoutubeProps {
@@ -222,6 +226,7 @@ export interface HeaderBreadCrumbsProps extends ClassNameProps {
222
226
  theme?: TextTheme;
223
227
  metrikaGoals?: MetrikaGoal;
224
228
  pixelEvents?: ButtonPixel;
229
+ analyticsEvents?: AnalyticsEventV2 | AnalyticsEventV2[];
225
230
  }
226
231
  export interface PreviewContentItemProps {
227
232
  title: string;
@@ -3,7 +3,7 @@ import { ThemeSupporting } from '../../utils';
3
3
  import { HubspotEventData, HubspotEventHandlers } from '../../utils/hubspot';
4
4
  import { AuthorItem, ButtonPixel, ButtonProps, CardBaseProps, ContentTheme, DividerSize, ImageObjectProps, ImageProps, LinkProps, MediaProps, PriceDetailedProps, TextTheme, Themable, ThemedImage } from './common';
5
5
  import { ContentBlockProps } from './blocks';
6
- import { PixelEvent } from '../common';
6
+ import { AnalyticsEventV2, PixelEvent } from '../common';
7
7
  export declare enum SubBlockType {
8
8
  Divider = "divider",
9
9
  Quote = "quote",
@@ -61,6 +61,7 @@ export interface HubspotFormProps extends HubspotEventHandlers {
61
61
  onLoad?: (arg: HubspotEventData) => void;
62
62
  pixelEvents?: string | string[] | PixelEvent | PixelEvent[] | ButtonPixel;
63
63
  hubspotEvents?: string[];
64
+ analyticsEvents?: AnalyticsEventV2 | AnalyticsEventV2[];
64
65
  }
65
66
  export interface PartnerProps extends CardBaseProps {
66
67
  text: string;