@avail-project/widgets 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/README.md +34 -0
  2. package/dist/common/components/ErrorBoundary.d.ts +44 -0
  3. package/dist/common/components/ErrorBoundary.d.ts.map +1 -0
  4. package/dist/common/components/ErrorBoundary.js +65 -0
  5. package/dist/common/hooks/useDebouncedCallback.d.ts +13 -0
  6. package/dist/common/hooks/useDebouncedCallback.d.ts.map +1 -0
  7. package/dist/common/hooks/useDebouncedCallback.js +42 -0
  8. package/dist/common/hooks/useDebouncedValue.d.ts +5 -0
  9. package/dist/common/hooks/useDebouncedValue.d.ts.map +1 -0
  10. package/dist/common/hooks/useDebouncedValue.js +15 -0
  11. package/dist/common/hooks/useInterval.d.ts +11 -0
  12. package/dist/common/hooks/useInterval.d.ts.map +1 -0
  13. package/dist/common/hooks/useInterval.js +25 -0
  14. package/dist/common/hooks/useLatest.d.ts +12 -0
  15. package/dist/common/hooks/useLatest.d.ts.map +1 -0
  16. package/dist/common/hooks/useLatest.js +19 -0
  17. package/dist/common/hooks/useNexusError.d.ts +20 -0
  18. package/dist/common/hooks/useNexusError.d.ts.map +1 -0
  19. package/dist/common/hooks/useNexusError.js +120 -0
  20. package/dist/common/hooks/usePolling.d.ts +7 -0
  21. package/dist/common/hooks/usePolling.d.ts.map +1 -0
  22. package/dist/common/hooks/usePolling.js +29 -0
  23. package/dist/common/hooks/useStableCallback.d.ts +6 -0
  24. package/dist/common/hooks/useStableCallback.d.ts.map +1 -0
  25. package/dist/common/hooks/useStableCallback.js +13 -0
  26. package/dist/common/hooks/useStopwatch.d.ts +17 -0
  27. package/dist/common/hooks/useStopwatch.d.ts.map +1 -0
  28. package/dist/common/hooks/useStopwatch.js +44 -0
  29. package/dist/common/hooks/useTransactionExecution.d.ts +62 -0
  30. package/dist/common/hooks/useTransactionExecution.d.ts.map +1 -0
  31. package/dist/common/hooks/useTransactionExecution.js +273 -0
  32. package/dist/common/hooks/useTransactionFlow.d.ts +71 -0
  33. package/dist/common/hooks/useTransactionFlow.d.ts.map +1 -0
  34. package/dist/common/hooks/useTransactionFlow.js +435 -0
  35. package/dist/common/index.d.ts +17 -0
  36. package/dist/common/index.d.ts.map +1 -0
  37. package/dist/common/index.js +16 -0
  38. package/dist/common/tx/steps.d.ts +19 -0
  39. package/dist/common/tx/steps.d.ts.map +1 -0
  40. package/dist/common/tx/steps.js +89 -0
  41. package/dist/common/tx/types.d.ts +11 -0
  42. package/dist/common/tx/types.d.ts.map +1 -0
  43. package/dist/common/tx/types.js +19 -0
  44. package/dist/common/tx/useTransactionSteps.d.ts +21 -0
  45. package/dist/common/tx/useTransactionSteps.d.ts.map +1 -0
  46. package/dist/common/tx/useTransactionSteps.js +40 -0
  47. package/dist/common/types/transaction-flow.d.ts +48 -0
  48. package/dist/common/types/transaction-flow.d.ts.map +1 -0
  49. package/dist/common/types/transaction-flow.js +2 -0
  50. package/dist/common/utils/constant.d.ts +99 -0
  51. package/dist/common/utils/constant.d.ts.map +1 -0
  52. package/dist/common/utils/constant.js +370 -0
  53. package/dist/common/utils/token-pricing.d.ts +33 -0
  54. package/dist/common/utils/token-pricing.d.ts.map +1 -0
  55. package/dist/common/utils/token-pricing.js +255 -0
  56. package/dist/common/utils/transaction-flow.d.ts +35 -0
  57. package/dist/common/utils/transaction-flow.d.ts.map +1 -0
  58. package/dist/common/utils/transaction-flow.js +65 -0
  59. package/dist/index.d.ts +5 -0
  60. package/dist/index.d.ts.map +1 -0
  61. package/dist/index.js +2 -0
  62. package/dist/lib/utils.d.ts +4 -0
  63. package/dist/lib/utils.d.ts.map +1 -0
  64. package/dist/lib/utils.js +8 -0
  65. package/dist/nexus/NexusProvider.d.ts +50 -0
  66. package/dist/nexus/NexusProvider.d.ts.map +1 -0
  67. package/dist/nexus/NexusProvider.js +572 -0
  68. package/dist/nexus-widget/components/address-identicon.d.ts +5 -0
  69. package/dist/nexus-widget/components/address-identicon.d.ts.map +1 -0
  70. package/dist/nexus-widget/components/address-identicon.js +39 -0
  71. package/dist/nexus-widget/components/amount-input-unified.d.ts +18 -0
  72. package/dist/nexus-widget/components/amount-input-unified.d.ts.map +1 -0
  73. package/dist/nexus-widget/components/amount-input-unified.js +88 -0
  74. package/dist/nexus-widget/components/deposit-idle-form.d.ts +29 -0
  75. package/dist/nexus-widget/components/deposit-idle-form.d.ts.map +1 -0
  76. package/dist/nexus-widget/components/deposit-idle-form.js +506 -0
  77. package/dist/nexus-widget/components/nexus-widget-progress-screen.d.ts +36 -0
  78. package/dist/nexus-widget/components/nexus-widget-progress-screen.d.ts.map +1 -0
  79. package/dist/nexus-widget/components/nexus-widget-progress-screen.js +737 -0
  80. package/dist/nexus-widget/components/pay-using-selector.d.ts +9 -0
  81. package/dist/nexus-widget/components/pay-using-selector.d.ts.map +1 -0
  82. package/dist/nexus-widget/components/pay-using-selector.js +37 -0
  83. package/dist/nexus-widget/components/pay-with-sources.d.ts +11 -0
  84. package/dist/nexus-widget/components/pay-with-sources.d.ts.map +1 -0
  85. package/dist/nexus-widget/components/pay-with-sources.js +266 -0
  86. package/dist/nexus-widget/components/receive-asset-selector.d.ts +28 -0
  87. package/dist/nexus-widget/components/receive-asset-selector.d.ts.map +1 -0
  88. package/dist/nexus-widget/components/receive-asset-selector.js +1178 -0
  89. package/dist/nexus-widget/components/recipient-input.d.ts +10 -0
  90. package/dist/nexus-widget/components/recipient-input.d.ts.map +1 -0
  91. package/dist/nexus-widget/components/recipient-input.js +44 -0
  92. package/dist/nexus-widget/components/send-idle-form.d.ts +29 -0
  93. package/dist/nexus-widget/components/send-idle-form.d.ts.map +1 -0
  94. package/dist/nexus-widget/components/send-idle-form.js +548 -0
  95. package/dist/nexus-widget/components/status-alerts.d.ts +7 -0
  96. package/dist/nexus-widget/components/status-alerts.d.ts.map +1 -0
  97. package/dist/nexus-widget/components/status-alerts.js +17 -0
  98. package/dist/nexus-widget/components/swap-asset-selector.d.ts +74 -0
  99. package/dist/nexus-widget/components/swap-asset-selector.d.ts.map +1 -0
  100. package/dist/nexus-widget/components/swap-asset-selector.js +1910 -0
  101. package/dist/nexus-widget/components/swap-idle-form.d.ts +29 -0
  102. package/dist/nexus-widget/components/swap-idle-form.d.ts.map +1 -0
  103. package/dist/nexus-widget/components/swap-idle-form.js +1289 -0
  104. package/dist/nexus-widget/components/swap-intent-preview.d.ts +95 -0
  105. package/dist/nexus-widget/components/swap-intent-preview.d.ts.map +1 -0
  106. package/dist/nexus-widget/components/swap-intent-preview.js +1050 -0
  107. package/dist/nexus-widget/nexus-widget.d.ts +4 -0
  108. package/dist/nexus-widget/nexus-widget.d.ts.map +1 -0
  109. package/dist/nexus-widget/nexus-widget.js +7819 -0
  110. package/dist/nexus-widget/sdk-types.d.ts +13 -0
  111. package/dist/nexus-widget/sdk-types.d.ts.map +1 -0
  112. package/dist/nexus-widget/sdk-types.js +1 -0
  113. package/dist/nexus-widget/theme.d.ts +156 -0
  114. package/dist/nexus-widget/theme.d.ts.map +1 -0
  115. package/dist/nexus-widget/theme.js +159 -0
  116. package/dist/nexus-widget/types.d.ts +141 -0
  117. package/dist/nexus-widget/types.d.ts.map +1 -0
  118. package/dist/nexus-widget/types.js +1 -0
  119. package/dist/nexus-widget/utils/citrea-tokens.d.ts +82 -0
  120. package/dist/nexus-widget/utils/citrea-tokens.d.ts.map +1 -0
  121. package/dist/nexus-widget/utils/citrea-tokens.js +136 -0
  122. package/dist/nexus-widget/utils/deposit-source-selection.d.ts +55 -0
  123. package/dist/nexus-widget/utils/deposit-source-selection.d.ts.map +1 -0
  124. package/dist/nexus-widget/utils/deposit-source-selection.js +219 -0
  125. package/dist/swaps/components/stacked-token-icons.d.ts +15 -0
  126. package/dist/swaps/components/stacked-token-icons.d.ts.map +1 -0
  127. package/dist/swaps/components/stacked-token-icons.js +38 -0
  128. package/dist/swaps/components/step-flow.d.ts +32 -0
  129. package/dist/swaps/components/step-flow.d.ts.map +1 -0
  130. package/dist/swaps/components/step-flow.js +54 -0
  131. package/dist/swaps/components/token-icon.d.ts +11 -0
  132. package/dist/swaps/components/token-icon.d.ts.map +1 -0
  133. package/dist/swaps/components/token-icon.js +16 -0
  134. package/dist/swaps/components/transaction-progress.d.ts +43 -0
  135. package/dist/swaps/components/transaction-progress.d.ts.map +1 -0
  136. package/dist/swaps/components/transaction-progress.js +94 -0
  137. package/dist/ui/button.d.ts +11 -0
  138. package/dist/ui/button.d.ts.map +1 -0
  139. package/dist/ui/button.js +34 -0
  140. package/dist/ui/dialog.d.ts +17 -0
  141. package/dist/ui/dialog.d.ts.map +1 -0
  142. package/dist/ui/dialog.js +47 -0
  143. package/package.json +60 -0
@@ -0,0 +1,10 @@
1
+ export interface RecipientInputProps {
2
+ hasError?: boolean;
3
+ label?: string | null;
4
+ onChange: (val: string) => void;
5
+ onClear?: () => void;
6
+ placeholder?: string;
7
+ value: string;
8
+ }
9
+ export declare function RecipientInput({ value, onChange, onClear, placeholder, label, hasError, }: RecipientInputProps): import("react/jsx-runtime").JSX.Element;
10
+ //# sourceMappingURL=recipient-input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipient-input.d.ts","sourceRoot":"","sources":["../../../.build-src/nexus-widget/components/recipient-input.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,QAAQ,EACR,OAAO,EACP,WAAyB,EACzB,KAAY,EACZ,QAAgB,GACjB,EAAE,mBAAmB,2CA2ErB"}
@@ -0,0 +1,44 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // biome-ignore-all lint: NexusWidget registry component from shadcn registry.
3
+ import { X } from "lucide-react";
4
+ import React from "react";
5
+ export function RecipientInput({ value, onChange, onClear, placeholder = "Search...", label = "To", hasError = false, }) {
6
+ return (_jsxs("div", { className: "flex items-center w-full px-4 overflow-hidden outline-none transition-all placeholder:text-[var(--foreground-muted, #848483)] text-[var(--foreground-primary, #161615)]", style: {
7
+ background: "#FFFFFE",
8
+ height: "38px",
9
+ borderRadius: "7px",
10
+ borderWidth: "1px",
11
+ borderStyle: "solid",
12
+ borderColor: hasError ? "#E35454" : "var(--foreground-brand)",
13
+ gap: "8px",
14
+ paddingTop: "8px",
15
+ paddingBottom: "8px",
16
+ }, children: [label && (_jsx("div", { className: "shrink-0 font-geist select-none flex items-center", style: {
17
+ color: "var(--foreground-primary, var(--foreground-primary, #161615))",
18
+ fontSize: "14px",
19
+ fontWeight: 400,
20
+ lineHeight: "17px",
21
+ }, children: label })), _jsx("style", { children: `
22
+ .nexus-widget-recipient-input::placeholder {
23
+ color: #9E9E9C;
24
+ -webkit-text-fill-color: #9E9E9C;
25
+ opacity: 1;
26
+ }
27
+ ` }), _jsx("input", { className: "nexus-widget-recipient-input flex-1 bg-transparent border-none outline-none focus:ring-0 font-geist placeholder:text-[var(--foreground-muted, #848483)]", onChange: (e) => onChange(e.target.value), placeholder: placeholder, style: {
28
+ color: "#161615",
29
+ caretColor: "var(--foreground-brand)",
30
+ fontSize: "14px",
31
+ fontWeight: 500,
32
+ WebkitTextFillColor: "#161615",
33
+ lineHeight: "17px",
34
+ }, value: value }), value && onClear && (_jsx("button", { "aria-label": "Clear recipient", onClick: onClear, style: {
35
+ alignItems: "center",
36
+ backgroundColor: "transparent",
37
+ border: "none",
38
+ cursor: "pointer",
39
+ display: "flex",
40
+ flexShrink: 0,
41
+ justifyContent: "center",
42
+ padding: 0,
43
+ }, type: "button", children: _jsx(X, { style: { color: "#9E9E9C", height: "16px", width: "16px" } }) }))] }));
44
+ }
@@ -0,0 +1,29 @@
1
+ import { type SwapTokenOption } from "./swap-asset-selector";
2
+ interface SendIdleFormProps {
3
+ amount: string;
4
+ calculatingPercent?: number | null;
5
+ fromTokens: SwapTokenOption[];
6
+ isAmountReadOnly?: boolean;
7
+ isAssetPickerDisabled?: boolean;
8
+ isCalculatingMax?: boolean;
9
+ isQuoteRefreshing?: boolean;
10
+ isRecipientLocked?: boolean;
11
+ hideDestinationTokenDropdownIcon?: boolean;
12
+ isSourcePickerDisabled?: boolean;
13
+ onAmountChange: (val: string) => void;
14
+ onOpenAssetPicker: () => void;
15
+ onOpenRecipientPicker: () => void;
16
+ onOpenSourcePicker: () => void;
17
+ onSetPercent: (pct: number) => void;
18
+ recipientAddress: string;
19
+ reserveSourceRows?: boolean;
20
+ routeMessage?: string;
21
+ routeStatus?: "loading" | "insufficient";
22
+ showAutoBadge?: boolean;
23
+ toToken?: SwapTokenOption;
24
+ totalBalance: string;
25
+ usdValue: string;
26
+ }
27
+ export declare function SendIdleForm({ amount, onAmountChange, toToken, fromTokens, totalBalance, usdValue, onOpenAssetPicker, onOpenSourcePicker, onOpenRecipientPicker, recipientAddress, onSetPercent, routeStatus, routeMessage, isAmountReadOnly, isAssetPickerDisabled, isCalculatingMax, calculatingPercent, isQuoteRefreshing, isRecipientLocked, hideDestinationTokenDropdownIcon, showAutoBadge, isSourcePickerDisabled, reserveSourceRows, }: SendIdleFormProps): import("react/jsx-runtime").JSX.Element;
28
+ export {};
29
+ //# sourceMappingURL=send-idle-form.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-idle-form.d.ts","sourceRoot":"","sources":["../../../.build-src/nexus-widget/components/send-idle-form.tsx"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAE/B,UAAU,iBAAiB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gCAAgC,CAAC,EAAE,OAAO,CAAC;IAC3C,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,qBAAqB,EAAE,MAAM,IAAI,CAAC;IAClC,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,SAAS,GAAG,cAAc,CAAC;IACzC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAogBD,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,cAAc,EACd,OAAO,EACP,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,gBAAwB,EACxB,qBAA6B,EAC7B,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAyB,EACzB,gCAAwC,EACxC,aAAoB,EACpB,sBAA8B,EAC9B,iBAAyB,GAC1B,EAAE,iBAAiB,2CAwbnB"}
@@ -0,0 +1,548 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ // biome-ignore-all lint: NexusWidget registry component from shadcn registry.
3
+ import Decimal from "decimal.js";
4
+ import { AlertCircle, ChevronDown, Loader2 } from "lucide-react";
5
+ import React, { useRef, useState } from "react";
6
+ import { PayWithSources as SharedPayWithSources } from "./pay-with-sources";
7
+ import { formatSelectedTokenBalanceLabel, } from "./swap-asset-selector";
8
+ const uiFont = '"Geist", system-ui, sans-serif';
9
+ const primary = "#161615";
10
+ const muted = "#848483";
11
+ const border = "#E8E8E7";
12
+ const brand = "var(--foreground-brand)";
13
+ const parseDecimal = (value) => {
14
+ if (value === null || value === undefined || value === "")
15
+ return undefined;
16
+ if (Decimal.isDecimal(value))
17
+ return value;
18
+ const cleaned = String(value).replace(/[^0-9.-]/g, "");
19
+ if (!cleaned || cleaned === "-" || cleaned === "." || cleaned === "-.") {
20
+ return undefined;
21
+ }
22
+ try {
23
+ const parsed = new Decimal(cleaned);
24
+ return parsed.isFinite() ? parsed : undefined;
25
+ }
26
+ catch {
27
+ return undefined;
28
+ }
29
+ };
30
+ const formatToken = (value) => {
31
+ const amount = parseDecimal(value) ?? new Decimal(0);
32
+ return amount.toDecimalPlaces(8).toFixed();
33
+ };
34
+ const formatUsd = (value) => {
35
+ const amount = parseDecimal(value) ?? new Decimal(0);
36
+ if (amount.gt(0) && amount.lt(0.01))
37
+ return "<$0.01";
38
+ return `$${amount.toDecimalPlaces(2).toFixed()}`;
39
+ };
40
+ const MAX_AMOUNT_DISPLAY_DECIMALS = 8;
41
+ const getTokenInputDecimals = (token) => {
42
+ const decimals = Number(token?.decimals);
43
+ return Number.isFinite(decimals) && decimals >= 0 ? Math.floor(decimals) : 18;
44
+ };
45
+ const formatAmountInputDisplay = (value) => {
46
+ if (!value)
47
+ return "";
48
+ try {
49
+ return new Decimal(value)
50
+ .toDecimalPlaces(MAX_AMOUNT_DISPLAY_DECIMALS, Decimal.ROUND_DOWN)
51
+ .toFixed();
52
+ }
53
+ catch {
54
+ return value;
55
+ }
56
+ };
57
+ const sanitizeAmountInput = (raw, maxDecimals) => {
58
+ let next = raw.replaceAll(/[^0-9.]/g, "");
59
+ const parts = next.split(".");
60
+ if (parts.length > 2)
61
+ next = parts[0] + "." + parts.slice(1).join("");
62
+ const [integerPart, decimalPart] = next.split(".");
63
+ if (decimalPart !== undefined) {
64
+ next = `${integerPart}.${decimalPart.slice(0, Math.max(0, maxDecimals))}`;
65
+ }
66
+ if (next === ".")
67
+ next = "0.";
68
+ return next;
69
+ };
70
+ function TokenLogo({ src, label, size = 30, fontSize = 12, style, }) {
71
+ const [failed, setFailed] = useState(!src);
72
+ React.useEffect(() => {
73
+ setFailed(!src);
74
+ }, [src]);
75
+ if (!failed && src) {
76
+ return (_jsx("img", { alt: label || "", onError: () => setFailed(true), src: src, style: {
77
+ backgroundColor: "#FFFFFE",
78
+ borderRadius: "999px",
79
+ height: size,
80
+ objectFit: "cover",
81
+ width: size,
82
+ ...style,
83
+ } }));
84
+ }
85
+ return (_jsx("div", { style: {
86
+ alignItems: "center",
87
+ backgroundColor: "#E8F0FF",
88
+ borderRadius: "999px",
89
+ color: brand,
90
+ display: "flex",
91
+ fontFamily: uiFont,
92
+ fontSize,
93
+ fontWeight: 700,
94
+ height: size,
95
+ justifyContent: "center",
96
+ width: size,
97
+ ...style,
98
+ }, children: (label || "?").slice(0, 1).toUpperCase() }));
99
+ }
100
+ function SourceLogoPair({ token }) {
101
+ return (_jsxs("div", { style: { flexShrink: 0, height: 32, position: "relative", width: 32 }, children: [_jsx(TokenLogo, { label: token.symbol, size: 32, src: token.logo }), token.chainLogo && (_jsx(TokenLogo, { label: token.chainName, size: 14, src: token.chainLogo, style: {
102
+ bottom: -2,
103
+ outline: "1px solid #FFFFFE",
104
+ position: "absolute",
105
+ right: -2,
106
+ } }))] }));
107
+ }
108
+ function ExactOutPercentButtons({ visible, onSelect, }) {
109
+ return (_jsx("div", { style: {
110
+ alignItems: "center",
111
+ boxSizing: "border-box",
112
+ display: "flex",
113
+ gap: "6px",
114
+ opacity: visible ? 1 : 0,
115
+ pointerEvents: visible ? "auto" : "none",
116
+ transition: "opacity 0.18s ease-out",
117
+ width: "100%",
118
+ }, children: [25, 50, 75, 100].map((pct) => {
119
+ const isMax = pct === 100;
120
+ return (_jsx("button", { onClick: (e) => {
121
+ e.stopPropagation();
122
+ onSelect(pct);
123
+ }, onMouseDown: (e) => {
124
+ e.preventDefault();
125
+ }, style: {
126
+ alignItems: "center",
127
+ backgroundColor: isMax ? "#E8F0FF" : "#F4F4F3",
128
+ border: "none",
129
+ borderRadius: "8px",
130
+ boxSizing: "border-box",
131
+ color: isMax ? brand : "#363635",
132
+ cursor: "pointer",
133
+ display: "flex",
134
+ flex: "1 1 0%",
135
+ fontFamily: '"Geist", system-ui, sans-serif',
136
+ fontSize: "12px",
137
+ fontWeight: 500,
138
+ justifyContent: "center",
139
+ lineHeight: "20px",
140
+ minWidth: 0,
141
+ paddingBlock: "5px",
142
+ paddingInline: "10px",
143
+ }, tabIndex: -1, type: "button", children: isMax ? "MAX" : `${pct}%` }, pct));
144
+ }) }));
145
+ }
146
+ function SkeletonRow() {
147
+ return (_jsxs("div", { style: {
148
+ alignItems: "center",
149
+ display: "flex",
150
+ justifyContent: "space-between",
151
+ }, children: [_jsx("div", { className: "animate-pulse", style: {
152
+ background: "linear-gradient(90deg, #F0F0EF 0%, #F7F7F6 48%, #F0F0EF 100%)",
153
+ backgroundSize: "200% 100%",
154
+ borderRadius: "6px",
155
+ height: "32px",
156
+ width: "128px",
157
+ } }), _jsx("div", { className: "animate-pulse", style: {
158
+ background: "linear-gradient(90deg, #F0F0EF 0%, #F7F7F6 48%, #F0F0EF 100%)",
159
+ backgroundSize: "200% 100%",
160
+ borderRadius: "999px",
161
+ height: "32px",
162
+ width: "108px",
163
+ } })] }));
164
+ }
165
+ function PayWithSources({ fromTokens, onOpenSourcePicker, routeStatus, routeMessage, }) {
166
+ const scrollRef = useRef(null);
167
+ const isRouteLoading = routeStatus === "loading";
168
+ const shouldShowSourceSummary = !isRouteLoading && fromTokens.length > 0;
169
+ const shouldScroll = shouldShowSourceSummary && fromTokens.length > 3;
170
+ const autoBadge = (_jsx("span", { style: {
171
+ border: `1px solid ${brand}`,
172
+ borderRadius: "999px",
173
+ color: brand,
174
+ fontFamily: uiFont,
175
+ fontSize: "9px",
176
+ fontWeight: 600,
177
+ letterSpacing: "0.04em",
178
+ lineHeight: "14px",
179
+ padding: "1px 5px",
180
+ }, children: "AUTO" }));
181
+ return (_jsxs("div", { style: {
182
+ backgroundColor: "#FFFFFE",
183
+ border: `1px solid ${border}`,
184
+ borderRadius: "12px",
185
+ boxShadow: "#1616150A 0px 1px 2px",
186
+ boxSizing: "border-box",
187
+ display: "flex",
188
+ flexDirection: "column",
189
+ gap: "10px",
190
+ padding: "14px",
191
+ }, children: [_jsxs("div", { style: {
192
+ alignItems: "center",
193
+ display: "flex",
194
+ justifyContent: "space-between",
195
+ }, children: [_jsxs("div", { style: {
196
+ alignItems: "center",
197
+ color: muted,
198
+ display: "flex",
199
+ fontFamily: uiFont,
200
+ fontSize: "14px",
201
+ fontWeight: 500,
202
+ gap: "6px",
203
+ letterSpacing: "0.08em",
204
+ lineHeight: "20px",
205
+ textTransform: "uppercase",
206
+ }, children: [_jsxs("span", { children: ["Pay With", shouldShowSourceSummary ? ` · ${fromTokens.length} assets` : ""] }), autoBadge] }), shouldShowSourceSummary && (_jsx("button", { onClick: onOpenSourcePicker, style: {
207
+ backgroundColor: "#F4F7FE",
208
+ border: "none",
209
+ borderRadius: "6px",
210
+ color: brand,
211
+ cursor: "pointer",
212
+ fontFamily: uiFont,
213
+ fontSize: "14px",
214
+ fontWeight: 500,
215
+ lineHeight: "16px",
216
+ padding: "7px 10px",
217
+ }, type: "button", children: "Edit tokens" }))] }), isRouteLoading ? (_jsxs(_Fragment, { children: [_jsx(SkeletonRow, {}), _jsxs("div", { style: {
218
+ alignItems: "center",
219
+ color: brand,
220
+ display: "flex",
221
+ fontFamily: uiFont,
222
+ fontSize: "15px",
223
+ gap: "6px",
224
+ }, children: [_jsx(Loader2, { className: "animate-spin", style: { height: 13, width: 13 } }), "Calculating best route..."] })] })) : shouldShowSourceSummary ? (_jsxs("div", { style: { position: "relative" }, children: [_jsx("div", { ref: scrollRef, style: {
225
+ display: "flex",
226
+ flexDirection: "column",
227
+ maxHeight: shouldScroll ? "184px" : undefined,
228
+ overflowY: shouldScroll ? "auto" : undefined,
229
+ paddingRight: shouldScroll ? "6px" : 0,
230
+ }, children: fromTokens.map((token, index) => (_jsxs("div", { style: {
231
+ alignItems: "center",
232
+ borderTop: index === 0 ? "none" : "1px solid #F0F0EF",
233
+ display: "flex",
234
+ justifyContent: "space-between",
235
+ minHeight: "52px",
236
+ padding: "6px 0",
237
+ }, children: [_jsxs("div", { style: {
238
+ alignItems: "center",
239
+ display: "flex",
240
+ gap: "10px",
241
+ minWidth: 0,
242
+ }, children: [_jsx(SourceLogoPair, { token: token }), _jsxs("div", { style: {
243
+ display: "flex",
244
+ flexDirection: "column",
245
+ gap: "3px",
246
+ minWidth: 0,
247
+ }, children: [_jsx("span", { style: {
248
+ color: primary,
249
+ fontFamily: uiFont,
250
+ fontSize: "16px",
251
+ fontWeight: 600,
252
+ }, children: token.symbol }), _jsx("span", { style: {
253
+ color: muted,
254
+ fontFamily: uiFont,
255
+ fontSize: "14px",
256
+ overflow: "hidden",
257
+ textOverflow: "ellipsis",
258
+ whiteSpace: "nowrap",
259
+ }, children: token.isUnified
260
+ ? "Unified balance"
261
+ : `on ${token.chainName || "Unknown chain"}` })] })] }), _jsxs("div", { style: {
262
+ display: "flex",
263
+ flexDirection: "column",
264
+ gap: "3px",
265
+ textAlign: "right",
266
+ }, children: [_jsxs("span", { style: {
267
+ color: primary,
268
+ fontFamily: uiFont,
269
+ fontSize: "15px",
270
+ }, children: [formatToken(token.userAmount || token.balance), " ", token.symbol] }), _jsx("span", { style: {
271
+ color: muted,
272
+ fontFamily: uiFont,
273
+ fontSize: "14px",
274
+ }, children: formatUsd(token.userAmountUsd || token.balanceInFiat) })] })] }, `${token.contractAddress}-${token.chainId ?? "unified"}-${index}`))) }), shouldScroll && (_jsx("button", { "aria-label": "Scroll payment sources", onClick: () => scrollRef.current?.scrollBy({ behavior: "smooth", top: 64 }), style: {
275
+ alignItems: "center",
276
+ background: "#FFFFFE",
277
+ border: `1px solid ${border}`,
278
+ borderRadius: "999px",
279
+ bottom: "4px",
280
+ boxShadow: "0 2px 8px rgba(22,22,21,0.08)",
281
+ cursor: "pointer",
282
+ display: "flex",
283
+ height: "22px",
284
+ justifyContent: "center",
285
+ left: "50%",
286
+ padding: 0,
287
+ position: "absolute",
288
+ transform: "translateX(-50%)",
289
+ width: "22px",
290
+ }, type: "button", children: _jsx(ChevronDown, { style: { color: muted, height: 14, width: 14 } }) }))] })) : (_jsx("div", { style: {
291
+ color: primary,
292
+ fontFamily: uiFont,
293
+ fontSize: "15px",
294
+ lineHeight: "20px",
295
+ }, children: "Sources will be auto selected" })), routeStatus === "insufficient" && routeMessage && (_jsxs("div", { style: {
296
+ alignItems: "center",
297
+ color: "#D32F2F",
298
+ display: "flex",
299
+ fontFamily: uiFont,
300
+ fontSize: "15px",
301
+ gap: "8px",
302
+ lineHeight: "20px",
303
+ }, children: [_jsx(AlertCircle, { style: { flexShrink: 0, height: 15, width: 15 } }), routeMessage] }))] }));
304
+ }
305
+ export function SendIdleForm({ amount, onAmountChange, toToken, fromTokens, totalBalance, usdValue, onOpenAssetPicker, onOpenSourcePicker, onOpenRecipientPicker, recipientAddress, onSetPercent, routeStatus, routeMessage, isAmountReadOnly = false, isAssetPickerDisabled = false, isCalculatingMax, calculatingPercent, isQuoteRefreshing, isRecipientLocked = false, hideDestinationTokenDropdownIcon = false, showAutoBadge = true, isSourcePickerDisabled = false, reserveSourceRows = false, }) {
306
+ const [pendingPercent, setPendingPercent] = useState(null);
307
+ const [isAmountFocused, setIsAmountFocused] = useState(false);
308
+ React.useEffect(() => {
309
+ if (!isCalculatingMax)
310
+ setPendingPercent(null);
311
+ }, [isCalculatingMax]);
312
+ const handlePercentSelect = (pct) => {
313
+ setPendingPercent(pct);
314
+ onSetPercent(pct);
315
+ };
316
+ const handleInput = (e) => {
317
+ if (isAmountReadOnly)
318
+ return;
319
+ onAmountChange(sanitizeAmountInput(e.target.value, getTokenInputDecimals(toToken)));
320
+ };
321
+ const amountDisplayValue = isAmountFocused
322
+ ? amount
323
+ : formatAmountInputDisplay(amount);
324
+ const activePendingPercent = calculatingPercent ?? (isCalculatingMax ? pendingPercent : null);
325
+ const isMaxCalculating = Boolean(isCalculatingMax && activePendingPercent === 100);
326
+ const destinationBalanceLabel = formatSelectedTokenBalanceLabel(toToken) ||
327
+ `0 ${toToken?.symbol || ""}`.trim();
328
+ return (_jsxs("div", { style: {
329
+ display: "flex",
330
+ flexDirection: "column",
331
+ gap: "10px",
332
+ width: "100%",
333
+ }, children: [_jsx("div", { style: {
334
+ alignItems: "start",
335
+ backgroundColor: "#FFFFFE",
336
+ borderColor: border,
337
+ borderRadius: "14px",
338
+ borderStyle: "solid",
339
+ borderWidth: "1px",
340
+ boxShadow: "#1616150A 0px 1px 2px",
341
+ boxSizing: "border-box",
342
+ display: "flex",
343
+ flexDirection: "column",
344
+ gap: "10px",
345
+ justifyContent: "center",
346
+ padding: "16px",
347
+ }, children: _jsxs("div", { style: {
348
+ alignSelf: "stretch",
349
+ boxSizing: "border-box",
350
+ display: "flex",
351
+ flexDirection: "column",
352
+ gap: "10px",
353
+ }, children: [_jsx("div", { style: {
354
+ boxSizing: "border-box",
355
+ color: muted,
356
+ fontFamily: uiFont,
357
+ fontSize: "12px",
358
+ fontWeight: 500,
359
+ letterSpacing: "0.08em",
360
+ lineHeight: "20px",
361
+ textTransform: "uppercase",
362
+ }, children: "Recipient" }), _jsxs("div", { style: {
363
+ alignItems: "center",
364
+ alignSelf: "stretch",
365
+ boxSizing: "border-box",
366
+ display: "flex",
367
+ gap: "10px",
368
+ justifyContent: "space-between",
369
+ width: "100%",
370
+ }, children: [_jsx("div", { style: {
371
+ boxSizing: "border-box",
372
+ color: brand,
373
+ fontFamily: uiFont,
374
+ fontSize: "16px",
375
+ fontVariantNumeric: "tabular-nums",
376
+ fontWeight: 500,
377
+ lineHeight: "20px",
378
+ }, children: recipientAddress
379
+ ? `${recipientAddress.slice(0, 6)}…${recipientAddress.slice(-4)}`
380
+ : "Select recipient" }), _jsx("button", { disabled: isRecipientLocked, onClick: onOpenRecipientPicker, style: {
381
+ alignItems: "center",
382
+ backgroundColor: "#E8F0FF",
383
+ border: "none",
384
+ borderRadius: "4px",
385
+ boxSizing: "border-box",
386
+ cursor: isRecipientLocked ? "default" : "pointer",
387
+ display: "flex",
388
+ gap: "4px",
389
+ paddingBlock: "8px",
390
+ paddingInline: "12px",
391
+ }, type: "button", children: _jsx("div", { style: {
392
+ boxSizing: "border-box",
393
+ color: isRecipientLocked ? "#6C756F" : brand,
394
+ fontFamily: uiFont,
395
+ fontSize: "12px",
396
+ fontWeight: 500,
397
+ lineHeight: "20px",
398
+ }, children: isRecipientLocked ? "Locked" : "Edit" }) })] })] }) }), _jsxs("div", { className: "nexus-focus-container", style: {
399
+ backgroundColor: "#FFFFFE",
400
+ borderColor: border,
401
+ borderRadius: "14px",
402
+ borderStyle: "solid",
403
+ borderWidth: "1px",
404
+ boxShadow: "#1616150A 0px 1px 2px",
405
+ boxSizing: "border-box",
406
+ display: "flex",
407
+ flexDirection: "column",
408
+ gap: "14px",
409
+ padding: "16px",
410
+ }, children: [_jsxs("div", { style: {
411
+ alignItems: "center",
412
+ display: "flex",
413
+ justifyContent: "space-between",
414
+ }, children: [_jsx("div", { style: {
415
+ color: muted,
416
+ fontFamily: uiFont,
417
+ fontSize: "12px",
418
+ fontWeight: 600,
419
+ letterSpacing: "0.08em",
420
+ lineHeight: "20px",
421
+ textTransform: "uppercase",
422
+ }, children: "Amount" }), _jsxs("div", { style: { alignItems: "center", display: "flex", gap: "4px" }, children: [_jsx("span", { style: {
423
+ color: muted,
424
+ fontFamily: uiFont,
425
+ fontSize: "14px",
426
+ lineHeight: "20px",
427
+ }, children: "Total Balance:" }), _jsxs("span", { style: {
428
+ color: primary,
429
+ fontFamily: uiFont,
430
+ fontSize: "14px",
431
+ fontWeight: 600,
432
+ lineHeight: "20px",
433
+ }, children: ["$", totalBalance] })] })] }), _jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "10px" }, children: [_jsxs("div", { style: {
434
+ alignItems: "center",
435
+ display: "flex",
436
+ gap: "12px",
437
+ justifyContent: "space-between",
438
+ width: "100%",
439
+ }, children: [isMaxCalculating ? (_jsx("div", { "aria-label": "Calculating max amount", className: "animate-pulse", style: {
440
+ backgroundColor: "#F0F0EF",
441
+ borderRadius: "8px",
442
+ flex: "1 1 0%",
443
+ height: "44px",
444
+ maxWidth: "220px",
445
+ minWidth: "132px",
446
+ } })) : (_jsx("input", { "aria-readonly": isAmountReadOnly, onBlur: () => setIsAmountFocused(false), onChange: handleInput, onFocus: () => setIsAmountFocused(true), placeholder: "0", style: {
447
+ background: "transparent",
448
+ border: "none",
449
+ boxSizing: "border-box",
450
+ color: amount ? primary : "#C8C8C6",
451
+ cursor: isAmountReadOnly ? "default" : "text",
452
+ flex: "1 1 0%",
453
+ fontFamily: '"Delight-Medium", "Delight", system-ui, sans-serif',
454
+ fontSize: "36px",
455
+ fontWeight: 500,
456
+ lineHeight: "44px",
457
+ minWidth: 0,
458
+ outline: "none",
459
+ padding: 0,
460
+ }, readOnly: isAmountReadOnly, type: "text", value: amountDisplayValue })), isCalculatingMax && !isMaxCalculating && (_jsx(Loader2, { className: "animate-spin", style: {
461
+ color: brand,
462
+ flexShrink: 0,
463
+ height: 18,
464
+ width: 18,
465
+ } })), _jsxs("button", { disabled: isAssetPickerDisabled, onClick: onOpenAssetPicker, style: {
466
+ alignItems: "center",
467
+ backgroundColor: "#FFFFFE",
468
+ borderColor: toToken ? border : "#C8C8C6",
469
+ borderRadius: "999px",
470
+ borderStyle: toToken ? "solid" : "dashed",
471
+ borderWidth: "1px",
472
+ boxShadow: "#1616150A 0px 1px 2px",
473
+ boxSizing: "border-box",
474
+ cursor: isAssetPickerDisabled ? "default" : "pointer",
475
+ display: "inline-flex",
476
+ flexShrink: 0,
477
+ gap: "8px",
478
+ paddingBottom: "5px",
479
+ paddingLeft: toToken ? "5px" : "10px",
480
+ paddingRight: "10px",
481
+ paddingTop: "5px",
482
+ }, type: "button", children: [toToken ? (_jsxs("div", { style: {
483
+ flexShrink: 0,
484
+ height: "26px",
485
+ position: "relative",
486
+ width: "26px",
487
+ }, children: [_jsx(TokenLogo, { label: toToken.symbol, size: 26, src: toToken.logo }), toToken.chainLogo && (_jsx(TokenLogo, { label: toToken.chainName, size: 12, src: toToken.chainLogo, style: {
488
+ bottom: -2,
489
+ outline: "1px solid #FFFFFE",
490
+ position: "absolute",
491
+ right: -2,
492
+ } }))] })) : (_jsx("div", { style: {
493
+ borderColor: "#C8C8C6",
494
+ borderRadius: "999px",
495
+ borderStyle: "dashed",
496
+ borderWidth: "1.5px",
497
+ boxSizing: "border-box",
498
+ flexShrink: 0,
499
+ height: "18px",
500
+ width: "18px",
501
+ } })), _jsx("div", { style: {
502
+ color: primary,
503
+ fontFamily: uiFont,
504
+ fontSize: "16px",
505
+ fontWeight: 500,
506
+ lineHeight: "24px",
507
+ }, children: toToken ? toToken.symbol : "Assets" }), !hideDestinationTokenDropdownIcon && (_jsx(ChevronDown, { style: {
508
+ color: isAssetPickerDisabled ? "#A8A8A6" : "#5B5B5A",
509
+ height: 16,
510
+ width: 16,
511
+ } }))] })] }), _jsxs("div", { style: {
512
+ alignItems: "center",
513
+ display: "flex",
514
+ justifyContent: "space-between",
515
+ width: "100%",
516
+ minHeight: "20px",
517
+ }, children: [_jsx("div", { style: {
518
+ display: "flex",
519
+ justifyContent: "flex-start",
520
+ alignItems: "center",
521
+ flex: 1,
522
+ }, children: _jsxs("div", { style: {
523
+ color: muted,
524
+ fontFamily: uiFont,
525
+ fontSize: "14px",
526
+ lineHeight: "20px",
527
+ }, children: ["\u2248 $", usdValue || "0"] }) }), _jsx("div", { style: {
528
+ alignItems: "center",
529
+ display: "flex",
530
+ justifyContent: "flex-end",
531
+ gap: "5px",
532
+ flex: 1,
533
+ minWidth: 0,
534
+ }, children: toToken && (_jsxs(_Fragment, { children: [_jsx("span", { style: {
535
+ color: "#7C7C7A",
536
+ fontFamily: uiFont,
537
+ fontSize: "14px",
538
+ lineHeight: "20px",
539
+ whiteSpace: "nowrap",
540
+ }, children: "Balance:" }), _jsx("span", { style: {
541
+ color: primary,
542
+ fontFamily: uiFont,
543
+ fontSize: "14px",
544
+ fontWeight: 500,
545
+ lineHeight: "20px",
546
+ whiteSpace: "nowrap",
547
+ }, children: destinationBalanceLabel })] })) })] }), _jsx(ExactOutPercentButtons, { onSelect: handlePercentSelect, visible: Boolean(toToken) && !isAmountReadOnly })] })] }), _jsx(SharedPayWithSources, { fromTokens: fromTokens, isSourcePickerDisabled: isSourcePickerDisabled, onOpenSourcePicker: onOpenSourcePicker, reserveSourceRows: reserveSourceRows, routeMessage: routeMessage, routeStatus: routeStatus, showAutoBadge: showAutoBadge })] }));
548
+ }
@@ -0,0 +1,7 @@
1
+ export type AlertType = "error" | "info" | "warning";
2
+ export declare function StatusAlert({ type, message, className, }: Readonly<{
3
+ type: AlertType;
4
+ message: React.ReactNode;
5
+ className?: string;
6
+ }>): import("react/jsx-runtime").JSX.Element;
7
+ //# sourceMappingURL=status-alerts.d.ts.map