@bloxwap/hig 0.6.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 (286) 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 +45 -2
  31. package/contracts/dist/index.js +145 -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 +62 -2
  35. package/contracts/dist/messages.js +22 -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 +62 -7
  47. package/native/dist/account-block.js +54 -11
  48. package/native/dist/animated-number-model.d.ts +47 -1
  49. package/native/dist/animated-number-model.js +248 -21
  50. package/native/dist/animated-number.d.ts +41 -1
  51. package/native/dist/animated-number.js +165 -17
  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 +19 -1
  55. package/native/dist/asset-balance-row.js +24 -8
  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 +16 -2
  65. package/native/dist/bar-mark.js +23 -7
  66. package/native/dist/bar-pnl.js +7 -5
  67. package/native/dist/blocks.d.ts +13 -14
  68. package/native/dist/blocks.js +10 -6
  69. package/native/dist/brand.js +2 -1
  70. package/native/dist/button.d.ts +7 -2
  71. package/native/dist/button.js +16 -4
  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.d.ts +1 -1
  78. package/native/dist/data.js +8 -4
  79. package/native/dist/explainer-block.d.ts +91 -0
  80. package/native/dist/explainer-block.js +34 -0
  81. package/native/dist/field.d.ts +19 -5
  82. package/native/dist/field.js +56 -9
  83. package/native/dist/figure.d.ts +23 -0
  84. package/native/dist/figure.js +10 -0
  85. package/native/dist/gesture-sheet-model.d.ts +50 -0
  86. package/native/dist/gesture-sheet-model.js +105 -0
  87. package/native/dist/gesture-sheet-next.d.ts +82 -0
  88. package/native/dist/gesture-sheet-next.js +315 -0
  89. package/native/dist/gesture-sheet.d.ts +5 -1
  90. package/native/dist/gesture-sheet.js +13 -6
  91. package/native/dist/icons.d.ts +9 -6
  92. package/native/dist/icons.js +25 -24
  93. package/native/dist/language-block.d.ts +14 -1
  94. package/native/dist/language-block.js +11 -4
  95. package/native/dist/list-group.d.ts +44 -8
  96. package/native/dist/list-group.js +84 -13
  97. package/native/dist/manage-position-block.d.ts +35 -2
  98. package/native/dist/manage-position-block.js +41 -11
  99. package/native/dist/market-row.d.ts +46 -0
  100. package/native/dist/market-row.js +41 -0
  101. package/native/dist/navigation.js +5 -3
  102. package/native/dist/notifications-block.d.ts +30 -2
  103. package/native/dist/notifications-block.js +16 -8
  104. package/native/dist/number-format.d.ts +6 -0
  105. package/native/dist/number-format.js +9 -0
  106. package/native/dist/pickers.d.ts +32 -2
  107. package/native/dist/pickers.js +17 -9
  108. package/native/dist/position-block.d.ts +66 -10
  109. package/native/dist/position-block.js +45 -11
  110. package/native/dist/preset-group.d.ts +31 -0
  111. package/native/dist/preset-group.js +39 -0
  112. package/native/dist/preset-picker-block.d.ts +107 -0
  113. package/native/dist/preset-picker-block.js +43 -0
  114. package/native/dist/profile-block.d.ts +38 -5
  115. package/native/dist/profile-block.js +31 -6
  116. package/native/dist/provider.d.ts +14 -5
  117. package/native/dist/provider.js +32 -6
  118. package/native/dist/qr-code.d.ts +33 -0
  119. package/native/dist/qr-code.js +29 -0
  120. package/native/dist/radio-group.d.ts +23 -5
  121. package/native/dist/radio-group.js +40 -12
  122. package/native/dist/recipes.d.ts +6 -0
  123. package/native/dist/recipes.js +6 -0
  124. package/native/dist/reward-block.d.ts +55 -13
  125. package/native/dist/reward-block.js +37 -14
  126. package/native/dist/screen-header.d.ts +59 -0
  127. package/native/dist/screen-header.js +37 -0
  128. package/native/dist/select.js +4 -2
  129. package/native/dist/selection.d.ts +3 -2
  130. package/native/dist/selection.js +1 -0
  131. package/native/dist/setting-header.d.ts +2 -8
  132. package/native/dist/setting-header.js +2 -11
  133. package/native/dist/setting-switch.d.ts +15 -2
  134. package/native/dist/setting-switch.js +11 -4
  135. package/native/dist/signals-block.d.ts +26 -2
  136. package/native/dist/signals-block.js +14 -4
  137. package/native/dist/slider.js +5 -1
  138. package/native/dist/sound-haptics-block.d.ts +29 -2
  139. package/native/dist/sound-haptics-block.js +19 -8
  140. package/native/dist/status.d.ts +47 -14
  141. package/native/dist/status.js +39 -22
  142. package/native/dist/sticky-header.d.ts +28 -0
  143. package/native/dist/sticky-header.js +29 -0
  144. package/native/dist/surface.d.ts +3 -1
  145. package/native/dist/surface.js +2 -1
  146. package/native/dist/swap-amount-card.d.ts +57 -0
  147. package/native/dist/swap-amount-card.js +31 -0
  148. package/native/dist/swap-panel-block.d.ts +11 -4
  149. package/native/dist/swap-panel-block.js +67 -38
  150. package/native/dist/swap-parts.d.ts +5 -10
  151. package/native/dist/swap-parts.js +22 -24
  152. package/native/dist/swap-shared.d.ts +8 -2
  153. package/native/dist/swap-shared.js +10 -6
  154. package/native/dist/swap-views.js +6 -4
  155. package/native/dist/switch-row.d.ts +3 -2
  156. package/native/dist/switch-row.js +5 -3
  157. package/native/dist/switch.d.ts +4 -2
  158. package/native/dist/switch.js +3 -3
  159. package/native/dist/target-block.d.ts +40 -7
  160. package/native/dist/target-block.js +31 -11
  161. package/native/dist/toast.d.ts +47 -0
  162. package/native/dist/toast.js +386 -0
  163. package/native/dist/token-action-block.d.ts +26 -9
  164. package/native/dist/token-action-block.js +21 -8
  165. package/native/dist/trade-history-detail-block.d.ts +26 -1
  166. package/native/dist/trade-history-detail-block.js +17 -9
  167. package/native/dist/trade-history-list-block.d.ts +71 -5
  168. package/native/dist/trade-history-list-block.js +55 -17
  169. package/native/dist/wallet-address-core.d.ts +25 -0
  170. package/native/dist/wallet-address-core.js +34 -0
  171. package/native/dist/wallet-address.d.ts +6 -10
  172. package/native/dist/wallet-address.js +16 -20
  173. package/native-fonts/README.md +1 -1
  174. package/og-fonts/README.md +1 -1
  175. package/package.json +131 -2
  176. package/react/README.md +3 -1
  177. package/react/dist/animated-number-flow.d.ts +72 -0
  178. package/react/dist/animated-number-flow.js +316 -0
  179. package/react/dist/animated-number-model.d.ts +24 -0
  180. package/react/dist/animated-number-model.js +106 -3
  181. package/react/dist/animated-number.d.ts +49 -1
  182. package/react/dist/animated-number.js +146 -11
  183. package/react/dist/asset-balance-row.d.ts +19 -1
  184. package/react/dist/asset-balance-row.js +17 -3
  185. package/react/dist/async-result.d.ts +2 -0
  186. package/react/dist/async-result.js +11 -0
  187. package/react/dist/avatar.d.ts +25 -0
  188. package/react/dist/avatar.js +50 -0
  189. package/react/dist/bar-mark.d.ts +5 -2
  190. package/react/dist/bar-mark.js +5 -3
  191. package/react/dist/blocks/account-block.d.ts +57 -7
  192. package/react/dist/blocks/account-block.js +51 -11
  193. package/react/dist/blocks/assets-block.d.ts +106 -0
  194. package/react/dist/blocks/assets-block.js +135 -0
  195. package/react/dist/blocks/confirm-block.d.ts +91 -0
  196. package/react/dist/blocks/confirm-block.js +31 -0
  197. package/react/dist/blocks/explainer-block.d.ts +80 -0
  198. package/react/dist/blocks/explainer-block.js +20 -0
  199. package/react/dist/blocks/install-command.js +3 -1
  200. package/react/dist/blocks/language-block.d.ts +9 -1
  201. package/react/dist/blocks/language-block.js +8 -6
  202. package/react/dist/blocks/manage-position-block.d.ts +30 -2
  203. package/react/dist/blocks/manage-position-block.js +23 -4
  204. package/react/dist/blocks/market-row.d.ts +20 -9
  205. package/react/dist/blocks/market-row.js +17 -4
  206. package/react/dist/blocks/notifications-block.d.ts +27 -2
  207. package/react/dist/blocks/notifications-block.js +11 -2
  208. package/react/dist/blocks/pickers.d.ts +30 -1
  209. package/react/dist/blocks/pickers.js +32 -10
  210. package/react/dist/blocks/position-block.d.ts +34 -11
  211. package/react/dist/blocks/position-block.js +16 -5
  212. package/react/dist/blocks/preset-picker-block.d.ts +85 -0
  213. package/react/dist/blocks/preset-picker-block.js +19 -0
  214. package/react/dist/blocks/profile-block.d.ts +33 -6
  215. package/react/dist/blocks/profile-block.js +31 -6
  216. package/react/dist/blocks/reward-block.d.ts +65 -21
  217. package/react/dist/blocks/reward-block.js +24 -11
  218. package/react/dist/blocks/screen-header.d.ts +34 -2
  219. package/react/dist/blocks/screen-header.js +17 -6
  220. package/react/dist/blocks/setting-switch.d.ts +14 -1
  221. package/react/dist/blocks/setting-switch.js +11 -4
  222. package/react/dist/blocks/signals-block.d.ts +23 -2
  223. package/react/dist/blocks/signals-block.js +6 -5
  224. package/react/dist/blocks/sound-haptics-block.d.ts +27 -3
  225. package/react/dist/blocks/sound-haptics-block.js +11 -7
  226. package/react/dist/blocks/sticky-header.d.ts +19 -0
  227. package/react/dist/blocks/sticky-header.js +103 -0
  228. package/react/dist/blocks/swap/amount-card.js +2 -1
  229. package/react/dist/blocks/swap/settings.js +4 -3
  230. package/react/dist/blocks/swap/shared.d.ts +29 -23
  231. package/react/dist/blocks/swap/shared.js +36 -32
  232. package/react/dist/blocks/swap-panel-block.d.ts +12 -3
  233. package/react/dist/blocks/swap-panel-block.js +72 -37
  234. package/react/dist/blocks/target-block.d.ts +35 -7
  235. package/react/dist/blocks/target-block.js +26 -12
  236. package/react/dist/blocks/token-action-block.d.ts +21 -8
  237. package/react/dist/blocks/token-action-block.js +9 -6
  238. package/react/dist/blocks/trade-history-detail-block.d.ts +23 -1
  239. package/react/dist/blocks/trade-history-detail-block.js +5 -4
  240. package/react/dist/blocks/trade-history-list-block.d.ts +31 -5
  241. package/react/dist/blocks/trade-history-list-block.js +20 -10
  242. package/react/dist/blocks.d.ts +12 -8
  243. package/react/dist/blocks.js +6 -2
  244. package/react/dist/brand.js +2 -1
  245. package/react/dist/button.d.ts +9 -3
  246. package/react/dist/button.js +12 -5
  247. package/react/dist/confetti.d.ts +27 -0
  248. package/react/dist/confetti.js +240 -0
  249. package/react/dist/data.js +11 -4
  250. package/react/dist/field.d.ts +20 -5
  251. package/react/dist/field.js +30 -8
  252. package/react/dist/figure.d.ts +23 -0
  253. package/react/dist/figure.js +12 -0
  254. package/react/dist/gesture-sheet.d.ts +15 -1
  255. package/react/dist/gesture-sheet.js +53 -8
  256. package/react/dist/list-group.d.ts +41 -8
  257. package/react/dist/list-group.js +49 -13
  258. package/react/dist/navigation.js +11 -3
  259. package/react/dist/overlay.d.ts +28 -3
  260. package/react/dist/overlay.js +29 -3
  261. package/react/dist/preset-group.d.ts +30 -0
  262. package/react/dist/preset-group.js +13 -0
  263. package/react/dist/provider.d.ts +42 -5
  264. package/react/dist/provider.js +84 -10
  265. package/react/dist/qr-code.d.ts +32 -0
  266. package/react/dist/qr-code.js +28 -0
  267. package/react/dist/select.js +10 -3
  268. package/react/dist/selection.d.ts +18 -4
  269. package/react/dist/selection.js +20 -10
  270. package/react/dist/slider.js +5 -1
  271. package/react/dist/status.d.ts +14 -10
  272. package/react/dist/status.js +17 -9
  273. package/react/dist/styles.css +380 -150
  274. package/react/dist/surface.d.ts +5 -1
  275. package/react/dist/surface.js +1 -1
  276. package/react/dist/toast.d.ts +19 -12
  277. package/react/dist/toast.js +29 -7
  278. package/react/dist/wallet-address-core.d.ts +27 -0
  279. package/react/dist/wallet-address-core.js +29 -0
  280. package/react/dist/wallet-address.d.ts +6 -12
  281. package/react/dist/wallet-address.js +5 -16
  282. package/tokens/README.md +2 -2
  283. package/tokens/dist/index.d.ts +16 -0
  284. package/tokens/dist/index.js +16 -0
  285. package/tokens/dist/manifest.json +8 -0
  286. package/tokens/dist/tokens.css +6 -0
@@ -20,6 +20,8 @@ export interface TradeHistoryDetail {
20
20
  options?: Intl.NumberFormatOptions;
21
21
  prefix?: string;
22
22
  suffix?: string;
23
+ /** With a number `value`: host-formatted text drawn and read in place of Intl's, still moving place by place. */
24
+ formattedValue?: string;
23
25
  }
24
26
  export interface TradeHistoryAction {
25
27
  id: string;
@@ -34,13 +36,21 @@ export interface TradeHistoryDetailBlockProps extends Omit<React.HTMLAttributes<
34
36
  /** Asset name: Amazon. */
35
37
  name: string;
36
38
  icon?: AssetArtwork;
39
+ /** Short ticker for the fallback disc when there is no `icon`: BTC. Without it the disc shows the first letters of the name. */
40
+ symbol?: string;
37
41
  side: 'long' | 'short';
38
42
  /** 20 reads `20×`. */
39
43
  leverage?: number;
44
+ /** A short muted qualifier after the leverage, read with it: current. */
45
+ leverageNote?: string;
40
46
  /** Net profit and loss in dollars. `null` reads as unknown. */
41
47
  pnl: number | null;
48
+ /** Format of the headline result. Defaults to signed US dollars with up to four decimals. The provider's `numberFormat` is merged under it. */
49
+ pnlOptions?: Intl.NumberFormatOptions;
42
50
  /** Return on margin as a fraction: 0.0284 reads +2.84%. */
43
51
  pnlPercent?: number | null;
52
+ /** Format of the return on margin. Defaults to a signed percent with two decimals. */
53
+ percentOptions?: Intl.NumberFormatOptions;
44
54
  /** Entry and exit prices. With both, one bar runs from entry to exit in the result colour, with the two prices under it, in place of two rows. */
45
55
  entry?: number;
46
56
  exit?: number;
@@ -48,11 +58,23 @@ export interface TradeHistoryDetailBlockProps extends Omit<React.HTMLAttributes<
48
58
  priceOptions?: Intl.NumberFormatOptions;
49
59
  /** The trade's other figures in the order shown: size, notional, time held, fees, funding. They are drawn as a grid of small labels over values. */
50
60
  details: readonly TradeHistoryDetail[];
61
+ /** One muted sentence under the details, such as that part of the record is missing. */
62
+ note?: string;
63
+ /** Short host text in a badge beside the title: Demo. */
64
+ badge?: string;
51
65
  /** Actions in one row under the details, such as Save image and Share. */
52
66
  actions?: readonly TradeHistoryAction[];
53
67
  onBack?: () => void;
54
68
  /** A control on the trailing edge of the header, usually an `IconButton`. */
55
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;
72
+ /** Ref to the summary (the asset line, the headline figure and the return), for a host that captures it as an image. */
73
+ summaryRef?: React.Ref<HTMLDivElement>;
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
+ summaryBackground?: boolean | string;
76
+ /** Pins the header to the top of the nearest scrolling container, transparent at rest and filled with `--hig-sticky-header-background` once content scrolls under it. */
77
+ stickyHeader?: boolean;
56
78
  }
57
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. */
58
- export declare function TradeHistoryDetailBlock({ labels, name, icon, side, leverage, pnl, pnlPercent, entry, exit, priceOptions, details, actions, onBack, headerAction, 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;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { formatNumber } from '@bloxwap/hig/contracts';
4
- import { useHIG } from '../provider.js';
4
+ import { useNumberLocale } from '../provider.js';
5
5
  import { Button } from '../button.js';
6
6
  import { AnimatedNumberReadout } from '../animated-number.js';
7
7
  import { BarPnl } from '../bar-pnl.js';
@@ -9,8 +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, side, leverage, pnl, pnlPercent, entry, exit, priceOptions, details, actions = [], onBack, headerAction, className, ...rest }) {
13
- const { locale } = useHIG();
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
+ const locale = useNumberLocale();
14
14
  const tone = pnl == null || pnl === 0 ? undefined : pnl > 0 ? 'up' : 'down';
15
- return _jsxs("section", { ...rest, className: `hig-trade-detail${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: labels.title, onBack: onBack, action: headerAction }), _jsxs("div", { className: 'hig-trade-summary', children: [_jsxs("div", { className: 'hig-trade-result', "data-tone": tone, 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 ?? 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"] })] })] }), _jsxs("strong", { className: 'hig-trade-figure', children: [_jsxs("span", { className: 'hig-trade-caption hig-sr-only', children: [labels.netPnl, " "] }), _jsx(AnimatedNumberReadout, { value: pnl, options: pnlFormat })] }), pnlPercent !== undefined && _jsx("span", { className: 'hig-trade-return', children: pnlPercent === null ? labels.onMargin('—') : _jsx(SwapNumber, { template: labels.onMargin, value: pnlPercent, options: percentFormat }) })] }), 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 }) : row.value })] }, row.label)) })] }), 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)) })] });
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, 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)) })] });
16
17
  }
@@ -8,21 +8,31 @@ export interface TradeHistoryListLabels {
8
8
  short: string;
9
9
  /** Shown in place of the rows when there are no trades. */
10
10
  empty: string;
11
+ /** A second line under `empty`, in the muted colour: Closed trades appear here. */
12
+ emptyDescription?: string;
11
13
  }
12
14
  /** One closed trade. */
13
15
  export interface TradeHistoryItem {
14
16
  id: string;
15
17
  /** Asset name: Amazon. */
16
18
  name: string;
17
- /** Round artwork: an image URL or a host element. Without it the row shows the first letters of the name. */
19
+ /** Short ticker for the fallback disc when there is no `icon`: BTC. Without it the disc shows the first letters of the name. */
20
+ symbol?: string;
21
+ /** Round artwork: an image URL or a host element. Without it the row shows `symbol` or the first letters of the name. */
18
22
  icon?: AssetArtwork;
19
23
  side: 'long' | 'short';
20
24
  /** 20 reads `20×`. */
21
25
  leverage?: number;
26
+ /** A short muted qualifier after the leverage, read with it: current. Use it when the leverage was not recorded with the trade. */
27
+ leverageNote?: string;
22
28
  /** Net profit and loss in dollars. `null` reads as unknown. */
23
29
  pnl: number | null;
24
30
  /** Host-formatted age or time of the close, shown under the result: `2d`. */
25
31
  time?: string;
32
+ /** Small muted host text before the age, such as the wallet the trade came from: `0x22…22`. */
33
+ tag?: string;
34
+ /** Format of this trade's result, in place of the block's `pnlOptions`, for a host whose decimal ladder depends on the amount. */
35
+ pnlOptions?: Intl.NumberFormatOptions;
26
36
  }
27
37
  export interface TradeHistoryListBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title' | 'onSelect'> {
28
38
  labels: TradeHistoryListLabels;
@@ -34,10 +44,26 @@ export interface TradeHistoryListBlockProps extends Omit<React.HTMLAttributes<HT
34
44
  onBack?: () => void;
35
45
  /** A control on the trailing edge of the header, usually an `IconButton`. */
36
46
  headerAction?: React.ReactNode;
37
- /** Format of the result. Defaults to signed US dollars at four significant digits: `+$1.412`, `+$17.90`, `-$0.6878`. */
47
+ /** `id` of the header's heading, so a host dialog or sheet can name itself with `aria-labelledby`. */
48
+ headingId?: string;
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. */
38
50
  pnlOptions?: Intl.NumberFormatOptions;
51
+ /** Draws rows of skeletons in place of the trades while the host loads them. */
52
+ loading?: boolean;
53
+ /** Host text that names the skeleton rows for assistive technology and announces them: Loading history. Without it they are only marked busy. */
54
+ loadingLabel?: string;
55
+ /** Why the trades could not load, in place of the rows, in the negative colour and announced. */
56
+ error?: string;
57
+ /** Host content under the header, above the rows: a partial-history notice or a mode banner. */
58
+ notice?: React.ReactNode;
59
+ /** Host content under the rows: paging, a spinner for the next page, a note. */
60
+ footer?: React.ReactNode;
61
+ /** Pins the header to the top of the nearest scrolling container, transparent at rest and filled with `--hig-sticky-header-background` once the rows scroll under it. */
62
+ stickyHeader?: boolean;
39
63
  }
40
64
  /** How a row reads its side: `Short 20×`, or `Short` without leverage. */
41
- export declare const tradeHistorySide: (trade: Pick<TradeHistoryItem, 'side' | 'leverage'>, labels: Pick<TradeHistoryListLabels, 'long' | 'short'>, locale?: string) => string;
42
- /** A history of closed trades as one screen: a header, then one row per trade with the asset, its side and leverage in the direction colour, and the net result in the result colour over its age. */
43
- export declare function TradeHistoryListBlock({ labels, trades, onSelect, onBack, headerAction, pnlOptions, className, ...rest }: TradeHistoryListBlockProps): React.JSX.Element;
65
+ export declare const tradeHistorySide: (trade: Pick<TradeHistoryItem, 'side' | 'leverage'> & {
66
+ leverageNote?: string;
67
+ }, labels: Pick<TradeHistoryListLabels, 'long' | 'short'>, locale?: string) => string;
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. */
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,21 +1,31 @@
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
- import { useHIG } from '../provider.js';
7
+ import { PressDecoration, usePresentNumber, useNumberLocale } from '../provider.js';
5
8
  import { AnimatedNumberReadout } from '../animated-number.js';
6
9
  import { ScreenHeader } from './screen-header.js';
7
10
  const pnlFormat = { style: 'currency', currency: 'USD', signDisplay: 'exceptZero', minimumSignificantDigits: 4, maximumSignificantDigits: 4 };
11
+ const skeletons = [0, 1, 2, 3];
8
12
  /** How a row reads its side: `Short 20×`, or `Short` without leverage. */
9
- export const tradeHistorySide = (trade, labels, locale) => `${trade.side === 'long' ? labels.long : labels.short}${trade.leverage != null ? ` ${formatNumber(trade.leverage, locale)}×` : ''}`;
10
- 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' }) });
11
- 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' }) });
12
- /** A history of closed trades as one screen: a header, then one row per trade with the asset, its side and leverage in the direction colour, and the net result in the result colour over its age. */
13
- export function TradeHistoryListBlock({ labels, trades, onSelect, onBack, headerAction, pnlOptions = pnlFormat, className, ...rest }) {
14
- const { locale } = useHIG();
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}` : ''}`;
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' });
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. */
17
+ export function TradeHistoryListBlock({ labels, trades, onSelect, onBack, headerAction, pnlOptions = pnlFormat, loading, loadingLabel, error, notice, footer, stickyHeader, headingId, className, ...rest }) {
18
+ const locale = useNumberLocale();
19
+ const present = usePresentNumber();
15
20
  const row = (trade) => {
21
+ const result = trade.pnlOptions ?? pnlOptions;
16
22
  const side = tradeHistorySide(trade, labels, locale), tone = trade.pnl == null || trade.pnl === 0 ? undefined : trade.pnl > 0 ? 'up' : 'down';
17
- const content = _jsxs(_Fragment, { children: [_jsx("span", { className: 'hig-asset-row-icon', "aria-hidden": 'true', children: typeof trade.icon === 'string' ? _jsx("img", { src: trade.icon, alt: '' }) : trade.icon ?? trade.name.slice(0, 3) }), _jsxs("span", { className: 'hig-trade-row-identity', children: [_jsx("strong", { children: trade.name }), _jsxs("span", { className: 'hig-trade-row-side', "data-side": trade.side, children: [arrow(trade.side), _jsxs("span", { className: 'hig-sr-only', children: [trade.side === 'long' ? labels.long : labels.short, " "] }), trade.leverage != null && `${formatNumber(trade.leverage, locale)}×`] })] }), _jsxs("span", { className: 'hig-trade-row-result', children: [_jsx("strong", { className: 'hig-trade-pnl', "data-tone": tone, children: _jsx(AnimatedNumberReadout, { value: trade.pnl, options: pnlOptions }) }), trade.time && _jsx("span", { children: trade.time })] }), onSelect && chevron] });
18
- return _jsx("li", { children: onSelect ? _jsx("button", { type: 'button', className: 'hig-trade-row', "aria-label": [trade.name, side, formatNumber(trade.pnl, locale, pnlOptions), trade.time].filter(Boolean).join(', '), onClick: () => onSelect(trade), children: content }) : _jsx("div", { className: 'hig-trade-row', children: content }) }, trade.id);
23
+ const content = _jsxs(_Fragment, { children: [_jsx("span", { className: 'hig-asset-row-icon', "aria-hidden": 'true', children: typeof trade.icon === 'string' ? _jsx("img", { src: trade.icon, alt: '' }) : trade.icon ?? trade.symbol ?? trade.name.slice(0, 3) }), _jsxs("span", { className: 'hig-trade-row-identity', children: [_jsx("strong", { children: trade.name }), _jsxs("span", { className: 'hig-trade-row-side', "data-side": trade.side, children: [arrow(trade.side), _jsxs("span", { className: 'hig-sr-only', children: [trade.side === 'long' ? labels.long : labels.short, " "] }), trade.leverage != null && `${formatNumber(trade.leverage, locale)}×`, trade.leverageNote && _jsx("span", { className: 'hig-trade-row-note', children: trade.leverageNote })] })] }), _jsxs("span", { className: 'hig-trade-row-result', children: [_jsx("strong", { className: 'hig-trade-pnl', "data-tone": tone, children: _jsx(AnimatedNumberReadout, { value: trade.pnl, options: result }) }), trade.tag ? _jsxs("span", { className: 'hig-trade-row-meta', children: [_jsx("span", { className: 'hig-trade-row-tag', children: trade.tag }), trade.time && _jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": 'true', children: "\u00B7" }), _jsx("span", { children: trade.time })] })] }) : trade.time && _jsx("span", { children: trade.time })] }), onSelect && chevron] });
24
+ return _jsx("li", { children: onSelect ? _jsxs("button", { type: 'button', className: 'hig-trade-row', "aria-label": [trade.name, side, formatNumber(trade.pnl, locale, present(result)), trade.tag, trade.time].filter(Boolean).join(', '), onClick: () => onSelect(trade), children: [content, _jsx(PressDecoration, { kind: 'row' })] }) : _jsx("div", { className: 'hig-trade-row', children: content }) }, trade.id);
19
25
  };
20
- return _jsxs("section", { ...rest, className: `hig-trade-history-list${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: labels.title, onBack: onBack, action: headerAction }), trades.length === 0 ? _jsx("p", { className: 'hig-swap-empty', role: 'status', children: labels.empty }) : _jsx("ul", { className: 'hig-trade-rows', "aria-label": labels.title, children: trades.map(row) })] });
26
+ const body = loading ? _jsxs(_Fragment, { children: [loadingLabel && _jsx("p", { className: 'hig-sr-only', role: 'status', children: loadingLabel }), _jsx("div", { className: 'hig-trade-rows', "aria-busy": 'true', children: skeletons.map(index => _jsx("div", { className: 'hig-skeleton hig-trade-skeleton', "aria-hidden": 'true' }, index)) })] })
27
+ : error ? _jsx("p", { className: 'hig-swap-empty hig-trade-error', role: 'alert', children: error })
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 })
29
+ : _jsx("ul", { className: 'hig-trade-rows', "aria-label": labels.title, children: trades.map(row) });
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 })] });
21
31
  }
@@ -1,20 +1,24 @@
1
1
  /** Aggregate entry. TradeEntry needs @radix-ui/react-dialog; import single blocks from `@bloxwap/hig/react/blocks/<name>` to avoid overlay peers. SwapSheet (Vaul) is only at `blocks/swap-sheet`. */
2
- export { MarketRow } from './blocks/market-row.js';
2
+ export { MarketRow, type MarketRowProps } from './blocks/market-row.js';
3
3
  export { TradeEntry } from './blocks/trade-entry.js';
4
4
  export { InstallCommand } from './blocks/install-command.js';
5
5
  export { MarketingHero } from './blocks/marketing-hero.js';
6
- export { AccountBlock, AssetBalanceRow, accountRows, assetValue, type AccountBlockProps, type AccountAsset, type AssetArtwork, type AssetBalanceRowProps } from './blocks/account-block.js';
6
+ export { AccountBlock, AssetBalanceRow, accountRows, accountSectionRows, accountSectionTotal, assetValue, type AccountBlockProps, type AccountAsset, type AccountSection, type AccountOrder, type AccountRowsOptions, type AssetArtwork, type AssetBalanceRowProps } from './blocks/account-block.js';
7
7
  export { LanguageBlock, filterLanguages, type LanguageBlockProps, type LanguageOption } from './blocks/language-block.js';
8
8
  export { TokenActionBlock, tokenActionLabel, type TokenActionBlockProps, type TokenAction, type TokenActionId } from './blocks/token-action-block.js';
9
- export { ManagePositionBlock, positionCorridor, type ManagePositionBlockProps, type ManagePositionBlockLabels, type ManagePositionBlockAction, type ManagePositionBlockSummary } from './blocks/manage-position-block.js';
10
- export { TargetBlock, targetLayout, targetFormat, type TargetBlockProps, type TargetBlockLabels, type TargetKind, type TargetUnit, type TargetPrice } from './blocks/target-block.js';
11
- export { PositionBlock, type PositionBlockProps, type PositionBlockDetail, type PositionBlockFigure, type PositionBlockRow, type PositionBlockFlag } from './blocks/position-block.js';
12
- export { ProfileBlock, type ProfileBlockProps, type ProfileSection, type ProfileRow, type ProfileStatus } from './blocks/profile-block.js';
9
+ export { ManagePositionBlock, positionCorridor, type ManagePositionBlockProps, type ManagePositionBlockLabels, type ManagePositionBlockAction, type ManagePositionBlockSummary, type ManagePositionBlockFigure, type ManagePositionIcon } from './blocks/manage-position-block.js';
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
+ 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';
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
- export { SoundHapticsBlock, soundLevel, type SoundHapticsBlockProps, type SoundSection, type SoundVolume } from './blocks/sound-haptics-block.js';
15
+ export { SoundHapticsBlock, soundLevel, type SoundHapticsBlockProps, type SoundSection, type SoundVolume, type SettingAction } from './blocks/sound-haptics-block.js';
15
16
  export { SignalsBlock, type SignalsBlockProps, type SignalsGroup, type SignalsItem } from './blocks/signals-block.js';
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 } 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';
@@ -4,12 +4,13 @@ export { MarketRow } from './blocks/market-row.js';
4
4
  export { TradeEntry } from './blocks/trade-entry.js';
5
5
  export { InstallCommand } from './blocks/install-command.js';
6
6
  export { MarketingHero } from './blocks/marketing-hero.js';
7
- export { AccountBlock, AssetBalanceRow, accountRows, assetValue } from './blocks/account-block.js';
7
+ export { AccountBlock, AssetBalanceRow, accountRows, accountSectionRows, accountSectionTotal, assetValue } from './blocks/account-block.js';
8
8
  export { LanguageBlock, filterLanguages } from './blocks/language-block.js';
9
9
  export { TokenActionBlock, tokenActionLabel } from './blocks/token-action-block.js';
10
10
  export { ManagePositionBlock, positionCorridor } from './blocks/manage-position-block.js';
11
- export { TargetBlock, targetLayout, targetFormat } from './blocks/target-block.js';
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>>;
@@ -3,18 +3,25 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { forwardRef, useId, useRef } from 'react';
4
4
  import * as en from '@bloxwap/hig/contracts/messages';
5
5
  import { useHIG } from './provider.js';
6
- export const Button = forwardRef(function Button({ intent = 'primary', busy = false, busyLabel, disabled, fullWidth, suppressFeedback, onClick, children, type = 'button', ...props }, ref) {
6
+ function useButton({ intent = 'primary', busy = false, busyLabel, disabled, fullWidth, suppressFeedback, onClick, children, type = 'button', href, glow, ...props }, ref, kind) {
7
+ // The provider puts its press layer on the context (see PressDecoration); calling it here keeps the layer out of a lone Button bundle.
7
8
  const context = useHIG();
8
9
  const id = useId();
9
10
  const sequence = useRef(0);
10
11
  const busyText = busyLabel ?? context.messages.busy ?? en.busy;
11
- return _jsxs("button", { ...props, ref: ref, type: type, className: `hig-button ${props.className ?? ''}`, "data-intent": intent, "data-full": fullWidth || undefined, "data-density": context.density, disabled: disabled || busy, "aria-busy": busy || undefined, onClick: e => { e.stopPropagation(); onClick?.(e); if (!e.defaultPrevented && !disabled && !busy && !suppressFeedback) {
12
+ const inert = !!disabled || busy;
13
+ const link = href !== undefined;
14
+ // One element either way. An inert link has no href, so it leaves the tab order like a disabled button, and keeps its link role for assistive technology.
15
+ const Root = (link ? 'a' : 'button');
16
+ return _jsxs(Root, { ...props, ...(link ? inert ? { role: 'link', 'aria-disabled': true } : { href } : { type, disabled: inert }), ref: ref, className: `hig-button ${props.className ?? ''}`, "data-intent": intent, "data-full": fullWidth || undefined, "data-density": context.density, "data-glow": glow || undefined, "aria-busy": busy || undefined, onClick: e => { if (inert)
17
+ return e.preventDefault(); e.stopPropagation(); onClick?.(e); if (!e.defaultPrevented && !suppressFeedback) {
12
18
  try {
13
19
  context.onAccepted?.(id);
14
20
  context.feedback?.emit({ id: `${id}/${++sequence.current}`, source: id, intent: 'activate', origin: e.detail === 0 ? 'keyboard' : 'pointer' });
15
21
  }
16
22
  catch { /* Optional feedback cannot alter the action. */ }
17
- } }, children: [busy && _jsx("span", { className: 'hig-button-spinner', "aria-hidden": 'true' }), children, busy && busyText ? _jsxs("span", { role: 'status', className: 'hig-busy hig-sr-only', children: [" \u00B7 ", busyText] }) : null] });
18
- });
19
- export const IconButton = forwardRef(function IconButton({ label, children, className, ...props }, ref) { return _jsx(Button, { ...props, ref: ref, className: `hig-icon-button ${className ?? ''}`, "aria-label": label, children: _jsx("span", { "aria-hidden": 'true', children: children }) }); });
23
+ } }, children: [busy && _jsx("span", { className: 'hig-button-spinner', "aria-hidden": 'true' }), children, busy && busyText ? _jsxs("span", { role: 'status', className: 'hig-busy hig-sr-only', children: [" \u00B7 ", busyText] }) : null, context.drawPress?.(kind, inert)] });
24
+ }
25
+ export const Button = forwardRef(function Button(props, ref) { return useButton(props, ref, 'button'); });
26
+ export const IconButton = forwardRef(function IconButton({ label, children, className, ...props }, ref) { return useButton({ ...props, className: `hig-icon-button ${className ?? ''}`, 'aria-label': label, children: _jsx("span", { "aria-hidden": 'true', children: children }) }, ref, 'icon-button'); });
20
27
  export const Link = forwardRef(function Link(props, ref) { return _jsx("a", { ...props, ref: ref, className: `hig-link ${props.className ?? ''}` }); });
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { type ConfettiOptions } from '@bloxwap/hig/contracts/confetti';
3
+ export { mirrorConfetti, type ConfettiOptions, type ConfettiShape } from '@bloxwap/hig/contracts/confetti';
4
+ export interface ConfettiFire {
5
+ /** Fires one burst and resolves when it has finished, or at once when nothing is drawn: under reduced motion (unless `disableForReducedMotion` is false), with no pieces, or on a server. Colours and reduced motion come from the most recently mounted `Confetti`, else from the document. */
6
+ (options?: ConfettiOptions): Promise<void>;
7
+ /** Stops every burst now, also one still waiting for its host, removes the canvas and resolves their promises. */
8
+ reset(): void;
9
+ }
10
+ /** Fires a burst of confetti over the viewport. Call it from an event handler or an effect; it needs no `Confetti` to be mounted on web. */
11
+ export declare const confetti: ConfettiFire;
12
+ export interface ConfettiProps {
13
+ /** Fires `options` whenever it is truthy: on mount, and each time it changes to another truthy value. A win count or an order id works. Leave it out to fire only through `confetti()`. */
14
+ trigger?: unknown;
15
+ /** The burst `trigger` fires, or several fired together. Read when `trigger` changes, so it need not be a stable object. */
16
+ options?: ConfettiOptions | readonly ConfettiOptions[];
17
+ }
18
+ /**
19
+ * The confetti host. Mount it once inside HIGProvider: bursts then follow the provider's `reducedMotion`, `primaryColor`
20
+ * and `marketColors`. It draws nothing itself and never renders again for a burst; on web the canvas is added to the
21
+ * document body while pieces fly. With `trigger` it also fires declaratively.
22
+ *
23
+ * HIGProvider reads the system's reduced motion setting in an effect, after the effects of what it holds. So where the
24
+ * system asks for reduced motion, a burst asked for while this host mounts (a truthy `trigger`, or `confetti()` in a mount
25
+ * effect) waits for the one render that follows, and is then drawn only if the provider itself says motion is wanted.
26
+ */
27
+ export declare function Confetti({ trigger, options }: ConfettiProps): React.JSX.Element;
@@ -0,0 +1,240 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useEffect, useRef, useState } from 'react';
4
+ import { nativeDisplayP3, nativeSrgb } from '@bloxwap/hig/tokens';
5
+ import { CONFETTI_FIRST_TICK, CONFETTI_TICKS_PER_SECOND, confettiBursts, confettiDefaults, confettiFlight, confettiOpacity, confettiSkipped, confettiStarPoints, confettiTravel, createConfettiBurst } from '@bloxwap/hig/contracts/confetti';
6
+ import { useHIG } from './provider.js';
7
+ export { mirrorConfetti } from '@bloxwap/hig/contracts/confetti';
8
+ const hosts = [];
9
+ let layer = null;
10
+ /** The token roles a burst is painted in when the call names no colours: CSS variable, the variable it defaults to, and the token role behind both. */
11
+ const roles = [['--hig-action', '', 'action'], ['--hig-info', '', 'info'], ['--hig-down', '--hig-sell', 'sell'], ['--hig-warning', '', 'warning'], ['--hig-up', '--hig-buy', 'buy']];
12
+ const systemReducedMotion = () => typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
13
+ const wideGamut = () => typeof CSS !== 'undefined' && typeof CSS.supports === 'function' && CSS.supports('color', 'color(display-p3 1 1 1)');
14
+ const displayP3 = (hex) => `color(display-p3 ${[1, 3, 5].map(at => Number((parseInt(hex.slice(at, at + 2), 16) / 255).toFixed(4))).join(' ')})`;
15
+ /**
16
+ * The default colours as the canvas can paint them. The `--hig-*` variables already hold `color(display-p3 …)` where the
17
+ * browser supports it, and a provider's `primaryColor` or `marketColors` where one is set. Without the tokens stylesheet
18
+ * the token tables stand in: Display P3 where the browser can parse it, sRGB elsewhere.
19
+ */
20
+ function themeColors(anchor) {
21
+ const style = getComputedStyle(anchor), wide = wideGamut();
22
+ return roles.map(([name, fallback, role]) => style.getPropertyValue(name).trim() || (fallback && style.getPropertyValue(fallback).trim()) || (wide ? displayP3(nativeDisplayP3[role]) : nativeSrgb[role]));
23
+ }
24
+ /** A Display P3 canvas on a screen that can show it, so the token colours keep their full strength; an sRGB canvas elsewhere. */
25
+ function paintContext(canvas) {
26
+ let context = null;
27
+ try {
28
+ if (typeof window.matchMedia === 'function' && window.matchMedia('(color-gamut: p3)').matches)
29
+ context = canvas.getContext('2d', { colorSpace: 'display-p3' });
30
+ }
31
+ catch { /* An engine that rejects the setting paints sRGB. */ }
32
+ try {
33
+ return context ?? canvas.getContext('2d');
34
+ }
35
+ catch {
36
+ return null;
37
+ }
38
+ }
39
+ function measure(current) {
40
+ const root = document.documentElement, width = root.clientWidth || window.innerWidth, height = root.clientHeight || window.innerHeight, ratio = window.devicePixelRatio || 1;
41
+ current.width = width;
42
+ current.height = height;
43
+ current.canvas.width = Math.round(width * ratio);
44
+ current.canvas.height = Math.round(height * ratio);
45
+ // Resizing the canvas resets its state, so the scale is set again: pieces are placed in CSS pixels and painted in device pixels.
46
+ current.context.setTransform(ratio, 0, 0, ratio, 0, 0);
47
+ current.stale = false;
48
+ }
49
+ const resized = () => { if (layer)
50
+ layer.stale = true; };
51
+ function open(zIndex) {
52
+ const canvas = document.createElement('canvas'), context = paintContext(canvas);
53
+ if (!context)
54
+ return null;
55
+ // Decoration: nothing for assistive technology to read.
56
+ canvas.ariaHidden = 'true';
57
+ canvas.dataset.higConfetti = '';
58
+ Object.assign(canvas.style, { position: 'fixed', top: '0', left: '0', width: '100%', height: '100%', pointerEvents: 'none', zIndex: String(zIndex) });
59
+ const current = { canvas, context, runs: [], frame: 0, width: 0, height: 0, stale: true };
60
+ (document.body ?? document.documentElement).appendChild(canvas);
61
+ window.addEventListener('resize', resized);
62
+ return current;
63
+ }
64
+ function close(current) {
65
+ if (layer === current)
66
+ layer = null;
67
+ if (current.frame)
68
+ cancelAnimationFrame(current.frame);
69
+ current.frame = 0;
70
+ window.removeEventListener('resize', resized);
71
+ current.canvas.remove();
72
+ }
73
+ const turn = Math.PI * 2, starPoints = confettiStarPoints;
74
+ const flight = { x: 0, y: 0, ux: 0, uy: 0, vx: 0, vy: 0, wobble: 0 };
75
+ /**
76
+ * One burst at tick `t`. Each piece is its own small convex path, filled on its own as canvas-confetti fills it, which is
77
+ * the cheap case for a canvas. What canvas-confetti repeats for every piece is done once here: the opacity is set once a
78
+ * burst and the fill colour once for each of its colours, with no colour string built or parsed per piece.
79
+ */
80
+ function draw(context, run, t, width, height) {
81
+ const { burst, groups } = run, { physics, origin, colors } = burst, travel = confettiTravel(physics, t), left = origin.x * width, top = origin.y * height, size = physics.size;
82
+ context.globalAlpha = confettiOpacity(physics, t);
83
+ for (let color = 0; color < groups.length; color++) {
84
+ const group = groups[color];
85
+ if (!group.length)
86
+ continue;
87
+ context.fillStyle = colors[color];
88
+ for (let index = 0; index < group.length; index++) {
89
+ const particle = group[index];
90
+ confettiFlight(particle, physics, t, travel, flight);
91
+ const x = left + flight.x, y = top + flight.y;
92
+ context.beginPath();
93
+ if (particle.shape === 'circle')
94
+ context.ellipse(x, y, Math.abs(flight.ux) * 0.6, Math.abs(flight.vy) * 0.6, Math.PI / 10 * flight.wobble, 0, turn);
95
+ else if (particle.shape === 'star') {
96
+ context.moveTo(x + starPoints[0][0] * size, y + starPoints[0][1] * size);
97
+ for (let point = 1; point < 10; point++)
98
+ context.lineTo(x + starPoints[point][0] * size, y + starPoints[point][1] * size);
99
+ }
100
+ else {
101
+ const { ux, uy, vx, vy } = flight;
102
+ context.moveTo(x, y);
103
+ context.lineTo(x + ux, y + uy);
104
+ context.lineTo(x + ux + vx, y + uy + vy);
105
+ context.lineTo(x + vx, y + vy);
106
+ }
107
+ context.closePath();
108
+ context.fill();
109
+ }
110
+ }
111
+ }
112
+ function frame(now) {
113
+ const current = layer;
114
+ if (!current)
115
+ return;
116
+ current.frame = 0;
117
+ if (current.stale)
118
+ measure(current);
119
+ const { context, width, height } = current;
120
+ context.clearRect(0, 0, width, height);
121
+ const runs = current.runs;
122
+ let kept = 0;
123
+ for (let index = 0; index < runs.length; index++) {
124
+ const run = runs[index];
125
+ // Time, not frames, moves a burst: it takes the same time at 60 Hz and 120 Hz, and a dropped frame costs nothing later.
126
+ if (run.start < 0)
127
+ run.start = now;
128
+ const t = CONFETTI_FIRST_TICK + (now - run.start) * CONFETTI_TICKS_PER_SECOND / 1000;
129
+ if (t >= run.burst.physics.ticks)
130
+ run.resolve();
131
+ else {
132
+ draw(context, run, t, width, height);
133
+ runs[kept++] = run;
134
+ }
135
+ }
136
+ runs.length = kept;
137
+ if (kept === 0) {
138
+ close(current);
139
+ return;
140
+ }
141
+ current.frame = requestAnimationFrame(frame);
142
+ }
143
+ function fire(options, host) {
144
+ if (typeof window === 'undefined' || typeof document === 'undefined')
145
+ return Promise.resolve();
146
+ // The host cannot answer for reduced motion yet: the burst waits for it, a moment at most.
147
+ if (host && !host.ready)
148
+ return new Promise(resolve => { if (host.waiting.length >= 8) {
149
+ resolve();
150
+ return;
151
+ } host.waiting.push({ options, resolve }); });
152
+ if (layer && layer.runs.length >= 8)
153
+ return Promise.resolve();
154
+ const reduced = host ? host.reducedMotion() : systemReducedMotion();
155
+ if (confettiSkipped(options, reduced))
156
+ return Promise.resolve();
157
+ const burst = createConfettiBurst(options, () => themeColors(host?.anchor() ?? document.documentElement));
158
+ if (burst.particles.length === 0)
159
+ return Promise.resolve();
160
+ const zIndex = options?.zIndex;
161
+ const current = layer ??= open(typeof zIndex === 'number' && Number.isFinite(zIndex) ? zIndex : confettiDefaults.zIndex);
162
+ // No 2D canvas here: there is nothing to draw on, so the burst is over.
163
+ if (!current)
164
+ return Promise.resolve();
165
+ const groups = burst.colors.map(() => []);
166
+ for (const particle of burst.particles)
167
+ groups[particle.color].push(particle);
168
+ return new Promise(resolve => {
169
+ current.runs.push({ burst, groups, start: -1, resolve });
170
+ if (!current.frame)
171
+ current.frame = requestAnimationFrame(frame);
172
+ });
173
+ }
174
+ function reset() {
175
+ for (const host of hosts)
176
+ for (const wait of host.waiting.splice(0))
177
+ wait.resolve();
178
+ const current = layer;
179
+ if (!current)
180
+ return;
181
+ close(current);
182
+ for (const run of current.runs.splice(0))
183
+ run.resolve();
184
+ }
185
+ /** Fires a burst of confetti over the viewport. Call it from an event handler or an effect; it needs no `Confetti` to be mounted on web. */
186
+ export const confetti = Object.assign((options) => fire(options, hosts[hosts.length - 1]), { reset });
187
+ /**
188
+ * The confetti host. Mount it once inside HIGProvider: bursts then follow the provider's `reducedMotion`, `primaryColor`
189
+ * and `marketColors`. It draws nothing itself and never renders again for a burst; on web the canvas is added to the
190
+ * document body while pieces fly. With `trigger` it also fires declaratively.
191
+ *
192
+ * HIGProvider reads the system's reduced motion setting in an effect, after the effects of what it holds. So where the
193
+ * system asks for reduced motion, a burst asked for while this host mounts (a truthy `trigger`, or `confetti()` in a mount
194
+ * effect) waits for the one render that follows, and is then drawn only if the provider itself says motion is wanted.
195
+ */
196
+ export function Confetti({ trigger, options }) {
197
+ const { reducedMotion } = useHIG();
198
+ const [settled, setSettled] = useState(false);
199
+ const anchor = useRef(null), motion = useRef(reducedMotion), latest = useRef(options), fired = useRef(undefined), self = useRef(null);
200
+ motion.current = reducedMotion;
201
+ latest.current = options;
202
+ // One host for the life of the component, so a burst it holds survives React running the effects twice in development.
203
+ const host = self.current ??= { anchor: () => anchor.current, reducedMotion: () => motion.current === true, ready: false, waiting: [] };
204
+ useEffect(() => {
205
+ hosts.push(host);
206
+ // Without a system request for reduced motion the provider has nothing left to learn. With one, this update is rendered
207
+ // together with the provider's own, and the effect below runs once both are in.
208
+ if (systemReducedMotion())
209
+ setSettled(true);
210
+ else
211
+ host.ready = true;
212
+ return () => {
213
+ const index = hosts.indexOf(host);
214
+ if (index >= 0)
215
+ hosts.splice(index, 1);
216
+ // Only a host that stays out is gone; what it still held is over.
217
+ void Promise.resolve().then(() => { if (!hosts.includes(host))
218
+ for (const wait of host.waiting.splice(0))
219
+ wait.resolve(); });
220
+ };
221
+ }, [host]);
222
+ useEffect(() => {
223
+ if (!settled)
224
+ return;
225
+ host.ready = true;
226
+ for (const wait of host.waiting.splice(0))
227
+ void fire(wait.options, host).then(wait.resolve);
228
+ }, [settled, host]);
229
+ useEffect(() => {
230
+ // Each truthy value fires once, also when React runs the effect twice in development.
231
+ if (Object.is(fired.current, trigger))
232
+ return;
233
+ fired.current = trigger;
234
+ if (!trigger)
235
+ return;
236
+ for (const burst of confettiBursts(latest.current))
237
+ void fire(burst, host);
238
+ }, [trigger, host]);
239
+ return _jsx("span", { ref: anchor, hidden: true, "data-hig-confetti-host": '' });
240
+ }