@coin-voyage/swapkit 0.1.0-beta.0 → 0.1.0-beta.2
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/components/connected-wallets.d.ts +1 -0
- package/dist/components/connected-wallets.js +66 -0
- package/dist/components/execution-modal.d.ts +5 -0
- package/dist/components/execution-modal.js +79 -0
- package/dist/components/icons.d.ts +23 -0
- package/dist/components/icons.js +49 -0
- package/dist/components/modal.d.ts +11 -0
- package/dist/components/modal.js +40 -0
- package/dist/components/styles.d.ts +124 -0
- package/dist/components/styles.js +1239 -0
- package/dist/components/swap.d.ts +2 -0
- package/dist/components/swap.js +295 -0
- package/dist/components/token-icon.d.ts +5 -0
- package/dist/components/token-icon.js +9 -0
- package/dist/components/token-picker.d.ts +11 -0
- package/dist/components/token-picker.js +69 -0
- package/dist/components/wallet-connector.d.ts +8 -0
- package/dist/components/wallet-connector.js +33 -0
- package/dist/components/wallet-icon.d.ts +5 -0
- package/dist/components/wallet-icon.js +6 -0
- package/dist/hooks/use-order-status.d.ts +9 -0
- package/dist/hooks/use-order-status.js +36 -0
- package/dist/hooks/use-swap-execution.d.ts +7 -0
- package/dist/hooks/use-swap-execution.js +105 -0
- package/dist/hooks/use-swap-quote.d.ts +6 -0
- package/dist/hooks/use-swap-quote.js +63 -0
- package/dist/hooks/use-swap-state.d.ts +70 -0
- package/dist/hooks/use-swap-state.js +147 -0
- package/dist/hooks/use-token-data.d.ts +12 -0
- package/dist/hooks/use-token-data.js +80 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/lib/amount-input.d.ts +3 -0
- package/dist/lib/amount-input.js +11 -0
- package/dist/lib/currency-selection.d.ts +13 -0
- package/dist/lib/currency-selection.js +26 -0
- package/dist/lib/execution.d.ts +38 -0
- package/dist/lib/execution.js +26 -0
- package/dist/lib/output-wallet.d.ts +24 -0
- package/dist/lib/output-wallet.js +24 -0
- package/dist/lib/quote.d.ts +13 -0
- package/dist/lib/quote.js +24 -0
- package/dist/lib/version.d.ts +1 -0
- package/dist/lib/version.js +2 -0
- package/dist/providers/swapkit-context.d.ts +10 -0
- package/dist/providers/swapkit-context.js +8 -0
- package/dist/providers/swapkit-provider.d.ts +2 -0
- package/dist/providers/swapkit-provider.js +18 -0
- package/dist/styles/root.d.ts +5 -0
- package/dist/styles/root.js +75 -0
- package/dist/styles/styled.d.ts +2 -0
- package/dist/styles/styled.js +3 -0
- package/dist/styles/theme.d.ts +3 -0
- package/dist/styles/theme.js +36 -0
- package/dist/types.d.ts +44 -0
- package/dist/types.js +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ConnectedWallets(): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useAccount, useAccountDisconnect, useInstalledWallets } from "@coin-voyage/crypto/hooks";
|
|
3
|
+
import { getChainTypeName } from "@coin-voyage/shared/chain";
|
|
4
|
+
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
import { CloseIcon, UnplugIcon } from "./icons";
|
|
6
|
+
import { ConnectedWalletPanel, ConnectedWalletRow, DisconnectAllButton, IconButton, TriggerWalletIcons, ToolbarGroup, WalletDetails, WalletDisconnectButton, WalletIdentity, WalletLabel, WalletPanelHeader, } from "./styles";
|
|
7
|
+
import { WalletIconDisplay } from "./wallet-icon";
|
|
8
|
+
function truncateAddress(address) {
|
|
9
|
+
return address.length <= 14 ? address : `${address.slice(0, 6)}…${address.slice(-5)}`;
|
|
10
|
+
}
|
|
11
|
+
function connectorId(connector) {
|
|
12
|
+
if (!connector || typeof connector !== "object")
|
|
13
|
+
return undefined;
|
|
14
|
+
if ("id" in connector && typeof connector.id === "string")
|
|
15
|
+
return connector.id;
|
|
16
|
+
if ("name" in connector && typeof connector.name === "string")
|
|
17
|
+
return connector.name;
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
function accountAddress(account) {
|
|
21
|
+
return account.address ?? account.addresses?.[0];
|
|
22
|
+
}
|
|
23
|
+
export function ConnectedWallets() {
|
|
24
|
+
const { accounts } = useAccount();
|
|
25
|
+
const wallets = useInstalledWallets();
|
|
26
|
+
const disconnectAccount = useAccountDisconnect();
|
|
27
|
+
const [open, setOpen] = useState(false);
|
|
28
|
+
const groupRef = useRef(null);
|
|
29
|
+
const connectedAccounts = accounts.filter((account) => account.isConnected);
|
|
30
|
+
const walletForAccount = (account) => {
|
|
31
|
+
const accountConnectorId = connectorId(account.connector);
|
|
32
|
+
return wallets.find((wallet) => wallet.connectors.some((candidate) => candidate.chainType === account.chainType && connectorId(candidate.connector) === accountConnectorId));
|
|
33
|
+
};
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (!open)
|
|
36
|
+
return;
|
|
37
|
+
const dismissFromPointer = (event) => {
|
|
38
|
+
if (!groupRef.current?.contains(event.target))
|
|
39
|
+
setOpen(false);
|
|
40
|
+
};
|
|
41
|
+
const dismissFromKeyboard = (event) => {
|
|
42
|
+
if (event.key === "Escape")
|
|
43
|
+
setOpen(false);
|
|
44
|
+
};
|
|
45
|
+
document.addEventListener("pointerdown", dismissFromPointer);
|
|
46
|
+
document.addEventListener("keydown", dismissFromKeyboard);
|
|
47
|
+
return () => {
|
|
48
|
+
document.removeEventListener("pointerdown", dismissFromPointer);
|
|
49
|
+
document.removeEventListener("keydown", dismissFromKeyboard);
|
|
50
|
+
};
|
|
51
|
+
}, [open]);
|
|
52
|
+
if (connectedAccounts.length === 0)
|
|
53
|
+
return null;
|
|
54
|
+
const triggerLabel = connectedAccounts.length === 1
|
|
55
|
+
? truncateAddress(accountAddress(connectedAccounts[0]) ?? "Wallet")
|
|
56
|
+
: `${connectedAccounts.length} connections`;
|
|
57
|
+
return (_jsxs(ToolbarGroup, { ref: groupRef, children: [_jsxs(IconButton, { type: "button", "aria-label": "Connected wallets", "aria-expanded": open, onClick: () => setOpen((current) => !current), children: [_jsx(TriggerWalletIcons, { children: connectedAccounts.slice(0, 3).map((account, index) => {
|
|
58
|
+
const wallet = walletForAccount(account);
|
|
59
|
+
return (_jsx(WalletIconDisplay, { icon: wallet?.icon, name: wallet?.name ?? getChainTypeName(account.chainType), size: 20 }, `${account.chainType}:${accountAddress(account) ?? index}`));
|
|
60
|
+
}) }), _jsx(WalletLabel, { children: triggerLabel })] }), open && (_jsxs(ConnectedWalletPanel, { role: "menu", "aria-label": "Connected wallets menu", children: [_jsx(WalletPanelHeader, { children: "Connected wallets" }), connectedAccounts.map((account, index) => {
|
|
61
|
+
const wallet = walletForAccount(account);
|
|
62
|
+
const chainName = getChainTypeName(account.chainType);
|
|
63
|
+
const address = accountAddress(account);
|
|
64
|
+
return (_jsxs(ConnectedWalletRow, { children: [_jsxs(WalletIdentity, { children: [_jsx(WalletIconDisplay, { icon: wallet?.icon, name: wallet?.name ?? chainName, size: 20 }), _jsxs(WalletDetails, { children: [_jsx("strong", { children: chainName }), _jsx("small", { children: address ? truncateAddress(address) : "Connected" })] })] }), _jsx(WalletDisconnectButton, { type: "button", "aria-label": `Disconnect ${chainName} wallet`, onClick: () => void disconnectAccount(account), children: _jsx(CloseIcon, { size: 16 }) })] }, `${account.chainType}:${address ?? index}`));
|
|
65
|
+
}), _jsxs(DisconnectAllButton, { type: "button", onClick: () => void disconnectAccount(), children: [_jsx(UnplugIcon, {}), "Disconnect all"] })] }))] }));
|
|
66
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getChainExplorerTxUrl, getChainName } from "@coin-voyage/shared/chain";
|
|
3
|
+
import { AlertCircleIcon, ArrowRightIcon, CheckIcon, StatusDot, WarningIcon } from "./icons";
|
|
4
|
+
import { Modal } from "./modal";
|
|
5
|
+
import { ExecutionContent, ExecutionState, ExplorerLink, ProgressConnector, ProgressItem, ProgressLabel, ProgressList, ProgressMarker, ProgressMarkerColumn, ProgressText, RouteArrow, Spinner, TokenAmount, TokenRoute, } from "./styles";
|
|
6
|
+
import { TokenIcon } from "./token-icon";
|
|
7
|
+
function completedLabel(step) {
|
|
8
|
+
return step.action === "approve" ? "Approved" : "Sent";
|
|
9
|
+
}
|
|
10
|
+
function paymentStepState(stage, step, index, total) {
|
|
11
|
+
const sourceTxHash = "sourceTxHash" in stage ? stage.sourceTxHash : undefined;
|
|
12
|
+
const sourceChainId = "swapData" in stage && stage.swapData ? stage.swapData.data.input.currency.chain_id : undefined;
|
|
13
|
+
const explorerUrl = sourceTxHash && sourceChainId ? getChainExplorerTxUrl(sourceChainId, sourceTxHash) : undefined;
|
|
14
|
+
const completed = { tone: "complete", label: completedLabel(step) };
|
|
15
|
+
const isLast = index === total - 1;
|
|
16
|
+
switch (stage.kind) {
|
|
17
|
+
case "awaiting_payment":
|
|
18
|
+
if (index < stage.paymentStepIndex)
|
|
19
|
+
return completed;
|
|
20
|
+
if (index === stage.paymentStepIndex)
|
|
21
|
+
return { tone: "active", label: "Send in wallet" };
|
|
22
|
+
return { tone: "muted", label: "Awaiting" };
|
|
23
|
+
case "source_confirming":
|
|
24
|
+
return isLast ? { tone: "active", label: "Confirming...", explorerUrl } : completed;
|
|
25
|
+
case "executing":
|
|
26
|
+
return isLast ? { tone: "active", label: "Processing...", explorerUrl } : completed;
|
|
27
|
+
case "done":
|
|
28
|
+
return isLast ? { tone: "complete", explorerUrl } : completed;
|
|
29
|
+
case "refunded":
|
|
30
|
+
return isLast ? { ...completed, explorerUrl } : completed;
|
|
31
|
+
default:
|
|
32
|
+
return { tone: "muted", label: "Awaiting" };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function outcomeState(stage) {
|
|
36
|
+
if (!("swapData" in stage) || !stage.swapData)
|
|
37
|
+
return { tone: "muted", label: "Awaiting" };
|
|
38
|
+
if (stage.kind === "done") {
|
|
39
|
+
return {
|
|
40
|
+
tone: "complete",
|
|
41
|
+
explorerUrl: getChainExplorerTxUrl(stage.swapData.data.output.currency.chain_id, stage.txHash),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if (stage.kind === "refunded") {
|
|
45
|
+
return {
|
|
46
|
+
tone: "warning",
|
|
47
|
+
label: "Refunded",
|
|
48
|
+
explorerUrl: getChainExplorerTxUrl(stage.swapData.data.input.currency.chain_id, stage.refundTxHash),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return { tone: "muted", label: "Awaiting" };
|
|
52
|
+
}
|
|
53
|
+
function marker(state) {
|
|
54
|
+
if (state.tone === "active")
|
|
55
|
+
return _jsx(Spinner, {});
|
|
56
|
+
if (state.tone === "complete")
|
|
57
|
+
return _jsx(CheckIcon, { size: 14 });
|
|
58
|
+
if (state.tone === "warning")
|
|
59
|
+
return _jsx(WarningIcon, {});
|
|
60
|
+
if (state.tone === "danger")
|
|
61
|
+
return _jsx(AlertCircleIcon, { size: 14 });
|
|
62
|
+
return _jsx(StatusDot, {});
|
|
63
|
+
}
|
|
64
|
+
function ProgressStep({ title, state, connected }) {
|
|
65
|
+
return (_jsxs(ProgressItem, { role: "listitem", children: [_jsxs(ProgressMarkerColumn, { children: [_jsx(ProgressMarker, { "$tone": state.tone, children: marker(state) }), connected && _jsx(ProgressConnector, { "aria-hidden": true })] }), _jsxs(ProgressText, { "$connected": connected, children: [_jsx("strong", { children: title }), state.label && _jsx(ProgressLabel, { "$tone": state.tone, children: state.label }), state.explorerUrl && (_jsx(ExplorerLink, { href: state.explorerUrl, target: "_blank", rel: "noopener noreferrer", children: "View on Explorer" }))] })] }));
|
|
66
|
+
}
|
|
67
|
+
function stepTitle(step, sourceSymbol, sourceChain) {
|
|
68
|
+
if (step.description)
|
|
69
|
+
return step.description;
|
|
70
|
+
return `${step.action === "approve" ? "Approve" : "Send"} ${sourceSymbol} on ${sourceChain}`;
|
|
71
|
+
}
|
|
72
|
+
export function ExecutionModal({ stage, onClose }) {
|
|
73
|
+
const open = stage.kind !== "idle";
|
|
74
|
+
const swapData = "swapData" in stage ? stage.swapData : null;
|
|
75
|
+
const preventDismiss = stage.kind !== "done" && stage.kind !== "refunded" && stage.kind !== "error";
|
|
76
|
+
return (_jsx(Modal, { open: open, title: "Transaction Details", onClose: onClose, preventDismiss: preventDismiss, maxWidth: 384, children: stage.kind === "error" ? (_jsxs(ExecutionState, { "$tone": "danger", children: [_jsx(AlertCircleIcon, {}), _jsx("p", { children: stage.message })] })) : !swapData ? (_jsxs(ExecutionState, { children: [_jsx(Spinner, {}), _jsx("p", { children: "Loading swap data..." })] })) : (_jsxs(ExecutionContent, { children: [_jsxs(TokenRoute, { children: [_jsxs(TokenAmount, { children: [_jsx(TokenIcon, { currency: swapData.data.input.currency, size: 40 }), _jsxs("strong", { children: [swapData.data.input.amount.ui, " ", swapData.data.input.currency.symbol] })] }), _jsx(RouteArrow, { children: _jsx(ArrowRightIcon, {}) }), _jsxs(TokenAmount, { "$align": "end", children: [_jsx(TokenIcon, { currency: swapData.data.output.currency, size: 40 }), _jsxs("strong", { children: [swapData.data.output.amount.ui, " ", swapData.data.output.currency.symbol] })] })] }), _jsxs(ProgressList, { "aria-label": "Swap progress", children: [swapData.data.steps.map((step, index) => (_jsx(ProgressStep, { title: stepTitle(step, swapData.data.input.currency.symbol, getChainName(swapData.data.input.currency.chain_id) ?? "Unknown network"), state: paymentStepState(stage, step, index, swapData.data.steps.length), connected: true }, step.id ?? index))), _jsx(ProgressStep, { title: stage.kind === "refunded"
|
|
77
|
+
? `Refund ${swapData.data.input.currency.symbol} on ${getChainName(swapData.data.input.currency.chain_id) ?? "Unknown network"}`
|
|
78
|
+
: `Receive ${swapData.data.output.currency.symbol} on ${getChainName(swapData.data.output.currency.chain_id) ?? "Unknown network"}`, state: outcomeState(stage), connected: false })] })] })) }));
|
|
79
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
interface IconProps {
|
|
2
|
+
size?: number;
|
|
3
|
+
}
|
|
4
|
+
export declare function WalletIcon({ size }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare function PasteIcon({ size }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function SettingsIcon({ size }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function ChevronDownIcon({ size, up }: IconProps & {
|
|
8
|
+
up?: boolean;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function SearchIcon({ size }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function FuelIcon({ size }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function CloseIcon({ size }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function UnplugIcon({ size }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function ArrowDownIcon({ size, rotated }: IconProps & {
|
|
15
|
+
rotated?: boolean;
|
|
16
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function CheckIcon({ size }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare function StatusDot({ size }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare function ArrowRightIcon({ size }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function AlertCircleIcon({ size }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare function InfoIcon({ size }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare function WarningIcon({ size }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export function WalletIcon({ size = 16 }) {
|
|
3
|
+
return (_jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", "aria-hidden": true, children: [_jsx("path", { d: "M4 6.5h14a2 2 0 0 1 2 2v9H4a2 2 0 0 1-2-2v-11a2 2 0 0 1 2-2h12" }), _jsx("path", { d: "M16 11h6v4h-6a2 2 0 0 1 0-4Z" })] }));
|
|
4
|
+
}
|
|
5
|
+
export function PasteIcon({ size = 16 }) {
|
|
6
|
+
return (_jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [_jsx("rect", { width: "8", height: "4", x: "8", y: "2", rx: "1" }), _jsx("path", { d: "M16 4h2a2 2 0 0 1 2 2v4" }), _jsx("path", { d: "M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h5" }), _jsx("path", { d: "m16 19 2 2 4-4" })] }));
|
|
7
|
+
}
|
|
8
|
+
export function SettingsIcon({ size = 16 }) {
|
|
9
|
+
return (_jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [_jsx("path", { d: "M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915" }), _jsx("circle", { cx: "12", cy: "12", r: "3" })] }));
|
|
10
|
+
}
|
|
11
|
+
export function ChevronDownIcon({ size = 18, up = false }) {
|
|
12
|
+
return (_jsx("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", style: { transform: up ? "rotate(180deg)" : undefined }, "aria-hidden": true, children: _jsx("path", { d: "m6 9 6 6 6-6" }) }));
|
|
13
|
+
}
|
|
14
|
+
export function SearchIcon({ size = 16 }) {
|
|
15
|
+
return (_jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [_jsx("path", { d: "m21 21-4.34-4.34" }), _jsx("circle", { cx: "11", cy: "11", r: "8" })] }));
|
|
16
|
+
}
|
|
17
|
+
export function FuelIcon({ size = 14 }) {
|
|
18
|
+
return (_jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", role: "img", "aria-label": "Network cost", children: [_jsx("path", { d: "M14 13h2a2 2 0 0 1 2 2v2a2 2 0 0 0 4 0v-6.998a2 2 0 0 0-.59-1.42L18 5" }), _jsx("path", { d: "M14 21V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v16" }), _jsx("path", { d: "M2 21h13" }), _jsx("path", { d: "M3 9h11" })] }));
|
|
19
|
+
}
|
|
20
|
+
export function CloseIcon({ size = 20 }) {
|
|
21
|
+
return (_jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [_jsx("path", { d: "M18 6 6 18" }), _jsx("path", { d: "m6 6 12 12" })] }));
|
|
22
|
+
}
|
|
23
|
+
export function UnplugIcon({ size = 16 }) {
|
|
24
|
+
return (_jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [_jsx("path", { d: "m19 5 3-3" }), _jsx("path", { d: "m2 22 3-3" }), _jsx("path", { d: "M6.3 11.7 9 9l6 6-2.7 2.7a4.24 4.24 0 0 1-6-6Z" }), _jsx("path", { d: "m8 2 2.1 2.1" }), _jsx("path", { d: "M14 2.1 15.9 4" }), _jsx("path", { d: "m20 8-2.1-2.1" }), _jsx("path", { d: "M21.9 14 20 12.1" })] }));
|
|
25
|
+
}
|
|
26
|
+
export function ArrowDownIcon({ size = 18, rotated = false }) {
|
|
27
|
+
return (_jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", style: {
|
|
28
|
+
transform: rotated ? "rotate(180deg)" : undefined,
|
|
29
|
+
transition: "transform 300ms ease",
|
|
30
|
+
}, "aria-hidden": true, children: [_jsx("path", { d: "M12 5v14" }), _jsx("path", { d: "m19 12-7 7-7-7" })] }));
|
|
31
|
+
}
|
|
32
|
+
export function CheckIcon({ size = 16 }) {
|
|
33
|
+
return (_jsx("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", "aria-hidden": true, children: _jsx("path", { d: "m5 12 4 4L19 6" }) }));
|
|
34
|
+
}
|
|
35
|
+
export function StatusDot({ size = 8 }) {
|
|
36
|
+
return (_jsx("svg", { width: size, height: size, viewBox: "0 0 8 8", fill: "currentColor", "aria-hidden": true, children: _jsx("circle", { cx: "4", cy: "4", r: "3" }) }));
|
|
37
|
+
}
|
|
38
|
+
export function ArrowRightIcon({ size = 24 }) {
|
|
39
|
+
return (_jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [_jsx("path", { d: "M5 12h14" }), _jsx("path", { d: "m13 6 6 6-6 6" })] }));
|
|
40
|
+
}
|
|
41
|
+
export function AlertCircleIcon({ size = 24 }) {
|
|
42
|
+
return (_jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [_jsx("circle", { cx: "12", cy: "12", r: "10" }), _jsx("path", { d: "M12 8v4" }), _jsx("path", { d: "M12 16h.01" })] }));
|
|
43
|
+
}
|
|
44
|
+
export function InfoIcon({ size = 14 }) {
|
|
45
|
+
return (_jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: [_jsx("circle", { cx: "12", cy: "12", r: "10" }), _jsx("path", { d: "M12 10.75v6", fill: "none", stroke: "var(--sk-surface)", strokeWidth: "2", strokeLinecap: "round" }), _jsx("circle", { cx: "12", cy: "7.25", r: "1.15", fill: "var(--sk-surface)" })] }));
|
|
46
|
+
}
|
|
47
|
+
export function WarningIcon({ size = 14 }) {
|
|
48
|
+
return (_jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [_jsx("path", { d: "m21.7 18-8-14a2 2 0 0 0-3.4 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.7-3Z" }), _jsx("path", { d: "M12 9v4" }), _jsx("path", { d: "M12 17h.01" })] }));
|
|
49
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type PropsWithChildren } from "react";
|
|
2
|
+
interface ModalProps extends PropsWithChildren {
|
|
3
|
+
open: boolean;
|
|
4
|
+
title: string;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
closeDisabled?: boolean;
|
|
7
|
+
preventDismiss?: boolean;
|
|
8
|
+
maxWidth?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function Modal({ open, title, onClose, closeDisabled, preventDismiss, maxWidth, children, }: ModalProps): import("react").ReactPortal | null;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FocusTrap } from "@coin-voyage/shared/hooks";
|
|
3
|
+
import { useEffect, useId, useRef } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { useSwapKit } from "../providers/swapkit-context";
|
|
6
|
+
import { SwapKitRoot } from "../styles/root";
|
|
7
|
+
import { CloseIcon } from "./icons";
|
|
8
|
+
import { Dialog, DialogCloseButton, DialogHeader, Overlay } from "./styles";
|
|
9
|
+
export function Modal({ open, title, onClose, closeDisabled = false, preventDismiss = false, maxWidth, children, }) {
|
|
10
|
+
const { mode, theme } = useSwapKit();
|
|
11
|
+
const previousFocus = useRef(null);
|
|
12
|
+
const onCloseRef = useRef(onClose);
|
|
13
|
+
const passiveDismissDisabledRef = useRef(closeDisabled || preventDismiss);
|
|
14
|
+
const titleId = useId();
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
onCloseRef.current = onClose;
|
|
17
|
+
passiveDismissDisabledRef.current = closeDisabled || preventDismiss;
|
|
18
|
+
}, [closeDisabled, onClose, preventDismiss]);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (!open)
|
|
21
|
+
return;
|
|
22
|
+
previousFocus.current = document.activeElement;
|
|
23
|
+
const onKeyDown = (event) => {
|
|
24
|
+
if (event.key === "Escape" && !passiveDismissDisabledRef.current)
|
|
25
|
+
onCloseRef.current();
|
|
26
|
+
};
|
|
27
|
+
document.addEventListener("keydown", onKeyDown);
|
|
28
|
+
return () => {
|
|
29
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
30
|
+
previousFocus.current?.focus();
|
|
31
|
+
};
|
|
32
|
+
}, [open]);
|
|
33
|
+
if (!open || typeof document === "undefined")
|
|
34
|
+
return null;
|
|
35
|
+
const closeFromOverlay = (event) => {
|
|
36
|
+
if (event.target === event.currentTarget && !closeDisabled && !preventDismiss)
|
|
37
|
+
onClose();
|
|
38
|
+
};
|
|
39
|
+
return createPortal(_jsx(SwapKitRoot, { "$mode": mode, "$customTheme": theme, "data-swapkit-portal": "", children: _jsx(Overlay, { onMouseDown: closeFromOverlay, children: _jsx(Dialog, { "$maxWidth": maxWidth, role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, children: _jsxs(FocusTrap, { children: [_jsxs(DialogHeader, { children: [_jsx("h2", { id: titleId, children: title }), !closeDisabled && (_jsx(DialogCloseButton, { type: "button", "aria-label": "Close dialog", onClick: onClose, children: _jsx(CloseIcon, {}) }))] }), children] }) }) }) }), document.body);
|
|
40
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
export declare const FormStack: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export declare const Toolbar: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const ToolbarGroup: import("styled-components").StyledComponent<"div", any, {
|
|
4
|
+
$pushRight?: boolean;
|
|
5
|
+
}, never>;
|
|
6
|
+
export declare const IconButton: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
7
|
+
export declare const WalletLabel: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
8
|
+
export declare const FloatingPanel: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
|
+
export declare const SettingsPanel: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
10
|
+
export declare const SettingsRow: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
11
|
+
export declare const SettingsLabel: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
12
|
+
export declare const InfoWrap: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
13
|
+
export declare const InfoButton: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
14
|
+
export declare const SettingsTooltip: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
15
|
+
export declare const SlippageControl: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
16
|
+
export declare const SlippageModeButton: import("styled-components").StyledComponent<"button", any, {
|
|
17
|
+
$active: boolean;
|
|
18
|
+
}, never>;
|
|
19
|
+
export declare const SlippageInputWrap: import("styled-components").StyledComponent<"label", any, {
|
|
20
|
+
$active: boolean;
|
|
21
|
+
}, never>;
|
|
22
|
+
export declare const SlippageInput: import("styled-components").StyledComponent<"input", any, {}, never>;
|
|
23
|
+
export declare const FieldLabel: import("styled-components").StyledComponent<"label", any, {}, never>;
|
|
24
|
+
export declare const CompactInput: import("styled-components").StyledComponent<"input", any, {}, never>;
|
|
25
|
+
export declare const Hint: import("styled-components").StyledComponent<"p", any, {
|
|
26
|
+
$tone?: "muted" | "warning" | "danger";
|
|
27
|
+
}, never>;
|
|
28
|
+
export declare const CardWrap: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
29
|
+
export declare const CurrencyCard: import("styled-components").StyledComponent<"section", any, {}, never>;
|
|
30
|
+
export declare const CardTitle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
31
|
+
export declare const AmountRow: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
32
|
+
export declare const AmountInput: import("styled-components").StyledComponent<"input", any, {}, never>;
|
|
33
|
+
export declare const AmountSkeleton: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
34
|
+
export declare const QuoteValueSkeleton: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
35
|
+
export declare const TokenButton: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
36
|
+
export declare const TokenIconWrap: import("styled-components").StyledComponent<"span", any, {
|
|
37
|
+
$size: number;
|
|
38
|
+
}, never>;
|
|
39
|
+
export declare const TokenImage: import("styled-components").StyledComponent<"img", any, {}, never>;
|
|
40
|
+
export declare const TokenFallback: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
41
|
+
export declare const ChainBadge: import("styled-components").StyledComponent<"span", any, {
|
|
42
|
+
$fillBackground: boolean;
|
|
43
|
+
$size: number;
|
|
44
|
+
}, never>;
|
|
45
|
+
export declare const CardFooter: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
46
|
+
export declare const InlineActions: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
47
|
+
export declare const TextButton: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
48
|
+
export declare const OutputWalletControl: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
49
|
+
export declare const OutputWalletTrigger: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
50
|
+
export declare const OutputWalletMenu: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
51
|
+
export declare const OutputWalletOption: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
52
|
+
export declare const SwitchButton: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
53
|
+
export declare const BreakdownCard: import("styled-components").StyledComponent<"section", any, {}, never>;
|
|
54
|
+
export declare const BreakdownToggle: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
55
|
+
export declare const BreakdownMeta: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
56
|
+
export declare const NetworkCost: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
57
|
+
export declare const BreakdownBody: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
58
|
+
export declare const DetailRow: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
59
|
+
export declare const FreeFeeBadge: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
60
|
+
export declare const ErrorBox: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
61
|
+
export declare const PrimaryButton: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
62
|
+
export declare const WalletRequirementButton: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
63
|
+
export declare const Overlay: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
64
|
+
export declare const Dialog: import("styled-components").StyledComponent<"div", any, {
|
|
65
|
+
$maxWidth?: number;
|
|
66
|
+
}, never>;
|
|
67
|
+
export declare const DialogHeader: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
68
|
+
export declare const DialogCloseButton: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
69
|
+
export declare const SearchInput: import("styled-components").StyledComponent<"input", any, {}, never>;
|
|
70
|
+
export declare const SearchField: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
71
|
+
export declare const PickerBody: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
72
|
+
export declare const PickerControls: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
73
|
+
export declare const NetworkButton: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
74
|
+
export declare const NetworkMenu: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
75
|
+
export declare const NetworkOption: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
76
|
+
export declare const NetworkLogo: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
77
|
+
export declare const AllNetworksLogo: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
78
|
+
export declare const TokenList: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
79
|
+
export declare const TokenOption: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
80
|
+
export declare const TokenMeta: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
81
|
+
export declare const TokenBalance: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
82
|
+
export declare const EmptyState: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
83
|
+
export declare const WalletList: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
84
|
+
export declare const WalletOption: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
85
|
+
export declare const WalletIconFrame: import("styled-components").StyledComponent<"span", any, {
|
|
86
|
+
$size?: number;
|
|
87
|
+
}, never>;
|
|
88
|
+
export declare const WalletImage: import("styled-components").StyledComponent<"img", any, {}, never>;
|
|
89
|
+
export declare const WalletFallback: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
90
|
+
export declare const WalletOptionMeta: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
91
|
+
export declare const MultichainBadge: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
92
|
+
export declare const ConnectedWalletPanel: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
93
|
+
export declare const WalletPanelHeader: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
94
|
+
export declare const ConnectedWalletRow: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
95
|
+
export declare const WalletIdentity: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
96
|
+
export declare const WalletDetails: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
97
|
+
export declare const WalletDisconnectButton: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
98
|
+
export declare const DisconnectAllButton: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
99
|
+
export declare const TriggerWalletIcons: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
100
|
+
export declare const ExecutionContent: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
101
|
+
export declare const TokenRoute: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
102
|
+
export declare const TokenAmount: import("styled-components").StyledComponent<"div", any, {
|
|
103
|
+
$align?: "start" | "end";
|
|
104
|
+
}, never>;
|
|
105
|
+
export declare const RouteArrow: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
106
|
+
export declare const ProgressList: import("styled-components").StyledComponent<"ol", any, {}, never>;
|
|
107
|
+
export declare const ProgressItem: import("styled-components").StyledComponent<"li", any, {}, never>;
|
|
108
|
+
export declare const ProgressMarkerColumn: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
109
|
+
export declare const ProgressMarker: import("styled-components").StyledComponent<"span", any, {
|
|
110
|
+
$tone: "active" | "complete" | "muted" | "danger" | "warning";
|
|
111
|
+
}, never>;
|
|
112
|
+
export declare const ProgressConnector: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
113
|
+
export declare const ProgressText: import("styled-components").StyledComponent<"span", any, {
|
|
114
|
+
$connected?: boolean;
|
|
115
|
+
}, never>;
|
|
116
|
+
export declare const ProgressLabel: import("styled-components").StyledComponent<"small", any, {
|
|
117
|
+
$tone: "active" | "complete" | "muted" | "danger" | "warning";
|
|
118
|
+
}, never>;
|
|
119
|
+
export declare const ExplorerLink: import("styled-components").StyledComponent<"a", any, {}, never>;
|
|
120
|
+
export declare const ExecutionState: import("styled-components").StyledComponent<"div", any, {
|
|
121
|
+
$tone?: "danger";
|
|
122
|
+
}, never>;
|
|
123
|
+
export declare const Spinner: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
124
|
+
export declare const SrOnly: import("styled-components").StyledComponent<"span", any, {}, never>;
|