@betterstore/react 0.3.69 → 0.3.71
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 +3 -21
- package/dist/index.mjs +3 -21
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -6,6 +6,7 @@ var LanguageDetector = require('i18next-browser-languagedetector');
|
|
|
6
6
|
var reactI18next = require('react-i18next');
|
|
7
7
|
var sdk = require('@betterstore/sdk');
|
|
8
8
|
var React = require('react');
|
|
9
|
+
var react = require('motion/dist/react');
|
|
9
10
|
var ReactDOM = require('react-dom');
|
|
10
11
|
var sonner = require('sonner');
|
|
11
12
|
var zod = require('zod');
|
|
@@ -534,25 +535,6 @@ const IframeWrapper = React.memo(({ children, iframeRef, wrapperRef }) => {
|
|
|
534
535
|
doc.head.appendChild(styleEl);
|
|
535
536
|
styleRef.current = styleEl;
|
|
536
537
|
}, []);
|
|
537
|
-
const cloneGlobals = (iframeWin) => {
|
|
538
|
-
const parentWin = window;
|
|
539
|
-
// Grab all own props of the parent window...
|
|
540
|
-
Object.getOwnPropertyNames(parentWin).forEach((key) => {
|
|
541
|
-
// Skip non–configurable or already-present props
|
|
542
|
-
if (key in iframeWin)
|
|
543
|
-
return;
|
|
544
|
-
const desc = Object.getOwnPropertyDescriptor(parentWin, key);
|
|
545
|
-
// Only clone functions or configurable props
|
|
546
|
-
if (typeof desc.value === "function" ||
|
|
547
|
-
(desc.configurable && (desc.writable || desc.get))) {
|
|
548
|
-
Object.defineProperty(iframeWin, key, Object.assign(Object.assign({}, desc), {
|
|
549
|
-
// if it's a function, bind it back to parent window
|
|
550
|
-
value: typeof desc.value === "function"
|
|
551
|
-
? desc.value.bind(parentWin)
|
|
552
|
-
: desc.value }));
|
|
553
|
-
}
|
|
554
|
-
});
|
|
555
|
-
};
|
|
556
538
|
const updateHeight = React.useCallback(() => {
|
|
557
539
|
const iframe = iframeRef.current;
|
|
558
540
|
const doc = iframe === null || iframe === void 0 ? void 0 : iframe.contentDocument;
|
|
@@ -566,7 +548,6 @@ const IframeWrapper = React.memo(({ children, iframeRef, wrapperRef }) => {
|
|
|
566
548
|
if (!iframe)
|
|
567
549
|
return;
|
|
568
550
|
const doc = iframe.contentDocument;
|
|
569
|
-
cloneGlobals(iframe.contentWindow);
|
|
570
551
|
injectStyles(doc);
|
|
571
552
|
setIframeBody(doc.body);
|
|
572
553
|
updateHeight();
|
|
@@ -605,7 +586,8 @@ const IframeWrapper = React.memo(({ children, iframeRef, wrapperRef }) => {
|
|
|
605
586
|
}, [updateHeight]);
|
|
606
587
|
return (React.createElement("div", { ref: wrapperRef, className: "w-full max-w-[1200px] min-h-screen mx-auto overflow-y-auto overflow-x-hidden relative" },
|
|
607
588
|
React.createElement("iframe", { ref: iframeRef, className: "w-full min-h-screen border-0", sandbox: "allow-same-origin allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-top-navigation" }),
|
|
608
|
-
iframeBody &&
|
|
589
|
+
iframeBody &&
|
|
590
|
+
ReactDOM.createPortal(React.createElement(react.MotionConfig, null, children), iframeBody)));
|
|
609
591
|
});
|
|
610
592
|
IframeWrapper.displayName = "IframeWrapper";
|
|
611
593
|
|
package/dist/index.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { initReactI18next, useTranslation } from 'react-i18next';
|
|
|
5
5
|
import { createStoreHelpers, createStoreClient } from '@betterstore/sdk';
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import React__default, { useState, useRef, useCallback, useLayoutEffect, useEffect, createContext, useId, useContext, useInsertionEffect, useMemo, Children, isValidElement, forwardRef, Fragment as Fragment$1, createElement, Component, memo as memo$1 } from 'react';
|
|
8
|
+
import { MotionConfig } from 'motion/dist/react';
|
|
8
9
|
import ReactDOM from 'react-dom';
|
|
9
10
|
import { Toaster as Toaster$1, toast } from 'sonner';
|
|
10
11
|
import { z as z$1 } from 'zod';
|
|
@@ -511,25 +512,6 @@ const IframeWrapper = React__default.memo(({ children, iframeRef, wrapperRef })
|
|
|
511
512
|
doc.head.appendChild(styleEl);
|
|
512
513
|
styleRef.current = styleEl;
|
|
513
514
|
}, []);
|
|
514
|
-
const cloneGlobals = (iframeWin) => {
|
|
515
|
-
const parentWin = window;
|
|
516
|
-
// Grab all own props of the parent window...
|
|
517
|
-
Object.getOwnPropertyNames(parentWin).forEach((key) => {
|
|
518
|
-
// Skip non–configurable or already-present props
|
|
519
|
-
if (key in iframeWin)
|
|
520
|
-
return;
|
|
521
|
-
const desc = Object.getOwnPropertyDescriptor(parentWin, key);
|
|
522
|
-
// Only clone functions or configurable props
|
|
523
|
-
if (typeof desc.value === "function" ||
|
|
524
|
-
(desc.configurable && (desc.writable || desc.get))) {
|
|
525
|
-
Object.defineProperty(iframeWin, key, Object.assign(Object.assign({}, desc), {
|
|
526
|
-
// if it's a function, bind it back to parent window
|
|
527
|
-
value: typeof desc.value === "function"
|
|
528
|
-
? desc.value.bind(parentWin)
|
|
529
|
-
: desc.value }));
|
|
530
|
-
}
|
|
531
|
-
});
|
|
532
|
-
};
|
|
533
515
|
const updateHeight = useCallback(() => {
|
|
534
516
|
const iframe = iframeRef.current;
|
|
535
517
|
const doc = iframe === null || iframe === void 0 ? void 0 : iframe.contentDocument;
|
|
@@ -543,7 +525,6 @@ const IframeWrapper = React__default.memo(({ children, iframeRef, wrapperRef })
|
|
|
543
525
|
if (!iframe)
|
|
544
526
|
return;
|
|
545
527
|
const doc = iframe.contentDocument;
|
|
546
|
-
cloneGlobals(iframe.contentWindow);
|
|
547
528
|
injectStyles(doc);
|
|
548
529
|
setIframeBody(doc.body);
|
|
549
530
|
updateHeight();
|
|
@@ -582,7 +563,8 @@ const IframeWrapper = React__default.memo(({ children, iframeRef, wrapperRef })
|
|
|
582
563
|
}, [updateHeight]);
|
|
583
564
|
return (React__default.createElement("div", { ref: wrapperRef, className: "w-full max-w-[1200px] min-h-screen mx-auto overflow-y-auto overflow-x-hidden relative" },
|
|
584
565
|
React__default.createElement("iframe", { ref: iframeRef, className: "w-full min-h-screen border-0", sandbox: "allow-same-origin allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-top-navigation" }),
|
|
585
|
-
iframeBody &&
|
|
566
|
+
iframeBody &&
|
|
567
|
+
ReactDOM.createPortal(React__default.createElement(MotionConfig, null, children), iframeBody)));
|
|
586
568
|
});
|
|
587
569
|
IframeWrapper.displayName = "IframeWrapper";
|
|
588
570
|
|