@cntrl-site/sdk-nextjs 1.7.0-alpha.12 → 1.7.0-alpha.13
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
|
|
@@ -17,7 +17,6 @@ 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)();
|
|
21
20
|
const { layouts } = sdk;
|
|
22
21
|
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
23
22
|
const layout = (0, useLayoutContext_1.useLayoutContext)();
|
|
@@ -29,24 +28,20 @@ const ComponentItem = ({ item, sectionId, onResize, interactionCtrl }) => {
|
|
|
29
28
|
const stateParams = interactionCtrl === null || interactionCtrl === void 0 ? void 0 : interactionCtrl.getState(['opacity', 'angle']);
|
|
30
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);
|
|
31
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);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const parameters = item.layoutParams[layout].parameters;
|
|
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: [" ", `
|
|
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: `
|
|
37
34
|
.custom-component-${item.id} {
|
|
38
35
|
width: 100%;
|
|
39
36
|
height: 100%;
|
|
40
37
|
}
|
|
41
38
|
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
|
|
42
|
-
|
|
39
|
+
return (`
|
|
43
40
|
.custom-component-${item.id} {
|
|
44
41
|
transform: rotate(${area.angle}deg);
|
|
45
42
|
opacity: ${layoutParams.opacity};
|
|
46
|
-
width: 100%;
|
|
47
|
-
height: 100%;
|
|
48
43
|
}
|
|
49
44
|
`);
|
|
50
|
-
|
|
45
|
+
})}` })] }));
|
|
51
46
|
};
|
|
52
47
|
exports.ComponentItem = ComponentItem;
|
package/package.json
CHANGED
|
@@ -11,7 +11,6 @@ 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();
|
|
15
14
|
const { layouts } = sdk;
|
|
16
15
|
const itemAngle = useItemAngle(item, sectionId);
|
|
17
16
|
const layout = useLayoutContext();
|
|
@@ -23,9 +22,8 @@ export const ComponentItem: FC<ItemProps<TComponentItem>> = ({ item, sectionId,
|
|
|
23
22
|
const stateParams = interactionCtrl?.getState(['opacity', 'angle']);
|
|
24
23
|
const angle = getStyleFromItemStateAndParams(stateParams?.styles?.angle, itemAngle);
|
|
25
24
|
const opacity = getStyleFromItemStateAndParams(stateParams?.styles?.opacity, itemOpacity);
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const parameters = item.layoutParams[layout].parameters;
|
|
25
|
+
const Element = component ? component.element : undefined;
|
|
26
|
+
const parameters = layout ? item.layoutParams[layout].parameters : undefined;
|
|
29
27
|
return (
|
|
30
28
|
<>
|
|
31
29
|
<div
|
|
@@ -37,26 +35,26 @@ export const ComponentItem: FC<ItemProps<TComponentItem>> = ({ item, sectionId,
|
|
|
37
35
|
transition: stateParams?.transition ?? 'none'
|
|
38
36
|
}}
|
|
39
37
|
>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
{parameters && Element && (
|
|
39
|
+
<Element
|
|
40
|
+
content={item.commonParams.content}
|
|
41
|
+
{...parameters}
|
|
42
|
+
/>
|
|
43
|
+
)}
|
|
44
44
|
</div>
|
|
45
|
-
<JSXStyle id={id}>
|
|
45
|
+
<JSXStyle id={item.id}>{`
|
|
46
46
|
.custom-component-${item.id} {
|
|
47
47
|
width: 100%;
|
|
48
48
|
height: 100%;
|
|
49
49
|
}
|
|
50
50
|
${getLayoutStyles(layouts, layoutValues, ([area, layoutParams]) => {
|
|
51
|
-
|
|
51
|
+
return (`
|
|
52
52
|
.custom-component-${item.id} {
|
|
53
53
|
transform: rotate(${area.angle}deg);
|
|
54
54
|
opacity: ${layoutParams.opacity};
|
|
55
|
-
width: 100%;
|
|
56
|
-
height: 100%;
|
|
57
55
|
}
|
|
58
56
|
`);
|
|
59
|
-
|
|
57
|
+
})}`}
|
|
60
58
|
</JSXStyle>
|
|
61
59
|
</>
|
|
62
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
|
|