@bloxwap/hig 0.7.0 → 0.9.0

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 (272) 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/login.d.ts +34 -0
  35. package/contracts/dist/login.js +43 -0
  36. package/contracts/dist/messages.d.ts +57 -3
  37. package/contracts/dist/messages.js +20 -2
  38. package/contracts/dist/number-flow.d.ts +90 -0
  39. package/contracts/dist/number-flow.js +150 -0
  40. package/contracts/dist/qr.d.ts +151 -0
  41. package/contracts/dist/qr.js +581 -0
  42. package/contracts/dist/toast.d.ts +168 -0
  43. package/contracts/dist/toast.js +171 -0
  44. package/feedback/README.md +1 -1
  45. package/feedback/dist/contract.js +1 -1
  46. package/feedback/dist/react.js +2 -4
  47. package/native/README.md +6 -1
  48. package/native/dist/account-block.d.ts +10 -1
  49. package/native/dist/account-block.js +17 -7
  50. package/native/dist/animated-number-model.d.ts +41 -1
  51. package/native/dist/animated-number-model.js +201 -23
  52. package/native/dist/animated-number.d.ts +39 -1
  53. package/native/dist/animated-number.js +164 -17
  54. package/native/dist/announce.d.ts +2 -0
  55. package/native/dist/announce.js +10 -0
  56. package/native/dist/asset-balance-row.d.ts +3 -1
  57. package/native/dist/asset-balance-row.js +15 -4
  58. package/native/dist/assets-block.d.ts +115 -0
  59. package/native/dist/assets-block.js +87 -0
  60. package/native/dist/async-result.d.ts +2 -0
  61. package/native/dist/async-result.js +11 -0
  62. package/native/dist/avatar-frame.d.ts +29 -0
  63. package/native/dist/avatar-frame.js +56 -0
  64. package/native/dist/avatar.d.ts +21 -0
  65. package/native/dist/avatar.js +31 -0
  66. package/native/dist/bar-mark.d.ts +2 -0
  67. package/native/dist/bar-mark.js +4 -2
  68. package/native/dist/bar-pnl.js +2 -1
  69. package/native/dist/blocks.d.ts +9 -2
  70. package/native/dist/blocks.js +8 -1
  71. package/native/dist/brand.js +2 -1
  72. package/native/dist/button.d.ts +7 -2
  73. package/native/dist/button.js +13 -3
  74. package/native/dist/checkbox.js +2 -1
  75. package/native/dist/confetti.d.ts +33 -0
  76. package/native/dist/confetti.js +143 -0
  77. package/native/dist/confirm-block.d.ts +98 -0
  78. package/native/dist/confirm-block.js +48 -0
  79. package/native/dist/data.d.ts +1 -1
  80. package/native/dist/data.js +5 -1
  81. package/native/dist/deposit-block.d.ts +19 -0
  82. package/native/dist/deposit-block.js +17 -0
  83. package/native/dist/explainer-block.d.ts +91 -0
  84. package/native/dist/explainer-block.js +34 -0
  85. package/native/dist/field.d.ts +5 -1
  86. package/native/dist/field.js +27 -6
  87. package/native/dist/gesture-sheet-model.d.ts +50 -0
  88. package/native/dist/gesture-sheet-model.js +105 -0
  89. package/native/dist/gesture-sheet-next.d.ts +82 -0
  90. package/native/dist/gesture-sheet-next.js +315 -0
  91. package/native/dist/gesture-sheet.d.ts +5 -1
  92. package/native/dist/gesture-sheet.js +13 -6
  93. package/native/dist/icons.d.ts +9 -6
  94. package/native/dist/icons.js +25 -24
  95. package/native/dist/language-block.d.ts +10 -1
  96. package/native/dist/language-block.js +11 -4
  97. package/native/dist/list-group.d.ts +3 -1
  98. package/native/dist/list-group.js +26 -13
  99. package/native/dist/login-block.d.ts +4 -0
  100. package/native/dist/login-block.js +22 -0
  101. package/native/dist/manage-position-block.d.ts +8 -1
  102. package/native/dist/manage-position-block.js +7 -2
  103. package/native/dist/market-row.js +19 -8
  104. package/native/dist/navigation.js +5 -3
  105. package/native/dist/number-format.d.ts +6 -0
  106. package/native/dist/number-format.js +9 -0
  107. package/native/dist/pickers.d.ts +8 -0
  108. package/native/dist/pickers.js +3 -3
  109. package/native/dist/position-block.d.ts +5 -5
  110. package/native/dist/preset-group.d.ts +31 -0
  111. package/native/dist/preset-group.js +39 -0
  112. package/native/dist/preset-picker-block.d.ts +107 -0
  113. package/native/dist/preset-picker-block.js +43 -0
  114. package/native/dist/profile-block.d.ts +10 -1
  115. package/native/dist/profile-block.js +8 -3
  116. package/native/dist/provider.d.ts +5 -2
  117. package/native/dist/provider.js +27 -5
  118. package/native/dist/qr-code.d.ts +33 -0
  119. package/native/dist/qr-code.js +29 -0
  120. package/native/dist/radio-group.d.ts +19 -7
  121. package/native/dist/radio-group.js +39 -10
  122. package/native/dist/reward-block.d.ts +10 -7
  123. package/native/dist/reward-block.js +9 -4
  124. package/native/dist/screen-header.d.ts +13 -3
  125. package/native/dist/screen-header.js +12 -4
  126. package/native/dist/select.js +4 -2
  127. package/native/dist/selection.d.ts +2 -1
  128. package/native/dist/selection.js +1 -0
  129. package/native/dist/setting-switch.d.ts +1 -1
  130. package/native/dist/setting-switch.js +7 -3
  131. package/native/dist/slider.js +5 -1
  132. package/native/dist/sound-haptics-block.js +1 -1
  133. package/native/dist/status.d.ts +41 -9
  134. package/native/dist/status.js +34 -17
  135. package/native/dist/sticky-header.js +9 -1
  136. package/native/dist/swap-amount-card.d.ts +57 -0
  137. package/native/dist/swap-amount-card.js +31 -0
  138. package/native/dist/{swap-panel-block.d.ts → swap-block.d.ts} +18 -8
  139. package/native/dist/{swap-panel-block.js → swap-block.js} +63 -35
  140. package/native/dist/swap-parts.d.ts +3 -10
  141. package/native/dist/swap-parts.js +22 -24
  142. package/native/dist/swap-shared.d.ts +2 -2
  143. package/native/dist/swap-shared.js +10 -6
  144. package/native/dist/swap-sheet.d.ts +3 -3
  145. package/native/dist/swap-sheet.js +3 -3
  146. package/native/dist/swap-views.js +1 -1
  147. package/native/dist/target-block.d.ts +7 -1
  148. package/native/dist/target-block.js +13 -6
  149. package/native/dist/toast.d.ts +47 -0
  150. package/native/dist/toast.js +386 -0
  151. package/native/dist/token-action-block.d.ts +11 -2
  152. package/native/dist/token-action-block.js +10 -4
  153. package/native/dist/trade-history-list-block.js +7 -4
  154. package/native/dist/wallet-address-core.js +6 -3
  155. package/native-fonts/README.md +1 -1
  156. package/og-fonts/README.md +1 -1
  157. package/package.json +155 -11
  158. package/react/README.md +3 -1
  159. package/react/dist/animated-number-flow.d.ts +72 -0
  160. package/react/dist/animated-number-flow.js +316 -0
  161. package/react/dist/animated-number-model.d.ts +18 -0
  162. package/react/dist/animated-number-model.js +75 -5
  163. package/react/dist/animated-number.d.ts +45 -1
  164. package/react/dist/animated-number.js +137 -6
  165. package/react/dist/asset-balance-row.d.ts +3 -1
  166. package/react/dist/asset-balance-row.js +10 -4
  167. package/react/dist/async-result.d.ts +2 -0
  168. package/react/dist/async-result.js +11 -0
  169. package/react/dist/avatar.d.ts +25 -0
  170. package/react/dist/avatar.js +50 -0
  171. package/react/dist/blocks/account-block.d.ts +5 -1
  172. package/react/dist/blocks/account-block.js +11 -6
  173. package/react/dist/blocks/assets-block.d.ts +106 -0
  174. package/react/dist/blocks/assets-block.js +135 -0
  175. package/react/dist/blocks/confirm-block.d.ts +91 -0
  176. package/react/dist/blocks/confirm-block.js +31 -0
  177. package/react/dist/blocks/deposit-block.d.ts +19 -0
  178. package/react/dist/blocks/deposit-block.js +15 -0
  179. package/react/dist/blocks/explainer-block.d.ts +80 -0
  180. package/react/dist/blocks/explainer-block.js +20 -0
  181. package/react/dist/blocks/install-command.js +3 -1
  182. package/react/dist/blocks/language-block.d.ts +5 -1
  183. package/react/dist/blocks/language-block.js +4 -3
  184. package/react/dist/blocks/login-block.d.ts +4 -0
  185. package/react/dist/blocks/login-block.js +14 -0
  186. package/react/dist/blocks/manage-position-block.d.ts +3 -1
  187. package/react/dist/blocks/manage-position-block.js +2 -2
  188. package/react/dist/blocks/market-row.js +8 -3
  189. package/react/dist/blocks/notifications-block.d.ts +3 -1
  190. package/react/dist/blocks/notifications-block.js +2 -2
  191. package/react/dist/blocks/pickers.d.ts +9 -0
  192. package/react/dist/blocks/pickers.js +4 -2
  193. package/react/dist/blocks/position-block.d.ts +3 -3
  194. package/react/dist/blocks/preset-picker-block.d.ts +85 -0
  195. package/react/dist/blocks/preset-picker-block.js +19 -0
  196. package/react/dist/blocks/profile-block.d.ts +5 -1
  197. package/react/dist/blocks/profile-block.js +12 -13
  198. package/react/dist/blocks/reward-block.d.ts +13 -8
  199. package/react/dist/blocks/reward-block.js +7 -4
  200. package/react/dist/blocks/screen-header.d.ts +10 -2
  201. package/react/dist/blocks/screen-header.js +7 -4
  202. package/react/dist/blocks/setting-switch.js +6 -3
  203. package/react/dist/blocks/signals-block.d.ts +3 -1
  204. package/react/dist/blocks/signals-block.js +4 -3
  205. package/react/dist/blocks/sound-haptics-block.d.ts +3 -1
  206. package/react/dist/blocks/sound-haptics-block.js +2 -2
  207. package/react/dist/blocks/sticky-header.d.ts +14 -4
  208. package/react/dist/blocks/sticky-header.js +68 -8
  209. package/react/dist/blocks/swap/settings.js +2 -1
  210. package/react/dist/blocks/swap/shared.d.ts +22 -22
  211. package/react/dist/blocks/swap/shared.js +30 -28
  212. package/react/dist/blocks/{swap-panel-block.d.ts → swap-block.d.ts} +19 -8
  213. package/react/dist/blocks/swap-block.js +215 -0
  214. package/react/dist/blocks/swap-sheet.d.ts +3 -3
  215. package/react/dist/blocks/swap-sheet.js +3 -3
  216. package/react/dist/blocks/target-block.d.ts +7 -1
  217. package/react/dist/blocks/target-block.js +10 -4
  218. package/react/dist/blocks/token-action-block.d.ts +6 -2
  219. package/react/dist/blocks/token-action-block.js +3 -2
  220. package/react/dist/blocks/trade-history-detail-block.d.ts +3 -1
  221. package/react/dist/blocks/trade-history-detail-block.js +2 -2
  222. package/react/dist/blocks/trade-history-list-block.d.ts +3 -1
  223. package/react/dist/blocks/trade-history-list-block.js +7 -4
  224. package/react/dist/blocks.d.ts +8 -2
  225. package/react/dist/blocks.js +7 -1
  226. package/react/dist/brand.js +2 -1
  227. package/react/dist/button.d.ts +9 -3
  228. package/react/dist/button.js +8 -3
  229. package/react/dist/confetti.d.ts +27 -0
  230. package/react/dist/confetti.js +240 -0
  231. package/react/dist/data.js +8 -1
  232. package/react/dist/field.d.ts +6 -1
  233. package/react/dist/field.js +18 -9
  234. package/react/dist/gesture-sheet.d.ts +15 -1
  235. package/react/dist/gesture-sheet.js +53 -8
  236. package/react/dist/list-group.js +11 -7
  237. package/react/dist/navigation.js +11 -3
  238. package/react/dist/overlay.d.ts +1 -4
  239. package/react/dist/overlay.js +1 -3
  240. package/react/dist/popover.d.ts +30 -0
  241. package/react/dist/popover.js +34 -0
  242. package/react/dist/preset-group.d.ts +30 -0
  243. package/react/dist/preset-group.js +13 -0
  244. package/react/dist/provider.d.ts +2 -2
  245. package/react/dist/provider.js +23 -6
  246. package/react/dist/qr-code.d.ts +32 -0
  247. package/react/dist/qr-code.js +28 -0
  248. package/react/dist/select.js +10 -3
  249. package/react/dist/selection.d.ts +13 -5
  250. package/react/dist/selection.js +13 -8
  251. package/react/dist/slider.js +5 -1
  252. package/react/dist/status.d.ts +14 -10
  253. package/react/dist/status.js +17 -9
  254. package/react/dist/styles.css +260 -165
  255. package/react/dist/toast.d.ts +19 -12
  256. package/react/dist/toast.js +29 -7
  257. package/react/dist/wallet-address-core.d.ts +8 -4
  258. package/react/dist/wallet-address-core.js +10 -5
  259. package/tokens/README.md +2 -2
  260. package/tokens/assets/onramps/apple-pay.svg +33 -0
  261. package/tokens/assets/onramps/bank.svg +98 -0
  262. package/tokens/assets/onramps/blink.svg +37 -0
  263. package/tokens/assets/onramps/cashapp.svg +33 -0
  264. package/tokens/assets/onramps/crypto.svg +121 -0
  265. package/tokens/assets/onramps/exchange.svg +105 -0
  266. package/tokens/dist/deposit-icons.d.ts +1 -0
  267. package/tokens/dist/deposit-icons.js +28 -0
  268. package/tokens/dist/index.d.ts +16 -0
  269. package/tokens/dist/index.js +16 -0
  270. package/tokens/dist/manifest.json +8 -0
  271. package/tokens/dist/tokens.css +6 -0
  272. package/react/dist/blocks/swap-panel-block.js +0 -178
@@ -0,0 +1,215 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { decimal, decimalDivide, decimalCompare, localizeDecimal } from '@bloxwap/hig/contracts';
4
+ import { useAsyncResult } from '../async-result.js';
5
+ import { useEffect, useMemo, useRef, useState } from 'react';
6
+ import * as en from '@bloxwap/hig/contracts/messages';
7
+ import { PressDecoration, useControllable, useHIG, useNumberLocale } from '../provider.js';
8
+ import { Button, IconButton } from '../button.js';
9
+ import { AnimatedNumberReadout } from '../animated-number.js';
10
+ import { notify } from '../notify.js';
11
+ import { VerticalAddress } from '../data.js';
12
+ import { SwapPicker } from './swap/picker.js';
13
+ import { ScreenHeader } from './screen-header.js';
14
+ import { SwapSettings } from './swap/settings.js';
15
+ import { SwapIcon, SwapKeypad, SwapNumber, SwapPill, percentNumber, swapArt, swapFigure, usdNumber, addressGradient, applyAmountKey, chainsOf, parentView, sanitizeAmount, shortAddress, swapAction, testAmount, unitsToEntry } from './swap/shared.js';
16
+ export { swapAction } from './swap/shared.js';
17
+ export { SwapAmountCard } from './swap/amount-card.js';
18
+ export { SwapPill, SwapKeypad, SwapNumber } from './swap/shared.js';
19
+ const visiblePanel = (node) => { for (let el = node; el; el = el.parentElement) {
20
+ const style = getComputedStyle(el);
21
+ if (style.display === 'none' || style.visibility === 'hidden')
22
+ return false;
23
+ } return true; };
24
+ const keyboardPanels = new Set();
25
+ const ownsKeyboard = (node) => { const visible = [...keyboardPanels].filter(el => el.isConnected && !el.closest('[hidden],[inert],[aria-hidden=true]') && visiblePanel(el)); return !!node && (visible.find(el => el.contains(document.activeElement)) ?? visible.at(-1)) === node; };
26
+ const textTarget = (target) => { const element = target; return !!element && (/^(INPUT|TEXTAREA|SELECT)$/.test(element.tagName) || element.isContentEditable); };
27
+ const amountKey = (event) => event.metaKey || event.ctrlKey || event.altKey ? null : /^[0-9.]$/.test(event.key) ? event.key : event.key === 'Backspace' ? 'back' : null;
28
+ /**
29
+ * Send, swap and bridge in one panel: a From card and a To card joined by a flip control, an amount entered in dollars
30
+ * or token units, token pickers, settings, and one action that names itself from the chosen pair.
31
+ * Presentation only. The host owns tokens, balances, prices, the quote, the wallet and the transaction.
32
+ */
33
+ export function SwapBlock({ 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, 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, keypad = 'auto', shortcuts = true, captureKeyboard = false, active = true, view: viewProp, onViewChange, settings, className, style }) {
34
+ const { messages } = useHIG();
35
+ const locale = useNumberLocale();
36
+ const [from, setFrom] = useControllable(fromProp, defaultFrom, onFromChange);
37
+ const [to, setTo] = useControllable(toProp, defaultTo, onToChange);
38
+ 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; };
39
+ const [defaultMode, setDefaultMode] = useControllable(denomination, 'usd', onDenominationChange);
40
+ const [isReceiving, setReceiving] = useControllable(receiving, false, onReceivingChange);
41
+ // A mounted `amount` seeds the entry, in the default denomination at the initial From token's price.
42
+ const [entry, setEntry] = useState(() => amount === undefined ? '0' : unitsToEntry(boundedUnits(amount), defaultMode, from?.price ?? 0));
43
+ const [fromMode, applyFromMode] = useState(defaultMode);
44
+ const [toMode, applyToMode] = useState(defaultMode);
45
+ const [view, show] = useControllable(viewProp, 'main', onViewChange);
46
+ const root = useRef(null);
47
+ const previous = useRef('main');
48
+ const openPicker = (side) => show(side);
49
+ const back = () => show(parentView(view));
50
+ // A push slides in from the trailing edge and a pop from the leading edge. Popping to the cards returns focus to the control that pushed.
51
+ const direction = view === 'main' || (view === 'settings' && previous.current !== 'main') ? 'pop' : 'push';
52
+ useEffect(() => { const from = previous.current; previous.current = view; if (view !== 'main' || from === 'main')
53
+ return; root.current?.querySelector(from === 'from' || from === 'to' ? `[data-side='${from}'] .hig-swap-hit` : '.hig-swap-settings-button')?.focus(); }, [view]);
54
+ const [touch, setTouch] = useState(false);
55
+ const [hint, showHint] = useState(null);
56
+ const [copied, setCopied] = useState('');
57
+ useEffect(() => {
58
+ const coarse = window.matchMedia?.('(pointer: coarse)');
59
+ const update = () => setTouch(!!coarse?.matches);
60
+ update();
61
+ coarse?.addEventListener('change', update);
62
+ if (window.matchMedia?.('(hover: hover) and (pointer: fine)').matches)
63
+ showHint(/Mac|iPhone|iPad/.test(navigator.platform) ? 'mac' : 'pc');
64
+ return () => coarse?.removeEventListener('change', update);
65
+ }, []);
66
+ const fromPrice = from?.price ?? 0, toPrice = to?.price ?? 0, input = Number(entry) || 0;
67
+ const exact = useRef(amount === undefined ? null : { entry, mode: fromMode, units: boundedUnits(amount), asset: from?.id });
68
+ 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);
69
+ const units = Number(unitsText), usd = units * fromPrice;
70
+ const showReceive = isReceiving && !!receive;
71
+ // Report the amount in token units; resync the entry when the host sets a different amount.
72
+ const reported = useRef(amount ?? '0');
73
+ useEffect(() => { if (reported.current !== unitsText) {
74
+ reported.current = unitsText;
75
+ onAmountChange?.(unitsText);
76
+ } }, [unitsText]);
77
+ useEffect(() => { if (amount === undefined || boundedUnits(amount) === reported.current)
78
+ return; const canonical = boundedUnits(amount), next = unitsToEntry(canonical, fromMode, fromPrice); reported.current = canonical; if (decimal(amount) !== canonical)
79
+ onAmountChange?.(canonical); exact.current = { entry: next, mode: fromMode, units: canonical, asset: from?.id }; setEntry(next); }, [amount]);
80
+ const sameAsset = !!from && !!to && swapAction(from, to) === 'send';
81
+ const receivedUnits = sameAsset ? units : received ?? (toPrice > 0 ? usd / toPrice : 0);
82
+ const receivedUsd = toPrice > 0 ? receivedUnits * toPrice : sameAsset ? usd : 0;
83
+ const action = swapAction(from, to);
84
+ const insufficient = !!from && from.balance != null && (!Number.isFinite(from.balance) || from.balance < 0 || decimalCompare(unitsText, from.balance) > 0);
85
+ // A destination or a details card stands in for the To token: one way, and ready from the From side alone.
86
+ const fixed = !!destination || (!!details && !to);
87
+ const oneWay = oneWayProp || fixed;
88
+ const eligible = !!from && (!!to || fixed) && !destination?.pending && Number.isFinite(units) && units > 0 && !insufficient;
89
+ const ready = eligible && !actionDisabled;
90
+ const readyText = actionLabel ?? (action === 'swap' && !fixed ? messages.swapActionSwap ?? en.swapActionSwap : action === 'bridge' && !fixed ? messages.swapActionBridge ?? en.swapActionBridge : messages.swapActionSend ?? en.swapActionSend);
91
+ // 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.
92
+ const actionText = showReceive ? (messages.swapSendFromWallet ?? en.swapSendFromWallet) : !from || (!to && !fixed) ? (messages.swapChooseToken ?? en.swapChooseToken) : destination?.pending ? (messages.swapChooseDestination ?? en.swapChooseDestination) : submitting ? submittingLabel ?? (actionDisabled && actionStatus ? actionStatus : readyText) : units <= 0 ? (messages.swapEnterAmount ?? en.swapEnterAmount) : insufficient ? (messages.swapInsufficient ?? en.swapInsufficient)(from.symbol) : actionDisabled && actionStatus ? actionStatus : readyText;
93
+ const pristine = (lockFrom || !from) && (lockTo || !to) && input === 0;
94
+ // Updater form: several keys can land before the next render, and each must build on the last.
95
+ const latest = useRef(fromMode);
96
+ latest.current = fromMode;
97
+ const latestView = useRef(view);
98
+ latestView.current = view;
99
+ // Read at key time: several keys can land in one render.
100
+ const limits = useRef({ decimals: from?.decimals, balance: from?.balance, price: fromPrice, cap: limitToBalance });
101
+ limits.current = { decimals: from?.decimals, balance: from?.balance, price: fromPrice, cap: limitToBalance };
102
+ const over = (next) => { const { balance, price, cap } = limits.current; if (!cap || balance == null)
103
+ return false; if (!Number.isFinite(balance) || balance < 0)
104
+ return true; const value = latest.current === 'token' ? next : decimalDivide(next, price, limits.current.decimals ?? 18); return decimalCompare(value, balance) > 0; };
105
+ // While the host's submit is in flight the keypad, typed keys, a paste, Max and Test leave the amount as it is.
106
+ const typed = next => { if (!submitting)
107
+ setEntry(current => { const value = typeof next === 'function' ? next(current) : next; if (value === current || value.length > 1000)
108
+ return current; const normalized = decimal(value, latest.current === 'usd' ? 2 : limits.current.decimals ?? 100); if (over(normalized))
109
+ 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; }); };
110
+ const press = (key) => typed(current => { const next = applyAmountKey(current, key, latest.current, limits.current.decimals); return key !== 'back' && over(next) ? current : next; });
111
+ const paste = (text) => { const clean = text.trim().replace(/,/g, ''); if (clean === '' || !/^[0-9]*\.?[0-9]*$/.test(clean))
112
+ return false; const next = sanitizeAmount(clean); typed(next); return true; };
113
+ const switchFromMode = (mode) => { if (submitting || mode === fromMode)
114
+ return; const next = unitsToEntry(unitsText, mode, fromPrice); exact.current = { entry: next, mode, units: unitsText, asset: from?.id }; setEntry(next); applyFromMode(mode); };
115
+ const changeDenomination = (mode) => { if (submitting)
116
+ return; setDefaultMode(mode); switchFromMode(mode); applyToMode(mode); };
117
+ // A new default applies to an untouched entry at once; a typed amount keeps its denomination until reset.
118
+ useEffect(() => { if (input === 0) {
119
+ applyFromMode(defaultMode);
120
+ applyToMode(defaultMode);
121
+ } }, [defaultMode]);
122
+ const reset = () => { if (submitting)
123
+ return; exact.current = null; setEntry('0'); applyFromMode(defaultMode); applyToMode(defaultMode); if (isReceiving)
124
+ setReceiving(false); if (!lockFrom)
125
+ setFrom(null); if (!lockTo)
126
+ setTo(null); onReset?.(); };
127
+ const flip = () => { if (submitting || !from || !to)
128
+ return; setFrom(to); setTo(from); };
129
+ const submit = () => { if (submitting)
130
+ return; if (showReceive) {
131
+ onConnect?.();
132
+ return;
133
+ } if (ready)
134
+ onSubmit(fixed ? 'send' : action); };
135
+ const beginCopy = useAsyncResult(receive?.address);
136
+ const copyAddress = () => { const current = beginCopy(); if (!receive?.onCopy)
137
+ return; Promise.resolve().then(receive.onCopy).then(() => { if (!current())
138
+ return; const text = (messages.addressCopied ?? en.addressCopied); setCopied(notify(text, { severity: 'success', id: 'hig-swap-address', dismissName: (messages.dismissNotice ?? en.dismissNotice)(text, (messages.dismiss ?? en.dismiss)) }) ? text : ''); }).catch(() => { if (current())
139
+ setCopied(''); }); };
140
+ useEffect(() => { const node = root.current; if (!active || (!shortcuts && !captureKeyboard) || !node)
141
+ return; keyboardPanels.add(node); return () => { keyboardPanels.delete(node); }; }, [active, shortcuts, captureKeyboard]);
142
+ useEffect(() => {
143
+ if (!active || (!shortcuts && !captureKeyboard))
144
+ return;
145
+ const onKeyDown = (event) => {
146
+ if (submitting || event.defaultPrevented || !ownsKeyboard(root.current))
147
+ return;
148
+ const key = event.key.toLowerCase();
149
+ if (shortcuts && (event.metaKey || event.ctrlKey) && !event.altKey && !event.shiftKey && (key === 'f' || key === 'k')) {
150
+ const side = key === 'f' ? 'from' : 'to';
151
+ if (side === 'from' ? lockFrom : lockTo || fixed)
152
+ return;
153
+ event.preventDefault();
154
+ show(side);
155
+ return;
156
+ }
157
+ if (!captureKeyboard || event.defaultPrevented || textTarget(event.target) || latestView.current !== 'main')
158
+ return;
159
+ const pressed = amountKey(event);
160
+ if (pressed) {
161
+ event.preventDefault();
162
+ press(pressed);
163
+ }
164
+ };
165
+ const onPaste = (event) => { if (!submitting && ownsKeyboard(root.current) && captureKeyboard && !event.defaultPrevented && !textTarget(event.target) && paste(event.clipboardData?.getData('text') ?? ''))
166
+ event.preventDefault(); };
167
+ window.addEventListener('keydown', onKeyDown);
168
+ document.addEventListener('paste', onPaste);
169
+ return () => { window.removeEventListener('keydown', onKeyDown); document.removeEventListener('paste', onPaste); };
170
+ });
171
+ // Keys typed while focus is inside the cards drive the amount; in a pushed view Escape pops it.
172
+ const inPanel = (event) => view === 'main' && !textTarget(event.target);
173
+ const onKeyDown = (event) => { if (view !== 'main' && event.key === 'Escape') {
174
+ event.preventDefault();
175
+ event.stopPropagation();
176
+ back();
177
+ return;
178
+ } if (captureKeyboard || !inPanel(event))
179
+ return; const pressed = amountKey(event); if (pressed) {
180
+ event.preventDefault();
181
+ press(pressed);
182
+ } };
183
+ const onPaste = (event) => { if (!captureKeyboard && inPanel(event) && paste(event.clipboardData.getData('text')))
184
+ event.preventDefault(); };
185
+ const chainList = useMemo(() => chains ?? chainsOf(tokens), [chains, tokens]);
186
+ // The fee keeps its sentence; only a known amount moves. Loading and unknown are plain placeholders.
187
+ const feeLine = quoteLoading || fee == null ? (messages.swapFee ?? en.swapFee)(quoteLoading ? '…' : '—') : _jsx(SwapNumber, { template: messages.swapFee ?? en.swapFee, ...usdNumber(fee) });
188
+ const fraction = entry.includes('.') ? Math.min(entry.length - entry.indexOf('.') - 1, fromMode === 'usd' ? 2 : 8) : 0;
189
+ // An account (a token with a `caption`) reads name over caption beside one disc, and offers Max only.
190
+ const account = (side, token, locked) => _jsxs("div", { className: 'hig-swap-selected', "data-account": 'true', children: [_jsx("span", { className: 'hig-swap-stack', "aria-hidden": 'true', children: token.icon ? swapArt(token.icon) : _jsx("span", { className: 'hig-swap-initials', children: token.symbol.slice(0, 3) }) }), _jsxs("span", { className: 'hig-swap-identity', children: [_jsxs("strong", { children: [token.name, !locked && _jsx(SwapIcon, { name: 'expand', size: 16 })] }), _jsx("span", { children: swapFigure(token.caption ?? '') })] }), side === 'from' && (token.balance ?? 0) > 0 && _jsx("span", { className: 'hig-swap-meta', children: _jsx(SwapPill, { disabled: submitting, onClick: () => typed(unitsToEntry(token.balance ?? 0, fromMode, fromPrice)), children: (messages.swapMax ?? en.swapMax) }) })] });
191
+ const header = (side, token) => _jsxs("div", { className: 'hig-swap-selected', children: [_jsxs("span", { className: 'hig-swap-stack', "aria-hidden": 'true', children: [wallet?.address && _jsx("span", { className: 'hig-swap-avatar', style: { background: addressGradient(wallet.address) } }), token.chainIcon && swapArt(token.chainIcon), token.icon ? swapArt(token.icon) : _jsx("span", { className: 'hig-swap-initials', children: token.symbol.slice(0, 3) })] }), _jsxs("span", { className: 'hig-swap-identity', children: [wallet?.address && _jsx("span", { children: shortAddress(wallet.address) }), _jsx("span", { children: token.chain }), _jsx("strong", { children: token.name })] }), side === 'from' ? (token.balance ?? 0) > 0 && _jsxs("span", { className: 'hig-swap-meta', children: [_jsxs("span", { className: 'hig-swap-pills', children: [_jsxs(SwapPill, { disabled: submitting, onClick: () => typed(unitsToEntry(testAmount(token), fromMode, fromPrice)), children: [_jsx(SwapIcon, { name: 'flask', size: 14 }), (messages.swapTest ?? en.swapTest)] }), _jsx(SwapPill, { disabled: submitting, onClick: () => typed(unitsToEntry(token.balance ?? 0, fromMode, fromPrice)), children: (messages.swapMax ?? en.swapMax) })] }), _jsx(SwapNumber, { value: token.balance, suffix: ' ' + token.symbol, options: { maximumFractionDigits: 6 } })] })
192
+ : _jsxs("span", { className: 'hig-swap-meta', children: [_jsxs(SwapPill, { disabled: submitting, onClick: () => show(onSlippageChange ? 'slippage' : 'settings'), children: [_jsx(SwapIcon, { name: 'sliders', size: 14 }), _jsx(SwapNumber, { template: messages.swapSlippage ?? en.swapSlippage, ...percentNumber(slippage) })] }), _jsx("span", { children: feeLine })] })] });
193
+ const receiveView = (view) => { const content = _jsxs(_Fragment, { children: [view.qr && _jsx("span", { className: 'hig-swap-qr', children: view.qr }), _jsx(VerticalAddress, { address: view.address })] }); return view.onCopy ? _jsxs("button", { type: 'button', className: 'hig-swap-receive', "aria-label": (messages.copyAddress ?? en.copyAddress) + ': ' + view.address, onClick: copyAddress, children: [content, _jsx(PressDecoration, { kind: 'row' })] }) : _jsx("div", { className: 'hig-swap-receive', children: content }); };
194
+ const card = (side) => {
195
+ const token = side === 'from' ? from : to, label = side === 'from' ? (messages.swapFrom ?? en.swapFrom) : (messages.swapTo ?? en.swapTo), mode = side === 'from' ? fromMode : toMode, locked = side === 'from' ? lockFrom : lockTo;
196
+ const cardUnits = side === 'from' ? units : receivedUnits, cardUsd = side === 'from' ? usd : receivedUsd;
197
+ const shown = side === 'from' ? input : mode === 'token' ? receivedUnits : receivedUsd;
198
+ return _jsxs("div", { className: 'hig-swap-card', "data-side": side, "data-locked": locked || undefined, children: [_jsxs("div", { className: 'hig-swap-slot', children: [!locked && _jsx("button", { type: 'button', disabled: submitting, className: 'hig-swap-hit', "aria-label": (messages.swapSelectToken ?? en.swapSelectToken)(label), onClick: () => openPicker(side), children: _jsx(PressDecoration, { kind: 'row' }) }), _jsx("div", { className: 'hig-swap-slot-content', children: token ? token.caption !== undefined ? account(side, token, locked) : header(side, token) : _jsxs(_Fragment, { children: [_jsxs("span", { className: 'hig-swap-placeholder', children: [label, "\u2026"] }), shortcuts && hint && !locked && _jsxs("kbd", { className: 'hig-swap-kbd', children: [hint === 'mac' ? '⌘' : messages.swapControlKey ?? en.swapControlKey, " ", side === 'from' ? 'F' : 'K'] })] }) })] }), side === 'from' && showReceive && receive ? receiveView(receive) :
199
+ !(side === 'to' && showReceive) && _jsxs("div", { className: 'hig-swap-amount-area', children: [!locked && _jsx("button", { type: 'button', disabled: submitting, className: 'hig-swap-hit', tabIndex: -1, "aria-hidden": 'true', onClick: () => openPicker(side), children: _jsx(PressDecoration, { kind: 'row' }) }), _jsxs("div", { className: 'hig-swap-amount-content', children: [_jsx("div", { className: 'hig-swap-amount', "data-muted": side === 'to' || undefined, ...(side === 'from' ? { role: 'textbox', tabIndex: 0, 'aria-label': (messages.swapAmount ?? en.swapAmount)(label) } : {}), children: _jsx(AnimatedNumberReadout, { value: shown, formattedValue: side === 'from' && mode === 'token' ? localizeDecimal(entry, locale) : undefined, label: side === 'to' ? (messages.swapAmount ?? en.swapAmount)(label) : undefined, prefix: mode === 'usd' ? '$' : '', suffix: side === 'from' && mode === 'usd' && entry.endsWith('.') ? '.' : '', options: { minimumFractionDigits: side === 'from' ? fraction : 0, maximumFractionDigits: mode === 'usd' ? 2 : 8, useGrouping: false } }) }), denominationSwitch && _jsxs(SwapPill, { disabled: submitting, "aria-label": (messages.swapSwitchDenomination ?? en.swapSwitchDenomination), onClick: () => side === 'from' ? switchFromMode(fromMode === 'usd' ? 'token' : 'usd') : applyToMode(toMode === 'usd' ? 'token' : 'usd'), children: [_jsx("span", { "aria-hidden": 'true', className: 'hig-swap-equals', children: "=" }), mode === 'token' ? _jsx(AnimatedNumberReadout, { value: cardUsd, options: { style: 'currency', currency: 'USD' } }) : _jsx(AnimatedNumberReadout, { value: cardUnits, suffix: token ? ` ${token.symbol}` : '', options: { maximumFractionDigits: 8, useGrouping: false } }), _jsx(SwapIcon, { name: 'flip', size: 14 })] })] })] })] });
200
+ };
201
+ // 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.
202
+ const fixedCard = fixed && _jsxs("div", { className: 'hig-swap-card', "data-side": 'to', "data-compact": 'true', "data-pending": destination?.pending || undefined, children: [destination && _jsxs("div", { className: 'hig-swap-slot', children: [destination.onPress && _jsx("button", { type: 'button', disabled: submitting, className: 'hig-swap-hit', "aria-label": destination.title, onClick: destination.onPress, children: _jsx(PressDecoration, { kind: 'row' }) }), _jsx("div", { className: 'hig-swap-slot-content', children: _jsxs("div", { className: 'hig-swap-selected', children: [_jsx("span", { className: 'hig-swap-stack', "aria-hidden": 'true', children: destination.icon ? swapArt(destination.icon) : destination.address ? _jsx("span", { className: 'hig-swap-avatar', style: { background: addressGradient(destination.address) } }) : _jsx("span", { className: 'hig-swap-initials', children: destination.title.slice(0, 2) }) }), _jsxs("span", { className: 'hig-swap-identity', children: [_jsx("strong", { children: destination.title }), destination.subtitle && _jsx("span", { children: destination.subtitle }), destination.address && _jsx("span", { children: shortAddress(destination.address) })] }), (destination.detail || fee !== undefined || destination.onPress) && _jsxs("span", { className: 'hig-swap-meta', "data-row": destination.onPress ? 'true' : undefined, children: [_jsxs("span", { children: [destination.detail && _jsx("span", { children: swapFigure(destination.detail) }), fee !== undefined && _jsx("span", { children: feeLine })] }), destination.onPress && _jsx(SwapIcon, { name: 'chevron', size: 16 })] })] }) })] }), details && details.length > 0 && _jsx("dl", { className: 'hig-swap-details', children: details.map(row => _jsxs("div", { children: [_jsx("dt", { children: row.label }), _jsx("dd", { children: typeof row.value === 'number' ? _jsx(SwapNumber, { value: row.value, options: row.options, prefix: row.prefix, suffix: row.suffix, formattedValue: row.formattedValue, animateFormatted: !!row.formattedValue }) : row.value })] }, row.label)) })] });
203
+ const fromCard = card('from'), toCard = fixedCard || card('to');
204
+ const body = view === 'main' ? _jsxs(_Fragment, { children: [title && _jsx(ScreenHeader, { title: title, onBack: onBack, headingId: headingId }), banner, fromCard, _jsx("div", { className: 'hig-swap-flip', children: oneWay ? _jsx("span", { "aria-hidden": 'true', children: _jsx(SwapIcon, { name: 'down', size: 16 }) }) : _jsxs("button", { type: 'button', "aria-label": (messages.swapFlip ?? en.swapFlip), disabled: submitting || !from || !to, onClick: flip, children: [_jsx(SwapIcon, { name: 'flip', size: 16 }), _jsx(PressDecoration, { kind: 'icon-button', disabled: submitting || !from || !to })] }) }), toCard, !showReceive && (keypad === 'always' || (keypad === 'auto' && touch)) && _jsx(SwapKeypad, { onKey: press, label: (messages.swapKeypad ?? en.swapKeypad), deleteLabel: (messages.swapDelete ?? en.swapDelete) }), note && _jsx("p", { className: 'hig-swap-note', "data-tone": noteTone, role: 'note', children: note }), _jsxs("div", { className: 'hig-swap-actions', children: [controls && _jsx(IconButton, { disabled: submitting, className: 'hig-swap-settings-button', intent: 'secondary', label: (messages.swapSettings ?? en.swapSettings), suppressFeedback: true, onClick: () => show('settings'), children: _jsx(SwapIcon, { name: 'menu' }) }), _jsxs(Button, { fullWidth: true, intent: actionIntent, busy: submitting, disabled: !showReceive && !ready, onClick: submit, children: [actionIcon, actionText] }), controls && _jsx(IconButton, { intent: 'secondary', label: (messages.swapReset ?? en.swapReset), disabled: pristine || submitting, onClick: reset, children: _jsx(SwapIcon, { name: 'reset' }) })] }), footer] }) : view === 'from' ? _jsx(SwapPicker, { side: view, onBack: back, tokens: fromTokens ?? tokens, loading: fromTokensLoading, chains: chainList, hotTokenIds: hotTokenIds, selected: from, onSelect: setFrom, wallet: wallet, onConnect: submitting ? undefined : onConnect, onDisconnect: submitting ? undefined : onDisconnect, receiving: isReceiving, onReceivingChange: receive ? setReceiving : undefined })
205
+ : 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: submitting ? undefined : onScanRecipient })
206
+ : _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 });
207
+ return _jsxs("section", { ref: root, className: `hig-swap-panel${className ? ` ${className}` : ''}`, style: style, onClickCapture: event => { if (submitting) {
208
+ event.preventDefault();
209
+ event.stopPropagation();
210
+ } }, "data-view": view, "data-receiving": showReceive || undefined, onKeyDown: onKeyDown, onPaste: onPaste, children: [_jsx("div", { className: 'hig-swap-view', "data-direction": direction, children: body }, view), _jsx("p", { className: 'hig-sr-only', role: 'status', children: copied })] });
211
+ }
212
+ /** @deprecated Renamed `SwapBlock`. The old name and the `blocks/swap-panel` and `recipes/swap-panel` import paths keep working until the next major release. */
213
+ export const SwapPanel = SwapBlock;
214
+ /** @deprecated Use SwapBlock. */
215
+ export const SwapPanelBlock = SwapBlock;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { type SwapPanelBlockProps } from './swap-panel-block.js';
3
- export interface SwapSheetProps extends SwapPanelBlockProps {
2
+ import { type SwapBlockProps } from './swap-block.js';
3
+ export interface SwapSheetProps extends SwapBlockProps {
4
4
  open: boolean;
5
5
  onOpenChange: (open: boolean) => void;
6
6
  /** Accessible name of the sheet; not drawn. */
@@ -9,7 +9,7 @@ export interface SwapSheetProps extends SwapPanelBlockProps {
9
9
  trigger?: React.ReactNode;
10
10
  }
11
11
  /**
12
- * SwapPanelBlock presented in a gesture sheet (Vaul). Token pickers and settings push inside the same sheet, which resizes to
12
+ * SwapBlock presented in a gesture sheet (Vaul). Token pickers and settings push inside the same sheet, which resizes to
13
13
  * each view. Escape and Back pop a pushed view first; from the cards, Escape, the scrim and a downward drag close the sheet.
14
14
  * Lives in its own entry so the blocks aggregate stays free of the optional Vaul peer.
15
15
  */
@@ -3,10 +3,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { useEffect } from 'react';
4
4
  import { useControllable } from '../provider.js';
5
5
  import { GestureSheet } from '../gesture-sheet.js';
6
- import { SwapPanelBlock } from './swap-panel-block.js';
6
+ import { SwapBlock } from './swap-block.js';
7
7
  import { parentView } from './swap/shared.js';
8
8
  /**
9
- * SwapPanelBlock presented in a gesture sheet (Vaul). Token pickers and settings push inside the same sheet, which resizes to
9
+ * SwapBlock presented in a gesture sheet (Vaul). Token pickers and settings push inside the same sheet, which resizes to
10
10
  * each view. Escape and Back pop a pushed view first; from the cards, Escape, the scrim and a downward drag close the sheet.
11
11
  * Lives in its own entry so the blocks aggregate stays free of the optional Vaul peer.
12
12
  */
@@ -18,5 +18,5 @@ export function SwapSheet({ open, onOpenChange, title, trigger, view: viewProp,
18
18
  return _jsx(GestureSheet, { open: open, onOpenChange: onOpenChange, title: title, titleHidden: true, trigger: trigger, closeButton: null, contentMode: 'custom', enableDynamicSizing: true, contentProps: { className: 'hig-swap-sheet', onEscapeKeyDown: event => { if (view !== 'main') {
19
19
  event.preventDefault();
20
20
  show(parentView(view));
21
- } } }, children: _jsx(SwapPanelBlock, { ...panel, view: view, onViewChange: show }) });
21
+ } } }, children: _jsx(SwapBlock, { ...panel, view: view, onViewChange: show }) });
22
22
  }
@@ -23,6 +23,8 @@ export interface TargetBlockLabels {
23
23
  custom: string;
24
24
  /** Accessible name of the info button that shows `note`: How this order fills. Without it the note is always shown. */
25
25
  info?: string;
26
+ /** Accessible name of the quick choices' group, not drawn: Quick targets. Defaults to `title`. */
27
+ presets?: string;
26
28
  }
27
29
  export interface TargetBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
28
30
  kind: TargetKind;
@@ -83,7 +85,11 @@ export interface TargetUnitOption {
83
85
  export declare function targetPresets(presets: readonly (number | TargetPreset)[]): TargetPreset[];
84
86
  /** The units as `{unit, disabled}`, whichever form the host gave. */
85
87
  export declare function targetUnits(units: readonly (TargetUnit | TargetUnitOption)[]): TargetUnitOption[];
86
- /** Number format of a target in a unit. Dollars and percents carry their sign; `short` drops the cents of a whole dollar amount, for a preset. */
88
+ /**
89
+ * Number format of a target in a unit. Dollars and percents carry their sign. `short` is a preset's value: a whole dollar amount
90
+ * or a whole price drops its fraction digits (`+$10`, `$63,000`), whatever fraction digits `priceOptions` fix, so a preset reads
91
+ * the same on web and native; a price formatted by significant digits keeps `priceOptions`.
92
+ */
87
93
  export declare function targetFormat(unit: TargetUnit, priceOptions?: Intl.NumberFormatOptions, short?: number): Intl.NumberFormatOptions;
88
94
  /**
89
95
  * Where each known price sits on the bar, as a fraction of its width from the low-price edge, the prices in price order, and
@@ -6,6 +6,7 @@ import * as en from '@bloxwap/hig/contracts/messages';
6
6
  import { PressDecoration, usePresentNumber, useHIG, useNumberLocale } from '../provider.js';
7
7
  import { Button } from '../button.js';
8
8
  import { SegmentedControl } from '../selection.js';
9
+ import { PresetGroup } from '../preset-group.js';
9
10
  import { AnimatedNumberReadout } from '../animated-number.js';
10
11
  import { ScreenHeader } from './screen-header.js';
11
12
  import { SwapIcon } from './swap/shared.js';
@@ -15,13 +16,18 @@ export function targetPresets(presets) { return presets.map(preset => typeof pre
15
16
  export function targetUnits(units) { return units.map(unit => typeof unit === 'string' ? { unit } : unit); }
16
17
  const usd = { style: 'currency', currency: 'USD' }, allUnits = ['dollar', 'price', 'percent'];
17
18
  const known = (value) => value != null && Number.isFinite(value);
18
- /** Number format of a target in a unit. Dollars and percents carry their sign; `short` drops the cents of a whole dollar amount, for a preset. */
19
+ /**
20
+ * Number format of a target in a unit. Dollars and percents carry their sign. `short` is a preset's value: a whole dollar amount
21
+ * or a whole price drops its fraction digits (`+$10`, `$63,000`), whatever fraction digits `priceOptions` fix, so a preset reads
22
+ * the same on web and native; a price formatted by significant digits keeps `priceOptions`.
23
+ */
19
24
  export function targetFormat(unit, priceOptions = usd, short) {
25
+ const whole = short !== undefined && Number.isInteger(short);
20
26
  if (unit === 'price')
21
- return priceOptions;
27
+ return whole && priceOptions.minimumSignificantDigits === undefined && priceOptions.maximumSignificantDigits === undefined ? { ...priceOptions, minimumFractionDigits: 0, maximumFractionDigits: 0 } : priceOptions;
22
28
  if (unit === 'percent')
23
29
  return { style: 'percent', maximumFractionDigits: 2, signDisplay: 'exceptZero' };
24
- return { ...usd, signDisplay: 'exceptZero', ...(short !== undefined && Number.isInteger(short) ? { maximumFractionDigits: 0 } : null) };
30
+ return { ...usd, signDisplay: 'exceptZero', ...(whole ? { maximumFractionDigits: 0 } : null) };
25
31
  }
26
32
  /**
27
33
  * Where each known price sits on the bar, as a fraction of its width from the low-price edge, the prices in price order, and
@@ -69,5 +75,5 @@ export function TargetBlock({ kind, labels, position, orderType, note, entry, tr
69
75
  const { positions, order, from, to } = targetLayout({ entry, trigger: target });
70
76
  const prices = { entry, trigger: target };
71
77
  const intent = kind === 'stop-loss' ? 'destructive' : 'primary';
72
- return _jsxs("section", { ...rest, className: `hig-target-block${className ? ` ${className}` : ''}`, "data-kind": kind, children: [_jsx(ScreenHeader, { title: labels.title, onBack: onBack, headingId: headingId, stickyHeader: stickyHeader, action: info ? headerAction ? _jsxs("span", { className: 'hig-target-header-actions', children: [infoButton, headerAction] }) : infoButton : headerAction }), _jsx("p", { className: 'hig-target-amount', children: _jsx(AnimatedNumberReadout, { value: value, options: targetFormat(unit, priceOptions) }) }), note && !info && _jsx("p", { className: 'hig-target-note', children: note }), _jsxs("section", { className: surface ? 'hig-surface hig-target-prices' : 'hig-target-prices', "data-surface": surface ? undefined : 'false', "aria-labelledby": position ? id : undefined, children: [(position || orderType) && _jsxs("div", { className: 'hig-bar-mark-header', children: [position && _jsx("strong", { id: id, className: 'hig-bar-mark-title', children: position }), orderType && _jsx("span", { className: 'hig-bar-mark-description', children: orderType })] }), _jsxs("div", { className: 'hig-target-bar', "aria-hidden": 'true', children: [_jsx("span", { className: 'hig-target-rest', style: { flexGrow: from } }), to > from && _jsx("span", { className: 'hig-target-move', "data-lead": (positions.trigger ?? 0) < (positions.entry ?? 0) ? 'trigger' : 'start', style: { flexGrow: to - from } }), _jsx("span", { className: 'hig-target-rest', style: { flexGrow: 1 - to } })] }), _jsx("dl", { className: 'hig-bar-pnl-readouts', children: order.map(price => _jsxs("div", { "data-price": price, children: [_jsx("dt", { children: labels[price] }), _jsx("dd", { children: _jsx(AnimatedNumberReadout, { value: prices[price], options: priceOptions }) })] }, price)) })] }), units.length > 1 && _jsx(SegmentedControl, { label: labels.unit, options: targetUnits(units).map(option => ({ value: option.unit, label: labels.units[option.unit], disabled: option.disabled })), value: unit, onValueChange: next => onUnitChange?.(next) }), onCustom && (custom === null ? _jsxs("button", { type: 'button', className: 'hig-swap-setting', "aria-pressed": customValue !== undefined ? false : undefined, onClick: onCustom, children: [_jsx("span", { children: labels.custom }), _jsx(SwapIcon, { name: 'chevron', size: 16 }), _jsx(PressDecoration, { kind: 'row' })] }) : _jsxs("button", { type: 'button', className: 'hig-swap-setting', "aria-pressed": 'true', onClick: onCustom, children: [_jsx("span", { children: labels.custom }), _jsxs("span", { className: 'hig-swap-setting-value', children: [formatNumber(custom, locale, present(targetFormat(unit, priceOptions))), _jsx(SwapIcon, { name: 'chevron', size: 16 })] }), _jsx(PressDecoration, { kind: 'row' })] })), presets.length > 0 && _jsx("div", { className: 'hig-target-presets', children: targetPresets(presets).map(({ value: preset, disabled }) => { const selected = custom === null && preset === value; return _jsx(Button, { fullWidth: true, intent: selected ? intent : 'secondary', "aria-pressed": selected, disabled: disabled, onClick: () => onValueChange?.(preset), children: formatNumber(preset, locale, present(targetFormat(unit, priceOptions, preset))) }, preset); }) }), _jsxs("div", { className: 'hig-target-actions', children: [onCancel && _jsx(Button, { fullWidth: true, intent: 'secondary', onClick: onCancel, children: labels.cancel ?? messages.cancel ?? en.cancel }), _jsx(Button, { fullWidth: true, intent: intent, disabled: submitDisabled ?? value === null, busy: busy, onClick: onSubmit, children: labels.submit })] })] });
78
+ return _jsxs("section", { ...rest, className: `hig-target-block${className ? ` ${className}` : ''}`, "data-kind": kind, children: [_jsx(ScreenHeader, { title: labels.title, onBack: onBack, headingId: headingId, stickyHeader: stickyHeader, action: info ? headerAction ? _jsxs("span", { className: 'hig-target-header-actions', children: [infoButton, headerAction] }) : infoButton : headerAction }), _jsx("p", { className: 'hig-target-amount', children: _jsx(AnimatedNumberReadout, { value: value, options: targetFormat(unit, priceOptions) }) }), note && !info && _jsx("p", { className: 'hig-target-note', children: note }), _jsxs("section", { className: surface ? 'hig-surface hig-target-prices' : 'hig-target-prices', "data-surface": surface ? undefined : 'false', "aria-labelledby": position ? id : undefined, children: [(position || orderType) && _jsxs("div", { className: 'hig-bar-mark-header', children: [position && _jsx("strong", { id: id, className: 'hig-bar-mark-title', children: position }), orderType && _jsx("span", { className: 'hig-bar-mark-description', children: orderType })] }), _jsxs("div", { className: 'hig-target-bar', "aria-hidden": 'true', children: [_jsx("span", { className: 'hig-target-rest', style: { flexGrow: from } }), to > from && _jsx("span", { className: 'hig-target-move', "data-lead": (positions.trigger ?? 0) < (positions.entry ?? 0) ? 'trigger' : 'start', style: { flexGrow: to - from } }), _jsx("span", { className: 'hig-target-rest', style: { flexGrow: 1 - to } })] }), _jsx("dl", { className: 'hig-bar-pnl-readouts', children: order.map(price => _jsxs("div", { "data-price": price, children: [_jsx("dt", { children: labels[price] }), _jsx("dd", { children: _jsx(AnimatedNumberReadout, { value: prices[price], options: priceOptions }) })] }, price)) })] }), units.length > 1 && _jsx(SegmentedControl, { label: labels.unit, options: targetUnits(units).map(option => ({ value: option.unit, label: labels.units[option.unit], disabled: option.disabled })), value: unit, onValueChange: next => onUnitChange?.(next) }), onCustom && (custom === null ? _jsxs("button", { type: 'button', className: 'hig-swap-setting', "aria-pressed": customValue !== undefined ? false : undefined, onClick: onCustom, children: [_jsx("span", { children: labels.custom }), _jsx(SwapIcon, { name: 'chevron', size: 16 }), _jsx(PressDecoration, { kind: 'row' })] }) : _jsxs("button", { type: 'button', className: 'hig-swap-setting', "aria-pressed": 'true', onClick: onCustom, children: [_jsx("span", { children: labels.custom }), _jsxs("span", { className: 'hig-swap-setting-value', children: [formatNumber(custom, locale, present(targetFormat(unit, priceOptions))), _jsx(SwapIcon, { name: 'chevron', size: 16 })] }), _jsx(PressDecoration, { kind: 'row' })] })), presets.length > 0 && _jsx(PresetGroup, { className: 'hig-target-presets', label: labels.presets ?? labels.title, selectedIntent: intent, options: targetPresets(presets).map(({ value: preset, disabled }) => ({ value: preset, disabled, label: formatNumber(preset, locale, present(targetFormat(unit, priceOptions, preset))) })), value: custom === null ? value : null, onValueChange: next => onValueChange?.(next) }), _jsxs("div", { className: 'hig-target-actions', children: [onCancel && _jsx(Button, { fullWidth: true, intent: 'secondary', onClick: onCancel, children: labels.cancel ?? messages.cancel ?? en.cancel }), _jsx(Button, { fullWidth: true, intent: intent, disabled: !!submitDisabled || !known(value) || (unit === 'price' && value <= 0), busy: busy, onClick: onSubmit, children: labels.submit })] })] });
73
79
  }
@@ -36,11 +36,15 @@ export interface TokenActionBlockProps extends Omit<React.HTMLAttributes<HTMLEle
36
36
  onBack?: () => void;
37
37
  /** A control on the trailing edge of the header, usually an `IconButton`. */
38
38
  headerAction?: React.ReactNode;
39
- /** A line under the actions, for example why some are missing. `noteTone` tints it as in `SwapPanelBlock`. */
39
+ /** Pins the header to the top of the nearest scroller: transparent at rest, filled once content scrolls under it, and still when it starts to stick. See Pinned headers. */
40
+ stickyHeader?: boolean;
41
+ /** `id` of the header's heading, so a host dialog or sheet can name itself with `aria-labelledby`. */
42
+ headingId?: string;
43
+ /** A line under the actions, for example why some are missing. `noteTone` tints it as in `SwapBlock`. */
40
44
  note?: React.ReactNode;
41
45
  noteTone?: 'muted' | 'warning' | 'negative';
42
46
  }
43
47
  /** The text of an action: its `label`, the built-in label for a known id, or the id itself. */
44
48
  export declare const tokenActionLabel: (action: TokenAction, messages?: Partial<HIGMessages>) => string;
45
49
  /** One token and what can be done with it: where it is held, which chains it sits on, and the actions as equal full-width buttons. */
46
- export declare function TokenActionBlock({ symbol, name, value, units, unitsSuffix, unitsOptions, assets, chains, chainsTitle, actions, onBack, headerAction, note, noteTone, className, ...rest }: TokenActionBlockProps): React.JSX.Element;
50
+ export declare function TokenActionBlock({ symbol, name, value, units, unitsSuffix, unitsOptions, assets, chains, chainsTitle, actions, onBack, headerAction, note, noteTone, stickyHeader, headingId, className, ...rest }: TokenActionBlockProps): React.JSX.Element;
@@ -11,11 +11,12 @@ const usd = { style: 'currency', currency: 'USD' }, unitsFormat = { maximumFract
11
11
  /** The text of an action: its `label`, the built-in label for a known id, or the id itself. */
12
12
  export const tokenActionLabel = (action, messages = {}) => action.label ?? (action.id === 'send' ? messages.swapActionSend ?? en.swapActionSend : action.id === 'receive' ? messages.receive ?? en.receive : action.id === 'stake' ? messages.stake ?? en.stake : action.id === 'unstake' ? messages.unstake ?? en.unstake : action.id);
13
13
  /** One token and what can be done with it: where it is held, which chains it sits on, and the actions as equal full-width buttons. */
14
- export function TokenActionBlock({ symbol, name, value, units, unitsSuffix, unitsOptions = unitsFormat, assets, chains, chainsTitle, actions, onBack, headerAction, note, noteTone = 'muted', className, ...rest }) {
14
+ export function TokenActionBlock({ symbol, name, value, units, unitsSuffix, unitsOptions = unitsFormat, assets, chains, chainsTitle, actions, onBack, headerAction, note, noteTone = 'muted', stickyHeader, headingId, className, ...rest }) {
15
15
  const { messages } = useHIG();
16
16
  const locale = useNumberLocale();
17
17
  const total = value !== undefined ? value : (assets ?? []).reduce((sum, asset) => sum + (held(asset.value) ? asset.value : 0), 0);
18
18
  // With no dollar value the units are the headline, as an AccountBlock row headlines them.
19
+ const showChains = chains !== undefined && chains.length > 1;
19
20
  const headline = units !== undefined && value == null ? _jsx(AnimatedNumberReadout, { value: units, options: unitsOptions, suffix: unitsSuffix }, 'units') : _jsx(AnimatedNumberReadout, { value: total, options: usd }, 'value');
20
- return _jsxs("section", { ...rest, className: `hig-token-card${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: symbol, onBack: onBack, action: headerAction }), (assets || chains) && _jsxs("div", { className: 'hig-token-bars', children: [assets && _jsx(BarMark, { surface: false, title: name ?? symbol, description: headline, elements: assets }), chains && _jsx(BarMark, { surface: false, title: chainsTitle ?? messages.swapChains ?? en.swapChains, description: formatNumber(chains.filter(chain => held(chain.value)).length, locale), elements: chains })] }), actions.length > 0 && _jsx("div", { className: 'hig-token-actions', children: actions.map(action => _jsx(Button, { fullWidth: true, intent: action.intent ?? 'secondary', disabled: action.disabled, onClick: action.onSelect, children: tokenActionLabel(action, messages) }, action.id)) }), note != null && note !== false && _jsx("p", { className: 'hig-swap-note hig-token-note', "data-tone": noteTone, role: 'note', children: note })] });
21
+ return _jsxs("section", { ...rest, className: `hig-token-card${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: symbol, onBack: onBack, action: headerAction, headingId: headingId, stickyHeader: stickyHeader }), (assets || showChains) && _jsxs("div", { className: 'hig-token-bars', children: [assets && _jsx(BarMark, { surface: false, title: name ?? symbol, description: headline, elements: assets }), showChains && _jsx(BarMark, { surface: false, title: chainsTitle ?? messages.swapChains ?? en.swapChains, description: formatNumber(chains.filter(chain => held(chain.value)).length, locale), elements: chains })] }), actions.length > 0 && _jsx("div", { className: 'hig-token-actions', children: actions.map(action => _jsx(Button, { fullWidth: true, intent: action.intent ?? 'secondary', disabled: action.disabled, onClick: action.onSelect, children: tokenActionLabel(action, messages) }, action.id)) }), note != null && note !== false && _jsx("p", { className: 'hig-swap-note hig-token-note', "data-tone": noteTone, role: 'note', children: note })] });
21
22
  }
@@ -67,6 +67,8 @@ export interface TradeHistoryDetailBlockProps extends Omit<React.HTMLAttributes<
67
67
  onBack?: () => void;
68
68
  /** A control on the trailing edge of the header, usually an `IconButton`. */
69
69
  headerAction?: React.ReactNode;
70
+ /** `id` of the header's heading, so a host dialog or sheet can name itself with `aria-labelledby`. */
71
+ headingId?: string;
70
72
  /** Ref to the summary (the asset line, the headline figure and the return), for a host that captures it as an image. */
71
73
  summaryRef?: React.Ref<HTMLDivElement>;
72
74
  /** Fills the summary, so an image captured from `summaryRef` is not transparent: `true` for the background role, or a CSS colour such as `var(--hig-overlay)` in a sheet. */
@@ -75,4 +77,4 @@ export interface TradeHistoryDetailBlockProps extends Omit<React.HTMLAttributes<
75
77
  stickyHeader?: boolean;
76
78
  }
77
79
  /** The full record of one closed trade, drawn on the screen without cards because none of it is pressable: the asset with its side and leverage on one line, the net result as the headline figure, a bar from the entry price to the exit price, the other figures as a compact grid, and the host's actions. */
78
- export declare function TradeHistoryDetailBlock({ labels, name, icon, symbol, side, leverage, leverageNote, pnl, pnlOptions, pnlPercent, percentOptions, entry, exit, priceOptions, details, note, badge, actions, onBack, headerAction, summaryRef, summaryBackground, stickyHeader, className, ...rest }: TradeHistoryDetailBlockProps): React.JSX.Element;
80
+ export declare function TradeHistoryDetailBlock({ labels, name, icon, symbol, side, leverage, leverageNote, pnl, pnlOptions, pnlPercent, percentOptions, entry, exit, priceOptions, details, note, badge, actions, onBack, headerAction, summaryRef, summaryBackground, stickyHeader, headingId, className, ...rest }: TradeHistoryDetailBlockProps): React.JSX.Element;
@@ -9,9 +9,9 @@ import { ScreenHeader } from './screen-header.js';
9
9
  import { SwapNumber } from './swap/shared.js';
10
10
  const pnlFormat = { style: 'currency', currency: 'USD', signDisplay: 'exceptZero', maximumFractionDigits: 4 }, percentFormat = { style: 'percent', minimumFractionDigits: 2, maximumFractionDigits: 2, signDisplay: 'exceptZero' };
11
11
  /** The full record of one closed trade, drawn on the screen without cards because none of it is pressable: the asset with its side and leverage on one line, the net result as the headline figure, a bar from the entry price to the exit price, the other figures as a compact grid, and the host's actions. */
12
- export function TradeHistoryDetailBlock({ labels, name, icon, symbol, side, leverage, leverageNote, pnl, pnlOptions = pnlFormat, pnlPercent, percentOptions = percentFormat, entry, exit, priceOptions, details, note, badge, actions = [], onBack, headerAction, summaryRef, summaryBackground, stickyHeader, className, ...rest }) {
12
+ export function TradeHistoryDetailBlock({ labels, name, icon, symbol, side, leverage, leverageNote, pnl, pnlOptions = pnlFormat, pnlPercent, percentOptions = percentFormat, entry, exit, priceOptions, details, note, badge, actions = [], onBack, headerAction, summaryRef, summaryBackground, stickyHeader, headingId, className, ...rest }) {
13
13
  const locale = useNumberLocale();
14
14
  const tone = pnl == null || pnl === 0 ? undefined : pnl > 0 ? 'up' : 'down';
15
15
  const fill = summaryBackground === true ? 'var(--hig-background)' : typeof summaryBackground === 'string' && summaryBackground ? summaryBackground : undefined;
16
- return _jsxs("section", { ...rest, className: `hig-trade-detail${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: labels.title, onBack: onBack, action: headerAction, badge: badge, stickyHeader: stickyHeader }), _jsxs("div", { className: 'hig-trade-summary', children: [_jsxs("div", { ref: summaryRef, className: 'hig-trade-result', "data-tone": tone, style: fill ? { background: fill } : undefined, children: [_jsxs("div", { className: 'hig-trade-identity', children: [_jsx("span", { className: 'hig-trade-avatar', "aria-hidden": 'true', children: typeof icon === 'string' ? _jsx("img", { src: icon, alt: '' }) : icon ?? symbol ?? name.slice(0, 3) }), _jsx("strong", { children: name }), _jsxs("span", { children: [_jsxs("span", { className: 'hig-position-side hig-trade-side', "data-side": side, children: [_jsxs("span", { "aria-hidden": 'true', children: [side === 'long' ? '↑' : '↓', " "] }), side === 'long' ? labels.long : labels.short] }), leverage != null && _jsxs(_Fragment, { children: [" ", formatNumber(leverage, locale), "\u00D7"] }), leverageNote && _jsxs(_Fragment, { children: [" ", _jsx("span", { className: 'hig-trade-leverage-note', children: leverageNote })] })] })] }), _jsxs("strong", { className: 'hig-trade-figure', children: [_jsxs("span", { className: 'hig-trade-caption hig-sr-only', children: [labels.netPnl, " "] }), _jsx(AnimatedNumberReadout, { value: pnl, options: pnlOptions })] }), pnlPercent !== undefined && _jsx("span", { className: 'hig-trade-return', children: pnlPercent === null ? labels.onMargin('—') : _jsx(SwapNumber, { template: labels.onMargin, value: pnlPercent, options: percentOptions }) })] }), entry != null && exit != null && _jsx(BarPnl, { className: 'hig-trade-bar', surface: false, fit: true, side: side, entry: entry, mark: exit, labels: { entry: labels.entry ?? '', mark: labels.exit ?? '', liquidation: '' }, priceOptions: priceOptions }), details.length > 0 && _jsx("dl", { className: 'hig-trade-details', children: details.map(row => _jsxs("div", { children: [_jsx("dt", { children: row.label }), _jsx("dd", { children: typeof row.value === 'number' ? _jsx(SwapNumber, { value: row.value, options: row.options, prefix: row.prefix, suffix: row.suffix, formattedValue: row.formattedValue, animateFormatted: !!row.formattedValue }) : row.value })] }, row.label)) }), note && _jsx("p", { className: 'hig-trade-note', children: note })] }), actions.length > 0 && _jsx("div", { className: 'hig-trade-actions', children: actions.map(action => _jsx(Button, { fullWidth: true, intent: action.intent ?? 'secondary', disabled: action.disabled, busy: action.busy, onClick: action.onSelect, children: action.label }, action.id)) })] });
16
+ return _jsxs("section", { ...rest, className: `hig-trade-detail${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: labels.title, onBack: onBack, action: headerAction, badge: badge, headingId: headingId, stickyHeader: stickyHeader }), _jsxs("div", { className: 'hig-trade-summary', children: [_jsxs("div", { ref: summaryRef, className: 'hig-trade-result', "data-tone": tone, style: fill ? { background: fill } : undefined, children: [_jsxs("div", { className: 'hig-trade-identity', children: [_jsx("span", { className: 'hig-trade-avatar', "aria-hidden": 'true', children: typeof icon === 'string' ? _jsx("img", { src: icon, alt: '' }) : icon ?? symbol ?? name.slice(0, 3) }), _jsx("strong", { children: name }), _jsxs("span", { children: [_jsxs("span", { className: 'hig-position-side hig-trade-side', "data-side": side, children: [_jsxs("span", { "aria-hidden": 'true', children: [side === 'long' ? '↑' : '↓', " "] }), side === 'long' ? labels.long : labels.short] }), leverage != null && _jsxs(_Fragment, { children: [" ", formatNumber(leverage, locale), "\u00D7"] }), leverageNote && _jsxs(_Fragment, { children: [" ", _jsx("span", { className: 'hig-trade-leverage-note', children: leverageNote })] })] })] }), _jsxs("strong", { className: 'hig-trade-figure', children: [_jsxs("span", { className: 'hig-trade-caption hig-sr-only', children: [labels.netPnl, " "] }), _jsx(AnimatedNumberReadout, { value: pnl, options: pnlOptions })] }), pnlPercent !== undefined && _jsx("span", { className: 'hig-trade-return', children: pnlPercent === null ? labels.onMargin('—') : _jsx(SwapNumber, { template: labels.onMargin, value: pnlPercent, options: percentOptions }) })] }), entry != null && exit != null && _jsx(BarPnl, { className: 'hig-trade-bar', surface: false, fit: true, side: side, entry: entry, mark: exit, labels: { entry: labels.entry ?? '', mark: labels.exit ?? '', liquidation: '' }, priceOptions: priceOptions }), details.length > 0 && _jsx("dl", { className: 'hig-trade-details', children: details.map(row => _jsxs("div", { children: [_jsx("dt", { children: row.label }), _jsx("dd", { children: typeof row.value === 'number' ? _jsx(SwapNumber, { value: row.value, options: row.options, prefix: row.prefix, suffix: row.suffix, formattedValue: row.formattedValue, animateFormatted: !!row.formattedValue }) : row.value })] }, row.label)) }), note && _jsx("p", { className: 'hig-trade-note', children: note })] }), actions.length > 0 && _jsx("div", { className: 'hig-trade-actions', children: actions.map(action => _jsx(Button, { fullWidth: true, intent: action.intent ?? 'secondary', disabled: action.disabled, busy: action.busy, onClick: action.onSelect, children: action.label }, action.id)) })] });
17
17
  }
@@ -44,6 +44,8 @@ export interface TradeHistoryListBlockProps extends Omit<React.HTMLAttributes<HT
44
44
  onBack?: () => void;
45
45
  /** A control on the trailing edge of the header, usually an `IconButton`. */
46
46
  headerAction?: React.ReactNode;
47
+ /** `id` of the header's heading, so a host dialog or sheet can name itself with `aria-labelledby`. */
48
+ headingId?: string;
47
49
  /** Format of the result. Defaults to signed US dollars at four significant digits: `+$1.412`, `+$17.90`, `-$0.6878`. The provider's `numberFormat` is merged under it. */
48
50
  pnlOptions?: Intl.NumberFormatOptions;
49
51
  /** Draws rows of skeletons in place of the trades while the host loads them. */
@@ -64,4 +66,4 @@ export declare const tradeHistorySide: (trade: Pick<TradeHistoryItem, 'side' | '
64
66
  leverageNote?: string;
65
67
  }, labels: Pick<TradeHistoryListLabels, 'long' | 'short'>, locale?: string) => string;
66
68
  /** A history of closed trades as one screen: a header, then one row per trade with the asset, its side and leverage in the market direction colour, and the net result in the market direction colour over its age. */
67
- export declare function TradeHistoryListBlock({ labels, trades, onSelect, onBack, headerAction, pnlOptions, loading, loadingLabel, error, notice, footer, stickyHeader, className, ...rest }: TradeHistoryListBlockProps): React.JSX.Element;
69
+ export declare function TradeHistoryListBlock({ labels, trades, onSelect, onBack, headerAction, pnlOptions, loading, loadingLabel, error, notice, footer, stickyHeader, headingId, className, ...rest }: TradeHistoryListBlockProps): React.JSX.Element;
@@ -1,5 +1,8 @@
1
1
  "use client";
2
2
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { ArrowDown } from '@bloxwap/icons/react/arrow-down';
4
+ import { ArrowUp } from '@bloxwap/icons/react/arrow-up';
5
+ import { ChevronRight } from '@bloxwap/icons/react/chevron-right';
3
6
  import { formatNumber } from '@bloxwap/hig/contracts';
4
7
  import { PressDecoration, usePresentNumber, useNumberLocale } from '../provider.js';
5
8
  import { AnimatedNumberReadout } from '../animated-number.js';
@@ -8,10 +11,10 @@ const pnlFormat = { style: 'currency', currency: 'USD', signDisplay: 'exceptZero
8
11
  const skeletons = [0, 1, 2, 3];
9
12
  /** How a row reads its side: `Short 20×`, or `Short` without leverage. */
10
13
  export const tradeHistorySide = (trade, labels, locale) => `${trade.side === 'long' ? labels.long : labels.short}${trade.leverage != null ? ` ${formatNumber(trade.leverage, locale)}×` : ''}${trade.leverageNote ? ` ${trade.leverageNote}` : ''}`;
11
- const arrow = (side) => _jsx("svg", { "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 16 16', width: '16', height: '16', fill: 'none', stroke: 'currentColor', strokeWidth: '1.8', strokeLinecap: 'round', strokeLinejoin: 'round', children: side === 'long' ? _jsx("path", { d: 'M8 13V3.5M4 7.5l4-4 4 4' }) : _jsx("path", { d: 'M8 3v9.5M4 8.5l4 4 4-4' }) });
12
- const chevron = _jsx("svg", { className: 'hig-trade-row-chevron', "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', width: '20', height: '20', fill: 'none', stroke: 'currentColor', strokeWidth: '1.8', strokeLinecap: 'round', strokeLinejoin: 'round', children: _jsx("path", { d: 'm7.5 4.5 5.5 5.5-5.5 5.5' }) });
14
+ const arrow = (side) => (side === 'long' ? _jsx(ArrowUp, { size: 16 }) : _jsx(ArrowDown, { size: 16 }));
15
+ const chevron = _jsx(ChevronRight, { size: 20, className: 'hig-trade-row-chevron' });
13
16
  /** A history of closed trades as one screen: a header, then one row per trade with the asset, its side and leverage in the market direction colour, and the net result in the market direction colour over its age. */
14
- export function TradeHistoryListBlock({ labels, trades, onSelect, onBack, headerAction, pnlOptions = pnlFormat, loading, loadingLabel, error, notice, footer, stickyHeader, className, ...rest }) {
17
+ export function TradeHistoryListBlock({ labels, trades, onSelect, onBack, headerAction, pnlOptions = pnlFormat, loading, loadingLabel, error, notice, footer, stickyHeader, headingId, className, ...rest }) {
15
18
  const locale = useNumberLocale();
16
19
  const present = usePresentNumber();
17
20
  const row = (trade) => {
@@ -24,5 +27,5 @@ export function TradeHistoryListBlock({ labels, trades, onSelect, onBack, header
24
27
  : error ? _jsx("p", { className: 'hig-swap-empty hig-trade-error', role: 'alert', children: error })
25
28
  : trades.length === 0 ? _jsx("p", { className: 'hig-swap-empty', role: 'status', children: labels.emptyDescription ? _jsxs(_Fragment, { children: [_jsx("strong", { className: 'hig-trade-empty-title', children: labels.empty }), _jsx("span", { className: 'hig-trade-empty-description', children: labels.emptyDescription })] }) : labels.empty })
26
29
  : _jsx("ul", { className: 'hig-trade-rows', "aria-label": labels.title, children: trades.map(row) });
27
- return _jsxs("section", { ...rest, className: `hig-trade-history-list${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: labels.title, onBack: onBack, action: headerAction, stickyHeader: stickyHeader }), notice != null && notice !== false && _jsx("div", { className: 'hig-trade-notice', children: notice }), body, footer != null && footer !== false && _jsx("div", { className: 'hig-trade-footer', children: footer })] });
30
+ return _jsxs("section", { ...rest, className: `hig-trade-history-list${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: labels.title, onBack: onBack, action: headerAction, headingId: headingId, stickyHeader: stickyHeader }), notice != null && notice !== false && _jsx("div", { className: 'hig-trade-notice', children: notice }), body, footer != null && footer !== false && _jsx("div", { className: 'hig-trade-footer', children: footer })] });
28
31
  }
@@ -4,11 +4,14 @@ export { TradeEntry } from './blocks/trade-entry.js';
4
4
  export { InstallCommand } from './blocks/install-command.js';
5
5
  export { MarketingHero } from './blocks/marketing-hero.js';
6
6
  export { AccountBlock, AssetBalanceRow, accountRows, accountSectionRows, accountSectionTotal, assetValue, type AccountBlockProps, type AccountAsset, type AccountSection, type AccountOrder, type AccountRowsOptions, type AssetArtwork, type AssetBalanceRowProps } from './blocks/account-block.js';
7
+ export { LoginBlock, type LoginBlockProps, type LoginProvider } from './blocks/login-block.js';
8
+ export { DepositBlock, type DepositBlockProps, type DepositMethod } from './blocks/deposit-block.js';
7
9
  export { LanguageBlock, filterLanguages, type LanguageBlockProps, type LanguageOption } from './blocks/language-block.js';
8
10
  export { TokenActionBlock, tokenActionLabel, type TokenActionBlockProps, type TokenAction, type TokenActionId } from './blocks/token-action-block.js';
9
11
  export { ManagePositionBlock, positionCorridor, type ManagePositionBlockProps, type ManagePositionBlockLabels, type ManagePositionBlockAction, type ManagePositionBlockSummary, type ManagePositionBlockFigure, type ManagePositionIcon } from './blocks/manage-position-block.js';
10
12
  export { TargetBlock, targetLayout, targetFormat, targetPresets, targetUnits, type TargetBlockProps, type TargetBlockLabels, type TargetKind, type TargetUnit, type TargetPrice, type TargetPreset, type TargetUnitOption } from './blocks/target-block.js';
11
13
  export { PositionBlock, type PositionBlockProps, type PositionBlockDetail, type PositionBlockFigure, type PositionBlockRow, type PositionBlockFlag, type PositionBlockFlagAction } from './blocks/position-block.js';
14
+ export { AssetsBlock, filterAssets, type AssetsBlockProps, type AssetItem, type AssetCategory, type AssetSignal, type AssetsView, type AssetsEmptyAction } from './blocks/assets-block.js';
12
15
  export { ProfileBlock, type ProfileBlockProps, type ProfileSection, type ProfileRow, type ProfileStatus, type ProfileAction, type ProfileFigure } from './blocks/profile-block.js';
13
16
  export { RewardBlock, rewardProgress, type RewardBlockProps, type RewardPromo, type RewardEntry } from './blocks/reward-block.js';
14
17
  export { SoundHapticsBlock, soundLevel, type SoundHapticsBlockProps, type SoundSection, type SoundVolume, type SettingAction } from './blocks/sound-haptics-block.js';
@@ -16,5 +19,8 @@ export { SignalsBlock, type SignalsBlockProps, type SignalsGroup, type SignalsIt
16
19
  export { NotificationsBlock, type NotificationsBlockProps, type NotificationsItem } from './blocks/notifications-block.js';
17
20
  export { TradeHistoryListBlock, tradeHistorySide, type TradeHistoryListBlockProps, type TradeHistoryListLabels, type TradeHistoryItem } from './blocks/trade-history-list-block.js';
18
21
  export { TradeHistoryDetailBlock, type TradeHistoryDetailBlockProps, type TradeHistoryDetailLabels, type TradeHistoryDetail, type TradeHistoryAction } from './blocks/trade-history-detail-block.js';
19
- export { FromPickerBlock, ToPickerBlock, FromPicker, ToPicker, type FromPickerBlockProps, type ToPickerBlockProps, type FromPickerProps, type ToPickerProps, type PickerListProps, type PickerInputProps } from './blocks/pickers.js';
20
- export { SwapPanelBlock, SwapPanel, swapAction, type SwapPanelBlockProps, type SwapPanelProps, type SwapToken, type SwapChain, type SwapAction, type SwapDenomination, type SwapWallet, type SwapFee, type SwapReceive, type SwapDestination, type SwapDetail } from './blocks/swap-panel-block.js';
22
+ export { FromPickerBlock, ToPickerBlock, FromPicker, ToPicker, type FromPickerBlockProps, type ToPickerBlockProps, type FromPickerProps, type ToPickerProps, type PickerListProps, type PickerInputProps, type PickerRowProps } from './blocks/pickers.js';
23
+ export { SwapBlock, SwapPanelBlock, SwapPanel, swapAction, type SwapBlockProps, type SwapPanelBlockProps, type SwapPanelProps, type SwapToken, type SwapChain, type SwapAction, type SwapDenomination, type SwapWallet, type SwapFee, type SwapReceive, type SwapDestination, type SwapDetail } from './blocks/swap-block.js';
24
+ export { ConfirmBlock, type ConfirmBlockProps, type ConfirmDetail, type ConfirmTertiaryAction } from './blocks/confirm-block.js';
25
+ export { PresetPickerBlock, type PresetPickerBlockProps, type PresetPickerCustom } from './blocks/preset-picker-block.js';
26
+ export { ExplainerBlock, type ExplainerBlockProps, type ExplainerSection, type ExplainerAction, type ExplainerTone } from './blocks/explainer-block.js';
@@ -5,11 +5,14 @@ export { TradeEntry } from './blocks/trade-entry.js';
5
5
  export { InstallCommand } from './blocks/install-command.js';
6
6
  export { MarketingHero } from './blocks/marketing-hero.js';
7
7
  export { AccountBlock, AssetBalanceRow, accountRows, accountSectionRows, accountSectionTotal, assetValue } from './blocks/account-block.js';
8
+ export { LoginBlock } from './blocks/login-block.js';
9
+ export { DepositBlock } from './blocks/deposit-block.js';
8
10
  export { LanguageBlock, filterLanguages } from './blocks/language-block.js';
9
11
  export { TokenActionBlock, tokenActionLabel } from './blocks/token-action-block.js';
10
12
  export { ManagePositionBlock, positionCorridor } from './blocks/manage-position-block.js';
11
13
  export { TargetBlock, targetLayout, targetFormat, targetPresets, targetUnits } from './blocks/target-block.js';
12
14
  export { PositionBlock } from './blocks/position-block.js';
15
+ export { AssetsBlock, filterAssets } from './blocks/assets-block.js';
13
16
  export { ProfileBlock } from './blocks/profile-block.js';
14
17
  export { RewardBlock, rewardProgress } from './blocks/reward-block.js';
15
18
  export { SoundHapticsBlock, soundLevel } from './blocks/sound-haptics-block.js';
@@ -18,4 +21,7 @@ export { NotificationsBlock } from './blocks/notifications-block.js';
18
21
  export { TradeHistoryListBlock, tradeHistorySide } from './blocks/trade-history-list-block.js';
19
22
  export { TradeHistoryDetailBlock } from './blocks/trade-history-detail-block.js';
20
23
  export { FromPickerBlock, ToPickerBlock, FromPicker, ToPicker } from './blocks/pickers.js';
21
- export { SwapPanelBlock, SwapPanel, swapAction } from './blocks/swap-panel-block.js';
24
+ export { SwapBlock, SwapPanelBlock, SwapPanel, swapAction } from './blocks/swap-block.js';
25
+ export { ConfirmBlock } from './blocks/confirm-block.js';
26
+ export { PresetPickerBlock } from './blocks/preset-picker-block.js';
27
+ export { ExplainerBlock } from './blocks/explainer-block.js';
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Check } from '@bloxwap/icons/react/check';
2
3
  import { brandMark as mark } from '@bloxwap/hig/tokens/brand';
3
4
  /** The approved mark. Geometry and fills come from the pinned SVG through `@bloxwap/hig/tokens/brand`, so it does not follow `primaryColor` or the token palette. */
4
5
  export function BrandMark({ size = 32, label }) { return _jsxs("svg", { width: size, height: size, viewBox: mark.viewBox, role: label ? 'img' : undefined, "aria-label": label, "aria-hidden": label ? undefined : true, children: [_jsx("rect", { width: mark.size, height: mark.size, rx: mark.radius, fill: mark.fill.srgb }), _jsx("g", { fill: 'none', stroke: mark.stroke.srgb, strokeWidth: mark.strokeWidth, strokeLinecap: mark.strokeLinecap, children: mark.paths.map(d => _jsx("path", { d: d }, d)) })] }); }
5
- export function CheckIcon() { return _jsx("svg", { width: '20', height: '20', viewBox: '0 0 24 24', "aria-hidden": 'true', children: _jsx("path", { d: 'm5 12 4 4 10-10', fill: 'none', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round' }) }); }
6
+ export function CheckIcon() { return _jsx(Check, { size: 20 }); }
@@ -1,14 +1,20 @@
1
1
  import React from 'react';
2
2
  import type { Intent } from '@bloxwap/hig/contracts';
3
+ /** A button's intent: the shared `Intent`, a market-direction fill, `up` (buy, long) or `down` (sell, short), that follows `HIGProvider marketColors` (default the buy and sell colours) with a dark label, or `warning`, the warning role's fill with a dark label, for an action that goes ahead despite a caution. */
4
+ export type ButtonIntent = Intent | 'up' | 'down' | 'warning';
3
5
  export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
4
- intent?: Intent; /** Shows a leading spinner and blocks activation. */
6
+ intent?: ButtonIntent; /** Shows a leading spinner and blocks activation. */
5
7
  busy?: boolean; /** Busy text appended to the accessible name (not drawn; the spinner is the visible cue); defaults to HIGProvider `messages.busy`. `''` omits it (busy state stays exposed). */
6
8
  busyLabel?: string;
7
9
  fullWidth?: boolean;
8
- suppressFeedback?: boolean;
10
+ suppressFeedback?: boolean; /** Draws the button as a real link, `<a class="hig-button" href>`, with the same intents, sizes and busy spinner. Disabled or busy, the link drops its `href` and reads as a disabled link (`role="link"`, `aria-disabled`). The forwarded ref then holds the `HTMLAnchorElement`. */
11
+ href?: string; /** Link target, with `href`. Browsers treat `_blank` as `noopener`; pass `rel` for more. */
12
+ target?: React.HTMLAttributeAnchorTarget; /** Link relationship, with `href`. */
13
+ rel?: string; /** A soft halo in the fill colour around a filled intent, for one hero action on a brand or marketing surface. No halo while unavailable. */
14
+ glow?: boolean;
9
15
  }
10
16
  export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
11
- export declare const IconButton: React.ForwardRefExoticComponent<Omit<ButtonProps, "aria-label"> & {
17
+ export declare const IconButton: React.ForwardRefExoticComponent<Omit<ButtonProps, "aria-label" | "href"> & {
12
18
  label: string;
13
19
  } & React.RefAttributes<HTMLButtonElement>>;
14
20
  export declare const Link: React.ForwardRefExoticComponent<React.AnchorHTMLAttributes<HTMLAnchorElement> & React.RefAttributes<HTMLAnchorElement>>;