@gravity-ui/page-constructor 5.24.0 → 5.26.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/build/cjs/blocks/Header/schema.d.ts +21 -3
- package/build/cjs/blocks/HeaderSlider/schema.d.ts +8 -1
- package/build/cjs/blocks/Media/schema.d.ts +10 -2
- package/build/cjs/blocks/PromoFeaturesBlock/schema.d.ts +5 -1
- package/build/cjs/blocks/Tabs/schema.d.ts +5 -1
- package/build/cjs/components/Media/Video/Video.js +2 -2
- package/build/cjs/components/ReactPlayer/ReactPlayer.css +7 -0
- package/build/cjs/components/ReactPlayer/ReactPlayer.d.ts +1 -0
- package/build/cjs/components/ReactPlayer/ReactPlayer.js +15 -4
- package/build/cjs/models/constructor-items/common.d.ts +2 -1
- package/build/cjs/schema/constants.d.ts +5 -1
- package/build/cjs/schema/validators/common.d.ts +11 -1
- package/build/cjs/schema/validators/common.js +5 -1
- package/build/cjs/sub-blocks/ImageCard/ImageCard.js +1 -1
- package/build/cjs/sub-blocks/LayoutItem/schema.d.ts +5 -1
- package/build/cjs/sub-blocks/MediaCard/schema.d.ts +5 -1
- package/build/esm/blocks/Header/schema.d.ts +21 -3
- package/build/esm/blocks/HeaderSlider/schema.d.ts +8 -1
- package/build/esm/blocks/Media/schema.d.ts +10 -2
- package/build/esm/blocks/PromoFeaturesBlock/schema.d.ts +5 -1
- package/build/esm/blocks/Tabs/schema.d.ts +5 -1
- package/build/esm/components/Media/Video/Video.js +2 -2
- package/build/esm/components/ReactPlayer/ReactPlayer.css +7 -0
- package/build/esm/components/ReactPlayer/ReactPlayer.d.ts +1 -0
- package/build/esm/components/ReactPlayer/ReactPlayer.js +15 -4
- package/build/esm/models/constructor-items/common.d.ts +2 -1
- package/build/esm/schema/constants.d.ts +5 -1
- package/build/esm/schema/validators/common.d.ts +11 -1
- package/build/esm/schema/validators/common.js +5 -1
- package/build/esm/sub-blocks/ImageCard/ImageCard.js +1 -1
- package/build/esm/sub-blocks/LayoutItem/schema.d.ts +5 -1
- package/build/esm/sub-blocks/MediaCard/schema.d.ts +5 -1
- package/package.json +1 -1
- package/server/models/constructor-items/common.d.ts +2 -1
- package/styles/variables.scss +1 -0
- package/widget/index.js +1 -1
|
@@ -10,6 +10,7 @@ export interface ReactPlayerBlockProps extends Omit<MediaVideoProps, 'loop' | 's
|
|
|
10
10
|
onClickPreview?: () => void;
|
|
11
11
|
height?: number;
|
|
12
12
|
ratio?: number;
|
|
13
|
+
autoRatio?: boolean;
|
|
13
14
|
children?: React.ReactNode;
|
|
14
15
|
}
|
|
15
16
|
export declare const ReactPlayerBlock: React.ForwardRefExoticComponent<ReactPlayerBlockProps & React.RefAttributes<ReactPlayerBlockHandler>>;
|
|
@@ -21,7 +21,7 @@ const FPS = 60;
|
|
|
21
21
|
// eslint-disable-next-line react/display-name
|
|
22
22
|
export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
23
23
|
const isMobile = useContext(MobileContext);
|
|
24
|
-
const { src, previewImgUrl, loop = false, controls = MediaVideoControlsType.Default, customControlsOptions = {}, muted: initiallyMuted = false, elapsedTime, playButton, className, customBarControlsClassName, showPreview, onClickPreview, analyticsEvents, height, ariaLabel, ratio, } = props;
|
|
24
|
+
const { src, previewImgUrl, loop = false, controls = MediaVideoControlsType.Default, customControlsOptions = {}, muted: initiallyMuted = false, elapsedTime, playButton, className, customBarControlsClassName, showPreview, onClickPreview, analyticsEvents, height, ariaLabel, ratio, autoRatio, contain, } = props;
|
|
25
25
|
const { type = PlayButtonType.Default, theme = PlayButtonThemes.Blue, text, className: buttonClassName, } = playButton || {};
|
|
26
26
|
const { type: customControlsType = CustomControlsType.WithMuteButton, muteButtonShown, positioning = CustomControlsButtonPositioning.Center, } = customControlsOptions;
|
|
27
27
|
const autoPlay = Boolean(!isMobile && !previewImgUrl && props.autoplay);
|
|
@@ -33,6 +33,7 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
33
33
|
const [playedPercent, setPlayedPercent] = useState(0);
|
|
34
34
|
const [currentHeight, setCurrentHeight] = useState(height);
|
|
35
35
|
const [width, setWidth] = useState(0);
|
|
36
|
+
const [actualRatio, setActualRatio] = useState();
|
|
36
37
|
const [muted, setMuted] = useState(mute);
|
|
37
38
|
const [started, setStarted] = useState(autoPlay);
|
|
38
39
|
const [ended, setEnded] = useState(false);
|
|
@@ -103,7 +104,7 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
103
104
|
parseFloat(paddingLeft) -
|
|
104
105
|
parseFloat(paddingRight);
|
|
105
106
|
setWidth(newWidth);
|
|
106
|
-
setCurrentHeight(Math.floor(getHeight(newWidth, ratio)));
|
|
107
|
+
setCurrentHeight(Math.floor(getHeight(newWidth, ratio !== null && ratio !== void 0 ? ratio : (autoRatio ? actualRatio : undefined))));
|
|
107
108
|
}
|
|
108
109
|
}, 200);
|
|
109
110
|
updateSize();
|
|
@@ -111,7 +112,7 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
111
112
|
return () => {
|
|
112
113
|
window.removeEventListener('resize', updateSize);
|
|
113
114
|
};
|
|
114
|
-
}, [ratio]);
|
|
115
|
+
}, [actualRatio, autoRatio, ratio]);
|
|
115
116
|
const playEvents = useMemo(() => eventsArray === null || eventsArray === void 0 ? void 0 : eventsArray.filter((e) => e.type === PredefinedEventTypes.Play), [eventsArray]);
|
|
116
117
|
const stopEvents = useMemo(() => eventsArray === null || eventsArray === void 0 ? void 0 : eventsArray.filter((e) => e.type === PredefinedEventTypes.Stop), [eventsArray]);
|
|
117
118
|
const playIcon = useMemo(() => {
|
|
@@ -181,6 +182,15 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
181
182
|
setEnded(false);
|
|
182
183
|
}
|
|
183
184
|
}, [changeMute, controls, customControlsType, ended, isPlaying, muted]);
|
|
185
|
+
const onReady = useCallback((player) => {
|
|
186
|
+
setPlayerRef(player);
|
|
187
|
+
const videoElement = player.getInternalPlayer();
|
|
188
|
+
const videoWidth = videoElement.videoWidth;
|
|
189
|
+
const videoHeight = videoElement.videoHeight;
|
|
190
|
+
if (videoWidth && videoHeight) {
|
|
191
|
+
setActualRatio(videoHeight / videoWidth);
|
|
192
|
+
}
|
|
193
|
+
}, []);
|
|
184
194
|
const onProgress = useCallback((progress) => {
|
|
185
195
|
setPlayedPercent(progress.played);
|
|
186
196
|
if (progress.played === 1) {
|
|
@@ -221,8 +231,9 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
221
231
|
return (React.createElement("div", { className: b({
|
|
222
232
|
wrapper: !currentHeight,
|
|
223
233
|
controls,
|
|
234
|
+
contain,
|
|
224
235
|
}, className), ref: ref, onClick: handleClick, onMouseEnter: onFocusIn, onMouseLeave: onFocusOut, onFocus: onFocusIn, onBlur: onFocusOut }, isMounted ? (React.createElement(Fragment, null,
|
|
225
|
-
React.createElement(ReactPlayer, { className: b('player'), url: videoSrc, muted: muted, controls: controls === MediaVideoControlsType.Default, height: currentHeight || '100%', width: width || '100%', light: previewImgUrl, playing: isPlaying, playIcon: playIcon, progressInterval: FPS, onClickPreview: handleClickPreview, onStart: onStart, onReady:
|
|
236
|
+
React.createElement(ReactPlayer, { className: b('player'), url: videoSrc, muted: muted, controls: controls === MediaVideoControlsType.Default, height: currentHeight || '100%', width: width || '100%', light: previewImgUrl, playing: isPlaying, playIcon: playIcon, progressInterval: FPS, onClickPreview: handleClickPreview, onStart: onStart, onReady: onReady, onPlay: onPlay, onPause: autoPlay && customControlsType !== CustomControlsType.WithMuteButton
|
|
226
237
|
? undefined
|
|
227
238
|
: onPause, onProgress: onProgress, onEnded: onEnded, "aria-label": ariaLabel, previewTabIndex: -1, config: {
|
|
228
239
|
file: {
|
|
@@ -127,6 +127,7 @@ export interface MediaVideoProps extends AnalyticsEventsBase {
|
|
|
127
127
|
controls?: MediaVideoControlsType;
|
|
128
128
|
customControlsOptions?: CustomControlsOptions;
|
|
129
129
|
ariaLabel?: string;
|
|
130
|
+
contain?: boolean;
|
|
130
131
|
}
|
|
131
132
|
export interface LinkProps extends AnalyticsEventsBase, Stylable, Tabbable {
|
|
132
133
|
url: string;
|
|
@@ -179,7 +180,7 @@ export type ThemedMediaVideoProps = ThemeSupporting<MediaVideoProps>;
|
|
|
179
180
|
export interface MediaComponentVideoProps extends AnalyticsEventsBase {
|
|
180
181
|
video: MediaVideoProps;
|
|
181
182
|
height?: number;
|
|
182
|
-
ratio?: number;
|
|
183
|
+
ratio?: number | 'auto';
|
|
183
184
|
previewImg?: string;
|
|
184
185
|
}
|
|
185
186
|
export interface MediaComponentVideoIframeProps {
|
|
@@ -1549,6 +1549,9 @@ export declare const cardSchemas: {
|
|
|
1549
1549
|
ariaLabel: {
|
|
1550
1550
|
type: string;
|
|
1551
1551
|
};
|
|
1552
|
+
contain: {
|
|
1553
|
+
type: string;
|
|
1554
|
+
};
|
|
1552
1555
|
};
|
|
1553
1556
|
};
|
|
1554
1557
|
youtube: {
|
|
@@ -1590,7 +1593,8 @@ export declare const cardSchemas: {
|
|
|
1590
1593
|
type: string;
|
|
1591
1594
|
};
|
|
1592
1595
|
ratio: {
|
|
1593
|
-
type: string;
|
|
1596
|
+
type: string[];
|
|
1597
|
+
pattern: string;
|
|
1594
1598
|
};
|
|
1595
1599
|
iframe: {
|
|
1596
1600
|
type: string;
|
|
@@ -203,6 +203,9 @@ export declare const VideoProps: {
|
|
|
203
203
|
ariaLabel: {
|
|
204
204
|
type: string;
|
|
205
205
|
};
|
|
206
|
+
contain: {
|
|
207
|
+
type: string;
|
|
208
|
+
};
|
|
206
209
|
};
|
|
207
210
|
};
|
|
208
211
|
export declare const ThemeProps: {
|
|
@@ -365,6 +368,9 @@ export declare const BackgroundProps: {
|
|
|
365
368
|
ariaLabel: {
|
|
366
369
|
type: string;
|
|
367
370
|
};
|
|
371
|
+
contain: {
|
|
372
|
+
type: string;
|
|
373
|
+
};
|
|
368
374
|
};
|
|
369
375
|
};
|
|
370
376
|
height: {
|
|
@@ -1129,6 +1135,9 @@ export declare const MediaProps: {
|
|
|
1129
1135
|
ariaLabel: {
|
|
1130
1136
|
type: string;
|
|
1131
1137
|
};
|
|
1138
|
+
contain: {
|
|
1139
|
+
type: string;
|
|
1140
|
+
};
|
|
1132
1141
|
};
|
|
1133
1142
|
};
|
|
1134
1143
|
youtube: {
|
|
@@ -1248,7 +1257,8 @@ export declare const MediaProps: {
|
|
|
1248
1257
|
})[];
|
|
1249
1258
|
};
|
|
1250
1259
|
ratio: {
|
|
1251
|
-
type: string;
|
|
1260
|
+
type: string[];
|
|
1261
|
+
pattern: string;
|
|
1252
1262
|
};
|
|
1253
1263
|
iframe: {
|
|
1254
1264
|
type: string;
|
|
@@ -160,6 +160,9 @@ export const VideoProps = {
|
|
|
160
160
|
ariaLabel: {
|
|
161
161
|
type: 'string',
|
|
162
162
|
},
|
|
163
|
+
contain: {
|
|
164
|
+
type: 'boolean',
|
|
165
|
+
},
|
|
163
166
|
},
|
|
164
167
|
};
|
|
165
168
|
export const ThemeProps = {
|
|
@@ -542,7 +545,8 @@ export const MediaProps = {
|
|
|
542
545
|
anyOf: [AnalyticsEventSchema, { type: 'array', items: AnalyticsEventSchema }],
|
|
543
546
|
},
|
|
544
547
|
ratio: {
|
|
545
|
-
type: 'number',
|
|
548
|
+
type: ['number', 'string'],
|
|
549
|
+
pattern: '^auto$',
|
|
546
550
|
},
|
|
547
551
|
iframe: Object.assign({}, IframeProps),
|
|
548
552
|
margins: {
|
|
@@ -22,7 +22,7 @@ const ImageCard = (props) => {
|
|
|
22
22
|
React.createElement(Image, Object.assign({ className: b('image_inner', { radius: enableImageBorderRadius }) }, imageProps))),
|
|
23
23
|
hasContent && (React.createElement("div", { className: b('content') },
|
|
24
24
|
React.createElement(Content, { titleId: titleId, title: title, text: text, links: links, buttons: buttons, list: list, theme: cardTheme, additionalInfo: additionalInfo, size: size, colSizes: CONTENT_COL_SIZES, controlPosition: areControlsInFooter ? 'bottom' : 'default' })))));
|
|
25
|
-
return url ? (React.createElement(Link, { href: url, target: target, rel: target === '_blank' ? 'noopener noreferrer' : undefined, className: b({ border, 'with-content': hasContent, direction }), title: urlTitle, extraProps: {
|
|
25
|
+
return url ? (React.createElement(Link, { href: url, target: target, rel: target === '_blank' ? 'noopener noreferrer' : undefined, className: b({ border, 'with-content': hasContent, direction }), title: urlTitle, style: { backgroundColor }, extraProps: {
|
|
26
26
|
draggable: false,
|
|
27
27
|
onDragStart: (e) => e.preventDefault(),
|
|
28
28
|
} }, cardContent)) : (React.createElement("div", { className: b({ border, 'with-content': hasContent, direction }), style: { backgroundColor } }, cardContent));
|
|
@@ -157,6 +157,9 @@ export declare const LayoutItem: {
|
|
|
157
157
|
ariaLabel: {
|
|
158
158
|
type: string;
|
|
159
159
|
};
|
|
160
|
+
contain: {
|
|
161
|
+
type: string;
|
|
162
|
+
};
|
|
160
163
|
};
|
|
161
164
|
};
|
|
162
165
|
youtube: {
|
|
@@ -276,7 +279,8 @@ export declare const LayoutItem: {
|
|
|
276
279
|
})[];
|
|
277
280
|
};
|
|
278
281
|
ratio: {
|
|
279
|
-
type: string;
|
|
282
|
+
type: string[];
|
|
283
|
+
pattern: string;
|
|
280
284
|
};
|
|
281
285
|
iframe: {
|
|
282
286
|
type: string;
|
|
@@ -240,6 +240,9 @@ export declare const MediaCardBlock: {
|
|
|
240
240
|
ariaLabel: {
|
|
241
241
|
type: string;
|
|
242
242
|
};
|
|
243
|
+
contain: {
|
|
244
|
+
type: string;
|
|
245
|
+
};
|
|
243
246
|
};
|
|
244
247
|
};
|
|
245
248
|
youtube: {
|
|
@@ -281,7 +284,8 @@ export declare const MediaCardBlock: {
|
|
|
281
284
|
type: string;
|
|
282
285
|
};
|
|
283
286
|
ratio: {
|
|
284
|
-
type: string;
|
|
287
|
+
type: string[];
|
|
288
|
+
pattern: string;
|
|
285
289
|
};
|
|
286
290
|
iframe: {
|
|
287
291
|
type: string;
|
package/package.json
CHANGED
|
@@ -127,6 +127,7 @@ export interface MediaVideoProps extends AnalyticsEventsBase {
|
|
|
127
127
|
controls?: MediaVideoControlsType;
|
|
128
128
|
customControlsOptions?: CustomControlsOptions;
|
|
129
129
|
ariaLabel?: string;
|
|
130
|
+
contain?: boolean;
|
|
130
131
|
}
|
|
131
132
|
export interface LinkProps extends AnalyticsEventsBase, Stylable, Tabbable {
|
|
132
133
|
url: string;
|
|
@@ -179,7 +180,7 @@ export type ThemedMediaVideoProps = ThemeSupporting<MediaVideoProps>;
|
|
|
179
180
|
export interface MediaComponentVideoProps extends AnalyticsEventsBase {
|
|
180
181
|
video: MediaVideoProps;
|
|
181
182
|
height?: number;
|
|
182
|
-
ratio?: number;
|
|
183
|
+
ratio?: number | 'auto';
|
|
183
184
|
previewImg?: string;
|
|
184
185
|
}
|
|
185
186
|
export interface MediaComponentVideoIframeProps {
|