@cntrl-site/sdk-nextjs 1.8.40 → 1.9.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/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/modules.xml +8 -0
- package/.idea/sdk-nextjs.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/lib/components/items/FileItem/ImageItem.js +49 -22
- package/lib/components/items/FileItem/VideoItem.js +48 -21
- package/lib/components/items/FileItem/useFileItem.js +12 -5
- package/lib/components/items/RectangleItem/RectangleItem.js +78 -22
- package/lib/components/items/RectangleItem/useRectangleItem.js +15 -8
- package/lib/interactions/CSSPropertyNameMap.js +18 -18
- package/lib/utils/Animator/Animator.js +171 -19
- package/lib/utils/areFillsVisible/areFillsVisible.js +23 -0
- package/lib/utils/getFill.js +43 -0
- package/package.json +2 -2
- package/src/components/items/CodeEmbedItem/CodeEmbedItem.tsx +1 -1
- package/src/components/items/ComponentItem/ComponentItem.tsx +1 -1
- package/src/components/items/CompoundItem/CompoundChild.tsx +2 -2
- package/src/components/items/CompoundItem/CompoundItem.tsx +1 -1
- package/src/components/items/CustomItem/CustomItem.tsx +1 -1
- package/src/components/items/EmbedVideoItem/VimeoEmbed.tsx +2 -2
- package/src/components/items/EmbedVideoItem/YoutubeEmbed.tsx +2 -2
- package/src/components/items/FileItem/ImageItem.tsx +63 -10
- package/src/components/items/FileItem/VideoItem.tsx +64 -11
- package/src/components/items/FileItem/useFileItem.ts +14 -6
- package/src/components/items/GroupItem/GroupItem.tsx +1 -1
- package/src/components/items/Item.tsx +2 -2
- package/src/components/items/RectangleItem/RectangleItem.tsx +126 -24
- package/src/components/items/RectangleItem/useRectangleItem.ts +17 -10
- package/src/components/items/RichTextItem/RichTextItem.tsx +5 -5
- package/src/interactions/CSSPropertyNameMap.ts +18 -19
- package/src/interactions/ItemInteractionCtrl.ts +4 -4
- package/src/interactions/types.ts +7 -7
- package/src/utils/Animator/Animator.ts +227 -27
- package/src/utils/areFillsVisible/areFillsVisible.test.ts +63 -0
- package/src/utils/areFillsVisible/areFillsVisible.ts +37 -0
- package/src/utils/getFill.ts +46 -0
- package/src/utils/getStyleFromItemStateAndParams.ts +2 -2
- package/src/provider/InteractionsContext.old.tsx +0 -66
- package/src/provider/InteractionsContext.test.tsx +0 -97
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/sdk-nextjs.iml" filepath="$PROJECT_DIR$/.idea/sdk-nextjs.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
+
</content>
|
|
9
|
+
<orderEntry type="inheritedJdk" />
|
|
10
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
+
</component>
|
|
12
|
+
</module>
|
package/.idea/vcs.xml
ADDED
|
@@ -7,7 +7,6 @@ exports.ImageItem = void 0;
|
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
10
|
-
const color_1 = require("@cntrl-site/color");
|
|
11
10
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
12
11
|
const LinkWrapper_1 = require("../LinkWrapper");
|
|
13
12
|
const useFileItem_1 = require("./useFileItem");
|
|
@@ -19,12 +18,13 @@ const useElementRect_1 = require("../../../utils/useElementRect");
|
|
|
19
18
|
const useLayoutContext_1 = require("../../useLayoutContext");
|
|
20
19
|
const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromItemStateAndParams");
|
|
21
20
|
const useItemFXData_1 = require("../../../common/useItemFXData");
|
|
21
|
+
const getFill_1 = require("../../../utils/getFill");
|
|
22
22
|
const ImageItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
23
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
23
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
24
24
|
const id = (0, react_1.useId)();
|
|
25
25
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
26
26
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
27
|
-
const { radius: itemRadius, strokeWidth: itemStrokeWidth, opacity: itemOpacity,
|
|
27
|
+
const { radius: itemRadius, strokeWidth: itemStrokeWidth, opacity: itemOpacity, strokeFill: itemStrokeFill, blur: itemBlur } = (0, useFileItem_1.useFileItem)(item, sectionId);
|
|
28
28
|
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
29
29
|
const [wrapperRef, setWrapperRef] = (0, react_1.useState)(null);
|
|
30
30
|
(0, useRegisterResize_1.useRegisterResize)(wrapperRef, onResize);
|
|
@@ -38,7 +38,10 @@ const ImageItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
38
38
|
const width = area && exemplary ? area.width * exemplary : 0;
|
|
39
39
|
const height = area && exemplary ? area.height * exemplary : 0;
|
|
40
40
|
const wrapperStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['angle', 'opacity', 'blur']);
|
|
41
|
-
const imgStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['strokeWidth', 'radius'
|
|
41
|
+
const imgStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['strokeWidth', 'radius']);
|
|
42
|
+
const stateStrokeFillParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['strokeFill']);
|
|
43
|
+
const stateStrokeFillLayers = (_b = stateStrokeFillParams === null || stateStrokeFillParams === void 0 ? void 0 : stateStrokeFillParams.styles) === null || _b === void 0 ? void 0 : _b.strokeFill;
|
|
44
|
+
const strokeSolidTransition = (_c = stateStrokeFillParams === null || stateStrokeFillParams === void 0 ? void 0 : stateStrokeFillParams.transition) !== null && _c !== void 0 ? _c : 'none';
|
|
42
45
|
(0, react_1.useEffect)(() => {
|
|
43
46
|
isInitialRef.current = false;
|
|
44
47
|
}, []);
|
|
@@ -48,26 +51,37 @@ const ImageItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
48
51
|
controlsValues
|
|
49
52
|
}, width, height);
|
|
50
53
|
const rect = (0, useElementRect_1.useElementRect)(wrapperRef);
|
|
51
|
-
const rectWidth = Math.floor((
|
|
52
|
-
const rectHeight = Math.floor((
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
54
|
+
const rectWidth = Math.floor((_d = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _d !== void 0 ? _d : 0);
|
|
55
|
+
const rectHeight = Math.floor((_e = rect === null || rect === void 0 ? void 0 : rect.height) !== null && _e !== void 0 ? _e : 0);
|
|
56
|
+
const radius = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_f = imgStateParams === null || imgStateParams === void 0 ? void 0 : imgStateParams.styles) === null || _f === void 0 ? void 0 : _f.radius, itemRadius);
|
|
57
|
+
const strokeWidth = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_g = imgStateParams === null || imgStateParams === void 0 ? void 0 : imgStateParams.styles) === null || _g === void 0 ? void 0 : _g.strokeWidth, itemStrokeWidth);
|
|
58
|
+
const angle = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_h = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _h === void 0 ? void 0 : _h.angle, itemAngle);
|
|
59
|
+
const opacity = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_j = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _j === void 0 ? void 0 : _j.opacity, itemOpacity);
|
|
60
|
+
const blur = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_k = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _k === void 0 ? void 0 : _k.blur, itemBlur);
|
|
61
|
+
const strokeValue = stateStrokeFillLayers
|
|
62
|
+
? (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(stateStrokeFillLayers[0], itemStrokeFill === null || itemStrokeFill === void 0 ? void 0 : itemStrokeFill[0])
|
|
63
|
+
: itemStrokeFill === null || itemStrokeFill === void 0 ? void 0 : itemStrokeFill[0];
|
|
64
|
+
const stroke = strokeValue
|
|
65
|
+
? (_l = (0, getFill_1.getFill)(strokeValue)) !== null && _l !== void 0 ? _l : 'transparent'
|
|
66
|
+
: 'transparent';
|
|
67
|
+
const inlineStyles = Object.assign(Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), (strokeWidth !== undefined ? { borderWidth: `${strokeWidth * 100}vw` } : {})), { transition: (_m = imgStateParams === null || imgStateParams === void 0 ? void 0 : imgStateParams.transition) !== null && _m !== void 0 ? _m : 'none' });
|
|
64
68
|
const isInteractive = opacity !== 0;
|
|
65
69
|
(0, react_1.useEffect)(() => {
|
|
66
70
|
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
67
71
|
}, [isInteractive, onVisibilityChange]);
|
|
68
|
-
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (
|
|
69
|
-
|
|
70
|
-
:
|
|
72
|
+
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_o = item.link) === null || _o === void 0 ? void 0 : _o.url, target: (_p = item.link) === null || _p === void 0 ? void 0 : _p.target, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: `image-wrapper-${item.id}`, ref: setWrapperRef, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), (strokeValue ? Object.assign({ '--stroke-background': stroke }, (strokeValue.type === 'image' ? {
|
|
73
|
+
'--stroke-background-position': 'center',
|
|
74
|
+
'--stroke-background-size': strokeValue.behavior === 'repeat' ? `${strokeValue.backgroundSize}%` : strokeValue.behavior,
|
|
75
|
+
'--stroke-background-repeat': strokeValue.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
76
|
+
} : {})) : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_q = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _q !== void 0 ? _q : 'none' }), children: [hasGLEffect && isFXAllowed
|
|
77
|
+
? ((0, jsx_runtime_1.jsx)("canvas", { style: inlineStyles, ref: fxCanvas, className: `img-canvas image-${item.id}`, width: rectWidth, height: rectHeight }))
|
|
78
|
+
: ((0, jsx_runtime_1.jsx)("img", { alt: "", className: `image image-${item.id}`, style: inlineStyles, src: item.commonParams.url })), (0, jsx_runtime_1.jsx)("div", { className: `image-border-${item.id}`, style: Object.assign({ position: 'absolute', inset: 0, borderRadius: 'inherit', pointerEvents: 'none', zIndex: 2, WebkitMask: 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)', WebkitMaskComposite: 'xor', maskComposite: 'exclude' }, (strokeWidth !== 0 && strokeValue ? Object.assign(Object.assign(Object.assign({}, (strokeWidth ? { padding: `${strokeWidth * 100}vw` } : {})), (strokeValue.type === 'solid' ? { transition: strokeSolidTransition, background: stroke } : {})), (strokeValue.type === 'image' ? {
|
|
79
|
+
backgroundPosition: 'center',
|
|
80
|
+
backgroundSize: strokeValue.behavior === 'repeat' ? `${strokeValue.backgroundSize}%` : strokeValue.behavior,
|
|
81
|
+
backgroundRepeat: strokeValue.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
82
|
+
} : {
|
|
83
|
+
background: stroke,
|
|
84
|
+
})) : { background: stroke })) })] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
71
85
|
.image-wrapper-${item.id} {
|
|
72
86
|
position: absolute;
|
|
73
87
|
width: 100%;
|
|
@@ -102,9 +116,22 @@ const ImageItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
102
116
|
${layoutParams.blur !== 0 ? 'will-change: transform;' : ''}
|
|
103
117
|
}
|
|
104
118
|
.image-${item.id} {
|
|
105
|
-
border
|
|
106
|
-
border-
|
|
119
|
+
border: solid;
|
|
120
|
+
border-color: transparent;
|
|
107
121
|
border-width: ${layoutParams.strokeWidth * 100}vw;
|
|
122
|
+
border-radius: ${layoutParams.radius * 100}vw;
|
|
123
|
+
}
|
|
124
|
+
.image-border-${item.id} {
|
|
125
|
+
position: absolute;
|
|
126
|
+
inset: 0;
|
|
127
|
+
border-radius: inherit;
|
|
128
|
+
pointer-events: none;
|
|
129
|
+
z-index: 2;
|
|
130
|
+
-webkit-mask:
|
|
131
|
+
linear-gradient(#fff 0 0) content-box,
|
|
132
|
+
linear-gradient(#fff 0 0);
|
|
133
|
+
-webkit-mask-composite: xor;
|
|
134
|
+
mask-composite: exclude;
|
|
108
135
|
}
|
|
109
136
|
`);
|
|
110
137
|
})}
|
|
@@ -7,7 +7,6 @@ exports.VideoItem = void 0;
|
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
10
|
-
const color_1 = require("@cntrl-site/color");
|
|
11
10
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
12
11
|
const LinkWrapper_1 = require("../LinkWrapper");
|
|
13
12
|
const useFileItem_1 = require("./useFileItem");
|
|
@@ -20,12 +19,13 @@ const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromIte
|
|
|
20
19
|
const useVideoFx_1 = require("../../../utils/effects/useVideoFx");
|
|
21
20
|
const useElementRect_1 = require("../../../utils/useElementRect");
|
|
22
21
|
const useItemFXData_1 = require("../../../common/useItemFXData");
|
|
22
|
+
const getFill_1 = require("../../../utils/getFill");
|
|
23
23
|
const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
24
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
24
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
25
25
|
const id = (0, react_1.useId)();
|
|
26
26
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
27
27
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
28
|
-
const { radius: itemRadius, strokeWidth: itemStrokeWidth,
|
|
28
|
+
const { radius: itemRadius, strokeWidth: itemStrokeWidth, strokeFill: itemStrokeFill, opacity: itemOpacity, blur: itemBlur } = (0, useFileItem_1.useFileItem)(item, sectionId);
|
|
29
29
|
const [isVideoPlaying, setIsVideoPlaying] = (0, react_1.useState)(false);
|
|
30
30
|
const isScrollPausedRef = (0, react_1.useRef)(false);
|
|
31
31
|
const [userPaused, setUserPaused] = (0, react_1.useState)(false);
|
|
@@ -49,17 +49,21 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
49
49
|
const layoutValues = [item.area, item.layoutParams];
|
|
50
50
|
const hasScrollPlayback = scrollPlayback !== null;
|
|
51
51
|
const wrapperStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['angle', 'opacity', 'blur']);
|
|
52
|
-
const videoStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['strokeWidth', 'radius'
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
|
|
52
|
+
const videoStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['strokeWidth', 'radius']);
|
|
53
|
+
const stateStrokeFillParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['strokeFill']);
|
|
54
|
+
const stateStrokeFillLayers = (_d = stateStrokeFillParams === null || stateStrokeFillParams === void 0 ? void 0 : stateStrokeFillParams.styles) === null || _d === void 0 ? void 0 : _d.strokeFill;
|
|
55
|
+
const strokeSolidTransition = (_e = stateStrokeFillParams === null || stateStrokeFillParams === void 0 ? void 0 : stateStrokeFillParams.transition) !== null && _e !== void 0 ? _e : 'none';
|
|
56
|
+
const angle = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_f = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _f === void 0 ? void 0 : _f.angle, itemAngle);
|
|
57
|
+
const opacity = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_g = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _g === void 0 ? void 0 : _g.opacity, itemOpacity);
|
|
58
|
+
const blur = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_h = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _h === void 0 ? void 0 : _h.blur, itemBlur);
|
|
59
|
+
const strokeWidth = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_j = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _j === void 0 ? void 0 : _j.strokeWidth, itemStrokeWidth);
|
|
60
|
+
const radius = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_k = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _k === void 0 ? void 0 : _k.radius, itemRadius);
|
|
61
|
+
const strokeValue = stateStrokeFillLayers
|
|
62
|
+
? (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(stateStrokeFillLayers[0], itemStrokeFill === null || itemStrokeFill === void 0 ? void 0 : itemStrokeFill[0])
|
|
63
|
+
: itemStrokeFill === null || itemStrokeFill === void 0 ? void 0 : itemStrokeFill[0];
|
|
64
|
+
const stroke = strokeValue
|
|
65
|
+
? (_l = (0, getFill_1.getFill)(strokeValue)) !== null && _l !== void 0 ? _l : 'transparent'
|
|
66
|
+
: 'transparent';
|
|
63
67
|
(0, react_1.useEffect)(() => {
|
|
64
68
|
isInitialRef.current = false;
|
|
65
69
|
}, []);
|
|
@@ -69,7 +73,7 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
69
73
|
controls: controlsValues
|
|
70
74
|
}, width, height);
|
|
71
75
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
72
|
-
const inlineStyles = Object.assign(Object.assign(Object.assign(
|
|
76
|
+
const inlineStyles = Object.assign(Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), (strokeWidth !== undefined ? { borderWidth: `${strokeWidth * 100}vw` } : {})), { transition: (_m = videoStateParams === null || videoStateParams === void 0 ? void 0 : videoStateParams.transition) !== null && _m !== void 0 ? _m : 'none' });
|
|
73
77
|
const isInteractive = opacity !== 0;
|
|
74
78
|
(0, react_1.useEffect)(() => {
|
|
75
79
|
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
@@ -92,7 +96,11 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
92
96
|
observer.observe(ref);
|
|
93
97
|
return () => observer.disconnect();
|
|
94
98
|
}, [layoutParams, videoRef, ref, userPaused, isVideoInteracted]);
|
|
95
|
-
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (
|
|
99
|
+
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_o = item.link) === null || _o === void 0 ? void 0 : _o.url, target: (_p = item.link) === null || _p === void 0 ? void 0 : _p.target, children: [(0, jsx_runtime_1.jsxs)("div", { className: `video-wrapper-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), (strokeValue ? Object.assign({ '--stroke-background': stroke }, (strokeValue.type === 'image' ? {
|
|
100
|
+
'--stroke-background-position': 'center',
|
|
101
|
+
'--stroke-background-size': strokeValue.behavior === 'repeat' ? `${strokeValue.backgroundSize}%` : strokeValue.behavior,
|
|
102
|
+
'--stroke-background-repeat': strokeValue.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
103
|
+
} : {})) : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_q = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _q !== void 0 ? _q : 'none' }), children: [hasScrollPlayback && ((0, jsx_runtime_1.jsx)(ScrollPlaybackVideo_1.ScrollPlaybackVideo, { sectionId: sectionId, src: item.commonParams.url, playbackParams: scrollPlayback, style: inlineStyles, className: `video video-playback-wrapper video-${item.id}` })), hasGLEffect && isFXAllowed && ((0, jsx_runtime_1.jsx)("canvas", { style: inlineStyles, ref: fxCanvas, className: `video-canvas video-${item.id}`, width: rectWidth, height: rectHeight })), !hasScrollPlayback && !hasGLEffect && layoutParams && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("video", { poster: (_r = item.commonParams.coverUrl) !== null && _r !== void 0 ? _r : '', ref: setVideoRef, autoPlay: layoutParams.play === 'auto', preload: "auto", onClick: () => {
|
|
96
104
|
setIsVideoInteracted(true);
|
|
97
105
|
}, muted: layoutParams.muted, onPlay: () => {
|
|
98
106
|
setIsVideoPlaying(true);
|
|
@@ -115,7 +123,7 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
115
123
|
return;
|
|
116
124
|
setIsVideoInteracted(true);
|
|
117
125
|
videoRef.play();
|
|
118
|
-
}, src: (
|
|
126
|
+
}, src: (_s = item.commonParams.coverUrl) !== null && _s !== void 0 ? _s : '', className: `video-cover-${item.id}`, onClick: () => {
|
|
119
127
|
if (!videoRef)
|
|
120
128
|
return;
|
|
121
129
|
setIsVideoInteracted(true);
|
|
@@ -130,7 +138,13 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
130
138
|
else {
|
|
131
139
|
videoRef.play();
|
|
132
140
|
}
|
|
133
|
-
} })))] }))
|
|
141
|
+
} })))] })), (0, jsx_runtime_1.jsx)("div", { className: `video-border-${item.id}`, style: Object.assign({ position: 'absolute', inset: 0, borderRadius: 'inherit', pointerEvents: 'none', zIndex: 2, WebkitMask: 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)', WebkitMaskComposite: 'xor', maskComposite: 'exclude' }, (strokeWidth !== 0 && strokeValue ? Object.assign(Object.assign(Object.assign({}, (strokeWidth ? { padding: `${strokeWidth * 100}vw` } : {})), (strokeValue.type === 'solid' ? { transition: strokeSolidTransition, background: stroke } : {})), (strokeValue.type === 'image' ? {
|
|
142
|
+
backgroundPosition: 'center',
|
|
143
|
+
backgroundSize: strokeValue.behavior === 'repeat' ? `${strokeValue.backgroundSize}%` : strokeValue.behavior,
|
|
144
|
+
backgroundRepeat: strokeValue.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
145
|
+
} : {
|
|
146
|
+
background: stroke,
|
|
147
|
+
})) : { background: stroke })) })] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
134
148
|
.video-wrapper-${item.id} {
|
|
135
149
|
position: absolute;
|
|
136
150
|
overflow: hidden;
|
|
@@ -166,7 +180,7 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
166
180
|
border-style: solid;
|
|
167
181
|
}
|
|
168
182
|
.video-${item.id} {
|
|
169
|
-
border-
|
|
183
|
+
border-radius: ${radius !== undefined ? `${radius * 100}vw` : '0'};
|
|
170
184
|
}
|
|
171
185
|
.video-playback-wrapper {
|
|
172
186
|
display: flex;
|
|
@@ -189,9 +203,22 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
189
203
|
${layoutParams.blur !== 0 ? 'will-change: transform;' : ''}
|
|
190
204
|
}
|
|
191
205
|
.video-${item.id} {
|
|
192
|
-
border
|
|
193
|
-
border-
|
|
206
|
+
border: solid;
|
|
207
|
+
border-color: transparent;
|
|
194
208
|
border-width: ${layoutParams.strokeWidth * 100}vw;
|
|
209
|
+
border-radius: ${layoutParams.radius * 100}vw;
|
|
210
|
+
}
|
|
211
|
+
.video-border-${item.id} {
|
|
212
|
+
position: absolute;
|
|
213
|
+
inset: 0;
|
|
214
|
+
border-radius: inherit;
|
|
215
|
+
pointer-events: none;
|
|
216
|
+
z-index: 2;
|
|
217
|
+
-webkit-mask:
|
|
218
|
+
linear-gradient(#fff 0 0) content-box,
|
|
219
|
+
linear-gradient(#fff 0 0);
|
|
220
|
+
-webkit-mask-composite: xor;
|
|
221
|
+
mask-composite: exclude;
|
|
195
222
|
}
|
|
196
223
|
`);
|
|
197
224
|
})}
|
|
@@ -4,7 +4,14 @@ exports.useFileItem = void 0;
|
|
|
4
4
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
5
5
|
const useKeyframeValue_1 = require("../../../common/useKeyframeValue");
|
|
6
6
|
const useLayoutContext_1 = require("../../useLayoutContext");
|
|
7
|
-
const
|
|
7
|
+
const DEFAULT_FILL = [
|
|
8
|
+
{
|
|
9
|
+
id: 'default',
|
|
10
|
+
type: 'solid',
|
|
11
|
+
value: 'rgba(0, 0, 0, 1)',
|
|
12
|
+
blendMode: 'normal'
|
|
13
|
+
}
|
|
14
|
+
];
|
|
8
15
|
function useFileItem(item, sectionId) {
|
|
9
16
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
10
17
|
const radius = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.BorderRadius, (item, layoutId) => {
|
|
@@ -25,18 +32,18 @@ function useFileItem(item, sectionId) {
|
|
|
25
32
|
const layoutParams = item.layoutParams[layoutId];
|
|
26
33
|
return 'opacity' in layoutParams ? layoutParams.opacity : 1;
|
|
27
34
|
}, (animator, scroll, value) => value !== undefined ? animator.getOpacity({ opacity: value }, scroll).opacity : undefined, sectionId, [layoutId]);
|
|
28
|
-
const
|
|
35
|
+
const strokeFill = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.BorderFill, (item, layoutId) => {
|
|
29
36
|
if (!layoutId)
|
|
30
37
|
return;
|
|
31
38
|
const layoutParams = item.layoutParams[layoutId];
|
|
32
|
-
return '
|
|
33
|
-
}, (animator, scroll, value) => value ? animator.
|
|
39
|
+
return 'strokeFill' in layoutParams ? layoutParams.strokeFill : DEFAULT_FILL;
|
|
40
|
+
}, (animator, scroll, value) => value ? animator.getBorderFill(value, scroll) : undefined, sectionId, [layoutId]);
|
|
34
41
|
const blur = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Blur, (item, layoutId) => {
|
|
35
42
|
if (!layoutId)
|
|
36
43
|
return;
|
|
37
44
|
const layoutParams = item.layoutParams[layoutId];
|
|
38
45
|
return 'blur' in layoutParams ? layoutParams.blur : 0;
|
|
39
46
|
}, (animator, scroll, value) => value !== undefined ? animator.getBlur({ blur: value }, scroll).blur : undefined, sectionId, [layoutId]);
|
|
40
|
-
return { radius, strokeWidth, opacity,
|
|
47
|
+
return { radius, strokeWidth, opacity, strokeFill, blur };
|
|
41
48
|
}
|
|
42
49
|
exports.useFileItem = useFileItem;
|
|
@@ -7,7 +7,6 @@ exports.RectangleItem = void 0;
|
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
10
|
-
const color_1 = require("@cntrl-site/color");
|
|
11
10
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
12
11
|
const LinkWrapper_1 = require("../LinkWrapper");
|
|
13
12
|
const useRectangleItem_1 = require("./useRectangleItem");
|
|
@@ -15,22 +14,22 @@ const useItemAngle_1 = require("../useItemAngle");
|
|
|
15
14
|
const useCntrlContext_1 = require("../../../provider/useCntrlContext");
|
|
16
15
|
const useRegisterResize_1 = require("../../../common/useRegisterResize");
|
|
17
16
|
const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromItemStateAndParams");
|
|
17
|
+
const getFill_1 = require("../../../utils/getFill");
|
|
18
|
+
const areFillsVisible_1 = require("../../../utils/areFillsVisible/areFillsVisible");
|
|
18
19
|
const RectangleItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
19
|
-
var _a, _b, _c, _d;
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
20
21
|
const id = (0, react_1.useId)();
|
|
21
22
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
22
|
-
const {
|
|
23
|
+
const { fill: itemFill, radius: itemRadius, strokeWidth: itemStrokeWidth, strokeFill: itemStrokeFill, blur: itemBlur, backdropBlur: itemBackdropBlur } = (0, useRectangleItem_1.useRectangleItem)(item, sectionId);
|
|
23
24
|
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
24
|
-
const stateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['angle', '
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
return strokeColor ? color_1.CntrlColor.parse(strokeColor) : undefined;
|
|
33
|
-
}, [itemStrokeColor, styles === null || styles === void 0 ? void 0 : styles.strokeColor]);
|
|
25
|
+
const stateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['angle', 'strokeWidth', 'radius', 'blur', 'backdropBlur']);
|
|
26
|
+
const stateFillParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['fill']);
|
|
27
|
+
const stateFillLayers = (_a = stateFillParams === null || stateFillParams === void 0 ? void 0 : stateFillParams.styles) === null || _a === void 0 ? void 0 : _a.fill;
|
|
28
|
+
const solidTransition = (_b = stateFillParams === null || stateFillParams === void 0 ? void 0 : stateFillParams.transition) !== null && _b !== void 0 ? _b : 'none';
|
|
29
|
+
const stateStrokeFillParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['strokeFill']);
|
|
30
|
+
const stateStrokeFillLayers = (_c = stateStrokeFillParams === null || stateStrokeFillParams === void 0 ? void 0 : stateStrokeFillParams.styles) === null || _c === void 0 ? void 0 : _c.strokeFill;
|
|
31
|
+
const strokeSolidTransition = (_d = stateStrokeFillParams === null || stateStrokeFillParams === void 0 ? void 0 : stateStrokeFillParams.transition) !== null && _d !== void 0 ? _d : 'none';
|
|
32
|
+
const styles = (_e = stateParams === null || stateParams === void 0 ? void 0 : stateParams.styles) !== null && _e !== void 0 ? _e : {};
|
|
34
33
|
const layoutValues = [item.area, item.layoutParams];
|
|
35
34
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
36
35
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
@@ -40,35 +39,92 @@ const RectangleItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilit
|
|
|
40
39
|
const angle = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(styles === null || styles === void 0 ? void 0 : styles.angle, itemAngle);
|
|
41
40
|
const blur = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(styles === null || styles === void 0 ? void 0 : styles.blur, itemBlur);
|
|
42
41
|
const backdropFilterValue = backdropBlur ? `blur(${backdropBlur * 100}vw)` : undefined;
|
|
43
|
-
const isInteractive = (
|
|
42
|
+
const isInteractive = (0, areFillsVisible_1.areFillsVisible)((_f = stateFillLayers !== null && stateFillLayers !== void 0 ? stateFillLayers : itemFill) !== null && _f !== void 0 ? _f : []) || (strokeWidth !== 0 && (0, areFillsVisible_1.areFillsVisible)((_g = stateStrokeFillLayers !== null && stateStrokeFillLayers !== void 0 ? stateStrokeFillLayers : itemStrokeFill) !== null && _g !== void 0 ? _g : []));
|
|
44
43
|
(0, react_1.useEffect)(() => {
|
|
45
44
|
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
46
45
|
}, [isInteractive, onVisibilityChange]);
|
|
47
|
-
|
|
46
|
+
const strokeValue = stateStrokeFillLayers
|
|
47
|
+
? (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(stateStrokeFillLayers[0], itemStrokeFill === null || itemStrokeFill === void 0 ? void 0 : itemStrokeFill[0])
|
|
48
|
+
: itemStrokeFill === null || itemStrokeFill === void 0 ? void 0 : itemStrokeFill[0];
|
|
49
|
+
const stroke = strokeValue
|
|
50
|
+
? (_h = (0, getFill_1.getFill)(strokeValue)) !== null && _h !== void 0 ? _h : 'transparent'
|
|
51
|
+
: 'transparent';
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_j = item.link) === null || _j === void 0 ? void 0 : _j.url, target: (_k = item.link) === null || _k === void 0 ? void 0 : _k.target, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: `rectangle-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (strokeValue ? Object.assign({ '--stroke-background': stroke }, (strokeValue.type === 'image' ? {
|
|
53
|
+
backgroundPosition: 'center',
|
|
54
|
+
backgroundSize: strokeValue.behavior === 'repeat' ? `${strokeValue.backgroundSize}%` : strokeValue.behavior,
|
|
55
|
+
backgroundRepeat: strokeValue.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
56
|
+
} : {})) : {})), (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset' }), (backdropFilterValue !== undefined
|
|
48
57
|
? { backdropFilter: backdropFilterValue, WebkitBackdropFilter: backdropFilterValue }
|
|
49
|
-
: {})), { transition: (
|
|
58
|
+
: {})), { transition: (_l = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _l !== void 0 ? _l : 'none' }), children: [(0, jsx_runtime_1.jsx)("div", { className: `rectangle-border-${item.id}`, style: Object.assign({ position: 'absolute', inset: 0, borderRadius: 'inherit', pointerEvents: 'none', zIndex: 2, WebkitMask: 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)', WebkitMaskComposite: 'xor', maskComposite: 'exclude' }, (strokeWidth !== 0 && strokeValue ? Object.assign(Object.assign(Object.assign({}, (strokeWidth ? { padding: `${strokeWidth * 100}vw` } : {})), (strokeValue.type === 'solid' ? { transition: strokeSolidTransition, background: stroke } : {})), (strokeValue.type === 'image' ? {
|
|
59
|
+
backgroundPosition: 'center',
|
|
60
|
+
backgroundSize: strokeValue.behavior === 'repeat' ? `${strokeValue.backgroundSize}%` : strokeValue.behavior,
|
|
61
|
+
backgroundRepeat: strokeValue.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
62
|
+
} : {
|
|
63
|
+
background: stroke,
|
|
64
|
+
})) : { background: stroke })) }), itemFill && itemFill.map((fill) => {
|
|
65
|
+
var _a, _b;
|
|
66
|
+
const stateFillLayer = stateFillLayers === null || stateFillLayers === void 0 ? void 0 : stateFillLayers.find((layer) => layer.id === fill.id);
|
|
67
|
+
const value = stateFillLayer
|
|
68
|
+
? ((_a = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(stateFillLayer, fill)) !== null && _a !== void 0 ? _a : fill)
|
|
69
|
+
: fill;
|
|
70
|
+
const background = value
|
|
71
|
+
? (_b = (0, getFill_1.getFill)(value)) !== null && _b !== void 0 ? _b : 'transparent'
|
|
72
|
+
: 'transparent';
|
|
73
|
+
return ((0, jsx_runtime_1.jsx)(Fill, { fill: value, itemId: item.id, background: background, solidTransition: solidTransition }));
|
|
74
|
+
})] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
50
75
|
.rectangle-${item.id} {
|
|
51
76
|
position: absolute;
|
|
52
77
|
width: 100%;
|
|
53
78
|
height: 100%;
|
|
54
|
-
border-style: solid;
|
|
55
79
|
box-sizing: border-box;
|
|
56
|
-
}
|
|
80
|
+
},
|
|
81
|
+
.image-fill-${item.id} {
|
|
82
|
+
position: absolute;
|
|
83
|
+
top: 0;
|
|
84
|
+
left: 0;
|
|
85
|
+
width: 100%;
|
|
86
|
+
height: 100%;
|
|
87
|
+
transform-origin: center center;
|
|
88
|
+
z-index: 1;
|
|
89
|
+
background-position: center;
|
|
90
|
+
},
|
|
57
91
|
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
|
|
58
92
|
return (`
|
|
59
93
|
.rectangle-${item.id} {
|
|
60
|
-
|
|
61
|
-
border-color: ${color_1.CntrlColor.parse(layoutParams.strokeColor).fmt('rgba')};
|
|
62
|
-
border-radius: ${layoutParams.radius * 100}vw;
|
|
63
|
-
border-width: ${layoutParams.strokeWidth * 100}vw;
|
|
94
|
+
border-radius: ${layoutParams.radius * 100}vw
|
|
64
95
|
transform: rotate(${area.angle}deg);
|
|
65
96
|
filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
66
97
|
${layoutParams.blur !== 0 ? 'will-change: transform;' : ''}
|
|
67
98
|
backdrop-filter: ${layoutParams.backdropBlur !== 0 ? `blur(${layoutParams.backdropBlur * 100}vw)` : 'unset'};
|
|
68
99
|
-webkit-backdrop-filter: ${layoutParams.backdropBlur !== 0 ? `blur(${layoutParams.backdropBlur * 100}vw)` : 'unset'};
|
|
100
|
+
},
|
|
101
|
+
.rectangle-border-${item.id} {
|
|
102
|
+
position: absolute;
|
|
103
|
+
inset: 0;
|
|
104
|
+
border-radius: inherit;
|
|
105
|
+
pointer-events: none;
|
|
106
|
+
z-index: 2;
|
|
107
|
+
-webkit-mask:
|
|
108
|
+
linear-gradient(#fff 0 0) content-box,
|
|
109
|
+
linear-gradient(#fff 0 0);
|
|
110
|
+
-webkit-mask-composite: xor;
|
|
111
|
+
mask-composite: exclude;
|
|
69
112
|
}
|
|
70
113
|
`);
|
|
71
114
|
})}
|
|
72
115
|
` })] }) }));
|
|
73
116
|
};
|
|
74
117
|
exports.RectangleItem = RectangleItem;
|
|
118
|
+
function Fill({ fill, itemId, background, solidTransition }) {
|
|
119
|
+
const isRotatedImage = fill.type === 'image' && fill.rotation && fill.rotation !== 0;
|
|
120
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: fill.type === 'image' ? `image-fill-${itemId}` : `fill-${itemId}`, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (fill.type === 'solid' ? { background, transition: solidTransition } : {})), (fill.type === 'image'
|
|
121
|
+
? {
|
|
122
|
+
transform: `rotate(${fill.rotation}deg)`,
|
|
123
|
+
backgroundImage: `url(${fill.src})`,
|
|
124
|
+
backgroundSize: fill.behavior === 'repeat' ? `${fill.backgroundSize}%` : fill.behavior,
|
|
125
|
+
backgroundRepeat: fill.behavior === 'repeat' ? 'repeat' : 'no-repeat',
|
|
126
|
+
opacity: fill.opacity
|
|
127
|
+
}
|
|
128
|
+
: { background })), { position: 'absolute', mixBlendMode: fill.blendMode, top: 0, left: 0, width: '100%', height: '100%', pointerEvents: 'none' }), (isRotatedImage ? { overflow: 'hidden' } : {})) }, fill.id));
|
|
129
|
+
}
|
|
130
|
+
;
|
|
@@ -4,7 +4,14 @@ exports.useRectangleItem = void 0;
|
|
|
4
4
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
5
5
|
const useKeyframeValue_1 = require("../../../common/useKeyframeValue");
|
|
6
6
|
const useLayoutContext_1 = require("../../useLayoutContext");
|
|
7
|
-
const
|
|
7
|
+
const defaultFill = [
|
|
8
|
+
{
|
|
9
|
+
id: 'default',
|
|
10
|
+
type: 'solid',
|
|
11
|
+
value: 'rgba(0, 0, 0, 1)',
|
|
12
|
+
blendMode: 'normal'
|
|
13
|
+
}
|
|
14
|
+
];
|
|
8
15
|
function useRectangleItem(item, sectionId) {
|
|
9
16
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
10
17
|
const radius = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.BorderRadius, (item, layoutId) => {
|
|
@@ -19,18 +26,18 @@ function useRectangleItem(item, sectionId) {
|
|
|
19
26
|
const layoutParams = item.layoutParams[layoutId];
|
|
20
27
|
return 'strokeWidth' in layoutParams ? layoutParams.strokeWidth : 0;
|
|
21
28
|
}, (animator, scroll, value) => value !== undefined ? animator.getBorderWidth({ borderWidth: value }, scroll).borderWidth : undefined, sectionId, [layoutId]);
|
|
22
|
-
const
|
|
29
|
+
const fill = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Fill, (item, layoutId) => {
|
|
23
30
|
if (!layoutId)
|
|
24
31
|
return;
|
|
25
32
|
const layoutParams = item.layoutParams[layoutId];
|
|
26
|
-
return '
|
|
27
|
-
}, (animator, scroll, value) => value ? animator.
|
|
28
|
-
const
|
|
33
|
+
return 'fill' in layoutParams ? layoutParams.fill : defaultFill;
|
|
34
|
+
}, (animator, scroll, value) => value ? animator.getFill(value, scroll) : undefined, sectionId, [layoutId]);
|
|
35
|
+
const strokeFill = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.BorderFill, (item, layoutId) => {
|
|
29
36
|
if (!layoutId)
|
|
30
37
|
return;
|
|
31
38
|
const layoutParams = item.layoutParams[layoutId];
|
|
32
|
-
return '
|
|
33
|
-
}, (animator, scroll, value) => value ? animator.
|
|
39
|
+
return 'strokeFill' in layoutParams ? layoutParams.strokeFill : defaultFill;
|
|
40
|
+
}, (animator, scroll, value) => value ? animator.getBorderFill(value, scroll) : undefined, sectionId, [layoutId]);
|
|
34
41
|
const blur = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Blur, (item, layoutId) => {
|
|
35
42
|
if (!layoutId)
|
|
36
43
|
return;
|
|
@@ -43,6 +50,6 @@ function useRectangleItem(item, sectionId) {
|
|
|
43
50
|
const layoutParams = item.layoutParams[layoutId];
|
|
44
51
|
return 'backdropBlur' in layoutParams ? layoutParams.backdropBlur : 0;
|
|
45
52
|
}, (animator, scroll, value) => value !== undefined ? animator.getBackdropBlur({ backdropBlur: value }, scroll).backdropBlur : undefined, sectionId, [layoutId]);
|
|
46
|
-
return {
|
|
53
|
+
return { fill, strokeWidth, radius, strokeFill, blur, backdropBlur };
|
|
47
54
|
}
|
|
48
55
|
exports.useRectangleItem = useRectangleItem;
|
|
@@ -2,29 +2,29 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getStyleKeysFromCSSProperty = exports.CSSPropertyNameMap = void 0;
|
|
4
4
|
exports.CSSPropertyNameMap = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
width: 'width',
|
|
6
|
+
height: 'height',
|
|
7
|
+
top: 'top',
|
|
8
|
+
left: 'left',
|
|
9
|
+
scale: 'transform',
|
|
10
|
+
angle: 'transform',
|
|
11
|
+
opacity: 'opacity',
|
|
12
|
+
radius: 'border-radius',
|
|
13
|
+
strokeWidth: 'border-width',
|
|
14
|
+
strokeFill: 'border-color',
|
|
15
|
+
fill: 'background',
|
|
16
|
+
blur: 'filter',
|
|
17
|
+
backdropBlur: 'backdrop-filter',
|
|
18
|
+
letterSpacing: 'letter-spacing',
|
|
19
|
+
wordSpacing: 'word-spacing',
|
|
20
|
+
color: 'color'
|
|
21
21
|
};
|
|
22
22
|
const PropertyNameCSSMap = {
|
|
23
23
|
'transform': ['angle', 'scale'],
|
|
24
24
|
'border-radius': ['radius'],
|
|
25
25
|
'border-width': ['strokeWidth'],
|
|
26
|
-
'border-color': ['
|
|
27
|
-
'background
|
|
26
|
+
'border-color': ['strokeFill'],
|
|
27
|
+
'background': ['fill'],
|
|
28
28
|
'filter': ['blur'],
|
|
29
29
|
'backdrop-filter': ['backdrop-blur'],
|
|
30
30
|
'letter-spacing': ['letterSpacing'],
|