@gravity-ui/page-constructor 1.12.0 → 1.13.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 (72) hide show
  1. package/build/cjs/blocks/Banner/schema.d.ts +141 -0
  2. package/build/cjs/blocks/CardLayout/schema.d.ts +22 -24
  3. package/build/cjs/blocks/CardLayout/schema.js +1 -6
  4. package/build/cjs/blocks/ExtendedFeatures/schema.d.ts +16 -17
  5. package/build/cjs/blocks/ExtendedFeatures/schema.js +1 -6
  6. package/build/cjs/blocks/HeaderSlider/schema.d.ts +0 -25
  7. package/build/cjs/blocks/LinkTable/schema.d.ts +29 -21
  8. package/build/cjs/blocks/LinkTable/schema.js +1 -1
  9. package/build/cjs/blocks/Media/schema.d.ts +47 -0
  10. package/build/cjs/blocks/Media/schema.js +1 -1
  11. package/build/cjs/blocks/PromoFeaturesBlock/schema.d.ts +14 -15
  12. package/build/cjs/blocks/PromoFeaturesBlock/schema.js +1 -6
  13. package/build/cjs/blocks/Slider/schema.d.ts +28 -49
  14. package/build/cjs/blocks/Slider/schema.js +1 -6
  15. package/build/cjs/blocks/Tabs/schema.d.ts +29 -25
  16. package/build/cjs/blocks/Tabs/schema.js +1 -4
  17. package/build/cjs/components/BlockHeader/BlockHeader.css +8 -19
  18. package/build/cjs/components/BlockHeader/BlockHeader.js +4 -3
  19. package/build/cjs/components/Button/Button.js +3 -3
  20. package/build/cjs/components/CardBase/CardBase.d.ts +2 -1
  21. package/build/cjs/components/CardBase/CardBase.js +2 -2
  22. package/build/cjs/components/HeaderBreadcrumbs/HeaderBreadcrumbs.js +2 -2
  23. package/build/cjs/components/Link/Link.js +2 -2
  24. package/build/cjs/context/metrikaContext/metrikaContext.d.ts +2 -1
  25. package/build/cjs/hooks/useMetrika.d.ts +3 -2
  26. package/build/cjs/hooks/useMetrika.js +10 -2
  27. package/build/cjs/models/common.d.ts +4 -1
  28. package/build/cjs/models/constructor-items/common.d.ts +21 -0
  29. package/build/cjs/schema/validators/common.d.ts +125 -0
  30. package/build/cjs/schema/validators/common.js +12 -1
  31. package/build/cjs/schema/validators/ga-events.d.ts +47 -0
  32. package/build/cjs/schema/validators/ga-events.js +50 -0
  33. package/build/cjs/sub-blocks/CardWithImage/schema.js +1 -1
  34. package/build/cjs/text-transform/blocks.js +44 -54
  35. package/build/esm/blocks/Banner/schema.d.ts +141 -0
  36. package/build/esm/blocks/CardLayout/schema.d.ts +22 -24
  37. package/build/esm/blocks/CardLayout/schema.js +2 -7
  38. package/build/esm/blocks/ExtendedFeatures/schema.d.ts +16 -17
  39. package/build/esm/blocks/ExtendedFeatures/schema.js +2 -7
  40. package/build/esm/blocks/HeaderSlider/schema.d.ts +0 -25
  41. package/build/esm/blocks/LinkTable/schema.d.ts +29 -21
  42. package/build/esm/blocks/LinkTable/schema.js +2 -2
  43. package/build/esm/blocks/Media/schema.d.ts +47 -0
  44. package/build/esm/blocks/Media/schema.js +1 -1
  45. package/build/esm/blocks/PromoFeaturesBlock/schema.d.ts +14 -15
  46. package/build/esm/blocks/PromoFeaturesBlock/schema.js +2 -7
  47. package/build/esm/blocks/Slider/schema.d.ts +28 -49
  48. package/build/esm/blocks/Slider/schema.js +2 -7
  49. package/build/esm/blocks/Tabs/schema.d.ts +29 -25
  50. package/build/esm/blocks/Tabs/schema.js +2 -5
  51. package/build/esm/components/BlockHeader/BlockHeader.css +8 -19
  52. package/build/esm/components/BlockHeader/BlockHeader.js +5 -4
  53. package/build/esm/components/Button/Button.js +3 -3
  54. package/build/esm/components/CardBase/CardBase.d.ts +2 -1
  55. package/build/esm/components/CardBase/CardBase.js +2 -2
  56. package/build/esm/components/HeaderBreadcrumbs/HeaderBreadcrumbs.js +2 -2
  57. package/build/esm/components/Link/Link.js +2 -2
  58. package/build/esm/context/metrikaContext/metrikaContext.d.ts +2 -1
  59. package/build/esm/hooks/useMetrika.d.ts +3 -2
  60. package/build/esm/hooks/useMetrika.js +10 -2
  61. package/build/esm/models/common.d.ts +4 -1
  62. package/build/esm/models/constructor-items/common.d.ts +21 -0
  63. package/build/esm/schema/validators/common.d.ts +125 -0
  64. package/build/esm/schema/validators/common.js +11 -0
  65. package/build/esm/schema/validators/ga-events.d.ts +47 -0
  66. package/build/esm/schema/validators/ga-events.js +47 -0
  67. package/build/esm/sub-blocks/CardWithImage/schema.js +1 -1
  68. package/build/esm/text-transform/blocks.js +44 -54
  69. package/package.json +1 -1
  70. package/server/models/common.d.ts +4 -1
  71. package/server/models/constructor-items/common.d.ts +21 -0
  72. package/server/text-transform/blocks.js +44 -54
@@ -155,6 +155,20 @@ export declare const PromoFeaturesBlock: {
155
155
  additionalProperties: boolean;
156
156
  required: string[];
157
157
  properties: {
158
+ theme: {
159
+ enum: string[];
160
+ };
161
+ items: {
162
+ type: string;
163
+ items: {
164
+ type: string;
165
+ properties: {
166
+ when: {
167
+ type: string;
168
+ };
169
+ };
170
+ };
171
+ };
158
172
  title: {
159
173
  oneOf: ({
160
174
  type: string;
@@ -178,27 +192,12 @@ export declare const PromoFeaturesBlock: {
178
192
  };
179
193
  } | {
180
194
  type: string;
181
- contentType: string;
182
195
  })[];
183
196
  };
184
197
  description: {
185
198
  type: string;
186
199
  contentType: string;
187
200
  };
188
- theme: {
189
- enum: string[];
190
- };
191
- items: {
192
- type: string;
193
- items: {
194
- type: string;
195
- properties: {
196
- when: {
197
- type: string;
198
- };
199
- };
200
- };
201
- };
202
201
  animated: {
203
202
  type: string;
204
203
  };
@@ -1,4 +1,4 @@
1
- import { AnimatableProps, BlockBaseProps, TitleProps } from '../../schema/validators/common';
1
+ import { AnimatableProps, BlockBaseProps, BlockHeaderProps } from '../../schema/validators/common';
2
2
  import { filteredArray } from '../../schema/validators/utils';
3
3
  import { Media } from '../Media/schema';
4
4
  export const PromoFeaturesItem = {
@@ -23,12 +23,7 @@ export const PromoFeaturesBlock = {
23
23
  'promo-features-block': {
24
24
  additionalProperties: false,
25
25
  required: ['items'],
26
- properties: Object.assign(Object.assign(Object.assign({}, BlockBaseProps), AnimatableProps), { title: {
27
- oneOf: [{ type: 'string', contentType: 'text' }, TitleProps],
28
- }, description: {
29
- type: 'string',
30
- contentType: 'text',
31
- }, theme: {
26
+ properties: Object.assign(Object.assign(Object.assign(Object.assign({}, BlockBaseProps), AnimatableProps), BlockHeaderProps), { theme: {
32
27
  enum: ['grey', 'default'],
33
28
  }, items: filteredArray(PromoFeaturesItem) }),
34
29
  },
@@ -5,31 +5,6 @@ export declare const SliderProps: {
5
5
  arrows: {
6
6
  type: string;
7
7
  };
8
- description: {
9
- type: string;
10
- contentType: string;
11
- };
12
- title: {
13
- type: string;
14
- additionalProperties: boolean;
15
- required: string[];
16
- properties: {
17
- text: {
18
- type: string;
19
- contentType: string;
20
- };
21
- textSize: {
22
- type: string;
23
- enum: string[];
24
- };
25
- url: {
26
- type: string;
27
- };
28
- resetMargin: {
29
- type: string;
30
- };
31
- };
32
- };
33
8
  randomOrder: {
34
9
  type: string;
35
10
  };
@@ -108,36 +83,40 @@ export declare const SliderBlock: {
108
83
  additionalProperties: boolean;
109
84
  required: never[];
110
85
  properties: {
111
- dots: {
112
- type: string;
113
- };
114
- arrows: {
115
- type: string;
86
+ title: {
87
+ oneOf: ({
88
+ type: string;
89
+ additionalProperties: boolean;
90
+ required: string[];
91
+ properties: {
92
+ text: {
93
+ type: string;
94
+ contentType: string;
95
+ };
96
+ textSize: {
97
+ type: string;
98
+ enum: string[];
99
+ };
100
+ url: {
101
+ type: string;
102
+ };
103
+ resetMargin: {
104
+ type: string;
105
+ };
106
+ };
107
+ } | {
108
+ type: string;
109
+ })[];
116
110
  };
117
111
  description: {
118
112
  type: string;
119
113
  contentType: string;
120
114
  };
121
- title: {
115
+ dots: {
116
+ type: string;
117
+ };
118
+ arrows: {
122
119
  type: string;
123
- additionalProperties: boolean;
124
- required: string[];
125
- properties: {
126
- text: {
127
- type: string;
128
- contentType: string;
129
- };
130
- textSize: {
131
- type: string;
132
- enum: string[];
133
- };
134
- url: {
135
- type: string;
136
- };
137
- resetMargin: {
138
- type: string;
139
- };
140
- };
141
120
  };
142
121
  randomOrder: {
143
122
  type: string;
@@ -1,4 +1,4 @@
1
- import { BlockBaseProps, TitleProps, AnimatableProps, ChildrenCardsProps, sliderSizesObject, textSize, } from '../../schema/validators/common';
1
+ import { BlockBaseProps, AnimatableProps, ChildrenCardsProps, sliderSizesObject, textSize, BlockHeaderProps, } from '../../schema/validators/common';
2
2
  const LoadableProps = {
3
3
  additionalProperties: false,
4
4
  required: ['source'],
@@ -48,11 +48,6 @@ export const SliderProps = {
48
48
  arrows: {
49
49
  type: 'boolean',
50
50
  },
51
- description: {
52
- type: 'string',
53
- contentType: 'text',
54
- },
55
- title: TitleProps,
56
51
  randomOrder: {
57
52
  type: 'boolean',
58
53
  },
@@ -69,6 +64,6 @@ export const SliderBlock = {
69
64
  'slider-block': {
70
65
  additionalProperties: false,
71
66
  required: [],
72
- properties: Object.assign(Object.assign(Object.assign({}, BlockBaseProps), AnimatableProps), SliderProps),
67
+ properties: Object.assign(Object.assign(Object.assign(Object.assign({}, BlockBaseProps), AnimatableProps), SliderProps), BlockHeaderProps),
73
68
  },
74
69
  };
@@ -272,31 +272,6 @@ export declare const TabsBlock: {
272
272
  additionalProperties: boolean;
273
273
  required: string[];
274
274
  properties: {
275
- title: {
276
- type: string;
277
- additionalProperties: boolean;
278
- required: string[];
279
- properties: {
280
- text: {
281
- type: string;
282
- contentType: string;
283
- };
284
- textSize: {
285
- type: string;
286
- enum: string[];
287
- };
288
- url: {
289
- type: string;
290
- };
291
- resetMargin: {
292
- type: string;
293
- };
294
- };
295
- };
296
- description: {
297
- type: string;
298
- contentType: string;
299
- };
300
275
  tabsColSizes: {};
301
276
  direction: {
302
277
  type: string;
@@ -316,6 +291,35 @@ export declare const TabsBlock: {
316
291
  };
317
292
  };
318
293
  };
294
+ title: {
295
+ oneOf: ({
296
+ type: string;
297
+ additionalProperties: boolean;
298
+ required: string[];
299
+ properties: {
300
+ text: {
301
+ type: string;
302
+ contentType: string;
303
+ };
304
+ textSize: {
305
+ type: string;
306
+ enum: string[];
307
+ };
308
+ url: {
309
+ type: string;
310
+ };
311
+ resetMargin: {
312
+ type: string;
313
+ };
314
+ };
315
+ } | {
316
+ type: string;
317
+ })[];
318
+ };
319
+ description: {
320
+ type: string;
321
+ contentType: string;
322
+ };
319
323
  anchor: {
320
324
  type: string;
321
325
  additionalProperties: boolean;
@@ -1,5 +1,5 @@
1
1
  import { filteredArray } from '../../schema/validators/utils';
2
- import { LinkProps, withTheme, BlockBaseProps, TitleProps, MediaProps, containerSizesArray, sizeNumber, mediaDirection, } from '../../schema/validators/common';
2
+ import { LinkProps, withTheme, BlockBaseProps, BlockHeaderProps, MediaProps, containerSizesArray, sizeNumber, mediaDirection, } from '../../schema/validators/common';
3
3
  import { ImageProps } from '../../components/Image/schema';
4
4
  import _ from 'lodash';
5
5
  import { ContentBase } from '../../sub-blocks/Content/schema';
@@ -24,10 +24,7 @@ export const TabsBlock = {
24
24
  'tabs-block': {
25
25
  additionalProperties: false,
26
26
  required: ['title', 'items'],
27
- properties: Object.assign(Object.assign({}, BlockBaseProps), { title: TitleProps, description: {
28
- type: 'string',
29
- contentType: 'text',
30
- }, tabsColSizes: containerSizesArray.reduce((acc, size) => (Object.assign(Object.assign({}, acc), { [size]: sizeNumber })), {}), direction: {
27
+ properties: Object.assign(Object.assign(Object.assign({}, BlockBaseProps), BlockHeaderProps), { tabsColSizes: containerSizesArray.reduce((acc, size) => (Object.assign(Object.assign({}, acc), { [size]: sizeNumber })), {}), direction: {
31
28
  type: 'string',
32
29
  enum: mediaDirection,
33
30
  }, centered: { type: 'boolean' }, items: filteredArray(tabsItem) }),
@@ -1,27 +1,16 @@
1
1
  /* use this for style redefinitions to awoid problems with
2
2
  unpredictable css rules order in build */
3
- .pc-BlockHeader__description {
4
- font-size: var(--yc-text-body-2-font-size);
5
- line-height: var(--yc-text-body-2-line-height);
6
- margin-top: 16px;
7
- }
8
- .pc-BlockHeader__description_titleSize_s {
9
- margin-top: 8px;
3
+ .pc-block-header__description {
4
+ margin-top: 12px;
10
5
  }
11
- .pc-BlockHeader__description_titleSize_l {
6
+ .pc-block-header__description .yfm {
12
7
  font-size: var(--yc-text-body-3-font-size);
13
8
  line-height: var(--yc-text-body-3-line-height);
14
9
  }
15
- .pc-BlockHeader__description a {
16
- outline: none;
17
- color: var(--yc-color-text-link);
18
- text-decoration: none;
19
- cursor: pointer;
20
- }
21
- .utilityfocus .pc-BlockHeader__description a:focus {
22
- outline: 2px solid #ffdb4d;
10
+ .pc-block-header__description_titleSize_s {
11
+ margin-top: 8px;
23
12
  }
24
- .pc-BlockHeader__description a:hover, .pc-BlockHeader__description a:active {
25
- --pc-text-header-color: var(--yc-color-text-link-hover);
26
- color: var(--yc-color-text-link-hover);
13
+ .pc-block-header__description_titleSize_s .yfm {
14
+ font-size: var(--yc-text-body-2-font-size);
15
+ line-height: var(--yc-text-body-2-line-height);
27
16
  }
@@ -2,9 +2,10 @@ import { __rest } from "tslib";
2
2
  import React from 'react';
3
3
  import { block } from '../../utils';
4
4
  import { Col } from '../../grid';
5
- import { Title, HTML } from '../';
5
+ import { Title } from '../';
6
+ import YFMWrapper from '../YFMWrapper/YFMWrapper';
6
7
  import './BlockHeader.css';
7
- const b = block('BlockHeader');
8
+ const b = block('block-header');
8
9
  const BlockHeader = ({ title, description, className, colSizes = { all: 12, sm: 8 }, }) => {
9
10
  if (!title && !description) {
10
11
  return null;
@@ -13,8 +14,8 @@ const BlockHeader = ({ title, description, className, colSizes = { all: 12, sm:
13
14
  return (React.createElement("div", { className: b(null, className) },
14
15
  text && (React.createElement(Col, { reset: true, sizes: colSizes },
15
16
  React.createElement(Title, Object.assign({ text: text }, titleProps)))),
16
- description && (React.createElement(Col, { reset: true, sizes: { all: 12, sm: 8 } },
17
+ description && (React.createElement(Col, { reset: true, sizes: colSizes },
17
18
  React.createElement("div", { className: b('description', { titleSize: titleProps === null || titleProps === void 0 ? void 0 : titleProps.textSize }) },
18
- React.createElement(HTML, null, description))))));
19
+ React.createElement(YFMWrapper, { content: description, modifiers: { constructor: true } }))))));
19
20
  };
20
21
  export default BlockHeader;
@@ -11,14 +11,14 @@ const b = block('button-block');
11
11
  const Button = (props) => {
12
12
  const handleMetrika = useMetrika();
13
13
  const { lang, tld } = useContext(LocaleContext);
14
- const { className, metrikaGoals, pixelEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text } = props, rest = __rest(props, ["className", "metrikaGoals", "pixelEvents", "size", "theme", "url", "img", "onClick", "text"]);
14
+ const { className, metrikaGoals, pixelEvents, gaEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text } = props, rest = __rest(props, ["className", "metrikaGoals", "pixelEvents", "gaEvents", "size", "theme", "url", "img", "onClick", "text"]);
15
15
  const defaultImgPosition = 'left';
16
16
  const onClick = useCallback(() => {
17
- handleMetrika({ metrikaGoals, pixelEvents });
17
+ handleMetrika({ metrikaGoals, pixelEvents, gaEvents });
18
18
  if (onClickOrigin) {
19
19
  onClickOrigin();
20
20
  }
21
- }, [handleMetrika, metrikaGoals, pixelEvents, onClickOrigin]);
21
+ }, [handleMetrika, metrikaGoals, pixelEvents, gaEvents, onClickOrigin]);
22
22
  const buttonImg = img instanceof Object
23
23
  ? { url: img.url, position: img.position || defaultImgPosition, alt: img.alt }
24
24
  : { url: img, position: defaultImgPosition };
@@ -1,5 +1,5 @@
1
1
  import React, { ReactElement, HTMLAttributeAnchorTarget } from 'react';
2
- import { ButtonPixel, CardBaseProps as CardBaseParams, ImageProps, MetrikaGoal, WithChildren } from '../../models';
2
+ import { ButtonPixel, CardBaseProps as CardBaseParams, GAEvents, ImageProps, MetrikaGoal, WithChildren } from '../../models';
3
3
  import './CardBase.css';
4
4
  export interface CardBaseProps extends CardBaseParams {
5
5
  className?: string;
@@ -10,6 +10,7 @@ export interface CardBaseProps extends CardBaseParams {
10
10
  target?: HTMLAttributeAnchorTarget;
11
11
  metrikaGoals?: MetrikaGoal;
12
12
  pixelEvents?: ButtonPixel;
13
+ gaEvents?: GAEvents;
13
14
  }
14
15
  export interface CardHeaderBaseProps {
15
16
  className?: string;
@@ -9,7 +9,7 @@ const Header = () => null;
9
9
  const Content = () => null;
10
10
  const Footer = () => null;
11
11
  export const Layout = (props) => {
12
- const { className, bodyClassName, metrikaGoals, pixelEvents, contentClassName, children, url, target, border = 'shadow', } = props;
12
+ const { className, bodyClassName, metrikaGoals, pixelEvents, gaEvents, contentClassName, children, url, target, border = 'shadow', } = props;
13
13
  const handleMetrika = useMetrika();
14
14
  let header, content, footer, image, headerClass, footerClass;
15
15
  function handleChild(child) {
@@ -42,7 +42,7 @@ export const Layout = (props) => {
42
42
  footer && React.createElement("div", { className: b('footer', footerClass) }, footer))));
43
43
  const fullClassName = b({ border }, className);
44
44
  const onClick = () => {
45
- handleMetrika({ metrikaGoals, pixelEvents });
45
+ handleMetrika({ metrikaGoals, pixelEvents, gaEvents });
46
46
  };
47
47
  return url ? (React.createElement(RouterLink, { href: url },
48
48
  React.createElement("a", { href: url, target: target, rel: target === '_blank' ? 'noopener noreferrer' : undefined, className: fullClassName, draggable: false, onDragStart: (e) => e.preventDefault(), onClick: onClick }, cardContent))) : (React.createElement("div", { className: fullClassName }, cardContent));
@@ -4,10 +4,10 @@ import { useMetrika } from '../../hooks/useMetrika';
4
4
  import './HeaderBreadcrumbs.css';
5
5
  const b = block('header-breadcrumbs');
6
6
  export default function HeaderBreadcrumbs(props) {
7
- const { items, metrikaGoals, pixelEvents, theme = 'light', className } = props;
7
+ const { items, metrikaGoals, pixelEvents, gaEvents, theme = 'light', className } = props;
8
8
  const handleMetrika = useMetrika();
9
9
  const onClick = () => {
10
- handleMetrika({ metrikaGoals, pixelEvents });
10
+ handleMetrika({ metrikaGoals, pixelEvents, gaEvents });
11
11
  };
12
12
  return (React.createElement("div", { className: b({ theme }, className) }, items.map((item) => (React.createElement("div", { className: b('item'), key: item.url },
13
13
  React.createElement("a", { href: item.url, className: b('text'), onClick: onClick }, item.text))))));
@@ -23,14 +23,14 @@ function getArrowSize(size) {
23
23
  }
24
24
  }
25
25
  const LinkBlock = (props) => {
26
- const { text, url, arrow, metrikaGoals, pixelEvents, theme = 'file-link', colorTheme = 'light', textSize = 'm', className, target, children, } = props;
26
+ const { text, url, arrow, metrikaGoals, pixelEvents, gaEvents, theme = 'file-link', colorTheme = 'light', textSize = 'm', className, target, children, } = props;
27
27
  const handleMetrika = useMetrika();
28
28
  const { hostname } = useContext(LocationContext);
29
29
  const { tld } = useContext(LocaleContext);
30
30
  const href = setUrlTld(props.url, tld);
31
31
  const defaultTextSize = theme === 'back' ? 'l' : 'm';
32
32
  const onClick = () => {
33
- handleMetrika({ metrikaGoals, pixelEvents });
33
+ handleMetrika({ metrikaGoals, pixelEvents, gaEvents });
34
34
  };
35
35
  const getLinkByType = () => {
36
36
  switch (theme) {
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
- import { Metrika, Pixel } from '../../models';
2
+ import { GaInline, Metrika, Pixel } from '../../models';
3
3
  export interface MetrikaContextProps {
4
4
  metrika?: Metrika;
5
5
  pixel?: Pixel;
6
+ gaInline?: GaInline;
6
7
  }
7
8
  export declare const MetrikaContext: React.Context<MetrikaContextProps>;
@@ -1,7 +1,8 @@
1
- import { ButtonPixel, MetrikaGoal, PixelEvent } from '../models';
1
+ import { ButtonPixel, MetrikaGoal, PixelEvent, GAEvents } from '../models';
2
2
  type UseMetrikaProps = {
3
3
  metrikaGoals?: MetrikaGoal;
4
4
  pixelEvents?: string | string[] | PixelEvent | PixelEvent[] | ButtonPixel;
5
+ gaEvents?: GAEvents;
5
6
  };
6
- export declare const useMetrika: () => ({ metrikaGoals, pixelEvents }: UseMetrikaProps) => void;
7
+ export declare const useMetrika: () => ({ metrikaGoals, pixelEvents, gaEvents }: UseMetrikaProps) => void;
7
8
  export {};
@@ -1,3 +1,4 @@
1
+ import { __rest } from "tslib";
1
2
  import { useContext } from 'react';
2
3
  import { MetrikaContext } from '../context/metrikaContext';
3
4
  import { PixelEventType } from '../models';
@@ -9,8 +10,8 @@ function isButtonPixel(pixelEvents) {
9
10
  return false;
10
11
  }
11
12
  export const useMetrika = () => {
12
- const { metrika, pixel } = useContext(MetrikaContext);
13
- return ({ metrikaGoals, pixelEvents }) => {
13
+ const { metrika, pixel, gaInline } = useContext(MetrikaContext);
14
+ return ({ metrikaGoals, pixelEvents, gaEvents }) => {
14
15
  if (metrika && metrikaGoals) {
15
16
  if (isNewMetrikaFormat(metrikaGoals)) {
16
17
  metrikaGoals.forEach(({ name, isCrossSite }) => metrika.reachGoal(isCrossSite ? 'cross-site' : 'main', name));
@@ -33,5 +34,12 @@ export const useMetrika = () => {
33
34
  pixel.track(pixelEvents);
34
35
  }
35
36
  }
37
+ if (gaInline && gaEvents) {
38
+ const gaEventsArray = Array.isArray(gaEvents) ? gaEvents : [gaEvents];
39
+ gaEventsArray.forEach((_a) => {
40
+ var { eventName } = _a, rest = __rest(_a, ["eventName"]);
41
+ gaInline.event(eventName, rest);
42
+ });
43
+ }
36
44
  };
37
45
  };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { MetrikaGoal } from './';
2
+ import { GAEventParams, MetrikaGoal } from './';
3
3
  export interface Refable<T> {
4
4
  ref?: React.Ref<T>;
5
5
  }
@@ -45,6 +45,9 @@ export interface Metrika {
45
45
  reachGoal: (counterName: string, ...args: any) => void;
46
46
  reachGoals: (goals: MetrikaGoal, counterName?: string) => void;
47
47
  }
48
+ export interface GaInline {
49
+ event: (eventName: string, params?: GAEventParams) => void;
50
+ }
48
51
  export interface ClassNameProps {
49
52
  className?: string;
50
53
  }
@@ -121,6 +121,7 @@ export interface LinkProps extends Stylable {
121
121
  target?: string;
122
122
  metrikaGoals?: MetrikaGoal;
123
123
  pixelEvents?: ButtonPixel;
124
+ gaEvents?: GAEvents;
124
125
  }
125
126
  export interface FileLinkProps extends ClassNameProps {
126
127
  href: string;
@@ -139,6 +140,7 @@ export interface ButtonProps {
139
140
  img?: ButtonImageProps | string;
140
141
  metrikaGoals?: MetrikaGoal;
141
142
  pixelEvents?: ButtonPixel;
143
+ gaEvents?: GAEvents;
142
144
  target?: string;
143
145
  }
144
146
  export interface ButtonImageProps {
@@ -222,6 +224,7 @@ export interface HeaderBreadCrumbsProps extends ClassNameProps {
222
224
  theme?: TextTheme;
223
225
  metrikaGoals?: MetrikaGoal;
224
226
  pixelEvents?: ButtonPixel;
227
+ gaEvents?: GAEvents;
225
228
  }
226
229
  export interface PreviewContentItemProps {
227
230
  title: string;
@@ -337,4 +340,22 @@ export interface BlockHeaderProps {
337
340
  title?: TitleProps | string;
338
341
  description?: string;
339
342
  }
343
+ export declare type GaParameterValue = string | number | boolean;
344
+ declare type GACommandConfig<T> = T & {
345
+ [key: string]: GaParameterValue;
346
+ };
347
+ declare type GACommonParams = {
348
+ groups?: string | string[];
349
+ sendTo?: string | string[];
350
+ eventTimeout?: number;
351
+ };
352
+ export declare type GAEventParams = GACommandConfig<GACommonParams & {
353
+ eventCategory?: string;
354
+ eventLabel?: string;
355
+ value?: number;
356
+ }>;
357
+ export type GAEvent = GAEventParams & {
358
+ eventName: string;
359
+ };
360
+ export type GAEvents = GAEvent | GAEvent[];
340
361
  export {};