@betterstore/react 0.3.61 → 0.3.62
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/CHANGELOG.md +6 -0
- package/dist/index.cjs.js +8 -12
- package/dist/index.mjs +8 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -529,6 +529,9 @@ const IframeWrapper = ({ children, iframeRef, wrapperRef, }) => {
|
|
|
529
529
|
const iframeDoc = iframe.contentDocument || ((_a = iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.document);
|
|
530
530
|
if (!iframeDoc)
|
|
531
531
|
return;
|
|
532
|
+
const updateHeight = () => {
|
|
533
|
+
iframe.style.height = `${iframeDoc.body.scrollHeight}px`;
|
|
534
|
+
};
|
|
532
535
|
const onLoad = () => {
|
|
533
536
|
// Remove previous style if it exists
|
|
534
537
|
if (styleRef.current && styleRef.current.parentNode) {
|
|
@@ -540,25 +543,18 @@ const IframeWrapper = ({ children, iframeRef, wrapperRef, }) => {
|
|
|
540
543
|
iframeDoc.head.appendChild(style);
|
|
541
544
|
styleRef.current = style;
|
|
542
545
|
setIframeBody(iframeDoc.body);
|
|
543
|
-
|
|
544
|
-
const resizeObserver = new ResizeObserver((entries) => {
|
|
545
|
-
for (const entry of entries) {
|
|
546
|
-
const height = entry.contentRect.height;
|
|
547
|
-
iframe.style.height = `${height}px`;
|
|
548
|
-
}
|
|
549
|
-
});
|
|
550
|
-
resizeObserver.observe(iframeDoc.body);
|
|
551
|
-
return () => {
|
|
552
|
-
resizeObserver.disconnect();
|
|
553
|
-
};
|
|
546
|
+
updateHeight();
|
|
554
547
|
};
|
|
555
548
|
// For first load
|
|
556
549
|
if (iframeDoc.readyState === "complete")
|
|
557
550
|
onLoad();
|
|
558
551
|
else
|
|
559
552
|
iframe.addEventListener("load", onLoad);
|
|
553
|
+
// Add resize listener
|
|
554
|
+
window.addEventListener("resize", updateHeight);
|
|
560
555
|
return () => {
|
|
561
556
|
iframe.removeEventListener("load", onLoad);
|
|
557
|
+
window.removeEventListener("resize", updateHeight);
|
|
562
558
|
// Cleanup style on unmount
|
|
563
559
|
if (styleRef.current && styleRef.current.parentNode) {
|
|
564
560
|
styleRef.current.parentNode.removeChild(styleRef.current);
|
|
@@ -580,7 +576,7 @@ const IframeWrapper = ({ children, iframeRef, wrapperRef, }) => {
|
|
|
580
576
|
React.createElement("iframe", { ref: iframeRef, style: {
|
|
581
577
|
width: "100%",
|
|
582
578
|
border: "none",
|
|
583
|
-
minHeight: "
|
|
579
|
+
minHeight: "100vh",
|
|
584
580
|
}, sandbox: "allow-same-origin allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-top-navigation" }),
|
|
585
581
|
iframeBody && ReactDOM.createPortal(children, iframeBody)));
|
|
586
582
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -506,6 +506,9 @@ const IframeWrapper = ({ children, iframeRef, wrapperRef, }) => {
|
|
|
506
506
|
const iframeDoc = iframe.contentDocument || ((_a = iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.document);
|
|
507
507
|
if (!iframeDoc)
|
|
508
508
|
return;
|
|
509
|
+
const updateHeight = () => {
|
|
510
|
+
iframe.style.height = `${iframeDoc.body.scrollHeight}px`;
|
|
511
|
+
};
|
|
509
512
|
const onLoad = () => {
|
|
510
513
|
// Remove previous style if it exists
|
|
511
514
|
if (styleRef.current && styleRef.current.parentNode) {
|
|
@@ -517,25 +520,18 @@ const IframeWrapper = ({ children, iframeRef, wrapperRef, }) => {
|
|
|
517
520
|
iframeDoc.head.appendChild(style);
|
|
518
521
|
styleRef.current = style;
|
|
519
522
|
setIframeBody(iframeDoc.body);
|
|
520
|
-
|
|
521
|
-
const resizeObserver = new ResizeObserver((entries) => {
|
|
522
|
-
for (const entry of entries) {
|
|
523
|
-
const height = entry.contentRect.height;
|
|
524
|
-
iframe.style.height = `${height}px`;
|
|
525
|
-
}
|
|
526
|
-
});
|
|
527
|
-
resizeObserver.observe(iframeDoc.body);
|
|
528
|
-
return () => {
|
|
529
|
-
resizeObserver.disconnect();
|
|
530
|
-
};
|
|
523
|
+
updateHeight();
|
|
531
524
|
};
|
|
532
525
|
// For first load
|
|
533
526
|
if (iframeDoc.readyState === "complete")
|
|
534
527
|
onLoad();
|
|
535
528
|
else
|
|
536
529
|
iframe.addEventListener("load", onLoad);
|
|
530
|
+
// Add resize listener
|
|
531
|
+
window.addEventListener("resize", updateHeight);
|
|
537
532
|
return () => {
|
|
538
533
|
iframe.removeEventListener("load", onLoad);
|
|
534
|
+
window.removeEventListener("resize", updateHeight);
|
|
539
535
|
// Cleanup style on unmount
|
|
540
536
|
if (styleRef.current && styleRef.current.parentNode) {
|
|
541
537
|
styleRef.current.parentNode.removeChild(styleRef.current);
|
|
@@ -557,7 +553,7 @@ const IframeWrapper = ({ children, iframeRef, wrapperRef, }) => {
|
|
|
557
553
|
React__default.createElement("iframe", { ref: iframeRef, style: {
|
|
558
554
|
width: "100%",
|
|
559
555
|
border: "none",
|
|
560
|
-
minHeight: "
|
|
556
|
+
minHeight: "100vh",
|
|
561
557
|
}, sandbox: "allow-same-origin allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-top-navigation" }),
|
|
562
558
|
iframeBody && ReactDOM.createPortal(children, iframeBody)));
|
|
563
559
|
};
|