@gravity-ui/page-constructor 5.26.1 → 5.27.0

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.
@@ -8,8 +8,8 @@ const sub_blocks_1 = require("../../sub-blocks");
8
8
  const utils_1 = require("../../utils");
9
9
  const b = (0, utils_1.block)('banner-block');
10
10
  const BannerBlock = (props) => {
11
- const { animated } = props, bannerProps = tslib_1.__rest(props, ["animated"]);
12
- return (react_1.default.createElement(AnimateBlock_1.default, { className: b(), animate: animated },
11
+ const { animated, className } = props, bannerProps = tslib_1.__rest(props, ["animated", "className"]);
12
+ return (react_1.default.createElement(AnimateBlock_1.default, { className: b(null, className), animate: animated },
13
13
  react_1.default.createElement(sub_blocks_1.BannerCard, Object.assign({}, bannerProps))));
14
14
  };
15
15
  exports.BannerBlock = BannerBlock;
@@ -9,6 +9,7 @@ const RootCn_1 = tslib_1.__importDefault(require("../../components/RootCn"));
9
9
  const constructor_items_1 = require("../../constructor-items");
10
10
  const animateContext_1 = require("../../context/animateContext");
11
11
  const innerContext_1 = require("../../context/innerContext");
12
+ const projectSettingsContext_1 = require("../../context/projectSettingsContext");
12
13
  const theme_1 = require("../../context/theme");
13
14
  const grid_1 = require("../../grid");
14
15
  const models_1 = require("../../models");
@@ -54,7 +55,8 @@ const Constructor = (props) => {
54
55
  };
55
56
  exports.Constructor = Constructor;
56
57
  const PageConstructor = (props) => {
57
- const { content: { animated = true } = {} } = props, rest = tslib_1.__rest(props, ["content"]);
58
+ const { isAnimationEnabled = true } = (0, react_1.useContext)(projectSettingsContext_1.ProjectSettingsContext);
59
+ const { content: { animated = isAnimationEnabled } = {} } = props, rest = tslib_1.__rest(props, ["content"]);
58
60
  return (react_1.default.createElement(animateContext_1.AnimateContext.Provider, { value: { animated } },
59
61
  react_1.default.createElement(exports.Constructor, Object.assign({ content: props.content }, rest))));
60
62
  };
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  export interface ProjectSettingsContextProps {
3
3
  disableCompress?: boolean;
4
+ isAnimationEnabled?: boolean;
4
5
  }
5
6
  export declare const ProjectSettingsContext: React.Context<ProjectSettingsContextProps>;
@@ -113,11 +113,12 @@ export interface BasicCardProps extends CardBaseProps, AnalyticsEventsBase, Card
113
113
  export interface BannerCardProps {
114
114
  title: string;
115
115
  subtitle?: string;
116
+ className?: string;
116
117
  image?: ThemeSupporting<string>;
117
118
  disableCompress?: boolean;
118
119
  color?: ThemeSupporting<string>;
119
120
  theme?: TextTheme;
120
- button: Pick<ButtonProps, 'text' | 'url' | 'target' | 'theme'>;
121
+ button?: Pick<ButtonProps, 'text' | 'url' | 'target' | 'theme'>;
121
122
  mediaView?: MediaView;
122
123
  }
123
124
  export interface MediaCardProps extends MediaProps, AnalyticsEventsBase, CardBaseProps {
@@ -8,7 +8,7 @@ const theme_1 = require("../../context/theme");
8
8
  const utils_1 = require("../../utils");
9
9
  const b = (0, utils_1.block)('banner-card');
10
10
  const BannerCard = (props) => {
11
- const { title, subtitle, button: { url, text, target, theme: buttonTheme = 'raised' }, color, theme: textTheme = 'light', image, disableCompress, mediaView = 'full', } = props;
11
+ const { title, subtitle, button: { url, text, target, theme: buttonTheme = 'raised' } = {}, color, theme: textTheme = 'light', image, disableCompress, mediaView = 'full', } = props;
12
12
  const theme = (0, theme_1.useTheme)();
13
13
  const contentStyle = {};
14
14
  if (color) {
@@ -21,8 +21,8 @@ const BannerCard = (props) => {
21
21
  react_1.default.createElement("h2", { className: b('title') },
22
22
  react_1.default.createElement(components_1.HTML, null, title)),
23
23
  subtitle && (react_1.default.createElement(components_1.YFMWrapper, { className: b('subtitle'), content: subtitle, modifiers: { constructor: true } }))),
24
- react_1.default.createElement(components_1.RouterLink, { href: url },
25
- react_1.default.createElement(components_1.Button, { className: b('button'), theme: buttonTheme, size: "xl", text: text, url: url, target: target }))),
24
+ url && (react_1.default.createElement(components_1.RouterLink, { href: url },
25
+ react_1.default.createElement(components_1.Button, { className: b('button'), theme: buttonTheme, size: "xl", text: text !== null && text !== void 0 ? text : '', url: url, target: target })))),
26
26
  react_1.default.createElement(components_1.BackgroundImage, { className: b('image'), src: (0, utils_1.getThemedValue)(image, theme), disableCompress: disableCompress }))));
27
27
  };
28
28
  exports.BannerCard = BannerCard;
@@ -6,8 +6,8 @@ import { block } from '../../utils';
6
6
  import './Banner.css';
7
7
  const b = block('banner-block');
8
8
  export const BannerBlock = (props) => {
9
- const { animated } = props, bannerProps = __rest(props, ["animated"]);
10
- return (React.createElement(AnimateBlock, { className: b(), animate: animated },
9
+ const { animated, className } = props, bannerProps = __rest(props, ["animated", "className"]);
10
+ return (React.createElement(AnimateBlock, { className: b(null, className), animate: animated },
11
11
  React.createElement(BannerCard, Object.assign({}, bannerProps))));
12
12
  };
13
13
  export default BannerBlock;
@@ -1,11 +1,12 @@
1
1
  import { __rest } from "tslib";
2
- import React, { useMemo } from 'react';
2
+ import React, { useContext, useMemo } from 'react';
3
3
  import '@diplodoc/transform/dist/js/yfm';
4
4
  import BackgroundMedia from '../../components/BackgroundMedia/BackgroundMedia';
5
5
  import RootCn from '../../components/RootCn';
6
6
  import { blockMap, navItemMap, subBlockMap } from '../../constructor-items';
7
7
  import { AnimateContext } from '../../context/animateContext';
8
8
  import { InnerContext } from '../../context/innerContext';
9
+ import { ProjectSettingsContext } from '../../context/projectSettingsContext';
9
10
  import { useTheme } from '../../context/theme';
10
11
  import { Grid } from '../../grid';
11
12
  import { BlockType, BlockTypes, HeaderBlockTypes, NavigationItemTypes, SubBlockTypes, } from '../../models';
@@ -51,7 +52,8 @@ export const Constructor = (props) => {
51
52
  React.createElement(ConstructorBlocks, { items: restBlocks })))))))));
52
53
  };
53
54
  export const PageConstructor = (props) => {
54
- const { content: { animated = true } = {} } = props, rest = __rest(props, ["content"]);
55
+ const { isAnimationEnabled = true } = useContext(ProjectSettingsContext);
56
+ const { content: { animated = isAnimationEnabled } = {} } = props, rest = __rest(props, ["content"]);
55
57
  return (React.createElement(AnimateContext.Provider, { value: { animated } },
56
58
  React.createElement(Constructor, Object.assign({ content: props.content }, rest))));
57
59
  };
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  export interface ProjectSettingsContextProps {
3
3
  disableCompress?: boolean;
4
+ isAnimationEnabled?: boolean;
4
5
  }
5
6
  export declare const ProjectSettingsContext: React.Context<ProjectSettingsContextProps>;
@@ -113,11 +113,12 @@ export interface BasicCardProps extends CardBaseProps, AnalyticsEventsBase, Card
113
113
  export interface BannerCardProps {
114
114
  title: string;
115
115
  subtitle?: string;
116
+ className?: string;
116
117
  image?: ThemeSupporting<string>;
117
118
  disableCompress?: boolean;
118
119
  color?: ThemeSupporting<string>;
119
120
  theme?: TextTheme;
120
- button: Pick<ButtonProps, 'text' | 'url' | 'target' | 'theme'>;
121
+ button?: Pick<ButtonProps, 'text' | 'url' | 'target' | 'theme'>;
121
122
  mediaView?: MediaView;
122
123
  }
123
124
  export interface MediaCardProps extends MediaProps, AnalyticsEventsBase, CardBaseProps {
@@ -5,7 +5,7 @@ import { block, getThemedValue } from '../../utils';
5
5
  import './BannerCard.css';
6
6
  const b = block('banner-card');
7
7
  export const BannerCard = (props) => {
8
- const { title, subtitle, button: { url, text, target, theme: buttonTheme = 'raised' }, color, theme: textTheme = 'light', image, disableCompress, mediaView = 'full', } = props;
8
+ const { title, subtitle, button: { url, text, target, theme: buttonTheme = 'raised' } = {}, color, theme: textTheme = 'light', image, disableCompress, mediaView = 'full', } = props;
9
9
  const theme = useTheme();
10
10
  const contentStyle = {};
11
11
  if (color) {
@@ -18,8 +18,8 @@ export const BannerCard = (props) => {
18
18
  React.createElement("h2", { className: b('title') },
19
19
  React.createElement(HTML, null, title)),
20
20
  subtitle && (React.createElement(YFMWrapper, { className: b('subtitle'), content: subtitle, modifiers: { constructor: true } }))),
21
- React.createElement(RouterLink, { href: url },
22
- React.createElement(Button, { className: b('button'), theme: buttonTheme, size: "xl", text: text, url: url, target: target }))),
21
+ url && (React.createElement(RouterLink, { href: url },
22
+ React.createElement(Button, { className: b('button'), theme: buttonTheme, size: "xl", text: text !== null && text !== void 0 ? text : '', url: url, target: target })))),
23
23
  React.createElement(BackgroundImage, { className: b('image'), src: getThemedValue(image, theme), disableCompress: disableCompress }))));
24
24
  };
25
25
  export default BannerCard;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "5.26.1",
3
+ "version": "5.27.0",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -202,6 +202,8 @@
202
202
  "ts-jest": "^29.0.3",
203
203
  "tslib": "^2.4.0",
204
204
  "typescript": "^4.9.4",
205
+ "vite-plugin-commonjs": "^0.10.1",
206
+ "vite-plugin-svgr": "^4.2.0",
205
207
  "webpack": "^5.88.2",
206
208
  "webpack-cli": "^5.1.4",
207
209
  "webpack-shell-plugin-next": "^2.3.1"
@@ -113,11 +113,12 @@ export interface BasicCardProps extends CardBaseProps, AnalyticsEventsBase, Card
113
113
  export interface BannerCardProps {
114
114
  title: string;
115
115
  subtitle?: string;
116
+ className?: string;
116
117
  image?: ThemeSupporting<string>;
117
118
  disableCompress?: boolean;
118
119
  color?: ThemeSupporting<string>;
119
120
  theme?: TextTheme;
120
- button: Pick<ButtonProps, 'text' | 'url' | 'target' | 'theme'>;
121
+ button?: Pick<ButtonProps, 'text' | 'url' | 'target' | 'theme'>;
121
122
  mediaView?: MediaView;
122
123
  }
123
124
  export interface MediaCardProps extends MediaProps, AnalyticsEventsBase, CardBaseProps {