@edel-finance/swap-widget 0.1.6-alpha → 0.1.8-alpha

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/widget.d.ts CHANGED
@@ -5,6 +5,7 @@ export declare const SWAP_STATUS_STEPS: ReadonlyArray<{
5
5
  status: SwapOrderStatus;
6
6
  label: string;
7
7
  }>;
8
+ export declare const SWAP_RAIL_STEPS: readonly ["Quote", "Review", "Sign", "Settled"];
8
9
  export declare const DEFAULT_SWAP_ASSETS: readonly ["CC", "USDCx", "EDELx", "NVDAe", "SPYe", "QQQe", "SPCXe", "ANTe", "TTWOe"];
9
10
  /** Alpine Forest II slippage presets: 1.0% (default), 2.0%, 3.0%. */
10
11
  export declare const SLIPPAGE_PRESETS_BPS: readonly [100, 200, 300];
@@ -21,6 +22,14 @@ export declare function resolveInitialSlippageBps(bps?: number): number;
21
22
  * Returns null if the input is outside 0.01%..50.00% (1..5000 bps).
22
23
  */
23
24
  export declare function parseCustomSlippagePercent(raw: string): number | null;
25
+ export interface SwapRailProgress {
26
+ index: 0 | 1 | 2 | 3;
27
+ complete: boolean;
28
+ }
29
+ /**
30
+ * Map current swap quote / order state to the 4-step top progress rail.
31
+ */
32
+ export declare function getSwapRailProgress(quote: SwapQuote | null, order: SwapOrder | null): SwapRailProgress;
24
33
  export interface EdelSwapWidgetProps {
25
34
  /** Integrator / partner identifier for fee attribution (SuperNova, Loop, etc.). */
26
35
  integratorId?: string;
@@ -73,4 +82,8 @@ export declare function formatPresetPercent(bps: number): string;
73
82
  * Ignores markets with logoUnavailable === true or non-HTTPS URLs.
74
83
  */
75
84
  export declare function extractMarketLogoUrls(markets: readonly MarketSummary[]): Record<string, string>;
85
+ /**
86
+ * Filter token options by symbol or display name (case-insensitive).
87
+ */
88
+ export declare function filterTokenOptions(options: readonly string[], query: string, assetNames?: Readonly<Record<string, string>>): string[];
76
89
  export declare function EdelSwapWidget(props: EdelSwapWidgetProps): import("react").JSX.Element;
package/dist/widget.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { DEFAULT_MAX_SLIPPAGE_BPS, DEFAULT_QUOTE_TTL_SECONDS, EdelClient, MAX_SLIPPAGE_BPS, MIN_SLIPPAGE_BPS, } from "@edel-finance/sdk";
3
3
  import { useEffect, useMemo, useRef, useState } from "react";
4
- import { EdelBrandMark, isValidHttpsLogoUrl, TokenLogo } from "./logos.js";
4
+ import { EdelBrandMark, getTokenDisplayName, isValidHttpsLogoUrl, TokenOnChainLogo, } from "./logos.js";
5
5
  import { getIsolatedWidgetCss } from "./theme.js";
6
6
  export const SWAP_STATUS_STEPS = [
7
7
  { status: "quoted", label: "Quoted" },
@@ -10,6 +10,7 @@ export const SWAP_STATUS_STEPS = [
10
10
  { status: "filled", label: "Filled" },
11
11
  { status: "settled", label: "Settled" },
12
12
  ];
13
+ export const SWAP_RAIL_STEPS = ["Quote", "Review", "Sign", "Settled"];
13
14
  export const DEFAULT_SWAP_ASSETS = [
14
15
  "CC",
15
16
  "USDCx",
@@ -56,6 +57,21 @@ export function parseCustomSlippagePercent(raw) {
56
57
  return null;
57
58
  return bps;
58
59
  }
60
+ /**
61
+ * Map current swap quote / order state to the 4-step top progress rail.
62
+ */
63
+ export function getSwapRailProgress(quote, order) {
64
+ if (order) {
65
+ if (order.status === "settled")
66
+ return { index: 3, complete: true };
67
+ if (order.status === "filled")
68
+ return { index: 3, complete: false };
69
+ return { index: 2, complete: false };
70
+ }
71
+ if (quote)
72
+ return { index: 1, complete: false };
73
+ return { index: 0, complete: false };
74
+ }
59
75
  export function getStepState(stepStatus, currentStatus) {
60
76
  const order = SWAP_STATUS_STEPS.map((s) => s.status);
61
77
  const stepIdx = order.indexOf(stepStatus);
@@ -100,40 +116,41 @@ export function extractMarketLogoUrls(markets) {
100
116
  }
101
117
  return map;
102
118
  }
103
- function TokenSelector({ ariaLabel, value, options, logoUrls, onChange, testId, }) {
104
- const [open, setOpen] = useState(false);
105
- const containerRef = useRef(null);
119
+ /**
120
+ * Filter token options by symbol or display name (case-insensitive).
121
+ */
122
+ export function filterTokenOptions(options, query, assetNames) {
123
+ const q = query.trim().toLowerCase();
124
+ if (!q)
125
+ return [...options];
126
+ return options.filter((sym) => {
127
+ const name = getTokenDisplayName(sym, assetNames?.[sym]).toLowerCase();
128
+ return sym.toLowerCase().includes(q) || name.includes(q);
129
+ });
130
+ }
131
+ function TokenPickerButton({ ariaLabel, value, open, logoUrls, onToggle, testId, }) {
132
+ return (_jsx("div", { className: "edel-sw-token-picker", "data-testid": testId, children: _jsxs("button", { type: "button", className: "edel-sw-token-trigger", "aria-label": ariaLabel, "aria-haspopup": "listbox", "aria-expanded": open, "data-selected-asset": value, onClick: onToggle, children: [_jsx(TokenOnChainLogo, { symbol: value, size: 24, className: "edel-sw-token-icon", logoUrl: logoUrls?.[value] }), _jsx("span", { className: "edel-sw-token-symbol", children: value }), _jsx("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "edel-sw-token-chevron", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M4 6L8 10L12 6", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" }) })] }) }));
133
+ }
134
+ function TokenDropdown({ ariaLabel, value, options, assetNames, logoUrls, onSelect, onClose, testId, }) {
135
+ const [query, setQuery] = useState("");
136
+ const inputRef = useRef(null);
106
137
  useEffect(() => {
107
- if (!open)
108
- return;
109
- const handlePointerDown = (event) => {
110
- const container = containerRef.current;
111
- if (!container)
112
- return;
113
- const path = typeof event.composedPath === "function" ? event.composedPath() : [];
114
- if (path.length > 0 ? !path.includes(container) : !container.contains(event.target)) {
115
- setOpen(false);
116
- }
117
- };
118
- const handleKeyDown = (event) => {
119
- if (event.key === "Escape") {
120
- setOpen(false);
121
- }
122
- };
123
- document.addEventListener("pointerdown", handlePointerDown);
124
- document.addEventListener("keydown", handleKeyDown);
125
- return () => {
126
- document.removeEventListener("pointerdown", handlePointerDown);
127
- document.removeEventListener("keydown", handleKeyDown);
128
- };
129
- }, [open]);
130
- return (_jsxs("div", { className: "edel-sw-token-picker", ref: containerRef, "data-testid": testId, children: [_jsxs("button", { type: "button", className: "edel-sw-token-trigger", "aria-label": ariaLabel, "aria-haspopup": "listbox", "aria-expanded": open, "data-selected-asset": value, onClick: () => setOpen((prev) => !prev), children: [_jsx(TokenLogo, { symbol: value, size: 22, className: "edel-sw-token-icon", logoUrl: logoUrls?.[value] }), _jsx("span", { className: "edel-sw-token-symbol", children: value }), _jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "edel-sw-token-chevron", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M3 4.5L6 7.5L9 4.5", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" }) })] }), open && (_jsx("div", { className: "edel-sw-token-menu", role: "listbox", "aria-label": ariaLabel, children: options.map((sym) => {
138
+ inputRef.current?.focus();
139
+ }, []);
140
+ const filtered = useMemo(() => filterTokenOptions(options, query, assetNames), [options, query, assetNames]);
141
+ return (_jsxs("div", { className: "edel-sw-token-menu", role: "listbox", "aria-label": ariaLabel, "data-testid": testId, children: [_jsxs("div", { className: "edel-sw-token-search", children: [_jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", focusable: "false", children: [_jsx("circle", { cx: "11", cy: "11", r: "7", stroke: "currentColor", strokeWidth: "2" }), _jsx("path", { d: "M20 20L16.65 16.65", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" })] }), _jsx("input", { ref: inputRef, type: "search", placeholder: "Search token...", "aria-label": "Search token", value: query, onChange: (e) => setQuery(e.target.value), onKeyDown: (e) => {
142
+ if (e.key === "Escape") {
143
+ e.stopPropagation();
144
+ onClose();
145
+ }
146
+ } })] }), _jsx("div", { className: "edel-sw-token-list", children: filtered.length === 0 ? (_jsxs("div", { className: "edel-sw-token-empty", children: ["No tokens matching \u201C", query.trim(), "\u201D"] })) : (filtered.map((sym) => {
131
147
  const selected = sym === value;
148
+ const displayName = getTokenDisplayName(sym, assetNames?.[sym]);
132
149
  return (_jsxs("button", { type: "button", role: "option", "aria-selected": selected, className: "edel-sw-token-option", "data-token-option": sym, onClick: () => {
133
- onChange(sym);
134
- setOpen(false);
135
- }, children: [_jsxs("span", { className: "edel-sw-token-option-main", children: [_jsx(TokenLogo, { symbol: sym, size: 20, className: "edel-sw-token-icon", logoUrl: logoUrls?.[sym] }), _jsx("span", { children: sym })] }), selected && (_jsx("span", { className: "edel-sw-token-check", "aria-hidden": "true", children: "\u2713" }))] }, sym));
136
- }) }))] }));
150
+ onSelect(sym);
151
+ onClose();
152
+ }, children: [_jsx(TokenOnChainLogo, { symbol: sym, size: 28, className: "edel-sw-token-icon", logoUrl: logoUrls?.[sym] }), _jsxs("span", { className: "edel-sw-token-option-text", children: [_jsx("strong", { children: sym }), _jsx("span", { children: displayName })] }), _jsx("span", { className: "edel-sw-token-option-aside", children: "Canton" }), _jsx("span", { className: "edel-sw-token-check", "aria-hidden": "true", children: selected ? (_jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M5 13L9.5 17.5L19 7.5", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round" }) })) : null })] }, sym));
153
+ })) })] }));
137
154
  }
138
155
  export function EdelSwapWidget(props) {
139
156
  const { integratorId, partnerId, theme = "dark", network = "mainnet", defaultFrom, defaultTo, defaultFromAsset, defaultToAsset, defaultMaxSlippageBps, recipientAddress = "", integratorFeeBps, client: providedClient, initialQuote = null, initialOrder = null, initialLogoUrls, onQuote, onSlippageChange, onSwapComplete, onOrderSubmitted, onError, style, } = props;
@@ -159,18 +176,58 @@ export function EdelSwapWidget(props) {
159
176
  const [submittingSigned, setSubmittingSigned] = useState(false);
160
177
  const [errorMessage, setErrorMessage] = useState(null);
161
178
  const [remainingSec, setRemainingSec] = useState(initialQuote?.ttlSeconds ?? DEFAULT_WIDGET_QUOTE_TTL_SECONDS);
179
+ const [openPicker, setOpenPicker] = useState(null);
180
+ const [flipCount, setFlipCount] = useState(0);
162
181
  const completedRef = useRef(null);
163
- const assetSymbols = useMemo(() => {
164
- if (pairs.length === 0)
165
- return [...DEFAULT_SWAP_ASSETS];
182
+ const pairRef = useRef(null);
183
+ // Close open token dropdown on outside click or Escape
184
+ useEffect(() => {
185
+ if (!openPicker)
186
+ return;
187
+ const handlePointerDown = (event) => {
188
+ const container = pairRef.current;
189
+ if (!container)
190
+ return;
191
+ const path = typeof event.composedPath === "function" ? event.composedPath() : [];
192
+ if (path.length > 0 ? !path.includes(container) : !container.contains(event.target)) {
193
+ setOpenPicker(null);
194
+ }
195
+ };
196
+ const handleKeyDown = (event) => {
197
+ if (event.key === "Escape") {
198
+ setOpenPicker(null);
199
+ }
200
+ };
201
+ document.addEventListener("pointerdown", handlePointerDown);
202
+ document.addEventListener("keydown", handleKeyDown);
203
+ return () => {
204
+ document.removeEventListener("pointerdown", handlePointerDown);
205
+ document.removeEventListener("keydown", handleKeyDown);
206
+ };
207
+ }, [openPicker]);
208
+ const { assetSymbols, assetNames } = useMemo(() => {
209
+ if (pairs.length === 0) {
210
+ return {
211
+ assetSymbols: [...DEFAULT_SWAP_ASSETS],
212
+ assetNames: {},
213
+ };
214
+ }
166
215
  const set = new Set();
216
+ const names = {};
167
217
  for (const pair of pairs) {
168
218
  if (pair.active) {
169
219
  set.add(pair.fromAsset.symbol);
170
220
  set.add(pair.toAsset.symbol);
221
+ if (pair.fromAsset.name)
222
+ names[pair.fromAsset.symbol] = pair.fromAsset.name;
223
+ if (pair.toAsset.name)
224
+ names[pair.toAsset.symbol] = pair.toAsset.name;
171
225
  }
172
226
  }
173
- return set.size > 0 ? Array.from(set) : [...DEFAULT_SWAP_ASSETS];
227
+ return {
228
+ assetSymbols: set.size > 0 ? Array.from(set) : [...DEFAULT_SWAP_ASSETS],
229
+ assetNames: names,
230
+ };
174
231
  }, [pairs]);
175
232
  // Hydrate tradable swap pairs and official token logos from @edel-finance/sdk
176
233
  useEffect(() => {
@@ -305,8 +362,24 @@ export function EdelSwapWidget(props) {
305
362
  };
306
363
  }, [client, activeOrderId, activeOrderStatus, onSwapComplete]);
307
364
  const handleFlip = () => {
308
- setFromAsset(toAsset);
309
- setToAsset(fromAsset);
365
+ const prevFrom = fromAsset;
366
+ const prevTo = toAsset;
367
+ setFromAsset(prevTo);
368
+ setToAsset(prevFrom);
369
+ setFlipCount((c) => c + 1);
370
+ setOpenPicker(null);
371
+ };
372
+ const handleSelectFromAsset = (next) => {
373
+ if (next === toAsset) {
374
+ setToAsset(fromAsset);
375
+ }
376
+ setFromAsset(next);
377
+ };
378
+ const handleSelectToAsset = (next) => {
379
+ if (next === fromAsset) {
380
+ setFromAsset(toAsset);
381
+ }
382
+ setToAsset(next);
310
383
  };
311
384
  const handleSelectPreset = (bps) => {
312
385
  setCustomMode(false);
@@ -380,13 +453,21 @@ export function EdelSwapWidget(props) {
380
453
  const ttlPercent = quote && effectiveTtlSeconds > 0
381
454
  ? Math.max(0, Math.min(100, (remainingSec / effectiveTtlSeconds) * 100))
382
455
  : 0;
456
+ const parsedFromAmount = Number(fromAmount);
457
+ const hasPositiveAmount = Number.isFinite(parsedFromAmount) && parsedFromAmount > 0;
383
458
  const canSubmitOrder = order !== null && (order.status === "quoted" || order.status === "awaiting_lock");
384
- return (_jsxs("div", { className: "edel-sw-root", "data-edel-theme": theme, "data-edel-network": network, "data-max-slippage-bps": maxSlippageBps, style: style, children: [_jsx("style", { children: getIsolatedWidgetCss(theme) }), _jsxs("div", { className: "edel-sw-header", children: [_jsxs("span", { className: "edel-sw-brand", children: [_jsx(EdelBrandMark, { size: 22, className: "edel-sw-brand-mark" }), _jsx("span", { className: "edel-sw-title", children: "Edel Swap" })] }), _jsx("span", { className: "edel-sw-badge", children: network === "mainnet" ? "MainNet" : "TestNet" })] }), _jsxs("div", { className: "edel-sw-box", children: [_jsx("div", { className: "edel-sw-label", children: "You pay" }), _jsxs("div", { className: "edel-sw-row", children: [_jsx("input", { "aria-label": "From amount", className: "edel-sw-input", inputMode: "decimal", value: fromAmount, onChange: (e) => setFromAmount(e.target.value), placeholder: "0.00" }), _jsx(TokenSelector, { ariaLabel: "From asset", testId: "from-asset-selector", value: fromAsset, options: assetSymbols, logoUrls: logoUrls, onChange: setFromAsset })] })] }), _jsx("div", { className: "edel-sw-flip-wrap", children: _jsx("button", { type: "button", className: "edel-sw-flip", "aria-label": "Flip swap pair", onClick: handleFlip, children: "\u2195" }) }), _jsxs("div", { className: "edel-sw-box", children: [_jsx("div", { className: "edel-sw-label", children: "You receive" }), _jsxs("div", { className: "edel-sw-row", children: [_jsx("input", { "aria-label": "To amount", className: "edel-sw-input", readOnly: true, value: loadingQuote ? "..." : (quote?.toAmount ?? "0.00") }), _jsx(TokenSelector, { ariaLabel: "To asset", testId: "to-asset-selector", value: toAsset, options: assetSymbols, logoUrls: logoUrls, onChange: setToAsset })] })] }), _jsxs("div", { className: "edel-sw-slippage", "data-testid": "slippage-selector", children: [_jsxs("div", { className: "edel-sw-slippage-header", children: [_jsx("span", { children: "Max slippage" }), _jsx("strong", { children: formatBps(maxSlippageBps) })] }), _jsxs("fieldset", { className: "edel-sw-slippage-pills", "aria-label": "Max slippage presets", children: [SLIPPAGE_PRESETS_BPS.map((bps) => {
459
+ const rail = getSwapRailProgress(quote, order);
460
+ return (_jsxs("div", { className: "edel-sw-root", "data-edel-theme": theme, "data-edel-network": network, "data-max-slippage-bps": maxSlippageBps, style: style, children: [_jsx("style", { children: getIsolatedWidgetCss(theme) }), _jsxs("div", { className: "edel-sw-header", children: [_jsxs("span", { className: "edel-sw-brand", children: [_jsx(EdelBrandMark, { size: 20, className: "edel-sw-brand-mark" }), _jsx("span", { className: "edel-sw-title", children: "Edel Swap" })] }), _jsx("span", { className: "edel-sw-badge", children: network === "mainnet" ? "MainNet" : "TestNet" })] }), _jsx("ol", { className: "edel-sw-rail", "aria-label": "Swap steps", "data-testid": "swap-step-rail", children: SWAP_RAIL_STEPS.map((label, idx) => {
461
+ const state = rail.complete || idx < rail.index ? "done" : idx === rail.index ? "current" : "next";
462
+ return (_jsx("li", { className: "edel-sw-rail-step", "data-state": state, "aria-current": state === "current" ? "step" : undefined, children: _jsxs("span", { className: "edel-sw-rail-inner", children: [_jsx("span", { className: "edel-sw-rail-marker", "aria-hidden": "true", children: state === "done" ? (_jsx("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M5 13L9.5 17.5L19 7.5", stroke: "currentColor", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round" }) })) : (idx + 1) }), _jsx("span", { className: "edel-sw-rail-label", children: label })] }) }, label));
463
+ }) }), _jsxs("div", { className: "edel-sw-pair", ref: pairRef, children: [_jsxs("div", { className: "edel-sw-box-wrap", children: [_jsxs("div", { className: "edel-sw-box", "data-pay": "true", children: [_jsxs("div", { className: "edel-sw-label", children: [_jsx("span", { children: "You send" }), _jsx("span", { className: "edel-sw-label-meta", children: "Canton Network" })] }), _jsxs("div", { className: "edel-sw-row", children: [_jsx("input", { "aria-label": "From amount", className: "edel-sw-input", inputMode: "decimal", value: fromAmount, onChange: (e) => setFromAmount(e.target.value), placeholder: "0" }), _jsx(TokenPickerButton, { ariaLabel: "From asset", testId: "from-asset-selector", value: fromAsset, open: openPicker === "from", logoUrls: logoUrls, onToggle: () => setOpenPicker((prev) => (prev === "from" ? null : "from")) })] }), _jsx("div", { className: "edel-sw-box-sub", children: _jsx("span", { children: getTokenDisplayName(fromAsset, assetNames[fromAsset]) }) })] }), openPicker === "from" && (_jsx(TokenDropdown, { ariaLabel: "Select token to send", testId: "from-asset-dropdown", value: fromAsset, options: assetSymbols, assetNames: assetNames, logoUrls: logoUrls, onSelect: handleSelectFromAsset, onClose: () => setOpenPicker(null) }))] }), _jsx("button", { type: "button", className: "edel-sw-flip", "aria-label": "Flip swap pair", "data-testid": "flip-pair-btn", "data-flip-count": flipCount, onClick: handleFlip, children: _jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "edel-sw-flip-icon", style: { transform: `rotate(${flipCount * 180}deg)` }, "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M7 4V20M7 4L3.5 7.5M7 4L10.5 7.5M17 20V4M17 20L13.5 16.5M17 20L20.5 16.5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }), _jsxs("div", { className: "edel-sw-box-wrap", children: [_jsxs("div", { className: "edel-sw-box", children: [_jsxs("div", { className: "edel-sw-label", children: [_jsx("span", { children: "You receive" }), quote?.estimatedSeconds !== undefined && (_jsxs("span", { className: "edel-sw-label-meta", children: ["~", quote.estimatedSeconds, "s"] }))] }), _jsxs("div", { className: "edel-sw-row", children: [_jsx("input", { "aria-label": "To amount", className: "edel-sw-input", "data-empty": !quote && !loadingQuote ? "true" : undefined, readOnly: true, value: loadingQuote ? "..." : (quote?.toAmount ?? "0") }), _jsx(TokenPickerButton, { ariaLabel: "To asset", testId: "to-asset-selector", value: toAsset, open: openPicker === "to", logoUrls: logoUrls, onToggle: () => setOpenPicker((prev) => (prev === "to" ? null : "to")) })] }), _jsx("div", { className: "edel-sw-box-sub", children: _jsx("span", { children: getTokenDisplayName(toAsset, assetNames[toAsset]) }) })] }), openPicker === "to" && (_jsx(TokenDropdown, { ariaLabel: "Select token to receive", testId: "to-asset-dropdown", value: toAsset, options: assetSymbols, assetNames: assetNames, logoUrls: logoUrls, onSelect: handleSelectToAsset, onClose: () => setOpenPicker(null) }))] })] }), _jsxs("div", { className: "edel-sw-slippage", "data-testid": "slippage-selector", children: [_jsxs("div", { className: "edel-sw-slippage-header", children: [_jsx("span", { children: "Max slippage" }), _jsx("strong", { children: formatBps(maxSlippageBps) })] }), _jsxs("fieldset", { className: "edel-sw-slippage-pills", "aria-label": "Max slippage presets", children: [SLIPPAGE_PRESETS_BPS.map((bps) => {
385
464
  const isActive = !customMode && maxSlippageBps === bps;
386
465
  return (_jsx("button", { type: "button", className: "edel-sw-pill", "data-slippage-bps": bps, "data-active": isActive ? "true" : "false", "aria-pressed": isActive, onClick: () => handleSelectPreset(bps), children: formatPresetPercent(bps) }, bps));
387
- }), _jsxs("div", { className: "edel-sw-custom-wrap", "data-active": customMode ? "true" : "false", children: [_jsx("input", { "aria-label": "Custom slippage percent", className: "edel-sw-custom-input", inputMode: "decimal", placeholder: "Custom", value: customSlippageInput, onFocus: () => setCustomMode(true), onChange: (e) => handleCustomSlippageChange(e.target.value) }), _jsx("span", { className: "edel-sw-custom-suffix", children: "%" })] })] })] }), quote && (_jsxs("div", { className: "edel-sw-fees", "data-testid": "quote-fee-breakdown", "data-min-amount-out-atoms": quote.minAmountOutAtoms, children: [_jsxs("div", { className: "edel-sw-fee-line", children: [_jsx("span", { children: "Rate" }), _jsxs("strong", { children: ["1 ", quote.fromAsset, " = ", quote.rate, " ", quote.toAsset] })] }), _jsxs("div", { className: "edel-sw-fee-line", children: [_jsxs("span", { children: ["Edel RFQ fee (", formatBps(quote.fees.edelRfqFeeBps), ")"] }), _jsxs("strong", { children: [quote.fees.edelRfqFeeAmount, " ", quote.toAsset] })] }), _jsxs("div", { className: "edel-sw-fee-line", children: [_jsx("span", { children: "Network fee" }), _jsxs("strong", { children: [quote.fees.networkFeeAmount, " ", quote.fees.networkFeeAsset] })] }), _jsxs("div", { className: "edel-sw-fee-line", children: [_jsxs("span", { children: ["Integrator markup (", formatBps(quote.fees.integratorFeeBps), ")"] }), _jsxs("strong", { children: [quote.fees.integratorFeeAmount, " ", quote.toAsset] })] }), _jsxs("div", { className: "edel-sw-fee-line", children: [_jsx("span", { children: "Price impact" }), _jsx("strong", { children: formatBps(quote.priceImpactBps) })] }), _jsxs("div", { className: "edel-sw-fee-line", children: [_jsx("span", { children: "Min received" }), _jsxs("strong", { children: [quote.minReceived, " ", quote.toAsset] })] }), quote.minAmountOutAtoms !== undefined && (_jsxs("div", { className: "edel-sw-fee-line", children: [_jsx("span", { children: "Min output (atoms)" }), _jsx("strong", { children: quote.minAmountOutAtoms })] })), quote.estimatedSeconds !== undefined && (_jsxs("div", { className: "edel-sw-fee-line", children: [_jsx("span", { children: "Estimated settlement" }), _jsxs("strong", { children: ["~", quote.estimatedSeconds, "s"] })] })), _jsxs("div", { className: "edel-sw-fee-line", children: [_jsx("span", { children: "Quote expires in" }), _jsxs("strong", { children: [remainingSec, "s"] })] }), _jsx("div", { className: "edel-sw-ttl-bar", children: _jsx("div", { className: "edel-sw-ttl-fill", style: { width: `${ttlPercent}%` } }) })] })), order && (_jsxs("div", { className: "edel-sw-tracker", "data-testid": "swap-status-tracker", children: [_jsxs("div", { className: "edel-sw-fee-line", children: [_jsxs("span", { children: ["Order ", order.swapId ?? order.orderId] }), _jsx("strong", { children: order.status })] }), _jsx("div", { className: "edel-sw-steps", children: SWAP_STATUS_STEPS.map((step) => (_jsx("div", { className: "edel-sw-step", "data-status": step.status, "data-state": getStepState(step.status, order.status), children: step.label }, step.status))) }), canSubmitOrder && (_jsx("button", { type: "button", className: "edel-sw-submit-btn", "data-testid": "submit-swap-order-btn", disabled: submittingSigned, onClick: handleSubmitOrder, children: submittingSigned ? "Submitting swap..." : "Submit Swap Order" }))] })), errorMessage && (_jsx("div", { className: "edel-sw-error", role: "alert", children: errorMessage })), _jsx("button", { type: "button", className: "edel-sw-cta", disabled: !quote || submitting || remainingSec === 0, onClick: handleSwap, children: submitting
388
- ? "Executing swap..."
389
- : loadingQuote
390
- ? "Fetching live quote..."
391
- : `Swap ${fromAsset} to ${toAsset}` })] }));
466
+ }), _jsxs("div", { className: "edel-sw-custom-wrap", "data-active": customMode ? "true" : "false", children: [_jsx("input", { "aria-label": "Custom slippage percent", className: "edel-sw-custom-input", inputMode: "decimal", placeholder: "Custom", value: customSlippageInput, onFocus: () => setCustomMode(true), onChange: (e) => handleCustomSlippageChange(e.target.value) }), _jsx("span", { className: "edel-sw-custom-suffix", children: "%" })] })] })] }), quote && (_jsxs("div", { className: "edel-sw-fees", "data-testid": "quote-fee-breakdown", "data-min-amount-out-atoms": quote.minAmountOutAtoms, children: [_jsxs("div", { className: "edel-sw-fee-line", children: [_jsx("span", { children: "Rate" }), _jsxs("strong", { children: ["1 ", quote.fromAsset, " = ", quote.rate, " ", quote.toAsset] })] }), _jsxs("div", { className: "edel-sw-fee-line", children: [_jsxs("span", { children: ["Edel RFQ fee (", formatBps(quote.fees.edelRfqFeeBps), ")"] }), _jsxs("strong", { children: [quote.fees.edelRfqFeeAmount, " ", quote.toAsset] })] }), _jsxs("div", { className: "edel-sw-fee-line", children: [_jsx("span", { children: "Network fee" }), _jsxs("strong", { children: [quote.fees.networkFeeAmount, " ", quote.fees.networkFeeAsset] })] }), _jsxs("div", { className: "edel-sw-fee-line", children: [_jsxs("span", { children: ["Integrator markup (", formatBps(quote.fees.integratorFeeBps), ")"] }), _jsxs("strong", { children: [quote.fees.integratorFeeAmount, " ", quote.toAsset] })] }), _jsxs("div", { className: "edel-sw-fee-line", children: [_jsx("span", { children: "Price impact" }), _jsx("strong", { children: formatBps(quote.priceImpactBps) })] }), _jsxs("div", { className: "edel-sw-fee-line", children: [_jsx("span", { children: "Min received" }), _jsxs("strong", { children: [quote.minReceived, " ", quote.toAsset] })] }), quote.minAmountOutAtoms !== undefined && (_jsxs("div", { className: "edel-sw-fee-line", children: [_jsx("span", { children: "Min output (atoms)" }), _jsx("strong", { children: quote.minAmountOutAtoms })] })), quote.estimatedSeconds !== undefined && (_jsxs("div", { className: "edel-sw-fee-line", children: [_jsx("span", { children: "Estimated settlement" }), _jsxs("strong", { children: ["~", quote.estimatedSeconds, "s"] })] })), _jsxs("div", { className: "edel-sw-fee-line", children: [_jsx("span", { children: "Quote expires in" }), _jsxs("strong", { children: [remainingSec, "s"] })] }), _jsx("div", { className: "edel-sw-ttl-bar", children: _jsx("div", { className: "edel-sw-ttl-fill", style: { width: `${ttlPercent}%` } }) })] })), order && (_jsxs("div", { className: "edel-sw-tracker", "data-testid": "swap-status-tracker", children: [_jsxs("div", { className: "edel-sw-fee-line", children: [_jsxs("span", { children: ["Order ", order.swapId ?? order.orderId] }), _jsx("strong", { children: order.status })] }), _jsx("div", { className: "edel-sw-steps", children: SWAP_STATUS_STEPS.map((step) => (_jsx("div", { className: "edel-sw-step", "data-status": step.status, "data-state": getStepState(step.status, order.status), children: step.label }, step.status))) }), canSubmitOrder && (_jsx("button", { type: "button", className: "edel-sw-submit-btn", "data-testid": "submit-swap-order-btn", disabled: submittingSigned, onClick: handleSubmitOrder, children: submittingSigned ? "Submitting swap..." : "Submit Swap Order" }))] })), errorMessage && (_jsx("div", { className: "edel-sw-error", role: "alert", children: errorMessage })), _jsx("button", { type: "button", className: "edel-sw-cta", disabled: !hasPositiveAmount || !quote || submitting || remainingSec === 0, onClick: handleSwap, children: !hasPositiveAmount
467
+ ? "Enter an amount"
468
+ : submitting
469
+ ? "Executing swap..."
470
+ : loadingQuote
471
+ ? "Fetching live quote..."
472
+ : `Swap ${fromAsset} to ${toAsset}` })] }));
392
473
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edel-finance/swap-widget",
3
- "version": "0.1.6-alpha",
3
+ "version": "0.1.8-alpha",
4
4
  "description": "Embeddable React, Vue 3, Svelte 5, Angular, SolidJS, Shadow DOM Web Component, and iframe Swap Widget for Edel Markets.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -32,7 +32,7 @@
32
32
  "README.md"
33
33
  ],
34
34
  "dependencies": {
35
- "@edel-finance/sdk": "0.1.6-alpha"
35
+ "@edel-finance/sdk": "0.1.8-alpha"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "react": ">=18.2.0",