@coin-voyage/swapkit 0.1.0-beta.0 → 0.1.0-beta.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.
Files changed (57) hide show
  1. package/dist/components/connected-wallets.d.ts +1 -0
  2. package/dist/components/connected-wallets.js +66 -0
  3. package/dist/components/execution-modal.d.ts +5 -0
  4. package/dist/components/execution-modal.js +79 -0
  5. package/dist/components/icons.d.ts +23 -0
  6. package/dist/components/icons.js +49 -0
  7. package/dist/components/modal.d.ts +11 -0
  8. package/dist/components/modal.js +40 -0
  9. package/dist/components/styles.d.ts +124 -0
  10. package/dist/components/styles.js +1239 -0
  11. package/dist/components/swap.d.ts +2 -0
  12. package/dist/components/swap.js +295 -0
  13. package/dist/components/token-icon.d.ts +5 -0
  14. package/dist/components/token-icon.js +9 -0
  15. package/dist/components/token-picker.d.ts +11 -0
  16. package/dist/components/token-picker.js +69 -0
  17. package/dist/components/wallet-connector.d.ts +8 -0
  18. package/dist/components/wallet-connector.js +33 -0
  19. package/dist/components/wallet-icon.d.ts +5 -0
  20. package/dist/components/wallet-icon.js +6 -0
  21. package/dist/hooks/use-order-status.d.ts +9 -0
  22. package/dist/hooks/use-order-status.js +36 -0
  23. package/dist/hooks/use-swap-execution.d.ts +7 -0
  24. package/dist/hooks/use-swap-execution.js +105 -0
  25. package/dist/hooks/use-swap-quote.d.ts +6 -0
  26. package/dist/hooks/use-swap-quote.js +63 -0
  27. package/dist/hooks/use-swap-state.d.ts +70 -0
  28. package/dist/hooks/use-swap-state.js +147 -0
  29. package/dist/hooks/use-token-data.d.ts +12 -0
  30. package/dist/hooks/use-token-data.js +80 -0
  31. package/dist/index.d.ts +4 -0
  32. package/dist/index.js +3 -0
  33. package/dist/lib/amount-input.d.ts +3 -0
  34. package/dist/lib/amount-input.js +11 -0
  35. package/dist/lib/currency-selection.d.ts +13 -0
  36. package/dist/lib/currency-selection.js +26 -0
  37. package/dist/lib/execution.d.ts +38 -0
  38. package/dist/lib/execution.js +26 -0
  39. package/dist/lib/output-wallet.d.ts +24 -0
  40. package/dist/lib/output-wallet.js +24 -0
  41. package/dist/lib/quote.d.ts +13 -0
  42. package/dist/lib/quote.js +24 -0
  43. package/dist/lib/version.d.ts +1 -0
  44. package/dist/lib/version.js +2 -0
  45. package/dist/providers/swapkit-context.d.ts +10 -0
  46. package/dist/providers/swapkit-context.js +8 -0
  47. package/dist/providers/swapkit-provider.d.ts +2 -0
  48. package/dist/providers/swapkit-provider.js +18 -0
  49. package/dist/styles/root.d.ts +5 -0
  50. package/dist/styles/root.js +75 -0
  51. package/dist/styles/styled.d.ts +2 -0
  52. package/dist/styles/styled.js +3 -0
  53. package/dist/styles/theme.d.ts +3 -0
  54. package/dist/styles/theme.js +36 -0
  55. package/dist/types.d.ts +44 -0
  56. package/dist/types.js +1 -0
  57. package/package.json +2 -2
@@ -0,0 +1,5 @@
1
+ import type { SwapKitMode, SwapKitTheme } from "../types";
2
+ export declare const SwapKitRoot: import("styled-components").StyledComponent<"div", any, {
3
+ $mode: SwapKitMode;
4
+ $customTheme: Partial<SwapKitTheme>;
5
+ }, never>;
@@ -0,0 +1,75 @@
1
+ import { css } from "styled-components";
2
+ import styled from "./styled";
3
+ import { darkTheme, lightTheme } from "./theme";
4
+ function variables(theme) {
5
+ return css `
6
+ --sk-font-family: ${theme.fontFamily};
7
+ --sk-background: ${theme.background};
8
+ --sk-surface: ${theme.surface};
9
+ --sk-surface-elevated: ${theme.surfaceElevated};
10
+ --sk-border: ${theme.border};
11
+ --sk-text: ${theme.text};
12
+ --sk-text-muted: ${theme.textMuted};
13
+ --sk-accent: ${theme.accent};
14
+ --sk-accent-hover: ${theme.accentHover};
15
+ --sk-accent-text: ${theme.accentText};
16
+ --sk-danger: ${theme.danger};
17
+ --sk-warning: ${theme.warning};
18
+ --sk-success: ${theme.success};
19
+ --sk-overlay: ${theme.overlay};
20
+ --sk-shadow: ${theme.shadow};
21
+ --sk-radius: ${theme.radius};
22
+ `;
23
+ }
24
+ function modeVariables(mode, customTheme) {
25
+ const light = { ...lightTheme, ...customTheme };
26
+ const dark = { ...darkTheme, ...customTheme };
27
+ if (mode === "light")
28
+ return variables(light);
29
+ if (mode === "dark")
30
+ return variables(dark);
31
+ return css `
32
+ ${variables(light)}
33
+ @media (prefers-color-scheme: dark) {
34
+ ${variables(dark)}
35
+ }
36
+ `;
37
+ }
38
+ export const SwapKitRoot = styled.div `
39
+ ${({ $mode, $customTheme }) => modeVariables($mode, $customTheme)}
40
+
41
+ all: initial;
42
+ display: block;
43
+ width: 100%;
44
+ color: var(--sk-text);
45
+ background: var(--sk-background);
46
+ font-family: var(--sk-font-family);
47
+ font-size: 16px;
48
+ text-align: left;
49
+ text-rendering: optimizeLegibility;
50
+ -webkit-font-smoothing: antialiased;
51
+
52
+ &,
53
+ * {
54
+ box-sizing: border-box;
55
+ font-family: var(--sk-font-family);
56
+ }
57
+
58
+ button,
59
+ input {
60
+ font-family: var(--sk-font-family);
61
+ }
62
+
63
+ button:focus-visible,
64
+ input:focus-visible,
65
+ a:focus-visible {
66
+ outline: 2px solid var(--sk-accent);
67
+ outline-offset: 2px;
68
+ }
69
+
70
+ img,
71
+ svg {
72
+ display: block;
73
+ max-width: 100%;
74
+ }
75
+ `;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("styled-components").StyledInterface;
2
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import styled from "styled-components";
2
+ const styledWithDefault = styled;
3
+ export default typeof styled.div === "function" ? styled : (styledWithDefault.default ?? styled);
@@ -0,0 +1,3 @@
1
+ import type { SwapKitTheme } from "../types";
2
+ export declare const lightTheme: SwapKitTheme;
3
+ export declare const darkTheme: SwapKitTheme;
@@ -0,0 +1,36 @@
1
+ export const lightTheme = {
2
+ fontFamily: `Roboto, Arial, Helvetica, sans-serif`,
3
+ background: "#f4f5f7",
4
+ surface: "#ffffff",
5
+ surfaceElevated: "#f7f8fa",
6
+ border: "#e4e7ec",
7
+ text: "#15181e",
8
+ textMuted: "#697386",
9
+ accent: "#866cff",
10
+ accentHover: "#7559f0",
11
+ accentText: "#ffffff",
12
+ danger: "#dc2626",
13
+ warning: "#d97706",
14
+ success: "#16a34a",
15
+ overlay: "rgba(15, 18, 25, 0.58)",
16
+ shadow: "0 18px 50px rgba(15, 18, 25, 0.16)",
17
+ radius: "12px",
18
+ };
19
+ export const darkTheme = {
20
+ fontFamily: lightTheme.fontFamily,
21
+ background: "hsl(180 6% 9%)",
22
+ surface: "hsl(180 5% 11%)",
23
+ surfaceElevated: "hsl(180 6% 9%)",
24
+ border: "hsl(180 7% 14%)",
25
+ text: "hsl(0 0% 100%)",
26
+ textMuted: "hsl(171 6% 53%)",
27
+ accent: "hsl(332 83% 60%)",
28
+ accentHover: "hsl(332 83% 56%)",
29
+ accentText: "#ffffff",
30
+ danger: "#f87171",
31
+ warning: "#fbbf24",
32
+ success: "#4ade80",
33
+ overlay: "rgba(0, 0, 0, 0.72)",
34
+ shadow: "0 18px 50px rgba(0, 0, 0, 0.5)",
35
+ radius: "12px",
36
+ };
@@ -0,0 +1,44 @@
1
+ import type { APIEnvironment } from "@coin-voyage/shared/api";
2
+ import type { CurrencyBase } from "@coin-voyage/shared/types";
3
+ import type { ReactNode } from "react";
4
+ export type SwapKitMode = "light" | "dark" | "auto";
5
+ export interface SwapKitTheme {
6
+ fontFamily: string;
7
+ background: string;
8
+ surface: string;
9
+ surfaceElevated: string;
10
+ border: string;
11
+ text: string;
12
+ textMuted: string;
13
+ accent: string;
14
+ accentHover: string;
15
+ accentText: string;
16
+ danger: string;
17
+ warning: string;
18
+ success: string;
19
+ overlay: string;
20
+ shadow: string;
21
+ radius: string;
22
+ }
23
+ export interface SwapKitProviderProps {
24
+ apiKey: string;
25
+ environment?: APIEnvironment;
26
+ mode?: SwapKitMode;
27
+ theme?: Partial<SwapKitTheme>;
28
+ children: ReactNode;
29
+ }
30
+ export interface SwapCompleteResult {
31
+ orderId: string;
32
+ transactionHash: string;
33
+ }
34
+ export interface SwapError {
35
+ message: string;
36
+ }
37
+ export type SwapCurrency = CurrencyBase;
38
+ export interface SwapProps {
39
+ defaultSourceCurrency?: SwapCurrency;
40
+ defaultDestinationCurrency?: SwapCurrency;
41
+ defaultSlippageBps?: number;
42
+ onComplete?: (result: SwapCompleteResult) => void;
43
+ onError?: (error: SwapError) => void;
44
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coin-voyage/swapkit",
3
3
  "description": "A reusable cross-chain swap component for CoinVoyage.",
4
- "version": "0.1.0-beta.0",
4
+ "version": "0.1.0-beta.1",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "author": "Lars <lars@coinvoyage.io>",
@@ -61,7 +61,7 @@
61
61
  "clean": "rm -rf dist tsconfig.tsbuildinfo coverage",
62
62
  "pre:release": "pnpm version prerelease --preid=beta",
63
63
  "pre:publish": "pnpm publish --access public --tag beta --no-git-checks",
64
- "pre:steps": "pnpm pre:release && pnpm release:build && pnpm pre:publish",
64
+ "pre:steps": "pnpm pre:release && pnpm pre:publish",
65
65
  "release:build": "pnpm clean && pnpm build",
66
66
  "release": "pnpm publish --access public --no-git-checks",
67
67
  "type-check": "tsc --noEmit"