@cntrl-site/sdk-nextjs 1.9.32 → 1.9.33
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.
- package/lib/components/items/ComponentItem/ComponentItem.js +1 -1
- package/lib/interactions/InteractionsRegistry.js +2 -29
- package/lib/provider/InteractionsContext.js +4 -3
- package/package.json +2 -2
- package/src/components/items/ComponentItem/ComponentItem.tsx +1 -0
- package/src/interactions/InteractionsRegistry.ts +2 -21
- package/src/provider/InteractionsContext.tsx +6 -5
|
@@ -33,7 +33,7 @@ const ComponentItem = ({ item, sectionId, onResize, interactionCtrl }) => {
|
|
|
33
33
|
const blur = (0, getStyleFromItemStateAndParams_1.getStyleFromItemStateAndParams)((_c = stateParams === null || stateParams === void 0 ? void 0 : stateParams.styles) === null || _c === void 0 ? void 0 : _c.blur, itemBlur);
|
|
34
34
|
const Element = component ? component.element : undefined;
|
|
35
35
|
const parameters = layout ? item.layoutParams[layout].parameters : undefined;
|
|
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(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_d = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _d !== void 0 ? _d : 'none' }), children: parameters && Element && ((0, jsx_runtime_1.jsx)(Element, Object.assign({ portalId: "component-portal", content: item.commonParams.content }, parameters))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: item.id, children: `
|
|
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(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_d = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _d !== void 0 ? _d : 'none' }), children: parameters && Element && ((0, jsx_runtime_1.jsx)(Element, Object.assign({ metadata: { itemId: item.id }, portalId: "component-portal", content: item.commonParams.content }, parameters))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: item.id, children: `
|
|
37
37
|
.custom-component-${item.id} {
|
|
38
38
|
width: 100%;
|
|
39
39
|
height: 100%;
|
|
@@ -400,35 +400,8 @@ class InteractionsRegistry {
|
|
|
400
400
|
});
|
|
401
401
|
(_a = this.ctrls.get(itemId)) === null || _a === void 0 ? void 0 : _a.receiveChange();
|
|
402
402
|
}
|
|
403
|
-
notifyPageOverlay() {
|
|
404
|
-
|
|
405
|
-
const currentStateId = this.getCurrentStateByInteractionId(interaction.id);
|
|
406
|
-
const startStateId = interaction.startStateId;
|
|
407
|
-
if (currentStateId === startStateId)
|
|
408
|
-
continue;
|
|
409
|
-
const hasScrollTriggers = interaction.triggers.find((trigger) => trigger.type === 'item-scroll-position' || trigger.type === 'scroll-position');
|
|
410
|
-
if (hasScrollTriggers)
|
|
411
|
-
continue;
|
|
412
|
-
const hoverOutTriggers = interaction.triggers.filter((trigger) => {
|
|
413
|
-
if (!('triggerEvent' in trigger))
|
|
414
|
-
return false;
|
|
415
|
-
if (trigger.triggerEvent !== 'hover-out')
|
|
416
|
-
return false;
|
|
417
|
-
if (trigger.from !== currentStateId)
|
|
418
|
-
return false;
|
|
419
|
-
if (trigger.to !== startStateId)
|
|
420
|
-
return false;
|
|
421
|
-
return true;
|
|
422
|
-
});
|
|
423
|
-
for (const trigger of hoverOutTriggers) {
|
|
424
|
-
if (!('itemId' in trigger))
|
|
425
|
-
continue;
|
|
426
|
-
const itemId = trigger.itemId;
|
|
427
|
-
if (this.isItemScrollBasedTrigger(itemId))
|
|
428
|
-
continue;
|
|
429
|
-
this.notifyItemTrigger(itemId, 'hover-out');
|
|
430
|
-
}
|
|
431
|
-
}
|
|
403
|
+
notifyPageOverlay(itemId) {
|
|
404
|
+
this.notifyItemTrigger(itemId, 'hover-out');
|
|
432
405
|
}
|
|
433
406
|
getCurrentStateByInteractionId(id) {
|
|
434
407
|
let state;
|
|
@@ -36,10 +36,11 @@ const InteractionsProvider = ({ article, children }) => {
|
|
|
36
36
|
});
|
|
37
37
|
}, [registry]);
|
|
38
38
|
(0, react_1.useEffect)(() => {
|
|
39
|
-
const handlePageOverlay = () => {
|
|
40
|
-
|
|
39
|
+
const handlePageOverlay = (e) => {
|
|
40
|
+
const itemId = e.detail.itemId;
|
|
41
|
+
if (!registry || !itemId)
|
|
41
42
|
return;
|
|
42
|
-
registry.notifyPageOverlay();
|
|
43
|
+
registry.notifyPageOverlay(itemId);
|
|
43
44
|
};
|
|
44
45
|
window.addEventListener('page-overlay', handlePageOverlay);
|
|
45
46
|
return () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cntrl-site/sdk-nextjs",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.33",
|
|
4
4
|
"description": "SDK for Next.js",
|
|
5
5
|
"author": "arsen@momdesign.nyc",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@antfu/eslint-config": "^3.8.0",
|
|
32
32
|
"@cntrl-site/color": "^1.0.0",
|
|
33
|
-
"@cntrl-site/components": "^0.1.
|
|
33
|
+
"@cntrl-site/components": "^0.1.21",
|
|
34
34
|
"@cntrl-site/effects": "^1.4.0",
|
|
35
35
|
"@cntrl-site/sdk": "^1.25.6",
|
|
36
36
|
"@types/vimeo__player": "^2.18.0",
|
|
@@ -402,27 +402,8 @@ export class InteractionsRegistry implements InteractionsRegistryPort {
|
|
|
402
402
|
this.ctrls.get(itemId)?.receiveChange();
|
|
403
403
|
}
|
|
404
404
|
|
|
405
|
-
notifyPageOverlay(): void {
|
|
406
|
-
|
|
407
|
-
const currentStateId = this.getCurrentStateByInteractionId(interaction.id);
|
|
408
|
-
const startStateId = interaction.startStateId;
|
|
409
|
-
if (currentStateId === startStateId) continue;
|
|
410
|
-
const hasScrollTriggers = interaction.triggers.find((trigger) => trigger.type === 'item-scroll-position' || trigger.type === 'scroll-position');
|
|
411
|
-
if (hasScrollTriggers) continue;
|
|
412
|
-
const hoverOutTriggers = interaction.triggers.filter((trigger) => {
|
|
413
|
-
if (!('triggerEvent' in trigger)) return false;
|
|
414
|
-
if (trigger.triggerEvent !== 'hover-out') return false;
|
|
415
|
-
if (trigger.from !== currentStateId) return false;
|
|
416
|
-
if (trigger.to !== startStateId) return false;
|
|
417
|
-
return true;
|
|
418
|
-
});
|
|
419
|
-
for (const trigger of hoverOutTriggers) {
|
|
420
|
-
if (!('itemId' in trigger)) continue;
|
|
421
|
-
const itemId = trigger.itemId;
|
|
422
|
-
if (this.isItemScrollBasedTrigger(itemId)) continue;
|
|
423
|
-
this.notifyItemTrigger(itemId, 'hover-out');
|
|
424
|
-
}
|
|
425
|
-
}
|
|
405
|
+
notifyPageOverlay(itemId: string): void {
|
|
406
|
+
this.notifyItemTrigger(itemId, 'hover-out');
|
|
426
407
|
}
|
|
427
408
|
|
|
428
409
|
private getCurrentStateByInteractionId(id: InteractionId): string {
|
|
@@ -39,13 +39,14 @@ export const InteractionsProvider: FC<PropsWithChildren<Props>> = ({ article, ch
|
|
|
39
39
|
}, [registry]);
|
|
40
40
|
|
|
41
41
|
useEffect(() => {
|
|
42
|
-
const handlePageOverlay = () => {
|
|
43
|
-
|
|
44
|
-
registry
|
|
42
|
+
const handlePageOverlay = (e: CustomEvent) => {
|
|
43
|
+
const itemId = e.detail.itemId;
|
|
44
|
+
if (!registry || !itemId) return;
|
|
45
|
+
registry.notifyPageOverlay(itemId);
|
|
45
46
|
};
|
|
46
|
-
window.addEventListener('page-overlay', handlePageOverlay);
|
|
47
|
+
window.addEventListener('page-overlay', handlePageOverlay as EventListener);
|
|
47
48
|
return () => {
|
|
48
|
-
window.removeEventListener('page-overlay', handlePageOverlay);
|
|
49
|
+
window.removeEventListener('page-overlay', handlePageOverlay as EventListener);
|
|
49
50
|
};
|
|
50
51
|
}, [registry]);
|
|
51
52
|
|