@dynamic-labs/sdk-react-core 3.8.3 → 3.8.5
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 +14 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/hooks/useResetCookieLocalStorage/useResetCookieLocalStorage.cjs +3 -5
- package/src/lib/utils/hooks/useResetCookieLocalStorage/useResetCookieLocalStorage.js +4 -6
- package/src/lib/widgets/DynamicBridgeWidget/DynamicBridgeWidget.cjs +5 -1
- package/src/lib/widgets/DynamicBridgeWidget/DynamicBridgeWidget.js +5 -1
|
@@ -27,7 +27,7 @@ var isCookieEnabled = require('../../functions/isCookieEnabled/isCookieEnabled.c
|
|
|
27
27
|
var useDynamicEvents = require('../events/useDynamicEvents/useDynamicEvents.cjs');
|
|
28
28
|
|
|
29
29
|
const useResetCookieLocalStorage = ({ environmentId, projectSettings, setPrimaryWalletId, }) => {
|
|
30
|
-
const
|
|
30
|
+
const [isLoading, setIsLoading] = React.useState(true);
|
|
31
31
|
const didRefreshUserRef = React.useRef(false);
|
|
32
32
|
const user$2 = user.getUser();
|
|
33
33
|
/**
|
|
@@ -77,7 +77,7 @@ const useResetCookieLocalStorage = ({ environmentId, projectSettings, setPrimary
|
|
|
77
77
|
if (projectSettings) {
|
|
78
78
|
// only set to false if projectSettings are available,
|
|
79
79
|
// otherwise isCookieEnabled might be a false negative
|
|
80
|
-
|
|
80
|
+
setIsLoading(false);
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
// Ensure this effect only runs once
|
|
@@ -85,9 +85,7 @@ const useResetCookieLocalStorage = ({ environmentId, projectSettings, setPrimary
|
|
|
85
85
|
return;
|
|
86
86
|
maybeInitUserRefresh();
|
|
87
87
|
}, [user$2, projectSettings, environmentId, setPrimaryWalletId]);
|
|
88
|
-
return {
|
|
89
|
-
isLoading: isLoadingRef.current,
|
|
90
|
-
};
|
|
88
|
+
return { isLoading };
|
|
91
89
|
};
|
|
92
90
|
|
|
93
91
|
exports.useResetCookieLocalStorage = useResetCookieLocalStorage;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { useRef, useEffect } from 'react';
|
|
3
|
+
import { useState, useRef, useEffect } from 'react';
|
|
4
4
|
import { JwtVerifiedCredentialFormatEnum } from '@dynamic-labs/sdk-api-core';
|
|
5
5
|
import { logger } from '../../../shared/logger.js';
|
|
6
6
|
import '@dynamic-labs/iconic';
|
|
@@ -23,7 +23,7 @@ import { isCookieEnabled } from '../../functions/isCookieEnabled/isCookieEnabled
|
|
|
23
23
|
import { useInternalDynamicEvents } from '../events/useDynamicEvents/useDynamicEvents.js';
|
|
24
24
|
|
|
25
25
|
const useResetCookieLocalStorage = ({ environmentId, projectSettings, setPrimaryWalletId, }) => {
|
|
26
|
-
const
|
|
26
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
27
27
|
const didRefreshUserRef = useRef(false);
|
|
28
28
|
const user = getUser();
|
|
29
29
|
/**
|
|
@@ -73,7 +73,7 @@ const useResetCookieLocalStorage = ({ environmentId, projectSettings, setPrimary
|
|
|
73
73
|
if (projectSettings) {
|
|
74
74
|
// only set to false if projectSettings are available,
|
|
75
75
|
// otherwise isCookieEnabled might be a false negative
|
|
76
|
-
|
|
76
|
+
setIsLoading(false);
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
// Ensure this effect only runs once
|
|
@@ -81,9 +81,7 @@ const useResetCookieLocalStorage = ({ environmentId, projectSettings, setPrimary
|
|
|
81
81
|
return;
|
|
82
82
|
maybeInitUserRefresh();
|
|
83
83
|
}, [user, projectSettings, environmentId, setPrimaryWalletId]);
|
|
84
|
-
return {
|
|
85
|
-
isLoading: isLoadingRef.current,
|
|
86
|
-
};
|
|
84
|
+
return { isLoading };
|
|
87
85
|
};
|
|
88
86
|
|
|
89
87
|
export { useResetCookieLocalStorage };
|
|
@@ -59,6 +59,7 @@ require('../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
|
59
59
|
require('../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
60
60
|
require('../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
61
61
|
require('../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
62
|
+
var Skeleton = require('../../components/Skeleton/Skeleton.cjs');
|
|
62
63
|
require('../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
63
64
|
require('../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
64
65
|
require('../DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
@@ -89,7 +90,7 @@ var DynamicBridgeUserProfile = require('./components/DynamicBridgeUserProfile/Dy
|
|
|
89
90
|
var DynamicBridgeWidgetContext = require('./context/DynamicBridgeWidgetContext/DynamicBridgeWidgetContext.cjs');
|
|
90
91
|
|
|
91
92
|
const DynamicBridgeWidget = ({ className, variant = 'modal', iconVariant = 'chain', }) => {
|
|
92
|
-
const { showAuthFlow, setShowBridgeWidget, bridgeChains, setShowAuthFlow, connectedWallets, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
93
|
+
const { showAuthFlow, setShowBridgeWidget, bridgeChains, setShowAuthFlow, connectedWallets, sdkHasLoaded, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
93
94
|
const { widgetRef, inlineControlsRef } = DynamicBridgeWidgetContext.useDynamicBridgeWidgetContext();
|
|
94
95
|
const { t } = reactI18next.useTranslation();
|
|
95
96
|
const closeOnOutsideClick = React.useCallback((e) => {
|
|
@@ -104,6 +105,9 @@ const DynamicBridgeWidget = ({ className, variant = 'modal', iconVariant = 'chai
|
|
|
104
105
|
index.useOnClickOutside(widgetRef, closeOnOutsideClick);
|
|
105
106
|
return (jsxRuntime.jsxs(ShadowDOM.ShadowDOM, { id: 'dynamic-bridge-widget', className: 'dynamic-widget__container', children: [jsxRuntime.jsx(InlineWidget.InlineWidget, { ref: inlineControlsRef, className: className, dataTestId: 'BridgeWidgetNav', children: bridgeChains === null || bridgeChains === void 0 ? void 0 : bridgeChains.map(({ chain }) => {
|
|
106
107
|
const ChainIcon = getChainIcon.getChainIcon(chain);
|
|
108
|
+
if (!sdkHasLoaded) {
|
|
109
|
+
return (jsxRuntime.jsx(InlineWidgetButton.InlineWidgetButton, { icon: jsxRuntime.jsx(ChainIcon, {}), className: 'dynamic-bridge-widget__skeleton-button', children: jsxRuntime.jsx(Skeleton.Skeleton, { className: 'dynamic-bridge-widget__skeleton' }) }, `skeleton-${chain}`));
|
|
110
|
+
}
|
|
107
111
|
const connectedChainWallets = connectedWallets.filter(({ chain: connectedChain }) => connectedChain === chain);
|
|
108
112
|
if (connectedChainWallets.length > 0) {
|
|
109
113
|
return connectedChainWallets.map((wallet) => (jsxRuntime.jsx(InlineWidgetButton.InlineWidgetButton, { icon: iconVariant === 'wallet' ? (jsxRuntime.jsx(walletBook.WalletIcon, { walletKey: wallet.connector.key })) : (jsxRuntime.jsx(ChainIcon, {})), onClick: () => setShowBridgeWidget(true), children: shortenWalletAddress.shortenWalletAddress(wallet.address) }, wallet.id)));
|
|
@@ -55,6 +55,7 @@ import '../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
|
55
55
|
import '../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
56
56
|
import '../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
57
57
|
import '../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.js';
|
|
58
|
+
import { Skeleton } from '../../components/Skeleton/Skeleton.js';
|
|
58
59
|
import '../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
59
60
|
import '../../context/WalletGroupContext/WalletGroupContext.js';
|
|
60
61
|
import '../DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
@@ -85,7 +86,7 @@ import { DynamicBridgeUserProfile } from './components/DynamicBridgeUserProfile/
|
|
|
85
86
|
import { useDynamicBridgeWidgetContext } from './context/DynamicBridgeWidgetContext/DynamicBridgeWidgetContext.js';
|
|
86
87
|
|
|
87
88
|
const DynamicBridgeWidget = ({ className, variant = 'modal', iconVariant = 'chain', }) => {
|
|
88
|
-
const { showAuthFlow, setShowBridgeWidget, bridgeChains, setShowAuthFlow, connectedWallets, } = useInternalDynamicContext();
|
|
89
|
+
const { showAuthFlow, setShowBridgeWidget, bridgeChains, setShowAuthFlow, connectedWallets, sdkHasLoaded, } = useInternalDynamicContext();
|
|
89
90
|
const { widgetRef, inlineControlsRef } = useDynamicBridgeWidgetContext();
|
|
90
91
|
const { t } = useTranslation();
|
|
91
92
|
const closeOnOutsideClick = useCallback((e) => {
|
|
@@ -100,6 +101,9 @@ const DynamicBridgeWidget = ({ className, variant = 'modal', iconVariant = 'chai
|
|
|
100
101
|
useOnClickOutside(widgetRef, closeOnOutsideClick);
|
|
101
102
|
return (jsxs(ShadowDOM, { id: 'dynamic-bridge-widget', className: 'dynamic-widget__container', children: [jsx(InlineWidget, { ref: inlineControlsRef, className: className, dataTestId: 'BridgeWidgetNav', children: bridgeChains === null || bridgeChains === void 0 ? void 0 : bridgeChains.map(({ chain }) => {
|
|
102
103
|
const ChainIcon = getChainIcon(chain);
|
|
104
|
+
if (!sdkHasLoaded) {
|
|
105
|
+
return (jsx(InlineWidgetButton, { icon: jsx(ChainIcon, {}), className: 'dynamic-bridge-widget__skeleton-button', children: jsx(Skeleton, { className: 'dynamic-bridge-widget__skeleton' }) }, `skeleton-${chain}`));
|
|
106
|
+
}
|
|
103
107
|
const connectedChainWallets = connectedWallets.filter(({ chain: connectedChain }) => connectedChain === chain);
|
|
104
108
|
if (connectedChainWallets.length > 0) {
|
|
105
109
|
return connectedChainWallets.map((wallet) => (jsx(InlineWidgetButton, { icon: iconVariant === 'wallet' ? (jsx(WalletIcon, { walletKey: wallet.connector.key })) : (jsx(ChainIcon, {})), onClick: () => setShowBridgeWidget(true), children: shortenWalletAddress(wallet.address) }, wallet.id)));
|