@cntrl-site/sdk-nextjs 1.6.9 → 1.6.11-alpha.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.
Binary file
Binary file
@@ -69,7 +69,7 @@ const CompoundChild = ({ item, sectionId, isParentVisible = true }) => {
69
69
  ? { height: `${sizingAxis.y === 'manual'
70
70
  ? (0, getCompoundBondaryStyles_1.getCompoundHeight)(compoundSettings, height)
71
71
  : 'unset'}` }
72
- : {})), (compoundSettings ? { transform: `${(0, getCompoundBondaryStyles_1.getCompoundTransform)(compoundSettings)}` } : {})), { transition: (_k = stateProps === null || stateProps === void 0 ? void 0 : stateProps.transition) !== null && _k !== void 0 ? _k : 'none', cursor: hasClickTriggers ? 'pointer' : 'unset', pointerEvents: allowPointerEvents ? 'auto' : 'none' }) }, triggers, { children: [(0, jsx_runtime_1.jsx)("div", { className: `item-${item.id}-inner`, style: Object.assign({}, (scale !== undefined ? { transform: `scale(${scale})` } : {})), children: (0, jsx_runtime_1.jsx)(RichTextWrapper_1.RichTextWrapper, { isRichText: isRichText, transformOrigin: transformOrigin, children: (0, jsx_runtime_1.jsx)(ItemComponent, { item: item, sectionId: sectionId, interactionCtrl: interactionCtrl, onVisibilityChange: handleVisibilityChange }) }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
72
+ : {})), (compoundSettings ? { transform: `${(0, getCompoundBondaryStyles_1.getCompoundTransform)(compoundSettings)}` } : {})), { transition: (_k = stateProps === null || stateProps === void 0 ? void 0 : stateProps.transition) !== null && _k !== void 0 ? _k : 'none', cursor: hasClickTriggers ? 'pointer' : 'unset', pointerEvents: allowPointerEvents ? 'auto' : 'none' }) }, triggers, { children: [(0, jsx_runtime_1.jsx)("div", { className: `item-${item.id}-inner`, style: Object.assign({}, (scale !== undefined ? { transform: `scale(${scale})` } : {})), children: (0, jsx_runtime_1.jsx)(RichTextWrapper_1.RichTextWrapper, { isRichText: isRichText, transformOrigin: transformOrigin, children: (0, jsx_runtime_1.jsx)(ItemComponent, { item: item, sectionId: sectionId, interactionCtrl: interactionCtrl, onVisibilityChange: handleVisibilityChange, isInCompound: true }) }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
73
73
  ${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, hidden, compoundSettings, layoutParams]) => {
74
74
  const sizingAxis = (0, useSizing_1.parseSizing)(layoutParams.sizing);
75
75
  const scaleAnchor = area.scaleAnchor;
@@ -15,7 +15,8 @@ const useCntrlContext_1 = require("../../../provider/useCntrlContext");
15
15
  const useItemAngle_1 = require("../useItemAngle");
16
16
  const useGroupItem_1 = require("./useGroupItem");
17
17
  const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromItemStateAndParams");
18
- const GroupItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
18
+ const CompoundChild_1 = require("../CompoundItem/CompoundChild");
19
+ const GroupItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange, isInCompound }) => {
19
20
  var _a, _b, _c, _d, _e, _f;
20
21
  const id = (0, react_1.useId)();
21
22
  const { items } = item;
@@ -33,7 +34,7 @@ const GroupItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
33
34
  (0, react_1.useEffect)(() => {
34
35
  onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
35
36
  }, [isInteractive, onVisibilityChange]);
36
- 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 => ((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: `
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: `
37
38
  .group-${item.id} {
38
39
  position: absolute;
39
40
  width: 100%;
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.InteractionsRegistry = void 0;
15
4
  const sdk_1 = require("@cntrl-site/sdk");
@@ -204,22 +193,26 @@ class InteractionsRegistry {
204
193
  }
205
194
  }
206
195
  unpackItems(article) {
207
- var _a;
208
196
  const itemsArr = [];
209
197
  for (const section of article.sections) {
210
- for (const item of section.items) {
211
- const { items } = item, itemWithoutChildren = __rest(item, ["items"]);
212
- itemsArr.push(itemWithoutChildren);
213
- if ((0, isItemType_1.isItemType)(item, sdk_1.ArticleItemType.Group) || (0, isItemType_1.isItemType)(item, sdk_1.ArticleItemType.Compound)) {
214
- const groupChildren = (_a = item === null || item === void 0 ? void 0 : item.items) !== null && _a !== void 0 ? _a : [];
215
- for (const child of groupChildren) {
216
- itemsArr.push(child);
217
- }
218
- }
219
- }
198
+ const items = this.getNestedItems(section.items);
199
+ itemsArr.push(...items);
220
200
  }
221
201
  return itemsArr;
222
202
  }
203
+ getNestedItems(items) {
204
+ var _a;
205
+ const allItems = [];
206
+ for (const item of items) {
207
+ if ((0, isItemType_1.isItemType)(item, sdk_1.ArticleItemType.Group) || (0, isItemType_1.isItemType)(item, sdk_1.ArticleItemType.Compound)) {
208
+ const groupChildren = (_a = item === null || item === void 0 ? void 0 : item.items) !== null && _a !== void 0 ? _a : [];
209
+ const nestedItems = this.getNestedItems(groupChildren);
210
+ allItems.push(...nestedItems);
211
+ }
212
+ allItems.push(item);
213
+ }
214
+ return allItems;
215
+ }
223
216
  getDefaultItemStages() {
224
217
  const timestamp = Date.now();
225
218
  const { items, layoutId } = this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk-nextjs",
3
- "version": "1.6.9",
3
+ "version": "1.6.11-alpha.0",
4
4
  "description": "SDK for Next.js",
5
5
  "author": "arsen@momdesign.nyc",
6
6
  "license": "MIT",
@@ -83,13 +83,13 @@ export const CompoundChild: FC<ChildItemProps> = ({ item, sectionId, isParentVis
83
83
  ...(top !== undefined && compoundSettings ? { top: getCompoundTop(compoundSettings, top) } : {}),
84
84
  ...(left !== undefined && compoundSettings ? { left: getCompoundLeft(compoundSettings, left) } : {}),
85
85
  ...(width !== undefined && compoundSettings
86
- ? { width: `${sizingAxis.x === 'manual'
87
- ? getCompoundWidth(compoundSettings, width, isRichText, exemplary)
86
+ ? { width: `${sizingAxis.x === 'manual'
87
+ ? getCompoundWidth(compoundSettings, width, isRichText, exemplary)
88
88
  : 'max-content'}` }
89
89
  : {}),
90
90
  ...(height !== undefined && compoundSettings
91
- ? { height: `${sizingAxis.y === 'manual'
92
- ? getCompoundHeight(compoundSettings, height)
91
+ ? { height: `${sizingAxis.y === 'manual'
92
+ ? getCompoundHeight(compoundSettings, height)
93
93
  : 'unset'}` }
94
94
  : {}),
95
95
  ...(compoundSettings ? { transform: `${getCompoundTransform(compoundSettings)}` } : {}),
@@ -99,25 +99,27 @@ export const CompoundChild: FC<ChildItemProps> = ({ item, sectionId, isParentVis
99
99
  }}
100
100
  {...triggers}
101
101
  >
102
- <div className={`item-${item.id}-inner`}
102
+ <div
103
+ className={`item-${item.id}-inner`}
103
104
  style={{
104
105
  ...(scale !== undefined ? { transform: `scale(${scale})` } : {}),
105
106
  }}
106
107
  >
107
- <RichTextWrapper isRichText={isRichText} transformOrigin={transformOrigin}>
108
- <ItemComponent
109
- item={item}
110
- sectionId={sectionId}
111
- interactionCtrl={interactionCtrl}
112
- onVisibilityChange={handleVisibilityChange}
113
- />
114
- </RichTextWrapper>
108
+ <RichTextWrapper isRichText={isRichText} transformOrigin={transformOrigin}>
109
+ <ItemComponent
110
+ item={item}
111
+ sectionId={sectionId}
112
+ interactionCtrl={interactionCtrl}
113
+ onVisibilityChange={handleVisibilityChange}
114
+ isInCompound
115
+ />
116
+ </RichTextWrapper>
115
117
  </div>
116
118
  <JSXStyle id={id}>{`
117
119
  ${getLayoutStyles(layouts, layoutValues, ([area, hidden, compoundSettings, layoutParams]) => {
118
- const sizingAxis = parseSizing(layoutParams.sizing);
119
- const scaleAnchor = area.scaleAnchor as AreaAnchor;
120
- return (`
120
+ const sizingAxis = parseSizing(layoutParams.sizing);
121
+ const scaleAnchor = area.scaleAnchor as AreaAnchor;
122
+ return (`
121
123
  .item-${item.id}-inner {
122
124
  width: 100%;
123
125
  height: 100%;
@@ -131,15 +133,16 @@ export const CompoundChild: FC<ChildItemProps> = ({ item, sectionId, isParentVis
131
133
  transition: opacity 0.2s linear 0.1s;
132
134
  display: ${hidden ? 'none' : 'block'};
133
135
  width: ${sizingAxis.x === 'manual'
134
- ? `${getCompoundWidth(compoundSettings, area.width, isRichText)}`
135
- : 'max-content'};
136
+ ? `${getCompoundWidth(compoundSettings, area.width, isRichText)}`
137
+ : 'max-content'};
136
138
  height: ${sizingAxis.y === 'manual' ? `${getCompoundHeight(compoundSettings, area.height)}` : 'unset'};
137
139
  transform: ${getCompoundTransform(compoundSettings)};
138
140
  z-index: ${area.zIndex};
139
141
  }
140
142
  `);
141
- })}
142
- `}</JSXStyle>
143
+ })}
144
+ `}
145
+ </JSXStyle>
143
146
  </div>
144
147
  );
145
148
  };
@@ -8,8 +8,9 @@ import { useCntrlContext } from '../../../provider/useCntrlContext';
8
8
  import { useItemAngle } from '../useItemAngle';
9
9
  import { useGroupItem } from './useGroupItem';
10
10
  import { getStyleFromItemStateAndParams } from '../../../utils/getStyleFromItemStateAndParams';
11
+ import { CompoundChild } from '../CompoundItem/CompoundChild';
11
12
 
12
- export const GroupItem: FC<ItemProps<TGroupItem>> = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
13
+ export const GroupItem: FC<ItemProps<TGroupItem>> = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange, isInCompound }) => {
13
14
  const id = useId();
14
15
  const { items } = item;
15
16
  const itemAngle = useItemAngle(item, sectionId);
@@ -39,7 +40,14 @@ export const GroupItem: FC<ItemProps<TGroupItem>> = ({ item, sectionId, onResize
39
40
  transition: stateParams?.transition ?? 'none'
40
41
  }}
41
42
  >
42
- {items && items.map(item => (
43
+ {items && items.map(item => isInCompound ? (
44
+ <CompoundChild
45
+ item={item}
46
+ key={item.id}
47
+ sectionId={sectionId}
48
+ isParentVisible={isInteractive}
49
+ />
50
+ ) : (
43
51
  <Item
44
52
  item={item}
45
53
  key={item.id}
@@ -57,13 +65,13 @@ export const GroupItem: FC<ItemProps<TGroupItem>> = ({ item, sectionId, onResize
57
65
  box-sizing: border-box;
58
66
  }
59
67
  ${getLayoutStyles(layouts, layoutValues, ([area, layoutParams]) => {
60
- return (`
68
+ return (`
61
69
  .group-${item.id} {
62
70
  opacity: ${layoutParams.opacity};
63
71
  transform: rotate(${area.angle}deg);
64
72
  }
65
73
  `);
66
- })}
74
+ })}
67
75
  `}</JSXStyle>
68
76
  </>
69
77
  </LinkWrapper>
@@ -43,6 +43,7 @@ export interface ItemProps<I extends ItemAny> {
43
43
  onResize?: (height: number) => void;
44
44
  interactionCtrl?: ReturnType<typeof useItemInteractionCtrl>;
45
45
  onVisibilityChange: (isVisible: boolean) => void;
46
+ isInCompound?: boolean;
46
47
  }
47
48
 
48
49
  export interface ItemWrapperProps {
@@ -107,7 +108,7 @@ export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight, isP
107
108
  if (!item) return;
108
109
  if (drag) {
109
110
  setIsDraggingActive(true);
110
- setPosition({
111
+ setPosition({
111
112
  x: (currentX - startX) + lastX,
112
113
  y: (currentY - startY) + lastY
113
114
  });
@@ -183,12 +184,12 @@ export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight, isP
183
184
  : {}),
184
185
  ...(scale !== undefined ? { transform: `scale(${scale})`, WebkitTransform: `scale(${scale})` } : {}),
185
186
  transition: innerStateProps?.transition ?? 'none',
186
- cursor: isDraggingActive
187
- ? 'grabbing'
188
- : isDraggable
187
+ cursor: isDraggingActive
188
+ ? 'grabbing'
189
+ : isDraggable
189
190
  ? 'grab'
190
- : hasClickTriggers
191
- ? 'pointer'
191
+ : hasClickTriggers
192
+ ? 'pointer'
192
193
  : 'unset',
193
194
  pointerEvents: allowPointerEvents ? 'auto' : 'none',
194
195
  userSelect: isDraggable ? 'none' : 'unset',
@@ -206,20 +206,25 @@ export class InteractionsRegistry implements InteractionsRegistryPort {
206
206
  private unpackItems(article: Article): ItemAny[] {
207
207
  const itemsArr = [];
208
208
  for (const section of article.sections) {
209
- for (const item of section.items) {
210
- const { items, ...itemWithoutChildren } = item;
211
- itemsArr.push(itemWithoutChildren);
212
- if (isItemType(item, ArticleItemType.Group) || isItemType(item, ArticleItemType.Compound)) {
213
- const groupChildren = item?.items ?? [];
214
- for (const child of groupChildren) {
215
- itemsArr.push(child);
216
- }
217
- }
218
- }
209
+ const items = this.getNestedItems(section.items);
210
+ itemsArr.push(...items);
219
211
  }
220
212
  return itemsArr;
221
213
  }
222
214
 
215
+ private getNestedItems(items: ItemAny[]): ItemAny[] {
216
+ const allItems: ItemAny[] = [];
217
+ for (const item of items) {
218
+ if (isItemType(item, ArticleItemType.Group) || isItemType(item, ArticleItemType.Compound)) {
219
+ const groupChildren = item?.items ?? [];
220
+ const nestedItems = this.getNestedItems(groupChildren);
221
+ allItems.push(...nestedItems);
222
+ }
223
+ allItems.push(item);
224
+ }
225
+ return allItems;
226
+ }
227
+
223
228
  private getDefaultItemStages(): ItemStages {
224
229
  const timestamp = Date.now();
225
230
  const { items, layoutId } = this;
@@ -1,5 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <state>
3
- <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
4
- </state>
5
- </component>
@@ -1,15 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <profile version="1.0">
3
- <option name="myName" value="Project Default" />
4
- <inspection_tool class="HtmlUnknownAttribute" enabled="true" level="WARNING" enabled_by_default="true">
5
- <option name="myValues">
6
- <value>
7
- <list size="1">
8
- <item index="0" class="java.lang.String" itemvalue="jsx" />
9
- </list>
10
- </value>
11
- </option>
12
- <option name="myCustomValuesEnabled" value="true" />
13
- </inspection_tool>
14
- </profile>
15
- </component>