@rango-dev/widget-embedded 0.20.1-next.7 → 0.20.1-next.9

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":"ConfirmSwapPage.d.ts","sourceRoot":"","sources":["../../src/pages/ConfirmSwapPage.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAuD,MAAM,OAAO,CAAC;AAyD5E,wBAAgB,eAAe,sBA2S9B"}
1
+ {"version":3,"file":"ConfirmSwapPage.d.ts","sourceRoot":"","sources":["../../src/pages/ConfirmSwapPage.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAuD,MAAM,OAAO,CAAC;AA0D5E,wBAAgB,eAAe,sBA6S9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../src/pages/Home.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AA+C3D,wBAAgB,IAAI,sBAyOnB"}
1
+ {"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../src/pages/Home.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AA+C3D,wBAAgB,IAAI,sBA6OnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"LiquiditySourcePage.d.ts","sourceRoot":"","sources":["../../src/pages/LiquiditySourcePage.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAexC,UAAU,SAAS;IACjB,UAAU,EAAE,WAAW,GAAG,SAAS,CAAC;CACrC;AAED,wBAAgB,mBAAmB,CAAC,EAAE,UAAU,EAAE,EAAE,SAAS,qBAqH5D"}
1
+ {"version":3,"file":"LiquiditySourcePage.d.ts","sourceRoot":"","sources":["../../src/pages/LiquiditySourcePage.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAexC,UAAU,SAAS;IACjB,UAAU,EAAE,WAAW,GAAG,SAAS,CAAC;CACrC;AAED,wBAAgB,mBAAmB,CAAC,EAAE,UAAU,EAAE,EAAE,SAAS,qBAwH5D"}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectSwapItemsPage.d.ts","sourceRoot":"","sources":["../../src/pages/SelectSwapItemsPage.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAcxC,UAAU,SAAS;IACjB,IAAI,EAAE,QAAQ,GAAG,aAAa,CAAC;CAChC;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,qBA+FnD"}
1
+ {"version":3,"file":"SelectSwapItemsPage.d.ts","sourceRoot":"","sources":["../../src/pages/SelectSwapItemsPage.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAcxC,UAAU,SAAS;IACjB,IAAI,EAAE,QAAQ,GAAG,aAAa,CAAC;CAChC;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,qBAmGnD"}
@@ -1 +1 @@
1
- {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/utils/date.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2CAA2C,CAAC;AAKzE,eAAO,MAAM,gBAAgB,EAAE,OAmE9B,CAAC"}
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/utils/date.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2CAA2C,CAAC;AAMzE,eAAO,MAAM,gBAAgB,EAAE,OAmE9B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.20.1-next.7",
3
+ "version": "0.20.1-next.9",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -25,7 +25,7 @@
25
25
  "@rango-dev/queue-manager-core": "^0.25.0",
26
26
  "@rango-dev/queue-manager-rango-preset": "^0.25.1-next.1",
27
27
  "@rango-dev/queue-manager-react": "^0.24.0",
28
- "@rango-dev/ui": "^0.26.1-next.3",
28
+ "@rango-dev/ui": "^0.26.1-next.4",
29
29
  "@rango-dev/wallets-react": "^0.11.1-next.1",
30
30
  "@rango-dev/wallets-shared": "^0.25.1-next.1",
31
31
  "bignumber.js": "^9.1.1",
@@ -274,7 +274,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
274
274
  type="primary"
275
275
  fullWidth
276
276
  size="large">
277
- Confirm
277
+ {i18n.t('Confirm')}
278
278
  </Button>
279
279
  </ConfirmButton>
280
280
  ),
@@ -23,7 +23,10 @@ export const ConnectedIcon = styled('div', {
23
23
  export const SuffixContainer = styled('div', {
24
24
  display: 'flex',
25
25
  justifyContent: 'flex-end',
26
- width: '$40',
26
+ minWidth: '$40',
27
+ button: {
28
+ padding: 0,
29
+ },
27
30
  });
28
31
 
29
32
  export const NotificationsBadgeContainer = styled('div', {
@@ -38,3 +41,15 @@ export const NotificationsBadgeContainer = styled('div', {
38
41
  top: '$0',
39
42
  right: '$0',
40
43
  });
44
+
45
+ export const ProgressIcon = styled('div', {
46
+ padding: '$2',
47
+ variants: {
48
+ isRefetched: {
49
+ true: {
50
+ transform: `rotate(360deg)`,
51
+ transition: 'transform 1s ease-in-out',
52
+ },
53
+ },
54
+ },
55
+ });
@@ -4,7 +4,6 @@ import { i18n } from '@lingui/core';
4
4
  import {
5
5
  NotificationsIcon,
6
6
  Popover,
7
- RefreshIcon,
8
7
  SettingsIcon,
9
8
  Tooltip,
10
9
  TransactionIcon,
@@ -17,6 +16,7 @@ import { isFeatureHidden } from '../../utils/settings';
17
16
  import { NotificationContent } from '../NotificationContent';
18
17
 
19
18
  import { HeaderButton } from './HeaderButtons.styles';
19
+ import { RefreshButton } from './RefreshButton';
20
20
  import { UnreadNotificationsBadge } from './UnreadNotificationsBadge';
21
21
 
22
22
  export function HomeButtons(props: HomeButtonsPropTypes) {
@@ -34,13 +34,7 @@ export function HomeButtons(props: HomeButtonsPropTypes) {
34
34
  container={getContainer()}
35
35
  side="top"
36
36
  content={i18n.t('Refresh')}>
37
- <HeaderButton
38
- variant="ghost"
39
- size="small"
40
- onClick={onClickRefresh}
41
- disabled={!onClickRefresh}>
42
- <RefreshIcon size={16} color={!onClickRefresh ? 'gray' : 'black'} />
43
- </HeaderButton>
37
+ <RefreshButton onClick={onClickRefresh} />
44
38
  </Tooltip>
45
39
 
46
40
  {!isNotificationsHidden && (
@@ -0,0 +1,81 @@
1
+ import { RefreshProgressButton } from '@rango-dev/ui';
2
+ import React, { useEffect, useState } from 'react';
3
+
4
+ import { HeaderButton, ProgressIcon } from './HeaderButtons.styles';
5
+
6
+ const REFRESH_INTERVAL = 1000;
7
+ const MAX_ELAPSED_TIME = 60;
8
+ const MAX_PERCENTAGE = 100;
9
+
10
+ function RefreshButton({ onClick }: { onClick: (() => void) | undefined }) {
11
+ const [elapsedTime, setElapsedTime] = useState(0);
12
+ const [isRefetched, setIsRefetched] = useState(false);
13
+
14
+ const handleVisibilityChange = (interval?: number) => {
15
+ if (document.hidden && interval) {
16
+ // Tab is inactive, clear the interval
17
+ clearTimeout(interval);
18
+ }
19
+ };
20
+
21
+ useEffect(() => {
22
+ let interval: number | undefined;
23
+ if (onClick) {
24
+ interval = window.setInterval(() => {
25
+ setElapsedTime((prevTime) => prevTime + 1);
26
+
27
+ if (elapsedTime === MAX_ELAPSED_TIME) {
28
+ handleRefreshClick();
29
+ }
30
+ }, REFRESH_INTERVAL);
31
+ } else {
32
+ clearTimeout(interval);
33
+ }
34
+
35
+ document.addEventListener('visibilitychange', () =>
36
+ handleVisibilityChange(interval)
37
+ );
38
+
39
+ return () => {
40
+ document.removeEventListener('visibilitychange', () =>
41
+ handleVisibilityChange(interval)
42
+ );
43
+ if (interval) {
44
+ clearInterval(interval);
45
+ }
46
+ };
47
+ }, [elapsedTime, onClick]);
48
+
49
+ const clearTimeout = (interval?: number) => {
50
+ if (interval) {
51
+ clearInterval(interval);
52
+ }
53
+ setElapsedTime(0);
54
+ };
55
+
56
+ const handleRefreshClick = () => {
57
+ onClick?.();
58
+ setElapsedTime(0);
59
+ setIsRefetched(true);
60
+ };
61
+
62
+ return (
63
+ <HeaderButton
64
+ variant="ghost"
65
+ size="small"
66
+ onClick={handleRefreshClick}
67
+ disabled={!onClick}>
68
+ <ProgressIcon
69
+ onTransitionEnd={() => setIsRefetched(false)}
70
+ isRefetched={isRefetched}>
71
+ <RefreshProgressButton
72
+ size={24}
73
+ color={!onClick ? 'gray' : 'black'}
74
+ progress={(elapsedTime / MAX_ELAPSED_TIME) * MAX_PERCENTAGE}
75
+ />
76
+ </ProgressIcon>
77
+ </HeaderButton>
78
+ );
79
+ }
80
+
81
+ export { RefreshButton };
@@ -1,5 +1,6 @@
1
1
  import type { PriceImpactWarningLevel, Step } from '@rango-dev/ui';
2
2
 
3
+ import { i18n } from '@lingui/core';
3
4
  import { TokenAmount } from '@rango-dev/ui';
4
5
  import React from 'react';
5
6
 
@@ -21,7 +22,7 @@ export function QuoteSummary(props: PropTypes) {
21
22
  <Container>
22
23
  <TokenAmount
23
24
  direction="horizontal"
24
- label="Swap input"
25
+ label={i18n.t('Swap input')}
25
26
  type="input"
26
27
  tooltipContainer={getContainer()}
27
28
  price={{
@@ -39,8 +40,8 @@ export function QuoteSummary(props: PropTypes) {
39
40
  <div className={separatorStyles()} />
40
41
  <TokenAmount
41
42
  direction="horizontal"
42
- label="Estimated output"
43
43
  tooltipContainer={getContainer()}
44
+ label={i18n.t('Estimated output')}
44
45
  type="output"
45
46
  price={{
46
47
  value: to.price.value,
@@ -18,11 +18,11 @@ export function SwapsGroup(props: PropTypes) {
18
18
 
19
19
  const loadingGroups = [
20
20
  {
21
- title: 'Today',
21
+ title: i18n.t('Today'),
22
22
  swaps,
23
23
  },
24
24
  {
25
- title: 'This month',
25
+ title: i18n.t('This month'),
26
26
  swaps,
27
27
  },
28
28
  ];
@@ -36,7 +36,7 @@ export function SwapsGroup(props: PropTypes) {
36
36
  variant="label"
37
37
  size="medium"
38
38
  className={groupStyles()}>
39
- {i18n.t(group.title)}
39
+ {group.title}
40
40
  </Typography>
41
41
  </Time>
42
42
  <Divider size={4} />
@@ -69,7 +69,7 @@ export function SwapsGroup(props: PropTypes) {
69
69
  variant="label"
70
70
  size="medium"
71
71
  className={groupStyles()}>
72
- {i18n.t(group.title)}
72
+ {group.title}
73
73
  </Typography>
74
74
  </Time>
75
75
  <Divider size={4} />
@@ -85,8 +85,8 @@ export function SwapsGroup(props: PropTypes) {
85
85
  creationTime={swap.creationTime}
86
86
  status={swap.status}
87
87
  onClick={onSwapClick}
88
- onlyShowTime={group.title === 'Today'}
89
88
  tooltipContainer={getContainer()}
89
+ onlyShowTime={group.title === i18n.t('Today')}
90
90
  swapTokenData={{
91
91
  from: {
92
92
  token: {
@@ -12,7 +12,6 @@ import {
12
12
  css,
13
13
  Divider,
14
14
  IconButton,
15
- RefreshIcon,
16
15
  SettingsIcon,
17
16
  styled,
18
17
  Tooltip,
@@ -26,6 +25,7 @@ import { useNavigate } from 'react-router-dom';
26
25
  import { getRequiredWallets } from '../components/ConfirmWalletsModal/ConfirmWallets.helpers';
27
26
  import { ConfirmWalletsModal } from '../components/ConfirmWalletsModal/ConfirmWalletsModal';
28
27
  import { HeaderButton } from '../components/HeaderButtons/HeaderButtons.styles';
28
+ import { RefreshButton } from '../components/HeaderButtons/RefreshButton';
29
29
  import { Layout } from '../components/Layout';
30
30
  import { navigationRoutes } from '../constants/navigationRoutes';
31
31
  import { getQuoteUpdateWarningMessage } from '../constants/warnings';
@@ -324,15 +324,17 @@ export function ConfirmSwapPage() {
324
324
  <Typography variant="title" size="small">
325
325
  {i18n.t('You get')}
326
326
  </Typography>
327
- <Button
328
- style={{ padding: '0' }}
329
- variant="ghost"
330
- disabled={fetchingConfirmationQuote}
331
- onClick={onRefresh}>
332
- <div className={iconStyles()}>
333
- <RefreshIcon size={16} />
334
- </div>
335
- </Button>
327
+ <div className={iconStyles()}>
328
+ <RefreshButton
329
+ onClick={
330
+ !fetchingConfirmationQuote &&
331
+ !showWallets &&
332
+ !showQuoteWarningModal
333
+ ? onRefresh
334
+ : undefined
335
+ }
336
+ />
337
+ </div>
336
338
  </div>
337
339
  {dbErrorMessage && (
338
340
  <>
@@ -161,7 +161,11 @@ export function Home() {
161
161
  suffix: (
162
162
  <HomeButtons
163
163
  layoutRef={layoutRef.current}
164
- onClickRefresh={!!quote || quoteError ? fetchQuote : undefined}
164
+ onClickRefresh={
165
+ (!!quote || quoteError) && !showQuoteWarningModal
166
+ ? fetchQuote
167
+ : undefined
168
+ }
165
169
  onClickHistory={() => navigate(navigationRoutes.swaps)}
166
170
  onClickSettings={() => navigate(navigationRoutes.settings)}
167
171
  />
@@ -40,6 +40,7 @@ export function LiquiditySourcePage({ sourceType }: PropTypes) {
40
40
  const supportedUniqueSwappersGroups: Array<UniqueSwappersGroupType> =
41
41
  getUniqueSwappersGroups(swappers, disabledLiquiditySources);
42
42
 
43
+ const types = { Exchanges: i18n.t('Exchanges'), Bridges: i18n.t('Bridges') };
43
44
  const validTypes: Array<LiquiditySourceType> = [];
44
45
  if (sourceType === 'Exchanges') {
45
46
  validTypes.push('DEX');
@@ -103,7 +104,7 @@ export function LiquiditySourcePage({ sourceType }: PropTypes) {
103
104
  suffix: (
104
105
  <LiquiditySourceSuffix>
105
106
  <Button variant="ghost" size="xsmall" onClick={toggleAllSources}>
106
- {i18n.t(hasSelectAll ? 'Deselect all' : 'Select all')}
107
+ {hasSelectAll ? i18n.t('Deselect all') : i18n.t('Select all')}
107
108
  </Button>
108
109
  </LiquiditySourceSuffix>
109
110
  ),
@@ -115,7 +116,9 @@ export function LiquiditySourcePage({ sourceType }: PropTypes) {
115
116
  fullWidth
116
117
  color="light"
117
118
  variant="contained"
118
- placeholder={i18n.t('Search {sourceType}', { sourceType })}
119
+ placeholder={i18n.t('Search {sourceType}', {
120
+ sourceType: types[sourceType],
121
+ })}
119
122
  onChange={searchHandler}
120
123
  />
121
124
  {fetchStatus === 'loading' && <LoadingLiquiditySourceList />}
@@ -2,7 +2,7 @@ import { i18n } from '@lingui/core';
2
2
  import {
3
3
  Divider,
4
4
  getCountCategories,
5
- SelectableCategoryList
5
+ SelectableCategoryList,
6
6
  } from '@rango-dev/ui';
7
7
  import React, { useState } from 'react';
8
8
 
@@ -27,7 +27,7 @@ export function SelectBlockchainPage(props: PropTypes) {
27
27
  const fetchStatus = useAppStore().fetchStatus;
28
28
 
29
29
  const blockchains = useAppStore().blockchains({
30
- type: type
30
+ type,
31
31
  });
32
32
 
33
33
  const countActiveCategories = getCountCategories(blockchains);
@@ -37,7 +37,7 @@ export function SelectBlockchainPage(props: PropTypes) {
37
37
  return (
38
38
  <Layout
39
39
  header={{
40
- title: i18n.t(`Select Blockchain`)
40
+ title: i18n.t(`Select Blockchain`),
41
41
  }}>
42
42
  <Divider size={12} />
43
43
 
@@ -68,11 +68,15 @@ export function SelectSwapItemsPage(props: PropTypes) {
68
68
  setToToken({ token, meta: { blockchains, tokens } });
69
69
  }
70
70
  };
71
+ const types = {
72
+ source: i18n.t('Source'),
73
+ destination: i18n.t('Destination'),
74
+ };
71
75
 
72
76
  return (
73
77
  <Layout
74
78
  header={{
75
- title: i18n.t('Swap {type}', { type }),
79
+ title: i18n.t('Swap {type}', { type: types[type] }),
76
80
  }}>
77
81
  <BlockchainsSection
78
82
  blockchains={blockchains}
package/src/utils/date.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { GroupBy } from '../components/SwapsGroup/SwapsGroup.types';
2
2
  import type { PendingSwap } from 'rango-types';
3
3
 
4
+ import { i18n } from '@lingui/core';
4
5
  import dayjs from 'dayjs';
5
6
 
6
7
  export const groupSwapsByDate: GroupBy = (swaps) => {
@@ -14,28 +15,28 @@ export const groupSwapsByDate: GroupBy = (swaps) => {
14
15
  [
15
16
  'today',
16
17
  {
17
- title: 'Today',
18
+ title: i18n.t('Today'),
18
19
  swaps: [],
19
20
  },
20
21
  ],
21
22
  [
22
23
  'week',
23
24
  {
24
- title: 'This week',
25
+ title: i18n.t('This week'),
25
26
  swaps: [],
26
27
  },
27
28
  ],
28
29
  [
29
30
  'month',
30
31
  {
31
- title: 'This month',
32
+ title: i18n.t('This month'),
32
33
  swaps: [],
33
34
  },
34
35
  ],
35
36
  [
36
37
  'year',
37
38
  {
38
- title: 'This year',
39
+ title: i18n.t('This year'),
39
40
  swaps: [],
40
41
  },
41
42
  ],