@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,33 @@
1
+ import React from 'react';
2
+ import { type StyleProp, type ViewStyle } from 'react-native';
3
+ import { type QRErrorCorrection } from '@bloxwap/hig/contracts/qr';
4
+ export type { QRErrorCorrection } from '@bloxwap/hig/contracts/qr';
5
+ export interface QRCodeProps {
6
+ /** The text to encode: an address, a payment URI, a link. Digits pack tightest, then upper-case alphanumerics, then UTF-8. A value too long for a QR code draws an empty square. */
7
+ value: string;
8
+ /** Edge of the square in dp, quiet zone included; default 196. */
9
+ size?: number;
10
+ /** Drawn over the centre, which is cleared of modules: an image URL, or a node such as a token mark laid out in the arena's box. */
11
+ arena?: React.ReactNode;
12
+ /** Error correction level. Defaults to `high` with an arena, which covers part of the code, and `medium` without. With an arena, `low` and `medium` are raised to `quartile` so the code still reads. */
13
+ errorCorrection?: QRErrorCorrection;
14
+ /** Colour of the modules. Defaults to the provider's `text` role. */
15
+ color?: string;
16
+ /** Colour of the tile behind the code. Defaults to the provider's `background` role; `'none'` draws no tile, for a code that sits on the host's own surface. */
17
+ background?: string;
18
+ /** Clear modules kept on every side, inside `size`; default 4, the margin scanners expect. Pass 0 only where the host keeps that margin itself. */
19
+ quietZone?: number;
20
+ /** Accessible name. Defaults to the built-in “QR code”. */
21
+ label?: string;
22
+ /** Hides the code from assistive technology, for a host that names it on an element of its own. */
23
+ decorative?: boolean;
24
+ /** Also the prefix of `-code` (the drawing) and `-arena` (the image or node in the centre). */
25
+ testID?: string;
26
+ style?: StyleProp<ViewStyle>;
27
+ }
28
+ /**
29
+ * A QR code in the Cuer style: round modules, rounded finder patterns and an optional arena in the centre. HIG encodes the
30
+ * value itself; the drawing is one `react-native-svg` path, so the only peer is `react-native-svg`. The value is encoded once
31
+ * per `value`, `errorCorrection` and arena; `size`, the colours and the quiet zone only change props of the drawing.
32
+ */
33
+ export declare function QRCode({ value, size, arena, errorCorrection, color, background, quietZone, label, decorative, testID, style }: QRCodeProps): React.JSX.Element;
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
+ import { Image, StyleSheet, View } from 'react-native';
4
+ import Svg, { Path, Rect } from 'react-native-svg';
5
+ import { QR_QUIET_ZONE, qrCodeGeometry, qrFrame } from '@bloxwap/hig/contracts/qr';
6
+ import { useColors, useMessages } from './provider.js';
7
+ const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
8
+ const drawn = (node) => node != null && node !== false && node !== true && node !== '';
9
+ // Centred rather than offset from an edge, so a right-to-left layout cannot move the arena off the cleared square.
10
+ const styles = StyleSheet.create({ centre: { position: 'absolute', top: 0, right: 0, bottom: 0, left: 0, alignItems: 'center', justifyContent: 'center' }, arena: { overflow: 'hidden', alignItems: 'center', justifyContent: 'center' } });
11
+ /**
12
+ * A QR code in the Cuer style: round modules, rounded finder patterns and an optional arena in the centre. HIG encodes the
13
+ * value itself; the drawing is one `react-native-svg` path, so the only peer is `react-native-svg`. The value is encoded once
14
+ * per `value`, `errorCorrection` and arena; `size`, the colours and the quiet zone only change props of the drawing.
15
+ */
16
+ export function QRCode({ value, size = 196, arena, errorCorrection, color, background, quietZone = QR_QUIET_ZONE, label, decorative = false, testID, style }) {
17
+ const colors = useColors();
18
+ const t = useMessages();
19
+ const withArena = drawn(arena);
20
+ const geometry = useMemo(() => qrCodeGeometry(value, { errorCorrection, arena: withArena }), [value, errorCorrection, withArena]);
21
+ const frame = useMemo(() => geometry ? qrFrame(geometry, size, quietZone) : null, [geometry, size, quietZone]);
22
+ const tile = background === 'none' || background === 'transparent' ? null : background ?? colors.background;
23
+ const named = !decorative && geometry !== null;
24
+ const box = frame?.arena;
25
+ const access = named ? { accessible: true, accessibilityRole: 'image', accessibilityLabel: label ?? t.qrCode } : hidden;
26
+ const codeID = testID ? `${testID}-code` : undefined, arenaID = testID ? `${testID}-arena` : undefined;
27
+ const boxStyle = box ? { width: box.edge, height: box.edge, borderRadius: box.corner } : undefined;
28
+ return _jsxs(View, { ...access, testID: testID, style: [{ width: size, height: size }, style], children: [_jsxs(Svg, { width: size, height: size, viewBox: frame?.viewBox, accessible: false, testID: codeID, children: [tile && frame ? _jsx(Rect, { x: -frame.quietZone, y: -frame.quietZone, width: frame.span, height: frame.span, rx: frame.tileRadius, fill: tile }) : null, geometry ? _jsx(Path, { d: geometry.path, fill: color ?? colors.text }) : null] }), box ? _jsx(View, { ...hidden, pointerEvents: 'none', style: styles.centre, children: typeof arena === 'string' ? _jsx(Image, { source: { uri: arena }, testID: arenaID, style: boxStyle }) : _jsx(View, { testID: arenaID, style: [styles.arena, boxStyle], children: arena }) }) : null] });
29
+ }
@@ -1,8 +1,20 @@
1
1
  import React from 'react';
2
- import type { ChoicesProps } from './selection-types.js';
2
+ import { type ScrollViewProps } from 'react-native';
3
+ import type { Choice, ChoicesProps } from './selection-types.js';
4
+ import type { ScreenHeaderControlProps } from './screen-header.js';
3
5
  export declare function RadioGroup({ label, options, value, defaultValue, disabled, onValueChange }: ChoicesProps): React.JSX.Element;
4
6
  /** Equal-width choices with one interruptible selection indicator. The track is the dark well and the selected segment the lighter fill; the control is 44dp tall (36 compact). */
5
- export declare function SegmentedControl({ label, options, value, defaultValue, disabled, onValueChange }: ChoicesProps): React.JSX.Element;
7
+ /** One segment. `testID` is the segment's test ID, in place of `<group testID>-<value>`. */
8
+ export interface SegmentedControlOption extends Choice {
9
+ testID?: string;
10
+ }
11
+ export interface SegmentedControlProps extends Omit<ChoicesProps, 'options'> {
12
+ options: readonly SegmentedControlOption[]; /** Keeps `label` as the group's accessible name but does not draw it, for a control whose heading or row already names it. */
13
+ hideLabel?: boolean; /** Test ID of the group; each segment takes `<testID>-<value>`, such as `trade-share-mode-video`, unless the option sets its own `testID`. */
14
+ testID?: string; /** Pressable props for every segment, such as `{android_disableSound: true}` when the host plays its own sound. HIG keeps its own name, role, state, target and press. */
15
+ segmentProps?: ScreenHeaderControlProps;
16
+ }
17
+ export declare function SegmentedControl({ label, options, value, defaultValue, disabled, hideLabel, testID, segmentProps, onValueChange }: SegmentedControlProps): React.JSX.Element;
6
18
  export interface FilterOption {
7
19
  value: string;
8
20
  label: string;
@@ -15,7 +27,13 @@ export interface FilterProps {
15
27
  value?: string;
16
28
  defaultValue?: string;
17
29
  disabled?: boolean;
18
- onValueChange?: (value: string) => void;
30
+ onValueChange?: (value: string) => void; /** The horizontal scroll view the capsules sit in, such as a sheet library's ScrollView that keeps sideways drags from the sheet. It receives the same props as React Native's `ScrollView`, which is the default. */
31
+ scrollComponent?: React.ComponentType<ScrollViewProps>; /** Units the row scrolls out past its container on each side, so the capsules are cut by the container's edge, while the first and last capsule rest this far in: pass the container's side padding. Default 0. */
32
+ bleed?: number;
19
33
  }
20
- /** A horizontal, scrolling row of single-choice filter chips. The selected chip inverts and its circle shows a check that animates in. */
21
- export declare function Filter({ label, options, value, defaultValue, disabled, onValueChange }: FilterProps): React.JSX.Element;
34
+ /**
35
+ * A horizontal, scrolling row of single-choice filter chips. The selected chip inverts and its circle shows a check that animates in.
36
+ * The row scrolls the selected chip fully into view on mount and whenever the selection changes, through the scroll view's
37
+ * `scrollTo` (a host `scrollComponent` receives the ref and `onLayout`/`onScroll`; one without `scrollTo` simply does not scroll).
38
+ */
39
+ export declare function Filter({ label, options, value, defaultValue, disabled, onValueChange, scrollComponent, bleed }: FilterProps): React.JSX.Element;
@@ -1,10 +1,14 @@
1
+ import { createElement as _createElement } from "react";
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Check } from '@bloxwap/icons/native/check';
4
+ import { assertUniqueKeys } from '@bloxwap/hig/contracts';
2
5
  import { useEffect, useLayoutEffect, useRef, useState } from 'react';
3
6
  import { Animated, Easing, Image, Platform, Pressable, ScrollView, View } from 'react-native';
4
7
  import { tokens } from '@bloxwap/hig/tokens';
5
8
  import { useControllable, useColors, useFills, useHIG } from './provider.js';
6
9
  import { Text } from './surface.js';
7
10
  export function RadioGroup({ label, options, value, defaultValue = '', disabled, onValueChange }) {
11
+ assertUniqueKeys(options, option => option.value, 'Choices');
8
12
  const [current, set] = useControllable(value, defaultValue, onValueChange);
9
13
  const { direction, locale } = useHIG();
10
14
  const colors = useColors();
@@ -16,10 +20,10 @@ export function RadioGroup({ label, options, value, defaultValue = '', disabled,
16
20
  activate(); }, style: { minHeight: 48, paddingVertical: 12, flexDirection: 'row', alignItems: 'center', gap: 12, opacity: blocked ? 0.5 : 1 }, children: [_jsx(Text, { accessible: false, children: current === o.value ? '●' : '○' }), _jsxs(View, { style: { flex: 1 }, children: [_jsx(Text, { accessible: false, accessibilityLanguage: o.lang, children: o.label }), o.description !== undefined && _jsx(Text, { accessible: false, accessibilityLanguage: locale, style: { color: colors.muted, fontSize: 14, lineHeight: 20 }, children: o.description })] })] }, o.value);
17
21
  })] });
18
22
  }
19
- /** Segments are 36dp inside a 44dp track; the slop restores a 48dp touch target. */
20
- const segmentSlop = { top: 6, bottom: 6 };
21
- /** Equal-width choices with one interruptible selection indicator. The track is the dark well and the selected segment the lighter fill; the control is 44dp tall (36 compact). */
22
- export function SegmentedControl({ label, options, value, defaultValue = '', disabled, onValueChange }) {
23
+ /** Segments are 36dp inside a 44dp track (28 in a 36 track at compact density); the slop restores a 48dp touch target at either density. Segments sit 4 apart and the slop is vertical only, so neighbouring targets never overlap. Android (Fabric) counts a child's hitSlop in its parent's overflow inset, so the slop past the track is reachable there too. */
24
+ const segmentSlop = { top: 6, bottom: 6 }, compactSegmentSlop = { top: 10, bottom: 10 };
25
+ export function SegmentedControl({ label, options, value, defaultValue = '', disabled, hideLabel, testID, segmentProps, onValueChange }) {
26
+ assertUniqueKeys(options, option => option.value, 'Choices');
23
27
  const [current, set] = useControllable(value, defaultValue, onValueChange);
24
28
  const { direction, locale, reducedMotion, density } = useHIG();
25
29
  const colors = useColors();
@@ -47,19 +51,21 @@ export function SegmentedControl({ label, options, value, defaultValue = '', dis
47
51
  animation.start();
48
52
  return () => animation.stop();
49
53
  }, [selected, width, count, direction, reducedMotion, target, translateX]);
50
- return _jsxs(View, { accessibilityRole: 'radiogroup', accessibilityLabel: label, style: { direction, gap: 8 }, children: [_jsx(Text, { style: { fontWeight: '600' }, children: label }), _jsx(View, { style: { padding: 4, borderRadius: 9999, backgroundColor: fills.well }, children: _jsxs(View, { onLayout: event => setWidth(event.nativeEvent.layout.width), style: { flexDirection: 'row', gap: 4 }, children: [selected >= 0 && width > 0 && _jsx(Animated.View, { pointerEvents: 'none', accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', style: { position: 'absolute', ...anchor, top: 0, bottom: 0, width: segmentWidth, borderRadius: 9999, backgroundColor: fills.raised, opacity: disabled || options[selected].disabled ? 0.5 : 1, transform: [{ translateX }] } }), options.map(option => {
54
+ return _jsxs(View, { testID: testID, accessibilityRole: 'radiogroup', accessibilityLabel: label, style: { direction, gap: 8 }, children: [hideLabel ? null : _jsx(Text, { style: { fontWeight: '600' }, children: label }), _jsx(View, { style: { padding: 4, borderRadius: 9999, backgroundColor: fills.well }, children: _jsxs(View, { onLayout: event => setWidth(event.nativeEvent.layout.width), style: { flexDirection: 'row', gap: 4 }, children: [selected >= 0 && width > 0 && _jsx(Animated.View, { pointerEvents: 'none', accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', style: { position: 'absolute', ...anchor, top: 0, bottom: 0, width: segmentWidth, borderRadius: 9999, backgroundColor: fills.raised, opacity: disabled || options[selected].disabled ? 0.5 : 1, transform: [{ translateX }] } }), options.map(option => {
51
55
  const checked = current === option.value, blocked = !!disabled || !!option.disabled;
52
56
  const activate = () => { if (!blocked)
53
57
  set(option.value); };
54
- return _jsxs(Pressable, { accessible: true, accessibilityRole: 'radio', accessibilityLabel: option.label, accessibilityHint: option.description, accessibilityLanguage: option.lang, "aria-checked": checked, "aria-disabled": blocked, accessibilityState: { checked, disabled: blocked }, accessibilityActions: [{ name: 'activate' }], disabled: blocked, onPress: activate, onAccessibilityAction: event => { if (event.nativeEvent.actionName === 'activate')
55
- activate(); }, hitSlop: segmentSlop, style: { flex: 1, minWidth: 0, minHeight: compact ? 28 : 36, paddingHorizontal: 12, paddingVertical: compact ? 2 : 4, alignItems: 'stretch', justifyContent: 'center', borderRadius: 9999, opacity: blocked ? 0.5 : 1 }, children: [_jsx(Text, { accessible: false, accessibilityLanguage: option.lang, style: { color: checked ? colors.text : colors.muted, fontWeight: '500', textAlign: 'center' }, children: option.label }), option.description !== undefined && _jsx(Text, { accessible: false, accessibilityLanguage: locale, style: { color: colors.muted, fontSize: 14, lineHeight: 20, textAlign: 'center' }, children: option.description })] }, option.value);
58
+ return _createElement(Pressable, { ...segmentProps, key: option.value, testID: option.testID ?? (testID === undefined ? undefined : `${testID}-${option.value}`), accessible: true, accessibilityRole: 'radio', accessibilityLabel: option.label, accessibilityHint: option.description, accessibilityLanguage: option.lang, "aria-checked": checked, "aria-disabled": blocked, accessibilityState: { checked, disabled: blocked }, accessibilityActions: [{ name: 'activate' }], disabled: blocked, onPress: activate, onAccessibilityAction: event => { if (event.nativeEvent.actionName === 'activate')
59
+ activate(); }, hitSlop: compact ? compactSegmentSlop : segmentSlop, style: { flex: 1, minWidth: 0, minHeight: compact ? 28 : 36, paddingHorizontal: 12, paddingVertical: compact ? 2 : 4, alignItems: 'stretch', justifyContent: 'center', borderRadius: 9999, opacity: blocked ? 0.5 : 1 } },
60
+ _jsx(Text, { accessible: false, accessibilityLanguage: option.lang, style: { color: checked ? colors.text : colors.muted, fontWeight: '500', textAlign: 'center' }, children: option.label }),
61
+ option.description !== undefined && _jsx(Text, { accessible: false, accessibilityLanguage: locale, style: { color: colors.muted, fontSize: 14, lineHeight: 20, textAlign: 'center' }, children: option.description }));
56
62
  })] }) })] });
57
63
  }
58
64
  /** Chips are 40dp; the slop restores a 44dp touch target. */
59
65
  const filterSlop = { top: 2, bottom: 2 };
60
66
  const hiddenMark = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', pointerEvents: 'none' };
61
67
  /** One chip. Its circle holds the option's icon or an empty ring; when the chip is selected the circle fills and a check settles in, and deselecting reverses it. */
62
- function FilterChip({ option, checked, blocked, reducedMotion, onSelect }) {
68
+ function FilterChip({ option, checked, blocked, reducedMotion, onSelect, onLayout }) {
63
69
  const colors = useColors();
64
70
  const fills = useFills();
65
71
  const progress = useRef(new Animated.Value(checked ? 1 : 0)).current;
@@ -81,11 +87,33 @@ function FilterChip({ option, checked, blocked, reducedMotion, onSelect }) {
81
87
  const activate = () => { if (!blocked)
82
88
  onSelect(); };
83
89
  return _jsxs(Pressable, { accessible: true, accessibilityRole: 'radio', accessibilityLabel: option.label, "aria-checked": checked, "aria-disabled": blocked, accessibilityState: { checked, disabled: blocked }, accessibilityActions: [{ name: 'activate' }], disabled: blocked, onPress: activate, onAccessibilityAction: event => { if (event.nativeEvent.actionName === 'activate')
84
- activate(); }, hitSlop: filterSlop, style: state => ({ flexDirection: 'row', alignItems: 'center', gap: 8, minHeight: 40, paddingVertical: 6, paddingStart: 8, paddingEnd: 16, borderRadius: 9999, backgroundColor: checked ? colors.text : state.pressed ? fills.raised : fills.well, opacity: blocked ? 0.5 : 1 }), children: [_jsxs(View, { ...hiddenMark, style: { width: 24, height: 24, borderRadius: 12, overflow: 'hidden', alignItems: 'center', justifyContent: 'center' }, children: [option.icon ? _jsx(Image, { source: { uri: option.icon }, accessible: false, style: { position: 'absolute', width: 24, height: 24, borderRadius: 12 } }) : _jsx(View, { style: { position: 'absolute', width: 24, height: 24, borderRadius: 12, borderWidth: 2, borderColor: ink } }), _jsx(Animated.View, { style: { position: 'absolute', width: 24, height: 24, borderRadius: 12, backgroundColor: colors.background, opacity: progress } }), _jsx(Animated.View, { style: { opacity: progress, transform: [{ scale: progress.interpolate({ inputRange: [0, 1], outputRange: [0.4, 1] }) }] }, children: _jsx(View, { style: { width: 11, height: 6, borderLeftWidth: 2, borderBottomWidth: 2, borderColor: colors.text, transform: [{ translateY: -1.5 }, { rotate: '-45deg' }] } }) })] }), _jsx(Text, { accessible: false, style: { fontSize: 14, lineHeight: 21, fontWeight: '600', color: ink }, children: option.label })] });
90
+ activate(); }, hitSlop: filterSlop, onLayout: onLayout, style: state => ({ flexDirection: 'row', alignItems: 'center', gap: 8, minHeight: 40, paddingVertical: 6, paddingStart: 8, paddingEnd: 16, borderRadius: 9999, backgroundColor: checked ? colors.text : state.pressed ? fills.raised : fills.well, opacity: blocked ? 0.5 : 1 }), children: [_jsxs(View, { ...hiddenMark, style: { width: 24, height: 24, borderRadius: 12, overflow: 'hidden', alignItems: 'center', justifyContent: 'center' }, children: [option.icon ? _jsx(Image, { source: { uri: option.icon }, accessible: false, style: { position: 'absolute', width: 24, height: 24, borderRadius: 12 } }) : _jsx(View, { style: { position: 'absolute', width: 24, height: 24, borderRadius: 12, borderWidth: 2, borderColor: ink } }), _jsx(Animated.View, { style: { position: 'absolute', width: 24, height: 24, borderRadius: 12, backgroundColor: colors.background, opacity: progress } }), _jsx(Animated.View, { style: { opacity: progress, transform: [{ scale: progress.interpolate({ inputRange: [0, 1], outputRange: [0.4, 1] }) }] }, children: _jsx(Check, { size: 16, color: colors.text }) })] }), _jsx(Text, { accessible: false, style: { fontSize: 14, lineHeight: 21, fontWeight: '600', color: ink }, children: option.label })] });
85
91
  }
86
- /** A horizontal, scrolling row of single-choice filter chips. The selected chip inverts and its circle shows a check that animates in. */
87
- export function Filter({ label, options, value, defaultValue = '', disabled, onValueChange }) {
92
+ /**
93
+ * A horizontal, scrolling row of single-choice filter chips. The selected chip inverts and its circle shows a check that animates in.
94
+ * The row scrolls the selected chip fully into view on mount and whenever the selection changes, through the scroll view's
95
+ * `scrollTo` (a host `scrollComponent` receives the ref and `onLayout`/`onScroll`; one without `scrollTo` simply does not scroll).
96
+ */
97
+ export function Filter({ label, options, value, defaultValue = '', disabled, onValueChange, scrollComponent = ScrollView, bleed = 0 }) {
98
+ assertUniqueKeys(options, option => option.value, 'Choices');
88
99
  const [current, set] = useControllable(value, defaultValue, onValueChange);
89
100
  const { direction, reducedMotion } = useHIG();
90
- return _jsx(ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, keyboardShouldPersistTaps: 'handled', accessibilityRole: 'radiogroup', accessibilityLabel: label, style: { flexGrow: 0, direction }, contentContainerStyle: { direction, gap: 8 }, children: options.map(option => _jsx(FilterChip, { option: option, checked: current === option.value, blocked: !!disabled || !!option.disabled, reducedMotion: !!reducedMotion, onSelect: () => set(option.value) }, option.value)) });
101
+ const Scroll = scrollComponent;
102
+ const scroller = useRef(null), chips = useRef(new Map()), viewport = useRef({ width: 0, offset: 0 }), mounted = useRef(false);
103
+ // Left-to-right only: right-to-left horizontal offsets differ by platform, so that row stays where the reader leaves it.
104
+ const reveal = (animated) => {
105
+ const chip = chips.current.get(current), { width, offset } = viewport.current;
106
+ if (!chip || width <= 0 || direction === 'rtl')
107
+ return;
108
+ // With a bleed the chip's x includes the leading inset, and a revealed chip keeps the inset clear on either side.
109
+ const x = chip.x - bleed < offset ? chip.x - bleed : chip.x + chip.width + bleed > offset + width ? chip.x + chip.width + bleed - width : null;
110
+ if (x === null)
111
+ return;
112
+ viewport.current.offset = Math.max(0, x);
113
+ scroller.current?.scrollTo?.({ x: viewport.current.offset, animated: animated && !reducedMotion });
114
+ };
115
+ useEffect(() => { if (mounted.current)
116
+ reveal(true); mounted.current = true; }, [current]);
117
+ return _jsx(Scroll, { ref: scroller, horizontal: true, showsHorizontalScrollIndicator: false, keyboardShouldPersistTaps: 'handled', accessibilityRole: 'radiogroup', accessibilityLabel: label, style: { flexGrow: 0, direction, ...(bleed ? { marginHorizontal: -bleed } : null) }, contentContainerStyle: { direction, gap: 8, ...(bleed ? { paddingHorizontal: bleed } : null) }, onLayout: event => { viewport.current.width = event.nativeEvent.layout.width; reveal(false); }, onScroll: event => { viewport.current.offset = event.nativeEvent.contentOffset.x; }, scrollEventThrottle: 16, children: options.map(option => _jsx(FilterChip, { option: option, checked: current === option.value, blocked: !!disabled || !!option.disabled, reducedMotion: !!reducedMotion, onSelect: () => set(option.value), onLayout: event => { const { x, width } = event.nativeEvent.layout; chips.current.set(option.value, { x, width }); if (option.value === current)
118
+ reveal(false); } }, option.value)) });
91
119
  }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @deprecated Blocks were called recipes through 0.5.x. Import from `@bloxwap/hig/native/blocks`; this module is removed in the next
3
+ * major release. It exists as a real file so a Jest `moduleNameMapper` that maps `@bloxwap/hig/native/<entry>` to `native/dist/<entry>.js`
4
+ * resolves the old path too.
5
+ */
6
+ export * from './blocks.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @deprecated Blocks were called recipes through 0.5.x. Import from `@bloxwap/hig/native/blocks`; this module is removed in the next
3
+ * major release. It exists as a real file so a Jest `moduleNameMapper` that maps `@bloxwap/hig/native/<entry>` to `native/dist/<entry>.js`
4
+ * resolves the old path too.
5
+ */
6
+ export * from './blocks.js';
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
+ import { type ScrollViewProps } from 'react-native';
2
3
  import type { AssetArtwork } from './asset-balance-row.js';
4
+ import { type Figure } from './figure.js';
3
5
  /** 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
6
  export interface RewardPromo {
5
7
  /** The small capitals line: Season 01. */
@@ -9,16 +11,18 @@ export interface RewardPromo {
9
11
  label: string;
10
12
  onSelect: () => void;
11
13
  };
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. */
14
+ /** 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. */
15
+ amount?: number | null | string;
16
+ /** Host content drawn in the headline figure's place (`<testID>-figure`), in place of `amount`, such as the host's own live figure. It is drawn as given and reads itself. */
17
+ figure?: React.ReactNode;
18
+ /** Format of a number `amount` and of `goal`. Defaults to whole US dollars. */
15
19
  amountOptions?: Intl.NumberFormatOptions;
16
- /** The amount the pool is filling towards. Draws the progress bar under the caption. */
20
+ /** The amount the pool is filling towards. Draws the progress bar under the caption (full only against a number `amount`). */
17
21
  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;
22
+ /** The line under the figure. A function receives the formatted goal: `goal => 'of ' + goal + ' prize pool'`. A string is drawn as given and read with the figure: top prize. Any other node, such as a live countdown, is drawn as given after the figure and reads itself. */
23
+ caption?: React.ReactNode | ((goal: string) => React.ReactNode);
24
+ /** The lead of the explaining sentence, in the text colour: Top 100 traders split the pool. Host text, or host Text elements for an accented word. */
25
+ headline?: React.ReactNode;
22
26
  /** Continues the sentence after the headline in the muted colour: Funded by builder fees on every trade. */
23
27
  description?: string;
24
28
  /** A full-width action under the description: Draws and winners. The host opens its own destination. */
@@ -27,6 +31,14 @@ export interface RewardPromo {
27
31
  onSelect: () => void;
28
32
  };
29
33
  }
34
+ /** A host figure that updates place by place: `{value:1090779, options:{style:'currency',currency:'USD',maximumFractionDigits:0}, suffix:' vol'}`. */
35
+ export type RewardFigure = Figure;
36
+ /** One step of the paging control under the list. */
37
+ export interface RewardPageStep {
38
+ label: string;
39
+ onSelect: () => void;
40
+ disabled?: boolean;
41
+ }
30
42
  /** One trader in the standings. */
31
43
  export interface RewardEntry {
32
44
  id: string;
@@ -37,10 +49,12 @@ export interface RewardEntry {
37
49
  avatar?: AssetArtwork;
38
50
  /** Shows the verified mark after the name. */
39
51
  verified?: boolean;
40
- /** The line under the name: `$1,090,779 vol`. */
41
- detail?: string;
52
+ /** The line under the name: `$1,090,779 vol` as text, or the same as a live figure. */
53
+ detail?: string | RewardFigure;
42
54
  /** Points or entries. `null` reads as unknown. */
43
55
  score: number | null;
56
+ /** Format of this entry's score, in place of the block's `scoreOptions`, for a prize list where some amounts have cents. */
57
+ scoreOptions?: Intl.NumberFormatOptions;
44
58
  /** Marks the viewer's own row: the name and score take the action colour. */
45
59
  you?: boolean;
46
60
  }
@@ -60,12 +74,39 @@ export interface RewardBlockProps {
60
74
  };
61
75
  /** The viewer's own standing, pinned above the list on a tinted row. */
62
76
  you?: RewardEntry;
77
+ /** Names the pinned row for assistive technology, read before its rank: Your rank. */
78
+ youLabel?: string;
79
+ /** A muted line between the pinned row and the list, announced when it changes: You're not ranked yet. */
80
+ status?: string;
81
+ /** Host artwork in place of the built-in verified mark, inside the row's one accessible element. */
82
+ verifiedMark?: React.ReactNode;
83
+ /** The `verifiedMark` is a control, such as a badge that opens an explanation: it stays in the accessibility tree, the row's reading then sits on the name and the mark follows as its own element. */
84
+ verifiedMarkInteractive?: boolean;
85
+ /** Draws skeleton rows in place of the entries while the host loads them. */
86
+ loading?: boolean;
87
+ /** Host text that names the skeleton rows for assistive technology: Loading standings. Without it they are only marked busy. */
88
+ loadingLabel?: string;
89
+ /** Paging under the list: Previous and Next as buttons with the host's range between them, such as 1–25. */
90
+ pagination?: {
91
+ previous?: RewardPageStep;
92
+ next?: RewardPageStep;
93
+ label?: string;
94
+ };
95
+ /** Keeps the header pinned while the rest scrolls: the block becomes its own scroll view (`scrollComponent`) with the header as a sticky first child, transparent at rest and filled once the standings scroll under it. Place it in a bounded container, such as a sheet body. */
96
+ stickyHeader?: boolean;
97
+ /** Fill behind the pinned header once rows scroll under it. Defaults to the background role; in a sheet pass the sheet's fill (`useColors().overlay`). */
98
+ stickyHeaderBackground?: string;
99
+ /** Set false to leave the header out, when the host pins its own `ScreenHeader` above the block. The content then starts at the block's top edge. */
100
+ header?: boolean;
101
+ /** The scroll view used with `stickyHeader`, such as a sheet library's own. Defaults to React Native's ScrollView. */
102
+ scrollComponent?: React.ComponentType<ScrollViewProps>;
63
103
  /** The column heading over the names: Top 25 by volume. */
64
104
  listTitle?: string;
65
105
  /** The column heading over the scores: Entries. */
66
106
  scoreTitle?: string;
67
- entries: readonly RewardEntry[];
68
- /** Format of every score. Defaults to a whole number. */
107
+ /** The standings, in order. Leave them out for a promotion-only pane: no list is drawn. */
108
+ entries?: readonly RewardEntry[];
109
+ /** Format of every score. Defaults to a whole number. An entry's own `scoreOptions` wins. */
69
110
  scoreOptions?: Intl.NumberFormatOptions;
70
111
  /** Words for the verified mark, read after the name. */
71
112
  verifiedLabel?: string;
@@ -75,9 +116,10 @@ export interface RewardBlockProps {
75
116
  onBack?: () => void;
76
117
  /** A control on the trailing edge of the header, usually an IconButton that shares. */
77
118
  headerAction?: React.ReactNode;
119
+ /** Prefixes every test ID inside the block: `<testID>-header`, `<testID>-back`, `<testID>-title`, `<testID>-row-<id>` and so on. Omitted, they start with `reward`. */
78
120
  testID?: string;
79
121
  }
80
122
  /** The share of the goal reached, from 0 to 1. Unknown amounts and goals that are not above zero give `null`. */
81
123
  export declare function rewardProgress(amount: number | null | undefined, goal: number | null | undefined): number | null;
82
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. */
83
- export declare function RewardBlock({ title, promo, tabs, you, listTitle, scoreTitle, entries, scoreOptions, verifiedLabel, footnote, onBack, headerAction, testID }: 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, stickyHeaderBackground, scrollComponent, header: showHeader, testID }: RewardBlockProps): React.JSX.Element;
@@ -1,16 +1,20 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Image, Pressable, View } from 'react-native';
3
- import { formatNumber } from '@bloxwap/hig/contracts';
3
+ import { formatNumber } from './number-format.js';
4
4
  import { withAlpha } from '@bloxwap/hig/tokens';
5
- import { useColors, useFills, useHIG, useMessages } from './provider.js';
5
+ import { useColors, useFills, useHIG, useNumberLocale, usePresentNumber } from './provider.js';
6
6
  import { Surface, Text } from './surface.js';
7
- import { IconButton } from './button.js';
7
+ import { Button } from './button.js';
8
8
  import { SegmentedControl } from './radio-group.js';
9
9
  import { ChevronIcon, SeverityIcon } from './icons.js';
10
10
  import { AnimatedNumberReadout } from './animated-number.js';
11
11
  import { formatNumberReadout } from './animated-number-model.js';
12
+ import { ScreenHeader } from './screen-header.js';
13
+ import { StickyHeaderLayout } from './sticky-header.js';
14
+ import { figureProps } from './figure.js';
12
15
  const wholeDollars = { style: 'currency', currency: 'USD', maximumFractionDigits: 0 };
13
16
  const whole = { maximumFractionDigits: 0 };
17
+ const noEntries = [];
14
18
  const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
15
19
  const avatar = 40, space = ' ';
16
20
  /** The share of the goal reached, from 0 to 1. Unknown amounts and goals that are not above zero give `null`. */
@@ -18,18 +22,37 @@ export function rewardProgress(amount, goal) {
18
22
  return amount == null || goal == null || !Number.isFinite(amount) || !Number.isFinite(goal) || !(goal > 0) ? null : Math.min(1, Math.max(0, amount / goal));
19
23
  }
20
24
  /** 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. */
21
- export function RewardBlock({ title, promo, tabs, you, listTitle, scoreTitle, entries, scoreOptions = whole, verifiedLabel, footnote, onBack, headerAction, testID }) {
22
- const colors = useColors(), fills = useFills(), t = useMessages(), { direction, locale, monoFontFamily } = useHIG();
23
- const money = promo?.amountOptions ?? wholeDollars, reached = promo ? rewardProgress(promo.amount, promo.goal) : null;
24
- const caption = typeof promo?.caption === 'function' ? promo.goal !== undefined ? promo.caption(formatNumber(promo.goal, locale, money)) : undefined : promo?.caption;
25
+ 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, stickyHeaderBackground, scrollComponent, header: showHeader = true, testID }) {
26
+ const colors = useColors(), fills = useFills(), { direction, monoFontFamily } = useHIG(), locale = useNumberLocale(), present = usePresentNumber();
27
+ const prefix = testID ?? 'reward', tid = (part) => `${prefix}-${part}`;
28
+ const amount = promo?.amount, money = promo?.amountOptions ?? wholeDollars, reached = promo ? rewardProgress(typeof amount === 'string' ? null : amount, promo.goal) : null;
29
+ const caption = typeof promo?.caption === 'function' ? promo.goal !== undefined ? promo.caption(formatNumber(promo.goal, locale, present(money))) : undefined : promo?.caption;
30
+ // A text caption is read with the figure; a host node (such as a live countdown) and a host figure read themselves.
31
+ const captionText = typeof caption === 'string' || typeof caption === 'number' ? String(caption) : null, captionNode = captionText === null && caption != null && caption !== false ? caption : null;
32
+ const hostFigure = promo?.figure != null && promo.figure !== false ? promo.figure : null;
25
33
  const caps = { fontFamily: monoFontFamily, fontSize: 12, lineHeight: 16, letterSpacing: 1.5, textTransform: 'uppercase' };
26
- const standing = (entry, id, style) => {
27
- const mine = !!entry.you, reading = [String(entry.rank), entry.name, entry.verified && verifiedLabel ? verifiedLabel : null, entry.detail, formatNumberReadout(entry.score, locale, scoreOptions).text].filter(Boolean).join(', ');
34
+ const figureStyle = { fontSize: 44, lineHeight: 50, fontWeight: '700', letterSpacing: -0.9 }, captionStyle = { fontFamily: monoFontFamily, fontSize: 15, lineHeight: 22, color: colors.muted };
35
+ const standing = (entry, id, style, lead) => {
36
+ const figure = entry.detail != null && typeof entry.detail === 'object' ? entry.detail : null, detail = typeof entry.detail === 'string' ? entry.detail : undefined, score = entry.scoreOptions ?? scoreOptions;
37
+ const said = figure ? formatNumberReadout(figure.value, locale, present(figure.options), figure.formattedValue, figure.prefix, figure.suffix).text : detail;
38
+ const mine = !!entry.you, reading = [lead, String(entry.rank), entry.name, entry.verified && verifiedLabel ? verifiedLabel : null, said, formatNumberReadout(entry.score, locale, present(score)).text].filter(Boolean).join(', ');
28
39
  const disc = { width: avatar, height: avatar, borderRadius: avatar / 2, backgroundColor: fills.raised, alignItems: 'center', justifyContent: 'center', overflow: 'hidden' };
29
- return _jsxs(View, { testID: id, accessible: true, accessibilityLabel: reading, style: { direction, flexDirection: 'row', alignItems: 'center', gap: 12, minHeight: 64, paddingVertical: 8, paddingHorizontal: 20, backgroundColor: fills.well, ...style }, children: [_jsx(Text, { ...hidden, style: { minWidth: 24, fontFamily: monoFontFamily, fontSize: 16, lineHeight: 24, fontWeight: '600', color: colors.muted }, children: entry.rank }), _jsx(View, { ...hidden, children: typeof entry.avatar === 'string' ? _jsx(Image, { accessible: false, accessibilityIgnoresInvertColors: true, source: { uri: entry.avatar }, style: disc }) : _jsx(View, { style: disc, children: entry.avatar ?? _jsx(Text, { maxFontSizeMultiplier: 1, style: { fontSize: 12, lineHeight: 16, fontWeight: '600', color: colors.muted }, children: entry.name.slice(0, 2) }) }) }), _jsxs(View, { ...hidden, style: { flex: 1, flexShrink: 1, minWidth: 0 }, children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 6 }, children: [_jsx(Text, { testID: `${id}-name`, numberOfLines: 1, style: { flexShrink: 1, fontFamily: monoFontFamily, fontSize: 16, lineHeight: 24, fontWeight: '600', color: mine ? colors.action : colors.text }, children: entry.name }), entry.verified ? _jsx(View, { testID: `${id}-verified`, style: { transform: [{ scale: 0.8 }] }, children: _jsx(SeverityIcon, { kind: 'success', color: colors.warning }) }) : null] }), entry.detail ? _jsx(Text, { numberOfLines: 1, style: { fontFamily: monoFontFamily, fontSize: 14, lineHeight: 20, color: colors.muted }, children: entry.detail }) : null] }), _jsx(View, { ...hidden, children: _jsx(AnimatedNumberReadout, { value: entry.score, options: scoreOptions, tone: mine ? 'positive' : 'text', testID: `${id}-score`, style: { fontSize: 16, lineHeight: 24, fontWeight: '600' } }) })] }, entry.id);
40
+ // An interactive host mark stays in the accessibility tree: the row's reading moves to the name, and the mark follows as its own element.
41
+ const split = !!entry.verified && verifiedMark != null && !!verifiedMarkInteractive;
42
+ return _jsxs(View, { testID: id, accessible: !split, accessibilityLabel: split ? undefined : reading, style: { direction, flexDirection: 'row', alignItems: 'center', gap: 12, minHeight: 64, paddingVertical: 8, paddingHorizontal: 20, backgroundColor: fills.well, ...style }, children: [_jsx(Text, { ...hidden, style: { minWidth: 24, fontFamily: monoFontFamily, fontSize: 16, lineHeight: 24, fontWeight: '600', color: colors.muted }, children: entry.rank }), _jsx(View, { ...hidden, children: typeof entry.avatar === 'string' ? _jsx(Image, { accessible: false, accessibilityIgnoresInvertColors: true, source: { uri: entry.avatar }, style: disc }) : _jsx(View, { style: disc, children: entry.avatar ?? _jsx(Text, { maxFontSizeMultiplier: 1, style: { fontSize: 12, lineHeight: 16, fontWeight: '600', color: colors.muted }, children: entry.name.slice(0, 2) }) }) }), _jsxs(View, { ...(split ? null : hidden), style: { flex: 1, flexShrink: 1, minWidth: 0 }, children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 6 }, children: [_jsx(Text, { testID: `${id}-name`, accessible: split, accessibilityLabel: split ? reading : undefined, numberOfLines: 1, style: { flexShrink: 1, fontFamily: monoFontFamily, fontSize: 16, lineHeight: 24, fontWeight: '600', color: mine ? colors.action : colors.text }, children: entry.name }), entry.verified ? (verifiedMark != null ? _jsx(View, { testID: `${id}-verified`, children: verifiedMark }) : _jsx(View, { testID: `${id}-verified`, style: { transform: [{ scale: 0.8 }] }, children: _jsx(SeverityIcon, { kind: 'success', color: colors.warning }) })) : null] }), figure ? _jsx(View, { ...hidden, style: { alignItems: 'flex-start' }, children: _jsx(AnimatedNumberReadout, { testID: `${id}-detail`, ...figureProps(figure), tone: 'muted', style: { fontFamily: monoFontFamily, fontSize: 14, lineHeight: 20 } }) })
43
+ : detail ? _jsx(Text, { ...hidden, numberOfLines: 1, style: { fontFamily: monoFontFamily, fontSize: 14, lineHeight: 20, color: colors.muted }, children: detail }) : null] }), _jsx(View, { ...hidden, children: _jsx(AnimatedNumberReadout, { value: entry.score, options: score, tone: mine ? 'positive' : 'text', testID: `${id}-score`, style: { fontSize: 16, lineHeight: 24, fontWeight: '600' } }) })] }, entry.id);
30
44
  };
31
45
  // Rows are built here so their test ids are code, not JSX text.
32
- const pinned = you ? standing({ ...you, you: true }, 'reward-you', { marginTop: 16, borderRadius: 20, backgroundColor: withAlpha(colors.action, 0.12) }) : null;
33
- const rows = entries.map(entry => standing(entry, `reward-row-${entry.id}`));
34
- return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [_jsxs(View, { testID: 'reward-header', style: { flexDirection: 'row', alignItems: 'center', minHeight: 44 }, children: [_jsx(View, { style: { minWidth: 44, alignItems: 'flex-start' }, children: onBack ? _jsx(IconButton, { intent: 'ghost', label: t.back, suppressFeedback: true, testID: 'reward-back', onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: colors.text }) }) }) : null }), _jsx(Text, { testID: 'reward-title', accessibilityRole: 'header', numberOfLines: 1, style: { flex: 1, textAlign: 'center', fontSize: 17, lineHeight: 24, fontWeight: '600', color: colors.text }, children: title }), _jsx(View, { style: { minWidth: 44, alignItems: 'flex-end' }, children: headerAction })] }), promo ? _jsxs(Surface, { testID: 'reward-promo', style: { gap: 12, marginTop: 16 }, children: [_jsxs(View, { style: { direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12 }, children: [_jsx(Text, { testID: 'reward-eyebrow', style: { ...caps, flexShrink: 1, color: colors.muted }, children: promo.eyebrow }), promo.rules ? _jsxs(Pressable, { testID: 'reward-rules', accessibilityRole: 'button', hitSlop: 12, onPress: promo.rules.onSelect, style: ({ pressed }) => ({ flexDirection: 'row', alignItems: 'center', gap: 4, opacity: pressed ? 0.6 : 1 }), children: [_jsx(Text, { style: { fontSize: 16, lineHeight: 24, fontWeight: '500', color: colors.muted }, children: promo.rules.label }), _jsx(View, { ...hidden, style: { transform: [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] }, children: _jsx(ChevronIcon, { color: colors.muted }) })] }) : null] }), _jsxs(View, { testID: 'reward-amount', accessible: true, accessibilityLabel: [formatNumberReadout(promo.amount, locale, money).text, caption].filter(Boolean).join(' '), style: { gap: 4 }, children: [_jsx(View, { ...hidden, style: { alignItems: 'flex-start' }, children: _jsx(AnimatedNumberReadout, { value: promo.amount, options: money, tone: 'positive', style: { fontSize: 44, lineHeight: 50, fontWeight: '700', letterSpacing: -0.9 } }) }), caption ? _jsx(Text, { ...hidden, testID: 'reward-caption', style: { fontFamily: monoFontFamily, fontSize: 15, lineHeight: 22, color: colors.muted }, children: caption }) : null] }), promo.goal !== undefined ? _jsx(View, { ...hidden, testID: 'reward-track', style: { direction, flexDirection: 'row', height: 4, borderRadius: 2, backgroundColor: fills.raised, overflow: 'hidden' }, children: _jsx(View, { testID: 'reward-fill', style: { width: `${(reached ?? 0) * 100}%`, minWidth: 8, borderRadius: 2, backgroundColor: colors.action } }) }) : null, promo.headline || promo.description ? _jsxs(Text, { testID: 'reward-summary', style: { fontSize: 16, lineHeight: 24, color: colors.muted }, children: [promo.headline ? _jsx(Text, { style: { fontWeight: '600', color: colors.text }, children: promo.headline }) : null, promo.headline && promo.description ? space : null, promo.description] }) : null, promo.action ? _jsxs(Pressable, { testID: 'reward-action', accessibilityRole: 'button', accessibilityLabel: promo.action.label, onPress: promo.action.onSelect, style: { direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12, minHeight: 44, marginTop: 4, marginBottom: -8, paddingTop: 12, borderTopWidth: 1, borderTopColor: fills.raised }, children: [_jsx(Text, { ...hidden, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, fontWeight: '500', color: colors.muted }, children: promo.action.label }), _jsx(View, { ...hidden, style: { transform: [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] }, children: _jsx(ChevronIcon, { color: colors.muted }) })] }) : null] }) : null, tabs ? _jsx(View, { testID: 'reward-tabs', style: { marginTop: 16 }, children: _jsx(SegmentedControl, { label: tabs.label, options: tabs.options, value: tabs.value, onValueChange: tabs.onValueChange }) }) : null, pinned, entries.length > 0 || listTitle || scoreTitle ? _jsxs(View, { testID: 'reward-list', style: { gap: 8, marginTop: 16 }, children: [listTitle || scoreTitle ? _jsxs(View, { style: { direction, flexDirection: 'row', justifyContent: 'space-between', gap: 12, paddingHorizontal: 4 }, children: [_jsx(Text, { testID: 'reward-list-title', style: { ...caps, flexShrink: 1, color: colors.muted }, children: listTitle }), _jsx(Text, { testID: 'reward-score-title', style: { ...caps, flexShrink: 1, color: colors.muted, textAlign: 'right' }, children: scoreTitle })] }) : null, entries.length > 0 ? _jsx(View, { testID: 'reward-rows', style: { gap: 2, borderRadius: 20, overflow: 'hidden' }, children: rows }) : null] }) : null, footnote ? _jsx(Text, { testID: 'reward-footnote', style: { fontSize: 14, lineHeight: 21, color: colors.muted, marginTop: 16, paddingHorizontal: 4 }, children: footnote }) : null] });
46
+ const pinned = you ? standing({ ...you, you: true }, tid('you'), { marginTop: 16, borderRadius: 20, backgroundColor: withAlpha(colors.action, 0.12) }, youLabel) : null;
47
+ const rows = entries.map(entry => standing(entry, tid(`row-${entry.id}`)));
48
+ const header = _jsx(ScreenHeader, { testID: prefix, title: title, onBack: onBack, action: headerAction });
49
+ const small = { fontSize: 14, lineHeight: 21, color: colors.muted };
50
+ const list = loading ? _jsx(View, { testID: tid('loading'), accessible: !!loadingLabel, accessibilityLabel: loadingLabel, accessibilityState: { busy: true }, style: { gap: 2, marginTop: 16, borderRadius: 20, overflow: 'hidden' }, children: [0, 1, 2, 3, 4].map(index => _jsx(View, { style: { minHeight: 64, backgroundColor: fills.raised } }, index)) }) : entries.length > 0 || listTitle || scoreTitle ? _jsxs(View, { testID: tid('list'), style: { gap: 8, marginTop: 16 }, children: [listTitle || scoreTitle ? _jsxs(View, { style: { direction, flexDirection: 'row', justifyContent: 'space-between', gap: 12, paddingHorizontal: 4 }, children: [_jsx(Text, { testID: tid('list-title'), style: { ...caps, flexShrink: 1, color: colors.muted }, children: listTitle }), _jsx(Text, { testID: tid('score-title'), style: { ...caps, flexShrink: 1, color: colors.muted, textAlign: 'right' }, children: scoreTitle })] }) : null, entries.length > 0 ? _jsx(View, { testID: tid('rows'), style: { gap: 2, borderRadius: 20, overflow: 'hidden' }, children: rows }) : null] }) : null;
51
+ const pages = pagination ? _jsxs(View, { testID: tid('pagination'), style: { direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 8, marginTop: 16 }, children: [_jsx(View, { style: { flex: 1, alignItems: 'flex-start' }, children: pagination.previous ? _jsx(Button, { testID: tid('previous'), intent: 'secondary', disabled: pagination.previous.disabled, onPress: pagination.previous.onSelect, children: pagination.previous.label }) : null }), pagination.label ? _jsx(Text, { testID: tid('page'), accessibilityLiveRegion: 'polite', style: { ...small, fontFamily: monoFontFamily, textAlign: 'center' }, children: pagination.label }) : null, _jsx(View, { style: { flex: 1, alignItems: 'flex-end' }, children: pagination.next ? _jsx(Button, { testID: tid('next'), intent: 'secondary', disabled: pagination.next.disabled, onPress: pagination.next.onSelect, children: pagination.next.label }) : null })] }) : null;
52
+ const body = _jsxs(_Fragment, { children: [promo ? _jsxs(Surface, { testID: tid('promo'), style: { gap: 12, marginTop: 16 }, children: [_jsxs(View, { style: { direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12 }, children: [_jsx(Text, { testID: tid('eyebrow'), style: { ...caps, flexShrink: 1, color: colors.muted }, children: promo.eyebrow }), promo.rules ? _jsxs(Pressable, { testID: tid('rules'), accessibilityRole: 'button', hitSlop: 12, onPress: promo.rules.onSelect, style: ({ pressed }) => ({ flexDirection: 'row', alignItems: 'center', gap: 4, opacity: pressed ? 0.6 : 1 }), children: [_jsx(Text, { style: { fontSize: 16, lineHeight: 24, fontWeight: '500', color: colors.muted }, children: promo.rules.label }), _jsx(View, { ...hidden, style: { transform: [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] }, children: _jsx(ChevronIcon, { color: colors.muted }) })] }) : null] }), hostFigure ? _jsxs(View, { testID: tid('amount'), style: { gap: 4 }, children: [_jsx(View, { testID: tid('figure'), style: { alignItems: 'flex-start' }, children: hostFigure }), captionText ? _jsx(Text, { testID: tid('caption'), style: captionStyle, children: captionText }) : null] }) : amount !== undefined || captionText ? _jsxs(View, { testID: tid('amount'), accessible: true, accessibilityLabel: [amount === undefined ? null : typeof amount === 'string' ? amount : formatNumberReadout(amount, locale, present(money)).text, captionText].filter(Boolean).join(' '), style: { gap: 4 }, children: [amount === undefined ? null : _jsx(View, { ...hidden, style: { alignItems: 'flex-start' }, children: typeof amount === 'string' ? _jsx(Text, { style: { ...figureStyle, color: colors.positive }, children: amount }) : _jsx(AnimatedNumberReadout, { value: amount, options: money, tone: 'positive', style: figureStyle }) }), captionText ? _jsx(Text, { ...hidden, testID: tid('caption'), style: captionStyle, children: captionText }) : null] }) : null, captionNode ? _jsx(View, { testID: tid('caption'), style: { marginTop: -8 }, children: captionNode }) : null, promo.goal !== undefined ? _jsx(View, { ...hidden, testID: tid('track'), style: { direction, flexDirection: 'row', height: 4, borderRadius: 2, backgroundColor: fills.raised, overflow: 'hidden' }, children: _jsx(View, { testID: tid('fill'), style: { width: `${(reached ?? 0) * 100}%`, minWidth: 8, borderRadius: 2, backgroundColor: colors.action } }) }) : null, promo.headline || promo.description ? _jsxs(Text, { testID: tid('summary'), style: { fontSize: 16, lineHeight: 24, color: colors.muted }, children: [promo.headline ? _jsx(Text, { style: { fontWeight: '600', color: colors.text }, children: promo.headline }) : null, promo.headline && promo.description ? space : null, promo.description] }) : null, promo.action ? _jsxs(Pressable, { testID: tid('action'), accessibilityRole: 'button', accessibilityLabel: promo.action.label, onPress: promo.action.onSelect, style: { direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12, minHeight: 44, marginTop: 4, marginBottom: -8, paddingTop: 12, borderTopWidth: 1, borderTopColor: fills.raised }, children: [_jsx(Text, { ...hidden, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, fontWeight: '500', color: colors.muted }, children: promo.action.label }), _jsx(View, { ...hidden, style: { transform: [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] }, children: _jsx(ChevronIcon, { color: colors.muted }) })] }) : null] }) : null, tabs ? _jsx(View, { testID: tid('tabs'), style: { marginTop: 16 }, children: _jsx(SegmentedControl, { label: tabs.label, options: tabs.options, value: tabs.value, onValueChange: tabs.onValueChange }) }) : null, pinned, status ? _jsx(Text, { testID: tid('status'), accessibilityLiveRegion: 'polite', style: { ...small, marginTop: 16, paddingHorizontal: 4 }, children: status }) : null, list, pages, footnote ? _jsx(Text, { testID: tid('footnote'), style: { fontSize: 14, lineHeight: 21, color: colors.muted, marginTop: 16, paddingHorizontal: 4 }, children: footnote }) : null] });
53
+ if (!showHeader)
54
+ return _jsx(View, { testID: testID, style: { padding: 16, paddingTop: 0 }, children: body });
55
+ if (stickyHeader)
56
+ return _jsx(StickyHeaderLayout, { testID: testID, headerTestID: tid('sticky-header'), header: header, background: stickyHeaderBackground, scrollComponent: scrollComponent, children: body });
57
+ return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [header, body] });
35
58
  }
@@ -0,0 +1,59 @@
1
+ import React from 'react';
2
+ import { View, type PressableProps, type StyleProp, type ViewStyle } from 'react-native';
3
+ export { ChevronIcon } from './icons.js';
4
+ export { useStickyHeaderScroll, type StickyHeaderScroll } from './sticky-header.js';
5
+ /** Pressable props passed through to a header control, such as `android_disableSound` or `onPressIn`. HIG keeps its own name, role, state, target and press. */
6
+ export type ScreenHeaderControlProps = Omit<PressableProps, 'children' | 'onPress' | 'disabled' | 'style' | 'accessibilityLabel' | 'accessibilityRole' | 'accessibilityState' | 'testID'>;
7
+ export interface ScreenHeaderProps {
8
+ /** The heading, centred. Host text. */
9
+ title: string;
10
+ /** Shows Back on the leading edge. */
11
+ onBack?: () => void;
12
+ /** Draws Back unavailable: dimmed, read as disabled and not pressable, for example while a close is being signed. */
13
+ backDisabled?: boolean;
14
+ /** Pressable props for Back, such as `{android_disableSound: true}` when the host plays its own sound. */
15
+ backProps?: ScreenHeaderControlProps;
16
+ /** A control on the trailing edge, usually an `IconButton`. */
17
+ action?: React.ReactNode;
18
+ /** Prefix of the test IDs: `<testID>-header`, `<testID>-back` and `<testID>-title`. Omitted, the header sets none. */
19
+ testID?: string;
20
+ /** Sets `nativeID` on the title, so a sheet around the pane can name itself with `accessibilityLabelledBy` (Android). Omitted, the title has none. */
21
+ headingId?: string;
22
+ /** A ref to the heading's accessible element (the title, or the title and badge as one header), for example to move accessibility focus to it when the pane opens. */
23
+ titleRef?: React.Ref<React.ComponentRef<typeof View>>;
24
+ /** Short host text in a badge beside the title, read as part of the heading after a pause: Demo. */
25
+ badge?: string;
26
+ /** A kicker over the title, centred in small muted capitals: Builder fee. Host text, read before the heading as its own element (test ID `<testID>-eyebrow`). The header grows to fit it. */
27
+ eyebrow?: string;
28
+ /** 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. */
29
+ hideTitle?: boolean;
30
+ /** Host text that describes the pane, never drawn and read after the heading as its accessibility hint, such as a sheet's description. */
31
+ description?: string;
32
+ /** Marks the header as pinned in the host's scroller: it is transparent at rest and takes `stickyHeaderBackground` once `scrolled` is true. Get `scrolled` from `useStickyHeaderScroll()` on that scroller. */
33
+ stickyHeader?: boolean;
34
+ /** With `stickyHeader`: content has scrolled under the header, so it draws its fill. */
35
+ scrolled?: boolean;
36
+ /** With `stickyHeader`: the fill once content is under the header. Defaults to the background role; in a sheet pass the sheet's fill (`useColors().overlay`). */
37
+ stickyHeaderBackground?: string;
38
+ /** With `stickyHeader`: space kept inside the fill above the row and to each side of it, such as the blocks' 16, so the inset fills with the header once content scrolls under it. Pass the inset here, not as `style` padding: React Native moves a sticky child's `style` onto its own wrapper, outside the fill. */
39
+ inset?: number;
40
+ /** Style of the header's container. With `stickyHeader` it sits outside the fill (React Native moves it onto the sticky slot's wrapper once pinned); put an inset in `inset`. */
41
+ style?: StyleProp<ViewStyle>;
42
+ }
43
+ /** Pressable props for a header Close: those of `ScreenHeaderControlProps`, plus `disabled`, which draws Close unavailable (a faint glyph, read as disabled, not pressable), for example while the pane's action is being signed. */
44
+ export type HeaderCloseProps = ScreenHeaderControlProps & {
45
+ disabled?: boolean;
46
+ };
47
+ /** The block header's Close control, shared by the blocks that draw one. */
48
+ export declare function HeaderClose({ onClose, label, testID, closeProps }: {
49
+ onClose: () => void;
50
+ label: string;
51
+ testID?: string;
52
+ closeProps?: HeaderCloseProps;
53
+ }): React.JSX.Element;
54
+ /**
55
+ * The header of a block that is its own screen: Back on the leading edge, the title centred, an optional control on the trailing
56
+ * edge. The settings blocks (Notifications, Signals, Sound & Haptics) draw it; the other native blocks draw a header that matches
57
+ * it. Import it from `@bloxwap/hig/native/screen-header` for a host pane that has no block.
58
+ */
59
+ export declare function ScreenHeader({ title, onBack, backDisabled, backProps, action, testID, headingId, titleRef, badge, eyebrow, hideTitle, description, stickyHeader, scrolled, stickyHeaderBackground, inset, style }: ScreenHeaderProps): React.JSX.Element;
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { View } from 'react-native';
3
+ import { useColors, useHIG, useMessages } from './provider.js';
4
+ import { Text } from './surface.js';
5
+ import { IconButton } from './button.js';
6
+ import { ChevronIcon, CloseIcon } from './icons.js';
7
+ import { Badge } from './status.js';
8
+ import { stickyHeaderFill } from './sticky-header.js';
9
+ export { ChevronIcon } from './icons.js';
10
+ export { useStickyHeaderScroll } from './sticky-header.js';
11
+ /** The block header's Close control, shared by the blocks that draw one. */
12
+ export function HeaderClose({ onClose, label, testID, closeProps }) {
13
+ const colors = useColors(), off = !!closeProps?.disabled;
14
+ return _jsx(IconButton, { ...closeProps, disabled: off, intent: 'ghost', label: label, suppressFeedback: true, testID: testID, onPress: onClose, children: _jsx(CloseIcon, { color: off ? colors.faint : colors.text }) });
15
+ }
16
+ /**
17
+ * The header of a block that is its own screen: Back on the leading edge, the title centred, an optional control on the trailing
18
+ * edge. The settings blocks (Notifications, Signals, Sound & Haptics) draw it; the other native blocks draw a header that matches
19
+ * it. Import it from `@bloxwap/hig/native/screen-header` for a host pane that has no block.
20
+ */
21
+ export function ScreenHeader({ title, onBack, backDisabled, backProps, action, testID, headingId, titleRef, badge, eyebrow, hideTitle, description, stickyHeader, scrolled, stickyHeaderBackground, inset, style }) {
22
+ const colors = useColors(), t = useMessages(), { direction } = useHIG();
23
+ const id = (part) => testID === undefined ? undefined : `${testID}-${part}`;
24
+ // Clear white stays in the accessibility tree where opacity 0 might not; the title keeps its line so the header keeps its height.
25
+ const ink = hideTitle ? '#ffffff00' : colors.text;
26
+ const heading = { textAlign: 'center', fontSize: 17, lineHeight: 24, fontWeight: '600', color: ink };
27
+ const fill = stickyHeader ? stickyHeaderFill(!!scrolled, stickyHeaderBackground ?? colors.background) : undefined;
28
+ const pad = stickyHeader && inset ? inset : 0, height = 44 + pad;
29
+ // Beside the sides the title fills the middle; under an eyebrow it sits in a column at its own height.
30
+ const grow = eyebrow ? null : { flex: 1 };
31
+ const titleNode = badge ? _jsxs(View, { ref: titleRef, nativeID: headingId, accessible: true, accessibilityRole: 'header', accessibilityLabel: `${title}, ${badge}`, accessibilityHint: description, style: { ...grow, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 8, minWidth: 0 }, children: [_jsx(Text, { testID: id('title'), accessible: false, numberOfLines: 1, style: { ...heading, flexShrink: 1 }, children: title }), hideTitle ? null : _jsx(View, { testID: id('badge'), style: { flexShrink: 0 }, children: _jsx(Badge, { children: _jsx(Text, { style: { fontSize: 12, lineHeight: 16, fontWeight: '600', color: colors.text }, children: badge }) }) })] }) : _jsx(Text, { ref: titleRef, testID: id('title'), nativeID: headingId, accessibilityRole: 'header', accessibilityHint: description, numberOfLines: 1, style: { ...grow, ...heading }, children: title });
32
+ const row = _jsxs(View, { testID: id('header'), style: [{ flexDirection: 'row', alignItems: 'center', minHeight: height }, pad ? { paddingTop: pad, paddingHorizontal: pad } : undefined, fill, stickyHeader ? undefined : style], children: [_jsx(View, { style: { minWidth: 44, alignItems: 'flex-start' }, children: onBack ? _jsx(IconButton, { ...backProps, intent: 'ghost', label: t.back, disabled: backDisabled, suppressFeedback: true, testID: id('back'), onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: backDisabled ? colors.faint : colors.text }) }) }) : null }), eyebrow ? _jsxs(View, { style: { flex: 1, minWidth: 0, gap: 2 }, children: [_jsx(Text, { testID: id('eyebrow'), numberOfLines: 1, style: { textAlign: 'center', fontSize: 12, lineHeight: 16, letterSpacing: 1.5, textTransform: 'uppercase', color: colors.muted }, children: eyebrow }), titleNode] }) : titleNode, _jsx(View, { style: { minWidth: 44, alignItems: 'flex-end' }, children: action })] });
33
+ // A pinned header is the host scroller's sticky child: React Native moves its `style` prop onto the slot's own wrapper and passes flex:1 in its
34
+ // place, which in that column measures the child at its minimum height alone (0 plus padding). So the outer view carries only what may move
35
+ // (the host's style) and a minimum height of the whole row, and the row, the inset and the fill sit on the inner view, pinned or not.
36
+ return stickyHeader ? _jsx(View, { style: [{ minHeight: height }, style], children: row }) : row;
37
+ }
@@ -1,9 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState, useRef } from 'react';
2
+ import { assertUniqueKeys } from '@bloxwap/hig/contracts';
3
+ import { useState, useRef, useEffect } from 'react';
3
4
  import { View } from 'react-native';
4
5
  import * as en from '@bloxwap/hig/contracts/messages';
5
6
  import { useControllable, useHIG } from './provider.js';
6
7
  import { Button } from './button.js';
7
8
  import { Dialog } from './overlay.js';
8
9
  import { RadioGroup } from './radio-group.js';
9
- export function Select(props) { const { messages } = useHIG(); const [open, setOpen] = useState(false); const trigger = useRef(null); const [current, set] = useControllable(props.value, props.defaultValue ?? '', props.onValueChange); return _jsxs(View, { children: [_jsxs(Button, { ref: trigger, disabled: props.disabled, intent: 'secondary', onPress: () => setOpen(true), children: [props.label, ": ", props.options.find(o => o.value === current)?.label ?? messages.choose ?? en.choose] }), _jsx(Dialog, { title: props.label, description: messages.chooseOne ?? en.chooseOne, open: open, onOpenChange: setOpen, returnFocusRef: trigger, children: _jsx(RadioGroup, { ...props, value: current, onValueChange: v => { set(v); setOpen(false); } }) })] }); }
10
+ export function Select(props) { const { messages } = useHIG(); const [open, setOpen] = useState(false); const trigger = useRef(null); assertUniqueKeys(props.options, o => o.value, 'Select'); const controlled = useRef(props.value !== undefined).current; const [stored, set] = useControllable(props.value, props.defaultValue ?? props.options.find(o => !o.disabled)?.value ?? '', props.onValueChange); const current = props.options.some(o => o.value === stored && !o.disabled) ? stored : controlled ? '' : props.options.find(o => !o.disabled)?.value ?? ''; useEffect(() => { if (!controlled && stored !== current)
11
+ set(current); }, [controlled, stored, current]); return _jsxs(View, { children: [_jsxs(Button, { ref: trigger, disabled: props.disabled, intent: 'secondary', onPress: () => setOpen(true), children: [props.label, ": ", props.options.find(o => o.value === current)?.label ?? messages.choose ?? en.choose] }), _jsx(Dialog, { title: props.label, description: messages.chooseOne ?? en.chooseOne, open: open, onOpenChange: setOpen, returnFocusRef: trigger, children: _jsx(RadioGroup, { ...props, value: current, onValueChange: v => { set(v); setOpen(false); } }) })] }); }