@gravity-ui/blog-constructor 5.16.1 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. package/README.md +5 -5
  2. package/build/cjs/blocks/Banner/Banner.js +7 -9
  3. package/build/cjs/blocks/CTA/CTA.js +7 -9
  4. package/build/cjs/blocks/Feed/Feed.js +5 -12
  5. package/build/cjs/blocks/Header/Header.js +10 -14
  6. package/build/cjs/blocks/Media/Media.js +1 -0
  7. package/build/cjs/blocks/Meta/Meta.js +11 -15
  8. package/build/cjs/blocks/Suggest/Suggest.js +8 -11
  9. package/build/cjs/components/FeedHeader/components/Controls/Controls.css +19 -5
  10. package/build/cjs/components/FeedHeader/components/Controls/Controls.js +22 -27
  11. package/build/cjs/components/FeedHeader/components/Controls/customRenders.js +1 -1
  12. package/build/cjs/components/FeedHeader/components/CustomSwitcher/CustomSwitcher.css +1 -1
  13. package/build/cjs/components/Paginator/Paginator.js +16 -19
  14. package/build/cjs/components/Paginator/components/NavigationButton.js +1 -1
  15. package/build/cjs/components/PostCard/PostCard.d.ts +3 -6
  16. package/build/cjs/components/PostCard/PostCard.js +2 -2
  17. package/build/cjs/components/PostInfo/PostInfo.d.ts +4 -10
  18. package/build/cjs/components/PostInfo/PostInfo.js +4 -4
  19. package/build/cjs/components/PostInfo/SuggestPostInfo.js +4 -1
  20. package/build/cjs/components/PostInfo/components/ReadingTime.js +1 -1
  21. package/build/cjs/components/PostInfo/components/Save.d.ts +4 -6
  22. package/build/cjs/components/PostInfo/components/Save.js +3 -6
  23. package/build/cjs/components/PostInfo/components/Sharing.d.ts +3 -5
  24. package/build/cjs/components/PostInfo/components/Sharing.js +4 -10
  25. package/build/cjs/components/Posts/Posts.js +3 -3
  26. package/build/cjs/components/PostsEmpty/PostsEmpty.js +2 -2
  27. package/build/cjs/components/PostsError/PostsError.js +3 -3
  28. package/build/cjs/components/PromptSignIn/PromptSignIn.js +2 -2
  29. package/build/cjs/components/Search/Search.js +1 -1
  30. package/build/cjs/constants.d.ts +2 -1
  31. package/build/cjs/constants.js +20 -19
  32. package/build/cjs/constructor/BlogConstructorProvider.js +1 -0
  33. package/build/cjs/containers/BlogPostPage/BlogPostPage.css +1 -1
  34. package/build/cjs/contexts/LocaleContext.js +2 -2
  35. package/build/cjs/counters/metrika.js +0 -3
  36. package/build/cjs/counters/utils.d.ts +1 -1
  37. package/build/cjs/counters/utils.js +7 -7
  38. package/build/cjs/i18n/index.d.ts +1 -3
  39. package/build/cjs/i18n/index.js +8 -10
  40. package/build/cjs/index.d.ts +0 -1
  41. package/build/cjs/index.js +1 -3
  42. package/build/cjs/models/common.d.ts +1 -1
  43. package/build/cjs/models/locale.d.ts +1 -4
  44. package/build/cjs/models/locale.js +1 -6
  45. package/build/cjs/utils/common.d.ts +15 -3
  46. package/build/cjs/utils/common.js +20 -19
  47. package/build/esm/blocks/Banner/Banner.js +8 -10
  48. package/build/esm/blocks/CTA/CTA.js +8 -10
  49. package/build/esm/blocks/Feed/Feed.js +8 -15
  50. package/build/esm/blocks/Header/Header.js +12 -16
  51. package/build/esm/blocks/Media/Media.js +1 -0
  52. package/build/esm/blocks/Meta/Meta.js +13 -17
  53. package/build/esm/blocks/Suggest/Suggest.js +9 -12
  54. package/build/esm/components/FeedHeader/components/Controls/Controls.css +19 -5
  55. package/build/esm/components/FeedHeader/components/Controls/Controls.js +25 -30
  56. package/build/esm/components/FeedHeader/components/Controls/customRenders.js +2 -2
  57. package/build/esm/components/FeedHeader/components/CustomSwitcher/CustomSwitcher.css +1 -1
  58. package/build/esm/components/Paginator/Paginator.js +18 -21
  59. package/build/esm/components/Paginator/components/NavigationButton.js +2 -2
  60. package/build/esm/components/PostCard/PostCard.d.ts +3 -6
  61. package/build/esm/components/PostCard/PostCard.js +2 -2
  62. package/build/esm/components/PostInfo/PostInfo.d.ts +4 -10
  63. package/build/esm/components/PostInfo/PostInfo.js +4 -4
  64. package/build/esm/components/PostInfo/SuggestPostInfo.js +4 -1
  65. package/build/esm/components/PostInfo/components/ReadingTime.js +2 -2
  66. package/build/esm/components/PostInfo/components/Save.d.ts +4 -6
  67. package/build/esm/components/PostInfo/components/Save.js +3 -6
  68. package/build/esm/components/PostInfo/components/Sharing.d.ts +3 -5
  69. package/build/esm/components/PostInfo/components/Sharing.js +5 -11
  70. package/build/esm/components/Posts/Posts.js +4 -4
  71. package/build/esm/components/PostsEmpty/PostsEmpty.js +3 -3
  72. package/build/esm/components/PostsError/PostsError.js +4 -4
  73. package/build/esm/components/PromptSignIn/PromptSignIn.js +3 -3
  74. package/build/esm/components/Search/Search.js +2 -2
  75. package/build/esm/constants.d.ts +2 -1
  76. package/build/esm/constants.js +19 -18
  77. package/build/esm/constructor/BlogConstructorProvider.js +2 -1
  78. package/build/esm/containers/BlogPostPage/BlogPostPage.css +1 -1
  79. package/build/esm/contexts/LocaleContext.js +1 -1
  80. package/build/esm/counters/metrika.js +0 -3
  81. package/build/esm/counters/utils.d.ts +1 -1
  82. package/build/esm/counters/utils.js +6 -6
  83. package/build/esm/i18n/index.d.ts +1 -3
  84. package/build/esm/i18n/index.js +7 -9
  85. package/build/esm/index.d.ts +0 -1
  86. package/build/esm/index.js +0 -1
  87. package/build/esm/models/common.d.ts +1 -1
  88. package/build/esm/models/locale.d.ts +1 -4
  89. package/build/esm/models/locale.js +0 -5
  90. package/build/esm/utils/common.d.ts +15 -3
  91. package/build/esm/utils/common.js +18 -17
  92. package/package.json +15 -14
  93. package/server/data/contentFilter.d.ts +1 -1
  94. package/server/data/contentFilter.js +2 -1
  95. package/server/data/transformPageContent.d.ts +2 -2
  96. package/server/data/transformPost.d.ts +7 -2
  97. package/server/data/transformPost.js +1 -1
  98. package/server/index.d.ts +1 -1
  99. package/server/models/common.d.ts +1 -1
  100. package/server/models/locale.d.ts +1 -4
  101. package/server/models/locale.js +1 -6
  102. package/styles/storybook/common.scss +8 -0
  103. package/styles/storybook/index.scss +1 -1
  104. package/styles/styles.css +115 -0
  105. package/styles/styles.scss +1 -0
  106. package/build/cjs/configure.d.ts +0 -5
  107. package/build/cjs/configure.js +0 -8
  108. package/build/esm/configure.d.ts +0 -5
  109. package/build/esm/configure.js +0 -4
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Icon } from '@gravity-ui/uikit';
3
- import { Keyset, i18 } from '../../../i18n';
3
+ import { Keyset, i18n } from '../../../i18n';
4
4
  import { Time } from '../../../icons/Time';
5
5
  import { block } from '../../../utils/cn';
6
6
  import '../PostInfo.css';
@@ -9,4 +9,4 @@ const ICON_SIZE = 16;
9
9
  export const ReadingTime = ({ readingTime, size = 's', id, qa }) => (React.createElement("div", { className: b('item', { size }), id: id, "data-qa": qa },
10
10
  React.createElement("span", { className: b('icon') },
11
11
  React.createElement(Icon, { data: Time, size: ICON_SIZE, className: b('icon-color') })),
12
- i18(Keyset.ContextReadingTime, { count: readingTime })));
12
+ i18n(Keyset.ContextReadingTime, { count: readingTime })));
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { AnalyticsEventsProp } from '@gravity-ui/page-constructor';
2
3
  import { QAProps } from '../../../models/common';
3
4
  import '../PostInfo.css';
4
5
  type SaveProps = QAProps & {
@@ -7,11 +8,8 @@ type SaveProps = QAProps & {
7
8
  hasUserLike: boolean;
8
9
  handleUserLike: () => void;
9
10
  theme?: 'light' | 'dark';
10
- /**
11
- * @deprecated Metrika will be deleted after launch of analyticsEvents
12
- */
13
- metrikaGoal?: string;
14
11
  size?: 's' | 'm';
12
+ analyticsEvents?: AnalyticsEventsProp;
15
13
  };
16
14
  /**
17
15
  * Components for 'save' blog UI-component
@@ -19,11 +17,11 @@ type SaveProps = QAProps & {
19
17
  * @param title - post title
20
18
  * @param postId - post id
21
19
  * @param hasUserLike - flag what blog has like from current user
22
- * @param metrikaGoal - metrika goal name
23
20
  * @param qa - test-attr
24
21
  * @param size - text size
22
+ * @param analyticsEvents - a single or collection of objects detailing analytics events
25
23
  *
26
24
  * @returns jsx
27
25
  */
28
- export declare const Save: ({ title, postId, hasUserLike, handleUserLike, metrikaGoal, size, theme, qa, }: SaveProps) => React.JSX.Element;
26
+ export declare const Save: ({ title, postId, hasUserLike, handleUserLike, size, theme, qa, analyticsEvents, }: SaveProps) => React.JSX.Element;
29
27
  export {};
@@ -2,8 +2,6 @@ import React, { useContext } from 'react';
2
2
  import { useAnalytics } from '@gravity-ui/page-constructor';
3
3
  import { Icon } from '@gravity-ui/uikit';
4
4
  import { LikesContext } from '../../../contexts/LikesContext';
5
- import metrika from '../../../counters/metrika';
6
- import { MetrikaCounter } from '../../../counters/utils';
7
5
  import { Save as SaveIcon } from '../../../icons/Save';
8
6
  import { SaveFilled } from '../../../icons/SaveFilled';
9
7
  import { DefaultEventNames } from '../../../models/common';
@@ -18,13 +16,13 @@ const b = block('post-info');
18
16
  * @param title - post title
19
17
  * @param postId - post id
20
18
  * @param hasUserLike - flag what blog has like from current user
21
- * @param metrikaGoal - metrika goal name
22
19
  * @param qa - test-attr
23
20
  * @param size - text size
21
+ * @param analyticsEvents - a single or collection of objects detailing analytics events
24
22
  *
25
23
  * @returns jsx
26
24
  */
27
- export const Save = ({ title, postId, hasUserLike, handleUserLike, metrikaGoal, size, theme, qa, }) => {
25
+ export const Save = ({ title, postId, hasUserLike, handleUserLike, size, theme, qa, analyticsEvents, }) => {
28
26
  const { toggleLike, isSignedInUser, requireSignIn } = useContext(LikesContext);
29
27
  const handleAnalytics = useAnalytics(DefaultEventNames.SaveButton);
30
28
  const isLikeable = Boolean(toggleLike);
@@ -43,8 +41,7 @@ export const Save = ({ title, postId, hasUserLike, handleUserLike, metrikaGoal,
43
41
  }
44
42
  postLikeStatus(postId, Boolean(hasUserLike));
45
43
  handleUserLike();
46
- metrika.reachGoal(MetrikaCounter.CrossSite, metrikaGoal);
47
- handleAnalytics();
44
+ handleAnalytics(analyticsEvents);
48
45
  }, "data-qa": qa },
49
46
  React.createElement("div", { className: b('content', { cursor: isLikeable, theme }) },
50
47
  React.createElement("span", { className: b('icon') },
@@ -1,11 +1,9 @@
1
1
  import React from 'react';
2
+ import { AnalyticsEventsProp } from '@gravity-ui/page-constructor';
2
3
  import '../PostInfo.css';
3
4
  type SharingProps = {
4
5
  theme?: 'light' | 'dark';
5
- /**
6
- * @deprecated Metrika will be deleted after launch of analyticsEvents
7
- */
8
- metrikaGoal?: string;
6
+ analyticsEvents?: AnalyticsEventsProp;
9
7
  };
10
- export declare const Sharing: ({ theme, metrikaGoal }: SharingProps) => React.JSX.Element;
8
+ export declare const Sharing: ({ theme, analyticsEvents }: SharingProps) => React.JSX.Element;
11
9
  export {};
@@ -4,28 +4,22 @@ import { useAnalytics } from '@gravity-ui/page-constructor';
4
4
  import { MobileContext } from '../../../contexts/MobileContext';
5
5
  import { PostPageContext } from '../../../contexts/PostPageContext';
6
6
  import { RouterContext } from '../../../contexts/RouterContext';
7
- import metrika from '../../../counters/metrika';
8
- import { MetrikaCounter } from '../../../counters/utils';
9
- import { Keyset, i18 } from '../../../i18n';
7
+ import { Keyset, i18n } from '../../../i18n';
10
8
  import { ShareArrowUp } from '../../../icons/ShareArrowUp';
11
9
  import { DefaultEventNames } from '../../../models/common';
12
10
  import { block } from '../../../utils/cn';
13
11
  import { getAbsolutePath } from '../../../utils/common';
14
12
  import '../PostInfo.css';
15
13
  const b = block('post-info');
16
- export const Sharing = ({ theme, metrikaGoal }) => {
14
+ export const Sharing = ({ theme, analyticsEvents }) => {
17
15
  const router = useContext(RouterContext);
18
16
  const isMobile = useContext(MobileContext);
19
17
  const { shareOptions } = useContext(PostPageContext);
20
18
  const handleAnalyticsGlobal = useAnalytics(DefaultEventNames.ShareButton);
21
- const handleMetrika = useCallback(() => {
22
- metrika.reachGoal(MetrikaCounter.CrossSite, metrikaGoal);
23
- }, [metrikaGoal]);
24
19
  const handleAnalytics = useCallback(() => {
25
- handleAnalyticsGlobal();
26
- handleMetrika();
27
- }, [handleAnalyticsGlobal, handleMetrika]);
20
+ handleAnalyticsGlobal(analyticsEvents);
21
+ }, [analyticsEvents, handleAnalyticsGlobal]);
28
22
  return (React.createElement("div", { className: b('item') },
29
23
  React.createElement("div", { className: b('icon') },
30
- React.createElement(SharePopover, { url: getAbsolutePath(router), className: b('share'), iconClass: b('share-icon'), switcherClassName: b('switcher', { theme }), tooltipClassName: b('popup'), useWebShareApi: isMobile, direction: ShareLayoutDirection.Column, buttonTitle: i18(Keyset.ActionShare), customIcon: ShareArrowUp, placement: "bottom", openByHover: false, shareOptions: shareOptions, onClick: handleAnalytics }))));
24
+ React.createElement(SharePopover, { url: getAbsolutePath(router), className: b('share'), iconClass: b('share-icon'), switcherClassName: b('switcher', { theme }), tooltipClassName: b('popup'), useWebShareApi: isMobile, direction: ShareLayoutDirection.Column, buttonTitle: i18n(Keyset.ActionShare), customIcon: ShareArrowUp, placement: "bottom", openByHover: false, shareOptions: shareOptions, onClick: handleAnalytics }))));
31
25
  };
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { CardLayoutBlock } from '@gravity-ui/page-constructor';
3
3
  import { Button } from '@gravity-ui/uikit';
4
- import { Keyset, i18 } from '../../i18n';
4
+ import { Keyset, i18n } from '../../i18n';
5
5
  import { PostCardSize, PostCardTitleHeadingLevel } from '../../models/common';
6
6
  import { block } from '../../utils/cn';
7
7
  import { Paginator } from '../Paginator/Paginator';
@@ -22,9 +22,9 @@ export const Posts = ({ containerId, pinnedPostOnPage, currentPage, postsOnPage,
22
22
  ? PostCardTitleHeadingLevel.H3
23
23
  : PostCardTitleHeadingLevel.H2 }))))) : (React.createElement(PostsEmpty, null))),
24
24
  React.createElement("div", { className: b('pagination') },
25
- Boolean(isShowMoreVisible && (postsOnPage === null || postsOnPage === void 0 ? void 0 : postsOnPage.length)) && (React.createElement(Button, { view: "outlined", size: "xl", className: b('more-button'), onClick: handleShowMore }, i18(Keyset.ActionLoadMore))),
25
+ Boolean(isShowMoreVisible && (postsOnPage === null || postsOnPage === void 0 ? void 0 : postsOnPage.length)) && (React.createElement(Button, { view: "outlined", size: "xl", className: b('more-button'), onClick: handleShowMore }, i18n(Keyset.ActionLoadMore))),
26
26
  errorShowMore && (React.createElement("div", { className: b('error-show-more') },
27
- React.createElement("div", null, i18(Keyset.ErrorTitle)),
28
- React.createElement("div", null, i18(Keyset.PostLoadError)))),
27
+ React.createElement("div", null, i18n(Keyset.ErrorTitle)),
28
+ React.createElement("div", null, i18n(Keyset.PostLoadError)))),
29
29
  Boolean(currentPage && postCountOnPage) && (React.createElement("div", { className: b('paginator') },
30
30
  React.createElement(Paginator, { onPageChange: handlePageChange, page: currentPage, totalItems: postCountOnPage, itemsPerPage: perPageInQuery, maxPages: Infinity, pageCountForShowSupportButtons: pageCountForShowSupportButtons, queryParams: queryParams }))))));
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import { Keyset, i18 } from '../../i18n';
2
+ import { Keyset, i18n } from '../../i18n';
3
3
  import { block } from '../../utils/cn';
4
4
  import './PostsEmpty.css';
5
5
  const b = block('posts-empty');
6
6
  export const PostsEmpty = () => (React.createElement("div", { className: b('container') },
7
- React.createElement("div", { className: b('title') }, i18(Keyset.TitleEmptyContainer)),
8
- React.createElement("div", { className: b('subtitle') }, i18(Keyset.ContextEmptyContainer))));
7
+ React.createElement("div", { className: b('title') }, i18n(Keyset.TitleEmptyContainer)),
8
+ React.createElement("div", { className: b('subtitle') }, i18n(Keyset.ContextEmptyContainer))));
@@ -1,14 +1,14 @@
1
1
  import React from 'react';
2
2
  import { Button } from '@gravity-ui/uikit';
3
- import { Keyset, i18 } from '../../i18n';
3
+ import { Keyset, i18n } from '../../i18n';
4
4
  import { block } from '../../utils/cn';
5
5
  import './PostError.css';
6
6
  const b = block('posts-error');
7
7
  export const PostsError = ({ onButtonClick }) => {
8
8
  const handleClick = () => (onButtonClick ? onButtonClick() : window.location.reload());
9
9
  return (React.createElement("div", { className: b('container') },
10
- React.createElement("div", { className: b('title') }, i18(Keyset.ErrorTitle)),
11
- React.createElement("div", { className: b('subtitle') }, i18(Keyset.PostLoadError)),
10
+ React.createElement("div", { className: b('title') }, i18n(Keyset.ErrorTitle)),
11
+ React.createElement("div", { className: b('subtitle') }, i18n(Keyset.PostLoadError)),
12
12
  React.createElement("div", { className: b('button') },
13
- React.createElement(Button, { size: "xl", view: "outlined", onClick: handleClick }, i18(Keyset.ActionTryAgain)))));
13
+ React.createElement(Button, { size: "xl", view: "outlined", onClick: handleClick }, i18n(Keyset.ActionTryAgain)))));
14
14
  };
@@ -1,15 +1,15 @@
1
1
  import { __rest } from "tslib";
2
2
  import React from 'react';
3
- import { Keyset, i18 } from '../../i18n';
3
+ import { Keyset, i18n } from '../../i18n';
4
4
  import { Prompt } from '../Prompt/Prompt';
5
5
  /**
6
6
  * Authentication Popup that appears when user action requires login
7
7
  * @returns {JSX|null}
8
8
  */
9
9
  export const PromptSignIn = (_a) => {
10
- var { text = i18(Keyset.PromptSignInOnLike), onClickSignIn = () => alert(i18(Keyset.SignIn)), actions = [
10
+ var { text = i18n(Keyset.PromptSignInOnLike), onClickSignIn = () => alert(i18n(Keyset.SignIn)), actions = [
11
11
  {
12
- children: i18(Keyset.SignIn),
12
+ children: i18n(Keyset.SignIn),
13
13
  onClick: onClickSignIn,
14
14
  size: 'l',
15
15
  },
@@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
2
2
  import { Icon, TextInput } from '@gravity-ui/uikit';
3
3
  import lodashDebounce from 'lodash/debounce';
4
4
  import { useIsIPhone } from '../../hooks/useIsIPhone';
5
- import { Keyset, i18 } from '../../i18n';
5
+ import { Keyset, i18n } from '../../i18n';
6
6
  import { Close } from '../../icons/Close';
7
7
  import { SearchIcon } from '../../icons/SearchIcon';
8
8
  import { block } from '../../utils/cn';
@@ -17,7 +17,7 @@ const AUTOFOCUS_TIMEOUT = 0;
17
17
  *
18
18
  * @returns {JSX|null}
19
19
  */
20
- export const Search = ({ className, initialValue, onSubmit, debounce = 300, placeholder = i18(Keyset.Search), size = 'm', autoFocus = false, value: externalValue, }) => {
20
+ export const Search = ({ className, initialValue, onSubmit, debounce = 300, placeholder = i18n(Keyset.Search), size = 'm', autoFocus = false, value: externalValue, }) => {
21
21
  const handleChange = lodashDebounce(onSubmit, debounce);
22
22
  const [value, setValue] = useState(initialValue);
23
23
  const inputRef = useRef(null);
@@ -9,13 +9,14 @@ export declare const BREAKPOINTS: {
9
9
  export declare const DEFAULT_THEME = "light";
10
10
  export declare const UIKIT_ROOT_CLASS = "g-root";
11
11
  export declare const UIKIT_THEME_LIGHT_CLASS: string;
12
- export declare enum BlogMetrikaGoalIds {
12
+ export declare enum DefaultGoalIds {
13
13
  shareTop = "SITE_BLOG_SHARE-TOP_CLICK",
14
14
  shareBottom = "SITE_BLOG_SHARE-BOTTOM_CLICK",
15
15
  breadcrumbsTop = "SITE_BLOG_BREADCRUMBS-TOP_CLICK",
16
16
  breadcrumbsBottom = "SITE_BLOG_BREADCRUMBS-BOTTOM_CLICK",
17
17
  saveTop = "SITE_BLOG_SAVE-TOP_CLICK",
18
18
  saveBottom = "SITE_BLOG_SAVE-BOTTOM_CLICK",
19
+ saveSuggest = "SITE_BLOG_SAVE-SUGGEST_CLICK",
19
20
  suggest = "SITE_BLOG_INTERESTING-CARD_CLICK",
20
21
  bannerCommon = "SITE_BLOG_TEXT-BANNER_CLICK",
21
22
  cta = "SITE_BLOG_CTA_CLICK",
@@ -9,24 +9,25 @@ export const BREAKPOINTS = {
9
9
  export const DEFAULT_THEME = 'light';
10
10
  export const UIKIT_ROOT_CLASS = 'g-root';
11
11
  export const UIKIT_THEME_LIGHT_CLASS = `${UIKIT_ROOT_CLASS}_theme_${DEFAULT_THEME}`;
12
- export var BlogMetrikaGoalIds;
13
- (function (BlogMetrikaGoalIds) {
14
- BlogMetrikaGoalIds["shareTop"] = "SITE_BLOG_SHARE-TOP_CLICK";
15
- BlogMetrikaGoalIds["shareBottom"] = "SITE_BLOG_SHARE-BOTTOM_CLICK";
16
- BlogMetrikaGoalIds["breadcrumbsTop"] = "SITE_BLOG_BREADCRUMBS-TOP_CLICK";
17
- BlogMetrikaGoalIds["breadcrumbsBottom"] = "SITE_BLOG_BREADCRUMBS-BOTTOM_CLICK";
18
- BlogMetrikaGoalIds["saveTop"] = "SITE_BLOG_SAVE-TOP_CLICK";
19
- BlogMetrikaGoalIds["saveBottom"] = "SITE_BLOG_SAVE-BOTTOM_CLICK";
20
- BlogMetrikaGoalIds["suggest"] = "SITE_BLOG_INTERESTING-CARD_CLICK";
21
- BlogMetrikaGoalIds["bannerCommon"] = "SITE_BLOG_TEXT-BANNER_CLICK";
22
- BlogMetrikaGoalIds["cta"] = "SITE_BLOG_CTA_CLICK";
23
- BlogMetrikaGoalIds["tag"] = "SITE_BLOG_THEME-SELECTOR_CLCK";
24
- BlogMetrikaGoalIds["service"] = "SITE_BLOG_SERVICE-SELECTOR_CLCK";
25
- BlogMetrikaGoalIds["showMore"] = "SITE_BLOG-PAGINATION_SHOW-MORE_CLCK";
26
- BlogMetrikaGoalIds["next"] = "SITE_BLOG-PAGINATION_NEXT_CLCK";
27
- BlogMetrikaGoalIds["home"] = "SITE_BLOG-PAGINATION_HOME_CLCK";
28
- BlogMetrikaGoalIds["page"] = "SITE_BLOG-PAGINATION_PAGE-NMBR_CLCK";
29
- })(BlogMetrikaGoalIds || (BlogMetrikaGoalIds = {}));
12
+ export var DefaultGoalIds;
13
+ (function (DefaultGoalIds) {
14
+ DefaultGoalIds["shareTop"] = "SITE_BLOG_SHARE-TOP_CLICK";
15
+ DefaultGoalIds["shareBottom"] = "SITE_BLOG_SHARE-BOTTOM_CLICK";
16
+ DefaultGoalIds["breadcrumbsTop"] = "SITE_BLOG_BREADCRUMBS-TOP_CLICK";
17
+ DefaultGoalIds["breadcrumbsBottom"] = "SITE_BLOG_BREADCRUMBS-BOTTOM_CLICK";
18
+ DefaultGoalIds["saveTop"] = "SITE_BLOG_SAVE-TOP_CLICK";
19
+ DefaultGoalIds["saveBottom"] = "SITE_BLOG_SAVE-BOTTOM_CLICK";
20
+ DefaultGoalIds["saveSuggest"] = "SITE_BLOG_SAVE-SUGGEST_CLICK";
21
+ DefaultGoalIds["suggest"] = "SITE_BLOG_INTERESTING-CARD_CLICK";
22
+ DefaultGoalIds["bannerCommon"] = "SITE_BLOG_TEXT-BANNER_CLICK";
23
+ DefaultGoalIds["cta"] = "SITE_BLOG_CTA_CLICK";
24
+ DefaultGoalIds["tag"] = "SITE_BLOG_THEME-SELECTOR_CLCK";
25
+ DefaultGoalIds["service"] = "SITE_BLOG_SERVICE-SELECTOR_CLCK";
26
+ DefaultGoalIds["showMore"] = "SITE_BLOG-PAGINATION_SHOW-MORE_CLCK";
27
+ DefaultGoalIds["next"] = "SITE_BLOG-PAGINATION_NEXT_CLCK";
28
+ DefaultGoalIds["home"] = "SITE_BLOG-PAGINATION_HOME_CLCK";
29
+ DefaultGoalIds["page"] = "SITE_BLOG-PAGINATION_PAGE-NMBR_CLCK";
30
+ })(DefaultGoalIds || (DefaultGoalIds = {}));
30
31
  export const DEFAULT_PADDINGS = {
31
32
  [PaddingsDirections.bottom]: 'l',
32
33
  [PaddingsDirections.top]: 'xs',
@@ -1,5 +1,5 @@
1
1
  import React, { Fragment } from 'react';
2
- import { AnalyticsContext } from '@gravity-ui/page-constructor';
2
+ import { AnalyticsContext, ThemeContext, } from '@gravity-ui/page-constructor';
3
3
  import { DEFAULT_THEME } from '../constants';
4
4
  import { DeviceContext } from '../contexts/DeviceContext';
5
5
  import { LocaleContext } from '../contexts/LocaleContext';
@@ -10,6 +10,7 @@ import { ThemeValueContext } from '../contexts/theme/ThemeValueContext';
10
10
  export const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = DEFAULT_THEME, device = {}, analytics = {}, settings = {}, children, }) => {
11
11
  const context = [
12
12
  React.createElement(ThemeValueContext.Provider, { value: { themeValue: theme }, key: "theme-context" }),
13
+ React.createElement(ThemeContext.Provider, { value: { theme: theme }, key: "pc-theme" }),
13
14
  React.createElement(LocaleContext.Provider, { value: { locale }, key: "locale-context" }),
14
15
  React.createElement(RouterContext.Provider, { value: router, key: "router-context" }),
15
16
  React.createElement(MobileContext.Provider, { value: Boolean(isMobile), key: "is-mobile-context" }),
@@ -1,5 +1,5 @@
1
1
  @charset "UTF-8";
2
- @import '~@doc-tools/transform/dist/css/yfm.css';
2
+ @import '~@diplodoc/transform/dist/css/yfm.css';
3
3
  :root {
4
4
  --header-height: 64px;
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Lang } from '../models/locale';
2
+ import { Lang } from '@gravity-ui/uikit';
3
3
  export const LocaleContext = React.createContext({
4
4
  locale: {
5
5
  code: 'en-En',
@@ -1,6 +1,3 @@
1
- /**
2
- * @deprecated Metrika will be deleted after launch of analyticsEvents
3
- */
4
1
  const Goal = {
5
2
  SUPPORT_OPEN_FORM: 'SUPPORTOPENFORM',
6
3
  SUPPORT_STEP_1_SUBMIT: 'SUPPORTSTEP1SUBMIT',
@@ -1,4 +1,4 @@
1
- export declare enum MetrikaCounter {
1
+ export declare enum AnalyticsCounter {
2
2
  Main = "main",
3
3
  CrossSite = "cross-site",
4
4
  Scale = "scale"
@@ -1,6 +1,6 @@
1
- export var MetrikaCounter;
2
- (function (MetrikaCounter) {
3
- MetrikaCounter["Main"] = "main";
4
- MetrikaCounter["CrossSite"] = "cross-site";
5
- MetrikaCounter["Scale"] = "scale";
6
- })(MetrikaCounter || (MetrikaCounter = {}));
1
+ export var AnalyticsCounter;
2
+ (function (AnalyticsCounter) {
3
+ AnalyticsCounter["Main"] = "main";
4
+ AnalyticsCounter["CrossSite"] = "cross-site";
5
+ AnalyticsCounter["Scale"] = "scale";
6
+ })(AnalyticsCounter || (AnalyticsCounter = {}));
@@ -1,5 +1,3 @@
1
- import { I18N } from '@gravity-ui/i18n';
2
- export declare const i18n: I18N;
3
1
  export declare enum Keyset {
4
2
  Title = "title",
5
3
  TitleBreadcrumbs = "title_breadcrumbs",
@@ -21,4 +19,4 @@ export declare enum Keyset {
21
19
  PromptSignInOnLike = "prompt_sign_in_on_like",
22
20
  SignIn = "Sign In"
23
21
  }
24
- export declare const i18: (key: string, params?: import("@gravity-ui/i18n").Params | undefined) => string;
22
+ export declare const i18n: (key: Keyset, params?: import("@gravity-ui/i18n").Params | undefined) => string;
@@ -1,7 +1,5 @@
1
- import { I18N } from '@gravity-ui/i18n';
2
- import { Lang } from '../models/locale';
3
- const KEYSET_NAME = 'blog';
4
- export const i18n = new I18N();
1
+ import { addComponentKeysets } from '@gravity-ui/uikit/i18n';
2
+ const NAMESPACE = 'blog';
5
3
  export var Keyset;
6
4
  (function (Keyset) {
7
5
  Keyset["Title"] = "title";
@@ -24,7 +22,7 @@ export var Keyset;
24
22
  Keyset["PromptSignInOnLike"] = "prompt_sign_in_on_like";
25
23
  Keyset["SignIn"] = "Sign In";
26
24
  })(Keyset || (Keyset = {}));
27
- i18n.registerKeyset(Lang.En, KEYSET_NAME, {
25
+ const en = {
28
26
  [Keyset.Title]: 'Blog',
29
27
  [Keyset.TitleBreadcrumbs]: 'Blog',
30
28
  [Keyset.TitleSuggest]: 'See also',
@@ -48,8 +46,8 @@ i18n.registerKeyset(Lang.En, KEYSET_NAME, {
48
46
  '{{count}} mins to read',
49
47
  ],
50
48
  [Keyset.SignIn]: 'Sign In',
51
- });
52
- i18n.registerKeyset(Lang.Ru, KEYSET_NAME, {
49
+ };
50
+ const ru = {
53
51
  [Keyset.Title]: 'Блог',
54
52
  [Keyset.TitleBreadcrumbs]: 'Блог',
55
53
  [Keyset.TitleSuggest]: 'Читать также',
@@ -73,5 +71,5 @@ i18n.registerKeyset(Lang.Ru, KEYSET_NAME, {
73
71
  '{{count}} минут чтения',
74
72
  ],
75
73
  [Keyset.SignIn]: 'Войти',
76
- });
77
- export const i18 = i18n.keyset(KEYSET_NAME);
74
+ };
75
+ export const i18n = addComponentKeysets({ en, ru }, NAMESPACE);
@@ -1,4 +1,3 @@
1
- export { configure } from './configure';
2
1
  export { BlogConstructorProvider } from './constructor/BlogConstructorProvider';
3
2
  export { BlogPostPage } from './containers/BlogPostPage/BlogPostPage';
4
3
  export { BlogPage } from './containers/BlogPage/BlogPage';
@@ -1,4 +1,3 @@
1
- export { configure } from './configure';
2
1
  export { BlogConstructorProvider } from './constructor/BlogConstructorProvider';
3
2
  export { BlogPostPage } from './containers/BlogPostPage/BlogPostPage';
4
3
  export { BlogPage } from './containers/BlogPage/BlogPage';
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { MarkdownItPluginCb } from '@doc-tools/transform/lib/plugins/typings';
2
+ import { MarkdownItPluginCb } from '@diplodoc/transform/lib/plugins/typings';
3
3
  import { HeaderBlockProps as PageConstructorHeaderBlockProps } from '@gravity-ui/page-constructor';
4
4
  import { IBrowser, IDevice } from 'ua-parser-js';
5
5
  import { Locale } from '../models/locale';
@@ -1,7 +1,4 @@
1
- export declare enum Lang {
2
- Ru = "ru",
3
- En = "en"
4
- }
1
+ import { Lang } from '@gravity-ui/uikit';
5
2
  export declare enum Currency {
6
3
  RUB = "RUB",
7
4
  USD = "USD",
@@ -1,8 +1,3 @@
1
- export var Lang;
2
- (function (Lang) {
3
- Lang["Ru"] = "ru";
4
- Lang["En"] = "en";
5
- })(Lang || (Lang = {}));
6
1
  export var Currency;
7
2
  (function (Currency) {
8
3
  Currency["RUB"] = "RUB";
@@ -1,7 +1,8 @@
1
1
  /// <reference types="lodash" />
2
- import { ContentBlockProps, HeaderBreadCrumbsProps, MetrikaGoal, NewMetrikaGoal } from '@gravity-ui/page-constructor';
2
+ import { AnalyticsEvent, AnalyticsEventsProp, ContentBlockProps, HeaderBreadCrumbsProps } from '@gravity-ui/page-constructor';
3
3
  import { RouterContextProps } from '../contexts/RouterContext';
4
4
  import { GetPostsRequest, Query, Tag } from '../models/common';
5
+ import { AnalyticsCounter } from '../counters/utils';
5
6
  export interface QueryParam {
6
7
  name: string;
7
8
  value?: string | number | null;
@@ -38,9 +39,20 @@ type GetBreadcrumbsProps = {
38
39
  };
39
40
  export declare const getBlogPath: (pathPrefix: string) => string;
40
41
  export declare const getBreadcrumbs: ({ tags, blogPath }: GetBreadcrumbsProps) => HeaderBreadCrumbsProps;
41
- export declare const isMetrikaExist: (goal: NewMetrikaGoal, existGoals: NewMetrikaGoal[]) => boolean;
42
- export declare const getBlogElementMetrika: (blogCustomGoal: NewMetrikaGoal, existingGoals?: MetrikaGoal) => string | string[] | NewMetrikaGoal[];
42
+ export declare const getMergedAnalyticsEvents: (analyticEvents: AnalyticsEventsProp, existringEvents?: AnalyticsEventsProp) => {
43
+ name: string;
44
+ type?: string | undefined;
45
+ counters?: import("@gravity-ui/page-constructor").AnalyticsCounters | undefined;
46
+ context?: string | undefined;
47
+ target?: string | undefined;
48
+ }[];
43
49
  export declare const getFeedQueryParams: (queryString: Query, pageNumber?: number) => GetPostsRequest;
44
50
  export declare const scrollOnPageChange: (containerId: string) => void;
45
51
  export declare const getQaAttributes: (qa?: string, ...customKeys: (string | Array<string>)[]) => Record<string, string>;
52
+ type PrepareAnalyticsEventArgs = {
53
+ name: string;
54
+ counter?: AnalyticsCounter;
55
+ options?: Record<string, string | number>;
56
+ };
57
+ export declare const prepareAnalyticsEvent: ({ name, counter, options, }: PrepareAnalyticsEventArgs) => AnalyticsEvent;
46
58
  export {};
@@ -1,12 +1,12 @@
1
1
  import { __rest } from "tslib";
2
2
  import { format, parse } from 'url';
3
- import { isNewMetrikaFormat, } from '@gravity-ui/page-constructor';
4
3
  import camelCase from 'lodash/camelCase';
5
4
  import debounce from 'lodash/debounce';
6
5
  import flatten from 'lodash/flatten';
7
6
  import memoize from 'lodash/memoize';
8
7
  import { CONTENT_DEFAULT_COL_SIZES, CONTENT_DEFAULT_SIZE, CONTENT_DEFAULT_THEME, DEFAULT_PAGE, DEFAULT_ROWS_PER_PAGE, } from '../blocks/constants';
9
- import { Keyset, i18 } from '../i18n';
8
+ import { Keyset, i18n } from '../i18n';
9
+ import { AnalyticsCounter } from '../counters/utils';
10
10
  const QA_ATTRIBUTES_KEYS = ['container', 'content', 'wrapper', 'image', 'button'];
11
11
  export function getAbsolutePath(router, url) {
12
12
  if (!router || !router.pathname) {
@@ -54,7 +54,7 @@ export const getBlogPath = (pathPrefix) => {
54
54
  };
55
55
  export const getBreadcrumbs = ({ tags, blogPath }) => {
56
56
  const breadcrumbs = {
57
- items: [{ text: i18(Keyset.TitleBreadcrumbs), url: blogPath }],
57
+ items: [{ text: i18n(Keyset.TitleBreadcrumbs), url: blogPath }],
58
58
  theme: 'light',
59
59
  };
60
60
  if (tags === null || tags === void 0 ? void 0 : tags.length) {
@@ -65,21 +65,19 @@ export const getBreadcrumbs = ({ tags, blogPath }) => {
65
65
  }
66
66
  return breadcrumbs;
67
67
  };
68
- export const isMetrikaExist = (goal, existGoals) => {
69
- return Boolean(existGoals.find((existGoal) => goal.name === existGoal.name));
70
- };
71
- export const getBlogElementMetrika = (blogCustomGoal, existingGoals) => {
72
- if (existingGoals) {
73
- if (isNewMetrikaFormat(existingGoals) && !isMetrikaExist(blogCustomGoal, existingGoals)) {
74
- const goals = [...existingGoals];
75
- goals.push(blogCustomGoal);
76
- return goals;
77
- }
78
- return existingGoals;
68
+ const getArrayOfEvents = (events) => {
69
+ if (!events) {
70
+ return [];
79
71
  }
80
- else {
81
- return [blogCustomGoal];
72
+ if (Array.isArray(events)) {
73
+ return events;
82
74
  }
75
+ return [events];
76
+ };
77
+ export const getMergedAnalyticsEvents = (analyticEvents, existringEvents) => {
78
+ const eventsAsArray = getArrayOfEvents(analyticEvents);
79
+ const existingAsArray = getArrayOfEvents(existringEvents);
80
+ return eventsAsArray.concat(existingAsArray);
83
81
  };
84
82
  export const getFeedQueryParams = (queryString, pageNumber) => {
85
83
  const queryParams = getPageSearchParams(queryString);
@@ -109,4 +107,7 @@ export const getQaAttributes = (qa, ...customKeys) => {
109
107
  attributes.default = qa;
110
108
  }
111
109
  return attributes;
112
- };
110
+ };
111
+ export const prepareAnalyticsEvent = ({ name, counter = AnalyticsCounter.Main, options = {}, }) => (Object.assign(Object.assign({}, options), { name, counters: {
112
+ include: [counter],
113
+ } }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/blog-constructor",
3
- "version": "5.16.1",
3
+ "version": "6.0.0",
4
4
  "description": "Gravity UI Blog Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -60,8 +60,8 @@
60
60
  },
61
61
  "dependencies": {
62
62
  "@bem-react/classname": "^1.6.0",
63
- "@gravity-ui/components": "^2.8.0",
64
- "@gravity-ui/i18n": "^1.1.0",
63
+ "@gravity-ui/components": "^3.0.0",
64
+ "@gravity-ui/i18n": "^1.3.0",
65
65
  "lodash": "^4.17.21",
66
66
  "react-helmet": "^6.1.0",
67
67
  "ua-parser-js": "^0.7.28",
@@ -70,9 +70,9 @@
70
70
  "uuid": "^9.0.1"
71
71
  },
72
72
  "peerDependencies": {
73
- "@doc-tools/transform": "^3.3.2",
74
- "@gravity-ui/page-constructor": "^4.45.0",
75
- "@gravity-ui/uikit": "^5.12.0",
73
+ "@diplodoc/transform": "^4.10.7",
74
+ "@gravity-ui/page-constructor": "^5.0.0",
75
+ "@gravity-ui/uikit": "^6.1.1",
76
76
  "react": "^16.0.0 || ^17.0.0 || ^18.0.0"
77
77
  },
78
78
  "devDependencies": {
@@ -80,19 +80,20 @@
80
80
  "@babel/preset-react": "^7.22.5",
81
81
  "@babel/preset-typescript": "^7.22.5",
82
82
  "@commitlint/config-conventional": "^17.4.3",
83
- "@doc-tools/transform": "^3.11.0",
83
+ "@diplodoc/transform": "^4.10.8",
84
84
  "@gravity-ui/eslint-config": "^3.1.1",
85
- "@gravity-ui/page-constructor": "^4.46.0",
85
+ "@gravity-ui/page-constructor": "^5.1.0",
86
86
  "@gravity-ui/prettier-config": "^1.1.0",
87
87
  "@gravity-ui/stylelint-config": "^4.0.1",
88
88
  "@gravity-ui/tsconfig": "^1.0.0",
89
- "@gravity-ui/uikit": "^5.25.0",
89
+ "@gravity-ui/uikit": "^6.2.0",
90
90
  "@jest/environment": "^29.7.0",
91
- "@storybook/addon-essentials": "^7.0.27",
92
- "@storybook/cli": "^7.0.27",
91
+ "@storybook/addon-essentials": "^7.6.17",
92
+ "@storybook/addon-mdx-gfm": "^7.6.17",
93
+ "@storybook/cli": "^7.6.17",
93
94
  "@storybook/preset-scss": "^1.0.3",
94
- "@storybook/react": "^7.0.27",
95
- "@storybook/react-webpack5": "^7.0.27",
95
+ "@storybook/react": "^7.6.17",
96
+ "@storybook/react-webpack5": "^7.6.17",
96
97
  "@testing-library/dom": "^9.3.3",
97
98
  "@testing-library/jest-dom": "^5.16.5",
98
99
  "@testing-library/react": "^14.0.0",
@@ -127,7 +128,7 @@
127
128
  "rimraf": "^3.0.2",
128
129
  "sass": "^1.54.4",
129
130
  "sass-loader": "^13.3.1",
130
- "storybook": "^7.0.27",
131
+ "storybook": "^7.6.17",
131
132
  "stylelint": "^15.11.0",
132
133
  "ts-jest": "^29.0.5",
133
134
  "typescript": "^4.9.3"
@@ -1,5 +1,5 @@
1
1
  import { PageContent } from '@gravity-ui/page-constructor';
2
- import { Lang } from '../models/locale';
2
+ import { Lang } from '@gravity-ui/uikit';
3
3
  type FilteringOptions = {
4
4
  lang: Lang;
5
5
  region?: string;