@edel-finance/swap-widget 0.0.0-stage → 0.1.4-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/README.md +174 -2
- package/dist/adapters/angular.d.ts +32 -0
- package/dist/adapters/angular.js +84 -0
- package/dist/adapters/solid.d.ts +56 -0
- package/dist/adapters/solid.js +41 -0
- package/dist/adapters/svelte.d.ts +26 -0
- package/dist/adapters/svelte.js +45 -0
- package/dist/adapters/vue.d.ts +58 -0
- package/dist/adapters/vue.js +124 -0
- package/dist/embed.d.ts +89 -0
- package/dist/embed.js +264 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/theme.d.ts +26 -0
- package/dist/theme.js +323 -0
- package/dist/widget.d.ts +69 -0
- package/dist/widget.js +304 -0
- package/package.json +57 -3
package/dist/embed.d.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { EdelNetwork, SwapOrder, SwapQuote } from "@edel-finance/sdk";
|
|
2
|
+
import { createElement } from "react";
|
|
3
|
+
import { type SwapWidgetTheme } from "./theme.js";
|
|
4
|
+
import { type EdelSwapWidgetProps } from "./widget.js";
|
|
5
|
+
export interface SwapWidgetEmbedOptions {
|
|
6
|
+
/** Target Edel network (MainNet or TestNet). Defaults to "mainnet". */
|
|
7
|
+
network?: EdelNetwork;
|
|
8
|
+
/** Partner or integrator identifier for fee attribution. */
|
|
9
|
+
integratorId?: string;
|
|
10
|
+
/** Backwards-compatible alias for integratorId. */
|
|
11
|
+
partnerId?: string;
|
|
12
|
+
/** Default input asset symbol (for example "CC"). */
|
|
13
|
+
defaultFrom?: string;
|
|
14
|
+
/** Default output asset symbol (for example "USDCx"). */
|
|
15
|
+
defaultTo?: string;
|
|
16
|
+
/** Color theme for the embedded widget. Defaults to "dark". */
|
|
17
|
+
theme?: SwapWidgetTheme;
|
|
18
|
+
/** Optional custom widget host origin (defaults to Edel hosted swap embed). */
|
|
19
|
+
embedOrigin?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const SWAP_WIDGET_ORIGINS: Record<EdelNetwork, string>;
|
|
22
|
+
export declare const EDEL_SWAP_WIDGET_TAG: "edel-swap-widget";
|
|
23
|
+
export declare const EDEL_SWAP_WIDGET_EVENTS: {
|
|
24
|
+
readonly quote: "edel-swap-quote";
|
|
25
|
+
readonly complete: "edel-swap-complete";
|
|
26
|
+
readonly error: "edel-swap-error";
|
|
27
|
+
readonly slippageChange: "edel-swap-slippage-change";
|
|
28
|
+
};
|
|
29
|
+
export interface EdelSwapWidgetErrorDetail {
|
|
30
|
+
message: string;
|
|
31
|
+
error: Error;
|
|
32
|
+
}
|
|
33
|
+
export interface EdelSwapWidgetSlippageDetail {
|
|
34
|
+
maxSlippageBps: number;
|
|
35
|
+
}
|
|
36
|
+
export interface EdelSwapWidgetEventMap {
|
|
37
|
+
"edel-swap-quote": CustomEvent<SwapQuote>;
|
|
38
|
+
"edel-swap-complete": CustomEvent<SwapOrder>;
|
|
39
|
+
"edel-swap-error": CustomEvent<EdelSwapWidgetErrorDetail>;
|
|
40
|
+
"edel-swap-slippage-change": CustomEvent<EdelSwapWidgetSlippageDetail>;
|
|
41
|
+
}
|
|
42
|
+
export interface MountedEdelSwapWidget {
|
|
43
|
+
/** Update widget props without remounting the underlying React root. */
|
|
44
|
+
update(nextProps: Partial<EdelSwapWidgetProps>): void;
|
|
45
|
+
/** Unmount the widget and release DOM/React resources. */
|
|
46
|
+
unmount(): void;
|
|
47
|
+
/** Return the currently applied props snapshot. */
|
|
48
|
+
getProps(): EdelSwapWidgetProps;
|
|
49
|
+
}
|
|
50
|
+
export interface WidgetRootLike {
|
|
51
|
+
render(element: ReturnType<typeof createElement>): void;
|
|
52
|
+
unmount(): void;
|
|
53
|
+
}
|
|
54
|
+
export interface MountEdelSwapWidgetOptions {
|
|
55
|
+
/** Attach and render inside an open Shadow DOM root for full CSS isolation. Defaults to true. */
|
|
56
|
+
shadowDom?: boolean;
|
|
57
|
+
/** Dispatch standard CustomEvents on the target element for widget lifecycle events. */
|
|
58
|
+
dispatchEvents?: boolean;
|
|
59
|
+
/** Optional custom React root factory (primarily for headless unit tests). */
|
|
60
|
+
createRootImpl?: (container: Element) => WidgetRootLike;
|
|
61
|
+
}
|
|
62
|
+
export interface EdelSwapWidgetElement extends HTMLElement {
|
|
63
|
+
widgetProps: Partial<EdelSwapWidgetProps>;
|
|
64
|
+
setProps(nextProps: Partial<EdelSwapWidgetProps>): void;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Builds the canonical iframe URL for embedding the Edel Swap Widget in
|
|
68
|
+
* partner dApps (SuperNova, Loop, institutional portals) or standalone pages.
|
|
69
|
+
*/
|
|
70
|
+
export declare function buildSwapWidgetUrl(options?: SwapWidgetEmbedOptions): string;
|
|
71
|
+
/**
|
|
72
|
+
* Returns a ready-to-paste 3-line HTML iframe embed snippet for partner portals.
|
|
73
|
+
*/
|
|
74
|
+
export declare function buildSwapWidgetEmbedSnippet(options?: SwapWidgetEmbedOptions & {
|
|
75
|
+
height?: number | string;
|
|
76
|
+
}): string;
|
|
77
|
+
/**
|
|
78
|
+
* Imperatively mounts the interactive `<EdelSwapWidget />` into any DOM element,
|
|
79
|
+
* with Shadow DOM CSS isolation enabled by default so host styles in Vue, Svelte,
|
|
80
|
+
* Angular, SolidJS, or plain HTML never collide with the widget.
|
|
81
|
+
*/
|
|
82
|
+
export declare function mountEdelSwapWidget(target: HTMLElement, props?: EdelSwapWidgetProps, options?: MountEdelSwapWidgetOptions): MountedEdelSwapWidget;
|
|
83
|
+
/**
|
|
84
|
+
* Registers the `<edel-swap-widget>` Custom Element (Web Component) with Shadow DOM
|
|
85
|
+
* CSS isolation. Mounts the full interactive React `<EdelSwapWidget />` inside an open
|
|
86
|
+
* Shadow Root and dispatches standard `CustomEvent`s (`edel-swap-quote`,
|
|
87
|
+
* `edel-swap-complete`, `edel-swap-error`, `edel-swap-slippage-change`).
|
|
88
|
+
*/
|
|
89
|
+
export declare function registerEdelSwapWidgetElement(tagName?: string, options?: Pick<MountEdelSwapWidgetOptions, "createRootImpl">): void;
|
package/dist/embed.js
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
import { getIsolatedWidgetCss } from "./theme.js";
|
|
4
|
+
import { EdelSwapWidget } from "./widget.js";
|
|
5
|
+
export const SWAP_WIDGET_ORIGINS = {
|
|
6
|
+
mainnet: "https://app.edel.finance/embed/swap",
|
|
7
|
+
testnet: "https://testnet.edel.finance/embed/swap",
|
|
8
|
+
};
|
|
9
|
+
export const EDEL_SWAP_WIDGET_TAG = "edel-swap-widget";
|
|
10
|
+
export const EDEL_SWAP_WIDGET_EVENTS = {
|
|
11
|
+
quote: "edel-swap-quote",
|
|
12
|
+
complete: "edel-swap-complete",
|
|
13
|
+
error: "edel-swap-error",
|
|
14
|
+
slippageChange: "edel-swap-slippage-change",
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Builds the canonical iframe URL for embedding the Edel Swap Widget in
|
|
18
|
+
* partner dApps (SuperNova, Loop, institutional portals) or standalone pages.
|
|
19
|
+
*/
|
|
20
|
+
export function buildSwapWidgetUrl(options = {}) {
|
|
21
|
+
const network = options.network ?? "mainnet";
|
|
22
|
+
const base = options.embedOrigin ?? SWAP_WIDGET_ORIGINS[network];
|
|
23
|
+
const url = new URL(base);
|
|
24
|
+
url.searchParams.set("network", network);
|
|
25
|
+
const integrator = options.integratorId ?? options.partnerId;
|
|
26
|
+
if (integrator)
|
|
27
|
+
url.searchParams.set("integratorId", integrator);
|
|
28
|
+
if (options.defaultFrom)
|
|
29
|
+
url.searchParams.set("from", options.defaultFrom);
|
|
30
|
+
if (options.defaultTo)
|
|
31
|
+
url.searchParams.set("to", options.defaultTo);
|
|
32
|
+
if (options.theme)
|
|
33
|
+
url.searchParams.set("theme", options.theme);
|
|
34
|
+
return url.toString();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns a ready-to-paste 3-line HTML iframe embed snippet for partner portals.
|
|
38
|
+
*/
|
|
39
|
+
export function buildSwapWidgetEmbedSnippet(options = {}) {
|
|
40
|
+
const src = buildSwapWidgetUrl(options);
|
|
41
|
+
const height = options.height ?? 560;
|
|
42
|
+
return [
|
|
43
|
+
`<iframe src="${src}" title="Edel Swap Widget"`,
|
|
44
|
+
` width="100%" height="${height}" allow="clipboard-write"`,
|
|
45
|
+
` style="border:0;border-radius:18px;overflow:hidden;max-width:440px;"></iframe>`,
|
|
46
|
+
].join("\n");
|
|
47
|
+
}
|
|
48
|
+
function buildShadowStyles(theme) {
|
|
49
|
+
return `:host{display:block;max-width:440px;width:100%;}\n${getIsolatedWidgetCss(theme)}`;
|
|
50
|
+
}
|
|
51
|
+
function dispatchWidgetEvent(target, type, detail) {
|
|
52
|
+
if (typeof CustomEvent === "undefined" || typeof target.dispatchEvent !== "function") {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
target.dispatchEvent(new CustomEvent(type, {
|
|
56
|
+
detail,
|
|
57
|
+
bubbles: true,
|
|
58
|
+
composed: true,
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
function decoratePropsWithEvents(target, props, dispatchEvents) {
|
|
62
|
+
if (!dispatchEvents) {
|
|
63
|
+
return props;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
...props,
|
|
67
|
+
onQuote: (quote) => {
|
|
68
|
+
props.onQuote?.(quote);
|
|
69
|
+
dispatchWidgetEvent(target, EDEL_SWAP_WIDGET_EVENTS.quote, quote);
|
|
70
|
+
},
|
|
71
|
+
onSwapComplete: (order) => {
|
|
72
|
+
props.onSwapComplete?.(order);
|
|
73
|
+
dispatchWidgetEvent(target, EDEL_SWAP_WIDGET_EVENTS.complete, order);
|
|
74
|
+
},
|
|
75
|
+
onError: (error) => {
|
|
76
|
+
props.onError?.(error);
|
|
77
|
+
dispatchWidgetEvent(target, EDEL_SWAP_WIDGET_EVENTS.error, {
|
|
78
|
+
message: error.message,
|
|
79
|
+
error,
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
onSlippageChange: (maxSlippageBps) => {
|
|
83
|
+
props.onSlippageChange?.(maxSlippageBps);
|
|
84
|
+
dispatchWidgetEvent(target, EDEL_SWAP_WIDGET_EVENTS.slippageChange, {
|
|
85
|
+
maxSlippageBps,
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Imperatively mounts the interactive `<EdelSwapWidget />` into any DOM element,
|
|
92
|
+
* with Shadow DOM CSS isolation enabled by default so host styles in Vue, Svelte,
|
|
93
|
+
* Angular, SolidJS, or plain HTML never collide with the widget.
|
|
94
|
+
*/
|
|
95
|
+
export function mountEdelSwapWidget(target, props = {}, options = {}) {
|
|
96
|
+
const useShadowDom = options.shadowDom !== false;
|
|
97
|
+
const dispatchEvents = options.dispatchEvents === true;
|
|
98
|
+
const createRootFn = options.createRootImpl ?? ((container) => createRoot(container));
|
|
99
|
+
let currentProps = { ...props };
|
|
100
|
+
let unmounted = false;
|
|
101
|
+
const ownerDoc = target.ownerDocument ?? (typeof document !== "undefined" ? document : undefined);
|
|
102
|
+
if (!ownerDoc) {
|
|
103
|
+
throw new Error("mountEdelSwapWidget requires a browser DOM environment.");
|
|
104
|
+
}
|
|
105
|
+
let styleEl = null;
|
|
106
|
+
let hostRoot = target;
|
|
107
|
+
if (useShadowDom && (target.shadowRoot || typeof target.attachShadow === "function")) {
|
|
108
|
+
const shadow = target.shadowRoot ?? target.attachShadow({ mode: "open" });
|
|
109
|
+
hostRoot = shadow;
|
|
110
|
+
const existingStyle = typeof shadow.querySelector === "function"
|
|
111
|
+
? shadow.querySelector('style[data-edel-swap-widget-styles="true"]')
|
|
112
|
+
: null;
|
|
113
|
+
if (existingStyle) {
|
|
114
|
+
styleEl = existingStyle;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
styleEl = ownerDoc.createElement("style");
|
|
118
|
+
styleEl.setAttribute("data-edel-swap-widget-styles", "true");
|
|
119
|
+
shadow.appendChild(styleEl);
|
|
120
|
+
}
|
|
121
|
+
styleEl.textContent = buildShadowStyles(currentProps.theme ?? "dark");
|
|
122
|
+
}
|
|
123
|
+
const mountNode = ownerDoc.createElement("div");
|
|
124
|
+
mountNode.setAttribute("data-edel-swap-widget-mount", "true");
|
|
125
|
+
hostRoot.appendChild(mountNode);
|
|
126
|
+
const root = createRootFn(mountNode);
|
|
127
|
+
const renderCurrent = () => {
|
|
128
|
+
if (unmounted)
|
|
129
|
+
return;
|
|
130
|
+
if (styleEl) {
|
|
131
|
+
styleEl.textContent = buildShadowStyles(currentProps.theme ?? "dark");
|
|
132
|
+
}
|
|
133
|
+
const effectiveProps = decoratePropsWithEvents(target, currentProps, dispatchEvents);
|
|
134
|
+
root.render(createElement(EdelSwapWidget, effectiveProps));
|
|
135
|
+
};
|
|
136
|
+
renderCurrent();
|
|
137
|
+
return {
|
|
138
|
+
update(nextProps) {
|
|
139
|
+
if (unmounted)
|
|
140
|
+
return;
|
|
141
|
+
currentProps = { ...currentProps, ...nextProps };
|
|
142
|
+
renderCurrent();
|
|
143
|
+
},
|
|
144
|
+
unmount() {
|
|
145
|
+
if (unmounted)
|
|
146
|
+
return;
|
|
147
|
+
unmounted = true;
|
|
148
|
+
root.unmount();
|
|
149
|
+
if (mountNode.parentNode) {
|
|
150
|
+
mountNode.parentNode.removeChild(mountNode);
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
getProps() {
|
|
154
|
+
return { ...currentProps };
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function parseOptionalInt(raw) {
|
|
159
|
+
if (raw === null || raw.trim() === "")
|
|
160
|
+
return undefined;
|
|
161
|
+
const n = Number(raw);
|
|
162
|
+
return Number.isFinite(n) ? Math.round(n) : undefined;
|
|
163
|
+
}
|
|
164
|
+
function readElementAttributeProps(el) {
|
|
165
|
+
const networkAttr = el.getAttribute("network");
|
|
166
|
+
const themeAttr = el.getAttribute("theme");
|
|
167
|
+
const props = {
|
|
168
|
+
network: networkAttr === "testnet" ? "testnet" : "mainnet",
|
|
169
|
+
theme: themeAttr === "light" ? "light" : "dark",
|
|
170
|
+
};
|
|
171
|
+
const integratorId = el.getAttribute("integrator-id") ?? el.getAttribute("partner-id");
|
|
172
|
+
if (integratorId)
|
|
173
|
+
props.integratorId = integratorId;
|
|
174
|
+
const defaultFrom = el.getAttribute("from");
|
|
175
|
+
if (defaultFrom)
|
|
176
|
+
props.defaultFrom = defaultFrom;
|
|
177
|
+
const defaultTo = el.getAttribute("to");
|
|
178
|
+
if (defaultTo)
|
|
179
|
+
props.defaultTo = defaultTo;
|
|
180
|
+
const maxSlippageBps = parseOptionalInt(el.getAttribute("max-slippage-bps"));
|
|
181
|
+
if (maxSlippageBps !== undefined)
|
|
182
|
+
props.defaultMaxSlippageBps = maxSlippageBps;
|
|
183
|
+
const integratorFeeBps = parseOptionalInt(el.getAttribute("integrator-fee-bps"));
|
|
184
|
+
if (integratorFeeBps !== undefined)
|
|
185
|
+
props.integratorFeeBps = integratorFeeBps;
|
|
186
|
+
const recipientAddress = el.getAttribute("recipient-address");
|
|
187
|
+
if (recipientAddress)
|
|
188
|
+
props.recipientAddress = recipientAddress;
|
|
189
|
+
return props;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Registers the `<edel-swap-widget>` Custom Element (Web Component) with Shadow DOM
|
|
193
|
+
* CSS isolation. Mounts the full interactive React `<EdelSwapWidget />` inside an open
|
|
194
|
+
* Shadow Root and dispatches standard `CustomEvent`s (`edel-swap-quote`,
|
|
195
|
+
* `edel-swap-complete`, `edel-swap-error`, `edel-swap-slippage-change`).
|
|
196
|
+
*/
|
|
197
|
+
export function registerEdelSwapWidgetElement(tagName = EDEL_SWAP_WIDGET_TAG, options = {}) {
|
|
198
|
+
if (typeof customElements === "undefined" || typeof HTMLElement === "undefined") {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
if (customElements.get(tagName)) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
class EdelSwapWidgetCustomElement extends HTMLElement {
|
|
205
|
+
mounted = null;
|
|
206
|
+
customProps = {};
|
|
207
|
+
static get observedAttributes() {
|
|
208
|
+
return [
|
|
209
|
+
"network",
|
|
210
|
+
"integrator-id",
|
|
211
|
+
"partner-id",
|
|
212
|
+
"from",
|
|
213
|
+
"to",
|
|
214
|
+
"theme",
|
|
215
|
+
"max-slippage-bps",
|
|
216
|
+
"integrator-fee-bps",
|
|
217
|
+
"recipient-address",
|
|
218
|
+
];
|
|
219
|
+
}
|
|
220
|
+
get widgetProps() {
|
|
221
|
+
return { ...this.customProps };
|
|
222
|
+
}
|
|
223
|
+
set widgetProps(nextProps) {
|
|
224
|
+
this.customProps = { ...nextProps };
|
|
225
|
+
this.syncMount();
|
|
226
|
+
}
|
|
227
|
+
setProps(nextProps) {
|
|
228
|
+
this.customProps = { ...this.customProps, ...nextProps };
|
|
229
|
+
this.syncMount();
|
|
230
|
+
}
|
|
231
|
+
connectedCallback() {
|
|
232
|
+
this.syncMount();
|
|
233
|
+
}
|
|
234
|
+
attributeChangedCallback() {
|
|
235
|
+
if (this.mounted) {
|
|
236
|
+
this.syncMount();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
disconnectedCallback() {
|
|
240
|
+
this.mounted?.unmount();
|
|
241
|
+
this.mounted = null;
|
|
242
|
+
}
|
|
243
|
+
resolveMergedProps() {
|
|
244
|
+
return {
|
|
245
|
+
...readElementAttributeProps(this),
|
|
246
|
+
...this.customProps,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
syncMount() {
|
|
250
|
+
const merged = this.resolveMergedProps();
|
|
251
|
+
if (!this.mounted) {
|
|
252
|
+
this.mounted = mountEdelSwapWidget(this, merged, {
|
|
253
|
+
shadowDom: true,
|
|
254
|
+
dispatchEvents: true,
|
|
255
|
+
createRootImpl: options.createRootImpl,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
this.mounted.update(merged);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
customElements.define(tagName, EdelSwapWidgetCustomElement);
|
|
264
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { buildSwapWidgetEmbedSnippet, buildSwapWidgetUrl, EDEL_SWAP_WIDGET_EVENTS, EDEL_SWAP_WIDGET_TAG, type EdelSwapWidgetElement, type EdelSwapWidgetErrorDetail, type EdelSwapWidgetEventMap, type EdelSwapWidgetSlippageDetail, type MountEdelSwapWidgetOptions, type MountedEdelSwapWidget, mountEdelSwapWidget, registerEdelSwapWidgetElement, SWAP_WIDGET_ORIGINS, type SwapWidgetEmbedOptions, type WidgetRootLike, } from "./embed.js";
|
|
2
|
+
export { ALPINE_FOREST_THEMES, type AlpineThemeTokens, getIsolatedWidgetCss, type SwapWidgetTheme, } from "./theme.js";
|
|
3
|
+
export { DEFAULT_SWAP_ASSETS, DEFAULT_WIDGET_QUOTE_TTL_SECONDS, DEFAULT_WIDGET_SLIPPAGE_BPS, EdelSwapWidget, type EdelSwapWidgetProps, formatBps, formatPresetPercent, getStepState, parseCustomSlippagePercent, resolveInitialSlippageBps, SLIPPAGE_PRESETS_BPS, SWAP_STATUS_STEPS, } from "./widget.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { buildSwapWidgetEmbedSnippet, buildSwapWidgetUrl, EDEL_SWAP_WIDGET_EVENTS, EDEL_SWAP_WIDGET_TAG, mountEdelSwapWidget, registerEdelSwapWidgetElement, SWAP_WIDGET_ORIGINS, } from "./embed.js";
|
|
2
|
+
export { ALPINE_FOREST_THEMES, getIsolatedWidgetCss, } from "./theme.js";
|
|
3
|
+
export { DEFAULT_SWAP_ASSETS, DEFAULT_WIDGET_QUOTE_TTL_SECONDS, DEFAULT_WIDGET_SLIPPAGE_BPS, EdelSwapWidget, formatBps, formatPresetPercent, getStepState, parseCustomSlippagePercent, resolveInitialSlippageBps, SLIPPAGE_PRESETS_BPS, SWAP_STATUS_STEPS, } from "./widget.js";
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Alpine Forest II theme tokens and CSS-isolated style sheet for @edel-finance/swap-widget.
|
|
3
|
+
*
|
|
4
|
+
* All rules are scoped to `.edel-sw-root` with an explicit reset so the widget
|
|
5
|
+
* never inherits or leaks styles when embedded in SuperNova, Loop, or partner dApps.
|
|
6
|
+
*/
|
|
7
|
+
export type SwapWidgetTheme = "dark" | "light";
|
|
8
|
+
export interface AlpineThemeTokens {
|
|
9
|
+
bg: string;
|
|
10
|
+
cardBg: string;
|
|
11
|
+
surfaceBg: string;
|
|
12
|
+
surfaceHover: string;
|
|
13
|
+
border: string;
|
|
14
|
+
borderStrong: string;
|
|
15
|
+
text: string;
|
|
16
|
+
textMuted: string;
|
|
17
|
+
accent: string;
|
|
18
|
+
accentHover: string;
|
|
19
|
+
accentText: string;
|
|
20
|
+
success: string;
|
|
21
|
+
warning: string;
|
|
22
|
+
danger: string;
|
|
23
|
+
shadow: string;
|
|
24
|
+
}
|
|
25
|
+
export declare const ALPINE_FOREST_THEMES: Record<SwapWidgetTheme, AlpineThemeTokens>;
|
|
26
|
+
export declare function getIsolatedWidgetCss(theme: SwapWidgetTheme): string;
|