@avail-project/widgets 2.0.0 → 2.0.1
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/dist/common/utils/token-pricing.d.ts +1 -1
- package/dist/common/utils/token-pricing.d.ts.map +1 -1
- package/dist/common/utils/token-pricing.js +4 -1
- package/dist/nexus/NexusProvider.d.ts +4 -2
- package/dist/nexus/NexusProvider.d.ts.map +1 -1
- package/dist/nexus/NexusProvider.js +216 -39
- package/dist/nexus-widget/components/deposit-idle-form.d.ts +2 -1
- package/dist/nexus-widget/components/deposit-idle-form.d.ts.map +1 -1
- package/dist/nexus-widget/components/deposit-idle-form.js +26 -10
- package/dist/nexus-widget/components/nexus-widget-progress-screen.d.ts.map +1 -1
- package/dist/nexus-widget/components/nexus-widget-progress-screen.js +21 -5
- package/dist/nexus-widget/components/pay-with-sources.d.ts.map +1 -1
- package/dist/nexus-widget/components/pay-with-sources.js +43 -54
- package/dist/nexus-widget/components/send-idle-form.d.ts +2 -1
- package/dist/nexus-widget/components/send-idle-form.d.ts.map +1 -1
- package/dist/nexus-widget/components/send-idle-form.js +26 -10
- package/dist/nexus-widget/components/swap-asset-selector.d.ts +1 -1
- package/dist/nexus-widget/components/swap-asset-selector.d.ts.map +1 -1
- package/dist/nexus-widget/components/swap-asset-selector.js +198 -140
- package/dist/nexus-widget/components/swap-idle-form.d.ts +2 -1
- package/dist/nexus-widget/components/swap-idle-form.d.ts.map +1 -1
- package/dist/nexus-widget/components/swap-idle-form.js +3 -3
- package/dist/nexus-widget/components/swap-intent-preview.d.ts +5 -1
- package/dist/nexus-widget/components/swap-intent-preview.d.ts.map +1 -1
- package/dist/nexus-widget/components/swap-intent-preview.js +50 -35
- package/dist/nexus-widget/nexus-widget.d.ts.map +1 -1
- package/dist/nexus-widget/nexus-widget.js +1311 -617
- package/dist/nexus-widget/types.d.ts +1 -1
- package/dist/nexus-widget/types.d.ts.map +1 -1
- package/dist/nexus-widget/utils/deposit-source-selection.d.ts.map +1 -1
- package/dist/nexus-widget/utils/deposit-source-selection.js +68 -4
- package/package.json +4 -4
|
@@ -176,11 +176,27 @@ const getApprovalIndexFromEvent = (event) => {
|
|
|
176
176
|
const rawStep = event?.step;
|
|
177
177
|
return getNumericEventIndex(rawEvent?.approvalIndex, rawEvent?.swapIndex, rawEvent?.currentIndex, rawEvent?.index, rawEvent?.data?.approvalIndex, rawEvent?.data?.swapIndex, rawEvent?.data?.currentIndex, rawEvent?.data?.index, rawStep?.approvalIndex, rawStep?.swapIndex, rawStep?.currentIndex, rawStep?.index, rawStep?.data?.approvalIndex, rawStep?.data?.swapIndex, rawStep?.data?.currentIndex, rawStep?.data?.index);
|
|
178
178
|
};
|
|
179
|
-
const getActiveApprovalProgressEvent = (events) => [...events]
|
|
179
|
+
const getActiveApprovalProgressEvent = (events, completedApprovalCount = 0, approvalSymbols = []) => [...events]
|
|
180
180
|
.reverse()
|
|
181
|
-
.find((event) =>
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
.find((event) => {
|
|
182
|
+
if (event.name !== PROGRESS_EVENT_NAMES.SWAP_PLAN_PROGRESS ||
|
|
183
|
+
event.completed) {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
const units = getApprovalUnitsForStep(event.step);
|
|
187
|
+
if (units.length === 0)
|
|
188
|
+
return false;
|
|
189
|
+
const eventIndex = getApprovalIndexFromEvent(event);
|
|
190
|
+
if (eventIndex !== undefined) {
|
|
191
|
+
return eventIndex >= completedApprovalCount;
|
|
192
|
+
}
|
|
193
|
+
if (units.length === 1 && units[0]?.symbol) {
|
|
194
|
+
const symbolIndex = approvalSymbols.findIndex((symbol) => symbol === units[0]?.symbol);
|
|
195
|
+
if (symbolIndex >= 0)
|
|
196
|
+
return symbolIndex >= completedApprovalCount;
|
|
197
|
+
}
|
|
198
|
+
return completedApprovalCount === 0;
|
|
199
|
+
});
|
|
184
200
|
const getApprovalSymbolFromProgressEvent = (event) => {
|
|
185
201
|
const units = getApprovalUnitsForStep(event?.step);
|
|
186
202
|
if (units.length === 0)
|
|
@@ -211,7 +227,7 @@ const buildStatusRows = ({ events, failedStep, mode, steps, approvalTotalCount,
|
|
|
211
227
|
stepMatches(failedStep, REFUND_ELIGIBLE_SWAP_TYPES);
|
|
212
228
|
const approvalCompletedCount = Math.min(immutableApprovalTotal || Number.MAX_SAFE_INTEGER, Math.max(countCompletedApprovalUnitsFromEvents(events), countCompletedApprovalUnitsFromSteps(steps)));
|
|
213
229
|
const approvalSymbols = getApprovalUnitSymbols(swapListSteps.length > 0 ? swapListSteps : fallbackSteps);
|
|
214
|
-
const activeApprovalSymbol = getApprovalSymbolFromProgressEvent(getActiveApprovalProgressEvent(events));
|
|
230
|
+
const activeApprovalSymbol = getApprovalSymbolFromProgressEvent(getActiveApprovalProgressEvent(events, approvalCompletedCount, approvalSymbols));
|
|
215
231
|
const hasSwapList = swapListSteps.length > 0 ||
|
|
216
232
|
hasStepType(events, steps, [
|
|
217
233
|
"SWAP_START",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pay-with-sources.d.ts","sourceRoot":"","sources":["../../../.build-src/nexus-widget/components/pay-with-sources.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"pay-with-sources.d.ts","sourceRoot":"","sources":["../../../.build-src/nexus-widget/components/pay-with-sources.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAiK7D,wBAAgB,cAAc,CAAC,EAC7B,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,aAAoB,EACpB,sBAA8B,EAC9B,iBAAyB,GAC1B,EAAE;IACD,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B,WAAW,CAAC,EAAE,SAAS,GAAG,cAAc,CAAC;IACzC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,2CAgSA"}
|
|
@@ -36,6 +36,13 @@ const formatUsd = (value) => {
|
|
|
36
36
|
return "<$0.01";
|
|
37
37
|
return `$${amount.toDecimalPlaces(2).toFixed()}`;
|
|
38
38
|
};
|
|
39
|
+
const getDisplayedUsdValue = (token) => parseDecimal(token.userAmountUsd || token.balanceInFiat) ?? new Decimal(0);
|
|
40
|
+
const sortSourceTokensByDisplayedUsdDesc = (tokens) => [...tokens].sort((a, b) => {
|
|
41
|
+
const usdDiff = getDisplayedUsdValue(b).cmp(getDisplayedUsdValue(a));
|
|
42
|
+
if (usdDiff !== 0)
|
|
43
|
+
return usdDiff;
|
|
44
|
+
return `${a.symbol ?? ""} ${a.chainName ?? ""}`.localeCompare(`${b.symbol ?? ""} ${b.chainName ?? ""}`);
|
|
45
|
+
});
|
|
39
46
|
function TokenLogo({ src, label, size = 30, fontSize = 12, style, }) {
|
|
40
47
|
const [failed, setFailed] = useState(!src);
|
|
41
48
|
React.useEffect(() => {
|
|
@@ -96,8 +103,10 @@ function SkeletonRow() {
|
|
|
96
103
|
export function PayWithSources({ fromTokens, onOpenSourcePicker, routeStatus, routeMessage, showAutoBadge = true, isSourcePickerDisabled = false, reserveSourceRows = false, }) {
|
|
97
104
|
const scrollRef = useRef(null);
|
|
98
105
|
const isRouteLoading = routeStatus === "loading";
|
|
99
|
-
const
|
|
100
|
-
const
|
|
106
|
+
const displayTokens = React.useMemo(() => sortSourceTokensByDisplayedUsdDesc(fromTokens), [fromTokens]);
|
|
107
|
+
const shouldShowSourceSummary = !isRouteLoading && displayTokens.length > 0;
|
|
108
|
+
const shouldScroll = shouldShowSourceSummary && displayTokens.length > 3;
|
|
109
|
+
const sourceCountLabel = displayTokens.length === 1 ? "1 asset" : `${displayTokens.length} assets`;
|
|
101
110
|
const autoBadge = (_jsx("span", { style: {
|
|
102
111
|
border: `1px solid ${brand}`,
|
|
103
112
|
borderRadius: "999px",
|
|
@@ -134,7 +143,7 @@ export function PayWithSources({ fromTokens, onOpenSourcePicker, routeStatus, ro
|
|
|
134
143
|
letterSpacing: "0.08em",
|
|
135
144
|
lineHeight: "20px",
|
|
136
145
|
textTransform: "uppercase",
|
|
137
|
-
}, children: [_jsxs("span", { children: ["Pay With", shouldShowSourceSummary ? ` · ${
|
|
146
|
+
}, children: [_jsxs("span", { children: ["Pay With", shouldShowSourceSummary ? ` · ${sourceCountLabel}` : ""] }), showAutoBadge ? autoBadge : null] }), shouldShowSourceSummary && (_jsx("button", { disabled: isSourcePickerDisabled, onClick: onOpenSourcePicker, style: {
|
|
138
147
|
backgroundColor: isSourcePickerDisabled ? "#F4F4F3" : "#E8F0FF",
|
|
139
148
|
border: "none",
|
|
140
149
|
borderRadius: "4px",
|
|
@@ -162,62 +171,42 @@ export function PayWithSources({ fromTokens, onOpenSourcePicker, routeStatus, ro
|
|
|
162
171
|
minHeight: reserveSourceRows && !shouldScroll ? "162px" : undefined,
|
|
163
172
|
overflowY: shouldScroll ? "auto" : undefined,
|
|
164
173
|
paddingRight: shouldScroll ? "8px" : 0,
|
|
165
|
-
}, children:
|
|
174
|
+
}, children: displayTokens.map((token, index) => (_jsxs("div", { style: {
|
|
166
175
|
alignItems: "center",
|
|
167
176
|
display: "flex",
|
|
168
177
|
gap: "14px",
|
|
169
178
|
justifyContent: "space-between",
|
|
170
179
|
minHeight: "44px",
|
|
171
|
-
}, children: [
|
|
180
|
+
}, children: [_jsx("div", { style: {
|
|
172
181
|
alignItems: "center",
|
|
173
|
-
borderTop: index === 0 ? "none" : "1px solid #F0F0EF",
|
|
174
182
|
display: "flex",
|
|
175
183
|
gap: "14px",
|
|
176
184
|
minWidth: 0,
|
|
177
|
-
}, children:
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
display: "flex",
|
|
203
|
-
flexDirection: "column",
|
|
204
|
-
gap: "3px",
|
|
205
|
-
textAlign: "right",
|
|
206
|
-
}, children: [_jsxs("span", { style: {
|
|
207
|
-
color: primary,
|
|
208
|
-
fontFamily: uiFont,
|
|
209
|
-
fontSize: "16px",
|
|
210
|
-
fontWeight: 500,
|
|
211
|
-
lineHeight: "24px",
|
|
212
|
-
}, children: [formatToken(token.userAmount || token.balance), " ", token.symbol] }), _jsx("span", { style: {
|
|
213
|
-
color: muted,
|
|
214
|
-
fontFamily: uiFont,
|
|
215
|
-
fontSize: "14px",
|
|
216
|
-
lineHeight: "20px",
|
|
217
|
-
overflow: "hidden",
|
|
218
|
-
textOverflow: "ellipsis",
|
|
219
|
-
whiteSpace: "nowrap",
|
|
220
|
-
}, children: formatUsd(token.userAmountUsd || token.balanceInFiat) })] })] }, `${token.contractAddress}-${token.chainId ?? "unified"}-${index}`), _jsxs("div", { style: {
|
|
185
|
+
}, children: _jsxs("div", { style: {
|
|
186
|
+
alignItems: "center",
|
|
187
|
+
display: "flex",
|
|
188
|
+
gap: "10px",
|
|
189
|
+
minWidth: 0,
|
|
190
|
+
}, children: [_jsx(SourceLogoPair, { token: token }), _jsxs("div", { style: {
|
|
191
|
+
display: "flex",
|
|
192
|
+
flexDirection: "column",
|
|
193
|
+
gap: "3px",
|
|
194
|
+
minWidth: 0,
|
|
195
|
+
}, children: [_jsx("span", { style: {
|
|
196
|
+
color: primary,
|
|
197
|
+
fontFamily: uiFont,
|
|
198
|
+
fontSize: "14px",
|
|
199
|
+
fontWeight: 600,
|
|
200
|
+
}, children: token.symbol }), _jsx("span", { style: {
|
|
201
|
+
color: muted,
|
|
202
|
+
fontFamily: uiFont,
|
|
203
|
+
fontSize: "12px",
|
|
204
|
+
overflow: "hidden",
|
|
205
|
+
textOverflow: "ellipsis",
|
|
206
|
+
whiteSpace: "nowrap",
|
|
207
|
+
}, children: token.isUnified
|
|
208
|
+
? "Unified balance"
|
|
209
|
+
: `on ${token.chainName || "Unknown chain"}` })] })] }) }, `${token.contractAddress}-${token.chainId ?? "unified"}-${index}`), _jsxs("div", { style: {
|
|
221
210
|
display: "flex",
|
|
222
211
|
flexDirection: "column",
|
|
223
212
|
gap: "3px",
|
|
@@ -225,14 +214,14 @@ export function PayWithSources({ fromTokens, onOpenSourcePicker, routeStatus, ro
|
|
|
225
214
|
}, children: [_jsxs("span", { style: {
|
|
226
215
|
color: primary,
|
|
227
216
|
fontFamily: uiFont,
|
|
228
|
-
fontSize: "
|
|
217
|
+
fontSize: "14px",
|
|
229
218
|
fontWeight: 500,
|
|
230
|
-
lineHeight: "
|
|
219
|
+
lineHeight: "18px",
|
|
231
220
|
}, children: [formatToken(token.userAmount || token.balance), " ", token.symbol] }), _jsx("span", { style: {
|
|
232
221
|
color: muted,
|
|
233
222
|
fontFamily: uiFont,
|
|
234
|
-
fontSize: "
|
|
235
|
-
lineHeight: "
|
|
223
|
+
fontSize: "12px",
|
|
224
|
+
lineHeight: "18px",
|
|
236
225
|
}, children: formatUsd(token.userAmountUsd || token.balanceInFiat) })] })] }, `${token.contractAddress}-${token.chainId ?? "unified"}-${index}`))) }), shouldScroll && (_jsx("button", { "aria-label": "Scroll payment sources", onClick: () => scrollRef.current?.scrollBy({ behavior: "smooth", top: 64 }), style: {
|
|
237
226
|
alignItems: "center",
|
|
238
227
|
background: "#FFFFFE",
|
|
@@ -5,6 +5,7 @@ interface SendIdleFormProps {
|
|
|
5
5
|
fromTokens: SwapTokenOption[];
|
|
6
6
|
isAmountReadOnly?: boolean;
|
|
7
7
|
isAssetPickerDisabled?: boolean;
|
|
8
|
+
isBalanceLoading?: boolean;
|
|
8
9
|
isCalculatingMax?: boolean;
|
|
9
10
|
isQuoteRefreshing?: boolean;
|
|
10
11
|
isRecipientLocked?: boolean;
|
|
@@ -24,6 +25,6 @@ interface SendIdleFormProps {
|
|
|
24
25
|
totalBalance: string;
|
|
25
26
|
usdValue: string;
|
|
26
27
|
}
|
|
27
|
-
export declare function SendIdleForm({ amount, onAmountChange, toToken, fromTokens, totalBalance, usdValue, onOpenAssetPicker, onOpenSourcePicker, onOpenRecipientPicker, recipientAddress, onSetPercent, routeStatus, routeMessage, isAmountReadOnly, isAssetPickerDisabled, isCalculatingMax, calculatingPercent, isQuoteRefreshing, isRecipientLocked, hideDestinationTokenDropdownIcon, showAutoBadge, isSourcePickerDisabled, reserveSourceRows, }: SendIdleFormProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare function SendIdleForm({ amount, onAmountChange, toToken, fromTokens, totalBalance, usdValue, onOpenAssetPicker, onOpenSourcePicker, onOpenRecipientPicker, recipientAddress, onSetPercent, routeStatus, routeMessage, isAmountReadOnly, isAssetPickerDisabled, isBalanceLoading, isCalculatingMax, calculatingPercent, isQuoteRefreshing, isRecipientLocked, hideDestinationTokenDropdownIcon, showAutoBadge, isSourcePickerDisabled, reserveSourceRows, }: SendIdleFormProps): import("react/jsx-runtime").JSX.Element;
|
|
28
29
|
export {};
|
|
29
30
|
//# sourceMappingURL=send-idle-form.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-idle-form.d.ts","sourceRoot":"","sources":["../../../.build-src/nexus-widget/components/send-idle-form.tsx"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAE/B,UAAU,iBAAiB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,gBAAgB,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,EAAE,OAAO,CAAC;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gCAAgC,CAAC,EAAE,OAAO,CAAC;IAC3C,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,qBAAqB,EAAE,MAAM,IAAI,CAAC;IAClC,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,SAAS,GAAG,cAAc,CAAC;IACzC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAmiBD,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,cAAc,EACd,OAAO,EACP,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,gBAAwB,EACxB,qBAA6B,EAC7B,gBAAwB,EACxB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAyB,EACzB,gCAAwC,EACxC,aAAoB,EACpB,sBAA8B,EAC9B,iBAAyB,GAC1B,EAAE,iBAAiB,2CAgcnB"}
|
|
@@ -106,6 +106,11 @@ function SourceLogoPair({ token }) {
|
|
|
106
106
|
} }))] }));
|
|
107
107
|
}
|
|
108
108
|
function ExactOutPercentButtons({ visible, onSelect, }) {
|
|
109
|
+
const [focusedPercent, setFocusedPercent] = useState(null);
|
|
110
|
+
React.useEffect(() => {
|
|
111
|
+
if (!visible)
|
|
112
|
+
setFocusedPercent(null);
|
|
113
|
+
}, [visible]);
|
|
109
114
|
return (_jsx("div", { style: {
|
|
110
115
|
alignItems: "center",
|
|
111
116
|
boxSizing: "border-box",
|
|
@@ -117,18 +122,17 @@ function ExactOutPercentButtons({ visible, onSelect, }) {
|
|
|
117
122
|
width: "100%",
|
|
118
123
|
}, children: [25, 50, 75, 100].map((pct) => {
|
|
119
124
|
const isMax = pct === 100;
|
|
125
|
+
const isFocused = focusedPercent === pct;
|
|
120
126
|
return (_jsx("button", { onClick: (e) => {
|
|
121
127
|
e.stopPropagation();
|
|
122
128
|
onSelect(pct);
|
|
123
|
-
},
|
|
124
|
-
e.preventDefault();
|
|
125
|
-
}, style: {
|
|
129
|
+
}, onBlur: () => setFocusedPercent(null), onFocus: () => setFocusedPercent(pct), style: {
|
|
126
130
|
alignItems: "center",
|
|
127
|
-
backgroundColor:
|
|
131
|
+
backgroundColor: isFocused ? "#E8F0FF" : "#F4F4F3",
|
|
128
132
|
border: "none",
|
|
129
133
|
borderRadius: "8px",
|
|
130
134
|
boxSizing: "border-box",
|
|
131
|
-
color:
|
|
135
|
+
color: isFocused ? brand : "#363635",
|
|
132
136
|
cursor: "pointer",
|
|
133
137
|
display: "flex",
|
|
134
138
|
flex: "1 1 0%",
|
|
@@ -140,7 +144,7 @@ function ExactOutPercentButtons({ visible, onSelect, }) {
|
|
|
140
144
|
minWidth: 0,
|
|
141
145
|
paddingBlock: "5px",
|
|
142
146
|
paddingInline: "10px",
|
|
143
|
-
},
|
|
147
|
+
}, type: "button", children: isMax ? "MAX" : `${pct}%` }, pct));
|
|
144
148
|
}) }));
|
|
145
149
|
}
|
|
146
150
|
function SkeletonRow() {
|
|
@@ -302,7 +306,19 @@ function PayWithSources({ fromTokens, onOpenSourcePicker, routeStatus, routeMess
|
|
|
302
306
|
lineHeight: "20px",
|
|
303
307
|
}, children: [_jsx(AlertCircle, { style: { flexShrink: 0, height: 15, width: 15 } }), routeMessage] }))] }));
|
|
304
308
|
}
|
|
305
|
-
|
|
309
|
+
function BalanceSkeleton({ height = "16px", width = "72px", }) {
|
|
310
|
+
return (_jsx("span", { "aria-hidden": "true", className: "animate-pulse", style: {
|
|
311
|
+
background: "linear-gradient(90deg, #F0F0EF 0%, #E6EEFF 48%, #F0F0EF 100%)",
|
|
312
|
+
backgroundSize: "200% 100%",
|
|
313
|
+
borderRadius: "6px",
|
|
314
|
+
display: "inline-block",
|
|
315
|
+
flexShrink: 0,
|
|
316
|
+
height,
|
|
317
|
+
maxWidth: "100%",
|
|
318
|
+
width,
|
|
319
|
+
} }));
|
|
320
|
+
}
|
|
321
|
+
export function SendIdleForm({ amount, onAmountChange, toToken, fromTokens, totalBalance, usdValue, onOpenAssetPicker, onOpenSourcePicker, onOpenRecipientPicker, recipientAddress, onSetPercent, routeStatus, routeMessage, isAmountReadOnly = false, isAssetPickerDisabled = false, isBalanceLoading = false, isCalculatingMax, calculatingPercent, isQuoteRefreshing, isRecipientLocked = false, hideDestinationTokenDropdownIcon = false, showAutoBadge = true, isSourcePickerDisabled = false, reserveSourceRows = false, }) {
|
|
306
322
|
const [pendingPercent, setPendingPercent] = useState(null);
|
|
307
323
|
const [isAmountFocused, setIsAmountFocused] = useState(false);
|
|
308
324
|
React.useEffect(() => {
|
|
@@ -424,13 +440,13 @@ export function SendIdleForm({ amount, onAmountChange, toToken, fromTokens, tota
|
|
|
424
440
|
fontFamily: uiFont,
|
|
425
441
|
fontSize: "14px",
|
|
426
442
|
lineHeight: "20px",
|
|
427
|
-
}, children: "Total Balance:" }),
|
|
443
|
+
}, children: "Total Balance:" }), _jsx("span", { style: {
|
|
428
444
|
color: primary,
|
|
429
445
|
fontFamily: uiFont,
|
|
430
446
|
fontSize: "14px",
|
|
431
447
|
fontWeight: 600,
|
|
432
448
|
lineHeight: "20px",
|
|
433
|
-
}, children:
|
|
449
|
+
}, children: isBalanceLoading ? (_jsx(BalanceSkeleton, { width: "64px" })) : (`$${totalBalance}`) })] })] }), _jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "10px" }, children: [_jsxs("div", { style: {
|
|
434
450
|
alignItems: "center",
|
|
435
451
|
display: "flex",
|
|
436
452
|
gap: "12px",
|
|
@@ -544,5 +560,5 @@ export function SendIdleForm({ amount, onAmountChange, toToken, fromTokens, tota
|
|
|
544
560
|
fontWeight: 500,
|
|
545
561
|
lineHeight: "20px",
|
|
546
562
|
whiteSpace: "nowrap",
|
|
547
|
-
}, children: destinationBalanceLabel })] })) })] }), _jsx(ExactOutPercentButtons, { onSelect: handlePercentSelect, visible: Boolean(toToken) && !isAmountReadOnly })] })] }), _jsx(SharedPayWithSources, { fromTokens: fromTokens, isSourcePickerDisabled: isSourcePickerDisabled, onOpenSourcePicker: onOpenSourcePicker, reserveSourceRows: reserveSourceRows, routeMessage: routeMessage, routeStatus: routeStatus, showAutoBadge: showAutoBadge })] }));
|
|
563
|
+
}, children: isBalanceLoading ? (_jsx(BalanceSkeleton, { width: "110px" })) : (destinationBalanceLabel) })] })) })] }), _jsx(ExactOutPercentButtons, { onSelect: handlePercentSelect, visible: Boolean(toToken) && !isAmountReadOnly })] })] }), _jsx(SharedPayWithSources, { fromTokens: fromTokens, isSourcePickerDisabled: isSourcePickerDisabled, onOpenSourcePicker: onOpenSourcePicker, reserveSourceRows: reserveSourceRows, routeMessage: routeMessage, routeStatus: routeStatus, showAutoBadge: showAutoBadge })] }));
|
|
548
564
|
}
|
|
@@ -31,7 +31,7 @@ interface SwapAssetSelectorProps {
|
|
|
31
31
|
lockedTokens?: SwapTokenOption[];
|
|
32
32
|
onBack: () => void;
|
|
33
33
|
onClearSelection?: () => void;
|
|
34
|
-
onDone?: () => void;
|
|
34
|
+
onDone?: (tokens?: SwapTokenOption[]) => void;
|
|
35
35
|
onFilterTabSelect?: (tab: Exclude<FilterTab, "custom">) => void;
|
|
36
36
|
onSelect: (token: SwapTokenOption) => void;
|
|
37
37
|
onSelectionChange?: (tokens: SwapTokenOption[]) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swap-asset-selector.d.ts","sourceRoot":"","sources":["../../../.build-src/nexus-widget/components/swap-asset-selector.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"swap-asset-selector.d.ts","sourceRoot":"","sources":["../../../.build-src/nexus-widget/components/swap-asset-selector.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;AA6BhF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAS3D,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,sBAAsB;IAC9B,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,YAAY,CAAC,EAAE,OAAO,CAAC;IAC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