@cntrl-site/sdk-nextjs 1.0.19-alpha.6 → 1.0.19-alpha.7

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.
@@ -52,7 +52,7 @@ const RichTextWrapper = ({ isRichText, children }) => {
52
52
  return ((0, jsx_runtime_1.jsx)("div", { style: { transformOrigin: 'top left', transform: 'scale(var(--layout-deviation))' }, children: children }));
53
53
  };
54
54
  const noop = () => null;
55
- const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
55
+ const Item = ({ item, sectionId, articleHeight, isItemVisible = true, isInGroup = false }) => {
56
56
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
57
57
  const itemWrapperRef = (0, react_1.useRef)(null);
58
58
  const itemInnerRef = (0, react_1.useRef)(null);
@@ -134,7 +134,7 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
134
134
  : `${width * 100}vw`
135
135
  : 'max-content'}`,
136
136
  height: `${sizingAxis.y === 'manual' ? `${height * 100}vw` : 'unset'}`
137
- } : {})), (scale !== undefined ? { transform: `scale(${scale})`, 'WebkitTransform': `scale(${scale})` } : {})), { transition: (_k = innerStateProps === null || innerStateProps === void 0 ? void 0 : innerStateProps.transition) !== null && _k !== void 0 ? _k : 'none' }), children: (0, jsx_runtime_1.jsx)(ItemComponent, { item: item, sectionId: sectionId, onResize: handleItemResize, articleHeight: articleHeight, interactionCtrl: interactionCtrl }) }) }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
137
+ } : {})), (scale !== undefined ? { transform: `scale(${scale})`, 'WebkitTransform': `scale(${scale})` } : {})), { transition: (_k = innerStateProps === null || innerStateProps === void 0 ? void 0 : innerStateProps.transition) !== null && _k !== void 0 ? _k : 'none', pointerEvents: isItemVisible ? 'auto' : 'none' }), children: (0, jsx_runtime_1.jsx)(ItemComponent, { item: item, sectionId: sectionId, onResize: handleItemResize, articleHeight: articleHeight, interactionCtrl: interactionCtrl }) }) }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
138
138
  ${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, hidden, sticky, sectionHeight, layoutParams], exemplary) => {
139
139
  const sizingAxis = parseSizing(layoutParams.sizing);
140
140
  const isScreenBasedBottom = area.positionType === sdk_1.PositionType.ScreenBased && area.anchorSide === sdk_1.AnchorSide.Bottom;
@@ -149,7 +149,6 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
149
149
  height: fit-content;
150
150
  }
151
151
  .item-${item.id}-inner {
152
- pointer-events: auto;
153
152
  width: ${sizingAxis.x === 'manual'
154
153
  ? `${area.width * 100}vw`
155
154
  : 'max-content'};
@@ -2,9 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LinkWrapper = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const LinkWrapper = ({ url, children, target }) => {
5
+ const LinkWrapper = ({ url, children, target, isInteractive = true }) => {
6
6
  const validUrl = url && buildValidUrl(url);
7
- return url ? ((0, jsx_runtime_1.jsx)("a", { href: validUrl, target: target, rel: "noreferrer", children: children })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }));
7
+ const style = { pointerEvents: isInteractive ? 'unset' : 'none' };
8
+ return url ? ((0, jsx_runtime_1.jsx)("a", { href: validUrl, target: target, rel: "noreferrer", style: style, children: children })) : ((0, jsx_runtime_1.jsx)("span", { style: style, children: children }));
8
9
  };
9
10
  exports.LinkWrapper = LinkWrapper;
10
11
  function buildValidUrl(url) {
@@ -61,7 +61,8 @@ const CodeEmbedItem = ({ item, sectionId, onResize, interactionCtrl }) => {
61
61
  return;
62
62
  iframe.srcdoc = item.commonParams.html;
63
63
  }, [item.commonParams.html, item.commonParams.iframe, ref]);
64
- return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_g = item.link) === null || _g === void 0 ? void 0 : _g.url, target: (_h = item.link) === null || _h === void 0 ? void 0 : _h.target, children: [(0, jsx_runtime_1.jsx)("div", { className: `embed-wrapper-${item.id}`, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), (opacity !== undefined ? { opacity } : {})), { transition: (_j = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _j !== void 0 ? _j : 'none' }), ref: setRef, children: item.commonParams.iframe ? ((0, jsx_runtime_1.jsx)("iframe", { "data-embed": item.id, className: `embed-${item.id}`, style: Object.assign(Object.assign({}, pos), { border: 'unset' }) })) : ((0, jsx_runtime_1.jsx)("div", { className: `embed-${item.id}`, style: Object.assign({}, pos), dangerouslySetInnerHTML: { __html: html } })) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
64
+ const isInteractive = Number(opacity) > 0;
65
+ return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_g = item.link) === null || _g === void 0 ? void 0 : _g.url, target: (_h = item.link) === null || _h === void 0 ? void 0 : _h.target, isInteractive: isInteractive, children: [(0, jsx_runtime_1.jsx)("div", { className: `embed-wrapper-${item.id}`, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), (opacity !== undefined ? { opacity } : {})), { transition: (_j = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _j !== void 0 ? _j : 'none' }), ref: setRef, children: item.commonParams.iframe ? ((0, jsx_runtime_1.jsx)("iframe", { "data-embed": item.id, className: `embed-${item.id}`, style: Object.assign(Object.assign({}, pos), { border: 'unset' }) })) : ((0, jsx_runtime_1.jsx)("div", { className: `embed-${item.id}`, style: Object.assign({}, pos), dangerouslySetInnerHTML: { __html: html } })) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
65
66
  .embed-wrapper-${item.id} {
66
67
  position: absolute;
67
68
  width: 100%;
@@ -28,7 +28,8 @@ const GroupItem = ({ item, sectionId, onResize, articleHeight, interactionCtrl }
28
28
  const stateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['opacity', 'angle']);
29
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
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
- 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, interactionCtrl: interactionCtrl, isInGroup: true }, item.id))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
31
+ const isVisible = opacity !== 0;
32
+ 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, isInteractive: isVisible, 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, interactionCtrl: interactionCtrl, isItemVisible: isVisible, isInGroup: true }, item.id))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
32
33
  .group-${item.id} {
33
34
  position: absolute;
34
35
  width: 100%;
@@ -76,7 +76,7 @@ const ImageItem = ({ item, sectionId, onResize, interactionCtrl }) => {
76
76
  const opacity = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_h = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _h === void 0 ? void 0 : _h.opacity, itemOpacity);
77
77
  const blur = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_j = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _j === void 0 ? void 0 : _j.blur, itemBlur);
78
78
  const inlineStyles = Object.assign(Object.assign(Object.assign(Object.assign({}, (borderColor ? { borderColor: `${borderColor.fmt('rgba')}` } : {})), (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), (strokeWidth !== undefined ? { borderWidth: `${strokeWidth * 100}vw` } : {})), { transition: (_k = imgStateParams === null || imgStateParams === void 0 ? void 0 : imgStateParams.transition) !== null && _k !== void 0 ? _k : 'none' });
79
- return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_l = item.link) === null || _l === void 0 ? void 0 : _l.url, target: (_m = item.link) === null || _m === void 0 ? void 0 : _m.target, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `image-wrapper-${item.id}`, ref: setWrapperRef, 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)` } : {})), { transition: (_o = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _o !== void 0 ? _o : 'none' }), children: hasGLEffect && isFXAllowed ? ((0, jsx_runtime_1.jsx)("canvas", { style: inlineStyles, ref: fxCanvas, className: `img-canvas image-${item.id}`, width: rectWidth, height: rectHeight })) : ((0, jsx_runtime_1.jsx)("img", { alt: "", className: `image image-${item.id}`, style: inlineStyles, src: item.commonParams.url })) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
79
+ return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_l = item.link) === null || _l === void 0 ? void 0 : _l.url, target: (_m = item.link) === null || _m === void 0 ? void 0 : _m.target, isInteractive: opacity !== 0, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `image-wrapper-${item.id}`, ref: setWrapperRef, 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)` } : {})), { transition: (_o = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _o !== void 0 ? _o : 'none' }), children: hasGLEffect && isFXAllowed ? ((0, jsx_runtime_1.jsx)("canvas", { style: inlineStyles, ref: fxCanvas, className: `img-canvas image-${item.id}`, width: rectWidth, height: rectHeight })) : ((0, jsx_runtime_1.jsx)("img", { alt: "", className: `image image-${item.id}`, style: inlineStyles, src: item.commonParams.url })) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
80
80
  .image-wrapper-${item.id} {
81
81
  position: absolute;
82
82
  width: 100%;
@@ -40,7 +40,8 @@ const RectangleItem = ({ item, sectionId, onResize, interactionCtrl }) => {
40
40
  const angle = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(styles === null || styles === void 0 ? void 0 : styles.angle, itemAngle);
41
41
  const blur = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(styles === null || styles === void 0 ? void 0 : styles.blur, itemBlur);
42
42
  const backdropFilterValue = backdropBlur ? `blur(${backdropBlur * 100}vw)` : undefined;
43
- return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_b = item.link) === null || _b === void 0 ? void 0 : _b.url, target: (_c = item.link) === null || _c === void 0 ? void 0 : _c.target, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `rectangle-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (backgroundColor ? { backgroundColor: `${backgroundColor.fmt('rgba')}` } : {})), (borderColor ? { borderColor: `${borderColor.fmt('rgba')}` } : {})), (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), (strokeWidth !== undefined ? { borderWidth: `${strokeWidth * 100}vw` } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), (backdropFilterValue !== undefined
43
+ const isInteractive = (backgroundColor === null || backgroundColor === void 0 ? void 0 : backgroundColor.getAlpha()) !== 0 || (strokeWidth !== 0 && (borderColor === null || borderColor === void 0 ? void 0 : borderColor.getAlpha()) !== 0);
44
+ return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_b = item.link) === null || _b === void 0 ? void 0 : _b.url, target: (_c = item.link) === null || _c === void 0 ? void 0 : _c.target, isInteractive: isInteractive, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `rectangle-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (backgroundColor ? { backgroundColor: `${backgroundColor.fmt('rgba')}` } : {})), (borderColor ? { borderColor: `${borderColor.fmt('rgba')}` } : {})), (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), (strokeWidth !== undefined ? { borderWidth: `${strokeWidth * 100}vw` } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), (backdropFilterValue !== undefined
44
45
  ? { backdropFilter: backdropFilterValue, WebkitBackdropFilter: backdropFilterValue }
45
46
  : {})), { transition: (_d = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _d !== void 0 ? _d : 'none' }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
46
47
  .rectangle-${item.id} {
@@ -17,9 +17,9 @@ const getFontFamilyValue_1 = require("../../utils/getFontFamilyValue");
17
17
  const useExemplary_1 = require("../../common/useExemplary");
18
18
  const useItemAngle_1 = require("../useItemAngle");
19
19
  const getStyleFromItemStateAndParams_1 = require("../../utils/getStyleFromItemStateAndParams");
20
+ const useCurrentLayout_1 = require("../../common/useCurrentLayout");
20
21
  const RichTextItem = ({ item, sectionId, onResize, interactionCtrl }) => {
21
- var _a, _b;
22
- const [content, styles] = (0, useRichTextItem_1.useRichTextItem)(item);
22
+ var _a, _b, _c, _d;
23
23
  const id = (0, react_1.useId)();
24
24
  const [ref, setRef] = (0, react_1.useState)(null);
25
25
  const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
@@ -27,6 +27,7 @@ const RichTextItem = ({ item, sectionId, onResize, interactionCtrl }) => {
27
27
  const { blur: itemBlur, wordSpacing: itemWordSpacing, letterSpacing: itemLetterSpacing, color: itemColor, fontSize, lineHeight } = (0, useRichTextItemValues_1.useRichTextItemValues)(item, sectionId);
28
28
  const layoutValues = [item.area, item.layoutParams];
29
29
  const exemplary = (0, useExemplary_1.useExemplary)();
30
+ const { layoutId } = (0, useCurrentLayout_1.useCurrentLayout)();
30
31
  (0, useRegisterResize_1.useRegisterResize)(ref, onResize);
31
32
  const stateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['angle', 'blur', 'letterSpacing', 'wordSpacing', 'color']);
32
33
  const stateStyles = (_a = stateParams === null || stateParams === void 0 ? void 0 : stateParams.styles) !== null && _a !== void 0 ? _a : {};
@@ -40,7 +41,16 @@ const RichTextItem = ({ item, sectionId, onResize, interactionCtrl }) => {
40
41
  const blur = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(stateStyles.blur, itemBlur);
41
42
  const letterSpacing = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(stateStyles.letterSpacing, itemLetterSpacing);
42
43
  const wordSpacing = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)(stateStyles.wordSpacing, itemWordSpacing);
43
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { ref: setRef, className: `rich-text-wrapper-${item.id}`, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), (textColor ? { color: `${textColor.fmt('rgba')}` } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (letterSpacing !== undefined ? { letterSpacing: `${letterSpacing * exemplary}px` } : {})), (wordSpacing !== undefined ? { wordSpacing: `${wordSpacing * exemplary}px` } : {})), (fontSize !== undefined ? { fontSize: `${Math.round(fontSize * exemplary)}px` } : {})), (lineHeight !== undefined ? { lineHeight: `${lineHeight * exemplary}px` } : {})), { transition }), children: content }), (0, jsx_runtime_1.jsxs)(style_1.default, { id: id, children: [styles, `${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
44
+ const colorAlpha = textColor === null || textColor === void 0 ? void 0 : textColor.getAlpha();
45
+ const rangeStyles = layoutId ? (_d = (_c = item.layoutParams[layoutId]) === null || _c === void 0 ? void 0 : _c.rangeStyles) !== null && _d !== void 0 ? _d : [] : [];
46
+ const rangeColors = rangeStyles.filter((style) => style.style === 'COLOR');
47
+ const hasVisibleRangeColors = rangeColors.some((color) => {
48
+ const alpha = color_1.CntrlColor.parse(color.value).getAlpha();
49
+ return alpha > 0;
50
+ });
51
+ const isInteractive = colorAlpha !== 0 || hasVisibleRangeColors;
52
+ const [content, styles] = (0, useRichTextItem_1.useRichTextItem)(item, isInteractive);
53
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { ref: setRef, className: `rich-text-wrapper-${item.id}`, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), (textColor ? { color: `${textColor.fmt('rgba')}` } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (letterSpacing !== undefined ? { letterSpacing: `${letterSpacing * exemplary}px` } : {})), (wordSpacing !== undefined ? { wordSpacing: `${wordSpacing * exemplary}px` } : {})), (fontSize !== undefined ? { fontSize: `${Math.round(fontSize * exemplary)}px` } : {})), (lineHeight !== undefined ? { lineHeight: `${lineHeight * exemplary}px` } : {})), { pointerEvents: isInteractive ? 'unset' : 'none', userSelect: isInteractive ? 'unset' : 'none', transition }), children: content }), (0, jsx_runtime_1.jsxs)(style_1.default, { id: id, children: [styles, `${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
44
54
  const color = color_1.CntrlColor.parse(layoutParams.color);
45
55
  return (`
46
56
  .rich-text-wrapper-${item.id} {
@@ -43,7 +43,7 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl }) => {
43
43
  const radius = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_f = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _f === void 0 ? void 0 : _f.radius, itemRadius);
44
44
  (0, useRegisterResize_1.useRegisterResize)(ref, onResize);
45
45
  const inlineStyles = Object.assign(Object.assign(Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), (strokeWidth !== undefined ? { borderWidth: `${strokeWidth * 100}vw` } : {})), (borderColor ? { borderColor: `${borderColor.toCss()}` } : {})), { transition: (_g = videoStateParams === null || videoStateParams === void 0 ? void 0 : videoStateParams.transition) !== null && _g !== void 0 ? _g : 'none' });
46
- return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_h = item.link) === null || _h === void 0 ? void 0 : _h.url, target: (_j = item.link) === null || _j === void 0 ? void 0 : _j.target, children: [(0, jsx_runtime_1.jsx)("div", { className: `video-wrapper-${item.id}`, ref: setRef, 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)` } : {})), { transition: (_k = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _k !== void 0 ? _k : 'none' }), children: hasScrollPlayback ? ((0, jsx_runtime_1.jsx)(ScrollPlaybackVideo_1.ScrollPlaybackVideo, { sectionId: sectionId, src: item.commonParams.url, playbackParams: scrollPlayback, style: inlineStyles, className: `video video-playback-wrapper video-${item.id}` })) : ((0, jsx_runtime_1.jsx)("video", { poster: (_l = item.commonParams.coverUrl) !== null && _l !== void 0 ? _l : '', ref: videoRef, autoPlay: true, muted: true, loop: true, playsInline: true, className: `video video-${item.id}`, style: inlineStyles, children: (0, jsx_runtime_1.jsx)("source", { src: item.commonParams.url }) })) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
46
+ return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_h = item.link) === null || _h === void 0 ? void 0 : _h.url, target: (_j = item.link) === null || _j === void 0 ? void 0 : _j.target, isInteractive: opacity !== 0, children: [(0, jsx_runtime_1.jsx)("div", { className: `video-wrapper-${item.id}`, ref: setRef, 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)` } : {})), { transition: (_k = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _k !== void 0 ? _k : 'none' }), children: hasScrollPlayback ? ((0, jsx_runtime_1.jsx)(ScrollPlaybackVideo_1.ScrollPlaybackVideo, { sectionId: sectionId, src: item.commonParams.url, playbackParams: scrollPlayback, style: inlineStyles, className: `video video-playback-wrapper video-${item.id}` })) : ((0, jsx_runtime_1.jsx)("video", { poster: (_l = item.commonParams.coverUrl) !== null && _l !== void 0 ? _l : '', ref: videoRef, autoPlay: true, muted: true, loop: true, playsInline: true, className: `video video-${item.id}`, style: inlineStyles, children: (0, jsx_runtime_1.jsx)("source", { src: item.commonParams.url }) })) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
47
47
  .video-wrapper-${item.id} {
48
48
  position: absolute;
49
49
  overflow: hidden;
@@ -67,7 +67,8 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl }) => {
67
67
  vimeoPlayer.play();
68
68
  setIsCoverVisible(false);
69
69
  };
70
- 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(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { transition: (_g = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _g !== void 0 ? _g : 'none' }), onMouseEnter: () => {
70
+ const isInteractive = opacity !== 0;
71
+ 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, isInteractive: isInteractive, children: [(0, jsx_runtime_1.jsxs)("div", { className: `embed-video-wrapper-${item.id}`, ref: setRef, 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)` } : {})), { transition: (_g = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _g !== void 0 ? _g : 'none' }), onMouseEnter: () => {
71
72
  if (!vimeoPlayer || play !== 'on-hover')
72
73
  return;
73
74
  vimeoPlayer.play();
@@ -35,6 +35,7 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl }) => {
35
35
  const blur = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_b = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _b === void 0 ? void 0 : _b.blur, itemBlur);
36
36
  const opacity = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_c = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.styles) === null || _c === void 0 ? void 0 : _c.opacity, itemOpacity);
37
37
  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);
38
+ const isInteractive = opacity !== 0;
38
39
  (0, useRegisterResize_1.useRegisterResize)(div, onResize);
39
40
  (0, react_1.useEffect)(() => {
40
41
  const newUrl = new URL(url);
@@ -86,7 +87,7 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl }) => {
86
87
  setIsCoverVisible(true);
87
88
  }
88
89
  }, []);
89
- 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: () => {
90
+ 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, isInteractive: isInteractive, children: [(0, jsx_runtime_1.jsxs)("div", { className: `embed-youtube-video-wrapper-${item.id}`, onMouseEnter: () => {
90
91
  if (!player || play !== 'on-hover')
91
92
  return;
92
93
  player.playVideo();
@@ -4,9 +4,9 @@ exports.useRichTextItem = void 0;
4
4
  const RichTextConverter_1 = require("../../utils/RichTextConverter/RichTextConverter");
5
5
  const useCntrlContext_1 = require("../../provider/useCntrlContext");
6
6
  const richTextConverter = new RichTextConverter_1.RichTextConverter();
7
- const useRichTextItem = (item) => {
7
+ const useRichTextItem = (item, isInteractive) => {
8
8
  const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
9
- const [content, styles] = richTextConverter.toHtml(item, layouts);
9
+ const [content, styles] = richTextConverter.toHtml(item, layouts, isInteractive);
10
10
  return [content, styles];
11
11
  };
12
12
  exports.useRichTextItem = useRichTextItem;
@@ -12,7 +12,7 @@ exports.FontStyles = {
12
12
  'italic': { 'font-style': 'italic' }
13
13
  };
14
14
  class RichTextConverter {
15
- toHtml(richText, layouts) {
15
+ toHtml(richText, layouts, isInteractive) {
16
16
  var _a, _b, _c;
17
17
  const { text, blocks = [] } = richText.commonParams;
18
18
  const root = [];
@@ -91,7 +91,7 @@ class RichTextConverter {
91
91
  offset = entity.end;
92
92
  }
93
93
  if (entity.link) {
94
- kids.push((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: entity.link, target: entity.target, children: entityKids }, entity.start));
94
+ kids.push((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: entity.link, target: entity.target, isInteractive: isInteractive, children: entityKids }, entity.start));
95
95
  continue;
96
96
  }
97
97
  kids.push(...entityKids);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk-nextjs",
3
- "version": "1.0.19-alpha.6",
3
+ "version": "1.0.19-alpha.7",
4
4
  "description": "SDK for Next.js",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/index.ts",
@@ -44,6 +44,7 @@ export interface ItemProps<I extends ItemAny> {
44
44
  export interface ItemWrapperProps extends ItemProps<ItemAny> {
45
45
  articleHeight: number;
46
46
  isInGroup?: boolean;
47
+ isItemVisible?: boolean;
47
48
  }
48
49
 
49
50
  const itemsMap: Record<ArticleItemType, ComponentType<ItemProps<any>>> = {
@@ -78,7 +79,7 @@ const RichTextWrapper: FC<PropsWithChildren<RTWrapperProps>> = ({ isRichText, ch
78
79
 
79
80
  const noop = () => null;
80
81
 
81
- export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight, isInGroup = false }) => {
82
+ export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight, isItemVisible = true, isInGroup = false }) => {
82
83
  const itemWrapperRef = useRef<HTMLDivElement | null>(null);
83
84
  const itemInnerRef = useRef<HTMLDivElement | null>(null);
84
85
  const rectObserver = useContext(ArticleRectContext);
@@ -187,7 +188,8 @@ export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight, isI
187
188
  : 'max-content'}`,
188
189
  height: `${sizingAxis.y === 'manual' ? `${height * 100}vw` : 'unset'}` } : {}),
189
190
  ...(scale !== undefined ? { transform: `scale(${scale})`, 'WebkitTransform': `scale(${scale})` } : {}),
190
- transition: innerStateProps?.transition ?? 'none'
191
+ transition: innerStateProps?.transition ?? 'none',
192
+ pointerEvents: isItemVisible ? 'auto' : 'none'
191
193
  }}
192
194
  >
193
195
  <ItemComponent
@@ -215,7 +217,6 @@ export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight, isI
215
217
  height: fit-content;
216
218
  }
217
219
  .item-${item.id}-inner {
218
- pointer-events: auto;
219
220
  width: ${sizingAxis.x === 'manual'
220
221
  ? `${area.width * 100}vw`
221
222
  : 'max-content'};
@@ -1,23 +1,26 @@
1
- import React, { ReactElement, ReactNode } from 'react';
1
+ import React, { CSSProperties, ReactElement, ReactNode } from 'react';
2
2
 
3
3
  interface Props {
4
4
  url?: string;
5
5
  children: ReactElement | ReactNode[];
6
6
  target?: string;
7
+ isInteractive?: boolean;
7
8
  }
8
9
 
9
- export const LinkWrapper: React.FC<Props> = ({ url, children, target }) => {
10
+ export const LinkWrapper: React.FC<Props> = ({ url, children, target, isInteractive = true }) => {
10
11
  const validUrl = url && buildValidUrl(url);
12
+ const style: CSSProperties = { pointerEvents: isInteractive ? 'unset' : 'none' };
11
13
  return url ? (
12
14
  <a
13
15
  href={validUrl}
14
16
  target={target}
15
17
  rel="noreferrer"
18
+ style={style}
16
19
  >
17
20
  {children}
18
21
  </a>
19
22
  ) : (
20
- <>{children}</>
23
+ <span style={style}>{children}</span>
21
24
  );
22
25
  };
23
26
 
@@ -56,8 +56,10 @@ export const CodeEmbedItem: FC<ItemProps<TCodeEmbedItem>> = ({ item, sectionId,
56
56
  iframe.srcdoc = item.commonParams.html;
57
57
  }, [item.commonParams.html, item.commonParams.iframe, ref]);
58
58
 
59
+ const isInteractive = Number(opacity) > 0;
60
+
59
61
  return (
60
- <LinkWrapper url={item.link?.url} target={item.link?.target}>
62
+ <LinkWrapper url={item.link?.url} target={item.link?.target} isInteractive={isInteractive}>
61
63
  <div
62
64
  className={`embed-wrapper-${item.id}`}
63
65
  style={{
@@ -21,9 +21,9 @@ export const GroupItem: FC<ItemProps<TGroupItem>> = ({ item, sectionId, onResize
21
21
  const stateParams = interactionCtrl?.getState(['opacity', 'angle']);
22
22
  const angle = getStyleFromItemStateAndParams(stateParams?.styles?.angle, itemAngle);
23
23
  const opacity = getStyleFromItemStateAndParams(stateParams?.styles?.opacity, itemOpacity);
24
-
24
+ const isVisible = opacity !== 0;
25
25
  return (
26
- <LinkWrapper url={item.link?.url} target={item.link?.target}>
26
+ <LinkWrapper url={item.link?.url} target={item.link?.target} isInteractive={isVisible}>
27
27
  <>
28
28
  <div
29
29
  className={`group-${item.id}`}
@@ -41,6 +41,7 @@ export const GroupItem: FC<ItemProps<TGroupItem>> = ({ item, sectionId, onResize
41
41
  sectionId={sectionId}
42
42
  articleHeight={articleHeight}
43
43
  interactionCtrl={interactionCtrl}
44
+ isItemVisible={isVisible}
44
45
  isInGroup
45
46
  />
46
47
  ))}
@@ -89,7 +89,7 @@ export const ImageItem: FC<ItemProps<TImageItem>> = ({ item, sectionId, onResize
89
89
  transition: imgStateParams?.transition ?? 'none'
90
90
  };
91
91
  return (
92
- <LinkWrapper url={item.link?.url} target={item.link?.target}>
92
+ <LinkWrapper url={item.link?.url} target={item.link?.target} isInteractive={opacity !== 0}>
93
93
  <>
94
94
  <div
95
95
  className={`image-wrapper-${item.id}`}
@@ -41,9 +41,10 @@ export const RectangleItem: FC<ItemProps<TRectangleItem>> = ({ item, sectionId,
41
41
  const angle = getStyleFromItemStateAndParams(styles?.angle, itemAngle);
42
42
  const blur = getStyleFromItemStateAndParams(styles?.blur, itemBlur);
43
43
  const backdropFilterValue = backdropBlur ? `blur(${backdropBlur * 100}vw)`: undefined;
44
+ const isInteractive = backgroundColor?.getAlpha() !== 0 || (strokeWidth !== 0 && borderColor?.getAlpha() !== 0);
44
45
 
45
46
  return (
46
- <LinkWrapper url={item.link?.url} target={item.link?.target}>
47
+ <LinkWrapper url={item.link?.url} target={item.link?.target} isInteractive={isInteractive}>
47
48
  <>
48
49
  <div
49
50
  className={`rectangle-${item.id}`}
@@ -11,9 +11,9 @@ import { getFontFamilyValue } from '../../utils/getFontFamilyValue';
11
11
  import { useExemplary } from '../../common/useExemplary';
12
12
  import { useItemAngle } from '../useItemAngle';
13
13
  import { getStyleFromItemStateAndParams } from '../../utils/getStyleFromItemStateAndParams';
14
+ import { useCurrentLayout } from '../../common/useCurrentLayout';
14
15
 
15
16
  export const RichTextItem: FC<ItemProps<TRichTextItem>> = ({ item, sectionId, onResize, interactionCtrl }) => {
16
- const [content, styles] = useRichTextItem(item);
17
17
  const id = useId();
18
18
  const [ref, setRef] = useState<HTMLDivElement | null>(null);
19
19
  const { layouts } = useCntrlContext();
@@ -28,6 +28,7 @@ export const RichTextItem: FC<ItemProps<TRichTextItem>> = ({ item, sectionId, on
28
28
  } = useRichTextItemValues(item, sectionId);
29
29
  const layoutValues: Record<string, any>[] = [item.area, item.layoutParams];
30
30
  const exemplary = useExemplary();
31
+ const { layoutId } = useCurrentLayout();
31
32
  useRegisterResize(ref, onResize);
32
33
  const stateParams = interactionCtrl?.getState(['angle', 'blur', 'letterSpacing', 'wordSpacing', 'color']);
33
34
  const stateStyles = stateParams?.styles ?? {};
@@ -40,6 +41,15 @@ export const RichTextItem: FC<ItemProps<TRichTextItem>> = ({ item, sectionId, on
40
41
  const blur = getStyleFromItemStateAndParams(stateStyles.blur, itemBlur);
41
42
  const letterSpacing = getStyleFromItemStateAndParams(stateStyles.letterSpacing, itemLetterSpacing);
42
43
  const wordSpacing = getStyleFromItemStateAndParams(stateStyles.wordSpacing, itemWordSpacing);
44
+ const colorAlpha = textColor?.getAlpha();
45
+ const rangeStyles = layoutId ? item.layoutParams[layoutId]?.rangeStyles ?? [] : [];
46
+ const rangeColors = rangeStyles.filter((style) => style.style === 'COLOR');
47
+ const hasVisibleRangeColors = rangeColors.some((color) => {
48
+ const alpha = CntrlColor.parse(color.value!).getAlpha();
49
+ return alpha > 0;
50
+ });
51
+ const isInteractive = colorAlpha !== 0 || hasVisibleRangeColors;
52
+ const [content, styles] = useRichTextItem(item, isInteractive);
43
53
 
44
54
  return (
45
55
  <>
@@ -54,6 +64,8 @@ export const RichTextItem: FC<ItemProps<TRichTextItem>> = ({ item, sectionId, on
54
64
  ...(wordSpacing !== undefined ? { wordSpacing: `${wordSpacing * exemplary}px` } : {}),
55
65
  ...(fontSize !== undefined ? { fontSize: `${Math.round(fontSize * exemplary)}px` } : {}),
56
66
  ...(lineHeight !== undefined ? { lineHeight: `${lineHeight * exemplary}px` } : {}),
67
+ pointerEvents: isInteractive ? 'unset' : 'none',
68
+ userSelect: isInteractive ? 'unset' : 'none',
57
69
  transition
58
70
  }}
59
71
  >
@@ -49,7 +49,7 @@ export const VideoItem: FC<ItemProps<TVideoItem>> = ({ item, sectionId, onResize
49
49
  };
50
50
 
51
51
  return (
52
- <LinkWrapper url={item.link?.url} target={item.link?.target}>
52
+ <LinkWrapper url={item.link?.url} target={item.link?.target} isInteractive={opacity !== 0}>
53
53
  <div
54
54
  className={`video-wrapper-${item.id}`}
55
55
  ref={setRef}
@@ -66,9 +66,10 @@ export const VimeoEmbedItem: FC<ItemProps<TVimeoEmbedItem>> = ({ item, sectionId
66
66
  vimeoPlayer!.play();
67
67
  setIsCoverVisible(false);
68
68
  };
69
+ const isInteractive = opacity !== 0;
69
70
 
70
71
  return (
71
- <LinkWrapper url={item.link?.url} target={item.link?.target}>
72
+ <LinkWrapper url={item.link?.url} target={item.link?.target} isInteractive={isInteractive}>
72
73
  <div
73
74
  className={`embed-video-wrapper-${item.id}`}
74
75
  ref={setRef}
@@ -30,6 +30,7 @@ export const YoutubeEmbedItem: FC<ItemProps<TYoutubeEmbedItem>> = ({ item, secti
30
30
  const blur = getStyleFromItemStateAndParams(wrapperStateParams?.styles?.blur, itemBlur);
31
31
  const opacity = getStyleFromItemStateAndParams(wrapperStateParams?.styles?.opacity, itemOpacity);
32
32
  const radius = getStyleFromItemStateAndParams(frameStateParams?.styles?.radius, itemRadius);
33
+ const isInteractive = opacity !== 0;
33
34
  useRegisterResize(div, onResize);
34
35
  useEffect(() => {
35
36
  const newUrl = new URL(url);
@@ -81,7 +82,7 @@ export const YoutubeEmbedItem: FC<ItemProps<TYoutubeEmbedItem>> = ({ item, secti
81
82
  }, []);
82
83
 
83
84
  return (
84
- <LinkWrapper url={item.link?.url} target={item.link?.target}>
85
+ <LinkWrapper url={item.link?.url} target={item.link?.target} isInteractive={isInteractive}>
85
86
  <div
86
87
  className={`embed-youtube-video-wrapper-${item.id}`}
87
88
  onMouseEnter={() => {
@@ -5,8 +5,8 @@ import { ReactNode } from 'react';
5
5
 
6
6
  const richTextConverter = new RichTextConverter();
7
7
 
8
- export const useRichTextItem = (item: RichTextItem): [ReactNode[], string] => {
8
+ export const useRichTextItem = (item: RichTextItem, isInteractive: boolean): [ReactNode[], string] => {
9
9
  const { layouts } = useCntrlContext();
10
- const [content, styles] = richTextConverter.toHtml(item, layouts);
10
+ const [content, styles] = richTextConverter.toHtml(item, layouts, isInteractive);
11
11
  return [content, styles];
12
12
  };
@@ -40,7 +40,8 @@ export const FontStyles: Record<string, Record<string, string>> = {
40
40
  export class RichTextConverter {
41
41
  toHtml(
42
42
  richText: RichTextItem,
43
- layouts: Layout[]
43
+ layouts: Layout[],
44
+ isInteractive: boolean
44
45
  ): [ReactNode[], string] {
45
46
  const { text, blocks = [] } = richText.commonParams;
46
47
  const root: ReactElement[] = [];
@@ -122,7 +123,16 @@ export class RichTextConverter {
122
123
  offset = entity.end;
123
124
  }
124
125
  if (entity.link) {
125
- kids.push(<LinkWrapper key={entity.start} url={entity.link} target={entity.target}>{entityKids}</LinkWrapper>);
126
+ kids.push(
127
+ <LinkWrapper
128
+ key={entity.start}
129
+ url={entity.link}
130
+ target={entity.target}
131
+ isInteractive={isInteractive}
132
+ >
133
+ {entityKids}
134
+ </LinkWrapper>
135
+ );
126
136
  continue;
127
137
  }
128
138
  kids.push(...entityKids);