@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
@@ -1,21 +1,55 @@
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 { View } from 'react-native';
3
- import { useColors, useFills, useHIG, useMessages } from './provider.js';
3
+ import { useColors, useFills, useHIG, useMessages, useNumberLocale, usePresentNumber } from './provider.js';
4
4
  import { Text } from './surface.js';
5
- import { IconButton } from './button.js';
6
- import { ChevronIcon, CloseIcon } from './icons.js';
5
+ import { Button } from './button.js';
7
6
  import { SwitchRow } from './switch-row.js';
8
7
  import { ListGroup, ListRow } from './list-group.js';
9
8
  import { AnimatedNumberReadout } from './animated-number.js';
10
- import { formatNumberReadout } from './animated-number-model.js';
9
+ import { HeaderClose, ScreenHeader } from './screen-header.js';
10
+ import { StickyHeaderLayout, stickyHeaderFill } from './sticky-header.js';
11
+ import { figureProps, figureReading } from './figure.js';
11
12
  const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
13
+ function HeaderRow({ title, onClose, onBack, headerAction, headingId, backProps, closeProps }) {
14
+ const t = useMessages();
15
+ return _jsx(ScreenHeader, { testID: 'position', title: title, onBack: onBack, backProps: backProps, headingId: headingId, action: headerAction ?? (onClose ? _jsx(HeaderClose, { testID: 'position-close', label: t.close, onClose: onClose, closeProps: closeProps }) : null) });
16
+ }
17
+ /** The PositionBlock header on its own: put it in a scroller's sticky header and render `PositionBlock` with `header={false}` under it. It carries the block's top and side padding. */
18
+ export function PositionBlockHeader({ style, testID, scrolled, stickyHeaderBackground, ...props }) {
19
+ const colors = useColors();
20
+ return _jsx(View, { testID: testID, style: [{ paddingTop: 16, paddingHorizontal: 16 }, scrolled === undefined ? undefined : stickyHeaderFill(scrolled, stickyHeaderBackground ?? colors.background), style], children: _jsx(HeaderRow, { ...props }) });
21
+ }
22
+ function Track({ checked, testID }) {
23
+ const colors = useColors(), fills = useFills();
24
+ return _jsx(View, { testID: testID, style: { width: 40, height: 24, borderRadius: 12, padding: 3, backgroundColor: checked ? colors.action : fills.raised, alignItems: checked ? 'flex-end' : 'flex-start' }, children: _jsx(View, { style: { width: 18, height: 18, borderRadius: 9, backgroundColor: checked ? colors.onAction : colors.text } }) });
25
+ }
12
26
  /** The position being opened or edited as a screen: a summary of what it costs and where it ends, an optional paper trading switch, and its settings as grouped rows that open the host's own views. */
13
- export function PositionBlock({ title, details, note, paperTrade, groups, onClose, onBack, headerAction, testID }) {
14
- const colors = useColors(), fills = useFills(), t = useMessages(), { direction, locale } = useHIG();
27
+ export function PositionBlock({ title, details, note, paperTrade, groups, onClose, onBack, headerAction, headingId, header = true, stickyHeader, stickyHeaderBackground, scrollComponent, backProps, closeProps, testID }) {
28
+ const colors = useColors(), fills = useFills(), { direction } = useHIG(), locale = useNumberLocale(), present = usePresentNumber();
15
29
  const figure = { fontSize: 16, lineHeight: 24, fontWeight: '500' };
16
30
  const shown = groups.filter(group => group.length > 0);
17
- return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [_jsxs(View, { testID: 'position-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: 'position-back', onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: colors.text }) }) }) : null }), _jsx(Text, { testID: 'position-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 ?? (onClose ? _jsx(IconButton, { intent: 'ghost', label: t.close, suppressFeedback: true, testID: 'position-close', onPress: onClose, children: _jsx(CloseIcon, { color: colors.text }) }) : null) })] }), details.length > 0 ? _jsx(View, { testID: 'position-details', style: { gap: 12, marginTop: 16, paddingHorizontal: 20 }, children: details.map((detail, index) => {
18
- const live = typeof detail.value === 'string' ? null : detail.value, reading = live ? formatNumberReadout(live.value, locale, live.options, undefined, live.prefix, live.suffix).text : detail.value;
19
- return _jsxs(View, { testID: `position-detail-${detail.id ?? index}`, accessible: true, accessibilityLabel: `${detail.label}, ${reading}`, style: { direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12 }, children: [_jsx(Text, { ...hidden, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, color: colors.muted }, children: detail.label }), _jsx(View, { ...hidden, style: { flexShrink: 1 }, children: live ? _jsx(AnimatedNumberReadout, { ...live, tone: detail.tone ?? 'text', style: figure }) : _jsx(Text, { style: { ...figure, color: detail.tone ? colors[detail.tone] : colors.text, textAlign: 'right' }, children: reading }) })] }, detail.id ?? index);
20
- }) }) : null, note ? _jsx(Text, { testID: 'position-note', style: { color: colors.muted, fontSize: 13, lineHeight: 20, marginTop: 8, paddingHorizontal: 20 }, children: note }) : null, paperTrade || shown.length > 0 ? _jsxs(View, { testID: 'position-groups', style: { gap: 24, marginTop: 16 }, children: [paperTrade ? _jsx(SwitchRow, { testID: 'position-paper-trade', label: paperTrade.label, checked: paperTrade.checked, disabled: paperTrade.disabled, onCheckedChange: paperTrade.onCheckedChange, style: { minHeight: 56, paddingVertical: 8, paddingHorizontal: 20, borderRadius: 20, backgroundColor: fills.well, opacity: paperTrade.disabled ? 0.5 : 1 }, children: _jsxs(View, { style: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: 12 }, children: [_jsx(Text, { style: { flex: 1, flexShrink: 1, minWidth: 0, fontSize: 16, lineHeight: 24, color: colors.text }, children: paperTrade.label }), _jsx(View, { testID: 'position-paper-trade-track', style: { width: 40, height: 24, borderRadius: 12, padding: 3, backgroundColor: paperTrade.checked ? colors.action : fills.raised, alignItems: paperTrade.checked ? 'flex-end' : 'flex-start' }, children: _jsx(View, { style: { width: 18, height: 18, borderRadius: 9, backgroundColor: paperTrade.checked ? colors.onAction : colors.text } }) })] }) }) : null, shown.map((group, index) => _jsx(ListGroup, { testID: `position-group-${index}`, children: group.map(row => _jsx(ListRow, { testID: `position-row-${row.id}`, label: row.label, value: row.value, onSelect: row.onSelect, disabled: row.disabled }, row.id)) }, index))] }) : null] });
31
+ const read = (live) => figureReading(live, locale, present(live.options));
32
+ const flagRow = paperTrade ? _jsx(SwitchRow, { testID: 'position-paper-trade', label: paperTrade.label, checked: paperTrade.checked, disabled: paperTrade.disabled, onCheckedChange: paperTrade.onCheckedChange, style: { minHeight: 56, paddingVertical: 8, paddingHorizontal: 20, borderRadius: 20, backgroundColor: fills.well, opacity: paperTrade.disabled ? 0.5 : 1 }, children: _jsxs(View, { style: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: 12 }, children: [_jsx(Text, { style: { flex: 1, flexShrink: 1, minWidth: 0, fontSize: 16, lineHeight: 24, color: colors.text }, children: paperTrade.label }), _jsx(Track, { checked: paperTrade.checked, testID: 'position-paper-trade-track' })] }) }) : null;
33
+ const action = paperTrade?.action;
34
+ const row = (item) => {
35
+ const live = item.value == null || typeof item.value === 'string' ? null : item.value, reading = live ? read(live) : item.value;
36
+ if (item.onCheckedChange)
37
+ return _jsx(SwitchRow, { testID: `position-row-${item.id}`, label: item.label, accessibilityHint: reading, checked: !!item.checked, disabled: item.disabled, onCheckedChange: item.onCheckedChange, style: { minHeight: 56, paddingVertical: 8, paddingHorizontal: 20, backgroundColor: fills.well, opacity: item.disabled ? 0.5 : 1 }, children: _jsxs(View, { style: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: 12 }, children: [_jsx(Text, { style: { flex: 1, flexShrink: 1, minWidth: 0, fontSize: 16, lineHeight: 24, color: colors.text }, children: item.label }), live ? _jsx(AnimatedNumberReadout, { ...figureProps(live), tone: 'muted', style: { fontSize: 16, lineHeight: 24 } }) : reading ? _jsx(Text, { numberOfLines: 1, style: { flexShrink: 1, maxWidth: '50%', fontSize: 16, lineHeight: 24, color: colors.muted, textAlign: 'right' }, children: reading }) : null, _jsx(Track, { checked: !!item.checked, testID: `position-row-${item.id}-track` })] }) }, item.id);
38
+ return _jsx(ListRow, { testID: `position-row-${item.id}`, label: item.label, value: live ? _jsx(AnimatedNumberReadout, { ...figureProps(live), tone: 'muted', testID: `position-row-${item.id}-value`, style: { fontSize: 16, lineHeight: 24 } }) : item.value, valueLabel: live ? reading : undefined, onSelect: item.onSelect, disabled: item.disabled }, item.id);
39
+ };
40
+ const headerRow = _jsx(HeaderRow, { title: title, onClose: onClose, onBack: onBack, headerAction: headerAction, headingId: headingId, backProps: backProps, closeProps: closeProps });
41
+ const content = _jsxs(_Fragment, { children: [details.length > 0 ? _jsx(View, { testID: 'position-details', style: { gap: 12, marginTop: 16, paddingHorizontal: 20 }, children: details.map((detail, index) => {
42
+ const key = detail.id ?? index, live = typeof detail.value === 'string' ? null : detail.value, reading = live ? read(live) : detail.value;
43
+ const spoken = `${detail.label}, ${reading}${detail.struck ? `, ${detail.struck}` : ''}`;
44
+ const value = live ? _jsx(AnimatedNumberReadout, { ...figureProps(live), tone: detail.tone ?? 'text', style: figure }) : _jsx(Text, { style: { ...figure, color: detail.tone ? colors[detail.tone] : colors.text, textAlign: 'right' }, children: reading });
45
+ // The line is drawn over the figure, so it crosses animated digits as well as text.
46
+ const drawn = detail.struck ? _jsxs(View, { testID: `position-detail-${key}-struck`, style: { position: 'relative' }, children: [value, _jsx(View, { pointerEvents: 'none', style: { position: 'absolute', start: 0, end: 0, top: '50%', height: 1, backgroundColor: detail.tone ? colors[detail.tone] : colors.text } })] }) : value;
47
+ const label = _jsx(Text, { ...hidden, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, color: colors.muted }, children: detail.label });
48
+ if (detail.labelAccessory != null)
49
+ return _jsxs(View, { testID: `position-detail-${key}`, style: { direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12 }, children: [_jsxs(View, { style: { direction, flexDirection: 'row', alignItems: 'center', gap: 6, flexShrink: 1 }, children: [_jsx(Text, { testID: `position-detail-${key}-label`, accessible: true, accessibilityLabel: spoken, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, color: colors.muted }, children: detail.label }), detail.labelAccessory] }), _jsx(View, { ...hidden, style: { flexShrink: 1 }, children: drawn })] }, key);
50
+ return _jsxs(View, { testID: `position-detail-${key}`, accessible: true, accessibilityLabel: spoken, style: { direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12 }, children: [label, _jsx(View, { ...hidden, style: { flexShrink: 1 }, children: drawn })] }, key);
51
+ }) }) : null, note ? _jsx(Text, { testID: 'position-note', style: { color: colors.muted, fontSize: 13, lineHeight: 20, marginTop: 8, paddingHorizontal: 20 }, children: note }) : null, paperTrade || shown.length > 0 ? _jsxs(View, { testID: 'position-groups', style: { gap: 24, marginTop: 16 }, children: [action ? _jsxs(View, { testID: 'position-paper-trade-card', style: { borderRadius: 20, overflow: 'hidden', backgroundColor: fills.well }, children: [flagRow, _jsx(View, { style: { paddingHorizontal: 20, paddingBottom: 16 }, children: _jsx(Button, { testID: 'position-paper-trade-action', fullWidth: true, intent: action.intent ?? 'primary', busy: action.busy, disabled: action.disabled, onPress: action.onSelect, children: action.label }) })] }) : flagRow, shown.map((group, index) => _jsx(ListGroup, { testID: `position-group-${index}`, children: group.map(row) }, index))] }) : null] });
52
+ if (header && stickyHeader)
53
+ return _jsx(StickyHeaderLayout, { testID: testID, headerTestID: 'position-sticky-header', header: headerRow, background: stickyHeaderBackground, scrollComponent: scrollComponent, children: content });
54
+ return _jsxs(View, { testID: testID, style: header ? { padding: 16 } : { padding: 16, paddingTop: 0 }, children: [header ? headerRow : null, content] });
21
55
  }
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import { type StyleProp, type ViewStyle } from 'react-native';
3
+ /** One quick choice. `testID` is the chip's test ID; without it the chip takes `<group testID>-<value>`. */
4
+ export interface PresetOption<T extends string | number = string> {
5
+ value: T;
6
+ label: string;
7
+ disabled?: boolean;
8
+ testID?: string;
9
+ }
10
+ export interface PresetGroupProps<T extends string | number = string> {
11
+ /** Accessible name of the group; not drawn, so a heading or row above it names it on screen. Native reads it as each chip's hint, after the chip's own label and state. */
12
+ label?: string;
13
+ options: readonly PresetOption<T>[];
14
+ /** The selected choice; `null` selects none. Omit it, with `defaultValue`, to let the group keep its own selection. */
15
+ value?: T | null;
16
+ defaultValue?: T | null;
17
+ /** Called with the choice taken. A press on the selected chip, or on a dimmed one, does nothing. */
18
+ onValueChange?: (value: T) => void;
19
+ /** Chips per row. Defaults to every option in one row; with fewer columns the chips wrap onto equal-width rows. */
20
+ columns?: number;
21
+ /** Fill of the selected chip. Defaults to `primary`; TargetBlock passes `destructive` for a stop loss. */
22
+ selectedIntent?: 'primary' | 'destructive' | 'up' | 'down';
23
+ disabled?: boolean;
24
+ /** Keeps the provider's `selection` feedback off this group, for a host that plays its own cue. By default a new choice plays it like a SegmentedControl. */
25
+ suppressFeedback?: boolean;
26
+ /** Layout of the group, such as a top margin. */
27
+ style?: StyleProp<ViewStyle>;
28
+ testID?: string;
29
+ }
30
+ /** A set of quick choices as chips in an equal-width grid, such as order sizes or leverage steps. Single choice, or none; each chip is a button that reads selected, 44dp tall with a 48dp touch target, in the interface face. TargetBlock draws its presets with it. */
31
+ export declare function PresetGroup<T extends string | number = string>({ label, options, value, defaultValue, onValueChange, columns, selectedIntent, disabled, suppressFeedback, style, testID }: PresetGroupProps<T>): React.JSX.Element;
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { assertUniqueKeys } from '@bloxwap/hig/contracts';
3
+ import { View } from 'react-native';
4
+ import { useColors, useControllable, useHIG } from './provider.js';
5
+ import { Button } from './button.js';
6
+ import { Text } from './surface.js';
7
+ /**
8
+ * A chip is 44dp tall; 2dp above and below make its 48dp touch target (Material's 48dp target around a smaller visual,
9
+ * as every HIG native control under 48dp does). Chips and rows sit 8 apart, so the slop reaches half the gap sideways
10
+ * (4) and 2 of it vertically: neighbouring targets meet but never overlap, and a chip narrower than 48 (many columns
11
+ * on a narrow screen) still gets the whole column pitch. Android (Fabric) counts a child's hitSlop in its parent's
12
+ * overflow inset, so slop past the row's own frame is reachable there too, unless a clipping ancestor cuts it.
13
+ */
14
+ const chipSlop = { top: 2, bottom: 2, left: 4, right: 4 };
15
+ /** A set of quick choices as chips in an equal-width grid, such as order sizes or leverage steps. Single choice, or none; each chip is a button that reads selected, 44dp tall with a 48dp touch target, in the interface face. TargetBlock draws its presets with it. */
16
+ export function PresetGroup({ label, options, value, defaultValue = null, onValueChange, columns, selectedIntent = 'primary', disabled, suppressFeedback, style, testID }) {
17
+ assertUniqueKeys(options, option => option.value, 'Choices');
18
+ const { direction } = useHIG(), colors = useColors();
19
+ const [current, set] = useControllable(value, defaultValue, onValueChange, suppressFeedback ? null : 'selection');
20
+ const count = Math.max(1, Math.floor(columns ?? options.length) || 1), rows = [];
21
+ for (let index = 0; index < options.length; index += count)
22
+ rows.push(options.slice(index, index + count));
23
+ // The label is one line in every chip: a label wider than its column shrinks to fit (down to three quarters of its
24
+ // size) instead of wrapping, so `$63,000` never breaks over two lines in a narrow column. Colours are Button's own.
25
+ const chip = (option) => {
26
+ const selected = current !== null && Object.is(current, option.value), blocked = !!disabled || !!option.disabled;
27
+ const color = blocked ? colors.muted : !selected ? colors.text : selectedIntent === 'primary' ? colors.onAction : colors.background;
28
+ return _jsx(Button, { testID: option.testID ?? (testID === undefined ? undefined : `${testID}-${option.value}`), intent: selected ? selectedIntent : 'secondary', disabled: blocked || undefined, accessibilityLabel: option.label, accessibilityState: { selected }, accessibilityHint: label || undefined, hitSlop: chipSlop, suppressFeedback: true, contentMode: 'custom', onPress: () => { if (!blocked && !selected)
29
+ set(option.value); }, style: { flex: 1, alignSelf: 'auto', paddingHorizontal: 8 }, children: _jsx(Text, { testID: option.testID ? `${option.testID}-label` : testID === undefined ? undefined : `${testID}-${option.value}-label`, numberOfLines: 1, adjustsFontSizeToFit: true, minimumFontScale: 0.75, style: { alignSelf: 'stretch', color, fontSize: 16, fontWeight: '600', textAlign: 'center' }, children: option.label }) }, String(option.value));
30
+ };
31
+ // A short row keeps the column width, as the web grid does: empty cells hold the place of the missing chips, also in a single row with more columns than options.
32
+ const row = (items, key, own) => _jsxs(View, { ...own, style: [{ direction, flexDirection: 'row', gap: 8 }, key === undefined ? { alignSelf: 'stretch' } : null, key === undefined ? style : null], children: [items.map(chip), Array.from({ length: items.length > 0 ? count - items.length : 0 }, (_, cell) => _jsx(View, { style: { flex: 1 } }, `cell-${cell}`))] }, key);
33
+ // React Native has no named group: VoiceOver never reads a container that is not an element (RN exposes no
34
+ // `accessibilityContainerType`), and TalkBack reads a plain container's description unreliably. So the group's name
35
+ // reaches each chip as its hint, which both read after the chip ("$25, button, selected, Size"), and the container
36
+ // carries none, so it is never read twice.
37
+ const group = { testID };
38
+ return rows.length > 1 ? _jsx(View, { ...group, style: [{ alignSelf: 'stretch', gap: 8 }, style], children: rows.map((items, index) => row(items, index)) }) : row(rows[0] ?? [], undefined, group);
39
+ }
@@ -0,0 +1,107 @@
1
+ import React from 'react';
2
+ import { type ScrollViewProps } from 'react-native';
3
+ import { type PresetOption } from './preset-group.js';
4
+ import { type ScreenHeaderControlProps } from './screen-header.js';
5
+ /** The row that opens the host's own entry of a value no quick choice holds, such as a keypad. */
6
+ export interface PresetPickerCustom {
7
+ /** The row's text: Custom amount. */
8
+ label: string;
9
+ /** Called on a press; the host opens its own entry. */
10
+ onSelect: () => void;
11
+ /** The value the host's entry set, as host text: `$75`. It is drawn on the trailing edge and the row reads as selected. */
12
+ value?: string;
13
+ /** Whether the row reads as selected. Defaults to whether `value` is given. */
14
+ selected?: boolean;
15
+ /** The row's accessible name, in place of its text (and value): Edit custom size, current $75. */
16
+ accessibilityLabel?: string;
17
+ /** The row's test ID, in place of `<testID>-custom`. */
18
+ testID?: string;
19
+ /** Pressable props for the row, such as `{android_disableSound: true}` when the host plays its own sound. HIG keeps its own name, role, state and press. */
20
+ pressProps?: ScreenHeaderControlProps;
21
+ }
22
+ /** Steps through the chips with the screen reader's adjust gesture (swipe up or down on iOS, volume keys on Android). */
23
+ export interface PresetPickerAdjustable {
24
+ /** Name of the increment action: Increase leverage. */
25
+ incrementLabel: string;
26
+ /** Name of the decrement action: Decrease leverage. */
27
+ decrementLabel: string;
28
+ /** The adjustable view's test ID, in place of `<testID>-adjustable`. */
29
+ testID?: string;
30
+ /** The lowest value the control reaches, reported in `accessibilityValue.min` with `max` and `now`: 1 for leverage. */
31
+ min?: number;
32
+ /** The highest value the control reaches, reported in `accessibilityValue.max`: 40 for leverage. */
33
+ max?: number;
34
+ /** The current value, reported in `accessibilityValue.now`: 10 for 10×. Defaults to the selected chip's value when it is a number. */
35
+ now?: number;
36
+ }
37
+ export interface PresetPickerBlockProps<T extends string | number = number> {
38
+ /** Heading of the header. Leave it out for a pane whose host draws its own header: the block then starts at the headline figure. */
39
+ title?: string;
40
+ /** The headline figure, the value being chosen. `null` reads as unknown. */
41
+ value: number | null;
42
+ /** Format of the headline figure, such as `{style:'currency',currency:'USD',maximumFractionDigits:0}`. */
43
+ valueOptions?: Intl.NumberFormatOptions;
44
+ /** Text drawn before the figure. */
45
+ valuePrefix?: string;
46
+ /** Text drawn after the figure, such as `×` for leverage. */
47
+ valueSuffix?: string;
48
+ /** What the figure is read as before its value: Size. */
49
+ valueLabel?: string;
50
+ /** 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 and read as given, static unless `animateFormatted`; `value` still decides known or unknown. As `AnimatedNumberReadout` `formattedValue`. */
51
+ formattedValue?: string;
52
+ /** With `formattedValue`, rolls each of its digits in place, counted from the end, as `AnimatedNumberReadout` `animateFormatted`. */
53
+ animateFormatted?: boolean;
54
+ /** The quick choices as chips, in order: `{value, label, disabled?, testID?}`. Labels are host text: `$25`, `Max`, `40×`. A chip without `testID` takes `<testID>-preset-<value>`. */
55
+ presets: readonly PresetOption<T>[];
56
+ /** The chip shown selected; `null` selects none, such as for a custom value. */
57
+ selected: T | null;
58
+ /** Called with the chip taken. A press on the selected chip, or on a dimmed one, does nothing. */
59
+ onPresetChange: (value: T) => void;
60
+ /** Accessible name of the chips, read as each chip's hint: Size. Defaults to `title`. */
61
+ presetsLabel?: string;
62
+ /** Chips per row. Defaults to every chip in one row. */
63
+ columns?: number;
64
+ /** Makes the chips one adjustable control that steps to the next or previous enabled chip, named by `presetsLabel` and valued by the selected chip's label. */
65
+ adjustable?: PresetPickerAdjustable;
66
+ /** The row that opens the host's own entry, drawn above the chips. */
67
+ custom?: PresetPickerCustom;
68
+ /** Fill of the selected chip, the selected custom row and the confirming action: `primary` (the default) or `destructive`. */
69
+ intent?: 'primary' | 'destructive';
70
+ /** Drawn as given between the chips and the actions, such as a muted note. */
71
+ children?: React.ReactNode;
72
+ /** Called on the confirming action. */
73
+ onSubmit: () => void;
74
+ /** Text of the confirming action: Set Size. */
75
+ submitLabel: string;
76
+ submitDisabled?: boolean;
77
+ /** The confirming action shows a spinner and ignores presses. */
78
+ busy?: boolean;
79
+ /** Shows Cancel on the leading side of the confirming action, the two sharing the row equally. */
80
+ onCancel?: () => void;
81
+ /** Text of Cancel. Defaults to the built-in "Cancel". */
82
+ cancelLabel?: string;
83
+ /** Keeps the provider's feedback off the chips and both actions, for a host that plays its own cue. */
84
+ suppressFeedback?: boolean;
85
+ /** Shows Back on the leading edge of the header (needs `title`). */
86
+ onBack?: () => void;
87
+ /** Pressable props for Back, such as `{android_disableSound: true}`. */
88
+ backProps?: ScreenHeaderControlProps;
89
+ /** A control on the trailing edge of the header, usually an IconButton. */
90
+ headerAction?: React.ReactNode;
91
+ /** `nativeID` of the title, so a sheet can name itself with `accessibilityLabelledBy` (Android). */
92
+ headingId?: string;
93
+ /** Keeps the header pinned while the rest scrolls: the block becomes its own scroll view with the header as its sticky first child. Needs `title`; place it in a bounded container. */
94
+ stickyHeader?: boolean;
95
+ /** With `stickyHeader`: the header's fill once content is under it. Defaults to the background role; in a sheet pass the sheet's fill. */
96
+ stickyHeaderBackground?: string;
97
+ /** The scroll view used with `stickyHeader`, such as a sheet library's own. */
98
+ scrollComponent?: React.ComponentType<ScrollViewProps>;
99
+ /** Prefix of the test IDs: `<testID>-header`, `-back`, `-title`, `-headline`, `-custom`, `-custom-value`, `-presets`, `-preset-<value>`, `-adjustable`, `-actions`, `-cancel` and `-confirm`. Defaults to `preset-picker`. */
100
+ testID?: string;
101
+ }
102
+ /**
103
+ * Choose one value from quick choices as a screen: an optional header, the value as the headline figure, an optional row that opens the
104
+ * host's own entry, the choices as chips, then Cancel and the confirming action. Draws a trade sheet's Size and Leverage panes. It reuses
105
+ * TargetBlock's parts (the headline, the Custom row, PresetGroup and the actions row) without its price card and unit control.
106
+ */
107
+ export declare function PresetPickerBlock<T extends string | number = number>({ title, value, valueOptions, valuePrefix, valueSuffix, valueLabel, formattedValue, animateFormatted, presets, selected, onPresetChange, presetsLabel, columns, adjustable, custom, intent, children, onSubmit, submitLabel, submitDisabled, busy, onCancel, cancelLabel, suppressFeedback, onBack, backProps, headerAction, headingId, stickyHeader, stickyHeaderBackground, scrollComponent, testID }: PresetPickerBlockProps<T>): React.JSX.Element;
@@ -0,0 +1,43 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Pressable, View } from 'react-native';
3
+ import { useColors, useFills, useHIG, useMessages } from './provider.js';
4
+ import { Text } from './surface.js';
5
+ import { Button } from './button.js';
6
+ import { PresetGroup } from './preset-group.js';
7
+ import { ChevronIcon } from './icons.js';
8
+ import { AnimatedNumberReadout } from './animated-number.js';
9
+ import { ScreenHeader } from './screen-header.js';
10
+ import { StickyHeaderLayout } from './sticky-header.js';
11
+ const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
12
+ /**
13
+ * Choose one value from quick choices as a screen: an optional header, the value as the headline figure, an optional row that opens the
14
+ * host's own entry, the choices as chips, then Cancel and the confirming action. Draws a trade sheet's Size and Leverage panes. It reuses
15
+ * TargetBlock's parts (the headline, the Custom row, PresetGroup and the actions row) without its price card and unit control.
16
+ */
17
+ export function PresetPickerBlock({ title, value, valueOptions, valuePrefix, valueSuffix, valueLabel, formattedValue, animateFormatted, presets, selected, onPresetChange, presetsLabel, columns, adjustable, custom, intent = 'primary', children, onSubmit, submitLabel, submitDisabled, busy, onCancel, cancelLabel, suppressFeedback, onBack, backProps, headerAction, headingId, stickyHeader, stickyHeaderBackground, scrollComponent, testID = 'preset-picker' }) {
18
+ const colors = useColors(), fills = useFills(), t = useMessages(), { direction } = useHIG();
19
+ const id = (part) => `${testID}-${part}`;
20
+ const destructive = intent === 'destructive', onFill = destructive ? colors.background : colors.onAction;
21
+ const customSelected = custom ? (custom.selected ?? custom.value !== undefined) : false;
22
+ const chevron = (color) => _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] }, children: _jsx(ChevronIcon, { color: color }) });
23
+ const label = presetsLabel ?? title;
24
+ const group = presets.length > 0 ? _jsx(PresetGroup, { testID: id('presets'), label: label, options: presets.map(option => ({ ...option, testID: option.testID ?? id(`preset-${option.value}`) })), value: selected, onValueChange: onPresetChange, columns: columns, selectedIntent: intent, suppressFeedback: suppressFeedback }) : null;
25
+ // The adjust gesture steps from the selected chip (or the first, when none is) to the next enabled one.
26
+ const enabled = presets.filter(option => !option.disabled), at = enabled.findIndex(option => selected !== null && Object.is(option.value, selected));
27
+ const step = (delta) => { const next = enabled[at < 0 ? 0 : Math.max(0, Math.min(enabled.length - 1, at + delta))]; if (next && !Object.is(next.value, selected))
28
+ onPresetChange(next.value); };
29
+ const current = presets.find(option => selected !== null && Object.is(option.value, selected));
30
+ // With a range the value is reported as min, max and now beside the chip's label; without one, as the label alone.
31
+ const range = (chip) => {
32
+ if (!adjustable || (adjustable.min === undefined && adjustable.max === undefined && adjustable.now === undefined))
33
+ return chip ? { text: chip.label } : undefined;
34
+ const now = adjustable.now ?? (typeof chip?.value === 'number' ? chip.value : undefined);
35
+ return { min: adjustable.min, max: adjustable.max, ...(now !== undefined ? { now } : {}), ...(chip ? { text: chip.label } : {}) };
36
+ };
37
+ const chips = adjustable && group ? _jsx(View, { testID: adjustable.testID ?? id('adjustable'), accessible: true, accessibilityRole: 'adjustable', accessibilityLabel: label, accessibilityValue: range(current), accessibilityActions: [{ name: 'increment', label: adjustable.incrementLabel }, { name: 'decrement', label: adjustable.decrementLabel }], onAccessibilityAction: event => step(event.nativeEvent.actionName === 'increment' ? 1 : -1), children: group }) : group;
38
+ const header = title !== undefined ? _jsx(ScreenHeader, { title: title, onBack: onBack, backProps: backProps, action: headerAction, headingId: headingId, testID: testID }) : null;
39
+ const body = _jsxs(_Fragment, { children: [_jsx(View, { style: { alignItems: 'center' }, children: _jsx(AnimatedNumberReadout, { testID: id('headline'), value: value, options: valueOptions, formattedValue: formattedValue, animateFormatted: animateFormatted, prefix: valuePrefix, suffix: valueSuffix, label: valueLabel, style: { fontSize: 44, lineHeight: 50, fontWeight: '700', letterSpacing: -0.9, textAlign: 'center' } }) }), custom ? _jsxs(Pressable, { ...custom.pressProps, testID: custom.testID ?? id('custom'), accessibilityRole: 'button', accessibilityLabel: custom.accessibilityLabel ?? (custom.value !== undefined ? `${custom.label}, ${custom.value}` : undefined), accessibilityState: { selected: customSelected }, onPress: custom.onSelect, style: ({ pressed }) => ({ direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12, minHeight: 48, paddingHorizontal: 16, borderRadius: 9999, backgroundColor: customSelected ? (destructive ? colors.negative : colors.action) : pressed ? fills.raised : fills.well, opacity: customSelected && pressed ? 0.9 : 1 }), children: [_jsx(Text, { ...hidden, numberOfLines: 1, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, fontWeight: '600', color: customSelected ? onFill : colors.text }, children: custom.label }), _jsxs(View, { ...hidden, style: { direction, flexDirection: 'row', alignItems: 'center', gap: 6, flexShrink: 1 }, children: [custom.value !== undefined ? _jsx(Text, { testID: id('custom-value'), numberOfLines: 1, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, fontWeight: '500', color: customSelected ? onFill : colors.muted }, children: custom.value }) : null, chevron(customSelected ? onFill : colors.muted)] })] }) : null, chips, children, _jsxs(View, { testID: id('actions'), style: { direction, flexDirection: 'row', gap: 8 }, children: [onCancel ? _jsx(Button, { testID: id('cancel'), intent: 'secondary', suppressFeedback: suppressFeedback, onPress: onCancel, style: { flex: 1, alignSelf: 'auto' }, children: cancelLabel ?? t.cancel }) : null, _jsx(Button, { testID: id('confirm'), intent: intent, disabled: submitDisabled, busy: busy, suppressFeedback: suppressFeedback, onPress: onSubmit, style: { flex: 1, alignSelf: 'auto' }, children: submitLabel })] })] });
40
+ if (stickyHeader && header)
41
+ return _jsx(StickyHeaderLayout, { testID: testID, headerTestID: id('sticky-header'), header: header, background: stickyHeaderBackground, scrollComponent: scrollComponent, bodyStyle: { direction, gap: 16, paddingTop: 16 }, children: body });
42
+ return _jsxs(View, { testID: testID, style: { direction, padding: 16, gap: 16 }, children: [header, body] });
43
+ }
@@ -1,16 +1,23 @@
1
1
  import React from 'react';
2
+ import { type ScrollViewProps } from 'react-native';
3
+ import { type Figure } from './figure.js';
2
4
  import type { AssetArtwork } from './asset-balance-row.js';
3
5
  export type { AssetArtwork } from './asset-balance-row.js';
6
+ /** 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. */
7
+ export type ProfileFigure = Figure;
4
8
  /** One row of a profile section. The host supplies every label and value. */
5
9
  export interface ProfileRow {
6
10
  id: string;
7
11
  label: string;
8
12
  leading?: React.ReactNode;
9
- value?: React.ReactNode;
13
+ /** Short text on the trailing edge, or a live figure that updates place by place. */
14
+ value?: React.ReactNode | ProfileFigure;
15
+ /** Colours the value. Without it the value keeps the row's muted value style. */
16
+ tone?: 'positive' | 'warning' | 'negative' | 'muted';
10
17
  trailing?: React.ReactNode;
11
18
  onSelect?: () => void;
12
19
  disabled?: boolean;
13
- /** With `onCheckedChange`, the row is a switch: the track trails and the label names it. */
20
+ /** With `onCheckedChange`, the row is a switch: the whole row is the target, the track trails and the label names it. */
14
21
  checked?: boolean;
15
22
  onCheckedChange?: (checked: boolean) => void;
16
23
  }
@@ -25,18 +32,44 @@ export interface ProfileStatus {
25
32
  label: string;
26
33
  tone?: 'positive' | 'warning' | 'negative' | 'info';
27
34
  }
35
+ /** The primary action under the name, such as Log in for a signed-out viewer. The host writes the label. */
36
+ export interface ProfileAction {
37
+ label: string;
38
+ onSelect: () => void;
39
+ disabled?: boolean;
40
+ /** Defaults to `primary`. */
41
+ intent?: 'primary' | 'secondary';
42
+ }
28
43
  export interface ProfileBlockProps {
29
- /** The name under the avatar: a display name or a shortened address. */
30
- name: string;
44
+ /** 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. */
45
+ name?: string;
46
+ /** Host content beside the name, such as a badge. It stays in the accessibility tree, so give an interactive badge its own label. */
47
+ nameAccessory?: React.ReactNode;
31
48
  /** Colours the avatar when there is no artwork. */
32
49
  address?: string;
33
50
  avatar?: AssetArtwork;
51
+ /** Makes the avatar a button, for example to choose a picture. `avatarLabel` names it. */
52
+ onAvatarPress?: () => void;
53
+ /** The accessible name of the avatar button, such as Change profile picture. Defaults to `name`, then the built-in “Change profile picture”. */
54
+ avatarLabel?: string;
34
55
  status?: ProfileStatus;
35
56
  onEditName?: () => void;
36
57
  onShowAddress?: () => void;
37
58
  onClose?: () => void;
59
+ /** A full-width button under the name, such as Log in. */
60
+ action?: ProfileAction;
38
61
  sections: readonly ProfileSection[];
62
+ /** Host content under the sections on the block's inset, such as legal links. */
63
+ footer?: React.ReactNode;
64
+ /** Keeps the top bar (address and Close) pinned while the rest scrolls: the block becomes its own scroll view with the bar as its sticky first child, transparent at rest and filled once content scrolls under it. Place it in a bounded container, such as a sheet body. */
65
+ stickyHeader?: boolean;
66
+ /** With `stickyHeader`: the bar's fill once content is under it. Defaults to the background role; in a sheet pass the sheet's fill. */
67
+ stickyHeaderBackground?: string;
68
+ /** The scroll view used with `stickyHeader`, such as a sheet library's own. Defaults to React Native's ScrollView. */
69
+ scrollComponent?: React.ComponentType<ScrollViewProps>;
70
+ /** `nativeID` of the name heading, so a sheet around the block can name itself with `accessibilityLabelledBy` (Android). */
71
+ headingId?: string;
39
72
  testID?: string;
40
73
  }
41
74
  /** A person's profile as one screen: the address and close controls, the avatar with its status, the name, then the host's sections of rows. */
42
- export declare function ProfileBlock({ name, address, avatar, status, onEditName, onShowAddress, onClose, sections, testID }: ProfileBlockProps): React.JSX.Element;
75
+ export declare function ProfileBlock({ name, nameAccessory, address, avatar, onAvatarPress, avatarLabel, status, onEditName, onShowAddress, onClose, action, sections, footer, stickyHeader, stickyHeaderBackground, scrollComponent, headingId, testID }: ProfileBlockProps): React.JSX.Element;
@@ -1,16 +1,25 @@
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
+ import React from 'react';
2
3
  import { Image, Pressable, View } from 'react-native';
3
- import { useColors, useFills, useHIG, useMessages } from './provider.js';
4
+ import { StickyHeaderLayout } from './sticky-header.js';
5
+ import { useColors, useFills, useHIG, useMessages, useNumberLocale, usePresentNumber } from './provider.js';
4
6
  import { Text } from './surface.js';
7
+ import { Button } from './button.js';
5
8
  import { CloseIcon, EditIcon, QrIcon } from './icons.js';
6
9
  import { ListGroup, ListRow } from './list-group.js';
7
10
  import { SwitchRow } from './switch-row.js';
11
+ import { AnimatedNumberReadout } from './animated-number.js';
12
+ import { figureProps, figureReading } from './figure.js';
8
13
  import { addressColor } from './swap-shared.js';
9
14
  const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
15
+ /** A 44dp control keeps a 48dp touch target on every side. */
16
+ const targetSlop = { top: 2, bottom: 2, left: 2, right: 2 };
17
+ /** True for a `ProfileFigure`: a plain object with a `value`, not an element, array or other node. */
18
+ const isProfileFigure = (value) => value != null && typeof value === 'object' && !React.isValidElement(value) && !Array.isArray(value) && !(Symbol.iterator in value) && 'value' in value;
10
19
  /** A round 44 control with no fill of its own, like the other block headers; it takes the well fill while pressed. */
11
20
  function RoundButton({ label, testID, onPress, children }) {
12
21
  const fills = useFills();
13
- return _jsx(Pressable, { testID: testID, accessibilityRole: 'button', accessibilityLabel: label, onPress: onPress, hitSlop: { top: 2, bottom: 2 }, style: ({ pressed }) => ({ width: 44, height: 44, borderRadius: 22, alignItems: 'center', justifyContent: 'center', backgroundColor: pressed ? fills.well : 'transparent' }), children: children });
22
+ return _jsx(Pressable, { testID: testID, accessibilityRole: 'button', accessibilityLabel: label, onPress: onPress, hitSlop: targetSlop, style: ({ pressed }) => ({ width: 44, height: 44, borderRadius: 22, alignItems: 'center', justifyContent: 'center', backgroundColor: pressed ? fills.well : 'transparent' }), children: children });
14
23
  }
15
24
  /** A list row that is one switch: the same anatomy as ListRow, with the track on the trailing edge, level with the first line of the label. */
16
25
  function ProfileSwitchRow({ row }) {
@@ -19,10 +28,26 @@ function ProfileSwitchRow({ row }) {
19
28
  const first = { minHeight: 40, justifyContent: 'center' };
20
29
  return _jsx(SwitchRow, { testID: `profile-row-${row.id}`, label: row.label, checked: on, disabled: row.disabled, onCheckedChange: row.onCheckedChange, style: { minHeight: 56, paddingVertical: 8, paddingHorizontal: 20, backgroundColor: fills.well, opacity: row.disabled ? 0.5 : 1 }, children: _jsxs(View, { style: { flex: 1, flexDirection: 'row', alignItems: 'flex-start', gap: 12 }, children: [row.leading == null ? null : _jsx(View, { style: first, children: row.leading }), _jsx(Text, { style: { flex: 1, flexShrink: 1, minWidth: 0, paddingVertical: 8, fontSize: 16, lineHeight: 24, color: colors.text }, children: row.label }), _jsx(View, { style: first, children: _jsx(View, { testID: `profile-row-${row.id}-track`, style: { width: 40, height: 24, borderRadius: 12, padding: 3, backgroundColor: on ? colors.action : fills.raised, alignItems: on ? 'flex-end' : 'flex-start' }, children: _jsx(View, { style: { width: 18, height: 18, borderRadius: 9, backgroundColor: on ? colors.onAction : colors.text } }) }) })] }) });
21
30
  }
31
+ /** A row that opens something or shows a value. A live figure or a toned value is drawn here and read through `valueLabel`. */
32
+ function ProfileListRow({ row }) {
33
+ const locale = useNumberLocale(), present = usePresentNumber();
34
+ const { value, tone } = row, testID = `profile-row-${row.id}`;
35
+ const style = { fontSize: 16, lineHeight: 24, textAlign: 'right' };
36
+ if (isProfileFigure(value)) {
37
+ const reading = figureReading(value, locale, present(value.options));
38
+ return _jsx(ListRow, { testID: testID, label: row.label, leading: row.leading, valueLabel: reading, value: _jsx(AnimatedNumberReadout, { ...figureProps(value), tone: tone ?? 'muted', testID: `${testID}-value`, style: style }), trailing: row.trailing, onSelect: row.onSelect, disabled: row.disabled });
39
+ }
40
+ return _jsx(ListRow, { testID: testID, label: row.label, leading: row.leading, value: value, valueTone: tone, trailing: row.trailing, onSelect: row.onSelect, disabled: row.disabled });
41
+ }
22
42
  /** A person's profile as one screen: the address and close controls, the avatar with its status, the name, then the host's sections of rows. */
23
- export function ProfileBlock({ name, address, avatar, status, onEditName, onShowAddress, onClose, sections, testID }) {
43
+ export function ProfileBlock({ name, nameAccessory, address, avatar, onAvatarPress, avatarLabel, status, onEditName, onShowAddress, onClose, action, sections, footer, stickyHeader, stickyHeaderBackground, scrollComponent, headingId, testID }) {
24
44
  const colors = useColors(), fills = useFills(), t = useMessages(), { direction } = useHIG();
25
- const art = typeof avatar === 'string' ? _jsx(Image, { source: { uri: avatar }, style: { width: 144, height: 144 } }) : avatar ?? (address ? null : _jsx(Text, { style: { fontSize: 40, lineHeight: 48, fontWeight: '600', color: colors.muted }, children: name.slice(0, 2) }));
45
+ const art = typeof avatar === 'string' ? _jsx(Image, { source: { uri: avatar }, style: { width: 144, height: 144 } }) : avatar ?? (address ? null : _jsx(Text, { style: { fontSize: 40, lineHeight: 48, fontWeight: '600', color: colors.muted }, children: name?.slice(0, 2) }));
26
46
  const shown = sections.filter(section => section.rows.length > 0);
27
- return _jsxs(View, { testID: testID, style: { direction, padding: 16 }, children: [_jsxs(View, { testID: 'profile-bar', style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', minHeight: 44 }, children: [_jsx(View, { style: { minWidth: 44, alignItems: 'flex-start' }, children: onShowAddress ? _jsx(RoundButton, { label: t.showAddress, testID: 'profile-address', onPress: onShowAddress, children: _jsx(QrIcon, { color: colors.text }) }) : null }), _jsx(View, { style: { minWidth: 44, alignItems: 'flex-end' }, children: onClose ? _jsx(RoundButton, { label: t.close, testID: 'profile-close', onPress: onClose, children: _jsx(CloseIcon, { color: colors.text }) }) : null })] }), _jsxs(View, { style: { alignSelf: 'center', width: 144, height: 144, marginTop: 8 }, children: [_jsx(View, { ...hidden, testID: 'profile-avatar', style: { width: 144, height: 144, borderRadius: 72, overflow: 'hidden', alignItems: 'center', justifyContent: 'center', backgroundColor: avatar == null && address ? addressColor(address) : fills.well }, children: art }), status ? _jsx(View, { testID: 'profile-status', accessible: true, accessibilityLabel: status.label, style: { position: 'absolute', top: 10, end: 10, width: 20, height: 20, borderRadius: 10, borderWidth: 3, borderColor: colors.background, backgroundColor: colors[status.tone ?? 'warning'] } }) : null] }), _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 4, marginTop: 16 }, children: [_jsx(Text, { testID: 'profile-name', accessibilityRole: 'header', numberOfLines: 1, style: { flexShrink: 1, fontSize: 28, lineHeight: 34, fontWeight: '700', color: colors.text }, children: name }), onEditName ? _jsx(Pressable, { testID: 'profile-edit', accessibilityRole: 'button', accessibilityLabel: t.editName, onPress: onEditName, style: ({ pressed }) => ({ width: 44, height: 44, alignItems: 'center', justifyContent: 'center', opacity: pressed ? 0.6 : 1 }), children: _jsx(EditIcon, { color: colors.muted }) }) : null] }), shown.length > 0 ? _jsx(View, { testID: 'profile-sections', style: { gap: 24, marginTop: 24 }, children: shown.map(section => _jsx(ListGroup, { testID: `profile-section-${section.id}`, title: section.title, children: section.rows.map(row => row.onCheckedChange ? _jsx(ProfileSwitchRow, { row: row }, row.id) : _jsx(ListRow, { testID: `profile-row-${row.id}`, label: row.label, leading: row.leading, value: row.value, trailing: row.trailing, onSelect: row.onSelect, disabled: row.disabled }, row.id)) }, section.id)) }) : null] });
47
+ const disc = _jsx(View, { ...hidden, testID: 'profile-avatar', style: { width: 144, height: 144, borderRadius: 72, overflow: 'hidden', alignItems: 'center', justifyContent: 'center', backgroundColor: avatar == null && address ? addressColor(address) : fills.well }, children: art });
48
+ const bar = _jsxs(View, { testID: 'profile-bar', style: stickyHeader ? { direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', minHeight: 44 } : { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', minHeight: 44 }, children: [_jsx(View, { style: { minWidth: 44, alignItems: 'flex-start' }, children: onShowAddress ? _jsx(RoundButton, { label: t.showAddress, testID: 'profile-address', onPress: onShowAddress, children: _jsx(QrIcon, { color: colors.text }) }) : null }), _jsx(View, { style: { minWidth: 44, alignItems: 'flex-end' }, children: onClose ? _jsx(RoundButton, { label: t.close, testID: 'profile-close', onPress: onClose, children: _jsx(CloseIcon, { color: colors.text }) }) : null })] });
49
+ const body = _jsxs(_Fragment, { children: [_jsxs(View, { style: { alignSelf: 'center', width: 144, height: 144, marginTop: 8 }, children: [onAvatarPress ? _jsx(Pressable, { testID: 'profile-avatar-button', accessibilityRole: 'button', accessibilityLabel: avatarLabel ?? name ?? t.changeProfilePicture, onPress: onAvatarPress, style: ({ pressed }) => ({ borderRadius: 72, opacity: pressed ? 0.85 : 1 }), children: disc }) : disc, status ? _jsx(View, { testID: 'profile-status', accessible: true, accessibilityLabel: status.label, style: { position: 'absolute', top: 10, end: 10, width: 20, height: 20, borderRadius: 10, borderWidth: 3, borderColor: colors.background, backgroundColor: colors[status.tone ?? 'warning'] } }) : null] }), name != null ? _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 4, marginTop: 16 }, children: [_jsx(Text, { testID: 'profile-name', nativeID: headingId, accessibilityRole: 'header', numberOfLines: 1, style: { flexShrink: 1, fontSize: 28, lineHeight: 34, fontWeight: '700', color: colors.text }, children: name }), nameAccessory != null ? _jsx(View, { testID: 'profile-name-accessory', style: { flexShrink: 0 }, children: nameAccessory }) : null, onEditName ? _jsx(Pressable, { testID: 'profile-edit', accessibilityRole: 'button', accessibilityLabel: t.editName, onPress: onEditName, hitSlop: targetSlop, style: ({ pressed }) => ({ width: 44, height: 44, alignItems: 'center', justifyContent: 'center', opacity: pressed ? 0.6 : 1 }), children: _jsx(EditIcon, { color: colors.muted }) }) : null] }) : null, action ? _jsx(View, { testID: 'profile-action-row', style: { marginTop: 16 }, children: _jsx(Button, { testID: 'profile-action', fullWidth: true, intent: action.intent ?? 'primary', disabled: action.disabled, onPress: action.onSelect, children: action.label }) }) : null, shown.length > 0 ? _jsx(View, { testID: 'profile-sections', style: { gap: 24, marginTop: 24 }, children: shown.map(section => _jsx(ListGroup, { testID: `profile-section-${section.id}`, title: section.title, children: section.rows.map(row => row.onCheckedChange ? _jsx(ProfileSwitchRow, { row: row }, row.id) : _jsx(ProfileListRow, { row: row }, row.id)) }, section.id)) }) : null, footer != null ? _jsx(View, { testID: 'profile-footer', style: { marginTop: 24 }, children: footer }) : null] });
50
+ if (stickyHeader)
51
+ return _jsx(StickyHeaderLayout, { testID: testID, headerTestID: 'profile-sticky-header', header: bar, background: stickyHeaderBackground, scrollComponent: scrollComponent, bodyStyle: { direction }, children: body });
52
+ return _jsxs(View, { testID: testID, style: { direction, padding: 16 }, children: [bar, body] });
28
53
  }
@@ -1,7 +1,8 @@
1
1
  import type { FeedbackSink, FeedbackIntent } from '@bloxwap/hig/contracts/feedback';
2
2
  import React from 'react';
3
3
  import { nativeSrgb } from '@bloxwap/hig/tokens';
4
- import { type Environment } from '@bloxwap/hig/contracts';
4
+ import { type Environment, type NumberFormatPresentation } from '@bloxwap/hig/contracts';
5
+ export type { NumberFormatPresentation } from '@bloxwap/hig/contracts';
5
6
  import { type HIGMessages } from '@bloxwap/hig/contracts/messages';
6
7
  export type { HIGMessages } from '@bloxwap/hig/contracts/messages';
7
8
  /** Direction of a host-supplied locale (for example expo-localization's `getLocales()[0]`) for `HIGProvider direction`; see #86. */
@@ -34,7 +35,8 @@ export interface HIGContext extends Environment {
34
35
  monoFontFamily?: string; /** Default Dynamic Type / font-scale cap for HIG Text; a Text prop overrides it. Leave unset for prose. */
35
36
  maxFontSizeMultiplier?: number; /** Per-script letter spacing in em for Korean and Chinese companion faces; overrides `scriptLetterSpacing`. */
36
37
  letterSpacingByScript?: Readonly<Partial<Record<'ko' | 'zh', number>>>; /** Colour space HIG paints in; defaults to `srgb` and is inherited by nested providers. Read the resolved table with `useColors()`. */
37
- colorSpace: HIGColorSpace; /** Host translations of built-in copy, merged through nested providers. Components fall back to the English export per key; read the full resolved catalog with `useMessages()`. */
38
+ colorSpace: HIGColorSpace; /** Money presentation merged under every currency format HIG draws: the blocks, BarMark, BarPnl, AssetBalanceRow, the swap pieces and the number readouts. Options a format sets itself win. Nested providers inherit it. */
39
+ numberFormat?: NumberFormatPresentation; /** Host translations of built-in copy, merged through nested providers. Components fall back to the English export per key; read the full resolved catalog with `useMessages()`. */
38
40
  messages: Readonly<Partial<HIGMessages>>;
39
41
  }
40
42
  export interface HIGProviderProps extends Partial<Omit<HIGContext, 'messages'>> {
@@ -42,8 +44,14 @@ export interface HIGProviderProps extends Partial<Omit<HIGContext, 'messages'>>
42
44
  messages?: Partial<HIGMessages>;
43
45
  }
44
46
  /** Direction defaults to the OS layout direction (I18nManager) so HIG roots never force LTR inside an RTL app. React Native 0.83 Android does not report a per-app RTL locale through I18nManager (#86): RTL hosts pass `direction={localeDirection(getLocales()[0])}`. Hosts that disallow RTL leave `direction` unset. */
45
- export declare function HIGProvider({ children, density, locale, direction, reducedMotion, onAccepted, feedback, fontFamily, fontFamilies, fontFamiliesByScript, monoFontFamily, maxFontSizeMultiplier, letterSpacingByScript, colorSpace, primaryColor, marketColors, messages }: React.PropsWithChildren<HIGProviderProps>): React.JSX.Element;
46
- export declare const useHIG: () => HIGContext;
47
+ export declare function HIGProvider({ children, density, locale, direction, reducedMotion, onAccepted, feedback, fontFamily, fontFamilies, fontFamiliesByScript, monoFontFamily, maxFontSizeMultiplier, letterSpacingByScript, colorSpace, primaryColor, marketColors, messages, numberFormat }: React.PropsWithChildren<HIGProviderProps>): React.JSX.Element;
48
+ export declare const useHIG: () => HIGContext & {
49
+ provided?: boolean;
50
+ };
51
+ /** Number options with the nearest provider's `numberFormat` merged under them; only currency formats change. */
52
+ export declare function usePresentNumber(): <T extends Intl.NumberFormatOptions | undefined>(options: T) => T;
53
+ /** The locale numbers are formatted in: the nearest provider's `numberFormat.locale`, else its `locale`. */
54
+ export declare function useNumberLocale(): string;
47
55
  /** Marks content that sits on a Surface, Dialog or sheet. HIG has no resting strokes, so wells inside step up one fill to stay visible. */
48
56
  export declare function Raised({ children }: React.PropsWithChildren): React.JSX.Element;
49
57
  /** Fills for the current elevation: `well` for inputs, tracks and neutral chips; `raised` for what sits on a well (a selected segment). On the page they are `surface` and `nested`; inside a Surface, Dialog or sheet, `nested` and `border`. */
@@ -59,4 +67,5 @@ export declare function useColorSpace(): HIGColorSpace;
59
67
  export declare function useBrandColors(): Readonly<Record<HIGTableColorRole, string>>;
60
68
  /** Complete built-in copy for the nearest HIGProvider: host translations over the English defaults. */
61
69
  export declare function useMessages(): HIGMessages;
62
- export declare function useControllable<T>(value: T | undefined, initial: T, onChange?: (value: T) => void, intent?: FeedbackIntent): [T, (next: T) => void];
70
+ /** Controlled values never silently switch to internal state. `intent: null` commits without provider feedback. */
71
+ export declare function useControllable<T>(value: T | undefined, initial: T, onChange?: (value: T) => void, intent?: FeedbackIntent | null): [T, (next: T) => void];
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { createContext, useContext, useEffect, useMemo, useState, useRef, useId } from 'react';
3
3
  import { AccessibilityInfo, I18nManager, Platform } from 'react-native';
4
4
  import { nativeSrgb, nativeDisplayP3, resolvePrimaryColor } from '@bloxwap/hig/tokens';
5
- import { defaultEnvironment } from '@bloxwap/hig/contracts';
5
+ import { defaultEnvironment, numberLocale, presentNumberFormat } from '@bloxwap/hig/contracts';
6
6
  import { defaultMessages, resolveMessages } from '@bloxwap/hig/contracts/messages';
7
7
  /** Direction of a host-supplied locale (for example expo-localization's `getLocales()[0]`) for `HIGProvider direction`; see #86. */
8
8
  export { localeDirection } from '@bloxwap/hig/contracts';
@@ -16,8 +16,18 @@ const marketColor = (value) => typeof value === 'string' && value !== '' ? value
16
16
  const srgbColors = withMarketRoles(nativeSrgb), displayP3Colors = withMarketRoles(nativeDisplayP3);
17
17
  const ColorsContext = createContext(srgbColors);
18
18
  /** Direction defaults to the OS layout direction (I18nManager) so HIG roots never force LTR inside an RTL app. React Native 0.83 Android does not report a per-app RTL locale through I18nManager (#86): RTL hosts pass `direction={localeDirection(getLocales()[0])}`. Hosts that disallow RTL leave `direction` unset. */
19
- export function HIGProvider({ children, density = 'comfortable', locale = 'en-US', direction = I18nManager.isRTL ? 'rtl' : 'ltr', reducedMotion, onAccepted, feedback, fontFamily, fontFamilies, fontFamiliesByScript, monoFontFamily, maxFontSizeMultiplier, letterSpacingByScript, colorSpace, primaryColor, marketColors, messages }) {
19
+ export function HIGProvider({ children, density, locale, direction, reducedMotion, onAccepted, feedback, fontFamily, fontFamilies, fontFamiliesByScript, monoFontFamily, maxFontSizeMultiplier, letterSpacingByScript, colorSpace, primaryColor, marketColors, messages, numberFormat }) {
20
20
  const parent = useContext(Context);
21
+ density ??= parent.density;
22
+ locale ??= parent.locale;
23
+ direction ??= parent.direction;
24
+ onAccepted ??= parent.onAccepted;
25
+ feedback ??= parent.feedback;
26
+ fontFamily ??= parent.fontFamily;
27
+ fontFamilies ??= parent.fontFamilies;
28
+ monoFontFamily ??= parent.monoFontFamily;
29
+ maxFontSizeMultiplier ??= parent.maxFontSizeMultiplier;
30
+ letterSpacingByScript ??= parent.letterSpacingByScript;
21
31
  const inherited = parent.messages;
22
32
  const resolved = useMemo(() => resolveMessages(inherited, messages), [inherited, messages]);
23
33
  const accent = primaryColor ?? parent.primaryColor;
@@ -31,9 +41,16 @@ export function HIGProvider({ children, density = 'comfortable', locale = 'en-US
31
41
  const [osReduced, setOSReduced] = useState(false);
32
42
  useEffect(() => { let alive = true; void AccessibilityInfo.isReduceMotionEnabled().then(v => { if (alive)
33
43
  setOSReduced(v); }).catch(() => { }); const sub = AccessibilityInfo.addEventListener('reduceMotionChanged', setOSReduced); return () => { alive = false; sub.remove(); }; }, []);
34
- return _jsx(Context.Provider, { value: { density, locale, direction, reducedMotion: reducedMotion ?? osReduced, onAccepted, feedback, fontFamily, fontFamilies, fontFamiliesByScript: fontFamiliesByScript ?? parent.fontFamiliesByScript, monoFontFamily, maxFontSizeMultiplier, letterSpacingByScript, colorSpace: space, primaryColor: normalized, marketColors: inheritedMarket, messages: resolved }, children: _jsx(ColorsContext.Provider, { value: colors, children: children }) });
44
+ const reduced = reducedMotion ?? (parent.provided ? parent.reducedMotion : osReduced), scripts = fontFamiliesByScript ?? parent.fontFamiliesByScript, format = numberFormat ?? parent.numberFormat;
45
+ // One context value for as long as nothing in it changes, so a provider that renders again re-renders no HIG Text or control below it.
46
+ const value = useMemo(() => ({ provided: true, density, locale, direction, reducedMotion: reduced, onAccepted, feedback, fontFamily, fontFamilies, fontFamiliesByScript: scripts, monoFontFamily, maxFontSizeMultiplier, letterSpacingByScript, colorSpace: space, primaryColor: normalized, marketColors: inheritedMarket, messages: resolved, numberFormat: format }), [density, locale, direction, reduced, onAccepted, feedback, fontFamily, fontFamilies, scripts, monoFontFamily, maxFontSizeMultiplier, letterSpacingByScript, space, normalized, inheritedMarket, resolved, format]);
47
+ return _jsx(Context.Provider, { value: value, children: _jsx(ColorsContext.Provider, { value: colors, children: children }) });
35
48
  }
36
49
  export const useHIG = () => useContext(Context);
50
+ /** Number options with the nearest provider's `numberFormat` merged under them; only currency formats change. */
51
+ export function usePresentNumber() { const { numberFormat } = useContext(Context); return useMemo(() => (options) => presentNumberFormat(options, numberFormat), [numberFormat]); }
52
+ /** The locale numbers are formatted in: the nearest provider's `numberFormat.locale`, else its `locale`. */
53
+ export function useNumberLocale() { const { locale, numberFormat } = useContext(Context); return numberLocale(locale, numberFormat); }
37
54
  const RaisedContext = createContext(false);
38
55
  /** Marks content that sits on a Surface, Dialog or sheet. HIG has no resting strokes, so wells inside step up one fill to stay visible. */
39
56
  export function Raised({ children }) { return _jsx(RaisedContext.Provider, { value: true, children: children }); }
@@ -47,21 +64,30 @@ export function useColorSpace() { return useContext(Context).colorSpace === 'dis
47
64
  export function useBrandColors() { return colorTable(useContext(Context).colorSpace); }
48
65
  /** Complete built-in copy for the nearest HIGProvider: host translations over the English defaults. */
49
66
  export function useMessages() { const overrides = useContext(Context).messages; return useMemo(() => resolveMessages({ ...defaultMessages }, overrides), [overrides]); }
67
+ /** Controlled values never silently switch to internal state. `intent: null` commits without provider feedback. */
50
68
  export function useControllable(value, initial, onChange, intent = 'selection') {
51
69
  const [internal, setInternal] = useState(initial);
52
- const current = value === undefined ? internal : value;
70
+ const controlled = useRef(value !== undefined).current, last = useRef(initial), warned = useRef(false);
71
+ if (controlled && value !== undefined)
72
+ last.current = value;
73
+ const current = controlled ? last.current : internal;
74
+ useEffect(() => { if ((value !== undefined) !== controlled && !warned.current) {
75
+ warned.current = true;
76
+ if (process.env.NODE_ENV !== 'production')
77
+ console.warn('HIG controlled state cannot change ownership after mount. Remount to reset it.');
78
+ } }, [controlled, value]);
53
79
  const { feedback } = useHIG();
54
80
  const id = useId();
55
81
  const sequence = useRef(0);
56
82
  const pending = useRef(null);
57
83
  useEffect(() => { const request = pending.current; if (!request)
58
- return; pending.current = null; if (Object.is(current, request.value)) {
84
+ return; pending.current = null; if (intent && Object.is(current, request.value)) {
59
85
  try {
60
86
  feedback?.emit({ id: `${id}/${++sequence.current}`, source: id, intent, origin: 'native' });
61
87
  }
62
88
  catch { /* Effects remain optional. */ }
63
89
  } });
64
90
  return [current, (next) => { if (Object.is(current, next))
65
- return; pending.current = { value: next }; if (value === undefined)
91
+ return; pending.current = { value: next }; if (!controlled)
66
92
  setInternal(next); onChange?.(next); }];
67
93
  }