@sky-mavis/tanto-widget
Version:
Tanto Widget
47 lines • 1.68 kB
JavaScript
import {jsx}from'@emotion/react/jsx-runtime';import {MotionConfig,LazyMotion,domAnimation}from'motion/react';import {useMemo}from'react';import {useConnectCallback}from'../../hooks/useConnectCallback.mjs';import {AuthProvider}from'../auth/AuthProvider.mjs';import {ThemeProvider}from'../theme/ThemeProvider.mjs';import {WidgetModalProvider}from'../widget-modal/WidgetModalProvider.mjs';import {TantoContext}from'./TantoContext.mjs';import {useConnectionAnalytics}from'./useConnectionAnalytics.mjs';import {useDeeplinkHandler}from'./useDeeplinkHandler.mjs';import {useTantoSetup}from'./useTantoSetup.mjs';function TantoProvider({
config: customConfig = {},
theme,
children,
onConnect,
onDisconnect
}) {
const config = useTantoSetup(customConfig);
const contextValue = useMemo(() => ({
config
}), [config]);
return jsx(TantoContext.Provider, {
value: contextValue,
children: jsx(ThemeProvider, {
theme: theme,
children: jsx(MotionConfig, {
reducedMotion: config.reducedMotion ? 'always' : 'never',
children: jsx(LazyMotion, {
features: domAnimation,
strict: true,
children: jsx(AuthProvider, {
children: jsx(ConnectionHandler, {
onConnect: onConnect,
onDisconnect: onDisconnect,
children: children
})
})
})
})
})
});
}
function ConnectionHandler({
children,
onConnect,
onDisconnect
}) {
useDeeplinkHandler();
useConnectionAnalytics();
useConnectCallback({
onConnect,
onDisconnect
});
return jsx(WidgetModalProvider, {
children: children
});
}export{TantoProvider};