@rango-dev/widget-embedded 0.20.1-next.20 → 0.20.1-next.22

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 (119) hide show
  1. package/dist/components/AppRouter.d.ts.map +1 -1
  2. package/dist/components/AppRoutes.d.ts.map +1 -1
  3. package/dist/components/BlockchainList/BlockchainList.styles.d.ts +161 -1
  4. package/dist/components/BlockchainList/BlockchainList.styles.d.ts.map +1 -1
  5. package/dist/components/HeaderButtons/HeaderButtons.types.d.ts +0 -1
  6. package/dist/components/HeaderButtons/HeaderButtons.types.d.ts.map +1 -1
  7. package/dist/components/HeaderButtons/HomeButtons.d.ts.map +1 -1
  8. package/dist/components/Layout/Layout.d.ts +2 -3
  9. package/dist/components/Layout/Layout.d.ts.map +1 -1
  10. package/dist/components/Layout/Layout.helpers.d.ts +2 -0
  11. package/dist/components/Layout/Layout.helpers.d.ts.map +1 -0
  12. package/dist/components/Layout/Layout.styles.d.ts +2 -4
  13. package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
  14. package/dist/components/Layout/Layout.types.d.ts +6 -3
  15. package/dist/components/Layout/Layout.types.d.ts.map +1 -1
  16. package/dist/components/Layout/PageContainer.d.ts +166 -0
  17. package/dist/components/Layout/PageContainer.d.ts.map +1 -0
  18. package/dist/components/Layout/ScrollableArea.d.ts +164 -0
  19. package/dist/components/Layout/ScrollableArea.d.ts.map +1 -0
  20. package/dist/components/Layout/index.d.ts +2 -0
  21. package/dist/components/Layout/index.d.ts.map +1 -1
  22. package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
  23. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -1
  24. package/dist/components/SettingsContainer/SettingsContainer.style.d.ts +0 -161
  25. package/dist/components/SettingsContainer/SettingsContainer.style.d.ts.map +1 -1
  26. package/dist/components/SettingsContainer/index.d.ts +1 -1
  27. package/dist/components/SettingsContainer/index.d.ts.map +1 -1
  28. package/dist/components/SwapDetails/SwapDetails.Placeholder.d.ts.map +1 -1
  29. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  30. package/dist/components/SwapDetails/SwapDetails.styles.d.ts +161 -1
  31. package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
  32. package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
  33. package/dist/constants/searchParams.d.ts +6 -6
  34. package/dist/constants/searchParams.d.ts.map +1 -1
  35. package/dist/containers/App/App.styles.d.ts.map +1 -1
  36. package/dist/containers/QuoteInfo/QuoteInfo.d.ts +1 -1
  37. package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -1
  38. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +0 -324
  39. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +1 -1
  40. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +0 -7
  41. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +1 -1
  42. package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
  43. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  44. package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
  45. package/dist/hooks/useSyncUrlAndStore/index.d.ts +2 -0
  46. package/dist/hooks/useSyncUrlAndStore/index.d.ts.map +1 -0
  47. package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.d.ts +2 -0
  48. package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.d.ts.map +1 -0
  49. package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.helpers.d.ts +4 -0
  50. package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.helpers.d.ts.map +1 -0
  51. package/dist/index.js +2 -2
  52. package/dist/index.js.map +4 -4
  53. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  54. package/dist/pages/HistoryPage.d.ts.map +1 -1
  55. package/dist/pages/Home.d.ts.map +1 -1
  56. package/dist/pages/LanguagePage.d.ts.map +1 -1
  57. package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
  58. package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
  59. package/dist/pages/SettingsPage.d.ts.map +1 -1
  60. package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
  61. package/dist/pages/ThemePage.d.ts.map +1 -1
  62. package/dist/pages/WalletsPage.d.ts.map +1 -1
  63. package/dist/utils/quote.d.ts +0 -1
  64. package/dist/utils/quote.d.ts.map +1 -1
  65. package/dist/utils/ui.d.ts +2 -0
  66. package/dist/utils/ui.d.ts.map +1 -1
  67. package/package.json +3 -3
  68. package/src/components/AppRouter.tsx +1 -8
  69. package/src/components/AppRoutes.tsx +11 -0
  70. package/src/components/BlockchainList/BlockchainList.styles.ts +4 -3
  71. package/src/components/BlockchainList/BlockchainList.tsx +1 -1
  72. package/src/components/HeaderButtons/HeaderButtons.types.ts +0 -1
  73. package/src/components/HeaderButtons/HomeButtons.tsx +1 -2
  74. package/src/components/Layout/Layout.helpers.ts +16 -0
  75. package/src/components/Layout/Layout.styles.ts +17 -31
  76. package/src/components/Layout/Layout.tsx +24 -27
  77. package/src/components/Layout/Layout.types.ts +9 -8
  78. package/src/components/Layout/PageContainer.tsx +24 -0
  79. package/src/components/Layout/ScrollableArea.tsx +11 -0
  80. package/src/components/Layout/index.ts +2 -0
  81. package/src/components/NotificationContent/NotificationContent.tsx +0 -3
  82. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts +0 -1
  83. package/src/components/SettingsContainer/SettingsContainer.style.ts +0 -5
  84. package/src/components/SettingsContainer/index.ts +0 -1
  85. package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +0 -1
  86. package/src/components/SwapDetails/SwapDetails.styles.ts +5 -6
  87. package/src/components/SwapDetails/SwapDetails.tsx +3 -5
  88. package/src/components/TokenList/TokenList.styles.ts +2 -0
  89. package/src/components/TokenList/TokenList.tsx +1 -1
  90. package/src/constants/searchParams.ts +6 -6
  91. package/src/containers/App/App.styles.ts +2 -0
  92. package/src/containers/QuoteInfo/QuoteInfo.styles.ts +0 -15
  93. package/src/containers/QuoteInfo/QuoteInfo.tsx +30 -77
  94. package/src/containers/QuoteInfo/QuoteInfo.types.ts +0 -7
  95. package/src/containers/Wallets/Wallets.tsx +0 -2
  96. package/src/hooks/useSwapInput.ts +6 -1
  97. package/src/hooks/useSyncStoresWithConfig.ts +3 -17
  98. package/src/hooks/useSyncUrlAndStore/index.ts +1 -0
  99. package/src/hooks/useSyncUrlAndStore/useSyncUrlAndStore.helpers.ts +35 -0
  100. package/src/hooks/useSyncUrlAndStore/useSyncUrlAndStore.ts +135 -0
  101. package/src/pages/ConfirmSwapPage.tsx +52 -47
  102. package/src/pages/HistoryPage.tsx +5 -17
  103. package/src/pages/Home.tsx +44 -43
  104. package/src/pages/LanguagePage.tsx +3 -4
  105. package/src/pages/LiquiditySourcePage.tsx +3 -4
  106. package/src/pages/SelectBlockchainPage.tsx +38 -38
  107. package/src/pages/SelectSwapItemsPage.tsx +40 -38
  108. package/src/pages/SettingsPage.tsx +3 -4
  109. package/src/pages/SwapDetailsPage.tsx +21 -7
  110. package/src/pages/ThemePage.tsx +3 -4
  111. package/src/pages/WalletsPage.tsx +12 -13
  112. package/src/utils/quote.ts +0 -27
  113. package/src/utils/ui.ts +20 -0
  114. package/dist/components/UpdateUrl.d.ts +0 -2
  115. package/dist/components/UpdateUrl.d.ts.map +0 -1
  116. package/dist/store/ui.d.ts +0 -22
  117. package/dist/store/ui.d.ts.map +0 -1
  118. package/src/components/UpdateUrl.tsx +0 -158
  119. package/src/store/ui.ts +0 -21
@@ -35,33 +35,6 @@ import {
35
35
  hasProperSlippage,
36
36
  } from './swap';
37
37
 
38
- export function searchParamsToToken(
39
- tokens: Token[],
40
- searchParams: string | null,
41
- chain: BlockchainMeta | null
42
- ): Token | null {
43
- if (!chain) {
44
- return null;
45
- }
46
- return (
47
- tokens.find((token) => {
48
- const symbolAndAddress = searchParams?.split('--');
49
- if (symbolAndAddress?.length === 1) {
50
- return (
51
- token.symbol === symbolAndAddress[0] &&
52
- token.address === null &&
53
- token.blockchain === chain.name
54
- );
55
- }
56
- return (
57
- token.symbol === symbolAndAddress?.[0] &&
58
- token.address === symbolAndAddress?.[1] &&
59
- token.blockchain === chain.name
60
- );
61
- }) || null
62
- );
63
- }
64
-
65
38
  export function getQuoteToTokenUsdPrice(
66
39
  quote: BestRouteResponse | null
67
40
  ): number | null | undefined {
package/src/utils/ui.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-magic-numbers */
2
2
  import type { WidgetTheme } from '../types';
3
3
  import type { createTheme } from '@rango-dev/ui';
4
+ import type React from 'react';
4
5
 
5
6
  import {
6
7
  theme as baseThemeTokens,
@@ -70,3 +71,22 @@ export function customizedThemeTokens(
70
71
  dark,
71
72
  };
72
73
  }
74
+
75
+ export function joinList(
76
+ list: React.JSX.Element[],
77
+ divider: React.JSX.Element
78
+ ) {
79
+ if (list.length <= 1) {
80
+ return list;
81
+ }
82
+
83
+ const output: React.JSX.Element[] = [];
84
+ list.forEach((item, index) => {
85
+ output.push(item);
86
+ if (index < list.length - 1) {
87
+ output.push(divider);
88
+ }
89
+ });
90
+
91
+ return output;
92
+ }
@@ -1,2 +0,0 @@
1
- export declare function UpdateUrl(): null;
2
- //# sourceMappingURL=UpdateUrl.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UpdateUrl.d.ts","sourceRoot":"","sources":["../../src/components/UpdateUrl.tsx"],"names":[],"mappings":"AAcA,wBAAgB,SAAS,SA+IxB"}
@@ -1,22 +0,0 @@
1
- interface UiState {
2
- connectWalletsButtonDisabled: boolean;
3
- selectedSwapRequestId: string | null;
4
- currentPage: string;
5
- setSelectedSwap: (requestId: string | null) => void;
6
- setCurrentPage: (path: string) => void;
7
- }
8
- export declare const useUiStore: {
9
- (): UiState;
10
- <U>(selector: (state: UiState) => U): U;
11
- <U_1>(selector: (state: UiState) => U_1, equalityFn: (a: U_1, b: U_1) => boolean): U_1;
12
- } & import("zustand").StoreApi<UiState> & {
13
- use: {
14
- connectWalletsButtonDisabled: () => boolean;
15
- selectedSwapRequestId: () => string | null;
16
- currentPage: () => string;
17
- setSelectedSwap: () => (requestId: string | null) => void;
18
- setCurrentPage: () => (path: string) => void;
19
- };
20
- };
21
- export {};
22
- //# sourceMappingURL=ui.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/store/ui.ts"],"names":[],"mappings":"AAIA,UAAU,OAAO;IACf,4BAA4B,EAAE,OAAO,CAAC;IACtC,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACpD,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,UAAU;;;;;;;;;2CAJQ,MAAM,GAAG,IAAI,KAAK,IAAI;qCAC5B,MAAM,KAAK,IAAI;;CAWvC,CAAC"}
@@ -1,158 +0,0 @@
1
- import { useEffect, useRef } from 'react';
2
- import {
3
- createSearchParams,
4
- useLocation,
5
- useSearchParams,
6
- } from 'react-router-dom';
7
-
8
- import { navigationRoutes } from '../constants/navigationRoutes';
9
- import { SearchParams } from '../constants/searchParams';
10
- import { useAppStore } from '../store/AppStore';
11
- import { useQuoteStore } from '../store/quote';
12
- import { useUiStore } from '../store/ui';
13
- import { searchParamsToToken } from '../utils/quote';
14
-
15
- export function UpdateUrl() {
16
- const firstRender = useRef(true);
17
- const [searchParams, setSearchParams] = useSearchParams();
18
- const location = useLocation();
19
- const firstRenderSearchParams = useRef(location.search);
20
- const searchParamsRef = useRef<Record<string, string>>({});
21
- const fromBlockchain = useQuoteStore.use.fromBlockchain();
22
- const toBlockchain = useQuoteStore.use.toBlockchain();
23
- const fromToken = useQuoteStore.use.fromToken();
24
- const toToken = useQuoteStore.use.toToken();
25
- const setFromBlockchain = useQuoteStore.use.setFromBlockchain();
26
- const setFromToken = useQuoteStore.use.setFromToken();
27
- const setToBlockchain = useQuoteStore.use.setToBlockchain();
28
- const setToToken = useQuoteStore.use.setToToken();
29
- const inputAmount = useQuoteStore.use.inputAmount();
30
- const setInputAmount = useQuoteStore.use.setInputAmount();
31
- const fetchMetaStatus = useAppStore().fetchStatus;
32
- const blockchains = useAppStore().blockchains();
33
- const tokens = useAppStore().tokens();
34
- const setSelectedSwap = useUiStore.use.setSelectedSwap();
35
-
36
- useEffect(() => {
37
- const params: Record<string, string> = {};
38
- createSearchParams(firstRenderSearchParams.current).forEach(
39
- (value, key) => {
40
- params[key] = value;
41
- }
42
- );
43
- searchParamsRef.current = params;
44
- const requestId =
45
- location.pathname.split(navigationRoutes.swaps + '/')[1] || null;
46
- if (requestId) {
47
- setSelectedSwap(requestId);
48
- }
49
- }, []);
50
-
51
- useEffect(() => {
52
- if (!firstRender.current) {
53
- let fromChainString = '',
54
- fromTokenString = '',
55
- toChainString = '',
56
- toTokenString = '',
57
- fromAmount = '';
58
- const autoConnect = searchParamsRef.current[SearchParams.AUTO_CONNECT];
59
- if (fetchMetaStatus !== 'success') {
60
- fromChainString = searchParamsRef.current[SearchParams.FROM_CHAIN];
61
- fromTokenString = searchParamsRef.current[SearchParams.FROM_TOKEN];
62
- toChainString = searchParamsRef.current[SearchParams.TO_CHAIN];
63
- toTokenString = searchParamsRef.current[SearchParams.TO_TOKEN];
64
- fromAmount =
65
- searchParamsRef.current[SearchParams.FROM_AMOUNT] || inputAmount;
66
- } else {
67
- fromChainString = fromBlockchain?.name || '';
68
- fromTokenString =
69
- (fromToken?.symbol || '') +
70
- (fromToken?.address ? `--${fromToken?.address}` : '');
71
- toChainString = toBlockchain?.name || '';
72
- toTokenString =
73
- (toToken?.symbol || '') +
74
- (toToken?.address ? `--${toToken?.address}` : '');
75
- fromAmount = inputAmount;
76
- }
77
- setSearchParams(
78
- {
79
- ...(fromChainString && {
80
- [SearchParams.FROM_CHAIN]: fromChainString,
81
- }),
82
- ...(fromTokenString && {
83
- [SearchParams.FROM_TOKEN]: fromTokenString,
84
- }),
85
- ...(toChainString && { [SearchParams.TO_CHAIN]: toChainString }),
86
- ...(toTokenString && { [SearchParams.TO_TOKEN]: toTokenString }),
87
- ...(fromAmount && {
88
- [SearchParams.FROM_AMOUNT]: fromAmount.toString(),
89
- }),
90
- ...(autoConnect && {
91
- [SearchParams.AUTO_CONNECT]: autoConnect,
92
- }),
93
- },
94
- { replace: true }
95
- );
96
- }
97
- firstRender.current = false;
98
- }, [
99
- location.pathname,
100
- inputAmount,
101
- fromBlockchain,
102
- fromToken,
103
- toBlockchain,
104
- toToken,
105
- ]);
106
-
107
- useEffect(() => {
108
- if (fetchMetaStatus === 'success') {
109
- const fromChainString = searchParams.get(SearchParams.FROM_CHAIN);
110
- const fromTokenString = searchParams.get(SearchParams.FROM_TOKEN);
111
- const toChainString = searchParams.get(SearchParams.TO_CHAIN);
112
- const toTokenString = searchParams.get(SearchParams.TO_TOKEN);
113
- const fromAmount = searchParams.get(SearchParams.FROM_AMOUNT);
114
- const fromBlockchain = blockchains.find(
115
- (blockchain) => blockchain.name === fromChainString
116
- );
117
- const fromToken = searchParamsToToken(
118
- tokens,
119
- fromTokenString,
120
- fromBlockchain || null
121
- );
122
- const toBlockchain = blockchains.find(
123
- (blockchain) => blockchain.name === toChainString
124
- );
125
- const toToken = searchParamsToToken(
126
- tokens,
127
- toTokenString,
128
- toBlockchain || null
129
- );
130
- if (!!fromBlockchain) {
131
- setFromBlockchain(fromBlockchain);
132
- if (!!fromToken) {
133
- setFromToken({
134
- token: fromToken,
135
- meta: {
136
- blockchains: blockchains,
137
- tokens: tokens,
138
- },
139
- });
140
- }
141
- }
142
- if (!!toBlockchain) {
143
- setToBlockchain(toBlockchain);
144
- if (!!toToken) {
145
- setToToken({
146
- token: toToken,
147
- meta: { blockchains: blockchains, tokens: tokens },
148
- });
149
- }
150
- }
151
- if (fromAmount) {
152
- setInputAmount(fromAmount);
153
- }
154
- }
155
- }, [fetchMetaStatus]);
156
-
157
- return null;
158
- }
package/src/store/ui.ts DELETED
@@ -1,21 +0,0 @@
1
- import { create } from 'zustand';
2
-
3
- import createSelectors from './selectors';
4
-
5
- interface UiState {
6
- connectWalletsButtonDisabled: boolean;
7
- selectedSwapRequestId: string | null;
8
- currentPage: string;
9
- setSelectedSwap: (requestId: string | null) => void;
10
- setCurrentPage: (path: string) => void;
11
- }
12
-
13
- export const useUiStore = createSelectors(
14
- create<UiState>()((set) => ({
15
- connectWalletsButtonDisabled: false,
16
- selectedSwapRequestId: null,
17
- currentPage: '',
18
- setSelectedSwap: (requestId) => set({ selectedSwapRequestId: requestId }),
19
- setCurrentPage: (path) => set({ currentPage: path }),
20
- }))
21
- );