@cntrl-site/sdk-nextjs 1.7.0-alpha.8 → 1.7.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.
@@ -5,12 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ComponentItem = void 0;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const style_1 = __importDefault(require("styled-jsx/style"));
8
9
  const sdk_1 = require("@cntrl-site/sdk");
9
10
  const react_1 = require("react");
10
11
  const useCntrlContext_1 = require("../../../provider/useCntrlContext");
11
12
  const useComponentItem_1 = require("./useComponentItem");
12
13
  const useItemAngle_1 = require("../useItemAngle");
13
- const style_1 = __importDefault(require("styled-jsx/style"));
14
14
  const useRegisterResize_1 = require("../../../common/useRegisterResize");
15
15
  const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromItemStateAndParams");
16
16
  const useLayoutContext_1 = require("../../useLayoutContext");
@@ -28,23 +28,20 @@ const ComponentItem = ({ item, sectionId, onResize, 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
- if (!component || !layout)
32
- return null;
33
- const Element = component.element;
34
- const parameters = item.layoutParams[layout].parameters;
35
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `custom-component-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), { transition: (_c = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _c !== void 0 ? _c : 'none' }), children: (0, jsx_runtime_1.jsx)(Element, Object.assign({ content: item.commonParams.content }, parameters)) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: item.id, children: `
31
+ const Element = component ? component.element : undefined;
32
+ const parameters = layout ? item.layoutParams[layout].parameters : undefined;
33
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `custom-component-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), { transition: (_c = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _c !== void 0 ? _c : 'none' }), children: parameters && Element && ((0, jsx_runtime_1.jsx)(Element, Object.assign({ content: item.commonParams.content }, parameters))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: item.id, children: `
34
+ .custom-component-${item.id} {
35
+ width: 100%;
36
+ height: 100%;
37
+ }
38
+ ${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
39
+ return (`
36
40
  .custom-component-${item.id} {
37
- width: 100%;
38
- height: 100%;
41
+ transform: rotate(${area.angle}deg);
42
+ opacity: ${layoutParams.opacity};
39
43
  }
40
- ${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
41
- return (`
42
- .custom-component-${item.id} {
43
- transform: rotate(${area.angle}deg);
44
- opacity: ${layoutParams.opacity};
45
- }
46
- `);
47
- })}
48
- ` })] }));
44
+ `);
45
+ })}` })] }));
49
46
  };
50
47
  exports.ComponentItem = ComponentItem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk-nextjs",
3
- "version": "1.7.0-alpha.8",
3
+ "version": "1.7.0",
4
4
  "description": "SDK for Next.js",
5
5
  "author": "arsen@momdesign.nyc",
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "@antfu/eslint-config": "^3.8.0",
32
32
  "@cntrl-site/color": "^1.0.0",
33
33
  "@cntrl-site/effects": "^1.3.2",
34
- "@cntrl-site/sdk": "^1.21.0-alpha.8",
34
+ "@cntrl-site/sdk": "^1.21.1",
35
35
  "@types/vimeo__player": "^2.18.0",
36
36
  "@vimeo/player": "^2.25.0",
37
37
  "html-react-parser": "^3.0.1",
@@ -1,10 +1,10 @@
1
+ import JSXStyle from 'styled-jsx/style';
1
2
  import { ItemProps } from '../Item';
2
3
  import { ComponentItem as TComponentItem, getLayoutStyles } from '@cntrl-site/sdk';
3
- import { FC, useState } from 'react';
4
+ import { FC, useId, useState } from 'react';
4
5
  import { useCntrlContext } from '../../../provider/useCntrlContext';
5
6
  import { useComponentItem } from './useComponentItem';
6
7
  import { useItemAngle } from '../useItemAngle';
7
- import JSXStyle from 'styled-jsx/style';
8
8
  import { useRegisterResize } from '../../../common/useRegisterResize';
9
9
  import { getStyleFromItemStateAndParams } from '../../../utils/getStyleFromItemStateAndParams';
10
10
  import { useLayoutContext } from '../../useLayoutContext';
@@ -22,9 +22,8 @@ export const ComponentItem: FC<ItemProps<TComponentItem>> = ({ item, sectionId,
22
22
  const stateParams = interactionCtrl?.getState(['opacity', 'angle']);
23
23
  const angle = getStyleFromItemStateAndParams(stateParams?.styles?.angle, itemAngle);
24
24
  const opacity = getStyleFromItemStateAndParams(stateParams?.styles?.opacity, itemOpacity);
25
- if (!component || !layout) return null;
26
- const Element = component.element;
27
- const parameters = item.layoutParams[layout].parameters;
25
+ const Element = component ? component.element : undefined;
26
+ const parameters = layout ? item.layoutParams[layout].parameters : undefined;
28
27
  return (
29
28
  <>
30
29
  <div
@@ -36,26 +35,26 @@ export const ComponentItem: FC<ItemProps<TComponentItem>> = ({ item, sectionId,
36
35
  transition: stateParams?.transition ?? 'none'
37
36
  }}
38
37
  >
39
- <Element
40
- content={item.commonParams.content}
41
- {...parameters}
42
- />
38
+ {parameters && Element && (
39
+ <Element
40
+ content={item.commonParams.content}
41
+ {...parameters}
42
+ />
43
+ )}
43
44
  </div>
44
- <JSXStyle id={item.id}>
45
- {`
45
+ <JSXStyle id={item.id}>{`
46
+ .custom-component-${item.id} {
47
+ width: 100%;
48
+ height: 100%;
49
+ }
50
+ ${getLayoutStyles(layouts, layoutValues, ([area, layoutParams]) => {
51
+ return (`
46
52
  .custom-component-${item.id} {
47
- width: 100%;
48
- height: 100%;
53
+ transform: rotate(${area.angle}deg);
54
+ opacity: ${layoutParams.opacity};
49
55
  }
50
- ${getLayoutStyles(layouts, layoutValues, ([area, layoutParams]) => {
51
- return (`
52
- .custom-component-${item.id} {
53
- transform: rotate(${area.angle}deg);
54
- opacity: ${layoutParams.opacity};
55
- }
56
- `);
57
- })}
58
- `}
56
+ `);
57
+ })}`}
59
58
  </JSXStyle>
60
59
  </>
61
60
  );
@@ -6,8 +6,7 @@ import { getStyleFromItemStateAndParams } from '../../../utils/getStyleFromItemS
6
6
  import { LinkWrapper } from '../LinkWrapper';
7
7
  import { ItemProps } from '../Item';
8
8
  import JSXStyle from 'styled-jsx/style';
9
- import { getLayoutStyles } from '@cntrl-site/sdk';
10
- import { CompoundItem as TCompoundItem } from '@cntrl-site/sdk';
9
+ import { getLayoutStyles, CompoundItem as TCompoundItem } from '@cntrl-site/sdk';
11
10
  import { CompoundChild } from './CompoundChild';
12
11
  import { useCompoundItem } from './useCompoundItem';
13
12