@gravity-ui/page-constructor 5.30.0-alpha.0 → 5.30.1
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 +0 -6
- package/build/cjs/blocks/Questions/QuestionBlockItem/QuestionBlockItem.css +12 -0
- package/build/cjs/blocks/Questions/QuestionBlockItem/QuestionBlockItem.js +1 -4
- package/build/cjs/components/ImageBase/ImageBase.d.ts +1 -1
- package/build/cjs/components/ImageBase/ImageBase.js +3 -4
- package/build/cjs/components/OutsideClick/OutsideClick.js +3 -5
- package/build/cjs/components/ReactPlayer/ReactPlayer.js +13 -6
- package/build/cjs/components/Title/TitleItem.css +9 -0
- package/build/cjs/components/Title/TitleItem.js +1 -4
- package/build/cjs/components/VideoBlock/VideoBlock.d.ts +1 -0
- package/build/cjs/components/VideoBlock/VideoBlock.js +5 -6
- package/build/cjs/editor/components/AddBlock/AddBlock.css +10 -0
- package/build/cjs/editor/components/AddBlock/AddBlock.js +1 -4
- package/build/cjs/editor/components/EditBlock/EditBlock.css +9 -0
- package/build/cjs/editor/components/EditBlock/EditBlock.js +6 -6
- package/build/esm/blocks/Questions/QuestionBlockItem/QuestionBlockItem.css +12 -0
- package/build/esm/blocks/Questions/QuestionBlockItem/QuestionBlockItem.js +1 -4
- package/build/esm/components/ImageBase/ImageBase.d.ts +1 -1
- package/build/esm/components/ImageBase/ImageBase.js +3 -4
- package/build/esm/components/OutsideClick/OutsideClick.js +3 -5
- package/build/esm/components/ReactPlayer/ReactPlayer.js +13 -6
- package/build/esm/components/Title/TitleItem.css +9 -0
- package/build/esm/components/Title/TitleItem.js +1 -4
- package/build/esm/components/VideoBlock/VideoBlock.d.ts +1 -0
- package/build/esm/components/VideoBlock/VideoBlock.js +6 -7
- package/build/esm/editor/components/AddBlock/AddBlock.css +10 -0
- package/build/esm/editor/components/AddBlock/AddBlock.js +1 -4
- package/build/esm/editor/components/EditBlock/EditBlock.css +9 -0
- package/build/esm/editor/components/EditBlock/EditBlock.js +7 -7
- package/package.json +1 -1
- package/styles/styles.css +1 -0
- package/styles/styles.scss +1 -0
- package/widget/index.js +1 -1
package/README.md
CHANGED
|
@@ -165,12 +165,6 @@ To use mixins and constructor style variables when creating custom blocks, add i
|
|
|
165
165
|
@import '~@gravity-ui/page-constructor/styles/styles.scss';
|
|
166
166
|
```
|
|
167
167
|
|
|
168
|
-
To use default font, add import in your file:
|
|
169
|
-
|
|
170
|
-
```css
|
|
171
|
-
@import '@gravity-ui/uikit/styles/fonts.css';
|
|
172
|
-
```
|
|
173
|
-
|
|
174
168
|
### Loadable blocks
|
|
175
169
|
|
|
176
170
|
It's sometimes necessary that a block renders itself based on data to be loaded. In this case, loadable blocks are used.
|
|
@@ -12,12 +12,24 @@ unpredictable css rules order in build */
|
|
|
12
12
|
padding-top: 32px;
|
|
13
13
|
}
|
|
14
14
|
.pc-QuestionsBlockItem__title {
|
|
15
|
+
display: inline-block;
|
|
16
|
+
margin: 0;
|
|
17
|
+
padding: 0;
|
|
18
|
+
font: inherit;
|
|
19
|
+
border: none;
|
|
20
|
+
outline: none;
|
|
21
|
+
color: inherit;
|
|
22
|
+
background: none;
|
|
23
|
+
cursor: pointer;
|
|
15
24
|
font-size: var(--g-text-header-1-font-size);
|
|
16
25
|
line-height: var(--g-text-header-1-line-height);
|
|
17
26
|
color: var(--pc-text-header-color);
|
|
18
27
|
font-weight: var(--g-text-accent-font-weight);
|
|
19
28
|
position: relative;
|
|
29
|
+
display: block;
|
|
30
|
+
width: 100%;
|
|
20
31
|
padding-right: 24px;
|
|
32
|
+
text-align: start;
|
|
21
33
|
cursor: pointer;
|
|
22
34
|
border-radius: var(--g-focus-border-radius);
|
|
23
35
|
}
|
|
@@ -12,10 +12,7 @@ const b = (0, utils_1.block)('QuestionsBlockItem');
|
|
|
12
12
|
const QuestionBlockItem = ({ title: itemTitle, text: itemText, link, listStyle = 'dash', isOpened, onClick, }) => {
|
|
13
13
|
const { onKeyDown } = (0, uikit_1.useActionHandlers)(onClick);
|
|
14
14
|
return (react_1.default.createElement("div", { className: b(), itemScope: true, itemProp: models_1.FaqMicrodataValues.QuestionProp, itemType: models_1.FaqMicrodataValues.QuestionType, role: 'listitem' },
|
|
15
|
-
react_1.default.createElement("
|
|
16
|
-
// TODO fix in https://github.com/gravity-ui/page-constructor/issues/966
|
|
17
|
-
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
|
|
18
|
-
role: 'button', tabIndex: 0, onKeyDown: onKeyDown },
|
|
15
|
+
react_1.default.createElement("button", { className: b('title'), onClick: onClick, "aria-expanded": isOpened, onKeyDown: onKeyDown },
|
|
19
16
|
react_1.default.createElement(components_1.HTML, { itemProp: models_1.FaqMicrodataValues.QuestionNameProp }, itemTitle),
|
|
20
17
|
react_1.default.createElement(components_1.ToggleArrow, { open: isOpened, size: 16, type: 'vertical', iconType: "navigation", className: b('arrow') })),
|
|
21
18
|
react_1.default.createElement(components_1.Foldable, { isOpened: isOpened },
|
|
@@ -7,5 +7,5 @@ export interface ImageBaseProps extends Partial<ImageObjectProps> {
|
|
|
7
7
|
onLoad?: ReactEventHandler<HTMLDivElement>;
|
|
8
8
|
onError?: () => void;
|
|
9
9
|
}
|
|
10
|
-
export declare const ImageBase: ({ fetchPriority, ...props }: ImageBaseProps) => JSX.Element;
|
|
10
|
+
export declare const ImageBase: ({ fetchPriority, alt, ...props }: ImageBaseProps) => JSX.Element;
|
|
11
11
|
export default ImageBase;
|
|
@@ -5,15 +5,14 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const imageContext_1 = require("../../context/imageContext/imageContext");
|
|
7
7
|
const ImageBase = (_a) => {
|
|
8
|
-
var { fetchPriority } = _a, props = tslib_1.__rest(_a, ["fetchPriority"]);
|
|
8
|
+
var { fetchPriority, alt } = _a, props = tslib_1.__rest(_a, ["fetchPriority", "alt"]);
|
|
9
9
|
const { Image } = react_1.default.useContext(imageContext_1.ImageContext);
|
|
10
|
-
return Image ? (react_1.default.createElement(Image, Object.assign({ fetchPriority: fetchPriority }, props))) : (
|
|
10
|
+
return Image ? (react_1.default.createElement(Image, Object.assign({ fetchPriority: fetchPriority, alt: alt }, props))) : (
|
|
11
11
|
// There is an issue with fetchpriority attr in img in React.
|
|
12
12
|
// It is still not supported. However it's nice to have ability to manage
|
|
13
13
|
// this prop is good to have to improve Core Web Vitals.
|
|
14
14
|
// So, here is a workaround to assign the attr.
|
|
15
|
-
|
|
16
|
-
react_1.default.createElement("img", Object.assign({}, { fetchpriority: fetchPriority }, props)));
|
|
15
|
+
react_1.default.createElement("img", Object.assign({}, { fetchpriority: fetchPriority }, { alt: alt }, props)));
|
|
17
16
|
};
|
|
18
17
|
exports.ImageBase = ImageBase;
|
|
19
18
|
exports.default = exports.ImageBase;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
3
|
-
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
4
|
-
// TODO fix in https://github.com/gravity-ui/page-constructor/issues/965
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
const tslib_1 = require("tslib");
|
|
7
4
|
//TODO move into cloud components?
|
|
8
5
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
+
const noop_1 = tslib_1.__importDefault(require("lodash/noop"));
|
|
9
7
|
class OutsideClick extends react_1.default.Component {
|
|
10
8
|
constructor() {
|
|
11
9
|
super(...arguments);
|
|
@@ -26,8 +24,8 @@ class OutsideClick extends react_1.default.Component {
|
|
|
26
24
|
document.removeEventListener('click', this.handleOutsideClick);
|
|
27
25
|
}
|
|
28
26
|
render() {
|
|
29
|
-
const { className, onClick
|
|
30
|
-
return (react_1.default.createElement("div", { className: className, ref: this.ref, onClick: onClick }, children));
|
|
27
|
+
const { children, className, onClick } = this.props;
|
|
28
|
+
return (react_1.default.createElement("div", { className: className, ref: this.ref, onClick: onClick, onKeyDown: noop_1.default, role: onClick ? 'button' : 'group', tabIndex: onClick ? 0 : -1 }, children));
|
|
31
29
|
}
|
|
32
30
|
}
|
|
33
31
|
exports.default = OutsideClick;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
3
|
-
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
4
|
-
// TODO fix in https://github.com/gravity-ui/page-constructor/issues/965
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.ReactPlayerBlock = void 0;
|
|
7
4
|
const tslib_1 = require("tslib");
|
|
@@ -31,6 +28,7 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
|
|
|
31
28
|
const mute = initiallyMuted || autoPlay;
|
|
32
29
|
const { playingVideoRef, setProps } = (0, react_1.useContext)(videoContext_1.VideoContext);
|
|
33
30
|
const ref = (0, react_1.useRef)(null);
|
|
31
|
+
const buttonRef = (0, react_1.useRef)(null);
|
|
34
32
|
const [playerRef, setPlayerRef] = (0, react_1.useState)();
|
|
35
33
|
const [isPlaying, setIsPlaying] = (0, react_1.useState)(autoPlay);
|
|
36
34
|
const [playedPercent, setPlayedPercent] = (0, react_1.useState)(0);
|
|
@@ -129,7 +127,7 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
|
|
|
129
127
|
playButtonContent = react_1.default.createElement(uikit_1.Icon, { className: b('icon'), data: icons_1.PlayFill, size: 24 });
|
|
130
128
|
break;
|
|
131
129
|
}
|
|
132
|
-
return (react_1.default.createElement("button", { className: b('button', { theme, text: Boolean(text) }, buttonClassName), "aria-label": (0, i18n_1.i18n)('play') }, playButtonContent));
|
|
130
|
+
return (react_1.default.createElement("button", { className: b('button', { theme, text: Boolean(text) }, buttonClassName), "aria-label": (0, i18n_1.i18n)('play'), ref: buttonRef }, playButtonContent));
|
|
133
131
|
}, [type, theme, text, buttonClassName]);
|
|
134
132
|
const changeMute = (0, react_1.useCallback)((isMuted) => {
|
|
135
133
|
if (isMuted &&
|
|
@@ -220,6 +218,8 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
|
|
|
220
218
|
}
|
|
221
219
|
}, [isPlaying, onPlay, onPause]);
|
|
222
220
|
const handleClick = (0, react_1.useCallback)(() => {
|
|
221
|
+
var _a;
|
|
222
|
+
(_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
223
223
|
if (controls === models_1.MediaVideoControlsType.Custom) {
|
|
224
224
|
if (customControlsType === models_1.CustomControlsType.WithMuteButton) {
|
|
225
225
|
changeMute(muted);
|
|
@@ -228,7 +228,14 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
|
|
|
228
228
|
onPlayClick();
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
}, [
|
|
231
|
+
}, [controls, customControlsType, changeMute, muted, onPlayClick]);
|
|
232
|
+
const handleKeyDown = (0, react_1.useCallback)((e) => {
|
|
233
|
+
var _a;
|
|
234
|
+
const key = e.key.toLowerCase();
|
|
235
|
+
if (key === 'enter') {
|
|
236
|
+
(_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
237
|
+
}
|
|
238
|
+
}, []);
|
|
232
239
|
const onFocusIn = (0, react_1.useCallback)(() => setHovered(true), []);
|
|
233
240
|
const onFocusOut = (0, react_1.useCallback)(() => setHovered(false), []);
|
|
234
241
|
return (react_1.default.createElement("div", { className: b({
|
|
@@ -236,7 +243,7 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
|
|
|
236
243
|
controls,
|
|
237
244
|
contain,
|
|
238
245
|
'auto-ratio': autoRatio,
|
|
239
|
-
}, className), ref: ref, onClick: handleClick, onMouseEnter: onFocusIn, onMouseLeave: onFocusOut, onFocus: onFocusIn, onBlur: onFocusOut }, isMounted ? (react_1.default.createElement(react_1.Fragment, null,
|
|
246
|
+
}, className), ref: ref, onClick: handleClick, onMouseEnter: onFocusIn, onMouseLeave: onFocusOut, onFocus: onFocusIn, onBlur: onFocusOut, onKeyDown: handleKeyDown, role: "button", tabIndex: 0 }, isMounted ? (react_1.default.createElement(react_1.Fragment, null,
|
|
240
247
|
react_1.default.createElement(react_player_1.default, { className: b('player'), url: videoSrc, muted: muted, controls: controls === models_1.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 !== models_1.CustomControlsType.WithMuteButton
|
|
241
248
|
? undefined
|
|
242
249
|
: onPause, onProgress: onProgress, onEnded: onEnded, "aria-label": ariaLabel, previewTabIndex: -1, config: {
|
|
@@ -59,6 +59,15 @@ unpredictable css rules order in build */
|
|
|
59
59
|
margin-top: 4px;
|
|
60
60
|
}
|
|
61
61
|
.pc-title-item__link {
|
|
62
|
+
display: inline-block;
|
|
63
|
+
margin: 0;
|
|
64
|
+
padding: 0;
|
|
65
|
+
font: inherit;
|
|
66
|
+
border: none;
|
|
67
|
+
outline: none;
|
|
68
|
+
color: inherit;
|
|
69
|
+
background: none;
|
|
70
|
+
cursor: pointer;
|
|
62
71
|
color: inherit;
|
|
63
72
|
text-decoration: none;
|
|
64
73
|
padding-right: 8px;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
3
|
-
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
4
|
-
// TODO fix in https://github.com/gravity-ui/page-constructor/issues/965
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getArrowSize = void 0;
|
|
7
4
|
const tslib_1 = require("tslib");
|
|
@@ -48,7 +45,7 @@ const TitleItem = (props) => {
|
|
|
48
45
|
content = (react_1.default.createElement("a", Object.assign({ className: b('link'), href: url }, (0, utils_1.getLinkProps)(url, hostname), { onClick: onClick, title: urlTitle }), insideClickableContent));
|
|
49
46
|
}
|
|
50
47
|
else if (onClick) {
|
|
51
|
-
content = (react_1.default.createElement("
|
|
48
|
+
content = (react_1.default.createElement("button", { className: b('link'), onClick: onClick, title: urlTitle }, insideClickableContent));
|
|
52
49
|
}
|
|
53
50
|
return (react_1.default.createElement(react_1.Fragment, null,
|
|
54
51
|
anchor && react_1.default.createElement(Anchor_1.default, { id: anchor, className: b('anchor') }),
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
3
|
-
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
4
|
-
// TODO fix in https://github.com/gravity-ui/page-constructor/issues/965
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getHeight = exports.AUTOPLAY_ATTRIBUTES = void 0;
|
|
7
4
|
const tslib_1 = require("tslib");
|
|
@@ -47,13 +44,14 @@ function getHeight(width) {
|
|
|
47
44
|
}
|
|
48
45
|
exports.getHeight = getHeight;
|
|
49
46
|
const VideoBlock = (props) => {
|
|
50
|
-
const { stream, record, videoIframe, attributes, className, id, previewImg, playButton, height, fullscreen, analyticsEvents, autoplay, onImageLoad, } = props;
|
|
47
|
+
const { stream, record, videoIframe, attributes, className, id, previewImg, playButton, playButtonId, height, fullscreen, analyticsEvents, autoplay, onImageLoad, } = props;
|
|
51
48
|
const handleAnalytics = (0, useAnalytics_1.useAnalytics)(common_1.DefaultEventNames.VideoPreview);
|
|
52
49
|
const src = videoIframe ? videoIframe : getYoutubeVideoSrc(stream, record);
|
|
53
50
|
const ref = (0, react_1.useRef)(null);
|
|
54
51
|
const [hidePreview, setHidePreview] = (0, react_1.useState)(false);
|
|
55
52
|
const [currentHeight, setCurrentHeight] = (0, react_1.useState)(height || undefined);
|
|
56
53
|
const fullId = (0, react_1.useMemo)(() => id || (0, uuid_1.v4)(), [id]);
|
|
54
|
+
const buttonId = (0, uikit_1.useUniqId)();
|
|
57
55
|
const [isPlaying, setIsPlaying] = (0, react_1.useState)(!previewImg);
|
|
58
56
|
const iframeSrc = src && isPlaying
|
|
59
57
|
? `${src}?${(0, utils_1.getPageSearchParams)(Object.assign(Object.assign({}, (attributes || {})), (previewImg || autoplay ? exports.AUTOPLAY_ATTRIBUTES : NO_AUTOPLAY_ATTRIBUTES)))}`
|
|
@@ -63,6 +61,7 @@ const VideoBlock = (props) => {
|
|
|
63
61
|
setIsPlaying(true);
|
|
64
62
|
setTimeout(() => setHidePreview(true), AUTOPLAY_DELAY);
|
|
65
63
|
}, [handleAnalytics, analyticsEvents]);
|
|
64
|
+
const { onKeyDown: onPreviewKeyDown } = (0, uikit_1.useActionHandlers)(onPreviewClick);
|
|
66
65
|
(0, react_1.useEffect)(() => {
|
|
67
66
|
const updateSize = (0, debounce_1.default)(() => {
|
|
68
67
|
setCurrentHeight(ref.current ? Math.round(getHeight(ref.current.offsetWidth)) : undefined);
|
|
@@ -84,9 +83,9 @@ const VideoBlock = (props) => {
|
|
|
84
83
|
}
|
|
85
84
|
return (react_1.default.createElement("div", { className: b(null, className), style: { height: currentHeight }, ref: ref },
|
|
86
85
|
iframeContent,
|
|
87
|
-
previewImg && !hidePreview && !fullscreen && (react_1.default.createElement("div", { className: b('preview'), onClick: onPreviewClick },
|
|
86
|
+
previewImg && !hidePreview && !fullscreen && (react_1.default.createElement("div", { className: b('preview'), onClick: onPreviewClick, onKeyDown: onPreviewKeyDown, role: "button", tabIndex: 0, "aria-labelledby": playButton ? playButtonId : buttonId },
|
|
88
87
|
react_1.default.createElement(Image_1.default, { src: previewImg, className: b('image'), containerClassName: b('image-wrapper'), onLoad: onImageLoad }),
|
|
89
|
-
playButton || (react_1.default.createElement("button", { title: "Play", className: b('button') },
|
|
88
|
+
playButton || (react_1.default.createElement("button", { title: "Play", id: buttonId, className: b('button') },
|
|
90
89
|
react_1.default.createElement(uikit_1.Icon, { className: b('icon'), data: icons_1.PlayFill, size: 24 })))))));
|
|
91
90
|
};
|
|
92
91
|
exports.default = VideoBlock;
|
|
@@ -51,12 +51,22 @@ unpredictable css rules order in build */
|
|
|
51
51
|
overflow-y: auto;
|
|
52
52
|
}
|
|
53
53
|
.pc-add-block__popup .pc-add-block__block {
|
|
54
|
+
display: inline-block;
|
|
55
|
+
margin: 0;
|
|
56
|
+
padding: 0;
|
|
57
|
+
font: inherit;
|
|
58
|
+
border: none;
|
|
59
|
+
outline: none;
|
|
60
|
+
color: inherit;
|
|
61
|
+
background: none;
|
|
62
|
+
cursor: pointer;
|
|
54
63
|
display: flex;
|
|
55
64
|
justify-content: center;
|
|
56
65
|
align-items: center;
|
|
57
66
|
transition: transform 0.2s;
|
|
58
67
|
margin-top: 20px;
|
|
59
68
|
justify-content: flex-start;
|
|
69
|
+
text-align: start;
|
|
60
70
|
cursor: pointer;
|
|
61
71
|
}
|
|
62
72
|
.pc-add-block__popup .pc-add-block__block:hover {
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
3
|
-
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
4
|
-
// TODO fix in https://github.com/gravity-ui/page-constructor/issues/965
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
const tslib_1 = require("tslib");
|
|
7
4
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
@@ -49,7 +46,7 @@ const AddBlock = ({ onAdd, className }) => {
|
|
|
49
46
|
return null;
|
|
50
47
|
}
|
|
51
48
|
const Preview = blockData.preview;
|
|
52
|
-
return (react_1.default.createElement("
|
|
49
|
+
return (react_1.default.createElement("button", { key: blockName, className: b('block'), onClick: () => {
|
|
53
50
|
onAdd(blockData === null || blockData === void 0 ? void 0 : blockData.template);
|
|
54
51
|
setIsOpened(false);
|
|
55
52
|
} },
|
|
@@ -38,6 +38,15 @@ unpredictable css rules order in build */
|
|
|
38
38
|
transform: translateX(-50%);
|
|
39
39
|
}
|
|
40
40
|
.pc-edit-block__control {
|
|
41
|
+
display: inline-block;
|
|
42
|
+
margin: 0;
|
|
43
|
+
padding: 0;
|
|
44
|
+
font: inherit;
|
|
45
|
+
border: none;
|
|
46
|
+
outline: none;
|
|
47
|
+
color: inherit;
|
|
48
|
+
background: none;
|
|
49
|
+
cursor: pointer;
|
|
41
50
|
display: flex;
|
|
42
51
|
justify-content: center;
|
|
43
52
|
align-items: center;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
3
|
-
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
4
|
-
// TODO fix in https://github.com/gravity-ui/page-constructor/issues/965
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.EditBlockControls = void 0;
|
|
7
4
|
const tslib_1 = require("tslib");
|
|
8
5
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
9
6
|
const icons_1 = require("@gravity-ui/icons");
|
|
7
|
+
const uikit_1 = require("@gravity-ui/uikit");
|
|
10
8
|
const utils_1 = require("../../../utils");
|
|
11
9
|
const b = (0, utils_1.block)('edit-block');
|
|
12
10
|
var EditBlockControls;
|
|
@@ -30,20 +28,22 @@ const editBlockControlsIcons = {
|
|
|
30
28
|
};
|
|
31
29
|
const EditBlock = ({ actions, isActive, onSelect, isHeader, children, resetPaddings, }) => {
|
|
32
30
|
const ref = (0, react_1.useRef)(null);
|
|
31
|
+
const stopPropagationProps = (0, react_1.useMemo)(() => ({ onClick: (e) => e.stopPropagation() }), []);
|
|
32
|
+
const { onKeyDown } = (0, uikit_1.useActionHandlers)(onSelect);
|
|
33
33
|
(0, react_1.useEffect)(() => {
|
|
34
34
|
if (isActive && ref.current) {
|
|
35
35
|
//TODO: add behavior 'smooth' after addiiton of dynamic form layout open/close managing support
|
|
36
36
|
ref.current.scrollIntoView({ block: 'center' });
|
|
37
37
|
}
|
|
38
38
|
}, [isActive]);
|
|
39
|
-
return (react_1.default.createElement("div", { className: b({ active: isActive }), onClick: onSelect, ref: ref },
|
|
39
|
+
return (react_1.default.createElement("div", { className: b({ active: isActive }), onClick: onSelect, onKeyDown: onKeyDown, ref: ref, role: "button", "aria-current": isActive, tabIndex: 0 },
|
|
40
40
|
react_1.default.createElement("div", { className: b('controls', {
|
|
41
41
|
active: isActive,
|
|
42
42
|
isHeader,
|
|
43
43
|
'reset-paddings': resetPaddings,
|
|
44
|
-
}) }, isActive && (react_1.default.createElement("div", { className: b('controls-content'),
|
|
44
|
+
}) }, isActive && (react_1.default.createElement("div", Object.assign({ className: b('controls-content') }, stopPropagationProps), actionsOrder.map((action) => {
|
|
45
45
|
const Icon = editBlockControlsIcons[action];
|
|
46
|
-
return actions[action] ? (react_1.default.createElement("
|
|
46
|
+
return actions[action] ? (react_1.default.createElement("button", { key: action, className: b('control'), onClick: actions[action] },
|
|
47
47
|
react_1.default.createElement(Icon, null))) : null;
|
|
48
48
|
})))),
|
|
49
49
|
children));
|
|
@@ -12,12 +12,24 @@ unpredictable css rules order in build */
|
|
|
12
12
|
padding-top: 32px;
|
|
13
13
|
}
|
|
14
14
|
.pc-QuestionsBlockItem__title {
|
|
15
|
+
display: inline-block;
|
|
16
|
+
margin: 0;
|
|
17
|
+
padding: 0;
|
|
18
|
+
font: inherit;
|
|
19
|
+
border: none;
|
|
20
|
+
outline: none;
|
|
21
|
+
color: inherit;
|
|
22
|
+
background: none;
|
|
23
|
+
cursor: pointer;
|
|
15
24
|
font-size: var(--g-text-header-1-font-size);
|
|
16
25
|
line-height: var(--g-text-header-1-line-height);
|
|
17
26
|
color: var(--pc-text-header-color);
|
|
18
27
|
font-weight: var(--g-text-accent-font-weight);
|
|
19
28
|
position: relative;
|
|
29
|
+
display: block;
|
|
30
|
+
width: 100%;
|
|
20
31
|
padding-right: 24px;
|
|
32
|
+
text-align: start;
|
|
21
33
|
cursor: pointer;
|
|
22
34
|
border-radius: var(--g-focus-border-radius);
|
|
23
35
|
}
|
|
@@ -9,10 +9,7 @@ const b = block('QuestionsBlockItem');
|
|
|
9
9
|
export const QuestionBlockItem = ({ title: itemTitle, text: itemText, link, listStyle = 'dash', isOpened, onClick, }) => {
|
|
10
10
|
const { onKeyDown } = useActionHandlers(onClick);
|
|
11
11
|
return (React.createElement("div", { className: b(), itemScope: true, itemProp: FaqMicrodataValues.QuestionProp, itemType: FaqMicrodataValues.QuestionType, role: 'listitem' },
|
|
12
|
-
React.createElement("
|
|
13
|
-
// TODO fix in https://github.com/gravity-ui/page-constructor/issues/966
|
|
14
|
-
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
|
|
15
|
-
role: 'button', tabIndex: 0, onKeyDown: onKeyDown },
|
|
12
|
+
React.createElement("button", { className: b('title'), onClick: onClick, "aria-expanded": isOpened, onKeyDown: onKeyDown },
|
|
16
13
|
React.createElement(HTML, { itemProp: FaqMicrodataValues.QuestionNameProp }, itemTitle),
|
|
17
14
|
React.createElement(ToggleArrow, { open: isOpened, size: 16, type: 'vertical', iconType: "navigation", className: b('arrow') })),
|
|
18
15
|
React.createElement(Foldable, { isOpened: isOpened },
|
|
@@ -7,5 +7,5 @@ export interface ImageBaseProps extends Partial<ImageObjectProps> {
|
|
|
7
7
|
onLoad?: ReactEventHandler<HTMLDivElement>;
|
|
8
8
|
onError?: () => void;
|
|
9
9
|
}
|
|
10
|
-
export declare const ImageBase: ({ fetchPriority, ...props }: ImageBaseProps) => JSX.Element;
|
|
10
|
+
export declare const ImageBase: ({ fetchPriority, alt, ...props }: ImageBaseProps) => JSX.Element;
|
|
11
11
|
export default ImageBase;
|
|
@@ -2,14 +2,13 @@ import { __rest } from "tslib";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { ImageContext } from '../../context/imageContext/imageContext';
|
|
4
4
|
export const ImageBase = (_a) => {
|
|
5
|
-
var { fetchPriority } = _a, props = __rest(_a, ["fetchPriority"]);
|
|
5
|
+
var { fetchPriority, alt } = _a, props = __rest(_a, ["fetchPriority", "alt"]);
|
|
6
6
|
const { Image } = React.useContext(ImageContext);
|
|
7
|
-
return Image ? (React.createElement(Image, Object.assign({ fetchPriority: fetchPriority }, props))) : (
|
|
7
|
+
return Image ? (React.createElement(Image, Object.assign({ fetchPriority: fetchPriority, alt: alt }, props))) : (
|
|
8
8
|
// There is an issue with fetchpriority attr in img in React.
|
|
9
9
|
// It is still not supported. However it's nice to have ability to manage
|
|
10
10
|
// this prop is good to have to improve Core Web Vitals.
|
|
11
11
|
// So, here is a workaround to assign the attr.
|
|
12
|
-
|
|
13
|
-
React.createElement("img", Object.assign({}, { fetchpriority: fetchPriority }, props)));
|
|
12
|
+
React.createElement("img", Object.assign({}, { fetchpriority: fetchPriority }, { alt: alt }, props)));
|
|
14
13
|
};
|
|
15
14
|
export default ImageBase;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
2
|
-
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
3
|
-
// TODO fix in https://github.com/gravity-ui/page-constructor/issues/965
|
|
4
1
|
//TODO move into cloud components?
|
|
5
2
|
import React, { createRef } from 'react';
|
|
3
|
+
import noop from 'lodash/noop';
|
|
6
4
|
export default class OutsideClick extends React.Component {
|
|
7
5
|
constructor() {
|
|
8
6
|
super(...arguments);
|
|
@@ -23,7 +21,7 @@ export default class OutsideClick extends React.Component {
|
|
|
23
21
|
document.removeEventListener('click', this.handleOutsideClick);
|
|
24
22
|
}
|
|
25
23
|
render() {
|
|
26
|
-
const { className, onClick
|
|
27
|
-
return (React.createElement("div", { className: className, ref: this.ref, onClick: onClick }, children));
|
|
24
|
+
const { children, className, onClick } = this.props;
|
|
25
|
+
return (React.createElement("div", { className: className, ref: this.ref, onClick: onClick, onKeyDown: noop, role: onClick ? 'button' : 'group', tabIndex: onClick ? 0 : -1 }, children));
|
|
28
26
|
}
|
|
29
27
|
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
2
|
-
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
3
|
-
// TODO fix in https://github.com/gravity-ui/page-constructor/issues/965
|
|
4
1
|
import React, { Fragment, useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState, } from 'react';
|
|
5
2
|
import { PlayFill } from '@gravity-ui/icons';
|
|
6
3
|
import { Icon } from '@gravity-ui/uikit';
|
|
@@ -28,6 +25,7 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
28
25
|
const mute = initiallyMuted || autoPlay;
|
|
29
26
|
const { playingVideoRef, setProps } = useContext(VideoContext);
|
|
30
27
|
const ref = useRef(null);
|
|
28
|
+
const buttonRef = useRef(null);
|
|
31
29
|
const [playerRef, setPlayerRef] = useState();
|
|
32
30
|
const [isPlaying, setIsPlaying] = useState(autoPlay);
|
|
33
31
|
const [playedPercent, setPlayedPercent] = useState(0);
|
|
@@ -126,7 +124,7 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
126
124
|
playButtonContent = React.createElement(Icon, { className: b('icon'), data: PlayFill, size: 24 });
|
|
127
125
|
break;
|
|
128
126
|
}
|
|
129
|
-
return (React.createElement("button", { className: b('button', { theme, text: Boolean(text) }, buttonClassName), "aria-label": i18n('play') }, playButtonContent));
|
|
127
|
+
return (React.createElement("button", { className: b('button', { theme, text: Boolean(text) }, buttonClassName), "aria-label": i18n('play'), ref: buttonRef }, playButtonContent));
|
|
130
128
|
}, [type, theme, text, buttonClassName]);
|
|
131
129
|
const changeMute = useCallback((isMuted) => {
|
|
132
130
|
if (isMuted &&
|
|
@@ -217,6 +215,8 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
217
215
|
}
|
|
218
216
|
}, [isPlaying, onPlay, onPause]);
|
|
219
217
|
const handleClick = useCallback(() => {
|
|
218
|
+
var _a;
|
|
219
|
+
(_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
220
220
|
if (controls === MediaVideoControlsType.Custom) {
|
|
221
221
|
if (customControlsType === CustomControlsType.WithMuteButton) {
|
|
222
222
|
changeMute(muted);
|
|
@@ -225,7 +225,14 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
225
225
|
onPlayClick();
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
}, [
|
|
228
|
+
}, [controls, customControlsType, changeMute, muted, onPlayClick]);
|
|
229
|
+
const handleKeyDown = useCallback((e) => {
|
|
230
|
+
var _a;
|
|
231
|
+
const key = e.key.toLowerCase();
|
|
232
|
+
if (key === 'enter') {
|
|
233
|
+
(_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
234
|
+
}
|
|
235
|
+
}, []);
|
|
229
236
|
const onFocusIn = useCallback(() => setHovered(true), []);
|
|
230
237
|
const onFocusOut = useCallback(() => setHovered(false), []);
|
|
231
238
|
return (React.createElement("div", { className: b({
|
|
@@ -233,7 +240,7 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
233
240
|
controls,
|
|
234
241
|
contain,
|
|
235
242
|
'auto-ratio': autoRatio,
|
|
236
|
-
}, className), ref: ref, onClick: handleClick, onMouseEnter: onFocusIn, onMouseLeave: onFocusOut, onFocus: onFocusIn, onBlur: onFocusOut }, isMounted ? (React.createElement(Fragment, null,
|
|
243
|
+
}, className), ref: ref, onClick: handleClick, onMouseEnter: onFocusIn, onMouseLeave: onFocusOut, onFocus: onFocusIn, onBlur: onFocusOut, onKeyDown: handleKeyDown, role: "button", tabIndex: 0 }, isMounted ? (React.createElement(Fragment, null,
|
|
237
244
|
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
|
|
238
245
|
? undefined
|
|
239
246
|
: onPause, onProgress: onProgress, onEnded: onEnded, "aria-label": ariaLabel, previewTabIndex: -1, config: {
|
|
@@ -59,6 +59,15 @@ unpredictable css rules order in build */
|
|
|
59
59
|
margin-top: 4px;
|
|
60
60
|
}
|
|
61
61
|
.pc-title-item__link {
|
|
62
|
+
display: inline-block;
|
|
63
|
+
margin: 0;
|
|
64
|
+
padding: 0;
|
|
65
|
+
font: inherit;
|
|
66
|
+
border: none;
|
|
67
|
+
outline: none;
|
|
68
|
+
color: inherit;
|
|
69
|
+
background: none;
|
|
70
|
+
cursor: pointer;
|
|
62
71
|
color: inherit;
|
|
63
72
|
text-decoration: none;
|
|
64
73
|
padding-right: 8px;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
2
|
-
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
3
|
-
// TODO fix in https://github.com/gravity-ui/page-constructor/issues/965
|
|
4
1
|
import React, { Fragment, useContext } from 'react';
|
|
5
2
|
import { HTML, ToggleArrow } from '../';
|
|
6
3
|
import { LocationContext } from '../../context/locationContext';
|
|
@@ -44,7 +41,7 @@ const TitleItem = (props) => {
|
|
|
44
41
|
content = (React.createElement("a", Object.assign({ className: b('link'), href: url }, getLinkProps(url, hostname), { onClick: onClick, title: urlTitle }), insideClickableContent));
|
|
45
42
|
}
|
|
46
43
|
else if (onClick) {
|
|
47
|
-
content = (React.createElement("
|
|
44
|
+
content = (React.createElement("button", { className: b('link'), onClick: onClick, title: urlTitle }, insideClickableContent));
|
|
48
45
|
}
|
|
49
46
|
return (React.createElement(Fragment, null,
|
|
50
47
|
anchor && React.createElement(Anchor, { id: anchor, className: b('anchor') }),
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
2
|
-
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
3
|
-
// TODO fix in https://github.com/gravity-ui/page-constructor/issues/965
|
|
4
1
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
2
|
import { PlayFill } from '@gravity-ui/icons';
|
|
6
|
-
import { Icon } from '@gravity-ui/uikit';
|
|
3
|
+
import { Icon, useActionHandlers, useUniqId } from '@gravity-ui/uikit';
|
|
7
4
|
import debounce from 'lodash/debounce';
|
|
8
5
|
import { v4 as uuidv4 } from 'uuid';
|
|
9
6
|
import { useAnalytics } from '../../hooks/useAnalytics';
|
|
@@ -43,13 +40,14 @@ export function getHeight(width) {
|
|
|
43
40
|
return (width / 16) * 9;
|
|
44
41
|
}
|
|
45
42
|
const VideoBlock = (props) => {
|
|
46
|
-
const { stream, record, videoIframe, attributes, className, id, previewImg, playButton, height, fullscreen, analyticsEvents, autoplay, onImageLoad, } = props;
|
|
43
|
+
const { stream, record, videoIframe, attributes, className, id, previewImg, playButton, playButtonId, height, fullscreen, analyticsEvents, autoplay, onImageLoad, } = props;
|
|
47
44
|
const handleAnalytics = useAnalytics(DefaultEventNames.VideoPreview);
|
|
48
45
|
const src = videoIframe ? videoIframe : getYoutubeVideoSrc(stream, record);
|
|
49
46
|
const ref = useRef(null);
|
|
50
47
|
const [hidePreview, setHidePreview] = useState(false);
|
|
51
48
|
const [currentHeight, setCurrentHeight] = useState(height || undefined);
|
|
52
49
|
const fullId = useMemo(() => id || uuidv4(), [id]);
|
|
50
|
+
const buttonId = useUniqId();
|
|
53
51
|
const [isPlaying, setIsPlaying] = useState(!previewImg);
|
|
54
52
|
const iframeSrc = src && isPlaying
|
|
55
53
|
? `${src}?${getPageSearchParams(Object.assign(Object.assign({}, (attributes || {})), (previewImg || autoplay ? AUTOPLAY_ATTRIBUTES : NO_AUTOPLAY_ATTRIBUTES)))}`
|
|
@@ -59,6 +57,7 @@ const VideoBlock = (props) => {
|
|
|
59
57
|
setIsPlaying(true);
|
|
60
58
|
setTimeout(() => setHidePreview(true), AUTOPLAY_DELAY);
|
|
61
59
|
}, [handleAnalytics, analyticsEvents]);
|
|
60
|
+
const { onKeyDown: onPreviewKeyDown } = useActionHandlers(onPreviewClick);
|
|
62
61
|
useEffect(() => {
|
|
63
62
|
const updateSize = debounce(() => {
|
|
64
63
|
setCurrentHeight(ref.current ? Math.round(getHeight(ref.current.offsetWidth)) : undefined);
|
|
@@ -80,9 +79,9 @@ const VideoBlock = (props) => {
|
|
|
80
79
|
}
|
|
81
80
|
return (React.createElement("div", { className: b(null, className), style: { height: currentHeight }, ref: ref },
|
|
82
81
|
iframeContent,
|
|
83
|
-
previewImg && !hidePreview && !fullscreen && (React.createElement("div", { className: b('preview'), onClick: onPreviewClick },
|
|
82
|
+
previewImg && !hidePreview && !fullscreen && (React.createElement("div", { className: b('preview'), onClick: onPreviewClick, onKeyDown: onPreviewKeyDown, role: "button", tabIndex: 0, "aria-labelledby": playButton ? playButtonId : buttonId },
|
|
84
83
|
React.createElement(Image, { src: previewImg, className: b('image'), containerClassName: b('image-wrapper'), onLoad: onImageLoad }),
|
|
85
|
-
playButton || (React.createElement("button", { title: "Play", className: b('button') },
|
|
84
|
+
playButton || (React.createElement("button", { title: "Play", id: buttonId, className: b('button') },
|
|
86
85
|
React.createElement(Icon, { className: b('icon'), data: PlayFill, size: 24 })))))));
|
|
87
86
|
};
|
|
88
87
|
export default VideoBlock;
|
|
@@ -51,12 +51,22 @@ unpredictable css rules order in build */
|
|
|
51
51
|
overflow-y: auto;
|
|
52
52
|
}
|
|
53
53
|
.pc-add-block__popup .pc-add-block__block {
|
|
54
|
+
display: inline-block;
|
|
55
|
+
margin: 0;
|
|
56
|
+
padding: 0;
|
|
57
|
+
font: inherit;
|
|
58
|
+
border: none;
|
|
59
|
+
outline: none;
|
|
60
|
+
color: inherit;
|
|
61
|
+
background: none;
|
|
62
|
+
cursor: pointer;
|
|
54
63
|
display: flex;
|
|
55
64
|
justify-content: center;
|
|
56
65
|
align-items: center;
|
|
57
66
|
transition: transform 0.2s;
|
|
58
67
|
margin-top: 20px;
|
|
59
68
|
justify-content: flex-start;
|
|
69
|
+
text-align: start;
|
|
60
70
|
cursor: pointer;
|
|
61
71
|
}
|
|
62
72
|
.pc-add-block__popup .pc-add-block__block:hover {
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
2
|
-
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
3
|
-
// TODO fix in https://github.com/gravity-ui/page-constructor/issues/965
|
|
4
1
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
5
2
|
import { Plus } from '@gravity-ui/icons';
|
|
6
3
|
import { Popup, TextInput } from '@gravity-ui/uikit';
|
|
@@ -47,7 +44,7 @@ const AddBlock = ({ onAdd, className }) => {
|
|
|
47
44
|
return null;
|
|
48
45
|
}
|
|
49
46
|
const Preview = blockData.preview;
|
|
50
|
-
return (React.createElement("
|
|
47
|
+
return (React.createElement("button", { key: blockName, className: b('block'), onClick: () => {
|
|
51
48
|
onAdd(blockData === null || blockData === void 0 ? void 0 : blockData.template);
|
|
52
49
|
setIsOpened(false);
|
|
53
50
|
} },
|