@gravity-ui/blog-constructor 2.3.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.0.1](https://github.com/gravity-ui/blog-constructor/compare/v3.0.0...v3.0.1) (2023-04-24)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * rewrap pagination item ([#36](https://github.com/gravity-ui/blog-constructor/issues/36)) ([a3a56b2](https://github.com/gravity-ui/blog-constructor/commit/a3a56b2d4519871427de1e42267ce18736f7f7b1))
9
+
10
+ ## [3.0.0](https://github.com/gravity-ui/blog-constructor/compare/v2.3.0...v3.0.0) (2023-04-10)
11
+
12
+
13
+ ### ⚠ BREAKING CHANGES
14
+
15
+ * add callback prop for blog page ([#25](https://github.com/gravity-ui/blog-constructor/issues/25))
16
+
17
+ ### Features
18
+
19
+ * add callback prop for blog page ([#25](https://github.com/gravity-ui/blog-constructor/issues/25)) ([7b1ab2c](https://github.com/gravity-ui/blog-constructor/commit/7b1ab2c12aa9ef4f8e5a11853508a9b439a196d7))
20
+
3
21
  ## [2.3.0](https://github.com/gravity-ui/blog-constructor/compare/v2.2.0...v2.3.0) (2023-04-10)
4
22
 
5
23
 
package/README.md CHANGED
@@ -47,6 +47,8 @@ import {BlogPostPage, BlogConstructorProvider} from '@gravity-ui/blog-constructo
47
47
 
48
48
  ```
49
49
 
50
+ Documentation about [providerProps](./src/constructor/README.md).
51
+
50
52
  Also blog-constructor have server components to help you transform your data if you need
51
53
 
52
54
  ```jsx
@@ -38,7 +38,6 @@ const Posts_1 = require("../../components/Posts/Posts");
38
38
  const PostsError_1 = require("../../components/PostsError/PostsError");
39
39
  const constants_1 = require("../../constants");
40
40
  const FeedContext_1 = require("../../contexts/FeedContext");
41
- const LocaleContext_1 = require("../../contexts/LocaleContext");
42
41
  const RouterContext_1 = require("../../contexts/RouterContext");
43
42
  /**
44
43
  * @deprecated Metrika will be deleted after launch of analyticsEvents
@@ -56,7 +55,6 @@ const Feed = ({ image }) => {
56
55
  var _a;
57
56
  const { posts, totalCount, tags, services, pinnedPost, getPosts, pageCountForShowSupportButtons, } = (0, react_1.useContext)(FeedContext_1.FeedContext);
58
57
  const router = (0, react_1.useContext)(RouterContext_1.RouterContext);
59
- const { locale } = (0, react_1.useContext)(LocaleContext_1.LocaleContext);
60
58
  const handleAnalytics = (0, page_constructor_1.useAnalytics)(common_1.DefaultEventNames.ShowMore);
61
59
  const [{ errorLoad, errorShowMore, isFetching, isShowMoreFetching, isShowMoreVisible, lastLoadedCount, postCountOnPage, postsOnPage, pinnedPostOnPage, currentPage, queryParams, }, dispatch,] = (0, react_1.useReducer)(reducer_1.reducer, {
62
60
  errorLoad: false,
@@ -79,6 +77,12 @@ const Feed = ({ image }) => {
79
77
  };
80
78
  const handleChangeQueryParams = (value) => {
81
79
  dispatch({ type: reducer_1.ActionTypes.QueryParamsChange, payload: value });
80
+ const hasFirstPageQuery = Object.keys(value).some((queryKey) => queryKey === PAGE_QUERY && value[queryKey] === FIRST_PAGE);
81
+ if (hasFirstPageQuery) {
82
+ // eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign
83
+ value[PAGE_QUERY] = null;
84
+ }
85
+ router.updateQueryCallback(value);
82
86
  };
83
87
  const handlePageChange = async (value) => {
84
88
  pageChange(value);
@@ -169,22 +173,6 @@ const Feed = ({ image }) => {
169
173
  value: tag.slug,
170
174
  icon: tag.icon && react_1.default.createElement(uikit_1.Icon, { data: tag.icon }),
171
175
  })), [tags]);
172
- (0, react_1.useEffect)(() => {
173
- const queryString = Object.keys(queryParams)
174
- .reduce((acc, curr) => {
175
- if (curr === PAGE_QUERY && queryParams[curr] === FIRST_PAGE) {
176
- return acc;
177
- }
178
- if (queryParams[curr]) {
179
- acc.push(`${curr}=${queryParams[curr]}`);
180
- }
181
- return acc;
182
- }, [])
183
- .join('&');
184
- const pathPrefix = (locale === null || locale === void 0 ? void 0 : locale.pathPrefix) ? `/${locale === null || locale === void 0 ? void 0 : locale.pathPrefix}/` : '/';
185
- const newUrl = `${pathPrefix}blog${queryString ? `?${queryString}` : ''}`;
186
- window.history.replaceState(Object.assign(Object.assign({}, window.history.state), { as: newUrl, url: newUrl }), '', newUrl);
187
- }, [locale === null || locale === void 0 ? void 0 : locale.pathPrefix, queryParams]);
188
176
  return (react_1.default.createElement("div", null,
189
177
  react_1.default.createElement(FeedHeader_1.FeedHeader, { verticalOffset: "s", tags: tagItems, services: serviceItems, setIsFetching: setIsFetching, handleChangeQuery: handleChangeQueryParams, queryParams: queryParams, background: {
190
178
  fullWidth: true,
@@ -9,6 +9,8 @@ unpredictable css rules order in build */
9
9
  }
10
10
  .bc-paginator__link {
11
11
  text-decoration: none;
12
+ pointer-events: none;
13
+ color: var(--yc-color-text-primary);
12
14
  }
13
15
  .bc-paginator__item {
14
16
  display: inline-flex;
@@ -36,7 +36,7 @@ const PaginatorItem = ({ dataKey, mods, content, onClick, loading = false, }) =>
36
36
  const itemKey = Number(dataKey) > 0 ? Number(dataKey) : dataKey;
37
37
  const navTag = itemKey > 0 ? `${mods.type || 'page'}=${itemKey}` : itemKey;
38
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)));
39
+ 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) },
40
+ react_1.default.createElement("a", { href: navigationLink, className: b('link'), onClick: (event) => event.preventDefault() }, content)));
41
41
  };
42
42
  exports.PaginatorItem = PaginatorItem;
@@ -5,5 +5,6 @@ export interface RouterContextProps {
5
5
  as: string;
6
6
  hostname: string;
7
7
  query?: Query;
8
+ updateQueryCallback: (query: Query) => void;
8
9
  }
9
10
  export declare const RouterContext: React.Context<RouterContextProps>;
@@ -1,18 +1,6 @@
1
1
  import React from 'react';
2
2
  export interface UserAccount {
3
3
  uid: string;
4
- login: string;
5
- avatarId: string;
6
- displayName?: string;
7
- lang?: string;
8
- hasStaffLogin?: boolean;
9
4
  }
10
- export interface User extends UserAccount {
11
- accounts: UserAccount[];
12
- passportHost: string;
13
- avatarHost: string;
14
- status: string;
15
- yandexuid: string;
16
- }
17
- export type UserContextProps = Partial<User>;
18
- export declare const UserContext: React.Context<Partial<User>>;
5
+ export type UserContextProps = Partial<UserAccount>;
6
+ export declare const UserContext: React.Context<Partial<UserAccount>>;
@@ -9,7 +9,6 @@ import { Posts } from '../../components/Posts/Posts';
9
9
  import { PostsError } from '../../components/PostsError/PostsError';
10
10
  import { BlogMetrikaGoalIds } from '../../constants';
11
11
  import { FeedContext } from '../../contexts/FeedContext';
12
- import { LocaleContext } from '../../contexts/LocaleContext';
13
12
  import { RouterContext } from '../../contexts/RouterContext';
14
13
  /**
15
14
  * @deprecated Metrika will be deleted after launch of analyticsEvents
@@ -27,7 +26,6 @@ export const Feed = ({ image }) => {
27
26
  var _a;
28
27
  const { posts, totalCount, tags, services, pinnedPost, getPosts, pageCountForShowSupportButtons, } = useContext(FeedContext);
29
28
  const router = useContext(RouterContext);
30
- const { locale } = useContext(LocaleContext);
31
29
  const handleAnalytics = useAnalytics(DefaultEventNames.ShowMore);
32
30
  const [{ errorLoad, errorShowMore, isFetching, isShowMoreFetching, isShowMoreVisible, lastLoadedCount, postCountOnPage, postsOnPage, pinnedPostOnPage, currentPage, queryParams, }, dispatch,] = useReducer(reducer, {
33
31
  errorLoad: false,
@@ -50,6 +48,12 @@ export const Feed = ({ image }) => {
50
48
  };
51
49
  const handleChangeQueryParams = (value) => {
52
50
  dispatch({ type: ActionTypes.QueryParamsChange, payload: value });
51
+ const hasFirstPageQuery = Object.keys(value).some((queryKey) => queryKey === PAGE_QUERY && value[queryKey] === FIRST_PAGE);
52
+ if (hasFirstPageQuery) {
53
+ // eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign
54
+ value[PAGE_QUERY] = null;
55
+ }
56
+ router.updateQueryCallback(value);
53
57
  };
54
58
  const handlePageChange = async (value) => {
55
59
  pageChange(value);
@@ -140,22 +144,6 @@ export const Feed = ({ image }) => {
140
144
  value: tag.slug,
141
145
  icon: tag.icon && React.createElement(Icon, { data: tag.icon }),
142
146
  })), [tags]);
143
- useEffect(() => {
144
- const queryString = Object.keys(queryParams)
145
- .reduce((acc, curr) => {
146
- if (curr === PAGE_QUERY && queryParams[curr] === FIRST_PAGE) {
147
- return acc;
148
- }
149
- if (queryParams[curr]) {
150
- acc.push(`${curr}=${queryParams[curr]}`);
151
- }
152
- return acc;
153
- }, [])
154
- .join('&');
155
- const pathPrefix = (locale === null || locale === void 0 ? void 0 : locale.pathPrefix) ? `/${locale === null || locale === void 0 ? void 0 : locale.pathPrefix}/` : '/';
156
- const newUrl = `${pathPrefix}blog${queryString ? `?${queryString}` : ''}`;
157
- window.history.replaceState(Object.assign(Object.assign({}, window.history.state), { as: newUrl, url: newUrl }), '', newUrl);
158
- }, [locale === null || locale === void 0 ? void 0 : locale.pathPrefix, queryParams]);
159
147
  return (React.createElement("div", null,
160
148
  React.createElement(FeedHeader, { verticalOffset: "s", tags: tagItems, services: serviceItems, setIsFetching: setIsFetching, handleChangeQuery: handleChangeQueryParams, queryParams: queryParams, background: {
161
149
  fullWidth: true,
@@ -9,6 +9,8 @@ unpredictable css rules order in build */
9
9
  }
10
10
  .bc-paginator__link {
11
11
  text-decoration: none;
12
+ pointer-events: none;
13
+ color: var(--yc-color-text-primary);
12
14
  }
13
15
  .bc-paginator__item {
14
16
  display: inline-flex;
@@ -11,6 +11,6 @@ export const PaginatorItem = ({ dataKey, mods, content, onClick, loading = false
11
11
  const itemKey = Number(dataKey) > 0 ? Number(dataKey) : dataKey;
12
12
  const navTag = itemKey > 0 ? `${mods.type || 'page'}=${itemKey}` : itemKey;
13
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)));
14
+ 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) },
15
+ React.createElement("a", { href: navigationLink, className: b('link'), onClick: (event) => event.preventDefault() }, content)));
16
16
  };
@@ -5,5 +5,6 @@ export interface RouterContextProps {
5
5
  as: string;
6
6
  hostname: string;
7
7
  query?: Query;
8
+ updateQueryCallback: (query: Query) => void;
8
9
  }
9
10
  export declare const RouterContext: React.Context<RouterContextProps>;
@@ -1,18 +1,6 @@
1
1
  import React from 'react';
2
2
  export interface UserAccount {
3
3
  uid: string;
4
- login: string;
5
- avatarId: string;
6
- displayName?: string;
7
- lang?: string;
8
- hasStaffLogin?: boolean;
9
4
  }
10
- export interface User extends UserAccount {
11
- accounts: UserAccount[];
12
- passportHost: string;
13
- avatarHost: string;
14
- status: string;
15
- yandexuid: string;
16
- }
17
- export type UserContextProps = Partial<User>;
18
- export declare const UserContext: React.Context<Partial<User>>;
5
+ export type UserContextProps = Partial<UserAccount>;
6
+ export declare const UserContext: React.Context<Partial<UserAccount>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/blog-constructor",
3
- "version": "2.3.0",
3
+ "version": "3.0.1",
4
4
  "description": "Gravity UI Blog Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {