@rango-dev/widget-embedded 0.1.16-next.1 → 0.1.16-next.11

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.
Files changed (42) hide show
  1. package/dist/QueueManager.d.ts.map +1 -1
  2. package/dist/components/Layout.d.ts.map +1 -1
  3. package/dist/components/TokenInfo.d.ts.map +1 -1
  4. package/dist/hooks/useTheme.d.ts.map +1 -1
  5. package/dist/index.d.ts +9 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  8. package/dist/pages/SettingsPage.d.ts +2 -1
  9. package/dist/pages/SettingsPage.d.ts.map +1 -1
  10. package/dist/types/config.d.ts +11 -1
  11. package/dist/types/config.d.ts.map +1 -1
  12. package/dist/utils/common.d.ts +0 -1
  13. package/dist/utils/common.d.ts.map +1 -1
  14. package/dist/utils/wallets.d.ts.map +1 -1
  15. package/dist/widget-embedded.cjs.development.js +94 -124
  16. package/dist/widget-embedded.cjs.development.js.map +1 -1
  17. package/dist/widget-embedded.cjs.production.min.js +94 -124
  18. package/dist/widget-embedded.cjs.production.min.js.map +1 -1
  19. package/dist/widget-embedded.esm.js +95 -125
  20. package/dist/widget-embedded.esm.js.map +1 -1
  21. package/package.json +10 -13
  22. package/src/QueueManager.tsx +0 -1
  23. package/src/components/AppRoutes.tsx +1 -1
  24. package/src/components/BottomLogo.tsx +1 -1
  25. package/src/components/Layout.tsx +22 -18
  26. package/src/components/RoutesOverview.tsx +2 -2
  27. package/src/components/TokenInfo.tsx +9 -8
  28. package/src/components/TokenPreview.tsx +6 -6
  29. package/src/hooks/useTheme.ts +42 -59
  30. package/src/index.tsx +144 -14
  31. package/src/pages/ConfirmSwapPage.tsx +25 -17
  32. package/src/pages/SettingsPage.tsx +3 -1
  33. package/src/types/config.ts +8 -1
  34. package/src/utils/common.ts +0 -21
  35. package/src/utils/wallets.ts +1 -11
  36. package/dist/App.d.ts +0 -9
  37. package/dist/App.d.ts.map +0 -1
  38. package/dist/lib.d.ts +0 -10
  39. package/dist/lib.d.ts.map +0 -1
  40. package/src/App.tsx +0 -123
  41. package/src/app.css +0 -12
  42. package/src/lib.tsx +0 -144
@@ -9,6 +9,9 @@ import { WalletType } from '@rango-dev/wallets-shared';
9
9
  * @property {string} success
10
10
  * @property {string} error
11
11
  * @property {string} warning
12
+ * @property {string} surface
13
+ * @property {string} neutral
14
+
12
15
  */
13
16
  export type WidgetColors = {
14
17
  background?: string;
@@ -17,6 +20,8 @@ export type WidgetColors = {
17
20
  success?: string;
18
21
  error?: string;
19
22
  warning?: string;
23
+ surface?: string;
24
+ neutral?: string;
20
25
  };
21
26
 
22
27
  /**
@@ -33,14 +38,16 @@ export type WidgetColors = {
33
38
  * specifies the radius of the corners of a widget.
34
39
  * @property {number} width - The `width` property is a number that represents the width of the widget.
35
40
  * @property {number} height - The `height` property is a number that specifies the height of the widget.
41
+ * @property {boolean} singleTheme - The `singleTheme` property is a boolean that specifies the theme is support dark and light or only light.
36
42
  */
37
43
  export type WidgetTheme = {
38
44
  mode?: 'auto' | 'light' | 'dark';
39
45
  fontFamily?: string;
40
- colors?: WidgetColors;
46
+ colors?: { light: WidgetColors; dark: WidgetColors };
41
47
  borderRadius?: number;
42
48
  width?: number;
43
49
  height?: number;
50
+ singleTheme?: boolean;
44
51
  };
45
52
 
46
53
  /**
@@ -10,29 +10,8 @@ export function areEqual(
10
10
  array1.length === array2.length && array1.every((v, i) => v === array2[i])
11
11
  );
12
12
  }
13
- export function shadeColor(color: string, percent: number) {
14
- var R = parseInt(color.substring(1, 3), 16);
15
- var G = parseInt(color.substring(3, 5), 16);
16
- var B = parseInt(color.substring(5, 7), 16);
17
13
 
18
- R = (R * (100 + percent)) / 100;
19
- G = (G * (100 + percent)) / 100;
20
- B = (B * (100 + percent)) / 100;
21
14
 
22
- R = R < 255 ? R : 255;
23
- G = G < 255 ? G : 255;
24
- B = B < 255 ? B : 255;
25
-
26
- R = Math.round(R);
27
- G = Math.round(G);
28
- B = Math.round(B);
29
-
30
- var RR = R.toString(16).length == 1 ? '0' + R.toString(16) : R.toString(16);
31
- var GG = G.toString(16).length == 1 ? '0' + G.toString(16) : G.toString(16);
32
- var BB = B.toString(16).length == 1 ? '0' + B.toString(16) : B.toString(16);
33
-
34
- return '#' + RR + GG + BB;
35
- }
36
15
 
37
16
  export function debounce(fn: Function, time: number) {
38
17
  let timeoutId: ReturnType<typeof setTimeout> | null;
@@ -42,23 +42,13 @@ export function getStateWallet(state: WalletState): WalletStatus {
42
42
  }
43
43
  }
44
44
 
45
- export const excludedWallets = [
46
- WalletType.UNKNOWN,
47
- WalletType.TERRA_STATION,
48
- WalletType.LEAP,
49
- ];
45
+ export const excludedWallets = [WalletType.UNKNOWN, WalletType.LEAP];
50
46
 
51
47
  export function getlistWallet(
52
48
  getState: (type: WalletType) => WalletState,
53
49
  getWalletInfo: (type: WalletType) => WalletInfo,
54
50
  list: WalletType[]
55
51
  ): ModalWalletInfo[] {
56
- const excludedWallets = [
57
- WalletType.UNKNOWN,
58
- WalletType.TERRA_STATION,
59
- WalletType.LEAP,
60
- ];
61
-
62
52
  return list
63
53
  .filter((wallet) => !excludedWallets.includes(wallet))
64
54
  .map((type) => {
package/dist/App.d.ts DELETED
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- import './app.css';
3
- import { WidgetConfig } from './types';
4
- import './i18n';
5
- export declare type WidgetProps = {
6
- config?: WidgetConfig;
7
- };
8
- export declare function App({ config }: WidgetProps): JSX.Element;
9
- //# sourceMappingURL=App.d.ts.map
package/dist/App.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["src/App.tsx"],"names":[],"mappings":";AAIA,OAAO,WAAW,CAAC;AAenB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,QAAQ,CAAC;AAOhB,oBAAY,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,wBAAgB,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,WAAW,eA2F1C"}
package/dist/lib.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- import { WalletType } from '@rango-dev/wallets-shared';
3
- import { WidgetTheme, WidgetConfig, WidgetColors, BlockchainAndTokenConfig } from './types';
4
- import './i18n';
5
- export { WidgetConfig, WalletType, WidgetTheme, WidgetColors, BlockchainAndTokenConfig, };
6
- export declare type WidgetProps = {
7
- config?: WidgetConfig;
8
- };
9
- export declare const Widget: React.FC<WidgetProps>;
10
- //# sourceMappingURL=lib.d.ts.map
package/dist/lib.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["src/lib.tsx"],"names":[],"mappings":"AACA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAM5D,OAAO,EAAW,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAUhE,OAAO,EACL,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB,OAAO,QAAQ,CAAC;AAMhB,OAAO,EACL,YAAY,EACZ,UAAU,EACV,WAAW,EACX,YAAY,EACZ,wBAAwB,GACzB,CAAC;AAEF,oBAAY,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAqGxC,CAAC"}
package/src/App.tsx DELETED
@@ -1,123 +0,0 @@
1
- import { SwapContainer } from '@rango-dev/ui';
2
- import React, { useEffect, useMemo, useState } from 'react';
3
- import { AppRouter } from './components/AppRouter';
4
- import { useMetaStore } from './store/meta';
5
- import './app.css';
6
- import { Events, Provider } from '@rango-dev/wallets-core';
7
- import { allProviders } from '@rango-dev/provider-all';
8
- import { EventHandler } from '@rango-dev/wallets-core/dist/wallet';
9
- import { Network, WalletType } from '@rango-dev/wallets-shared';
10
- import {
11
- prepareAccountsForWalletStore,
12
- walletAndSupportedChainsNames,
13
- } from './utils/wallets';
14
- import { useWalletsStore } from './store/wallets';
15
- import { Layout } from './components/Layout';
16
- import { globalFont } from './globalStyles';
17
- import { useTheme } from './hooks/useTheme';
18
- import QueueManager from './QueueManager';
19
- import { isEvmBlockchain } from 'rango-sdk';
20
- import { WidgetConfig } from './types';
21
- import './i18n';
22
- import { useUiStore } from './store/ui';
23
- import { navigationRoutes } from './constants/navigationRoutes';
24
- import { initConfig } from './utils/configs';
25
-
26
- const providers = allProviders();
27
-
28
- export type WidgetProps = {
29
- config?: WidgetConfig;
30
- };
31
-
32
- export function App({ config }: WidgetProps) {
33
- globalFont(config?.theme?.fontFamily || 'Roboto');
34
- const { activeTheme } = useTheme({ ...config?.theme });
35
- useMemo(() => {
36
- if (config?.apiKey) {
37
- initConfig({
38
- API_KEY: config?.apiKey,
39
- });
40
- }
41
- }, [config]);
42
-
43
- const { blockchains } = useMetaStore.use.meta();
44
- const disconnectWallet = useWalletsStore.use.disconnectWallet();
45
- const connectWallet = useWalletsStore.use.connectWallet();
46
- const currentPage = useUiStore.use.currentPage();
47
-
48
- const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] =
49
- useState<string>('');
50
- const [disconnectedWallet, setDisconnectedWallet] = useState<WalletType>();
51
-
52
- const evmBasedChainNames = blockchains
53
- .filter(isEvmBlockchain)
54
- .map((chain) => chain.name);
55
-
56
- const themeBackground = activeTheme?.colors?.background?.value;
57
-
58
- useEffect(() => {
59
- document.body.style.background = themeBackground;
60
- }, [themeBackground]);
61
-
62
- const onUpdateState: EventHandler = (
63
- type,
64
- event,
65
- value,
66
- state,
67
- supportedChains
68
- ) => {
69
- if (event === Events.ACCOUNTS) {
70
- if (value) {
71
- const supportedChainNames: Network[] | null =
72
- walletAndSupportedChainsNames(supportedChains);
73
- const data = prepareAccountsForWalletStore(
74
- type,
75
- value,
76
- evmBasedChainNames,
77
- supportedChainNames
78
- );
79
- connectWallet(data);
80
- } else {
81
- disconnectWallet(type);
82
- setDisconnectedWallet(type);
83
- }
84
- }
85
-
86
- if (event === Events.ACCOUNTS && state.connected) {
87
- const key = `${type}-${state.network}-${value}`;
88
-
89
- if (state.connected) {
90
- setLastConnectedWalletWithNetwork(key);
91
- }
92
- }
93
-
94
- if (event === Events.NETWORK && state.network) {
95
- const key = `${type}-${state.network}`;
96
- setLastConnectedWalletWithNetwork(key);
97
- }
98
- };
99
-
100
- return (
101
- <Provider
102
- allBlockChains={blockchains}
103
- providers={providers}
104
- onUpdateState={onUpdateState}
105
- >
106
- <div id="pageContainer" className={activeTheme}>
107
- <QueueManager>
108
- <SwapContainer fixedHeight={currentPage !== navigationRoutes.home}>
109
- <AppRouter
110
- lastConnectedWallet={lastConnectedWalletWithNetwork}
111
- disconnectedWallet={disconnectedWallet}
112
- clearDisconnectedWallet={() => {
113
- setDisconnectedWallet(undefined);
114
- }}
115
- >
116
- <Layout config={config} />
117
- </AppRouter>
118
- </SwapContainer>
119
- </QueueManager>
120
- </div>
121
- </Provider>
122
- );
123
- }
package/src/app.css DELETED
@@ -1,12 +0,0 @@
1
- @import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap');
2
-
3
- #app {
4
- height: 100vh;
5
- }
6
- #pageContainer {
7
- display: flex;
8
- align-items: center;
9
- justify-content: center;
10
- height: 100%;
11
- width: 100%;
12
- }
package/src/lib.tsx DELETED
@@ -1,144 +0,0 @@
1
- import { SwapContainer } from '@rango-dev/ui';
2
- import React, { useEffect, useMemo, useState } from 'react';
3
- import { AppRouter } from './components/AppRouter';
4
- import { useMetaStore } from './store/meta';
5
- import { Events, Provider } from '@rango-dev/wallets-core';
6
- import { allProviders } from '@rango-dev/provider-all';
7
- import { EventHandler } from '@rango-dev/wallets-core/dist/wallet';
8
- import { Network, WalletType } from '@rango-dev/wallets-shared';
9
- import {
10
- prepareAccountsForWalletStore,
11
- walletAndSupportedChainsNames,
12
- } from './utils/wallets';
13
- import { useWalletsStore } from './store/wallets';
14
- import { Layout } from './components/Layout';
15
- import { globalFont } from './globalStyles';
16
- import { useTheme } from './hooks/useTheme';
17
- import { isEvmBlockchain } from 'rango-sdk';
18
- import {
19
- WidgetTheme,
20
- WidgetConfig,
21
- WidgetColors,
22
- BlockchainAndTokenConfig,
23
- } from './types';
24
- import useSelectLanguage from './hooks/useSelectLanguage';
25
- import './i18n';
26
- import QueueManager from './QueueManager';
27
- import { useUiStore } from './store/ui';
28
- import { navigationRoutes } from './constants/navigationRoutes';
29
- import { initConfig } from './utils/configs';
30
-
31
- export {
32
- WidgetConfig,
33
- WalletType,
34
- WidgetTheme,
35
- WidgetColors,
36
- BlockchainAndTokenConfig,
37
- };
38
-
39
- export type WidgetProps = {
40
- config?: WidgetConfig;
41
- };
42
-
43
- export const Widget: React.FC<WidgetProps> = ({ config }) => {
44
- globalFont(config?.theme?.fontFamily || 'Roboto');
45
-
46
- const { activeTheme } = useTheme({ ...config?.theme });
47
- const { blockchains } = useMetaStore.use.meta();
48
- const disconnectWallet = useWalletsStore.use.disconnectWallet();
49
- const connectWallet = useWalletsStore.use.connectWallet();
50
- const { changeLanguage } = useSelectLanguage();
51
- const clearConnectedWallet = useWalletsStore.use.clearConnectedWallet();
52
- const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] =
53
- useState<string>('');
54
- const [disconnectedWallet, setDisconnectedWallet] = useState<WalletType>();
55
- const currentPage = useUiStore.use.currentPage();
56
-
57
- const evmBasedChainNames = blockchains
58
- .filter(isEvmBlockchain)
59
- .map((chain) => chain.name);
60
-
61
- useMemo(() => {
62
- if (config?.apiKey) {
63
- initConfig({
64
- API_KEY: config?.apiKey,
65
- });
66
- }
67
- }, [config]);
68
-
69
- const onUpdateState: EventHandler = (
70
- type,
71
- event,
72
- value,
73
- state,
74
- supportedChains
75
- ) => {
76
- if (event === Events.ACCOUNTS) {
77
- if (value) {
78
- const supportedChainNames: Network[] | null =
79
- walletAndSupportedChainsNames(supportedChains);
80
- const data = prepareAccountsForWalletStore(
81
- type,
82
- value,
83
- evmBasedChainNames,
84
- supportedChainNames
85
- );
86
- connectWallet(data);
87
- } else {
88
- disconnectWallet(type);
89
- }
90
- }
91
- if (event === Events.ACCOUNTS && state.connected) {
92
- const key = `${type}-${state.network}-${value}`;
93
-
94
- if (state.connected) {
95
- setLastConnectedWalletWithNetwork(key);
96
- }
97
- }
98
-
99
- if (event === Events.NETWORK && state.network) {
100
- const key = `${type}-${state.network}`;
101
- setLastConnectedWalletWithNetwork(key);
102
- }
103
- };
104
- let providers = allProviders();
105
-
106
- useEffect(() => {
107
- const wallets = config?.wallets;
108
- clearConnectedWallet();
109
- providers = !wallets
110
- ? allProviders()
111
- : allProviders().filter((provider) => {
112
- const type = provider.config.type;
113
- return wallets.find((w) => w === type);
114
- });
115
- }, [config?.wallets]);
116
-
117
- useEffect(() => {
118
- changeLanguage(config?.language || 'en');
119
- }, [config?.language]);
120
-
121
- return (
122
- <Provider
123
- allBlockChains={blockchains}
124
- providers={providers}
125
- onUpdateState={onUpdateState}
126
- >
127
- <div className={activeTheme}>
128
- <QueueManager>
129
- <SwapContainer fixedHeight={currentPage !== navigationRoutes.home}>
130
- <AppRouter
131
- lastConnectedWallet={lastConnectedWalletWithNetwork}
132
- disconnectedWallet={disconnectedWallet}
133
- clearDisconnectedWallet={() => {
134
- setDisconnectedWallet(undefined);
135
- }}
136
- >
137
- <Layout config={config} />
138
- </AppRouter>
139
- </SwapContainer>
140
- </QueueManager>
141
- </div>
142
- </Provider>
143
- );
144
- };