@parafin/react 6.2.2 → 6.2.3
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/out/index.js +20 -6
- package/package.json +1 -1
package/out/index.js
CHANGED
|
@@ -37,9 +37,11 @@ const openParafinDashboard = (props) => {
|
|
|
37
37
|
}
|
|
38
38
|
const frame = document.createElement('iframe');
|
|
39
39
|
frame.id = 'parafin-dashboard';
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
if (!props.dashboardTargetElementId) {
|
|
41
|
+
frame.style.position = 'fixed';
|
|
42
|
+
frame.style.top = '0';
|
|
43
|
+
frame.style.left = '0';
|
|
44
|
+
}
|
|
43
45
|
frame.style.width = '100%';
|
|
44
46
|
frame.style.height = '100%';
|
|
45
47
|
frame.style.border = 'none';
|
|
@@ -49,6 +51,12 @@ const openParafinDashboard = (props) => {
|
|
|
49
51
|
frame.style.transition = 'opacity 0.2s';
|
|
50
52
|
frame.src = url;
|
|
51
53
|
frame.allow = 'accelerometer; gyroscope; clipboard-read; clipboard-write';
|
|
54
|
+
const dashboardTargetElement = props.dashboardTargetElementId
|
|
55
|
+
? document.getElementById(props.dashboardTargetElementId)
|
|
56
|
+
: document.body;
|
|
57
|
+
if (!dashboardTargetElement) {
|
|
58
|
+
throw new Error('Dashboard target element not found');
|
|
59
|
+
}
|
|
52
60
|
const closeParafinDashboard = (e) => {
|
|
53
61
|
if (e.origin === origin && e.data?.message === 'close-dashboard') {
|
|
54
62
|
if ('orderId' in props) {
|
|
@@ -62,12 +70,18 @@ const openParafinDashboard = (props) => {
|
|
|
62
70
|
}
|
|
63
71
|
window.removeEventListener('message', closeParafinDashboard);
|
|
64
72
|
frame.style.opacity = '0';
|
|
65
|
-
setTimeout(() =>
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
dashboardTargetElement.removeChild(frame);
|
|
75
|
+
document.body.style.removeProperty('overflow');
|
|
76
|
+
}, 200);
|
|
66
77
|
}
|
|
67
78
|
};
|
|
68
79
|
window.addEventListener('message', closeParafinDashboard);
|
|
69
|
-
|
|
70
|
-
setTimeout(() =>
|
|
80
|
+
dashboardTargetElement.appendChild(frame);
|
|
81
|
+
setTimeout(() => {
|
|
82
|
+
frame.style.opacity = '1';
|
|
83
|
+
document.body.style.overflow = 'hidden';
|
|
84
|
+
}, 1);
|
|
71
85
|
}
|
|
72
86
|
catch (error) {
|
|
73
87
|
console.error('Error loading Parafin dashboard', error);
|