@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.
- package/.idea/modules.xml +8 -0
- package/.idea/sdk-nextjs.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/cntrl-site-sdk-nextjs-1.2.3.tgz +0 -0
- package/lib/components/Article.js +2 -2
- package/lib/components/{Section.js → Section/Section.js} +2 -2
- package/lib/components/{useSectionHeightMap.js → Section/useSectionHeightMap.js} +1 -1
- package/lib/components/items/{CodeEmbedItem.js → CodeEmbedItem/CodeEmbedItem.js} +2 -2
- package/lib/components/items/{useCodeEmbedItem.js → CodeEmbedItem/useCodeEmbedItem.js} +2 -2
- package/lib/components/items/CompoundItem/CompoundChild.js +115 -0
- package/lib/components/items/CompoundItem/CompoundItem.js +52 -0
- package/lib/components/items/CompoundItem/useCompoundItem.js +17 -0
- package/lib/components/items/{CustomItem.js → CustomItem/CustomItem.js} +2 -2
- package/lib/components/items/{VimeoEmbed.js → EmbedVideoItem/VimeoEmbed.js} +10 -13
- package/lib/components/items/{YoutubeEmbed.js → EmbedVideoItem/YoutubeEmbed.js} +5 -5
- package/lib/components/items/{useEmbedVideoItem.js → EmbedVideoItem/useEmbedVideoItem.js} +2 -2
- package/lib/components/items/{ImageItem.js → FileItem/ImageItem.js} +6 -6
- package/lib/components/items/{VideoItem.js → FileItem/VideoItem.js} +5 -5
- package/lib/components/items/{useFileItem.js → FileItem/useFileItem.js} +2 -2
- package/lib/components/items/{GroupItem.js → GroupItem/GroupItem.js} +5 -5
- package/lib/components/items/{useGroupItem.js → GroupItem/useGroupItem.js} +2 -2
- package/lib/components/{Item.js → items/Item.js} +24 -47
- package/lib/components/items/{RectangleItem.js → RectangleItem/RectangleItem.js} +3 -3
- package/lib/components/items/{useRectangleItem.js → RectangleItem/useRectangleItem.js} +2 -2
- package/lib/components/items/{RichTextItem.js → RichTextItem/RichTextItem.js} +7 -7
- package/lib/components/items/{useRichTextItem.js → RichTextItem/useRichTextItem.js} +2 -2
- package/lib/components/items/RichTextWrapper.js +10 -0
- package/lib/components/items/itemsMap.js +26 -0
- package/lib/components/{useItemAngle.js → items/useItemAngle.js} +1 -1
- package/lib/components/{useItemDimensions.js → items/useItemDimensions.js} +2 -2
- package/lib/components/{useItemPosition.js → items/useItemPosition.js} +4 -9
- package/lib/components/{useItemScale.js → items/useItemScale.js} +2 -2
- package/lib/index.js +8 -8
- package/lib/interactions/InteractionsRegistry.js +6 -6
- package/lib/utils/RichTextConverter/RichTextConverter.js +1 -1
- package/lib/utils/getCompoundBondaryStyles.js +61 -0
- package/lib/utils/isItemType.js +7 -0
- package/package.json +18 -19
- package/src/components/Article.tsx +2 -2
- package/src/components/{Section.tsx → Section/Section.tsx} +2 -2
- package/src/components/{useSectionColor.ts → Section/useSectionColor.ts} +1 -1
- package/src/components/{useSectionHeightMap.ts → Section/useSectionHeightMap.ts} +1 -1
- package/src/components/items/{CodeEmbedItem.tsx → CodeEmbedItem/CodeEmbedItem.tsx} +2 -2
- package/src/components/items/{useCodeEmbedItem.ts → CodeEmbedItem/useCodeEmbedItem.ts} +2 -2
- package/src/components/items/CompoundItem/CompoundChild.tsx +160 -0
- package/src/components/items/CompoundItem/CompoundItem.tsx +70 -0
- package/src/components/items/CompoundItem/useCompoundItem.ts +21 -0
- package/src/components/items/{CustomItem.tsx → CustomItem/CustomItem.tsx} +2 -2
- package/src/components/items/{VimeoEmbed.tsx → EmbedVideoItem/VimeoEmbed.tsx} +19 -28
- package/src/components/items/{YoutubeEmbed.tsx → EmbedVideoItem/YoutubeEmbed.tsx} +6 -6
- package/src/components/items/{useEmbedVideoItem.ts → EmbedVideoItem/useEmbedVideoItem.ts} +2 -2
- package/src/components/items/{ImageItem.tsx → FileItem/ImageItem.tsx} +6 -6
- package/src/components/items/{VideoItem.tsx → FileItem/VideoItem.tsx} +5 -5
- package/src/components/items/{useFileItem.ts → FileItem/useFileItem.ts} +2 -2
- package/src/components/items/{GroupItem.tsx → GroupItem/GroupItem.tsx} +4 -5
- package/src/components/items/{useGroupItem.ts → GroupItem/useGroupItem.ts} +2 -2
- package/src/components/{Item.tsx → items/Item.tsx} +24 -59
- package/src/components/items/{RectangleItem.tsx → RectangleItem/RectangleItem.tsx} +3 -3
- package/src/components/items/{useRectangleItem.ts → RectangleItem/useRectangleItem.ts} +2 -2
- package/src/components/items/{RichTextItem.tsx → RichTextItem/RichTextItem.tsx} +7 -7
- package/src/components/items/{useRichTextItem.ts → RichTextItem/useRichTextItem.ts} +2 -2
- package/src/components/items/RichTextWrapper.tsx +15 -0
- package/src/components/items/itemsMap.ts +26 -0
- package/src/components/{useItemAngle.ts → items/useItemAngle.ts} +1 -1
- package/src/components/{useItemDimensions.ts → items/useItemDimensions.ts} +2 -2
- package/src/components/{useItemPosition.ts → items/useItemPosition.ts} +6 -9
- package/src/components/{useItemScale.ts → items/useItemScale.ts} +2 -2
- package/src/index.ts +8 -8
- package/src/interactions/InteractionsRegistry.ts +6 -5
- package/src/utils/RichTextConverter/RichTextConverter.tsx +1 -1
- package/src/utils/getCompoundBondaryStyles.ts +62 -0
- package/src/utils/isItemType.ts +6 -0
- package/eslint.config.mjs +0 -18
- /package/lib/components/{LinkWrapper.js → items/LinkWrapper.js} +0 -0
- /package/src/components/{LinkWrapper.tsx → items/LinkWrapper.tsx} +0 -0
|
@@ -3,54 +3,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.Item = 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
10
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
11
|
-
const
|
|
12
|
-
const ImageItem_1 = require("./items/ImageItem");
|
|
13
|
-
const VideoItem_1 = require("./items/VideoItem");
|
|
14
|
-
const RichTextItem_1 = require("./items/RichTextItem");
|
|
15
|
-
const VimeoEmbed_1 = require("./items/VimeoEmbed");
|
|
16
|
-
const YoutubeEmbed_1 = require("./items/YoutubeEmbed");
|
|
17
|
-
const CustomItem_1 = require("./items/CustomItem");
|
|
18
|
-
const useCntrlContext_1 = require("../provider/useCntrlContext");
|
|
11
|
+
const useCntrlContext_1 = require("../../provider/useCntrlContext");
|
|
19
12
|
const useItemPosition_1 = require("./useItemPosition");
|
|
20
13
|
const useItemDimensions_1 = require("./useItemDimensions");
|
|
21
14
|
const useItemScale_1 = require("./useItemScale");
|
|
22
|
-
const ScaleAnchorMap_1 = require("
|
|
23
|
-
const useSectionHeightMap_1 = require("
|
|
24
|
-
const getItemTopStyle_1 = require("
|
|
25
|
-
const useStickyItemTop_1 = require("./
|
|
26
|
-
const getAnchoredItemTop_1 = require("
|
|
27
|
-
const useLayoutContext_1 = require("
|
|
28
|
-
const ArticleRectContext_1 = require("
|
|
29
|
-
const useExemplary_1 = require("
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
[sdk_1.ArticleItemType.Rectangle]: RectangleItem_1.RectangleItem,
|
|
36
|
-
[sdk_1.ArticleItemType.Image]: ImageItem_1.ImageItem,
|
|
37
|
-
[sdk_1.ArticleItemType.Video]: VideoItem_1.VideoItem,
|
|
38
|
-
[sdk_1.ArticleItemType.RichText]: RichTextItem_1.RichTextItem,
|
|
39
|
-
[sdk_1.ArticleItemType.YoutubeEmbed]: YoutubeEmbed_1.YoutubeEmbedItem,
|
|
40
|
-
[sdk_1.ArticleItemType.VimeoEmbed]: VimeoEmbed_1.VimeoEmbedItem,
|
|
41
|
-
[sdk_1.ArticleItemType.Custom]: CustomItem_1.CustomItem,
|
|
42
|
-
[sdk_1.ArticleItemType.Group]: GroupItem_1.GroupItem,
|
|
43
|
-
[sdk_1.ArticleItemType.CodeEmbed]: CodeEmbedItem_1.CodeEmbedItem
|
|
44
|
-
};
|
|
15
|
+
const ScaleAnchorMap_1 = require("../../utils/ScaleAnchorMap");
|
|
16
|
+
const useSectionHeightMap_1 = require("../Section/useSectionHeightMap");
|
|
17
|
+
const getItemTopStyle_1 = require("../../utils/getItemTopStyle");
|
|
18
|
+
const useStickyItemTop_1 = require("./useStickyItemTop");
|
|
19
|
+
const getAnchoredItemTop_1 = require("../../utils/getAnchoredItemTop");
|
|
20
|
+
const useLayoutContext_1 = require("../useLayoutContext");
|
|
21
|
+
const ArticleRectContext_1 = require("../../provider/ArticleRectContext");
|
|
22
|
+
const useExemplary_1 = require("../../common/useExemplary");
|
|
23
|
+
const KeyframesContext_1 = require("../../provider/KeyframesContext");
|
|
24
|
+
const useItemInteractionCtrl_1 = require("../../interactions/useItemInteractionCtrl");
|
|
25
|
+
const isItemType_1 = require("../../utils/isItemType");
|
|
26
|
+
const RichTextWrapper_1 = require("./RichTextWrapper");
|
|
27
|
+
const itemsMap_1 = require("./itemsMap");
|
|
45
28
|
const stickyFix = `
|
|
46
29
|
-webkit-transform: translate3d(0, 0, 0);
|
|
47
30
|
transform: translate3d(0, 0, 0);
|
|
48
31
|
`;
|
|
49
|
-
const RichTextWrapper = ({ isRichText, children }) => {
|
|
50
|
-
if (!isRichText)
|
|
51
|
-
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
|
|
52
|
-
return ((0, jsx_runtime_1.jsx)("div", { style: { transformOrigin: 'top left', transform: 'scale(var(--layout-deviation))' }, children: children }));
|
|
53
|
-
};
|
|
54
32
|
const noop = () => null;
|
|
55
33
|
const Item = ({ item, sectionId, articleHeight, isParentVisible = true, isInGroup = false }) => {
|
|
56
34
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
@@ -84,17 +62,17 @@ const Item = ({ item, sectionId, articleHeight, isParentVisible = true, isInGrou
|
|
|
84
62
|
if (item.layoutParams) {
|
|
85
63
|
layoutValues.push(item.layoutParams);
|
|
86
64
|
}
|
|
87
|
-
const sizing = layout && isItemType(item, sdk_1.ArticleItemType.RichText)
|
|
65
|
+
const sizing = layout && (0, isItemType_1.isItemType)(item, sdk_1.ArticleItemType.RichText)
|
|
88
66
|
? item.layoutParams[layout].sizing
|
|
89
67
|
: undefined;
|
|
90
68
|
const sizingAxis = parseSizing(sizing);
|
|
91
|
-
const ItemComponent = itemsMap[item.type] || noop;
|
|
69
|
+
const ItemComponent = itemsMap_1.itemsMap[item.type] || noop;
|
|
92
70
|
const sectionTop = rectObserver ? rectObserver.getSectionTop(sectionId) : 0;
|
|
93
71
|
const handleItemResize = (height) => {
|
|
94
72
|
if (!layout)
|
|
95
73
|
return;
|
|
96
74
|
const sticky = item.sticky[layout];
|
|
97
|
-
if (!sticky || stickyTop === undefined) {
|
|
75
|
+
if (!sticky || stickyTop === undefined || !articleHeight) {
|
|
98
76
|
setWrapperHeight(undefined);
|
|
99
77
|
return;
|
|
100
78
|
}
|
|
@@ -115,20 +93,23 @@ const Item = ({ item, sectionId, articleHeight, isParentVisible = true, isInGrou
|
|
|
115
93
|
(0, react_1.useEffect)(() => {
|
|
116
94
|
isInitialRef.current = false;
|
|
117
95
|
}, []);
|
|
118
|
-
const isRichText = isItemType(item, sdk_1.ArticleItemType.RichText);
|
|
96
|
+
const isRichText = (0, isItemType_1.isItemType)(item, sdk_1.ArticleItemType.RichText);
|
|
119
97
|
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);
|
|
120
98
|
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);
|
|
99
|
+
const anchorSide = layout ? item.area[layout].anchorSide : sdk_1.AnchorSide.Top;
|
|
100
|
+
const positionType = layout ? item.area[layout].positionType : sdk_1.PositionType.ScreenBased;
|
|
101
|
+
const isScreenBasedBottom = positionType === sdk_1.PositionType.ScreenBased && anchorSide === sdk_1.AnchorSide.Bottom;
|
|
121
102
|
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;
|
|
122
103
|
const hasClickTriggers = (_j = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getHasTrigger(item.id, 'click')) !== null && _j !== void 0 ? _j : false;
|
|
123
104
|
return ((0, jsx_runtime_1.jsxs)("div", { className: `item-wrapper-${item.id}`, ref: itemWrapperRef, onTransitionEnd: (e) => {
|
|
124
105
|
var _a;
|
|
125
106
|
e.stopPropagation();
|
|
126
107
|
(_a = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.handleTransitionEnd) === null || _a === void 0 ? void 0 : _a.call(interactionCtrl, e.propertyName);
|
|
127
|
-
}, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (position ? { top: position.top } : {})), (position ? { left: position.left } : {})), (position ? { bottom: position.
|
|
108
|
+
}, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (position ? { top: isScreenBasedBottom ? 'unset' : (0, getItemTopStyle_1.getItemTopStyle)(position.top, anchorSide) } : {})), (position ? { left: `${position.left * 100}vw` } : {})), (position ? { bottom: isScreenBasedBottom ? `${-position.top * 100}vw` : 'unset' } : {})), (wrapperHeight !== undefined ? { height: `${wrapperHeight * 100}vw` } : {})), { transition: (_k = wrapperStateProps === null || wrapperStateProps === void 0 ? void 0 : wrapperStateProps.transition) !== null && _k !== void 0 ? _k : 'none' }), children: [(0, jsx_runtime_1.jsx)("div", { suppressHydrationWarning: true, className: `item-${item.id}`, style: {
|
|
128
109
|
opacity: (keyframes.length !== 0 && !layout) ? 0 : 1,
|
|
129
110
|
top: `${stickyTop * 100}vw`,
|
|
130
111
|
height: isRichText && itemHeight ? `${itemHeight * 100}vw` : 'unset',
|
|
131
|
-
}, children: (0, jsx_runtime_1.jsx)(RichTextWrapper, { isRichText: isRichText, children: (0, jsx_runtime_1.jsx)("div", { className: `item-${item.id}-inner`, ref: itemInnerRef, onClick: () => {
|
|
112
|
+
}, children: (0, jsx_runtime_1.jsx)(RichTextWrapper_1.RichTextWrapper, { isRichText: isRichText, children: (0, jsx_runtime_1.jsx)("div", { className: `item-${item.id}-inner`, ref: itemInnerRef, onClick: () => {
|
|
132
113
|
interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.sendTrigger('click');
|
|
133
114
|
}, onMouseEnter: () => {
|
|
134
115
|
interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.sendTrigger('hover-in');
|
|
@@ -184,7 +165,3 @@ function parseSizing(sizing = 'manual') {
|
|
|
184
165
|
x: axisSizing[1] ? axisSizing[1] : axisSizing[0]
|
|
185
166
|
};
|
|
186
167
|
}
|
|
187
|
-
function isItemType(item, itemType) {
|
|
188
|
-
return item.type === itemType;
|
|
189
|
-
}
|
|
190
|
-
exports.isItemType = isItemType;
|
|
@@ -12,9 +12,9 @@ const sdk_1 = require("@cntrl-site/sdk");
|
|
|
12
12
|
const LinkWrapper_1 = require("../LinkWrapper");
|
|
13
13
|
const useRectangleItem_1 = require("./useRectangleItem");
|
|
14
14
|
const useItemAngle_1 = require("../useItemAngle");
|
|
15
|
-
const useCntrlContext_1 = require("
|
|
16
|
-
const useRegisterResize_1 = require("
|
|
17
|
-
const getStyleFromItemStateAndParams_1 = require("
|
|
15
|
+
const useCntrlContext_1 = require("../../../provider/useCntrlContext");
|
|
16
|
+
const useRegisterResize_1 = require("../../../common/useRegisterResize");
|
|
17
|
+
const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromItemStateAndParams");
|
|
18
18
|
const RectangleItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
19
19
|
var _a, _b, _c, _d;
|
|
20
20
|
const id = (0, react_1.useId)();
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useRectangleItem = void 0;
|
|
4
4
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
5
|
-
const useKeyframeValue_1 = require("
|
|
6
|
-
const useLayoutContext_1 = require("
|
|
5
|
+
const useKeyframeValue_1 = require("../../../common/useKeyframeValue");
|
|
6
|
+
const useLayoutContext_1 = require("../../useLayoutContext");
|
|
7
7
|
const defaultColor = 'rgba(0, 0, 0, 1)';
|
|
8
8
|
const useRectangleItem = (item, sectionId) => {
|
|
9
9
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
@@ -10,14 +10,14 @@ const color_1 = require("@cntrl-site/color");
|
|
|
10
10
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
11
11
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
12
12
|
const useRichTextItem_1 = require("./useRichTextItem");
|
|
13
|
-
const useCntrlContext_1 = require("
|
|
14
|
-
const useRichTextItemValues_1 = require("
|
|
15
|
-
const useRegisterResize_1 = require("
|
|
16
|
-
const getFontFamilyValue_1 = require("
|
|
17
|
-
const useExemplary_1 = require("
|
|
13
|
+
const useCntrlContext_1 = require("../../../provider/useCntrlContext");
|
|
14
|
+
const useRichTextItemValues_1 = require("../useRichTextItemValues");
|
|
15
|
+
const useRegisterResize_1 = require("../../../common/useRegisterResize");
|
|
16
|
+
const getFontFamilyValue_1 = require("../../../utils/getFontFamilyValue");
|
|
17
|
+
const useExemplary_1 = require("../../../common/useExemplary");
|
|
18
18
|
const useItemAngle_1 = require("../useItemAngle");
|
|
19
|
-
const getStyleFromItemStateAndParams_1 = require("
|
|
20
|
-
const useCurrentLayout_1 = require("
|
|
19
|
+
const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromItemStateAndParams");
|
|
20
|
+
const useCurrentLayout_1 = require("../../../common/useCurrentLayout");
|
|
21
21
|
const RichTextItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
22
22
|
var _a, _b, _c, _d;
|
|
23
23
|
const id = (0, react_1.useId)();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useRichTextItem = void 0;
|
|
4
|
-
const RichTextConverter_1 = require("
|
|
5
|
-
const useCntrlContext_1 = require("
|
|
4
|
+
const RichTextConverter_1 = require("../../../utils/RichTextConverter/RichTextConverter");
|
|
5
|
+
const useCntrlContext_1 = require("../../../provider/useCntrlContext");
|
|
6
6
|
const richTextConverter = new RichTextConverter_1.RichTextConverter();
|
|
7
7
|
const useRichTextItem = (item) => {
|
|
8
8
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RichTextWrapper = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const RichTextWrapper = ({ isRichText, children, transformOrigin = 'top left' }) => {
|
|
6
|
+
if (!isRichText)
|
|
7
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { transformOrigin, transform: 'scale(var(--layout-deviation))' }, children: children }));
|
|
9
|
+
};
|
|
10
|
+
exports.RichTextWrapper = RichTextWrapper;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.itemsMap = void 0;
|
|
4
|
+
const sdk_1 = require("@cntrl-site/sdk");
|
|
5
|
+
const RectangleItem_1 = require("./RectangleItem/RectangleItem");
|
|
6
|
+
const ImageItem_1 = require("./FileItem/ImageItem");
|
|
7
|
+
const VideoItem_1 = require("./FileItem/VideoItem");
|
|
8
|
+
const RichTextItem_1 = require("./RichTextItem/RichTextItem");
|
|
9
|
+
const YoutubeEmbed_1 = require("./EmbedVideoItem/YoutubeEmbed");
|
|
10
|
+
const VimeoEmbed_1 = require("./EmbedVideoItem/VimeoEmbed");
|
|
11
|
+
const CustomItem_1 = require("./CustomItem/CustomItem");
|
|
12
|
+
const GroupItem_1 = require("./GroupItem/GroupItem");
|
|
13
|
+
const CodeEmbedItem_1 = require("./CodeEmbedItem/CodeEmbedItem");
|
|
14
|
+
const CompoundItem_1 = require("./CompoundItem/CompoundItem");
|
|
15
|
+
exports.itemsMap = {
|
|
16
|
+
[sdk_1.ArticleItemType.Rectangle]: RectangleItem_1.RectangleItem,
|
|
17
|
+
[sdk_1.ArticleItemType.Image]: ImageItem_1.ImageItem,
|
|
18
|
+
[sdk_1.ArticleItemType.Video]: VideoItem_1.VideoItem,
|
|
19
|
+
[sdk_1.ArticleItemType.RichText]: RichTextItem_1.RichTextItem,
|
|
20
|
+
[sdk_1.ArticleItemType.YoutubeEmbed]: YoutubeEmbed_1.YoutubeEmbedItem,
|
|
21
|
+
[sdk_1.ArticleItemType.VimeoEmbed]: VimeoEmbed_1.VimeoEmbedItem,
|
|
22
|
+
[sdk_1.ArticleItemType.Custom]: CustomItem_1.CustomItem,
|
|
23
|
+
[sdk_1.ArticleItemType.Group]: GroupItem_1.GroupItem,
|
|
24
|
+
[sdk_1.ArticleItemType.Compound]: CompoundItem_1.CompoundItem,
|
|
25
|
+
[sdk_1.ArticleItemType.CodeEmbed]: CodeEmbedItem_1.CodeEmbedItem
|
|
26
|
+
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useItemAngle = void 0;
|
|
4
4
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
5
|
-
const useKeyframeValue_1 = require("
|
|
5
|
+
const useKeyframeValue_1 = require("../../common/useKeyframeValue");
|
|
6
6
|
const useItemAngle = (item, sectionId) => {
|
|
7
7
|
const angle = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Rotation, (item, layoutId) => layoutId ? item.area[layoutId].angle : undefined, (animator, scroll, value) => value !== undefined ? animator.getRotation({ angle: value }, scroll).angle : undefined, sectionId);
|
|
8
8
|
return angle;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useItemDimensions = void 0;
|
|
4
4
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
5
|
-
const useKeyframeValue_1 = require("
|
|
6
|
-
const useLayoutContext_1 = require("
|
|
5
|
+
const useKeyframeValue_1 = require("../../common/useKeyframeValue");
|
|
6
|
+
const useLayoutContext_1 = require("../useLayoutContext");
|
|
7
7
|
const useItemDimensions = (item, sectionId) => {
|
|
8
8
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
9
9
|
const dimensions = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Dimensions, (item, layoutId) => layoutId ? item.area[layoutId] : undefined, (animator, scroll, value) => value ? animator.getDimensions(value, scroll) : undefined, sectionId, [layoutId]);
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useItemPosition = void 0;
|
|
4
4
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
5
|
-
const useKeyframeValue_1 = require("
|
|
6
|
-
const
|
|
7
|
-
const useLayoutContext_1 = require("./useLayoutContext");
|
|
5
|
+
const useKeyframeValue_1 = require("../../common/useKeyframeValue");
|
|
6
|
+
const useLayoutContext_1 = require("../useLayoutContext");
|
|
8
7
|
const useItemPosition = (item, sectionId, stateValues) => {
|
|
9
8
|
var _a, _b;
|
|
10
9
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
@@ -13,18 +12,14 @@ const useItemPosition = (item, sectionId, stateValues) => {
|
|
|
13
12
|
return;
|
|
14
13
|
return item.area[layoutId];
|
|
15
14
|
}, (animator, scroll, value) => value ? animator.getPositions(value, scroll) : undefined, sectionId, [layoutId]);
|
|
16
|
-
const anchorSide = layoutId ? item.area[layoutId].anchorSide : sdk_1.AnchorSide.Top;
|
|
17
|
-
const positionType = layoutId ? item.area[layoutId].positionType : sdk_1.PositionType.ScreenBased;
|
|
18
15
|
// to prevent fixed item (with anchor point bottom) to jump when scroll in safari on mobile
|
|
19
|
-
const isScreenBasedBottom = positionType === sdk_1.PositionType.ScreenBased && anchorSide === sdk_1.AnchorSide.Bottom;
|
|
20
16
|
if (!position)
|
|
21
17
|
return undefined;
|
|
22
18
|
const top = (_a = stateValues === null || stateValues === void 0 ? void 0 : stateValues.top) !== null && _a !== void 0 ? _a : position.top;
|
|
23
19
|
const left = (_b = stateValues === null || stateValues === void 0 ? void 0 : stateValues.left) !== null && _b !== void 0 ? _b : position.left;
|
|
24
20
|
return position ? {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
left: `${left * 100}vw`
|
|
21
|
+
top,
|
|
22
|
+
left
|
|
28
23
|
} : undefined;
|
|
29
24
|
};
|
|
30
25
|
exports.useItemPosition = useItemPosition;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useItemScale = void 0;
|
|
4
4
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
5
|
-
const useKeyframeValue_1 = require("
|
|
6
|
-
const useLayoutContext_1 = require("
|
|
5
|
+
const useKeyframeValue_1 = require("../../common/useKeyframeValue");
|
|
6
|
+
const useLayoutContext_1 = require("../useLayoutContext");
|
|
7
7
|
const useItemScale = (item, sectionId) => {
|
|
8
8
|
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
9
9
|
const scale = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Scale, (item, layoutId) => (layoutId ? item.area[layoutId].scale : undefined), (animator, scroll, value) => value !== undefined ? animator.getScale({ scale: value }, scroll).scale : undefined, sectionId, [layoutId]);
|
package/lib/index.js
CHANGED
|
@@ -24,23 +24,23 @@ var Head_1 = require("./components/Head");
|
|
|
24
24
|
Object.defineProperty(exports, "Head", { enumerable: true, get: function () { return Head_1.CNTRLHead; } });
|
|
25
25
|
var Article_1 = require("./components/Article");
|
|
26
26
|
Object.defineProperty(exports, "Article", { enumerable: true, get: function () { return Article_1.Article; } });
|
|
27
|
-
var Section_1 = require("./components/Section");
|
|
27
|
+
var Section_1 = require("./components/Section/Section");
|
|
28
28
|
Object.defineProperty(exports, "Section", { enumerable: true, get: function () { return Section_1.Section; } });
|
|
29
|
-
var Item_1 = require("./components/Item");
|
|
29
|
+
var Item_1 = require("./components/items/Item");
|
|
30
30
|
Object.defineProperty(exports, "Item", { enumerable: true, get: function () { return Item_1.Item; } });
|
|
31
|
-
var ImageItem_1 = require("./components/items/ImageItem");
|
|
31
|
+
var ImageItem_1 = require("./components/items/FileItem/ImageItem");
|
|
32
32
|
Object.defineProperty(exports, "ImageItem", { enumerable: true, get: function () { return ImageItem_1.ImageItem; } });
|
|
33
|
-
var RectangleItem_1 = require("./components/items/RectangleItem");
|
|
33
|
+
var RectangleItem_1 = require("./components/items/RectangleItem/RectangleItem");
|
|
34
34
|
Object.defineProperty(exports, "RectangleItem", { enumerable: true, get: function () { return RectangleItem_1.RectangleItem; } });
|
|
35
|
-
var RichTextItem_1 = require("./components/items/RichTextItem");
|
|
35
|
+
var RichTextItem_1 = require("./components/items/RichTextItem/RichTextItem");
|
|
36
36
|
Object.defineProperty(exports, "RichTextItem", { enumerable: true, get: function () { return RichTextItem_1.RichTextItem; } });
|
|
37
|
-
var VideoItem_1 = require("./components/items/VideoItem");
|
|
37
|
+
var VideoItem_1 = require("./components/items/FileItem/VideoItem");
|
|
38
38
|
Object.defineProperty(exports, "VideoItem", { enumerable: true, get: function () { return VideoItem_1.VideoItem; } });
|
|
39
39
|
var LayoutStyle_1 = require("./components/LayoutStyle");
|
|
40
40
|
Object.defineProperty(exports, "LayoutStyle", { enumerable: true, get: function () { return LayoutStyle_1.LayoutStyle; } });
|
|
41
|
-
var VimeoEmbed_1 = require("./components/items/VimeoEmbed");
|
|
41
|
+
var VimeoEmbed_1 = require("./components/items/EmbedVideoItem/VimeoEmbed");
|
|
42
42
|
Object.defineProperty(exports, "VimeoEmbedItem", { enumerable: true, get: function () { return VimeoEmbed_1.VimeoEmbedItem; } });
|
|
43
|
-
var YoutubeEmbed_1 = require("./components/items/YoutubeEmbed");
|
|
43
|
+
var YoutubeEmbed_1 = require("./components/items/EmbedVideoItem/YoutubeEmbed");
|
|
44
44
|
Object.defineProperty(exports, "YoutubeEmbedItem", { enumerable: true, get: function () { return YoutubeEmbed_1.YoutubeEmbedItem; } });
|
|
45
45
|
const defaultContext_1 = require("./provider/defaultContext");
|
|
46
46
|
var CntrlProvider_1 = require("./provider/CntrlProvider");
|
|
@@ -13,7 +13,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.InteractionsRegistry = void 0;
|
|
15
15
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
16
|
-
const
|
|
16
|
+
const isItemType_1 = require("../utils/isItemType");
|
|
17
17
|
class InteractionsRegistry {
|
|
18
18
|
constructor(article, layoutId) {
|
|
19
19
|
this.layoutId = layoutId;
|
|
@@ -202,11 +202,11 @@ class InteractionsRegistry {
|
|
|
202
202
|
for (const item of section.items) {
|
|
203
203
|
const { items } = item, itemWithoutChildren = __rest(item, ["items"]);
|
|
204
204
|
itemsArr.push(itemWithoutChildren);
|
|
205
|
-
if (
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
205
|
+
if ((0, isItemType_1.isItemType)(item, sdk_1.ArticleItemType.Group) || (0, isItemType_1.isItemType)(item, sdk_1.ArticleItemType.Compound)) {
|
|
206
|
+
const groupChildren = (_a = item === null || item === void 0 ? void 0 : item.items) !== null && _a !== void 0 ? _a : [];
|
|
207
|
+
for (const child of groupChildren) {
|
|
208
|
+
itemsArr.push(child);
|
|
209
|
+
}
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
}
|
|
@@ -4,7 +4,7 @@ exports.RichTextConverter = exports.FontStyles = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const color_1 = require("@cntrl-site/color");
|
|
6
6
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
7
|
-
const LinkWrapper_1 = require("../../components/LinkWrapper");
|
|
7
|
+
const LinkWrapper_1 = require("../../components/items/LinkWrapper");
|
|
8
8
|
const getFontFamilyValue_1 = require("../getFontFamilyValue");
|
|
9
9
|
exports.FontStyles = {
|
|
10
10
|
'normal': {},
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCompoundTransform = exports.getCompoundLeft = exports.getCompoundTop = exports.getCompoundWidth = exports.getCompoundHeight = void 0;
|
|
4
|
+
const sdk_1 = require("@cntrl-site/sdk");
|
|
5
|
+
const positionMatrix = {
|
|
6
|
+
[sdk_1.AreaAnchor.TopLeft]: [0, 0],
|
|
7
|
+
[sdk_1.AreaAnchor.TopCenter]: [0, 0.5],
|
|
8
|
+
[sdk_1.AreaAnchor.TopRight]: [0, 1],
|
|
9
|
+
[sdk_1.AreaAnchor.MiddleLeft]: [0.5, 0],
|
|
10
|
+
[sdk_1.AreaAnchor.MiddleCenter]: [0.5, 0.5],
|
|
11
|
+
[sdk_1.AreaAnchor.MiddleRight]: [0.5, 1],
|
|
12
|
+
[sdk_1.AreaAnchor.BottomLeft]: [1, 0],
|
|
13
|
+
[sdk_1.AreaAnchor.BottomCenter]: [1, 0.5],
|
|
14
|
+
[sdk_1.AreaAnchor.BottomRight]: [1, 1]
|
|
15
|
+
};
|
|
16
|
+
function getCompoundHeight(compoundSettings, height) {
|
|
17
|
+
if (!height || !compoundSettings)
|
|
18
|
+
return;
|
|
19
|
+
if (compoundSettings.heightMode === 'relative') {
|
|
20
|
+
return `${height * 100}%`;
|
|
21
|
+
}
|
|
22
|
+
return `${height * 100}vw`;
|
|
23
|
+
}
|
|
24
|
+
exports.getCompoundHeight = getCompoundHeight;
|
|
25
|
+
function getCompoundWidth(compoundSettings, width, isRichText, exemplary) {
|
|
26
|
+
if (!width || !compoundSettings)
|
|
27
|
+
return;
|
|
28
|
+
if (compoundSettings.widthMode === 'relative') {
|
|
29
|
+
return `${width * 100}%`;
|
|
30
|
+
}
|
|
31
|
+
return isRichText && exemplary ? `${width * exemplary}px` : `${width * 100}vw`;
|
|
32
|
+
}
|
|
33
|
+
exports.getCompoundWidth = getCompoundWidth;
|
|
34
|
+
function getCompoundTop(compoundSettings, top) {
|
|
35
|
+
if (!top || !compoundSettings)
|
|
36
|
+
return;
|
|
37
|
+
if (compoundSettings.heightMode === 'relative') {
|
|
38
|
+
return `${top * 100}%`;
|
|
39
|
+
}
|
|
40
|
+
const [ky] = positionMatrix[compoundSettings.positionAnchor];
|
|
41
|
+
return `calc(${ky * 100}% + ${top * 100}vw)`;
|
|
42
|
+
}
|
|
43
|
+
exports.getCompoundTop = getCompoundTop;
|
|
44
|
+
function getCompoundLeft(compoundSettings, left) {
|
|
45
|
+
if (!left || !compoundSettings)
|
|
46
|
+
return;
|
|
47
|
+
if (compoundSettings.widthMode === 'relative') {
|
|
48
|
+
return `${left * 100}%`;
|
|
49
|
+
}
|
|
50
|
+
const [_, kx] = positionMatrix[compoundSettings.positionAnchor];
|
|
51
|
+
return `calc(${kx * 100}% + ${left * 100}vw)`;
|
|
52
|
+
}
|
|
53
|
+
exports.getCompoundLeft = getCompoundLeft;
|
|
54
|
+
function getCompoundTransform(compoundSettings) {
|
|
55
|
+
if (!compoundSettings)
|
|
56
|
+
return 'unset';
|
|
57
|
+
const areaAnchor = compoundSettings.positionAnchor;
|
|
58
|
+
const [ky, kx] = positionMatrix[areaAnchor];
|
|
59
|
+
return `translate(${kx * (-100)}%, ${ky * (-100)}%)`;
|
|
60
|
+
}
|
|
61
|
+
exports.getCompoundTransform = getCompoundTransform;
|
package/package.json
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cntrl-site/sdk-nextjs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "SDK for Next.js",
|
|
5
|
-
"author": "arsen@momdesign.nyc",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"homepage": "https://github.com/cntrl-site/sdk-nextjs#readme",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/cntrl-site/sdk-nextjs.git"
|
|
11
|
-
},
|
|
12
|
-
"bugs": {
|
|
13
|
-
"url": "https://github.com/cntrl-site/sdk-nextjs/issues"
|
|
14
|
-
},
|
|
15
5
|
"main": "lib/index.js",
|
|
16
6
|
"types": "src/index.ts",
|
|
17
7
|
"scripts": {
|
|
@@ -20,24 +10,33 @@
|
|
|
20
10
|
"build": "tsc --project tsconfig.build.json",
|
|
21
11
|
"prepublishOnly": "NODE_ENV=production npm run build"
|
|
22
12
|
},
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/cntrl-site/sdk-nextjs.git"
|
|
16
|
+
},
|
|
17
|
+
"author": "arsen@momdesign.nyc",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/cntrl-site/sdk-nextjs/issues"
|
|
29
21
|
},
|
|
22
|
+
"homepage": "https://github.com/cntrl-site/sdk-nextjs#readme",
|
|
30
23
|
"dependencies": {
|
|
31
|
-
"@antfu/eslint-config": "^3.8.0",
|
|
32
24
|
"@cntrl-site/color": "^1.0.0",
|
|
33
25
|
"@cntrl-site/effects": "^1.2.0",
|
|
34
|
-
"@cntrl-site/sdk": "^1.
|
|
26
|
+
"@cntrl-site/sdk": "^1.14.0",
|
|
35
27
|
"@types/vimeo__player": "^2.18.0",
|
|
36
28
|
"@vimeo/player": "^2.20.1",
|
|
37
29
|
"html-react-parser": "^3.0.1",
|
|
38
30
|
"resize-observer-polyfill": "^1.5.1",
|
|
39
31
|
"styled-jsx": "^5.0.2"
|
|
40
32
|
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@types/lodash.isequal": "^4.5.6",
|
|
35
|
+
"lodash.isequal": "^4.5.0",
|
|
36
|
+
"next": "^14.2.3",
|
|
37
|
+
"react": "^18.3.1",
|
|
38
|
+
"react-dom": "^18.3.1"
|
|
39
|
+
},
|
|
41
40
|
"devDependencies": {
|
|
42
41
|
"@testing-library/jest-dom": "^6.4.8",
|
|
43
42
|
"@testing-library/react": "^16.0.0",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FC, useEffect, useId, useRef, useState } from 'react';
|
|
2
2
|
import JSXStyle from 'styled-jsx/style';
|
|
3
3
|
import { Article as TArticle } from '@cntrl-site/sdk';
|
|
4
|
-
import { Section } from './Section';
|
|
5
|
-
import { Item } from './Item';
|
|
4
|
+
import { Section } from './Section/Section';
|
|
5
|
+
import { Item } from './items/Item';
|
|
6
6
|
import { useArticleRectObserver } from '../utils/ArticleRectManager/useArticleRectObserver';
|
|
7
7
|
import { ArticleRectContext } from '../provider/ArticleRectContext';
|
|
8
8
|
import { ArticleWrapper } from './ArticleWrapper';
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
SectionHeight,
|
|
8
8
|
SectionHeightMode
|
|
9
9
|
} from '@cntrl-site/sdk';
|
|
10
|
-
import { useCntrlContext } from '
|
|
11
|
-
import { useSectionRegistry } from '
|
|
10
|
+
import { useCntrlContext } from '../../provider/useCntrlContext';
|
|
11
|
+
import { useSectionRegistry } from '../../utils/ArticleRectManager/useSectionRegistry';
|
|
12
12
|
import { CntrlColor } from '@cntrl-site/color';
|
|
13
13
|
|
|
14
14
|
type SectionChild = ReactElement<any, any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { CntrlColor } from '@cntrl-site/color';
|
|
3
|
-
import { useLayoutContext } from '
|
|
3
|
+
import { useLayoutContext } from '../useLayoutContext';
|
|
4
4
|
|
|
5
5
|
type LayoutIdentifier = string;
|
|
6
6
|
const DEFAULT_COLOR = 'rgba(0, 0, 0, 0)';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getLayoutStyles, CodeEmbedItem as TCodeEmbedItem, AreaAnchor } from '@cntrl-site/sdk';
|
|
2
2
|
import { FC, useEffect, useId, useState } from 'react';
|
|
3
|
-
import { useCntrlContext } from '
|
|
3
|
+
import { useCntrlContext } from '../../../provider/useCntrlContext';
|
|
4
4
|
import { ItemProps } from '../Item';
|
|
5
5
|
import JSXStyle from 'styled-jsx/style';
|
|
6
|
-
import { useRegisterResize } from "
|
|
6
|
+
import { useRegisterResize } from "../../../common/useRegisterResize";
|
|
7
7
|
import { useItemAngle } from '../useItemAngle';
|
|
8
8
|
import { LinkWrapper } from '../LinkWrapper';
|
|
9
9
|
import { useCodeEmbedItem } from './useCodeEmbedItem';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CodeEmbedItem, AreaAnchor, KeyframeType } from '@cntrl-site/sdk';
|
|
2
|
-
import { useLayoutContext } from '
|
|
3
|
-
import { useKeyframeValue } from '
|
|
2
|
+
import { useLayoutContext } from '../../useLayoutContext';
|
|
3
|
+
import { useKeyframeValue } from '../../../common/useKeyframeValue';
|
|
4
4
|
|
|
5
5
|
export const useCodeEmbedItem = (item: CodeEmbedItem, sectionId: string) => {
|
|
6
6
|
const layoutId = useLayoutContext();
|