@bloxwap/hig 0.7.0 → 0.8.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 (246) hide show
  1. package/README.md +2 -2
  2. package/chart/README.md +13 -2
  3. package/chart/dist/altimeter-burst.d.ts +4 -0
  4. package/chart/dist/altimeter-burst.js +43 -0
  5. package/chart/dist/altimeter-chart.d.ts +52 -0
  6. package/chart/dist/altimeter-chart.js +275 -0
  7. package/chart/dist/altimeter-model.d.ts +43 -0
  8. package/chart/dist/altimeter-model.js +148 -0
  9. package/chart/dist/altimeter-targets.d.ts +33 -0
  10. package/chart/dist/altimeter-targets.js +88 -0
  11. package/chart/dist/bitcoin-price.d.ts +8 -0
  12. package/chart/dist/bitcoin-price.js +41 -0
  13. package/chart/dist/champions-league.d.ts +19 -0
  14. package/chart/dist/champions-league.js +104 -0
  15. package/chart/dist/index.d.ts +6 -0
  16. package/chart/dist/index.js +5 -0
  17. package/chart/dist/outcome-chart.d.ts +37 -0
  18. package/chart/dist/outcome-chart.js +212 -0
  19. package/chart/dist/outcome-model.d.ts +43 -0
  20. package/chart/dist/outcome-model.js +71 -0
  21. package/chart/dist/plus-grid.d.ts +6 -0
  22. package/chart/dist/plus-grid.js +29 -0
  23. package/contracts/README.md +1 -1
  24. package/contracts/dist/avatar.d.ts +68 -0
  25. package/contracts/dist/avatar.js +93 -0
  26. package/contracts/dist/confetti.d.ts +174 -0
  27. package/contracts/dist/confetti.js +138 -0
  28. package/contracts/dist/decimal.d.ts +7 -0
  29. package/contracts/dist/decimal.js +35 -0
  30. package/contracts/dist/index.d.ts +29 -2
  31. package/contracts/dist/index.js +123 -4
  32. package/contracts/dist/invariants.d.ts +17 -0
  33. package/contracts/dist/invariants.js +24 -0
  34. package/contracts/dist/messages.d.ts +56 -2
  35. package/contracts/dist/messages.js +20 -2
  36. package/contracts/dist/number-flow.d.ts +90 -0
  37. package/contracts/dist/number-flow.js +150 -0
  38. package/contracts/dist/qr.d.ts +151 -0
  39. package/contracts/dist/qr.js +581 -0
  40. package/contracts/dist/toast.d.ts +168 -0
  41. package/contracts/dist/toast.js +171 -0
  42. package/feedback/README.md +1 -1
  43. package/feedback/dist/contract.js +1 -1
  44. package/feedback/dist/react.js +2 -4
  45. package/native/README.md +6 -1
  46. package/native/dist/account-block.d.ts +10 -1
  47. package/native/dist/account-block.js +17 -7
  48. package/native/dist/animated-number-model.d.ts +41 -1
  49. package/native/dist/animated-number-model.js +201 -23
  50. package/native/dist/animated-number.d.ts +39 -1
  51. package/native/dist/animated-number.js +161 -16
  52. package/native/dist/announce.d.ts +2 -0
  53. package/native/dist/announce.js +10 -0
  54. package/native/dist/asset-balance-row.d.ts +3 -1
  55. package/native/dist/asset-balance-row.js +15 -4
  56. package/native/dist/assets-block.d.ts +115 -0
  57. package/native/dist/assets-block.js +87 -0
  58. package/native/dist/async-result.d.ts +2 -0
  59. package/native/dist/async-result.js +11 -0
  60. package/native/dist/avatar-frame.d.ts +29 -0
  61. package/native/dist/avatar-frame.js +56 -0
  62. package/native/dist/avatar.d.ts +21 -0
  63. package/native/dist/avatar.js +31 -0
  64. package/native/dist/bar-mark.d.ts +2 -0
  65. package/native/dist/bar-mark.js +4 -2
  66. package/native/dist/bar-pnl.js +2 -1
  67. package/native/dist/blocks.d.ts +6 -1
  68. package/native/dist/blocks.js +5 -0
  69. package/native/dist/brand.js +2 -1
  70. package/native/dist/button.d.ts +7 -2
  71. package/native/dist/button.js +13 -3
  72. package/native/dist/checkbox.js +2 -1
  73. package/native/dist/confetti.d.ts +33 -0
  74. package/native/dist/confetti.js +143 -0
  75. package/native/dist/confirm-block.d.ts +98 -0
  76. package/native/dist/confirm-block.js +48 -0
  77. package/native/dist/data.js +2 -0
  78. package/native/dist/explainer-block.d.ts +91 -0
  79. package/native/dist/explainer-block.js +34 -0
  80. package/native/dist/field.d.ts +5 -1
  81. package/native/dist/field.js +27 -6
  82. package/native/dist/gesture-sheet-model.d.ts +50 -0
  83. package/native/dist/gesture-sheet-model.js +105 -0
  84. package/native/dist/gesture-sheet-next.d.ts +82 -0
  85. package/native/dist/gesture-sheet-next.js +315 -0
  86. package/native/dist/gesture-sheet.d.ts +5 -1
  87. package/native/dist/gesture-sheet.js +13 -6
  88. package/native/dist/icons.d.ts +9 -6
  89. package/native/dist/icons.js +25 -24
  90. package/native/dist/language-block.d.ts +10 -1
  91. package/native/dist/language-block.js +11 -4
  92. package/native/dist/list-group.d.ts +3 -1
  93. package/native/dist/list-group.js +26 -13
  94. package/native/dist/manage-position-block.d.ts +8 -1
  95. package/native/dist/manage-position-block.js +7 -2
  96. package/native/dist/market-row.js +19 -8
  97. package/native/dist/navigation.js +5 -3
  98. package/native/dist/number-format.d.ts +6 -0
  99. package/native/dist/number-format.js +9 -0
  100. package/native/dist/pickers.d.ts +8 -0
  101. package/native/dist/pickers.js +3 -3
  102. package/native/dist/position-block.d.ts +5 -5
  103. package/native/dist/preset-group.d.ts +31 -0
  104. package/native/dist/preset-group.js +39 -0
  105. package/native/dist/preset-picker-block.d.ts +107 -0
  106. package/native/dist/preset-picker-block.js +43 -0
  107. package/native/dist/profile-block.d.ts +10 -1
  108. package/native/dist/profile-block.js +8 -3
  109. package/native/dist/provider.d.ts +5 -2
  110. package/native/dist/provider.js +27 -5
  111. package/native/dist/qr-code.d.ts +33 -0
  112. package/native/dist/qr-code.js +29 -0
  113. package/native/dist/radio-group.d.ts +19 -7
  114. package/native/dist/radio-group.js +39 -10
  115. package/native/dist/reward-block.d.ts +10 -7
  116. package/native/dist/reward-block.js +9 -4
  117. package/native/dist/screen-header.d.ts +13 -3
  118. package/native/dist/screen-header.js +12 -4
  119. package/native/dist/select.js +4 -2
  120. package/native/dist/selection.d.ts +2 -1
  121. package/native/dist/selection.js +1 -0
  122. package/native/dist/setting-switch.d.ts +1 -1
  123. package/native/dist/setting-switch.js +7 -3
  124. package/native/dist/slider.js +5 -1
  125. package/native/dist/sound-haptics-block.js +1 -1
  126. package/native/dist/status.d.ts +41 -9
  127. package/native/dist/status.js +34 -17
  128. package/native/dist/sticky-header.js +9 -1
  129. package/native/dist/swap-amount-card.d.ts +57 -0
  130. package/native/dist/swap-amount-card.js +31 -0
  131. package/native/dist/swap-panel-block.d.ts +9 -3
  132. package/native/dist/swap-panel-block.js +59 -33
  133. package/native/dist/swap-parts.d.ts +3 -10
  134. package/native/dist/swap-parts.js +22 -24
  135. package/native/dist/swap-shared.d.ts +2 -2
  136. package/native/dist/swap-shared.js +10 -6
  137. package/native/dist/swap-views.js +1 -1
  138. package/native/dist/target-block.d.ts +7 -1
  139. package/native/dist/target-block.js +13 -6
  140. package/native/dist/toast.d.ts +47 -0
  141. package/native/dist/toast.js +386 -0
  142. package/native/dist/token-action-block.d.ts +10 -1
  143. package/native/dist/token-action-block.js +9 -4
  144. package/native/dist/trade-history-list-block.js +7 -4
  145. package/native/dist/wallet-address-core.js +6 -3
  146. package/native-fonts/README.md +1 -1
  147. package/og-fonts/README.md +1 -1
  148. package/package.json +111 -2
  149. package/react/README.md +3 -1
  150. package/react/dist/animated-number-flow.d.ts +72 -0
  151. package/react/dist/animated-number-flow.js +316 -0
  152. package/react/dist/animated-number-model.d.ts +18 -0
  153. package/react/dist/animated-number-model.js +75 -5
  154. package/react/dist/animated-number.d.ts +45 -1
  155. package/react/dist/animated-number.js +137 -6
  156. package/react/dist/asset-balance-row.d.ts +3 -1
  157. package/react/dist/asset-balance-row.js +10 -4
  158. package/react/dist/async-result.d.ts +2 -0
  159. package/react/dist/async-result.js +11 -0
  160. package/react/dist/avatar.d.ts +25 -0
  161. package/react/dist/avatar.js +50 -0
  162. package/react/dist/blocks/account-block.d.ts +5 -1
  163. package/react/dist/blocks/account-block.js +11 -6
  164. package/react/dist/blocks/assets-block.d.ts +106 -0
  165. package/react/dist/blocks/assets-block.js +135 -0
  166. package/react/dist/blocks/confirm-block.d.ts +91 -0
  167. package/react/dist/blocks/confirm-block.js +31 -0
  168. package/react/dist/blocks/explainer-block.d.ts +80 -0
  169. package/react/dist/blocks/explainer-block.js +20 -0
  170. package/react/dist/blocks/install-command.js +3 -1
  171. package/react/dist/blocks/language-block.d.ts +5 -1
  172. package/react/dist/blocks/language-block.js +4 -3
  173. package/react/dist/blocks/manage-position-block.d.ts +3 -1
  174. package/react/dist/blocks/manage-position-block.js +2 -2
  175. package/react/dist/blocks/market-row.js +8 -3
  176. package/react/dist/blocks/notifications-block.d.ts +3 -1
  177. package/react/dist/blocks/notifications-block.js +2 -2
  178. package/react/dist/blocks/pickers.d.ts +9 -0
  179. package/react/dist/blocks/pickers.js +4 -2
  180. package/react/dist/blocks/position-block.d.ts +3 -3
  181. package/react/dist/blocks/preset-picker-block.d.ts +85 -0
  182. package/react/dist/blocks/preset-picker-block.js +19 -0
  183. package/react/dist/blocks/profile-block.d.ts +5 -1
  184. package/react/dist/blocks/profile-block.js +12 -13
  185. package/react/dist/blocks/reward-block.d.ts +13 -8
  186. package/react/dist/blocks/reward-block.js +7 -4
  187. package/react/dist/blocks/screen-header.d.ts +10 -2
  188. package/react/dist/blocks/screen-header.js +7 -4
  189. package/react/dist/blocks/setting-switch.js +6 -3
  190. package/react/dist/blocks/signals-block.d.ts +3 -1
  191. package/react/dist/blocks/signals-block.js +4 -3
  192. package/react/dist/blocks/sound-haptics-block.d.ts +3 -1
  193. package/react/dist/blocks/sound-haptics-block.js +2 -2
  194. package/react/dist/blocks/sticky-header.d.ts +14 -4
  195. package/react/dist/blocks/sticky-header.js +68 -8
  196. package/react/dist/blocks/swap/settings.js +2 -1
  197. package/react/dist/blocks/swap/shared.d.ts +22 -22
  198. package/react/dist/blocks/swap/shared.js +30 -28
  199. package/react/dist/blocks/swap-panel-block.d.ts +10 -3
  200. package/react/dist/blocks/swap-panel-block.js +71 -36
  201. package/react/dist/blocks/target-block.d.ts +7 -1
  202. package/react/dist/blocks/target-block.js +10 -4
  203. package/react/dist/blocks/token-action-block.d.ts +5 -1
  204. package/react/dist/blocks/token-action-block.js +2 -2
  205. package/react/dist/blocks/trade-history-detail-block.d.ts +3 -1
  206. package/react/dist/blocks/trade-history-detail-block.js +2 -2
  207. package/react/dist/blocks/trade-history-list-block.d.ts +3 -1
  208. package/react/dist/blocks/trade-history-list-block.js +7 -4
  209. package/react/dist/blocks.d.ts +5 -1
  210. package/react/dist/blocks.js +4 -0
  211. package/react/dist/brand.js +2 -1
  212. package/react/dist/button.d.ts +9 -3
  213. package/react/dist/button.js +8 -3
  214. package/react/dist/confetti.d.ts +27 -0
  215. package/react/dist/confetti.js +240 -0
  216. package/react/dist/data.js +8 -1
  217. package/react/dist/field.d.ts +6 -1
  218. package/react/dist/field.js +18 -9
  219. package/react/dist/gesture-sheet.d.ts +15 -1
  220. package/react/dist/gesture-sheet.js +53 -8
  221. package/react/dist/list-group.js +11 -7
  222. package/react/dist/navigation.js +11 -3
  223. package/react/dist/overlay.d.ts +28 -3
  224. package/react/dist/overlay.js +29 -3
  225. package/react/dist/preset-group.d.ts +30 -0
  226. package/react/dist/preset-group.js +13 -0
  227. package/react/dist/provider.d.ts +2 -2
  228. package/react/dist/provider.js +23 -6
  229. package/react/dist/qr-code.d.ts +32 -0
  230. package/react/dist/qr-code.js +28 -0
  231. package/react/dist/select.js +10 -3
  232. package/react/dist/selection.d.ts +13 -5
  233. package/react/dist/selection.js +13 -8
  234. package/react/dist/slider.js +5 -1
  235. package/react/dist/status.d.ts +14 -10
  236. package/react/dist/status.js +17 -9
  237. package/react/dist/styles.css +238 -163
  238. package/react/dist/toast.d.ts +19 -12
  239. package/react/dist/toast.js +29 -7
  240. package/react/dist/wallet-address-core.d.ts +8 -4
  241. package/react/dist/wallet-address-core.js +10 -5
  242. package/tokens/README.md +2 -2
  243. package/tokens/dist/index.d.ts +16 -0
  244. package/tokens/dist/index.js +16 -0
  245. package/tokens/dist/manifest.json +8 -0
  246. package/tokens/dist/tokens.css +6 -0
@@ -14,8 +14,16 @@ export function useStickyHeaderScroll(onScroll) {
14
14
  }
15
15
  /** The fill of a pinned header: transparent at rest so what the host draws behind it shows through, `background` once content has scrolled under it. */
16
16
  export function stickyHeaderFill(scrolled, background) { return { backgroundColor: scrolled ? background : 'transparent' }; }
17
+ const stickySlotStyle = { flexDirection: 'row' };
18
+ const stickyScrollStyle = { flexGrow: 1, flexShrink: 1, minHeight: 0 };
17
19
  /** A block as its own scroll view with its header pinned: 16dp around the content as the block draws it, the header transparent until content scrolls under it. Place it in a bounded container, such as a sheet body. */
18
20
  export function StickyHeaderLayout({ header, children, background, scrollComponent: Scroll = ScrollView, testID, headerTestID, bodyStyle }) {
19
21
  const colors = useColors(), { scrolled, onScroll, scrollEventThrottle } = useStickyHeaderScroll();
20
- return _jsxs(Scroll, { testID: testID, stickyHeaderIndices: [0], onScroll: onScroll, scrollEventThrottle: scrollEventThrottle, contentContainerStyle: { paddingBottom: 16 }, children: [_jsx(View, { testID: headerTestID, style: [{ paddingHorizontal: 16, paddingTop: 16 }, stickyHeaderFill(scrolled, background ?? colors.background)], children: header }), _jsx(View, { style: [{ paddingHorizontal: 16 }, bodyStyle], children: children })] });
22
+ // React Native's sticky slot moves the pinned child's style onto its own wrapper and gives the child flex:1, which measures 0 tall in a column.
23
+ // So the pinned child carries only a row direction (the wrapper lays out as a row, where flex:1 fills the width and the height follows content),
24
+ // and the inset and fill sit on the inner view, which keeps its full height whether or not the scroller pins it.
25
+ // The scroller fills a bounded parent and may shrink below its content, whatever scroll component the host passes, so the
26
+ // content scrolls inside it. It cannot bound itself: in a parent whose height follows its content (a View with no flex or
27
+ // height, a content-sized sheet) it grows to its content and nothing scrolls.
28
+ return _jsxs(Scroll, { testID: testID, style: stickyScrollStyle, stickyHeaderIndices: [0], onScroll: onScroll, scrollEventThrottle: scrollEventThrottle, contentContainerStyle: { paddingBottom: 16 }, children: [_jsx(View, { style: stickySlotStyle, children: _jsx(View, { testID: headerTestID, style: [{ flexGrow: 1, paddingHorizontal: 16, paddingTop: 16 }, stickyHeaderFill(scrolled, background ?? colors.background)], children: header }) }), _jsx(View, { style: [{ paddingHorizontal: 16 }, bodyStyle], children: children })] });
21
29
  }
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+ import { type PressableProps, type StyleProp, type ViewStyle } from 'react-native';
3
+ import type { SwapArtwork } from './swap-shared.js';
4
+ export interface SwapPillProps extends Omit<PressableProps, 'children' | 'style' | 'accessibilityRole' | 'accessibilityState'> {
5
+ /** The pill's text, drawn small and muted, such as Max; or host nodes drawn as given, such as a live figure. */
6
+ children: React.ReactNode;
7
+ /** Called on a press. */
8
+ onPress?: () => void;
9
+ /** Dims the pill, ignores presses and reads as unavailable. */
10
+ disabled?: boolean;
11
+ }
12
+ /** A small capsule action on a swap card, as the web `SwapPill`: Max, Test, a converted value. 32dp tall with a 44dp target; text is drawn small and muted, and other children as given. Other Pressable props, such as `accessibilityLabel`, `testID` or `android_disableSound`, reach it. */
13
+ export declare function SwapPill({ children, onPress, disabled, hitSlop, ...props }: SwapPillProps): React.JSX.Element;
14
+ export interface SwapAmountCardProps {
15
+ /** Asset name, drawn in the slot. */
16
+ name: string;
17
+ /** Asset symbol; its first letters stand in when there is no `icon`. */
18
+ symbol: string;
19
+ /** Asset artwork: an image URL, or an element the host draws. */
20
+ icon?: SwapArtwork;
21
+ /** Chain or venue artwork, stacked above the asset. */
22
+ chainIcon?: string;
23
+ /** Line above the name: the chain, venue or account the amount comes from. A string is drawn small and muted. */
24
+ context?: React.ReactNode;
25
+ /** Capsule actions on the trailing edge, such as Max. Use `SwapPill`. They stay their own targets. */
26
+ actions?: React.ReactNode;
27
+ /** Supporting line under the actions, such as the available balance. A string is drawn small and muted; a node, such as a live figure, as given. */
28
+ meta?: React.ReactNode;
29
+ /** The entered amount. */
30
+ value: number;
31
+ /** Accessible name of the amount: From amount. */
32
+ amountLabel: string;
33
+ /** Text before the amount, such as a currency sign. */
34
+ prefix?: string;
35
+ /** Text after the amount, such as a percent sign. */
36
+ suffix?: string;
37
+ /** Decimal places typed so far, so `1.50` keeps its zero. */
38
+ fractionDigits?: number;
39
+ /** Set while the entry ends with a decimal point that has no digits after it yet. */
40
+ trailingDot?: boolean;
41
+ /** Most decimal places the amount can show. Defaults to 8. */
42
+ maximumFractionDigits?: number;
43
+ /** Capsule under the amount, such as the converted value. Use `SwapPill`. */
44
+ conversion?: React.ReactNode;
45
+ /** Makes the slot a button that chooses the asset. Requires `selectLabel`. */
46
+ onSelect?: () => void;
47
+ /** Accessible name of the slot's button: Select token, From. */
48
+ selectLabel?: string;
49
+ style?: StyleProp<ViewStyle>;
50
+ /** Prefix of the test IDs: `<testID>` (the card), `-slot`, `-select`, `-name`, `-context`, `-actions`, `-meta`, `-amount` and `-conversion`. Defaults to `swap-amount-card`. */
51
+ testID?: string;
52
+ }
53
+ /**
54
+ * The swap panel's From card on its own, as the web `SwapAmountCard`: the asset with its actions and balance in the slot, the entered amount
55
+ * under it. The host owns the entry, the keypad and what the amount means.
56
+ */
57
+ export declare function SwapAmountCard({ name, symbol, icon, chainIcon, context, actions, meta, value, amountLabel, prefix, suffix, fractionDigits, trailingDot, maximumFractionDigits, conversion, onSelect, selectLabel, style, testID }: SwapAmountCardProps): React.JSX.Element;
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Pressable, StyleSheet, View } from 'react-native';
3
+ import { formatNumber } from './number-format.js';
4
+ import { Raised, useColors, useFills, useHIG, useNumberLocale } from './provider.js';
5
+ import { Text } from './surface.js';
6
+ import { AnimatedNumberReadout } from './animated-number.js';
7
+ import { TokenArt } from './swap-parts.js';
8
+ const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
9
+ const smallType = { fontSize: 14, lineHeight: 19 };
10
+ /** Test ID parts. */
11
+ const contextPart = 'context', metaPart = 'meta';
12
+ /** A small capsule action on a swap card, as the web `SwapPill`: Max, Test, a converted value. 32dp tall with a 44dp target; text is drawn small and muted, and other children as given. Other Pressable props, such as `accessibilityLabel`, `testID` or `android_disableSound`, reach it. */
13
+ export function SwapPill({ children, onPress, disabled, hitSlop, ...props }) {
14
+ const colors = useColors(), fills = useFills(), { direction } = useHIG();
15
+ const text = typeof children === 'string' || typeof children === 'number';
16
+ return _jsx(Pressable, { ...props, accessibilityRole: 'button', accessibilityState: { disabled: !!disabled }, disabled: disabled, onPress: onPress, hitSlop: hitSlop ?? { top: 6, bottom: 6 }, style: ({ pressed }) => ({ direction, flexDirection: 'row', alignItems: 'center', gap: 6, minHeight: 32, paddingVertical: 4, paddingHorizontal: 12, borderRadius: 9999, backgroundColor: pressed && !disabled ? fills.raised : fills.well, opacity: disabled ? 0.5 : 1 }), children: text ? _jsx(Text, { style: { ...smallType, color: colors.muted }, children: children }) : children });
17
+ }
18
+ /**
19
+ * The swap panel's From card on its own, as the web `SwapAmountCard`: the asset with its actions and balance in the slot, the entered amount
20
+ * under it. The host owns the entry, the keypad and what the amount means.
21
+ */
22
+ export function SwapAmountCard({ name, symbol, icon, chainIcon, context, actions, meta, value, amountLabel, prefix = '', suffix = '', fractionDigits = 0, trailingDot = false, maximumFractionDigits = 8, conversion, onSelect, selectLabel, style, testID = 'swap-amount-card' }) {
23
+ const colors = useColors(), { direction } = useHIG(), locale = useNumberLocale();
24
+ const id = (part) => `${testID}-${part}`;
25
+ const small = { ...smallType, color: colors.muted };
26
+ const options = { minimumFractionDigits: Math.min(fractionDigits, maximumFractionDigits), maximumFractionDigits, useGrouping: false };
27
+ const after = (trailingDot ? '.' : '') + suffix;
28
+ const line = (node, part) => typeof node === 'string' || typeof node === 'number' ? _jsx(Text, { testID: id(part), style: small, children: node }) : _jsx(View, { testID: id(part), children: node });
29
+ const shown = (node) => node != null && node !== false;
30
+ return _jsx(View, { testID: testID, style: [{ direction, backgroundColor: colors.surface, borderRadius: 24, overflow: 'hidden' }, style], children: _jsxs(Raised, { children: [_jsxs(View, { testID: id('slot'), children: [onSelect ? _jsx(Pressable, { testID: id('select'), accessibilityRole: 'button', accessibilityLabel: selectLabel, onPress: onSelect, style: StyleSheet.absoluteFill }) : null, _jsxs(View, { pointerEvents: 'box-none', style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12, minHeight: 84, padding: 16 }, children: [_jsxs(View, { pointerEvents: 'none', style: { flex: 1, minWidth: 0, flexDirection: 'row', alignItems: 'flex-start', gap: 12 }, children: [_jsxs(View, { ...hidden, style: { alignItems: 'center' }, children: [chainIcon ? _jsx(TokenArt, { uri: chainIcon, size: 28, ring: colors.surface }) : null, _jsx(View, { style: { marginTop: chainIcon ? -14 : 0 }, children: _jsx(TokenArt, { uri: icon, symbol: symbol, size: 28, ring: colors.surface }) })] }), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [shown(context) ? line(context, contextPart) : null, _jsx(Text, { testID: id('name'), style: { fontWeight: '600', lineHeight: 21 }, children: name })] })] }), shown(actions) || shown(meta) ? _jsxs(View, { pointerEvents: 'box-none', style: { alignItems: 'flex-end', gap: 8, maxWidth: '60%' }, children: [shown(actions) ? _jsx(View, { testID: id('actions'), pointerEvents: 'box-none', style: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'flex-end', gap: 8 }, children: actions }) : null, shown(meta) ? line(meta, metaPart) : null] }) : null] })] }), _jsxs(View, { pointerEvents: 'box-none', style: { alignItems: 'center', gap: 8, paddingTop: 4, paddingHorizontal: 16, paddingBottom: 20 }, children: [_jsx(View, { accessible: true, accessibilityLabel: amountLabel, accessibilityValue: { text: `${prefix}${formatNumber(value, locale, options)}${after}` }, testID: id('amount'), children: _jsx(AnimatedNumberReadout, { value: value, prefix: prefix, suffix: after, options: options, maxFontSizeMultiplier: 1.5, style: { fontSize: 44, lineHeight: 50, fontWeight: '700', letterSpacing: -0.9, textAlign: 'center' } }) }), shown(conversion) ? _jsx(View, { testID: id('conversion'), children: conversion }) : null] })] }) });
31
+ }
@@ -4,6 +4,7 @@ import { type SwapAction, type SwapArtwork, type SwapChain, type SwapDenominatio
4
4
  export { swapAction, swapParentView, type SwapAction, type SwapArtwork, type SwapChain, type SwapDenomination, type SwapFee, type SwapFigure, type SwapToken, type SwapView, type SwapWallet } from './swap-shared.js';
5
5
  /** What a host surface lends the panel. A sheet passes its backend's list, so list drags hand off to the sheet, and sizes itself, so the panel does not animate its own height. */
6
6
  export { SwapHostContext } from './swap-parts.js';
7
+ export { SwapAmountCard, SwapPill, type SwapAmountCardProps, type SwapPillProps } from './swap-amount-card.js';
7
8
  /** A fixed place the assets go, in place of a token the user picks: a wallet, a staking pool, a trading account. Shown as a compact To card with no amount. */
8
9
  export interface SwapDestination {
9
10
  title: string;
@@ -80,7 +81,10 @@ export interface SwapPanelBlockProps {
80
81
  onReceivingChange?: (receiving: boolean) => void;
81
82
  /** The host validates, quotes and executes. HIG never submits a transaction. */
82
83
  onSubmit: (action: SwapAction) => void;
84
+ /** The host's submit is in flight: the action shows a spinner and ignores presses, the keypad, Max and Test leave the amount as it is, and the action keeps its ready name (or `submittingLabel`, or a held action's `actionStatus`) even when the host has cleared the amount meanwhile, never “Enter an amount” or the balance check. */
83
85
  submitting?: boolean;
86
+ /** What the action says while `submitting`, in place of its ready name: Burning…. Host text. */
87
+ submittingLabel?: string;
84
88
  /** Called after the panel clears its entry and both tokens (through `onFromChange(null)` / `onToChange(null)`), so the host can drop its quote. */
85
89
  onReset?: () => void;
86
90
  /** On native there is no hardware keyboard to rely on, so `auto` shows the keypad; `never` hides it. */
@@ -93,9 +97,11 @@ export interface SwapPanelBlockProps {
93
97
  /** A line under the cards: a limit, a delay, a warning. `noteTone` tints it. */
94
98
  note?: React.ReactNode;
95
99
  noteTone?: 'muted' | 'warning' | 'negative';
96
- /** Heading above the cards, for a panel that is its own screen or sheet. `onBack` adds a Back control before it. */
100
+ /** Heading above the cards, for a panel that is its own screen or sheet, drawn as the shared `ScreenHeader` (the title centred, 17/24, in a 44dp row) like every other block. `onBack` adds Back on its leading edge. Test IDs `swap-header`, `swap-back` and `swap-title`. */
97
101
  title?: string;
98
102
  onBack?: () => void;
103
+ /** With `title`: `nativeID` of the heading, so a sheet around the panel can name itself with `accessibilityLabelledBy` (Android). */
104
+ headingId?: string;
99
105
  /** `false` leaves the action button on its own, full width: no settings and no reset button. */
100
106
  controls?: boolean;
101
107
  /** Decoration before the action text. */
@@ -107,7 +113,7 @@ export interface SwapPanelBlockProps {
107
113
  actionLabel?: string;
108
114
  /** Holds the action for a reason only the host knows: below a minimum, no quote yet, a closed market. The panel's own checks (a token, an amount, the balance) still apply first. */
109
115
  actionDisabled?: boolean;
110
- /** What the held action says, for example “Below minimum”. Without it the action keeps its ready name. */
116
+ /** What the held action says, for example “Below minimum” or, while `submitting`, “Signing…” (a `submittingLabel` wins over it). Without it the action keeps its ready name. */
111
117
  actionStatus?: string;
112
118
  /** `destructive` for an action that cannot be undone, such as a burn. */
113
119
  actionIntent?: 'primary' | 'destructive';
@@ -138,7 +144,7 @@ export interface SwapPanelBlockProps {
138
144
  * or token units through the keypad, token pickers, settings, and one action that names itself from the chosen pair.
139
145
  * Presentation only. The host owns tokens, balances, prices, the quote, the wallet and the transaction.
140
146
  */
141
- export declare function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains, hotTokenIds, from: fromProp, to: toProp, defaultFrom, defaultTo, onFromChange, onToChange, amount, onAmountChange, received, fee, fees, quoteLoading, slippage, onSlippageChange, denomination, onDenominationChange, wallet, onConnect, onDisconnect, recipient, onRecipientChange, onScanRecipient, receive, receiving, onReceivingChange, onSubmit, submitting, onReset, keypad, destination, details, note, noteTone, title, onBack, controls, actionIcon, lockFrom, lockTo, actionLabel, actionDisabled, actionStatus, actionIntent, limitToBalance, banner, footer, oneWay: oneWayProp, denominationSwitch, settings, view: viewProp, onViewChange, style }: SwapPanelBlockProps): React.JSX.Element;
147
+ export declare function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains, hotTokenIds, from: fromProp, to: toProp, defaultFrom, defaultTo, onFromChange, onToChange, amount, onAmountChange, received, fee, fees, quoteLoading, slippage, onSlippageChange, denomination, onDenominationChange, wallet, onConnect, onDisconnect, recipient, onRecipientChange, onScanRecipient, receive, receiving, onReceivingChange, onSubmit, submitting, submittingLabel, onReset, keypad, destination, details, note, noteTone, title, onBack, headingId, controls, actionIcon, lockFrom, lockTo, actionLabel, actionDisabled, actionStatus, actionIntent, limitToBalance, banner, footer, oneWay: oneWayProp, denominationSwitch, settings, view: viewProp, onViewChange, style }: SwapPanelBlockProps): React.JSX.Element;
142
148
  /** @deprecated Renamed `SwapPanelBlock`. The old name keeps working until the next major release. */
143
149
  export declare const SwapPanel: typeof SwapPanelBlock;
144
150
  /** @deprecated Renamed `SwapPanelBlockProps`. */
@@ -1,7 +1,9 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { decimal, decimalDivide, decimalCompare, localizeDecimal } from '@bloxwap/hig/contracts';
3
+ import { useAsyncResult } from './async-result.js';
2
4
  import { useContext, useEffect, useMemo, useRef, useState } from 'react';
3
5
  import { Animated, BackHandler, Easing, Platform, Pressable, StyleSheet, View } from 'react-native';
4
- import { formatNumber } from '@bloxwap/hig/contracts';
6
+ import { formatNumber } from './number-format.js';
5
7
  import { Raised, useColors, useControllable, useHIG, useMessages, useNumberLocale, usePresentNumber } from './provider.js';
6
8
  import { Text } from './surface.js';
7
9
  import { Button, IconButton } from './button.js';
@@ -10,18 +12,20 @@ import { figureProps } from './figure.js';
10
12
  import { Toast, useTransientNotice } from './status.js';
11
13
  import { VerticalAddress, addressKind } from './data.js';
12
14
  import { withAlpha } from '@bloxwap/hig/tokens';
13
- import { DownIcon, FlipIcon, MenuIcon, ResetIcon, SmallChevron, SwapCapsule, SwapHeader, SwapHostContext, SwapKeypad, SwapNumberText, TokenArt } from './swap-parts.js';
15
+ import { DownIcon, FlipIcon, MenuIcon, ResetIcon, SmallChevron, SwapCapsule, SwapHostContext, SwapKeypad, SwapNumberText, TokenArt } from './swap-parts.js';
16
+ import { ScreenHeader } from './screen-header.js';
14
17
  import { SwapPicker, SwapSettings } from './swap-views.js';
15
- import { addressColor, applyAmountKey, formatPercent, shortAddress, swapAction, swapParentView, testAmount, trimNumber, unitsToEntry } from './swap-shared.js';
18
+ import { addressColor, applyAmountKey, formatPercent, shortAddress, swapAction, swapParentView, testAmount, unitsToEntry } from './swap-shared.js';
16
19
  export { swapAction, swapParentView } from './swap-shared.js';
17
20
  /** What a host surface lends the panel. A sheet passes its backend's list, so list drags hand off to the sheet, and sizes itself, so the panel does not animate its own height. */
18
21
  export { SwapHostContext } from './swap-parts.js';
22
+ export { SwapAmountCard, SwapPill } from './swap-amount-card.js';
19
23
  /**
20
24
  * Send, swap and bridge in one panel: a From card and a To card joined by a flip control, an amount entered in dollars
21
25
  * or token units through the keypad, token pickers, settings, and one action that names itself from the chosen pair.
22
26
  * Presentation only. The host owns tokens, balances, prices, the quote, the wallet and the transaction.
23
27
  */
24
- export function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains, hotTokenIds, from: fromProp, to: toProp, defaultFrom = null, defaultTo = null, onFromChange, onToChange, amount, onAmountChange, received, fee, fees, quoteLoading, slippage = 0.005, onSlippageChange, denomination, onDenominationChange, wallet, onConnect, onDisconnect, recipient, onRecipientChange, onScanRecipient, receive, receiving, onReceivingChange, onSubmit, submitting = false, onReset, keypad = 'auto', destination, details, note, noteTone = 'muted', title, onBack, controls = true, actionIcon, lockFrom = false, lockTo = false, actionLabel, actionDisabled = false, actionStatus, actionIntent = 'primary', limitToBalance = false, banner, footer, oneWay: oneWayProp = false, denominationSwitch = true, settings, view: viewProp, onViewChange, style }) {
28
+ export function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains, hotTokenIds, from: fromProp, to: toProp, defaultFrom = null, defaultTo = null, onFromChange, onToChange, amount, onAmountChange, received, fee, fees, quoteLoading, slippage = 0.005, onSlippageChange, denomination, onDenominationChange, wallet, onConnect, onDisconnect, recipient, onRecipientChange, onScanRecipient, receive, receiving, onReceivingChange, onSubmit, submitting = false, submittingLabel, onReset, keypad = 'auto', destination, details, note, noteTone = 'muted', title, onBack, headingId, controls = true, actionIcon, lockFrom = false, lockTo = false, actionLabel, actionDisabled = false, actionStatus, actionIntent = 'primary', limitToBalance = false, banner, footer, oneWay: oneWayProp = false, denominationSwitch = true, settings, view: viewProp, onViewChange, style }) {
25
29
  const env = useHIG();
26
30
  const { direction } = env;
27
31
  const locale = useNumberLocale();
@@ -30,10 +34,11 @@ export function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains,
30
34
  const t = useMessages();
31
35
  const [from, setFrom] = useControllable(fromProp, defaultFrom, onFromChange);
32
36
  const [to, setTo] = useControllable(toProp, defaultTo, onToChange);
37
+ const boundedUnits = (raw) => { const canonical = decimal(raw, from?.decimals ?? 100); return limitToBalance && from?.balance != null && Number.isFinite(from.balance) && from.balance >= 0 && decimalCompare(canonical, from.balance) > 0 ? decimal(from.balance, from?.decimals ?? 100) : canonical; };
33
38
  const [defaultMode, setDefaultMode] = useControllable(denomination, 'usd', onDenominationChange);
34
39
  const [isReceiving, setReceiving] = useControllable(receiving, false, onReceivingChange);
35
40
  // `amount` seeds the first render too, in the default denomination at the initial From token's price.
36
- const [entry, setEntry] = useState(() => amount === undefined ? '0' : unitsToEntry(Number(amount) || 0, defaultMode, from?.price ?? 0));
41
+ const [entry, setEntry] = useState(() => amount === undefined ? '0' : unitsToEntry(boundedUnits(amount), defaultMode, from?.price ?? 0));
37
42
  const [fromMode, setFromMode] = useState(defaultMode);
38
43
  const [toMode, applyToMode] = useState(defaultMode);
39
44
  const host = useContext(SwapHostContext);
@@ -50,7 +55,9 @@ export function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains,
50
55
  return; const subscription = BackHandler.addEventListener('hardwareBackPress', () => { pop.current(); return true; }); return () => subscription.remove(); }, [view === 'main']);
51
56
  const { notice, show: showNotice, dismiss: dismissNotice } = useTransientNotice();
52
57
  const fromPrice = from?.price ?? 0, toPrice = to?.price ?? 0, input = Number(entry) || 0;
53
- const units = fromMode === 'token' ? input : fromPrice > 0 ? input / fromPrice : 0, usd = units * fromPrice, unitsText = trimNumber(units);
58
+ const exact = useRef(amount === undefined ? null : { entry, mode: fromMode, units: boundedUnits(amount), asset: from?.id });
59
+ const unitsText = exact.current && exact.current.entry === entry && exact.current.mode === fromMode && exact.current.asset === from?.id ? exact.current.units : fromMode === 'token' ? decimal(entry, from?.decimals ?? 100) : decimalDivide(entry, fromPrice, from?.decimals ?? 18);
60
+ const units = Number(unitsText), usd = units * fromPrice;
54
61
  const showReceive = isReceiving && !!receive;
55
62
  // Report the amount in token units; resync the entry when the host sets a different amount.
56
63
  const reported = useRef(amount ?? '0');
@@ -58,42 +65,53 @@ export function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains,
58
65
  reported.current = unitsText;
59
66
  onAmountChange?.(unitsText);
60
67
  } }, [unitsText]);
61
- useEffect(() => { if (amount === undefined || Number(amount) === Number(reported.current))
62
- return; reported.current = trimNumber(Number(amount) || 0); setEntry(unitsToEntry(Number(amount) || 0, fromMode, fromPrice)); }, [amount]);
63
- const sameAsset = !!from && !!to && from.id === to.id;
68
+ useEffect(() => { if (amount === undefined || boundedUnits(amount) === reported.current)
69
+ return; const canonical = boundedUnits(amount), next = unitsToEntry(canonical, fromMode, fromPrice); reported.current = canonical; if (decimal(amount) !== canonical)
70
+ onAmountChange?.(canonical); exact.current = { entry: next, mode: fromMode, units: canonical, asset: from?.id }; setEntry(next); }, [amount]);
71
+ const sameAsset = !!from && !!to && swapAction(from, to) === 'send';
64
72
  const receivedUnits = sameAsset ? units : received ?? (toPrice > 0 ? usd / toPrice : 0);
65
73
  const receivedUsd = toPrice > 0 ? receivedUnits * toPrice : sameAsset ? usd : 0;
66
74
  const action = swapAction(from, to);
67
- const insufficient = !!from && (from.balance ?? 0) > 0 && units > (from.balance ?? 0);
75
+ const insufficient = !!from && from.balance != null && (!Number.isFinite(from.balance) || from.balance < 0 || decimalCompare(unitsText, from.balance) > 0);
68
76
  // A destination or a details card stands in for the To token: one way, and ready from the From side alone.
69
77
  const fixed = !!destination || (!!details && !to);
70
78
  const oneWay = oneWayProp || fixed;
71
- const eligible = !!from && (!!to || fixed) && !destination?.pending && units > 0 && !insufficient;
79
+ const eligible = !!from && (!!to || fixed) && !destination?.pending && Number.isFinite(units) && units > 0 && !insufficient;
72
80
  const ready = eligible && !actionDisabled;
73
- const actionText = showReceive ? t.swapSendFromWallet : !from || (!to && !fixed) ? t.swapChooseToken : destination?.pending ? t.swapChooseDestination : units <= 0 ? t.swapEnterAmount : insufficient ? t.swapInsufficient(from.symbol) : actionDisabled && actionStatus ? actionStatus : actionLabel ?? (action === 'swap' && !fixed ? t.swapActionSwap : action === 'bridge' && !fixed ? t.swapActionBridge : t.swapActionSend);
81
+ const readyText = actionLabel ?? (action === 'swap' && !fixed ? t.swapActionSwap : action === 'bridge' && !fixed ? t.swapActionBridge : t.swapActionSend);
82
+ // While the host's submit is in flight the amount may already be cleared: the action keeps its name rather than asking for an amount.
83
+ const actionText = showReceive ? t.swapSendFromWallet : !from || (!to && !fixed) ? t.swapChooseToken : destination?.pending ? t.swapChooseDestination : submitting ? submittingLabel ?? (actionDisabled && actionStatus ? actionStatus : readyText) : units <= 0 ? t.swapEnterAmount : insufficient ? t.swapInsufficient(from.symbol) : actionDisabled && actionStatus ? actionStatus : readyText;
74
84
  const pristine = (lockFrom || !from) && (lockTo || !to) && input === 0;
75
85
  // Updater form: several keys can land before the next render, and each must build on the last.
76
86
  const latest = useRef(fromMode);
77
87
  latest.current = fromMode;
78
88
  // Read at key time: several keys can land in one render.
79
- const limits = useRef({ decimals: from?.decimals, balance: from?.balance ?? 0, price: from?.price ?? 0, cap: limitToBalance });
80
- limits.current = { decimals: from?.decimals, balance: from?.balance ?? 0, price: from?.price ?? 0, cap: limitToBalance };
81
- const over = (next) => { const { balance, price, cap } = limits.current; if (!cap || !(balance > 0))
82
- return false; const value = Number(next) || 0; return (latest.current === 'token' ? value : price > 0 ? value / price : 0) > balance; };
83
- const press = (key) => setEntry(current => { const next = applyAmountKey(current, key, latest.current, limits.current.decimals); return key !== 'back' && over(next) ? current : next; });
84
- const switchFromMode = (mode) => { if (mode === fromMode)
85
- return; setEntry(mode === 'usd' ? trimNumber(usd, 2) : trimNumber(units)); setFromMode(mode); };
86
- const changeDenomination = (mode) => { setDefaultMode(mode); switchFromMode(mode); applyToMode(mode); };
89
+ const limits = useRef({ decimals: from?.decimals, balance: from?.balance, price: from?.price ?? 0, cap: limitToBalance });
90
+ limits.current = { decimals: from?.decimals, balance: from?.balance, price: from?.price ?? 0, cap: limitToBalance };
91
+ const over = (next) => { const { balance, price, cap } = limits.current; if (!cap || balance == null)
92
+ return false; if (!Number.isFinite(balance) || balance < 0)
93
+ return true; const value = latest.current === 'token' ? next : decimalDivide(next, price, limits.current.decimals ?? 18); return decimalCompare(value, balance) > 0; };
94
+ // While the host's submit is in flight the keypad, Max and Test leave the amount as it is.
95
+ const typed = next => { if (!submitting)
96
+ setEntry(current => { const value = typeof next === 'function' ? next(current) : next; if (value === current || value.length > 1000)
97
+ return current; const normalized = decimal(value, latest.current === 'usd' ? 2 : limits.current.decimals ?? 100); if (over(normalized))
98
+ return current; exact.current = null; const [whole, fraction] = value.split('.'); const places = latest.current === 'usd' ? 2 : limits.current.decimals ?? 100; return fraction === undefined ? whole : places > 0 ? whole + '.' + fraction.slice(0, places) : whole; }); };
99
+ const press = (key) => typed(current => { const next = applyAmountKey(current, key, latest.current, limits.current.decimals); return key !== 'back' && over(next) ? current : next; });
100
+ const switchFromMode = (mode) => { if (submitting || mode === fromMode)
101
+ return; const next = unitsToEntry(unitsText, mode, fromPrice); exact.current = { entry: next, mode, units: unitsText, asset: from?.id }; setEntry(next); setFromMode(mode); };
102
+ const changeDenomination = (mode) => { if (submitting)
103
+ return; setDefaultMode(mode); switchFromMode(mode); applyToMode(mode); };
87
104
  // A new default applies to an untouched entry at once; a typed amount keeps its denomination until reset.
88
105
  useEffect(() => { if (input === 0) {
89
106
  setFromMode(defaultMode);
90
107
  applyToMode(defaultMode);
91
108
  } }, [defaultMode]);
92
- const reset = () => { setEntry('0'); setFromMode(defaultMode); applyToMode(defaultMode); if (isReceiving)
109
+ const reset = () => { if (submitting)
110
+ return; exact.current = null; setEntry('0'); setFromMode(defaultMode); applyToMode(defaultMode); if (isReceiving)
93
111
  setReceiving(false); if (!lockFrom)
94
112
  setFrom(null); if (!lockTo)
95
113
  setTo(null); onReset?.(); };
96
- const flip = () => { if (!from || !to)
114
+ const flip = () => { if (submitting || !from || !to)
97
115
  return; setFrom(to); setTo(from); };
98
116
  const submit = () => { if (submitting)
99
117
  return; if (showReceive) {
@@ -102,8 +120,10 @@ export function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains,
102
120
  } if (ready)
103
121
  onSubmit(fixed ? 'send' : action); };
104
122
  // A copied address shows as a transient toast capsule (about 4s, dismissible), announced the way Toast announces any notice.
105
- const copyAddress = () => { if (!receive?.onCopy)
106
- return; Promise.resolve().then(receive.onCopy).then(() => showNotice(t.addressCopied)).catch(() => { }); };
123
+ const beginCopy = useAsyncResult(receive?.address);
124
+ const copyAddress = () => { const current = beginCopy(); if (!receive?.onCopy)
125
+ return; Promise.resolve().then(receive.onCopy).then(() => { if (current())
126
+ showNotice(t.addressCopied); }).catch(() => { }); };
107
127
  const chainList = useMemo(() => { if (chains)
108
128
  return chains; const seen = new Map(); for (const token of tokens)
109
129
  if (!seen.has(token.chainId))
@@ -114,9 +134,9 @@ export function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains,
114
134
  // Live numbers: the fee and slippage sentences keep their translated wording around a number that updates in place.
115
135
  const usdOptions = { style: 'currency', currency: 'USD' }, feeKnown = !quoteLoading && fee != null, feeAmount = quoteLoading ? '…' : fee != null ? usdText(fee) : '—', slippageText = formatPercent(slippage);
116
136
  // An account (a token with a `caption`) reads name over caption beside one disc, and offers Max only.
117
- const account = (side, token, locked) => _jsxs(_Fragment, { children: [_jsxs(View, { pointerEvents: 'none', testID: `swap-account-${side}`, style: { flex: 1, minWidth: 0, flexDirection: 'row', alignItems: 'center', gap: 12 }, children: [_jsx(View, { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', children: _jsx(TokenArt, { uri: token.icon, symbol: token.symbol, size: 40 }) }), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 4 }, children: [_jsx(Text, { style: { fontWeight: '600', lineHeight: 21, flexShrink: 1 }, children: token.name }), locked ? null : _jsx(View, { testID: `swap-account-chevron-${side}`, children: _jsx(SmallChevron, { color: colors.muted }) })] }), typeof token.caption === 'object' ? _jsx(AnimatedNumberReadout, { testID: 'swap-caption', ...figureProps(token.caption), tone: 'muted', style: smallType }) : _jsx(Text, { style: small, children: token.caption })] })] }), side === 'from' && (token.balance ?? 0) > 0 ? _jsx(SwapCapsule, { testID: 'swap-max', onPress: () => setEntry(unitsToEntry(token.balance ?? 0, fromMode, fromPrice)), children: _jsx(Text, { style: small, children: t.swapMax }) }) : null] });
118
- const header = (side, token) => _jsxs(_Fragment, { children: [_jsxs(View, { pointerEvents: 'none', style: { flex: 1, minWidth: 0, flexDirection: 'row', alignItems: 'flex-start', gap: 12 }, children: [_jsx(View, { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', style: { alignItems: 'center' }, children: [wallet?.address ? _jsx(View, { style: { width: 28, height: 28, borderRadius: 14, backgroundColor: addressColor(wallet.address), borderWidth: 2, borderColor: colors.surface } }) : null, token.chainIcon ? _jsx(TokenArt, { uri: token.chainIcon, size: 28, ring: colors.surface }) : null, _jsx(TokenArt, { uri: token.icon, symbol: token.symbol, size: 28, ring: colors.surface })].filter(Boolean).map((layer, index) => _jsx(View, { style: { marginTop: index ? -14 : 0 }, children: layer }, index)) }), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [wallet?.address ? _jsx(Text, { style: small, children: shortAddress(wallet.address) }) : null, _jsx(Text, { style: small, children: token.chain }), _jsx(Text, { style: { fontWeight: '600', lineHeight: 21 }, children: token.name })] })] }), side === 'from' ? ((token.balance ?? 0) > 0 ? _jsxs(View, { pointerEvents: 'box-none', style: { alignItems: 'flex-end', gap: 8, maxWidth: '60%' }, children: [_jsxs(View, { pointerEvents: 'box-none', style: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'flex-end', gap: 8 }, children: [_jsx(SwapCapsule, { testID: 'swap-test', onPress: () => setEntry(unitsToEntry(testAmount(token), fromMode, fromPrice)), children: _jsx(Text, { style: small, children: t.swapTest }) }), _jsx(SwapCapsule, { testID: 'swap-max', onPress: () => setEntry(unitsToEntry(token.balance ?? 0, fromMode, fromPrice)), children: _jsx(Text, { style: small, children: t.swapMax }) })] }), _jsx(View, { pointerEvents: 'none', children: _jsx(AnimatedNumberReadout, { testID: 'swap-balance', value: token.balance, options: { maximumFractionDigits: 6 }, suffix: ` ${token.symbol}`, tone: 'muted', style: smallType }) })] }) : null)
119
- : _jsxs(View, { pointerEvents: 'box-none', style: { alignItems: 'flex-end', gap: 8, maxWidth: '60%' }, children: [_jsx(SwapCapsule, { testID: 'swap-slippage', label: t.swapSlippage(slippageText), onPress: () => show(onSlippageChange ? 'slippage' : 'settings'), children: _jsx(SwapNumberText, { template: t.swapSlippage, text: slippageText, value: slippage * 100, formattedValue: slippageText.slice(0, -1), suffix: '%' }) }), _jsx(View, { pointerEvents: 'none', children: _jsx(SwapNumberText, { testID: 'swap-fee', template: t.swapFee, text: feeAmount, value: feeKnown ? fee : null, options: usdOptions }) })] })] });
137
+ const account = (side, token, locked) => _jsxs(_Fragment, { children: [_jsxs(View, { pointerEvents: 'none', testID: `swap-account-${side}`, style: { flex: 1, minWidth: 0, flexDirection: 'row', alignItems: 'center', gap: 12 }, children: [_jsx(View, { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', children: _jsx(TokenArt, { uri: token.icon, symbol: token.symbol, size: 40 }) }), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 4 }, children: [_jsx(Text, { style: { fontWeight: '600', lineHeight: 21, flexShrink: 1 }, children: token.name }), locked ? null : _jsx(View, { testID: `swap-account-chevron-${side}`, children: _jsx(SmallChevron, { color: colors.muted }) })] }), typeof token.caption === 'object' ? _jsx(AnimatedNumberReadout, { testID: 'swap-caption', ...figureProps(token.caption), tone: 'muted', style: smallType }) : _jsx(Text, { style: small, children: token.caption })] })] }), side === 'from' && (token.balance ?? 0) > 0 ? _jsx(SwapCapsule, { disabled: submitting, testID: 'swap-max', onPress: () => typed(unitsToEntry(token.balance ?? 0, fromMode, fromPrice)), children: _jsx(Text, { style: small, children: t.swapMax }) }) : null] });
138
+ const header = (side, token) => _jsxs(_Fragment, { children: [_jsxs(View, { pointerEvents: 'none', style: { flex: 1, minWidth: 0, flexDirection: 'row', alignItems: 'flex-start', gap: 12 }, children: [_jsx(View, { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', style: { alignItems: 'center' }, children: [wallet?.address ? _jsx(View, { style: { width: 28, height: 28, borderRadius: 14, backgroundColor: addressColor(wallet.address), borderWidth: 2, borderColor: colors.surface } }) : null, token.chainIcon ? _jsx(TokenArt, { uri: token.chainIcon, size: 28, ring: colors.surface }) : null, _jsx(TokenArt, { uri: token.icon, symbol: token.symbol, size: 28, ring: colors.surface })].filter(Boolean).map((layer, index) => _jsx(View, { style: { marginTop: index ? -14 : 0 }, children: layer }, index)) }), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [wallet?.address ? _jsx(Text, { style: small, children: shortAddress(wallet.address) }) : null, _jsx(Text, { style: small, children: token.chain }), _jsx(Text, { style: { fontWeight: '600', lineHeight: 21 }, children: token.name })] })] }), side === 'from' ? ((token.balance ?? 0) > 0 ? _jsxs(View, { pointerEvents: 'box-none', style: { alignItems: 'flex-end', gap: 8, maxWidth: '60%' }, children: [_jsxs(View, { pointerEvents: 'box-none', style: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'flex-end', gap: 8 }, children: [_jsx(SwapCapsule, { disabled: submitting, testID: 'swap-test', onPress: () => typed(unitsToEntry(testAmount(token), fromMode, fromPrice)), children: _jsx(Text, { style: small, children: t.swapTest }) }), _jsx(SwapCapsule, { disabled: submitting, testID: 'swap-max', onPress: () => typed(unitsToEntry(token.balance ?? 0, fromMode, fromPrice)), children: _jsx(Text, { style: small, children: t.swapMax }) })] }), _jsx(View, { pointerEvents: 'none', children: _jsx(AnimatedNumberReadout, { testID: 'swap-balance', value: token.balance, options: { maximumFractionDigits: 6 }, suffix: ` ${token.symbol}`, tone: 'muted', style: smallType }) })] }) : null)
139
+ : _jsxs(View, { pointerEvents: 'box-none', style: { alignItems: 'flex-end', gap: 8, maxWidth: '60%' }, children: [_jsx(SwapCapsule, { disabled: submitting, testID: 'swap-slippage', label: t.swapSlippage(slippageText), onPress: () => !submitting && show(onSlippageChange ? 'slippage' : 'settings'), children: _jsx(SwapNumberText, { template: t.swapSlippage, text: slippageText, value: slippage * 100, formattedValue: slippageText.slice(0, -1), suffix: '%' }) }), _jsx(View, { pointerEvents: 'none', children: _jsx(SwapNumberText, { testID: 'swap-fee', template: t.swapFee, text: feeAmount, value: feeKnown ? fee : null, options: usdOptions }) })] })] });
120
140
  const receiveView = (view) => {
121
141
  const body = _jsxs(_Fragment, { children: [view.qr ? _jsx(View, { style: { width: 132, height: 132, padding: 8, borderRadius: 16, backgroundColor: colors.background }, children: view.qr }) : null, _jsx(View, { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', children: _jsx(VerticalAddress, { address: view.address, rowHeight: addressKind(view.address) === 'ethereum' ? 22 : 16 }) })] });
122
142
  const layout = { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-evenly', gap: 12, paddingTop: 8, paddingHorizontal: 16, paddingBottom: 20 };
@@ -128,7 +148,7 @@ export function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains,
128
148
  const shown = side === 'from' ? input : mode === 'token' ? receivedUnits : receivedUsd;
129
149
  const options = { minimumFractionDigits: side === 'from' ? fraction : 0, maximumFractionDigits: mode === 'usd' ? 2 : 8, useGrouping: false };
130
150
  const prefix = mode === 'usd' ? '$' : '', suffix = side === 'from' && entry.endsWith('.') ? '.' : '';
131
- return _jsx(View, { testID: `swap-card-${side}`, style: { backgroundColor: colors.surface, borderRadius: 24, overflow: 'hidden' }, children: _jsxs(Raised, { children: [_jsxs(View, { children: [locked ? null : _jsx(Pressable, { accessibilityRole: 'button', accessibilityLabel: t.swapSelectToken(label), testID: `swap-slot-${side}`, onPress: () => show(side), style: StyleSheet.absoluteFill }), _jsx(View, { pointerEvents: 'box-none', style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12, minHeight: 84, padding: 16 }, children: token ? token.caption !== undefined ? account(side, token, locked) : header(side, token) : _jsx(View, { pointerEvents: 'none', children: _jsxs(Text, { accessible: false, style: { fontSize: 40, lineHeight: 46, fontWeight: '500', letterSpacing: -0.8, color: colors.faint }, children: [label, "\u2026"] }) }) })] }), side === 'from' && showReceive && receive ? receiveView(receive) : side === 'to' && showReceive ? null : _jsxs(View, { children: [locked ? null : _jsx(Pressable, { accessible: false, importantForAccessibility: 'no', testID: `swap-area-${side}`, onPress: () => show(side), style: StyleSheet.absoluteFill }), _jsxs(View, { pointerEvents: 'box-none', style: { alignItems: 'center', gap: 8, paddingTop: 4, paddingHorizontal: 16, paddingBottom: 20 }, children: [_jsx(View, { pointerEvents: 'none', accessible: true, accessibilityLabel: t.swapAmount(label), accessibilityValue: { text: `${prefix}${formatNumber(shown, locale, options)}${suffix}` }, testID: `swap-amount-${side}`, children: _jsx(AnimatedNumberReadout, { value: shown, prefix: prefix, suffix: suffix, options: options, tone: side === 'to' ? 'muted' : 'text', maxFontSizeMultiplier: 1.5, style: { fontSize: 44, lineHeight: 50, fontWeight: '700', letterSpacing: -0.9, textAlign: 'center' } }) }), denominationSwitch && _jsxs(SwapCapsule, { label: t.swapSwitchDenomination, testID: `swap-mode-${side}`, onPress: () => side === 'from' ? switchFromMode(fromMode === 'usd' ? 'token' : 'usd') : applyToMode(toMode === 'usd' ? 'token' : 'usd'), children: [_jsx(Text, { accessible: false, style: [small, { opacity: 0.5 }], children: "=" }), mode === 'token' ? _jsx(AnimatedNumberReadout, { testID: `swap-conversion-${side}`, value: cardUsd, options: usdOptions, tone: 'muted', style: smallType }) : _jsx(AnimatedNumberReadout, { testID: `swap-conversion-${side}`, value: cardUnits, options: { maximumFractionDigits: 8, useGrouping: false }, suffix: token ? ` ${token.symbol}` : '', tone: 'muted', style: smallType }), _jsx(FlipIcon, { color: colors.muted, size: 14 })] })] })] })] }) });
151
+ return _jsx(View, { testID: `swap-card-${side}`, style: { backgroundColor: colors.surface, borderRadius: 24, overflow: 'hidden' }, children: _jsxs(Raised, { children: [_jsxs(View, { children: [locked ? null : _jsx(Pressable, { accessibilityRole: 'button', accessibilityLabel: t.swapSelectToken(label), disabled: submitting, testID: `swap-slot-${side}`, onPress: () => !submitting && show(side), style: StyleSheet.absoluteFill }), _jsx(View, { pointerEvents: 'box-none', style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12, minHeight: 84, padding: 16 }, children: token ? token.caption !== undefined ? account(side, token, locked) : header(side, token) : _jsx(View, { pointerEvents: 'none', children: _jsxs(Text, { accessible: false, style: { fontSize: 40, lineHeight: 46, fontWeight: '500', letterSpacing: -0.8, color: colors.faint }, children: [label, "\u2026"] }) }) })] }), side === 'from' && showReceive && receive ? receiveView(receive) : side === 'to' && showReceive ? null : _jsxs(View, { children: [locked ? null : _jsx(Pressable, { accessible: false, importantForAccessibility: 'no', testID: `swap-area-${side}`, onPress: () => !submitting && show(side), style: StyleSheet.absoluteFill }), _jsxs(View, { pointerEvents: 'box-none', style: { alignItems: 'center', gap: 8, paddingTop: 4, paddingHorizontal: 16, paddingBottom: 20 }, children: [_jsx(View, { pointerEvents: 'none', accessible: true, accessibilityLabel: t.swapAmount(label), accessibilityValue: { text: side === 'from' && mode === 'token' ? localizeDecimal(entry, locale) : `${prefix}${formatNumber(shown, locale, options)}${suffix}` }, testID: `swap-amount-${side}`, children: _jsx(AnimatedNumberReadout, { value: shown, formattedValue: side === 'from' && mode === 'token' ? localizeDecimal(entry, locale) : undefined, prefix: prefix, suffix: side === 'from' && mode === 'token' ? '' : suffix, options: options, tone: side === 'to' ? 'muted' : 'text', maxFontSizeMultiplier: 1.5, style: { fontSize: 44, lineHeight: 50, fontWeight: '700', letterSpacing: -0.9, textAlign: 'center' } }) }), denominationSwitch && _jsxs(SwapCapsule, { disabled: submitting, label: t.swapSwitchDenomination, testID: `swap-mode-${side}`, onPress: () => !submitting && (side === 'from' ? switchFromMode(fromMode === 'usd' ? 'token' : 'usd') : applyToMode(toMode === 'usd' ? 'token' : 'usd')), children: [_jsx(Text, { accessible: false, style: [small, { opacity: 0.5 }], children: "=" }), mode === 'token' ? _jsx(AnimatedNumberReadout, { testID: `swap-conversion-${side}`, value: cardUsd, options: usdOptions, tone: 'muted', style: smallType }) : _jsx(AnimatedNumberReadout, { testID: `swap-conversion-${side}`, value: cardUnits, options: { maximumFractionDigits: 8, useGrouping: false }, suffix: token ? ` ${token.symbol}` : '', tone: 'muted', style: smallType }), _jsx(FlipIcon, { color: colors.muted, size: 14 })] })] })] })] }) });
132
152
  };
133
153
  // The fixed bottom card is one compact row for the destination (artwork, where it goes, a trailing detail and fee), label and value rows, or both.
134
154
  const fixedCard = () => {
@@ -139,15 +159,21 @@ export function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains,
139
159
  const rows = details && details.length > 0 ? _jsx(View, { testID: 'swap-details', style: { gap: 12, padding: 16, paddingTop: destination ? 0 : 16 }, children: details.map(detail => _jsxs(View, { style: { flexDirection: 'row', justifyContent: 'space-between', gap: 12 }, children: [_jsx(Text, { style: { color: colors.muted, lineHeight: 21 }, children: detail.label }), typeof detail.value === 'number' ? _jsx(AnimatedNumberReadout, { value: detail.value, options: detail.options, prefix: detail.prefix, suffix: detail.suffix, formattedValue: detail.formattedValue, animateFormatted: !!detail.formattedValue, style: { lineHeight: 21, textAlign: 'right' } }) : _jsx(Text, { style: { lineHeight: 21, textAlign: 'right', flexShrink: 1 }, children: detail.value })] }, detail.label)) }) : null;
140
160
  const shape = { backgroundColor: colors.surface, borderRadius: 24, overflow: 'hidden' };
141
161
  // With a pressable destination the whole card is the button; the rows inside it are read as part of it.
142
- return destination?.onPress ? _jsx(Pressable, { accessibilityRole: 'button', accessibilityLabel: destination.title, testID: 'swap-destination', onPress: destination.onPress, style: ({ pressed }) => [shape, { opacity: pressed ? 0.85 : 1 }], children: _jsxs(Raised, { children: [row, rows] }) }) : _jsx(View, { testID: 'swap-destination', style: shape, children: _jsxs(Raised, { children: [row, rows] }) });
162
+ return destination?.onPress ? _jsx(Pressable, { accessibilityRole: 'button', accessibilityLabel: destination.title, testID: 'swap-destination', disabled: submitting, onPress: () => { if (!submitting)
163
+ destination.onPress?.(); }, style: ({ pressed }) => [shape, { opacity: pressed ? 0.85 : 1 }], children: _jsxs(Raised, { children: [row, rows] }) }) : _jsx(View, { testID: 'swap-destination', style: shape, children: _jsxs(Raised, { children: [row, rows] }) });
143
164
  };
144
165
  const fromCard = card('from'), toCard = fixedCard() ?? card('to');
145
166
  const tone = noteTone === 'warning' ? colors.warning : noteTone === 'negative' ? colors.negative : null;
146
- const main = _jsxs(View, { testID: 'swap-view-main', children: [title ? _jsx(View, { style: { marginBottom: 12 }, children: _jsx(SwapHeader, { title: title, onBack: onBack }) }) : null, banner ? _jsx(View, { testID: 'swap-banner', style: { marginBottom: 8 }, children: banner }) : null, fromCard, _jsx(View, { style: { height: 8, zIndex: 1, alignItems: 'center' }, children: _jsx(View, { style: { position: 'absolute', top: -15, width: 38, height: 38, borderRadius: 19, backgroundColor: colors.background, alignItems: 'center', justifyContent: 'center' }, children: oneWay ? _jsx(View, { testID: 'swap-one-way', style: { width: 32, height: 32, borderRadius: 16, alignItems: 'center', justifyContent: 'center', backgroundColor: colors.nested }, children: _jsx(DownIcon, { color: colors.muted }) }) : _jsx(Pressable, { accessibilityRole: 'button', accessibilityLabel: t.swapFlip, accessibilityState: { disabled: !from || !to }, disabled: !from || !to, testID: 'swap-flip', onPress: flip, hitSlop: 6, style: ({ pressed }) => ({ width: 32, height: 32, borderRadius: 16, alignItems: 'center', justifyContent: 'center', backgroundColor: !from || !to ? colors.surface : colors.nested, opacity: pressed ? 0.85 : 1 }), children: _jsx(FlipIcon, { color: !from || !to ? colors.faint : colors.muted }) }) }) }), toCard, note ? _jsx(View, { testID: 'swap-note', style: tone ? { marginTop: 8, paddingVertical: 12, paddingHorizontal: 16, borderRadius: 16, backgroundColor: withAlpha(tone, 0.1) } : { marginTop: 8, paddingHorizontal: 4 }, children: _jsx(Text, { style: { fontSize: 14, lineHeight: 21, color: tone ?? colors.muted }, children: note }) }) : null, !showReceive && keypad !== 'never' ? _jsx(SwapKeypad, { onKey: press, label: t.swapKeypad, deleteLabel: t.swapDelete }) : null, _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 8, marginTop: 16 }, children: [controls ? _jsx(IconButton, { intent: 'secondary', label: t.swapSettings, suppressFeedback: true, testID: 'swap-settings-button', onPress: () => show('settings'), children: _jsx(MenuIcon, { color: colors.text }) }) : null, _jsxs(Button, { intent: actionIntent, busy: submitting, disabled: !showReceive && !ready, testID: 'swap-action', onPress: submit, style: { flex: 1, alignSelf: 'auto' }, children: [actionIcon ? _jsx(View, { testID: 'swap-action-icon', accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', children: actionIcon }, 'icon') : null, actionText] }), controls ? _jsx(IconButton, { intent: 'secondary', label: t.swapReset, disabled: pristine || submitting, testID: 'swap-reset', onPress: reset, children: _jsx(ResetIcon, { color: colors.text }) }) : null] }), notice ? _jsx(View, { style: { marginTop: 8, alignItems: 'center' }, children: _jsx(Toast, { notices: [notice], onDismiss: dismissNotice }) }) : null, footer ? _jsx(View, { testID: 'swap-footer', style: { marginTop: 16 }, children: footer }) : null] });
167
+ const main = _jsxs(View, { testID: 'swap-view-main', children: [title ? _jsx(View, { style: { marginBottom: 12 }, children: _jsx(ScreenHeader, { testID: 'swap', title: title, onBack: onBack, headingId: headingId }) }) : null, banner ? _jsx(View, { testID: 'swap-banner', style: { marginBottom: 8 }, children: banner }) : null, fromCard, _jsx(View, { style: { height: 8, zIndex: 1, alignItems: 'center' }, children: _jsx(View, { style: { position: 'absolute', top: -15, width: 38, height: 38, borderRadius: 19, backgroundColor: colors.background, alignItems: 'center', justifyContent: 'center' }, children: oneWay ? _jsx(View, { testID: 'swap-one-way', style: { width: 32, height: 32, borderRadius: 16, alignItems: 'center', justifyContent: 'center', backgroundColor: colors.nested }, children: _jsx(DownIcon, { color: colors.muted }) }) : _jsx(Pressable, { accessibilityRole: 'button', accessibilityLabel: t.swapFlip, accessibilityState: { disabled: submitting || !from || !to }, disabled: submitting || !from || !to, testID: 'swap-flip', onPress: flip, hitSlop: 6, style: ({ pressed }) => ({ width: 32, height: 32, borderRadius: 16, alignItems: 'center', justifyContent: 'center', backgroundColor: !from || !to ? colors.surface : colors.nested, opacity: pressed ? 0.85 : 1 }), children: _jsx(FlipIcon, { color: !from || !to ? colors.faint : colors.muted }) }) }) }), toCard, note ? _jsx(View, { testID: 'swap-note', style: tone ? { marginTop: 8, paddingVertical: 12, paddingHorizontal: 16, borderRadius: 16, backgroundColor: withAlpha(tone, 0.1) } : { marginTop: 8, paddingHorizontal: 4 }, children: _jsx(Text, { style: { fontSize: 14, lineHeight: 21, color: tone ?? colors.muted }, children: note }) }) : null, !showReceive && keypad !== 'never' ? _jsx(SwapKeypad, { onKey: press, label: t.swapKeypad, deleteLabel: t.swapDelete }) : null, _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 8, marginTop: 16 }, children: [controls ? _jsx(IconButton, { intent: 'secondary', label: t.swapSettings, suppressFeedback: true, testID: 'swap-settings-button', disabled: submitting, onPress: () => !submitting && show('settings'), children: _jsx(MenuIcon, { color: colors.text }) }) : null, _jsxs(Button, { intent: actionIntent, busy: submitting, disabled: !showReceive && !ready, testID: 'swap-action', onPress: submit, style: { flex: 1, alignSelf: 'auto' }, children: [actionIcon ? _jsx(View, { testID: 'swap-action-icon', accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', children: actionIcon }, 'icon') : null, actionText] }), controls ? _jsx(IconButton, { intent: 'secondary', label: t.swapReset, disabled: pristine || submitting, testID: 'swap-reset', onPress: reset, children: _jsx(ResetIcon, { color: colors.text }) }) : null] }), notice ? _jsx(View, { style: { marginTop: 8, alignItems: 'center' }, children: _jsx(Toast, { notices: [notice], onDismiss: dismissNotice }) }) : null, footer ? _jsx(View, { testID: 'swap-footer', style: { marginTop: 16 }, children: footer }) : null] });
147
168
  const body = view === 'main' ? main
148
- : view === 'from' ? _jsx(SwapPicker, { side: view, onBack: back, tokens: fromTokens ?? tokens, loading: fromTokensLoading, chains: chainList, hotTokenIds: hotTokenIds, selected: from, onSelect: setFrom, wallet: wallet, onConnect: onConnect, onDisconnect: onDisconnect, receiving: isReceiving, onReceivingChange: receive ? setReceiving : undefined })
149
- : view === 'to' ? _jsx(SwapPicker, { side: view, onBack: back, tokens: tokens, chains: chainList, hotTokenIds: hotTokenIds, selected: to, onSelect: setTo, wallet: wallet, recipient: recipient, onRecipientChange: onRecipientChange, onScanRecipient: onScanRecipient })
150
- : _jsx(SwapSettings, { view: view, onViewChange: show, onBack: back, denomination: defaultMode, onDenominationChange: denominationSwitch ? changeDenomination : undefined, slippage: slippage, onSlippageChange: onSlippageChange, fee: fee, fees: fees, quoteLoading: quoteLoading, children: settings });
169
+ : view === 'from' ? _jsx(SwapPicker, { side: view, onBack: back, tokens: fromTokens ?? tokens, loading: fromTokensLoading, chains: chainList, hotTokenIds: hotTokenIds, selected: from, onSelect: token => { if (!submitting)
170
+ setFrom(token); }, wallet: wallet, onConnect: submitting ? undefined : onConnect, onDisconnect: submitting ? undefined : onDisconnect, receiving: isReceiving, onReceivingChange: receive ? value => { if (!submitting)
171
+ setReceiving(value); } : undefined })
172
+ : view === 'to' ? _jsx(SwapPicker, { side: view, onBack: back, tokens: tokens, chains: chainList, hotTokenIds: hotTokenIds, selected: to, onSelect: token => { if (!submitting)
173
+ setTo(token); }, wallet: wallet, recipient: recipient, onRecipientChange: value => { if (!submitting)
174
+ onRecipientChange?.(value); }, onScanRecipient: submitting ? undefined : onScanRecipient })
175
+ : _jsx(SwapSettings, { view: view, onViewChange: show, onBack: back, denomination: defaultMode, onDenominationChange: denominationSwitch ? changeDenomination : undefined, slippage: slippage, onSlippageChange: value => { if (!submitting)
176
+ onSlippageChange?.(value); }, fee: fee, fees: fees, quoteLoading: quoteLoading, children: settings });
151
177
  return _jsx(View, { testID: 'swap-panel', style: [{ direction, width: '100%', maxWidth: 448, alignSelf: 'center' }, style], children: _jsx(SwapStage, { view: view, animateHeight: host.animateHeight !== false, children: body }) });
152
178
  }
153
179
  const viewDepth = (view) => view === 'main' ? 0 : view === 'slippage' || view === 'fees' ? 2 : 1;
@@ -6,12 +6,10 @@ export declare const SwapHostContext: React.Context<{
6
6
  listComponent?: React.ComponentType<FlatListProps<SwapToken>>;
7
7
  animateHeight?: boolean;
8
8
  }>;
9
- /** One arrow, top to bottom: a one-way panel. */
10
9
  export declare function DownIcon({ color, size }: {
11
10
  color: string;
12
11
  size?: number;
13
12
  }): React.JSX.Element;
14
- /** Two opposed arrows: exchange the pair, or switch the denomination. */
15
13
  export declare function FlipIcon({ color, size }: {
16
14
  color: string;
17
15
  size?: number;
@@ -19,27 +17,21 @@ export declare function FlipIcon({ color, size }: {
19
17
  export declare function MenuIcon({ color }: {
20
18
  color: string;
21
19
  }): React.JSX.Element;
22
- /** An open ring with an arrowhead at its gap. */
23
20
  export declare function ResetIcon({ color }: {
24
21
  color: string;
25
22
  }): React.JSX.Element;
26
- /** Keypad delete: a key outline holding an x. */
27
23
  export declare function DeleteIcon({ color }: {
28
24
  color: string;
29
25
  }): React.JSX.Element;
30
- /** Four viewfinder corners. */
31
26
  export declare function ScanIcon({ color }: {
32
27
  color: string;
33
28
  }): React.JSX.Element;
34
- /** A wallet: a rounded body with a clasp on the trailing edge. */
35
29
  export declare function WalletIcon({ color }: {
36
30
  color: string;
37
31
  }): React.JSX.Element;
38
- /** A padlock: a shackle over a body. */
39
32
  export declare function LockIcon({ color }: {
40
33
  color: string;
41
34
  }): React.JSX.Element;
42
- /** A doorway with an arrow leaving it. */
43
35
  export declare function LeaveIcon({ color }: {
44
36
  color: string;
45
37
  }): React.JSX.Element;
@@ -56,11 +48,12 @@ export declare function TokenIcon({ token, size }: {
56
48
  size?: number;
57
49
  }): React.JSX.Element;
58
50
  /** Small capsule action that sits on a card: Max, Test, the slippage setting and the denomination switch. 32dp tall with a 44dp target. */
59
- export declare function SwapCapsule({ children, onPress, label, testID, hitSlop, ref }: {
51
+ export declare function SwapCapsule({ children, onPress, label, testID, disabled, hitSlop, ref }: {
60
52
  children: React.ReactNode;
61
53
  onPress: () => void;
62
54
  label?: string;
63
- testID?: string; /** Defaults to a 44dp target, as on the swap card. */
55
+ testID?: string;
56
+ disabled?: boolean; /** Defaults to a 44dp target, as on the swap card. */
64
57
  hitSlop?: Insets; /** Reaches the capsule, for example to move accessibility focus back to it. */
65
58
  ref?: React.Ref<View>;
66
59
  }): React.JSX.Element;
@@ -1,4 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ArrowDown } from '@bloxwap/icons/native/arrow-down';
3
+ import { ArrowUpDown } from '@bloxwap/icons/native/arrow-up-down';
4
+ import { ChevronDown } from '@bloxwap/icons/native/chevron-down';
5
+ import { Delete } from '@bloxwap/icons/native/delete';
6
+ import { Lock } from '@bloxwap/icons/native/lock';
7
+ import { LogOut } from '@bloxwap/icons/native/log-out';
8
+ import { Menu } from '@bloxwap/icons/native/menu';
9
+ import { RotateCcw } from '@bloxwap/icons/native/rotate-ccw';
10
+ import { ScanLine } from '@bloxwap/icons/native/scan-line';
11
+ import { Wallet } from '@bloxwap/icons/native/wallet';
2
12
  import { createContext } from 'react';
3
13
  import { Image, Pressable, View } from 'react-native';
4
14
  import { useColors, useFills, useHIG, useMessages } from './provider.js';
@@ -8,29 +18,17 @@ import { ChevronIcon } from './icons.js';
8
18
  import { AnimatedNumberReadout } from './animated-number.js';
9
19
  /** What a host surface supplies to the swap views: a sheet passes its backend's list so drags hand off to the sheet, and turns off the panel's own height animation. */
10
20
  export const SwapHostContext = createContext({});
11
- // Outline symbols drawn from plain views, like ./icons: decorative, so the control that holds them carries the name.
12
21
  const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', pointerEvents: 'none' };
13
- const stroke = 1.75;
14
22
  const centre = { alignItems: 'center', justifyContent: 'center' };
15
- const crossAngles = ['45deg', '-45deg'];
16
- function Arrow({ color, down, height }) { return _jsxs(View, { style: { width: 7, height, alignItems: 'center', transform: down ? [{ rotate: '180deg' }] : undefined }, children: [_jsx(View, { style: { position: 'absolute', top: 1, width: 5, height: 5, borderLeftWidth: stroke, borderTopWidth: stroke, borderColor: color, transform: [{ rotate: '45deg' }] } }), _jsx(View, { style: { width: stroke, height, borderRadius: stroke, backgroundColor: color } })] }); }
17
- /** One arrow, top to bottom: a one-way panel. */
18
- export function DownIcon({ color, size = 16 }) { return _jsx(View, { ...hidden, style: { width: size, height: size, ...centre }, children: _jsx(Arrow, { color: color, down: true, height: size - 3 }) }); }
19
- /** Two opposed arrows: exchange the pair, or switch the denomination. */
20
- export function FlipIcon({ color, size = 16 }) { return _jsxs(View, { ...hidden, style: { width: size, height: size, flexDirection: 'row', gap: 1, ...centre }, children: [_jsx(Arrow, { color: color, down: true, height: size - 3 }), _jsx(Arrow, { color: color, height: size - 3 })] }); }
21
- export function MenuIcon({ color }) { return _jsx(View, { ...hidden, style: { width: 20, height: 20, gap: 3.5, ...centre }, children: [0, 1, 2].map(index => _jsx(View, { style: { width: 14, height: stroke, borderRadius: stroke, backgroundColor: color } }, index)) }); }
22
- /** An open ring with an arrowhead at its gap. */
23
- export function ResetIcon({ color }) { return _jsxs(View, { ...hidden, style: { width: 20, height: 20, ...centre }, children: [_jsx(View, { style: { width: 14, height: 14, borderRadius: 7, borderWidth: stroke, borderColor: color, borderTopColor: 'transparent', transform: [{ rotate: '-45deg' }] } }), _jsx(View, { style: { position: 'absolute', left: 2, top: 3, width: 5, height: 5, borderLeftWidth: stroke, borderBottomWidth: stroke, borderColor: color } })] }); }
24
- /** Keypad delete: a key outline holding an x. */
25
- export function DeleteIcon({ color }) { return _jsx(View, { ...hidden, style: { width: 26, height: 18, borderRadius: 5, borderWidth: stroke, borderColor: color, ...centre }, children: crossAngles.map(angle => _jsx(View, { style: { position: 'absolute', width: 9, height: stroke, borderRadius: stroke, backgroundColor: color, transform: [{ rotate: angle }] } }, angle)) }); }
26
- /** Four viewfinder corners. */
27
- export function ScanIcon({ color }) { const corner = (style) => _jsx(View, { style: [{ position: 'absolute', width: 6, height: 6, borderColor: color }, style] }); return _jsxs(View, { ...hidden, style: { width: 18, height: 18 }, children: [corner({ left: 0, top: 0, borderLeftWidth: stroke, borderTopWidth: stroke, borderTopLeftRadius: 3 }), corner({ right: 0, top: 0, borderRightWidth: stroke, borderTopWidth: stroke, borderTopRightRadius: 3 }), corner({ left: 0, bottom: 0, borderLeftWidth: stroke, borderBottomWidth: stroke, borderBottomLeftRadius: 3 }), corner({ right: 0, bottom: 0, borderRightWidth: stroke, borderBottomWidth: stroke, borderBottomRightRadius: 3 }), _jsx(View, { style: { position: 'absolute', left: 0, right: 0, top: 8, height: stroke, borderRadius: stroke, backgroundColor: color } })] }); }
28
- /** A wallet: a rounded body with a clasp on the trailing edge. */
29
- export function WalletIcon({ color }) { return _jsx(View, { ...hidden, style: { width: 20, height: 20, ...centre }, children: _jsx(View, { style: { width: 16, height: 12, borderRadius: 3, borderWidth: stroke, borderColor: color, alignItems: 'flex-end', justifyContent: 'center' }, children: _jsx(View, { style: { width: 5, height: 4, borderTopLeftRadius: 2, borderBottomLeftRadius: 2, borderWidth: stroke, borderRightWidth: 0, borderColor: color, marginEnd: -stroke } }) }) }); }
30
- /** A padlock: a shackle over a body. */
31
- export function LockIcon({ color }) { return _jsxs(View, { ...hidden, style: { width: 16, height: 16, alignItems: 'center', justifyContent: 'flex-end' }, children: [_jsx(View, { style: { width: 8, height: 7, borderTopLeftRadius: 4, borderTopRightRadius: 4, borderWidth: stroke, borderBottomWidth: 0, borderColor: color } }), _jsx(View, { style: { width: 12, height: 8, borderRadius: 2, borderWidth: stroke, borderColor: color } })] }); }
32
- /** A doorway with an arrow leaving it. */
33
- export function LeaveIcon({ color }) { return _jsxs(View, { ...hidden, style: { width: 20, height: 20, flexDirection: 'row', alignItems: 'center' }, children: [_jsx(View, { style: { width: 8, height: 14, borderWidth: stroke, borderRightWidth: 0, borderColor: color, borderTopLeftRadius: 3, borderBottomLeftRadius: 3 } }), _jsx(View, { style: { width: 9, height: stroke, borderRadius: stroke, backgroundColor: color, marginStart: -2 } }), _jsx(View, { style: { width: 5, height: 5, borderRightWidth: stroke, borderTopWidth: stroke, borderColor: color, marginStart: -5, transform: [{ rotate: '45deg' }] } })] }); }
23
+ export function DownIcon({ color, size = 16 }) { return _jsx(ArrowDown, { size: size, color: color }); }
24
+ export function FlipIcon({ color, size = 16 }) { return _jsx(ArrowUpDown, { size: size, color: color }); }
25
+ export function MenuIcon({ color }) { return _jsx(Menu, { size: 20, color: color }); }
26
+ export function ResetIcon({ color }) { return _jsx(RotateCcw, { size: 20, color: color }); }
27
+ export function DeleteIcon({ color }) { return _jsx(Delete, { size: 24, color: color }); }
28
+ export function ScanIcon({ color }) { return _jsx(ScanLine, { size: 18, color: color }); }
29
+ export function WalletIcon({ color }) { return _jsx(Wallet, { size: 20, color: color }); }
30
+ export function LockIcon({ color }) { return _jsx(Lock, { size: 16, color: color }); }
31
+ export function LeaveIcon({ color }) { return _jsx(LogOut, { size: 20, color: color }); }
34
32
  /** Circular artwork from a URL or the host's own element, or the symbol's first letters when the host has none. */
35
33
  export function TokenArt({ uri, symbol, size, ring }) {
36
34
  const colors = useColors();
@@ -42,10 +40,10 @@ export function TokenArt({ uri, symbol, size, ring }) {
42
40
  /** Token artwork with its chain badge. */
43
41
  export function TokenIcon({ token, size = 44 }) { const colors = useColors(); return _jsxs(View, { ...hidden, style: { width: size, height: size }, children: [_jsx(TokenArt, { uri: token.icon, symbol: token.symbol, size: size }), token.chainIcon ? _jsx(View, { style: { position: 'absolute', end: 0, bottom: 0 }, children: _jsx(TokenArt, { uri: token.chainIcon, size: 18, ring: colors.overlay }) }) : null] }); }
44
42
  /** Small capsule action that sits on a card: Max, Test, the slippage setting and the denomination switch. 32dp tall with a 44dp target. */
45
- export function SwapCapsule({ children, onPress, label, testID, hitSlop = { top: 6, bottom: 6 }, ref }) {
43
+ export function SwapCapsule({ children, onPress, label, testID, disabled = false, hitSlop = { top: 6, bottom: 6 }, ref }) {
46
44
  const fills = useFills();
47
45
  const { direction } = useHIG();
48
- return _jsx(Pressable, { ref: ref, accessibilityRole: 'button', accessibilityLabel: label, testID: testID, onPress: onPress, hitSlop: hitSlop, style: ({ pressed }) => ({ direction, flexDirection: 'row', alignItems: 'center', gap: 6, minHeight: 32, paddingVertical: 4, paddingHorizontal: 12, borderRadius: 9999, backgroundColor: pressed ? fills.raised : fills.well }), children: children });
46
+ return _jsx(Pressable, { disabled: disabled, accessibilityState: { disabled }, ref: ref, accessibilityRole: 'button', accessibilityLabel: label, testID: testID, onPress: onPress, hitSlop: hitSlop, style: ({ pressed }) => ({ direction, flexDirection: 'row', alignItems: 'center', gap: 6, minHeight: 32, paddingVertical: 4, paddingHorizontal: 12, borderRadius: 9999, backgroundColor: pressed ? fills.raised : fills.well }), children: children });
49
47
  }
50
48
  const keys = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '0', 'back'];
51
49
  /** Numeric keypad: a 3 by 4 grid of 56dp keys. Emits `0`–`9`, `.` or `back`. */
@@ -62,7 +60,7 @@ export function SwapHeader({ title, onBack }) {
62
60
  return _jsxs(View, { testID: 'swap-header', style: { flexDirection: 'row', alignItems: 'center', gap: 4, minHeight: 44, paddingStart: onBack ? 0 : 4 }, children: [onBack ? _jsx(IconButton, { intent: 'ghost', label: t.back, suppressFeedback: true, testID: 'swap-back', onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: colors.text }) }) }) : null, _jsx(Heading, { style: { fontWeight: '700', flexShrink: 1 }, children: title })] });
63
61
  }
64
62
  /** A small chevron: down marks a side that can be changed, trailing marks a card that opens something. Mirrors in RTL. */
65
- export function SmallChevron({ color, trailing }) { const { direction } = useHIG(); return _jsx(View, { ...hidden, style: { width: 16, height: 16, ...centre, transform: trailing ? [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] : undefined }, children: _jsx(View, { style: { width: 7, height: 7, borderRightWidth: stroke, borderBottomWidth: stroke, borderColor: color, transform: [{ translateY: -1.5 }, { rotate: '45deg' }] } }) }); }
63
+ export function SmallChevron({ color, trailing }) { const { direction } = useHIG(); return _jsx(ChevronDown, { size: 16, color: color, style: { transform: trailing ? [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] : undefined } }); }
66
64
  /** A pushed view inside the panel: Back and the view title, then the body. There is no close control; Back pops. */
67
65
  export function SwapSubview({ title, onBack, testID, children }) {
68
66
  return _jsxs(View, { testID: testID, style: { gap: 16 }, children: [_jsx(SwapHeader, { title: title, onBack: onBack }), children] });
@@ -20,7 +20,7 @@ export interface SwapToken {
20
20
  /** Artwork: an image URL, or the host's own element (an SVG component, say), which fills the disc. A missing token icon falls back to the symbol's first letters. */
21
21
  icon?: SwapArtwork;
22
22
  chainIcon?: SwapArtwork;
23
- /** Most decimal places a token amount may be typed with, for example 6 for USDC. Unlimited when omitted. Dollars always stop at two. */
23
+ /** Most decimal places a token amount may be typed with, for example 6 for USDC. Up to 100 when omitted; explicit precision must be an integer from 0 to 100. Dollars always stop at two. */
24
24
  decimals?: number;
25
25
  /** Holdings in token units, when the host knows them. Enables Max, Test and the balance check. */
26
26
  balance?: number | null;
@@ -64,7 +64,7 @@ export declare const trimNumber: (value: number, digits?: number) => string;
64
64
  /** Keeps digits and one decimal point, and strips leading zeros; never returns an empty string. */
65
65
  export declare function sanitizeAmount(raw: string): string;
66
66
  /** Token units shown in the active denomination. Dollars floor to the cent so Max never resolves to more than the balance. */
67
- export declare function unitsToEntry(units: number, mode: SwapDenomination, price: number): string;
67
+ export declare function unitsToEntry(units: number | string, mode: SwapDenomination, price: number): string;
68
68
  /** Applies one keypad key (`0`–`9`, `.`, `back`) to an amount string. Dollars stop at two decimals. */
69
69
  export declare function applyAmountKey(current: string, key: string, mode: SwapDenomination, decimals?: number): string;
70
70
  /** Case-insensitive substring or in-order subsequence match. */