@rango-dev/ui 0.1.10 → 0.1.11-next.3
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/Modal/Modal.d.ts +0 -1
- package/dist/components/TokenList/TokenList.d.ts +2 -2
- package/dist/components/TokenSelector/TokenSelector.d.ts +1 -3
- package/dist/helper/index.d.ts +3 -2
- package/dist/ui.cjs.development.js +49 -48
- 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 +49 -48
- package/dist/ui.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Modal/Modal.tsx +1 -6
- package/src/components/SwapDetail/SwapDetail.tsx +7 -5
- package/src/components/SwapDetail/Token.tsx +1 -0
- package/src/components/TokenList/TokenList.tsx +2 -3
- package/src/components/TokenSelector/TokenSelector.tsx +23 -47
- package/src/containers/SwapHistory/SwapHistory.tsx +8 -4
- package/src/helper/index.ts +20 -5
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
# @rango-dev/ui
|
|
1
|
+
# @rango-dev/ui
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Token } from 'rango-sdk';
|
|
2
|
+
import { Asset, Token } from 'rango-sdk';
|
|
3
3
|
export interface TokenWithAmount extends Token {
|
|
4
4
|
balance?: {
|
|
5
5
|
amount: string;
|
|
@@ -12,6 +12,6 @@ export interface PropTypes {
|
|
|
12
12
|
searchedText: string;
|
|
13
13
|
onChange: (token: TokenWithAmount) => void;
|
|
14
14
|
multiSelect?: boolean;
|
|
15
|
-
selectedList?:
|
|
15
|
+
selectedList?: Asset[];
|
|
16
16
|
}
|
|
17
17
|
export declare function TokenList(props: PropTypes): JSX.Element;
|
|
@@ -7,10 +7,8 @@ export interface PropTypes {
|
|
|
7
7
|
type?: 'Source' | 'Destination';
|
|
8
8
|
selected: TokenWithAmount | null;
|
|
9
9
|
onChange: (token: TokenWithAmount) => void;
|
|
10
|
-
hasHeader?: boolean;
|
|
11
|
-
multiSelect?: boolean;
|
|
12
10
|
onBack?: () => void;
|
|
13
|
-
selectedList?: TokenWithAmount[] | 'all';
|
|
14
11
|
loadingStatus: LoadingStatus;
|
|
12
|
+
hasHeader?: boolean;
|
|
15
13
|
}
|
|
16
14
|
export declare function TokenSelector(props: PropTypes): JSX.Element;
|
package/dist/helper/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
export declare
|
|
1
|
+
export declare function containsText(text: string, searchText: string): boolean;
|
|
2
|
+
export declare function getConciseAddress(address: string | null, maxChars?: number, ellipsisLength?: number): string | null;
|
|
3
|
+
export declare function limitDecimalPlaces(numberString: string, maxDecimalPlaces?: number): string;
|
|
@@ -2735,10 +2735,10 @@ function SecondaryPage(props) {
|
|
|
2735
2735
|
})), props.textField && (props.children == null ? void 0 : props.children(searchedFor)), !props.textField && props.children), Footer);
|
|
2736
2736
|
}
|
|
2737
2737
|
|
|
2738
|
-
|
|
2738
|
+
function containsText(text, searchText) {
|
|
2739
2739
|
return text.toLowerCase().indexOf(searchText.toLowerCase()) > -1;
|
|
2740
|
-
}
|
|
2741
|
-
|
|
2740
|
+
}
|
|
2741
|
+
function getConciseAddress(address, maxChars, ellipsisLength) {
|
|
2742
2742
|
if (maxChars === void 0) {
|
|
2743
2743
|
maxChars = 8;
|
|
2744
2744
|
}
|
|
@@ -2750,7 +2750,19 @@ var getConciseAddress = function getConciseAddress(address, maxChars, ellipsisLe
|
|
|
2750
2750
|
var start = Math.ceil((address.length - maxChars) / 2);
|
|
2751
2751
|
var end = address.length - maxChars;
|
|
2752
2752
|
return "" + address.substr(start, maxChars) + '.'.repeat(ellipsisLength) + address.substr(end);
|
|
2753
|
-
}
|
|
2753
|
+
}
|
|
2754
|
+
function limitDecimalPlaces(numberString, maxDecimalPlaces) {
|
|
2755
|
+
if (maxDecimalPlaces === void 0) {
|
|
2756
|
+
maxDecimalPlaces = 4;
|
|
2757
|
+
}
|
|
2758
|
+
var number = parseFloat(numberString);
|
|
2759
|
+
if (isNaN(number)) return numberString; // Return the original string if it's not a valid number
|
|
2760
|
+
else {
|
|
2761
|
+
var multiplier = Math.pow(10, maxDecimalPlaces);
|
|
2762
|
+
var roundedNumber = Math.round(number * multiplier) / multiplier;
|
|
2763
|
+
return roundedNumber.toString();
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2754
2766
|
|
|
2755
2767
|
var SpacerContainer = /*#__PURE__*/styled('div', {
|
|
2756
2768
|
variants: {
|
|
@@ -3077,7 +3089,7 @@ function TokenList(props) {
|
|
|
3077
3089
|
};
|
|
3078
3090
|
var isSelected = function isSelected(token) {
|
|
3079
3091
|
if (multiSelect && selectedList) {
|
|
3080
|
-
return selectedList
|
|
3092
|
+
return selectedList.map(function (item) {
|
|
3081
3093
|
return item.symbol + item.address;
|
|
3082
3094
|
}).indexOf(token.symbol + token.address) > -1;
|
|
3083
3095
|
}
|
|
@@ -3128,15 +3140,12 @@ function TokenList(props) {
|
|
|
3128
3140
|
});
|
|
3129
3141
|
}
|
|
3130
3142
|
|
|
3131
|
-
var Container$1 = /*#__PURE__*/styled('div', {
|
|
3132
|
-
flex: '1'
|
|
3133
|
-
});
|
|
3134
3143
|
var LoaderContainer = /*#__PURE__*/styled('div', {
|
|
3135
3144
|
display: 'flex',
|
|
3136
3145
|
justifyContent: 'center',
|
|
3137
3146
|
width: '100%',
|
|
3138
|
-
|
|
3139
|
-
|
|
3147
|
+
paddingTop: '5%',
|
|
3148
|
+
flex: 1
|
|
3140
3149
|
});
|
|
3141
3150
|
var filterTokens = function filterTokens(list, searchedFor) {
|
|
3142
3151
|
return list.filter(function (token) {
|
|
@@ -3147,33 +3156,29 @@ function TokenSelector(props) {
|
|
|
3147
3156
|
var list = props.list,
|
|
3148
3157
|
type = props.type,
|
|
3149
3158
|
selected = props.selected,
|
|
3150
|
-
onChange = props.onChange,
|
|
3151
3159
|
hasHeader = props.hasHeader,
|
|
3152
|
-
|
|
3153
|
-
selectedList = props.selectedList,
|
|
3160
|
+
onChange = props.onChange,
|
|
3154
3161
|
onBack = props.onBack,
|
|
3155
3162
|
loadingStatus = props.loadingStatus;
|
|
3156
3163
|
return React__default.createElement(SecondaryPage, {
|
|
3157
3164
|
textField: true,
|
|
3158
|
-
textFieldPlaceholder: "Search Blockchain By Name",
|
|
3159
|
-
title: "Select " + type + " Token",
|
|
3160
3165
|
hasHeader: hasHeader,
|
|
3161
|
-
|
|
3166
|
+
title: "Select " + type + " Token",
|
|
3167
|
+
onBack: onBack,
|
|
3168
|
+
textFieldPlaceholder: "Search Token By Name"
|
|
3162
3169
|
}, function (searchedFor) {
|
|
3163
3170
|
var filteredTokens = filterTokens(list, searchedFor);
|
|
3164
|
-
return
|
|
3171
|
+
return loadingStatus === 'loading' ? React__default.createElement(LoaderContainer, null, React__default.createElement(Spinner, {
|
|
3165
3172
|
size: 24
|
|
3166
|
-
}))
|
|
3173
|
+
})) : loadingStatus === 'failed' ? React__default.createElement(LoadingFailedAlert, null) : filteredTokens.length ? React__default.createElement(TokenList, {
|
|
3167
3174
|
searchedText: searchedFor,
|
|
3168
3175
|
list: filteredTokens,
|
|
3169
3176
|
selected: selected,
|
|
3170
|
-
selectedList: selectedList,
|
|
3171
|
-
multiSelect: multiSelect,
|
|
3172
3177
|
onChange: onChange
|
|
3173
3178
|
}) : React__default.createElement(NotFoundAlert, {
|
|
3174
3179
|
catergory: "Token",
|
|
3175
3180
|
searchedFor: searchedFor
|
|
3176
|
-
})
|
|
3181
|
+
});
|
|
3177
3182
|
});
|
|
3178
3183
|
}
|
|
3179
3184
|
|
|
@@ -3330,15 +3335,13 @@ var ModalHeader = /*#__PURE__*/styled('div', {
|
|
|
3330
3335
|
position: 'relative',
|
|
3331
3336
|
marginBottom: '$16'
|
|
3332
3337
|
});
|
|
3333
|
-
var ContentContainer$1 = /*#__PURE__*/styled('div', {});
|
|
3334
3338
|
function Modal(props) {
|
|
3335
3339
|
var title = props.title,
|
|
3336
3340
|
content = props.content,
|
|
3337
3341
|
open = props.open,
|
|
3338
3342
|
onClose = props.onClose,
|
|
3339
3343
|
containerStyle = props.containerStyle,
|
|
3340
|
-
action = props.action
|
|
3341
|
-
contentStyle = props.contentStyle;
|
|
3344
|
+
action = props.action;
|
|
3342
3345
|
var handleBackDropClick = function handleBackDropClick(event) {
|
|
3343
3346
|
if (event.target === event.currentTarget) onClose();
|
|
3344
3347
|
};
|
|
@@ -3354,9 +3357,7 @@ function Modal(props) {
|
|
|
3354
3357
|
}, title), React__default.createElement(Row, null, action, React__default.createElement(CloseIcon, {
|
|
3355
3358
|
size: 24,
|
|
3356
3359
|
onClick: onClose
|
|
3357
|
-
}))),
|
|
3358
|
-
style: contentStyle
|
|
3359
|
-
}, content))), document.body));
|
|
3360
|
+
}))), content)), document.body));
|
|
3360
3361
|
}
|
|
3361
3362
|
|
|
3362
3363
|
(function (WalletState) {
|
|
@@ -3733,7 +3734,7 @@ var SolidCircle = /*#__PURE__*/styled('div', {
|
|
|
3733
3734
|
}
|
|
3734
3735
|
}
|
|
3735
3736
|
});
|
|
3736
|
-
var Container$
|
|
3737
|
+
var Container$1 = /*#__PURE__*/styled('div', {
|
|
3737
3738
|
border: '1.5px solid',
|
|
3738
3739
|
borderRadius: '$5',
|
|
3739
3740
|
padding: '$12',
|
|
@@ -3780,7 +3781,7 @@ function SelectableWalletList(_ref) {
|
|
|
3780
3781
|
}, [list]);
|
|
3781
3782
|
return React__default.createElement(Row$1, null, list.map(function (w, index) {
|
|
3782
3783
|
var checked = active === w.walletType;
|
|
3783
|
-
return React__default.createElement(Container$
|
|
3784
|
+
return React__default.createElement(Container$1, {
|
|
3784
3785
|
checked: checked,
|
|
3785
3786
|
onClick: onClick.bind(null, w),
|
|
3786
3787
|
key: index
|
|
@@ -3833,7 +3834,7 @@ var StyledItem = /*#__PURE__*/styled(RadioGroup.Item, {
|
|
|
3833
3834
|
borderColor: '$neutrals600'
|
|
3834
3835
|
}
|
|
3835
3836
|
});
|
|
3836
|
-
var Container$
|
|
3837
|
+
var Container$2 = /*#__PURE__*/styled('div', {
|
|
3837
3838
|
display: 'flex'
|
|
3838
3839
|
});
|
|
3839
3840
|
var StyledIndicator = /*#__PURE__*/styled(RadioGroup.Indicator, {
|
|
@@ -3863,7 +3864,7 @@ function Radio(props) {
|
|
|
3863
3864
|
_props$direction = props.direction,
|
|
3864
3865
|
direction = _props$direction === void 0 ? 'vertical' : _props$direction,
|
|
3865
3866
|
style = props.style;
|
|
3866
|
-
return React__default.createElement(Container$
|
|
3867
|
+
return React__default.createElement(Container$2, null, React__default.createElement(StyledRoot, {
|
|
3867
3868
|
onValueChange: onChange,
|
|
3868
3869
|
value: value,
|
|
3869
3870
|
direction: direction,
|
|
@@ -4068,6 +4069,7 @@ function SwapContainer(props) {
|
|
|
4068
4069
|
var TokenContainer = /*#__PURE__*/styled('div', {
|
|
4069
4070
|
display: 'flex',
|
|
4070
4071
|
alignItems: 'center',
|
|
4072
|
+
width: '160px',
|
|
4071
4073
|
'& .amount': {
|
|
4072
4074
|
fontWeight: 'bold'
|
|
4073
4075
|
}
|
|
@@ -4110,7 +4112,7 @@ function Token(props) {
|
|
|
4110
4112
|
}), props.data.token.symbol);
|
|
4111
4113
|
}
|
|
4112
4114
|
|
|
4113
|
-
var Container$
|
|
4115
|
+
var Container$3 = /*#__PURE__*/styled('div', {
|
|
4114
4116
|
position: 'relative',
|
|
4115
4117
|
display: 'flex',
|
|
4116
4118
|
justifyContent: 'space-between',
|
|
@@ -4150,7 +4152,7 @@ function SwapDetail(_ref) {
|
|
|
4150
4152
|
size: "free",
|
|
4151
4153
|
fullWidth: true,
|
|
4152
4154
|
onClick: onClick.bind(null, swap.requestId)
|
|
4153
|
-
}, React__default.createElement(Container$
|
|
4155
|
+
}, React__default.createElement(Container$3, {
|
|
4154
4156
|
className: "" + status
|
|
4155
4157
|
}, React__default.createElement("div", {
|
|
4156
4158
|
className: "info"
|
|
@@ -4162,10 +4164,10 @@ function SwapDetail(_ref) {
|
|
|
4162
4164
|
},
|
|
4163
4165
|
blockchain: {
|
|
4164
4166
|
// @ts-ignore
|
|
4165
|
-
logo: firstStep.fromBlockchainLogo,
|
|
4167
|
+
logo: firstStep.fromBlockchainLogo || '',
|
|
4166
4168
|
name: firstStep.fromBlockchain
|
|
4167
4169
|
},
|
|
4168
|
-
amount: swap.inputAmount
|
|
4170
|
+
amount: limitDecimalPlaces(swap.inputAmount)
|
|
4169
4171
|
}
|
|
4170
4172
|
}), React__default.createElement(Spacer, {
|
|
4171
4173
|
size: 12
|
|
@@ -4184,7 +4186,7 @@ function SwapDetail(_ref) {
|
|
|
4184
4186
|
logo: lastStep.toBlockchainLogo,
|
|
4185
4187
|
name: lastStep.toBlockchain
|
|
4186
4188
|
},
|
|
4187
|
-
amount: lastStep.outputAmount || lastStep.expectedOutputAmountHumanReadable || ''
|
|
4189
|
+
amount: limitDecimalPlaces(lastStep.outputAmount || lastStep.expectedOutputAmountHumanReadable || '')
|
|
4188
4190
|
}
|
|
4189
4191
|
})), React__default.createElement("div", {
|
|
4190
4192
|
className: "status"
|
|
@@ -4194,7 +4196,7 @@ function SwapDetail(_ref) {
|
|
|
4194
4196
|
}) : status)));
|
|
4195
4197
|
}
|
|
4196
4198
|
|
|
4197
|
-
var Container$
|
|
4199
|
+
var Container$4 = /*#__PURE__*/styled('div', {
|
|
4198
4200
|
position: 'relative'
|
|
4199
4201
|
});
|
|
4200
4202
|
var Color = /*#__PURE__*/styled('div', {
|
|
@@ -4244,7 +4246,7 @@ function ColorPicker(_ref) {
|
|
|
4244
4246
|
var _useState = React.useState(false),
|
|
4245
4247
|
displayColorPicker = _useState[0],
|
|
4246
4248
|
setDisplayColorPicker = _useState[1];
|
|
4247
|
-
return React__default.createElement(Container$
|
|
4249
|
+
return React__default.createElement(Container$4, null, React__default.createElement(Label$3, {
|
|
4248
4250
|
className: "_text"
|
|
4249
4251
|
}, label), React__default.createElement(Button, {
|
|
4250
4252
|
variant: "outlined",
|
|
@@ -4383,7 +4385,7 @@ var AlertContainer = /*#__PURE__*/styled('div', {
|
|
|
4383
4385
|
var ConfirmButton = /*#__PURE__*/styled(Button, {
|
|
4384
4386
|
marginTop: '$16'
|
|
4385
4387
|
});
|
|
4386
|
-
var Container$
|
|
4388
|
+
var Container$5 = /*#__PURE__*/styled('div', {
|
|
4387
4389
|
paddingBottom: '$24',
|
|
4388
4390
|
'.title': {
|
|
4389
4391
|
paddingBottom: '$8',
|
|
@@ -4453,7 +4455,7 @@ function ConfirmSwap(props) {
|
|
|
4453
4455
|
var list = selectableWallets.filter(function (w) {
|
|
4454
4456
|
return wallet === w.chain;
|
|
4455
4457
|
});
|
|
4456
|
-
return React__default.createElement(Container$
|
|
4458
|
+
return React__default.createElement(Container$5, {
|
|
4457
4459
|
key: index
|
|
4458
4460
|
}, React__default.createElement("div", {
|
|
4459
4461
|
className: "title"
|
|
@@ -4484,7 +4486,7 @@ var Group = /*#__PURE__*/styled('div', {
|
|
|
4484
4486
|
textTransform: 'uppercase'
|
|
4485
4487
|
}
|
|
4486
4488
|
});
|
|
4487
|
-
var Container$
|
|
4489
|
+
var Container$6 = /*#__PURE__*/styled('div', {
|
|
4488
4490
|
overflowY: 'auto'
|
|
4489
4491
|
});
|
|
4490
4492
|
var filteredHistory = function filteredHistory(list, searchedFor) {
|
|
@@ -4538,7 +4540,7 @@ function History(_ref) {
|
|
|
4538
4540
|
title: "Swaps"
|
|
4539
4541
|
}, function (searchedFor) {
|
|
4540
4542
|
var filterSwaps = filteredHistory(list, searchedFor);
|
|
4541
|
-
return React__default.createElement(Container$
|
|
4543
|
+
return React__default.createElement(Container$6, null, filterSwaps.length ? React__default.createElement(SwapsGroup, {
|
|
4542
4544
|
list: filterSwaps,
|
|
4543
4545
|
onSwapClick: onSwapClick,
|
|
4544
4546
|
groupBy: groupBy
|
|
@@ -4786,14 +4788,13 @@ function SwapHistory(props) {
|
|
|
4786
4788
|
logo: step.fromLogo,
|
|
4787
4789
|
symbol: step.fromSymbol,
|
|
4788
4790
|
// @ts-ignore
|
|
4789
|
-
chainLogo: step.fromBlockchainLogo,
|
|
4791
|
+
chainLogo: step.fromBlockchainLogo || '',
|
|
4790
4792
|
blockchain: step.fromBlockchain,
|
|
4791
4793
|
amount: pendingSwap.inputAmount
|
|
4792
|
-
}), React__default.createElement(Dot$1, null)), React__default.createElement(Line$1, null), React__default.createElement(SwapperContainer$1, null, React__default.createElement(SwapperLogo$1
|
|
4793
|
-
|
|
4794
|
-
, {
|
|
4794
|
+
}), React__default.createElement(Dot$1, null)), React__default.createElement(Line$1, null), React__default.createElement(SwapperContainer$1, null, React__default.createElement(SwapperLogo$1, {
|
|
4795
|
+
src:
|
|
4795
4796
|
// @ts-ignore
|
|
4796
|
-
|
|
4797
|
+
step.swapperLogo || '',
|
|
4797
4798
|
alt: step.swapperId
|
|
4798
4799
|
}), React__default.createElement("div", null, React__default.createElement(Typography, {
|
|
4799
4800
|
ml: 4,
|
|
@@ -4830,7 +4831,7 @@ function SwapHistory(props) {
|
|
|
4830
4831
|
logo: step.toLogo,
|
|
4831
4832
|
symbol: step.toSymbol,
|
|
4832
4833
|
// @ts-ignore
|
|
4833
|
-
chainLogo: step.toBlockchainLogo,
|
|
4834
|
+
chainLogo: step.toBlockchainLogo || '',
|
|
4834
4835
|
blockchain: step.toBlockchain,
|
|
4835
4836
|
amount: step.outputAmount || ''
|
|
4836
4837
|
}));
|