@betterstore/react 0.3.66 → 0.3.67
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 +7 -4
- package/dist/index.mjs +7 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -528,10 +528,16 @@ const IframeWrapper = React.memo(({ children, iframeRef, wrapperRef }) => {
|
|
|
528
528
|
if ((_a = styleRef.current) === null || _a === void 0 ? void 0 : _a.parentNode) {
|
|
529
529
|
styleRef.current.parentNode.removeChild(styleRef.current);
|
|
530
530
|
}
|
|
531
|
+
// Inject global CSS
|
|
531
532
|
const styleEl = doc.createElement("style");
|
|
532
533
|
styleEl.textContent = css_248z;
|
|
533
534
|
doc.head.appendChild(styleEl);
|
|
534
535
|
styleRef.current = styleEl;
|
|
536
|
+
// Clone Framer Motion styles into iframe
|
|
537
|
+
Array.from(document.querySelectorAll("style[data-motion]")).forEach((styleTag) => {
|
|
538
|
+
const clone = styleTag.cloneNode(true);
|
|
539
|
+
doc.head.appendChild(clone);
|
|
540
|
+
});
|
|
535
541
|
}, []);
|
|
536
542
|
const updateHeight = React.useCallback(() => {
|
|
537
543
|
const iframe = iframeRef.current;
|
|
@@ -549,7 +555,7 @@ const IframeWrapper = React.memo(({ children, iframeRef, wrapperRef }) => {
|
|
|
549
555
|
injectStyles(doc);
|
|
550
556
|
setIframeBody(doc.body);
|
|
551
557
|
updateHeight();
|
|
552
|
-
// Observe body
|
|
558
|
+
// Observe body size changes
|
|
553
559
|
if ("ResizeObserver" in window) {
|
|
554
560
|
resizeObserver.current = new ResizeObserver(updateHeight);
|
|
555
561
|
resizeObserver.current.observe(doc.body);
|
|
@@ -560,9 +566,7 @@ const IframeWrapper = React.memo(({ children, iframeRef, wrapperRef }) => {
|
|
|
560
566
|
const iframe = iframeRef.current;
|
|
561
567
|
if (!iframe)
|
|
562
568
|
return;
|
|
563
|
-
// Attach onLoad
|
|
564
569
|
iframe.addEventListener("load", handleLoad);
|
|
565
|
-
// If already loaded
|
|
566
570
|
if (((_a = iframe.contentDocument) === null || _a === void 0 ? void 0 : _a.readyState) === "complete") {
|
|
567
571
|
handleLoad();
|
|
568
572
|
}
|
|
@@ -575,7 +579,6 @@ const IframeWrapper = React.memo(({ children, iframeRef, wrapperRef }) => {
|
|
|
575
579
|
}
|
|
576
580
|
};
|
|
577
581
|
}, [iframeRef, handleLoad]);
|
|
578
|
-
// Update on window resize
|
|
579
582
|
React.useEffect(() => {
|
|
580
583
|
window.addEventListener("resize", updateHeight);
|
|
581
584
|
return () => {
|
package/dist/index.mjs
CHANGED
|
@@ -505,10 +505,16 @@ const IframeWrapper = React__default.memo(({ children, iframeRef, wrapperRef })
|
|
|
505
505
|
if ((_a = styleRef.current) === null || _a === void 0 ? void 0 : _a.parentNode) {
|
|
506
506
|
styleRef.current.parentNode.removeChild(styleRef.current);
|
|
507
507
|
}
|
|
508
|
+
// Inject global CSS
|
|
508
509
|
const styleEl = doc.createElement("style");
|
|
509
510
|
styleEl.textContent = css_248z;
|
|
510
511
|
doc.head.appendChild(styleEl);
|
|
511
512
|
styleRef.current = styleEl;
|
|
513
|
+
// Clone Framer Motion styles into iframe
|
|
514
|
+
Array.from(document.querySelectorAll("style[data-motion]")).forEach((styleTag) => {
|
|
515
|
+
const clone = styleTag.cloneNode(true);
|
|
516
|
+
doc.head.appendChild(clone);
|
|
517
|
+
});
|
|
512
518
|
}, []);
|
|
513
519
|
const updateHeight = useCallback(() => {
|
|
514
520
|
const iframe = iframeRef.current;
|
|
@@ -526,7 +532,7 @@ const IframeWrapper = React__default.memo(({ children, iframeRef, wrapperRef })
|
|
|
526
532
|
injectStyles(doc);
|
|
527
533
|
setIframeBody(doc.body);
|
|
528
534
|
updateHeight();
|
|
529
|
-
// Observe body
|
|
535
|
+
// Observe body size changes
|
|
530
536
|
if ("ResizeObserver" in window) {
|
|
531
537
|
resizeObserver.current = new ResizeObserver(updateHeight);
|
|
532
538
|
resizeObserver.current.observe(doc.body);
|
|
@@ -537,9 +543,7 @@ const IframeWrapper = React__default.memo(({ children, iframeRef, wrapperRef })
|
|
|
537
543
|
const iframe = iframeRef.current;
|
|
538
544
|
if (!iframe)
|
|
539
545
|
return;
|
|
540
|
-
// Attach onLoad
|
|
541
546
|
iframe.addEventListener("load", handleLoad);
|
|
542
|
-
// If already loaded
|
|
543
547
|
if (((_a = iframe.contentDocument) === null || _a === void 0 ? void 0 : _a.readyState) === "complete") {
|
|
544
548
|
handleLoad();
|
|
545
549
|
}
|
|
@@ -552,7 +556,6 @@ const IframeWrapper = React__default.memo(({ children, iframeRef, wrapperRef })
|
|
|
552
556
|
}
|
|
553
557
|
};
|
|
554
558
|
}, [iframeRef, handleLoad]);
|
|
555
|
-
// Update on window resize
|
|
556
559
|
useEffect(() => {
|
|
557
560
|
window.addEventListener("resize", updateHeight);
|
|
558
561
|
return () => {
|