@cntrl-site/sdk-nextjs 1.7.0-alpha.10 → 1.7.0-alpha.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.
|
@@ -5,18 +5,19 @@ 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");
|
|
17
17
|
const ComponentItem = ({ item, sectionId, onResize, interactionCtrl }) => {
|
|
18
18
|
var _a, _b, _c;
|
|
19
19
|
const sdk = (0, useCntrlContext_1.useCntrlContext)();
|
|
20
|
+
const id = (0, react_1.useId)();
|
|
20
21
|
const { layouts } = sdk;
|
|
21
22
|
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
22
23
|
const layout = (0, useLayoutContext_1.useLayoutContext)();
|
|
@@ -32,15 +33,20 @@ const ComponentItem = ({ item, sectionId, onResize, interactionCtrl }) => {
|
|
|
32
33
|
return null;
|
|
33
34
|
const Element = component.element;
|
|
34
35
|
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.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
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.jsxs)(style_1.default, { id: id, children: [" ", `
|
|
37
|
+
.custom-component-${item.id} {
|
|
38
|
+
width: 100%;
|
|
39
|
+
height: 100%;
|
|
40
|
+
}
|
|
41
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
|
|
42
|
+
return (`
|
|
43
|
+
.custom-component-${item.id} {
|
|
44
|
+
transform: rotate(${area.angle}deg);
|
|
45
|
+
opacity: ${layoutParams.opacity};
|
|
46
|
+
width: 100%;
|
|
47
|
+
height: 100%;
|
|
48
|
+
}
|
|
49
|
+
`);
|
|
50
|
+
})}`] })] }));
|
|
45
51
|
};
|
|
46
52
|
exports.ComponentItem = ComponentItem;
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
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';
|
|
11
11
|
|
|
12
12
|
export const ComponentItem: FC<ItemProps<TComponentItem>> = ({ item, sectionId, onResize, interactionCtrl }) => {
|
|
13
13
|
const sdk = useCntrlContext();
|
|
14
|
+
const id = useId();
|
|
14
15
|
const { layouts } = sdk;
|
|
15
16
|
const itemAngle = useItemAngle(item, sectionId);
|
|
16
17
|
const layout = useLayoutContext();
|
|
@@ -41,17 +42,21 @@ export const ComponentItem: FC<ItemProps<TComponentItem>> = ({ item, sectionId,
|
|
|
41
42
|
{...parameters}
|
|
42
43
|
/>
|
|
43
44
|
</div>
|
|
44
|
-
<JSXStyle id={
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
<JSXStyle id={id}> {`
|
|
46
|
+
.custom-component-${item.id} {
|
|
47
|
+
width: 100%;
|
|
48
|
+
height: 100%;
|
|
49
|
+
}
|
|
50
|
+
${getLayoutStyles(layouts, layoutValues, ([area, layoutParams]) => {
|
|
51
|
+
return (`
|
|
52
|
+
.custom-component-${item.id} {
|
|
53
|
+
transform: rotate(${area.angle}deg);
|
|
54
|
+
opacity: ${layoutParams.opacity};
|
|
55
|
+
width: 100%;
|
|
56
|
+
height: 100%;
|
|
57
|
+
}
|
|
58
|
+
`);
|
|
59
|
+
})}`}
|
|
55
60
|
</JSXStyle>
|
|
56
61
|
</>
|
|
57
62
|
);
|