@rango-dev/widget-embedded 0.12.1-next.17 → 0.12.1-next.19

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.
@@ -1 +1 @@
1
- {"version":3,"file":"SelectSwapItemsPage.d.ts","sourceRoot":"","sources":["../../src/pages/SelectSwapItemsPage.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAS,MAAM,WAAW,CAAC;AAI9C,OAAO,KAA8B,MAAM,OAAO,CAAC;AAgBnD,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,eAAe,CAAC,EAAE,KAAK,EAAE,CAAC;IAC1B,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC;CACxB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,qBAmInD"}
1
+ {"version":3,"file":"SelectSwapItemsPage.d.ts","sourceRoot":"","sources":["../../src/pages/SelectSwapItemsPage.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAS,MAAM,WAAW,CAAC;AAI9C,OAAO,KAA8B,MAAM,OAAO,CAAC;AAgBnD,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,eAAe,CAAC,EAAE,KAAK,EAAE,CAAC;IAC1B,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC;CACxB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,qBAuInD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.12.1-next.17",
3
+ "version": "0.12.1-next.19",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "@rango-dev/queue-manager-core": "^0.15.1-next.1",
24
24
  "@rango-dev/queue-manager-rango-preset": "^0.15.1-next.5",
25
25
  "@rango-dev/queue-manager-react": "^0.15.1-next.3",
26
- "@rango-dev/ui": "^0.15.1-next.10",
26
+ "@rango-dev/ui": "^0.15.1-next.11",
27
27
  "@rango-dev/wallets-react": "^0.1.1-next.5",
28
28
  "@rango-dev/wallets-shared": "^0.15.1-next.3",
29
29
  "bignumber.js": "^9.1.1",
@@ -41,7 +41,7 @@ export function BlockchainList(props: PropTypes) {
41
41
  );
42
42
  }
43
43
  return (
44
- <List>
44
+ <List key={`${blockchainCategory}-${searchedFor}`}>
45
45
  {blockchains.map((item) => (
46
46
  <ListItemButton
47
47
  key={`${item.name}-${item.chainId}`}
@@ -25,7 +25,7 @@ export const Content = styled('div', {
25
25
  display: 'flex',
26
26
  flexDirection: 'column',
27
27
  flex: 1,
28
- padding: '$20 $0 $10 $20',
28
+ padding: '$20 $20 $10 $20',
29
29
  backgroundColor: '$background',
30
30
  position: 'relative',
31
31
  overflowY: 'auto',
@@ -1,14 +1,8 @@
1
1
  import type { PropTypes, Ref } from './Layout.types';
2
2
  import type { PropsWithChildren } from 'react';
3
3
 
4
- import {
5
- BottomLogo,
6
- Divider,
7
- Header,
8
- theme,
9
- usePaddingRight,
10
- } from '@rango-dev/ui';
11
- import React, { useRef } from 'react';
4
+ import { BottomLogo, Divider, Header } from '@rango-dev/ui';
5
+ import React from 'react';
12
6
  import { useNavigate } from 'react-router-dom';
13
7
 
14
8
  import { navigationRoutes } from '../../constants/navigationRoutes';
@@ -18,8 +12,6 @@ import { BackButton, CancelButton, WalletButton } from '../HeaderButtons';
18
12
 
19
13
  import { Container, Content, Footer } from './Layout.styles';
20
14
 
21
- const DEFAULT_CONTENT_PADDING = 20;
22
-
23
15
  function LayoutComponent(props: PropsWithChildren<PropTypes>, ref: Ref) {
24
16
  const {
25
17
  children,
@@ -35,13 +27,6 @@ function LayoutComponent(props: PropsWithChildren<PropTypes>, ref: Ref) {
35
27
  useUiStore.use.connectWalletsButtonDisabled();
36
28
  const navigate = useNavigate();
37
29
 
38
- const contentRef = useRef<HTMLDivElement | null>(null);
39
-
40
- usePaddingRight({
41
- elementRef: contentRef,
42
- paddingRight: noPadding ? '0' : theme.sizes[DEFAULT_CONTENT_PADDING],
43
- });
44
-
45
30
  const onConnectWallet = () => {
46
31
  if (!connectWalletsButtonDisabled) {
47
32
  navigate('/' + navigationRoutes.wallets);
@@ -65,9 +50,7 @@ function LayoutComponent(props: PropsWithChildren<PropTypes>, ref: Ref) {
65
50
  </>
66
51
  }
67
52
  />
68
- <Content noPadding={noPadding} ref={contentRef}>
69
- {children}
70
- </Content>
53
+ <Content noPadding={noPadding}>{children}</Content>
71
54
  {(hasLogo || footer) && (
72
55
  <Footer>
73
56
  <div className="footer__content">{footer}</div>
@@ -42,7 +42,7 @@ export const HeaderDetails = styled('div', {
42
42
  });
43
43
 
44
44
  export const StepsList = styled('div', {
45
- padding: '$0 $0 $20 $20',
45
+ padding: '$0 $20 $20 $20',
46
46
  width: '100%',
47
47
  overflow: 'auto',
48
48
  });
@@ -16,10 +16,8 @@ import {
16
16
  RouteCost,
17
17
  RouteSummary,
18
18
  StepDetails,
19
- theme,
20
19
  Typography,
21
20
  useCopyToClipboard,
22
- usePaddingRight,
23
21
  } from '@rango-dev/ui';
24
22
  import { useWallets } from '@rango-dev/wallets-react';
25
23
  import React, { useEffect, useRef, useState } from 'react';
@@ -65,15 +63,14 @@ import {
65
63
  } from './SwapDetails.helpers';
66
64
  import { Container, HeaderDetails, StepsList } from './SwapDetails.styles';
67
65
 
68
- const DEFAULT_CONTENT_PADDING = 20;
69
66
  export function SwapDetails(props: SwapDetailsProps) {
70
67
  const { swap, requestId, onDelete, onCancel: onCancelProps } = props;
71
68
  const { canSwitchNetworkTo, connect, getWalletInfo } = useWallets();
72
69
  const retry = useBestRouteStore.use.retry();
73
70
  const navigate = useNavigate();
74
71
  const { navigateBackFrom } = useNavigateBack();
75
- const listRef = useRef<HTMLDivElement | null>(null);
76
72
  const [_, handleCopy] = useCopyToClipboard(RESET_INTERVAL);
73
+ const listRef = useRef<HTMLDivElement | null>(null);
77
74
  const [modalState, setModalState] = useState<ModalState>(null);
78
75
  const [showCompletedModal, setShowCompletedModal] = useState<
79
76
  'success' | 'failed' | null
@@ -82,11 +79,6 @@ export function SwapDetails(props: SwapDetailsProps) {
82
79
  meta: { tokens },
83
80
  } = useMetaStore();
84
81
 
85
- usePaddingRight({
86
- elementRef: listRef,
87
- paddingRight: theme.sizes[DEFAULT_CONTENT_PADDING],
88
- });
89
-
90
82
  const onCancel = () => {
91
83
  onCancelProps();
92
84
  setModalState(null);
@@ -1,38 +1,8 @@
1
1
  import { ReverseIcon, styled } from '@rango-dev/ui';
2
- import React, { useEffect, useRef, useState } from 'react';
3
- import { useInRouterContext, useSearchParams } from 'react-router-dom';
2
+ import React from 'react';
4
3
 
5
- import { SearchParams } from '../constants/searchParams';
6
4
  import { useBestRouteStore } from '../store/bestRoute';
7
5
 
8
- function SwitchFromAndTo({ count }: { count: number }) {
9
- const firstRender = useRef(true);
10
- const [searchParams, setSearchParams] = useSearchParams();
11
- const outputAmount = useBestRouteStore.use.outputAmount();
12
-
13
- useEffect(() => {
14
- if (!firstRender.current) {
15
- const fromChainString = searchParams.get(SearchParams.FROM_CHAIN);
16
- const fromTokenString = searchParams.get(SearchParams.FROM_TOKEN);
17
- const toChainString = searchParams.get(SearchParams.TO_CHAIN);
18
- const toTokenString = searchParams.get(SearchParams.TO_TOKEN);
19
- setSearchParams({
20
- ...(toChainString && { [SearchParams.FROM_CHAIN]: toChainString }),
21
- ...(toTokenString && { [SearchParams.FROM_TOKEN]: toTokenString }),
22
- ...(fromChainString && { [SearchParams.TO_CHAIN]: fromChainString }),
23
- ...(fromTokenString && { [SearchParams.TO_TOKEN]: fromTokenString }),
24
- ...(outputAmount && {
25
- [SearchParams.FROM_AMOUNT]: outputAmount.toString(),
26
- }),
27
- });
28
- } else {
29
- firstRender.current = false;
30
- }
31
- }, [count]);
32
-
33
- return null;
34
- }
35
-
36
6
  const SwitchButtonContainer = styled('div', {
37
7
  position: 'absolute',
38
8
  bottom: '-12px',
@@ -58,18 +28,14 @@ const StyledButton = styled('div', {
58
28
 
59
29
  export function SwitchFromAndToButton() {
60
30
  const switchFromAndTo = useBestRouteStore.use.switchFromAndTo();
61
- const isRouterInContext = useInRouterContext();
62
- const [count, setCount] = useState(0);
63
31
 
64
32
  return (
65
33
  <SwitchButtonContainer>
66
34
  <StyledButton
67
35
  onClick={() => {
68
36
  switchFromAndTo();
69
- setCount((prev) => prev + 1);
70
37
  }}>
71
38
  <ReverseIcon size={12} />
72
- {isRouterInContext && <SwitchFromAndTo count={count} />}
73
39
  </StyledButton>
74
40
  </SwitchButtonContainer>
75
41
  );
@@ -83,7 +83,7 @@ const renderDesc = (props: RenderDescProps) => {
83
83
  };
84
84
 
85
85
  export function TokenList(props: PropTypes) {
86
- const { list, searchedFor = '', onChange } = props;
86
+ const { list, searchedFor = '', onChange, selectedBlockchain } = props;
87
87
 
88
88
  const [tokens, setTokens] = useState<TokenWithBalance[]>(list);
89
89
  const loadingStatus = useMetaStore.use.loadingStatus();
@@ -253,6 +253,7 @@ export function TokenList(props: PropTypes) {
253
253
  loadNextPage={loadNextPage}
254
254
  innerElementType={innerElementType}
255
255
  size={60}
256
+ key={`${selectedBlockchain}-${searchedFor}`}
256
257
  />
257
258
  );
258
259
  };
@@ -12,6 +12,7 @@ export interface PropTypes {
12
12
  list: TokenWithBalance[];
13
13
  searchedFor?: string;
14
14
  onChange: (token: TokenWithBalance) => void;
15
+ selectedBlockchain?: string;
15
16
  }
16
17
 
17
18
  export interface LoadingTokenListProps {
@@ -28,6 +28,7 @@ interface PropTypes {
28
28
 
29
29
  export function SelectSwapItemsPage(props: PropTypes) {
30
30
  const { type, supportedBlockchains, supportedTokens, pinnedTokens } = props;
31
+ const [selectedBlockchain, setSelectedBlockchain] = useState('');
31
32
  const navigate = useNavigate();
32
33
  const { navigateBackFrom } = useNavigateBack();
33
34
  const {
@@ -120,6 +121,7 @@ export function SelectSwapItemsPage(props: PropTypes) {
120
121
  } else {
121
122
  setToBlockchain(blockchain, true);
122
123
  }
124
+ setSelectedBlockchain(blockchain.name);
123
125
  }
124
126
  }}
125
127
  />
@@ -137,6 +139,8 @@ export function SelectSwapItemsPage(props: PropTypes) {
137
139
  <Divider size={16} />
138
140
  <TokenList
139
141
  list={filterTokens(tokenList, searchedFor)}
142
+ selectedBlockchain={selectedBlockchain}
143
+ searchedFor={searchedFor}
140
144
  onChange={(token) => {
141
145
  const blockchain = blockchains.find(
142
146
  (chain) => token.blockchain === chain.name