@rango-dev/widget-embedded 0.1.11-next.23 → 0.1.11-next.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.1.11-next.23",
3
+ "version": "0.1.11-next.25",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -32,7 +32,7 @@
32
32
  "@rango-dev/queue-manager-core": "^0.1.11-next.0",
33
33
  "@rango-dev/queue-manager-rango-preset": "^0.1.11-next.7",
34
34
  "@rango-dev/queue-manager-react": "^0.1.10-next.76",
35
- "@rango-dev/ui": "^0.1.11-next.11",
35
+ "@rango-dev/ui": "^0.1.11-next.12",
36
36
  "@rango-dev/wallets-core": "^0.1.11-next.88",
37
37
  "@rango-dev/wallets-shared": "^0.1.11-next.84",
38
38
  "bignumber.js": "^9.1.1",
package/src/App.tsx CHANGED
@@ -106,21 +106,7 @@ export function App({ config }: WidgetProps) {
106
106
  >
107
107
  <div id="pageContainer" className={activeTheme}>
108
108
  <QueueManager>
109
- <SwapContainer
110
- // style={
111
- // currentPage !== navigationRoutes.home && config?.theme?.height
112
- // ? {
113
- // height: config?.theme?.height,
114
- // width: config?.theme?.width || 'auto',
115
- // }
116
- // : config?.theme?.width
117
- // ? {
118
- // width: config?.theme?.width || 'auto',
119
- // }
120
- // : undefined
121
- // }
122
- fixedHeight={currentPage !== navigationRoutes.home}
123
- >
109
+ <SwapContainer fixedHeight={currentPage !== navigationRoutes.home}>
124
110
  <AppRouter
125
111
  lastConnectedWallet={lastConnectedWalletWithNetwork}
126
112
  disconnectedWallet={disconnectedWallet}
@@ -2,7 +2,7 @@ import { createTheme } from '@rango-dev/ui';
2
2
  import { useState, useEffect, useLayoutEffect } from 'react';
3
3
  import { useMetaStore } from '../store/meta';
4
4
  import { useSettingsStore } from '../store/settings';
5
- import { Theme } from '../types';
5
+ import { WidgetTheme } from '../types';
6
6
  import { shadeColor } from '../utils/common';
7
7
  import usePrevious from './usePrevious';
8
8
 
@@ -11,7 +11,7 @@ export function useTheme({
11
11
  fontFamily = 'Robot',
12
12
  borderRadius = 8,
13
13
  mode = 'auto',
14
- }: Theme) {
14
+ }: WidgetTheme) {
15
15
  const theme = useSettingsStore.use.theme();
16
16
  const fetchMeta = useMetaStore.use.fetchMeta();
17
17
  const setTheme = useSettingsStore.use.setTheme();
package/src/index.tsx CHANGED
@@ -11,4 +11,4 @@ root.render(
11
11
  </BrowserRouter>
12
12
  );
13
13
 
14
- export { SwapBox } from './lib';
14
+ export { Widget } from './lib';
package/src/lib.tsx CHANGED
@@ -15,7 +15,7 @@ import { Layout } from './components/Layout';
15
15
  import { globalFont, globalStyles } from './globalStyles';
16
16
  import { useTheme } from './hooks/useTheme';
17
17
  import { isEvmBlockchain } from 'rango-sdk';
18
- import { WidgetConfig } from './types';
18
+ import { WidgetTheme, WidgetConfig, WidgetColors, BlockchainAndTokenConfig } from './types';
19
19
  import useSelectLanguage from './hooks/useSelectLanguage';
20
20
  import './i18n';
21
21
  import QueueManager from './QueueManager';
@@ -23,11 +23,14 @@ import { useUiStore } from './store/ui';
23
23
  import { navigationRoutes } from './constants/navigationRoutes';
24
24
  import { initConfig } from './utils/configs';
25
25
 
26
+
27
+ export {WidgetConfig, WalletType, WidgetTheme, WidgetColors, BlockchainAndTokenConfig}
28
+
26
29
  export type WidgetProps = {
27
30
  config?: WidgetConfig;
28
31
  };
29
32
 
30
- export const SwapBox: React.FC<WidgetProps> = ({ config }) => {
33
+ export const Widget: React.FC<WidgetProps> = ({ config }) => {
31
34
  globalStyles();
32
35
  globalFont(config?.theme?.fontFamily || 'Roboto');
33
36
 
@@ -115,18 +118,7 @@ export const SwapBox: React.FC<WidgetProps> = ({ config }) => {
115
118
  <div id="pageContainer" className={activeTheme}>
116
119
  <QueueManager>
117
120
  <SwapContainer
118
- fixedHeight={currentPage !== navigationRoutes.home}
119
- // style={
120
- // currentPage !== navigationRoutes.home && config?.theme?.height
121
- // ? {
122
- // height: config?.theme?.height,
123
- // width: config?.theme?.width || 'auto',
124
- // }
125
- // : {
126
- // width: config?.theme?.width || 'auto',
127
- // }
128
- // }
129
- >
121
+ fixedHeight={currentPage !== navigationRoutes.home}>
130
122
  <AppRouter
131
123
  lastConnectedWallet={lastConnectedWalletWithNetwork}
132
124
  disconnectedWallet={disconnectedWallet}
@@ -1,43 +1,109 @@
1
1
  import { Asset } from 'rango-sdk';
2
2
  import { WalletType } from '@rango-dev/wallets-shared';
3
3
 
4
- export type Colors = {
4
+ /**
5
+ * The above type defines a set of optional color properties for a widget.
6
+ * @property {string} background
7
+ * @property {string} foreground
8
+ * @property {string} primary
9
+ * @property {string} success
10
+ * @property {string} error
11
+ * @property {string} warning
12
+ */
13
+ export type WidgetColors = {
5
14
  background?: string;
6
- // inputBackground?: string;
7
- // icons?: string;
8
- primary?: string;
9
15
  foreground?: string;
10
- // text?: string;
16
+ primary?: string;
11
17
  success?: string;
12
18
  error?: string;
13
19
  warning?: string;
14
20
  };
15
21
 
16
- export type Theme = {
17
- mode?: 'dark' | 'light' | 'auto';
22
+ /**
23
+ * The `WidgetTheme` defines the properties of a widget theme, including mode, font family, colors, border
24
+ * radius, width, and height.
25
+ * @property {'auto' | 'light' | 'dark'} mode - The mode property is used to specify the default theme for
26
+ * the widget.
27
+ * @property {string} fontFamily - The font family to be used in the widget.
28
+ * @property {Colors} colors - The `colors` property is a sub-property of the `WidgetTheme` object that
29
+ * defines the color scheme for the widget. It is of type `Colors`, which is likely another object that
30
+ * contains specific color values for various parts of the widget (e.g. background color, text color,
31
+ * border color
32
+ * @property {number} borderRadius - `borderRadius` is a property of the `WidgetTheme` type that
33
+ * specifies the radius of the corners of a widget.
34
+ * @property {number} width - The `width` property is a number that represents the width of the widget.
35
+ * @property {number} height - The `height` property is a number that specifies the height of the widget.
36
+ */
37
+ export type WidgetTheme = {
38
+ mode?: 'auto' | 'light' | 'dark';
18
39
  fontFamily?: string;
19
- colors?: Colors;
40
+ colors?: WidgetColors;
20
41
  borderRadius?: number;
21
42
  width?: number;
22
43
  height?: number;
23
44
  };
24
- export type Support = {
45
+
46
+ /**
47
+ * `BlockchainAndTokenConfig`
48
+ *
49
+ * @property {string} blockchain - This property is optional and represents the default selected blockchain.
50
+ * @property {Asset} token - The `token` property is a type of `Asset` and represents the default token
51
+ * which is selected. e.g. {blockchain: 'BSC', symbol: 'BNB', address: null}
52
+ * @property {string[]} blockchains - An optional array of strings representing the supported
53
+ * blockchains. e.g. ['BSC','ETHEREUM']
54
+ * @property {Asset[]} tokens - The `tokens` property is an optional array of `Asset` objects that
55
+ * you could use that to limit tokens to some limited ones.
56
+ */
57
+ export type BlockchainAndTokenConfig = {
25
58
  blockchain?: string;
26
59
  token?: Asset;
27
60
  blockchains?: string[];
28
61
  tokens?: Asset[];
29
62
  };
30
63
 
64
+ /**
65
+ * The type WidgetConfig defines the configuration options for a widget, including API key, affiliate
66
+ * reference, amount, blockchain and token configurations, liquidity sources, wallet types, language,
67
+ * and theme.
68
+ *
69
+ * @property {string} apiKey - The API key used to communicate with Rango API
70
+ * @property {string} affiliateRef - The affiliate reference is an optional string property in the
71
+ * WidgetConfig type. It is used to set and track referrals or affiliations for the dApps.
72
+ * @property {number} amount - The default input amount.
73
+ * @property {BlockchainAndTokenConfig} from - The `from` property is an optional property of type
74
+ * `BlockchainAndTokenConfig` that specifies the default blockchain and token from which the user wants to
75
+ * exchange.It can also used to limit source swap blockchains/tokens to some limited ones.
76
+ * @property {BlockchainAndTokenConfig} to - The "to" property is an optional property of type
77
+ * "BlockchainAndTokenConfig" that specifies the default blockchain and token to which the user wants to
78
+ * exchange.It can also used to limit destination swap blockchains/tokens to some limited ones.
79
+ * blockchain during the transaction.
80
+ * @property {string[]} liquiditySources - The `liquiditySources` property is an optional array of
81
+ * strings that specifies the liquidity sources allowed dexes and bridges for the routing
82
+ * @property {WalletType[]} wallets - The `wallets` property is an optional array of `WalletType`
83
+ * values that represent the types of wallets that the widget should support. For example, it could
84
+ * include values like `"metamask"`, `"kepler"`, or `"phantom"`.
85
+ * @property {boolean} multiWallets - The `multiWallets` property is a boolean value that indicates
86
+ * whether the widget should allow the user to select multiple wallets for the transaction.
87
+ * @property {boolean} customAddress - A boolean value indicating whether the user can input a custom
88
+ * address for the transaction. If set to true, the widget will allow the user to input a custom
89
+ * address for the destination.
90
+ * @property {string} language - The language property is an optional string that specifies the
91
+ * default language in which the widget should be displayed. If not provided, the widget will default to the
92
+ * language of the user's browser.
93
+ * @property {WidgetTheme} theme - The `theme` property is a part of the `WidgetConfig` type and is
94
+ * used to specify the visual theme of the widget. It is of type `WidgetTheme`, which is an interface
95
+ * that defines the various properties of the theme, such as colors, fonts, and others.
96
+ */
31
97
  export type WidgetConfig = {
32
98
  apiKey: string;
33
99
  affiliateRef?: string;
34
100
  amount?: number;
35
- from?: Support;
36
- to?: Support;
101
+ from?: BlockchainAndTokenConfig;
102
+ to?: BlockchainAndTokenConfig;
37
103
  liquiditySources?: string[];
38
104
  wallets?: WalletType[];
39
105
  multiWallets?: boolean;
40
106
  customAddress?: boolean;
41
107
  language?: string;
42
- theme?: Theme;
108
+ theme?: WidgetTheme;
43
109
  };