@gravity-ui/blog-constructor 2.1.0-alpha.2 → 2.1.2-alpha.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.0.2](https://github.com/gravity-ui/blog-constructor/compare/v2.0.1...v2.0.2) (2023-04-05)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * covering pagination buttons into 'a' tag ([#23](https://github.com/gravity-ui/blog-constructor/issues/23)) ([e603f2e](https://github.com/gravity-ui/blog-constructor/commit/e603f2e2b0f86d492132174a1c8172786e7a09a1))
9
+
10
+ ## [2.0.1](https://github.com/gravity-ui/blog-constructor/compare/v2.0.0...v2.0.1) (2023-04-04)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * 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))
16
+ * 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))
17
+
3
18
  ## [2.0.0](https://github.com/gravity-ui/blog-constructor/compare/v1.1.2...v2.0.0) (2023-04-03)
4
19
 
5
20
 
@@ -41,6 +41,7 @@ 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;
44
45
  const Controls = ({ setIsFetching, tags = [], services = [], handleChangeQuery, queryParams, }) => {
45
46
  const { hasLikes } = (0, react_1.useContext)(LikesContext_1.LikesContext);
46
47
  const { savedOnly: savedOnlyInitial, search: searchInitial, tags: tagInitial, services: servicesInitial, } = queryParams || {};
@@ -91,13 +92,13 @@ const Controls = ({ setIsFetching, tags = [], services = [], handleChangeQuery,
91
92
  initial: [tagInitial],
92
93
  list: tagsItems,
93
94
  defaultLabel: (0, i18n_1.i18)(i18n_1.Keyset.AllTags),
94
- }), disablePortal: true, renderOption: customRenders_1.renderOption })),
95
+ }), disablePortal: true, virtualizationThreshold: VIRTUALIZATION_THRESHOLD, renderOption: customRenders_1.renderOption })),
95
96
  services.length > 0 ? (react_1.default.createElement("div", { className: b('filter-item') },
96
97
  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)({
97
98
  initial: servicesItems,
98
99
  list: services,
99
100
  defaultLabel: (0, i18n_1.i18)(i18n_1.Keyset.AllServices),
100
- }), renderOption: customRenders_1.renderOption, renderFilter: customRenders_1.renderFilter }))) : null,
101
+ }), virtualizationThreshold: VIRTUALIZATION_THRESHOLD, renderOption: customRenders_1.renderOption, renderFilter: customRenders_1.renderFilter }))) : null,
101
102
  hasLikes ? (react_1.default.createElement("div", { className: b('filter-item', { 'width-auto': true }) },
102
103
  react_1.default.createElement(uikit_1.Button, { view: 'outlined', className: b('saved-only-button', { savedOnly }), size: "xl", onClick: handleSavedOnly },
103
104
  react_1.default.createElement(uikit_1.Icon, { data: Save_1.Save, size: ICON_SIZE, className: b('icon', { savedOnly }) }),
@@ -7,6 +7,9 @@ unpredictable css rules order in build */
7
7
  display: flex;
8
8
  align-items: center;
9
9
  }
10
+ .bc-paginator__link {
11
+ text-decoration: none;
12
+ }
10
13
  .bc-paginator__item {
11
14
  display: inline-flex;
12
15
  align-items: center;
@@ -1,15 +1,42 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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;
4
24
  };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
26
  exports.PaginatorItem = void 0;
7
- const react_1 = __importDefault(require("react"));
27
+ const react_1 = __importStar(require("react"));
8
28
  const uikit_1 = require("@gravity-ui/uikit");
29
+ const LocaleContext_1 = require("../../../contexts/LocaleContext");
30
+ const common_1 = require("../../../utils/common");
9
31
  const cn_1 = require("../../../utils/cn");
10
32
  const b = (0, cn_1.block)('paginator');
11
33
  const PaginatorItem = ({ dataKey, mods, content, onClick, loading = false, }) => {
34
+ const { locale } = (0, react_1.useContext)(LocaleContext_1.LocaleContext);
35
+ const urlPath = (0, common_1.getBlogPath)((locale === null || locale === void 0 ? void 0 : locale.pathPrefix) || '');
12
36
  const itemKey = Number(dataKey) > 0 ? Number(dataKey) : dataKey;
13
- return (react_1.default.createElement(uikit_1.Button, { view: "flat", size: "xl", className: b('item', mods), onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick(itemKey), loading: loading && Boolean(mods.active) }, content));
37
+ const navTag = itemKey > 0 ? `${mods.type || 'page'}=${itemKey}` : itemKey;
38
+ const navigationLink = `${urlPath || ''}?${navTag}`;
39
+ return (react_1.default.createElement("a", { href: navigationLink, className: b('link', mods), onClick: (event) => event.preventDefault() },
40
+ react_1.default.createElement(uikit_1.Button, { view: "flat", size: "xl", className: b('item', mods), onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick(itemKey), loading: loading && Boolean(mods.active) }, content)));
14
41
  };
15
42
  exports.PaginatorItem = PaginatorItem;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { AnalyticsContextProps } from '@gravity-ui/page-constructor/build/esm/context/analyticsContext';
2
+ import { AnalyticsContextProps } from '@gravity-ui/page-constructor';
3
3
  import { RouterContextProps } from '../contexts/RouterContext';
4
4
  import { UserContextProps } from '../contexts/UserContext';
5
5
  import { DeviceContextProps } from '../contexts/DeviceContext';
@@ -25,7 +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
+ const page_constructor_1 = require("@gravity-ui/page-constructor");
29
29
  const MobileContext_1 = require("../contexts/MobileContext");
30
30
  const LocaleContext_1 = require("../contexts/LocaleContext");
31
31
  const RouterContext_1 = require("../contexts/RouterContext");
@@ -41,7 +41,7 @@ const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = c
41
41
  react_1.default.createElement(MobileContext_1.MobileContext.Provider, { value: Boolean(isMobile), key: "is-mobile-context" }),
42
42
  react_1.default.createElement(UserContext_1.UserContext.Provider, { value: user, key: "user-context" }),
43
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" }),
44
+ react_1.default.createElement(page_constructor_1.AnalyticsContext.Provider, { value: analytics, key: "analytics-context" }),
45
45
  ].reduceRight((prev, provider) => react_1.default.cloneElement(provider, {}, prev), children);
46
46
  return react_1.default.createElement(react_1.Fragment, null, context);
47
47
  };
@@ -34,6 +34,7 @@ type GetBreadcrumbsProps = {
34
34
  tags?: Tag[];
35
35
  pathPrefix?: string;
36
36
  };
37
+ export declare const getBlogPath: (pathPrefix: string) => string;
37
38
  export declare const getBreadcrumbs: ({ tags, pathPrefix }: GetBreadcrumbsProps) => HeaderBreadCrumbsProps;
38
39
  export declare const isMetrikaExist: (goal: NewMetrikaGoal, existGoals: NewMetrikaGoal[]) => boolean;
39
40
  export declare const getBlogElementMetrika: (blogCustomGoal: NewMetrikaGoal, existingGoals?: MetrikaGoal) => string | string[] | NewMetrikaGoal[];
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  return t;
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.scrollOnPageChange = exports.getFeedQueryParams = exports.getBlogElementMetrika = exports.isMetrikaExist = exports.getBreadcrumbs = exports.updateContentSizes = exports.getTagFilterUrl = exports.postLikeStatus = exports.getTags = exports.scrollToHash = exports.getPageSearchParams = exports.getAbsolutePath = void 0;
14
+ exports.scrollOnPageChange = exports.getFeedQueryParams = exports.getBlogElementMetrika = exports.isMetrikaExist = exports.getBreadcrumbs = exports.getBlogPath = exports.updateContentSizes = exports.getTagFilterUrl = exports.postLikeStatus = exports.getTags = exports.scrollToHash = exports.getPageSearchParams = exports.getAbsolutePath = void 0;
15
15
  const url_1 = require("url");
16
16
  const lodash_1 = require("lodash");
17
17
  const page_constructor_1 = require("@gravity-ui/page-constructor");
@@ -65,6 +65,11 @@ const updateContentSizes = (_a) => {
65
65
  return (Object.assign(Object.assign({}, contentData), { size: size || constants_1.CONTENT_DEFAULT_SIZE, colSizes: colSizes || constants_1.CONTENT_DEFAULT_COL_SIZES, theme: theme || constants_1.CONTENT_DEFAULT_THEME }));
66
66
  };
67
67
  exports.updateContentSizes = updateContentSizes;
68
+ const getBlogPath = (pathPrefix) => {
69
+ const prefix = pathPrefix ? `/${pathPrefix}/` : '/';
70
+ return `${prefix}blog`;
71
+ };
72
+ exports.getBlogPath = getBlogPath;
68
73
  const getBreadcrumbs = ({ tags, pathPrefix }) => {
69
74
  const prefix = pathPrefix ? `/${pathPrefix}/` : '/';
70
75
  const breadcrumbs = {
@@ -13,6 +13,7 @@ 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;
16
17
  export const Controls = ({ setIsFetching, tags = [], services = [], handleChangeQuery, queryParams, }) => {
17
18
  const { hasLikes } = useContext(LikesContext);
18
19
  const { savedOnly: savedOnlyInitial, search: searchInitial, tags: tagInitial, services: servicesInitial, } = queryParams || {};
@@ -63,13 +64,13 @@ export const Controls = ({ setIsFetching, tags = [], services = [], handleChange
63
64
  initial: [tagInitial],
64
65
  list: tagsItems,
65
66
  defaultLabel: i18(Keyset.AllTags),
66
- }), disablePortal: true, renderOption: renderOption })),
67
+ }), disablePortal: true, virtualizationThreshold: VIRTUALIZATION_THRESHOLD, renderOption: renderOption })),
67
68
  services.length > 0 ? (React.createElement("div", { className: b('filter-item') },
68
69
  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({
69
70
  initial: servicesItems,
70
71
  list: services,
71
72
  defaultLabel: i18(Keyset.AllServices),
72
- }), renderOption: renderOption, renderFilter: renderFilter }))) : null,
73
+ }), virtualizationThreshold: VIRTUALIZATION_THRESHOLD, renderOption: renderOption, renderFilter: renderFilter }))) : null,
73
74
  hasLikes ? (React.createElement("div", { className: b('filter-item', { 'width-auto': true }) },
74
75
  React.createElement(Button, { view: 'outlined', className: b('saved-only-button', { savedOnly }), size: "xl", onClick: handleSavedOnly },
75
76
  React.createElement(Icon, { data: Save, size: ICON_SIZE, className: b('icon', { savedOnly }) }),
@@ -7,6 +7,9 @@ unpredictable css rules order in build */
7
7
  display: flex;
8
8
  align-items: center;
9
9
  }
10
+ .bc-paginator__link {
11
+ text-decoration: none;
12
+ }
10
13
  .bc-paginator__item {
11
14
  display: inline-flex;
12
15
  align-items: center;
@@ -1,9 +1,16 @@
1
- import React from 'react';
1
+ import React, { useContext } from 'react';
2
2
  import { Button } from '@gravity-ui/uikit';
3
+ import { LocaleContext } from '../../../contexts/LocaleContext';
4
+ import { getBlogPath } from '../../../utils/common';
3
5
  import { block } from '../../../utils/cn';
4
6
  import '../Paginator.css';
5
7
  const b = block('paginator');
6
8
  export const PaginatorItem = ({ dataKey, mods, content, onClick, loading = false, }) => {
9
+ const { locale } = useContext(LocaleContext);
10
+ const urlPath = getBlogPath((locale === null || locale === void 0 ? void 0 : locale.pathPrefix) || '');
7
11
  const itemKey = Number(dataKey) > 0 ? Number(dataKey) : dataKey;
8
- return (React.createElement(Button, { view: "flat", size: "xl", className: b('item', mods), onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick(itemKey), loading: loading && Boolean(mods.active) }, content));
12
+ const navTag = itemKey > 0 ? `${mods.type || 'page'}=${itemKey}` : itemKey;
13
+ const navigationLink = `${urlPath || ''}?${navTag}`;
14
+ return (React.createElement("a", { href: navigationLink, className: b('link', mods), onClick: (event) => event.preventDefault() },
15
+ React.createElement(Button, { view: "flat", size: "xl", className: b('item', mods), onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick(itemKey), loading: loading && Boolean(mods.active) }, content)));
9
16
  };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { AnalyticsContextProps } from '@gravity-ui/page-constructor/build/esm/context/analyticsContext';
2
+ import { AnalyticsContextProps } from '@gravity-ui/page-constructor';
3
3
  import { RouterContextProps } from '../contexts/RouterContext';
4
4
  import { UserContextProps } from '../contexts/UserContext';
5
5
  import { DeviceContextProps } from '../contexts/DeviceContext';
@@ -1,5 +1,5 @@
1
1
  import React, { Fragment } from 'react';
2
- import { AnalyticsContext, } from '@gravity-ui/page-constructor/build/esm/context/analyticsContext';
2
+ import { AnalyticsContext } from '@gravity-ui/page-constructor';
3
3
  import { MobileContext } from '../contexts/MobileContext';
4
4
  import { LocaleContext } from '../contexts/LocaleContext';
5
5
  import { RouterContext } from '../contexts/RouterContext';
@@ -34,6 +34,7 @@ type GetBreadcrumbsProps = {
34
34
  tags?: Tag[];
35
35
  pathPrefix?: string;
36
36
  };
37
+ export declare const getBlogPath: (pathPrefix: string) => string;
37
38
  export declare const getBreadcrumbs: ({ tags, pathPrefix }: GetBreadcrumbsProps) => HeaderBreadCrumbsProps;
38
39
  export declare const isMetrikaExist: (goal: NewMetrikaGoal, existGoals: NewMetrikaGoal[]) => boolean;
39
40
  export declare const getBlogElementMetrika: (blogCustomGoal: NewMetrikaGoal, existingGoals?: MetrikaGoal) => string | string[] | NewMetrikaGoal[];
@@ -57,6 +57,10 @@ export const updateContentSizes = (_a) => {
57
57
  var { size, colSizes, theme } = _a, contentData = __rest(_a, ["size", "colSizes", "theme"]);
58
58
  return (Object.assign(Object.assign({}, contentData), { size: size || CONTENT_DEFAULT_SIZE, colSizes: colSizes || CONTENT_DEFAULT_COL_SIZES, theme: theme || CONTENT_DEFAULT_THEME }));
59
59
  };
60
+ export const getBlogPath = (pathPrefix) => {
61
+ const prefix = pathPrefix ? `/${pathPrefix}/` : '/';
62
+ return `${prefix}blog`;
63
+ };
60
64
  export const getBreadcrumbs = ({ tags, pathPrefix }) => {
61
65
  const prefix = pathPrefix ? `/${pathPrefix}/` : '/';
62
66
  const breadcrumbs = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/blog-constructor",
3
- "version": "2.1.0-alpha.2",
3
+ "version": "2.1.2-alpha.0",
4
4
  "description": "Gravity UI Blog Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {