@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
@@ -7,6 +7,16 @@ export interface SignalsItem {
7
7
  checked: boolean;
8
8
  onCheckedChange: (checked: boolean) => void;
9
9
  disabled?: boolean;
10
+ /** Always on and not changeable: shown on at full strength and read as unavailable. */
11
+ locked?: boolean;
12
+ /** Host content after the label, such as a badge. It is part of the switch's name. */
13
+ labelAccessory?: React.ReactNode;
14
+ /** Host words for the `labelAccessory`, read after the label and a pause in place of its content: `Feed, New`. */
15
+ labelAccessoryLabel?: string;
16
+ /** A neutral line under the switch, announced when it changes: Needs this browser's permission. */
17
+ hint?: string;
18
+ /** A failure under the switch, in the negative role and announced. */
19
+ error?: string;
10
20
  }
11
21
  /** A family of signals under one heading: Trend, Swing. Every word is host text. */
12
22
  export interface SignalsGroup {
@@ -14,22 +24,33 @@ export interface SignalsGroup {
14
24
  title: string;
15
25
  /** Shows the verified mark after the title. */
16
26
  verified?: boolean;
17
- /** A small pill on the trailing edge of the heading: How it works. The host opens its own explanation. */
27
+ /** A small pill on the trailing edge of the heading: How it works. The host opens its own explanation. `ref` reaches the pill, so the host can return focus to it when the explanation closes. */
18
28
  help?: {
19
29
  label: string;
20
30
  onSelect: () => void;
31
+ ref?: React.Ref<HTMLButtonElement>;
21
32
  };
22
33
  items: readonly SignalsItem[];
23
34
  }
24
35
  export interface SignalsBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
25
36
  /** Heading: Signals. */
26
37
  title: string;
38
+ /** A muted line under the header that explains the screen. */
39
+ description?: string;
27
40
  groups: readonly SignalsGroup[];
28
41
  /** Accessible name of the verified mark. The mark is decorative without it. */
29
42
  verifiedLabel?: string;
43
+ /** Host artwork in place of the built-in verified mark, drawn inside the mark's image role. */
44
+ verifiedMark?: React.ReactNode;
45
+ /** The `verifiedMark` is a control, such as a badge with a popover: it stays in the accessibility tree outside the image role, and `verifiedLabel` is read before it. */
46
+ verifiedMarkInteractive?: boolean;
30
47
  onBack?: () => void;
31
48
  /** A control on the trailing edge of the header, usually an `IconButton`. */
32
49
  headerAction?: React.ReactNode;
50
+ /** `id` of the header's heading, so a host dialog or sheet can name itself with `aria-labelledby`. */
51
+ headingId?: string;
52
+ /** 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. */
53
+ stickyHeader?: boolean;
33
54
  }
34
55
  /** The signals the viewer receives, in groups: each group has a heading with an optional verified mark and a small help pill, and its signals as switches with a line of explanation, sharing one rounded container. */
35
- export declare function SignalsBlock({ title, groups, verifiedLabel, onBack, headerAction, className, ...rest }: SignalsBlockProps): React.JSX.Element;
56
+ export declare function SignalsBlock({ title, description, groups, verifiedLabel, verifiedMark, verifiedMarkInteractive, onBack, headerAction, stickyHeader, headingId, className, ...rest }: SignalsBlockProps): React.JSX.Element;
@@ -1,15 +1,16 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { CircleCheck } from '@bloxwap/icons/react/circle-check';
3
4
  import { useId } from 'react';
4
5
  import { ScreenHeader } from './screen-header.js';
5
6
  import { SettingSwitch } from './setting-switch.js';
6
7
  import { SwapPill } from './swap/shared.js';
7
- const verifiedMark = _jsxs("svg", { "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', width: '16', height: '16', fill: 'none', stroke: 'currentColor', strokeWidth: '1.8', strokeLinecap: 'round', strokeLinejoin: 'round', children: [_jsx("circle", { cx: '10', cy: '10', r: '7.5' }), _jsx("path", { d: 'm6.75 10.25 2.25 2.25 4.25-4.75' })] });
8
- function Group({ group, verifiedLabel }) {
8
+ const verifiedGlyph = _jsx(CircleCheck, { size: 16 });
9
+ function Group({ group, verifiedLabel, verifiedMark, verifiedMarkInteractive }) {
9
10
  const id = useId();
10
- return _jsxs("section", { className: 'hig-signals-group', "aria-labelledby": id, children: [_jsxs("div", { className: 'hig-signals-group-header', children: [_jsxs("h3", { id: id, children: [group.title, group.verified && _jsx("span", { className: 'hig-reward-verified', role: verifiedLabel ? 'img' : undefined, "aria-label": verifiedLabel, children: verifiedMark })] }), group.help && _jsx(SwapPill, { onClick: group.help.onSelect, children: group.help.label })] }), group.items.length > 0 && _jsx("div", { className: 'hig-setting-list', children: group.items.map(item => _jsx("div", { className: 'hig-setting-card', children: _jsx(SettingSwitch, { label: item.label, description: item.description, checked: item.checked, disabled: item.disabled, onCheckedChange: item.onCheckedChange }) }, item.id)) })] });
11
+ return _jsxs("section", { className: 'hig-signals-group', "aria-labelledby": id, children: [_jsxs("div", { className: 'hig-signals-group-header', children: [_jsxs("h3", { id: id, children: [group.title, group.verified && (verifiedMark != null && verifiedMarkInteractive ? _jsxs("span", { className: 'hig-reward-verified', children: [verifiedLabel && _jsx("span", { className: 'hig-sr-only', children: verifiedLabel }), verifiedMark] }) : _jsx("span", { className: 'hig-reward-verified', role: verifiedLabel ? 'img' : undefined, "aria-label": verifiedLabel, children: verifiedMark ?? verifiedGlyph }))] }), group.help && _jsx(SwapPill, { ref: group.help.ref, onClick: group.help.onSelect, children: group.help.label })] }), group.items.length > 0 && _jsx("div", { className: 'hig-setting-list', children: group.items.map(item => _jsxs("div", { className: 'hig-setting-card', children: [_jsx(SettingSwitch, { label: item.label, description: item.description, checked: item.checked, disabled: item.disabled, locked: item.locked, labelAccessory: item.labelAccessory, labelAccessoryLabel: item.labelAccessoryLabel, onCheckedChange: item.onCheckedChange }), (item.hint || item.error) && _jsxs("div", { className: 'hig-setting-notes', children: [item.hint && _jsx("p", { role: 'status', className: 'hig-setting-hint', children: item.hint }), item.error && _jsx("p", { role: 'alert', className: 'hig-setting-error', children: item.error })] })] }, item.id)) })] });
11
12
  }
12
13
  /** The signals the viewer receives, in groups: each group has a heading with an optional verified mark and a small help pill, and its signals as switches with a line of explanation, sharing one rounded container. */
13
- export function SignalsBlock({ title, groups, verifiedLabel, onBack, headerAction, className, ...rest }) {
14
- return _jsxs("section", { ...rest, className: `hig-settings-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: title, onBack: onBack, action: headerAction }), groups.map(group => _jsx(Group, { group: group, verifiedLabel: verifiedLabel }, group.id))] });
14
+ export function SignalsBlock({ title, description, groups, verifiedLabel, verifiedMark, verifiedMarkInteractive, onBack, headerAction, stickyHeader, headingId, className, ...rest }) {
15
+ return _jsxs("section", { ...rest, className: `hig-settings-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: title, onBack: onBack, action: headerAction, headingId: headingId, stickyHeader: stickyHeader }), description && _jsx("p", { className: 'hig-settings-description', children: description }), groups.map(group => _jsx(Group, { group: group, verifiedLabel: verifiedLabel, verifiedMark: verifiedMark, verifiedMarkInteractive: verifiedMarkInteractive }, group.id))] });
15
16
  }
@@ -1,4 +1,7 @@
1
1
  import React from 'react';
2
+ import { type Choice } from '../selection.js';
3
+ import { type SettingAction } from './setting-switch.js';
4
+ export type { SettingAction } from './setting-switch.js';
2
5
  /** A volume as a few fixed steps. `value` and `options` are fractions: 0.25 reads 25%. */
3
6
  export interface SoundVolume {
4
7
  /** Names the steps and is drawn above them: Volume. */
@@ -8,6 +11,13 @@ export interface SoundVolume {
8
11
  value: number;
9
12
  onValueChange: (value: number) => void;
10
13
  }
14
+ /** A choice of device under the source, such as which microphone to use. `label` names the group and is drawn above it. */
15
+ export interface SoundChoices {
16
+ label: string;
17
+ options: readonly Choice[];
18
+ value: string;
19
+ onValueChange: (value: string) => void;
20
+ }
11
21
  /** One feedback channel: sound effects, the microphone, haptics, the flash. Every word is host text. */
12
22
  export interface SoundSection {
13
23
  id: string;
@@ -18,20 +28,34 @@ export interface SoundSection {
18
28
  disabled?: boolean;
19
29
  /** The device in use, under the switch: iPhone Microphone. */
20
30
  source?: string;
31
+ /** A choice between devices, as radios under the source: Automatic, iPhone Microphone, AirPods. Shown while the channel is on. */
32
+ choices?: SoundChoices;
21
33
  /** A live input level from 0 to 1, drawn as a meter. `null` draws an empty meter. */
22
34
  level?: number | null;
35
+ /** Names the meter for assistive technology, which then reads the level as a percentage. Without it the meter is decorative. */
36
+ levelLabel?: string;
23
37
  volume?: SoundVolume;
38
+ /** What the volume does while the channel is off: `hidden` (the default) leaves it out, `disabled` keeps it in place and unavailable. */
39
+ volumeWhenOff?: 'hidden' | 'disabled';
40
+ /** A secondary action at the foot of the card, shown whether the channel is on or off: Open Settings. */
41
+ action?: SettingAction;
24
42
  }
25
43
  export interface SoundHapticsBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
26
44
  /** Heading: Sound & Haptics. */
27
45
  title: string;
28
- /** One card each, in order. A section's source, meter and volume show only while it is on. */
46
+ /** A muted line under the header that explains the screen. */
47
+ description?: string;
48
+ /** One card each, in order. A section's source, choices and meter show only while it is on; its volume too unless `volumeWhenOff` is `disabled`. */
29
49
  sections: readonly SoundSection[];
30
50
  onBack?: () => void;
31
51
  /** A control on the trailing edge of the header, usually an `IconButton`. */
32
52
  headerAction?: React.ReactNode;
53
+ /** `id` of the header's heading, so a host dialog or sheet can name itself with `aria-labelledby`. */
54
+ headingId?: string;
55
+ /** 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. */
56
+ stickyHeader?: boolean;
33
57
  }
34
58
  /** The share of the meter filled, from 0 to 1. Unknown and out-of-range levels are clamped. */
35
59
  export declare const soundLevel: (level: number | null | undefined) => number;
36
- /** The settings for what the app plays and feels like: each channel is a card with a switch, and a channel that is on can show the device it uses, a live input meter and its volume as fixed steps. */
37
- export declare function SoundHapticsBlock({ title, sections, onBack, headerAction, className, ...rest }: SoundHapticsBlockProps): React.JSX.Element;
60
+ /** The settings for what the app plays and feels like: each channel is a card with a switch, and a channel that is on can show the device it uses, a choice of devices, a live input meter and its volume as fixed steps. */
61
+ export declare function SoundHapticsBlock({ title, description, sections, onBack, headerAction, stickyHeader, headingId, className, ...rest }: SoundHapticsBlockProps): React.JSX.Element;
@@ -1,18 +1,22 @@
1
1
  "use client";
2
2
  import { 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
+ import { RadioGroup } from '../selection.js';
6
7
  import { ScreenHeader } from './screen-header.js';
7
8
  import { SettingSwitch } from './setting-switch.js';
8
9
  const steps = [0.25, 0.5, 0.75, 1], percent = { style: 'percent', maximumFractionDigits: 0 };
9
10
  /** The share of the meter filled, from 0 to 1. Unknown and out-of-range levels are clamped. */
10
11
  export const soundLevel = (level) => level == null || !Number.isFinite(level) ? 0 : Math.min(1, Math.max(0, level));
11
- /** The settings for what the app plays and feels like: each channel is a card with a switch, and a channel that is on can show the device it uses, a live input meter and its volume as fixed steps. */
12
- export function SoundHapticsBlock({ title, sections, onBack, headerAction, className, ...rest }) {
13
- const { locale } = useHIG();
14
- return _jsxs("section", { ...rest, className: `hig-settings-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: title, onBack: onBack, action: headerAction }), sections.length > 0 && _jsx("div", { className: 'hig-setting-cards', children: sections.map(section => {
15
- const { source, level, volume } = section, open = section.checked && (!!source || level !== undefined || !!volume);
16
- return _jsxs("div", { className: 'hig-setting-card', children: [_jsx(SettingSwitch, { label: section.label, description: section.description, checked: section.checked, disabled: section.disabled, onCheckedChange: section.onCheckedChange }), open && _jsxs("div", { className: 'hig-setting-body', children: [source && _jsx("span", { className: 'hig-setting-caption', children: source }), level !== undefined && _jsx("div", { className: 'hig-setting-meter', "aria-hidden": 'true', children: _jsx("span", { style: { width: `${soundLevel(level) * 100}%` } }) }), volume && _jsxs("div", { className: 'hig-setting-volume', role: 'group', "aria-label": volume.label, children: [_jsx("span", { className: 'hig-setting-caption', "aria-hidden": 'true', children: volume.label }), _jsx("div", { className: 'hig-setting-steps', children: (volume.options ?? steps).map(option => _jsx(Button, { fullWidth: true, intent: option === volume.value ? 'primary' : 'secondary', "aria-pressed": option === volume.value, disabled: section.disabled, onClick: () => volume.onValueChange(option), children: formatNumber(option, locale, percent) }, option)) })] })] })] }, section.id);
12
+ /** The settings for what the app plays and feels like: each channel is a card with a switch, and a channel that is on can show the device it uses, a choice of devices, a live input meter and its volume as fixed steps. */
13
+ export function SoundHapticsBlock({ title, description, sections, onBack, headerAction, stickyHeader, headingId, className, ...rest }) {
14
+ const locale = useNumberLocale();
15
+ return _jsxs("section", { ...rest, className: `hig-settings-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: title, onBack: onBack, action: headerAction, headingId: headingId, stickyHeader: stickyHeader }), description && _jsx("p", { className: 'hig-settings-description', children: description }), sections.length > 0 && _jsx("div", { className: 'hig-setting-cards', children: sections.map(section => {
16
+ const { source, choices, level, levelLabel, volume, action } = section, on = section.checked;
17
+ const showVolume = !!volume && (on || section.volumeWhenOff === 'disabled'), volumeOff = !!section.disabled || !on;
18
+ const open = (on && (!!source || !!choices || level !== undefined)) || showVolume || !!action;
19
+ return _jsxs("div", { className: 'hig-setting-card', children: [_jsx(SettingSwitch, { label: section.label, description: section.description, checked: section.checked, disabled: section.disabled, onCheckedChange: section.onCheckedChange }), open && _jsxs("div", { className: 'hig-setting-body', children: [on && source && _jsx("span", { className: 'hig-setting-caption', children: source }), on && choices && _jsx("div", { className: 'hig-setting-choices', children: _jsx(RadioGroup, { label: choices.label, options: choices.options, value: choices.value, disabled: section.disabled, onValueChange: choices.onValueChange }) }), on && level !== undefined && (levelLabel ? _jsx("div", { className: 'hig-setting-meter', role: 'meter', "aria-label": levelLabel, "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": Math.round(soundLevel(level) * 100), "aria-valuetext": formatNumber(soundLevel(level), locale, percent), children: _jsx("span", { style: { width: `${soundLevel(level) * 100}%` } }) })
20
+ : _jsx("div", { className: 'hig-setting-meter', "aria-hidden": 'true', children: _jsx("span", { style: { width: `${soundLevel(level) * 100}%` } }) })), showVolume && volume && _jsxs("div", { className: 'hig-setting-volume', role: 'group', "aria-label": volume.label, children: [_jsx("span", { className: 'hig-setting-caption', "aria-hidden": 'true', children: volume.label }), _jsx("div", { className: 'hig-setting-steps', children: (volume.options ?? steps).map(option => _jsx(Button, { fullWidth: true, intent: option === volume.value ? 'primary' : 'secondary', "aria-pressed": option === volume.value, disabled: on ? section.disabled : volumeOff, onClick: () => volume.onValueChange(option), children: formatNumber(option, locale, percent) }, option)) })] }), action && _jsx(Button, { className: 'hig-setting-action', intent: 'secondary', fullWidth: true, disabled: action.disabled, suppressFeedback: action.feedback === false, onClick: action.onSelect, children: action.label })] })] }, section.id);
17
21
  }) })] });
18
22
  }
@@ -0,0 +1,19 @@
1
+ import { type RefObject } from 'react';
2
+ /**
3
+ * How far the header rests below the edge it sticks to: the scroller's content edge (browsers stick inside the scroller's own
4
+ * padding) or the viewport. When the header leads every box between it and the scroller, that distance is the top margins,
5
+ * borders and padding of those boxes, such as a pane's padding; sticking at it keeps the header where it rests. A header that
6
+ * follows other content returns `null`: it scrolls up to the edge before it pins, as before.
7
+ */
8
+ export declare function stickyRestingInset(header: HTMLElement, root: HTMLElement | null): number | null;
9
+ /**
10
+ * Marks a pinned header `data-scrolled` once content has scrolled under it, so its fill appears only then and it stays
11
+ * transparent at rest, and pins it where it rests so it does not move when it starts to stick, whatever padding sits between
12
+ * it and the scroller. The header's parent is the content: the header is scrolled once the parent has moved up past the point
13
+ * where the header pins (or the scroller is the parent and has moved). The pinned inset is `--hig-sticky-inset`, and
14
+ * `--hig-sticky-cover` is how far above the header the fill reaches to the scroller's edge, so content does not show through
15
+ * the gap; `data-sticky-inset` marks a header with such a gap. Where the browser supports scroll-driven animations the
16
+ * stylesheet fades the fill in on the same rule for a header that pins at the scroller's very edge; this keeps every other
17
+ * browser, a header with a gap and reduced motion in step with it.
18
+ */
19
+ export declare function useStickyHeader(header: RefObject<HTMLElement | null>, enabled: boolean): void;
@@ -0,0 +1,103 @@
1
+ "use client";
2
+ import { useEffect } from 'react';
3
+ const scrolls = /(auto|scroll|overlay)/;
4
+ /** The nearest ancestor of `node` (itself included) that scrolls vertically, or `null` for the document. */
5
+ function scroller(node) {
6
+ for (let current = node; current && current !== document.body && current !== document.documentElement; current = current.parentElement) {
7
+ if (scrolls.test(getComputedStyle(current).overflowY))
8
+ return current;
9
+ }
10
+ return null;
11
+ }
12
+ /** The custom properties the stylesheet reads for the pinned inset and the fill above it. */
13
+ const insetProperty = '--hig-sticky-inset', coverProperty = '--hig-sticky-cover';
14
+ const length = (value) => `${value}px`;
15
+ const px = (value) => { const number = parseFloat(value ?? ''); return Number.isFinite(number) ? number : 0; };
16
+ /** True when something that takes space in the flow comes before `node`; hidden and out-of-flow siblings do not count. */
17
+ function follows(node) {
18
+ for (let sibling = node.previousElementSibling; sibling; sibling = sibling.previousElementSibling) {
19
+ const style = getComputedStyle(sibling);
20
+ if (style.display === 'none' || style.position === 'absolute' || style.position === 'fixed')
21
+ continue;
22
+ if (sibling.getBoundingClientRect().height > 0)
23
+ return true;
24
+ }
25
+ return false;
26
+ }
27
+ /**
28
+ * How far the header rests below the edge it sticks to: the scroller's content edge (browsers stick inside the scroller's own
29
+ * padding) or the viewport. When the header leads every box between it and the scroller, that distance is the top margins,
30
+ * borders and padding of those boxes, such as a pane's padding; sticking at it keeps the header where it rests. A header that
31
+ * follows other content returns `null`: it scrolls up to the edge before it pins, as before.
32
+ */
33
+ export function stickyRestingInset(header, root) {
34
+ let inset = px(getComputedStyle(header).marginTop);
35
+ for (let node = header, parent = header.parentElement; parent && parent !== root; node = parent, parent = parent.parentElement) {
36
+ if (follows(node))
37
+ return null;
38
+ const style = getComputedStyle(parent);
39
+ inset += px(style.borderTopWidth) + px(style.paddingTop);
40
+ if (parent === document.documentElement)
41
+ break;
42
+ inset += px(style.marginTop);
43
+ }
44
+ return inset;
45
+ }
46
+ /**
47
+ * Marks a pinned header `data-scrolled` once content has scrolled under it, so its fill appears only then and it stays
48
+ * transparent at rest, and pins it where it rests so it does not move when it starts to stick, whatever padding sits between
49
+ * it and the scroller. The header's parent is the content: the header is scrolled once the parent has moved up past the point
50
+ * where the header pins (or the scroller is the parent and has moved). The pinned inset is `--hig-sticky-inset`, and
51
+ * `--hig-sticky-cover` is how far above the header the fill reaches to the scroller's edge, so content does not show through
52
+ * the gap; `data-sticky-inset` marks a header with such a gap. Where the browser supports scroll-driven animations the
53
+ * stylesheet fades the fill in on the same rule for a header that pins at the scroller's very edge; this keeps every other
54
+ * browser, a header with a gap and reduced motion in step with it.
55
+ */
56
+ export function useStickyHeader(header, enabled) {
57
+ useEffect(() => {
58
+ const element = header.current;
59
+ if (!enabled || !element)
60
+ return;
61
+ const content = element.parentElement;
62
+ if (!content)
63
+ return;
64
+ const root = scroller(content);
65
+ const target = root ?? window;
66
+ // When the parent is the scroller itself a view timeline on it tracks an outer scroller, never its own scrolling, so the
67
+ // stylesheet leaves the scroll-driven fill off (data-sticky-own) and this script alone marks the moment.
68
+ const own = root === content;
69
+ element.toggleAttribute('data-sticky-own', own);
70
+ let inset = 0, leading = false;
71
+ const measure = () => {
72
+ const resting = stickyRestingInset(element, root);
73
+ leading = resting !== null;
74
+ inset = Math.max(0, resting ?? 0);
75
+ const pad = root ? px(getComputedStyle(root).paddingTop) : 0;
76
+ // Any gap above the pinned header (its own inset or the scroller's padding) hands the fill to the script, which marks the
77
+ // moment it pins; a scroll-driven fill would wait for the parent to reach the scroller's outer edge.
78
+ element.toggleAttribute('data-sticky-inset', inset + pad > 0.5);
79
+ element.style.setProperty(insetProperty, length(inset));
80
+ element.style.setProperty(coverProperty, length(inset + pad));
81
+ };
82
+ const update = () => {
83
+ let scrolled;
84
+ if (own)
85
+ scrolled = content.scrollTop > 0;
86
+ else if (leading) {
87
+ // The line the header pins to, and where the header would sit without sticking: the parent's content edge.
88
+ const edge = root ? root.getBoundingClientRect().top + root.clientTop + px(getComputedStyle(root).paddingTop) : 0;
89
+ const parent = getComputedStyle(content), natural = content.getBoundingClientRect().top + px(parent.borderTopWidth) + px(parent.paddingTop) + px(getComputedStyle(element).marginTop);
90
+ scrolled = natural < edge + inset - 0.5;
91
+ }
92
+ else
93
+ scrolled = content.getBoundingClientRect().top < (root ? root.getBoundingClientRect().top : 0) - 0.5;
94
+ if (element.hasAttribute('data-scrolled') !== scrolled)
95
+ element.toggleAttribute('data-scrolled', scrolled);
96
+ };
97
+ const resize = () => { measure(); update(); };
98
+ resize();
99
+ target.addEventListener('scroll', update, { passive: true });
100
+ window.addEventListener('resize', resize, { passive: true });
101
+ return () => { target.removeEventListener('scroll', update); window.removeEventListener('resize', resize); element.removeAttribute('data-scrolled'); element.removeAttribute('data-sticky-own'); element.removeAttribute('data-sticky-inset'); element.style.removeProperty(insetProperty); element.style.removeProperty(coverProperty); };
102
+ }, [header, enabled]);
103
+ }
@@ -1,7 +1,8 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { AnimatedNumberReadout } from '../../animated-number.js';
4
+ import { PressDecoration } from '../../provider.js';
4
5
  /** The swap panel's From card on its own: the asset with its actions and balance in the slot, the entered amount under it. The host owns the entry, the keypad and what the amount means. */
5
6
  export function SwapAmountCard({ name, symbol, icon, chainIcon, context, actions, meta, value, amountLabel, prefix = '', suffix = '', fractionDigits = 0, trailingDot = false, maximumFractionDigits = 8, conversion, onSelect, selectLabel, className, style }) {
6
- return _jsxs("div", { className: `hig-swap-card${className ? ` ${className}` : ''}`, style: style, "data-side": 'from', children: [_jsxs("div", { className: 'hig-swap-slot', children: [onSelect && _jsx("button", { type: 'button', className: 'hig-swap-hit', "aria-label": selectLabel, onClick: onSelect }), _jsx("div", { className: 'hig-swap-slot-content', children: _jsxs("div", { className: 'hig-swap-selected', children: [_jsxs("span", { className: 'hig-swap-stack', "aria-hidden": 'true', children: [chainIcon && _jsx("img", { src: chainIcon, alt: '' }), typeof icon === 'string' ? _jsx("img", { src: icon, alt: '' }) : icon ?? _jsx("span", { className: 'hig-swap-initials', children: symbol.slice(0, 3) })] }), _jsxs("span", { className: 'hig-swap-identity', children: [context != null && _jsx("span", { children: context }), _jsx("strong", { children: name })] }), (actions != null || meta != null) && _jsxs("span", { className: 'hig-swap-meta', children: [actions != null && _jsx("span", { className: 'hig-swap-pills', children: actions }), meta != null && _jsx("span", { className: 'hig-number', children: meta })] })] }) })] }), _jsx("div", { className: 'hig-swap-amount-area', children: _jsxs("div", { className: 'hig-swap-amount-content', children: [_jsx("div", { className: 'hig-swap-amount', role: 'textbox', tabIndex: 0, "aria-readonly": 'true', "aria-label": amountLabel, children: _jsx(AnimatedNumberReadout, { value: value, prefix: prefix, suffix: (trailingDot ? '.' : '') + suffix, options: { minimumFractionDigits: Math.min(fractionDigits, maximumFractionDigits), maximumFractionDigits, useGrouping: false } }) }), conversion] }) })] });
7
+ return _jsxs("div", { className: `hig-swap-card${className ? ` ${className}` : ''}`, style: style, "data-side": 'from', children: [_jsxs("div", { className: 'hig-swap-slot', children: [onSelect && _jsx("button", { type: 'button', className: 'hig-swap-hit', "aria-label": selectLabel, onClick: onSelect, children: _jsx(PressDecoration, { kind: 'row' }) }), _jsx("div", { className: 'hig-swap-slot-content', children: _jsxs("div", { className: 'hig-swap-selected', children: [_jsxs("span", { className: 'hig-swap-stack', "aria-hidden": 'true', children: [chainIcon && _jsx("img", { src: chainIcon, alt: '' }), typeof icon === 'string' ? _jsx("img", { src: icon, alt: '' }) : icon ?? _jsx("span", { className: 'hig-swap-initials', children: symbol.slice(0, 3) })] }), _jsxs("span", { className: 'hig-swap-identity', children: [context != null && _jsx("span", { children: context }), _jsx("strong", { children: name })] }), (actions != null || meta != null) && _jsxs("span", { className: 'hig-swap-meta', children: [actions != null && _jsx("span", { className: 'hig-swap-pills', children: actions }), meta != null && _jsx("span", { className: 'hig-number', children: meta })] })] }) })] }), _jsx("div", { className: 'hig-swap-amount-area', children: _jsxs("div", { className: 'hig-swap-amount-content', children: [_jsx("div", { className: 'hig-swap-amount', role: 'textbox', tabIndex: 0, "aria-readonly": 'true', "aria-label": amountLabel, children: _jsx(AnimatedNumberReadout, { value: value, prefix: prefix, suffix: (trailingDot ? '.' : '') + suffix, options: { minimumFractionDigits: Math.min(fractionDigits, maximumFractionDigits), maximumFractionDigits, useGrouping: false } }) }), conversion] }) })] });
7
8
  }
@@ -2,7 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useRef, useState } 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
  import { Field, Input } from '../../field.js';
7
7
  import { SegmentedControl } from '../../selection.js';
8
8
  import { SwapIcon, SwapNumber, SwapViewHeader, formatPercent, percentNumber, usdNumber } from './shared.js';
@@ -16,8 +16,9 @@ export function SwapSettings({ view, onViewChange, onBack, denomination, onDenom
16
16
  const title = view === 'slippage' ? (messages.swapSlippageTitle ?? en.swapSlippageTitle) : view === 'fees' ? (messages.swapFees ?? en.swapFees) : (messages.swapSettings ?? en.swapSettings);
17
17
  const feeText = quoteLoading ? '…' : fee != null ? _jsx(SwapNumber, { ...usdNumber(fee) }) : '—';
18
18
  const preset = slippagePresets.find(value => Math.abs(value - slippage) < 1e-9);
19
- const row = (label, value, target) => _jsxs("button", { type: 'button', className: 'hig-swap-setting', onClick: () => onViewChange(target), children: [_jsx("span", { children: label }), _jsxs("span", { className: 'hig-swap-setting-value', children: [value, _jsx(SwapIcon, { name: 'chevron', size: 16 })] })] });
19
+ const row = (label, value, target) => _jsxs("button", { type: 'button', className: 'hig-swap-setting', onClick: () => onViewChange(target), children: [_jsx("span", { children: label }), _jsxs("span", { className: 'hig-swap-setting-value', children: [value, _jsx(SwapIcon, { name: 'chevron', size: 16 })] }), _jsx(PressDecoration, { kind: 'row' })] });
20
20
  const slippageRow = row(messages.swapSlippageTitle ?? en.swapSlippageTitle, _jsx(SwapNumber, { ...percentNumber(slippage) }), 'slippage'), feesRow = row(messages.swapFees ?? en.swapFees, feeText, 'fees');
21
- return _jsxs("div", { className: 'hig-swap-settings-view', role: 'group', "aria-label": title, children: [_jsx(SwapViewHeader, { title: title, titleRef: heading, backLabel: messages.back ?? en.back, onBack: onBack }), view === 'settings' && _jsxs("div", { className: 'hig-swap-settings', children: [onDenominationChange && _jsx(SegmentedControl, { label: (messages.swapDenomination ?? en.swapDenomination), options: [{ value: 'usd', label: (messages.swapDollars ?? en.swapDollars) }, { value: 'token', label: (messages.swapUnits ?? en.swapUnits) }], value: denomination, onValueChange: value => onDenominationChange(value) }), onSlippageChange && slippageRow, feesRow, children] }), view === 'slippage' && onSlippageChange && _jsxs("div", { className: 'hig-swap-settings hig-swap-presets', children: [_jsx(SegmentedControl, { label: (messages.swapSlippageTitle ?? en.swapSlippageTitle), options: slippagePresets.map(value => ({ value: String(value), label: formatPercent(value) })), value: preset === undefined ? '' : String(preset), onValueChange: value => { setCustom(null); onSlippageChange(Number(value)); } }), _jsx(Field, { label: (messages.swapSlippageCustom ?? en.swapSlippageCustom), children: _jsx(Input, { inputMode: 'decimal', value: custom ?? String(Number((slippage * 100).toFixed(4))), onChange: event => { const raw = event.target.value.replace(/[^0-9.]/g, ''); setCustom(raw); const percent = Number.parseFloat(raw); if (Number.isFinite(percent) && percent >= 0 && percent <= 50)
21
+ return _jsxs("div", { className: 'hig-swap-settings-view', role: 'group', "aria-label": title, children: [_jsx(SwapViewHeader, { title: title, titleRef: heading, backLabel: messages.back ?? en.back, onBack: () => { setCustom(null); onBack(); } }), view === 'settings' && _jsxs("div", { className: 'hig-swap-settings', children: [onDenominationChange && _jsx(SegmentedControl, { label: (messages.swapDenomination ?? en.swapDenomination), options: [{ value: 'usd', label: (messages.swapDollars ?? en.swapDollars) }, { value: 'token', label: (messages.swapUnits ?? en.swapUnits) }], value: denomination, onValueChange: value => onDenominationChange(value) }), onSlippageChange && slippageRow, feesRow, children] }), view === 'slippage' && onSlippageChange && _jsxs("div", { className: 'hig-swap-settings hig-swap-presets', children: [_jsx(SegmentedControl, { label: (messages.swapSlippageTitle ?? en.swapSlippageTitle), options: slippagePresets.map(value => ({ value: String(value), label: formatPercent(value) })), value: preset === undefined ? '' : String(preset), onValueChange: value => { setCustom(null); onSlippageChange(Number(value)); } }), _jsx(Field, { label: (messages.swapSlippageCustom ?? en.swapSlippageCustom), children: _jsx(Input, { inputMode: 'decimal', onBlur: () => setCustom(null), value: custom ?? String(Number((slippage * 100).toFixed(4))), onChange: event => { const raw = event.target.value; const percent = Number(raw); if (!/^\d*\.?\d*$/.test(raw) || !Number.isFinite(percent) || percent > 50)
22
+ return; setCustom(raw); if (raw !== '' && raw !== '.')
22
23
  onSlippageChange(percent / 100); } }) })] }), view === 'fees' && _jsxs("dl", { className: 'hig-swap-fees', children: [fees?.map(item => _jsxs("div", { children: [_jsx("dt", { children: item.label }), _jsx("dd", { children: _jsx(SwapNumber, { ...usdNumber(item.usd) }) })] }, item.label)), _jsxs("div", { className: 'hig-swap-fees-total', children: [_jsx("dt", { children: (messages.swapFeeTotal ?? en.swapFeeTotal) }), _jsx("dd", { className: 'hig-number', children: feeText })] })] })] });
23
24
  }
@@ -12,7 +12,7 @@ export interface SwapToken {
12
12
  /** Artwork: an image URL, or the host's own element (an inline SVG, say), which fills the disc. A missing token icon falls back to the symbol's first letters. */
13
13
  icon?: SwapArtwork;
14
14
  chainIcon?: SwapArtwork;
15
- /** Most decimal places a token amount may be typed with, for example 6 for USDC. Unlimited when omitted. Dollars always stop at two. */
15
+ /** Most decimal places a token amount may be typed with, for example 6 for USDC. Up to 100 when omitted; explicit precision must be an integer from 0 to 100. Dollars always stop at two. */
16
16
  decimals?: number;
17
17
  /** Holdings in token units, when the host knows them. Enables Max, Test and the balance check. */
18
18
  balance?: number | null;
@@ -23,6 +23,10 @@ export interface SwapToken {
23
23
  caption?: string | SwapFigure;
24
24
  /** Extra text matched by the picker search, such as the contract address. */
25
25
  keywords?: string;
26
+ /** Picker rows: host text after the balance figure, such as ` HYPE`. */
27
+ unitsSuffix?: string;
28
+ /** Picker rows: the second line under the name in place of the chain, for a list that is not about chains. The search still matches the chain. */
29
+ detail?: string;
26
30
  }
27
31
  /** An image URL, or an element the host draws. */
28
32
  export type SwapArtwork = string | React.ReactElement;
@@ -42,7 +46,7 @@ export declare const trimNumber: (value: number, digits?: number) => string;
42
46
  /** Keeps digits and one decimal point, and strips leading zeros; never returns an empty string. */
43
47
  export declare function sanitizeAmount(raw: string): string;
44
48
  /** Token units shown in the active denomination. Dollars floor to the cent so Max never resolves to more than the balance. */
45
- export declare function unitsToEntry(units: number, mode: SwapDenomination, price: number): string;
49
+ export declare function unitsToEntry(units: number | string, mode: SwapDenomination, price: number): string;
46
50
  /** Applies one keypad or keyboard key (`0`–`9`, `.`, `back`) to an amount string. Dollars stop at two decimals, token units at `decimals` when given. */
47
51
  export declare function applyAmountKey(current: string, key: string, mode: SwapDenomination, decimals?: number): string;
48
52
  /** Case-insensitive substring or in-order subsequence match. */
@@ -57,6 +61,8 @@ export interface SwapFigure {
57
61
  options?: Intl.NumberFormatOptions;
58
62
  prefix?: string;
59
63
  suffix?: string;
64
+ /** Host-formatted text for `value`, drawn and read in place of Intl's and still moving place by place. Never parsed back. */
65
+ formattedValue?: string;
60
66
  }
61
67
  /** Host text that is either a fixed string or a live figure. */
62
68
  export declare const swapFigure: (text: string | SwapFigure) => string | React.JSX.Element;
@@ -83,27 +89,27 @@ export declare function testAmount(token: SwapToken): number;
83
89
  export declare const shortAddress: (address: string) => string;
84
90
  /** A stable two-stop gradient for a wallet address, so the same wallet always looks the same. */
85
91
  export declare function addressGradient(address: string): string;
86
- declare const paths: {
87
- flip: React.JSX.Element;
88
- down: React.JSX.Element;
89
- reset: React.JSX.Element;
90
- menu: React.JSX.Element;
91
- close: React.JSX.Element;
92
- back: React.JSX.Element;
93
- chevron: React.JSX.Element;
94
- expand: React.JSX.Element;
95
- delete: React.JSX.Element;
96
- sliders: React.JSX.Element;
97
- flask: React.JSX.Element;
98
- scan: React.JSX.Element;
99
- flame: React.JSX.Element;
100
- logout: React.JSX.Element;
101
- wallet: React.JSX.Element;
102
- info: React.JSX.Element;
103
- lock: React.JSX.Element;
92
+ declare const symbols: {
93
+ flip: import("@bloxwap/icons/react/create-icon").IconComponent;
94
+ down: import("@bloxwap/icons/react/create-icon").IconComponent;
95
+ reset: import("@bloxwap/icons/react/create-icon").IconComponent;
96
+ menu: import("@bloxwap/icons/react/create-icon").IconComponent;
97
+ close: import("@bloxwap/icons/react/create-icon").IconComponent;
98
+ back: import("@bloxwap/icons/react/create-icon").IconComponent;
99
+ chevron: import("@bloxwap/icons/react/create-icon").IconComponent;
100
+ expand: import("@bloxwap/icons/react/create-icon").IconComponent;
101
+ delete: import("@bloxwap/icons/react/create-icon").IconComponent;
102
+ sliders: import("@bloxwap/icons/react/create-icon").IconComponent;
103
+ flask: import("@bloxwap/icons/react/create-icon").IconComponent;
104
+ scan: import("@bloxwap/icons/react/create-icon").IconComponent;
105
+ flame: import("@bloxwap/icons/react/create-icon").IconComponent;
106
+ logout: import("@bloxwap/icons/react/create-icon").IconComponent;
107
+ wallet: import("@bloxwap/icons/react/create-icon").IconComponent;
108
+ info: import("@bloxwap/icons/react/create-icon").IconComponent;
109
+ lock: import("@bloxwap/icons/react/create-icon").IconComponent;
104
110
  };
105
- export type SwapIconName = keyof typeof paths;
106
- /** Outline symbol on a 20 unit grid; decorative, so the control that holds it carries the name. */
111
+ export type SwapIconName = keyof typeof symbols;
112
+ /** Shared outline symbol; the containing control carries its accessible name. */
107
113
  export declare function SwapIcon({ name, size }: {
108
114
  name: SwapIconName;
109
115
  size?: number;
@@ -114,7 +120,7 @@ export declare function TokenIcon({ token, size }: {
114
120
  size?: number;
115
121
  }): React.JSX.Element;
116
122
  /** Small capsule action that sits on a card: Max, Test, the slippage setting and the denomination switch. */
117
- export declare function SwapPill({ children, ...props }: React.ButtonHTMLAttributes<HTMLButtonElement>): React.JSX.Element;
123
+ export declare function SwapPill({ children, ...props }: React.ComponentPropsWithRef<'button'>): React.JSX.Element;
118
124
  /** Numeric keypad. Emits `0`–`9`, `.` or `back`. */
119
125
  export declare function SwapKeypad({ onKey, label, deleteLabel }: {
120
126
  onKey: (key: string) => void;
@@ -1,12 +1,34 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { ArrowDown } from '@bloxwap/icons/react/arrow-down';
4
+ import { ArrowUpDown } from '@bloxwap/icons/react/arrow-up-down';
5
+ import { ChevronDown } from '@bloxwap/icons/react/chevron-down';
6
+ import { ChevronLeft } from '@bloxwap/icons/react/chevron-left';
7
+ import { ChevronRight } from '@bloxwap/icons/react/chevron-right';
8
+ import { Delete } from '@bloxwap/icons/react/delete';
9
+ import { Flame } from '@bloxwap/icons/react/flame';
10
+ import { FlaskConical } from '@bloxwap/icons/react/flask-conical';
11
+ import { Info } from '@bloxwap/icons/react/info';
12
+ import { Lock } from '@bloxwap/icons/react/lock';
13
+ import { LogOut } from '@bloxwap/icons/react/log-out';
14
+ import { Menu } from '@bloxwap/icons/react/menu';
15
+ import { RotateCcw } from '@bloxwap/icons/react/rotate-ccw';
16
+ import { ScanLine } from '@bloxwap/icons/react/scan-line';
17
+ import { SlidersHorizontal } from '@bloxwap/icons/react/sliders-horizontal';
18
+ import { Wallet } from '@bloxwap/icons/react/wallet';
19
+ import { X } from '@bloxwap/icons/react/x';
20
+ import { decimal, decimalMultiply, decimalDivide } from '@bloxwap/hig/contracts';
3
21
  import { AnimatedNumberReadout } from '../../animated-number.js';
22
+ import { PressDecoration } from '../../provider.js';
23
+ import { figureProps } from '../../figure.js';
4
24
  /** Artwork in a disc: the URL as an image, the host's element inside a clipped wrapper. */
5
25
  export const swapArt = (icon, className, lazy) => typeof icon === 'string' ? _jsx("img", { className: className, src: icon, alt: '', loading: lazy ? 'lazy' : undefined }) : _jsx("span", { className: `hig-swap-art${className ? ` ${className}` : ''}`, "aria-hidden": 'true', children: icon });
6
26
  export function swapAction(from, to) {
7
- if (!from || !to || from.symbol === to.symbol)
27
+ if (!from || !to)
8
28
  return 'send';
9
- return from.chainId === to.chainId ? 'swap' : 'bridge';
29
+ if (String(from.chainId) !== String(to.chainId))
30
+ return 'bridge';
31
+ return from.id === to.id ? 'send' : 'swap';
10
32
  }
11
33
  /** A clean numeric string: no trailing zeros, at most `digits` decimals. */
12
34
  export const trimNumber = (value, digits = 8) => String(Number((Number.isFinite(value) ? value : 0).toFixed(digits)));
@@ -22,8 +44,8 @@ export function sanitizeAmount(raw) {
22
44
  /** Token units shown in the active denomination. Dollars floor to the cent so Max never resolves to more than the balance. */
23
45
  export function unitsToEntry(units, mode, price) {
24
46
  if (mode === 'token')
25
- return trimNumber(units);
26
- return price > 0 ? String(Math.floor(units * price * 100) / 100) : '0';
47
+ return decimal(units);
48
+ return price > 0 ? decimalMultiply(units, price, 2) : '0';
27
49
  }
28
50
  /** Applies one keypad or keyboard key (`0`–`9`, `.`, `back`) to an amount string. Dollars stop at two decimals, token units at `decimals` when given. */
29
51
  export function applyAmountKey(current, key, mode, decimals) {
@@ -59,7 +81,7 @@ export function SwapNumber({ template, ...number }) {
59
81
  return _jsxs("span", { children: [before, _jsx(AnimatedNumberReadout, { ...number }), after] });
60
82
  }
61
83
  /** Host text that is either a fixed string or a live figure. */
62
- export const swapFigure = (text) => typeof text === 'string' ? text : _jsx(SwapNumber, { value: text.value, options: text.options, prefix: text.prefix, suffix: text.suffix });
84
+ export const swapFigure = (text) => typeof text === 'string' ? text : _jsx(SwapNumber, { ...figureProps(text) });
63
85
  /** `SwapNumber` props for a dollar amount and for a slippage fraction (0.005 reads `0.5%`). */
64
86
  export const usdNumber = (value) => ({ value, options: { style: 'currency', currency: 'USD' } });
65
87
  export const percentNumber = (fraction) => ({ value: Number((fraction * 100).toFixed(4)), suffix: '%', options: { maximumFractionDigits: 4, useGrouping: false } });
@@ -68,9 +90,10 @@ export const formatPercent = (fraction) => `${Number((fraction * 100).toFixed(4)
68
90
  /** A small trial amount: 1% of holdings, capped at about one dollar's worth. */
69
91
  export function testAmount(token) {
70
92
  const balance = token.balance ?? 0, price = token.price ?? 0;
71
- if (!(balance > 0))
93
+ if (!(balance > 0) || !Number.isFinite(balance))
72
94
  return 0;
73
- return Number(Math.min(balance * 0.01, price > 0 ? 1 / price : balance * 0.01).toFixed(8));
95
+ const fraction = decimalDivide(balance, 100, token.decimals ?? 18);
96
+ return Number(decimal(price > 0 ? Math.min(Number(fraction), Number(decimalDivide(1, price, token.decimals ?? 18))) : fraction, token.decimals ?? 18));
74
97
  }
75
98
  export const shortAddress = (address) => address.length <= 12 ? address : `${address.slice(0, 6)}…${address.slice(-4)}`;
76
99
  /** A stable two-stop gradient for a wallet address, so the same wallet always looks the same. */
@@ -80,39 +103,20 @@ export function addressGradient(address) {
80
103
  hash = (hash * 31 + character.charCodeAt(0)) >>> 0;
81
104
  return `linear-gradient(135deg,hsl(${hash % 360} 80% 62%),hsl(${(hash >>> 8) % 360} 75% 42%))`;
82
105
  }
83
- const stroke = { fill: 'none', stroke: 'currentColor', strokeWidth: 1.75, strokeLinecap: 'round', strokeLinejoin: 'round' };
84
- const paths = {
85
- flip: _jsx("path", { d: 'M6.5 3.5v13m0 0-3-3m3 3 3-3M13.5 16.5v-13m0 0-3 3m3-3 3 3' }),
86
- down: _jsx("path", { d: 'M10 3.5v13m0 0-4.5-4.5M10 16.5l4.5-4.5' }),
87
- reset: _jsx("path", { d: 'M4 10a6 6 0 1 0 2-4.5M4 4v3h3' }),
88
- menu: _jsx("path", { d: 'M4 6h12M4 10h12M4 14h12' }),
89
- close: _jsx("path", { d: 'm5.5 5.5 9 9m0-9-9 9' }),
90
- back: _jsx("path", { d: 'm12 4.5-5.5 5.5 5.5 5.5' }),
91
- chevron: _jsx("path", { d: 'm7.5 4.5 5.5 5.5-5.5 5.5' }),
92
- expand: _jsx("path", { d: 'm5 7.5 5 5 5-5' }),
93
- delete: _jsx("path", { d: 'M7.5 4.5h8a1.5 1.5 0 0 1 1.5 1.5v8a1.5 1.5 0 0 1-1.5 1.5h-8L2.5 10ZM10 8l4 4m0-4-4 4' }),
94
- sliders: _jsx("path", { d: 'M4 6h6m4 0h2M4 14h2m4 0h6M12 4v4M8 12v4' }),
95
- flask: _jsx("path", { d: 'M8 3.5h4M8.75 3.5v4.75L4.5 15.5a1 1 0 0 0 .9 1.5h9.2a1 1 0 0 0 .9-1.5l-4.25-7.25V3.5M6.5 12.5h7' }),
96
- scan: _jsx("path", { d: 'M4 7V5a1 1 0 0 1 1-1h2M13 4h2a1 1 0 0 1 1 1v2M16 13v2a1 1 0 0 1-1 1h-2M7 16H5a1 1 0 0 1-1-1v-2M4 10h12' }),
97
- flame: _jsx("path", { d: 'M10 17a5 5 0 0 0 5-5c0-3-2.5-4.5-3-8-2 1-3.5 3-3.5 5.5C7.5 8.5 7 7.5 7 7c-1.5 1.5-2 3-2 5a5 5 0 0 0 5 5Z' }),
98
- logout: _jsx("path", { d: 'M8 4H5.5A1.5 1.5 0 0 0 4 5.5v9A1.5 1.5 0 0 0 5.5 16H8M12.5 6.5 16 10l-3.5 3.5M16 10H8' }),
99
- wallet: _jsx("path", { d: 'M3.5 6.5A1.5 1.5 0 0 1 5 5h9.5A1.5 1.5 0 0 1 16 6.5v.75M3.5 6.5v7A1.5 1.5 0 0 0 5 15h10.5a1 1 0 0 0 1-1V8.25a1 1 0 0 0-1-1H5a1.5 1.5 0 0 1-1.5-.75M13.25 11.25v.01' }),
100
- info: _jsx("path", { d: 'M10 17a7 7 0 1 0 0-14 7 7 0 0 0 0 14ZM10 9.5v4M10 6.5v.01' }),
101
- lock: _jsx("path", { d: 'M5.5 9h9a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1ZM7 9V6.5a3 3 0 0 1 6 0V9' }),
102
- };
103
- /** Outline symbol on a 20 unit grid; decorative, so the control that holds it carries the name. */
104
- export function SwapIcon({ name, size = 20 }) { return _jsx("svg", { className: 'hig-swap-icon', "aria-hidden": 'true', focusable: 'false', width: size, height: size, viewBox: '0 0 20 20', ...stroke, children: paths[name] }); }
106
+ const symbols = { flip: ArrowUpDown, down: ArrowDown, reset: RotateCcw, menu: Menu, close: X, back: ChevronLeft, chevron: ChevronRight, expand: ChevronDown, delete: Delete, sliders: SlidersHorizontal, flask: FlaskConical, scan: ScanLine, flame: Flame, logout: LogOut, wallet: Wallet, info: Info, lock: Lock };
107
+ /** Shared outline symbol; the containing control carries its accessible name. */
108
+ export function SwapIcon({ name, size = 20 }) { const Symbol = symbols[name]; return _jsx(Symbol, { className: 'hig-swap-icon', size: size }); }
105
109
  const chainBadge = 'hig-swap-chain-badge';
106
110
  /** Token artwork with its chain badge. */
107
111
  export function TokenIcon({ token, size = 44 }) {
108
112
  return _jsxs("span", { className: 'hig-swap-token-icon', style: { width: size, height: size }, children: [token.icon ? swapArt(token.icon, undefined, true) : _jsx("span", { "aria-hidden": 'true', children: token.symbol.slice(0, 3) }), token.chainIcon && swapArt(token.chainIcon, chainBadge, true)] });
109
113
  }
110
114
  /** Small capsule action that sits on a card: Max, Test, the slippage setting and the denomination switch. */
111
- export function SwapPill({ children, ...props }) { return _jsx("button", { type: 'button', ...props, className: 'hig-swap-pill', children: children }); }
115
+ export function SwapPill({ children, ...props }) { return _jsxs("button", { type: 'button', ...props, className: 'hig-swap-pill', children: [children, _jsx(PressDecoration, { kind: 'button', disabled: !!props.disabled })] }); }
112
116
  const keys = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '0', 'back'];
113
117
  /** Numeric keypad. Emits `0`–`9`, `.` or `back`. */
114
118
  export function SwapKeypad({ onKey, label, deleteLabel }) {
115
- return _jsx("div", { className: 'hig-swap-keypad', role: 'group', "aria-label": label, children: keys.map(key => _jsx("button", { type: 'button', className: 'hig-swap-key', "aria-label": key === 'back' ? deleteLabel : undefined, onClick: () => onKey(key), children: key === 'back' ? _jsx(SwapIcon, { name: 'delete', size: 24 }) : key }, key)) });
119
+ return _jsx("div", { className: 'hig-swap-keypad', role: 'group', "aria-label": label, children: keys.map(key => _jsxs("button", { type: 'button', className: 'hig-swap-key', "aria-label": key === 'back' ? deleteLabel : undefined, onClick: () => onKey(key), children: [key === 'back' ? _jsx(SwapIcon, { name: 'delete', size: 24 }) : key, _jsx(PressDecoration, { kind: 'button' })] }, key)) });
116
120
  }
117
121
  /** Chains present in a token list, in first-seen order. */
118
122
  export function chainsOf(tokens) { const seen = new Map(); for (const token of tokens)
@@ -122,5 +126,5 @@ export function chainsOf(tokens) { const seen = new Map(); for (const token of t
122
126
  export const parentView = (view) => view === 'slippage' || view === 'fees' ? 'settings' : 'main';
123
127
  /** Header of a pushed view: Back on the leading edge, then the title, which takes focus when the view arrives. */
124
128
  export function SwapViewHeader({ title, titleRef, backLabel, onBack }) {
125
- return _jsxs("div", { className: 'hig-swap-view-header', children: [_jsx("button", { type: 'button', className: 'hig-swap-back', "aria-label": backLabel, onClick: onBack, children: _jsx(SwapIcon, { name: 'back' }) }), _jsx("h2", { ref: titleRef, tabIndex: -1, className: 'hig-swap-view-title', children: title })] });
129
+ return _jsxs("div", { className: 'hig-swap-view-header', children: [_jsxs("button", { type: 'button', className: 'hig-swap-back', "aria-label": backLabel, onClick: onBack, children: [_jsx(SwapIcon, { name: 'back' }), _jsx(PressDecoration, { kind: 'back' })] }), _jsx("h2", { ref: titleRef, tabIndex: -1, className: 'hig-swap-view-title', children: title })] });
126
130
  }