@gravity-ui/page-constructor 4.45.0 → 4.47.0-beta.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.
- package/README.md +1 -1
- package/build/cjs/blocks/Header/schema.d.ts +33 -3
- package/build/cjs/blocks/HeaderSlider/schema.d.ts +11 -1
- package/build/cjs/blocks/Media/schema.d.ts +22 -2
- package/build/cjs/blocks/PromoFeaturesBlock/schema.d.ts +11 -1
- package/build/cjs/blocks/Tabs/schema.d.ts +11 -1
- package/build/cjs/components/Media/Iframe/Iframe.css +0 -4
- package/build/cjs/components/Media/Iframe/Iframe.js +64 -4
- package/build/cjs/grid/Col/Col.d.ts +1 -1
- package/build/cjs/models/constructor-items/common.d.ts +4 -2
- package/build/cjs/schema/constants.d.ts +11 -1
- package/build/cjs/schema/validators/common.d.ts +11 -1
- package/build/cjs/schema/validators/common.js +5 -1
- package/build/cjs/schema/validators/components.d.ts +1 -0
- package/build/cjs/schema/validators/components.js +1 -0
- package/build/cjs/schema/validators/sub-blocks.d.ts +1 -0
- package/build/cjs/schema/validators/sub-blocks.js +1 -0
- package/build/cjs/sub-blocks/LayoutItem/schema.d.ts +11 -1
- package/build/cjs/sub-blocks/MediaCard/schema.d.ts +11 -1
- package/build/esm/blocks/Header/schema.d.ts +33 -3
- package/build/esm/blocks/HeaderSlider/schema.d.ts +11 -1
- package/build/esm/blocks/Media/schema.d.ts +22 -2
- package/build/esm/blocks/PromoFeaturesBlock/schema.d.ts +11 -1
- package/build/esm/blocks/Tabs/schema.d.ts +11 -1
- package/build/esm/components/Media/Iframe/Iframe.css +0 -4
- package/build/esm/components/Media/Iframe/Iframe.js +64 -4
- package/build/esm/grid/Col/Col.d.ts +1 -1
- package/build/esm/models/constructor-items/common.d.ts +4 -2
- package/build/esm/schema/constants.d.ts +11 -1
- package/build/esm/schema/validators/common.d.ts +11 -1
- package/build/esm/schema/validators/common.js +5 -1
- package/build/esm/schema/validators/components.d.ts +1 -0
- package/build/esm/schema/validators/components.js +1 -0
- package/build/esm/schema/validators/sub-blocks.d.ts +1 -0
- package/build/esm/schema/validators/sub-blocks.js +1 -0
- package/build/esm/sub-blocks/LayoutItem/schema.d.ts +11 -1
- package/build/esm/sub-blocks/MediaCard/schema.d.ts +11 -1
- package/package.json +4 -1
- package/server/models/constructor-items/common.d.ts +4 -2
- package/widget/index.js +1 -1
|
@@ -1,12 +1,72 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useRef } 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
|
-
|
|
10
|
-
|
|
9
|
+
const { height = 400, src, width = '100%', name, title, justifyContent = 'center' } = iframe;
|
|
10
|
+
const formContainerRef = useRef(null);
|
|
11
|
+
const iframeRef = useRef();
|
|
12
|
+
const { current: iframeId } = useRef(uuidv4());
|
|
13
|
+
const updateIframe = 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
|
+
updateIframe(container);
|
|
63
|
+
window.addEventListener('message', handleMessage, { passive: true });
|
|
64
|
+
}
|
|
65
|
+
}, [updateIframe, 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;
|
|
@@ -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" | "
|
|
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>>;
|
|
@@ -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 {
|
|
@@ -1530,11 +1530,21 @@ export declare const cardSchemas: {
|
|
|
1530
1530
|
type: string;
|
|
1531
1531
|
};
|
|
1532
1532
|
height: {
|
|
1533
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "4.47.0-beta.0",
|
|
4
4
|
"description": "Gravity UI Page Constructor",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -205,5 +205,8 @@
|
|
|
205
205
|
"*.{json,yaml,yml,md}": [
|
|
206
206
|
"prettier --write"
|
|
207
207
|
]
|
|
208
|
+
},
|
|
209
|
+
"publishConfig": {
|
|
210
|
+
"tag": "beta"
|
|
208
211
|
}
|
|
209
212
|
}
|
|
@@ -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 {
|