@gravity-ui/page-constructor 1.15.0-alpha.4 → 1.15.0-alpha.6
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.
- package/build/cjs/blocks/Banner/schema.d.ts +18 -0
- package/build/cjs/blocks/Media/schema.d.ts +6 -0
- package/build/cjs/blocks/Share/Share.js +8 -7
- package/build/cjs/components/BackLink/BackLink.js +9 -8
- package/build/cjs/components/Button/Button.js +8 -11
- package/build/cjs/components/ButtonTabs/ButtonTabs.js +11 -5
- package/build/cjs/components/CardBase/CardBase.js +7 -2
- package/build/cjs/components/HeaderBreadcrumbs/HeaderBreadcrumbs.js +7 -6
- package/build/cjs/components/Link/Link.js +7 -2
- package/build/cjs/components/ReactPlayer/ReactPlayer.js +11 -29
- package/build/cjs/components/YandexForm/YandexForm.js +8 -8
- package/build/cjs/constants.d.ts +1 -0
- package/build/cjs/constants.js +2 -1
- package/build/cjs/context/analyticsContext/analyticsContext.d.ts +1 -1
- package/build/cjs/hooks/useAnalytics.d.ts +2 -2
- package/build/cjs/hooks/useAnalytics.js +11 -4
- package/build/cjs/models/common.d.ts +1 -1
- package/build/cjs/schema/validators/common.d.ts +12 -0
- package/build/cjs/schema/validators/event.d.ts +3 -0
- package/build/cjs/schema/validators/event.js +3 -0
- package/build/cjs/sub-blocks/HubspotForm/index.js +7 -7
- package/build/cjs/sub-blocks/Quote/Quote.js +8 -7
- package/build/esm/blocks/Banner/schema.d.ts +18 -0
- package/build/esm/blocks/Media/schema.d.ts +6 -0
- package/build/esm/blocks/Share/Share.js +8 -7
- package/build/esm/components/BackLink/BackLink.js +9 -8
- package/build/esm/components/Button/Button.js +8 -11
- package/build/esm/components/ButtonTabs/ButtonTabs.js +11 -5
- package/build/esm/components/CardBase/CardBase.js +7 -2
- package/build/esm/components/HeaderBreadcrumbs/HeaderBreadcrumbs.js +7 -6
- package/build/esm/components/Link/Link.js +7 -2
- package/build/esm/components/ReactPlayer/ReactPlayer.js +11 -29
- package/build/esm/components/YandexForm/YandexForm.js +8 -8
- package/build/esm/constants.d.ts +1 -0
- package/build/esm/constants.js +1 -0
- package/build/esm/context/analyticsContext/analyticsContext.d.ts +1 -1
- package/build/esm/hooks/useAnalytics.d.ts +2 -2
- package/build/esm/hooks/useAnalytics.js +11 -4
- package/build/esm/models/common.d.ts +1 -1
- package/build/esm/schema/validators/common.d.ts +12 -0
- package/build/esm/schema/validators/event.d.ts +3 -0
- package/build/esm/schema/validators/event.js +3 -0
- package/build/esm/sub-blocks/HubspotForm/index.js +7 -7
- package/build/esm/sub-blocks/Quote/Quote.js +8 -7
- package/package.json +1 -1
- package/server/models/common.d.ts +1 -1
|
@@ -206,6 +206,9 @@ export declare const BannerCardProps: {
|
|
|
206
206
|
};
|
|
207
207
|
};
|
|
208
208
|
};
|
|
209
|
+
blockName: {
|
|
210
|
+
type: string;
|
|
211
|
+
};
|
|
209
212
|
};
|
|
210
213
|
} | {
|
|
211
214
|
type: string;
|
|
@@ -241,6 +244,9 @@ export declare const BannerCardProps: {
|
|
|
241
244
|
};
|
|
242
245
|
};
|
|
243
246
|
};
|
|
247
|
+
blockName: {
|
|
248
|
+
type: string;
|
|
249
|
+
};
|
|
244
250
|
};
|
|
245
251
|
};
|
|
246
252
|
})[];
|
|
@@ -483,6 +489,9 @@ export declare const BannerBlock: {
|
|
|
483
489
|
};
|
|
484
490
|
};
|
|
485
491
|
};
|
|
492
|
+
blockName: {
|
|
493
|
+
type: string;
|
|
494
|
+
};
|
|
486
495
|
};
|
|
487
496
|
} | {
|
|
488
497
|
type: string;
|
|
@@ -518,6 +527,9 @@ export declare const BannerBlock: {
|
|
|
518
527
|
};
|
|
519
528
|
};
|
|
520
529
|
};
|
|
530
|
+
blockName: {
|
|
531
|
+
type: string;
|
|
532
|
+
};
|
|
521
533
|
};
|
|
522
534
|
};
|
|
523
535
|
})[];
|
|
@@ -761,6 +773,9 @@ export declare const BannerCard: {
|
|
|
761
773
|
};
|
|
762
774
|
};
|
|
763
775
|
};
|
|
776
|
+
blockName: {
|
|
777
|
+
type: string;
|
|
778
|
+
};
|
|
764
779
|
};
|
|
765
780
|
} | {
|
|
766
781
|
type: string;
|
|
@@ -796,6 +811,9 @@ export declare const BannerCard: {
|
|
|
796
811
|
};
|
|
797
812
|
};
|
|
798
813
|
};
|
|
814
|
+
blockName: {
|
|
815
|
+
type: string;
|
|
816
|
+
};
|
|
799
817
|
};
|
|
800
818
|
};
|
|
801
819
|
})[];
|
|
@@ -459,6 +459,9 @@ export declare const MediaBlock: {
|
|
|
459
459
|
};
|
|
460
460
|
};
|
|
461
461
|
};
|
|
462
|
+
blockName: {
|
|
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
|
+
blockName: {
|
|
501
|
+
type: string;
|
|
502
|
+
};
|
|
497
503
|
};
|
|
498
504
|
};
|
|
499
505
|
})[];
|
|
@@ -7,12 +7,13 @@ const utils_1 = require("../../utils");
|
|
|
7
7
|
const models_1 = require("../../models");
|
|
8
8
|
const locationContext_1 = require("../../context/locationContext");
|
|
9
9
|
const i18n_1 = tslib_1.__importDefault(require("./i18n"));
|
|
10
|
-
const hooks_1 = require("
|
|
10
|
+
const hooks_1 = require("../../hooks");
|
|
11
11
|
const Facebook_1 = require("../../icons/Facebook");
|
|
12
12
|
const Twitter_1 = require("../../icons/Twitter");
|
|
13
13
|
const Linkedin_1 = require("../../icons/Linkedin");
|
|
14
14
|
const Vk_1 = require("../../icons/Vk");
|
|
15
15
|
const Telegram_1 = require("../../icons/Telegram");
|
|
16
|
+
const constants_1 = require("../../constants");
|
|
16
17
|
const icons = {
|
|
17
18
|
facebook: Facebook_1.Facebook,
|
|
18
19
|
twitter: Twitter_1.Twitter,
|
|
@@ -23,12 +24,12 @@ const icons = {
|
|
|
23
24
|
const b = (0, utils_1.block)('share-block');
|
|
24
25
|
const Share = ({ items, title, blockName = models_1.BlockType.ShareBlock }) => {
|
|
25
26
|
const { pathname, hostname } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
26
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)({
|
|
28
|
+
name: 'share-button-click',
|
|
29
|
+
type: constants_1.DEFAULT_EVENT_TYPE,
|
|
30
|
+
blockName: blockName,
|
|
31
|
+
});
|
|
32
|
+
const handleButtonClick = (0, react_1.useCallback)(() => handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(), [handleAnalytics]);
|
|
32
33
|
return (react_1.default.createElement("div", { className: b() },
|
|
33
34
|
react_1.default.createElement("h5", { className: b('title') }, title || (0, i18n_1.default)('constructor-share')),
|
|
34
35
|
react_1.default.createElement("div", { className: b('items') }, items.map((type) => {
|
|
@@ -5,18 +5,19 @@ const react_1 = tslib_1.__importStar(require("react"));
|
|
|
5
5
|
const uikit_1 = require("@gravity-ui/uikit");
|
|
6
6
|
const icons_1 = require("../../icons");
|
|
7
7
|
const locationContext_1 = require("../../context/locationContext");
|
|
8
|
-
const hooks_1 = require("
|
|
8
|
+
const hooks_1 = require("../../hooks");
|
|
9
|
+
const constants_1 = require("../../constants");
|
|
9
10
|
const COMPONENT_NAME = 'backlink';
|
|
10
11
|
function BackLink(props) {
|
|
11
12
|
const { history } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
12
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)();
|
|
13
13
|
const { url, title, theme = 'default', size = 'l', className, shouldHandleBackAction = false, onClick, blockName = COMPONENT_NAME, } = props;
|
|
14
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)({
|
|
15
|
+
name: 'back-link-click',
|
|
16
|
+
type: constants_1.DEFAULT_EVENT_TYPE,
|
|
17
|
+
blockName: blockName,
|
|
18
|
+
});
|
|
14
19
|
const backActionHandler = (0, react_1.useCallback)(async () => {
|
|
15
|
-
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(
|
|
16
|
-
name: 'default',
|
|
17
|
-
type: 'button',
|
|
18
|
-
block: blockName,
|
|
19
|
-
});
|
|
20
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics();
|
|
20
21
|
if (!history) {
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
@@ -29,7 +30,7 @@ function BackLink(props) {
|
|
|
29
30
|
else {
|
|
30
31
|
history.push({ pathname: url });
|
|
31
32
|
}
|
|
32
|
-
}, [
|
|
33
|
+
}, [handleAnalytics, history, onClick, url]);
|
|
33
34
|
return (react_1.default.createElement(uikit_1.Button, { className: className, view: theme === 'special' ? 'flat-contrast' : 'flat-secondary', size: size, href: shouldHandleBackAction ? undefined : url, onClick: shouldHandleBackAction ? backActionHandler : undefined },
|
|
34
35
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.ArrowSidebar, size: 24 }),
|
|
35
36
|
react_1.default.createElement("span", null, title)));
|
|
@@ -9,29 +9,26 @@ const localeContext_1 = require("../../context/localeContext/localeContext");
|
|
|
9
9
|
const useMetrika_1 = require("../../hooks/useMetrika");
|
|
10
10
|
const hooks_1 = require("../../hooks");
|
|
11
11
|
const icons_1 = require("../../icons");
|
|
12
|
+
const constants_1 = require("../../constants");
|
|
12
13
|
const COMPONENT_NAME = 'button';
|
|
13
14
|
const b = (0, utils_1.block)('button-block');
|
|
14
15
|
const Button = (props) => {
|
|
15
16
|
const handleMetrika = (0, useMetrika_1.useMetrika)();
|
|
16
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)();
|
|
17
17
|
const { lang, tld } = (0, react_1.useContext)(localeContext_1.LocaleContext);
|
|
18
18
|
const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text, blockName = COMPONENT_NAME } = props, rest = tslib_1.__rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text", "blockName"]);
|
|
19
19
|
const defaultImgPosition = 'left';
|
|
20
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)({
|
|
21
|
+
name: 'button-click',
|
|
22
|
+
type: constants_1.DEFAULT_EVENT_TYPE,
|
|
23
|
+
blockName: blockName,
|
|
24
|
+
});
|
|
20
25
|
const onClick = (0, react_1.useCallback)(() => {
|
|
21
26
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
22
|
-
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents
|
|
27
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
|
|
23
28
|
if (onClickOrigin) {
|
|
24
29
|
onClickOrigin();
|
|
25
30
|
}
|
|
26
|
-
}, [
|
|
27
|
-
handleMetrika,
|
|
28
|
-
metrikaGoals,
|
|
29
|
-
pixelEvents,
|
|
30
|
-
handleAnalytics,
|
|
31
|
-
analyticsEvents,
|
|
32
|
-
blockName,
|
|
33
|
-
onClickOrigin,
|
|
34
|
-
]);
|
|
31
|
+
}, [handleMetrika, metrikaGoals, pixelEvents, handleAnalytics, analyticsEvents, onClickOrigin]);
|
|
35
32
|
const buttonImg = img instanceof Object
|
|
36
33
|
? { url: img.url, position: img.position || defaultImgPosition, alt: img.alt }
|
|
37
34
|
: { url: img, position: defaultImgPosition };
|
|
@@ -4,11 +4,17 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
6
|
const index_1 = require("../index");
|
|
7
|
-
const hooks_1 = require("
|
|
7
|
+
const hooks_1 = require("../../hooks");
|
|
8
|
+
const constants_1 = require("../../constants");
|
|
8
9
|
const b = (0, utils_1.block)('button-tabs');
|
|
10
|
+
const COMPONENT_NAME = 'button-tabs';
|
|
9
11
|
const ButtonTabs = (props) => {
|
|
10
|
-
const { className, items, activeTab, onSelectTab, blockName =
|
|
11
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(
|
|
12
|
+
const { className, items, activeTab, onSelectTab, blockName = COMPONENT_NAME } = props;
|
|
13
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)({
|
|
14
|
+
name: 'button-tabs-click',
|
|
15
|
+
type: constants_1.DEFAULT_EVENT_TYPE,
|
|
16
|
+
blockName: blockName,
|
|
17
|
+
});
|
|
12
18
|
const activeTabId = (0, react_1.useMemo)(() => {
|
|
13
19
|
if (activeTab) {
|
|
14
20
|
return activeTab;
|
|
@@ -16,11 +22,11 @@ const ButtonTabs = (props) => {
|
|
|
16
22
|
return items[0].id;
|
|
17
23
|
}, [activeTab, items]);
|
|
18
24
|
const handleClick = (0, react_1.useCallback)((tabId) => {
|
|
19
|
-
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(
|
|
25
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics();
|
|
20
26
|
if (onSelectTab) {
|
|
21
27
|
onSelectTab(tabId);
|
|
22
28
|
}
|
|
23
|
-
}, [
|
|
29
|
+
}, [handleAnalytics, onSelectTab]);
|
|
24
30
|
return (react_1.default.createElement("div", { className: b(null, className) }, items.map((item) => {
|
|
25
31
|
const isActive = item.id === activeTabId;
|
|
26
32
|
return (react_1.default.createElement(index_1.Button, { text: item.title, className: b('item', { active: isActive }), key: item.title, size: 'l', onClick: () => handleClick(item.id), theme: isActive ? 'monochrome' : 'normal' }));
|
|
@@ -8,6 +8,7 @@ const BackgroundImage_1 = tslib_1.__importDefault(require("../BackgroundImage/Ba
|
|
|
8
8
|
const RouterLink_1 = tslib_1.__importDefault(require("../RouterLink/RouterLink"));
|
|
9
9
|
const useMetrika_1 = require("../../hooks/useMetrika");
|
|
10
10
|
const hooks_1 = require("../../hooks");
|
|
11
|
+
const constants_1 = require("../../constants");
|
|
11
12
|
const COMPONENT_NAME = 'card-base';
|
|
12
13
|
const b = (0, utils_1.block)('card-base-block');
|
|
13
14
|
const Header = () => null;
|
|
@@ -16,7 +17,11 @@ const Footer = () => null;
|
|
|
16
17
|
const Layout = (props) => {
|
|
17
18
|
const { className, bodyClassName, metrikaGoals, pixelEvents, analyticsEvents, contentClassName, children, url, target, border = 'shadow', blockName = COMPONENT_NAME, } = props;
|
|
18
19
|
const handleMetrika = (0, useMetrika_1.useMetrika)();
|
|
19
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(
|
|
20
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)({
|
|
21
|
+
name: 'card-base-click',
|
|
22
|
+
type: constants_1.DEFAULT_EVENT_TYPE,
|
|
23
|
+
blockName: blockName,
|
|
24
|
+
});
|
|
20
25
|
let header, content, footer, image, headerClass, footerClass;
|
|
21
26
|
function handleChild(child) {
|
|
22
27
|
switch (child.type) {
|
|
@@ -49,7 +54,7 @@ const Layout = (props) => {
|
|
|
49
54
|
const fullClassName = b({ border }, className);
|
|
50
55
|
const onClick = () => {
|
|
51
56
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
52
|
-
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents
|
|
57
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
|
|
53
58
|
};
|
|
54
59
|
return url ? (react_1.default.createElement(RouterLink_1.default, { href: url },
|
|
55
60
|
react_1.default.createElement("a", { href: url, target: target, rel: target === '_blank' ? 'noopener noreferrer' : undefined, className: fullClassName, draggable: false, onDragStart: (e) => e.preventDefault(), onClick: onClick }, cardContent))) : (react_1.default.createElement("div", { className: fullClassName }, cardContent));
|
|
@@ -5,19 +5,20 @@ const react_1 = tslib_1.__importDefault(require("react"));
|
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
6
|
const useMetrika_1 = require("../../hooks/useMetrika");
|
|
7
7
|
const hooks_1 = require("../../hooks");
|
|
8
|
+
const constants_1 = require("../../constants");
|
|
8
9
|
const b = (0, utils_1.block)('header-breadcrumbs');
|
|
9
10
|
const COMPONENT_NAME = 'header-breadcrumbs';
|
|
10
11
|
function HeaderBreadcrumbs(props) {
|
|
11
12
|
const { items, metrikaGoals, pixelEvents, analyticsEvents, theme = 'light', blockName = COMPONENT_NAME, className, } = props;
|
|
12
13
|
const handleMetrika = (0, useMetrika_1.useMetrika)();
|
|
13
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(
|
|
14
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)({
|
|
15
|
+
name: 'header-breadcrumbs-click',
|
|
16
|
+
type: constants_1.DEFAULT_EVENT_TYPE,
|
|
17
|
+
blockName: blockName,
|
|
18
|
+
});
|
|
14
19
|
const onClick = () => {
|
|
15
20
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
16
|
-
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents
|
|
17
|
-
name: 'default',
|
|
18
|
-
type: 'header-breadcrumbs',
|
|
19
|
-
block: blockName,
|
|
20
|
-
});
|
|
21
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
|
|
21
22
|
};
|
|
22
23
|
return (react_1.default.createElement("div", { className: b({ theme }, className) }, items.map((item) => (react_1.default.createElement("div", { className: b('item'), key: item.url },
|
|
23
24
|
react_1.default.createElement("a", { href: item.url, className: b('text'), onClick: onClick }, item.text))))));
|
|
@@ -11,6 +11,7 @@ const localeContext_1 = require("../../context/localeContext/localeContext");
|
|
|
11
11
|
const locationContext_1 = require("../../context/locationContext/locationContext");
|
|
12
12
|
const useMetrika_1 = require("../../hooks/useMetrika");
|
|
13
13
|
const hooks_1 = require("../../hooks");
|
|
14
|
+
const constants_1 = require("../../constants");
|
|
14
15
|
const b = (0, utils_1.block)('link-block');
|
|
15
16
|
const WORD_JOINER_SYM = '\u200b';
|
|
16
17
|
const COMPONENT_NAME = 'link';
|
|
@@ -29,14 +30,18 @@ function getArrowSize(size) {
|
|
|
29
30
|
const LinkBlock = (props) => {
|
|
30
31
|
const { text, url, arrow, metrikaGoals, pixelEvents, analyticsEvents, theme = 'file-link', colorTheme = 'light', textSize = 'm', className, target, children, blockName = COMPONENT_NAME, } = props;
|
|
31
32
|
const handleMetrika = (0, useMetrika_1.useMetrika)();
|
|
32
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(
|
|
33
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)({
|
|
34
|
+
name: 'link-click',
|
|
35
|
+
type: constants_1.DEFAULT_EVENT_TYPE,
|
|
36
|
+
blockName: blockName,
|
|
37
|
+
});
|
|
33
38
|
const { hostname } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
34
39
|
const { tld } = (0, react_1.useContext)(localeContext_1.LocaleContext);
|
|
35
40
|
const href = (0, utils_1.setUrlTld)(props.url, tld);
|
|
36
41
|
const defaultTextSize = theme === 'back' ? 'l' : 'm';
|
|
37
42
|
const onClick = () => {
|
|
38
43
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
39
|
-
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents
|
|
44
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
|
|
40
45
|
};
|
|
41
46
|
const getLinkByType = () => {
|
|
42
47
|
switch (theme) {
|
|
@@ -14,6 +14,7 @@ const metrikaContext_1 = require("../../context/metrikaContext");
|
|
|
14
14
|
const mobileContext_1 = require("../../context/mobileContext");
|
|
15
15
|
const icons_1 = require("../../icons");
|
|
16
16
|
const hooks_1 = require("../../hooks");
|
|
17
|
+
const constants_1 = require("../../constants");
|
|
17
18
|
const b = (0, utils_1.block)('ReactPlayer');
|
|
18
19
|
const FPS = 60;
|
|
19
20
|
const COMPONENT_NAME = 'react-player';
|
|
@@ -36,7 +37,11 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
|
|
|
36
37
|
const [started, setStarted] = (0, react_1.useState)(autoPlay);
|
|
37
38
|
const [paused, setPaused] = (0, react_1.useState)(false);
|
|
38
39
|
const [ended, setEnded] = (0, react_1.useState)(false);
|
|
39
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(
|
|
40
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)({
|
|
41
|
+
name: 'react-player-controls-click',
|
|
42
|
+
type: constants_1.DEFAULT_EVENT_TYPE,
|
|
43
|
+
blockName: blockName,
|
|
44
|
+
});
|
|
40
45
|
(0, react_1.useImperativeHandle)(originRef, () => ({
|
|
41
46
|
pause: () => setIsPlaying(false),
|
|
42
47
|
}));
|
|
@@ -112,30 +117,14 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
|
|
|
112
117
|
metrika.reachGoals(goal, counterName);
|
|
113
118
|
}
|
|
114
119
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (events) {
|
|
118
|
-
handleAnalytics(events, {
|
|
119
|
-
type: 'react-player-change-mute',
|
|
120
|
-
block: blockName,
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
}
|
|
120
|
+
const events = isMuted ? playEvents : stopEvents;
|
|
121
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(events);
|
|
124
122
|
if (isMuted) {
|
|
125
123
|
setProps({ playingVideoRef: ref.current });
|
|
126
124
|
}
|
|
127
125
|
// In order to the progress bar to update (equals 0) before displaying
|
|
128
126
|
setTimeout(() => setMuted(!isMuted), 0);
|
|
129
|
-
}, [
|
|
130
|
-
playerRef,
|
|
131
|
-
metrika,
|
|
132
|
-
videoMetrika,
|
|
133
|
-
handleAnalytics,
|
|
134
|
-
playEvents,
|
|
135
|
-
stopEvents,
|
|
136
|
-
blockName,
|
|
137
|
-
setProps,
|
|
138
|
-
]);
|
|
127
|
+
}, [playerRef, metrika, videoMetrika, handleAnalytics, playEvents, stopEvents, setProps]);
|
|
139
128
|
const handleClick = (0, react_1.useCallback)(() => changeMute(muted), [changeMute, muted]);
|
|
140
129
|
const handleClickPreview = (0, react_1.useCallback)(() => {
|
|
141
130
|
setIsPlaying(true);
|
|
@@ -146,15 +135,8 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
|
|
|
146
135
|
metrika.reachGoals(play, counterName);
|
|
147
136
|
}
|
|
148
137
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
handleAnalytics(playEvents, {
|
|
152
|
-
type: 'react-player-preview',
|
|
153
|
-
block: blockName,
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}, [onClickPreview, metrika, videoMetrika, handleAnalytics, playEvents, blockName]);
|
|
138
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(playEvents);
|
|
139
|
+
}, [onClickPreview, metrika, videoMetrika, handleAnalytics, playEvents]);
|
|
158
140
|
const onPause = (0, react_1.useCallback)(() => {
|
|
159
141
|
// For support correct state for youtube
|
|
160
142
|
setIsPlaying(false);
|
|
@@ -8,7 +8,8 @@ const localeContext_1 = require("../../context/localeContext");
|
|
|
8
8
|
const mobileContext_1 = require("../../context/mobileContext");
|
|
9
9
|
const utils_1 = require("../../utils");
|
|
10
10
|
const useMetrika_1 = require("../../hooks/useMetrika");
|
|
11
|
-
const hooks_1 = require("
|
|
11
|
+
const hooks_1 = require("../../hooks");
|
|
12
|
+
const constants_2 = require("../../constants");
|
|
12
13
|
exports.YANDEX_FORM_ORIGIN = 'https://forms.yandex.ru';
|
|
13
14
|
const CONTAINER_ID = 'pc-yandex-form-container';
|
|
14
15
|
const COMPONENT_NAME = 'yandex-form';
|
|
@@ -19,7 +20,11 @@ const YandexForm = (props) => {
|
|
|
19
20
|
const iframeRef = (0, react_1.useRef)();
|
|
20
21
|
const yaFormOrigin = customFormOrigin || exports.YANDEX_FORM_ORIGIN;
|
|
21
22
|
const handleMetrika = (0, useMetrika_1.useMetrika)();
|
|
22
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(
|
|
23
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)({
|
|
24
|
+
name: 'yndex-form-submit',
|
|
25
|
+
type: constants_2.DEFAULT_EVENT_TYPE,
|
|
26
|
+
blockName: blockName,
|
|
27
|
+
});
|
|
23
28
|
const isMobile = (0, react_1.useContext)(mobileContext_1.MobileContext);
|
|
24
29
|
const locale = (0, react_1.useContext)(localeContext_1.LocaleContext);
|
|
25
30
|
const updateFormIframe = (0, react_1.useCallback)((container) => {
|
|
@@ -60,11 +65,7 @@ const YandexForm = (props) => {
|
|
|
60
65
|
window.scrollBy(0, top - headerHeight);
|
|
61
66
|
}
|
|
62
67
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
63
|
-
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents
|
|
64
|
-
name: 'default',
|
|
65
|
-
type: 'yandex-form',
|
|
66
|
-
block: blockName,
|
|
67
|
-
});
|
|
68
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
|
|
68
69
|
if (onSubmit) {
|
|
69
70
|
onSubmit();
|
|
70
71
|
}
|
|
@@ -74,7 +75,6 @@ const YandexForm = (props) => {
|
|
|
74
75
|
pixelEvents,
|
|
75
76
|
handleAnalytics,
|
|
76
77
|
analyticsEvents,
|
|
77
|
-
blockName,
|
|
78
78
|
onSubmit,
|
|
79
79
|
headerHeight,
|
|
80
80
|
]);
|
package/build/cjs/constants.d.ts
CHANGED
package/build/cjs/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BREAKPOINTS = void 0;
|
|
3
|
+
exports.DEFAULT_EVENT_TYPE = exports.BREAKPOINTS = void 0;
|
|
4
4
|
exports.BREAKPOINTS = {
|
|
5
5
|
xs: 0,
|
|
6
6
|
sm: 577,
|
|
@@ -8,3 +8,4 @@ exports.BREAKPOINTS = {
|
|
|
8
8
|
lg: 1081,
|
|
9
9
|
xl: 1185,
|
|
10
10
|
};
|
|
11
|
+
exports.DEFAULT_EVENT_TYPE = 'default-event';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AnalyticsEvent } from '../../models';
|
|
3
3
|
export interface AnalyticsContextProps {
|
|
4
|
-
sendEvents?: (e: AnalyticsEvent | AnalyticsEvent[]
|
|
4
|
+
sendEvents?: (e: AnalyticsEvent | AnalyticsEvent[]) => void;
|
|
5
5
|
}
|
|
6
6
|
export declare const AnalyticsContext: React.Context<AnalyticsContextProps>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AnalyticsEvent
|
|
2
|
-
export declare const useAnalytics: () => ((e?: AnalyticsEvent | AnalyticsEvent[]
|
|
1
|
+
import { AnalyticsEvent } from '../models';
|
|
2
|
+
export declare const useAnalytics: (defaultEvent?: AnalyticsEvent) => ((e?: AnalyticsEvent | AnalyticsEvent[]) => void) | undefined;
|
|
@@ -3,16 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useAnalytics = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const analyticsContext_1 = require("../context/analyticsContext");
|
|
6
|
-
const useAnalytics = () => {
|
|
6
|
+
const useAnalytics = (defaultEvent) => {
|
|
7
7
|
const { sendEvents } = (0, react_1.useContext)(analyticsContext_1.AnalyticsContext);
|
|
8
8
|
if (!sendEvents) {
|
|
9
9
|
return undefined;
|
|
10
10
|
}
|
|
11
|
-
return (e
|
|
12
|
-
|
|
11
|
+
return (e) => {
|
|
12
|
+
let events = [];
|
|
13
|
+
if (defaultEvent && e) {
|
|
14
|
+
events = Array.isArray(e) ? [...e, defaultEvent] : [e, defaultEvent];
|
|
15
|
+
}
|
|
16
|
+
else if (e) {
|
|
17
|
+
events = e;
|
|
18
|
+
}
|
|
19
|
+
if (!events) {
|
|
13
20
|
return;
|
|
14
21
|
}
|
|
15
|
-
sendEvents(
|
|
22
|
+
sendEvents(events);
|
|
16
23
|
};
|
|
17
24
|
};
|
|
18
25
|
exports.useAnalytics = useAnalytics;
|
|
@@ -538,6 +538,9 @@ export declare const ButtonProps: {
|
|
|
538
538
|
};
|
|
539
539
|
};
|
|
540
540
|
};
|
|
541
|
+
blockName: {
|
|
542
|
+
type: string;
|
|
543
|
+
};
|
|
541
544
|
};
|
|
542
545
|
} | {
|
|
543
546
|
type: string;
|
|
@@ -573,6 +576,9 @@ export declare const ButtonProps: {
|
|
|
573
576
|
};
|
|
574
577
|
};
|
|
575
578
|
};
|
|
579
|
+
blockName: {
|
|
580
|
+
type: string;
|
|
581
|
+
};
|
|
576
582
|
};
|
|
577
583
|
};
|
|
578
584
|
})[];
|
|
@@ -834,6 +840,9 @@ export declare const ButtonBlock: {
|
|
|
834
840
|
};
|
|
835
841
|
};
|
|
836
842
|
};
|
|
843
|
+
blockName: {
|
|
844
|
+
type: string;
|
|
845
|
+
};
|
|
837
846
|
};
|
|
838
847
|
} | {
|
|
839
848
|
type: string;
|
|
@@ -869,6 +878,9 @@ export declare const ButtonBlock: {
|
|
|
869
878
|
};
|
|
870
879
|
};
|
|
871
880
|
};
|
|
881
|
+
blockName: {
|
|
882
|
+
type: string;
|
|
883
|
+
};
|
|
872
884
|
};
|
|
873
885
|
};
|
|
874
886
|
})[];
|
|
@@ -9,13 +9,18 @@ const useMetrika_1 = require("../../hooks/useMetrika");
|
|
|
9
9
|
const models_1 = require("../../models");
|
|
10
10
|
const hooks_1 = require("../../hooks");
|
|
11
11
|
const HubspotFormContainer_1 = tslib_1.__importDefault(require("./HubspotFormContainer"));
|
|
12
|
+
const constants_1 = require("../../constants");
|
|
12
13
|
const b = (0, utils_1.block)('hubspot-form');
|
|
13
14
|
const HubspotForm = (props) => {
|
|
14
15
|
const { className, theme: themeProp, isMobile: isMobileProp, formId, formInstanceId, portalId, region, formClassName, pixelEvents,
|
|
15
16
|
// hubspotEvents, // TODO: decide how to handle them
|
|
16
17
|
analyticsEvents, onBeforeSubmit, onSubmit, onBeforeLoad, onLoad, blockName = models_1.SubBlockType.HubspotForm, } = props;
|
|
17
18
|
const handleMetrika = (0, useMetrika_1.useMetrika)();
|
|
18
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(
|
|
19
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)({
|
|
20
|
+
name: 'hubspot-form-submit',
|
|
21
|
+
type: constants_1.DEFAULT_EVENT_TYPE,
|
|
22
|
+
blockName: blockName,
|
|
23
|
+
});
|
|
19
24
|
const { themeValue } = (0, react_1.useContext)(ThemeValueContext_1.ThemeValueContext);
|
|
20
25
|
const isMobileValue = (0, react_1.useContext)(mobileContext_1.MobileContext);
|
|
21
26
|
const theme = themeProp !== null && themeProp !== void 0 ? themeProp : themeValue;
|
|
@@ -26,11 +31,7 @@ const HubspotForm = (props) => {
|
|
|
26
31
|
onLoad,
|
|
27
32
|
onSubmit: (e) => {
|
|
28
33
|
handleMetrika === null || handleMetrika === void 0 ? void 0 : handleMetrika({ pixelEvents });
|
|
29
|
-
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents
|
|
30
|
-
name: 'default',
|
|
31
|
-
type: 'hubspot-form',
|
|
32
|
-
block: blockName,
|
|
33
|
-
});
|
|
34
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
|
|
34
35
|
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(e);
|
|
35
36
|
},
|
|
36
37
|
}), [
|
|
@@ -41,7 +42,6 @@ const HubspotForm = (props) => {
|
|
|
41
42
|
pixelEvents,
|
|
42
43
|
handleAnalytics,
|
|
43
44
|
analyticsEvents,
|
|
44
|
-
blockName,
|
|
45
45
|
onSubmit,
|
|
46
46
|
]);
|
|
47
47
|
(0, hooks_1.useHandleHubspotEvents)(handlers, formId);
|
|
@@ -8,19 +8,20 @@ const models_1 = require("../../models");
|
|
|
8
8
|
const components_1 = require("../../components");
|
|
9
9
|
const ThemeValueContext_1 = require("../../context/theme/ThemeValueContext");
|
|
10
10
|
const utils_2 = require("../../components/Media/Image/utils");
|
|
11
|
-
const hooks_1 = require("
|
|
11
|
+
const hooks_1 = require("../../hooks");
|
|
12
|
+
const constants_1 = require("src/constants");
|
|
12
13
|
const b = (0, utils_1.block)('quote');
|
|
13
14
|
const Quote = (props) => {
|
|
14
15
|
const { theme: textTheme = 'light', color, image, border = 'shadow', text, logo, author, url, buttonText, blockName = models_1.SubBlockType.Quote, } = props;
|
|
15
16
|
const { themeValue: theme } = (0, react_1.useContext)(ThemeValueContext_1.ThemeValueContext);
|
|
16
17
|
const imageThemed = (0, utils_1.getThemedValue)(image, theme);
|
|
17
18
|
const imageData = (0, utils_2.getMediaImage)(imageThemed);
|
|
18
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)({
|
|
20
|
+
name: 'quote-button-click',
|
|
21
|
+
type: constants_1.DEFAULT_EVENT_TYPE,
|
|
22
|
+
blockName: blockName,
|
|
23
|
+
});
|
|
24
|
+
const handleButtonClick = (0, react_1.useCallback)(() => handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(), [handleAnalytics]);
|
|
24
25
|
const renderFooter = Boolean(author || url) && (react_1.default.createElement("div", { className: b('author-wrapper') },
|
|
25
26
|
author && (react_1.default.createElement(components_1.Author, { className: b('author', { theme: textTheme }), author: author, type: models_1.AuthorType.Line })),
|
|
26
27
|
url && buttonText && (react_1.default.createElement(uikit_1.Button, { view: "outlined", size: "xl", href: url, className: b('link-button', { theme: textTheme }), onClick: handleButtonClick }, buttonText))));
|