UNPKG

@pushchain/ui-kit

Version:
56 lines (55 loc) 3.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PushUniversalWalletProvider = void 0; const tslib_1 = require("tslib"); const jsx_runtime_1 = require("react/jsx-runtime"); const WalletContext_1 = require("../context/WalletContext"); const constants_1 = require("../constants"); const styled_components_1 = require("styled-components"); const token_1 = require("../styles/token"); const theme_1 = require("../utils/theme"); const loginDefaultConfig = { email: true, google: true, wallet: { enabled: true, }, }; const PushWalletConfigDefault = { uid: 'default', login: loginDefaultConfig, network: constants_1.PushUI.CONSTANTS.PUSH_NETWORK.TESTNET_DONUT, modal: { loginLayout: constants_1.PushUI.CONSTANTS.LOGIN.LAYOUT.SIMPLE, appPreview: false, connectedInteraction: constants_1.PushUI.CONSTANTS.CONNECTED.INTERACTION.BLUR, connectedLayout: constants_1.PushUI.CONSTANTS.CONNECTED.LAYOUT.HOVER, }, }; const PushUniversalWalletProvider = ({ config, app, themeMode = constants_1.PushUI.CONSTANTS.THEME.LIGHT, themeOverrides = {}, children, }) => { var _a; const GlobalStyle = (0, styled_components_1.createGlobalStyle) ` [data-pw-wrapper='${(props) => props.uid}']{ #w3m-modal { z-index: 9999 !important; position: fixed !important; } ${(props) => { var _a; const { themeMode, themeOverrides } = props.theme; const isLightMode = themeMode === constants_1.PushUI.CONSTANTS.THEME.LIGHT; const { dark, light } = themeOverrides, globalOverrides = tslib_1.__rest(themeOverrides, ["dark", "light"]); const newOverrides = Object.assign(Object.assign(Object.assign({}, Object.assign(Object.assign(Object.assign({}, token_1.themeDefault), token_1.buttonThemeDefault), (isLightMode ? token_1.lightThemeDefault : token_1.darkThemeDefault))), (0, theme_1.mapCoreToInt)(globalOverrides)), (0, theme_1.mapCoreToInt)((_a = (isLightMode ? light : dark)) !== null && _a !== void 0 ? _a : {})); return Object.entries(newOverrides) .map(([key, value]) => `${key}: ${value};`) .join('\n'); }} } `; const mergedConfig = Object.assign(Object.assign(Object.assign({}, PushWalletConfigDefault), config), { login: Object.assign(Object.assign(Object.assign({}, loginDefaultConfig), ((config === null || config === void 0 ? void 0 : config.login) || {})), { wallet: Object.assign(Object.assign({}, loginDefaultConfig.wallet), (((_a = config === null || config === void 0 ? void 0 : config.login) === null || _a === void 0 ? void 0 : _a.wallet) || {})) }), modal: Object.assign(Object.assign({}, PushWalletConfigDefault.modal), config.modal) }); return ( // @ts-expect-error (0, jsx_runtime_1.jsxs)(styled_components_1.ThemeProvider, { theme: { themeMode, themeOverrides }, children: [(0, jsx_runtime_1.jsx)(GlobalStyle, { uid: mergedConfig.uid }), (0, jsx_runtime_1.jsx)("div", { "data-pw-wrapper": mergedConfig.uid, children: (0, jsx_runtime_1.jsx)(WalletContext_1.WalletContextProvider, { config: mergedConfig, app: app, themeMode: themeMode, themeOverrides: themeOverrides, children: children }) })] })); }; exports.PushUniversalWalletProvider = PushUniversalWalletProvider; //# sourceMappingURL=PushWalletProvider.js.map