@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
@@ -0,0 +1,85 @@
1
+ import React from 'react';
2
+ import { type PresetOption } from '../preset-group.js';
3
+ import { type ScreenHeaderControlProps } from './screen-header.js';
4
+ /** The row that opens the host's own entry of a value no quick choice holds, such as a keypad. */
5
+ export interface PresetPickerCustom {
6
+ /** The row's text: Custom amount. */
7
+ label: string;
8
+ /** Called on a press; the host opens its own entry. */
9
+ onSelect: () => void;
10
+ /** The value the host's entry set, as host text: `$75`. It is drawn on the trailing edge and the row reads as selected. */
11
+ value?: string;
12
+ /** Whether the row reads as selected. Defaults to whether `value` is given. */
13
+ selected?: boolean;
14
+ /** The row's accessible name, in place of its text: Edit custom size, current $75. */
15
+ accessibilityLabel?: string;
16
+ /** The row's `data-testid`. */
17
+ testID?: string;
18
+ }
19
+ export interface PresetPickerBlockProps<T extends string | number = number> extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
20
+ /** Heading of the header. Leave it out for a pane whose host draws its own header: the block then starts at the headline figure. */
21
+ title?: string;
22
+ /** The headline figure, the value being chosen. `null` reads as unknown. */
23
+ value: number | null;
24
+ /** Format of the headline figure, such as `{style:'currency',currency:'USD',maximumFractionDigits:0}`. */
25
+ valueOptions?: Intl.NumberFormatOptions;
26
+ /** Text drawn before the figure, such as a sign the format does not draw. */
27
+ valuePrefix?: string;
28
+ /** Text drawn after the figure, such as `×` for leverage. */
29
+ valueSuffix?: string;
30
+ /** What the figure is read as before its value: Size. */
31
+ valueLabel?: string;
32
+ /** The host's own text for the figure, in place of formatting `value` with `valueOptions`, for a host with its own number table: `$1,250.50`. Drawn static unless `animateFormatted`; `value` still decides known or unknown and the direction of a move. As `AnimatedNumberReadout` `formattedValue`. */
33
+ formattedValue?: string;
34
+ /** With `formattedValue`, rolls each of its digits in place, counted from the end, as `AnimatedNumberReadout` `animateFormatted`. */
35
+ animateFormatted?: boolean;
36
+ /** The quick choices as chips, in order: `{value, label, disabled?, testID?}`. Labels are host text: `$25`, `Max`, `40×`. */
37
+ presets: readonly PresetOption<T>[];
38
+ /** The chip shown selected; `null` selects none, such as for a custom value. */
39
+ selected: T | null;
40
+ /** Called with the chip taken. A press on the selected chip, or on a dimmed one, does nothing. */
41
+ onPresetChange: (value: T) => void;
42
+ /** Accessible name of the chips' group, not drawn: Size. Defaults to `title`. */
43
+ presetsLabel?: string;
44
+ /** Chips per row. Defaults to every chip in one row. */
45
+ columns?: number;
46
+ /** The row that opens the host's own entry, drawn above the chips. */
47
+ custom?: PresetPickerCustom;
48
+ /** Fill of the selected chip, the selected custom row and the confirming action: `primary` (the default) or `destructive`. */
49
+ intent?: 'primary' | 'destructive';
50
+ /** Drawn as given between the chips and the actions, such as a muted note. */
51
+ children?: React.ReactNode;
52
+ /** Called on the confirming action. */
53
+ onSubmit: () => void;
54
+ /** Text of the confirming action: Set Size. */
55
+ submitLabel: string;
56
+ submitDisabled?: boolean;
57
+ /** The confirming action shows a spinner and ignores presses. */
58
+ busy?: boolean;
59
+ /** Shows Cancel on the leading side of the confirming action, the two sharing the row equally. */
60
+ onCancel?: () => void;
61
+ /** Text of Cancel. Defaults to the built-in “Cancel”. */
62
+ cancelLabel?: string;
63
+ /** The confirming action's `data-testid`. */
64
+ submitTestID?: string;
65
+ /** Cancel's `data-testid`. */
66
+ cancelTestID?: string;
67
+ /** Keeps the provider's feedback off the chips and both actions, for a host that plays its own cue. */
68
+ suppressFeedback?: boolean;
69
+ /** Shows Back on the leading edge of the header (needs `title`). */
70
+ onBack?: () => void;
71
+ /** Attributes for the header's Back `<button>`. */
72
+ backProps?: ScreenHeaderControlProps;
73
+ /** A control on the trailing edge of the header, usually an `IconButton`. */
74
+ headerAction?: React.ReactNode;
75
+ /** `id` of the header's heading, so a dialog or sheet can name itself with `aria-labelledby`. */
76
+ headingId?: string;
77
+ /** Pins the header to the top of the nearest scroller. See Pinned headers. */
78
+ stickyHeader?: boolean;
79
+ }
80
+ /**
81
+ * Choose one value from quick choices: an optional header, the value as the headline figure, an optional row that opens the host's own
82
+ * entry, the choices as chips, then Cancel and the confirming action. Draws a trade sheet's Size and Leverage panes. It reuses
83
+ * TargetBlock's parts (the headline, the Custom row, PresetGroup and the actions row) without its price card and unit control.
84
+ */
85
+ export declare function PresetPickerBlock<T extends string | number = number>({ title, value, valueOptions, valuePrefix, valueSuffix, valueLabel, formattedValue, animateFormatted, presets, selected, onPresetChange, presetsLabel, columns, custom, intent, children, onSubmit, submitLabel, submitDisabled, busy, onCancel, cancelLabel, submitTestID, cancelTestID, suppressFeedback, onBack, backProps, headerAction, headingId, stickyHeader, className, ...rest }: PresetPickerBlockProps<T>): React.JSX.Element;
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as en from '@bloxwap/hig/contracts/messages';
4
+ import { PressDecoration, useHIG } from '../provider.js';
5
+ import { Button } from '../button.js';
6
+ import { PresetGroup } from '../preset-group.js';
7
+ import { AnimatedNumberReadout } from '../animated-number.js';
8
+ import { ScreenHeader } from './screen-header.js';
9
+ import { SwapIcon } from './swap/shared.js';
10
+ /**
11
+ * Choose one value from quick choices: an optional header, the value as the headline figure, an optional row that opens the host's own
12
+ * entry, the choices as chips, then Cancel and the confirming action. Draws a trade sheet's Size and Leverage panes. It reuses
13
+ * TargetBlock's parts (the headline, the Custom row, PresetGroup and the actions row) without its price card and unit control.
14
+ */
15
+ export function PresetPickerBlock({ title, value, valueOptions, valuePrefix, valueSuffix, valueLabel, formattedValue, animateFormatted, presets, selected, onPresetChange, presetsLabel, columns, custom, intent = 'primary', children, onSubmit, submitLabel, submitDisabled, busy, onCancel, cancelLabel, submitTestID, cancelTestID, suppressFeedback, onBack, backProps, headerAction, headingId, stickyHeader, className, ...rest }) {
16
+ const { messages } = useHIG();
17
+ const customSelected = custom ? (custom.selected ?? custom.value !== undefined) : false;
18
+ return _jsxs("section", { ...rest, className: `hig-preset-picker${className ? ` ${className}` : ''}`, "data-intent": intent === 'destructive' ? intent : undefined, children: [title !== undefined && _jsx(ScreenHeader, { title: title, onBack: onBack, backProps: backProps, action: headerAction, headingId: headingId, stickyHeader: stickyHeader }), _jsx("p", { className: 'hig-target-amount', children: _jsx(AnimatedNumberReadout, { value: value, options: valueOptions, formattedValue: formattedValue, animateFormatted: animateFormatted, prefix: valuePrefix, suffix: valueSuffix, label: valueLabel }) }), custom && _jsxs("button", { type: 'button', className: 'hig-swap-setting', "aria-pressed": customSelected, "aria-label": custom.accessibilityLabel, "data-testid": custom.testID, onClick: custom.onSelect, children: [_jsx("span", { children: custom.label }), custom.value !== undefined ? _jsxs("span", { className: 'hig-swap-setting-value', children: [custom.value, _jsx(SwapIcon, { name: 'chevron', size: 16 })] }) : _jsx(SwapIcon, { name: 'chevron', size: 16 }), _jsx(PressDecoration, { kind: 'row' })] }), presets.length > 0 && _jsx(PresetGroup, { label: presetsLabel ?? title, options: presets, value: selected, onValueChange: onPresetChange, columns: columns, selectedIntent: intent, suppressFeedback: suppressFeedback }), children, _jsxs("div", { className: 'hig-target-actions', children: [onCancel && _jsx(Button, { fullWidth: true, intent: 'secondary', suppressFeedback: suppressFeedback, "data-testid": cancelTestID, onClick: onCancel, children: cancelLabel ?? messages.cancel ?? en.cancel }), _jsx(Button, { fullWidth: true, intent: intent, disabled: submitDisabled, busy: busy, suppressFeedback: suppressFeedback, "data-testid": submitTestID, onClick: onSubmit, children: submitLabel })] })] });
19
+ }
@@ -1,18 +1,23 @@
1
1
  import React from 'react';
2
+ import { type Figure } from '../figure.js';
2
3
  import type { AssetArtwork } from '../asset-balance-row.js';
4
+ /** A row value that can change while the profile is shown, such as a balance: formatted with `options` between `prefix` and `suffix`, and updated place by place. `null` reads as unknown. */
5
+ export type ProfileFigure = Figure;
3
6
  /** One row of a profile section. With `onSelect` it opens something and shows a chevron; with `onCheckedChange` it is a switch. */
4
7
  export interface ProfileRow {
5
8
  id: string;
6
9
  label: string;
7
10
  /** Artwork before the label, such as an icon. */
8
11
  leading?: React.ReactNode;
9
- /** Short text on the trailing edge, such as a balance or `Off`. */
10
- value?: React.ReactNode;
12
+ /** Short text on the trailing edge, such as a balance or `Off`, or a live figure that updates place by place. */
13
+ value?: React.ReactNode | ProfileFigure;
14
+ /** Colours the value. Without it the value keeps the row's muted value style. */
15
+ tone?: 'positive' | 'warning' | 'negative' | 'muted';
11
16
  /** Anything richer on the trailing edge: icons or a `Badge`. */
12
17
  trailing?: React.ReactNode;
13
18
  onSelect?: () => void;
14
19
  disabled?: boolean;
15
- /** With `onCheckedChange`, the row is a switch: the track trails and the label names it. */
20
+ /** With `onCheckedChange`, the row is a switch: the track trails, the label names it, and a press anywhere on the row toggles it. */
16
21
  checked?: boolean;
17
22
  onCheckedChange?: (checked: boolean) => void;
18
23
  }
@@ -28,13 +33,27 @@ export interface ProfileStatus {
28
33
  label: string;
29
34
  tone?: 'positive' | 'warning' | 'negative' | 'info';
30
35
  }
36
+ /** The primary action under the name, such as Log in for a signed-out viewer. The host writes the label. */
37
+ export interface ProfileAction {
38
+ label: string;
39
+ onSelect: () => void;
40
+ disabled?: boolean;
41
+ /** Defaults to `primary`. */
42
+ intent?: 'primary' | 'secondary';
43
+ }
31
44
  export interface ProfileBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
32
- /** The name under the avatar: a display name or a shortened address. */
33
- name: string;
45
+ /** The name under the avatar: a display name or a shortened address. It may be left out when `action` is set, for a signed-out viewer. */
46
+ name?: string;
47
+ /** Host content beside the name, such as a badge. It stays in the accessibility tree, so give an interactive badge its own name. */
48
+ nameAccessory?: React.ReactNode;
34
49
  /** Colours the avatar when there is no artwork. */
35
50
  address?: string;
36
51
  /** An image URL or an element the host draws. */
37
52
  avatar?: AssetArtwork;
53
+ /** Makes the avatar a button, for example to choose a picture. `avatarLabel` names it. */
54
+ onAvatarPress?: () => void;
55
+ /** The accessible name of the avatar button, such as Change profile picture. Defaults to `name`, then the built-in “Change profile picture”. */
56
+ avatarLabel?: string;
38
57
  status?: ProfileStatus;
39
58
  /** Shows the edit control after the name. */
40
59
  onEditName?: () => void;
@@ -42,7 +61,15 @@ export interface ProfileBlockProps extends Omit<React.HTMLAttributes<HTMLElement
42
61
  onShowAddress?: () => void;
43
62
  /** Shows Close on the trailing edge of the top bar. */
44
63
  onClose?: () => void;
64
+ /** A full-width button under the name, such as Log in. */
65
+ action?: ProfileAction;
45
66
  sections: readonly ProfileSection[];
67
+ /** Host content under the sections, such as legal links. */
68
+ footer?: React.ReactNode;
69
+ /** Pins the top bar (address and Close) to the top of the nearest scroller, transparent at rest and filled once content scrolls under it, without moving when it starts to stick. See Pinned headers. */
70
+ stickyHeader?: boolean;
71
+ /** `id` of the name heading, so a host dialog or sheet can name itself with `aria-labelledby`. */
72
+ headingId?: string;
46
73
  }
47
74
  /** A person's profile as one screen: who they are (avatar, status, name), then grouped rows that open their accounts, history, rewards and settings. */
48
- export declare function ProfileBlock({ name, address, avatar, status, onEditName, onShowAddress, onClose, sections, className, ...rest }: ProfileBlockProps): React.JSX.Element;
75
+ export declare function ProfileBlock({ name, nameAccessory, address, avatar, onAvatarPress, avatarLabel, status, onEditName, onShowAddress, onClose, action, sections, footer, stickyHeader, headingId, className, ...rest }: ProfileBlockProps): React.JSX.Element;
@@ -1,15 +1,40 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { PenLine } from '@bloxwap/icons/react/pen-line';
4
+ import React, { useRef } from 'react';
3
5
  import * as en from '@bloxwap/hig/contracts/messages';
4
- import { useHIG } from '../provider.js';
5
- import { IconButton } from '../button.js';
6
- import { Switch } from '../selection.js';
6
+ import { PressDecoration, useHIG } from '../provider.js';
7
+ import { useStickyHeader } from './sticky-header.js';
8
+ import { Button, IconButton } from '../button.js';
7
9
  import { ListGroup, ListRow } from '../list-group.js';
10
+ import { AnimatedNumberReadout } from '../animated-number.js';
11
+ import { figureProps } from '../figure.js';
8
12
  import { qrIcon } from './screen-header.js';
9
13
  import { SwapIcon, addressGradient } from './swap/shared.js';
10
- const editIcon = _jsx("svg", { "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', width: '20', height: '20', fill: 'none', stroke: 'currentColor', strokeWidth: '1.6', strokeLinecap: 'round', strokeLinejoin: 'round', children: _jsx("path", { d: 'M12.5 4.5 15.5 7.5 7.5 15.5H4.5V12.5ZM10.5 15.5H16' }) });
14
+ const editIcon = _jsx(PenLine, { size: 20 });
15
+ /** True for a `ProfileFigure`: a plain object with a `value`, not an element, array or other node. */
16
+ const isProfileFigure = (value) => value != null && typeof value === 'object' && !React.isValidElement(value) && !Array.isArray(value) && !(Symbol.iterator in value) && 'value' in value;
17
+ function rowValue(row) {
18
+ const { value, tone } = row;
19
+ if (value == null)
20
+ return value;
21
+ if (isProfileFigure(value))
22
+ return _jsx("span", { className: 'hig-profile-value', "data-tone": tone, children: _jsx(AnimatedNumberReadout, { ...figureProps(value) }) });
23
+ return tone ? _jsx("span", { className: 'hig-profile-value', "data-tone": tone, children: value }) : value;
24
+ }
25
+ /**
26
+ * A switch row whose whole row is the target: `ListRow`'s switch row. A press anywhere outside the switch toggles it, the switch
27
+ * input stays the one named control, named by the visible label (so the name is read once), and the host's press decoration
28
+ * covers the whole row.
29
+ */
30
+ function ProfileSwitchRow({ row }) {
31
+ return _jsx(ListRow, { label: row.label, leading: row.leading, value: rowValue(row), disabled: row.disabled, checked: !!row.checked, onCheckedChange: row.onCheckedChange });
32
+ }
11
33
  /** A person's profile as one screen: who they are (avatar, status, name), then grouped rows that open their accounts, history, rewards and settings. */
12
- export function ProfileBlock({ name, address, avatar, status, onEditName, onShowAddress, onClose, sections, className, ...rest }) {
34
+ export function ProfileBlock({ name, nameAccessory, address, avatar, onAvatarPress, avatarLabel, status, onEditName, onShowAddress, onClose, action, sections, footer, stickyHeader, headingId, className, ...rest }) {
13
35
  const { messages } = useHIG();
14
- return _jsxs("section", { ...rest, className: `hig-profile-block${className ? ` ${className}` : ''}`, children: [_jsxs("div", { className: 'hig-profile-bar', children: [_jsx("span", { children: onShowAddress && _jsx(IconButton, { intent: 'ghost', label: messages.showAddress ?? en.showAddress, onClick: onShowAddress, children: qrIcon }) }), _jsx("span", { children: onClose && _jsx(IconButton, { intent: 'ghost', label: messages.close ?? en.close, onClick: onClose, children: _jsx(SwapIcon, { name: 'close' }) }) })] }), _jsxs("div", { className: 'hig-profile-identity', children: [_jsxs("span", { className: 'hig-profile-avatar', style: avatar == null && address ? { background: addressGradient(address) } : undefined, children: [_jsx("span", { className: 'hig-profile-artwork', "aria-hidden": 'true', children: typeof avatar === 'string' ? _jsx("img", { src: avatar, alt: '' }) : avatar ?? (address ? null : name.slice(0, 2)) }), status && _jsx("span", { className: 'hig-profile-status', "data-tone": status.tone ?? 'warning', children: _jsx("span", { className: 'hig-sr-only', children: status.label }) })] }), _jsxs("div", { className: 'hig-profile-name', children: [_jsx("h2", { children: name }), onEditName && _jsx(IconButton, { intent: 'ghost', label: messages.editName ?? en.editName, onClick: onEditName, children: editIcon })] })] }), sections.filter(section => section.rows.length > 0).map(section => _jsx(ListGroup, { title: section.title, children: section.rows.map(row => _jsx(ListRow, { label: row.label, leading: row.leading, value: row.value, disabled: row.disabled, onSelect: row.onCheckedChange ? undefined : row.onSelect, trailing: row.onCheckedChange ? _jsx(Switch, { label: row.label, checked: !!row.checked, disabled: row.disabled, onCheckedChange: row.onCheckedChange }) : row.trailing }, row.id)) }, section.id))] });
36
+ const bar = useRef(null);
37
+ useStickyHeader(bar, !!stickyHeader);
38
+ const artwork = typeof avatar === 'string' ? _jsx("img", { src: avatar, alt: '' }) : avatar ?? (address ? null : name?.slice(0, 2));
39
+ return _jsxs("section", { ...rest, className: `hig-profile-block${className ? ` ${className}` : ''}`, children: [_jsxs("div", { ref: bar, className: 'hig-profile-bar', "data-sticky": stickyHeader || undefined, children: [_jsx("span", { children: onShowAddress && _jsx(IconButton, { intent: 'ghost', label: messages.showAddress ?? en.showAddress, onClick: onShowAddress, children: qrIcon }) }), _jsx("span", { children: onClose && _jsx(IconButton, { intent: 'ghost', label: messages.close ?? en.close, onClick: onClose, children: _jsx(SwapIcon, { name: 'close' }) }) })] }), _jsxs("div", { className: 'hig-profile-identity', children: [_jsxs("span", { className: 'hig-profile-avatar', style: avatar == null && address ? { background: addressGradient(address) } : undefined, children: [onAvatarPress ? _jsxs("button", { type: 'button', className: 'hig-profile-artwork', "aria-label": avatarLabel ?? name ?? messages.changeProfilePicture ?? en.changeProfilePicture, onClick: onAvatarPress, children: [artwork, _jsx(PressDecoration, { kind: 'icon-button' })] }) : _jsx("span", { className: 'hig-profile-artwork', "aria-hidden": 'true', children: artwork }), status && _jsx("span", { className: 'hig-profile-status', "data-tone": status.tone ?? 'warning', children: _jsx("span", { className: 'hig-sr-only', children: status.label }) })] }), name != null && _jsxs("div", { className: 'hig-profile-name', children: [_jsx("h2", { id: headingId, children: name }), nameAccessory != null && _jsx("span", { className: 'hig-profile-name-accessory', children: nameAccessory }), onEditName && _jsx(IconButton, { intent: 'ghost', label: messages.editName ?? en.editName, onClick: onEditName, children: editIcon })] }), action && _jsx(Button, { className: 'hig-profile-action', fullWidth: true, intent: action.intent ?? 'primary', disabled: action.disabled, onClick: action.onSelect, children: action.label })] }), sections.filter(section => section.rows.length > 0).map(section => _jsx(ListGroup, { title: section.title, children: section.rows.map(row => row.onCheckedChange ? _jsx(ProfileSwitchRow, { row: row }, row.id) : _jsx(ListRow, { label: row.label, leading: row.leading, value: rowValue(row), disabled: row.disabled, onSelect: row.onSelect, trailing: row.trailing }, row.id)) }, section.id)), footer != null && _jsx("div", { className: 'hig-profile-footer', children: footer })] });
15
40
  }
@@ -1,32 +1,43 @@
1
1
  import React from 'react';
2
+ import { type Figure } from '../figure.js';
2
3
  import type { AssetArtwork } from '../asset-balance-row.js';
4
+ /** A way onward from the promotion. `href` draws a real link (an `<a>`), with `target` such as `_blank`; `onSelect` is still called on the press. */
5
+ export type RewardLink = {
6
+ label: string;
7
+ onSelect: () => void;
8
+ href?: undefined;
9
+ target?: undefined;
10
+ } | {
11
+ label: string;
12
+ href: string;
13
+ target?: string;
14
+ onSelect?: () => void;
15
+ };
3
16
  /** The promotion above the standings: a prize pool filling towards a goal, or a draw with a top prize. Every word is host text. */
4
17
  export interface RewardPromo {
5
18
  /** The small capitals line: Season 01. */
6
19
  eyebrow: string;
7
20
  /** A text link with a chevron on the trailing edge of the eyebrow: Rules. */
8
- rules?: {
9
- label: string;
10
- onSelect: () => void;
11
- };
12
- /** The headline figure: the pool so far, or the top prize. `null` reads as unknown. */
13
- amount: number | null;
14
- /** Format of `amount` and `goal`. Defaults to whole US dollars. */
21
+ rules?: RewardLink;
22
+ /** The headline figure: the pool so far, or the top prize. A number updates place by place, formatted with `amountOptions`; `null` reads as unknown; a string is host text drawn as given in the same style, such as `$500` already formatted. Leave it out (with no `figure`) for a promotion with no figure. */
23
+ amount?: number | null | string;
24
+ /** Host content drawn in the headline figure's place and type, in place of `amount`, such as the host's own live figure. */
25
+ figure?: React.ReactNode;
26
+ /** Format of a number `amount` and of `goal`. Defaults to whole US dollars. */
15
27
  amountOptions?: Intl.NumberFormatOptions;
16
- /** The amount the pool is filling towards. Draws the progress bar under the caption. */
28
+ /** The amount the pool is filling towards. Draws the progress bar under the caption (full only against a number `amount`). */
17
29
  goal?: number;
18
- /** The line under the figure. A function receives the formatted goal: `goal => 'of ' + goal + ' prize pool'`. A string is drawn as given: top prize. */
19
- caption?: string | ((goal: string) => string);
20
- /** The lead of the explaining sentence, in the text colour: Top 100 traders split the pool. */
21
- headline?: string;
30
+ /** The line under the figure. A function receives the formatted goal: `goal => 'of ' + goal + ' prize pool'`. A string is drawn as given: top prize. Any other node is drawn as given, such as a live countdown. */
31
+ caption?: React.ReactNode | ((goal: string) => React.ReactNode);
32
+ /** The lead of the explaining sentence, in the text colour: Top 100 traders split the pool. Host text, or host elements for an accented word. */
33
+ headline?: React.ReactNode;
22
34
  /** Continues the sentence after the headline in the muted colour: Funded by builder fees on every trade. */
23
35
  description?: string;
24
36
  /** A quiet row under a hairline at the foot of the card, with a chevron on its trailing edge: Draws and winners. The host opens its own destination. */
25
- action?: {
26
- label: string;
27
- onSelect: () => void;
28
- };
37
+ action?: RewardLink;
29
38
  }
39
+ /** A host figure that updates place by place: `{value:1090779, options:{style:'currency',currency:'USD',maximumFractionDigits:0}, suffix:' vol'}`. */
40
+ export type RewardFigure = Figure;
30
41
  /** One trader in the standings. */
31
42
  export interface RewardEntry {
32
43
  id: string;
@@ -37,13 +48,21 @@ export interface RewardEntry {
37
48
  avatar?: AssetArtwork;
38
49
  /** Shows the verified mark after the name. */
39
50
  verified?: boolean;
40
- /** The line under the name: `$1,090,779 vol`. */
41
- detail?: string;
51
+ /** The line under the name: `$1,090,779 vol` as text, or the same as a live figure. */
52
+ detail?: string | RewardFigure;
42
53
  /** Points or entries. `null` reads as unknown. */
43
54
  score: number | null;
55
+ /** Format of this entry's score, in place of the block's `scoreOptions`, for a prize list where some amounts have cents. */
56
+ scoreOptions?: Intl.NumberFormatOptions;
44
57
  /** Marks the viewer's own row: the name and score take the action colour. */
45
58
  you?: boolean;
46
59
  }
60
+ /** One step of the paging control under the list. */
61
+ export interface RewardPageStep {
62
+ label: string;
63
+ onSelect: () => void;
64
+ disabled?: boolean;
65
+ }
47
66
  export interface RewardBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
48
67
  /** Heading: Leaderboard. */
49
68
  title: string;
@@ -60,22 +79,47 @@ export interface RewardBlockProps extends Omit<React.HTMLAttributes<HTMLElement>
60
79
  };
61
80
  /** The viewer's own standing, pinned above the list on a tinted row. */
62
81
  you?: RewardEntry;
82
+ /** Names the pinned row for assistive technology: Your rank. */
83
+ youLabel?: string;
84
+ /** A muted line between the pinned row and the list, announced when it changes: You're not ranked yet. */
85
+ status?: string;
63
86
  /** The column heading over the names: Top 25 by volume. */
64
87
  listTitle?: string;
65
88
  /** The column heading over the scores: Entries. */
66
89
  scoreTitle?: string;
67
- entries: readonly RewardEntry[];
68
- /** Format of every score. Defaults to a whole number. */
90
+ /** The standings, in order. Leave them out for a promotion-only pane: no list is drawn. */
91
+ entries?: readonly RewardEntry[];
92
+ /** Format of every score. Defaults to a whole number. An entry's own `scoreOptions` wins. */
69
93
  scoreOptions?: Intl.NumberFormatOptions;
70
94
  /** Accessible name of the verified mark. The mark is decorative without it. */
71
95
  verifiedLabel?: string;
96
+ /** Host artwork in place of the built-in verified mark, drawn inside the mark's image role. */
97
+ verifiedMark?: React.ReactNode;
98
+ /** 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. */
99
+ verifiedMarkInteractive?: boolean;
100
+ /** Draws skeleton rows in place of the entries while the host loads them. */
101
+ loading?: boolean;
102
+ /** Host text that names the skeleton rows for assistive technology and announces them: Loading standings. Without it the block is only marked busy. */
103
+ loadingLabel?: string;
104
+ /** Paging under the list: Previous and Next as buttons with the host's range between them, such as 1–25. */
105
+ pagination?: {
106
+ previous?: RewardPageStep;
107
+ next?: RewardPageStep;
108
+ label?: string;
109
+ };
72
110
  /** A line under the list: Entries are provisional until audited. */
73
111
  footnote?: string;
74
112
  onBack?: () => void;
75
113
  /** A control on the trailing edge of the header, usually an `IconButton` that shares. */
76
114
  headerAction?: React.ReactNode;
115
+ /** `id` of the header's heading, so a host dialog or sheet can name itself with `aria-labelledby`. */
116
+ headingId?: string;
117
+ /** Keeps the header pinned to the top of the scrolling container. It is transparent at rest and fills with `--hig-sticky-header-background` (`--hig-background` by default) once the standings scroll under it; inside a sheet remap it, for example `--hig-sticky-header-background: var(--hig-overlay)`. */
118
+ stickyHeader?: boolean;
119
+ /** Set false to leave the header out, when the host pins its own `ScreenHeader` above the block. */
120
+ header?: boolean;
77
121
  }
78
122
  /** The share of the goal reached, from 0 to 1. Unknown amounts and goals that are not above zero give `null`. */
79
123
  export declare function rewardProgress(amount: number | null | undefined, goal: number | null | undefined): number | null;
80
124
  /** A competition as a screen: an optional promotion (a prize pool filling towards its goal, or a draw with its top prize), an optional choice of standings, the viewer's own standing pinned on a tinted row, and the ranked list. */
81
- export declare function RewardBlock({ title, promo, tabs, you, listTitle, scoreTitle, entries, scoreOptions, verifiedLabel, footnote, onBack, headerAction, className, ...rest }: RewardBlockProps): React.JSX.Element;
125
+ export declare function RewardBlock({ title, promo, tabs, you, youLabel, status, listTitle, scoreTitle, entries, scoreOptions, verifiedLabel, verifiedMark, verifiedMarkInteractive, loading, loadingLabel, pagination, footnote, onBack, headerAction, stickyHeader, headingId, header, className, ...rest }: RewardBlockProps): React.JSX.Element;
@@ -1,24 +1,37 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { CircleCheck } from '@bloxwap/icons/react/circle-check';
3
4
  import { formatNumber } from '@bloxwap/hig/contracts';
4
- import { useHIG } from '../provider.js';
5
+ import { PressDecoration, usePresentNumber, useNumberLocale } from '../provider.js';
6
+ import { figureProps } from '../figure.js';
5
7
  import { SegmentedControl } from '../selection.js';
8
+ import { Button } from '../button.js';
6
9
  import { AnimatedNumberReadout } from '../animated-number.js';
7
10
  import { ScreenHeader } from './screen-header.js';
8
- import { SwapIcon } from './swap/shared.js';
11
+ import { SwapIcon, SwapNumber } from './swap/shared.js';
9
12
  const wholeDollars = { style: 'currency', currency: 'USD', maximumFractionDigits: 0 }, whole = { maximumFractionDigits: 0 };
13
+ const noEntries = [];
14
+ const skeletons = [0, 1, 2, 3, 4];
10
15
  /** The share of the goal reached, from 0 to 1. Unknown amounts and goals that are not above zero give `null`. */
11
16
  export function rewardProgress(amount, goal) {
12
17
  return amount == null || goal == null || !Number.isFinite(amount) || !Number.isFinite(goal) || !(goal > 0) ? null : Math.min(1, Math.max(0, amount / goal));
13
18
  }
14
- const verifiedMark = _jsxs("svg", { className: 'hig-reward-verified-mark', "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' })] });
15
- function Standing({ entry, scoreOptions, verifiedLabel, as: Tag = 'li' }) {
16
- return _jsxs(Tag, { className: 'hig-reward-row', "data-you": entry.you || undefined, children: [_jsx("span", { className: 'hig-reward-rank hig-number', children: entry.rank }), _jsx("span", { className: 'hig-reward-avatar', "aria-hidden": 'true', children: typeof entry.avatar === 'string' ? _jsx("img", { src: entry.avatar, alt: '' }) : entry.avatar ?? entry.name.slice(0, 2) }), _jsxs("span", { className: 'hig-reward-identity', children: [_jsxs("strong", { className: 'hig-number', children: [entry.name, entry.verified && _jsx("span", { className: 'hig-reward-verified', role: verifiedLabel ? 'img' : undefined, "aria-label": verifiedLabel, children: verifiedMark })] }), entry.detail && _jsx("span", { className: 'hig-number', children: entry.detail })] }), _jsx("span", { className: 'hig-reward-score', children: _jsx(AnimatedNumberReadout, { value: entry.score, options: scoreOptions }) })] });
19
+ const verifiedGlyph = _jsx(CircleCheck, { size: 16, className: 'hig-reward-verified-mark' });
20
+ function Standing({ entry, scoreOptions, verifiedLabel, verifiedMark, verifiedMarkInteractive, as: Tag = 'li' }) {
21
+ const detail = entry.detail;
22
+ return _jsxs(Tag, { className: 'hig-reward-row', "data-you": entry.you || undefined, children: [_jsx("span", { className: 'hig-reward-rank hig-number', children: entry.rank }), _jsx("span", { className: 'hig-reward-avatar', "aria-hidden": 'true', children: typeof entry.avatar === 'string' ? _jsx("img", { src: entry.avatar, alt: '' }) : entry.avatar ?? entry.name.slice(0, 2) }), _jsxs("span", { className: 'hig-reward-identity', children: [_jsxs("strong", { className: 'hig-number', children: [entry.name, entry.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 }))] }), detail != null && detail !== '' && _jsx("span", { className: 'hig-number', children: typeof detail === 'string' ? detail : _jsx(SwapNumber, { ...figureProps(detail) }) })] }), _jsx("span", { className: 'hig-reward-score', children: _jsx(AnimatedNumberReadout, { value: entry.score, options: entry.scoreOptions ?? scoreOptions }) })] });
23
+ }
24
+ function Onward({ link, className, children }) {
25
+ return link.href !== undefined ? _jsxs("a", { className: className, href: link.href, target: link.target, rel: link.target === '_blank' ? 'noopener noreferrer' : undefined, onClick: link.onSelect, children: [children, _jsx(PressDecoration, { kind: 'row' })] })
26
+ : _jsxs("button", { type: 'button', className: className, onClick: link.onSelect, children: [children, _jsx(PressDecoration, { kind: 'row' })] });
17
27
  }
18
28
  /** A competition as a screen: an optional promotion (a prize pool filling towards its goal, or a draw with its top prize), an optional choice of standings, the viewer's own standing pinned on a tinted row, and the ranked list. */
19
- export function RewardBlock({ title, promo, tabs, you, listTitle, scoreTitle, entries, scoreOptions = whole, verifiedLabel, footnote, onBack, headerAction, className, ...rest }) {
20
- const { locale } = useHIG();
21
- const money = promo?.amountOptions ?? wholeDollars, share = promo ? rewardProgress(promo.amount, promo.goal) : null;
22
- const caption = typeof promo?.caption === 'function' ? promo.goal !== undefined ? promo.caption(formatNumber(promo.goal, locale, money)) : undefined : promo?.caption;
23
- return _jsxs("section", { ...rest, className: `hig-reward-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: title, onBack: onBack, action: headerAction }), promo && _jsxs("section", { className: 'hig-surface hig-reward-promo', children: [_jsxs("div", { className: 'hig-reward-promo-top', children: [_jsx("span", { className: 'hig-reward-eyebrow hig-number', children: promo.eyebrow }), promo.rules && _jsxs("button", { type: 'button', className: 'hig-reward-rules', onClick: promo.rules.onSelect, children: [promo.rules.label, _jsx(SwapIcon, { name: 'chevron', size: 16 })] })] }), _jsx("p", { className: 'hig-reward-amount', children: _jsx(AnimatedNumberReadout, { value: promo.amount, options: money }) }), caption && _jsx("p", { className: 'hig-reward-caption hig-number', children: caption }), promo.goal !== undefined && _jsx("div", { className: 'hig-reward-track', "aria-hidden": 'true', children: _jsx("span", { style: { width: `${(share ?? 0) * 100}%` } }) }), (promo.headline || promo.description) && _jsxs("p", { className: 'hig-reward-summary', children: [promo.headline && _jsx("strong", { children: promo.headline }), promo.headline && promo.description ? ' ' : null, promo.description] }), promo.action && _jsxs("button", { type: 'button', className: 'hig-reward-action', onClick: promo.action.onSelect, children: [_jsx("span", { children: promo.action.label }), _jsx(SwapIcon, { name: 'chevron', size: 16 })] })] }), tabs && _jsx(SegmentedControl, { label: tabs.label, options: tabs.options, value: tabs.value, onValueChange: tabs.onValueChange }), you && _jsx("div", { className: 'hig-reward-you', children: _jsx(Standing, { as: 'div', entry: { ...you, you: true }, scoreOptions: scoreOptions, verifiedLabel: verifiedLabel }) }), (entries.length > 0 || listTitle || scoreTitle) && _jsxs("div", { className: 'hig-reward-list', children: [(listTitle || scoreTitle) && _jsxs("div", { className: 'hig-reward-columns hig-number', children: [_jsx("span", { children: listTitle }), _jsx("span", { children: scoreTitle })] }), entries.length > 0 && _jsx("ol", { className: 'hig-reward-rows', children: entries.map(entry => _jsx(Standing, { entry: entry, scoreOptions: scoreOptions, verifiedLabel: verifiedLabel }, entry.id)) })] }), footnote && _jsx("p", { className: 'hig-reward-footnote', children: footnote })] });
29
+ export function RewardBlock({ title, promo, tabs, you, youLabel, status, listTitle, scoreTitle, entries = noEntries, scoreOptions = whole, verifiedLabel, verifiedMark, verifiedMarkInteractive, loading, loadingLabel, pagination, footnote, onBack, headerAction, stickyHeader, headingId, header = true, className, ...rest }) {
30
+ const locale = useNumberLocale();
31
+ const present = usePresentNumber();
32
+ const amount = promo?.amount, money = promo?.amountOptions ?? wholeDollars, share = promo ? rewardProgress(typeof amount === 'string' ? null : amount, promo.goal) : null;
33
+ const caption = typeof promo?.caption === 'function' ? promo.goal !== undefined ? promo.caption(formatNumber(promo.goal, locale, present(money))) : undefined : promo?.caption;
34
+ const figure = promo?.figure != null && promo.figure !== false ? promo.figure : amount === undefined ? null : typeof amount === 'string' ? amount : _jsx(AnimatedNumberReadout, { value: amount, options: money });
35
+ const pinned = you && _jsx(Standing, { as: 'div', entry: { ...you, you: true }, scoreOptions: scoreOptions, verifiedLabel: verifiedLabel, verifiedMark: verifiedMark, verifiedMarkInteractive: verifiedMarkInteractive });
36
+ return _jsxs("section", { ...rest, className: `hig-reward-block${className ? ` ${className}` : ''}`, children: [header && _jsx(ScreenHeader, { title: title, onBack: onBack, action: headerAction, headingId: headingId, stickyHeader: stickyHeader }), promo && _jsxs("section", { className: 'hig-surface hig-reward-promo', children: [_jsxs("div", { className: 'hig-reward-promo-top', children: [_jsx("span", { className: 'hig-reward-eyebrow hig-number', children: promo.eyebrow }), promo.rules && _jsxs(Onward, { link: promo.rules, className: 'hig-reward-rules', children: [promo.rules.label, _jsx(SwapIcon, { name: 'chevron', size: 16 })] })] }), figure != null && (promo.figure != null && promo.figure !== false ? _jsx("div", { className: 'hig-reward-amount', children: figure }) : _jsx("p", { className: 'hig-reward-amount', children: figure })), caption != null && caption !== false && caption !== '' && (typeof caption === 'string' || typeof caption === 'number' ? _jsx("p", { className: 'hig-reward-caption hig-number', children: caption }) : _jsx("div", { className: 'hig-reward-caption hig-number', children: caption })), promo.goal !== undefined && _jsx("div", { className: 'hig-reward-track', "aria-hidden": 'true', children: _jsx("span", { style: { width: `${(share ?? 0) * 100}%` } }) }), (promo.headline || promo.description) && _jsxs("p", { className: 'hig-reward-summary', children: [promo.headline && _jsx("strong", { children: promo.headline }), promo.headline && promo.description ? ' ' : null, promo.description] }), promo.action && _jsxs(Onward, { link: promo.action, className: 'hig-reward-action', children: [_jsx("span", { children: promo.action.label }), _jsx(SwapIcon, { name: 'chevron', size: 16 })] })] }), tabs && _jsx(SegmentedControl, { label: tabs.label, options: tabs.options, value: tabs.value, onValueChange: tabs.onValueChange }), pinned && (youLabel ? _jsx("div", { className: 'hig-reward-you', role: 'group', "aria-label": youLabel, children: pinned }) : _jsx("div", { className: 'hig-reward-you', children: pinned })), status && _jsx("p", { className: 'hig-reward-status', role: 'status', children: status }), loading ? _jsxs(_Fragment, { children: [loadingLabel && _jsx("p", { className: 'hig-sr-only', role: 'status', children: loadingLabel }), _jsx("div", { className: 'hig-reward-list', "aria-busy": 'true', children: skeletons.map(index => _jsx("div", { className: 'hig-skeleton hig-reward-skeleton', "aria-hidden": 'true' }, index)) })] }) : (entries.length > 0 || listTitle || scoreTitle) && _jsxs("div", { className: 'hig-reward-list', children: [(listTitle || scoreTitle) && _jsxs("div", { className: 'hig-reward-columns hig-number', children: [_jsx("span", { children: listTitle }), _jsx("span", { children: scoreTitle })] }), entries.length > 0 && _jsx("ol", { className: 'hig-reward-rows', children: entries.map(entry => _jsx(Standing, { entry: entry, scoreOptions: scoreOptions, verifiedLabel: verifiedLabel, verifiedMark: verifiedMark, verifiedMarkInteractive: verifiedMarkInteractive }, entry.id)) })] }), pagination && _jsxs("div", { className: 'hig-reward-pagination', children: [pagination.previous ? _jsx(Button, { intent: 'secondary', disabled: pagination.previous.disabled, onClick: pagination.previous.onSelect, children: pagination.previous.label }) : _jsx("span", {}), pagination.label ? _jsx("span", { className: 'hig-reward-page hig-number', "aria-live": 'polite', children: pagination.label }) : _jsx("span", {}), pagination.next ? _jsx(Button, { intent: 'secondary', disabled: pagination.next.disabled, onClick: pagination.next.onSelect, children: pagination.next.label }) : _jsx("span", {})] }), footnote && _jsx("p", { className: 'hig-reward-footnote', children: footnote })] });
24
37
  }
@@ -1,9 +1,41 @@
1
1
  import React from 'react';
2
- /** Header of a card that is its own screen: Back on the leading edge, the title centred, and an optional control on the trailing edge. The title stays centred with either, both or neither. */
3
- export declare function ScreenHeader({ title, onBack, action }: {
2
+ /** Attributes passed through to a header control's `<button>`, such as a data attribute or a pointer handler. HIG keeps its own type, class, name and click. */
3
+ export type ScreenHeaderControlProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type' | 'className' | 'onClick' | 'aria-label' | 'children' | 'disabled'>;
4
+ export interface ScreenHeaderProps {
5
+ /** The heading, centred. Host text. */
4
6
  title: string;
7
+ /** Shows Back on the leading edge. */
5
8
  onBack?: () => void;
9
+ /** Draws Back unavailable: dimmed, `disabled` and not pressable, for example while a close is being signed. */
10
+ backDisabled?: boolean;
11
+ /** Attributes for the Back `<button>`. */
12
+ backProps?: ScreenHeaderControlProps;
13
+ /** A control on the trailing edge, usually an `IconButton`. */
6
14
  action?: React.ReactNode;
15
+ /** `id` of the heading, so a dialog or sheet can name itself with `aria-labelledby` instead of repeating the title. */
16
+ headingId?: string;
17
+ /** Short host text in a badge beside the title, read as part of the heading after a pause: Demo. */
18
+ badge?: string;
19
+ /** A kicker over the title, centred in small muted capitals: Builder fee. Host text, read before the heading as its own line. The header grows to fit it. */
20
+ eyebrow?: string;
21
+ /** Hides the title visually while it stays the accessible heading, for a host that draws its own visible title and must not have it read twice. The header keeps its height and its two sides. */
22
+ hideTitle?: boolean;
23
+ /** Host text that describes the pane, never drawn and read after the heading: a visually hidden paragraph that follows it, `id` `<headingId>-description` when `headingId` is set, so a dialog can point `aria-describedby` at it. */
24
+ description?: string;
25
+ /** Pins the header to the top of the nearest scrolling container. It is transparent at rest and takes its fill (`--hig-sticky-header-background`) only once content has scrolled under it. */
26
+ stickyHeader?: boolean;
27
+ }
28
+ /** Attributes for a header Close `<button>`: those of `ScreenHeaderControlProps`, plus `disabled`, which draws Close unavailable (dimmed, `disabled`, not pressable), for example while the pane's action is being signed. */
29
+ export type HeaderCloseProps = ScreenHeaderControlProps & {
30
+ disabled?: boolean;
31
+ };
32
+ /** The block header's Close control, shared by the blocks that draw one. */
33
+ export declare function HeaderClose({ onClose, label, closeProps }: {
34
+ onClose: () => void;
35
+ label: string;
36
+ closeProps?: HeaderCloseProps;
7
37
  }): React.JSX.Element;
38
+ /** Header of a card that is its own screen: Back on the leading edge, the title centred, and an optional control on the trailing edge. The title stays centred with either, both or neither. Every block draws it; import it from `@bloxwap/hig/react/blocks/screen-header` for a host pane that has no block. */
39
+ export declare function ScreenHeader({ title, onBack, backDisabled, backProps, action, headingId, badge, eyebrow, hideTitle, description, stickyHeader }: ScreenHeaderProps): React.JSX.Element;
8
40
  /** The QR glyph of a control that shows an address. */
9
41
  export declare const qrIcon: React.JSX.Element;
@@ -1,12 +1,23 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { QrCode } from '@bloxwap/icons/react/qr-code';
4
+ import { useRef } from 'react';
3
5
  import * as en from '@bloxwap/hig/contracts/messages';
4
- import { useHIG } from '../provider.js';
6
+ import { PressDecoration, useHIG } from '../provider.js';
5
7
  import { SwapIcon } from './swap/shared.js';
6
- /** Header of a card that is its own screen: Back on the leading edge, the title centred, and an optional control on the trailing edge. The title stays centred with either, both or neither. */
7
- export function ScreenHeader({ title, onBack, action }) {
8
+ import { useStickyHeader } from './sticky-header.js';
9
+ /** The block header's Close control, shared by the blocks that draw one. */
10
+ export function HeaderClose({ onClose, label, closeProps }) {
11
+ const off = !!closeProps?.disabled;
12
+ return _jsxs("button", { ...closeProps, type: 'button', className: 'hig-swap-back', "aria-label": label, disabled: off || undefined, onClick: onClose, children: [_jsx(SwapIcon, { name: 'close' }), _jsx(PressDecoration, { kind: 'back', disabled: off })] });
13
+ }
14
+ /** Header of a card that is its own screen: Back on the leading edge, the title centred, and an optional control on the trailing edge. The title stays centred with either, both or neither. Every block draws it; import it from `@bloxwap/hig/react/blocks/screen-header` for a host pane that has no block. */
15
+ export function ScreenHeader({ title, onBack, backDisabled, backProps, action, headingId, badge, eyebrow, hideTitle, description, stickyHeader }) {
8
16
  const { messages } = useHIG();
9
- return _jsxs("div", { className: 'hig-screen-header', children: [_jsx("span", { className: 'hig-screen-header-side', children: onBack && _jsx("button", { type: 'button', className: 'hig-swap-back', "aria-label": messages.back ?? en.back, onClick: onBack, children: _jsx(SwapIcon, { name: 'back' }) }) }), _jsx("h2", { className: 'hig-screen-title', children: title }), _jsx("span", { className: 'hig-screen-header-side', children: action })] });
17
+ const header = useRef(null);
18
+ useStickyHeader(header, !!stickyHeader);
19
+ const heading = _jsx("h2", { id: headingId, className: `hig-screen-title${hideTitle ? ' hig-sr-only' : ''}`, children: badge ? _jsxs(_Fragment, { children: [title, _jsx("span", { className: 'hig-sr-only', children: "," }), " ", _jsx("span", { className: 'hig-badge hig-screen-badge', children: badge })] }) : title });
20
+ return _jsxs("div", { ref: header, className: 'hig-screen-header', "data-sticky": stickyHeader || undefined, children: [_jsx("span", { className: 'hig-screen-header-side', children: onBack && _jsxs("button", { ...backProps, type: 'button', className: 'hig-swap-back', "aria-label": messages.back ?? en.back, disabled: backDisabled || undefined, onClick: onBack, children: [_jsx(SwapIcon, { name: 'back' }), _jsx(PressDecoration, { kind: 'back', disabled: !!backDisabled })] }) }), eyebrow ? _jsxs("div", { className: 'hig-screen-heading', children: [_jsx("p", { className: 'hig-screen-eyebrow', children: eyebrow }), heading] }) : heading, description ? _jsx("p", { id: headingId ? `${headingId}-description` : undefined, className: 'hig-sr-only', children: description }) : null, _jsx("span", { className: 'hig-screen-header-side', children: action })] });
10
21
  }
11
22
  /** The QR glyph of a control that shows an address. */
12
- export const qrIcon = _jsxs("svg", { "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', width: '20', height: '20', fill: 'none', stroke: 'currentColor', strokeWidth: '1.6', strokeLinejoin: 'round', children: [_jsx("rect", { x: '3', y: '3', width: '5.5', height: '5.5', rx: '1' }), _jsx("rect", { x: '11.5', y: '3', width: '5.5', height: '5.5', rx: '1' }), _jsx("rect", { x: '3', y: '11.5', width: '5.5', height: '5.5', rx: '1' }), _jsx("path", { d: 'M11.5 11.5h2v2h-2zM15 15h2v2h-2z', fill: 'currentColor', stroke: 'none' })] });
23
+ export const qrIcon = _jsx(QrCode, { size: 20 });
@@ -1,10 +1,23 @@
1
1
  import React from 'react';
2
+ /** A secondary button under a setting, such as Open Settings. `feedback: false` keeps the provider's press feedback off this one button, for a host that plays its own cue for it; by default it plays like any `Button`. */
3
+ export interface SettingAction {
4
+ label: string;
5
+ onSelect: () => void;
6
+ disabled?: boolean;
7
+ feedback?: boolean;
8
+ }
2
9
  export interface SettingSwitchProps {
3
10
  label: string;
4
11
  description?: string;
5
12
  checked: boolean;
6
13
  onCheckedChange: (checked: boolean) => void;
7
14
  disabled?: boolean;
15
+ /** Always on and not changeable: the switch shows on at full strength and is read as unavailable. Presses do nothing. */
16
+ locked?: boolean;
17
+ /** Host content after the label, such as a badge. It is part of the switch's name, read after the label and a pause, so give artwork a text alternative or hide it. */
18
+ labelAccessory?: React.ReactNode;
19
+ /** Host words for the `labelAccessory`, read after the label and a pause in place of the accessory's own content, which is then hidden from assistive technology: `Feed, New`. Same prop on native. */
20
+ labelAccessoryLabel?: string;
8
21
  }
9
22
  /** One setting as a switch: the label over an optional description on the leading edge, the track on the trailing edge. The whole row is the `label.hig-choice` hit target, at least `--hig-control` tall, and toggles it; the label names the switch and the description describes it. */
10
- export declare function SettingSwitch({ label, description, checked, onCheckedChange, disabled }: SettingSwitchProps): React.JSX.Element;
23
+ export declare function SettingSwitch({ label, description, checked, onCheckedChange, disabled, locked, labelAccessory, labelAccessoryLabel }: SettingSwitchProps): React.JSX.Element;
@@ -1,8 +1,15 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useId } from 'react';
3
+ import { useId, useRef } from 'react';
4
+ import { PressDecoration } from '../provider.js';
4
5
  /** One setting as a switch: the label over an optional description on the leading edge, the track on the trailing edge. The whole row is the `label.hig-choice` hit target, at least `--hig-control` tall, and toggles it; the label names the switch and the description describes it. */
5
- export function SettingSwitch({ label, description, checked, onCheckedChange, disabled }) {
6
- const id = useId(), name = `${id}-label`, about = `${id}-description`;
7
- return _jsxs("label", { className: 'hig-choice hig-setting-switch', "data-disabled": disabled || undefined, children: [_jsxs("span", { className: 'hig-setting-switch-text', children: [_jsx("span", { id: name, children: label }), description && _jsx("span", { id: about, className: 'hig-setting-switch-description', children: description })] }), _jsx("span", { className: 'hig-switch', children: _jsx("input", { type: 'checkbox', role: 'switch', "aria-labelledby": name, "aria-describedby": description ? about : undefined, checked: checked, disabled: disabled, onChange: event => onCheckedChange(event.target.checked) }) })] });
6
+ export function SettingSwitch({ label, description, checked, onCheckedChange, disabled, locked, labelAccessory, labelAccessoryLabel }) {
7
+ const id = useId(), name = `${id}-label`, about = `${id}-description`, spoken = `${id}-name`, extra = `${id}-accessory`;
8
+ const input = useRef(null);
9
+ const accessory = labelAccessory != null && labelAccessory !== false, worded = accessory && !!labelAccessoryLabel;
10
+ // The comma is read, not drawn, so the name pauses between the label and the accessory instead of running them together.
11
+ // The label and its comma are one hidden text node: a visually hidden comma beside the label is laid out apart, and Chromium and WebKit read a space before it (`Swing notifications , Genesis`).
12
+ // With host words that node is the whole name; otherwise the name is that node then the accessory's own content, which the name computation joins with one space (`Feed, New`).
13
+ return _jsxs("label", { className: 'hig-choice hig-setting-switch', "data-disabled": disabled || undefined, "data-locked": locked || undefined, children: [_jsxs("span", { className: 'hig-setting-switch-text', children: [_jsxs("span", { id: name, children: [label, accessory && _jsx("span", { id: worded ? undefined : extra, className: 'hig-setting-switch-accessory', "aria-hidden": worded || undefined, children: labelAccessory })] }), accessory && _jsx("span", { id: spoken, hidden: true, children: worded ? `${label}, ${labelAccessoryLabel}` : `${label},` }), description && _jsx("span", { id: about, className: 'hig-setting-switch-description', children: description })] }), _jsx("span", { className: 'hig-switch', children: _jsx("input", { ref: input, type: 'checkbox', role: 'switch', "aria-labelledby": !accessory ? name : worded ? spoken : `${spoken} ${extra}`, "aria-describedby": description ? about : undefined, "aria-disabled": locked || undefined, checked: locked ? true : checked, disabled: disabled, onChange: event => { if (!locked)
14
+ onCheckedChange(event.target.checked); } }) }), _jsx(PressDecoration, { kind: 'switch', disabled: !!disabled || !!locked, input: input })] });
8
15
  }