@rango-dev/ui 0.1.10 → 0.1.11-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.
- package/README.md +1 -1
- package/dist/components/Icon/types.d.ts +1 -0
- package/dist/components/Modal/Modal.d.ts +0 -1
- package/dist/components/StepDetail/StepDetail.d.ts +3 -1
- package/dist/components/SwapDetail/Token.d.ts +1 -0
- package/dist/components/TextField/TextField.d.ts +1 -1
- package/dist/components/TokenList/TokenList.d.ts +2 -2
- package/dist/components/TokenSelector/TokenSelector.d.ts +1 -3
- package/dist/components/Typography/Typography.d.ts +1 -1
- package/dist/components/common/Image.d.ts +6 -0
- package/dist/components/common/index.d.ts +1 -0
- package/dist/containers/ConfirmSwap/ConfirmSwap.d.ts +4 -2
- package/dist/containers/History/History.d.ts +5 -12
- package/dist/containers/History/SwapsGroup.d.ts +13 -0
- package/dist/containers/History/index.d.ts +2 -1
- package/dist/containers/SwapHistory/SwapHistory.d.ts +1 -1
- package/dist/helper/index.d.ts +3 -2
- package/dist/ui.cjs.development.js +329 -255
- package/dist/ui.cjs.development.js.map +1 -1
- package/dist/ui.cjs.production.min.js +1 -1
- package/dist/ui.cjs.production.min.js.map +1 -1
- package/dist/ui.esm.js +328 -256
- package/dist/ui.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Alert/Alert.tsx +3 -3
- package/src/components/BestRoute/BestRoute.tsx +2 -5
- package/src/components/BlockchainSelector/BlockchainSelector.tsx +24 -21
- package/src/components/BlockchainsList/BlockchainsList.tsx +8 -6
- package/src/components/Drawer/Drawer.tsx +1 -1
- package/src/components/Icon/common.ts +10 -0
- package/src/components/Icon/types.tsx +1 -0
- package/src/components/LiquiditySourceList/LiquiditySourceList.tsx +9 -5
- package/src/components/Modal/Modal.tsx +1 -6
- package/src/components/SelectableWalletList/SelectableWalletList.tsx +2 -1
- package/src/components/Settings/Settings.tsx +4 -3
- package/src/components/StepDetail/StepDetail.tsx +45 -12
- package/src/components/SwapContainer/SwapContainer.tsx +1 -2
- package/src/components/SwapDetail/SwapDetail.tsx +8 -16
- package/src/components/SwapDetail/Token.tsx +19 -14
- package/src/components/TextField/TextField.tsx +8 -0
- package/src/components/TokenList/TokenItem.tsx +8 -5
- package/src/components/TokenList/TokenList.tsx +2 -3
- package/src/components/TokenSelector/TokenSelector.tsx +23 -47
- package/src/components/Typography/Typography.tsx +11 -3
- package/src/components/Wallet/Wallet.tsx +8 -5
- package/src/components/common/Image.tsx +27 -0
- package/src/components/common/index.ts +1 -0
- package/src/containers/ConfirmSwap/ConfirmSwap.tsx +9 -9
- package/src/containers/History/History.tsx +28 -71
- package/src/containers/History/SwapsGroup.tsx +59 -0
- package/src/containers/History/index.ts +2 -1
- package/src/containers/SwapHistory/SwapHistory.tsx +121 -135
- package/src/helper/index.ts +20 -5
|
@@ -9,27 +9,21 @@ import { LoadingFailedAlert } from '../Alert/LoadingFailedAlert';
|
|
|
9
9
|
import { NotFoundAlert } from '../Alert/NotFoundAlert';
|
|
10
10
|
import { styled } from '../../theme';
|
|
11
11
|
|
|
12
|
-
const Container = styled('div', {
|
|
13
|
-
flex: '1',
|
|
14
|
-
});
|
|
15
|
-
|
|
16
12
|
export const LoaderContainer = styled('div', {
|
|
17
13
|
display: 'flex',
|
|
18
14
|
justifyContent: 'center',
|
|
19
15
|
width: '100%',
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
paddingTop: '33%',
|
|
17
|
+
flex: 1,
|
|
22
18
|
});
|
|
23
19
|
export interface PropTypes {
|
|
24
20
|
list: TokenWithAmount[];
|
|
25
21
|
type?: 'Source' | 'Destination';
|
|
26
22
|
selected: TokenWithAmount | null;
|
|
27
23
|
onChange: (token: TokenWithAmount) => void;
|
|
28
|
-
hasHeader?: boolean;
|
|
29
|
-
multiSelect?: boolean;
|
|
30
24
|
onBack?: () => void;
|
|
31
|
-
selectedList?: TokenWithAmount[] | 'all';
|
|
32
25
|
loadingStatus: LoadingStatus;
|
|
26
|
+
hasHeader?: boolean;
|
|
33
27
|
}
|
|
34
28
|
|
|
35
29
|
const filterTokens = (list: TokenWithAmount[], searchedFor: string) =>
|
|
@@ -41,53 +35,35 @@ const filterTokens = (list: TokenWithAmount[], searchedFor: string) =>
|
|
|
41
35
|
);
|
|
42
36
|
|
|
43
37
|
export function TokenSelector(props: PropTypes) {
|
|
44
|
-
const {
|
|
45
|
-
|
|
46
|
-
type,
|
|
47
|
-
selected,
|
|
48
|
-
onChange,
|
|
49
|
-
hasHeader,
|
|
50
|
-
multiSelect,
|
|
51
|
-
selectedList,
|
|
52
|
-
onBack,
|
|
53
|
-
loadingStatus,
|
|
54
|
-
} = props;
|
|
38
|
+
const { list, type, selected, hasHeader, onChange, onBack, loadingStatus } =
|
|
39
|
+
props;
|
|
55
40
|
|
|
56
41
|
return (
|
|
57
42
|
<SecondaryPage
|
|
58
43
|
textField={true}
|
|
59
|
-
textFieldPlaceholder="Search Blockchain By Name"
|
|
60
|
-
title={`Select ${type} Token`}
|
|
61
44
|
hasHeader={hasHeader}
|
|
45
|
+
title={`Select ${type} Token`}
|
|
62
46
|
onBack={onBack}
|
|
47
|
+
textFieldPlaceholder="Search Token By Name"
|
|
63
48
|
>
|
|
64
49
|
{(searchedFor) => {
|
|
65
50
|
const filteredTokens = filterTokens(list, searchedFor);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
multiSelect={multiSelect}
|
|
83
|
-
onChange={onChange}
|
|
84
|
-
/>
|
|
85
|
-
) : (
|
|
86
|
-
<NotFoundAlert catergory="Token" searchedFor={searchedFor} />
|
|
87
|
-
)}
|
|
88
|
-
</>
|
|
89
|
-
)}
|
|
90
|
-
</Container>
|
|
51
|
+
|
|
52
|
+
return loadingStatus === 'loading' ? (
|
|
53
|
+
<LoaderContainer>
|
|
54
|
+
<Spinner size={24} />
|
|
55
|
+
</LoaderContainer>
|
|
56
|
+
) : loadingStatus === 'failed' ? (
|
|
57
|
+
<LoadingFailedAlert />
|
|
58
|
+
) : filteredTokens.length ? (
|
|
59
|
+
<TokenList
|
|
60
|
+
searchedText={searchedFor}
|
|
61
|
+
list={filteredTokens}
|
|
62
|
+
selected={selected}
|
|
63
|
+
onChange={onChange}
|
|
64
|
+
/>
|
|
65
|
+
) : (
|
|
66
|
+
<NotFoundAlert catergory="Token" searchedFor={searchedFor} />
|
|
91
67
|
);
|
|
92
68
|
}}
|
|
93
69
|
</SecondaryPage>
|
|
@@ -61,6 +61,13 @@ const TypographyContainer = styled('span', {
|
|
|
61
61
|
fontSize: '$18',
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
|
+
title: {
|
|
65
|
+
fontSize: '$14',
|
|
66
|
+
fontWeight: '$500',
|
|
67
|
+
'@md': {
|
|
68
|
+
fontSize: '$15',
|
|
69
|
+
}
|
|
70
|
+
},
|
|
64
71
|
body1: {
|
|
65
72
|
fontSize: '$14',
|
|
66
73
|
fontWeight: '$400',
|
|
@@ -74,9 +81,9 @@ const TypographyContainer = styled('span', {
|
|
|
74
81
|
body2: {
|
|
75
82
|
fontSize: '$14',
|
|
76
83
|
fontWeight: '$400',
|
|
77
|
-
'@lg': {
|
|
78
|
-
|
|
79
|
-
},
|
|
84
|
+
// '@lg': {
|
|
85
|
+
// fontSize: '$14',
|
|
86
|
+
// },
|
|
80
87
|
},
|
|
81
88
|
body3: {
|
|
82
89
|
fontSize: '$12',
|
|
@@ -173,6 +180,7 @@ export interface PropTypes {
|
|
|
173
180
|
| 'h4'
|
|
174
181
|
| 'h5'
|
|
175
182
|
| 'h6'
|
|
183
|
+
| 'title'
|
|
176
184
|
| 'body1'
|
|
177
185
|
| 'body2'
|
|
178
186
|
| 'body3'
|
|
@@ -6,11 +6,10 @@ import { WalletInfo, WalletState } from '../../types/wallet';
|
|
|
6
6
|
import { Button } from '../Button/Button';
|
|
7
7
|
import { Typography } from '../Typography';
|
|
8
8
|
import { State } from './State';
|
|
9
|
+
import { Image } from '../common';
|
|
9
10
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
height: '$24',
|
|
13
|
-
marginRight: '$12',
|
|
11
|
+
const WalletImageContainer = styled('div', {
|
|
12
|
+
paddingRight: '$12',
|
|
14
13
|
});
|
|
15
14
|
const Text = styled('div', {
|
|
16
15
|
display: 'flex',
|
|
@@ -51,7 +50,11 @@ export function Wallet(props: PropTypes) {
|
|
|
51
50
|
align="start"
|
|
52
51
|
variant="outlined"
|
|
53
52
|
size="large"
|
|
54
|
-
prefix={
|
|
53
|
+
prefix={
|
|
54
|
+
<WalletImageContainer>
|
|
55
|
+
<Image src={image} size={24} />
|
|
56
|
+
</WalletImageContainer>
|
|
57
|
+
}
|
|
55
58
|
suffix={<State walletState={state} installLink={installLink} />}
|
|
56
59
|
>
|
|
57
60
|
<Text>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { styled } from '../../theme';
|
|
3
|
+
|
|
4
|
+
const ImageContainer = styled('div', {
|
|
5
|
+
display: 'flex',
|
|
6
|
+
justifyContent: 'center',
|
|
7
|
+
alignItems: 'center',
|
|
8
|
+
'.image': {
|
|
9
|
+
width: '100%',
|
|
10
|
+
height: '100%',
|
|
11
|
+
objectFit: 'contain',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
type PropTypes = {
|
|
16
|
+
size: number;
|
|
17
|
+
} & React.ImgHTMLAttributes<HTMLImageElement>;
|
|
18
|
+
|
|
19
|
+
export function Image(props: PropTypes) {
|
|
20
|
+
const { size, ...otherProps } = props;
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<ImageContainer css={{ width: size + 'px', height: size + 'px' }}>
|
|
24
|
+
<img className="image" {...otherProps} />
|
|
25
|
+
</ImageContainer>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -54,6 +54,8 @@ const Container = styled('div', {
|
|
|
54
54
|
|
|
55
55
|
const Alerts = styled('div', { paddingBottom: '$16' });
|
|
56
56
|
|
|
57
|
+
type Message = string | ReactNode
|
|
58
|
+
|
|
57
59
|
export interface PropTypes {
|
|
58
60
|
onBack: () => void;
|
|
59
61
|
onConfirm?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
@@ -67,8 +69,8 @@ export interface PropTypes {
|
|
|
67
69
|
previewInputs?: ReactNode;
|
|
68
70
|
previewRoutes?: ReactNode;
|
|
69
71
|
confirmButtonTitle: string;
|
|
70
|
-
errors?:
|
|
71
|
-
warnings?:
|
|
72
|
+
errors?: Message[];
|
|
73
|
+
warnings?: Message[];
|
|
72
74
|
extraMessages?: ReactNode;
|
|
73
75
|
}
|
|
74
76
|
export function ConfirmSwap(props: PropsWithChildren<PropTypes>) {
|
|
@@ -115,17 +117,15 @@ export function ConfirmSwap(props: PropsWithChildren<PropTypes>) {
|
|
|
115
117
|
{errors?.map((error, index) => (
|
|
116
118
|
<>
|
|
117
119
|
<Spacer direction="vertical" />
|
|
118
|
-
<Alert type="error" key={index}
|
|
119
|
-
{error}
|
|
120
|
-
</Alert>
|
|
120
|
+
<Alert type="error" key={index}
|
|
121
|
+
{...(typeof error === 'string') ? {title: error} : {children: error} }/>
|
|
121
122
|
</>
|
|
122
123
|
))}
|
|
123
124
|
{warnings?.map((warning, index) => (
|
|
124
125
|
<>
|
|
125
126
|
<Spacer direction="vertical" />
|
|
126
|
-
<Alert type="warning" key={index}
|
|
127
|
-
{warning}
|
|
128
|
-
</Alert>
|
|
127
|
+
<Alert type="warning" key={index}
|
|
128
|
+
{...(typeof warning === 'string') ? {title: warning} : {children: warning} }/>
|
|
129
129
|
</>
|
|
130
130
|
))}
|
|
131
131
|
</Alerts>
|
|
@@ -153,7 +153,7 @@ export function ConfirmSwap(props: PropsWithChildren<PropTypes>) {
|
|
|
153
153
|
<>
|
|
154
154
|
<AlertContainer>
|
|
155
155
|
<Alert type="error">
|
|
156
|
-
You need to connect a compatible wallet with {wallet}
|
|
156
|
+
You need to connect a compatible wallet with {wallet}.
|
|
157
157
|
</Alert>
|
|
158
158
|
</AlertContainer>
|
|
159
159
|
{isExperimentalChain?.(wallet) && (
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Spinner } from '../../components';
|
|
3
3
|
import { SecondaryPage } from '../../components/SecondaryPage';
|
|
4
|
-
import { SwapDetail } from '../../components/SwapDetail';
|
|
5
|
-
import { Typography } from '../../components/Typography';
|
|
6
4
|
import { containsText } from '../../helper';
|
|
7
5
|
import { styled } from '../../theme';
|
|
8
6
|
import { PendingSwap } from './types';
|
|
9
7
|
import { NotFoundAlert } from '../../components/Alert/NotFoundAlert';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
'.group-title': {
|
|
13
|
-
textTransform: 'uppercase',
|
|
14
|
-
},
|
|
15
|
-
});
|
|
8
|
+
import { LoaderContainer } from '../../components/TokenSelector/TokenSelector';
|
|
9
|
+
import { SwapsGroup, PropTypes as SwapsGroupPropTypes } from './SwapsGroup';
|
|
16
10
|
|
|
17
11
|
const Container = styled('div', {
|
|
18
12
|
overflowY: 'auto',
|
|
@@ -34,80 +28,43 @@ const filteredHistory = (
|
|
|
34
28
|
});
|
|
35
29
|
};
|
|
36
30
|
|
|
37
|
-
export type
|
|
38
|
-
title: string;
|
|
39
|
-
swaps: PendingSwap[];
|
|
40
|
-
}[];
|
|
41
|
-
export interface PropTypes {
|
|
42
|
-
list: PendingSwap[];
|
|
43
|
-
onBack: () => void;
|
|
44
|
-
onSwapClick: (requestId: string) => void;
|
|
45
|
-
groupBy?: GroupBy;
|
|
46
|
-
}
|
|
47
|
-
const SwapsGroup = (props: Omit<PropTypes, 'onBack'>) => {
|
|
48
|
-
const { list, onSwapClick, groupBy } = props;
|
|
49
|
-
const groups = groupBy ? groupBy(list) : [{ title: 'History', swaps: list }];
|
|
31
|
+
export type PropTypes = SwapsGroupPropTypes & { loading: boolean };
|
|
50
32
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
{groups
|
|
54
|
-
.filter((group) => group.swaps.length > 0)
|
|
55
|
-
.map((group, index) => (
|
|
56
|
-
<>
|
|
57
|
-
<Group key={index}>
|
|
58
|
-
<Typography
|
|
59
|
-
variant="body2"
|
|
60
|
-
color="neutrals600"
|
|
61
|
-
className="group-title"
|
|
62
|
-
>
|
|
63
|
-
{group.title}
|
|
64
|
-
</Typography>
|
|
65
|
-
{group.swaps.map((swap: PendingSwap, index: number) => (
|
|
66
|
-
<>
|
|
67
|
-
<SwapDetail
|
|
68
|
-
key={index}
|
|
69
|
-
swap={swap}
|
|
70
|
-
status={swap.status}
|
|
71
|
-
onClick={onSwapClick}
|
|
72
|
-
/>
|
|
73
|
-
<Divider size={12} />
|
|
74
|
-
</>
|
|
75
|
-
))}
|
|
76
|
-
</Group>
|
|
77
|
-
<Divider size={24} />
|
|
78
|
-
</>
|
|
79
|
-
))}
|
|
80
|
-
</>
|
|
81
|
-
);
|
|
82
|
-
};
|
|
33
|
+
export function History(props: PropsWithChildren<PropTypes>) {
|
|
34
|
+
const { list = [], onBack, onSwapClick, groupBy, loading } = props;
|
|
83
35
|
|
|
84
|
-
export function History({
|
|
85
|
-
list = [],
|
|
86
|
-
onBack,
|
|
87
|
-
onSwapClick,
|
|
88
|
-
groupBy,
|
|
89
|
-
}: PropsWithChildren<PropTypes>) {
|
|
90
36
|
return (
|
|
91
37
|
<SecondaryPage
|
|
92
38
|
onBack={onBack}
|
|
93
39
|
textField={true}
|
|
94
|
-
textFieldPlaceholder="Search
|
|
40
|
+
textFieldPlaceholder="Search by Network, Token or Request ID"
|
|
95
41
|
title="Swaps"
|
|
96
42
|
>
|
|
97
43
|
{(searchedFor) => {
|
|
98
44
|
const filterSwaps = filteredHistory(list, searchedFor);
|
|
99
45
|
return (
|
|
100
|
-
|
|
101
|
-
{
|
|
102
|
-
<
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
groupBy={groupBy}
|
|
106
|
-
/>
|
|
107
|
-
) : (
|
|
108
|
-
<NotFoundAlert catergory="Swap" />
|
|
46
|
+
<>
|
|
47
|
+
{loading && (
|
|
48
|
+
<LoaderContainer>
|
|
49
|
+
<Spinner size={24} />
|
|
50
|
+
</LoaderContainer>
|
|
109
51
|
)}
|
|
110
|
-
|
|
52
|
+
<Container>
|
|
53
|
+
{!loading && (
|
|
54
|
+
<>
|
|
55
|
+
{filterSwaps.length ? (
|
|
56
|
+
<SwapsGroup
|
|
57
|
+
list={filterSwaps}
|
|
58
|
+
onSwapClick={onSwapClick}
|
|
59
|
+
groupBy={groupBy}
|
|
60
|
+
/>
|
|
61
|
+
) : (
|
|
62
|
+
<NotFoundAlert catergory="Swap" />
|
|
63
|
+
)}
|
|
64
|
+
</>
|
|
65
|
+
)}
|
|
66
|
+
</Container>
|
|
67
|
+
</>
|
|
111
68
|
);
|
|
112
69
|
}}
|
|
113
70
|
</SecondaryPage>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { PendingSwap } from '@rango-dev/queue-manager-rango-preset';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Typography, SwapDetail, Divider } from '../../components';
|
|
4
|
+
import { styled } from '../../theme';
|
|
5
|
+
|
|
6
|
+
const Group = styled('div', {
|
|
7
|
+
'.group-title': {
|
|
8
|
+
textTransform: 'uppercase',
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export type GroupBy = (list: PendingSwap[]) => {
|
|
13
|
+
title: string;
|
|
14
|
+
swaps: PendingSwap[];
|
|
15
|
+
}[];
|
|
16
|
+
|
|
17
|
+
export interface PropTypes {
|
|
18
|
+
list: PendingSwap[];
|
|
19
|
+
onBack: () => void;
|
|
20
|
+
onSwapClick: (requestId: string) => void;
|
|
21
|
+
groupBy?: GroupBy;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function SwapsGroup(props: Omit<PropTypes, 'onBack'>) {
|
|
25
|
+
const { list, onSwapClick, groupBy } = props;
|
|
26
|
+
const groups = groupBy ? groupBy(list) : [{ title: 'History', swaps: list }];
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<>
|
|
30
|
+
{groups
|
|
31
|
+
.filter((group) => group.swaps.length > 0)
|
|
32
|
+
.map((group, index) => (
|
|
33
|
+
<>
|
|
34
|
+
<Group key={index}>
|
|
35
|
+
<Typography
|
|
36
|
+
variant="body2"
|
|
37
|
+
color="neutrals600"
|
|
38
|
+
className="group-title"
|
|
39
|
+
>
|
|
40
|
+
{group.title}
|
|
41
|
+
</Typography>
|
|
42
|
+
{group.swaps.map((swap: PendingSwap, index: number) => (
|
|
43
|
+
<>
|
|
44
|
+
<SwapDetail
|
|
45
|
+
key={index}
|
|
46
|
+
swap={swap}
|
|
47
|
+
status={swap.status}
|
|
48
|
+
onClick={onSwapClick}
|
|
49
|
+
/>
|
|
50
|
+
<Divider size={12} />
|
|
51
|
+
</>
|
|
52
|
+
))}
|
|
53
|
+
</Group>
|
|
54
|
+
<Divider size={24} />
|
|
55
|
+
</>
|
|
56
|
+
))}
|
|
57
|
+
</>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { History
|
|
1
|
+
export { History } from './History';
|
|
2
|
+
export { SwapsGroup, GroupBy } from './SwapsGroup';
|