@gravity-ui/blog-constructor 3.4.0 → 3.5.0-alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +7 -0
- package/build/cjs/components/PostInfo/components/Save.js +6 -1
- package/build/cjs/components/Prompt/Prompt.css +61 -0
- package/build/cjs/components/Prompt/Prompt.d.ts +18 -0
- package/build/cjs/components/Prompt/Prompt.js +41 -0
- package/build/cjs/components/PromptSignIn/PromptSignIn.d.ts +10 -0
- package/build/cjs/components/PromptSignIn/PromptSignIn.js +34 -0
- package/build/cjs/components/PromptSignIn/hooks/usePromptSignInProps.d.ts +6 -0
- package/build/cjs/components/PromptSignIn/hooks/usePromptSignInProps.js +16 -0
- package/build/cjs/containers/BlogPage/BlogPage.d.ts +4 -1
- package/build/cjs/containers/BlogPage/BlogPage.js +56 -18
- package/build/cjs/contexts/LikesContext.d.ts +2 -0
- package/build/cjs/counters/metrika.d.ts +62 -0
- package/build/cjs/counters/metrika.js +173 -0
- package/build/cjs/hooks/useOpenCloseTimer.d.ts +9 -0
- package/build/cjs/hooks/useOpenCloseTimer.js +30 -0
- package/build/cjs/i18n/index.d.ts +3 -1
- package/build/cjs/i18n/index.js +6 -0
- package/build/esm/components/PostInfo/components/Save.js +6 -1
- package/build/esm/components/Prompt/Prompt.css +61 -0
- package/build/esm/components/Prompt/Prompt.d.ts +19 -0
- package/build/esm/components/Prompt/Prompt.js +35 -0
- package/build/esm/components/PromptSignIn/PromptSignIn.d.ts +10 -0
- package/build/esm/components/PromptSignIn/PromptSignIn.js +27 -0
- package/build/esm/components/PromptSignIn/hooks/usePromptSignInProps.d.ts +6 -0
- package/build/esm/components/PromptSignIn/hooks/usePromptSignInProps.js +12 -0
- package/build/esm/containers/BlogPage/BlogPage.d.ts +4 -1
- package/build/esm/containers/BlogPage/BlogPage.js +33 -18
- package/build/esm/contexts/LikesContext.d.ts +2 -0
- package/build/esm/counters/metrika.d.ts +62 -0
- package/build/esm/counters/metrika.js +169 -0
- package/build/esm/hooks/useOpenCloseTimer.d.ts +9 -0
- package/build/esm/hooks/useOpenCloseTimer.js +26 -0
- package/build/esm/i18n/index.d.ts +3 -1
- package/build/esm/i18n/index.js +6 -0
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [3.4.1](https://github.com/gravity-ui/blog-constructor/compare/v3.4.0...v3.4.1) (2023-05-30)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* return js, jsx files to gulpfile.js ([#58](https://github.com/gravity-ui/blog-constructor/issues/58)) ([d5e4c42](https://github.com/gravity-ui/blog-constructor/commit/d5e4c428e8eae56fd7ab381c2969c04955adc45b))
|
9
|
+
|
3
10
|
## [3.4.0](https://github.com/gravity-ui/blog-constructor/compare/v3.3.0...v3.4.0) (2023-05-24)
|
4
11
|
|
5
12
|
|
@@ -53,7 +53,7 @@ const b = (0, cn_1.block)('post-info');
|
|
53
53
|
* @returns jsx
|
54
54
|
*/
|
55
55
|
const Save = ({ title, postId, hasUserLike, handleUserLike, metrikaGoal, size, theme, dataQa, }) => {
|
56
|
-
const { toggleLike } = (0, react_1.useContext)(LikesContext_1.LikesContext);
|
56
|
+
const { toggleLike, isSignedInUser, requireSignIn } = (0, react_1.useContext)(LikesContext_1.LikesContext);
|
57
57
|
const handleAnalytics = (0, page_constructor_1.useAnalytics)(common_1.DefaultEventNames.SaveButton);
|
58
58
|
const isLikeable = Boolean(toggleLike);
|
59
59
|
return (react_1.default.createElement("div", { className: b('item', { size }), onClick: (event) => {
|
@@ -64,6 +64,11 @@ const Save = ({ title, postId, hasUserLike, handleUserLike, metrikaGoal, size, t
|
|
64
64
|
if (!isLikeable) {
|
65
65
|
return;
|
66
66
|
}
|
67
|
+
// Open Popup to ask the User to sign in first
|
68
|
+
if (!isSignedInUser && requireSignIn) {
|
69
|
+
requireSignIn(event);
|
70
|
+
return;
|
71
|
+
}
|
67
72
|
(0, common_2.postLikeStatus)(postId, Boolean(hasUserLike));
|
68
73
|
handleUserLike();
|
69
74
|
metrika_js_1.default.reachGoal(utils_1.MetrikaCounter.CrossSite, metrikaGoal);
|
@@ -0,0 +1,61 @@
|
|
1
|
+
.bc-prompt__content {
|
2
|
+
box-shadow: 0px 4px 24px var(--pc-color-sfx-shadow), 0px 2px 8px var(--pc-color-sfx-shadow);
|
3
|
+
}
|
4
|
+
|
5
|
+
/* use this for style redefinitions to awoid problems with
|
6
|
+
unpredictable css rules order in build */
|
7
|
+
@keyframes bc-prompt_open {
|
8
|
+
0% {
|
9
|
+
opacity: 0;
|
10
|
+
transform: translateY(100%);
|
11
|
+
}
|
12
|
+
100% {
|
13
|
+
opacity: 1;
|
14
|
+
transform: translateY(0%);
|
15
|
+
}
|
16
|
+
}
|
17
|
+
@keyframes bc-prompt_close {
|
18
|
+
0% {
|
19
|
+
opacity: 1;
|
20
|
+
transform: translateY(0%);
|
21
|
+
}
|
22
|
+
100% {
|
23
|
+
opacity: 0;
|
24
|
+
transform: translateY(100%);
|
25
|
+
}
|
26
|
+
}
|
27
|
+
.bc-prompt {
|
28
|
+
display: flex;
|
29
|
+
width: 100%;
|
30
|
+
justify-content: center;
|
31
|
+
overflow: hidden;
|
32
|
+
position: fixed;
|
33
|
+
bottom: 0;
|
34
|
+
}
|
35
|
+
.bc-prompt:not(.bc-prompt_mounted) {
|
36
|
+
display: none;
|
37
|
+
}
|
38
|
+
.bc-prompt__content {
|
39
|
+
display: flex;
|
40
|
+
flex-flow: row wrap;
|
41
|
+
gap: 16px;
|
42
|
+
align-items: center;
|
43
|
+
margin: 24px;
|
44
|
+
padding: 16px 20px;
|
45
|
+
border-radius: var(--pc-border-radius);
|
46
|
+
background-color: var(--yc-color-base-float);
|
47
|
+
font-size: 1rem;
|
48
|
+
}
|
49
|
+
.bc-prompt_close {
|
50
|
+
pointer-events: none;
|
51
|
+
}
|
52
|
+
.bc-prompt_open > .bc-prompt__content {
|
53
|
+
opacity: 0;
|
54
|
+
transform: translateY(100%);
|
55
|
+
animation: bc-prompt_open 600ms forwards;
|
56
|
+
}
|
57
|
+
.bc-prompt_close > .bc-prompt__content {
|
58
|
+
opacity: 1;
|
59
|
+
transform: translateY(0%);
|
60
|
+
animation: bc-prompt_close 600ms forwards;
|
61
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { ButtonProps } from '@gravity-ui/uikit';
|
3
|
+
export interface PromptProps {
|
4
|
+
text: string;
|
5
|
+
actions: ButtonProps[];
|
6
|
+
openTimestamp?: number;
|
7
|
+
openDuration?: number;
|
8
|
+
className?: string;
|
9
|
+
theme?: 'grey' | 'beige' | 'white';
|
10
|
+
}
|
11
|
+
/**
|
12
|
+
* Popup that appears with text message and button(s) for given `actions`.
|
13
|
+
* Features:
|
14
|
+
* - Automatically disappears after `openDuration` in milliseconds
|
15
|
+
* - `openTimestamp` (`Date.now()`) resets the visible duration
|
16
|
+
* @returns {JSX|null}
|
17
|
+
*/
|
18
|
+
export declare const Prompt: React.FC<PromptProps>;
|
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
3
|
+
var t = {};
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
5
|
+
t[p] = s[p];
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
9
|
+
t[p[i]] = s[p[i]];
|
10
|
+
}
|
11
|
+
return t;
|
12
|
+
};
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
exports.Prompt = void 0;
|
18
|
+
const react_1 = __importDefault(require("react"));
|
19
|
+
const uikit_1 = require("@gravity-ui/uikit");
|
20
|
+
const useOpenCloseTimer_1 = require("../../hooks/useOpenCloseTimer");
|
21
|
+
const cn_1 = require("../../utils/cn");
|
22
|
+
const b = (0, cn_1.block)('prompt');
|
23
|
+
/**
|
24
|
+
* Popup that appears with text message and button(s) for given `actions`.
|
25
|
+
* Features:
|
26
|
+
* - Automatically disappears after `openDuration` in milliseconds
|
27
|
+
* - `openTimestamp` (`Date.now()`) resets the visible duration
|
28
|
+
* @returns {JSX|null}
|
29
|
+
*/
|
30
|
+
const Prompt = ({ text, actions, className, openTimestamp = 0, openDuration, theme, }) => {
|
31
|
+
const { open } = (0, useOpenCloseTimer_1.useOpenCloseTimer)(openTimestamp, openDuration);
|
32
|
+
const mounted = openTimestamp > 0;
|
33
|
+
return (react_1.default.createElement("div", { className: b({ theme, open, close: !open, mounted }, className) },
|
34
|
+
react_1.default.createElement("div", { className: b('content') },
|
35
|
+
react_1.default.createElement("span", { className: b('text') }, text),
|
36
|
+
react_1.default.createElement("div", { className: b('actions') }, actions.map((_a, i) => {
|
37
|
+
var { view = 'action', className: btnClass } = _a, btnProps = __rest(_a, ["view", "className"]);
|
38
|
+
return (react_1.default.createElement(uikit_1.Button, Object.assign({ key: i, className: b('action', btnClass), view: view }, btnProps)));
|
39
|
+
})))));
|
40
|
+
};
|
41
|
+
exports.Prompt = Prompt;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import React, { SyntheticEvent } from 'react';
|
2
|
+
import { PromptProps } from '../Prompt/Prompt';
|
3
|
+
export interface PromptSignInProps extends Partial<PromptProps> {
|
4
|
+
onClickSignIn?: React.EventHandler<SyntheticEvent>;
|
5
|
+
}
|
6
|
+
/**
|
7
|
+
* Authentication Popup that appears when user action requires login
|
8
|
+
* @returns {JSX|null}
|
9
|
+
*/
|
10
|
+
export declare const PromptSignIn: React.FC<PromptSignInProps>;
|
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
3
|
+
var t = {};
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
5
|
+
t[p] = s[p];
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
9
|
+
t[p[i]] = s[p[i]];
|
10
|
+
}
|
11
|
+
return t;
|
12
|
+
};
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
exports.PromptSignIn = void 0;
|
18
|
+
const react_1 = __importDefault(require("react"));
|
19
|
+
const i18n_1 = require("../../i18n");
|
20
|
+
const Prompt_1 = require("../Prompt/Prompt");
|
21
|
+
/**
|
22
|
+
* Authentication Popup that appears when user action requires login
|
23
|
+
* @returns {JSX|null}
|
24
|
+
*/
|
25
|
+
const PromptSignIn = (_a) => {
|
26
|
+
var { text = (0, i18n_1.i18)(i18n_1.Keyset.PromptSignInOnLike), onClickSignIn = () => alert((0, i18n_1.i18)(i18n_1.Keyset.SignIn)), actions = [
|
27
|
+
{
|
28
|
+
children: (0, i18n_1.i18)(i18n_1.Keyset.SignIn),
|
29
|
+
onClick: onClickSignIn,
|
30
|
+
},
|
31
|
+
] } = _a, props = __rest(_a, ["text", "onClickSignIn", "actions"]);
|
32
|
+
return react_1.default.createElement(Prompt_1.Prompt, Object.assign({}, { text, actions }, props));
|
33
|
+
};
|
34
|
+
exports.PromptSignIn = PromptSignIn;
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import React, { SyntheticEvent } from 'react';
|
2
|
+
export declare function usePromptSignInProps(onClickSignIn?: React.EventHandler<SyntheticEvent>): {
|
3
|
+
onClickSignIn: ((event: React.SyntheticEvent<Element, Event>) => void) | undefined;
|
4
|
+
openTimestamp: number;
|
5
|
+
requireSignIn: (() => void) | undefined;
|
6
|
+
};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.usePromptSignInProps = void 0;
|
4
|
+
const react_1 = require("react");
|
5
|
+
function usePromptSignInProps(onClickSignIn) {
|
6
|
+
const [openTimestamp, setTime] = (0, react_1.useState)(0);
|
7
|
+
const requireSignIn = (0, react_1.useMemo)(() => {
|
8
|
+
return onClickSignIn
|
9
|
+
? () => {
|
10
|
+
setTime(Date.now());
|
11
|
+
}
|
12
|
+
: undefined;
|
13
|
+
}, [onClickSignIn, setTime]);
|
14
|
+
return { onClickSignIn, openTimestamp, requireSignIn };
|
15
|
+
}
|
16
|
+
exports.usePromptSignInProps = usePromptSignInProps;
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import React, { SyntheticEvent } from 'react';
|
1
2
|
import { NavigationData, PageConstructorProviderProps, PageContent } from '@gravity-ui/page-constructor';
|
2
3
|
import { GetPostsType, MetaProps, PostsProps, Service, SetQueryType, Tag, ToggleLikeCallbackType } from '../../models/common';
|
3
4
|
export type BlogPageProps = {
|
@@ -13,5 +14,7 @@ export type BlogPageProps = {
|
|
13
14
|
setQuery?: SetQueryType;
|
14
15
|
settings?: PageConstructorProviderProps;
|
15
16
|
pageCountForShowSupportButtons?: number;
|
17
|
+
isSignedInUser?: boolean;
|
18
|
+
onClickSignIn?: React.EventHandler<SyntheticEvent>;
|
16
19
|
};
|
17
|
-
export declare const BlogPage: ({ content, posts, tags, services, getPosts, metaData, hasLikes, toggleLike, navigation, settings, pageCountForShowSupportButtons, }: BlogPageProps) => JSX.Element;
|
20
|
+
export declare const BlogPage: ({ content, posts, tags, services, getPosts, metaData, hasLikes, toggleLike, navigation, settings, pageCountForShowSupportButtons, isSignedInUser, onClickSignIn, }: BlogPageProps) => JSX.Element;
|
@@ -1,30 +1,68 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
26
|
+
var t = {};
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
28
|
+
t[p] = s[p];
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
32
|
+
t[p[i]] = s[p[i]];
|
33
|
+
}
|
34
|
+
return t;
|
35
|
+
};
|
2
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
38
|
};
|
5
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
40
|
exports.BlogPage = void 0;
|
7
|
-
const react_1 =
|
41
|
+
const react_1 = __importStar(require("react"));
|
8
42
|
const page_constructor_1 = require("@gravity-ui/page-constructor");
|
9
43
|
const MetaWrapper_1 = require("../../components/MetaWrapper/MetaWrapper");
|
44
|
+
const PromptSignIn_1 = require("../../components/PromptSignIn/PromptSignIn");
|
45
|
+
const usePromptSignInProps_1 = require("../../components/PromptSignIn/hooks/usePromptSignInProps");
|
10
46
|
const blocksMap_1 = __importDefault(require("../../constructor/blocksMap"));
|
11
47
|
const FeedContext_1 = require("../../contexts/FeedContext");
|
12
48
|
const LikesContext_1 = require("../../contexts/LikesContext");
|
13
|
-
const BlogPage = ({ content, posts, tags, services, getPosts, metaData, hasLikes = false, toggleLike, navigation, settings, pageCountForShowSupportButtons, }) =>
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
49
|
+
const BlogPage = ({ content, posts, tags, services, getPosts, metaData, hasLikes = false, toggleLike, navigation, settings, pageCountForShowSupportButtons, isSignedInUser = false, onClickSignIn, }) => {
|
50
|
+
const _a = (0, usePromptSignInProps_1.usePromptSignInProps)(onClickSignIn), { requireSignIn } = _a, promptSignInProps = __rest(_a, ["requireSignIn"]);
|
51
|
+
const likes = (0, react_1.useMemo)(() => ({ toggleLike, hasLikes, isSignedInUser, requireSignIn }), [toggleLike, hasLikes, isSignedInUser, requireSignIn]);
|
52
|
+
return (react_1.default.createElement("main", null,
|
53
|
+
react_1.default.createElement(LikesContext_1.LikesContext.Provider, { value: likes },
|
54
|
+
react_1.default.createElement(FeedContext_1.FeedContext.Provider, { value: {
|
55
|
+
posts: posts.posts,
|
56
|
+
pinnedPost: posts.pinnedPost,
|
57
|
+
totalCount: posts.count,
|
58
|
+
tags,
|
59
|
+
services: services !== null && services !== void 0 ? services : [],
|
60
|
+
getPosts,
|
61
|
+
pageCountForShowSupportButtons,
|
62
|
+
} },
|
63
|
+
react_1.default.createElement(page_constructor_1.PageConstructorProvider, Object.assign({}, settings),
|
64
|
+
metaData ? react_1.default.createElement(MetaWrapper_1.MetaWrapper, Object.assign({}, metaData)) : null,
|
65
|
+
react_1.default.createElement(page_constructor_1.PageConstructor, { content: content, custom: blocksMap_1.default, navigation: navigation })))),
|
66
|
+
react_1.default.createElement(PromptSignIn_1.PromptSignIn, Object.assign({}, promptSignInProps))));
|
67
|
+
};
|
30
68
|
exports.BlogPage = BlogPage;
|
@@ -3,5 +3,7 @@ import { ToggleLikeCallbackType } from '../models/common';
|
|
3
3
|
export interface LikesContextProps {
|
4
4
|
toggleLike?: ToggleLikeCallbackType;
|
5
5
|
hasLikes?: boolean;
|
6
|
+
isSignedInUser?: boolean;
|
7
|
+
requireSignIn?: React.MouseEventHandler;
|
6
8
|
}
|
7
9
|
export declare const LikesContext: React.Context<LikesContextProps>;
|
@@ -0,0 +1,62 @@
|
|
1
|
+
export function initCounters(configs: any): void;
|
2
|
+
declare namespace _default {
|
3
|
+
export { hit };
|
4
|
+
export { params };
|
5
|
+
export { reachGoal };
|
6
|
+
export { reachGoals };
|
7
|
+
export { Goal };
|
8
|
+
export { getServicePrefix };
|
9
|
+
export { getMarketPlacePrefix };
|
10
|
+
export { goalGoToConsole };
|
11
|
+
export { goalGoToForm };
|
12
|
+
export { goalGoToDocs };
|
13
|
+
export { goalFormSubmit };
|
14
|
+
export { goalEventFormSubmit };
|
15
|
+
export { goalEventVideoAction };
|
16
|
+
export { goalCaseFormSubmit };
|
17
|
+
export { goalSwitchLang };
|
18
|
+
}
|
19
|
+
export default _default;
|
20
|
+
declare function hit(...args: any[]): void;
|
21
|
+
declare function params(...args: any[]): void;
|
22
|
+
declare function reachGoal(counterName: any, ...args: any[]): void;
|
23
|
+
declare function reachGoals(goals: any, counterName?: string): void;
|
24
|
+
/**
|
25
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
26
|
+
*/
|
27
|
+
declare const Goal: {
|
28
|
+
SUPPORT_OPEN_FORM: string;
|
29
|
+
SUPPORT_STEP_1_SUBMIT: string;
|
30
|
+
SUPPORT_STEP_2_SUBMIT: string;
|
31
|
+
SUPPORT_STEP_3_SUBMIT: string;
|
32
|
+
SUPPORT_THANKYOU_SUBMIT: string;
|
33
|
+
MP_OPEN_FORM: string;
|
34
|
+
EDIT_ON_GITHUB: string;
|
35
|
+
MAIN_GO_TO_VAR: string;
|
36
|
+
MAIN_GO_TO_ISV: string;
|
37
|
+
MAIN_ALL_PARTNERS: string;
|
38
|
+
FIND_GO_TO_VAR: string;
|
39
|
+
ISV_GO_TO_MP: string;
|
40
|
+
FOOTER_SUBSCRIBE: string;
|
41
|
+
FOOTER_MNG_SUBSCRIPTIONS: string;
|
42
|
+
MOBILE_STORE_IOS: string;
|
43
|
+
MOBILE_STORE_ANDROID: string;
|
44
|
+
REGION_POPUP_SHOW: string;
|
45
|
+
REGION_POPUP_YES: string;
|
46
|
+
REGION_POPUP_NO: string;
|
47
|
+
REGION_POPUP_CLOSE: string;
|
48
|
+
SCALE_REGISTRATION: string;
|
49
|
+
DLGOTOPRODUCT_MPSITE: string;
|
50
|
+
MPK8S_CLCK: string;
|
51
|
+
'SITE_CALCULATOR_SHARE-RESULT_CLICK': string;
|
52
|
+
};
|
53
|
+
declare function getServicePrefix(id: any): "CMPT" | "IAM" | "VPC" | "STRG" | "SK" | "CH" | "MONGO" | "POSTGR" | "MR" | "MMSQL" | "MK" | "TRSL" | "INSTGR" | "LB" | "MQ" | "DL" | "MNTRG" | "DP" | "KMS" | "YDB" | "INTRCNCT" | undefined;
|
54
|
+
declare function getMarketPlacePrefix(id: any): string;
|
55
|
+
declare function goalGoToConsole(prefix: any): any;
|
56
|
+
declare function goalGoToForm(prefix: any): any;
|
57
|
+
declare function goalGoToDocs(prefix: any): any;
|
58
|
+
declare function goalFormSubmit(prefix: any): any;
|
59
|
+
declare function goalEventFormSubmit(id: any): string;
|
60
|
+
declare function goalEventVideoAction(id: any, action: any): string;
|
61
|
+
declare function goalCaseFormSubmit(id: any): string;
|
62
|
+
declare function goalSwitchLang(place: any): string;
|
@@ -0,0 +1,173 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.initCounters = void 0;
|
4
|
+
/**
|
5
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
6
|
+
*/
|
7
|
+
const Goal = {
|
8
|
+
SUPPORT_OPEN_FORM: 'SUPPORTOPENFORM',
|
9
|
+
SUPPORT_STEP_1_SUBMIT: 'SUPPORTSTEP1SUBMIT',
|
10
|
+
SUPPORT_STEP_2_SUBMIT: 'SUPPORTSTEP2SUBMIT',
|
11
|
+
SUPPORT_STEP_3_SUBMIT: 'SUPPORTSTEP3SUBMIT',
|
12
|
+
SUPPORT_THANKYOU_SUBMIT: 'SUPPORTTHANKYOUSUBMIT',
|
13
|
+
MP_OPEN_FORM: 'MPOPENFORM',
|
14
|
+
EDIT_ON_GITHUB: 'EDITONGITHUB',
|
15
|
+
MAIN_GO_TO_VAR: 'MAINGOTOVAR',
|
16
|
+
MAIN_GO_TO_ISV: 'MAINGOTOISV',
|
17
|
+
MAIN_ALL_PARTNERS: 'MAINALLPARTNERS',
|
18
|
+
FIND_GO_TO_VAR: 'FINDGOTOVAR',
|
19
|
+
ISV_GO_TO_MP: 'ISVGOTOMP',
|
20
|
+
FOOTER_SUBSCRIBE: 'FOOTERSUBSCRIBE',
|
21
|
+
FOOTER_MNG_SUBSCRIPTIONS: 'FOOTERMNGSUBSCRIPTIONS',
|
22
|
+
MOBILE_STORE_IOS: '154_Mobile_App_Store_Badge',
|
23
|
+
MOBILE_STORE_ANDROID: '155_Mobile_Google_Play_Badge',
|
24
|
+
REGION_POPUP_SHOW: 'REGIONPOPUP',
|
25
|
+
REGION_POPUP_YES: 'REGIONPOPUPYES',
|
26
|
+
REGION_POPUP_NO: 'REGIONPOPUPNO',
|
27
|
+
REGION_POPUP_CLOSE: 'REGIONPOPUPCLOSE',
|
28
|
+
SCALE_REGISTRATION: 'Scale_registration',
|
29
|
+
DLGOTOPRODUCT_MPSITE: 'DLGOTOPRODUCT_MPSITE',
|
30
|
+
MPK8S_CLCK: 'MPK8S_CLCK',
|
31
|
+
'SITE_CALCULATOR_SHARE-RESULT_CLICK': 'SITE_CALCULATOR_SHARE-RESULT_CLICK',
|
32
|
+
};
|
33
|
+
const HIT_COUNTERS = ['main', 'cross-site', 'scale'];
|
34
|
+
const counterIds = {};
|
35
|
+
function getCounter(name) {
|
36
|
+
const counterId = counterIds[name];
|
37
|
+
return window['yaCounter' + counterId];
|
38
|
+
}
|
39
|
+
function initCounters(configs) {
|
40
|
+
configs.forEach((config) => {
|
41
|
+
counterIds[config.name] = config.id;
|
42
|
+
});
|
43
|
+
}
|
44
|
+
exports.initCounters = initCounters;
|
45
|
+
function hit(...args) {
|
46
|
+
HIT_COUNTERS.forEach((counterName) => {
|
47
|
+
const counter = getCounter(counterName);
|
48
|
+
if (!counter) {
|
49
|
+
return;
|
50
|
+
}
|
51
|
+
counter.hit(...args);
|
52
|
+
});
|
53
|
+
}
|
54
|
+
function params(...args) {
|
55
|
+
const counter = getCounter('main');
|
56
|
+
if (!counter) {
|
57
|
+
return;
|
58
|
+
}
|
59
|
+
counter.params(...args);
|
60
|
+
}
|
61
|
+
function reachGoal(counterName, ...args) {
|
62
|
+
const counter = getCounter(counterName);
|
63
|
+
if (!counter) {
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
counter.reachGoal(...args);
|
67
|
+
}
|
68
|
+
function reachGoals(goals, counterName = 'main') {
|
69
|
+
if (!goals) {
|
70
|
+
return;
|
71
|
+
}
|
72
|
+
const goalsArray = Array.isArray(goals) ? goals : [goals];
|
73
|
+
goalsArray.forEach((goal) => {
|
74
|
+
if (typeof goal === 'object') {
|
75
|
+
reachGoal(counterName, goal.name, goal.params);
|
76
|
+
}
|
77
|
+
else {
|
78
|
+
reachGoal(counterName, goal);
|
79
|
+
}
|
80
|
+
});
|
81
|
+
}
|
82
|
+
// eslint-disable-next-line complexity
|
83
|
+
function getServicePrefix(id) {
|
84
|
+
switch (id) {
|
85
|
+
case 'compute':
|
86
|
+
return 'CMPT';
|
87
|
+
case 'iam':
|
88
|
+
return 'IAM';
|
89
|
+
case 'vpc':
|
90
|
+
return 'VPC';
|
91
|
+
case 'storage':
|
92
|
+
return 'STRG';
|
93
|
+
case 'speechkit':
|
94
|
+
return 'SK';
|
95
|
+
case 'managed-clickhouse':
|
96
|
+
return 'CH';
|
97
|
+
case 'managed-mongodb':
|
98
|
+
return 'MONGO';
|
99
|
+
case 'managed-postgresql':
|
100
|
+
return 'POSTGR';
|
101
|
+
case 'managed-redis':
|
102
|
+
return 'MR';
|
103
|
+
case 'managed-mysql':
|
104
|
+
return 'MMSQL';
|
105
|
+
case 'managed-kubernetes':
|
106
|
+
return 'MK';
|
107
|
+
case 'translate':
|
108
|
+
return 'TRSL';
|
109
|
+
case 'instance-groups':
|
110
|
+
return 'INSTGR';
|
111
|
+
case 'load-balancer':
|
112
|
+
return 'LB';
|
113
|
+
case 'message-queue':
|
114
|
+
return 'MQ';
|
115
|
+
case 'datalens':
|
116
|
+
return 'DL';
|
117
|
+
case 'monitoring':
|
118
|
+
return 'MNTRG';
|
119
|
+
case 'data-proc':
|
120
|
+
return 'DP';
|
121
|
+
case 'kms':
|
122
|
+
return 'KMS';
|
123
|
+
case 'ydb':
|
124
|
+
return 'YDB';
|
125
|
+
case 'interconnect':
|
126
|
+
return 'INTRCNCT';
|
127
|
+
}
|
128
|
+
return undefined;
|
129
|
+
}
|
130
|
+
function getMarketPlacePrefix(id) {
|
131
|
+
return `product_${id}_`;
|
132
|
+
}
|
133
|
+
function goalGoToConsole(prefix) {
|
134
|
+
return prefix && `${prefix}GOTOCONSOLE`;
|
135
|
+
}
|
136
|
+
function goalGoToForm(prefix) {
|
137
|
+
return prefix && `${prefix}GOTOFORM`;
|
138
|
+
}
|
139
|
+
function goalGoToDocs(prefix) {
|
140
|
+
return prefix && `${prefix}GOTODOCS`;
|
141
|
+
}
|
142
|
+
function goalFormSubmit(prefix) {
|
143
|
+
return prefix && `${prefix}FORMSUBMIT`;
|
144
|
+
}
|
145
|
+
function goalEventFormSubmit(id) {
|
146
|
+
return `event${id || 's'}_form_submit`;
|
147
|
+
}
|
148
|
+
function goalEventVideoAction(id, action) {
|
149
|
+
return `event${id}_video_${action}`;
|
150
|
+
}
|
151
|
+
function goalCaseFormSubmit(id) {
|
152
|
+
return `case${id ? `_${id}` : 's'}_form_submit`;
|
153
|
+
}
|
154
|
+
function goalSwitchLang(place) {
|
155
|
+
return `SWITCH_LANG_${place}`;
|
156
|
+
}
|
157
|
+
exports.default = {
|
158
|
+
hit,
|
159
|
+
params,
|
160
|
+
reachGoal,
|
161
|
+
reachGoals,
|
162
|
+
Goal,
|
163
|
+
getServicePrefix,
|
164
|
+
getMarketPlacePrefix,
|
165
|
+
goalGoToConsole,
|
166
|
+
goalGoToForm,
|
167
|
+
goalGoToDocs,
|
168
|
+
goalFormSubmit,
|
169
|
+
goalEventFormSubmit,
|
170
|
+
goalEventVideoAction,
|
171
|
+
goalCaseFormSubmit,
|
172
|
+
goalSwitchLang,
|
173
|
+
};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* Timer to automatically update `open` state after a given duration
|
3
|
+
* @param {number} openTimestamp - UNIX timestamp in milliseconds
|
4
|
+
* @param {number} openDuration - in milliseconds
|
5
|
+
* @returns {{open: boolean}} {open} - whether the state is open
|
6
|
+
*/
|
7
|
+
export declare function useOpenCloseTimer(openTimestamp?: number, openDuration?: number): {
|
8
|
+
open: boolean;
|
9
|
+
};
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.useOpenCloseTimer = void 0;
|
4
|
+
const react_1 = require("react");
|
5
|
+
/**
|
6
|
+
* Timer to automatically update `open` state after a given duration
|
7
|
+
* @param {number} openTimestamp - UNIX timestamp in milliseconds
|
8
|
+
* @param {number} openDuration - in milliseconds
|
9
|
+
* @returns {{open: boolean}} {open} - whether the state is open
|
10
|
+
*/
|
11
|
+
function useOpenCloseTimer(openTimestamp = Date.now(), openDuration = 4000) {
|
12
|
+
const open = Date.now() - openTimestamp < openDuration;
|
13
|
+
const [, reset] = (0, react_1.useState)(0); // time to reset `open` state
|
14
|
+
(0, react_1.useEffect)(() => {
|
15
|
+
const closeTime = openTimestamp + openDuration;
|
16
|
+
const delay = closeTime - Date.now();
|
17
|
+
if (delay <= 0) {
|
18
|
+
return;
|
19
|
+
}
|
20
|
+
const timer = setTimeout(() => {
|
21
|
+
reset(Date.now);
|
22
|
+
}, delay);
|
23
|
+
// eslint-disable-next-line consistent-return
|
24
|
+
return () => {
|
25
|
+
clearTimeout(timer);
|
26
|
+
};
|
27
|
+
}, [openTimestamp, openDuration]);
|
28
|
+
return { open };
|
29
|
+
}
|
30
|
+
exports.useOpenCloseTimer = useOpenCloseTimer;
|
@@ -17,6 +17,8 @@ export declare enum Keyset {
|
|
17
17
|
Search = "search_placeholder",
|
18
18
|
AllTags = "label_all_tags",
|
19
19
|
ActionSavedOnly = "action_saved_only",
|
20
|
-
AllServices = "label_all_services"
|
20
|
+
AllServices = "label_all_services",
|
21
|
+
PromptSignInOnLike = "prompt_sign_in_on_like",
|
22
|
+
SignIn = "Sign In"
|
21
23
|
}
|
22
24
|
export declare const i18: (key: string, params?: import("@gravity-ui/i18n").Params | undefined) => string;
|
package/build/cjs/i18n/index.js
CHANGED
@@ -24,6 +24,8 @@ var Keyset;
|
|
24
24
|
Keyset["AllTags"] = "label_all_tags";
|
25
25
|
Keyset["ActionSavedOnly"] = "action_saved_only";
|
26
26
|
Keyset["AllServices"] = "label_all_services";
|
27
|
+
Keyset["PromptSignInOnLike"] = "prompt_sign_in_on_like";
|
28
|
+
Keyset["SignIn"] = "Sign In";
|
27
29
|
})(Keyset = exports.Keyset || (exports.Keyset = {}));
|
28
30
|
exports.i18n.registerKeyset(locale_1.Lang.En, KEYSET_NAME, {
|
29
31
|
[Keyset.Title]: 'Blog',
|
@@ -42,11 +44,13 @@ exports.i18n.registerKeyset(locale_1.Lang.En, KEYSET_NAME, {
|
|
42
44
|
[Keyset.AllTags]: 'All topics',
|
43
45
|
[Keyset.ActionSavedOnly]: 'Saved',
|
44
46
|
[Keyset.AllServices]: 'All Services',
|
47
|
+
[Keyset.PromptSignInOnLike]: 'Please sign in to save your bookmarks',
|
45
48
|
[Keyset.ContextReadingTime]: [
|
46
49
|
'{{count}} min to read',
|
47
50
|
'{{count}} mins to read',
|
48
51
|
'{{count}} mins to read',
|
49
52
|
],
|
53
|
+
[Keyset.SignIn]: 'Sign In',
|
50
54
|
});
|
51
55
|
exports.i18n.registerKeyset(locale_1.Lang.Ru, KEYSET_NAME, {
|
52
56
|
[Keyset.Title]: 'Блог',
|
@@ -65,10 +69,12 @@ exports.i18n.registerKeyset(locale_1.Lang.Ru, KEYSET_NAME, {
|
|
65
69
|
[Keyset.AllTags]: 'Все темы',
|
66
70
|
[Keyset.ActionSavedOnly]: 'Сохранённые',
|
67
71
|
[Keyset.AllServices]: 'Все сервисы',
|
72
|
+
[Keyset.PromptSignInOnLike]: 'Войдите, чтобы добавить доклад в своё расписание',
|
68
73
|
[Keyset.ContextReadingTime]: [
|
69
74
|
'{{count}} минута чтения',
|
70
75
|
'{{count}} минуты чтения',
|
71
76
|
'{{count}} минут чтения',
|
72
77
|
],
|
78
|
+
[Keyset.SignIn]: 'Войти',
|
73
79
|
});
|
74
80
|
exports.i18 = exports.i18n.keyset(KEYSET_NAME);
|