@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
@@ -1,18 +1,28 @@
1
1
  "use client";
2
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';
3
5
  import { useEffect, useMemo, useRef, useState } from 'react';
4
6
  import * as en from '@bloxwap/hig/contracts/messages';
5
- import { PressDecoration, useControllable, useHIG } from '../provider.js';
7
+ import { PressDecoration, useControllable, useHIG, useNumberLocale } from '../provider.js';
6
8
  import { Button, IconButton } from '../button.js';
7
9
  import { AnimatedNumberReadout } from '../animated-number.js';
8
10
  import { notify } from '../notify.js';
9
11
  import { VerticalAddress } from '../data.js';
10
12
  import { SwapPicker } from './swap/picker.js';
13
+ import { ScreenHeader } from './screen-header.js';
11
14
  import { SwapSettings } from './swap/settings.js';
12
- import { SwapIcon, SwapKeypad, SwapNumber, SwapPill, percentNumber, swapArt, swapFigure, usdNumber, addressGradient, applyAmountKey, chainsOf, parentView, sanitizeAmount, shortAddress, swapAction, testAmount, trimNumber, unitsToEntry } from './swap/shared.js';
15
+ import { SwapIcon, SwapKeypad, SwapNumber, SwapPill, percentNumber, swapArt, swapFigure, usdNumber, addressGradient, applyAmountKey, chainsOf, parentView, sanitizeAmount, shortAddress, swapAction, testAmount, unitsToEntry } from './swap/shared.js';
13
16
  export { swapAction } from './swap/shared.js';
14
17
  export { SwapAmountCard } from './swap/amount-card.js';
15
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; };
16
26
  const textTarget = (target) => { const element = target; return !!element && (/^(INPUT|TEXTAREA|SELECT)$/.test(element.tagName) || element.isContentEditable); };
17
27
  const amountKey = (event) => event.metaKey || event.ctrlKey || event.altKey ? null : /^[0-9.]$/.test(event.key) ? event.key : event.key === 'Backspace' ? 'back' : null;
18
28
  /**
@@ -20,14 +30,16 @@ const amountKey = (event) => event.metaKey || event.ctrlKey || event.altKey ? nu
20
30
  * or token units, token pickers, settings, and one action that names itself from the chosen pair.
21
31
  * Presentation only. The host owns tokens, balances, prices, the quote, the wallet and the transaction.
22
32
  */
23
- 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, 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, keypad = 'auto', shortcuts = true, captureKeyboard = false, view: viewProp, onViewChange, settings, className, style }) {
33
+ 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, 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 }) {
24
34
  const { messages } = useHIG();
35
+ const locale = useNumberLocale();
25
36
  const [from, setFrom] = useControllable(fromProp, defaultFrom, onFromChange);
26
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; };
27
39
  const [defaultMode, setDefaultMode] = useControllable(denomination, 'usd', onDenominationChange);
28
40
  const [isReceiving, setReceiving] = useControllable(receiving, false, onReceivingChange);
29
41
  // A mounted `amount` seeds the entry, in the default denomination at the initial From token's price.
30
- const [entry, setEntry] = useState(() => amount === undefined ? '0' : unitsToEntry(Number(amount) || 0, defaultMode, from?.price ?? 0));
42
+ const [entry, setEntry] = useState(() => amount === undefined ? '0' : unitsToEntry(boundedUnits(amount), defaultMode, from?.price ?? 0));
31
43
  const [fromMode, applyFromMode] = useState(defaultMode);
32
44
  const [toMode, applyToMode] = useState(defaultMode);
33
45
  const [view, show] = useControllable(viewProp, 'main', onViewChange);
@@ -52,7 +64,9 @@ export function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains,
52
64
  return () => coarse?.removeEventListener('change', update);
53
65
  }, []);
54
66
  const fromPrice = from?.price ?? 0, toPrice = to?.price ?? 0, input = Number(entry) || 0;
55
- const units = fromMode === 'token' ? input : fromPrice > 0 ? input / fromPrice : 0, usd = units * fromPrice, unitsText = trimNumber(units);
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;
56
70
  const showReceive = isReceiving && !!receive;
57
71
  // Report the amount in token units; resync the entry when the host sets a different amount.
58
72
  const reported = useRef(amount ?? '0');
@@ -60,19 +74,22 @@ export function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains,
60
74
  reported.current = unitsText;
61
75
  onAmountChange?.(unitsText);
62
76
  } }, [unitsText]);
63
- useEffect(() => { if (amount === undefined || Number(amount) === Number(reported.current))
64
- return; reported.current = trimNumber(Number(amount) || 0); setEntry(unitsToEntry(Number(amount) || 0, fromMode, fromPrice)); }, [amount]);
65
- const sameAsset = !!from && !!to && from.id === to.id;
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';
66
81
  const receivedUnits = sameAsset ? units : received ?? (toPrice > 0 ? usd / toPrice : 0);
67
82
  const receivedUsd = toPrice > 0 ? receivedUnits * toPrice : sameAsset ? usd : 0;
68
83
  const action = swapAction(from, to);
69
- const insufficient = !!from && (from.balance ?? 0) > 0 && units > (from.balance ?? 0);
84
+ const insufficient = !!from && from.balance != null && (!Number.isFinite(from.balance) || from.balance < 0 || decimalCompare(unitsText, from.balance) > 0);
70
85
  // A destination or a details card stands in for the To token: one way, and ready from the From side alone.
71
86
  const fixed = !!destination || (!!details && !to);
72
87
  const oneWay = oneWayProp || fixed;
73
- const eligible = !!from && (!!to || fixed) && !destination?.pending && units > 0 && !insufficient;
88
+ const eligible = !!from && (!!to || fixed) && !destination?.pending && Number.isFinite(units) && units > 0 && !insufficient;
74
89
  const ready = eligible && !actionDisabled;
75
- const actionText = showReceive ? (messages.swapSendFromWallet ?? en.swapSendFromWallet) : !from || (!to && !fixed) ? (messages.swapChooseToken ?? en.swapChooseToken) : destination?.pending ? (messages.swapChooseDestination ?? en.swapChooseDestination) : units <= 0 ? (messages.swapEnterAmount ?? en.swapEnterAmount) : insufficient ? (messages.swapInsufficient ?? en.swapInsufficient)(from.symbol) : actionDisabled && actionStatus ? actionStatus : actionLabel ?? (action === 'swap' && !fixed ? messages.swapActionSwap ?? en.swapActionSwap : action === 'bridge' && !fixed ? messages.swapActionBridge ?? en.swapActionBridge : messages.swapActionSend ?? en.swapActionSend);
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;
76
93
  const pristine = (lockFrom || !from) && (lockTo || !to) && input === 0;
77
94
  // Updater form: several keys can land before the next render, and each must build on the last.
78
95
  const latest = useRef(fromMode);
@@ -80,26 +97,34 @@ export function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains,
80
97
  const latestView = useRef(view);
81
98
  latestView.current = view;
82
99
  // Read at key time: several keys can land in one render.
83
- const limits = useRef({ decimals: from?.decimals, balance: from?.balance ?? 0, price: fromPrice, cap: limitToBalance });
84
- limits.current = { decimals: from?.decimals, balance: from?.balance ?? 0, price: fromPrice, cap: limitToBalance };
85
- const over = (next) => { const { balance, price, cap } = limits.current; if (!cap || !(balance > 0))
86
- return false; const value = Number(next) || 0; return (latest.current === 'token' ? value : price > 0 ? value / price : 0) > balance; };
87
- const press = (key) => setEntry(current => { const next = applyAmountKey(current, key, latest.current, limits.current.decimals); return key !== 'back' && over(next) ? current : next; });
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; });
88
111
  const paste = (text) => { const clean = text.trim().replace(/,/g, ''); if (clean === '' || !/^[0-9]*\.?[0-9]*$/.test(clean))
89
- return false; const next = sanitizeAmount(clean); setEntry(latest.current === 'usd' ? trimNumber(Number(next) || 0, 2) : next); return true; };
90
- const switchFromMode = (mode) => { if (mode === fromMode)
91
- return; setEntry(mode === 'usd' ? trimNumber(usd, 2) : trimNumber(units)); applyFromMode(mode); };
92
- const changeDenomination = (mode) => { setDefaultMode(mode); switchFromMode(mode); applyToMode(mode); };
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); };
93
117
  // A new default applies to an untouched entry at once; a typed amount keeps its denomination until reset.
94
118
  useEffect(() => { if (input === 0) {
95
119
  applyFromMode(defaultMode);
96
120
  applyToMode(defaultMode);
97
121
  } }, [defaultMode]);
98
- const reset = () => { setEntry('0'); applyFromMode(defaultMode); applyToMode(defaultMode); if (isReceiving)
122
+ const reset = () => { if (submitting)
123
+ return; exact.current = null; setEntry('0'); applyFromMode(defaultMode); applyToMode(defaultMode); if (isReceiving)
99
124
  setReceiving(false); if (!lockFrom)
100
125
  setFrom(null); if (!lockTo)
101
126
  setTo(null); onReset?.(); };
102
- const flip = () => { if (!from || !to)
127
+ const flip = () => { if (submitting || !from || !to)
103
128
  return; setFrom(to); setTo(from); };
104
129
  const submit = () => { if (submitting)
105
130
  return; if (showReceive) {
@@ -107,12 +132,19 @@ export function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains,
107
132
  return;
108
133
  } if (ready)
109
134
  onSubmit(fixed ? 'send' : action); };
110
- const copyAddress = () => { if (!receive?.onCopy)
111
- return; Promise.resolve().then(receive.onCopy).then(() => { 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(() => setCopied('')); };
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]);
112
142
  useEffect(() => {
113
- if (!shortcuts && !captureKeyboard)
143
+ if (!active || (!shortcuts && !captureKeyboard))
114
144
  return;
115
145
  const onKeyDown = (event) => {
146
+ if (submitting || event.defaultPrevented || !ownsKeyboard(root.current))
147
+ return;
116
148
  const key = event.key.toLowerCase();
117
149
  if (shortcuts && (event.metaKey || event.ctrlKey) && !event.altKey && !event.shiftKey && (key === 'f' || key === 'k')) {
118
150
  const side = key === 'f' ? 'from' : 'to';
@@ -130,12 +162,12 @@ export function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains,
130
162
  press(pressed);
131
163
  }
132
164
  };
133
- const onPaste = (event) => { if (captureKeyboard && !event.defaultPrevented && !textTarget(event.target) && paste(event.clipboardData?.getData('text') ?? ''))
165
+ const onPaste = (event) => { if (!submitting && ownsKeyboard(root.current) && captureKeyboard && !event.defaultPrevented && !textTarget(event.target) && paste(event.clipboardData?.getData('text') ?? ''))
134
166
  event.preventDefault(); };
135
167
  window.addEventListener('keydown', onKeyDown);
136
168
  document.addEventListener('paste', onPaste);
137
169
  return () => { window.removeEventListener('keydown', onKeyDown); document.removeEventListener('paste', onPaste); };
138
- }, [shortcuts, captureKeyboard, lockFrom, lockTo, fixed]);
170
+ });
139
171
  // Keys typed while focus is inside the cards drive the amount; in a pushed view Escape pops it.
140
172
  const inPanel = (event) => view === 'main' && !textTarget(event.target);
141
173
  const onKeyDown = (event) => { if (view !== 'main' && event.key === 'Escape') {
@@ -155,24 +187,27 @@ export function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains,
155
187
  const feeLine = quoteLoading || fee == null ? (messages.swapFee ?? en.swapFee)(quoteLoading ? '…' : '—') : _jsx(SwapNumber, { template: messages.swapFee ?? en.swapFee, ...usdNumber(fee) });
156
188
  const fraction = entry.includes('.') ? Math.min(entry.length - entry.indexOf('.') - 1, fromMode === 'usd' ? 2 : 8) : 0;
157
189
  // An account (a token with a `caption`) reads name over caption beside one disc, and offers Max only.
158
- 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, { onClick: () => setEntry(unitsToEntry(token.balance ?? 0, fromMode, fromPrice)), children: (messages.swapMax ?? en.swapMax) }) })] });
159
- 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, { onClick: () => setEntry(unitsToEntry(testAmount(token), fromMode, fromPrice)), children: [_jsx(SwapIcon, { name: 'flask', size: 14 }), (messages.swapTest ?? en.swapTest)] }), _jsx(SwapPill, { onClick: () => setEntry(unitsToEntry(token.balance ?? 0, fromMode, fromPrice)), children: (messages.swapMax ?? en.swapMax) })] }), _jsx(SwapNumber, { value: token.balance, suffix: ' ' + token.symbol, options: { maximumFractionDigits: 6 } })] })
160
- : _jsxs("span", { className: 'hig-swap-meta', children: [_jsxs(SwapPill, { 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 })] })] });
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 })] })] });
161
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 }); };
162
194
  const card = (side) => {
163
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;
164
196
  const cardUnits = side === 'from' ? units : receivedUnits, cardUsd = side === 'from' ? usd : receivedUsd;
165
197
  const shown = side === 'from' ? input : mode === 'token' ? receivedUnits : receivedUsd;
166
- 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', 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) :
167
- !(side === 'to' && showReceive) && _jsxs("div", { className: 'hig-swap-amount-area', children: [!locked && _jsx("button", { type: 'button', 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, label: side === 'to' ? (messages.swapAmount ?? en.swapAmount)(label) : undefined, prefix: mode === 'usd' ? '$' : '', suffix: side === 'from' && entry.endsWith('.') ? '.' : '', options: { minimumFractionDigits: side === 'from' ? fraction : 0, maximumFractionDigits: mode === 'usd' ? 2 : 8, useGrouping: false } }) }), denominationSwitch && _jsxs(SwapPill, { "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 })] })] })] })] });
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 })] })] })] })] });
168
200
  };
169
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.
170
- 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', 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)) })] });
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)) })] });
171
203
  const fromCard = card('from'), toCard = fixedCard || card('to');
172
- const body = view === 'main' ? _jsxs(_Fragment, { children: [title && _jsxs("div", { className: 'hig-swap-view-header', "data-plain": onBack ? undefined : 'true', children: [onBack && _jsxs("button", { type: 'button', className: 'hig-swap-back', "aria-label": messages.back ?? en.back, onClick: onBack, children: [_jsx(SwapIcon, { name: 'back' }), _jsx(PressDecoration, { kind: 'back' })] }), _jsx("h2", { className: 'hig-swap-view-title', children: title })] }), 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: !from || !to, onClick: flip, children: [_jsx(SwapIcon, { name: 'flip', size: 16 }), _jsx(PressDecoration, { kind: 'icon-button', disabled: !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, { 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: onConnect, onDisconnect: onDisconnect, receiving: isReceiving, onReceivingChange: receive ? setReceiving : undefined })
173
- : 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 })
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 })
174
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 });
175
- return _jsxs("section", { ref: root, className: `hig-swap-panel${className ? ` ${className}` : ''}`, style: style, "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 })] });
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 })] });
176
211
  }
177
212
  /** @deprecated Renamed `SwapPanelBlock`. The old name and the `blocks/swap-panel` and `recipes/swap-panel` import paths keep working until the next major release. */
178
213
  export const SwapPanel = SwapPanelBlock;
@@ -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,6 +36,10 @@ 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
+ /** 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;
39
43
  /** A line under the actions, for example why some are missing. `noteTone` tints it as in `SwapPanelBlock`. */
40
44
  note?: React.ReactNode;
41
45
  noteTone?: 'muted' | 'warning' | 'negative';
@@ -43,4 +47,4 @@ export interface TokenActionBlockProps extends Omit<React.HTMLAttributes<HTMLEle
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,11 @@ 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
19
  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 })] });
20
+ return _jsxs("section", { ...rest, className: `hig-token-card${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: symbol, onBack: onBack, action: headerAction, headingId: headingId, stickyHeader: stickyHeader }), (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
21
  }
@@ -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
  }
@@ -9,6 +9,7 @@ export { TokenActionBlock, tokenActionLabel, type TokenActionBlockProps, type To
9
9
  export { ManagePositionBlock, positionCorridor, type ManagePositionBlockProps, type ManagePositionBlockLabels, type ManagePositionBlockAction, type ManagePositionBlockSummary, type ManagePositionBlockFigure, type ManagePositionIcon } from './blocks/manage-position-block.js';
10
10
  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
11
  export { PositionBlock, type PositionBlockProps, type PositionBlockDetail, type PositionBlockFigure, type PositionBlockRow, type PositionBlockFlag, type PositionBlockFlagAction } from './blocks/position-block.js';
12
+ export { AssetsBlock, filterAssets, type AssetsBlockProps, type AssetItem, type AssetCategory, type AssetSignal, type AssetsView, type AssetsEmptyAction } from './blocks/assets-block.js';
12
13
  export { ProfileBlock, type ProfileBlockProps, type ProfileSection, type ProfileRow, type ProfileStatus, type ProfileAction, type ProfileFigure } from './blocks/profile-block.js';
13
14
  export { RewardBlock, rewardProgress, type RewardBlockProps, type RewardPromo, type RewardEntry } from './blocks/reward-block.js';
14
15
  export { SoundHapticsBlock, soundLevel, type SoundHapticsBlockProps, type SoundSection, type SoundVolume, type SettingAction } from './blocks/sound-haptics-block.js';
@@ -16,5 +17,8 @@ export { SignalsBlock, type SignalsBlockProps, type SignalsGroup, type SignalsIt
16
17
  export { NotificationsBlock, type NotificationsBlockProps, type NotificationsItem } from './blocks/notifications-block.js';
17
18
  export { TradeHistoryListBlock, tradeHistorySide, type TradeHistoryListBlockProps, type TradeHistoryListLabels, type TradeHistoryItem } from './blocks/trade-history-list-block.js';
18
19
  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 { FromPickerBlock, ToPickerBlock, FromPicker, ToPicker, type FromPickerBlockProps, type ToPickerBlockProps, type FromPickerProps, type ToPickerProps, type PickerListProps, type PickerInputProps, type PickerRowProps } from './blocks/pickers.js';
20
21
  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 { ConfirmBlock, type ConfirmBlockProps, type ConfirmDetail, type ConfirmTertiaryAction } from './blocks/confirm-block.js';
23
+ export { PresetPickerBlock, type PresetPickerBlockProps, type PresetPickerCustom } from './blocks/preset-picker-block.js';
24
+ export { ExplainerBlock, type ExplainerBlockProps, type ExplainerSection, type ExplainerAction, type ExplainerTone } from './blocks/explainer-block.js';
@@ -10,6 +10,7 @@ export { TokenActionBlock, tokenActionLabel } from './blocks/token-action-block.
10
10
  export { ManagePositionBlock, positionCorridor } from './blocks/manage-position-block.js';
11
11
  export { TargetBlock, targetLayout, targetFormat, targetPresets, targetUnits } from './blocks/target-block.js';
12
12
  export { PositionBlock } from './blocks/position-block.js';
13
+ export { AssetsBlock, filterAssets } from './blocks/assets-block.js';
13
14
  export { ProfileBlock } from './blocks/profile-block.js';
14
15
  export { RewardBlock, rewardProgress } from './blocks/reward-block.js';
15
16
  export { SoundHapticsBlock, soundLevel } from './blocks/sound-haptics-block.js';
@@ -19,3 +20,6 @@ export { TradeHistoryListBlock, tradeHistorySide } from './blocks/trade-history-
19
20
  export { TradeHistoryDetailBlock } from './blocks/trade-history-detail-block.js';
20
21
  export { FromPickerBlock, ToPickerBlock, FromPicker, ToPicker } from './blocks/pickers.js';
21
22
  export { SwapPanelBlock, SwapPanel, swapAction } from './blocks/swap-panel-block.js';
23
+ export { ConfirmBlock } from './blocks/confirm-block.js';
24
+ export { PresetPickerBlock } from './blocks/preset-picker-block.js';
25
+ 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>>;