@gxpl/sdk 0.0.8 → 0.0.9
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/lib/index.d.ts +1 -4
- package/lib/index.js +1 -4
- package/lib/sdk/Client/Client.d.ts +0 -2
- package/lib/sdk/Client/Client.js +0 -11
- package/lib/sdk/schemas/article/Article.schema.d.ts +40 -45
- package/lib/sdk/schemas/article/Article.schema.js +1 -1
- package/lib/sdk/schemas/article/Item.schema.js +64 -84
- package/lib/sdk/schemas/article/ItemBase.schema.d.ts +15 -18
- package/lib/sdk/schemas/article/ItemBase.schema.js +3 -4
- package/lib/sdk/schemas/article/ItemState.schema.d.ts +76 -76
- package/lib/sdk/schemas/article/RichTextItem.schema.d.ts +78 -86
- package/lib/sdk/schemas/article/RichTextItem.schema.js +9 -11
- package/lib/sdk/schemas/article/Section.schema.d.ts +20 -23
- package/lib/sdk/schemas/article/Section.schema.js +4 -5
- package/lib/sdk/schemas/keyframe/Keyframes.schema.d.ts +0 -90
- package/lib/sdk/schemas/keyframe/Keyframes.schema.js +0 -1
- package/lib/sdk/schemas/project/Project.schema.d.ts +3 -28
- package/lib/sdk/schemas/project/Project.schema.js +1 -2
- package/lib/sdk/types/article/Article.d.ts +1 -1
- package/lib/sdk/types/article/Item.d.ts +75 -114
- package/lib/sdk/types/article/Section.d.ts +4 -5
- package/lib/sdk/types/keyframe/Keyframe.d.ts +0 -1
- package/lib/sdk/types/project/Project.d.ts +1 -2
- package/lib/sdk-nextjs/common/useExemplary.js +1 -5
- package/lib/sdk-nextjs/common/useItemFXData.js +1 -1
- package/lib/sdk-nextjs/common/useKeyframeValue.d.ts +1 -1
- package/lib/sdk-nextjs/common/useKeyframeValue.js +4 -7
- package/lib/sdk-nextjs/common/useLayoutDeviation.d.ts +5 -0
- package/lib/sdk-nextjs/common/useLayoutDeviation.js +20 -0
- package/lib/sdk-nextjs/components/ArticleWrapper.js +3 -4
- package/lib/sdk-nextjs/components/Section/Section.js +12 -31
- package/lib/sdk-nextjs/components/Section/useSectionHeightMap.d.ts +1 -3
- package/lib/sdk-nextjs/components/Section/useSectionHeightMap.js +1 -9
- package/lib/sdk-nextjs/components/items/CodeEmbedItem/CodeEmbedItem.js +16 -35
- package/lib/sdk-nextjs/components/items/CodeEmbedItem/useCodeEmbedItem.d.ts +2 -4
- package/lib/sdk-nextjs/components/items/CodeEmbedItem/useCodeEmbedItem.js +3 -17
- package/lib/sdk-nextjs/components/items/ComponentItem/ComponentItem.js +13 -23
- package/lib/sdk-nextjs/components/items/ComponentItem/useComponentItem.d.ts +2 -2
- package/lib/sdk-nextjs/components/items/ComponentItem/useComponentItem.js +2 -14
- package/lib/sdk-nextjs/components/items/CompoundItem/CompoundChild.js +40 -46
- package/lib/sdk-nextjs/components/items/CompoundItem/CompoundItem.js +8 -14
- package/lib/sdk-nextjs/components/items/CompoundItem/useCompoundItem.d.ts +1 -1
- package/lib/sdk-nextjs/components/items/CompoundItem/useCompoundItem.js +1 -8
- package/lib/sdk-nextjs/components/items/CustomItem/CustomItem.js +11 -16
- package/lib/sdk-nextjs/components/items/EmbedVideoItem/VimeoEmbed.js +28 -37
- package/lib/sdk-nextjs/components/items/EmbedVideoItem/YoutubeEmbed.js +17 -29
- package/lib/sdk-nextjs/components/items/EmbedVideoItem/useEmbedVideoItem.d.ts +3 -3
- package/lib/sdk-nextjs/components/items/EmbedVideoItem/useEmbedVideoItem.js +3 -20
- package/lib/sdk-nextjs/components/items/FileItem/ImageItem.js +48 -54
- package/lib/sdk-nextjs/components/items/FileItem/VideoItem.js +53 -64
- package/lib/sdk-nextjs/components/items/FileItem/useFileItem.d.ts +6 -6
- package/lib/sdk-nextjs/components/items/FileItem/useFileItem.js +5 -32
- package/lib/sdk-nextjs/components/items/GroupItem/GroupItem.js +3 -13
- package/lib/sdk-nextjs/components/items/GroupItem/useGroupItem.d.ts +2 -2
- package/lib/sdk-nextjs/components/items/GroupItem/useGroupItem.js +2 -14
- package/lib/sdk-nextjs/components/items/Item.js +23 -48
- package/lib/sdk-nextjs/components/items/RectangleItem/RectangleItem.js +19 -29
- package/lib/sdk-nextjs/components/items/RectangleItem/useRectangleItem.d.ts +6 -6
- package/lib/sdk-nextjs/components/items/RectangleItem/useRectangleItem.js +6 -38
- package/lib/sdk-nextjs/components/items/RichTextItem/RichTextItem.js +23 -31
- package/lib/sdk-nextjs/components/items/RichTextItem/useRichTextItem.js +2 -2
- package/lib/sdk-nextjs/components/items/useItemAngle.d.ts +1 -1
- package/lib/sdk-nextjs/components/items/useItemAngle.js +1 -1
- package/lib/sdk-nextjs/components/items/useItemArea.d.ts +4 -4
- package/lib/sdk-nextjs/components/items/useItemArea.js +2 -8
- package/lib/sdk-nextjs/components/items/useItemScale.d.ts +1 -1
- package/lib/sdk-nextjs/components/items/useItemScale.js +1 -3
- package/lib/sdk-nextjs/components/items/useRichTextItemValues.d.ts +6 -6
- package/lib/sdk-nextjs/components/items/useRichTextItemValues.js +6 -28
- package/lib/sdk-nextjs/components/items/useSizing.js +2 -4
- package/lib/sdk-nextjs/components/items/useStickyItemTop.js +3 -9
- package/lib/sdk-nextjs/interactions/InteractionsRegistry.d.ts +1 -1
- package/lib/sdk-nextjs/interactions/InteractionsRegistry.js +2 -2
- package/lib/sdk-nextjs/provider/CntrlSdkContext.d.ts +5 -6
- package/lib/sdk-nextjs/provider/CntrlSdkContext.js +6 -6
- package/lib/sdk-nextjs/provider/InteractionsContext.js +2 -6
- package/lib/sdk-nextjs/utils/RichTextConverter/RichTextConverter.d.ts +1 -2
- package/lib/sdk-nextjs/utils/RichTextConverter/RichTextConverter.js +37 -62
- package/lib/sdk-nextjs/utils/getStyleFromItemStateAndParams.d.ts +1 -1
- package/package.json +1 -1
- package/lib/cli.d.ts +0 -10
- package/lib/cli.js +0 -64
- package/lib/sdk/schemas/project/Layout.schema.d.ts +0 -17
- package/lib/sdk/schemas/project/Layout.schema.js +0 -10
- package/lib/sdk/types/component/Component.d.ts +0 -15
- package/lib/sdk/types/component/Component.js +0 -2
- package/lib/sdk/types/project/Layout.d.ts +0 -6
- package/lib/sdk/types/project/Layout.js +0 -2
- package/lib/sdk-nextjs/common/useCurrentLayout.d.ts +0 -6
- package/lib/sdk-nextjs/common/useCurrentLayout.js +0 -42
- package/lib/sdk-nextjs/components/useLayoutContext.d.ts +0 -1
- package/lib/sdk-nextjs/components/useLayoutContext.js +0 -9
- package/lib/sdk-nextjs/provider/LayoutContext.d.ts +0 -1
- package/lib/sdk-nextjs/provider/LayoutContext.js +0 -5
- package/lib/utils.d.ts +0 -3
- package/lib/utils.js +0 -30
|
@@ -12,16 +12,11 @@ const useComponentItem_1 = require("./useComponentItem");
|
|
|
12
12
|
const useItemAngle_1 = require("../useItemAngle");
|
|
13
13
|
const useRegisterResize_1 = require("../../../common/useRegisterResize");
|
|
14
14
|
const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromItemStateAndParams");
|
|
15
|
-
const useLayoutContext_1 = require("../../useLayoutContext");
|
|
16
|
-
const utils_1 = require("../../../../utils");
|
|
17
15
|
const ComponentItem = ({ item, sectionId, onResize, interactionCtrl }) => {
|
|
18
16
|
var _a, _b, _c, _d;
|
|
19
17
|
const sdk = (0, useCntrlContext_1.useCntrlContext)();
|
|
20
|
-
const { layouts } = sdk;
|
|
21
18
|
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
22
|
-
const
|
|
23
|
-
const layoutValues = [item.area, item.layoutParams];
|
|
24
|
-
const component = sdk.getComponent(item.commonParams.componentId);
|
|
19
|
+
const component = sdk.getComponent(item.params.componentId);
|
|
25
20
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
26
21
|
const { opacity: itemOpacity, blur: itemBlur } = (0, useComponentItem_1.useComponentItem)(item, sectionId);
|
|
27
22
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
@@ -30,22 +25,17 @@ const ComponentItem = ({ item, sectionId, onResize, interactionCtrl }) => {
|
|
|
30
25
|
const opacity = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_b = stateParams === null || stateParams === void 0 ? void 0 : stateParams.styles) === null || _b === void 0 ? void 0 : _b.opacity, itemOpacity);
|
|
31
26
|
const blur = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_c = stateParams === null || stateParams === void 0 ? void 0 : stateParams.styles) === null || _c === void 0 ? void 0 : _c.blur, itemBlur);
|
|
32
27
|
const Element = component ? component.element : undefined;
|
|
33
|
-
const parameters =
|
|
34
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `custom-component-${item.id}`, ref: setRef, style: Object.assign(Object.assign(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
filter: blur(${layoutParams.blur}vw);
|
|
46
|
-
${layoutParams.blur !== 0 ? 'will-change: transform;' : ''}
|
|
47
|
-
}
|
|
48
|
-
`);
|
|
49
|
-
})}` })] }));
|
|
28
|
+
const parameters = item.params.parameters;
|
|
29
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `custom-component-${item.id}`, ref: setRef, style: Object.assign(Object.assign({ opacity, transform: `rotate(${angle}deg)` }, (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_d = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _d !== void 0 ? _d : 'none' }), children: parameters && Element && ((0, jsx_runtime_1.jsx)(Element, Object.assign({ content: item.params.content }, parameters))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: item.id, children: `
|
|
30
|
+
.custom-component-${item.id} {
|
|
31
|
+
width: 100%;
|
|
32
|
+
height: 100%;
|
|
33
|
+
pointer-events: auto;
|
|
34
|
+
transform: rotate(${item.area.angle}deg);
|
|
35
|
+
opacity: ${item.params.opacity};
|
|
36
|
+
filter: blur(${item.params.blur}vw);
|
|
37
|
+
${item.params.blur !== 0 ? 'will-change: transform;' : ''}
|
|
38
|
+
}
|
|
39
|
+
` })] }));
|
|
50
40
|
};
|
|
51
41
|
exports.ComponentItem = ComponentItem;
|
|
@@ -2,22 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useComponentItem = useComponentItem;
|
|
4
4
|
const useKeyframeValue_1 = require("../../../common/useKeyframeValue");
|
|
5
|
-
const useLayoutContext_1 = require("../../useLayoutContext");
|
|
6
5
|
const Keyframe_1 = require("../../../../sdk/types/keyframe/Keyframe");
|
|
7
6
|
function useComponentItem(item, sectionId) {
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
if (!layoutId)
|
|
11
|
-
return;
|
|
12
|
-
const layoutParams = item.layoutParams[layoutId];
|
|
13
|
-
return 'opacity' in layoutParams ? layoutParams.opacity : 1;
|
|
14
|
-
}, (animator, scroll, value) => value !== undefined ? animator.getOpacity({ opacity: value }, scroll).opacity : undefined, sectionId, [layoutId]);
|
|
15
|
-
const blur = (0, useKeyframeValue_1.useKeyframeValue)(item, Keyframe_1.KeyframeType.Blur, (item, layoutId) => {
|
|
16
|
-
if (!layoutId)
|
|
17
|
-
return;
|
|
18
|
-
const layoutParams = item.layoutParams[layoutId];
|
|
19
|
-
return 'blur' in layoutParams ? layoutParams.blur : 0;
|
|
20
|
-
}, (animator, scroll, value) => value !== undefined ? animator.getBlur({ blur: value }, scroll).blur : undefined, sectionId, [layoutId]);
|
|
7
|
+
const opacity = (0, useKeyframeValue_1.useKeyframeValue)(item, Keyframe_1.KeyframeType.Opacity, (item) => 'opacity' in item.params ? item.params.opacity : 1, (animator, scroll, value) => animator.getOpacity({ opacity: value }, scroll).opacity, sectionId);
|
|
8
|
+
const blur = (0, useKeyframeValue_1.useKeyframeValue)(item, Keyframe_1.KeyframeType.Blur, (item) => 'blur' in item.params ? item.params.blur : 0, (animator, scroll, value) => animator.getBlur({ blur: value }, scroll).blur, sectionId);
|
|
21
9
|
return {
|
|
22
10
|
opacity,
|
|
23
11
|
blur
|
|
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.CompoundChild = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_1 = require("react");
|
|
9
|
-
const useCntrlContext_1 = require("../../../provider/useCntrlContext");
|
|
10
|
-
const useLayoutContext_1 = require("../../useLayoutContext");
|
|
11
9
|
const useExemplary_1 = require("../../../common/useExemplary");
|
|
12
10
|
const useItemScale_1 = require("../useItemScale");
|
|
13
11
|
const useItemInteractionCtrl_1 = require("../../../interactions/useItemInteractionCtrl");
|
|
@@ -22,21 +20,18 @@ const useSizing_1 = require("../useSizing");
|
|
|
22
20
|
const useItemPointerEvents_1 = require("../useItemPointerEvents");
|
|
23
21
|
const useItemArea_1 = require("../useItemArea");
|
|
24
22
|
const ArticleItemType_1 = require("../../../../sdk/types/article/ArticleItemType");
|
|
25
|
-
const utils_1 = require("../../../../utils");
|
|
26
23
|
const noop = () => null;
|
|
27
24
|
const CompoundChild = ({ item, sectionId, isParentVisible = true }) => {
|
|
28
25
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
29
26
|
const id = (0, react_1.useId)();
|
|
30
|
-
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
31
|
-
const layout = (0, useLayoutContext_1.useLayoutContext)();
|
|
32
27
|
const exemplary = (0, useExemplary_1.useExemplary)();
|
|
33
|
-
const { handleVisibilityChange, allowPointerEvents } = (0, useItemPointerEvents_1.useItemPointerEvents)((_b = (_a = item.
|
|
28
|
+
const { handleVisibilityChange, allowPointerEvents } = (0, useItemPointerEvents_1.useItemPointerEvents)((_b = (_a = item.params) === null || _a === void 0 ? void 0 : _a.pointerEvents) !== null && _b !== void 0 ? _b : 'when_visible', isParentVisible);
|
|
34
29
|
const itemScale = (0, useItemScale_1.useItemScale)(item, sectionId);
|
|
35
30
|
const interactionCtrl = (0, useItemInteractionCtrl_1.useItemInteractionCtrl)(item.id);
|
|
36
31
|
const triggers = (0, useItemTriggers_1.useItemTriggers)(interactionCtrl);
|
|
37
32
|
const wrapperStateProps = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['top', 'left', 'width', 'height']);
|
|
38
33
|
const innerStateProps = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['scale']);
|
|
39
|
-
const compoundSettings =
|
|
34
|
+
const compoundSettings = item.compoundSettings;
|
|
40
35
|
const { width, height, top, left } = (0, useItemArea_1.useItemArea)(item, sectionId, {
|
|
41
36
|
top: (_c = wrapperStateProps === null || wrapperStateProps === void 0 ? void 0 : wrapperStateProps.styles) === null || _c === void 0 ? void 0 : _c.top,
|
|
42
37
|
left: (_d = wrapperStateProps === null || wrapperStateProps === void 0 ? void 0 : wrapperStateProps.styles) === null || _d === void 0 ? void 0 : _d.left,
|
|
@@ -53,50 +48,49 @@ const CompoundChild = ({ item, sectionId, isParentVisible = true }) => {
|
|
|
53
48
|
const isRichText = (0, isItemType_1.isItemType)(item, ArticleItemType_1.ArticleItemType.RichText);
|
|
54
49
|
const scale = (_h = (_g = innerStateProps === null || innerStateProps === void 0 ? void 0 : innerStateProps.styles) === null || _g === void 0 ? void 0 : _g.scale) !== null && _h !== void 0 ? _h : itemScale;
|
|
55
50
|
const hasClickTriggers = (_j = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getHasTrigger(item.id, 'click')) !== null && _j !== void 0 ? _j : false;
|
|
56
|
-
|
|
51
|
+
const scaleAnchor = item.area.scaleAnchor;
|
|
52
|
+
if (!compoundSettings)
|
|
57
53
|
return null;
|
|
58
|
-
const layoutValues = [item.area, item.hidden, item.compoundSettings];
|
|
59
|
-
if (item.layoutParams) {
|
|
60
|
-
layoutValues.push(item.layoutParams);
|
|
61
|
-
}
|
|
62
54
|
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: `item-${item.id}`, onTransitionEnd: (e) => {
|
|
63
55
|
var _a;
|
|
64
56
|
e.stopPropagation();
|
|
65
57
|
(_a = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.handleTransitionEnd) === null || _a === void 0 ? void 0 : _a.call(interactionCtrl, e.propertyName);
|
|
66
|
-
}, style:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
`
|
|
99
|
-
|
|
58
|
+
}, style: {
|
|
59
|
+
top: (0, getCompoundBoundaryStyles_1.getCompoundTop)(compoundSettings, top),
|
|
60
|
+
left: (0, getCompoundBoundaryStyles_1.getCompoundLeft)(compoundSettings, left),
|
|
61
|
+
width: `${sizingAxis.x === 'manual'
|
|
62
|
+
? (0, getCompoundBoundaryStyles_1.getCompoundWidth)(compoundSettings, width, isRichText, exemplary)
|
|
63
|
+
: 'max-content'}`,
|
|
64
|
+
height: `${sizingAxis.y === 'manual'
|
|
65
|
+
? (0, getCompoundBoundaryStyles_1.getCompoundHeight)(compoundSettings, height)
|
|
66
|
+
: 'unset'}`,
|
|
67
|
+
transform: `${(0, getCompoundBoundaryStyles_1.getCompoundTransform)(compoundSettings)}`,
|
|
68
|
+
transition: (_k = wrapperStateProps === null || wrapperStateProps === void 0 ? void 0 : wrapperStateProps.transition) !== null && _k !== void 0 ? _k : 'none',
|
|
69
|
+
cursor: hasClickTriggers ? 'pointer' : 'unset',
|
|
70
|
+
pointerEvents: allowPointerEvents ? 'auto' : 'none'
|
|
71
|
+
} }, triggers, { children: [(0, jsx_runtime_1.jsx)("div", { className: `item-${item.id}-inner`, style: {
|
|
72
|
+
transition: (_l = innerStateProps === null || innerStateProps === void 0 ? void 0 : innerStateProps.transition) !== null && _l !== void 0 ? _l : 'none',
|
|
73
|
+
transform: `scale(${scale})`,
|
|
74
|
+
}, children: (0, jsx_runtime_1.jsx)(RichTextWrapper_1.RichTextWrapper, { isRichText: isRichText, transformOrigin: transformOrigin, children: (0, jsx_runtime_1.jsx)(ItemComponent, { item: item, sectionId: sectionId, interactionCtrl: interactionCtrl, onVisibilityChange: handleVisibilityChange, isInCompound: true }) }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
75
|
+
.item-${item.id}-inner {
|
|
76
|
+
width: 100%;
|
|
77
|
+
height: 100%;
|
|
78
|
+
transform-origin: ${ScaleAnchorMap_1.ScaleAnchorMap[scaleAnchor]};
|
|
79
|
+
transform: scale(${item.area.scale});
|
|
80
|
+
}
|
|
81
|
+
.item-${item.id} {
|
|
82
|
+
position: absolute;
|
|
83
|
+
top: ${(0, getCompoundBoundaryStyles_1.getCompoundTop)(compoundSettings, item.area.top)};
|
|
84
|
+
left: ${(0, getCompoundBoundaryStyles_1.getCompoundLeft)(compoundSettings, item.area.left)};
|
|
85
|
+
transition: opacity 0.2s linear 0.1s;
|
|
86
|
+
display: ${item.hidden ? 'none' : 'block'};
|
|
87
|
+
width: ${sizingAxis.x === 'manual'
|
|
88
|
+
? `${(0, getCompoundBoundaryStyles_1.getCompoundWidth)(compoundSettings, item.area.width, isRichText)}`
|
|
89
|
+
: 'max-content'};
|
|
90
|
+
height: ${sizingAxis.y === 'manual' ? `${(0, getCompoundBoundaryStyles_1.getCompoundHeight)(compoundSettings, item.area.height)}` : 'unset'};
|
|
91
|
+
transform: ${(0, getCompoundBoundaryStyles_1.getCompoundTransform)(compoundSettings)};
|
|
92
|
+
z-index: ${item.area.zIndex};
|
|
93
|
+
}
|
|
100
94
|
` })] })));
|
|
101
95
|
};
|
|
102
96
|
exports.CompoundChild = CompoundChild;
|
|
@@ -7,22 +7,18 @@ exports.CompoundItem = void 0;
|
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const useItemAngle_1 = require("../useItemAngle");
|
|
10
|
-
const useCntrlContext_1 = require("../../../provider/useCntrlContext");
|
|
11
10
|
const useRegisterResize_1 = require("../../../common/useRegisterResize");
|
|
12
11
|
const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromItemStateAndParams");
|
|
13
12
|
const LinkWrapper_1 = require("../LinkWrapper");
|
|
14
13
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
15
14
|
const CompoundChild_1 = require("./CompoundChild");
|
|
16
15
|
const useCompoundItem_1 = require("./useCompoundItem");
|
|
17
|
-
const utils_1 = require("../../../../utils");
|
|
18
16
|
const CompoundItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
19
17
|
var _a, _b, _c, _d, _e;
|
|
20
18
|
const id = (0, react_1.useId)();
|
|
21
19
|
const { items } = item;
|
|
22
20
|
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
23
|
-
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
24
21
|
const { opacity: itemOpacity } = (0, useCompoundItem_1.useCompoundItem)(item, sectionId);
|
|
25
|
-
const layoutValues = [item.area, item.layoutParams];
|
|
26
22
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
27
23
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
28
24
|
const stateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['opacity', 'angle']);
|
|
@@ -32,22 +28,20 @@ const CompoundItem = ({ item, sectionId, onResize, interactionCtrl, onVisibility
|
|
|
32
28
|
(0, react_1.useEffect)(() => {
|
|
33
29
|
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
34
30
|
}, [isInteractive, onVisibilityChange]);
|
|
35
|
-
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_c = item.link) === null || _c === void 0 ? void 0 : _c.url, target: (_d = item.link) === null || _d === void 0 ? void 0 : _d.target, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `compound-${item.id}`, ref: setRef, style:
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_c = item.link) === null || _c === void 0 ? void 0 : _c.url, target: (_d = item.link) === null || _d === void 0 ? void 0 : _d.target, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `compound-${item.id}`, ref: setRef, style: {
|
|
32
|
+
opacity,
|
|
33
|
+
transform: `rotate(${angle}deg)`,
|
|
34
|
+
transition: (_e = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _e !== void 0 ? _e : 'none'
|
|
35
|
+
}, children: items && items.map(item => ((0, jsx_runtime_1.jsx)(CompoundChild_1.CompoundChild, { item: item, sectionId: sectionId, isParentVisible: isInteractive }, item.id))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
36
36
|
.compound-${item.id} {
|
|
37
|
-
overflow: ${item.
|
|
37
|
+
overflow: ${item.params.overflow};
|
|
38
38
|
position: absolute;
|
|
39
39
|
width: 100%;
|
|
40
40
|
height: 100%;
|
|
41
41
|
box-sizing: border-box;
|
|
42
|
+
opacity: ${item.params.opacity};
|
|
43
|
+
transform: rotate(${item.area.angle}deg);
|
|
42
44
|
}
|
|
43
|
-
${(0, utils_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
|
|
44
|
-
return (`
|
|
45
|
-
.compound-${item.id} {
|
|
46
|
-
opacity: ${layoutParams.opacity};
|
|
47
|
-
transform: rotate(${area.angle}deg);
|
|
48
|
-
}
|
|
49
|
-
`);
|
|
50
|
-
})}
|
|
51
45
|
` })] }) }));
|
|
52
46
|
};
|
|
53
47
|
exports.CompoundItem = CompoundItem;
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useCompoundItem = useCompoundItem;
|
|
4
|
-
const useLayoutContext_1 = require("../../useLayoutContext");
|
|
5
4
|
const useKeyframeValue_1 = require("../../../common/useKeyframeValue");
|
|
6
5
|
const Keyframe_1 = require("../../../../sdk/types/keyframe/Keyframe");
|
|
7
6
|
function useCompoundItem(item, sectionId) {
|
|
8
|
-
const
|
|
9
|
-
const opacity = (0, useKeyframeValue_1.useKeyframeValue)(item, Keyframe_1.KeyframeType.Opacity, (item, layoutId) => {
|
|
10
|
-
if (!layoutId)
|
|
11
|
-
return;
|
|
12
|
-
const layoutParams = item.layoutParams[layoutId];
|
|
13
|
-
return 'opacity' in layoutParams ? layoutParams.opacity : 1;
|
|
14
|
-
}, (animator, scroll, value) => value !== undefined ? animator.getOpacity({ opacity: value }, scroll).opacity : undefined, sectionId, [layoutId]);
|
|
7
|
+
const opacity = (0, useKeyframeValue_1.useKeyframeValue)(item, Keyframe_1.KeyframeType.Opacity, (item) => 'opacity' in item.params ? item.params.opacity : 1, (animator, scroll, value) => animator.getOpacity({ opacity: value }, scroll).opacity, sectionId);
|
|
15
8
|
return { opacity };
|
|
16
9
|
}
|
|
@@ -10,31 +10,26 @@ const useCntrlContext_1 = require("../../../provider/useCntrlContext");
|
|
|
10
10
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
11
11
|
const useRegisterResize_1 = require("../../../common/useRegisterResize");
|
|
12
12
|
const useItemAngle_1 = require("../useItemAngle");
|
|
13
|
-
const utils_1 = require("../../../../utils");
|
|
14
13
|
const CustomItem = ({ item, onResize, sectionId, interactionCtrl }) => {
|
|
15
14
|
var _a, _b, _c;
|
|
16
15
|
const sdk = (0, useCntrlContext_1.useCntrlContext)();
|
|
17
|
-
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
18
16
|
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
19
|
-
const component = sdk.customItems.get(item.
|
|
20
|
-
const layoutValues = [item.area];
|
|
17
|
+
const component = sdk.customItems.get(item.params.name);
|
|
21
18
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
22
19
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
23
20
|
const stateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['angle']);
|
|
24
21
|
const angle = (_b = (_a = stateParams === null || stateParams === void 0 ? void 0 : stateParams.styles) === null || _a === void 0 ? void 0 : _a.angle) !== null && _b !== void 0 ? _b : itemAngle;
|
|
25
22
|
if (!component)
|
|
26
23
|
return null;
|
|
27
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `custom-component-${item.id}`, ref: setRef, style: Object.assign(Object.assign({}, (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), { transition: (_c = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _c !== void 0 ? _c : 'none' }), children: component({}) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: item.id, children:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
`);
|
|
38
|
-
})}` })] }));
|
|
24
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `custom-component-${item.id}`, ref: setRef, style: Object.assign(Object.assign({}, (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), { transition: (_c = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _c !== void 0 ? _c : 'none' }), children: component({}) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: item.id, children: `
|
|
25
|
+
.custom-component-${item.id} {
|
|
26
|
+
transform: rotate(${item.area.angle}deg);
|
|
27
|
+
height: 100%;
|
|
28
|
+
width: 100%;
|
|
29
|
+
position: absolute;
|
|
30
|
+
left: 0;
|
|
31
|
+
top: 0;
|
|
32
|
+
}
|
|
33
|
+
` })] }));
|
|
39
34
|
};
|
|
40
35
|
exports.CustomItem = CustomItem;
|
|
@@ -18,28 +18,22 @@ const player_1 = __importDefault(require("@vimeo/player"));
|
|
|
18
18
|
const react_1 = require("react");
|
|
19
19
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
20
20
|
const useItemAngle_1 = require("../useItemAngle");
|
|
21
|
-
const useCntrlContext_1 = require("../../../provider/useCntrlContext");
|
|
22
21
|
const useRegisterResize_1 = require("../../../common/useRegisterResize");
|
|
23
22
|
const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromItemStateAndParams");
|
|
24
23
|
const useEmbedVideoItem_1 = require("./useEmbedVideoItem");
|
|
25
24
|
const LinkWrapper_1 = require("../LinkWrapper");
|
|
26
|
-
const useLayoutContext_1 = require("../../useLayoutContext");
|
|
27
|
-
const utils_1 = require("../../../../utils");
|
|
28
25
|
const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
29
26
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
30
27
|
const id = (0, react_1.useId)();
|
|
31
|
-
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
32
28
|
const { radius: itemRadius, blur: itemBlur, opacity: itemOpacity } = (0, useEmbedVideoItem_1.useEmbedVideoItem)(item, sectionId);
|
|
33
|
-
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
34
29
|
const [iframeRef, setIframeRef] = (0, react_1.useState)(null);
|
|
35
30
|
const vimeoPlayer = (0, react_1.useMemo)(() => iframeRef ? new player_1.default(iframeRef) : undefined, [iframeRef]);
|
|
36
31
|
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
37
|
-
const { url } = item.
|
|
38
|
-
const
|
|
32
|
+
const { url } = item.params;
|
|
33
|
+
const params = item.params;
|
|
39
34
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
40
35
|
const [imgRef, setImgRef] = (0, react_1.useState)(null);
|
|
41
36
|
const [isCoverVisible, setIsCoverVisible] = (0, react_1.useState)(false);
|
|
42
|
-
const layoutValues = [item.area, item.layoutParams];
|
|
43
37
|
const wrapperStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['angle', 'blur', 'opacity']);
|
|
44
38
|
const frameStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['radius']);
|
|
45
39
|
const angle = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_a = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _a === void 0 ? void 0 : _a.angle, itemAngle);
|
|
@@ -48,24 +42,24 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibili
|
|
|
48
42
|
const radius = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_d = frameStateParams === null || frameStateParams === void 0 ? void 0 : frameStateParams.styles) === null || _d === void 0 ? void 0 : _d.radius, itemRadius);
|
|
49
43
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
50
44
|
const validUrl = (0, react_1.useMemo)(() => {
|
|
51
|
-
if (!
|
|
45
|
+
if (!params)
|
|
52
46
|
return url;
|
|
53
47
|
const validURL = new URL(url);
|
|
54
|
-
validURL.searchParams.append('controls', String(
|
|
55
|
-
validURL.searchParams.append('autoplay', String(
|
|
56
|
-
validURL.searchParams.append('muted', String(
|
|
57
|
-
validURL.searchParams.append('loop', String(
|
|
58
|
-
validURL.searchParams.append('pip', String(
|
|
48
|
+
validURL.searchParams.append('controls', String(params.controls));
|
|
49
|
+
validURL.searchParams.append('autoplay', String(params.play === 'auto'));
|
|
50
|
+
validURL.searchParams.append('muted', String(params.muted));
|
|
51
|
+
validURL.searchParams.append('loop', String(params.loop));
|
|
52
|
+
validURL.searchParams.append('pip', String(params.pictureInPicture));
|
|
59
53
|
validURL.searchParams.append('title', '0');
|
|
60
54
|
validURL.searchParams.append('byline', '0');
|
|
61
55
|
validURL.searchParams.append('portrait', '0');
|
|
62
56
|
validURL.searchParams.append('autopause', 'false');
|
|
63
57
|
return validURL.href;
|
|
64
|
-
}, [url,
|
|
58
|
+
}, [url, params]);
|
|
65
59
|
(0, react_1.useEffect)(() => {
|
|
66
|
-
if (!vimeoPlayer || !imgRef
|
|
60
|
+
if (!vimeoPlayer || !imgRef)
|
|
67
61
|
return;
|
|
68
|
-
if (
|
|
62
|
+
if (params.play === 'on-click') {
|
|
69
63
|
setIsCoverVisible(true);
|
|
70
64
|
}
|
|
71
65
|
vimeoPlayer.on('pause', (e) => {
|
|
@@ -76,7 +70,7 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibili
|
|
|
76
70
|
vimeoPlayer.on('ended', () => {
|
|
77
71
|
setIsCoverVisible(true);
|
|
78
72
|
});
|
|
79
|
-
}, [vimeoPlayer, imgRef,
|
|
73
|
+
}, [vimeoPlayer, imgRef, params]);
|
|
80
74
|
const handleClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
81
75
|
if (!vimeoPlayer)
|
|
82
76
|
return;
|
|
@@ -116,15 +110,15 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibili
|
|
|
116
110
|
}
|
|
117
111
|
});
|
|
118
112
|
}, [interactionCtrl, vimeoPlayer]);
|
|
119
|
-
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_e = item.link) === null || _e === void 0 ? void 0 : _e.url, target: (_f = item.link) === null || _f === void 0 ? void 0 : _f.target, children: [(0, jsx_runtime_1.jsxs)("div", { className: `embed-video-wrapper-${item.id}`, ref: setRef, style: Object.assign(Object.assign(
|
|
120
|
-
if (!vimeoPlayer ||
|
|
113
|
+
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_e = item.link) === null || _e === void 0 ? void 0 : _e.url, target: (_f = item.link) === null || _f === void 0 ? void 0 : _f.target, children: [(0, jsx_runtime_1.jsxs)("div", { className: `embed-video-wrapper-${item.id}`, ref: setRef, style: Object.assign(Object.assign({ opacity, transform: `rotate(${angle}deg)` }, (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_g = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _g !== void 0 ? _g : 'none' }), onMouseEnter: () => {
|
|
114
|
+
if (!vimeoPlayer || params.play !== 'on-hover')
|
|
121
115
|
return;
|
|
122
116
|
vimeoPlayer.play();
|
|
123
117
|
}, onMouseLeave: () => {
|
|
124
|
-
if (!vimeoPlayer ||
|
|
118
|
+
if (!vimeoPlayer || params.play !== 'on-hover')
|
|
125
119
|
return;
|
|
126
120
|
vimeoPlayer.pause();
|
|
127
|
-
}, children: [
|
|
121
|
+
}, children: [params.coverUrl && ((0, jsx_runtime_1.jsx)("img", { ref: setImgRef, onClick: () => onCoverClick(), src: (_h = params.coverUrl) !== null && _h !== void 0 ? _h : '', style: {
|
|
128
122
|
display: isCoverVisible ? 'block' : 'none',
|
|
129
123
|
cursor: 'pointer',
|
|
130
124
|
position: 'absolute',
|
|
@@ -133,17 +127,24 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibili
|
|
|
133
127
|
width: '100%',
|
|
134
128
|
top: '0',
|
|
135
129
|
left: '0'
|
|
136
|
-
}, alt: "Cover img" })),
|
|
130
|
+
}, alt: "Cover img" })), params && (!params.controls && (params.play === 'on-click' || params.play === 'auto')) && ((0, jsx_runtime_1.jsx)("div", { onClick: handleClick, style: {
|
|
137
131
|
position: 'absolute',
|
|
138
132
|
height: '100%',
|
|
139
133
|
width: '100%',
|
|
140
134
|
top: '0',
|
|
141
135
|
left: '0'
|
|
142
|
-
} })), (0, jsx_runtime_1.jsx)("iframe", { ref: setIframeRef, className: "embed-video", src: validUrl || '', allow: "autoplay; fullscreen; picture-in-picture;", allowFullScreen: true, style:
|
|
136
|
+
} })), (0, jsx_runtime_1.jsx)("iframe", { ref: setIframeRef, className: "embed-video", src: validUrl || '', allow: "autoplay; fullscreen; picture-in-picture;", allowFullScreen: true, style: {
|
|
137
|
+
borderRadius: `${radius * 100}vw`,
|
|
138
|
+
transition: (_j = frameStateParams === null || frameStateParams === void 0 ? void 0 : frameStateParams.transition) !== null && _j !== void 0 ? _j : 'none'
|
|
139
|
+
} })] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
143
140
|
.embed-video-wrapper-${item.id} {
|
|
144
141
|
position: absolute;
|
|
145
142
|
width: 100%;
|
|
146
143
|
height: 100%;
|
|
144
|
+
opacity: ${params.opacity};
|
|
145
|
+
transform: rotate(${item.area.angle}deg);
|
|
146
|
+
filter: ${params.blur !== 0 ? `blur(${params.blur * 100}vw)` : 'unset'};
|
|
147
|
+
${params.blur !== 0 ? 'will-change: transform;' : ''}
|
|
147
148
|
}
|
|
148
149
|
.embed-video {
|
|
149
150
|
width: 100%;
|
|
@@ -152,19 +153,9 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibili
|
|
|
152
153
|
border: none;
|
|
153
154
|
overflow: hidden;
|
|
154
155
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
opacity: ${layoutParams.opacity};
|
|
159
|
-
transform: rotate(${area.angle}deg);
|
|
160
|
-
filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
|
|
161
|
-
${layoutParams.blur !== 0 ? 'will-change: transform;' : ''}
|
|
162
|
-
}
|
|
163
|
-
.embed-video-wrapper-${item.id} .embed-video {
|
|
164
|
-
border-radius: ${layoutParams.radius * 100}vw;
|
|
165
|
-
}
|
|
166
|
-
`);
|
|
167
|
-
})}
|
|
156
|
+
.embed-video-wrapper-${item.id} .embed-video {
|
|
157
|
+
border-radius: ${params.radius * 100}vw;
|
|
158
|
+
}
|
|
168
159
|
` })] }));
|
|
169
160
|
};
|
|
170
161
|
exports.VimeoEmbedItem = VimeoEmbedItem;
|
|
@@ -11,19 +11,14 @@ const LinkWrapper_1 = require("../LinkWrapper");
|
|
|
11
11
|
const getValidYoutubeUrl_1 = require("../../../utils/getValidYoutubeUrl");
|
|
12
12
|
const useEmbedVideoItem_1 = require("./useEmbedVideoItem");
|
|
13
13
|
const useItemAngle_1 = require("../useItemAngle");
|
|
14
|
-
const useCntrlContext_1 = require("../../../provider/useCntrlContext");
|
|
15
14
|
const useYouTubeIframeApi_1 = require("../../../utils/Youtube/useYouTubeIframeApi");
|
|
16
15
|
const useRegisterResize_1 = require("../../../common/useRegisterResize");
|
|
17
16
|
const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromItemStateAndParams");
|
|
18
|
-
const useLayoutContext_1 = require("../../useLayoutContext");
|
|
19
|
-
const utils_1 = require("../../../../utils");
|
|
20
17
|
const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
21
18
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
22
19
|
const id = (0, react_1.useId)();
|
|
23
|
-
const {
|
|
24
|
-
const
|
|
25
|
-
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
26
|
-
const layoutParams = layoutId ? item.layoutParams[layoutId] : null;
|
|
20
|
+
const { url } = item.params;
|
|
21
|
+
const params = item.params;
|
|
27
22
|
const { radius: itemRadius, blur: itemBlur, opacity: itemOpacity } = (0, useEmbedVideoItem_1.useEmbedVideoItem)(item, sectionId);
|
|
28
23
|
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
29
24
|
const YT = (0, useYouTubeIframeApi_1.useYouTubeIframeApi)();
|
|
@@ -31,7 +26,6 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibi
|
|
|
31
26
|
const [player, setPlayer] = (0, react_1.useState)(undefined);
|
|
32
27
|
const [isCoverVisible, setIsCoverVisible] = (0, react_1.useState)(false);
|
|
33
28
|
const [imgRef, setImgRef] = (0, react_1.useState)(null);
|
|
34
|
-
const layoutValues = [item.area, item.layoutParams];
|
|
35
29
|
const wrapperStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['angle', 'blur', 'opacity']);
|
|
36
30
|
const frameStateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['radius']);
|
|
37
31
|
const angle = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_a = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _a === void 0 ? void 0 : _a.angle, itemAngle);
|
|
@@ -46,9 +40,9 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibi
|
|
|
46
40
|
(0, react_1.useEffect)(() => {
|
|
47
41
|
const newUrl = new URL(url);
|
|
48
42
|
const videoId = (0, getValidYoutubeUrl_1.getYoutubeId)(newUrl);
|
|
49
|
-
if (!YT || !videoId || !div
|
|
43
|
+
if (!YT || !videoId || !div)
|
|
50
44
|
return;
|
|
51
|
-
const { play, controls } =
|
|
45
|
+
const { play, controls } = params;
|
|
52
46
|
const placeholder = document.createElement('div');
|
|
53
47
|
div.appendChild(placeholder);
|
|
54
48
|
const player = new YT.Player(placeholder, {
|
|
@@ -82,7 +76,7 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibi
|
|
|
82
76
|
player.destroy();
|
|
83
77
|
(_a = placeholder.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(placeholder);
|
|
84
78
|
};
|
|
85
|
-
}, [YT, div,
|
|
79
|
+
}, [YT, div, params]);
|
|
86
80
|
const onCoverClick = () => {
|
|
87
81
|
if (!player || !imgRef)
|
|
88
82
|
return;
|
|
@@ -90,10 +84,10 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibi
|
|
|
90
84
|
setIsCoverVisible(false);
|
|
91
85
|
};
|
|
92
86
|
(0, react_1.useEffect)(() => {
|
|
93
|
-
if (
|
|
87
|
+
if (params.play === 'on-click' && !params.controls) {
|
|
94
88
|
setIsCoverVisible(true);
|
|
95
89
|
}
|
|
96
|
-
}, [
|
|
90
|
+
}, [params]);
|
|
97
91
|
(0, react_1.useEffect)(() => {
|
|
98
92
|
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
99
93
|
if (!isInteractive && player) {
|
|
@@ -115,14 +109,14 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibi
|
|
|
115
109
|
});
|
|
116
110
|
}, [interactionCtrl, player]);
|
|
117
111
|
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_e = item.link) === null || _e === void 0 ? void 0 : _e.url, target: (_f = item.link) === null || _f === void 0 ? void 0 : _f.target, children: [(0, jsx_runtime_1.jsxs)("div", { className: `embed-youtube-video-wrapper-${item.id}`, onMouseEnter: () => {
|
|
118
|
-
if (!player ||
|
|
112
|
+
if (!player || params.play !== 'on-hover')
|
|
119
113
|
return;
|
|
120
114
|
player.playVideo();
|
|
121
115
|
}, onMouseLeave: () => {
|
|
122
|
-
if (!player ||
|
|
116
|
+
if (!player || params.play !== 'on-hover')
|
|
123
117
|
return;
|
|
124
118
|
player.pauseVideo();
|
|
125
|
-
}, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_g = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _g !== void 0 ? _g : 'none' }), children: [
|
|
119
|
+
}, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_g = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _g !== void 0 ? _g : 'none' }), children: [params.coverUrl && ((0, jsx_runtime_1.jsx)("img", { ref: setImgRef, onClick: () => onCoverClick(), src: (_h = params.coverUrl) !== null && _h !== void 0 ? _h : '', style: {
|
|
126
120
|
display: isCoverVisible ? 'block' : 'none',
|
|
127
121
|
cursor: 'pointer',
|
|
128
122
|
position: 'absolute',
|
|
@@ -138,6 +132,7 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibi
|
|
|
138
132
|
position: absolute;
|
|
139
133
|
width: 100%;
|
|
140
134
|
height: 100%;
|
|
135
|
+
border-radius: ${params.radius * 100}vw;
|
|
141
136
|
}
|
|
142
137
|
.embed-${item.id} {
|
|
143
138
|
overflow: hidden;
|
|
@@ -148,19 +143,12 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibi
|
|
|
148
143
|
z-index: 1;
|
|
149
144
|
border: none;
|
|
150
145
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
${layoutParams.blur !== 0 ? 'will-change: transform;' : ''}
|
|
158
|
-
}
|
|
159
|
-
.embed-youtube-video-wrapper-${item.id} .embed-${item.id} {
|
|
160
|
-
border-radius: ${layoutParams.radius * 100}vw;
|
|
161
|
-
}
|
|
162
|
-
`);
|
|
163
|
-
})}
|
|
146
|
+
.embed-youtube-video-wrapper-${item.id} {
|
|
147
|
+
opacity: ${params.opacity};
|
|
148
|
+
transform: rotate(${item.area.angle}deg);
|
|
149
|
+
filter: ${params.blur !== 0 ? `blur(${params.blur * 100}vw)` : 'unset'};
|
|
150
|
+
${params.blur !== 0 ? 'will-change: transform;' : ''}
|
|
151
|
+
}
|
|
164
152
|
` })] }));
|
|
165
153
|
};
|
|
166
154
|
exports.YoutubeEmbedItem = YoutubeEmbedItem;
|