@doyourjob/gravity-ui-page-constructor 5.31.131 → 5.31.133

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.
@@ -15,11 +15,11 @@ unpredictable css rules order in build */
15
15
  .pc-background-effect__right {
16
16
  position: absolute;
17
17
  inset: 0;
18
+ transition: clip-path 0.5s linear;
18
19
  clip-path: inset(0 0 0 99.99%);
19
- transition: clip-path 1.5s ease;
20
20
  }
21
21
  .pc-header-block:hover .pc-background-effect__right {
22
- clip-path: inset(0 0 0 0.01%);
22
+ transition: none;
23
23
  }
24
24
  .pc-background-effect__video {
25
25
  width: 100%;
@@ -1,6 +1,8 @@
1
+ import React from 'react';
1
2
  type BackgroundEffectProps = {
2
3
  firstSrc: string;
3
4
  secondSrc: string;
5
+ attachRef: React.RefObject<HTMLElement>;
4
6
  };
5
- export declare const BackgroundEffect: ({ firstSrc, secondSrc }: BackgroundEffectProps) => JSX.Element | null;
7
+ export declare const BackgroundEffect: ({ firstSrc, secondSrc, attachRef }: BackgroundEffectProps) => JSX.Element | null;
6
8
  export default BackgroundEffect;
@@ -10,9 +10,10 @@ const SYNC_THRESHOLD = 0.03;
10
10
  const MAX_DESYNC = 0.5;
11
11
  const FAST_RATE = 1.05;
12
12
  const SLOW_RATE = 0.95;
13
- const BackgroundEffect = ({ firstSrc, secondSrc }) => {
13
+ const BackgroundEffect = ({ firstSrc, secondSrc, attachRef }) => {
14
14
  const master = (0, react_1.useRef)(null);
15
15
  const driven = (0, react_1.useRef)(null);
16
+ const drivenWrap = (0, react_1.useRef)(null);
16
17
  (0, react_1.useEffect)(() => {
17
18
  const m = master.current;
18
19
  const d = driven.current;
@@ -55,9 +56,83 @@ const BackgroundEffect = ({ firstSrc, secondSrc }) => {
55
56
  }
56
57
  };
57
58
  }, []);
58
- if (!firstSrc || !secondSrc) {
59
+ (0, react_1.useEffect)(() => {
60
+ const el = attachRef.current;
61
+ if (!el)
62
+ return () => { };
63
+ const wrap = drivenWrap.current;
64
+ if (!wrap)
65
+ return () => { };
66
+ let target = 99.99;
67
+ let current = 99.99;
68
+ let locked = false;
69
+ let rafId = null;
70
+ const setClip = (value) => {
71
+ if (!wrap)
72
+ return;
73
+ wrap.style.setProperty('clip-path', `inset(0 0 0 ${value}%)`);
74
+ };
75
+ const update = () => {
76
+ if (!wrap)
77
+ return;
78
+ const diff = target - current;
79
+ if (Math.abs(diff) < 0.1) {
80
+ current = target;
81
+ setClip(current);
82
+ locked = true;
83
+ rafId = null;
84
+ return;
85
+ }
86
+ if (!locked) {
87
+ current += diff * 0.05;
88
+ setClip(current);
89
+ rafId = requestAnimationFrame(update);
90
+ }
91
+ };
92
+ const handleEnter = (e) => {
93
+ const rect = el.getBoundingClientRect();
94
+ const x = e.clientX - rect.left;
95
+ target = (x / rect.width) * 100;
96
+ locked = false;
97
+ if (rafId)
98
+ cancelAnimationFrame(rafId);
99
+ rafId = requestAnimationFrame(update);
100
+ };
101
+ const handleMove = (e) => {
102
+ const rect = el.getBoundingClientRect();
103
+ const x = e.clientX - rect.left;
104
+ target = (x / rect.width) * 100;
105
+ if (locked) {
106
+ current = target;
107
+ setClip(current);
108
+ return;
109
+ }
110
+ if (!rafId)
111
+ rafId = requestAnimationFrame(update);
112
+ };
113
+ const handleLeave = () => {
114
+ locked = false;
115
+ target = 99.99;
116
+ setClip(target);
117
+ current = target;
118
+ if (rafId) {
119
+ cancelAnimationFrame(rafId);
120
+ rafId = null;
121
+ }
122
+ };
123
+ el.addEventListener('mouseenter', handleEnter);
124
+ el.addEventListener('mousemove', handleMove);
125
+ el.addEventListener('mouseleave', handleLeave);
126
+ return () => {
127
+ el.removeEventListener('mouseenter', handleEnter);
128
+ el.removeEventListener('mousemove', handleMove);
129
+ el.removeEventListener('mouseleave', handleLeave);
130
+ if (rafId)
131
+ cancelAnimationFrame(rafId);
132
+ };
133
+ }, [attachRef]);
134
+ if (!firstSrc || !secondSrc)
59
135
  return null;
60
- }
61
136
  return (react_1.default.createElement("div", { className: b() },
62
137
  react_1.default.createElement("div", { className: b('left') },
63
138
  react_1.default.createElement("video", { ref: master, disablePictureInPicture: true, playsInline: true,
@@ -65,7 +140,7 @@ const BackgroundEffect = ({ firstSrc, secondSrc }) => {
65
140
  // eslint-disable-next-line react/no-unknown-property
66
141
  pip: "false", autoPlay: true, loop: true, preload: "auto", muted: true, className: b('video') },
67
142
  react_1.default.createElement("source", { src: firstSrc, type: (0, utils_1.parseVideoType)(firstSrc) }))),
68
- react_1.default.createElement("div", { className: b('right') },
143
+ react_1.default.createElement("div", { className: b('right'), ref: drivenWrap },
69
144
  react_1.default.createElement("video", { ref: driven, disablePictureInPicture: true, playsInline: true,
70
145
  // @ts-ignore
71
146
  // eslint-disable-next-line react/no-unknown-property
@@ -44,7 +44,8 @@ const HeaderBlock = (props) => {
44
44
  const videoThemed = (0, react_1.useMemo)(() => video && (0, utils_2.getThemedValue)(video, theme), [theme, video]);
45
45
  const fullWidth = (backgroundThemed === null || backgroundThemed === void 0 ? void 0 : backgroundThemed.fullWidth) || (backgroundThemed === null || backgroundThemed === void 0 ? void 0 : backgroundThemed.fullWidthMedia);
46
46
  const titleId = (0, uikit_1.useUniqId)();
47
- return (react_1.default.createElement("header", { className: b({
47
+ const headerRef = (0, react_1.useRef)(null);
48
+ return (react_1.default.createElement("header", { ref: headerRef, className: b({
48
49
  ['has-media']: hasRightSideImage,
49
50
  ['full-width']: fullWidth,
50
51
  ['media-view']: mediaView,
@@ -53,7 +54,7 @@ const HeaderBlock = (props) => {
53
54
  }, className) },
54
55
  backgroundThemed && fullWidth && react_1.default.createElement(FullWidthBackground, { background: backgroundThemed }),
55
56
  backgroundThemed && react_1.default.createElement(Background, { background: backgroundThemed, isMobile: isMobile }),
56
- backgroundEffect && backgroundEffect.firstSrc && backgroundEffect.secondSrc && (react_1.default.createElement(BackgroundEffect_1.default, Object.assign({}, backgroundEffect))),
57
+ backgroundEffect && backgroundEffect.firstSrc && backgroundEffect.secondSrc && (react_1.default.createElement(BackgroundEffect_1.default, Object.assign({}, backgroundEffect, { attachRef: headerRef }))),
57
58
  react_1.default.createElement(grid_1.Grid, { containerClass: b('container-fluid') },
58
59
  react_1.default.createElement(Breadcrumbs_1.default, { breadcrumbs: breadcrumbs, theme: textTheme }),
59
60
  react_1.default.createElement(BackButton_1.default, { backButton: verticalOffset !== '0' && !breadcrumbs ? backButton : undefined, theme: textTheme }),
@@ -1,17 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const react_1 = tslib_1.__importDefault(require("react"));
4
+ const react_1 = tslib_1.__importStar(require("react"));
5
5
  const grid_1 = require("../../grid");
6
6
  const utils_1 = require("../../utils");
7
7
  const Anchor_1 = tslib_1.__importDefault(require("../Anchor/Anchor"));
8
8
  const b = (0, utils_1.block)('block-base');
9
9
  const BlockBase = (props) => {
10
- const { anchor, visibility, indent, backgroundFull, visible, hidden, children, className, resetPaddings, qa, } = props;
10
+ const { anchor, visibility, indent, backgroundFull, selectionColor, visible, hidden, children, className, resetPaddings, qa, } = props;
11
11
  const { top, bottom } = indent || (resetPaddings ? { top: '0', bottom: '0' } : { top: 'l', bottom: 'l' });
12
12
  const isBackgroundUrl = /^https?:\/\/[^\s/$.?#].[^\s]*$/i.test(backgroundFull || '');
13
13
  const visibilityClasses = (0, utils_1.getBlockVisibilityClasses)(visibility);
14
- return (react_1.default.createElement(grid_1.Col, { className: b(Object.assign({ ['reset-paddings']: resetPaddings, indentTop: top, indentBottom: bottom }, visibilityClasses), className), hidden: hidden, visible: visible, reset: true, qa: qa },
14
+ const rootStyle = (0, react_1.useMemo)(() => selectionColor ? { ['--selection-bg']: selectionColor } : undefined, [selectionColor]);
15
+ return (react_1.default.createElement(grid_1.Col, { className: b(Object.assign({ ['reset-paddings']: resetPaddings, indentTop: top, indentBottom: bottom }, visibilityClasses), className), style: rootStyle, hidden: hidden, visible: visible, reset: true, qa: qa },
15
16
  anchor && react_1.default.createElement(Anchor_1.default, { id: anchor.url, className: b('anchor') }),
16
17
  backgroundFull && (react_1.default.createElement("div", { className: b('background-full', { top }), style: isBackgroundUrl
17
18
  ? { backgroundImage: `url(${backgroundFull})` }
@@ -18,6 +18,7 @@ const ConstructorBlock = ({ index = 0, data, children, }) => {
18
18
  'resetPaddings',
19
19
  'indent',
20
20
  'backgroundFull',
21
+ 'selectionColor',
21
22
  ]), [data]);
22
23
  return (react_1.default.createElement(BlockDecoration_1.BlockDecoration, Object.assign({ type: type, index: index }, blockBaseProps),
23
24
  react_1.default.createElement(BlockBase_1.default, Object.assign({ className: b({ type }) }, blockBaseProps), children)));
@@ -72,6 +72,7 @@ export interface BlockBaseProps {
72
72
  bottom?: IndentValue;
73
73
  };
74
74
  backgroundFull?: string;
75
+ selectionColor?: string;
75
76
  blockBackground?: BlockBackgroundType;
76
77
  className?: string;
77
78
  qa?: string;
@@ -15,11 +15,11 @@ unpredictable css rules order in build */
15
15
  .pc-background-effect__right {
16
16
  position: absolute;
17
17
  inset: 0;
18
+ transition: clip-path 0.5s linear;
18
19
  clip-path: inset(0 0 0 99.99%);
19
- transition: clip-path 1.5s ease;
20
20
  }
21
21
  .pc-header-block:hover .pc-background-effect__right {
22
- clip-path: inset(0 0 0 0.01%);
22
+ transition: none;
23
23
  }
24
24
  .pc-background-effect__video {
25
25
  width: 100%;
@@ -1,7 +1,9 @@
1
+ import React from 'react';
1
2
  import './BackgroundEffect.css';
2
3
  type BackgroundEffectProps = {
3
4
  firstSrc: string;
4
5
  secondSrc: string;
6
+ attachRef: React.RefObject<HTMLElement>;
5
7
  };
6
- export declare const BackgroundEffect: ({ firstSrc, secondSrc }: BackgroundEffectProps) => JSX.Element | null;
8
+ export declare const BackgroundEffect: ({ firstSrc, secondSrc, attachRef }: BackgroundEffectProps) => JSX.Element | null;
7
9
  export default BackgroundEffect;
@@ -7,9 +7,10 @@ const SYNC_THRESHOLD = 0.03;
7
7
  const MAX_DESYNC = 0.5;
8
8
  const FAST_RATE = 1.05;
9
9
  const SLOW_RATE = 0.95;
10
- export const BackgroundEffect = ({ firstSrc, secondSrc }) => {
10
+ export const BackgroundEffect = ({ firstSrc, secondSrc, attachRef }) => {
11
11
  const master = useRef(null);
12
12
  const driven = useRef(null);
13
+ const drivenWrap = useRef(null);
13
14
  useEffect(() => {
14
15
  const m = master.current;
15
16
  const d = driven.current;
@@ -52,9 +53,83 @@ export const BackgroundEffect = ({ firstSrc, secondSrc }) => {
52
53
  }
53
54
  };
54
55
  }, []);
55
- if (!firstSrc || !secondSrc) {
56
+ useEffect(() => {
57
+ const el = attachRef.current;
58
+ if (!el)
59
+ return () => { };
60
+ const wrap = drivenWrap.current;
61
+ if (!wrap)
62
+ return () => { };
63
+ let target = 99.99;
64
+ let current = 99.99;
65
+ let locked = false;
66
+ let rafId = null;
67
+ const setClip = (value) => {
68
+ if (!wrap)
69
+ return;
70
+ wrap.style.setProperty('clip-path', `inset(0 0 0 ${value}%)`);
71
+ };
72
+ const update = () => {
73
+ if (!wrap)
74
+ return;
75
+ const diff = target - current;
76
+ if (Math.abs(diff) < 0.1) {
77
+ current = target;
78
+ setClip(current);
79
+ locked = true;
80
+ rafId = null;
81
+ return;
82
+ }
83
+ if (!locked) {
84
+ current += diff * 0.05;
85
+ setClip(current);
86
+ rafId = requestAnimationFrame(update);
87
+ }
88
+ };
89
+ const handleEnter = (e) => {
90
+ const rect = el.getBoundingClientRect();
91
+ const x = e.clientX - rect.left;
92
+ target = (x / rect.width) * 100;
93
+ locked = false;
94
+ if (rafId)
95
+ cancelAnimationFrame(rafId);
96
+ rafId = requestAnimationFrame(update);
97
+ };
98
+ const handleMove = (e) => {
99
+ const rect = el.getBoundingClientRect();
100
+ const x = e.clientX - rect.left;
101
+ target = (x / rect.width) * 100;
102
+ if (locked) {
103
+ current = target;
104
+ setClip(current);
105
+ return;
106
+ }
107
+ if (!rafId)
108
+ rafId = requestAnimationFrame(update);
109
+ };
110
+ const handleLeave = () => {
111
+ locked = false;
112
+ target = 99.99;
113
+ setClip(target);
114
+ current = target;
115
+ if (rafId) {
116
+ cancelAnimationFrame(rafId);
117
+ rafId = null;
118
+ }
119
+ };
120
+ el.addEventListener('mouseenter', handleEnter);
121
+ el.addEventListener('mousemove', handleMove);
122
+ el.addEventListener('mouseleave', handleLeave);
123
+ return () => {
124
+ el.removeEventListener('mouseenter', handleEnter);
125
+ el.removeEventListener('mousemove', handleMove);
126
+ el.removeEventListener('mouseleave', handleLeave);
127
+ if (rafId)
128
+ cancelAnimationFrame(rafId);
129
+ };
130
+ }, [attachRef]);
131
+ if (!firstSrc || !secondSrc)
56
132
  return null;
57
- }
58
133
  return (React.createElement("div", { className: b() },
59
134
  React.createElement("div", { className: b('left') },
60
135
  React.createElement("video", { ref: master, disablePictureInPicture: true, playsInline: true,
@@ -62,7 +137,7 @@ export const BackgroundEffect = ({ firstSrc, secondSrc }) => {
62
137
  // eslint-disable-next-line react/no-unknown-property
63
138
  pip: "false", autoPlay: true, loop: true, preload: "auto", muted: true, className: b('video') },
64
139
  React.createElement("source", { src: firstSrc, type: parseVideoType(firstSrc) }))),
65
- React.createElement("div", { className: b('right') },
140
+ React.createElement("div", { className: b('right'), ref: drivenWrap },
66
141
  React.createElement("video", { ref: driven, disablePictureInPicture: true, playsInline: true,
67
142
  // @ts-ignore
68
143
  // eslint-disable-next-line react/no-unknown-property
@@ -1,4 +1,4 @@
1
- import React, { useContext, useMemo } from 'react';
1
+ import React, { useContext, useMemo, useRef } from 'react';
2
2
  import { useUniqId } from '@gravity-ui/uikit';
3
3
  import { HTML, Media } from '../../components';
4
4
  import { getMediaImage } from '../../components/Media/Image/utils';
@@ -41,7 +41,8 @@ export const HeaderBlock = (props) => {
41
41
  const videoThemed = useMemo(() => video && getThemedValue(video, theme), [theme, video]);
42
42
  const fullWidth = (backgroundThemed === null || backgroundThemed === void 0 ? void 0 : backgroundThemed.fullWidth) || (backgroundThemed === null || backgroundThemed === void 0 ? void 0 : backgroundThemed.fullWidthMedia);
43
43
  const titleId = useUniqId();
44
- return (React.createElement("header", { className: b({
44
+ const headerRef = useRef(null);
45
+ return (React.createElement("header", { ref: headerRef, className: b({
45
46
  ['has-media']: hasRightSideImage,
46
47
  ['full-width']: fullWidth,
47
48
  ['media-view']: mediaView,
@@ -50,7 +51,7 @@ export const HeaderBlock = (props) => {
50
51
  }, className) },
51
52
  backgroundThemed && fullWidth && React.createElement(FullWidthBackground, { background: backgroundThemed }),
52
53
  backgroundThemed && React.createElement(Background, { background: backgroundThemed, isMobile: isMobile }),
53
- backgroundEffect && backgroundEffect.firstSrc && backgroundEffect.secondSrc && (React.createElement(BackgroundEffect, Object.assign({}, backgroundEffect))),
54
+ backgroundEffect && backgroundEffect.firstSrc && backgroundEffect.secondSrc && (React.createElement(BackgroundEffect, Object.assign({}, backgroundEffect, { attachRef: headerRef }))),
54
55
  React.createElement(Grid, { containerClass: b('container-fluid') },
55
56
  React.createElement(Breadcrumbs, { breadcrumbs: breadcrumbs, theme: textTheme }),
56
57
  React.createElement(BackButton, { backButton: verticalOffset !== '0' && !breadcrumbs ? backButton : undefined, theme: textTheme }),
@@ -1,15 +1,16 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import { Col } from '../../grid';
3
3
  import { block, getBlockVisibilityClasses } from '../../utils';
4
4
  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, visibility, indent, backgroundFull, visible, hidden, children, className, resetPaddings, qa, } = props;
8
+ const { anchor, visibility, indent, backgroundFull, selectionColor, visible, hidden, children, className, resetPaddings, qa, } = props;
9
9
  const { top, bottom } = indent || (resetPaddings ? { top: '0', bottom: '0' } : { top: 'l', bottom: 'l' });
10
10
  const isBackgroundUrl = /^https?:\/\/[^\s/$.?#].[^\s]*$/i.test(backgroundFull || '');
11
11
  const visibilityClasses = getBlockVisibilityClasses(visibility);
12
- return (React.createElement(Col, { className: b(Object.assign({ ['reset-paddings']: resetPaddings, indentTop: top, indentBottom: bottom }, visibilityClasses), className), hidden: hidden, visible: visible, reset: true, qa: qa },
12
+ const rootStyle = useMemo(() => selectionColor ? { ['--selection-bg']: selectionColor } : undefined, [selectionColor]);
13
+ return (React.createElement(Col, { className: b(Object.assign({ ['reset-paddings']: resetPaddings, indentTop: top, indentBottom: bottom }, visibilityClasses), className), style: rootStyle, hidden: hidden, visible: visible, reset: true, qa: qa },
13
14
  anchor && React.createElement(Anchor, { id: anchor.url, className: b('anchor') }),
14
15
  backgroundFull && (React.createElement("div", { className: b('background-full', { top }), style: isBackgroundUrl
15
16
  ? { backgroundImage: `url(${backgroundFull})` }
@@ -15,6 +15,7 @@ export const ConstructorBlock = ({ index = 0, data, children, }) => {
15
15
  'resetPaddings',
16
16
  'indent',
17
17
  'backgroundFull',
18
+ 'selectionColor',
18
19
  ]), [data]);
19
20
  return (React.createElement(BlockDecoration, Object.assign({ type: type, index: index }, blockBaseProps),
20
21
  React.createElement(BlockBase, Object.assign({ className: b({ type }) }, blockBaseProps), children)));
@@ -72,6 +72,7 @@ export interface BlockBaseProps {
72
72
  bottom?: IndentValue;
73
73
  };
74
74
  backgroundFull?: string;
75
+ selectionColor?: string;
75
76
  blockBackground?: BlockBackgroundType;
76
77
  className?: string;
77
78
  qa?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doyourjob/gravity-ui-page-constructor",
3
- "version": "5.31.131",
3
+ "version": "5.31.133",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -72,6 +72,7 @@ export interface BlockBaseProps {
72
72
  bottom?: IndentValue;
73
73
  };
74
74
  backgroundFull?: string;
75
+ selectionColor?: string;
75
76
  blockBackground?: BlockBackgroundType;
76
77
  className?: string;
77
78
  qa?: string;