@gravity-ui/blog-constructor 3.2.0 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +7 -0
- package/build/cjs/components/Paginator/Paginator.css +0 -1
- package/build/cjs/components/Paginator/components/PaginatorItem.js +4 -2
- package/build/cjs/constructor/BlogConstructorProvider.d.ts +2 -0
- package/build/cjs/constructor/BlogConstructorProvider.js +3 -1
- package/build/cjs/contexts/SettingsContext.d.ts +5 -0
- package/build/cjs/contexts/SettingsContext.js +8 -0
- package/build/esm/components/Paginator/Paginator.css +0 -1
- package/build/esm/components/Paginator/components/PaginatorItem.js +5 -3
- package/build/esm/constructor/BlogConstructorProvider.d.ts +2 -0
- package/build/esm/constructor/BlogConstructorProvider.js +3 -1
- package/build/esm/contexts/SettingsContext.d.ts +5 -0
- package/build/esm/contexts/SettingsContext.js +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [3.2.1](https://github.com/gravity-ui/blog-constructor/compare/v3.2.0...v3.2.1) (2023-05-16)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* add settings context to add a tag for pagination ([#47](https://github.com/gravity-ui/blog-constructor/issues/47)) ([0856675](https://github.com/gravity-ui/blog-constructor/commit/0856675316425c9a690664a99d30d2af63e116ca))
|
9
|
+
|
3
10
|
## [3.2.0](https://github.com/gravity-ui/blog-constructor/compare/v3.1.1...v3.2.0) (2023-05-15)
|
4
11
|
|
5
12
|
|
@@ -27,16 +27,18 @@ exports.PaginatorItem = void 0;
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
28
28
|
const uikit_1 = require("@gravity-ui/uikit");
|
29
29
|
const LocaleContext_1 = require("../../../contexts/LocaleContext");
|
30
|
+
const SettingsContext_1 = require("../../../contexts/SettingsContext");
|
30
31
|
const cn_1 = require("../../../utils/cn");
|
31
32
|
const common_1 = require("../../../utils/common");
|
32
33
|
const b = (0, cn_1.block)('paginator');
|
33
34
|
const PaginatorItem = ({ dataKey, mods, content, onClick, loading = false, index, }) => {
|
34
35
|
const { locale } = (0, react_1.useContext)(LocaleContext_1.LocaleContext);
|
36
|
+
const { addNavigationLinkForPages } = (0, react_1.useContext)(SettingsContext_1.SettingsContext);
|
35
37
|
const urlPath = (0, common_1.getBlogPath)((locale === null || locale === void 0 ? void 0 : locale.pathPrefix) || '');
|
36
38
|
const itemKey = Number(dataKey) > 0 ? Number(dataKey) : dataKey;
|
37
39
|
const navTag = index > 1 ? `?page=${index}` : '';
|
38
40
|
const navigationLink = `${urlPath || ''}${navTag}`;
|
39
|
-
|
40
|
-
|
41
|
+
const renderButton = (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));
|
42
|
+
return (react_1.default.createElement(react_1.Fragment, null, addNavigationLinkForPages ? (react_1.default.createElement("a", { href: navigationLink, className: b('link'), onClick: (event) => event.preventDefault() }, renderButton)) : (react_1.default.createElement(react_1.Fragment, null, renderButton))));
|
41
43
|
};
|
42
44
|
exports.PaginatorItem = PaginatorItem;
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
2
2
|
import { AnalyticsContextProps } from '@gravity-ui/page-constructor';
|
3
3
|
import { DeviceContextProps } from '../contexts/DeviceContext';
|
4
4
|
import { RouterContextProps } from '../contexts/RouterContext';
|
5
|
+
import { SettingsContextProps } from '../contexts/SettingsContext';
|
5
6
|
import { ThemeValueType } from '../contexts/theme/ThemeValueContext';
|
6
7
|
import { Locale } from '../models/locale';
|
7
8
|
export interface BlogConstructorProviderProps {
|
@@ -11,6 +12,7 @@ export interface BlogConstructorProviderProps {
|
|
11
12
|
theme?: ThemeValueType;
|
12
13
|
device?: DeviceContextProps;
|
13
14
|
analytics?: AnalyticsContextProps;
|
15
|
+
settings?: SettingsContextProps;
|
14
16
|
children?: React.ReactNode;
|
15
17
|
}
|
16
18
|
export declare const BlogConstructorProvider: React.FC<BlogConstructorProviderProps>;
|
@@ -31,14 +31,16 @@ const DeviceContext_1 = require("../contexts/DeviceContext");
|
|
31
31
|
const LocaleContext_1 = require("../contexts/LocaleContext");
|
32
32
|
const MobileContext_1 = require("../contexts/MobileContext");
|
33
33
|
const RouterContext_1 = require("../contexts/RouterContext");
|
34
|
+
const SettingsContext_1 = require("../contexts/SettingsContext");
|
34
35
|
const ThemeValueContext_1 = require("../contexts/theme/ThemeValueContext");
|
35
|
-
const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = constants_1.DEFAULT_THEME, device = {}, analytics = {}, children, }) => {
|
36
|
+
const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = constants_1.DEFAULT_THEME, device = {}, analytics = {}, settings = {}, 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" }),
|
39
40
|
react_1.default.createElement(RouterContext_1.RouterContext.Provider, { value: router, key: "router-context" }),
|
40
41
|
react_1.default.createElement(MobileContext_1.MobileContext.Provider, { value: Boolean(isMobile), key: "is-mobile-context" }),
|
41
42
|
react_1.default.createElement(DeviceContext_1.DeviceContext.Provider, { value: device, key: "device-context" }),
|
43
|
+
react_1.default.createElement(SettingsContext_1.SettingsContext.Provider, { value: settings, key: "settings-context" }),
|
42
44
|
react_1.default.createElement(page_constructor_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);
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.SettingsContext = void 0;
|
7
|
+
const react_1 = __importDefault(require("react"));
|
8
|
+
exports.SettingsContext = react_1.default.createContext({});
|
@@ -1,16 +1,18 @@
|
|
1
|
-
import React, { useContext } from 'react';
|
1
|
+
import React, { Fragment, useContext } from 'react';
|
2
2
|
import { Button } from '@gravity-ui/uikit';
|
3
3
|
import { LocaleContext } from '../../../contexts/LocaleContext';
|
4
|
+
import { SettingsContext } from '../../../contexts/SettingsContext';
|
4
5
|
import { block } from '../../../utils/cn';
|
5
6
|
import { getBlogPath } from '../../../utils/common';
|
6
7
|
import '../Paginator.css';
|
7
8
|
const b = block('paginator');
|
8
9
|
export const PaginatorItem = ({ dataKey, mods, content, onClick, loading = false, index, }) => {
|
9
10
|
const { locale } = useContext(LocaleContext);
|
11
|
+
const { addNavigationLinkForPages } = useContext(SettingsContext);
|
10
12
|
const urlPath = getBlogPath((locale === null || locale === void 0 ? void 0 : locale.pathPrefix) || '');
|
11
13
|
const itemKey = Number(dataKey) > 0 ? Number(dataKey) : dataKey;
|
12
14
|
const navTag = index > 1 ? `?page=${index}` : '';
|
13
15
|
const navigationLink = `${urlPath || ''}${navTag}`;
|
14
|
-
|
15
|
-
|
16
|
+
const renderButton = (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));
|
17
|
+
return (React.createElement(Fragment, null, addNavigationLinkForPages ? (React.createElement("a", { href: navigationLink, className: b('link'), onClick: (event) => event.preventDefault() }, renderButton)) : (React.createElement(Fragment, null, renderButton))));
|
16
18
|
};
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
2
2
|
import { AnalyticsContextProps } from '@gravity-ui/page-constructor';
|
3
3
|
import { DeviceContextProps } from '../contexts/DeviceContext';
|
4
4
|
import { RouterContextProps } from '../contexts/RouterContext';
|
5
|
+
import { SettingsContextProps } from '../contexts/SettingsContext';
|
5
6
|
import { ThemeValueType } from '../contexts/theme/ThemeValueContext';
|
6
7
|
import { Locale } from '../models/locale';
|
7
8
|
export interface BlogConstructorProviderProps {
|
@@ -11,6 +12,7 @@ export interface BlogConstructorProviderProps {
|
|
11
12
|
theme?: ThemeValueType;
|
12
13
|
device?: DeviceContextProps;
|
13
14
|
analytics?: AnalyticsContextProps;
|
15
|
+
settings?: SettingsContextProps;
|
14
16
|
children?: React.ReactNode;
|
15
17
|
}
|
16
18
|
export declare const BlogConstructorProvider: React.FC<BlogConstructorProviderProps>;
|
@@ -5,14 +5,16 @@ import { DeviceContext } from '../contexts/DeviceContext';
|
|
5
5
|
import { LocaleContext } from '../contexts/LocaleContext';
|
6
6
|
import { MobileContext } from '../contexts/MobileContext';
|
7
7
|
import { RouterContext } from '../contexts/RouterContext';
|
8
|
+
import { SettingsContext } from '../contexts/SettingsContext';
|
8
9
|
import { ThemeValueContext } from '../contexts/theme/ThemeValueContext';
|
9
|
-
export const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = DEFAULT_THEME, device = {}, analytics = {}, children, }) => {
|
10
|
+
export const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = DEFAULT_THEME, device = {}, analytics = {}, settings = {}, 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" }),
|
13
14
|
React.createElement(RouterContext.Provider, { value: router, key: "router-context" }),
|
14
15
|
React.createElement(MobileContext.Provider, { value: Boolean(isMobile), key: "is-mobile-context" }),
|
15
16
|
React.createElement(DeviceContext.Provider, { value: device, key: "device-context" }),
|
17
|
+
React.createElement(SettingsContext.Provider, { value: settings, key: "settings-context" }),
|
16
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);
|