@gravity-ui/blog-constructor 2.0.1 → 2.1.0-alpha.1

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,13 +1,5 @@
1
1
  # Changelog
2
2
 
3
- ## [2.0.1](https://github.com/gravity-ui/blog-constructor/compare/v2.0.0...v2.0.1) (2023-04-04)
4
-
5
-
6
- ### Bug Fixes
7
-
8
- * throw virtualization threshold prop in Select ([#26](https://github.com/gravity-ui/blog-constructor/issues/26)) ([ccb0f19](https://github.com/gravity-ui/blog-constructor/commit/ccb0f19a904e54fd43ca66195da9e94925d0a26f))
9
- * throw virtualization threshold prop in Select ([#26](https://github.com/gravity-ui/blog-constructor/issues/26)) ([0aa5aed](https://github.com/gravity-ui/blog-constructor/commit/0aa5aeda9a0afd99ae8590c6b666c033a12b7fba))
10
-
11
3
  ## [2.0.0](https://github.com/gravity-ui/blog-constructor/compare/v1.1.2...v2.0.0) (2023-04-03)
12
4
 
13
5
 
@@ -41,7 +41,6 @@ const cn_1 = require("../../../../utils/cn");
41
41
  const b = (0, cn_1.block)('feed-controls');
42
42
  const ICON_SIZE = 16;
43
43
  const DEFAULT_PAGE = 1;
44
- const VIRTUALIZATION_THRESHOLD = 1000;
45
44
  const Controls = ({ setIsFetching, tags = [], services = [], handleChangeQuery, queryParams, }) => {
46
45
  const { hasLikes } = (0, react_1.useContext)(LikesContext_1.LikesContext);
47
46
  const { savedOnly: savedOnlyInitial, search: searchInitial, tags: tagInitial, services: servicesInitial, } = queryParams || {};
@@ -92,13 +91,13 @@ const Controls = ({ setIsFetching, tags = [], services = [], handleChangeQuery,
92
91
  initial: [tagInitial],
93
92
  list: tagsItems,
94
93
  defaultLabel: (0, i18n_1.i18)(i18n_1.Keyset.AllTags),
95
- }), disablePortal: true, virtualizationThreshold: VIRTUALIZATION_THRESHOLD, renderOption: customRenders_1.renderOption })),
94
+ }), disablePortal: true, renderOption: customRenders_1.renderOption })),
96
95
  services.length > 0 ? (react_1.default.createElement("div", { className: b('filter-item') },
97
96
  react_1.default.createElement(uikit_1.Select, { className: b('select'), size: "xl", multiple: true, filterable: true, disablePortal: true, options: services, defaultValue: servicesItems, popupClassName: b('popup'), onUpdate: handleServicesSelect, placeholder: (0, i18n_1.i18)(i18n_1.Keyset.AllServices), renderControl: (0, customRenders_1.renderSwitcher)({
98
97
  initial: servicesItems,
99
98
  list: services,
100
99
  defaultLabel: (0, i18n_1.i18)(i18n_1.Keyset.AllServices),
101
- }), virtualizationThreshold: VIRTUALIZATION_THRESHOLD, renderOption: customRenders_1.renderOption, renderFilter: customRenders_1.renderFilter }))) : null,
100
+ }), renderOption: customRenders_1.renderOption, renderFilter: customRenders_1.renderFilter }))) : null,
102
101
  hasLikes ? (react_1.default.createElement("div", { className: b('filter-item', { 'width-auto': true }) },
103
102
  react_1.default.createElement(uikit_1.Button, { view: 'outlined', className: b('saved-only-button', { savedOnly }), size: "xl", onClick: handleSavedOnly },
104
103
  react_1.default.createElement(uikit_1.Icon, { data: Save_1.Save, size: ICON_SIZE, className: b('icon', { savedOnly }) }),
@@ -27,28 +27,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.Sharing = void 0;
30
- const react_1 = __importStar(require("react"));
30
+ const useAnalytics_1 = require("@gravity-ui/page-constructor/build/esm/hooks/useAnalytics");
31
31
  const uikit_1 = require("@gravity-ui/uikit");
32
+ const react_1 = __importStar(require("react"));
32
33
  const MobileContext_1 = require("../../../contexts/MobileContext");
33
- const RouterContext_1 = require("../../../contexts/RouterContext");
34
34
  const PostPageContext_1 = require("../../../contexts/PostPageContext");
35
+ const RouterContext_1 = require("../../../contexts/RouterContext");
36
+ const metrika_js_1 = __importDefault(require("../../../counters/metrika.js"));
37
+ const utils_1 = require("../../../counters/utils");
35
38
  const i18n_1 = require("../../../i18n");
36
- const common_1 = require("../../../utils/common");
39
+ const ShareArrowUp_1 = require("../../../icons/ShareArrowUp");
40
+ const common_1 = require("../../../models/common");
37
41
  const cn_1 = require("../../../utils/cn");
38
- const utils_1 = require("../../../counters/utils");
42
+ const common_2 = require("../../../utils/common");
39
43
  // @ts-ignore
40
- const metrika_js_1 = __importDefault(require("../../../counters/metrika.js"));
41
- const ShareArrowUp_1 = require("../../../icons/ShareArrowUp");
42
44
  const b = (0, cn_1.block)('post-info');
43
45
  const Sharing = ({ theme, metrikaGoal }) => {
44
46
  const router = (0, react_1.useContext)(RouterContext_1.RouterContext);
45
47
  const isMobile = (0, react_1.useContext)(MobileContext_1.MobileContext);
46
48
  const { shareOptions } = (0, react_1.useContext)(PostPageContext_1.PostPageContext);
47
- const handleMetrika = () => {
49
+ const handleAnalyticsGlobal = (0, useAnalytics_1.useAnalytics)(common_1.DefaultEventNames.ShareButton);
50
+ const handleMetrika = (0, react_1.useCallback)(() => {
48
51
  metrika_js_1.default.reachGoal(utils_1.MetrikaCounter.CrossSite, metrikaGoal);
49
- };
52
+ }, [metrikaGoal]);
53
+ const handleAnalytics = (0, react_1.useCallback)(() => {
54
+ handleAnalyticsGlobal();
55
+ handleMetrika();
56
+ }, [handleAnalyticsGlobal, handleMetrika]);
50
57
  return (react_1.default.createElement("div", { className: b('item') },
51
58
  react_1.default.createElement("span", { className: b('icon') },
52
- react_1.default.createElement(uikit_1.SharePopover, { url: (0, common_1.getAbsolutePath)(router), className: b('share'), iconClass: b('share-icon'), switcherClassName: b('switcher', { theme }), tooltipClassName: b('popup'), useWebShareApi: isMobile, direction: 'column', buttonTitle: (0, i18n_1.i18)(i18n_1.Keyset.ActionShare), customIcon: ShareArrowUp_1.ShareArrowUp, placement: "bottom", openByHover: false, shareOptions: shareOptions, handleMetrika: handleMetrika }))));
59
+ react_1.default.createElement(uikit_1.SharePopover, { url: (0, common_2.getAbsolutePath)(router), className: b('share'), iconClass: b('share-icon'), switcherClassName: b('switcher', { theme }), tooltipClassName: b('popup'), useWebShareApi: isMobile, direction: 'column', buttonTitle: (0, i18n_1.i18)(i18n_1.Keyset.ActionShare), customIcon: ShareArrowUp_1.ShareArrowUp, placement: "bottom", openByHover: false, shareOptions: shareOptions, handleMetrika: handleAnalytics }))));
53
60
  };
54
61
  exports.Sharing = Sharing;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { AnalyticsContextProps } from '@gravity-ui/page-constructor/build/esm/context/analyticsContext';
2
3
  import { RouterContextProps } from '../contexts/RouterContext';
3
4
  import { UserContextProps } from '../contexts/UserContext';
4
5
  import { DeviceContextProps } from '../contexts/DeviceContext';
@@ -11,6 +12,7 @@ export interface BlogConstructorProviderProps {
11
12
  theme?: ThemeValueType;
12
13
  user?: UserContextProps;
13
14
  device?: DeviceContextProps;
15
+ analytics?: AnalyticsContextProps;
14
16
  children?: React.ReactNode;
15
17
  }
16
18
  export declare const BlogConstructorProvider: React.FC<BlogConstructorProviderProps>;
@@ -25,6 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.BlogConstructorProvider = void 0;
27
27
  const react_1 = __importStar(require("react"));
28
+ const analyticsContext_1 = require("@gravity-ui/page-constructor/build/esm/context/analyticsContext");
28
29
  const MobileContext_1 = require("../contexts/MobileContext");
29
30
  const LocaleContext_1 = require("../contexts/LocaleContext");
30
31
  const RouterContext_1 = require("../contexts/RouterContext");
@@ -32,7 +33,7 @@ const UserContext_1 = require("../contexts/UserContext");
32
33
  const DeviceContext_1 = require("../contexts/DeviceContext");
33
34
  const ThemeValueContext_1 = require("../contexts/theme/ThemeValueContext");
34
35
  const constants_1 = require("../constants");
35
- const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = constants_1.DEFAULT_THEME, user = {}, device = {}, children, }) => {
36
+ const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = constants_1.DEFAULT_THEME, user = {}, device = {}, analytics = {}, children, }) => {
36
37
  const context = [
37
38
  react_1.default.createElement(ThemeValueContext_1.ThemeValueContext.Provider, { value: { themeValue: theme }, key: "theme-context" }),
38
39
  react_1.default.createElement(LocaleContext_1.LocaleContext.Provider, { value: { locale }, key: "locale-context" }),
@@ -40,6 +41,7 @@ const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = c
40
41
  react_1.default.createElement(MobileContext_1.MobileContext.Provider, { value: Boolean(isMobile), key: "is-mobile-context" }),
41
42
  react_1.default.createElement(UserContext_1.UserContext.Provider, { value: user, key: "user-context" }),
42
43
  react_1.default.createElement(DeviceContext_1.DeviceContext.Provider, { value: device, key: "device-context" }),
44
+ react_1.default.createElement(analyticsContext_1.AnalyticsContext.Provider, { value: analytics, key: "analytics-context" }),
43
45
  ].reduceRight((prev, provider) => react_1.default.cloneElement(provider, {}, prev), children);
44
46
  return react_1.default.createElement(react_1.Fragment, null, context);
45
47
  };
@@ -149,3 +149,6 @@ export type HandleChangeQueryParams = (params: Query) => void;
149
149
  export type SetQueryType = (params: Query, options?: {
150
150
  [y: string]: boolean;
151
151
  }) => Promise<void> | void;
152
+ export declare enum DefaultEventNames {
153
+ ShareButton = "share-button-click"
154
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BlockType = exports.Theme = void 0;
3
+ exports.DefaultEventNames = exports.BlockType = exports.Theme = void 0;
4
4
  var Theme;
5
5
  (function (Theme) {
6
6
  Theme["Light"] = "light";
@@ -19,4 +19,8 @@ var BlockType;
19
19
  BlockType["Suggest"] = "blog-suggest-block";
20
20
  BlockType["Meta"] = "blog-meta-block";
21
21
  BlockType["Feed"] = "blog-feed-block";
22
- })(BlockType = exports.BlockType || (exports.BlockType = {}));
22
+ })(BlockType = exports.BlockType || (exports.BlockType = {}));
23
+ var DefaultEventNames;
24
+ (function (DefaultEventNames) {
25
+ DefaultEventNames["ShareButton"] = "share-button-click";
26
+ })(DefaultEventNames = exports.DefaultEventNames || (exports.DefaultEventNames = {}));
@@ -13,7 +13,6 @@ import './Controls.css';
13
13
  const b = block('feed-controls');
14
14
  const ICON_SIZE = 16;
15
15
  const DEFAULT_PAGE = 1;
16
- const VIRTUALIZATION_THRESHOLD = 1000;
17
16
  export const Controls = ({ setIsFetching, tags = [], services = [], handleChangeQuery, queryParams, }) => {
18
17
  const { hasLikes } = useContext(LikesContext);
19
18
  const { savedOnly: savedOnlyInitial, search: searchInitial, tags: tagInitial, services: servicesInitial, } = queryParams || {};
@@ -64,13 +63,13 @@ export const Controls = ({ setIsFetching, tags = [], services = [], handleChange
64
63
  initial: [tagInitial],
65
64
  list: tagsItems,
66
65
  defaultLabel: i18(Keyset.AllTags),
67
- }), disablePortal: true, virtualizationThreshold: VIRTUALIZATION_THRESHOLD, renderOption: renderOption })),
66
+ }), disablePortal: true, renderOption: renderOption })),
68
67
  services.length > 0 ? (React.createElement("div", { className: b('filter-item') },
69
68
  React.createElement(Select, { className: b('select'), size: "xl", multiple: true, filterable: true, disablePortal: true, options: services, defaultValue: servicesItems, popupClassName: b('popup'), onUpdate: handleServicesSelect, placeholder: i18(Keyset.AllServices), renderControl: renderSwitcher({
70
69
  initial: servicesItems,
71
70
  list: services,
72
71
  defaultLabel: i18(Keyset.AllServices),
73
- }), virtualizationThreshold: VIRTUALIZATION_THRESHOLD, renderOption: renderOption, renderFilter: renderFilter }))) : null,
72
+ }), renderOption: renderOption, renderFilter: renderFilter }))) : null,
74
73
  hasLikes ? (React.createElement("div", { className: b('filter-item', { 'width-auto': true }) },
75
74
  React.createElement(Button, { view: 'outlined', className: b('saved-only-button', { savedOnly }), size: "xl", onClick: handleSavedOnly },
76
75
  React.createElement(Icon, { data: Save, size: ICON_SIZE, className: b('icon', { savedOnly }) }),
@@ -1,25 +1,32 @@
1
- import React, { useContext } from 'react';
1
+ import { useAnalytics } from '@gravity-ui/page-constructor/build/esm/hooks/useAnalytics';
2
2
  import { SharePopover } from '@gravity-ui/uikit';
3
+ import React, { useCallback, useContext } from 'react';
3
4
  import { MobileContext } from '../../../contexts/MobileContext';
4
- import { RouterContext } from '../../../contexts/RouterContext';
5
5
  import { PostPageContext } from '../../../contexts/PostPageContext';
6
- import { i18, Keyset } from '../../../i18n';
7
- import { getAbsolutePath } from '../../../utils/common';
8
- import { block } from '../../../utils/cn';
9
- import { MetrikaCounter } from '../../../counters/utils';
10
- // @ts-ignore
6
+ import { RouterContext } from '../../../contexts/RouterContext';
11
7
  import metrika from '../../../counters/metrika.js';
8
+ import { MetrikaCounter } from '../../../counters/utils';
9
+ import { Keyset, i18 } from '../../../i18n';
12
10
  import { ShareArrowUp } from '../../../icons/ShareArrowUp';
11
+ import { DefaultEventNames } from '../../../models/common';
12
+ import { block } from '../../../utils/cn';
13
+ import { getAbsolutePath } from '../../../utils/common';
14
+ // @ts-ignore
13
15
  import '../PostInfo.css';
14
16
  const b = block('post-info');
15
17
  export const Sharing = ({ theme, metrikaGoal }) => {
16
18
  const router = useContext(RouterContext);
17
19
  const isMobile = useContext(MobileContext);
18
20
  const { shareOptions } = useContext(PostPageContext);
19
- const handleMetrika = () => {
21
+ const handleAnalyticsGlobal = useAnalytics(DefaultEventNames.ShareButton);
22
+ const handleMetrika = useCallback(() => {
20
23
  metrika.reachGoal(MetrikaCounter.CrossSite, metrikaGoal);
21
- };
24
+ }, [metrikaGoal]);
25
+ const handleAnalytics = useCallback(() => {
26
+ handleAnalyticsGlobal();
27
+ handleMetrika();
28
+ }, [handleAnalyticsGlobal, handleMetrika]);
22
29
  return (React.createElement("div", { className: b('item') },
23
30
  React.createElement("span", { className: b('icon') },
24
- React.createElement(SharePopover, { url: getAbsolutePath(router), className: b('share'), iconClass: b('share-icon'), switcherClassName: b('switcher', { theme }), tooltipClassName: b('popup'), useWebShareApi: isMobile, direction: 'column', buttonTitle: i18(Keyset.ActionShare), customIcon: ShareArrowUp, placement: "bottom", openByHover: false, shareOptions: shareOptions, handleMetrika: handleMetrika }))));
31
+ React.createElement(SharePopover, { url: getAbsolutePath(router), className: b('share'), iconClass: b('share-icon'), switcherClassName: b('switcher', { theme }), tooltipClassName: b('popup'), useWebShareApi: isMobile, direction: 'column', buttonTitle: i18(Keyset.ActionShare), customIcon: ShareArrowUp, placement: "bottom", openByHover: false, shareOptions: shareOptions, handleMetrika: handleAnalytics }))));
25
32
  };
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { AnalyticsContextProps } from '@gravity-ui/page-constructor/build/esm/context/analyticsContext';
2
3
  import { RouterContextProps } from '../contexts/RouterContext';
3
4
  import { UserContextProps } from '../contexts/UserContext';
4
5
  import { DeviceContextProps } from '../contexts/DeviceContext';
@@ -11,6 +12,7 @@ export interface BlogConstructorProviderProps {
11
12
  theme?: ThemeValueType;
12
13
  user?: UserContextProps;
13
14
  device?: DeviceContextProps;
15
+ analytics?: AnalyticsContextProps;
14
16
  children?: React.ReactNode;
15
17
  }
16
18
  export declare const BlogConstructorProvider: React.FC<BlogConstructorProviderProps>;
@@ -1,4 +1,5 @@
1
1
  import React, { Fragment } from 'react';
2
+ import { AnalyticsContext, } from '@gravity-ui/page-constructor/build/esm/context/analyticsContext';
2
3
  import { MobileContext } from '../contexts/MobileContext';
3
4
  import { LocaleContext } from '../contexts/LocaleContext';
4
5
  import { RouterContext } from '../contexts/RouterContext';
@@ -6,7 +7,7 @@ import { UserContext } from '../contexts/UserContext';
6
7
  import { DeviceContext } from '../contexts/DeviceContext';
7
8
  import { ThemeValueContext } from '../contexts/theme/ThemeValueContext';
8
9
  import { DEFAULT_THEME } from '../constants';
9
- export const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = DEFAULT_THEME, user = {}, device = {}, children, }) => {
10
+ export const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = DEFAULT_THEME, user = {}, device = {}, analytics = {}, children, }) => {
10
11
  const context = [
11
12
  React.createElement(ThemeValueContext.Provider, { value: { themeValue: theme }, key: "theme-context" }),
12
13
  React.createElement(LocaleContext.Provider, { value: { locale }, key: "locale-context" }),
@@ -14,6 +15,7 @@ export const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, th
14
15
  React.createElement(MobileContext.Provider, { value: Boolean(isMobile), key: "is-mobile-context" }),
15
16
  React.createElement(UserContext.Provider, { value: user, key: "user-context" }),
16
17
  React.createElement(DeviceContext.Provider, { value: device, key: "device-context" }),
18
+ React.createElement(AnalyticsContext.Provider, { value: analytics, key: "analytics-context" }),
17
19
  ].reduceRight((prev, provider) => React.cloneElement(provider, {}, prev), children);
18
20
  return React.createElement(Fragment, null, context);
19
21
  };
@@ -149,3 +149,6 @@ export type HandleChangeQueryParams = (params: Query) => void;
149
149
  export type SetQueryType = (params: Query, options?: {
150
150
  [y: string]: boolean;
151
151
  }) => Promise<void> | void;
152
+ export declare enum DefaultEventNames {
153
+ ShareButton = "share-button-click"
154
+ }
@@ -16,4 +16,8 @@ export var BlockType;
16
16
  BlockType["Suggest"] = "blog-suggest-block";
17
17
  BlockType["Meta"] = "blog-meta-block";
18
18
  BlockType["Feed"] = "blog-feed-block";
19
- })(BlockType || (BlockType = {}));
19
+ })(BlockType || (BlockType = {}));
20
+ export var DefaultEventNames;
21
+ (function (DefaultEventNames) {
22
+ DefaultEventNames["ShareButton"] = "share-button-click";
23
+ })(DefaultEventNames || (DefaultEventNames = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/blog-constructor",
3
- "version": "2.0.1",
3
+ "version": "2.1.0-alpha.1",
4
4
  "description": "Gravity UI Blog Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -140,5 +140,8 @@
140
140
  "*.{json,yaml,yml,md}": [
141
141
  "prettier --write"
142
142
  ]
143
+ },
144
+ "publishConfig": {
145
+ "tag": "alpha"
143
146
  }
144
147
  }
@@ -149,3 +149,6 @@ export type HandleChangeQueryParams = (params: Query) => void;
149
149
  export type SetQueryType = (params: Query, options?: {
150
150
  [y: string]: boolean;
151
151
  }) => Promise<void> | void;
152
+ export declare enum DefaultEventNames {
153
+ ShareButton = "share-button-click"
154
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BlockType = exports.Theme = void 0;
3
+ exports.DefaultEventNames = exports.BlockType = exports.Theme = void 0;
4
4
  var Theme;
5
5
  (function (Theme) {
6
6
  Theme["Light"] = "light";
@@ -19,4 +19,8 @@ var BlockType;
19
19
  BlockType["Suggest"] = "blog-suggest-block";
20
20
  BlockType["Meta"] = "blog-meta-block";
21
21
  BlockType["Feed"] = "blog-feed-block";
22
- })(BlockType = exports.BlockType || (exports.BlockType = {}));
22
+ })(BlockType = exports.BlockType || (exports.BlockType = {}));
23
+ var DefaultEventNames;
24
+ (function (DefaultEventNames) {
25
+ DefaultEventNames["ShareButton"] = "share-button-click";
26
+ })(DefaultEventNames = exports.DefaultEventNames || (exports.DefaultEventNames = {}));