@betterstore/react 0.3.60 → 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 +12 -0
- package/dist/index.cjs.js +8 -1
- package/dist/index.mjs +8 -1
- 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,14 +543,18 @@ const IframeWrapper = ({ children, iframeRef, wrapperRef, }) => {
|
|
|
540
543
|
iframeDoc.head.appendChild(style);
|
|
541
544
|
styleRef.current = style;
|
|
542
545
|
setIframeBody(iframeDoc.body);
|
|
546
|
+
updateHeight();
|
|
543
547
|
};
|
|
544
548
|
// For first load
|
|
545
549
|
if (iframeDoc.readyState === "complete")
|
|
546
550
|
onLoad();
|
|
547
551
|
else
|
|
548
552
|
iframe.addEventListener("load", onLoad);
|
|
553
|
+
// Add resize listener
|
|
554
|
+
window.addEventListener("resize", updateHeight);
|
|
549
555
|
return () => {
|
|
550
556
|
iframe.removeEventListener("load", onLoad);
|
|
557
|
+
window.removeEventListener("resize", updateHeight);
|
|
551
558
|
// Cleanup style on unmount
|
|
552
559
|
if (styleRef.current && styleRef.current.parentNode) {
|
|
553
560
|
styleRef.current.parentNode.removeChild(styleRef.current);
|
|
@@ -564,10 +571,10 @@ const IframeWrapper = ({ children, iframeRef, wrapperRef, }) => {
|
|
|
564
571
|
overflowX: "hidden",
|
|
565
572
|
marginInline: "auto",
|
|
566
573
|
scrollbarWidth: "none",
|
|
574
|
+
overflowY: "auto",
|
|
567
575
|
}, ref: wrapperRef },
|
|
568
576
|
React.createElement("iframe", { ref: iframeRef, style: {
|
|
569
577
|
width: "100%",
|
|
570
|
-
height: "100%",
|
|
571
578
|
border: "none",
|
|
572
579
|
minHeight: "100vh",
|
|
573
580
|
}, sandbox: "allow-same-origin allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-top-navigation" }),
|
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,14 +520,18 @@ const IframeWrapper = ({ children, iframeRef, wrapperRef, }) => {
|
|
|
517
520
|
iframeDoc.head.appendChild(style);
|
|
518
521
|
styleRef.current = style;
|
|
519
522
|
setIframeBody(iframeDoc.body);
|
|
523
|
+
updateHeight();
|
|
520
524
|
};
|
|
521
525
|
// For first load
|
|
522
526
|
if (iframeDoc.readyState === "complete")
|
|
523
527
|
onLoad();
|
|
524
528
|
else
|
|
525
529
|
iframe.addEventListener("load", onLoad);
|
|
530
|
+
// Add resize listener
|
|
531
|
+
window.addEventListener("resize", updateHeight);
|
|
526
532
|
return () => {
|
|
527
533
|
iframe.removeEventListener("load", onLoad);
|
|
534
|
+
window.removeEventListener("resize", updateHeight);
|
|
528
535
|
// Cleanup style on unmount
|
|
529
536
|
if (styleRef.current && styleRef.current.parentNode) {
|
|
530
537
|
styleRef.current.parentNode.removeChild(styleRef.current);
|
|
@@ -541,10 +548,10 @@ const IframeWrapper = ({ children, iframeRef, wrapperRef, }) => {
|
|
|
541
548
|
overflowX: "hidden",
|
|
542
549
|
marginInline: "auto",
|
|
543
550
|
scrollbarWidth: "none",
|
|
551
|
+
overflowY: "auto",
|
|
544
552
|
}, ref: wrapperRef },
|
|
545
553
|
React__default.createElement("iframe", { ref: iframeRef, style: {
|
|
546
554
|
width: "100%",
|
|
547
|
-
height: "100%",
|
|
548
555
|
border: "none",
|
|
549
556
|
minHeight: "100vh",
|
|
550
557
|
}, sandbox: "allow-same-origin allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-top-navigation" }),
|