@cntrl-site/sdk-nextjs 1.6.11 → 1.6.12

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 (122) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +4 -4
  3. package/TODO.md +1 -1
  4. package/eslint.config.mjs +35 -35
  5. package/jest.config.js +6 -6
  6. package/lib/common/useItemFXData.js +7 -7
  7. package/lib/components/Article.js +5 -5
  8. package/lib/components/LayoutStyle.js +4 -4
  9. package/lib/components/Section/Section.js +14 -14
  10. package/lib/components/items/CodeEmbedItem/CodeEmbedItem.js +40 -29
  11. package/lib/components/items/CompoundItem/CompoundChild.js +20 -20
  12. package/lib/components/items/CompoundItem/CompoundItem.js +14 -14
  13. package/lib/components/items/CustomItem/CustomItem.js +9 -9
  14. package/lib/components/items/EmbedVideoItem/VimeoEmbed.js +23 -23
  15. package/lib/components/items/EmbedVideoItem/YoutubeEmbed.js +26 -26
  16. package/lib/components/items/FileItem/ImageItem.js +38 -38
  17. package/lib/components/items/FileItem/VideoItem.js +45 -45
  18. package/lib/components/items/GroupItem/GroupItem.js +13 -13
  19. package/lib/components/items/Item.js +30 -30
  20. package/lib/components/items/RectangleItem/RectangleItem.js +20 -20
  21. package/lib/components/items/RichTextItem/RichTextItem.js +21 -21
  22. package/lib/provider/CntrlSdkContext.js +8 -0
  23. package/lib/utils/RichTextConverter/RichTextConverter.js +21 -21
  24. package/package.json +57 -57
  25. package/src/common/useCurrentLayout.ts +52 -52
  26. package/src/common/useExemplary.ts +9 -9
  27. package/src/common/useItemFXData.ts +47 -47
  28. package/src/common/useKeyframeValue.ts +85 -85
  29. package/src/common/useRegisterResize.ts +17 -17
  30. package/src/components/Article.tsx +66 -66
  31. package/src/components/ArticleWrapper.tsx +21 -21
  32. package/src/components/Head.tsx +56 -56
  33. package/src/components/LayoutStyle.tsx +21 -21
  34. package/src/components/Page.tsx +33 -33
  35. package/src/components/ScrollPlaybackVideo.tsx +56 -56
  36. package/src/components/Section/Section.tsx +77 -77
  37. package/src/components/Section/useSectionColor.ts +19 -19
  38. package/src/components/Section/useSectionHeightMap.ts +19 -19
  39. package/src/components/items/CodeEmbedItem/CodeEmbedItem.tsx +132 -120
  40. package/src/components/items/CodeEmbedItem/useCodeEmbedItem.ts +36 -36
  41. package/src/components/items/CompoundItem/CompoundChild.tsx +150 -150
  42. package/src/components/items/CompoundItem/CompoundItem.tsx +71 -71
  43. package/src/components/items/CompoundItem/useCompoundItem.ts +21 -21
  44. package/src/components/items/CustomItem/CustomItem.tsx +47 -47
  45. package/src/components/items/EmbedVideoItem/VimeoEmbed.tsx +202 -202
  46. package/src/components/items/EmbedVideoItem/YoutubeEmbed.tsx +187 -187
  47. package/src/components/items/EmbedVideoItem/useEmbedVideoItem.ts +46 -46
  48. package/src/components/items/FileItem/ImageItem.tsx +156 -156
  49. package/src/components/items/FileItem/VideoItem.tsx +185 -185
  50. package/src/components/items/FileItem/useFileItem.ts +73 -73
  51. package/src/components/items/GroupItem/GroupItem.tsx +79 -79
  52. package/src/components/items/GroupItem/useGroupItem.ts +34 -34
  53. package/src/components/items/Item.tsx +251 -251
  54. package/src/components/items/LinkWrapper.tsx +39 -39
  55. package/src/components/items/RectangleItem/RectangleItem.tsx +95 -95
  56. package/src/components/items/RectangleItem/useRectangleItem.ts +82 -82
  57. package/src/components/items/RichTextItem/RichTextItem.tsx +105 -105
  58. package/src/components/items/RichTextItem/useRichTextItem.ts +12 -12
  59. package/src/components/items/RichTextWrapper.tsx +15 -15
  60. package/src/components/items/itemsMap.ts +26 -26
  61. package/src/components/items/useDraggable.ts +252 -252
  62. package/src/components/items/useItemAngle.ts +13 -13
  63. package/src/components/items/useItemArea.ts +35 -35
  64. package/src/components/items/useItemPointerEvents.ts +23 -23
  65. package/src/components/items/useItemScale.ts +17 -17
  66. package/src/components/items/useItemTriggers.ts +15 -15
  67. package/src/components/items/useRichTextItemValues.ts +65 -65
  68. package/src/components/items/useSizing.ts +25 -25
  69. package/src/components/items/useStickyItemTop.ts +21 -21
  70. package/src/components/useLayoutContext.ts +7 -7
  71. package/src/index.ts +24 -24
  72. package/src/interactions/CSSPropertyNameMap.ts +38 -38
  73. package/src/interactions/InteractionsRegistry.ts +275 -275
  74. package/src/interactions/ItemInteractionCtrl.ts +77 -77
  75. package/src/interactions/getTransition.ts +27 -27
  76. package/src/interactions/types.ts +36 -36
  77. package/src/interactions/useItemInteractionCtrl.ts +18 -18
  78. package/src/provider/ArticleRectContext.ts +4 -4
  79. package/src/provider/CntrlContext.ts +5 -5
  80. package/src/provider/CntrlProvider.tsx +11 -11
  81. package/src/provider/CntrlSdkContext.ts +69 -59
  82. package/src/provider/CustomItemRegistry.ts +14 -14
  83. package/src/provider/CustomItemTypes.ts +3 -3
  84. package/src/provider/CustomSectionRegistry.ts +25 -25
  85. package/src/provider/InteractionsContext.old.tsx +65 -65
  86. package/src/provider/InteractionsContext.test.tsx +97 -97
  87. package/src/provider/InteractionsContext.tsx +28 -28
  88. package/src/provider/Keyframes.ts +11 -11
  89. package/src/provider/KeyframesContext.ts +5 -5
  90. package/src/provider/LayoutContext.ts +3 -3
  91. package/src/provider/defaultContext.ts +8 -8
  92. package/src/provider/useCntrlContext.ts +8 -8
  93. package/src/styled-jsx.d.ts +1 -1
  94. package/src/utils/Animator/Animator.ts +371 -371
  95. package/src/utils/ArticleRectManager/ArticleRectObserver.ts +93 -93
  96. package/src/utils/ArticleRectManager/useArticleRectObserver.ts +17 -17
  97. package/src/utils/ArticleRectManager/useSectionRegistry.ts +11 -11
  98. package/src/utils/EventEmitter.ts +41 -41
  99. package/src/utils/RichTextConverter/RichTextConverter.tsx +326 -326
  100. package/src/utils/ScaleAnchorMap.ts +13 -13
  101. package/src/utils/StickyManager/StickyManager.ts +23 -23
  102. package/src/utils/Youtube/YouTubeIframeApiLoader.ts +58 -58
  103. package/src/utils/Youtube/YoutubeIframeApi.ts +101 -101
  104. package/src/utils/Youtube/useYouTubeIframeApi.ts +12 -12
  105. package/src/utils/binSearchInsertAt.ts +33 -33
  106. package/src/utils/castObject.ts +10 -10
  107. package/src/utils/effects/useImageFx.ts +113 -113
  108. package/src/utils/effects/useVideoFx.ts +116 -116
  109. package/src/utils/getAnchoredItemTop.ts +12 -12
  110. package/src/utils/getCompoundBondaryStyles.ts +62 -62
  111. package/src/utils/getFontFamilyValue.ts +3 -3
  112. package/src/utils/getInvertedRanges.ts +43 -43
  113. package/src/utils/getItemTopStyle.ts +14 -14
  114. package/src/utils/getStyleFromItemStateAndParams.ts +8 -8
  115. package/src/utils/getValidYoutubeUrl.ts +29 -29
  116. package/src/utils/isItemType.ts +6 -6
  117. package/src/utils/rangeMap.ts +13 -13
  118. package/src/utils/useElementRect.ts +23 -23
  119. package/.idea/modules.xml +0 -8
  120. package/.idea/sdk-nextjs.iml +0 -12
  121. package/.idea/vcs.xml +0 -6
  122. package/cntrl-site-sdk-nextjs-1.6.11-alpha.0.tgz +0 -0
@@ -67,46 +67,46 @@ const ImageItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
67
67
  }, [isInteractive, onVisibilityChange]);
68
68
  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
69
69
  ? ((0, jsx_runtime_1.jsx)("canvas", { style: inlineStyles, ref: fxCanvas, className: `img-canvas image-${item.id}`, width: rectWidth, height: rectHeight }))
70
- : ((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: `
71
- .image-wrapper-${item.id} {
72
- position: absolute;
73
- width: 100%;
74
- height: 100%;
75
- box-sizing: border-box;
76
- display: flex;
77
- }
78
- .image {
79
- width: 100%;
80
- height: 100%;
81
- opacity: 1;
82
- object-fit: cover;
83
- pointer-events: none;
84
- border-style: solid;
85
- overflow: hidden;
86
- box-sizing: border-box;
87
- }
88
- .img-canvas {
89
- border: solid;
90
- width: 100%;
91
- height: 100%;
92
- pointer-events: none;
93
- border-width: 0;
94
- box-sizing: border-box;
95
- }
70
+ : ((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: `
71
+ .image-wrapper-${item.id} {
72
+ position: absolute;
73
+ width: 100%;
74
+ height: 100%;
75
+ box-sizing: border-box;
76
+ display: flex;
77
+ }
78
+ .image {
79
+ width: 100%;
80
+ height: 100%;
81
+ opacity: 1;
82
+ object-fit: cover;
83
+ pointer-events: none;
84
+ border-style: solid;
85
+ overflow: hidden;
86
+ box-sizing: border-box;
87
+ }
88
+ .img-canvas {
89
+ border: solid;
90
+ width: 100%;
91
+ height: 100%;
92
+ pointer-events: none;
93
+ border-width: 0;
94
+ box-sizing: border-box;
95
+ }
96
96
  ${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
97
- return (`
98
- .image-wrapper-${item.id} {
99
- opacity: ${layoutParams.opacity};
100
- transform: rotate(${area.angle}deg);
101
- filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
102
- }
103
- .image-${item.id} {
104
- border-color: ${color_1.CntrlColor.parse(layoutParams.strokeColor).fmt('rgba')};
105
- border-radius: ${layoutParams.radius * 100}vw;
106
- border-width: ${layoutParams.strokeWidth * 100}vw;
107
- }
97
+ return (`
98
+ .image-wrapper-${item.id} {
99
+ opacity: ${layoutParams.opacity};
100
+ transform: rotate(${area.angle}deg);
101
+ filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
102
+ }
103
+ .image-${item.id} {
104
+ border-color: ${color_1.CntrlColor.parse(layoutParams.strokeColor).fmt('rgba')};
105
+ border-radius: ${layoutParams.radius * 100}vw;
106
+ border-width: ${layoutParams.strokeWidth * 100}vw;
107
+ }
108
108
  `);
109
- })}
109
+ })}
110
110
  ` })] }) }));
111
111
  };
112
112
  exports.ImageItem = ImageItem;
@@ -73,53 +73,53 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
73
73
  ? ((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}` }))
74
74
  : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: hasGLEffect && isFXAllowed
75
75
  ? ((0, jsx_runtime_1.jsx)("canvas", { style: inlineStyles, ref: fxCanvas, className: `video-canvas video-${item.id}`, width: rectWidth, height: rectHeight }))
76
- : ((0, jsx_runtime_1.jsx)("video", { poster: (_p = item.commonParams.coverUrl) !== null && _p !== void 0 ? _p : '', 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: `
77
- .video-wrapper-${item.id} {
78
- position: absolute;
79
- overflow: hidden;
80
- width: 100%;
81
- height: 100%;
82
- box-sizing: border-box;
83
- opacity: ${opacity};
84
- }
85
- .video {
86
- width: 100%;
87
- height: 100%;
88
- box-sizing: border-box;
89
- opacity: 1;
90
- object-fit: cover;
91
- overflow: hidden;
92
- border-style: solid;
93
- }
94
- .video-${item.id} {
95
- border-color: ${itemStrokeColor};
96
- }
97
- .video-playback-wrapper {
98
- display: flex;
99
- justify-content: center;
100
- }
101
- .video-canvas {
102
- border: solid;
103
- width: 100%;
104
- height: 100%;
105
- pointer-events: none;
106
- border-width: 0;
107
- box-sizing: border-box;
108
- }
76
+ : ((0, jsx_runtime_1.jsx)("video", { poster: (_p = item.commonParams.coverUrl) !== null && _p !== void 0 ? _p : '', 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: `
77
+ .video-wrapper-${item.id} {
78
+ position: absolute;
79
+ overflow: hidden;
80
+ width: 100%;
81
+ height: 100%;
82
+ box-sizing: border-box;
83
+ opacity: ${opacity};
84
+ }
85
+ .video {
86
+ width: 100%;
87
+ height: 100%;
88
+ box-sizing: border-box;
89
+ opacity: 1;
90
+ object-fit: cover;
91
+ overflow: hidden;
92
+ border-style: solid;
93
+ }
94
+ .video-${item.id} {
95
+ border-color: ${itemStrokeColor};
96
+ }
97
+ .video-playback-wrapper {
98
+ display: flex;
99
+ justify-content: center;
100
+ }
101
+ .video-canvas {
102
+ border: solid;
103
+ width: 100%;
104
+ height: 100%;
105
+ pointer-events: none;
106
+ border-width: 0;
107
+ box-sizing: border-box;
108
+ }
109
109
  ${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
110
- return (`
111
- .video-wrapper-${item.id} {
112
- opacity: ${layoutParams.opacity};
113
- transform: rotate(${area.angle}deg);
114
- filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
115
- }
116
- .video-${item.id} {
117
- border-color: ${color_1.CntrlColor.parse(layoutParams.strokeColor).fmt('rgba')};
118
- border-radius: ${layoutParams.radius * 100}vw;
119
- border-width: ${layoutParams.strokeWidth * 100}vw;
120
- }
110
+ return (`
111
+ .video-wrapper-${item.id} {
112
+ opacity: ${layoutParams.opacity};
113
+ transform: rotate(${area.angle}deg);
114
+ filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
115
+ }
116
+ .video-${item.id} {
117
+ border-color: ${color_1.CntrlColor.parse(layoutParams.strokeColor).fmt('rgba')};
118
+ border-radius: ${layoutParams.radius * 100}vw;
119
+ border-width: ${layoutParams.strokeWidth * 100}vw;
120
+ }
121
121
  `);
122
- })}
122
+ })}
123
123
  ` })] }));
124
124
  };
125
125
  exports.VideoItem = VideoItem;
@@ -34,21 +34,21 @@ const GroupItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
34
34
  (0, react_1.useEffect)(() => {
35
35
  onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
36
36
  }, [isInteractive, onVisibilityChange]);
37
- return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_d = item.link) === null || _d === void 0 ? void 0 : _d.url, target: (_e = item.link) === null || _e === void 0 ? void 0 : _e.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(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { transition: (_f = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _f !== void 0 ? _f : 'none' }), children: items && items.map(item => isInCompound ? ((0, jsx_runtime_1.jsx)(CompoundChild_1.CompoundChild, { item: item, sectionId: sectionId, isParentVisible: isInteractive }, item.id)) : ((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: `
38
- .group-${item.id} {
39
- position: absolute;
40
- width: 100%;
41
- height: 100%;
42
- box-sizing: border-box;
43
- }
37
+ return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_d = item.link) === null || _d === void 0 ? void 0 : _d.url, target: (_e = item.link) === null || _e === void 0 ? void 0 : _e.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(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { transition: (_f = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _f !== void 0 ? _f : 'none' }), children: items && items.map(item => isInCompound ? ((0, jsx_runtime_1.jsx)(CompoundChild_1.CompoundChild, { item: item, sectionId: sectionId, isParentVisible: isInteractive }, item.id)) : ((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: `
38
+ .group-${item.id} {
39
+ position: absolute;
40
+ width: 100%;
41
+ height: 100%;
42
+ box-sizing: border-box;
43
+ }
44
44
  ${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
45
- return (`
46
- .group-${item.id} {
47
- opacity: ${layoutParams.opacity};
48
- transform: rotate(${area.angle}deg);
49
- }
45
+ return (`
46
+ .group-${item.id} {
47
+ opacity: ${layoutParams.opacity};
48
+ transform: rotate(${area.angle}deg);
49
+ }
50
50
  `);
51
- })}
51
+ })}
52
52
  ` })] }) }));
53
53
  };
54
54
  exports.GroupItem = GroupItem;
@@ -28,9 +28,9 @@ const useSizing_1 = require("./useSizing");
28
28
  const useItemPointerEvents_1 = require("./useItemPointerEvents");
29
29
  const useItemArea_1 = require("./useItemArea");
30
30
  const useDraggable_1 = require("./useDraggable");
31
- const stickyFix = `
32
- -webkit-transform: translate3d(0, 0, 0);
33
- transform: translate3d(0, 0, 0);
31
+ const stickyFix = `
32
+ -webkit-transform: translate3d(0, 0, 0);
33
+ transform: translate3d(0, 0, 0);
34
34
  `;
35
35
  const noop = () => null;
36
36
  const Item = ({ item, sectionId, articleHeight, isParentVisible = true, isInGroup = false }) => {
@@ -134,40 +134,40 @@ const Item = ({ item, sectionId, articleHeight, isParentVisible = true, isInGrou
134
134
  ? 'grab'
135
135
  : hasClickTriggers
136
136
  ? 'pointer'
137
- : 'unset', pointerEvents: allowPointerEvents ? 'auto' : 'none', userSelect: isDraggable ? 'none' : 'unset', WebkitUserSelect: isDraggable ? 'none' : 'unset', MozUserSelect: isDraggable ? 'none' : 'unset', msUserSelect: isDraggable ? 'none' : 'unset' }) }, triggers, { children: (0, jsx_runtime_1.jsx)(ItemComponent, { item: item, sectionId: sectionId, onResize: handleItemResize, articleHeight: articleHeight, interactionCtrl: interactionCtrl, onVisibilityChange: handleVisibilityChange }) })) }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
137
+ : 'unset', pointerEvents: allowPointerEvents ? 'auto' : 'none', userSelect: isDraggable ? 'none' : 'unset', WebkitUserSelect: isDraggable ? 'none' : 'unset', MozUserSelect: isDraggable ? 'none' : 'unset', msUserSelect: isDraggable ? 'none' : 'unset' }) }, triggers, { children: (0, jsx_runtime_1.jsx)(ItemComponent, { item: item, sectionId: sectionId, onResize: handleItemResize, articleHeight: articleHeight, interactionCtrl: interactionCtrl, onVisibilityChange: handleVisibilityChange }) })) }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
138
138
  ${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, hidden, sticky, sectionHeight, layoutParams]) => {
139
139
  const sizingAxis = (0, useSizing_1.parseSizing)(layoutParams.sizing);
140
140
  const isScreenBasedBottom = area.positionType === sdk_1.PositionType.ScreenBased && area.anchorSide === sdk_1.AnchorSide.Bottom;
141
141
  const scaleAnchor = area.scaleAnchor;
142
- return (`
143
- .item-${item.id} {
144
- position: ${sticky ? 'sticky' : 'absolute'};
145
- top: ${sticky ? `${(0, getAnchoredItemTop_1.getAnchoredItemTop)(area.top - sticky.from, sectionHeight, area.anchorSide)}` : 0};
146
- transition: opacity 0.2s linear 0.1s;
147
- pointer-events: none;
148
- display: ${hidden ? 'none' : 'block'};
149
- height: fit-content;
150
- }
151
- .item-${item.id}-inner {
142
+ return (`
143
+ .item-${item.id} {
144
+ position: ${sticky ? 'sticky' : 'absolute'};
145
+ top: ${sticky ? `${(0, getAnchoredItemTop_1.getAnchoredItemTop)(area.top - sticky.from, sectionHeight, area.anchorSide)}` : 0};
146
+ transition: opacity 0.2s linear 0.1s;
147
+ pointer-events: none;
148
+ display: ${hidden ? 'none' : 'block'};
149
+ height: fit-content;
150
+ }
151
+ .item-${item.id}-inner {
152
152
  width: ${sizingAxis.x === 'manual'
153
153
  ? `${area.width * 100}vw`
154
- : 'max-content'};
155
- height: ${sizingAxis.y === 'manual' ? `${area.height * 100}vw` : 'unset'};
156
- transform-origin: ${ScaleAnchorMap_1.ScaleAnchorMap[scaleAnchor]};
157
- transform: scale(${area.scale});
158
- position: relative;
159
- }
160
- .item-wrapper-${item.id} {
161
- position: ${area.positionType === sdk_1.PositionType.ScreenBased ? 'fixed' : 'absolute'};
162
- z-index: ${area.zIndex};
163
- ${!isInGroup && stickyFix}
164
- pointer-events: none;
165
- bottom: ${isScreenBasedBottom ? `${-area.top * 100}vw` : 'unset'};
166
- top: ${isScreenBasedBottom ? 'unset' : (0, getItemTopStyle_1.getItemTopStyle)(area.top, area.anchorSide)};
167
- left: ${area.left * 100}vw;
168
- }
154
+ : 'max-content'};
155
+ height: ${sizingAxis.y === 'manual' ? `${area.height * 100}vw` : 'unset'};
156
+ transform-origin: ${ScaleAnchorMap_1.ScaleAnchorMap[scaleAnchor]};
157
+ transform: scale(${area.scale});
158
+ position: relative;
159
+ }
160
+ .item-wrapper-${item.id} {
161
+ position: ${area.positionType === sdk_1.PositionType.ScreenBased ? 'fixed' : 'absolute'};
162
+ z-index: ${area.zIndex};
163
+ ${!isInGroup && stickyFix}
164
+ pointer-events: none;
165
+ bottom: ${isScreenBasedBottom ? `${-area.top * 100}vw` : 'unset'};
166
+ top: ${isScreenBasedBottom ? 'unset' : (0, getItemTopStyle_1.getItemTopStyle)(area.top, area.anchorSide)};
167
+ left: ${area.left * 100}vw;
168
+ }
169
169
  `);
170
- })}
170
+ })}
171
171
  ` })] }));
172
172
  };
173
173
  exports.Item = Item;
@@ -46,28 +46,28 @@ const RectangleItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilit
46
46
  }, [isInteractive, onVisibilityChange]);
47
47
  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
48
48
  ? { backdropFilter: backdropFilterValue, WebkitBackdropFilter: backdropFilterValue }
49
- : {})), { 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: `
50
- .rectangle-${item.id} {
51
- position: absolute;
52
- width: 100%;
53
- height: 100%;
54
- border-style: solid;
55
- box-sizing: border-box;
56
- }
49
+ : {})), { 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: `
50
+ .rectangle-${item.id} {
51
+ position: absolute;
52
+ width: 100%;
53
+ height: 100%;
54
+ border-style: solid;
55
+ box-sizing: border-box;
56
+ }
57
57
  ${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
58
- return (`
59
- .rectangle-${item.id} {
60
- background-color: ${color_1.CntrlColor.parse(layoutParams.fillColor).fmt('rgba')};
61
- border-color: ${color_1.CntrlColor.parse(layoutParams.strokeColor).fmt('rgba')};
62
- border-radius: ${layoutParams.radius * 100}vw;
63
- border-width: ${layoutParams.strokeWidth * 100}vw;
64
- transform: rotate(${area.angle}deg);
65
- filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
66
- backdrop-filter: ${layoutParams.backdropBlur !== 0 ? `blur(${layoutParams.backdropBlur * 100}vw)` : 'unset'};
67
- -webkit-backdrop-filter: ${layoutParams.backdropBlur !== 0 ? `blur(${layoutParams.backdropBlur * 100}vw)` : 'unset'};
68
- }
58
+ return (`
59
+ .rectangle-${item.id} {
60
+ background-color: ${color_1.CntrlColor.parse(layoutParams.fillColor).fmt('rgba')};
61
+ border-color: ${color_1.CntrlColor.parse(layoutParams.strokeColor).fmt('rgba')};
62
+ border-radius: ${layoutParams.radius * 100}vw;
63
+ border-width: ${layoutParams.strokeWidth * 100}vw;
64
+ transform: rotate(${area.angle}deg);
65
+ filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
66
+ backdrop-filter: ${layoutParams.backdropBlur !== 0 ? `blur(${layoutParams.backdropBlur * 100}vw)` : 'unset'};
67
+ -webkit-backdrop-filter: ${layoutParams.backdropBlur !== 0 ? `blur(${layoutParams.backdropBlur * 100}vw)` : 'unset'};
68
+ }
69
69
  `);
70
- })}
70
+ })}
71
71
  ` })] }) }));
72
72
  };
73
73
  exports.RectangleItem = RectangleItem;
@@ -55,27 +55,27 @@ const RichTextItem = ({ item, sectionId, onResize, interactionCtrl, onVisibility
55
55
  }, [isInteractive, onVisibilityChange]);
56
56
  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]) => {
57
57
  const color = color_1.CntrlColor.parse(layoutParams.color);
58
- return (`
59
- .rich-text-wrapper-${item.id} {
60
- font-size: ${layoutParams.fontSize * 100}vw;
61
- line-height: ${layoutParams.lineHeight * 100}vw;
62
- letter-spacing: ${layoutParams.letterSpacing * 100}vw;
63
- word-spacing: ${layoutParams.wordSpacing * 100}vw;
64
- font-family: ${(0, getFontFamilyValue_1.getFontFamilyValue)(layoutParams.typeFace)};
65
- font-weight: ${layoutParams.fontWeight};
66
- font-style: ${layoutParams.fontStyle ? layoutParams.fontStyle : 'normal'};
67
- vertical-align: ${layoutParams.verticalAlign};
68
- font-variant: ${layoutParams.fontVariant};
69
- color: ${color.fmt('rgba')};
70
- transform: rotate(${area.angle}deg);
71
- filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
72
- text-transform: ${layoutParams.textTransform};
73
- }
74
- @supports not (color: oklch(42% 0.3 90 / 1)) {
75
- .rich-text-wrapper-${item.id} {
76
- color: ${color.fmt('rgba')};
77
- }
78
- }
58
+ return (`
59
+ .rich-text-wrapper-${item.id} {
60
+ font-size: ${layoutParams.fontSize * 100}vw;
61
+ line-height: ${layoutParams.lineHeight * 100}vw;
62
+ letter-spacing: ${layoutParams.letterSpacing * 100}vw;
63
+ word-spacing: ${layoutParams.wordSpacing * 100}vw;
64
+ font-family: ${(0, getFontFamilyValue_1.getFontFamilyValue)(layoutParams.typeFace)};
65
+ font-weight: ${layoutParams.fontWeight};
66
+ font-style: ${layoutParams.fontStyle ? layoutParams.fontStyle : 'normal'};
67
+ vertical-align: ${layoutParams.verticalAlign};
68
+ font-variant: ${layoutParams.fontVariant};
69
+ color: ${color.fmt('rgba')};
70
+ transform: rotate(${area.angle}deg);
71
+ filter: ${layoutParams.blur !== 0 ? `blur(${layoutParams.blur * 100}vw)` : 'unset'};
72
+ text-transform: ${layoutParams.textTransform};
73
+ }
74
+ @supports not (color: oklch(42% 0.3 90 / 1)) {
75
+ .rich-text-wrapper-${item.id} {
76
+ color: ${color.fmt('rgba')};
77
+ }
78
+ }
79
79
  `);
80
80
  })}`] })] }));
81
81
  };
@@ -15,6 +15,7 @@ class CntrlSdkContext {
15
15
  this.customItems = customItems;
16
16
  this.customSections = customSections;
17
17
  this._layouts = [];
18
+ this._fonts = undefined;
18
19
  this.sectionHeightMap = new Map();
19
20
  }
20
21
  resolveSectionData(sections) {
@@ -33,11 +34,15 @@ class CntrlSdkContext {
33
34
  }
34
35
  init({ project, article }) {
35
36
  this.setLayouts(project.layouts);
37
+ this.setFonts(project.fonts);
36
38
  this.setSectionsHeight(article.sections);
37
39
  }
38
40
  setLayouts(layouts) {
39
41
  this._layouts = layouts;
40
42
  }
43
+ setFonts(fonts) {
44
+ this._fonts = fonts;
45
+ }
41
46
  setSectionsHeight(sections) {
42
47
  for (const section of sections) {
43
48
  this.sectionHeightMap.set(section.id, section.height);
@@ -50,6 +55,9 @@ class CntrlSdkContext {
50
55
  get layouts() {
51
56
  return this._layouts;
52
57
  }
58
+ get fonts() {
59
+ return this._fonts;
60
+ }
53
61
  }
54
62
  exports.CntrlSdkContext = CntrlSdkContext;
55
63
  function isDefined(value) {
@@ -61,13 +61,13 @@ class RichTextConverter {
61
61
  const kids = [];
62
62
  layouts.forEach(l => {
63
63
  const ta = richText.layoutParams[l.id].textAlign;
64
- styleRules[l.id].push(`
65
- .${blockClass} {
66
- display: ${group.some(g => g.layout === l.id) ? 'block' : 'none'};
67
- text-align: ${ta};
68
- white-space: pre-wrap;
69
- overflow-wrap: break-word;
70
- }
64
+ styleRules[l.id].push(`
65
+ .${blockClass} {
66
+ display: ${group.some(g => g.layout === l.id) ? 'block' : 'none'};
67
+ text-align: ${ta};
68
+ white-space: pre-wrap;
69
+ overflow-wrap: break-word;
70
+ }
71
71
  `);
72
72
  });
73
73
  const item = group[0];
@@ -111,18 +111,18 @@ class RichTextConverter {
111
111
  if (lineHeight === null || lineHeight === void 0 ? void 0 : lineHeight.value) {
112
112
  currentLineHeight[item.layout] = lineHeight.value;
113
113
  }
114
- styleRules[item.layout].push(`
115
- .${blockClass} .s-${styleGroup.start}-${styleGroup.end} {
116
- ${styleGroup.styles.map(s => RichTextConverter.fromRangeStylesToInline(s, exemplary)).join('\n')}
117
- }
114
+ styleRules[item.layout].push(`
115
+ .${blockClass} .s-${styleGroup.start}-${styleGroup.end} {
116
+ ${styleGroup.styles.map(s => RichTextConverter.fromRangeStylesToInline(s, exemplary)).join('\n')}
117
+ }
118
118
  `);
119
119
  if (color) {
120
- styleRules[item.layout].push(`
121
- @supports not (color: oklch(42% 0.3 90 / 1)) {
122
- .${blockClass} .s-${styleGroup.start}-${styleGroup.end} {
123
- color: ${color_1.CntrlColor.parse(getResolvedValue(color.value, 'COLOR')).fmt('rgba')};
124
- }
125
- }
120
+ styleRules[item.layout].push(`
121
+ @supports not (color: oklch(42% 0.3 90 / 1)) {
122
+ .${blockClass} .s-${styleGroup.start}-${styleGroup.end} {
123
+ color: ${color_1.CntrlColor.parse(getResolvedValue(color.value, 'COLOR')).fmt('rgba')};
124
+ }
125
+ }
126
126
  `);
127
127
  }
128
128
  }
@@ -131,10 +131,10 @@ class RichTextConverter {
131
131
  root.push((0, jsx_runtime_1.jsx)("div", { className: blockClass, children: kids }, blockClass));
132
132
  }
133
133
  }
134
- const styles = layouts.map(l => `
135
- ${(0, sdk_1.getLayoutMediaQuery)(l.id, layouts)} {
136
- ${styleRules[l.id].join('\n')}
137
- }
134
+ const styles = layouts.map(l => `
135
+ ${(0, sdk_1.getLayoutMediaQuery)(l.id, layouts)} {
136
+ ${styleRules[l.id].join('\n')}
137
+ }
138
138
  `).join('\n');
139
139
  return [
140
140
  root,
package/package.json CHANGED
@@ -1,57 +1,57 @@
1
- {
2
- "name": "@cntrl-site/sdk-nextjs",
3
- "version": "1.6.11",
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
- "main": "lib/index.js",
16
- "types": "src/index.ts",
17
- "scripts": {
18
- "test": "jest",
19
- "prebuild": "rm -rf ./lib",
20
- "build": "tsc --project tsconfig.build.json",
21
- "prepublishOnly": "NODE_ENV=production npm run build"
22
- },
23
- "peerDependencies": {
24
- "@types/lodash.isequal": "^4.5.6",
25
- "lodash.isequal": "^4.5.0",
26
- "next": "^14.2.3",
27
- "react": "^18.3.1",
28
- "react-dom": "^18.3.1"
29
- },
30
- "dependencies": {
31
- "@antfu/eslint-config": "^3.8.0",
32
- "@cntrl-site/color": "^1.0.0",
33
- "@cntrl-site/effects": "^1.3.2",
34
- "@cntrl-site/sdk": "^1.19.4",
35
- "@types/vimeo__player": "^2.18.0",
36
- "@vimeo/player": "^2.25.0",
37
- "html-react-parser": "^3.0.1",
38
- "resize-observer-polyfill": "^1.5.1",
39
- "styled-jsx": "^5.0.2"
40
- },
41
- "devDependencies": {
42
- "@testing-library/jest-dom": "^6.4.8",
43
- "@testing-library/react": "^16.0.0",
44
- "@tsconfig/node16": "^1.0.3",
45
- "@tsconfig/recommended": "^1.0.1",
46
- "@types/jest": "^29.5.12",
47
- "@types/node": "^18.11.7",
48
- "@types/react": "^18.0.15",
49
- "jest": "^29.7.0",
50
- "jest-environment-jsdom": "^29.7.0",
51
- "ts-jest": "^29.0.3",
52
- "typescript": "^5.2.2"
53
- },
54
- "directories": {
55
- "lib": "lib"
56
- }
57
- }
1
+ {
2
+ "name": "@cntrl-site/sdk-nextjs",
3
+ "version": "1.6.12",
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
+ "main": "lib/index.js",
16
+ "types": "src/index.ts",
17
+ "scripts": {
18
+ "test": "jest",
19
+ "prebuild": "rm -rf ./lib",
20
+ "build": "tsc --project tsconfig.build.json",
21
+ "prepublishOnly": "set NODE_ENV=production npm run build"
22
+ },
23
+ "peerDependencies": {
24
+ "@types/lodash.isequal": "^4.5.6",
25
+ "lodash.isequal": "^4.5.0",
26
+ "next": "^14.2.3",
27
+ "react": "^18.3.1",
28
+ "react-dom": "^18.3.1"
29
+ },
30
+ "dependencies": {
31
+ "@antfu/eslint-config": "^3.8.0",
32
+ "@cntrl-site/color": "^1.0.0",
33
+ "@cntrl-site/effects": "^1.3.2",
34
+ "@cntrl-site/sdk": "^1.19.4",
35
+ "@types/vimeo__player": "^2.18.0",
36
+ "@vimeo/player": "^2.25.0",
37
+ "html-react-parser": "^3.0.1",
38
+ "resize-observer-polyfill": "^1.5.1",
39
+ "styled-jsx": "^5.0.2"
40
+ },
41
+ "devDependencies": {
42
+ "@testing-library/jest-dom": "^6.4.8",
43
+ "@testing-library/react": "^16.0.0",
44
+ "@tsconfig/node16": "^1.0.3",
45
+ "@tsconfig/recommended": "^1.0.1",
46
+ "@types/jest": "^29.5.12",
47
+ "@types/node": "^18.11.7",
48
+ "@types/react": "^18.0.15",
49
+ "jest": "^29.7.0",
50
+ "jest-environment-jsdom": "^29.7.0",
51
+ "ts-jest": "^29.0.3",
52
+ "typescript": "^5.2.2"
53
+ },
54
+ "directories": {
55
+ "lib": "lib"
56
+ }
57
+ }