@bloxwap/hig 0.7.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 (246) 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 +29 -2
  31. package/contracts/dist/index.js +123 -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 +56 -2
  35. package/contracts/dist/messages.js +20 -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 +10 -1
  47. package/native/dist/account-block.js +17 -7
  48. package/native/dist/animated-number-model.d.ts +41 -1
  49. package/native/dist/animated-number-model.js +201 -23
  50. package/native/dist/animated-number.d.ts +39 -1
  51. package/native/dist/animated-number.js +161 -16
  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 +3 -1
  55. package/native/dist/asset-balance-row.js +15 -4
  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 +2 -0
  65. package/native/dist/bar-mark.js +4 -2
  66. package/native/dist/bar-pnl.js +2 -1
  67. package/native/dist/blocks.d.ts +6 -1
  68. package/native/dist/blocks.js +5 -0
  69. package/native/dist/brand.js +2 -1
  70. package/native/dist/button.d.ts +7 -2
  71. package/native/dist/button.js +13 -3
  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.js +2 -0
  78. package/native/dist/explainer-block.d.ts +91 -0
  79. package/native/dist/explainer-block.js +34 -0
  80. package/native/dist/field.d.ts +5 -1
  81. package/native/dist/field.js +27 -6
  82. package/native/dist/gesture-sheet-model.d.ts +50 -0
  83. package/native/dist/gesture-sheet-model.js +105 -0
  84. package/native/dist/gesture-sheet-next.d.ts +82 -0
  85. package/native/dist/gesture-sheet-next.js +315 -0
  86. package/native/dist/gesture-sheet.d.ts +5 -1
  87. package/native/dist/gesture-sheet.js +13 -6
  88. package/native/dist/icons.d.ts +9 -6
  89. package/native/dist/icons.js +25 -24
  90. package/native/dist/language-block.d.ts +10 -1
  91. package/native/dist/language-block.js +11 -4
  92. package/native/dist/list-group.d.ts +3 -1
  93. package/native/dist/list-group.js +26 -13
  94. package/native/dist/manage-position-block.d.ts +8 -1
  95. package/native/dist/manage-position-block.js +7 -2
  96. package/native/dist/market-row.js +19 -8
  97. package/native/dist/navigation.js +5 -3
  98. package/native/dist/number-format.d.ts +6 -0
  99. package/native/dist/number-format.js +9 -0
  100. package/native/dist/pickers.d.ts +8 -0
  101. package/native/dist/pickers.js +3 -3
  102. package/native/dist/position-block.d.ts +5 -5
  103. package/native/dist/preset-group.d.ts +31 -0
  104. package/native/dist/preset-group.js +39 -0
  105. package/native/dist/preset-picker-block.d.ts +107 -0
  106. package/native/dist/preset-picker-block.js +43 -0
  107. package/native/dist/profile-block.d.ts +10 -1
  108. package/native/dist/profile-block.js +8 -3
  109. package/native/dist/provider.d.ts +5 -2
  110. package/native/dist/provider.js +27 -5
  111. package/native/dist/qr-code.d.ts +33 -0
  112. package/native/dist/qr-code.js +29 -0
  113. package/native/dist/radio-group.d.ts +19 -7
  114. package/native/dist/radio-group.js +39 -10
  115. package/native/dist/reward-block.d.ts +10 -7
  116. package/native/dist/reward-block.js +9 -4
  117. package/native/dist/screen-header.d.ts +13 -3
  118. package/native/dist/screen-header.js +12 -4
  119. package/native/dist/select.js +4 -2
  120. package/native/dist/selection.d.ts +2 -1
  121. package/native/dist/selection.js +1 -0
  122. package/native/dist/setting-switch.d.ts +1 -1
  123. package/native/dist/setting-switch.js +7 -3
  124. package/native/dist/slider.js +5 -1
  125. package/native/dist/sound-haptics-block.js +1 -1
  126. package/native/dist/status.d.ts +41 -9
  127. package/native/dist/status.js +34 -17
  128. package/native/dist/sticky-header.js +9 -1
  129. package/native/dist/swap-amount-card.d.ts +57 -0
  130. package/native/dist/swap-amount-card.js +31 -0
  131. package/native/dist/swap-panel-block.d.ts +9 -3
  132. package/native/dist/swap-panel-block.js +59 -33
  133. package/native/dist/swap-parts.d.ts +3 -10
  134. package/native/dist/swap-parts.js +22 -24
  135. package/native/dist/swap-shared.d.ts +2 -2
  136. package/native/dist/swap-shared.js +10 -6
  137. package/native/dist/swap-views.js +1 -1
  138. package/native/dist/target-block.d.ts +7 -1
  139. package/native/dist/target-block.js +13 -6
  140. package/native/dist/toast.d.ts +47 -0
  141. package/native/dist/toast.js +386 -0
  142. package/native/dist/token-action-block.d.ts +10 -1
  143. package/native/dist/token-action-block.js +9 -4
  144. package/native/dist/trade-history-list-block.js +7 -4
  145. package/native/dist/wallet-address-core.js +6 -3
  146. package/native-fonts/README.md +1 -1
  147. package/og-fonts/README.md +1 -1
  148. package/package.json +111 -2
  149. package/react/README.md +3 -1
  150. package/react/dist/animated-number-flow.d.ts +72 -0
  151. package/react/dist/animated-number-flow.js +316 -0
  152. package/react/dist/animated-number-model.d.ts +18 -0
  153. package/react/dist/animated-number-model.js +75 -5
  154. package/react/dist/animated-number.d.ts +45 -1
  155. package/react/dist/animated-number.js +137 -6
  156. package/react/dist/asset-balance-row.d.ts +3 -1
  157. package/react/dist/asset-balance-row.js +10 -4
  158. package/react/dist/async-result.d.ts +2 -0
  159. package/react/dist/async-result.js +11 -0
  160. package/react/dist/avatar.d.ts +25 -0
  161. package/react/dist/avatar.js +50 -0
  162. package/react/dist/blocks/account-block.d.ts +5 -1
  163. package/react/dist/blocks/account-block.js +11 -6
  164. package/react/dist/blocks/assets-block.d.ts +106 -0
  165. package/react/dist/blocks/assets-block.js +135 -0
  166. package/react/dist/blocks/confirm-block.d.ts +91 -0
  167. package/react/dist/blocks/confirm-block.js +31 -0
  168. package/react/dist/blocks/explainer-block.d.ts +80 -0
  169. package/react/dist/blocks/explainer-block.js +20 -0
  170. package/react/dist/blocks/install-command.js +3 -1
  171. package/react/dist/blocks/language-block.d.ts +5 -1
  172. package/react/dist/blocks/language-block.js +4 -3
  173. package/react/dist/blocks/manage-position-block.d.ts +3 -1
  174. package/react/dist/blocks/manage-position-block.js +2 -2
  175. package/react/dist/blocks/market-row.js +8 -3
  176. package/react/dist/blocks/notifications-block.d.ts +3 -1
  177. package/react/dist/blocks/notifications-block.js +2 -2
  178. package/react/dist/blocks/pickers.d.ts +9 -0
  179. package/react/dist/blocks/pickers.js +4 -2
  180. package/react/dist/blocks/position-block.d.ts +3 -3
  181. package/react/dist/blocks/preset-picker-block.d.ts +85 -0
  182. package/react/dist/blocks/preset-picker-block.js +19 -0
  183. package/react/dist/blocks/profile-block.d.ts +5 -1
  184. package/react/dist/blocks/profile-block.js +12 -13
  185. package/react/dist/blocks/reward-block.d.ts +13 -8
  186. package/react/dist/blocks/reward-block.js +7 -4
  187. package/react/dist/blocks/screen-header.d.ts +10 -2
  188. package/react/dist/blocks/screen-header.js +7 -4
  189. package/react/dist/blocks/setting-switch.js +6 -3
  190. package/react/dist/blocks/signals-block.d.ts +3 -1
  191. package/react/dist/blocks/signals-block.js +4 -3
  192. package/react/dist/blocks/sound-haptics-block.d.ts +3 -1
  193. package/react/dist/blocks/sound-haptics-block.js +2 -2
  194. package/react/dist/blocks/sticky-header.d.ts +14 -4
  195. package/react/dist/blocks/sticky-header.js +68 -8
  196. package/react/dist/blocks/swap/settings.js +2 -1
  197. package/react/dist/blocks/swap/shared.d.ts +22 -22
  198. package/react/dist/blocks/swap/shared.js +30 -28
  199. package/react/dist/blocks/swap-panel-block.d.ts +10 -3
  200. package/react/dist/blocks/swap-panel-block.js +71 -36
  201. package/react/dist/blocks/target-block.d.ts +7 -1
  202. package/react/dist/blocks/target-block.js +10 -4
  203. package/react/dist/blocks/token-action-block.d.ts +5 -1
  204. package/react/dist/blocks/token-action-block.js +2 -2
  205. package/react/dist/blocks/trade-history-detail-block.d.ts +3 -1
  206. package/react/dist/blocks/trade-history-detail-block.js +2 -2
  207. package/react/dist/blocks/trade-history-list-block.d.ts +3 -1
  208. package/react/dist/blocks/trade-history-list-block.js +7 -4
  209. package/react/dist/blocks.d.ts +5 -1
  210. package/react/dist/blocks.js +4 -0
  211. package/react/dist/brand.js +2 -1
  212. package/react/dist/button.d.ts +9 -3
  213. package/react/dist/button.js +8 -3
  214. package/react/dist/confetti.d.ts +27 -0
  215. package/react/dist/confetti.js +240 -0
  216. package/react/dist/data.js +8 -1
  217. package/react/dist/field.d.ts +6 -1
  218. package/react/dist/field.js +18 -9
  219. package/react/dist/gesture-sheet.d.ts +15 -1
  220. package/react/dist/gesture-sheet.js +53 -8
  221. package/react/dist/list-group.js +11 -7
  222. package/react/dist/navigation.js +11 -3
  223. package/react/dist/overlay.d.ts +28 -3
  224. package/react/dist/overlay.js +29 -3
  225. package/react/dist/preset-group.d.ts +30 -0
  226. package/react/dist/preset-group.js +13 -0
  227. package/react/dist/provider.d.ts +2 -2
  228. package/react/dist/provider.js +23 -6
  229. package/react/dist/qr-code.d.ts +32 -0
  230. package/react/dist/qr-code.js +28 -0
  231. package/react/dist/select.js +10 -3
  232. package/react/dist/selection.d.ts +13 -5
  233. package/react/dist/selection.js +13 -8
  234. package/react/dist/slider.js +5 -1
  235. package/react/dist/status.d.ts +14 -10
  236. package/react/dist/status.js +17 -9
  237. package/react/dist/styles.css +238 -163
  238. package/react/dist/toast.d.ts +19 -12
  239. package/react/dist/toast.js +29 -7
  240. package/react/dist/wallet-address-core.d.ts +8 -4
  241. package/react/dist/wallet-address-core.js +10 -5
  242. package/tokens/README.md +2 -2
  243. package/tokens/dist/index.d.ts +16 -0
  244. package/tokens/dist/index.js +16 -0
  245. package/tokens/dist/manifest.json +8 -0
  246. package/tokens/dist/tokens.css +6 -0
@@ -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,9 +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
- export function SegmentedControl({ label, options, value, defaultValue = '', disabled, hideLabel, testID, 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');
22
27
  const [current, set] = useControllable(value, defaultValue, onValueChange);
23
28
  const { direction, locale, reducedMotion, density } = useHIG();
24
29
  const colors = useColors();
@@ -50,15 +55,17 @@ export function SegmentedControl({ label, options, value, defaultValue = '', dis
50
55
  const checked = current === option.value, blocked = !!disabled || !!option.disabled;
51
56
  const activate = () => { if (!blocked)
52
57
  set(option.value); };
53
- 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')
54
- 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 }));
55
62
  })] }) })] });
56
63
  }
57
64
  /** Chips are 40dp; the slop restores a 44dp touch target. */
58
65
  const filterSlop = { top: 2, bottom: 2 };
59
66
  const hiddenMark = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', pointerEvents: 'none' };
60
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. */
61
- function FilterChip({ option, checked, blocked, reducedMotion, onSelect }) {
68
+ function FilterChip({ option, checked, blocked, reducedMotion, onSelect, onLayout }) {
62
69
  const colors = useColors();
63
70
  const fills = useFills();
64
71
  const progress = useRef(new Animated.Value(checked ? 1 : 0)).current;
@@ -80,11 +87,33 @@ function FilterChip({ option, checked, blocked, reducedMotion, onSelect }) {
80
87
  const activate = () => { if (!blocked)
81
88
  onSelect(); };
82
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')
83
- 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 })] });
84
91
  }
85
- /** A horizontal, scrolling row of single-choice filter chips. The selected chip inverts and its circle shows a check that animates in. */
86
- export function Filter({ label, options, value, defaultValue = '', disabled, onValueChange, scrollComponent: Scroll = ScrollView }) {
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');
87
99
  const [current, set] = useControllable(value, defaultValue, onValueChange);
88
100
  const { direction, reducedMotion } = useHIG();
89
- return _jsx(Scroll, { 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)) });
90
119
  }
@@ -11,14 +11,16 @@ export interface RewardPromo {
11
11
  label: string;
12
12
  onSelect: () => void;
13
13
  };
14
- /** The headline figure: the pool so far, or the top prize. `null` reads as unknown. */
15
- amount: number | null;
16
- /** 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. */
17
19
  amountOptions?: Intl.NumberFormatOptions;
18
- /** 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`). */
19
21
  goal?: number;
20
- /** The line under the figure. A function receives the formatted goal: `goal => 'of ' + goal + ' prize pool'`. A string is drawn as given: top prize. */
21
- caption?: string | ((goal: string) => 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);
22
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. */
23
25
  headline?: React.ReactNode;
24
26
  /** Continues the sentence after the headline in the muted colour: Funded by builder fees on every trade. */
@@ -102,7 +104,8 @@ export interface RewardBlockProps {
102
104
  listTitle?: string;
103
105
  /** The column heading over the scores: Entries. */
104
106
  scoreTitle?: string;
105
- entries: readonly RewardEntry[];
107
+ /** The standings, in order. Leave them out for a promotion-only pane: no list is drawn. */
108
+ entries?: readonly RewardEntry[];
106
109
  /** Format of every score. Defaults to a whole number. An entry's own `scoreOptions` wins. */
107
110
  scoreOptions?: Intl.NumberFormatOptions;
108
111
  /** Words for the verified mark, read after the name. */
@@ -1,6 +1,6 @@
1
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
5
  import { useColors, useFills, useHIG, useNumberLocale, usePresentNumber } from './provider.js';
6
6
  import { Surface, Text } from './surface.js';
@@ -14,6 +14,7 @@ import { StickyHeaderLayout } from './sticky-header.js';
14
14
  import { figureProps } from './figure.js';
15
15
  const wholeDollars = { style: 'currency', currency: 'USD', maximumFractionDigits: 0 };
16
16
  const whole = { maximumFractionDigits: 0 };
17
+ const noEntries = [];
17
18
  const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
18
19
  const avatar = 40, space = ' ';
19
20
  /** The share of the goal reached, from 0 to 1. Unknown amounts and goals that are not above zero give `null`. */
@@ -21,12 +22,16 @@ export function rewardProgress(amount, goal) {
21
22
  return amount == null || goal == null || !Number.isFinite(amount) || !Number.isFinite(goal) || !(goal > 0) ? null : Math.min(1, Math.max(0, amount / goal));
22
23
  }
23
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. */
24
- export function RewardBlock({ title, promo, tabs, you, youLabel, status, listTitle, scoreTitle, entries, scoreOptions = whole, verifiedLabel, verifiedMark, verifiedMarkInteractive, loading, loadingLabel, pagination, footnote, onBack, headerAction, stickyHeader, stickyHeaderBackground, scrollComponent, header: showHeader = true, testID }) {
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 }) {
25
26
  const colors = useColors(), fills = useFills(), { direction, monoFontFamily } = useHIG(), locale = useNumberLocale(), present = usePresentNumber();
26
27
  const prefix = testID ?? 'reward', tid = (part) => `${prefix}-${part}`;
27
- const money = promo?.amountOptions ?? wholeDollars, reached = promo ? rewardProgress(promo.amount, promo.goal) : null;
28
+ const amount = promo?.amount, money = promo?.amountOptions ?? wholeDollars, reached = promo ? rewardProgress(typeof amount === 'string' ? null : amount, promo.goal) : null;
28
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;
29
33
  const caps = { fontFamily: monoFontFamily, fontSize: 12, lineHeight: 16, letterSpacing: 1.5, textTransform: 'uppercase' };
34
+ const figureStyle = { fontSize: 44, lineHeight: 50, fontWeight: '700', letterSpacing: -0.9 }, captionStyle = { fontFamily: monoFontFamily, fontSize: 15, lineHeight: 22, color: colors.muted };
30
35
  const standing = (entry, id, style, lead) => {
31
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;
32
37
  const said = figure ? formatNumberReadout(figure.value, locale, present(figure.options), figure.formattedValue, figure.prefix, figure.suffix).text : detail;
@@ -44,7 +49,7 @@ export function RewardBlock({ title, promo, tabs, you, youLabel, status, listTit
44
49
  const small = { fontSize: 14, lineHeight: 21, color: colors.muted };
45
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;
46
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;
47
- 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] }), _jsxs(View, { testID: tid('amount'), accessible: true, accessibilityLabel: [formatNumberReadout(promo.amount, locale, present(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: tid('caption'), style: { fontFamily: monoFontFamily, fontSize: 15, lineHeight: 22, color: colors.muted }, children: caption }) : 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] });
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] });
48
53
  if (!showHeader)
49
54
  return _jsx(View, { testID: testID, style: { padding: 16, paddingTop: 0 }, children: body });
50
55
  if (stickyHeader)
@@ -23,27 +23,37 @@ export interface ScreenHeaderProps {
23
23
  titleRef?: React.Ref<React.ComponentRef<typeof View>>;
24
24
  /** Short host text in a badge beside the title, read as part of the heading after a pause: Demo. */
25
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;
26
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. */
27
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;
28
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. */
29
33
  stickyHeader?: boolean;
30
34
  /** With `stickyHeader`: content has scrolled under the header, so it draws its fill. */
31
35
  scrolled?: boolean;
32
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`). */
33
37
  stickyHeaderBackground?: string;
34
- /** Style of the header's container, such as padding when it sits in a scroller's sticky slot. */
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`. */
35
41
  style?: StyleProp<ViewStyle>;
36
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
+ };
37
47
  /** The block header's Close control, shared by the blocks that draw one. */
38
48
  export declare function HeaderClose({ onClose, label, testID, closeProps }: {
39
49
  onClose: () => void;
40
50
  label: string;
41
51
  testID?: string;
42
- closeProps?: ScreenHeaderControlProps;
52
+ closeProps?: HeaderCloseProps;
43
53
  }): React.JSX.Element;
44
54
  /**
45
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
46
56
  * edge. The settings blocks (Notifications, Signals, Sound & Haptics) draw it; the other native blocks draw a header that matches
47
57
  * it. Import it from `@bloxwap/hig/native/screen-header` for a host pane that has no block.
48
58
  */
49
- export declare function ScreenHeader({ title, onBack, backDisabled, backProps, action, testID, headingId, titleRef, badge, hideTitle, stickyHeader, scrolled, stickyHeaderBackground, style }: ScreenHeaderProps): React.JSX.Element;
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;
@@ -10,20 +10,28 @@ export { ChevronIcon } from './icons.js';
10
10
  export { useStickyHeaderScroll } from './sticky-header.js';
11
11
  /** The block header's Close control, shared by the blocks that draw one. */
12
12
  export function HeaderClose({ onClose, label, testID, closeProps }) {
13
- const colors = useColors();
14
- return _jsx(IconButton, { ...closeProps, intent: 'ghost', label: label, suppressFeedback: true, testID: testID, onPress: onClose, children: _jsx(CloseIcon, { color: colors.text }) });
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
15
  }
16
16
  /**
17
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
18
  * edge. The settings blocks (Notifications, Signals, Sound & Haptics) draw it; the other native blocks draw a header that matches
19
19
  * it. Import it from `@bloxwap/hig/native/screen-header` for a host pane that has no block.
20
20
  */
21
- export function ScreenHeader({ title, onBack, backDisabled, backProps, action, testID, headingId, titleRef, badge, hideTitle, stickyHeader, scrolled, stickyHeaderBackground, style }) {
21
+ export function ScreenHeader({ title, onBack, backDisabled, backProps, action, testID, headingId, titleRef, badge, eyebrow, hideTitle, description, stickyHeader, scrolled, stickyHeaderBackground, inset, style }) {
22
22
  const colors = useColors(), t = useMessages(), { direction } = useHIG();
23
23
  const id = (part) => testID === undefined ? undefined : `${testID}-${part}`;
24
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
25
  const ink = hideTitle ? '#ffffff00' : colors.text;
26
26
  const heading = { textAlign: 'center', fontSize: 17, lineHeight: 24, fontWeight: '600', color: ink };
27
27
  const fill = stickyHeader ? stickyHeaderFill(!!scrolled, stickyHeaderBackground ?? colors.background) : undefined;
28
- return _jsxs(View, { testID: id('header'), style: [{ flexDirection: 'row', alignItems: 'center', minHeight: 44 }, fill, 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 }), badge ? _jsxs(View, { ref: titleRef, nativeID: headingId, accessible: true, accessibilityRole: 'header', accessibilityLabel: `${title}, ${badge}`, style: { flex: 1, 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', numberOfLines: 1, style: { flex: 1, ...heading }, children: title }), _jsx(View, { style: { minWidth: 44, alignItems: 'flex-end' }, children: action })] });
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;
29
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); } }) })] }); }
@@ -4,5 +4,6 @@ export { Checkbox } from './checkbox.js';
4
4
  export { RadioGroup } from './radio-group.js';
5
5
  export { Select } from './select.js';
6
6
  export { Slider } from './slider.js';
7
- export { SegmentedControl, type SegmentedControlProps } from './radio-group.js';
7
+ export { SegmentedControl, type SegmentedControlProps, type SegmentedControlOption } from './radio-group.js';
8
8
  export { Filter, type FilterOption, type FilterProps } from './radio-group.js';
9
+ export { PresetGroup, type PresetGroupProps, type PresetOption } from './preset-group.js';
@@ -5,3 +5,4 @@ export { Select } from './select.js';
5
5
  export { Slider } from './slider.js';
6
6
  export { SegmentedControl } from './radio-group.js';
7
7
  export { Filter } from './radio-group.js';
8
+ export { PresetGroup } from './preset-group.js';
@@ -22,7 +22,7 @@ export interface SettingSwitchProps {
22
22
  }
23
23
  /** One setting as a switch: the label over an optional description on the leading edge, the track on the trailing edge. The whole row is the switch; the label names it and the description is its hint. */
24
24
  export declare function SettingSwitch({ label, description, checked: requested, onCheckedChange, disabled, locked, labelAccessory, labelAccessoryLabel, testID }: SettingSwitchProps): React.JSX.Element;
25
- /** The card a setting sits in. Inside a list the cards share one rounded container, so they drop their own radius. */
25
+ /** The card a setting sits in, as on web: 4 above and below the switch's own 48dp row, and 16 at the foot when content follows the switch (a channel's body, a signal's hint or error), 12 under the switch. Inside a list the cards share one rounded container, so they drop their own radius. */
26
26
  export declare function SettingCard({ children, joined, testID }: React.PropsWithChildren<{
27
27
  joined?: boolean;
28
28
  testID?: string;
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from 'react';
2
3
  import { View } from 'react-native';
3
4
  import { useColors, useFills, useHIG } from './provider.js';
4
5
  import { Text } from './surface.js';
@@ -9,12 +10,15 @@ export function SettingSwitch({ label, description, checked: requested, onChecke
9
10
  const checked = locked ? true : requested;
10
11
  const name = _jsx(Text, { style: { fontSize: 16, lineHeight: 24, color: colors.text }, children: label });
11
12
  const named = labelAccessoryLabel && labelAccessory != null && labelAccessory !== false ? `${label}, ${labelAccessoryLabel}` : label;
12
- return _jsx(SwitchRow, { testID: testID, label: named, accessibilityHint: description, checked: checked, disabled: locked ? true : disabled, onCheckedChange: onCheckedChange, style: { minHeight: 32, opacity: disabled ? 0.5 : 1 }, children: _jsxs(View, { style: { direction, flex: 1, flexDirection: 'row', alignItems: 'flex-start', gap: 12 }, children: [_jsxs(View, { style: { flex: 1, minWidth: 0, gap: 2 }, children: [labelAccessory != null && labelAccessory !== false ? _jsxs(View, { testID: testID ? `${testID}-label` : undefined, style: { direction, flexDirection: 'row', alignItems: 'center', flexWrap: 'wrap', gap: 8 }, children: [name, labelAccessory] }) : name, description ? _jsx(Text, { style: { fontSize: 14, lineHeight: 21, color: colors.muted }, children: description }) : null] }), _jsx(View, { testID: testID ? `${testID}-track` : undefined, 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 } }) })] }) });
13
+ // As on web: the switch is a 48dp target (SwitchRow's own minimum) with 12 above and below the text, and the track sits on
14
+ // the first line. A row is 56dp in its card, 79dp with a one-line description (24 + 2 + 21 + 12 + 12, plus the card's 4 + 4).
15
+ return _jsx(SwitchRow, { testID: testID, label: named, accessibilityHint: description, checked: checked, disabled: locked ? true : disabled, onCheckedChange: onCheckedChange, style: { opacity: disabled ? 0.5 : 1 }, children: _jsxs(View, { style: { direction, flex: 1, flexDirection: 'row', alignItems: 'flex-start', gap: 12, paddingVertical: 12 }, children: [_jsxs(View, { style: { flex: 1, minWidth: 0, gap: 2 }, children: [labelAccessory != null && labelAccessory !== false ? _jsxs(View, { testID: testID ? `${testID}-label` : undefined, style: { direction, flexDirection: 'row', alignItems: 'center', flexWrap: 'wrap', gap: 8 }, children: [name, labelAccessory] }) : name, description ? _jsx(Text, { style: { fontSize: 14, lineHeight: 21, color: colors.muted }, children: description }) : null] }), _jsx(View, { testID: testID ? `${testID}-track` : undefined, 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 } }) })] }) });
13
16
  }
14
- /** The card a setting sits in. Inside a list the cards share one rounded container, so they drop their own radius. */
17
+ /** The card a setting sits in, as on web: 4 above and below the switch's own 48dp row, and 16 at the foot when content follows the switch (a channel's body, a signal's hint or error), 12 under the switch. Inside a list the cards share one rounded container, so they drop their own radius. */
15
18
  export function SettingCard({ children, joined, testID }) {
16
19
  const fills = useFills();
17
- return _jsx(View, { testID: testID, style: { gap: 12, paddingVertical: 12, paddingHorizontal: 20, borderRadius: joined ? 0 : 20, backgroundColor: fills.well }, children: children });
20
+ const extended = React.Children.toArray(children).length > 1;
21
+ return _jsx(View, { testID: testID, style: { gap: 12, paddingTop: 4, paddingBottom: extended ? 16 : 4, paddingHorizontal: 20, borderRadius: joined ? 0 : 20, backgroundColor: fills.well }, children: children });
18
22
  }
19
23
  /** The shared header of a settings screen: Back on the leading edge, the title centred, a host control on the trailing edge. */
20
24
  export { SettingHeader } from './setting-header.js';
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { numericRange } from '@bloxwap/hig/contracts';
2
3
  import { View, Platform, UIManager, requireNativeComponent } from 'react-native';
3
4
  import SliderBackend from '@react-native-community/slider';
4
5
  import * as en from '@bloxwap/hig/contracts/messages';
@@ -9,7 +10,10 @@ import { Text } from './surface.js';
9
10
  // {actionName:'setProgress',value}; without native linking (Expo Go, web, tests) the wrapper stays a plain View.
10
11
  const AndroidAdjustable = Platform.OS === 'android' && UIManager.hasViewManagerConfig?.('HIGAdjustableView') ? requireNativeComponent('HIGAdjustableView') : null;
11
12
  export function Slider({ label, value, defaultValue = 0, min = 0, max = 100, step = 1, disabled, onValueChange }) {
12
- const [current, set] = useControllable(value, defaultValue, onValueChange);
13
+ const range = numericRange(min, max, step);
14
+ const [stored, commit] = useControllable(value, defaultValue, onValueChange);
15
+ const current = range.clamp(stored);
16
+ const set = (next) => commit(range.clamp(next));
13
17
  const { messages } = useHIG();
14
18
  const colors = useColors();
15
19
  const fills = useFills();
@@ -1,6 +1,6 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { View } from 'react-native';
3
- import { formatNumber } from '@bloxwap/hig/contracts';
3
+ import { formatNumber } from './number-format.js';
4
4
  import { useColors, useFills, useHIG, useNumberLocale } from './provider.js';
5
5
  import { Text } from './surface.js';
6
6
  import { Button } from './button.js';
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { type DimensionValue, type ImageSourcePropType, type ViewProps, type TextProps } from 'react-native';
2
+ import { type AvatarFrameProps } from './avatar-frame.js';
3
+ import { type DimensionValue, type StyleProp, type ViewProps, type ViewStyle, type TextProps } from 'react-native';
3
4
  import { type AccentRole } from './roles.js';
4
5
  export type { AccentRole } from './roles.js';
5
6
  declare const severityRole: {
@@ -12,8 +13,16 @@ declare const severityRole: {
12
13
  };
13
14
  /** `note` and `tip` are documentation callout severities that reuse the info and positive token roles; `default` is the neutral variant (a faint `text` tint, title in `text`). */
14
15
  export type AlertSeverity = keyof typeof severityRole | 'default';
16
+ /** A badge's meaning, as on web: explicit, never inferred from text or a number's sign. */
17
+ export type BadgeTone = 'neutral' | 'positive' | 'negative' | 'warning' | 'info';
18
+ export interface BadgeProps {
19
+ children?: React.ReactNode; /** `positive`, `negative`, `warning` or `info` draws the label in that token role over a 15% wash of it, like web `.hig-badge[data-tone]`; `neutral` (default) keeps the well fill. */
20
+ tone?: BadgeTone; /** A 6dp status dot in the label colour on the leading edge, hidden from assistive technology. */
21
+ dot?: boolean;
22
+ testID?: string;
23
+ }
15
24
  /** Neutral chip in the dark well fill (one step lighter inside a Surface, Dialog or sheet). */
16
- export declare function Badge({ children }: React.PropsWithChildren): React.JSX.Element;
25
+ export declare function Badge({ children, tone, dot, testID }: BadgeProps): React.JSX.Element;
17
26
  /** Severity tints the fill 10% and colours the title from a token role (info/note → info, success/tip → positive, warning, error → negative; default → 6% of `text`), with no stroke or glow; `tone` swaps in another approved token role, never a raw colour. A non-string title renders inside the Heading, so pass strings or inline Text; its visible text is announced. A string or number child is drawn in a HIG `Text`. `announce` (default true) speaks the title and body when they appear or change; pass `false` for guidance that is present from the start. */
18
27
  export declare function Alert({ title, children: body, severity, tone, action, announce }: React.PropsWithChildren<{
19
28
  title: React.ReactNode;
@@ -41,6 +50,23 @@ export interface ToastProps {
41
50
  maxHeight?: DimensionValue;
42
51
  testID?: string;
43
52
  }
53
+ export interface ToastNoticeProps {
54
+ message: string;
55
+ /** A second line under the message, in regular weight. */
56
+ description?: string;
57
+ severity?: Notice['severity'];
58
+ action?: React.ReactNode;
59
+ /** Accessible name of the close control; defaults to HIGProvider `messages.dismissNotice` around the message. */
60
+ dismissName?: string;
61
+ /** Draws the close control and takes its press. Omitted, the notice has none. */
62
+ onDismiss?: () => void;
63
+ /** Sizes the capsule to its content, up to the room it has, instead of filling its parent. `Toaster` draws it this way. Default `false`. */
64
+ hug?: boolean;
65
+ /** Merged over the capsule's fill, radius and shadow. */
66
+ style?: StyleProp<ViewStyle>;
67
+ }
68
+ /** One notice as a single capsule row: severity symbol on the leading edge, message with an optional description under it, optional action, close on the trailing edge. Shared by `Toast` and the transient `Toaster` of `@bloxwap/hig/native/toast`; it announces nothing itself. */
69
+ export declare function ToastNotice({ message, description, severity, action, dismissName, onDismiss, hug, style }: ToastNoticeProps): React.JSX.Element;
44
70
  /** Each notice is one capsule row: severity symbol, message, optional action, then a close control. Compact, scrollable notices remain visible until their host removes them. */
45
71
  export declare function Toast({ notices, onDismiss, dismissLabel, maxHeight, testID }: ToastProps): React.JSX.Element;
46
72
  /** One transient notice: shown for about four seconds, replaced by the next one, dismissible, and cleared on unmount. Render it with `Toast`, which announces it. */
@@ -49,9 +75,14 @@ export declare function useTransientNotice(duration?: number): {
49
75
  show: (message: string, severity?: Notice['severity']) => void;
50
76
  dismiss: () => void;
51
77
  };
52
- export declare function Spinner({ label }: {
78
+ export interface SpinnerProps {
79
+ /** What is loading; defaults to HIGProvider `messages.loading`. */
53
80
  label?: string;
54
- }): React.JSX.Element;
81
+ /** Draws the indicator alone, for a tight spot such as a row or a button-sized slot: the label is not drawn but stays the element's accessibility label. */
82
+ hideLabel?: boolean;
83
+ testID?: string;
84
+ }
85
+ export declare function Spinner({ label, hideLabel, testID }: SpinnerProps): React.JSX.Element;
55
86
  export declare function Progress({ label, value, max, hideValue }: {
56
87
  label: string;
57
88
  value?: number;
@@ -75,11 +106,12 @@ export interface EmptyStateProps extends Omit<ViewProps, 'children'> {
75
106
  }
76
107
  /** A strokeless card, centred: icon, title, optional description, then the action. */
77
108
  export declare function EmptyState({ title, description, action, illustration, titleStyle, descriptionStyle, maxFontSizeMultiplier, ...props }: EmptyStateProps): React.JSX.Element;
78
- /** Initials sit on the dark well fill (one step lighter inside a Surface, Dialog or sheet). */
79
- export declare function Avatar({ name, source }: {
80
- name: string;
81
- source?: ImageSourcePropType;
82
- }): React.JSX.Element;
109
+ /**
110
+ * A person or account as a 40dp disc: an image, else the first two letters of the name on the well fill (one step lighter inside a Surface, Dialog or sheet).
111
+ * `size`, `square` and `decorative` are as in `@bloxwap/hig/native/avatar`, whose `Avatar` also draws a face generated from a seed; that entry needs `react-native-svg` and this one does not.
112
+ * It renders again only when one of its props changes.
113
+ */
114
+ export declare function Avatar(props: AvatarFrameProps): React.JSX.Element;
83
115
  /** The dot carries the state colour. Online and stale emit a ring that grows and fades in that colour; offline and reduced motion stay still. */
84
116
  export declare function StatusIndicator({ label, state }: {
85
117
  label: string;
@@ -1,27 +1,31 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { progressValue } from '@bloxwap/hig/contracts';
2
3
  import React, { useEffect, useRef, useState } from 'react';
3
4
  import { tokens } from '@bloxwap/hig/tokens';
4
5
  import { CloseIcon, EmptyIcon, SeverityIcon } from './icons.js';
5
6
  import { notificationDelta } from '@bloxwap/hig/contracts/announcements';
6
- import { ActivityIndicator, Animated, Easing, View, Image, ScrollView, useWindowDimensions, AccessibilityInfo, Platform } from 'react-native';
7
+ import { AvatarFrame, sameFrame } from './avatar-frame.js';
8
+ import { ActivityIndicator, Animated, Easing, View, ScrollView, useWindowDimensions, Platform } from 'react-native';
7
9
  import { Text, Heading, Surface, Stack } from './surface.js';
8
- import { formatNumber } from '@bloxwap/hig/contracts';
10
+ import { formatNumber } from './number-format.js';
9
11
  import { Button } from './button.js';
10
12
  import * as en from '@bloxwap/hig/contracts/messages';
11
13
  import { useColors, useFills, useHIG } from './provider.js';
12
14
  import { blockText, plainText } from './text-content.js';
13
15
  import { roleColor } from './roles.js';
16
+ import { speak } from './announce.js';
14
17
  const severityRole = { info: 'info', note: 'info', success: 'positive', tip: 'positive', warning: 'warning', error: 'negative' };
15
- function speak(message, severity) { if (Platform.OS === 'web' || !message)
16
- return; try {
17
- if (Platform.OS === 'ios' && typeof AccessibilityInfo.announceForAccessibilityWithOptions === 'function')
18
- AccessibilityInfo.announceForAccessibilityWithOptions(message, { queue: severity !== 'error' });
19
- else
20
- AccessibilityInfo.announceForAccessibility(message);
21
- }
22
- catch { /* The visible message and navigable text remain available. */ } }
23
18
  /** Neutral chip in the dark well fill (one step lighter inside a Surface, Dialog or sheet). */
24
- export function Badge({ children }) { const fills = useFills(); return _jsx(Text, { style: { alignSelf: 'flex-start', maxWidth: '100%', backgroundColor: fills.well, overflow: 'hidden', borderRadius: 9999, paddingVertical: 4, paddingHorizontal: 10 }, children: children }); }
19
+ export function Badge({ children, tone = 'neutral', dot, testID }) {
20
+ const fills = useFills();
21
+ const colors = useColors();
22
+ const accent = tone === 'positive' || tone === 'negative' || tone === 'warning' || tone === 'info' ? colors[tone] : undefined;
23
+ /* 15% of the role over whatever is behind, as web color-mix with transparent; a colour that is not #rrggbb blends into the well instead. */
24
+ const fill = accent ? (/^#[0-9a-f]{6}$/i.test(accent) ? `${accent}26` : tint(accent, fills.well, 0.15)) : fills.well;
25
+ const chip = { alignSelf: 'flex-start', maxWidth: '100%', backgroundColor: fill, overflow: 'hidden', borderRadius: 9999, paddingVertical: 4, paddingHorizontal: 10 };
26
+ const label = accent ? { color: accent } : null;
27
+ return dot ? _jsxs(View, { testID: testID, style: [chip, { flexDirection: 'row', alignItems: 'center', gap: 6 }], children: [_jsx(View, { accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', style: { width: 6, height: 6, borderRadius: 3, backgroundColor: accent ?? colors.text } }), _jsx(Text, { style: [label, { flexShrink: 1 }], children: children })] }) : _jsx(Text, { testID: testID, style: label ? [chip, label] : chip, children: children });
28
+ }
25
29
  /** Opaque sRGB blend of `tone` into `base` (both `#rrggbb`): the native counterpart of CSS `color-mix`. */
26
30
  const tint = (tone, base, amount) => '#' + [1, 3, 5].map(i => Math.round(parseInt(base.slice(i, i + 2), 16) * (1 - amount) + parseInt(tone.slice(i, i + 2), 16) * amount).toString(16).padStart(2, '0')).join('');
27
31
  /** Severity tints the fill 10% and colours the title from a token role (info/note → info, success/tip → positive, warning, error → negative; default → 6% of `text`), with no stroke or glow; `tone` swaps in another approved token role, never a raw colour. A non-string title renders inside the Heading, so pass strings or inline Text; its visible text is announced. A string or number child is drawn in a HIG `Text`. `announce` (default true) speaks the title and body when they appear or change; pass `false` for guidance that is present from the start. */
@@ -37,10 +41,16 @@ function useLoop(active, duration, easing = Easing.linear) { const value = useRe
37
41
  value.setValue(0);
38
42
  return;
39
43
  } const loop = Animated.loop(Animated.timing(value, { toValue: 1, duration, easing, useNativeDriver: Platform.OS !== 'web', isInteraction: false })); loop.start(); return () => loop.stop(); }, [active, duration, easing, value]); return value; }
40
- /** Each notice is one capsule row: severity symbol, message, optional action, then a close control. Compact, scrollable notices remain visible until their host removes them. */
41
- export function Toast({ notices, onDismiss, dismissLabel, maxHeight, testID }) {
44
+ /** One notice as a single capsule row: severity symbol on the leading edge, message with an optional description under it, optional action, close on the trailing edge. Shared by `Toast` and the transient `Toaster` of `@bloxwap/hig/native/toast`; it announces nothing itself. */
45
+ export function ToastNotice({ message, description, severity = 'info', action, dismissName, onDismiss, hug = false, style }) {
42
46
  const { messages, direction } = useHIG();
43
47
  const colors = useColors();
48
+ const close = onDismiss ? _jsx(Button, { intent: 'ghost', contentMode: 'custom', suppressFeedback: true, accessibilityLabel: dismissName ?? (messages.dismissNotice ?? en.dismissNotice)(message, messages.dismiss ?? en.dismiss), hitSlop: 8, onPress: onDismiss, style: { minHeight: 32, minWidth: 32, paddingHorizontal: 0, paddingVertical: 0, alignSelf: 'center' }, children: _jsx(CloseIcon, { color: colors.muted }) }) : null;
49
+ return _jsxs(View, { accessibilityLiveRegion: 'none', style: [{ direction, flexDirection: 'row', alignItems: 'center', gap: 10, minHeight: 44, paddingVertical: 6, paddingHorizontal: 12, borderRadius: 22, backgroundColor: colors.nested, boxShadow: '0 4px 16px #0006' }, style], children: [_jsx(SeverityIcon, { kind: severity, color: colors[severityRole[severity]] }), _jsxs(View, { style: hug ? { flexShrink: 1, minWidth: 0 } : { flex: 1, minWidth: 0 }, children: [_jsx(Text, { style: { fontWeight: '600' }, children: message }), description ? _jsx(Text, { children: description }) : null] }), action, close] });
50
+ }
51
+ /** Each notice is one capsule row: severity symbol, message, optional action, then a close control. Compact, scrollable notices remain visible until their host removes them. */
52
+ export function Toast({ notices, onDismiss, dismissLabel, maxHeight, testID }) {
53
+ const { messages } = useHIG();
44
54
  const { height } = useWindowDimensions();
45
55
  const dismiss = dismissLabel ?? messages.dismiss ?? en.dismiss;
46
56
  const unique = [...new Map(notices.map(n => [n.id, n])).values()];
@@ -65,7 +75,7 @@ export function Toast({ notices, onDismiss, dismissLabel, maxHeight, testID }) {
65
75
  }, [key]);
66
76
  useEffect(() => () => { if (timer.current !== null)
67
77
  clearTimeout(timer.current); }, []);
68
- return _jsxs(View, { testID: testID, style: { maxHeight: maxHeight ?? height * .6, flexShrink: 1 }, children: [_jsx(ScrollView, { style: { flexGrow: 0, flexShrink: 1 }, nestedScrollEnabled: true, keyboardShouldPersistTaps: 'handled', accessibilityLabel: messages.notifications ?? en.notifications, children: _jsx(Stack, { style: { gap: 8 }, children: unique.map(n => _jsxs(View, { accessibilityLiveRegion: 'none', style: { direction, flexDirection: 'row', alignItems: 'center', gap: 10, minHeight: 44, paddingVertical: 6, paddingHorizontal: 12, borderRadius: 22, backgroundColor: colors.nested, boxShadow: '0 4px 16px #0006' }, children: [_jsx(SeverityIcon, { kind: n.severity, color: colors[severityRole[n.severity]] }), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { style: { fontWeight: '600' }, children: n.message }), n.description ? _jsx(Text, { children: n.description }) : null] }), n.action, n.closable !== false && onDismiss ? _jsx(Button, { intent: 'ghost', contentMode: 'custom', suppressFeedback: true, accessibilityLabel: (messages.dismissNotice ?? en.dismissNotice)(n.message, dismiss), hitSlop: 8, onPress: () => onDismiss(n.id), style: { minHeight: 32, minWidth: 32, paddingHorizontal: 0, paddingVertical: 0, alignSelf: 'center' }, children: _jsx(CloseIcon, { color: colors.muted }) }) : null] }, n.id)) }) }), Platform.OS === 'web' && _jsx(Text, { accessibilityLiveRegion: 'polite', style: { position: 'absolute', width: 1, height: 1, overflow: 'hidden' }, children: announcement })] });
78
+ return _jsxs(View, { testID: testID, style: { maxHeight: maxHeight ?? height * .6, flexShrink: 1 }, children: [_jsx(ScrollView, { style: { flexGrow: 0, flexShrink: 1 }, nestedScrollEnabled: true, keyboardShouldPersistTaps: 'handled', accessibilityLabel: messages.notifications ?? en.notifications, children: _jsx(Stack, { style: { gap: 8 }, children: unique.map(n => _jsx(ToastNotice, { message: n.message, description: n.description, severity: n.severity, action: n.action, dismissName: (messages.dismissNotice ?? en.dismissNotice)(n.message, dismiss), onDismiss: n.closable !== false && onDismiss ? () => onDismiss(n.id) : undefined }, n.id)) }) }), Platform.OS === 'web' && _jsx(Text, { accessibilityLiveRegion: 'polite', style: { position: 'absolute', width: 1, height: 1, overflow: 'hidden' }, children: announcement })] });
69
79
  }
70
80
  /** One transient notice: shown for about four seconds, replaced by the next one, dismissible, and cleared on unmount. Render it with `Toast`, which announces it. */
71
81
  export function useTransientNotice(duration = 4000) {
@@ -80,8 +90,9 @@ export function useTransientNotice(duration = 4000) {
80
90
  return { notice, dismiss: () => { stop(); setNotice(null); }, show: (message, severity = 'success') => { if (!alive.current)
81
91
  return; stop(); setNotice({ id: `notice-${++sequence.current}`, message, severity }); timer.current = setTimeout(() => { timer.current = null; setNotice(null); }, duration); } };
82
92
  }
83
- export function Spinner({ label }) { const { messages } = useHIG(); const colors = useColors(); const text = label ?? messages.loading ?? en.loading; return _jsxs(View, { accessible: true, accessibilityLabel: text, children: [_jsx(ActivityIndicator, { color: colors.action }), _jsx(Text, { children: text })] }); }
93
+ export function Spinner({ label, hideLabel, testID }) { const { messages } = useHIG(); const colors = useColors(); const text = label ?? messages.loading ?? en.loading; return _jsxs(View, { testID: testID, accessible: true, accessibilityLabel: text, children: [_jsx(ActivityIndicator, { color: colors.action }), hideLabel ? null : _jsx(Text, { children: text })] }); }
84
94
  export function Progress({ label, value, max = 100, hideValue }) {
95
+ ({ value, max } = progressValue(value, max));
85
96
  const { locale, messages, direction } = useHIG();
86
97
  const colors = useColors();
87
98
  const fills = useFills();
@@ -96,8 +107,14 @@ export function EmptyState({ title, description, action, illustration, titleStyl
96
107
  const mark = illustration !== undefined ? illustration : _jsx(EmptyIcon, { color: colors.muted });
97
108
  return _jsxs(Surface, { ...props, style: [{ gap: 12, alignItems: 'center' }, props.style], children: [mark != null && _jsx(View, { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', children: mark }), _jsx(Heading, { style: [{ textAlign: 'center' }, titleStyle], maxFontSizeMultiplier: maxFontSizeMultiplier, children: title }), description ? _jsx(Text, { style: [{ textAlign: 'center', color: colors.muted }, descriptionStyle], maxFontSizeMultiplier: maxFontSizeMultiplier, children: description }) : null, action] });
98
109
  }
99
- /** Initials sit on the dark well fill (one step lighter inside a Surface, Dialog or sheet). */
100
- export function Avatar({ name, source }) { const fills = useFills(); return source ? _jsx(Image, { source: source, accessibilityLabel: name, style: { width: 40, height: 40, borderRadius: 20 } }) : _jsx(View, { accessible: true, accessibilityRole: 'image', accessibilityLabel: name, style: { width: 40, height: 40, borderRadius: 20, backgroundColor: fills.well, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { accessible: false, children: name.slice(0, 2) }) }); }
110
+ /** The Avatar frame, kept while its props are the same: a list that renders again renders no frame for the rows that did not change. */
111
+ const StillFrame = React.memo(AvatarFrame, sameFrame);
112
+ /**
113
+ * A person or account as a 40dp disc: an image, else the first two letters of the name on the well fill (one step lighter inside a Surface, Dialog or sheet).
114
+ * `size`, `square` and `decorative` are as in `@bloxwap/hig/native/avatar`, whose `Avatar` also draws a face generated from a seed; that entry needs `react-native-svg` and this one does not.
115
+ * It renders again only when one of its props changes.
116
+ */
117
+ export function Avatar(props) { return _jsx(StillFrame, { ...props }); }
101
118
  const statusRole = { online: 'positive', stale: 'warning', offline: 'muted' };
102
119
  const ringEasing = Easing.out(Easing.quad);
103
120
  /** The dot carries the state colour. Online and stale emit a ring that grows and fades in that colour; offline and reduced motion stay still. */