@gravity-ui/page-constructor 1.2.3 → 1.2.5-alpha.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/build/cjs/blocks/Companies/Companies.js +2 -6
  3. package/build/cjs/blocks/ContentLayout/schema.js +2 -1
  4. package/build/cjs/blocks/Header/Header.css +13 -11
  5. package/build/cjs/blocks/Header/Header.js +15 -15
  6. package/build/cjs/blocks/Header/schema.d.ts +332 -230
  7. package/build/cjs/blocks/Header/schema.js +6 -20
  8. package/build/cjs/blocks/HeaderSlider/schema.d.ts +96 -115
  9. package/build/cjs/blocks/Tabs/Tabs.js +3 -2
  10. package/build/cjs/blocks/Tabs/schema.js +2 -1
  11. package/build/cjs/components/BackgroundImage/BackgroundImage.js +2 -2
  12. package/build/cjs/components/BackgroundMedia/BackgroundMedia.css +2 -0
  13. package/build/cjs/components/BackgroundMedia/BackgroundMedia.js +2 -2
  14. package/build/cjs/components/FullscreenImage/FullscreenImage.d.ts +2 -2
  15. package/build/cjs/components/Image/Image.d.ts +3 -5
  16. package/build/cjs/components/Image/Image.js +16 -6
  17. package/build/cjs/components/Image/schema.d.ts +56 -0
  18. package/build/cjs/components/Image/schema.js +54 -0
  19. package/build/cjs/components/Link/Link.js +1 -1
  20. package/build/cjs/components/Media/Image/Image.js +3 -3
  21. package/build/cjs/components/Media/Image/utils.d.ts +2 -2
  22. package/build/cjs/models/constructor-items/blocks.d.ts +4 -8
  23. package/build/cjs/models/constructor-items/common.d.ts +11 -7
  24. package/build/cjs/models/guards.d.ts +2 -3
  25. package/build/cjs/models/guards.js +1 -5
  26. package/build/cjs/schema/validators/common.d.ts +0 -31
  27. package/build/cjs/schema/validators/common.js +5 -32
  28. package/build/cjs/sub-blocks/BackgroundCard/schema.js +2 -1
  29. package/build/cjs/sub-blocks/BasicCard/BasicCard.js +1 -1
  30. package/build/cjs/sub-blocks/BasicCard/schema.js +2 -1
  31. package/build/cjs/sub-blocks/Content/Content.css +2 -1
  32. package/build/cjs/sub-blocks/Partner/Partner.js +1 -1
  33. package/build/cjs/sub-blocks/Partner/schema.js +2 -1
  34. package/build/cjs/sub-blocks/Quote/Quote.js +3 -2
  35. package/build/cjs/sub-blocks/Quote/schema.js +4 -3
  36. package/build/cjs/sub-blocks/TutorialCard/TutorialCard.js +2 -2
  37. package/build/cjs/sub-blocks/TutorialCard/schema.js +2 -1
  38. package/build/esm/blocks/Companies/Companies.js +2 -6
  39. package/build/esm/blocks/ContentLayout/schema.js +2 -1
  40. package/build/esm/blocks/Header/Header.css +13 -11
  41. package/build/esm/blocks/Header/Header.js +16 -16
  42. package/build/esm/blocks/Header/schema.d.ts +332 -230
  43. package/build/esm/blocks/Header/schema.js +5 -19
  44. package/build/esm/blocks/HeaderSlider/schema.d.ts +96 -115
  45. package/build/esm/blocks/Tabs/Tabs.js +3 -2
  46. package/build/esm/blocks/Tabs/schema.js +2 -1
  47. package/build/esm/components/BackgroundImage/BackgroundImage.js +2 -2
  48. package/build/esm/components/BackgroundMedia/BackgroundMedia.css +2 -0
  49. package/build/esm/components/BackgroundMedia/BackgroundMedia.js +2 -2
  50. package/build/esm/components/FullscreenImage/FullscreenImage.d.ts +2 -2
  51. package/build/esm/components/Image/Image.d.ts +3 -5
  52. package/build/esm/components/Image/Image.js +17 -7
  53. package/build/esm/components/Image/schema.d.ts +56 -0
  54. package/build/esm/components/Image/schema.js +51 -0
  55. package/build/esm/components/Link/Link.js +1 -1
  56. package/build/esm/components/Media/Image/Image.js +3 -3
  57. package/build/esm/components/Media/Image/utils.d.ts +2 -2
  58. package/build/esm/models/constructor-items/blocks.d.ts +4 -8
  59. package/build/esm/models/constructor-items/common.d.ts +11 -7
  60. package/build/esm/models/guards.d.ts +2 -3
  61. package/build/esm/models/guards.js +0 -3
  62. package/build/esm/schema/validators/common.d.ts +0 -31
  63. package/build/esm/schema/validators/common.js +1 -28
  64. package/build/esm/sub-blocks/BackgroundCard/schema.js +2 -1
  65. package/build/esm/sub-blocks/BasicCard/BasicCard.js +1 -1
  66. package/build/esm/sub-blocks/BasicCard/schema.js +2 -1
  67. package/build/esm/sub-blocks/Content/Content.css +2 -1
  68. package/build/esm/sub-blocks/Partner/Partner.js +1 -1
  69. package/build/esm/sub-blocks/Partner/schema.js +2 -1
  70. package/build/esm/sub-blocks/Quote/Quote.js +3 -2
  71. package/build/esm/sub-blocks/Quote/schema.js +2 -1
  72. package/build/esm/sub-blocks/TutorialCard/TutorialCard.js +2 -2
  73. package/build/esm/sub-blocks/TutorialCard/schema.js +2 -1
  74. package/package.json +4 -1
  75. package/server/models/constructor-items/blocks.d.ts +4 -8
  76. package/server/models/constructor-items/common.d.ts +11 -7
  77. package/server/models/guards.d.ts +2 -3
  78. package/server/models/guards.js +1 -5
@@ -81,17 +81,21 @@ interface LoopProps {
81
81
  start: number;
82
82
  end?: number;
83
83
  }
84
- export interface ImageObjectProps {
85
- src: string;
84
+ export interface ImageInfoProps {
86
85
  alt?: string;
87
86
  disableCompress?: boolean;
88
87
  }
89
- export declare type ImageProps = string | ImageObjectProps;
88
+ export interface ImageObjectProps extends ImageInfoProps {
89
+ src: string;
90
+ }
91
+ export interface ImageDeviceProps extends ImageInfoProps {
92
+ desktop: string;
93
+ mobile: string;
94
+ tablet?: string;
95
+ }
96
+ export declare type ImageProps = string | ImageObjectProps | ImageDeviceProps;
90
97
  export declare type ThemedImage = ThemeSupporting<ImageProps>;
91
- export interface BackgroundImageProps extends React.HTMLProps<HTMLDivElement> {
92
- src?: string;
93
- alt?: string;
94
- disableCompress?: boolean;
98
+ export interface BackgroundImageProps extends React.HTMLProps<HTMLDivElement>, Partial<ImageDeviceProps>, Partial<ImageObjectProps> {
95
99
  style?: CSSProperties;
96
100
  imageClassName?: string;
97
101
  hide?: boolean;
@@ -1,5 +1,4 @@
1
- import { Block, ConstructorItem, HeaderBlockBackground } from './';
2
- import { MediaProps, MetrikaGoal, NewMetrikaGoal } from './index';
1
+ import { Block, ConstructorItem } from './';
2
+ import { MetrikaGoal, NewMetrikaGoal } from './index';
3
3
  export declare function isBlock(block: ConstructorItem): block is Block;
4
4
  export declare function isNewMetrikaFormat(metrika: MetrikaGoal): metrika is NewMetrikaGoal[];
5
- export declare function headerHasMediaBackground(background: HeaderBlockBackground): background is MediaProps;
@@ -5,6 +5,3 @@ export function isBlock(block) {
5
5
  export function isNewMetrikaFormat(metrika) {
6
6
  return Boolean(Array.isArray(metrika) && metrika.length && typeof metrika[0] === 'object');
7
7
  }
8
- export function headerHasMediaBackground(background) {
9
- return 'image' in background || 'video' in background || 'youtube' in background;
10
- }
@@ -19,7 +19,6 @@ export declare const sizeNumber: {
19
19
  minimum: number;
20
20
  };
21
21
  export declare const contentThemes: string[];
22
- export declare const urlPattern = "^((http[s]?|ftp):\\/)?\\/?([^:\\/\\s]+)((\\/\\w+)*\\/)([\\w\\-\\.]+[^#?\\s]+)(.*)?(#[\\w\\-]+)?$";
23
22
  export declare const BaseProps: {
24
23
  type: {};
25
24
  when: {};
@@ -159,36 +158,6 @@ export declare const JustifyProps: {
159
158
  type: string;
160
159
  enum: string[];
161
160
  };
162
- export declare const ImageObjectProps: {
163
- type: string;
164
- additionalProperties: boolean;
165
- required: string[];
166
- properties: {
167
- src: {
168
- type: string;
169
- pattern: string;
170
- };
171
- alt: {
172
- type: string;
173
- };
174
- disableCompress: {
175
- type: string;
176
- };
177
- };
178
- };
179
- export declare const ImageProps: {
180
- oneOf: ({
181
- type: string;
182
- properties: {
183
- when: {
184
- type: string;
185
- };
186
- };
187
- } | {
188
- type: string;
189
- pattern: string;
190
- })[];
191
- };
192
161
  export declare const DataLensObjectProps: {
193
162
  type: string;
194
163
  additionalProperties: boolean;
@@ -1,6 +1,6 @@
1
- import { filteredItem } from './utils';
2
1
  import { pixelEvents } from './pixel';
3
2
  import { Theme } from '../../models';
3
+ import { ImageProps, urlPattern } from '../../components/Image/schema';
4
4
  export const mediaDirection = ['media-content', 'content-media'];
5
5
  export const textSize = ['s', 'm', 'l'];
6
6
  export const containerSizesArray = ['sm', 'md', 'lg', 'xl', 'all'];
@@ -15,7 +15,6 @@ export const fileLinkTypes = ['vertical', 'horizontal'];
15
15
  export const dividerEnum = { enum: [0, 'xxs', 'xs', 's', 'm', 'l', 'xl', 'xxl', 'xxxl'] };
16
16
  export const sizeNumber = { type: 'number', maximum: 12, minimum: 1 };
17
17
  export const contentThemes = ['default', 'dark', 'light'];
18
- export const urlPattern = '^((http[s]?|ftp):\\/)?\\/?([^:\\/\\s]+)((\\/\\w+)*\\/)([\\w\\-\\.]+[^#?\\s]+)(.*)?(#[\\w\\-]+)?$';
19
18
  export const BaseProps = {
20
19
  type: {},
21
20
  when: {},
@@ -127,32 +126,6 @@ export const JustifyProps = {
127
126
  type: 'string',
128
127
  enum: ['start', 'center', 'end'],
129
128
  };
130
- export const ImageObjectProps = {
131
- type: 'object',
132
- additionalProperties: false,
133
- required: ['src'],
134
- properties: {
135
- src: {
136
- type: 'string',
137
- pattern: urlPattern,
138
- },
139
- alt: {
140
- type: 'string',
141
- },
142
- disableCompress: {
143
- type: 'boolean',
144
- },
145
- },
146
- };
147
- export const ImageProps = {
148
- oneOf: [
149
- {
150
- type: 'string',
151
- pattern: urlPattern,
152
- },
153
- filteredItem(Object.assign({}, ImageObjectProps)),
154
- ],
155
- };
156
129
  export const DataLensObjectProps = {
157
130
  type: 'object',
158
131
  additionalProperties: false,
@@ -1,6 +1,7 @@
1
- import { BaseProps, ImageObjectProps, withTheme } from '../../schema/validators/common';
1
+ import { BaseProps, withTheme } from '../../schema/validators/common';
2
2
  import { CardBase } from '../../components/CardBase/schema';
3
3
  import { ContentBase } from '../Content/schema';
4
+ import { ImageObjectProps } from '../../components/Image/schema';
4
5
  import _ from 'lodash';
5
6
  const BackgroundCardContentProps = _.omit(ContentBase, ['size']);
6
7
  export const BackgroundCard = {
@@ -11,7 +11,7 @@ const BasicCard = (props) => {
11
11
  const iconProps = icon && getMediaImage(icon);
12
12
  return (React.createElement(CardBase, { className: b(), url: url, border: border },
13
13
  React.createElement(CardBase.Content, null,
14
- iconProps && (React.createElement(Image, { src: iconProps.src, alt: iconProps.alt, className: b('icon'), disableCompress: iconProps.disableCompress })),
14
+ iconProps && React.createElement(Image, Object.assign({}, iconProps, { className: b('icon') })),
15
15
  React.createElement(Content, { title: title, text: text, additionalInfo: additionalInfo, links: links, buttons: buttons, colSizes: { all: 12, md: 12 }, size: "s" }))));
16
16
  };
17
17
  export default BasicCard;
@@ -1,7 +1,8 @@
1
1
  import _ from 'lodash';
2
- import { BaseProps, ImageProps } from '../../schema/validators/common';
2
+ import { BaseProps } from '../../schema/validators/common';
3
3
  import { CardBase } from '../../components/CardBase/schema';
4
4
  import { ContentBase } from '../Content/schema';
5
+ import { ImageProps } from '../../components/Image/schema';
5
6
  const BasicCardContentProps = _.omit(ContentBase, ['size', 'theme']);
6
7
  export const BasicCard = {
7
8
  'basic-card': {
@@ -22,10 +22,11 @@ unpredictable css rules order in build */
22
22
  color: var(--yc-color-text-primary);
23
23
  }
24
24
 
25
- .pc-content__button {
25
+ .pc-content__button.pc-content__button {
26
26
  margin-top: 0;
27
27
  margin-right: 12px;
28
28
  }
29
+
29
30
  .pc-content__links {
30
31
  display: flex;
31
32
  flex-direction: column;
@@ -7,7 +7,7 @@ const Partner = ({ text, logo, url, border }) => {
7
7
  const logoData = typeof logo === 'string' ? { src: logo } : logo;
8
8
  return (React.createElement(CardBase, { url: url, target: "_blank", className: b(), border: border },
9
9
  React.createElement(CardBase.Content, null,
10
- React.createElement(Image, { className: b('logo'), src: logoData.src, alt: logoData.alt }),
10
+ React.createElement(Image, Object.assign({ className: b('logo') }, logoData)),
11
11
  React.createElement(HTML, null, text))));
12
12
  };
13
13
  export default Partner;
@@ -1,4 +1,5 @@
1
- import { BaseProps, ImageProps } from '../../schema/validators/common';
1
+ import { BaseProps } from '../../schema/validators/common';
2
+ import { ImageProps } from '../../components/Image/schema';
2
3
  export const PartnerBlock = {
3
4
  partner: {
4
5
  additionalProperties: false,
@@ -4,13 +4,14 @@ import { block, getThemedValue } from '../../utils';
4
4
  import { AuthorType } from '../../models';
5
5
  import { Author, Image, HTML } from '../../components';
6
6
  import { ThemeValueContext } from '../../context/theme/ThemeValueContext';
7
+ import { getMediaImage } from '../../components/Media/Image/utils';
7
8
  import './Quote.css';
8
9
  const b = block('quote');
9
10
  const Quote = (props) => {
10
11
  const { theme: textTheme = 'light', color, image, border = 'shadow', text, logo, author, url, buttonText, } = props;
11
12
  const { themeValue: theme } = useContext(ThemeValueContext);
12
13
  const imageThemed = getThemedValue(image, theme);
13
- const imageData = typeof imageThemed === 'string' ? { src: imageThemed } : imageThemed;
14
+ const imageData = getMediaImage(imageThemed);
14
15
  const renderFooter = Boolean(author || url) && (React.createElement("div", { className: b('author-wrapper') },
15
16
  author && (React.createElement(Author, { className: b('author', { theme: textTheme }), author: author, type: AuthorType.Line })),
16
17
  url && buttonText && (React.createElement(Button, { view: "outlined", size: "xl", href: url, className: b('link-button', { theme: textTheme }) }, buttonText))));
@@ -23,6 +24,6 @@ const Quote = (props) => {
23
24
  React.createElement(HTML, null, text)))),
24
25
  renderFooter),
25
26
  React.createElement("div", { className: b('image-wrapper') },
26
- React.createElement(Image, { src: imageData.src, alt: imageData.alt, className: b('image') }))));
27
+ React.createElement(Image, Object.assign({}, imageData, { className: b('image') })))));
27
28
  };
28
29
  export default Quote;
@@ -1,4 +1,5 @@
1
- import { authorItem, BaseProps, ImageProps, ThemeProps, withTheme, urlPattern, } from '../../schema/validators/common';
1
+ import { authorItem, BaseProps, ThemeProps, withTheme } from '../../schema/validators/common';
2
+ import { ImageProps, urlPattern } from '../../components/Image/schema';
2
3
  export const Quote = {
3
4
  quote: {
4
5
  additionalProperties: false,
@@ -6,8 +6,8 @@ import { getMediaImage } from '../../components/Media/Image/utils';
6
6
  import './TutorialCard.css';
7
7
  const b = block('tutorial-card');
8
8
  function iconElement(icon, title) {
9
- const { src, alt = title, disableCompress } = getMediaImage(icon !== null && icon !== void 0 ? icon : {});
10
- return React.createElement(Image, { src: src, alt: alt, className: b('icon'), disableCompress: disableCompress });
9
+ const image = getMediaImage(icon !== null && icon !== void 0 ? icon : {});
10
+ return React.createElement(Image, Object.assign({}, image, { alt: title, className: b('icon') }));
11
11
  }
12
12
  const TutorialCard = (props) => {
13
13
  const { url, title, text, border, icon } = props;
@@ -1,4 +1,5 @@
1
- import { BaseProps, ImageProps } from '../../schema/validators/common';
1
+ import { BaseProps } from '../../schema/validators/common';
2
+ import { ImageProps } from '../../components/Image/schema';
2
3
  export const TutorialCard = {
3
4
  'tutorial-card': {
4
5
  additionalProperties: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "1.2.3",
3
+ "version": "1.2.5-alpha.0",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -121,5 +121,8 @@
121
121
  "*.{json,yaml,yml,md}": [
122
122
  "prettier --write"
123
123
  ]
124
+ },
125
+ "publishConfig": {
126
+ "tag": "alpha"
124
127
  }
125
128
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { BackgroundImageProps, ButtonProps, ContentSize, ContentTextSize, ContentTheme, FileLinkProps, HeaderBreadCrumbsProps, HeaderImageSize, HeaderOffset, HeaderWidth, Justify, LinkProps, LinkTheme, MediaDirection, MediaProps, PreviewItemProps, PreviewRatioMediaContent, TextSize, TextTheme, ThemedImage, ThemedMediaProps, ThemedMediaVideoProps, TitleProps, LegendTableMarkerType, AnchorProps, TitleBaseProps, Animatable, BlockHeaderProps } from './common';
2
+ import { BackgroundImageProps, ButtonProps, ContentSize, ContentTextSize, ContentTheme, FileLinkProps, HeaderBreadCrumbsProps, HeaderImageSize, HeaderOffset, HeaderWidth, Justify, LinkProps, LinkTheme, MediaDirection, MediaProps, PreviewItemProps, PreviewRatioMediaContent, TextSize, TextTheme, ThemedImage, ThemedMediaProps, ThemedMediaVideoProps, TitleProps, LegendTableMarkerType, AnchorProps, TitleBaseProps, Animatable, BlockHeaderProps, ImageDeviceProps } from './common';
3
3
  import { ThemeSupporting } from '../../utils';
4
4
  import { GridColumnSize, GridColumnSizesType } from '../../grid/types';
5
5
  import { BannerCardProps, SubBlock } from './sub-blocks';
@@ -78,8 +78,9 @@ export interface HeaderSliderBlockProps extends Omit<SliderProps, 'title' | 'des
78
78
  items: HeaderBlockProps[];
79
79
  }
80
80
  interface HeaderBackgroundProps {
81
- color?: string;
81
+ /** @deprecated replaced by Media Props image */
82
82
  url?: string;
83
+ /** @deprecated replaced by Media Props image */
83
84
  disableCompress?: boolean;
84
85
  }
85
86
  export interface HeaderBlockBackground extends Partial<HeaderBackgroundProps>, Partial<MediaProps> {
@@ -151,12 +152,7 @@ export interface BannerBlockProps extends BannerCardProps, Animatable {
151
152
  }
152
153
  export interface CompaniesBlockProps extends Animatable {
153
154
  title: string;
154
- images: ThemeSupporting<{
155
- desktop: string;
156
- tablet: string;
157
- mobile: string;
158
- alt?: string;
159
- }>;
155
+ images: ThemeSupporting<ImageDeviceProps>;
160
156
  }
161
157
  export interface MediaContentProps {
162
158
  title: string;
@@ -81,17 +81,21 @@ interface LoopProps {
81
81
  start: number;
82
82
  end?: number;
83
83
  }
84
- export interface ImageObjectProps {
85
- src: string;
84
+ export interface ImageInfoProps {
86
85
  alt?: string;
87
86
  disableCompress?: boolean;
88
87
  }
89
- export declare type ImageProps = string | ImageObjectProps;
88
+ export interface ImageObjectProps extends ImageInfoProps {
89
+ src: string;
90
+ }
91
+ export interface ImageDeviceProps extends ImageInfoProps {
92
+ desktop: string;
93
+ mobile: string;
94
+ tablet?: string;
95
+ }
96
+ export declare type ImageProps = string | ImageObjectProps | ImageDeviceProps;
90
97
  export declare type ThemedImage = ThemeSupporting<ImageProps>;
91
- export interface BackgroundImageProps extends React.HTMLProps<HTMLDivElement> {
92
- src?: string;
93
- alt?: string;
94
- disableCompress?: boolean;
98
+ export interface BackgroundImageProps extends React.HTMLProps<HTMLDivElement>, Partial<ImageDeviceProps>, Partial<ImageObjectProps> {
95
99
  style?: CSSProperties;
96
100
  imageClassName?: string;
97
101
  hide?: boolean;
@@ -1,5 +1,4 @@
1
- import { Block, ConstructorItem, HeaderBlockBackground } from './';
2
- import { MediaProps, MetrikaGoal, NewMetrikaGoal } from './index';
1
+ import { Block, ConstructorItem } from './';
2
+ import { MetrikaGoal, NewMetrikaGoal } from './index';
3
3
  export declare function isBlock(block: ConstructorItem): block is Block;
4
4
  export declare function isNewMetrikaFormat(metrika: MetrikaGoal): metrika is NewMetrikaGoal[];
5
- export declare function headerHasMediaBackground(background: HeaderBlockBackground): background is MediaProps;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.headerHasMediaBackground = exports.isNewMetrikaFormat = exports.isBlock = void 0;
3
+ exports.isNewMetrikaFormat = exports.isBlock = void 0;
4
4
  const _1 = require("./");
5
5
  function isBlock(block) {
6
6
  return block.type in _1.BlockTypes;
@@ -10,7 +10,3 @@ function isNewMetrikaFormat(metrika) {
10
10
  return Boolean(Array.isArray(metrika) && metrika.length && typeof metrika[0] === 'object');
11
11
  }
12
12
  exports.isNewMetrikaFormat = isNewMetrikaFormat;
13
- function headerHasMediaBackground(background) {
14
- return 'image' in background || 'video' in background || 'youtube' in background;
15
- }
16
- exports.headerHasMediaBackground = headerHasMediaBackground;