@gravity-ui/blog-constructor 2.3.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +18 -0
- package/README.md +2 -0
- package/build/cjs/blocks/Feed/Feed.js +6 -18
- package/build/cjs/components/Paginator/Paginator.css +2 -0
- package/build/cjs/components/Paginator/components/PaginatorItem.js +2 -2
- package/build/cjs/contexts/RouterContext.d.ts +1 -0
- package/build/cjs/contexts/UserContext.d.ts +2 -14
- package/build/esm/blocks/Feed/Feed.js +6 -18
- package/build/esm/components/Paginator/Paginator.css +2 -0
- package/build/esm/components/Paginator/components/PaginatorItem.js +2 -2
- package/build/esm/contexts/RouterContext.d.ts +1 -0
- package/build/esm/contexts/UserContext.d.ts +2 -14
- package/package.json +1 -1
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,
|
@@ -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(
|
40
|
-
react_1.default.createElement(
|
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;
|
@@ -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
|
11
|
-
|
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,
|
@@ -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(
|
15
|
-
React.createElement(
|
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
|
};
|
@@ -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
|
11
|
-
|
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>>;
|