@cntrl-site/sdk-nextjs 1.1.5 → 1.2.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.
Files changed (75) hide show
  1. package/.idea/modules.xml +8 -0
  2. package/.idea/sdk-nextjs.iml +12 -0
  3. package/.idea/vcs.xml +6 -0
  4. package/cntrl-site-sdk-nextjs-1.2.3.tgz +0 -0
  5. package/lib/components/Article.js +2 -2
  6. package/lib/components/{Section.js → Section/Section.js} +2 -2
  7. package/lib/components/{useSectionHeightMap.js → Section/useSectionHeightMap.js} +1 -1
  8. package/lib/components/items/{CodeEmbedItem.js → CodeEmbedItem/CodeEmbedItem.js} +2 -2
  9. package/lib/components/items/{useCodeEmbedItem.js → CodeEmbedItem/useCodeEmbedItem.js} +2 -2
  10. package/lib/components/items/CompoundItem/CompoundChild.js +115 -0
  11. package/lib/components/items/CompoundItem/CompoundItem.js +52 -0
  12. package/lib/components/items/CompoundItem/useCompoundItem.js +17 -0
  13. package/lib/components/items/{CustomItem.js → CustomItem/CustomItem.js} +2 -2
  14. package/lib/components/items/{VimeoEmbed.js → EmbedVideoItem/VimeoEmbed.js} +10 -13
  15. package/lib/components/items/{YoutubeEmbed.js → EmbedVideoItem/YoutubeEmbed.js} +5 -5
  16. package/lib/components/items/{useEmbedVideoItem.js → EmbedVideoItem/useEmbedVideoItem.js} +2 -2
  17. package/lib/components/items/{ImageItem.js → FileItem/ImageItem.js} +6 -6
  18. package/lib/components/items/{VideoItem.js → FileItem/VideoItem.js} +5 -5
  19. package/lib/components/items/{useFileItem.js → FileItem/useFileItem.js} +2 -2
  20. package/lib/components/items/{GroupItem.js → GroupItem/GroupItem.js} +5 -5
  21. package/lib/components/items/{useGroupItem.js → GroupItem/useGroupItem.js} +2 -2
  22. package/lib/components/{Item.js → items/Item.js} +24 -47
  23. package/lib/components/items/{RectangleItem.js → RectangleItem/RectangleItem.js} +3 -3
  24. package/lib/components/items/{useRectangleItem.js → RectangleItem/useRectangleItem.js} +2 -2
  25. package/lib/components/items/{RichTextItem.js → RichTextItem/RichTextItem.js} +7 -7
  26. package/lib/components/items/{useRichTextItem.js → RichTextItem/useRichTextItem.js} +2 -2
  27. package/lib/components/items/RichTextWrapper.js +10 -0
  28. package/lib/components/items/itemsMap.js +26 -0
  29. package/lib/components/{useItemAngle.js → items/useItemAngle.js} +1 -1
  30. package/lib/components/{useItemDimensions.js → items/useItemDimensions.js} +2 -2
  31. package/lib/components/{useItemPosition.js → items/useItemPosition.js} +4 -9
  32. package/lib/components/{useItemScale.js → items/useItemScale.js} +2 -2
  33. package/lib/index.js +8 -8
  34. package/lib/interactions/InteractionsRegistry.js +6 -6
  35. package/lib/utils/RichTextConverter/RichTextConverter.js +1 -1
  36. package/lib/utils/getCompoundBondaryStyles.js +61 -0
  37. package/lib/utils/isItemType.js +7 -0
  38. package/package.json +18 -19
  39. package/src/components/Article.tsx +2 -2
  40. package/src/components/{Section.tsx → Section/Section.tsx} +2 -2
  41. package/src/components/{useSectionColor.ts → Section/useSectionColor.ts} +1 -1
  42. package/src/components/{useSectionHeightMap.ts → Section/useSectionHeightMap.ts} +1 -1
  43. package/src/components/items/{CodeEmbedItem.tsx → CodeEmbedItem/CodeEmbedItem.tsx} +2 -2
  44. package/src/components/items/{useCodeEmbedItem.ts → CodeEmbedItem/useCodeEmbedItem.ts} +2 -2
  45. package/src/components/items/CompoundItem/CompoundChild.tsx +160 -0
  46. package/src/components/items/CompoundItem/CompoundItem.tsx +70 -0
  47. package/src/components/items/CompoundItem/useCompoundItem.ts +21 -0
  48. package/src/components/items/{CustomItem.tsx → CustomItem/CustomItem.tsx} +2 -2
  49. package/src/components/items/{VimeoEmbed.tsx → EmbedVideoItem/VimeoEmbed.tsx} +19 -28
  50. package/src/components/items/{YoutubeEmbed.tsx → EmbedVideoItem/YoutubeEmbed.tsx} +6 -6
  51. package/src/components/items/{useEmbedVideoItem.ts → EmbedVideoItem/useEmbedVideoItem.ts} +2 -2
  52. package/src/components/items/{ImageItem.tsx → FileItem/ImageItem.tsx} +6 -6
  53. package/src/components/items/{VideoItem.tsx → FileItem/VideoItem.tsx} +5 -5
  54. package/src/components/items/{useFileItem.ts → FileItem/useFileItem.ts} +2 -2
  55. package/src/components/items/{GroupItem.tsx → GroupItem/GroupItem.tsx} +4 -5
  56. package/src/components/items/{useGroupItem.ts → GroupItem/useGroupItem.ts} +2 -2
  57. package/src/components/{Item.tsx → items/Item.tsx} +24 -59
  58. package/src/components/items/{RectangleItem.tsx → RectangleItem/RectangleItem.tsx} +3 -3
  59. package/src/components/items/{useRectangleItem.ts → RectangleItem/useRectangleItem.ts} +2 -2
  60. package/src/components/items/{RichTextItem.tsx → RichTextItem/RichTextItem.tsx} +7 -7
  61. package/src/components/items/{useRichTextItem.ts → RichTextItem/useRichTextItem.ts} +2 -2
  62. package/src/components/items/RichTextWrapper.tsx +15 -0
  63. package/src/components/items/itemsMap.ts +26 -0
  64. package/src/components/{useItemAngle.ts → items/useItemAngle.ts} +1 -1
  65. package/src/components/{useItemDimensions.ts → items/useItemDimensions.ts} +2 -2
  66. package/src/components/{useItemPosition.ts → items/useItemPosition.ts} +6 -9
  67. package/src/components/{useItemScale.ts → items/useItemScale.ts} +2 -2
  68. package/src/index.ts +8 -8
  69. package/src/interactions/InteractionsRegistry.ts +6 -5
  70. package/src/utils/RichTextConverter/RichTextConverter.tsx +1 -1
  71. package/src/utils/getCompoundBondaryStyles.ts +62 -0
  72. package/src/utils/isItemType.ts +6 -0
  73. package/eslint.config.mjs +0 -18
  74. /package/lib/components/{LinkWrapper.js → items/LinkWrapper.js} +0 -0
  75. /package/src/components/{LinkWrapper.tsx → items/LinkWrapper.tsx} +0 -0
@@ -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
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
Binary file
@@ -7,8 +7,8 @@ exports.Article = 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 Section_1 = require("./Section");
11
- const Item_1 = require("./Item");
10
+ const Section_1 = require("./Section/Section");
11
+ const Item_1 = require("./items/Item");
12
12
  const useArticleRectObserver_1 = require("../utils/ArticleRectManager/useArticleRectObserver");
13
13
  const ArticleRectContext_1 = require("../provider/ArticleRectContext");
14
14
  const ArticleWrapper_1 = require("./ArticleWrapper");
@@ -8,8 +8,8 @@ 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
10
  const sdk_1 = require("@cntrl-site/sdk");
11
- const useCntrlContext_1 = require("../provider/useCntrlContext");
12
- const useSectionRegistry_1 = require("../utils/ArticleRectManager/useSectionRegistry");
11
+ const useCntrlContext_1 = require("../../provider/useCntrlContext");
12
+ const useSectionRegistry_1 = require("../../utils/ArticleRectManager/useSectionRegistry");
13
13
  const color_1 = require("@cntrl-site/color");
14
14
  const DEFAULT_COLOR = 'rgba(0, 0, 0, 0)';
15
15
  const Section = ({ section, data, children }) => {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getSectionHeightMap = exports.useSectionHeightData = void 0;
4
4
  const react_1 = require("react");
5
- const CntrlContext_1 = require("../provider/CntrlContext");
5
+ const CntrlContext_1 = require("../../provider/CntrlContext");
6
6
  const Section_1 = require("./Section");
7
7
  const useSectionHeightData = (sectionId) => {
8
8
  const sectionHeightContext = (0, react_1.useContext)(CntrlContext_1.CntrlContext);
@@ -7,9 +7,9 @@ exports.CodeEmbedItem = void 0;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const sdk_1 = require("@cntrl-site/sdk");
9
9
  const react_1 = require("react");
10
- const useCntrlContext_1 = require("../../provider/useCntrlContext");
10
+ const useCntrlContext_1 = require("../../../provider/useCntrlContext");
11
11
  const style_1 = __importDefault(require("styled-jsx/style"));
12
- const useRegisterResize_1 = require("../../common/useRegisterResize");
12
+ const useRegisterResize_1 = require("../../../common/useRegisterResize");
13
13
  const useItemAngle_1 = require("../useItemAngle");
14
14
  const LinkWrapper_1 = require("../LinkWrapper");
15
15
  const useCodeEmbedItem_1 = require("./useCodeEmbedItem");
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useCodeEmbedItem = void 0;
4
4
  const sdk_1 = require("@cntrl-site/sdk");
5
- const useLayoutContext_1 = require("../useLayoutContext");
6
- const useKeyframeValue_1 = require("../../common/useKeyframeValue");
5
+ const useLayoutContext_1 = require("../../useLayoutContext");
6
+ const useKeyframeValue_1 = require("../../../common/useKeyframeValue");
7
7
  const useCodeEmbedItem = (item, sectionId) => {
8
8
  const layoutId = (0, useLayoutContext_1.useLayoutContext)();
9
9
  const blur = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Blur, (item, layoutId) => {
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CompoundChild = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const react_1 = require("react");
9
+ const useCntrlContext_1 = require("../../../provider/useCntrlContext");
10
+ const useLayoutContext_1 = require("../../useLayoutContext");
11
+ const useExemplary_1 = require("../../../common/useExemplary");
12
+ const useItemScale_1 = require("../useItemScale");
13
+ const useItemInteractionCtrl_1 = require("../../../interactions/useItemInteractionCtrl");
14
+ const useItemPosition_1 = require("../useItemPosition");
15
+ const useItemDimensions_1 = require("../useItemDimensions");
16
+ const sdk_1 = require("@cntrl-site/sdk");
17
+ const style_1 = __importDefault(require("styled-jsx/style"));
18
+ const ScaleAnchorMap_1 = require("../../../utils/ScaleAnchorMap");
19
+ const isItemType_1 = require("../../../utils/isItemType");
20
+ const RichTextWrapper_1 = require("../RichTextWrapper");
21
+ const itemsMap_1 = require("../itemsMap");
22
+ const getCompoundBondaryStyles_1 = require("../../../utils/getCompoundBondaryStyles");
23
+ const noop = () => null;
24
+ const CompoundChild = ({ item, sectionId, isParentVisible = true }) => {
25
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
26
+ const id = (0, react_1.useId)();
27
+ const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
28
+ const layout = (0, useLayoutContext_1.useLayoutContext)();
29
+ const exemplary = (0, useExemplary_1.useExemplary)();
30
+ const [allowPointerEvents, setAllowPointerEvents] = (0, react_1.useState)(isParentVisible);
31
+ const itemScale = (0, useItemScale_1.useItemScale)(item, sectionId);
32
+ const interactionCtrl = (0, useItemInteractionCtrl_1.useItemInteractionCtrl)(item.id);
33
+ const wrapperStateProps = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['top', 'left']);
34
+ const innerStateProps = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['width', 'height', 'scale']);
35
+ const position = (0, useItemPosition_1.useItemPosition)(item, sectionId, {
36
+ top: (_a = wrapperStateProps === null || wrapperStateProps === void 0 ? void 0 : wrapperStateProps.styles) === null || _a === void 0 ? void 0 : _a.top,
37
+ left: (_b = wrapperStateProps === null || wrapperStateProps === void 0 ? void 0 : wrapperStateProps.styles) === null || _b === void 0 ? void 0 : _b.left,
38
+ });
39
+ const compoundSettings = layout && item.compoundSettings ? item.compoundSettings[layout] : undefined;
40
+ const dimensions = (0, useItemDimensions_1.useItemDimensions)(item, sectionId);
41
+ const isInitialRef = (0, react_1.useRef)(true);
42
+ const sizing = layout && (0, isItemType_1.isItemType)(item, sdk_1.ArticleItemType.RichText)
43
+ ? item.layoutParams[layout].sizing
44
+ : undefined;
45
+ const sizingAxis = parseSizing(sizing);
46
+ const ItemComponent = itemsMap_1.itemsMap[item.type] || noop;
47
+ const handleVisibilityChange = (0, react_1.useCallback)((isVisible) => {
48
+ if (!isParentVisible)
49
+ return;
50
+ setAllowPointerEvents(isVisible);
51
+ }, [isParentVisible]);
52
+ (0, react_1.useEffect)(() => {
53
+ isInitialRef.current = false;
54
+ }, []);
55
+ const transformOrigin = compoundSettings ? ScaleAnchorMap_1.ScaleAnchorMap[compoundSettings.positionAnchor] : 'top left';
56
+ const isRichText = (0, isItemType_1.isItemType)(item, sdk_1.ArticleItemType.RichText);
57
+ const width = ((_d = (_c = innerStateProps === null || innerStateProps === void 0 ? void 0 : innerStateProps.styles) === null || _c === void 0 ? void 0 : _c.width) !== null && _d !== void 0 ? _d : dimensions === null || dimensions === void 0 ? void 0 : dimensions.width);
58
+ const height = ((_f = (_e = innerStateProps === null || innerStateProps === void 0 ? void 0 : innerStateProps.styles) === null || _e === void 0 ? void 0 : _e.height) !== null && _f !== void 0 ? _f : dimensions === null || dimensions === void 0 ? void 0 : dimensions.height);
59
+ 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;
60
+ const hasClickTriggers = (_j = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getHasTrigger(item.id, 'click')) !== null && _j !== void 0 ? _j : false;
61
+ if (!item.compoundSettings)
62
+ return null;
63
+ const layoutValues = [item.area, item.hidden, item.compoundSettings];
64
+ if (item.layoutParams) {
65
+ layoutValues.push(item.layoutParams);
66
+ }
67
+ return ((0, jsx_runtime_1.jsxs)("div", { className: `item-${item.id}`, onTransitionEnd: (e) => {
68
+ var _a;
69
+ e.stopPropagation();
70
+ (_a = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.handleTransitionEnd) === null || _a === void 0 ? void 0 : _a.call(interactionCtrl, e.propertyName);
71
+ }, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (position && compoundSettings ? { top: (0, getCompoundBondaryStyles_1.getCompoundTop)(compoundSettings, position.top) } : {})), (position && compoundSettings ? { left: (0, getCompoundBondaryStyles_1.getCompoundLeft)(compoundSettings, position.left) } : {})), (width && compoundSettings
72
+ ? { width: `${sizingAxis.x === 'manual'
73
+ ? (0, getCompoundBondaryStyles_1.getCompoundWidth)(compoundSettings, width, isRichText, exemplary)
74
+ : 'max-content'}` }
75
+ : {})), (height && compoundSettings
76
+ ? { height: `${sizingAxis.y === 'manual'
77
+ ? (0, getCompoundBondaryStyles_1.getCompoundHeight)(compoundSettings, height)
78
+ : 'unset'}` }
79
+ : {})), (scale && compoundSettings ? { transform: `scale(${scale}) ${(0, getCompoundBondaryStyles_1.getCompoundTransform)(compoundSettings)}` } : {})), { transition: (_k = innerStateProps === null || innerStateProps === void 0 ? void 0 : innerStateProps.transition) !== null && _k !== void 0 ? _k : 'none', cursor: hasClickTriggers ? 'pointer' : 'unset', pointerEvents: allowPointerEvents ? 'auto' : 'none' }), onClick: () => {
80
+ interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.sendTrigger('click');
81
+ }, onMouseEnter: () => {
82
+ interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.sendTrigger('hover-in');
83
+ }, onMouseLeave: () => {
84
+ interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.sendTrigger('hover-out');
85
+ }, 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 }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
86
+ ${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, hidden, compoundSettings, layoutParams]) => {
87
+ const sizingAxis = parseSizing(layoutParams.sizing);
88
+ const scaleAnchor = area.scaleAnchor;
89
+ return (`
90
+ .item-${item.id} {
91
+ position: absolute;
92
+ top: ${(0, getCompoundBondaryStyles_1.getCompoundTop)(compoundSettings, area.top)};
93
+ left: ${(0, getCompoundBondaryStyles_1.getCompoundLeft)(compoundSettings, area.left)};
94
+ transition: opacity 0.2s linear 0.1s;
95
+ display: ${hidden ? 'none' : 'block'};
96
+ width: ${sizingAxis.x === 'manual'
97
+ ? `${(0, getCompoundBondaryStyles_1.getCompoundWidth)(compoundSettings, area.width, isRichText)}`
98
+ : 'max-content'};
99
+ height: ${sizingAxis.y === 'manual' ? `${(0, getCompoundBondaryStyles_1.getCompoundHeight)(compoundSettings, area.height)}` : 'unset'};
100
+ transform-origin: ${ScaleAnchorMap_1.ScaleAnchorMap[scaleAnchor]};
101
+ transform: scale(${area.scale}) ${(0, getCompoundBondaryStyles_1.getCompoundTransform)(compoundSettings)};
102
+ z-index: ${area.zIndex};
103
+ }
104
+ `);
105
+ })}
106
+ ` })] }));
107
+ };
108
+ exports.CompoundChild = CompoundChild;
109
+ function parseSizing(sizing = 'manual') {
110
+ const axisSizing = sizing.split(' ');
111
+ return {
112
+ y: axisSizing[0],
113
+ x: axisSizing[1] ? axisSizing[1] : axisSizing[0]
114
+ };
115
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CompoundItem = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const react_1 = require("react");
9
+ const useItemAngle_1 = require("../useItemAngle");
10
+ const useCntrlContext_1 = require("../../../provider/useCntrlContext");
11
+ const useRegisterResize_1 = require("../../../common/useRegisterResize");
12
+ const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromItemStateAndParams");
13
+ const LinkWrapper_1 = require("../LinkWrapper");
14
+ const style_1 = __importDefault(require("styled-jsx/style"));
15
+ const sdk_1 = require("@cntrl-site/sdk");
16
+ const CompoundChild_1 = require("./CompoundChild");
17
+ const useCompoundItem_1 = require("./useCompoundItem");
18
+ const CompoundItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
19
+ var _a, _b, _c, _d, _e;
20
+ const id = (0, react_1.useId)();
21
+ const { items } = item;
22
+ const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
23
+ const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
24
+ const { opacity: itemOpacity } = (0, useCompoundItem_1.useCompoundItem)(item, sectionId);
25
+ const layoutValues = [item.area, item.layoutParams];
26
+ const [ref, setRef] = (0, react_1.useState)(null);
27
+ (0, useRegisterResize_1.useRegisterResize)(ref, onResize);
28
+ const stateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['opacity', 'angle']);
29
+ const angle = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_a = stateParams === null || stateParams === void 0 ? void 0 : stateParams.styles) === null || _a === void 0 ? void 0 : _a.angle, itemAngle);
30
+ 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
+ const isInteractive = opacity !== 0 && opacity !== undefined;
32
+ (0, react_1.useEffect)(() => {
33
+ onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
34
+ }, [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: Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), { transition: (_e = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _e !== void 0 ? _e : 'none' }), 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
+ .compound-${item.id} {
37
+ position: absolute;
38
+ width: 100%;
39
+ height: 100%;
40
+ box-sizing: border-box;
41
+ }
42
+ ${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
43
+ return (`
44
+ .compound-${item.id} {
45
+ opacity: ${layoutParams.opacity};
46
+ transform: rotate(${area.angle}deg);
47
+ }
48
+ `);
49
+ })}
50
+ ` })] }) }));
51
+ };
52
+ exports.CompoundItem = CompoundItem;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCompoundItem = void 0;
4
+ const sdk_1 = require("@cntrl-site/sdk");
5
+ const useLayoutContext_1 = require("../../useLayoutContext");
6
+ const useKeyframeValue_1 = require("../../../common/useKeyframeValue");
7
+ function useCompoundItem(item, sectionId) {
8
+ const layoutId = (0, useLayoutContext_1.useLayoutContext)();
9
+ const opacity = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_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]);
15
+ return { opacity };
16
+ }
17
+ exports.useCompoundItem = useCompoundItem;
@@ -7,9 +7,9 @@ exports.CustomItem = void 0;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const sdk_1 = require("@cntrl-site/sdk");
9
9
  const react_1 = require("react");
10
- const useCntrlContext_1 = require("../../provider/useCntrlContext");
10
+ const useCntrlContext_1 = require("../../../provider/useCntrlContext");
11
11
  const style_1 = __importDefault(require("styled-jsx/style"));
12
- const useRegisterResize_1 = require("../../common/useRegisterResize");
12
+ const useRegisterResize_1 = require("../../../common/useRegisterResize");
13
13
  const useItemAngle_1 = require("../useItemAngle");
14
14
  const CustomItem = ({ item, onResize, sectionId, interactionCtrl }) => {
15
15
  var _a, _b, _c;
@@ -14,16 +14,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.VimeoEmbedItem = void 0;
16
16
  const jsx_runtime_1 = require("react/jsx-runtime");
17
- const sdk_1 = require("@cntrl-site/sdk");
18
- const player_1 = __importDefault(require("@vimeo/player"));
19
17
  const react_1 = require("react");
18
+ const player_1 = __importDefault(require("@vimeo/player"));
20
19
  const style_1 = __importDefault(require("styled-jsx/style"));
21
- const useRegisterResize_1 = require("../../common/useRegisterResize");
22
- const useCntrlContext_1 = require("../../provider/useCntrlContext");
23
- const getStyleFromItemStateAndParams_1 = require("../../utils/getStyleFromItemStateAndParams");
24
20
  const LinkWrapper_1 = require("../LinkWrapper");
25
- const useItemAngle_1 = require("../useItemAngle");
26
21
  const useEmbedVideoItem_1 = require("./useEmbedVideoItem");
22
+ const useItemAngle_1 = require("../useItemAngle");
23
+ const sdk_1 = require("@cntrl-site/sdk");
24
+ const useCntrlContext_1 = require("../../../provider/useCntrlContext");
25
+ const useRegisterResize_1 = require("../../../common/useRegisterResize");
26
+ const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromItemStateAndParams");
27
27
  const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
28
28
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
29
29
  const id = (0, react_1.useId)();
@@ -48,7 +48,7 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibili
48
48
  const validURL = new URL(url);
49
49
  validURL.searchParams.append('controls', String(controls));
50
50
  validURL.searchParams.append('autoplay', String(play === 'auto'));
51
- validURL.searchParams.append('muted', String(muted));
51
+ validURL.searchParams.append('muted', String(play !== 'on-click' ? true : muted));
52
52
  validURL.searchParams.append('loop', String(loop));
53
53
  validURL.searchParams.append('pip', String(pictureInPicture));
54
54
  validURL.searchParams.append('title', '0');
@@ -61,7 +61,7 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibili
61
61
  (0, react_1.useEffect)(() => {
62
62
  if (!vimeoPlayer || !imgRef)
63
63
  return;
64
- if (play === 'on-click') {
64
+ if (play === 'on-click' && !controls) {
65
65
  setIsCoverVisible(true);
66
66
  }
67
67
  vimeoPlayer.on('pause', (e) => {
@@ -69,9 +69,6 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibili
69
69
  setIsCoverVisible(true);
70
70
  }
71
71
  });
72
- vimeoPlayer.on('ended', () => {
73
- setIsCoverVisible(true);
74
- });
75
72
  }, [vimeoPlayer, imgRef]);
76
73
  const handleClick = () => __awaiter(void 0, void 0, void 0, function* () {
77
74
  if (!vimeoPlayer)
@@ -112,13 +109,13 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibili
112
109
  width: '100%',
113
110
  top: '0',
114
111
  left: '0'
115
- }, alt: "Cover img" })), (!item.commonParams.controls && (play === 'on-click' || play === 'auto')) && ((0, jsx_runtime_1.jsx)("div", { onClick: handleClick, style: {
112
+ }, alt: "Cover img" })), (!item.commonParams.controls && play === 'on-click') && ((0, jsx_runtime_1.jsx)("div", { onClick: handleClick, style: {
116
113
  position: 'absolute',
117
114
  height: '100%',
118
115
  width: '100%',
119
116
  top: '0',
120
117
  left: '0'
121
- } })), (0, jsx_runtime_1.jsx)("iframe", { ref: setIframeRef, className: "embed-video", src: validUrl || '', allow: "autoplay; fullscreen; picture-in-picture;", allowFullScreen: true, style: Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), { transition: (_j = frameStateParams === null || frameStateParams === void 0 ? void 0 : frameStateParams.transition) !== null && _j !== void 0 ? _j : 'none' }) })] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
118
+ } })), (0, jsx_runtime_1.jsx)("iframe", { ref: setIframeRef, className: `embed-video`, src: validUrl || '', allow: "autoplay; fullscreen; picture-in-picture;", allowFullScreen: true, style: Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), { transition: (_j = frameStateParams === null || frameStateParams === void 0 ? void 0 : frameStateParams.transition) !== null && _j !== void 0 ? _j : 'none' }) })] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
122
119
  .embed-video-wrapper-${item.id} {
123
120
  position: absolute;
124
121
  width: 100%;
@@ -8,14 +8,14 @@ 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
10
  const LinkWrapper_1 = require("../LinkWrapper");
11
- const getValidYoutubeUrl_1 = require("../../utils/getValidYoutubeUrl");
11
+ const getValidYoutubeUrl_1 = require("../../../utils/getValidYoutubeUrl");
12
12
  const useEmbedVideoItem_1 = require("./useEmbedVideoItem");
13
13
  const useItemAngle_1 = require("../useItemAngle");
14
14
  const sdk_1 = require("@cntrl-site/sdk");
15
- const useCntrlContext_1 = require("../../provider/useCntrlContext");
16
- const useYouTubeIframeApi_1 = require("../../utils/Youtube/useYouTubeIframeApi");
17
- const useRegisterResize_1 = require("../../common/useRegisterResize");
18
- const getStyleFromItemStateAndParams_1 = require("../../utils/getStyleFromItemStateAndParams");
15
+ const useCntrlContext_1 = require("../../../provider/useCntrlContext");
16
+ const useYouTubeIframeApi_1 = require("../../../utils/Youtube/useYouTubeIframeApi");
17
+ const useRegisterResize_1 = require("../../../common/useRegisterResize");
18
+ const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromItemStateAndParams");
19
19
  const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
20
20
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
21
21
  const id = (0, react_1.useId)();
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useEmbedVideoItem = void 0;
4
4
  const sdk_1 = require("@cntrl-site/sdk");
5
- const useKeyframeValue_1 = require("../../common/useKeyframeValue");
6
- const useLayoutContext_1 = require("../useLayoutContext");
5
+ const useKeyframeValue_1 = require("../../../common/useKeyframeValue");
6
+ const useLayoutContext_1 = require("../../useLayoutContext");
7
7
  const useEmbedVideoItem = (item, sectionId) => {
8
8
  const layoutId = (0, useLayoutContext_1.useLayoutContext)();
9
9
  const radius = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.BorderRadius, (item, layoutId) => {
@@ -12,12 +12,12 @@ const sdk_1 = require("@cntrl-site/sdk");
12
12
  const LinkWrapper_1 = require("../LinkWrapper");
13
13
  const useFileItem_1 = require("./useFileItem");
14
14
  const useItemAngle_1 = require("../useItemAngle");
15
- const useCntrlContext_1 = require("../../provider/useCntrlContext");
16
- const useRegisterResize_1 = require("../../common/useRegisterResize");
17
- const useImageFx_1 = require("../../utils/effects/useImageFx");
18
- const useElementRect_1 = require("../../utils/useElementRect");
19
- const useLayoutContext_1 = require("../useLayoutContext");
20
- const getStyleFromItemStateAndParams_1 = require("../../utils/getStyleFromItemStateAndParams");
15
+ const useCntrlContext_1 = require("../../../provider/useCntrlContext");
16
+ const useRegisterResize_1 = require("../../../common/useRegisterResize");
17
+ const useImageFx_1 = require("../../../utils/effects/useImageFx");
18
+ const useElementRect_1 = require("../../../utils/useElementRect");
19
+ const useLayoutContext_1 = require("../../useLayoutContext");
20
+ const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromItemStateAndParams");
21
21
  const baseVariables = `precision mediump float;
22
22
  uniform sampler2D u_image;
23
23
  uniform sampler2D u_pattern;
@@ -12,11 +12,11 @@ const sdk_1 = require("@cntrl-site/sdk");
12
12
  const LinkWrapper_1 = require("../LinkWrapper");
13
13
  const useFileItem_1 = require("./useFileItem");
14
14
  const useItemAngle_1 = require("../useItemAngle");
15
- const useCntrlContext_1 = require("../../provider/useCntrlContext");
16
- const useRegisterResize_1 = require("../../common/useRegisterResize");
17
- const useLayoutContext_1 = require("../useLayoutContext");
18
- const ScrollPlaybackVideo_1 = require("../ScrollPlaybackVideo");
19
- const getStyleFromItemStateAndParams_1 = require("../../utils/getStyleFromItemStateAndParams");
15
+ const useCntrlContext_1 = require("../../../provider/useCntrlContext");
16
+ const useRegisterResize_1 = require("../../../common/useRegisterResize");
17
+ const useLayoutContext_1 = require("../../useLayoutContext");
18
+ const ScrollPlaybackVideo_1 = require("../../ScrollPlaybackVideo");
19
+ const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromItemStateAndParams");
20
20
  const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
21
21
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
22
22
  const id = (0, react_1.useId)();
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useFileItem = void 0;
4
4
  const sdk_1 = require("@cntrl-site/sdk");
5
- const useKeyframeValue_1 = require("../../common/useKeyframeValue");
6
- const useLayoutContext_1 = require("../useLayoutContext");
5
+ const useKeyframeValue_1 = require("../../../common/useKeyframeValue");
6
+ const useLayoutContext_1 = require("../../useLayoutContext");
7
7
  const DEFAULT_COLOR = 'rgba(0, 0, 0, 1)';
8
8
  const useFileItem = (item, sectionId) => {
9
9
  const layoutId = (0, useLayoutContext_1.useLayoutContext)();
@@ -10,12 +10,12 @@ const Item_1 = require("../Item");
10
10
  const style_1 = __importDefault(require("styled-jsx/style"));
11
11
  const sdk_1 = require("@cntrl-site/sdk");
12
12
  const LinkWrapper_1 = require("../LinkWrapper");
13
- const useRegisterResize_1 = require("../../common/useRegisterResize");
14
- const useCntrlContext_1 = require("../../provider/useCntrlContext");
13
+ const useRegisterResize_1 = require("../../../common/useRegisterResize");
14
+ const useCntrlContext_1 = require("../../../provider/useCntrlContext");
15
15
  const useItemAngle_1 = require("../useItemAngle");
16
16
  const useGroupItem_1 = require("./useGroupItem");
17
- const getStyleFromItemStateAndParams_1 = require("../../utils/getStyleFromItemStateAndParams");
18
- const GroupItem = ({ item, sectionId, onResize, articleHeight, interactionCtrl, onVisibilityChange }) => {
17
+ const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromItemStateAndParams");
18
+ const GroupItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
19
19
  var _a, _b, _c, _d, _e;
20
20
  const id = (0, react_1.useId)();
21
21
  const { items } = item;
@@ -32,7 +32,7 @@ const GroupItem = ({ item, sectionId, onResize, articleHeight, interactionCtrl,
32
32
  (0, react_1.useEffect)(() => {
33
33
  onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
34
34
  }, [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: `group-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), { transition: (_e = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _e !== void 0 ? _e : 'none' }), children: items && items.map(item => ((0, jsx_runtime_1.jsx)(Item_1.Item, { item: item, sectionId: sectionId, articleHeight: articleHeight, isParentVisible: isInteractive, isInGroup: true }, item.id))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
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: `group-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), { transition: (_e = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _e !== void 0 ? _e : 'none' }), children: items && items.map(item => ((0, jsx_runtime_1.jsx)(Item_1.Item, { item: item, sectionId: sectionId, isParentVisible: isInteractive, isInGroup: true }, item.id))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
36
36
  .group-${item.id} {
37
37
  position: absolute;
38
38
  width: 100%;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useGroupItem = void 0;
4
- const useKeyframeValue_1 = require("../../common/useKeyframeValue");
4
+ const useKeyframeValue_1 = require("../../../common/useKeyframeValue");
5
5
  const sdk_1 = require("@cntrl-site/sdk");
6
- const useLayoutContext_1 = require("../useLayoutContext");
6
+ const useLayoutContext_1 = require("../../useLayoutContext");
7
7
  function useGroupItem(item, sectionId) {
8
8
  const layoutId = (0, useLayoutContext_1.useLayoutContext)();
9
9
  const opacity = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Opacity, (item, layoutId) => {