@gravity-ui/page-constructor 4.43.0 → 4.43.2-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 (46) hide show
  1. package/build/cjs/blocks/Header/schema.d.ts +33 -3
  2. package/build/cjs/blocks/HeaderSlider/schema.d.ts +11 -1
  3. package/build/cjs/blocks/Media/schema.d.ts +22 -2
  4. package/build/cjs/blocks/PromoFeaturesBlock/schema.d.ts +11 -1
  5. package/build/cjs/blocks/Tabs/schema.d.ts +11 -1
  6. package/build/cjs/components/BlockBase/BlockBase.css +37 -0
  7. package/build/cjs/components/BlockBase/BlockBase.js +3 -2
  8. package/build/cjs/components/Media/Iframe/Iframe.css +0 -4
  9. package/build/cjs/components/Media/Iframe/Iframe.js +64 -4
  10. package/build/cjs/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.js +3 -4
  11. package/build/cjs/grid/Col/Col.d.ts +1 -1
  12. package/build/cjs/grid/types.d.ts +1 -0
  13. package/build/cjs/models/constructor-items/blocks.d.ts +5 -1
  14. package/build/cjs/models/constructor-items/common.d.ts +4 -2
  15. package/build/cjs/models/constructor.d.ts +1 -6
  16. package/build/cjs/schema/constants.d.ts +11 -1
  17. package/build/cjs/schema/validators/common.d.ts +11 -1
  18. package/build/cjs/schema/validators/common.js +5 -1
  19. package/build/cjs/sub-blocks/LayoutItem/schema.d.ts +11 -1
  20. package/build/cjs/sub-blocks/MediaCard/schema.d.ts +11 -1
  21. package/build/esm/blocks/Header/schema.d.ts +33 -3
  22. package/build/esm/blocks/HeaderSlider/schema.d.ts +11 -1
  23. package/build/esm/blocks/Media/schema.d.ts +22 -2
  24. package/build/esm/blocks/PromoFeaturesBlock/schema.d.ts +11 -1
  25. package/build/esm/blocks/Tabs/schema.d.ts +11 -1
  26. package/build/esm/components/BlockBase/BlockBase.css +37 -0
  27. package/build/esm/components/BlockBase/BlockBase.js +3 -2
  28. package/build/esm/components/Media/Iframe/Iframe.css +0 -4
  29. package/build/esm/components/Media/Iframe/Iframe.js +64 -4
  30. package/build/esm/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.js +3 -4
  31. package/build/esm/grid/Col/Col.d.ts +1 -1
  32. package/build/esm/grid/types.d.ts +1 -0
  33. package/build/esm/models/constructor-items/blocks.d.ts +5 -1
  34. package/build/esm/models/constructor-items/common.d.ts +4 -2
  35. package/build/esm/models/constructor.d.ts +1 -6
  36. package/build/esm/schema/constants.d.ts +11 -1
  37. package/build/esm/schema/validators/common.d.ts +11 -1
  38. package/build/esm/schema/validators/common.js +5 -1
  39. package/build/esm/sub-blocks/LayoutItem/schema.d.ts +11 -1
  40. package/build/esm/sub-blocks/MediaCard/schema.d.ts +11 -1
  41. package/package.json +1 -1
  42. package/server/grid/types.d.ts +1 -0
  43. package/server/models/constructor-items/blocks.d.ts +5 -1
  44. package/server/models/constructor-items/common.d.ts +4 -2
  45. package/server/models/constructor.d.ts +1 -6
  46. package/widget/index.js +1 -1
@@ -260,11 +260,21 @@ export declare const Media: {
260
260
  type: string;
261
261
  };
262
262
  height: {
263
- type: string;
263
+ oneOf: ({
264
+ type: string;
265
+ enum?: undefined;
266
+ } | {
267
+ type: string;
268
+ enum: string[];
269
+ })[];
264
270
  };
265
271
  width: {
266
272
  type: string;
267
273
  };
274
+ justifyContent: {
275
+ type: string;
276
+ enum: string[];
277
+ };
268
278
  };
269
279
  };
270
280
  margins: {
@@ -931,11 +941,21 @@ export declare const MediaBlock: {
931
941
  type: string;
932
942
  };
933
943
  height: {
934
- type: string;
944
+ oneOf: ({
945
+ type: string;
946
+ enum?: undefined;
947
+ } | {
948
+ type: string;
949
+ enum: string[];
950
+ })[];
935
951
  };
936
952
  width: {
937
953
  type: string;
938
954
  };
955
+ justifyContent: {
956
+ type: string;
957
+ enum: string[];
958
+ };
939
959
  };
940
960
  };
941
961
  margins: {
@@ -276,11 +276,21 @@ export declare const PromoFeaturesItem: {
276
276
  type: string;
277
277
  };
278
278
  height: {
279
- type: string;
279
+ oneOf: ({
280
+ type: string;
281
+ enum?: undefined;
282
+ } | {
283
+ type: string;
284
+ enum: string[];
285
+ })[];
280
286
  };
281
287
  width: {
282
288
  type: string;
283
289
  };
290
+ justifyContent: {
291
+ type: string;
292
+ enum: string[];
293
+ };
284
294
  };
285
295
  };
286
296
  margins: {
@@ -271,11 +271,21 @@ export declare const tabsItem: {
271
271
  type: string;
272
272
  };
273
273
  height: {
274
- type: string;
274
+ oneOf: ({
275
+ type: string;
276
+ enum?: undefined;
277
+ } | {
278
+ type: string;
279
+ enum: string[];
280
+ })[];
275
281
  };
276
282
  width: {
277
283
  type: string;
278
284
  };
285
+ justifyContent: {
286
+ type: string;
287
+ enum: string[];
288
+ };
279
289
  };
280
290
  };
281
291
  margins: {
@@ -11,6 +11,43 @@ unpredictable css rules order in build */
11
11
  margin-top: var(--pc-first-block-indent, 96px);
12
12
  }
13
13
 
14
+ .pc-block-base.pc-block-base.pc-block-base.pc-block-base_indentTop_0 {
15
+ margin-top: 0;
16
+ }
17
+ .pc-block-base.pc-block-base.pc-block-base.pc-block-base_indentTop_xs {
18
+ margin-top: 16px;
19
+ }
20
+ .pc-block-base.pc-block-base.pc-block-base.pc-block-base_indentTop_s {
21
+ margin-top: 24px;
22
+ }
23
+ .pc-block-base.pc-block-base.pc-block-base.pc-block-base_indentTop_m {
24
+ margin-top: 32px;
25
+ }
26
+ .pc-block-base.pc-block-base.pc-block-base.pc-block-base_indentTop_l {
27
+ margin-top: 48px;
28
+ }
29
+ .pc-block-base.pc-block-base.pc-block-base.pc-block-base_indentTop_xl {
30
+ margin-top: 64px;
31
+ }
32
+ .pc-block-base.pc-block-base.pc-block-base.pc-block-base_indentBottom_0 {
33
+ padding-bottom: 0;
34
+ }
35
+ .pc-block-base.pc-block-base.pc-block-base.pc-block-base_indentBottom_xs {
36
+ padding-bottom: 16px;
37
+ }
38
+ .pc-block-base.pc-block-base.pc-block-base.pc-block-base_indentBottom_s {
39
+ padding-bottom: 24px;
40
+ }
41
+ .pc-block-base.pc-block-base.pc-block-base.pc-block-base_indentBottom_m {
42
+ padding-bottom: 32px;
43
+ }
44
+ .pc-block-base.pc-block-base.pc-block-base.pc-block-base_indentBottom_l {
45
+ padding-bottom: 48px;
46
+ }
47
+ .pc-block-base.pc-block-base.pc-block-base.pc-block-base_indentBottom_xl {
48
+ padding-bottom: 64px;
49
+ }
50
+
14
51
  @media only screen and (max-width: 577px) {
15
52
  .pc-block-base.pc-block-base {
16
53
  margin-top: 32px;
@@ -5,8 +5,9 @@ import Anchor from '../Anchor/Anchor';
5
5
  import './BlockBase.css';
6
6
  const b = block('block-base');
7
7
  const BlockBase = (props) => {
8
- const { anchor, visible, children, className, resetPaddings, qa } = props;
9
- return (React.createElement(Col, { className: b({ ['reset-paddings']: resetPaddings }, className), visible: visible, reset: true, qa: qa },
8
+ const { anchor, indent, visible, children, className, resetPaddings, qa } = props;
9
+ const { top, bottom } = indent || (resetPaddings ? { top: '0', bottom: '0' } : { top: 'l', bottom: 'l' });
10
+ return (React.createElement(Col, { className: b({ ['reset-paddings']: resetPaddings, indentTop: top, indentBottom: bottom }, className), visible: visible, reset: true, qa: qa },
10
11
  anchor && React.createElement(Anchor, { id: anchor.url, className: b('anchor') }),
11
12
  children));
12
13
  };
@@ -11,8 +11,4 @@ unpredictable css rules order in build */
11
11
  }
12
12
  .pc-media-component-iframe .pc-media-component-iframe__iframe {
13
13
  border-radius: 0;
14
- }
15
- .pc-media-component-iframe__item {
16
- width: 100%;
17
- height: 100%;
18
14
  }
@@ -1,12 +1,72 @@
1
- import React from 'react';
1
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
2
+ import { v4 as uuidv4 } from 'uuid';
2
3
  import { block } from '../../../utils';
3
4
  import i18n from './i18n';
4
5
  import './Iframe.css';
5
6
  const b = block('media-component-iframe');
6
7
  const Iframe = (props) => {
7
8
  const { iframe, margins = true } = props;
8
- const { height = 400, src, width, name, title } = iframe;
9
- return iframe ? (React.createElement("div", { className: b({ margins }), style: { height } },
10
- React.createElement("iframe", { className: b('item'), loading: "lazy", title: title || i18n('iframe-title'), frameBorder: 0, src: src, width: width, height: height, name: name }))) : null;
9
+ const { height = 400, src, width = '100%', name, title, justifyContent = 'center' } = iframe;
10
+ const formContainerRef = useRef(null);
11
+ const iframeRef = useRef();
12
+ const [iframeId] = useState(uuidv4());
13
+ const updateFormIframe = useCallback((container) => {
14
+ if (iframeRef.current) {
15
+ iframeRef.current.src = src;
16
+ }
17
+ else {
18
+ const iframeWidth = typeof width === 'number' ? `${width}px` : width;
19
+ let iframeHeight = typeof height === 'number' ? `${height}px` : height;
20
+ if (height === 'auto') {
21
+ iframeHeight = undefined;
22
+ }
23
+ iframeRef.current = document.createElement('iframe');
24
+ iframeRef.current.src = src;
25
+ iframeRef.current.id = iframeId;
26
+ iframeRef.current.name = name || iframeId;
27
+ iframeRef.current.setAttribute('loading', 'lazy');
28
+ iframeRef.current.setAttribute('title', title || i18n('iframe-title'));
29
+ iframeRef.current.frameBorder = '0';
30
+ iframeRef.current.scrolling = 'no';
31
+ iframeRef.current.width = iframeWidth;
32
+ iframeRef.current.style.width = iframeWidth;
33
+ if (iframeHeight) {
34
+ iframeRef.current.style.height = iframeHeight;
35
+ }
36
+ container.appendChild(iframeRef.current);
37
+ }
38
+ }, [src, width, iframeId, name, title, height]);
39
+ const handleMessage = useCallback(({ data }) => {
40
+ if (height !== 'auto' && typeof height === 'number' && iframeRef.current) {
41
+ iframeRef.current.height = `${height}px`;
42
+ return;
43
+ }
44
+ try {
45
+ const parsed = JSON.parse(data);
46
+ const iframeHeight = parsed['iframe-height'];
47
+ const { message, name: iframeName } = parsed;
48
+ if (iframeName !== name && iframeName !== iframeId) {
49
+ return;
50
+ }
51
+ if (iframeRef.current && iframeHeight && !message) {
52
+ iframeRef.current.height = `${iframeHeight}px`;
53
+ }
54
+ }
55
+ catch (error) {
56
+ return;
57
+ }
58
+ }, [height, iframeId, name]);
59
+ const addIframe = useCallback(() => {
60
+ const container = formContainerRef.current;
61
+ if (container) {
62
+ updateFormIframe(container);
63
+ window.addEventListener('message', handleMessage, { passive: true });
64
+ }
65
+ }, [updateFormIframe, handleMessage]);
66
+ useEffect(() => {
67
+ addIframe();
68
+ return () => window.removeEventListener('message', handleMessage);
69
+ }, [addIframe, handleMessage]);
70
+ return iframe ? (React.createElement("div", { className: b({ margins }), ref: formContainerRef, style: { height, textAlign: justifyContent } })) : null;
11
71
  };
12
72
  export default Iframe;
@@ -6,9 +6,8 @@ import { block } from '../../../../utils';
6
6
  import './ConstructorBlock.css';
7
7
  const b = block('constructor-block');
8
8
  export const ConstructorBlock = ({ index = 0, data, children, }) => {
9
- const { type, indent } = data;
10
- const blockBaseProps = useMemo(() => pick(data, ['anchor', 'visible', 'resetPaddings']), [data]);
11
- const { top, bottom } = indent || { top: 'l', bottom: 'l' };
9
+ const { type } = data;
10
+ const blockBaseProps = useMemo(() => pick(data, ['anchor', 'visible', 'resetPaddings', 'indent']), [data]);
12
11
  return (React.createElement(BlockDecoration, Object.assign({ type: type, index: index }, blockBaseProps),
13
- React.createElement(BlockBase, Object.assign({ className: b({ type, indentTop: top, indentBottom: bottom }) }, blockBaseProps), children)));
12
+ React.createElement(BlockBase, Object.assign({ className: b({ type }) }, blockBaseProps), children)));
14
13
  };
@@ -5,4 +5,4 @@ export interface GridColumnProps extends GridColumnClassParams, Refable<HTMLDivE
5
5
  style?: CSSProperties;
6
6
  children?: React.ReactNode;
7
7
  }
8
- export declare const Col: React.ForwardRefExoticComponent<Pick<WithChildren<GridColumnProps>, "style" | "children" | "sizes" | "className" | "hidden" | "role" | "qa" | "reset" | "visible" | "offsets" | "orders" | "alignSelf" | "justifyContent"> & React.RefAttributes<HTMLDivElement>>;
8
+ export declare const Col: React.ForwardRefExoticComponent<Pick<WithChildren<GridColumnProps>, "style" | "children" | "sizes" | "className" | "hidden" | "role" | "qa" | "reset" | "visible" | "justifyContent" | "offsets" | "orders" | "alignSelf"> & React.RefAttributes<HTMLDivElement>>;
@@ -48,3 +48,4 @@ export interface GridColumnClassParams {
48
48
  justifyContent?: GridJustifyContent;
49
49
  reset?: boolean;
50
50
  }
51
+ export type IndentValue = '0' | 'xs' | 's' | 'm' | 'l' | 'xl';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ButtonSize } from '@gravity-ui/uikit';
3
- import { GridColumnSize, GridColumnSizesType } from '../../grid/types';
3
+ import { GridColumnSize, GridColumnSizesType, IndentValue } from '../../grid/types';
4
4
  import { ThemeSupporting } from '../../utils';
5
5
  import { AnalyticsEventsBase } from '../common';
6
6
  import { AnchorProps, Animatable, BackgroundImageProps, ButtonProps, ContentSize, ContentTextSize, ContentTheme, FileLinkProps, HeaderBreadCrumbsProps, HeaderImageSize, HeaderOffset, HeaderWidth, ImageDeviceProps, ImageProps, Justify, LegendTableMarkerType, LinkProps, MapProps, MediaDirection, MediaProps, TextSize, TextTheme, ThemedImage, ThemedMediaProps, ThemedMediaVideoProps, TitleItemBaseProps, TitleItemProps, YandexFormProps } from './common';
@@ -36,6 +36,10 @@ export interface BlockBaseProps {
36
36
  visible?: GridColumnSize;
37
37
  /** @deprecated */
38
38
  resetPaddings?: boolean;
39
+ indent?: {
40
+ top?: IndentValue;
41
+ bottom?: IndentValue;
42
+ };
39
43
  qa?: string;
40
44
  }
41
45
  export interface LoadableProps {
@@ -257,12 +257,14 @@ export interface DataLensObjectProps {
257
257
  id: string;
258
258
  theme: 'dark' | 'light';
259
259
  }
260
+ export type JustifyValues = 'left' | 'right' | 'center';
260
261
  export interface IframeProps {
261
262
  src: string;
262
- width?: number;
263
- height?: number;
263
+ width?: number | string;
264
+ height?: number | string;
264
265
  title?: string;
265
266
  name?: string;
267
+ justifyContent?: JustifyValues;
266
268
  }
267
269
  export type DataLensProps = string | DataLensObjectProps;
268
270
  export interface AuthorItem {
@@ -6,12 +6,7 @@ export interface PageData {
6
6
  export interface Menu {
7
7
  title: string;
8
8
  }
9
- export type ConstructorBlock = (ConstructorItem | CustomBlock) & {
10
- indent?: {
11
- top?: string;
12
- bottom?: string;
13
- };
14
- };
9
+ export type ConstructorBlock = ConstructorItem | CustomBlock;
15
10
  export interface PageContent extends Animatable {
16
11
  blocks: ConstructorBlock[];
17
12
  menu?: Menu;
@@ -1530,11 +1530,21 @@ export declare const cardSchemas: {
1530
1530
  type: string;
1531
1531
  };
1532
1532
  height: {
1533
- type: string;
1533
+ oneOf: ({
1534
+ type: string;
1535
+ enum?: undefined;
1536
+ } | {
1537
+ type: string;
1538
+ enum: string[];
1539
+ })[];
1534
1540
  };
1535
1541
  width: {
1536
1542
  type: string;
1537
1543
  };
1544
+ justifyContent: {
1545
+ type: string;
1546
+ enum: string[];
1547
+ };
1538
1548
  };
1539
1549
  };
1540
1550
  margins: {
@@ -1388,11 +1388,21 @@ export declare const MediaProps: {
1388
1388
  type: string;
1389
1389
  };
1390
1390
  height: {
1391
- type: string;
1391
+ oneOf: ({
1392
+ type: string;
1393
+ enum?: undefined;
1394
+ } | {
1395
+ type: string;
1396
+ enum: string[];
1397
+ })[];
1392
1398
  };
1393
1399
  width: {
1394
1400
  type: string;
1395
1401
  };
1402
+ justifyContent: {
1403
+ type: string;
1404
+ enum: string[];
1405
+ };
1396
1406
  };
1397
1407
  };
1398
1408
  margins: {
@@ -522,11 +522,15 @@ const IframeProps = {
522
522
  type: 'string',
523
523
  },
524
524
  height: {
525
- type: 'number',
525
+ oneOf: [{ type: 'number' }, { type: 'string', enum: ['auto'] }],
526
526
  },
527
527
  width: {
528
528
  type: 'number',
529
529
  },
530
+ justifyContent: {
531
+ type: 'string',
532
+ enum: ['left', 'right', 'center'],
533
+ },
530
534
  },
531
535
  };
532
536
  export const MediaProps = {
@@ -261,11 +261,21 @@ export declare const LayoutItem: {
261
261
  type: string;
262
262
  };
263
263
  height: {
264
- type: string;
264
+ oneOf: ({
265
+ type: string;
266
+ enum?: undefined;
267
+ } | {
268
+ type: string;
269
+ enum: string[];
270
+ })[];
265
271
  };
266
272
  width: {
267
273
  type: string;
268
274
  };
275
+ justifyContent: {
276
+ type: string;
277
+ enum: string[];
278
+ };
269
279
  };
270
280
  };
271
281
  margins: {
@@ -266,11 +266,21 @@ export declare const MediaCardBlock: {
266
266
  type: string;
267
267
  };
268
268
  height: {
269
- type: string;
269
+ oneOf: ({
270
+ type: string;
271
+ enum?: undefined;
272
+ } | {
273
+ type: string;
274
+ enum: string[];
275
+ })[];
270
276
  };
271
277
  width: {
272
278
  type: string;
273
279
  };
280
+ justifyContent: {
281
+ type: string;
282
+ enum: string[];
283
+ };
274
284
  };
275
285
  };
276
286
  margins: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "4.43.0",
3
+ "version": "4.43.2-alpha.0",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -48,3 +48,4 @@ export interface GridColumnClassParams {
48
48
  justifyContent?: GridJustifyContent;
49
49
  reset?: boolean;
50
50
  }
51
+ export type IndentValue = '0' | 'xs' | 's' | 'm' | 'l' | 'xl';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ButtonSize } from '@gravity-ui/uikit';
3
- import { GridColumnSize, GridColumnSizesType } from '../../grid/types';
3
+ import { GridColumnSize, GridColumnSizesType, IndentValue } from '../../grid/types';
4
4
  import { ThemeSupporting } from '../../utils';
5
5
  import { AnalyticsEventsBase } from '../common';
6
6
  import { AnchorProps, Animatable, BackgroundImageProps, ButtonProps, ContentSize, ContentTextSize, ContentTheme, FileLinkProps, HeaderBreadCrumbsProps, HeaderImageSize, HeaderOffset, HeaderWidth, ImageDeviceProps, ImageProps, Justify, LegendTableMarkerType, LinkProps, MapProps, MediaDirection, MediaProps, TextSize, TextTheme, ThemedImage, ThemedMediaProps, ThemedMediaVideoProps, TitleItemBaseProps, TitleItemProps, YandexFormProps } from './common';
@@ -36,6 +36,10 @@ export interface BlockBaseProps {
36
36
  visible?: GridColumnSize;
37
37
  /** @deprecated */
38
38
  resetPaddings?: boolean;
39
+ indent?: {
40
+ top?: IndentValue;
41
+ bottom?: IndentValue;
42
+ };
39
43
  qa?: string;
40
44
  }
41
45
  export interface LoadableProps {
@@ -257,12 +257,14 @@ export interface DataLensObjectProps {
257
257
  id: string;
258
258
  theme: 'dark' | 'light';
259
259
  }
260
+ export type JustifyValues = 'left' | 'right' | 'center';
260
261
  export interface IframeProps {
261
262
  src: string;
262
- width?: number;
263
- height?: number;
263
+ width?: number | string;
264
+ height?: number | string;
264
265
  title?: string;
265
266
  name?: string;
267
+ justifyContent?: JustifyValues;
266
268
  }
267
269
  export type DataLensProps = string | DataLensObjectProps;
268
270
  export interface AuthorItem {
@@ -6,12 +6,7 @@ export interface PageData {
6
6
  export interface Menu {
7
7
  title: string;
8
8
  }
9
- export type ConstructorBlock = (ConstructorItem | CustomBlock) & {
10
- indent?: {
11
- top?: string;
12
- bottom?: string;
13
- };
14
- };
9
+ export type ConstructorBlock = ConstructorItem | CustomBlock;
15
10
  export interface PageContent extends Animatable {
16
11
  blocks: ConstructorBlock[];
17
12
  menu?: Menu;