@bloxwap/hig 0.5.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/README.md +1 -1
  2. package/chart/README.md +1 -1
  3. package/contracts/README.md +1 -1
  4. package/contracts/dist/index.d.ts +16 -0
  5. package/contracts/dist/index.js +22 -0
  6. package/contracts/dist/messages.d.ts +37 -4
  7. package/contracts/dist/messages.js +13 -2
  8. package/feedback/README.md +1 -1
  9. package/native/README.md +1 -1
  10. package/native/dist/account-block.d.ts +92 -0
  11. package/native/dist/account-block.js +61 -0
  12. package/native/dist/animated-number-model.d.ts +7 -1
  13. package/native/dist/animated-number-model.js +50 -1
  14. package/native/dist/animated-number.d.ts +3 -1
  15. package/native/dist/animated-number.js +8 -5
  16. package/native/dist/asset-balance-row.d.ts +36 -0
  17. package/native/dist/asset-balance-row.js +26 -0
  18. package/native/dist/bar-mark.d.ts +57 -0
  19. package/native/dist/bar-mark.js +48 -0
  20. package/native/dist/bar-pnl.d.ts +50 -0
  21. package/native/dist/bar-pnl.js +60 -0
  22. package/native/dist/blocks.d.ts +38 -0
  23. package/native/dist/blocks.js +42 -0
  24. package/native/dist/button.js +3 -1
  25. package/native/dist/data.d.ts +1 -1
  26. package/native/dist/data.js +6 -4
  27. package/native/dist/field.d.ts +14 -5
  28. package/native/dist/field.js +33 -8
  29. package/native/dist/figure.d.ts +23 -0
  30. package/native/dist/figure.js +10 -0
  31. package/native/dist/icons.d.ts +8 -0
  32. package/native/dist/icons.js +4 -0
  33. package/native/dist/language-block.d.ts +35 -0
  34. package/native/dist/language-block.js +30 -0
  35. package/native/dist/list-group.d.ts +60 -0
  36. package/native/dist/list-group.js +85 -0
  37. package/native/dist/manage-position-block.d.ts +95 -0
  38. package/native/dist/manage-position-block.js +82 -0
  39. package/native/dist/market-row.d.ts +46 -0
  40. package/native/dist/market-row.js +30 -0
  41. package/native/dist/notifications-block.d.ts +53 -0
  42. package/native/dist/notifications-block.js +22 -0
  43. package/native/dist/pickers.d.ts +35 -5
  44. package/native/dist/pickers.js +21 -9
  45. package/native/dist/position-block.d.ts +107 -0
  46. package/native/dist/position-block.js +55 -0
  47. package/native/dist/profile-block.d.ts +66 -0
  48. package/native/dist/profile-block.js +48 -0
  49. package/native/dist/provider.d.ts +9 -3
  50. package/native/dist/provider.js +7 -3
  51. package/native/dist/radio-group.d.ts +9 -3
  52. package/native/dist/radio-group.js +4 -5
  53. package/native/dist/recipes.d.ts +6 -46
  54. package/native/dist/recipes.js +6 -33
  55. package/native/dist/reward-block.d.ts +122 -0
  56. package/native/dist/reward-block.js +53 -0
  57. package/native/dist/screen-header.d.ts +49 -0
  58. package/native/dist/screen-header.js +29 -0
  59. package/native/dist/selection.d.ts +2 -2
  60. package/native/dist/setting-header.d.ts +2 -0
  61. package/native/dist/setting-header.js +2 -0
  62. package/native/dist/setting-switch.d.ts +31 -0
  63. package/native/dist/setting-switch.js +20 -0
  64. package/native/dist/signals-block.d.ts +61 -0
  65. package/native/dist/signals-block.js +26 -0
  66. package/native/dist/sound-haptics-block.d.ts +66 -0
  67. package/native/dist/sound-haptics-block.js +32 -0
  68. package/native/dist/status.d.ts +6 -5
  69. package/native/dist/status.js +5 -5
  70. package/native/dist/sticky-header.d.ts +28 -0
  71. package/native/dist/sticky-header.js +21 -0
  72. package/native/dist/surface.d.ts +3 -1
  73. package/native/dist/surface.js +2 -1
  74. package/native/dist/{swap-panel.d.ts → swap-panel-block.d.ts} +8 -3
  75. package/native/dist/{swap-panel.js → swap-panel-block.js} +13 -8
  76. package/native/dist/swap-parts.d.ts +5 -3
  77. package/native/dist/swap-parts.js +2 -2
  78. package/native/dist/swap-shared.d.ts +6 -0
  79. package/native/dist/swap-sheet.d.ts +4 -4
  80. package/native/dist/swap-sheet.js +4 -4
  81. package/native/dist/swap-views.d.ts +1 -1
  82. package/native/dist/swap-views.js +9 -7
  83. package/native/dist/switch-row.d.ts +3 -2
  84. package/native/dist/switch-row.js +5 -3
  85. package/native/dist/switch.d.ts +4 -2
  86. package/native/dist/switch.js +3 -3
  87. package/native/dist/target-block.d.ts +110 -0
  88. package/native/dist/target-block.js +74 -0
  89. package/native/dist/token-action-block.d.ts +47 -0
  90. package/native/dist/token-action-block.js +28 -0
  91. package/native/dist/trade-history-detail-block.d.ts +84 -0
  92. package/native/dist/trade-history-detail-block.js +46 -0
  93. package/native/dist/trade-history-list-block.d.ts +110 -0
  94. package/native/dist/trade-history-list-block.js +64 -0
  95. package/native/dist/wallet-address-core.d.ts +25 -0
  96. package/native/dist/wallet-address-core.js +31 -0
  97. package/native/dist/wallet-address.d.ts +6 -10
  98. package/native/dist/wallet-address.js +16 -20
  99. package/native-fonts/README.md +1 -1
  100. package/og-fonts/README.md +1 -1
  101. package/package.json +266 -41
  102. package/react/README.md +1 -1
  103. package/react/dist/animated-number-model.d.ts +6 -0
  104. package/react/dist/animated-number-model.js +33 -0
  105. package/react/dist/animated-number.d.ts +5 -1
  106. package/react/dist/animated-number.js +12 -8
  107. package/react/dist/asset-balance-row.d.ts +35 -0
  108. package/react/dist/asset-balance-row.js +18 -0
  109. package/react/dist/bar-mark.d.ts +38 -0
  110. package/react/dist/bar-mark.js +23 -0
  111. package/react/dist/bar-pnl.d.ts +49 -0
  112. package/react/dist/bar-pnl.js +45 -0
  113. package/react/dist/blocks/account-block.d.ts +92 -0
  114. package/react/dist/blocks/account-block.js +62 -0
  115. package/react/dist/blocks/language-block.d.ts +36 -0
  116. package/react/dist/blocks/language-block.js +52 -0
  117. package/react/dist/blocks/manage-position-block.d.ts +93 -0
  118. package/react/dist/blocks/manage-position-block.js +47 -0
  119. package/react/dist/blocks/market-row.d.ts +36 -0
  120. package/react/dist/blocks/market-row.js +16 -0
  121. package/react/dist/blocks/notifications-block.d.ts +46 -0
  122. package/react/dist/blocks/notifications-block.js +17 -0
  123. package/react/dist/{recipes → blocks}/pickers.d.ts +32 -4
  124. package/react/dist/{recipes → blocks}/pickers.js +35 -11
  125. package/react/dist/blocks/position-block.d.ts +72 -0
  126. package/react/dist/blocks/position-block.js +25 -0
  127. package/react/dist/blocks/profile-block.d.ts +71 -0
  128. package/react/dist/blocks/profile-block.js +41 -0
  129. package/react/dist/blocks/reward-block.d.ts +120 -0
  130. package/react/dist/blocks/reward-block.js +34 -0
  131. package/react/dist/blocks/screen-header.d.ts +33 -0
  132. package/react/dist/blocks/screen-header.js +20 -0
  133. package/react/dist/blocks/setting-switch.d.ts +23 -0
  134. package/react/dist/blocks/setting-switch.js +12 -0
  135. package/react/dist/blocks/signals-block.d.ts +54 -0
  136. package/react/dist/blocks/signals-block.js +15 -0
  137. package/react/dist/blocks/sound-haptics-block.d.ts +59 -0
  138. package/react/dist/blocks/sound-haptics-block.js +22 -0
  139. package/react/dist/blocks/sticky-header.d.ts +9 -0
  140. package/react/dist/blocks/sticky-header.js +43 -0
  141. package/react/dist/blocks/swap/amount-card.js +8 -0
  142. package/react/dist/{recipes → blocks}/swap/picker.d.ts +1 -1
  143. package/react/dist/{recipes → blocks}/swap/picker.js +4 -4
  144. package/react/dist/{recipes → blocks}/swap/settings.js +2 -2
  145. package/react/dist/{recipes → blocks}/swap/shared.d.ts +8 -1
  146. package/react/dist/{recipes → blocks}/swap/shared.js +7 -4
  147. package/react/dist/{recipes/swap-panel.d.ts → blocks/swap-panel-block.d.ts} +8 -2
  148. package/react/dist/{recipes/swap-panel.js → blocks/swap-panel-block.js} +9 -7
  149. package/react/dist/{recipes → blocks}/swap-sheet.d.ts +4 -4
  150. package/react/dist/{recipes → blocks}/swap-sheet.js +4 -4
  151. package/react/dist/blocks/target-block.d.ts +103 -0
  152. package/react/dist/blocks/target-block.js +73 -0
  153. package/react/dist/blocks/token-action-block.d.ts +46 -0
  154. package/react/dist/blocks/token-action-block.js +21 -0
  155. package/react/dist/{recipes → blocks}/trade-entry.js +2 -2
  156. package/react/dist/blocks/trade-history-detail-block.d.ts +78 -0
  157. package/react/dist/blocks/trade-history-detail-block.js +17 -0
  158. package/react/dist/blocks/trade-history-list-block.d.ts +67 -0
  159. package/react/dist/blocks/trade-history-list-block.js +28 -0
  160. package/react/dist/blocks.d.ts +20 -0
  161. package/react/dist/blocks.js +21 -0
  162. package/react/dist/button.js +6 -4
  163. package/react/dist/data.js +3 -3
  164. package/react/dist/field.d.ts +14 -6
  165. package/react/dist/field.js +19 -8
  166. package/react/dist/figure.d.ts +23 -0
  167. package/react/dist/figure.js +12 -0
  168. package/react/dist/list-group.d.ts +59 -0
  169. package/react/dist/list-group.js +52 -0
  170. package/react/dist/provider.d.ts +40 -3
  171. package/react/dist/provider.js +63 -6
  172. package/react/dist/selection.d.ts +8 -2
  173. package/react/dist/selection.js +11 -6
  174. package/react/dist/styles.css +425 -5
  175. package/react/dist/surface.d.ts +5 -1
  176. package/react/dist/surface.js +1 -1
  177. package/react/dist/wallet-address-core.d.ts +23 -0
  178. package/react/dist/wallet-address-core.js +24 -0
  179. package/react/dist/wallet-address.d.ts +6 -12
  180. package/react/dist/wallet-address.js +5 -16
  181. package/tokens/README.md +1 -1
  182. package/react/dist/recipes/activity-list.d.ts +0 -8
  183. package/react/dist/recipes/activity-list.js +0 -6
  184. package/react/dist/recipes/balance-card.d.ts +0 -6
  185. package/react/dist/recipes/balance-card.js +0 -5
  186. package/react/dist/recipes/code-window.d.ts +0 -4
  187. package/react/dist/recipes/code-window.js +0 -4
  188. package/react/dist/recipes/market-row.d.ts +0 -25
  189. package/react/dist/recipes/market-row.js +0 -8
  190. package/react/dist/recipes/swap/amount-card.js +0 -7
  191. package/react/dist/recipes.d.ts +0 -10
  192. package/react/dist/recipes.js +0 -11
  193. /package/react/dist/{recipes → blocks}/install-command.d.ts +0 -0
  194. /package/react/dist/{recipes → blocks}/install-command.js +0 -0
  195. /package/react/dist/{recipes → blocks}/marketing-hero.d.ts +0 -0
  196. /package/react/dist/{recipes → blocks}/marketing-hero.js +0 -0
  197. /package/react/dist/{recipes → blocks}/swap/amount-card.d.ts +0 -0
  198. /package/react/dist/{recipes → blocks}/swap/settings.d.ts +0 -0
  199. /package/react/dist/{recipes → blocks}/trade-entry.d.ts +0 -0
@@ -0,0 +1,67 @@
1
+ import React from 'react';
2
+ import type { AssetArtwork } from '../asset-balance-row.js';
3
+ /** The words of the card. They are trading terms, so the host supplies them; HIG ships none. */
4
+ export interface TradeHistoryListLabels {
5
+ /** Heading of the screen: History. */
6
+ title: string;
7
+ long: string;
8
+ short: string;
9
+ /** Shown in place of the rows when there are no trades. */
10
+ empty: string;
11
+ /** A second line under `empty`, in the muted colour: Closed trades appear here. */
12
+ emptyDescription?: string;
13
+ }
14
+ /** One closed trade. */
15
+ export interface TradeHistoryItem {
16
+ id: string;
17
+ /** Asset name: Amazon. */
18
+ name: string;
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. */
22
+ icon?: AssetArtwork;
23
+ side: 'long' | 'short';
24
+ /** 20 reads `20×`. */
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;
28
+ /** Net profit and loss in dollars. `null` reads as unknown. */
29
+ pnl: number | null;
30
+ /** Host-formatted age or time of the close, shown under the result: `2d`. */
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;
36
+ }
37
+ export interface TradeHistoryListBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title' | 'onSelect'> {
38
+ labels: TradeHistoryListLabels;
39
+ /** Closed trades, in the order shown. The host sorts and pages them. */
40
+ trades: readonly TradeHistoryItem[];
41
+ /** Makes each row a button that reports its trade, usually to open its detail, and shows the disclosure chevron. */
42
+ onSelect?: (trade: TradeHistoryItem) => void;
43
+ /** Shows Back on the leading edge of the header. */
44
+ onBack?: () => void;
45
+ /** A control on the trailing edge of the header, usually an `IconButton`. */
46
+ headerAction?: React.ReactNode;
47
+ /** 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
+ pnlOptions?: Intl.NumberFormatOptions;
49
+ /** Draws rows of skeletons in place of the trades while the host loads them. */
50
+ loading?: boolean;
51
+ /** Host text that names the skeleton rows for assistive technology and announces them: Loading history. Without it they are only marked busy. */
52
+ loadingLabel?: string;
53
+ /** Why the trades could not load, in place of the rows, in the negative colour and announced. */
54
+ error?: string;
55
+ /** Host content under the header, above the rows: a partial-history notice or a mode banner. */
56
+ notice?: React.ReactNode;
57
+ /** Host content under the rows: paging, a spinner for the next page, a note. */
58
+ footer?: React.ReactNode;
59
+ /** 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. */
60
+ stickyHeader?: boolean;
61
+ }
62
+ /** How a row reads its side: `Short 20×`, or `Short` without leverage. */
63
+ export declare const tradeHistorySide: (trade: Pick<TradeHistoryItem, 'side' | 'leverage'> & {
64
+ leverageNote?: string;
65
+ }, labels: Pick<TradeHistoryListLabels, 'long' | 'short'>, locale?: string) => string;
66
+ /** 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;
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { formatNumber } from '@bloxwap/hig/contracts';
4
+ import { PressDecoration, usePresentNumber, useNumberLocale } from '../provider.js';
5
+ import { AnimatedNumberReadout } from '../animated-number.js';
6
+ import { ScreenHeader } from './screen-header.js';
7
+ const pnlFormat = { style: 'currency', currency: 'USD', signDisplay: 'exceptZero', minimumSignificantDigits: 4, maximumSignificantDigits: 4 };
8
+ const skeletons = [0, 1, 2, 3];
9
+ /** How a row reads its side: `Short 20×`, or `Short` without leverage. */
10
+ 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' }) });
13
+ /** 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 }) {
15
+ const locale = useNumberLocale();
16
+ const present = usePresentNumber();
17
+ const row = (trade) => {
18
+ const result = trade.pnlOptions ?? pnlOptions;
19
+ const side = tradeHistorySide(trade, labels, locale), tone = trade.pnl == null || trade.pnl === 0 ? undefined : trade.pnl > 0 ? 'up' : 'down';
20
+ 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] });
21
+ 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);
22
+ };
23
+ 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)) })] })
24
+ : error ? _jsx("p", { className: 'hig-swap-empty hig-trade-error', role: 'alert', children: error })
25
+ : 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
+ : _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 })] });
28
+ }
@@ -0,0 +1,20 @@
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, type MarketRowProps } from './blocks/market-row.js';
3
+ export { TradeEntry } from './blocks/trade-entry.js';
4
+ export { InstallCommand } from './blocks/install-command.js';
5
+ export { MarketingHero } from './blocks/marketing-hero.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
+ export { LanguageBlock, filterLanguages, type LanguageBlockProps, type LanguageOption } from './blocks/language-block.js';
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, 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 { ProfileBlock, type ProfileBlockProps, type ProfileSection, type ProfileRow, type ProfileStatus, type ProfileAction, type ProfileFigure } from './blocks/profile-block.js';
13
+ export { RewardBlock, rewardProgress, type RewardBlockProps, type RewardPromo, type RewardEntry } from './blocks/reward-block.js';
14
+ export { SoundHapticsBlock, soundLevel, type SoundHapticsBlockProps, type SoundSection, type SoundVolume, type SettingAction } from './blocks/sound-haptics-block.js';
15
+ export { SignalsBlock, type SignalsBlockProps, type SignalsGroup, type SignalsItem } from './blocks/signals-block.js';
16
+ export { NotificationsBlock, type NotificationsBlockProps, type NotificationsItem } from './blocks/notifications-block.js';
17
+ export { TradeHistoryListBlock, tradeHistorySide, type TradeHistoryListBlockProps, type TradeHistoryListLabels, type TradeHistoryItem } from './blocks/trade-history-list-block.js';
18
+ export { TradeHistoryDetailBlock, type TradeHistoryDetailBlockProps, type TradeHistoryDetailLabels, type TradeHistoryDetail, type TradeHistoryAction } from './blocks/trade-history-detail-block.js';
19
+ export { FromPickerBlock, ToPickerBlock, FromPicker, ToPicker, type FromPickerBlockProps, type ToPickerBlockProps, type FromPickerProps, type ToPickerProps, type PickerListProps, type PickerInputProps } from './blocks/pickers.js';
20
+ export { SwapPanelBlock, SwapPanel, swapAction, type SwapPanelBlockProps, type SwapPanelProps, type SwapToken, type SwapChain, type SwapAction, type SwapDenomination, type SwapWallet, type SwapFee, type SwapReceive, type SwapDestination, type SwapDetail } from './blocks/swap-panel-block.js';
@@ -0,0 +1,21 @@
1
+ "use client";
2
+ /** 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`. */
3
+ export { MarketRow } from './blocks/market-row.js';
4
+ export { TradeEntry } from './blocks/trade-entry.js';
5
+ export { InstallCommand } from './blocks/install-command.js';
6
+ export { MarketingHero } from './blocks/marketing-hero.js';
7
+ export { AccountBlock, AssetBalanceRow, accountRows, accountSectionRows, accountSectionTotal, assetValue } from './blocks/account-block.js';
8
+ export { LanguageBlock, filterLanguages } from './blocks/language-block.js';
9
+ export { TokenActionBlock, tokenActionLabel } from './blocks/token-action-block.js';
10
+ export { ManagePositionBlock, positionCorridor } from './blocks/manage-position-block.js';
11
+ export { TargetBlock, targetLayout, targetFormat, targetPresets, targetUnits } from './blocks/target-block.js';
12
+ export { PositionBlock } from './blocks/position-block.js';
13
+ export { ProfileBlock } from './blocks/profile-block.js';
14
+ export { RewardBlock, rewardProgress } from './blocks/reward-block.js';
15
+ export { SoundHapticsBlock, soundLevel } from './blocks/sound-haptics-block.js';
16
+ export { SignalsBlock } from './blocks/signals-block.js';
17
+ export { NotificationsBlock } from './blocks/notifications-block.js';
18
+ export { TradeHistoryListBlock, tradeHistorySide } from './blocks/trade-history-list-block.js';
19
+ export { TradeHistoryDetailBlock } from './blocks/trade-history-detail-block.js';
20
+ export { FromPickerBlock, ToPickerBlock, FromPicker, ToPicker } from './blocks/pickers.js';
21
+ export { SwapPanelBlock, SwapPanel, swapAction } from './blocks/swap-panel-block.js';
@@ -3,7 +3,8 @@ 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', ...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);
@@ -14,7 +15,8 @@ export const Button = forwardRef(function Button({ intent = 'primary', busy = fa
14
15
  context.feedback?.emit({ id: `${id}/${++sequence.current}`, source: id, intent: 'activate', origin: e.detail === 0 ? 'keyboard' : 'pointer' });
15
16
  }
16
17
  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 }) }); });
18
+ } }, 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, !!disabled || busy)] });
19
+ }
20
+ export const Button = forwardRef(function Button(props, ref) { return useButton(props, ref, 'button'); });
21
+ 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
22
  export const Link = forwardRef(function Link(props, ref) { return _jsx("a", { ...props, ref: ref, className: `hig-link ${props.className ?? ''}` }); });
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
  import { createElement as _createElement } from "react";
3
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
- import { formatNumber } from '@bloxwap/hig/contracts';
4
+ import { formatNumber, presentNumberFormat } from '@bloxwap/hig/contracts';
5
5
  import * as en from '@bloxwap/hig/contracts/messages';
6
- import { useHIG } from './provider.js';
7
- export function NumberReadout({ value, options, stale, label, prefix = '', suffix = '' }) { const { locale, messages } = useHIG(); const known = value != null && Number.isFinite(value), formatted = formatNumber(value, locale, options), reading = known ? `${prefix}${formatted}${suffix}` : formatted; return _jsxs("span", { className: 'hig-number', "aria-label": label ? `${label}: ${reading}${stale ? ` ${messages.stale ?? en.stale}` : ''}` : undefined, children: [reading, stale && _jsxs("span", { children: [" ", messages.stale ?? en.stale] })] }); }
6
+ import { useHIG, useNumberLocale } from './provider.js';
7
+ export function NumberReadout({ value, options, stale, label, prefix = '', suffix = '' }) { const { messages, numberFormat } = useHIG(); const locale = useNumberLocale(); const known = value != null && Number.isFinite(value), formatted = formatNumber(value, locale, presentNumberFormat(options, numberFormat)), reading = known ? `${prefix}${formatted}${suffix}` : formatted; return _jsxs("span", { className: 'hig-number', "aria-label": label ? `${label}: ${reading}${stale ? ` ${messages.stale ?? en.stale}` : ''}` : undefined, children: [reading, stale && _jsxs("span", { children: [" ", messages.stale ?? en.stale] })] }); }
8
8
  export function Usd(props) { return _jsx(NumberReadout, { ...props, options: { style: 'currency', currency: 'USD', ...props.options } }); }
9
9
  /** Input is percent points: 5 means 5%, not 500%. */
10
10
  export function Percent(props) { return _jsx(NumberReadout, { ...props, value: props.value == null ? props.value : props.value / 100, options: { maximumFractionDigits: Math.max(3, props.options?.minimumFractionDigits ?? 0), ...props.options, style: 'percent' } }); }
@@ -1,16 +1,24 @@
1
1
  import React from 'react';
2
- export declare function Field({ id: provided, label, description, error, required, disabled, children }: React.PropsWithChildren<{
2
+ export interface FieldProps {
3
3
  id?: string;
4
4
  label: string;
5
- description?: string;
5
+ description?: string; /** `positive` draws the description as a success line, such as a name that is available, and announces it when it changes. The words carry the meaning; the colour repeats it. */
6
+ descriptionTone?: 'muted' | 'positive';
6
7
  error?: string;
7
8
  required?: boolean;
8
9
  disabled?: boolean;
9
- }>): React.JSX.Element;
10
+ }
11
+ export declare function Field({ id: provided, label, description, descriptionTone, error, required, disabled, children }: React.PropsWithChildren<FieldProps>): React.JSX.Element;
10
12
  export declare const Label: (props: React.LabelHTMLAttributes<HTMLLabelElement>) => React.JSX.Element;
11
13
  export declare const Input: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
12
14
  export declare const TextArea: React.ForwardRefExoticComponent<React.TextareaHTMLAttributes<HTMLTextAreaElement> & React.RefAttributes<HTMLTextAreaElement>>;
13
- /** Raw string and selection stay untouched; host parses/validates precision on submit. */
14
- export declare const AmountInput: React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "type"> & React.RefAttributes<HTMLInputElement>>;
15
15
  /** The magnifying glass sits inset on the leading edge; the input keeps the ref, class and every prop. Marked pure so a bundle that imports another field drops the icon. */
16
- export declare const SearchInput: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
16
+ export interface SearchInputProps extends React.InputHTMLAttributes<HTMLInputElement> {
17
+ /** Host content on the trailing edge inside the field, such as a filter button. The text stops 48 units short of the edge; wider content sets the input's `padding-inline-end`. */
18
+ trailing?: React.ReactNode;
19
+ /** Shows a clear button on the trailing edge while the controlled `value` is not empty. It calls this and returns focus to the field. */
20
+ onClear?: () => void;
21
+ /** Accessible name of the clear button; defaults to HIGProvider `messages.clearSearch`. */
22
+ clearLabel?: string;
23
+ }
24
+ export declare const SearchInput: React.ForwardRefExoticComponent<SearchInputProps & React.RefAttributes<HTMLInputElement>>;
@@ -1,20 +1,31 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { createContext, useContext, useId, forwardRef } from 'react';
3
+ import { createContext, useContext, useId, useRef, forwardRef } from 'react';
4
4
  import * as en from '@bloxwap/hig/contracts/messages';
5
- import { useHIG } from './provider.js';
5
+ import { PressDecoration, useHIG } from './provider.js';
6
6
  const Context = createContext({ id: '' });
7
- export function Field({ id: provided, label, description, error, required, disabled, children }) {
7
+ export function Field({ id: provided, label, description, descriptionTone, error, required, disabled, children }) {
8
8
  const { messages } = useHIG();
9
9
  const generated = useId();
10
10
  const id = provided ?? generated;
11
11
  const ids = [description && `${id}-help`, error && `${id}-error`].filter(Boolean).join(' ') || undefined;
12
- return _jsx(Context.Provider, { value: { id, description: ids, invalid: !!error, disabled, required }, children: _jsxs("div", { className: 'hig-field', children: [_jsxs("label", { htmlFor: id, children: [label, required ? ` ${messages.required ?? en.required}` : ''] }), children, description && _jsx("p", { id: `${id}-help`, children: description }), error && _jsx("p", { id: `${id}-error`, role: 'alert', children: error })] }) });
12
+ const positive = descriptionTone === 'positive';
13
+ return _jsx(Context.Provider, { value: { id, description: ids, invalid: !!error, disabled, required }, children: _jsxs("div", { className: 'hig-field', children: [_jsxs("label", { htmlFor: id, children: [label, required ? ` ${messages.required ?? en.required}` : ''] }), children, description && _jsx("p", { id: `${id}-help`, "data-tone": positive ? 'positive' : undefined, "aria-live": positive ? 'polite' : undefined, children: description }), error && _jsx("p", { id: `${id}-error`, role: 'alert', children: error })] }) });
13
14
  }
14
15
  export const Label = (props) => _jsx("label", { ...props });
15
16
  export const Input = forwardRef(function Input(props, ref) { const field = useContext(Context); return _jsx("input", { id: field.id || undefined, "aria-describedby": field.description, "aria-invalid": field.invalid || undefined, required: field.required, ...props, disabled: !!field.disabled || props.disabled, ref: ref, className: `hig-input ${props.className ?? ''}` }); });
16
17
  export const TextArea = forwardRef(function TextArea(props, ref) { const field = useContext(Context); return _jsx("textarea", { id: field.id || undefined, "aria-describedby": field.description, "aria-invalid": field.invalid || undefined, required: field.required, ...props, disabled: !!field.disabled || props.disabled, ref: ref, className: `hig-input ${props.className ?? ''}` }); });
17
- /** Raw string and selection stay untouched; host parses/validates precision on submit. */
18
- export const AmountInput = forwardRef(function AmountInput(props, ref) { return _jsx(Input, { ...props, ref: ref, type: 'text', inputMode: props.inputMode ?? 'decimal' }); });
19
- /** The magnifying glass sits inset on the leading edge; the input keeps the ref, class and every prop. Marked pure so a bundle that imports another field drops the icon. */
20
- export const SearchInput = /* @__PURE__ */ forwardRef(function SearchInput(props, ref) { return _jsxs("span", { className: 'hig-search-input', children: [_jsxs("svg", { className: 'hig-search-icon', "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', children: [_jsx("circle", { cx: '9', cy: '9', r: '5.25' }), _jsx("path", { d: 'm13 13 3.5 3.5' })] }), _jsx(Input, { type: 'search', ...props, ref: ref })] }); });
18
+ export const SearchInput = /* @__PURE__ */ forwardRef(function SearchInput({ trailing, onClear, clearLabel, ...props }, ref) {
19
+ const { messages } = useHIG();
20
+ const inner = useRef(null);
21
+ const off = !!useContext(Context).disabled || !!props.disabled;
22
+ const attach = (node) => { inner.current = node; if (typeof ref === 'function')
23
+ ref(node);
24
+ else if (ref)
25
+ ref.current = node; };
26
+ const clear = onClear && props.value != null && String(props.value) !== '' ? _jsxs("button", { type: 'button', className: 'hig-search-clear', "aria-label": clearLabel ?? messages.clearSearch ?? en.clearSearch, disabled: off, onClick: () => { onClear(); inner.current?.focus(); }, children: [_jsx("svg", { "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 16 16', children: _jsx("path", { d: 'm4 4 8 8m0-8-8 8' }) }), _jsx(PressDecoration, { kind: 'icon-button', disabled: off })] }) : null;
27
+ const extra = trailing != null && trailing !== false;
28
+ const end = extra || clear ? _jsxs("span", { className: 'hig-search-trailing', children: [trailing, clear] }) : null;
29
+ // The end padding stays while the clear button comes and goes, so typed text never reflows.
30
+ return _jsxs("span", { className: 'hig-search-input', "data-trailing": extra || onClear ? '' : undefined, children: [_jsxs("svg", { className: 'hig-search-icon', "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', children: [_jsx("circle", { cx: '9', cy: '9', r: '5.25' }), _jsx("path", { d: 'm13 13 3.5 3.5' })] }), _jsx(Input, { type: 'search', ...props, ref: onClear ? attach : ref }), end] });
31
+ });
@@ -0,0 +1,23 @@
1
+ /**
2
+ * A number the host supplies as a number so it updates place by place: `{value:0.53,options:{style:'currency',currency:'USD'}}`.
3
+ * `null` reads as unknown. `formattedValue` is the host's own text for the value, drawn and read in place of Intl's, which
4
+ * still moves place by place: use it where the browser's Intl does not match the host's number table. Never parse it back.
5
+ */
6
+ export interface Figure {
7
+ value: number | null;
8
+ options?: Intl.NumberFormatOptions;
9
+ prefix?: string;
10
+ suffix?: string;
11
+ formattedValue?: string;
12
+ }
13
+ /** The props of an `AnimatedNumberReadout` that draws a figure: its host text, when given, moves place by place too. */
14
+ export declare function figureProps(figure: Figure): {
15
+ value: number | null;
16
+ options?: Intl.NumberFormatOptions;
17
+ prefix?: string;
18
+ suffix?: string;
19
+ formattedValue?: string;
20
+ animateFormatted?: boolean;
21
+ };
22
+ /** What a figure reads as, with the provider's money format already merged into `options` by the caller. Unknown values read as the dash, without affixes. */
23
+ export declare function figureReading(figure: Figure, locale: string, options?: Intl.NumberFormatOptions): string;
@@ -0,0 +1,12 @@
1
+ import { formatNumber } from '@bloxwap/hig/contracts';
2
+ /** The props of an `AnimatedNumberReadout` that draws a figure: its host text, when given, moves place by place too. */
3
+ export function figureProps(figure) {
4
+ const { value, options, prefix, suffix, formattedValue } = figure;
5
+ return formattedValue ? { value, options, prefix, suffix, formattedValue, animateFormatted: true } : { value, options, prefix, suffix };
6
+ }
7
+ /** What a figure reads as, with the provider's money format already merged into `options` by the caller. Unknown values read as the dash, without affixes. */
8
+ export function figureReading(figure, locale, options) {
9
+ if (figure.value == null || !Number.isFinite(figure.value))
10
+ return '—';
11
+ return `${figure.prefix ?? ''}${figure.formattedValue || formatNumber(figure.value, locale, options)}${figure.suffix ?? ''}`;
12
+ }
@@ -0,0 +1,59 @@
1
+ import React from 'react';
2
+ /** A text action on the trailing edge of a `ListGroup` heading, such as “Cancel all”. */
3
+ export interface ListGroupAction {
4
+ /** Host text drawn as the action and naming it. */
5
+ label: string;
6
+ onSelect: () => void;
7
+ disabled?: boolean;
8
+ }
9
+ export interface ListGroupProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
10
+ /** Heading above the group, such as “Settings”: host text or an element such as a live count. Omit it for an untitled group. */
11
+ title?: React.ReactNode;
12
+ /** Host content after the title, such as a count or a figure. It is read with the heading; the group itself stays named by the title. */
13
+ titleAccessory?: React.ReactNode;
14
+ /** A text action on the trailing edge of the heading. */
15
+ action?: ListGroupAction;
16
+ /** Host content between the heading and the rows, such as a note or a field. A group with `intro` and no rows draws no row container. */
17
+ intro?: React.ReactNode;
18
+ /** `ListRow` elements. */
19
+ children?: React.ReactNode;
20
+ }
21
+ /** A grouped list for menus and settings: an optional heading over rows that share one rounded container. */
22
+ export declare function ListGroup({ title, titleAccessory, action, intro, children, className, ...rest }: ListGroupProps): React.JSX.Element;
23
+ export interface ListRowProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onSelect' | 'defaultChecked'> {
24
+ label: string;
25
+ /** A muted second line under the label, such as a subtitle or an address. The row grows to fit it, and it is read with the label. */
26
+ description?: React.ReactNode;
27
+ /** Colours the label: `destructive` for an action that deletes or ends something, `muted` for one that is done or inactive. */
28
+ tone?: 'destructive' | 'muted';
29
+ /** Artwork before the label, such as an icon. Decorative: the label names the row. */
30
+ leading?: React.ReactNode;
31
+ /** Short text on the trailing edge, such as `Off`, `English` or a balance. A string or number is drawn muted. */
32
+ value?: React.ReactNode;
33
+ /** What a `value` that is not text reads as, such as the formatted amount of a live figure. The element is then hidden from assistive technology and this text is read in its place. */
34
+ valueLabel?: string;
35
+ /** Colours a string or number `value` instead of the muted default, keeping its layout and reading. */
36
+ valueTone?: 'positive' | 'warning' | 'negative' | 'muted';
37
+ /** Anything richer on the trailing edge: icons, a `Badge`, or a control such as a `Switch`. */
38
+ trailing?: React.ReactNode;
39
+ /** Makes the whole row a button, usually one that opens another view, and shows the disclosure chevron. */
40
+ onSelect?: () => void;
41
+ /** Makes the whole row a link and shows the disclosure chevron. */
42
+ href?: string;
43
+ /** Dims the row and blocks `onSelect`, `href` and the switch. */
44
+ disabled?: boolean;
45
+ /** A row in a list of choices, such as a picker that selects and closes: `true` draws a check on the trailing edge and marks the row `aria-current`. With `selected` set, true or false, the row draws no chevron unless `disclosure` asks for one. */
46
+ selected?: boolean;
47
+ /** Something the row started is in progress: a spinner takes the disclosure's place, the row is marked busy and presses are ignored, without dimming it. */
48
+ busy?: boolean;
49
+ /** Busy text appended to the accessible name while `busy`; defaults to HIGProvider `messages.busy`. `''` omits it (the busy state stays exposed). */
50
+ busyLabel?: string;
51
+ /** The glyph a row with `onSelect` or `href` draws on its trailing edge: the `chevron` (default), `external` (an arrow, for something that opens outside the app) or `none`. */
52
+ disclosure?: 'chevron' | 'external' | 'none';
53
+ /** Makes the row a switch: the whole row is the target, the switch on its trailing edge is named by `label`, and `onCheckedChange` receives the new state. Use with no `onSelect` or `href`. */
54
+ checked?: boolean;
55
+ defaultChecked?: boolean;
56
+ onCheckedChange?: (checked: boolean) => void;
57
+ }
58
+ /** One row of a `ListGroup`: the label leads; a value, icons, a badge or a control trail. With `onSelect` or `href` the whole row is one target and shows a disclosure chevron; with `checked` or `onCheckedChange` the whole row is a switch; otherwise the row is static, so a control in `trailing` is its only target. The ref reaches the row's element. */
59
+ export declare const ListRow: React.ForwardRefExoticComponent<ListRowProps & React.RefAttributes<HTMLElement>>;
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import React, { Children, forwardRef, useId, useRef } from 'react';
4
+ import * as en from '@bloxwap/hig/contracts/messages';
5
+ import { PressDecoration, useControllable, useHIG } from './provider.js';
6
+ const shown = (node) => node != null && node !== false && node !== '';
7
+ /** A grouped list for menus and settings: an optional heading over rows that share one rounded container. */
8
+ export function ListGroup({ title, titleAccessory, action, intro, children, className, ...rest }) {
9
+ const id = useId();
10
+ const titled = shown(title), accessory = shown(titleAccessory);
11
+ const heading = titled ? accessory
12
+ ? _jsxs("h3", { className: 'hig-list-group-title', "data-accessory": '', children: [_jsx("span", { id: id, children: title }), ' ', _jsx("span", { className: 'hig-list-group-title-accessory', children: titleAccessory })] })
13
+ : _jsx("h3", { id: id, className: 'hig-list-group-title', children: title }) : null;
14
+ const rows = Children.toArray(children);
15
+ return _jsxs("section", { ...rest, className: `hig-list-group${className ? ` ${className}` : ''}`, "aria-labelledby": titled ? id : undefined, children: [action ? _jsxs("div", { className: 'hig-list-group-header', children: [heading, _jsxs("button", { type: 'button', className: 'hig-list-group-action', disabled: action.disabled, onClick: action.onSelect, children: [action.label, _jsx(PressDecoration, { kind: 'button', disabled: !!action.disabled })] })] }) : heading, shown(intro) && _jsx("div", { className: 'hig-list-group-intro', children: intro }), (!shown(intro) || rows.length > 0) && _jsx("ul", { className: 'hig-list-group-rows', children: rows.map((child, index) => _jsx("li", { children: child }, React.isValidElement(child) && child.key != null ? child.key : index)) })] });
16
+ }
17
+ const svg = { 'aria-hidden': true, focusable: false, viewBox: '0 0 20 20', width: 20, height: 20, fill: 'none', stroke: 'currentColor', strokeLinecap: 'round', strokeLinejoin: 'round' };
18
+ const chevron = _jsx("svg", { className: 'hig-list-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' }) });
19
+ const external = _jsx("svg", { ...svg, className: 'hig-list-row-chevron', "data-glyph": 'external', strokeWidth: '1.8', children: _jsx("path", { d: 'M6.5 13.5 14 6M8 5.5h6.5V12' }) });
20
+ const check = _jsx("svg", { ...svg, className: 'hig-list-row-check', strokeWidth: '2', children: _jsx("path", { d: 'm4.5 10.5 3.5 3.5 7.5-8' }) });
21
+ /** One row of a `ListGroup`: the label leads; a value, icons, a badge or a control trail. With `onSelect` or `href` the whole row is one target and shows a disclosure chevron; with `checked` or `onCheckedChange` the whole row is a switch; otherwise the row is static, so a control in `trailing` is its only target. The ref reaches the row's element. */
22
+ export const ListRow = /* @__PURE__ */ forwardRef(function ListRow({ label, description, tone, leading, value, valueLabel, valueTone, trailing, onSelect, href, disabled, selected, busy, busyLabel, disclosure, checked, defaultChecked, onCheckedChange, className, ...rest }, ref) {
23
+ const { messages } = useHIG();
24
+ const descriptionId = useId();
25
+ const input = useRef(null);
26
+ const [on, setOn] = useControllable(checked, defaultChecked ?? false, onCheckedChange);
27
+ const pressable = onSelect != null || href != null;
28
+ const toggles = !pressable && (checked !== undefined || defaultChecked !== undefined || onCheckedChange != null);
29
+ const text = typeof value === 'string' || typeof value === 'number';
30
+ const busyText = busyLabel ?? messages.busy ?? en.busy;
31
+ const name = _jsx("span", { className: 'hig-list-row-label', "data-tone": tone, children: label });
32
+ const glyphKind = disclosure ?? (selected !== undefined ? 'none' : 'chevron');
33
+ const glyph = busy && !toggles ? _jsx("span", { className: 'hig-button-spinner hig-list-row-spinner', "aria-hidden": 'true' }) : selected ? check : pressable ? (glyphKind === 'chevron' ? chevron : glyphKind === 'external' ? external : null) : null;
34
+ const swatch = toggles ? _jsxs("label", { className: 'hig-choice hig-switch', children: [_jsx("input", { ref: input, role: 'switch', type: 'checkbox', checked: on, disabled: disabled, "aria-busy": busy || undefined, "aria-describedby": shown(description) ? descriptionId : undefined, onChange: event => { if (!busy)
35
+ setOn(event.target.checked); } }), _jsx("span", { children: label })] }) : null;
36
+ const content = _jsxs(_Fragment, { children: [leading != null && _jsx("span", { className: 'hig-list-row-leading', "aria-hidden": 'true', children: leading }), shown(description) ? _jsxs("span", { className: 'hig-list-row-text', children: [name, _jsx("span", { id: descriptionId, className: 'hig-list-row-description', children: description })] }) : name, value != null && _jsx("span", { className: 'hig-list-row-value', "data-tone": text && valueTone && valueTone !== 'muted' ? valueTone : undefined, children: !text && valueLabel ? _jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": 'true', children: value }), _jsx("span", { className: 'hig-sr-only', children: valueLabel })] }) : value }), (trailing != null || swatch) && _jsxs("span", { className: 'hig-list-row-trailing', children: [trailing, swatch] }), glyph, busy && !toggles && busyText ? _jsxs("span", { role: 'status', className: 'hig-busy hig-sr-only', children: [" \u00B7 ", busyText] }) : null] });
37
+ const classes = `hig-list-row${className ? ` ${className}` : ''}`;
38
+ const current = selected ? { 'aria-current': true } : {};
39
+ if (toggles) {
40
+ // A press anywhere outside the switch and the host's own controls toggles it; the input stays the one named control.
41
+ const toggle = (event) => { const target = event.target; if (disabled || busy || target.closest('.hig-switch') || target.closest('a[href],button,input,select,textarea,label'))
42
+ return; input.current?.click(); };
43
+ return _jsxs("div", { ...rest, ref: ref, className: classes, "data-switch": '', "aria-disabled": disabled || undefined, onClick: event => { rest.onClick?.(event); if (!event.defaultPrevented)
44
+ toggle(event); }, children: [content, _jsx(PressDecoration, { kind: 'switch', disabled: !!disabled || !!busy, input: input })] });
45
+ }
46
+ // A busy link stays the same element, so the focus the press left on it stays; it only stops navigating.
47
+ if (!disabled && href != null)
48
+ return _jsxs("a", { ...current, ...rest, ref: ref, className: classes, href: href, "aria-disabled": busy || undefined, "aria-busy": busy || undefined, onClick: busy ? event => event.preventDefault() : onSelect, children: [content, _jsx(PressDecoration, { kind: 'row', disabled: !!busy })] });
49
+ if (onSelect)
50
+ return _jsxs("button", { type: 'button', ...current, ...rest, ref: ref, className: classes, disabled: disabled, "aria-busy": busy || undefined, onClick: busy ? undefined : onSelect, children: [content, _jsx(PressDecoration, { kind: 'row', disabled: !!disabled || !!busy })] });
51
+ return _jsx("div", { ...current, ...rest, ref: ref, className: classes, "aria-disabled": disabled || undefined, "aria-busy": busy || undefined, children: content });
52
+ });
@@ -1,21 +1,58 @@
1
1
  import type { FeedbackSink, FeedbackIntent } from '@bloxwap/hig/contracts/feedback';
2
2
  import React from 'react';
3
- import { type Environment } from '@bloxwap/hig/contracts';
3
+ import { type Environment, type NumberFormatPresentation } from '@bloxwap/hig/contracts';
4
4
  import { type HIGMessages } from '@bloxwap/hig/contracts/messages';
5
5
  import { nativeSrgb } from '@bloxwap/hig/tokens';
6
6
  export type { HIGMessages } from '@bloxwap/hig/contracts/messages';
7
+ export type { NumberFormatPresentation } from '@bloxwap/hig/contracts';
8
+ /** The kind of pressable HIG control a press decoration is drawn in: `button` (Button, the block action buttons and a ListGroup heading action), `icon-button` (IconButton and the SearchInput clear button), `row` (a pressable ListRow, AssetBalanceRow, the WalletAddress copy button or a block row), `switch` (Switch, a switch ListRow and the setting switch rows), `segment` (each SegmentedControl segment) and `back` (the block header's Back, Close and address controls). */
9
+ export type PressDecorationKind = 'button' | 'icon-button' | 'row' | 'switch' | 'segment' | 'back';
10
+ export interface PressDecorationInfo {
11
+ kind: PressDecorationKind; /** The control is disabled or busy and will not act on a press. */
12
+ disabled: boolean;
13
+ }
7
14
  export interface HIGContext extends Environment {
8
15
  onAccepted?: (id: string) => void;
9
16
  feedback?: FeedbackSink; /** Brand accent as opaque sRGB hex (#RGB or #RRGGBB). Nested providers inherit it; omitted at the root, Bloxwap green applies. */
10
17
  primaryColor?: string; /** Host translations of built-in copy, merged through nested providers. Components fall back to the English export per key; read the full resolved catalog with `useMessages()`. */
11
18
  messages: Readonly<Partial<HIGMessages>>;
19
+ /** Host content drawn inside every pressable HIG control, such as a native switch input that gives iOS Safari a haptic. It sits in an absolutely positioned layer over the control that changes no layout and catches no pointer events itself; its children do. Nested providers inherit it. Omitted, nothing is drawn. */
20
+ pressDecoration?: (info: PressDecorationInfo) => React.ReactNode;
21
+ /** Money presentation merged under every currency format HIG draws: the blocks, BarMark, BarPnl, AssetBalanceRow, the swap pieces and the number readouts. Options a format sets itself win. Nested providers inherit it. */
22
+ numberFormat?: NumberFormatPresentation;
23
+ /** Market-direction colours: `up` (rising, long, gain) and `down` (falling, short, loss), as CSS colours. They default to `--hig-buy` and `--hig-sell`; the provider sets `--hig-up` and `--hig-down` on its wrapper. Nested providers inherit them. */
24
+ marketColors?: HIGMarketColors;
25
+ }
26
+ /** Host colours for the market-direction roles. An omitted, empty or non-string role keeps `buy`/`sell`. */
27
+ export interface HIGMarketColors {
28
+ up?: string;
29
+ down?: string;
12
30
  }
13
31
  export interface HIGProviderProps extends Partial<Omit<HIGContext, 'messages'>> {
14
32
  messages?: Partial<HIGMessages>;
15
33
  }
16
- export declare function HIGProvider({ children, density, locale, direction, reducedMotion, onAccepted, feedback, primaryColor, messages }: React.PropsWithChildren<HIGProviderProps>): React.JSX.Element;
34
+ export declare function HIGProvider({ children, density, locale, direction, reducedMotion, onAccepted, feedback, primaryColor, messages, pressDecoration, numberFormat, marketColors }: React.PropsWithChildren<HIGProviderProps>): React.JSX.Element;
17
35
  export declare const useHIG: () => HIGContext;
18
- /** Scoped primary colour variables for host-owned portals outside the provider's DOM. */
36
+ /** Number options with the nearest provider's `numberFormat` merged under them; only currency formats change. */
37
+ export declare function usePresentNumber(): <T extends Intl.NumberFormatOptions | undefined>(options: T) => T;
38
+ /** The locale numbers are formatted in: the nearest provider's `numberFormat.locale`, else its `locale`. */
39
+ export declare function useNumberLocale(): string;
40
+ /**
41
+ * The provider's press decoration for one control: the host content in an absolutely positioned layer that is the control's last
42
+ * child, or nothing without a `pressDecoration`. Place it inside a host control to give it the same treatment as HIG's own.
43
+ * A press on an interactive element in the layer makes that element the activation target (the HTML activation rules), so the
44
+ * control around it would skip its own default action: a submit or reset button would not submit, a link would not navigate and
45
+ * a label would not toggle its input. The layer therefore stops that click and sends the control one click of its own, which
46
+ * runs the control's handlers and its default action once. For a control drawn as a `<label>` around its `input`, pass that
47
+ * input and the click goes to it. A host `<label>` that names a control is left alone, because the click it then sends to that
48
+ * control comes through next. A disabled control gets nothing.
49
+ */
50
+ export declare function PressDecoration({ kind, disabled, input }: {
51
+ kind: PressDecorationKind;
52
+ disabled?: boolean;
53
+ input?: React.RefObject<HTMLInputElement | null>;
54
+ }): React.JSX.Element | null;
55
+ /** Scoped primary and market colour variables for host-owned portals outside the provider's DOM. */
19
56
  export declare function useThemeStyle(): React.CSSProperties | undefined;
20
57
  /** Resolved sRGB roles for canvas and host-drawn content. CSS retains the default wide-gamut palette. */
21
58
  export declare function useColors(): Readonly<Record<keyof typeof nativeSrgb, string>>;
@@ -1,30 +1,87 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { createContext, useContext, useEffect, useMemo, useState, useRef, useId } from 'react';
4
- import { defaultEnvironment } from '@bloxwap/hig/contracts';
4
+ import { defaultEnvironment, numberLocale, presentNumberFormat } from '@bloxwap/hig/contracts';
5
5
  import { defaultMessages, resolveMessages } from '@bloxwap/hig/contracts/messages';
6
6
  import { nativeSrgb, resolvePrimaryColor } from '@bloxwap/hig/tokens';
7
7
  const Context = createContext({ ...defaultEnvironment, messages: {} });
8
- export function HIGProvider({ children, density = 'comfortable', locale = 'en-US', direction = 'ltr', reducedMotion, onAccepted, feedback, primaryColor, messages }) {
8
+ const marketColor = (value) => typeof value === 'string' && value !== '' ? value : undefined;
9
+ export function HIGProvider({ children, density = 'comfortable', locale = 'en-US', direction = 'ltr', reducedMotion, onAccepted, feedback, primaryColor, messages, pressDecoration, numberFormat, marketColors }) {
9
10
  const parent = useContext(Context);
10
11
  const inherited = parent.messages;
11
12
  const resolved = useMemo(() => resolveMessages(inherited, messages), [inherited, messages]);
13
+ const market = marketColors ?? parent.marketColors;
14
+ const up = marketColor(market?.up), down = marketColor(market?.down);
15
+ const inheritedMarket = useMemo(() => up === undefined && down === undefined ? undefined : { up, down }, [up, down]);
12
16
  const accent = primaryColor ?? parent.primaryColor;
13
- const theme = useMemo(() => primaryStyle(accent), [accent]);
17
+ const theme = useMemo(() => marketStyle(primaryStyle(accent), up, down), [accent, up, down]);
18
+ const decorate = pressDecoration ?? parent.pressDecoration;
19
+ const drawPress = useMemo(() => decorate ? pressLayer(decorate) : undefined, [decorate]);
14
20
  const [osReduced, setOSReduced] = useState(false);
15
21
  useEffect(() => { const query = window.matchMedia?.('(prefers-reduced-motion: reduce)'); if (!query)
16
22
  return; const update = () => setOSReduced(query.matches); update(); query.addEventListener('change', update); return () => query.removeEventListener('change', update); }, []);
17
- return _jsx(Context.Provider, { value: { density, locale, direction, reducedMotion: reducedMotion ?? osReduced, onAccepted, feedback, primaryColor: accent, messages: resolved }, children: _jsx("div", { style: theme, "data-hig-density": density, "data-hig-motion": reducedMotion ?? osReduced ? 'reduced' : 'full', dir: direction, lang: locale, children: children }) });
23
+ return _jsx(Context.Provider, { value: { density, locale, direction, reducedMotion: reducedMotion ?? osReduced, onAccepted, feedback, primaryColor: accent, messages: resolved, pressDecoration: decorate, numberFormat: numberFormat ?? parent.numberFormat, marketColors: inheritedMarket, drawPress }, children: _jsx("div", { style: theme, "data-hig-density": density, "data-hig-motion": reducedMotion ?? osReduced ? 'reduced' : 'full', dir: direction, lang: locale, children: children }) });
18
24
  }
19
25
  export const useHIG = () => useContext(Context);
26
+ /** Number options with the nearest provider's `numberFormat` merged under them; only currency formats change. */
27
+ export function usePresentNumber() { const { numberFormat } = useContext(Context); return useMemo(() => (options) => presentNumberFormat(options, numberFormat), [numberFormat]); }
28
+ /** The locale numbers are formatted in: the nearest provider's `numberFormat.locale`, else its `locale`. */
29
+ export function useNumberLocale() { const { locale, numberFormat } = useContext(Context); return numberLocale(locale, numberFormat); }
30
+ const interactive = 'a[href],button,input,select,textarea,label';
31
+ /**
32
+ * The provider's press decoration for one control: the host content in an absolutely positioned layer that is the control's last
33
+ * child, or nothing without a `pressDecoration`. Place it inside a host control to give it the same treatment as HIG's own.
34
+ * A press on an interactive element in the layer makes that element the activation target (the HTML activation rules), so the
35
+ * control around it would skip its own default action: a submit or reset button would not submit, a link would not navigate and
36
+ * a label would not toggle its input. The layer therefore stops that click and sends the control one click of its own, which
37
+ * runs the control's handlers and its default action once. For a control drawn as a `<label>` around its `input`, pass that
38
+ * input and the click goes to it. A host `<label>` that names a control is left alone, because the click it then sends to that
39
+ * control comes through next. A disabled control gets nothing.
40
+ */
41
+ export function PressDecoration({ kind, disabled = false, input }) {
42
+ const draw = useContext(Context).drawPress;
43
+ return draw ? draw(kind, disabled, input) : null;
44
+ }
45
+ function pressLayer(decorate) {
46
+ return (kind, disabled, input) => {
47
+ const content = decorate({ kind, disabled });
48
+ if (content == null || content === false)
49
+ return null;
50
+ return _jsx("span", { className: 'hig-press-decoration', "data-kind": kind, onClick: event => forwardPress(event, input), children: content });
51
+ };
52
+ }
53
+ function forwardPress(event, input) {
54
+ const layer = event.currentTarget;
55
+ for (let node = event.target; node && node !== layer; node = node.parentElement) {
56
+ if (!node.matches(interactive))
57
+ continue;
58
+ if (node instanceof HTMLLabelElement && node.control)
59
+ return;
60
+ const control = input ? input.current : layer.parentElement;
61
+ if (!control)
62
+ return;
63
+ event.stopPropagation();
64
+ if (control.matches(':disabled'))
65
+ return;
66
+ const { detail, screenX, screenY, clientX, clientY, ctrlKey, shiftKey, altKey, metaKey, button } = event;
67
+ control.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, composed: true, view: event.nativeEvent.view, detail, screenX, screenY, clientX, clientY, ctrlKey, shiftKey, altKey, metaKey, button }));
68
+ return;
69
+ }
70
+ }
20
71
  function primaryStyle(primaryColor) {
21
72
  if (primaryColor === undefined)
22
73
  return undefined;
23
74
  const colors = resolvePrimaryColor(primaryColor);
24
75
  return { '--hig-action': colors.action, '--hig-focus': colors.focus, '--hig-onAction': colors.onAction };
25
76
  }
26
- /** Scoped primary colour variables for host-owned portals outside the provider's DOM. */
27
- export function useThemeStyle() { const { primaryColor } = useHIG(); return useMemo(() => primaryStyle(primaryColor), [primaryColor]); }
77
+ /** Adds `--hig-up` / `--hig-down` for a market colour override; without one the style is returned unchanged. */
78
+ function marketStyle(style, up, down) {
79
+ if (up === undefined && down === undefined)
80
+ return style;
81
+ return { ...style, ...(up !== undefined ? { '--hig-up': up } : {}), ...(down !== undefined ? { '--hig-down': down } : {}) };
82
+ }
83
+ /** Scoped primary and market colour variables for host-owned portals outside the provider's DOM. */
84
+ export function useThemeStyle() { const { primaryColor, marketColors } = useHIG(); return useMemo(() => marketStyle(primaryStyle(primaryColor), marketColors?.up, marketColors?.down), [primaryColor, marketColors]); }
28
85
  /** Resolved sRGB roles for canvas and host-drawn content. CSS retains the default wide-gamut palette. */
29
86
  export function useColors() { const { primaryColor } = useHIG(); return useMemo(() => primaryColor === undefined ? nativeSrgb : { ...nativeSrgb, ...resolvePrimaryColor(primaryColor) }, [primaryColor]); }
30
87
  /** Complete built-in copy for the nearest HIGProvider: host translations over the English defaults. */