@rango-dev/widget-embedded 0.10.0 → 0.10.1-next.0

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 (33) hide show
  1. package/dist/components/Layout.d.ts.map +1 -1
  2. package/dist/components/SwitchFromAndTo.d.ts +2 -3
  3. package/dist/components/SwitchFromAndTo.d.ts.map +1 -1
  4. package/dist/index.js +1 -1
  5. package/dist/index.js.map +4 -4
  6. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  7. package/dist/pages/Home.d.ts.map +1 -1
  8. package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
  9. package/dist/utils/numbers.d.ts.map +1 -1
  10. package/package.json +2 -2
  11. package/src/components/Layout.tsx +12 -65
  12. package/src/components/SwitchFromAndTo.tsx +34 -4
  13. package/src/pages/ConfirmSwapPage.tsx +20 -9
  14. package/src/pages/Home.tsx +101 -144
  15. package/src/pages/SwapDetailsPage.tsx +5 -2
  16. package/src/utils/numbers.ts +2 -0
  17. package/dist/components/PercentageChange.d.ts +0 -9
  18. package/dist/components/PercentageChange.d.ts.map +0 -1
  19. package/dist/components/RoutesOverview.d.ts +0 -120
  20. package/dist/components/RoutesOverview.d.ts.map +0 -1
  21. package/dist/components/SwapDetailsPlaceholder.d.ts +0 -120
  22. package/dist/components/SwapDetailsPlaceholder.d.ts.map +0 -1
  23. package/dist/components/TokenInfo.d.ts +0 -18
  24. package/dist/components/TokenInfo.d.ts.map +0 -1
  25. package/dist/components/TokenPreview.d.ts +0 -21
  26. package/dist/components/TokenPreview.d.ts.map +0 -1
  27. package/src/components/PercentageChange.tsx +0 -33
  28. package/src/components/RoutesOverview.tsx +0 -57
  29. package/src/components/SwapDetailsPlaceholder.tsx +0 -47
  30. package/src/components/TokenInfo.tsx +0 -329
  31. package/src/components/TokenPreview.tsx +0 -187
  32. package/src/languages/en.json +0 -14
  33. package/src/languages/tr.json +0 -11
@@ -1,329 +0,0 @@
1
- import React from 'react';
2
- import {
3
- AngleDownIcon,
4
- Button,
5
- InfoCircleIcon,
6
- styled,
7
- TextField,
8
- Typography,
9
- Image,
10
- Divider,
11
- } from '@rango-dev/ui';
12
- import { useMetaStore } from '../store/meta';
13
- import { BlockchainMeta, Token } from 'rango-sdk';
14
- import { useNavigate } from 'react-router-dom';
15
- import { useBestRouteStore } from '../store/bestRoute';
16
- import { numberToString } from '../utils/numbers';
17
- import BigNumber from 'bignumber.js';
18
- import { getBalanceFromWallet } from '../utils/wallets';
19
- import { useWalletsStore } from '../store/wallets';
20
- import { Trans } from '@lingui/react';
21
- import { i18n } from '@lingui/core';
22
- import { PercentageChange } from './PercentageChange';
23
-
24
- type PropTypes = (
25
- | {
26
- type: 'From';
27
- inputAmount: string;
28
- onAmountChange: (amount: string) => void;
29
- }
30
- | {
31
- type: 'To';
32
- outputAmount: BigNumber | null;
33
- outputUsdValue: BigNumber | null;
34
- }
35
- ) & { chain: BlockchainMeta | null; token: Token | null };
36
-
37
- const Box = styled('div', {
38
- display: 'flex',
39
- flexDirection: 'column',
40
- width: '100%',
41
- overflow: 'hidden',
42
- });
43
-
44
- const Container = styled('div', {
45
- boxSizing: 'border-box',
46
- borderRadius: '$5',
47
- padding: '$8 $16 $16 $16',
48
-
49
- variants: {
50
- type: {
51
- filled: {
52
- backgroundColor: '$neutral100',
53
- },
54
- outlined: {
55
- border: '1px solid $neutral100',
56
- backgroundColor: '$surface',
57
- },
58
- },
59
- },
60
-
61
- defaultVariants: {
62
- type: 'filled',
63
- },
64
-
65
- '.head': {
66
- display: 'flex',
67
- justifyContent: 'space-between',
68
- alignItems: 'center',
69
- minHeight: '32px',
70
- },
71
- '.form': {
72
- display: 'flex',
73
- width: '100%',
74
- padding: '$2 0',
75
- '.selectors': {
76
- width: '35%',
77
-
78
- '._text': {
79
- whiteSpace: 'nowrap',
80
- overflow: 'hidden',
81
- textOverflow: 'ellipsis',
82
- },
83
- },
84
- '.amount': {
85
- width: '30%',
86
- },
87
- },
88
- '.output-usd': {
89
- display: 'flex',
90
- div: {
91
- display: 'flex',
92
- paddingLeft: '$8',
93
- },
94
- },
95
- });
96
-
97
- const Options = styled('div', {
98
- display: 'flex',
99
- justifyContent: 'flex-end',
100
-
101
- '.balance': {
102
- display: 'flex',
103
- alignItems: 'center',
104
- },
105
- });
106
-
107
- const ImagePlaceholder = styled('span', {
108
- width: '24px',
109
- height: '24px',
110
- backgroundColor: '$neutral100',
111
- borderRadius: '99999px',
112
- });
113
-
114
- const OutputContainer = styled('div', {
115
- windth: '100%',
116
- height: '$48',
117
- borderRadius: '$5',
118
- backgroundColor: '$surface',
119
- border: '1px solid transparent',
120
- position: 'relative',
121
- display: 'flex',
122
- alignItems: 'center',
123
- paddingLeft: '$8',
124
- paddingRight: '$8',
125
- });
126
-
127
- export function TokenInfo(props: PropTypes) {
128
- const { type, chain, token } = props;
129
- const loadingStatus = useMetaStore.use.loadingStatus();
130
- const fromChain = useBestRouteStore.use.fromChain();
131
- const toChain = useBestRouteStore.use.toChain();
132
- const inputUsdValue = useBestRouteStore.use.inputUsdValue();
133
- const fromToken = useBestRouteStore.use.fromToken();
134
- const setInputAmount = useBestRouteStore.use.setInputAmount();
135
- const bestRoute = useBestRouteStore.use.bestRoute();
136
- const inputAmount = useBestRouteStore.use.inputAmount();
137
- const connectedWallets = useWalletsStore.use.connectedWallets();
138
- const fetchingBestRoute = useBestRouteStore.use.loading();
139
- const navigate = useNavigate();
140
-
141
- const tokenBalance =
142
- !!fromChain && !!fromToken
143
- ? numberToString(
144
- getBalanceFromWallet(
145
- connectedWallets,
146
- fromChain?.name,
147
- fromToken?.symbol,
148
- fromToken?.address
149
- )?.amount || '0',
150
- 8
151
- )
152
- : '0';
153
-
154
- const tokenBalanceReal =
155
- !!fromChain && !!fromToken
156
- ? numberToString(
157
- getBalanceFromWallet(
158
- connectedWallets,
159
- fromChain?.name,
160
- fromToken?.symbol,
161
- fromToken?.address
162
- )?.amount || '0',
163
- getBalanceFromWallet(
164
- connectedWallets,
165
- fromChain?.name,
166
- fromToken?.symbol,
167
- fromToken?.address
168
- )?.decimal
169
- )
170
- : '0';
171
-
172
- const ItemSuffix = (
173
- <div
174
- style={{
175
- display: 'flex',
176
- justifyContent: 'center',
177
- alignItems: 'center',
178
- }}>
179
- {loadingStatus === 'failed' && <InfoCircleIcon color="error" size={24} />}
180
- <AngleDownIcon />
181
- </div>
182
- );
183
-
184
- return (
185
- <Box>
186
- <Container type={props.type === 'From' ? 'filled' : 'outlined'}>
187
- <div className="head">
188
- <Typography variant="body2" color="neutral800">
189
- {type === 'From' ? (
190
- <Trans id="swap from" message="From" />
191
- ) : (
192
- <Trans id="swap to" message="To" />
193
- )}
194
- </Typography>
195
- {props.type === 'From' ? (
196
- <Options>
197
- <div
198
- className="balance"
199
- onClick={() => {
200
- if (tokenBalance !== '0')
201
- setInputAmount(tokenBalanceReal.split(',').join(''));
202
- }}>
203
- <Typography variant="body3" color="neutral600">
204
- {i18n.t('Balance')}: {tokenBalance} {fromToken?.symbol || ''}
205
- </Typography>
206
- <Divider size={4} />
207
- <Button type="primary" variant="ghost" size="compact">
208
- <Trans id="maximum amount of asset" message="Max" />
209
- </Button>
210
- </div>
211
- </Options>
212
- ) : (
213
- <div className="output-usd">
214
- <PercentageChange
215
- inputUsdValue={inputUsdValue}
216
- outputUsdValue={props.outputUsdValue}
217
- />
218
- <div>
219
- <Typography
220
- variant="caption"
221
- color="neutral600">{`$${numberToString(
222
- props.outputUsdValue
223
- )}`}</Typography>
224
- </div>
225
- </div>
226
- )}
227
- </div>
228
- <div className="form">
229
- <Button
230
- className="selectors"
231
- onClick={() => {
232
- navigate(`${props.type.toLowerCase()}-chain`);
233
- }}
234
- variant="outlined"
235
- disabled={loadingStatus === 'failed'}
236
- loading={loadingStatus === 'loading'}
237
- prefix={
238
- loadingStatus === 'success' && chain ? (
239
- <Image src={chain.logo} size={24} />
240
- ) : (
241
- <ImagePlaceholder />
242
- )
243
- }
244
- suffix={ItemSuffix}
245
- align="start"
246
- size="large">
247
- {loadingStatus === 'success' && chain
248
- ? chain.displayName
249
- : i18n.t('Chain')}
250
- </Button>
251
- <Divider size={12} direction="horizontal" />
252
- <Button
253
- className="selectors"
254
- onClick={() => {
255
- navigate(`${props.type.toLowerCase()}-token`);
256
- }}
257
- variant="outlined"
258
- disabled={
259
- loadingStatus === 'failed' ||
260
- (type === 'From' && !fromChain) ||
261
- (type === 'To' && !toChain)
262
- }
263
- loading={loadingStatus === 'loading'}
264
- prefix={
265
- loadingStatus === 'success' && token ? (
266
- <Image src={token.image} size={24} />
267
- ) : (
268
- <ImagePlaceholder />
269
- )
270
- }
271
- suffix={ItemSuffix}
272
- size="large"
273
- align="start">
274
- {loadingStatus === 'success' && token
275
- ? token.symbol
276
- : i18n.t('Token')}
277
- </Button>
278
- <Divider size={12} direction="horizontal" />
279
- <div className="amount">
280
- {props.type === 'From' ? (
281
- <TextField
282
- type="number"
283
- size="large"
284
- autoFocus
285
- placeholder="0"
286
- style={{
287
- position: 'relative',
288
- backgroundColor: '$background !important',
289
- }}
290
- suffix={
291
- <span
292
- style={{
293
- position: 'absolute',
294
- right: '4px',
295
- bottom: '2px',
296
- }}>
297
- <Typography
298
- variant="caption"
299
- color="neutral800">{`$${numberToString(
300
- inputUsdValue
301
- )}`}</Typography>
302
- </span>
303
- }
304
- value={props.inputAmount || ''}
305
- min={0}
306
- onChange={
307
- props.type === 'From'
308
- ? (event) => {
309
- props.onAmountChange(event.target.value);
310
- }
311
- : undefined
312
- }
313
- />
314
- ) : (
315
- <OutputContainer>
316
- <Typography variant="h4">
317
- {fetchingBestRoute && '?'}
318
- {!!bestRoute?.result &&
319
- `≈ ${numberToString(props.outputAmount)}`}
320
- {(!inputAmount || inputAmount === '0') && '0'}
321
- </Typography>
322
- </OutputContainer>
323
- )}
324
- </div>
325
- </div>
326
- </Container>
327
- </Box>
328
- );
329
- }
@@ -1,187 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import {
3
- Button,
4
- InfoCircleIcon,
5
- styled,
6
- Typography,
7
- Divider,
8
- Image,
9
- } from '@rango-dev/ui';
10
- import { LoadingStatus } from '../store/meta';
11
- import { i18n } from '@lingui/core';
12
- import BigNumber from 'bignumber.js';
13
- import { numberToString } from '../utils/numbers';
14
-
15
- const Box = styled('div', {
16
- display: 'flex',
17
- flexDirection: 'column',
18
- width: '100%',
19
- overflow: 'hidden',
20
- });
21
-
22
- const Container = styled('div', {
23
- boxSizing: 'border-box',
24
- borderRadius: '$5',
25
- padding: '$8 $16 $16 $16',
26
-
27
- variants: {
28
- type: {
29
- filled: {
30
- backgroundColor: '$neutral100',
31
- },
32
- outlined: {
33
- border: '1px solid $neutral100',
34
- },
35
- },
36
- },
37
-
38
- defaultVariants: {
39
- type: 'filled',
40
- },
41
-
42
- '.head': {
43
- display: 'flex',
44
- justifyContent: 'space-between',
45
- alignItems: 'center',
46
- minHeight: '32px',
47
- '.usd-value': {
48
- paddingLeft: '$8',
49
- },
50
- },
51
- '.form': {
52
- display: 'flex',
53
- width: '100%',
54
- padding: '$2 0',
55
- '.selectors': {
56
- width: '35%',
57
-
58
- '._text': {
59
- whiteSpace: 'nowrap',
60
- overflow: 'hidden',
61
- textOverflow: 'ellipsis',
62
- },
63
- },
64
- '.amount': {
65
- width: '30%',
66
- },
67
- },
68
- });
69
-
70
- const ImagePlaceholder = styled('span', {
71
- width: '24px',
72
- height: '24px',
73
- backgroundColor: '$neutral100',
74
- borderRadius: '99999px',
75
- });
76
-
77
- const OutputContainer = styled('div', {
78
- windth: '100%',
79
- height: '$48',
80
- borderRadius: '$5',
81
- backgroundColor: '$surface',
82
- border: '1px solid transparent',
83
- position: 'relative',
84
- display: 'flex',
85
- alignItems: 'center',
86
- paddingLeft: '$8',
87
- paddingRight: '$8',
88
- });
89
-
90
- interface PropTypes {
91
- label: string;
92
- amount: string;
93
- usdValue: BigNumber | null;
94
- loadingStatus: LoadingStatus;
95
- chain: {
96
- displayName: string;
97
- logo: string;
98
- };
99
- token: {
100
- symbol: string;
101
- image: string;
102
- };
103
- percentageChange?: ReactNode;
104
- }
105
-
106
- export function TokenPreview(props: PropTypes) {
107
- const { chain, token, loadingStatus, percentageChange } = props;
108
-
109
- const ItemSuffix = (
110
- <div
111
- style={{
112
- display: 'flex',
113
- justifyContent: 'center',
114
- alignItems: 'center',
115
- }}>
116
- {loadingStatus === 'failed' && <InfoCircleIcon color="error" size={24} />}
117
- </div>
118
- );
119
-
120
- return (
121
- <Box>
122
- <Container type={'outlined'}>
123
- <div className="head">
124
- <Typography variant="body2" color="neutral800">
125
- {props.label}
126
- </Typography>
127
- <div>
128
- {percentageChange}
129
- {props.usdValue && (
130
- <Typography
131
- variant="caption"
132
- color="neutral600"
133
- className="usd-value">{`$${numberToString(
134
- props.usdValue
135
- )}`}</Typography>
136
- )}
137
- </div>
138
- </div>
139
- <div className="form">
140
- <Button
141
- className="selectors"
142
- variant="outlined"
143
- loading={loadingStatus === 'loading'}
144
- prefix={
145
- loadingStatus === 'success' && chain ? (
146
- <Image src={chain.logo} size={24} />
147
- ) : (
148
- <ImagePlaceholder />
149
- )
150
- }
151
- suffix={ItemSuffix}
152
- align="start"
153
- size="large">
154
- {loadingStatus === 'success' && chain
155
- ? chain.displayName
156
- : i18n.t('Chain')}
157
- </Button>
158
- <Divider size={12} direction="horizontal" />
159
- <Button
160
- className="selectors"
161
- variant="outlined"
162
- loading={loadingStatus === 'loading'}
163
- prefix={
164
- loadingStatus === 'success' && token ? (
165
- <Image src={token.image} size={24} />
166
- ) : (
167
- <ImagePlaceholder />
168
- )
169
- }
170
- suffix={ItemSuffix}
171
- size="large"
172
- align="start">
173
- {loadingStatus === 'success' && token
174
- ? token.symbol
175
- : i18n.t('Token')}
176
- </Button>
177
- <Divider size={12} direction="horizontal" />
178
- <div className="amount">
179
- <OutputContainer>
180
- <Typography variant="h4">{props.amount}</Typography>
181
- </OutputContainer>
182
- </div>
183
- </div>
184
- </Container>
185
- </Box>
186
- );
187
- }
@@ -1,14 +0,0 @@
1
- {
2
- "swap": "SWAP",
3
- "Connect Wallet": "Connect Wallet",
4
- "Powered By": "Powered By",
5
- "From": "You sell",
6
- "To": "You receive",
7
- "Balance": "Balance",
8
- "Max": "Max",
9
- "Chain": "Chain",
10
- "Token": "Token",
11
- "Source": "Source",
12
- "Destination": "Destination",
13
- "Select Wallet": "Connect Your Wallet"
14
- }
@@ -1,11 +0,0 @@
1
- {
2
- "swap": "TAKAS",
3
- "Select Wallet":"Cüzdan Seç",
4
- "Powered By" :"Tarafından desteklenmektedir",
5
- "Connect Wallet":"Cüzdanı Bağla",
6
- "From":"İtibaren",
7
- "To":"İle",
8
- "Max":"maks.",
9
- "Chain": "Zincir",
10
- "Token": "Jeton"
11
- }